diff options
author | Marco Gittler <g.marco@freenet.de> | 2007-04-23 16:52:58 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:45:59 -0400 |
commit | 86534e5e8eaeab2f5d2e92cff5e16980750095c6 (patch) | |
tree | 67a2398455fbff1f19f3de7d0750c9042a418bdd /drivers/media | |
parent | 12df2f54e5522d89b3de6df62a800a0edeb10dcc (diff) |
V4L/DVB (5558): Opera: use 7-bit i2c addresses
- the tuner i2c addr now without define (as wanted).
- now 7 bit addr are used (the power_ctrl fkt ist ok so,
because this is a raw write)
- the addr >> 1 , addr << 1 is ok so, i think beause the
read write is now taken from the last bit.
- now i have no datasheet for the device, all taken from usb-logs
Signed-off-by: Marco Gittler <g.marco@freenet.de>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 2 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/opera1.c | 78 |
2 files changed, 49 insertions, 31 deletions
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index e4e60619421e..97715f7514d6 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -32,13 +32,13 @@ | |||
32 | #define USB_VID_LITEON 0x04ca | 32 | #define USB_VID_LITEON 0x04ca |
33 | #define USB_VID_MEDION 0x1660 | 33 | #define USB_VID_MEDION 0x1660 |
34 | #define USB_VID_MSI 0x0db0 | 34 | #define USB_VID_MSI 0x0db0 |
35 | #define USB_VID_OPERA1 0x695c | ||
35 | #define USB_VID_PINNACLE 0x2304 | 36 | #define USB_VID_PINNACLE 0x2304 |
36 | #define USB_VID_VISIONPLUS 0x13d3 | 37 | #define USB_VID_VISIONPLUS 0x13d3 |
37 | #define USB_VID_TWINHAN 0x1822 | 38 | #define USB_VID_TWINHAN 0x1822 |
38 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 | 39 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 |
39 | #define USB_VID_UNIWILL 0x1584 | 40 | #define USB_VID_UNIWILL 0x1584 |
40 | #define USB_VID_WIDEVIEW 0x14aa | 41 | #define USB_VID_WIDEVIEW 0x14aa |
41 | #define USB_VID_OPERA1 0x695c | ||
42 | 42 | ||
43 | /* Product IDs */ | 43 | /* Product IDs */ |
44 | #define USB_PID_ADSTECH_USB2_COLD 0xa333 | 44 | #define USB_PID_ADSTECH_USB2_COLD 0xa333 |
diff --git a/drivers/media/dvb/dvb-usb/opera1.c b/drivers/media/dvb/dvb-usb/opera1.c index 67c2aa59f74c..518d7ad217df 100644 --- a/drivers/media/dvb/dvb-usb/opera1.c +++ b/drivers/media/dvb/dvb-usb/opera1.c | |||
@@ -25,6 +25,11 @@ | |||
25 | #define REG_20_SYMBOLRATE_BYTE1 0x20 | 25 | #define REG_20_SYMBOLRATE_BYTE1 0x20 |
26 | #define REG_21_SYMBOLRATE_BYTE2 0x21 | 26 | #define REG_21_SYMBOLRATE_BYTE2 0x21 |
27 | 27 | ||
28 | #define ADDR_B600_VOLTAGE_13V (0x02) | ||
29 | #define ADDR_B601_VOLTAGE_18V (0x03) | ||
30 | #define ADDR_B1A6_STREAM_CTRL (0x04) | ||
31 | #define ADDR_B880_READ_REMOTE (0x05) | ||
32 | |||
28 | struct opera1_state { | 33 | struct opera1_state { |
29 | u32 last_key_pressed; | 34 | u32 last_key_pressed; |
30 | }; | 35 | }; |
@@ -70,7 +75,7 @@ static int opera1_xilinx_rw(struct usb_device *dev, u8 request, u16 value, | |||
70 | /* I2C */ | 75 | /* I2C */ |
71 | 76 | ||
72 | static int opera1_usb_i2c_msgxfer(struct dvb_usb_device *dev, u16 addr, | 77 | static int opera1_usb_i2c_msgxfer(struct dvb_usb_device *dev, u16 addr, |
73 | u8 * buf, u16 len, int flag) | 78 | u8 * buf, u16 len) |
74 | { | 79 | { |
75 | int ret = 0; | 80 | int ret = 0; |
76 | u8 request; | 81 | u8 request; |
@@ -83,16 +88,30 @@ static int opera1_usb_i2c_msgxfer(struct dvb_usb_device *dev, u16 addr, | |||
83 | if (mutex_lock_interruptible(&dev->usb_mutex) < 0) | 88 | if (mutex_lock_interruptible(&dev->usb_mutex) < 0) |
84 | return -EAGAIN; | 89 | return -EAGAIN; |
85 | 90 | ||
86 | request = (addr & 0xff00) >> 8; | 91 | switch (addr>>1){ |
87 | if (!request) | 92 | case ADDR_B600_VOLTAGE_13V: |
88 | request = 0xb1; | 93 | request=0xb6; |
89 | value = (addr & 0xff); | 94 | value=0x00; |
90 | if (flag & OPERA_READ_MSG) { | 95 | break; |
91 | value |= 0x01; | 96 | case ADDR_B601_VOLTAGE_18V: |
97 | request=0xb6; | ||
98 | value=0x01; | ||
99 | break; | ||
100 | case ADDR_B1A6_STREAM_CTRL: | ||
101 | request=0xb1; | ||
102 | value=0xa6; | ||
103 | break; | ||
104 | case ADDR_B880_READ_REMOTE: | ||
105 | request=0xb8; | ||
106 | value=0x80; | ||
107 | break; | ||
108 | default: | ||
109 | request=0xb1; | ||
110 | value=addr; | ||
92 | } | 111 | } |
93 | if (request == 0xa0) | 112 | ret = opera1_xilinx_rw(dev->udev, request, |
94 | value = 0xe600; | 113 | value, buf, len, |
95 | ret = opera1_xilinx_rw(dev->udev, request, value, buf, len, flag); | 114 | addr&0x01?OPERA_READ_MSG:OPERA_WRITE_MSG); |
96 | 115 | ||
97 | mutex_unlock(&dev->usb_mutex); | 116 | mutex_unlock(&dev->usb_mutex); |
98 | return ret; | 117 | return ret; |
@@ -111,13 +130,10 @@ static int opera1_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
111 | 130 | ||
112 | for (i = 0; i < num; i++) { | 131 | for (i = 0; i < num; i++) { |
113 | if ((tmp = opera1_usb_i2c_msgxfer(d, | 132 | if ((tmp = opera1_usb_i2c_msgxfer(d, |
114 | msg[i].addr, | 133 | (msg[i].addr<<1)|(msg[i].flags&I2C_M_RD?0x01:0), |
115 | msg[i].buf, | 134 | msg[i].buf, |
116 | msg[i].len, | 135 | msg[i].len |
117 | (msg[i].flags == | 136 | )!= msg[i].len)) { |
118 | I2C_M_RD ? | ||
119 | OPERA_READ_MSG : | ||
120 | OPERA_WRITE_MSG))!= msg[i].len)) { | ||
121 | break; | 137 | break; |
122 | } | 138 | } |
123 | if (dvb_usb_opera1_debug & 0x10) | 139 | if (dvb_usb_opera1_debug & 0x10) |
@@ -142,12 +158,12 @@ static int opera1_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | |||
142 | static u8 command_13v[1]={0x00}; | 158 | static u8 command_13v[1]={0x00}; |
143 | static u8 command_18v[1]={0x01}; | 159 | static u8 command_18v[1]={0x01}; |
144 | struct i2c_msg msg[] = { | 160 | struct i2c_msg msg[] = { |
145 | {.addr = 0xb600,.flags = 0,.buf = command_13v,.len = 1}, | 161 | {.addr = ADDR_B600_VOLTAGE_13V,.flags = 0,.buf = command_13v,.len = 1}, |
146 | }; | 162 | }; |
147 | struct dvb_usb_adapter *udev_adap = | 163 | struct dvb_usb_adapter *udev_adap = |
148 | (struct dvb_usb_adapter *)(fe->dvb->priv); | 164 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
149 | if (voltage == SEC_VOLTAGE_18) { | 165 | if (voltage == SEC_VOLTAGE_18) { |
150 | msg[0].addr = 0xb601; | 166 | msg[0].addr = ADDR_B601_VOLTAGE_18V; |
151 | msg[0].buf = command_18v; | 167 | msg[0].buf = command_18v; |
152 | } | 168 | } |
153 | i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1); | 169 | i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1); |
@@ -220,7 +236,7 @@ static u8 opera1_inittab[] = { | |||
220 | }; | 236 | }; |
221 | 237 | ||
222 | static struct stv0299_config opera1_stv0299_config = { | 238 | static struct stv0299_config opera1_stv0299_config = { |
223 | .demod_address = 0xd0, | 239 | .demod_address = 0xd0>>1, |
224 | .min_delay_ms = 100, | 240 | .min_delay_ms = 100, |
225 | .mclk = 88000000UL, | 241 | .mclk = 88000000UL, |
226 | .invert = 1, | 242 | .invert = 1, |
@@ -245,19 +261,21 @@ static int opera1_frontend_attach(struct dvb_usb_adapter *d) | |||
245 | 261 | ||
246 | static int opera1_tuner_attach(struct dvb_usb_adapter *adap) | 262 | static int opera1_tuner_attach(struct dvb_usb_adapter *adap) |
247 | { | 263 | { |
248 | adap->pll_addr = 0xc0; | 264 | dvb_attach( |
249 | adap->pll_desc = &dvb_pll_opera1; | 265 | dvb_pll_attach, adap->fe, 0xc0>>1, |
250 | adap->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; | 266 | &adap->dev->i2c_adap, &dvb_pll_opera1 |
267 | ); | ||
251 | return 0; | 268 | return 0; |
252 | } | 269 | } |
253 | 270 | ||
254 | static int opera1_power_ctrl(struct dvb_usb_device *d, int onoff) | 271 | static int opera1_power_ctrl(struct dvb_usb_device *d, int onoff) |
255 | { | 272 | { |
256 | int addr = onoff ? 0xb701 : 0xb700; | ||
257 | u8 val = onoff ? 0x01 : 0x00; | 273 | u8 val = onoff ? 0x01 : 0x00; |
274 | |||
258 | if (dvb_usb_opera1_debug) | 275 | if (dvb_usb_opera1_debug) |
259 | info("power %s", onoff ? "on" : "off"); | 276 | info("power %s", onoff ? "on" : "off"); |
260 | return opera1_usb_i2c_msgxfer(d, addr, &val, 1, OPERA_WRITE_MSG); | 277 | return opera1_xilinx_rw(d->udev, 0xb7, val, |
278 | &val, 1, OPERA_WRITE_MSG); | ||
261 | } | 279 | } |
262 | 280 | ||
263 | static int opera1_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) | 281 | static int opera1_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) |
@@ -265,7 +283,7 @@ static int opera1_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) | |||
265 | static u8 buf_start[2] = { 0xff, 0x03 }; | 283 | static u8 buf_start[2] = { 0xff, 0x03 }; |
266 | static u8 buf_stop[2] = { 0xff, 0x00 }; | 284 | static u8 buf_stop[2] = { 0xff, 0x00 }; |
267 | struct i2c_msg start_tuner[] = { | 285 | struct i2c_msg start_tuner[] = { |
268 | {.addr = 0xb1a6,.buf = onoff ? buf_start : buf_stop,.len = 2}, | 286 | {.addr = ADDR_B1A6_STREAM_CTRL,.buf = onoff ? buf_start : buf_stop,.len = 2}, |
269 | }; | 287 | }; |
270 | if (dvb_usb_opera1_debug) | 288 | if (dvb_usb_opera1_debug) |
271 | info("streaming %s", onoff ? "on" : "off"); | 289 | info("streaming %s", onoff ? "on" : "off"); |
@@ -278,7 +296,7 @@ static int opera1_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, | |||
278 | { | 296 | { |
279 | u8 b_pid[3]; | 297 | u8 b_pid[3]; |
280 | struct i2c_msg msg[] = { | 298 | struct i2c_msg msg[] = { |
281 | {.addr = 0xb1a6,.buf = b_pid,.len = 3}, | 299 | {.addr = ADDR_B1A6_STREAM_CTRL,.buf = b_pid,.len = 3}, |
282 | }; | 300 | }; |
283 | if (dvb_usb_opera1_debug) | 301 | if (dvb_usb_opera1_debug) |
284 | info("pidfilter index: %d pid: %d %s", index, pid, | 302 | info("pidfilter index: %d pid: %d %s", index, pid, |
@@ -295,7 +313,7 @@ static int opera1_pid_filter_control(struct dvb_usb_adapter *adap, int onoff) | |||
295 | int u = 0x04; | 313 | int u = 0x04; |
296 | u8 b_pid[3]; | 314 | u8 b_pid[3]; |
297 | struct i2c_msg msg[] = { | 315 | struct i2c_msg msg[] = { |
298 | {.addr = 0xb1a6,.buf = b_pid,.len = 3}, | 316 | {.addr = ADDR_B1A6_STREAM_CTRL,.buf = b_pid,.len = 3}, |
299 | }; | 317 | }; |
300 | if (dvb_usb_opera1_debug) | 318 | if (dvb_usb_opera1_debug) |
301 | info("%s hw-pidfilter", onoff ? "enable" : "disable"); | 319 | info("%s hw-pidfilter", onoff ? "enable" : "disable"); |
@@ -345,7 +363,7 @@ static int opera1_rc_query(struct dvb_usb_device *dev, u32 * event, int *state) | |||
345 | const u16 startmarker1 = 0x10ed; | 363 | const u16 startmarker1 = 0x10ed; |
346 | const u16 startmarker2 = 0x11ec; | 364 | const u16 startmarker2 = 0x11ec; |
347 | struct i2c_msg read_remote[] = { | 365 | struct i2c_msg read_remote[] = { |
348 | {.addr = 0xb880,.buf = rcbuffer,.flags = I2C_M_RD,.len = 32}, | 366 | {.addr = ADDR_B880_READ_REMOTE,.buf = rcbuffer,.flags = I2C_M_RD,.len = 32}, |
349 | }; | 367 | }; |
350 | int i = 0; | 368 | int i = 0; |
351 | u32 send_key = 0; | 369 | u32 send_key = 0; |
@@ -467,7 +485,7 @@ static int opera1_xilinx_load_firmware(struct usb_device *dev, | |||
467 | static struct dvb_usb_device_properties opera1_properties = { | 485 | static struct dvb_usb_device_properties opera1_properties = { |
468 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | 486 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
469 | .usb_ctrl = CYPRESS_FX2, | 487 | .usb_ctrl = CYPRESS_FX2, |
470 | .firmware = "opera.fw", | 488 | .firmware = "dvb-usb-opera-01.fw", |
471 | .size_of_priv = sizeof(struct opera1_state), | 489 | .size_of_priv = sizeof(struct opera1_state), |
472 | 490 | ||
473 | .power_ctrl = opera1_power_ctrl, | 491 | .power_ctrl = opera1_power_ctrl, |
@@ -522,7 +540,7 @@ static int opera1_probe(struct usb_interface *intf, | |||
522 | if (udev->descriptor.idProduct == USB_PID_OPERA1_WARM && | 540 | if (udev->descriptor.idProduct == USB_PID_OPERA1_WARM && |
523 | udev->descriptor.idVendor == USB_VID_OPERA1 && | 541 | udev->descriptor.idVendor == USB_VID_OPERA1 && |
524 | (d == NULL | 542 | (d == NULL |
525 | || opera1_xilinx_load_firmware(udev, "opera1-fpga.fw") != 0) | 543 | || opera1_xilinx_load_firmware(udev, "dvb-usb-opera1-fpga.fw") != 0) |
526 | ) { | 544 | ) { |
527 | return -EINVAL; | 545 | return -EINVAL; |
528 | } | 546 | } |