aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/Kconfig4
-rw-r--r--drivers/media/video/Makefile5
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c51
-rw-r--r--drivers/media/video/bt8xx/bttv-vbi.c4
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c16
-rw-r--r--drivers/media/video/cx88/cx88.h1
-rw-r--r--drivers/media/video/em28xx/em28xx-audio.c6
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c8
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c111
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c79
-rw-r--r--drivers/media/video/em28xx/em28xx.h5
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c123
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c28
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c20
-rw-r--r--drivers/media/video/saa7134/saa7134.h2
-rw-r--r--drivers/media/video/stk-sensor.c23
-rw-r--r--drivers/media/video/stk-webcam.c104
-rw-r--r--drivers/media/video/stk-webcam.h3
-rw-r--r--drivers/media/video/tcm825x.c2
-rw-r--r--drivers/media/video/tuner-core.c2
-rw-r--r--drivers/media/video/tuner-xc2028.c3
-rw-r--r--drivers/media/video/tvaudio.c10
-rw-r--r--drivers/media/video/tveeprom.c2
-rw-r--r--drivers/media/video/v4l2-common.c393
-rw-r--r--drivers/media/video/videobuf-core.c78
-rw-r--r--drivers/media/video/videobuf-dma-sg.c4
-rw-r--r--drivers/media/video/videobuf-vmalloc.c20
-rw-r--r--drivers/media/video/videodev.c444
-rw-r--r--drivers/media/video/zoran.h22
-rw-r--r--drivers/media/video/zoran_device.c12
-rw-r--r--drivers/media/video/zr364xx.c2
33 files changed, 947 insertions, 652 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index a2e8987a6195..37072a21d8c9 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -4,14 +4,14 @@
4 4
5menuconfig VIDEO_CAPTURE_DRIVERS 5menuconfig VIDEO_CAPTURE_DRIVERS
6 bool "Video capture adapters" 6 bool "Video capture adapters"
7 depends on VIDEO_DEV 7 depends on VIDEO_V4L2
8 default y 8 default y
9 ---help--- 9 ---help---
10 Say Y here to enable selecting the video adapters for 10 Say Y here to enable selecting the video adapters for
11 webcams, analog TV, and hybrid analog/digital TV. 11 webcams, analog TV, and hybrid analog/digital TV.
12 Some of those devices also supports FM radio. 12 Some of those devices also supports FM radio.
13 13
14if VIDEO_CAPTURE_DRIVERS && VIDEO_DEV 14if VIDEO_CAPTURE_DRIVERS && VIDEO_V4L2
15 15
16config VIDEO_ADV_DEBUG 16config VIDEO_ADV_DEBUG
17 bool "Enable advanced debug functionality" 17 bool "Enable advanced debug functionality"
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 850b8c6f4577..3f209b32eeac 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -10,8 +10,9 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o
10 10
11stkwebcam-objs := stk-webcam.o stk-sensor.o 11stkwebcam-objs := stk-webcam.o stk-sensor.o
12 12
13obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o compat_ioctl32.o \ 13obj-$(CONFIG_VIDEO_DEV) += videodev.o compat_ioctl32.o v4l2-int-device.o
14 v4l2-int-device.o 14
15obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o
15 16
16ifeq ($(CONFIG_VIDEO_V4L1_COMPAT),y) 17ifeq ($(CONFIG_VIDEO_V4L1_COMPAT),y)
17 obj-$(CONFIG_VIDEO_DEV) += v4l1-compat.o 18 obj-$(CONFIG_VIDEO_DEV) += v4l1-compat.o
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 907dc62c1783..5404fcc5276d 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2354,8 +2354,8 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
2354 BUG(); 2354 BUG();
2355 } 2355 }
2356 2356
2357 mutex_lock(&fh->cap.lock); 2357 mutex_lock(&fh->cap.vb_lock);
2358 kfree(fh->ov.clips); 2358 kfree(fh->ov.clips);
2359 fh->ov.clips = clips; 2359 fh->ov.clips = clips;
2360 fh->ov.nclips = n; 2360 fh->ov.nclips = n;
2361 2361
@@ -2376,7 +2376,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
2376 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); 2376 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
2377 retval = bttv_switch_overlay(btv,fh,new); 2377 retval = bttv_switch_overlay(btv,fh,new);
2378 } 2378 }
2379 mutex_unlock(&fh->cap.lock); 2379 mutex_unlock(&fh->cap.vb_lock);
2380 return retval; 2380 return retval;
2381} 2381}
2382 2382
@@ -2576,7 +2576,7 @@ static int bttv_s_fmt_cap(struct file *file, void *priv,
2576 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 2576 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
2577 2577
2578 /* update our state informations */ 2578 /* update our state informations */
2579 mutex_lock(&fh->cap.lock); 2579 mutex_lock(&fh->cap.vb_lock);
2580 fh->fmt = fmt; 2580 fh->fmt = fmt;
2581 fh->cap.field = f->fmt.pix.field; 2581 fh->cap.field = f->fmt.pix.field;
2582 fh->cap.last = V4L2_FIELD_NONE; 2582 fh->cap.last = V4L2_FIELD_NONE;
@@ -2585,7 +2585,7 @@ static int bttv_s_fmt_cap(struct file *file, void *priv,
2585 btv->init.fmt = fmt; 2585 btv->init.fmt = fmt;
2586 btv->init.width = f->fmt.pix.width; 2586 btv->init.width = f->fmt.pix.width;
2587 btv->init.height = f->fmt.pix.height; 2587 btv->init.height = f->fmt.pix.height;
2588 mutex_unlock(&fh->cap.lock); 2588 mutex_unlock(&fh->cap.vb_lock);
2589 2589
2590 return 0; 2590 return 0;
2591} 2591}
@@ -2611,11 +2611,11 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
2611 unsigned int i; 2611 unsigned int i;
2612 struct bttv_fh *fh = priv; 2612 struct bttv_fh *fh = priv;
2613 2613
2614 mutex_lock(&fh->cap.lock); 2614 mutex_lock(&fh->cap.vb_lock);
2615 retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, 2615 retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
2616 V4L2_MEMORY_MMAP); 2616 V4L2_MEMORY_MMAP);
2617 if (retval < 0) { 2617 if (retval < 0) {
2618 mutex_unlock(&fh->cap.lock); 2618 mutex_unlock(&fh->cap.vb_lock);
2619 return retval; 2619 return retval;
2620 } 2620 }
2621 2621
@@ -2627,7 +2627,7 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
2627 for (i = 0; i < gbuffers; i++) 2627 for (i = 0; i < gbuffers; i++)
2628 mbuf->offsets[i] = i * gbufsize; 2628 mbuf->offsets[i] = i * gbufsize;
2629 2629
2630 mutex_unlock(&fh->cap.lock); 2630 mutex_unlock(&fh->cap.vb_lock);
2631 return 0; 2631 return 0;
2632} 2632}
2633#endif 2633#endif
@@ -2756,10 +2756,11 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
2756 if (!check_alloc_btres(btv, fh, RESOURCE_OVERLAY)) 2756 if (!check_alloc_btres(btv, fh, RESOURCE_OVERLAY))
2757 return -EBUSY; 2757 return -EBUSY;
2758 2758
2759 mutex_lock(&fh->cap.lock); 2759 mutex_lock(&fh->cap.vb_lock);
2760 if (on) { 2760 if (on) {
2761 fh->ov.tvnorm = btv->tvnorm; 2761 fh->ov.tvnorm = btv->tvnorm;
2762 new = videobuf_pci_alloc(sizeof(*new)); 2762 new = videobuf_pci_alloc(sizeof(*new));
2763 new->crop = btv->crop[!!fh->do_crop].rect;
2763 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); 2764 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
2764 } else { 2765 } else {
2765 new = NULL; 2766 new = NULL;
@@ -2767,7 +2768,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
2767 2768
2768 /* switch over */ 2769 /* switch over */
2769 retval = bttv_switch_overlay(btv, fh, new); 2770 retval = bttv_switch_overlay(btv, fh, new);
2770 mutex_unlock(&fh->cap.lock); 2771 mutex_unlock(&fh->cap.vb_lock);
2771 return retval; 2772 return retval;
2772} 2773}
2773 2774
@@ -2806,7 +2807,7 @@ static int bttv_s_fbuf(struct file *file, void *f,
2806 } 2807 }
2807 2808
2808 /* ok, accept it */ 2809 /* ok, accept it */
2809 mutex_lock(&fh->cap.lock); 2810 mutex_lock(&fh->cap.vb_lock);
2810 btv->fbuf.base = fb->base; 2811 btv->fbuf.base = fb->base;
2811 btv->fbuf.fmt.width = fb->fmt.width; 2812 btv->fbuf.fmt.width = fb->fmt.width;
2812 btv->fbuf.fmt.height = fb->fmt.height; 2813 btv->fbuf.fmt.height = fb->fmt.height;
@@ -2838,7 +2839,7 @@ static int bttv_s_fbuf(struct file *file, void *f,
2838 retval = bttv_switch_overlay(btv, fh, new); 2839 retval = bttv_switch_overlay(btv, fh, new);
2839 } 2840 }
2840 } 2841 }
2841 mutex_unlock(&fh->cap.lock); 2842 mutex_unlock(&fh->cap.vb_lock);
2842 return retval; 2843 return retval;
2843} 2844}
2844 2845
@@ -3090,7 +3091,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
3090 3091
3091 fh->do_crop = 1; 3092 fh->do_crop = 1;
3092 3093
3093 mutex_lock(&fh->cap.lock); 3094 mutex_lock(&fh->cap.vb_lock);
3094 3095
3095 if (fh->width < c.min_scaled_width) { 3096 if (fh->width < c.min_scaled_width) {
3096 fh->width = c.min_scaled_width; 3097 fh->width = c.min_scaled_width;
@@ -3108,7 +3109,7 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
3108 btv->init.height = c.max_scaled_height; 3109 btv->init.height = c.max_scaled_height;
3109 } 3110 }
3110 3111
3111 mutex_unlock(&fh->cap.lock); 3112 mutex_unlock(&fh->cap.vb_lock);
3112 3113
3113 return 0; 3114 return 0;
3114} 3115}
@@ -3177,30 +3178,25 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3177 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); 3178 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream);
3178 } else { 3179 } else {
3179 /* read() capture */ 3180 /* read() capture */
3180 mutex_lock(&fh->cap.lock); 3181 mutex_lock(&fh->cap.vb_lock);
3181 if (NULL == fh->cap.read_buf) { 3182 if (NULL == fh->cap.read_buf) {
3182 /* need to capture a new frame */ 3183 /* need to capture a new frame */
3183 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) { 3184 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM))
3184 mutex_unlock(&fh->cap.lock); 3185 goto err;
3185 return POLLERR;
3186 }
3187 fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize); 3186 fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize);
3188 if (NULL == fh->cap.read_buf) { 3187 if (NULL == fh->cap.read_buf)
3189 mutex_unlock(&fh->cap.lock); 3188 goto err;
3190 return POLLERR;
3191 }
3192 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; 3189 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
3193 field = videobuf_next_field(&fh->cap); 3190 field = videobuf_next_field(&fh->cap);
3194 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { 3191 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
3195 kfree (fh->cap.read_buf); 3192 kfree (fh->cap.read_buf);
3196 fh->cap.read_buf = NULL; 3193 fh->cap.read_buf = NULL;
3197 mutex_unlock(&fh->cap.lock); 3194 goto err;
3198 return POLLERR;
3199 } 3195 }
3200 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); 3196 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
3201 fh->cap.read_off = 0; 3197 fh->cap.read_off = 0;
3202 } 3198 }
3203 mutex_unlock(&fh->cap.lock); 3199 mutex_unlock(&fh->cap.vb_lock);
3204 buf = (struct bttv_buffer*)fh->cap.read_buf; 3200 buf = (struct bttv_buffer*)fh->cap.read_buf;
3205 } 3201 }
3206 3202
@@ -3209,6 +3205,9 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3209 buf->vb.state == VIDEOBUF_ERROR) 3205 buf->vb.state == VIDEOBUF_ERROR)
3210 return POLLIN|POLLRDNORM; 3206 return POLLIN|POLLRDNORM;
3211 return 0; 3207 return 0;
3208err:
3209 mutex_unlock(&fh->cap.vb_lock);
3210 return POLLERR;
3212} 3211}
3213 3212
3214static int bttv_open(struct inode *inode, struct file *file) 3213static int bttv_open(struct inode *inode, struct file *file)
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c
index 1f0cc79e2a33..75fa82c7c735 100644
--- a/drivers/media/video/bt8xx/bttv-vbi.c
+++ b/drivers/media/video/bt8xx/bttv-vbi.c
@@ -352,13 +352,13 @@ int bttv_s_fmt_vbi(struct file *file, void *f, struct v4l2_format *frt)
352 because vbi_fmt.end counts field lines times two. */ 352 because vbi_fmt.end counts field lines times two. */
353 end = max(frt->fmt.vbi.start[0], start1) * 2 + 2; 353 end = max(frt->fmt.vbi.start[0], start1) * 2 + 2;
354 354
355 mutex_lock(&fh->vbi.lock); 355 mutex_lock(&fh->vbi.vb_lock);
356 356
357 fh->vbi_fmt.fmt = frt->fmt.vbi; 357 fh->vbi_fmt.fmt = frt->fmt.vbi;
358 fh->vbi_fmt.tvnorm = tvnorm; 358 fh->vbi_fmt.tvnorm = tvnorm;
359 fh->vbi_fmt.end = end; 359 fh->vbi_fmt.end = end;
360 360
361 mutex_unlock(&fh->vbi.lock); 361 mutex_unlock(&fh->vbi.vb_lock);
362 362
363 rc = 0; 363 rc = 0;
364 364
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 0aedbeaf94cd..e357f415db06 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -609,13 +609,19 @@ static int cx8802_request_acquire(struct cx8802_driver *drv)
609 struct cx88_core *core = drv->core; 609 struct cx88_core *core = drv->core;
610 610
611 /* Fail a request for hardware if the device is busy. */ 611 /* Fail a request for hardware if the device is busy. */
612 if (core->active_type_id != CX88_BOARD_NONE) 612 if (core->active_type_id != CX88_BOARD_NONE &&
613 core->active_type_id != drv->type_id)
613 return -EBUSY; 614 return -EBUSY;
614 615
615 if (drv->advise_acquire) 616 if (drv->advise_acquire)
616 { 617 {
617 core->active_type_id = drv->type_id; 618 mutex_lock(&drv->core->lock);
618 drv->advise_acquire(drv); 619 core->active_ref++;
620 if (core->active_type_id == CX88_BOARD_NONE) {
621 core->active_type_id = drv->type_id;
622 drv->advise_acquire(drv);
623 }
624 mutex_unlock(&drv->core->lock);
619 625
620 mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO)); 626 mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO));
621 } 627 }
@@ -628,12 +634,14 @@ static int cx8802_request_release(struct cx8802_driver *drv)
628{ 634{
629 struct cx88_core *core = drv->core; 635 struct cx88_core *core = drv->core;
630 636
631 if (drv->advise_release) 637 mutex_lock(&drv->core->lock);
638 if (drv->advise_release && --core->active_ref == 0)
632 { 639 {
633 drv->advise_release(drv); 640 drv->advise_release(drv);
634 core->active_type_id = CX88_BOARD_NONE; 641 core->active_type_id = CX88_BOARD_NONE;
635 mpeg_dbg(1,"%s() Post release GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO)); 642 mpeg_dbg(1,"%s() Post release GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO));
636 } 643 }
644 mutex_unlock(&drv->core->lock);
637 645
638 return 0; 646 return 0;
639} 647}
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 4e823f2a539a..37e6d2e4002f 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -336,6 +336,7 @@ struct cx88_core {
336 /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ 336 /* cx88-video needs to access cx8802 for hybrid tuner pll access. */
337 struct cx8802_dev *dvbdev; 337 struct cx8802_dev *dvbdev;
338 enum cx88_board_type active_type_id; 338 enum cx88_board_type active_type_id;
339 int active_ref;
339}; 340};
340 341
341struct cx8800_dev; 342struct cx8800_dev;
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c
index 941357c4f3f5..8c67f678266a 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -35,7 +35,6 @@
35#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
36#include <linux/proc_fs.h> 36#include <linux/proc_fs.h>
37#include <linux/module.h> 37#include <linux/module.h>
38#include <sound/driver.h>
39#include <sound/core.h> 38#include <sound/core.h>
40#include <sound/pcm.h> 39#include <sound/pcm.h>
41#include <sound/pcm_params.h> 40#include <sound/pcm_params.h>
@@ -270,8 +269,11 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
270 dprintk("opening device and trying to acquire exclusive lock\n"); 269 dprintk("opening device and trying to acquire exclusive lock\n");
271 270
272 /* Sets volume, mute, etc */ 271 /* Sets volume, mute, etc */
272
273 dev->mute = 0; 273 dev->mute = 0;
274 mutex_lock(&dev->lock);
274 ret = em28xx_audio_analog_set(dev); 275 ret = em28xx_audio_analog_set(dev);
276 mutex_unlock(&dev->lock);
275 if (ret < 0) 277 if (ret < 0)
276 goto err; 278 goto err;
277 279
@@ -303,7 +305,9 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream)
303 dprintk("closing device\n"); 305 dprintk("closing device\n");
304 306
305 dev->mute = 1; 307 dev->mute = 1;
308 mutex_lock(&dev->lock);
306 em28xx_audio_analog_set(dev); 309 em28xx_audio_analog_set(dev);
310 mutex_unlock(&dev->lock);
307 311
308 if (dev->adev->users == 0 && dev->adev->shutdown == 1) { 312 if (dev->adev->users == 0 && dev->adev->shutdown == 1) {
309 dprintk("audio users: %d\n", dev->adev->users); 313 dprintk("audio users: %d\n", dev->adev->users);
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 2159d0160df2..aae7753fef11 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -393,15 +393,15 @@ struct em28xx_board em28xx_boards[] = {
393 .input = { { 393 .input = { {
394 .type = EM28XX_VMUX_TELEVISION, 394 .type = EM28XX_VMUX_TELEVISION,
395 .vmux = SAA7115_COMPOSITE2, 395 .vmux = SAA7115_COMPOSITE2,
396 .amux = 1, 396 .amux = EM28XX_AMUX_LINE_IN,
397 }, { 397 }, {
398 .type = EM28XX_VMUX_COMPOSITE1, 398 .type = EM28XX_VMUX_COMPOSITE1,
399 .vmux = SAA7115_COMPOSITE0, 399 .vmux = SAA7115_COMPOSITE0,
400 .amux = 1, 400 .amux = EM28XX_AMUX_LINE_IN,
401 }, { 401 }, {
402 .type = EM28XX_VMUX_SVIDEO, 402 .type = EM28XX_VMUX_SVIDEO,
403 .vmux = SAA7115_SVIDEO3, 403 .vmux = SAA7115_SVIDEO3,
404 .amux = 1, 404 .amux = EM28XX_AMUX_LINE_IN,
405 } }, 405 } },
406 }, 406 },
407}; 407};
@@ -441,6 +441,8 @@ struct usb_device_id em28xx_id_table [] = {
441 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, 441 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
442 { USB_DEVICE(0x2040, 0x6500), 442 { USB_DEVICE(0x2040, 0x6500),
443 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, 443 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
444 { USB_DEVICE(0x2040, 0x6502),
445 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
444 { USB_DEVICE(0x2040, 0x6513), 446 { USB_DEVICE(0x2040, 0x6513),
445 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, 447 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
446 { USB_DEVICE(0x0ccd, 0x0042), 448 { USB_DEVICE(0x0ccd, 0x0042),
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index f6b78357f0e5..7d1537cab867 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -72,7 +72,8 @@ u32 em28xx_request_buffers(struct em28xx *dev, u32 count)
72 const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */ 72 const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */
73 void *buff = NULL; 73 void *buff = NULL;
74 u32 i; 74 u32 i;
75 em28xx_coredbg("requested %i buffers with size %zi", count, imagesize); 75 em28xx_coredbg("requested %i buffers with size %zi\n",
76 count, imagesize);
76 if (count > EM28XX_NUM_FRAMES) 77 if (count > EM28XX_NUM_FRAMES)
77 count = EM28XX_NUM_FRAMES; 78 count = EM28XX_NUM_FRAMES;
78 79
@@ -150,7 +151,7 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
150 if (reg_debug){ 151 if (reg_debug){
151 printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); 152 printk(ret < 0 ? " failed!\n" : "%02x values: ", ret);
152 for (byte = 0; byte < len; byte++) { 153 for (byte = 0; byte < len; byte++) {
153 printk(" %02x", buf[byte]); 154 printk(" %02x", (unsigned char)buf[byte]);
154 } 155 }
155 printk("\n"); 156 printk("\n");
156 } 157 }
@@ -177,7 +178,8 @@ int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg)
177 0x0000, reg, &val, 1, HZ); 178 0x0000, reg, &val, 1, HZ);
178 179
179 if (reg_debug) 180 if (reg_debug)
180 printk(ret < 0 ? " failed!\n" : "%02x\n", val); 181 printk(ret < 0 ? " failed!\n" :
182 "%02x\n", (unsigned char) val);
181 183
182 if (ret < 0) 184 if (ret < 0)
183 return ret; 185 return ret;
@@ -237,7 +239,7 @@ int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len)
237 * sets only some bits (specified by bitmask) of a register, by first reading 239 * sets only some bits (specified by bitmask) of a register, by first reading
238 * the actual value 240 * the actual value
239 */ 241 */
240int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, 242static int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
241 u8 bitmask) 243 u8 bitmask)
242{ 244{
243 int oldval; 245 int oldval;
@@ -254,26 +256,31 @@ int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
254 */ 256 */
255static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val) 257static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val)
256{ 258{
257 int ret; 259 int ret, i;
258 u8 addr = reg & 0x7f; 260 u8 addr = reg & 0x7f;
259 if ((ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2)) < 0) 261 if ((ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2)) < 0)
260 return ret; 262 return ret;
261 if ((ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0) 263 if ((ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0)
262 return ret; 264 return ret;
263 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0) 265
264 return ret; 266 /* Wait up to 50 ms for AC97 command to complete */
265 else if (((u8) ret) & 0x01) { 267 for (i = 0; i < 10; i++) {
266 em28xx_warn ("AC97 command still being executed: not handled properly!\n"); 268 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0)
269 return ret;
270 if (!((u8) ret) & 0x01)
271 return 0;
272 msleep(5);
267 } 273 }
274 em28xx_warn ("AC97 command still being executed: not handled properly!\n");
268 return 0; 275 return 0;
269} 276}
270 277
271int em28xx_set_audio_source(struct em28xx *dev) 278static int em28xx_set_audio_source(struct em28xx *dev)
272{ 279{
273 static char *enable = "\x08\x08"; 280 static char *enable = "\x08\x08";
274 static char *disable = "\x08\x88"; 281 static char *disable = "\x08\x88";
275 char *video = enable, *line = disable; 282 char *video = enable, *line = disable;
276 int ret, no_ac97; 283 int ret;
277 u8 input; 284 u8 input;
278 285
279 if (dev->is_em2800) { 286 if (dev->is_em2800) {
@@ -293,11 +300,9 @@ int em28xx_set_audio_source(struct em28xx *dev)
293 switch (dev->ctl_ainput) { 300 switch (dev->ctl_ainput) {
294 case EM28XX_AMUX_VIDEO: 301 case EM28XX_AMUX_VIDEO:
295 input = EM28XX_AUDIO_SRC_TUNER; 302 input = EM28XX_AUDIO_SRC_TUNER;
296 no_ac97 = 1;
297 break; 303 break;
298 case EM28XX_AMUX_LINE_IN: 304 case EM28XX_AMUX_LINE_IN:
299 input = EM28XX_AUDIO_SRC_LINE; 305 input = EM28XX_AUDIO_SRC_LINE;
300 no_ac97 = 1;
301 break; 306 break;
302 case EM28XX_AMUX_AC97_VIDEO: 307 case EM28XX_AMUX_AC97_VIDEO:
303 input = EM28XX_AUDIO_SRC_LINE; 308 input = EM28XX_AUDIO_SRC_LINE;
@@ -313,12 +318,11 @@ int em28xx_set_audio_source(struct em28xx *dev)
313 ret = em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0); 318 ret = em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0);
314 if (ret < 0) 319 if (ret < 0)
315 return ret; 320 return ret;
321 msleep(5);
316 322
317 if (no_ac97) 323 /* Sets AC97 mixer registers
318 return 0; 324 This is seems to be needed, even for non-ac97 configs
319 325 */
320 /* Sets AC97 mixer registers */
321
322 ret = em28xx_write_ac97(dev, VIDEO_AC97, video); 326 ret = em28xx_write_ac97(dev, VIDEO_AC97, video);
323 if (ret < 0) 327 if (ret < 0)
324 return ret; 328 return ret;
@@ -337,9 +341,10 @@ int em28xx_audio_analog_set(struct em28xx *dev)
337 s[0] |= 0x1f - dev->volume; 341 s[0] |= 0x1f - dev->volume;
338 s[1] |= 0x1f - dev->volume; 342 s[1] |= 0x1f - dev->volume;
339 343
340 if (dev->mute) 344 /* Mute */
341 s[1] |= 0x80; 345 s[1] |= 0x80;
342 ret = em28xx_write_ac97(dev, MASTER_AC97, s); 346 ret = em28xx_write_ac97(dev, MASTER_AC97, s);
347
343 if (ret < 0) 348 if (ret < 0)
344 return ret; 349 return ret;
345 350
@@ -357,6 +362,11 @@ int em28xx_audio_analog_set(struct em28xx *dev)
357 /* Selects the proper audio input */ 362 /* Selects the proper audio input */
358 ret = em28xx_set_audio_source(dev); 363 ret = em28xx_set_audio_source(dev);
359 364
365 /* Unmute device */
366 if (!dev->mute)
367 s[1] &= ~0x80;
368 ret = em28xx_write_ac97(dev, MASTER_AC97, s);
369
360 return ret; 370 return ret;
361} 371}
362EXPORT_SYMBOL_GPL(em28xx_audio_analog_set); 372EXPORT_SYMBOL_GPL(em28xx_audio_analog_set);
@@ -667,7 +677,7 @@ static void em28xx_isocIrq(struct urb *urb)
667 continue; 677 continue;
668 } 678 }
669 if (urb->iso_frame_desc[i].actual_length > 679 if (urb->iso_frame_desc[i].actual_length >
670 dev->max_pkt_size) { 680 urb->iso_frame_desc[i].length) {
671 em28xx_isocdbg("packet bigger than packet size"); 681 em28xx_isocdbg("packet bigger than packet size");
672 continue; 682 continue;
673 } 683 }
@@ -713,8 +723,11 @@ void em28xx_uninit_isoc(struct em28xx *dev)
713 for (i = 0; i < EM28XX_NUM_BUFS; i++) { 723 for (i = 0; i < EM28XX_NUM_BUFS; i++) {
714 if (dev->urb[i]) { 724 if (dev->urb[i]) {
715 usb_kill_urb(dev->urb[i]); 725 usb_kill_urb(dev->urb[i]);
716 if (dev->transfer_buffer[i]){ 726 if (dev->transfer_buffer[i]) {
717 usb_buffer_free(dev->udev,(EM28XX_NUM_PACKETS*dev->max_pkt_size),dev->transfer_buffer[i],dev->urb[i]->transfer_dma); 727 usb_buffer_free(dev->udev,
728 dev->urb[i]->transfer_buffer_length,
729 dev->transfer_buffer[i],
730 dev->urb[i]->transfer_dma);
718 } 731 }
719 usb_free_urb(dev->urb[i]); 732 usb_free_urb(dev->urb[i]);
720 } 733 }
@@ -732,7 +745,10 @@ int em28xx_init_isoc(struct em28xx *dev)
732{ 745{
733 /* change interface to 3 which allows the biggest packet sizes */ 746 /* change interface to 3 which allows the biggest packet sizes */
734 int i, errCode; 747 int i, errCode;
735 const int sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size; 748 int sb_size;
749
750 em28xx_set_alternate(dev);
751 sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size;
736 752
737 /* reset streaming vars */ 753 /* reset streaming vars */
738 dev->frame_current = NULL; 754 dev->frame_current = NULL;
@@ -741,7 +757,7 @@ int em28xx_init_isoc(struct em28xx *dev)
741 /* allocate urbs */ 757 /* allocate urbs */
742 for (i = 0; i < EM28XX_NUM_BUFS; i++) { 758 for (i = 0; i < EM28XX_NUM_BUFS; i++) {
743 struct urb *urb; 759 struct urb *urb;
744 int j, k; 760 int j;
745 /* allocate transfer buffer */ 761 /* allocate transfer buffer */
746 urb = usb_alloc_urb(EM28XX_NUM_PACKETS, GFP_KERNEL); 762 urb = usb_alloc_urb(EM28XX_NUM_PACKETS, GFP_KERNEL);
747 if (!urb){ 763 if (!urb){
@@ -749,7 +765,9 @@ int em28xx_init_isoc(struct em28xx *dev)
749 em28xx_uninit_isoc(dev); 765 em28xx_uninit_isoc(dev);
750 return -ENOMEM; 766 return -ENOMEM;
751 } 767 }
752 dev->transfer_buffer[i] = usb_buffer_alloc(dev->udev, sb_size, GFP_KERNEL,&urb->transfer_dma); 768 dev->transfer_buffer[i] = usb_buffer_alloc(dev->udev, sb_size,
769 GFP_KERNEL,
770 &urb->transfer_dma);
753 if (!dev->transfer_buffer[i]) { 771 if (!dev->transfer_buffer[i]) {
754 em28xx_errdev 772 em28xx_errdev
755 ("unable to allocate %i bytes for transfer buffer %i\n", 773 ("unable to allocate %i bytes for transfer buffer %i\n",
@@ -762,22 +780,22 @@ int em28xx_init_isoc(struct em28xx *dev)
762 urb->dev = dev->udev; 780 urb->dev = dev->udev;
763 urb->context = dev; 781 urb->context = dev;
764 urb->pipe = usb_rcvisocpipe(dev->udev, 0x82); 782 urb->pipe = usb_rcvisocpipe(dev->udev, 0x82);
765 urb->transfer_flags = URB_ISO_ASAP; 783 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
766 urb->interval = 1; 784 urb->interval = 1;
767 urb->transfer_buffer = dev->transfer_buffer[i]; 785 urb->transfer_buffer = dev->transfer_buffer[i];
768 urb->complete = em28xx_isocIrq; 786 urb->complete = em28xx_isocIrq;
769 urb->number_of_packets = EM28XX_NUM_PACKETS; 787 urb->number_of_packets = EM28XX_NUM_PACKETS;
770 urb->transfer_buffer_length = sb_size; 788 urb->transfer_buffer_length = sb_size;
771 for (j = k = 0; j < EM28XX_NUM_PACKETS; 789 for (j = 0; j < EM28XX_NUM_PACKETS; j++) {
772 j++, k += dev->max_pkt_size) { 790 urb->iso_frame_desc[j].offset = j * dev->max_pkt_size;
773 urb->iso_frame_desc[j].offset = k; 791 urb->iso_frame_desc[j].length = dev->max_pkt_size;
774 urb->iso_frame_desc[j].length =
775 dev->max_pkt_size;
776 } 792 }
777 dev->urb[i] = urb; 793 dev->urb[i] = urb;
778 } 794 }
779 795
780 /* submit urbs */ 796 /* submit urbs */
797 em28xx_coredbg("Submitting %d urbs of %d packets (%d each)\n",
798 EM28XX_NUM_BUFS, EM28XX_NUM_PACKETS, dev->max_pkt_size);
781 for (i = 0; i < EM28XX_NUM_BUFS; i++) { 799 for (i = 0; i < EM28XX_NUM_BUFS; i++) {
782 errCode = usb_submit_urb(dev->urb[i], GFP_KERNEL); 800 errCode = usb_submit_urb(dev->urb[i], GFP_KERNEL);
783 if (errCode) { 801 if (errCode) {
@@ -794,22 +812,31 @@ int em28xx_init_isoc(struct em28xx *dev)
794int em28xx_set_alternate(struct em28xx *dev) 812int em28xx_set_alternate(struct em28xx *dev)
795{ 813{
796 int errCode, prev_alt = dev->alt; 814 int errCode, prev_alt = dev->alt;
797 dev->alt = alt; 815 int i;
798 if (dev->alt == 0) { 816 unsigned int min_pkt_size = dev->bytesperline+4;
799 int i; 817
800 for(i=0;i< dev->num_alt; i++) 818 /* When image size is bigger than a ceirtain value,
801 if(dev->alt_max_pkt_size[i]>dev->alt_max_pkt_size[dev->alt]) 819 the frame size should be increased, otherwise, only
802 dev->alt=i; 820 green screen will be received.
803 } 821 */
822 if (dev->frame_size > 720*240*2)
823 min_pkt_size *= 2;
824
825 for (i = 0; i < dev->num_alt; i++)
826 if (dev->alt_max_pkt_size[i] >= min_pkt_size)
827 break;
828 dev->alt = i;
804 829
805 if (dev->alt != prev_alt) { 830 if (dev->alt != prev_alt) {
831 em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n",
832 min_pkt_size, dev->alt);
806 dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; 833 dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt];
807 em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", dev->alt, 834 em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n",
808 dev->max_pkt_size); 835 dev->alt, dev->max_pkt_size);
809 errCode = usb_set_interface(dev->udev, 0, dev->alt); 836 errCode = usb_set_interface(dev->udev, 0, dev->alt);
810 if (errCode < 0) { 837 if (errCode < 0) {
811 em28xx_errdev ("cannot change alternate number to %d (error=%i)\n", 838 em28xx_errdev ("cannot change alternate number to %d (error=%i)\n",
812 dev->alt, errCode); 839 dev->alt, errCode);
813 return errCode; 840 return errCode;
814 } 841 }
815 } 842 }
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index a0c334672488..4abe6701a770 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -189,7 +189,7 @@ static void video_mux(struct em28xx *dev, int index)
189 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route); 189 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route);
190 } 190 }
191 191
192 em28xx_set_audio_source(dev); 192 em28xx_audio_analog_set(dev);
193} 193}
194 194
195/* Usage lock check functions */ 195/* Usage lock check functions */
@@ -830,6 +830,63 @@ static int vidioc_s_frequency(struct file *file, void *priv,
830 return 0; 830 return 0;
831} 831}
832 832
833#ifdef CONFIG_VIDEO_ADV_DEBUG
834static int em28xx_reg_len(int reg)
835{
836 switch (reg) {
837 case AC97LSB_REG:
838 case HSCALELOW_REG:
839 case VSCALELOW_REG:
840 return 2;
841 default:
842 return 1;
843 }
844}
845
846static int vidioc_g_register(struct file *file, void *priv,
847 struct v4l2_register *reg)
848{
849 struct em28xx_fh *fh = priv;
850 struct em28xx *dev = fh->dev;
851 int ret;
852
853 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
854 return -EINVAL;
855
856 if (em28xx_reg_len(reg->reg) == 1) {
857 ret = em28xx_read_reg(dev, reg->reg);
858 if (ret < 0)
859 return ret;
860
861 reg->val = ret;
862 } else {
863 u64 val = 0;
864 ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS,
865 reg->reg, (char *)&val, 2);
866 if (ret < 0)
867 return ret;
868
869 reg->val = cpu_to_le64((__u64)val);
870 }
871
872 return 0;
873}
874
875static int vidioc_s_register(struct file *file, void *priv,
876 struct v4l2_register *reg)
877{
878 struct em28xx_fh *fh = priv;
879 struct em28xx *dev = fh->dev;
880 u64 buf;
881
882 buf = le64_to_cpu((__u64)reg->val);
883
884 return em28xx_write_regs(dev, reg->reg, (char *)&buf,
885 em28xx_reg_len(reg->reg));
886}
887#endif
888
889
833static int vidioc_cropcap(struct file *file, void *priv, 890static int vidioc_cropcap(struct file *file, void *priv,
834 struct v4l2_cropcap *cc) 891 struct v4l2_cropcap *cc)
835{ 892{
@@ -1295,8 +1352,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1295 filp->private_data = fh; 1352 filp->private_data = fh;
1296 1353
1297 if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { 1354 if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) {
1298 em28xx_set_alternate(dev);
1299
1300 dev->width = norm_maxw(dev); 1355 dev->width = norm_maxw(dev);
1301 dev->height = norm_maxh(dev); 1356 dev->height = norm_maxh(dev);
1302 dev->frame_size = dev->width * dev->height * 2; 1357 dev->frame_size = dev->width * dev->height * 2;
@@ -1305,6 +1360,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1305 dev->hscale = 0; 1360 dev->hscale = 0;
1306 dev->vscale = 0; 1361 dev->vscale = 0;
1307 1362
1363 em28xx_set_alternate(dev);
1308 em28xx_capture_start(dev, 1); 1364 em28xx_capture_start(dev, 1);
1309 em28xx_resolution_set(dev); 1365 em28xx_resolution_set(dev);
1310 1366
@@ -1730,6 +1786,10 @@ static const struct video_device em28xx_video_template = {
1730 .vidioc_s_tuner = vidioc_s_tuner, 1786 .vidioc_s_tuner = vidioc_s_tuner,
1731 .vidioc_g_frequency = vidioc_g_frequency, 1787 .vidioc_g_frequency = vidioc_g_frequency,
1732 .vidioc_s_frequency = vidioc_s_frequency, 1788 .vidioc_s_frequency = vidioc_s_frequency,
1789#ifdef CONFIG_VIDEO_ADV_DEBUG
1790 .vidioc_g_register = vidioc_g_register,
1791 .vidioc_s_register = vidioc_s_register,
1792#endif
1733 1793
1734 .tvnorms = V4L2_STD_ALL, 1794 .tvnorms = V4L2_STD_ALL,
1735 .current_norm = V4L2_STD_PAL, 1795 .current_norm = V4L2_STD_PAL,
@@ -1752,6 +1812,10 @@ static struct video_device em28xx_radio_template = {
1752 .vidioc_s_ctrl = vidioc_s_ctrl, 1812 .vidioc_s_ctrl = vidioc_s_ctrl,
1753 .vidioc_g_frequency = vidioc_g_frequency, 1813 .vidioc_g_frequency = vidioc_g_frequency,
1754 .vidioc_s_frequency = vidioc_s_frequency, 1814 .vidioc_s_frequency = vidioc_s_frequency,
1815#ifdef CONFIG_VIDEO_ADV_DEBUG
1816 .vidioc_g_register = vidioc_g_register,
1817 .vidioc_s_register = vidioc_s_register,
1818#endif
1755}; 1819};
1756 1820
1757/******************************** usb interface *****************************************/ 1821/******************************** usb interface *****************************************/
@@ -1796,10 +1860,10 @@ void em28xx_unregister_extension(struct em28xx_ops *ops)
1796} 1860}
1797EXPORT_SYMBOL(em28xx_unregister_extension); 1861EXPORT_SYMBOL(em28xx_unregister_extension);
1798 1862
1799struct video_device *em28xx_vdev_init(struct em28xx *dev, 1863static struct video_device *em28xx_vdev_init(struct em28xx *dev,
1800 const struct video_device *template, 1864 const struct video_device *template,
1801 const int type, 1865 const int type,
1802 const char *type_name) 1866 const char *type_name)
1803{ 1867{
1804 struct video_device *vfd; 1868 struct video_device *vfd;
1805 1869
@@ -2064,6 +2128,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2064 snprintf(dev->name, 29, "em28xx #%d", nr); 2128 snprintf(dev->name, 29, "em28xx #%d", nr);
2065 dev->devno = nr; 2129 dev->devno = nr;
2066 dev->model = id->driver_info; 2130 dev->model = id->driver_info;
2131 dev->alt = -1;
2067 2132
2068 /* Checks if audio is provided by some interface */ 2133 /* Checks if audio is provided by some interface */
2069 for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { 2134 for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index f3bad0c1c517..04e0e48ecabe 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -33,7 +33,7 @@
33#define UNSET -1 33#define UNSET -1
34 34
35/* maximum number of em28xx boards */ 35/* maximum number of em28xx boards */
36#define EM28XX_MAXBOARDS 1 /*FIXME: should be bigger */ 36#define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */
37 37
38/* maximum number of frames that can be queued */ 38/* maximum number of frames that can be queued */
39#define EM28XX_NUM_FRAMES 5 39#define EM28XX_NUM_FRAMES 5
@@ -345,9 +345,6 @@ int em28xx_read_reg(struct em28xx *dev, u16 reg);
345int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, 345int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
346 int len); 346 int len);
347int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); 347int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len);
348int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
349 u8 bitmask);
350int em28xx_set_audio_source(struct em28xx *dev);
351int em28xx_audio_analog_set(struct em28xx *dev); 348int em28xx_audio_analog_set(struct em28xx *dev);
352 349
353int em28xx_colorlevels_set_default(struct em28xx *dev); 350int em28xx_colorlevels_set_default(struct em28xx *dev);
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 7d7f383b404f..262830da08c8 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -928,27 +928,38 @@ struct saa7134_board saa7134_boards[] = {
928 .tuner_addr = ADDR_UNSET, 928 .tuner_addr = ADDR_UNSET,
929 .radio_addr = ADDR_UNSET, 929 .radio_addr = ADDR_UNSET,
930 .tda9887_conf = TDA9887_PRESENT, 930 .tda9887_conf = TDA9887_PRESENT,
931 .gpiomask = 0x03,
931 .inputs = {{ 932 .inputs = {{
932 .name = name_tv, 933 .name = name_tv,
933 .vmux = 1, 934 .vmux = 1,
934 .amux = TV, 935 .amux = TV,
935 .tv = 1, 936 .tv = 1,
936 },{ 937 .gpio = 0x00,
938 }, {
937 .name = name_comp1, 939 .name = name_comp1,
938 .vmux = 0,
939 .amux = LINE2,
940 },{
941 .name = name_comp2,
942 .vmux = 3, 940 .vmux = 3,
943 .amux = LINE2, 941 .amux = LINE1,
944 },{ 942 .gpio = 0x02,
943 }, {
944 .name = name_comp2,
945 .vmux = 0,
946 .amux = LINE1,
947 .gpio = 0x02,
948 }, {
945 .name = name_svideo, 949 .name = name_svideo,
946 .vmux = 8, 950 .vmux = 8,
947 .amux = LINE2, 951 .amux = LINE1,
948 }}, 952 .gpio = 0x02,
953 } },
949 .radio = { 954 .radio = {
950 .name = name_radio, 955 .name = name_radio,
951 .amux = LINE2, 956 .amux = LINE1,
957 .gpio = 0x01,
958 },
959 .mute = {
960 .name = name_mute,
961 .amux = TV,
962 .gpio = 0x00,
952 }, 963 },
953 }, 964 },
954 [SAA7134_BOARD_BMK_MPEX_TUNER] = { 965 [SAA7134_BOARD_BMK_MPEX_TUNER] = {
@@ -3912,6 +3923,74 @@ struct saa7134_board saa7134_boards[] = {
3912 }, 3923 },
3913 .mpeg = SAA7134_MPEG_EMPRESS, 3924 .mpeg = SAA7134_MPEG_EMPRESS,
3914 }, 3925 },
3926 [SAA7134_BOARD_TWINHAN_DTV_DVB_3056] = {
3927 .name = "Twinhan Hybrid DTV-DVB 3056 PCI",
3928 .audio_clock = 0x00187de7,
3929 .tuner_type = TUNER_PHILIPS_TDA8290,
3930 .radio_type = UNSET,
3931 .tuner_addr = ADDR_UNSET,
3932 .radio_addr = ADDR_UNSET,
3933 .tuner_config = 2,
3934 .mpeg = SAA7134_MPEG_DVB,
3935 .gpiomask = 0x0200000,
3936 .inputs = {{
3937 .name = name_tv,
3938 .vmux = 1,
3939 .amux = TV,
3940 .tv = 1,
3941 }, {
3942 .name = name_comp1,
3943 .vmux = 3,
3944 .amux = LINE1,
3945 }, {
3946 .name = name_svideo,
3947 .vmux = 8, /* untested */
3948 .amux = LINE1,
3949 } },
3950 .radio = {
3951 .name = name_radio,
3952 .amux = TV,
3953 .gpio = 0x0200000,
3954 },
3955 },
3956 [SAA7134_BOARD_GENIUS_TVGO_A11MCE] = {
3957 /* Adrian Pardini <pardo.bsso@gmail.com> */
3958 .name = "Genius TVGO AM11MCE",
3959 .audio_clock = 0x00200000,
3960 .tuner_type = TUNER_TNF_5335MF,
3961 .radio_type = UNSET,
3962 .tuner_addr = ADDR_UNSET,
3963 .radio_addr = ADDR_UNSET,
3964 .gpiomask = 0xf000,
3965 .inputs = {{
3966 .name = name_tv_mono,
3967 .vmux = 1,
3968 .amux = LINE2,
3969 .gpio = 0x0000,
3970 .tv = 1,
3971 }, {
3972 .name = name_comp1,
3973 .vmux = 3,
3974 .amux = LINE1,
3975 .gpio = 0x2000,
3976 .tv = 1
3977 }, {
3978 .name = name_svideo,
3979 .vmux = 8,
3980 .amux = LINE1,
3981 .gpio = 0x2000,
3982 } },
3983 .radio = {
3984 .name = name_radio,
3985 .amux = LINE2,
3986 .gpio = 0x1000,
3987 },
3988 .mute = {
3989 .name = name_mute,
3990 .amux = LINE2,
3991 .gpio = 0x6000,
3992 },
3993 },
3915}; 3994};
3916 3995
3917const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 3996const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -4511,6 +4590,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
4511 },{ 4590 },{
4512 .vendor = PCI_VENDOR_ID_PHILIPS, 4591 .vendor = PCI_VENDOR_ID_PHILIPS,
4513 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 4592 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
4593 .subvendor = 0x5168,
4594 .subdevice = 0x3307, /* FlyDVB-T Hybrid Mini PCI */
4595 .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS,
4596 }, {
4597 .vendor = PCI_VENDOR_ID_PHILIPS,
4598 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
4514 .subvendor = 0x16be, 4599 .subvendor = 0x16be,
4515 .subdevice = 0x0007, 4600 .subdevice = 0x0007,
4516 .driver_data = SAA7134_BOARD_MEDION_MD8800_QUADRO, 4601 .driver_data = SAA7134_BOARD_MEDION_MD8800_QUADRO,
@@ -4523,6 +4608,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
4523 },{ 4608 },{
4524 .vendor = PCI_VENDOR_ID_PHILIPS, 4609 .vendor = PCI_VENDOR_ID_PHILIPS,
4525 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 4610 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
4611 .subvendor = 0x16be,
4612 .subdevice = 0x000d, /* triple CTX948_V1.1.1 */
4613 .driver_data = SAA7134_BOARD_MEDION_MD8800_QUADRO,
4614 }, {
4615 .vendor = PCI_VENDOR_ID_PHILIPS,
4616 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
4526 .subvendor = 0x1461, 4617 .subvendor = 0x1461,
4527 .subdevice = 0x2c05, 4618 .subdevice = 0x2c05,
4528 .driver_data = SAA7134_BOARD_AVERMEDIA_777, 4619 .driver_data = SAA7134_BOARD_AVERMEDIA_777,
@@ -4843,7 +4934,13 @@ struct pci_device_id saa7134_pci_tbl[] = {
4843 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 4934 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
4844 .subvendor = 0x4e42, 4935 .subvendor = 0x4e42,
4845 .subdevice = 0x3502, 4936 .subdevice = 0x3502,
4846 .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS 4937 .driver_data = SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS,
4938 }, {
4939 .vendor = PCI_VENDOR_ID_PHILIPS,
4940 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
4941 .subvendor = 0x1822, /*Twinhan Technology Co. Ltd*/
4942 .subdevice = 0x0022,
4943 .driver_data = SAA7134_BOARD_TWINHAN_DTV_DVB_3056,
4847 },{ 4944 },{
4848 /* --- boards without eeprom + subsystem ID --- */ 4945 /* --- boards without eeprom + subsystem ID --- */
4849 .vendor = PCI_VENDOR_ID_PHILIPS, 4946 .vendor = PCI_VENDOR_ID_PHILIPS,
@@ -4995,6 +5092,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
4995 case SAA7134_BOARD_BEHOLD_409: 5092 case SAA7134_BOARD_BEHOLD_409:
4996 case SAA7134_BOARD_BEHOLD_505FM: 5093 case SAA7134_BOARD_BEHOLD_505FM:
4997 case SAA7134_BOARD_BEHOLD_507_9FM: 5094 case SAA7134_BOARD_BEHOLD_507_9FM:
5095 case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
4998 dev->has_remote = SAA7134_REMOTE_GPIO; 5096 dev->has_remote = SAA7134_REMOTE_GPIO;
4999 break; 5097 break;
5000 case SAA7134_BOARD_FLYDVBS_LR300: 5098 case SAA7134_BOARD_FLYDVBS_LR300:
@@ -5232,7 +5330,8 @@ int saa7134_board_init2(struct saa7134_dev *dev)
5232 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 5330 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
5233 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: 5331 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
5234 case SAA7134_BOARD_MEDION_MD8800_QUADRO: 5332 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
5235 case SAA7134_BOARD_AVERMEDIA_SUPER_007: 5333 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
5334 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
5236 /* this is a hybrid board, initialize to analog mode 5335 /* this is a hybrid board, initialize to analog mode
5237 * and configure firmware eeprom address 5336 * and configure firmware eeprom address
5238 */ 5337 */
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index a9ca5730826f..ea2be9eceeb8 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -779,6 +779,21 @@ static struct tda1004x_config avermedia_super_007_config = {
779 .request_firmware = philips_tda1004x_request_firmware 779 .request_firmware = philips_tda1004x_request_firmware
780}; 780};
781 781
782static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
783 .demod_address = 0x08,
784 .invert = 1,
785 .invert_oclk = 0,
786 .xtal_freq = TDA10046_XTAL_16M,
787 .agc_config = TDA10046_AGC_TDA827X,
788 .gpio_config = TDA10046_GP01_I,
789 .if_freq = TDA10046_FREQ_045,
790 .i2c_gate = 0x42,
791 .tuner_address = 0x61,
792 .tuner_config = 2,
793 .antenna_switch = 1,
794 .request_firmware = philips_tda1004x_request_firmware
795};
796
782/* ------------------------------------------------------------------ 797/* ------------------------------------------------------------------
783 * special case: this card uses saa713x GPIO22 for the mode switch 798 * special case: this card uses saa713x GPIO22 for the mode switch
784 */ 799 */
@@ -826,6 +841,7 @@ static struct tda1004x_config ads_tech_duo_config = {
826static struct tda10086_config flydvbs = { 841static struct tda10086_config flydvbs = {
827 .demod_address = 0x0e, 842 .demod_address = 0x0e,
828 .invert = 0, 843 .invert = 0,
844 .diseqc_tone = 0,
829}; 845};
830 846
831/* ================================================================== 847/* ==================================================================
@@ -940,9 +956,9 @@ static int dvb_init(struct saa7134_dev *dev)
940 configure_tda827x_fe(dev, &tda827x_lifeview_config); 956 configure_tda827x_fe(dev, &tda827x_lifeview_config);
941 break; 957 break;
942 case SAA7134_BOARD_FLYDVB_TRIO: 958 case SAA7134_BOARD_FLYDVB_TRIO:
943 if(! use_frontend) { //terrestrial 959 if(! use_frontend) { /* terrestrial */
944 configure_tda827x_fe(dev, &lifeview_trio_config); 960 configure_tda827x_fe(dev, &lifeview_trio_config);
945 } else { //satellite 961 } else { /* satellite */
946 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); 962 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
947 if (dev->dvb.frontend) { 963 if (dev->dvb.frontend) {
948 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, 964 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
@@ -1007,8 +1023,9 @@ static int dvb_init(struct saa7134_dev *dev)
1007 } 1023 }
1008 break; 1024 break;
1009 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: 1025 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1010 dev->dvb.frontend = tda10046_attach(&medion_cardbus, 1026 dev->dvb.frontend = dvb_attach(tda10046_attach,
1011 &dev->i2c_adap); 1027 &medion_cardbus,
1028 &dev->i2c_adap);
1012 if (dev->dvb.frontend) { 1029 if (dev->dvb.frontend) {
1013 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; 1030 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1014 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; 1031 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
@@ -1044,6 +1061,9 @@ static int dvb_init(struct saa7134_dev *dev)
1044 case SAA7134_BOARD_AVERMEDIA_SUPER_007: 1061 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1045 configure_tda827x_fe(dev, &avermedia_super_007_config); 1062 configure_tda827x_fe(dev, &avermedia_super_007_config);
1046 break; 1063 break;
1064 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1065 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
1066 break;
1047 default: 1067 default:
1048 wprintk("Huh? unknown DVB card?\n"); 1068 wprintk("Huh? unknown DVB card?\n");
1049 break; 1069 break;
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index b1b01fa86720..3d2ec30de227 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -87,7 +87,7 @@ static int ts_open(struct inode *inode, struct file *file)
87 87
88 dprintk("open minor=%d\n",minor); 88 dprintk("open minor=%d\n",minor);
89 err = -EBUSY; 89 err = -EBUSY;
90 if (!mutex_trylock(&dev->empress_tsq.lock)) 90 if (!mutex_trylock(&dev->empress_tsq.vb_lock))
91 goto done; 91 goto done;
92 if (dev->empress_users) 92 if (dev->empress_users)
93 goto done_up; 93 goto done_up;
@@ -101,7 +101,7 @@ static int ts_open(struct inode *inode, struct file *file)
101 err = 0; 101 err = 0;
102 102
103done_up: 103done_up:
104 mutex_unlock(&dev->empress_tsq.lock); 104 mutex_unlock(&dev->empress_tsq.vb_lock);
105done: 105done:
106 return err; 106 return err;
107} 107}
@@ -110,7 +110,6 @@ static int ts_release(struct inode *inode, struct file *file)
110{ 110{
111 struct saa7134_dev *dev = file->private_data; 111 struct saa7134_dev *dev = file->private_data;
112 112
113 mutex_lock(&dev->empress_tsq.lock);
114 videobuf_stop(&dev->empress_tsq); 113 videobuf_stop(&dev->empress_tsq);
115 videobuf_mmap_free(&dev->empress_tsq); 114 videobuf_mmap_free(&dev->empress_tsq);
116 dev->empress_users--; 115 dev->empress_users--;
@@ -122,7 +121,6 @@ static int ts_release(struct inode *inode, struct file *file)
122 saa_writeb(SAA7134_AUDIO_MUTE_CTRL, 121 saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
123 saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6)); 122 saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6));
124 123
125 mutex_unlock(&dev->empress_tsq.lock);
126 return 0; 124 return 0;
127} 125}
128 126
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 0db955c2d9b9..b4188819782f 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -406,6 +406,12 @@ int saa7134_input_init1(struct saa7134_dev *dev)
406 mask_keyup = 0x8000000; 406 mask_keyup = 0x8000000;
407 polling = 50; //ms 407 polling = 50; //ms
408 break; 408 break;
409 case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
410 ir_codes = ir_codes_genius_tvgo_a11mce;
411 mask_keycode = 0xff;
412 mask_keydown = 0xf00000;
413 polling = 50; /* ms */
414 break;
409 } 415 }
410 if (NULL == ir_codes) { 416 if (NULL == ir_codes) {
411 printk("%s: Oops: IR config error [card=%d]\n", 417 printk("%s: Oops: IR config error [card=%d]\n",
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 1184d359e848..39c41ad97d0e 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1414,21 +1414,17 @@ video_poll(struct file *file, struct poll_table_struct *wait)
1414 if (!list_empty(&fh->cap.stream)) 1414 if (!list_empty(&fh->cap.stream))
1415 buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream); 1415 buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream);
1416 } else { 1416 } else {
1417 mutex_lock(&fh->cap.lock); 1417 mutex_lock(&fh->cap.vb_lock);
1418 if (UNSET == fh->cap.read_off) { 1418 if (UNSET == fh->cap.read_off) {
1419 /* need to capture a new frame */ 1419 /* need to capture a new frame */
1420 if (res_locked(fh->dev,RESOURCE_VIDEO)) { 1420 if (res_locked(fh->dev,RESOURCE_VIDEO))
1421 mutex_unlock(&fh->cap.lock); 1421 goto err;
1422 return POLLERR; 1422 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field))
1423 } 1423 goto err;
1424 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) {
1425 mutex_unlock(&fh->cap.lock);
1426 return POLLERR;
1427 }
1428 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); 1424 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
1429 fh->cap.read_off = 0; 1425 fh->cap.read_off = 0;
1430 } 1426 }
1431 mutex_unlock(&fh->cap.lock); 1427 mutex_unlock(&fh->cap.vb_lock);
1432 buf = fh->cap.read_buf; 1428 buf = fh->cap.read_buf;
1433 } 1429 }
1434 1430
@@ -1440,6 +1436,10 @@ video_poll(struct file *file, struct poll_table_struct *wait)
1440 buf->state == VIDEOBUF_ERROR) 1436 buf->state == VIDEOBUF_ERROR)
1441 return POLLIN|POLLRDNORM; 1437 return POLLIN|POLLRDNORM;
1442 return 0; 1438 return 0;
1439
1440err:
1441 mutex_unlock(&fh->cap.vb_lock);
1442 return POLLERR;
1443} 1443}
1444 1444
1445static int video_release(struct inode *inode, struct file *file) 1445static int video_release(struct inode *inode, struct file *file)
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index b88ca995fafb..f940d0254798 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -252,6 +252,8 @@ struct saa7134_format {
252#define SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM 128 252#define SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM 128
253#define SAA7134_BOARD_BEHOLD_607_9FM 129 253#define SAA7134_BOARD_BEHOLD_607_9FM 129
254#define SAA7134_BOARD_BEHOLD_M6 130 254#define SAA7134_BOARD_BEHOLD_M6 130
255#define SAA7134_BOARD_TWINHAN_DTV_DVB_3056 131
256#define SAA7134_BOARD_GENIUS_TVGO_A11MCE 132
255 257
256#define SAA7134_MAXBOARDS 8 258#define SAA7134_MAXBOARDS 8
257#define SAA7134_INPUT_MAX 8 259#define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/video/stk-sensor.c b/drivers/media/video/stk-sensor.c
index 4a9a0b62efa3..e546b014d7ad 100644
--- a/drivers/media/video/stk-sensor.c
+++ b/drivers/media/video/stk-sensor.c
@@ -225,7 +225,7 @@
225 225
226 226
227/* Returns 0 if OK */ 227/* Returns 0 if OK */
228int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val) 228static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val)
229{ 229{
230 int i = 0; 230 int i = 0;
231 int tmpval = 0; 231 int tmpval = 0;
@@ -250,7 +250,7 @@ int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val)
250 return 0; 250 return 0;
251} 251}
252 252
253int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val) 253static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val)
254{ 254{
255 int i = 0; 255 int i = 0;
256 int tmpval = 0; 256 int tmpval = 0;
@@ -380,7 +380,7 @@ int stk_sensor_init(struct stk_camera *dev)
380 STK_ERROR("Strange error reading sensor ID\n"); 380 STK_ERROR("Strange error reading sensor ID\n");
381 return -ENODEV; 381 return -ENODEV;
382 } 382 }
383 if (idh != 0x7F || idl != 0xA2) { 383 if (idh != 0x7f || idl != 0xa2) {
384 STK_ERROR("Huh? you don't have a sensor from ovt\n"); 384 STK_ERROR("Huh? you don't have a sensor from ovt\n");
385 return -ENODEV; 385 return -ENODEV;
386 } 386 }
@@ -409,6 +409,19 @@ static struct regval ov_fmt_uyvy[] = {
409 {REG_COM15, COM15_R00FF }, 409 {REG_COM15, COM15_R00FF },
410 {0xff, 0xff}, /* END MARKER */ 410 {0xff, 0xff}, /* END MARKER */
411}; 411};
412/* V4L2_PIX_FMT_YUYV */
413static struct regval ov_fmt_yuyv[] = {
414 {REG_TSLB, 0 },
415 { 0x4f, 0x80 }, /* "matrix coefficient 1" */
416 { 0x50, 0x80 }, /* "matrix coefficient 2" */
417 { 0x51, 0 }, /* vb */
418 { 0x52, 0x22 }, /* "matrix coefficient 4" */
419 { 0x53, 0x5e }, /* "matrix coefficient 5" */
420 { 0x54, 0x80 }, /* "matrix coefficient 6" */
421 {REG_COM13, COM13_UVSAT|COM13_CMATRIX},
422 {REG_COM15, COM15_R00FF },
423 {0xff, 0xff}, /* END MARKER */
424};
412 425
413/* V4L2_PIX_FMT_RGB565X rrrrrggg gggbbbbb */ 426/* V4L2_PIX_FMT_RGB565X rrrrrggg gggbbbbb */
414static struct regval ov_fmt_rgbr[] = { 427static struct regval ov_fmt_rgbr[] = {
@@ -519,6 +532,10 @@ int stk_sensor_configure(struct stk_camera *dev)
519 com7 |= COM7_YUV; 532 com7 |= COM7_YUV;
520 rv = ov_fmt_uyvy; 533 rv = ov_fmt_uyvy;
521 break; 534 break;
535 case V4L2_PIX_FMT_YUYV:
536 com7 |= COM7_YUV;
537 rv = ov_fmt_yuyv;
538 break;
522 case V4L2_PIX_FMT_RGB565: 539 case V4L2_PIX_FMT_RGB565:
523 com7 |= COM7_RGB; 540 com7 |= COM7_RGB;
524 rv = ov_fmt_rgbp; 541 rv = ov_fmt_rgbp;
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index d37e5e2594b4..ceba45ad0294 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -63,7 +63,7 @@ static struct usb_device_id stkwebcam_table[] = {
63}; 63};
64MODULE_DEVICE_TABLE(usb, stkwebcam_table); 64MODULE_DEVICE_TABLE(usb, stkwebcam_table);
65 65
66void stk_camera_cleanup(struct kref *kref) 66static void stk_camera_cleanup(struct kref *kref)
67{ 67{
68 struct stk_camera *dev = to_stk_camera(kref); 68 struct stk_camera *dev = to_stk_camera(kref);
69 69
@@ -682,6 +682,7 @@ static int v4l_stk_open(struct inode *inode, struct file *fp)
682 return -ENXIO; 682 return -ENXIO;
683 fp->private_data = vdev; 683 fp->private_data = vdev;
684 kref_get(&dev->kref); 684 kref_get(&dev->kref);
685 usb_autopm_get_interface(dev->interface);
685 686
686 return 0; 687 return 0;
687} 688}
@@ -703,6 +704,7 @@ static int v4l_stk_release(struct inode *inode, struct file *fp)
703 } 704 }
704 705
705 if (dev->owner != fp) { 706 if (dev->owner != fp) {
707 usb_autopm_put_interface(dev->interface);
706 kref_put(&dev->kref, stk_camera_cleanup); 708 kref_put(&dev->kref, stk_camera_cleanup);
707 return 0; 709 return 0;
708 } 710 }
@@ -713,6 +715,7 @@ static int v4l_stk_release(struct inode *inode, struct file *fp)
713 715
714 dev->owner = NULL; 716 dev->owner = NULL;
715 717
718 usb_autopm_put_interface(dev->interface);
716 kref_put(&dev->kref, stk_camera_cleanup); 719 kref_put(&dev->kref, stk_camera_cleanup);
717 720
718 return 0; 721 return 0;
@@ -993,6 +996,10 @@ static int stk_vidioc_enum_fmt_cap(struct file *filp,
993 fmtd->pixelformat = V4L2_PIX_FMT_SBGGR8; 996 fmtd->pixelformat = V4L2_PIX_FMT_SBGGR8;
994 strcpy(fmtd->description, "Raw bayer"); 997 strcpy(fmtd->description, "Raw bayer");
995 break; 998 break;
999 case 4:
1000 fmtd->pixelformat = V4L2_PIX_FMT_YUYV;
1001 strcpy(fmtd->description, "yuv4:2:2");
1002 break;
996 default: 1003 default:
997 return -EINVAL; 1004 return -EINVAL;
998 } 1005 }
@@ -1048,6 +1055,7 @@ static int stk_vidioc_try_fmt_cap(struct file *filp,
1048 case V4L2_PIX_FMT_RGB565: 1055 case V4L2_PIX_FMT_RGB565:
1049 case V4L2_PIX_FMT_RGB565X: 1056 case V4L2_PIX_FMT_RGB565X:
1050 case V4L2_PIX_FMT_UYVY: 1057 case V4L2_PIX_FMT_UYVY:
1058 case V4L2_PIX_FMT_YUYV:
1051 case V4L2_PIX_FMT_SBGGR8: 1059 case V4L2_PIX_FMT_SBGGR8:
1052 break; 1060 break;
1053 default: 1061 default:
@@ -1080,6 +1088,42 @@ static int stk_vidioc_try_fmt_cap(struct file *filp,
1080 return 0; 1088 return 0;
1081} 1089}
1082 1090
1091static int stk_setup_format(struct stk_camera *dev)
1092{
1093 int i = 0;
1094 int depth;
1095 if (dev->vsettings.palette == V4L2_PIX_FMT_SBGGR8)
1096 depth = 1;
1097 else
1098 depth = 2;
1099 while (stk_sizes[i].m != dev->vsettings.mode
1100 && i < ARRAY_SIZE(stk_sizes))
1101 i++;
1102 if (i == ARRAY_SIZE(stk_sizes)) {
1103 STK_ERROR("Something is broken in %s\n", __FUNCTION__);
1104 return -EFAULT;
1105 }
1106 /* This registers controls some timings, not sure of what. */
1107 stk_camera_write_reg(dev, 0x001b, 0x0e);
1108 if (dev->vsettings.mode == MODE_SXGA)
1109 stk_camera_write_reg(dev, 0x001c, 0x0e);
1110 else
1111 stk_camera_write_reg(dev, 0x001c, 0x46);
1112 /*
1113 * Registers 0x0115 0x0114 are the size of each line (bytes),
1114 * regs 0x0117 0x0116 are the heigth of the image.
1115 */
1116 stk_camera_write_reg(dev, 0x0115,
1117 ((stk_sizes[i].w * depth) >> 8) & 0xff);
1118 stk_camera_write_reg(dev, 0x0114,
1119 (stk_sizes[i].w * depth) & 0xff);
1120 stk_camera_write_reg(dev, 0x0117,
1121 (stk_sizes[i].h >> 8) & 0xff);
1122 stk_camera_write_reg(dev, 0x0116,
1123 stk_sizes[i].h & 0xff);
1124 return stk_sensor_configure(dev);
1125}
1126
1083static int stk_vidioc_s_fmt_cap(struct file *filp, 1127static int stk_vidioc_s_fmt_cap(struct file *filp,
1084 void *priv, struct v4l2_format *fmtd) 1128 void *priv, struct v4l2_format *fmtd)
1085{ 1129{
@@ -1094,10 +1138,10 @@ static int stk_vidioc_s_fmt_cap(struct file *filp,
1094 return -EBUSY; 1138 return -EBUSY;
1095 if (dev->owner && dev->owner != filp) 1139 if (dev->owner && dev->owner != filp)
1096 return -EBUSY; 1140 return -EBUSY;
1097 dev->owner = filp;
1098 ret = stk_vidioc_try_fmt_cap(filp, priv, fmtd); 1141 ret = stk_vidioc_try_fmt_cap(filp, priv, fmtd);
1099 if (ret) 1142 if (ret)
1100 return ret; 1143 return ret;
1144 dev->owner = filp;
1101 1145
1102 dev->vsettings.palette = fmtd->fmt.pix.pixelformat; 1146 dev->vsettings.palette = fmtd->fmt.pix.pixelformat;
1103 stk_free_buffers(dev); 1147 stk_free_buffers(dev);
@@ -1105,25 +1149,7 @@ static int stk_vidioc_s_fmt_cap(struct file *filp,
1105 dev->vsettings.mode = stk_sizes[fmtd->fmt.pix.priv].m; 1149 dev->vsettings.mode = stk_sizes[fmtd->fmt.pix.priv].m;
1106 1150
1107 stk_initialise(dev); 1151 stk_initialise(dev);
1108 /* This registers controls some timings, not sure of what. */ 1152 return stk_setup_format(dev);
1109 stk_camera_write_reg(dev, 0x001b, 0x0e);
1110 if (dev->vsettings.mode == MODE_SXGA)
1111 stk_camera_write_reg(dev, 0x001c, 0x0e);
1112 else
1113 stk_camera_write_reg(dev, 0x001c, 0x46);
1114 /*
1115 * Registers 0x0115 0x0114 are the size of each line (bytes),
1116 * regs 0x0117 0x0116 are the heigth of the image.
1117 */
1118 stk_camera_write_reg(dev, 0x0115,
1119 (fmtd->fmt.pix.bytesperline >> 8) & 0xff);
1120 stk_camera_write_reg(dev, 0x0114,
1121 fmtd->fmt.pix.bytesperline & 0xff);
1122 stk_camera_write_reg(dev, 0x0117,
1123 (fmtd->fmt.pix.height >> 8) & 0xff);
1124 stk_camera_write_reg(dev, 0x0116,
1125 fmtd->fmt.pix.height & 0xff);
1126 return stk_sensor_configure(dev);
1127} 1153}
1128 1154
1129static int stk_vidioc_reqbufs(struct file *filp, 1155static int stk_vidioc_reqbufs(struct file *filp,
@@ -1288,6 +1314,9 @@ static struct file_operations v4l_stk_fops = {
1288 .poll = v4l_stk_poll, 1314 .poll = v4l_stk_poll,
1289 .mmap = v4l_stk_mmap, 1315 .mmap = v4l_stk_mmap,
1290 .ioctl = video_ioctl2, 1316 .ioctl = video_ioctl2,
1317#ifdef CONFIG_COMPAT
1318 .compat_ioctl = v4l_compat_ioctl32,
1319#endif
1291 .llseek = no_llseek 1320 .llseek = no_llseek
1292}; 1321};
1293 1322
@@ -1403,7 +1432,7 @@ static int stk_camera_probe(struct usb_interface *interface,
1403 dev->vsettings.brightness = 0x7fff; 1432 dev->vsettings.brightness = 0x7fff;
1404 dev->vsettings.palette = V4L2_PIX_FMT_RGB565; 1433 dev->vsettings.palette = V4L2_PIX_FMT_RGB565;
1405 dev->vsettings.mode = MODE_VGA; 1434 dev->vsettings.mode = MODE_VGA;
1406 dev->frame_size = 640*480*2; 1435 dev->frame_size = 640 * 480 * 2;
1407 1436
1408 INIT_LIST_HEAD(&dev->sio_avail); 1437 INIT_LIST_HEAD(&dev->sio_avail);
1409 INIT_LIST_HEAD(&dev->sio_full); 1438 INIT_LIST_HEAD(&dev->sio_full);
@@ -1417,6 +1446,7 @@ static int stk_camera_probe(struct usb_interface *interface,
1417 } 1446 }
1418 1447
1419 stk_create_sysfs_files(&dev->vdev); 1448 stk_create_sysfs_files(&dev->vdev);
1449 usb_autopm_enable(dev->interface);
1420 1450
1421 return 0; 1451 return 0;
1422} 1452}
@@ -1434,11 +1464,41 @@ static void stk_camera_disconnect(struct usb_interface *interface)
1434 kref_put(&dev->kref, stk_camera_cleanup); 1464 kref_put(&dev->kref, stk_camera_cleanup);
1435} 1465}
1436 1466
1467#ifdef CONFIG_PM
1468int stk_camera_suspend(struct usb_interface *intf, pm_message_t message)
1469{
1470 struct stk_camera *dev = usb_get_intfdata(intf);
1471 if (is_streaming(dev)) {
1472 stk_stop_stream(dev);
1473 /* yes, this is ugly */
1474 set_streaming(dev);
1475 }
1476 return 0;
1477}
1478
1479int stk_camera_resume(struct usb_interface *intf)
1480{
1481 struct stk_camera *dev = usb_get_intfdata(intf);
1482 if (!is_initialised(dev))
1483 return 0;
1484 unset_initialised(dev);
1485 stk_initialise(dev);
1486 stk_setup_format(dev);
1487 if (is_streaming(dev))
1488 stk_start_stream(dev);
1489 return 0;
1490}
1491#endif
1492
1437static struct usb_driver stk_camera_driver = { 1493static struct usb_driver stk_camera_driver = {
1438 .name = "stkwebcam", 1494 .name = "stkwebcam",
1439 .probe = stk_camera_probe, 1495 .probe = stk_camera_probe,
1440 .disconnect = stk_camera_disconnect, 1496 .disconnect = stk_camera_disconnect,
1441 .id_table = stkwebcam_table, 1497 .id_table = stkwebcam_table,
1498#ifdef CONFIG_PM
1499 .suspend = stk_camera_suspend,
1500 .resume = stk_camera_resume,
1501#endif
1442}; 1502};
1443 1503
1444 1504
diff --git a/drivers/media/video/stk-webcam.h b/drivers/media/video/stk-webcam.h
index 7e989d1ac1e0..df4dfefc5327 100644
--- a/drivers/media/video/stk-webcam.h
+++ b/drivers/media/video/stk-webcam.h
@@ -79,6 +79,7 @@ enum stk_status {
79#define unset_present(dev) ((dev)->status &= \ 79#define unset_present(dev) ((dev)->status &= \
80 ~(S_PRESENT|S_INITIALISED|S_STREAMING)) 80 ~(S_PRESENT|S_INITIALISED|S_STREAMING))
81#define set_initialised(dev) ((dev)->status |= S_INITIALISED) 81#define set_initialised(dev) ((dev)->status |= S_INITIALISED)
82#define unset_initialised(dev) ((dev)->status &= ~S_INITIALISED)
82#define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD) 83#define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD)
83#define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD) 84#define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD)
84#define set_streaming(dev) ((dev)->status |= S_STREAMING) 85#define set_streaming(dev) ((dev)->status |= S_STREAMING)
@@ -127,8 +128,6 @@ void stk_camera_delete(struct kref *);
127int stk_camera_write_reg(struct stk_camera *, u16, u8); 128int stk_camera_write_reg(struct stk_camera *, u16, u8);
128int stk_camera_read_reg(struct stk_camera *, u16, int *); 129int stk_camera_read_reg(struct stk_camera *, u16, int *);
129 130
130int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val);
131int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val);
132int stk_sensor_init(struct stk_camera *); 131int stk_sensor_init(struct stk_camera *);
133int stk_sensor_configure(struct stk_camera *); 132int stk_sensor_configure(struct stk_camera *);
134int stk_sensor_sleep(struct stk_camera *dev); 133int stk_sensor_sleep(struct stk_camera *dev);
diff --git a/drivers/media/video/tcm825x.c b/drivers/media/video/tcm825x.c
index 41cd6a0b0485..fb895f6684a3 100644
--- a/drivers/media/video/tcm825x.c
+++ b/drivers/media/video/tcm825x.c
@@ -851,7 +851,7 @@ static int tcm825x_probe(struct i2c_client *client)
851 sensor->platform_data = client->dev.platform_data; 851 sensor->platform_data = client->dev.platform_data;
852 852
853 if (sensor->platform_data == NULL 853 if (sensor->platform_data == NULL
854 && !sensor->platform_data->is_okay()) 854 || !sensor->platform_data->is_okay())
855 return -ENODEV; 855 return -ENODEV;
856 856
857 sensor->v4l2_int_device = &tcm825x_int_device; 857 sensor->v4l2_int_device = &tcm825x_int_device;
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index ba538f6fbcc3..78a09a2a4857 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -1038,7 +1038,7 @@ static int tuner_resume(struct i2c_client *c)
1038 1038
1039/* ---------------------------------------------------------------------- */ 1039/* ---------------------------------------------------------------------- */
1040 1040
1041LIST_HEAD(tuner_list); 1041static LIST_HEAD(tuner_list);
1042 1042
1043/* Search for existing radio and/or TV tuners on the given I2C adapter. 1043/* Search for existing radio and/or TV tuners on the given I2C adapter.
1044 Note that when this function is called from tuner_probe you can be 1044 Note that when this function is called from tuner_probe you can be
diff --git a/drivers/media/video/tuner-xc2028.c b/drivers/media/video/tuner-xc2028.c
index f191f6a48070..50cf876f020f 100644
--- a/drivers/media/video/tuner-xc2028.c
+++ b/drivers/media/video/tuner-xc2028.c
@@ -754,6 +754,9 @@ skip_std_specific:
754 goto check_device; 754 goto check_device;
755 } 755 }
756 756
757 if (new_fw.type & FM)
758 goto check_device;
759
757 /* Load SCODE firmware, if exists */ 760 /* Load SCODE firmware, if exists */
758 tuner_dbg("Trying to load scode %d\n", new_fw.scode_nr); 761 tuner_dbg("Trying to load scode %d\n", new_fw.scode_nr);
759 762
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index a75560540e79..01ebcec040c4 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -1571,14 +1571,14 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip,
1571 ctrl->value=chip->muted; 1571 ctrl->value=chip->muted;
1572 return 0; 1572 return 0;
1573 case V4L2_CID_AUDIO_VOLUME: 1573 case V4L2_CID_AUDIO_VOLUME:
1574 if (!desc->flags & CHIP_HAS_VOLUME) 1574 if (!(desc->flags & CHIP_HAS_VOLUME))
1575 break; 1575 break;
1576 ctrl->value = max(chip->left,chip->right); 1576 ctrl->value = max(chip->left,chip->right);
1577 return 0; 1577 return 0;
1578 case V4L2_CID_AUDIO_BALANCE: 1578 case V4L2_CID_AUDIO_BALANCE:
1579 { 1579 {
1580 int volume; 1580 int volume;
1581 if (!desc->flags & CHIP_HAS_VOLUME) 1581 if (!(desc->flags & CHIP_HAS_VOLUME))
1582 break; 1582 break;
1583 volume = max(chip->left,chip->right); 1583 volume = max(chip->left,chip->right);
1584 if (volume) 1584 if (volume)
@@ -1621,7 +1621,7 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip,
1621 { 1621 {
1622 int volume,balance; 1622 int volume,balance;
1623 1623
1624 if (!desc->flags & CHIP_HAS_VOLUME) 1624 if (!(desc->flags & CHIP_HAS_VOLUME))
1625 break; 1625 break;
1626 1626
1627 volume = max(chip->left,chip->right); 1627 volume = max(chip->left,chip->right);
@@ -1642,7 +1642,7 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip,
1642 case V4L2_CID_AUDIO_BALANCE: 1642 case V4L2_CID_AUDIO_BALANCE:
1643 { 1643 {
1644 int volume, balance; 1644 int volume, balance;
1645 if (!desc->flags & CHIP_HAS_VOLUME) 1645 if (!(desc->flags & CHIP_HAS_VOLUME))
1646 break; 1646 break;
1647 1647
1648 volume = max(chip->left,chip->right); 1648 volume = max(chip->left,chip->right);
@@ -1702,7 +1702,7 @@ static int chip_command(struct i2c_client *client,
1702 break; 1702 break;
1703 case V4L2_CID_AUDIO_VOLUME: 1703 case V4L2_CID_AUDIO_VOLUME:
1704 case V4L2_CID_AUDIO_BALANCE: 1704 case V4L2_CID_AUDIO_BALANCE:
1705 if (!desc->flags & CHIP_HAS_VOLUME) 1705 if (!(desc->flags & CHIP_HAS_VOLUME))
1706 return -EINVAL; 1706 return -EINVAL;
1707 break; 1707 break;
1708 case V4L2_CID_AUDIO_BASS: 1708 case V4L2_CID_AUDIO_BASS:
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 0b8fbad3c721..dc0da44a5af6 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -242,7 +242,7 @@ hauppauge_tuner[] =
242 { TUNER_ABSENT, "TCL M2523_3DBH_E"}, 242 { TUNER_ABSENT, "TCL M2523_3DBH_E"},
243 { TUNER_ABSENT, "TCL M2523_3DIH_E"}, 243 { TUNER_ABSENT, "TCL M2523_3DIH_E"},
244 { TUNER_ABSENT, "TCL MFPE05_2_U"}, 244 { TUNER_ABSENT, "TCL MFPE05_2_U"},
245 { TUNER_ABSENT, "Philips FMD1216MEX"}, 245 { TUNER_PHILIPS_FMD1216ME_MK3, "Philips FMD1216MEX"},
246 { TUNER_ABSENT, "Philips FRH2036B"}, 246 { TUNER_ABSENT, "Philips FRH2036B"},
247 { TUNER_ABSENT, "Panasonic ENGF75_01GF"}, 247 { TUNER_ABSENT, "Panasonic ENGF75_01GF"},
248 { TUNER_ABSENT, "MaxLinear MXL5005"}, 248 { TUNER_ABSENT, "MaxLinear MXL5005"},
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index c056ff6d810c..34deb68ae568 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -56,7 +56,6 @@
56#include <asm/pgtable.h> 56#include <asm/pgtable.h>
57#include <asm/io.h> 57#include <asm/io.h>
58#include <asm/div64.h> 58#include <asm/div64.h>
59#include <linux/video_decoder.h>
60#define __OLD_VIDIOC_ /* To allow fixing old calls*/ 59#define __OLD_VIDIOC_ /* To allow fixing old calls*/
61#include <media/v4l2-common.h> 60#include <media/v4l2-common.h>
62#include <media/v4l2-chip-ident.h> 61#include <media/v4l2-chip-ident.h>
@@ -82,108 +81,6 @@ MODULE_LICENSE("GPL");
82 */ 81 */
83 82
84 83
85char *v4l2_norm_to_name(v4l2_std_id id)
86{
87 char *name;
88 u32 myid = id;
89
90 /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
91 64 bit comparations. So, on that architecture, with some gcc variants,
92 compilation fails. Currently, the max value is 30bit wide.
93 */
94 BUG_ON(myid != id);
95
96 switch (myid) {
97 case V4L2_STD_PAL:
98 name="PAL"; break;
99 case V4L2_STD_PAL_BG:
100 name="PAL-BG"; break;
101 case V4L2_STD_PAL_DK:
102 name="PAL-DK"; break;
103 case V4L2_STD_PAL_B:
104 name="PAL-B"; break;
105 case V4L2_STD_PAL_B1:
106 name="PAL-B1"; break;
107 case V4L2_STD_PAL_G:
108 name="PAL-G"; break;
109 case V4L2_STD_PAL_H:
110 name="PAL-H"; break;
111 case V4L2_STD_PAL_I:
112 name="PAL-I"; break;
113 case V4L2_STD_PAL_D:
114 name="PAL-D"; break;
115 case V4L2_STD_PAL_D1:
116 name="PAL-D1"; break;
117 case V4L2_STD_PAL_K:
118 name="PAL-K"; break;
119 case V4L2_STD_PAL_M:
120 name="PAL-M"; break;
121 case V4L2_STD_PAL_N:
122 name="PAL-N"; break;
123 case V4L2_STD_PAL_Nc:
124 name="PAL-Nc"; break;
125 case V4L2_STD_PAL_60:
126 name="PAL-60"; break;
127 case V4L2_STD_NTSC:
128 name="NTSC"; break;
129 case V4L2_STD_NTSC_M:
130 name="NTSC-M"; break;
131 case V4L2_STD_NTSC_M_JP:
132 name="NTSC-M-JP"; break;
133 case V4L2_STD_NTSC_443:
134 name="NTSC-443"; break;
135 case V4L2_STD_NTSC_M_KR:
136 name="NTSC-M-KR"; break;
137 case V4L2_STD_SECAM:
138 name="SECAM"; break;
139 case V4L2_STD_SECAM_DK:
140 name="SECAM-DK"; break;
141 case V4L2_STD_SECAM_B:
142 name="SECAM-B"; break;
143 case V4L2_STD_SECAM_D:
144 name="SECAM-D"; break;
145 case V4L2_STD_SECAM_G:
146 name="SECAM-G"; break;
147 case V4L2_STD_SECAM_H:
148 name="SECAM-H"; break;
149 case V4L2_STD_SECAM_K:
150 name="SECAM-K"; break;
151 case V4L2_STD_SECAM_K1:
152 name="SECAM-K1"; break;
153 case V4L2_STD_SECAM_L:
154 name="SECAM-L"; break;
155 case V4L2_STD_SECAM_LC:
156 name="SECAM-LC"; break;
157 default:
158 name="Unknown"; break;
159 }
160
161 return name;
162}
163
164/* Fill in the fields of a v4l2_standard structure according to the
165 'id' and 'transmission' parameters. Returns negative on error. */
166int v4l2_video_std_construct(struct v4l2_standard *vs,
167 int id, char *name)
168{
169 u32 index = vs->index;
170
171 memset(vs, 0, sizeof(struct v4l2_standard));
172 vs->index = index;
173 vs->id = id;
174 if (id & V4L2_STD_525_60) {
175 vs->frameperiod.numerator = 1001;
176 vs->frameperiod.denominator = 30000;
177 vs->framelines = 525;
178 } else {
179 vs->frameperiod.numerator = 1;
180 vs->frameperiod.denominator = 25;
181 vs->framelines = 625;
182 }
183 strlcpy(vs->name,name,sizeof(vs->name));
184 return 0;
185}
186
187/* ----------------------------------------------------------------- */ 84/* ----------------------------------------------------------------- */
188/* priority handling */ 85/* priority handling */
189 86
@@ -196,6 +93,7 @@ int v4l2_prio_init(struct v4l2_prio_state *global)
196 memset(global,0,sizeof(*global)); 93 memset(global,0,sizeof(*global));
197 return 0; 94 return 0;
198} 95}
96EXPORT_SYMBOL(v4l2_prio_init);
199 97
200int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, 98int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
201 enum v4l2_priority new) 99 enum v4l2_priority new)
@@ -211,11 +109,13 @@ int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
211 *local = new; 109 *local = new;
212 return 0; 110 return 0;
213} 111}
112EXPORT_SYMBOL(v4l2_prio_change);
214 113
215int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local) 114int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local)
216{ 115{
217 return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT); 116 return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT);
218} 117}
118EXPORT_SYMBOL(v4l2_prio_open);
219 119
220int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local) 120int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local)
221{ 121{
@@ -223,6 +123,7 @@ int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local)
223 atomic_dec(&global->prios[*local]); 123 atomic_dec(&global->prios[*local]);
224 return 0; 124 return 0;
225} 125}
126EXPORT_SYMBOL(v4l2_prio_close);
226 127
227enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global) 128enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
228{ 129{
@@ -234,6 +135,7 @@ enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global)
234 return V4L2_PRIORITY_BACKGROUND; 135 return V4L2_PRIORITY_BACKGROUND;
235 return V4L2_PRIORITY_UNSET; 136 return V4L2_PRIORITY_UNSET;
236} 137}
138EXPORT_SYMBOL(v4l2_prio_max);
237 139
238int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local) 140int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local)
239{ 141{
@@ -241,225 +143,7 @@ int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local)
241 return -EBUSY; 143 return -EBUSY;
242 return 0; 144 return 0;
243} 145}
244 146EXPORT_SYMBOL(v4l2_prio_check);
245
246/* ----------------------------------------------------------------- */
247/* some arrays for pretty-printing debug messages of enum types */
248
249char *v4l2_field_names[] = {
250 [V4L2_FIELD_ANY] = "any",
251 [V4L2_FIELD_NONE] = "none",
252 [V4L2_FIELD_TOP] = "top",
253 [V4L2_FIELD_BOTTOM] = "bottom",
254 [V4L2_FIELD_INTERLACED] = "interlaced",
255 [V4L2_FIELD_SEQ_TB] = "seq-tb",
256 [V4L2_FIELD_SEQ_BT] = "seq-bt",
257 [V4L2_FIELD_ALTERNATE] = "alternate",
258 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
259 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
260};
261
262char *v4l2_type_names[] = {
263 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap",
264 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over",
265 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out",
266 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
267 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
268 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
269 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
270 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over",
271};
272
273
274#define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown"
275
276/* ------------------------------------------------------------------ */
277/* debug help functions */
278
279#ifdef CONFIG_VIDEO_V4L1_COMPAT
280static const char *v4l1_ioctls[] = {
281 [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP",
282 [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN",
283 [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN",
284 [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER",
285 [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER",
286 [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT",
287 [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT",
288 [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE",
289 [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN",
290 [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN",
291 [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF",
292 [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF",
293 [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY",
294 [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ",
295 [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ",
296 [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO",
297 [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO",
298 [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC",
299 [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE",
300 [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF",
301 [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT",
302 [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE",
303 [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE",
304 [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE",
305 [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE",
306 [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO",
307 [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE",
308 [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT",
309 [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT"
310};
311#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
312#endif
313
314static const char *v4l2_ioctls[] = {
315 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
316 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
317 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
318 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
319 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
320 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
321 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
322 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
323 [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
324 [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
325 [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
326 [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
327 [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
328 [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
329 [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
330 [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
331 [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
332 [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
333 [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
334 [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
335 [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
336 [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
337 [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
338 [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
339 [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
340 [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
341 [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
342 [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
343 [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
344 [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
345 [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
346 [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
347 [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
348 [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
349 [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
350 [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
351 [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
352 [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
353 [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
354 [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
355 [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
356 [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
357 [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
358 [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
359 [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
360 [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
361 [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO",
362 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
363 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
364 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
365 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
366 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
367 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
368 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
369 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
370#if 1
371 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
372 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
373 [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
374 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
375 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
376
377 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
378 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
379
380 [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT",
381#endif
382};
383#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
384
385static const char *v4l2_int_ioctls[] = {
386#ifdef CONFIG_VIDEO_V4L1_COMPAT
387 [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES",
388 [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS",
389 [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM",
390 [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT",
391 [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT",
392 [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT",
393 [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE",
394 [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO",
395 [_IOC_NR(DECODER_INIT)] = "DECODER_INIT",
396 [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS",
397 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
398#endif
399 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
400
401 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
402 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
403 [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG",
404
405 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
406 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
407 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
408 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
409 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
410 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
411 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
412 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
413 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
414 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
415 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
416 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING",
417 [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ",
418 [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT",
419 [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT",
420 [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT",
421};
422#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
423
424
425/* Common ioctl debug function. This function can be used by
426 external ioctl messages as well as internal V4L ioctl */
427void v4l_printk_ioctl(unsigned int cmd)
428{
429 char *dir;
430
431 switch (_IOC_DIR(cmd)) {
432 case _IOC_NONE: dir = "--"; break;
433 case _IOC_READ: dir = "r-"; break;
434 case _IOC_WRITE: dir = "-w"; break;
435 case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
436 default: dir = "*ERR*"; break;
437 }
438 switch (_IOC_TYPE(cmd)) {
439 case 'd':
440 printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n",
441 (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ?
442 v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
443 break;
444#ifdef CONFIG_VIDEO_V4L1_COMPAT
445 case 'v':
446 printk("v4l1 ioctl %s, dir=%s (0x%08x)\n",
447 (_IOC_NR(cmd) < V4L1_IOCTLS) ?
448 v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
449 break;
450#endif
451 case 'V':
452 printk("v4l2 ioctl %s, dir=%s (0x%08x)\n",
453 (_IOC_NR(cmd) < V4L2_IOCTLS) ?
454 v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
455 break;
456
457 default:
458 printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n",
459 _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
460 }
461}
462
463 147
464/* ----------------------------------------------------------------- */ 148/* ----------------------------------------------------------------- */
465 149
@@ -488,6 +172,7 @@ int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
488 } 172 }
489 return 0; 173 return 0;
490} 174}
175EXPORT_SYMBOL(v4l2_ctrl_check);
491 176
492/* Returns NULL or a character pointer array containing the menu for 177/* Returns NULL or a character pointer array containing the menu for
493 the given control ID. The pointer array ends with a NULL pointer. 178 the given control ID. The pointer array ends with a NULL pointer.
@@ -648,6 +333,7 @@ const char **v4l2_ctrl_get_menu(u32 id)
648 return NULL; 333 return NULL;
649 } 334 }
650} 335}
336EXPORT_SYMBOL(v4l2_ctrl_get_menu);
651 337
652/* Fill in a struct v4l2_queryctrl */ 338/* Fill in a struct v4l2_queryctrl */
653int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) 339int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def)
@@ -770,6 +456,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste
770 snprintf(qctrl->name, sizeof(qctrl->name), name); 456 snprintf(qctrl->name, sizeof(qctrl->name), name);
771 return 0; 457 return 0;
772} 458}
459EXPORT_SYMBOL(v4l2_ctrl_query_fill);
773 460
774/* Fill in a struct v4l2_queryctrl with standard values based on 461/* Fill in a struct v4l2_queryctrl with standard values based on
775 the control ID. */ 462 the control ID. */
@@ -904,6 +591,7 @@ int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl)
904 return -EINVAL; 591 return -EINVAL;
905 } 592 }
906} 593}
594EXPORT_SYMBOL(v4l2_ctrl_query_fill_std);
907 595
908/* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and 596/* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and
909 the menu. The qctrl pointer may be NULL, in which case it is ignored. */ 597 the menu. The qctrl pointer may be NULL, in which case it is ignored. */
@@ -922,6 +610,7 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc
922 qmenu->reserved = 0; 610 qmenu->reserved = 0;
923 return 0; 611 return 0;
924} 612}
613EXPORT_SYMBOL(v4l2_ctrl_query_menu);
925 614
926/* ctrl_classes points to an array of u32 pointers, the last element is 615/* ctrl_classes points to an array of u32 pointers, the last element is
927 a NULL pointer. Each u32 array is a 0-terminated array of control IDs. 616 a NULL pointer. Each u32 array is a 0-terminated array of control IDs.
@@ -972,7 +661,20 @@ u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id)
972 return 0; 661 return 0;
973 return **ctrl_classes; 662 return **ctrl_classes;
974} 663}
664EXPORT_SYMBOL(v4l2_ctrl_next);
975 665
666int v4l2_chip_match_host(u32 match_type, u32 match_chip)
667{
668 switch (match_type) {
669 case V4L2_CHIP_MATCH_HOST:
670 return match_chip == 0;
671 default:
672 return 0;
673 }
674}
675EXPORT_SYMBOL(v4l2_chip_match_host);
676
677#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE))
976int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_chip) 678int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_chip)
977{ 679{
978 switch (match_type) { 680 switch (match_type) {
@@ -984,6 +686,7 @@ int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_c
984 return 0; 686 return 0;
985 } 687 }
986} 688}
689EXPORT_SYMBOL(v4l2_chip_match_i2c_client);
987 690
988int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip, 691int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip,
989 u32 ident, u32 revision) 692 u32 ident, u32 revision)
@@ -1000,16 +703,7 @@ int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chi
1000 } 703 }
1001 return 0; 704 return 0;
1002} 705}
1003 706EXPORT_SYMBOL(v4l2_chip_ident_i2c_client);
1004int v4l2_chip_match_host(u32 match_type, u32 match_chip)
1005{
1006 switch (match_type) {
1007 case V4L2_CHIP_MATCH_HOST:
1008 return match_chip == 0;
1009 default:
1010 return 0;
1011 }
1012}
1013 707
1014/* ----------------------------------------------------------------- */ 708/* ----------------------------------------------------------------- */
1015 709
@@ -1038,38 +732,5 @@ int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver
1038 } 732 }
1039 return err != -ENOMEM ? 0 : err; 733 return err != -ENOMEM ? 0 : err;
1040} 734}
1041
1042/* ----------------------------------------------------------------- */
1043
1044EXPORT_SYMBOL(v4l2_norm_to_name);
1045EXPORT_SYMBOL(v4l2_video_std_construct);
1046
1047EXPORT_SYMBOL(v4l2_prio_init);
1048EXPORT_SYMBOL(v4l2_prio_change);
1049EXPORT_SYMBOL(v4l2_prio_open);
1050EXPORT_SYMBOL(v4l2_prio_close);
1051EXPORT_SYMBOL(v4l2_prio_max);
1052EXPORT_SYMBOL(v4l2_prio_check);
1053
1054EXPORT_SYMBOL(v4l2_field_names);
1055EXPORT_SYMBOL(v4l2_type_names);
1056EXPORT_SYMBOL(v4l_printk_ioctl);
1057
1058EXPORT_SYMBOL(v4l2_ctrl_next);
1059EXPORT_SYMBOL(v4l2_ctrl_check);
1060EXPORT_SYMBOL(v4l2_ctrl_get_menu);
1061EXPORT_SYMBOL(v4l2_ctrl_query_menu);
1062EXPORT_SYMBOL(v4l2_ctrl_query_fill);
1063EXPORT_SYMBOL(v4l2_ctrl_query_fill_std);
1064
1065EXPORT_SYMBOL(v4l2_chip_match_i2c_client);
1066EXPORT_SYMBOL(v4l2_chip_ident_i2c_client);
1067EXPORT_SYMBOL(v4l2_chip_match_host);
1068
1069EXPORT_SYMBOL(v4l2_i2c_attach); 735EXPORT_SYMBOL(v4l2_i2c_attach);
1070 736#endif
1071/*
1072 * Local variables:
1073 * c-basic-offset: 8
1074 * End:
1075 */
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c
index 80a14da9acef..eab79ffdf56a 100644
--- a/drivers/media/video/videobuf-core.c
+++ b/drivers/media/video/videobuf-core.c
@@ -147,7 +147,7 @@ void videobuf_queue_core_init(struct videobuf_queue *q,
147 /* Having implementations for abstract methods are mandatory */ 147 /* Having implementations for abstract methods are mandatory */
148 BUG_ON(!q->int_ops); 148 BUG_ON(!q->int_ops);
149 149
150 mutex_init(&q->lock); 150 mutex_init(&q->vb_lock);
151 INIT_LIST_HEAD(&q->stream); 151 INIT_LIST_HEAD(&q->stream);
152} 152}
153 153
@@ -189,7 +189,7 @@ int videobuf_queue_is_busy(struct videobuf_queue *q)
189 return 0; 189 return 0;
190} 190}
191 191
192/* Locking: Caller holds q->lock */ 192/* Locking: Caller holds q->vb_lock */
193void videobuf_queue_cancel(struct videobuf_queue *q) 193void videobuf_queue_cancel(struct videobuf_queue *q)
194{ 194{
195 unsigned long flags = 0; 195 unsigned long flags = 0;
@@ -220,7 +220,7 @@ void videobuf_queue_cancel(struct videobuf_queue *q)
220 220
221/* --------------------------------------------------------------------- */ 221/* --------------------------------------------------------------------- */
222 222
223/* Locking: Caller holds q->lock */ 223/* Locking: Caller holds q->vb_lock */
224enum v4l2_field videobuf_next_field(struct videobuf_queue *q) 224enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
225{ 225{
226 enum v4l2_field field = q->field; 226 enum v4l2_field field = q->field;
@@ -239,7 +239,7 @@ enum v4l2_field videobuf_next_field(struct videobuf_queue *q)
239 return field; 239 return field;
240} 240}
241 241
242/* Locking: Caller holds q->lock */ 242/* Locking: Caller holds q->vb_lock */
243static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, 243static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
244 struct videobuf_buffer *vb, enum v4l2_buf_type type) 244 struct videobuf_buffer *vb, enum v4l2_buf_type type)
245{ 245{
@@ -295,7 +295,7 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
295 b->sequence = vb->field_count >> 1; 295 b->sequence = vb->field_count >> 1;
296} 296}
297 297
298/* Locking: Caller holds q->lock */ 298/* Locking: Caller holds q->vb_lock */
299static int __videobuf_mmap_free(struct videobuf_queue *q) 299static int __videobuf_mmap_free(struct videobuf_queue *q)
300{ 300{
301 int i; 301 int i;
@@ -328,13 +328,13 @@ static int __videobuf_mmap_free(struct videobuf_queue *q)
328int videobuf_mmap_free(struct videobuf_queue *q) 328int videobuf_mmap_free(struct videobuf_queue *q)
329{ 329{
330 int ret; 330 int ret;
331 mutex_lock(&q->lock); 331 mutex_lock(&q->vb_lock);
332 ret = __videobuf_mmap_free(q); 332 ret = __videobuf_mmap_free(q);
333 mutex_unlock(&q->lock); 333 mutex_unlock(&q->vb_lock);
334 return ret; 334 return ret;
335} 335}
336 336
337/* Locking: Caller holds q->lock */ 337/* Locking: Caller holds q->vb_lock */
338static int __videobuf_mmap_setup(struct videobuf_queue *q, 338static int __videobuf_mmap_setup(struct videobuf_queue *q,
339 unsigned int bcount, unsigned int bsize, 339 unsigned int bcount, unsigned int bsize,
340 enum v4l2_memory memory) 340 enum v4l2_memory memory)
@@ -384,9 +384,9 @@ int videobuf_mmap_setup(struct videobuf_queue *q,
384 enum v4l2_memory memory) 384 enum v4l2_memory memory)
385{ 385{
386 int ret; 386 int ret;
387 mutex_lock(&q->lock); 387 mutex_lock(&q->vb_lock);
388 ret = __videobuf_mmap_setup(q, bcount, bsize, memory); 388 ret = __videobuf_mmap_setup(q, bcount, bsize, memory);
389 mutex_unlock(&q->lock); 389 mutex_unlock(&q->vb_lock);
390 return ret; 390 return ret;
391} 391}
392 392
@@ -408,7 +408,7 @@ int videobuf_reqbufs(struct videobuf_queue *q,
408 return -EINVAL; 408 return -EINVAL;
409 } 409 }
410 410
411 mutex_lock(&q->lock); 411 mutex_lock(&q->vb_lock);
412 if (req->type != q->type) { 412 if (req->type != q->type) {
413 dprintk(1, "reqbufs: queue type invalid\n"); 413 dprintk(1, "reqbufs: queue type invalid\n");
414 retval = -EINVAL; 414 retval = -EINVAL;
@@ -444,7 +444,7 @@ int videobuf_reqbufs(struct videobuf_queue *q,
444 req->count = retval; 444 req->count = retval;
445 445
446 done: 446 done:
447 mutex_unlock(&q->lock); 447 mutex_unlock(&q->vb_lock);
448 return retval; 448 return retval;
449} 449}
450 450
@@ -452,7 +452,7 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
452{ 452{
453 int ret = -EINVAL; 453 int ret = -EINVAL;
454 454
455 mutex_lock(&q->lock); 455 mutex_lock(&q->vb_lock);
456 if (unlikely(b->type != q->type)) { 456 if (unlikely(b->type != q->type)) {
457 dprintk(1, "querybuf: Wrong type.\n"); 457 dprintk(1, "querybuf: Wrong type.\n");
458 goto done; 458 goto done;
@@ -470,7 +470,7 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
470 470
471 ret = 0; 471 ret = 0;
472done: 472done:
473 mutex_unlock(&q->lock); 473 mutex_unlock(&q->vb_lock);
474 return ret; 474 return ret;
475} 475}
476 476
@@ -487,7 +487,7 @@ int videobuf_qbuf(struct videobuf_queue *q,
487 if (b->memory == V4L2_MEMORY_MMAP) 487 if (b->memory == V4L2_MEMORY_MMAP)
488 down_read(&current->mm->mmap_sem); 488 down_read(&current->mm->mmap_sem);
489 489
490 mutex_lock(&q->lock); 490 mutex_lock(&q->vb_lock);
491 retval = -EBUSY; 491 retval = -EBUSY;
492 if (q->reading) { 492 if (q->reading) {
493 dprintk(1, "qbuf: Reading running...\n"); 493 dprintk(1, "qbuf: Reading running...\n");
@@ -573,7 +573,7 @@ int videobuf_qbuf(struct videobuf_queue *q,
573 retval = 0; 573 retval = 0;
574 574
575 done: 575 done:
576 mutex_unlock(&q->lock); 576 mutex_unlock(&q->vb_lock);
577 577
578 if (b->memory == V4L2_MEMORY_MMAP) 578 if (b->memory == V4L2_MEMORY_MMAP)
579 up_read(&current->mm->mmap_sem); 579 up_read(&current->mm->mmap_sem);
@@ -589,7 +589,7 @@ int videobuf_dqbuf(struct videobuf_queue *q,
589 589
590 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 590 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
591 591
592 mutex_lock(&q->lock); 592 mutex_lock(&q->vb_lock);
593 retval = -EBUSY; 593 retval = -EBUSY;
594 if (q->reading) { 594 if (q->reading) {
595 dprintk(1, "dqbuf: Reading running...\n"); 595 dprintk(1, "dqbuf: Reading running...\n");
@@ -632,7 +632,7 @@ int videobuf_dqbuf(struct videobuf_queue *q,
632 videobuf_status(q, b, buf, q->type); 632 videobuf_status(q, b, buf, q->type);
633 633
634 done: 634 done:
635 mutex_unlock(&q->lock); 635 mutex_unlock(&q->vb_lock);
636 return retval; 636 return retval;
637} 637}
638 638
@@ -642,7 +642,7 @@ int videobuf_streamon(struct videobuf_queue *q)
642 unsigned long flags = 0; 642 unsigned long flags = 0;
643 int retval; 643 int retval;
644 644
645 mutex_lock(&q->lock); 645 mutex_lock(&q->vb_lock);
646 retval = -EBUSY; 646 retval = -EBUSY;
647 if (q->reading) 647 if (q->reading)
648 goto done; 648 goto done;
@@ -659,11 +659,11 @@ int videobuf_streamon(struct videobuf_queue *q)
659 spin_unlock_irqrestore(q->irqlock, flags); 659 spin_unlock_irqrestore(q->irqlock, flags);
660 660
661 done: 661 done:
662 mutex_unlock(&q->lock); 662 mutex_unlock(&q->vb_lock);
663 return retval; 663 return retval;
664} 664}
665 665
666/* Locking: Caller holds q->lock */ 666/* Locking: Caller holds q->vb_lock */
667static int __videobuf_streamoff(struct videobuf_queue *q) 667static int __videobuf_streamoff(struct videobuf_queue *q)
668{ 668{
669 if (!q->streaming) 669 if (!q->streaming)
@@ -679,14 +679,14 @@ int videobuf_streamoff(struct videobuf_queue *q)
679{ 679{
680 int retval; 680 int retval;
681 681
682 mutex_lock(&q->lock); 682 mutex_lock(&q->vb_lock);
683 retval = __videobuf_streamoff(q); 683 retval = __videobuf_streamoff(q);
684 mutex_unlock(&q->lock); 684 mutex_unlock(&q->vb_lock);
685 685
686 return retval; 686 return retval;
687} 687}
688 688
689/* Locking: Caller holds q->lock */ 689/* Locking: Caller holds q->vb_lock */
690static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, 690static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q,
691 char __user *data, 691 char __user *data,
692 size_t count, loff_t *ppos) 692 size_t count, loff_t *ppos)
@@ -745,7 +745,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
745 745
746 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 746 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
747 747
748 mutex_lock(&q->lock); 748 mutex_lock(&q->vb_lock);
749 749
750 nbufs = 1; size = 0; 750 nbufs = 1; size = 0;
751 q->ops->buf_setup(q, &nbufs, &size); 751 q->ops->buf_setup(q, &nbufs, &size);
@@ -817,11 +817,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
817 } 817 }
818 818
819 done: 819 done:
820 mutex_unlock(&q->lock); 820 mutex_unlock(&q->vb_lock);
821 return retval; 821 return retval;
822} 822}
823 823
824/* Locking: Caller holds q->lock */ 824/* Locking: Caller holds q->vb_lock */
825static int __videobuf_read_start(struct videobuf_queue *q) 825static int __videobuf_read_start(struct videobuf_queue *q)
826{ 826{
827 enum v4l2_field field; 827 enum v4l2_field field;
@@ -882,23 +882,23 @@ int videobuf_read_start(struct videobuf_queue *q)
882{ 882{
883 int rc; 883 int rc;
884 884
885 mutex_lock(&q->lock); 885 mutex_lock(&q->vb_lock);
886 rc = __videobuf_read_start(q); 886 rc = __videobuf_read_start(q);
887 mutex_unlock(&q->lock); 887 mutex_unlock(&q->vb_lock);
888 888
889 return rc; 889 return rc;
890} 890}
891 891
892void videobuf_read_stop(struct videobuf_queue *q) 892void videobuf_read_stop(struct videobuf_queue *q)
893{ 893{
894 mutex_lock(&q->lock); 894 mutex_lock(&q->vb_lock);
895 __videobuf_read_stop(q); 895 __videobuf_read_stop(q);
896 mutex_unlock(&q->lock); 896 mutex_unlock(&q->vb_lock);
897} 897}
898 898
899void videobuf_stop(struct videobuf_queue *q) 899void videobuf_stop(struct videobuf_queue *q)
900{ 900{
901 mutex_lock(&q->lock); 901 mutex_lock(&q->vb_lock);
902 902
903 if (q->streaming) 903 if (q->streaming)
904 __videobuf_streamoff(q); 904 __videobuf_streamoff(q);
@@ -906,7 +906,7 @@ void videobuf_stop(struct videobuf_queue *q)
906 if (q->reading) 906 if (q->reading)
907 __videobuf_read_stop(q); 907 __videobuf_read_stop(q);
908 908
909 mutex_unlock(&q->lock); 909 mutex_unlock(&q->vb_lock);
910} 910}
911 911
912 912
@@ -920,7 +920,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
920 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 920 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
921 921
922 dprintk(2, "%s\n", __FUNCTION__); 922 dprintk(2, "%s\n", __FUNCTION__);
923 mutex_lock(&q->lock); 923 mutex_lock(&q->vb_lock);
924 retval = -EBUSY; 924 retval = -EBUSY;
925 if (q->streaming) 925 if (q->streaming)
926 goto done; 926 goto done;
@@ -980,7 +980,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
980 } 980 }
981 981
982 done: 982 done:
983 mutex_unlock(&q->lock); 983 mutex_unlock(&q->vb_lock);
984 return retval; 984 return retval;
985} 985}
986 986
@@ -991,7 +991,7 @@ unsigned int videobuf_poll_stream(struct file *file,
991 struct videobuf_buffer *buf = NULL; 991 struct videobuf_buffer *buf = NULL;
992 unsigned int rc = 0; 992 unsigned int rc = 0;
993 993
994 mutex_lock(&q->lock); 994 mutex_lock(&q->vb_lock);
995 if (q->streaming) { 995 if (q->streaming) {
996 if (!list_empty(&q->stream)) 996 if (!list_empty(&q->stream))
997 buf = list_entry(q->stream.next, 997 buf = list_entry(q->stream.next,
@@ -1019,7 +1019,7 @@ unsigned int videobuf_poll_stream(struct file *file,
1019 buf->state == VIDEOBUF_ERROR) 1019 buf->state == VIDEOBUF_ERROR)
1020 rc = POLLIN|POLLRDNORM; 1020 rc = POLLIN|POLLRDNORM;
1021 } 1021 }
1022 mutex_unlock(&q->lock); 1022 mutex_unlock(&q->vb_lock);
1023 return rc; 1023 return rc;
1024} 1024}
1025 1025
@@ -1030,10 +1030,10 @@ int videobuf_mmap_mapper(struct videobuf_queue *q,
1030 1030
1031 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); 1031 MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
1032 1032
1033 mutex_lock(&q->lock); 1033 mutex_lock(&q->vb_lock);
1034 retval = CALL(q, mmap_mapper, q, vma); 1034 retval = CALL(q, mmap_mapper, q, vma);
1035 q->is_mmapped = 1; 1035 q->is_mmapped = 1;
1036 mutex_unlock(&q->lock); 1036 mutex_unlock(&q->vb_lock);
1037 1037
1038 return retval; 1038 return retval;
1039} 1039}
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
index 98efd7ab1f50..53fed4b74ce9 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -356,7 +356,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
356 map->count--; 356 map->count--;
357 if (0 == map->count) { 357 if (0 == map->count) {
358 dprintk(1,"munmap %p q=%p\n",map,q); 358 dprintk(1,"munmap %p q=%p\n",map,q);
359 mutex_lock(&q->lock); 359 mutex_lock(&q->vb_lock);
360 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 360 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
361 if (NULL == q->bufs[i]) 361 if (NULL == q->bufs[i])
362 continue; 362 continue;
@@ -373,7 +373,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
373 q->bufs[i]->baddr = 0; 373 q->bufs[i]->baddr = 0;
374 q->ops->buf_release(q,q->bufs[i]); 374 q->ops->buf_release(q,q->bufs[i]);
375 } 375 }
376 mutex_unlock(&q->lock); 376 mutex_unlock(&q->vb_lock);
377 kfree(map); 377 kfree(map);
378 } 378 }
379 return; 379 return;
diff --git a/drivers/media/video/videobuf-vmalloc.c b/drivers/media/video/videobuf-vmalloc.c
index 9b3898347ca5..5266ecc91dab 100644
--- a/drivers/media/video/videobuf-vmalloc.c
+++ b/drivers/media/video/videobuf-vmalloc.c
@@ -70,7 +70,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
70 map->count--; 70 map->count--;
71 if (0 == map->count) { 71 if (0 == map->count) {
72 dprintk(1,"munmap %p q=%p\n",map,q); 72 dprintk(1,"munmap %p q=%p\n",map,q);
73 mutex_lock(&q->lock); 73 mutex_lock(&q->vb_lock);
74 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 74 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
75 if (NULL == q->bufs[i]) 75 if (NULL == q->bufs[i])
76 continue; 76 continue;
@@ -83,7 +83,7 @@ videobuf_vm_close(struct vm_area_struct *vma)
83 q->bufs[i]->map = NULL; 83 q->bufs[i]->map = NULL;
84 q->bufs[i]->baddr = 0; 84 q->bufs[i]->baddr = 0;
85 } 85 }
86 mutex_unlock(&q->lock); 86 mutex_unlock(&q->vb_lock);
87 kfree(map); 87 kfree(map);
88 } 88 }
89 return; 89 return;
@@ -107,7 +107,7 @@ static struct vm_operations_struct videobuf_vm_ops =
107 107
108static void *__videobuf_alloc(size_t size) 108static void *__videobuf_alloc(size_t size)
109{ 109{
110 struct videbuf_vmalloc_memory *mem; 110 struct videobuf_vmalloc_memory *mem;
111 struct videobuf_buffer *vb; 111 struct videobuf_buffer *vb;
112 112
113 vb = kzalloc(size+sizeof(*mem),GFP_KERNEL); 113 vb = kzalloc(size+sizeof(*mem),GFP_KERNEL);
@@ -127,9 +127,7 @@ static int __videobuf_iolock (struct videobuf_queue* q,
127 struct v4l2_framebuffer *fbuf) 127 struct v4l2_framebuffer *fbuf)
128{ 128{
129 int pages; 129 int pages;
130 130 struct videobuf_vmalloc_memory *mem=vb->priv;
131 struct videbuf_vmalloc_memory *mem=vb->priv;
132
133 131
134 BUG_ON(!mem); 132 BUG_ON(!mem);
135 133
@@ -195,7 +193,7 @@ static int __videobuf_mmap_free(struct videobuf_queue *q)
195static int __videobuf_mmap_mapper(struct videobuf_queue *q, 193static int __videobuf_mmap_mapper(struct videobuf_queue *q,
196 struct vm_area_struct *vma) 194 struct vm_area_struct *vma)
197{ 195{
198 struct videbuf_vmalloc_memory *mem; 196 struct videobuf_vmalloc_memory *mem;
199 struct videobuf_mapping *map; 197 struct videobuf_mapping *map;
200 unsigned int first; 198 unsigned int first;
201 int retval; 199 int retval;
@@ -267,7 +265,7 @@ static int __videobuf_copy_to_user ( struct videobuf_queue *q,
267 char __user *data, size_t count, 265 char __user *data, size_t count,
268 int nonblocking ) 266 int nonblocking )
269{ 267{
270 struct videbuf_vmalloc_memory *mem=q->read_buf->priv; 268 struct videobuf_vmalloc_memory *mem=q->read_buf->priv;
271 BUG_ON (!mem); 269 BUG_ON (!mem);
272 MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); 270 MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM);
273 271
@@ -288,7 +286,7 @@ static int __videobuf_copy_stream ( struct videobuf_queue *q,
288 int vbihack, int nonblocking ) 286 int vbihack, int nonblocking )
289{ 287{
290 unsigned int *fc; 288 unsigned int *fc;
291 struct videbuf_vmalloc_memory *mem=q->read_buf->priv; 289 struct videobuf_vmalloc_memory *mem=q->read_buf->priv;
292 BUG_ON (!mem); 290 BUG_ON (!mem);
293 MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); 291 MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM);
294 292
@@ -341,7 +339,7 @@ EXPORT_SYMBOL_GPL(videobuf_queue_vmalloc_init);
341 339
342void *videobuf_to_vmalloc (struct videobuf_buffer *buf) 340void *videobuf_to_vmalloc (struct videobuf_buffer *buf)
343{ 341{
344 struct videbuf_vmalloc_memory *mem=buf->priv; 342 struct videobuf_vmalloc_memory *mem=buf->priv;
345 BUG_ON (!mem); 343 BUG_ON (!mem);
346 MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); 344 MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM);
347 345
@@ -351,7 +349,7 @@ EXPORT_SYMBOL_GPL(videobuf_to_vmalloc);
351 349
352void videobuf_vmalloc_free (struct videobuf_buffer *buf) 350void videobuf_vmalloc_free (struct videobuf_buffer *buf)
353{ 351{
354 struct videbuf_vmalloc_memory *mem=buf->priv; 352 struct videobuf_vmalloc_memory *mem=buf->priv;
355 BUG_ON (!mem); 353 BUG_ON (!mem);
356 354
357 MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); 355 MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM);
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 28655f8983c6..0d9b63762a48 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -46,10 +46,373 @@
46#include <linux/videodev.h> 46#include <linux/videodev.h>
47#endif 47#endif
48#include <media/v4l2-common.h> 48#include <media/v4l2-common.h>
49#include <linux/video_decoder.h>
49 50
50#define VIDEO_NUM_DEVICES 256 51#define VIDEO_NUM_DEVICES 256
51#define VIDEO_NAME "video4linux" 52#define VIDEO_NAME "video4linux"
52 53
54/* video4linux standard ID conversion to standard name
55 */
56char *v4l2_norm_to_name(v4l2_std_id id)
57{
58 char *name;
59 u32 myid = id;
60
61 /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
62 64 bit comparations. So, on that architecture, with some gcc
63 variants, compilation fails. Currently, the max value is 30bit wide.
64 */
65 BUG_ON(myid != id);
66
67 switch (myid) {
68 case V4L2_STD_PAL:
69 name = "PAL";
70 break;
71 case V4L2_STD_PAL_BG:
72 name = "PAL-BG";
73 break;
74 case V4L2_STD_PAL_DK:
75 name = "PAL-DK";
76 break;
77 case V4L2_STD_PAL_B:
78 name = "PAL-B";
79 break;
80 case V4L2_STD_PAL_B1:
81 name = "PAL-B1";
82 break;
83 case V4L2_STD_PAL_G:
84 name = "PAL-G";
85 break;
86 case V4L2_STD_PAL_H:
87 name = "PAL-H";
88 break;
89 case V4L2_STD_PAL_I:
90 name = "PAL-I";
91 break;
92 case V4L2_STD_PAL_D:
93 name = "PAL-D";
94 break;
95 case V4L2_STD_PAL_D1:
96 name = "PAL-D1";
97 break;
98 case V4L2_STD_PAL_K:
99 name = "PAL-K";
100 break;
101 case V4L2_STD_PAL_M:
102 name = "PAL-M";
103 break;
104 case V4L2_STD_PAL_N:
105 name = "PAL-N";
106 break;
107 case V4L2_STD_PAL_Nc:
108 name = "PAL-Nc";
109 break;
110 case V4L2_STD_PAL_60:
111 name = "PAL-60";
112 break;
113 case V4L2_STD_NTSC:
114 name = "NTSC";
115 break;
116 case V4L2_STD_NTSC_M:
117 name = "NTSC-M";
118 break;
119 case V4L2_STD_NTSC_M_JP:
120 name = "NTSC-M-JP";
121 break;
122 case V4L2_STD_NTSC_443:
123 name = "NTSC-443";
124 break;
125 case V4L2_STD_NTSC_M_KR:
126 name = "NTSC-M-KR";
127 break;
128 case V4L2_STD_SECAM:
129 name = "SECAM";
130 break;
131 case V4L2_STD_SECAM_DK:
132 name = "SECAM-DK";
133 break;
134 case V4L2_STD_SECAM_B:
135 name = "SECAM-B";
136 break;
137 case V4L2_STD_SECAM_D:
138 name = "SECAM-D";
139 break;
140 case V4L2_STD_SECAM_G:
141 name = "SECAM-G";
142 break;
143 case V4L2_STD_SECAM_H:
144 name = "SECAM-H";
145 break;
146 case V4L2_STD_SECAM_K:
147 name = "SECAM-K";
148 break;
149 case V4L2_STD_SECAM_K1:
150 name = "SECAM-K1";
151 break;
152 case V4L2_STD_SECAM_L:
153 name = "SECAM-L";
154 break;
155 case V4L2_STD_SECAM_LC:
156 name = "SECAM-LC";
157 break;
158 default:
159 name = "Unknown";
160 break;
161 }
162
163 return name;
164}
165EXPORT_SYMBOL(v4l2_norm_to_name);
166
167/* Fill in the fields of a v4l2_standard structure according to the
168 'id' and 'transmission' parameters. Returns negative on error. */
169int v4l2_video_std_construct(struct v4l2_standard *vs,
170 int id, char *name)
171{
172 u32 index = vs->index;
173
174 memset(vs, 0, sizeof(struct v4l2_standard));
175 vs->index = index;
176 vs->id = id;
177 if (id & V4L2_STD_525_60) {
178 vs->frameperiod.numerator = 1001;
179 vs->frameperiod.denominator = 30000;
180 vs->framelines = 525;
181 } else {
182 vs->frameperiod.numerator = 1;
183 vs->frameperiod.denominator = 25;
184 vs->framelines = 625;
185 }
186 strlcpy(vs->name, name, sizeof(vs->name));
187 return 0;
188}
189EXPORT_SYMBOL(v4l2_video_std_construct);
190
191/* ----------------------------------------------------------------- */
192/* some arrays for pretty-printing debug messages of enum types */
193
194char *v4l2_field_names[] = {
195 [V4L2_FIELD_ANY] = "any",
196 [V4L2_FIELD_NONE] = "none",
197 [V4L2_FIELD_TOP] = "top",
198 [V4L2_FIELD_BOTTOM] = "bottom",
199 [V4L2_FIELD_INTERLACED] = "interlaced",
200 [V4L2_FIELD_SEQ_TB] = "seq-tb",
201 [V4L2_FIELD_SEQ_BT] = "seq-bt",
202 [V4L2_FIELD_ALTERNATE] = "alternate",
203 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
204 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
205};
206EXPORT_SYMBOL(v4l2_field_names);
207
208char *v4l2_type_names[] = {
209 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap",
210 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over",
211 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out",
212 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
213 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
214 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap",
215 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
216 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over",
217};
218EXPORT_SYMBOL(v4l2_type_names);
219
220static char *v4l2_memory_names[] = {
221 [V4L2_MEMORY_MMAP] = "mmap",
222 [V4L2_MEMORY_USERPTR] = "userptr",
223 [V4L2_MEMORY_OVERLAY] = "overlay",
224};
225
226#define prt_names(a, arr) ((((a) >= 0) && ((a) < ARRAY_SIZE(arr))) ? \
227 arr[a] : "unknown")
228
229/* ------------------------------------------------------------------ */
230/* debug help functions */
231
232#ifdef CONFIG_VIDEO_V4L1_COMPAT
233static const char *v4l1_ioctls[] = {
234 [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP",
235 [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN",
236 [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN",
237 [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER",
238 [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER",
239 [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT",
240 [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT",
241 [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE",
242 [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN",
243 [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN",
244 [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF",
245 [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF",
246 [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY",
247 [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ",
248 [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ",
249 [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO",
250 [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO",
251 [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC",
252 [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE",
253 [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF",
254 [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT",
255 [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE",
256 [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE",
257 [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE",
258 [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE",
259 [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO",
260 [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE",
261 [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT",
262 [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT"
263};
264#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
265#endif
266
267static const char *v4l2_ioctls[] = {
268 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
269 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
270 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
271 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
272 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
273 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
274 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
275 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
276 [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
277 [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
278 [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
279 [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
280 [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
281 [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
282 [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
283 [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
284 [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
285 [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
286 [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
287 [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
288 [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
289 [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
290 [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
291 [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
292 [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
293 [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
294 [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
295 [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
296 [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
297 [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
298 [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
299 [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
300 [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
301 [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
302 [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
303 [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
304 [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
305 [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
306 [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
307 [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
308 [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
309 [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
310 [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
311 [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
312 [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
313 [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
314 [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO",
315 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT",
316 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY",
317 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY",
318 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP",
319 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS",
320 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS",
321 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS",
322 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS",
323#if 1
324 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES",
325 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS",
326 [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX",
327 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD",
328 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD",
329
330 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
331 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
332
333 [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT",
334#endif
335};
336#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
337
338static const char *v4l2_int_ioctls[] = {
339#ifdef CONFIG_VIDEO_V4L1_COMPAT
340 [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES",
341 [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS",
342 [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM",
343 [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT",
344 [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT",
345 [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT",
346 [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE",
347 [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO",
348 [_IOC_NR(DECODER_INIT)] = "DECODER_INIT",
349 [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS",
350 [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
351#endif
352 [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
353
354 [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
355 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
356 [_IOC_NR(TUNER_SET_CONFIG)] = "TUNER_SET_CONFIG",
357
358 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
359 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
360 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
361 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
362 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
363 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
364 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
365 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
366 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
367 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
368 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
369 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING",
370 [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ",
371 [_IOC_NR(VIDIOC_INT_INIT)] = "VIDIOC_INT_INIT",
372 [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)] = "VIDIOC_INT_G_STD_OUTPUT",
373 [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)] = "VIDIOC_INT_S_STD_OUTPUT",
374};
375#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
376
377/* Common ioctl debug function. This function can be used by
378 external ioctl messages as well as internal V4L ioctl */
379void v4l_printk_ioctl(unsigned int cmd)
380{
381 char *dir;
382
383 switch (_IOC_DIR(cmd)) {
384 case _IOC_NONE: dir = "--"; break;
385 case _IOC_READ: dir = "r-"; break;
386 case _IOC_WRITE: dir = "-w"; break;
387 case _IOC_READ | _IOC_WRITE: dir = "rw"; break;
388 default: dir = "*ERR*"; break;
389 }
390 switch (_IOC_TYPE(cmd)) {
391 case 'd':
392 printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n",
393 (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ?
394 v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
395 break;
396#ifdef CONFIG_VIDEO_V4L1_COMPAT
397 case 'v':
398 printk("v4l1 ioctl %s, dir=%s (0x%08x)\n",
399 (_IOC_NR(cmd) < V4L1_IOCTLS) ?
400 v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
401 break;
402#endif
403 case 'V':
404 printk("v4l2 ioctl %s, dir=%s (0x%08x)\n",
405 (_IOC_NR(cmd) < V4L2_IOCTLS) ?
406 v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd);
407 break;
408
409 default:
410 printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n",
411 _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd);
412 }
413}
414EXPORT_SYMBOL(v4l_printk_ioctl);
415
53/* 416/*
54 * sysfs stuff 417 * sysfs stuff
55 */ 418 */
@@ -69,11 +432,13 @@ struct video_device *video_device_alloc(void)
69 vfd = kzalloc(sizeof(*vfd),GFP_KERNEL); 432 vfd = kzalloc(sizeof(*vfd),GFP_KERNEL);
70 return vfd; 433 return vfd;
71} 434}
435EXPORT_SYMBOL(video_device_alloc);
72 436
73void video_device_release(struct video_device *vfd) 437void video_device_release(struct video_device *vfd)
74{ 438{
75 kfree(vfd); 439 kfree(vfd);
76} 440}
441EXPORT_SYMBOL(video_device_release);
77 442
78static void video_release(struct device *cd) 443static void video_release(struct device *cd)
79{ 444{
@@ -110,6 +475,7 @@ struct video_device* video_devdata(struct file *file)
110{ 475{
111 return video_device[iminor(file->f_path.dentry->d_inode)]; 476 return video_device[iminor(file->f_path.dentry->d_inode)];
112} 477}
478EXPORT_SYMBOL(video_devdata);
113 479
114/* 480/*
115 * Open a video device - FIXME: Obsoleted 481 * Open a video device - FIXME: Obsoleted
@@ -278,6 +644,7 @@ out:
278 kfree(mbuf); 644 kfree(mbuf);
279 return err; 645 return err;
280} 646}
647EXPORT_SYMBOL(video_usercopy);
281 648
282/* 649/*
283 * open/release helper functions -- handle exclusive opens 650 * open/release helper functions -- handle exclusive opens
@@ -297,6 +664,7 @@ int video_exclusive_open(struct inode *inode, struct file *file)
297 mutex_unlock(&vfl->lock); 664 mutex_unlock(&vfl->lock);
298 return retval; 665 return retval;
299} 666}
667EXPORT_SYMBOL(video_exclusive_open);
300 668
301int video_exclusive_release(struct inode *inode, struct file *file) 669int video_exclusive_release(struct inode *inode, struct file *file)
302{ 670{
@@ -305,41 +673,7 @@ int video_exclusive_release(struct inode *inode, struct file *file)
305 vfl->users--; 673 vfl->users--;
306 return 0; 674 return 0;
307} 675}
308 676EXPORT_SYMBOL(video_exclusive_release);
309static char *v4l2_memory_names[] = {
310 [V4L2_MEMORY_MMAP] = "mmap",
311 [V4L2_MEMORY_USERPTR] = "userptr",
312 [V4L2_MEMORY_OVERLAY] = "overlay",
313};
314
315
316/* FIXME: Those stuff are replicated also on v4l2-common.c */
317static char *v4l2_type_names_FIXME[] = {
318 [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap",
319 [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over",
320 [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out",
321 [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
322 [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
323 [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
324 [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-capture",
325 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "video-out-over",
326 [V4L2_BUF_TYPE_PRIVATE] = "private",
327};
328
329static char *v4l2_field_names_FIXME[] = {
330 [V4L2_FIELD_ANY] = "any",
331 [V4L2_FIELD_NONE] = "none",
332 [V4L2_FIELD_TOP] = "top",
333 [V4L2_FIELD_BOTTOM] = "bottom",
334 [V4L2_FIELD_INTERLACED] = "interlaced",
335 [V4L2_FIELD_SEQ_TB] = "seq-tb",
336 [V4L2_FIELD_SEQ_BT] = "seq-bt",
337 [V4L2_FIELD_ALTERNATE] = "alternate",
338 [V4L2_FIELD_INTERLACED_TB] = "interlaced-tb",
339 [V4L2_FIELD_INTERLACED_BT] = "interlaced-bt",
340};
341
342#define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown"
343 677
344static void dbgbuf(unsigned int cmd, struct video_device *vfd, 678static void dbgbuf(unsigned int cmd, struct video_device *vfd,
345 struct v4l2_buffer *p) 679 struct v4l2_buffer *p)
@@ -354,10 +688,10 @@ static void dbgbuf(unsigned int cmd, struct video_device *vfd,
354 (int)(p->timestamp.tv_sec%60), 688 (int)(p->timestamp.tv_sec%60),
355 p->timestamp.tv_usec, 689 p->timestamp.tv_usec,
356 p->index, 690 p->index,
357 prt_names(p->type,v4l2_type_names_FIXME), 691 prt_names(p->type, v4l2_type_names),
358 p->bytesused,p->flags, 692 p->bytesused, p->flags,
359 p->field,p->sequence, 693 p->field, p->sequence,
360 prt_names(p->memory,v4l2_memory_names), 694 prt_names(p->memory, v4l2_memory_names),
361 p->m.userptr, p->length); 695 p->m.userptr, p->length);
362 dbgarg2 ("timecode= %02d:%02d:%02d type=%d, " 696 dbgarg2 ("timecode= %02d:%02d:%02d type=%d, "
363 "flags=0x%08d, frames=%d, userbits=0x%08x\n", 697 "flags=0x%08d, frames=%d, userbits=0x%08x\n",
@@ -382,8 +716,8 @@ static inline void v4l_print_pix_fmt (struct video_device *vfd,
382 (fmt->pixelformat >> 8) & 0xff, 716 (fmt->pixelformat >> 8) & 0xff,
383 (fmt->pixelformat >> 16) & 0xff, 717 (fmt->pixelformat >> 16) & 0xff,
384 (fmt->pixelformat >> 24) & 0xff, 718 (fmt->pixelformat >> 24) & 0xff,
385 prt_names(fmt->field,v4l2_field_names_FIXME), 719 prt_names(fmt->field, v4l2_field_names),
386 fmt->bytesperline,fmt->sizeimage,fmt->colorspace); 720 fmt->bytesperline, fmt->sizeimage, fmt->colorspace);
387}; 721};
388 722
389 723
@@ -597,7 +931,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
597 931
598 /* FIXME: Should be one dump per type */ 932 /* FIXME: Should be one dump per type */
599 dbgarg (cmd, "type=%s\n", prt_names(type, 933 dbgarg (cmd, "type=%s\n", prt_names(type,
600 v4l2_type_names_FIXME)); 934 v4l2_type_names));
601 935
602 switch (type) { 936 switch (type) {
603 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 937 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -650,7 +984,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
650 984
651 /* FIXME: Should be one dump per type */ 985 /* FIXME: Should be one dump per type */
652 dbgarg (cmd, "type=%s\n", prt_names(f->type, 986 dbgarg (cmd, "type=%s\n", prt_names(f->type,
653 v4l2_type_names_FIXME)); 987 v4l2_type_names));
654 988
655 switch (f->type) { 989 switch (f->type) {
656 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 990 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -702,7 +1036,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
702 1036
703 /* FIXME: Should be one dump per type */ 1037 /* FIXME: Should be one dump per type */
704 dbgarg (cmd, "type=%s\n", prt_names(f->type, 1038 dbgarg (cmd, "type=%s\n", prt_names(f->type,
705 v4l2_type_names_FIXME)); 1039 v4l2_type_names));
706 switch (f->type) { 1040 switch (f->type) {
707 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1041 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
708 if (vfd->vidioc_try_fmt_cap) 1042 if (vfd->vidioc_try_fmt_cap)
@@ -768,8 +1102,8 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
768 ret=vfd->vidioc_reqbufs(file, fh, p); 1102 ret=vfd->vidioc_reqbufs(file, fh, p);
769 dbgarg (cmd, "count=%d, type=%s, memory=%s\n", 1103 dbgarg (cmd, "count=%d, type=%s, memory=%s\n",
770 p->count, 1104 p->count,
771 prt_names(p->type,v4l2_type_names_FIXME), 1105 prt_names(p->type, v4l2_type_names),
772 prt_names(p->memory,v4l2_memory_names)); 1106 prt_names(p->memory, v4l2_memory_names));
773 break; 1107 break;
774 } 1108 }
775 case VIDIOC_QUERYBUF: 1109 case VIDIOC_QUERYBUF:
@@ -858,7 +1192,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
858 enum v4l2_buf_type i = *(int *)arg; 1192 enum v4l2_buf_type i = *(int *)arg;
859 if (!vfd->vidioc_streamon) 1193 if (!vfd->vidioc_streamon)
860 break; 1194 break;
861 dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME)); 1195 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
862 ret=vfd->vidioc_streamon(file, fh,i); 1196 ret=vfd->vidioc_streamon(file, fh,i);
863 break; 1197 break;
864 } 1198 }
@@ -868,7 +1202,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
868 1202
869 if (!vfd->vidioc_streamoff) 1203 if (!vfd->vidioc_streamoff)
870 break; 1204 break;
871 dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME)); 1205 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
872 ret=vfd->vidioc_streamoff(file, fh, i); 1206 ret=vfd->vidioc_streamoff(file, fh, i);
873 break; 1207 break;
874 } 1208 }
@@ -1624,7 +1958,7 @@ out:
1624 kfree(mbuf); 1958 kfree(mbuf);
1625 return err; 1959 return err;
1626} 1960}
1627 1961EXPORT_SYMBOL(video_ioctl2);
1628 1962
1629static const struct file_operations video_fops; 1963static const struct file_operations video_fops;
1630 1964
@@ -1743,6 +2077,7 @@ fail_minor:
1743 mutex_unlock(&videodev_lock); 2077 mutex_unlock(&videodev_lock);
1744 return ret; 2078 return ret;
1745} 2079}
2080EXPORT_SYMBOL(video_register_device);
1746 2081
1747/** 2082/**
1748 * video_unregister_device - unregister a video4linux device 2083 * video_unregister_device - unregister a video4linux device
@@ -1762,6 +2097,7 @@ void video_unregister_device(struct video_device *vfd)
1762 device_unregister(&vfd->class_dev); 2097 device_unregister(&vfd->class_dev);
1763 mutex_unlock(&videodev_lock); 2098 mutex_unlock(&videodev_lock);
1764} 2099}
2100EXPORT_SYMBOL(video_unregister_device);
1765 2101
1766/* 2102/*
1767 * Video fs operations 2103 * Video fs operations
@@ -1806,16 +2142,6 @@ static void __exit videodev_exit(void)
1806module_init(videodev_init) 2142module_init(videodev_init)
1807module_exit(videodev_exit) 2143module_exit(videodev_exit)
1808 2144
1809EXPORT_SYMBOL(video_register_device);
1810EXPORT_SYMBOL(video_unregister_device);
1811EXPORT_SYMBOL(video_devdata);
1812EXPORT_SYMBOL(video_usercopy);
1813EXPORT_SYMBOL(video_exclusive_open);
1814EXPORT_SYMBOL(video_exclusive_release);
1815EXPORT_SYMBOL(video_ioctl2);
1816EXPORT_SYMBOL(video_device_alloc);
1817EXPORT_SYMBOL(video_device_release);
1818
1819MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>"); 2145MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>");
1820MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2"); 2146MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2");
1821MODULE_LICENSE("GPL"); 2147MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
index 937c4a616c0e..498a43c1f2b1 100644
--- a/drivers/media/video/zoran.h
+++ b/drivers/media/video/zoran.h
@@ -221,15 +221,15 @@ enum zoran_map_mode {
221}; 221};
222 222
223enum gpio_type { 223enum gpio_type {
224 GPIO_JPEG_SLEEP = 0, 224 ZR_GPIO_JPEG_SLEEP = 0,
225 GPIO_JPEG_RESET, 225 ZR_GPIO_JPEG_RESET,
226 GPIO_JPEG_FRAME, 226 ZR_GPIO_JPEG_FRAME,
227 GPIO_VID_DIR, 227 ZR_GPIO_VID_DIR,
228 GPIO_VID_EN, 228 ZR_GPIO_VID_EN,
229 GPIO_VID_RESET, 229 ZR_GPIO_VID_RESET,
230 GPIO_CLK_SEL1, 230 ZR_GPIO_CLK_SEL1,
231 GPIO_CLK_SEL2, 231 ZR_GPIO_CLK_SEL2,
232 GPIO_MAX, 232 ZR_GPIO_MAX,
233}; 233};
234 234
235enum gpcs_type { 235enum gpcs_type {
@@ -378,11 +378,11 @@ struct card_info {
378 378
379 u32 jpeg_int; /* JPEG interrupt */ 379 u32 jpeg_int; /* JPEG interrupt */
380 u32 vsync_int; /* VSYNC interrupt */ 380 u32 vsync_int; /* VSYNC interrupt */
381 s8 gpio[GPIO_MAX]; 381 s8 gpio[ZR_GPIO_MAX];
382 u8 gpcs[GPCS_MAX]; 382 u8 gpcs[GPCS_MAX];
383 383
384 struct vfe_polarity vfe_pol; 384 struct vfe_polarity vfe_pol;
385 u8 gpio_pol[GPIO_MAX]; 385 u8 gpio_pol[ZR_GPIO_MAX];
386 386
387 /* is the /GWS line conected? */ 387 /* is the /GWS line conected? */
388 u8 gws_not_connected; 388 u8 gws_not_connected;
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index 68c7c505587e..f97c20692057 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -250,7 +250,7 @@ void
250jpeg_codec_sleep (struct zoran *zr, 250jpeg_codec_sleep (struct zoran *zr,
251 int sleep) 251 int sleep)
252{ 252{
253 GPIO(zr, zr->card.gpio[GPIO_JPEG_SLEEP], !sleep); 253 GPIO(zr, zr->card.gpio[ZR_GPIO_JPEG_SLEEP], !sleep);
254 if (!sleep) { 254 if (!sleep) {
255 dprintk(3, 255 dprintk(3,
256 KERN_DEBUG 256 KERN_DEBUG
@@ -277,9 +277,9 @@ jpeg_codec_reset (struct zoran *zr)
277 0); 277 0);
278 udelay(2); 278 udelay(2);
279 } else { 279 } else {
280 GPIO(zr, zr->card.gpio[GPIO_JPEG_RESET], 0); 280 GPIO(zr, zr->card.gpio[ZR_GPIO_JPEG_RESET], 0);
281 udelay(2); 281 udelay(2);
282 GPIO(zr, zr->card.gpio[GPIO_JPEG_RESET], 1); 282 GPIO(zr, zr->card.gpio[ZR_GPIO_JPEG_RESET], 1);
283 udelay(2); 283 udelay(2);
284 } 284 }
285 285
@@ -688,7 +688,7 @@ static inline void
688set_frame (struct zoran *zr, 688set_frame (struct zoran *zr,
689 int val) 689 int val)
690{ 690{
691 GPIO(zr, zr->card.gpio[GPIO_JPEG_FRAME], val); 691 GPIO(zr, zr->card.gpio[ZR_GPIO_JPEG_FRAME], val);
692} 692}
693 693
694static void 694static void
@@ -704,8 +704,8 @@ set_videobus_dir (struct zoran *zr,
704 GPIO(zr, 5, 1); 704 GPIO(zr, 5, 1);
705 break; 705 break;
706 default: 706 default:
707 GPIO(zr, zr->card.gpio[GPIO_VID_DIR], 707 GPIO(zr, zr->card.gpio[ZR_GPIO_VID_DIR],
708 zr->card.gpio_pol[GPIO_VID_DIR] ? !val : val); 708 zr->card.gpio_pol[ZR_GPIO_VID_DIR] ? !val : val);
709 break; 709 break;
710 } 710 }
711} 711}
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index 1fdbb46de7f3..1b44784d0efb 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -93,6 +93,8 @@ static struct usb_device_id device_table[] = {
93 {USB_DEVICE(0x06d6, 0x0034), .driver_info = METHOD0 }, 93 {USB_DEVICE(0x06d6, 0x0034), .driver_info = METHOD0 },
94 {USB_DEVICE(0x0a17, 0x0062), .driver_info = METHOD2 }, 94 {USB_DEVICE(0x0a17, 0x0062), .driver_info = METHOD2 },
95 {USB_DEVICE(0x06d6, 0x003b), .driver_info = METHOD0 }, 95 {USB_DEVICE(0x06d6, 0x003b), .driver_info = METHOD0 },
96 {USB_DEVICE(0x0a17, 0x004e), .driver_info = METHOD2 },
97 {USB_DEVICE(0x041e, 0x405d), .driver_info = METHOD2 },
96 {} /* Terminating entry */ 98 {} /* Terminating entry */
97}; 99};
98 100