^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* DVB USB compliant linux driver for Technotrend DVB USB boxes and clones
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * (e.g. Pinnacle 400e DVB-S USB2.0).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * The Pinnacle 400e uses the same protocol as the Technotrend USB1.1 boxes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * TDA8263 + TDA10086
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * I2C addresses:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * 0x08 - LNBP21PD - LNB power supply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * 0x0e - TDA10086 - Demodulator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * 0x50 - FX2 eeprom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * 0x60 - TDA8263 - Tuner
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * 0x78 ???
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Copyright (c) 2002 Holger Waechtler <holger@convergence.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Copyright (c) 2003 Felix Domke <tmbinc@elitedvb.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Copyright (C) 2005-6 Patrick Boettcher <pb@linuxtv.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define DVB_USB_LOG_PREFIX "ttusb2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "dvb-usb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include "ttusb2.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include "tda826x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include "tda10086.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "tda1002x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include "tda10048.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include "tda827x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include "lnbp21.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* CA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <media/dvb_ca_en50221.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* debug */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static int dvb_usb_ttusb2_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define deb_info(args...) dprintk(dvb_usb_ttusb2_debug,0x01,args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) module_param_named(debug,dvb_usb_ttusb2_debug, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))." DVB_USB_DEBUG_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static int dvb_usb_ttusb2_debug_ci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) module_param_named(debug_ci,dvb_usb_ttusb2_debug_ci, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) MODULE_PARM_DESC(debug_ci, "set debugging ci." DVB_USB_DEBUG_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define ci_dbg(format, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) if (dvb_usb_ttusb2_debug_ci) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) printk(KERN_DEBUG DVB_USB_LOG_PREFIX \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ": %s " format "\n" , __func__, ## arg); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) TT3650_CMD_CI_TEST = 0x40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) TT3650_CMD_CI_RD_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) TT3650_CMD_CI_WR_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) TT3650_CMD_CI_RD_ATTR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) TT3650_CMD_CI_WR_ATTR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) TT3650_CMD_CI_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) TT3650_CMD_CI_SET_VIDEO_PORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct ttusb2_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct dvb_ca_en50221 ca;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct mutex ca_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u8 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u16 last_rc_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static int ttusb2_msg(struct dvb_usb_device *d, u8 cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u8 *wbuf, int wlen, u8 *rbuf, int rlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct ttusb2_state *st = d->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u8 *s, *r = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) if (4 + rlen > 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) s = kzalloc(wlen+4, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if (!s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) r = kzalloc(64, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) if (!r) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) kfree(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) s[0] = 0xaa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) s[1] = ++st->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) s[2] = cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) s[3] = wlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) memcpy(&s[4],wbuf,wlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ret = dvb_usb_generic_rw(d, s, wlen+4, r, 64, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (ret != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) r[0] != 0x55 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) r[1] != s[1] ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) r[2] != cmd ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) (rlen > 0 && r[3] != rlen)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) warn("there might have been an error during control message transfer. (rlen = %d, was %d)",rlen,r[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) kfree(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) kfree(r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (rlen > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) memcpy(rbuf, &r[4], rlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) kfree(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) kfree(r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /* ci */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static int tt3650_ci_msg(struct dvb_usb_device *d, u8 cmd, u8 *data, unsigned int write_len, unsigned int read_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) u8 rx[60];/* (64 -4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ret = ttusb2_msg(d, cmd, data, write_len, rx, read_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) memcpy(data, rx, read_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static int tt3650_ci_msg_locked(struct dvb_ca_en50221 *ca, u8 cmd, u8 *data, unsigned int write_len, unsigned int read_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct dvb_usb_device *d = ca->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct ttusb2_state *state = d->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) mutex_lock(&state->ca_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) ret = tt3650_ci_msg(d, cmd, data, write_len, read_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) mutex_unlock(&state->ca_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int tt3650_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) u8 buf[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) buf[0] = (address >> 8) & 0x0F;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) buf[1] = address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_RD_ATTR, buf, 2, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) ci_dbg("%04x -> %d 0x%02x", address, ret, buf[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) return buf[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static int tt3650_ci_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) u8 buf[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ci_dbg("%d 0x%04x 0x%02x", slot, address, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) buf[0] = (address >> 8) & 0x0F;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) buf[1] = address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) buf[2] = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return tt3650_ci_msg_locked(ca, TT3650_CMD_CI_WR_ATTR, buf, 3, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static int tt3650_ci_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) u8 buf[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) buf[0] = address & 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_RD_CTRL, buf, 1, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) ci_dbg("0x%02x -> %d 0x%02x", address, ret, buf[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) return buf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static int tt3650_ci_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) u8 buf[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) ci_dbg("%d 0x%02x 0x%02x", slot, address, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) buf[0] = address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) buf[1] = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) return tt3650_ci_msg_locked(ca, TT3650_CMD_CI_WR_CTRL, buf, 2, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static int tt3650_ci_set_video_port(struct dvb_ca_en50221 *ca, int slot, int enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) u8 buf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) ci_dbg("%d %d", slot, enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) buf[0] = enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_SET_VIDEO_PORT, buf, 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) if (enable != buf[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) err("CI not %sabled.", enable ? "en" : "dis");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static int tt3650_ci_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return tt3650_ci_set_video_port(ca, slot, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static int tt3650_ci_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) return tt3650_ci_set_video_port(ca, slot, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static int tt3650_ci_slot_reset(struct dvb_ca_en50221 *ca, int slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) struct dvb_usb_device *d = ca->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) struct ttusb2_state *state = d->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) u8 buf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ci_dbg("%d", slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) if (slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) buf[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) mutex_lock(&state->ca_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) ret = tt3650_ci_msg(d, TT3650_CMD_CI_RESET, buf, 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) goto failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) msleep(500);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) buf[0] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) ret = tt3650_ci_msg(d, TT3650_CMD_CI_RESET, buf, 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) goto failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) msleep(500);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) buf[0] = 0; /* FTA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) ret = tt3650_ci_msg(d, TT3650_CMD_CI_SET_VIDEO_PORT, buf, 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) msleep(1100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) failed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) mutex_unlock(&state->ca_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) static int tt3650_ci_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) u8 buf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) if (slot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_TEST, buf, 0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) if (1 == buf[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) return DVB_CA_EN50221_POLL_CAM_PRESENT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) DVB_CA_EN50221_POLL_CAM_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) static void tt3650_ci_uninit(struct dvb_usb_device *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) struct ttusb2_state *state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) ci_dbg("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) if (NULL == d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) state = d->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) if (NULL == state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) if (NULL == state->ca.data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) dvb_ca_en50221_release(&state->ca);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) memset(&state->ca, 0, sizeof(state->ca));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) static int tt3650_ci_init(struct dvb_usb_adapter *a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) struct dvb_usb_device *d = a->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) struct ttusb2_state *state = d->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) ci_dbg("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) mutex_init(&state->ca_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) state->ca.owner = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) state->ca.read_attribute_mem = tt3650_ci_read_attribute_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) state->ca.write_attribute_mem = tt3650_ci_write_attribute_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) state->ca.read_cam_control = tt3650_ci_read_cam_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) state->ca.write_cam_control = tt3650_ci_write_cam_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) state->ca.slot_reset = tt3650_ci_slot_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) state->ca.slot_shutdown = tt3650_ci_slot_shutdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) state->ca.slot_ts_enable = tt3650_ci_slot_ts_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) state->ca.poll_slot_status = tt3650_ci_poll_slot_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) state->ca.data = d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) ret = dvb_ca_en50221_init(&a->dvb_adap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) &state->ca,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) /* flags */ 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) /* n_slots */ 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) err("Cannot initialize CI: Error %d.", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) memset(&state->ca, 0, sizeof(state->ca));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) info("CI initialized.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) static int ttusb2_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) struct dvb_usb_device *d = i2c_get_adapdata(adap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) static u8 obuf[60], ibuf[60];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) int i, write_read, read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) if (num > 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) warn("more than 2 i2c messages at a time is not handled yet. TODO.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) for (i = 0; i < num; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) write_read = i+1 < num && (msg[i+1].flags & I2C_M_RD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) read = msg[i].flags & I2C_M_RD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) if (3 + msg[i].len > sizeof(obuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) err("i2c wr len=%d too high", msg[i].len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) if (write_read) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) if (3 + msg[i+1].len > sizeof(ibuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) err("i2c rd len=%d too high", msg[i+1].len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) } else if (read) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) if (3 + msg[i].len > sizeof(ibuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) err("i2c rd len=%d too high", msg[i].len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) obuf[0] = (msg[i].addr << 1) | (write_read | read);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) if (read)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) obuf[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) obuf[1] = msg[i].len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) /* read request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) if (write_read)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) obuf[2] = msg[i+1].len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) else if (read)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) obuf[2] = msg[i].len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) obuf[2] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) memcpy(&obuf[3], msg[i].buf, msg[i].len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) if (ttusb2_msg(d, CMD_I2C_XFER, obuf, obuf[1]+3, ibuf, obuf[2] + 3) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) err("i2c transfer failed.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) if (write_read) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) memcpy(msg[i+1].buf, &ibuf[3], msg[i+1].len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) } else if (read)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) memcpy(msg[i].buf, &ibuf[3], msg[i].len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) mutex_unlock(&d->i2c_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) static u32 ttusb2_i2c_func(struct i2c_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) return I2C_FUNC_I2C;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) static struct i2c_algorithm ttusb2_i2c_algo = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) .master_xfer = ttusb2_i2c_xfer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) .functionality = ttusb2_i2c_func,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) /* command to poll IR receiver (copied from pctv452e.c) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) #define CMD_GET_IR_CODE 0x1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) /* IR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) static int tt3650_rc_query(struct dvb_usb_device *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) u8 rx[9]; /* A CMD_GET_IR_CODE reply is 9 bytes long */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) struct ttusb2_state *st = d->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) ret = ttusb2_msg(d, CMD_GET_IR_CODE, NULL, 0, rx, sizeof(rx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) if (rx[8] & 0x01) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) /* got a "press" event */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) st->last_rc_key = RC_SCANCODE_RC5(rx[3], rx[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) rc_keydown(d->rc_dev, RC_PROTO_RC5, st->last_rc_key, rx[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) } else if (st->last_rc_key) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) rc_keyup(d->rc_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) st->last_rc_key = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) /* Callbacks for DVB USB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) static int ttusb2_identify_state(struct usb_device *udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) const struct dvb_usb_device_properties *props,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) const struct dvb_usb_device_description **desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) int *cold)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) *cold = udev->descriptor.iManufacturer == 0 && udev->descriptor.iProduct == 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) static int ttusb2_power_ctrl(struct dvb_usb_device *d, int onoff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) u8 b = onoff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) ttusb2_msg(d, CMD_POWER, &b, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) return ttusb2_msg(d, CMD_POWER, &b, 1, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) static struct tda10086_config tda10086_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) .demod_address = 0x0e,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) .invert = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) .diseqc_tone = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) .xtal_freq = TDA10086_XTAL_16M,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) static struct tda10023_config tda10023_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) .demod_address = 0x0c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) .invert = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) .xtal = 16000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) .pll_m = 11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) .pll_p = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) .pll_n = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) .deltaf = 0xa511,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) static struct tda10048_config tda10048_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) .demod_address = 0x10 >> 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) .output_mode = TDA10048_PARALLEL_OUTPUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) .inversion = TDA10048_INVERSION_ON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) .dtv6_if_freq_khz = TDA10048_IF_4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) .dtv7_if_freq_khz = TDA10048_IF_4500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) .dtv8_if_freq_khz = TDA10048_IF_5000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) .clk_freq_khz = TDA10048_CLK_16000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) .no_firmware = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) .set_pll = true ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) .pll_m = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) .pll_n = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) .pll_p = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) static struct tda827x_config tda827x_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) .config = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) static int ttusb2_frontend_tda10086_attach(struct dvb_usb_adapter *adap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) if (usb_set_interface(adap->dev->udev,0,3) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) err("set interface to alts=3 failed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) if ((adap->fe_adap[0].fe = dvb_attach(tda10086_attach, &tda10086_config, &adap->dev->i2c_adap)) == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) deb_info("TDA10086 attach failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) static int ttusb2_ct3650_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) struct dvb_usb_adapter *adap = fe->dvb->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) return adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) static int ttusb2_frontend_tda10023_attach(struct dvb_usb_adapter *adap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) if (usb_set_interface(adap->dev->udev, 0, 3) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) err("set interface to alts=3 failed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) if (adap->fe_adap[0].fe == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) /* FE 0 DVB-C */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) adap->fe_adap[0].fe = dvb_attach(tda10023_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) &tda10023_config, &adap->dev->i2c_adap, 0x48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) if (adap->fe_adap[0].fe == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) deb_info("TDA10023 attach failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) tt3650_ci_init(adap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) adap->fe_adap[1].fe = dvb_attach(tda10048_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) &tda10048_config, &adap->dev->i2c_adap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) if (adap->fe_adap[1].fe == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) deb_info("TDA10048 attach failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) /* tuner is behind TDA10023 I2C-gate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) adap->fe_adap[1].fe->ops.i2c_gate_ctrl = ttusb2_ct3650_i2c_gate_ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) static int ttusb2_tuner_tda827x_attach(struct dvb_usb_adapter *adap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) struct dvb_frontend *fe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) /* MFE: select correct FE to attach tuner since that's called twice */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) if (adap->fe_adap[1].fe == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) fe = adap->fe_adap[0].fe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) fe = adap->fe_adap[1].fe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) /* attach tuner */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) if (dvb_attach(tda827x_attach, fe, 0x61, &adap->dev->i2c_adap, &tda827x_config) == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) printk(KERN_ERR "%s: No tda827x found!\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) static int ttusb2_tuner_tda826x_attach(struct dvb_usb_adapter *adap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) if (dvb_attach(tda826x_attach, adap->fe_adap[0].fe, 0x60, &adap->dev->i2c_adap, 0) == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) deb_info("TDA8263 attach failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) if (dvb_attach(lnbp21_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, 0, 0) == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) deb_info("LNBP21 attach failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) /* DVB USB Driver stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) static struct dvb_usb_device_properties ttusb2_properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) static struct dvb_usb_device_properties ttusb2_properties_s2400;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) static struct dvb_usb_device_properties ttusb2_properties_ct3650;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) static void ttusb2_usb_disconnect(struct usb_interface *intf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) struct dvb_usb_device *d = usb_get_intfdata(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) tt3650_ci_uninit(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) dvb_usb_device_exit(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) static int ttusb2_probe(struct usb_interface *intf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) const struct usb_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) if (0 == dvb_usb_device_init(intf, &ttusb2_properties,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) THIS_MODULE, NULL, adapter_nr) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 0 == dvb_usb_device_init(intf, &ttusb2_properties_s2400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) THIS_MODULE, NULL, adapter_nr) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 0 == dvb_usb_device_init(intf, &ttusb2_properties_ct3650,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) THIS_MODULE, NULL, adapter_nr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) static struct usb_device_id ttusb2_table [] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_400E) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_450E) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) { USB_DEVICE(USB_VID_TECHNOTREND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) USB_PID_TECHNOTREND_CONNECT_S2400) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) { USB_DEVICE(USB_VID_TECHNOTREND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) USB_PID_TECHNOTREND_CONNECT_CT3650) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) { USB_DEVICE(USB_VID_TECHNOTREND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) {} /* Terminating entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) MODULE_DEVICE_TABLE (usb, ttusb2_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) static struct dvb_usb_device_properties ttusb2_properties = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) .caps = DVB_USB_IS_AN_I2C_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) .usb_ctrl = CYPRESS_FX2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) .firmware = "dvb-usb-pctv-400e-01.fw",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) .size_of_priv = sizeof(struct ttusb2_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) .num_adapters = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) .adapter = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) .num_frontends = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) .fe = {{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) .streaming_ctrl = NULL, // ttusb2_streaming_ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) .frontend_attach = ttusb2_frontend_tda10086_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) .tuner_attach = ttusb2_tuner_tda826x_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) /* parameter for the MPEG2-data transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) .stream = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) .type = USB_ISOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) .count = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) .endpoint = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) .u = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) .isoc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) .framesperurb = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) .framesize = 940,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) .interval = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) }},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) .power_ctrl = ttusb2_power_ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) .identify_state = ttusb2_identify_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) .i2c_algo = &ttusb2_i2c_algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) .generic_bulk_ctrl_endpoint = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) .num_device_descs = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) .devices = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) { "Pinnacle 400e DVB-S USB2.0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) { &ttusb2_table[0], NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) { NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) { "Pinnacle 450e DVB-S USB2.0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) { &ttusb2_table[1], NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) { NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) static struct dvb_usb_device_properties ttusb2_properties_s2400 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) .caps = DVB_USB_IS_AN_I2C_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) .usb_ctrl = CYPRESS_FX2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) .firmware = "dvb-usb-tt-s2400-01.fw",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) .size_of_priv = sizeof(struct ttusb2_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) .num_adapters = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) .adapter = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) .num_frontends = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) .fe = {{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) .streaming_ctrl = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) .frontend_attach = ttusb2_frontend_tda10086_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) .tuner_attach = ttusb2_tuner_tda826x_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) /* parameter for the MPEG2-data transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) .stream = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) .type = USB_ISOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) .count = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) .endpoint = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) .u = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) .isoc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) .framesperurb = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) .framesize = 940,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) .interval = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) }},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) .power_ctrl = ttusb2_power_ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) .identify_state = ttusb2_identify_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) .i2c_algo = &ttusb2_i2c_algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) .generic_bulk_ctrl_endpoint = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) .num_device_descs = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) .devices = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) { "Technotrend TT-connect S-2400",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) { &ttusb2_table[2], NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) { NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) { "Technotrend TT-connect S-2400 (8kB EEPROM)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) { &ttusb2_table[4], NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) { NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) static struct dvb_usb_device_properties ttusb2_properties_ct3650 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) .caps = DVB_USB_IS_AN_I2C_ADAPTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) .usb_ctrl = CYPRESS_FX2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) .size_of_priv = sizeof(struct ttusb2_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) .rc.core = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) .rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) .rc_codes = RC_MAP_TT_1500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) .rc_query = tt3650_rc_query,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) .allowed_protos = RC_PROTO_BIT_RC5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) .num_adapters = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) .adapter = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) .num_frontends = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) .fe = {{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) .streaming_ctrl = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) .frontend_attach = ttusb2_frontend_tda10023_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) .tuner_attach = ttusb2_tuner_tda827x_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) /* parameter for the MPEG2-data transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) .stream = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) .type = USB_ISOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) .count = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) .endpoint = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) .u = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) .isoc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) .framesperurb = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) .framesize = 940,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) .interval = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) .streaming_ctrl = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) .frontend_attach = ttusb2_frontend_tda10023_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) .tuner_attach = ttusb2_tuner_tda827x_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) /* parameter for the MPEG2-data transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) .stream = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) .type = USB_ISOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) .count = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) .endpoint = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) .u = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) .isoc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) .framesperurb = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) .framesize = 940,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) .interval = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) }},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) .power_ctrl = ttusb2_power_ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) .identify_state = ttusb2_identify_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) .i2c_algo = &ttusb2_i2c_algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) .generic_bulk_ctrl_endpoint = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) .num_device_descs = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) .devices = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) { "Technotrend TT-connect CT-3650",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) .warm_ids = { &ttusb2_table[3], NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) static struct usb_driver ttusb2_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) .name = "dvb_usb_ttusb2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) .probe = ttusb2_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) .disconnect = ttusb2_usb_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) .id_table = ttusb2_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) module_usb_driver(ttusb2_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) MODULE_DESCRIPTION("Driver for Pinnacle PCTV 400e DVB-S USB2.0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) MODULE_VERSION("1.0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) MODULE_LICENSE("GPL");