1786baecfSMauro Carvalho Chehab /* DVB USB framework compliant Linux driver for the 2786baecfSMauro Carvalho Chehab * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, 3955d00acSIgor M. Liplianin * TeVii S600, S630, S650, S660, S480, S421, S632 4786baecfSMauro Carvalho Chehab * Prof 1100, 7500, 551d882edSEvgeny Plehov * Geniatech SU3000, T220 Cards 6955d00acSIgor M. Liplianin * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by) 7786baecfSMauro Carvalho Chehab * 8786baecfSMauro Carvalho Chehab * This program is free software; you can redistribute it and/or modify it 9786baecfSMauro Carvalho Chehab * under the terms of the GNU General Public License as published by the 10786baecfSMauro Carvalho Chehab * Free Software Foundation, version 2. 11786baecfSMauro Carvalho Chehab * 12786baecfSMauro Carvalho Chehab * see Documentation/dvb/README.dvb-usb for more information 13786baecfSMauro Carvalho Chehab */ 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" 34786baecfSMauro Carvalho Chehab 350065a79aSMauro Carvalho Chehab /* Max transfer size done by I2C transfer functions */ 360065a79aSMauro Carvalho Chehab #define MAX_XFER_SIZE 64 370065a79aSMauro Carvalho Chehab 38786baecfSMauro Carvalho Chehab #ifndef USB_PID_DW2102 39786baecfSMauro Carvalho Chehab #define USB_PID_DW2102 0x2102 40786baecfSMauro Carvalho Chehab #endif 41786baecfSMauro Carvalho Chehab 42786baecfSMauro Carvalho Chehab #ifndef USB_PID_DW2104 43786baecfSMauro Carvalho Chehab #define USB_PID_DW2104 0x2104 44786baecfSMauro Carvalho Chehab #endif 45786baecfSMauro Carvalho Chehab 46786baecfSMauro Carvalho Chehab #ifndef USB_PID_DW3101 47786baecfSMauro Carvalho Chehab #define USB_PID_DW3101 0x3101 48786baecfSMauro Carvalho Chehab #endif 49786baecfSMauro Carvalho Chehab 50786baecfSMauro Carvalho Chehab #ifndef USB_PID_CINERGY_S 51786baecfSMauro Carvalho Chehab #define USB_PID_CINERGY_S 0x0064 52786baecfSMauro Carvalho Chehab #endif 53786baecfSMauro Carvalho Chehab 54786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S630 55786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S630 0xd630 56786baecfSMauro Carvalho Chehab #endif 57786baecfSMauro Carvalho Chehab 58786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S650 59786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S650 0xd650 60786baecfSMauro Carvalho Chehab #endif 61786baecfSMauro Carvalho Chehab 62786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S660 63786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S660 0xd660 64786baecfSMauro Carvalho Chehab #endif 65786baecfSMauro Carvalho Chehab 66786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S480_1 67786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S480_1 0xd481 68786baecfSMauro Carvalho Chehab #endif 69786baecfSMauro Carvalho Chehab 70786baecfSMauro Carvalho Chehab #ifndef USB_PID_TEVII_S480_2 71786baecfSMauro Carvalho Chehab #define USB_PID_TEVII_S480_2 0xd482 72786baecfSMauro Carvalho Chehab #endif 73786baecfSMauro Carvalho Chehab 74786baecfSMauro Carvalho Chehab #ifndef USB_PID_PROF_1100 75786baecfSMauro Carvalho Chehab #define USB_PID_PROF_1100 0xb012 76786baecfSMauro Carvalho Chehab #endif 77786baecfSMauro Carvalho Chehab 78955d00acSIgor M. Liplianin #ifndef USB_PID_TEVII_S421 79955d00acSIgor M. Liplianin #define USB_PID_TEVII_S421 0xd421 80955d00acSIgor M. Liplianin #endif 81955d00acSIgor M. Liplianin 82955d00acSIgor M. Liplianin #ifndef USB_PID_TEVII_S632 83955d00acSIgor M. Liplianin #define USB_PID_TEVII_S632 0xd632 84955d00acSIgor M. Liplianin #endif 85955d00acSIgor M. Liplianin 86f08e9f0dSAndrey Pavlenko #ifndef USB_PID_GOTVIEW_SAT_HD 87f08e9f0dSAndrey Pavlenko #define USB_PID_GOTVIEW_SAT_HD 0x5456 88f08e9f0dSAndrey Pavlenko #endif 89f08e9f0dSAndrey Pavlenko 90786baecfSMauro Carvalho Chehab #define DW210X_READ_MSG 0 91786baecfSMauro Carvalho Chehab #define DW210X_WRITE_MSG 1 92786baecfSMauro Carvalho Chehab 93786baecfSMauro Carvalho Chehab #define REG_1F_SYMBOLRATE_BYTE0 0x1f 94786baecfSMauro Carvalho Chehab #define REG_20_SYMBOLRATE_BYTE1 0x20 95786baecfSMauro Carvalho Chehab #define REG_21_SYMBOLRATE_BYTE2 0x21 96786baecfSMauro Carvalho Chehab /* on my own*/ 97786baecfSMauro Carvalho Chehab #define DW2102_VOLTAGE_CTRL (0x1800) 98786baecfSMauro Carvalho Chehab #define SU3000_STREAM_CTRL (0x1900) 99786baecfSMauro Carvalho Chehab #define DW2102_RC_QUERY (0x1a00) 100786baecfSMauro Carvalho Chehab #define DW2102_LED_CTRL (0x1b00) 101786baecfSMauro Carvalho Chehab 1026823627bSRémi Cardona #define DW2101_FIRMWARE "dvb-usb-dw2101.fw" 1036823627bSRémi Cardona #define DW2102_FIRMWARE "dvb-usb-dw2102.fw" 1046823627bSRémi Cardona #define DW2104_FIRMWARE "dvb-usb-dw2104.fw" 1056823627bSRémi Cardona #define DW3101_FIRMWARE "dvb-usb-dw3101.fw" 1066823627bSRémi Cardona #define S630_FIRMWARE "dvb-usb-s630.fw" 1076823627bSRémi Cardona #define S660_FIRMWARE "dvb-usb-s660.fw" 1086823627bSRémi Cardona #define P1100_FIRMWARE "dvb-usb-p1100.fw" 1096823627bSRémi Cardona #define P7500_FIRMWARE "dvb-usb-p7500.fw" 1106823627bSRémi Cardona 111786baecfSMauro Carvalho Chehab #define err_str "did not find the firmware file. (%s) " \ 112786baecfSMauro Carvalho Chehab "Please see linux/Documentation/dvb/ for more details " \ 113786baecfSMauro Carvalho Chehab "on firmware-problems." 114786baecfSMauro Carvalho Chehab 115786baecfSMauro Carvalho Chehab struct su3000_state { 116786baecfSMauro Carvalho Chehab u8 initialized; 117786baecfSMauro Carvalho Chehab }; 118786baecfSMauro Carvalho Chehab 119786baecfSMauro Carvalho Chehab struct s6x0_state { 120786baecfSMauro Carvalho Chehab int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v); 121786baecfSMauro Carvalho Chehab }; 122786baecfSMauro Carvalho Chehab 123786baecfSMauro Carvalho Chehab /* debug */ 124786baecfSMauro Carvalho Chehab static int dvb_usb_dw2102_debug; 125786baecfSMauro Carvalho Chehab module_param_named(debug, dvb_usb_dw2102_debug, int, 0644); 126786baecfSMauro Carvalho Chehab MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))." 127786baecfSMauro Carvalho Chehab DVB_USB_DEBUG_STATUS); 128786baecfSMauro Carvalho Chehab 129786baecfSMauro Carvalho Chehab /* demod probe */ 130786baecfSMauro Carvalho Chehab static int demod_probe = 1; 131786baecfSMauro Carvalho Chehab module_param_named(demod, demod_probe, int, 0644); 132786baecfSMauro Carvalho Chehab MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 " 133786baecfSMauro Carvalho Chehab "4=stv0903+stb6100(or-able))."); 134786baecfSMauro Carvalho Chehab 135786baecfSMauro Carvalho Chehab DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 136786baecfSMauro Carvalho Chehab 137786baecfSMauro Carvalho Chehab static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value, 138786baecfSMauro Carvalho Chehab u16 index, u8 * data, u16 len, int flags) 139786baecfSMauro Carvalho Chehab { 140786baecfSMauro Carvalho Chehab int ret; 141786baecfSMauro Carvalho Chehab u8 *u8buf; 142786baecfSMauro Carvalho Chehab unsigned int pipe = (flags == DW210X_READ_MSG) ? 143786baecfSMauro Carvalho Chehab usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0); 144786baecfSMauro Carvalho Chehab u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT; 145786baecfSMauro Carvalho Chehab 146786baecfSMauro Carvalho Chehab u8buf = kmalloc(len, GFP_KERNEL); 147786baecfSMauro Carvalho Chehab if (!u8buf) 148786baecfSMauro Carvalho Chehab return -ENOMEM; 149786baecfSMauro Carvalho Chehab 150786baecfSMauro Carvalho Chehab 151786baecfSMauro Carvalho Chehab if (flags == DW210X_WRITE_MSG) 152786baecfSMauro Carvalho Chehab memcpy(u8buf, data, len); 153786baecfSMauro Carvalho Chehab ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, 154786baecfSMauro Carvalho Chehab value, index , u8buf, len, 2000); 155786baecfSMauro Carvalho Chehab 156786baecfSMauro Carvalho Chehab if (flags == DW210X_READ_MSG) 157786baecfSMauro Carvalho Chehab memcpy(data, u8buf, len); 158786baecfSMauro Carvalho Chehab 159786baecfSMauro Carvalho Chehab kfree(u8buf); 160786baecfSMauro Carvalho Chehab return ret; 161786baecfSMauro Carvalho Chehab } 162786baecfSMauro Carvalho Chehab 163786baecfSMauro Carvalho Chehab /* I2C */ 164786baecfSMauro Carvalho Chehab static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 165786baecfSMauro Carvalho Chehab int num) 166786baecfSMauro Carvalho Chehab { 167786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 168786baecfSMauro Carvalho Chehab int i = 0; 169786baecfSMauro Carvalho Chehab u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0}; 170786baecfSMauro Carvalho Chehab u16 value; 171786baecfSMauro Carvalho Chehab 172786baecfSMauro Carvalho Chehab if (!d) 173786baecfSMauro Carvalho Chehab return -ENODEV; 174786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 175786baecfSMauro Carvalho Chehab return -EAGAIN; 176786baecfSMauro Carvalho Chehab 177786baecfSMauro Carvalho Chehab switch (num) { 178786baecfSMauro Carvalho Chehab case 2: 179786baecfSMauro Carvalho Chehab /* read stv0299 register */ 180786baecfSMauro Carvalho Chehab value = msg[0].buf[0];/* register */ 181786baecfSMauro Carvalho Chehab for (i = 0; i < msg[1].len; i++) { 182786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb5, value + i, 0, 183786baecfSMauro Carvalho Chehab buf6, 2, DW210X_READ_MSG); 184786baecfSMauro Carvalho Chehab msg[1].buf[i] = buf6[0]; 185786baecfSMauro Carvalho Chehab } 186786baecfSMauro Carvalho Chehab break; 187786baecfSMauro Carvalho Chehab case 1: 188786baecfSMauro Carvalho Chehab switch (msg[0].addr) { 189786baecfSMauro Carvalho Chehab case 0x68: 190786baecfSMauro Carvalho Chehab /* write to stv0299 register */ 191786baecfSMauro Carvalho Chehab buf6[0] = 0x2a; 192786baecfSMauro Carvalho Chehab buf6[1] = msg[0].buf[0]; 193786baecfSMauro Carvalho Chehab buf6[2] = msg[0].buf[1]; 194786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 195786baecfSMauro Carvalho Chehab buf6, 3, DW210X_WRITE_MSG); 196786baecfSMauro Carvalho Chehab break; 197786baecfSMauro Carvalho Chehab case 0x60: 198786baecfSMauro Carvalho Chehab if (msg[0].flags == 0) { 199786baecfSMauro Carvalho Chehab /* write to tuner pll */ 200786baecfSMauro Carvalho Chehab buf6[0] = 0x2c; 201786baecfSMauro Carvalho Chehab buf6[1] = 5; 202786baecfSMauro Carvalho Chehab buf6[2] = 0xc0; 203786baecfSMauro Carvalho Chehab buf6[3] = msg[0].buf[0]; 204786baecfSMauro Carvalho Chehab buf6[4] = msg[0].buf[1]; 205786baecfSMauro Carvalho Chehab buf6[5] = msg[0].buf[2]; 206786baecfSMauro Carvalho Chehab buf6[6] = msg[0].buf[3]; 207786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 208786baecfSMauro Carvalho Chehab buf6, 7, DW210X_WRITE_MSG); 209786baecfSMauro Carvalho Chehab } else { 210786baecfSMauro Carvalho Chehab /* read from tuner */ 211786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb5, 0, 0, 212786baecfSMauro Carvalho Chehab buf6, 1, DW210X_READ_MSG); 213786baecfSMauro Carvalho Chehab msg[0].buf[0] = buf6[0]; 214786baecfSMauro Carvalho Chehab } 215786baecfSMauro Carvalho Chehab break; 216786baecfSMauro Carvalho Chehab case (DW2102_RC_QUERY): 217786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 218786baecfSMauro Carvalho Chehab buf6, 2, DW210X_READ_MSG); 219786baecfSMauro Carvalho Chehab msg[0].buf[0] = buf6[0]; 220786baecfSMauro Carvalho Chehab msg[0].buf[1] = buf6[1]; 221786baecfSMauro Carvalho Chehab break; 222786baecfSMauro Carvalho Chehab case (DW2102_VOLTAGE_CTRL): 223786baecfSMauro Carvalho Chehab buf6[0] = 0x30; 224786baecfSMauro Carvalho Chehab buf6[1] = msg[0].buf[0]; 225786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 226786baecfSMauro Carvalho Chehab buf6, 2, DW210X_WRITE_MSG); 227786baecfSMauro Carvalho Chehab break; 228786baecfSMauro Carvalho Chehab } 229786baecfSMauro Carvalho Chehab 230786baecfSMauro Carvalho Chehab break; 231786baecfSMauro Carvalho Chehab } 232786baecfSMauro Carvalho Chehab 233786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 234786baecfSMauro Carvalho Chehab return num; 235786baecfSMauro Carvalho Chehab } 236786baecfSMauro Carvalho Chehab 237786baecfSMauro Carvalho Chehab static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap, 238786baecfSMauro Carvalho Chehab struct i2c_msg msg[], int num) 239786baecfSMauro Carvalho Chehab { 240786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 241786baecfSMauro Carvalho Chehab u8 buf6[] = {0, 0, 0, 0, 0, 0, 0}; 242786baecfSMauro Carvalho Chehab 243786baecfSMauro Carvalho Chehab if (!d) 244786baecfSMauro Carvalho Chehab return -ENODEV; 245786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 246786baecfSMauro Carvalho Chehab return -EAGAIN; 247786baecfSMauro Carvalho Chehab 248786baecfSMauro Carvalho Chehab switch (num) { 249786baecfSMauro Carvalho Chehab case 2: 250786baecfSMauro Carvalho Chehab /* read si2109 register by number */ 251786baecfSMauro Carvalho Chehab buf6[0] = msg[0].addr << 1; 252786baecfSMauro Carvalho Chehab buf6[1] = msg[0].len; 253786baecfSMauro Carvalho Chehab buf6[2] = msg[0].buf[0]; 254786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 255786baecfSMauro Carvalho Chehab buf6, msg[0].len + 2, DW210X_WRITE_MSG); 256786baecfSMauro Carvalho Chehab /* read si2109 register */ 257786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc3, 0xd0, 0, 258786baecfSMauro Carvalho Chehab buf6, msg[1].len + 2, DW210X_READ_MSG); 259786baecfSMauro Carvalho Chehab memcpy(msg[1].buf, buf6 + 2, msg[1].len); 260786baecfSMauro Carvalho Chehab 261786baecfSMauro Carvalho Chehab break; 262786baecfSMauro Carvalho Chehab case 1: 263786baecfSMauro Carvalho Chehab switch (msg[0].addr) { 264786baecfSMauro Carvalho Chehab case 0x68: 265786baecfSMauro Carvalho Chehab /* write to si2109 register */ 266786baecfSMauro Carvalho Chehab buf6[0] = msg[0].addr << 1; 267786baecfSMauro Carvalho Chehab buf6[1] = msg[0].len; 268786baecfSMauro Carvalho Chehab memcpy(buf6 + 2, msg[0].buf, msg[0].len); 269786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6, 270786baecfSMauro Carvalho Chehab msg[0].len + 2, DW210X_WRITE_MSG); 271786baecfSMauro Carvalho Chehab break; 272786baecfSMauro Carvalho Chehab case(DW2102_RC_QUERY): 273786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 274786baecfSMauro Carvalho Chehab buf6, 2, DW210X_READ_MSG); 275786baecfSMauro Carvalho Chehab msg[0].buf[0] = buf6[0]; 276786baecfSMauro Carvalho Chehab msg[0].buf[1] = buf6[1]; 277786baecfSMauro Carvalho Chehab break; 278786baecfSMauro Carvalho Chehab case(DW2102_VOLTAGE_CTRL): 279786baecfSMauro Carvalho Chehab buf6[0] = 0x30; 280786baecfSMauro Carvalho Chehab buf6[1] = msg[0].buf[0]; 281786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 282786baecfSMauro Carvalho Chehab buf6, 2, DW210X_WRITE_MSG); 283786baecfSMauro Carvalho Chehab break; 284786baecfSMauro Carvalho Chehab } 285786baecfSMauro Carvalho Chehab break; 286786baecfSMauro Carvalho Chehab } 287786baecfSMauro Carvalho Chehab 288786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 289786baecfSMauro Carvalho Chehab return num; 290786baecfSMauro Carvalho Chehab } 291786baecfSMauro Carvalho Chehab 292786baecfSMauro Carvalho Chehab static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 293786baecfSMauro Carvalho Chehab { 294786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 295324ed533SDan Carpenter int ret; 296786baecfSMauro Carvalho Chehab 297786baecfSMauro Carvalho Chehab if (!d) 298786baecfSMauro Carvalho Chehab return -ENODEV; 299786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 300786baecfSMauro Carvalho Chehab return -EAGAIN; 301786baecfSMauro Carvalho Chehab 302786baecfSMauro Carvalho Chehab switch (num) { 303786baecfSMauro Carvalho Chehab case 2: { 304786baecfSMauro Carvalho Chehab /* read */ 305786baecfSMauro Carvalho Chehab /* first write first register number */ 3060065a79aSMauro Carvalho Chehab u8 ibuf[MAX_XFER_SIZE], obuf[3]; 3070065a79aSMauro Carvalho Chehab 3080065a79aSMauro Carvalho Chehab if (2 + msg[1].len > sizeof(ibuf)) { 3090065a79aSMauro Carvalho Chehab warn("i2c rd: len=%d is too big!\n", 3100065a79aSMauro Carvalho Chehab msg[1].len); 311324ed533SDan Carpenter ret = -EOPNOTSUPP; 312324ed533SDan Carpenter goto unlock; 3130065a79aSMauro Carvalho Chehab } 3140065a79aSMauro Carvalho Chehab 315786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 316786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 317786baecfSMauro Carvalho Chehab obuf[2] = msg[0].buf[0]; 318786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 319786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 320786baecfSMauro Carvalho Chehab /* second read registers */ 321786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, 322786baecfSMauro Carvalho Chehab ibuf, msg[1].len + 2, DW210X_READ_MSG); 323786baecfSMauro Carvalho Chehab memcpy(msg[1].buf, ibuf + 2, msg[1].len); 324786baecfSMauro Carvalho Chehab 325786baecfSMauro Carvalho Chehab break; 326786baecfSMauro Carvalho Chehab } 327786baecfSMauro Carvalho Chehab case 1: 328786baecfSMauro Carvalho Chehab switch (msg[0].addr) { 329786baecfSMauro Carvalho Chehab case 0x68: { 330786baecfSMauro Carvalho Chehab /* write to register */ 3310065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 3320065a79aSMauro Carvalho Chehab 3330065a79aSMauro Carvalho Chehab if (2 + msg[0].len > sizeof(obuf)) { 3340065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 3350065a79aSMauro Carvalho Chehab msg[1].len); 336324ed533SDan Carpenter ret = -EOPNOTSUPP; 337324ed533SDan Carpenter goto unlock; 3380065a79aSMauro Carvalho Chehab } 3390065a79aSMauro Carvalho Chehab 340786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 341786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 342786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[0].buf, msg[0].len); 343786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 344786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 345786baecfSMauro Carvalho Chehab break; 346786baecfSMauro Carvalho Chehab } 347786baecfSMauro Carvalho Chehab case 0x61: { 348786baecfSMauro Carvalho Chehab /* write to tuner */ 3490065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 3500065a79aSMauro Carvalho Chehab 3510065a79aSMauro Carvalho Chehab if (2 + msg[0].len > sizeof(obuf)) { 3520065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 3530065a79aSMauro Carvalho Chehab msg[1].len); 354324ed533SDan Carpenter ret = -EOPNOTSUPP; 355324ed533SDan Carpenter goto unlock; 3560065a79aSMauro Carvalho Chehab } 3570065a79aSMauro Carvalho Chehab 358786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 359786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 360786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[0].buf, msg[0].len); 361786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 362786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 363786baecfSMauro Carvalho Chehab break; 364786baecfSMauro Carvalho Chehab } 365786baecfSMauro Carvalho Chehab case(DW2102_RC_QUERY): { 366786baecfSMauro Carvalho Chehab u8 ibuf[2]; 367786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 368786baecfSMauro Carvalho Chehab ibuf, 2, DW210X_READ_MSG); 369786baecfSMauro Carvalho Chehab memcpy(msg[0].buf, ibuf , 2); 370786baecfSMauro Carvalho Chehab break; 371786baecfSMauro Carvalho Chehab } 372786baecfSMauro Carvalho Chehab case(DW2102_VOLTAGE_CTRL): { 373786baecfSMauro Carvalho Chehab u8 obuf[2]; 374786baecfSMauro Carvalho Chehab obuf[0] = 0x30; 375786baecfSMauro Carvalho Chehab obuf[1] = msg[0].buf[0]; 376786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 377786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 378786baecfSMauro Carvalho Chehab break; 379786baecfSMauro Carvalho Chehab } 380786baecfSMauro Carvalho Chehab } 381786baecfSMauro Carvalho Chehab 382786baecfSMauro Carvalho Chehab break; 383786baecfSMauro Carvalho Chehab } 384324ed533SDan Carpenter ret = num; 385786baecfSMauro Carvalho Chehab 386324ed533SDan Carpenter unlock: 387786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 388324ed533SDan Carpenter return ret; 389786baecfSMauro Carvalho Chehab } 390786baecfSMauro Carvalho Chehab 391786baecfSMauro Carvalho Chehab static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 392786baecfSMauro Carvalho Chehab { 393786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 394324ed533SDan Carpenter int len, i, j, ret; 395786baecfSMauro Carvalho Chehab 396786baecfSMauro Carvalho Chehab if (!d) 397786baecfSMauro Carvalho Chehab return -ENODEV; 398786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 399786baecfSMauro Carvalho Chehab return -EAGAIN; 400786baecfSMauro Carvalho Chehab 401786baecfSMauro Carvalho Chehab for (j = 0; j < num; j++) { 402786baecfSMauro Carvalho Chehab switch (msg[j].addr) { 403786baecfSMauro Carvalho Chehab case(DW2102_RC_QUERY): { 404786baecfSMauro Carvalho Chehab u8 ibuf[2]; 405786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 406786baecfSMauro Carvalho Chehab ibuf, 2, DW210X_READ_MSG); 407786baecfSMauro Carvalho Chehab memcpy(msg[j].buf, ibuf , 2); 408786baecfSMauro Carvalho Chehab break; 409786baecfSMauro Carvalho Chehab } 410786baecfSMauro Carvalho Chehab case(DW2102_VOLTAGE_CTRL): { 411786baecfSMauro Carvalho Chehab u8 obuf[2]; 412786baecfSMauro Carvalho Chehab obuf[0] = 0x30; 413786baecfSMauro Carvalho Chehab obuf[1] = msg[j].buf[0]; 414786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb2, 0, 0, 415786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 416786baecfSMauro Carvalho Chehab break; 417786baecfSMauro Carvalho Chehab } 418786baecfSMauro Carvalho Chehab /*case 0x55: cx24116 419786baecfSMauro Carvalho Chehab case 0x6a: stv0903 420786baecfSMauro Carvalho Chehab case 0x68: ds3000, stv0903 421786baecfSMauro Carvalho Chehab case 0x60: ts2020, stv6110, stb6100 */ 422786baecfSMauro Carvalho Chehab default: { 423786baecfSMauro Carvalho Chehab if (msg[j].flags == I2C_M_RD) { 424786baecfSMauro Carvalho Chehab /* read registers */ 4250065a79aSMauro Carvalho Chehab u8 ibuf[MAX_XFER_SIZE]; 4260065a79aSMauro Carvalho Chehab 4270065a79aSMauro Carvalho Chehab if (2 + msg[j].len > sizeof(ibuf)) { 4280065a79aSMauro Carvalho Chehab warn("i2c rd: len=%d is too big!\n", 4290065a79aSMauro Carvalho Chehab msg[j].len); 430324ed533SDan Carpenter ret = -EOPNOTSUPP; 431324ed533SDan Carpenter goto unlock; 4320065a79aSMauro Carvalho Chehab } 4330065a79aSMauro Carvalho Chehab 434786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc3, 435786baecfSMauro Carvalho Chehab (msg[j].addr << 1) + 1, 0, 436786baecfSMauro Carvalho Chehab ibuf, msg[j].len + 2, 437786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 438786baecfSMauro Carvalho Chehab memcpy(msg[j].buf, ibuf + 2, msg[j].len); 439786baecfSMauro Carvalho Chehab mdelay(10); 440786baecfSMauro Carvalho Chehab } else if (((msg[j].buf[0] == 0xb0) && 441786baecfSMauro Carvalho Chehab (msg[j].addr == 0x68)) || 442786baecfSMauro Carvalho Chehab ((msg[j].buf[0] == 0xf7) && 443786baecfSMauro Carvalho Chehab (msg[j].addr == 0x55))) { 444786baecfSMauro Carvalho Chehab /* write firmware */ 445786baecfSMauro Carvalho Chehab u8 obuf[19]; 446786baecfSMauro Carvalho Chehab obuf[0] = msg[j].addr << 1; 447786baecfSMauro Carvalho Chehab obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len); 448786baecfSMauro Carvalho Chehab obuf[2] = msg[j].buf[0]; 449786baecfSMauro Carvalho Chehab len = msg[j].len - 1; 450786baecfSMauro Carvalho Chehab i = 1; 451786baecfSMauro Carvalho Chehab do { 452786baecfSMauro Carvalho Chehab memcpy(obuf + 3, msg[j].buf + i, 453786baecfSMauro Carvalho Chehab (len > 16 ? 16 : len)); 454786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 455786baecfSMauro Carvalho Chehab obuf, (len > 16 ? 16 : len) + 3, 456786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 457786baecfSMauro Carvalho Chehab i += 16; 458786baecfSMauro Carvalho Chehab len -= 16; 459786baecfSMauro Carvalho Chehab } while (len > 0); 460786baecfSMauro Carvalho Chehab } else { 461786baecfSMauro Carvalho Chehab /* write registers */ 4620065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 4630065a79aSMauro Carvalho Chehab 4640065a79aSMauro Carvalho Chehab if (2 + msg[j].len > sizeof(obuf)) { 4650065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 4660065a79aSMauro Carvalho Chehab msg[j].len); 467324ed533SDan Carpenter ret = -EOPNOTSUPP; 468324ed533SDan Carpenter goto unlock; 4690065a79aSMauro Carvalho Chehab } 4700065a79aSMauro Carvalho Chehab 471786baecfSMauro Carvalho Chehab obuf[0] = msg[j].addr << 1; 472786baecfSMauro Carvalho Chehab obuf[1] = msg[j].len; 473786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[j].buf, msg[j].len); 474786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 475786baecfSMauro Carvalho Chehab obuf, msg[j].len + 2, 476786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 477786baecfSMauro Carvalho Chehab } 478786baecfSMauro Carvalho Chehab break; 479786baecfSMauro Carvalho Chehab } 480786baecfSMauro Carvalho Chehab } 481786baecfSMauro Carvalho Chehab 482786baecfSMauro Carvalho Chehab } 483324ed533SDan Carpenter ret = num; 484786baecfSMauro Carvalho Chehab 485324ed533SDan Carpenter unlock: 486786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 487324ed533SDan Carpenter return ret; 488786baecfSMauro Carvalho Chehab } 489786baecfSMauro Carvalho Chehab 490786baecfSMauro Carvalho Chehab static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 491786baecfSMauro Carvalho Chehab int num) 492786baecfSMauro Carvalho Chehab { 493786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 494324ed533SDan Carpenter int ret; 495786baecfSMauro Carvalho Chehab int i; 496786baecfSMauro Carvalho Chehab 497786baecfSMauro Carvalho Chehab if (!d) 498786baecfSMauro Carvalho Chehab return -ENODEV; 499786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 500786baecfSMauro Carvalho Chehab return -EAGAIN; 501786baecfSMauro Carvalho Chehab 502786baecfSMauro Carvalho Chehab switch (num) { 503786baecfSMauro Carvalho Chehab case 2: { 504786baecfSMauro Carvalho Chehab /* read */ 505786baecfSMauro Carvalho Chehab /* first write first register number */ 5060065a79aSMauro Carvalho Chehab u8 ibuf[MAX_XFER_SIZE], obuf[3]; 5070065a79aSMauro Carvalho Chehab 5080065a79aSMauro Carvalho Chehab if (2 + msg[1].len > sizeof(ibuf)) { 5090065a79aSMauro Carvalho Chehab warn("i2c rd: len=%d is too big!\n", 5100065a79aSMauro Carvalho Chehab msg[1].len); 511324ed533SDan Carpenter ret = -EOPNOTSUPP; 512324ed533SDan Carpenter goto unlock; 5130065a79aSMauro Carvalho Chehab } 514786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 515786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 516786baecfSMauro Carvalho Chehab obuf[2] = msg[0].buf[0]; 517786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 518786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 519786baecfSMauro Carvalho Chehab /* second read registers */ 520786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, 521786baecfSMauro Carvalho Chehab ibuf, msg[1].len + 2, DW210X_READ_MSG); 522786baecfSMauro Carvalho Chehab memcpy(msg[1].buf, ibuf + 2, msg[1].len); 523786baecfSMauro Carvalho Chehab 524786baecfSMauro Carvalho Chehab break; 525786baecfSMauro Carvalho Chehab } 526786baecfSMauro Carvalho Chehab case 1: 527786baecfSMauro Carvalho Chehab switch (msg[0].addr) { 528786baecfSMauro Carvalho Chehab case 0x60: 529786baecfSMauro Carvalho Chehab case 0x0c: { 530786baecfSMauro Carvalho Chehab /* write to register */ 5310065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 5320065a79aSMauro Carvalho Chehab 5330065a79aSMauro Carvalho Chehab if (2 + msg[0].len > sizeof(obuf)) { 5340065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 5350065a79aSMauro Carvalho Chehab msg[0].len); 536324ed533SDan Carpenter ret = -EOPNOTSUPP; 537324ed533SDan Carpenter goto unlock; 5380065a79aSMauro Carvalho Chehab } 539786baecfSMauro Carvalho Chehab obuf[0] = msg[0].addr << 1; 540786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 541786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[0].buf, msg[0].len); 542786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xc2, 0, 0, 543786baecfSMauro Carvalho Chehab obuf, msg[0].len + 2, DW210X_WRITE_MSG); 544786baecfSMauro Carvalho Chehab break; 545786baecfSMauro Carvalho Chehab } 546786baecfSMauro Carvalho Chehab case(DW2102_RC_QUERY): { 547786baecfSMauro Carvalho Chehab u8 ibuf[2]; 548786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 549786baecfSMauro Carvalho Chehab ibuf, 2, DW210X_READ_MSG); 550786baecfSMauro Carvalho Chehab memcpy(msg[0].buf, ibuf , 2); 551786baecfSMauro Carvalho Chehab break; 552786baecfSMauro Carvalho Chehab } 553786baecfSMauro Carvalho Chehab } 554786baecfSMauro Carvalho Chehab 555786baecfSMauro Carvalho Chehab break; 556786baecfSMauro Carvalho Chehab } 557786baecfSMauro Carvalho Chehab 558786baecfSMauro Carvalho Chehab for (i = 0; i < num; i++) { 559786baecfSMauro Carvalho Chehab deb_xfer("%02x:%02x: %s ", i, msg[i].addr, 560786baecfSMauro Carvalho Chehab msg[i].flags == 0 ? ">>>" : "<<<"); 561786baecfSMauro Carvalho Chehab debug_dump(msg[i].buf, msg[i].len, deb_xfer); 562786baecfSMauro Carvalho Chehab } 563324ed533SDan Carpenter ret = num; 564786baecfSMauro Carvalho Chehab 565324ed533SDan Carpenter unlock: 566786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 567324ed533SDan Carpenter return ret; 568786baecfSMauro Carvalho Chehab } 569786baecfSMauro Carvalho Chehab 570786baecfSMauro Carvalho Chehab static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 571786baecfSMauro Carvalho Chehab int num) 572786baecfSMauro Carvalho Chehab { 573786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 574786baecfSMauro Carvalho Chehab struct usb_device *udev; 575324ed533SDan Carpenter int len, i, j, ret; 576786baecfSMauro Carvalho Chehab 577786baecfSMauro Carvalho Chehab if (!d) 578786baecfSMauro Carvalho Chehab return -ENODEV; 579786baecfSMauro Carvalho Chehab udev = d->udev; 580786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 581786baecfSMauro Carvalho Chehab return -EAGAIN; 582786baecfSMauro Carvalho Chehab 583786baecfSMauro Carvalho Chehab for (j = 0; j < num; j++) { 584786baecfSMauro Carvalho Chehab switch (msg[j].addr) { 585786baecfSMauro Carvalho Chehab case (DW2102_RC_QUERY): { 586786baecfSMauro Carvalho Chehab u8 ibuf[5]; 587786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0xb8, 0, 0, 588786baecfSMauro Carvalho Chehab ibuf, 5, DW210X_READ_MSG); 589786baecfSMauro Carvalho Chehab memcpy(msg[j].buf, ibuf + 3, 2); 590786baecfSMauro Carvalho Chehab break; 591786baecfSMauro Carvalho Chehab } 592786baecfSMauro Carvalho Chehab case (DW2102_VOLTAGE_CTRL): { 593786baecfSMauro Carvalho Chehab u8 obuf[2]; 594786baecfSMauro Carvalho Chehab 595786baecfSMauro Carvalho Chehab obuf[0] = 1; 596786baecfSMauro Carvalho Chehab obuf[1] = msg[j].buf[1];/* off-on */ 597786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x8a, 0, 0, 598786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 599786baecfSMauro Carvalho Chehab obuf[0] = 3; 600786baecfSMauro Carvalho Chehab obuf[1] = msg[j].buf[0];/* 13v-18v */ 601786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x8a, 0, 0, 602786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 603786baecfSMauro Carvalho Chehab break; 604786baecfSMauro Carvalho Chehab } 605786baecfSMauro Carvalho Chehab case (DW2102_LED_CTRL): { 606786baecfSMauro Carvalho Chehab u8 obuf[2]; 607786baecfSMauro Carvalho Chehab 608786baecfSMauro Carvalho Chehab obuf[0] = 5; 609786baecfSMauro Carvalho Chehab obuf[1] = msg[j].buf[0]; 610786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x8a, 0, 0, 611786baecfSMauro Carvalho Chehab obuf, 2, DW210X_WRITE_MSG); 612786baecfSMauro Carvalho Chehab break; 613786baecfSMauro Carvalho Chehab } 614786baecfSMauro Carvalho Chehab /*case 0x55: cx24116 615786baecfSMauro Carvalho Chehab case 0x6a: stv0903 616955d00acSIgor M. Liplianin case 0x68: ds3000, stv0903, rs2000 617786baecfSMauro Carvalho Chehab case 0x60: ts2020, stv6110, stb6100 618786baecfSMauro Carvalho Chehab case 0xa0: eeprom */ 619786baecfSMauro Carvalho Chehab default: { 620786baecfSMauro Carvalho Chehab if (msg[j].flags == I2C_M_RD) { 621786baecfSMauro Carvalho Chehab /* read registers */ 6220065a79aSMauro Carvalho Chehab u8 ibuf[MAX_XFER_SIZE]; 6230065a79aSMauro Carvalho Chehab 6240065a79aSMauro Carvalho Chehab if (msg[j].len > sizeof(ibuf)) { 6250065a79aSMauro Carvalho Chehab warn("i2c rd: len=%d is too big!\n", 6260065a79aSMauro Carvalho Chehab msg[j].len); 627324ed533SDan Carpenter ret = -EOPNOTSUPP; 628324ed533SDan Carpenter goto unlock; 6290065a79aSMauro Carvalho Chehab } 6300065a79aSMauro Carvalho Chehab 631786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x91, 0, 0, 632786baecfSMauro Carvalho Chehab ibuf, msg[j].len, 633786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 634786baecfSMauro Carvalho Chehab memcpy(msg[j].buf, ibuf, msg[j].len); 635786baecfSMauro Carvalho Chehab break; 636786baecfSMauro Carvalho Chehab } else if ((msg[j].buf[0] == 0xb0) && 637786baecfSMauro Carvalho Chehab (msg[j].addr == 0x68)) { 638786baecfSMauro Carvalho Chehab /* write firmware */ 639786baecfSMauro Carvalho Chehab u8 obuf[19]; 640786baecfSMauro Carvalho Chehab obuf[0] = (msg[j].len > 16 ? 641786baecfSMauro Carvalho Chehab 18 : msg[j].len + 1); 642786baecfSMauro Carvalho Chehab obuf[1] = msg[j].addr << 1; 643786baecfSMauro Carvalho Chehab obuf[2] = msg[j].buf[0]; 644786baecfSMauro Carvalho Chehab len = msg[j].len - 1; 645786baecfSMauro Carvalho Chehab i = 1; 646786baecfSMauro Carvalho Chehab do { 647786baecfSMauro Carvalho Chehab memcpy(obuf + 3, msg[j].buf + i, 648786baecfSMauro Carvalho Chehab (len > 16 ? 16 : len)); 649786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x80, 0, 0, 650786baecfSMauro Carvalho Chehab obuf, (len > 16 ? 16 : len) + 3, 651786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 652786baecfSMauro Carvalho Chehab i += 16; 653786baecfSMauro Carvalho Chehab len -= 16; 654786baecfSMauro Carvalho Chehab } while (len > 0); 655786baecfSMauro Carvalho Chehab } else if (j < (num - 1)) { 656786baecfSMauro Carvalho Chehab /* write register addr before read */ 6570065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 6580065a79aSMauro Carvalho Chehab 6590065a79aSMauro Carvalho Chehab if (2 + msg[j].len > sizeof(obuf)) { 6600065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 6610065a79aSMauro Carvalho Chehab msg[j].len); 662324ed533SDan Carpenter ret = -EOPNOTSUPP; 663324ed533SDan Carpenter goto unlock; 6640065a79aSMauro Carvalho Chehab } 6650065a79aSMauro Carvalho Chehab 666786baecfSMauro Carvalho Chehab obuf[0] = msg[j + 1].len; 667786baecfSMauro Carvalho Chehab obuf[1] = (msg[j].addr << 1); 668786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[j].buf, msg[j].len); 669786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 670*1ad5d064SHans Verkuil le16_to_cpu(udev->descriptor.idProduct) == 671786baecfSMauro Carvalho Chehab 0x7500 ? 0x92 : 0x90, 0, 0, 672786baecfSMauro Carvalho Chehab obuf, msg[j].len + 2, 673786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 674786baecfSMauro Carvalho Chehab break; 675786baecfSMauro Carvalho Chehab } else { 676786baecfSMauro Carvalho Chehab /* write registers */ 6770065a79aSMauro Carvalho Chehab u8 obuf[MAX_XFER_SIZE]; 6780065a79aSMauro Carvalho Chehab 6790065a79aSMauro Carvalho Chehab if (2 + msg[j].len > sizeof(obuf)) { 6800065a79aSMauro Carvalho Chehab warn("i2c wr: len=%d is too big!\n", 6810065a79aSMauro Carvalho Chehab msg[j].len); 682324ed533SDan Carpenter ret = -EOPNOTSUPP; 683324ed533SDan Carpenter goto unlock; 6840065a79aSMauro Carvalho Chehab } 685786baecfSMauro Carvalho Chehab obuf[0] = msg[j].len + 1; 686786baecfSMauro Carvalho Chehab obuf[1] = (msg[j].addr << 1); 687786baecfSMauro Carvalho Chehab memcpy(obuf + 2, msg[j].buf, msg[j].len); 688786baecfSMauro Carvalho Chehab dw210x_op_rw(d->udev, 0x80, 0, 0, 689786baecfSMauro Carvalho Chehab obuf, msg[j].len + 2, 690786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 691786baecfSMauro Carvalho Chehab break; 692786baecfSMauro Carvalho Chehab } 693786baecfSMauro Carvalho Chehab break; 694786baecfSMauro Carvalho Chehab } 695786baecfSMauro Carvalho Chehab } 696786baecfSMauro Carvalho Chehab } 697324ed533SDan Carpenter ret = num; 698786baecfSMauro Carvalho Chehab 699324ed533SDan Carpenter unlock: 700786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 701324ed533SDan Carpenter return ret; 702786baecfSMauro Carvalho Chehab } 703786baecfSMauro Carvalho Chehab 704786baecfSMauro Carvalho Chehab static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 705786baecfSMauro Carvalho Chehab int num) 706786baecfSMauro Carvalho Chehab { 707786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adap); 708786baecfSMauro Carvalho Chehab u8 obuf[0x40], ibuf[0x40]; 709786baecfSMauro Carvalho Chehab 710786baecfSMauro Carvalho Chehab if (!d) 711786baecfSMauro Carvalho Chehab return -ENODEV; 712786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 713786baecfSMauro Carvalho Chehab return -EAGAIN; 714786baecfSMauro Carvalho Chehab 715786baecfSMauro Carvalho Chehab switch (num) { 716786baecfSMauro Carvalho Chehab case 1: 717786baecfSMauro Carvalho Chehab switch (msg[0].addr) { 718786baecfSMauro Carvalho Chehab case SU3000_STREAM_CTRL: 719786baecfSMauro Carvalho Chehab obuf[0] = msg[0].buf[0] + 0x36; 720786baecfSMauro Carvalho Chehab obuf[1] = 3; 721786baecfSMauro Carvalho Chehab obuf[2] = 0; 722786baecfSMauro Carvalho Chehab if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0) 723786baecfSMauro Carvalho Chehab err("i2c transfer failed."); 724786baecfSMauro Carvalho Chehab break; 725786baecfSMauro Carvalho Chehab case DW2102_RC_QUERY: 726786baecfSMauro Carvalho Chehab obuf[0] = 0x10; 727786baecfSMauro Carvalho Chehab if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0) 728786baecfSMauro Carvalho Chehab err("i2c transfer failed."); 729786baecfSMauro Carvalho Chehab msg[0].buf[1] = ibuf[0]; 730786baecfSMauro Carvalho Chehab msg[0].buf[0] = ibuf[1]; 731786baecfSMauro Carvalho Chehab break; 732786baecfSMauro Carvalho Chehab default: 733786baecfSMauro Carvalho Chehab /* always i2c write*/ 734786baecfSMauro Carvalho Chehab obuf[0] = 0x08; 735786baecfSMauro Carvalho Chehab obuf[1] = msg[0].addr; 736786baecfSMauro Carvalho Chehab obuf[2] = msg[0].len; 737786baecfSMauro Carvalho Chehab 738786baecfSMauro Carvalho Chehab memcpy(&obuf[3], msg[0].buf, msg[0].len); 739786baecfSMauro Carvalho Chehab 740786baecfSMauro Carvalho Chehab if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3, 741786baecfSMauro Carvalho Chehab ibuf, 1, 0) < 0) 742786baecfSMauro Carvalho Chehab err("i2c transfer failed."); 743786baecfSMauro Carvalho Chehab 744786baecfSMauro Carvalho Chehab } 745786baecfSMauro Carvalho Chehab break; 746786baecfSMauro Carvalho Chehab case 2: 747786baecfSMauro Carvalho Chehab /* always i2c read */ 748786baecfSMauro Carvalho Chehab obuf[0] = 0x09; 749786baecfSMauro Carvalho Chehab obuf[1] = msg[0].len; 750786baecfSMauro Carvalho Chehab obuf[2] = msg[1].len; 751786baecfSMauro Carvalho Chehab obuf[3] = msg[0].addr; 752786baecfSMauro Carvalho Chehab memcpy(&obuf[4], msg[0].buf, msg[0].len); 753786baecfSMauro Carvalho Chehab 754786baecfSMauro Carvalho Chehab if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4, 755786baecfSMauro Carvalho Chehab ibuf, msg[1].len + 1, 0) < 0) 756786baecfSMauro Carvalho Chehab err("i2c transfer failed."); 757786baecfSMauro Carvalho Chehab 758786baecfSMauro Carvalho Chehab memcpy(msg[1].buf, &ibuf[1], msg[1].len); 759786baecfSMauro Carvalho Chehab break; 760786baecfSMauro Carvalho Chehab default: 761786baecfSMauro Carvalho Chehab warn("more than 2 i2c messages at a time is not handled yet."); 762786baecfSMauro Carvalho Chehab break; 763786baecfSMauro Carvalho Chehab } 764786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 765786baecfSMauro Carvalho Chehab return num; 766786baecfSMauro Carvalho Chehab } 767786baecfSMauro Carvalho Chehab 768786baecfSMauro Carvalho Chehab static u32 dw210x_i2c_func(struct i2c_adapter *adapter) 769786baecfSMauro Carvalho Chehab { 770786baecfSMauro Carvalho Chehab return I2C_FUNC_I2C; 771786baecfSMauro Carvalho Chehab } 772786baecfSMauro Carvalho Chehab 773786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2102_i2c_algo = { 774786baecfSMauro Carvalho Chehab .master_xfer = dw2102_i2c_transfer, 775786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 776786baecfSMauro Carvalho Chehab }; 777786baecfSMauro Carvalho Chehab 778786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2102_serit_i2c_algo = { 779786baecfSMauro Carvalho Chehab .master_xfer = dw2102_serit_i2c_transfer, 780786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 781786baecfSMauro Carvalho Chehab }; 782786baecfSMauro Carvalho Chehab 783786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2102_earda_i2c_algo = { 784786baecfSMauro Carvalho Chehab .master_xfer = dw2102_earda_i2c_transfer, 785786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 786786baecfSMauro Carvalho Chehab }; 787786baecfSMauro Carvalho Chehab 788786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw2104_i2c_algo = { 789786baecfSMauro Carvalho Chehab .master_xfer = dw2104_i2c_transfer, 790786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 791786baecfSMauro Carvalho Chehab }; 792786baecfSMauro Carvalho Chehab 793786baecfSMauro Carvalho Chehab static struct i2c_algorithm dw3101_i2c_algo = { 794786baecfSMauro Carvalho Chehab .master_xfer = dw3101_i2c_transfer, 795786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 796786baecfSMauro Carvalho Chehab }; 797786baecfSMauro Carvalho Chehab 798786baecfSMauro Carvalho Chehab static struct i2c_algorithm s6x0_i2c_algo = { 799786baecfSMauro Carvalho Chehab .master_xfer = s6x0_i2c_transfer, 800786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 801786baecfSMauro Carvalho Chehab }; 802786baecfSMauro Carvalho Chehab 803786baecfSMauro Carvalho Chehab static struct i2c_algorithm su3000_i2c_algo = { 804786baecfSMauro Carvalho Chehab .master_xfer = su3000_i2c_transfer, 805786baecfSMauro Carvalho Chehab .functionality = dw210x_i2c_func, 806786baecfSMauro Carvalho Chehab }; 807786baecfSMauro Carvalho Chehab 808786baecfSMauro Carvalho Chehab static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 809786baecfSMauro Carvalho Chehab { 810786baecfSMauro Carvalho Chehab int i; 811786baecfSMauro Carvalho Chehab u8 ibuf[] = {0, 0}; 812786baecfSMauro Carvalho Chehab u8 eeprom[256], eepromline[16]; 813786baecfSMauro Carvalho Chehab 814786baecfSMauro Carvalho Chehab for (i = 0; i < 256; i++) { 815786baecfSMauro Carvalho Chehab if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) { 816786baecfSMauro Carvalho Chehab err("read eeprom failed."); 817786baecfSMauro Carvalho Chehab return -1; 818786baecfSMauro Carvalho Chehab } else { 819786baecfSMauro Carvalho Chehab eepromline[i%16] = ibuf[0]; 820786baecfSMauro Carvalho Chehab eeprom[i] = ibuf[0]; 821786baecfSMauro Carvalho Chehab } 822786baecfSMauro Carvalho Chehab if ((i % 16) == 15) { 823786baecfSMauro Carvalho Chehab deb_xfer("%02x: ", i - 15); 824786baecfSMauro Carvalho Chehab debug_dump(eepromline, 16, deb_xfer); 825786baecfSMauro Carvalho Chehab } 826786baecfSMauro Carvalho Chehab } 827786baecfSMauro Carvalho Chehab 828786baecfSMauro Carvalho Chehab memcpy(mac, eeprom + 8, 6); 829786baecfSMauro Carvalho Chehab return 0; 830786baecfSMauro Carvalho Chehab }; 831786baecfSMauro Carvalho Chehab 832786baecfSMauro Carvalho Chehab static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 833786baecfSMauro Carvalho Chehab { 834786baecfSMauro Carvalho Chehab int i, ret; 835786baecfSMauro Carvalho Chehab u8 ibuf[] = { 0 }, obuf[] = { 0 }; 836786baecfSMauro Carvalho Chehab u8 eeprom[256], eepromline[16]; 837786baecfSMauro Carvalho Chehab struct i2c_msg msg[] = { 838786baecfSMauro Carvalho Chehab { 839786baecfSMauro Carvalho Chehab .addr = 0xa0 >> 1, 840786baecfSMauro Carvalho Chehab .flags = 0, 841786baecfSMauro Carvalho Chehab .buf = obuf, 842786baecfSMauro Carvalho Chehab .len = 1, 843786baecfSMauro Carvalho Chehab }, { 844786baecfSMauro Carvalho Chehab .addr = 0xa0 >> 1, 845786baecfSMauro Carvalho Chehab .flags = I2C_M_RD, 846786baecfSMauro Carvalho Chehab .buf = ibuf, 847786baecfSMauro Carvalho Chehab .len = 1, 848786baecfSMauro Carvalho Chehab } 849786baecfSMauro Carvalho Chehab }; 850786baecfSMauro Carvalho Chehab 851786baecfSMauro Carvalho Chehab for (i = 0; i < 256; i++) { 852786baecfSMauro Carvalho Chehab obuf[0] = i; 853786baecfSMauro Carvalho Chehab ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2); 854786baecfSMauro Carvalho Chehab if (ret != 2) { 855786baecfSMauro Carvalho Chehab err("read eeprom failed."); 856786baecfSMauro Carvalho Chehab return -1; 857786baecfSMauro Carvalho Chehab } else { 858786baecfSMauro Carvalho Chehab eepromline[i % 16] = ibuf[0]; 859786baecfSMauro Carvalho Chehab eeprom[i] = ibuf[0]; 860786baecfSMauro Carvalho Chehab } 861786baecfSMauro Carvalho Chehab 862786baecfSMauro Carvalho Chehab if ((i % 16) == 15) { 863786baecfSMauro Carvalho Chehab deb_xfer("%02x: ", i - 15); 864786baecfSMauro Carvalho Chehab debug_dump(eepromline, 16, deb_xfer); 865786baecfSMauro Carvalho Chehab } 866786baecfSMauro Carvalho Chehab } 867786baecfSMauro Carvalho Chehab 868786baecfSMauro Carvalho Chehab memcpy(mac, eeprom + 16, 6); 869786baecfSMauro Carvalho Chehab return 0; 870786baecfSMauro Carvalho Chehab }; 871786baecfSMauro Carvalho Chehab 872786baecfSMauro Carvalho Chehab static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 873786baecfSMauro Carvalho Chehab { 874786baecfSMauro Carvalho Chehab static u8 command_start[] = {0x00}; 875786baecfSMauro Carvalho Chehab static u8 command_stop[] = {0x01}; 876786baecfSMauro Carvalho Chehab struct i2c_msg msg = { 877786baecfSMauro Carvalho Chehab .addr = SU3000_STREAM_CTRL, 878786baecfSMauro Carvalho Chehab .flags = 0, 879786baecfSMauro Carvalho Chehab .buf = onoff ? command_start : command_stop, 880786baecfSMauro Carvalho Chehab .len = 1 881786baecfSMauro Carvalho Chehab }; 882786baecfSMauro Carvalho Chehab 883786baecfSMauro Carvalho Chehab i2c_transfer(&adap->dev->i2c_adap, &msg, 1); 884786baecfSMauro Carvalho Chehab 885786baecfSMauro Carvalho Chehab return 0; 886786baecfSMauro Carvalho Chehab } 887786baecfSMauro Carvalho Chehab 888786baecfSMauro Carvalho Chehab static int su3000_power_ctrl(struct dvb_usb_device *d, int i) 889786baecfSMauro Carvalho Chehab { 890786baecfSMauro Carvalho Chehab struct su3000_state *state = (struct su3000_state *)d->priv; 891786baecfSMauro Carvalho Chehab u8 obuf[] = {0xde, 0}; 892786baecfSMauro Carvalho Chehab 893786baecfSMauro Carvalho Chehab info("%s: %d, initialized %d\n", __func__, i, state->initialized); 894786baecfSMauro Carvalho Chehab 895786baecfSMauro Carvalho Chehab if (i && !state->initialized) { 896786baecfSMauro Carvalho Chehab state->initialized = 1; 897786baecfSMauro Carvalho Chehab /* reset board */ 898786baecfSMauro Carvalho Chehab dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0); 899786baecfSMauro Carvalho Chehab } 900786baecfSMauro Carvalho Chehab 901786baecfSMauro Carvalho Chehab return 0; 902786baecfSMauro Carvalho Chehab } 903786baecfSMauro Carvalho Chehab 904786baecfSMauro Carvalho Chehab static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 905786baecfSMauro Carvalho Chehab { 906786baecfSMauro Carvalho Chehab int i; 907786baecfSMauro Carvalho Chehab u8 obuf[] = { 0x1f, 0xf0 }; 908786baecfSMauro Carvalho Chehab u8 ibuf[] = { 0 }; 909786baecfSMauro Carvalho Chehab struct i2c_msg msg[] = { 910786baecfSMauro Carvalho Chehab { 911786baecfSMauro Carvalho Chehab .addr = 0x51, 912786baecfSMauro Carvalho Chehab .flags = 0, 913786baecfSMauro Carvalho Chehab .buf = obuf, 914786baecfSMauro Carvalho Chehab .len = 2, 915786baecfSMauro Carvalho Chehab }, { 916786baecfSMauro Carvalho Chehab .addr = 0x51, 917786baecfSMauro Carvalho Chehab .flags = I2C_M_RD, 918786baecfSMauro Carvalho Chehab .buf = ibuf, 919786baecfSMauro Carvalho Chehab .len = 1, 920786baecfSMauro Carvalho Chehab 921786baecfSMauro Carvalho Chehab } 922786baecfSMauro Carvalho Chehab }; 923786baecfSMauro Carvalho Chehab 924786baecfSMauro Carvalho Chehab for (i = 0; i < 6; i++) { 925786baecfSMauro Carvalho Chehab obuf[1] = 0xf0 + i; 926786baecfSMauro Carvalho Chehab if (i2c_transfer(&d->i2c_adap, msg, 2) != 2) 927786baecfSMauro Carvalho Chehab break; 928786baecfSMauro Carvalho Chehab else 929786baecfSMauro Carvalho Chehab mac[i] = ibuf[0]; 930786baecfSMauro Carvalho Chehab 931786baecfSMauro Carvalho Chehab debug_dump(mac, 6, printk); 932786baecfSMauro Carvalho Chehab } 933786baecfSMauro Carvalho Chehab 934786baecfSMauro Carvalho Chehab return 0; 935786baecfSMauro Carvalho Chehab } 936786baecfSMauro Carvalho Chehab 937786baecfSMauro Carvalho Chehab static int su3000_identify_state(struct usb_device *udev, 938786baecfSMauro Carvalho Chehab struct dvb_usb_device_properties *props, 939786baecfSMauro Carvalho Chehab struct dvb_usb_device_description **desc, 940786baecfSMauro Carvalho Chehab int *cold) 941786baecfSMauro Carvalho Chehab { 942786baecfSMauro Carvalho Chehab info("%s\n", __func__); 943786baecfSMauro Carvalho Chehab 944786baecfSMauro Carvalho Chehab *cold = 0; 945786baecfSMauro Carvalho Chehab return 0; 946786baecfSMauro Carvalho Chehab } 947786baecfSMauro Carvalho Chehab 948786baecfSMauro Carvalho Chehab static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 949786baecfSMauro Carvalho Chehab { 950786baecfSMauro Carvalho Chehab static u8 command_13v[] = {0x00, 0x01}; 951786baecfSMauro Carvalho Chehab static u8 command_18v[] = {0x01, 0x01}; 952786baecfSMauro Carvalho Chehab static u8 command_off[] = {0x00, 0x00}; 953786baecfSMauro Carvalho Chehab struct i2c_msg msg = { 954786baecfSMauro Carvalho Chehab .addr = DW2102_VOLTAGE_CTRL, 955786baecfSMauro Carvalho Chehab .flags = 0, 956786baecfSMauro Carvalho Chehab .buf = command_off, 957786baecfSMauro Carvalho Chehab .len = 2, 958786baecfSMauro Carvalho Chehab }; 959786baecfSMauro Carvalho Chehab 960786baecfSMauro Carvalho Chehab struct dvb_usb_adapter *udev_adap = 961786baecfSMauro Carvalho Chehab (struct dvb_usb_adapter *)(fe->dvb->priv); 962786baecfSMauro Carvalho Chehab if (voltage == SEC_VOLTAGE_18) 963786baecfSMauro Carvalho Chehab msg.buf = command_18v; 964786baecfSMauro Carvalho Chehab else if (voltage == SEC_VOLTAGE_13) 965786baecfSMauro Carvalho Chehab msg.buf = command_13v; 966786baecfSMauro Carvalho Chehab 967786baecfSMauro Carvalho Chehab i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); 968786baecfSMauro Carvalho Chehab 969786baecfSMauro Carvalho Chehab return 0; 970786baecfSMauro Carvalho Chehab } 971786baecfSMauro Carvalho Chehab 972786baecfSMauro Carvalho Chehab static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 973786baecfSMauro Carvalho Chehab { 974786baecfSMauro Carvalho Chehab struct dvb_usb_adapter *d = 975786baecfSMauro Carvalho Chehab (struct dvb_usb_adapter *)(fe->dvb->priv); 976786baecfSMauro Carvalho Chehab struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; 977786baecfSMauro Carvalho Chehab 978786baecfSMauro Carvalho Chehab dw210x_set_voltage(fe, voltage); 979786baecfSMauro Carvalho Chehab if (st->old_set_voltage) 980786baecfSMauro Carvalho Chehab st->old_set_voltage(fe, voltage); 981786baecfSMauro Carvalho Chehab 982786baecfSMauro Carvalho Chehab return 0; 983786baecfSMauro Carvalho Chehab } 984786baecfSMauro Carvalho Chehab 985786baecfSMauro Carvalho Chehab static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon) 986786baecfSMauro Carvalho Chehab { 987786baecfSMauro Carvalho Chehab static u8 led_off[] = { 0 }; 988786baecfSMauro Carvalho Chehab static u8 led_on[] = { 1 }; 989786baecfSMauro Carvalho Chehab struct i2c_msg msg = { 990786baecfSMauro Carvalho Chehab .addr = DW2102_LED_CTRL, 991786baecfSMauro Carvalho Chehab .flags = 0, 992786baecfSMauro Carvalho Chehab .buf = led_off, 993786baecfSMauro Carvalho Chehab .len = 1 994786baecfSMauro Carvalho Chehab }; 995786baecfSMauro Carvalho Chehab struct dvb_usb_adapter *udev_adap = 996786baecfSMauro Carvalho Chehab (struct dvb_usb_adapter *)(fe->dvb->priv); 997786baecfSMauro Carvalho Chehab 998786baecfSMauro Carvalho Chehab if (offon) 999786baecfSMauro Carvalho Chehab msg.buf = led_on; 1000786baecfSMauro Carvalho Chehab i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); 1001786baecfSMauro Carvalho Chehab } 1002786baecfSMauro Carvalho Chehab 1003786baecfSMauro Carvalho Chehab static struct stv0299_config sharp_z0194a_config = { 1004786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1005786baecfSMauro Carvalho Chehab .inittab = sharp_z0194a_inittab, 1006786baecfSMauro Carvalho Chehab .mclk = 88000000UL, 1007786baecfSMauro Carvalho Chehab .invert = 1, 1008786baecfSMauro Carvalho Chehab .skip_reinit = 0, 1009786baecfSMauro Carvalho Chehab .lock_output = STV0299_LOCKOUTPUT_1, 1010786baecfSMauro Carvalho Chehab .volt13_op0_op1 = STV0299_VOLT13_OP1, 1011786baecfSMauro Carvalho Chehab .min_delay_ms = 100, 1012786baecfSMauro Carvalho Chehab .set_symbol_rate = sharp_z0194a_set_symbol_rate, 1013786baecfSMauro Carvalho Chehab }; 1014786baecfSMauro Carvalho Chehab 1015786baecfSMauro Carvalho Chehab static struct cx24116_config dw2104_config = { 1016786baecfSMauro Carvalho Chehab .demod_address = 0x55, 1017786baecfSMauro Carvalho Chehab .mpg_clk_pos_pol = 0x01, 1018786baecfSMauro Carvalho Chehab }; 1019786baecfSMauro Carvalho Chehab 1020786baecfSMauro Carvalho Chehab static struct si21xx_config serit_sp1511lhb_config = { 1021786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1022786baecfSMauro Carvalho Chehab .min_delay_ms = 100, 1023786baecfSMauro Carvalho Chehab 1024786baecfSMauro Carvalho Chehab }; 1025786baecfSMauro Carvalho Chehab 1026786baecfSMauro Carvalho Chehab static struct tda10023_config dw3101_tda10023_config = { 1027786baecfSMauro Carvalho Chehab .demod_address = 0x0c, 1028786baecfSMauro Carvalho Chehab .invert = 1, 1029786baecfSMauro Carvalho Chehab }; 1030786baecfSMauro Carvalho Chehab 1031786baecfSMauro Carvalho Chehab static struct mt312_config zl313_config = { 1032786baecfSMauro Carvalho Chehab .demod_address = 0x0e, 1033786baecfSMauro Carvalho Chehab }; 1034786baecfSMauro Carvalho Chehab 1035786baecfSMauro Carvalho Chehab static struct ds3000_config dw2104_ds3000_config = { 1036786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1037786baecfSMauro Carvalho Chehab }; 1038786baecfSMauro Carvalho Chehab 103973f0af44SKonstantin Dimitrov static struct ts2020_config dw2104_ts2020_config = { 104073f0af44SKonstantin Dimitrov .tuner_address = 0x60, 1041b858c331SIgor M. Liplianin .clk_out_div = 1, 104203a67279SJohn Horan .frequency_div = 1060000, 104373f0af44SKonstantin Dimitrov }; 104473f0af44SKonstantin Dimitrov 104543385c8aSIgor M. Liplianin static struct ds3000_config s660_ds3000_config = { 104643385c8aSIgor M. Liplianin .demod_address = 0x68, 1047b858c331SIgor M. Liplianin .ci_mode = 1, 104843385c8aSIgor M. Liplianin .set_lock_led = dw210x_led_ctrl, 104943385c8aSIgor M. Liplianin }; 105043385c8aSIgor M. Liplianin 105103a67279SJohn Horan static struct ts2020_config s660_ts2020_config = { 105203a67279SJohn Horan .tuner_address = 0x60, 105303a67279SJohn Horan .clk_out_div = 1, 105403a67279SJohn Horan .frequency_div = 1146000, 105503a67279SJohn Horan }; 105603a67279SJohn Horan 1057786baecfSMauro Carvalho Chehab static struct stv0900_config dw2104a_stv0900_config = { 1058786baecfSMauro Carvalho Chehab .demod_address = 0x6a, 1059786baecfSMauro Carvalho Chehab .demod_mode = 0, 1060786baecfSMauro Carvalho Chehab .xtal = 27000000, 1061786baecfSMauro Carvalho Chehab .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 1062786baecfSMauro Carvalho Chehab .diseqc_mode = 2,/* 2/3 PWM */ 1063786baecfSMauro Carvalho Chehab .tun1_maddress = 0,/* 0x60 */ 1064786baecfSMauro Carvalho Chehab .tun1_adc = 0,/* 2 Vpp */ 1065786baecfSMauro Carvalho Chehab .path1_mode = 3, 1066786baecfSMauro Carvalho Chehab }; 1067786baecfSMauro Carvalho Chehab 1068786baecfSMauro Carvalho Chehab static struct stb6100_config dw2104a_stb6100_config = { 1069786baecfSMauro Carvalho Chehab .tuner_address = 0x60, 1070786baecfSMauro Carvalho Chehab .refclock = 27000000, 1071786baecfSMauro Carvalho Chehab }; 1072786baecfSMauro Carvalho Chehab 1073786baecfSMauro Carvalho Chehab static struct stv0900_config dw2104_stv0900_config = { 1074786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1075786baecfSMauro Carvalho Chehab .demod_mode = 0, 1076786baecfSMauro Carvalho Chehab .xtal = 8000000, 1077786baecfSMauro Carvalho Chehab .clkmode = 3, 1078786baecfSMauro Carvalho Chehab .diseqc_mode = 2, 1079786baecfSMauro Carvalho Chehab .tun1_maddress = 0, 1080786baecfSMauro Carvalho Chehab .tun1_adc = 1,/* 1 Vpp */ 1081786baecfSMauro Carvalho Chehab .path1_mode = 3, 1082786baecfSMauro Carvalho Chehab }; 1083786baecfSMauro Carvalho Chehab 1084786baecfSMauro Carvalho Chehab static struct stv6110_config dw2104_stv6110_config = { 1085786baecfSMauro Carvalho Chehab .i2c_address = 0x60, 1086786baecfSMauro Carvalho Chehab .mclk = 16000000, 1087786baecfSMauro Carvalho Chehab .clk_div = 1, 1088786baecfSMauro Carvalho Chehab }; 1089786baecfSMauro Carvalho Chehab 1090786baecfSMauro Carvalho Chehab static struct stv0900_config prof_7500_stv0900_config = { 1091786baecfSMauro Carvalho Chehab .demod_address = 0x6a, 1092786baecfSMauro Carvalho Chehab .demod_mode = 0, 1093786baecfSMauro Carvalho Chehab .xtal = 27000000, 1094786baecfSMauro Carvalho Chehab .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 1095786baecfSMauro Carvalho Chehab .diseqc_mode = 2,/* 2/3 PWM */ 1096786baecfSMauro Carvalho Chehab .tun1_maddress = 0,/* 0x60 */ 1097786baecfSMauro Carvalho Chehab .tun1_adc = 0,/* 2 Vpp */ 1098786baecfSMauro Carvalho Chehab .path1_mode = 3, 1099786baecfSMauro Carvalho Chehab .tun1_type = 3, 1100786baecfSMauro Carvalho Chehab .set_lock_led = dw210x_led_ctrl, 1101786baecfSMauro Carvalho Chehab }; 1102786baecfSMauro Carvalho Chehab 1103786baecfSMauro Carvalho Chehab static struct ds3000_config su3000_ds3000_config = { 1104786baecfSMauro Carvalho Chehab .demod_address = 0x68, 1105786baecfSMauro Carvalho Chehab .ci_mode = 1, 1106b858c331SIgor M. Liplianin .set_lock_led = dw210x_led_ctrl, 110773f0af44SKonstantin Dimitrov }; 110873f0af44SKonstantin Dimitrov 110951d882edSEvgeny Plehov static struct cxd2820r_config cxd2820r_config = { 111051d882edSEvgeny Plehov .i2c_address = 0x6c, /* (0xd8 >> 1) */ 111151d882edSEvgeny Plehov .ts_mode = 0x38, 11127b71ef7eSCrazyCat .ts_clock_inv = 1, 111351d882edSEvgeny Plehov }; 111451d882edSEvgeny Plehov 111551d882edSEvgeny Plehov static struct tda18271_config tda18271_config = { 111651d882edSEvgeny Plehov .output_opt = TDA18271_OUTPUT_LT_OFF, 111751d882edSEvgeny Plehov .gate = TDA18271_GATE_DIGITAL, 111851d882edSEvgeny Plehov }; 111951d882edSEvgeny Plehov 1120955d00acSIgor M. Liplianin static u8 m88rs2000_inittab[] = { 1121955d00acSIgor M. Liplianin DEMOD_WRITE, 0x9a, 0x30, 1122955d00acSIgor M. Liplianin DEMOD_WRITE, 0x00, 0x01, 1123955d00acSIgor M. Liplianin WRITE_DELAY, 0x19, 0x00, 1124955d00acSIgor M. Liplianin DEMOD_WRITE, 0x00, 0x00, 1125955d00acSIgor M. Liplianin DEMOD_WRITE, 0x9a, 0xb0, 1126955d00acSIgor M. Liplianin DEMOD_WRITE, 0x81, 0xc1, 1127955d00acSIgor M. Liplianin DEMOD_WRITE, 0x81, 0x81, 1128955d00acSIgor M. Liplianin DEMOD_WRITE, 0x86, 0xc6, 1129955d00acSIgor M. Liplianin DEMOD_WRITE, 0x9a, 0x30, 1130955d00acSIgor M. Liplianin DEMOD_WRITE, 0xf0, 0x80, 1131955d00acSIgor M. Liplianin DEMOD_WRITE, 0xf1, 0xbf, 1132955d00acSIgor M. Liplianin DEMOD_WRITE, 0xb0, 0x45, 1133955d00acSIgor M. Liplianin DEMOD_WRITE, 0xb2, 0x01, 1134955d00acSIgor M. Liplianin DEMOD_WRITE, 0x9a, 0xb0, 1135955d00acSIgor M. Liplianin 0xff, 0xaa, 0xff 1136955d00acSIgor M. Liplianin }; 1137955d00acSIgor M. Liplianin 1138955d00acSIgor M. Liplianin static struct m88rs2000_config s421_m88rs2000_config = { 1139955d00acSIgor M. Liplianin .demod_addr = 0x68, 1140955d00acSIgor M. Liplianin .inittab = m88rs2000_inittab, 1141955d00acSIgor M. Liplianin }; 1142955d00acSIgor M. Liplianin 1143786baecfSMauro Carvalho Chehab static int dw2104_frontend_attach(struct dvb_usb_adapter *d) 1144786baecfSMauro Carvalho Chehab { 1145786baecfSMauro Carvalho Chehab struct dvb_tuner_ops *tuner_ops = NULL; 1146786baecfSMauro Carvalho Chehab 1147786baecfSMauro Carvalho Chehab if (demod_probe & 4) { 1148786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config, 1149786baecfSMauro Carvalho Chehab &d->dev->i2c_adap, 0); 1150786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1151786baecfSMauro Carvalho Chehab if (dvb_attach(stb6100_attach, d->fe_adap[0].fe, 1152786baecfSMauro Carvalho Chehab &dw2104a_stb6100_config, 1153786baecfSMauro Carvalho Chehab &d->dev->i2c_adap)) { 1154786baecfSMauro Carvalho Chehab tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops; 1155786baecfSMauro Carvalho Chehab tuner_ops->set_frequency = stb6100_set_freq; 1156786baecfSMauro Carvalho Chehab tuner_ops->get_frequency = stb6100_get_freq; 1157786baecfSMauro Carvalho Chehab tuner_ops->set_bandwidth = stb6100_set_bandw; 1158786baecfSMauro Carvalho Chehab tuner_ops->get_bandwidth = stb6100_get_bandw; 1159786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1160786baecfSMauro Carvalho Chehab info("Attached STV0900+STB6100!\n"); 1161786baecfSMauro Carvalho Chehab return 0; 1162786baecfSMauro Carvalho Chehab } 1163786baecfSMauro Carvalho Chehab } 1164786baecfSMauro Carvalho Chehab } 1165786baecfSMauro Carvalho Chehab 1166786baecfSMauro Carvalho Chehab if (demod_probe & 2) { 1167786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config, 1168786baecfSMauro Carvalho Chehab &d->dev->i2c_adap, 0); 1169786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1170786baecfSMauro Carvalho Chehab if (dvb_attach(stv6110_attach, d->fe_adap[0].fe, 1171786baecfSMauro Carvalho Chehab &dw2104_stv6110_config, 1172786baecfSMauro Carvalho Chehab &d->dev->i2c_adap)) { 1173786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1174786baecfSMauro Carvalho Chehab info("Attached STV0900+STV6110A!\n"); 1175786baecfSMauro Carvalho Chehab return 0; 1176786baecfSMauro Carvalho Chehab } 1177786baecfSMauro Carvalho Chehab } 1178786baecfSMauro Carvalho Chehab } 1179786baecfSMauro Carvalho Chehab 1180786baecfSMauro Carvalho Chehab if (demod_probe & 1) { 1181786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config, 1182786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1183786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1184786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1185786baecfSMauro Carvalho Chehab info("Attached cx24116!\n"); 1186786baecfSMauro Carvalho Chehab return 0; 1187786baecfSMauro Carvalho Chehab } 1188786baecfSMauro Carvalho Chehab } 1189786baecfSMauro Carvalho Chehab 1190786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, 1191786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1192786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 119373f0af44SKonstantin Dimitrov dvb_attach(ts2020_attach, d->fe_adap[0].fe, 119473f0af44SKonstantin Dimitrov &dw2104_ts2020_config, &d->dev->i2c_adap); 1195786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1196786baecfSMauro Carvalho Chehab info("Attached DS3000!\n"); 1197786baecfSMauro Carvalho Chehab return 0; 1198786baecfSMauro Carvalho Chehab } 1199786baecfSMauro Carvalho Chehab 1200786baecfSMauro Carvalho Chehab return -EIO; 1201786baecfSMauro Carvalho Chehab } 1202786baecfSMauro Carvalho Chehab 1203786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2102_properties; 1204786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2104_properties; 1205786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties s6x0_properties; 1206786baecfSMauro Carvalho Chehab 1207786baecfSMauro Carvalho Chehab static int dw2102_frontend_attach(struct dvb_usb_adapter *d) 1208786baecfSMauro Carvalho Chehab { 1209786baecfSMauro Carvalho Chehab if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) { 1210786baecfSMauro Carvalho Chehab /*dw2102_properties.adapter->tuner_attach = NULL;*/ 1211786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config, 1212786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1213786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1214786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1215786baecfSMauro Carvalho Chehab info("Attached si21xx!\n"); 1216786baecfSMauro Carvalho Chehab return 0; 1217786baecfSMauro Carvalho Chehab } 1218786baecfSMauro Carvalho Chehab } 1219786baecfSMauro Carvalho Chehab 1220786baecfSMauro Carvalho Chehab if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) { 1221786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, 1222786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1223786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1224786baecfSMauro Carvalho Chehab if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, 1225786baecfSMauro Carvalho Chehab &d->dev->i2c_adap)) { 1226786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1227786baecfSMauro Carvalho Chehab info("Attached stv0288!\n"); 1228786baecfSMauro Carvalho Chehab return 0; 1229786baecfSMauro Carvalho Chehab } 1230786baecfSMauro Carvalho Chehab } 1231786baecfSMauro Carvalho Chehab } 1232786baecfSMauro Carvalho Chehab 1233786baecfSMauro Carvalho Chehab if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) { 1234786baecfSMauro Carvalho Chehab /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ 1235786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config, 1236786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1237786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1238786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1239786baecfSMauro Carvalho Chehab info("Attached stv0299!\n"); 1240786baecfSMauro Carvalho Chehab return 0; 1241786baecfSMauro Carvalho Chehab } 1242786baecfSMauro Carvalho Chehab } 1243786baecfSMauro Carvalho Chehab return -EIO; 1244786baecfSMauro Carvalho Chehab } 1245786baecfSMauro Carvalho Chehab 1246786baecfSMauro Carvalho Chehab static int dw3101_frontend_attach(struct dvb_usb_adapter *d) 1247786baecfSMauro Carvalho Chehab { 1248786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config, 1249786baecfSMauro Carvalho Chehab &d->dev->i2c_adap, 0x48); 1250786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1251786baecfSMauro Carvalho Chehab info("Attached tda10023!\n"); 1252786baecfSMauro Carvalho Chehab return 0; 1253786baecfSMauro Carvalho Chehab } 1254786baecfSMauro Carvalho Chehab return -EIO; 1255786baecfSMauro Carvalho Chehab } 1256786baecfSMauro Carvalho Chehab 1257786baecfSMauro Carvalho Chehab static int zl100313_frontend_attach(struct dvb_usb_adapter *d) 1258786baecfSMauro Carvalho Chehab { 1259786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config, 1260786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1261786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe != NULL) { 1262786baecfSMauro Carvalho Chehab if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60, 1263786baecfSMauro Carvalho Chehab &d->dev->i2c_adap)) { 1264786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1265786baecfSMauro Carvalho Chehab info("Attached zl100313+zl10039!\n"); 1266786baecfSMauro Carvalho Chehab return 0; 1267786baecfSMauro Carvalho Chehab } 1268786baecfSMauro Carvalho Chehab } 1269786baecfSMauro Carvalho Chehab 1270786baecfSMauro Carvalho Chehab return -EIO; 1271786baecfSMauro Carvalho Chehab } 1272786baecfSMauro Carvalho Chehab 1273786baecfSMauro Carvalho Chehab static int stv0288_frontend_attach(struct dvb_usb_adapter *d) 1274786baecfSMauro Carvalho Chehab { 1275786baecfSMauro Carvalho Chehab u8 obuf[] = {7, 1}; 1276786baecfSMauro Carvalho Chehab 1277786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, 1278786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1279786baecfSMauro Carvalho Chehab 1280786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe == NULL) 1281786baecfSMauro Carvalho Chehab return -EIO; 1282786baecfSMauro Carvalho Chehab 1283786baecfSMauro Carvalho Chehab if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap)) 1284786baecfSMauro Carvalho Chehab return -EIO; 1285786baecfSMauro Carvalho Chehab 1286786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1287786baecfSMauro Carvalho Chehab 1288786baecfSMauro Carvalho Chehab dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1289786baecfSMauro Carvalho Chehab 1290786baecfSMauro Carvalho Chehab info("Attached stv0288+stb6000!\n"); 1291786baecfSMauro Carvalho Chehab 1292786baecfSMauro Carvalho Chehab return 0; 1293786baecfSMauro Carvalho Chehab 1294786baecfSMauro Carvalho Chehab } 1295786baecfSMauro Carvalho Chehab 1296786baecfSMauro Carvalho Chehab static int ds3000_frontend_attach(struct dvb_usb_adapter *d) 1297786baecfSMauro Carvalho Chehab { 1298786baecfSMauro Carvalho Chehab struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; 1299786baecfSMauro Carvalho Chehab u8 obuf[] = {7, 1}; 1300786baecfSMauro Carvalho Chehab 130143385c8aSIgor M. Liplianin d->fe_adap[0].fe = dvb_attach(ds3000_attach, &s660_ds3000_config, 1302786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1303786baecfSMauro Carvalho Chehab 1304786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe == NULL) 1305786baecfSMauro Carvalho Chehab return -EIO; 1306786baecfSMauro Carvalho Chehab 130703a67279SJohn Horan dvb_attach(ts2020_attach, d->fe_adap[0].fe, &s660_ts2020_config, 130873f0af44SKonstantin Dimitrov &d->dev->i2c_adap); 130973f0af44SKonstantin Dimitrov 1310786baecfSMauro Carvalho Chehab st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; 1311786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage; 1312786baecfSMauro Carvalho Chehab 1313786baecfSMauro Carvalho Chehab dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1314786baecfSMauro Carvalho Chehab 131503a67279SJohn Horan info("Attached ds3000+ts2020!\n"); 1316786baecfSMauro Carvalho Chehab 1317786baecfSMauro Carvalho Chehab return 0; 1318786baecfSMauro Carvalho Chehab } 1319786baecfSMauro Carvalho Chehab 1320786baecfSMauro Carvalho Chehab static int prof_7500_frontend_attach(struct dvb_usb_adapter *d) 1321786baecfSMauro Carvalho Chehab { 1322786baecfSMauro Carvalho Chehab u8 obuf[] = {7, 1}; 1323786baecfSMauro Carvalho Chehab 1324786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config, 1325786baecfSMauro Carvalho Chehab &d->dev->i2c_adap, 0); 1326786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe == NULL) 1327786baecfSMauro Carvalho Chehab return -EIO; 1328786baecfSMauro Carvalho Chehab 1329786baecfSMauro Carvalho Chehab d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1330786baecfSMauro Carvalho Chehab 1331786baecfSMauro Carvalho Chehab dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1332786baecfSMauro Carvalho Chehab 1333786baecfSMauro Carvalho Chehab info("Attached STV0900+STB6100A!\n"); 1334786baecfSMauro Carvalho Chehab 1335786baecfSMauro Carvalho Chehab return 0; 1336786baecfSMauro Carvalho Chehab } 1337786baecfSMauro Carvalho Chehab 1338786baecfSMauro Carvalho Chehab static int su3000_frontend_attach(struct dvb_usb_adapter *d) 1339786baecfSMauro Carvalho Chehab { 1340786baecfSMauro Carvalho Chehab u8 obuf[3] = { 0xe, 0x80, 0 }; 1341786baecfSMauro Carvalho Chehab u8 ibuf[] = { 0 }; 1342786baecfSMauro Carvalho Chehab 1343786baecfSMauro Carvalho Chehab if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 1344786baecfSMauro Carvalho Chehab err("command 0x0e transfer failed."); 1345786baecfSMauro Carvalho Chehab 1346786baecfSMauro Carvalho Chehab obuf[0] = 0xe; 1347b858c331SIgor M. Liplianin obuf[1] = 0x02; 1348b858c331SIgor M. Liplianin obuf[2] = 1; 1349b858c331SIgor M. Liplianin 1350b858c331SIgor M. Liplianin if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 1351b858c331SIgor M. Liplianin err("command 0x0e transfer failed."); 1352b858c331SIgor M. Liplianin msleep(300); 1353b858c331SIgor M. Liplianin 1354b858c331SIgor M. Liplianin obuf[0] = 0xe; 1355786baecfSMauro Carvalho Chehab obuf[1] = 0x83; 1356786baecfSMauro Carvalho Chehab obuf[2] = 0; 1357786baecfSMauro Carvalho Chehab 1358786baecfSMauro Carvalho Chehab if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 1359786baecfSMauro Carvalho Chehab err("command 0x0e transfer failed."); 1360786baecfSMauro Carvalho Chehab 1361786baecfSMauro Carvalho Chehab obuf[0] = 0xe; 1362786baecfSMauro Carvalho Chehab obuf[1] = 0x83; 1363786baecfSMauro Carvalho Chehab obuf[2] = 1; 1364786baecfSMauro Carvalho Chehab 1365786baecfSMauro Carvalho Chehab if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 1366786baecfSMauro Carvalho Chehab err("command 0x0e transfer failed."); 1367786baecfSMauro Carvalho Chehab 1368786baecfSMauro Carvalho Chehab obuf[0] = 0x51; 1369786baecfSMauro Carvalho Chehab 1370786baecfSMauro Carvalho Chehab if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) 1371786baecfSMauro Carvalho Chehab err("command 0x51 transfer failed."); 1372786baecfSMauro Carvalho Chehab 1373786baecfSMauro Carvalho Chehab d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config, 1374786baecfSMauro Carvalho Chehab &d->dev->i2c_adap); 1375786baecfSMauro Carvalho Chehab if (d->fe_adap[0].fe == NULL) 1376786baecfSMauro Carvalho Chehab return -EIO; 1377786baecfSMauro Carvalho Chehab 1378b858c331SIgor M. Liplianin if (dvb_attach(ts2020_attach, d->fe_adap[0].fe, 1379b858c331SIgor M. Liplianin &dw2104_ts2020_config, 1380b858c331SIgor M. Liplianin &d->dev->i2c_adap)) { 1381b858c331SIgor M. Liplianin info("Attached DS3000/TS2020!\n"); 1382786baecfSMauro Carvalho Chehab return 0; 1383786baecfSMauro Carvalho Chehab } 1384786baecfSMauro Carvalho Chehab 1385b858c331SIgor M. Liplianin info("Failed to attach DS3000/TS2020!\n"); 1386b858c331SIgor M. Liplianin return -EIO; 1387b858c331SIgor M. Liplianin } 1388b858c331SIgor M. Liplianin 138951d882edSEvgeny Plehov static int t220_frontend_attach(struct dvb_usb_adapter *d) 139051d882edSEvgeny Plehov { 13917b71ef7eSCrazyCat u8 obuf[3] = { 0xe, 0x87, 0 }; 139251d882edSEvgeny Plehov u8 ibuf[] = { 0 }; 139351d882edSEvgeny Plehov 139451d882edSEvgeny Plehov if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 139551d882edSEvgeny Plehov err("command 0x0e transfer failed."); 139651d882edSEvgeny Plehov 139751d882edSEvgeny Plehov obuf[0] = 0xe; 13987b71ef7eSCrazyCat obuf[1] = 0x86; 13997b71ef7eSCrazyCat obuf[2] = 1; 14007b71ef7eSCrazyCat 14017b71ef7eSCrazyCat if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 14027b71ef7eSCrazyCat err("command 0x0e transfer failed."); 14037b71ef7eSCrazyCat 14047b71ef7eSCrazyCat obuf[0] = 0xe; 14057b71ef7eSCrazyCat obuf[1] = 0x80; 140651d882edSEvgeny Plehov obuf[2] = 0; 140751d882edSEvgeny Plehov 140851d882edSEvgeny Plehov if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 140951d882edSEvgeny Plehov err("command 0x0e transfer failed."); 141051d882edSEvgeny Plehov 14117b71ef7eSCrazyCat msleep(50); 141251d882edSEvgeny Plehov 141351d882edSEvgeny Plehov obuf[0] = 0xe; 141451d882edSEvgeny Plehov obuf[1] = 0x80; 141551d882edSEvgeny Plehov obuf[2] = 1; 141651d882edSEvgeny Plehov 141751d882edSEvgeny Plehov if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 141851d882edSEvgeny Plehov err("command 0x0e transfer failed."); 141951d882edSEvgeny Plehov 142051d882edSEvgeny Plehov obuf[0] = 0x51; 142151d882edSEvgeny Plehov 142251d882edSEvgeny Plehov if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) 142351d882edSEvgeny Plehov err("command 0x51 transfer failed."); 142451d882edSEvgeny Plehov 142551d882edSEvgeny Plehov d->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config, 142651d882edSEvgeny Plehov &d->dev->i2c_adap, NULL); 142751d882edSEvgeny Plehov if (d->fe_adap[0].fe != NULL) { 142851d882edSEvgeny Plehov if (dvb_attach(tda18271_attach, d->fe_adap[0].fe, 0x60, 142951d882edSEvgeny Plehov &d->dev->i2c_adap, &tda18271_config)) { 143051d882edSEvgeny Plehov info("Attached TDA18271HD/CXD2820R!\n"); 143151d882edSEvgeny Plehov return 0; 143251d882edSEvgeny Plehov } 143351d882edSEvgeny Plehov } 143451d882edSEvgeny Plehov 143551d882edSEvgeny Plehov info("Failed to attach TDA18271HD/CXD2820R!\n"); 143651d882edSEvgeny Plehov return -EIO; 143751d882edSEvgeny Plehov } 143851d882edSEvgeny Plehov 1439955d00acSIgor M. Liplianin static int m88rs2000_frontend_attach(struct dvb_usb_adapter *d) 1440955d00acSIgor M. Liplianin { 1441955d00acSIgor M. Liplianin u8 obuf[] = { 0x51 }; 1442955d00acSIgor M. Liplianin u8 ibuf[] = { 0 }; 1443955d00acSIgor M. Liplianin 1444955d00acSIgor M. Liplianin if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) 1445955d00acSIgor M. Liplianin err("command 0x51 transfer failed."); 1446955d00acSIgor M. Liplianin 1447955d00acSIgor M. Liplianin d->fe_adap[0].fe = dvb_attach(m88rs2000_attach, &s421_m88rs2000_config, 1448955d00acSIgor M. Liplianin &d->dev->i2c_adap); 1449b858c331SIgor M. Liplianin 1450955d00acSIgor M. Liplianin if (d->fe_adap[0].fe == NULL) 1451955d00acSIgor M. Liplianin return -EIO; 1452955d00acSIgor M. Liplianin 1453b858c331SIgor M. Liplianin if (dvb_attach(ts2020_attach, d->fe_adap[0].fe, 1454b858c331SIgor M. Liplianin &dw2104_ts2020_config, 1455b858c331SIgor M. Liplianin &d->dev->i2c_adap)) { 1456b858c331SIgor M. Liplianin info("Attached RS2000/TS2020!\n"); 1457955d00acSIgor M. Liplianin return 0; 1458955d00acSIgor M. Liplianin } 1459955d00acSIgor M. Liplianin 1460b858c331SIgor M. Liplianin info("Failed to attach RS2000/TS2020!\n"); 1461b858c331SIgor M. Liplianin return -EIO; 1462b858c331SIgor M. Liplianin } 1463b858c331SIgor M. Liplianin 1464786baecfSMauro Carvalho Chehab static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) 1465786baecfSMauro Carvalho Chehab { 1466786baecfSMauro Carvalho Chehab dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 1467786baecfSMauro Carvalho Chehab &adap->dev->i2c_adap, DVB_PLL_OPERA1); 1468786baecfSMauro Carvalho Chehab return 0; 1469786baecfSMauro Carvalho Chehab } 1470786baecfSMauro Carvalho Chehab 1471786baecfSMauro Carvalho Chehab static int dw3101_tuner_attach(struct dvb_usb_adapter *adap) 1472786baecfSMauro Carvalho Chehab { 1473786baecfSMauro Carvalho Chehab dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 1474786baecfSMauro Carvalho Chehab &adap->dev->i2c_adap, DVB_PLL_TUA6034); 1475786baecfSMauro Carvalho Chehab 1476786baecfSMauro Carvalho Chehab return 0; 1477786baecfSMauro Carvalho Chehab } 1478786baecfSMauro Carvalho Chehab 1479a49de26aSEvgeny Plehov static int dw2102_rc_query(struct dvb_usb_device *d) 1480786baecfSMauro Carvalho Chehab { 1481786baecfSMauro Carvalho Chehab u8 key[2]; 1482786baecfSMauro Carvalho Chehab struct i2c_msg msg = { 1483786baecfSMauro Carvalho Chehab .addr = DW2102_RC_QUERY, 1484786baecfSMauro Carvalho Chehab .flags = I2C_M_RD, 1485786baecfSMauro Carvalho Chehab .buf = key, 1486786baecfSMauro Carvalho Chehab .len = 2 1487786baecfSMauro Carvalho Chehab }; 1488786baecfSMauro Carvalho Chehab 1489786baecfSMauro Carvalho Chehab if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1490a49de26aSEvgeny Plehov if (msg.buf[0] != 0xff) { 1491a49de26aSEvgeny Plehov deb_rc("%s: rc code: %x, %x\n", 1492786baecfSMauro Carvalho Chehab __func__, key[0], key[1]); 1493120703f9SDavid Härdeman rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0], 0); 1494a49de26aSEvgeny Plehov } 1495a49de26aSEvgeny Plehov } 1496786baecfSMauro Carvalho Chehab 1497a49de26aSEvgeny Plehov return 0; 1498a49de26aSEvgeny Plehov } 1499a49de26aSEvgeny Plehov 1500a49de26aSEvgeny Plehov static int prof_rc_query(struct dvb_usb_device *d) 1501a49de26aSEvgeny Plehov { 1502a49de26aSEvgeny Plehov u8 key[2]; 1503a49de26aSEvgeny Plehov struct i2c_msg msg = { 1504a49de26aSEvgeny Plehov .addr = DW2102_RC_QUERY, 1505a49de26aSEvgeny Plehov .flags = I2C_M_RD, 1506a49de26aSEvgeny Plehov .buf = key, 1507a49de26aSEvgeny Plehov .len = 2 1508a49de26aSEvgeny Plehov }; 1509a49de26aSEvgeny Plehov 1510a49de26aSEvgeny Plehov if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1511a49de26aSEvgeny Plehov if (msg.buf[0] != 0xff) { 1512a49de26aSEvgeny Plehov deb_rc("%s: rc code: %x, %x\n", 1513a49de26aSEvgeny Plehov __func__, key[0], key[1]); 1514120703f9SDavid Härdeman rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0]^0xff, 0); 1515a49de26aSEvgeny Plehov } 1516a49de26aSEvgeny Plehov } 1517a49de26aSEvgeny Plehov 1518a49de26aSEvgeny Plehov return 0; 1519a49de26aSEvgeny Plehov } 1520a49de26aSEvgeny Plehov 1521a49de26aSEvgeny Plehov static int su3000_rc_query(struct dvb_usb_device *d) 1522a49de26aSEvgeny Plehov { 1523a49de26aSEvgeny Plehov u8 key[2]; 1524a49de26aSEvgeny Plehov struct i2c_msg msg = { 1525a49de26aSEvgeny Plehov .addr = DW2102_RC_QUERY, 1526a49de26aSEvgeny Plehov .flags = I2C_M_RD, 1527a49de26aSEvgeny Plehov .buf = key, 1528a49de26aSEvgeny Plehov .len = 2 1529a49de26aSEvgeny Plehov }; 1530a49de26aSEvgeny Plehov 1531a49de26aSEvgeny Plehov if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1532a49de26aSEvgeny Plehov if (msg.buf[0] != 0xff) { 1533a49de26aSEvgeny Plehov deb_rc("%s: rc code: %x, %x\n", 1534a49de26aSEvgeny Plehov __func__, key[0], key[1]); 1535120703f9SDavid Härdeman rc_keydown(d->rc_dev, RC_TYPE_RC5, 1536120703f9SDavid Härdeman RC_SCANCODE_RC5(key[1], key[0]), 0); 1537a49de26aSEvgeny Plehov } 1538786baecfSMauro Carvalho Chehab } 1539786baecfSMauro Carvalho Chehab 1540786baecfSMauro Carvalho Chehab return 0; 1541786baecfSMauro Carvalho Chehab } 1542786baecfSMauro Carvalho Chehab 1543786baecfSMauro Carvalho Chehab enum dw2102_table_entry { 1544786baecfSMauro Carvalho Chehab CYPRESS_DW2102, 1545786baecfSMauro Carvalho Chehab CYPRESS_DW2101, 1546786baecfSMauro Carvalho Chehab CYPRESS_DW2104, 1547786baecfSMauro Carvalho Chehab TEVII_S650, 1548786baecfSMauro Carvalho Chehab TERRATEC_CINERGY_S, 1549786baecfSMauro Carvalho Chehab CYPRESS_DW3101, 1550786baecfSMauro Carvalho Chehab TEVII_S630, 1551786baecfSMauro Carvalho Chehab PROF_1100, 1552786baecfSMauro Carvalho Chehab TEVII_S660, 1553786baecfSMauro Carvalho Chehab PROF_7500, 1554786baecfSMauro Carvalho Chehab GENIATECH_SU3000, 1555786baecfSMauro Carvalho Chehab TERRATEC_CINERGY_S2, 1556786baecfSMauro Carvalho Chehab TEVII_S480_1, 1557786baecfSMauro Carvalho Chehab TEVII_S480_2, 1558786baecfSMauro Carvalho Chehab X3M_SPC1400HD, 1559955d00acSIgor M. Liplianin TEVII_S421, 1560955d00acSIgor M. Liplianin TEVII_S632, 156144122dd6SIgor M. Liplianin TERRATEC_CINERGY_S2_R2, 1562f08e9f0dSAndrey Pavlenko GOTVIEW_SAT_HD, 156351d882edSEvgeny Plehov GENIATECH_T220, 1564786baecfSMauro Carvalho Chehab }; 1565786baecfSMauro Carvalho Chehab 1566786baecfSMauro Carvalho Chehab static struct usb_device_id dw2102_table[] = { 1567786baecfSMauro Carvalho Chehab [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)}, 1568786baecfSMauro Carvalho Chehab [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)}, 1569786baecfSMauro Carvalho Chehab [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)}, 1570786baecfSMauro Carvalho Chehab [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)}, 1571786baecfSMauro Carvalho Chehab [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)}, 1572786baecfSMauro Carvalho Chehab [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)}, 1573786baecfSMauro Carvalho Chehab [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)}, 1574786baecfSMauro Carvalho Chehab [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)}, 1575786baecfSMauro Carvalho Chehab [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)}, 1576786baecfSMauro Carvalho Chehab [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)}, 1577786baecfSMauro Carvalho Chehab [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)}, 1578786baecfSMauro Carvalho Chehab [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)}, 1579786baecfSMauro Carvalho Chehab [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)}, 1580786baecfSMauro Carvalho Chehab [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)}, 1581786baecfSMauro Carvalho Chehab [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)}, 1582955d00acSIgor M. Liplianin [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)}, 1583955d00acSIgor M. Liplianin [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)}, 158444122dd6SIgor M. Liplianin [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00b0)}, 1585f08e9f0dSAndrey Pavlenko [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)}, 158651d882edSEvgeny Plehov [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)}, 1587786baecfSMauro Carvalho Chehab { } 1588786baecfSMauro Carvalho Chehab }; 1589786baecfSMauro Carvalho Chehab 1590786baecfSMauro Carvalho Chehab MODULE_DEVICE_TABLE(usb, dw2102_table); 1591786baecfSMauro Carvalho Chehab 1592786baecfSMauro Carvalho Chehab static int dw2102_load_firmware(struct usb_device *dev, 1593786baecfSMauro Carvalho Chehab const struct firmware *frmwr) 1594786baecfSMauro Carvalho Chehab { 1595786baecfSMauro Carvalho Chehab u8 *b, *p; 1596786baecfSMauro Carvalho Chehab int ret = 0, i; 1597786baecfSMauro Carvalho Chehab u8 reset; 1598786baecfSMauro Carvalho Chehab u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; 1599786baecfSMauro Carvalho Chehab const struct firmware *fw; 1600786baecfSMauro Carvalho Chehab 1601*1ad5d064SHans Verkuil switch (le16_to_cpu(dev->descriptor.idProduct)) { 1602786baecfSMauro Carvalho Chehab case 0x2101: 16036823627bSRémi Cardona ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev); 1604786baecfSMauro Carvalho Chehab if (ret != 0) { 16056823627bSRémi Cardona err(err_str, DW2101_FIRMWARE); 1606786baecfSMauro Carvalho Chehab return ret; 1607786baecfSMauro Carvalho Chehab } 1608786baecfSMauro Carvalho Chehab break; 1609786baecfSMauro Carvalho Chehab default: 1610786baecfSMauro Carvalho Chehab fw = frmwr; 1611786baecfSMauro Carvalho Chehab break; 1612786baecfSMauro Carvalho Chehab } 1613786baecfSMauro Carvalho Chehab info("start downloading DW210X firmware"); 1614786baecfSMauro Carvalho Chehab p = kmalloc(fw->size, GFP_KERNEL); 1615786baecfSMauro Carvalho Chehab reset = 1; 1616786baecfSMauro Carvalho Chehab /*stop the CPU*/ 1617786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG); 1618786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG); 1619786baecfSMauro Carvalho Chehab 1620786baecfSMauro Carvalho Chehab if (p != NULL) { 1621786baecfSMauro Carvalho Chehab memcpy(p, fw->data, fw->size); 1622786baecfSMauro Carvalho Chehab for (i = 0; i < fw->size; i += 0x40) { 1623786baecfSMauro Carvalho Chehab b = (u8 *) p + i; 1624786baecfSMauro Carvalho Chehab if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40, 1625786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG) != 0x40) { 1626786baecfSMauro Carvalho Chehab err("error while transferring firmware"); 1627786baecfSMauro Carvalho Chehab ret = -EINVAL; 1628786baecfSMauro Carvalho Chehab break; 1629786baecfSMauro Carvalho Chehab } 1630786baecfSMauro Carvalho Chehab } 1631786baecfSMauro Carvalho Chehab /* restart the CPU */ 1632786baecfSMauro Carvalho Chehab reset = 0; 1633786baecfSMauro Carvalho Chehab if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, 1634786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG) != 1) { 1635786baecfSMauro Carvalho Chehab err("could not restart the USB controller CPU."); 1636786baecfSMauro Carvalho Chehab ret = -EINVAL; 1637786baecfSMauro Carvalho Chehab } 1638786baecfSMauro Carvalho Chehab if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, 1639786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG) != 1) { 1640786baecfSMauro Carvalho Chehab err("could not restart the USB controller CPU."); 1641786baecfSMauro Carvalho Chehab ret = -EINVAL; 1642786baecfSMauro Carvalho Chehab } 1643786baecfSMauro Carvalho Chehab /* init registers */ 1644*1ad5d064SHans Verkuil switch (le16_to_cpu(dev->descriptor.idProduct)) { 1645786baecfSMauro Carvalho Chehab case USB_PID_TEVII_S650: 1646a49de26aSEvgeny Plehov dw2104_properties.rc.core.rc_codes = RC_MAP_TEVII_NEC; 1647786baecfSMauro Carvalho Chehab case USB_PID_DW2104: 1648786baecfSMauro Carvalho Chehab reset = 1; 1649786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, 1650786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 1651786baecfSMauro Carvalho Chehab /* break omitted intentionally */ 1652786baecfSMauro Carvalho Chehab case USB_PID_DW3101: 1653786baecfSMauro Carvalho Chehab reset = 0; 1654786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 1655786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 1656786baecfSMauro Carvalho Chehab break; 1657786baecfSMauro Carvalho Chehab case USB_PID_CINERGY_S: 1658786baecfSMauro Carvalho Chehab case USB_PID_DW2102: 1659786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 1660786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 1661786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 1662786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1663786baecfSMauro Carvalho Chehab /* check STV0299 frontend */ 1664786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2, 1665786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1666786baecfSMauro Carvalho Chehab if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) { 1667786baecfSMauro Carvalho Chehab dw2102_properties.i2c_algo = &dw2102_i2c_algo; 1668786baecfSMauro Carvalho Chehab dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach; 1669786baecfSMauro Carvalho Chehab break; 1670786baecfSMauro Carvalho Chehab } else { 1671786baecfSMauro Carvalho Chehab /* check STV0288 frontend */ 1672786baecfSMauro Carvalho Chehab reset16[0] = 0xd0; 1673786baecfSMauro Carvalho Chehab reset16[1] = 1; 1674786baecfSMauro Carvalho Chehab reset16[2] = 0; 1675786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, 1676786baecfSMauro Carvalho Chehab DW210X_WRITE_MSG); 1677786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, 1678786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1679786baecfSMauro Carvalho Chehab if (reset16[2] == 0x11) { 1680786baecfSMauro Carvalho Chehab dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; 1681786baecfSMauro Carvalho Chehab break; 1682786baecfSMauro Carvalho Chehab } 1683786baecfSMauro Carvalho Chehab } 1684786baecfSMauro Carvalho Chehab case 0x2101: 1685786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, 1686786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1687786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 1688786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1689786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 1690786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1691786baecfSMauro Carvalho Chehab dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 1692786baecfSMauro Carvalho Chehab DW210X_READ_MSG); 1693786baecfSMauro Carvalho Chehab break; 1694786baecfSMauro Carvalho Chehab } 1695786baecfSMauro Carvalho Chehab 1696786baecfSMauro Carvalho Chehab msleep(100); 1697786baecfSMauro Carvalho Chehab kfree(p); 1698786baecfSMauro Carvalho Chehab } 1699786baecfSMauro Carvalho Chehab return ret; 1700786baecfSMauro Carvalho Chehab } 1701786baecfSMauro Carvalho Chehab 1702786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2102_properties = { 1703786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1704786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 17056823627bSRémi Cardona .firmware = DW2102_FIRMWARE, 1706786baecfSMauro Carvalho Chehab .no_reconnect = 1, 1707786baecfSMauro Carvalho Chehab 1708786baecfSMauro Carvalho Chehab .i2c_algo = &dw2102_serit_i2c_algo, 1709786baecfSMauro Carvalho Chehab 1710a49de26aSEvgeny Plehov .rc.core = { 1711786baecfSMauro Carvalho Chehab .rc_interval = 150, 1712a49de26aSEvgeny Plehov .rc_codes = RC_MAP_DM1105_NEC, 1713a49de26aSEvgeny Plehov .module_name = "dw2102", 1714a49de26aSEvgeny Plehov .allowed_protos = RC_BIT_NEC, 1715786baecfSMauro Carvalho Chehab .rc_query = dw2102_rc_query, 1716786baecfSMauro Carvalho Chehab }, 1717786baecfSMauro Carvalho Chehab 1718786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x81, 1719786baecfSMauro Carvalho Chehab /* parameter for the MPEG2-data transfer */ 1720786baecfSMauro Carvalho Chehab .num_adapters = 1, 1721786baecfSMauro Carvalho Chehab .download_firmware = dw2102_load_firmware, 1722786baecfSMauro Carvalho Chehab .read_mac_address = dw210x_read_mac_address, 1723786baecfSMauro Carvalho Chehab .adapter = { 1724786baecfSMauro Carvalho Chehab { 1725786baecfSMauro Carvalho Chehab .num_frontends = 1, 1726786baecfSMauro Carvalho Chehab .fe = {{ 1727786baecfSMauro Carvalho Chehab .frontend_attach = dw2102_frontend_attach, 1728786baecfSMauro Carvalho Chehab .stream = { 1729786baecfSMauro Carvalho Chehab .type = USB_BULK, 1730786baecfSMauro Carvalho Chehab .count = 8, 1731786baecfSMauro Carvalho Chehab .endpoint = 0x82, 1732786baecfSMauro Carvalho Chehab .u = { 1733786baecfSMauro Carvalho Chehab .bulk = { 1734786baecfSMauro Carvalho Chehab .buffersize = 4096, 1735786baecfSMauro Carvalho Chehab } 1736786baecfSMauro Carvalho Chehab } 1737786baecfSMauro Carvalho Chehab }, 1738786baecfSMauro Carvalho Chehab }}, 1739786baecfSMauro Carvalho Chehab } 1740786baecfSMauro Carvalho Chehab }, 1741786baecfSMauro Carvalho Chehab .num_device_descs = 3, 1742786baecfSMauro Carvalho Chehab .devices = { 1743786baecfSMauro Carvalho Chehab {"DVBWorld DVB-S 2102 USB2.0", 1744786baecfSMauro Carvalho Chehab {&dw2102_table[CYPRESS_DW2102], NULL}, 1745786baecfSMauro Carvalho Chehab {NULL}, 1746786baecfSMauro Carvalho Chehab }, 1747786baecfSMauro Carvalho Chehab {"DVBWorld DVB-S 2101 USB2.0", 1748786baecfSMauro Carvalho Chehab {&dw2102_table[CYPRESS_DW2101], NULL}, 1749786baecfSMauro Carvalho Chehab {NULL}, 1750786baecfSMauro Carvalho Chehab }, 1751786baecfSMauro Carvalho Chehab {"TerraTec Cinergy S USB", 1752786baecfSMauro Carvalho Chehab {&dw2102_table[TERRATEC_CINERGY_S], NULL}, 1753786baecfSMauro Carvalho Chehab {NULL}, 1754786baecfSMauro Carvalho Chehab }, 1755786baecfSMauro Carvalho Chehab } 1756786baecfSMauro Carvalho Chehab }; 1757786baecfSMauro Carvalho Chehab 1758786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw2104_properties = { 1759786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1760786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 17616823627bSRémi Cardona .firmware = DW2104_FIRMWARE, 1762786baecfSMauro Carvalho Chehab .no_reconnect = 1, 1763786baecfSMauro Carvalho Chehab 1764786baecfSMauro Carvalho Chehab .i2c_algo = &dw2104_i2c_algo, 1765a49de26aSEvgeny Plehov .rc.core = { 1766786baecfSMauro Carvalho Chehab .rc_interval = 150, 1767a49de26aSEvgeny Plehov .rc_codes = RC_MAP_DM1105_NEC, 1768a49de26aSEvgeny Plehov .module_name = "dw2102", 1769a49de26aSEvgeny Plehov .allowed_protos = RC_BIT_NEC, 1770786baecfSMauro Carvalho Chehab .rc_query = dw2102_rc_query, 1771786baecfSMauro Carvalho Chehab }, 1772786baecfSMauro Carvalho Chehab 1773786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x81, 1774786baecfSMauro Carvalho Chehab /* parameter for the MPEG2-data transfer */ 1775786baecfSMauro Carvalho Chehab .num_adapters = 1, 1776786baecfSMauro Carvalho Chehab .download_firmware = dw2102_load_firmware, 1777786baecfSMauro Carvalho Chehab .read_mac_address = dw210x_read_mac_address, 1778786baecfSMauro Carvalho Chehab .adapter = { 1779786baecfSMauro Carvalho Chehab { 1780786baecfSMauro Carvalho Chehab .num_frontends = 1, 1781786baecfSMauro Carvalho Chehab .fe = {{ 1782786baecfSMauro Carvalho Chehab .frontend_attach = dw2104_frontend_attach, 1783786baecfSMauro Carvalho Chehab .stream = { 1784786baecfSMauro Carvalho Chehab .type = USB_BULK, 1785786baecfSMauro Carvalho Chehab .count = 8, 1786786baecfSMauro Carvalho Chehab .endpoint = 0x82, 1787786baecfSMauro Carvalho Chehab .u = { 1788786baecfSMauro Carvalho Chehab .bulk = { 1789786baecfSMauro Carvalho Chehab .buffersize = 4096, 1790786baecfSMauro Carvalho Chehab } 1791786baecfSMauro Carvalho Chehab } 1792786baecfSMauro Carvalho Chehab }, 1793786baecfSMauro Carvalho Chehab }}, 1794786baecfSMauro Carvalho Chehab } 1795786baecfSMauro Carvalho Chehab }, 1796786baecfSMauro Carvalho Chehab .num_device_descs = 2, 1797786baecfSMauro Carvalho Chehab .devices = { 1798786baecfSMauro Carvalho Chehab { "DVBWorld DW2104 USB2.0", 1799786baecfSMauro Carvalho Chehab {&dw2102_table[CYPRESS_DW2104], NULL}, 1800786baecfSMauro Carvalho Chehab {NULL}, 1801786baecfSMauro Carvalho Chehab }, 1802786baecfSMauro Carvalho Chehab { "TeVii S650 USB2.0", 1803786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S650], NULL}, 1804786baecfSMauro Carvalho Chehab {NULL}, 1805786baecfSMauro Carvalho Chehab }, 1806786baecfSMauro Carvalho Chehab } 1807786baecfSMauro Carvalho Chehab }; 1808786baecfSMauro Carvalho Chehab 1809786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties dw3101_properties = { 1810786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1811786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 18126823627bSRémi Cardona .firmware = DW3101_FIRMWARE, 1813786baecfSMauro Carvalho Chehab .no_reconnect = 1, 1814786baecfSMauro Carvalho Chehab 1815786baecfSMauro Carvalho Chehab .i2c_algo = &dw3101_i2c_algo, 1816a49de26aSEvgeny Plehov .rc.core = { 1817786baecfSMauro Carvalho Chehab .rc_interval = 150, 1818a49de26aSEvgeny Plehov .rc_codes = RC_MAP_DM1105_NEC, 1819a49de26aSEvgeny Plehov .module_name = "dw2102", 1820a49de26aSEvgeny Plehov .allowed_protos = RC_BIT_NEC, 1821786baecfSMauro Carvalho Chehab .rc_query = dw2102_rc_query, 1822786baecfSMauro Carvalho Chehab }, 1823786baecfSMauro Carvalho Chehab 1824786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x81, 1825786baecfSMauro Carvalho Chehab /* parameter for the MPEG2-data transfer */ 1826786baecfSMauro Carvalho Chehab .num_adapters = 1, 1827786baecfSMauro Carvalho Chehab .download_firmware = dw2102_load_firmware, 1828786baecfSMauro Carvalho Chehab .read_mac_address = dw210x_read_mac_address, 1829786baecfSMauro Carvalho Chehab .adapter = { 1830786baecfSMauro Carvalho Chehab { 1831786baecfSMauro Carvalho Chehab .num_frontends = 1, 1832786baecfSMauro Carvalho Chehab .fe = {{ 1833786baecfSMauro Carvalho Chehab .frontend_attach = dw3101_frontend_attach, 1834786baecfSMauro Carvalho Chehab .tuner_attach = dw3101_tuner_attach, 1835786baecfSMauro Carvalho Chehab .stream = { 1836786baecfSMauro Carvalho Chehab .type = USB_BULK, 1837786baecfSMauro Carvalho Chehab .count = 8, 1838786baecfSMauro Carvalho Chehab .endpoint = 0x82, 1839786baecfSMauro Carvalho Chehab .u = { 1840786baecfSMauro Carvalho Chehab .bulk = { 1841786baecfSMauro Carvalho Chehab .buffersize = 4096, 1842786baecfSMauro Carvalho Chehab } 1843786baecfSMauro Carvalho Chehab } 1844786baecfSMauro Carvalho Chehab }, 1845786baecfSMauro Carvalho Chehab }}, 1846786baecfSMauro Carvalho Chehab } 1847786baecfSMauro Carvalho Chehab }, 1848786baecfSMauro Carvalho Chehab .num_device_descs = 1, 1849786baecfSMauro Carvalho Chehab .devices = { 1850786baecfSMauro Carvalho Chehab { "DVBWorld DVB-C 3101 USB2.0", 1851786baecfSMauro Carvalho Chehab {&dw2102_table[CYPRESS_DW3101], NULL}, 1852786baecfSMauro Carvalho Chehab {NULL}, 1853786baecfSMauro Carvalho Chehab }, 1854786baecfSMauro Carvalho Chehab } 1855786baecfSMauro Carvalho Chehab }; 1856786baecfSMauro Carvalho Chehab 1857786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties s6x0_properties = { 1858786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1859786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 1860786baecfSMauro Carvalho Chehab .size_of_priv = sizeof(struct s6x0_state), 18616823627bSRémi Cardona .firmware = S630_FIRMWARE, 1862786baecfSMauro Carvalho Chehab .no_reconnect = 1, 1863786baecfSMauro Carvalho Chehab 1864786baecfSMauro Carvalho Chehab .i2c_algo = &s6x0_i2c_algo, 1865a49de26aSEvgeny Plehov .rc.core = { 1866786baecfSMauro Carvalho Chehab .rc_interval = 150, 1867a49de26aSEvgeny Plehov .rc_codes = RC_MAP_TEVII_NEC, 1868a49de26aSEvgeny Plehov .module_name = "dw2102", 1869a49de26aSEvgeny Plehov .allowed_protos = RC_BIT_NEC, 1870786baecfSMauro Carvalho Chehab .rc_query = dw2102_rc_query, 1871786baecfSMauro Carvalho Chehab }, 1872786baecfSMauro Carvalho Chehab 1873786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x81, 1874786baecfSMauro Carvalho Chehab .num_adapters = 1, 1875786baecfSMauro Carvalho Chehab .download_firmware = dw2102_load_firmware, 1876786baecfSMauro Carvalho Chehab .read_mac_address = s6x0_read_mac_address, 1877786baecfSMauro Carvalho Chehab .adapter = { 1878786baecfSMauro Carvalho Chehab { 1879786baecfSMauro Carvalho Chehab .num_frontends = 1, 1880786baecfSMauro Carvalho Chehab .fe = {{ 1881786baecfSMauro Carvalho Chehab .frontend_attach = zl100313_frontend_attach, 1882786baecfSMauro Carvalho Chehab .stream = { 1883786baecfSMauro Carvalho Chehab .type = USB_BULK, 1884786baecfSMauro Carvalho Chehab .count = 8, 1885786baecfSMauro Carvalho Chehab .endpoint = 0x82, 1886786baecfSMauro Carvalho Chehab .u = { 1887786baecfSMauro Carvalho Chehab .bulk = { 1888786baecfSMauro Carvalho Chehab .buffersize = 4096, 1889786baecfSMauro Carvalho Chehab } 1890786baecfSMauro Carvalho Chehab } 1891786baecfSMauro Carvalho Chehab }, 1892786baecfSMauro Carvalho Chehab }}, 1893786baecfSMauro Carvalho Chehab } 1894786baecfSMauro Carvalho Chehab }, 1895786baecfSMauro Carvalho Chehab .num_device_descs = 1, 1896786baecfSMauro Carvalho Chehab .devices = { 1897786baecfSMauro Carvalho Chehab {"TeVii S630 USB", 1898786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S630], NULL}, 1899786baecfSMauro Carvalho Chehab {NULL}, 1900786baecfSMauro Carvalho Chehab }, 1901786baecfSMauro Carvalho Chehab } 1902786baecfSMauro Carvalho Chehab }; 1903786baecfSMauro Carvalho Chehab 1904*1ad5d064SHans Verkuil static struct dvb_usb_device_properties *p1100; 1905786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d1100 = { 1906786baecfSMauro Carvalho Chehab "Prof 1100 USB ", 1907786baecfSMauro Carvalho Chehab {&dw2102_table[PROF_1100], NULL}, 1908786baecfSMauro Carvalho Chehab {NULL}, 1909786baecfSMauro Carvalho Chehab }; 1910786baecfSMauro Carvalho Chehab 1911*1ad5d064SHans Verkuil static struct dvb_usb_device_properties *s660; 1912786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d660 = { 1913786baecfSMauro Carvalho Chehab "TeVii S660 USB", 1914786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S660], NULL}, 1915786baecfSMauro Carvalho Chehab {NULL}, 1916786baecfSMauro Carvalho Chehab }; 1917786baecfSMauro Carvalho Chehab 1918786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d480_1 = { 1919786baecfSMauro Carvalho Chehab "TeVii S480.1 USB", 1920786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S480_1], NULL}, 1921786baecfSMauro Carvalho Chehab {NULL}, 1922786baecfSMauro Carvalho Chehab }; 1923786baecfSMauro Carvalho Chehab 1924786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d480_2 = { 1925786baecfSMauro Carvalho Chehab "TeVii S480.2 USB", 1926786baecfSMauro Carvalho Chehab {&dw2102_table[TEVII_S480_2], NULL}, 1927786baecfSMauro Carvalho Chehab {NULL}, 1928786baecfSMauro Carvalho Chehab }; 1929786baecfSMauro Carvalho Chehab 1930*1ad5d064SHans Verkuil static struct dvb_usb_device_properties *p7500; 1931786baecfSMauro Carvalho Chehab static struct dvb_usb_device_description d7500 = { 1932786baecfSMauro Carvalho Chehab "Prof 7500 USB DVB-S2", 1933786baecfSMauro Carvalho Chehab {&dw2102_table[PROF_7500], NULL}, 1934786baecfSMauro Carvalho Chehab {NULL}, 1935786baecfSMauro Carvalho Chehab }; 1936786baecfSMauro Carvalho Chehab 1937*1ad5d064SHans Verkuil static struct dvb_usb_device_properties *s421; 1938955d00acSIgor M. Liplianin static struct dvb_usb_device_description d421 = { 1939955d00acSIgor M. Liplianin "TeVii S421 PCI", 1940955d00acSIgor M. Liplianin {&dw2102_table[TEVII_S421], NULL}, 1941955d00acSIgor M. Liplianin {NULL}, 1942955d00acSIgor M. Liplianin }; 1943955d00acSIgor M. Liplianin 1944955d00acSIgor M. Liplianin static struct dvb_usb_device_description d632 = { 1945955d00acSIgor M. Liplianin "TeVii S632 USB", 1946955d00acSIgor M. Liplianin {&dw2102_table[TEVII_S632], NULL}, 1947955d00acSIgor M. Liplianin {NULL}, 1948955d00acSIgor M. Liplianin }; 1949955d00acSIgor M. Liplianin 1950786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties su3000_properties = { 1951786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1952786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 1953786baecfSMauro Carvalho Chehab .size_of_priv = sizeof(struct su3000_state), 1954786baecfSMauro Carvalho Chehab .power_ctrl = su3000_power_ctrl, 1955786baecfSMauro Carvalho Chehab .num_adapters = 1, 1956786baecfSMauro Carvalho Chehab .identify_state = su3000_identify_state, 1957786baecfSMauro Carvalho Chehab .i2c_algo = &su3000_i2c_algo, 1958786baecfSMauro Carvalho Chehab 1959a49de26aSEvgeny Plehov .rc.core = { 1960786baecfSMauro Carvalho Chehab .rc_interval = 150, 1961a49de26aSEvgeny Plehov .rc_codes = RC_MAP_SU3000, 1962a49de26aSEvgeny Plehov .module_name = "dw2102", 1963a49de26aSEvgeny Plehov .allowed_protos = RC_BIT_RC5, 1964a49de26aSEvgeny Plehov .rc_query = su3000_rc_query, 1965786baecfSMauro Carvalho Chehab }, 1966786baecfSMauro Carvalho Chehab 1967786baecfSMauro Carvalho Chehab .read_mac_address = su3000_read_mac_address, 1968786baecfSMauro Carvalho Chehab 1969786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 0x01, 1970786baecfSMauro Carvalho Chehab 1971786baecfSMauro Carvalho Chehab .adapter = { 1972786baecfSMauro Carvalho Chehab { 1973786baecfSMauro Carvalho Chehab .num_frontends = 1, 1974786baecfSMauro Carvalho Chehab .fe = {{ 1975786baecfSMauro Carvalho Chehab .streaming_ctrl = su3000_streaming_ctrl, 1976786baecfSMauro Carvalho Chehab .frontend_attach = su3000_frontend_attach, 1977786baecfSMauro Carvalho Chehab .stream = { 1978786baecfSMauro Carvalho Chehab .type = USB_BULK, 1979786baecfSMauro Carvalho Chehab .count = 8, 1980786baecfSMauro Carvalho Chehab .endpoint = 0x82, 1981786baecfSMauro Carvalho Chehab .u = { 1982786baecfSMauro Carvalho Chehab .bulk = { 1983786baecfSMauro Carvalho Chehab .buffersize = 4096, 1984786baecfSMauro Carvalho Chehab } 1985786baecfSMauro Carvalho Chehab } 1986786baecfSMauro Carvalho Chehab } 1987786baecfSMauro Carvalho Chehab }}, 1988786baecfSMauro Carvalho Chehab } 1989786baecfSMauro Carvalho Chehab }, 1990f08e9f0dSAndrey Pavlenko .num_device_descs = 5, 1991786baecfSMauro Carvalho Chehab .devices = { 1992786baecfSMauro Carvalho Chehab { "SU3000HD DVB-S USB2.0", 1993786baecfSMauro Carvalho Chehab { &dw2102_table[GENIATECH_SU3000], NULL }, 1994786baecfSMauro Carvalho Chehab { NULL }, 1995786baecfSMauro Carvalho Chehab }, 1996786baecfSMauro Carvalho Chehab { "Terratec Cinergy S2 USB HD", 1997786baecfSMauro Carvalho Chehab { &dw2102_table[TERRATEC_CINERGY_S2], NULL }, 1998786baecfSMauro Carvalho Chehab { NULL }, 1999786baecfSMauro Carvalho Chehab }, 2000786baecfSMauro Carvalho Chehab { "X3M TV SPC1400HD PCI", 2001786baecfSMauro Carvalho Chehab { &dw2102_table[X3M_SPC1400HD], NULL }, 2002786baecfSMauro Carvalho Chehab { NULL }, 2003786baecfSMauro Carvalho Chehab }, 200444122dd6SIgor M. Liplianin { "Terratec Cinergy S2 USB HD Rev.2", 200544122dd6SIgor M. Liplianin { &dw2102_table[TERRATEC_CINERGY_S2_R2], NULL }, 200644122dd6SIgor M. Liplianin { NULL }, 200744122dd6SIgor M. Liplianin }, 2008f08e9f0dSAndrey Pavlenko { "GOTVIEW Satellite HD", 2009f08e9f0dSAndrey Pavlenko { &dw2102_table[GOTVIEW_SAT_HD], NULL }, 2010f08e9f0dSAndrey Pavlenko { NULL }, 2011f08e9f0dSAndrey Pavlenko }, 2012786baecfSMauro Carvalho Chehab } 2013786baecfSMauro Carvalho Chehab }; 2014786baecfSMauro Carvalho Chehab 201551d882edSEvgeny Plehov static struct dvb_usb_device_properties t220_properties = { 201651d882edSEvgeny Plehov .caps = DVB_USB_IS_AN_I2C_ADAPTER, 201751d882edSEvgeny Plehov .usb_ctrl = DEVICE_SPECIFIC, 201851d882edSEvgeny Plehov .size_of_priv = sizeof(struct su3000_state), 201951d882edSEvgeny Plehov .power_ctrl = su3000_power_ctrl, 202051d882edSEvgeny Plehov .num_adapters = 1, 202151d882edSEvgeny Plehov .identify_state = su3000_identify_state, 202251d882edSEvgeny Plehov .i2c_algo = &su3000_i2c_algo, 202351d882edSEvgeny Plehov 2024a49de26aSEvgeny Plehov .rc.core = { 202551d882edSEvgeny Plehov .rc_interval = 150, 2026a49de26aSEvgeny Plehov .rc_codes = RC_MAP_SU3000, 2027a49de26aSEvgeny Plehov .module_name = "dw2102", 2028a49de26aSEvgeny Plehov .allowed_protos = RC_BIT_RC5, 2029a49de26aSEvgeny Plehov .rc_query = su3000_rc_query, 203051d882edSEvgeny Plehov }, 203151d882edSEvgeny Plehov 203251d882edSEvgeny Plehov .read_mac_address = su3000_read_mac_address, 203351d882edSEvgeny Plehov 203451d882edSEvgeny Plehov .generic_bulk_ctrl_endpoint = 0x01, 203551d882edSEvgeny Plehov 203651d882edSEvgeny Plehov .adapter = { 203751d882edSEvgeny Plehov { 203851d882edSEvgeny Plehov .num_frontends = 1, 203951d882edSEvgeny Plehov .fe = { { 204051d882edSEvgeny Plehov .streaming_ctrl = su3000_streaming_ctrl, 204151d882edSEvgeny Plehov .frontend_attach = t220_frontend_attach, 204251d882edSEvgeny Plehov .stream = { 204351d882edSEvgeny Plehov .type = USB_BULK, 204451d882edSEvgeny Plehov .count = 8, 204551d882edSEvgeny Plehov .endpoint = 0x82, 204651d882edSEvgeny Plehov .u = { 204751d882edSEvgeny Plehov .bulk = { 204851d882edSEvgeny Plehov .buffersize = 4096, 204951d882edSEvgeny Plehov } 205051d882edSEvgeny Plehov } 205151d882edSEvgeny Plehov } 205251d882edSEvgeny Plehov } }, 205351d882edSEvgeny Plehov } 205451d882edSEvgeny Plehov }, 205551d882edSEvgeny Plehov .num_device_descs = 1, 205651d882edSEvgeny Plehov .devices = { 205751d882edSEvgeny Plehov { "Geniatech T220 DVB-T/T2 USB2.0", 205851d882edSEvgeny Plehov { &dw2102_table[GENIATECH_T220], NULL }, 205951d882edSEvgeny Plehov { NULL }, 206051d882edSEvgeny Plehov }, 206151d882edSEvgeny Plehov } 206251d882edSEvgeny Plehov }; 206351d882edSEvgeny Plehov 2064786baecfSMauro Carvalho Chehab static int dw2102_probe(struct usb_interface *intf, 2065786baecfSMauro Carvalho Chehab const struct usb_device_id *id) 2066786baecfSMauro Carvalho Chehab { 2067786baecfSMauro Carvalho Chehab p1100 = kmemdup(&s6x0_properties, 2068786baecfSMauro Carvalho Chehab sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 2069786baecfSMauro Carvalho Chehab if (!p1100) 2070786baecfSMauro Carvalho Chehab return -ENOMEM; 2071786baecfSMauro Carvalho Chehab /* copy default structure */ 2072786baecfSMauro Carvalho Chehab /* fill only different fields */ 20736823627bSRémi Cardona p1100->firmware = P1100_FIRMWARE; 2074786baecfSMauro Carvalho Chehab p1100->devices[0] = d1100; 2075a49de26aSEvgeny Plehov p1100->rc.core.rc_query = prof_rc_query; 2076a49de26aSEvgeny Plehov p1100->rc.core.rc_codes = RC_MAP_TBS_NEC; 2077786baecfSMauro Carvalho Chehab p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach; 2078786baecfSMauro Carvalho Chehab 2079786baecfSMauro Carvalho Chehab s660 = kmemdup(&s6x0_properties, 2080786baecfSMauro Carvalho Chehab sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 2081786baecfSMauro Carvalho Chehab if (!s660) { 2082786baecfSMauro Carvalho Chehab kfree(p1100); 2083786baecfSMauro Carvalho Chehab return -ENOMEM; 2084786baecfSMauro Carvalho Chehab } 20856823627bSRémi Cardona s660->firmware = S660_FIRMWARE; 2086786baecfSMauro Carvalho Chehab s660->num_device_descs = 3; 2087786baecfSMauro Carvalho Chehab s660->devices[0] = d660; 2088786baecfSMauro Carvalho Chehab s660->devices[1] = d480_1; 2089786baecfSMauro Carvalho Chehab s660->devices[2] = d480_2; 2090786baecfSMauro Carvalho Chehab s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach; 2091786baecfSMauro Carvalho Chehab 2092786baecfSMauro Carvalho Chehab p7500 = kmemdup(&s6x0_properties, 2093786baecfSMauro Carvalho Chehab sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 2094786baecfSMauro Carvalho Chehab if (!p7500) { 2095786baecfSMauro Carvalho Chehab kfree(p1100); 2096786baecfSMauro Carvalho Chehab kfree(s660); 2097786baecfSMauro Carvalho Chehab return -ENOMEM; 2098786baecfSMauro Carvalho Chehab } 20996823627bSRémi Cardona p7500->firmware = P7500_FIRMWARE; 2100786baecfSMauro Carvalho Chehab p7500->devices[0] = d7500; 2101a49de26aSEvgeny Plehov p7500->rc.core.rc_query = prof_rc_query; 2102a49de26aSEvgeny Plehov p7500->rc.core.rc_codes = RC_MAP_TBS_NEC; 2103786baecfSMauro Carvalho Chehab p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach; 2104786baecfSMauro Carvalho Chehab 2105955d00acSIgor M. Liplianin 2106955d00acSIgor M. Liplianin s421 = kmemdup(&su3000_properties, 2107955d00acSIgor M. Liplianin sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 2108955d00acSIgor M. Liplianin if (!s421) { 2109955d00acSIgor M. Liplianin kfree(p1100); 2110955d00acSIgor M. Liplianin kfree(s660); 2111955d00acSIgor M. Liplianin kfree(p7500); 2112955d00acSIgor M. Liplianin return -ENOMEM; 2113955d00acSIgor M. Liplianin } 2114955d00acSIgor M. Liplianin s421->num_device_descs = 2; 2115955d00acSIgor M. Liplianin s421->devices[0] = d421; 2116955d00acSIgor M. Liplianin s421->devices[1] = d632; 2117955d00acSIgor M. Liplianin s421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach; 2118955d00acSIgor M. Liplianin 2119786baecfSMauro Carvalho Chehab if (0 == dvb_usb_device_init(intf, &dw2102_properties, 2120786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr) || 2121786baecfSMauro Carvalho Chehab 0 == dvb_usb_device_init(intf, &dw2104_properties, 2122786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr) || 2123786baecfSMauro Carvalho Chehab 0 == dvb_usb_device_init(intf, &dw3101_properties, 2124786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr) || 2125786baecfSMauro Carvalho Chehab 0 == dvb_usb_device_init(intf, &s6x0_properties, 2126786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr) || 2127786baecfSMauro Carvalho Chehab 0 == dvb_usb_device_init(intf, p1100, 2128786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr) || 2129786baecfSMauro Carvalho Chehab 0 == dvb_usb_device_init(intf, s660, 2130786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr) || 2131786baecfSMauro Carvalho Chehab 0 == dvb_usb_device_init(intf, p7500, 2132786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr) || 2133955d00acSIgor M. Liplianin 0 == dvb_usb_device_init(intf, s421, 2134955d00acSIgor M. Liplianin THIS_MODULE, NULL, adapter_nr) || 2135786baecfSMauro Carvalho Chehab 0 == dvb_usb_device_init(intf, &su3000_properties, 213651d882edSEvgeny Plehov THIS_MODULE, NULL, adapter_nr) || 213751d882edSEvgeny Plehov 0 == dvb_usb_device_init(intf, &t220_properties, 2138786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr)) 2139786baecfSMauro Carvalho Chehab return 0; 2140786baecfSMauro Carvalho Chehab 2141786baecfSMauro Carvalho Chehab return -ENODEV; 2142786baecfSMauro Carvalho Chehab } 2143786baecfSMauro Carvalho Chehab 2144786baecfSMauro Carvalho Chehab static struct usb_driver dw2102_driver = { 2145786baecfSMauro Carvalho Chehab .name = "dw2102", 2146786baecfSMauro Carvalho Chehab .probe = dw2102_probe, 2147786baecfSMauro Carvalho Chehab .disconnect = dvb_usb_device_exit, 2148786baecfSMauro Carvalho Chehab .id_table = dw2102_table, 2149786baecfSMauro Carvalho Chehab }; 2150786baecfSMauro Carvalho Chehab 2151786baecfSMauro Carvalho Chehab module_usb_driver(dw2102_driver); 2152786baecfSMauro Carvalho Chehab 2153786baecfSMauro Carvalho Chehab MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); 2154786baecfSMauro Carvalho Chehab MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," 2155786baecfSMauro Carvalho Chehab " DVB-C 3101 USB2.0," 2156955d00acSIgor M. Liplianin " TeVii S600, S630, S650, S660, S480, S421, S632" 2157786baecfSMauro Carvalho Chehab " Prof 1100, 7500 USB2.0," 215851d882edSEvgeny Plehov " Geniatech SU3000, T220 devices"); 2159786baecfSMauro Carvalho Chehab MODULE_VERSION("0.1"); 2160786baecfSMauro Carvalho Chehab MODULE_LICENSE("GPL"); 21616823627bSRémi Cardona MODULE_FIRMWARE(DW2101_FIRMWARE); 21626823627bSRémi Cardona MODULE_FIRMWARE(DW2102_FIRMWARE); 21636823627bSRémi Cardona MODULE_FIRMWARE(DW2104_FIRMWARE); 21646823627bSRémi Cardona MODULE_FIRMWARE(DW3101_FIRMWARE); 21656823627bSRémi Cardona MODULE_FIRMWARE(S630_FIRMWARE); 21666823627bSRémi Cardona MODULE_FIRMWARE(S660_FIRMWARE); 21676823627bSRémi Cardona MODULE_FIRMWARE(P1100_FIRMWARE); 21686823627bSRémi Cardona MODULE_FIRMWARE(P7500_FIRMWARE); 2169