diff options
Diffstat (limited to 'linux/drivers/media/dvb')
-rw-r--r-- | linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c | 45 | ||||
-rw-r--r-- | linux/drivers/media/dvb/frontends/or51211.c | 33 | ||||
-rw-r--r-- | linux/drivers/media/dvb/frontends/or51211.h | 7 |
3 files changed, 52 insertions, 33 deletions
diff --git a/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 73ce1f661..9116e2fdd 100644 --- a/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/linux/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -376,10 +376,53 @@ static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmwa return request_firmware(fw, name, &bt->bt->dev->dev); } +static void or51211_setmode(struct dvb_frontend * fe, int mode) +{ + struct dvb_bt8xx_card *bt = fe->dvb->priv; + bttv_write_gpio(bt->bttv_nr, 0x0002, mode); /* Reset */ + msleep(20); +} + +static void or51211_reset(struct dvb_frontend * fe) +{ + struct dvb_bt8xx_card *bt = fe->dvb->priv; + + /* RESET DEVICE + * reset is controled by GPIO-0 + * when set to 0 causes reset and when to 1 for normal op + * must remain reset for 128 clock cycles on a 50Mhz clock + * also PRM1 PRM2 & PRM4 are controled by GPIO-1,GPIO-2 & GPIO-4 + * We assume that the reset has be held low long enough or we + * have been reset by a power on. When the driver is unloaded + * reset set to 0 so if reloaded we have been reset. + */ + /* reset & PRM1,2&4 are outputs */ + int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); + if (ret != 0) { + printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " + "(%i)\n", ret); + } + bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ + msleep(20); + /* Now set for normal operation */ + bttv_write_gpio(bt->bttv_nr, 0x0001F, 0x0001); + /* wait for operation to begin */ + msleep(500); +} + +static void or51211_sleep(struct dvb_frontend * fe) +{ + struct dvb_bt8xx_card *bt = fe->dvb->priv; + bttv_write_gpio(bt->bttv_nr, 0x0001, 0x0000); +} + static struct or51211_config or51211_config = { .demod_address = 0x15, .request_firmware = or51211_request_firmware, + .setmode = or51211_setmode, + .reset = or51211_reset, + .sleep = or51211_sleep, }; @@ -474,7 +517,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) break; case BTTV_PC_HDTV: - card->fe = or51211_attach(&or51211_config, card->i2c_adapter, card->bt); + card->fe = or51211_attach(&or51211_config, card->i2c_adapter); if (card->fe != NULL) { break; } diff --git a/linux/drivers/media/dvb/frontends/or51211.c b/linux/drivers/media/dvb/frontends/or51211.c index 1e8b1ea45..1b0ff61c6 100644 --- a/linux/drivers/media/dvb/frontends/or51211.c +++ b/linux/drivers/media/dvb/frontends/or51211.c @@ -130,27 +130,7 @@ static int or51211_load_firmware (struct dvb_frontend* fe, for (i = 0; i < 248; i++) tudata[i+337] = fw->data[145+i]; - /* RESET DEVICE - * reset is controled by GPIO-0 - * when set to 0 causes reset and when to 1 for normal op - * must remain reset for 128 clock cycles on a 50Mhz clock - * also PRM1 PRM2 & PRM4 are controled by GPIO-1,GPIO-2 & GPIO-4 - * We assume that the reset has be held low long enough or we - * have been reset by a power on. When the driver is unloaded - * reset set to 0 so if reloaded we have been reset. - */ - /* reset & PRM1,2&4 are outputs */ - i = bttv_gpio_enable(state->bt->bttv_nr, 0x001F, 0x001F); - if (i != 0) { - printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " - "(%i)\n",i); - } - bttv_write_gpio(state->bt->bttv_nr, 0x001F, 0x0000); /* Reset */ - msleep(20); - /* Now set for normal operation */ - bttv_write_gpio(state->bt->bttv_nr, 0x0001F, 0x0001); - /* wait for operation to begin */ - msleep(500); + state->config->reset(fe); if (i2c_writebytes(state,state->config->demod_address,tudata,585)) { printk(KERN_WARNING "or51211: load_firmware error 1\n"); @@ -187,8 +167,7 @@ static int or51211_setmode(struct dvb_frontend* fe, int mode) struct or51211_state* state = fe->demodulator_priv; u8 rec_buf[14]; - bttv_write_gpio(state->bt->bttv_nr, 0x0002, mode); /* Reset */ - msleep(20); + state->config->setmode(fe, mode); if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { printk(KERN_WARNING "or51211: setmode error 1\n"); @@ -580,17 +559,14 @@ static int or51211_get_tune_settings(struct dvb_frontend* fe, static void or51211_release(struct dvb_frontend* fe) { struct or51211_state* state = fe->demodulator_priv; - - /* Now in reset condition */ - bttv_write_gpio(state->bt->bttv_nr, 0x0001, 0x0000); + state->config->sleep(fe); kfree(state); } static struct dvb_frontend_ops or51211_ops; struct dvb_frontend* or51211_attach(const struct or51211_config* config, - struct i2c_adapter* i2c, - struct bt878 *bt) + struct i2c_adapter* i2c) { struct or51211_state* state = NULL; @@ -602,7 +578,6 @@ struct dvb_frontend* or51211_attach(const struct or51211_config* config, /* Setup the state */ state->config = config; state->i2c = i2c; - state->bt = bt; memcpy(&state->ops, &or51211_ops, sizeof(struct dvb_frontend_ops)); state->initialized = 0; state->current_frequency = 0; diff --git a/linux/drivers/media/dvb/frontends/or51211.h b/linux/drivers/media/dvb/frontends/or51211.h index 330db1eb9..13a5a3afb 100644 --- a/linux/drivers/media/dvb/frontends/or51211.h +++ b/linux/drivers/media/dvb/frontends/or51211.h @@ -24,7 +24,6 @@ #include <linux/dvb/frontend.h> #include <linux/firmware.h> -#include "bt878.h" struct or51211_config { @@ -33,11 +32,13 @@ struct or51211_config /* Request firmware for device */ int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); + void (*setmode)(struct dvb_frontend * fe, int mode); + void (*reset)(struct dvb_frontend * fe); + void (*sleep)(struct dvb_frontend * fe); }; extern struct dvb_frontend* or51211_attach(const struct or51211_config* config, - struct i2c_adapter* i2c, - struct bt878 *bt); + struct i2c_adapter* i2c); #endif // OR51211_H |