aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/siano/smsdvb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/siano/smsdvb.c')
-rw-r--r--drivers/media/dvb/siano/smsdvb.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c
index 3ee1c3902c56..266033ae2784 100644
--- a/drivers/media/dvb/siano/smsdvb.c
+++ b/drivers/media/dvb/siano/smsdvb.c
@@ -325,6 +325,16 @@ static int smsdvb_sendrequest_and_wait(struct smsdvb_client_t *client,
325 0 : -ETIME; 325 0 : -ETIME;
326} 326}
327 327
328static inline int led_feedback(struct smsdvb_client_t *client)
329{
330 if (client->fe_status & FE_HAS_LOCK)
331 return sms_board_led_feedback(client->coredev,
332 (client->sms_stat_dvb.ReceptionData.BER
333 == 0) ? SMS_LED_HI : SMS_LED_LO);
334 else
335 return sms_board_led_feedback(client->coredev, SMS_LED_OFF);
336}
337
328static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) 338static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
329{ 339{
330 struct smsdvb_client_t *client; 340 struct smsdvb_client_t *client;
@@ -332,6 +342,8 @@ static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
332 342
333 *stat = client->fe_status; 343 *stat = client->fe_status;
334 344
345 led_feedback(client);
346
335 return 0; 347 return 0;
336} 348}
337 349
@@ -342,6 +354,8 @@ static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber)
342 354
343 *ber = client->sms_stat_dvb.ReceptionData.BER; 355 *ber = client->sms_stat_dvb.ReceptionData.BER;
344 356
357 led_feedback(client);
358
345 return 0; 359 return 0;
346} 360}
347 361
@@ -359,6 +373,8 @@ static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
359 (client->sms_stat_dvb.ReceptionData.InBandPwr 373 (client->sms_stat_dvb.ReceptionData.InBandPwr
360 + 95) * 3 / 2; 374 + 95) * 3 / 2;
361 375
376 led_feedback(client);
377
362 return 0; 378 return 0;
363} 379}
364 380
@@ -369,6 +385,8 @@ static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr)
369 385
370 *snr = client->sms_stat_dvb.ReceptionData.SNR; 386 *snr = client->sms_stat_dvb.ReceptionData.SNR;
371 387
388 led_feedback(client);
389
372 return 0; 390 return 0;
373} 391}
374 392
@@ -379,6 +397,8 @@ static int smsdvb_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
379 397
380 *ucblocks = client->sms_stat_dvb.ReceptionData.ErrorTSPackets; 398 *ucblocks = client->sms_stat_dvb.ReceptionData.ErrorTSPackets;
381 399
400 led_feedback(client);
401
382 return 0; 402 return 0;
383} 403}
384 404
@@ -404,6 +424,8 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe,
404 u32 Data[3]; 424 u32 Data[3];
405 } Msg; 425 } Msg;
406 426
427 int ret;
428
407 client->fe_status = FE_HAS_SIGNAL; 429 client->fe_status = FE_HAS_SIGNAL;
408 client->event_fe_state = -1; 430 client->event_fe_state = -1;
409 client->event_unc_state = -1; 431 client->event_unc_state = -1;
@@ -426,6 +448,23 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe,
426 case BANDWIDTH_AUTO: return -EOPNOTSUPP; 448 case BANDWIDTH_AUTO: return -EOPNOTSUPP;
427 default: return -EINVAL; 449 default: return -EINVAL;
428 } 450 }
451 /* Disable LNA, if any. An error is returned if no LNA is present */
452 ret = sms_board_lna_control(client->coredev, 0);
453 if (ret == 0) {
454 fe_status_t status;
455
456 /* tune with LNA off at first */
457 ret = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
458 &client->tune_done);
459
460 smsdvb_read_status(fe, &status);
461
462 if (status & FE_HAS_LOCK)
463 return ret;
464
465 /* previous tune didnt lock - enable LNA and tune again */
466 sms_board_lna_control(client->coredev, 1);
467 }
429 468
430 return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), 469 return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
431 &client->tune_done); 470 &client->tune_done);
@@ -451,6 +490,8 @@ static int smsdvb_init(struct dvb_frontend *fe)
451 struct smsdvb_client_t *client = 490 struct smsdvb_client_t *client =
452 container_of(fe, struct smsdvb_client_t, frontend); 491 container_of(fe, struct smsdvb_client_t, frontend);
453 492
493 sms_board_power(client->coredev, 1);
494
454 sms_board_dvb3_event(client, DVB3_EVENT_INIT); 495 sms_board_dvb3_event(client, DVB3_EVENT_INIT);
455 return 0; 496 return 0;
456} 497}
@@ -460,6 +501,9 @@ static int smsdvb_sleep(struct dvb_frontend *fe)
460 struct smsdvb_client_t *client = 501 struct smsdvb_client_t *client =
461 container_of(fe, struct smsdvb_client_t, frontend); 502 container_of(fe, struct smsdvb_client_t, frontend);
462 503
504 sms_board_led_feedback(client->coredev, SMS_LED_OFF);
505 sms_board_power(client->coredev, 0);
506
463 sms_board_dvb3_event(client, DVB3_EVENT_SLEEP); 507 sms_board_dvb3_event(client, DVB3_EVENT_SLEEP);
464 508
465 return 0; 509 return 0;