From d1872674e76b74a2d0689b0db78239446d45a819 Mon Sep 17 00:00:00 2001 From: CrazyCat Date: Sat, 20 Sep 2014 19:21:05 +0300 Subject: [PATCH 2/2] dvb-usb: dw2102: Geniatech T220A support. Cc: Linux Media Mailing List Signed-off-by: CrazyCat --- drivers/media/usb/dvb-usb/dw2102.c | 109 ++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c index 1a3df10..a33d920 100644 --- a/drivers/media/usb/dvb-usb/dw2102.c +++ b/drivers/media/usb/dvb-usb/dw2102.c @@ -2,8 +2,9 @@ * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, * TeVii S600, S630, S650, S660, S480, S421, S632 * Prof 1100, 7500, - * Geniatech SU3000, T220 Cards + * Geniatech SU3000, T220, T220A Cards * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by) + * (C) 2013-2014 CrazyCat (crazycat69@narod.ru) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -30,6 +31,7 @@ #include "stb6100_proc.h" #include "m88rs2000.h" #include "tda18271.h" +#include "tda18273.h" #include "cxd2820r.h" /* Max transfer size done by I2C transfer functions */ @@ -1436,6 +1438,56 @@ static int t220_frontend_attach(struct dvb_usb_adapter *d) return -EIO; } +static int t220a_frontend_attach(struct dvb_usb_adapter *d) +{ + u8 obuf[3] = { 0xe, 0x87, 0 }; + u8 ibuf[] = { 0 }; + + if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) + err("command 0x0e transfer failed."); + + obuf[0] = 0xe; + obuf[1] = 0x86; + obuf[2] = 1; + + if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) + err("command 0x0e transfer failed."); + + obuf[0] = 0xe; + obuf[1] = 0x80; + obuf[2] = 0; + + if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) + err("command 0x0e transfer failed."); + + msleep(50); + + obuf[0] = 0xe; + obuf[1] = 0x80; + obuf[2] = 1; + + if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) + err("command 0x0e transfer failed."); + + obuf[0] = 0x51; + + if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) + err("command 0x51 transfer failed."); + + d->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config, + &d->dev->i2c_adap, NULL); + if (d->fe_adap[0].fe != NULL) { + if (dvb_attach(tda18273_attach, d->fe_adap[0].fe, + &d->dev->i2c_adap, 0x60)) { + info("Attached TDA18273/CXD2820R!\n"); + return 0; + } + } + + info("Failed to attach TDA18273/CXD2820R!\n"); + return -EIO; +} + static int m88rs2000_frontend_attach(struct dvb_usb_adapter *d) { u8 obuf[] = { 0x51 }; @@ -1561,6 +1613,7 @@ enum dw2102_table_entry { TERRATEC_CINERGY_S2_R2, GOTVIEW_SAT_HD, GENIATECH_T220, + GENIATECH_T220A, }; static struct usb_device_id dw2102_table[] = { @@ -1584,6 +1637,7 @@ static struct usb_device_id dw2102_table[] = { [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00b0)}, [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)}, [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)}, + [GENIATECH_T220A] = {USB_DEVICE(0x0572, 0xC686)}, { } }; @@ -2061,6 +2115,55 @@ static struct dvb_usb_device_properties t220_properties = { } }; +static struct dvb_usb_device_properties t220a_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, + .usb_ctrl = DEVICE_SPECIFIC, + .size_of_priv = sizeof(struct su3000_state), + .power_ctrl = su3000_power_ctrl, + .num_adapters = 1, + .identify_state = su3000_identify_state, + .i2c_algo = &su3000_i2c_algo, + + .rc.core = { + .rc_interval = 150, + .rc_codes = RC_MAP_SU3000, + .module_name = "dw2102", + .allowed_protos = RC_BIT_RC5, + .rc_query = su3000_rc_query, + }, + + .read_mac_address = su3000_read_mac_address, + + .generic_bulk_ctrl_endpoint = 0x01, + + .adapter = { + { + .num_frontends = 1, + .fe = { { + .streaming_ctrl = su3000_streaming_ctrl, + .frontend_attach = t220a_frontend_attach, + .stream = { + .type = USB_BULK, + .count = 8, + .endpoint = 0x82, + .u = { + .bulk = { + .buffersize = 4096, + } + } + } + } }, + } + }, + .num_device_descs = 1, + .devices = { + { "Geniatech T220A DVB-T/T2 USB2.0", + { &dw2102_table[GENIATECH_T220A], NULL }, + { NULL }, + }, + } +}; + static int dw2102_probe(struct usb_interface *intf, const struct usb_device_id *id) { @@ -2135,6 +2238,8 @@ static int dw2102_probe(struct usb_interface *intf, 0 == dvb_usb_device_init(intf, &su3000_properties, THIS_MODULE, NULL, adapter_nr) || 0 == dvb_usb_device_init(intf, &t220_properties, + THIS_MODULE, NULL, adapter_nr) || + 0 == dvb_usb_device_init(intf, &t220a_properties, THIS_MODULE, NULL, adapter_nr)) return 0; @@ -2155,7 +2260,7 @@ MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," " DVB-C 3101 USB2.0," " TeVii S600, S630, S650, S660, S480, S421, S632" " Prof 1100, 7500 USB2.0," - " Geniatech SU3000, T220 devices"); + " Geniatech SU3000, T220, T220A devices"); MODULE_VERSION("0.1"); MODULE_LICENSE("GPL"); MODULE_FIRMWARE(DW2101_FIRMWARE); -- 1.9.1