diff options
Diffstat (limited to 'linux/drivers/media/dvb/frontends')
-rw-r--r-- | linux/drivers/media/dvb/frontends/af9013.c | 8 | ||||
-rw-r--r-- | linux/drivers/media/dvb/frontends/af9013_priv.h | 4 | ||||
-rw-r--r-- | linux/drivers/media/dvb/frontends/au8522.c | 133 | ||||
-rw-r--r-- | linux/drivers/media/dvb/frontends/au8522.h | 17 |
4 files changed, 155 insertions, 7 deletions
diff --git a/linux/drivers/media/dvb/frontends/af9013.c b/linux/drivers/media/dvb/frontends/af9013.c index 739d885b3..21c1060cf 100644 --- a/linux/drivers/media/dvb/frontends/af9013.c +++ b/linux/drivers/media/dvb/frontends/af9013.c @@ -34,7 +34,7 @@ #include "af9013_priv.h" #include "af9013.h" -int debug; +int af9013_debug; struct af9013_state { struct i2c_adapter *i2c; @@ -1490,7 +1490,7 @@ static int af9013_download_firmware(struct af9013_state *state) if (i == packets) /* set size of the last packet */ len = remainder; - data = (fw->data + i * FW_PACKET_MAX_DATA); + data = (u8 *)(fw->data + i * FW_PACKET_MAX_DATA); ret = af9013_write_ofsm_regs(state, addr, data, len); addr += FW_PACKET_MAX_DATA; @@ -1500,8 +1500,6 @@ static int af9013_download_firmware(struct af9013_state *state) } } - #undef FW_PACKET_MAX_DATA - /* request boot firmware */ ret = af9013_write_reg(state, 0xe205, 1); if (ret) @@ -1679,7 +1677,7 @@ static struct dvb_frontend_ops af9013_ops = { .read_ucblocks = af9013_read_ucblocks, }; -module_param(debug, int, 0644); +module_param_named(debug, af9013_debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); diff --git a/linux/drivers/media/dvb/frontends/af9013_priv.h b/linux/drivers/media/dvb/frontends/af9013_priv.h index b62e4cc9b..163e251d0 100644 --- a/linux/drivers/media/dvb/frontends/af9013_priv.h +++ b/linux/drivers/media/dvb/frontends/af9013_priv.h @@ -25,7 +25,7 @@ #define _AF9013_PRIV_ #define LOG_PREFIX "af9013" -extern int debug; +extern int af9013_debug; #define dprintk(var, level, args...) \ do { if ((var & level)) printk(args); } while (0) @@ -37,7 +37,7 @@ extern int debug; func("\n");\ } -#define deb_info(args...) dprintk(debug, 0x01, args) +#define deb_info(args...) dprintk(af9013_debug, 0x01, args) #undef err #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg) diff --git a/linux/drivers/media/dvb/frontends/au8522.c b/linux/drivers/media/dvb/frontends/au8522.c index 78e270ee0..1e3ad2302 100644 --- a/linux/drivers/media/dvb/frontends/au8522.c +++ b/linux/drivers/media/dvb/frontends/au8522.c @@ -40,6 +40,8 @@ struct au8522_state { u32 current_frequency; fe_modulation_t current_modulation; + u32 fe_status; + unsigned int led_state; }; static int debug; @@ -538,11 +540,98 @@ static int au8522_init(struct dvb_frontend *fe) return 0; } +static int au8522_led_gpio_enable(struct au8522_state *state, int onoff) +{ + struct au8522_led_config *led_config = state->config->led_cfg; + u8 val; + + /* bail out if we cant control an LED */ + if (!led_config || !led_config->gpio_output || + !led_config->gpio_output_enable || !led_config->gpio_output_disable) + return 0; + + val = au8522_readreg(state, 0x4000 | + (led_config->gpio_output & ~0xc000)); + if (onoff) { + /* enable GPIO output */ + val &= ~((led_config->gpio_output_enable >> 8) & 0xff); + val |= (led_config->gpio_output_enable & 0xff); + } else { + /* disable GPIO output */ + val &= ~((led_config->gpio_output_disable >> 8) & 0xff); + val |= (led_config->gpio_output_disable & 0xff); + } + return au8522_writereg(state, 0x8000 | + (led_config->gpio_output & ~0xc000), val); +} + +/* led = 0 | off + * led = 1 | signal ok + * led = 2 | signal strong + * led < 0 | only light led if leds are currently off + */ +static int au8522_led_ctrl(struct au8522_state *state, int led) +{ + struct au8522_led_config *led_config = state->config->led_cfg; + int i, ret = 0; + + /* bail out if we cant control an LED */ + if (!led_config || !led_config->gpio_leds || + !led_config->num_led_states || !led_config->led_states) + return 0; + + if (led < 0) { + /* if LED is already lit, then leave it as-is */ + if (state->led_state) + return 0; + else + led *= -1; + } + + /* toggle LED if changing state */ + if (state->led_state != led) { + u8 val; + + dprintk("%s: %d\n", __func__, led); + + au8522_led_gpio_enable(state, 1); + + val = au8522_readreg(state, 0x4000 | + (led_config->gpio_leds & ~0xc000)); + + /* start with all leds off */ + for (i = 0; i < led_config->num_led_states; i++) + val &= ~led_config->led_states[i]; + + /* set selected LED state */ + if (led < led_config->num_led_states) + val |= led_config->led_states[led]; + else if (led_config->num_led_states) + val |= + led_config->led_states[led_config->num_led_states - 1]; + + ret = au8522_writereg(state, 0x8000 | + (led_config->gpio_leds & ~0xc000), val); + if (ret < 0) + return ret; + + state->led_state = led; + + if (led == 0) + au8522_led_gpio_enable(state, 0); + } + + return 0; +} + static int au8522_sleep(struct dvb_frontend *fe) { struct au8522_state *state = fe->demodulator_priv; dprintk("%s()\n", __func__); + /* turn off led */ + au8522_led_ctrl(state, 0); + state->current_frequency = 0; return 0; @@ -592,12 +681,53 @@ static int au8522_read_status(struct dvb_frontend *fe, fe_status_t *status) *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; break; } + state->fe_status = *status; + + if (*status & FE_HAS_LOCK) + /* turn on LED, if it isn't on already */ + au8522_led_ctrl(state, -1); + else + /* turn off LED */ + au8522_led_ctrl(state, 0); dprintk("%s() status 0x%08x\n", __func__, *status); return 0; } +static int au8522_led_status(struct au8522_state *state, const u16 *snr) +{ + struct au8522_led_config *led_config = state->config->led_cfg; + int led; + u16 strong; + + /* bail out if we cant control an LED */ + if (!led_config) + return 0; + + if (0 == (state->fe_status & FE_HAS_LOCK)) + return au8522_led_ctrl(state, 0); + else if (state->current_modulation == QAM_256) + strong = led_config->qam256_strong; + else if (state->current_modulation == QAM_64) + strong = led_config->qam64_strong; + else /* (state->current_modulation == VSB_8) */ + strong = led_config->vsb8_strong; + + if (*snr >= strong) + led = 2; + else + led = 1; + + if ((state->led_state) && + (((strong < *snr) ? (*snr - strong) : (strong - *snr)) <= 10)) + /* snr didn't change enough to bother + * changing the color of the led */ + return 0; + + return au8522_led_ctrl(state, led); +} + static int au8522_read_snr(struct dvb_frontend *fe, u16 *snr) { struct au8522_state *state = fe->demodulator_priv; @@ -621,6 +751,9 @@ static int au8522_read_snr(struct dvb_frontend *fe, u16 *snr) au8522_readreg(state, 0x4311), snr); + if (state->config->led_cfg) + au8522_led_status(state, snr); + return ret; } diff --git a/linux/drivers/media/dvb/frontends/au8522.h b/linux/drivers/media/dvb/frontends/au8522.h index 595915ade..7b94f554a 100644 --- a/linux/drivers/media/dvb/frontends/au8522.h +++ b/linux/drivers/media/dvb/frontends/au8522.h @@ -30,6 +30,21 @@ enum au8522_if_freq { AU8522_IF_3_25MHZ, }; +struct au8522_led_config { + u16 vsb8_strong; + u16 qam64_strong; + u16 qam256_strong; + + u16 gpio_output; + /* unset hi bits, set low bits */ + u16 gpio_output_enable; + u16 gpio_output_disable; + + u16 gpio_leds; + u8 *led_states; + unsigned int num_led_states; +}; + struct au8522_config { /* the demodulator's i2c address */ u8 demod_address; @@ -39,6 +54,8 @@ struct au8522_config { #define AU8522_DEMODLOCKING 1 u8 status_mode; + struct au8522_led_config *led_cfg; + enum au8522_if_freq vsb_if; enum au8522_if_freq qam_if; }; |