diff options
Diffstat (limited to 'drivers/media/dvb/siano/smsdvb.c')
-rw-r--r-- | drivers/media/dvb/siano/smsdvb.c | 318 |
1 files changed, 291 insertions, 27 deletions
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c index 68bf9fbd8fed..5f3939821ca3 100644 --- a/drivers/media/dvb/siano/smsdvb.c +++ b/drivers/media/dvb/siano/smsdvb.c | |||
@@ -116,6 +116,118 @@ static void sms_board_dvb3_event(struct smsdvb_client_t *client, | |||
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | |||
120 | static void smsdvb_update_dvb_stats(struct RECEPTION_STATISTICS_S *pReceptionData, | ||
121 | struct SMSHOSTLIB_STATISTICS_ST *p) | ||
122 | { | ||
123 | if (sms_dbg & 2) { | ||
124 | printk(KERN_DEBUG "Reserved = %d", p->Reserved); | ||
125 | printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked); | ||
126 | printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked); | ||
127 | printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn); | ||
128 | printk(KERN_DEBUG "SNR = %d", p->SNR); | ||
129 | printk(KERN_DEBUG "BER = %d", p->BER); | ||
130 | printk(KERN_DEBUG "FIB_CRC = %d", p->FIB_CRC); | ||
131 | printk(KERN_DEBUG "TS_PER = %d", p->TS_PER); | ||
132 | printk(KERN_DEBUG "MFER = %d", p->MFER); | ||
133 | printk(KERN_DEBUG "RSSI = %d", p->RSSI); | ||
134 | printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr); | ||
135 | printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset); | ||
136 | printk(KERN_DEBUG "Frequency = %d", p->Frequency); | ||
137 | printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth); | ||
138 | printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode); | ||
139 | printk(KERN_DEBUG "ModemState = %d", p->ModemState); | ||
140 | printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval); | ||
141 | printk(KERN_DEBUG "CodeRate = %d", p->CodeRate); | ||
142 | printk(KERN_DEBUG "LPCodeRate = %d", p->LPCodeRate); | ||
143 | printk(KERN_DEBUG "Hierarchy = %d", p->Hierarchy); | ||
144 | printk(KERN_DEBUG "Constellation = %d", p->Constellation); | ||
145 | printk(KERN_DEBUG "BurstSize = %d", p->BurstSize); | ||
146 | printk(KERN_DEBUG "BurstDuration = %d", p->BurstDuration); | ||
147 | printk(KERN_DEBUG "BurstCycleTime = %d", p->BurstCycleTime); | ||
148 | printk(KERN_DEBUG "CalculatedBurstCycleTime = %d", p->CalculatedBurstCycleTime); | ||
149 | printk(KERN_DEBUG "NumOfRows = %d", p->NumOfRows); | ||
150 | printk(KERN_DEBUG "NumOfPaddCols = %d", p->NumOfPaddCols); | ||
151 | printk(KERN_DEBUG "NumOfPunctCols = %d", p->NumOfPunctCols); | ||
152 | printk(KERN_DEBUG "ErrorTSPackets = %d", p->ErrorTSPackets); | ||
153 | printk(KERN_DEBUG "TotalTSPackets = %d", p->TotalTSPackets); | ||
154 | printk(KERN_DEBUG "NumOfValidMpeTlbs = %d", p->NumOfValidMpeTlbs); | ||
155 | printk(KERN_DEBUG "NumOfInvalidMpeTlbs = %d", p->NumOfInvalidMpeTlbs); | ||
156 | printk(KERN_DEBUG "NumOfCorrectedMpeTlbs = %d", p->NumOfCorrectedMpeTlbs); | ||
157 | printk(KERN_DEBUG "BERErrorCount = %d", p->BERErrorCount); | ||
158 | printk(KERN_DEBUG "BERBitCount = %d", p->BERBitCount); | ||
159 | printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors); | ||
160 | printk(KERN_DEBUG "PreBER = %d", p->PreBER); | ||
161 | printk(KERN_DEBUG "CellId = %d", p->CellId); | ||
162 | printk(KERN_DEBUG "DvbhSrvIndHP = %d", p->DvbhSrvIndHP); | ||
163 | printk(KERN_DEBUG "DvbhSrvIndLP = %d", p->DvbhSrvIndLP); | ||
164 | printk(KERN_DEBUG "NumMPEReceived = %d", p->NumMPEReceived); | ||
165 | } | ||
166 | |||
167 | pReceptionData->IsDemodLocked = p->IsDemodLocked; | ||
168 | |||
169 | pReceptionData->SNR = p->SNR; | ||
170 | pReceptionData->BER = p->BER; | ||
171 | pReceptionData->BERErrorCount = p->BERErrorCount; | ||
172 | pReceptionData->InBandPwr = p->InBandPwr; | ||
173 | pReceptionData->ErrorTSPackets = p->ErrorTSPackets; | ||
174 | }; | ||
175 | |||
176 | |||
177 | static void smsdvb_update_isdbt_stats(struct RECEPTION_STATISTICS_S *pReceptionData, | ||
178 | struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p) | ||
179 | { | ||
180 | int i; | ||
181 | |||
182 | if (sms_dbg & 2) { | ||
183 | printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked); | ||
184 | printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked); | ||
185 | printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn); | ||
186 | printk(KERN_DEBUG "SNR = %d", p->SNR); | ||
187 | printk(KERN_DEBUG "RSSI = %d", p->RSSI); | ||
188 | printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr); | ||
189 | printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset); | ||
190 | printk(KERN_DEBUG "Frequency = %d", p->Frequency); | ||
191 | printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth); | ||
192 | printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode); | ||
193 | printk(KERN_DEBUG "ModemState = %d", p->ModemState); | ||
194 | printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval); | ||
195 | printk(KERN_DEBUG "SystemType = %d", p->SystemType); | ||
196 | printk(KERN_DEBUG "PartialReception = %d", p->PartialReception); | ||
197 | printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers); | ||
198 | printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors); | ||
199 | |||
200 | for (i = 0; i < 3; i++) { | ||
201 | printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate); | ||
202 | printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation); | ||
203 | printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER); | ||
204 | printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount); | ||
205 | printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount); | ||
206 | printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER); | ||
207 | printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER); | ||
208 | printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets); | ||
209 | printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets); | ||
210 | printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI); | ||
211 | printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments); | ||
212 | printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors); | ||
213 | } | ||
214 | } | ||
215 | |||
216 | pReceptionData->IsDemodLocked = p->IsDemodLocked; | ||
217 | |||
218 | pReceptionData->SNR = p->SNR; | ||
219 | pReceptionData->InBandPwr = p->InBandPwr; | ||
220 | |||
221 | pReceptionData->ErrorTSPackets = 0; | ||
222 | pReceptionData->BER = 0; | ||
223 | pReceptionData->BERErrorCount = 0; | ||
224 | for (i = 0; i < 3; i++) { | ||
225 | pReceptionData->BER += p->LayerInfo[i].BER; | ||
226 | pReceptionData->BERErrorCount += p->LayerInfo[i].BERErrorCount; | ||
227 | pReceptionData->ErrorTSPackets += p->LayerInfo[i].ErrorTSPackets; | ||
228 | } | ||
229 | } | ||
230 | |||
119 | static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) | 231 | static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) |
120 | { | 232 | { |
121 | struct smsdvb_client_t *client = (struct smsdvb_client_t *) context; | 233 | struct smsdvb_client_t *client = (struct smsdvb_client_t *) context; |
@@ -134,6 +246,7 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) | |||
134 | break; | 246 | break; |
135 | 247 | ||
136 | case MSG_SMS_RF_TUNE_RES: | 248 | case MSG_SMS_RF_TUNE_RES: |
249 | case MSG_SMS_ISDBT_TUNE_RES: | ||
137 | complete(&client->tune_done); | 250 | complete(&client->tune_done); |
138 | break; | 251 | break; |
139 | 252 | ||
@@ -217,6 +330,40 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) | |||
217 | is_status_update = true; | 330 | is_status_update = true; |
218 | break; | 331 | break; |
219 | } | 332 | } |
333 | case MSG_SMS_GET_STATISTICS_RES: { | ||
334 | union { | ||
335 | struct SMSHOSTLIB_STATISTICS_ISDBT_ST isdbt; | ||
336 | struct SmsMsgStatisticsInfo_ST dvb; | ||
337 | } *p = (void *) (phdr + 1); | ||
338 | struct RECEPTION_STATISTICS_S *pReceptionData = | ||
339 | &client->sms_stat_dvb.ReceptionData; | ||
340 | |||
341 | sms_info("MSG_SMS_GET_STATISTICS_RES"); | ||
342 | |||
343 | is_status_update = true; | ||
344 | |||
345 | switch (smscore_get_device_mode(client->coredev)) { | ||
346 | case DEVICE_MODE_ISDBT: | ||
347 | case DEVICE_MODE_ISDBT_BDA: | ||
348 | smsdvb_update_isdbt_stats(pReceptionData, &p->isdbt); | ||
349 | break; | ||
350 | default: | ||
351 | smsdvb_update_dvb_stats(pReceptionData, &p->dvb.Stat); | ||
352 | } | ||
353 | if (!pReceptionData->IsDemodLocked) { | ||
354 | pReceptionData->SNR = 0; | ||
355 | pReceptionData->BER = 0; | ||
356 | pReceptionData->BERErrorCount = 0; | ||
357 | pReceptionData->InBandPwr = 0; | ||
358 | pReceptionData->ErrorTSPackets = 0; | ||
359 | } | ||
360 | |||
361 | complete(&client->tune_done); | ||
362 | break; | ||
363 | } | ||
364 | default: | ||
365 | sms_info("Unhandled message %d", phdr->msgType); | ||
366 | |||
220 | } | 367 | } |
221 | smscore_putbuffer(client->coredev, cb); | 368 | smscore_putbuffer(client->coredev, cb); |
222 | 369 | ||
@@ -233,10 +380,10 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb) | |||
233 | DVB3_EVENT_UNC_ERR); | 380 | DVB3_EVENT_UNC_ERR); |
234 | 381 | ||
235 | } else { | 382 | } else { |
236 | /*client->fe_status = | 383 | if (client->sms_stat_dvb.ReceptionData.IsRfLocked) |
237 | (phdr->msgType == MSG_SMS_NO_SIGNAL_IND) ? | 384 | client->fe_status = FE_HAS_SIGNAL | FE_HAS_CARRIER; |
238 | 0 : FE_HAS_SIGNAL;*/ | 385 | else |
239 | client->fe_status = 0; | 386 | client->fe_status = 0; |
240 | sms_board_dvb3_event(client, DVB3_EVENT_FE_UNLOCK); | 387 | sms_board_dvb3_event(client, DVB3_EVENT_FE_UNLOCK); |
241 | } | 388 | } |
242 | } | 389 | } |
@@ -325,6 +472,20 @@ static int smsdvb_sendrequest_and_wait(struct smsdvb_client_t *client, | |||
325 | 0 : -ETIME; | 472 | 0 : -ETIME; |
326 | } | 473 | } |
327 | 474 | ||
475 | static int smsdvb_send_statistics_request(struct smsdvb_client_t *client) | ||
476 | { | ||
477 | int rc; | ||
478 | struct SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ, | ||
479 | DVBT_BDA_CONTROL_MSG_ID, | ||
480 | HIF_TASK, | ||
481 | sizeof(struct SmsMsgHdr_ST), 0 }; | ||
482 | |||
483 | rc = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), | ||
484 | &client->tune_done); | ||
485 | |||
486 | return rc; | ||
487 | } | ||
488 | |||
328 | static inline int led_feedback(struct smsdvb_client_t *client) | 489 | static inline int led_feedback(struct smsdvb_client_t *client) |
329 | { | 490 | { |
330 | if (client->fe_status & FE_HAS_LOCK) | 491 | if (client->fe_status & FE_HAS_LOCK) |
@@ -337,33 +498,43 @@ static inline int led_feedback(struct smsdvb_client_t *client) | |||
337 | 498 | ||
338 | static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) | 499 | static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) |
339 | { | 500 | { |
501 | int rc; | ||
340 | struct smsdvb_client_t *client; | 502 | struct smsdvb_client_t *client; |
341 | client = container_of(fe, struct smsdvb_client_t, frontend); | 503 | client = container_of(fe, struct smsdvb_client_t, frontend); |
342 | 504 | ||
505 | rc = smsdvb_send_statistics_request(client); | ||
506 | |||
343 | *stat = client->fe_status; | 507 | *stat = client->fe_status; |
344 | 508 | ||
345 | led_feedback(client); | 509 | led_feedback(client); |
346 | 510 | ||
347 | return 0; | 511 | return rc; |
348 | } | 512 | } |
349 | 513 | ||
350 | static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber) | 514 | static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber) |
351 | { | 515 | { |
516 | int rc; | ||
352 | struct smsdvb_client_t *client; | 517 | struct smsdvb_client_t *client; |
353 | client = container_of(fe, struct smsdvb_client_t, frontend); | 518 | client = container_of(fe, struct smsdvb_client_t, frontend); |
354 | 519 | ||
520 | rc = smsdvb_send_statistics_request(client); | ||
521 | |||
355 | *ber = client->sms_stat_dvb.ReceptionData.BER; | 522 | *ber = client->sms_stat_dvb.ReceptionData.BER; |
356 | 523 | ||
357 | led_feedback(client); | 524 | led_feedback(client); |
358 | 525 | ||
359 | return 0; | 526 | return rc; |
360 | } | 527 | } |
361 | 528 | ||
362 | static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | 529 | static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength) |
363 | { | 530 | { |
531 | int rc; | ||
532 | |||
364 | struct smsdvb_client_t *client; | 533 | struct smsdvb_client_t *client; |
365 | client = container_of(fe, struct smsdvb_client_t, frontend); | 534 | client = container_of(fe, struct smsdvb_client_t, frontend); |
366 | 535 | ||
536 | rc = smsdvb_send_statistics_request(client); | ||
537 | |||
367 | if (client->sms_stat_dvb.ReceptionData.InBandPwr < -95) | 538 | if (client->sms_stat_dvb.ReceptionData.InBandPwr < -95) |
368 | *strength = 0; | 539 | *strength = 0; |
369 | else if (client->sms_stat_dvb.ReceptionData.InBandPwr > -29) | 540 | else if (client->sms_stat_dvb.ReceptionData.InBandPwr > -29) |
@@ -375,31 +546,37 @@ static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |||
375 | 546 | ||
376 | led_feedback(client); | 547 | led_feedback(client); |
377 | 548 | ||
378 | return 0; | 549 | return rc; |
379 | } | 550 | } |
380 | 551 | ||
381 | static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr) | 552 | static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr) |
382 | { | 553 | { |
554 | int rc; | ||
383 | struct smsdvb_client_t *client; | 555 | struct smsdvb_client_t *client; |
384 | client = container_of(fe, struct smsdvb_client_t, frontend); | 556 | client = container_of(fe, struct smsdvb_client_t, frontend); |
385 | 557 | ||
558 | rc = smsdvb_send_statistics_request(client); | ||
559 | |||
386 | *snr = client->sms_stat_dvb.ReceptionData.SNR; | 560 | *snr = client->sms_stat_dvb.ReceptionData.SNR; |
387 | 561 | ||
388 | led_feedback(client); | 562 | led_feedback(client); |
389 | 563 | ||
390 | return 0; | 564 | return rc; |
391 | } | 565 | } |
392 | 566 | ||
393 | static int smsdvb_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | 567 | static int smsdvb_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) |
394 | { | 568 | { |
569 | int rc; | ||
395 | struct smsdvb_client_t *client; | 570 | struct smsdvb_client_t *client; |
396 | client = container_of(fe, struct smsdvb_client_t, frontend); | 571 | client = container_of(fe, struct smsdvb_client_t, frontend); |
397 | 572 | ||
573 | rc = smsdvb_send_statistics_request(client); | ||
574 | |||
398 | *ucblocks = client->sms_stat_dvb.ReceptionData.ErrorTSPackets; | 575 | *ucblocks = client->sms_stat_dvb.ReceptionData.ErrorTSPackets; |
399 | 576 | ||
400 | led_feedback(client); | 577 | led_feedback(client); |
401 | 578 | ||
402 | return 0; | 579 | return rc; |
403 | } | 580 | } |
404 | 581 | ||
405 | static int smsdvb_get_tune_settings(struct dvb_frontend *fe, | 582 | static int smsdvb_get_tune_settings(struct dvb_frontend *fe, |
@@ -413,9 +590,10 @@ static int smsdvb_get_tune_settings(struct dvb_frontend *fe, | |||
413 | return 0; | 590 | return 0; |
414 | } | 591 | } |
415 | 592 | ||
416 | static int smsdvb_set_frontend(struct dvb_frontend *fe, | 593 | static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe, |
417 | struct dvb_frontend_parameters *fep) | 594 | struct dvb_frontend_parameters *p) |
418 | { | 595 | { |
596 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
419 | struct smsdvb_client_t *client = | 597 | struct smsdvb_client_t *client = |
420 | container_of(fe, struct smsdvb_client_t, frontend); | 598 | container_of(fe, struct smsdvb_client_t, frontend); |
421 | 599 | ||
@@ -429,24 +607,33 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe, | |||
429 | client->fe_status = FE_HAS_SIGNAL; | 607 | client->fe_status = FE_HAS_SIGNAL; |
430 | client->event_fe_state = -1; | 608 | client->event_fe_state = -1; |
431 | client->event_unc_state = -1; | 609 | client->event_unc_state = -1; |
610 | fe->dtv_property_cache.delivery_system = SYS_DVBT; | ||
432 | 611 | ||
433 | Msg.Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; | 612 | Msg.Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; |
434 | Msg.Msg.msgDstId = HIF_TASK; | 613 | Msg.Msg.msgDstId = HIF_TASK; |
435 | Msg.Msg.msgFlags = 0; | 614 | Msg.Msg.msgFlags = 0; |
436 | Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ; | 615 | Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ; |
437 | Msg.Msg.msgLength = sizeof(Msg); | 616 | Msg.Msg.msgLength = sizeof(Msg); |
438 | Msg.Data[0] = fep->frequency; | 617 | Msg.Data[0] = c->frequency; |
439 | Msg.Data[2] = 12000000; | 618 | Msg.Data[2] = 12000000; |
440 | 619 | ||
441 | sms_debug("freq %d band %d", | 620 | sms_info("%s: freq %d band %d", __func__, c->frequency, |
442 | fep->frequency, fep->u.ofdm.bandwidth); | 621 | c->bandwidth_hz); |
443 | 622 | ||
444 | switch (fep->u.ofdm.bandwidth) { | 623 | switch (c->bandwidth_hz / 1000000) { |
445 | case BANDWIDTH_8_MHZ: Msg.Data[1] = BW_8_MHZ; break; | 624 | case 8: |
446 | case BANDWIDTH_7_MHZ: Msg.Data[1] = BW_7_MHZ; break; | 625 | Msg.Data[1] = BW_8_MHZ; |
447 | case BANDWIDTH_6_MHZ: Msg.Data[1] = BW_6_MHZ; break; | 626 | break; |
448 | case BANDWIDTH_AUTO: return -EOPNOTSUPP; | 627 | case 7: |
449 | default: return -EINVAL; | 628 | Msg.Data[1] = BW_7_MHZ; |
629 | break; | ||
630 | case 6: | ||
631 | Msg.Data[1] = BW_6_MHZ; | ||
632 | break; | ||
633 | case 0: | ||
634 | return -EOPNOTSUPP; | ||
635 | default: | ||
636 | return -EINVAL; | ||
450 | } | 637 | } |
451 | /* Disable LNA, if any. An error is returned if no LNA is present */ | 638 | /* Disable LNA, if any. An error is returned if no LNA is present */ |
452 | ret = sms_board_lna_control(client->coredev, 0); | 639 | ret = sms_board_lna_control(client->coredev, 0); |
@@ -470,6 +657,90 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe, | |||
470 | &client->tune_done); | 657 | &client->tune_done); |
471 | } | 658 | } |
472 | 659 | ||
660 | static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe, | ||
661 | struct dvb_frontend_parameters *p) | ||
662 | { | ||
663 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
664 | struct smsdvb_client_t *client = | ||
665 | container_of(fe, struct smsdvb_client_t, frontend); | ||
666 | |||
667 | struct { | ||
668 | struct SmsMsgHdr_ST Msg; | ||
669 | u32 Data[4]; | ||
670 | } Msg; | ||
671 | |||
672 | fe->dtv_property_cache.delivery_system = SYS_ISDBT; | ||
673 | |||
674 | Msg.Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID; | ||
675 | Msg.Msg.msgDstId = HIF_TASK; | ||
676 | Msg.Msg.msgFlags = 0; | ||
677 | Msg.Msg.msgType = MSG_SMS_ISDBT_TUNE_REQ; | ||
678 | Msg.Msg.msgLength = sizeof(Msg); | ||
679 | |||
680 | if (c->isdbt_sb_segment_idx == -1) | ||
681 | c->isdbt_sb_segment_idx = 0; | ||
682 | |||
683 | switch (c->isdbt_sb_segment_count) { | ||
684 | case 3: | ||
685 | Msg.Data[1] = BW_ISDBT_3SEG; | ||
686 | break; | ||
687 | case 1: | ||
688 | Msg.Data[1] = BW_ISDBT_1SEG; | ||
689 | break; | ||
690 | case 0: /* AUTO */ | ||
691 | switch (c->bandwidth_hz / 1000000) { | ||
692 | case 8: | ||
693 | case 7: | ||
694 | c->isdbt_sb_segment_count = 3; | ||
695 | Msg.Data[1] = BW_ISDBT_3SEG; | ||
696 | break; | ||
697 | case 6: | ||
698 | c->isdbt_sb_segment_count = 1; | ||
699 | Msg.Data[1] = BW_ISDBT_1SEG; | ||
700 | break; | ||
701 | default: /* Assumes 6 MHZ bw */ | ||
702 | c->isdbt_sb_segment_count = 1; | ||
703 | c->bandwidth_hz = 6000; | ||
704 | Msg.Data[1] = BW_ISDBT_1SEG; | ||
705 | break; | ||
706 | } | ||
707 | break; | ||
708 | default: | ||
709 | sms_info("Segment count %d not supported", c->isdbt_sb_segment_count); | ||
710 | return -EINVAL; | ||
711 | } | ||
712 | |||
713 | Msg.Data[0] = c->frequency; | ||
714 | Msg.Data[2] = 12000000; | ||
715 | Msg.Data[3] = c->isdbt_sb_segment_idx; | ||
716 | |||
717 | sms_info("%s: freq %d segwidth %d segindex %d\n", __func__, | ||
718 | c->frequency, c->isdbt_sb_segment_count, | ||
719 | c->isdbt_sb_segment_idx); | ||
720 | |||
721 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), | ||
722 | &client->tune_done); | ||
723 | } | ||
724 | |||
725 | static int smsdvb_set_frontend(struct dvb_frontend *fe, | ||
726 | struct dvb_frontend_parameters *fep) | ||
727 | { | ||
728 | struct smsdvb_client_t *client = | ||
729 | container_of(fe, struct smsdvb_client_t, frontend); | ||
730 | struct smscore_device_t *coredev = client->coredev; | ||
731 | |||
732 | switch (smscore_get_device_mode(coredev)) { | ||
733 | case DEVICE_MODE_DVBT: | ||
734 | case DEVICE_MODE_DVBT_BDA: | ||
735 | return smsdvb_dvbt_set_frontend(fe, fep); | ||
736 | case DEVICE_MODE_ISDBT: | ||
737 | case DEVICE_MODE_ISDBT_BDA: | ||
738 | return smsdvb_isdbt_set_frontend(fe, fep); | ||
739 | default: | ||
740 | return -EINVAL; | ||
741 | } | ||
742 | } | ||
743 | |||
473 | static int smsdvb_get_frontend(struct dvb_frontend *fe, | 744 | static int smsdvb_get_frontend(struct dvb_frontend *fe, |
474 | struct dvb_frontend_parameters *fep) | 745 | struct dvb_frontend_parameters *fep) |
475 | { | 746 | { |
@@ -557,13 +828,6 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev, | |||
557 | /* device removal handled by onremove callback */ | 828 | /* device removal handled by onremove callback */ |
558 | if (!arrival) | 829 | if (!arrival) |
559 | return 0; | 830 | return 0; |
560 | |||
561 | if (smscore_get_device_mode(coredev) != DEVICE_MODE_DVBT_BDA) { | ||
562 | sms_err("SMS Device mode is not set for " | ||
563 | "DVB operation."); | ||
564 | return 0; | ||
565 | } | ||
566 | |||
567 | client = kzalloc(sizeof(struct smsdvb_client_t), GFP_KERNEL); | 831 | client = kzalloc(sizeof(struct smsdvb_client_t), GFP_KERNEL); |
568 | if (!client) { | 832 | if (!client) { |
569 | sms_err("kmalloc() failed"); | 833 | sms_err("kmalloc() failed"); |