Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 1 | /* |
| 2 | DVB device driver for em28xx |
| 3 | |
| 4 | (c) 2008 Mauro Carvalho Chehab <mchehab@infradead.org> |
| 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" |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 42 | |
| 43 | MODULE_DESCRIPTION("driver for em28xx based DVB cards"); |
| 44 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); |
| 45 | MODULE_LICENSE("GPL"); |
| 46 | |
| 47 | static unsigned int debug; |
| 48 | module_param(debug, int, 0644); |
| 49 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); |
| 50 | |
| 51 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 52 | |
| 53 | #define dprintk(level, fmt, arg...) do { \ |
| 54 | if (debug >= level) \ |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 55 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 56 | } while (0) |
| 57 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 58 | #define EM28XX_DVB_NUM_BUFS 5 |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 59 | #define EM28XX_DVB_MAX_PACKETS 64 |
| 60 | |
| 61 | struct em28xx_dvb { |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 62 | struct dvb_frontend *fe[2]; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 63 | |
| 64 | /* feed count management */ |
| 65 | struct mutex lock; |
| 66 | int nfeeds; |
| 67 | |
| 68 | /* general boilerplate stuff */ |
| 69 | struct dvb_adapter adapter; |
| 70 | struct dvb_demux demux; |
| 71 | struct dmxdev dmxdev; |
| 72 | struct dmx_frontend fe_hw; |
| 73 | struct dmx_frontend fe_mem; |
| 74 | struct dvb_net net; |
| 75 | }; |
| 76 | |
| 77 | |
| 78 | static inline void print_err_status(struct em28xx *dev, |
| 79 | int packet, int status) |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 80 | { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 81 | char *errmsg = "Unknown"; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 82 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 83 | switch (status) { |
| 84 | case -ENOENT: |
| 85 | errmsg = "unlinked synchronuously"; |
| 86 | break; |
| 87 | case -ECONNRESET: |
| 88 | errmsg = "unlinked asynchronuously"; |
| 89 | break; |
| 90 | case -ENOSR: |
| 91 | errmsg = "Buffer error (overrun)"; |
| 92 | break; |
| 93 | case -EPIPE: |
| 94 | errmsg = "Stalled (device not responding)"; |
| 95 | break; |
| 96 | case -EOVERFLOW: |
| 97 | errmsg = "Babble (bad cable?)"; |
| 98 | break; |
| 99 | case -EPROTO: |
| 100 | errmsg = "Bit-stuff error (bad cable?)"; |
| 101 | break; |
| 102 | case -EILSEQ: |
| 103 | errmsg = "CRC/Timeout (could be anything)"; |
| 104 | break; |
| 105 | case -ETIME: |
| 106 | errmsg = "Device does not respond"; |
| 107 | break; |
| 108 | } |
| 109 | if (packet < 0) { |
| 110 | dprintk(1, "URB status %d [%s].\n", status, errmsg); |
| 111 | } else { |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 112 | dprintk(1, "URB packet %d, status %d [%s].\n", |
| 113 | packet, status, errmsg); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 114 | } |
| 115 | } |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 116 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 117 | static inline int dvb_isoc_copy(struct em28xx *dev, struct urb *urb) |
| 118 | { |
| 119 | int i; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 120 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 121 | if (!dev) |
| 122 | return 0; |
| 123 | |
| 124 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) |
| 125 | return 0; |
| 126 | |
| 127 | if (urb->status < 0) { |
| 128 | print_err_status(dev, -1, urb->status); |
| 129 | if (urb->status == -ENOENT) |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | for (i = 0; i < urb->number_of_packets; i++) { |
| 134 | int status = urb->iso_frame_desc[i].status; |
| 135 | |
| 136 | if (status < 0) { |
| 137 | print_err_status(dev, i, status); |
| 138 | if (urb->iso_frame_desc[i].status != -EPROTO) |
| 139 | continue; |
| 140 | } |
| 141 | |
| 142 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer + |
| 143 | urb->iso_frame_desc[i].offset, |
| 144 | urb->iso_frame_desc[i].actual_length); |
| 145 | } |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 146 | |
| 147 | return 0; |
| 148 | } |
| 149 | |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 150 | static int start_streaming(struct em28xx_dvb *dvb) |
| 151 | { |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 152 | int rc; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 153 | struct em28xx *dev = dvb->adapter.priv; |
Devin Heitmueller | d18e2fd | 2009-05-16 17:09:28 -0300 | [diff] [blame] | 154 | int max_dvb_packet_size; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 155 | |
| 156 | usb_set_interface(dev->udev, 0, 1); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 157 | rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
| 158 | if (rc < 0) |
| 159 | return rc; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 160 | |
Devin Heitmueller | d18e2fd | 2009-05-16 17:09:28 -0300 | [diff] [blame] | 161 | max_dvb_packet_size = em28xx_isoc_dvb_max_packetsize(dev); |
| 162 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 163 | return em28xx_init_isoc(dev, EM28XX_DVB_MAX_PACKETS, |
Devin Heitmueller | d18e2fd | 2009-05-16 17:09:28 -0300 | [diff] [blame] | 164 | EM28XX_DVB_NUM_BUFS, max_dvb_packet_size, |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 165 | dvb_isoc_copy); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 166 | } |
| 167 | |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 168 | static int stop_streaming(struct em28xx_dvb *dvb) |
| 169 | { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 170 | struct em28xx *dev = dvb->adapter.priv; |
| 171 | |
| 172 | em28xx_uninit_isoc(dev); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 173 | |
Mauro Carvalho Chehab | 2fe3e2e | 2008-11-27 09:10:40 -0300 | [diff] [blame] | 174 | em28xx_set_mode(dev, EM28XX_SUSPEND); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 175 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | static int start_feed(struct dvb_demux_feed *feed) |
| 180 | { |
| 181 | struct dvb_demux *demux = feed->demux; |
| 182 | struct em28xx_dvb *dvb = demux->priv; |
| 183 | int rc, ret; |
| 184 | |
| 185 | if (!demux->dmx.frontend) |
| 186 | return -EINVAL; |
| 187 | |
| 188 | mutex_lock(&dvb->lock); |
| 189 | dvb->nfeeds++; |
| 190 | rc = dvb->nfeeds; |
| 191 | |
| 192 | if (dvb->nfeeds == 1) { |
| 193 | ret = start_streaming(dvb); |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 194 | if (ret < 0) |
| 195 | rc = ret; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | mutex_unlock(&dvb->lock); |
| 199 | return rc; |
| 200 | } |
| 201 | |
| 202 | static int stop_feed(struct dvb_demux_feed *feed) |
| 203 | { |
| 204 | struct dvb_demux *demux = feed->demux; |
| 205 | struct em28xx_dvb *dvb = demux->priv; |
| 206 | int err = 0; |
| 207 | |
| 208 | mutex_lock(&dvb->lock); |
| 209 | dvb->nfeeds--; |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 210 | |
| 211 | if (0 == dvb->nfeeds) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 212 | err = stop_streaming(dvb); |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 213 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 214 | mutex_unlock(&dvb->lock); |
| 215 | return err; |
| 216 | } |
| 217 | |
| 218 | |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 219 | |
| 220 | /* ------------------------------------------------------------------ */ |
| 221 | static int em28xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) |
| 222 | { |
| 223 | struct em28xx *dev = fe->dvb->priv; |
| 224 | |
| 225 | if (acquire) |
| 226 | return em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
| 227 | else |
Mauro Carvalho Chehab | 2fe3e2e | 2008-11-27 09:10:40 -0300 | [diff] [blame] | 228 | return em28xx_set_mode(dev, EM28XX_SUSPEND); |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 229 | } |
| 230 | |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 231 | /* ------------------------------------------------------------------ */ |
| 232 | |
Mauro Carvalho Chehab | 227ad4a | 2008-04-17 21:37:40 -0300 | [diff] [blame] | 233 | static struct lgdt330x_config em2880_lgdt3303_dev = { |
| 234 | .demod_address = 0x0e, |
| 235 | .demod_chip = LGDT3303, |
| 236 | }; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 237 | |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 238 | static struct lgdt3305_config em2870_lgdt3304_dev = { |
| 239 | .i2c_addr = 0x0e, |
| 240 | .demod_chip = LGDT3304, |
| 241 | .spectral_inversion = 1, |
| 242 | .deny_i2c_rptr = 1, |
| 243 | .mpeg_mode = LGDT3305_MPEG_PARALLEL, |
| 244 | .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, |
| 245 | .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, |
| 246 | .vsb_if_khz = 3250, |
| 247 | .qam_if_khz = 4000, |
| 248 | }; |
| 249 | |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 250 | static struct s921_config sharp_isdbt = { |
| 251 | .demod_address = 0x30 >> 1 |
| 252 | }; |
| 253 | |
Aidan Thornton | 7e6388a | 2008-04-17 21:40:03 -0300 | [diff] [blame] | 254 | static struct zl10353_config em28xx_zl10353_with_xc3028 = { |
| 255 | .demod_address = (0x1e >> 1), |
| 256 | .no_tuner = 1, |
| 257 | .parallel_ts = 1, |
| 258 | .if2 = 45600, |
| 259 | }; |
| 260 | |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 261 | static struct s5h1409_config em28xx_s5h1409_with_xc3028 = { |
| 262 | .demod_address = 0x32 >> 1, |
| 263 | .output_mode = S5H1409_PARALLEL_OUTPUT, |
| 264 | .gpio = S5H1409_GPIO_OFF, |
| 265 | .inversion = S5H1409_INVERSION_OFF, |
| 266 | .status_mode = S5H1409_DEMODLOCKING, |
| 267 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK |
| 268 | }; |
| 269 | |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 270 | static struct tda18271_std_map kworld_a340_std_map = { |
| 271 | .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 0, |
| 272 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 273 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 1, |
| 274 | .if_lvl = 1, .rfagc_top = 0x37, }, |
| 275 | }; |
| 276 | |
| 277 | static struct tda18271_config kworld_a340_config = { |
| 278 | .std_map = &kworld_a340_std_map, |
| 279 | }; |
| 280 | |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 281 | static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = { |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 282 | .demod_address = (0x1e >> 1), |
| 283 | .no_tuner = 1, |
| 284 | .disable_i2c_gate_ctrl = 1, |
| 285 | .parallel_ts = 1, |
| 286 | .if2 = 45600, |
| 287 | }; |
| 288 | |
Devin Heitmueller | 75e2b86 | 2011-03-13 02:01:02 -0300 | [diff] [blame] | 289 | static struct drxd_config em28xx_drxd = { |
| 290 | .index = 0, .demod_address = 0x70, .demod_revision = 0xa2, |
| 291 | .demoda_address = 0x00, .pll_address = 0x00, |
| 292 | .pll_type = DRXD_PLL_NONE, .clock = 12000, .insert_rs_byte = 1, |
| 293 | .pll_set = NULL, .osc_deviation = NULL, .IF = 42800000, |
Devin Heitmueller | 6b142b3 | 2011-03-13 02:02:01 -0300 | [diff] [blame] | 294 | .disable_i2c_gate_ctrl = 1, |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 295 | }; |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 296 | |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 297 | static int mt352_terratec_xs_init(struct dvb_frontend *fe) |
| 298 | { |
| 299 | /* Values extracted from a USB trace of the Terratec Windows driver */ |
| 300 | static u8 clock_config[] = { CLOCK_CTL, 0x38, 0x2c }; |
| 301 | static u8 reset[] = { RESET, 0x80 }; |
| 302 | static u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 }; |
| 303 | static u8 agc_cfg[] = { AGC_TARGET, 0x28, 0xa0 }; |
| 304 | static u8 input_freq_cfg[] = { INPUT_FREQ_1, 0x31, 0xb8 }; |
| 305 | static u8 rs_err_cfg[] = { RS_ERR_PER_1, 0x00, 0x4d }; |
| 306 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; |
| 307 | static u8 trl_nom_cfg[] = { TRL_NOMINAL_RATE_1, 0x64, 0x00 }; |
| 308 | static u8 tps_given_cfg[] = { TPS_GIVEN_1, 0x40, 0x80, 0x50 }; |
Devin Heitmueller | ff69786 | 2009-07-12 18:44:19 -0300 | [diff] [blame] | 309 | static u8 tuner_go[] = { TUNER_GO, 0x01}; |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 310 | |
| 311 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 312 | udelay(200); |
| 313 | mt352_write(fe, reset, sizeof(reset)); |
| 314 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 315 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 316 | mt352_write(fe, input_freq_cfg, sizeof(input_freq_cfg)); |
| 317 | mt352_write(fe, rs_err_cfg, sizeof(rs_err_cfg)); |
| 318 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 319 | mt352_write(fe, trl_nom_cfg, sizeof(trl_nom_cfg)); |
| 320 | mt352_write(fe, tps_given_cfg, sizeof(tps_given_cfg)); |
| 321 | mt352_write(fe, tuner_go, sizeof(tuner_go)); |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | static struct mt352_config terratec_xs_mt352_cfg = { |
| 326 | .demod_address = (0x1e >> 1), |
| 327 | .no_tuner = 1, |
| 328 | .if2 = 45600, |
| 329 | .demod_init = mt352_terratec_xs_init, |
| 330 | }; |
| 331 | |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 332 | static struct tda10023_config em28xx_tda10023_config = { |
| 333 | .demod_address = 0x0c, |
| 334 | .invert = 1, |
| 335 | }; |
| 336 | |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 337 | /* ------------------------------------------------------------------ */ |
| 338 | |
| 339 | static int attach_xc3028(u8 addr, struct em28xx *dev) |
| 340 | { |
| 341 | struct dvb_frontend *fe; |
Mauro Carvalho Chehab | 3ca9c09 | 2008-04-17 21:37:53 -0300 | [diff] [blame] | 342 | struct xc2028_config cfg; |
| 343 | |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 344 | memset(&cfg, 0, sizeof(cfg)); |
Mauro Carvalho Chehab | 3ca9c09 | 2008-04-17 21:37:53 -0300 | [diff] [blame] | 345 | cfg.i2c_adap = &dev->i2c_adap; |
| 346 | cfg.i2c_addr = addr; |
Mauro Carvalho Chehab | 3ca9c09 | 2008-04-17 21:37:53 -0300 | [diff] [blame] | 347 | |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 348 | if (!dev->dvb->fe[0]) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 349 | em28xx_errdev("/2: dvb frontend not attached. " |
| 350 | "Can't attach xc3028\n"); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 351 | return -EINVAL; |
| 352 | } |
| 353 | |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 354 | fe = dvb_attach(xc2028_attach, dev->dvb->fe[0], &cfg); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 355 | if (!fe) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 356 | em28xx_errdev("/2: xc3028 attach failed\n"); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 357 | dvb_frontend_detach(dev->dvb->fe[0]); |
| 358 | dev->dvb->fe[0] = NULL; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 359 | return -EINVAL; |
| 360 | } |
| 361 | |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 362 | em28xx_info("%s/2: xc3028 attached\n", dev->name); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 363 | |
| 364 | return 0; |
| 365 | } |
| 366 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 367 | /* ------------------------------------------------------------------ */ |
| 368 | |
Hans Verkuil | d45b9b8 | 2008-09-04 03:33:43 -0300 | [diff] [blame] | 369 | static int register_dvb(struct em28xx_dvb *dvb, |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 370 | struct module *module, |
| 371 | struct em28xx *dev, |
| 372 | struct device *device) |
| 373 | { |
| 374 | int result; |
| 375 | |
| 376 | mutex_init(&dvb->lock); |
| 377 | |
| 378 | /* register adapter */ |
| 379 | result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, |
| 380 | adapter_nr); |
| 381 | if (result < 0) { |
| 382 | printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", |
| 383 | dev->name, result); |
| 384 | goto fail_adapter; |
| 385 | } |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 386 | |
| 387 | /* Ensure all frontends negotiate bus access */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 388 | dvb->fe[0]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; |
| 389 | if (dvb->fe[1]) |
| 390 | dvb->fe[1]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 391 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 392 | dvb->adapter.priv = dev; |
| 393 | |
| 394 | /* register frontend */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 395 | result = dvb_register_frontend(&dvb->adapter, dvb->fe[0]); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 396 | if (result < 0) { |
| 397 | printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", |
| 398 | dev->name, result); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 399 | goto fail_frontend0; |
| 400 | } |
| 401 | |
| 402 | /* register 2nd frontend */ |
| 403 | if (dvb->fe[1]) { |
| 404 | result = dvb_register_frontend(&dvb->adapter, dvb->fe[1]); |
| 405 | if (result < 0) { |
| 406 | printk(KERN_WARNING "%s: 2nd dvb_register_frontend failed (errno = %d)\n", |
| 407 | dev->name, result); |
| 408 | goto fail_frontend1; |
| 409 | } |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | /* register demux stuff */ |
| 413 | dvb->demux.dmx.capabilities = |
| 414 | DMX_TS_FILTERING | DMX_SECTION_FILTERING | |
| 415 | DMX_MEMORY_BASED_FILTERING; |
| 416 | dvb->demux.priv = dvb; |
| 417 | dvb->demux.filternum = 256; |
| 418 | dvb->demux.feednum = 256; |
| 419 | dvb->demux.start_feed = start_feed; |
| 420 | dvb->demux.stop_feed = stop_feed; |
Mauro Carvalho Chehab | e3569ab | 2008-04-17 21:49:20 -0300 | [diff] [blame] | 421 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 422 | result = dvb_dmx_init(&dvb->demux); |
| 423 | if (result < 0) { |
| 424 | printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", |
| 425 | dev->name, result); |
| 426 | goto fail_dmx; |
| 427 | } |
| 428 | |
| 429 | dvb->dmxdev.filternum = 256; |
| 430 | dvb->dmxdev.demux = &dvb->demux.dmx; |
| 431 | dvb->dmxdev.capabilities = 0; |
| 432 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); |
| 433 | if (result < 0) { |
| 434 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", |
| 435 | dev->name, result); |
| 436 | goto fail_dmxdev; |
| 437 | } |
| 438 | |
| 439 | dvb->fe_hw.source = DMX_FRONTEND_0; |
| 440 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 441 | if (result < 0) { |
| 442 | printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", |
| 443 | dev->name, result); |
| 444 | goto fail_fe_hw; |
| 445 | } |
| 446 | |
| 447 | dvb->fe_mem.source = DMX_MEMORY_FE; |
| 448 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
| 449 | if (result < 0) { |
| 450 | printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", |
| 451 | dev->name, result); |
| 452 | goto fail_fe_mem; |
| 453 | } |
| 454 | |
| 455 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 456 | if (result < 0) { |
| 457 | printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n", |
| 458 | dev->name, result); |
| 459 | goto fail_fe_conn; |
| 460 | } |
| 461 | |
| 462 | /* register network adapter */ |
| 463 | dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); |
| 464 | return 0; |
| 465 | |
| 466 | fail_fe_conn: |
| 467 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
| 468 | fail_fe_mem: |
| 469 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 470 | fail_fe_hw: |
| 471 | dvb_dmxdev_release(&dvb->dmxdev); |
| 472 | fail_dmxdev: |
| 473 | dvb_dmx_release(&dvb->demux); |
| 474 | fail_dmx: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 475 | if (dvb->fe[1]) |
| 476 | dvb_unregister_frontend(dvb->fe[1]); |
| 477 | dvb_unregister_frontend(dvb->fe[0]); |
| 478 | fail_frontend1: |
| 479 | if (dvb->fe[1]) |
| 480 | dvb_frontend_detach(dvb->fe[1]); |
| 481 | fail_frontend0: |
| 482 | dvb_frontend_detach(dvb->fe[0]); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 483 | dvb_unregister_adapter(&dvb->adapter); |
| 484 | fail_adapter: |
| 485 | return result; |
| 486 | } |
| 487 | |
| 488 | static void unregister_dvb(struct em28xx_dvb *dvb) |
| 489 | { |
| 490 | dvb_net_release(&dvb->net); |
| 491 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); |
| 492 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); |
| 493 | dvb_dmxdev_release(&dvb->dmxdev); |
| 494 | dvb_dmx_release(&dvb->demux); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 495 | if (dvb->fe[1]) |
| 496 | dvb_unregister_frontend(dvb->fe[1]); |
| 497 | dvb_unregister_frontend(dvb->fe[0]); |
| 498 | if (dvb->fe[1]) |
| 499 | dvb_frontend_detach(dvb->fe[1]); |
| 500 | dvb_frontend_detach(dvb->fe[0]); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 501 | dvb_unregister_adapter(&dvb->adapter); |
| 502 | } |
| 503 | |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 504 | static int dvb_init(struct em28xx *dev) |
| 505 | { |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 506 | int result = 0; |
| 507 | struct em28xx_dvb *dvb; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 508 | |
Mauro Carvalho Chehab | 505b6d0 | 2008-11-25 09:39:50 -0300 | [diff] [blame] | 509 | if (!dev->board.has_dvb) { |
Devin Heitmueller | df61918 | 2008-06-10 12:34:35 -0300 | [diff] [blame] | 510 | /* This device does not support the extension */ |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 511 | 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] | 512 | return 0; |
| 513 | } |
| 514 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 515 | dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 516 | |
| 517 | if (dvb == NULL) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 518 | em28xx_info("em28xx_dvb: memory allocation failed\n"); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 519 | return -ENOMEM; |
| 520 | } |
| 521 | dev->dvb = dvb; |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 522 | dvb->fe[0] = dvb->fe[1] = NULL; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 523 | |
Mauro Carvalho Chehab | 5013318 | 2010-04-07 17:07:58 -0300 | [diff] [blame] | 524 | mutex_lock(&dev->lock); |
Mauro Carvalho Chehab | c67ec53 | 2008-04-17 21:48:00 -0300 | [diff] [blame] | 525 | em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 526 | /* init frontend */ |
| 527 | switch (dev->model) { |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 528 | case EM2874_LEADERSHIP_ISDBT: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 529 | dvb->fe[0] = dvb_attach(s921_attach, |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 530 | &sharp_isdbt, &dev->i2c_adap); |
| 531 | |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 532 | if (!dvb->fe[0]) { |
Mauro Carvalho Chehab | ca3dfd6 | 2010-09-10 17:29:14 -0300 | [diff] [blame] | 533 | result = -EINVAL; |
| 534 | goto out_free; |
| 535 | } |
| 536 | |
| 537 | break; |
Douglas Schilling Landgraf | f89bc32 | 2008-12-01 21:01:04 -0300 | [diff] [blame] | 538 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850: |
Mauro Carvalho Chehab | 10ac660 | 2008-07-27 14:58:58 -0300 | [diff] [blame] | 539 | case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: |
Devin Heitmueller | 4fd305b | 2008-06-04 13:43:46 -0300 | [diff] [blame] | 540 | case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: |
Devin Heitmueller | e14b365 | 2008-07-26 11:04:33 -0300 | [diff] [blame] | 541 | case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 542 | dvb->fe[0] = dvb_attach(lgdt330x_attach, |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 543 | &em2880_lgdt3303_dev, |
| 544 | &dev->i2c_adap); |
| 545 | if (attach_xc3028(0x61, dev) < 0) { |
| 546 | result = -EINVAL; |
| 547 | goto out_free; |
| 548 | } |
Mauro Carvalho Chehab | 227ad4a | 2008-04-17 21:37:40 -0300 | [diff] [blame] | 549 | break; |
Thierry MERLE | 46510b5 | 2008-10-11 16:56:13 -0300 | [diff] [blame] | 550 | case EM2880_BOARD_KWORLD_DVB_310U: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 551 | dvb->fe[0] = dvb_attach(zl10353_attach, |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 552 | &em28xx_zl10353_with_xc3028, |
| 553 | &dev->i2c_adap); |
| 554 | if (attach_xc3028(0x61, dev) < 0) { |
| 555 | result = -EINVAL; |
| 556 | goto out_free; |
| 557 | } |
Aidan Thornton | 7e6388a | 2008-04-17 21:40:03 -0300 | [diff] [blame] | 558 | break; |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 559 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: |
Uroš Vampl | ec994d0 | 2009-09-30 22:53:37 -0300 | [diff] [blame] | 560 | case EM2882_BOARD_TERRATEC_HYBRID_XS: |
Devin Heitmueller | 01a5fd6 | 2009-08-07 09:25:06 -0300 | [diff] [blame] | 561 | case EM2880_BOARD_EMPIRE_DUAL_TV: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 562 | dvb->fe[0] = dvb_attach(zl10353_attach, |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 563 | &em28xx_zl10353_xc3028_no_i2c_gate, |
| 564 | &dev->i2c_adap); |
| 565 | if (attach_xc3028(0x61, dev) < 0) { |
| 566 | result = -EINVAL; |
| 567 | goto out_free; |
| 568 | } |
| 569 | break; |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 570 | case EM2880_BOARD_TERRATEC_HYBRID_XS: |
Catimimi | 6563801 | 2010-02-18 18:06:32 -0300 | [diff] [blame] | 571 | case EM2880_BOARD_TERRATEC_HYBRID_XS_FR: |
Devin Heitmueller | d5b3ba9 | 2009-07-08 21:51:35 -0300 | [diff] [blame] | 572 | case EM2881_BOARD_PINNACLE_HYBRID_PRO: |
Andrea.Amorosi76@gmail.com | 7ca7ef6 | 2010-02-09 17:53:38 -0300 | [diff] [blame] | 573 | case EM2882_BOARD_DIKOM_DK300: |
Antonio Larrosa | 811fab6 | 2010-03-04 22:19:48 -0300 | [diff] [blame] | 574 | case EM2882_BOARD_KWORLD_VS_DVBT: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 575 | dvb->fe[0] = dvb_attach(zl10353_attach, |
Devin Heitmueller | a84f79a | 2009-07-12 17:05:02 -0300 | [diff] [blame] | 576 | &em28xx_zl10353_xc3028_no_i2c_gate, |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 577 | &dev->i2c_adap); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 578 | if (dvb->fe[0] == NULL) { |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 579 | /* This board could have either a zl10353 or a mt352. |
| 580 | If the chip id isn't for zl10353, try mt352 */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 581 | dvb->fe[0] = dvb_attach(mt352_attach, |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 582 | &terratec_xs_mt352_cfg, |
| 583 | &dev->i2c_adap); |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 584 | } |
Devin Heitmueller | 4fb202a | 2009-07-12 17:51:12 -0300 | [diff] [blame] | 585 | |
Devin Heitmueller | f797608 | 2009-06-22 22:32:32 -0300 | [diff] [blame] | 586 | if (attach_xc3028(0x61, dev) < 0) { |
| 587 | result = -EINVAL; |
| 588 | goto out_free; |
| 589 | } |
| 590 | break; |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 591 | case EM2883_BOARD_KWORLD_HYBRID_330U: |
Devin Heitmueller | 1985922 | 2009-06-19 00:33:54 -0300 | [diff] [blame] | 592 | case EM2882_BOARD_EVGA_INDTUBE: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 593 | dvb->fe[0] = dvb_attach(s5h1409_attach, |
Robert Krakora | 6e7b9ea | 2009-01-18 21:59:34 -0300 | [diff] [blame] | 594 | &em28xx_s5h1409_with_xc3028, |
| 595 | &dev->i2c_adap); |
| 596 | if (attach_xc3028(0x61, dev) < 0) { |
| 597 | result = -EINVAL; |
| 598 | goto out_free; |
| 599 | } |
| 600 | break; |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 601 | case EM2882_BOARD_KWORLD_ATSC_315U: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 602 | dvb->fe[0] = dvb_attach(lgdt330x_attach, |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 603 | &em2880_lgdt3303_dev, |
| 604 | &dev->i2c_adap); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 605 | if (dvb->fe[0] != NULL) { |
| 606 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], |
Franklin Meng | d7de5d8 | 2009-06-06 17:05:02 -0300 | [diff] [blame] | 607 | &dev->i2c_adap, 0x61, TUNER_THOMSON_DTT761X)) { |
| 608 | result = -EINVAL; |
| 609 | goto out_free; |
| 610 | } |
| 611 | } |
| 612 | break; |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 613 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2: |
Devin Heitmueller | ad9b4bb | 2011-03-13 02:09:59 -0300 | [diff] [blame] | 614 | case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 615 | dvb->fe[0] = dvb_attach(drxd_attach, &em28xx_drxd, NULL, |
Devin Heitmueller | 75e2b86 | 2011-03-13 02:01:02 -0300 | [diff] [blame] | 616 | &dev->i2c_adap, &dev->udev->dev); |
Devin Heitmueller | 17d9d55 | 2008-06-08 10:22:03 -0300 | [diff] [blame] | 617 | if (attach_xc3028(0x61, dev) < 0) { |
| 618 | result = -EINVAL; |
| 619 | goto out_free; |
| 620 | } |
| 621 | break; |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 622 | case EM2870_BOARD_REDDO_DVB_C_USB_BOX: |
| 623 | /* Philips CU1216L NIM (Philips TDA10023 + Infineon TUA6034) */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 624 | dvb->fe[0] = dvb_attach(tda10023_attach, |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 625 | &em28xx_tda10023_config, |
| 626 | &dev->i2c_adap, 0x48); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 627 | if (dvb->fe[0]) { |
| 628 | if (!dvb_attach(simple_tuner_attach, dvb->fe[0], |
Antti Palosaari | 285eb1a | 2009-09-15 14:42:13 -0300 | [diff] [blame] | 629 | &dev->i2c_adap, 0x60, TUNER_PHILIPS_CU1216L)) { |
| 630 | result = -EINVAL; |
| 631 | goto out_free; |
| 632 | } |
| 633 | } |
| 634 | break; |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 635 | case EM2870_BOARD_KWORLD_A340: |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 636 | dvb->fe[0] = dvb_attach(lgdt3305_attach, |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 637 | &em2870_lgdt3304_dev, |
| 638 | &dev->i2c_adap); |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 639 | if (dvb->fe[0] != NULL) |
| 640 | dvb_attach(tda18271_attach, dvb->fe[0], 0x60, |
Jarod Wilson | 7e48b30 | 2010-03-07 17:55:43 -0300 | [diff] [blame] | 641 | &dev->i2c_adap, &kworld_a340_config); |
| 642 | break; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 643 | default: |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 644 | em28xx_errdev("/2: The frontend of your DVB/ATSC card" |
| 645 | " isn't supported yet\n"); |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 646 | break; |
| 647 | } |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 648 | if (NULL == dvb->fe[0]) { |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 649 | em28xx_errdev("/2: frontend initialization failed\n"); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 650 | result = -EINVAL; |
| 651 | goto out_free; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 652 | } |
Michael Krufky | d7cba04 | 2008-09-12 13:31:45 -0300 | [diff] [blame] | 653 | /* define general-purpose callback pointer */ |
Antti Palosaari | f71095b | 2011-04-07 15:51:52 -0300 | [diff] [blame^] | 654 | dvb->fe[0]->callback = em28xx_tuner_callback; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 655 | |
| 656 | /* register everything */ |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 657 | result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); |
| 658 | |
Douglas Schilling Landgraf | 6ea54d9 | 2008-04-17 21:41:10 -0300 | [diff] [blame] | 659 | if (result < 0) |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 660 | goto out_free; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 661 | |
Filipe Rosset | 480be18 | 2009-11-04 15:32:37 -0300 | [diff] [blame] | 662 | em28xx_info("Successfully loaded em28xx-dvb\n"); |
Mauro Carvalho Chehab | 5013318 | 2010-04-07 17:07:58 -0300 | [diff] [blame] | 663 | ret: |
| 664 | em28xx_set_mode(dev, EM28XX_SUSPEND); |
| 665 | mutex_unlock(&dev->lock); |
| 666 | return result; |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 667 | |
| 668 | out_free: |
| 669 | kfree(dvb); |
| 670 | dev->dvb = NULL; |
Mauro Carvalho Chehab | 5013318 | 2010-04-07 17:07:58 -0300 | [diff] [blame] | 671 | goto ret; |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | static int dvb_fini(struct em28xx *dev) |
| 675 | { |
Mauro Carvalho Chehab | 505b6d0 | 2008-11-25 09:39:50 -0300 | [diff] [blame] | 676 | if (!dev->board.has_dvb) { |
Devin Heitmueller | df61918 | 2008-06-10 12:34:35 -0300 | [diff] [blame] | 677 | /* This device does not support the extension */ |
| 678 | return 0; |
| 679 | } |
| 680 | |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 681 | if (dev->dvb) { |
| 682 | unregister_dvb(dev->dvb); |
Francesco Lavra | 19f48cb | 2009-12-31 08:47:11 -0300 | [diff] [blame] | 683 | kfree(dev->dvb); |
Aidan Thornton | 3421b77 | 2008-04-17 21:40:36 -0300 | [diff] [blame] | 684 | dev->dvb = NULL; |
| 685 | } |
Mauro Carvalho Chehab | 3aefb79 | 2008-04-17 21:36:41 -0300 | [diff] [blame] | 686 | |
| 687 | return 0; |
| 688 | } |
| 689 | |
| 690 | static struct em28xx_ops dvb_ops = { |
| 691 | .id = EM28XX_DVB, |
| 692 | .name = "Em28xx dvb Extension", |
| 693 | .init = dvb_init, |
| 694 | .fini = dvb_fini, |
| 695 | }; |
| 696 | |
| 697 | static int __init em28xx_dvb_register(void) |
| 698 | { |
| 699 | return em28xx_register_extension(&dvb_ops); |
| 700 | } |
| 701 | |
| 702 | static void __exit em28xx_dvb_unregister(void) |
| 703 | { |
| 704 | em28xx_unregister_extension(&dvb_ops); |
| 705 | } |
| 706 | |
| 707 | module_init(em28xx_dvb_register); |
| 708 | module_exit(em28xx_dvb_unregister); |