aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@m1k.net>2005-07-27 14:45:54 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-27 19:26:16 -0400
commitb6aef071bdef0cd9f69113bb3575aa45fafdbbbf (patch)
treed6c7d89190119811244f1c039671d7483296e7c1 /drivers/media/dvb/frontends
parent7fd0f3acfa7dfc6e8aba7ce1639b8590ddb98fea (diff)
[PATCH] dvb/v4l: lgdt3302: isolate tuner
Remove the dvb_pll_desc from the frontend and replace with a pll_set-callback to isolate the tuner programming from the frontend. Signed-off-by: Mac Michaels <wmichaels1@earthlink.net> Signed-off-by: Michael Krufky <mkrufky@m1k.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/dvb/frontends')
-rw-r--r--drivers/media/dvb/frontends/lgdt3302.c68
-rw-r--r--drivers/media/dvb/frontends/lgdt3302.h7
2 files changed, 34 insertions, 41 deletions
diff --git a/drivers/media/dvb/frontends/lgdt3302.c b/drivers/media/dvb/frontends/lgdt3302.c
index c85a2a99df42..136563606fb1 100644
--- a/drivers/media/dvb/frontends/lgdt3302.c
+++ b/drivers/media/dvb/frontends/lgdt3302.c
@@ -74,11 +74,14 @@ static int i2c_writebytes (struct lgdt3302_state* state,
74 u8 *buf, /* data bytes to send */ 74 u8 *buf, /* data bytes to send */
75 int len /* number of bytes to send */ ) 75 int len /* number of bytes to send */ )
76{ 76{
77 if (addr == state->config->pll_address) { 77 u8 tmp[] = { buf[0], buf[1] };
78 struct i2c_msg msg = 78 struct i2c_msg msg =
79 { .addr = addr, .flags = 0, .buf = buf, .len = len }; 79 { .addr = addr, .flags = 0, .buf = tmp, .len = 2 };
80 int err; 80 int err;
81 int i;
81 82
83 for (i=1; i<len; i++) {
84 tmp[1] = buf[i];
82 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 85 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
83 printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err); 86 printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err);
84 if (err < 0) 87 if (err < 0)
@@ -86,27 +89,11 @@ static int i2c_writebytes (struct lgdt3302_state* state,
86 else 89 else
87 return -EREMOTEIO; 90 return -EREMOTEIO;
88 } 91 }
89 } else { 92 tmp[0]++;
90 u8 tmp[] = { buf[0], buf[1] };
91 struct i2c_msg msg =
92 { .addr = addr, .flags = 0, .buf = tmp, .len = 2 };
93 int err;
94 int i;
95
96 for (i=1; i<len; i++) {
97 tmp[1] = buf[i];
98 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
99 printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err);
100 if (err < 0)
101 return err;
102 else
103 return -EREMOTEIO;
104 }
105 tmp[0]++;
106 }
107 } 93 }
108 return 0; 94 return 0;
109} 95}
96
110static int i2c_readbytes (struct lgdt3302_state* state, 97static int i2c_readbytes (struct lgdt3302_state* state,
111 u8 addr, /* demod_address or pll_address */ 98 u8 addr, /* demod_address or pll_address */
112 u8 *buf, /* holds data bytes read */ 99 u8 *buf, /* holds data bytes read */
@@ -207,7 +194,6 @@ static int lgdt3302_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
207static int lgdt3302_set_parameters(struct dvb_frontend* fe, 194static int lgdt3302_set_parameters(struct dvb_frontend* fe,
208 struct dvb_frontend_parameters *param) 195 struct dvb_frontend_parameters *param)
209{ 196{
210 u8 buf[4];
211 struct lgdt3302_state* state = 197 struct lgdt3302_state* state =
212 (struct lgdt3302_state*) fe->demodulator_priv; 198 (struct lgdt3302_state*) fe->demodulator_priv;
213 199
@@ -290,16 +276,30 @@ static int lgdt3302_set_parameters(struct dvb_frontend* fe,
290 276
291 /* Change only if we are actually changing the channel */ 277 /* Change only if we are actually changing the channel */
292 if (state->current_frequency != param->frequency) { 278 if (state->current_frequency != param->frequency) {
293 dvb_pll_configure(state->config->pll_desc, buf, 279 u8 buf[5];
294 param->frequency, 0);
295 dprintk("%s: tuner bytes: 0x%02x 0x%02x "
296 "0x%02x 0x%02x\n", __FUNCTION__, buf[0],buf[1],buf[2],buf[3]);
297 i2c_writebytes(state, state->config->pll_address ,buf, 4);
298 280
299 /* Check the status of the tuner pll */ 281 /* This must be done before the initialized msg is declared */
300 i2c_readbytes(state, state->config->pll_address, buf, 1); 282 state->config->pll_set(fe, param, buf);
301 dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[0]); 283
284 struct i2c_msg msg =
285 { .addr = buf[0], .flags = 0, .buf = &buf[1], .len = 4 };
286 int err;
302 287
288 dprintk("%s: tuner at 0x%02x bytes: 0x%02x 0x%02x "
289 "0x%02x 0x%02x\n", __FUNCTION__,
290 buf[0],buf[1],buf[2],buf[3],buf[4]);
291 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
292 printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err = %i)\n", __FUNCTION__, buf[0], buf[1], err);
293 if (err < 0)
294 return err;
295 else
296 return -EREMOTEIO;
297 }
298#if 0
299 /* Check the status of the tuner pll */
300 i2c_readbytes(state, buf[0], &buf[1], 1);
301 dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[1]);
302#endif
303 /* Update current frequency */ 303 /* Update current frequency */
304 state->current_frequency = param->frequency; 304 state->current_frequency = param->frequency;
305 } 305 }
@@ -322,12 +322,6 @@ static int lgdt3302_read_status(struct dvb_frontend* fe, fe_status_t* status)
322 322
323 *status = 0; /* Reset status result */ 323 *status = 0; /* Reset status result */
324 324
325 /* Check the status of the tuner pll */
326 i2c_readbytes(state, state->config->pll_address, buf, 1);
327 dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[0]);
328 if ((buf[0] & 0xc0) != 0x40)
329 return 0; /* Tuner PLL not locked or not powered on */
330
331 /* 325 /*
332 * You must set the Mask bits to 1 in the IRQ_MASK in order 326 * You must set the Mask bits to 1 in the IRQ_MASK in order
333 * to see that status bit in the IRQ_STATUS register. 327 * to see that status bit in the IRQ_STATUS register.
diff --git a/drivers/media/dvb/frontends/lgdt3302.h b/drivers/media/dvb/frontends/lgdt3302.h
index 81587a40032b..327c47e598a2 100644
--- a/drivers/media/dvb/frontends/lgdt3302.h
+++ b/drivers/media/dvb/frontends/lgdt3302.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: lgdt3302.h,v 1.2 2005/06/28 23:50:48 mkrufky Exp $
3 *
4 * Support for LGDT3302 (DViCO FustionHDTV 3 Gold) - VSB/QAM 2 * Support for LGDT3302 (DViCO FustionHDTV 3 Gold) - VSB/QAM
5 * 3 *
6 * Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net> 4 * Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net>
@@ -30,8 +28,9 @@ struct lgdt3302_config
30{ 28{
31 /* The demodulator's i2c address */ 29 /* The demodulator's i2c address */
32 u8 demod_address; 30 u8 demod_address;
33 u8 pll_address; 31
34 struct dvb_pll_desc *pll_desc; 32 /* PLL interface */
33 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pll_address);
35 34
36 /* Need to set device param for start_dma */ 35 /* Need to set device param for start_dma */
37 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 36 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);