-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V4L/DVB (7593): em28xx: add a module to handle dvb
This patch adds em28xx-dvb. This driver is highly based on cx88-dvb and saa7134-dvb. This code currently loads and unloads successfully. However, some changes are needed to properly support the mpeg streams and to setup em28xx to work on DVB mode. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
- Loading branch information
Mauro Carvalho Chehab
committed
Apr 24, 2008
1 parent
168c626
commit 3aefb79
Showing
6 changed files
with
218 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
/* | ||
DVB device driver for em28xx | ||
(c) 2008 Mauro Carvalho Chehab <mchehab@infradead.org> | ||
Based on cx88-dvb and saa7134-dvb originally written by: | ||
(c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> | ||
(c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License. | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/usb.h> | ||
|
||
#include "em28xx.h" | ||
#include <media/v4l2-common.h> | ||
#include <media/videobuf-vmalloc.h> | ||
|
||
#include "lgdt330x.h" | ||
#include "tuner-xc2028.h" | ||
#include "tuner-xc2028-types.h" | ||
|
||
MODULE_DESCRIPTION("driver for em28xx based DVB cards"); | ||
MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); | ||
MODULE_LICENSE("GPL"); | ||
|
||
static unsigned int debug; | ||
module_param(debug, int, 0644); | ||
MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); | ||
|
||
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
|
||
#define dprintk(level, fmt, arg...) do { \ | ||
if (debug >= level) \ | ||
printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg) \ | ||
} while (0) | ||
|
||
static int | ||
buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) | ||
{ | ||
struct em28xx_fh *fh = vq->priv_data; | ||
struct em28xx *dev = fh->dev; | ||
|
||
*size = 16 * fh->dev->width * fh->dev->height >> 3; | ||
if (0 == *count) | ||
*count = EM28XX_DEF_BUF; | ||
|
||
if (*count < EM28XX_MIN_BUF) | ||
*count = EM28XX_MIN_BUF; | ||
|
||
dev->mode = EM28XX_DIGITAL_MODE; | ||
|
||
return 0; | ||
} | ||
|
||
/* ------------------------------------------------------------------ */ | ||
|
||
/* Add demods here */ | ||
|
||
/* ------------------------------------------------------------------ */ | ||
|
||
static int attach_xc3028(u8 addr, struct em28xx *dev) | ||
{ | ||
struct dvb_frontend *fe; | ||
struct xc2028_ctrl ctl; | ||
struct xc2028_config cfg = { | ||
.i2c_adap = &dev->i2c_adap, | ||
.i2c_addr = addr, | ||
.ctrl = &ctl, | ||
}; | ||
|
||
if (!dev->dvb.frontend) { | ||
printk(KERN_ERR "%s/2: dvb frontend not attached. " | ||
"Can't attach xc3028\n", | ||
dev->name); | ||
return -EINVAL; | ||
} | ||
|
||
fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); | ||
if (!fe) { | ||
printk(KERN_ERR "%s/2: xc3028 attach failed\n", | ||
dev->name); | ||
dvb_frontend_detach(dev->dvb.frontend); | ||
dvb_unregister_frontend(dev->dvb.frontend); | ||
dev->dvb.frontend = NULL; | ||
return -EINVAL; | ||
} | ||
|
||
printk(KERN_INFO "%s/2: xc3028 attached\n", dev->name); | ||
|
||
return 0; | ||
} | ||
|
||
static int dvb_init(struct em28xx *dev) | ||
{ | ||
/* init struct videobuf_dvb */ | ||
dev->dvb.name = dev->name; | ||
|
||
dev->qops->buf_setup = buffer_setup; | ||
|
||
videobuf_queue_vmalloc_init(&dev->dvb.dvbq, dev->qops, | ||
&dev->udev->dev, &dev->slock, | ||
V4L2_BUF_TYPE_VIDEO_CAPTURE, | ||
V4L2_FIELD_ALTERNATE, | ||
sizeof(struct em28xx_buffer), dev); | ||
|
||
/* init frontend */ | ||
switch (dev->model) { | ||
default: | ||
printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" | ||
" isn't supported yet\n", | ||
dev->name); | ||
break; | ||
} | ||
if (NULL == dev->dvb.frontend) { | ||
printk(KERN_ERR | ||
"%s/2: frontend initialization failed\n", | ||
dev->name); | ||
return -EINVAL; | ||
} | ||
|
||
/* register everything */ | ||
return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, | ||
&dev->udev->dev, | ||
adapter_nr); | ||
} | ||
|
||
static int dvb_fini(struct em28xx *dev) | ||
{ | ||
if (dev->dvb.frontend) | ||
videobuf_dvb_unregister(&dev->dvb); | ||
|
||
return 0; | ||
} | ||
|
||
static struct em28xx_ops dvb_ops = { | ||
.id = EM28XX_DVB, | ||
.name = "Em28xx dvb Extension", | ||
.init = dvb_init, | ||
.fini = dvb_fini, | ||
}; | ||
|
||
static int __init em28xx_dvb_register(void) | ||
{ | ||
return em28xx_register_extension(&dvb_ops); | ||
} | ||
|
||
static void __exit em28xx_dvb_unregister(void) | ||
{ | ||
em28xx_unregister_extension(&dvb_ops); | ||
} | ||
|
||
module_init(em28xx_dvb_register); | ||
module_exit(em28xx_dvb_unregister); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters