summaryrefslogtreecommitdiff
path: root/v4l/mt352.c
diff options
context:
space:
mode:
Diffstat (limited to 'v4l/mt352.c')
-rw-r--r--v4l/mt352.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/v4l/mt352.c b/v4l/mt352.c
index 4638207be..9d7ddefc1 100644
--- a/v4l/mt352.c
+++ b/v4l/mt352.c
@@ -107,11 +107,14 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
struct dvb_frontend_parameters *param)
{
struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
- unsigned char buf[14];
+ unsigned char buf[13];
+ static unsigned char go[2] = { 0x5b, 0x01 };
unsigned int tps = 0;
struct dvb_ofdm_parameters *op = &param->u.ofdm;
- int i;
+ int regs, tune, i;
+ dprintk("%s: hello\n",__FUNCTION__);
+
switch (op->code_rate_HP) {
case FEC_2_3:
tps |= (1 << 7);
@@ -243,21 +246,30 @@ static int mt352_set_parameters(struct dvb_frontend* fe,
state->config->pll_set(fe, param, buf+8);
- buf[13] = 0x01; /* TUNER_GO!! */
+ if (0 != buf[8]) {
+ /* default */
+ regs = 13;
+ tune = 0;
+ } else {
+ /* no tuner address given => don't write these registers */
+ regs = 8;
+ tune = 1;
+ }
/* Only send the tuning request if the tuner doesn't have the requested
* parameters already set. Enhances tuning time and prevents stream
* breakup when retuning the same transponder. */
- for (i = 1; i < 13; i++) {
+ for (i = 1; i < regs; i++) {
if (buf[i] != mt352_read_register(state, i + 0x50)) {
- mt352_write(fe, buf, sizeof(buf));
+ mt352_write(fe, buf, regs);
+ tune = 1;
break;
}
- if (8 == i && 0 == buf[i])
- /* no tuner address given => skip that part */
- break;
}
+ if (tune)
+ mt352_write(fe, go, sizeof(go)); /* set TUNER_GO */
+
return 0;
}
@@ -381,7 +393,7 @@ static int mt352_read_status(struct dvb_frontend* fe, fe_status_t* status)
struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
u8 r;
- *status = 0;
+ *status = 0;
r = mt352_read_register (state, STATUS_0);
if (r & (1 << 4))
*status = FE_HAS_CARRIER;
@@ -462,22 +474,24 @@ static int mt352_init(struct dvb_frontend* fe)
static u8 mt352_reset_attach [] = { RESET, 0xC0 };
+ dprintk("%s: hello\n",__FUNCTION__);
+
if ((mt352_read_register(state, CLOCK_CTL) & 0x10) == 0 ||
(mt352_read_register(state, CONFIG) & 0x20) == 0) {
- /* Do a "hard" reset */
+ /* Do a "hard" reset */
mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach));
return state->config->demod_init(fe);
}
return 0;
- }
+}
static void mt352_release(struct dvb_frontend* fe)
{
struct mt352_state* state = (struct mt352_state*) fe->demodulator_priv;
- kfree(state);
- }
+ kfree(state);
+}
static struct dvb_frontend_ops mt352_ops;
@@ -489,6 +503,7 @@ struct dvb_frontend* mt352_attach(const struct mt352_config* config,
/* allocate memory for the internal state */
state = (struct mt352_state*) kmalloc(sizeof(struct mt352_state), GFP_KERNEL);
if (state == NULL) goto error;
+ memset(state,0,sizeof(*state));
/* setup the state */
state->config = config;