]>
Commit | Line | Data |
---|---|---|
8d4f9d0e | 1 | /* |
8f37356b | 2 | * Driver for the Siano SMS1xxx USB dongle |
8d4f9d0e | 3 | * |
e0f14c25 | 4 | * Author: Uri Shkolni |
85447060 MK |
5 | * |
6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. | |
8d4f9d0e ST |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify | |
09a29b77 | 9 | * it under the terms of the GNU General Public License version 2 as |
85447060 | 10 | * published by the Free Software Foundation; |
8d4f9d0e | 11 | * |
85447060 MK |
12 | * Software distributed under the License is distributed on an "AS IS" |
13 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | |
8d4f9d0e | 14 | * |
85447060 | 15 | * See the GNU General Public License for more details. |
8d4f9d0e ST |
16 | * |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | */ | |
21 | ||
2e5c1ec8 MK |
22 | #include <linux/module.h> |
23 | #include <linux/init.h> | |
24 | ||
2e5c1ec8 | 25 | #include "smscoreapi.h" |
1c11d546 | 26 | #include "sms-cards.h" |
2e5c1ec8 | 27 | |
9c59f968 MK |
28 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
29 | ||
62c7167d MK |
30 | struct smsdvb_client_t { |
31 | struct list_head entry; | |
32 | ||
33 | struct smscore_device_t *coredev; | |
34 | struct smscore_client_t *smsclient; | |
35 | ||
36 | struct dvb_adapter adapter; | |
37 | struct dvb_demux demux; | |
38 | struct dmxdev dmxdev; | |
39 | struct dvb_frontend frontend; | |
40 | ||
41 | fe_status_t fe_status; | |
42 | int fe_ber, fe_snr, fe_unc, fe_signal_strength; | |
43 | ||
44 | struct completion tune_done, stat_done; | |
45 | ||
46 | /* todo: save freq/band instead whole struct */ | |
47 | struct dvb_frontend_parameters fe_params; | |
48 | }; | |
49 | ||
c5e0bd1a AB |
50 | static struct list_head g_smsdvb_clients; |
51 | static struct mutex g_smsdvb_clientslock; | |
2e5c1ec8 | 52 | |
0c071f37 | 53 | static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) |
2e5c1ec8 | 54 | { |
18245e18 MK |
55 | struct smsdvb_client_t *client = (struct smsdvb_client_t *) context; |
56 | struct SmsMsgHdr_ST *phdr = | |
57 | (struct SmsMsgHdr_ST *)(((u8 *) cb->p) + cb->offset); | |
2e5c1ec8 | 58 | |
fa830e8a | 59 | switch (phdr->msgType) { |
82237416 MK |
60 | case MSG_SMS_DVBT_BDA_DATA: |
61 | dvb_dmx_swfilter(&client->demux, (u8 *)(phdr + 1), | |
18245e18 | 62 | cb->size - sizeof(struct SmsMsgHdr_ST)); |
82237416 MK |
63 | break; |
64 | ||
65 | case MSG_SMS_RF_TUNE_RES: | |
66 | complete(&client->tune_done); | |
67 | break; | |
2e5c1ec8 | 68 | |
82237416 MK |
69 | case MSG_SMS_GET_STATISTICS_RES: |
70 | { | |
18245e18 MK |
71 | struct SmsMsgStatisticsInfo_ST *p = |
72 | (struct SmsMsgStatisticsInfo_ST *)(phdr + 1); | |
2e5c1ec8 | 73 | |
fa830e8a | 74 | if (p->Stat.IsDemodLocked) { |
82237416 MK |
75 | client->fe_status = FE_HAS_SIGNAL | |
76 | FE_HAS_CARRIER | | |
77 | FE_HAS_VITERBI | | |
78 | FE_HAS_SYNC | | |
79 | FE_HAS_LOCK; | |
80 | ||
81 | client->fe_snr = p->Stat.SNR; | |
82 | client->fe_ber = p->Stat.BER; | |
851a9091 | 83 | client->fe_unc = p->Stat.BERErrorCount; |
2e5c1ec8 | 84 | |
82237416 MK |
85 | if (p->Stat.InBandPwr < -95) |
86 | client->fe_signal_strength = 0; | |
87 | else if (p->Stat.InBandPwr > -29) | |
88 | client->fe_signal_strength = 100; | |
89 | else | |
90 | client->fe_signal_strength = | |
91 | (p->Stat.InBandPwr + 95) * 3 / 2; | |
92 | } else { | |
93 | client->fe_status = 0; | |
94 | client->fe_snr = | |
95 | client->fe_ber = | |
851a9091 | 96 | client->fe_unc = |
82237416 | 97 | client->fe_signal_strength = 0; |
2e5c1ec8 | 98 | } |
82237416 MK |
99 | |
100 | complete(&client->stat_done); | |
101 | break; | |
102 | } } | |
2e5c1ec8 MK |
103 | |
104 | smscore_putbuffer(client->coredev, cb); | |
105 | ||
106 | return 0; | |
107 | } | |
108 | ||
0c071f37 | 109 | static void smsdvb_unregister_client(struct smsdvb_client_t *client) |
2e5c1ec8 | 110 | { |
fa830e8a | 111 | /* must be called under clientslock */ |
2e5c1ec8 MK |
112 | |
113 | list_del(&client->entry); | |
114 | ||
115 | smscore_unregister_client(client->smsclient); | |
116 | dvb_unregister_frontend(&client->frontend); | |
117 | dvb_dmxdev_release(&client->dmxdev); | |
118 | dvb_dmx_release(&client->demux); | |
119 | dvb_unregister_adapter(&client->adapter); | |
120 | kfree(client); | |
121 | } | |
122 | ||
0c071f37 | 123 | static void smsdvb_onremove(void *context) |
2e5c1ec8 MK |
124 | { |
125 | kmutex_lock(&g_smsdvb_clientslock); | |
126 | ||
18245e18 | 127 | smsdvb_unregister_client((struct smsdvb_client_t *) context); |
2e5c1ec8 MK |
128 | |
129 | kmutex_unlock(&g_smsdvb_clientslock); | |
130 | } | |
131 | ||
132 | static int smsdvb_start_feed(struct dvb_demux_feed *feed) | |
133 | { | |
18245e18 MK |
134 | struct smsdvb_client_t *client = |
135 | container_of(feed->demux, struct smsdvb_client_t, demux); | |
136 | struct SmsMsgData_ST PidMsg; | |
2e5c1ec8 | 137 | |
a0c0abcb | 138 | sms_debug("add pid %d(%x)", |
068d6c0f | 139 | feed->pid, feed->pid); |
2e5c1ec8 MK |
140 | |
141 | PidMsg.xMsgHeader.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; | |
142 | PidMsg.xMsgHeader.msgDstId = HIF_TASK; | |
143 | PidMsg.xMsgHeader.msgFlags = 0; | |
144 | PidMsg.xMsgHeader.msgType = MSG_SMS_ADD_PID_FILTER_REQ; | |
145 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); | |
146 | PidMsg.msgData[0] = feed->pid; | |
147 | ||
82237416 MK |
148 | return smsclient_sendrequest(client->smsclient, |
149 | &PidMsg, sizeof(PidMsg)); | |
2e5c1ec8 MK |
150 | } |
151 | ||
152 | static int smsdvb_stop_feed(struct dvb_demux_feed *feed) | |
153 | { | |
18245e18 MK |
154 | struct smsdvb_client_t *client = |
155 | container_of(feed->demux, struct smsdvb_client_t, demux); | |
156 | struct SmsMsgData_ST PidMsg; | |
2e5c1ec8 | 157 | |
a0c0abcb | 158 | sms_debug("remove pid %d(%x)", |
068d6c0f | 159 | feed->pid, feed->pid); |
2e5c1ec8 MK |
160 | |
161 | PidMsg.xMsgHeader.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; | |
162 | PidMsg.xMsgHeader.msgDstId = HIF_TASK; | |
163 | PidMsg.xMsgHeader.msgFlags = 0; | |
164 | PidMsg.xMsgHeader.msgType = MSG_SMS_REMOVE_PID_FILTER_REQ; | |
165 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); | |
166 | PidMsg.msgData[0] = feed->pid; | |
167 | ||
82237416 MK |
168 | return smsclient_sendrequest(client->smsclient, |
169 | &PidMsg, sizeof(PidMsg)); | |
2e5c1ec8 MK |
170 | } |
171 | ||
18245e18 | 172 | static int smsdvb_sendrequest_and_wait(struct smsdvb_client_t *client, |
a83ccdd6 MK |
173 | void *buffer, size_t size, |
174 | struct completion *completion) | |
2e5c1ec8 MK |
175 | { |
176 | int rc = smsclient_sendrequest(client->smsclient, buffer, size); | |
177 | if (rc < 0) | |
178 | return rc; | |
179 | ||
82237416 MK |
180 | return wait_for_completion_timeout(completion, |
181 | msecs_to_jiffies(2000)) ? | |
182 | 0 : -ETIME; | |
2e5c1ec8 MK |
183 | } |
184 | ||
18245e18 | 185 | static int smsdvb_send_statistics_request(struct smsdvb_client_t *client) |
2e5c1ec8 | 186 | { |
18245e18 | 187 | struct SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ, |
82237416 | 188 | DVBT_BDA_CONTROL_MSG_ID, |
18245e18 | 189 | HIF_TASK, sizeof(struct SmsMsgHdr_ST), 0 }; |
7b29e10d MK |
190 | int ret = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), |
191 | &client->stat_done); | |
192 | if (ret < 0) | |
193 | return ret; | |
194 | ||
195 | if (client->fe_status & FE_HAS_LOCK) | |
196 | sms_board_led_feedback(client->coredev, | |
197 | (client->fe_unc == 0) ? | |
198 | SMS_LED_HI : SMS_LED_LO); | |
199 | else | |
200 | sms_board_led_feedback(client->coredev, SMS_LED_OFF); | |
201 | return ret; | |
2e5c1ec8 MK |
202 | } |
203 | ||
204 | static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) | |
205 | { | |
18245e18 MK |
206 | struct smsdvb_client_t *client = |
207 | container_of(fe, struct smsdvb_client_t, frontend); | |
2e5c1ec8 MK |
208 | int rc = smsdvb_send_statistics_request(client); |
209 | ||
210 | if (!rc) | |
211 | *stat = client->fe_status; | |
212 | ||
213 | return rc; | |
214 | } | |
215 | ||
216 | static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber) | |
217 | { | |
18245e18 MK |
218 | struct smsdvb_client_t *client = |
219 | container_of(fe, struct smsdvb_client_t, frontend); | |
2e5c1ec8 MK |
220 | int rc = smsdvb_send_statistics_request(client); |
221 | ||
222 | if (!rc) | |
223 | *ber = client->fe_ber; | |
224 | ||
225 | return rc; | |
226 | } | |
227 | ||
228 | static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |
229 | { | |
18245e18 MK |
230 | struct smsdvb_client_t *client = |
231 | container_of(fe, struct smsdvb_client_t, frontend); | |
2e5c1ec8 MK |
232 | int rc = smsdvb_send_statistics_request(client); |
233 | ||
234 | if (!rc) | |
235 | *strength = client->fe_signal_strength; | |
236 | ||
237 | return rc; | |
238 | } | |
239 | ||
240 | static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr) | |
241 | { | |
18245e18 MK |
242 | struct smsdvb_client_t *client = |
243 | container_of(fe, struct smsdvb_client_t, frontend); | |
2e5c1ec8 MK |
244 | int rc = smsdvb_send_statistics_request(client); |
245 | ||
246 | if (!rc) | |
247 | *snr = client->fe_snr; | |
248 | ||
249 | return rc; | |
250 | } | |
251 | ||
851a9091 MK |
252 | static int smsdvb_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) |
253 | { | |
254 | struct smsdvb_client_t *client = | |
255 | container_of(fe, struct smsdvb_client_t, frontend); | |
256 | int rc = smsdvb_send_statistics_request(client); | |
257 | ||
258 | if (!rc) | |
259 | *ucblocks = client->fe_unc; | |
260 | ||
261 | return rc; | |
262 | } | |
263 | ||
82237416 MK |
264 | static int smsdvb_get_tune_settings(struct dvb_frontend *fe, |
265 | struct dvb_frontend_tune_settings *tune) | |
2e5c1ec8 | 266 | { |
a0c0abcb | 267 | sms_debug(""); |
2e5c1ec8 MK |
268 | |
269 | tune->min_delay_ms = 400; | |
270 | tune->step_size = 250000; | |
271 | tune->max_drift = 0; | |
272 | return 0; | |
273 | } | |
274 | ||
82237416 MK |
275 | static int smsdvb_set_frontend(struct dvb_frontend *fe, |
276 | struct dvb_frontend_parameters *fep) | |
2e5c1ec8 | 277 | { |
18245e18 MK |
278 | struct smsdvb_client_t *client = |
279 | container_of(fe, struct smsdvb_client_t, frontend); | |
2e5c1ec8 | 280 | |
18245e18 MK |
281 | struct { |
282 | struct SmsMsgHdr_ST Msg; | |
82237416 | 283 | u32 Data[3]; |
2e5c1ec8 | 284 | } Msg; |
d54093af | 285 | int ret; |
2e5c1ec8 MK |
286 | |
287 | Msg.Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; | |
288 | Msg.Msg.msgDstId = HIF_TASK; | |
289 | Msg.Msg.msgFlags = 0; | |
290 | Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ; | |
291 | Msg.Msg.msgLength = sizeof(Msg); | |
292 | Msg.Data[0] = fep->frequency; | |
293 | Msg.Data[2] = 12000000; | |
294 | ||
a0c0abcb | 295 | sms_debug("freq %d band %d", |
068d6c0f | 296 | fep->frequency, fep->u.ofdm.bandwidth); |
2e5c1ec8 | 297 | |
fa830e8a MK |
298 | switch (fep->u.ofdm.bandwidth) { |
299 | case BANDWIDTH_8_MHZ: Msg.Data[1] = BW_8_MHZ; break; | |
300 | case BANDWIDTH_7_MHZ: Msg.Data[1] = BW_7_MHZ; break; | |
301 | case BANDWIDTH_6_MHZ: Msg.Data[1] = BW_6_MHZ; break; | |
302 | case BANDWIDTH_AUTO: return -EOPNOTSUPP; | |
303 | default: return -EINVAL; | |
2e5c1ec8 MK |
304 | } |
305 | ||
d54093af MK |
306 | /* Disable LNA, if any. An error is returned if no LNA is present */ |
307 | ret = sms_board_lna_control(client->coredev, 0); | |
308 | if (ret == 0) { | |
309 | fe_status_t status; | |
310 | ||
311 | /* tune with LNA off at first */ | |
312 | ret = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), | |
313 | &client->tune_done); | |
314 | ||
315 | smsdvb_read_status(fe, &status); | |
316 | ||
317 | if (status & FE_HAS_LOCK) | |
318 | return ret; | |
319 | ||
320 | /* previous tune didnt lock - enable LNA and tune again */ | |
321 | sms_board_lna_control(client->coredev, 1); | |
322 | } | |
323 | ||
82237416 MK |
324 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), |
325 | &client->tune_done); | |
2e5c1ec8 MK |
326 | } |
327 | ||
82237416 MK |
328 | static int smsdvb_get_frontend(struct dvb_frontend *fe, |
329 | struct dvb_frontend_parameters *fep) | |
2e5c1ec8 | 330 | { |
18245e18 MK |
331 | struct smsdvb_client_t *client = |
332 | container_of(fe, struct smsdvb_client_t, frontend); | |
2e5c1ec8 | 333 | |
a0c0abcb | 334 | sms_debug(""); |
2e5c1ec8 | 335 | |
fa830e8a | 336 | /* todo: */ |
82237416 MK |
337 | memcpy(fep, &client->fe_params, |
338 | sizeof(struct dvb_frontend_parameters)); | |
7a6fbed6 MK |
339 | |
340 | return 0; | |
341 | } | |
342 | ||
343 | static int smsdvb_init(struct dvb_frontend *fe) | |
344 | { | |
345 | struct smsdvb_client_t *client = | |
346 | container_of(fe, struct smsdvb_client_t, frontend); | |
347 | ||
348 | sms_board_power(client->coredev, 1); | |
349 | ||
350 | return 0; | |
351 | } | |
352 | ||
353 | static int smsdvb_sleep(struct dvb_frontend *fe) | |
354 | { | |
355 | struct smsdvb_client_t *client = | |
356 | container_of(fe, struct smsdvb_client_t, frontend); | |
357 | ||
7b29e10d | 358 | sms_board_led_feedback(client->coredev, SMS_LED_OFF); |
7a6fbed6 MK |
359 | sms_board_power(client->coredev, 0); |
360 | ||
2e5c1ec8 MK |
361 | return 0; |
362 | } | |
363 | ||
364 | static void smsdvb_release(struct dvb_frontend *fe) | |
365 | { | |
fa830e8a | 366 | /* do nothing */ |
2e5c1ec8 MK |
367 | } |
368 | ||
369 | static struct dvb_frontend_ops smsdvb_fe_ops = { | |
370 | .info = { | |
e0f14c25 | 371 | .name = "Siano Mobile Digital MDTV Receiver", |
82237416 | 372 | .type = FE_OFDM, |
2e5c1ec8 MK |
373 | .frequency_min = 44250000, |
374 | .frequency_max = 867250000, | |
375 | .frequency_stepsize = 250000, | |
376 | .caps = FE_CAN_INVERSION_AUTO | | |
82237416 MK |
377 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | |
378 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | | |
379 | FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | | |
380 | FE_CAN_QAM_AUTO | FE_CAN_TRANSMISSION_MODE_AUTO | | |
381 | FE_CAN_GUARD_INTERVAL_AUTO | | |
382 | FE_CAN_RECOVER | | |
383 | FE_CAN_HIERARCHY_AUTO, | |
2e5c1ec8 MK |
384 | }, |
385 | ||
386 | .release = smsdvb_release, | |
387 | ||
388 | .set_frontend = smsdvb_set_frontend, | |
389 | .get_frontend = smsdvb_get_frontend, | |
390 | .get_tune_settings = smsdvb_get_tune_settings, | |
391 | ||
392 | .read_status = smsdvb_read_status, | |
393 | .read_ber = smsdvb_read_ber, | |
394 | .read_signal_strength = smsdvb_read_signal_strength, | |
395 | .read_snr = smsdvb_read_snr, | |
851a9091 | 396 | .read_ucblocks = smsdvb_read_ucblocks, |
7a6fbed6 MK |
397 | |
398 | .init = smsdvb_init, | |
399 | .sleep = smsdvb_sleep, | |
2e5c1ec8 MK |
400 | }; |
401 | ||
0c071f37 MK |
402 | static int smsdvb_hotplug(struct smscore_device_t *coredev, |
403 | struct device *device, int arrival) | |
2e5c1ec8 | 404 | { |
18245e18 MK |
405 | struct smsclient_params_t params; |
406 | struct smsdvb_client_t *client; | |
2e5c1ec8 MK |
407 | int rc; |
408 | ||
fa830e8a | 409 | /* device removal handled by onremove callback */ |
2e5c1ec8 MK |
410 | if (!arrival) |
411 | return 0; | |
412 | ||
e0f14c25 | 413 | if (smscore_get_device_mode(coredev) != DEVICE_MODE_DVBT_BDA) { |
a0c0abcb MK |
414 | sms_err("SMS Device mode is not set for " |
415 | "DVB operation."); | |
f17407a8 | 416 | return 0; |
2e5c1ec8 MK |
417 | } |
418 | ||
18245e18 | 419 | client = kzalloc(sizeof(struct smsdvb_client_t), GFP_KERNEL); |
82237416 | 420 | if (!client) { |
eb250942 | 421 | sms_err("kmalloc() failed"); |
2e5c1ec8 MK |
422 | return -ENOMEM; |
423 | } | |
424 | ||
fa830e8a | 425 | /* register dvb adapter */ |
1c11d546 MK |
426 | rc = dvb_register_adapter(&client->adapter, |
427 | sms_get_board( | |
428 | smscore_get_board_id(coredev))->name, | |
82237416 MK |
429 | THIS_MODULE, device, adapter_nr); |
430 | if (rc < 0) { | |
a0c0abcb | 431 | sms_err("dvb_register_adapter() failed %d", rc); |
2e5c1ec8 MK |
432 | goto adapter_error; |
433 | } | |
434 | ||
fa830e8a | 435 | /* init dvb demux */ |
2e5c1ec8 | 436 | client->demux.dmx.capabilities = DMX_TS_FILTERING; |
fa830e8a | 437 | client->demux.filternum = 32; /* todo: nova ??? */ |
2e5c1ec8 MK |
438 | client->demux.feednum = 32; |
439 | client->demux.start_feed = smsdvb_start_feed; | |
440 | client->demux.stop_feed = smsdvb_stop_feed; | |
441 | ||
442 | rc = dvb_dmx_init(&client->demux); | |
82237416 | 443 | if (rc < 0) { |
a0c0abcb | 444 | sms_err("dvb_dmx_init failed %d", rc); |
2e5c1ec8 MK |
445 | goto dvbdmx_error; |
446 | } | |
447 | ||
fa830e8a | 448 | /* init dmxdev */ |
2e5c1ec8 MK |
449 | client->dmxdev.filternum = 32; |
450 | client->dmxdev.demux = &client->demux.dmx; | |
451 | client->dmxdev.capabilities = 0; | |
452 | ||
453 | rc = dvb_dmxdev_init(&client->dmxdev, &client->adapter); | |
82237416 | 454 | if (rc < 0) { |
a0c0abcb | 455 | sms_err("dvb_dmxdev_init failed %d", rc); |
2e5c1ec8 MK |
456 | goto dmxdev_error; |
457 | } | |
458 | ||
fa830e8a | 459 | /* init and register frontend */ |
82237416 MK |
460 | memcpy(&client->frontend.ops, &smsdvb_fe_ops, |
461 | sizeof(struct dvb_frontend_ops)); | |
2e5c1ec8 MK |
462 | |
463 | rc = dvb_register_frontend(&client->adapter, &client->frontend); | |
82237416 | 464 | if (rc < 0) { |
a0c0abcb | 465 | sms_err("frontend registration failed %d", rc); |
2e5c1ec8 MK |
466 | goto frontend_error; |
467 | } | |
468 | ||
f17407a8 | 469 | params.initial_id = 1; |
2e5c1ec8 MK |
470 | params.data_type = MSG_SMS_DVBT_BDA_DATA; |
471 | params.onresponse_handler = smsdvb_onresponse; | |
472 | params.onremove_handler = smsdvb_onremove; | |
473 | params.context = client; | |
474 | ||
475 | rc = smscore_register_client(coredev, ¶ms, &client->smsclient); | |
82237416 | 476 | if (rc < 0) { |
eb250942 | 477 | sms_err("smscore_register_client() failed %d", rc); |
2e5c1ec8 MK |
478 | goto client_error; |
479 | } | |
480 | ||
481 | client->coredev = coredev; | |
482 | ||
483 | init_completion(&client->tune_done); | |
484 | init_completion(&client->stat_done); | |
485 | ||
486 | kmutex_lock(&g_smsdvb_clientslock); | |
487 | ||
488 | list_add(&client->entry, &g_smsdvb_clients); | |
489 | ||
490 | kmutex_unlock(&g_smsdvb_clientslock); | |
491 | ||
a0c0abcb | 492 | sms_info("success"); |
2e5c1ec8 | 493 | |
250fa674 MK |
494 | sms_board_setup(coredev); |
495 | ||
2e5c1ec8 MK |
496 | return 0; |
497 | ||
498 | client_error: | |
499 | dvb_unregister_frontend(&client->frontend); | |
500 | ||
501 | frontend_error: | |
502 | dvb_dmxdev_release(&client->dmxdev); | |
503 | ||
504 | dmxdev_error: | |
505 | dvb_dmx_release(&client->demux); | |
506 | ||
507 | dvbdmx_error: | |
508 | dvb_unregister_adapter(&client->adapter); | |
509 | ||
510 | adapter_error: | |
511 | kfree(client); | |
512 | return rc; | |
513 | } | |
514 | ||
e0f14c25 | 515 | int smsdvb_module_init(void) |
eae55660 ST |
516 | { |
517 | int rc; | |
518 | ||
519 | INIT_LIST_HEAD(&g_smsdvb_clients); | |
520 | kmutex_init(&g_smsdvb_clientslock); | |
521 | ||
522 | rc = smscore_register_hotplug(smsdvb_hotplug); | |
523 | ||
a0c0abcb | 524 | sms_debug(""); |
eae55660 ST |
525 | |
526 | return rc; | |
527 | } | |
528 | ||
e0f14c25 | 529 | void smsdvb_module_exit(void) |
eae55660 ST |
530 | { |
531 | smscore_unregister_hotplug(smsdvb_hotplug); | |
532 | ||
533 | kmutex_lock(&g_smsdvb_clientslock); | |
534 | ||
535 | while (!list_empty(&g_smsdvb_clients)) | |
82237416 | 536 | smsdvb_unregister_client( |
18245e18 | 537 | (struct smsdvb_client_t *) g_smsdvb_clients.next); |
eae55660 ST |
538 | |
539 | kmutex_unlock(&g_smsdvb_clientslock); | |
eae55660 | 540 | } |
e0f14c25 US |
541 | |
542 | module_init(smsdvb_module_init); | |
543 | module_exit(smsdvb_module_exit); | |
544 | ||
545 | MODULE_DESCRIPTION("SMS DVB subsystem adaptation module"); | |
546 | MODULE_AUTHOR("Siano Mobile Silicon, INC. (uris@siano-ms.com)"); | |
547 | MODULE_LICENSE("GPL"); |