12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 2786baecfSMauro Carvalho Chehab /* 3786baecfSMauro Carvalho Chehab * PCTV 452e DVB driver 4786baecfSMauro Carvalho Chehab * 5786baecfSMauro Carvalho Chehab * Copyright (c) 2006-2008 Dominik Kuhlen <dkuhlen@gmx.net> 6786baecfSMauro Carvalho Chehab * 7786baecfSMauro Carvalho Chehab * TT connect S2-3650-CI Common Interface support, MAC readout 8786baecfSMauro Carvalho Chehab * Copyright (C) 2008 Michael H. Schimek <mschimek@gmx.at> 9786baecfSMauro Carvalho Chehab */ 10786baecfSMauro Carvalho Chehab 11786baecfSMauro Carvalho Chehab /* dvb usb framework */ 12786baecfSMauro Carvalho Chehab #define DVB_USB_LOG_PREFIX "pctv452e" 13786baecfSMauro Carvalho Chehab #include "dvb-usb.h" 14786baecfSMauro Carvalho Chehab 15786baecfSMauro Carvalho Chehab /* Demodulator */ 16786baecfSMauro Carvalho Chehab #include "stb0899_drv.h" 17786baecfSMauro Carvalho Chehab #include "stb0899_reg.h" 18786baecfSMauro Carvalho Chehab #include "stb0899_cfg.h" 19786baecfSMauro Carvalho Chehab /* Tuner */ 20786baecfSMauro Carvalho Chehab #include "stb6100.h" 21786baecfSMauro Carvalho Chehab #include "stb6100_cfg.h" 22786baecfSMauro Carvalho Chehab /* FE Power */ 23f35e5231SAlex Bee #include "isl6423.h" 24786baecfSMauro Carvalho Chehab #include "lnbp22.h" 25786baecfSMauro Carvalho Chehab 26fada1935SMauro Carvalho Chehab #include <media/dvb_ca_en50221.h> 27786baecfSMauro Carvalho Chehab #include "ttpci-eeprom.h" 28786baecfSMauro Carvalho Chehab 29786baecfSMauro Carvalho Chehab static int debug; 30786baecfSMauro Carvalho Chehab module_param(debug, int, 0644); 31786baecfSMauro Carvalho Chehab MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); 32786baecfSMauro Carvalho Chehab 33786baecfSMauro Carvalho Chehab DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 34786baecfSMauro Carvalho Chehab 35786baecfSMauro Carvalho Chehab #define ISOC_INTERFACE_ALTERNATIVE 3 36786baecfSMauro Carvalho Chehab 37786baecfSMauro Carvalho Chehab #define SYNC_BYTE_OUT 0xaa 38786baecfSMauro Carvalho Chehab #define SYNC_BYTE_IN 0x55 39786baecfSMauro Carvalho Chehab 40786baecfSMauro Carvalho Chehab /* guessed: (copied from ttusb-budget) */ 41786baecfSMauro Carvalho Chehab #define PCTV_CMD_RESET 0x15 42786baecfSMauro Carvalho Chehab /* command to poll IR receiver */ 43786baecfSMauro Carvalho Chehab #define PCTV_CMD_IR 0x1b 44786baecfSMauro Carvalho Chehab /* command to send I2C */ 45786baecfSMauro Carvalho Chehab #define PCTV_CMD_I2C 0x31 46786baecfSMauro Carvalho Chehab 47786baecfSMauro Carvalho Chehab #define I2C_ADDR_STB0899 (0xd0 >> 1) 48786baecfSMauro Carvalho Chehab #define I2C_ADDR_STB6100 (0xc0 >> 1) 49786baecfSMauro Carvalho Chehab #define I2C_ADDR_LNBP22 (0x10 >> 1) 50786baecfSMauro Carvalho Chehab #define I2C_ADDR_24C16 (0xa0 >> 1) 51786baecfSMauro Carvalho Chehab #define I2C_ADDR_24C64 (0xa2 >> 1) 52786baecfSMauro Carvalho Chehab 53786baecfSMauro Carvalho Chehab 54786baecfSMauro Carvalho Chehab /* pctv452e sends us this amount of data for each issued usb-command */ 55786baecfSMauro Carvalho Chehab #define PCTV_ANSWER_LEN 64 56786baecfSMauro Carvalho Chehab /* Wait up to 1000ms for device */ 57786baecfSMauro Carvalho Chehab #define PCTV_TIMEOUT 1000 58786baecfSMauro Carvalho Chehab 59786baecfSMauro Carvalho Chehab 60786baecfSMauro Carvalho Chehab #define PCTV_LED_GPIO STB0899_GPIO01 61786baecfSMauro Carvalho Chehab #define PCTV_LED_GREEN 0x82 62786baecfSMauro Carvalho Chehab #define PCTV_LED_ORANGE 0x02 63786baecfSMauro Carvalho Chehab 64786baecfSMauro Carvalho Chehab #define ci_dbg(format, arg...) \ 65786baecfSMauro Carvalho Chehab do { \ 66786baecfSMauro Carvalho Chehab if (0) \ 67786baecfSMauro Carvalho Chehab printk(KERN_DEBUG DVB_USB_LOG_PREFIX \ 68786baecfSMauro Carvalho Chehab ": " format "\n" , ## arg); \ 69786baecfSMauro Carvalho Chehab } while (0) 70786baecfSMauro Carvalho Chehab 71786baecfSMauro Carvalho Chehab enum { 72786baecfSMauro Carvalho Chehab TT3650_CMD_CI_TEST = 0x40, 73786baecfSMauro Carvalho Chehab TT3650_CMD_CI_RD_CTRL, 74786baecfSMauro Carvalho Chehab TT3650_CMD_CI_WR_CTRL, 75786baecfSMauro Carvalho Chehab TT3650_CMD_CI_RD_ATTR, 76786baecfSMauro Carvalho Chehab TT3650_CMD_CI_WR_ATTR, 77786baecfSMauro Carvalho Chehab TT3650_CMD_CI_RESET, 78786baecfSMauro Carvalho Chehab TT3650_CMD_CI_SET_VIDEO_PORT 79786baecfSMauro Carvalho Chehab }; 80786baecfSMauro Carvalho Chehab 81786baecfSMauro Carvalho Chehab 82786baecfSMauro Carvalho Chehab static struct stb0899_postproc pctv45e_postproc[] = { 83786baecfSMauro Carvalho Chehab { PCTV_LED_GPIO, STB0899_GPIOPULLUP }, 84786baecfSMauro Carvalho Chehab { 0, 0 } 85786baecfSMauro Carvalho Chehab }; 86786baecfSMauro Carvalho Chehab 87f35e5231SAlex Bee static struct isl6423_config pctv452e_isl6423_config = { 88f35e5231SAlex Bee .current_max = SEC_CURRENT_515m, 89f35e5231SAlex Bee .curlim = SEC_CURRENT_LIM_ON, 90f35e5231SAlex Bee .mod_extern = 1, 91f35e5231SAlex Bee .addr = 0x08, 92f35e5231SAlex Bee }; 93f35e5231SAlex Bee 94786baecfSMauro Carvalho Chehab /* 95786baecfSMauro Carvalho Chehab * stores all private variables for communication with the PCTV452e DVB-S2 96786baecfSMauro Carvalho Chehab */ 97786baecfSMauro Carvalho Chehab struct pctv452e_state { 98786baecfSMauro Carvalho Chehab struct dvb_ca_en50221 ca; 99786baecfSMauro Carvalho Chehab struct mutex ca_mutex; 100786baecfSMauro Carvalho Chehab 101786baecfSMauro Carvalho Chehab u8 c; /* transaction counter, wraps around... */ 102786baecfSMauro Carvalho Chehab u8 initialized; /* set to 1 if 0x15 has been sent */ 103786baecfSMauro Carvalho Chehab u16 last_rc_key; 104786baecfSMauro Carvalho Chehab }; 105786baecfSMauro Carvalho Chehab 106786baecfSMauro Carvalho Chehab static int tt3650_ci_msg(struct dvb_usb_device *d, u8 cmd, u8 *data, 107786baecfSMauro Carvalho Chehab unsigned int write_len, unsigned int read_len) 108786baecfSMauro Carvalho Chehab { 109786baecfSMauro Carvalho Chehab struct pctv452e_state *state = (struct pctv452e_state *)d->priv; 11048775cb7SMax Kellermann u8 *buf; 111786baecfSMauro Carvalho Chehab u8 id; 112786baecfSMauro Carvalho Chehab unsigned int rlen; 113786baecfSMauro Carvalho Chehab int ret; 114786baecfSMauro Carvalho Chehab 1155dfd2c8fSMauro Carvalho Chehab if (!data || (write_len > 64 - 4) || (read_len > 64 - 4)) { 1165dfd2c8fSMauro Carvalho Chehab err("%s: transfer data invalid", __func__); 1175dfd2c8fSMauro Carvalho Chehab return -EIO; 11859dde8e7Skbuild test robot } 119786baecfSMauro Carvalho Chehab 12048775cb7SMax Kellermann buf = kmalloc(64, GFP_KERNEL); 12148775cb7SMax Kellermann if (!buf) 12248775cb7SMax Kellermann return -ENOMEM; 12348775cb7SMax Kellermann 124786baecfSMauro Carvalho Chehab id = state->c++; 125786baecfSMauro Carvalho Chehab 12648775cb7SMax Kellermann buf[0] = SYNC_BYTE_OUT; 12748775cb7SMax Kellermann buf[1] = id; 12848775cb7SMax Kellermann buf[2] = cmd; 12948775cb7SMax Kellermann buf[3] = write_len; 130786baecfSMauro Carvalho Chehab 13148775cb7SMax Kellermann memcpy(buf + 4, data, write_len); 132786baecfSMauro Carvalho Chehab 133786baecfSMauro Carvalho Chehab rlen = (read_len > 0) ? 64 : 0; 13448775cb7SMax Kellermann ret = dvb_usb_generic_rw(d, buf, 4 + write_len, 13548775cb7SMax Kellermann buf, rlen, /* delay_ms */ 0); 136786baecfSMauro Carvalho Chehab if (0 != ret) 137786baecfSMauro Carvalho Chehab goto failed; 138786baecfSMauro Carvalho Chehab 139786baecfSMauro Carvalho Chehab ret = -EIO; 14048775cb7SMax Kellermann if (SYNC_BYTE_IN != buf[0] || id != buf[1]) 141786baecfSMauro Carvalho Chehab goto failed; 142786baecfSMauro Carvalho Chehab 14348775cb7SMax Kellermann memcpy(data, buf + 4, read_len); 144786baecfSMauro Carvalho Chehab 14548775cb7SMax Kellermann kfree(buf); 146786baecfSMauro Carvalho Chehab return 0; 147786baecfSMauro Carvalho Chehab 148786baecfSMauro Carvalho Chehab failed: 149786baecfSMauro Carvalho Chehab err("CI error %d; %02X %02X %02X -> %*ph.", 15048775cb7SMax Kellermann ret, SYNC_BYTE_OUT, id, cmd, 3, buf); 151786baecfSMauro Carvalho Chehab 15248775cb7SMax Kellermann kfree(buf); 153786baecfSMauro Carvalho Chehab return ret; 154786baecfSMauro Carvalho Chehab } 155786baecfSMauro Carvalho Chehab 156786baecfSMauro Carvalho Chehab static int tt3650_ci_msg_locked(struct dvb_ca_en50221 *ca, 157786baecfSMauro Carvalho Chehab u8 cmd, u8 *data, unsigned int write_len, 158786baecfSMauro Carvalho Chehab unsigned int read_len) 159786baecfSMauro Carvalho Chehab { 160786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; 161786baecfSMauro Carvalho Chehab struct pctv452e_state *state = (struct pctv452e_state *)d->priv; 162786baecfSMauro Carvalho Chehab int ret; 163786baecfSMauro Carvalho Chehab 164786baecfSMauro Carvalho Chehab mutex_lock(&state->ca_mutex); 165786baecfSMauro Carvalho Chehab ret = tt3650_ci_msg(d, cmd, data, write_len, read_len); 166786baecfSMauro Carvalho Chehab mutex_unlock(&state->ca_mutex); 167786baecfSMauro Carvalho Chehab 168786baecfSMauro Carvalho Chehab return ret; 169786baecfSMauro Carvalho Chehab } 170786baecfSMauro Carvalho Chehab 171786baecfSMauro Carvalho Chehab static int tt3650_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, 172786baecfSMauro Carvalho Chehab int slot, int address) 173786baecfSMauro Carvalho Chehab { 174786baecfSMauro Carvalho Chehab u8 buf[3]; 175786baecfSMauro Carvalho Chehab int ret; 176786baecfSMauro Carvalho Chehab 177786baecfSMauro Carvalho Chehab if (0 != slot) 178786baecfSMauro Carvalho Chehab return -EINVAL; 179786baecfSMauro Carvalho Chehab 180786baecfSMauro Carvalho Chehab buf[0] = (address >> 8) & 0x0F; 181786baecfSMauro Carvalho Chehab buf[1] = address; 182786baecfSMauro Carvalho Chehab 183786baecfSMauro Carvalho Chehab ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_RD_ATTR, buf, 2, 3); 184786baecfSMauro Carvalho Chehab 185786baecfSMauro Carvalho Chehab ci_dbg("%s %04x -> %d 0x%02x", 186786baecfSMauro Carvalho Chehab __func__, address, ret, buf[2]); 187786baecfSMauro Carvalho Chehab 188786baecfSMauro Carvalho Chehab if (ret < 0) 189786baecfSMauro Carvalho Chehab return ret; 190786baecfSMauro Carvalho Chehab 191786baecfSMauro Carvalho Chehab return buf[2]; 192786baecfSMauro Carvalho Chehab } 193786baecfSMauro Carvalho Chehab 194786baecfSMauro Carvalho Chehab static int tt3650_ci_write_attribute_mem(struct dvb_ca_en50221 *ca, 195786baecfSMauro Carvalho Chehab int slot, int address, u8 value) 196786baecfSMauro Carvalho Chehab { 197786baecfSMauro Carvalho Chehab u8 buf[3]; 198786baecfSMauro Carvalho Chehab 199786baecfSMauro Carvalho Chehab ci_dbg("%s %d 0x%04x 0x%02x", 200786baecfSMauro Carvalho Chehab __func__, slot, address, value); 201786baecfSMauro Carvalho Chehab 202786baecfSMauro Carvalho Chehab if (0 != slot) 203786baecfSMauro Carvalho Chehab return -EINVAL; 204786baecfSMauro Carvalho Chehab 205786baecfSMauro Carvalho Chehab buf[0] = (address >> 8) & 0x0F; 206786baecfSMauro Carvalho Chehab buf[1] = address; 207786baecfSMauro Carvalho Chehab buf[2] = value; 208786baecfSMauro Carvalho Chehab 209786baecfSMauro Carvalho Chehab return tt3650_ci_msg_locked(ca, TT3650_CMD_CI_WR_ATTR, buf, 3, 3); 210786baecfSMauro Carvalho Chehab } 211786baecfSMauro Carvalho Chehab 212786baecfSMauro Carvalho Chehab static int tt3650_ci_read_cam_control(struct dvb_ca_en50221 *ca, 213786baecfSMauro Carvalho Chehab int slot, 214786baecfSMauro Carvalho Chehab u8 address) 215786baecfSMauro Carvalho Chehab { 216786baecfSMauro Carvalho Chehab u8 buf[2]; 217786baecfSMauro Carvalho Chehab int ret; 218786baecfSMauro Carvalho Chehab 219786baecfSMauro Carvalho Chehab if (0 != slot) 220786baecfSMauro Carvalho Chehab return -EINVAL; 221786baecfSMauro Carvalho Chehab 222786baecfSMauro Carvalho Chehab buf[0] = address & 3; 223786baecfSMauro Carvalho Chehab 224786baecfSMauro Carvalho Chehab ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_RD_CTRL, buf, 1, 2); 225786baecfSMauro Carvalho Chehab 226786baecfSMauro Carvalho Chehab ci_dbg("%s 0x%02x -> %d 0x%02x", 227786baecfSMauro Carvalho Chehab __func__, address, ret, buf[1]); 228786baecfSMauro Carvalho Chehab 229786baecfSMauro Carvalho Chehab if (ret < 0) 230786baecfSMauro Carvalho Chehab return ret; 231786baecfSMauro Carvalho Chehab 232786baecfSMauro Carvalho Chehab return buf[1]; 233786baecfSMauro Carvalho Chehab } 234786baecfSMauro Carvalho Chehab 235786baecfSMauro Carvalho Chehab static int tt3650_ci_write_cam_control(struct dvb_ca_en50221 *ca, 236786baecfSMauro Carvalho Chehab int slot, 237786baecfSMauro Carvalho Chehab u8 address, 238786baecfSMauro Carvalho Chehab u8 value) 239786baecfSMauro Carvalho Chehab { 240786baecfSMauro Carvalho Chehab u8 buf[2]; 241786baecfSMauro Carvalho Chehab 242786baecfSMauro Carvalho Chehab ci_dbg("%s %d 0x%02x 0x%02x", 243786baecfSMauro Carvalho Chehab __func__, slot, address, value); 244786baecfSMauro Carvalho Chehab 245786baecfSMauro Carvalho Chehab if (0 != slot) 246786baecfSMauro Carvalho Chehab return -EINVAL; 247786baecfSMauro Carvalho Chehab 248786baecfSMauro Carvalho Chehab buf[0] = address; 249786baecfSMauro Carvalho Chehab buf[1] = value; 250786baecfSMauro Carvalho Chehab 251786baecfSMauro Carvalho Chehab return tt3650_ci_msg_locked(ca, TT3650_CMD_CI_WR_CTRL, buf, 2, 2); 252786baecfSMauro Carvalho Chehab } 253786baecfSMauro Carvalho Chehab 254786baecfSMauro Carvalho Chehab static int tt3650_ci_set_video_port(struct dvb_ca_en50221 *ca, 255786baecfSMauro Carvalho Chehab int slot, 256786baecfSMauro Carvalho Chehab int enable) 257786baecfSMauro Carvalho Chehab { 258786baecfSMauro Carvalho Chehab u8 buf[1]; 259786baecfSMauro Carvalho Chehab int ret; 260786baecfSMauro Carvalho Chehab 261786baecfSMauro Carvalho Chehab ci_dbg("%s %d %d", __func__, slot, enable); 262786baecfSMauro Carvalho Chehab 263786baecfSMauro Carvalho Chehab if (0 != slot) 264786baecfSMauro Carvalho Chehab return -EINVAL; 265786baecfSMauro Carvalho Chehab 266786baecfSMauro Carvalho Chehab enable = !!enable; 267786baecfSMauro Carvalho Chehab buf[0] = enable; 268786baecfSMauro Carvalho Chehab 269786baecfSMauro Carvalho Chehab ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_SET_VIDEO_PORT, buf, 1, 1); 270786baecfSMauro Carvalho Chehab if (ret < 0) 271786baecfSMauro Carvalho Chehab return ret; 272786baecfSMauro Carvalho Chehab 273786baecfSMauro Carvalho Chehab if (enable != buf[0]) { 274786baecfSMauro Carvalho Chehab err("CI not %sabled.", enable ? "en" : "dis"); 275786baecfSMauro Carvalho Chehab return -EIO; 276786baecfSMauro Carvalho Chehab } 277786baecfSMauro Carvalho Chehab 278786baecfSMauro Carvalho Chehab return 0; 279786baecfSMauro Carvalho Chehab } 280786baecfSMauro Carvalho Chehab 281786baecfSMauro Carvalho Chehab static int tt3650_ci_slot_shutdown(struct dvb_ca_en50221 *ca, int slot) 282786baecfSMauro Carvalho Chehab { 283786baecfSMauro Carvalho Chehab return tt3650_ci_set_video_port(ca, slot, /* enable */ 0); 284786baecfSMauro Carvalho Chehab } 285786baecfSMauro Carvalho Chehab 286786baecfSMauro Carvalho Chehab static int tt3650_ci_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) 287786baecfSMauro Carvalho Chehab { 288786baecfSMauro Carvalho Chehab return tt3650_ci_set_video_port(ca, slot, /* enable */ 1); 289786baecfSMauro Carvalho Chehab } 290786baecfSMauro Carvalho Chehab 291786baecfSMauro Carvalho Chehab static int tt3650_ci_slot_reset(struct dvb_ca_en50221 *ca, int slot) 292786baecfSMauro Carvalho Chehab { 293786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data; 294786baecfSMauro Carvalho Chehab struct pctv452e_state *state = (struct pctv452e_state *)d->priv; 295786baecfSMauro Carvalho Chehab u8 buf[1]; 296786baecfSMauro Carvalho Chehab int ret; 297786baecfSMauro Carvalho Chehab 298786baecfSMauro Carvalho Chehab ci_dbg("%s %d", __func__, slot); 299786baecfSMauro Carvalho Chehab 300786baecfSMauro Carvalho Chehab if (0 != slot) 301786baecfSMauro Carvalho Chehab return -EINVAL; 302786baecfSMauro Carvalho Chehab 303786baecfSMauro Carvalho Chehab buf[0] = 0; 304786baecfSMauro Carvalho Chehab 305786baecfSMauro Carvalho Chehab mutex_lock(&state->ca_mutex); 306786baecfSMauro Carvalho Chehab 307786baecfSMauro Carvalho Chehab ret = tt3650_ci_msg(d, TT3650_CMD_CI_RESET, buf, 1, 1); 308786baecfSMauro Carvalho Chehab if (0 != ret) 309786baecfSMauro Carvalho Chehab goto failed; 310786baecfSMauro Carvalho Chehab 311786baecfSMauro Carvalho Chehab msleep(500); 312786baecfSMauro Carvalho Chehab 313786baecfSMauro Carvalho Chehab buf[0] = 1; 314786baecfSMauro Carvalho Chehab 315786baecfSMauro Carvalho Chehab ret = tt3650_ci_msg(d, TT3650_CMD_CI_RESET, buf, 1, 1); 316786baecfSMauro Carvalho Chehab if (0 != ret) 317786baecfSMauro Carvalho Chehab goto failed; 318786baecfSMauro Carvalho Chehab 319786baecfSMauro Carvalho Chehab msleep(500); 320786baecfSMauro Carvalho Chehab 321786baecfSMauro Carvalho Chehab buf[0] = 0; /* FTA */ 322786baecfSMauro Carvalho Chehab 323786baecfSMauro Carvalho Chehab ret = tt3650_ci_msg(d, TT3650_CMD_CI_SET_VIDEO_PORT, buf, 1, 1); 324786baecfSMauro Carvalho Chehab 325786baecfSMauro Carvalho Chehab failed: 326786baecfSMauro Carvalho Chehab mutex_unlock(&state->ca_mutex); 327786baecfSMauro Carvalho Chehab 328786baecfSMauro Carvalho Chehab return ret; 329786baecfSMauro Carvalho Chehab } 330786baecfSMauro Carvalho Chehab 331786baecfSMauro Carvalho Chehab static int tt3650_ci_poll_slot_status(struct dvb_ca_en50221 *ca, 332786baecfSMauro Carvalho Chehab int slot, 333786baecfSMauro Carvalho Chehab int open) 334786baecfSMauro Carvalho Chehab { 335786baecfSMauro Carvalho Chehab u8 buf[1]; 336786baecfSMauro Carvalho Chehab int ret; 337786baecfSMauro Carvalho Chehab 338786baecfSMauro Carvalho Chehab if (0 != slot) 339786baecfSMauro Carvalho Chehab return -EINVAL; 340786baecfSMauro Carvalho Chehab 341786baecfSMauro Carvalho Chehab ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_TEST, buf, 0, 1); 342786baecfSMauro Carvalho Chehab if (0 != ret) 343786baecfSMauro Carvalho Chehab return ret; 344786baecfSMauro Carvalho Chehab 345786baecfSMauro Carvalho Chehab if (1 == buf[0]) 346786baecfSMauro Carvalho Chehab return DVB_CA_EN50221_POLL_CAM_PRESENT | 347786baecfSMauro Carvalho Chehab DVB_CA_EN50221_POLL_CAM_READY; 348786baecfSMauro Carvalho Chehab 349786baecfSMauro Carvalho Chehab return 0; 350786baecfSMauro Carvalho Chehab 351786baecfSMauro Carvalho Chehab } 352786baecfSMauro Carvalho Chehab 353786baecfSMauro Carvalho Chehab static void tt3650_ci_uninit(struct dvb_usb_device *d) 354786baecfSMauro Carvalho Chehab { 355786baecfSMauro Carvalho Chehab struct pctv452e_state *state; 356786baecfSMauro Carvalho Chehab 357786baecfSMauro Carvalho Chehab ci_dbg("%s", __func__); 358786baecfSMauro Carvalho Chehab 359786baecfSMauro Carvalho Chehab if (NULL == d) 360786baecfSMauro Carvalho Chehab return; 361786baecfSMauro Carvalho Chehab 362786baecfSMauro Carvalho Chehab state = (struct pctv452e_state *)d->priv; 363786baecfSMauro Carvalho Chehab if (NULL == state) 364786baecfSMauro Carvalho Chehab return; 365786baecfSMauro Carvalho Chehab 366786baecfSMauro Carvalho Chehab if (NULL == state->ca.data) 367786baecfSMauro Carvalho Chehab return; 368786baecfSMauro Carvalho Chehab 369786baecfSMauro Carvalho Chehab /* Error ignored. */ 370786baecfSMauro Carvalho Chehab tt3650_ci_set_video_port(&state->ca, /* slot */ 0, /* enable */ 0); 371786baecfSMauro Carvalho Chehab 372786baecfSMauro Carvalho Chehab dvb_ca_en50221_release(&state->ca); 373786baecfSMauro Carvalho Chehab 374786baecfSMauro Carvalho Chehab memset(&state->ca, 0, sizeof(state->ca)); 375786baecfSMauro Carvalho Chehab } 376786baecfSMauro Carvalho Chehab 377786baecfSMauro Carvalho Chehab static int tt3650_ci_init(struct dvb_usb_adapter *a) 378786baecfSMauro Carvalho Chehab { 379786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = a->dev; 380786baecfSMauro Carvalho Chehab struct pctv452e_state *state = (struct pctv452e_state *)d->priv; 381786baecfSMauro Carvalho Chehab int ret; 382786baecfSMauro Carvalho Chehab 383786baecfSMauro Carvalho Chehab ci_dbg("%s", __func__); 384786baecfSMauro Carvalho Chehab 385786baecfSMauro Carvalho Chehab mutex_init(&state->ca_mutex); 386786baecfSMauro Carvalho Chehab 387786baecfSMauro Carvalho Chehab state->ca.owner = THIS_MODULE; 388786baecfSMauro Carvalho Chehab state->ca.read_attribute_mem = tt3650_ci_read_attribute_mem; 389786baecfSMauro Carvalho Chehab state->ca.write_attribute_mem = tt3650_ci_write_attribute_mem; 390786baecfSMauro Carvalho Chehab state->ca.read_cam_control = tt3650_ci_read_cam_control; 391786baecfSMauro Carvalho Chehab state->ca.write_cam_control = tt3650_ci_write_cam_control; 392786baecfSMauro Carvalho Chehab state->ca.slot_reset = tt3650_ci_slot_reset; 393786baecfSMauro Carvalho Chehab state->ca.slot_shutdown = tt3650_ci_slot_shutdown; 394786baecfSMauro Carvalho Chehab state->ca.slot_ts_enable = tt3650_ci_slot_ts_enable; 395786baecfSMauro Carvalho Chehab state->ca.poll_slot_status = tt3650_ci_poll_slot_status; 396786baecfSMauro Carvalho Chehab state->ca.data = d; 397786baecfSMauro Carvalho Chehab 398786baecfSMauro Carvalho Chehab ret = dvb_ca_en50221_init(&a->dvb_adap, 399786baecfSMauro Carvalho Chehab &state->ca, 400786baecfSMauro Carvalho Chehab /* flags */ 0, 401786baecfSMauro Carvalho Chehab /* n_slots */ 1); 402786baecfSMauro Carvalho Chehab if (0 != ret) { 403786baecfSMauro Carvalho Chehab err("Cannot initialize CI: Error %d.", ret); 404786baecfSMauro Carvalho Chehab memset(&state->ca, 0, sizeof(state->ca)); 405786baecfSMauro Carvalho Chehab return ret; 406786baecfSMauro Carvalho Chehab } 407786baecfSMauro Carvalho Chehab 408786baecfSMauro Carvalho Chehab info("CI initialized."); 409786baecfSMauro Carvalho Chehab 410786baecfSMauro Carvalho Chehab return 0; 411786baecfSMauro Carvalho Chehab } 412786baecfSMauro Carvalho Chehab 413786baecfSMauro Carvalho Chehab #define CMD_BUFFER_SIZE 0x28 414786baecfSMauro Carvalho Chehab static int pctv452e_i2c_msg(struct dvb_usb_device *d, u8 addr, 415786baecfSMauro Carvalho Chehab const u8 *snd_buf, u8 snd_len, 416786baecfSMauro Carvalho Chehab u8 *rcv_buf, u8 rcv_len) 417786baecfSMauro Carvalho Chehab { 418786baecfSMauro Carvalho Chehab struct pctv452e_state *state = (struct pctv452e_state *)d->priv; 41948775cb7SMax Kellermann u8 *buf; 420786baecfSMauro Carvalho Chehab u8 id; 421786baecfSMauro Carvalho Chehab int ret; 422786baecfSMauro Carvalho Chehab 42348775cb7SMax Kellermann buf = kmalloc(64, GFP_KERNEL); 42448775cb7SMax Kellermann if (!buf) 42548775cb7SMax Kellermann return -ENOMEM; 42648775cb7SMax Kellermann 427786baecfSMauro Carvalho Chehab id = state->c++; 428786baecfSMauro Carvalho Chehab 429786baecfSMauro Carvalho Chehab ret = -EINVAL; 430786baecfSMauro Carvalho Chehab if (snd_len > 64 - 7 || rcv_len > 64 - 7) 431786baecfSMauro Carvalho Chehab goto failed; 432786baecfSMauro Carvalho Chehab 43348775cb7SMax Kellermann buf[0] = SYNC_BYTE_OUT; 43448775cb7SMax Kellermann buf[1] = id; 43548775cb7SMax Kellermann buf[2] = PCTV_CMD_I2C; 43648775cb7SMax Kellermann buf[3] = snd_len + 3; 43748775cb7SMax Kellermann buf[4] = addr << 1; 43848775cb7SMax Kellermann buf[5] = snd_len; 43948775cb7SMax Kellermann buf[6] = rcv_len; 440786baecfSMauro Carvalho Chehab 44148775cb7SMax Kellermann memcpy(buf + 7, snd_buf, snd_len); 442786baecfSMauro Carvalho Chehab 44348775cb7SMax Kellermann ret = dvb_usb_generic_rw(d, buf, 7 + snd_len, 44448775cb7SMax Kellermann buf, /* rcv_len */ 64, 445786baecfSMauro Carvalho Chehab /* delay_ms */ 0); 446786baecfSMauro Carvalho Chehab if (ret < 0) 447786baecfSMauro Carvalho Chehab goto failed; 448786baecfSMauro Carvalho Chehab 449786baecfSMauro Carvalho Chehab /* TT USB protocol error. */ 450786baecfSMauro Carvalho Chehab ret = -EIO; 45148775cb7SMax Kellermann if (SYNC_BYTE_IN != buf[0] || id != buf[1]) 452786baecfSMauro Carvalho Chehab goto failed; 453786baecfSMauro Carvalho Chehab 454786baecfSMauro Carvalho Chehab /* I2C device didn't respond as expected. */ 455786baecfSMauro Carvalho Chehab ret = -EREMOTEIO; 45648775cb7SMax Kellermann if (buf[5] < snd_len || buf[6] < rcv_len) 457786baecfSMauro Carvalho Chehab goto failed; 458786baecfSMauro Carvalho Chehab 45948775cb7SMax Kellermann memcpy(rcv_buf, buf + 7, rcv_len); 460786baecfSMauro Carvalho Chehab 46148775cb7SMax Kellermann kfree(buf); 462786baecfSMauro Carvalho Chehab return rcv_len; 463786baecfSMauro Carvalho Chehab 464786baecfSMauro Carvalho Chehab failed: 46573d5c5c8SMauro Carvalho Chehab err("I2C error %d; %02X %02X %02X %02X %02X -> %*ph", 466786baecfSMauro Carvalho Chehab ret, SYNC_BYTE_OUT, id, addr << 1, snd_len, rcv_len, 46748775cb7SMax Kellermann 7, buf); 468786baecfSMauro Carvalho Chehab 46948775cb7SMax Kellermann kfree(buf); 470786baecfSMauro Carvalho Chehab return ret; 471786baecfSMauro Carvalho Chehab } 472786baecfSMauro Carvalho Chehab 473786baecfSMauro Carvalho Chehab static int pctv452e_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msg, 474786baecfSMauro Carvalho Chehab int num) 475786baecfSMauro Carvalho Chehab { 476786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = i2c_get_adapdata(adapter); 477786baecfSMauro Carvalho Chehab int i; 478786baecfSMauro Carvalho Chehab 479786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 480786baecfSMauro Carvalho Chehab return -EAGAIN; 481786baecfSMauro Carvalho Chehab 482786baecfSMauro Carvalho Chehab for (i = 0; i < num; i++) { 483786baecfSMauro Carvalho Chehab u8 addr, snd_len, rcv_len, *snd_buf, *rcv_buf; 484786baecfSMauro Carvalho Chehab int ret; 485786baecfSMauro Carvalho Chehab 486786baecfSMauro Carvalho Chehab if (msg[i].flags & I2C_M_RD) { 487786baecfSMauro Carvalho Chehab addr = msg[i].addr; 488786baecfSMauro Carvalho Chehab snd_buf = NULL; 489786baecfSMauro Carvalho Chehab snd_len = 0; 490786baecfSMauro Carvalho Chehab rcv_buf = msg[i].buf; 491786baecfSMauro Carvalho Chehab rcv_len = msg[i].len; 492786baecfSMauro Carvalho Chehab } else { 493786baecfSMauro Carvalho Chehab addr = msg[i].addr; 494786baecfSMauro Carvalho Chehab snd_buf = msg[i].buf; 495786baecfSMauro Carvalho Chehab snd_len = msg[i].len; 496786baecfSMauro Carvalho Chehab rcv_buf = NULL; 497786baecfSMauro Carvalho Chehab rcv_len = 0; 498786baecfSMauro Carvalho Chehab } 499786baecfSMauro Carvalho Chehab 500786baecfSMauro Carvalho Chehab ret = pctv452e_i2c_msg(d, addr, snd_buf, snd_len, rcv_buf, 501786baecfSMauro Carvalho Chehab rcv_len); 502786baecfSMauro Carvalho Chehab if (ret < rcv_len) 503786baecfSMauro Carvalho Chehab break; 504786baecfSMauro Carvalho Chehab } 505786baecfSMauro Carvalho Chehab 506786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 507786baecfSMauro Carvalho Chehab return i; 508786baecfSMauro Carvalho Chehab } 509786baecfSMauro Carvalho Chehab 510786baecfSMauro Carvalho Chehab static u32 pctv452e_i2c_func(struct i2c_adapter *adapter) 511786baecfSMauro Carvalho Chehab { 512786baecfSMauro Carvalho Chehab return I2C_FUNC_I2C; 513786baecfSMauro Carvalho Chehab } 514786baecfSMauro Carvalho Chehab 515786baecfSMauro Carvalho Chehab static int pctv452e_power_ctrl(struct dvb_usb_device *d, int i) 516786baecfSMauro Carvalho Chehab { 517786baecfSMauro Carvalho Chehab struct pctv452e_state *state = (struct pctv452e_state *)d->priv; 51848775cb7SMax Kellermann u8 *b0, *rx; 519786baecfSMauro Carvalho Chehab int ret; 520786baecfSMauro Carvalho Chehab 521786baecfSMauro Carvalho Chehab info("%s: %d\n", __func__, i); 522786baecfSMauro Carvalho Chehab 523786baecfSMauro Carvalho Chehab if (!i) 524786baecfSMauro Carvalho Chehab return 0; 525786baecfSMauro Carvalho Chehab 526786baecfSMauro Carvalho Chehab if (state->initialized) 527786baecfSMauro Carvalho Chehab return 0; 528786baecfSMauro Carvalho Chehab 52948775cb7SMax Kellermann b0 = kmalloc(5 + PCTV_ANSWER_LEN, GFP_KERNEL); 53048775cb7SMax Kellermann if (!b0) 53173d5c5c8SMauro Carvalho Chehab return -ENOMEM; 53273d5c5c8SMauro Carvalho Chehab 53348775cb7SMax Kellermann rx = b0 + 5; 53448775cb7SMax Kellermann 5353e4d8f48SMauro Carvalho Chehab /* hmm where should this should go? */ 536786baecfSMauro Carvalho Chehab ret = usb_set_interface(d->udev, 0, ISOC_INTERFACE_ALTERNATIVE); 537786baecfSMauro Carvalho Chehab if (ret != 0) 538786baecfSMauro Carvalho Chehab info("%s: Warning set interface returned: %d\n", 539786baecfSMauro Carvalho Chehab __func__, ret); 540786baecfSMauro Carvalho Chehab 5413e4d8f48SMauro Carvalho Chehab /* this is a one-time initialization, don't know where to put */ 54248775cb7SMax Kellermann b0[0] = 0xaa; 54348775cb7SMax Kellermann b0[1] = state->c++; 54448775cb7SMax Kellermann b0[2] = PCTV_CMD_RESET; 54548775cb7SMax Kellermann b0[3] = 1; 54648775cb7SMax Kellermann b0[4] = 0; 547786baecfSMauro Carvalho Chehab /* reset board */ 54848775cb7SMax Kellermann ret = dvb_usb_generic_rw(d, b0, 5, rx, PCTV_ANSWER_LEN, 0); 549786baecfSMauro Carvalho Chehab if (ret) 55073d5c5c8SMauro Carvalho Chehab goto ret; 551786baecfSMauro Carvalho Chehab 55248775cb7SMax Kellermann b0[1] = state->c++; 55348775cb7SMax Kellermann b0[4] = 1; 554786baecfSMauro Carvalho Chehab /* reset board (again?) */ 55548775cb7SMax Kellermann ret = dvb_usb_generic_rw(d, b0, 5, rx, PCTV_ANSWER_LEN, 0); 556786baecfSMauro Carvalho Chehab if (ret) 55773d5c5c8SMauro Carvalho Chehab goto ret; 558786baecfSMauro Carvalho Chehab 559786baecfSMauro Carvalho Chehab state->initialized = 1; 560786baecfSMauro Carvalho Chehab 56173d5c5c8SMauro Carvalho Chehab ret: 56248775cb7SMax Kellermann kfree(b0); 56373d5c5c8SMauro Carvalho Chehab return ret; 564786baecfSMauro Carvalho Chehab } 565786baecfSMauro Carvalho Chehab 566786baecfSMauro Carvalho Chehab static int pctv452e_rc_query(struct dvb_usb_device *d) 567786baecfSMauro Carvalho Chehab { 568786baecfSMauro Carvalho Chehab struct pctv452e_state *state = (struct pctv452e_state *)d->priv; 56948775cb7SMax Kellermann u8 *b, *rx; 570786baecfSMauro Carvalho Chehab int ret, i; 57173d5c5c8SMauro Carvalho Chehab u8 id; 57273d5c5c8SMauro Carvalho Chehab 57348775cb7SMax Kellermann b = kmalloc(CMD_BUFFER_SIZE + PCTV_ANSWER_LEN, GFP_KERNEL); 57448775cb7SMax Kellermann if (!b) 57548775cb7SMax Kellermann return -ENOMEM; 57648775cb7SMax Kellermann 57748775cb7SMax Kellermann rx = b + CMD_BUFFER_SIZE; 57848775cb7SMax Kellermann 57973d5c5c8SMauro Carvalho Chehab id = state->c++; 580786baecfSMauro Carvalho Chehab 581786baecfSMauro Carvalho Chehab /* prepare command header */ 58248775cb7SMax Kellermann b[0] = SYNC_BYTE_OUT; 58348775cb7SMax Kellermann b[1] = id; 58448775cb7SMax Kellermann b[2] = PCTV_CMD_IR; 58548775cb7SMax Kellermann b[3] = 0; 586786baecfSMauro Carvalho Chehab 587786baecfSMauro Carvalho Chehab /* send ir request */ 58848775cb7SMax Kellermann ret = dvb_usb_generic_rw(d, b, 4, rx, PCTV_ANSWER_LEN, 0); 589786baecfSMauro Carvalho Chehab if (ret != 0) 59073d5c5c8SMauro Carvalho Chehab goto ret; 591786baecfSMauro Carvalho Chehab 592786baecfSMauro Carvalho Chehab if (debug > 3) { 59348775cb7SMax Kellermann info("%s: read: %2d: %*ph: ", __func__, ret, 3, rx); 59448775cb7SMax Kellermann for (i = 0; (i < rx[3]) && ((i+3) < PCTV_ANSWER_LEN); i++) 59548775cb7SMax Kellermann info(" %02x", rx[i+3]); 596786baecfSMauro Carvalho Chehab 597786baecfSMauro Carvalho Chehab info("\n"); 598786baecfSMauro Carvalho Chehab } 599786baecfSMauro Carvalho Chehab 60048775cb7SMax Kellermann if ((rx[3] == 9) && (rx[12] & 0x01)) { 601786baecfSMauro Carvalho Chehab /* got a "press" event */ 60248775cb7SMax Kellermann state->last_rc_key = RC_SCANCODE_RC5(rx[7], rx[6]); 603786baecfSMauro Carvalho Chehab if (debug > 2) 604786baecfSMauro Carvalho Chehab info("%s: cmd=0x%02x sys=0x%02x\n", 60548775cb7SMax Kellermann __func__, rx[6], rx[7]); 606786baecfSMauro Carvalho Chehab 6076d741bfeSSean Young rc_keydown(d->rc_dev, RC_PROTO_RC5, state->last_rc_key, 0); 608786baecfSMauro Carvalho Chehab } else if (state->last_rc_key) { 609786baecfSMauro Carvalho Chehab rc_keyup(d->rc_dev); 610786baecfSMauro Carvalho Chehab state->last_rc_key = 0; 611786baecfSMauro Carvalho Chehab } 61273d5c5c8SMauro Carvalho Chehab ret: 61348775cb7SMax Kellermann kfree(b); 61473d5c5c8SMauro Carvalho Chehab return ret; 615786baecfSMauro Carvalho Chehab } 616786baecfSMauro Carvalho Chehab 617786baecfSMauro Carvalho Chehab static int pctv452e_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 618786baecfSMauro Carvalho Chehab { 619786baecfSMauro Carvalho Chehab const u8 mem_addr[] = { 0x1f, 0xcc }; 620786baecfSMauro Carvalho Chehab u8 encoded_mac[20]; 621786baecfSMauro Carvalho Chehab int ret; 622786baecfSMauro Carvalho Chehab 623786baecfSMauro Carvalho Chehab ret = -EAGAIN; 624786baecfSMauro Carvalho Chehab if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 625786baecfSMauro Carvalho Chehab goto failed; 626786baecfSMauro Carvalho Chehab 627786baecfSMauro Carvalho Chehab ret = pctv452e_i2c_msg(d, I2C_ADDR_24C16, 628786baecfSMauro Carvalho Chehab mem_addr + 1, /* snd_len */ 1, 629786baecfSMauro Carvalho Chehab encoded_mac, /* rcv_len */ 20); 630786baecfSMauro Carvalho Chehab if (-EREMOTEIO == ret) 631786baecfSMauro Carvalho Chehab /* Caution! A 24C16 interprets 0xA2 0x1F 0xCC as a 632786baecfSMauro Carvalho Chehab byte write if /WC is low. */ 633786baecfSMauro Carvalho Chehab ret = pctv452e_i2c_msg(d, I2C_ADDR_24C64, 634786baecfSMauro Carvalho Chehab mem_addr, 2, 635786baecfSMauro Carvalho Chehab encoded_mac, 20); 636786baecfSMauro Carvalho Chehab 637786baecfSMauro Carvalho Chehab mutex_unlock(&d->i2c_mutex); 638786baecfSMauro Carvalho Chehab 639786baecfSMauro Carvalho Chehab if (20 != ret) 640786baecfSMauro Carvalho Chehab goto failed; 641786baecfSMauro Carvalho Chehab 642786baecfSMauro Carvalho Chehab ret = ttpci_eeprom_decode_mac(mac, encoded_mac); 643786baecfSMauro Carvalho Chehab if (0 != ret) 644786baecfSMauro Carvalho Chehab goto failed; 645786baecfSMauro Carvalho Chehab 646786baecfSMauro Carvalho Chehab return 0; 647786baecfSMauro Carvalho Chehab 648786baecfSMauro Carvalho Chehab failed: 64938dcdca3SVaishali Thakkar eth_zero_addr(mac); 650786baecfSMauro Carvalho Chehab 651786baecfSMauro Carvalho Chehab return ret; 652786baecfSMauro Carvalho Chehab } 653786baecfSMauro Carvalho Chehab 654786baecfSMauro Carvalho Chehab static const struct stb0899_s1_reg pctv452e_init_dev[] = { 655786baecfSMauro Carvalho Chehab { STB0899_DISCNTRL1, 0x26 }, 656786baecfSMauro Carvalho Chehab { STB0899_DISCNTRL2, 0x80 }, 657786baecfSMauro Carvalho Chehab { STB0899_DISRX_ST0, 0x04 }, 658786baecfSMauro Carvalho Chehab { STB0899_DISRX_ST1, 0x20 }, 659786baecfSMauro Carvalho Chehab { STB0899_DISPARITY, 0x00 }, 660786baecfSMauro Carvalho Chehab { STB0899_DISFIFO, 0x00 }, 661786baecfSMauro Carvalho Chehab { STB0899_DISF22, 0x99 }, 662786baecfSMauro Carvalho Chehab { STB0899_DISF22RX, 0x85 }, /* 0xa8 */ 663786baecfSMauro Carvalho Chehab { STB0899_ACRPRESC, 0x11 }, 664786baecfSMauro Carvalho Chehab { STB0899_ACRDIV1, 0x0a }, 665786baecfSMauro Carvalho Chehab { STB0899_ACRDIV2, 0x05 }, 666786baecfSMauro Carvalho Chehab { STB0899_DACR1 , 0x00 }, 667786baecfSMauro Carvalho Chehab { STB0899_DACR2 , 0x00 }, 668786baecfSMauro Carvalho Chehab { STB0899_OUTCFG, 0x00 }, 669786baecfSMauro Carvalho Chehab { STB0899_MODECFG, 0x00 }, /* Inversion */ 670786baecfSMauro Carvalho Chehab { STB0899_IRQMSK_3, 0xf3 }, 671786baecfSMauro Carvalho Chehab { STB0899_IRQMSK_2, 0xfc }, 672786baecfSMauro Carvalho Chehab { STB0899_IRQMSK_1, 0xff }, 673786baecfSMauro Carvalho Chehab { STB0899_IRQMSK_0, 0xff }, 674786baecfSMauro Carvalho Chehab { STB0899_I2CCFG, 0x88 }, 675786baecfSMauro Carvalho Chehab { STB0899_I2CRPT, 0x58 }, 676786baecfSMauro Carvalho Chehab { STB0899_GPIO00CFG, 0x82 }, 677786baecfSMauro Carvalho Chehab { STB0899_GPIO01CFG, 0x82 }, /* LED: 0x02 green, 0x82 orange */ 678786baecfSMauro Carvalho Chehab { STB0899_GPIO02CFG, 0x82 }, 679786baecfSMauro Carvalho Chehab { STB0899_GPIO03CFG, 0x82 }, 680786baecfSMauro Carvalho Chehab { STB0899_GPIO04CFG, 0x82 }, 681786baecfSMauro Carvalho Chehab { STB0899_GPIO05CFG, 0x82 }, 682786baecfSMauro Carvalho Chehab { STB0899_GPIO06CFG, 0x82 }, 683786baecfSMauro Carvalho Chehab { STB0899_GPIO07CFG, 0x82 }, 684786baecfSMauro Carvalho Chehab { STB0899_GPIO08CFG, 0x82 }, 685786baecfSMauro Carvalho Chehab { STB0899_GPIO09CFG, 0x82 }, 686786baecfSMauro Carvalho Chehab { STB0899_GPIO10CFG, 0x82 }, 687786baecfSMauro Carvalho Chehab { STB0899_GPIO11CFG, 0x82 }, 688786baecfSMauro Carvalho Chehab { STB0899_GPIO12CFG, 0x82 }, 689786baecfSMauro Carvalho Chehab { STB0899_GPIO13CFG, 0x82 }, 690786baecfSMauro Carvalho Chehab { STB0899_GPIO14CFG, 0x82 }, 691786baecfSMauro Carvalho Chehab { STB0899_GPIO15CFG, 0x82 }, 692786baecfSMauro Carvalho Chehab { STB0899_GPIO16CFG, 0x82 }, 693786baecfSMauro Carvalho Chehab { STB0899_GPIO17CFG, 0x82 }, 694786baecfSMauro Carvalho Chehab { STB0899_GPIO18CFG, 0x82 }, 695786baecfSMauro Carvalho Chehab { STB0899_GPIO19CFG, 0x82 }, 696786baecfSMauro Carvalho Chehab { STB0899_GPIO20CFG, 0x82 }, 697786baecfSMauro Carvalho Chehab { STB0899_SDATCFG, 0xb8 }, 698786baecfSMauro Carvalho Chehab { STB0899_SCLTCFG, 0xba }, 699786baecfSMauro Carvalho Chehab { STB0899_AGCRFCFG, 0x1c }, /* 0x11 DVB-S; 0x1c DVB-S2 (1c, rjkm) */ 700786baecfSMauro Carvalho Chehab { STB0899_GPIO22, 0x82 }, 701786baecfSMauro Carvalho Chehab { STB0899_GPIO21, 0x91 }, 702786baecfSMauro Carvalho Chehab { STB0899_DIRCLKCFG, 0x82 }, 703786baecfSMauro Carvalho Chehab { STB0899_CLKOUT27CFG, 0x7e }, 704786baecfSMauro Carvalho Chehab { STB0899_STDBYCFG, 0x82 }, 705786baecfSMauro Carvalho Chehab { STB0899_CS0CFG, 0x82 }, 706786baecfSMauro Carvalho Chehab { STB0899_CS1CFG, 0x82 }, 707786baecfSMauro Carvalho Chehab { STB0899_DISEQCOCFG, 0x20 }, 708786baecfSMauro Carvalho Chehab { STB0899_NCOARSE, 0x15 }, /* 0x15 27Mhz, F/3 198MHz, F/6 108MHz */ 709786baecfSMauro Carvalho Chehab { STB0899_SYNTCTRL, 0x00 }, /* 0x00 CLKI, 0x02 XTALI */ 710786baecfSMauro Carvalho Chehab { STB0899_FILTCTRL, 0x00 }, 711786baecfSMauro Carvalho Chehab { STB0899_SYSCTRL, 0x00 }, 712786baecfSMauro Carvalho Chehab { STB0899_STOPCLK1, 0x20 }, /* orig: 0x00 budget-ci: 0x20 */ 713786baecfSMauro Carvalho Chehab { STB0899_STOPCLK2, 0x00 }, 714786baecfSMauro Carvalho Chehab { STB0899_INTBUFCTRL, 0x0a }, 715786baecfSMauro Carvalho Chehab { STB0899_AGC2I1, 0x00 }, 716786baecfSMauro Carvalho Chehab { STB0899_AGC2I2, 0x00 }, 717786baecfSMauro Carvalho Chehab { STB0899_AGCIQIN, 0x00 }, 718786baecfSMauro Carvalho Chehab { STB0899_TSTRES, 0x40 }, /* rjkm */ 719786baecfSMauro Carvalho Chehab { 0xffff, 0xff }, 720786baecfSMauro Carvalho Chehab }; 721786baecfSMauro Carvalho Chehab 722786baecfSMauro Carvalho Chehab static const struct stb0899_s1_reg pctv452e_init_s1_demod[] = { 723786baecfSMauro Carvalho Chehab { STB0899_DEMOD, 0x00 }, 724786baecfSMauro Carvalho Chehab { STB0899_RCOMPC, 0xc9 }, 725786baecfSMauro Carvalho Chehab { STB0899_AGC1CN, 0x01 }, 726786baecfSMauro Carvalho Chehab { STB0899_AGC1REF, 0x10 }, 727786baecfSMauro Carvalho Chehab { STB0899_RTC, 0x23 }, 728786baecfSMauro Carvalho Chehab { STB0899_TMGCFG, 0x4e }, 729786baecfSMauro Carvalho Chehab { STB0899_AGC2REF, 0x34 }, 730786baecfSMauro Carvalho Chehab { STB0899_TLSR, 0x84 }, 731786baecfSMauro Carvalho Chehab { STB0899_CFD, 0xf7 }, 732786baecfSMauro Carvalho Chehab { STB0899_ACLC, 0x87 }, 733786baecfSMauro Carvalho Chehab { STB0899_BCLC, 0x94 }, 734786baecfSMauro Carvalho Chehab { STB0899_EQON, 0x41 }, 735786baecfSMauro Carvalho Chehab { STB0899_LDT, 0xf1 }, 736786baecfSMauro Carvalho Chehab { STB0899_LDT2, 0xe3 }, 737786baecfSMauro Carvalho Chehab { STB0899_EQUALREF, 0xb4 }, 738786baecfSMauro Carvalho Chehab { STB0899_TMGRAMP, 0x10 }, 739786baecfSMauro Carvalho Chehab { STB0899_TMGTHD, 0x30 }, 740786baecfSMauro Carvalho Chehab { STB0899_IDCCOMP, 0xfd }, 741786baecfSMauro Carvalho Chehab { STB0899_QDCCOMP, 0xff }, 742786baecfSMauro Carvalho Chehab { STB0899_POWERI, 0x0c }, 743786baecfSMauro Carvalho Chehab { STB0899_POWERQ, 0x0f }, 744786baecfSMauro Carvalho Chehab { STB0899_RCOMP, 0x6c }, 745786baecfSMauro Carvalho Chehab { STB0899_AGCIQIN, 0x80 }, 746786baecfSMauro Carvalho Chehab { STB0899_AGC2I1, 0x06 }, 747786baecfSMauro Carvalho Chehab { STB0899_AGC2I2, 0x00 }, 748786baecfSMauro Carvalho Chehab { STB0899_TLIR, 0x30 }, 749786baecfSMauro Carvalho Chehab { STB0899_RTF, 0x7f }, 750786baecfSMauro Carvalho Chehab { STB0899_DSTATUS, 0x00 }, 751786baecfSMauro Carvalho Chehab { STB0899_LDI, 0xbc }, 752786baecfSMauro Carvalho Chehab { STB0899_CFRM, 0xea }, 753786baecfSMauro Carvalho Chehab { STB0899_CFRL, 0x31 }, 754786baecfSMauro Carvalho Chehab { STB0899_NIRM, 0x2b }, 755786baecfSMauro Carvalho Chehab { STB0899_NIRL, 0x80 }, 756786baecfSMauro Carvalho Chehab { STB0899_ISYMB, 0x1d }, 757786baecfSMauro Carvalho Chehab { STB0899_QSYMB, 0xa6 }, 758786baecfSMauro Carvalho Chehab { STB0899_SFRH, 0x2f }, 759786baecfSMauro Carvalho Chehab { STB0899_SFRM, 0x68 }, 760786baecfSMauro Carvalho Chehab { STB0899_SFRL, 0x40 }, 761786baecfSMauro Carvalho Chehab { STB0899_SFRUPH, 0x2f }, 762786baecfSMauro Carvalho Chehab { STB0899_SFRUPM, 0x68 }, 763786baecfSMauro Carvalho Chehab { STB0899_SFRUPL, 0x40 }, 764786baecfSMauro Carvalho Chehab { STB0899_EQUAI1, 0x02 }, 765786baecfSMauro Carvalho Chehab { STB0899_EQUAQ1, 0xff }, 766786baecfSMauro Carvalho Chehab { STB0899_EQUAI2, 0x04 }, 767786baecfSMauro Carvalho Chehab { STB0899_EQUAQ2, 0x05 }, 768786baecfSMauro Carvalho Chehab { STB0899_EQUAI3, 0x02 }, 769786baecfSMauro Carvalho Chehab { STB0899_EQUAQ3, 0xfd }, 770786baecfSMauro Carvalho Chehab { STB0899_EQUAI4, 0x03 }, 771786baecfSMauro Carvalho Chehab { STB0899_EQUAQ4, 0x07 }, 772786baecfSMauro Carvalho Chehab { STB0899_EQUAI5, 0x08 }, 773786baecfSMauro Carvalho Chehab { STB0899_EQUAQ5, 0xf5 }, 774786baecfSMauro Carvalho Chehab { STB0899_DSTATUS2, 0x00 }, 775786baecfSMauro Carvalho Chehab { STB0899_VSTATUS, 0x00 }, 776786baecfSMauro Carvalho Chehab { STB0899_VERROR, 0x86 }, 777786baecfSMauro Carvalho Chehab { STB0899_IQSWAP, 0x2a }, 778786baecfSMauro Carvalho Chehab { STB0899_ECNT1M, 0x00 }, 779786baecfSMauro Carvalho Chehab { STB0899_ECNT1L, 0x00 }, 780786baecfSMauro Carvalho Chehab { STB0899_ECNT2M, 0x00 }, 781786baecfSMauro Carvalho Chehab { STB0899_ECNT2L, 0x00 }, 782786baecfSMauro Carvalho Chehab { STB0899_ECNT3M, 0x0a }, 783786baecfSMauro Carvalho Chehab { STB0899_ECNT3L, 0xad }, 784786baecfSMauro Carvalho Chehab { STB0899_FECAUTO1, 0x06 }, 785786baecfSMauro Carvalho Chehab { STB0899_FECM, 0x01 }, 786786baecfSMauro Carvalho Chehab { STB0899_VTH12, 0xb0 }, 787786baecfSMauro Carvalho Chehab { STB0899_VTH23, 0x7a }, 788786baecfSMauro Carvalho Chehab { STB0899_VTH34, 0x58 }, 789786baecfSMauro Carvalho Chehab { STB0899_VTH56, 0x38 }, 790786baecfSMauro Carvalho Chehab { STB0899_VTH67, 0x34 }, 791786baecfSMauro Carvalho Chehab { STB0899_VTH78, 0x24 }, 792786baecfSMauro Carvalho Chehab { STB0899_PRVIT, 0xff }, 793786baecfSMauro Carvalho Chehab { STB0899_VITSYNC, 0x19 }, 794786baecfSMauro Carvalho Chehab { STB0899_RSULC, 0xb1 }, /* DVB = 0xb1, DSS = 0xa1 */ 795786baecfSMauro Carvalho Chehab { STB0899_TSULC, 0x42 }, 796786baecfSMauro Carvalho Chehab { STB0899_RSLLC, 0x41 }, 797786baecfSMauro Carvalho Chehab { STB0899_TSLPL, 0x12 }, 798786baecfSMauro Carvalho Chehab { STB0899_TSCFGH, 0x0c }, 799786baecfSMauro Carvalho Chehab { STB0899_TSCFGM, 0x00 }, 800786baecfSMauro Carvalho Chehab { STB0899_TSCFGL, 0x00 }, 801786baecfSMauro Carvalho Chehab { STB0899_TSOUT, 0x69 }, /* 0x0d for CAM */ 802786baecfSMauro Carvalho Chehab { STB0899_RSSYNCDEL, 0x00 }, 803786baecfSMauro Carvalho Chehab { STB0899_TSINHDELH, 0x02 }, 804786baecfSMauro Carvalho Chehab { STB0899_TSINHDELM, 0x00 }, 805786baecfSMauro Carvalho Chehab { STB0899_TSINHDELL, 0x00 }, 806786baecfSMauro Carvalho Chehab { STB0899_TSLLSTKM, 0x1b }, 807786baecfSMauro Carvalho Chehab { STB0899_TSLLSTKL, 0xb3 }, 808786baecfSMauro Carvalho Chehab { STB0899_TSULSTKM, 0x00 }, 809786baecfSMauro Carvalho Chehab { STB0899_TSULSTKL, 0x00 }, 810786baecfSMauro Carvalho Chehab { STB0899_PCKLENUL, 0xbc }, 811786baecfSMauro Carvalho Chehab { STB0899_PCKLENLL, 0xcc }, 812786baecfSMauro Carvalho Chehab { STB0899_RSPCKLEN, 0xbd }, 813786baecfSMauro Carvalho Chehab { STB0899_TSSTATUS, 0x90 }, 814786baecfSMauro Carvalho Chehab { STB0899_ERRCTRL1, 0xb6 }, 815786baecfSMauro Carvalho Chehab { STB0899_ERRCTRL2, 0x95 }, 816786baecfSMauro Carvalho Chehab { STB0899_ERRCTRL3, 0x8d }, 817786baecfSMauro Carvalho Chehab { STB0899_DMONMSK1, 0x27 }, 818786baecfSMauro Carvalho Chehab { STB0899_DMONMSK0, 0x03 }, 819786baecfSMauro Carvalho Chehab { STB0899_DEMAPVIT, 0x5c }, 820786baecfSMauro Carvalho Chehab { STB0899_PLPARM, 0x19 }, 821786baecfSMauro Carvalho Chehab { STB0899_PDELCTRL, 0x48 }, 822786baecfSMauro Carvalho Chehab { STB0899_PDELCTRL2, 0x00 }, 823786baecfSMauro Carvalho Chehab { STB0899_BBHCTRL1, 0x00 }, 824786baecfSMauro Carvalho Chehab { STB0899_BBHCTRL2, 0x00 }, 825786baecfSMauro Carvalho Chehab { STB0899_HYSTTHRESH, 0x77 }, 826786baecfSMauro Carvalho Chehab { STB0899_MATCSTM, 0x00 }, 827786baecfSMauro Carvalho Chehab { STB0899_MATCSTL, 0x00 }, 828786baecfSMauro Carvalho Chehab { STB0899_UPLCSTM, 0x00 }, 829786baecfSMauro Carvalho Chehab { STB0899_UPLCSTL, 0x00 }, 830786baecfSMauro Carvalho Chehab { STB0899_DFLCSTM, 0x00 }, 831786baecfSMauro Carvalho Chehab { STB0899_DFLCSTL, 0x00 }, 832786baecfSMauro Carvalho Chehab { STB0899_SYNCCST, 0x00 }, 833786baecfSMauro Carvalho Chehab { STB0899_SYNCDCSTM, 0x00 }, 834786baecfSMauro Carvalho Chehab { STB0899_SYNCDCSTL, 0x00 }, 835786baecfSMauro Carvalho Chehab { STB0899_ISI_ENTRY, 0x00 }, 836786baecfSMauro Carvalho Chehab { STB0899_ISI_BIT_EN, 0x00 }, 837786baecfSMauro Carvalho Chehab { STB0899_MATSTRM, 0xf0 }, 838786baecfSMauro Carvalho Chehab { STB0899_MATSTRL, 0x02 }, 839786baecfSMauro Carvalho Chehab { STB0899_UPLSTRM, 0x45 }, 840786baecfSMauro Carvalho Chehab { STB0899_UPLSTRL, 0x60 }, 841786baecfSMauro Carvalho Chehab { STB0899_DFLSTRM, 0xe3 }, 842786baecfSMauro Carvalho Chehab { STB0899_DFLSTRL, 0x00 }, 843786baecfSMauro Carvalho Chehab { STB0899_SYNCSTR, 0x47 }, 844786baecfSMauro Carvalho Chehab { STB0899_SYNCDSTRM, 0x05 }, 845786baecfSMauro Carvalho Chehab { STB0899_SYNCDSTRL, 0x18 }, 846786baecfSMauro Carvalho Chehab { STB0899_CFGPDELSTATUS1, 0x19 }, 847786baecfSMauro Carvalho Chehab { STB0899_CFGPDELSTATUS2, 0x2b }, 848786baecfSMauro Carvalho Chehab { STB0899_BBFERRORM, 0x00 }, 849786baecfSMauro Carvalho Chehab { STB0899_BBFERRORL, 0x01 }, 850786baecfSMauro Carvalho Chehab { STB0899_UPKTERRORM, 0x00 }, 851786baecfSMauro Carvalho Chehab { STB0899_UPKTERRORL, 0x00 }, 852786baecfSMauro Carvalho Chehab { 0xffff, 0xff }, 853786baecfSMauro Carvalho Chehab }; 854786baecfSMauro Carvalho Chehab 855786baecfSMauro Carvalho Chehab static struct stb0899_config stb0899_config = { 856786baecfSMauro Carvalho Chehab .init_dev = pctv452e_init_dev, 857786baecfSMauro Carvalho Chehab .init_s2_demod = stb0899_s2_init_2, 858786baecfSMauro Carvalho Chehab .init_s1_demod = pctv452e_init_s1_demod, 859786baecfSMauro Carvalho Chehab .init_s2_fec = stb0899_s2_init_4, 860786baecfSMauro Carvalho Chehab .init_tst = stb0899_s1_init_5, 861786baecfSMauro Carvalho Chehab 862786baecfSMauro Carvalho Chehab .demod_address = I2C_ADDR_STB0899, /* I2C Address */ 863786baecfSMauro Carvalho Chehab .block_sync_mode = STB0899_SYNC_FORCED, /* ? */ 864786baecfSMauro Carvalho Chehab 865786baecfSMauro Carvalho Chehab .xtal_freq = 27000000, /* Assume Hz ? */ 8660735647cSReinhard Nissl .inversion = IQ_SWAP_ON, 867786baecfSMauro Carvalho Chehab 868786baecfSMauro Carvalho Chehab .lo_clk = 76500000, 869786baecfSMauro Carvalho Chehab .hi_clk = 99000000, 870786baecfSMauro Carvalho Chehab 871786baecfSMauro Carvalho Chehab .ts_output_mode = 0, /* Use parallel mode */ 872786baecfSMauro Carvalho Chehab .clock_polarity = 0, 873786baecfSMauro Carvalho Chehab .data_clk_parity = 0, 874786baecfSMauro Carvalho Chehab .fec_mode = 0, 875786baecfSMauro Carvalho Chehab 876786baecfSMauro Carvalho Chehab .esno_ave = STB0899_DVBS2_ESNO_AVE, 877786baecfSMauro Carvalho Chehab .esno_quant = STB0899_DVBS2_ESNO_QUANT, 878786baecfSMauro Carvalho Chehab .avframes_coarse = STB0899_DVBS2_AVFRAMES_COARSE, 879786baecfSMauro Carvalho Chehab .avframes_fine = STB0899_DVBS2_AVFRAMES_FINE, 880786baecfSMauro Carvalho Chehab .miss_threshold = STB0899_DVBS2_MISS_THRESHOLD, 881786baecfSMauro Carvalho Chehab .uwp_threshold_acq = STB0899_DVBS2_UWP_THRESHOLD_ACQ, 882786baecfSMauro Carvalho Chehab .uwp_threshold_track = STB0899_DVBS2_UWP_THRESHOLD_TRACK, 883786baecfSMauro Carvalho Chehab .uwp_threshold_sof = STB0899_DVBS2_UWP_THRESHOLD_SOF, 884786baecfSMauro Carvalho Chehab .sof_search_timeout = STB0899_DVBS2_SOF_SEARCH_TIMEOUT, 885786baecfSMauro Carvalho Chehab 886786baecfSMauro Carvalho Chehab .btr_nco_bits = STB0899_DVBS2_BTR_NCO_BITS, 887786baecfSMauro Carvalho Chehab .btr_gain_shift_offset = STB0899_DVBS2_BTR_GAIN_SHIFT_OFFSET, 888786baecfSMauro Carvalho Chehab .crl_nco_bits = STB0899_DVBS2_CRL_NCO_BITS, 889786baecfSMauro Carvalho Chehab .ldpc_max_iter = STB0899_DVBS2_LDPC_MAX_ITER, 890786baecfSMauro Carvalho Chehab 891786baecfSMauro Carvalho Chehab .tuner_get_frequency = stb6100_get_frequency, 892786baecfSMauro Carvalho Chehab .tuner_set_frequency = stb6100_set_frequency, 893786baecfSMauro Carvalho Chehab .tuner_set_bandwidth = stb6100_set_bandwidth, 894786baecfSMauro Carvalho Chehab .tuner_get_bandwidth = stb6100_get_bandwidth, 895786baecfSMauro Carvalho Chehab .tuner_set_rfsiggain = NULL, 896786baecfSMauro Carvalho Chehab 897786baecfSMauro Carvalho Chehab /* helper for switching LED green/orange */ 898786baecfSMauro Carvalho Chehab .postproc = pctv45e_postproc 899786baecfSMauro Carvalho Chehab }; 900786baecfSMauro Carvalho Chehab 901786baecfSMauro Carvalho Chehab static struct stb6100_config stb6100_config = { 902786baecfSMauro Carvalho Chehab .tuner_address = I2C_ADDR_STB6100, 903786baecfSMauro Carvalho Chehab .refclock = 27000000 904786baecfSMauro Carvalho Chehab }; 905786baecfSMauro Carvalho Chehab 906786baecfSMauro Carvalho Chehab 907786baecfSMauro Carvalho Chehab static struct i2c_algorithm pctv452e_i2c_algo = { 908786baecfSMauro Carvalho Chehab .master_xfer = pctv452e_i2c_xfer, 909786baecfSMauro Carvalho Chehab .functionality = pctv452e_i2c_func 910786baecfSMauro Carvalho Chehab }; 911786baecfSMauro Carvalho Chehab 912786baecfSMauro Carvalho Chehab static int pctv452e_frontend_attach(struct dvb_usb_adapter *a) 913786baecfSMauro Carvalho Chehab { 914786baecfSMauro Carvalho Chehab struct usb_device_id *id; 915786baecfSMauro Carvalho Chehab 916786baecfSMauro Carvalho Chehab a->fe_adap[0].fe = dvb_attach(stb0899_attach, &stb0899_config, 917786baecfSMauro Carvalho Chehab &a->dev->i2c_adap); 918786baecfSMauro Carvalho Chehab if (!a->fe_adap[0].fe) 919786baecfSMauro Carvalho Chehab return -ENODEV; 920786baecfSMauro Carvalho Chehab 921786baecfSMauro Carvalho Chehab id = a->dev->desc->warm_ids[0]; 922f35e5231SAlex Bee if (id->idVendor == USB_VID_TECHNOTREND && 923f35e5231SAlex Bee id->idProduct == USB_PID_TECHNOTREND_CONNECT_S2_3650_CI) { 924f35e5231SAlex Bee if (dvb_attach(lnbp22_attach, 925f35e5231SAlex Bee a->fe_adap[0].fe, 926f35e5231SAlex Bee &a->dev->i2c_adap) == NULL) { 927f35e5231SAlex Bee err("Cannot attach lnbp22\n"); 928f35e5231SAlex Bee } 929786baecfSMauro Carvalho Chehab /* Error ignored. */ 930786baecfSMauro Carvalho Chehab tt3650_ci_init(a); 931f35e5231SAlex Bee } else if (dvb_attach(isl6423_attach, 932f35e5231SAlex Bee a->fe_adap[0].fe, 933f35e5231SAlex Bee &a->dev->i2c_adap, 934f35e5231SAlex Bee &pctv452e_isl6423_config) == NULL) { 935f35e5231SAlex Bee err("Cannot attach isl6423\n"); 936f35e5231SAlex Bee } 937786baecfSMauro Carvalho Chehab 938786baecfSMauro Carvalho Chehab return 0; 939786baecfSMauro Carvalho Chehab } 940786baecfSMauro Carvalho Chehab 941786baecfSMauro Carvalho Chehab static int pctv452e_tuner_attach(struct dvb_usb_adapter *a) 942786baecfSMauro Carvalho Chehab { 943786baecfSMauro Carvalho Chehab if (!a->fe_adap[0].fe) 944786baecfSMauro Carvalho Chehab return -ENODEV; 945786baecfSMauro Carvalho Chehab if (dvb_attach(stb6100_attach, a->fe_adap[0].fe, &stb6100_config, 946ee40d32fSHans Verkuil &a->dev->i2c_adap) == NULL) { 947786baecfSMauro Carvalho Chehab err("%s failed\n", __func__); 948786baecfSMauro Carvalho Chehab return -ENODEV; 949786baecfSMauro Carvalho Chehab } 950786baecfSMauro Carvalho Chehab 951786baecfSMauro Carvalho Chehab return 0; 952786baecfSMauro Carvalho Chehab } 953786baecfSMauro Carvalho Chehab 954*710801c7SMauro Carvalho Chehab enum { 955*710801c7SMauro Carvalho Chehab PINNACLE_PCTV_452E, 956*710801c7SMauro Carvalho Chehab TECHNOTREND_CONNECT_S2_3600, 957*710801c7SMauro Carvalho Chehab TECHNOTREND_CONNECT_S2_3650_CI, 958*710801c7SMauro Carvalho Chehab }; 959*710801c7SMauro Carvalho Chehab 960786baecfSMauro Carvalho Chehab static struct usb_device_id pctv452e_usb_table[] = { 961*710801c7SMauro Carvalho Chehab DVB_USB_DEV(PINNACLE, PINNACLE_PCTV_452E), 962*710801c7SMauro Carvalho Chehab DVB_USB_DEV(TECHNOTREND, TECHNOTREND_CONNECT_S2_3600), 963*710801c7SMauro Carvalho Chehab DVB_USB_DEV(TECHNOTREND, TECHNOTREND_CONNECT_S2_3650_CI), 964786baecfSMauro Carvalho Chehab { } 965786baecfSMauro Carvalho Chehab }; 966*710801c7SMauro Carvalho Chehab 967786baecfSMauro Carvalho Chehab MODULE_DEVICE_TABLE(usb, pctv452e_usb_table); 968786baecfSMauro Carvalho Chehab 969786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties pctv452e_properties = { 970786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, /* more ? */ 971786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 972786baecfSMauro Carvalho Chehab 973786baecfSMauro Carvalho Chehab .size_of_priv = sizeof(struct pctv452e_state), 974786baecfSMauro Carvalho Chehab 975786baecfSMauro Carvalho Chehab .power_ctrl = pctv452e_power_ctrl, 976786baecfSMauro Carvalho Chehab 977786baecfSMauro Carvalho Chehab .rc.core = { 978786baecfSMauro Carvalho Chehab .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 9796d741bfeSSean Young .allowed_protos = RC_PROTO_BIT_RC5, 980786baecfSMauro Carvalho Chehab .rc_query = pctv452e_rc_query, 981786baecfSMauro Carvalho Chehab .rc_interval = 100, 982786baecfSMauro Carvalho Chehab }, 983786baecfSMauro Carvalho Chehab 984786baecfSMauro Carvalho Chehab .num_adapters = 1, 985786baecfSMauro Carvalho Chehab .adapter = {{ 986786baecfSMauro Carvalho Chehab .num_frontends = 1, 987786baecfSMauro Carvalho Chehab .fe = {{ 988786baecfSMauro Carvalho Chehab .frontend_attach = pctv452e_frontend_attach, 989786baecfSMauro Carvalho Chehab .tuner_attach = pctv452e_tuner_attach, 990786baecfSMauro Carvalho Chehab 991786baecfSMauro Carvalho Chehab /* parameter for the MPEG2-data transfer */ 992786baecfSMauro Carvalho Chehab .stream = { 993786baecfSMauro Carvalho Chehab .type = USB_ISOC, 994786baecfSMauro Carvalho Chehab .count = 4, 995786baecfSMauro Carvalho Chehab .endpoint = 0x02, 996786baecfSMauro Carvalho Chehab .u = { 997786baecfSMauro Carvalho Chehab .isoc = { 998786baecfSMauro Carvalho Chehab .framesperurb = 4, 999786baecfSMauro Carvalho Chehab .framesize = 940, 1000786baecfSMauro Carvalho Chehab .interval = 1 1001786baecfSMauro Carvalho Chehab } 1002786baecfSMauro Carvalho Chehab } 1003786baecfSMauro Carvalho Chehab }, 1004786baecfSMauro Carvalho Chehab } }, 1005786baecfSMauro Carvalho Chehab } }, 1006786baecfSMauro Carvalho Chehab 1007786baecfSMauro Carvalho Chehab .i2c_algo = &pctv452e_i2c_algo, 1008786baecfSMauro Carvalho Chehab 1009786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 1, /* allow generice rw function */ 1010786baecfSMauro Carvalho Chehab 1011786baecfSMauro Carvalho Chehab .num_device_descs = 1, 1012786baecfSMauro Carvalho Chehab .devices = { 1013786baecfSMauro Carvalho Chehab { .name = "PCTV HDTV USB", 1014786baecfSMauro Carvalho Chehab .cold_ids = { NULL, NULL }, /* this is a warm only device */ 1015*710801c7SMauro Carvalho Chehab .warm_ids = { &pctv452e_usb_table[PINNACLE_PCTV_452E], NULL } 1016786baecfSMauro Carvalho Chehab }, 1017ee40d32fSHans Verkuil { NULL }, 1018786baecfSMauro Carvalho Chehab } 1019786baecfSMauro Carvalho Chehab }; 1020786baecfSMauro Carvalho Chehab 1021786baecfSMauro Carvalho Chehab static struct dvb_usb_device_properties tt_connect_s2_3600_properties = { 1022786baecfSMauro Carvalho Chehab .caps = DVB_USB_IS_AN_I2C_ADAPTER, /* more ? */ 1023786baecfSMauro Carvalho Chehab .usb_ctrl = DEVICE_SPECIFIC, 1024786baecfSMauro Carvalho Chehab 1025786baecfSMauro Carvalho Chehab .size_of_priv = sizeof(struct pctv452e_state), 1026786baecfSMauro Carvalho Chehab 1027786baecfSMauro Carvalho Chehab .power_ctrl = pctv452e_power_ctrl, 1028786baecfSMauro Carvalho Chehab .read_mac_address = pctv452e_read_mac_address, 1029786baecfSMauro Carvalho Chehab 1030786baecfSMauro Carvalho Chehab .rc.core = { 1031786baecfSMauro Carvalho Chehab .rc_codes = RC_MAP_TT_1500, 10326d741bfeSSean Young .allowed_protos = RC_PROTO_BIT_RC5, 1033786baecfSMauro Carvalho Chehab .rc_query = pctv452e_rc_query, 1034786baecfSMauro Carvalho Chehab .rc_interval = 100, 1035786baecfSMauro Carvalho Chehab }, 1036786baecfSMauro Carvalho Chehab 1037786baecfSMauro Carvalho Chehab .num_adapters = 1, 1038786baecfSMauro Carvalho Chehab .adapter = {{ 1039786baecfSMauro Carvalho Chehab .num_frontends = 1, 1040786baecfSMauro Carvalho Chehab .fe = {{ 1041786baecfSMauro Carvalho Chehab .frontend_attach = pctv452e_frontend_attach, 1042786baecfSMauro Carvalho Chehab .tuner_attach = pctv452e_tuner_attach, 1043786baecfSMauro Carvalho Chehab 1044786baecfSMauro Carvalho Chehab /* parameter for the MPEG2-data transfer */ 1045786baecfSMauro Carvalho Chehab .stream = { 1046786baecfSMauro Carvalho Chehab .type = USB_ISOC, 1047a403ceebSOlli Salonen .count = 4, 1048786baecfSMauro Carvalho Chehab .endpoint = 0x02, 1049786baecfSMauro Carvalho Chehab .u = { 1050786baecfSMauro Carvalho Chehab .isoc = { 1051a403ceebSOlli Salonen .framesperurb = 64, 1052786baecfSMauro Carvalho Chehab .framesize = 940, 1053786baecfSMauro Carvalho Chehab .interval = 1 1054786baecfSMauro Carvalho Chehab } 1055786baecfSMauro Carvalho Chehab } 1056786baecfSMauro Carvalho Chehab }, 1057786baecfSMauro Carvalho Chehab 1058786baecfSMauro Carvalho Chehab } }, 1059786baecfSMauro Carvalho Chehab } }, 1060786baecfSMauro Carvalho Chehab 1061786baecfSMauro Carvalho Chehab .i2c_algo = &pctv452e_i2c_algo, 1062786baecfSMauro Carvalho Chehab 1063786baecfSMauro Carvalho Chehab .generic_bulk_ctrl_endpoint = 1, /* allow generic rw function*/ 1064786baecfSMauro Carvalho Chehab 1065786baecfSMauro Carvalho Chehab .num_device_descs = 2, 1066786baecfSMauro Carvalho Chehab .devices = { 1067786baecfSMauro Carvalho Chehab { .name = "Technotrend TT Connect S2-3600", 1068786baecfSMauro Carvalho Chehab .cold_ids = { NULL, NULL }, /* this is a warm only device */ 1069*710801c7SMauro Carvalho Chehab .warm_ids = { &pctv452e_usb_table[TECHNOTREND_CONNECT_S2_3600], NULL } 1070786baecfSMauro Carvalho Chehab }, 1071786baecfSMauro Carvalho Chehab { .name = "Technotrend TT Connect S2-3650-CI", 1072786baecfSMauro Carvalho Chehab .cold_ids = { NULL, NULL }, 1073*710801c7SMauro Carvalho Chehab .warm_ids = { &pctv452e_usb_table[TECHNOTREND_CONNECT_S2_3650_CI], NULL } 1074786baecfSMauro Carvalho Chehab }, 1075ee40d32fSHans Verkuil { NULL }, 1076786baecfSMauro Carvalho Chehab } 1077786baecfSMauro Carvalho Chehab }; 1078786baecfSMauro Carvalho Chehab 1079786baecfSMauro Carvalho Chehab static void pctv452e_usb_disconnect(struct usb_interface *intf) 1080786baecfSMauro Carvalho Chehab { 1081786baecfSMauro Carvalho Chehab struct dvb_usb_device *d = usb_get_intfdata(intf); 1082786baecfSMauro Carvalho Chehab 1083786baecfSMauro Carvalho Chehab tt3650_ci_uninit(d); 1084786baecfSMauro Carvalho Chehab dvb_usb_device_exit(intf); 1085786baecfSMauro Carvalho Chehab } 1086786baecfSMauro Carvalho Chehab 1087786baecfSMauro Carvalho Chehab static int pctv452e_usb_probe(struct usb_interface *intf, 1088786baecfSMauro Carvalho Chehab const struct usb_device_id *id) 1089786baecfSMauro Carvalho Chehab { 1090786baecfSMauro Carvalho Chehab if (0 == dvb_usb_device_init(intf, &pctv452e_properties, 1091786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr) || 1092786baecfSMauro Carvalho Chehab 0 == dvb_usb_device_init(intf, &tt_connect_s2_3600_properties, 1093786baecfSMauro Carvalho Chehab THIS_MODULE, NULL, adapter_nr)) 1094786baecfSMauro Carvalho Chehab return 0; 1095786baecfSMauro Carvalho Chehab 1096786baecfSMauro Carvalho Chehab return -ENODEV; 1097786baecfSMauro Carvalho Chehab } 1098786baecfSMauro Carvalho Chehab 1099786baecfSMauro Carvalho Chehab static struct usb_driver pctv452e_usb_driver = { 1100786baecfSMauro Carvalho Chehab .name = "pctv452e", 1101786baecfSMauro Carvalho Chehab .probe = pctv452e_usb_probe, 1102786baecfSMauro Carvalho Chehab .disconnect = pctv452e_usb_disconnect, 1103786baecfSMauro Carvalho Chehab .id_table = pctv452e_usb_table, 1104786baecfSMauro Carvalho Chehab }; 1105786baecfSMauro Carvalho Chehab 1106786baecfSMauro Carvalho Chehab module_usb_driver(pctv452e_usb_driver); 1107786baecfSMauro Carvalho Chehab 1108786baecfSMauro Carvalho Chehab MODULE_AUTHOR("Dominik Kuhlen <dkuhlen@gmx.net>"); 1109786baecfSMauro Carvalho Chehab MODULE_AUTHOR("Andre Weidemann <Andre.Weidemann@web.de>"); 1110786baecfSMauro Carvalho Chehab MODULE_AUTHOR("Michael H. Schimek <mschimek@gmx.at>"); 1111786baecfSMauro Carvalho Chehab MODULE_DESCRIPTION("Pinnacle PCTV HDTV USB DVB / TT connect S2-3600 Driver"); 1112786baecfSMauro Carvalho Chehab MODULE_LICENSE("GPL"); 1113