Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1 | /* DVB USB framework compliant Linux driver for the |
Igor M. Liplianin | 2f30fb4 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2 | * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 3 | * TeVii S600, S630, S650, S660, S480, S421, S632 |
Igor M. Liplianin | 2f30fb4 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 4 | * Prof 1100, 7500, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 5 | * Geniatech SU3000 Cards |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 6 | * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by) |
Igor M. Liplianin | 2f30fb4 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation, version 2. |
| 11 | * |
| 12 | * see Documentation/dvb/README.dvb-usb for more information |
| 13 | */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 14 | #include "dw2102.h" |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 15 | #include "si21xx.h" |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 16 | #include "stv0299.h" |
| 17 | #include "z0194a.h" |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 18 | #include "stv0288.h" |
| 19 | #include "stb6000.h" |
| 20 | #include "eds1547.h" |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 21 | #include "cx24116.h" |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 22 | #include "tda1002x.h" |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 23 | #include "mt312.h" |
| 24 | #include "zl10039.h" |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 25 | #include "ts2020.h" |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 26 | #include "ds3000.h" |
| 27 | #include "stv0900.h" |
| 28 | #include "stv6110.h" |
| 29 | #include "stb6100.h" |
| 30 | #include "stb6100_proc.h" |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 31 | #include "m88rs2000.h" |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 32 | |
| 33 | #ifndef USB_PID_DW2102 |
| 34 | #define USB_PID_DW2102 0x2102 |
| 35 | #endif |
| 36 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 37 | #ifndef USB_PID_DW2104 |
| 38 | #define USB_PID_DW2104 0x2104 |
| 39 | #endif |
| 40 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 41 | #ifndef USB_PID_DW3101 |
| 42 | #define USB_PID_DW3101 0x3101 |
| 43 | #endif |
| 44 | |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 45 | #ifndef USB_PID_CINERGY_S |
| 46 | #define USB_PID_CINERGY_S 0x0064 |
| 47 | #endif |
| 48 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 49 | #ifndef USB_PID_TEVII_S630 |
| 50 | #define USB_PID_TEVII_S630 0xd630 |
| 51 | #endif |
| 52 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 53 | #ifndef USB_PID_TEVII_S650 |
| 54 | #define USB_PID_TEVII_S650 0xd650 |
| 55 | #endif |
| 56 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 57 | #ifndef USB_PID_TEVII_S660 |
| 58 | #define USB_PID_TEVII_S660 0xd660 |
| 59 | #endif |
| 60 | |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 61 | #ifndef USB_PID_TEVII_S480_1 |
| 62 | #define USB_PID_TEVII_S480_1 0xd481 |
| 63 | #endif |
| 64 | |
| 65 | #ifndef USB_PID_TEVII_S480_2 |
| 66 | #define USB_PID_TEVII_S480_2 0xd482 |
| 67 | #endif |
| 68 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 69 | #ifndef USB_PID_PROF_1100 |
| 70 | #define USB_PID_PROF_1100 0xb012 |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 71 | #endif |
| 72 | |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 73 | #ifndef USB_PID_TEVII_S421 |
| 74 | #define USB_PID_TEVII_S421 0xd421 |
| 75 | #endif |
| 76 | |
| 77 | #ifndef USB_PID_TEVII_S632 |
| 78 | #define USB_PID_TEVII_S632 0xd632 |
| 79 | #endif |
| 80 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 81 | #define DW210X_READ_MSG 0 |
| 82 | #define DW210X_WRITE_MSG 1 |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 83 | |
| 84 | #define REG_1F_SYMBOLRATE_BYTE0 0x1f |
| 85 | #define REG_20_SYMBOLRATE_BYTE1 0x20 |
| 86 | #define REG_21_SYMBOLRATE_BYTE2 0x21 |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 87 | /* on my own*/ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 88 | #define DW2102_VOLTAGE_CTRL (0x1800) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 89 | #define SU3000_STREAM_CTRL (0x1900) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 90 | #define DW2102_RC_QUERY (0x1a00) |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 91 | #define DW2102_LED_CTRL (0x1b00) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 92 | |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 93 | #define DW2101_FIRMWARE "dvb-usb-dw2101.fw" |
| 94 | #define DW2102_FIRMWARE "dvb-usb-dw2102.fw" |
| 95 | #define DW2104_FIRMWARE "dvb-usb-dw2104.fw" |
| 96 | #define DW3101_FIRMWARE "dvb-usb-dw3101.fw" |
| 97 | #define S630_FIRMWARE "dvb-usb-s630.fw" |
| 98 | #define S660_FIRMWARE "dvb-usb-s660.fw" |
| 99 | #define P1100_FIRMWARE "dvb-usb-p1100.fw" |
| 100 | #define P7500_FIRMWARE "dvb-usb-p7500.fw" |
| 101 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 102 | #define err_str "did not find the firmware file. (%s) " \ |
| 103 | "Please see linux/Documentation/dvb/ for more details " \ |
| 104 | "on firmware-problems." |
| 105 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 106 | struct rc_map_dvb_usb_table_table { |
| 107 | struct rc_map_table *rc_keys; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 108 | int rc_keys_size; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 109 | }; |
| 110 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 111 | struct su3000_state { |
| 112 | u8 initialized; |
| 113 | }; |
| 114 | |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 115 | struct s6x0_state { |
| 116 | int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v); |
| 117 | }; |
| 118 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 119 | /* debug */ |
| 120 | static int dvb_usb_dw2102_debug; |
| 121 | module_param_named(debug, dvb_usb_dw2102_debug, int, 0644); |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 122 | MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))." |
| 123 | DVB_USB_DEBUG_STATUS); |
| 124 | |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 125 | /* keymaps */ |
| 126 | static int ir_keymap; |
| 127 | module_param_named(keymap, ir_keymap, int, 0644); |
Igor M. Liplianin | feb16e9 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 128 | MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..." |
| 129 | " 256=none"); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 130 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 131 | /* demod probe */ |
| 132 | static int demod_probe = 1; |
| 133 | module_param_named(demod, demod_probe, int, 0644); |
| 134 | MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 " |
| 135 | "4=stv0903+stb6100(or-able))."); |
| 136 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 137 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 138 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 139 | static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 140 | u16 index, u8 * data, u16 len, int flags) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 141 | { |
| 142 | int ret; |
Florian Mickler | b47b850 | 2011-03-21 15:33:44 -0300 | [diff] [blame] | 143 | u8 *u8buf; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 144 | unsigned int pipe = (flags == DW210X_READ_MSG) ? |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 145 | usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 146 | u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 147 | |
Florian Mickler | b47b850 | 2011-03-21 15:33:44 -0300 | [diff] [blame] | 148 | u8buf = kmalloc(len, GFP_KERNEL); |
| 149 | if (!u8buf) |
| 150 | return -ENOMEM; |
| 151 | |
| 152 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 153 | if (flags == DW210X_WRITE_MSG) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 154 | memcpy(u8buf, data, len); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 155 | ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, |
| 156 | value, index , u8buf, len, 2000); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 157 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 158 | if (flags == DW210X_READ_MSG) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 159 | memcpy(data, u8buf, len); |
Florian Mickler | b47b850 | 2011-03-21 15:33:44 -0300 | [diff] [blame] | 160 | |
| 161 | kfree(u8buf); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 162 | return ret; |
| 163 | } |
| 164 | |
| 165 | /* I2C */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 166 | static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 167 | int num) |
| 168 | { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 169 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 170 | int i = 0; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 171 | u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0}; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 172 | u16 value; |
| 173 | |
| 174 | if (!d) |
| 175 | return -ENODEV; |
| 176 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 177 | return -EAGAIN; |
| 178 | |
| 179 | switch (num) { |
| 180 | case 2: |
| 181 | /* read stv0299 register */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 182 | value = msg[0].buf[0];/* register */ |
| 183 | for (i = 0; i < msg[1].len; i++) { |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 184 | dw210x_op_rw(d->udev, 0xb5, value + i, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 185 | buf6, 2, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 186 | msg[1].buf[i] = buf6[0]; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 187 | } |
| 188 | break; |
| 189 | case 1: |
| 190 | switch (msg[0].addr) { |
| 191 | case 0x68: |
| 192 | /* write to stv0299 register */ |
| 193 | buf6[0] = 0x2a; |
| 194 | buf6[1] = msg[0].buf[0]; |
| 195 | buf6[2] = msg[0].buf[1]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 196 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 197 | buf6, 3, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 198 | break; |
| 199 | case 0x60: |
| 200 | if (msg[0].flags == 0) { |
| 201 | /* write to tuner pll */ |
| 202 | buf6[0] = 0x2c; |
| 203 | buf6[1] = 5; |
| 204 | buf6[2] = 0xc0; |
| 205 | buf6[3] = msg[0].buf[0]; |
| 206 | buf6[4] = msg[0].buf[1]; |
| 207 | buf6[5] = msg[0].buf[2]; |
| 208 | buf6[6] = msg[0].buf[3]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 209 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 210 | buf6, 7, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 211 | } else { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 212 | /* read from tuner */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 213 | dw210x_op_rw(d->udev, 0xb5, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 214 | buf6, 1, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 215 | msg[0].buf[0] = buf6[0]; |
| 216 | } |
| 217 | break; |
| 218 | case (DW2102_RC_QUERY): |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 219 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 220 | buf6, 2, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 221 | msg[0].buf[0] = buf6[0]; |
| 222 | msg[0].buf[1] = buf6[1]; |
| 223 | break; |
| 224 | case (DW2102_VOLTAGE_CTRL): |
| 225 | buf6[0] = 0x30; |
| 226 | buf6[1] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 227 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 228 | buf6, 2, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 229 | break; |
| 230 | } |
| 231 | |
| 232 | break; |
| 233 | } |
| 234 | |
| 235 | mutex_unlock(&d->i2c_mutex); |
| 236 | return num; |
| 237 | } |
| 238 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 239 | static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap, |
| 240 | struct i2c_msg msg[], int num) |
| 241 | { |
| 242 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 243 | u8 buf6[] = {0, 0, 0, 0, 0, 0, 0}; |
| 244 | |
| 245 | if (!d) |
| 246 | return -ENODEV; |
| 247 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 248 | return -EAGAIN; |
| 249 | |
| 250 | switch (num) { |
| 251 | case 2: |
| 252 | /* read si2109 register by number */ |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 253 | buf6[0] = msg[0].addr << 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 254 | buf6[1] = msg[0].len; |
| 255 | buf6[2] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 256 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 257 | buf6, msg[0].len + 2, DW210X_WRITE_MSG); |
| 258 | /* read si2109 register */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 259 | dw210x_op_rw(d->udev, 0xc3, 0xd0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 260 | buf6, msg[1].len + 2, DW210X_READ_MSG); |
| 261 | memcpy(msg[1].buf, buf6 + 2, msg[1].len); |
| 262 | |
| 263 | break; |
| 264 | case 1: |
| 265 | switch (msg[0].addr) { |
| 266 | case 0x68: |
| 267 | /* write to si2109 register */ |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 268 | buf6[0] = msg[0].addr << 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 269 | buf6[1] = msg[0].len; |
| 270 | memcpy(buf6 + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 271 | dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 272 | msg[0].len + 2, DW210X_WRITE_MSG); |
| 273 | break; |
| 274 | case(DW2102_RC_QUERY): |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 275 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 276 | buf6, 2, DW210X_READ_MSG); |
| 277 | msg[0].buf[0] = buf6[0]; |
| 278 | msg[0].buf[1] = buf6[1]; |
| 279 | break; |
| 280 | case(DW2102_VOLTAGE_CTRL): |
| 281 | buf6[0] = 0x30; |
| 282 | buf6[1] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 283 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 284 | buf6, 2, DW210X_WRITE_MSG); |
| 285 | break; |
| 286 | } |
| 287 | break; |
| 288 | } |
| 289 | |
| 290 | mutex_unlock(&d->i2c_mutex); |
| 291 | return num; |
| 292 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 293 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 294 | static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
| 295 | { |
| 296 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 297 | |
| 298 | if (!d) |
| 299 | return -ENODEV; |
| 300 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 301 | return -EAGAIN; |
| 302 | |
| 303 | switch (num) { |
| 304 | case 2: { |
| 305 | /* read */ |
| 306 | /* first write first register number */ |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 307 | u8 ibuf[msg[1].len + 2], obuf[3]; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 308 | obuf[0] = msg[0].addr << 1; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 309 | obuf[1] = msg[0].len; |
| 310 | obuf[2] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 311 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 312 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 313 | /* second read registers */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 314 | dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 315 | ibuf, msg[1].len + 2, DW210X_READ_MSG); |
| 316 | memcpy(msg[1].buf, ibuf + 2, msg[1].len); |
| 317 | |
| 318 | break; |
| 319 | } |
| 320 | case 1: |
| 321 | switch (msg[0].addr) { |
| 322 | case 0x68: { |
| 323 | /* write to register */ |
| 324 | u8 obuf[msg[0].len + 2]; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 325 | obuf[0] = msg[0].addr << 1; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 326 | obuf[1] = msg[0].len; |
| 327 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 328 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 329 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 330 | break; |
| 331 | } |
| 332 | case 0x61: { |
| 333 | /* write to tuner */ |
| 334 | u8 obuf[msg[0].len + 2]; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 335 | obuf[0] = msg[0].addr << 1; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 336 | obuf[1] = msg[0].len; |
| 337 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 338 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 339 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 340 | break; |
| 341 | } |
| 342 | case(DW2102_RC_QUERY): { |
| 343 | u8 ibuf[2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 344 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 345 | ibuf, 2, DW210X_READ_MSG); |
| 346 | memcpy(msg[0].buf, ibuf , 2); |
| 347 | break; |
| 348 | } |
| 349 | case(DW2102_VOLTAGE_CTRL): { |
| 350 | u8 obuf[2]; |
| 351 | obuf[0] = 0x30; |
| 352 | obuf[1] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 353 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 354 | obuf, 2, DW210X_WRITE_MSG); |
| 355 | break; |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | break; |
| 360 | } |
| 361 | |
| 362 | mutex_unlock(&d->i2c_mutex); |
| 363 | return num; |
| 364 | } |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 365 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 366 | static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
| 367 | { |
| 368 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 369 | int len, i, j; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 370 | |
| 371 | if (!d) |
| 372 | return -ENODEV; |
| 373 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 374 | return -EAGAIN; |
| 375 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 376 | for (j = 0; j < num; j++) { |
| 377 | switch (msg[j].addr) { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 378 | case(DW2102_RC_QUERY): { |
| 379 | u8 ibuf[2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 380 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 381 | ibuf, 2, DW210X_READ_MSG); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 382 | memcpy(msg[j].buf, ibuf , 2); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 383 | break; |
| 384 | } |
| 385 | case(DW2102_VOLTAGE_CTRL): { |
| 386 | u8 obuf[2]; |
| 387 | obuf[0] = 0x30; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 388 | obuf[1] = msg[j].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 389 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 390 | obuf, 2, DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 391 | break; |
| 392 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 393 | /*case 0x55: cx24116 |
| 394 | case 0x6a: stv0903 |
| 395 | case 0x68: ds3000, stv0903 |
| 396 | case 0x60: ts2020, stv6110, stb6100 */ |
| 397 | default: { |
| 398 | if (msg[j].flags == I2C_M_RD) { |
| 399 | /* read registers */ |
| 400 | u8 ibuf[msg[j].len + 2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 401 | dw210x_op_rw(d->udev, 0xc3, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 402 | (msg[j].addr << 1) + 1, 0, |
| 403 | ibuf, msg[j].len + 2, |
| 404 | DW210X_READ_MSG); |
| 405 | memcpy(msg[j].buf, ibuf + 2, msg[j].len); |
| 406 | mdelay(10); |
| 407 | } else if (((msg[j].buf[0] == 0xb0) && |
| 408 | (msg[j].addr == 0x68)) || |
| 409 | ((msg[j].buf[0] == 0xf7) && |
| 410 | (msg[j].addr == 0x55))) { |
| 411 | /* write firmware */ |
| 412 | u8 obuf[19]; |
| 413 | obuf[0] = msg[j].addr << 1; |
| 414 | obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len); |
| 415 | obuf[2] = msg[j].buf[0]; |
| 416 | len = msg[j].len - 1; |
| 417 | i = 1; |
| 418 | do { |
| 419 | memcpy(obuf + 3, msg[j].buf + i, |
| 420 | (len > 16 ? 16 : len)); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 421 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 422 | obuf, (len > 16 ? 16 : len) + 3, |
| 423 | DW210X_WRITE_MSG); |
| 424 | i += 16; |
| 425 | len -= 16; |
| 426 | } while (len > 0); |
| 427 | } else { |
| 428 | /* write registers */ |
| 429 | u8 obuf[msg[j].len + 2]; |
| 430 | obuf[0] = msg[j].addr << 1; |
| 431 | obuf[1] = msg[j].len; |
| 432 | memcpy(obuf + 2, msg[j].buf, msg[j].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 433 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 434 | obuf, msg[j].len + 2, |
| 435 | DW210X_WRITE_MSG); |
| 436 | } |
| 437 | break; |
| 438 | } |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 439 | } |
| 440 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | mutex_unlock(&d->i2c_mutex); |
| 444 | return num; |
| 445 | } |
| 446 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 447 | static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 448 | int num) |
| 449 | { |
| 450 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 451 | int i; |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 452 | |
| 453 | if (!d) |
| 454 | return -ENODEV; |
| 455 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 456 | return -EAGAIN; |
| 457 | |
| 458 | switch (num) { |
| 459 | case 2: { |
| 460 | /* read */ |
| 461 | /* first write first register number */ |
| 462 | u8 ibuf[msg[1].len + 2], obuf[3]; |
| 463 | obuf[0] = msg[0].addr << 1; |
| 464 | obuf[1] = msg[0].len; |
| 465 | obuf[2] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 466 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 467 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 468 | /* second read registers */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 469 | dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 470 | ibuf, msg[1].len + 2, DW210X_READ_MSG); |
| 471 | memcpy(msg[1].buf, ibuf + 2, msg[1].len); |
| 472 | |
| 473 | break; |
| 474 | } |
| 475 | case 1: |
| 476 | switch (msg[0].addr) { |
| 477 | case 0x60: |
| 478 | case 0x0c: { |
| 479 | /* write to register */ |
| 480 | u8 obuf[msg[0].len + 2]; |
| 481 | obuf[0] = msg[0].addr << 1; |
| 482 | obuf[1] = msg[0].len; |
| 483 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 484 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 485 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 486 | break; |
| 487 | } |
| 488 | case(DW2102_RC_QUERY): { |
| 489 | u8 ibuf[2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 490 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 491 | ibuf, 2, DW210X_READ_MSG); |
| 492 | memcpy(msg[0].buf, ibuf , 2); |
| 493 | break; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | break; |
| 498 | } |
| 499 | |
| 500 | for (i = 0; i < num; i++) { |
| 501 | deb_xfer("%02x:%02x: %s ", i, msg[i].addr, |
| 502 | msg[i].flags == 0 ? ">>>" : "<<<"); |
| 503 | debug_dump(msg[i].buf, msg[i].len, deb_xfer); |
| 504 | } |
| 505 | |
| 506 | mutex_unlock(&d->i2c_mutex); |
| 507 | return num; |
| 508 | } |
| 509 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 510 | static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 511 | int num) |
| 512 | { |
| 513 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Julia Lawall | 21ead03 | 2009-12-22 18:00:07 -0300 | [diff] [blame] | 514 | struct usb_device *udev; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 515 | int len, i, j; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 516 | |
| 517 | if (!d) |
| 518 | return -ENODEV; |
Julia Lawall | 21ead03 | 2009-12-22 18:00:07 -0300 | [diff] [blame] | 519 | udev = d->udev; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 520 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 521 | return -EAGAIN; |
| 522 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 523 | for (j = 0; j < num; j++) { |
| 524 | switch (msg[j].addr) { |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 525 | case (DW2102_RC_QUERY): { |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 526 | u8 ibuf[5]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 527 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 528 | ibuf, 5, DW210X_READ_MSG); |
| 529 | memcpy(msg[j].buf, ibuf + 3, 2); |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 530 | break; |
| 531 | } |
| 532 | case (DW2102_VOLTAGE_CTRL): { |
| 533 | u8 obuf[2]; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 534 | |
| 535 | obuf[0] = 1; |
| 536 | obuf[1] = msg[j].buf[1];/* off-on */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 537 | dw210x_op_rw(d->udev, 0x8a, 0, 0, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 538 | obuf, 2, DW210X_WRITE_MSG); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 539 | obuf[0] = 3; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 540 | obuf[1] = msg[j].buf[0];/* 13v-18v */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 541 | dw210x_op_rw(d->udev, 0x8a, 0, 0, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 542 | obuf, 2, DW210X_WRITE_MSG); |
| 543 | break; |
| 544 | } |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 545 | case (DW2102_LED_CTRL): { |
| 546 | u8 obuf[2]; |
| 547 | |
| 548 | obuf[0] = 5; |
| 549 | obuf[1] = msg[j].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 550 | dw210x_op_rw(d->udev, 0x8a, 0, 0, |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 551 | obuf, 2, DW210X_WRITE_MSG); |
| 552 | break; |
| 553 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 554 | /*case 0x55: cx24116 |
| 555 | case 0x6a: stv0903 |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 556 | case 0x68: ds3000, stv0903, rs2000 |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 557 | case 0x60: ts2020, stv6110, stb6100 |
| 558 | case 0xa0: eeprom */ |
| 559 | default: { |
| 560 | if (msg[j].flags == I2C_M_RD) { |
| 561 | /* read registers */ |
| 562 | u8 ibuf[msg[j].len]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 563 | dw210x_op_rw(d->udev, 0x91, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 564 | ibuf, msg[j].len, |
| 565 | DW210X_READ_MSG); |
| 566 | memcpy(msg[j].buf, ibuf, msg[j].len); |
| 567 | break; |
| 568 | } else if ((msg[j].buf[0] == 0xb0) && |
| 569 | (msg[j].addr == 0x68)) { |
| 570 | /* write firmware */ |
| 571 | u8 obuf[19]; |
| 572 | obuf[0] = (msg[j].len > 16 ? |
| 573 | 18 : msg[j].len + 1); |
| 574 | obuf[1] = msg[j].addr << 1; |
| 575 | obuf[2] = msg[j].buf[0]; |
| 576 | len = msg[j].len - 1; |
| 577 | i = 1; |
| 578 | do { |
| 579 | memcpy(obuf + 3, msg[j].buf + i, |
| 580 | (len > 16 ? 16 : len)); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 581 | dw210x_op_rw(d->udev, 0x80, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 582 | obuf, (len > 16 ? 16 : len) + 3, |
| 583 | DW210X_WRITE_MSG); |
| 584 | i += 16; |
| 585 | len -= 16; |
| 586 | } while (len > 0); |
Igor M. Liplianin | a84adf4 | 2011-02-27 16:18:38 -0300 | [diff] [blame] | 587 | } else if (j < (num - 1)) { |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 588 | /* write register addr before read */ |
| 589 | u8 obuf[msg[j].len + 2]; |
| 590 | obuf[0] = msg[j + 1].len; |
| 591 | obuf[1] = (msg[j].addr << 1); |
| 592 | memcpy(obuf + 2, msg[j].buf, msg[j].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 593 | dw210x_op_rw(d->udev, |
Igor M. Liplianin | a84adf4 | 2011-02-27 16:18:38 -0300 | [diff] [blame] | 594 | udev->descriptor.idProduct == |
| 595 | 0x7500 ? 0x92 : 0x90, 0, 0, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 596 | obuf, msg[j].len + 2, |
| 597 | DW210X_WRITE_MSG); |
| 598 | break; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 599 | } else { |
| 600 | /* write registers */ |
| 601 | u8 obuf[msg[j].len + 2]; |
| 602 | obuf[0] = msg[j].len + 1; |
| 603 | obuf[1] = (msg[j].addr << 1); |
| 604 | memcpy(obuf + 2, msg[j].buf, msg[j].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 605 | dw210x_op_rw(d->udev, 0x80, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 606 | obuf, msg[j].len + 2, |
| 607 | DW210X_WRITE_MSG); |
| 608 | break; |
| 609 | } |
| 610 | break; |
| 611 | } |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 612 | } |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | mutex_unlock(&d->i2c_mutex); |
| 616 | return num; |
| 617 | } |
| 618 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 619 | static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 620 | int num) |
| 621 | { |
| 622 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| 623 | u8 obuf[0x40], ibuf[0x40]; |
| 624 | |
| 625 | if (!d) |
| 626 | return -ENODEV; |
| 627 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 628 | return -EAGAIN; |
| 629 | |
| 630 | switch (num) { |
| 631 | case 1: |
| 632 | switch (msg[0].addr) { |
| 633 | case SU3000_STREAM_CTRL: |
| 634 | obuf[0] = msg[0].buf[0] + 0x36; |
| 635 | obuf[1] = 3; |
| 636 | obuf[2] = 0; |
| 637 | if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0) |
| 638 | err("i2c transfer failed."); |
| 639 | break; |
| 640 | case DW2102_RC_QUERY: |
| 641 | obuf[0] = 0x10; |
| 642 | if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0) |
| 643 | err("i2c transfer failed."); |
| 644 | msg[0].buf[1] = ibuf[0]; |
| 645 | msg[0].buf[0] = ibuf[1]; |
| 646 | break; |
| 647 | default: |
| 648 | /* always i2c write*/ |
| 649 | obuf[0] = 0x08; |
| 650 | obuf[1] = msg[0].addr; |
| 651 | obuf[2] = msg[0].len; |
| 652 | |
| 653 | memcpy(&obuf[3], msg[0].buf, msg[0].len); |
| 654 | |
| 655 | if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3, |
| 656 | ibuf, 1, 0) < 0) |
| 657 | err("i2c transfer failed."); |
| 658 | |
| 659 | } |
| 660 | break; |
| 661 | case 2: |
| 662 | /* always i2c read */ |
| 663 | obuf[0] = 0x09; |
| 664 | obuf[1] = msg[0].len; |
| 665 | obuf[2] = msg[1].len; |
| 666 | obuf[3] = msg[0].addr; |
| 667 | memcpy(&obuf[4], msg[0].buf, msg[0].len); |
| 668 | |
| 669 | if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4, |
| 670 | ibuf, msg[1].len + 1, 0) < 0) |
| 671 | err("i2c transfer failed."); |
| 672 | |
| 673 | memcpy(msg[1].buf, &ibuf[1], msg[1].len); |
| 674 | break; |
| 675 | default: |
| 676 | warn("more than 2 i2c messages at a time is not handled yet."); |
| 677 | break; |
| 678 | } |
| 679 | mutex_unlock(&d->i2c_mutex); |
| 680 | return num; |
| 681 | } |
| 682 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 683 | static u32 dw210x_i2c_func(struct i2c_adapter *adapter) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 684 | { |
| 685 | return I2C_FUNC_I2C; |
| 686 | } |
| 687 | |
| 688 | static struct i2c_algorithm dw2102_i2c_algo = { |
| 689 | .master_xfer = dw2102_i2c_transfer, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 690 | .functionality = dw210x_i2c_func, |
| 691 | }; |
| 692 | |
| 693 | static struct i2c_algorithm dw2102_serit_i2c_algo = { |
| 694 | .master_xfer = dw2102_serit_i2c_transfer, |
| 695 | .functionality = dw210x_i2c_func, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 696 | }; |
| 697 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 698 | static struct i2c_algorithm dw2102_earda_i2c_algo = { |
| 699 | .master_xfer = dw2102_earda_i2c_transfer, |
| 700 | .functionality = dw210x_i2c_func, |
| 701 | }; |
| 702 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 703 | static struct i2c_algorithm dw2104_i2c_algo = { |
| 704 | .master_xfer = dw2104_i2c_transfer, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 705 | .functionality = dw210x_i2c_func, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 706 | }; |
| 707 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 708 | static struct i2c_algorithm dw3101_i2c_algo = { |
| 709 | .master_xfer = dw3101_i2c_transfer, |
| 710 | .functionality = dw210x_i2c_func, |
| 711 | }; |
| 712 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 713 | static struct i2c_algorithm s6x0_i2c_algo = { |
| 714 | .master_xfer = s6x0_i2c_transfer, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 715 | .functionality = dw210x_i2c_func, |
| 716 | }; |
| 717 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 718 | static struct i2c_algorithm su3000_i2c_algo = { |
| 719 | .master_xfer = su3000_i2c_transfer, |
| 720 | .functionality = dw210x_i2c_func, |
| 721 | }; |
| 722 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 723 | static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 724 | { |
| 725 | int i; |
| 726 | u8 ibuf[] = {0, 0}; |
| 727 | u8 eeprom[256], eepromline[16]; |
| 728 | |
| 729 | for (i = 0; i < 256; i++) { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 730 | if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 731 | err("read eeprom failed."); |
| 732 | return -1; |
| 733 | } else { |
| 734 | eepromline[i%16] = ibuf[0]; |
| 735 | eeprom[i] = ibuf[0]; |
| 736 | } |
| 737 | if ((i % 16) == 15) { |
| 738 | deb_xfer("%02x: ", i - 15); |
| 739 | debug_dump(eepromline, 16, deb_xfer); |
| 740 | } |
| 741 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 742 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 743 | memcpy(mac, eeprom + 8, 6); |
| 744 | return 0; |
| 745 | }; |
| 746 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 747 | static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 748 | { |
| 749 | int i, ret; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 750 | u8 ibuf[] = { 0 }, obuf[] = { 0 }; |
| 751 | u8 eeprom[256], eepromline[16]; |
| 752 | struct i2c_msg msg[] = { |
| 753 | { |
| 754 | .addr = 0xa0 >> 1, |
| 755 | .flags = 0, |
| 756 | .buf = obuf, |
| 757 | .len = 1, |
| 758 | }, { |
| 759 | .addr = 0xa0 >> 1, |
| 760 | .flags = I2C_M_RD, |
| 761 | .buf = ibuf, |
| 762 | .len = 1, |
| 763 | } |
| 764 | }; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 765 | |
| 766 | for (i = 0; i < 256; i++) { |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 767 | obuf[0] = i; |
| 768 | ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2); |
| 769 | if (ret != 2) { |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 770 | err("read eeprom failed."); |
| 771 | return -1; |
| 772 | } else { |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 773 | eepromline[i % 16] = ibuf[0]; |
| 774 | eeprom[i] = ibuf[0]; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | if ((i % 16) == 15) { |
| 778 | deb_xfer("%02x: ", i - 15); |
| 779 | debug_dump(eepromline, 16, deb_xfer); |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | memcpy(mac, eeprom + 16, 6); |
| 784 | return 0; |
| 785 | }; |
| 786 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 787 | static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) |
| 788 | { |
| 789 | static u8 command_start[] = {0x00}; |
| 790 | static u8 command_stop[] = {0x01}; |
| 791 | struct i2c_msg msg = { |
| 792 | .addr = SU3000_STREAM_CTRL, |
| 793 | .flags = 0, |
| 794 | .buf = onoff ? command_start : command_stop, |
| 795 | .len = 1 |
| 796 | }; |
| 797 | |
| 798 | i2c_transfer(&adap->dev->i2c_adap, &msg, 1); |
| 799 | |
| 800 | return 0; |
| 801 | } |
| 802 | |
| 803 | static int su3000_power_ctrl(struct dvb_usb_device *d, int i) |
| 804 | { |
| 805 | struct su3000_state *state = (struct su3000_state *)d->priv; |
| 806 | u8 obuf[] = {0xde, 0}; |
| 807 | |
| 808 | info("%s: %d, initialized %d\n", __func__, i, state->initialized); |
| 809 | |
| 810 | if (i && !state->initialized) { |
| 811 | state->initialized = 1; |
| 812 | /* reset board */ |
| 813 | dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0); |
| 814 | } |
| 815 | |
| 816 | return 0; |
| 817 | } |
| 818 | |
| 819 | static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) |
| 820 | { |
| 821 | int i; |
| 822 | u8 obuf[] = { 0x1f, 0xf0 }; |
| 823 | u8 ibuf[] = { 0 }; |
| 824 | struct i2c_msg msg[] = { |
| 825 | { |
| 826 | .addr = 0x51, |
| 827 | .flags = 0, |
| 828 | .buf = obuf, |
| 829 | .len = 2, |
| 830 | }, { |
| 831 | .addr = 0x51, |
| 832 | .flags = I2C_M_RD, |
| 833 | .buf = ibuf, |
| 834 | .len = 1, |
| 835 | |
| 836 | } |
| 837 | }; |
| 838 | |
| 839 | for (i = 0; i < 6; i++) { |
| 840 | obuf[1] = 0xf0 + i; |
| 841 | if (i2c_transfer(&d->i2c_adap, msg, 2) != 2) |
| 842 | break; |
| 843 | else |
| 844 | mac[i] = ibuf[0]; |
| 845 | |
| 846 | debug_dump(mac, 6, printk); |
| 847 | } |
| 848 | |
| 849 | return 0; |
| 850 | } |
| 851 | |
| 852 | static int su3000_identify_state(struct usb_device *udev, |
| 853 | struct dvb_usb_device_properties *props, |
| 854 | struct dvb_usb_device_description **desc, |
| 855 | int *cold) |
| 856 | { |
| 857 | info("%s\n", __func__); |
| 858 | |
| 859 | *cold = 0; |
| 860 | return 0; |
| 861 | } |
| 862 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 863 | static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 864 | { |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 865 | static u8 command_13v[] = {0x00, 0x01}; |
| 866 | static u8 command_18v[] = {0x01, 0x01}; |
| 867 | static u8 command_off[] = {0x00, 0x00}; |
| 868 | struct i2c_msg msg = { |
| 869 | .addr = DW2102_VOLTAGE_CTRL, |
| 870 | .flags = 0, |
| 871 | .buf = command_off, |
| 872 | .len = 2, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 873 | }; |
| 874 | |
| 875 | struct dvb_usb_adapter *udev_adap = |
| 876 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 877 | if (voltage == SEC_VOLTAGE_18) |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 878 | msg.buf = command_18v; |
| 879 | else if (voltage == SEC_VOLTAGE_13) |
| 880 | msg.buf = command_13v; |
| 881 | |
| 882 | i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); |
| 883 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 884 | return 0; |
| 885 | } |
| 886 | |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 887 | static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
| 888 | { |
| 889 | struct dvb_usb_adapter *d = |
| 890 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 891 | struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; |
| 892 | |
| 893 | dw210x_set_voltage(fe, voltage); |
| 894 | if (st->old_set_voltage) |
| 895 | st->old_set_voltage(fe, voltage); |
| 896 | |
| 897 | return 0; |
| 898 | } |
| 899 | |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 900 | static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon) |
| 901 | { |
| 902 | static u8 led_off[] = { 0 }; |
| 903 | static u8 led_on[] = { 1 }; |
| 904 | struct i2c_msg msg = { |
| 905 | .addr = DW2102_LED_CTRL, |
| 906 | .flags = 0, |
| 907 | .buf = led_off, |
| 908 | .len = 1 |
| 909 | }; |
| 910 | struct dvb_usb_adapter *udev_adap = |
| 911 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 912 | |
| 913 | if (offon) |
| 914 | msg.buf = led_on; |
| 915 | i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); |
| 916 | } |
| 917 | |
Igor M. Liplianin | d4305c6 | 2008-10-17 13:45:55 -0300 | [diff] [blame] | 918 | static struct stv0299_config sharp_z0194a_config = { |
| 919 | .demod_address = 0x68, |
| 920 | .inittab = sharp_z0194a_inittab, |
| 921 | .mclk = 88000000UL, |
| 922 | .invert = 1, |
| 923 | .skip_reinit = 0, |
| 924 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 925 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
| 926 | .min_delay_ms = 100, |
| 927 | .set_symbol_rate = sharp_z0194a_set_symbol_rate, |
| 928 | }; |
| 929 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 930 | static struct cx24116_config dw2104_config = { |
| 931 | .demod_address = 0x55, |
Igor M. Liplianin | cc8c4f3 | 2008-09-09 13:57:47 -0300 | [diff] [blame] | 932 | .mpg_clk_pos_pol = 0x01, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 933 | }; |
| 934 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 935 | static struct si21xx_config serit_sp1511lhb_config = { |
| 936 | .demod_address = 0x68, |
| 937 | .min_delay_ms = 100, |
| 938 | |
| 939 | }; |
| 940 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 941 | static struct tda10023_config dw3101_tda10023_config = { |
| 942 | .demod_address = 0x0c, |
| 943 | .invert = 1, |
| 944 | }; |
| 945 | |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 946 | static struct mt312_config zl313_config = { |
| 947 | .demod_address = 0x0e, |
| 948 | }; |
| 949 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 950 | static struct ds3000_config dw2104_ds3000_config = { |
| 951 | .demod_address = 0x68, |
| 952 | }; |
| 953 | |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 954 | static struct ts2020_config dw2104_ts2020_config = { |
| 955 | .tuner_address = 0x60, |
| 956 | }; |
| 957 | |
Igor M. Liplianin | 43385c8 | 2012-12-28 19:40:24 -0300 | [diff] [blame^] | 958 | static struct ds3000_config s660_ds3000_config = { |
| 959 | .demod_address = 0x68, |
| 960 | .set_lock_led = dw210x_led_ctrl, |
| 961 | }; |
| 962 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 963 | static struct stv0900_config dw2104a_stv0900_config = { |
| 964 | .demod_address = 0x6a, |
| 965 | .demod_mode = 0, |
| 966 | .xtal = 27000000, |
| 967 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ |
| 968 | .diseqc_mode = 2,/* 2/3 PWM */ |
| 969 | .tun1_maddress = 0,/* 0x60 */ |
| 970 | .tun1_adc = 0,/* 2 Vpp */ |
| 971 | .path1_mode = 3, |
| 972 | }; |
| 973 | |
| 974 | static struct stb6100_config dw2104a_stb6100_config = { |
| 975 | .tuner_address = 0x60, |
| 976 | .refclock = 27000000, |
| 977 | }; |
| 978 | |
| 979 | static struct stv0900_config dw2104_stv0900_config = { |
| 980 | .demod_address = 0x68, |
| 981 | .demod_mode = 0, |
| 982 | .xtal = 8000000, |
| 983 | .clkmode = 3, |
| 984 | .diseqc_mode = 2, |
| 985 | .tun1_maddress = 0, |
| 986 | .tun1_adc = 1,/* 1 Vpp */ |
| 987 | .path1_mode = 3, |
| 988 | }; |
| 989 | |
| 990 | static struct stv6110_config dw2104_stv6110_config = { |
| 991 | .i2c_address = 0x60, |
| 992 | .mclk = 16000000, |
| 993 | .clk_div = 1, |
| 994 | }; |
| 995 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 996 | static struct stv0900_config prof_7500_stv0900_config = { |
| 997 | .demod_address = 0x6a, |
| 998 | .demod_mode = 0, |
| 999 | .xtal = 27000000, |
| 1000 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ |
| 1001 | .diseqc_mode = 2,/* 2/3 PWM */ |
| 1002 | .tun1_maddress = 0,/* 0x60 */ |
| 1003 | .tun1_adc = 0,/* 2 Vpp */ |
| 1004 | .path1_mode = 3, |
| 1005 | .tun1_type = 3, |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1006 | .set_lock_led = dw210x_led_ctrl, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1007 | }; |
| 1008 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1009 | static struct ds3000_config su3000_ds3000_config = { |
| 1010 | .demod_address = 0x68, |
| 1011 | .ci_mode = 1, |
| 1012 | }; |
| 1013 | |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1014 | static struct ts2020_config su3000_ts2020_config = { |
| 1015 | .tuner_address = 0x60, |
| 1016 | }; |
| 1017 | |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1018 | static u8 m88rs2000_inittab[] = { |
| 1019 | DEMOD_WRITE, 0x9a, 0x30, |
| 1020 | DEMOD_WRITE, 0x00, 0x01, |
| 1021 | WRITE_DELAY, 0x19, 0x00, |
| 1022 | DEMOD_WRITE, 0x00, 0x00, |
| 1023 | DEMOD_WRITE, 0x9a, 0xb0, |
| 1024 | DEMOD_WRITE, 0x81, 0xc1, |
| 1025 | TUNER_WRITE, 0x42, 0x73, |
| 1026 | TUNER_WRITE, 0x05, 0x07, |
| 1027 | TUNER_WRITE, 0x20, 0x27, |
| 1028 | TUNER_WRITE, 0x07, 0x02, |
| 1029 | TUNER_WRITE, 0x11, 0xff, |
| 1030 | TUNER_WRITE, 0x60, 0xf9, |
| 1031 | TUNER_WRITE, 0x08, 0x01, |
| 1032 | TUNER_WRITE, 0x00, 0x41, |
| 1033 | DEMOD_WRITE, 0x81, 0x81, |
| 1034 | DEMOD_WRITE, 0x86, 0xc6, |
| 1035 | DEMOD_WRITE, 0x9a, 0x30, |
| 1036 | DEMOD_WRITE, 0xf0, 0x80, |
| 1037 | DEMOD_WRITE, 0xf1, 0xbf, |
| 1038 | DEMOD_WRITE, 0xb0, 0x45, |
| 1039 | DEMOD_WRITE, 0xb2, 0x01, |
| 1040 | DEMOD_WRITE, 0x9a, 0xb0, |
| 1041 | 0xff, 0xaa, 0xff |
| 1042 | }; |
| 1043 | |
| 1044 | static struct m88rs2000_config s421_m88rs2000_config = { |
| 1045 | .demod_addr = 0x68, |
| 1046 | .tuner_addr = 0x60, |
| 1047 | .inittab = m88rs2000_inittab, |
| 1048 | }; |
| 1049 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1050 | static int dw2104_frontend_attach(struct dvb_usb_adapter *d) |
| 1051 | { |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1052 | struct dvb_tuner_ops *tuner_ops = NULL; |
| 1053 | |
| 1054 | if (demod_probe & 4) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1055 | d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1056 | &d->dev->i2c_adap, 0); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1057 | if (d->fe_adap[0].fe != NULL) { |
| 1058 | if (dvb_attach(stb6100_attach, d->fe_adap[0].fe, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1059 | &dw2104a_stb6100_config, |
| 1060 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1061 | tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1062 | tuner_ops->set_frequency = stb6100_set_freq; |
| 1063 | tuner_ops->get_frequency = stb6100_get_freq; |
| 1064 | tuner_ops->set_bandwidth = stb6100_set_bandw; |
| 1065 | tuner_ops->get_bandwidth = stb6100_get_bandw; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1066 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1067 | info("Attached STV0900+STB6100!\n"); |
| 1068 | return 0; |
| 1069 | } |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | if (demod_probe & 2) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1074 | d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1075 | &d->dev->i2c_adap, 0); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1076 | if (d->fe_adap[0].fe != NULL) { |
| 1077 | if (dvb_attach(stv6110_attach, d->fe_adap[0].fe, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1078 | &dw2104_stv6110_config, |
| 1079 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1080 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1081 | info("Attached STV0900+STV6110A!\n"); |
| 1082 | return 0; |
| 1083 | } |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | if (demod_probe & 1) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1088 | d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1089 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1090 | if (d->fe_adap[0].fe != NULL) { |
| 1091 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1092 | info("Attached cx24116!\n"); |
| 1093 | return 0; |
| 1094 | } |
| 1095 | } |
| 1096 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1097 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1098 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1099 | if (d->fe_adap[0].fe != NULL) { |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1100 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, |
| 1101 | &dw2104_ts2020_config, &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1102 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1103 | info("Attached DS3000!\n"); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1104 | return 0; |
| 1105 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1106 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1107 | return -EIO; |
| 1108 | } |
| 1109 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1110 | static struct dvb_usb_device_properties dw2102_properties; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1111 | static struct dvb_usb_device_properties dw2104_properties; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1112 | static struct dvb_usb_device_properties s6x0_properties; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1113 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1114 | static int dw2102_frontend_attach(struct dvb_usb_adapter *d) |
| 1115 | { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1116 | if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) { |
| 1117 | /*dw2102_properties.adapter->tuner_attach = NULL;*/ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1118 | d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1119 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1120 | if (d->fe_adap[0].fe != NULL) { |
| 1121 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1122 | info("Attached si21xx!\n"); |
| 1123 | return 0; |
| 1124 | } |
| 1125 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1126 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1127 | if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1128 | d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1129 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1130 | if (d->fe_adap[0].fe != NULL) { |
| 1131 | if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1132 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1133 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1134 | info("Attached stv0288!\n"); |
| 1135 | return 0; |
| 1136 | } |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1137 | } |
| 1138 | } |
| 1139 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1140 | if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) { |
| 1141 | /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1142 | d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1143 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1144 | if (d->fe_adap[0].fe != NULL) { |
| 1145 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1146 | info("Attached stv0299!\n"); |
| 1147 | return 0; |
| 1148 | } |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1149 | } |
| 1150 | return -EIO; |
| 1151 | } |
| 1152 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1153 | static int dw3101_frontend_attach(struct dvb_usb_adapter *d) |
| 1154 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1155 | d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1156 | &d->dev->i2c_adap, 0x48); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1157 | if (d->fe_adap[0].fe != NULL) { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1158 | info("Attached tda10023!\n"); |
| 1159 | return 0; |
| 1160 | } |
| 1161 | return -EIO; |
| 1162 | } |
| 1163 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1164 | static int zl100313_frontend_attach(struct dvb_usb_adapter *d) |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1165 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1166 | d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1167 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1168 | if (d->fe_adap[0].fe != NULL) { |
| 1169 | if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1170 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1171 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1172 | info("Attached zl100313+zl10039!\n"); |
| 1173 | return 0; |
| 1174 | } |
| 1175 | } |
| 1176 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1177 | return -EIO; |
| 1178 | } |
| 1179 | |
| 1180 | static int stv0288_frontend_attach(struct dvb_usb_adapter *d) |
| 1181 | { |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1182 | u8 obuf[] = {7, 1}; |
| 1183 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1184 | d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1185 | &d->dev->i2c_adap); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1186 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1187 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1188 | return -EIO; |
| 1189 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1190 | if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap)) |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1191 | return -EIO; |
| 1192 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1193 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1194 | |
| 1195 | dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); |
| 1196 | |
| 1197 | info("Attached stv0288+stb6000!\n"); |
| 1198 | |
| 1199 | return 0; |
| 1200 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | static int ds3000_frontend_attach(struct dvb_usb_adapter *d) |
| 1204 | { |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1205 | struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1206 | u8 obuf[] = {7, 1}; |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1207 | |
Igor M. Liplianin | 43385c8 | 2012-12-28 19:40:24 -0300 | [diff] [blame^] | 1208 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &s660_ds3000_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1209 | &d->dev->i2c_adap); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1210 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1211 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1212 | return -EIO; |
| 1213 | |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1214 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, &dw2104_ts2020_config, |
| 1215 | &d->dev->i2c_adap); |
| 1216 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1217 | st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; |
| 1218 | d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage; |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1219 | |
| 1220 | dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); |
| 1221 | |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1222 | info("Attached ds3000+ds2020!\n"); |
| 1223 | |
| 1224 | return 0; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1225 | } |
| 1226 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1227 | static int prof_7500_frontend_attach(struct dvb_usb_adapter *d) |
| 1228 | { |
Igor M. Liplianin | 4e59df8 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1229 | u8 obuf[] = {7, 1}; |
| 1230 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1231 | d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1232 | &d->dev->i2c_adap, 0); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1233 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1234 | return -EIO; |
Igor M. Liplianin | 4e59df8 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1235 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1236 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1237 | |
Igor M. Liplianin | 4e59df8 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1238 | dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); |
| 1239 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1240 | info("Attached STV0900+STB6100A!\n"); |
| 1241 | |
| 1242 | return 0; |
| 1243 | } |
| 1244 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1245 | static int su3000_frontend_attach(struct dvb_usb_adapter *d) |
| 1246 | { |
| 1247 | u8 obuf[3] = { 0xe, 0x80, 0 }; |
| 1248 | u8 ibuf[] = { 0 }; |
| 1249 | |
| 1250 | if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) |
| 1251 | err("command 0x0e transfer failed."); |
| 1252 | |
| 1253 | obuf[0] = 0xe; |
| 1254 | obuf[1] = 0x83; |
| 1255 | obuf[2] = 0; |
| 1256 | |
| 1257 | if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) |
| 1258 | err("command 0x0e transfer failed."); |
| 1259 | |
| 1260 | obuf[0] = 0xe; |
| 1261 | obuf[1] = 0x83; |
| 1262 | obuf[2] = 1; |
| 1263 | |
| 1264 | if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) |
| 1265 | err("command 0x0e transfer failed."); |
| 1266 | |
| 1267 | obuf[0] = 0x51; |
| 1268 | |
| 1269 | if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) |
| 1270 | err("command 0x51 transfer failed."); |
| 1271 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1272 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1273 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1274 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1275 | return -EIO; |
| 1276 | |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1277 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, &su3000_ts2020_config, |
| 1278 | &d->dev->i2c_adap); |
| 1279 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1280 | info("Attached DS3000!\n"); |
| 1281 | |
| 1282 | return 0; |
| 1283 | } |
| 1284 | |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1285 | static int m88rs2000_frontend_attach(struct dvb_usb_adapter *d) |
| 1286 | { |
| 1287 | u8 obuf[] = { 0x51 }; |
| 1288 | u8 ibuf[] = { 0 }; |
| 1289 | |
| 1290 | if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) |
| 1291 | err("command 0x51 transfer failed."); |
| 1292 | |
| 1293 | d->fe_adap[0].fe = dvb_attach(m88rs2000_attach, &s421_m88rs2000_config, |
| 1294 | &d->dev->i2c_adap); |
| 1295 | if (d->fe_adap[0].fe == NULL) |
| 1296 | return -EIO; |
| 1297 | |
| 1298 | info("Attached m88rs2000!\n"); |
| 1299 | |
| 1300 | return 0; |
| 1301 | } |
| 1302 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1303 | static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) |
| 1304 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1305 | dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1306 | &adap->dev->i2c_adap, DVB_PLL_OPERA1); |
| 1307 | return 0; |
| 1308 | } |
| 1309 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1310 | static int dw3101_tuner_attach(struct dvb_usb_adapter *adap) |
| 1311 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1312 | dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1313 | &adap->dev->i2c_adap, DVB_PLL_TUA6034); |
| 1314 | |
| 1315 | return 0; |
| 1316 | } |
| 1317 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1318 | static struct rc_map_table rc_map_dw210x_table[] = { |
Mauro Carvalho Chehab | 991bd3c | 2011-01-24 12:18:40 -0300 | [diff] [blame] | 1319 | { 0xf80a, KEY_POWER2 }, /*power*/ |
| 1320 | { 0xf80c, KEY_MUTE }, /*mute*/ |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1321 | { 0xf811, KEY_1 }, |
| 1322 | { 0xf812, KEY_2 }, |
| 1323 | { 0xf813, KEY_3 }, |
| 1324 | { 0xf814, KEY_4 }, |
| 1325 | { 0xf815, KEY_5 }, |
| 1326 | { 0xf816, KEY_6 }, |
| 1327 | { 0xf817, KEY_7 }, |
| 1328 | { 0xf818, KEY_8 }, |
| 1329 | { 0xf819, KEY_9 }, |
| 1330 | { 0xf810, KEY_0 }, |
Mauro Carvalho Chehab | 991bd3c | 2011-01-24 12:18:40 -0300 | [diff] [blame] | 1331 | { 0xf81c, KEY_CHANNELUP }, /*ch+*/ |
| 1332 | { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/ |
| 1333 | { 0xf81a, KEY_VOLUMEUP }, /*vol+*/ |
| 1334 | { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/ |
| 1335 | { 0xf804, KEY_RECORD }, /*rec*/ |
| 1336 | { 0xf809, KEY_FAVORITES }, /*fav*/ |
| 1337 | { 0xf808, KEY_REWIND }, /*rewind*/ |
| 1338 | { 0xf807, KEY_FASTFORWARD }, /*fast*/ |
| 1339 | { 0xf80b, KEY_PAUSE }, /*pause*/ |
| 1340 | { 0xf802, KEY_ESC }, /*cancel*/ |
| 1341 | { 0xf803, KEY_TAB }, /*tab*/ |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1342 | { 0xf800, KEY_UP }, /*up*/ |
Mauro Carvalho Chehab | 991bd3c | 2011-01-24 12:18:40 -0300 | [diff] [blame] | 1343 | { 0xf81f, KEY_OK }, /*ok*/ |
| 1344 | { 0xf801, KEY_DOWN }, /*down*/ |
| 1345 | { 0xf805, KEY_CAMERA }, /*cap*/ |
| 1346 | { 0xf806, KEY_STOP }, /*stop*/ |
| 1347 | { 0xf840, KEY_ZOOM }, /*full*/ |
| 1348 | { 0xf81e, KEY_TV }, /*tvmode*/ |
| 1349 | { 0xf81b, KEY_LAST }, /*recall*/ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1350 | }; |
| 1351 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1352 | static struct rc_map_table rc_map_tevii_table[] = { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1353 | { 0xf80a, KEY_POWER }, |
| 1354 | { 0xf80c, KEY_MUTE }, |
| 1355 | { 0xf811, KEY_1 }, |
| 1356 | { 0xf812, KEY_2 }, |
| 1357 | { 0xf813, KEY_3 }, |
| 1358 | { 0xf814, KEY_4 }, |
| 1359 | { 0xf815, KEY_5 }, |
| 1360 | { 0xf816, KEY_6 }, |
| 1361 | { 0xf817, KEY_7 }, |
| 1362 | { 0xf818, KEY_8 }, |
| 1363 | { 0xf819, KEY_9 }, |
| 1364 | { 0xf810, KEY_0 }, |
| 1365 | { 0xf81c, KEY_MENU }, |
| 1366 | { 0xf80f, KEY_VOLUMEDOWN }, |
| 1367 | { 0xf81a, KEY_LAST }, |
| 1368 | { 0xf80e, KEY_OPEN }, |
| 1369 | { 0xf804, KEY_RECORD }, |
| 1370 | { 0xf809, KEY_VOLUMEUP }, |
| 1371 | { 0xf808, KEY_CHANNELUP }, |
| 1372 | { 0xf807, KEY_PVR }, |
| 1373 | { 0xf80b, KEY_TIME }, |
| 1374 | { 0xf802, KEY_RIGHT }, |
| 1375 | { 0xf803, KEY_LEFT }, |
| 1376 | { 0xf800, KEY_UP }, |
| 1377 | { 0xf81f, KEY_OK }, |
| 1378 | { 0xf801, KEY_DOWN }, |
| 1379 | { 0xf805, KEY_TUNER }, |
| 1380 | { 0xf806, KEY_CHANNELDOWN }, |
| 1381 | { 0xf840, KEY_PLAYPAUSE }, |
| 1382 | { 0xf81e, KEY_REWIND }, |
| 1383 | { 0xf81b, KEY_FAVORITES }, |
| 1384 | { 0xf81d, KEY_BACK }, |
| 1385 | { 0xf84d, KEY_FASTFORWARD }, |
| 1386 | { 0xf844, KEY_EPG }, |
| 1387 | { 0xf84c, KEY_INFO }, |
| 1388 | { 0xf841, KEY_AB }, |
| 1389 | { 0xf843, KEY_AUDIO }, |
| 1390 | { 0xf845, KEY_SUBTITLE }, |
| 1391 | { 0xf84a, KEY_LIST }, |
| 1392 | { 0xf846, KEY_F1 }, |
| 1393 | { 0xf847, KEY_F2 }, |
| 1394 | { 0xf85e, KEY_F3 }, |
| 1395 | { 0xf85c, KEY_F4 }, |
| 1396 | { 0xf852, KEY_F5 }, |
| 1397 | { 0xf85a, KEY_F6 }, |
| 1398 | { 0xf856, KEY_MODE }, |
| 1399 | { 0xf858, KEY_SWITCHVIDEOMODE }, |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1400 | }; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1401 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1402 | static struct rc_map_table rc_map_tbs_table[] = { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1403 | { 0xf884, KEY_POWER }, |
| 1404 | { 0xf894, KEY_MUTE }, |
| 1405 | { 0xf887, KEY_1 }, |
| 1406 | { 0xf886, KEY_2 }, |
| 1407 | { 0xf885, KEY_3 }, |
| 1408 | { 0xf88b, KEY_4 }, |
| 1409 | { 0xf88a, KEY_5 }, |
| 1410 | { 0xf889, KEY_6 }, |
| 1411 | { 0xf88f, KEY_7 }, |
| 1412 | { 0xf88e, KEY_8 }, |
| 1413 | { 0xf88d, KEY_9 }, |
| 1414 | { 0xf892, KEY_0 }, |
| 1415 | { 0xf896, KEY_CHANNELUP }, |
| 1416 | { 0xf891, KEY_CHANNELDOWN }, |
| 1417 | { 0xf893, KEY_VOLUMEUP }, |
| 1418 | { 0xf88c, KEY_VOLUMEDOWN }, |
| 1419 | { 0xf883, KEY_RECORD }, |
| 1420 | { 0xf898, KEY_PAUSE }, |
| 1421 | { 0xf899, KEY_OK }, |
| 1422 | { 0xf89a, KEY_SHUFFLE }, |
| 1423 | { 0xf881, KEY_UP }, |
| 1424 | { 0xf890, KEY_LEFT }, |
| 1425 | { 0xf882, KEY_RIGHT }, |
| 1426 | { 0xf888, KEY_DOWN }, |
| 1427 | { 0xf895, KEY_FAVORITES }, |
| 1428 | { 0xf897, KEY_SUBTITLE }, |
| 1429 | { 0xf89d, KEY_ZOOM }, |
| 1430 | { 0xf89f, KEY_EXIT }, |
| 1431 | { 0xf89e, KEY_MENU }, |
| 1432 | { 0xf89c, KEY_EPG }, |
| 1433 | { 0xf880, KEY_PREVIOUS }, |
| 1434 | { 0xf89b, KEY_MODE } |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1435 | }; |
| 1436 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1437 | static struct rc_map_table rc_map_su3000_table[] = { |
| 1438 | { 0x25, KEY_POWER }, /* right-bottom Red */ |
| 1439 | { 0x0a, KEY_MUTE }, /* -/-- */ |
| 1440 | { 0x01, KEY_1 }, |
| 1441 | { 0x02, KEY_2 }, |
| 1442 | { 0x03, KEY_3 }, |
| 1443 | { 0x04, KEY_4 }, |
| 1444 | { 0x05, KEY_5 }, |
| 1445 | { 0x06, KEY_6 }, |
| 1446 | { 0x07, KEY_7 }, |
| 1447 | { 0x08, KEY_8 }, |
| 1448 | { 0x09, KEY_9 }, |
| 1449 | { 0x00, KEY_0 }, |
| 1450 | { 0x20, KEY_UP }, /* CH+ */ |
| 1451 | { 0x21, KEY_DOWN }, /* CH+ */ |
| 1452 | { 0x12, KEY_VOLUMEUP }, /* Brightness Up */ |
| 1453 | { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */ |
| 1454 | { 0x1f, KEY_RECORD }, |
| 1455 | { 0x17, KEY_PLAY }, |
| 1456 | { 0x16, KEY_PAUSE }, |
| 1457 | { 0x0b, KEY_STOP }, |
| 1458 | { 0x27, KEY_FASTFORWARD },/* >> */ |
| 1459 | { 0x26, KEY_REWIND }, /* << */ |
| 1460 | { 0x0d, KEY_OK }, /* Mute */ |
| 1461 | { 0x11, KEY_LEFT }, /* VOL- */ |
| 1462 | { 0x10, KEY_RIGHT }, /* VOL+ */ |
| 1463 | { 0x29, KEY_BACK }, /* button under 9 */ |
| 1464 | { 0x2c, KEY_MENU }, /* TTX */ |
| 1465 | { 0x2b, KEY_EPG }, /* EPG */ |
| 1466 | { 0x1e, KEY_RED }, /* OSD */ |
| 1467 | { 0x0e, KEY_GREEN }, /* Window */ |
| 1468 | { 0x2d, KEY_YELLOW }, /* button under << */ |
| 1469 | { 0x0f, KEY_BLUE }, /* bottom yellow button */ |
| 1470 | { 0x14, KEY_AUDIO }, /* Snapshot */ |
| 1471 | { 0x38, KEY_TV }, /* TV/Radio */ |
Justin P. Mattock | 70f23fd | 2011-05-10 10:16:21 +0200 | [diff] [blame] | 1472 | { 0x0c, KEY_ESC } /* upper Red button */ |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1473 | }; |
| 1474 | |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1475 | static struct rc_map_dvb_usb_table_table keys_tables[] = { |
| 1476 | { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) }, |
| 1477 | { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) }, |
| 1478 | { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) }, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1479 | { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) }, |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1480 | }; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1481 | |
| 1482 | static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
| 1483 | { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1484 | struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; |
| 1485 | int keymap_size = d->props.rc.legacy.rc_map_size; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1486 | u8 key[2]; |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1487 | struct i2c_msg msg = { |
| 1488 | .addr = DW2102_RC_QUERY, |
| 1489 | .flags = I2C_M_RD, |
| 1490 | .buf = key, |
| 1491 | .len = 2 |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1492 | }; |
| 1493 | int i; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1494 | /* override keymap */ |
| 1495 | if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) { |
| 1496 | keymap = keys_tables[ir_keymap - 1].rc_keys ; |
| 1497 | keymap_size = keys_tables[ir_keymap - 1].rc_keys_size; |
Igor M. Liplianin | feb16e9 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1498 | } else if (ir_keymap > ARRAY_SIZE(keys_tables)) |
| 1499 | return 0; /* none */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1500 | |
| 1501 | *state = REMOTE_NO_KEY_PRESSED; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1502 | if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1503 | for (i = 0; i < keymap_size ; i++) { |
Mauro Carvalho Chehab | 2e36588 | 2009-08-29 15:19:31 -0300 | [diff] [blame] | 1504 | if (rc5_data(&keymap[i]) == msg.buf[0]) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1505 | *state = REMOTE_KEY_PRESSED; |
Mauro Carvalho Chehab | 34abf21 | 2010-07-31 11:24:57 -0300 | [diff] [blame] | 1506 | *event = keymap[i].keycode; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1507 | break; |
| 1508 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1509 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1510 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1511 | |
| 1512 | if ((*state) == REMOTE_KEY_PRESSED) |
| 1513 | deb_rc("%s: found rc key: %x, %x, event: %x\n", |
| 1514 | __func__, key[0], key[1], (*event)); |
| 1515 | else if (key[0] != 0xff) |
| 1516 | deb_rc("%s: unknown rc key: %x, %x\n", |
| 1517 | __func__, key[0], key[1]); |
| 1518 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1519 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1520 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1521 | return 0; |
| 1522 | } |
| 1523 | |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1524 | enum dw2102_table_entry { |
| 1525 | CYPRESS_DW2102, |
| 1526 | CYPRESS_DW2101, |
| 1527 | CYPRESS_DW2104, |
| 1528 | TEVII_S650, |
| 1529 | TERRATEC_CINERGY_S, |
| 1530 | CYPRESS_DW3101, |
| 1531 | TEVII_S630, |
| 1532 | PROF_1100, |
| 1533 | TEVII_S660, |
| 1534 | PROF_7500, |
| 1535 | GENIATECH_SU3000, |
| 1536 | TERRATEC_CINERGY_S2, |
| 1537 | TEVII_S480_1, |
| 1538 | TEVII_S480_2, |
| 1539 | X3M_SPC1400HD, |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1540 | TEVII_S421, |
| 1541 | TEVII_S632, |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1542 | }; |
| 1543 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1544 | static struct usb_device_id dw2102_table[] = { |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1545 | [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)}, |
| 1546 | [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)}, |
| 1547 | [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)}, |
| 1548 | [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)}, |
| 1549 | [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)}, |
| 1550 | [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)}, |
| 1551 | [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)}, |
| 1552 | [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)}, |
| 1553 | [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)}, |
| 1554 | [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)}, |
| 1555 | [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)}, |
| 1556 | [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)}, |
| 1557 | [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)}, |
| 1558 | [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)}, |
| 1559 | [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)}, |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1560 | [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)}, |
| 1561 | [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1562 | { } |
| 1563 | }; |
| 1564 | |
| 1565 | MODULE_DEVICE_TABLE(usb, dw2102_table); |
| 1566 | |
| 1567 | static int dw2102_load_firmware(struct usb_device *dev, |
| 1568 | const struct firmware *frmwr) |
| 1569 | { |
| 1570 | u8 *b, *p; |
| 1571 | int ret = 0, i; |
| 1572 | u8 reset; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1573 | u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1574 | const struct firmware *fw; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1575 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1576 | switch (dev->descriptor.idProduct) { |
| 1577 | case 0x2101: |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1578 | ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1579 | if (ret != 0) { |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1580 | err(err_str, DW2101_FIRMWARE); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1581 | return ret; |
| 1582 | } |
| 1583 | break; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1584 | default: |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1585 | fw = frmwr; |
| 1586 | break; |
| 1587 | } |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1588 | info("start downloading DW210X firmware"); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1589 | p = kmalloc(fw->size, GFP_KERNEL); |
| 1590 | reset = 1; |
| 1591 | /*stop the CPU*/ |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1592 | dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG); |
| 1593 | dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1594 | |
| 1595 | if (p != NULL) { |
| 1596 | memcpy(p, fw->data, fw->size); |
| 1597 | for (i = 0; i < fw->size; i += 0x40) { |
| 1598 | b = (u8 *) p + i; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1599 | if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40, |
| 1600 | DW210X_WRITE_MSG) != 0x40) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1601 | err("error while transferring firmware"); |
| 1602 | ret = -EINVAL; |
| 1603 | break; |
| 1604 | } |
| 1605 | } |
| 1606 | /* restart the CPU */ |
| 1607 | reset = 0; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1608 | if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, |
| 1609 | DW210X_WRITE_MSG) != 1) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1610 | err("could not restart the USB controller CPU."); |
| 1611 | ret = -EINVAL; |
| 1612 | } |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1613 | if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, |
| 1614 | DW210X_WRITE_MSG) != 1) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1615 | err("could not restart the USB controller CPU."); |
| 1616 | ret = -EINVAL; |
| 1617 | } |
| 1618 | /* init registers */ |
| 1619 | switch (dev->descriptor.idProduct) { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1620 | case USB_PID_TEVII_S650: |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1621 | dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table; |
| 1622 | dw2104_properties.rc.legacy.rc_map_size = |
| 1623 | ARRAY_SIZE(rc_map_tevii_table); |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1624 | case USB_PID_DW2104: |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1625 | reset = 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1626 | dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, |
| 1627 | DW210X_WRITE_MSG); |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1628 | /* break omitted intentionally */ |
| 1629 | case USB_PID_DW3101: |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1630 | reset = 0; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1631 | dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, |
| 1632 | DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1633 | break; |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1634 | case USB_PID_CINERGY_S: |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1635 | case USB_PID_DW2102: |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1636 | dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, |
| 1637 | DW210X_WRITE_MSG); |
| 1638 | dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, |
| 1639 | DW210X_READ_MSG); |
| 1640 | /* check STV0299 frontend */ |
| 1641 | dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2, |
| 1642 | DW210X_READ_MSG); |
Igor M. Liplianin | ea023df | 2008-12-04 12:49:23 -0300 | [diff] [blame] | 1643 | if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1644 | dw2102_properties.i2c_algo = &dw2102_i2c_algo; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1645 | dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1646 | break; |
| 1647 | } else { |
| 1648 | /* check STV0288 frontend */ |
| 1649 | reset16[0] = 0xd0; |
| 1650 | reset16[1] = 1; |
| 1651 | reset16[2] = 0; |
| 1652 | dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, |
| 1653 | DW210X_WRITE_MSG); |
| 1654 | dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, |
| 1655 | DW210X_READ_MSG); |
| 1656 | if (reset16[2] == 0x11) { |
| 1657 | dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1658 | break; |
| 1659 | } |
| 1660 | } |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1661 | case 0x2101: |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1662 | dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, |
| 1663 | DW210X_READ_MSG); |
| 1664 | dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, |
| 1665 | DW210X_READ_MSG); |
| 1666 | dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, |
| 1667 | DW210X_READ_MSG); |
| 1668 | dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, |
| 1669 | DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1670 | break; |
| 1671 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1672 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1673 | msleep(100); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1674 | kfree(p); |
| 1675 | } |
| 1676 | return ret; |
| 1677 | } |
| 1678 | |
| 1679 | static struct dvb_usb_device_properties dw2102_properties = { |
| 1680 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1681 | .usb_ctrl = DEVICE_SPECIFIC, |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1682 | .firmware = DW2102_FIRMWARE, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1683 | .no_reconnect = 1, |
| 1684 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1685 | .i2c_algo = &dw2102_serit_i2c_algo, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1686 | |
| 1687 | .rc.legacy = { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1688 | .rc_map_table = rc_map_dw210x_table, |
| 1689 | .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table), |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1690 | .rc_interval = 150, |
| 1691 | .rc_query = dw2102_rc_query, |
| 1692 | }, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1693 | |
| 1694 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1695 | /* parameter for the MPEG2-data transfer */ |
| 1696 | .num_adapters = 1, |
| 1697 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1698 | .read_mac_address = dw210x_read_mac_address, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1699 | .adapter = { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1700 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1701 | .num_frontends = 1, |
| 1702 | .fe = {{ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1703 | .frontend_attach = dw2102_frontend_attach, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1704 | .stream = { |
| 1705 | .type = USB_BULK, |
| 1706 | .count = 8, |
| 1707 | .endpoint = 0x82, |
| 1708 | .u = { |
| 1709 | .bulk = { |
| 1710 | .buffersize = 4096, |
| 1711 | } |
| 1712 | } |
| 1713 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1714 | }}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1715 | } |
| 1716 | }, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1717 | .num_device_descs = 3, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1718 | .devices = { |
| 1719 | {"DVBWorld DVB-S 2102 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1720 | {&dw2102_table[CYPRESS_DW2102], NULL}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1721 | {NULL}, |
| 1722 | }, |
| 1723 | {"DVBWorld DVB-S 2101 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1724 | {&dw2102_table[CYPRESS_DW2101], NULL}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1725 | {NULL}, |
| 1726 | }, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1727 | {"TerraTec Cinergy S USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1728 | {&dw2102_table[TERRATEC_CINERGY_S], NULL}, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1729 | {NULL}, |
| 1730 | }, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1731 | } |
| 1732 | }; |
| 1733 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1734 | static struct dvb_usb_device_properties dw2104_properties = { |
| 1735 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1736 | .usb_ctrl = DEVICE_SPECIFIC, |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1737 | .firmware = DW2104_FIRMWARE, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1738 | .no_reconnect = 1, |
| 1739 | |
| 1740 | .i2c_algo = &dw2104_i2c_algo, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1741 | .rc.legacy = { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1742 | .rc_map_table = rc_map_dw210x_table, |
| 1743 | .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table), |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1744 | .rc_interval = 150, |
| 1745 | .rc_query = dw2102_rc_query, |
| 1746 | }, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1747 | |
| 1748 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1749 | /* parameter for the MPEG2-data transfer */ |
| 1750 | .num_adapters = 1, |
| 1751 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1752 | .read_mac_address = dw210x_read_mac_address, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1753 | .adapter = { |
| 1754 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1755 | .num_frontends = 1, |
| 1756 | .fe = {{ |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1757 | .frontend_attach = dw2104_frontend_attach, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1758 | .stream = { |
| 1759 | .type = USB_BULK, |
| 1760 | .count = 8, |
| 1761 | .endpoint = 0x82, |
| 1762 | .u = { |
| 1763 | .bulk = { |
| 1764 | .buffersize = 4096, |
| 1765 | } |
| 1766 | } |
| 1767 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1768 | }}, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1769 | } |
| 1770 | }, |
| 1771 | .num_device_descs = 2, |
| 1772 | .devices = { |
| 1773 | { "DVBWorld DW2104 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1774 | {&dw2102_table[CYPRESS_DW2104], NULL}, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1775 | {NULL}, |
| 1776 | }, |
| 1777 | { "TeVii S650 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1778 | {&dw2102_table[TEVII_S650], NULL}, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1779 | {NULL}, |
| 1780 | }, |
| 1781 | } |
| 1782 | }; |
| 1783 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1784 | static struct dvb_usb_device_properties dw3101_properties = { |
| 1785 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1786 | .usb_ctrl = DEVICE_SPECIFIC, |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1787 | .firmware = DW3101_FIRMWARE, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1788 | .no_reconnect = 1, |
| 1789 | |
| 1790 | .i2c_algo = &dw3101_i2c_algo, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1791 | .rc.legacy = { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1792 | .rc_map_table = rc_map_dw210x_table, |
| 1793 | .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table), |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1794 | .rc_interval = 150, |
| 1795 | .rc_query = dw2102_rc_query, |
| 1796 | }, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1797 | |
| 1798 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1799 | /* parameter for the MPEG2-data transfer */ |
| 1800 | .num_adapters = 1, |
| 1801 | .download_firmware = dw2102_load_firmware, |
| 1802 | .read_mac_address = dw210x_read_mac_address, |
| 1803 | .adapter = { |
| 1804 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1805 | .num_frontends = 1, |
| 1806 | .fe = {{ |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1807 | .frontend_attach = dw3101_frontend_attach, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1808 | .tuner_attach = dw3101_tuner_attach, |
| 1809 | .stream = { |
| 1810 | .type = USB_BULK, |
| 1811 | .count = 8, |
| 1812 | .endpoint = 0x82, |
| 1813 | .u = { |
| 1814 | .bulk = { |
| 1815 | .buffersize = 4096, |
| 1816 | } |
| 1817 | } |
| 1818 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1819 | }}, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1820 | } |
| 1821 | }, |
| 1822 | .num_device_descs = 1, |
| 1823 | .devices = { |
| 1824 | { "DVBWorld DVB-C 3101 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1825 | {&dw2102_table[CYPRESS_DW3101], NULL}, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1826 | {NULL}, |
| 1827 | }, |
| 1828 | } |
| 1829 | }; |
| 1830 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1831 | static struct dvb_usb_device_properties s6x0_properties = { |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1832 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1833 | .usb_ctrl = DEVICE_SPECIFIC, |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1834 | .size_of_priv = sizeof(struct s6x0_state), |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1835 | .firmware = S630_FIRMWARE, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1836 | .no_reconnect = 1, |
| 1837 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1838 | .i2c_algo = &s6x0_i2c_algo, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1839 | .rc.legacy = { |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 1840 | .rc_map_table = rc_map_tevii_table, |
| 1841 | .rc_map_size = ARRAY_SIZE(rc_map_tevii_table), |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1842 | .rc_interval = 150, |
| 1843 | .rc_query = dw2102_rc_query, |
| 1844 | }, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1845 | |
| 1846 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1847 | .num_adapters = 1, |
| 1848 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1849 | .read_mac_address = s6x0_read_mac_address, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1850 | .adapter = { |
| 1851 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1852 | .num_frontends = 1, |
| 1853 | .fe = {{ |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1854 | .frontend_attach = zl100313_frontend_attach, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1855 | .stream = { |
| 1856 | .type = USB_BULK, |
| 1857 | .count = 8, |
| 1858 | .endpoint = 0x82, |
| 1859 | .u = { |
| 1860 | .bulk = { |
| 1861 | .buffersize = 4096, |
| 1862 | } |
| 1863 | } |
| 1864 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1865 | }}, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1866 | } |
| 1867 | }, |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1868 | .num_device_descs = 1, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1869 | .devices = { |
| 1870 | {"TeVii S630 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1871 | {&dw2102_table[TEVII_S630], NULL}, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1872 | {NULL}, |
| 1873 | }, |
| 1874 | } |
| 1875 | }; |
| 1876 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1877 | struct dvb_usb_device_properties *p1100; |
| 1878 | static struct dvb_usb_device_description d1100 = { |
| 1879 | "Prof 1100 USB ", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1880 | {&dw2102_table[PROF_1100], NULL}, |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1881 | {NULL}, |
| 1882 | }; |
| 1883 | |
| 1884 | struct dvb_usb_device_properties *s660; |
| 1885 | static struct dvb_usb_device_description d660 = { |
| 1886 | "TeVii S660 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1887 | {&dw2102_table[TEVII_S660], NULL}, |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1888 | {NULL}, |
| 1889 | }; |
| 1890 | |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1891 | static struct dvb_usb_device_description d480_1 = { |
| 1892 | "TeVii S480.1 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1893 | {&dw2102_table[TEVII_S480_1], NULL}, |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1894 | {NULL}, |
| 1895 | }; |
| 1896 | |
| 1897 | static struct dvb_usb_device_description d480_2 = { |
| 1898 | "TeVii S480.2 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1899 | {&dw2102_table[TEVII_S480_2], NULL}, |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1900 | {NULL}, |
| 1901 | }; |
| 1902 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1903 | struct dvb_usb_device_properties *p7500; |
| 1904 | static struct dvb_usb_device_description d7500 = { |
| 1905 | "Prof 7500 USB DVB-S2", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1906 | {&dw2102_table[PROF_7500], NULL}, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1907 | {NULL}, |
| 1908 | }; |
| 1909 | |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1910 | struct dvb_usb_device_properties *s421; |
| 1911 | static struct dvb_usb_device_description d421 = { |
| 1912 | "TeVii S421 PCI", |
| 1913 | {&dw2102_table[TEVII_S421], NULL}, |
| 1914 | {NULL}, |
| 1915 | }; |
| 1916 | |
| 1917 | static struct dvb_usb_device_description d632 = { |
| 1918 | "TeVii S632 USB", |
| 1919 | {&dw2102_table[TEVII_S632], NULL}, |
| 1920 | {NULL}, |
| 1921 | }; |
| 1922 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1923 | static struct dvb_usb_device_properties su3000_properties = { |
| 1924 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1925 | .usb_ctrl = DEVICE_SPECIFIC, |
| 1926 | .size_of_priv = sizeof(struct su3000_state), |
| 1927 | .power_ctrl = su3000_power_ctrl, |
| 1928 | .num_adapters = 1, |
| 1929 | .identify_state = su3000_identify_state, |
| 1930 | .i2c_algo = &su3000_i2c_algo, |
| 1931 | |
| 1932 | .rc.legacy = { |
| 1933 | .rc_map_table = rc_map_su3000_table, |
| 1934 | .rc_map_size = ARRAY_SIZE(rc_map_su3000_table), |
| 1935 | .rc_interval = 150, |
| 1936 | .rc_query = dw2102_rc_query, |
| 1937 | }, |
| 1938 | |
| 1939 | .read_mac_address = su3000_read_mac_address, |
| 1940 | |
| 1941 | .generic_bulk_ctrl_endpoint = 0x01, |
| 1942 | |
| 1943 | .adapter = { |
| 1944 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1945 | .num_frontends = 1, |
| 1946 | .fe = {{ |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1947 | .streaming_ctrl = su3000_streaming_ctrl, |
| 1948 | .frontend_attach = su3000_frontend_attach, |
| 1949 | .stream = { |
| 1950 | .type = USB_BULK, |
| 1951 | .count = 8, |
| 1952 | .endpoint = 0x82, |
| 1953 | .u = { |
| 1954 | .bulk = { |
| 1955 | .buffersize = 4096, |
| 1956 | } |
| 1957 | } |
| 1958 | } |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1959 | }}, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1960 | } |
| 1961 | }, |
Mauro Carvalho Chehab | b7e3863 | 2012-07-07 00:19:20 -0300 | [diff] [blame] | 1962 | .num_device_descs = 3, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1963 | .devices = { |
| 1964 | { "SU3000HD DVB-S USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1965 | { &dw2102_table[GENIATECH_SU3000], NULL }, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1966 | { NULL }, |
| 1967 | }, |
Igor M. Liplianin | 2adc591 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1968 | { "Terratec Cinergy S2 USB HD", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1969 | { &dw2102_table[TERRATEC_CINERGY_S2], NULL }, |
Igor M. Liplianin | 2adc591 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1970 | { NULL }, |
| 1971 | }, |
Igor M. Liplianin | 5265ea5 | 2011-02-27 16:17:25 -0300 | [diff] [blame] | 1972 | { "X3M TV SPC1400HD PCI", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1973 | { &dw2102_table[X3M_SPC1400HD], NULL }, |
Igor M. Liplianin | 5265ea5 | 2011-02-27 16:17:25 -0300 | [diff] [blame] | 1974 | { NULL }, |
| 1975 | }, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1976 | } |
| 1977 | }; |
| 1978 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1979 | static int dw2102_probe(struct usb_interface *intf, |
| 1980 | const struct usb_device_id *id) |
| 1981 | { |
Thomas Meyer | 68dd9dd | 2011-11-17 18:43:40 -0300 | [diff] [blame] | 1982 | p1100 = kmemdup(&s6x0_properties, |
| 1983 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1984 | if (!p1100) |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1985 | return -ENOMEM; |
| 1986 | /* copy default structure */ |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1987 | /* fill only different fields */ |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1988 | p1100->firmware = P1100_FIRMWARE; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1989 | p1100->devices[0] = d1100; |
| 1990 | p1100->rc.legacy.rc_map_table = rc_map_tbs_table; |
| 1991 | p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1992 | p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1993 | |
Thomas Meyer | 68dd9dd | 2011-11-17 18:43:40 -0300 | [diff] [blame] | 1994 | s660 = kmemdup(&s6x0_properties, |
| 1995 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1996 | if (!s660) { |
| 1997 | kfree(p1100); |
| 1998 | return -ENOMEM; |
| 1999 | } |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 2000 | s660->firmware = S660_FIRMWARE; |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2001 | s660->num_device_descs = 3; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2002 | s660->devices[0] = d660; |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2003 | s660->devices[1] = d480_1; |
| 2004 | s660->devices[2] = d480_2; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2005 | s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2006 | |
Thomas Meyer | 68dd9dd | 2011-11-17 18:43:40 -0300 | [diff] [blame] | 2007 | p7500 = kmemdup(&s6x0_properties, |
| 2008 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2009 | if (!p7500) { |
| 2010 | kfree(p1100); |
| 2011 | kfree(s660); |
| 2012 | return -ENOMEM; |
| 2013 | } |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 2014 | p7500->firmware = P7500_FIRMWARE; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2015 | p7500->devices[0] = d7500; |
Mauro Carvalho Chehab | 2f4f58d | 2010-11-17 15:46:09 -0300 | [diff] [blame] | 2016 | p7500->rc.legacy.rc_map_table = rc_map_tbs_table; |
| 2017 | p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2018 | p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2019 | |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 2020 | |
| 2021 | s421 = kmemdup(&su3000_properties, |
| 2022 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
| 2023 | if (!s421) { |
| 2024 | kfree(p1100); |
| 2025 | kfree(s660); |
| 2026 | kfree(p7500); |
| 2027 | return -ENOMEM; |
| 2028 | } |
| 2029 | s421->num_device_descs = 2; |
| 2030 | s421->devices[0] = d421; |
| 2031 | s421->devices[1] = d632; |
| 2032 | s421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach; |
| 2033 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 2034 | if (0 == dvb_usb_device_init(intf, &dw2102_properties, |
| 2035 | THIS_MODULE, NULL, adapter_nr) || |
| 2036 | 0 == dvb_usb_device_init(intf, &dw2104_properties, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2037 | THIS_MODULE, NULL, adapter_nr) || |
| 2038 | 0 == dvb_usb_device_init(intf, &dw3101_properties, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2039 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 2040 | 0 == dvb_usb_device_init(intf, &s6x0_properties, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2041 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2042 | 0 == dvb_usb_device_init(intf, p1100, |
| 2043 | THIS_MODULE, NULL, adapter_nr) || |
| 2044 | 0 == dvb_usb_device_init(intf, s660, |
| 2045 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2046 | 0 == dvb_usb_device_init(intf, p7500, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2047 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 2048 | 0 == dvb_usb_device_init(intf, s421, |
| 2049 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2050 | 0 == dvb_usb_device_init(intf, &su3000_properties, |
| 2051 | THIS_MODULE, NULL, adapter_nr)) |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 2052 | return 0; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 2053 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 2054 | return -ENODEV; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 2055 | } |
| 2056 | |
| 2057 | static struct usb_driver dw2102_driver = { |
| 2058 | .name = "dw2102", |
| 2059 | .probe = dw2102_probe, |
| 2060 | .disconnect = dvb_usb_device_exit, |
| 2061 | .id_table = dw2102_table, |
| 2062 | }; |
| 2063 | |
Greg Kroah-Hartman | ecb3b2b | 2011-11-18 09:46:12 -0800 | [diff] [blame] | 2064 | module_usb_driver(dw2102_driver); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 2065 | |
| 2066 | MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2067 | MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 2068 | " DVB-C 3101 USB2.0," |
| 2069 | " TeVii S600, S630, S650, S660, S480, S421, S632" |
| 2070 | " Prof 1100, 7500 USB2.0," |
| 2071 | " Geniatech SU3000 devices"); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 2072 | MODULE_VERSION("0.1"); |
| 2073 | MODULE_LICENSE("GPL"); |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 2074 | MODULE_FIRMWARE(DW2101_FIRMWARE); |
| 2075 | MODULE_FIRMWARE(DW2102_FIRMWARE); |
| 2076 | MODULE_FIRMWARE(DW2104_FIRMWARE); |
| 2077 | MODULE_FIRMWARE(DW3101_FIRMWARE); |
| 2078 | MODULE_FIRMWARE(S630_FIRMWARE); |
| 2079 | MODULE_FIRMWARE(S660_FIRMWARE); |
| 2080 | MODULE_FIRMWARE(P1100_FIRMWARE); |
| 2081 | MODULE_FIRMWARE(P7500_FIRMWARE); |