aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/tda10021.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends/tda10021.c')
-rw-r--r--drivers/media/dvb/frontends/tda10021.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
index 9cbd164aa281..dca89171be1f 100644
--- a/drivers/media/dvb/frontends/tda10021.c
+++ b/drivers/media/dvb/frontends/tda10021.c
@@ -72,7 +72,7 @@ static u8 tda10021_inittab[0x40]=
72 0x04, 0x2d, 0x2f, 0xff, 0x00, 0x00, 0x00, 0x00, 72 0x04, 0x2d, 0x2f, 0xff, 0x00, 0x00, 0x00, 0x00,
73}; 73};
74 74
75static int tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data) 75static int _tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data)
76{ 76{
77 u8 buf[] = { reg, data }; 77 u8 buf[] = { reg, data };
78 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; 78 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
@@ -88,14 +88,6 @@ static int tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data)
88 return (ret != 1) ? -EREMOTEIO : 0; 88 return (ret != 1) ? -EREMOTEIO : 0;
89} 89}
90 90
91int tda10021_write_byte(struct dvb_frontend* fe, int reg, int data)
92{
93 struct tda10021_state* state = fe->demodulator_priv;
94
95 return tda10021_writereg(state, reg, data);
96}
97EXPORT_SYMBOL(tda10021_write_byte);
98
99static u8 tda10021_readreg (struct tda10021_state* state, u8 reg) 91static u8 tda10021_readreg (struct tda10021_state* state, u8 reg)
100{ 92{
101 u8 b0 [] = { reg }; 93 u8 b0 [] = { reg };
@@ -149,8 +141,8 @@ static int tda10021_setup_reg0 (struct tda10021_state* state, u8 reg0,
149 else if (INVERSION_OFF == inversion) 141 else if (INVERSION_OFF == inversion)
150 DISABLE_INVERSION(reg0); 142 DISABLE_INVERSION(reg0);
151 143
152 tda10021_writereg (state, 0x00, reg0 & 0xfe); 144 _tda10021_writereg (state, 0x00, reg0 & 0xfe);
153 tda10021_writereg (state, 0x00, reg0 | 0x01); 145 _tda10021_writereg (state, 0x00, reg0 | 0x01);
154 146
155 state->reg0 = reg0; 147 state->reg0 = reg0;
156 return 0; 148 return 0;
@@ -198,17 +190,27 @@ static int tda10021_set_symbolrate (struct tda10021_state* state, u32 symbolrate
198 190
199 NDEC = (NDEC << 6) | tda10021_inittab[0x03]; 191 NDEC = (NDEC << 6) | tda10021_inittab[0x03];
200 192
201 tda10021_writereg (state, 0x03, NDEC); 193 _tda10021_writereg (state, 0x03, NDEC);
202 tda10021_writereg (state, 0x0a, BDR&0xff); 194 _tda10021_writereg (state, 0x0a, BDR&0xff);
203 tda10021_writereg (state, 0x0b, (BDR>> 8)&0xff); 195 _tda10021_writereg (state, 0x0b, (BDR>> 8)&0xff);
204 tda10021_writereg (state, 0x0c, (BDR>>16)&0x3f); 196 _tda10021_writereg (state, 0x0c, (BDR>>16)&0x3f);
205 197
206 tda10021_writereg (state, 0x0d, BDRI); 198 _tda10021_writereg (state, 0x0d, BDRI);
207 tda10021_writereg (state, 0x0e, SFIL); 199 _tda10021_writereg (state, 0x0e, SFIL);
208 200
209 return 0; 201 return 0;
210} 202}
211 203
204int tda10021_write(struct dvb_frontend* fe, u8 *buf, int len)
205{
206 struct tda10021_state* state = fe->demodulator_priv;
207
208 if (len != 2)
209 return -EINVAL;
210
211 return _tda10021_writereg(state, buf[0], buf[1]);
212}
213
212static int tda10021_init (struct dvb_frontend *fe) 214static int tda10021_init (struct dvb_frontend *fe)
213{ 215{
214 struct tda10021_state* state = fe->demodulator_priv; 216 struct tda10021_state* state = fe->demodulator_priv;
@@ -216,12 +218,12 @@ static int tda10021_init (struct dvb_frontend *fe)
216 218
217 dprintk("DVB: TDA10021(%d): init chip\n", fe->adapter->num); 219 dprintk("DVB: TDA10021(%d): init chip\n", fe->adapter->num);
218 220
219 //tda10021_writereg (fe, 0, 0); 221 //_tda10021_writereg (fe, 0, 0);
220 222
221 for (i=0; i<tda10021_inittab_size; i++) 223 for (i=0; i<tda10021_inittab_size; i++)
222 tda10021_writereg (state, i, tda10021_inittab[i]); 224 _tda10021_writereg (state, i, tda10021_inittab[i]);
223 225
224 tda10021_writereg (state, 0x34, state->pwm); 226 _tda10021_writereg (state, 0x34, state->pwm);
225 227
226 //Comment by markus 228 //Comment by markus
227 //0x2A[3-0] == PDIV -> P multiplaying factor (P=PDIV+1)(default 0) 229 //0x2A[3-0] == PDIV -> P multiplaying factor (P=PDIV+1)(default 0)
@@ -230,7 +232,7 @@ static int tda10021_init (struct dvb_frontend *fe)
230 //0x2A[6] == POLAXIN -> Polarity of the input reference clock (default 0) 232 //0x2A[6] == POLAXIN -> Polarity of the input reference clock (default 0)
231 233
232 //Activate PLL 234 //Activate PLL
233 tda10021_writereg(state, 0x2a, tda10021_inittab[0x2a] & 0xef); 235 _tda10021_writereg(state, 0x2a, tda10021_inittab[0x2a] & 0xef);
234 return 0; 236 return 0;
235} 237}
236 238
@@ -264,12 +266,12 @@ static int tda10021_set_parameters (struct dvb_frontend *fe,
264 } 266 }
265 267
266 tda10021_set_symbolrate (state, p->u.qam.symbol_rate); 268 tda10021_set_symbolrate (state, p->u.qam.symbol_rate);
267 tda10021_writereg (state, 0x34, state->pwm); 269 _tda10021_writereg (state, 0x34, state->pwm);
268 270
269 tda10021_writereg (state, 0x01, reg0x01[qam]); 271 _tda10021_writereg (state, 0x01, reg0x01[qam]);
270 tda10021_writereg (state, 0x05, reg0x05[qam]); 272 _tda10021_writereg (state, 0x05, reg0x05[qam]);
271 tda10021_writereg (state, 0x08, reg0x08[qam]); 273 _tda10021_writereg (state, 0x08, reg0x08[qam]);
272 tda10021_writereg (state, 0x09, reg0x09[qam]); 274 _tda10021_writereg (state, 0x09, reg0x09[qam]);
273 275
274 tda10021_setup_reg0 (state, reg0x00[qam], p->inversion); 276 tda10021_setup_reg0 (state, reg0x00[qam], p->inversion);
275 277
@@ -342,8 +344,8 @@ static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
342 *ucblocks = 0xffffffff; 344 *ucblocks = 0xffffffff;
343 345
344 /* reset uncorrected block counter */ 346 /* reset uncorrected block counter */
345 tda10021_writereg (state, 0x10, tda10021_inittab[0x10] & 0xdf); 347 _tda10021_writereg (state, 0x10, tda10021_inittab[0x10] & 0xdf);
346 tda10021_writereg (state, 0x10, tda10021_inittab[0x10]); 348 _tda10021_writereg (state, 0x10, tda10021_inittab[0x10]);
347 349
348 return 0; 350 return 0;
349} 351}
@@ -392,8 +394,8 @@ static int tda10021_sleep(struct dvb_frontend* fe)
392{ 394{
393 struct tda10021_state* state = fe->demodulator_priv; 395 struct tda10021_state* state = fe->demodulator_priv;
394 396
395 tda10021_writereg (state, 0x1b, 0x02); /* pdown ADC */ 397 _tda10021_writereg (state, 0x1b, 0x02); /* pdown ADC */
396 tda10021_writereg (state, 0x00, 0x80); /* standby */ 398 _tda10021_writereg (state, 0x00, 0x80); /* standby */
397 399
398 return 0; 400 return 0;
399} 401}
@@ -459,6 +461,7 @@ static struct dvb_frontend_ops tda10021_ops = {
459 461
460 .init = tda10021_init, 462 .init = tda10021_init,
461 .sleep = tda10021_sleep, 463 .sleep = tda10021_sleep,
464 .write = tda10021_write,
462 .i2c_gate_ctrl = tda10021_i2c_gate_ctrl, 465 .i2c_gate_ctrl = tda10021_i2c_gate_ctrl,
463 466
464 .set_frontend = tda10021_set_parameters, 467 .set_frontend = tda10021_set_parameters,