Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1 | /* |
| 2 | DVB device driver for em28xx |
| 3 | |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 4 | (c) 2008-2011 Mauro Carvalho Chehab <mchehab@infradead.org> |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 5 | |
Devin Heitmueller | bdfbf95 | 2008-04-17 21:38:27 -0300 | [diff] [blame] | 6 | (c) 2008 Devin Heitmueller <devin.heitmueller@gmail.com> |
| 7 | - Fixes for the driver to properly work with HVR-950 |
Devin Heitmueller | 4fd305b | 2008-06-04 13:43:46 -0300 | [diff] [blame] | 8 | - Fixes for the driver to properly work with Pinnacle PCTV HD Pro Stick |
Devin Heitmueller | e14b365 | 2008-07-26 11:04:33 -0300 | [diff] [blame] | 9 | - Fixes for the driver to properly work with AMD ATI TV Wonder HD 600 |
Devin Heitmueller | bdfbf95 | 2008-04-17 21:38:27 -0300 | [diff] [blame] | 10 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 11 | (c) 2008 Aidan Thornton <makosoft@googlemail.com> |
| 12 | |
| 13 | Based on cx88-dvb, saa7134-dvb and videobuf-dvb originally written by: |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 14 | (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> |
| 15 | (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] |
| 16 | |
| 17 | This program is free software; you can redistribute it and/or modify |
| 18 | it under the terms of the GNU General Public License as published by |
| 19 | the Free Software Foundation; either version 2 of the License. |
| 20 | */ |
| 21 | |
| 22 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 23 | #include <linux/slab.h> |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 24 | #include <linux/usb.h> |
| 25 | |
| 26 | #include "em28xx.h" |
| 27 | #include <media/v4l2-common.h> |
| 28 | #include <media/videobuf-vmalloc.h> |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 29 | #include <media/tuner.h> |
| 30 | #include "tuner-simple.h" |
Antti Palosaari | 1e8f31f | 2012-07-19 21:10:36 -0300 | [diff] [blame] | 31 | #include <linux/gpio.h> |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 32 | |
| 33 | #include "lgdt330x.h" |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 34 | #include "lgdt3305.h" |
Aidan Thornton | 7e6388a | 2008-04-17 21:40:03 -0300 | [diff] [blame] | 35 | #include "zl10353.h" |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 36 | #include "s5h1409.h" |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 37 | #include "mt352.h" |
| 38 | #include "mt352_priv.h" /* FIXME */ |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 39 | #include "tda1002x.h" |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 40 | #include "tda18271.h" |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 41 | #include "s921.h" |
Devin Heitmueller | 75e2b86 | 2011-03-13 02:01:02 -0300 | [diff] [blame] | 42 | #include "drxd.h" |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 43 | #include "cxd2820r.h" |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 44 | #include "tda18271c2dd.h" |
| 45 | #include "drxk.h" |
Antti Palosaari | 3658871 | 2011-08-01 01:15:30 -0300 | [diff] [blame] | 46 | #include "tda10071.h" |
| 47 | #include "a8293.h" |
Aivar Päkk | 1985f6f | 2011-12-11 18:15:00 -0300 | [diff] [blame] | 48 | #include "qt1010.h" |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 49 | |
| 50 | MODULE_DESCRIPTION("driver for em28xx based DVB cards"); |
| 51 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); |
| 52 | MODULE_LICENSE("GPL"); |
| 53 | |
| 54 | static unsigned int debug; |
| 55 | module_param(debug, int, 0644); |
| 56 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); |
| 57 | |
| 58 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 59 | |
| 60 | #define dprintk(level, fmt, arg...) do { \ |
| 61 | if (debug >= level) \ |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 62 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 63 | } while (0) |
| 64 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 65 | struct em28xx_dvb { |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 66 | struct dvb_frontend *fe[2]; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 67 | |
| 68 | /* feed count management */ |
| 69 | struct mutex lock; |
| 70 | int nfeeds; |
| 71 | |
| 72 | /* general boilerplate stuff */ |
| 73 | struct dvb_adapter adapter; |
| 74 | struct dvb_demux demux; |
| 75 | struct dmxdev dmxdev; |
| 76 | struct dmx_frontend fe_hw; |
| 77 | struct dmx_frontend fe_mem; |
| 78 | struct dvb_net net; |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 79 | |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 80 | /* Due to DRX-K - probably need changes */ |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 81 | int (*gate_ctrl)(struct dvb_frontend *, int); |
| 82 | struct semaphore pll_mutex; |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 83 | bool dont_attach_fe1; |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 84 | int lna_gpio; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | |
| 88 | static inline void print_err_status(struct em28xx *dev, |
| 89 | int packet, int status) |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 90 | { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 91 | char *errmsg = "Unknown"; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 92 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 93 | switch (status) { |
| 94 | case -ENOENT: |
| 95 | errmsg = "unlinked synchronuously"; |
| 96 | break; |
| 97 | case -ECONNRESET: |
| 98 | errmsg = "unlinked asynchronuously"; |
| 99 | break; |
| 100 | case -ENOSR: |
| 101 | errmsg = "Buffer error (overrun)"; |
| 102 | break; |
| 103 | case -EPIPE: |
| 104 | errmsg = "Stalled (device not responding)"; |
| 105 | break; |
| 106 | case -EOVERFLOW: |
| 107 | errmsg = "Babble (bad cable?)"; |
| 108 | break; |
| 109 | case -EPROTO: |
| 110 | errmsg = "Bit-stuff error (bad cable?)"; |
| 111 | break; |
| 112 | case -EILSEQ: |
| 113 | errmsg = "CRC/Timeout (could be anything)"; |
| 114 | break; |
| 115 | case -ETIME: |
| 116 | errmsg = "Device does not respond"; |
| 117 | break; |
| 118 | } |
| 119 | if (packet < 0) { |
| 120 | dprintk(1, "URB status %d [%s].\n", status, errmsg); |
| 121 | } else { |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 122 | dprintk(1, "URB packet %d, status %d [%s].\n", |
| 123 | packet, status, errmsg); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 124 | } |
| 125 | } |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 126 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 127 | static inline int em28xx_dvb_isoc_copy(struct em28xx *dev, struct urb *urb) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 128 | { |
| 129 | int i; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 130 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 131 | if (!dev) |
| 132 | return 0; |
| 133 | |
| 134 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) |
| 135 | return 0; |
| 136 | |
| 137 | if (urb->status < 0) { |
| 138 | print_err_status(dev, -1, urb->status); |
| 139 | if (urb->status == -ENOENT) |
| 140 | return 0; |
| 141 | } |
| 142 | |
| 143 | for (i = 0; i < urb->number_of_packets; i++) { |
| 144 | int status = urb->iso_frame_desc[i].status; |
| 145 | |
| 146 | if (status < 0) { |
| 147 | print_err_status(dev, i, status); |
| 148 | if (urb->iso_frame_desc[i].status != -EPROTO) |
| 149 | continue; |
| 150 | } |
| 151 | |
| 152 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer + |
| 153 | urb->iso_frame_desc[i].offset, |
| 154 | urb->iso_frame_desc[i].actual_length); |
| 155 | } |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 156 | |
| 157 | return 0; |
| 158 | } |
| 159 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 160 | static int em28xx_start_streaming(struct em28xx_dvb *dvb) |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 161 | { |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 162 | int rc; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 163 | struct em28xx *dev = dvb->adapter.priv; |
Devin Heitmueller | d18e2fd | 2009-05-16 17:09:28 -0300 | [diff] [blame] | 164 | int max_dvb_packet_size; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 165 | |
Holger Nelson | 8ab3362 | 2011-12-28 18:55:41 -0300 | [diff] [blame] | 166 | usb_set_interface(dev->udev, 0, dev->dvb_alt); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 167 | rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
| 168 | if (rc < 0) |
| 169 | return rc; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 170 | |
Holger Nelson | 8ab3362 | 2011-12-28 18:55:41 -0300 | [diff] [blame] | 171 | max_dvb_packet_size = dev->dvb_max_pkt_size; |
Mauro Carvalho Chehab | f7acc4b | 2011-07-28 15:42:00 -0300 | [diff] [blame] | 172 | if (max_dvb_packet_size < 0) |
| 173 | return max_dvb_packet_size; |
Gianluca Gennari | 86d38d1 | 2012-02-13 13:59:22 -0300 | [diff] [blame] | 174 | dprintk(1, "Using %d buffers each with %d x %d bytes\n", |
Mauro Carvalho Chehab | f7acc4b | 2011-07-28 15:42:00 -0300 | [diff] [blame] | 175 | EM28XX_DVB_NUM_BUFS, |
Frank Schaefer | 515688a | 2012-11-08 14:11:35 -0300 | [diff] [blame] | 176 | EM28XX_DVB_NUM_ISOC_PACKETS, |
Mauro Carvalho Chehab | f7acc4b | 2011-07-28 15:42:00 -0300 | [diff] [blame] | 177 | max_dvb_packet_size); |
Devin Heitmueller | d18e2fd | 2009-05-16 17:09:28 -0300 | [diff] [blame] | 178 | |
Gianluca Gennari | 86d38d1 | 2012-02-13 13:59:22 -0300 | [diff] [blame] | 179 | return em28xx_init_isoc(dev, EM28XX_DIGITAL_MODE, |
Frank Schaefer | 515688a | 2012-11-08 14:11:35 -0300 | [diff] [blame] | 180 | EM28XX_DVB_NUM_ISOC_PACKETS, |
| 181 | EM28XX_DVB_NUM_BUFS, |
Gianluca Gennari | 86d38d1 | 2012-02-13 13:59:22 -0300 | [diff] [blame] | 182 | max_dvb_packet_size, em28xx_dvb_isoc_copy); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 183 | } |
| 184 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 185 | static int em28xx_stop_streaming(struct em28xx_dvb *dvb) |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 186 | { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 187 | struct em28xx *dev = dvb->adapter.priv; |
| 188 | |
Gianluca Gennari | 5f5f147 | 2012-03-22 08:48:17 -0300 | [diff] [blame] | 189 | em28xx_stop_urbs(dev); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 190 | |
Mauro Carvalho Chehab | 2fe3e2e | 2008-11-27 09:10:40 -0300 | [diff] [blame] | 191 | em28xx_set_mode(dev, EM28XX_SUSPEND); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 192 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 193 | return 0; |
| 194 | } |
| 195 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 196 | static int em28xx_start_feed(struct dvb_demux_feed *feed) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 197 | { |
| 198 | struct dvb_demux *demux = feed->demux; |
| 199 | struct em28xx_dvb *dvb = demux->priv; |
| 200 | int rc, ret; |
| 201 | |
| 202 | if (!demux->dmx.frontend) |
| 203 | return -EINVAL; |
| 204 | |
| 205 | mutex_lock(&dvb->lock); |
| 206 | dvb->nfeeds++; |
| 207 | rc = dvb->nfeeds; |
| 208 | |
| 209 | if (dvb->nfeeds == 1) { |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 210 | ret = em28xx_start_streaming(dvb); |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 211 | if (ret < 0) |
| 212 | rc = ret; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | mutex_unlock(&dvb->lock); |
| 216 | return rc; |
| 217 | } |
| 218 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 219 | static int em28xx_stop_feed(struct dvb_demux_feed *feed) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 220 | { |
| 221 | struct dvb_demux *demux = feed->demux; |
| 222 | struct em28xx_dvb *dvb = demux->priv; |
| 223 | int err = 0; |
| 224 | |
| 225 | mutex_lock(&dvb->lock); |
| 226 | dvb->nfeeds--; |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 227 | |
| 228 | if (0 == dvb->nfeeds) |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 229 | err = em28xx_stop_streaming(dvb); |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 230 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 231 | mutex_unlock(&dvb->lock); |
| 232 | return err; |
| 233 | } |
| 234 | |
| 235 | |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 236 | |
| 237 | /* ------------------------------------------------------------------ */ |
| 238 | static int em28xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) |
| 239 | { |
| 240 | struct em28xx *dev = fe->dvb->priv; |
| 241 | |
| 242 | if (acquire) |
| 243 | return em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
| 244 | else |
Mauro Carvalho Chehab | 2fe3e2e | 2008-11-27 09:10:40 -0300 | [diff] [blame] | 245 | return em28xx_set_mode(dev, EM28XX_SUSPEND); |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 246 | } |
| 247 | |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 248 | /* ------------------------------------------------------------------ */ |
| 249 | |
Mauro Carvalho Chehab | 227ad4a | 2008-04-17 21:37:40 -0300 | [diff] [blame] | 250 | static struct lgdt330x_config em2880_lgdt3303_dev = { |
| 251 | .demod_address = 0x0e, |
| 252 | .demod_chip = LGDT3303, |
| 253 | }; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 254 | |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 255 | static struct lgdt3305_config em2870_lgdt3304_dev = { |
| 256 | .i2c_addr = 0x0e, |
| 257 | .demod_chip = LGDT3304, |
| 258 | .spectral_inversion = 1, |
| 259 | .deny_i2c_rptr = 1, |
| 260 | .mpeg_mode = LGDT3305_MPEG_PARALLEL, |
| 261 | .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, |
| 262 | .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, |
| 263 | .vsb_if_khz = 3250, |
| 264 | .qam_if_khz = 4000, |
| 265 | }; |
| 266 | |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 267 | static struct s921_config sharp_isdbt = { |
| 268 | .demod_address = 0x30 >> 1 |
| 269 | }; |
| 270 | |
Aidan Thornton | 7e6388a | 2008-04-17 21:40:03 -0300 | [diff] [blame] | 271 | static struct zl10353_config em28xx_zl10353_with_xc3028 = { |
| 272 | .demod_address = (0x1e >> 1), |
| 273 | .no_tuner = 1, |
| 274 | .parallel_ts = 1, |
| 275 | .if2 = 45600, |
| 276 | }; |
| 277 | |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 278 | static struct s5h1409_config em28xx_s5h1409_with_xc3028 = { |
| 279 | .demod_address = 0x32 >> 1, |
| 280 | .output_mode = S5H1409_PARALLEL_OUTPUT, |
| 281 | .gpio = S5H1409_GPIO_OFF, |
| 282 | .inversion = S5H1409_INVERSION_OFF, |
| 283 | .status_mode = S5H1409_DEMODLOCKING, |
| 284 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK |
| 285 | }; |
| 286 | |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 287 | static struct tda18271_std_map kworld_a340_std_map = { |
| 288 | .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 0, |
| 289 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 290 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 1, |
| 291 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 292 | }; |
| 293 | |
| 294 | static struct tda18271_config kworld_a340_config = { |
| 295 | .std_map = &kworld_a340_std_map, |
| 296 | }; |
| 297 | |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 298 | static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = { |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 299 | .demod_address = (0x1e >> 1), |
| 300 | .no_tuner = 1, |
| 301 | .disable_i2c_gate_ctrl = 1, |
| 302 | .parallel_ts = 1, |
| 303 | .if2 = 45600, |
| 304 | }; |
| 305 | |
Devin Heitmueller | 75e2b86 | 2011-03-13 02:01:02 -0300 | [diff] [blame] | 306 | static struct drxd_config em28xx_drxd = { |
Mauro Carvalho Chehab | aac865f | 2011-12-26 09:41:14 -0300 | [diff] [blame] | 307 | .demod_address = 0x70, |
| 308 | .demod_revision = 0xa2, |
| 309 | .pll_type = DRXD_PLL_NONE, |
| 310 | .clock = 12000, |
| 311 | .insert_rs_byte = 1, |
| 312 | .IF = 42800000, |
Devin Heitmueller | 6b142b3 | 2011-03-13 02:02:01 -0300 | [diff] [blame] | 313 | .disable_i2c_gate_ctrl = 1, |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 314 | }; |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 315 | |
Ezequiel García | 61bdbef | 2012-06-12 09:53:41 -0300 | [diff] [blame] | 316 | static struct drxk_config terratec_h5_drxk = { |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 317 | .adr = 0x29, |
Mauro Carvalho Chehab | e4f4f87 | 2011-07-09 17:35:26 -0300 | [diff] [blame] | 318 | .single_master = 1, |
Mauro Carvalho Chehab | f1fe1b7 | 2011-07-09 21:59:33 -0300 | [diff] [blame] | 319 | .no_i2c_bridge = 1, |
Mauro Carvalho Chehab | 8b9456a | 2011-07-11 14:33:51 -0300 | [diff] [blame] | 320 | .microcode_name = "dvb-usb-terratec-h5-drxk.fw", |
Martin Blumenstingl | 9e23f50a | 2012-07-04 17:36:55 -0300 | [diff] [blame] | 321 | .qam_demod_parameter_count = 2, |
Mauro Carvalho Chehab | 2425bb3 | 2012-10-02 16:02:57 -0300 | [diff] [blame] | 322 | .load_firmware_sync = true, |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 323 | }; |
| 324 | |
Ezequiel García | 61bdbef | 2012-06-12 09:53:41 -0300 | [diff] [blame] | 325 | static struct drxk_config hauppauge_930c_drxk = { |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 326 | .adr = 0x29, |
| 327 | .single_master = 1, |
| 328 | .no_i2c_bridge = 1, |
| 329 | .microcode_name = "dvb-usb-hauppauge-hvr930c-drxk.fw", |
| 330 | .chunk_size = 56, |
Martin Blumenstingl | 9e23f50a | 2012-07-04 17:36:55 -0300 | [diff] [blame] | 331 | .qam_demod_parameter_count = 2, |
Mauro Carvalho Chehab | 2425bb3 | 2012-10-02 16:02:57 -0300 | [diff] [blame] | 332 | .load_firmware_sync = true, |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 333 | }; |
| 334 | |
Martin Blumenstingl | 8904013 | 2012-10-04 14:22:54 -0300 | [diff] [blame] | 335 | static struct drxk_config terratec_htc_stick_drxk = { |
Martin Blumenstingl | c8dce00 | 2012-06-12 18:19:28 -0300 | [diff] [blame] | 336 | .adr = 0x29, |
| 337 | .single_master = 1, |
| 338 | .no_i2c_bridge = 1, |
| 339 | .microcode_name = "dvb-usb-terratec-htc-stick-drxk.fw", |
| 340 | .chunk_size = 54, |
Martin Blumenstingl | 9e23f50a | 2012-07-04 17:36:55 -0300 | [diff] [blame] | 341 | .qam_demod_parameter_count = 2, |
Martin Blumenstingl | c8dce00 | 2012-06-12 18:19:28 -0300 | [diff] [blame] | 342 | /* Required for the antenna_gpio to disable LNA. */ |
| 343 | .antenna_dvbt = true, |
| 344 | /* The windows driver uses the same. This will disable LNA. */ |
| 345 | .antenna_gpio = 0x6, |
Mauro Carvalho Chehab | 2425bb3 | 2012-10-02 16:02:57 -0300 | [diff] [blame] | 346 | .load_firmware_sync = true, |
Martin Blumenstingl | c8dce00 | 2012-06-12 18:19:28 -0300 | [diff] [blame] | 347 | }; |
| 348 | |
Ezequiel García | 61bdbef | 2012-06-12 09:53:41 -0300 | [diff] [blame] | 349 | static struct drxk_config maxmedia_ub425_tc_drxk = { |
Antti Palosaari | 3553085 | 2012-03-18 18:09:01 -0300 | [diff] [blame] | 350 | .adr = 0x29, |
| 351 | .single_master = 1, |
| 352 | .no_i2c_bridge = 1, |
Mauro Carvalho Chehab | 2425bb3 | 2012-10-02 16:02:57 -0300 | [diff] [blame] | 353 | .load_firmware_sync = true, |
Antti Palosaari | 3553085 | 2012-03-18 18:09:01 -0300 | [diff] [blame] | 354 | }; |
| 355 | |
Ezequiel García | 61bdbef | 2012-06-12 09:53:41 -0300 | [diff] [blame] | 356 | static struct drxk_config pctv_520e_drxk = { |
Antti Palosaari | c247d7b | 2012-03-19 11:48:19 -0300 | [diff] [blame] | 357 | .adr = 0x29, |
| 358 | .single_master = 1, |
| 359 | .microcode_name = "dvb-demod-drxk-pctv.fw", |
Martin Blumenstingl | 9e23f50a | 2012-07-04 17:36:55 -0300 | [diff] [blame] | 360 | .qam_demod_parameter_count = 2, |
Antti Palosaari | c247d7b | 2012-03-19 11:48:19 -0300 | [diff] [blame] | 361 | .chunk_size = 58, |
Antti Palosaari | f6f379d | 2012-05-17 19:09:06 -0300 | [diff] [blame] | 362 | .antenna_dvbt = true, /* disable LNA */ |
| 363 | .antenna_gpio = (1 << 2), /* disable LNA */ |
Mauro Carvalho Chehab | 2425bb3 | 2012-10-02 16:02:57 -0300 | [diff] [blame] | 364 | .load_firmware_sync = true, |
Antti Palosaari | c247d7b | 2012-03-19 11:48:19 -0300 | [diff] [blame] | 365 | }; |
| 366 | |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 367 | static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) |
| 368 | { |
| 369 | struct em28xx_dvb *dvb = fe->sec_priv; |
| 370 | int status; |
| 371 | |
| 372 | if (!dvb) |
| 373 | return -EINVAL; |
| 374 | |
| 375 | if (enable) { |
| 376 | down(&dvb->pll_mutex); |
| 377 | status = dvb->gate_ctrl(fe, 1); |
| 378 | } else { |
| 379 | status = dvb->gate_ctrl(fe, 0); |
| 380 | up(&dvb->pll_mutex); |
| 381 | } |
| 382 | return status; |
| 383 | } |
| 384 | |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 385 | static void hauppauge_hvr930c_init(struct em28xx *dev) |
| 386 | { |
| 387 | int i; |
| 388 | |
| 389 | struct em28xx_reg_seq hauppauge_hvr930c_init[] = { |
Mauro Carvalho Chehab | de72405 | 2011-11-20 11:23:24 -0200 | [diff] [blame] | 390 | {EM2874_R80_GPIO, 0xff, 0xff, 0x65}, |
| 391 | {EM2874_R80_GPIO, 0xfb, 0xff, 0x32}, |
| 392 | {EM2874_R80_GPIO, 0xff, 0xff, 0xb8}, |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 393 | { -1, -1, -1, -1}, |
| 394 | }; |
| 395 | struct em28xx_reg_seq hauppauge_hvr930c_end[] = { |
Mauro Carvalho Chehab | de72405 | 2011-11-20 11:23:24 -0200 | [diff] [blame] | 396 | {EM2874_R80_GPIO, 0xef, 0xff, 0x01}, |
| 397 | {EM2874_R80_GPIO, 0xaf, 0xff, 0x65}, |
| 398 | {EM2874_R80_GPIO, 0xef, 0xff, 0x76}, |
| 399 | {EM2874_R80_GPIO, 0xef, 0xff, 0x01}, |
| 400 | {EM2874_R80_GPIO, 0xcf, 0xff, 0x0b}, |
| 401 | {EM2874_R80_GPIO, 0xef, 0xff, 0x40}, |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 402 | |
Mauro Carvalho Chehab | de72405 | 2011-11-20 11:23:24 -0200 | [diff] [blame] | 403 | {EM2874_R80_GPIO, 0xcf, 0xff, 0x65}, |
| 404 | {EM2874_R80_GPIO, 0xef, 0xff, 0x65}, |
| 405 | {EM2874_R80_GPIO, 0xcf, 0xff, 0x0b}, |
| 406 | {EM2874_R80_GPIO, 0xef, 0xff, 0x65}, |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 407 | |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 408 | { -1, -1, -1, -1}, |
| 409 | }; |
| 410 | |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 411 | struct { |
| 412 | unsigned char r[4]; |
| 413 | int len; |
| 414 | } regs[] = { |
| 415 | {{ 0x06, 0x02, 0x00, 0x31 }, 4}, |
| 416 | {{ 0x01, 0x02 }, 2}, |
| 417 | {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, |
| 418 | {{ 0x01, 0x00 }, 2}, |
| 419 | {{ 0x01, 0x00, 0xff, 0xaf }, 4}, |
| 420 | {{ 0x01, 0x00, 0x03, 0xa0 }, 4}, |
| 421 | {{ 0x01, 0x00 }, 2}, |
| 422 | {{ 0x01, 0x00, 0x73, 0xaf }, 4}, |
| 423 | {{ 0x04, 0x00 }, 2}, |
| 424 | {{ 0x00, 0x04 }, 2}, |
| 425 | {{ 0x00, 0x04, 0x00, 0x0a }, 4}, |
| 426 | {{ 0x04, 0x14 }, 2}, |
| 427 | {{ 0x04, 0x14, 0x00, 0x00 }, 4}, |
| 428 | }; |
| 429 | |
| 430 | em28xx_gpio_set(dev, hauppauge_hvr930c_init); |
| 431 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); |
| 432 | msleep(10); |
| 433 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44); |
| 434 | msleep(10); |
| 435 | |
| 436 | dev->i2c_client.addr = 0x82 >> 1; |
| 437 | |
| 438 | for (i = 0; i < ARRAY_SIZE(regs); i++) |
| 439 | i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len); |
| 440 | em28xx_gpio_set(dev, hauppauge_hvr930c_end); |
| 441 | |
| 442 | msleep(100); |
| 443 | |
| 444 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44); |
| 445 | msleep(30); |
| 446 | |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 447 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x45); |
| 448 | msleep(10); |
| 449 | |
| 450 | } |
| 451 | |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 452 | static void terratec_h5_init(struct em28xx *dev) |
| 453 | { |
| 454 | int i; |
| 455 | struct em28xx_reg_seq terratec_h5_init[] = { |
| 456 | {EM28XX_R08_GPIO, 0xff, 0xff, 10}, |
| 457 | {EM2874_R80_GPIO, 0xf6, 0xff, 100}, |
| 458 | {EM2874_R80_GPIO, 0xf2, 0xff, 50}, |
| 459 | {EM2874_R80_GPIO, 0xf6, 0xff, 100}, |
| 460 | { -1, -1, -1, -1}, |
| 461 | }; |
| 462 | struct em28xx_reg_seq terratec_h5_end[] = { |
| 463 | {EM2874_R80_GPIO, 0xe6, 0xff, 100}, |
| 464 | {EM2874_R80_GPIO, 0xa6, 0xff, 50}, |
| 465 | {EM2874_R80_GPIO, 0xe6, 0xff, 100}, |
| 466 | { -1, -1, -1, -1}, |
| 467 | }; |
| 468 | struct { |
| 469 | unsigned char r[4]; |
| 470 | int len; |
| 471 | } regs[] = { |
| 472 | {{ 0x06, 0x02, 0x00, 0x31 }, 4}, |
| 473 | {{ 0x01, 0x02 }, 2}, |
| 474 | {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, |
| 475 | {{ 0x01, 0x00 }, 2}, |
| 476 | {{ 0x01, 0x00, 0xff, 0xaf }, 4}, |
| 477 | {{ 0x01, 0x00, 0x03, 0xa0 }, 4}, |
| 478 | {{ 0x01, 0x00 }, 2}, |
| 479 | {{ 0x01, 0x00, 0x73, 0xaf }, 4}, |
| 480 | {{ 0x04, 0x00 }, 2}, |
| 481 | {{ 0x00, 0x04 }, 2}, |
| 482 | {{ 0x00, 0x04, 0x00, 0x0a }, 4}, |
| 483 | {{ 0x04, 0x14 }, 2}, |
| 484 | {{ 0x04, 0x14, 0x00, 0x00 }, 4}, |
| 485 | }; |
| 486 | |
| 487 | em28xx_gpio_set(dev, terratec_h5_init); |
| 488 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); |
| 489 | msleep(10); |
| 490 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x45); |
| 491 | msleep(10); |
| 492 | |
| 493 | dev->i2c_client.addr = 0x82 >> 1; |
| 494 | |
| 495 | for (i = 0; i < ARRAY_SIZE(regs); i++) |
| 496 | i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len); |
| 497 | em28xx_gpio_set(dev, terratec_h5_end); |
| 498 | }; |
| 499 | |
Martin Blumenstingl | c8dce00 | 2012-06-12 18:19:28 -0300 | [diff] [blame] | 500 | static void terratec_htc_stick_init(struct em28xx *dev) |
| 501 | { |
| 502 | int i; |
| 503 | |
| 504 | /* |
| 505 | * GPIO configuration: |
| 506 | * 0xff: unknown (does not affect DVB-T). |
| 507 | * 0xf6: DRX-K (demodulator). |
| 508 | * 0xe6: unknown (does not affect DVB-T). |
| 509 | * 0xb6: unknown (does not affect DVB-T). |
| 510 | */ |
| 511 | struct em28xx_reg_seq terratec_htc_stick_init[] = { |
| 512 | {EM28XX_R08_GPIO, 0xff, 0xff, 10}, |
| 513 | {EM2874_R80_GPIO, 0xf6, 0xff, 100}, |
| 514 | {EM2874_R80_GPIO, 0xe6, 0xff, 50}, |
| 515 | {EM2874_R80_GPIO, 0xf6, 0xff, 100}, |
| 516 | { -1, -1, -1, -1}, |
| 517 | }; |
| 518 | struct em28xx_reg_seq terratec_htc_stick_end[] = { |
| 519 | {EM2874_R80_GPIO, 0xb6, 0xff, 100}, |
| 520 | {EM2874_R80_GPIO, 0xf6, 0xff, 50}, |
| 521 | { -1, -1, -1, -1}, |
| 522 | }; |
| 523 | |
Martin Blumenstingl | 8904013 | 2012-10-04 14:22:54 -0300 | [diff] [blame] | 524 | /* |
| 525 | * Init the analog decoder (not yet supported), but |
| 526 | * it's probably still a good idea. |
| 527 | */ |
Martin Blumenstingl | c8dce00 | 2012-06-12 18:19:28 -0300 | [diff] [blame] | 528 | struct { |
| 529 | unsigned char r[4]; |
| 530 | int len; |
| 531 | } regs[] = { |
| 532 | {{ 0x06, 0x02, 0x00, 0x31 }, 4}, |
| 533 | {{ 0x01, 0x02 }, 2}, |
| 534 | {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, |
| 535 | {{ 0x01, 0x00 }, 2}, |
| 536 | {{ 0x01, 0x00, 0xff, 0xaf }, 4}, |
| 537 | }; |
| 538 | |
| 539 | em28xx_gpio_set(dev, terratec_htc_stick_init); |
| 540 | |
| 541 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); |
| 542 | msleep(10); |
| 543 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44); |
| 544 | msleep(10); |
| 545 | |
| 546 | dev->i2c_client.addr = 0x82 >> 1; |
| 547 | |
| 548 | for (i = 0; i < ARRAY_SIZE(regs); i++) |
| 549 | i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len); |
| 550 | |
| 551 | em28xx_gpio_set(dev, terratec_htc_stick_end); |
| 552 | }; |
| 553 | |
Martin Blumenstingl | 8904013 | 2012-10-04 14:22:54 -0300 | [diff] [blame] | 554 | static void terratec_htc_usb_xs_init(struct em28xx *dev) |
| 555 | { |
| 556 | int i; |
| 557 | |
| 558 | struct em28xx_reg_seq terratec_htc_usb_xs_init[] = { |
| 559 | {EM28XX_R08_GPIO, 0xff, 0xff, 10}, |
| 560 | {EM2874_R80_GPIO, 0xb2, 0xff, 100}, |
| 561 | {EM2874_R80_GPIO, 0xb2, 0xff, 50}, |
| 562 | {EM2874_R80_GPIO, 0xb6, 0xff, 100}, |
| 563 | { -1, -1, -1, -1}, |
| 564 | }; |
| 565 | struct em28xx_reg_seq terratec_htc_usb_xs_end[] = { |
| 566 | {EM2874_R80_GPIO, 0xa6, 0xff, 100}, |
| 567 | {EM2874_R80_GPIO, 0xa6, 0xff, 50}, |
| 568 | {EM2874_R80_GPIO, 0xe6, 0xff, 100}, |
| 569 | { -1, -1, -1, -1}, |
| 570 | }; |
| 571 | |
| 572 | /* |
| 573 | * Init the analog decoder (not yet supported), but |
| 574 | * it's probably still a good idea. |
| 575 | */ |
| 576 | struct { |
| 577 | unsigned char r[4]; |
| 578 | int len; |
| 579 | } regs[] = { |
| 580 | {{ 0x06, 0x02, 0x00, 0x31 }, 4}, |
| 581 | {{ 0x01, 0x02 }, 2}, |
| 582 | {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, |
| 583 | {{ 0x01, 0x00 }, 2}, |
| 584 | {{ 0x01, 0x00, 0xff, 0xaf }, 4}, |
| 585 | {{ 0x01, 0x00, 0x03, 0xa0 }, 4}, |
| 586 | {{ 0x01, 0x00 }, 2}, |
| 587 | {{ 0x01, 0x00, 0x73, 0xaf }, 4}, |
| 588 | {{ 0x04, 0x00 }, 2}, |
| 589 | {{ 0x00, 0x04 }, 2}, |
| 590 | {{ 0x00, 0x04, 0x00, 0x0a }, 4}, |
| 591 | {{ 0x04, 0x14 }, 2}, |
| 592 | {{ 0x04, 0x14, 0x00, 0x00 }, 4}, |
| 593 | }; |
| 594 | |
| 595 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); |
| 596 | |
| 597 | em28xx_gpio_set(dev, terratec_htc_usb_xs_init); |
| 598 | |
| 599 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); |
| 600 | msleep(10); |
| 601 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44); |
| 602 | msleep(10); |
| 603 | |
| 604 | dev->i2c_client.addr = 0x82 >> 1; |
| 605 | |
| 606 | for (i = 0; i < ARRAY_SIZE(regs); i++) |
| 607 | i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len); |
| 608 | |
| 609 | em28xx_gpio_set(dev, terratec_htc_usb_xs_end); |
| 610 | }; |
| 611 | |
Antti Palosaari | c247d7b | 2012-03-19 11:48:19 -0300 | [diff] [blame] | 612 | static void pctv_520e_init(struct em28xx *dev) |
| 613 | { |
| 614 | /* |
Antti Palosaari | 26c8a72 | 2012-05-17 18:22:02 -0300 | [diff] [blame] | 615 | * Init AVF4910B analog decoder. Looks like I2C traffic to |
| 616 | * digital demodulator and tuner are routed via AVF4910B. |
Antti Palosaari | c247d7b | 2012-03-19 11:48:19 -0300 | [diff] [blame] | 617 | */ |
| 618 | int i; |
| 619 | struct { |
| 620 | unsigned char r[4]; |
| 621 | int len; |
| 622 | } regs[] = { |
| 623 | {{ 0x06, 0x02, 0x00, 0x31 }, 4}, |
| 624 | {{ 0x01, 0x02 }, 2}, |
| 625 | {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, |
| 626 | {{ 0x01, 0x00 }, 2}, |
| 627 | {{ 0x01, 0x00, 0xff, 0xaf }, 4}, |
| 628 | {{ 0x01, 0x00, 0x03, 0xa0 }, 4}, |
| 629 | {{ 0x01, 0x00 }, 2}, |
| 630 | {{ 0x01, 0x00, 0x73, 0xaf }, 4}, |
| 631 | }; |
| 632 | |
| 633 | dev->i2c_client.addr = 0x82 >> 1; /* 0x41 */ |
| 634 | |
| 635 | for (i = 0; i < ARRAY_SIZE(regs); i++) |
| 636 | i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len); |
| 637 | }; |
| 638 | |
Antti Palosaari | 33eebec | 2012-10-03 04:28:56 -0300 | [diff] [blame] | 639 | static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe) |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 640 | { |
Antti Palosaari | 33eebec | 2012-10-03 04:28:56 -0300 | [diff] [blame] | 641 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 642 | struct em28xx *dev = fe->dvb->priv; |
| 643 | #ifdef CONFIG_GPIOLIB |
| 644 | struct em28xx_dvb *dvb = dev->dvb; |
| 645 | int ret; |
| 646 | unsigned long flags; |
| 647 | |
Antti Palosaari | 33eebec | 2012-10-03 04:28:56 -0300 | [diff] [blame] | 648 | if (c->lna == 1) |
| 649 | flags = GPIOF_OUT_INIT_HIGH; /* enable LNA */ |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 650 | else |
Antti Palosaari | 33eebec | 2012-10-03 04:28:56 -0300 | [diff] [blame] | 651 | flags = GPIOF_OUT_INIT_LOW; /* disable LNA */ |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 652 | |
| 653 | ret = gpio_request_one(dvb->lna_gpio, flags, NULL); |
| 654 | if (ret) |
| 655 | em28xx_errdev("gpio request failed %d\n", ret); |
| 656 | else |
| 657 | gpio_free(dvb->lna_gpio); |
| 658 | |
| 659 | return ret; |
| 660 | #else |
Antti Palosaari | 33eebec | 2012-10-03 04:28:56 -0300 | [diff] [blame] | 661 | dev_warn(&dev->udev->dev, "%s: LNA control is disabled (lna=%u)\n", |
| 662 | KBUILD_MODNAME, c->lna); |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 663 | return 0; |
| 664 | #endif |
| 665 | } |
| 666 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 667 | static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe) |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 668 | { |
| 669 | /* Values extracted from a USB trace of the Terratec Windows driver */ |
| 670 | static u8 clock_config[] = { CLOCK_CTL, 0x38, 0x2c }; |
| 671 | static u8 reset[] = { RESET, 0x80 }; |
| 672 | static u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 }; |
| 673 | static u8 agc_cfg[] = { AGC_TARGET, 0x28, 0xa0 }; |
| 674 | static u8 input_freq_cfg[] = { INPUT_FREQ_1, 0x31, 0xb8 }; |
| 675 | static u8 rs_err_cfg[] = { RS_ERR_PER_1, 0x00, 0x4d }; |
| 676 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; |
| 677 | static u8 trl_nom_cfg[] = { TRL_NOMINAL_RATE_1, 0x64, 0x00 }; |
| 678 | static u8 tps_given_cfg[] = { TPS_GIVEN_1, 0x40, 0x80, 0x50 }; |
Devin Heitmueller | ff69786 | 2009-07-12 18:44:19 -0300 | [diff] [blame] | 679 | static u8 tuner_go[] = { TUNER_GO, 0x01}; |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 680 | |
| 681 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 682 | udelay(200); |
| 683 | mt352_write(fe, reset, sizeof(reset)); |
| 684 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 685 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 686 | mt352_write(fe, input_freq_cfg, sizeof(input_freq_cfg)); |
| 687 | mt352_write(fe, rs_err_cfg, sizeof(rs_err_cfg)); |
| 688 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 689 | mt352_write(fe, trl_nom_cfg, sizeof(trl_nom_cfg)); |
| 690 | mt352_write(fe, tps_given_cfg, sizeof(tps_given_cfg)); |
| 691 | mt352_write(fe, tuner_go, sizeof(tuner_go)); |
| 692 | return 0; |
| 693 | } |
| 694 | |
| 695 | static struct mt352_config terratec_xs_mt352_cfg = { |
| 696 | .demod_address = (0x1e >> 1), |
| 697 | .no_tuner = 1, |
| 698 | .if2 = 45600, |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 699 | .demod_init = em28xx_mt352_terratec_xs_init, |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 700 | }; |
| 701 | |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 702 | static struct tda10023_config em28xx_tda10023_config = { |
| 703 | .demod_address = 0x0c, |
| 704 | .invert = 1, |
| 705 | }; |
| 706 | |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 707 | static struct cxd2820r_config em28xx_cxd2820r_config = { |
| 708 | .i2c_address = (0xd8 >> 1), |
| 709 | .ts_mode = CXD2820R_TS_SERIAL, |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 710 | }; |
| 711 | |
| 712 | static struct tda18271_config em28xx_cxd2820r_tda18271_config = { |
| 713 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
Steve Kerrison | 0db4bf4 | 2011-08-09 07:16:21 -0300 | [diff] [blame] | 714 | .gate = TDA18271_GATE_DIGITAL, |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 715 | }; |
| 716 | |
Antti Palosaari | 3658871 | 2011-08-01 01:15:30 -0300 | [diff] [blame] | 717 | static const struct tda10071_config em28xx_tda10071_config = { |
Michael Krufky | 41f55d5 | 2012-12-16 19:37:11 -0300 | [diff] [blame] | 718 | .demod_i2c_addr = 0x55, /* (0xaa >> 1) */ |
| 719 | .tuner_i2c_addr = 0x14, |
Antti Palosaari | 3658871 | 2011-08-01 01:15:30 -0300 | [diff] [blame] | 720 | .i2c_wr_max = 64, |
| 721 | .ts_mode = TDA10071_TS_SERIAL, |
| 722 | .spec_inv = 0, |
| 723 | .xtal = 40444000, /* 40.444 MHz */ |
| 724 | .pll_multiplier = 20, |
| 725 | }; |
| 726 | |
| 727 | static const struct a8293_config em28xx_a8293_config = { |
| 728 | .i2c_addr = 0x08, /* (0x10 >> 1) */ |
| 729 | }; |
| 730 | |
Aivar Päkk | 1985f6f | 2011-12-11 18:15:00 -0300 | [diff] [blame] | 731 | static struct zl10353_config em28xx_zl10353_no_i2c_gate_dev = { |
| 732 | .demod_address = (0x1e >> 1), |
| 733 | .disable_i2c_gate_ctrl = 1, |
| 734 | .no_tuner = 1, |
| 735 | .parallel_ts = 1, |
| 736 | }; |
| 737 | static struct qt1010_config em28xx_qt1010_config = { |
| 738 | .i2c_address = 0x62 |
| 739 | |
| 740 | }; |
| 741 | |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 742 | /* ------------------------------------------------------------------ */ |
| 743 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 744 | static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev) |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 745 | { |
| 746 | struct dvb_frontend *fe; |
Mauro Carvalho Chehab | 3ca9c09 | 2008-04-17 21:37:53 -0300 | [diff] [blame] | 747 | struct xc2028_config cfg; |
| 748 | |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 749 | memset(&cfg, 0, sizeof(cfg)); |
Mauro Carvalho Chehab | 3ca9c09 | 2008-04-17 21:37:53 -0300 | [diff] [blame] | 750 | cfg.i2c_adap = &dev->i2c_adap; |
| 751 | cfg.i2c_addr = addr; |
Mauro Carvalho Chehab | 3ca9c09 | 2008-04-17 21:37:53 -0300 | [diff] [blame] | 752 | |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 753 | if (!dev->dvb->fe[0]) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 754 | em28xx_errdev("/2: dvb frontend not attached. " |
| 755 | "Can't attach xc3028\n"); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 756 | return -EINVAL; |
| 757 | } |
| 758 | |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 759 | fe = dvb_attach(xc2028_attach, dev->dvb->fe[0], &cfg); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 760 | if (!fe) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 761 | em28xx_errdev("/2: xc3028 attach failed\n"); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 762 | dvb_frontend_detach(dev->dvb->fe[0]); |
| 763 | dev->dvb->fe[0] = NULL; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 764 | return -EINVAL; |
| 765 | } |
| 766 | |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 767 | em28xx_info("%s/2: xc3028 attached\n", dev->name); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 768 | |
| 769 | return 0; |
| 770 | } |
| 771 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 772 | /* ------------------------------------------------------------------ */ |
| 773 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 774 | static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module, |
| 775 | struct em28xx *dev, struct device *device) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 776 | { |
| 777 | int result; |
| 778 | |
| 779 | mutex_init(&dvb->lock); |
| 780 | |
| 781 | /* register adapter */ |
| 782 | result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, |
| 783 | adapter_nr); |
| 784 | if (result < 0) { |
| 785 | printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", |
| 786 | dev->name, result); |
| 787 | goto fail_adapter; |
| 788 | } |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 789 | |
| 790 | /* Ensure all frontends negotiate bus access */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 791 | dvb->fe[0]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; |
| 792 | if (dvb->fe[1]) |
| 793 | dvb->fe[1]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 794 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 795 | dvb->adapter.priv = dev; |
| 796 | |
| 797 | /* register frontend */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 798 | result = dvb_register_frontend(&dvb->adapter, dvb->fe[0]); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 799 | if (result < 0) { |
| 800 | printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", |
| 801 | dev->name, result); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 802 | goto fail_frontend0; |
| 803 | } |
| 804 | |
| 805 | /* register 2nd frontend */ |
| 806 | if (dvb->fe[1]) { |
| 807 | result = dvb_register_frontend(&dvb->adapter, dvb->fe[1]); |
| 808 | if (result < 0) { |
| 809 | printk(KERN_WARNING "%s: 2nd dvb_register_frontend failed (errno = %d)\n", |
| 810 | dev->name, result); |
| 811 | goto fail_frontend1; |
| 812 | } |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | /* register demux stuff */ |
| 816 | dvb->demux.dmx.capabilities = |
| 817 | DMX_TS_FILTERING | DMX_SECTION_FILTERING | |
| 818 | DMX_MEMORY_BASED_FILTERING; |
| 819 | dvb->demux.priv = dvb; |
| 820 | dvb->demux.filternum = 256; |
| 821 | dvb->demux.feednum = 256; |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 822 | dvb->demux.start_feed = em28xx_start_feed; |
| 823 | dvb->demux.stop_feed = em28xx_stop_feed; |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 824 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 825 | result = dvb_dmx_init(&dvb->demux); |
| 826 | if (result < 0) { |
| 827 | printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", |
| 828 | dev->name, result); |
| 829 | goto fail_dmx; |
| 830 | } |
| 831 | |
| 832 | dvb->dmxdev.filternum = 256; |
| 833 | dvb->dmxdev.demux = &dvb->demux.dmx; |
| 834 | dvb->dmxdev.capabilities = 0; |
| 835 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); |
| 836 | if (result < 0) { |
| 837 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", |
| 838 | dev->name, result); |
| 839 | goto fail_dmxdev; |
| 840 | } |
| 841 | |
| 842 | dvb->fe_hw.source = DMX_FRONTEND_0; |
| 843 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 844 | if (result < 0) { |
| 845 | printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", |
| 846 | dev->name, result); |
| 847 | goto fail_fe_hw; |
| 848 | } |
| 849 | |
| 850 | dvb->fe_mem.source = DMX_MEMORY_FE; |
| 851 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
| 852 | if (result < 0) { |
| 853 | printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", |
| 854 | dev->name, result); |
| 855 | goto fail_fe_mem; |
| 856 | } |
| 857 | |
| 858 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 859 | if (result < 0) { |
| 860 | printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n", |
| 861 | dev->name, result); |
| 862 | goto fail_fe_conn; |
| 863 | } |
| 864 | |
| 865 | /* register network adapter */ |
| 866 | dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); |
| 867 | return 0; |
| 868 | |
| 869 | fail_fe_conn: |
| 870 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
| 871 | fail_fe_mem: |
| 872 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 873 | fail_fe_hw: |
| 874 | dvb_dmxdev_release(&dvb->dmxdev); |
| 875 | fail_dmxdev: |
| 876 | dvb_dmx_release(&dvb->demux); |
| 877 | fail_dmx: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 878 | if (dvb->fe[1]) |
| 879 | dvb_unregister_frontend(dvb->fe[1]); |
| 880 | dvb_unregister_frontend(dvb->fe[0]); |
| 881 | fail_frontend1: |
| 882 | if (dvb->fe[1]) |
| 883 | dvb_frontend_detach(dvb->fe[1]); |
| 884 | fail_frontend0: |
| 885 | dvb_frontend_detach(dvb->fe[0]); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 886 | dvb_unregister_adapter(&dvb->adapter); |
| 887 | fail_adapter: |
| 888 | return result; |
| 889 | } |
| 890 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 891 | static void em28xx_unregister_dvb(struct em28xx_dvb *dvb) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 892 | { |
| 893 | dvb_net_release(&dvb->net); |
| 894 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
| 895 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 896 | dvb_dmxdev_release(&dvb->dmxdev); |
| 897 | dvb_dmx_release(&dvb->demux); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 898 | if (dvb->fe[1]) |
| 899 | dvb_unregister_frontend(dvb->fe[1]); |
| 900 | dvb_unregister_frontend(dvb->fe[0]); |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 901 | if (dvb->fe[1] && !dvb->dont_attach_fe1) |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 902 | dvb_frontend_detach(dvb->fe[1]); |
| 903 | dvb_frontend_detach(dvb->fe[0]); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 904 | dvb_unregister_adapter(&dvb->adapter); |
| 905 | } |
| 906 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 907 | static int em28xx_dvb_init(struct em28xx *dev) |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 908 | { |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 909 | int result = 0, mfe_shared = 0; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 910 | struct em28xx_dvb *dvb; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 911 | |
Mauro Carvalho Chehab | 505b6d0 | 2008-11-25 09:39:50 -0300 | [diff] [blame] | 912 | if (!dev->board.has_dvb) { |
Devin Heitmueller | df61918 | 2008-06-10 12:34:35 -0300 | [diff] [blame] | 913 | /* This device does not support the extension */ |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 914 | printk(KERN_INFO "em28xx_dvb: This device does not support the extension\n"); |
Devin Heitmueller | df61918 | 2008-06-10 12:34:35 -0300 | [diff] [blame] | 915 | return 0; |
| 916 | } |
| 917 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 918 | dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 919 | |
| 920 | if (dvb == NULL) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 921 | em28xx_info("em28xx_dvb: memory allocation failed\n"); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 922 | return -ENOMEM; |
| 923 | } |
| 924 | dev->dvb = dvb; |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 925 | dvb->fe[0] = dvb->fe[1] = NULL; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 926 | |
Mauro Carvalho Chehab | 5013318 | 2010-04-07 17:07:58 -0300 | [diff] [blame] | 927 | mutex_lock(&dev->lock); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 928 | em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 929 | /* init frontend */ |
| 930 | switch (dev->model) { |
Mauro Carvalho Chehab | ebaefdb | 2011-06-01 10:16:25 -0300 | [diff] [blame] | 931 | case EM2874_BOARD_LEADERSHIP_ISDBT: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 932 | dvb->fe[0] = dvb_attach(s921_attach, |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 933 | &sharp_isdbt, &dev->i2c_adap); |
| 934 | |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 935 | if (!dvb->fe[0]) { |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 936 | result = -EINVAL; |
| 937 | goto out_free; |
| 938 | } |
| 939 | |
| 940 | break; |
Douglas Schilling Landgraf | f89bc32 | 2008-12-01 21:01:04 -0300 | [diff] [blame] | 941 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850: |
Mauro Carvalho Chehab | 10ac660 | 2008-07-27 14:58:58 -0300 | [diff] [blame] | 942 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: |
Devin Heitmueller | 4fd305b | 2008-06-04 13:43:46 -0300 | [diff] [blame] | 943 | case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: |
Devin Heitmueller | e14b365 | 2008-07-26 11:04:33 -0300 | [diff] [blame] | 944 | case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 945 | dvb->fe[0] = dvb_attach(lgdt330x_attach, |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 946 | &em2880_lgdt3303_dev, |
| 947 | &dev->i2c_adap); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 948 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 949 | result = -EINVAL; |
| 950 | goto out_free; |
| 951 | } |
Mauro Carvalho Chehab | 227ad4a | 2008-04-17 21:37:40 -0300 | [diff] [blame] | 952 | break; |
Thierry MERLE | 46510b5 | 2008-10-11 16:56:13 -0300 | [diff] [blame] | 953 | case EM2880_BOARD_KWORLD_DVB_310U: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 954 | dvb->fe[0] = dvb_attach(zl10353_attach, |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 955 | &em28xx_zl10353_with_xc3028, |
| 956 | &dev->i2c_adap); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 957 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 958 | result = -EINVAL; |
| 959 | goto out_free; |
| 960 | } |
Aidan Thornton | 7e6388a | 2008-04-17 21:40:03 -0300 | [diff] [blame] | 961 | break; |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 962 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: |
Uroš Vampl | ec994d0 | 2009-09-30 22:53:37 -0300 | [diff] [blame] | 963 | case EM2882_BOARD_TERRATEC_HYBRID_XS: |
Devin Heitmueller | 01a5fd6 | 2009-08-07 09:25:06 -0300 | [diff] [blame] | 964 | case EM2880_BOARD_EMPIRE_DUAL_TV: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 965 | dvb->fe[0] = dvb_attach(zl10353_attach, |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 966 | &em28xx_zl10353_xc3028_no_i2c_gate, |
| 967 | &dev->i2c_adap); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 968 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 969 | result = -EINVAL; |
| 970 | goto out_free; |
| 971 | } |
| 972 | break; |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 973 | case EM2880_BOARD_TERRATEC_HYBRID_XS: |
Catimimi | 6563801 | 2010-02-18 18:06:32 -0300 | [diff] [blame] | 974 | case EM2880_BOARD_TERRATEC_HYBRID_XS_FR: |
Devin Heitmueller | d5b3ba9 | 2009-07-08 21:51:35 -0300 | [diff] [blame] | 975 | case EM2881_BOARD_PINNACLE_HYBRID_PRO: |
Andrea.Amorosi76@gmail.com | 7ca7ef6 | 2010-02-09 17:53:38 -0300 | [diff] [blame] | 976 | case EM2882_BOARD_DIKOM_DK300: |
Antonio Larrosa | 811fab6 | 2010-03-04 22:19:48 -0300 | [diff] [blame] | 977 | case EM2882_BOARD_KWORLD_VS_DVBT: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 978 | dvb->fe[0] = dvb_attach(zl10353_attach, |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 979 | &em28xx_zl10353_xc3028_no_i2c_gate, |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 980 | &dev->i2c_adap); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 981 | if (dvb->fe[0] == NULL) { |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 982 | /* This board could have either a zl10353 or a mt352. |
| 983 | If the chip id isn't for zl10353, try mt352 */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 984 | dvb->fe[0] = dvb_attach(mt352_attach, |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 985 | &terratec_xs_mt352_cfg, |
| 986 | &dev->i2c_adap); |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 987 | } |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 988 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 989 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 990 | result = -EINVAL; |
| 991 | goto out_free; |
| 992 | } |
| 993 | break; |
Aivar Päkk | 1985f6f | 2011-12-11 18:15:00 -0300 | [diff] [blame] | 994 | case EM2870_BOARD_KWORLD_355U: |
| 995 | dvb->fe[0] = dvb_attach(zl10353_attach, |
| 996 | &em28xx_zl10353_no_i2c_gate_dev, |
| 997 | &dev->i2c_adap); |
| 998 | if (dvb->fe[0] != NULL) |
| 999 | dvb_attach(qt1010_attach, dvb->fe[0], |
| 1000 | &dev->i2c_adap, &em28xx_qt1010_config); |
| 1001 | break; |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 1002 | case EM2883_BOARD_KWORLD_HYBRID_330U: |
Devin Heitmueller | 1985922 | 2009-06-19 00:33:54 -0300 | [diff] [blame] | 1003 | case EM2882_BOARD_EVGA_INDTUBE: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1004 | dvb->fe[0] = dvb_attach(s5h1409_attach, |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 1005 | &em28xx_s5h1409_with_xc3028, |
| 1006 | &dev->i2c_adap); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 1007 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 1008 | result = -EINVAL; |
| 1009 | goto out_free; |
| 1010 | } |
| 1011 | break; |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 1012 | case EM2882_BOARD_KWORLD_ATSC_315U: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1013 | dvb->fe[0] = dvb_attach(lgdt330x_attach, |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 1014 | &em2880_lgdt3303_dev, |
| 1015 | &dev->i2c_adap); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1016 | if (dvb->fe[0] != NULL) { |
| 1017 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 1018 | &dev->i2c_adap, 0x61, TUNER_THOMSON_DTT761X)) { |
| 1019 | result = -EINVAL; |
| 1020 | goto out_free; |
| 1021 | } |
| 1022 | } |
| 1023 | break; |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 1024 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: |
Devin Heitmueller | ad9b4bb | 2011-03-13 02:09:59 -0300 | [diff] [blame] | 1025 | case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1026 | dvb->fe[0] = dvb_attach(drxd_attach, &em28xx_drxd, NULL, |
Devin Heitmueller | 75e2b86 | 2011-03-13 02:01:02 -0300 | [diff] [blame] | 1027 | &dev->i2c_adap, &dev->udev->dev); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 1028 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 1029 | result = -EINVAL; |
| 1030 | goto out_free; |
| 1031 | } |
| 1032 | break; |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 1033 | case EM2870_BOARD_REDDO_DVB_C_USB_BOX: |
| 1034 | /* Philips CU1216L NIM (Philips TDA10023 + Infineon TUA6034) */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1035 | dvb->fe[0] = dvb_attach(tda10023_attach, |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 1036 | &em28xx_tda10023_config, |
| 1037 | &dev->i2c_adap, 0x48); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1038 | if (dvb->fe[0]) { |
| 1039 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 1040 | &dev->i2c_adap, 0x60, TUNER_PHILIPS_CU1216L)) { |
| 1041 | result = -EINVAL; |
| 1042 | goto out_free; |
| 1043 | } |
| 1044 | } |
| 1045 | break; |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 1046 | case EM2870_BOARD_KWORLD_A340: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1047 | dvb->fe[0] = dvb_attach(lgdt3305_attach, |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 1048 | &em2870_lgdt3304_dev, |
| 1049 | &dev->i2c_adap); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1050 | if (dvb->fe[0] != NULL) |
| 1051 | dvb_attach(tda18271_attach, dvb->fe[0], 0x60, |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 1052 | &dev->i2c_adap, &kworld_a340_config); |
| 1053 | break; |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 1054 | case EM28174_BOARD_PCTV_290E: |
Antti Palosaari | a36a66d | 2012-08-16 21:07:23 -0300 | [diff] [blame] | 1055 | /* set default GPIO0 for LNA, used if GPIOLIB is undefined */ |
| 1056 | dvb->lna_gpio = CXD2820R_GPIO_E | CXD2820R_GPIO_O | |
| 1057 | CXD2820R_GPIO_L; |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 1058 | dvb->fe[0] = dvb_attach(cxd2820r_attach, |
Manu Abraham | 7e7b828 | 2011-12-10 00:44:24 -0300 | [diff] [blame] | 1059 | &em28xx_cxd2820r_config, |
Antti Palosaari | 1e8f31f | 2012-07-19 21:10:36 -0300 | [diff] [blame] | 1060 | &dev->i2c_adap, |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 1061 | &dvb->lna_gpio); |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 1062 | if (dvb->fe[0]) { |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 1063 | /* FE 0 attach tuner */ |
Manu Abraham | 7e7b828 | 2011-12-10 00:44:24 -0300 | [diff] [blame] | 1064 | if (!dvb_attach(tda18271_attach, |
| 1065 | dvb->fe[0], |
| 1066 | 0x60, |
| 1067 | &dev->i2c_adap, |
| 1068 | &em28xx_cxd2820r_tda18271_config)) { |
| 1069 | |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 1070 | dvb_frontend_detach(dvb->fe[0]); |
| 1071 | result = -EINVAL; |
| 1072 | goto out_free; |
| 1073 | } |
Antti Palosaari | 1e8f31f | 2012-07-19 21:10:36 -0300 | [diff] [blame] | 1074 | |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 1075 | #ifdef CONFIG_GPIOLIB |
Antti Palosaari | 0c42a55 | 2012-09-19 20:52:21 -0300 | [diff] [blame] | 1076 | /* enable LNA for DVB-T, DVB-T2 and DVB-C */ |
| 1077 | result = gpio_request_one(dvb->lna_gpio, |
| 1078 | GPIOF_OUT_INIT_LOW, NULL); |
| 1079 | if (result) |
| 1080 | em28xx_errdev("gpio request failed %d\n", |
| 1081 | result); |
| 1082 | else |
| 1083 | gpio_free(dvb->lna_gpio); |
Antti Palosaari | 1e8f31f | 2012-07-19 21:10:36 -0300 | [diff] [blame] | 1084 | |
Antti Palosaari | 0c42a55 | 2012-09-19 20:52:21 -0300 | [diff] [blame] | 1085 | result = 0; /* continue even set LNA fails */ |
Antti Palosaari | 13a5336 | 2012-07-19 22:28:56 -0300 | [diff] [blame] | 1086 | #endif |
Antti Palosaari | 0c42a55 | 2012-09-19 20:52:21 -0300 | [diff] [blame] | 1087 | dvb->fe[0]->ops.set_lna = em28xx_pctv_290e_set_lna; |
| 1088 | } |
| 1089 | |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 1090 | break; |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1091 | case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C: |
Mauro Carvalho Chehab | 8503232 | 2011-11-24 15:01:45 -0200 | [diff] [blame] | 1092 | { |
| 1093 | struct xc5000_config cfg; |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1094 | hauppauge_hvr930c_init(dev); |
| 1095 | |
Mauro Carvalho Chehab | de72405 | 2011-11-20 11:23:24 -0200 | [diff] [blame] | 1096 | dvb->fe[0] = dvb_attach(drxk_attach, |
Mauro Carvalho Chehab | fa4b2a1 | 2012-01-05 08:07:32 -0200 | [diff] [blame] | 1097 | &hauppauge_930c_drxk, &dev->i2c_adap); |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1098 | if (!dvb->fe[0]) { |
| 1099 | result = -EINVAL; |
| 1100 | goto out_free; |
| 1101 | } |
| 1102 | /* FIXME: do we need a pll semaphore? */ |
| 1103 | dvb->fe[0]->sec_priv = dvb; |
| 1104 | sema_init(&dvb->pll_mutex, 1); |
| 1105 | dvb->gate_ctrl = dvb->fe[0]->ops.i2c_gate_ctrl; |
| 1106 | dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl; |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1107 | |
| 1108 | /* Attach xc5000 */ |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1109 | memset(&cfg, 0, sizeof(cfg)); |
| 1110 | cfg.i2c_address = 0x61; |
Mauro Carvalho Chehab | de72405 | 2011-11-20 11:23:24 -0200 | [diff] [blame] | 1111 | cfg.if_khz = 4000; |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1112 | |
| 1113 | if (dvb->fe[0]->ops.i2c_gate_ctrl) |
| 1114 | dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 1); |
Mauro Carvalho Chehab | de72405 | 2011-11-20 11:23:24 -0200 | [diff] [blame] | 1115 | if (!dvb_attach(xc5000_attach, dvb->fe[0], &dev->i2c_adap, |
| 1116 | &cfg)) { |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1117 | result = -EINVAL; |
| 1118 | goto out_free; |
| 1119 | } |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1120 | if (dvb->fe[0]->ops.i2c_gate_ctrl) |
| 1121 | dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 0); |
| 1122 | |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1123 | break; |
Mauro Carvalho Chehab | 8503232 | 2011-11-24 15:01:45 -0200 | [diff] [blame] | 1124 | } |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 1125 | case EM2884_BOARD_TERRATEC_H5: |
| 1126 | terratec_h5_init(dev); |
| 1127 | |
Mauro Carvalho Chehab | fa4b2a1 | 2012-01-05 08:07:32 -0200 | [diff] [blame] | 1128 | dvb->fe[0] = dvb_attach(drxk_attach, &terratec_h5_drxk, &dev->i2c_adap); |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 1129 | if (!dvb->fe[0]) { |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 1130 | result = -EINVAL; |
| 1131 | goto out_free; |
| 1132 | } |
| 1133 | /* FIXME: do we need a pll semaphore? */ |
| 1134 | dvb->fe[0]->sec_priv = dvb; |
| 1135 | sema_init(&dvb->pll_mutex, 1); |
| 1136 | dvb->gate_ctrl = dvb->fe[0]->ops.i2c_gate_ctrl; |
| 1137 | dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl; |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 1138 | |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 1139 | /* Attach tda18271 to DVB-C frontend */ |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 1140 | if (dvb->fe[0]->ops.i2c_gate_ctrl) |
| 1141 | dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 1); |
| 1142 | if (!dvb_attach(tda18271c2dd_attach, dvb->fe[0], &dev->i2c_adap, 0x60)) { |
| 1143 | result = -EINVAL; |
| 1144 | goto out_free; |
| 1145 | } |
| 1146 | if (dvb->fe[0]->ops.i2c_gate_ctrl) |
| 1147 | dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 0); |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 1148 | |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 1149 | break; |
Antti Palosaari | 3658871 | 2011-08-01 01:15:30 -0300 | [diff] [blame] | 1150 | case EM28174_BOARD_PCTV_460E: |
| 1151 | /* attach demod */ |
| 1152 | dvb->fe[0] = dvb_attach(tda10071_attach, |
| 1153 | &em28xx_tda10071_config, &dev->i2c_adap); |
| 1154 | |
| 1155 | /* attach SEC */ |
| 1156 | if (dvb->fe[0]) |
| 1157 | dvb_attach(a8293_attach, dvb->fe[0], &dev->i2c_adap, |
| 1158 | &em28xx_a8293_config); |
| 1159 | break; |
Antti Palosaari | 3553085 | 2012-03-18 18:09:01 -0300 | [diff] [blame] | 1160 | case EM2874_BOARD_MAXMEDIA_UB425_TC: |
| 1161 | /* attach demodulator */ |
| 1162 | dvb->fe[0] = dvb_attach(drxk_attach, &maxmedia_ub425_tc_drxk, |
| 1163 | &dev->i2c_adap); |
| 1164 | |
| 1165 | if (dvb->fe[0]) { |
| 1166 | /* disable I2C-gate */ |
| 1167 | dvb->fe[0]->ops.i2c_gate_ctrl = NULL; |
| 1168 | |
| 1169 | /* attach tuner */ |
| 1170 | if (!dvb_attach(tda18271c2dd_attach, dvb->fe[0], |
| 1171 | &dev->i2c_adap, 0x60)) { |
| 1172 | dvb_frontend_detach(dvb->fe[0]); |
| 1173 | result = -EINVAL; |
| 1174 | goto out_free; |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | /* TODO: we need drx-3913k firmware in order to support DVB-T */ |
| 1179 | em28xx_info("MaxMedia UB425-TC: only DVB-C supported by that " \ |
| 1180 | "driver version\n"); |
| 1181 | |
| 1182 | break; |
Ivan Kalvachev | fa5527c | 2012-03-19 20:09:55 -0300 | [diff] [blame] | 1183 | case EM2884_BOARD_PCTV_510E: |
| 1184 | case EM2884_BOARD_PCTV_520E: |
| 1185 | pctv_520e_init(dev); |
| 1186 | |
| 1187 | /* attach demodulator */ |
| 1188 | dvb->fe[0] = dvb_attach(drxk_attach, &pctv_520e_drxk, |
| 1189 | &dev->i2c_adap); |
| 1190 | |
| 1191 | if (dvb->fe[0]) { |
| 1192 | /* attach tuner */ |
| 1193 | if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, |
| 1194 | &dev->i2c_adap, |
| 1195 | &em28xx_cxd2820r_tda18271_config)) { |
| 1196 | dvb_frontend_detach(dvb->fe[0]); |
| 1197 | result = -EINVAL; |
| 1198 | goto out_free; |
| 1199 | } |
| 1200 | } |
| 1201 | break; |
Martin Blumenstingl | c8dce00 | 2012-06-12 18:19:28 -0300 | [diff] [blame] | 1202 | case EM2884_BOARD_CINERGY_HTC_STICK: |
| 1203 | terratec_htc_stick_init(dev); |
| 1204 | |
| 1205 | /* attach demodulator */ |
| 1206 | dvb->fe[0] = dvb_attach(drxk_attach, &terratec_htc_stick_drxk, |
| 1207 | &dev->i2c_adap); |
| 1208 | if (!dvb->fe[0]) { |
| 1209 | result = -EINVAL; |
| 1210 | goto out_free; |
| 1211 | } |
| 1212 | |
| 1213 | /* Attach the demodulator. */ |
| 1214 | if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, |
| 1215 | &dev->i2c_adap, |
| 1216 | &em28xx_cxd2820r_tda18271_config)) { |
| 1217 | result = -EINVAL; |
| 1218 | goto out_free; |
| 1219 | } |
| 1220 | break; |
Martin Blumenstingl | 8904013 | 2012-10-04 14:22:54 -0300 | [diff] [blame] | 1221 | case EM2884_BOARD_TERRATEC_HTC_USB_XS: |
| 1222 | terratec_htc_usb_xs_init(dev); |
| 1223 | |
| 1224 | /* attach demodulator */ |
| 1225 | dvb->fe[0] = dvb_attach(drxk_attach, &terratec_htc_stick_drxk, |
| 1226 | &dev->i2c_adap); |
| 1227 | if (!dvb->fe[0]) { |
| 1228 | result = -EINVAL; |
| 1229 | goto out_free; |
| 1230 | } |
| 1231 | |
| 1232 | /* Attach the demodulator. */ |
| 1233 | if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, |
| 1234 | &dev->i2c_adap, |
| 1235 | &em28xx_cxd2820r_tda18271_config)) { |
| 1236 | result = -EINVAL; |
| 1237 | goto out_free; |
| 1238 | } |
| 1239 | break; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1240 | default: |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 1241 | em28xx_errdev("/2: The frontend of your DVB/ATSC card" |
| 1242 | " isn't supported yet\n"); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1243 | break; |
| 1244 | } |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1245 | if (NULL == dvb->fe[0]) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 1246 | em28xx_errdev("/2: frontend initialization failed\n"); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 1247 | result = -EINVAL; |
| 1248 | goto out_free; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1249 | } |
Michael Krufky | d7cba04 | 2008-09-12 13:31:45 -0300 | [diff] [blame] | 1250 | /* define general-purpose callback pointer */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 1251 | dvb->fe[0]->callback = em28xx_tuner_callback; |
Eddi De Pieri | 82e7dbb | 2011-11-19 11:37:14 -0300 | [diff] [blame] | 1252 | if (dvb->fe[1]) |
Mauro Carvalho Chehab | de72405 | 2011-11-20 11:23:24 -0200 | [diff] [blame] | 1253 | dvb->fe[1]->callback = em28xx_tuner_callback; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1254 | |
| 1255 | /* register everything */ |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 1256 | result = em28xx_register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 1257 | |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 1258 | if (result < 0) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 1259 | goto out_free; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 1260 | |
Antti Palosaari | e364543 | 2011-07-28 18:59:30 -0300 | [diff] [blame] | 1261 | /* MFE lock */ |
| 1262 | dvb->adapter.mfe_shared = mfe_shared; |
| 1263 | |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 1264 | em28xx_info("Successfully loaded em28xx-dvb\n"); |
Mauro Carvalho Chehab | 5013318 | 2010-04-07 17:07:58 -0300 | [diff] [blame] | 1265 | ret: |
| 1266 | em28xx_set_mode(dev, EM28XX_SUSPEND); |
| 1267 | mutex_unlock(&dev->lock); |
| 1268 | return result; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 1269 | |
| 1270 | out_free: |
| 1271 | kfree(dvb); |
| 1272 | dev->dvb = NULL; |
Mauro Carvalho Chehab | 5013318 | 2010-04-07 17:07:58 -0300 | [diff] [blame] | 1273 | goto ret; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1274 | } |
| 1275 | |
Chris Rankin | 0b8bd83 | 2011-08-20 16:01:26 -0300 | [diff] [blame] | 1276 | static inline void prevent_sleep(struct dvb_frontend_ops *ops) |
| 1277 | { |
| 1278 | ops->set_voltage = NULL; |
| 1279 | ops->sleep = NULL; |
| 1280 | ops->tuner_ops.sleep = NULL; |
| 1281 | } |
| 1282 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 1283 | static int em28xx_dvb_fini(struct em28xx *dev) |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1284 | { |
Mauro Carvalho Chehab | 505b6d0 | 2008-11-25 09:39:50 -0300 | [diff] [blame] | 1285 | if (!dev->board.has_dvb) { |
Devin Heitmueller | df61918 | 2008-06-10 12:34:35 -0300 | [diff] [blame] | 1286 | /* This device does not support the extension */ |
| 1287 | return 0; |
| 1288 | } |
| 1289 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 1290 | if (dev->dvb) { |
Chris Rankin | 0b8bd83 | 2011-08-20 16:01:26 -0300 | [diff] [blame] | 1291 | struct em28xx_dvb *dvb = dev->dvb; |
| 1292 | |
| 1293 | if (dev->state & DEV_DISCONNECTED) { |
| 1294 | /* We cannot tell the device to sleep |
| 1295 | * once it has been unplugged. */ |
| 1296 | if (dvb->fe[0]) |
| 1297 | prevent_sleep(&dvb->fe[0]->ops); |
| 1298 | if (dvb->fe[1]) |
| 1299 | prevent_sleep(&dvb->fe[1]->ops); |
| 1300 | } |
| 1301 | |
| 1302 | em28xx_unregister_dvb(dvb); |
| 1303 | kfree(dvb); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 1304 | dev->dvb = NULL; |
| 1305 | } |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1306 | |
| 1307 | return 0; |
| 1308 | } |
| 1309 | |
| 1310 | static struct em28xx_ops dvb_ops = { |
| 1311 | .id = EM28XX_DVB, |
| 1312 | .name = "Em28xx dvb Extension", |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame] | 1313 | .init = em28xx_dvb_init, |
| 1314 | .fini = em28xx_dvb_fini, |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1315 | }; |
| 1316 | |
| 1317 | static int __init em28xx_dvb_register(void) |
| 1318 | { |
| 1319 | return em28xx_register_extension(&dvb_ops); |
| 1320 | } |
| 1321 | |
| 1322 | static void __exit em28xx_dvb_unregister(void) |
| 1323 | { |
| 1324 | em28xx_unregister_extension(&dvb_ops); |
| 1325 | } |
| 1326 | |
| 1327 | module_init(em28xx_dvb_register); |
| 1328 | module_exit(em28xx_dvb_unregister); |