X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fmedia%2Fdvb%2Ffrontends%2Fsp8870.c;h=d98fd5c2e13e12e6a1dc1f17253e4f4d7de71143;hb=7b69a4c360e8787877ebf5e42609b8bab13afa6a;hp=1c6b2e9264bc15c7b78cd8bac150ef8957abba41;hpb=87199134b4a85de56a7508c551ab3b3a3ee35035;p=pandora-kernel.git diff --git a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c index 1c6b2e9264bc..d98fd5c2e13e 100644 --- a/drivers/media/dvb/frontends/sp8870.c +++ b/drivers/media/dvb/frontends/sp8870.c @@ -22,7 +22,8 @@ /* * This driver needs external firmware. Please use the command * "/Documentation/dvb/get_dvb_firmware alps_tdlb7" to - * download/extract it, and then copy it to /usr/lib/hotplug/firmware. + * download/extract it, and then copy it to /usr/lib/hotplug/firmware + * or /lib/firmware (depending on configuration of firmware hotplug). */ #define SP8870_DEFAULT_FIRMWARE "dvb-fe-sp8870.fw" @@ -43,8 +44,6 @@ struct sp8870_state { struct i2c_adapter* i2c; - struct dvb_frontend_ops ops; - const struct sp8870_config* config; struct dvb_frontend frontend; @@ -67,16 +66,16 @@ static int debug; static int sp8870_writereg (struct sp8870_state* state, u16 reg, u16 data) { - u8 buf [] = { reg >> 8, reg & 0xff, data >> 8, data & 0xff }; + u8 buf [] = { reg >> 8, reg & 0xff, data >> 8, data & 0xff }; struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 4 }; int err; - if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { + if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data); return -EREMOTEIO; } - return 0; + return 0; } static int sp8870_readreg (struct sp8870_state* state, u16 reg) @@ -261,9 +260,10 @@ static int sp8870_set_frontend_parameters (struct dvb_frontend* fe, sp8870_microcontroller_stop(state); // set tuner parameters - sp8870_writereg(state, 0x206, 0x001); - state->config->pll_set(fe, p); - sp8870_writereg(state, 0x206, 0x000); + if (fe->ops.tuner_ops.set_params) { + fe->ops.tuner_ops.set_params(fe, p); + if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); + } // sample rate correction bit [23..17] sp8870_writereg(state, 0x0319, 0x000A); @@ -305,7 +305,7 @@ static int sp8870_set_frontend_parameters (struct dvb_frontend* fe, static int sp8870_init (struct dvb_frontend* fe) { struct sp8870_state* state = fe->demodulator_priv; - const struct firmware *fw = NULL; + const struct firmware *fw = NULL; sp8870_wake_up(state); if (state->initialised) return 0; @@ -318,7 +318,6 @@ static int sp8870_init (struct dvb_frontend* fe) printk("sp8870: waiting for firmware upload (%s)...\n", SP8870_DEFAULT_FIRMWARE); if (state->config->request_firmware(fe, &fw, SP8870_DEFAULT_FIRMWARE)) { printk("sp8870: no firmware upload (timeout or file not found?)\n"); - release_firmware(fw); return -EIO; } @@ -327,6 +326,7 @@ static int sp8870_init (struct dvb_frontend* fe) release_firmware(fw); return -EIO; } + release_firmware(fw); printk("sp8870: firmware upload complete\n"); /* enable TS output and interface pins */ @@ -348,13 +348,6 @@ static int sp8870_init (struct dvb_frontend* fe) sp8870_writereg(state, 0x0D00, 0x010); sp8870_writereg(state, 0x0D01, 0x000); - /* setup PLL */ - if (state->config->pll_init) { - sp8870_writereg(state, 0x206, 0x001); - state->config->pll_init(fe); - sp8870_writereg(state, 0x206, 0x000); - } - return 0; } @@ -534,10 +527,21 @@ static int sp8870_sleep(struct dvb_frontend* fe) static int sp8870_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) { - fesettings->min_delay_ms = 350; - fesettings->step_size = 0; - fesettings->max_drift = 0; - return 0; + fesettings->min_delay_ms = 350; + fesettings->step_size = 0; + fesettings->max_drift = 0; + return 0; +} + +static int sp8870_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) +{ + struct sp8870_state* state = fe->demodulator_priv; + + if (enable) { + return sp8870_writereg(state, 0x206, 0x001); + } else { + return sp8870_writereg(state, 0x206, 0x000); + } } static void sp8870_release(struct dvb_frontend* fe) @@ -560,14 +564,13 @@ struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, /* setup the state */ state->config = config; state->i2c = i2c; - memcpy(&state->ops, &sp8870_ops, sizeof(struct dvb_frontend_ops)); state->initialised = 0; /* check if the demod is there */ if (sp8870_readreg(state, 0x0200) < 0) goto error; /* create dvb_frontend */ - state->frontend.ops = &state->ops; + memcpy(&state->frontend.ops, &sp8870_ops, sizeof(struct dvb_frontend_ops)); state->frontend.demodulator_priv = state; return &state->frontend; @@ -596,6 +599,7 @@ static struct dvb_frontend_ops sp8870_ops = { .init = sp8870_init, .sleep = sp8870_sleep, + .i2c_gate_ctrl = sp8870_i2c_gate_ctrl, .set_frontend = sp8870_set_frontend, .get_tune_settings = sp8870_get_tune_settings,