aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAapo Tahkola <aet@rasterburn.org>2007-01-21 13:57:20 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:53 -0500
commit84ad7574f69b971565061663be2b0a9ade5b8ca7 (patch)
treec874a372ec713e5a803019724a59d3c40b5e0545 /drivers
parent816172f8b944a98716f4b5fda801b7744cb91624 (diff)
V4L/DVB (5139): M920x: Fix tuner identification bug with qt1010 module
Fixes qt1010 identification bug with megasky caused by the Quantek QT1010 tuner module patch. Signed-off-by: Aapo Tahkola <aet@rasterburn.org> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.c46
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.h9
2 files changed, 41 insertions, 14 deletions
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index fd9d19b9cf2..f06fee3af9e 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -134,6 +134,7 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
134static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 134static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
135{ 135{
136 struct dvb_usb_device *d = i2c_get_adapdata(adap); 136 struct dvb_usb_device *d = i2c_get_adapdata(adap);
137 struct m9206_state *m = d->priv;
137 int i; 138 int i;
138 int ret = 0; 139 int ret = 0;
139 140
@@ -144,8 +145,6 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu
144 return -EINVAL; 145 return -EINVAL;
145 146
146 for (i = 0; i < num; i++) { 147 for (i = 0; i < num; i++) {
147 u8 w_len;
148
149 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].addr, 0x80)) != 0) 148 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].addr, 0x80)) != 0)
150 goto unlock; 149 goto unlock;
151 150
@@ -153,13 +152,19 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int nu
153 goto unlock; 152 goto unlock;
154 153
155 if (i + 1 < num && msg[i + 1].flags & I2C_M_RD) { 154 if (i + 1 < num && msg[i + 1].flags & I2C_M_RD) {
156 /* Possibly device dependant */ 155 int i2c_i;
157 if (msg[i].addr == d->adapter[0].pll_addr) 156
158 w_len = 0xc5; 157 for (i2c_i = 0; i2c_i < M9206_I2C_MAX; i2c_i++)
159 else 158 if (msg[i].addr == m->i2c_r[i2c_i].addr)
160 w_len = 0x1f; 159 break;
161 160
162 if ((ret = m9206_write(d->udev, M9206_I2C, w_len, 0x80)) != 0) 161 if (i2c_i >= M9206_I2C_MAX) {
162 deb_rc("No magic for i2c addr!\n");
163 ret = -EINVAL;
164 goto unlock;
165 }
166
167 if ((ret = m9206_write(d->udev, M9206_I2C, m->i2c_r[i2c_i].magic, 0x80)) != 0)
163 goto unlock; 168 goto unlock;
164 169
165 if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x60, msg[i + 1].buf, msg[i + 1].len)) != 0) 170 if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x60, msg[i + 1].buf, msg[i + 1].len)) != 0)
@@ -238,11 +243,17 @@ static struct mt352_config megasky_mt352_config = {
238 243
239static int megasky_frontend_attach(struct dvb_usb_adapter *adap) 244static int megasky_frontend_attach(struct dvb_usb_adapter *adap)
240{ 245{
246 struct m9206_state *m = adap->dev->priv;
247
241 deb_rc("megasky_frontend_attach!\n"); 248 deb_rc("megasky_frontend_attach!\n");
242 249
243 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) != NULL) 250 m->i2c_r[M9206_I2C_DEMOD].addr = megasky_mt352_config.demod_address;
244 return 0; 251 m->i2c_r[M9206_I2C_DEMOD].magic = 0x1f;
245 return -EIO; 252
253 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL)
254 return -EIO;
255
256 return 0;
246} 257}
247 258
248static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, int pid) 259static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, int pid)
@@ -389,9 +400,16 @@ static struct qt1010_config megasky_qt1010_config = {
389 400
390static int megasky_tuner_attach(struct dvb_usb_adapter *adap) 401static int megasky_tuner_attach(struct dvb_usb_adapter *adap)
391{ 402{
392 return dvb_attach(qt1010_attach, 403 struct m9206_state *m = adap->dev->priv;
393 adap->fe, &adap->dev->i2c_adap, 404
394 &megasky_qt1010_config) == NULL ? -ENODEV : 0; 405 m->i2c_r[M9206_I2C_TUNER].addr = megasky_qt1010_config.i2c_address;
406 m->i2c_r[M9206_I2C_TUNER].magic = 0xc5;
407
408 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap,
409 &megasky_qt1010_config) == NULL)
410 return -ENODEV;
411
412 return 0;
395} 413}
396 414
397/* DVB USB Driver stuff */ 415/* DVB USB Driver stuff */
diff --git a/drivers/media/dvb/dvb-usb/m920x.h b/drivers/media/dvb/dvb-usb/m920x.h
index 597df11e6ea..c354196ffe5 100644
--- a/drivers/media/dvb/dvb-usb/m920x.h
+++ b/drivers/media/dvb/dvb-usb/m920x.h
@@ -18,9 +18,18 @@
18#define M9206_FW 0x30 18#define M9206_FW 0x30
19 19
20#define M9206_MAX_FILTERS 8 20#define M9206_MAX_FILTERS 8
21
22#define M9206_I2C_TUNER 0
23#define M9206_I2C_DEMOD 1
24#define M9206_I2C_MAX 2
25
21struct m9206_state { 26struct m9206_state {
22 u16 filters[M9206_MAX_FILTERS]; 27 u16 filters[M9206_MAX_FILTERS];
23 int filtering_enabled; 28 int filtering_enabled;
24 int rep_count; 29 int rep_count;
30 struct {
31 unsigned char addr;
32 unsigned char magic;
33 }i2c_r[M9206_I2C_MAX];
25}; 34};
26#endif 35#endif