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" |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 31 | |
| 32 | #include "lgdt330x.h" |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 33 | #include "lgdt3305.h" |
Aidan Thornton | 7e6388a | 2008-04-17 21:40:03 -0300 | [diff] [blame] | 34 | #include "zl10353.h" |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 35 | #include "s5h1409.h" |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 36 | #include "mt352.h" |
| 37 | #include "mt352_priv.h" /* FIXME */ |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 38 | #include "tda1002x.h" |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 39 | #include "tda18271.h" |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 40 | #include "s921.h" |
Devin Heitmueller | 75e2b86 | 2011-03-13 02:01:02 -0300 | [diff] [blame] | 41 | #include "drxd.h" |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 42 | #include "cxd2820r.h" |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 43 | #include "tda18271c2dd.h" |
| 44 | #include "drxk.h" |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 45 | |
| 46 | MODULE_DESCRIPTION("driver for em28xx based DVB cards"); |
| 47 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); |
| 48 | MODULE_LICENSE("GPL"); |
| 49 | |
| 50 | static unsigned int debug; |
| 51 | module_param(debug, int, 0644); |
| 52 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); |
| 53 | |
| 54 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 55 | |
| 56 | #define dprintk(level, fmt, arg...) do { \ |
| 57 | if (debug >= level) \ |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 58 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 59 | } while (0) |
| 60 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 61 | #define EM28XX_DVB_NUM_BUFS 5 |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 62 | #define EM28XX_DVB_MAX_PACKETS 64 |
| 63 | |
| 64 | struct em28xx_dvb { |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 65 | struct dvb_frontend *fe[2]; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 66 | |
| 67 | /* feed count management */ |
| 68 | struct mutex lock; |
| 69 | int nfeeds; |
| 70 | |
| 71 | /* general boilerplate stuff */ |
| 72 | struct dvb_adapter adapter; |
| 73 | struct dvb_demux demux; |
| 74 | struct dmxdev dmxdev; |
| 75 | struct dmx_frontend fe_hw; |
| 76 | struct dmx_frontend fe_mem; |
| 77 | struct dvb_net net; |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 78 | |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 79 | /* Due to DRX-K - probably need changes */ |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 80 | int (*gate_ctrl)(struct dvb_frontend *, int); |
| 81 | struct semaphore pll_mutex; |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 82 | bool dont_attach_fe1; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | |
| 86 | static inline void print_err_status(struct em28xx *dev, |
| 87 | int packet, int status) |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 88 | { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 89 | char *errmsg = "Unknown"; |
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 | switch (status) { |
| 92 | case -ENOENT: |
| 93 | errmsg = "unlinked synchronuously"; |
| 94 | break; |
| 95 | case -ECONNRESET: |
| 96 | errmsg = "unlinked asynchronuously"; |
| 97 | break; |
| 98 | case -ENOSR: |
| 99 | errmsg = "Buffer error (overrun)"; |
| 100 | break; |
| 101 | case -EPIPE: |
| 102 | errmsg = "Stalled (device not responding)"; |
| 103 | break; |
| 104 | case -EOVERFLOW: |
| 105 | errmsg = "Babble (bad cable?)"; |
| 106 | break; |
| 107 | case -EPROTO: |
| 108 | errmsg = "Bit-stuff error (bad cable?)"; |
| 109 | break; |
| 110 | case -EILSEQ: |
| 111 | errmsg = "CRC/Timeout (could be anything)"; |
| 112 | break; |
| 113 | case -ETIME: |
| 114 | errmsg = "Device does not respond"; |
| 115 | break; |
| 116 | } |
| 117 | if (packet < 0) { |
| 118 | dprintk(1, "URB status %d [%s].\n", status, errmsg); |
| 119 | } else { |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 120 | dprintk(1, "URB packet %d, status %d [%s].\n", |
| 121 | packet, status, errmsg); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 122 | } |
| 123 | } |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 124 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 125 | 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] | 126 | { |
| 127 | int i; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 128 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 129 | if (!dev) |
| 130 | return 0; |
| 131 | |
| 132 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) |
| 133 | return 0; |
| 134 | |
| 135 | if (urb->status < 0) { |
| 136 | print_err_status(dev, -1, urb->status); |
| 137 | if (urb->status == -ENOENT) |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | for (i = 0; i < urb->number_of_packets; i++) { |
| 142 | int status = urb->iso_frame_desc[i].status; |
| 143 | |
| 144 | if (status < 0) { |
| 145 | print_err_status(dev, i, status); |
| 146 | if (urb->iso_frame_desc[i].status != -EPROTO) |
| 147 | continue; |
| 148 | } |
| 149 | |
| 150 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer + |
| 151 | urb->iso_frame_desc[i].offset, |
| 152 | urb->iso_frame_desc[i].actual_length); |
| 153 | } |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 154 | |
| 155 | return 0; |
| 156 | } |
| 157 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 158 | static int em28xx_start_streaming(struct em28xx_dvb *dvb) |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 159 | { |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 160 | int rc; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 161 | struct em28xx *dev = dvb->adapter.priv; |
Devin Heitmueller | d18e2fd | 2009-05-16 17:09:28 -0300 | [diff] [blame] | 162 | int max_dvb_packet_size; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 163 | |
| 164 | usb_set_interface(dev->udev, 0, 1); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 165 | rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
| 166 | if (rc < 0) |
| 167 | return rc; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 168 | |
Devin Heitmueller | d18e2fd | 2009-05-16 17:09:28 -0300 | [diff] [blame] | 169 | max_dvb_packet_size = em28xx_isoc_dvb_max_packetsize(dev); |
Mauro Carvalho Chehab | f7acc4b | 2011-07-28 15:42:00 -0300 | [diff] [blame] | 170 | if (max_dvb_packet_size < 0) |
| 171 | return max_dvb_packet_size; |
| 172 | dprintk(1, "Using %d buffers each with %d bytes\n", |
| 173 | EM28XX_DVB_NUM_BUFS, |
| 174 | max_dvb_packet_size); |
Devin Heitmueller | d18e2fd | 2009-05-16 17:09:28 -0300 | [diff] [blame] | 175 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 176 | return em28xx_init_isoc(dev, EM28XX_DVB_MAX_PACKETS, |
Devin Heitmueller | d18e2fd | 2009-05-16 17:09:28 -0300 | [diff] [blame] | 177 | EM28XX_DVB_NUM_BUFS, max_dvb_packet_size, |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 178 | em28xx_dvb_isoc_copy); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 179 | } |
| 180 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 181 | static int em28xx_stop_streaming(struct em28xx_dvb *dvb) |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 182 | { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 183 | struct em28xx *dev = dvb->adapter.priv; |
| 184 | |
| 185 | em28xx_uninit_isoc(dev); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 186 | |
Mauro Carvalho Chehab | 2fe3e2e | 2008-11-27 09:10:40 -0300 | [diff] [blame] | 187 | em28xx_set_mode(dev, EM28XX_SUSPEND); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 188 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 189 | return 0; |
| 190 | } |
| 191 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 192 | static int em28xx_start_feed(struct dvb_demux_feed *feed) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 193 | { |
| 194 | struct dvb_demux *demux = feed->demux; |
| 195 | struct em28xx_dvb *dvb = demux->priv; |
| 196 | int rc, ret; |
| 197 | |
| 198 | if (!demux->dmx.frontend) |
| 199 | return -EINVAL; |
| 200 | |
| 201 | mutex_lock(&dvb->lock); |
| 202 | dvb->nfeeds++; |
| 203 | rc = dvb->nfeeds; |
| 204 | |
| 205 | if (dvb->nfeeds == 1) { |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 206 | ret = em28xx_start_streaming(dvb); |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 207 | if (ret < 0) |
| 208 | rc = ret; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | mutex_unlock(&dvb->lock); |
| 212 | return rc; |
| 213 | } |
| 214 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 215 | static int em28xx_stop_feed(struct dvb_demux_feed *feed) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 216 | { |
| 217 | struct dvb_demux *demux = feed->demux; |
| 218 | struct em28xx_dvb *dvb = demux->priv; |
| 219 | int err = 0; |
| 220 | |
| 221 | mutex_lock(&dvb->lock); |
| 222 | dvb->nfeeds--; |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 223 | |
| 224 | if (0 == dvb->nfeeds) |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 225 | err = em28xx_stop_streaming(dvb); |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 226 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 227 | mutex_unlock(&dvb->lock); |
| 228 | return err; |
| 229 | } |
| 230 | |
| 231 | |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 232 | |
| 233 | /* ------------------------------------------------------------------ */ |
| 234 | static int em28xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) |
| 235 | { |
| 236 | struct em28xx *dev = fe->dvb->priv; |
| 237 | |
| 238 | if (acquire) |
| 239 | return em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
| 240 | else |
Mauro Carvalho Chehab | 2fe3e2e | 2008-11-27 09:10:40 -0300 | [diff] [blame] | 241 | return em28xx_set_mode(dev, EM28XX_SUSPEND); |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 242 | } |
| 243 | |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 244 | /* ------------------------------------------------------------------ */ |
| 245 | |
Mauro Carvalho Chehab | 227ad4a | 2008-04-17 21:37:40 -0300 | [diff] [blame] | 246 | static struct lgdt330x_config em2880_lgdt3303_dev = { |
| 247 | .demod_address = 0x0e, |
| 248 | .demod_chip = LGDT3303, |
| 249 | }; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 250 | |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 251 | static struct lgdt3305_config em2870_lgdt3304_dev = { |
| 252 | .i2c_addr = 0x0e, |
| 253 | .demod_chip = LGDT3304, |
| 254 | .spectral_inversion = 1, |
| 255 | .deny_i2c_rptr = 1, |
| 256 | .mpeg_mode = LGDT3305_MPEG_PARALLEL, |
| 257 | .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, |
| 258 | .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, |
| 259 | .vsb_if_khz = 3250, |
| 260 | .qam_if_khz = 4000, |
| 261 | }; |
| 262 | |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 263 | static struct s921_config sharp_isdbt = { |
| 264 | .demod_address = 0x30 >> 1 |
| 265 | }; |
| 266 | |
Aidan Thornton | 7e6388a | 2008-04-17 21:40:03 -0300 | [diff] [blame] | 267 | static struct zl10353_config em28xx_zl10353_with_xc3028 = { |
| 268 | .demod_address = (0x1e >> 1), |
| 269 | .no_tuner = 1, |
| 270 | .parallel_ts = 1, |
| 271 | .if2 = 45600, |
| 272 | }; |
| 273 | |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 274 | static struct s5h1409_config em28xx_s5h1409_with_xc3028 = { |
| 275 | .demod_address = 0x32 >> 1, |
| 276 | .output_mode = S5H1409_PARALLEL_OUTPUT, |
| 277 | .gpio = S5H1409_GPIO_OFF, |
| 278 | .inversion = S5H1409_INVERSION_OFF, |
| 279 | .status_mode = S5H1409_DEMODLOCKING, |
| 280 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK |
| 281 | }; |
| 282 | |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 283 | static struct tda18271_std_map kworld_a340_std_map = { |
| 284 | .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 0, |
| 285 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 286 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 1, |
| 287 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 288 | }; |
| 289 | |
| 290 | static struct tda18271_config kworld_a340_config = { |
| 291 | .std_map = &kworld_a340_std_map, |
| 292 | }; |
| 293 | |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 294 | static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = { |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 295 | .demod_address = (0x1e >> 1), |
| 296 | .no_tuner = 1, |
| 297 | .disable_i2c_gate_ctrl = 1, |
| 298 | .parallel_ts = 1, |
| 299 | .if2 = 45600, |
| 300 | }; |
| 301 | |
Devin Heitmueller | 75e2b86 | 2011-03-13 02:01:02 -0300 | [diff] [blame] | 302 | static struct drxd_config em28xx_drxd = { |
| 303 | .index = 0, .demod_address = 0x70, .demod_revision = 0xa2, |
| 304 | .demoda_address = 0x00, .pll_address = 0x00, |
| 305 | .pll_type = DRXD_PLL_NONE, .clock = 12000, .insert_rs_byte = 1, |
| 306 | .pll_set = NULL, .osc_deviation = NULL, .IF = 42800000, |
Devin Heitmueller | 6b142b3 | 2011-03-13 02:02:01 -0300 | [diff] [blame] | 307 | .disable_i2c_gate_ctrl = 1, |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 308 | }; |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 309 | |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 310 | struct drxk_config terratec_h5_drxk = { |
| 311 | .adr = 0x29, |
Mauro Carvalho Chehab | e4f4f87 | 2011-07-09 17:35:26 -0300 | [diff] [blame] | 312 | .single_master = 1, |
Mauro Carvalho Chehab | f1fe1b7 | 2011-07-09 21:59:33 -0300 | [diff] [blame] | 313 | .no_i2c_bridge = 1, |
Mauro Carvalho Chehab | 8b9456a | 2011-07-11 14:33:51 -0300 | [diff] [blame] | 314 | .microcode_name = "dvb-usb-terratec-h5-drxk.fw", |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 315 | }; |
| 316 | |
| 317 | static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) |
| 318 | { |
| 319 | struct em28xx_dvb *dvb = fe->sec_priv; |
| 320 | int status; |
| 321 | |
| 322 | if (!dvb) |
| 323 | return -EINVAL; |
| 324 | |
| 325 | if (enable) { |
| 326 | down(&dvb->pll_mutex); |
| 327 | status = dvb->gate_ctrl(fe, 1); |
| 328 | } else { |
| 329 | status = dvb->gate_ctrl(fe, 0); |
| 330 | up(&dvb->pll_mutex); |
| 331 | } |
| 332 | return status; |
| 333 | } |
| 334 | |
| 335 | static void terratec_h5_init(struct em28xx *dev) |
| 336 | { |
| 337 | int i; |
| 338 | struct em28xx_reg_seq terratec_h5_init[] = { |
| 339 | {EM28XX_R08_GPIO, 0xff, 0xff, 10}, |
| 340 | {EM2874_R80_GPIO, 0xf6, 0xff, 100}, |
| 341 | {EM2874_R80_GPIO, 0xf2, 0xff, 50}, |
| 342 | {EM2874_R80_GPIO, 0xf6, 0xff, 100}, |
| 343 | { -1, -1, -1, -1}, |
| 344 | }; |
| 345 | struct em28xx_reg_seq terratec_h5_end[] = { |
| 346 | {EM2874_R80_GPIO, 0xe6, 0xff, 100}, |
| 347 | {EM2874_R80_GPIO, 0xa6, 0xff, 50}, |
| 348 | {EM2874_R80_GPIO, 0xe6, 0xff, 100}, |
| 349 | { -1, -1, -1, -1}, |
| 350 | }; |
| 351 | struct { |
| 352 | unsigned char r[4]; |
| 353 | int len; |
| 354 | } regs[] = { |
| 355 | {{ 0x06, 0x02, 0x00, 0x31 }, 4}, |
| 356 | {{ 0x01, 0x02 }, 2}, |
| 357 | {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, |
| 358 | {{ 0x01, 0x00 }, 2}, |
| 359 | {{ 0x01, 0x00, 0xff, 0xaf }, 4}, |
| 360 | {{ 0x01, 0x00, 0x03, 0xa0 }, 4}, |
| 361 | {{ 0x01, 0x00 }, 2}, |
| 362 | {{ 0x01, 0x00, 0x73, 0xaf }, 4}, |
| 363 | {{ 0x04, 0x00 }, 2}, |
| 364 | {{ 0x00, 0x04 }, 2}, |
| 365 | {{ 0x00, 0x04, 0x00, 0x0a }, 4}, |
| 366 | {{ 0x04, 0x14 }, 2}, |
| 367 | {{ 0x04, 0x14, 0x00, 0x00 }, 4}, |
| 368 | }; |
| 369 | |
| 370 | em28xx_gpio_set(dev, terratec_h5_init); |
| 371 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); |
| 372 | msleep(10); |
| 373 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x45); |
| 374 | msleep(10); |
| 375 | |
| 376 | dev->i2c_client.addr = 0x82 >> 1; |
| 377 | |
| 378 | for (i = 0; i < ARRAY_SIZE(regs); i++) |
| 379 | i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len); |
| 380 | em28xx_gpio_set(dev, terratec_h5_end); |
| 381 | }; |
| 382 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 383 | static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe) |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 384 | { |
| 385 | /* Values extracted from a USB trace of the Terratec Windows driver */ |
| 386 | static u8 clock_config[] = { CLOCK_CTL, 0x38, 0x2c }; |
| 387 | static u8 reset[] = { RESET, 0x80 }; |
| 388 | static u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 }; |
| 389 | static u8 agc_cfg[] = { AGC_TARGET, 0x28, 0xa0 }; |
| 390 | static u8 input_freq_cfg[] = { INPUT_FREQ_1, 0x31, 0xb8 }; |
| 391 | static u8 rs_err_cfg[] = { RS_ERR_PER_1, 0x00, 0x4d }; |
| 392 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; |
| 393 | static u8 trl_nom_cfg[] = { TRL_NOMINAL_RATE_1, 0x64, 0x00 }; |
| 394 | static u8 tps_given_cfg[] = { TPS_GIVEN_1, 0x40, 0x80, 0x50 }; |
Devin Heitmueller | ff69786 | 2009-07-12 18:44:19 -0300 | [diff] [blame] | 395 | static u8 tuner_go[] = { TUNER_GO, 0x01}; |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 396 | |
| 397 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 398 | udelay(200); |
| 399 | mt352_write(fe, reset, sizeof(reset)); |
| 400 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 401 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 402 | mt352_write(fe, input_freq_cfg, sizeof(input_freq_cfg)); |
| 403 | mt352_write(fe, rs_err_cfg, sizeof(rs_err_cfg)); |
| 404 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 405 | mt352_write(fe, trl_nom_cfg, sizeof(trl_nom_cfg)); |
| 406 | mt352_write(fe, tps_given_cfg, sizeof(tps_given_cfg)); |
| 407 | mt352_write(fe, tuner_go, sizeof(tuner_go)); |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | static struct mt352_config terratec_xs_mt352_cfg = { |
| 412 | .demod_address = (0x1e >> 1), |
| 413 | .no_tuner = 1, |
| 414 | .if2 = 45600, |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 415 | .demod_init = em28xx_mt352_terratec_xs_init, |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 416 | }; |
| 417 | |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 418 | static struct tda10023_config em28xx_tda10023_config = { |
| 419 | .demod_address = 0x0c, |
| 420 | .invert = 1, |
| 421 | }; |
| 422 | |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 423 | static struct cxd2820r_config em28xx_cxd2820r_config = { |
| 424 | .i2c_address = (0xd8 >> 1), |
| 425 | .ts_mode = CXD2820R_TS_SERIAL, |
| 426 | .if_dvbt_6 = 3300, |
| 427 | .if_dvbt_7 = 3500, |
| 428 | .if_dvbt_8 = 4000, |
| 429 | .if_dvbt2_6 = 3300, |
| 430 | .if_dvbt2_7 = 3500, |
| 431 | .if_dvbt2_8 = 4000, |
| 432 | .if_dvbc = 5000, |
| 433 | |
| 434 | /* enable LNA for DVB-T2 and DVB-C */ |
| 435 | .gpio_dvbt2[0] = CXD2820R_GPIO_E | CXD2820R_GPIO_O | CXD2820R_GPIO_L, |
| 436 | .gpio_dvbc[0] = CXD2820R_GPIO_E | CXD2820R_GPIO_O | CXD2820R_GPIO_L, |
| 437 | }; |
| 438 | |
| 439 | static struct tda18271_config em28xx_cxd2820r_tda18271_config = { |
| 440 | .output_opt = TDA18271_OUTPUT_LT_OFF, |
| 441 | }; |
| 442 | |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 443 | /* ------------------------------------------------------------------ */ |
| 444 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 445 | static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev) |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 446 | { |
| 447 | struct dvb_frontend *fe; |
Mauro Carvalho Chehab | 3ca9c09 | 2008-04-17 21:37:53 -0300 | [diff] [blame] | 448 | struct xc2028_config cfg; |
| 449 | |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 450 | memset(&cfg, 0, sizeof(cfg)); |
Mauro Carvalho Chehab | 3ca9c09 | 2008-04-17 21:37:53 -0300 | [diff] [blame] | 451 | cfg.i2c_adap = &dev->i2c_adap; |
| 452 | cfg.i2c_addr = addr; |
Mauro Carvalho Chehab | 3ca9c09 | 2008-04-17 21:37:53 -0300 | [diff] [blame] | 453 | |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 454 | if (!dev->dvb->fe[0]) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 455 | em28xx_errdev("/2: dvb frontend not attached. " |
| 456 | "Can't attach xc3028\n"); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 457 | return -EINVAL; |
| 458 | } |
| 459 | |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 460 | fe = dvb_attach(xc2028_attach, dev->dvb->fe[0], &cfg); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 461 | if (!fe) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 462 | em28xx_errdev("/2: xc3028 attach failed\n"); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 463 | dvb_frontend_detach(dev->dvb->fe[0]); |
| 464 | dev->dvb->fe[0] = NULL; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 465 | return -EINVAL; |
| 466 | } |
| 467 | |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 468 | em28xx_info("%s/2: xc3028 attached\n", dev->name); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 469 | |
| 470 | return 0; |
| 471 | } |
| 472 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 473 | /* ------------------------------------------------------------------ */ |
| 474 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 475 | static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module, |
| 476 | struct em28xx *dev, struct device *device) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 477 | { |
| 478 | int result; |
| 479 | |
| 480 | mutex_init(&dvb->lock); |
| 481 | |
| 482 | /* register adapter */ |
| 483 | result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, |
| 484 | adapter_nr); |
| 485 | if (result < 0) { |
| 486 | printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", |
| 487 | dev->name, result); |
| 488 | goto fail_adapter; |
| 489 | } |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 490 | |
| 491 | /* Ensure all frontends negotiate bus access */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 492 | dvb->fe[0]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; |
| 493 | if (dvb->fe[1]) |
| 494 | dvb->fe[1]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 495 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 496 | dvb->adapter.priv = dev; |
| 497 | |
| 498 | /* register frontend */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 499 | result = dvb_register_frontend(&dvb->adapter, dvb->fe[0]); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 500 | if (result < 0) { |
| 501 | printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", |
| 502 | dev->name, result); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 503 | goto fail_frontend0; |
| 504 | } |
| 505 | |
| 506 | /* register 2nd frontend */ |
| 507 | if (dvb->fe[1]) { |
| 508 | result = dvb_register_frontend(&dvb->adapter, dvb->fe[1]); |
| 509 | if (result < 0) { |
| 510 | printk(KERN_WARNING "%s: 2nd dvb_register_frontend failed (errno = %d)\n", |
| 511 | dev->name, result); |
| 512 | goto fail_frontend1; |
| 513 | } |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | /* register demux stuff */ |
| 517 | dvb->demux.dmx.capabilities = |
| 518 | DMX_TS_FILTERING | DMX_SECTION_FILTERING | |
| 519 | DMX_MEMORY_BASED_FILTERING; |
| 520 | dvb->demux.priv = dvb; |
| 521 | dvb->demux.filternum = 256; |
| 522 | dvb->demux.feednum = 256; |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 523 | dvb->demux.start_feed = em28xx_start_feed; |
| 524 | dvb->demux.stop_feed = em28xx_stop_feed; |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 525 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 526 | result = dvb_dmx_init(&dvb->demux); |
| 527 | if (result < 0) { |
| 528 | printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", |
| 529 | dev->name, result); |
| 530 | goto fail_dmx; |
| 531 | } |
| 532 | |
| 533 | dvb->dmxdev.filternum = 256; |
| 534 | dvb->dmxdev.demux = &dvb->demux.dmx; |
| 535 | dvb->dmxdev.capabilities = 0; |
| 536 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); |
| 537 | if (result < 0) { |
| 538 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", |
| 539 | dev->name, result); |
| 540 | goto fail_dmxdev; |
| 541 | } |
| 542 | |
| 543 | dvb->fe_hw.source = DMX_FRONTEND_0; |
| 544 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 545 | if (result < 0) { |
| 546 | printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", |
| 547 | dev->name, result); |
| 548 | goto fail_fe_hw; |
| 549 | } |
| 550 | |
| 551 | dvb->fe_mem.source = DMX_MEMORY_FE; |
| 552 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
| 553 | if (result < 0) { |
| 554 | printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", |
| 555 | dev->name, result); |
| 556 | goto fail_fe_mem; |
| 557 | } |
| 558 | |
| 559 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 560 | if (result < 0) { |
| 561 | printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n", |
| 562 | dev->name, result); |
| 563 | goto fail_fe_conn; |
| 564 | } |
| 565 | |
| 566 | /* register network adapter */ |
| 567 | dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); |
| 568 | return 0; |
| 569 | |
| 570 | fail_fe_conn: |
| 571 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
| 572 | fail_fe_mem: |
| 573 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 574 | fail_fe_hw: |
| 575 | dvb_dmxdev_release(&dvb->dmxdev); |
| 576 | fail_dmxdev: |
| 577 | dvb_dmx_release(&dvb->demux); |
| 578 | fail_dmx: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 579 | if (dvb->fe[1]) |
| 580 | dvb_unregister_frontend(dvb->fe[1]); |
| 581 | dvb_unregister_frontend(dvb->fe[0]); |
| 582 | fail_frontend1: |
| 583 | if (dvb->fe[1]) |
| 584 | dvb_frontend_detach(dvb->fe[1]); |
| 585 | fail_frontend0: |
| 586 | dvb_frontend_detach(dvb->fe[0]); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 587 | dvb_unregister_adapter(&dvb->adapter); |
| 588 | fail_adapter: |
| 589 | return result; |
| 590 | } |
| 591 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 592 | static void em28xx_unregister_dvb(struct em28xx_dvb *dvb) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 593 | { |
| 594 | dvb_net_release(&dvb->net); |
| 595 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
| 596 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 597 | dvb_dmxdev_release(&dvb->dmxdev); |
| 598 | dvb_dmx_release(&dvb->demux); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 599 | if (dvb->fe[1]) |
| 600 | dvb_unregister_frontend(dvb->fe[1]); |
| 601 | dvb_unregister_frontend(dvb->fe[0]); |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 602 | if (dvb->fe[1] && !dvb->dont_attach_fe1) |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 603 | dvb_frontend_detach(dvb->fe[1]); |
| 604 | dvb_frontend_detach(dvb->fe[0]); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 605 | dvb_unregister_adapter(&dvb->adapter); |
| 606 | } |
| 607 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 608 | static int em28xx_dvb_init(struct em28xx *dev) |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 609 | { |
Antti Palosaari | e364543 | 2011-07-28 18:59:30 -0300 | [diff] [blame] | 610 | int result = 0, mfe_shared = 0; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 611 | struct em28xx_dvb *dvb; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 612 | |
Mauro Carvalho Chehab | 505b6d0 | 2008-11-25 09:39:50 -0300 | [diff] [blame] | 613 | if (!dev->board.has_dvb) { |
Devin Heitmueller | df61918 | 2008-06-10 12:34:35 -0300 | [diff] [blame] | 614 | /* This device does not support the extension */ |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 615 | 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] | 616 | return 0; |
| 617 | } |
| 618 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 619 | dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 620 | |
| 621 | if (dvb == NULL) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 622 | em28xx_info("em28xx_dvb: memory allocation failed\n"); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 623 | return -ENOMEM; |
| 624 | } |
| 625 | dev->dvb = dvb; |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 626 | dvb->fe[0] = dvb->fe[1] = NULL; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 627 | |
Mauro Carvalho Chehab | 5013318 | 2010-04-07 17:07:58 -0300 | [diff] [blame] | 628 | mutex_lock(&dev->lock); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 629 | em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 630 | /* init frontend */ |
| 631 | switch (dev->model) { |
Mauro Carvalho Chehab | ebaefdb | 2011-06-01 10:16:25 -0300 | [diff] [blame] | 632 | case EM2874_BOARD_LEADERSHIP_ISDBT: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 633 | dvb->fe[0] = dvb_attach(s921_attach, |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 634 | &sharp_isdbt, &dev->i2c_adap); |
| 635 | |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 636 | if (!dvb->fe[0]) { |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 637 | result = -EINVAL; |
| 638 | goto out_free; |
| 639 | } |
| 640 | |
| 641 | break; |
Douglas Schilling Landgraf | f89bc32 | 2008-12-01 21:01:04 -0300 | [diff] [blame] | 642 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850: |
Mauro Carvalho Chehab | 10ac660 | 2008-07-27 14:58:58 -0300 | [diff] [blame] | 643 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: |
Devin Heitmueller | 4fd305b | 2008-06-04 13:43:46 -0300 | [diff] [blame] | 644 | case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: |
Devin Heitmueller | e14b365 | 2008-07-26 11:04:33 -0300 | [diff] [blame] | 645 | case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 646 | dvb->fe[0] = dvb_attach(lgdt330x_attach, |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 647 | &em2880_lgdt3303_dev, |
| 648 | &dev->i2c_adap); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 649 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 650 | result = -EINVAL; |
| 651 | goto out_free; |
| 652 | } |
Mauro Carvalho Chehab | 227ad4a | 2008-04-17 21:37:40 -0300 | [diff] [blame] | 653 | break; |
Thierry MERLE | 46510b5 | 2008-10-11 16:56:13 -0300 | [diff] [blame] | 654 | case EM2880_BOARD_KWORLD_DVB_310U: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 655 | dvb->fe[0] = dvb_attach(zl10353_attach, |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 656 | &em28xx_zl10353_with_xc3028, |
| 657 | &dev->i2c_adap); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 658 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 659 | result = -EINVAL; |
| 660 | goto out_free; |
| 661 | } |
Aidan Thornton | 7e6388a | 2008-04-17 21:40:03 -0300 | [diff] [blame] | 662 | break; |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 663 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: |
Uroš Vampl | ec994d0 | 2009-09-30 22:53:37 -0300 | [diff] [blame] | 664 | case EM2882_BOARD_TERRATEC_HYBRID_XS: |
Devin Heitmueller | 01a5fd6 | 2009-08-07 09:25:06 -0300 | [diff] [blame] | 665 | case EM2880_BOARD_EMPIRE_DUAL_TV: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 666 | dvb->fe[0] = dvb_attach(zl10353_attach, |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 667 | &em28xx_zl10353_xc3028_no_i2c_gate, |
| 668 | &dev->i2c_adap); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 669 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 670 | result = -EINVAL; |
| 671 | goto out_free; |
| 672 | } |
| 673 | break; |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 674 | case EM2880_BOARD_TERRATEC_HYBRID_XS: |
Catimimi | 6563801 | 2010-02-18 18:06:32 -0300 | [diff] [blame] | 675 | case EM2880_BOARD_TERRATEC_HYBRID_XS_FR: |
Devin Heitmueller | d5b3ba9 | 2009-07-08 21:51:35 -0300 | [diff] [blame] | 676 | case EM2881_BOARD_PINNACLE_HYBRID_PRO: |
Andrea.Amorosi76@gmail.com | 7ca7ef6 | 2010-02-09 17:53:38 -0300 | [diff] [blame] | 677 | case EM2882_BOARD_DIKOM_DK300: |
Antonio Larrosa | 811fab6 | 2010-03-04 22:19:48 -0300 | [diff] [blame] | 678 | case EM2882_BOARD_KWORLD_VS_DVBT: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 679 | dvb->fe[0] = dvb_attach(zl10353_attach, |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 680 | &em28xx_zl10353_xc3028_no_i2c_gate, |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 681 | &dev->i2c_adap); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 682 | if (dvb->fe[0] == NULL) { |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 683 | /* This board could have either a zl10353 or a mt352. |
| 684 | If the chip id isn't for zl10353, try mt352 */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 685 | dvb->fe[0] = dvb_attach(mt352_attach, |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 686 | &terratec_xs_mt352_cfg, |
| 687 | &dev->i2c_adap); |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 688 | } |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 689 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 690 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 691 | result = -EINVAL; |
| 692 | goto out_free; |
| 693 | } |
| 694 | break; |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 695 | case EM2883_BOARD_KWORLD_HYBRID_330U: |
Devin Heitmueller | 1985922 | 2009-06-19 00:33:54 -0300 | [diff] [blame] | 696 | case EM2882_BOARD_EVGA_INDTUBE: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 697 | dvb->fe[0] = dvb_attach(s5h1409_attach, |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 698 | &em28xx_s5h1409_with_xc3028, |
| 699 | &dev->i2c_adap); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 700 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 701 | result = -EINVAL; |
| 702 | goto out_free; |
| 703 | } |
| 704 | break; |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 705 | case EM2882_BOARD_KWORLD_ATSC_315U: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 706 | dvb->fe[0] = dvb_attach(lgdt330x_attach, |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 707 | &em2880_lgdt3303_dev, |
| 708 | &dev->i2c_adap); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 709 | if (dvb->fe[0] != NULL) { |
| 710 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 711 | &dev->i2c_adap, 0x61, TUNER_THOMSON_DTT761X)) { |
| 712 | result = -EINVAL; |
| 713 | goto out_free; |
| 714 | } |
| 715 | } |
| 716 | break; |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 717 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: |
Devin Heitmueller | ad9b4bb | 2011-03-13 02:09:59 -0300 | [diff] [blame] | 718 | case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 719 | dvb->fe[0] = dvb_attach(drxd_attach, &em28xx_drxd, NULL, |
Devin Heitmueller | 75e2b86 | 2011-03-13 02:01:02 -0300 | [diff] [blame] | 720 | &dev->i2c_adap, &dev->udev->dev); |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 721 | if (em28xx_attach_xc3028(0x61, dev) < 0) { |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 722 | result = -EINVAL; |
| 723 | goto out_free; |
| 724 | } |
| 725 | break; |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 726 | case EM2870_BOARD_REDDO_DVB_C_USB_BOX: |
| 727 | /* Philips CU1216L NIM (Philips TDA10023 + Infineon TUA6034) */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 728 | dvb->fe[0] = dvb_attach(tda10023_attach, |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 729 | &em28xx_tda10023_config, |
| 730 | &dev->i2c_adap, 0x48); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 731 | if (dvb->fe[0]) { |
| 732 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 733 | &dev->i2c_adap, 0x60, TUNER_PHILIPS_CU1216L)) { |
| 734 | result = -EINVAL; |
| 735 | goto out_free; |
| 736 | } |
| 737 | } |
| 738 | break; |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 739 | case EM2870_BOARD_KWORLD_A340: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 740 | dvb->fe[0] = dvb_attach(lgdt3305_attach, |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 741 | &em2870_lgdt3304_dev, |
| 742 | &dev->i2c_adap); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 743 | if (dvb->fe[0] != NULL) |
| 744 | dvb_attach(tda18271_attach, dvb->fe[0], 0x60, |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 745 | &dev->i2c_adap, &kworld_a340_config); |
| 746 | break; |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 747 | case EM28174_BOARD_PCTV_290E: |
| 748 | /* MFE |
| 749 | * FE 0 = DVB-T/T2 + FE 1 = DVB-C, both sharing same tuner. */ |
| 750 | /* FE 0 */ |
| 751 | dvb->fe[0] = dvb_attach(cxd2820r_attach, |
| 752 | &em28xx_cxd2820r_config, &dev->i2c_adap, NULL); |
| 753 | if (dvb->fe[0]) { |
| 754 | struct i2c_adapter *i2c_tuner; |
| 755 | i2c_tuner = cxd2820r_get_tuner_i2c_adapter(dvb->fe[0]); |
| 756 | /* FE 0 attach tuner */ |
| 757 | if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, |
| 758 | i2c_tuner, &em28xx_cxd2820r_tda18271_config)) { |
| 759 | dvb_frontend_detach(dvb->fe[0]); |
| 760 | result = -EINVAL; |
| 761 | goto out_free; |
| 762 | } |
| 763 | /* FE 1. This dvb_attach() cannot fail. */ |
| 764 | dvb->fe[1] = dvb_attach(cxd2820r_attach, NULL, NULL, |
| 765 | dvb->fe[0]); |
| 766 | dvb->fe[1]->id = 1; |
| 767 | /* FE 1 attach tuner */ |
| 768 | if (!dvb_attach(tda18271_attach, dvb->fe[1], 0x60, |
| 769 | i2c_tuner, &em28xx_cxd2820r_tda18271_config)) { |
| 770 | dvb_frontend_detach(dvb->fe[1]); |
| 771 | /* leave FE 0 still active */ |
| 772 | } |
Antti Palosaari | e364543 | 2011-07-28 18:59:30 -0300 | [diff] [blame] | 773 | |
| 774 | mfe_shared = 1; |
Antti Palosaari | d6a5f92 | 2011-04-07 16:34:44 -0300 | [diff] [blame] | 775 | } |
| 776 | break; |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 777 | case EM2884_BOARD_TERRATEC_H5: |
| 778 | terratec_h5_init(dev); |
| 779 | |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 780 | dvb->dont_attach_fe1 = 1; |
| 781 | |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 782 | dvb->fe[0] = dvb_attach(drxk_attach, &terratec_h5_drxk, &dev->i2c_adap, &dvb->fe[1]); |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 783 | if (!dvb->fe[0]) { |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 784 | result = -EINVAL; |
| 785 | goto out_free; |
| 786 | } |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 787 | |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 788 | /* FIXME: do we need a pll semaphore? */ |
| 789 | dvb->fe[0]->sec_priv = dvb; |
| 790 | sema_init(&dvb->pll_mutex, 1); |
| 791 | dvb->gate_ctrl = dvb->fe[0]->ops.i2c_gate_ctrl; |
| 792 | dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl; |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 793 | dvb->fe[1]->id = 1; |
| 794 | |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 795 | /* Attach tda18271 to DVB-C frontend */ |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 796 | if (dvb->fe[0]->ops.i2c_gate_ctrl) |
| 797 | dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 1); |
| 798 | if (!dvb_attach(tda18271c2dd_attach, dvb->fe[0], &dev->i2c_adap, 0x60)) { |
| 799 | result = -EINVAL; |
| 800 | goto out_free; |
| 801 | } |
| 802 | if (dvb->fe[0]->ops.i2c_gate_ctrl) |
| 803 | dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 0); |
Mauro Carvalho Chehab | c4c3a3d | 2011-07-14 22:23:18 -0300 | [diff] [blame] | 804 | |
| 805 | /* Hack - needed by drxk/tda18271c2dd */ |
| 806 | dvb->fe[1]->tuner_priv = dvb->fe[0]->tuner_priv; |
| 807 | memcpy(&dvb->fe[1]->ops.tuner_ops, |
| 808 | &dvb->fe[0]->ops.tuner_ops, |
| 809 | sizeof(dvb->fe[0]->ops.tuner_ops)); |
Mauro Carvalho Chehab | fec528b | 2011-07-03 21:05:06 -0300 | [diff] [blame] | 810 | |
| 811 | break; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 812 | default: |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 813 | em28xx_errdev("/2: The frontend of your DVB/ATSC card" |
| 814 | " isn't supported yet\n"); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 815 | break; |
| 816 | } |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 817 | if (NULL == dvb->fe[0]) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 818 | em28xx_errdev("/2: frontend initialization failed\n"); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 819 | result = -EINVAL; |
| 820 | goto out_free; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 821 | } |
Michael Krufky | d7cba04 | 2008-09-12 13:31:45 -0300 | [diff] [blame] | 822 | /* define general-purpose callback pointer */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame] | 823 | dvb->fe[0]->callback = em28xx_tuner_callback; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 824 | |
| 825 | /* register everything */ |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 826 | result = em28xx_register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 827 | |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 828 | if (result < 0) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 829 | goto out_free; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 830 | |
Antti Palosaari | e364543 | 2011-07-28 18:59:30 -0300 | [diff] [blame] | 831 | /* MFE lock */ |
| 832 | dvb->adapter.mfe_shared = mfe_shared; |
| 833 | |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 834 | em28xx_info("Successfully loaded em28xx-dvb\n"); |
Mauro Carvalho Chehab | 5013318 | 2010-04-07 17:07:58 -0300 | [diff] [blame] | 835 | ret: |
| 836 | em28xx_set_mode(dev, EM28XX_SUSPEND); |
| 837 | mutex_unlock(&dev->lock); |
| 838 | return result; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 839 | |
| 840 | out_free: |
| 841 | kfree(dvb); |
| 842 | dev->dvb = NULL; |
Mauro Carvalho Chehab | 5013318 | 2010-04-07 17:07:58 -0300 | [diff] [blame] | 843 | goto ret; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 844 | } |
| 845 | |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 846 | static int em28xx_dvb_fini(struct em28xx *dev) |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 847 | { |
Mauro Carvalho Chehab | 505b6d0 | 2008-11-25 09:39:50 -0300 | [diff] [blame] | 848 | if (!dev->board.has_dvb) { |
Devin Heitmueller | df61918 | 2008-06-10 12:34:35 -0300 | [diff] [blame] | 849 | /* This device does not support the extension */ |
| 850 | return 0; |
| 851 | } |
| 852 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 853 | if (dev->dvb) { |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 854 | em28xx_unregister_dvb(dev->dvb); |
Francesco Lavra | 19f48cb | 2009-12-31 08:47:11 -0300 | [diff] [blame] | 855 | kfree(dev->dvb); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 856 | dev->dvb = NULL; |
| 857 | } |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 858 | |
| 859 | return 0; |
| 860 | } |
| 861 | |
| 862 | static struct em28xx_ops dvb_ops = { |
| 863 | .id = EM28XX_DVB, |
| 864 | .name = "Em28xx dvb Extension", |
Jarod Wilson | f2d0c1c | 2011-07-14 19:06:08 -0300 | [diff] [blame^] | 865 | .init = em28xx_dvb_init, |
| 866 | .fini = em28xx_dvb_fini, |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 867 | }; |
| 868 | |
| 869 | static int __init em28xx_dvb_register(void) |
| 870 | { |
| 871 | return em28xx_register_extension(&dvb_ops); |
| 872 | } |
| 873 | |
| 874 | static void __exit em28xx_dvb_unregister(void) |
| 875 | { |
| 876 | em28xx_unregister_extension(&dvb_ops); |
| 877 | } |
| 878 | |
| 879 | module_init(em28xx_dvb_register); |
| 880 | module_exit(em28xx_dvb_unregister); |