10c0d06caSMauro Carvalho Chehab /* 20c0d06caSMauro Carvalho Chehab DVB device driver for em28xx 30c0d06caSMauro Carvalho Chehab 40c0d06caSMauro Carvalho Chehab (c) 2008-2011 Mauro Carvalho Chehab <mchehab@infradead.org> 50c0d06caSMauro Carvalho Chehab 60c0d06caSMauro Carvalho Chehab (c) 2008 Devin Heitmueller <devin.heitmueller@gmail.com> 70c0d06caSMauro Carvalho Chehab - Fixes for the driver to properly work with HVR-950 80c0d06caSMauro Carvalho Chehab - Fixes for the driver to properly work with Pinnacle PCTV HD Pro Stick 90c0d06caSMauro Carvalho Chehab - Fixes for the driver to properly work with AMD ATI TV Wonder HD 600 100c0d06caSMauro Carvalho Chehab 110c0d06caSMauro Carvalho Chehab (c) 2008 Aidan Thornton <makosoft@googlemail.com> 120c0d06caSMauro Carvalho Chehab 13a950e4a7SFrank Schaefer (c) 2012 Frank Schäfer <fschaefer.oss@googlemail.com> 14a950e4a7SFrank Schaefer 150c0d06caSMauro Carvalho Chehab Based on cx88-dvb, saa7134-dvb and videobuf-dvb originally written by: 160c0d06caSMauro Carvalho Chehab (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> 170c0d06caSMauro Carvalho Chehab (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] 180c0d06caSMauro Carvalho Chehab 190c0d06caSMauro Carvalho Chehab This program is free software; you can redistribute it and/or modify 200c0d06caSMauro Carvalho Chehab it under the terms of the GNU General Public License as published by 210c0d06caSMauro Carvalho Chehab the Free Software Foundation; either version 2 of the License. 220c0d06caSMauro Carvalho Chehab */ 230c0d06caSMauro Carvalho Chehab 248314d402SMauro Carvalho Chehab #include "em28xx.h" 258314d402SMauro Carvalho Chehab 260c0d06caSMauro Carvalho Chehab #include <linux/kernel.h> 270c0d06caSMauro Carvalho Chehab #include <linux/slab.h> 280c0d06caSMauro Carvalho Chehab #include <linux/usb.h> 290c0d06caSMauro Carvalho Chehab 300c0d06caSMauro Carvalho Chehab #include <media/v4l2-common.h> 31fada1935SMauro Carvalho Chehab #include <media/dvb_demux.h> 32fada1935SMauro Carvalho Chehab #include <media/dvb_net.h> 33fada1935SMauro Carvalho Chehab #include <media/dmxdev.h> 340c0d06caSMauro Carvalho Chehab #include <media/tuner.h> 350c0d06caSMauro Carvalho Chehab #include "tuner-simple.h" 361e8f31f3SAntti Palosaari #include <linux/gpio.h> 370c0d06caSMauro Carvalho Chehab 380c0d06caSMauro Carvalho Chehab #include "lgdt330x.h" 390c0d06caSMauro Carvalho Chehab #include "lgdt3305.h" 401586342eSKevin Cheng #include "lgdt3306a.h" 410c0d06caSMauro Carvalho Chehab #include "zl10353.h" 420c0d06caSMauro Carvalho Chehab #include "s5h1409.h" 438c47311dSAlberto Mardegan #include "mt2060.h" 440c0d06caSMauro Carvalho Chehab #include "mt352.h" 450c0d06caSMauro Carvalho Chehab #include "mt352_priv.h" /* FIXME */ 460c0d06caSMauro Carvalho Chehab #include "tda1002x.h" 4738b2df95SDevin Heitmueller #include "drx39xyj/drx39xxj.h" 480c0d06caSMauro Carvalho Chehab #include "tda18271.h" 490c0d06caSMauro Carvalho Chehab #include "s921.h" 500c0d06caSMauro Carvalho Chehab #include "drxd.h" 510c0d06caSMauro Carvalho Chehab #include "cxd2820r.h" 520c0d06caSMauro Carvalho Chehab #include "tda18271c2dd.h" 530c0d06caSMauro Carvalho Chehab #include "drxk.h" 540c0d06caSMauro Carvalho Chehab #include "tda10071.h" 5502bc1f55SMauro Carvalho Chehab #include "tda18212.h" 560c0d06caSMauro Carvalho Chehab #include "a8293.h" 570c0d06caSMauro Carvalho Chehab #include "qt1010.h" 584159d01bSMauro Carvalho Chehab #include "mb86a20s.h" 59ec573362SAntti Palosaari #include "m88ds3103.h" 6083c1b6ceSAntti Palosaari #include "ts2020.h" 6119229240SAntti Palosaari #include "si2168.h" 6219229240SAntti Palosaari #include "si2157.h" 63ab4d1452SSatoshi Nagahama #include "tc90522.h" 64ab4d1452SSatoshi Nagahama #include "qm1d1c0042.h" 650c0d06caSMauro Carvalho Chehab 660c0d06caSMauro Carvalho Chehab MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); 670c0d06caSMauro Carvalho Chehab MODULE_LICENSE("GPL"); 68d8992b09SMauro Carvalho Chehab MODULE_DESCRIPTION(DRIVER_DESC " - digital TV interface"); 69d8992b09SMauro Carvalho Chehab MODULE_VERSION(EM28XX_VERSION); 70d8992b09SMauro Carvalho Chehab 710c0d06caSMauro Carvalho Chehab static unsigned int debug; 720c0d06caSMauro Carvalho Chehab module_param(debug, int, 0644); 730c0d06caSMauro Carvalho Chehab MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); 740c0d06caSMauro Carvalho Chehab 750c0d06caSMauro Carvalho Chehab DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 760c0d06caSMauro Carvalho Chehab 770c0d06caSMauro Carvalho Chehab #define dprintk(level, fmt, arg...) do { \ 780c0d06caSMauro Carvalho Chehab if (debug >= level) \ 7929b05e22SMauro Carvalho Chehab dev_printk(KERN_DEBUG, &dev->intf->dev, \ 80ce8591ffSMauro Carvalho Chehab "dvb: " fmt, ## arg); \ 810c0d06caSMauro Carvalho Chehab } while (0) 820c0d06caSMauro Carvalho Chehab 830c0d06caSMauro Carvalho Chehab struct em28xx_dvb { 840c0d06caSMauro Carvalho Chehab struct dvb_frontend *fe[2]; 850c0d06caSMauro Carvalho Chehab 860c0d06caSMauro Carvalho Chehab /* feed count management */ 870c0d06caSMauro Carvalho Chehab struct mutex lock; 880c0d06caSMauro Carvalho Chehab int nfeeds; 890c0d06caSMauro Carvalho Chehab 900c0d06caSMauro Carvalho Chehab /* general boilerplate stuff */ 910c0d06caSMauro Carvalho Chehab struct dvb_adapter adapter; 920c0d06caSMauro Carvalho Chehab struct dvb_demux demux; 930c0d06caSMauro Carvalho Chehab struct dmxdev dmxdev; 940c0d06caSMauro Carvalho Chehab struct dmx_frontend fe_hw; 950c0d06caSMauro Carvalho Chehab struct dmx_frontend fe_mem; 960c0d06caSMauro Carvalho Chehab struct dvb_net net; 970c0d06caSMauro Carvalho Chehab 980c0d06caSMauro Carvalho Chehab /* Due to DRX-K - probably need changes */ 990c0d06caSMauro Carvalho Chehab int (*gate_ctrl)(struct dvb_frontend *, int); 1000c0d06caSMauro Carvalho Chehab struct semaphore pll_mutex; 1010c0d06caSMauro Carvalho Chehab bool dont_attach_fe1; 10213a5336eSAntti Palosaari int lna_gpio; 10319229240SAntti Palosaari struct i2c_client *i2c_client_demod; 104eafa2ad6SAntti Palosaari struct i2c_client *i2c_client_tuner; 1057098f582SAntti Palosaari struct i2c_client *i2c_client_sec; 1060c0d06caSMauro Carvalho Chehab }; 1070c0d06caSMauro Carvalho Chehab 1080c0d06caSMauro Carvalho Chehab static inline void print_err_status(struct em28xx *dev, 1090c0d06caSMauro Carvalho Chehab int packet, int status) 1100c0d06caSMauro Carvalho Chehab { 1110c0d06caSMauro Carvalho Chehab char *errmsg = "Unknown"; 1120c0d06caSMauro Carvalho Chehab 1130c0d06caSMauro Carvalho Chehab switch (status) { 1140c0d06caSMauro Carvalho Chehab case -ENOENT: 115b436e26eSColin Ian King errmsg = "unlinked synchronously"; 1160c0d06caSMauro Carvalho Chehab break; 1170c0d06caSMauro Carvalho Chehab case -ECONNRESET: 118b436e26eSColin Ian King errmsg = "unlinked asynchronously"; 1190c0d06caSMauro Carvalho Chehab break; 1200c0d06caSMauro Carvalho Chehab case -ENOSR: 1210c0d06caSMauro Carvalho Chehab errmsg = "Buffer error (overrun)"; 1220c0d06caSMauro Carvalho Chehab break; 1230c0d06caSMauro Carvalho Chehab case -EPIPE: 1240c0d06caSMauro Carvalho Chehab errmsg = "Stalled (device not responding)"; 1250c0d06caSMauro Carvalho Chehab break; 1260c0d06caSMauro Carvalho Chehab case -EOVERFLOW: 1270c0d06caSMauro Carvalho Chehab errmsg = "Babble (bad cable?)"; 1280c0d06caSMauro Carvalho Chehab break; 1290c0d06caSMauro Carvalho Chehab case -EPROTO: 1300c0d06caSMauro Carvalho Chehab errmsg = "Bit-stuff error (bad cable?)"; 1310c0d06caSMauro Carvalho Chehab break; 1320c0d06caSMauro Carvalho Chehab case -EILSEQ: 1330c0d06caSMauro Carvalho Chehab errmsg = "CRC/Timeout (could be anything)"; 1340c0d06caSMauro Carvalho Chehab break; 1350c0d06caSMauro Carvalho Chehab case -ETIME: 1360c0d06caSMauro Carvalho Chehab errmsg = "Device does not respond"; 1370c0d06caSMauro Carvalho Chehab break; 1380c0d06caSMauro Carvalho Chehab } 1390c0d06caSMauro Carvalho Chehab if (packet < 0) { 1400c0d06caSMauro Carvalho Chehab dprintk(1, "URB status %d [%s].\n", status, errmsg); 1410c0d06caSMauro Carvalho Chehab } else { 1420c0d06caSMauro Carvalho Chehab dprintk(1, "URB packet %d, status %d [%s].\n", 1430c0d06caSMauro Carvalho Chehab packet, status, errmsg); 1440c0d06caSMauro Carvalho Chehab } 1450c0d06caSMauro Carvalho Chehab } 1460c0d06caSMauro Carvalho Chehab 147a950e4a7SFrank Schaefer static inline int em28xx_dvb_urb_data_copy(struct em28xx *dev, struct urb *urb) 1480c0d06caSMauro Carvalho Chehab { 149a950e4a7SFrank Schaefer int xfer_bulk, num_packets, i; 1500c0d06caSMauro Carvalho Chehab 1510c0d06caSMauro Carvalho Chehab if (!dev) 1520c0d06caSMauro Carvalho Chehab return 0; 1530c0d06caSMauro Carvalho Chehab 1542665c299SFrank Schaefer if (dev->disconnected) 1550c0d06caSMauro Carvalho Chehab return 0; 1560c0d06caSMauro Carvalho Chehab 1571653cb0cSFrank Schaefer if (urb->status < 0) 1580c0d06caSMauro Carvalho Chehab print_err_status(dev, -1, urb->status); 1590c0d06caSMauro Carvalho Chehab 160a950e4a7SFrank Schaefer xfer_bulk = usb_pipebulk(urb->pipe); 1610c0d06caSMauro Carvalho Chehab 162a950e4a7SFrank Schaefer if (xfer_bulk) /* bulk */ 163a950e4a7SFrank Schaefer num_packets = 1; 164a950e4a7SFrank Schaefer else /* isoc */ 165a950e4a7SFrank Schaefer num_packets = urb->number_of_packets; 166a950e4a7SFrank Schaefer 167a950e4a7SFrank Schaefer for (i = 0; i < num_packets; i++) { 168a950e4a7SFrank Schaefer if (xfer_bulk) { 169a950e4a7SFrank Schaefer if (urb->status < 0) { 170a950e4a7SFrank Schaefer print_err_status(dev, i, urb->status); 171a950e4a7SFrank Schaefer if (urb->status != -EPROTO) 172a950e4a7SFrank Schaefer continue; 173a950e4a7SFrank Schaefer } 174ffdeca88SMauro Carvalho Chehab if (!urb->actual_length) 175ffdeca88SMauro Carvalho Chehab continue; 176a950e4a7SFrank Schaefer dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer, 177a950e4a7SFrank Schaefer urb->actual_length); 178a950e4a7SFrank Schaefer } else { 179a950e4a7SFrank Schaefer if (urb->iso_frame_desc[i].status < 0) { 180a950e4a7SFrank Schaefer print_err_status(dev, i, 181a950e4a7SFrank Schaefer urb->iso_frame_desc[i].status); 1820c0d06caSMauro Carvalho Chehab if (urb->iso_frame_desc[i].status != -EPROTO) 1830c0d06caSMauro Carvalho Chehab continue; 1840c0d06caSMauro Carvalho Chehab } 185ffdeca88SMauro Carvalho Chehab if (!urb->iso_frame_desc[i].actual_length) 186ffdeca88SMauro Carvalho Chehab continue; 187a950e4a7SFrank Schaefer dvb_dmx_swfilter(&dev->dvb->demux, 188a950e4a7SFrank Schaefer urb->transfer_buffer + 1890c0d06caSMauro Carvalho Chehab urb->iso_frame_desc[i].offset, 1900c0d06caSMauro Carvalho Chehab urb->iso_frame_desc[i].actual_length); 1910c0d06caSMauro Carvalho Chehab } 192a950e4a7SFrank Schaefer } 1930c0d06caSMauro Carvalho Chehab 1940c0d06caSMauro Carvalho Chehab return 0; 1950c0d06caSMauro Carvalho Chehab } 1960c0d06caSMauro Carvalho Chehab 1970c0d06caSMauro Carvalho Chehab static int em28xx_start_streaming(struct em28xx_dvb *dvb) 1980c0d06caSMauro Carvalho Chehab { 1990c0d06caSMauro Carvalho Chehab int rc; 2003de09fbbSHans Verkuil struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv; 2013de09fbbSHans Verkuil struct em28xx *dev = i2c_bus->dev; 202c647a91aSFrank Schaefer int dvb_max_packet_size, packet_multiplier, dvb_alt; 2030c0d06caSMauro Carvalho Chehab 204c647a91aSFrank Schaefer if (dev->dvb_xfer_bulk) { 205c647a91aSFrank Schaefer if (!dev->dvb_ep_bulk) 206c647a91aSFrank Schaefer return -ENODEV; 207c647a91aSFrank Schaefer dvb_max_packet_size = 512; /* USB 2.0 spec */ 208c647a91aSFrank Schaefer packet_multiplier = EM28XX_DVB_BULK_PACKET_MULTIPLIER; 209c647a91aSFrank Schaefer dvb_alt = 0; 210c647a91aSFrank Schaefer } else { /* isoc */ 211c647a91aSFrank Schaefer if (!dev->dvb_ep_isoc) 212c647a91aSFrank Schaefer return -ENODEV; 213c647a91aSFrank Schaefer dvb_max_packet_size = dev->dvb_max_pkt_size_isoc; 214c647a91aSFrank Schaefer if (dvb_max_packet_size < 0) 215c647a91aSFrank Schaefer return dvb_max_packet_size; 216c647a91aSFrank Schaefer packet_multiplier = EM28XX_DVB_NUM_ISOC_PACKETS; 217c647a91aSFrank Schaefer dvb_alt = dev->dvb_alt_isoc; 218c647a91aSFrank Schaefer } 219c647a91aSFrank Schaefer 2200c0d06caSMauro Carvalho Chehab rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); 2210c0d06caSMauro Carvalho Chehab if (rc < 0) 2220c0d06caSMauro Carvalho Chehab return rc; 2230c0d06caSMauro Carvalho Chehab 22452f7b00eSMauro Carvalho Chehab dprintk(1, "Using %d buffers each with %d x %d bytes, alternate %d\n", 2250c0d06caSMauro Carvalho Chehab EM28XX_DVB_NUM_BUFS, 226c647a91aSFrank Schaefer packet_multiplier, 22752f7b00eSMauro Carvalho Chehab dvb_max_packet_size, dvb_alt); 2280c0d06caSMauro Carvalho Chehab 229c647a91aSFrank Schaefer return em28xx_init_usb_xfer(dev, EM28XX_DIGITAL_MODE, 230c647a91aSFrank Schaefer dev->dvb_xfer_bulk, 231515688a8SFrank Schaefer EM28XX_DVB_NUM_BUFS, 232c647a91aSFrank Schaefer dvb_max_packet_size, 233c647a91aSFrank Schaefer packet_multiplier, 234a950e4a7SFrank Schaefer em28xx_dvb_urb_data_copy); 2350c0d06caSMauro Carvalho Chehab } 2360c0d06caSMauro Carvalho Chehab 2370c0d06caSMauro Carvalho Chehab static int em28xx_stop_streaming(struct em28xx_dvb *dvb) 2380c0d06caSMauro Carvalho Chehab { 2393de09fbbSHans Verkuil struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv; 2403de09fbbSHans Verkuil struct em28xx *dev = i2c_bus->dev; 2410c0d06caSMauro Carvalho Chehab 2420c0d06caSMauro Carvalho Chehab em28xx_stop_urbs(dev); 2430c0d06caSMauro Carvalho Chehab 2440c0d06caSMauro Carvalho Chehab return 0; 2450c0d06caSMauro Carvalho Chehab } 2460c0d06caSMauro Carvalho Chehab 2470c0d06caSMauro Carvalho Chehab static int em28xx_start_feed(struct dvb_demux_feed *feed) 2480c0d06caSMauro Carvalho Chehab { 2490c0d06caSMauro Carvalho Chehab struct dvb_demux *demux = feed->demux; 2500c0d06caSMauro Carvalho Chehab struct em28xx_dvb *dvb = demux->priv; 2510c0d06caSMauro Carvalho Chehab int rc, ret; 2520c0d06caSMauro Carvalho Chehab 2530c0d06caSMauro Carvalho Chehab if (!demux->dmx.frontend) 2540c0d06caSMauro Carvalho Chehab return -EINVAL; 2550c0d06caSMauro Carvalho Chehab 2560c0d06caSMauro Carvalho Chehab mutex_lock(&dvb->lock); 2570c0d06caSMauro Carvalho Chehab dvb->nfeeds++; 2580c0d06caSMauro Carvalho Chehab rc = dvb->nfeeds; 2590c0d06caSMauro Carvalho Chehab 2600c0d06caSMauro Carvalho Chehab if (dvb->nfeeds == 1) { 2610c0d06caSMauro Carvalho Chehab ret = em28xx_start_streaming(dvb); 2620c0d06caSMauro Carvalho Chehab if (ret < 0) 2630c0d06caSMauro Carvalho Chehab rc = ret; 2640c0d06caSMauro Carvalho Chehab } 2650c0d06caSMauro Carvalho Chehab 2660c0d06caSMauro Carvalho Chehab mutex_unlock(&dvb->lock); 2670c0d06caSMauro Carvalho Chehab return rc; 2680c0d06caSMauro Carvalho Chehab } 2690c0d06caSMauro Carvalho Chehab 2700c0d06caSMauro Carvalho Chehab static int em28xx_stop_feed(struct dvb_demux_feed *feed) 2710c0d06caSMauro Carvalho Chehab { 2720c0d06caSMauro Carvalho Chehab struct dvb_demux *demux = feed->demux; 2730c0d06caSMauro Carvalho Chehab struct em28xx_dvb *dvb = demux->priv; 2740c0d06caSMauro Carvalho Chehab int err = 0; 2750c0d06caSMauro Carvalho Chehab 2760c0d06caSMauro Carvalho Chehab mutex_lock(&dvb->lock); 2770c0d06caSMauro Carvalho Chehab dvb->nfeeds--; 2780c0d06caSMauro Carvalho Chehab 2790c0d06caSMauro Carvalho Chehab if (0 == dvb->nfeeds) 2800c0d06caSMauro Carvalho Chehab err = em28xx_stop_streaming(dvb); 2810c0d06caSMauro Carvalho Chehab 2820c0d06caSMauro Carvalho Chehab mutex_unlock(&dvb->lock); 2830c0d06caSMauro Carvalho Chehab return err; 2840c0d06caSMauro Carvalho Chehab } 2850c0d06caSMauro Carvalho Chehab 2860c0d06caSMauro Carvalho Chehab 2870c0d06caSMauro Carvalho Chehab /* ------------------------------------------------------------------ */ 2880c0d06caSMauro Carvalho Chehab static int em28xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) 2890c0d06caSMauro Carvalho Chehab { 290a3b60209SMauro Carvalho Chehab struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv; 291a3b60209SMauro Carvalho Chehab struct em28xx *dev = i2c_bus->dev; 2920c0d06caSMauro Carvalho Chehab 2930c0d06caSMauro Carvalho Chehab if (acquire) 2940c0d06caSMauro Carvalho Chehab return em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); 2950c0d06caSMauro Carvalho Chehab else 2960c0d06caSMauro Carvalho Chehab return em28xx_set_mode(dev, EM28XX_SUSPEND); 2970c0d06caSMauro Carvalho Chehab } 2980c0d06caSMauro Carvalho Chehab 2990c0d06caSMauro Carvalho Chehab /* ------------------------------------------------------------------ */ 3000c0d06caSMauro Carvalho Chehab 3010c0d06caSMauro Carvalho Chehab static struct lgdt330x_config em2880_lgdt3303_dev = { 3020c0d06caSMauro Carvalho Chehab .demod_address = 0x0e, 3030c0d06caSMauro Carvalho Chehab .demod_chip = LGDT3303, 3040c0d06caSMauro Carvalho Chehab }; 3050c0d06caSMauro Carvalho Chehab 3060c0d06caSMauro Carvalho Chehab static struct lgdt3305_config em2870_lgdt3304_dev = { 3070c0d06caSMauro Carvalho Chehab .i2c_addr = 0x0e, 3080c0d06caSMauro Carvalho Chehab .demod_chip = LGDT3304, 3090c0d06caSMauro Carvalho Chehab .spectral_inversion = 1, 3100c0d06caSMauro Carvalho Chehab .deny_i2c_rptr = 1, 3110c0d06caSMauro Carvalho Chehab .mpeg_mode = LGDT3305_MPEG_PARALLEL, 3120c0d06caSMauro Carvalho Chehab .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, 3130c0d06caSMauro Carvalho Chehab .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, 3140c0d06caSMauro Carvalho Chehab .vsb_if_khz = 3250, 3150c0d06caSMauro Carvalho Chehab .qam_if_khz = 4000, 3160c0d06caSMauro Carvalho Chehab }; 3170c0d06caSMauro Carvalho Chehab 3186dbea9f0SJean-Francois Thibert static struct lgdt3305_config em2874_lgdt3305_dev = { 3196dbea9f0SJean-Francois Thibert .i2c_addr = 0x0e, 3206dbea9f0SJean-Francois Thibert .demod_chip = LGDT3305, 3216dbea9f0SJean-Francois Thibert .spectral_inversion = 1, 3226dbea9f0SJean-Francois Thibert .deny_i2c_rptr = 0, 3236dbea9f0SJean-Francois Thibert .mpeg_mode = LGDT3305_MPEG_SERIAL, 3246dbea9f0SJean-Francois Thibert .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, 3256dbea9f0SJean-Francois Thibert .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, 3266dbea9f0SJean-Francois Thibert .vsb_if_khz = 3250, 3276dbea9f0SJean-Francois Thibert .qam_if_khz = 4000, 3286dbea9f0SJean-Francois Thibert }; 3296dbea9f0SJean-Francois Thibert 33002bc1f55SMauro Carvalho Chehab static struct lgdt3305_config em2874_lgdt3305_nogate_dev = { 33102bc1f55SMauro Carvalho Chehab .i2c_addr = 0x0e, 33202bc1f55SMauro Carvalho Chehab .demod_chip = LGDT3305, 33302bc1f55SMauro Carvalho Chehab .spectral_inversion = 1, 33402bc1f55SMauro Carvalho Chehab .deny_i2c_rptr = 1, 33502bc1f55SMauro Carvalho Chehab .mpeg_mode = LGDT3305_MPEG_SERIAL, 33602bc1f55SMauro Carvalho Chehab .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, 33702bc1f55SMauro Carvalho Chehab .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, 33802bc1f55SMauro Carvalho Chehab .vsb_if_khz = 3600, 33902bc1f55SMauro Carvalho Chehab .qam_if_khz = 3600, 34002bc1f55SMauro Carvalho Chehab }; 34102bc1f55SMauro Carvalho Chehab 3420c0d06caSMauro Carvalho Chehab static struct s921_config sharp_isdbt = { 3430c0d06caSMauro Carvalho Chehab .demod_address = 0x30 >> 1 3440c0d06caSMauro Carvalho Chehab }; 3450c0d06caSMauro Carvalho Chehab 3460c0d06caSMauro Carvalho Chehab static struct zl10353_config em28xx_zl10353_with_xc3028 = { 3470c0d06caSMauro Carvalho Chehab .demod_address = (0x1e >> 1), 3480c0d06caSMauro Carvalho Chehab .no_tuner = 1, 3490c0d06caSMauro Carvalho Chehab .parallel_ts = 1, 3500c0d06caSMauro Carvalho Chehab .if2 = 45600, 3510c0d06caSMauro Carvalho Chehab }; 3520c0d06caSMauro Carvalho Chehab 3530c0d06caSMauro Carvalho Chehab static struct s5h1409_config em28xx_s5h1409_with_xc3028 = { 3540c0d06caSMauro Carvalho Chehab .demod_address = 0x32 >> 1, 3550c0d06caSMauro Carvalho Chehab .output_mode = S5H1409_PARALLEL_OUTPUT, 3560c0d06caSMauro Carvalho Chehab .gpio = S5H1409_GPIO_OFF, 3570c0d06caSMauro Carvalho Chehab .inversion = S5H1409_INVERSION_OFF, 3580c0d06caSMauro Carvalho Chehab .status_mode = S5H1409_DEMODLOCKING, 3590c0d06caSMauro Carvalho Chehab .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK 3600c0d06caSMauro Carvalho Chehab }; 3610c0d06caSMauro Carvalho Chehab 3620c0d06caSMauro Carvalho Chehab static struct tda18271_std_map kworld_a340_std_map = { 3630c0d06caSMauro Carvalho Chehab .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 0, 3640c0d06caSMauro Carvalho Chehab .if_lvl = 1, .rfagc_top = 0x37, }, 3650c0d06caSMauro Carvalho Chehab .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 1, 3660c0d06caSMauro Carvalho Chehab .if_lvl = 1, .rfagc_top = 0x37, }, 3670c0d06caSMauro Carvalho Chehab }; 3680c0d06caSMauro Carvalho Chehab 3690c0d06caSMauro Carvalho Chehab static struct tda18271_config kworld_a340_config = { 3700c0d06caSMauro Carvalho Chehab .std_map = &kworld_a340_std_map, 3710c0d06caSMauro Carvalho Chehab }; 3720c0d06caSMauro Carvalho Chehab 3736dbea9f0SJean-Francois Thibert static struct tda18271_config kworld_ub435q_v2_config = { 3746dbea9f0SJean-Francois Thibert .std_map = &kworld_a340_std_map, 3756dbea9f0SJean-Francois Thibert .gate = TDA18271_GATE_DIGITAL, 3766dbea9f0SJean-Francois Thibert }; 3776dbea9f0SJean-Francois Thibert 37802bc1f55SMauro Carvalho Chehab static struct tda18212_config kworld_ub435q_v3_config = { 37902bc1f55SMauro Carvalho Chehab .if_atsc_vsb = 3600, 38002bc1f55SMauro Carvalho Chehab .if_atsc_qam = 3600, 38102bc1f55SMauro Carvalho Chehab }; 38202bc1f55SMauro Carvalho Chehab 3830c0d06caSMauro Carvalho Chehab static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = { 3840c0d06caSMauro Carvalho Chehab .demod_address = (0x1e >> 1), 3850c0d06caSMauro Carvalho Chehab .no_tuner = 1, 3860c0d06caSMauro Carvalho Chehab .disable_i2c_gate_ctrl = 1, 3870c0d06caSMauro Carvalho Chehab .parallel_ts = 1, 3880c0d06caSMauro Carvalho Chehab .if2 = 45600, 3890c0d06caSMauro Carvalho Chehab }; 3900c0d06caSMauro Carvalho Chehab 3910c0d06caSMauro Carvalho Chehab static struct drxd_config em28xx_drxd = { 3920c0d06caSMauro Carvalho Chehab .demod_address = 0x70, 3930c0d06caSMauro Carvalho Chehab .demod_revision = 0xa2, 3940c0d06caSMauro Carvalho Chehab .pll_type = DRXD_PLL_NONE, 3950c0d06caSMauro Carvalho Chehab .clock = 12000, 3960c0d06caSMauro Carvalho Chehab .insert_rs_byte = 1, 3970c0d06caSMauro Carvalho Chehab .IF = 42800000, 3980c0d06caSMauro Carvalho Chehab .disable_i2c_gate_ctrl = 1, 3990c0d06caSMauro Carvalho Chehab }; 4000c0d06caSMauro Carvalho Chehab 4010c0d06caSMauro Carvalho Chehab static struct drxk_config terratec_h5_drxk = { 4020c0d06caSMauro Carvalho Chehab .adr = 0x29, 4030c0d06caSMauro Carvalho Chehab .single_master = 1, 4040c0d06caSMauro Carvalho Chehab .no_i2c_bridge = 1, 4050c0d06caSMauro Carvalho Chehab .microcode_name = "dvb-usb-terratec-h5-drxk.fw", 4060c0d06caSMauro Carvalho Chehab .qam_demod_parameter_count = 2, 4070c0d06caSMauro Carvalho Chehab }; 4080c0d06caSMauro Carvalho Chehab 4090c0d06caSMauro Carvalho Chehab static struct drxk_config hauppauge_930c_drxk = { 4100c0d06caSMauro Carvalho Chehab .adr = 0x29, 4110c0d06caSMauro Carvalho Chehab .single_master = 1, 4120c0d06caSMauro Carvalho Chehab .no_i2c_bridge = 1, 4130c0d06caSMauro Carvalho Chehab .microcode_name = "dvb-usb-hauppauge-hvr930c-drxk.fw", 4140c0d06caSMauro Carvalho Chehab .chunk_size = 56, 4150c0d06caSMauro Carvalho Chehab .qam_demod_parameter_count = 2, 4160c0d06caSMauro Carvalho Chehab }; 4170c0d06caSMauro Carvalho Chehab 41889040136SMartin Blumenstingl static struct drxk_config terratec_htc_stick_drxk = { 4190c0d06caSMauro Carvalho Chehab .adr = 0x29, 4200c0d06caSMauro Carvalho Chehab .single_master = 1, 4210c0d06caSMauro Carvalho Chehab .no_i2c_bridge = 1, 4220c0d06caSMauro Carvalho Chehab .microcode_name = "dvb-usb-terratec-htc-stick-drxk.fw", 4230c0d06caSMauro Carvalho Chehab .chunk_size = 54, 4240c0d06caSMauro Carvalho Chehab .qam_demod_parameter_count = 2, 4250c0d06caSMauro Carvalho Chehab /* Required for the antenna_gpio to disable LNA. */ 4260c0d06caSMauro Carvalho Chehab .antenna_dvbt = true, 4270c0d06caSMauro Carvalho Chehab /* The windows driver uses the same. This will disable LNA. */ 4280c0d06caSMauro Carvalho Chehab .antenna_gpio = 0x6, 4290c0d06caSMauro Carvalho Chehab }; 4300c0d06caSMauro Carvalho Chehab 4310c0d06caSMauro Carvalho Chehab static struct drxk_config maxmedia_ub425_tc_drxk = { 4320c0d06caSMauro Carvalho Chehab .adr = 0x29, 4330c0d06caSMauro Carvalho Chehab .single_master = 1, 4340c0d06caSMauro Carvalho Chehab .no_i2c_bridge = 1, 4358d100b27SAntti Palosaari .microcode_name = "dvb-demod-drxk-01.fw", 4368d100b27SAntti Palosaari .chunk_size = 62, 437de0fc463SAntti Palosaari .qam_demod_parameter_count = 2, 4380c0d06caSMauro Carvalho Chehab }; 4390c0d06caSMauro Carvalho Chehab 4400c0d06caSMauro Carvalho Chehab static struct drxk_config pctv_520e_drxk = { 4410c0d06caSMauro Carvalho Chehab .adr = 0x29, 4420c0d06caSMauro Carvalho Chehab .single_master = 1, 4430c0d06caSMauro Carvalho Chehab .microcode_name = "dvb-demod-drxk-pctv.fw", 4440c0d06caSMauro Carvalho Chehab .qam_demod_parameter_count = 2, 4450c0d06caSMauro Carvalho Chehab .chunk_size = 58, 4460c0d06caSMauro Carvalho Chehab .antenna_dvbt = true, /* disable LNA */ 4470c0d06caSMauro Carvalho Chehab .antenna_gpio = (1 << 2), /* disable LNA */ 4480c0d06caSMauro Carvalho Chehab }; 4490c0d06caSMauro Carvalho Chehab 4500c0d06caSMauro Carvalho Chehab static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) 4510c0d06caSMauro Carvalho Chehab { 4520c0d06caSMauro Carvalho Chehab struct em28xx_dvb *dvb = fe->sec_priv; 4530c0d06caSMauro Carvalho Chehab int status; 4540c0d06caSMauro Carvalho Chehab 4550c0d06caSMauro Carvalho Chehab if (!dvb) 4560c0d06caSMauro Carvalho Chehab return -EINVAL; 4570c0d06caSMauro Carvalho Chehab 4580c0d06caSMauro Carvalho Chehab if (enable) { 4590c0d06caSMauro Carvalho Chehab down(&dvb->pll_mutex); 4600c0d06caSMauro Carvalho Chehab status = dvb->gate_ctrl(fe, 1); 4610c0d06caSMauro Carvalho Chehab } else { 4620c0d06caSMauro Carvalho Chehab status = dvb->gate_ctrl(fe, 0); 4630c0d06caSMauro Carvalho Chehab up(&dvb->pll_mutex); 4640c0d06caSMauro Carvalho Chehab } 4650c0d06caSMauro Carvalho Chehab return status; 4660c0d06caSMauro Carvalho Chehab } 4670c0d06caSMauro Carvalho Chehab 4680c0d06caSMauro Carvalho Chehab static void hauppauge_hvr930c_init(struct em28xx *dev) 4690c0d06caSMauro Carvalho Chehab { 4700c0d06caSMauro Carvalho Chehab int i; 4710c0d06caSMauro Carvalho Chehab 4720c0d06caSMauro Carvalho Chehab struct em28xx_reg_seq hauppauge_hvr930c_init[] = { 473907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0x65}, 474907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xfb, 0xff, 0x32}, 475907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0xb8}, 4760c0d06caSMauro Carvalho Chehab { -1, -1, -1, -1}, 4770c0d06caSMauro Carvalho Chehab }; 4780c0d06caSMauro Carvalho Chehab struct em28xx_reg_seq hauppauge_hvr930c_end[] = { 479907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x01}, 480907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xaf, 0xff, 0x65}, 481907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x76}, 482907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x01}, 483907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x0b}, 484907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x40}, 4850c0d06caSMauro Carvalho Chehab 486907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x65}, 487907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x65}, 488907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xcf, 0xff, 0x0b}, 489907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xef, 0xff, 0x65}, 4900c0d06caSMauro Carvalho Chehab 4910c0d06caSMauro Carvalho Chehab { -1, -1, -1, -1}, 4920c0d06caSMauro Carvalho Chehab }; 4930c0d06caSMauro Carvalho Chehab 4940c0d06caSMauro Carvalho Chehab struct { 4950c0d06caSMauro Carvalho Chehab unsigned char r[4]; 4960c0d06caSMauro Carvalho Chehab int len; 4970c0d06caSMauro Carvalho Chehab } regs[] = { 4980c0d06caSMauro Carvalho Chehab {{ 0x06, 0x02, 0x00, 0x31 }, 4}, 4990c0d06caSMauro Carvalho Chehab {{ 0x01, 0x02 }, 2}, 5000c0d06caSMauro Carvalho Chehab {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, 5010c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00 }, 2}, 5020c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0xff, 0xaf }, 4}, 5030c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0x03, 0xa0 }, 4}, 5040c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00 }, 2}, 5050c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0x73, 0xaf }, 4}, 5060c0d06caSMauro Carvalho Chehab {{ 0x04, 0x00 }, 2}, 5070c0d06caSMauro Carvalho Chehab {{ 0x00, 0x04 }, 2}, 5080c0d06caSMauro Carvalho Chehab {{ 0x00, 0x04, 0x00, 0x0a }, 4}, 5090c0d06caSMauro Carvalho Chehab {{ 0x04, 0x14 }, 2}, 5100c0d06caSMauro Carvalho Chehab {{ 0x04, 0x14, 0x00, 0x00 }, 4}, 5110c0d06caSMauro Carvalho Chehab }; 5120c0d06caSMauro Carvalho Chehab 5130c0d06caSMauro Carvalho Chehab em28xx_gpio_set(dev, hauppauge_hvr930c_init); 5140c0d06caSMauro Carvalho Chehab em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); 5150c0d06caSMauro Carvalho Chehab msleep(10); 5160c0d06caSMauro Carvalho Chehab em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44); 5170c0d06caSMauro Carvalho Chehab msleep(10); 5180c0d06caSMauro Carvalho Chehab 519c7a45e5bSMauro Carvalho Chehab dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1; 5200c0d06caSMauro Carvalho Chehab 5210c0d06caSMauro Carvalho Chehab for (i = 0; i < ARRAY_SIZE(regs); i++) 522c7a45e5bSMauro Carvalho Chehab i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len); 5230c0d06caSMauro Carvalho Chehab em28xx_gpio_set(dev, hauppauge_hvr930c_end); 5240c0d06caSMauro Carvalho Chehab 5250c0d06caSMauro Carvalho Chehab msleep(100); 5260c0d06caSMauro Carvalho Chehab 5270c0d06caSMauro Carvalho Chehab em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44); 5280c0d06caSMauro Carvalho Chehab msleep(30); 5290c0d06caSMauro Carvalho Chehab 5300c0d06caSMauro Carvalho Chehab em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x45); 5310c0d06caSMauro Carvalho Chehab msleep(10); 5320c0d06caSMauro Carvalho Chehab 5330c0d06caSMauro Carvalho Chehab } 5340c0d06caSMauro Carvalho Chehab 5350c0d06caSMauro Carvalho Chehab static void terratec_h5_init(struct em28xx *dev) 5360c0d06caSMauro Carvalho Chehab { 5370c0d06caSMauro Carvalho Chehab int i; 5380c0d06caSMauro Carvalho Chehab struct em28xx_reg_seq terratec_h5_init[] = { 539c074fc4cSFrank Schaefer {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, 540907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, 541907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xf2, 0xff, 50}, 542907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, 5430c0d06caSMauro Carvalho Chehab { -1, -1, -1, -1}, 5440c0d06caSMauro Carvalho Chehab }; 5450c0d06caSMauro Carvalho Chehab struct em28xx_reg_seq terratec_h5_end[] = { 546907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, 547907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50}, 548907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, 5490c0d06caSMauro Carvalho Chehab { -1, -1, -1, -1}, 5500c0d06caSMauro Carvalho Chehab }; 5510c0d06caSMauro Carvalho Chehab struct { 5520c0d06caSMauro Carvalho Chehab unsigned char r[4]; 5530c0d06caSMauro Carvalho Chehab int len; 5540c0d06caSMauro Carvalho Chehab } regs[] = { 5550c0d06caSMauro Carvalho Chehab {{ 0x06, 0x02, 0x00, 0x31 }, 4}, 5560c0d06caSMauro Carvalho Chehab {{ 0x01, 0x02 }, 2}, 5570c0d06caSMauro Carvalho Chehab {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, 5580c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00 }, 2}, 5590c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0xff, 0xaf }, 4}, 5600c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0x03, 0xa0 }, 4}, 5610c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00 }, 2}, 5620c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0x73, 0xaf }, 4}, 5630c0d06caSMauro Carvalho Chehab {{ 0x04, 0x00 }, 2}, 5640c0d06caSMauro Carvalho Chehab {{ 0x00, 0x04 }, 2}, 5650c0d06caSMauro Carvalho Chehab {{ 0x00, 0x04, 0x00, 0x0a }, 4}, 5660c0d06caSMauro Carvalho Chehab {{ 0x04, 0x14 }, 2}, 5670c0d06caSMauro Carvalho Chehab {{ 0x04, 0x14, 0x00, 0x00 }, 4}, 5680c0d06caSMauro Carvalho Chehab }; 5690c0d06caSMauro Carvalho Chehab 5700c0d06caSMauro Carvalho Chehab em28xx_gpio_set(dev, terratec_h5_init); 5710c0d06caSMauro Carvalho Chehab em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); 5720c0d06caSMauro Carvalho Chehab msleep(10); 5730c0d06caSMauro Carvalho Chehab em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x45); 5740c0d06caSMauro Carvalho Chehab msleep(10); 5750c0d06caSMauro Carvalho Chehab 576c7a45e5bSMauro Carvalho Chehab dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1; 5770c0d06caSMauro Carvalho Chehab 5780c0d06caSMauro Carvalho Chehab for (i = 0; i < ARRAY_SIZE(regs); i++) 579c7a45e5bSMauro Carvalho Chehab i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len); 5800c0d06caSMauro Carvalho Chehab em28xx_gpio_set(dev, terratec_h5_end); 5810c0d06caSMauro Carvalho Chehab }; 5820c0d06caSMauro Carvalho Chehab 5830c0d06caSMauro Carvalho Chehab static void terratec_htc_stick_init(struct em28xx *dev) 5840c0d06caSMauro Carvalho Chehab { 5850c0d06caSMauro Carvalho Chehab int i; 5860c0d06caSMauro Carvalho Chehab 5870c0d06caSMauro Carvalho Chehab /* 5880c0d06caSMauro Carvalho Chehab * GPIO configuration: 5890c0d06caSMauro Carvalho Chehab * 0xff: unknown (does not affect DVB-T). 5900c0d06caSMauro Carvalho Chehab * 0xf6: DRX-K (demodulator). 5910c0d06caSMauro Carvalho Chehab * 0xe6: unknown (does not affect DVB-T). 5920c0d06caSMauro Carvalho Chehab * 0xb6: unknown (does not affect DVB-T). 5930c0d06caSMauro Carvalho Chehab */ 5940c0d06caSMauro Carvalho Chehab struct em28xx_reg_seq terratec_htc_stick_init[] = { 595c074fc4cSFrank Schaefer {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, 596907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, 597907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 50}, 598907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 100}, 5990c0d06caSMauro Carvalho Chehab { -1, -1, -1, -1}, 6000c0d06caSMauro Carvalho Chehab }; 6010c0d06caSMauro Carvalho Chehab struct em28xx_reg_seq terratec_htc_stick_end[] = { 602907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100}, 603907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xf6, 0xff, 50}, 6040c0d06caSMauro Carvalho Chehab { -1, -1, -1, -1}, 6050c0d06caSMauro Carvalho Chehab }; 6060c0d06caSMauro Carvalho Chehab 60789040136SMartin Blumenstingl /* 60889040136SMartin Blumenstingl * Init the analog decoder (not yet supported), but 60989040136SMartin Blumenstingl * it's probably still a good idea. 61089040136SMartin Blumenstingl */ 6110c0d06caSMauro Carvalho Chehab struct { 6120c0d06caSMauro Carvalho Chehab unsigned char r[4]; 6130c0d06caSMauro Carvalho Chehab int len; 6140c0d06caSMauro Carvalho Chehab } regs[] = { 6150c0d06caSMauro Carvalho Chehab {{ 0x06, 0x02, 0x00, 0x31 }, 4}, 6160c0d06caSMauro Carvalho Chehab {{ 0x01, 0x02 }, 2}, 6170c0d06caSMauro Carvalho Chehab {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, 6180c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00 }, 2}, 6190c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0xff, 0xaf }, 4}, 6200c0d06caSMauro Carvalho Chehab }; 6210c0d06caSMauro Carvalho Chehab 6220c0d06caSMauro Carvalho Chehab em28xx_gpio_set(dev, terratec_htc_stick_init); 6230c0d06caSMauro Carvalho Chehab 6240c0d06caSMauro Carvalho Chehab em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); 6250c0d06caSMauro Carvalho Chehab msleep(10); 6260c0d06caSMauro Carvalho Chehab em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44); 6270c0d06caSMauro Carvalho Chehab msleep(10); 6280c0d06caSMauro Carvalho Chehab 629c7a45e5bSMauro Carvalho Chehab dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1; 6300c0d06caSMauro Carvalho Chehab 6310c0d06caSMauro Carvalho Chehab for (i = 0; i < ARRAY_SIZE(regs); i++) 632c7a45e5bSMauro Carvalho Chehab i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len); 6330c0d06caSMauro Carvalho Chehab 6340c0d06caSMauro Carvalho Chehab em28xx_gpio_set(dev, terratec_htc_stick_end); 6350c0d06caSMauro Carvalho Chehab }; 6360c0d06caSMauro Carvalho Chehab 63789040136SMartin Blumenstingl static void terratec_htc_usb_xs_init(struct em28xx *dev) 63889040136SMartin Blumenstingl { 63989040136SMartin Blumenstingl int i; 64089040136SMartin Blumenstingl 64189040136SMartin Blumenstingl struct em28xx_reg_seq terratec_htc_usb_xs_init[] = { 642c074fc4cSFrank Schaefer {EM2820_R08_GPIO_CTRL, 0xff, 0xff, 10}, 643907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 100}, 644907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xb2, 0xff, 50}, 645907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xb6, 0xff, 100}, 64689040136SMartin Blumenstingl { -1, -1, -1, -1}, 64789040136SMartin Blumenstingl }; 64889040136SMartin Blumenstingl struct em28xx_reg_seq terratec_htc_usb_xs_end[] = { 649907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 100}, 650907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xa6, 0xff, 50}, 651907d109bSFrank Schaefer {EM2874_R80_GPIO_P0_CTRL, 0xe6, 0xff, 100}, 65289040136SMartin Blumenstingl { -1, -1, -1, -1}, 65389040136SMartin Blumenstingl }; 65489040136SMartin Blumenstingl 65589040136SMartin Blumenstingl /* 65689040136SMartin Blumenstingl * Init the analog decoder (not yet supported), but 65789040136SMartin Blumenstingl * it's probably still a good idea. 65889040136SMartin Blumenstingl */ 65989040136SMartin Blumenstingl struct { 66089040136SMartin Blumenstingl unsigned char r[4]; 66189040136SMartin Blumenstingl int len; 66289040136SMartin Blumenstingl } regs[] = { 66389040136SMartin Blumenstingl {{ 0x06, 0x02, 0x00, 0x31 }, 4}, 66489040136SMartin Blumenstingl {{ 0x01, 0x02 }, 2}, 66589040136SMartin Blumenstingl {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, 66689040136SMartin Blumenstingl {{ 0x01, 0x00 }, 2}, 66789040136SMartin Blumenstingl {{ 0x01, 0x00, 0xff, 0xaf }, 4}, 66889040136SMartin Blumenstingl {{ 0x01, 0x00, 0x03, 0xa0 }, 4}, 66989040136SMartin Blumenstingl {{ 0x01, 0x00 }, 2}, 67089040136SMartin Blumenstingl {{ 0x01, 0x00, 0x73, 0xaf }, 4}, 67189040136SMartin Blumenstingl {{ 0x04, 0x00 }, 2}, 67289040136SMartin Blumenstingl {{ 0x00, 0x04 }, 2}, 67389040136SMartin Blumenstingl {{ 0x00, 0x04, 0x00, 0x0a }, 4}, 67489040136SMartin Blumenstingl {{ 0x04, 0x14 }, 2}, 67589040136SMartin Blumenstingl {{ 0x04, 0x14, 0x00, 0x00 }, 4}, 67689040136SMartin Blumenstingl }; 67789040136SMartin Blumenstingl 67889040136SMartin Blumenstingl em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); 67989040136SMartin Blumenstingl 68089040136SMartin Blumenstingl em28xx_gpio_set(dev, terratec_htc_usb_xs_init); 68189040136SMartin Blumenstingl 68289040136SMartin Blumenstingl em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); 68389040136SMartin Blumenstingl msleep(10); 68489040136SMartin Blumenstingl em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44); 68589040136SMartin Blumenstingl msleep(10); 68689040136SMartin Blumenstingl 687c7a45e5bSMauro Carvalho Chehab dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1; 68889040136SMartin Blumenstingl 68989040136SMartin Blumenstingl for (i = 0; i < ARRAY_SIZE(regs); i++) 690c7a45e5bSMauro Carvalho Chehab i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len); 69189040136SMartin Blumenstingl 69289040136SMartin Blumenstingl em28xx_gpio_set(dev, terratec_htc_usb_xs_end); 69389040136SMartin Blumenstingl }; 69489040136SMartin Blumenstingl 6950c0d06caSMauro Carvalho Chehab static void pctv_520e_init(struct em28xx *dev) 6960c0d06caSMauro Carvalho Chehab { 6970c0d06caSMauro Carvalho Chehab /* 6980c0d06caSMauro Carvalho Chehab * Init AVF4910B analog decoder. Looks like I2C traffic to 6990c0d06caSMauro Carvalho Chehab * digital demodulator and tuner are routed via AVF4910B. 7000c0d06caSMauro Carvalho Chehab */ 7010c0d06caSMauro Carvalho Chehab int i; 7020c0d06caSMauro Carvalho Chehab struct { 7030c0d06caSMauro Carvalho Chehab unsigned char r[4]; 7040c0d06caSMauro Carvalho Chehab int len; 7050c0d06caSMauro Carvalho Chehab } regs[] = { 7060c0d06caSMauro Carvalho Chehab {{ 0x06, 0x02, 0x00, 0x31 }, 4}, 7070c0d06caSMauro Carvalho Chehab {{ 0x01, 0x02 }, 2}, 7080c0d06caSMauro Carvalho Chehab {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, 7090c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00 }, 2}, 7100c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0xff, 0xaf }, 4}, 7110c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0x03, 0xa0 }, 4}, 7120c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00 }, 2}, 7130c0d06caSMauro Carvalho Chehab {{ 0x01, 0x00, 0x73, 0xaf }, 4}, 7140c0d06caSMauro Carvalho Chehab }; 7150c0d06caSMauro Carvalho Chehab 716c7a45e5bSMauro Carvalho Chehab dev->i2c_client[dev->def_i2c_bus].addr = 0x82 >> 1; /* 0x41 */ 7170c0d06caSMauro Carvalho Chehab 7180c0d06caSMauro Carvalho Chehab for (i = 0; i < ARRAY_SIZE(regs); i++) 719c7a45e5bSMauro Carvalho Chehab i2c_master_send(&dev->i2c_client[dev->def_i2c_bus], regs[i].r, regs[i].len); 7200c0d06caSMauro Carvalho Chehab }; 7210c0d06caSMauro Carvalho Chehab 72233eebec5SAntti Palosaari static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe) 72313a5336eSAntti Palosaari { 72433eebec5SAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 7253ec40dcfSAntti Palosaari struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv; 7263ec40dcfSAntti Palosaari struct em28xx *dev = i2c_bus->dev; 72713a5336eSAntti Palosaari #ifdef CONFIG_GPIOLIB 72813a5336eSAntti Palosaari struct em28xx_dvb *dvb = dev->dvb; 72913a5336eSAntti Palosaari int ret; 73013a5336eSAntti Palosaari unsigned long flags; 73113a5336eSAntti Palosaari 73233eebec5SAntti Palosaari if (c->lna == 1) 73333eebec5SAntti Palosaari flags = GPIOF_OUT_INIT_HIGH; /* enable LNA */ 73413a5336eSAntti Palosaari else 73533eebec5SAntti Palosaari flags = GPIOF_OUT_INIT_LOW; /* disable LNA */ 73613a5336eSAntti Palosaari 73713a5336eSAntti Palosaari ret = gpio_request_one(dvb->lna_gpio, flags, NULL); 73813a5336eSAntti Palosaari if (ret) 73929b05e22SMauro Carvalho Chehab dev_err(&dev->intf->dev, "gpio request failed %d\n", ret); 74013a5336eSAntti Palosaari else 74113a5336eSAntti Palosaari gpio_free(dvb->lna_gpio); 74213a5336eSAntti Palosaari 74313a5336eSAntti Palosaari return ret; 74413a5336eSAntti Palosaari #else 74529b05e22SMauro Carvalho Chehab dev_warn(&dev->intf->dev, "%s: LNA control is disabled (lna=%u)\n", 74633eebec5SAntti Palosaari KBUILD_MODNAME, c->lna); 74713a5336eSAntti Palosaari return 0; 74813a5336eSAntti Palosaari #endif 74913a5336eSAntti Palosaari } 75013a5336eSAntti Palosaari 751ffb9948eSAntti Palosaari static int em28xx_pctv_292e_set_lna(struct dvb_frontend *fe) 752ffb9948eSAntti Palosaari { 753ffb9948eSAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 754ffb9948eSAntti Palosaari struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv; 755ffb9948eSAntti Palosaari struct em28xx *dev = i2c_bus->dev; 756ffb9948eSAntti Palosaari u8 lna; 757ffb9948eSAntti Palosaari 758ffb9948eSAntti Palosaari if (c->lna == 1) 759ffb9948eSAntti Palosaari lna = 0x01; 760ffb9948eSAntti Palosaari else 761ffb9948eSAntti Palosaari lna = 0x00; 762ffb9948eSAntti Palosaari 763ffb9948eSAntti Palosaari return em28xx_write_reg_bits(dev, EM2874_R80_GPIO_P0_CTRL, lna, 0x01); 764ffb9948eSAntti Palosaari } 765ffb9948eSAntti Palosaari 7660c0d06caSMauro Carvalho Chehab static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe) 7670c0d06caSMauro Carvalho Chehab { 7680c0d06caSMauro Carvalho Chehab /* Values extracted from a USB trace of the Terratec Windows driver */ 7690c0d06caSMauro Carvalho Chehab static u8 clock_config[] = { CLOCK_CTL, 0x38, 0x2c }; 7700c0d06caSMauro Carvalho Chehab static u8 reset[] = { RESET, 0x80 }; 7710c0d06caSMauro Carvalho Chehab static u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 }; 7720c0d06caSMauro Carvalho Chehab static u8 agc_cfg[] = { AGC_TARGET, 0x28, 0xa0 }; 7730c0d06caSMauro Carvalho Chehab static u8 input_freq_cfg[] = { INPUT_FREQ_1, 0x31, 0xb8 }; 7740c0d06caSMauro Carvalho Chehab static u8 rs_err_cfg[] = { RS_ERR_PER_1, 0x00, 0x4d }; 7750c0d06caSMauro Carvalho Chehab static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; 7760c0d06caSMauro Carvalho Chehab static u8 trl_nom_cfg[] = { TRL_NOMINAL_RATE_1, 0x64, 0x00 }; 7770c0d06caSMauro Carvalho Chehab static u8 tps_given_cfg[] = { TPS_GIVEN_1, 0x40, 0x80, 0x50 }; 7780c0d06caSMauro Carvalho Chehab static u8 tuner_go[] = { TUNER_GO, 0x01}; 7790c0d06caSMauro Carvalho Chehab 7800c0d06caSMauro Carvalho Chehab mt352_write(fe, clock_config, sizeof(clock_config)); 7810c0d06caSMauro Carvalho Chehab udelay(200); 7820c0d06caSMauro Carvalho Chehab mt352_write(fe, reset, sizeof(reset)); 7830c0d06caSMauro Carvalho Chehab mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); 7840c0d06caSMauro Carvalho Chehab mt352_write(fe, agc_cfg, sizeof(agc_cfg)); 7850c0d06caSMauro Carvalho Chehab mt352_write(fe, input_freq_cfg, sizeof(input_freq_cfg)); 7860c0d06caSMauro Carvalho Chehab mt352_write(fe, rs_err_cfg, sizeof(rs_err_cfg)); 7870c0d06caSMauro Carvalho Chehab mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); 7880c0d06caSMauro Carvalho Chehab mt352_write(fe, trl_nom_cfg, sizeof(trl_nom_cfg)); 7890c0d06caSMauro Carvalho Chehab mt352_write(fe, tps_given_cfg, sizeof(tps_given_cfg)); 7900c0d06caSMauro Carvalho Chehab mt352_write(fe, tuner_go, sizeof(tuner_go)); 7910c0d06caSMauro Carvalho Chehab return 0; 7920c0d06caSMauro Carvalho Chehab } 7930c0d06caSMauro Carvalho Chehab 794ab4d1452SSatoshi Nagahama static void px_bcud_init(struct em28xx *dev) 795ab4d1452SSatoshi Nagahama { 796ab4d1452SSatoshi Nagahama int i; 797ab4d1452SSatoshi Nagahama struct { 798ab4d1452SSatoshi Nagahama unsigned char r[4]; 799ab4d1452SSatoshi Nagahama int len; 800ab4d1452SSatoshi Nagahama } regs1[] = { 801ab4d1452SSatoshi Nagahama {{ 0x0e, 0x77 }, 2}, 802ab4d1452SSatoshi Nagahama {{ 0x0f, 0x77 }, 2}, 803ab4d1452SSatoshi Nagahama {{ 0x03, 0x90 }, 2}, 804ab4d1452SSatoshi Nagahama }, regs2[] = { 805ab4d1452SSatoshi Nagahama {{ 0x07, 0x01 }, 2}, 806ab4d1452SSatoshi Nagahama {{ 0x08, 0x10 }, 2}, 807ab4d1452SSatoshi Nagahama {{ 0x13, 0x00 }, 2}, 808ab4d1452SSatoshi Nagahama {{ 0x17, 0x00 }, 2}, 809ab4d1452SSatoshi Nagahama {{ 0x03, 0x01 }, 2}, 810ab4d1452SSatoshi Nagahama {{ 0x10, 0xb1 }, 2}, 811ab4d1452SSatoshi Nagahama {{ 0x11, 0x40 }, 2}, 812ab4d1452SSatoshi Nagahama {{ 0x85, 0x7a }, 2}, 813ab4d1452SSatoshi Nagahama {{ 0x87, 0x04 }, 2}, 814ab4d1452SSatoshi Nagahama }; 815ab4d1452SSatoshi Nagahama static struct em28xx_reg_seq gpio[] = { 816ab4d1452SSatoshi Nagahama {EM28XX_R06_I2C_CLK, 0x40, 0xff, 300}, 817ab4d1452SSatoshi Nagahama {EM2874_R80_GPIO_P0_CTRL, 0xfd, 0xff, 60}, 818ab4d1452SSatoshi Nagahama {EM28XX_R15_RGAIN, 0x20, 0xff, 0}, 819ab4d1452SSatoshi Nagahama {EM28XX_R16_GGAIN, 0x20, 0xff, 0}, 820ab4d1452SSatoshi Nagahama {EM28XX_R17_BGAIN, 0x20, 0xff, 0}, 821ab4d1452SSatoshi Nagahama {EM28XX_R18_ROFFSET, 0x00, 0xff, 0}, 822ab4d1452SSatoshi Nagahama {EM28XX_R19_GOFFSET, 0x00, 0xff, 0}, 823ab4d1452SSatoshi Nagahama {EM28XX_R1A_BOFFSET, 0x00, 0xff, 0}, 824ab4d1452SSatoshi Nagahama {EM28XX_R23_UOFFSET, 0x00, 0xff, 0}, 825ab4d1452SSatoshi Nagahama {EM28XX_R24_VOFFSET, 0x00, 0xff, 0}, 826ab4d1452SSatoshi Nagahama {EM28XX_R26_COMPR, 0x00, 0xff, 0}, 827ab4d1452SSatoshi Nagahama {0x13, 0x08, 0xff, 0}, 828ab4d1452SSatoshi Nagahama {EM28XX_R12_VINENABLE, 0x27, 0xff, 0}, 829ab4d1452SSatoshi Nagahama {EM28XX_R0C_USBSUSP, 0x10, 0xff, 0}, 830ab4d1452SSatoshi Nagahama {EM28XX_R27_OUTFMT, 0x00, 0xff, 0}, 831ab4d1452SSatoshi Nagahama {EM28XX_R10_VINMODE, 0x00, 0xff, 0}, 832ab4d1452SSatoshi Nagahama {EM28XX_R11_VINCTRL, 0x11, 0xff, 0}, 833ab4d1452SSatoshi Nagahama {EM2874_R50_IR_CONFIG, 0x01, 0xff, 0}, 834ab4d1452SSatoshi Nagahama {EM2874_R5F_TS_ENABLE, 0x80, 0xff, 0}, 835ab4d1452SSatoshi Nagahama {EM28XX_R06_I2C_CLK, 0x46, 0xff, 0}, 836ab4d1452SSatoshi Nagahama }; 837ab4d1452SSatoshi Nagahama em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x46); 838ab4d1452SSatoshi Nagahama /* sleeping ISDB-T */ 839ab4d1452SSatoshi Nagahama dev->dvb->i2c_client_demod->addr = 0x14; 840ab4d1452SSatoshi Nagahama for (i = 0; i < ARRAY_SIZE(regs1); i++) 841ab4d1452SSatoshi Nagahama i2c_master_send(dev->dvb->i2c_client_demod, regs1[i].r, 842ab4d1452SSatoshi Nagahama regs1[i].len); 843ab4d1452SSatoshi Nagahama /* sleeping ISDB-S */ 844ab4d1452SSatoshi Nagahama dev->dvb->i2c_client_demod->addr = 0x15; 845ab4d1452SSatoshi Nagahama for (i = 0; i < ARRAY_SIZE(regs2); i++) 846ab4d1452SSatoshi Nagahama i2c_master_send(dev->dvb->i2c_client_demod, regs2[i].r, 847ab4d1452SSatoshi Nagahama regs2[i].len); 848ab4d1452SSatoshi Nagahama for (i = 0; i < ARRAY_SIZE(gpio); i++) { 849ab4d1452SSatoshi Nagahama em28xx_write_reg_bits(dev, gpio[i].reg, gpio[i].val, 850ab4d1452SSatoshi Nagahama gpio[i].mask); 851ab4d1452SSatoshi Nagahama if (gpio[i].sleep > 0) 852ab4d1452SSatoshi Nagahama msleep(gpio[i].sleep); 853ab4d1452SSatoshi Nagahama } 854ab4d1452SSatoshi Nagahama }; 855ab4d1452SSatoshi Nagahama 8560c0d06caSMauro Carvalho Chehab static struct mt352_config terratec_xs_mt352_cfg = { 8570c0d06caSMauro Carvalho Chehab .demod_address = (0x1e >> 1), 8580c0d06caSMauro Carvalho Chehab .no_tuner = 1, 8590c0d06caSMauro Carvalho Chehab .if2 = 45600, 8600c0d06caSMauro Carvalho Chehab .demod_init = em28xx_mt352_terratec_xs_init, 8610c0d06caSMauro Carvalho Chehab }; 8620c0d06caSMauro Carvalho Chehab 8630c0d06caSMauro Carvalho Chehab static struct tda10023_config em28xx_tda10023_config = { 8640c0d06caSMauro Carvalho Chehab .demod_address = 0x0c, 8650c0d06caSMauro Carvalho Chehab .invert = 1, 8660c0d06caSMauro Carvalho Chehab }; 8670c0d06caSMauro Carvalho Chehab 8680c0d06caSMauro Carvalho Chehab static struct cxd2820r_config em28xx_cxd2820r_config = { 8690c0d06caSMauro Carvalho Chehab .i2c_address = (0xd8 >> 1), 8700c0d06caSMauro Carvalho Chehab .ts_mode = CXD2820R_TS_SERIAL, 8710c0d06caSMauro Carvalho Chehab }; 8720c0d06caSMauro Carvalho Chehab 8730c0d06caSMauro Carvalho Chehab static struct tda18271_config em28xx_cxd2820r_tda18271_config = { 8740c0d06caSMauro Carvalho Chehab .output_opt = TDA18271_OUTPUT_LT_OFF, 8750c0d06caSMauro Carvalho Chehab .gate = TDA18271_GATE_DIGITAL, 8760c0d06caSMauro Carvalho Chehab }; 8770c0d06caSMauro Carvalho Chehab 8780c0d06caSMauro Carvalho Chehab static struct zl10353_config em28xx_zl10353_no_i2c_gate_dev = { 8790c0d06caSMauro Carvalho Chehab .demod_address = (0x1e >> 1), 8800c0d06caSMauro Carvalho Chehab .disable_i2c_gate_ctrl = 1, 8810c0d06caSMauro Carvalho Chehab .no_tuner = 1, 8820c0d06caSMauro Carvalho Chehab .parallel_ts = 1, 8830c0d06caSMauro Carvalho Chehab }; 884fdf1bc9fSMauro Carvalho Chehab 8858c47311dSAlberto Mardegan static struct mt2060_config em28xx_mt2060_config = { 8868c47311dSAlberto Mardegan .i2c_address = 0x60, 8878c47311dSAlberto Mardegan }; 8888c47311dSAlberto Mardegan 8890c0d06caSMauro Carvalho Chehab static struct qt1010_config em28xx_qt1010_config = { 8900c0d06caSMauro Carvalho Chehab .i2c_address = 0x62 8910c0d06caSMauro Carvalho Chehab }; 8920c0d06caSMauro Carvalho Chehab 8934159d01bSMauro Carvalho Chehab static const struct mb86a20s_config c3tech_duo_mb86a20s_config = { 8944159d01bSMauro Carvalho Chehab .demod_address = 0x10, 8954159d01bSMauro Carvalho Chehab .is_serial = true, 8964159d01bSMauro Carvalho Chehab }; 8974159d01bSMauro Carvalho Chehab 8984159d01bSMauro Carvalho Chehab static struct tda18271_std_map mb86a20s_tda18271_config = { 8994159d01bSMauro Carvalho Chehab .dvbt_6 = { .if_freq = 4000, .agc_mode = 3, .std = 4, 9004159d01bSMauro Carvalho Chehab .if_lvl = 1, .rfagc_top = 0x37, }, 9014159d01bSMauro Carvalho Chehab }; 9024159d01bSMauro Carvalho Chehab 9034159d01bSMauro Carvalho Chehab static struct tda18271_config c3tech_duo_tda18271_config = { 9044159d01bSMauro Carvalho Chehab .std_map = &mb86a20s_tda18271_config, 9054159d01bSMauro Carvalho Chehab .gate = TDA18271_GATE_DIGITAL, 9064159d01bSMauro Carvalho Chehab .small_i2c = TDA18271_03_BYTE_CHUNK_INIT, 9074159d01bSMauro Carvalho Chehab }; 9084159d01bSMauro Carvalho Chehab 90938b2df95SDevin Heitmueller static struct tda18271_std_map drx_j_std_map = { 91038b2df95SDevin Heitmueller .atsc_6 = { .if_freq = 5000, .agc_mode = 3, .std = 0, .if_lvl = 1, 91138b2df95SDevin Heitmueller .rfagc_top = 0x37, }, 91238b2df95SDevin Heitmueller .qam_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3, .if_lvl = 1, 91338b2df95SDevin Heitmueller .rfagc_top = 0x37, }, 91438b2df95SDevin Heitmueller }; 91538b2df95SDevin Heitmueller 91638b2df95SDevin Heitmueller static struct tda18271_config pinnacle_80e_dvb_config = { 91738b2df95SDevin Heitmueller .std_map = &drx_j_std_map, 91838b2df95SDevin Heitmueller .gate = TDA18271_GATE_DIGITAL, 91938b2df95SDevin Heitmueller .role = TDA18271_MASTER, 92038b2df95SDevin Heitmueller }; 92138b2df95SDevin Heitmueller 9221586342eSKevin Cheng static struct lgdt3306a_config hauppauge_01595_lgdt3306a_config = { 9231586342eSKevin Cheng .qam_if_khz = 4000, 9241586342eSKevin Cheng .vsb_if_khz = 3250, 9251586342eSKevin Cheng .spectral_inversion = 0, 9261586342eSKevin Cheng .deny_i2c_rptr = 0, 9271586342eSKevin Cheng .mpeg_mode = LGDT3306A_MPEG_SERIAL, 9281586342eSKevin Cheng .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE, 9291586342eSKevin Cheng .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH, 9301586342eSKevin Cheng .xtalMHz = 25, 9311586342eSKevin Cheng }; 9321586342eSKevin Cheng 9330c0d06caSMauro Carvalho Chehab /* ------------------------------------------------------------------ */ 9340c0d06caSMauro Carvalho Chehab 9350c0d06caSMauro Carvalho Chehab static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev) 9360c0d06caSMauro Carvalho Chehab { 9370c0d06caSMauro Carvalho Chehab struct dvb_frontend *fe; 9380c0d06caSMauro Carvalho Chehab struct xc2028_config cfg; 939ee97207cSMauro Carvalho Chehab struct xc2028_ctrl ctl; 9400c0d06caSMauro Carvalho Chehab 9410c0d06caSMauro Carvalho Chehab memset(&cfg, 0, sizeof(cfg)); 942c7a45e5bSMauro Carvalho Chehab cfg.i2c_adap = &dev->i2c_adap[dev->def_i2c_bus]; 9430c0d06caSMauro Carvalho Chehab cfg.i2c_addr = addr; 9440c0d06caSMauro Carvalho Chehab 945ee97207cSMauro Carvalho Chehab memset(&ctl, 0, sizeof(ctl)); 946ee97207cSMauro Carvalho Chehab em28xx_setup_xc3028(dev, &ctl); 947ee97207cSMauro Carvalho Chehab cfg.ctrl = &ctl; 948ee97207cSMauro Carvalho Chehab 9490c0d06caSMauro Carvalho Chehab if (!dev->dvb->fe[0]) { 95029b05e22SMauro Carvalho Chehab dev_err(&dev->intf->dev, 951ce8591ffSMauro Carvalho Chehab "dvb frontend not attached. Can't attach xc3028\n"); 9520c0d06caSMauro Carvalho Chehab return -EINVAL; 9530c0d06caSMauro Carvalho Chehab } 9540c0d06caSMauro Carvalho Chehab 9550c0d06caSMauro Carvalho Chehab fe = dvb_attach(xc2028_attach, dev->dvb->fe[0], &cfg); 9560c0d06caSMauro Carvalho Chehab if (!fe) { 95729b05e22SMauro Carvalho Chehab dev_err(&dev->intf->dev, "xc3028 attach failed\n"); 9580c0d06caSMauro Carvalho Chehab dvb_frontend_detach(dev->dvb->fe[0]); 9590c0d06caSMauro Carvalho Chehab dev->dvb->fe[0] = NULL; 9600c0d06caSMauro Carvalho Chehab return -EINVAL; 9610c0d06caSMauro Carvalho Chehab } 9620c0d06caSMauro Carvalho Chehab 96329b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "xc3028 attached\n"); 9640c0d06caSMauro Carvalho Chehab 9650c0d06caSMauro Carvalho Chehab return 0; 9660c0d06caSMauro Carvalho Chehab } 9670c0d06caSMauro Carvalho Chehab 9680c0d06caSMauro Carvalho Chehab /* ------------------------------------------------------------------ */ 9690c0d06caSMauro Carvalho Chehab 9700c0d06caSMauro Carvalho Chehab static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module, 9710c0d06caSMauro Carvalho Chehab struct em28xx *dev, struct device *device) 9720c0d06caSMauro Carvalho Chehab { 9730c0d06caSMauro Carvalho Chehab int result; 974e9ef88bdSMauro Carvalho Chehab bool create_rf_connector = false; 9750c0d06caSMauro Carvalho Chehab 9760c0d06caSMauro Carvalho Chehab mutex_init(&dvb->lock); 9770c0d06caSMauro Carvalho Chehab 9780c0d06caSMauro Carvalho Chehab /* register adapter */ 979ce8591ffSMauro Carvalho Chehab result = dvb_register_adapter(&dvb->adapter, 98029b05e22SMauro Carvalho Chehab dev_name(&dev->intf->dev), module, 981ce8591ffSMauro Carvalho Chehab device, adapter_nr); 9820c0d06caSMauro Carvalho Chehab if (result < 0) { 98329b05e22SMauro Carvalho Chehab dev_warn(&dev->intf->dev, 984ce8591ffSMauro Carvalho Chehab "dvb_register_adapter failed (errno = %d)\n", 9852a96f60eSMauro Carvalho Chehab result); 9860c0d06caSMauro Carvalho Chehab goto fail_adapter; 9870c0d06caSMauro Carvalho Chehab } 98837ecc7b1SMauro Carvalho Chehab #ifdef CONFIG_MEDIA_CONTROLLER_DVB 98937ecc7b1SMauro Carvalho Chehab dvb->adapter.mdev = dev->media_dev; 99037ecc7b1SMauro Carvalho Chehab #endif 9910c0d06caSMauro Carvalho Chehab 9920c0d06caSMauro Carvalho Chehab /* Ensure all frontends negotiate bus access */ 9930c0d06caSMauro Carvalho Chehab dvb->fe[0]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; 9940c0d06caSMauro Carvalho Chehab if (dvb->fe[1]) 9950c0d06caSMauro Carvalho Chehab dvb->fe[1]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; 9960c0d06caSMauro Carvalho Chehab 9973de09fbbSHans Verkuil dvb->adapter.priv = &dev->i2c_bus[dev->def_i2c_bus]; 9980c0d06caSMauro Carvalho Chehab 9990c0d06caSMauro Carvalho Chehab /* register frontend */ 10000c0d06caSMauro Carvalho Chehab result = dvb_register_frontend(&dvb->adapter, dvb->fe[0]); 10010c0d06caSMauro Carvalho Chehab if (result < 0) { 100229b05e22SMauro Carvalho Chehab dev_warn(&dev->intf->dev, 1003ce8591ffSMauro Carvalho Chehab "dvb_register_frontend failed (errno = %d)\n", 10042a96f60eSMauro Carvalho Chehab result); 10050c0d06caSMauro Carvalho Chehab goto fail_frontend0; 10060c0d06caSMauro Carvalho Chehab } 10070c0d06caSMauro Carvalho Chehab 10080c0d06caSMauro Carvalho Chehab /* register 2nd frontend */ 10090c0d06caSMauro Carvalho Chehab if (dvb->fe[1]) { 10100c0d06caSMauro Carvalho Chehab result = dvb_register_frontend(&dvb->adapter, dvb->fe[1]); 10110c0d06caSMauro Carvalho Chehab if (result < 0) { 101229b05e22SMauro Carvalho Chehab dev_warn(&dev->intf->dev, 1013ce8591ffSMauro Carvalho Chehab "2nd dvb_register_frontend failed (errno = %d)\n", 10142a96f60eSMauro Carvalho Chehab result); 10150c0d06caSMauro Carvalho Chehab goto fail_frontend1; 10160c0d06caSMauro Carvalho Chehab } 10170c0d06caSMauro Carvalho Chehab } 10180c0d06caSMauro Carvalho Chehab 10190c0d06caSMauro Carvalho Chehab /* register demux stuff */ 10200c0d06caSMauro Carvalho Chehab dvb->demux.dmx.capabilities = 10210c0d06caSMauro Carvalho Chehab DMX_TS_FILTERING | DMX_SECTION_FILTERING | 10220c0d06caSMauro Carvalho Chehab DMX_MEMORY_BASED_FILTERING; 10230c0d06caSMauro Carvalho Chehab dvb->demux.priv = dvb; 10240c0d06caSMauro Carvalho Chehab dvb->demux.filternum = 256; 10250c0d06caSMauro Carvalho Chehab dvb->demux.feednum = 256; 10260c0d06caSMauro Carvalho Chehab dvb->demux.start_feed = em28xx_start_feed; 10270c0d06caSMauro Carvalho Chehab dvb->demux.stop_feed = em28xx_stop_feed; 10280c0d06caSMauro Carvalho Chehab 10290c0d06caSMauro Carvalho Chehab result = dvb_dmx_init(&dvb->demux); 10300c0d06caSMauro Carvalho Chehab if (result < 0) { 103129b05e22SMauro Carvalho Chehab dev_warn(&dev->intf->dev, 1032ce8591ffSMauro Carvalho Chehab "dvb_dmx_init failed (errno = %d)\n", 1033ce8591ffSMauro Carvalho Chehab result); 10340c0d06caSMauro Carvalho Chehab goto fail_dmx; 10350c0d06caSMauro Carvalho Chehab } 10360c0d06caSMauro Carvalho Chehab 10370c0d06caSMauro Carvalho Chehab dvb->dmxdev.filternum = 256; 10380c0d06caSMauro Carvalho Chehab dvb->dmxdev.demux = &dvb->demux.dmx; 10390c0d06caSMauro Carvalho Chehab dvb->dmxdev.capabilities = 0; 10400c0d06caSMauro Carvalho Chehab result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); 10410c0d06caSMauro Carvalho Chehab if (result < 0) { 104229b05e22SMauro Carvalho Chehab dev_warn(&dev->intf->dev, 1043ce8591ffSMauro Carvalho Chehab "dvb_dmxdev_init failed (errno = %d)\n", 1044ce8591ffSMauro Carvalho Chehab result); 10450c0d06caSMauro Carvalho Chehab goto fail_dmxdev; 10460c0d06caSMauro Carvalho Chehab } 10470c0d06caSMauro Carvalho Chehab 10480c0d06caSMauro Carvalho Chehab dvb->fe_hw.source = DMX_FRONTEND_0; 10490c0d06caSMauro Carvalho Chehab result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); 10500c0d06caSMauro Carvalho Chehab if (result < 0) { 105129b05e22SMauro Carvalho Chehab dev_warn(&dev->intf->dev, 1052ce8591ffSMauro Carvalho Chehab "add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", 10532a96f60eSMauro Carvalho Chehab result); 10540c0d06caSMauro Carvalho Chehab goto fail_fe_hw; 10550c0d06caSMauro Carvalho Chehab } 10560c0d06caSMauro Carvalho Chehab 10570c0d06caSMauro Carvalho Chehab dvb->fe_mem.source = DMX_MEMORY_FE; 10580c0d06caSMauro Carvalho Chehab result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); 10590c0d06caSMauro Carvalho Chehab if (result < 0) { 106029b05e22SMauro Carvalho Chehab dev_warn(&dev->intf->dev, 1061ce8591ffSMauro Carvalho Chehab "add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", 10622a96f60eSMauro Carvalho Chehab result); 10630c0d06caSMauro Carvalho Chehab goto fail_fe_mem; 10640c0d06caSMauro Carvalho Chehab } 10650c0d06caSMauro Carvalho Chehab 10660c0d06caSMauro Carvalho Chehab result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); 10670c0d06caSMauro Carvalho Chehab if (result < 0) { 106829b05e22SMauro Carvalho Chehab dev_warn(&dev->intf->dev, 1069ce8591ffSMauro Carvalho Chehab "connect_frontend failed (errno = %d)\n", 1070ce8591ffSMauro Carvalho Chehab result); 10710c0d06caSMauro Carvalho Chehab goto fail_fe_conn; 10720c0d06caSMauro Carvalho Chehab } 10730c0d06caSMauro Carvalho Chehab 10740c0d06caSMauro Carvalho Chehab /* register network adapter */ 10750c0d06caSMauro Carvalho Chehab dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); 107637ecc7b1SMauro Carvalho Chehab 1077e9ef88bdSMauro Carvalho Chehab /* If the analog part won't create RF connectors, DVB will do it */ 1078e9ef88bdSMauro Carvalho Chehab if (!dev->has_video || (dev->tuner_type == TUNER_ABSENT)) 1079e9ef88bdSMauro Carvalho Chehab create_rf_connector = true; 1080e9ef88bdSMauro Carvalho Chehab 1081e9ef88bdSMauro Carvalho Chehab result = dvb_create_media_graph(&dvb->adapter, create_rf_connector); 108237ecc7b1SMauro Carvalho Chehab if (result < 0) 108337ecc7b1SMauro Carvalho Chehab goto fail_create_graph; 108437ecc7b1SMauro Carvalho Chehab 10850c0d06caSMauro Carvalho Chehab return 0; 10860c0d06caSMauro Carvalho Chehab 108737ecc7b1SMauro Carvalho Chehab fail_create_graph: 108837ecc7b1SMauro Carvalho Chehab dvb_net_release(&dvb->net); 10890c0d06caSMauro Carvalho Chehab fail_fe_conn: 10900c0d06caSMauro Carvalho Chehab dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); 10910c0d06caSMauro Carvalho Chehab fail_fe_mem: 10920c0d06caSMauro Carvalho Chehab dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); 10930c0d06caSMauro Carvalho Chehab fail_fe_hw: 10940c0d06caSMauro Carvalho Chehab dvb_dmxdev_release(&dvb->dmxdev); 10950c0d06caSMauro Carvalho Chehab fail_dmxdev: 10960c0d06caSMauro Carvalho Chehab dvb_dmx_release(&dvb->demux); 10970c0d06caSMauro Carvalho Chehab fail_dmx: 10980c0d06caSMauro Carvalho Chehab if (dvb->fe[1]) 10990c0d06caSMauro Carvalho Chehab dvb_unregister_frontend(dvb->fe[1]); 11000c0d06caSMauro Carvalho Chehab dvb_unregister_frontend(dvb->fe[0]); 11010c0d06caSMauro Carvalho Chehab fail_frontend1: 11020c0d06caSMauro Carvalho Chehab if (dvb->fe[1]) 11030c0d06caSMauro Carvalho Chehab dvb_frontend_detach(dvb->fe[1]); 11040c0d06caSMauro Carvalho Chehab fail_frontend0: 11050c0d06caSMauro Carvalho Chehab dvb_frontend_detach(dvb->fe[0]); 11060c0d06caSMauro Carvalho Chehab dvb_unregister_adapter(&dvb->adapter); 11070c0d06caSMauro Carvalho Chehab fail_adapter: 11080c0d06caSMauro Carvalho Chehab return result; 11090c0d06caSMauro Carvalho Chehab } 11100c0d06caSMauro Carvalho Chehab 11110c0d06caSMauro Carvalho Chehab static void em28xx_unregister_dvb(struct em28xx_dvb *dvb) 11120c0d06caSMauro Carvalho Chehab { 11130c0d06caSMauro Carvalho Chehab dvb_net_release(&dvb->net); 11140c0d06caSMauro Carvalho Chehab dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); 11150c0d06caSMauro Carvalho Chehab dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); 11160c0d06caSMauro Carvalho Chehab dvb_dmxdev_release(&dvb->dmxdev); 11170c0d06caSMauro Carvalho Chehab dvb_dmx_release(&dvb->demux); 11180c0d06caSMauro Carvalho Chehab if (dvb->fe[1]) 11190c0d06caSMauro Carvalho Chehab dvb_unregister_frontend(dvb->fe[1]); 11200c0d06caSMauro Carvalho Chehab dvb_unregister_frontend(dvb->fe[0]); 11210c0d06caSMauro Carvalho Chehab if (dvb->fe[1] && !dvb->dont_attach_fe1) 11220c0d06caSMauro Carvalho Chehab dvb_frontend_detach(dvb->fe[1]); 11230c0d06caSMauro Carvalho Chehab dvb_frontend_detach(dvb->fe[0]); 11240c0d06caSMauro Carvalho Chehab dvb_unregister_adapter(&dvb->adapter); 11250c0d06caSMauro Carvalho Chehab } 11260c0d06caSMauro Carvalho Chehab 11270c0d06caSMauro Carvalho Chehab static int em28xx_dvb_init(struct em28xx *dev) 11280c0d06caSMauro Carvalho Chehab { 1129*be7fd3c3SBrad Love int result = 0, dvb_alt = 0; 11300c0d06caSMauro Carvalho Chehab struct em28xx_dvb *dvb; 1131*be7fd3c3SBrad Love struct usb_device *udev; 11320c0d06caSMauro Carvalho Chehab 1133822b8deaSMauro Carvalho Chehab if (dev->is_audio_only) { 1134822b8deaSMauro Carvalho Chehab /* Shouldn't initialize IR for this interface */ 1135822b8deaSMauro Carvalho Chehab return 0; 1136822b8deaSMauro Carvalho Chehab } 1137822b8deaSMauro Carvalho Chehab 11380c0d06caSMauro Carvalho Chehab if (!dev->board.has_dvb) { 11390c0d06caSMauro Carvalho Chehab /* This device does not support the extension */ 11400c0d06caSMauro Carvalho Chehab return 0; 11410c0d06caSMauro Carvalho Chehab } 11420c0d06caSMauro Carvalho Chehab 114329b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "Binding DVB extension\n"); 11449634614fSMauro Carvalho Chehab 11450c0d06caSMauro Carvalho Chehab dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); 11468314d402SMauro Carvalho Chehab if (!dvb) 11470c0d06caSMauro Carvalho Chehab return -ENOMEM; 11488314d402SMauro Carvalho Chehab 11490c0d06caSMauro Carvalho Chehab dev->dvb = dvb; 11500c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb->fe[1] = NULL; 11510c0d06caSMauro Carvalho Chehab 115227ba0dacSFrank Schaefer /* pre-allocate DVB usb transfer buffers */ 115327ba0dacSFrank Schaefer if (dev->dvb_xfer_bulk) { 115427ba0dacSFrank Schaefer result = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE, 115527ba0dacSFrank Schaefer dev->dvb_xfer_bulk, 115627ba0dacSFrank Schaefer EM28XX_DVB_NUM_BUFS, 115727ba0dacSFrank Schaefer 512, 115827ba0dacSFrank Schaefer EM28XX_DVB_BULK_PACKET_MULTIPLIER); 115927ba0dacSFrank Schaefer } else { 116027ba0dacSFrank Schaefer result = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE, 116127ba0dacSFrank Schaefer dev->dvb_xfer_bulk, 116227ba0dacSFrank Schaefer EM28XX_DVB_NUM_BUFS, 116327ba0dacSFrank Schaefer dev->dvb_max_pkt_size_isoc, 116427ba0dacSFrank Schaefer EM28XX_DVB_NUM_ISOC_PACKETS); 116527ba0dacSFrank Schaefer } 116627ba0dacSFrank Schaefer if (result) { 116729b05e22SMauro Carvalho Chehab dev_err(&dev->intf->dev, 1168ce8591ffSMauro Carvalho Chehab "failed to pre-allocate USB transfer buffers for DVB.\n"); 116927ba0dacSFrank Schaefer kfree(dvb); 117027ba0dacSFrank Schaefer dev->dvb = NULL; 117127ba0dacSFrank Schaefer return result; 117227ba0dacSFrank Schaefer } 117327ba0dacSFrank Schaefer 11740c0d06caSMauro Carvalho Chehab mutex_lock(&dev->lock); 11750c0d06caSMauro Carvalho Chehab em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); 11760c0d06caSMauro Carvalho Chehab /* init frontend */ 11770c0d06caSMauro Carvalho Chehab switch (dev->model) { 11780c0d06caSMauro Carvalho Chehab case EM2874_BOARD_LEADERSHIP_ISDBT: 11790c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(s921_attach, 1180c7a45e5bSMauro Carvalho Chehab &sharp_isdbt, &dev->i2c_adap[dev->def_i2c_bus]); 11810c0d06caSMauro Carvalho Chehab 11820c0d06caSMauro Carvalho Chehab if (!dvb->fe[0]) { 11830c0d06caSMauro Carvalho Chehab result = -EINVAL; 11840c0d06caSMauro Carvalho Chehab goto out_free; 11850c0d06caSMauro Carvalho Chehab } 11860c0d06caSMauro Carvalho Chehab 11870c0d06caSMauro Carvalho Chehab break; 11880c0d06caSMauro Carvalho Chehab case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850: 11890c0d06caSMauro Carvalho Chehab case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: 11900c0d06caSMauro Carvalho Chehab case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: 11910c0d06caSMauro Carvalho Chehab case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600: 11920c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(lgdt330x_attach, 11930c0d06caSMauro Carvalho Chehab &em2880_lgdt3303_dev, 1194c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 11950c0d06caSMauro Carvalho Chehab if (em28xx_attach_xc3028(0x61, dev) < 0) { 11960c0d06caSMauro Carvalho Chehab result = -EINVAL; 11970c0d06caSMauro Carvalho Chehab goto out_free; 11980c0d06caSMauro Carvalho Chehab } 11990c0d06caSMauro Carvalho Chehab break; 12000c0d06caSMauro Carvalho Chehab case EM2880_BOARD_KWORLD_DVB_310U: 12010c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(zl10353_attach, 12020c0d06caSMauro Carvalho Chehab &em28xx_zl10353_with_xc3028, 1203c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 12040c0d06caSMauro Carvalho Chehab if (em28xx_attach_xc3028(0x61, dev) < 0) { 12050c0d06caSMauro Carvalho Chehab result = -EINVAL; 12060c0d06caSMauro Carvalho Chehab goto out_free; 12070c0d06caSMauro Carvalho Chehab } 12080c0d06caSMauro Carvalho Chehab break; 12090c0d06caSMauro Carvalho Chehab case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: 12100c0d06caSMauro Carvalho Chehab case EM2882_BOARD_TERRATEC_HYBRID_XS: 12110c0d06caSMauro Carvalho Chehab case EM2880_BOARD_EMPIRE_DUAL_TV: 12120c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(zl10353_attach, 12130c0d06caSMauro Carvalho Chehab &em28xx_zl10353_xc3028_no_i2c_gate, 1214c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 12150c0d06caSMauro Carvalho Chehab if (em28xx_attach_xc3028(0x61, dev) < 0) { 12160c0d06caSMauro Carvalho Chehab result = -EINVAL; 12170c0d06caSMauro Carvalho Chehab goto out_free; 12180c0d06caSMauro Carvalho Chehab } 12190c0d06caSMauro Carvalho Chehab break; 12200c0d06caSMauro Carvalho Chehab case EM2880_BOARD_TERRATEC_HYBRID_XS: 12210c0d06caSMauro Carvalho Chehab case EM2880_BOARD_TERRATEC_HYBRID_XS_FR: 12220c0d06caSMauro Carvalho Chehab case EM2881_BOARD_PINNACLE_HYBRID_PRO: 12230c0d06caSMauro Carvalho Chehab case EM2882_BOARD_DIKOM_DK300: 12240c0d06caSMauro Carvalho Chehab case EM2882_BOARD_KWORLD_VS_DVBT: 12250c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(zl10353_attach, 12260c0d06caSMauro Carvalho Chehab &em28xx_zl10353_xc3028_no_i2c_gate, 1227c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 12280c0d06caSMauro Carvalho Chehab if (dvb->fe[0] == NULL) { 12290c0d06caSMauro Carvalho Chehab /* This board could have either a zl10353 or a mt352. 12300c0d06caSMauro Carvalho Chehab If the chip id isn't for zl10353, try mt352 */ 12310c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(mt352_attach, 12320c0d06caSMauro Carvalho Chehab &terratec_xs_mt352_cfg, 1233c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 12340c0d06caSMauro Carvalho Chehab } 12350c0d06caSMauro Carvalho Chehab 12360c0d06caSMauro Carvalho Chehab if (em28xx_attach_xc3028(0x61, dev) < 0) { 12370c0d06caSMauro Carvalho Chehab result = -EINVAL; 12380c0d06caSMauro Carvalho Chehab goto out_free; 12390c0d06caSMauro Carvalho Chehab } 12400c0d06caSMauro Carvalho Chehab break; 12418c47311dSAlberto Mardegan case EM2870_BOARD_TERRATEC_XS_MT2060: 12428c47311dSAlberto Mardegan dvb->fe[0] = dvb_attach(zl10353_attach, 12438c47311dSAlberto Mardegan &em28xx_zl10353_no_i2c_gate_dev, 12448c47311dSAlberto Mardegan &dev->i2c_adap[dev->def_i2c_bus]); 12458c47311dSAlberto Mardegan if (dvb->fe[0] != NULL) { 12468c47311dSAlberto Mardegan dvb_attach(mt2060_attach, dvb->fe[0], 12478c47311dSAlberto Mardegan &dev->i2c_adap[dev->def_i2c_bus], 12488c47311dSAlberto Mardegan &em28xx_mt2060_config, 1220); 12498c47311dSAlberto Mardegan } 12508c47311dSAlberto Mardegan break; 12510c0d06caSMauro Carvalho Chehab case EM2870_BOARD_KWORLD_355U: 12520c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(zl10353_attach, 12530c0d06caSMauro Carvalho Chehab &em28xx_zl10353_no_i2c_gate_dev, 1254c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 12550c0d06caSMauro Carvalho Chehab if (dvb->fe[0] != NULL) 12560c0d06caSMauro Carvalho Chehab dvb_attach(qt1010_attach, dvb->fe[0], 1257c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], &em28xx_qt1010_config); 12580c0d06caSMauro Carvalho Chehab break; 12590c0d06caSMauro Carvalho Chehab case EM2883_BOARD_KWORLD_HYBRID_330U: 12600c0d06caSMauro Carvalho Chehab case EM2882_BOARD_EVGA_INDTUBE: 12610c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(s5h1409_attach, 12620c0d06caSMauro Carvalho Chehab &em28xx_s5h1409_with_xc3028, 1263c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 12640c0d06caSMauro Carvalho Chehab if (em28xx_attach_xc3028(0x61, dev) < 0) { 12650c0d06caSMauro Carvalho Chehab result = -EINVAL; 12660c0d06caSMauro Carvalho Chehab goto out_free; 12670c0d06caSMauro Carvalho Chehab } 12680c0d06caSMauro Carvalho Chehab break; 12690c0d06caSMauro Carvalho Chehab case EM2882_BOARD_KWORLD_ATSC_315U: 12700c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(lgdt330x_attach, 12710c0d06caSMauro Carvalho Chehab &em2880_lgdt3303_dev, 1272c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 12730c0d06caSMauro Carvalho Chehab if (dvb->fe[0] != NULL) { 12740c0d06caSMauro Carvalho Chehab if (!dvb_attach(simple_tuner_attach, dvb->fe[0], 1275fdf1bc9fSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 1276fdf1bc9fSMauro Carvalho Chehab 0x61, TUNER_THOMSON_DTT761X)) { 12770c0d06caSMauro Carvalho Chehab result = -EINVAL; 12780c0d06caSMauro Carvalho Chehab goto out_free; 12790c0d06caSMauro Carvalho Chehab } 12800c0d06caSMauro Carvalho Chehab } 12810c0d06caSMauro Carvalho Chehab break; 12820c0d06caSMauro Carvalho Chehab case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: 12830c0d06caSMauro Carvalho Chehab case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E: 12840c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(drxd_attach, &em28xx_drxd, NULL, 128529b05e22SMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 128629b05e22SMauro Carvalho Chehab &dev->intf->dev); 12870c0d06caSMauro Carvalho Chehab if (em28xx_attach_xc3028(0x61, dev) < 0) { 12880c0d06caSMauro Carvalho Chehab result = -EINVAL; 12890c0d06caSMauro Carvalho Chehab goto out_free; 12900c0d06caSMauro Carvalho Chehab } 12910c0d06caSMauro Carvalho Chehab break; 12920c0d06caSMauro Carvalho Chehab case EM2870_BOARD_REDDO_DVB_C_USB_BOX: 12930c0d06caSMauro Carvalho Chehab /* Philips CU1216L NIM (Philips TDA10023 + Infineon TUA6034) */ 12940c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(tda10023_attach, 12950c0d06caSMauro Carvalho Chehab &em28xx_tda10023_config, 1296c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 0x48); 12970c0d06caSMauro Carvalho Chehab if (dvb->fe[0]) { 12980c0d06caSMauro Carvalho Chehab if (!dvb_attach(simple_tuner_attach, dvb->fe[0], 1299fdf1bc9fSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 1300fdf1bc9fSMauro Carvalho Chehab 0x60, TUNER_PHILIPS_CU1216L)) { 13010c0d06caSMauro Carvalho Chehab result = -EINVAL; 13020c0d06caSMauro Carvalho Chehab goto out_free; 13030c0d06caSMauro Carvalho Chehab } 13040c0d06caSMauro Carvalho Chehab } 13050c0d06caSMauro Carvalho Chehab break; 13060c0d06caSMauro Carvalho Chehab case EM2870_BOARD_KWORLD_A340: 13070c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(lgdt3305_attach, 13080c0d06caSMauro Carvalho Chehab &em2870_lgdt3304_dev, 1309c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 13104db8954aSShuah Khan if (!dvb->fe[0]) { 13114db8954aSShuah Khan result = -EINVAL; 13124db8954aSShuah Khan goto out_free; 13134db8954aSShuah Khan } 13144db8954aSShuah Khan if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, 13154db8954aSShuah Khan &dev->i2c_adap[dev->def_i2c_bus], 13164db8954aSShuah Khan &kworld_a340_config)) { 13174db8954aSShuah Khan dvb_frontend_detach(dvb->fe[0]); 13184db8954aSShuah Khan result = -EINVAL; 13194db8954aSShuah Khan goto out_free; 13204db8954aSShuah Khan } 13210c0d06caSMauro Carvalho Chehab break; 13220c0d06caSMauro Carvalho Chehab case EM28174_BOARD_PCTV_290E: 1323a36a66d7SAntti Palosaari /* set default GPIO0 for LNA, used if GPIOLIB is undefined */ 1324a36a66d7SAntti Palosaari dvb->lna_gpio = CXD2820R_GPIO_E | CXD2820R_GPIO_O | 1325a36a66d7SAntti Palosaari CXD2820R_GPIO_L; 13260c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(cxd2820r_attach, 13270c0d06caSMauro Carvalho Chehab &em28xx_cxd2820r_config, 1328c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 132913a5336eSAntti Palosaari &dvb->lna_gpio); 13300c0d06caSMauro Carvalho Chehab if (dvb->fe[0]) { 13310c0d06caSMauro Carvalho Chehab /* FE 0 attach tuner */ 13320c0d06caSMauro Carvalho Chehab if (!dvb_attach(tda18271_attach, 13330c0d06caSMauro Carvalho Chehab dvb->fe[0], 13340c0d06caSMauro Carvalho Chehab 0x60, 1335c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 13360c0d06caSMauro Carvalho Chehab &em28xx_cxd2820r_tda18271_config)) { 13370c0d06caSMauro Carvalho Chehab 13380c0d06caSMauro Carvalho Chehab dvb_frontend_detach(dvb->fe[0]); 13390c0d06caSMauro Carvalho Chehab result = -EINVAL; 13400c0d06caSMauro Carvalho Chehab goto out_free; 13410c0d06caSMauro Carvalho Chehab } 13421e8f31f3SAntti Palosaari 134313a5336eSAntti Palosaari #ifdef CONFIG_GPIOLIB 13441e8f31f3SAntti Palosaari /* enable LNA for DVB-T, DVB-T2 and DVB-C */ 13450c42a55cSAntti Palosaari result = gpio_request_one(dvb->lna_gpio, 13460c42a55cSAntti Palosaari GPIOF_OUT_INIT_LOW, NULL); 13471e8f31f3SAntti Palosaari if (result) 134829b05e22SMauro Carvalho Chehab dev_err(&dev->intf->dev, 1349ce8591ffSMauro Carvalho Chehab "gpio request failed %d\n", 13500c42a55cSAntti Palosaari result); 13511e8f31f3SAntti Palosaari else 135213a5336eSAntti Palosaari gpio_free(dvb->lna_gpio); 13531e8f31f3SAntti Palosaari 13541e8f31f3SAntti Palosaari result = 0; /* continue even set LNA fails */ 135513a5336eSAntti Palosaari #endif 135613a5336eSAntti Palosaari dvb->fe[0]->ops.set_lna = em28xx_pctv_290e_set_lna; 13570c42a55cSAntti Palosaari } 13580c42a55cSAntti Palosaari 13590c0d06caSMauro Carvalho Chehab break; 13600c0d06caSMauro Carvalho Chehab case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C: 13610c0d06caSMauro Carvalho Chehab { 13620c0d06caSMauro Carvalho Chehab struct xc5000_config cfg; 1363fdf1bc9fSMauro Carvalho Chehab 13640c0d06caSMauro Carvalho Chehab hauppauge_hvr930c_init(dev); 13650c0d06caSMauro Carvalho Chehab 13660c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(drxk_attach, 1367c7a45e5bSMauro Carvalho Chehab &hauppauge_930c_drxk, &dev->i2c_adap[dev->def_i2c_bus]); 13680c0d06caSMauro Carvalho Chehab if (!dvb->fe[0]) { 13690c0d06caSMauro Carvalho Chehab result = -EINVAL; 13700c0d06caSMauro Carvalho Chehab goto out_free; 13710c0d06caSMauro Carvalho Chehab } 13720c0d06caSMauro Carvalho Chehab /* FIXME: do we need a pll semaphore? */ 13730c0d06caSMauro Carvalho Chehab dvb->fe[0]->sec_priv = dvb; 13740c0d06caSMauro Carvalho Chehab sema_init(&dvb->pll_mutex, 1); 13750c0d06caSMauro Carvalho Chehab dvb->gate_ctrl = dvb->fe[0]->ops.i2c_gate_ctrl; 13760c0d06caSMauro Carvalho Chehab dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl; 13770c0d06caSMauro Carvalho Chehab 13780c0d06caSMauro Carvalho Chehab /* Attach xc5000 */ 13790c0d06caSMauro Carvalho Chehab memset(&cfg, 0, sizeof(cfg)); 13800c0d06caSMauro Carvalho Chehab cfg.i2c_address = 0x61; 13810c0d06caSMauro Carvalho Chehab cfg.if_khz = 4000; 13820c0d06caSMauro Carvalho Chehab 13830c0d06caSMauro Carvalho Chehab if (dvb->fe[0]->ops.i2c_gate_ctrl) 13840c0d06caSMauro Carvalho Chehab dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 1); 1385c7a45e5bSMauro Carvalho Chehab if (!dvb_attach(xc5000_attach, dvb->fe[0], &dev->i2c_adap[dev->def_i2c_bus], 13860c0d06caSMauro Carvalho Chehab &cfg)) { 13870c0d06caSMauro Carvalho Chehab result = -EINVAL; 13880c0d06caSMauro Carvalho Chehab goto out_free; 13890c0d06caSMauro Carvalho Chehab } 13900c0d06caSMauro Carvalho Chehab if (dvb->fe[0]->ops.i2c_gate_ctrl) 13910c0d06caSMauro Carvalho Chehab dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 0); 13920c0d06caSMauro Carvalho Chehab 13930c0d06caSMauro Carvalho Chehab break; 13940c0d06caSMauro Carvalho Chehab } 13950c0d06caSMauro Carvalho Chehab case EM2884_BOARD_TERRATEC_H5: 13960c0d06caSMauro Carvalho Chehab terratec_h5_init(dev); 13970c0d06caSMauro Carvalho Chehab 1398c7a45e5bSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(drxk_attach, &terratec_h5_drxk, &dev->i2c_adap[dev->def_i2c_bus]); 13990c0d06caSMauro Carvalho Chehab if (!dvb->fe[0]) { 14000c0d06caSMauro Carvalho Chehab result = -EINVAL; 14010c0d06caSMauro Carvalho Chehab goto out_free; 14020c0d06caSMauro Carvalho Chehab } 14030c0d06caSMauro Carvalho Chehab /* FIXME: do we need a pll semaphore? */ 14040c0d06caSMauro Carvalho Chehab dvb->fe[0]->sec_priv = dvb; 14050c0d06caSMauro Carvalho Chehab sema_init(&dvb->pll_mutex, 1); 14060c0d06caSMauro Carvalho Chehab dvb->gate_ctrl = dvb->fe[0]->ops.i2c_gate_ctrl; 14070c0d06caSMauro Carvalho Chehab dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl; 14080c0d06caSMauro Carvalho Chehab 14090c0d06caSMauro Carvalho Chehab /* Attach tda18271 to DVB-C frontend */ 14100c0d06caSMauro Carvalho Chehab if (dvb->fe[0]->ops.i2c_gate_ctrl) 14110c0d06caSMauro Carvalho Chehab dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 1); 1412c7a45e5bSMauro Carvalho Chehab if (!dvb_attach(tda18271c2dd_attach, dvb->fe[0], &dev->i2c_adap[dev->def_i2c_bus], 0x60)) { 14130c0d06caSMauro Carvalho Chehab result = -EINVAL; 14140c0d06caSMauro Carvalho Chehab goto out_free; 14150c0d06caSMauro Carvalho Chehab } 14160c0d06caSMauro Carvalho Chehab if (dvb->fe[0]->ops.i2c_gate_ctrl) 14170c0d06caSMauro Carvalho Chehab dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 0); 14180c0d06caSMauro Carvalho Chehab 14190c0d06caSMauro Carvalho Chehab break; 14204159d01bSMauro Carvalho Chehab case EM2884_BOARD_C3TECH_DIGITAL_DUO: 14214159d01bSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(mb86a20s_attach, 14224159d01bSMauro Carvalho Chehab &c3tech_duo_mb86a20s_config, 14234159d01bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 14244159d01bSMauro Carvalho Chehab if (dvb->fe[0] != NULL) 14254159d01bSMauro Carvalho Chehab dvb_attach(tda18271_attach, dvb->fe[0], 0x60, 14264159d01bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 14274159d01bSMauro Carvalho Chehab &c3tech_duo_tda18271_config); 14284159d01bSMauro Carvalho Chehab break; 14298022f9afSAntti Palosaari case EM28174_BOARD_PCTV_460E: { 14308022f9afSAntti Palosaari struct i2c_client *client; 14318022f9afSAntti Palosaari struct i2c_board_info board_info; 14328022f9afSAntti Palosaari struct tda10071_platform_data tda10071_pdata = {}; 14338022f9afSAntti Palosaari struct a8293_platform_data a8293_pdata = {}; 14348022f9afSAntti Palosaari 14358022f9afSAntti Palosaari /* attach demod + tuner combo */ 14368022f9afSAntti Palosaari tda10071_pdata.clk = 40444000, /* 40.444 MHz */ 14378022f9afSAntti Palosaari tda10071_pdata.i2c_wr_max = 64, 14388022f9afSAntti Palosaari tda10071_pdata.ts_mode = TDA10071_TS_SERIAL, 14398022f9afSAntti Palosaari tda10071_pdata.pll_multiplier = 20, 14408022f9afSAntti Palosaari tda10071_pdata.tuner_i2c_addr = 0x14, 14418022f9afSAntti Palosaari memset(&board_info, 0, sizeof(board_info)); 14428022f9afSAntti Palosaari strlcpy(board_info.type, "tda10071_cx24118", I2C_NAME_SIZE); 14438022f9afSAntti Palosaari board_info.addr = 0x55; 14448022f9afSAntti Palosaari board_info.platform_data = &tda10071_pdata; 14458022f9afSAntti Palosaari request_module("tda10071"); 14468022f9afSAntti Palosaari client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info); 14478022f9afSAntti Palosaari if (client == NULL || client->dev.driver == NULL) { 14488022f9afSAntti Palosaari result = -ENODEV; 14498022f9afSAntti Palosaari goto out_free; 14508022f9afSAntti Palosaari } 14518022f9afSAntti Palosaari if (!try_module_get(client->dev.driver->owner)) { 14528022f9afSAntti Palosaari i2c_unregister_device(client); 14538022f9afSAntti Palosaari result = -ENODEV; 14548022f9afSAntti Palosaari goto out_free; 14558022f9afSAntti Palosaari } 14568022f9afSAntti Palosaari dvb->fe[0] = tda10071_pdata.get_dvb_frontend(client); 14578022f9afSAntti Palosaari dvb->i2c_client_demod = client; 14580c0d06caSMauro Carvalho Chehab 14590c0d06caSMauro Carvalho Chehab /* attach SEC */ 14608022f9afSAntti Palosaari a8293_pdata.dvb_frontend = dvb->fe[0]; 14618022f9afSAntti Palosaari memset(&board_info, 0, sizeof(board_info)); 14628022f9afSAntti Palosaari strlcpy(board_info.type, "a8293", I2C_NAME_SIZE); 14638022f9afSAntti Palosaari board_info.addr = 0x08; 14648022f9afSAntti Palosaari board_info.platform_data = &a8293_pdata; 14658022f9afSAntti Palosaari request_module("a8293"); 14668022f9afSAntti Palosaari client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info); 14678022f9afSAntti Palosaari if (client == NULL || client->dev.driver == NULL) { 14688022f9afSAntti Palosaari module_put(dvb->i2c_client_demod->dev.driver->owner); 14698022f9afSAntti Palosaari i2c_unregister_device(dvb->i2c_client_demod); 14708022f9afSAntti Palosaari result = -ENODEV; 14718022f9afSAntti Palosaari goto out_free; 14728022f9afSAntti Palosaari } 14738022f9afSAntti Palosaari if (!try_module_get(client->dev.driver->owner)) { 14748022f9afSAntti Palosaari i2c_unregister_device(client); 14758022f9afSAntti Palosaari module_put(dvb->i2c_client_demod->dev.driver->owner); 14768022f9afSAntti Palosaari i2c_unregister_device(dvb->i2c_client_demod); 14778022f9afSAntti Palosaari result = -ENODEV; 14788022f9afSAntti Palosaari goto out_free; 14798022f9afSAntti Palosaari } 14808022f9afSAntti Palosaari dvb->i2c_client_sec = client; 14810c0d06caSMauro Carvalho Chehab break; 14828022f9afSAntti Palosaari } 14837c1dfdb0SJakob Haufe case EM2874_BOARD_DELOCK_61959: 14840c0d06caSMauro Carvalho Chehab case EM2874_BOARD_MAXMEDIA_UB425_TC: 14850c0d06caSMauro Carvalho Chehab /* attach demodulator */ 14860c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(drxk_attach, &maxmedia_ub425_tc_drxk, 1487c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 14880c0d06caSMauro Carvalho Chehab 14890c0d06caSMauro Carvalho Chehab if (dvb->fe[0]) { 14900c0d06caSMauro Carvalho Chehab /* disable I2C-gate */ 14910c0d06caSMauro Carvalho Chehab dvb->fe[0]->ops.i2c_gate_ctrl = NULL; 14920c0d06caSMauro Carvalho Chehab 14930c0d06caSMauro Carvalho Chehab /* attach tuner */ 1494b6c7abb1SAntti Palosaari if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, 1495b6c7abb1SAntti Palosaari &dev->i2c_adap[dev->def_i2c_bus], 1496b6c7abb1SAntti Palosaari &em28xx_cxd2820r_tda18271_config)) { 14970c0d06caSMauro Carvalho Chehab dvb_frontend_detach(dvb->fe[0]); 14980c0d06caSMauro Carvalho Chehab result = -EINVAL; 14990c0d06caSMauro Carvalho Chehab goto out_free; 15000c0d06caSMauro Carvalho Chehab } 15010c0d06caSMauro Carvalho Chehab } 15020c0d06caSMauro Carvalho Chehab break; 15030c0d06caSMauro Carvalho Chehab case EM2884_BOARD_PCTV_510E: 15040c0d06caSMauro Carvalho Chehab case EM2884_BOARD_PCTV_520E: 15050c0d06caSMauro Carvalho Chehab pctv_520e_init(dev); 15060c0d06caSMauro Carvalho Chehab 15070c0d06caSMauro Carvalho Chehab /* attach demodulator */ 15080c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(drxk_attach, &pctv_520e_drxk, 1509c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 15100c0d06caSMauro Carvalho Chehab 15110c0d06caSMauro Carvalho Chehab if (dvb->fe[0]) { 15120c0d06caSMauro Carvalho Chehab /* attach tuner */ 15130c0d06caSMauro Carvalho Chehab if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, 1514c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 15150c0d06caSMauro Carvalho Chehab &em28xx_cxd2820r_tda18271_config)) { 15160c0d06caSMauro Carvalho Chehab dvb_frontend_detach(dvb->fe[0]); 15170c0d06caSMauro Carvalho Chehab result = -EINVAL; 15180c0d06caSMauro Carvalho Chehab goto out_free; 15190c0d06caSMauro Carvalho Chehab } 15200c0d06caSMauro Carvalho Chehab } 15210c0d06caSMauro Carvalho Chehab break; 15221fe0fbd6SGilles Risch case EM2884_BOARD_ELGATO_EYETV_HYBRID_2008: 15230c0d06caSMauro Carvalho Chehab case EM2884_BOARD_CINERGY_HTC_STICK: 1524d6a64327SMauro Carvalho Chehab case EM2884_BOARD_TERRATEC_H6: 15250c0d06caSMauro Carvalho Chehab terratec_htc_stick_init(dev); 15260c0d06caSMauro Carvalho Chehab 15270c0d06caSMauro Carvalho Chehab /* attach demodulator */ 15280c0d06caSMauro Carvalho Chehab dvb->fe[0] = dvb_attach(drxk_attach, &terratec_htc_stick_drxk, 1529c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 15300c0d06caSMauro Carvalho Chehab if (!dvb->fe[0]) { 15310c0d06caSMauro Carvalho Chehab result = -EINVAL; 15320c0d06caSMauro Carvalho Chehab goto out_free; 15330c0d06caSMauro Carvalho Chehab } 15340c0d06caSMauro Carvalho Chehab 15350c0d06caSMauro Carvalho Chehab /* Attach the demodulator. */ 15360c0d06caSMauro Carvalho Chehab if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, 1537c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 15380c0d06caSMauro Carvalho Chehab &em28xx_cxd2820r_tda18271_config)) { 15390c0d06caSMauro Carvalho Chehab result = -EINVAL; 15400c0d06caSMauro Carvalho Chehab goto out_free; 15410c0d06caSMauro Carvalho Chehab } 15420c0d06caSMauro Carvalho Chehab break; 154389040136SMartin Blumenstingl case EM2884_BOARD_TERRATEC_HTC_USB_XS: 154489040136SMartin Blumenstingl terratec_htc_usb_xs_init(dev); 154589040136SMartin Blumenstingl 154689040136SMartin Blumenstingl /* attach demodulator */ 154789040136SMartin Blumenstingl dvb->fe[0] = dvb_attach(drxk_attach, &terratec_htc_stick_drxk, 1548c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 154989040136SMartin Blumenstingl if (!dvb->fe[0]) { 155089040136SMartin Blumenstingl result = -EINVAL; 155189040136SMartin Blumenstingl goto out_free; 155289040136SMartin Blumenstingl } 155389040136SMartin Blumenstingl 155489040136SMartin Blumenstingl /* Attach the demodulator. */ 155589040136SMartin Blumenstingl if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, 1556c7a45e5bSMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus], 155789040136SMartin Blumenstingl &em28xx_cxd2820r_tda18271_config)) { 155889040136SMartin Blumenstingl result = -EINVAL; 155989040136SMartin Blumenstingl goto out_free; 156089040136SMartin Blumenstingl } 156189040136SMartin Blumenstingl break; 15626dbea9f0SJean-Francois Thibert case EM2874_BOARD_KWORLD_UB435Q_V2: 15636dbea9f0SJean-Francois Thibert dvb->fe[0] = dvb_attach(lgdt3305_attach, 15646dbea9f0SJean-Francois Thibert &em2874_lgdt3305_dev, 15656dbea9f0SJean-Francois Thibert &dev->i2c_adap[dev->def_i2c_bus]); 15666dbea9f0SJean-Francois Thibert if (!dvb->fe[0]) { 15676dbea9f0SJean-Francois Thibert result = -EINVAL; 15686dbea9f0SJean-Francois Thibert goto out_free; 15696dbea9f0SJean-Francois Thibert } 15706dbea9f0SJean-Francois Thibert 15716dbea9f0SJean-Francois Thibert /* Attach the demodulator. */ 15726dbea9f0SJean-Francois Thibert if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, 15736dbea9f0SJean-Francois Thibert &dev->i2c_adap[dev->def_i2c_bus], 15746dbea9f0SJean-Francois Thibert &kworld_ub435q_v2_config)) { 15756dbea9f0SJean-Francois Thibert result = -EINVAL; 15766dbea9f0SJean-Francois Thibert goto out_free; 15776dbea9f0SJean-Francois Thibert } 15786dbea9f0SJean-Francois Thibert break; 157902bc1f55SMauro Carvalho Chehab case EM2874_BOARD_KWORLD_UB435Q_V3: 1580ac7a24fbSAntti Palosaari { 1581ac7a24fbSAntti Palosaari struct i2c_client *client; 1582ac7a24fbSAntti Palosaari struct i2c_adapter *adapter = &dev->i2c_adap[dev->def_i2c_bus]; 1583ac7a24fbSAntti Palosaari struct i2c_board_info board_info = { 1584ac7a24fbSAntti Palosaari .type = "tda18212", 1585ac7a24fbSAntti Palosaari .addr = 0x60, 1586ac7a24fbSAntti Palosaari .platform_data = &kworld_ub435q_v3_config, 1587ac7a24fbSAntti Palosaari }; 1588ac7a24fbSAntti Palosaari 158902bc1f55SMauro Carvalho Chehab dvb->fe[0] = dvb_attach(lgdt3305_attach, 159002bc1f55SMauro Carvalho Chehab &em2874_lgdt3305_nogate_dev, 159102bc1f55SMauro Carvalho Chehab &dev->i2c_adap[dev->def_i2c_bus]); 159202bc1f55SMauro Carvalho Chehab if (!dvb->fe[0]) { 159302bc1f55SMauro Carvalho Chehab result = -EINVAL; 159402bc1f55SMauro Carvalho Chehab goto out_free; 159502bc1f55SMauro Carvalho Chehab } 159602bc1f55SMauro Carvalho Chehab 1597ac7a24fbSAntti Palosaari /* attach tuner */ 1598ac7a24fbSAntti Palosaari kworld_ub435q_v3_config.fe = dvb->fe[0]; 1599ac7a24fbSAntti Palosaari request_module("tda18212"); 1600ac7a24fbSAntti Palosaari client = i2c_new_device(adapter, &board_info); 1601ac7a24fbSAntti Palosaari if (client == NULL || client->dev.driver == NULL) { 1602ac7a24fbSAntti Palosaari dvb_frontend_detach(dvb->fe[0]); 1603ac7a24fbSAntti Palosaari result = -ENODEV; 160402bc1f55SMauro Carvalho Chehab goto out_free; 160502bc1f55SMauro Carvalho Chehab } 1606ac7a24fbSAntti Palosaari 1607ac7a24fbSAntti Palosaari if (!try_module_get(client->dev.driver->owner)) { 1608ac7a24fbSAntti Palosaari i2c_unregister_device(client); 1609ac7a24fbSAntti Palosaari dvb_frontend_detach(dvb->fe[0]); 1610ac7a24fbSAntti Palosaari result = -ENODEV; 1611ac7a24fbSAntti Palosaari goto out_free; 1612ac7a24fbSAntti Palosaari } 1613ac7a24fbSAntti Palosaari 1614ac7a24fbSAntti Palosaari dvb->i2c_client_tuner = client; 161502bc1f55SMauro Carvalho Chehab break; 1616ac7a24fbSAntti Palosaari } 161738b2df95SDevin Heitmueller case EM2874_BOARD_PCTV_HD_MINI_80E: 161838b2df95SDevin Heitmueller dvb->fe[0] = dvb_attach(drx39xxj_attach, &dev->i2c_adap[dev->def_i2c_bus]); 161938b2df95SDevin Heitmueller if (dvb->fe[0] != NULL) { 162038b2df95SDevin Heitmueller dvb->fe[0] = dvb_attach(tda18271_attach, dvb->fe[0], 0x60, 162138b2df95SDevin Heitmueller &dev->i2c_adap[dev->def_i2c_bus], 162238b2df95SDevin Heitmueller &pinnacle_80e_dvb_config); 162338b2df95SDevin Heitmueller if (!dvb->fe[0]) { 162438b2df95SDevin Heitmueller result = -EINVAL; 162538b2df95SDevin Heitmueller goto out_free; 162638b2df95SDevin Heitmueller } 162738b2df95SDevin Heitmueller } 162838b2df95SDevin Heitmueller break; 162976b91be3SAntti Palosaari case EM28178_BOARD_PCTV_461E: { 1630425f53aaSAntti Palosaari struct i2c_client *client; 163176b91be3SAntti Palosaari struct i2c_adapter *i2c_adapter; 163276b91be3SAntti Palosaari struct i2c_board_info board_info; 163376b91be3SAntti Palosaari struct m88ds3103_platform_data m88ds3103_pdata = {}; 163476b91be3SAntti Palosaari struct ts2020_config ts2020_config = {}; 163576b91be3SAntti Palosaari struct a8293_platform_data a8293_pdata = {}; 1636ec573362SAntti Palosaari 1637ec573362SAntti Palosaari /* attach demod */ 163876b91be3SAntti Palosaari m88ds3103_pdata.clk = 27000000; 163976b91be3SAntti Palosaari m88ds3103_pdata.i2c_wr_max = 33; 164076b91be3SAntti Palosaari m88ds3103_pdata.ts_mode = M88DS3103_TS_PARALLEL; 164176b91be3SAntti Palosaari m88ds3103_pdata.ts_clk = 16000; 164276b91be3SAntti Palosaari m88ds3103_pdata.ts_clk_pol = 1; 164376b91be3SAntti Palosaari m88ds3103_pdata.agc = 0x99; 164476b91be3SAntti Palosaari memset(&board_info, 0, sizeof(board_info)); 164576b91be3SAntti Palosaari strlcpy(board_info.type, "m88ds3103", I2C_NAME_SIZE); 164676b91be3SAntti Palosaari board_info.addr = 0x68; 164776b91be3SAntti Palosaari board_info.platform_data = &m88ds3103_pdata; 164876b91be3SAntti Palosaari request_module("m88ds3103"); 164976b91be3SAntti Palosaari client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info); 165076b91be3SAntti Palosaari if (client == NULL || client->dev.driver == NULL) { 1651ec573362SAntti Palosaari result = -ENODEV; 1652ec573362SAntti Palosaari goto out_free; 1653ec573362SAntti Palosaari } 165476b91be3SAntti Palosaari if (!try_module_get(client->dev.driver->owner)) { 165576b91be3SAntti Palosaari i2c_unregister_device(client); 165676b91be3SAntti Palosaari result = -ENODEV; 165776b91be3SAntti Palosaari goto out_free; 165876b91be3SAntti Palosaari } 165976b91be3SAntti Palosaari dvb->fe[0] = m88ds3103_pdata.get_dvb_frontend(client); 166076b91be3SAntti Palosaari i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client); 166176b91be3SAntti Palosaari dvb->i2c_client_demod = client; 1662ec573362SAntti Palosaari 1663ec573362SAntti Palosaari /* attach tuner */ 166483c1b6ceSAntti Palosaari ts2020_config.fe = dvb->fe[0]; 166576b91be3SAntti Palosaari memset(&board_info, 0, sizeof(board_info)); 166676b91be3SAntti Palosaari strlcpy(board_info.type, "ts2022", I2C_NAME_SIZE); 166776b91be3SAntti Palosaari board_info.addr = 0x60; 166876b91be3SAntti Palosaari board_info.platform_data = &ts2020_config; 166983c1b6ceSAntti Palosaari request_module("ts2020"); 167076b91be3SAntti Palosaari client = i2c_new_device(i2c_adapter, &board_info); 1671425f53aaSAntti Palosaari if (client == NULL || client->dev.driver == NULL) { 167276b91be3SAntti Palosaari module_put(dvb->i2c_client_demod->dev.driver->owner); 167376b91be3SAntti Palosaari i2c_unregister_device(dvb->i2c_client_demod); 1674425f53aaSAntti Palosaari result = -ENODEV; 1675425f53aaSAntti Palosaari goto out_free; 1676425f53aaSAntti Palosaari } 1677425f53aaSAntti Palosaari if (!try_module_get(client->dev.driver->owner)) { 1678425f53aaSAntti Palosaari i2c_unregister_device(client); 167976b91be3SAntti Palosaari module_put(dvb->i2c_client_demod->dev.driver->owner); 168076b91be3SAntti Palosaari i2c_unregister_device(dvb->i2c_client_demod); 1681425f53aaSAntti Palosaari result = -ENODEV; 1682425f53aaSAntti Palosaari goto out_free; 1683425f53aaSAntti Palosaari } 168476b91be3SAntti Palosaari dvb->i2c_client_tuner = client; 1685ec573362SAntti Palosaari /* delegate signal strength measurement to tuner */ 1686ec573362SAntti Palosaari dvb->fe[0]->ops.read_signal_strength = 1687ec573362SAntti Palosaari dvb->fe[0]->ops.tuner_ops.get_rf_strength; 1688ec573362SAntti Palosaari 1689ec573362SAntti Palosaari /* attach SEC */ 169076b91be3SAntti Palosaari a8293_pdata.dvb_frontend = dvb->fe[0]; 169176b91be3SAntti Palosaari memset(&board_info, 0, sizeof(board_info)); 169276b91be3SAntti Palosaari strlcpy(board_info.type, "a8293", I2C_NAME_SIZE); 169376b91be3SAntti Palosaari board_info.addr = 0x08; 169476b91be3SAntti Palosaari board_info.platform_data = &a8293_pdata; 169576b91be3SAntti Palosaari request_module("a8293"); 169676b91be3SAntti Palosaari client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info); 169776b91be3SAntti Palosaari if (client == NULL || client->dev.driver == NULL) { 169876b91be3SAntti Palosaari module_put(dvb->i2c_client_tuner->dev.driver->owner); 169976b91be3SAntti Palosaari i2c_unregister_device(dvb->i2c_client_tuner); 170076b91be3SAntti Palosaari module_put(dvb->i2c_client_demod->dev.driver->owner); 170176b91be3SAntti Palosaari i2c_unregister_device(dvb->i2c_client_demod); 1702ec573362SAntti Palosaari result = -ENODEV; 1703ec573362SAntti Palosaari goto out_free; 1704ec573362SAntti Palosaari } 170576b91be3SAntti Palosaari if (!try_module_get(client->dev.driver->owner)) { 170676b91be3SAntti Palosaari i2c_unregister_device(client); 170776b91be3SAntti Palosaari module_put(dvb->i2c_client_tuner->dev.driver->owner); 170876b91be3SAntti Palosaari i2c_unregister_device(dvb->i2c_client_tuner); 170976b91be3SAntti Palosaari module_put(dvb->i2c_client_demod->dev.driver->owner); 171076b91be3SAntti Palosaari i2c_unregister_device(dvb->i2c_client_demod); 171176b91be3SAntti Palosaari result = -ENODEV; 171276b91be3SAntti Palosaari goto out_free; 1713ec573362SAntti Palosaari } 171476b91be3SAntti Palosaari dvb->i2c_client_sec = client; 1715ec573362SAntti Palosaari break; 171676b91be3SAntti Palosaari } 171719229240SAntti Palosaari case EM28178_BOARD_PCTV_292E: 171819229240SAntti Palosaari { 171919229240SAntti Palosaari struct i2c_adapter *adapter; 172019229240SAntti Palosaari struct i2c_client *client; 172119229240SAntti Palosaari struct i2c_board_info info; 172219229240SAntti Palosaari struct si2168_config si2168_config; 172319229240SAntti Palosaari struct si2157_config si2157_config; 172419229240SAntti Palosaari 172519229240SAntti Palosaari /* attach demod */ 1726bf9025f3SOlli Salonen memset(&si2168_config, 0, sizeof(si2168_config)); 172719229240SAntti Palosaari si2168_config.i2c_adapter = &adapter; 172819229240SAntti Palosaari si2168_config.fe = &dvb->fe[0]; 17296fd2f44aSOlli Salonen si2168_config.ts_mode = SI2168_TS_PARALLEL; 173019229240SAntti Palosaari memset(&info, 0, sizeof(struct i2c_board_info)); 173119229240SAntti Palosaari strlcpy(info.type, "si2168", I2C_NAME_SIZE); 173219229240SAntti Palosaari info.addr = 0x64; 173319229240SAntti Palosaari info.platform_data = &si2168_config; 173419229240SAntti Palosaari request_module(info.type); 173519229240SAntti Palosaari client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info); 173619229240SAntti Palosaari if (client == NULL || client->dev.driver == NULL) { 173719229240SAntti Palosaari result = -ENODEV; 173819229240SAntti Palosaari goto out_free; 173919229240SAntti Palosaari } 174019229240SAntti Palosaari 174119229240SAntti Palosaari if (!try_module_get(client->dev.driver->owner)) { 174219229240SAntti Palosaari i2c_unregister_device(client); 174319229240SAntti Palosaari result = -ENODEV; 174419229240SAntti Palosaari goto out_free; 174519229240SAntti Palosaari } 174619229240SAntti Palosaari 174719229240SAntti Palosaari dvb->i2c_client_demod = client; 174819229240SAntti Palosaari 174919229240SAntti Palosaari /* attach tuner */ 1750c3b513bdSMatthias Schwarzott memset(&si2157_config, 0, sizeof(si2157_config)); 175119229240SAntti Palosaari si2157_config.fe = dvb->fe[0]; 1752ee3c3e46SOlli Salonen si2157_config.if_port = 1; 1753133bc4e4SMauro Carvalho Chehab #ifdef CONFIG_MEDIA_CONTROLLER_DVB 1754133bc4e4SMauro Carvalho Chehab si2157_config.mdev = dev->media_dev; 1755133bc4e4SMauro Carvalho Chehab #endif 175619229240SAntti Palosaari memset(&info, 0, sizeof(struct i2c_board_info)); 175719229240SAntti Palosaari strlcpy(info.type, "si2157", I2C_NAME_SIZE); 175819229240SAntti Palosaari info.addr = 0x60; 175919229240SAntti Palosaari info.platform_data = &si2157_config; 176019229240SAntti Palosaari request_module(info.type); 176119229240SAntti Palosaari client = i2c_new_device(adapter, &info); 176219229240SAntti Palosaari if (client == NULL || client->dev.driver == NULL) { 176319229240SAntti Palosaari module_put(dvb->i2c_client_demod->dev.driver->owner); 176419229240SAntti Palosaari i2c_unregister_device(dvb->i2c_client_demod); 176519229240SAntti Palosaari result = -ENODEV; 176619229240SAntti Palosaari goto out_free; 176719229240SAntti Palosaari } 176819229240SAntti Palosaari 176919229240SAntti Palosaari if (!try_module_get(client->dev.driver->owner)) { 177019229240SAntti Palosaari i2c_unregister_device(client); 177119229240SAntti Palosaari module_put(dvb->i2c_client_demod->dev.driver->owner); 177219229240SAntti Palosaari i2c_unregister_device(dvb->i2c_client_demod); 177319229240SAntti Palosaari result = -ENODEV; 177419229240SAntti Palosaari goto out_free; 177519229240SAntti Palosaari } 177619229240SAntti Palosaari 177719229240SAntti Palosaari dvb->i2c_client_tuner = client; 1778ffb9948eSAntti Palosaari dvb->fe[0]->ops.set_lna = em28xx_pctv_292e_set_lna; 177919229240SAntti Palosaari } 178019229240SAntti Palosaari break; 1781fc30dd76SOlli Salonen case EM28178_BOARD_TERRATEC_T2_STICK_HD: 1782fc30dd76SOlli Salonen { 1783fc30dd76SOlli Salonen struct i2c_adapter *adapter; 1784fc30dd76SOlli Salonen struct i2c_client *client; 1785fc30dd76SOlli Salonen struct i2c_board_info info; 1786fc30dd76SOlli Salonen struct si2168_config si2168_config; 1787fc30dd76SOlli Salonen struct si2157_config si2157_config; 1788fc30dd76SOlli Salonen 1789fc30dd76SOlli Salonen /* attach demod */ 1790fc30dd76SOlli Salonen memset(&si2168_config, 0, sizeof(si2168_config)); 1791fc30dd76SOlli Salonen si2168_config.i2c_adapter = &adapter; 1792fc30dd76SOlli Salonen si2168_config.fe = &dvb->fe[0]; 1793fc30dd76SOlli Salonen si2168_config.ts_mode = SI2168_TS_PARALLEL; 1794fc30dd76SOlli Salonen memset(&info, 0, sizeof(struct i2c_board_info)); 1795fc30dd76SOlli Salonen strlcpy(info.type, "si2168", I2C_NAME_SIZE); 1796fc30dd76SOlli Salonen info.addr = 0x64; 1797fc30dd76SOlli Salonen info.platform_data = &si2168_config; 1798fc30dd76SOlli Salonen request_module(info.type); 1799fc30dd76SOlli Salonen client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info); 1800fc30dd76SOlli Salonen if (client == NULL || client->dev.driver == NULL) { 1801fc30dd76SOlli Salonen result = -ENODEV; 1802fc30dd76SOlli Salonen goto out_free; 1803fc30dd76SOlli Salonen } 1804fc30dd76SOlli Salonen 1805fc30dd76SOlli Salonen if (!try_module_get(client->dev.driver->owner)) { 1806fc30dd76SOlli Salonen i2c_unregister_device(client); 1807fc30dd76SOlli Salonen result = -ENODEV; 1808fc30dd76SOlli Salonen goto out_free; 1809fc30dd76SOlli Salonen } 1810fc30dd76SOlli Salonen 1811fc30dd76SOlli Salonen dvb->i2c_client_demod = client; 1812fc30dd76SOlli Salonen 1813fc30dd76SOlli Salonen /* attach tuner */ 1814fc30dd76SOlli Salonen memset(&si2157_config, 0, sizeof(si2157_config)); 1815fc30dd76SOlli Salonen si2157_config.fe = dvb->fe[0]; 1816ee3c3e46SOlli Salonen si2157_config.if_port = 0; 1817133bc4e4SMauro Carvalho Chehab #ifdef CONFIG_MEDIA_CONTROLLER_DVB 1818133bc4e4SMauro Carvalho Chehab si2157_config.mdev = dev->media_dev; 1819133bc4e4SMauro Carvalho Chehab #endif 1820fc30dd76SOlli Salonen memset(&info, 0, sizeof(struct i2c_board_info)); 1821fc30dd76SOlli Salonen strlcpy(info.type, "si2146", I2C_NAME_SIZE); 1822fc30dd76SOlli Salonen info.addr = 0x60; 1823fc30dd76SOlli Salonen info.platform_data = &si2157_config; 1824fc30dd76SOlli Salonen request_module("si2157"); 1825fc30dd76SOlli Salonen client = i2c_new_device(adapter, &info); 1826fc30dd76SOlli Salonen if (client == NULL || client->dev.driver == NULL) { 1827fc30dd76SOlli Salonen module_put(dvb->i2c_client_demod->dev.driver->owner); 1828fc30dd76SOlli Salonen i2c_unregister_device(dvb->i2c_client_demod); 1829fc30dd76SOlli Salonen result = -ENODEV; 1830fc30dd76SOlli Salonen goto out_free; 1831fc30dd76SOlli Salonen } 1832fc30dd76SOlli Salonen 1833fc30dd76SOlli Salonen if (!try_module_get(client->dev.driver->owner)) { 1834fc30dd76SOlli Salonen i2c_unregister_device(client); 1835fc30dd76SOlli Salonen module_put(dvb->i2c_client_demod->dev.driver->owner); 1836fc30dd76SOlli Salonen i2c_unregister_device(dvb->i2c_client_demod); 1837fc30dd76SOlli Salonen result = -ENODEV; 1838fc30dd76SOlli Salonen goto out_free; 1839fc30dd76SOlli Salonen } 1840fc30dd76SOlli Salonen 1841fc30dd76SOlli Salonen dvb->i2c_client_tuner = client; 1842fc30dd76SOlli Salonen } 1843fc30dd76SOlli Salonen break; 1844ab4d1452SSatoshi Nagahama 1845ab4d1452SSatoshi Nagahama case EM28178_BOARD_PLEX_PX_BCUD: 1846ab4d1452SSatoshi Nagahama { 1847ab4d1452SSatoshi Nagahama struct i2c_client *client; 1848ab4d1452SSatoshi Nagahama struct i2c_board_info info; 1849ab4d1452SSatoshi Nagahama struct tc90522_config tc90522_config; 1850ab4d1452SSatoshi Nagahama struct qm1d1c0042_config qm1d1c0042_config; 1851ab4d1452SSatoshi Nagahama 1852ab4d1452SSatoshi Nagahama /* attach demod */ 1853ab4d1452SSatoshi Nagahama memset(&tc90522_config, 0, sizeof(tc90522_config)); 1854ab4d1452SSatoshi Nagahama memset(&info, 0, sizeof(struct i2c_board_info)); 1855ab4d1452SSatoshi Nagahama strlcpy(info.type, "tc90522sat", I2C_NAME_SIZE); 1856ab4d1452SSatoshi Nagahama info.addr = 0x15; 1857ab4d1452SSatoshi Nagahama info.platform_data = &tc90522_config; 1858ab4d1452SSatoshi Nagahama request_module("tc90522"); 1859ab4d1452SSatoshi Nagahama client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info); 1860ab4d1452SSatoshi Nagahama if (client == NULL || client->dev.driver == NULL) { 1861ab4d1452SSatoshi Nagahama result = -ENODEV; 1862ab4d1452SSatoshi Nagahama goto out_free; 1863ab4d1452SSatoshi Nagahama } 1864ab4d1452SSatoshi Nagahama dvb->i2c_client_demod = client; 1865ab4d1452SSatoshi Nagahama if (!try_module_get(client->dev.driver->owner)) { 1866ab4d1452SSatoshi Nagahama i2c_unregister_device(client); 1867ab4d1452SSatoshi Nagahama result = -ENODEV; 1868ab4d1452SSatoshi Nagahama goto out_free; 1869ab4d1452SSatoshi Nagahama } 1870ab4d1452SSatoshi Nagahama 1871ab4d1452SSatoshi Nagahama /* attach tuner */ 1872ab4d1452SSatoshi Nagahama memset(&qm1d1c0042_config, 0, 1873ab4d1452SSatoshi Nagahama sizeof(qm1d1c0042_config)); 1874ab4d1452SSatoshi Nagahama qm1d1c0042_config.fe = tc90522_config.fe; 1875ab4d1452SSatoshi Nagahama qm1d1c0042_config.lpf = 1; 1876ab4d1452SSatoshi Nagahama memset(&info, 0, sizeof(struct i2c_board_info)); 1877ab4d1452SSatoshi Nagahama strlcpy(info.type, "qm1d1c0042", I2C_NAME_SIZE); 1878ab4d1452SSatoshi Nagahama info.addr = 0x61; 1879ab4d1452SSatoshi Nagahama info.platform_data = &qm1d1c0042_config; 1880ab4d1452SSatoshi Nagahama request_module(info.type); 1881ab4d1452SSatoshi Nagahama client = i2c_new_device(tc90522_config.tuner_i2c, 1882ab4d1452SSatoshi Nagahama &info); 1883ab4d1452SSatoshi Nagahama if (client == NULL || client->dev.driver == NULL) { 1884ab4d1452SSatoshi Nagahama module_put(dvb->i2c_client_demod->dev.driver->owner); 1885ab4d1452SSatoshi Nagahama i2c_unregister_device(dvb->i2c_client_demod); 1886ab4d1452SSatoshi Nagahama result = -ENODEV; 1887ab4d1452SSatoshi Nagahama goto out_free; 1888ab4d1452SSatoshi Nagahama } 1889ab4d1452SSatoshi Nagahama dvb->i2c_client_tuner = client; 1890ab4d1452SSatoshi Nagahama if (!try_module_get(client->dev.driver->owner)) { 1891ab4d1452SSatoshi Nagahama i2c_unregister_device(client); 1892ab4d1452SSatoshi Nagahama module_put(dvb->i2c_client_demod->dev.driver->owner); 1893ab4d1452SSatoshi Nagahama i2c_unregister_device(dvb->i2c_client_demod); 1894ab4d1452SSatoshi Nagahama result = -ENODEV; 1895ab4d1452SSatoshi Nagahama goto out_free; 1896ab4d1452SSatoshi Nagahama } 1897ab4d1452SSatoshi Nagahama dvb->fe[0] = tc90522_config.fe; 1898ab4d1452SSatoshi Nagahama px_bcud_init(dev); 1899ab4d1452SSatoshi Nagahama } 1900ab4d1452SSatoshi Nagahama break; 190111a2a949SOlli Salonen case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB: 190211a2a949SOlli Salonen { 190311a2a949SOlli Salonen struct i2c_adapter *adapter; 190411a2a949SOlli Salonen struct i2c_client *client; 190511a2a949SOlli Salonen struct i2c_board_info info; 190611a2a949SOlli Salonen struct si2168_config si2168_config; 190711a2a949SOlli Salonen struct si2157_config si2157_config; 190811a2a949SOlli Salonen 190911a2a949SOlli Salonen /* attach demod */ 191011a2a949SOlli Salonen memset(&si2168_config, 0, sizeof(si2168_config)); 191111a2a949SOlli Salonen si2168_config.i2c_adapter = &adapter; 191211a2a949SOlli Salonen si2168_config.fe = &dvb->fe[0]; 191311a2a949SOlli Salonen si2168_config.ts_mode = SI2168_TS_SERIAL; 191411a2a949SOlli Salonen memset(&info, 0, sizeof(struct i2c_board_info)); 191511a2a949SOlli Salonen strlcpy(info.type, "si2168", I2C_NAME_SIZE); 1916*be7fd3c3SBrad Love if (dev->ts == PRIMARY_TS) 191711a2a949SOlli Salonen info.addr = 0x64; 1918*be7fd3c3SBrad Love else 1919*be7fd3c3SBrad Love info.addr = 0x67; 192011a2a949SOlli Salonen info.platform_data = &si2168_config; 192111a2a949SOlli Salonen request_module(info.type); 192211a2a949SOlli Salonen client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info); 192311a2a949SOlli Salonen if (client == NULL || client->dev.driver == NULL) { 192411a2a949SOlli Salonen result = -ENODEV; 192511a2a949SOlli Salonen goto out_free; 192611a2a949SOlli Salonen } 192711a2a949SOlli Salonen 192811a2a949SOlli Salonen if (!try_module_get(client->dev.driver->owner)) { 192911a2a949SOlli Salonen i2c_unregister_device(client); 193011a2a949SOlli Salonen result = -ENODEV; 193111a2a949SOlli Salonen goto out_free; 193211a2a949SOlli Salonen } 193311a2a949SOlli Salonen 193411a2a949SOlli Salonen dvb->i2c_client_demod = client; 193511a2a949SOlli Salonen 193611a2a949SOlli Salonen /* attach tuner */ 193711a2a949SOlli Salonen memset(&si2157_config, 0, sizeof(si2157_config)); 193811a2a949SOlli Salonen si2157_config.fe = dvb->fe[0]; 193911a2a949SOlli Salonen si2157_config.if_port = 1; 194011a2a949SOlli Salonen #ifdef CONFIG_MEDIA_CONTROLLER_DVB 194111a2a949SOlli Salonen si2157_config.mdev = dev->media_dev; 194211a2a949SOlli Salonen #endif 194311a2a949SOlli Salonen memset(&info, 0, sizeof(struct i2c_board_info)); 194411a2a949SOlli Salonen strlcpy(info.type, "si2157", I2C_NAME_SIZE); 1945*be7fd3c3SBrad Love if (dev->ts == PRIMARY_TS) 194611a2a949SOlli Salonen info.addr = 0x60; 1947*be7fd3c3SBrad Love else 1948*be7fd3c3SBrad Love info.addr = 0x63; 194911a2a949SOlli Salonen info.platform_data = &si2157_config; 195011a2a949SOlli Salonen request_module(info.type); 195111a2a949SOlli Salonen client = i2c_new_device(adapter, &info); 195211a2a949SOlli Salonen if (client == NULL || client->dev.driver == NULL) { 195311a2a949SOlli Salonen module_put(dvb->i2c_client_demod->dev.driver->owner); 195411a2a949SOlli Salonen i2c_unregister_device(dvb->i2c_client_demod); 195511a2a949SOlli Salonen result = -ENODEV; 195611a2a949SOlli Salonen goto out_free; 195711a2a949SOlli Salonen } 195811a2a949SOlli Salonen 195911a2a949SOlli Salonen if (!try_module_get(client->dev.driver->owner)) { 196011a2a949SOlli Salonen i2c_unregister_device(client); 196111a2a949SOlli Salonen module_put(dvb->i2c_client_demod->dev.driver->owner); 196211a2a949SOlli Salonen i2c_unregister_device(dvb->i2c_client_demod); 196311a2a949SOlli Salonen result = -ENODEV; 196411a2a949SOlli Salonen goto out_free; 196511a2a949SOlli Salonen } 196611a2a949SOlli Salonen 196711a2a949SOlli Salonen dvb->i2c_client_tuner = client; 196811a2a949SOlli Salonen 196911a2a949SOlli Salonen } 197011a2a949SOlli Salonen break; 19711586342eSKevin Cheng case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595: 19721586342eSKevin Cheng { 19731586342eSKevin Cheng struct i2c_adapter *adapter; 19741586342eSKevin Cheng struct i2c_client *client; 19751586342eSKevin Cheng struct i2c_board_info info = {}; 19761586342eSKevin Cheng struct lgdt3306a_config lgdt3306a_config; 19771586342eSKevin Cheng struct si2157_config si2157_config = {}; 19781586342eSKevin Cheng 19791586342eSKevin Cheng /* attach demod */ 19801586342eSKevin Cheng lgdt3306a_config = hauppauge_01595_lgdt3306a_config; 19811586342eSKevin Cheng lgdt3306a_config.fe = &dvb->fe[0]; 19821586342eSKevin Cheng lgdt3306a_config.i2c_adapter = &adapter; 19831586342eSKevin Cheng strlcpy(info.type, "lgdt3306a", sizeof(info.type)); 1984*be7fd3c3SBrad Love if (dev->ts == PRIMARY_TS) 19851586342eSKevin Cheng info.addr = 0x59; 1986*be7fd3c3SBrad Love else 1987*be7fd3c3SBrad Love info.addr = 0x0e; 19881586342eSKevin Cheng info.platform_data = &lgdt3306a_config; 19891586342eSKevin Cheng request_module(info.type); 19901586342eSKevin Cheng client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], 19911586342eSKevin Cheng &info); 19921586342eSKevin Cheng if (client == NULL || client->dev.driver == NULL) { 19931586342eSKevin Cheng result = -ENODEV; 19941586342eSKevin Cheng goto out_free; 19951586342eSKevin Cheng } 19961586342eSKevin Cheng 19971586342eSKevin Cheng if (!try_module_get(client->dev.driver->owner)) { 19981586342eSKevin Cheng i2c_unregister_device(client); 19991586342eSKevin Cheng result = -ENODEV; 20001586342eSKevin Cheng goto out_free; 20011586342eSKevin Cheng } 20021586342eSKevin Cheng 20031586342eSKevin Cheng dvb->i2c_client_demod = client; 20041586342eSKevin Cheng 20051586342eSKevin Cheng /* attach tuner */ 20061586342eSKevin Cheng si2157_config.fe = dvb->fe[0]; 20071586342eSKevin Cheng si2157_config.if_port = 1; 20081586342eSKevin Cheng si2157_config.inversion = 1; 20091586342eSKevin Cheng #ifdef CONFIG_MEDIA_CONTROLLER_DVB 20101586342eSKevin Cheng si2157_config.mdev = dev->media_dev; 20111586342eSKevin Cheng #endif 20121586342eSKevin Cheng memset(&info, 0, sizeof(struct i2c_board_info)); 20131586342eSKevin Cheng strlcpy(info.type, "si2157", sizeof(info.type)); 2014*be7fd3c3SBrad Love if (dev->ts == PRIMARY_TS) 20151586342eSKevin Cheng info.addr = 0x60; 2016*be7fd3c3SBrad Love else 2017*be7fd3c3SBrad Love info.addr = 0x62; 20181586342eSKevin Cheng info.platform_data = &si2157_config; 20191586342eSKevin Cheng request_module(info.type); 20201586342eSKevin Cheng 20211586342eSKevin Cheng client = i2c_new_device(adapter, &info); 20221586342eSKevin Cheng if (client == NULL || client->dev.driver == NULL) { 20231586342eSKevin Cheng module_put(dvb->i2c_client_demod->dev.driver->owner); 20241586342eSKevin Cheng i2c_unregister_device(dvb->i2c_client_demod); 20251586342eSKevin Cheng result = -ENODEV; 20261586342eSKevin Cheng goto out_free; 20271586342eSKevin Cheng } 20281586342eSKevin Cheng if (!try_module_get(client->dev.driver->owner)) { 20291586342eSKevin Cheng i2c_unregister_device(client); 20301586342eSKevin Cheng module_put(dvb->i2c_client_demod->dev.driver->owner); 20311586342eSKevin Cheng i2c_unregister_device(dvb->i2c_client_demod); 20321586342eSKevin Cheng result = -ENODEV; 20331586342eSKevin Cheng goto out_free; 20341586342eSKevin Cheng } 20351586342eSKevin Cheng 20361586342eSKevin Cheng dvb->i2c_client_tuner = client; 20371586342eSKevin Cheng } 20381586342eSKevin Cheng break; 20390c0d06caSMauro Carvalho Chehab default: 204029b05e22SMauro Carvalho Chehab dev_err(&dev->intf->dev, 2041ce8591ffSMauro Carvalho Chehab "The frontend of your DVB/ATSC card isn't supported yet\n"); 20420c0d06caSMauro Carvalho Chehab break; 20430c0d06caSMauro Carvalho Chehab } 20440c0d06caSMauro Carvalho Chehab if (NULL == dvb->fe[0]) { 204529b05e22SMauro Carvalho Chehab dev_err(&dev->intf->dev, "frontend initialization failed\n"); 20460c0d06caSMauro Carvalho Chehab result = -EINVAL; 20470c0d06caSMauro Carvalho Chehab goto out_free; 20480c0d06caSMauro Carvalho Chehab } 20490c0d06caSMauro Carvalho Chehab /* define general-purpose callback pointer */ 20500c0d06caSMauro Carvalho Chehab dvb->fe[0]->callback = em28xx_tuner_callback; 20510c0d06caSMauro Carvalho Chehab if (dvb->fe[1]) 20520c0d06caSMauro Carvalho Chehab dvb->fe[1]->callback = em28xx_tuner_callback; 20530c0d06caSMauro Carvalho Chehab 20540c0d06caSMauro Carvalho Chehab /* register everything */ 205529b05e22SMauro Carvalho Chehab result = em28xx_register_dvb(dvb, THIS_MODULE, dev, &dev->intf->dev); 20560c0d06caSMauro Carvalho Chehab 20570c0d06caSMauro Carvalho Chehab if (result < 0) 20580c0d06caSMauro Carvalho Chehab goto out_free; 20590c0d06caSMauro Carvalho Chehab 2060*be7fd3c3SBrad Love if (dev->dvb_xfer_bulk) { 2061*be7fd3c3SBrad Love dvb_alt = 0; 2062*be7fd3c3SBrad Love } else { /* isoc */ 2063*be7fd3c3SBrad Love dvb_alt = dev->dvb_alt_isoc; 2064*be7fd3c3SBrad Love } 2065*be7fd3c3SBrad Love 2066*be7fd3c3SBrad Love udev = interface_to_usbdev(dev->intf); 2067*be7fd3c3SBrad Love usb_set_interface(udev, dev->ifnum, dvb_alt); 206829b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "DVB extension successfully initialized\n"); 206947677e51SMauro Carvalho Chehab 207047677e51SMauro Carvalho Chehab kref_get(&dev->ref); 207147677e51SMauro Carvalho Chehab 20720c0d06caSMauro Carvalho Chehab ret: 20730c0d06caSMauro Carvalho Chehab em28xx_set_mode(dev, EM28XX_SUSPEND); 20740c0d06caSMauro Carvalho Chehab mutex_unlock(&dev->lock); 20750c0d06caSMauro Carvalho Chehab return result; 20760c0d06caSMauro Carvalho Chehab 20770c0d06caSMauro Carvalho Chehab out_free: 20780c0d06caSMauro Carvalho Chehab kfree(dvb); 20790c0d06caSMauro Carvalho Chehab dev->dvb = NULL; 20800c0d06caSMauro Carvalho Chehab goto ret; 20810c0d06caSMauro Carvalho Chehab } 20820c0d06caSMauro Carvalho Chehab 20830c0d06caSMauro Carvalho Chehab static inline void prevent_sleep(struct dvb_frontend_ops *ops) 20840c0d06caSMauro Carvalho Chehab { 20850c0d06caSMauro Carvalho Chehab ops->set_voltage = NULL; 20860c0d06caSMauro Carvalho Chehab ops->sleep = NULL; 20870c0d06caSMauro Carvalho Chehab ops->tuner_ops.sleep = NULL; 20880c0d06caSMauro Carvalho Chehab } 20890c0d06caSMauro Carvalho Chehab 20900c0d06caSMauro Carvalho Chehab static int em28xx_dvb_fini(struct em28xx *dev) 20910c0d06caSMauro Carvalho Chehab { 2092b45e34f2SMauro Carvalho Chehab struct em28xx_dvb *dvb; 2093b45e34f2SMauro Carvalho Chehab struct i2c_client *client; 2094b45e34f2SMauro Carvalho Chehab 2095822b8deaSMauro Carvalho Chehab if (dev->is_audio_only) { 2096822b8deaSMauro Carvalho Chehab /* Shouldn't initialize IR for this interface */ 2097822b8deaSMauro Carvalho Chehab return 0; 2098822b8deaSMauro Carvalho Chehab } 2099822b8deaSMauro Carvalho Chehab 21000c0d06caSMauro Carvalho Chehab if (!dev->board.has_dvb) { 21010c0d06caSMauro Carvalho Chehab /* This device does not support the extension */ 21020c0d06caSMauro Carvalho Chehab return 0; 21030c0d06caSMauro Carvalho Chehab } 21040c0d06caSMauro Carvalho Chehab 2105b45e34f2SMauro Carvalho Chehab if (!dev->dvb) 2106b45e34f2SMauro Carvalho Chehab return 0; 2107b45e34f2SMauro Carvalho Chehab 210829b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "Closing DVB extension\n"); 2109aa929ad7SMauro Carvalho Chehab 2110b45e34f2SMauro Carvalho Chehab dvb = dev->dvb; 21110c0d06caSMauro Carvalho Chehab 211227ba0dacSFrank Schaefer em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE); 211327ba0dacSFrank Schaefer 21142665c299SFrank Schaefer if (dev->disconnected) { 21150c0d06caSMauro Carvalho Chehab /* We cannot tell the device to sleep 21160c0d06caSMauro Carvalho Chehab * once it has been unplugged. */ 2117f68e35afSShuah Khan if (dvb->fe[0]) { 21180c0d06caSMauro Carvalho Chehab prevent_sleep(&dvb->fe[0]->ops); 2119f68e35afSShuah Khan dvb->fe[0]->exit = DVB_FE_DEVICE_REMOVED; 2120f68e35afSShuah Khan } 2121f68e35afSShuah Khan if (dvb->fe[1]) { 21220c0d06caSMauro Carvalho Chehab prevent_sleep(&dvb->fe[1]->ops); 2123f68e35afSShuah Khan dvb->fe[1]->exit = DVB_FE_DEVICE_REMOVED; 2124f68e35afSShuah Khan } 21250c0d06caSMauro Carvalho Chehab } 21260c0d06caSMauro Carvalho Chehab 2127910b0797SMatthias Schwarzott em28xx_unregister_dvb(dvb); 2128910b0797SMatthias Schwarzott 21297098f582SAntti Palosaari /* remove I2C SEC */ 21307098f582SAntti Palosaari client = dvb->i2c_client_sec; 21317098f582SAntti Palosaari if (client) { 21327098f582SAntti Palosaari module_put(client->dev.driver->owner); 21337098f582SAntti Palosaari i2c_unregister_device(client); 21347098f582SAntti Palosaari } 21357098f582SAntti Palosaari 2136425f53aaSAntti Palosaari /* remove I2C tuner */ 21377098f582SAntti Palosaari client = dvb->i2c_client_tuner; 2138425f53aaSAntti Palosaari if (client) { 2139425f53aaSAntti Palosaari module_put(client->dev.driver->owner); 2140425f53aaSAntti Palosaari i2c_unregister_device(client); 2141425f53aaSAntti Palosaari } 2142425f53aaSAntti Palosaari 214319229240SAntti Palosaari /* remove I2C demod */ 214419229240SAntti Palosaari client = dvb->i2c_client_demod; 214519229240SAntti Palosaari if (client) { 214619229240SAntti Palosaari module_put(client->dev.driver->owner); 214719229240SAntti Palosaari i2c_unregister_device(client); 214819229240SAntti Palosaari } 214919229240SAntti Palosaari 21500c0d06caSMauro Carvalho Chehab kfree(dvb); 21510c0d06caSMauro Carvalho Chehab dev->dvb = NULL; 215247677e51SMauro Carvalho Chehab kref_put(&dev->ref, em28xx_free_device); 21530c0d06caSMauro Carvalho Chehab 21540c0d06caSMauro Carvalho Chehab return 0; 21550c0d06caSMauro Carvalho Chehab } 21560c0d06caSMauro Carvalho Chehab 2157ca2b46daSShuah Khan static int em28xx_dvb_suspend(struct em28xx *dev) 2158ca2b46daSShuah Khan { 2159ca2b46daSShuah Khan int ret = 0; 2160ca2b46daSShuah Khan 2161ca2b46daSShuah Khan if (dev->is_audio_only) 2162ca2b46daSShuah Khan return 0; 2163ca2b46daSShuah Khan 2164ca2b46daSShuah Khan if (!dev->board.has_dvb) 2165ca2b46daSShuah Khan return 0; 2166ca2b46daSShuah Khan 216729b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "Suspending DVB extension\n"); 2168ca2b46daSShuah Khan if (dev->dvb) { 2169ca2b46daSShuah Khan struct em28xx_dvb *dvb = dev->dvb; 2170ca2b46daSShuah Khan 2171ca2b46daSShuah Khan if (dvb->fe[0]) { 2172ca2b46daSShuah Khan ret = dvb_frontend_suspend(dvb->fe[0]); 217329b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "fe0 suspend %d\n", ret); 2174ca2b46daSShuah Khan } 2175ca2b46daSShuah Khan if (dvb->fe[1]) { 2176ca2b46daSShuah Khan dvb_frontend_suspend(dvb->fe[1]); 217729b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "fe1 suspend %d\n", ret); 2178ca2b46daSShuah Khan } 2179ca2b46daSShuah Khan } 2180ca2b46daSShuah Khan 2181ca2b46daSShuah Khan return 0; 2182ca2b46daSShuah Khan } 2183ca2b46daSShuah Khan 2184ca2b46daSShuah Khan static int em28xx_dvb_resume(struct em28xx *dev) 2185ca2b46daSShuah Khan { 2186ca2b46daSShuah Khan int ret = 0; 2187ca2b46daSShuah Khan 2188ca2b46daSShuah Khan if (dev->is_audio_only) 2189ca2b46daSShuah Khan return 0; 2190ca2b46daSShuah Khan 2191ca2b46daSShuah Khan if (!dev->board.has_dvb) 2192ca2b46daSShuah Khan return 0; 2193ca2b46daSShuah Khan 219429b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "Resuming DVB extension\n"); 2195ca2b46daSShuah Khan if (dev->dvb) { 2196ca2b46daSShuah Khan struct em28xx_dvb *dvb = dev->dvb; 2197ca2b46daSShuah Khan 2198ca2b46daSShuah Khan if (dvb->fe[0]) { 2199ca2b46daSShuah Khan ret = dvb_frontend_resume(dvb->fe[0]); 220029b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "fe0 resume %d\n", ret); 2201ca2b46daSShuah Khan } 2202ca2b46daSShuah Khan 2203ca2b46daSShuah Khan if (dvb->fe[1]) { 2204ca2b46daSShuah Khan ret = dvb_frontend_resume(dvb->fe[1]); 220529b05e22SMauro Carvalho Chehab dev_info(&dev->intf->dev, "fe1 resume %d\n", ret); 2206ca2b46daSShuah Khan } 2207ca2b46daSShuah Khan } 2208ca2b46daSShuah Khan 2209ca2b46daSShuah Khan return 0; 2210ca2b46daSShuah Khan } 2211ca2b46daSShuah Khan 22120c0d06caSMauro Carvalho Chehab static struct em28xx_ops dvb_ops = { 22130c0d06caSMauro Carvalho Chehab .id = EM28XX_DVB, 22140c0d06caSMauro Carvalho Chehab .name = "Em28xx dvb Extension", 22150c0d06caSMauro Carvalho Chehab .init = em28xx_dvb_init, 22160c0d06caSMauro Carvalho Chehab .fini = em28xx_dvb_fini, 2217ca2b46daSShuah Khan .suspend = em28xx_dvb_suspend, 2218ca2b46daSShuah Khan .resume = em28xx_dvb_resume, 22190c0d06caSMauro Carvalho Chehab }; 22200c0d06caSMauro Carvalho Chehab 22210c0d06caSMauro Carvalho Chehab static int __init em28xx_dvb_register(void) 22220c0d06caSMauro Carvalho Chehab { 22230c0d06caSMauro Carvalho Chehab return em28xx_register_extension(&dvb_ops); 22240c0d06caSMauro Carvalho Chehab } 22250c0d06caSMauro Carvalho Chehab 22260c0d06caSMauro Carvalho Chehab static void __exit em28xx_dvb_unregister(void) 22270c0d06caSMauro Carvalho Chehab { 22280c0d06caSMauro Carvalho Chehab em28xx_unregister_extension(&dvb_ops); 22290c0d06caSMauro Carvalho Chehab } 22300c0d06caSMauro Carvalho Chehab 22310c0d06caSMauro Carvalho Chehab module_init(em28xx_dvb_register); 22320c0d06caSMauro Carvalho Chehab module_exit(em28xx_dvb_unregister); 2233