summaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/dw2102.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dvb-usb/dw2102.c')
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.c403
1 files changed, 289 insertions, 114 deletions
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
index 75de49c0d94..5bb9479d154 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -1,6 +1,6 @@
/* DVB USB framework compliant Linux driver for the
* DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
-* TeVii S600, S650 Cards
+* TeVii S600, S630, S650 Cards
* Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by)
*
* This program is free software; you can redistribute it and/or modify it
@@ -18,6 +18,8 @@
#include "eds1547.h"
#include "cx24116.h"
#include "tda1002x.h"
+#include "mt312.h"
+#include "zl10039.h"
#ifndef USB_PID_DW2102
#define USB_PID_DW2102 0x2102
@@ -39,6 +41,10 @@
#define USB_PID_TEVII_S650 0xd650
#endif
+#ifndef USB_PID_TEVII_S630
+#define USB_PID_TEVII_S630 0xd630
+#endif
+
#define DW210X_READ_MSG 0
#define DW210X_WRITE_MSG 1
@@ -436,6 +442,69 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
return num;
}
+static int s630_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+ int num)
+{
+ struct dvb_usb_device *d = i2c_get_adapdata(adap);
+ int ret = 0;
+
+ if (!d)
+ return -ENODEV;
+ if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+ return -EAGAIN;
+
+ switch (num) {
+ case 2: { /* read */
+ u8 ibuf[msg[1].len], obuf[3];
+ obuf[0] = msg[1].len;
+ obuf[1] = (msg[0].addr << 1);
+ obuf[2] = msg[0].buf[0];
+
+ ret = dw210x_op_rw(d->udev, 0x90, 0, 0,
+ obuf, 3, DW210X_WRITE_MSG);
+ msleep(5);
+ ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
+ ibuf, msg[1].len, DW210X_READ_MSG);
+ memcpy(msg[1].buf, ibuf, msg[1].len);
+ break;
+ }
+ case 1:
+ switch (msg[0].addr) {
+ case 0x60:
+ case 0x0e: {
+ /* write to zl10313, zl10039 register, */
+ u8 obuf[msg[0].len + 2];
+ obuf[0] = msg[0].len + 1;
+ obuf[1] = (msg[0].addr << 1);
+ memcpy(obuf + 2, msg[0].buf, msg[0].len);
+ ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
+ obuf, msg[0].len + 2, DW210X_WRITE_MSG);
+ break;
+ }
+ case (DW2102_RC_QUERY): {
+ u8 ibuf[4];
+ ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
+ ibuf, 4, DW210X_READ_MSG);
+ msg[0].buf[0] = ibuf[3];
+ break;
+ }
+ case (DW2102_VOLTAGE_CTRL): {
+ u8 obuf[2];
+ obuf[0] = 0x03;
+ obuf[1] = msg[0].buf[0];
+ ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
+ obuf, 2, DW210X_WRITE_MSG);
+ break;
+ }
+ }
+
+ break;
+ }
+
+ mutex_unlock(&d->i2c_mutex);
+ return num;
+}
+
static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
{
return I2C_FUNC_I2C;
@@ -466,6 +535,11 @@ static struct i2c_algorithm dw3101_i2c_algo = {
.functionality = dw210x_i2c_func,
};
+static struct i2c_algorithm s630_i2c_algo = {
+ .master_xfer = s630_i2c_transfer,
+ .functionality = dw210x_i2c_func,
+};
+
static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
{
int i;
@@ -490,6 +564,37 @@ static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
return 0;
};
+static int s630_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
+{
+ int i, ret;
+ u8 buf[3], eeprom[256], eepromline[16];
+
+ for (i = 0; i < 256; i++) {
+ buf[0] = 1;
+ buf[1] = 0xa0;
+ buf[2] = i;
+ ret = dw210x_op_rw(d->udev, 0x90, 0, 0,
+ buf, 3, DW210X_WRITE_MSG);
+ ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
+ buf, 1, DW210X_READ_MSG);
+ if (ret < 0) {
+ err("read eeprom failed.");
+ return -1;
+ } else {
+ eepromline[i % 16] = buf[0];
+ eeprom[i] = buf[0];
+ }
+
+ if ((i % 16) == 15) {
+ deb_xfer("%02x: ", i - 15);
+ debug_dump(eepromline, 16, deb_xfer);
+ }
+ }
+
+ memcpy(mac, eeprom + 16, 6);
+ return 0;
+};
+
static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
{
static u8 command_13v[1] = {0x00};
@@ -535,6 +640,10 @@ static struct tda10023_config dw3101_tda10023_config = {
.invert = 1,
};
+static struct mt312_config zl313_config = {
+ .demod_address = 0x0e,
+};
+
static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
{
if ((d->fe = dvb_attach(cx24116_attach, &dw2104_config,
@@ -596,6 +705,18 @@ static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
return -EIO;
}
+static int s630_frontend_attach(struct dvb_usb_adapter *d)
+{
+ d->fe = dvb_attach(mt312_attach, &zl313_config,
+ &d->dev->i2c_adap);
+ if (d->fe != NULL) {
+ d->fe->ops.set_voltage = dw210x_set_voltage;
+ info("Attached zl10313!\n");
+ return 0;
+ }
+ return -EIO;
+}
+
static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
{
dvb_attach(dvb_pll_attach, adap->fe, 0x60,
@@ -619,123 +740,131 @@ static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
return 0;
}
+static int s630_zl10039_tuner_attach(struct dvb_usb_adapter *adap)
+{
+ dvb_attach(zl10039_attach, adap->fe, 0x60,
+ &adap->dev->i2c_adap);
+
+ return 0;
+}
+
static struct dvb_usb_rc_key dw210x_rc_keys[] = {
- { 0xf8, 0x0a, KEY_Q }, /*power*/
- { 0xf8, 0x0c, KEY_M }, /*mute*/
- { 0xf8, 0x11, KEY_1 },
- { 0xf8, 0x12, KEY_2 },
- { 0xf8, 0x13, KEY_3 },
- { 0xf8, 0x14, KEY_4 },
- { 0xf8, 0x15, KEY_5 },
- { 0xf8, 0x16, KEY_6 },
- { 0xf8, 0x17, KEY_7 },
- { 0xf8, 0x18, KEY_8 },
- { 0xf8, 0x19, KEY_9 },
- { 0xf8, 0x10, KEY_0 },
- { 0xf8, 0x1c, KEY_PAGEUP }, /*ch+*/
- { 0xf8, 0x0f, KEY_PAGEDOWN }, /*ch-*/
- { 0xf8, 0x1a, KEY_O }, /*vol+*/
- { 0xf8, 0x0e, KEY_Z }, /*vol-*/
- { 0xf8, 0x04, KEY_R }, /*rec*/
- { 0xf8, 0x09, KEY_D }, /*fav*/
- { 0xf8, 0x08, KEY_BACKSPACE }, /*rewind*/
- { 0xf8, 0x07, KEY_A }, /*fast*/
- { 0xf8, 0x0b, KEY_P }, /*pause*/
- { 0xf8, 0x02, KEY_ESC }, /*cancel*/
- { 0xf8, 0x03, KEY_G }, /*tab*/
- { 0xf8, 0x00, KEY_UP }, /*up*/
- { 0xf8, 0x1f, KEY_ENTER }, /*ok*/
- { 0xf8, 0x01, KEY_DOWN }, /*down*/
- { 0xf8, 0x05, KEY_C }, /*cap*/
- { 0xf8, 0x06, KEY_S }, /*stop*/
- { 0xf8, 0x40, KEY_F }, /*full*/
- { 0xf8, 0x1e, KEY_W }, /*tvmode*/
- { 0xf8, 0x1b, KEY_B }, /*recall*/
+ { 0xf80a, KEY_Q }, /*power*/
+ { 0xf80c, KEY_M }, /*mute*/
+ { 0xf811, KEY_1 },
+ { 0xf812, KEY_2 },
+ { 0xf813, KEY_3 },
+ { 0xf814, KEY_4 },
+ { 0xf815, KEY_5 },
+ { 0xf816, KEY_6 },
+ { 0xf817, KEY_7 },
+ { 0xf818, KEY_8 },
+ { 0xf819, KEY_9 },
+ { 0xf810, KEY_0 },
+ { 0xf81c, KEY_PAGEUP }, /*ch+*/
+ { 0xf80f, KEY_PAGEDOWN }, /*ch-*/
+ { 0xf81a, KEY_O }, /*vol+*/
+ { 0xf80e, KEY_Z }, /*vol-*/
+ { 0xf804, KEY_R }, /*rec*/
+ { 0xf809, KEY_D }, /*fav*/
+ { 0xf808, KEY_BACKSPACE }, /*rewind*/
+ { 0xf807, KEY_A }, /*fast*/
+ { 0xf80b, KEY_P }, /*pause*/
+ { 0xf802, KEY_ESC }, /*cancel*/
+ { 0xf803, KEY_G }, /*tab*/
+ { 0xf800, KEY_UP }, /*up*/
+ { 0xf81f, KEY_ENTER }, /*ok*/
+ { 0xf801, KEY_DOWN }, /*down*/
+ { 0xf805, KEY_C }, /*cap*/
+ { 0xf806, KEY_S }, /*stop*/
+ { 0xf840, KEY_F }, /*full*/
+ { 0xf81e, KEY_W }, /*tvmode*/
+ { 0xf81b, KEY_B }, /*recall*/
};
static struct dvb_usb_rc_key tevii_rc_keys[] = {
- { 0xf8, 0x0a, KEY_POWER },
- { 0xf8, 0x0c, KEY_MUTE },
- { 0xf8, 0x11, KEY_1 },
- { 0xf8, 0x12, KEY_2 },
- { 0xf8, 0x13, KEY_3 },
- { 0xf8, 0x14, KEY_4 },
- { 0xf8, 0x15, KEY_5 },
- { 0xf8, 0x16, KEY_6 },
- { 0xf8, 0x17, KEY_7 },
- { 0xf8, 0x18, KEY_8 },
- { 0xf8, 0x19, KEY_9 },
- { 0xf8, 0x10, KEY_0 },
- { 0xf8, 0x1c, KEY_MENU },
- { 0xf8, 0x0f, KEY_VOLUMEDOWN },
- { 0xf8, 0x1a, KEY_LAST },
- { 0xf8, 0x0e, KEY_OPEN },
- { 0xf8, 0x04, KEY_RECORD },
- { 0xf8, 0x09, KEY_VOLUMEUP },
- { 0xf8, 0x08, KEY_CHANNELUP },
- { 0xf8, 0x07, KEY_PVR },
- { 0xf8, 0x0b, KEY_TIME },
- { 0xf8, 0x02, KEY_RIGHT },
- { 0xf8, 0x03, KEY_LEFT },
- { 0xf8, 0x00, KEY_UP },
- { 0xf8, 0x1f, KEY_OK },
- { 0xf8, 0x01, KEY_DOWN },
- { 0xf8, 0x05, KEY_TUNER },
- { 0xf8, 0x06, KEY_CHANNELDOWN },
- { 0xf8, 0x40, KEY_PLAYPAUSE },
- { 0xf8, 0x1e, KEY_REWIND },
- { 0xf8, 0x1b, KEY_FAVORITES },
- { 0xf8, 0x1d, KEY_BACK },
- { 0xf8, 0x4d, KEY_FASTFORWARD },
- { 0xf8, 0x44, KEY_EPG },
- { 0xf8, 0x4c, KEY_INFO },
- { 0xf8, 0x41, KEY_AB },
- { 0xf8, 0x43, KEY_AUDIO },
- { 0xf8, 0x45, KEY_SUBTITLE },
- { 0xf8, 0x4a, KEY_LIST },
- { 0xf8, 0x46, KEY_F1 },
- { 0xf8, 0x47, KEY_F2 },
- { 0xf8, 0x5e, KEY_F3 },
- { 0xf8, 0x5c, KEY_F4 },
- { 0xf8, 0x52, KEY_F5 },
- { 0xf8, 0x5a, KEY_F6 },
- { 0xf8, 0x56, KEY_MODE },
- { 0xf8, 0x58, KEY_SWITCHVIDEOMODE },
+ { 0xf80a, KEY_POWER },
+ { 0xf80c, KEY_MUTE },
+ { 0xf811, KEY_1 },
+ { 0xf812, KEY_2 },
+ { 0xf813, KEY_3 },
+ { 0xf814, KEY_4 },
+ { 0xf815, KEY_5 },
+ { 0xf816, KEY_6 },
+ { 0xf817, KEY_7 },
+ { 0xf818, KEY_8 },
+ { 0xf819, KEY_9 },
+ { 0xf810, KEY_0 },
+ { 0xf81c, KEY_MENU },
+ { 0xf80f, KEY_VOLUMEDOWN },
+ { 0xf81a, KEY_LAST },
+ { 0xf80e, KEY_OPEN },
+ { 0xf804, KEY_RECORD },
+ { 0xf809, KEY_VOLUMEUP },
+ { 0xf808, KEY_CHANNELUP },
+ { 0xf807, KEY_PVR },
+ { 0xf80b, KEY_TIME },
+ { 0xf802, KEY_RIGHT },
+ { 0xf803, KEY_LEFT },
+ { 0xf800, KEY_UP },
+ { 0xf81f, KEY_OK },
+ { 0xf801, KEY_DOWN },
+ { 0xf805, KEY_TUNER },
+ { 0xf806, KEY_CHANNELDOWN },
+ { 0xf840, KEY_PLAYPAUSE },
+ { 0xf81e, KEY_REWIND },
+ { 0xf81b, KEY_FAVORITES },
+ { 0xf81d, KEY_BACK },
+ { 0xf84d, KEY_FASTFORWARD },
+ { 0xf844, KEY_EPG },
+ { 0xf84c, KEY_INFO },
+ { 0xf841, KEY_AB },
+ { 0xf843, KEY_AUDIO },
+ { 0xf845, KEY_SUBTITLE },
+ { 0xf84a, KEY_LIST },
+ { 0xf846, KEY_F1 },
+ { 0xf847, KEY_F2 },
+ { 0xf85e, KEY_F3 },
+ { 0xf85c, KEY_F4 },
+ { 0xf852, KEY_F5 },
+ { 0xf85a, KEY_F6 },
+ { 0xf856, KEY_MODE },
+ { 0xf858, KEY_SWITCHVIDEOMODE },
};
static struct dvb_usb_rc_key tbs_rc_keys[] = {
- { 0xf8, 0x84, KEY_POWER },
- { 0xf8, 0x94, KEY_MUTE },
- { 0xf8, 0x87, KEY_1 },
- { 0xf8, 0x86, KEY_2 },
- { 0xf8, 0x85, KEY_3 },
- { 0xf8, 0x8b, KEY_4 },
- { 0xf8, 0x8a, KEY_5 },
- { 0xf8, 0x89, KEY_6 },
- { 0xf8, 0x8f, KEY_7 },
- { 0xf8, 0x8e, KEY_8 },
- { 0xf8, 0x8d, KEY_9 },
- { 0xf8, 0x92, KEY_0 },
- { 0xf8, 0x96, KEY_CHANNELUP },
- { 0xf8, 0x91, KEY_CHANNELDOWN },
- { 0xf8, 0x93, KEY_VOLUMEUP },
- { 0xf8, 0x8c, KEY_VOLUMEDOWN },
- { 0xf8, 0x83, KEY_RECORD },
- { 0xf8, 0x98, KEY_PAUSE },
- { 0xf8, 0x99, KEY_OK },
- { 0xf8, 0x9a, KEY_SHUFFLE },
- { 0xf8, 0x81, KEY_UP },
- { 0xf8, 0x90, KEY_LEFT },
- { 0xf8, 0x82, KEY_RIGHT },
- { 0xf8, 0x88, KEY_DOWN },
- { 0xf8, 0x95, KEY_FAVORITES },
- { 0xf8, 0x97, KEY_SUBTITLE },
- { 0xf8, 0x9d, KEY_ZOOM },
- { 0xf8, 0x9f, KEY_EXIT },
- { 0xf8, 0x9e, KEY_MENU },
- { 0xf8, 0x9c, KEY_EPG },
- { 0xf8, 0x80, KEY_PREVIOUS },
- { 0xf8, 0x9b, KEY_MODE }
+ { 0xf884, KEY_POWER },
+ { 0xf894, KEY_MUTE },
+ { 0xf887, KEY_1 },
+ { 0xf886, KEY_2 },
+ { 0xf885, KEY_3 },
+ { 0xf88b, KEY_4 },
+ { 0xf88a, KEY_5 },
+ { 0xf889, KEY_6 },
+ { 0xf88f, KEY_7 },
+ { 0xf88e, KEY_8 },
+ { 0xf88d, KEY_9 },
+ { 0xf892, KEY_0 },
+ { 0xf896, KEY_CHANNELUP },
+ { 0xf891, KEY_CHANNELDOWN },
+ { 0xf893, KEY_VOLUMEUP },
+ { 0xf88c, KEY_VOLUMEDOWN },
+ { 0xf883, KEY_RECORD },
+ { 0xf898, KEY_PAUSE },
+ { 0xf899, KEY_OK },
+ { 0xf89a, KEY_SHUFFLE },
+ { 0xf881, KEY_UP },
+ { 0xf890, KEY_LEFT },
+ { 0xf882, KEY_RIGHT },
+ { 0xf888, KEY_DOWN },
+ { 0xf895, KEY_FAVORITES },
+ { 0xf897, KEY_SUBTITLE },
+ { 0xf89d, KEY_ZOOM },
+ { 0xf89f, KEY_EXIT },
+ { 0xf89e, KEY_MENU },
+ { 0xf89c, KEY_EPG },
+ { 0xf880, KEY_PREVIOUS },
+ { 0xf89b, KEY_MODE }
};
static struct dvb_usb_rc_keys_table keys_tables[] = {
@@ -763,9 +892,9 @@ static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
}
*state = REMOTE_NO_KEY_PRESSED;
- if (dw2102_i2c_transfer(&d->i2c_adap, &msg, 1) == 1) {
+ if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
for (i = 0; i < keymap_size ; i++) {
- if (keymap[i].data == msg.buf[0]) {
+ if (rc5_data(&keymap[i]) == msg.buf[0]) {
*state = REMOTE_KEY_PRESSED;
*event = keymap[i].event;
break;
@@ -792,6 +921,7 @@ static struct usb_device_id dw2102_table[] = {
{USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
{USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
{USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
+ {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
{ }
};
@@ -806,6 +936,7 @@ static int dw2102_load_firmware(struct usb_device *dev,
u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
const struct firmware *fw;
const char *filename = "dvb-usb-dw2101.fw";
+
switch (dev->descriptor.idProduct) {
case 0x2101:
ret = request_firmware(&fw, filename, &dev->dev);
@@ -1053,6 +1184,48 @@ static struct dvb_usb_device_properties dw3101_properties = {
}
};
+static struct dvb_usb_device_properties s630_properties = {
+ .caps = DVB_USB_IS_AN_I2C_ADAPTER,
+ .usb_ctrl = DEVICE_SPECIFIC,
+ .firmware = "dvb-usb-s630.fw",
+ .no_reconnect = 1,
+
+ .i2c_algo = &s630_i2c_algo,
+ .rc_key_map = tevii_rc_keys,
+ .rc_key_map_size = ARRAY_SIZE(tevii_rc_keys),
+ .rc_interval = 150,
+ .rc_query = dw2102_rc_query,
+
+ .generic_bulk_ctrl_endpoint = 0x81,
+ .num_adapters = 1,
+ .download_firmware = dw2102_load_firmware,
+ .read_mac_address = s630_read_mac_address,
+ .adapter = {
+ {
+ .frontend_attach = s630_frontend_attach,
+ .streaming_ctrl = NULL,
+ .tuner_attach = s630_zl10039_tuner_attach,
+ .stream = {
+ .type = USB_BULK,
+ .count = 8,
+ .endpoint = 0x82,
+ .u = {
+ .bulk = {
+ .buffersize = 4096,
+ }
+ }
+ },
+ }
+ },
+ .num_device_descs = 1,
+ .devices = {
+ {"TeVii S630 USB",
+ {&dw2102_table[6], NULL},
+ {NULL},
+ },
+ }
+};
+
static int dw2102_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
@@ -1061,6 +1234,8 @@ static int dw2102_probe(struct usb_interface *intf,
0 == dvb_usb_device_init(intf, &dw2104_properties,
THIS_MODULE, NULL, adapter_nr) ||
0 == dvb_usb_device_init(intf, &dw3101_properties,
+ THIS_MODULE, NULL, adapter_nr) ||
+ 0 == dvb_usb_device_init(intf, &s630_properties,
THIS_MODULE, NULL, adapter_nr)) {
return 0;
}
@@ -1094,6 +1269,6 @@ module_exit(dw2102_module_exit);
MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
" DVB-C 3101 USB2.0,"
- " TeVii S600, S650 USB2.0 devices");
+ " TeVii S600, S630, S650 USB2.0 devices");
MODULE_VERSION("0.1");
MODULE_LICENSE("GPL");