diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2008-06-15 14:14:13 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:21:25 -0400 |
commit | 822374165d6b11733467cfa2fa18234319198233 (patch) | |
tree | f3e29319e9d1624b8c9ed8d532ec6cab0120679a /drivers/media/dvb/siano/smsdvb.c | |
parent | 73104fb3e4e692cb1f9505b548ab073b0859b256 (diff) |
V4L/DVB (8280): sms1xxx: more codingstyle cleanups
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/siano/smsdvb.c')
-rw-r--r-- | drivers/media/dvb/siano/smsdvb.c | 175 |
1 files changed, 93 insertions, 82 deletions
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c index e050e0da7900..13980fb649c4 100644 --- a/drivers/media/dvb/siano/smsdvb.c +++ b/drivers/media/dvb/siano/smsdvb.c | |||
@@ -34,47 +34,49 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb) | |||
34 | smsdvb_client_t *client = (smsdvb_client_t *) context; | 34 | smsdvb_client_t *client = (smsdvb_client_t *) context; |
35 | SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)(((u8 *) cb->p) + cb->offset); | 35 | SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)(((u8 *) cb->p) + cb->offset); |
36 | 36 | ||
37 | switch(phdr->msgType) | 37 | switch(phdr->msgType) { |
38 | { | 38 | case MSG_SMS_DVBT_BDA_DATA: |
39 | case MSG_SMS_DVBT_BDA_DATA: | 39 | dvb_dmx_swfilter(&client->demux, (u8 *)(phdr + 1), |
40 | dvb_dmx_swfilter(&client->demux, (u8 *)(phdr + 1), | 40 | cb->size - sizeof(SmsMsgHdr_ST)); |
41 | cb->size - sizeof(SmsMsgHdr_ST)); | 41 | break; |
42 | break; | 42 | |
43 | case MSG_SMS_RF_TUNE_RES: | ||
44 | complete(&client->tune_done); | ||
45 | break; | ||
43 | 46 | ||
44 | case MSG_SMS_RF_TUNE_RES: | 47 | case MSG_SMS_GET_STATISTICS_RES: |
45 | complete(&client->tune_done); | 48 | { |
46 | break; | 49 | SmsMsgStatisticsInfo_ST *p = |
50 | (SmsMsgStatisticsInfo_ST *)(phdr + 1); | ||
47 | 51 | ||
48 | case MSG_SMS_GET_STATISTICS_RES: | 52 | if (p->Stat.IsDemodLocked) |
49 | { | 53 | { |
50 | SmsMsgStatisticsInfo_ST *p = | 54 | client->fe_status = FE_HAS_SIGNAL | |
51 | (SmsMsgStatisticsInfo_ST *)(phdr + 1); | 55 | FE_HAS_CARRIER | |
52 | 56 | FE_HAS_VITERBI | | |
53 | if (p->Stat.IsDemodLocked) | 57 | FE_HAS_SYNC | |
54 | { | 58 | FE_HAS_LOCK; |
55 | client->fe_status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; | 59 | |
56 | client->fe_snr = p->Stat.SNR; | 60 | client->fe_snr = p->Stat.SNR; |
57 | client->fe_ber = p->Stat.BER; | 61 | client->fe_ber = p->Stat.BER; |
58 | |||
59 | if (p->Stat.InBandPwr < -95) | ||
60 | client->fe_signal_strength = 0; | ||
61 | else if (p->Stat.InBandPwr > -29) | ||
62 | client->fe_signal_strength = 100; | ||
63 | else | ||
64 | client->fe_signal_strength = (p->Stat.InBandPwr + 95) * 3 / 2; | ||
65 | } | ||
66 | else | ||
67 | { | ||
68 | client->fe_status = 0; | ||
69 | client->fe_snr = | ||
70 | client->fe_ber = | ||
71 | client->fe_signal_strength = 0; | ||
72 | } | ||
73 | 62 | ||
74 | complete(&client->stat_done); | 63 | if (p->Stat.InBandPwr < -95) |
75 | break; | 64 | client->fe_signal_strength = 0; |
65 | else if (p->Stat.InBandPwr > -29) | ||
66 | client->fe_signal_strength = 100; | ||
67 | else | ||
68 | client->fe_signal_strength = | ||
69 | (p->Stat.InBandPwr + 95) * 3 / 2; | ||
70 | } else { | ||
71 | client->fe_status = 0; | ||
72 | client->fe_snr = | ||
73 | client->fe_ber = | ||
74 | client->fe_signal_strength = 0; | ||
76 | } | 75 | } |
77 | } | 76 | |
77 | complete(&client->stat_done); | ||
78 | break; | ||
79 | } } | ||
78 | 80 | ||
79 | smscore_putbuffer(client->coredev, cb); | 81 | smscore_putbuffer(client->coredev, cb); |
80 | 82 | ||
@@ -106,7 +108,8 @@ void smsdvb_onremove(void *context) | |||
106 | 108 | ||
107 | static int smsdvb_start_feed(struct dvb_demux_feed *feed) | 109 | static int smsdvb_start_feed(struct dvb_demux_feed *feed) |
108 | { | 110 | { |
109 | smsdvb_client_t *client = container_of(feed->demux, smsdvb_client_t, demux); | 111 | smsdvb_client_t *client = |
112 | container_of(feed->demux, smsdvb_client_t, demux); | ||
110 | SmsMsgData_ST PidMsg; | 113 | SmsMsgData_ST PidMsg; |
111 | 114 | ||
112 | printk("%s add pid %d(%x)\n", __func__, feed->pid, feed->pid); | 115 | printk("%s add pid %d(%x)\n", __func__, feed->pid, feed->pid); |
@@ -118,12 +121,14 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed) | |||
118 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); | 121 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); |
119 | PidMsg.msgData[0] = feed->pid; | 122 | PidMsg.msgData[0] = feed->pid; |
120 | 123 | ||
121 | return smsclient_sendrequest(client->smsclient, &PidMsg, sizeof(PidMsg)); | 124 | return smsclient_sendrequest(client->smsclient, |
125 | &PidMsg, sizeof(PidMsg)); | ||
122 | } | 126 | } |
123 | 127 | ||
124 | static int smsdvb_stop_feed(struct dvb_demux_feed *feed) | 128 | static int smsdvb_stop_feed(struct dvb_demux_feed *feed) |
125 | { | 129 | { |
126 | smsdvb_client_t *client = container_of(feed->demux, smsdvb_client_t, demux); | 130 | smsdvb_client_t *client = |
131 | container_of(feed->demux, smsdvb_client_t, demux); | ||
127 | SmsMsgData_ST PidMsg; | 132 | SmsMsgData_ST PidMsg; |
128 | 133 | ||
129 | printk("%s remove pid %d(%x)\n", __func__, feed->pid, feed->pid); | 134 | printk("%s remove pid %d(%x)\n", __func__, feed->pid, feed->pid); |
@@ -135,7 +140,8 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed) | |||
135 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); | 140 | PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); |
136 | PidMsg.msgData[0] = feed->pid; | 141 | PidMsg.msgData[0] = feed->pid; |
137 | 142 | ||
138 | return smsclient_sendrequest(client->smsclient, &PidMsg, sizeof(PidMsg)); | 143 | return smsclient_sendrequest(client->smsclient, |
144 | &PidMsg, sizeof(PidMsg)); | ||
139 | } | 145 | } |
140 | 146 | ||
141 | static int smsdvb_sendrequest_and_wait(smsdvb_client_t *client, | 147 | static int smsdvb_sendrequest_and_wait(smsdvb_client_t *client, |
@@ -146,13 +152,18 @@ static int smsdvb_sendrequest_and_wait(smsdvb_client_t *client, | |||
146 | if (rc < 0) | 152 | if (rc < 0) |
147 | return rc; | 153 | return rc; |
148 | 154 | ||
149 | return wait_for_completion_timeout(completion, msecs_to_jiffies(2000)) ? 0 : -ETIME; | 155 | return wait_for_completion_timeout(completion, |
156 | msecs_to_jiffies(2000)) ? | ||
157 | 0 : -ETIME; | ||
150 | } | 158 | } |
151 | 159 | ||
152 | static int smsdvb_send_statistics_request(smsdvb_client_t *client) | 160 | static int smsdvb_send_statistics_request(smsdvb_client_t *client) |
153 | { | 161 | { |
154 | SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ, DVBT_BDA_CONTROL_MSG_ID, HIF_TASK, sizeof(SmsMsgHdr_ST), 0 }; | 162 | SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ, |
155 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), &client->stat_done); | 163 | DVBT_BDA_CONTROL_MSG_ID, |
164 | HIF_TASK, sizeof(SmsMsgHdr_ST), 0 }; | ||
165 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), | ||
166 | &client->stat_done); | ||
156 | } | 167 | } |
157 | 168 | ||
158 | static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) | 169 | static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) |
@@ -199,7 +210,8 @@ static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr) | |||
199 | return rc; | 210 | return rc; |
200 | } | 211 | } |
201 | 212 | ||
202 | static int smsdvb_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings *tune) | 213 | static int smsdvb_get_tune_settings(struct dvb_frontend *fe, |
214 | struct dvb_frontend_tune_settings *tune) | ||
203 | { | 215 | { |
204 | printk("%s\n", __func__); | 216 | printk("%s\n", __func__); |
205 | 217 | ||
@@ -209,14 +221,15 @@ static int smsdvb_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend | |||
209 | return 0; | 221 | return 0; |
210 | } | 222 | } |
211 | 223 | ||
212 | static int smsdvb_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) | 224 | static int smsdvb_set_frontend(struct dvb_frontend *fe, |
225 | struct dvb_frontend_parameters *fep) | ||
213 | { | 226 | { |
214 | smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); | 227 | smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); |
215 | 228 | ||
216 | struct | 229 | struct |
217 | { | 230 | { |
218 | SmsMsgHdr_ST Msg; | 231 | SmsMsgHdr_ST Msg; |
219 | u32 Data[3]; | 232 | u32 Data[3]; |
220 | } Msg; | 233 | } Msg; |
221 | 234 | ||
222 | Msg.Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; | 235 | Msg.Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; |
@@ -227,29 +240,32 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_para | |||
227 | Msg.Data[0] = fep->frequency; | 240 | Msg.Data[0] = fep->frequency; |
228 | Msg.Data[2] = 12000000; | 241 | Msg.Data[2] = 12000000; |
229 | 242 | ||
230 | printk("%s freq %d band %d\n", __func__, fep->frequency, fep->u.ofdm.bandwidth); | 243 | printk("%s freq %d band %d\n", __func__, |
244 | fep->frequency, fep->u.ofdm.bandwidth); | ||
231 | 245 | ||
232 | switch(fep->u.ofdm.bandwidth) | 246 | switch(fep->u.ofdm.bandwidth) |
233 | { | 247 | { |
234 | case BANDWIDTH_8_MHZ: Msg.Data[1] = BW_8_MHZ; break; | 248 | case BANDWIDTH_8_MHZ: Msg.Data[1] = BW_8_MHZ; break; |
235 | case BANDWIDTH_7_MHZ: Msg.Data[1] = BW_7_MHZ; break; | 249 | case BANDWIDTH_7_MHZ: Msg.Data[1] = BW_7_MHZ; break; |
236 | case BANDWIDTH_6_MHZ: Msg.Data[1] = BW_6_MHZ; break; | 250 | case BANDWIDTH_6_MHZ: Msg.Data[1] = BW_6_MHZ; break; |
237 | // case BANDWIDTH_5_MHZ: Msg.Data[1] = BW_5_MHZ; break; | ||
238 | case BANDWIDTH_AUTO: return -EOPNOTSUPP; | 251 | case BANDWIDTH_AUTO: return -EOPNOTSUPP; |
239 | default: return -EINVAL; | 252 | default: return -EINVAL; |
240 | } | 253 | } |
241 | 254 | ||
242 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), &client->tune_done); | 255 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), |
256 | &client->tune_done); | ||
243 | } | 257 | } |
244 | 258 | ||
245 | static int smsdvb_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) | 259 | static int smsdvb_get_frontend(struct dvb_frontend *fe, |
260 | struct dvb_frontend_parameters *fep) | ||
246 | { | 261 | { |
247 | smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); | 262 | smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); |
248 | 263 | ||
249 | printk("%s\n", __func__); | 264 | printk("%s\n", __func__); |
250 | 265 | ||
251 | // todo: | 266 | // todo: |
252 | memcpy(fep, &client->fe_params, sizeof(struct dvb_frontend_parameters)); | 267 | memcpy(fep, &client->fe_params, |
268 | sizeof(struct dvb_frontend_parameters)); | ||
253 | return 0; | 269 | return 0; |
254 | } | 270 | } |
255 | 271 | ||
@@ -260,19 +276,19 @@ static void smsdvb_release(struct dvb_frontend *fe) | |||
260 | 276 | ||
261 | static struct dvb_frontend_ops smsdvb_fe_ops = { | 277 | static struct dvb_frontend_ops smsdvb_fe_ops = { |
262 | .info = { | 278 | .info = { |
263 | .name = "Siano Mobile Digital SMS10xx", | 279 | .name = "Siano Mobile Digital SMS10xx", |
264 | .type = FE_OFDM, | 280 | .type = FE_OFDM, |
265 | .frequency_min = 44250000, | 281 | .frequency_min = 44250000, |
266 | .frequency_max = 867250000, | 282 | .frequency_max = 867250000, |
267 | .frequency_stepsize = 250000, | 283 | .frequency_stepsize = 250000, |
268 | .caps = FE_CAN_INVERSION_AUTO | | 284 | .caps = FE_CAN_INVERSION_AUTO | |
269 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | | 285 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | |
270 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | | 286 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | |
271 | FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | | 287 | FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | |
272 | FE_CAN_TRANSMISSION_MODE_AUTO | | 288 | FE_CAN_QAM_AUTO | FE_CAN_TRANSMISSION_MODE_AUTO | |
273 | FE_CAN_GUARD_INTERVAL_AUTO | | 289 | FE_CAN_GUARD_INTERVAL_AUTO | |
274 | FE_CAN_RECOVER | | 290 | FE_CAN_RECOVER | |
275 | FE_CAN_HIERARCHY_AUTO, | 291 | FE_CAN_HIERARCHY_AUTO, |
276 | }, | 292 | }, |
277 | 293 | ||
278 | .release = smsdvb_release, | 294 | .release = smsdvb_release, |
@@ -287,8 +303,8 @@ static struct dvb_frontend_ops smsdvb_fe_ops = { | |||
287 | .read_snr = smsdvb_read_snr, | 303 | .read_snr = smsdvb_read_snr, |
288 | }; | 304 | }; |
289 | 305 | ||
290 | int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, | 306 | int smsdvb_hotplug(smscore_device_t *coredev, |
291 | int arrival) | 307 | struct device *device, int arrival) |
292 | { | 308 | { |
293 | smsclient_params_t params; | 309 | smsclient_params_t params; |
294 | smsdvb_client_t *client; | 310 | smsdvb_client_t *client; |
@@ -298,23 +314,21 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, | |||
298 | if (!arrival) | 314 | if (!arrival) |
299 | return 0; | 315 | return 0; |
300 | 316 | ||
301 | if (smscore_get_device_mode(coredev) != 4) | 317 | if (smscore_get_device_mode(coredev) != 4) { |
302 | { | ||
303 | printk(KERN_ERR "%sSMS Device mode is not set for DVB operation.\n", __func__); | 318 | printk(KERN_ERR "%sSMS Device mode is not set for DVB operation.\n", __func__); |
304 | return 0; | 319 | return 0; |
305 | } | 320 | } |
306 | 321 | ||
307 | client = kzalloc(sizeof(smsdvb_client_t), GFP_KERNEL); | 322 | client = kzalloc(sizeof(smsdvb_client_t), GFP_KERNEL); |
308 | if (!client) | 323 | if (!client) { |
309 | { | ||
310 | printk(KERN_INFO "%s kmalloc() failed\n", __func__); | 324 | printk(KERN_INFO "%s kmalloc() failed\n", __func__); |
311 | return -ENOMEM; | 325 | return -ENOMEM; |
312 | } | 326 | } |
313 | 327 | ||
314 | // register dvb adapter | 328 | // register dvb adapter |
315 | rc = dvb_register_adapter(&client->adapter, "Siano Digital Receiver", THIS_MODULE, device, adapter_nr); | 329 | rc = dvb_register_adapter(&client->adapter, "Siano Digital Receiver", |
316 | if (rc < 0) | 330 | THIS_MODULE, device, adapter_nr); |
317 | { | 331 | if (rc < 0) { |
318 | printk("%s dvb_register_adapter() failed %d\n", __func__, rc); | 332 | printk("%s dvb_register_adapter() failed %d\n", __func__, rc); |
319 | goto adapter_error; | 333 | goto adapter_error; |
320 | } | 334 | } |
@@ -327,8 +341,7 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, | |||
327 | client->demux.stop_feed = smsdvb_stop_feed; | 341 | client->demux.stop_feed = smsdvb_stop_feed; |
328 | 342 | ||
329 | rc = dvb_dmx_init(&client->demux); | 343 | rc = dvb_dmx_init(&client->demux); |
330 | if (rc < 0) | 344 | if (rc < 0) { |
331 | { | ||
332 | printk("%s dvb_dmx_init failed %d\n\n", __func__, rc); | 345 | printk("%s dvb_dmx_init failed %d\n\n", __func__, rc); |
333 | goto dvbdmx_error; | 346 | goto dvbdmx_error; |
334 | } | 347 | } |
@@ -339,18 +352,17 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, | |||
339 | client->dmxdev.capabilities = 0; | 352 | client->dmxdev.capabilities = 0; |
340 | 353 | ||
341 | rc = dvb_dmxdev_init(&client->dmxdev, &client->adapter); | 354 | rc = dvb_dmxdev_init(&client->dmxdev, &client->adapter); |
342 | if (rc < 0) | 355 | if (rc < 0) { |
343 | { | ||
344 | printk("%s dvb_dmxdev_init failed %d\n", __func__, rc); | 356 | printk("%s dvb_dmxdev_init failed %d\n", __func__, rc); |
345 | goto dmxdev_error; | 357 | goto dmxdev_error; |
346 | } | 358 | } |
347 | 359 | ||
348 | // init and register frontend | 360 | // init and register frontend |
349 | memcpy(&client->frontend.ops, &smsdvb_fe_ops, sizeof(struct dvb_frontend_ops)); | 361 | memcpy(&client->frontend.ops, &smsdvb_fe_ops, |
362 | sizeof(struct dvb_frontend_ops)); | ||
350 | 363 | ||
351 | rc = dvb_register_frontend(&client->adapter, &client->frontend); | 364 | rc = dvb_register_frontend(&client->adapter, &client->frontend); |
352 | if (rc < 0) | 365 | if (rc < 0) { |
353 | { | ||
354 | printk("%s frontend registration failed %d\n", __func__, rc); | 366 | printk("%s frontend registration failed %d\n", __func__, rc); |
355 | goto frontend_error; | 367 | goto frontend_error; |
356 | } | 368 | } |
@@ -362,9 +374,9 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, | |||
362 | params.context = client; | 374 | params.context = client; |
363 | 375 | ||
364 | rc = smscore_register_client(coredev, ¶ms, &client->smsclient); | 376 | rc = smscore_register_client(coredev, ¶ms, &client->smsclient); |
365 | if (rc < 0) | 377 | if (rc < 0) { |
366 | { | 378 | printk(KERN_INFO "%s smscore_register_client() failed %d\n", |
367 | printk(KERN_INFO "%s smscore_register_client() failed %d\n", __func__, rc); | 379 | __func__, rc); |
368 | goto client_error; | 380 | goto client_error; |
369 | } | 381 | } |
370 | 382 | ||
@@ -421,9 +433,8 @@ void smsdvb_unregister(void) | |||
421 | kmutex_lock(&g_smsdvb_clientslock); | 433 | kmutex_lock(&g_smsdvb_clientslock); |
422 | 434 | ||
423 | while (!list_empty(&g_smsdvb_clients)) | 435 | while (!list_empty(&g_smsdvb_clients)) |
424 | smsdvb_unregister_client((smsdvb_client_t *) g_smsdvb_clients.next); | 436 | smsdvb_unregister_client( |
437 | (smsdvb_client_t *) g_smsdvb_clients.next); | ||
425 | 438 | ||
426 | kmutex_unlock(&g_smsdvb_clientslock); | 439 | kmutex_unlock(&g_smsdvb_clientslock); |
427 | |||
428 | } | 440 | } |
429 | |||