1a10e763bSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 2786baecfSMauro Carvalho Chehab /* DVB USB framework compliant Linux driver for the 3786baecfSMauro Carvalho Chehab * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, 46ede20f9SOlli Salonen * TeVii S421, S480, S482, S600, S630, S632, S650, S660, S662, 5786baecfSMauro Carvalho Chehab * Prof 1100, 7500, 627254c36SOlli Salonen * Geniatech SU3000, T220, 76ede20f9SOlli Salonen * TechnoTrend S2-4600, 86ede20f9SOlli Salonen * Terratec Cinergy S2 cards 9955d00acSIgor M. Liplianin * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by) 10786baecfSMauro Carvalho Chehab * 11577a7ad3SMauro Carvalho Chehab * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information 12786baecfSMauro Carvalho Chehab */ 13fada1935SMauro Carvalho Chehab #include <media/dvb-usb-ids.h> 14786baecfSMauro Carvalho Chehab #include "dw2102.h" 15786baecfSMauro Carvalho Chehab #include "si21xx.h" 16786baecfSMauro Carvalho Chehab #include "stv0299.h" 17786baecfSMauro Carvalho Chehab #include "z0194a.h" 18786baecfSMauro Carvalho Chehab #include "stv0288.h" 19786baecfSMauro Carvalho Chehab #include "stb6000.h" 20786baecfSMauro Carvalho Chehab #include "eds1547.h" 21786baecfSMauro Carvalho Chehab #include "cx24116.h" 22786baecfSMauro Carvalho Chehab #include "tda1002x.h" 23786baecfSMauro Carvalho Chehab #include "mt312.h" 24786baecfSMauro Carvalho Chehab #include "zl10039.h" 2573f0af44SKonstantin Dimitrov #include "ts2020.h" 26786baecfSMauro Carvalho Chehab #include "ds3000.h" 27786baecfSMauro Carvalho Chehab #include "stv0900.h" 28786baecfSMauro Carvalho Chehab #include "stv6110.h" 29786baecfSMauro Carvalho Chehab #include "stb6100.h" 30786baecfSMauro Carvalho Chehab #include "stb6100_proc.h" 31955d00acSIgor M. Liplianin #include "m88rs2000.h" 3251d882edSEvgeny Plehov #include "tda18271.h" 3351d882edSEvgeny Plehov #include "cxd2820r.h" 3427254c36SOlli Salonen #include "m88ds3103.h" 35786baecfSMauro Carvalho Chehab 360065a79aSMauro Carvalho Chehab /* Max transfer size done by I2C transfer functions */ 370065a79aSMauro Carvalho Chehab #define MAX_XFER_SIZE 64 380065a79aSMauro Carvalho Chehab 39f08e9f0dSAndrey Pavlenko 40786baecfSMauro Carvalho Chehab #define DW210X_READ_MSG 0 41786baecfSMauro Carvalho Chehab #define DW210X_WRITE_MSG 1 42786baecfSMauro Carvalho Chehab 43786baecfSMauro Carvalho Chehab #define REG_1F_SYMBOLRATE_BYTE0 0x1f 44786baecfSMauro Carvalho Chehab #define REG_20_SYMBOLRATE_BYTE1 0x20 45786baecfSMauro Carvalho Chehab #define REG_21_SYMBOLRATE_BYTE2 0x21 46786baecfSMauro Carvalho Chehab /* on my own*/ 47786baecfSMauro Carvalho Chehab #define DW2102_VOLTAGE_CTRL (0x1800) 48786baecfSMauro Carvalho Chehab #define SU3000_STREAM_CTRL (0x1900) 49786baecfSMauro Carvalho Chehab #define DW2102_RC_QUERY (0x1a00) 50786baecfSMauro Carvalho Chehab #define DW2102_LED_CTRL (0x1b00) 51786baecfSMauro Carvalho Chehab 526823627bSRémi Cardona #define DW2101_FIRMWARE "dvb-usb-dw2101.fw" 536823627bSRémi Cardona #define DW2102_FIRMWARE "dvb-usb-dw2102.fw" 546823627bSRémi Cardona #define DW2104_FIRMWARE "dvb-usb-dw2104.fw" 556823627bSRémi Cardona #define DW3101_FIRMWARE "dvb-usb-dw3101.fw" 566823627bSRémi Cardona #define S630_FIRMWARE "dvb-usb-s630.fw" 576823627bSRémi Cardona #define S660_FIRMWARE "dvb-usb-s660.fw" 586823627bSRémi Cardona #define P1100_FIRMWARE "dvb-usb-p1100.fw" 596823627bSRémi Cardona #define P7500_FIRMWARE "dvb-usb-p7500.fw" 606823627bSRémi Cardona 61fe63a1a6SMauro Carvalho Chehab #define err_str "did not find the firmware file '%s'. You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware" 62786baecfSMauro Carvalho Chehab 632c4ffe27SOlli Salonen struct dw2102_state { 64786baecfSMauro Carvalho Chehab u8 initialized; 65356484caSOlli Salonen u8 last_lock; 66606142afSJonathan McDowell u8 data[MAX_XFER_SIZE + 4]; 67f3c6abcaSOlli Salonen struct i2c_client *i2c_client_demod; 6870769b24SOlli Salonen struct i2c_client *i2c_client_tuner; 69356484caSOlli Salonen 70356484caSOlli Salonen /* fe hook functions*/ 710df289a2SMauro Carvalho Chehab int (*old_set_voltage)(struct dvb_frontend *f, enum fe_sec_voltage v); 72356484caSOlli Salonen int (*fe_read_status)(struct dvb_frontend *fe, 730df289a2SMauro Carvalho Chehab enum fe_status *status); 74786baecfSMauro Carvalho Chehab }; 75786baecfSMauro Carvalho Chehab 76786baecfSMauro Carvalho Chehab /* debug */ 77786baecfSMauro Carvalho Chehab static int dvb_usb_dw2102_debug; 78786baecfSMauro Carvalho Chehab module_param_named(debug, dvb_usb_dw2102_debug, int, 0644); 79786baecfSMauro Carvalho Chehab MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))." 80786baecfSMauro Carvalho Chehab DVB_USB_DEBUG_STATUS); 81786baecfSMauro Carvalho Chehab 82786baecfSMauro Carvalho Chehab /* demod probe */ 83786baecfSMauro Carvalho Chehab static int demod_probe = 1; 84786baecfSMauro Carvalho Chehab module_param_named(demod, demod_probe, int, 0644); 85f319ed91SMauro Carvalho Chehab MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 4=stv0903+stb6100(or-able))."); 86786baecfSMauro Carvalho Chehab 87786baecfSMauro Carvalho Chehab DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 88786baecfSMauro Carvalho Chehab 89786baecfSMauro Carvalho Chehab static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value, 90786baecfSMauro Carvalho Chehab u16 index, u8 * data, u16 len, int flags) 91786baecfSMauro Carvalho Chehab { 92786baecfSMauro Carvalho Chehab int ret; 93786baecfSMauro Carvalho Chehab u8 *u8buf; 94786baecfSMauro Carvalho Chehab unsigned int pipe = (flags == DW210X_READ_MSG) ? 95786baecfSMauro Carvalho Chehab usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0); 96786baecfSMauro Carvalho Chehab u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT; 97786baecfSMauro Carvalho Chehab 98786baecfSMauro Carvalho Chehab u8buf = kmalloc(len, GFP_KERNEL); 99786baecfSMauro Carvalho Chehab if (!u8buf) 100786baecfSMauro Carvalho Chehab return -ENOMEM; 101786baecfSMauro Carvalho Chehab 102786baecfSMauro Carvalho Chehab 103786baecfSMauro Carvalho Chehab if (flags == DW210X_WRITE_MSG) 104786baecfSMauro Carvalho Chehab memcpy(u8buf, data, len); 105786baecfSMauro Carvalho Chehab ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, 106786baecfSMauro Carvalho Chehab value, index , u8buf, len, 2000); 107786baecfSMauro Carvalho Chehab 108786baecfSMauro Carvalho Chehab if (flags == DW210X_READ_MSG) 109786baecfSMauro Carvalho Chehab memcpy(data, u8buf, len); 110786baecfSMauro Carvalho Chehab 111786baecfSMauro Carvalho Chehab kfree(u8buf); 112786baecfSMauro Carvalho Chehab return ret; 113786baecfSMauro Carvalho Chehab } 114786baecfSMauro Carvalho Chehab 115786baecfSMauro Carvalho Chehab /* I2C */ 116786baecfSMauro Carvalho Chehab static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 117786baecfSMauro Carvalho Chehab int num) 118786baecfSMauro Carvalho Chehab { 119786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 120786baecfSMauro Carvalho Chehab int i = 0; 121786baecfSMauro Carvalho Chehab u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0}; 122786baecfSMauro Carvalho Chehab u16 value; 123786baecfSMauro Carvalho Chehab 124786baecfSMauro Carvalho Chehab if (!d) 125786baecfSMauro Carvalho Chehab return -ENODEV; 126786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 127786baecfSMauro Carvalho Chehab return -EAGAIN; 128786baecfSMauro Carvalho Chehab 129786baecfSMauro Carvalho Chehab switch (num) { 130786baecfSMauro Carvalho Chehab case 2: 1315ae544d9SZhang Shurong if (msg[0].len < 1) { 1325ae544d9SZhang Shurong num = -EOPNOTSUPP; 1335ae544d9SZhang Shurong break; 1345ae544d9SZhang Shurong } 135786baecfSMauro Carvalho Chehab /* read stv0299 register */ 136786baecfSMauro Carvalho Chehab value = msg[0].buf[0];/* register */ 137786baecfSMauro Carvalho Chehab for (i = 0; i < msg[1].len; i++) { 138786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb5, value + i, 0, 139786baecfSMauro Carvalho Chehab buf6, 2, DW210X_READ_MSG); 140786baecfSMauro Carvalho Chehab msg[1].buf[i] = buf6[0]; 141786baecfSMauro Carvalho Chehab } 142786baecfSMauro Carvalho Chehab break; 143786baecfSMauro Carvalho Chehab case 1: 144786baecfSMauro Carvalho Chehab switch (msg[0].addr) { 145786baecfSMauro Carvalho Chehab case 0x68: 1465ae544d9SZhang Shurong if (msg[0].len < 2) { 1475ae544d9SZhang Shurong num = -EOPNOTSUPP; 1485ae544d9SZhang Shurong break; 1495ae544d9SZhang Shurong } 150786baecfSMauro Carvalho Chehab /* write to stv0299 register */ 151786baecfSMauro Carvalho Chehab buf6[0] = 0x2a; 152786baecfSMauro Carvalho Chehab buf6[1] = msg[0].buf[0]; 153786baecfSMauro Carvalho Chehab buf6[2] = msg[0].buf[1]; 154786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 155786baecfSMauro Carvalho Chehab buf6, 3, DW210X_WRITE_MSG); 156786baecfSMauro Carvalho Chehab break; 157786baecfSMauro Carvalho Chehab case 0x60: 158786baecfSMauro Carvalho Chehab if (msg[0].flags == 0) { 1595ae544d9SZhang Shurong if (msg[0].len < 4) { 1605ae544d9SZhang Shurong num = -EOPNOTSUPP; 1615ae544d9SZhang Shurong break; 1625ae544d9SZhang Shurong } 163786baecfSMauro Carvalho Chehab /* write to tuner pll */ 164786baecfSMauro Carvalho Chehab buf6[0] = 0x2c; 165786baecfSMauro Carvalho Chehab buf6[1] = 5; 166786baecfSMauro Carvalho Chehab buf6[2] = 0xc0; 167786baecfSMauro Carvalho Chehab buf6[3] = msg[0].buf[0]; 168786baecfSMauro Carvalho Chehab buf6[4] = msg[0].buf[1]; 169786baecfSMauro Carvalho Chehab buf6[5] = msg[0].buf[2]; 170786baecfSMauro Carvalho Chehab buf6[6] = msg[0].buf[3]; 171786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 172786baecfSMauro Carvalho Chehab buf6, 7, DW210X_WRITE_MSG); 173786baecfSMauro Carvalho Chehab } else { 1745ae544d9SZhang Shurong if (msg[0].len < 1) { 1755ae544d9SZhang Shurong num = -EOPNOTSUPP; 1765ae544d9SZhang Shurong break; 1775ae544d9SZhang Shurong } 178786baecfSMauro Carvalho Chehab /* read from tuner */ 179786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb5, 0, 0, 180786baecfSMauro Carvalho Chehab buf6, 1, DW210X_READ_MSG); 181786baecfSMauro Carvalho Chehab msg[0].buf[0] = buf6[0]; 182786baecfSMauro Carvalho Chehab } 183786baecfSMauro Carvalho Chehab break; 184786baecfSMauro Carvalho Chehab case (DW2102_RC_QUERY): 1855ae544d9SZhang Shurong if (msg[0].len < 2) { 1865ae544d9SZhang Shurong num = -EOPNOTSUPP; 1875ae544d9SZhang Shurong break; 1885ae544d9SZhang Shurong } 189786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 190786baecfSMauro Carvalho Chehab buf6, 2, DW210X_READ_MSG); 191786baecfSMauro Carvalho Chehab msg[0].buf[0] = buf6[0]; 192786baecfSMauro Carvalho Chehab msg[0].buf[1] = buf6[1]; 193786baecfSMauro Carvalho Chehab break; 194786baecfSMauro Carvalho Chehab case (DW2102_VOLTAGE_CTRL): 1955ae544d9SZhang Shurong if (msg[0].len < 1) { 1965ae544d9SZhang Shurong num = -EOPNOTSUPP; 1975ae544d9SZhang Shurong break; 1985ae544d9SZhang Shurong } 199786baecfSMauro Carvalho Chehab buf6[0] = 0x30; 200786baecfSMauro Carvalho Chehab buf6[1] = msg[0].buf[0]; 201786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 202786baecfSMauro Carvalho Chehab buf6, 2, DW210X_WRITE_MSG); 203786baecfSMauro Carvalho Chehab break; 204786baecfSMauro Carvalho Chehab } 205786baecfSMauro Carvalho Chehab 206786baecfSMauro Carvalho Chehab break; 207786baecfSMauro Carvalho Chehab } 208786baecfSMauro Carvalho Chehab 209786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 210786baecfSMauro Carvalho Chehab return num; 211786baecfSMauro Carvalho Chehab } 212786baecfSMauro Carvalho Chehab 213786baecfSMauro Carvalho Chehab static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap, 214786baecfSMauro Carvalho Chehab struct i2c_msg msg[], int num) 215786baecfSMauro Carvalho Chehab { 216786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 217786baecfSMauro Carvalho Chehab u8 buf6[] = {0, 0, 0, 0, 0, 0, 0}; 218786baecfSMauro Carvalho Chehab 219786baecfSMauro Carvalho Chehab if (!d) 220786baecfSMauro Carvalho Chehab return -ENODEV; 221786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 222786baecfSMauro Carvalho Chehab return -EAGAIN; 223786baecfSMauro Carvalho Chehab 224786baecfSMauro Carvalho Chehab switch (num) { 225786baecfSMauro Carvalho Chehab case 2: 226950e252cSAlyssa Milburn if (msg[0].len != 1) { 227950e252cSAlyssa Milburn warn("i2c rd: len=%d is not 1!\n", 228950e252cSAlyssa Milburn msg[0].len); 229950e252cSAlyssa Milburn num = -EOPNOTSUPP; 230950e252cSAlyssa Milburn break; 231950e252cSAlyssa Milburn } 232950e252cSAlyssa Milburn 233950e252cSAlyssa Milburn if (2 + msg[1].len > sizeof(buf6)) { 234950e252cSAlyssa Milburn warn("i2c rd: len=%d is too big!\n", 235950e252cSAlyssa Milburn msg[1].len); 236950e252cSAlyssa Milburn num = -EOPNOTSUPP; 237950e252cSAlyssa Milburn break; 238950e252cSAlyssa Milburn } 239950e252cSAlyssa Milburn 240786baecfSMauro Carvalho Chehab /* read si2109 register by number */ 241786baecfSMauro Carvalho Chehab buf6[0] = msg[0].addr << 1; 242786baecfSMauro Carvalho Chehab buf6[1] = msg[0].len; 243786baecfSMauro Carvalho Chehab buf6[2] = msg[0].buf[0]; 244786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 245786baecfSMauro Carvalho Chehab buf6, msg[0].len + 2, DW210X_WRITE_MSG); 246786baecfSMauro Carvalho Chehab /* read si2109 register */ 247786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc3, 0xd0, 0, 248786baecfSMauro Carvalho Chehab buf6, msg[1].len + 2, DW210X_READ_MSG); 249786baecfSMauro Carvalho Chehab memcpy(msg[1].buf, buf6 + 2, msg[1].len); 250786baecfSMauro Carvalho Chehab 251786baecfSMauro Carvalho Chehab break; 252786baecfSMauro Carvalho Chehab case 1: 253786baecfSMauro Carvalho Chehab switch (msg[0].addr) { 254786baecfSMauro Carvalho Chehab case 0x68: 255950e252cSAlyssa Milburn if (2 + msg[0].len > sizeof(buf6)) { 256950e252cSAlyssa Milburn warn("i2c wr: len=%d is too big!\n", 257950e252cSAlyssa Milburn msg[0].len); 258950e252cSAlyssa Milburn num = -EOPNOTSUPP; 259950e252cSAlyssa Milburn break; 260950e252cSAlyssa Milburn } 261950e252cSAlyssa Milburn 262786baecfSMauro Carvalho Chehab /* write to si2109 register */ 263786baecfSMauro Carvalho Chehab buf6[0] = msg[0].addr << 1; 264786baecfSMauro Carvalho Chehab buf6[1] = msg[0].len; 265786baecfSMauro Carvalho Chehab memcpy(buf6 + 2, msg[0].buf, msg[0].len); 266786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6, 267786baecfSMauro Carvalho Chehab msg[0].len + 2, DW210X_WRITE_MSG); 268786baecfSMauro Carvalho Chehab break; 269786baecfSMauro Carvalho Chehab case(DW2102_RC_QUERY): 270786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 271786baecfSMauro Carvalho Chehab buf6, 2, DW210X_READ_MSG); 272786baecfSMauro Carvalho Chehab msg[0].buf[0] = buf6[0]; 273786baecfSMauro Carvalho Chehab msg[0].buf[1] = buf6[1]; 274786baecfSMauro Carvalho Chehab break; 275786baecfSMauro Carvalho Chehab case(DW2102_VOLTAGE_CTRL): 276786baecfSMauro Carvalho Chehab buf6[0] = 0x30; 277786baecfSMauro Carvalho Chehab buf6[1] = msg[0].buf[0]; 278786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 279786baecfSMauro Carvalho Chehab buf6, 2, DW210X_WRITE_MSG); 280786baecfSMauro Carvalho Chehab break; 281786baecfSMauro Carvalho Chehab } 282786baecfSMauro Carvalho Chehab break; 283786baecfSMauro Carvalho Chehab } 284786baecfSMauro Carvalho Chehab 285786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 286786baecfSMauro Carvalho Chehab return num; 287786baecfSMauro Carvalho Chehab } 288786baecfSMauro Carvalho Chehab 289786baecfSMauro Carvalho Chehab static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 290786baecfSMauro Carvalho Chehab { 291786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 292324ed533SDan Carpenter int ret; 293786baecfSMauro Carvalho Chehab 294786baecfSMauro Carvalho Chehab if (!d) 295786baecfSMauro Carvalho Chehab return -ENODEV; 296786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 297786baecfSMauro Carvalho Chehab return -EAGAIN; 298786baecfSMauro Carvalho Chehab 299786baecfSMauro Carvalho Chehab switch (num) { 300786baecfSMauro Carvalho Chehab case 2: { 301786baecfSMauro Carvalho Chehab /* read */ 302786baecfSMauro Carvalho Chehab /* first write first register number */ 3030065a79aSMauro Carvalho Chehab u8 ibuf[MAX_XFER_SIZE], obuf[3]; 3040065a79aSMauro Carvalho Chehab 305950e252cSAlyssa Milburn if (2 + msg[0].len != sizeof(obuf)) { 306950e252cSAlyssa Milburn warn("i2c rd: len=%d is not 1!\n", 307950e252cSAlyssa Milburn msg[0].len); 308950e252cSAlyssa Milburn ret = -EOPNOTSUPP; 309950e252cSAlyssa Milburn goto unlock; 310950e252cSAlyssa Milburn } 311950e252cSAlyssa Milburn 3120065a79aSMauro Carvalho Chehab if (2 + msg[1].len > sizeof(ibuf)) { 3130065a79aSMauro Carvalho Chehab warn("i2c rd: len=%d is too big!\n", 3140065a79aSMauro Carvalho Chehab msg[1].len); 315324ed533SDan Carpenter ret = -EOPNOTSUPP; 316324ed533SDan Carpenter goto unlock; 3170065a79aSMauro Carvalho Chehab } 3180065a79aSMauro Carvalho Chehab 319786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 320786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 321786baecfSMauro Carvalho Chehab obuf[2] = msg[0].buf[0]; 322786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 323786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 324786baecfSMauro Carvalho Chehab /* second read registers */ 325786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, 326786baecfSMauro Carvalho Chehab ibuf, msg[1].len + 2, DW210X_READ_MSG); 327786baecfSMauro Carvalho Chehab memcpy(msg[1].buf, ibuf + 2, msg[1].len); 328786baecfSMauro Carvalho Chehab 329786baecfSMauro Carvalho Chehab break; 330786baecfSMauro Carvalho Chehab } 331786baecfSMauro Carvalho Chehab case 1: 332786baecfSMauro Carvalho Chehab switch (msg[0].addr) { 333786baecfSMauro Carvalho Chehab case 0x68: { 334786baecfSMauro Carvalho Chehab /* write to register */ 3350065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 3360065a79aSMauro Carvalho Chehab 3370065a79aSMauro Carvalho Chehab if (2 + msg[0].len > sizeof(obuf)) { 3380065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 3390065a79aSMauro Carvalho Chehab msg[1].len); 340324ed533SDan Carpenter ret = -EOPNOTSUPP; 341324ed533SDan Carpenter goto unlock; 3420065a79aSMauro Carvalho Chehab } 3430065a79aSMauro Carvalho Chehab 344786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 345786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 346786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[0].buf, msg[0].len); 347786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 348786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 349786baecfSMauro Carvalho Chehab break; 350786baecfSMauro Carvalho Chehab } 351786baecfSMauro Carvalho Chehab case 0x61: { 352786baecfSMauro Carvalho Chehab /* write to tuner */ 3530065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 3540065a79aSMauro Carvalho Chehab 3550065a79aSMauro Carvalho Chehab if (2 + msg[0].len > sizeof(obuf)) { 3560065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 3570065a79aSMauro Carvalho Chehab msg[1].len); 358324ed533SDan Carpenter ret = -EOPNOTSUPP; 359324ed533SDan Carpenter goto unlock; 3600065a79aSMauro Carvalho Chehab } 3610065a79aSMauro Carvalho Chehab 362786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 363786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 364786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[0].buf, msg[0].len); 365786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 366786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 367786baecfSMauro Carvalho Chehab break; 368786baecfSMauro Carvalho Chehab } 369786baecfSMauro Carvalho Chehab case(DW2102_RC_QUERY): { 370786baecfSMauro Carvalho Chehab u8 ibuf[2]; 371786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 372786baecfSMauro Carvalho Chehab ibuf, 2, DW210X_READ_MSG); 373786baecfSMauro Carvalho Chehab memcpy(msg[0].buf, ibuf , 2); 374786baecfSMauro Carvalho Chehab break; 375786baecfSMauro Carvalho Chehab } 376786baecfSMauro Carvalho Chehab case(DW2102_VOLTAGE_CTRL): { 377786baecfSMauro Carvalho Chehab u8 obuf[2]; 378786baecfSMauro Carvalho Chehab obuf[0] = 0x30; 379786baecfSMauro Carvalho Chehab obuf[1] = msg[0].buf[0]; 380786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 381786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 382786baecfSMauro Carvalho Chehab break; 383786baecfSMauro Carvalho Chehab } 384786baecfSMauro Carvalho Chehab } 385786baecfSMauro Carvalho Chehab 386786baecfSMauro Carvalho Chehab break; 387786baecfSMauro Carvalho Chehab } 388324ed533SDan Carpenter ret = num; 389786baecfSMauro Carvalho Chehab 390324ed533SDan Carpenter unlock: 391786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 392324ed533SDan Carpenter return ret; 393786baecfSMauro Carvalho Chehab } 394786baecfSMauro Carvalho Chehab 395786baecfSMauro Carvalho Chehab static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 396786baecfSMauro Carvalho Chehab { 397786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 398324ed533SDan Carpenter int len, i, j, ret; 399786baecfSMauro Carvalho Chehab 400786baecfSMauro Carvalho Chehab if (!d) 401786baecfSMauro Carvalho Chehab return -ENODEV; 402786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 403786baecfSMauro Carvalho Chehab return -EAGAIN; 404786baecfSMauro Carvalho Chehab 405786baecfSMauro Carvalho Chehab for (j = 0; j < num; j++) { 406786baecfSMauro Carvalho Chehab switch (msg[j].addr) { 407786baecfSMauro Carvalho Chehab case(DW2102_RC_QUERY): { 408786baecfSMauro Carvalho Chehab u8 ibuf[2]; 409786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 410786baecfSMauro Carvalho Chehab ibuf, 2, DW210X_READ_MSG); 411786baecfSMauro Carvalho Chehab memcpy(msg[j].buf, ibuf , 2); 412786baecfSMauro Carvalho Chehab break; 413786baecfSMauro Carvalho Chehab } 414786baecfSMauro Carvalho Chehab case(DW2102_VOLTAGE_CTRL): { 415786baecfSMauro Carvalho Chehab u8 obuf[2]; 416786baecfSMauro Carvalho Chehab obuf[0] = 0x30; 417786baecfSMauro Carvalho Chehab obuf[1] = msg[j].buf[0]; 418786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 419786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 420786baecfSMauro Carvalho Chehab break; 421786baecfSMauro Carvalho Chehab } 422786baecfSMauro Carvalho Chehab /*case 0x55: cx24116 423786baecfSMauro Carvalho Chehab case 0x6a: stv0903 424786baecfSMauro Carvalho Chehab case 0x68: ds3000, stv0903 425786baecfSMauro Carvalho Chehab case 0x60: ts2020, stv6110, stb6100 */ 426786baecfSMauro Carvalho Chehab default: { 427786baecfSMauro Carvalho Chehab if (msg[j].flags == I2C_M_RD) { 428786baecfSMauro Carvalho Chehab /* read registers */ 4290065a79aSMauro Carvalho Chehab u8 ibuf[MAX_XFER_SIZE]; 4300065a79aSMauro Carvalho Chehab 4310065a79aSMauro Carvalho Chehab if (2 + msg[j].len > sizeof(ibuf)) { 4320065a79aSMauro Carvalho Chehab warn("i2c rd: len=%d is too big!\n", 4330065a79aSMauro Carvalho Chehab msg[j].len); 434324ed533SDan Carpenter ret = -EOPNOTSUPP; 435324ed533SDan Carpenter goto unlock; 4360065a79aSMauro Carvalho Chehab } 4370065a79aSMauro Carvalho Chehab 438786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc3, 439786baecfSMauro Carvalho Chehab (msg[j].addr << 1) + 1, 0, 440786baecfSMauro Carvalho Chehab ibuf, msg[j].len + 2, 441786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 442786baecfSMauro Carvalho Chehab memcpy(msg[j].buf, ibuf + 2, msg[j].len); 443786baecfSMauro Carvalho Chehab mdelay(10); 444786baecfSMauro Carvalho Chehab } else if (((msg[j].buf[0] == 0xb0) && 445786baecfSMauro Carvalho Chehab (msg[j].addr == 0x68)) || 446786baecfSMauro Carvalho Chehab ((msg[j].buf[0] == 0xf7) && 447786baecfSMauro Carvalho Chehab (msg[j].addr == 0x55))) { 448786baecfSMauro Carvalho Chehab /* write firmware */ 449786baecfSMauro Carvalho Chehab u8 obuf[19]; 450786baecfSMauro Carvalho Chehab obuf[0] = msg[j].addr << 1; 451786baecfSMauro Carvalho Chehab obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len); 452786baecfSMauro Carvalho Chehab obuf[2] = msg[j].buf[0]; 453786baecfSMauro Carvalho Chehab len = msg[j].len - 1; 454786baecfSMauro Carvalho Chehab i = 1; 455786baecfSMauro Carvalho Chehab do { 456786baecfSMauro Carvalho Chehab memcpy(obuf + 3, msg[j].buf + i, 457786baecfSMauro Carvalho Chehab (len > 16 ? 16 : len)); 458786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 459786baecfSMauro Carvalho Chehab obuf, (len > 16 ? 16 : len) + 3, 460786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 461786baecfSMauro Carvalho Chehab i += 16; 462786baecfSMauro Carvalho Chehab len -= 16; 463786baecfSMauro Carvalho Chehab } while (len > 0); 464786baecfSMauro Carvalho Chehab } else { 465786baecfSMauro Carvalho Chehab /* write registers */ 4660065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 4670065a79aSMauro Carvalho Chehab 4680065a79aSMauro Carvalho Chehab if (2 + msg[j].len > sizeof(obuf)) { 4690065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 4700065a79aSMauro Carvalho Chehab msg[j].len); 471324ed533SDan Carpenter ret = -EOPNOTSUPP; 472324ed533SDan Carpenter goto unlock; 4730065a79aSMauro Carvalho Chehab } 4740065a79aSMauro Carvalho Chehab 475786baecfSMauro Carvalho Chehab obuf[0] = msg[j].addr << 1; 476786baecfSMauro Carvalho Chehab obuf[1] = msg[j].len; 477786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[j].buf, msg[j].len); 478786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 479786baecfSMauro Carvalho Chehab obuf, msg[j].len + 2, 480786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 481786baecfSMauro Carvalho Chehab } 482786baecfSMauro Carvalho Chehab break; 483786baecfSMauro Carvalho Chehab } 484786baecfSMauro Carvalho Chehab } 485786baecfSMauro Carvalho Chehab 486786baecfSMauro Carvalho Chehab } 487324ed533SDan Carpenter ret = num; 488786baecfSMauro Carvalho Chehab 489324ed533SDan Carpenter unlock: 490786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 491324ed533SDan Carpenter return ret; 492786baecfSMauro Carvalho Chehab } 493786baecfSMauro Carvalho Chehab 494786baecfSMauro Carvalho Chehab static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 495786baecfSMauro Carvalho Chehab int num) 496786baecfSMauro Carvalho Chehab { 497786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 498324ed533SDan Carpenter int ret; 499786baecfSMauro Carvalho Chehab int i; 500786baecfSMauro Carvalho Chehab 501786baecfSMauro Carvalho Chehab if (!d) 502786baecfSMauro Carvalho Chehab return -ENODEV; 503786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 504786baecfSMauro Carvalho Chehab return -EAGAIN; 505786baecfSMauro Carvalho Chehab 506786baecfSMauro Carvalho Chehab switch (num) { 507786baecfSMauro Carvalho Chehab case 2: { 508786baecfSMauro Carvalho Chehab /* read */ 509786baecfSMauro Carvalho Chehab /* first write first register number */ 5100065a79aSMauro Carvalho Chehab u8 ibuf[MAX_XFER_SIZE], obuf[3]; 5110065a79aSMauro Carvalho Chehab 512950e252cSAlyssa Milburn if (2 + msg[0].len != sizeof(obuf)) { 513950e252cSAlyssa Milburn warn("i2c rd: len=%d is not 1!\n", 514950e252cSAlyssa Milburn msg[0].len); 515950e252cSAlyssa Milburn ret = -EOPNOTSUPP; 516950e252cSAlyssa Milburn goto unlock; 517950e252cSAlyssa Milburn } 5180065a79aSMauro Carvalho Chehab if (2 + msg[1].len > sizeof(ibuf)) { 5190065a79aSMauro Carvalho Chehab warn("i2c rd: len=%d is too big!\n", 5200065a79aSMauro Carvalho Chehab msg[1].len); 521324ed533SDan Carpenter ret = -EOPNOTSUPP; 522324ed533SDan Carpenter goto unlock; 5230065a79aSMauro Carvalho Chehab } 524786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 525786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 526786baecfSMauro Carvalho Chehab obuf[2] = msg[0].buf[0]; 527786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 528786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 529786baecfSMauro Carvalho Chehab /* second read registers */ 530786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, 531786baecfSMauro Carvalho Chehab ibuf, msg[1].len + 2, DW210X_READ_MSG); 532786baecfSMauro Carvalho Chehab memcpy(msg[1].buf, ibuf + 2, msg[1].len); 533786baecfSMauro Carvalho Chehab 534786baecfSMauro Carvalho Chehab break; 535786baecfSMauro Carvalho Chehab } 536786baecfSMauro Carvalho Chehab case 1: 537786baecfSMauro Carvalho Chehab switch (msg[0].addr) { 538786baecfSMauro Carvalho Chehab case 0x60: 539786baecfSMauro Carvalho Chehab case 0x0c: { 540786baecfSMauro Carvalho Chehab /* write to register */ 5410065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 5420065a79aSMauro Carvalho Chehab 5430065a79aSMauro Carvalho Chehab if (2 + msg[0].len > sizeof(obuf)) { 5440065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 5450065a79aSMauro Carvalho Chehab msg[0].len); 546324ed533SDan Carpenter ret = -EOPNOTSUPP; 547324ed533SDan Carpenter goto unlock; 5480065a79aSMauro Carvalho Chehab } 549786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 550786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 551786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[0].buf, msg[0].len); 552786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 553786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 554786baecfSMauro Carvalho Chehab break; 555786baecfSMauro Carvalho Chehab } 556786baecfSMauro Carvalho Chehab case(DW2102_RC_QUERY): { 557786baecfSMauro Carvalho Chehab u8 ibuf[2]; 558786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 559786baecfSMauro Carvalho Chehab ibuf, 2, DW210X_READ_MSG); 560786baecfSMauro Carvalho Chehab memcpy(msg[0].buf, ibuf , 2); 561786baecfSMauro Carvalho Chehab break; 562786baecfSMauro Carvalho Chehab } 563786baecfSMauro Carvalho Chehab } 564786baecfSMauro Carvalho Chehab 565786baecfSMauro Carvalho Chehab break; 566786baecfSMauro Carvalho Chehab } 567786baecfSMauro Carvalho Chehab 568786baecfSMauro Carvalho Chehab for (i = 0; i < num; i++) { 569786baecfSMauro Carvalho Chehab deb_xfer("%02x:%02x: %s ", i, msg[i].addr, 570786baecfSMauro Carvalho Chehab msg[i].flags == 0 ? ">>>" : "<<<"); 571786baecfSMauro Carvalho Chehab debug_dump(msg[i].buf, msg[i].len, deb_xfer); 572786baecfSMauro Carvalho Chehab } 573324ed533SDan Carpenter ret = num; 574786baecfSMauro Carvalho Chehab 575324ed533SDan Carpenter unlock: 576786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 577324ed533SDan Carpenter return ret; 578786baecfSMauro Carvalho Chehab } 579786baecfSMauro Carvalho Chehab 580786baecfSMauro Carvalho Chehab static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 581786baecfSMauro Carvalho Chehab int num) 582786baecfSMauro Carvalho Chehab { 583786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 584786baecfSMauro Carvalho Chehab struct usb_device *udev; 585324ed533SDan Carpenter int len, i, j, ret; 586786baecfSMauro Carvalho Chehab 587786baecfSMauro Carvalho Chehab if (!d) 588786baecfSMauro Carvalho Chehab return -ENODEV; 589786baecfSMauro Carvalho Chehab udev = d->udev; 590786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 591786baecfSMauro Carvalho Chehab return -EAGAIN; 592786baecfSMauro Carvalho Chehab 593786baecfSMauro Carvalho Chehab for (j = 0; j < num; j++) { 594786baecfSMauro Carvalho Chehab switch (msg[j].addr) { 595786baecfSMauro Carvalho Chehab case (DW2102_RC_QUERY): { 596786baecfSMauro Carvalho Chehab u8 ibuf[5]; 597786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 598786baecfSMauro Carvalho Chehab ibuf, 5, DW210X_READ_MSG); 599786baecfSMauro Carvalho Chehab memcpy(msg[j].buf, ibuf + 3, 2); 600786baecfSMauro Carvalho Chehab break; 601786baecfSMauro Carvalho Chehab } 602786baecfSMauro Carvalho Chehab case (DW2102_VOLTAGE_CTRL): { 603786baecfSMauro Carvalho Chehab u8 obuf[2]; 604786baecfSMauro Carvalho Chehab 605786baecfSMauro Carvalho Chehab obuf[0] = 1; 606786baecfSMauro Carvalho Chehab obuf[1] = msg[j].buf[1];/* off-on */ 607786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x8a, 0, 0, 608786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 609786baecfSMauro Carvalho Chehab obuf[0] = 3; 610786baecfSMauro Carvalho Chehab obuf[1] = msg[j].buf[0];/* 13v-18v */ 611786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x8a, 0, 0, 612786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 613786baecfSMauro Carvalho Chehab break; 614786baecfSMauro Carvalho Chehab } 615786baecfSMauro Carvalho Chehab case (DW2102_LED_CTRL): { 616786baecfSMauro Carvalho Chehab u8 obuf[2]; 617786baecfSMauro Carvalho Chehab 618786baecfSMauro Carvalho Chehab obuf[0] = 5; 619786baecfSMauro Carvalho Chehab obuf[1] = msg[j].buf[0]; 620786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x8a, 0, 0, 621786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 622786baecfSMauro Carvalho Chehab break; 623786baecfSMauro Carvalho Chehab } 624786baecfSMauro Carvalho Chehab /*case 0x55: cx24116 625786baecfSMauro Carvalho Chehab case 0x6a: stv0903 626955d00acSIgor M. Liplianin case 0x68: ds3000, stv0903, rs2000 627786baecfSMauro Carvalho Chehab case 0x60: ts2020, stv6110, stb6100 628786baecfSMauro Carvalho Chehab case 0xa0: eeprom */ 629786baecfSMauro Carvalho Chehab default: { 630786baecfSMauro Carvalho Chehab if (msg[j].flags == I2C_M_RD) { 631786baecfSMauro Carvalho Chehab /* read registers */ 6320065a79aSMauro Carvalho Chehab u8 ibuf[MAX_XFER_SIZE]; 6330065a79aSMauro Carvalho Chehab 6340065a79aSMauro Carvalho Chehab if (msg[j].len > sizeof(ibuf)) { 6350065a79aSMauro Carvalho Chehab warn("i2c rd: len=%d is too big!\n", 6360065a79aSMauro Carvalho Chehab msg[j].len); 637324ed533SDan Carpenter ret = -EOPNOTSUPP; 638324ed533SDan Carpenter goto unlock; 6390065a79aSMauro Carvalho Chehab } 6400065a79aSMauro Carvalho Chehab 641786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x91, 0, 0, 642786baecfSMauro Carvalho Chehab ibuf, msg[j].len, 643786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 644786baecfSMauro Carvalho Chehab memcpy(msg[j].buf, ibuf, msg[j].len); 645786baecfSMauro Carvalho Chehab break; 646786baecfSMauro Carvalho Chehab } else if ((msg[j].buf[0] == 0xb0) && 647786baecfSMauro Carvalho Chehab (msg[j].addr == 0x68)) { 648786baecfSMauro Carvalho Chehab /* write firmware */ 649786baecfSMauro Carvalho Chehab u8 obuf[19]; 650786baecfSMauro Carvalho Chehab obuf[0] = (msg[j].len > 16 ? 651786baecfSMauro Carvalho Chehab 18 : msg[j].len + 1); 652786baecfSMauro Carvalho Chehab obuf[1] = msg[j].addr << 1; 653786baecfSMauro Carvalho Chehab obuf[2] = msg[j].buf[0]; 654786baecfSMauro Carvalho Chehab len = msg[j].len - 1; 655786baecfSMauro Carvalho Chehab i = 1; 656786baecfSMauro Carvalho Chehab do { 657786baecfSMauro Carvalho Chehab memcpy(obuf + 3, msg[j].buf + i, 658786baecfSMauro Carvalho Chehab (len > 16 ? 16 : len)); 659786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x80, 0, 0, 660786baecfSMauro Carvalho Chehab obuf, (len > 16 ? 16 : len) + 3, 661786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 662786baecfSMauro Carvalho Chehab i += 16; 663786baecfSMauro Carvalho Chehab len -= 16; 664786baecfSMauro Carvalho Chehab } while (len > 0); 665786baecfSMauro Carvalho Chehab } else if (j < (num - 1)) { 666786baecfSMauro Carvalho Chehab /* write register addr before read */ 6670065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 6680065a79aSMauro Carvalho Chehab 6690065a79aSMauro Carvalho Chehab if (2 + msg[j].len > sizeof(obuf)) { 6700065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 6710065a79aSMauro Carvalho Chehab msg[j].len); 672324ed533SDan Carpenter ret = -EOPNOTSUPP; 673324ed533SDan Carpenter goto unlock; 6740065a79aSMauro Carvalho Chehab } 6750065a79aSMauro Carvalho Chehab 676786baecfSMauro Carvalho Chehab obuf[0] = msg[j + 1].len; 677786baecfSMauro Carvalho Chehab obuf[1] = (msg[j].addr << 1); 678786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[j].buf, msg[j].len); 679786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 6801ad5d064SHans Verkuil le16_to_cpu(udev->descriptor.idProduct) == 681786baecfSMauro Carvalho Chehab 0x7500 ? 0x92 : 0x90, 0, 0, 682786baecfSMauro Carvalho Chehab obuf, msg[j].len + 2, 683786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 684786baecfSMauro Carvalho Chehab break; 685786baecfSMauro Carvalho Chehab } else { 686786baecfSMauro Carvalho Chehab /* write registers */ 6870065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 6880065a79aSMauro Carvalho Chehab 6890065a79aSMauro Carvalho Chehab if (2 + msg[j].len > sizeof(obuf)) { 6900065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 6910065a79aSMauro Carvalho Chehab msg[j].len); 692324ed533SDan Carpenter ret = -EOPNOTSUPP; 693324ed533SDan Carpenter goto unlock; 6940065a79aSMauro Carvalho Chehab } 695786baecfSMauro Carvalho Chehab obuf[0] = msg[j].len + 1; 696786baecfSMauro Carvalho Chehab obuf[1] = (msg[j].addr << 1); 697786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[j].buf, msg[j].len); 698786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x80, 0, 0, 699786baecfSMauro Carvalho Chehab obuf, msg[j].len + 2, 700786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 701786baecfSMauro Carvalho Chehab break; 702786baecfSMauro Carvalho Chehab } 703786baecfSMauro Carvalho Chehab break; 704786baecfSMauro Carvalho Chehab } 705786baecfSMauro Carvalho Chehab } 706786baecfSMauro Carvalho Chehab } 707324ed533SDan Carpenter ret = num; 708786baecfSMauro Carvalho Chehab 709324ed533SDan Carpenter unlock: 710786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 711324ed533SDan Carpenter return ret; 712786baecfSMauro Carvalho Chehab } 713786baecfSMauro Carvalho Chehab 714786baecfSMauro Carvalho Chehab static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 715786baecfSMauro Carvalho Chehab int num) 716786baecfSMauro Carvalho Chehab { 717786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 718606142afSJonathan McDowell struct dw2102_state *state; 7190e148a52SMichael Bunk int j; 720786baecfSMauro Carvalho Chehab 721786baecfSMauro Carvalho Chehab if (!d) 722786baecfSMauro Carvalho Chehab return -ENODEV; 723606142afSJonathan McDowell 724606142afSJonathan McDowell state = d->priv; 725606142afSJonathan McDowell 726786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 727786baecfSMauro Carvalho Chehab return -EAGAIN; 728606142afSJonathan McDowell if (mutex_lock_interruptible(&d->data_mutex) < 0) { 729606142afSJonathan McDowell mutex_unlock(&d->i2c_mutex); 730606142afSJonathan McDowell return -EAGAIN; 731606142afSJonathan McDowell } 732786baecfSMauro Carvalho Chehab 7330e148a52SMichael Bunk j = 0; 7340e148a52SMichael Bunk while (j < num) { 7350e148a52SMichael Bunk switch (msg[j].addr) { 736786baecfSMauro Carvalho Chehab case SU3000_STREAM_CTRL: 7370e148a52SMichael Bunk state->data[0] = msg[j].buf[0] + 0x36; 738606142afSJonathan McDowell state->data[1] = 3; 739606142afSJonathan McDowell state->data[2] = 0; 740606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, 741606142afSJonathan McDowell state->data, 0, 0) < 0) 742786baecfSMauro Carvalho Chehab err("i2c transfer failed."); 743786baecfSMauro Carvalho Chehab break; 744786baecfSMauro Carvalho Chehab case DW2102_RC_QUERY: 745606142afSJonathan McDowell state->data[0] = 0x10; 746606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 1, 747606142afSJonathan McDowell state->data, 2, 0) < 0) 748786baecfSMauro Carvalho Chehab err("i2c transfer failed."); 7490e148a52SMichael Bunk msg[j].buf[1] = state->data[0]; 7500e148a52SMichael Bunk msg[j].buf[0] = state->data[1]; 751786baecfSMauro Carvalho Chehab break; 752786baecfSMauro Carvalho Chehab default: 7530e148a52SMichael Bunk /* if the current write msg is followed by a another 7540e148a52SMichael Bunk * read msg to/from the same address 7550e148a52SMichael Bunk */ 7560e148a52SMichael Bunk if ((j+1 < num) && (msg[j+1].flags & I2C_M_RD) && 7570e148a52SMichael Bunk (msg[j].addr == msg[j+1].addr)) { 7580e148a52SMichael Bunk /* join both i2c msgs to one usb read command */ 7590e148a52SMichael Bunk if (4 + msg[j].len > sizeof(state->data)) { 7600e148a52SMichael Bunk warn("i2c combined wr/rd: write len=%d is too big!\n", 7610e148a52SMichael Bunk msg[j].len); 762950e252cSAlyssa Milburn num = -EOPNOTSUPP; 763950e252cSAlyssa Milburn break; 764950e252cSAlyssa Milburn } 7650e148a52SMichael Bunk if (1 + msg[j+1].len > sizeof(state->data)) { 7660e148a52SMichael Bunk warn("i2c combined wr/rd: read len=%d is too big!\n", 7670e148a52SMichael Bunk msg[j+1].len); 768950e252cSAlyssa Milburn num = -EOPNOTSUPP; 769950e252cSAlyssa Milburn break; 770950e252cSAlyssa Milburn } 771950e252cSAlyssa Milburn 772606142afSJonathan McDowell state->data[0] = 0x09; 7730e148a52SMichael Bunk state->data[1] = msg[j].len; 7740e148a52SMichael Bunk state->data[2] = msg[j+1].len; 7750e148a52SMichael Bunk state->data[3] = msg[j].addr; 7760e148a52SMichael Bunk memcpy(&state->data[4], msg[j].buf, msg[j].len); 777786baecfSMauro Carvalho Chehab 7780e148a52SMichael Bunk if (dvb_usb_generic_rw(d, state->data, msg[j].len + 4, 7790e148a52SMichael Bunk state->data, msg[j+1].len + 1, 0) < 0) 780786baecfSMauro Carvalho Chehab err("i2c transfer failed."); 781786baecfSMauro Carvalho Chehab 7820e148a52SMichael Bunk memcpy(msg[j+1].buf, &state->data[1], msg[j+1].len); 7830e148a52SMichael Bunk j++; 784786baecfSMauro Carvalho Chehab break; 785786baecfSMauro Carvalho Chehab } 7860e148a52SMichael Bunk 7870e148a52SMichael Bunk if (msg[j].flags & I2C_M_RD) { 7880e148a52SMichael Bunk /* single read */ 7890e148a52SMichael Bunk if (1 + msg[j].len > sizeof(state->data)) { 7900e148a52SMichael Bunk warn("i2c rd: len=%d is too big!\n", msg[j].len); 7910e148a52SMichael Bunk num = -EOPNOTSUPP; 7920e148a52SMichael Bunk break; 7930e148a52SMichael Bunk } 7940e148a52SMichael Bunk 7950e148a52SMichael Bunk state->data[0] = 0x09; 7960e148a52SMichael Bunk state->data[1] = 0; 7970e148a52SMichael Bunk state->data[2] = msg[j].len; 7980e148a52SMichael Bunk state->data[3] = msg[j].addr; 7990e148a52SMichael Bunk memcpy(&state->data[4], msg[j].buf, msg[j].len); 8000e148a52SMichael Bunk 8010e148a52SMichael Bunk if (dvb_usb_generic_rw(d, state->data, 4, 8020e148a52SMichael Bunk state->data, msg[j].len + 1, 0) < 0) 8030e148a52SMichael Bunk err("i2c transfer failed."); 8040e148a52SMichael Bunk 8050e148a52SMichael Bunk memcpy(msg[j].buf, &state->data[1], msg[j].len); 8060e148a52SMichael Bunk break; 8070e148a52SMichael Bunk } 8080e148a52SMichael Bunk 8090e148a52SMichael Bunk /* single write */ 8100e148a52SMichael Bunk if (3 + msg[j].len > sizeof(state->data)) { 8110e148a52SMichael Bunk warn("i2c wr: len=%d is too big!\n", msg[j].len); 8120e148a52SMichael Bunk num = -EOPNOTSUPP; 8130e148a52SMichael Bunk break; 8140e148a52SMichael Bunk } 8150e148a52SMichael Bunk 8160e148a52SMichael Bunk state->data[0] = 0x08; 8170e148a52SMichael Bunk state->data[1] = msg[j].addr; 8180e148a52SMichael Bunk state->data[2] = msg[j].len; 8190e148a52SMichael Bunk 8200e148a52SMichael Bunk memcpy(&state->data[3], msg[j].buf, msg[j].len); 8210e148a52SMichael Bunk 8220e148a52SMichael Bunk if (dvb_usb_generic_rw(d, state->data, msg[j].len + 3, 8230e148a52SMichael Bunk state->data, 1, 0) < 0) 8240e148a52SMichael Bunk err("i2c transfer failed."); 8250e148a52SMichael Bunk } // switch 8260e148a52SMichael Bunk j++; 8270e148a52SMichael Bunk 8280e148a52SMichael Bunk } // while 829606142afSJonathan McDowell mutex_unlock(&d->data_mutex); 830786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 831786baecfSMauro Carvalho Chehab return num; 832786baecfSMauro Carvalho Chehab } 833786baecfSMauro Carvalho Chehab 834786baecfSMauro Carvalho Chehab static u32 dw210x_i2c_func(struct i2c_adapter *adapter) 835786baecfSMauro Carvalho Chehab { 836786baecfSMauro Carvalho Chehab return I2C_FUNC_I2C; 837786baecfSMauro Carvalho Chehab } 838786baecfSMauro Carvalho Chehab 839786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2102_i2c_algo = { 840786baecfSMauro Carvalho Chehab .master_xfer = dw2102_i2c_transfer, 841786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 842786baecfSMauro Carvalho Chehab }; 843786baecfSMauro Carvalho Chehab 844786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2102_serit_i2c_algo = { 845786baecfSMauro Carvalho Chehab .master_xfer = dw2102_serit_i2c_transfer, 846786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 847786baecfSMauro Carvalho Chehab }; 848786baecfSMauro Carvalho Chehab 849786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2102_earda_i2c_algo = { 850786baecfSMauro Carvalho Chehab .master_xfer = dw2102_earda_i2c_transfer, 851786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 852786baecfSMauro Carvalho Chehab }; 853786baecfSMauro Carvalho Chehab 854786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2104_i2c_algo = { 855786baecfSMauro Carvalho Chehab .master_xfer = dw2104_i2c_transfer, 856786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 857786baecfSMauro Carvalho Chehab }; 858786baecfSMauro Carvalho Chehab 859786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw3101_i2c_algo = { 860786baecfSMauro Carvalho Chehab .master_xfer = dw3101_i2c_transfer, 861786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 862786baecfSMauro Carvalho Chehab }; 863786baecfSMauro Carvalho Chehab 864786baecfSMauro Carvalho Chehab static struct i2c_algorithm s6x0_i2c_algo = { 865786baecfSMauro Carvalho Chehab .master_xfer = s6x0_i2c_transfer, 866786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 867786baecfSMauro Carvalho Chehab }; 868786baecfSMauro Carvalho Chehab 869786baecfSMauro Carvalho Chehab static struct i2c_algorithm su3000_i2c_algo = { 870786baecfSMauro Carvalho Chehab .master_xfer = su3000_i2c_transfer, 871786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 872786baecfSMauro Carvalho Chehab }; 873786baecfSMauro Carvalho Chehab 874786baecfSMauro Carvalho Chehab static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 875786baecfSMauro Carvalho Chehab { 876786baecfSMauro Carvalho Chehab int i; 877786baecfSMauro Carvalho Chehab u8 ibuf[] = {0, 0}; 878786baecfSMauro Carvalho Chehab u8 eeprom[256], eepromline[16]; 879786baecfSMauro Carvalho Chehab 880786baecfSMauro Carvalho Chehab for (i = 0; i < 256; i++) { 881786baecfSMauro Carvalho Chehab if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) { 882786baecfSMauro Carvalho Chehab err("read eeprom failed."); 883b37d9c99SMauro Carvalho Chehab return -EIO; 884786baecfSMauro Carvalho Chehab } else { 885786baecfSMauro Carvalho Chehab eepromline[i%16] = ibuf[0]; 886786baecfSMauro Carvalho Chehab eeprom[i] = ibuf[0]; 887786baecfSMauro Carvalho Chehab } 888786baecfSMauro Carvalho Chehab if ((i % 16) == 15) { 889786baecfSMauro Carvalho Chehab deb_xfer("%02x: ", i - 15); 890786baecfSMauro Carvalho Chehab debug_dump(eepromline, 16, deb_xfer); 891786baecfSMauro Carvalho Chehab } 892786baecfSMauro Carvalho Chehab } 893786baecfSMauro Carvalho Chehab 894786baecfSMauro Carvalho Chehab memcpy(mac, eeprom + 8, 6); 895786baecfSMauro Carvalho Chehab return 0; 896786baecfSMauro Carvalho Chehab }; 897786baecfSMauro Carvalho Chehab 898786baecfSMauro Carvalho Chehab static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 899786baecfSMauro Carvalho Chehab { 900786baecfSMauro Carvalho Chehab int i, ret; 901786baecfSMauro Carvalho Chehab u8 ibuf[] = { 0 }, obuf[] = { 0 }; 902786baecfSMauro Carvalho Chehab u8 eeprom[256], eepromline[16]; 903786baecfSMauro Carvalho Chehab struct i2c_msg msg[] = { 904786baecfSMauro Carvalho Chehab { 905786baecfSMauro Carvalho Chehab .addr = 0xa0 >> 1, 906786baecfSMauro Carvalho Chehab .flags = 0, 907786baecfSMauro Carvalho Chehab .buf = obuf, 908786baecfSMauro Carvalho Chehab .len = 1, 909786baecfSMauro Carvalho Chehab }, { 910786baecfSMauro Carvalho Chehab .addr = 0xa0 >> 1, 911786baecfSMauro Carvalho Chehab .flags = I2C_M_RD, 912786baecfSMauro Carvalho Chehab .buf = ibuf, 913786baecfSMauro Carvalho Chehab .len = 1, 914786baecfSMauro Carvalho Chehab } 915786baecfSMauro Carvalho Chehab }; 916786baecfSMauro Carvalho Chehab 917786baecfSMauro Carvalho Chehab for (i = 0; i < 256; i++) { 918786baecfSMauro Carvalho Chehab obuf[0] = i; 919786baecfSMauro Carvalho Chehab ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2); 920786baecfSMauro Carvalho Chehab if (ret != 2) { 921786baecfSMauro Carvalho Chehab err("read eeprom failed."); 922b37d9c99SMauro Carvalho Chehab return -EIO; 923786baecfSMauro Carvalho Chehab } else { 924786baecfSMauro Carvalho Chehab eepromline[i % 16] = ibuf[0]; 925786baecfSMauro Carvalho Chehab eeprom[i] = ibuf[0]; 926786baecfSMauro Carvalho Chehab } 927786baecfSMauro Carvalho Chehab 928786baecfSMauro Carvalho Chehab if ((i % 16) == 15) { 929786baecfSMauro Carvalho Chehab deb_xfer("%02x: ", i - 15); 930786baecfSMauro Carvalho Chehab debug_dump(eepromline, 16, deb_xfer); 931786baecfSMauro Carvalho Chehab } 932786baecfSMauro Carvalho Chehab } 933786baecfSMauro Carvalho Chehab 934786baecfSMauro Carvalho Chehab memcpy(mac, eeprom + 16, 6); 935786baecfSMauro Carvalho Chehab return 0; 936786baecfSMauro Carvalho Chehab }; 937786baecfSMauro Carvalho Chehab 938786baecfSMauro Carvalho Chehab static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 939786baecfSMauro Carvalho Chehab { 940786baecfSMauro Carvalho Chehab static u8 command_start[] = {0x00}; 941786baecfSMauro Carvalho Chehab static u8 command_stop[] = {0x01}; 942786baecfSMauro Carvalho Chehab struct i2c_msg msg = { 943786baecfSMauro Carvalho Chehab .addr = SU3000_STREAM_CTRL, 944786baecfSMauro Carvalho Chehab .flags = 0, 945786baecfSMauro Carvalho Chehab .buf = onoff ? command_start : command_stop, 946786baecfSMauro Carvalho Chehab .len = 1 947786baecfSMauro Carvalho Chehab }; 948786baecfSMauro Carvalho Chehab 949786baecfSMauro Carvalho Chehab i2c_transfer(&adap->dev->i2c_adap, &msg, 1); 950786baecfSMauro Carvalho Chehab 951786baecfSMauro Carvalho Chehab return 0; 952786baecfSMauro Carvalho Chehab } 953786baecfSMauro Carvalho Chehab 954786baecfSMauro Carvalho Chehab static int su3000_power_ctrl(struct dvb_usb_device *d, int i) 955786baecfSMauro Carvalho Chehab { 956663e7460SYu Zhe struct dw2102_state *state = d->priv; 957606142afSJonathan McDowell int ret = 0; 958786baecfSMauro Carvalho Chehab 9590385443fSJonathan McDowell info("%s: %d, initialized %d", __func__, i, state->initialized); 960786baecfSMauro Carvalho Chehab 961786baecfSMauro Carvalho Chehab if (i && !state->initialized) { 962606142afSJonathan McDowell mutex_lock(&d->data_mutex); 963606142afSJonathan McDowell 964606142afSJonathan McDowell state->data[0] = 0xde; 965606142afSJonathan McDowell state->data[1] = 0; 966606142afSJonathan McDowell 967786baecfSMauro Carvalho Chehab state->initialized = 1; 968786baecfSMauro Carvalho Chehab /* reset board */ 969606142afSJonathan McDowell ret = dvb_usb_generic_rw(d, state->data, 2, NULL, 0, 0); 970606142afSJonathan McDowell mutex_unlock(&d->data_mutex); 971786baecfSMauro Carvalho Chehab } 972786baecfSMauro Carvalho Chehab 973606142afSJonathan McDowell return ret; 974786baecfSMauro Carvalho Chehab } 975786baecfSMauro Carvalho Chehab 976786baecfSMauro Carvalho Chehab static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 977786baecfSMauro Carvalho Chehab { 978786baecfSMauro Carvalho Chehab int i; 979786baecfSMauro Carvalho Chehab u8 obuf[] = { 0x1f, 0xf0 }; 980786baecfSMauro Carvalho Chehab u8 ibuf[] = { 0 }; 981786baecfSMauro Carvalho Chehab struct i2c_msg msg[] = { 982786baecfSMauro Carvalho Chehab { 983786baecfSMauro Carvalho Chehab .addr = 0x51, 984786baecfSMauro Carvalho Chehab .flags = 0, 985786baecfSMauro Carvalho Chehab .buf = obuf, 986786baecfSMauro Carvalho Chehab .len = 2, 987786baecfSMauro Carvalho Chehab }, { 988786baecfSMauro Carvalho Chehab .addr = 0x51, 989786baecfSMauro Carvalho Chehab .flags = I2C_M_RD, 990786baecfSMauro Carvalho Chehab .buf = ibuf, 991786baecfSMauro Carvalho Chehab .len = 1, 992786baecfSMauro Carvalho Chehab 993786baecfSMauro Carvalho Chehab } 994786baecfSMauro Carvalho Chehab }; 995786baecfSMauro Carvalho Chehab 996786baecfSMauro Carvalho Chehab for (i = 0; i < 6; i++) { 997786baecfSMauro Carvalho Chehab obuf[1] = 0xf0 + i; 998786baecfSMauro Carvalho Chehab if (i2c_transfer(&d->i2c_adap, msg, 2) != 2) 999b37d9c99SMauro Carvalho Chehab return -EIO; 1000786baecfSMauro Carvalho Chehab else 1001786baecfSMauro Carvalho Chehab mac[i] = ibuf[0]; 1002786baecfSMauro Carvalho Chehab } 1003786baecfSMauro Carvalho Chehab 1004786baecfSMauro Carvalho Chehab return 0; 1005786baecfSMauro Carvalho Chehab } 1006786baecfSMauro Carvalho Chehab 1007786baecfSMauro Carvalho Chehab static int su3000_identify_state(struct usb_device *udev, 1008d27958dfSSean Young const struct dvb_usb_device_properties *props, 1009d27958dfSSean Young const struct dvb_usb_device_description **desc, 1010786baecfSMauro Carvalho Chehab int *cold) 1011786baecfSMauro Carvalho Chehab { 10120385443fSJonathan McDowell info("%s", __func__); 1013786baecfSMauro Carvalho Chehab 1014786baecfSMauro Carvalho Chehab *cold = 0; 1015786baecfSMauro Carvalho Chehab return 0; 1016786baecfSMauro Carvalho Chehab } 1017786baecfSMauro Carvalho Chehab 10180df289a2SMauro Carvalho Chehab static int dw210x_set_voltage(struct dvb_frontend *fe, 10190df289a2SMauro Carvalho Chehab enum fe_sec_voltage voltage) 1020786baecfSMauro Carvalho Chehab { 1021786baecfSMauro Carvalho Chehab static u8 command_13v[] = {0x00, 0x01}; 1022786baecfSMauro Carvalho Chehab static u8 command_18v[] = {0x01, 0x01}; 1023786baecfSMauro Carvalho Chehab static u8 command_off[] = {0x00, 0x00}; 1024786baecfSMauro Carvalho Chehab struct i2c_msg msg = { 1025786baecfSMauro Carvalho Chehab .addr = DW2102_VOLTAGE_CTRL, 1026786baecfSMauro Carvalho Chehab .flags = 0, 1027786baecfSMauro Carvalho Chehab .buf = command_off, 1028786baecfSMauro Carvalho Chehab .len = 2, 1029786baecfSMauro Carvalho Chehab }; 1030786baecfSMauro Carvalho Chehab 1031663e7460SYu Zhe struct dvb_usb_adapter *udev_adap = fe->dvb->priv; 1032786baecfSMauro Carvalho Chehab if (voltage == SEC_VOLTAGE_18) 1033786baecfSMauro Carvalho Chehab msg.buf = command_18v; 1034786baecfSMauro Carvalho Chehab else if (voltage == SEC_VOLTAGE_13) 1035786baecfSMauro Carvalho Chehab msg.buf = command_13v; 1036786baecfSMauro Carvalho Chehab 1037786baecfSMauro Carvalho Chehab i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); 1038786baecfSMauro Carvalho Chehab 1039786baecfSMauro Carvalho Chehab return 0; 1040786baecfSMauro Carvalho Chehab } 1041786baecfSMauro Carvalho Chehab 10420df289a2SMauro Carvalho Chehab static int s660_set_voltage(struct dvb_frontend *fe, 10430df289a2SMauro Carvalho Chehab enum fe_sec_voltage voltage) 1044786baecfSMauro Carvalho Chehab { 1045663e7460SYu Zhe struct dvb_usb_adapter *d = fe->dvb->priv; 1046663e7460SYu Zhe struct dw2102_state *st = d->dev->priv; 1047786baecfSMauro Carvalho Chehab 1048786baecfSMauro Carvalho Chehab dw210x_set_voltage(fe, voltage); 1049786baecfSMauro Carvalho Chehab if (st->old_set_voltage) 1050786baecfSMauro Carvalho Chehab st->old_set_voltage(fe, voltage); 1051786baecfSMauro Carvalho Chehab 1052786baecfSMauro Carvalho Chehab return 0; 1053786baecfSMauro Carvalho Chehab } 1054786baecfSMauro Carvalho Chehab 1055786baecfSMauro Carvalho Chehab static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon) 1056786baecfSMauro Carvalho Chehab { 1057786baecfSMauro Carvalho Chehab static u8 led_off[] = { 0 }; 1058786baecfSMauro Carvalho Chehab static u8 led_on[] = { 1 }; 1059786baecfSMauro Carvalho Chehab struct i2c_msg msg = { 1060786baecfSMauro Carvalho Chehab .addr = DW2102_LED_CTRL, 1061786baecfSMauro Carvalho Chehab .flags = 0, 1062786baecfSMauro Carvalho Chehab .buf = led_off, 1063786baecfSMauro Carvalho Chehab .len = 1 1064786baecfSMauro Carvalho Chehab }; 1065663e7460SYu Zhe struct dvb_usb_adapter *udev_adap = fe->dvb->priv; 1066786baecfSMauro Carvalho Chehab 1067786baecfSMauro Carvalho Chehab if (offon) 1068786baecfSMauro Carvalho Chehab msg.buf = led_on; 1069786baecfSMauro Carvalho Chehab i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); 1070786baecfSMauro Carvalho Chehab } 1071786baecfSMauro Carvalho Chehab 10720df289a2SMauro Carvalho Chehab static int tt_s2_4600_read_status(struct dvb_frontend *fe, 10730df289a2SMauro Carvalho Chehab enum fe_status *status) 1074356484caSOlli Salonen { 1075663e7460SYu Zhe struct dvb_usb_adapter *d = fe->dvb->priv; 1076663e7460SYu Zhe struct dw2102_state *st = d->dev->priv; 1077356484caSOlli Salonen int ret; 1078356484caSOlli Salonen 1079356484caSOlli Salonen ret = st->fe_read_status(fe, status); 1080356484caSOlli Salonen 1081356484caSOlli Salonen /* resync slave fifo when signal change from unlock to lock */ 1082356484caSOlli Salonen if ((*status & FE_HAS_LOCK) && (!st->last_lock)) 1083356484caSOlli Salonen su3000_streaming_ctrl(d, 1); 1084356484caSOlli Salonen 1085356484caSOlli Salonen st->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0; 1086356484caSOlli Salonen return ret; 1087356484caSOlli Salonen } 1088356484caSOlli Salonen 1089786baecfSMauro Carvalho Chehab static struct stv0299_config sharp_z0194a_config = { 1090786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1091786baecfSMauro Carvalho Chehab .inittab = sharp_z0194a_inittab, 1092786baecfSMauro Carvalho Chehab .mclk = 88000000UL, 1093786baecfSMauro Carvalho Chehab .invert = 1, 1094786baecfSMauro Carvalho Chehab .skip_reinit = 0, 1095786baecfSMauro Carvalho Chehab .lock_output = STV0299_LOCKOUTPUT_1, 1096786baecfSMauro Carvalho Chehab .volt13_op0_op1 = STV0299_VOLT13_OP1, 1097786baecfSMauro Carvalho Chehab .min_delay_ms = 100, 1098786baecfSMauro Carvalho Chehab .set_symbol_rate = sharp_z0194a_set_symbol_rate, 1099786baecfSMauro Carvalho Chehab }; 1100786baecfSMauro Carvalho Chehab 1101786baecfSMauro Carvalho Chehab static struct cx24116_config dw2104_config = { 1102786baecfSMauro Carvalho Chehab .demod_address = 0x55, 1103786baecfSMauro Carvalho Chehab .mpg_clk_pos_pol = 0x01, 1104786baecfSMauro Carvalho Chehab }; 1105786baecfSMauro Carvalho Chehab 1106786baecfSMauro Carvalho Chehab static struct si21xx_config serit_sp1511lhb_config = { 1107786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1108786baecfSMauro Carvalho Chehab .min_delay_ms = 100, 1109786baecfSMauro Carvalho Chehab 1110786baecfSMauro Carvalho Chehab }; 1111786baecfSMauro Carvalho Chehab 1112786baecfSMauro Carvalho Chehab static struct tda10023_config dw3101_tda10023_config = { 1113786baecfSMauro Carvalho Chehab .demod_address = 0x0c, 1114786baecfSMauro Carvalho Chehab .invert = 1, 1115786baecfSMauro Carvalho Chehab }; 1116786baecfSMauro Carvalho Chehab 1117786baecfSMauro Carvalho Chehab static struct mt312_config zl313_config = { 1118786baecfSMauro Carvalho Chehab .demod_address = 0x0e, 1119786baecfSMauro Carvalho Chehab }; 1120786baecfSMauro Carvalho Chehab 1121786baecfSMauro Carvalho Chehab static struct ds3000_config dw2104_ds3000_config = { 1122786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1123786baecfSMauro Carvalho Chehab }; 1124786baecfSMauro Carvalho Chehab 112573f0af44SKonstantin Dimitrov static struct ts2020_config dw2104_ts2020_config = { 112673f0af44SKonstantin Dimitrov .tuner_address = 0x60, 1127b858c331SIgor M. Liplianin .clk_out_div = 1, 112803a67279SJohn Horan .frequency_div = 1060000, 112973f0af44SKonstantin Dimitrov }; 113073f0af44SKonstantin Dimitrov 113143385c8aSIgor M. Liplianin static struct ds3000_config s660_ds3000_config = { 113243385c8aSIgor M. Liplianin .demod_address = 0x68, 1133b858c331SIgor M. Liplianin .ci_mode = 1, 113443385c8aSIgor M. Liplianin .set_lock_led = dw210x_led_ctrl, 113543385c8aSIgor M. Liplianin }; 113643385c8aSIgor M. Liplianin 113703a67279SJohn Horan static struct ts2020_config s660_ts2020_config = { 113803a67279SJohn Horan .tuner_address = 0x60, 113903a67279SJohn Horan .clk_out_div = 1, 114003a67279SJohn Horan .frequency_div = 1146000, 114103a67279SJohn Horan }; 114203a67279SJohn Horan 1143786baecfSMauro Carvalho Chehab static struct stv0900_config dw2104a_stv0900_config = { 1144786baecfSMauro Carvalho Chehab .demod_address = 0x6a, 1145786baecfSMauro Carvalho Chehab .demod_mode = 0, 1146786baecfSMauro Carvalho Chehab .xtal = 27000000, 1147786baecfSMauro Carvalho Chehab .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 1148786baecfSMauro Carvalho Chehab .diseqc_mode = 2,/* 2/3 PWM */ 1149786baecfSMauro Carvalho Chehab .tun1_maddress = 0,/* 0x60 */ 1150786baecfSMauro Carvalho Chehab .tun1_adc = 0,/* 2 Vpp */ 1151786baecfSMauro Carvalho Chehab .path1_mode = 3, 1152786baecfSMauro Carvalho Chehab }; 1153786baecfSMauro Carvalho Chehab 1154786baecfSMauro Carvalho Chehab static struct stb6100_config dw2104a_stb6100_config = { 1155786baecfSMauro Carvalho Chehab .tuner_address = 0x60, 1156786baecfSMauro Carvalho Chehab .refclock = 27000000, 1157786baecfSMauro Carvalho Chehab }; 1158786baecfSMauro Carvalho Chehab 1159786baecfSMauro Carvalho Chehab static struct stv0900_config dw2104_stv0900_config = { 1160786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1161786baecfSMauro Carvalho Chehab .demod_mode = 0, 1162786baecfSMauro Carvalho Chehab .xtal = 8000000, 1163786baecfSMauro Carvalho Chehab .clkmode = 3, 1164786baecfSMauro Carvalho Chehab .diseqc_mode = 2, 1165786baecfSMauro Carvalho Chehab .tun1_maddress = 0, 1166786baecfSMauro Carvalho Chehab .tun1_adc = 1,/* 1 Vpp */ 1167786baecfSMauro Carvalho Chehab .path1_mode = 3, 1168786baecfSMauro Carvalho Chehab }; 1169786baecfSMauro Carvalho Chehab 1170786baecfSMauro Carvalho Chehab static struct stv6110_config dw2104_stv6110_config = { 1171786baecfSMauro Carvalho Chehab .i2c_address = 0x60, 1172786baecfSMauro Carvalho Chehab .mclk = 16000000, 1173786baecfSMauro Carvalho Chehab .clk_div = 1, 1174786baecfSMauro Carvalho Chehab }; 1175786baecfSMauro Carvalho Chehab 1176786baecfSMauro Carvalho Chehab static struct stv0900_config prof_7500_stv0900_config = { 1177786baecfSMauro Carvalho Chehab .demod_address = 0x6a, 1178786baecfSMauro Carvalho Chehab .demod_mode = 0, 1179786baecfSMauro Carvalho Chehab .xtal = 27000000, 1180786baecfSMauro Carvalho Chehab .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 1181786baecfSMauro Carvalho Chehab .diseqc_mode = 2,/* 2/3 PWM */ 1182786baecfSMauro Carvalho Chehab .tun1_maddress = 0,/* 0x60 */ 1183786baecfSMauro Carvalho Chehab .tun1_adc = 0,/* 2 Vpp */ 1184786baecfSMauro Carvalho Chehab .path1_mode = 3, 1185786baecfSMauro Carvalho Chehab .tun1_type = 3, 1186786baecfSMauro Carvalho Chehab .set_lock_led = dw210x_led_ctrl, 1187786baecfSMauro Carvalho Chehab }; 1188786baecfSMauro Carvalho Chehab 1189786baecfSMauro Carvalho Chehab static struct ds3000_config su3000_ds3000_config = { 1190786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1191786baecfSMauro Carvalho Chehab .ci_mode = 1, 1192b858c331SIgor M. Liplianin .set_lock_led = dw210x_led_ctrl, 119373f0af44SKonstantin Dimitrov }; 119473f0af44SKonstantin Dimitrov 119551d882edSEvgeny Plehov static struct cxd2820r_config cxd2820r_config = { 119651d882edSEvgeny Plehov .i2c_address = 0x6c, /* (0xd8 >> 1) */ 119751d882edSEvgeny Plehov .ts_mode = 0x38, 11987b71ef7eSCrazyCat .ts_clock_inv = 1, 119951d882edSEvgeny Plehov }; 120051d882edSEvgeny Plehov 120151d882edSEvgeny Plehov static struct tda18271_config tda18271_config = { 120251d882edSEvgeny Plehov .output_opt = TDA18271_OUTPUT_LT_OFF, 120351d882edSEvgeny Plehov .gate = TDA18271_GATE_DIGITAL, 120451d882edSEvgeny Plehov }; 120551d882edSEvgeny Plehov 1206955d00acSIgor M. Liplianin static u8 m88rs2000_inittab[] = { 1207955d00acSIgor M. Liplianin DEMOD_WRITE, 0x9a, 0x30, 1208955d00acSIgor M. Liplianin DEMOD_WRITE, 0x00, 0x01, 1209955d00acSIgor M. Liplianin WRITE_DELAY, 0x19, 0x00, 1210955d00acSIgor M. Liplianin DEMOD_WRITE, 0x00, 0x00, 1211955d00acSIgor M. Liplianin DEMOD_WRITE, 0x9a, 0xb0, 1212955d00acSIgor M. Liplianin DEMOD_WRITE, 0x81, 0xc1, 1213955d00acSIgor M. Liplianin DEMOD_WRITE, 0x81, 0x81, 1214955d00acSIgor M. Liplianin DEMOD_WRITE, 0x86, 0xc6, 1215955d00acSIgor M. Liplianin DEMOD_WRITE, 0x9a, 0x30, 1216955d00acSIgor M. Liplianin DEMOD_WRITE, 0xf0, 0x80, 1217955d00acSIgor M. Liplianin DEMOD_WRITE, 0xf1, 0xbf, 1218955d00acSIgor M. Liplianin DEMOD_WRITE, 0xb0, 0x45, 1219955d00acSIgor M. Liplianin DEMOD_WRITE, 0xb2, 0x01, 1220955d00acSIgor M. Liplianin DEMOD_WRITE, 0x9a, 0xb0, 1221955d00acSIgor M. Liplianin 0xff, 0xaa, 0xff 1222955d00acSIgor M. Liplianin }; 1223955d00acSIgor M. Liplianin 1224955d00acSIgor M. Liplianin static struct m88rs2000_config s421_m88rs2000_config = { 1225955d00acSIgor M. Liplianin .demod_addr = 0x68, 1226955d00acSIgor M. Liplianin .inittab = m88rs2000_inittab, 1227955d00acSIgor M. Liplianin }; 1228955d00acSIgor M. Liplianin 1229786baecfSMauro Carvalho Chehab static int dw2104_frontend_attach(struct dvb_usb_adapter *d) 1230786baecfSMauro Carvalho Chehab { 1231786baecfSMauro Carvalho Chehab struct dvb_tuner_ops *tuner_ops = NULL; 1232786baecfSMauro Carvalho Chehab 1233786baecfSMauro Carvalho Chehab if (demod_probe & 4) { 1234786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config, 1235786baecfSMauro Carvalho Chehab &d->dev->i2c_adap, 0); 1236786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1237786baecfSMauro Carvalho Chehab if (dvb_attach(stb6100_attach, d->fe_adap[0].fe, 1238786baecfSMauro Carvalho Chehab &dw2104a_stb6100_config, 1239786baecfSMauro Carvalho Chehab &d->dev->i2c_adap)) { 1240786baecfSMauro Carvalho Chehab tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops; 1241786baecfSMauro Carvalho Chehab tuner_ops->set_frequency = stb6100_set_freq; 1242786baecfSMauro Carvalho Chehab tuner_ops->get_frequency = stb6100_get_freq; 1243786baecfSMauro Carvalho Chehab tuner_ops->set_bandwidth = stb6100_set_bandw; 1244786baecfSMauro Carvalho Chehab tuner_ops->get_bandwidth = stb6100_get_bandw; 1245786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 12460385443fSJonathan McDowell info("Attached STV0900+STB6100!"); 1247786baecfSMauro Carvalho Chehab return 0; 1248786baecfSMauro Carvalho Chehab } 1249786baecfSMauro Carvalho Chehab } 1250786baecfSMauro Carvalho Chehab } 1251786baecfSMauro Carvalho Chehab 1252786baecfSMauro Carvalho Chehab if (demod_probe & 2) { 1253786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config, 1254786baecfSMauro Carvalho Chehab &d->dev->i2c_adap, 0); 1255786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1256786baecfSMauro Carvalho Chehab if (dvb_attach(stv6110_attach, d->fe_adap[0].fe, 1257786baecfSMauro Carvalho Chehab &dw2104_stv6110_config, 1258786baecfSMauro Carvalho Chehab &d->dev->i2c_adap)) { 1259786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 12600385443fSJonathan McDowell info("Attached STV0900+STV6110A!"); 1261786baecfSMauro Carvalho Chehab return 0; 1262786baecfSMauro Carvalho Chehab } 1263786baecfSMauro Carvalho Chehab } 1264786baecfSMauro Carvalho Chehab } 1265786baecfSMauro Carvalho Chehab 1266786baecfSMauro Carvalho Chehab if (demod_probe & 1) { 1267786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config, 1268786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1269786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1270786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 12710385443fSJonathan McDowell info("Attached cx24116!"); 1272786baecfSMauro Carvalho Chehab return 0; 1273786baecfSMauro Carvalho Chehab } 1274786baecfSMauro Carvalho Chehab } 1275786baecfSMauro Carvalho Chehab 1276786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, 1277786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1278786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 127973f0af44SKonstantin Dimitrov dvb_attach(ts2020_attach, d->fe_adap[0].fe, 128073f0af44SKonstantin Dimitrov &dw2104_ts2020_config, &d->dev->i2c_adap); 1281786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 12820385443fSJonathan McDowell info("Attached DS3000!"); 1283786baecfSMauro Carvalho Chehab return 0; 1284786baecfSMauro Carvalho Chehab } 1285786baecfSMauro Carvalho Chehab 1286786baecfSMauro Carvalho Chehab return -EIO; 1287786baecfSMauro Carvalho Chehab } 1288786baecfSMauro Carvalho Chehab 1289786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2102_properties; 1290786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2104_properties; 1291786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties s6x0_properties; 1292786baecfSMauro Carvalho Chehab 1293786baecfSMauro Carvalho Chehab static int dw2102_frontend_attach(struct dvb_usb_adapter *d) 1294786baecfSMauro Carvalho Chehab { 1295786baecfSMauro Carvalho Chehab if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) { 1296786baecfSMauro Carvalho Chehab /*dw2102_properties.adapter->tuner_attach = NULL;*/ 1297786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config, 1298786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1299786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1300786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 13010385443fSJonathan McDowell info("Attached si21xx!"); 1302786baecfSMauro Carvalho Chehab return 0; 1303786baecfSMauro Carvalho Chehab } 1304786baecfSMauro Carvalho Chehab } 1305786baecfSMauro Carvalho Chehab 1306786baecfSMauro Carvalho Chehab if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) { 1307786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, 1308786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1309786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1310786baecfSMauro Carvalho Chehab if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, 1311786baecfSMauro Carvalho Chehab &d->dev->i2c_adap)) { 1312786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 13130385443fSJonathan McDowell info("Attached stv0288!"); 1314786baecfSMauro Carvalho Chehab return 0; 1315786baecfSMauro Carvalho Chehab } 1316786baecfSMauro Carvalho Chehab } 1317786baecfSMauro Carvalho Chehab } 1318786baecfSMauro Carvalho Chehab 1319786baecfSMauro Carvalho Chehab if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) { 1320786baecfSMauro Carvalho Chehab /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ 1321786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config, 1322786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1323786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1324786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 13250385443fSJonathan McDowell info("Attached stv0299!"); 1326786baecfSMauro Carvalho Chehab return 0; 1327786baecfSMauro Carvalho Chehab } 1328786baecfSMauro Carvalho Chehab } 1329786baecfSMauro Carvalho Chehab return -EIO; 1330786baecfSMauro Carvalho Chehab } 1331786baecfSMauro Carvalho Chehab 1332786baecfSMauro Carvalho Chehab static int dw3101_frontend_attach(struct dvb_usb_adapter *d) 1333786baecfSMauro Carvalho Chehab { 1334786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config, 1335786baecfSMauro Carvalho Chehab &d->dev->i2c_adap, 0x48); 1336786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 13370385443fSJonathan McDowell info("Attached tda10023!"); 1338786baecfSMauro Carvalho Chehab return 0; 1339786baecfSMauro Carvalho Chehab } 1340786baecfSMauro Carvalho Chehab return -EIO; 1341786baecfSMauro Carvalho Chehab } 1342786baecfSMauro Carvalho Chehab 1343786baecfSMauro Carvalho Chehab static int zl100313_frontend_attach(struct dvb_usb_adapter *d) 1344786baecfSMauro Carvalho Chehab { 1345786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config, 1346786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1347786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1348786baecfSMauro Carvalho Chehab if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60, 1349786baecfSMauro Carvalho Chehab &d->dev->i2c_adap)) { 1350786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 13510385443fSJonathan McDowell info("Attached zl100313+zl10039!"); 1352786baecfSMauro Carvalho Chehab return 0; 1353786baecfSMauro Carvalho Chehab } 1354786baecfSMauro Carvalho Chehab } 1355786baecfSMauro Carvalho Chehab 1356786baecfSMauro Carvalho Chehab return -EIO; 1357786baecfSMauro Carvalho Chehab } 1358786baecfSMauro Carvalho Chehab 1359786baecfSMauro Carvalho Chehab static int stv0288_frontend_attach(struct dvb_usb_adapter *d) 1360786baecfSMauro Carvalho Chehab { 1361786baecfSMauro Carvalho Chehab u8 obuf[] = {7, 1}; 1362786baecfSMauro Carvalho Chehab 1363786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, 1364786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1365786baecfSMauro Carvalho Chehab 1366786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe == NULL) 1367786baecfSMauro Carvalho Chehab return -EIO; 1368786baecfSMauro Carvalho Chehab 1369786baecfSMauro Carvalho Chehab if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap)) 1370786baecfSMauro Carvalho Chehab return -EIO; 1371786baecfSMauro Carvalho Chehab 1372786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1373786baecfSMauro Carvalho Chehab 1374786baecfSMauro Carvalho Chehab dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1375786baecfSMauro Carvalho Chehab 13760385443fSJonathan McDowell info("Attached stv0288+stb6000!"); 1377786baecfSMauro Carvalho Chehab 1378786baecfSMauro Carvalho Chehab return 0; 1379786baecfSMauro Carvalho Chehab 1380786baecfSMauro Carvalho Chehab } 1381786baecfSMauro Carvalho Chehab 1382786baecfSMauro Carvalho Chehab static int ds3000_frontend_attach(struct dvb_usb_adapter *d) 1383786baecfSMauro Carvalho Chehab { 13842c4ffe27SOlli Salonen struct dw2102_state *st = d->dev->priv; 1385786baecfSMauro Carvalho Chehab u8 obuf[] = {7, 1}; 1386786baecfSMauro Carvalho Chehab 138743385c8aSIgor M. Liplianin d->fe_adap[0].fe = dvb_attach(ds3000_attach, &s660_ds3000_config, 1388786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1389786baecfSMauro Carvalho Chehab 1390786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe == NULL) 1391786baecfSMauro Carvalho Chehab return -EIO; 1392786baecfSMauro Carvalho Chehab 139303a67279SJohn Horan dvb_attach(ts2020_attach, d->fe_adap[0].fe, &s660_ts2020_config, 139473f0af44SKonstantin Dimitrov &d->dev->i2c_adap); 139573f0af44SKonstantin Dimitrov 1396786baecfSMauro Carvalho Chehab st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; 1397786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage; 1398786baecfSMauro Carvalho Chehab 1399786baecfSMauro Carvalho Chehab dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1400786baecfSMauro Carvalho Chehab 14010385443fSJonathan McDowell info("Attached ds3000+ts2020!"); 1402786baecfSMauro Carvalho Chehab 1403786baecfSMauro Carvalho Chehab return 0; 1404786baecfSMauro Carvalho Chehab } 1405786baecfSMauro Carvalho Chehab 1406786baecfSMauro Carvalho Chehab static int prof_7500_frontend_attach(struct dvb_usb_adapter *d) 1407786baecfSMauro Carvalho Chehab { 1408786baecfSMauro Carvalho Chehab u8 obuf[] = {7, 1}; 1409786baecfSMauro Carvalho Chehab 1410786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config, 1411786baecfSMauro Carvalho Chehab &d->dev->i2c_adap, 0); 1412786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe == NULL) 1413786baecfSMauro Carvalho Chehab return -EIO; 1414786baecfSMauro Carvalho Chehab 1415786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1416786baecfSMauro Carvalho Chehab 1417786baecfSMauro Carvalho Chehab dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1418786baecfSMauro Carvalho Chehab 14190385443fSJonathan McDowell info("Attached STV0900+STB6100A!"); 1420786baecfSMauro Carvalho Chehab 1421786baecfSMauro Carvalho Chehab return 0; 1422786baecfSMauro Carvalho Chehab } 1423786baecfSMauro Carvalho Chehab 1424606142afSJonathan McDowell static int su3000_frontend_attach(struct dvb_usb_adapter *adap) 1425786baecfSMauro Carvalho Chehab { 1426606142afSJonathan McDowell struct dvb_usb_device *d = adap->dev; 1427606142afSJonathan McDowell struct dw2102_state *state = d->priv; 1428786baecfSMauro Carvalho Chehab 1429606142afSJonathan McDowell mutex_lock(&d->data_mutex); 1430606142afSJonathan McDowell 1431606142afSJonathan McDowell state->data[0] = 0xe; 1432606142afSJonathan McDowell state->data[1] = 0x80; 1433606142afSJonathan McDowell state->data[2] = 0; 1434606142afSJonathan McDowell 1435606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1436786baecfSMauro Carvalho Chehab err("command 0x0e transfer failed."); 1437786baecfSMauro Carvalho Chehab 1438606142afSJonathan McDowell state->data[0] = 0xe; 1439606142afSJonathan McDowell state->data[1] = 0x02; 1440606142afSJonathan McDowell state->data[2] = 1; 1441b858c331SIgor M. Liplianin 1442606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1443b858c331SIgor M. Liplianin err("command 0x0e transfer failed."); 1444b858c331SIgor M. Liplianin msleep(300); 1445b858c331SIgor M. Liplianin 1446606142afSJonathan McDowell state->data[0] = 0xe; 1447606142afSJonathan McDowell state->data[1] = 0x83; 1448606142afSJonathan McDowell state->data[2] = 0; 1449786baecfSMauro Carvalho Chehab 1450606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1451786baecfSMauro Carvalho Chehab err("command 0x0e transfer failed."); 1452786baecfSMauro Carvalho Chehab 1453606142afSJonathan McDowell state->data[0] = 0xe; 1454606142afSJonathan McDowell state->data[1] = 0x83; 1455606142afSJonathan McDowell state->data[2] = 1; 1456786baecfSMauro Carvalho Chehab 1457606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1458786baecfSMauro Carvalho Chehab err("command 0x0e transfer failed."); 1459786baecfSMauro Carvalho Chehab 1460606142afSJonathan McDowell state->data[0] = 0x51; 1461786baecfSMauro Carvalho Chehab 1462606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) 1463786baecfSMauro Carvalho Chehab err("command 0x51 transfer failed."); 1464786baecfSMauro Carvalho Chehab 1465606142afSJonathan McDowell mutex_unlock(&d->data_mutex); 1466606142afSJonathan McDowell 1467606142afSJonathan McDowell adap->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config, 1468606142afSJonathan McDowell &d->i2c_adap); 1469606142afSJonathan McDowell if (adap->fe_adap[0].fe == NULL) 1470786baecfSMauro Carvalho Chehab return -EIO; 1471786baecfSMauro Carvalho Chehab 1472606142afSJonathan McDowell if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe, 1473b858c331SIgor M. Liplianin &dw2104_ts2020_config, 1474606142afSJonathan McDowell &d->i2c_adap)) { 14750385443fSJonathan McDowell info("Attached DS3000/TS2020!"); 1476786baecfSMauro Carvalho Chehab return 0; 1477786baecfSMauro Carvalho Chehab } 1478786baecfSMauro Carvalho Chehab 14790385443fSJonathan McDowell info("Failed to attach DS3000/TS2020!"); 1480b858c331SIgor M. Liplianin return -EIO; 1481b858c331SIgor M. Liplianin } 1482b858c331SIgor M. Liplianin 1483606142afSJonathan McDowell static int t220_frontend_attach(struct dvb_usb_adapter *adap) 148451d882edSEvgeny Plehov { 1485606142afSJonathan McDowell struct dvb_usb_device *d = adap->dev; 1486606142afSJonathan McDowell struct dw2102_state *state = d->priv; 148751d882edSEvgeny Plehov 1488606142afSJonathan McDowell mutex_lock(&d->data_mutex); 1489606142afSJonathan McDowell 1490606142afSJonathan McDowell state->data[0] = 0xe; 1491606142afSJonathan McDowell state->data[1] = 0x87; 1492606142afSJonathan McDowell state->data[2] = 0x0; 1493606142afSJonathan McDowell 1494606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 149551d882edSEvgeny Plehov err("command 0x0e transfer failed."); 149651d882edSEvgeny Plehov 1497606142afSJonathan McDowell state->data[0] = 0xe; 1498606142afSJonathan McDowell state->data[1] = 0x86; 1499606142afSJonathan McDowell state->data[2] = 1; 15007b71ef7eSCrazyCat 1501606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 15027b71ef7eSCrazyCat err("command 0x0e transfer failed."); 15037b71ef7eSCrazyCat 1504606142afSJonathan McDowell state->data[0] = 0xe; 1505606142afSJonathan McDowell state->data[1] = 0x80; 1506606142afSJonathan McDowell state->data[2] = 0; 150751d882edSEvgeny Plehov 1508606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 150951d882edSEvgeny Plehov err("command 0x0e transfer failed."); 151051d882edSEvgeny Plehov 15117b71ef7eSCrazyCat msleep(50); 151251d882edSEvgeny Plehov 1513606142afSJonathan McDowell state->data[0] = 0xe; 1514606142afSJonathan McDowell state->data[1] = 0x80; 1515606142afSJonathan McDowell state->data[2] = 1; 151651d882edSEvgeny Plehov 1517606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 151851d882edSEvgeny Plehov err("command 0x0e transfer failed."); 151951d882edSEvgeny Plehov 1520606142afSJonathan McDowell state->data[0] = 0x51; 152151d882edSEvgeny Plehov 1522606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) 152351d882edSEvgeny Plehov err("command 0x51 transfer failed."); 152451d882edSEvgeny Plehov 1525606142afSJonathan McDowell mutex_unlock(&d->data_mutex); 1526606142afSJonathan McDowell 1527606142afSJonathan McDowell adap->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config, 1528606142afSJonathan McDowell &d->i2c_adap, NULL); 1529606142afSJonathan McDowell if (adap->fe_adap[0].fe != NULL) { 1530606142afSJonathan McDowell if (dvb_attach(tda18271_attach, adap->fe_adap[0].fe, 0x60, 1531606142afSJonathan McDowell &d->i2c_adap, &tda18271_config)) { 15320385443fSJonathan McDowell info("Attached TDA18271HD/CXD2820R!"); 153351d882edSEvgeny Plehov return 0; 153451d882edSEvgeny Plehov } 153551d882edSEvgeny Plehov } 153651d882edSEvgeny Plehov 15370385443fSJonathan McDowell info("Failed to attach TDA18271HD/CXD2820R!"); 153851d882edSEvgeny Plehov return -EIO; 153951d882edSEvgeny Plehov } 154051d882edSEvgeny Plehov 1541606142afSJonathan McDowell static int m88rs2000_frontend_attach(struct dvb_usb_adapter *adap) 1542955d00acSIgor M. Liplianin { 1543606142afSJonathan McDowell struct dvb_usb_device *d = adap->dev; 1544606142afSJonathan McDowell struct dw2102_state *state = d->priv; 1545955d00acSIgor M. Liplianin 1546606142afSJonathan McDowell mutex_lock(&d->data_mutex); 1547606142afSJonathan McDowell 1548606142afSJonathan McDowell state->data[0] = 0x51; 1549606142afSJonathan McDowell 1550606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) 1551955d00acSIgor M. Liplianin err("command 0x51 transfer failed."); 1552955d00acSIgor M. Liplianin 1553606142afSJonathan McDowell mutex_unlock(&d->data_mutex); 1554b858c331SIgor M. Liplianin 1555606142afSJonathan McDowell adap->fe_adap[0].fe = dvb_attach(m88rs2000_attach, 1556606142afSJonathan McDowell &s421_m88rs2000_config, 1557606142afSJonathan McDowell &d->i2c_adap); 1558606142afSJonathan McDowell 1559606142afSJonathan McDowell if (adap->fe_adap[0].fe == NULL) 1560955d00acSIgor M. Liplianin return -EIO; 1561955d00acSIgor M. Liplianin 1562606142afSJonathan McDowell if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe, 1563b858c331SIgor M. Liplianin &dw2104_ts2020_config, 1564606142afSJonathan McDowell &d->i2c_adap)) { 15650385443fSJonathan McDowell info("Attached RS2000/TS2020!"); 1566955d00acSIgor M. Liplianin return 0; 1567955d00acSIgor M. Liplianin } 1568955d00acSIgor M. Liplianin 15690385443fSJonathan McDowell info("Failed to attach RS2000/TS2020!"); 1570b858c331SIgor M. Liplianin return -EIO; 1571b858c331SIgor M. Liplianin } 1572b858c331SIgor M. Liplianin 1573889968a4SBrad Love static int tt_s2_4600_frontend_attach_probe_demod(struct dvb_usb_device *d, 1574889968a4SBrad Love const int probe_addr) 1575889968a4SBrad Love { 1576889968a4SBrad Love struct dw2102_state *state = d->priv; 1577889968a4SBrad Love 1578889968a4SBrad Love state->data[0] = 0x9; 1579889968a4SBrad Love state->data[1] = 0x1; 1580889968a4SBrad Love state->data[2] = 0x1; 1581889968a4SBrad Love state->data[3] = probe_addr; 1582889968a4SBrad Love state->data[4] = 0x0; 1583889968a4SBrad Love 1584889968a4SBrad Love if (dvb_usb_generic_rw(d, state->data, 5, state->data, 2, 0) < 0) { 1585889968a4SBrad Love err("i2c probe for address 0x%x failed.", probe_addr); 1586889968a4SBrad Love return 0; 1587889968a4SBrad Love } 1588889968a4SBrad Love 1589889968a4SBrad Love if (state->data[0] != 8) /* fail(7) or error, no device at address */ 1590889968a4SBrad Love return 0; 1591889968a4SBrad Love 1592889968a4SBrad Love /* probing successful */ 1593889968a4SBrad Love return 1; 1594889968a4SBrad Love } 1595889968a4SBrad Love 159627254c36SOlli Salonen static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap) 159727254c36SOlli Salonen { 159827254c36SOlli Salonen struct dvb_usb_device *d = adap->dev; 159927254c36SOlli Salonen struct dw2102_state *state = d->priv; 160027254c36SOlli Salonen struct i2c_adapter *i2c_adapter; 160127254c36SOlli Salonen struct i2c_client *client; 1602f3c6abcaSOlli Salonen struct i2c_board_info board_info; 1603f3c6abcaSOlli Salonen struct m88ds3103_platform_data m88ds3103_pdata = {}; 16040fecb6c0SAntti Palosaari struct ts2020_config ts2020_config = {}; 1605889968a4SBrad Love int demod_addr; 160627254c36SOlli Salonen 1607606142afSJonathan McDowell mutex_lock(&d->data_mutex); 1608606142afSJonathan McDowell 1609606142afSJonathan McDowell state->data[0] = 0xe; 1610606142afSJonathan McDowell state->data[1] = 0x80; 1611606142afSJonathan McDowell state->data[2] = 0x0; 1612606142afSJonathan McDowell 1613606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 161427254c36SOlli Salonen err("command 0x0e transfer failed."); 161527254c36SOlli Salonen 1616606142afSJonathan McDowell state->data[0] = 0xe; 1617606142afSJonathan McDowell state->data[1] = 0x02; 1618606142afSJonathan McDowell state->data[2] = 1; 161927254c36SOlli Salonen 1620606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 162127254c36SOlli Salonen err("command 0x0e transfer failed."); 162227254c36SOlli Salonen msleep(300); 162327254c36SOlli Salonen 1624606142afSJonathan McDowell state->data[0] = 0xe; 1625606142afSJonathan McDowell state->data[1] = 0x83; 1626606142afSJonathan McDowell state->data[2] = 0; 162727254c36SOlli Salonen 1628606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 162927254c36SOlli Salonen err("command 0x0e transfer failed."); 163027254c36SOlli Salonen 1631606142afSJonathan McDowell state->data[0] = 0xe; 1632606142afSJonathan McDowell state->data[1] = 0x83; 1633606142afSJonathan McDowell state->data[2] = 1; 163427254c36SOlli Salonen 1635606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 163627254c36SOlli Salonen err("command 0x0e transfer failed."); 163727254c36SOlli Salonen 1638606142afSJonathan McDowell state->data[0] = 0x51; 163927254c36SOlli Salonen 1640606142afSJonathan McDowell if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) 164127254c36SOlli Salonen err("command 0x51 transfer failed."); 164227254c36SOlli Salonen 1643889968a4SBrad Love /* probe for demodulator i2c address */ 1644889968a4SBrad Love demod_addr = -1; 1645889968a4SBrad Love if (tt_s2_4600_frontend_attach_probe_demod(d, 0x68)) 1646889968a4SBrad Love demod_addr = 0x68; 1647889968a4SBrad Love else if (tt_s2_4600_frontend_attach_probe_demod(d, 0x69)) 1648889968a4SBrad Love demod_addr = 0x69; 1649889968a4SBrad Love else if (tt_s2_4600_frontend_attach_probe_demod(d, 0x6a)) 1650889968a4SBrad Love demod_addr = 0x6a; 1651889968a4SBrad Love 1652606142afSJonathan McDowell mutex_unlock(&d->data_mutex); 1653606142afSJonathan McDowell 1654889968a4SBrad Love if (demod_addr < 0) { 1655889968a4SBrad Love err("probing for demodulator failed. Is the external power switched on?"); 1656889968a4SBrad Love return -ENODEV; 1657889968a4SBrad Love } 1658889968a4SBrad Love 1659f3c6abcaSOlli Salonen /* attach demod */ 1660f3c6abcaSOlli Salonen m88ds3103_pdata.clk = 27000000; 1661f3c6abcaSOlli Salonen m88ds3103_pdata.i2c_wr_max = 33; 1662f3c6abcaSOlli Salonen m88ds3103_pdata.ts_mode = M88DS3103_TS_CI; 1663f3c6abcaSOlli Salonen m88ds3103_pdata.ts_clk = 16000; 1664f3c6abcaSOlli Salonen m88ds3103_pdata.ts_clk_pol = 0; 1665f3c6abcaSOlli Salonen m88ds3103_pdata.spec_inv = 0; 1666f3c6abcaSOlli Salonen m88ds3103_pdata.agc = 0x99; 1667f3c6abcaSOlli Salonen m88ds3103_pdata.agc_inv = 0; 1668f3c6abcaSOlli Salonen m88ds3103_pdata.clk_out = M88DS3103_CLOCK_OUT_ENABLED; 1669f3c6abcaSOlli Salonen m88ds3103_pdata.envelope_mode = 0; 1670f3c6abcaSOlli Salonen m88ds3103_pdata.lnb_hv_pol = 1; 1671f3c6abcaSOlli Salonen m88ds3103_pdata.lnb_en_pol = 0; 1672f3c6abcaSOlli Salonen memset(&board_info, 0, sizeof(board_info)); 1673889968a4SBrad Love if (demod_addr == 0x6a) 1674889968a4SBrad Love strscpy(board_info.type, "m88ds3103b", I2C_NAME_SIZE); 1675889968a4SBrad Love else 1676c0decac1SMauro Carvalho Chehab strscpy(board_info.type, "m88ds3103", I2C_NAME_SIZE); 1677889968a4SBrad Love board_info.addr = demod_addr; 1678f3c6abcaSOlli Salonen board_info.platform_data = &m88ds3103_pdata; 1679f3c6abcaSOlli Salonen request_module("m88ds3103"); 1680334f6aafSWolfram Sang client = i2c_new_client_device(&d->i2c_adap, &board_info); 1681334f6aafSWolfram Sang if (!i2c_client_has_driver(client)) 168227254c36SOlli Salonen return -ENODEV; 1683f3c6abcaSOlli Salonen if (!try_module_get(client->dev.driver->owner)) { 1684f3c6abcaSOlli Salonen i2c_unregister_device(client); 1685f3c6abcaSOlli Salonen return -ENODEV; 1686f3c6abcaSOlli Salonen } 1687f3c6abcaSOlli Salonen adap->fe_adap[0].fe = m88ds3103_pdata.get_dvb_frontend(client); 1688f3c6abcaSOlli Salonen i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client); 1689f3c6abcaSOlli Salonen 1690f3c6abcaSOlli Salonen state->i2c_client_demod = client; 169127254c36SOlli Salonen 169227254c36SOlli Salonen /* attach tuner */ 16930fecb6c0SAntti Palosaari ts2020_config.fe = adap->fe_adap[0].fe; 1694f3c6abcaSOlli Salonen memset(&board_info, 0, sizeof(board_info)); 1695c0decac1SMauro Carvalho Chehab strscpy(board_info.type, "ts2022", I2C_NAME_SIZE); 1696f3c6abcaSOlli Salonen board_info.addr = 0x60; 1697f3c6abcaSOlli Salonen board_info.platform_data = &ts2020_config; 16980fecb6c0SAntti Palosaari request_module("ts2020"); 1699334f6aafSWolfram Sang client = i2c_new_client_device(i2c_adapter, &board_info); 170027254c36SOlli Salonen 1701334f6aafSWolfram Sang if (!i2c_client_has_driver(client)) { 170227254c36SOlli Salonen dvb_frontend_detach(adap->fe_adap[0].fe); 170327254c36SOlli Salonen return -ENODEV; 170427254c36SOlli Salonen } 170527254c36SOlli Salonen 170627254c36SOlli Salonen if (!try_module_get(client->dev.driver->owner)) { 170727254c36SOlli Salonen i2c_unregister_device(client); 170827254c36SOlli Salonen dvb_frontend_detach(adap->fe_adap[0].fe); 170927254c36SOlli Salonen return -ENODEV; 171027254c36SOlli Salonen } 171127254c36SOlli Salonen 171227254c36SOlli Salonen /* delegate signal strength measurement to tuner */ 171327254c36SOlli Salonen adap->fe_adap[0].fe->ops.read_signal_strength = 171427254c36SOlli Salonen adap->fe_adap[0].fe->ops.tuner_ops.get_rf_strength; 171527254c36SOlli Salonen 171627254c36SOlli Salonen state->i2c_client_tuner = client; 171727254c36SOlli Salonen 1718356484caSOlli Salonen /* hook fe: need to resync the slave fifo when signal locks */ 1719356484caSOlli Salonen state->fe_read_status = adap->fe_adap[0].fe->ops.read_status; 1720356484caSOlli Salonen adap->fe_adap[0].fe->ops.read_status = tt_s2_4600_read_status; 1721356484caSOlli Salonen 1722356484caSOlli Salonen state->last_lock = 0; 1723356484caSOlli Salonen 172427254c36SOlli Salonen return 0; 172527254c36SOlli Salonen } 172627254c36SOlli Salonen 1727786baecfSMauro Carvalho Chehab static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) 1728786baecfSMauro Carvalho Chehab { 1729786baecfSMauro Carvalho Chehab dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 1730786baecfSMauro Carvalho Chehab &adap->dev->i2c_adap, DVB_PLL_OPERA1); 1731786baecfSMauro Carvalho Chehab return 0; 1732786baecfSMauro Carvalho Chehab } 1733786baecfSMauro Carvalho Chehab 1734786baecfSMauro Carvalho Chehab static int dw3101_tuner_attach(struct dvb_usb_adapter *adap) 1735786baecfSMauro Carvalho Chehab { 1736786baecfSMauro Carvalho Chehab dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 1737786baecfSMauro Carvalho Chehab &adap->dev->i2c_adap, DVB_PLL_TUA6034); 1738786baecfSMauro Carvalho Chehab 1739786baecfSMauro Carvalho Chehab return 0; 1740786baecfSMauro Carvalho Chehab } 1741786baecfSMauro Carvalho Chehab 1742a49de26aSEvgeny Plehov static int dw2102_rc_query(struct dvb_usb_device *d) 1743786baecfSMauro Carvalho Chehab { 1744786baecfSMauro Carvalho Chehab u8 key[2]; 1745786baecfSMauro Carvalho Chehab struct i2c_msg msg = { 1746786baecfSMauro Carvalho Chehab .addr = DW2102_RC_QUERY, 1747786baecfSMauro Carvalho Chehab .flags = I2C_M_RD, 1748786baecfSMauro Carvalho Chehab .buf = key, 1749786baecfSMauro Carvalho Chehab .len = 2 1750786baecfSMauro Carvalho Chehab }; 1751786baecfSMauro Carvalho Chehab 1752786baecfSMauro Carvalho Chehab if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1753a49de26aSEvgeny Plehov if (msg.buf[0] != 0xff) { 1754a49de26aSEvgeny Plehov deb_rc("%s: rc code: %x, %x\n", 1755786baecfSMauro Carvalho Chehab __func__, key[0], key[1]); 17566d741bfeSSean Young rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN, key[0], 0); 1757a49de26aSEvgeny Plehov } 1758a49de26aSEvgeny Plehov } 1759786baecfSMauro Carvalho Chehab 1760a49de26aSEvgeny Plehov return 0; 1761a49de26aSEvgeny Plehov } 1762a49de26aSEvgeny Plehov 1763a49de26aSEvgeny Plehov static int prof_rc_query(struct dvb_usb_device *d) 1764a49de26aSEvgeny Plehov { 1765a49de26aSEvgeny Plehov u8 key[2]; 1766a49de26aSEvgeny Plehov struct i2c_msg msg = { 1767a49de26aSEvgeny Plehov .addr = DW2102_RC_QUERY, 1768a49de26aSEvgeny Plehov .flags = I2C_M_RD, 1769a49de26aSEvgeny Plehov .buf = key, 1770a49de26aSEvgeny Plehov .len = 2 1771a49de26aSEvgeny Plehov }; 1772a49de26aSEvgeny Plehov 1773a49de26aSEvgeny Plehov if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1774a49de26aSEvgeny Plehov if (msg.buf[0] != 0xff) { 1775a49de26aSEvgeny Plehov deb_rc("%s: rc code: %x, %x\n", 1776a49de26aSEvgeny Plehov __func__, key[0], key[1]); 17776d741bfeSSean Young rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN, key[0] ^ 0xff, 17786d741bfeSSean Young 0); 1779a49de26aSEvgeny Plehov } 1780a49de26aSEvgeny Plehov } 1781a49de26aSEvgeny Plehov 1782a49de26aSEvgeny Plehov return 0; 1783a49de26aSEvgeny Plehov } 1784a49de26aSEvgeny Plehov 1785a49de26aSEvgeny Plehov static int su3000_rc_query(struct dvb_usb_device *d) 1786a49de26aSEvgeny Plehov { 1787a49de26aSEvgeny Plehov u8 key[2]; 1788a49de26aSEvgeny Plehov struct i2c_msg msg = { 1789a49de26aSEvgeny Plehov .addr = DW2102_RC_QUERY, 1790a49de26aSEvgeny Plehov .flags = I2C_M_RD, 1791a49de26aSEvgeny Plehov .buf = key, 1792a49de26aSEvgeny Plehov .len = 2 1793a49de26aSEvgeny Plehov }; 1794a49de26aSEvgeny Plehov 1795a49de26aSEvgeny Plehov if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1796a49de26aSEvgeny Plehov if (msg.buf[0] != 0xff) { 1797a49de26aSEvgeny Plehov deb_rc("%s: rc code: %x, %x\n", 1798a49de26aSEvgeny Plehov __func__, key[0], key[1]); 17996d741bfeSSean Young rc_keydown(d->rc_dev, RC_PROTO_RC5, 1800120703f9SDavid Härdeman RC_SCANCODE_RC5(key[1], key[0]), 0); 1801a49de26aSEvgeny Plehov } 1802786baecfSMauro Carvalho Chehab } 1803786baecfSMauro Carvalho Chehab 1804786baecfSMauro Carvalho Chehab return 0; 1805786baecfSMauro Carvalho Chehab } 1806786baecfSMauro Carvalho Chehab 1807786baecfSMauro Carvalho Chehab enum dw2102_table_entry { 1808786baecfSMauro Carvalho Chehab CYPRESS_DW2102, 1809786baecfSMauro Carvalho Chehab CYPRESS_DW2101, 1810786baecfSMauro Carvalho Chehab CYPRESS_DW2104, 1811786baecfSMauro Carvalho Chehab TEVII_S650, 1812786baecfSMauro Carvalho Chehab TERRATEC_CINERGY_S, 1813786baecfSMauro Carvalho Chehab CYPRESS_DW3101, 1814786baecfSMauro Carvalho Chehab TEVII_S630, 1815786baecfSMauro Carvalho Chehab PROF_1100, 1816786baecfSMauro Carvalho Chehab TEVII_S660, 1817786baecfSMauro Carvalho Chehab PROF_7500, 1818786baecfSMauro Carvalho Chehab GENIATECH_SU3000, 18199cd4bcfbSKai Muenz HAUPPAUGE_MAX_S2, 18202fa2002fSMauro Carvalho Chehab TERRATEC_CINERGY_S2_R1, 1821786baecfSMauro Carvalho Chehab TEVII_S480_1, 1822786baecfSMauro Carvalho Chehab TEVII_S480_2, 18232fa2002fSMauro Carvalho Chehab GENIATECH_X3M_SPC1400HD, 1824955d00acSIgor M. Liplianin TEVII_S421, 1825955d00acSIgor M. Liplianin TEVII_S632, 182644122dd6SIgor M. Liplianin TERRATEC_CINERGY_S2_R2, 182749438d97SOlli Salonen TERRATEC_CINERGY_S2_R3, 182869fd825cSEnrico Mioso TERRATEC_CINERGY_S2_R4, 1829528b1a1aSDirk Nehring TERRATEC_CINERGY_S2_1, 1830528b1a1aSDirk Nehring TERRATEC_CINERGY_S2_2, 1831f08e9f0dSAndrey Pavlenko GOTVIEW_SAT_HD, 183251d882edSEvgeny Plehov GENIATECH_T220, 18332fa2002fSMauro Carvalho Chehab TECHNOTREND_CONNECT_S2_4600, 183444767fc4SOlli Salonen TEVII_S482_1, 183544767fc4SOlli Salonen TEVII_S482_2, 18366ede20f9SOlli Salonen TEVII_S662 1837786baecfSMauro Carvalho Chehab }; 1838786baecfSMauro Carvalho Chehab 1839786baecfSMauro Carvalho Chehab static struct usb_device_id dw2102_table[] = { 18402fa2002fSMauro Carvalho Chehab DVB_USB_DEV(CYPRESS, CYPRESS_DW2102), 18412fa2002fSMauro Carvalho Chehab DVB_USB_DEV(CYPRESS, CYPRESS_DW2101), 18422fa2002fSMauro Carvalho Chehab DVB_USB_DEV(CYPRESS, CYPRESS_DW2104), 18432fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S650), 18442fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S), 18452fa2002fSMauro Carvalho Chehab DVB_USB_DEV(CYPRESS, CYPRESS_DW3101), 18462fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S630), 18472fa2002fSMauro Carvalho Chehab DVB_USB_DEV(PROF_1, PROF_1100), 18482fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S660), 18492fa2002fSMauro Carvalho Chehab DVB_USB_DEV(PROF_2, PROF_7500), 18502fa2002fSMauro Carvalho Chehab DVB_USB_DEV(GTEK, GENIATECH_SU3000), 18512fa2002fSMauro Carvalho Chehab DVB_USB_DEV(HAUPPAUGE, HAUPPAUGE_MAX_S2), 18522fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S2_R1), 18532fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S480_1), 18542fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S480_2), 18552fa2002fSMauro Carvalho Chehab DVB_USB_DEV(GTEK, GENIATECH_X3M_SPC1400HD), 18562fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S421), 18572fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S632), 18582fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S2_R2), 18592fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S2_R3), 18602fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S2_R4), 18612fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TERRATEC_2, TERRATEC_CINERGY_S2_1), 18622fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TERRATEC_2, TERRATEC_CINERGY_S2_2), 18632fa2002fSMauro Carvalho Chehab DVB_USB_DEV(GOTVIEW, GOTVIEW_SAT_HD), 18642fa2002fSMauro Carvalho Chehab DVB_USB_DEV(GTEK, GENIATECH_T220), 18652fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TECHNOTREND, TECHNOTREND_CONNECT_S2_4600), 18662fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S482_1), 18672fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S482_2), 18682fa2002fSMauro Carvalho Chehab DVB_USB_DEV(TEVII, TEVII_S662), 1869786baecfSMauro Carvalho Chehab { } 1870786baecfSMauro Carvalho Chehab }; 1871786baecfSMauro Carvalho Chehab 1872786baecfSMauro Carvalho Chehab MODULE_DEVICE_TABLE(usb, dw2102_table); 1873786baecfSMauro Carvalho Chehab 1874786baecfSMauro Carvalho Chehab static int dw2102_load_firmware(struct usb_device *dev, 1875786baecfSMauro Carvalho Chehab const struct firmware *frmwr) 1876786baecfSMauro Carvalho Chehab { 1877786baecfSMauro Carvalho Chehab u8 *b, *p; 1878786baecfSMauro Carvalho Chehab int ret = 0, i; 1879786baecfSMauro Carvalho Chehab u8 reset; 1880786baecfSMauro Carvalho Chehab u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; 1881786baecfSMauro Carvalho Chehab const struct firmware *fw; 1882786baecfSMauro Carvalho Chehab 18831ad5d064SHans Verkuil switch (le16_to_cpu(dev->descriptor.idProduct)) { 1884786baecfSMauro Carvalho Chehab case 0x2101: 18856823627bSRémi Cardona ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev); 1886786baecfSMauro Carvalho Chehab if (ret != 0) { 18876823627bSRémi Cardona err(err_str, DW2101_FIRMWARE); 1888786baecfSMauro Carvalho Chehab return ret; 1889786baecfSMauro Carvalho Chehab } 1890786baecfSMauro Carvalho Chehab break; 1891786baecfSMauro Carvalho Chehab default: 1892786baecfSMauro Carvalho Chehab fw = frmwr; 1893786baecfSMauro Carvalho Chehab break; 1894786baecfSMauro Carvalho Chehab } 1895786baecfSMauro Carvalho Chehab info("start downloading DW210X firmware"); 1896786baecfSMauro Carvalho Chehab p = kmalloc(fw->size, GFP_KERNEL); 1897786baecfSMauro Carvalho Chehab reset = 1; 1898786baecfSMauro Carvalho Chehab /*stop the CPU*/ 1899786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG); 1900786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG); 1901786baecfSMauro Carvalho Chehab 1902786baecfSMauro Carvalho Chehab if (p != NULL) { 1903786baecfSMauro Carvalho Chehab memcpy(p, fw->data, fw->size); 1904786baecfSMauro Carvalho Chehab for (i = 0; i < fw->size; i += 0x40) { 1905786baecfSMauro Carvalho Chehab b = (u8 *) p + i; 1906786baecfSMauro Carvalho Chehab if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40, 1907786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG) != 0x40) { 1908786baecfSMauro Carvalho Chehab err("error while transferring firmware"); 1909786baecfSMauro Carvalho Chehab ret = -EINVAL; 1910786baecfSMauro Carvalho Chehab break; 1911786baecfSMauro Carvalho Chehab } 1912786baecfSMauro Carvalho Chehab } 1913786baecfSMauro Carvalho Chehab /* restart the CPU */ 1914786baecfSMauro Carvalho Chehab reset = 0; 1915786baecfSMauro Carvalho Chehab if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, 1916786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG) != 1) { 1917786baecfSMauro Carvalho Chehab err("could not restart the USB controller CPU."); 1918786baecfSMauro Carvalho Chehab ret = -EINVAL; 1919786baecfSMauro Carvalho Chehab } 1920786baecfSMauro Carvalho Chehab if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, 1921786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG) != 1) { 1922786baecfSMauro Carvalho Chehab err("could not restart the USB controller CPU."); 1923786baecfSMauro Carvalho Chehab ret = -EINVAL; 1924786baecfSMauro Carvalho Chehab } 1925786baecfSMauro Carvalho Chehab /* init registers */ 19261ad5d064SHans Verkuil switch (le16_to_cpu(dev->descriptor.idProduct)) { 1927786baecfSMauro Carvalho Chehab case USB_PID_TEVII_S650: 1928a49de26aSEvgeny Plehov dw2104_properties.rc.core.rc_codes = RC_MAP_TEVII_NEC; 1929df561f66SGustavo A. R. Silva fallthrough; 19302fa2002fSMauro Carvalho Chehab case USB_PID_CYPRESS_DW2104: 1931786baecfSMauro Carvalho Chehab reset = 1; 1932786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, 1933786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 1934df561f66SGustavo A. R. Silva fallthrough; 19352fa2002fSMauro Carvalho Chehab case USB_PID_CYPRESS_DW3101: 1936786baecfSMauro Carvalho Chehab reset = 0; 1937786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 1938786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 1939786baecfSMauro Carvalho Chehab break; 1940e8364275SMauro Carvalho Chehab case USB_PID_TERRATEC_CINERGY_S: 19412fa2002fSMauro Carvalho Chehab case USB_PID_CYPRESS_DW2102: 1942786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 1943786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 1944786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 1945786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1946786baecfSMauro Carvalho Chehab /* check STV0299 frontend */ 1947786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2, 1948786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1949786baecfSMauro Carvalho Chehab if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) { 1950786baecfSMauro Carvalho Chehab dw2102_properties.i2c_algo = &dw2102_i2c_algo; 1951786baecfSMauro Carvalho Chehab dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach; 1952786baecfSMauro Carvalho Chehab break; 1953786baecfSMauro Carvalho Chehab } else { 1954786baecfSMauro Carvalho Chehab /* check STV0288 frontend */ 1955786baecfSMauro Carvalho Chehab reset16[0] = 0xd0; 1956786baecfSMauro Carvalho Chehab reset16[1] = 1; 1957786baecfSMauro Carvalho Chehab reset16[2] = 0; 1958786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, 1959786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 1960786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, 1961786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1962786baecfSMauro Carvalho Chehab if (reset16[2] == 0x11) { 1963786baecfSMauro Carvalho Chehab dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; 1964786baecfSMauro Carvalho Chehab break; 1965786baecfSMauro Carvalho Chehab } 1966786baecfSMauro Carvalho Chehab } 1967df561f66SGustavo A. R. Silva fallthrough; 1968786baecfSMauro Carvalho Chehab case 0x2101: 1969786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, 1970786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1971786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 1972786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1973786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 1974786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1975786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 1976786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1977786baecfSMauro Carvalho Chehab break; 1978786baecfSMauro Carvalho Chehab } 1979786baecfSMauro Carvalho Chehab 1980786baecfSMauro Carvalho Chehab msleep(100); 1981786baecfSMauro Carvalho Chehab kfree(p); 1982786baecfSMauro Carvalho Chehab } 19832a518f8eSSudip Mukherjee 19842a518f8eSSudip Mukherjee if (le16_to_cpu(dev->descriptor.idProduct) == 0x2101) 19852a518f8eSSudip Mukherjee release_firmware(fw); 1986786baecfSMauro Carvalho Chehab return ret; 1987786baecfSMauro Carvalho Chehab } 1988786baecfSMauro Carvalho Chehab 1989786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2102_properties = { 1990786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1991786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 19926823627bSRémi Cardona .firmware = DW2102_FIRMWARE, 1993786baecfSMauro Carvalho Chehab .no_reconnect = 1, 1994786baecfSMauro Carvalho Chehab 1995786baecfSMauro Carvalho Chehab .i2c_algo = &dw2102_serit_i2c_algo, 1996786baecfSMauro Carvalho Chehab 1997a49de26aSEvgeny Plehov .rc.core = { 1998786baecfSMauro Carvalho Chehab .rc_interval = 150, 1999a49de26aSEvgeny Plehov .rc_codes = RC_MAP_DM1105_NEC, 2000a49de26aSEvgeny Plehov .module_name = "dw2102", 20016d741bfeSSean Young .allowed_protos = RC_PROTO_BIT_NEC, 2002786baecfSMauro Carvalho Chehab .rc_query = dw2102_rc_query, 2003786baecfSMauro Carvalho Chehab }, 2004786baecfSMauro Carvalho Chehab 2005786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x81, 2006786baecfSMauro Carvalho Chehab /* parameter for the MPEG2-data transfer */ 2007786baecfSMauro Carvalho Chehab .num_adapters = 1, 2008786baecfSMauro Carvalho Chehab .download_firmware = dw2102_load_firmware, 2009786baecfSMauro Carvalho Chehab .read_mac_address = dw210x_read_mac_address, 2010786baecfSMauro Carvalho Chehab .adapter = { 2011786baecfSMauro Carvalho Chehab { 2012786baecfSMauro Carvalho Chehab .num_frontends = 1, 2013786baecfSMauro Carvalho Chehab .fe = {{ 2014786baecfSMauro Carvalho Chehab .frontend_attach = dw2102_frontend_attach, 2015786baecfSMauro Carvalho Chehab .stream = { 2016786baecfSMauro Carvalho Chehab .type = USB_BULK, 2017786baecfSMauro Carvalho Chehab .count = 8, 2018786baecfSMauro Carvalho Chehab .endpoint = 0x82, 2019786baecfSMauro Carvalho Chehab .u = { 2020786baecfSMauro Carvalho Chehab .bulk = { 2021786baecfSMauro Carvalho Chehab .buffersize = 4096, 2022786baecfSMauro Carvalho Chehab } 2023786baecfSMauro Carvalho Chehab } 2024786baecfSMauro Carvalho Chehab }, 2025786baecfSMauro Carvalho Chehab }}, 2026786baecfSMauro Carvalho Chehab } 2027786baecfSMauro Carvalho Chehab }, 2028786baecfSMauro Carvalho Chehab .num_device_descs = 3, 2029786baecfSMauro Carvalho Chehab .devices = { 2030786baecfSMauro Carvalho Chehab {"DVBWorld DVB-S 2102 USB2.0", 2031786baecfSMauro Carvalho Chehab {&dw2102_table[CYPRESS_DW2102], NULL}, 2032786baecfSMauro Carvalho Chehab {NULL}, 2033786baecfSMauro Carvalho Chehab }, 2034786baecfSMauro Carvalho Chehab {"DVBWorld DVB-S 2101 USB2.0", 2035786baecfSMauro Carvalho Chehab {&dw2102_table[CYPRESS_DW2101], NULL}, 2036786baecfSMauro Carvalho Chehab {NULL}, 2037786baecfSMauro Carvalho Chehab }, 2038786baecfSMauro Carvalho Chehab {"TerraTec Cinergy S USB", 2039786baecfSMauro Carvalho Chehab {&dw2102_table[TERRATEC_CINERGY_S], NULL}, 2040786baecfSMauro Carvalho Chehab {NULL}, 2041786baecfSMauro Carvalho Chehab }, 2042786baecfSMauro Carvalho Chehab } 2043786baecfSMauro Carvalho Chehab }; 2044786baecfSMauro Carvalho Chehab 2045786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2104_properties = { 2046786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2047786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 20486823627bSRémi Cardona .firmware = DW2104_FIRMWARE, 2049786baecfSMauro Carvalho Chehab .no_reconnect = 1, 2050786baecfSMauro Carvalho Chehab 2051786baecfSMauro Carvalho Chehab .i2c_algo = &dw2104_i2c_algo, 2052a49de26aSEvgeny Plehov .rc.core = { 2053786baecfSMauro Carvalho Chehab .rc_interval = 150, 2054a49de26aSEvgeny Plehov .rc_codes = RC_MAP_DM1105_NEC, 2055a49de26aSEvgeny Plehov .module_name = "dw2102", 20566d741bfeSSean Young .allowed_protos = RC_PROTO_BIT_NEC, 2057786baecfSMauro Carvalho Chehab .rc_query = dw2102_rc_query, 2058786baecfSMauro Carvalho Chehab }, 2059786baecfSMauro Carvalho Chehab 2060786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x81, 2061786baecfSMauro Carvalho Chehab /* parameter for the MPEG2-data transfer */ 2062786baecfSMauro Carvalho Chehab .num_adapters = 1, 2063786baecfSMauro Carvalho Chehab .download_firmware = dw2102_load_firmware, 2064786baecfSMauro Carvalho Chehab .read_mac_address = dw210x_read_mac_address, 2065786baecfSMauro Carvalho Chehab .adapter = { 2066786baecfSMauro Carvalho Chehab { 2067786baecfSMauro Carvalho Chehab .num_frontends = 1, 2068786baecfSMauro Carvalho Chehab .fe = {{ 2069786baecfSMauro Carvalho Chehab .frontend_attach = dw2104_frontend_attach, 2070786baecfSMauro Carvalho Chehab .stream = { 2071786baecfSMauro Carvalho Chehab .type = USB_BULK, 2072786baecfSMauro Carvalho Chehab .count = 8, 2073786baecfSMauro Carvalho Chehab .endpoint = 0x82, 2074786baecfSMauro Carvalho Chehab .u = { 2075786baecfSMauro Carvalho Chehab .bulk = { 2076786baecfSMauro Carvalho Chehab .buffersize = 4096, 2077786baecfSMauro Carvalho Chehab } 2078786baecfSMauro Carvalho Chehab } 2079786baecfSMauro Carvalho Chehab }, 2080786baecfSMauro Carvalho Chehab }}, 2081786baecfSMauro Carvalho Chehab } 2082786baecfSMauro Carvalho Chehab }, 2083786baecfSMauro Carvalho Chehab .num_device_descs = 2, 2084786baecfSMauro Carvalho Chehab .devices = { 2085786baecfSMauro Carvalho Chehab { "DVBWorld DW2104 USB2.0", 2086786baecfSMauro Carvalho Chehab {&dw2102_table[CYPRESS_DW2104], NULL}, 2087786baecfSMauro Carvalho Chehab {NULL}, 2088786baecfSMauro Carvalho Chehab }, 2089786baecfSMauro Carvalho Chehab { "TeVii S650 USB2.0", 2090786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S650], NULL}, 2091786baecfSMauro Carvalho Chehab {NULL}, 2092786baecfSMauro Carvalho Chehab }, 2093786baecfSMauro Carvalho Chehab } 2094786baecfSMauro Carvalho Chehab }; 2095786baecfSMauro Carvalho Chehab 2096786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw3101_properties = { 2097786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2098786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 20996823627bSRémi Cardona .firmware = DW3101_FIRMWARE, 2100786baecfSMauro Carvalho Chehab .no_reconnect = 1, 2101786baecfSMauro Carvalho Chehab 2102786baecfSMauro Carvalho Chehab .i2c_algo = &dw3101_i2c_algo, 2103a49de26aSEvgeny Plehov .rc.core = { 2104786baecfSMauro Carvalho Chehab .rc_interval = 150, 2105a49de26aSEvgeny Plehov .rc_codes = RC_MAP_DM1105_NEC, 2106a49de26aSEvgeny Plehov .module_name = "dw2102", 21076d741bfeSSean Young .allowed_protos = RC_PROTO_BIT_NEC, 2108786baecfSMauro Carvalho Chehab .rc_query = dw2102_rc_query, 2109786baecfSMauro Carvalho Chehab }, 2110786baecfSMauro Carvalho Chehab 2111786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x81, 2112786baecfSMauro Carvalho Chehab /* parameter for the MPEG2-data transfer */ 2113786baecfSMauro Carvalho Chehab .num_adapters = 1, 2114786baecfSMauro Carvalho Chehab .download_firmware = dw2102_load_firmware, 2115786baecfSMauro Carvalho Chehab .read_mac_address = dw210x_read_mac_address, 2116786baecfSMauro Carvalho Chehab .adapter = { 2117786baecfSMauro Carvalho Chehab { 2118786baecfSMauro Carvalho Chehab .num_frontends = 1, 2119786baecfSMauro Carvalho Chehab .fe = {{ 2120786baecfSMauro Carvalho Chehab .frontend_attach = dw3101_frontend_attach, 2121786baecfSMauro Carvalho Chehab .tuner_attach = dw3101_tuner_attach, 2122786baecfSMauro Carvalho Chehab .stream = { 2123786baecfSMauro Carvalho Chehab .type = USB_BULK, 2124786baecfSMauro Carvalho Chehab .count = 8, 2125786baecfSMauro Carvalho Chehab .endpoint = 0x82, 2126786baecfSMauro Carvalho Chehab .u = { 2127786baecfSMauro Carvalho Chehab .bulk = { 2128786baecfSMauro Carvalho Chehab .buffersize = 4096, 2129786baecfSMauro Carvalho Chehab } 2130786baecfSMauro Carvalho Chehab } 2131786baecfSMauro Carvalho Chehab }, 2132786baecfSMauro Carvalho Chehab }}, 2133786baecfSMauro Carvalho Chehab } 2134786baecfSMauro Carvalho Chehab }, 2135786baecfSMauro Carvalho Chehab .num_device_descs = 1, 2136786baecfSMauro Carvalho Chehab .devices = { 2137786baecfSMauro Carvalho Chehab { "DVBWorld DVB-C 3101 USB2.0", 2138786baecfSMauro Carvalho Chehab {&dw2102_table[CYPRESS_DW3101], NULL}, 2139786baecfSMauro Carvalho Chehab {NULL}, 2140786baecfSMauro Carvalho Chehab }, 2141786baecfSMauro Carvalho Chehab } 2142786baecfSMauro Carvalho Chehab }; 2143786baecfSMauro Carvalho Chehab 2144786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties s6x0_properties = { 2145786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2146786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 21472c4ffe27SOlli Salonen .size_of_priv = sizeof(struct dw2102_state), 21486823627bSRémi Cardona .firmware = S630_FIRMWARE, 2149786baecfSMauro Carvalho Chehab .no_reconnect = 1, 2150786baecfSMauro Carvalho Chehab 2151786baecfSMauro Carvalho Chehab .i2c_algo = &s6x0_i2c_algo, 2152a49de26aSEvgeny Plehov .rc.core = { 2153786baecfSMauro Carvalho Chehab .rc_interval = 150, 2154a49de26aSEvgeny Plehov .rc_codes = RC_MAP_TEVII_NEC, 2155a49de26aSEvgeny Plehov .module_name = "dw2102", 21566d741bfeSSean Young .allowed_protos = RC_PROTO_BIT_NEC, 2157786baecfSMauro Carvalho Chehab .rc_query = dw2102_rc_query, 2158786baecfSMauro Carvalho Chehab }, 2159786baecfSMauro Carvalho Chehab 2160786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x81, 2161786baecfSMauro Carvalho Chehab .num_adapters = 1, 2162786baecfSMauro Carvalho Chehab .download_firmware = dw2102_load_firmware, 2163786baecfSMauro Carvalho Chehab .read_mac_address = s6x0_read_mac_address, 2164786baecfSMauro Carvalho Chehab .adapter = { 2165786baecfSMauro Carvalho Chehab { 2166786baecfSMauro Carvalho Chehab .num_frontends = 1, 2167786baecfSMauro Carvalho Chehab .fe = {{ 2168786baecfSMauro Carvalho Chehab .frontend_attach = zl100313_frontend_attach, 2169786baecfSMauro Carvalho Chehab .stream = { 2170786baecfSMauro Carvalho Chehab .type = USB_BULK, 2171786baecfSMauro Carvalho Chehab .count = 8, 2172786baecfSMauro Carvalho Chehab .endpoint = 0x82, 2173786baecfSMauro Carvalho Chehab .u = { 2174786baecfSMauro Carvalho Chehab .bulk = { 2175786baecfSMauro Carvalho Chehab .buffersize = 4096, 2176786baecfSMauro Carvalho Chehab } 2177786baecfSMauro Carvalho Chehab } 2178786baecfSMauro Carvalho Chehab }, 2179786baecfSMauro Carvalho Chehab }}, 2180786baecfSMauro Carvalho Chehab } 2181786baecfSMauro Carvalho Chehab }, 2182786baecfSMauro Carvalho Chehab .num_device_descs = 1, 2183786baecfSMauro Carvalho Chehab .devices = { 2184786baecfSMauro Carvalho Chehab {"TeVii S630 USB", 2185786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S630], NULL}, 2186786baecfSMauro Carvalho Chehab {NULL}, 2187786baecfSMauro Carvalho Chehab }, 2188786baecfSMauro Carvalho Chehab } 2189786baecfSMauro Carvalho Chehab }; 2190786baecfSMauro Carvalho Chehab 2191589a9f0eSAnton Vasilyev static struct dvb_usb_device_properties p1100_properties = { 2192589a9f0eSAnton Vasilyev .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2193589a9f0eSAnton Vasilyev .usb_ctrl = DEVICE_SPECIFIC, 2194589a9f0eSAnton Vasilyev .size_of_priv = sizeof(struct dw2102_state), 2195589a9f0eSAnton Vasilyev .firmware = P1100_FIRMWARE, 2196589a9f0eSAnton Vasilyev .no_reconnect = 1, 2197589a9f0eSAnton Vasilyev 2198589a9f0eSAnton Vasilyev .i2c_algo = &s6x0_i2c_algo, 2199589a9f0eSAnton Vasilyev .rc.core = { 2200589a9f0eSAnton Vasilyev .rc_interval = 150, 2201589a9f0eSAnton Vasilyev .rc_codes = RC_MAP_TBS_NEC, 2202589a9f0eSAnton Vasilyev .module_name = "dw2102", 2203589a9f0eSAnton Vasilyev .allowed_protos = RC_PROTO_BIT_NEC, 2204589a9f0eSAnton Vasilyev .rc_query = prof_rc_query, 2205589a9f0eSAnton Vasilyev }, 2206589a9f0eSAnton Vasilyev 2207589a9f0eSAnton Vasilyev .generic_bulk_ctrl_endpoint = 0x81, 2208589a9f0eSAnton Vasilyev .num_adapters = 1, 2209589a9f0eSAnton Vasilyev .download_firmware = dw2102_load_firmware, 2210589a9f0eSAnton Vasilyev .read_mac_address = s6x0_read_mac_address, 2211589a9f0eSAnton Vasilyev .adapter = { 2212589a9f0eSAnton Vasilyev { 2213589a9f0eSAnton Vasilyev .num_frontends = 1, 2214589a9f0eSAnton Vasilyev .fe = {{ 2215589a9f0eSAnton Vasilyev .frontend_attach = stv0288_frontend_attach, 2216589a9f0eSAnton Vasilyev .stream = { 2217589a9f0eSAnton Vasilyev .type = USB_BULK, 2218589a9f0eSAnton Vasilyev .count = 8, 2219589a9f0eSAnton Vasilyev .endpoint = 0x82, 2220589a9f0eSAnton Vasilyev .u = { 2221589a9f0eSAnton Vasilyev .bulk = { 2222589a9f0eSAnton Vasilyev .buffersize = 4096, 2223589a9f0eSAnton Vasilyev } 2224589a9f0eSAnton Vasilyev } 2225589a9f0eSAnton Vasilyev }, 2226589a9f0eSAnton Vasilyev } }, 2227589a9f0eSAnton Vasilyev } 2228589a9f0eSAnton Vasilyev }, 2229589a9f0eSAnton Vasilyev .num_device_descs = 1, 2230589a9f0eSAnton Vasilyev .devices = { 2231589a9f0eSAnton Vasilyev {"Prof 1100 USB ", 2232786baecfSMauro Carvalho Chehab {&dw2102_table[PROF_1100], NULL}, 2233786baecfSMauro Carvalho Chehab {NULL}, 2234589a9f0eSAnton Vasilyev }, 2235589a9f0eSAnton Vasilyev } 2236786baecfSMauro Carvalho Chehab }; 2237786baecfSMauro Carvalho Chehab 2238589a9f0eSAnton Vasilyev static struct dvb_usb_device_properties s660_properties = { 2239589a9f0eSAnton Vasilyev .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2240589a9f0eSAnton Vasilyev .usb_ctrl = DEVICE_SPECIFIC, 2241589a9f0eSAnton Vasilyev .size_of_priv = sizeof(struct dw2102_state), 2242589a9f0eSAnton Vasilyev .firmware = S660_FIRMWARE, 2243589a9f0eSAnton Vasilyev .no_reconnect = 1, 2244589a9f0eSAnton Vasilyev 2245589a9f0eSAnton Vasilyev .i2c_algo = &s6x0_i2c_algo, 2246589a9f0eSAnton Vasilyev .rc.core = { 2247589a9f0eSAnton Vasilyev .rc_interval = 150, 2248589a9f0eSAnton Vasilyev .rc_codes = RC_MAP_TEVII_NEC, 2249589a9f0eSAnton Vasilyev .module_name = "dw2102", 2250589a9f0eSAnton Vasilyev .allowed_protos = RC_PROTO_BIT_NEC, 2251589a9f0eSAnton Vasilyev .rc_query = dw2102_rc_query, 2252589a9f0eSAnton Vasilyev }, 2253589a9f0eSAnton Vasilyev 2254589a9f0eSAnton Vasilyev .generic_bulk_ctrl_endpoint = 0x81, 2255589a9f0eSAnton Vasilyev .num_adapters = 1, 2256589a9f0eSAnton Vasilyev .download_firmware = dw2102_load_firmware, 2257589a9f0eSAnton Vasilyev .read_mac_address = s6x0_read_mac_address, 2258589a9f0eSAnton Vasilyev .adapter = { 2259589a9f0eSAnton Vasilyev { 2260589a9f0eSAnton Vasilyev .num_frontends = 1, 2261589a9f0eSAnton Vasilyev .fe = {{ 2262589a9f0eSAnton Vasilyev .frontend_attach = ds3000_frontend_attach, 2263589a9f0eSAnton Vasilyev .stream = { 2264589a9f0eSAnton Vasilyev .type = USB_BULK, 2265589a9f0eSAnton Vasilyev .count = 8, 2266589a9f0eSAnton Vasilyev .endpoint = 0x82, 2267589a9f0eSAnton Vasilyev .u = { 2268589a9f0eSAnton Vasilyev .bulk = { 2269589a9f0eSAnton Vasilyev .buffersize = 4096, 2270589a9f0eSAnton Vasilyev } 2271589a9f0eSAnton Vasilyev } 2272589a9f0eSAnton Vasilyev }, 2273589a9f0eSAnton Vasilyev } }, 2274589a9f0eSAnton Vasilyev } 2275589a9f0eSAnton Vasilyev }, 2276589a9f0eSAnton Vasilyev .num_device_descs = 3, 2277589a9f0eSAnton Vasilyev .devices = { 2278589a9f0eSAnton Vasilyev {"TeVii S660 USB", 2279786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S660], NULL}, 2280786baecfSMauro Carvalho Chehab {NULL}, 2281589a9f0eSAnton Vasilyev }, 2282589a9f0eSAnton Vasilyev {"TeVii S480.1 USB", 2283786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S480_1], NULL}, 2284786baecfSMauro Carvalho Chehab {NULL}, 2285589a9f0eSAnton Vasilyev }, 2286589a9f0eSAnton Vasilyev {"TeVii S480.2 USB", 2287786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S480_2], NULL}, 2288786baecfSMauro Carvalho Chehab {NULL}, 2289589a9f0eSAnton Vasilyev }, 2290589a9f0eSAnton Vasilyev } 2291786baecfSMauro Carvalho Chehab }; 2292786baecfSMauro Carvalho Chehab 2293589a9f0eSAnton Vasilyev static struct dvb_usb_device_properties p7500_properties = { 2294589a9f0eSAnton Vasilyev .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2295589a9f0eSAnton Vasilyev .usb_ctrl = DEVICE_SPECIFIC, 2296589a9f0eSAnton Vasilyev .size_of_priv = sizeof(struct dw2102_state), 2297589a9f0eSAnton Vasilyev .firmware = P7500_FIRMWARE, 2298589a9f0eSAnton Vasilyev .no_reconnect = 1, 2299589a9f0eSAnton Vasilyev 2300589a9f0eSAnton Vasilyev .i2c_algo = &s6x0_i2c_algo, 2301589a9f0eSAnton Vasilyev .rc.core = { 2302589a9f0eSAnton Vasilyev .rc_interval = 150, 2303589a9f0eSAnton Vasilyev .rc_codes = RC_MAP_TBS_NEC, 2304589a9f0eSAnton Vasilyev .module_name = "dw2102", 2305589a9f0eSAnton Vasilyev .allowed_protos = RC_PROTO_BIT_NEC, 2306589a9f0eSAnton Vasilyev .rc_query = prof_rc_query, 2307589a9f0eSAnton Vasilyev }, 2308589a9f0eSAnton Vasilyev 2309589a9f0eSAnton Vasilyev .generic_bulk_ctrl_endpoint = 0x81, 2310589a9f0eSAnton Vasilyev .num_adapters = 1, 2311589a9f0eSAnton Vasilyev .download_firmware = dw2102_load_firmware, 2312589a9f0eSAnton Vasilyev .read_mac_address = s6x0_read_mac_address, 2313589a9f0eSAnton Vasilyev .adapter = { 2314589a9f0eSAnton Vasilyev { 2315589a9f0eSAnton Vasilyev .num_frontends = 1, 2316589a9f0eSAnton Vasilyev .fe = {{ 2317589a9f0eSAnton Vasilyev .frontend_attach = prof_7500_frontend_attach, 2318589a9f0eSAnton Vasilyev .stream = { 2319589a9f0eSAnton Vasilyev .type = USB_BULK, 2320589a9f0eSAnton Vasilyev .count = 8, 2321589a9f0eSAnton Vasilyev .endpoint = 0x82, 2322589a9f0eSAnton Vasilyev .u = { 2323589a9f0eSAnton Vasilyev .bulk = { 2324589a9f0eSAnton Vasilyev .buffersize = 4096, 2325589a9f0eSAnton Vasilyev } 2326589a9f0eSAnton Vasilyev } 2327589a9f0eSAnton Vasilyev }, 2328589a9f0eSAnton Vasilyev } }, 2329589a9f0eSAnton Vasilyev } 2330589a9f0eSAnton Vasilyev }, 2331589a9f0eSAnton Vasilyev .num_device_descs = 1, 2332589a9f0eSAnton Vasilyev .devices = { 2333589a9f0eSAnton Vasilyev {"Prof 7500 USB DVB-S2", 2334786baecfSMauro Carvalho Chehab {&dw2102_table[PROF_7500], NULL}, 2335786baecfSMauro Carvalho Chehab {NULL}, 2336589a9f0eSAnton Vasilyev }, 2337589a9f0eSAnton Vasilyev } 2338955d00acSIgor M. Liplianin }; 2339955d00acSIgor M. Liplianin 2340786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties su3000_properties = { 2341786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2342786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 23432c4ffe27SOlli Salonen .size_of_priv = sizeof(struct dw2102_state), 2344786baecfSMauro Carvalho Chehab .power_ctrl = su3000_power_ctrl, 2345786baecfSMauro Carvalho Chehab .num_adapters = 1, 2346786baecfSMauro Carvalho Chehab .identify_state = su3000_identify_state, 2347786baecfSMauro Carvalho Chehab .i2c_algo = &su3000_i2c_algo, 2348786baecfSMauro Carvalho Chehab 2349a49de26aSEvgeny Plehov .rc.core = { 2350786baecfSMauro Carvalho Chehab .rc_interval = 150, 2351a49de26aSEvgeny Plehov .rc_codes = RC_MAP_SU3000, 2352a49de26aSEvgeny Plehov .module_name = "dw2102", 23536d741bfeSSean Young .allowed_protos = RC_PROTO_BIT_RC5, 2354a49de26aSEvgeny Plehov .rc_query = su3000_rc_query, 2355786baecfSMauro Carvalho Chehab }, 2356786baecfSMauro Carvalho Chehab 2357786baecfSMauro Carvalho Chehab .read_mac_address = su3000_read_mac_address, 2358786baecfSMauro Carvalho Chehab 2359786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x01, 2360786baecfSMauro Carvalho Chehab 2361786baecfSMauro Carvalho Chehab .adapter = { 2362786baecfSMauro Carvalho Chehab { 2363786baecfSMauro Carvalho Chehab .num_frontends = 1, 2364786baecfSMauro Carvalho Chehab .fe = {{ 2365786baecfSMauro Carvalho Chehab .streaming_ctrl = su3000_streaming_ctrl, 2366786baecfSMauro Carvalho Chehab .frontend_attach = su3000_frontend_attach, 2367786baecfSMauro Carvalho Chehab .stream = { 2368786baecfSMauro Carvalho Chehab .type = USB_BULK, 2369786baecfSMauro Carvalho Chehab .count = 8, 2370786baecfSMauro Carvalho Chehab .endpoint = 0x82, 2371786baecfSMauro Carvalho Chehab .u = { 2372786baecfSMauro Carvalho Chehab .bulk = { 2373786baecfSMauro Carvalho Chehab .buffersize = 4096, 2374786baecfSMauro Carvalho Chehab } 2375786baecfSMauro Carvalho Chehab } 2376786baecfSMauro Carvalho Chehab } 2377786baecfSMauro Carvalho Chehab }}, 2378786baecfSMauro Carvalho Chehab } 2379786baecfSMauro Carvalho Chehab }, 23809cd4bcfbSKai Muenz .num_device_descs = 9, 2381786baecfSMauro Carvalho Chehab .devices = { 2382786baecfSMauro Carvalho Chehab { "SU3000HD DVB-S USB2.0", 2383786baecfSMauro Carvalho Chehab { &dw2102_table[GENIATECH_SU3000], NULL }, 2384786baecfSMauro Carvalho Chehab { NULL }, 2385786baecfSMauro Carvalho Chehab }, 23869cd4bcfbSKai Muenz { "Hauppauge MAX S2 or WinTV NOVA HD USB2.0", 23879cd4bcfbSKai Muenz { &dw2102_table[HAUPPAUGE_MAX_S2], NULL }, 23889cd4bcfbSKai Muenz { NULL }, 23899cd4bcfbSKai Muenz }, 2390786baecfSMauro Carvalho Chehab { "Terratec Cinergy S2 USB HD", 23912fa2002fSMauro Carvalho Chehab { &dw2102_table[TERRATEC_CINERGY_S2_R1], NULL }, 2392786baecfSMauro Carvalho Chehab { NULL }, 2393786baecfSMauro Carvalho Chehab }, 2394786baecfSMauro Carvalho Chehab { "X3M TV SPC1400HD PCI", 23952fa2002fSMauro Carvalho Chehab { &dw2102_table[GENIATECH_X3M_SPC1400HD], NULL }, 2396786baecfSMauro Carvalho Chehab { NULL }, 2397786baecfSMauro Carvalho Chehab }, 239844122dd6SIgor M. Liplianin { "Terratec Cinergy S2 USB HD Rev.2", 239944122dd6SIgor M. Liplianin { &dw2102_table[TERRATEC_CINERGY_S2_R2], NULL }, 240044122dd6SIgor M. Liplianin { NULL }, 240144122dd6SIgor M. Liplianin }, 240249438d97SOlli Salonen { "Terratec Cinergy S2 USB HD Rev.3", 240349438d97SOlli Salonen { &dw2102_table[TERRATEC_CINERGY_S2_R3], NULL }, 240449438d97SOlli Salonen { NULL }, 240549438d97SOlli Salonen }, 2406528b1a1aSDirk Nehring { "Terratec Cinergy S2 PCIe Dual Port 1", 2407528b1a1aSDirk Nehring { &dw2102_table[TERRATEC_CINERGY_S2_1], NULL }, 2408528b1a1aSDirk Nehring { NULL }, 2409528b1a1aSDirk Nehring }, 2410528b1a1aSDirk Nehring { "Terratec Cinergy S2 PCIe Dual Port 2", 2411528b1a1aSDirk Nehring { &dw2102_table[TERRATEC_CINERGY_S2_2], NULL }, 2412528b1a1aSDirk Nehring { NULL }, 2413528b1a1aSDirk Nehring }, 2414f08e9f0dSAndrey Pavlenko { "GOTVIEW Satellite HD", 2415f08e9f0dSAndrey Pavlenko { &dw2102_table[GOTVIEW_SAT_HD], NULL }, 2416f08e9f0dSAndrey Pavlenko { NULL }, 2417f08e9f0dSAndrey Pavlenko }, 2418786baecfSMauro Carvalho Chehab } 2419786baecfSMauro Carvalho Chehab }; 2420786baecfSMauro Carvalho Chehab 2421589a9f0eSAnton Vasilyev static struct dvb_usb_device_properties s421_properties = { 2422589a9f0eSAnton Vasilyev .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2423589a9f0eSAnton Vasilyev .usb_ctrl = DEVICE_SPECIFIC, 2424589a9f0eSAnton Vasilyev .size_of_priv = sizeof(struct dw2102_state), 2425589a9f0eSAnton Vasilyev .power_ctrl = su3000_power_ctrl, 2426589a9f0eSAnton Vasilyev .num_adapters = 1, 2427589a9f0eSAnton Vasilyev .identify_state = su3000_identify_state, 2428589a9f0eSAnton Vasilyev .i2c_algo = &su3000_i2c_algo, 2429589a9f0eSAnton Vasilyev 2430589a9f0eSAnton Vasilyev .rc.core = { 2431589a9f0eSAnton Vasilyev .rc_interval = 150, 2432589a9f0eSAnton Vasilyev .rc_codes = RC_MAP_SU3000, 2433589a9f0eSAnton Vasilyev .module_name = "dw2102", 2434589a9f0eSAnton Vasilyev .allowed_protos = RC_PROTO_BIT_RC5, 2435589a9f0eSAnton Vasilyev .rc_query = su3000_rc_query, 2436589a9f0eSAnton Vasilyev }, 2437589a9f0eSAnton Vasilyev 2438589a9f0eSAnton Vasilyev .read_mac_address = su3000_read_mac_address, 2439589a9f0eSAnton Vasilyev 2440589a9f0eSAnton Vasilyev .generic_bulk_ctrl_endpoint = 0x01, 2441589a9f0eSAnton Vasilyev 2442589a9f0eSAnton Vasilyev .adapter = { 2443589a9f0eSAnton Vasilyev { 2444589a9f0eSAnton Vasilyev .num_frontends = 1, 2445589a9f0eSAnton Vasilyev .fe = {{ 2446589a9f0eSAnton Vasilyev .streaming_ctrl = su3000_streaming_ctrl, 2447589a9f0eSAnton Vasilyev .frontend_attach = m88rs2000_frontend_attach, 2448589a9f0eSAnton Vasilyev .stream = { 2449589a9f0eSAnton Vasilyev .type = USB_BULK, 2450589a9f0eSAnton Vasilyev .count = 8, 2451589a9f0eSAnton Vasilyev .endpoint = 0x82, 2452589a9f0eSAnton Vasilyev .u = { 2453589a9f0eSAnton Vasilyev .bulk = { 2454589a9f0eSAnton Vasilyev .buffersize = 4096, 2455589a9f0eSAnton Vasilyev } 2456589a9f0eSAnton Vasilyev } 2457589a9f0eSAnton Vasilyev } 2458589a9f0eSAnton Vasilyev } }, 2459589a9f0eSAnton Vasilyev } 2460589a9f0eSAnton Vasilyev }, 2461589a9f0eSAnton Vasilyev .num_device_descs = 2, 2462589a9f0eSAnton Vasilyev .devices = { 2463589a9f0eSAnton Vasilyev { "TeVii S421 PCI", 2464589a9f0eSAnton Vasilyev { &dw2102_table[TEVII_S421], NULL }, 2465589a9f0eSAnton Vasilyev { NULL }, 2466589a9f0eSAnton Vasilyev }, 2467589a9f0eSAnton Vasilyev { "TeVii S632 USB", 2468589a9f0eSAnton Vasilyev { &dw2102_table[TEVII_S632], NULL }, 2469589a9f0eSAnton Vasilyev { NULL }, 2470589a9f0eSAnton Vasilyev }, 2471589a9f0eSAnton Vasilyev } 2472589a9f0eSAnton Vasilyev }; 2473589a9f0eSAnton Vasilyev 247451d882edSEvgeny Plehov static struct dvb_usb_device_properties t220_properties = { 247551d882edSEvgeny Plehov .caps = DVB_USB_IS_AN_I2C_ADAPTER, 247651d882edSEvgeny Plehov .usb_ctrl = DEVICE_SPECIFIC, 24772c4ffe27SOlli Salonen .size_of_priv = sizeof(struct dw2102_state), 247851d882edSEvgeny Plehov .power_ctrl = su3000_power_ctrl, 247951d882edSEvgeny Plehov .num_adapters = 1, 248051d882edSEvgeny Plehov .identify_state = su3000_identify_state, 248151d882edSEvgeny Plehov .i2c_algo = &su3000_i2c_algo, 248251d882edSEvgeny Plehov 2483a49de26aSEvgeny Plehov .rc.core = { 248451d882edSEvgeny Plehov .rc_interval = 150, 2485a49de26aSEvgeny Plehov .rc_codes = RC_MAP_SU3000, 2486a49de26aSEvgeny Plehov .module_name = "dw2102", 24876d741bfeSSean Young .allowed_protos = RC_PROTO_BIT_RC5, 2488a49de26aSEvgeny Plehov .rc_query = su3000_rc_query, 248951d882edSEvgeny Plehov }, 249051d882edSEvgeny Plehov 249151d882edSEvgeny Plehov .read_mac_address = su3000_read_mac_address, 249251d882edSEvgeny Plehov 249351d882edSEvgeny Plehov .generic_bulk_ctrl_endpoint = 0x01, 249451d882edSEvgeny Plehov 249551d882edSEvgeny Plehov .adapter = { 249651d882edSEvgeny Plehov { 249751d882edSEvgeny Plehov .num_frontends = 1, 249851d882edSEvgeny Plehov .fe = { { 249951d882edSEvgeny Plehov .streaming_ctrl = su3000_streaming_ctrl, 250051d882edSEvgeny Plehov .frontend_attach = t220_frontend_attach, 250151d882edSEvgeny Plehov .stream = { 250251d882edSEvgeny Plehov .type = USB_BULK, 250351d882edSEvgeny Plehov .count = 8, 250451d882edSEvgeny Plehov .endpoint = 0x82, 250551d882edSEvgeny Plehov .u = { 250651d882edSEvgeny Plehov .bulk = { 250751d882edSEvgeny Plehov .buffersize = 4096, 250851d882edSEvgeny Plehov } 250951d882edSEvgeny Plehov } 251051d882edSEvgeny Plehov } 251151d882edSEvgeny Plehov } }, 251251d882edSEvgeny Plehov } 251351d882edSEvgeny Plehov }, 251451d882edSEvgeny Plehov .num_device_descs = 1, 251551d882edSEvgeny Plehov .devices = { 251651d882edSEvgeny Plehov { "Geniatech T220 DVB-T/T2 USB2.0", 251751d882edSEvgeny Plehov { &dw2102_table[GENIATECH_T220], NULL }, 251851d882edSEvgeny Plehov { NULL }, 251951d882edSEvgeny Plehov }, 252051d882edSEvgeny Plehov } 252151d882edSEvgeny Plehov }; 252251d882edSEvgeny Plehov 252327254c36SOlli Salonen static struct dvb_usb_device_properties tt_s2_4600_properties = { 252427254c36SOlli Salonen .caps = DVB_USB_IS_AN_I2C_ADAPTER, 252527254c36SOlli Salonen .usb_ctrl = DEVICE_SPECIFIC, 252627254c36SOlli Salonen .size_of_priv = sizeof(struct dw2102_state), 252727254c36SOlli Salonen .power_ctrl = su3000_power_ctrl, 252827254c36SOlli Salonen .num_adapters = 1, 252927254c36SOlli Salonen .identify_state = su3000_identify_state, 253027254c36SOlli Salonen .i2c_algo = &su3000_i2c_algo, 253127254c36SOlli Salonen 253227254c36SOlli Salonen .rc.core = { 253327254c36SOlli Salonen .rc_interval = 250, 253427254c36SOlli Salonen .rc_codes = RC_MAP_TT_1500, 253527254c36SOlli Salonen .module_name = "dw2102", 25366d741bfeSSean Young .allowed_protos = RC_PROTO_BIT_RC5, 253727254c36SOlli Salonen .rc_query = su3000_rc_query, 253827254c36SOlli Salonen }, 253927254c36SOlli Salonen 254027254c36SOlli Salonen .read_mac_address = su3000_read_mac_address, 254127254c36SOlli Salonen 254227254c36SOlli Salonen .generic_bulk_ctrl_endpoint = 0x01, 254327254c36SOlli Salonen 254427254c36SOlli Salonen .adapter = { 254527254c36SOlli Salonen { 254627254c36SOlli Salonen .num_frontends = 1, 254727254c36SOlli Salonen .fe = {{ 254827254c36SOlli Salonen .streaming_ctrl = su3000_streaming_ctrl, 254927254c36SOlli Salonen .frontend_attach = tt_s2_4600_frontend_attach, 255027254c36SOlli Salonen .stream = { 255127254c36SOlli Salonen .type = USB_BULK, 255227254c36SOlli Salonen .count = 8, 255327254c36SOlli Salonen .endpoint = 0x82, 255427254c36SOlli Salonen .u = { 255527254c36SOlli Salonen .bulk = { 255627254c36SOlli Salonen .buffersize = 4096, 255727254c36SOlli Salonen } 255827254c36SOlli Salonen } 255927254c36SOlli Salonen } 256027254c36SOlli Salonen } }, 256127254c36SOlli Salonen } 256227254c36SOlli Salonen }, 25636ede20f9SOlli Salonen .num_device_descs = 5, 256427254c36SOlli Salonen .devices = { 256527254c36SOlli Salonen { "TechnoTrend TT-connect S2-4600", 25662fa2002fSMauro Carvalho Chehab { &dw2102_table[TECHNOTREND_CONNECT_S2_4600], NULL }, 256727254c36SOlli Salonen { NULL }, 256827254c36SOlli Salonen }, 256944767fc4SOlli Salonen { "TeVii S482 (tuner 1)", 257044767fc4SOlli Salonen { &dw2102_table[TEVII_S482_1], NULL }, 257144767fc4SOlli Salonen { NULL }, 257244767fc4SOlli Salonen }, 257344767fc4SOlli Salonen { "TeVii S482 (tuner 2)", 257444767fc4SOlli Salonen { &dw2102_table[TEVII_S482_2], NULL }, 257544767fc4SOlli Salonen { NULL }, 257644767fc4SOlli Salonen }, 257793b66420SPhilipp Zabel { "Terratec Cinergy S2 USB BOX", 2578*bd693f68SMichael Bunk { &dw2102_table[TERRATEC_CINERGY_S2_R4], NULL }, 257993b66420SPhilipp Zabel { NULL }, 258093b66420SPhilipp Zabel }, 25816ede20f9SOlli Salonen { "TeVii S662", 25826ede20f9SOlli Salonen { &dw2102_table[TEVII_S662], NULL }, 25836ede20f9SOlli Salonen { NULL }, 25846ede20f9SOlli Salonen }, 258527254c36SOlli Salonen } 258627254c36SOlli Salonen }; 258727254c36SOlli Salonen 2588786baecfSMauro Carvalho Chehab static int dw2102_probe(struct usb_interface *intf, 2589786baecfSMauro Carvalho Chehab const struct usb_device_id *id) 2590786baecfSMauro Carvalho Chehab { 2591589a9f0eSAnton Vasilyev if (!(dvb_usb_device_init(intf, &dw2102_properties, 2592589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2593589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &dw2104_properties, 2594589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2595589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &dw3101_properties, 2596589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2597589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &s6x0_properties, 2598589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2599589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &p1100_properties, 2600589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2601589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &s660_properties, 2602589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2603589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &p7500_properties, 2604589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2605589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &s421_properties, 2606589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2607589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &su3000_properties, 2608589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2609589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &t220_properties, 2610589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr) && 2611589a9f0eSAnton Vasilyev dvb_usb_device_init(intf, &tt_s2_4600_properties, 2612589a9f0eSAnton Vasilyev THIS_MODULE, NULL, adapter_nr))) { 2613299c7007SAnton Vasilyev 2614786baecfSMauro Carvalho Chehab return 0; 2615299c7007SAnton Vasilyev } 2616786baecfSMauro Carvalho Chehab 2617589a9f0eSAnton Vasilyev return -ENODEV; 2618786baecfSMauro Carvalho Chehab } 2619786baecfSMauro Carvalho Chehab 262070769b24SOlli Salonen static void dw2102_disconnect(struct usb_interface *intf) 262170769b24SOlli Salonen { 262270769b24SOlli Salonen struct dvb_usb_device *d = usb_get_intfdata(intf); 2623663e7460SYu Zhe struct dw2102_state *st = d->priv; 262470769b24SOlli Salonen struct i2c_client *client; 262570769b24SOlli Salonen 262670769b24SOlli Salonen /* remove I2C client for tuner */ 262770769b24SOlli Salonen client = st->i2c_client_tuner; 262870769b24SOlli Salonen if (client) { 262970769b24SOlli Salonen module_put(client->dev.driver->owner); 263070769b24SOlli Salonen i2c_unregister_device(client); 263170769b24SOlli Salonen } 263270769b24SOlli Salonen 2633f3c6abcaSOlli Salonen /* remove I2C client for demodulator */ 2634f3c6abcaSOlli Salonen client = st->i2c_client_demod; 2635f3c6abcaSOlli Salonen if (client) { 2636f3c6abcaSOlli Salonen module_put(client->dev.driver->owner); 2637f3c6abcaSOlli Salonen i2c_unregister_device(client); 2638f3c6abcaSOlli Salonen } 2639f3c6abcaSOlli Salonen 264070769b24SOlli Salonen dvb_usb_device_exit(intf); 264170769b24SOlli Salonen } 264270769b24SOlli Salonen 2643786baecfSMauro Carvalho Chehab static struct usb_driver dw2102_driver = { 2644786baecfSMauro Carvalho Chehab .name = "dw2102", 2645786baecfSMauro Carvalho Chehab .probe = dw2102_probe, 264670769b24SOlli Salonen .disconnect = dw2102_disconnect, 2647786baecfSMauro Carvalho Chehab .id_table = dw2102_table, 2648786baecfSMauro Carvalho Chehab }; 2649786baecfSMauro Carvalho Chehab 2650786baecfSMauro Carvalho Chehab module_usb_driver(dw2102_driver); 2651786baecfSMauro Carvalho Chehab 2652786baecfSMauro Carvalho Chehab MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); 2653f319ed91SMauro Carvalho Chehab 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"); 2654786baecfSMauro Carvalho Chehab MODULE_VERSION("0.1"); 2655786baecfSMauro Carvalho Chehab MODULE_LICENSE("GPL"); 26566823627bSRémi Cardona MODULE_FIRMWARE(DW2101_FIRMWARE); 26576823627bSRémi Cardona MODULE_FIRMWARE(DW2102_FIRMWARE); 26586823627bSRémi Cardona MODULE_FIRMWARE(DW2104_FIRMWARE); 26596823627bSRémi Cardona MODULE_FIRMWARE(DW3101_FIRMWARE); 26606823627bSRémi Cardona MODULE_FIRMWARE(S630_FIRMWARE); 26616823627bSRémi Cardona MODULE_FIRMWARE(S660_FIRMWARE); 26626823627bSRémi Cardona MODULE_FIRMWARE(P1100_FIRMWARE); 26636823627bSRémi Cardona MODULE_FIRMWARE(P7500_FIRMWARE); 2664