2 DVB device driver for em28xx
4 (c) 2008 Mauro Carvalho Chehab <mchehab@infradead.org>
6 Based on cx88-dvb and saa7134-dvb originally written by:
7 (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
8 (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License.
15 #include <linux/kernel.h>
16 #include <linux/usb.h>
19 #include <media/v4l2-common.h>
20 #include <media/videobuf-vmalloc.h>
23 #include "tuner-xc2028.h"
24 #include "tuner-xc2028-types.h"
26 MODULE_DESCRIPTION("driver for em28xx based DVB cards");
27 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
28 MODULE_LICENSE("GPL");
30 static unsigned int debug;
31 module_param(debug, int, 0644);
32 MODULE_PARM_DESC(debug, "enable debug messages [dvb]");
34 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
36 #define dprintk(level, fmt, arg...) do { \
38 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg) \
42 buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
44 struct em28xx_fh *fh = vq->priv_data;
45 struct em28xx *dev = fh->dev;
47 *size = 16 * fh->dev->width * fh->dev->height >> 3;
49 *count = EM28XX_DEF_BUF;
51 if (*count < EM28XX_MIN_BUF)
52 *count = EM28XX_MIN_BUF;
54 dev->mode = EM28XX_DIGITAL_MODE;
59 /* ------------------------------------------------------------------ */
63 /* ------------------------------------------------------------------ */
65 static int attach_xc3028(u8 addr, struct em28xx *dev)
67 struct dvb_frontend *fe;
68 struct xc2028_ctrl ctl;
69 struct xc2028_config cfg = {
70 .i2c_adap = &dev->i2c_adap,
75 if (!dev->dvb.frontend) {
76 printk(KERN_ERR "%s/2: dvb frontend not attached. "
77 "Can't attach xc3028\n",
82 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
84 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
86 dvb_frontend_detach(dev->dvb.frontend);
87 dvb_unregister_frontend(dev->dvb.frontend);
88 dev->dvb.frontend = NULL;
92 printk(KERN_INFO "%s/2: xc3028 attached\n", dev->name);
97 static int dvb_init(struct em28xx *dev)
99 /* init struct videobuf_dvb */
100 dev->dvb.name = dev->name;
102 dev->qops->buf_setup = buffer_setup;
104 videobuf_queue_vmalloc_init(&dev->dvb.dvbq, dev->qops,
105 &dev->udev->dev, &dev->slock,
106 V4L2_BUF_TYPE_VIDEO_CAPTURE,
107 V4L2_FIELD_ALTERNATE,
108 sizeof(struct em28xx_buffer), dev);
111 switch (dev->model) {
113 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card"
114 " isn't supported yet\n",
118 if (NULL == dev->dvb.frontend) {
120 "%s/2: frontend initialization failed\n",
125 /* register everything */
126 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev,
131 static int dvb_fini(struct em28xx *dev)
133 if (dev->dvb.frontend)
134 videobuf_dvb_unregister(&dev->dvb);
139 static struct em28xx_ops dvb_ops = {
141 .name = "Em28xx dvb Extension",
146 static int __init em28xx_dvb_register(void)
148 return em28xx_register_extension(&dvb_ops);
151 static void __exit em28xx_dvb_unregister(void)
153 em28xx_unregister_extension(&dvb_ops);
156 module_init(em28xx_dvb_register);
157 module_exit(em28xx_dvb_unregister);