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.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
index 5b9c5bb29b23..110536843e8e 100644
--- a/drivers/media/dvb/frontends/tda10021.c
+++ b/drivers/media/dvb/frontends/tda10021.c
@@ -30,13 +30,13 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31 31
32#include "dvb_frontend.h" 32#include "dvb_frontend.h"
33#include "tda10021.h" 33#include "tda1002x.h"
34 34
35 35
36struct tda10021_state { 36struct tda10021_state {
37 struct i2c_adapter* i2c; 37 struct i2c_adapter* i2c;
38 /* configuration settings */ 38 /* configuration settings */
39 const struct tda10021_config* config; 39 const struct tda1002x_config* config;
40 struct dvb_frontend frontend; 40 struct dvb_frontend frontend;
41 41
42 u8 pwm; 42 u8 pwm;
@@ -53,9 +53,6 @@ struct tda10021_state {
53static int verbose; 53static int verbose;
54 54
55#define XIN 57840000UL 55#define XIN 57840000UL
56#define DISABLE_INVERSION(reg0) do { reg0 |= 0x20; } while (0)
57#define ENABLE_INVERSION(reg0) do { reg0 &= ~0x20; } while (0)
58#define HAS_INVERSION(reg0) (!(reg0 & 0x20))
59 56
60#define FIN (XIN >> 4) 57#define FIN (XIN >> 4)
61 58
@@ -64,7 +61,7 @@ static u8 tda10021_inittab[0x40]=
64{ 61{
65 0x73, 0x6a, 0x23, 0x0a, 0x02, 0x37, 0x77, 0x1a, 62 0x73, 0x6a, 0x23, 0x0a, 0x02, 0x37, 0x77, 0x1a,
66 0x37, 0x6a, 0x17, 0x8a, 0x1e, 0x86, 0x43, 0x40, 63 0x37, 0x6a, 0x17, 0x8a, 0x1e, 0x86, 0x43, 0x40,
67 0xb8, 0x3f, 0xa0, 0x00, 0xcd, 0x01, 0x00, 0xff, 64 0xb8, 0x3f, 0xa1, 0x00, 0xcd, 0x01, 0x00, 0xff,
68 0x11, 0x00, 0x7c, 0x31, 0x30, 0x20, 0x00, 0x00, 65 0x11, 0x00, 0x7c, 0x31, 0x30, 0x20, 0x00, 0x00,
69 0x02, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00, 66 0x02, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00,
70 0x07, 0x00, 0x33, 0x11, 0x0d, 0x95, 0x08, 0x58, 67 0x07, 0x00, 0x33, 0x11, 0x0d, 0x95, 0x08, 0x58,
@@ -97,7 +94,8 @@ static u8 tda10021_readreg (struct tda10021_state* state, u8 reg)
97 int ret; 94 int ret;
98 95
99 ret = i2c_transfer (state->i2c, msg, 2); 96 ret = i2c_transfer (state->i2c, msg, 2);
100 if (ret != 2) 97 // Don't print an error message if the id is read.
98 if (ret != 2 && reg != 0x1a)
101 printk("DVB: TDA10021: %s: readreg error (ret == %i)\n", 99 printk("DVB: TDA10021: %s: readreg error (ret == %i)\n",
102 __FUNCTION__, ret); 100 __FUNCTION__, ret);
103 return b1[0]; 101 return b1[0];
@@ -136,10 +134,10 @@ static int tda10021_setup_reg0 (struct tda10021_state* state, u8 reg0,
136{ 134{
137 reg0 |= state->reg0 & 0x63; 135 reg0 |= state->reg0 & 0x63;
138 136
139 if (INVERSION_ON == inversion) 137 if ((INVERSION_ON == inversion) ^ (state->config->invert == 0))
140 ENABLE_INVERSION(reg0); 138 reg0 &= ~0x20;
141 else if (INVERSION_OFF == inversion) 139 else
142 DISABLE_INVERSION(reg0); 140 reg0 |= 0x20;
143 141
144 _tda10021_writereg (state, 0x00, reg0 & 0xfe); 142 _tda10021_writereg (state, 0x00, reg0 & 0xfe);
145 _tda10021_writereg (state, 0x00, reg0 | 0x01); 143 _tda10021_writereg (state, 0x00, reg0 | 0x01);
@@ -201,16 +199,6 @@ static int tda10021_set_symbolrate (struct tda10021_state* state, u32 symbolrate
201 return 0; 199 return 0;
202} 200}
203 201
204static int 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
214static int tda10021_init (struct dvb_frontend *fe) 202static int tda10021_init (struct dvb_frontend *fe)
215{ 203{
216 struct tda10021_state* state = fe->demodulator_priv; 204 struct tda10021_state* state = fe->demodulator_priv;
@@ -258,6 +246,9 @@ static int tda10021_set_parameters (struct dvb_frontend *fe,
258 if (qam < 0 || qam > 5) 246 if (qam < 0 || qam > 5)
259 return -EINVAL; 247 return -EINVAL;
260 248
249 if (p->inversion != INVERSION_ON && p->inversion != INVERSION_OFF)
250 return -EINVAL;
251
261 //printk("tda10021: set frequency to %d qam=%d symrate=%d\n", p->frequency,qam,p->u.qam.symbol_rate); 252 //printk("tda10021: set frequency to %d qam=%d symrate=%d\n", p->frequency,qam,p->u.qam.symbol_rate);
262 253
263 if (fe->ops.tuner_ops.set_params) { 254 if (fe->ops.tuner_ops.set_params) {
@@ -366,7 +357,7 @@ static int tda10021_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa
366 -((s32)p->u.qam.symbol_rate * afc) >> 10); 357 -((s32)p->u.qam.symbol_rate * afc) >> 10);
367 } 358 }
368 359
369 p->inversion = HAS_INVERSION(state->reg0) ? INVERSION_ON : INVERSION_OFF; 360 p->inversion = ((state->reg0 & 0x20) == 0x20) ^ (state->config->invert != 0) ? INVERSION_ON : INVERSION_OFF;
370 p->u.qam.modulation = ((state->reg0 >> 2) & 7) + QAM_16; 361 p->u.qam.modulation = ((state->reg0 >> 2) & 7) + QAM_16;
371 362
372 p->u.qam.fec_inner = FEC_NONE; 363 p->u.qam.fec_inner = FEC_NONE;
@@ -408,11 +399,12 @@ static void tda10021_release(struct dvb_frontend* fe)
408 399
409static struct dvb_frontend_ops tda10021_ops; 400static struct dvb_frontend_ops tda10021_ops;
410 401
411struct dvb_frontend* tda10021_attach(const struct tda10021_config* config, 402struct dvb_frontend* tda10021_attach(const struct tda1002x_config* config,
412 struct i2c_adapter* i2c, 403 struct i2c_adapter* i2c,
413 u8 pwm) 404 u8 pwm)
414{ 405{
415 struct tda10021_state* state = NULL; 406 struct tda10021_state* state = NULL;
407 u8 id;
416 408
417 /* allocate memory for the internal state */ 409 /* allocate memory for the internal state */
418 state = kmalloc(sizeof(struct tda10021_state), GFP_KERNEL); 410 state = kmalloc(sizeof(struct tda10021_state), GFP_KERNEL);
@@ -425,7 +417,11 @@ struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
425 state->reg0 = tda10021_inittab[0]; 417 state->reg0 = tda10021_inittab[0];
426 418
427 /* check if the demod is there */ 419 /* check if the demod is there */
428 if ((tda10021_readreg(state, 0x1a) & 0xf0) != 0x70) goto error; 420 id = tda10021_readreg(state, 0x1a);
421 if ((id & 0xf0) != 0x70) goto error;
422
423 printk("TDA10021: i2c-addr = 0x%02x, id = 0x%02x\n",
424 state->config->demod_address, id);
429 425
430 /* create dvb_frontend */ 426 /* create dvb_frontend */
431 memcpy(&state->frontend.ops, &tda10021_ops, sizeof(struct dvb_frontend_ops)); 427 memcpy(&state->frontend.ops, &tda10021_ops, sizeof(struct dvb_frontend_ops));
@@ -447,7 +443,7 @@ static struct dvb_frontend_ops tda10021_ops = {
447 .frequency_max = 858000000, 443 .frequency_max = 858000000,
448 .symbol_rate_min = (XIN/2)/64, /* SACLK/64 == (XIN/2)/64 */ 444 .symbol_rate_min = (XIN/2)/64, /* SACLK/64 == (XIN/2)/64 */
449 .symbol_rate_max = (XIN/2)/4, /* SACLK/4 */ 445 .symbol_rate_max = (XIN/2)/4, /* SACLK/4 */
450#if 0 446 #if 0
451 .frequency_tolerance = ???, 447 .frequency_tolerance = ???,
452 .symbol_rate_tolerance = ???, /* ppm */ /* == 8% (spec p. 5) */ 448 .symbol_rate_tolerance = ???, /* ppm */ /* == 8% (spec p. 5) */
453 #endif 449 #endif
@@ -461,7 +457,6 @@ static struct dvb_frontend_ops tda10021_ops = {
461 457
462 .init = tda10021_init, 458 .init = tda10021_init,
463 .sleep = tda10021_sleep, 459 .sleep = tda10021_sleep,
464 .write = tda10021_write,
465 .i2c_gate_ctrl = tda10021_i2c_gate_ctrl, 460 .i2c_gate_ctrl = tda10021_i2c_gate_ctrl,
466 461
467 .set_frontend = tda10021_set_parameters, 462 .set_frontend = tda10021_set_parameters,