diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-17 20:36:41 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:09:40 -0400 |
commit | 3aefb79af8d41c85e11da7109d62038849421bb6 (patch) | |
tree | 1a85e8e0de5136f9c578db882c49f8faa6ecd4a5 /drivers/media | |
parent | 168c626cb8f85df17585af99e14403904641c7ac (diff) |
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>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/em28xx/Kconfig | 8 | ||||
-rw-r--r-- | drivers/media/video/em28xx/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-cards.c | 21 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-dvb.c | 157 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 12 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx.h | 43 |
6 files changed, 218 insertions, 24 deletions
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig index 0f7a0bd86ff4..11a2759ecbc9 100644 --- a/drivers/media/video/em28xx/Kconfig +++ b/drivers/media/video/em28xx/Kconfig | |||
@@ -27,3 +27,11 @@ config VIDEO_EM28XX_ALSA | |||
27 | To compile this driver as a module, choose M here: the | 27 | To compile this driver as a module, choose M here: the |
28 | module will be called em28xx-alsa | 28 | module will be called em28xx-alsa |
29 | 29 | ||
30 | config VIDEO_EM28XX_DVB | ||
31 | tristate "DVB/ATSC Support for em28xx based TV cards" | ||
32 | depends on VIDEO_EM28XX && DVB_CORE | ||
33 | select VIDEOBUF_DVB | ||
34 | select FW_LOADER | ||
35 | ---help--- | ||
36 | This adds support for DVB cards based on the | ||
37 | Empiatech em28xx chips. | ||
diff --git a/drivers/media/video/em28xx/Makefile b/drivers/media/video/em28xx/Makefile index 0924550992d0..3d1c3cc337fe 100644 --- a/drivers/media/video/em28xx/Makefile +++ b/drivers/media/video/em28xx/Makefile | |||
@@ -5,6 +5,7 @@ em28xx-alsa-objs := em28xx-audio.o | |||
5 | 5 | ||
6 | obj-$(CONFIG_VIDEO_EM28XX) += em28xx.o | 6 | obj-$(CONFIG_VIDEO_EM28XX) += em28xx.o |
7 | obj-$(CONFIG_VIDEO_EM28XX_ALSA) += em28xx-alsa.o | 7 | obj-$(CONFIG_VIDEO_EM28XX_ALSA) += em28xx-alsa.o |
8 | obj-$(CONFIG_VIDEO_EM28XX_DVB) += em28xx-dvb.o | ||
8 | 9 | ||
9 | EXTRA_CFLAGS += -Idrivers/media/video | 10 | EXTRA_CFLAGS += -Idrivers/media/video |
10 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | 11 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 94aed008f83b..bbd75bd3ff1a 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -52,26 +52,6 @@ struct em28xx_hash_table { | |||
52 | unsigned int tuner; | 52 | unsigned int tuner; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | /* Boards supported by driver */ | ||
56 | |||
57 | #define EM2800_BOARD_UNKNOWN 0 | ||
58 | #define EM2820_BOARD_UNKNOWN 1 | ||
59 | #define EM2820_BOARD_TERRATEC_CINERGY_250 2 | ||
60 | #define EM2820_BOARD_PINNACLE_USB_2 3 | ||
61 | #define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 4 | ||
62 | #define EM2820_BOARD_MSI_VOX_USB_2 5 | ||
63 | #define EM2800_BOARD_TERRATEC_CINERGY_200 6 | ||
64 | #define EM2800_BOARD_LEADTEK_WINFAST_USBII 7 | ||
65 | #define EM2800_BOARD_KWORLD_USB2800 8 | ||
66 | #define EM2820_BOARD_PINNACLE_DVC_90 9 | ||
67 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 10 | ||
68 | #define EM2880_BOARD_TERRATEC_HYBRID_XS 11 | ||
69 | #define EM2820_BOARD_KWORLD_PVRTV2800RF 12 | ||
70 | #define EM2880_BOARD_TERRATEC_PRODIGY_XS 13 | ||
71 | #define EM2820_BOARD_PROLINK_PLAYTV_USB2 14 | ||
72 | #define EM2800_BOARD_VGEAR_POCKETTV 15 | ||
73 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 16 | ||
74 | |||
75 | struct em28xx_board em28xx_boards[] = { | 55 | struct em28xx_board em28xx_boards[] = { |
76 | [EM2800_BOARD_UNKNOWN] = { | 56 | [EM2800_BOARD_UNKNOWN] = { |
77 | .name = "Unknown EM2800 video grabber", | 57 | .name = "Unknown EM2800 video grabber", |
@@ -665,6 +645,7 @@ static void em28xx_set_model(struct em28xx *dev) | |||
665 | dev->analog_gpio = em28xx_boards[dev->model].analog_gpio; | 645 | dev->analog_gpio = em28xx_boards[dev->model].analog_gpio; |
666 | dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s; | 646 | dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s; |
667 | dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480; | 647 | dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480; |
648 | dev->has_dvb = em28xx_boards[dev->model].has_dvb; | ||
668 | } | 649 | } |
669 | 650 | ||
670 | /* ----------------------------------------------------------------------- */ | 651 | /* ----------------------------------------------------------------------- */ |
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c new file mode 100644 index 000000000000..1ffe64f62095 --- /dev/null +++ b/drivers/media/video/em28xx/em28xx-dvb.c | |||
@@ -0,0 +1,157 @@ | |||
1 | /* | ||
2 | DVB device driver for em28xx | ||
3 | |||
4 | (c) 2008 Mauro Carvalho Chehab <mchehab@infradead.org> | ||
5 | |||
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] | ||
9 | |||
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. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/usb.h> | ||
17 | |||
18 | #include "em28xx.h" | ||
19 | #include <media/v4l2-common.h> | ||
20 | #include <media/videobuf-vmalloc.h> | ||
21 | |||
22 | #include "lgdt330x.h" | ||
23 | #include "tuner-xc2028.h" | ||
24 | #include "tuner-xc2028-types.h" | ||
25 | |||
26 | MODULE_DESCRIPTION("driver for em28xx based DVB cards"); | ||
27 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); | ||
28 | MODULE_LICENSE("GPL"); | ||
29 | |||
30 | static unsigned int debug; | ||
31 | module_param(debug, int, 0644); | ||
32 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); | ||
33 | |||
34 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
35 | |||
36 | #define dprintk(level, fmt, arg...) do { \ | ||
37 | if (debug >= level) \ | ||
38 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg) \ | ||
39 | } while (0) | ||
40 | |||
41 | static int | ||
42 | buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) | ||
43 | { | ||
44 | struct em28xx_fh *fh = vq->priv_data; | ||
45 | struct em28xx *dev = fh->dev; | ||
46 | |||
47 | *size = 16 * fh->dev->width * fh->dev->height >> 3; | ||
48 | if (0 == *count) | ||
49 | *count = EM28XX_DEF_BUF; | ||
50 | |||
51 | if (*count < EM28XX_MIN_BUF) | ||
52 | *count = EM28XX_MIN_BUF; | ||
53 | |||
54 | dev->mode = EM28XX_DIGITAL_MODE; | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | /* ------------------------------------------------------------------ */ | ||
60 | |||
61 | /* Add demods here */ | ||
62 | |||
63 | /* ------------------------------------------------------------------ */ | ||
64 | |||
65 | static int attach_xc3028(u8 addr, struct em28xx *dev) | ||
66 | { | ||
67 | struct dvb_frontend *fe; | ||
68 | struct xc2028_ctrl ctl; | ||
69 | struct xc2028_config cfg = { | ||
70 | .i2c_adap = &dev->i2c_adap, | ||
71 | .i2c_addr = addr, | ||
72 | .ctrl = &ctl, | ||
73 | }; | ||
74 | |||
75 | if (!dev->dvb.frontend) { | ||
76 | printk(KERN_ERR "%s/2: dvb frontend not attached. " | ||
77 | "Can't attach xc3028\n", | ||
78 | dev->name); | ||
79 | return -EINVAL; | ||
80 | } | ||
81 | |||
82 | fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); | ||
83 | if (!fe) { | ||
84 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | ||
85 | dev->name); | ||
86 | dvb_frontend_detach(dev->dvb.frontend); | ||
87 | dvb_unregister_frontend(dev->dvb.frontend); | ||
88 | dev->dvb.frontend = NULL; | ||
89 | return -EINVAL; | ||
90 | } | ||
91 | |||
92 | printk(KERN_INFO "%s/2: xc3028 attached\n", dev->name); | ||
93 | |||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | static int dvb_init(struct em28xx *dev) | ||
98 | { | ||
99 | /* init struct videobuf_dvb */ | ||
100 | dev->dvb.name = dev->name; | ||
101 | |||
102 | dev->qops->buf_setup = buffer_setup; | ||
103 | |||
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); | ||
109 | |||
110 | /* init frontend */ | ||
111 | switch (dev->model) { | ||
112 | default: | ||
113 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" | ||
114 | " isn't supported yet\n", | ||
115 | dev->name); | ||
116 | break; | ||
117 | } | ||
118 | if (NULL == dev->dvb.frontend) { | ||
119 | printk(KERN_ERR | ||
120 | "%s/2: frontend initialization failed\n", | ||
121 | dev->name); | ||
122 | return -EINVAL; | ||
123 | } | ||
124 | |||
125 | /* register everything */ | ||
126 | return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, | ||
127 | &dev->udev->dev, | ||
128 | adapter_nr); | ||
129 | } | ||
130 | |||
131 | static int dvb_fini(struct em28xx *dev) | ||
132 | { | ||
133 | if (dev->dvb.frontend) | ||
134 | videobuf_dvb_unregister(&dev->dvb); | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | static struct em28xx_ops dvb_ops = { | ||
140 | .id = EM28XX_DVB, | ||
141 | .name = "Em28xx dvb Extension", | ||
142 | .init = dvb_init, | ||
143 | .fini = dvb_fini, | ||
144 | }; | ||
145 | |||
146 | static int __init em28xx_dvb_register(void) | ||
147 | { | ||
148 | return em28xx_register_extension(&dvb_ops); | ||
149 | } | ||
150 | |||
151 | static void __exit em28xx_dvb_unregister(void) | ||
152 | { | ||
153 | em28xx_unregister_extension(&dvb_ops); | ||
154 | } | ||
155 | |||
156 | module_init(em28xx_dvb_register); | ||
157 | module_exit(em28xx_dvb_unregister); | ||
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 6084f8452b2b..362251838d4b 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -63,10 +63,6 @@ MODULE_PARM_DESC(isoc_debug, "enable debug messages [isoc transfers]"); | |||
63 | printk(KERN_INFO "%s %s :"fmt, \ | 63 | printk(KERN_INFO "%s %s :"fmt, \ |
64 | dev->name, __func__ , ##arg); } while (0) | 64 | dev->name, __func__ , ##arg); } while (0) |
65 | 65 | ||
66 | /* Limits minimum and default number of buffers */ | ||
67 | #define EM28XX_MIN_BUF 4 | ||
68 | #define EM28XX_DEF_BUF 8 | ||
69 | |||
70 | MODULE_AUTHOR(DRIVER_AUTHOR); | 66 | MODULE_AUTHOR(DRIVER_AUTHOR); |
71 | MODULE_DESCRIPTION(DRIVER_DESC); | 67 | MODULE_DESCRIPTION(DRIVER_DESC); |
72 | MODULE_LICENSE("GPL"); | 68 | MODULE_LICENSE("GPL"); |
@@ -2237,6 +2233,9 @@ static void request_module_async(struct work_struct *work) | |||
2237 | request_module("snd-usb-audio"); | 2233 | request_module("snd-usb-audio"); |
2238 | else | 2234 | else |
2239 | request_module("em28xx-alsa"); | 2235 | request_module("em28xx-alsa"); |
2236 | |||
2237 | if (dev->has_dvb) | ||
2238 | request_module("em28xx-dvb"); | ||
2240 | } | 2239 | } |
2241 | 2240 | ||
2242 | static void request_modules(struct em28xx *dev) | 2241 | static void request_modules(struct em28xx *dev) |
@@ -2368,6 +2367,11 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2368 | /* save our data pointer in this interface device */ | 2367 | /* save our data pointer in this interface device */ |
2369 | usb_set_intfdata(interface, dev); | 2368 | usb_set_intfdata(interface, dev); |
2370 | 2369 | ||
2370 | #if defined(CONFIG_VIDEO_EM28XX_DVB) || defined(CONFIG_VIDEO_EM28XX_DVB_MODULE) | ||
2371 | dev->qops = kmalloc(sizeof(em28xx_video_qops), GFP_KERNEL); | ||
2372 | memcpy(dev->qops, &em28xx_video_qops, sizeof(em28xx_video_qops)); | ||
2373 | #endif | ||
2374 | |||
2371 | request_modules(dev); | 2375 | request_modules(dev); |
2372 | 2376 | ||
2373 | return 0; | 2377 | return 0; |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 0080a09860d9..96a56faeb77b 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -31,6 +31,32 @@ | |||
31 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
32 | #include <linux/mutex.h> | 32 | #include <linux/mutex.h> |
33 | #include <media/ir-kbd-i2c.h> | 33 | #include <media/ir-kbd-i2c.h> |
34 | #if defined(CONFIG_VIDEO_EM28XX_DVB) || defined(CONFIG_VIDEO_EM28XX_DVB_MODULE) | ||
35 | #include <media/videobuf-dvb.h> | ||
36 | #endif | ||
37 | |||
38 | /* Boards supported by driver */ | ||
39 | #define EM2800_BOARD_UNKNOWN 0 | ||
40 | #define EM2820_BOARD_UNKNOWN 1 | ||
41 | #define EM2820_BOARD_TERRATEC_CINERGY_250 2 | ||
42 | #define EM2820_BOARD_PINNACLE_USB_2 3 | ||
43 | #define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 4 | ||
44 | #define EM2820_BOARD_MSI_VOX_USB_2 5 | ||
45 | #define EM2800_BOARD_TERRATEC_CINERGY_200 6 | ||
46 | #define EM2800_BOARD_LEADTEK_WINFAST_USBII 7 | ||
47 | #define EM2800_BOARD_KWORLD_USB2800 8 | ||
48 | #define EM2820_BOARD_PINNACLE_DVC_90 9 | ||
49 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 10 | ||
50 | #define EM2880_BOARD_TERRATEC_HYBRID_XS 11 | ||
51 | #define EM2820_BOARD_KWORLD_PVRTV2800RF 12 | ||
52 | #define EM2880_BOARD_TERRATEC_PRODIGY_XS 13 | ||
53 | #define EM2820_BOARD_PROLINK_PLAYTV_USB2 14 | ||
54 | #define EM2800_BOARD_VGEAR_POCKETTV 15 | ||
55 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 16 | ||
56 | |||
57 | /* Limits minimum and default number of buffers */ | ||
58 | #define EM28XX_MIN_BUF 4 | ||
59 | #define EM28XX_DEF_BUF 8 | ||
34 | 60 | ||
35 | /* maximum number of em28xx boards */ | 61 | /* maximum number of em28xx boards */ |
36 | #define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ | 62 | #define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ |
@@ -81,6 +107,11 @@ | |||
81 | /* time in msecs to wait for i2c writes to finish */ | 107 | /* time in msecs to wait for i2c writes to finish */ |
82 | #define EM2800_I2C_WRITE_TIMEOUT 20 | 108 | #define EM2800_I2C_WRITE_TIMEOUT 20 |
83 | 109 | ||
110 | enum em28xx_mode { | ||
111 | EM28XX_ANALOG_MODE, | ||
112 | EM28XX_DIGITAL_MODE, | ||
113 | }; | ||
114 | |||
84 | enum em28xx_stream_state { | 115 | enum em28xx_stream_state { |
85 | STREAM_OFF, | 116 | STREAM_OFF, |
86 | STREAM_INTERRUPT, | 117 | STREAM_INTERRUPT, |
@@ -200,6 +231,7 @@ struct em28xx_board { | |||
200 | unsigned int mts_firmware:1; | 231 | unsigned int mts_firmware:1; |
201 | unsigned int has_12mhz_i2s:1; | 232 | unsigned int has_12mhz_i2s:1; |
202 | unsigned int max_range_640_480:1; | 233 | unsigned int max_range_640_480:1; |
234 | unsigned int has_dvb:1; | ||
203 | 235 | ||
204 | unsigned int analog_gpio; | 236 | unsigned int analog_gpio; |
205 | 237 | ||
@@ -234,7 +266,10 @@ enum em28xx_dev_state { | |||
234 | #define EM28XX_NUM_AUDIO_PACKETS 64 | 266 | #define EM28XX_NUM_AUDIO_PACKETS 64 |
235 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ | 267 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ |
236 | #define EM28XX_CAPTURE_STREAM_EN 1 | 268 | #define EM28XX_CAPTURE_STREAM_EN 1 |
269 | |||
270 | /* em28xx extensions */ | ||
237 | #define EM28XX_AUDIO 0x10 | 271 | #define EM28XX_AUDIO 0x10 |
272 | #define EM28XX_DVB 0x20 | ||
238 | 273 | ||
239 | struct em28xx_audio { | 274 | struct em28xx_audio { |
240 | char name[50]; | 275 | char name[50]; |
@@ -266,6 +301,7 @@ struct em28xx { | |||
266 | unsigned int has_audio_class:1; | 301 | unsigned int has_audio_class:1; |
267 | unsigned int has_12mhz_i2s:1; | 302 | unsigned int has_12mhz_i2s:1; |
268 | unsigned int max_range_640_480:1; | 303 | unsigned int max_range_640_480:1; |
304 | unsigned int has_dvb:1; | ||
269 | 305 | ||
270 | int video_inputs; /* number of video inputs */ | 306 | int video_inputs; /* number of video inputs */ |
271 | struct list_head devlist; | 307 | struct list_head devlist; |
@@ -340,6 +376,13 @@ struct em28xx { | |||
340 | int (*em28xx_write_regs_req) (struct em28xx * dev, u8 req, u16 reg, | 376 | int (*em28xx_write_regs_req) (struct em28xx * dev, u8 req, u16 reg, |
341 | char *buf, int len); | 377 | char *buf, int len); |
342 | int (*em28xx_read_reg_req) (struct em28xx * dev, u8 req, u16 reg); | 378 | int (*em28xx_read_reg_req) (struct em28xx * dev, u8 req, u16 reg); |
379 | |||
380 | enum em28xx_mode mode; | ||
381 | |||
382 | #if defined(CONFIG_VIDEO_EM28XX_DVB) || defined(CONFIG_VIDEO_EM28XX_DVB_MODULE) | ||
383 | struct videobuf_dvb dvb; | ||
384 | struct videobuf_queue_ops *qops; | ||
385 | #endif | ||
343 | }; | 386 | }; |
344 | 387 | ||
345 | struct em28xx_fh { | 388 | struct em28xx_fh { |