blob: 5d676b533a3ab245956764592047219d035c0069 [file] [log] [blame]
Michael Krufky4c66c922011-08-29 00:05:35 -03001/*
Michael Krufky08e10972014-01-29 23:10:11 -03002 * Copyright (C) 2010-2014 Michael Krufky (mkrufky@linuxtv.org)
Michael Krufky4c66c922011-08-29 00:05:35 -03003 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation, version 2.
7 *
8 * see Documentation/dvb/README.dvb-usb for more information
9 */
10
11#include <linux/vmalloc.h>
12#include <linux/i2c.h>
Mauro Carvalho Chehabce084d42015-12-30 11:09:39 -020013#include <media/tuner.h>
Michael Krufky4c66c922011-08-29 00:05:35 -030014
15#include "mxl111sf.h"
16#include "mxl111sf-reg.h"
17#include "mxl111sf-phy.h"
18#include "mxl111sf-i2c.h"
19#include "mxl111sf-gpio.h"
20
Michael Krufky4f984802011-10-15 23:10:15 +010021#include "mxl111sf-demod.h"
Michael Krufky4c66c922011-08-29 00:05:35 -030022#include "mxl111sf-tuner.h"
23
24#include "lgdt3305.h"
Michael Krufky31136212012-01-29 15:53:55 -030025#include "lg2160.h"
Michael Krufky4c66c922011-08-29 00:05:35 -030026
Mauro Carvalho Chehabc98300a2013-11-02 08:13:02 -030027/* Max transfer size done by I2C transfer functions */
28#define MAX_XFER_SIZE 64
29
Michael Krufky4c66c922011-08-29 00:05:35 -030030int dvb_usb_mxl111sf_debug;
31module_param_named(debug, dvb_usb_mxl111sf_debug, int, 0644);
32MODULE_PARM_DESC(debug, "set debugging level "
33 "(1=info, 2=xfer, 4=i2c, 8=reg, 16=adv (or-able)).");
34
Hans Verkuiled267162014-08-20 16:48:07 -030035static int dvb_usb_mxl111sf_isoc;
Michael Krufky4c66c922011-08-29 00:05:35 -030036module_param_named(isoc, dvb_usb_mxl111sf_isoc, int, 0644);
37MODULE_PARM_DESC(isoc, "enable usb isoc xfer (0=bulk, 1=isoc).");
38
Hans Verkuiled267162014-08-20 16:48:07 -030039static int dvb_usb_mxl111sf_spi;
Michael Krufky31136212012-01-29 15:53:55 -030040module_param_named(spi, dvb_usb_mxl111sf_spi, int, 0644);
41MODULE_PARM_DESC(spi, "use spi rather than tp for data xfer (0=tp, 1=spi).");
42
Michael Krufky4c66c922011-08-29 00:05:35 -030043#define ANT_PATH_AUTO 0
44#define ANT_PATH_EXTERNAL 1
45#define ANT_PATH_INTERNAL 2
46
Hans Verkuiled267162014-08-20 16:48:07 -030047static int dvb_usb_mxl111sf_rfswitch =
Michael Krufky4c66c922011-08-29 00:05:35 -030048#if 0
49 ANT_PATH_AUTO;
50#else
51 ANT_PATH_EXTERNAL;
52#endif
53
54module_param_named(rfswitch, dvb_usb_mxl111sf_rfswitch, int, 0644);
55MODULE_PARM_DESC(rfswitch, "force rf switch position (0=auto, 1=ext, 2=int).");
56
57DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
58
Michael Krufky4c66c922011-08-29 00:05:35 -030059int mxl111sf_ctrl_msg(struct dvb_usb_device *d,
60 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
61{
62 int wo = (rbuf == NULL || rlen == 0); /* write-only */
63 int ret;
Mauro Carvalho Chehabc98300a2013-11-02 08:13:02 -030064 u8 sndbuf[MAX_XFER_SIZE];
65
66 if (1 + wlen > sizeof(sndbuf)) {
67 pr_warn("%s: len=%d is too big!\n", __func__, wlen);
68 return -EOPNOTSUPP;
69 }
Michael Krufky4c66c922011-08-29 00:05:35 -030070
Hans Verkuilc778edb2013-06-17 20:56:40 -030071 pr_debug("%s(wlen = %d, rlen = %d)\n", __func__, wlen, rlen);
Michael Krufky4c66c922011-08-29 00:05:35 -030072
73 memset(sndbuf, 0, 1+wlen);
74
75 sndbuf[0] = cmd;
76 memcpy(&sndbuf[1], wbuf, wlen);
77
Antti Palosaari85722112012-06-26 00:17:04 -030078 ret = (wo) ? dvb_usbv2_generic_write(d, sndbuf, 1+wlen) :
79 dvb_usbv2_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen);
Michael Krufky4c66c922011-08-29 00:05:35 -030080 mxl_fail(ret);
81
82 return ret;
83}
84
85/* ------------------------------------------------------------------------ */
86
87#define MXL_CMD_REG_READ 0xaa
88#define MXL_CMD_REG_WRITE 0x55
89
90int mxl111sf_read_reg(struct mxl111sf_state *state, u8 addr, u8 *data)
91{
92 u8 buf[2];
93 int ret;
94
95 ret = mxl111sf_ctrl_msg(state->d, MXL_CMD_REG_READ, &addr, 1, buf, 2);
96 if (mxl_fail(ret)) {
97 mxl_debug("error reading reg: 0x%02x", addr);
98 goto fail;
99 }
100
101 if (buf[0] == addr)
102 *data = buf[1];
103 else {
Hans Verkuilc778edb2013-06-17 20:56:40 -0300104 pr_err("invalid response reading reg: 0x%02x != 0x%02x, 0x%02x",
Michael Krufky4c66c922011-08-29 00:05:35 -0300105 addr, buf[0], buf[1]);
106 ret = -EINVAL;
107 }
108
Dave Jones866e8d82014-01-30 00:11:33 -0300109 pr_debug("R: (0x%02x, 0x%02x)\n", addr, buf[1]);
Michael Krufky4c66c922011-08-29 00:05:35 -0300110fail:
111 return ret;
112}
113
114int mxl111sf_write_reg(struct mxl111sf_state *state, u8 addr, u8 data)
115{
116 u8 buf[] = { addr, data };
117 int ret;
118
Hans Verkuilc778edb2013-06-17 20:56:40 -0300119 pr_debug("W: (0x%02x, 0x%02x)\n", addr, data);
Michael Krufky4c66c922011-08-29 00:05:35 -0300120
121 ret = mxl111sf_ctrl_msg(state->d, MXL_CMD_REG_WRITE, buf, 2, NULL, 0);
122 if (mxl_fail(ret))
Hans Verkuilc778edb2013-06-17 20:56:40 -0300123 pr_err("error writing reg: 0x%02x, val: 0x%02x", addr, data);
Michael Krufky4c66c922011-08-29 00:05:35 -0300124 return ret;
125}
126
127/* ------------------------------------------------------------------------ */
128
129int mxl111sf_write_reg_mask(struct mxl111sf_state *state,
130 u8 addr, u8 mask, u8 data)
131{
132 int ret;
Rickard Strandqviste5a89992014-06-01 09:29:19 -0300133 u8 val = 0;
Michael Krufky4c66c922011-08-29 00:05:35 -0300134
135 if (mask != 0xff) {
136 ret = mxl111sf_read_reg(state, addr, &val);
137#if 1
138 /* dont know why this usually errors out on the first try */
139 if (mxl_fail(ret))
Hans Verkuilc778edb2013-06-17 20:56:40 -0300140 pr_err("error writing addr: 0x%02x, mask: 0x%02x, "
Michael Krufky4c66c922011-08-29 00:05:35 -0300141 "data: 0x%02x, retrying...", addr, mask, data);
142
143 ret = mxl111sf_read_reg(state, addr, &val);
144#endif
145 if (mxl_fail(ret))
146 goto fail;
147 }
148 val &= ~mask;
149 val |= data;
150
151 ret = mxl111sf_write_reg(state, addr, val);
152 mxl_fail(ret);
153fail:
154 return ret;
155}
156
157/* ------------------------------------------------------------------------ */
158
159int mxl111sf_ctrl_program_regs(struct mxl111sf_state *state,
160 struct mxl111sf_reg_ctrl_info *ctrl_reg_info)
161{
162 int i, ret = 0;
163
164 for (i = 0; ctrl_reg_info[i].addr |
165 ctrl_reg_info[i].mask |
166 ctrl_reg_info[i].data; i++) {
167
168 ret = mxl111sf_write_reg_mask(state,
169 ctrl_reg_info[i].addr,
170 ctrl_reg_info[i].mask,
171 ctrl_reg_info[i].data);
172 if (mxl_fail(ret)) {
Hans Verkuilc778edb2013-06-17 20:56:40 -0300173 pr_err("failed on reg #%d (0x%02x)", i,
Michael Krufky4c66c922011-08-29 00:05:35 -0300174 ctrl_reg_info[i].addr);
175 break;
176 }
177 }
178 return ret;
179}
180
181/* ------------------------------------------------------------------------ */
182
183static int mxl1x1sf_get_chip_info(struct mxl111sf_state *state)
184{
185 int ret;
186 u8 id, ver;
187 char *mxl_chip, *mxl_rev;
188
189 if ((state->chip_id) && (state->chip_ver))
190 return 0;
191
192 ret = mxl111sf_read_reg(state, CHIP_ID_REG, &id);
193 if (mxl_fail(ret))
194 goto fail;
195 state->chip_id = id;
196
197 ret = mxl111sf_read_reg(state, TOP_CHIP_REV_ID_REG, &ver);
198 if (mxl_fail(ret))
199 goto fail;
200 state->chip_ver = ver;
201
202 switch (id) {
203 case 0x61:
204 mxl_chip = "MxL101SF";
205 break;
206 case 0x63:
207 mxl_chip = "MxL111SF";
208 break;
209 default:
210 mxl_chip = "UNKNOWN MxL1X1";
211 break;
212 }
213 switch (ver) {
214 case 0x36:
215 state->chip_rev = MXL111SF_V6;
216 mxl_rev = "v6";
217 break;
218 case 0x08:
219 state->chip_rev = MXL111SF_V8_100;
220 mxl_rev = "v8_100";
221 break;
222 case 0x18:
223 state->chip_rev = MXL111SF_V8_200;
224 mxl_rev = "v8_200";
225 break;
226 default:
227 state->chip_rev = 0;
228 mxl_rev = "UNKNOWN REVISION";
229 break;
230 }
Hans Verkuilc778edb2013-06-17 20:56:40 -0300231 pr_info("%s detected, %s (0x%x)", mxl_chip, mxl_rev, ver);
Michael Krufky4c66c922011-08-29 00:05:35 -0300232fail:
233 return ret;
234}
235
236#define get_chip_info(state) \
237({ \
238 int ___ret; \
239 ___ret = mxl1x1sf_get_chip_info(state); \
240 if (mxl_fail(___ret)) { \
241 mxl_debug("failed to get chip info" \
242 " on first probe attempt"); \
243 ___ret = mxl1x1sf_get_chip_info(state); \
244 if (mxl_fail(___ret)) \
Hans Verkuilc778edb2013-06-17 20:56:40 -0300245 pr_err("failed to get chip info during probe"); \
Michael Krufky4c66c922011-08-29 00:05:35 -0300246 else \
247 mxl_debug("probe needed a retry " \
248 "in order to succeed."); \
249 } \
250 ___ret; \
251})
252
253/* ------------------------------------------------------------------------ */
Antti Palosaari85722112012-06-26 00:17:04 -0300254#if 0
Michael Krufky4c66c922011-08-29 00:05:35 -0300255static int mxl111sf_power_ctrl(struct dvb_usb_device *d, int onoff)
256{
257 /* power control depends on which adapter is being woken:
258 * save this for init, instead, via mxl111sf_adap_fe_init */
259 return 0;
260}
Antti Palosaari85722112012-06-26 00:17:04 -0300261#endif
Michael Krufky4c66c922011-08-29 00:05:35 -0300262
263static int mxl111sf_adap_fe_init(struct dvb_frontend *fe)
264{
Antti Palosaari85722112012-06-26 00:17:04 -0300265 struct dvb_usb_device *d = fe_to_d(fe);
266 struct mxl111sf_state *state = fe_to_priv(fe);
267 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id];
Michael Krufky4c66c922011-08-29 00:05:35 -0300268 int err;
269
Jonathan McCrohan39c1cb22013-10-20 21:34:01 -0300270 /* exit if we didn't initialize the driver yet */
Michael Krufky4c66c922011-08-29 00:05:35 -0300271 if (!state->chip_id) {
272 mxl_debug("driver not yet initialized, exit.");
273 goto fail;
274 }
275
Hans Verkuilc778edb2013-06-17 20:56:40 -0300276 pr_debug("%s()\n", __func__);
Michael Krufky4c66c922011-08-29 00:05:35 -0300277
278 mutex_lock(&state->fe_lock);
279
280 state->alt_mode = adap_state->alt_mode;
281
Antti Palosaari85722112012-06-26 00:17:04 -0300282 if (usb_set_interface(d->udev, 0, state->alt_mode) < 0)
Hans Verkuilc778edb2013-06-17 20:56:40 -0300283 pr_err("set interface failed");
Michael Krufky4c66c922011-08-29 00:05:35 -0300284
285 err = mxl1x1sf_soft_reset(state);
286 mxl_fail(err);
287 err = mxl111sf_init_tuner_demod(state);
288 mxl_fail(err);
289 err = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
290
291 mxl_fail(err);
Insu Yun997f69f2015-10-15 17:22:45 -0300292 err = mxl111sf_enable_usb_output(state);
Michael Krufky4c66c922011-08-29 00:05:35 -0300293 mxl_fail(err);
Insu Yun997f69f2015-10-15 17:22:45 -0300294 err = mxl1x1sf_top_master_ctrl(state, 1);
Michael Krufky4c66c922011-08-29 00:05:35 -0300295 mxl_fail(err);
296
297 if ((MXL111SF_GPIO_MOD_DVBT != adap_state->gpio_mode) &&
298 (state->chip_rev > MXL111SF_V6)) {
299 mxl111sf_config_pin_mux_modes(state,
300 PIN_MUX_TS_SPI_IN_MODE_1);
301 mxl_fail(err);
302 }
303 err = mxl111sf_init_port_expander(state);
304 if (!mxl_fail(err)) {
305 state->gpio_mode = adap_state->gpio_mode;
306 err = mxl111sf_gpio_mode_switch(state, state->gpio_mode);
307 mxl_fail(err);
308#if 0
309 err = fe->ops.init(fe);
310#endif
311 msleep(100); /* add short delay after enabling
312 * the demod before touching it */
313 }
314
315 return (adap_state->fe_init) ? adap_state->fe_init(fe) : 0;
316fail:
317 return -ENODEV;
318}
319
320static int mxl111sf_adap_fe_sleep(struct dvb_frontend *fe)
321{
Antti Palosaari85722112012-06-26 00:17:04 -0300322 struct mxl111sf_state *state = fe_to_priv(fe);
323 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id];
Michael Krufky4c66c922011-08-29 00:05:35 -0300324 int err;
325
Jonathan McCrohan39c1cb22013-10-20 21:34:01 -0300326 /* exit if we didn't initialize the driver yet */
Michael Krufky4c66c922011-08-29 00:05:35 -0300327 if (!state->chip_id) {
328 mxl_debug("driver not yet initialized, exit.");
329 goto fail;
330 }
331
Hans Verkuilc778edb2013-06-17 20:56:40 -0300332 pr_debug("%s()\n", __func__);
Michael Krufky4c66c922011-08-29 00:05:35 -0300333
334 err = (adap_state->fe_sleep) ? adap_state->fe_sleep(fe) : 0;
335
336 mutex_unlock(&state->fe_lock);
337
338 return err;
339fail:
340 return -ENODEV;
341}
342
343
Antti Palosaari85722112012-06-26 00:17:04 -0300344static int mxl111sf_ep6_streaming_ctrl(struct dvb_frontend *fe, int onoff)
Michael Krufky4c66c922011-08-29 00:05:35 -0300345{
Antti Palosaari85722112012-06-26 00:17:04 -0300346 struct mxl111sf_state *state = fe_to_priv(fe);
347 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id];
Michael Krufky4c66c922011-08-29 00:05:35 -0300348 int ret = 0;
Michael Krufky4c66c922011-08-29 00:05:35 -0300349
Hans Verkuilc778edb2013-06-17 20:56:40 -0300350 pr_debug("%s(%d)\n", __func__, onoff);
Michael Krufky4c66c922011-08-29 00:05:35 -0300351
352 if (onoff) {
353 ret = mxl111sf_enable_usb_output(state);
354 mxl_fail(ret);
355 ret = mxl111sf_config_mpeg_in(state, 1, 1,
356 adap_state->ep6_clockphase,
357 0, 0);
358 mxl_fail(ret);
Michael Krufky3be5bb72012-03-18 14:35:57 -0300359#if 0
Michael Krufky4c66c922011-08-29 00:05:35 -0300360 } else {
361 ret = mxl111sf_disable_656_port(state);
362 mxl_fail(ret);
Michael Krufky3be5bb72012-03-18 14:35:57 -0300363#endif
Michael Krufky4c66c922011-08-29 00:05:35 -0300364 }
365
Michael Krufky4c66c922011-08-29 00:05:35 -0300366 return ret;
367}
368
Antti Palosaari85722112012-06-26 00:17:04 -0300369static int mxl111sf_ep5_streaming_ctrl(struct dvb_frontend *fe, int onoff)
Michael Krufky31136212012-01-29 15:53:55 -0300370{
Antti Palosaari85722112012-06-26 00:17:04 -0300371 struct mxl111sf_state *state = fe_to_priv(fe);
Michael Krufky31136212012-01-29 15:53:55 -0300372 int ret = 0;
373
Hans Verkuilc778edb2013-06-17 20:56:40 -0300374 pr_debug("%s(%d)\n", __func__, onoff);
Michael Krufky31136212012-01-29 15:53:55 -0300375
376 if (onoff) {
377 ret = mxl111sf_enable_usb_output(state);
378 mxl_fail(ret);
379
380 ret = mxl111sf_init_i2s_port(state, 200);
381 mxl_fail(ret);
382 ret = mxl111sf_config_i2s(state, 0, 15);
383 mxl_fail(ret);
384 } else {
385 ret = mxl111sf_disable_i2s_port(state);
386 mxl_fail(ret);
387 }
388 if (state->chip_rev > MXL111SF_V6)
389 ret = mxl111sf_config_spi(state, onoff);
390 mxl_fail(ret);
391
392 return ret;
393}
394
Antti Palosaari85722112012-06-26 00:17:04 -0300395static int mxl111sf_ep4_streaming_ctrl(struct dvb_frontend *fe, int onoff)
Michael Krufky4f984802011-10-15 23:10:15 +0100396{
Antti Palosaari85722112012-06-26 00:17:04 -0300397 struct mxl111sf_state *state = fe_to_priv(fe);
Michael Krufky4f984802011-10-15 23:10:15 +0100398 int ret = 0;
399
Hans Verkuilc778edb2013-06-17 20:56:40 -0300400 pr_debug("%s(%d)\n", __func__, onoff);
Michael Krufky4f984802011-10-15 23:10:15 +0100401
402 if (onoff) {
403 ret = mxl111sf_enable_usb_output(state);
404 mxl_fail(ret);
405 }
406
407 return ret;
408}
409
Michael Krufky4c66c922011-08-29 00:05:35 -0300410/* ------------------------------------------------------------------------ */
411
412static struct lgdt3305_config hauppauge_lgdt3305_config = {
413 .i2c_addr = 0xb2 >> 1,
414 .mpeg_mode = LGDT3305_MPEG_SERIAL,
415 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
416 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
417 .deny_i2c_rptr = 1,
418 .spectral_inversion = 0,
419 .qam_if_khz = 6000,
420 .vsb_if_khz = 6000,
421};
422
Antti Palosaari85722112012-06-26 00:17:04 -0300423static int mxl111sf_lgdt3305_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_id)
Michael Krufky4c66c922011-08-29 00:05:35 -0300424{
Antti Palosaari85722112012-06-26 00:17:04 -0300425 struct dvb_usb_device *d = adap_to_d(adap);
426 struct mxl111sf_state *state = d_to_priv(d);
427 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id];
Michael Krufky4c66c922011-08-29 00:05:35 -0300428 int ret;
429
Hans Verkuilc778edb2013-06-17 20:56:40 -0300430 pr_debug("%s()\n", __func__);
Michael Krufky4c66c922011-08-29 00:05:35 -0300431
432 /* save a pointer to the dvb_usb_device in device state */
433 state->d = d;
434 adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ? 2 : 1;
435 state->alt_mode = adap_state->alt_mode;
436
Antti Palosaari85722112012-06-26 00:17:04 -0300437 if (usb_set_interface(d->udev, 0, state->alt_mode) < 0)
Hans Verkuilc778edb2013-06-17 20:56:40 -0300438 pr_err("set interface failed");
Michael Krufky4c66c922011-08-29 00:05:35 -0300439
440 state->gpio_mode = MXL111SF_GPIO_MOD_ATSC;
441 adap_state->gpio_mode = state->gpio_mode;
442 adap_state->device_mode = MXL_TUNER_MODE;
443 adap_state->ep6_clockphase = 1;
444
445 ret = mxl1x1sf_soft_reset(state);
446 if (mxl_fail(ret))
447 goto fail;
448 ret = mxl111sf_init_tuner_demod(state);
449 if (mxl_fail(ret))
450 goto fail;
451
452 ret = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
453 if (mxl_fail(ret))
454 goto fail;
455
456 ret = mxl111sf_enable_usb_output(state);
457 if (mxl_fail(ret))
458 goto fail;
459 ret = mxl1x1sf_top_master_ctrl(state, 1);
460 if (mxl_fail(ret))
461 goto fail;
462
463 ret = mxl111sf_init_port_expander(state);
464 if (mxl_fail(ret))
465 goto fail;
466 ret = mxl111sf_gpio_mode_switch(state, state->gpio_mode);
467 if (mxl_fail(ret))
468 goto fail;
469
Antti Palosaari85722112012-06-26 00:17:04 -0300470 adap->fe[fe_id] = dvb_attach(lgdt3305_attach,
Michael Krufky4c66c922011-08-29 00:05:35 -0300471 &hauppauge_lgdt3305_config,
Antti Palosaari85722112012-06-26 00:17:04 -0300472 &d->i2c_adap);
473 if (adap->fe[fe_id]) {
474 state->num_frontends++;
475 adap_state->fe_init = adap->fe[fe_id]->ops.init;
476 adap->fe[fe_id]->ops.init = mxl111sf_adap_fe_init;
477 adap_state->fe_sleep = adap->fe[fe_id]->ops.sleep;
478 adap->fe[fe_id]->ops.sleep = mxl111sf_adap_fe_sleep;
Michael Krufky4c66c922011-08-29 00:05:35 -0300479 return 0;
480 }
481 ret = -EIO;
482fail:
483 return ret;
484}
485
Michael Krufky31136212012-01-29 15:53:55 -0300486static struct lg2160_config hauppauge_lg2160_config = {
487 .lg_chip = LG2160,
488 .i2c_addr = 0x1c >> 1,
489 .deny_i2c_rptr = 1,
490 .spectral_inversion = 0,
491 .if_khz = 6000,
492};
493
Antti Palosaari85722112012-06-26 00:17:04 -0300494static int mxl111sf_lg2160_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_id)
Michael Krufky31136212012-01-29 15:53:55 -0300495{
Antti Palosaari85722112012-06-26 00:17:04 -0300496 struct dvb_usb_device *d = adap_to_d(adap);
497 struct mxl111sf_state *state = d_to_priv(d);
498 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id];
Michael Krufky31136212012-01-29 15:53:55 -0300499 int ret;
500
Hans Verkuilc778edb2013-06-17 20:56:40 -0300501 pr_debug("%s()\n", __func__);
Michael Krufky31136212012-01-29 15:53:55 -0300502
503 /* save a pointer to the dvb_usb_device in device state */
504 state->d = d;
505 adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ? 2 : 1;
506 state->alt_mode = adap_state->alt_mode;
507
Antti Palosaari85722112012-06-26 00:17:04 -0300508 if (usb_set_interface(d->udev, 0, state->alt_mode) < 0)
Hans Verkuilc778edb2013-06-17 20:56:40 -0300509 pr_err("set interface failed");
Michael Krufky31136212012-01-29 15:53:55 -0300510
511 state->gpio_mode = MXL111SF_GPIO_MOD_MH;
512 adap_state->gpio_mode = state->gpio_mode;
513 adap_state->device_mode = MXL_TUNER_MODE;
514 adap_state->ep6_clockphase = 1;
515
516 ret = mxl1x1sf_soft_reset(state);
517 if (mxl_fail(ret))
518 goto fail;
519 ret = mxl111sf_init_tuner_demod(state);
520 if (mxl_fail(ret))
521 goto fail;
522
523 ret = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
524 if (mxl_fail(ret))
525 goto fail;
526
527 ret = mxl111sf_enable_usb_output(state);
528 if (mxl_fail(ret))
529 goto fail;
530 ret = mxl1x1sf_top_master_ctrl(state, 1);
531 if (mxl_fail(ret))
532 goto fail;
533
534 ret = mxl111sf_init_port_expander(state);
535 if (mxl_fail(ret))
536 goto fail;
537 ret = mxl111sf_gpio_mode_switch(state, state->gpio_mode);
538 if (mxl_fail(ret))
539 goto fail;
540
541 ret = get_chip_info(state);
542 if (mxl_fail(ret))
543 goto fail;
544
Antti Palosaari85722112012-06-26 00:17:04 -0300545 adap->fe[fe_id] = dvb_attach(lg2160_attach,
Michael Krufky31136212012-01-29 15:53:55 -0300546 &hauppauge_lg2160_config,
Antti Palosaari85722112012-06-26 00:17:04 -0300547 &d->i2c_adap);
548 if (adap->fe[fe_id]) {
549 state->num_frontends++;
550 adap_state->fe_init = adap->fe[fe_id]->ops.init;
551 adap->fe[fe_id]->ops.init = mxl111sf_adap_fe_init;
552 adap_state->fe_sleep = adap->fe[fe_id]->ops.sleep;
553 adap->fe[fe_id]->ops.sleep = mxl111sf_adap_fe_sleep;
Michael Krufky31136212012-01-29 15:53:55 -0300554 return 0;
555 }
556 ret = -EIO;
557fail:
558 return ret;
559}
560
561static struct lg2160_config hauppauge_lg2161_1019_config = {
562 .lg_chip = LG2161_1019,
563 .i2c_addr = 0x1c >> 1,
564 .deny_i2c_rptr = 1,
565 .spectral_inversion = 0,
566 .if_khz = 6000,
567 .output_if = 2, /* LG2161_OIF_SPI_MAS */
568};
569
570static struct lg2160_config hauppauge_lg2161_1040_config = {
571 .lg_chip = LG2161_1040,
572 .i2c_addr = 0x1c >> 1,
573 .deny_i2c_rptr = 1,
574 .spectral_inversion = 0,
575 .if_khz = 6000,
576 .output_if = 4, /* LG2161_OIF_SPI_MAS */
577};
578
Antti Palosaari85722112012-06-26 00:17:04 -0300579static int mxl111sf_lg2161_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_id)
Michael Krufky31136212012-01-29 15:53:55 -0300580{
Antti Palosaari85722112012-06-26 00:17:04 -0300581 struct dvb_usb_device *d = adap_to_d(adap);
582 struct mxl111sf_state *state = d_to_priv(d);
583 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id];
Michael Krufky31136212012-01-29 15:53:55 -0300584 int ret;
585
Hans Verkuilc778edb2013-06-17 20:56:40 -0300586 pr_debug("%s()\n", __func__);
Michael Krufky31136212012-01-29 15:53:55 -0300587
588 /* save a pointer to the dvb_usb_device in device state */
589 state->d = d;
590 adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ? 2 : 1;
591 state->alt_mode = adap_state->alt_mode;
592
Antti Palosaari85722112012-06-26 00:17:04 -0300593 if (usb_set_interface(d->udev, 0, state->alt_mode) < 0)
Hans Verkuilc778edb2013-06-17 20:56:40 -0300594 pr_err("set interface failed");
Michael Krufky31136212012-01-29 15:53:55 -0300595
596 state->gpio_mode = MXL111SF_GPIO_MOD_MH;
597 adap_state->gpio_mode = state->gpio_mode;
598 adap_state->device_mode = MXL_TUNER_MODE;
599 adap_state->ep6_clockphase = 1;
600
601 ret = mxl1x1sf_soft_reset(state);
602 if (mxl_fail(ret))
603 goto fail;
604 ret = mxl111sf_init_tuner_demod(state);
605 if (mxl_fail(ret))
606 goto fail;
607
608 ret = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
609 if (mxl_fail(ret))
610 goto fail;
611
612 ret = mxl111sf_enable_usb_output(state);
613 if (mxl_fail(ret))
614 goto fail;
615 ret = mxl1x1sf_top_master_ctrl(state, 1);
616 if (mxl_fail(ret))
617 goto fail;
618
619 ret = mxl111sf_init_port_expander(state);
620 if (mxl_fail(ret))
621 goto fail;
622 ret = mxl111sf_gpio_mode_switch(state, state->gpio_mode);
623 if (mxl_fail(ret))
624 goto fail;
625
626 ret = get_chip_info(state);
627 if (mxl_fail(ret))
628 goto fail;
629
Antti Palosaari85722112012-06-26 00:17:04 -0300630 adap->fe[fe_id] = dvb_attach(lg2160_attach,
Michael Krufky31136212012-01-29 15:53:55 -0300631 (MXL111SF_V8_200 == state->chip_rev) ?
632 &hauppauge_lg2161_1040_config :
633 &hauppauge_lg2161_1019_config,
Antti Palosaari85722112012-06-26 00:17:04 -0300634 &d->i2c_adap);
635 if (adap->fe[fe_id]) {
636 state->num_frontends++;
637 adap_state->fe_init = adap->fe[fe_id]->ops.init;
638 adap->fe[fe_id]->ops.init = mxl111sf_adap_fe_init;
639 adap_state->fe_sleep = adap->fe[fe_id]->ops.sleep;
640 adap->fe[fe_id]->ops.sleep = mxl111sf_adap_fe_sleep;
Michael Krufky31136212012-01-29 15:53:55 -0300641 return 0;
642 }
643 ret = -EIO;
644fail:
645 return ret;
646}
647
648static struct lg2160_config hauppauge_lg2161_1019_ep6_config = {
649 .lg_chip = LG2161_1019,
650 .i2c_addr = 0x1c >> 1,
651 .deny_i2c_rptr = 1,
652 .spectral_inversion = 0,
653 .if_khz = 6000,
654 .output_if = 1, /* LG2161_OIF_SERIAL_TS */
655};
656
657static struct lg2160_config hauppauge_lg2161_1040_ep6_config = {
658 .lg_chip = LG2161_1040,
659 .i2c_addr = 0x1c >> 1,
660 .deny_i2c_rptr = 1,
661 .spectral_inversion = 0,
662 .if_khz = 6000,
663 .output_if = 7, /* LG2161_OIF_SERIAL_TS */
664};
665
Antti Palosaari85722112012-06-26 00:17:04 -0300666static int mxl111sf_lg2161_ep6_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_id)
Michael Krufky31136212012-01-29 15:53:55 -0300667{
Antti Palosaari85722112012-06-26 00:17:04 -0300668 struct dvb_usb_device *d = adap_to_d(adap);
669 struct mxl111sf_state *state = d_to_priv(d);
670 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id];
Michael Krufky31136212012-01-29 15:53:55 -0300671 int ret;
672
Hans Verkuilc778edb2013-06-17 20:56:40 -0300673 pr_debug("%s()\n", __func__);
Michael Krufky31136212012-01-29 15:53:55 -0300674
675 /* save a pointer to the dvb_usb_device in device state */
676 state->d = d;
677 adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ? 2 : 1;
678 state->alt_mode = adap_state->alt_mode;
679
Antti Palosaari85722112012-06-26 00:17:04 -0300680 if (usb_set_interface(d->udev, 0, state->alt_mode) < 0)
Hans Verkuilc778edb2013-06-17 20:56:40 -0300681 pr_err("set interface failed");
Michael Krufky31136212012-01-29 15:53:55 -0300682
683 state->gpio_mode = MXL111SF_GPIO_MOD_MH;
684 adap_state->gpio_mode = state->gpio_mode;
685 adap_state->device_mode = MXL_TUNER_MODE;
686 adap_state->ep6_clockphase = 0;
687
688 ret = mxl1x1sf_soft_reset(state);
689 if (mxl_fail(ret))
690 goto fail;
691 ret = mxl111sf_init_tuner_demod(state);
692 if (mxl_fail(ret))
693 goto fail;
694
695 ret = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
696 if (mxl_fail(ret))
697 goto fail;
698
699 ret = mxl111sf_enable_usb_output(state);
700 if (mxl_fail(ret))
701 goto fail;
702 ret = mxl1x1sf_top_master_ctrl(state, 1);
703 if (mxl_fail(ret))
704 goto fail;
705
706 ret = mxl111sf_init_port_expander(state);
707 if (mxl_fail(ret))
708 goto fail;
709 ret = mxl111sf_gpio_mode_switch(state, state->gpio_mode);
710 if (mxl_fail(ret))
711 goto fail;
712
713 ret = get_chip_info(state);
714 if (mxl_fail(ret))
715 goto fail;
716
Antti Palosaari85722112012-06-26 00:17:04 -0300717 adap->fe[fe_id] = dvb_attach(lg2160_attach,
Michael Krufky31136212012-01-29 15:53:55 -0300718 (MXL111SF_V8_200 == state->chip_rev) ?
719 &hauppauge_lg2161_1040_ep6_config :
720 &hauppauge_lg2161_1019_ep6_config,
Antti Palosaari85722112012-06-26 00:17:04 -0300721 &d->i2c_adap);
722 if (adap->fe[fe_id]) {
723 state->num_frontends++;
724 adap_state->fe_init = adap->fe[fe_id]->ops.init;
725 adap->fe[fe_id]->ops.init = mxl111sf_adap_fe_init;
726 adap_state->fe_sleep = adap->fe[fe_id]->ops.sleep;
727 adap->fe[fe_id]->ops.sleep = mxl111sf_adap_fe_sleep;
Michael Krufky31136212012-01-29 15:53:55 -0300728 return 0;
729 }
730 ret = -EIO;
731fail:
732 return ret;
733}
734
Julia Lawall9c5e44a2015-11-13 10:24:39 -0200735static const struct mxl111sf_demod_config mxl_demod_config = {
Michael Krufky4f984802011-10-15 23:10:15 +0100736 .read_reg = mxl111sf_read_reg,
737 .write_reg = mxl111sf_write_reg,
738 .program_regs = mxl111sf_ctrl_program_regs,
739};
740
Antti Palosaari85722112012-06-26 00:17:04 -0300741static int mxl111sf_attach_demod(struct dvb_usb_adapter *adap, u8 fe_id)
Michael Krufky4f984802011-10-15 23:10:15 +0100742{
Antti Palosaari85722112012-06-26 00:17:04 -0300743 struct dvb_usb_device *d = adap_to_d(adap);
744 struct mxl111sf_state *state = d_to_priv(d);
745 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe_id];
Michael Krufky4f984802011-10-15 23:10:15 +0100746 int ret;
747
Hans Verkuilc778edb2013-06-17 20:56:40 -0300748 pr_debug("%s()\n", __func__);
Michael Krufky4f984802011-10-15 23:10:15 +0100749
750 /* save a pointer to the dvb_usb_device in device state */
751 state->d = d;
752 adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ? 1 : 2;
753 state->alt_mode = adap_state->alt_mode;
754
Antti Palosaari85722112012-06-26 00:17:04 -0300755 if (usb_set_interface(d->udev, 0, state->alt_mode) < 0)
Hans Verkuilc778edb2013-06-17 20:56:40 -0300756 pr_err("set interface failed");
Michael Krufky4f984802011-10-15 23:10:15 +0100757
758 state->gpio_mode = MXL111SF_GPIO_MOD_DVBT;
759 adap_state->gpio_mode = state->gpio_mode;
760 adap_state->device_mode = MXL_SOC_MODE;
761 adap_state->ep6_clockphase = 1;
762
763 ret = mxl1x1sf_soft_reset(state);
764 if (mxl_fail(ret))
765 goto fail;
766 ret = mxl111sf_init_tuner_demod(state);
767 if (mxl_fail(ret))
768 goto fail;
769
770 ret = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
771 if (mxl_fail(ret))
772 goto fail;
773
774 ret = mxl111sf_enable_usb_output(state);
775 if (mxl_fail(ret))
776 goto fail;
777 ret = mxl1x1sf_top_master_ctrl(state, 1);
778 if (mxl_fail(ret))
779 goto fail;
780
781 /* dont care if this fails */
782 mxl111sf_init_port_expander(state);
783
Antti Palosaari85722112012-06-26 00:17:04 -0300784 adap->fe[fe_id] = dvb_attach(mxl111sf_demod_attach, state,
Michael Krufky4f984802011-10-15 23:10:15 +0100785 &mxl_demod_config);
Antti Palosaari85722112012-06-26 00:17:04 -0300786 if (adap->fe[fe_id]) {
787 state->num_frontends++;
788 adap_state->fe_init = adap->fe[fe_id]->ops.init;
789 adap->fe[fe_id]->ops.init = mxl111sf_adap_fe_init;
790 adap_state->fe_sleep = adap->fe[fe_id]->ops.sleep;
791 adap->fe[fe_id]->ops.sleep = mxl111sf_adap_fe_sleep;
Michael Krufky4f984802011-10-15 23:10:15 +0100792 return 0;
793 }
794 ret = -EIO;
795fail:
796 return ret;
797}
798
Michael Krufky4c66c922011-08-29 00:05:35 -0300799static inline int mxl111sf_set_ant_path(struct mxl111sf_state *state,
800 int antpath)
801{
802 return mxl111sf_idac_config(state, 1, 1,
803 (antpath == ANT_PATH_INTERNAL) ?
804 0x3f : 0x00, 0);
805}
806
807#define DbgAntHunt(x, pwr0, pwr1, pwr2, pwr3) \
Hans Verkuilc778edb2013-06-17 20:56:40 -0300808 pr_err("%s(%d) FINAL input set to %s rxPwr:%d|%d|%d|%d\n", \
Michael Krufky4c66c922011-08-29 00:05:35 -0300809 __func__, __LINE__, \
810 (ANT_PATH_EXTERNAL == x) ? "EXTERNAL" : "INTERNAL", \
811 pwr0, pwr1, pwr2, pwr3)
812
813#define ANT_HUNT_SLEEP 90
814#define ANT_EXT_TWEAK 0
815
816static int mxl111sf_ant_hunt(struct dvb_frontend *fe)
817{
Antti Palosaari85722112012-06-26 00:17:04 -0300818 struct mxl111sf_state *state = fe_to_priv(fe);
Michael Krufky4c66c922011-08-29 00:05:35 -0300819 int antctrl = dvb_usb_mxl111sf_rfswitch;
820
821 u16 rxPwrA, rxPwr0, rxPwr1, rxPwr2;
822
823 /* FIXME: must force EXTERNAL for QAM - done elsewhere */
824 mxl111sf_set_ant_path(state, antctrl == ANT_PATH_AUTO ?
825 ANT_PATH_EXTERNAL : antctrl);
826
827 if (antctrl == ANT_PATH_AUTO) {
828#if 0
829 msleep(ANT_HUNT_SLEEP);
830#endif
831 fe->ops.tuner_ops.get_rf_strength(fe, &rxPwrA);
832
833 mxl111sf_set_ant_path(state, ANT_PATH_EXTERNAL);
834 msleep(ANT_HUNT_SLEEP);
835 fe->ops.tuner_ops.get_rf_strength(fe, &rxPwr0);
836
837 mxl111sf_set_ant_path(state, ANT_PATH_EXTERNAL);
838 msleep(ANT_HUNT_SLEEP);
839 fe->ops.tuner_ops.get_rf_strength(fe, &rxPwr1);
840
841 mxl111sf_set_ant_path(state, ANT_PATH_INTERNAL);
842 msleep(ANT_HUNT_SLEEP);
843 fe->ops.tuner_ops.get_rf_strength(fe, &rxPwr2);
844
845 if (rxPwr1+ANT_EXT_TWEAK >= rxPwr2) {
846 /* return with EXTERNAL enabled */
847 mxl111sf_set_ant_path(state, ANT_PATH_EXTERNAL);
848 DbgAntHunt(ANT_PATH_EXTERNAL, rxPwrA,
849 rxPwr0, rxPwr1, rxPwr2);
850 } else {
851 /* return with INTERNAL enabled */
852 DbgAntHunt(ANT_PATH_INTERNAL, rxPwrA,
853 rxPwr0, rxPwr1, rxPwr2);
854 }
855 }
856 return 0;
857}
858
Julia Lawall40205162016-01-03 10:11:06 -0200859static const struct mxl111sf_tuner_config mxl_tuner_config = {
Michael Krufky4c66c922011-08-29 00:05:35 -0300860 .if_freq = MXL_IF_6_0, /* applies to external IF output, only */
861 .invert_spectrum = 0,
862 .read_reg = mxl111sf_read_reg,
863 .write_reg = mxl111sf_write_reg,
864 .program_regs = mxl111sf_ctrl_program_regs,
865 .top_master_ctrl = mxl1x1sf_top_master_ctrl,
866 .ant_hunt = mxl111sf_ant_hunt,
867};
868
869static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap)
870{
Antti Palosaari85722112012-06-26 00:17:04 -0300871 struct mxl111sf_state *state = adap_to_priv(adap);
Mauro Carvalho Chehabce084d42015-12-30 11:09:39 -0200872#ifdef CONFIG_MEDIA_CONTROLLER_DVB
873 struct media_device *mdev = dvb_get_media_controller(&adap->dvb_adap);
874 int ret;
875#endif
Antti Palosaari85722112012-06-26 00:17:04 -0300876 int i;
Michael Krufky4c66c922011-08-29 00:05:35 -0300877
Hans Verkuilc778edb2013-06-17 20:56:40 -0300878 pr_debug("%s()\n", __func__);
Michael Krufky4c66c922011-08-29 00:05:35 -0300879
Antti Palosaari85722112012-06-26 00:17:04 -0300880 for (i = 0; i < state->num_frontends; i++) {
881 if (dvb_attach(mxl111sf_tuner_attach, adap->fe[i], state,
882 &mxl_tuner_config) == NULL)
883 return -EIO;
Mauro Carvalho Chehab9adf6132012-08-05 14:16:30 -0300884 adap->fe[i]->ops.read_signal_strength = adap->fe[i]->ops.tuner_ops.get_rf_strength;
Antti Palosaari85722112012-06-26 00:17:04 -0300885 }
Michael Krufky4c66c922011-08-29 00:05:35 -0300886
Mauro Carvalho Chehabce084d42015-12-30 11:09:39 -0200887#ifdef CONFIG_MEDIA_CONTROLLER_DVB
888 state->tuner.function = MEDIA_ENT_F_TUNER;
889 state->tuner.name = "mxl111sf tuner";
890 state->tuner_pads[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
Mauro Carvalho Chehab163c9bc2016-01-27 08:39:33 -0200891 state->tuner_pads[TUNER_PAD_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
Mauro Carvalho Chehabce084d42015-12-30 11:09:39 -0200892
893 ret = media_entity_pads_init(&state->tuner,
894 TUNER_NUM_PADS, state->tuner_pads);
895 if (ret)
896 return ret;
897
898 ret = media_device_register_entity(mdev, &state->tuner);
899 if (ret)
900 return ret;
901#endif
Antti Palosaari85722112012-06-26 00:17:04 -0300902 return 0;
Michael Krufky4c66c922011-08-29 00:05:35 -0300903}
904
Michael Krufky4c66c922011-08-29 00:05:35 -0300905static u32 mxl111sf_i2c_func(struct i2c_adapter *adapter)
906{
907 return I2C_FUNC_I2C;
908}
909
Hans Verkuiled267162014-08-20 16:48:07 -0300910static struct i2c_algorithm mxl111sf_i2c_algo = {
Michael Krufky4c66c922011-08-29 00:05:35 -0300911 .master_xfer = mxl111sf_i2c_xfer,
912 .functionality = mxl111sf_i2c_func,
913#ifdef NEED_ALGO_CONTROL
914 .algo_control = dummy_algo_control,
915#endif
916};
917
Antti Palosaari85722112012-06-26 00:17:04 -0300918static int mxl111sf_init(struct dvb_usb_device *d)
Michael Krufky4c66c922011-08-29 00:05:35 -0300919{
Antti Palosaari85722112012-06-26 00:17:04 -0300920 struct mxl111sf_state *state = d_to_priv(d);
921 int ret;
922 static u8 eeprom[256];
923 struct i2c_client c;
Michael Krufky4c66c922011-08-29 00:05:35 -0300924
Antti Palosaari85722112012-06-26 00:17:04 -0300925 ret = get_chip_info(state);
926 if (mxl_fail(ret))
Hans Verkuilc778edb2013-06-17 20:56:40 -0300927 pr_err("failed to get chip info during probe");
Michael Krufky4c66c922011-08-29 00:05:35 -0300928
Antti Palosaari85722112012-06-26 00:17:04 -0300929 mutex_init(&state->fe_lock);
Michael Krufky4c66c922011-08-29 00:05:35 -0300930
Antti Palosaari85722112012-06-26 00:17:04 -0300931 if (state->chip_rev > MXL111SF_V6)
932 mxl111sf_config_pin_mux_modes(state, PIN_MUX_TS_SPI_IN_MODE_1);
Michael Krufky4c66c922011-08-29 00:05:35 -0300933
Antti Palosaari85722112012-06-26 00:17:04 -0300934 c.adapter = &d->i2c_adap;
935 c.addr = 0xa0 >> 1;
Michael Krufky4c66c922011-08-29 00:05:35 -0300936
Antti Palosaari85722112012-06-26 00:17:04 -0300937 ret = tveeprom_read(&c, eeprom, sizeof(eeprom));
938 if (mxl_fail(ret))
Michael Krufky4c66c922011-08-29 00:05:35 -0300939 return 0;
Antti Palosaari85722112012-06-26 00:17:04 -0300940 tveeprom_hauppauge_analog(&c, &state->tv, (0x84 == eeprom[0xa0]) ?
941 eeprom + 0xa0 : eeprom + 0x80);
942#if 0
943 switch (state->tv.model) {
944 case 117001:
945 case 126001:
946 case 138001:
947 break;
948 default:
949 printk(KERN_WARNING "%s: warning: "
950 "unknown hauppauge model #%d\n",
951 __func__, state->tv.model);
Michael Krufky4c66c922011-08-29 00:05:35 -0300952 }
Antti Palosaari85722112012-06-26 00:17:04 -0300953#endif
954 return 0;
Michael Krufky4c66c922011-08-29 00:05:35 -0300955}
956
Antti Palosaari85722112012-06-26 00:17:04 -0300957static int mxl111sf_frontend_attach_dvbt(struct dvb_usb_adapter *adap)
958{
959 return mxl111sf_attach_demod(adap, 0);
960}
Michael Krufky4c66c922011-08-29 00:05:35 -0300961
Antti Palosaari85722112012-06-26 00:17:04 -0300962static int mxl111sf_frontend_attach_atsc(struct dvb_usb_adapter *adap)
963{
964 return mxl111sf_lgdt3305_frontend_attach(adap, 0);
965}
Michael Krufky4c66c922011-08-29 00:05:35 -0300966
Antti Palosaari85722112012-06-26 00:17:04 -0300967static int mxl111sf_frontend_attach_mh(struct dvb_usb_adapter *adap)
968{
969 return mxl111sf_lg2160_frontend_attach(adap, 0);
970}
Michael Krufky4f984802011-10-15 23:10:15 +0100971
Antti Palosaari85722112012-06-26 00:17:04 -0300972static int mxl111sf_frontend_attach_atsc_mh(struct dvb_usb_adapter *adap)
973{
974 int ret;
Hans Verkuilc778edb2013-06-17 20:56:40 -0300975 pr_debug("%s\n", __func__);
Michael Krufky4f984802011-10-15 23:10:15 +0100976
Antti Palosaari85722112012-06-26 00:17:04 -0300977 ret = mxl111sf_lgdt3305_frontend_attach(adap, 0);
978 if (ret < 0)
979 return ret;
Michael Krufky31136212012-01-29 15:53:55 -0300980
Antti Palosaari85722112012-06-26 00:17:04 -0300981 ret = mxl111sf_attach_demod(adap, 1);
982 if (ret < 0)
983 return ret;
Michael Krufky31136212012-01-29 15:53:55 -0300984
Antti Palosaari85722112012-06-26 00:17:04 -0300985 ret = mxl111sf_lg2160_frontend_attach(adap, 2);
986 if (ret < 0)
987 return ret;
Michael Krufky4c66c922011-08-29 00:05:35 -0300988
Antti Palosaari85722112012-06-26 00:17:04 -0300989 return ret;
990}
Michael Krufky4c66c922011-08-29 00:05:35 -0300991
Antti Palosaari85722112012-06-26 00:17:04 -0300992static int mxl111sf_frontend_attach_mercury(struct dvb_usb_adapter *adap)
993{
994 int ret;
Hans Verkuilc778edb2013-06-17 20:56:40 -0300995 pr_debug("%s\n", __func__);
Michael Krufky4c66c922011-08-29 00:05:35 -0300996
Antti Palosaari85722112012-06-26 00:17:04 -0300997 ret = mxl111sf_lgdt3305_frontend_attach(adap, 0);
998 if (ret < 0)
999 return ret;
1000
1001 ret = mxl111sf_attach_demod(adap, 1);
1002 if (ret < 0)
1003 return ret;
1004
1005 ret = mxl111sf_lg2161_ep6_frontend_attach(adap, 2);
1006 if (ret < 0)
1007 return ret;
1008
1009 return ret;
1010}
1011
1012static int mxl111sf_frontend_attach_mercury_mh(struct dvb_usb_adapter *adap)
1013{
1014 int ret;
Hans Verkuilc778edb2013-06-17 20:56:40 -03001015 pr_debug("%s\n", __func__);
Antti Palosaari85722112012-06-26 00:17:04 -03001016
1017 ret = mxl111sf_attach_demod(adap, 0);
1018 if (ret < 0)
1019 return ret;
1020
1021 if (dvb_usb_mxl111sf_spi)
1022 ret = mxl111sf_lg2161_frontend_attach(adap, 1);
1023 else
1024 ret = mxl111sf_lg2161_ep6_frontend_attach(adap, 1);
1025
1026 return ret;
1027}
1028
1029static void mxl111sf_stream_config_bulk(struct usb_data_stream_properties *stream, u8 endpoint)
1030{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001031 pr_debug("%s: endpoint=%d size=8192\n", __func__, endpoint);
Antti Palosaari85722112012-06-26 00:17:04 -03001032 stream->type = USB_BULK;
1033 stream->count = 5;
1034 stream->endpoint = endpoint;
1035 stream->u.bulk.buffersize = 8192;
1036}
1037
1038static void mxl111sf_stream_config_isoc(struct usb_data_stream_properties *stream,
1039 u8 endpoint, int framesperurb, int framesize)
1040{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001041 pr_debug("%s: endpoint=%d size=%d\n", __func__, endpoint,
Antti Palosaari85722112012-06-26 00:17:04 -03001042 framesperurb * framesize);
1043 stream->type = USB_ISOC;
1044 stream->count = 5;
1045 stream->endpoint = endpoint;
1046 stream->u.isoc.framesperurb = framesperurb;
1047 stream->u.isoc.framesize = framesize;
1048 stream->u.isoc.interval = 1;
1049}
1050
1051/* DVB USB Driver stuff */
1052
1053/* dvbt mxl111sf
1054 * bulk EP4/BULK/5/8192
1055 * isoc EP4/ISOC/5/96/564
1056 */
1057static int mxl111sf_get_stream_config_dvbt(struct dvb_frontend *fe,
1058 u8 *ts_type, struct usb_data_stream_properties *stream)
1059{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001060 pr_debug("%s: fe=%d\n", __func__, fe->id);
Antti Palosaari85722112012-06-26 00:17:04 -03001061
1062 *ts_type = DVB_USB_FE_TS_TYPE_188;
1063 if (dvb_usb_mxl111sf_isoc)
1064 mxl111sf_stream_config_isoc(stream, 4, 96, 564);
1065 else
1066 mxl111sf_stream_config_bulk(stream, 4);
1067 return 0;
1068}
1069
1070static struct dvb_usb_device_properties mxl111sf_props_dvbt = {
1071 .driver_name = KBUILD_MODNAME,
1072 .owner = THIS_MODULE,
1073 .adapter_nr = adapter_nr,
1074 .size_of_priv = sizeof(struct mxl111sf_state),
1075
1076 .generic_bulk_ctrl_endpoint = 0x02,
1077 .generic_bulk_ctrl_endpoint_response = 0x81,
1078
1079 .i2c_algo = &mxl111sf_i2c_algo,
1080 .frontend_attach = mxl111sf_frontend_attach_dvbt,
1081 .tuner_attach = mxl111sf_attach_tuner,
1082 .init = mxl111sf_init,
1083 .streaming_ctrl = mxl111sf_ep4_streaming_ctrl,
1084 .get_stream_config = mxl111sf_get_stream_config_dvbt,
Michael Krufky4c66c922011-08-29 00:05:35 -03001085
1086 .num_adapters = 1,
1087 .adapter = {
1088 {
Antti Palosaari85722112012-06-26 00:17:04 -03001089 .stream = DVB_USB_STREAM_ISOC(6, 5, 24, 3072, 1),
1090 }
Michael Krufky4f984802011-10-15 23:10:15 +01001091 }
1092};
1093
Antti Palosaari85722112012-06-26 00:17:04 -03001094/* atsc lgdt3305
1095 * bulk EP6/BULK/5/8192
1096 * isoc EP6/ISOC/5/24/3072
1097 */
1098static int mxl111sf_get_stream_config_atsc(struct dvb_frontend *fe,
1099 u8 *ts_type, struct usb_data_stream_properties *stream)
1100{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001101 pr_debug("%s: fe=%d\n", __func__, fe->id);
Antti Palosaari85722112012-06-26 00:17:04 -03001102
1103 *ts_type = DVB_USB_FE_TS_TYPE_188;
1104 if (dvb_usb_mxl111sf_isoc)
1105 mxl111sf_stream_config_isoc(stream, 6, 24, 3072);
1106 else
1107 mxl111sf_stream_config_bulk(stream, 6);
1108 return 0;
1109}
1110
1111static struct dvb_usb_device_properties mxl111sf_props_atsc = {
1112 .driver_name = KBUILD_MODNAME,
1113 .owner = THIS_MODULE,
1114 .adapter_nr = adapter_nr,
1115 .size_of_priv = sizeof(struct mxl111sf_state),
1116
1117 .generic_bulk_ctrl_endpoint = 0x02,
1118 .generic_bulk_ctrl_endpoint_response = 0x81,
1119
1120 .i2c_algo = &mxl111sf_i2c_algo,
1121 .frontend_attach = mxl111sf_frontend_attach_atsc,
1122 .tuner_attach = mxl111sf_attach_tuner,
1123 .init = mxl111sf_init,
1124 .streaming_ctrl = mxl111sf_ep6_streaming_ctrl,
1125 .get_stream_config = mxl111sf_get_stream_config_atsc,
Michael Krufky4f984802011-10-15 23:10:15 +01001126
1127 .num_adapters = 1,
1128 .adapter = {
1129 {
Antti Palosaari85722112012-06-26 00:17:04 -03001130 .stream = DVB_USB_STREAM_ISOC(6, 5, 24, 3072, 1),
1131 }
Michael Krufky4f984802011-10-15 23:10:15 +01001132 }
1133};
1134
Antti Palosaari85722112012-06-26 00:17:04 -03001135/* mh lg2160
1136 * bulk EP5/BULK/5/8192/RAW
1137 * isoc EP5/ISOC/5/96/200/RAW
1138 */
1139static int mxl111sf_get_stream_config_mh(struct dvb_frontend *fe,
1140 u8 *ts_type, struct usb_data_stream_properties *stream)
1141{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001142 pr_debug("%s: fe=%d\n", __func__, fe->id);
Antti Palosaari85722112012-06-26 00:17:04 -03001143
1144 *ts_type = DVB_USB_FE_TS_TYPE_RAW;
1145 if (dvb_usb_mxl111sf_isoc)
1146 mxl111sf_stream_config_isoc(stream, 5, 96, 200);
1147 else
1148 mxl111sf_stream_config_bulk(stream, 5);
1149 return 0;
1150}
1151
1152static struct dvb_usb_device_properties mxl111sf_props_mh = {
1153 .driver_name = KBUILD_MODNAME,
1154 .owner = THIS_MODULE,
1155 .adapter_nr = adapter_nr,
1156 .size_of_priv = sizeof(struct mxl111sf_state),
1157
1158 .generic_bulk_ctrl_endpoint = 0x02,
1159 .generic_bulk_ctrl_endpoint_response = 0x81,
1160
1161 .i2c_algo = &mxl111sf_i2c_algo,
1162 .frontend_attach = mxl111sf_frontend_attach_mh,
1163 .tuner_attach = mxl111sf_attach_tuner,
1164 .init = mxl111sf_init,
1165 .streaming_ctrl = mxl111sf_ep5_streaming_ctrl,
1166 .get_stream_config = mxl111sf_get_stream_config_mh,
Michael Krufky4f984802011-10-15 23:10:15 +01001167
1168 .num_adapters = 1,
1169 .adapter = {
1170 {
Antti Palosaari85722112012-06-26 00:17:04 -03001171 .stream = DVB_USB_STREAM_ISOC(6, 5, 24, 3072, 1),
1172 }
Michael Krufky31136212012-01-29 15:53:55 -03001173 }
1174};
1175
Antti Palosaari85722112012-06-26 00:17:04 -03001176/* atsc mh lgdt3305 mxl111sf lg2160
1177 * bulk EP6/BULK/5/8192 EP4/BULK/5/8192 EP5/BULK/5/8192/RAW
1178 * isoc EP6/ISOC/5/24/3072 EP4/ISOC/5/96/564 EP5/ISOC/5/96/200/RAW
1179 */
1180static int mxl111sf_get_stream_config_atsc_mh(struct dvb_frontend *fe,
1181 u8 *ts_type, struct usb_data_stream_properties *stream)
1182{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001183 pr_debug("%s: fe=%d\n", __func__, fe->id);
Antti Palosaari85722112012-06-26 00:17:04 -03001184
1185 if (fe->id == 0) {
1186 *ts_type = DVB_USB_FE_TS_TYPE_188;
1187 if (dvb_usb_mxl111sf_isoc)
1188 mxl111sf_stream_config_isoc(stream, 6, 24, 3072);
1189 else
1190 mxl111sf_stream_config_bulk(stream, 6);
1191 } else if (fe->id == 1) {
1192 *ts_type = DVB_USB_FE_TS_TYPE_188;
1193 if (dvb_usb_mxl111sf_isoc)
1194 mxl111sf_stream_config_isoc(stream, 4, 96, 564);
1195 else
1196 mxl111sf_stream_config_bulk(stream, 4);
1197 } else if (fe->id == 2) {
1198 *ts_type = DVB_USB_FE_TS_TYPE_RAW;
1199 if (dvb_usb_mxl111sf_isoc)
1200 mxl111sf_stream_config_isoc(stream, 5, 96, 200);
1201 else
1202 mxl111sf_stream_config_bulk(stream, 5);
1203 }
1204 return 0;
1205}
1206
1207static int mxl111sf_streaming_ctrl_atsc_mh(struct dvb_frontend *fe, int onoff)
1208{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001209 pr_debug("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff);
Antti Palosaari85722112012-06-26 00:17:04 -03001210
1211 if (fe->id == 0)
1212 return mxl111sf_ep6_streaming_ctrl(fe, onoff);
1213 else if (fe->id == 1)
1214 return mxl111sf_ep4_streaming_ctrl(fe, onoff);
1215 else if (fe->id == 2)
1216 return mxl111sf_ep5_streaming_ctrl(fe, onoff);
1217 return 0;
1218}
1219
1220static struct dvb_usb_device_properties mxl111sf_props_atsc_mh = {
1221 .driver_name = KBUILD_MODNAME,
1222 .owner = THIS_MODULE,
1223 .adapter_nr = adapter_nr,
1224 .size_of_priv = sizeof(struct mxl111sf_state),
1225
1226 .generic_bulk_ctrl_endpoint = 0x02,
1227 .generic_bulk_ctrl_endpoint_response = 0x81,
1228
1229 .i2c_algo = &mxl111sf_i2c_algo,
1230 .frontend_attach = mxl111sf_frontend_attach_atsc_mh,
1231 .tuner_attach = mxl111sf_attach_tuner,
1232 .init = mxl111sf_init,
1233 .streaming_ctrl = mxl111sf_streaming_ctrl_atsc_mh,
1234 .get_stream_config = mxl111sf_get_stream_config_atsc_mh,
Michael Krufky31136212012-01-29 15:53:55 -03001235
1236 .num_adapters = 1,
1237 .adapter = {
1238 {
Antti Palosaari85722112012-06-26 00:17:04 -03001239 .stream = DVB_USB_STREAM_ISOC(6, 5, 24, 3072, 1),
1240 }
Michael Krufky31136212012-01-29 15:53:55 -03001241 }
1242};
1243
Antti Palosaari85722112012-06-26 00:17:04 -03001244/* mercury lgdt3305 mxl111sf lg2161
1245 * tp bulk EP6/BULK/5/8192 EP4/BULK/5/8192 EP6/BULK/5/8192/RAW
1246 * tp isoc EP6/ISOC/5/24/3072 EP4/ISOC/5/96/564 EP6/ISOC/5/24/3072/RAW
1247 * spi bulk EP6/BULK/5/8192 EP4/BULK/5/8192 EP5/BULK/5/8192/RAW
1248 * spi isoc EP6/ISOC/5/24/3072 EP4/ISOC/5/96/564 EP5/ISOC/5/96/200/RAW
1249 */
1250static int mxl111sf_get_stream_config_mercury(struct dvb_frontend *fe,
1251 u8 *ts_type, struct usb_data_stream_properties *stream)
1252{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001253 pr_debug("%s: fe=%d\n", __func__, fe->id);
Antti Palosaari85722112012-06-26 00:17:04 -03001254
1255 if (fe->id == 0) {
1256 *ts_type = DVB_USB_FE_TS_TYPE_188;
1257 if (dvb_usb_mxl111sf_isoc)
1258 mxl111sf_stream_config_isoc(stream, 6, 24, 3072);
1259 else
1260 mxl111sf_stream_config_bulk(stream, 6);
1261 } else if (fe->id == 1) {
1262 *ts_type = DVB_USB_FE_TS_TYPE_188;
1263 if (dvb_usb_mxl111sf_isoc)
1264 mxl111sf_stream_config_isoc(stream, 4, 96, 564);
1265 else
1266 mxl111sf_stream_config_bulk(stream, 4);
1267 } else if (fe->id == 2 && dvb_usb_mxl111sf_spi) {
1268 *ts_type = DVB_USB_FE_TS_TYPE_RAW;
1269 if (dvb_usb_mxl111sf_isoc)
1270 mxl111sf_stream_config_isoc(stream, 5, 96, 200);
1271 else
1272 mxl111sf_stream_config_bulk(stream, 5);
1273 } else if (fe->id == 2 && !dvb_usb_mxl111sf_spi) {
1274 *ts_type = DVB_USB_FE_TS_TYPE_RAW;
1275 if (dvb_usb_mxl111sf_isoc)
1276 mxl111sf_stream_config_isoc(stream, 6, 24, 3072);
1277 else
1278 mxl111sf_stream_config_bulk(stream, 6);
1279 }
1280 return 0;
1281}
1282
1283static int mxl111sf_streaming_ctrl_mercury(struct dvb_frontend *fe, int onoff)
1284{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001285 pr_debug("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff);
Antti Palosaari85722112012-06-26 00:17:04 -03001286
1287 if (fe->id == 0)
1288 return mxl111sf_ep6_streaming_ctrl(fe, onoff);
1289 else if (fe->id == 1)
1290 return mxl111sf_ep4_streaming_ctrl(fe, onoff);
1291 else if (fe->id == 2 && dvb_usb_mxl111sf_spi)
1292 return mxl111sf_ep5_streaming_ctrl(fe, onoff);
1293 else if (fe->id == 2 && !dvb_usb_mxl111sf_spi)
1294 return mxl111sf_ep6_streaming_ctrl(fe, onoff);
1295 return 0;
1296}
1297
1298static struct dvb_usb_device_properties mxl111sf_props_mercury = {
1299 .driver_name = KBUILD_MODNAME,
1300 .owner = THIS_MODULE,
1301 .adapter_nr = adapter_nr,
1302 .size_of_priv = sizeof(struct mxl111sf_state),
1303
1304 .generic_bulk_ctrl_endpoint = 0x02,
1305 .generic_bulk_ctrl_endpoint_response = 0x81,
1306
1307 .i2c_algo = &mxl111sf_i2c_algo,
1308 .frontend_attach = mxl111sf_frontend_attach_mercury,
1309 .tuner_attach = mxl111sf_attach_tuner,
1310 .init = mxl111sf_init,
1311 .streaming_ctrl = mxl111sf_streaming_ctrl_mercury,
1312 .get_stream_config = mxl111sf_get_stream_config_mercury,
Michael Krufky31136212012-01-29 15:53:55 -03001313
1314 .num_adapters = 1,
1315 .adapter = {
1316 {
Antti Palosaari85722112012-06-26 00:17:04 -03001317 .stream = DVB_USB_STREAM_ISOC(6, 5, 24, 3072, 1),
1318 }
Michael Krufky31136212012-01-29 15:53:55 -03001319 }
1320};
1321
Antti Palosaari85722112012-06-26 00:17:04 -03001322/* mercury mh mxl111sf lg2161
1323 * tp bulk EP4/BULK/5/8192 EP6/BULK/5/8192/RAW
1324 * tp isoc EP4/ISOC/5/96/564 EP6/ISOC/5/24/3072/RAW
1325 * spi bulk EP4/BULK/5/8192 EP5/BULK/5/8192/RAW
1326 * spi isoc EP4/ISOC/5/96/564 EP5/ISOC/5/96/200/RAW
1327 */
1328static int mxl111sf_get_stream_config_mercury_mh(struct dvb_frontend *fe,
1329 u8 *ts_type, struct usb_data_stream_properties *stream)
1330{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001331 pr_debug("%s: fe=%d\n", __func__, fe->id);
Antti Palosaari85722112012-06-26 00:17:04 -03001332
1333 if (fe->id == 0) {
1334 *ts_type = DVB_USB_FE_TS_TYPE_188;
1335 if (dvb_usb_mxl111sf_isoc)
1336 mxl111sf_stream_config_isoc(stream, 4, 96, 564);
1337 else
1338 mxl111sf_stream_config_bulk(stream, 4);
1339 } else if (fe->id == 1 && dvb_usb_mxl111sf_spi) {
1340 *ts_type = DVB_USB_FE_TS_TYPE_RAW;
1341 if (dvb_usb_mxl111sf_isoc)
1342 mxl111sf_stream_config_isoc(stream, 5, 96, 200);
1343 else
1344 mxl111sf_stream_config_bulk(stream, 5);
1345 } else if (fe->id == 1 && !dvb_usb_mxl111sf_spi) {
1346 *ts_type = DVB_USB_FE_TS_TYPE_RAW;
1347 if (dvb_usb_mxl111sf_isoc)
1348 mxl111sf_stream_config_isoc(stream, 6, 24, 3072);
1349 else
1350 mxl111sf_stream_config_bulk(stream, 6);
1351 }
1352 return 0;
1353}
1354
1355static int mxl111sf_streaming_ctrl_mercury_mh(struct dvb_frontend *fe, int onoff)
1356{
Hans Verkuilc778edb2013-06-17 20:56:40 -03001357 pr_debug("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff);
Antti Palosaari85722112012-06-26 00:17:04 -03001358
1359 if (fe->id == 0)
1360 return mxl111sf_ep4_streaming_ctrl(fe, onoff);
1361 else if (fe->id == 1 && dvb_usb_mxl111sf_spi)
1362 return mxl111sf_ep5_streaming_ctrl(fe, onoff);
1363 else if (fe->id == 1 && !dvb_usb_mxl111sf_spi)
1364 return mxl111sf_ep6_streaming_ctrl(fe, onoff);
1365 return 0;
1366}
1367
1368static struct dvb_usb_device_properties mxl111sf_props_mercury_mh = {
1369 .driver_name = KBUILD_MODNAME,
1370 .owner = THIS_MODULE,
1371 .adapter_nr = adapter_nr,
1372 .size_of_priv = sizeof(struct mxl111sf_state),
1373
1374 .generic_bulk_ctrl_endpoint = 0x02,
1375 .generic_bulk_ctrl_endpoint_response = 0x81,
1376
1377 .i2c_algo = &mxl111sf_i2c_algo,
1378 .frontend_attach = mxl111sf_frontend_attach_mercury_mh,
1379 .tuner_attach = mxl111sf_attach_tuner,
1380 .init = mxl111sf_init,
1381 .streaming_ctrl = mxl111sf_streaming_ctrl_mercury_mh,
1382 .get_stream_config = mxl111sf_get_stream_config_mercury_mh,
Michael Krufky31136212012-01-29 15:53:55 -03001383
1384 .num_adapters = 1,
1385 .adapter = {
1386 {
Antti Palosaari85722112012-06-26 00:17:04 -03001387 .stream = DVB_USB_STREAM_ISOC(6, 5, 24, 3072, 1),
1388 }
Michael Krufky31136212012-01-29 15:53:55 -03001389 }
1390};
1391
Antti Palosaari85722112012-06-26 00:17:04 -03001392static const struct usb_device_id mxl111sf_id_table[] = {
1393 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc600, &mxl111sf_props_atsc_mh, "Hauppauge 126xxx ATSC+", NULL) },
1394 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc601, &mxl111sf_props_atsc, "Hauppauge 126xxx ATSC", NULL) },
1395 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc602, &mxl111sf_props_mh, "HCW 126xxx", NULL) },
1396 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc603, &mxl111sf_props_atsc_mh, "Hauppauge 126xxx ATSC+", NULL) },
1397 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc604, &mxl111sf_props_dvbt, "Hauppauge 126xxx DVBT", NULL) },
1398 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc609, &mxl111sf_props_atsc, "Hauppauge 126xxx ATSC", NULL) },
1399 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc60a, &mxl111sf_props_mh, "HCW 126xxx", NULL) },
1400 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc60b, &mxl111sf_props_atsc_mh, "Hauppauge 126xxx ATSC+", NULL) },
1401 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc60c, &mxl111sf_props_dvbt, "Hauppauge 126xxx DVBT", NULL) },
1402 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc653, &mxl111sf_props_atsc_mh, "Hauppauge 126xxx ATSC+", NULL) },
1403 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc65b, &mxl111sf_props_atsc_mh, "Hauppauge 126xxx ATSC+", NULL) },
1404 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb700, &mxl111sf_props_atsc_mh, "Hauppauge 117xxx ATSC+", NULL) },
1405 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb701, &mxl111sf_props_atsc, "Hauppauge 126xxx ATSC", NULL) },
1406 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb702, &mxl111sf_props_mh, "HCW 117xxx", NULL) },
1407 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb703, &mxl111sf_props_atsc_mh, "Hauppauge 117xxx ATSC+", NULL) },
1408 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb704, &mxl111sf_props_dvbt, "Hauppauge 117xxx DVBT", NULL) },
1409 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb753, &mxl111sf_props_atsc_mh, "Hauppauge 117xxx ATSC+", NULL) },
1410 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb763, &mxl111sf_props_atsc_mh, "Hauppauge 117xxx ATSC+", NULL) },
1411 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb764, &mxl111sf_props_dvbt, "Hauppauge 117xxx DVBT", NULL) },
1412 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xd853, &mxl111sf_props_mercury, "Hauppauge Mercury", NULL) },
1413 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xd854, &mxl111sf_props_dvbt, "Hauppauge 138xxx DVBT", NULL) },
1414 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xd863, &mxl111sf_props_mercury, "Hauppauge Mercury", NULL) },
1415 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xd864, &mxl111sf_props_dvbt, "Hauppauge 138xxx DVBT", NULL) },
1416 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xd8d3, &mxl111sf_props_mercury, "Hauppauge Mercury", NULL) },
1417 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xd8d4, &mxl111sf_props_dvbt, "Hauppauge 138xxx DVBT", NULL) },
1418 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xd8e3, &mxl111sf_props_mercury, "Hauppauge Mercury", NULL) },
1419 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xd8e4, &mxl111sf_props_dvbt, "Hauppauge 138xxx DVBT", NULL) },
1420 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xd8ff, &mxl111sf_props_mercury, "Hauppauge Mercury", NULL) },
1421 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc612, &mxl111sf_props_mercury_mh, "Hauppauge 126xxx", NULL) },
1422 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc613, &mxl111sf_props_mercury, "Hauppauge WinTV-Aero-M", NULL) },
1423 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc61a, &mxl111sf_props_mercury_mh, "Hauppauge 126xxx", NULL) },
1424 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xc61b, &mxl111sf_props_mercury, "Hauppauge WinTV-Aero-M", NULL) },
1425 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb757, &mxl111sf_props_atsc_mh, "Hauppauge 117xxx ATSC+", NULL) },
1426 { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xb767, &mxl111sf_props_atsc_mh, "Hauppauge 117xxx ATSC+", NULL) },
1427 { }
1428};
1429MODULE_DEVICE_TABLE(usb, mxl111sf_id_table);
Michael Krufky31136212012-01-29 15:53:55 -03001430
Antti Palosaari85722112012-06-26 00:17:04 -03001431static struct usb_driver mxl111sf_usb_driver = {
1432 .name = KBUILD_MODNAME,
1433 .id_table = mxl111sf_id_table,
1434 .probe = dvb_usbv2_probe,
1435 .disconnect = dvb_usbv2_disconnect,
1436 .suspend = dvb_usbv2_suspend,
1437 .resume = dvb_usbv2_resume,
1438 .no_dynamic_id = 1,
1439 .soft_unbind = 1,
Michael Krufky31136212012-01-29 15:53:55 -03001440};
1441
Antti Palosaari85722112012-06-26 00:17:04 -03001442module_usb_driver(mxl111sf_usb_driver);
Michael Krufky4c66c922011-08-29 00:05:35 -03001443
Michael Krufky08e10972014-01-29 23:10:11 -03001444MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
Michael Krufky4c66c922011-08-29 00:05:35 -03001445MODULE_DESCRIPTION("Driver for MaxLinear MxL111SF");
1446MODULE_VERSION("1.0");
1447MODULE_LICENSE("GPL");