22 #include <linux/kernel.h>
23 #include <linux/slab.h>
41 static unsigned int debug;
47 #define dprintk(level, fmt, arg...) do { \
49 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \
52 #define CX231XX_DVB_NUM_BUFS 5
53 #define CX231XX_DVB_MAX_PACKETSIZE 564
54 #define CX231XX_DVB_MAX_PACKETS 64
83 .dvbt_6 = { .if_freq = 4000, .agc_mode = 3, .std = 4,
84 .if_lvl = 1, .rfagc_top = 0x37, },
85 .dvbt_7 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
86 .if_lvl = 1, .rfagc_top = 0x37, },
87 .dvbt_8 = { .if_freq = 4000, .agc_mode = 3, .std = 6,
88 .if_lvl = 1, .rfagc_top = 0x37, },
92 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
93 .if_lvl = 7, .rfagc_top = 0x37, },
97 .std_map = &cnxt_rde253s_tda18271_std_map,
126 .spectral_inversion = 1,
132 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
133 .if_lvl = 1, .rfagc_top = 0x58, },
134 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
135 .if_lvl = 1, .rfagc_top = 0x58, },
139 .std_map = &hauppauge_tda18271_std_map,
144 .demod_address = 0x10,
149 .std_map = &mb86a20s_tda18271_config,
156 char *errmsg =
"Unknown";
160 errmsg =
"unlinked synchronuously";
163 errmsg =
"unlinked asynchronuously";
166 errmsg =
"Buffer error (overrun)";
169 errmsg =
"Stalled (device not responding)";
172 errmsg =
"Babble (bad cable?)";
175 errmsg =
"Bit-stuff error (bad cable?)";
178 errmsg =
"CRC/Timeout (could be anything)";
181 errmsg =
"Device does not respond";
185 dprintk(1,
"URB status %d [%s].\n", status, errmsg);
187 dprintk(1,
"URB packet %d, status %d [%s].\n",
188 packet, status, errmsg);
192 static inline int dvb_isoc_copy(
struct cx231xx *dev,
struct urb *
urb)
202 if (urb->status < 0) {
203 print_err_status(dev, -1, urb->status);
204 if (urb->status == -
ENOENT)
208 for (i = 0; i < urb->number_of_packets; i++) {
209 int status = urb->iso_frame_desc[
i].status;
212 print_err_status(dev, i, status);
213 if (urb->iso_frame_desc[i].status != -
EPROTO)
218 urb->transfer_buffer +
219 urb->iso_frame_desc[i].offset,
220 urb->iso_frame_desc[i].actual_length);
226 static inline int dvb_bulk_copy(
struct cx231xx *dev,
struct urb *urb)
234 if (urb->status < 0) {
235 print_err_status(dev, -1, urb->status);
236 if (urb->status == -
ENOENT)
242 urb->transfer_buffer, urb->actual_length);
247 static int start_streaming(
struct cx231xx_dvb *dvb)
302 if (!demux->
dmx.frontend)
310 ret = start_streaming(dvb);
329 err = stop_streaming(dvb);
336 static int cx231xx_dvb_bus_ctrl(
struct dvb_frontend *fe,
int acquire)
369 if (!dev->
dvb->frontend) {
371 "Can't attach xc5000\n", dev->
name);
425 status = dops->
init(dev->
dvb->frontend);
429 (
"XC5000 firmware download completed\n");
433 (
"XC5000 firmware download failed !!!\n");
457 "%s: dvb_register_adapter failed (errno = %d)\n",
463 dvb->
frontend->ops.ts_bus_ctrl = cx231xx_dvb_bus_ctrl;
471 "%s: dvb_register_frontend failed (errno = %d)\n",
477 dvb->
demux.dmx.capabilities =
480 dvb->
demux.priv = dvb;
481 dvb->
demux.filternum = 256;
482 dvb->
demux.feednum = 256;
483 dvb->
demux.start_feed = start_feed;
484 dvb->
demux.stop_feed = stop_feed;
493 dvb->
dmxdev.filternum = 256;
495 dvb->
dmxdev.capabilities = 0;
507 "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
516 "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
521 result = dvb->
demux.dmx.connect_frontend(&dvb->
demux.dmx, &dvb->
fe_hw);
524 "%s: connect_frontend failed (errno = %d)\n", dev->
name,
550 static void unregister_dvb(
struct cx231xx_dvb *dvb)
562 static int dvb_init(
struct cx231xx *dev)
567 if (!dev->
board.has_dvb) {
586 switch (dev->
model) {
591 &dvico_s5h1432_config,
594 if (dev->
dvb->frontend ==
NULL) {
596 ": Failed to attach s5h1432 front end\n");
606 &cnxt_rde250_tunerconfig)) {
616 &xc5000_s5h1411_config,
619 if (dev->
dvb->frontend ==
NULL) {
621 ": Failed to attach s5h1411 front end\n");
631 &cnxt_rdu250_tunerconfig)) {
639 &dvico_s5h1432_config,
642 if (dev->
dvb->frontend ==
NULL) {
644 ": Failed to attach s5h1432 front end\n");
653 0x60, &dev->
i2c_bus[dev->
board.tuner_i2c_master].i2c_adap,
654 &cnxt_rde253s_tunerconfig)) {
662 &tda18271_s5h1411_config,
665 if (dev->
dvb->frontend ==
NULL) {
667 ": Failed to attach s5h1411 front end\n");
676 0x60, &dev->
i2c_bus[dev->
board.tuner_i2c_master].i2c_adap,
677 &cnxt_rde253s_tunerconfig)) {
685 __func__, i2c_adapter_id(&dev->
i2c_bus[dev->
board.tuner_i2c_master].i2c_adap));
688 &hcw_lgdt3305_config,
691 if (dev->
dvb->frontend ==
NULL) {
693 ": Failed to attach LG3305 front end\n");
702 0x60, &dev->
i2c_bus[dev->
board.tuner_i2c_master].i2c_adap,
703 &hcw_tda18271_config);
710 __func__, i2c_adapter_id(&dev->
i2c_bus[dev->
board.tuner_i2c_master].i2c_adap));
716 if (dev->
dvb->frontend ==
NULL) {
718 ": Failed to attach mb86a20s demod\n");
727 0x60, &dev->
i2c_bus[dev->
board.tuner_i2c_master].i2c_adap,
728 &pv_tda18271_config);
733 " isn't supported yet\n", dev->
name);
738 "%s/2: frontend initialization failed\n", dev->
name);
763 static int dvb_fini(
struct cx231xx *dev)
765 if (!dev->
board.has_dvb) {
771 unregister_dvb(dev->
dvb);
780 .name =
"Cx231xx dvb Extension",
785 static int __init cx231xx_dvb_register(
void)
790 static void __exit cx231xx_dvb_unregister(
void)