Commit 7b29e10d authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

V4L/DVB (9739): sms1xxx: enable signal quality indicator LEDs on Hauppauge WinTV MiniStick

Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 851a9091
...@@ -183,3 +183,25 @@ int sms_board_power(struct smscore_device_t *coredev, int onoff) ...@@ -183,3 +183,25 @@ int sms_board_power(struct smscore_device_t *coredev, int onoff)
} }
return 0; return 0;
} }
int sms_board_led_feedback(struct smscore_device_t *coredev, int led)
{
int board_id = smscore_get_board_id(coredev);
struct sms_board *board = sms_get_board(board_id);
/* dont touch GPIO if LEDs are already set */
if (smscore_led_state(coredev, -1) == led)
return 0;
switch (board_id) {
case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
sms_set_gpio(coredev,
board->led_lo, (led & SMS_LED_LO) ? 1 : 0);
sms_set_gpio(coredev,
board->led_hi, (led & SMS_LED_HI) ? 1 : 0);
smscore_led_state(coredev, led);
break;
}
return 0;
}
...@@ -46,6 +46,10 @@ struct sms_board *sms_get_board(int id); ...@@ -46,6 +46,10 @@ struct sms_board *sms_get_board(int id);
int sms_board_setup(struct smscore_device_t *coredev); int sms_board_setup(struct smscore_device_t *coredev);
#define SMS_LED_OFF 0
#define SMS_LED_LO 1
#define SMS_LED_HI 2
int sms_board_led_feedback(struct smscore_device_t *coredev, int led);
int sms_board_power(struct smscore_device_t *coredev, int onoff); int sms_board_power(struct smscore_device_t *coredev, int onoff);
extern struct usb_device_id smsusb_id_table[]; extern struct usb_device_id smsusb_id_table[];
......
...@@ -91,6 +91,7 @@ struct smscore_device_t { ...@@ -91,6 +91,7 @@ struct smscore_device_t {
struct completion init_device_done, reload_start_done, resume_done; struct completion init_device_done, reload_start_done, resume_done;
int board_id; int board_id;
int led_state;
}; };
void smscore_set_board_id(struct smscore_device_t *core, int id) void smscore_set_board_id(struct smscore_device_t *core, int id)
...@@ -98,6 +99,13 @@ void smscore_set_board_id(struct smscore_device_t *core, int id) ...@@ -98,6 +99,13 @@ void smscore_set_board_id(struct smscore_device_t *core, int id)
core->board_id = id; core->board_id = id;
} }
int smscore_led_state(struct smscore_device_t *core, int led)
{
if (led >= 0)
core->led_state = led;
return core->led_state;
}
int smscore_get_board_id(struct smscore_device_t *core) int smscore_get_board_id(struct smscore_device_t *core)
{ {
return core->board_id; return core->board_id;
......
...@@ -431,6 +431,8 @@ int smscore_set_gpio(struct smscore_device_t *coredev, u32 pin, int level); ...@@ -431,6 +431,8 @@ int smscore_set_gpio(struct smscore_device_t *coredev, u32 pin, int level);
void smscore_set_board_id(struct smscore_device_t *core, int id); void smscore_set_board_id(struct smscore_device_t *core, int id);
int smscore_get_board_id(struct smscore_device_t *core); int smscore_get_board_id(struct smscore_device_t *core);
int smscore_led_state(struct smscore_device_t *core, int led);
/* smsdvb.c */ /* smsdvb.c */
int smsdvb_register(void); int smsdvb_register(void);
void smsdvb_unregister(void); void smsdvb_unregister(void);
......
...@@ -167,8 +167,18 @@ static int smsdvb_send_statistics_request(struct smsdvb_client_t *client) ...@@ -167,8 +167,18 @@ static int smsdvb_send_statistics_request(struct smsdvb_client_t *client)
struct SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ, struct SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ,
DVBT_BDA_CONTROL_MSG_ID, DVBT_BDA_CONTROL_MSG_ID,
HIF_TASK, sizeof(struct SmsMsgHdr_ST), 0 }; HIF_TASK, sizeof(struct SmsMsgHdr_ST), 0 };
return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), int ret = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
&client->stat_done); &client->stat_done);
if (ret < 0)
return ret;
if (client->fe_status & FE_HAS_LOCK)
sms_board_led_feedback(client->coredev,
(client->fe_unc == 0) ?
SMS_LED_HI : SMS_LED_LO);
else
sms_board_led_feedback(client->coredev, SMS_LED_OFF);
return ret;
} }
static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
...@@ -306,6 +316,7 @@ static int smsdvb_sleep(struct dvb_frontend *fe) ...@@ -306,6 +316,7 @@ static int smsdvb_sleep(struct dvb_frontend *fe)
struct smsdvb_client_t *client = struct smsdvb_client_t *client =
container_of(fe, struct smsdvb_client_t, frontend); container_of(fe, struct smsdvb_client_t, frontend);
sms_board_led_feedback(client->coredev, SMS_LED_OFF);
sms_board_power(client->coredev, 0); sms_board_power(client->coredev, 0);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment