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, |
Olli Salonen | 6ede20f | 2016-03-02 08:06:06 -0300 | [diff] [blame] | 3 | * TeVii S421, S480, S482, S600, S630, S632, S650, S660, S662, |
Igor M. Liplianin | 2f30fb4 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 4 | * Prof 1100, 7500, |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 5 | * Geniatech SU3000, T220, |
Olli Salonen | 6ede20f | 2016-03-02 08:06:06 -0300 | [diff] [blame] | 6 | * TechnoTrend S2-4600, |
| 7 | * Terratec Cinergy S2 cards |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 8 | * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by) |
Igor M. Liplianin | 2f30fb4 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the |
| 12 | * Free Software Foundation, version 2. |
| 13 | * |
| 14 | * see Documentation/dvb/README.dvb-usb for more information |
| 15 | */ |
Mauro Carvalho Chehab | e836427 | 2016-03-03 14:50:17 -0300 | [diff] [blame] | 16 | #include "dvb-usb-ids.h" |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 17 | #include "dw2102.h" |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 18 | #include "si21xx.h" |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 19 | #include "stv0299.h" |
| 20 | #include "z0194a.h" |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 21 | #include "stv0288.h" |
| 22 | #include "stb6000.h" |
| 23 | #include "eds1547.h" |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 24 | #include "cx24116.h" |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 25 | #include "tda1002x.h" |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 26 | #include "mt312.h" |
| 27 | #include "zl10039.h" |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 28 | #include "ts2020.h" |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 29 | #include "ds3000.h" |
| 30 | #include "stv0900.h" |
| 31 | #include "stv6110.h" |
| 32 | #include "stb6100.h" |
| 33 | #include "stb6100_proc.h" |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 34 | #include "m88rs2000.h" |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 35 | #include "tda18271.h" |
| 36 | #include "cxd2820r.h" |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 37 | #include "m88ds3103.h" |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 38 | |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 39 | /* Max transfer size done by I2C transfer functions */ |
| 40 | #define MAX_XFER_SIZE 64 |
| 41 | |
Andrey Pavlenko | f08e9f0 | 2013-03-07 09:36:22 -0300 | [diff] [blame] | 42 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 43 | #define DW210X_READ_MSG 0 |
| 44 | #define DW210X_WRITE_MSG 1 |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 45 | |
| 46 | #define REG_1F_SYMBOLRATE_BYTE0 0x1f |
| 47 | #define REG_20_SYMBOLRATE_BYTE1 0x20 |
| 48 | #define REG_21_SYMBOLRATE_BYTE2 0x21 |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 49 | /* on my own*/ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 50 | #define DW2102_VOLTAGE_CTRL (0x1800) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 51 | #define SU3000_STREAM_CTRL (0x1900) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 52 | #define DW2102_RC_QUERY (0x1a00) |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 53 | #define DW2102_LED_CTRL (0x1b00) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 54 | |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 55 | #define DW2101_FIRMWARE "dvb-usb-dw2101.fw" |
| 56 | #define DW2102_FIRMWARE "dvb-usb-dw2102.fw" |
| 57 | #define DW2104_FIRMWARE "dvb-usb-dw2104.fw" |
| 58 | #define DW3101_FIRMWARE "dvb-usb-dw3101.fw" |
| 59 | #define S630_FIRMWARE "dvb-usb-s630.fw" |
| 60 | #define S660_FIRMWARE "dvb-usb-s660.fw" |
| 61 | #define P1100_FIRMWARE "dvb-usb-p1100.fw" |
| 62 | #define P7500_FIRMWARE "dvb-usb-p7500.fw" |
| 63 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 64 | #define err_str "did not find the firmware file. (%s) " \ |
| 65 | "Please see linux/Documentation/dvb/ for more details " \ |
| 66 | "on firmware-problems." |
| 67 | |
Olli Salonen | 2c4ffe2 | 2015-03-16 14:14:04 -0300 | [diff] [blame] | 68 | struct dw2102_state { |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 69 | u8 initialized; |
Olli Salonen | 356484c | 2015-05-05 13:33:55 -0300 | [diff] [blame] | 70 | u8 last_lock; |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 71 | u8 data[MAX_XFER_SIZE + 4]; |
Olli Salonen | f3c6abc | 2016-02-16 15:53:45 -0200 | [diff] [blame] | 72 | struct i2c_client *i2c_client_demod; |
Olli Salonen | 70769b2 | 2015-03-16 14:14:05 -0300 | [diff] [blame] | 73 | struct i2c_client *i2c_client_tuner; |
Olli Salonen | 356484c | 2015-05-05 13:33:55 -0300 | [diff] [blame] | 74 | |
| 75 | /* fe hook functions*/ |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 76 | int (*old_set_voltage)(struct dvb_frontend *f, enum fe_sec_voltage v); |
Olli Salonen | 356484c | 2015-05-05 13:33:55 -0300 | [diff] [blame] | 77 | int (*fe_read_status)(struct dvb_frontend *fe, |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 78 | enum fe_status *status); |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 79 | }; |
| 80 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 81 | /* debug */ |
| 82 | static int dvb_usb_dw2102_debug; |
| 83 | module_param_named(debug, dvb_usb_dw2102_debug, int, 0644); |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 84 | MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))." |
| 85 | DVB_USB_DEBUG_STATUS); |
| 86 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 87 | /* demod probe */ |
| 88 | static int demod_probe = 1; |
| 89 | module_param_named(demod, demod_probe, int, 0644); |
Mauro Carvalho Chehab | f319ed9 | 2016-10-18 17:44:15 -0200 | [diff] [blame] | 90 | MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 4=stv0903+stb6100(or-able))."); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 91 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 92 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 93 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 94 | 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] | 95 | u16 index, u8 * data, u16 len, int flags) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 96 | { |
| 97 | int ret; |
Florian Mickler | b47b850 | 2011-03-21 15:33:44 -0300 | [diff] [blame] | 98 | u8 *u8buf; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 99 | unsigned int pipe = (flags == DW210X_READ_MSG) ? |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 100 | usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 101 | 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] | 102 | |
Florian Mickler | b47b850 | 2011-03-21 15:33:44 -0300 | [diff] [blame] | 103 | u8buf = kmalloc(len, GFP_KERNEL); |
| 104 | if (!u8buf) |
| 105 | return -ENOMEM; |
| 106 | |
| 107 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 108 | if (flags == DW210X_WRITE_MSG) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 109 | memcpy(u8buf, data, len); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 110 | ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, |
| 111 | value, index , u8buf, len, 2000); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 112 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 113 | if (flags == DW210X_READ_MSG) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 114 | memcpy(data, u8buf, len); |
Florian Mickler | b47b850 | 2011-03-21 15:33:44 -0300 | [diff] [blame] | 115 | |
| 116 | kfree(u8buf); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 117 | return ret; |
| 118 | } |
| 119 | |
| 120 | /* I2C */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 121 | static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 122 | int num) |
| 123 | { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 124 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 125 | int i = 0; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 126 | u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0}; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 127 | u16 value; |
| 128 | |
| 129 | if (!d) |
| 130 | return -ENODEV; |
| 131 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 132 | return -EAGAIN; |
| 133 | |
| 134 | switch (num) { |
| 135 | case 2: |
| 136 | /* read stv0299 register */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 137 | value = msg[0].buf[0];/* register */ |
| 138 | for (i = 0; i < msg[1].len; i++) { |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 139 | dw210x_op_rw(d->udev, 0xb5, value + i, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 140 | buf6, 2, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 141 | msg[1].buf[i] = buf6[0]; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 142 | } |
| 143 | break; |
| 144 | case 1: |
| 145 | switch (msg[0].addr) { |
| 146 | case 0x68: |
| 147 | /* write to stv0299 register */ |
| 148 | buf6[0] = 0x2a; |
| 149 | buf6[1] = msg[0].buf[0]; |
| 150 | buf6[2] = msg[0].buf[1]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 151 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 152 | buf6, 3, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 153 | break; |
| 154 | case 0x60: |
| 155 | if (msg[0].flags == 0) { |
| 156 | /* write to tuner pll */ |
| 157 | buf6[0] = 0x2c; |
| 158 | buf6[1] = 5; |
| 159 | buf6[2] = 0xc0; |
| 160 | buf6[3] = msg[0].buf[0]; |
| 161 | buf6[4] = msg[0].buf[1]; |
| 162 | buf6[5] = msg[0].buf[2]; |
| 163 | buf6[6] = msg[0].buf[3]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 164 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 165 | buf6, 7, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 166 | } else { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 167 | /* read from tuner */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 168 | dw210x_op_rw(d->udev, 0xb5, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 169 | buf6, 1, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 170 | msg[0].buf[0] = buf6[0]; |
| 171 | } |
| 172 | break; |
| 173 | case (DW2102_RC_QUERY): |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 174 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 175 | buf6, 2, DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 176 | msg[0].buf[0] = buf6[0]; |
| 177 | msg[0].buf[1] = buf6[1]; |
| 178 | break; |
| 179 | case (DW2102_VOLTAGE_CTRL): |
| 180 | buf6[0] = 0x30; |
| 181 | buf6[1] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 182 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 183 | buf6, 2, DW210X_WRITE_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 184 | break; |
| 185 | } |
| 186 | |
| 187 | break; |
| 188 | } |
| 189 | |
| 190 | mutex_unlock(&d->i2c_mutex); |
| 191 | return num; |
| 192 | } |
| 193 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 194 | static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap, |
| 195 | struct i2c_msg msg[], int num) |
| 196 | { |
| 197 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 198 | u8 buf6[] = {0, 0, 0, 0, 0, 0, 0}; |
| 199 | |
| 200 | if (!d) |
| 201 | return -ENODEV; |
| 202 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 203 | return -EAGAIN; |
| 204 | |
| 205 | switch (num) { |
| 206 | case 2: |
Alyssa Milburn | 950e252 | 2017-04-01 14:34:49 -0300 | [diff] [blame] | 207 | if (msg[0].len != 1) { |
| 208 | warn("i2c rd: len=%d is not 1!\n", |
| 209 | msg[0].len); |
| 210 | num = -EOPNOTSUPP; |
| 211 | break; |
| 212 | } |
| 213 | |
| 214 | if (2 + msg[1].len > sizeof(buf6)) { |
| 215 | warn("i2c rd: len=%d is too big!\n", |
| 216 | msg[1].len); |
| 217 | num = -EOPNOTSUPP; |
| 218 | break; |
| 219 | } |
| 220 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 221 | /* read si2109 register by number */ |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 222 | buf6[0] = msg[0].addr << 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 223 | buf6[1] = msg[0].len; |
| 224 | buf6[2] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 225 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 226 | buf6, msg[0].len + 2, DW210X_WRITE_MSG); |
| 227 | /* read si2109 register */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 228 | dw210x_op_rw(d->udev, 0xc3, 0xd0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 229 | buf6, msg[1].len + 2, DW210X_READ_MSG); |
| 230 | memcpy(msg[1].buf, buf6 + 2, msg[1].len); |
| 231 | |
| 232 | break; |
| 233 | case 1: |
| 234 | switch (msg[0].addr) { |
| 235 | case 0x68: |
Alyssa Milburn | 950e252 | 2017-04-01 14:34:49 -0300 | [diff] [blame] | 236 | if (2 + msg[0].len > sizeof(buf6)) { |
| 237 | warn("i2c wr: len=%d is too big!\n", |
| 238 | msg[0].len); |
| 239 | num = -EOPNOTSUPP; |
| 240 | break; |
| 241 | } |
| 242 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 243 | /* write to si2109 register */ |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 244 | buf6[0] = msg[0].addr << 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 245 | buf6[1] = msg[0].len; |
| 246 | memcpy(buf6 + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 247 | dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 248 | msg[0].len + 2, DW210X_WRITE_MSG); |
| 249 | break; |
| 250 | case(DW2102_RC_QUERY): |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 251 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 252 | buf6, 2, DW210X_READ_MSG); |
| 253 | msg[0].buf[0] = buf6[0]; |
| 254 | msg[0].buf[1] = buf6[1]; |
| 255 | break; |
| 256 | case(DW2102_VOLTAGE_CTRL): |
| 257 | buf6[0] = 0x30; |
| 258 | buf6[1] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 259 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 260 | buf6, 2, DW210X_WRITE_MSG); |
| 261 | break; |
| 262 | } |
| 263 | break; |
| 264 | } |
| 265 | |
| 266 | mutex_unlock(&d->i2c_mutex); |
| 267 | return num; |
| 268 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 269 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 270 | static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
| 271 | { |
| 272 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 273 | int ret; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 274 | |
| 275 | if (!d) |
| 276 | return -ENODEV; |
| 277 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 278 | return -EAGAIN; |
| 279 | |
| 280 | switch (num) { |
| 281 | case 2: { |
| 282 | /* read */ |
| 283 | /* first write first register number */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 284 | u8 ibuf[MAX_XFER_SIZE], obuf[3]; |
| 285 | |
Alyssa Milburn | 950e252 | 2017-04-01 14:34:49 -0300 | [diff] [blame] | 286 | if (2 + msg[0].len != sizeof(obuf)) { |
| 287 | warn("i2c rd: len=%d is not 1!\n", |
| 288 | msg[0].len); |
| 289 | ret = -EOPNOTSUPP; |
| 290 | goto unlock; |
| 291 | } |
| 292 | |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 293 | if (2 + msg[1].len > sizeof(ibuf)) { |
| 294 | warn("i2c rd: len=%d is too big!\n", |
| 295 | msg[1].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 296 | ret = -EOPNOTSUPP; |
| 297 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 298 | } |
| 299 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 300 | obuf[0] = msg[0].addr << 1; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 301 | obuf[1] = msg[0].len; |
| 302 | obuf[2] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 303 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 304 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 305 | /* second read registers */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 306 | dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 307 | ibuf, msg[1].len + 2, DW210X_READ_MSG); |
| 308 | memcpy(msg[1].buf, ibuf + 2, msg[1].len); |
| 309 | |
| 310 | break; |
| 311 | } |
| 312 | case 1: |
| 313 | switch (msg[0].addr) { |
| 314 | case 0x68: { |
| 315 | /* write to register */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 316 | u8 obuf[MAX_XFER_SIZE]; |
| 317 | |
| 318 | if (2 + msg[0].len > sizeof(obuf)) { |
| 319 | warn("i2c wr: len=%d is too big!\n", |
| 320 | msg[1].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 321 | ret = -EOPNOTSUPP; |
| 322 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 323 | } |
| 324 | |
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 */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 334 | u8 obuf[MAX_XFER_SIZE]; |
| 335 | |
| 336 | if (2 + msg[0].len > sizeof(obuf)) { |
| 337 | warn("i2c wr: len=%d is too big!\n", |
| 338 | msg[1].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 339 | ret = -EOPNOTSUPP; |
| 340 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 341 | } |
| 342 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 343 | obuf[0] = msg[0].addr << 1; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 344 | obuf[1] = msg[0].len; |
| 345 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 346 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 347 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 348 | break; |
| 349 | } |
| 350 | case(DW2102_RC_QUERY): { |
| 351 | u8 ibuf[2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 352 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 353 | ibuf, 2, DW210X_READ_MSG); |
| 354 | memcpy(msg[0].buf, ibuf , 2); |
| 355 | break; |
| 356 | } |
| 357 | case(DW2102_VOLTAGE_CTRL): { |
| 358 | u8 obuf[2]; |
| 359 | obuf[0] = 0x30; |
| 360 | obuf[1] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 361 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 362 | obuf, 2, DW210X_WRITE_MSG); |
| 363 | break; |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | break; |
| 368 | } |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 369 | ret = num; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 370 | |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 371 | unlock: |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 372 | mutex_unlock(&d->i2c_mutex); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 373 | return ret; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 374 | } |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 375 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 376 | static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
| 377 | { |
| 378 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 379 | int len, i, j, ret; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 380 | |
| 381 | if (!d) |
| 382 | return -ENODEV; |
| 383 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 384 | return -EAGAIN; |
| 385 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 386 | for (j = 0; j < num; j++) { |
| 387 | switch (msg[j].addr) { |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 388 | case(DW2102_RC_QUERY): { |
| 389 | u8 ibuf[2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 390 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 391 | ibuf, 2, DW210X_READ_MSG); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 392 | memcpy(msg[j].buf, ibuf , 2); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 393 | break; |
| 394 | } |
| 395 | case(DW2102_VOLTAGE_CTRL): { |
| 396 | u8 obuf[2]; |
| 397 | obuf[0] = 0x30; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 398 | obuf[1] = msg[j].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 399 | dw210x_op_rw(d->udev, 0xb2, 0, 0, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 400 | obuf, 2, DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 401 | break; |
| 402 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 403 | /*case 0x55: cx24116 |
| 404 | case 0x6a: stv0903 |
| 405 | case 0x68: ds3000, stv0903 |
| 406 | case 0x60: ts2020, stv6110, stb6100 */ |
| 407 | default: { |
| 408 | if (msg[j].flags == I2C_M_RD) { |
| 409 | /* read registers */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 410 | u8 ibuf[MAX_XFER_SIZE]; |
| 411 | |
| 412 | if (2 + msg[j].len > sizeof(ibuf)) { |
| 413 | warn("i2c rd: len=%d is too big!\n", |
| 414 | msg[j].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 415 | ret = -EOPNOTSUPP; |
| 416 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 417 | } |
| 418 | |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 419 | dw210x_op_rw(d->udev, 0xc3, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 420 | (msg[j].addr << 1) + 1, 0, |
| 421 | ibuf, msg[j].len + 2, |
| 422 | DW210X_READ_MSG); |
| 423 | memcpy(msg[j].buf, ibuf + 2, msg[j].len); |
Mauro Carvalho Chehab | 48902bc | 2015-04-29 20:19:20 -0300 | [diff] [blame] | 424 | mdelay(10); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 425 | } else if (((msg[j].buf[0] == 0xb0) && |
| 426 | (msg[j].addr == 0x68)) || |
| 427 | ((msg[j].buf[0] == 0xf7) && |
| 428 | (msg[j].addr == 0x55))) { |
| 429 | /* write firmware */ |
| 430 | u8 obuf[19]; |
| 431 | obuf[0] = msg[j].addr << 1; |
| 432 | obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len); |
| 433 | obuf[2] = msg[j].buf[0]; |
| 434 | len = msg[j].len - 1; |
| 435 | i = 1; |
| 436 | do { |
| 437 | memcpy(obuf + 3, msg[j].buf + i, |
| 438 | (len > 16 ? 16 : len)); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 439 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 440 | obuf, (len > 16 ? 16 : len) + 3, |
| 441 | DW210X_WRITE_MSG); |
| 442 | i += 16; |
| 443 | len -= 16; |
| 444 | } while (len > 0); |
| 445 | } else { |
| 446 | /* write registers */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 447 | u8 obuf[MAX_XFER_SIZE]; |
| 448 | |
| 449 | if (2 + msg[j].len > sizeof(obuf)) { |
| 450 | warn("i2c wr: len=%d is too big!\n", |
| 451 | msg[j].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 452 | ret = -EOPNOTSUPP; |
| 453 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 454 | } |
| 455 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 456 | obuf[0] = msg[j].addr << 1; |
| 457 | obuf[1] = msg[j].len; |
| 458 | memcpy(obuf + 2, msg[j].buf, msg[j].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 459 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 460 | obuf, msg[j].len + 2, |
| 461 | DW210X_WRITE_MSG); |
| 462 | } |
| 463 | break; |
| 464 | } |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 465 | } |
| 466 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 467 | } |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 468 | ret = num; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 469 | |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 470 | unlock: |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 471 | mutex_unlock(&d->i2c_mutex); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 472 | return ret; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 473 | } |
| 474 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 475 | static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 476 | int num) |
| 477 | { |
| 478 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 479 | int ret; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 480 | int i; |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 481 | |
| 482 | if (!d) |
| 483 | return -ENODEV; |
| 484 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 485 | return -EAGAIN; |
| 486 | |
| 487 | switch (num) { |
| 488 | case 2: { |
| 489 | /* read */ |
| 490 | /* first write first register number */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 491 | u8 ibuf[MAX_XFER_SIZE], obuf[3]; |
| 492 | |
Alyssa Milburn | 950e252 | 2017-04-01 14:34:49 -0300 | [diff] [blame] | 493 | if (2 + msg[0].len != sizeof(obuf)) { |
| 494 | warn("i2c rd: len=%d is not 1!\n", |
| 495 | msg[0].len); |
| 496 | ret = -EOPNOTSUPP; |
| 497 | goto unlock; |
| 498 | } |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 499 | if (2 + msg[1].len > sizeof(ibuf)) { |
| 500 | warn("i2c rd: len=%d is too big!\n", |
| 501 | msg[1].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 502 | ret = -EOPNOTSUPP; |
| 503 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 504 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 505 | obuf[0] = msg[0].addr << 1; |
| 506 | obuf[1] = msg[0].len; |
| 507 | obuf[2] = msg[0].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 508 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 509 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 510 | /* second read registers */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 511 | dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 512 | ibuf, msg[1].len + 2, DW210X_READ_MSG); |
| 513 | memcpy(msg[1].buf, ibuf + 2, msg[1].len); |
| 514 | |
| 515 | break; |
| 516 | } |
| 517 | case 1: |
| 518 | switch (msg[0].addr) { |
| 519 | case 0x60: |
| 520 | case 0x0c: { |
| 521 | /* write to register */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 522 | u8 obuf[MAX_XFER_SIZE]; |
| 523 | |
| 524 | if (2 + msg[0].len > sizeof(obuf)) { |
| 525 | warn("i2c wr: len=%d is too big!\n", |
| 526 | msg[0].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 527 | ret = -EOPNOTSUPP; |
| 528 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 529 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 530 | obuf[0] = msg[0].addr << 1; |
| 531 | obuf[1] = msg[0].len; |
| 532 | memcpy(obuf + 2, msg[0].buf, msg[0].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 533 | dw210x_op_rw(d->udev, 0xc2, 0, 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 534 | obuf, msg[0].len + 2, DW210X_WRITE_MSG); |
| 535 | break; |
| 536 | } |
| 537 | case(DW2102_RC_QUERY): { |
| 538 | u8 ibuf[2]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 539 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 540 | ibuf, 2, DW210X_READ_MSG); |
| 541 | memcpy(msg[0].buf, ibuf , 2); |
| 542 | break; |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | break; |
| 547 | } |
| 548 | |
| 549 | for (i = 0; i < num; i++) { |
| 550 | deb_xfer("%02x:%02x: %s ", i, msg[i].addr, |
| 551 | msg[i].flags == 0 ? ">>>" : "<<<"); |
| 552 | debug_dump(msg[i].buf, msg[i].len, deb_xfer); |
| 553 | } |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 554 | ret = num; |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 555 | |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 556 | unlock: |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 557 | mutex_unlock(&d->i2c_mutex); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 558 | return ret; |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 559 | } |
| 560 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 561 | 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] | 562 | int num) |
| 563 | { |
| 564 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Julia Lawall | 21ead03 | 2009-12-22 18:00:07 -0300 | [diff] [blame] | 565 | struct usb_device *udev; |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 566 | int len, i, j, ret; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 567 | |
| 568 | if (!d) |
| 569 | return -ENODEV; |
Julia Lawall | 21ead03 | 2009-12-22 18:00:07 -0300 | [diff] [blame] | 570 | udev = d->udev; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 571 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 572 | return -EAGAIN; |
| 573 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 574 | for (j = 0; j < num; j++) { |
| 575 | switch (msg[j].addr) { |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 576 | case (DW2102_RC_QUERY): { |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 577 | u8 ibuf[5]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 578 | dw210x_op_rw(d->udev, 0xb8, 0, 0, |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 579 | ibuf, 5, DW210X_READ_MSG); |
| 580 | memcpy(msg[j].buf, ibuf + 3, 2); |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 581 | break; |
| 582 | } |
| 583 | case (DW2102_VOLTAGE_CTRL): { |
| 584 | u8 obuf[2]; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 585 | |
| 586 | obuf[0] = 1; |
| 587 | obuf[1] = msg[j].buf[1];/* off-on */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 588 | dw210x_op_rw(d->udev, 0x8a, 0, 0, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 589 | obuf, 2, DW210X_WRITE_MSG); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 590 | obuf[0] = 3; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 591 | obuf[1] = msg[j].buf[0];/* 13v-18v */ |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 592 | dw210x_op_rw(d->udev, 0x8a, 0, 0, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 593 | obuf, 2, DW210X_WRITE_MSG); |
| 594 | break; |
| 595 | } |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 596 | case (DW2102_LED_CTRL): { |
| 597 | u8 obuf[2]; |
| 598 | |
| 599 | obuf[0] = 5; |
| 600 | obuf[1] = msg[j].buf[0]; |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 601 | dw210x_op_rw(d->udev, 0x8a, 0, 0, |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 602 | obuf, 2, DW210X_WRITE_MSG); |
| 603 | break; |
| 604 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 605 | /*case 0x55: cx24116 |
| 606 | case 0x6a: stv0903 |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 607 | case 0x68: ds3000, stv0903, rs2000 |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 608 | case 0x60: ts2020, stv6110, stb6100 |
| 609 | case 0xa0: eeprom */ |
| 610 | default: { |
| 611 | if (msg[j].flags == I2C_M_RD) { |
| 612 | /* read registers */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 613 | u8 ibuf[MAX_XFER_SIZE]; |
| 614 | |
| 615 | if (msg[j].len > sizeof(ibuf)) { |
| 616 | warn("i2c rd: len=%d is too big!\n", |
| 617 | msg[j].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 618 | ret = -EOPNOTSUPP; |
| 619 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 620 | } |
| 621 | |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 622 | dw210x_op_rw(d->udev, 0x91, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 623 | ibuf, msg[j].len, |
| 624 | DW210X_READ_MSG); |
| 625 | memcpy(msg[j].buf, ibuf, msg[j].len); |
| 626 | break; |
| 627 | } else if ((msg[j].buf[0] == 0xb0) && |
| 628 | (msg[j].addr == 0x68)) { |
| 629 | /* write firmware */ |
| 630 | u8 obuf[19]; |
| 631 | obuf[0] = (msg[j].len > 16 ? |
| 632 | 18 : msg[j].len + 1); |
| 633 | obuf[1] = msg[j].addr << 1; |
| 634 | obuf[2] = msg[j].buf[0]; |
| 635 | len = msg[j].len - 1; |
| 636 | i = 1; |
| 637 | do { |
| 638 | memcpy(obuf + 3, msg[j].buf + i, |
| 639 | (len > 16 ? 16 : len)); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 640 | dw210x_op_rw(d->udev, 0x80, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 641 | obuf, (len > 16 ? 16 : len) + 3, |
| 642 | DW210X_WRITE_MSG); |
| 643 | i += 16; |
| 644 | len -= 16; |
| 645 | } while (len > 0); |
Igor M. Liplianin | a84adf4 | 2011-02-27 16:18:38 -0300 | [diff] [blame] | 646 | } else if (j < (num - 1)) { |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 647 | /* write register addr before read */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 648 | u8 obuf[MAX_XFER_SIZE]; |
| 649 | |
| 650 | if (2 + msg[j].len > sizeof(obuf)) { |
| 651 | warn("i2c wr: len=%d is too big!\n", |
| 652 | msg[j].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 653 | ret = -EOPNOTSUPP; |
| 654 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 655 | } |
| 656 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 657 | obuf[0] = msg[j + 1].len; |
| 658 | obuf[1] = (msg[j].addr << 1); |
| 659 | memcpy(obuf + 2, msg[j].buf, msg[j].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 660 | dw210x_op_rw(d->udev, |
Hans Verkuil | 1ad5d06 | 2014-08-20 16:45:27 -0300 | [diff] [blame] | 661 | le16_to_cpu(udev->descriptor.idProduct) == |
Igor M. Liplianin | a84adf4 | 2011-02-27 16:18:38 -0300 | [diff] [blame] | 662 | 0x7500 ? 0x92 : 0x90, 0, 0, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 663 | obuf, msg[j].len + 2, |
| 664 | DW210X_WRITE_MSG); |
| 665 | break; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 666 | } else { |
| 667 | /* write registers */ |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 668 | u8 obuf[MAX_XFER_SIZE]; |
| 669 | |
| 670 | if (2 + msg[j].len > sizeof(obuf)) { |
| 671 | warn("i2c wr: len=%d is too big!\n", |
| 672 | msg[j].len); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 673 | ret = -EOPNOTSUPP; |
| 674 | goto unlock; |
Mauro Carvalho Chehab | 0065a79 | 2013-11-02 07:43:40 -0300 | [diff] [blame] | 675 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 676 | obuf[0] = msg[j].len + 1; |
| 677 | obuf[1] = (msg[j].addr << 1); |
| 678 | memcpy(obuf + 2, msg[j].buf, msg[j].len); |
Hans Verkuil | d51dbec | 2012-04-20 03:30:11 -0300 | [diff] [blame] | 679 | dw210x_op_rw(d->udev, 0x80, 0, 0, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 680 | obuf, msg[j].len + 2, |
| 681 | DW210X_WRITE_MSG); |
| 682 | break; |
| 683 | } |
| 684 | break; |
| 685 | } |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 686 | } |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 687 | } |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 688 | ret = num; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 689 | |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 690 | unlock: |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 691 | mutex_unlock(&d->i2c_mutex); |
Dan Carpenter | 324ed53 | 2013-11-22 04:56:33 -0300 | [diff] [blame] | 692 | return ret; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 693 | } |
| 694 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 695 | static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], |
| 696 | int num) |
| 697 | { |
| 698 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 699 | struct dw2102_state *state; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 700 | |
| 701 | if (!d) |
| 702 | return -ENODEV; |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 703 | |
| 704 | state = d->priv; |
| 705 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 706 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 707 | return -EAGAIN; |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 708 | if (mutex_lock_interruptible(&d->data_mutex) < 0) { |
| 709 | mutex_unlock(&d->i2c_mutex); |
| 710 | return -EAGAIN; |
| 711 | } |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 712 | |
| 713 | switch (num) { |
| 714 | case 1: |
| 715 | switch (msg[0].addr) { |
| 716 | case SU3000_STREAM_CTRL: |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 717 | state->data[0] = msg[0].buf[0] + 0x36; |
| 718 | state->data[1] = 3; |
| 719 | state->data[2] = 0; |
| 720 | if (dvb_usb_generic_rw(d, state->data, 3, |
| 721 | state->data, 0, 0) < 0) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 722 | err("i2c transfer failed."); |
| 723 | break; |
| 724 | case DW2102_RC_QUERY: |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 725 | state->data[0] = 0x10; |
| 726 | if (dvb_usb_generic_rw(d, state->data, 1, |
| 727 | state->data, 2, 0) < 0) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 728 | err("i2c transfer failed."); |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 729 | msg[0].buf[1] = state->data[0]; |
| 730 | msg[0].buf[0] = state->data[1]; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 731 | break; |
| 732 | default: |
Alyssa Milburn | 950e252 | 2017-04-01 14:34:49 -0300 | [diff] [blame] | 733 | if (3 + msg[0].len > sizeof(state->data)) { |
| 734 | warn("i2c wr: len=%d is too big!\n", |
| 735 | msg[0].len); |
| 736 | num = -EOPNOTSUPP; |
| 737 | break; |
| 738 | } |
| 739 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 740 | /* always i2c write*/ |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 741 | state->data[0] = 0x08; |
| 742 | state->data[1] = msg[0].addr; |
| 743 | state->data[2] = msg[0].len; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 744 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 745 | memcpy(&state->data[3], msg[0].buf, msg[0].len); |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 746 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 747 | if (dvb_usb_generic_rw(d, state->data, msg[0].len + 3, |
| 748 | state->data, 1, 0) < 0) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 749 | err("i2c transfer failed."); |
| 750 | |
| 751 | } |
| 752 | break; |
| 753 | case 2: |
| 754 | /* always i2c read */ |
Alyssa Milburn | 950e252 | 2017-04-01 14:34:49 -0300 | [diff] [blame] | 755 | if (4 + msg[0].len > sizeof(state->data)) { |
| 756 | warn("i2c rd: len=%d is too big!\n", |
| 757 | msg[0].len); |
| 758 | num = -EOPNOTSUPP; |
| 759 | break; |
| 760 | } |
| 761 | if (1 + msg[1].len > sizeof(state->data)) { |
| 762 | warn("i2c rd: len=%d is too big!\n", |
| 763 | msg[1].len); |
| 764 | num = -EOPNOTSUPP; |
| 765 | break; |
| 766 | } |
| 767 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 768 | state->data[0] = 0x09; |
| 769 | state->data[1] = msg[0].len; |
| 770 | state->data[2] = msg[1].len; |
| 771 | state->data[3] = msg[0].addr; |
| 772 | memcpy(&state->data[4], msg[0].buf, msg[0].len); |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 773 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 774 | if (dvb_usb_generic_rw(d, state->data, msg[0].len + 4, |
| 775 | state->data, msg[1].len + 1, 0) < 0) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 776 | err("i2c transfer failed."); |
| 777 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 778 | memcpy(msg[1].buf, &state->data[1], msg[1].len); |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 779 | break; |
| 780 | default: |
| 781 | warn("more than 2 i2c messages at a time is not handled yet."); |
| 782 | break; |
| 783 | } |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 784 | mutex_unlock(&d->data_mutex); |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 785 | mutex_unlock(&d->i2c_mutex); |
| 786 | return num; |
| 787 | } |
| 788 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 789 | static u32 dw210x_i2c_func(struct i2c_adapter *adapter) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 790 | { |
| 791 | return I2C_FUNC_I2C; |
| 792 | } |
| 793 | |
| 794 | static struct i2c_algorithm dw2102_i2c_algo = { |
| 795 | .master_xfer = dw2102_i2c_transfer, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 796 | .functionality = dw210x_i2c_func, |
| 797 | }; |
| 798 | |
| 799 | static struct i2c_algorithm dw2102_serit_i2c_algo = { |
| 800 | .master_xfer = dw2102_serit_i2c_transfer, |
| 801 | .functionality = dw210x_i2c_func, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 802 | }; |
| 803 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 804 | static struct i2c_algorithm dw2102_earda_i2c_algo = { |
| 805 | .master_xfer = dw2102_earda_i2c_transfer, |
| 806 | .functionality = dw210x_i2c_func, |
| 807 | }; |
| 808 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 809 | static struct i2c_algorithm dw2104_i2c_algo = { |
| 810 | .master_xfer = dw2104_i2c_transfer, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 811 | .functionality = dw210x_i2c_func, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 812 | }; |
| 813 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 814 | static struct i2c_algorithm dw3101_i2c_algo = { |
| 815 | .master_xfer = dw3101_i2c_transfer, |
| 816 | .functionality = dw210x_i2c_func, |
| 817 | }; |
| 818 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 819 | static struct i2c_algorithm s6x0_i2c_algo = { |
| 820 | .master_xfer = s6x0_i2c_transfer, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 821 | .functionality = dw210x_i2c_func, |
| 822 | }; |
| 823 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 824 | static struct i2c_algorithm su3000_i2c_algo = { |
| 825 | .master_xfer = su3000_i2c_transfer, |
| 826 | .functionality = dw210x_i2c_func, |
| 827 | }; |
| 828 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 829 | 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] | 830 | { |
| 831 | int i; |
| 832 | u8 ibuf[] = {0, 0}; |
| 833 | u8 eeprom[256], eepromline[16]; |
| 834 | |
| 835 | for (i = 0; i < 256; i++) { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 836 | 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] | 837 | err("read eeprom failed."); |
| 838 | return -1; |
| 839 | } else { |
| 840 | eepromline[i%16] = ibuf[0]; |
| 841 | eeprom[i] = ibuf[0]; |
| 842 | } |
| 843 | if ((i % 16) == 15) { |
| 844 | deb_xfer("%02x: ", i - 15); |
| 845 | debug_dump(eepromline, 16, deb_xfer); |
| 846 | } |
| 847 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 848 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 849 | memcpy(mac, eeprom + 8, 6); |
| 850 | return 0; |
| 851 | }; |
| 852 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 853 | 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] | 854 | { |
| 855 | int i, ret; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 856 | u8 ibuf[] = { 0 }, obuf[] = { 0 }; |
| 857 | u8 eeprom[256], eepromline[16]; |
| 858 | struct i2c_msg msg[] = { |
| 859 | { |
| 860 | .addr = 0xa0 >> 1, |
| 861 | .flags = 0, |
| 862 | .buf = obuf, |
| 863 | .len = 1, |
| 864 | }, { |
| 865 | .addr = 0xa0 >> 1, |
| 866 | .flags = I2C_M_RD, |
| 867 | .buf = ibuf, |
| 868 | .len = 1, |
| 869 | } |
| 870 | }; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 871 | |
| 872 | for (i = 0; i < 256; i++) { |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 873 | obuf[0] = i; |
| 874 | ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2); |
| 875 | if (ret != 2) { |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 876 | err("read eeprom failed."); |
| 877 | return -1; |
| 878 | } else { |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 879 | eepromline[i % 16] = ibuf[0]; |
| 880 | eeprom[i] = ibuf[0]; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | if ((i % 16) == 15) { |
| 884 | deb_xfer("%02x: ", i - 15); |
| 885 | debug_dump(eepromline, 16, deb_xfer); |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | memcpy(mac, eeprom + 16, 6); |
| 890 | return 0; |
| 891 | }; |
| 892 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 893 | static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) |
| 894 | { |
| 895 | static u8 command_start[] = {0x00}; |
| 896 | static u8 command_stop[] = {0x01}; |
| 897 | struct i2c_msg msg = { |
| 898 | .addr = SU3000_STREAM_CTRL, |
| 899 | .flags = 0, |
| 900 | .buf = onoff ? command_start : command_stop, |
| 901 | .len = 1 |
| 902 | }; |
| 903 | |
| 904 | i2c_transfer(&adap->dev->i2c_adap, &msg, 1); |
| 905 | |
| 906 | return 0; |
| 907 | } |
| 908 | |
| 909 | static int su3000_power_ctrl(struct dvb_usb_device *d, int i) |
| 910 | { |
Olli Salonen | 2c4ffe2 | 2015-03-16 14:14:04 -0300 | [diff] [blame] | 911 | struct dw2102_state *state = (struct dw2102_state *)d->priv; |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 912 | int ret = 0; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 913 | |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 914 | info("%s: %d, initialized %d", __func__, i, state->initialized); |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 915 | |
| 916 | if (i && !state->initialized) { |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 917 | mutex_lock(&d->data_mutex); |
| 918 | |
| 919 | state->data[0] = 0xde; |
| 920 | state->data[1] = 0; |
| 921 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 922 | state->initialized = 1; |
| 923 | /* reset board */ |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 924 | ret = dvb_usb_generic_rw(d, state->data, 2, NULL, 0, 0); |
| 925 | mutex_unlock(&d->data_mutex); |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 926 | } |
| 927 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 928 | return ret; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) |
| 932 | { |
| 933 | int i; |
| 934 | u8 obuf[] = { 0x1f, 0xf0 }; |
| 935 | u8 ibuf[] = { 0 }; |
| 936 | struct i2c_msg msg[] = { |
| 937 | { |
| 938 | .addr = 0x51, |
| 939 | .flags = 0, |
| 940 | .buf = obuf, |
| 941 | .len = 2, |
| 942 | }, { |
| 943 | .addr = 0x51, |
| 944 | .flags = I2C_M_RD, |
| 945 | .buf = ibuf, |
| 946 | .len = 1, |
| 947 | |
| 948 | } |
| 949 | }; |
| 950 | |
| 951 | for (i = 0; i < 6; i++) { |
| 952 | obuf[1] = 0xf0 + i; |
| 953 | if (i2c_transfer(&d->i2c_adap, msg, 2) != 2) |
| 954 | break; |
| 955 | else |
| 956 | mac[i] = ibuf[0]; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | return 0; |
| 960 | } |
| 961 | |
| 962 | static int su3000_identify_state(struct usb_device *udev, |
| 963 | struct dvb_usb_device_properties *props, |
| 964 | struct dvb_usb_device_description **desc, |
| 965 | int *cold) |
| 966 | { |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 967 | info("%s", __func__); |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 968 | |
| 969 | *cold = 0; |
| 970 | return 0; |
| 971 | } |
| 972 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 973 | static int dw210x_set_voltage(struct dvb_frontend *fe, |
| 974 | enum fe_sec_voltage voltage) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 975 | { |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 976 | static u8 command_13v[] = {0x00, 0x01}; |
| 977 | static u8 command_18v[] = {0x01, 0x01}; |
| 978 | static u8 command_off[] = {0x00, 0x00}; |
| 979 | struct i2c_msg msg = { |
| 980 | .addr = DW2102_VOLTAGE_CTRL, |
| 981 | .flags = 0, |
| 982 | .buf = command_off, |
| 983 | .len = 2, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 984 | }; |
| 985 | |
| 986 | struct dvb_usb_adapter *udev_adap = |
| 987 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 988 | if (voltage == SEC_VOLTAGE_18) |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 989 | msg.buf = command_18v; |
| 990 | else if (voltage == SEC_VOLTAGE_13) |
| 991 | msg.buf = command_13v; |
| 992 | |
| 993 | i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); |
| 994 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 995 | return 0; |
| 996 | } |
| 997 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 998 | static int s660_set_voltage(struct dvb_frontend *fe, |
| 999 | enum fe_sec_voltage voltage) |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1000 | { |
| 1001 | struct dvb_usb_adapter *d = |
| 1002 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
Olli Salonen | 2c4ffe2 | 2015-03-16 14:14:04 -0300 | [diff] [blame] | 1003 | struct dw2102_state *st = (struct dw2102_state *)d->dev->priv; |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1004 | |
| 1005 | dw210x_set_voltage(fe, voltage); |
| 1006 | if (st->old_set_voltage) |
| 1007 | st->old_set_voltage(fe, voltage); |
| 1008 | |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1012 | static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon) |
| 1013 | { |
| 1014 | static u8 led_off[] = { 0 }; |
| 1015 | static u8 led_on[] = { 1 }; |
| 1016 | struct i2c_msg msg = { |
| 1017 | .addr = DW2102_LED_CTRL, |
| 1018 | .flags = 0, |
| 1019 | .buf = led_off, |
| 1020 | .len = 1 |
| 1021 | }; |
| 1022 | struct dvb_usb_adapter *udev_adap = |
| 1023 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 1024 | |
| 1025 | if (offon) |
| 1026 | msg.buf = led_on; |
| 1027 | i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); |
| 1028 | } |
| 1029 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 1030 | static int tt_s2_4600_read_status(struct dvb_frontend *fe, |
| 1031 | enum fe_status *status) |
Olli Salonen | 356484c | 2015-05-05 13:33:55 -0300 | [diff] [blame] | 1032 | { |
| 1033 | struct dvb_usb_adapter *d = |
| 1034 | (struct dvb_usb_adapter *)(fe->dvb->priv); |
| 1035 | struct dw2102_state *st = (struct dw2102_state *)d->dev->priv; |
| 1036 | int ret; |
| 1037 | |
| 1038 | ret = st->fe_read_status(fe, status); |
| 1039 | |
| 1040 | /* resync slave fifo when signal change from unlock to lock */ |
| 1041 | if ((*status & FE_HAS_LOCK) && (!st->last_lock)) |
| 1042 | su3000_streaming_ctrl(d, 1); |
| 1043 | |
| 1044 | st->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0; |
| 1045 | return ret; |
| 1046 | } |
| 1047 | |
Igor M. Liplianin | d4305c6 | 2008-10-17 13:45:55 -0300 | [diff] [blame] | 1048 | static struct stv0299_config sharp_z0194a_config = { |
| 1049 | .demod_address = 0x68, |
| 1050 | .inittab = sharp_z0194a_inittab, |
| 1051 | .mclk = 88000000UL, |
| 1052 | .invert = 1, |
| 1053 | .skip_reinit = 0, |
| 1054 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 1055 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
| 1056 | .min_delay_ms = 100, |
| 1057 | .set_symbol_rate = sharp_z0194a_set_symbol_rate, |
| 1058 | }; |
| 1059 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1060 | static struct cx24116_config dw2104_config = { |
| 1061 | .demod_address = 0x55, |
Igor M. Liplianin | cc8c4f3 | 2008-09-09 13:57:47 -0300 | [diff] [blame] | 1062 | .mpg_clk_pos_pol = 0x01, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1063 | }; |
| 1064 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1065 | static struct si21xx_config serit_sp1511lhb_config = { |
| 1066 | .demod_address = 0x68, |
| 1067 | .min_delay_ms = 100, |
| 1068 | |
| 1069 | }; |
| 1070 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1071 | static struct tda10023_config dw3101_tda10023_config = { |
| 1072 | .demod_address = 0x0c, |
| 1073 | .invert = 1, |
| 1074 | }; |
| 1075 | |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1076 | static struct mt312_config zl313_config = { |
| 1077 | .demod_address = 0x0e, |
| 1078 | }; |
| 1079 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1080 | static struct ds3000_config dw2104_ds3000_config = { |
| 1081 | .demod_address = 0x68, |
| 1082 | }; |
| 1083 | |
John Horan | 03a6727 | 2013-08-28 09:37:37 -0300 | [diff] [blame] | 1084 | static struct ts2020_config dw2104_ts2020_config = { |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1085 | .tuner_address = 0x60, |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1086 | .clk_out_div = 1, |
John Horan | 03a6727 | 2013-08-28 09:37:37 -0300 | [diff] [blame] | 1087 | .frequency_div = 1060000, |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1088 | }; |
| 1089 | |
Igor M. Liplianin | 43385c8 | 2012-12-28 19:40:24 -0300 | [diff] [blame] | 1090 | static struct ds3000_config s660_ds3000_config = { |
| 1091 | .demod_address = 0x68, |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1092 | .ci_mode = 1, |
Igor M. Liplianin | 43385c8 | 2012-12-28 19:40:24 -0300 | [diff] [blame] | 1093 | .set_lock_led = dw210x_led_ctrl, |
| 1094 | }; |
| 1095 | |
John Horan | 03a6727 | 2013-08-28 09:37:37 -0300 | [diff] [blame] | 1096 | static struct ts2020_config s660_ts2020_config = { |
| 1097 | .tuner_address = 0x60, |
| 1098 | .clk_out_div = 1, |
| 1099 | .frequency_div = 1146000, |
| 1100 | }; |
| 1101 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1102 | static struct stv0900_config dw2104a_stv0900_config = { |
| 1103 | .demod_address = 0x6a, |
| 1104 | .demod_mode = 0, |
| 1105 | .xtal = 27000000, |
| 1106 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ |
| 1107 | .diseqc_mode = 2,/* 2/3 PWM */ |
| 1108 | .tun1_maddress = 0,/* 0x60 */ |
| 1109 | .tun1_adc = 0,/* 2 Vpp */ |
| 1110 | .path1_mode = 3, |
| 1111 | }; |
| 1112 | |
| 1113 | static struct stb6100_config dw2104a_stb6100_config = { |
| 1114 | .tuner_address = 0x60, |
| 1115 | .refclock = 27000000, |
| 1116 | }; |
| 1117 | |
| 1118 | static struct stv0900_config dw2104_stv0900_config = { |
| 1119 | .demod_address = 0x68, |
| 1120 | .demod_mode = 0, |
| 1121 | .xtal = 8000000, |
| 1122 | .clkmode = 3, |
| 1123 | .diseqc_mode = 2, |
| 1124 | .tun1_maddress = 0, |
| 1125 | .tun1_adc = 1,/* 1 Vpp */ |
| 1126 | .path1_mode = 3, |
| 1127 | }; |
| 1128 | |
| 1129 | static struct stv6110_config dw2104_stv6110_config = { |
| 1130 | .i2c_address = 0x60, |
| 1131 | .mclk = 16000000, |
| 1132 | .clk_div = 1, |
| 1133 | }; |
| 1134 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1135 | static struct stv0900_config prof_7500_stv0900_config = { |
| 1136 | .demod_address = 0x6a, |
| 1137 | .demod_mode = 0, |
| 1138 | .xtal = 27000000, |
| 1139 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ |
| 1140 | .diseqc_mode = 2,/* 2/3 PWM */ |
| 1141 | .tun1_maddress = 0,/* 0x60 */ |
| 1142 | .tun1_adc = 0,/* 2 Vpp */ |
| 1143 | .path1_mode = 3, |
| 1144 | .tun1_type = 3, |
Igor M. Liplianin | fa8bae1 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1145 | .set_lock_led = dw210x_led_ctrl, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1146 | }; |
| 1147 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1148 | static struct ds3000_config su3000_ds3000_config = { |
| 1149 | .demod_address = 0x68, |
| 1150 | .ci_mode = 1, |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1151 | .set_lock_led = dw210x_led_ctrl, |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1152 | }; |
| 1153 | |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1154 | static struct cxd2820r_config cxd2820r_config = { |
| 1155 | .i2c_address = 0x6c, /* (0xd8 >> 1) */ |
| 1156 | .ts_mode = 0x38, |
CrazyCat | 7b71ef7 | 2014-06-03 14:22:44 -0300 | [diff] [blame] | 1157 | .ts_clock_inv = 1, |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1158 | }; |
| 1159 | |
| 1160 | static struct tda18271_config tda18271_config = { |
| 1161 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
| 1162 | .gate = TDA18271_GATE_DIGITAL, |
| 1163 | }; |
| 1164 | |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1165 | static u8 m88rs2000_inittab[] = { |
| 1166 | DEMOD_WRITE, 0x9a, 0x30, |
| 1167 | DEMOD_WRITE, 0x00, 0x01, |
| 1168 | WRITE_DELAY, 0x19, 0x00, |
| 1169 | DEMOD_WRITE, 0x00, 0x00, |
| 1170 | DEMOD_WRITE, 0x9a, 0xb0, |
| 1171 | DEMOD_WRITE, 0x81, 0xc1, |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1172 | DEMOD_WRITE, 0x81, 0x81, |
| 1173 | DEMOD_WRITE, 0x86, 0xc6, |
| 1174 | DEMOD_WRITE, 0x9a, 0x30, |
| 1175 | DEMOD_WRITE, 0xf0, 0x80, |
| 1176 | DEMOD_WRITE, 0xf1, 0xbf, |
| 1177 | DEMOD_WRITE, 0xb0, 0x45, |
| 1178 | DEMOD_WRITE, 0xb2, 0x01, |
| 1179 | DEMOD_WRITE, 0x9a, 0xb0, |
| 1180 | 0xff, 0xaa, 0xff |
| 1181 | }; |
| 1182 | |
| 1183 | static struct m88rs2000_config s421_m88rs2000_config = { |
| 1184 | .demod_addr = 0x68, |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1185 | .inittab = m88rs2000_inittab, |
| 1186 | }; |
| 1187 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1188 | static int dw2104_frontend_attach(struct dvb_usb_adapter *d) |
| 1189 | { |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1190 | struct dvb_tuner_ops *tuner_ops = NULL; |
| 1191 | |
| 1192 | if (demod_probe & 4) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1193 | 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] | 1194 | &d->dev->i2c_adap, 0); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1195 | if (d->fe_adap[0].fe != NULL) { |
| 1196 | if (dvb_attach(stb6100_attach, d->fe_adap[0].fe, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1197 | &dw2104a_stb6100_config, |
| 1198 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1199 | tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1200 | tuner_ops->set_frequency = stb6100_set_freq; |
| 1201 | tuner_ops->get_frequency = stb6100_get_freq; |
| 1202 | tuner_ops->set_bandwidth = stb6100_set_bandw; |
| 1203 | tuner_ops->get_bandwidth = stb6100_get_bandw; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1204 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1205 | info("Attached STV0900+STB6100!"); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1206 | return 0; |
| 1207 | } |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | if (demod_probe & 2) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1212 | 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] | 1213 | &d->dev->i2c_adap, 0); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1214 | if (d->fe_adap[0].fe != NULL) { |
| 1215 | if (dvb_attach(stv6110_attach, d->fe_adap[0].fe, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1216 | &dw2104_stv6110_config, |
| 1217 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1218 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1219 | info("Attached STV0900+STV6110A!"); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1220 | return 0; |
| 1221 | } |
| 1222 | } |
| 1223 | } |
| 1224 | |
| 1225 | if (demod_probe & 1) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1226 | d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1227 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1228 | if (d->fe_adap[0].fe != NULL) { |
| 1229 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1230 | info("Attached cx24116!"); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1231 | return 0; |
| 1232 | } |
| 1233 | } |
| 1234 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1235 | 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] | 1236 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1237 | if (d->fe_adap[0].fe != NULL) { |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1238 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, |
| 1239 | &dw2104_ts2020_config, &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1240 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1241 | info("Attached DS3000!"); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1242 | return 0; |
| 1243 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1244 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1245 | return -EIO; |
| 1246 | } |
| 1247 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1248 | static struct dvb_usb_device_properties dw2102_properties; |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1249 | static struct dvb_usb_device_properties dw2104_properties; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1250 | static struct dvb_usb_device_properties s6x0_properties; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1251 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1252 | static int dw2102_frontend_attach(struct dvb_usb_adapter *d) |
| 1253 | { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1254 | if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) { |
| 1255 | /*dw2102_properties.adapter->tuner_attach = NULL;*/ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1256 | 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] | 1257 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1258 | if (d->fe_adap[0].fe != NULL) { |
| 1259 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1260 | info("Attached si21xx!"); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1261 | return 0; |
| 1262 | } |
| 1263 | } |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1264 | |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1265 | if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1266 | d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1267 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1268 | if (d->fe_adap[0].fe != NULL) { |
| 1269 | if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1270 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1271 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1272 | info("Attached stv0288!"); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1273 | return 0; |
| 1274 | } |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1275 | } |
| 1276 | } |
| 1277 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1278 | if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) { |
| 1279 | /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1280 | 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] | 1281 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1282 | if (d->fe_adap[0].fe != NULL) { |
| 1283 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1284 | info("Attached stv0299!"); |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1285 | return 0; |
| 1286 | } |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1287 | } |
| 1288 | return -EIO; |
| 1289 | } |
| 1290 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1291 | static int dw3101_frontend_attach(struct dvb_usb_adapter *d) |
| 1292 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1293 | 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] | 1294 | &d->dev->i2c_adap, 0x48); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1295 | if (d->fe_adap[0].fe != NULL) { |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1296 | info("Attached tda10023!"); |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1297 | return 0; |
| 1298 | } |
| 1299 | return -EIO; |
| 1300 | } |
| 1301 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1302 | static int zl100313_frontend_attach(struct dvb_usb_adapter *d) |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1303 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1304 | d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1305 | &d->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1306 | if (d->fe_adap[0].fe != NULL) { |
| 1307 | if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1308 | &d->dev->i2c_adap)) { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1309 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1310 | info("Attached zl100313+zl10039!"); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1311 | return 0; |
| 1312 | } |
| 1313 | } |
| 1314 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1315 | return -EIO; |
| 1316 | } |
| 1317 | |
| 1318 | static int stv0288_frontend_attach(struct dvb_usb_adapter *d) |
| 1319 | { |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1320 | u8 obuf[] = {7, 1}; |
| 1321 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1322 | d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1323 | &d->dev->i2c_adap); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1324 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1325 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1326 | return -EIO; |
| 1327 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1328 | 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] | 1329 | return -EIO; |
| 1330 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1331 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1332 | |
| 1333 | dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); |
| 1334 | |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1335 | info("Attached stv0288+stb6000!"); |
Igor M. Liplianin | fd5466d | 2011-02-27 16:22:52 -0300 | [diff] [blame] | 1336 | |
| 1337 | return 0; |
| 1338 | |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1339 | } |
| 1340 | |
| 1341 | static int ds3000_frontend_attach(struct dvb_usb_adapter *d) |
| 1342 | { |
Olli Salonen | 2c4ffe2 | 2015-03-16 14:14:04 -0300 | [diff] [blame] | 1343 | struct dw2102_state *st = d->dev->priv; |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1344 | u8 obuf[] = {7, 1}; |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1345 | |
Igor M. Liplianin | 43385c8 | 2012-12-28 19:40:24 -0300 | [diff] [blame] | 1346 | 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] | 1347 | &d->dev->i2c_adap); |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 1348 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1349 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1350 | return -EIO; |
| 1351 | |
John Horan | 03a6727 | 2013-08-28 09:37:37 -0300 | [diff] [blame] | 1352 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, &s660_ts2020_config, |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1353 | &d->dev->i2c_adap); |
| 1354 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1355 | st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; |
| 1356 | d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage; |
Igor M. Liplianin | 5a530cb | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1357 | |
| 1358 | dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); |
| 1359 | |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1360 | info("Attached ds3000+ts2020!"); |
Igor M. Liplianin | 52c506e | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1361 | |
| 1362 | return 0; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1363 | } |
| 1364 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1365 | static int prof_7500_frontend_attach(struct dvb_usb_adapter *d) |
| 1366 | { |
Igor M. Liplianin | 4e59df8 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1367 | u8 obuf[] = {7, 1}; |
| 1368 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1369 | 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] | 1370 | &d->dev->i2c_adap, 0); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1371 | if (d->fe_adap[0].fe == NULL) |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1372 | return -EIO; |
Igor M. Liplianin | 4e59df8 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1373 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1374 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1375 | |
Igor M. Liplianin | 4e59df8 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 1376 | dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); |
| 1377 | |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1378 | info("Attached STV0900+STB6100A!"); |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 1379 | |
| 1380 | return 0; |
| 1381 | } |
| 1382 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1383 | static int su3000_frontend_attach(struct dvb_usb_adapter *adap) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1384 | { |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1385 | struct dvb_usb_device *d = adap->dev; |
| 1386 | struct dw2102_state *state = d->priv; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1387 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1388 | mutex_lock(&d->data_mutex); |
| 1389 | |
| 1390 | state->data[0] = 0xe; |
| 1391 | state->data[1] = 0x80; |
| 1392 | state->data[2] = 0; |
| 1393 | |
| 1394 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1395 | err("command 0x0e transfer failed."); |
| 1396 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1397 | state->data[0] = 0xe; |
| 1398 | state->data[1] = 0x02; |
| 1399 | state->data[2] = 1; |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1400 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1401 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1402 | err("command 0x0e transfer failed."); |
| 1403 | msleep(300); |
| 1404 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1405 | state->data[0] = 0xe; |
| 1406 | state->data[1] = 0x83; |
| 1407 | state->data[2] = 0; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1408 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1409 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1410 | err("command 0x0e transfer failed."); |
| 1411 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1412 | state->data[0] = 0xe; |
| 1413 | state->data[1] = 0x83; |
| 1414 | state->data[2] = 1; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1415 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1416 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1417 | err("command 0x0e transfer failed."); |
| 1418 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1419 | state->data[0] = 0x51; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1420 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1421 | if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1422 | err("command 0x51 transfer failed."); |
| 1423 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1424 | mutex_unlock(&d->data_mutex); |
| 1425 | |
| 1426 | adap->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config, |
| 1427 | &d->i2c_adap); |
| 1428 | if (adap->fe_adap[0].fe == NULL) |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1429 | return -EIO; |
| 1430 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1431 | if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe, |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1432 | &dw2104_ts2020_config, |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1433 | &d->i2c_adap)) { |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1434 | info("Attached DS3000/TS2020!"); |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1435 | return 0; |
| 1436 | } |
Konstantin Dimitrov | 73f0af4 | 2012-12-23 19:25:38 -0300 | [diff] [blame] | 1437 | |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1438 | info("Failed to attach DS3000/TS2020!"); |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1439 | return -EIO; |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 1440 | } |
| 1441 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1442 | static int t220_frontend_attach(struct dvb_usb_adapter *adap) |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1443 | { |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1444 | struct dvb_usb_device *d = adap->dev; |
| 1445 | struct dw2102_state *state = d->priv; |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1446 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1447 | mutex_lock(&d->data_mutex); |
| 1448 | |
| 1449 | state->data[0] = 0xe; |
| 1450 | state->data[1] = 0x87; |
| 1451 | state->data[2] = 0x0; |
| 1452 | |
| 1453 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1454 | err("command 0x0e transfer failed."); |
| 1455 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1456 | state->data[0] = 0xe; |
| 1457 | state->data[1] = 0x86; |
| 1458 | state->data[2] = 1; |
CrazyCat | 7b71ef7 | 2014-06-03 14:22:44 -0300 | [diff] [blame] | 1459 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1460 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
CrazyCat | 7b71ef7 | 2014-06-03 14:22:44 -0300 | [diff] [blame] | 1461 | err("command 0x0e transfer failed."); |
| 1462 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1463 | state->data[0] = 0xe; |
| 1464 | state->data[1] = 0x80; |
| 1465 | state->data[2] = 0; |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1466 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1467 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1468 | err("command 0x0e transfer failed."); |
| 1469 | |
CrazyCat | 7b71ef7 | 2014-06-03 14:22:44 -0300 | [diff] [blame] | 1470 | msleep(50); |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1471 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1472 | state->data[0] = 0xe; |
| 1473 | state->data[1] = 0x80; |
| 1474 | state->data[2] = 1; |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1475 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1476 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1477 | err("command 0x0e transfer failed."); |
| 1478 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1479 | state->data[0] = 0x51; |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1480 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1481 | if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1482 | err("command 0x51 transfer failed."); |
| 1483 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1484 | mutex_unlock(&d->data_mutex); |
| 1485 | |
| 1486 | adap->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config, |
| 1487 | &d->i2c_adap, NULL); |
| 1488 | if (adap->fe_adap[0].fe != NULL) { |
| 1489 | if (dvb_attach(tda18271_attach, adap->fe_adap[0].fe, 0x60, |
| 1490 | &d->i2c_adap, &tda18271_config)) { |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1491 | info("Attached TDA18271HD/CXD2820R!"); |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1492 | return 0; |
| 1493 | } |
| 1494 | } |
| 1495 | |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1496 | info("Failed to attach TDA18271HD/CXD2820R!"); |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1497 | return -EIO; |
| 1498 | } |
| 1499 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1500 | static int m88rs2000_frontend_attach(struct dvb_usb_adapter *adap) |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1501 | { |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1502 | struct dvb_usb_device *d = adap->dev; |
| 1503 | struct dw2102_state *state = d->priv; |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1504 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1505 | mutex_lock(&d->data_mutex); |
| 1506 | |
| 1507 | state->data[0] = 0x51; |
| 1508 | |
| 1509 | if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1510 | err("command 0x51 transfer failed."); |
| 1511 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1512 | mutex_unlock(&d->data_mutex); |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1513 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1514 | adap->fe_adap[0].fe = dvb_attach(m88rs2000_attach, |
| 1515 | &s421_m88rs2000_config, |
| 1516 | &d->i2c_adap); |
| 1517 | |
| 1518 | if (adap->fe_adap[0].fe == NULL) |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1519 | return -EIO; |
| 1520 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1521 | if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe, |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1522 | &dw2104_ts2020_config, |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1523 | &d->i2c_adap)) { |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1524 | info("Attached RS2000/TS2020!"); |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1525 | return 0; |
| 1526 | } |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1527 | |
Jonathan McDowell | 0385443 | 2016-06-06 10:23:59 -0300 | [diff] [blame] | 1528 | info("Failed to attach RS2000/TS2020!"); |
Igor M. Liplianin | b858c33 | 2012-12-28 19:40:33 -0300 | [diff] [blame] | 1529 | return -EIO; |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1530 | } |
| 1531 | |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1532 | static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap) |
| 1533 | { |
| 1534 | struct dvb_usb_device *d = adap->dev; |
| 1535 | struct dw2102_state *state = d->priv; |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1536 | struct i2c_adapter *i2c_adapter; |
| 1537 | struct i2c_client *client; |
Olli Salonen | f3c6abc | 2016-02-16 15:53:45 -0200 | [diff] [blame] | 1538 | struct i2c_board_info board_info; |
| 1539 | struct m88ds3103_platform_data m88ds3103_pdata = {}; |
Antti Palosaari | 0fecb6c | 2015-03-29 19:28:39 -0300 | [diff] [blame] | 1540 | struct ts2020_config ts2020_config = {}; |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1541 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1542 | mutex_lock(&d->data_mutex); |
| 1543 | |
| 1544 | state->data[0] = 0xe; |
| 1545 | state->data[1] = 0x80; |
| 1546 | state->data[2] = 0x0; |
| 1547 | |
| 1548 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1549 | err("command 0x0e transfer failed."); |
| 1550 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1551 | state->data[0] = 0xe; |
| 1552 | state->data[1] = 0x02; |
| 1553 | state->data[2] = 1; |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1554 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1555 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1556 | err("command 0x0e transfer failed."); |
| 1557 | msleep(300); |
| 1558 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1559 | state->data[0] = 0xe; |
| 1560 | state->data[1] = 0x83; |
| 1561 | state->data[2] = 0; |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1562 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1563 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1564 | err("command 0x0e transfer failed."); |
| 1565 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1566 | state->data[0] = 0xe; |
| 1567 | state->data[1] = 0x83; |
| 1568 | state->data[2] = 1; |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1569 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1570 | if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1571 | err("command 0x0e transfer failed."); |
| 1572 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1573 | state->data[0] = 0x51; |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1574 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1575 | if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1576 | err("command 0x51 transfer failed."); |
| 1577 | |
Jonathan McDowell | 606142a | 2017-02-15 18:29:15 -0200 | [diff] [blame] | 1578 | mutex_unlock(&d->data_mutex); |
| 1579 | |
Olli Salonen | f3c6abc | 2016-02-16 15:53:45 -0200 | [diff] [blame] | 1580 | /* attach demod */ |
| 1581 | m88ds3103_pdata.clk = 27000000; |
| 1582 | m88ds3103_pdata.i2c_wr_max = 33; |
| 1583 | m88ds3103_pdata.ts_mode = M88DS3103_TS_CI; |
| 1584 | m88ds3103_pdata.ts_clk = 16000; |
| 1585 | m88ds3103_pdata.ts_clk_pol = 0; |
| 1586 | m88ds3103_pdata.spec_inv = 0; |
| 1587 | m88ds3103_pdata.agc = 0x99; |
| 1588 | m88ds3103_pdata.agc_inv = 0; |
| 1589 | m88ds3103_pdata.clk_out = M88DS3103_CLOCK_OUT_ENABLED; |
| 1590 | m88ds3103_pdata.envelope_mode = 0; |
| 1591 | m88ds3103_pdata.lnb_hv_pol = 1; |
| 1592 | m88ds3103_pdata.lnb_en_pol = 0; |
| 1593 | memset(&board_info, 0, sizeof(board_info)); |
| 1594 | strlcpy(board_info.type, "m88ds3103", I2C_NAME_SIZE); |
| 1595 | board_info.addr = 0x68; |
| 1596 | board_info.platform_data = &m88ds3103_pdata; |
| 1597 | request_module("m88ds3103"); |
| 1598 | client = i2c_new_device(&d->i2c_adap, &board_info); |
| 1599 | if (client == NULL || client->dev.driver == NULL) |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1600 | return -ENODEV; |
Olli Salonen | f3c6abc | 2016-02-16 15:53:45 -0200 | [diff] [blame] | 1601 | if (!try_module_get(client->dev.driver->owner)) { |
| 1602 | i2c_unregister_device(client); |
| 1603 | return -ENODEV; |
| 1604 | } |
| 1605 | adap->fe_adap[0].fe = m88ds3103_pdata.get_dvb_frontend(client); |
| 1606 | i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client); |
| 1607 | |
| 1608 | state->i2c_client_demod = client; |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1609 | |
| 1610 | /* attach tuner */ |
Antti Palosaari | 0fecb6c | 2015-03-29 19:28:39 -0300 | [diff] [blame] | 1611 | ts2020_config.fe = adap->fe_adap[0].fe; |
Olli Salonen | f3c6abc | 2016-02-16 15:53:45 -0200 | [diff] [blame] | 1612 | memset(&board_info, 0, sizeof(board_info)); |
| 1613 | strlcpy(board_info.type, "ts2022", I2C_NAME_SIZE); |
| 1614 | board_info.addr = 0x60; |
| 1615 | board_info.platform_data = &ts2020_config; |
Antti Palosaari | 0fecb6c | 2015-03-29 19:28:39 -0300 | [diff] [blame] | 1616 | request_module("ts2020"); |
Olli Salonen | f3c6abc | 2016-02-16 15:53:45 -0200 | [diff] [blame] | 1617 | client = i2c_new_device(i2c_adapter, &board_info); |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1618 | |
| 1619 | if (client == NULL || client->dev.driver == NULL) { |
| 1620 | dvb_frontend_detach(adap->fe_adap[0].fe); |
| 1621 | return -ENODEV; |
| 1622 | } |
| 1623 | |
| 1624 | if (!try_module_get(client->dev.driver->owner)) { |
| 1625 | i2c_unregister_device(client); |
| 1626 | dvb_frontend_detach(adap->fe_adap[0].fe); |
| 1627 | return -ENODEV; |
| 1628 | } |
| 1629 | |
| 1630 | /* delegate signal strength measurement to tuner */ |
| 1631 | adap->fe_adap[0].fe->ops.read_signal_strength = |
| 1632 | adap->fe_adap[0].fe->ops.tuner_ops.get_rf_strength; |
| 1633 | |
| 1634 | state->i2c_client_tuner = client; |
| 1635 | |
Olli Salonen | 356484c | 2015-05-05 13:33:55 -0300 | [diff] [blame] | 1636 | /* hook fe: need to resync the slave fifo when signal locks */ |
| 1637 | state->fe_read_status = adap->fe_adap[0].fe->ops.read_status; |
| 1638 | adap->fe_adap[0].fe->ops.read_status = tt_s2_4600_read_status; |
| 1639 | |
| 1640 | state->last_lock = 0; |
| 1641 | |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1642 | return 0; |
| 1643 | } |
| 1644 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1645 | static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) |
| 1646 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1647 | dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1648 | &adap->dev->i2c_adap, DVB_PLL_OPERA1); |
| 1649 | return 0; |
| 1650 | } |
| 1651 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1652 | static int dw3101_tuner_attach(struct dvb_usb_adapter *adap) |
| 1653 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1654 | dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1655 | &adap->dev->i2c_adap, DVB_PLL_TUA6034); |
| 1656 | |
| 1657 | return 0; |
| 1658 | } |
| 1659 | |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1660 | static int dw2102_rc_query(struct dvb_usb_device *d) |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1661 | { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1662 | u8 key[2]; |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1663 | struct i2c_msg msg = { |
| 1664 | .addr = DW2102_RC_QUERY, |
| 1665 | .flags = I2C_M_RD, |
| 1666 | .buf = key, |
| 1667 | .len = 2 |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1668 | }; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1669 | |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1670 | if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1671 | if (msg.buf[0] != 0xff) { |
| 1672 | deb_rc("%s: rc code: %x, %x\n", |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1673 | __func__, key[0], key[1]); |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 1674 | rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN, key[0], 0); |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1675 | } |
| 1676 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1677 | |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1678 | return 0; |
| 1679 | } |
| 1680 | |
| 1681 | static int prof_rc_query(struct dvb_usb_device *d) |
| 1682 | { |
| 1683 | u8 key[2]; |
| 1684 | struct i2c_msg msg = { |
| 1685 | .addr = DW2102_RC_QUERY, |
| 1686 | .flags = I2C_M_RD, |
| 1687 | .buf = key, |
| 1688 | .len = 2 |
| 1689 | }; |
| 1690 | |
| 1691 | if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { |
| 1692 | if (msg.buf[0] != 0xff) { |
| 1693 | deb_rc("%s: rc code: %x, %x\n", |
| 1694 | __func__, key[0], key[1]); |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 1695 | rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN, key[0] ^ 0xff, |
| 1696 | 0); |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1697 | } |
| 1698 | } |
| 1699 | |
| 1700 | return 0; |
| 1701 | } |
| 1702 | |
| 1703 | static int su3000_rc_query(struct dvb_usb_device *d) |
| 1704 | { |
| 1705 | u8 key[2]; |
| 1706 | struct i2c_msg msg = { |
| 1707 | .addr = DW2102_RC_QUERY, |
| 1708 | .flags = I2C_M_RD, |
| 1709 | .buf = key, |
| 1710 | .len = 2 |
| 1711 | }; |
| 1712 | |
| 1713 | if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { |
| 1714 | if (msg.buf[0] != 0xff) { |
| 1715 | deb_rc("%s: rc code: %x, %x\n", |
| 1716 | __func__, key[0], key[1]); |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 1717 | rc_keydown(d->rc_dev, RC_PROTO_RC5, |
David Härdeman | 120703f | 2014-04-03 20:31:30 -0300 | [diff] [blame] | 1718 | RC_SCANCODE_RC5(key[1], key[0]), 0); |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1719 | } |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1720 | } |
Igor M. Liplianin | 8a8dad7 | 2009-06-13 08:10:24 -0300 | [diff] [blame] | 1721 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1722 | return 0; |
| 1723 | } |
| 1724 | |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1725 | enum dw2102_table_entry { |
| 1726 | CYPRESS_DW2102, |
| 1727 | CYPRESS_DW2101, |
| 1728 | CYPRESS_DW2104, |
| 1729 | TEVII_S650, |
| 1730 | TERRATEC_CINERGY_S, |
| 1731 | CYPRESS_DW3101, |
| 1732 | TEVII_S630, |
| 1733 | PROF_1100, |
| 1734 | TEVII_S660, |
| 1735 | PROF_7500, |
| 1736 | GENIATECH_SU3000, |
| 1737 | TERRATEC_CINERGY_S2, |
| 1738 | TEVII_S480_1, |
| 1739 | TEVII_S480_2, |
| 1740 | X3M_SPC1400HD, |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1741 | TEVII_S421, |
| 1742 | TEVII_S632, |
Igor M. Liplianin | 44122dd | 2013-02-21 08:11:41 -0300 | [diff] [blame] | 1743 | TERRATEC_CINERGY_S2_R2, |
Olli Salonen | 49438d9 | 2016-06-13 11:04:50 -0300 | [diff] [blame] | 1744 | TERRATEC_CINERGY_S2_R3, |
Enrico Mioso | 69fd825 | 2016-10-04 08:13:27 -0300 | [diff] [blame] | 1745 | TERRATEC_CINERGY_S2_R4, |
Andrey Pavlenko | f08e9f0 | 2013-03-07 09:36:22 -0300 | [diff] [blame] | 1746 | GOTVIEW_SAT_HD, |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1747 | GENIATECH_T220, |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1748 | TECHNOTREND_S2_4600, |
Olli Salonen | 44767fc | 2015-03-21 17:42:23 -0300 | [diff] [blame] | 1749 | TEVII_S482_1, |
| 1750 | TEVII_S482_2, |
Philipp Zabel | 93b6642 | 2016-01-04 17:32:51 -0200 | [diff] [blame] | 1751 | TERRATEC_CINERGY_S2_BOX, |
Olli Salonen | 6ede20f | 2016-03-02 08:06:06 -0300 | [diff] [blame] | 1752 | TEVII_S662 |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1753 | }; |
| 1754 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1755 | static struct usb_device_id dw2102_table[] = { |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1756 | [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)}, |
| 1757 | [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)}, |
| 1758 | [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)}, |
| 1759 | [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)}, |
Mauro Carvalho Chehab | e836427 | 2016-03-03 14:50:17 -0300 | [diff] [blame] | 1760 | [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S)}, |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1761 | [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)}, |
| 1762 | [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)}, |
| 1763 | [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)}, |
| 1764 | [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)}, |
| 1765 | [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)}, |
| 1766 | [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)}, |
Mauro Carvalho Chehab | a561d76 | 2016-01-25 12:47:44 -0200 | [diff] [blame] | 1767 | [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R1)}, |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1768 | [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)}, |
| 1769 | [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)}, |
| 1770 | [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)}, |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 1771 | [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)}, |
| 1772 | [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)}, |
Mauro Carvalho Chehab | a561d76 | 2016-01-25 12:47:44 -0200 | [diff] [blame] | 1773 | [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R2)}, |
Olli Salonen | 49438d9 | 2016-06-13 11:04:50 -0300 | [diff] [blame] | 1774 | [TERRATEC_CINERGY_S2_R3] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R3)}, |
Enrico Mioso | 69fd825 | 2016-10-04 08:13:27 -0300 | [diff] [blame] | 1775 | [TERRATEC_CINERGY_S2_R4] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R4)}, |
Andrey Pavlenko | f08e9f0 | 2013-03-07 09:36:22 -0300 | [diff] [blame] | 1776 | [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)}, |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 1777 | [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)}, |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 1778 | [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND, |
| 1779 | USB_PID_TECHNOTREND_CONNECT_S2_4600)}, |
Olli Salonen | 44767fc | 2015-03-21 17:42:23 -0300 | [diff] [blame] | 1780 | [TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)}, |
| 1781 | [TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)}, |
Philipp Zabel | 93b6642 | 2016-01-04 17:32:51 -0200 | [diff] [blame] | 1782 | [TERRATEC_CINERGY_S2_BOX] = {USB_DEVICE(USB_VID_TERRATEC, 0x0105)}, |
Olli Salonen | 6ede20f | 2016-03-02 08:06:06 -0300 | [diff] [blame] | 1783 | [TEVII_S662] = {USB_DEVICE(0x9022, USB_PID_TEVII_S662)}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1784 | { } |
| 1785 | }; |
| 1786 | |
| 1787 | MODULE_DEVICE_TABLE(usb, dw2102_table); |
| 1788 | |
| 1789 | static int dw2102_load_firmware(struct usb_device *dev, |
| 1790 | const struct firmware *frmwr) |
| 1791 | { |
| 1792 | u8 *b, *p; |
| 1793 | int ret = 0, i; |
| 1794 | u8 reset; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1795 | u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1796 | const struct firmware *fw; |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 1797 | |
Hans Verkuil | 1ad5d06 | 2014-08-20 16:45:27 -0300 | [diff] [blame] | 1798 | switch (le16_to_cpu(dev->descriptor.idProduct)) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1799 | case 0x2101: |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1800 | ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1801 | if (ret != 0) { |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1802 | err(err_str, DW2101_FIRMWARE); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1803 | return ret; |
| 1804 | } |
| 1805 | break; |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1806 | default: |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1807 | fw = frmwr; |
| 1808 | break; |
| 1809 | } |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1810 | info("start downloading DW210X firmware"); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1811 | p = kmalloc(fw->size, GFP_KERNEL); |
| 1812 | reset = 1; |
| 1813 | /*stop the CPU*/ |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1814 | dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG); |
| 1815 | 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] | 1816 | |
| 1817 | if (p != NULL) { |
| 1818 | memcpy(p, fw->data, fw->size); |
| 1819 | for (i = 0; i < fw->size; i += 0x40) { |
| 1820 | b = (u8 *) p + i; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1821 | if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40, |
| 1822 | DW210X_WRITE_MSG) != 0x40) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1823 | err("error while transferring firmware"); |
| 1824 | ret = -EINVAL; |
| 1825 | break; |
| 1826 | } |
| 1827 | } |
| 1828 | /* restart the CPU */ |
| 1829 | reset = 0; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1830 | if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, |
| 1831 | DW210X_WRITE_MSG) != 1) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1832 | err("could not restart the USB controller CPU."); |
| 1833 | ret = -EINVAL; |
| 1834 | } |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1835 | if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, |
| 1836 | DW210X_WRITE_MSG) != 1) { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1837 | err("could not restart the USB controller CPU."); |
| 1838 | ret = -EINVAL; |
| 1839 | } |
| 1840 | /* init registers */ |
Hans Verkuil | 1ad5d06 | 2014-08-20 16:45:27 -0300 | [diff] [blame] | 1841 | switch (le16_to_cpu(dev->descriptor.idProduct)) { |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1842 | case USB_PID_TEVII_S650: |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1843 | dw2104_properties.rc.core.rc_codes = RC_MAP_TEVII_NEC; |
Mauro Carvalho Chehab | 06eeefe | 2017-05-18 08:13:28 -0300 | [diff] [blame] | 1844 | /* fall through */ |
Igor M. Liplianin | b42e1d7 | 2009-06-14 19:41:22 -0300 | [diff] [blame] | 1845 | case USB_PID_DW2104: |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1846 | reset = 1; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1847 | dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, |
| 1848 | DW210X_WRITE_MSG); |
Mauro Carvalho Chehab | 06eeefe | 2017-05-18 08:13:28 -0300 | [diff] [blame] | 1849 | /* fall through */ |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1850 | case USB_PID_DW3101: |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1851 | reset = 0; |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1852 | dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, |
| 1853 | DW210X_WRITE_MSG); |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1854 | break; |
Mauro Carvalho Chehab | e836427 | 2016-03-03 14:50:17 -0300 | [diff] [blame] | 1855 | case USB_PID_TERRATEC_CINERGY_S: |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1856 | case USB_PID_DW2102: |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1857 | dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, |
| 1858 | DW210X_WRITE_MSG); |
| 1859 | dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, |
| 1860 | DW210X_READ_MSG); |
| 1861 | /* check STV0299 frontend */ |
| 1862 | dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2, |
| 1863 | DW210X_READ_MSG); |
Igor M. Liplianin | ea023df | 2008-12-04 12:49:23 -0300 | [diff] [blame] | 1864 | if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) { |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1865 | dw2102_properties.i2c_algo = &dw2102_i2c_algo; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1866 | dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1867 | break; |
| 1868 | } else { |
| 1869 | /* check STV0288 frontend */ |
| 1870 | reset16[0] = 0xd0; |
| 1871 | reset16[1] = 1; |
| 1872 | reset16[2] = 0; |
| 1873 | dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, |
| 1874 | DW210X_WRITE_MSG); |
| 1875 | dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, |
| 1876 | DW210X_READ_MSG); |
| 1877 | if (reset16[2] == 0x11) { |
| 1878 | dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; |
Igor M. Liplianin | 8a4949b | 2008-10-05 09:11:21 -0300 | [diff] [blame] | 1879 | break; |
| 1880 | } |
| 1881 | } |
Mauro Carvalho Chehab | 06eeefe | 2017-05-18 08:13:28 -0300 | [diff] [blame] | 1882 | /* fall through */ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1883 | case 0x2101: |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1884 | dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, |
| 1885 | DW210X_READ_MSG); |
| 1886 | dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, |
| 1887 | DW210X_READ_MSG); |
| 1888 | dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, |
| 1889 | DW210X_READ_MSG); |
| 1890 | dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, |
| 1891 | DW210X_READ_MSG); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1892 | break; |
| 1893 | } |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1894 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1895 | msleep(100); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1896 | kfree(p); |
| 1897 | } |
Sudip Mukherjee | 2a518f8 | 2016-03-07 07:26:55 -0300 | [diff] [blame] | 1898 | |
| 1899 | if (le16_to_cpu(dev->descriptor.idProduct) == 0x2101) |
| 1900 | release_firmware(fw); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1901 | return ret; |
| 1902 | } |
| 1903 | |
| 1904 | static struct dvb_usb_device_properties dw2102_properties = { |
| 1905 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1906 | .usb_ctrl = DEVICE_SPECIFIC, |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1907 | .firmware = DW2102_FIRMWARE, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1908 | .no_reconnect = 1, |
| 1909 | |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1910 | .i2c_algo = &dw2102_serit_i2c_algo, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1911 | |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1912 | .rc.core = { |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1913 | .rc_interval = 150, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1914 | .rc_codes = RC_MAP_DM1105_NEC, |
| 1915 | .module_name = "dw2102", |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 1916 | .allowed_protos = RC_PROTO_BIT_NEC, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1917 | .rc_query = dw2102_rc_query, |
| 1918 | }, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1919 | |
| 1920 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1921 | /* parameter for the MPEG2-data transfer */ |
| 1922 | .num_adapters = 1, |
| 1923 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1924 | .read_mac_address = dw210x_read_mac_address, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 1925 | .adapter = { |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1926 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1927 | .num_frontends = 1, |
| 1928 | .fe = {{ |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1929 | .frontend_attach = dw2102_frontend_attach, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1930 | .stream = { |
| 1931 | .type = USB_BULK, |
| 1932 | .count = 8, |
| 1933 | .endpoint = 0x82, |
| 1934 | .u = { |
| 1935 | .bulk = { |
| 1936 | .buffersize = 4096, |
| 1937 | } |
| 1938 | } |
| 1939 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1940 | }}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1941 | } |
| 1942 | }, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1943 | .num_device_descs = 3, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1944 | .devices = { |
| 1945 | {"DVBWorld DVB-S 2102 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1946 | {&dw2102_table[CYPRESS_DW2102], NULL}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1947 | {NULL}, |
| 1948 | }, |
| 1949 | {"DVBWorld DVB-S 2101 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1950 | {&dw2102_table[CYPRESS_DW2101], NULL}, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1951 | {NULL}, |
| 1952 | }, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1953 | {"TerraTec Cinergy S USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 1954 | {&dw2102_table[TERRATEC_CINERGY_S], NULL}, |
Igor M. Liplianin | 4cc0edf | 2008-11-05 22:12:56 -0300 | [diff] [blame] | 1955 | {NULL}, |
| 1956 | }, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 1957 | } |
| 1958 | }; |
| 1959 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1960 | static struct dvb_usb_device_properties dw2104_properties = { |
| 1961 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1962 | .usb_ctrl = DEVICE_SPECIFIC, |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 1963 | .firmware = DW2104_FIRMWARE, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1964 | .no_reconnect = 1, |
| 1965 | |
| 1966 | .i2c_algo = &dw2104_i2c_algo, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1967 | .rc.core = { |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1968 | .rc_interval = 150, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 1969 | .rc_codes = RC_MAP_DM1105_NEC, |
| 1970 | .module_name = "dw2102", |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 1971 | .allowed_protos = RC_PROTO_BIT_NEC, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1972 | .rc_query = dw2102_rc_query, |
| 1973 | }, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1974 | |
| 1975 | .generic_bulk_ctrl_endpoint = 0x81, |
| 1976 | /* parameter for the MPEG2-data transfer */ |
| 1977 | .num_adapters = 1, |
| 1978 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 21b007b | 2008-09-17 19:19:19 -0300 | [diff] [blame] | 1979 | .read_mac_address = dw210x_read_mac_address, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1980 | .adapter = { |
| 1981 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1982 | .num_frontends = 1, |
| 1983 | .fe = {{ |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1984 | .frontend_attach = dw2104_frontend_attach, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1985 | .stream = { |
| 1986 | .type = USB_BULK, |
| 1987 | .count = 8, |
| 1988 | .endpoint = 0x82, |
| 1989 | .u = { |
| 1990 | .bulk = { |
| 1991 | .buffersize = 4096, |
| 1992 | } |
| 1993 | } |
| 1994 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1995 | }}, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 1996 | } |
| 1997 | }, |
| 1998 | .num_device_descs = 2, |
| 1999 | .devices = { |
| 2000 | { "DVBWorld DW2104 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2001 | {&dw2102_table[CYPRESS_DW2104], NULL}, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 2002 | {NULL}, |
| 2003 | }, |
| 2004 | { "TeVii S650 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2005 | {&dw2102_table[TEVII_S650], NULL}, |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 2006 | {NULL}, |
| 2007 | }, |
| 2008 | } |
| 2009 | }; |
| 2010 | |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2011 | static struct dvb_usb_device_properties dw3101_properties = { |
| 2012 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 2013 | .usb_ctrl = DEVICE_SPECIFIC, |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 2014 | .firmware = DW3101_FIRMWARE, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2015 | .no_reconnect = 1, |
| 2016 | |
| 2017 | .i2c_algo = &dw3101_i2c_algo, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2018 | .rc.core = { |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 2019 | .rc_interval = 150, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2020 | .rc_codes = RC_MAP_DM1105_NEC, |
| 2021 | .module_name = "dw2102", |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 2022 | .allowed_protos = RC_PROTO_BIT_NEC, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 2023 | .rc_query = dw2102_rc_query, |
| 2024 | }, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2025 | |
| 2026 | .generic_bulk_ctrl_endpoint = 0x81, |
| 2027 | /* parameter for the MPEG2-data transfer */ |
| 2028 | .num_adapters = 1, |
| 2029 | .download_firmware = dw2102_load_firmware, |
| 2030 | .read_mac_address = dw210x_read_mac_address, |
| 2031 | .adapter = { |
| 2032 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2033 | .num_frontends = 1, |
| 2034 | .fe = {{ |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2035 | .frontend_attach = dw3101_frontend_attach, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2036 | .tuner_attach = dw3101_tuner_attach, |
| 2037 | .stream = { |
| 2038 | .type = USB_BULK, |
| 2039 | .count = 8, |
| 2040 | .endpoint = 0x82, |
| 2041 | .u = { |
| 2042 | .bulk = { |
| 2043 | .buffersize = 4096, |
| 2044 | } |
| 2045 | } |
| 2046 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2047 | }}, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2048 | } |
| 2049 | }, |
| 2050 | .num_device_descs = 1, |
| 2051 | .devices = { |
| 2052 | { "DVBWorld DVB-C 3101 USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2053 | {&dw2102_table[CYPRESS_DW3101], NULL}, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2054 | {NULL}, |
| 2055 | }, |
| 2056 | } |
| 2057 | }; |
| 2058 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 2059 | static struct dvb_usb_device_properties s6x0_properties = { |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2060 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 2061 | .usb_ctrl = DEVICE_SPECIFIC, |
Olli Salonen | 2c4ffe2 | 2015-03-16 14:14:04 -0300 | [diff] [blame] | 2062 | .size_of_priv = sizeof(struct dw2102_state), |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 2063 | .firmware = S630_FIRMWARE, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2064 | .no_reconnect = 1, |
| 2065 | |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 2066 | .i2c_algo = &s6x0_i2c_algo, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2067 | .rc.core = { |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 2068 | .rc_interval = 150, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2069 | .rc_codes = RC_MAP_TEVII_NEC, |
| 2070 | .module_name = "dw2102", |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 2071 | .allowed_protos = RC_PROTO_BIT_NEC, |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 2072 | .rc_query = dw2102_rc_query, |
| 2073 | }, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2074 | |
| 2075 | .generic_bulk_ctrl_endpoint = 0x81, |
| 2076 | .num_adapters = 1, |
| 2077 | .download_firmware = dw2102_load_firmware, |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 2078 | .read_mac_address = s6x0_read_mac_address, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2079 | .adapter = { |
| 2080 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2081 | .num_frontends = 1, |
| 2082 | .fe = {{ |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2083 | .frontend_attach = zl100313_frontend_attach, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2084 | .stream = { |
| 2085 | .type = USB_BULK, |
| 2086 | .count = 8, |
| 2087 | .endpoint = 0x82, |
| 2088 | .u = { |
| 2089 | .bulk = { |
| 2090 | .buffersize = 4096, |
| 2091 | } |
| 2092 | } |
| 2093 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2094 | }}, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2095 | } |
| 2096 | }, |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2097 | .num_device_descs = 1, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2098 | .devices = { |
| 2099 | {"TeVii S630 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2100 | {&dw2102_table[TEVII_S630], NULL}, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2101 | {NULL}, |
| 2102 | }, |
| 2103 | } |
| 2104 | }; |
| 2105 | |
Hans Verkuil | 1ad5d06 | 2014-08-20 16:45:27 -0300 | [diff] [blame] | 2106 | static struct dvb_usb_device_properties *p1100; |
Bhumika Goyal | 651ac129 | 2017-08-03 06:00:32 -0400 | [diff] [blame] | 2107 | static const struct dvb_usb_device_description d1100 = { |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2108 | "Prof 1100 USB ", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2109 | {&dw2102_table[PROF_1100], NULL}, |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2110 | {NULL}, |
| 2111 | }; |
| 2112 | |
Hans Verkuil | 1ad5d06 | 2014-08-20 16:45:27 -0300 | [diff] [blame] | 2113 | static struct dvb_usb_device_properties *s660; |
Bhumika Goyal | 651ac129 | 2017-08-03 06:00:32 -0400 | [diff] [blame] | 2114 | static const struct dvb_usb_device_description d660 = { |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2115 | "TeVii S660 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2116 | {&dw2102_table[TEVII_S660], NULL}, |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2117 | {NULL}, |
| 2118 | }; |
| 2119 | |
Bhumika Goyal | 651ac129 | 2017-08-03 06:00:32 -0400 | [diff] [blame] | 2120 | static const struct dvb_usb_device_description d480_1 = { |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2121 | "TeVii S480.1 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2122 | {&dw2102_table[TEVII_S480_1], NULL}, |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2123 | {NULL}, |
| 2124 | }; |
| 2125 | |
Bhumika Goyal | 651ac129 | 2017-08-03 06:00:32 -0400 | [diff] [blame] | 2126 | static const struct dvb_usb_device_description d480_2 = { |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2127 | "TeVii S480.2 USB", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2128 | {&dw2102_table[TEVII_S480_2], NULL}, |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2129 | {NULL}, |
| 2130 | }; |
| 2131 | |
Hans Verkuil | 1ad5d06 | 2014-08-20 16:45:27 -0300 | [diff] [blame] | 2132 | static struct dvb_usb_device_properties *p7500; |
Bhumika Goyal | 651ac129 | 2017-08-03 06:00:32 -0400 | [diff] [blame] | 2133 | static const struct dvb_usb_device_description d7500 = { |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2134 | "Prof 7500 USB DVB-S2", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2135 | {&dw2102_table[PROF_7500], NULL}, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2136 | {NULL}, |
| 2137 | }; |
| 2138 | |
Hans Verkuil | 1ad5d06 | 2014-08-20 16:45:27 -0300 | [diff] [blame] | 2139 | static struct dvb_usb_device_properties *s421; |
Bhumika Goyal | 651ac129 | 2017-08-03 06:00:32 -0400 | [diff] [blame] | 2140 | static const struct dvb_usb_device_description d421 = { |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 2141 | "TeVii S421 PCI", |
| 2142 | {&dw2102_table[TEVII_S421], NULL}, |
| 2143 | {NULL}, |
| 2144 | }; |
| 2145 | |
Bhumika Goyal | 651ac129 | 2017-08-03 06:00:32 -0400 | [diff] [blame] | 2146 | static const struct dvb_usb_device_description d632 = { |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 2147 | "TeVii S632 USB", |
| 2148 | {&dw2102_table[TEVII_S632], NULL}, |
| 2149 | {NULL}, |
| 2150 | }; |
| 2151 | |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2152 | static struct dvb_usb_device_properties su3000_properties = { |
| 2153 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 2154 | .usb_ctrl = DEVICE_SPECIFIC, |
Olli Salonen | 2c4ffe2 | 2015-03-16 14:14:04 -0300 | [diff] [blame] | 2155 | .size_of_priv = sizeof(struct dw2102_state), |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2156 | .power_ctrl = su3000_power_ctrl, |
| 2157 | .num_adapters = 1, |
| 2158 | .identify_state = su3000_identify_state, |
| 2159 | .i2c_algo = &su3000_i2c_algo, |
| 2160 | |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2161 | .rc.core = { |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2162 | .rc_interval = 150, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2163 | .rc_codes = RC_MAP_SU3000, |
| 2164 | .module_name = "dw2102", |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 2165 | .allowed_protos = RC_PROTO_BIT_RC5, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2166 | .rc_query = su3000_rc_query, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2167 | }, |
| 2168 | |
| 2169 | .read_mac_address = su3000_read_mac_address, |
| 2170 | |
| 2171 | .generic_bulk_ctrl_endpoint = 0x01, |
| 2172 | |
| 2173 | .adapter = { |
| 2174 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2175 | .num_frontends = 1, |
| 2176 | .fe = {{ |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2177 | .streaming_ctrl = su3000_streaming_ctrl, |
| 2178 | .frontend_attach = su3000_frontend_attach, |
| 2179 | .stream = { |
| 2180 | .type = USB_BULK, |
| 2181 | .count = 8, |
| 2182 | .endpoint = 0x82, |
| 2183 | .u = { |
| 2184 | .bulk = { |
| 2185 | .buffersize = 4096, |
| 2186 | } |
| 2187 | } |
| 2188 | } |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2189 | }}, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2190 | } |
| 2191 | }, |
Olli Salonen | 49438d9 | 2016-06-13 11:04:50 -0300 | [diff] [blame] | 2192 | .num_device_descs = 6, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2193 | .devices = { |
| 2194 | { "SU3000HD DVB-S USB2.0", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2195 | { &dw2102_table[GENIATECH_SU3000], NULL }, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2196 | { NULL }, |
| 2197 | }, |
Igor M. Liplianin | 2adc591 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2198 | { "Terratec Cinergy S2 USB HD", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2199 | { &dw2102_table[TERRATEC_CINERGY_S2], NULL }, |
Igor M. Liplianin | 2adc591 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2200 | { NULL }, |
| 2201 | }, |
Igor M. Liplianin | 5265ea5 | 2011-02-27 16:17:25 -0300 | [diff] [blame] | 2202 | { "X3M TV SPC1400HD PCI", |
Jonathan Nieder | 27351b1 | 2011-12-23 19:00:45 -0300 | [diff] [blame] | 2203 | { &dw2102_table[X3M_SPC1400HD], NULL }, |
Igor M. Liplianin | 5265ea5 | 2011-02-27 16:17:25 -0300 | [diff] [blame] | 2204 | { NULL }, |
| 2205 | }, |
Igor M. Liplianin | 44122dd | 2013-02-21 08:11:41 -0300 | [diff] [blame] | 2206 | { "Terratec Cinergy S2 USB HD Rev.2", |
| 2207 | { &dw2102_table[TERRATEC_CINERGY_S2_R2], NULL }, |
| 2208 | { NULL }, |
| 2209 | }, |
Olli Salonen | 49438d9 | 2016-06-13 11:04:50 -0300 | [diff] [blame] | 2210 | { "Terratec Cinergy S2 USB HD Rev.3", |
| 2211 | { &dw2102_table[TERRATEC_CINERGY_S2_R3], NULL }, |
| 2212 | { NULL }, |
| 2213 | }, |
Andrey Pavlenko | f08e9f0 | 2013-03-07 09:36:22 -0300 | [diff] [blame] | 2214 | { "GOTVIEW Satellite HD", |
| 2215 | { &dw2102_table[GOTVIEW_SAT_HD], NULL }, |
| 2216 | { NULL }, |
| 2217 | }, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2218 | } |
| 2219 | }; |
| 2220 | |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 2221 | static struct dvb_usb_device_properties t220_properties = { |
| 2222 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 2223 | .usb_ctrl = DEVICE_SPECIFIC, |
Olli Salonen | 2c4ffe2 | 2015-03-16 14:14:04 -0300 | [diff] [blame] | 2224 | .size_of_priv = sizeof(struct dw2102_state), |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 2225 | .power_ctrl = su3000_power_ctrl, |
| 2226 | .num_adapters = 1, |
| 2227 | .identify_state = su3000_identify_state, |
| 2228 | .i2c_algo = &su3000_i2c_algo, |
| 2229 | |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2230 | .rc.core = { |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 2231 | .rc_interval = 150, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2232 | .rc_codes = RC_MAP_SU3000, |
| 2233 | .module_name = "dw2102", |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 2234 | .allowed_protos = RC_PROTO_BIT_RC5, |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2235 | .rc_query = su3000_rc_query, |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 2236 | }, |
| 2237 | |
| 2238 | .read_mac_address = su3000_read_mac_address, |
| 2239 | |
| 2240 | .generic_bulk_ctrl_endpoint = 0x01, |
| 2241 | |
| 2242 | .adapter = { |
| 2243 | { |
| 2244 | .num_frontends = 1, |
| 2245 | .fe = { { |
| 2246 | .streaming_ctrl = su3000_streaming_ctrl, |
| 2247 | .frontend_attach = t220_frontend_attach, |
| 2248 | .stream = { |
| 2249 | .type = USB_BULK, |
| 2250 | .count = 8, |
| 2251 | .endpoint = 0x82, |
| 2252 | .u = { |
| 2253 | .bulk = { |
| 2254 | .buffersize = 4096, |
| 2255 | } |
| 2256 | } |
| 2257 | } |
| 2258 | } }, |
| 2259 | } |
| 2260 | }, |
| 2261 | .num_device_descs = 1, |
| 2262 | .devices = { |
| 2263 | { "Geniatech T220 DVB-T/T2 USB2.0", |
| 2264 | { &dw2102_table[GENIATECH_T220], NULL }, |
| 2265 | { NULL }, |
| 2266 | }, |
| 2267 | } |
| 2268 | }; |
| 2269 | |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 2270 | static struct dvb_usb_device_properties tt_s2_4600_properties = { |
| 2271 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 2272 | .usb_ctrl = DEVICE_SPECIFIC, |
| 2273 | .size_of_priv = sizeof(struct dw2102_state), |
| 2274 | .power_ctrl = su3000_power_ctrl, |
| 2275 | .num_adapters = 1, |
| 2276 | .identify_state = su3000_identify_state, |
| 2277 | .i2c_algo = &su3000_i2c_algo, |
| 2278 | |
| 2279 | .rc.core = { |
| 2280 | .rc_interval = 250, |
| 2281 | .rc_codes = RC_MAP_TT_1500, |
| 2282 | .module_name = "dw2102", |
Sean Young | 6d741bf | 2017-08-07 16:20:58 -0400 | [diff] [blame] | 2283 | .allowed_protos = RC_PROTO_BIT_RC5, |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 2284 | .rc_query = su3000_rc_query, |
| 2285 | }, |
| 2286 | |
| 2287 | .read_mac_address = su3000_read_mac_address, |
| 2288 | |
| 2289 | .generic_bulk_ctrl_endpoint = 0x01, |
| 2290 | |
| 2291 | .adapter = { |
| 2292 | { |
| 2293 | .num_frontends = 1, |
| 2294 | .fe = {{ |
| 2295 | .streaming_ctrl = su3000_streaming_ctrl, |
| 2296 | .frontend_attach = tt_s2_4600_frontend_attach, |
| 2297 | .stream = { |
| 2298 | .type = USB_BULK, |
| 2299 | .count = 8, |
| 2300 | .endpoint = 0x82, |
| 2301 | .u = { |
| 2302 | .bulk = { |
| 2303 | .buffersize = 4096, |
| 2304 | } |
| 2305 | } |
| 2306 | } |
| 2307 | } }, |
| 2308 | } |
| 2309 | }, |
Olli Salonen | 6ede20f | 2016-03-02 08:06:06 -0300 | [diff] [blame] | 2310 | .num_device_descs = 5, |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 2311 | .devices = { |
| 2312 | { "TechnoTrend TT-connect S2-4600", |
| 2313 | { &dw2102_table[TECHNOTREND_S2_4600], NULL }, |
| 2314 | { NULL }, |
| 2315 | }, |
Olli Salonen | 44767fc | 2015-03-21 17:42:23 -0300 | [diff] [blame] | 2316 | { "TeVii S482 (tuner 1)", |
| 2317 | { &dw2102_table[TEVII_S482_1], NULL }, |
| 2318 | { NULL }, |
| 2319 | }, |
| 2320 | { "TeVii S482 (tuner 2)", |
| 2321 | { &dw2102_table[TEVII_S482_2], NULL }, |
| 2322 | { NULL }, |
| 2323 | }, |
Philipp Zabel | 93b6642 | 2016-01-04 17:32:51 -0200 | [diff] [blame] | 2324 | { "Terratec Cinergy S2 USB BOX", |
| 2325 | { &dw2102_table[TERRATEC_CINERGY_S2_BOX], NULL }, |
| 2326 | { NULL }, |
| 2327 | }, |
Olli Salonen | 6ede20f | 2016-03-02 08:06:06 -0300 | [diff] [blame] | 2328 | { "TeVii S662", |
| 2329 | { &dw2102_table[TEVII_S662], NULL }, |
| 2330 | { NULL }, |
| 2331 | }, |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 2332 | } |
| 2333 | }; |
| 2334 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 2335 | static int dw2102_probe(struct usb_interface *intf, |
| 2336 | const struct usb_device_id *id) |
| 2337 | { |
Anton Vasilyev | be90cc8 | 2017-08-10 11:27:44 -0400 | [diff] [blame] | 2338 | int retval = -ENOMEM; |
Thomas Meyer | 68dd9dd | 2011-11-17 18:43:40 -0300 | [diff] [blame] | 2339 | p1100 = kmemdup(&s6x0_properties, |
| 2340 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2341 | if (!p1100) |
Anton Vasilyev | be90cc8 | 2017-08-10 11:27:44 -0400 | [diff] [blame] | 2342 | goto err0; |
| 2343 | |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2344 | /* copy default structure */ |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2345 | /* fill only different fields */ |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 2346 | p1100->firmware = P1100_FIRMWARE; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2347 | p1100->devices[0] = d1100; |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2348 | p1100->rc.core.rc_query = prof_rc_query; |
| 2349 | p1100->rc.core.rc_codes = RC_MAP_TBS_NEC; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2350 | p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2351 | |
Thomas Meyer | 68dd9dd | 2011-11-17 18:43:40 -0300 | [diff] [blame] | 2352 | s660 = kmemdup(&s6x0_properties, |
| 2353 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Anton Vasilyev | be90cc8 | 2017-08-10 11:27:44 -0400 | [diff] [blame] | 2354 | if (!s660) |
| 2355 | goto err1; |
| 2356 | |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 2357 | s660->firmware = S660_FIRMWARE; |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2358 | s660->num_device_descs = 3; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2359 | s660->devices[0] = d660; |
Igor M. Liplianin | e8f5055 | 2011-02-25 18:41:23 -0300 | [diff] [blame] | 2360 | s660->devices[1] = d480_1; |
| 2361 | s660->devices[2] = d480_2; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2362 | s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach; |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2363 | |
Thomas Meyer | 68dd9dd | 2011-11-17 18:43:40 -0300 | [diff] [blame] | 2364 | p7500 = kmemdup(&s6x0_properties, |
| 2365 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Anton Vasilyev | be90cc8 | 2017-08-10 11:27:44 -0400 | [diff] [blame] | 2366 | if (!p7500) |
| 2367 | goto err2; |
| 2368 | |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 2369 | p7500->firmware = P7500_FIRMWARE; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2370 | p7500->devices[0] = d7500; |
Evgeny Plehov | a49de26 | 2013-11-15 16:43:33 -0300 | [diff] [blame] | 2371 | p7500->rc.core.rc_query = prof_rc_query; |
| 2372 | p7500->rc.core.rc_codes = RC_MAP_TBS_NEC; |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 2373 | p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach; |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2374 | |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 2375 | |
| 2376 | s421 = kmemdup(&su3000_properties, |
| 2377 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); |
Anton Vasilyev | be90cc8 | 2017-08-10 11:27:44 -0400 | [diff] [blame] | 2378 | if (!s421) |
| 2379 | goto err3; |
| 2380 | |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 2381 | s421->num_device_descs = 2; |
| 2382 | s421->devices[0] = d421; |
| 2383 | s421->devices[1] = d632; |
| 2384 | s421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach; |
| 2385 | |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 2386 | if (0 == dvb_usb_device_init(intf, &dw2102_properties, |
| 2387 | THIS_MODULE, NULL, adapter_nr) || |
| 2388 | 0 == dvb_usb_device_init(intf, &dw2104_properties, |
Igor M. Liplianin | 1dac77c | 2009-06-14 20:51:45 -0300 | [diff] [blame] | 2389 | THIS_MODULE, NULL, adapter_nr) || |
| 2390 | 0 == dvb_usb_device_init(intf, &dw3101_properties, |
Igor M. Liplianin | d0a1dda | 2009-06-20 09:54:18 -0300 | [diff] [blame] | 2391 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 2392 | 0 == dvb_usb_device_init(intf, &s6x0_properties, |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2393 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | 195288d | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2394 | 0 == dvb_usb_device_init(intf, p1100, |
| 2395 | THIS_MODULE, NULL, adapter_nr) || |
| 2396 | 0 == dvb_usb_device_init(intf, s660, |
| 2397 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | cd79d33 | 2009-12-14 20:24:56 -0300 | [diff] [blame] | 2398 | 0 == dvb_usb_device_init(intf, p7500, |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2399 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | 955d00a | 2012-05-08 03:53:17 -0300 | [diff] [blame] | 2400 | 0 == dvb_usb_device_init(intf, s421, |
| 2401 | THIS_MODULE, NULL, adapter_nr) || |
Igor M. Liplianin | d2ffc44 | 2011-02-25 18:41:22 -0300 | [diff] [blame] | 2402 | 0 == dvb_usb_device_init(intf, &su3000_properties, |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 2403 | THIS_MODULE, NULL, adapter_nr) || |
| 2404 | 0 == dvb_usb_device_init(intf, &t220_properties, |
Olli Salonen | 27254c3 | 2015-03-16 14:22:18 -0300 | [diff] [blame] | 2405 | THIS_MODULE, NULL, adapter_nr) || |
| 2406 | 0 == dvb_usb_device_init(intf, &tt_s2_4600_properties, |
Evgeny Plehov | 51d882e | 2013-11-13 20:53:59 -0300 | [diff] [blame] | 2407 | THIS_MODULE, NULL, adapter_nr)) |
Igor M. Liplianin | fe03d5e | 2008-09-08 17:16:40 -0300 | [diff] [blame] | 2408 | return 0; |
Igor M. Liplianin | 141cc35 | 2009-11-27 14:37:35 -0300 | [diff] [blame] | 2409 | |
Anton Vasilyev | be90cc8 | 2017-08-10 11:27:44 -0400 | [diff] [blame] | 2410 | retval = -ENODEV; |
| 2411 | kfree(s421); |
| 2412 | err3: |
| 2413 | kfree(p7500); |
| 2414 | err2: |
| 2415 | kfree(s660); |
| 2416 | err1: |
| 2417 | kfree(p1100); |
| 2418 | err0: |
| 2419 | return retval; |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 2420 | } |
| 2421 | |
Olli Salonen | 70769b2 | 2015-03-16 14:14:05 -0300 | [diff] [blame] | 2422 | static void dw2102_disconnect(struct usb_interface *intf) |
| 2423 | { |
| 2424 | struct dvb_usb_device *d = usb_get_intfdata(intf); |
| 2425 | struct dw2102_state *st = (struct dw2102_state *)d->priv; |
| 2426 | struct i2c_client *client; |
| 2427 | |
| 2428 | /* remove I2C client for tuner */ |
| 2429 | client = st->i2c_client_tuner; |
| 2430 | if (client) { |
| 2431 | module_put(client->dev.driver->owner); |
| 2432 | i2c_unregister_device(client); |
| 2433 | } |
| 2434 | |
Olli Salonen | f3c6abc | 2016-02-16 15:53:45 -0200 | [diff] [blame] | 2435 | /* remove I2C client for demodulator */ |
| 2436 | client = st->i2c_client_demod; |
| 2437 | if (client) { |
| 2438 | module_put(client->dev.driver->owner); |
| 2439 | i2c_unregister_device(client); |
| 2440 | } |
| 2441 | |
Olli Salonen | 70769b2 | 2015-03-16 14:14:05 -0300 | [diff] [blame] | 2442 | dvb_usb_device_exit(intf); |
| 2443 | } |
| 2444 | |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 2445 | static struct usb_driver dw2102_driver = { |
| 2446 | .name = "dw2102", |
| 2447 | .probe = dw2102_probe, |
Olli Salonen | 70769b2 | 2015-03-16 14:14:05 -0300 | [diff] [blame] | 2448 | .disconnect = dw2102_disconnect, |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 2449 | .id_table = dw2102_table, |
| 2450 | }; |
| 2451 | |
Greg Kroah-Hartman | ecb3b2b | 2011-11-18 09:46:12 -0800 | [diff] [blame] | 2452 | module_usb_driver(dw2102_driver); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 2453 | |
| 2454 | MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); |
Mauro Carvalho Chehab | f319ed9 | 2016-10-18 17:44:15 -0200 | [diff] [blame] | 2455 | MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101 USB2.0, TeVii S421, S480, S482, S600, S630, S632, S650, TeVii S660, S662, Prof 1100, 7500 USB2.0, Geniatech SU3000, T220, TechnoTrend S2-4600, Terratec Cinergy S2 devices"); |
Igor M Liplianin | 7fd4828 | 2008-07-20 08:05:50 -0300 | [diff] [blame] | 2456 | MODULE_VERSION("0.1"); |
| 2457 | MODULE_LICENSE("GPL"); |
Rémi Cardona | 6823627 | 2012-09-28 08:59:32 -0300 | [diff] [blame] | 2458 | MODULE_FIRMWARE(DW2101_FIRMWARE); |
| 2459 | MODULE_FIRMWARE(DW2102_FIRMWARE); |
| 2460 | MODULE_FIRMWARE(DW2104_FIRMWARE); |
| 2461 | MODULE_FIRMWARE(DW3101_FIRMWARE); |
| 2462 | MODULE_FIRMWARE(S630_FIRMWARE); |
| 2463 | MODULE_FIRMWARE(S660_FIRMWARE); |
| 2464 | MODULE_FIRMWARE(P1100_FIRMWARE); |
| 2465 | MODULE_FIRMWARE(P7500_FIRMWARE); |