diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 09:36:07 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 09:36:07 -0300 |
commit | 7abbab1a9801ad11729cc746653a909972548502 (patch) | |
tree | 232a3bbdbf4c48b602848b9b0031b79e734fc599 /linux/drivers/media/video | |
parent | ec810366b1dc73c6e1e9251b2bf21135e42d9fc7 (diff) | |
parent | 619f91291de90dbff3aaafdf29a3886757eda34f (diff) | |
download | mediapointer-dvb-s2-7abbab1a9801ad11729cc746653a909972548502.tar.gz mediapointer-dvb-s2-7abbab1a9801ad11729cc746653a909972548502.tar.bz2 |
merge: http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-videodev2
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video')
58 files changed, 819 insertions, 778 deletions
diff --git a/linux/drivers/media/video/Makefile b/linux/drivers/media/video/Makefile index 00e2df8a4..a0240a105 100644 --- a/linux/drivers/media/video/Makefile +++ b/linux/drivers/media/video/Makefile @@ -10,6 +10,8 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o stkwebcam-objs := stk-webcam.o stk-sensor.o +videodev-objs := v4l2-dev.o v4l2-ioctl.o + obj-$(CONFIG_VIDEO_DEV) += videodev.o compat_ioctl32.o v4l2-int-device.o obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o diff --git a/linux/drivers/media/video/bt8xx/bttv-driver.c b/linux/drivers/media/video/bt8xx/bttv-driver.c index 9877a7124..17fa68233 100644 --- a/linux/drivers/media/video/bt8xx/bttv-driver.c +++ b/linux/drivers/media/video/bt8xx/bttv-driver.c @@ -45,6 +45,7 @@ #include <linux/kdev_t.h> #include "bttvp.h" #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/tvaudio.h> #include <media/msp3400.h> @@ -163,8 +164,8 @@ MODULE_LICENSE("GPL"); static ssize_t show_card(struct device *cd, struct device_attribute *attr, char *buf) { - struct video_device *vfd = container_of(cd, struct video_device, class_dev); - struct bttv *btv = dev_get_drvdata(vfd->dev); + struct video_device *vfd = container_of(cd, struct video_device, dev); + struct bttv *btv = dev_get_drvdata(vfd->parent); return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); } static DEVICE_ATTR(card, S_IRUGO, show_card, NULL); @@ -4209,7 +4210,7 @@ static struct video_device *vdev_init(struct bttv *btv, return NULL; *vfd = *template; vfd->minor = -1; - vfd->dev = &btv->c.pci->dev; + vfd->parent = &btv->c.pci->dev; vfd->release = video_device_release; vfd->type = type; vfd->debug = bttv_debug; @@ -4268,7 +4269,7 @@ static int __devinit bttv_register_video(struct bttv *btv) goto err; printk(KERN_INFO "bttv%d: registered device video%d\n", btv->c.nr,btv->video_dev->minor & 0x1f); - if (device_create_file(&btv->video_dev->class_dev, + if (device_create_file(&btv->video_dev->dev, &dev_attr_card)<0) { printk(KERN_ERR "bttv%d: device_create_file 'card' " "failed\n", btv->c.nr); diff --git a/linux/drivers/media/video/bt8xx/bttv-risc.c b/linux/drivers/media/video/bt8xx/bttv-risc.c index a8c98e52c..0cffd3a72 100644 --- a/linux/drivers/media/video/bt8xx/bttv-risc.c +++ b/linux/drivers/media/video/bt8xx/bttv-risc.c @@ -31,6 +31,7 @@ #include <linux/interrupt.h> #include <asm/page.h> #include <asm/pgtable.h> +#include <media/v4l2-ioctl.h> #include "bttvp.h" diff --git a/linux/drivers/media/video/bt8xx/bttv-vbi.c b/linux/drivers/media/video/bt8xx/bttv-vbi.c index 68f28e5fa..6819e21a3 100644 --- a/linux/drivers/media/video/bt8xx/bttv-vbi.c +++ b/linux/drivers/media/video/bt8xx/bttv-vbi.c @@ -29,6 +29,7 @@ #include <linux/kernel.h> #include <linux/interrupt.h> #include <linux/kdev_t.h> +#include <media/v4l2-ioctl.h> #include <asm/io.h> #include "bttvp.h" diff --git a/linux/drivers/media/video/bw-qcam.c b/linux/drivers/media/video/bw-qcam.c index e587fb332..cc247d6bb 100644 --- a/linux/drivers/media/video/bw-qcam.c +++ b/linux/drivers/media/video/bw-qcam.c @@ -75,6 +75,7 @@ OTHER DEALINGS IN THE SOFTWARE. #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/mutex.h> #include <asm/uaccess.h> diff --git a/linux/drivers/media/video/c-qcam.c b/linux/drivers/media/video/c-qcam.c index 0755931e7..3824c8601 100644 --- a/linux/drivers/media/video/c-qcam.c +++ b/linux/drivers/media/video/c-qcam.c @@ -36,6 +36,7 @@ #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/mutex.h> #include <linux/jiffies.h> diff --git a/linux/drivers/media/video/cafe_ccic.c b/linux/drivers/media/video/cafe_ccic.c index b75c151cc..075d57031 100644 --- a/linux/drivers/media/video/cafe_ccic.c +++ b/linux/drivers/media/video/cafe_ccic.c @@ -26,6 +26,7 @@ #include <linux/videodev2.h> #include "compat.h" #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/v4l2-chip-ident.h> #include <linux/device.h> #include <linux/wait.h> @@ -2164,7 +2165,7 @@ static int cafe_pci_probe(struct pci_dev *pdev, cam->v4ldev = cafe_v4l_template; cam->v4ldev.debug = 0; // cam->v4ldev.debug = V4L2_DEBUG_IOCTL_ARG; - cam->v4ldev.dev = &pdev->dev; + cam->v4ldev.parent = &pdev->dev; ret = video_register_device(&cam->v4ldev, VFL_TYPE_GRABBER, -1); if (ret) goto out_smbus; diff --git a/linux/drivers/media/video/cpia.h b/linux/drivers/media/video/cpia.h index f90857a39..3a6f79420 100644 --- a/linux/drivers/media/video/cpia.h +++ b/linux/drivers/media/video/cpia.h @@ -46,6 +46,7 @@ #include <asm/uaccess.h> #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/list.h> #include <linux/mutex.h> #include "compat.h" diff --git a/linux/drivers/media/video/cpia2/cpia2_v4l.c b/linux/drivers/media/video/cpia2/cpia2_v4l.c index 7ce2789fa..8817c3841 100644 --- a/linux/drivers/media/video/cpia2/cpia2_v4l.c +++ b/linux/drivers/media/video/cpia2/cpia2_v4l.c @@ -37,6 +37,7 @@ #include <linux/sched.h> #include <linux/slab.h> #include <linux/init.h> +#include <media/v4l2-ioctl.h> #include "cpia2.h" #include "cpia2dev.h" diff --git a/linux/drivers/media/video/cx18/cx18-driver.h b/linux/drivers/media/video/cx18/cx18-driver.h index 45e31b047..4801bc7fb 100644 --- a/linux/drivers/media/video/cx18/cx18-driver.h +++ b/linux/drivers/media/video/cx18/cx18-driver.h @@ -46,6 +46,7 @@ #include <linux/dvb/video.h> #include <linux/dvb/audio.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/tuner.h> #include "cx18-mailbox.h" #include "cx18-av-core.h" diff --git a/linux/drivers/media/video/cx18/cx18-streams.c b/linux/drivers/media/video/cx18/cx18-streams.c index a4886bc6c..3eedae726 100644 --- a/linux/drivers/media/video/cx18/cx18-streams.c +++ b/linux/drivers/media/video/cx18/cx18-streams.c @@ -194,7 +194,7 @@ static int cx18_prep_dev(struct cx18 *cx, int type) cx->num); s->v4l2dev->minor = minor; - s->v4l2dev->dev = &cx->dev->dev; + s->v4l2dev->parent = &cx->dev->dev; s->v4l2dev->fops = cx18_stream_info[type].fops; s->v4l2dev->release = video_device_release; s->v4l2dev->tvnorms = V4L2_STD_ALL; diff --git a/linux/drivers/media/video/cx23885/cx23885-417.c b/linux/drivers/media/video/cx23885/cx23885-417.c index ff1abdb0f..3c3563f73 100644 --- a/linux/drivers/media/video/cx23885/cx23885-417.c +++ b/linux/drivers/media/video/cx23885/cx23885-417.c @@ -32,6 +32,7 @@ #include <linux/device.h> #include <linux/firmware.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/cx2341x.h> #include "cx23885.h" @@ -1774,7 +1775,7 @@ static struct video_device *cx23885_video_dev_alloc( vfd->minor = -1; snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, cx23885_boards[tsport->dev->board].name); - vfd->dev = &pci->dev; + vfd->parent = &pci->dev; vfd->release = video_device_release; return vfd; } diff --git a/linux/drivers/media/video/cx23885/cx23885-video.c b/linux/drivers/media/video/cx23885/cx23885-video.c index 6d0345935..b3d0902e1 100644 --- a/linux/drivers/media/video/cx23885/cx23885-video.c +++ b/linux/drivers/media/video/cx23885/cx23885-video.c @@ -34,6 +34,7 @@ #include "cx23885.h" #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #ifdef CONFIG_VIDEO_V4L1_COMPAT /* Include V4L1 specific functions. Should be removed soon */ @@ -361,7 +362,7 @@ struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, return NULL; *vfd = *template; vfd->minor = -1; - vfd->dev = &pci->dev; + vfd->parent = &pci->dev; vfd->release = video_device_release; snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, cx23885_boards[dev->board].name); diff --git a/linux/drivers/media/video/cx88/cx88-blackbird.c b/linux/drivers/media/video/cx88/cx88-blackbird.c index 83638557d..4b780c237 100644 --- a/linux/drivers/media/video/cx88/cx88-blackbird.c +++ b/linux/drivers/media/video/cx88/cx88-blackbird.c @@ -33,6 +33,7 @@ #include <linux/device.h> #include <linux/firmware.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/cx2341x.h> #include "cx88.h" diff --git a/linux/drivers/media/video/cx88/cx88-core.c b/linux/drivers/media/video/cx88/cx88-core.c index a63915bdf..4ce5f7589 100644 --- a/linux/drivers/media/video/cx88/cx88-core.c +++ b/linux/drivers/media/video/cx88/cx88-core.c @@ -41,6 +41,7 @@ #include "cx88.h" #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); @@ -1035,7 +1036,7 @@ struct video_device *cx88_vdev_init(struct cx88_core *core, return NULL; *vfd = *template; vfd->minor = -1; - vfd->dev = &pci->dev; + vfd->parent = &pci->dev; vfd->release = video_device_release; snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", core->name, type, core->board.name); diff --git a/linux/drivers/media/video/cx88/cx88-video.c b/linux/drivers/media/video/cx88/cx88-video.c index 63521066d..f26232345 100644 --- a/linux/drivers/media/video/cx88/cx88-video.c +++ b/linux/drivers/media/video/cx88/cx88-video.c @@ -40,6 +40,7 @@ #include "cx88.h" #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #ifdef CONFIG_VIDEO_V4L1_COMPAT /* Include V4L1 specific functions. Should be removed soon */ diff --git a/linux/drivers/media/video/em28xx/em28xx-video.c b/linux/drivers/media/video/em28xx/em28xx-video.c index 4f7a51e66..c456f9945 100644 --- a/linux/drivers/media/video/em28xx/em28xx-video.c +++ b/linux/drivers/media/video/em28xx/em28xx-video.c @@ -38,6 +38,7 @@ #include "em28xx.h" #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/msp3400.h> #include <media/tuner.h> @@ -1954,7 +1955,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, return NULL; *vfd = *template; vfd->minor = -1; - vfd->dev = &dev->udev->dev; + vfd->parent = &dev->udev->dev; vfd->release = video_device_release; vfd->type = type; vfd->debug = video_debug; diff --git a/linux/drivers/media/video/et61x251/et61x251_core.c b/linux/drivers/media/video/et61x251/et61x251_core.c index 4d08f0225..0711a34fb 100644 --- a/linux/drivers/media/video/et61x251/et61x251_core.c +++ b/linux/drivers/media/video/et61x251/et61x251_core.c @@ -34,6 +34,7 @@ #include <linux/mm.h> #include <linux/vmalloc.h> #include <linux/page-flags.h> +#include <media/v4l2-ioctl.h> #include <asm/byteorder.h> #include <asm/page.h> #include <asm/uaccess.h> @@ -989,7 +990,7 @@ static DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, static int et61x251_create_sysfs(struct et61x251_device* cam) { - struct device *classdev = &(cam->v4ldev->class_dev); + struct device *classdev = &(cam->v4ldev->dev); int err = 0; if ((err = device_create_file(classdev, &dev_attr_reg))) diff --git a/linux/drivers/media/video/gspca/gspca.c b/linux/drivers/media/video/gspca/gspca.c index 697202d47..8ba3b6b52 100644 --- a/linux/drivers/media/video/gspca/gspca.c +++ b/linux/drivers/media/video/gspca/gspca.c @@ -36,6 +36,7 @@ #include <linux/uaccess.h> #endif #include <linux/jiffies.h> +#include <media/v4l2-ioctl.h> #include "gspca.h" @@ -1747,7 +1748,7 @@ int gspca_dev_probe(struct usb_interface *intf, /* init video stuff */ memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template); - gspca_dev->vdev.dev = &dev->dev; + gspca_dev->vdev.parent = &dev->dev; memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops); gspca_dev->vdev.fops = &gspca_dev->fops; gspca_dev->fops.owner = module; /* module protection */ diff --git a/linux/drivers/media/video/ivtv/ivtv-driver.h b/linux/drivers/media/video/ivtv/ivtv-driver.h index 7bae21e5b..d66ee14b6 100644 --- a/linux/drivers/media/video/ivtv/ivtv-driver.h +++ b/linux/drivers/media/video/ivtv/ivtv-driver.h @@ -61,6 +61,7 @@ #include <linux/dvb/video.h> #include <linux/dvb/audio.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/tuner.h> #include <media/cx2341x.h> diff --git a/linux/drivers/media/video/ivtv/ivtv-streams.c b/linux/drivers/media/video/ivtv/ivtv-streams.c index f8883b487..b883c4e08 100644 --- a/linux/drivers/media/video/ivtv/ivtv-streams.c +++ b/linux/drivers/media/video/ivtv/ivtv-streams.c @@ -217,7 +217,7 @@ static int ivtv_prep_dev(struct ivtv *itv, int type) itv->num, s->name); s->v4l2dev->minor = minor; - s->v4l2dev->dev = &itv->dev->dev; + s->v4l2dev->parent = &itv->dev->dev; s->v4l2dev->fops = ivtv_stream_info[type].fops; s->v4l2dev->release = video_device_release; s->v4l2dev->tvnorms = V4L2_STD_ALL; diff --git a/linux/drivers/media/video/meye.c b/linux/drivers/media/video/meye.c index 07295afff..4ae76d0b0 100644 --- a/linux/drivers/media/video/meye.c +++ b/linux/drivers/media/video/meye.c @@ -32,6 +32,7 @@ #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <asm/uaccess.h> #include <asm/io.h> #include <linux/delay.h> @@ -1806,7 +1807,7 @@ static int __devinit meye_probe(struct pci_dev *pcidev, } memcpy(meye.video_dev, &meye_template, sizeof(meye_template)); - meye.video_dev->dev = &meye.mchip_dev->dev; + meye.video_dev->parent = &meye.mchip_dev->dev; if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) { printk(KERN_ERR "meye: unable to power on the camera\n"); diff --git a/linux/drivers/media/video/msp3400-driver.c b/linux/drivers/media/video/msp3400-driver.c index cd92f1f68..d67af9753 100644 --- a/linux/drivers/media/video/msp3400-driver.c +++ b/linux/drivers/media/video/msp3400-driver.c @@ -54,6 +54,7 @@ #include <linux/videodev.h> #include <linux/videodev2.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/v4l2-i2c-drv-legacy.h> #include <media/tvaudio.h> #include <media/msp3400.h> diff --git a/linux/drivers/media/video/mt9m001.c b/linux/drivers/media/video/mt9m001.c index 94709f05c..f4742936c 100644 --- a/linux/drivers/media/video/mt9m001.c +++ b/linux/drivers/media/video/mt9m001.c @@ -120,7 +120,7 @@ static int mt9m001_init(struct soc_camera_device *icd) int ret; /* Disable chip, synchronous option update */ - dev_dbg(icd->vdev->dev, "%s\n", __func__); + dev_dbg(icd->vdev->parent, "%s\n", __func__); ret = reg_write(icd, MT9M001_RESET, 1); if (ret >= 0) diff --git a/linux/drivers/media/video/ov511.c b/linux/drivers/media/video/ov511.c index 9676c1d6f..ebfe94076 100644 --- a/linux/drivers/media/video/ov511.c +++ b/linux/drivers/media/video/ov511.c @@ -5837,7 +5837,7 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id) goto error; memcpy(ov->vdev, &vdev_template, sizeof(*ov->vdev)); - ov->vdev->dev = &intf->dev; + ov->vdev->parent = &intf->dev; video_set_drvdata(ov->vdev, ov); for (i = 0; i < OV511_MAX_UNIT_VIDEO; i++) { diff --git a/linux/drivers/media/video/ov511.h b/linux/drivers/media/video/ov511.h index 62f0cb4d7..eba9f2e64 100644 --- a/linux/drivers/media/video/ov511.h +++ b/linux/drivers/media/video/ov511.h @@ -5,6 +5,7 @@ #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/usb.h> #include <linux/mutex.h> diff --git a/linux/drivers/media/video/pms.c b/linux/drivers/media/video/pms.c index bf9858257..31d8a929f 100644 --- a/linux/drivers/media/video/pms.c +++ b/linux/drivers/media/video/pms.c @@ -31,6 +31,7 @@ #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/mutex.h> #include <asm/uaccess.h> diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c index 55cb4021a..f097d6aaf 100644 --- a/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c +++ b/linux/drivers/media/video/pvrusb2/pvrusb2-v4l2.c @@ -30,6 +30,7 @@ #include <linux/videodev2.h> #include <media/v4l2-dev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include "compat.h" struct pvr2_v4l2_dev; diff --git a/linux/drivers/media/video/pwc/pwc-if.c b/linux/drivers/media/video/pwc/pwc-if.c index c28490ae5..e51ee878b 100644 --- a/linux/drivers/media/video/pwc/pwc-if.c +++ b/linux/drivers/media/video/pwc/pwc-if.c @@ -1771,7 +1771,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id return -ENOMEM; } memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); - pdev->vdev->dev = &(udev->dev); + pdev->vdev->parent = &(udev->dev); strcpy(pdev->vdev->name, name); pdev->vdev->owner = THIS_MODULE; video_set_drvdata(pdev->vdev, pdev); diff --git a/linux/drivers/media/video/pwc/pwc.h b/linux/drivers/media/video/pwc/pwc.h index d01548d2c..977700416 100644 --- a/linux/drivers/media/video/pwc/pwc.h +++ b/linux/drivers/media/video/pwc/pwc.h @@ -36,6 +36,7 @@ #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include "pwc-uncompress.h" #include <media/pwc-ioctl.h> diff --git a/linux/drivers/media/video/s2255drv.c b/linux/drivers/media/video/s2255drv.c index 6eb396ffc..f6516a4e4 100644 --- a/linux/drivers/media/video/s2255drv.c +++ b/linux/drivers/media/video/s2255drv.c @@ -49,6 +49,7 @@ #include <linux/version.h> #include <media/videobuf-vmalloc.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/vmalloc.h> #include <linux/usb.h> #include "compat.h" @@ -1707,7 +1708,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev) /* register 4 video devices */ dev->vdev[i] = video_device_alloc(); memcpy(dev->vdev[i], &template, sizeof(struct video_device)); - dev->vdev[i]->dev = &dev->interface->dev; + dev->vdev[i]->parent = &dev->interface->dev; if (video_nr == -1) ret = video_register_device(dev->vdev[i], VFL_TYPE_GRABBER, diff --git a/linux/drivers/media/video/saa5246a.c b/linux/drivers/media/video/saa5246a.c index 59b95caef..49b4a046c 100644 --- a/linux/drivers/media/video/saa5246a.c +++ b/linux/drivers/media/video/saa5246a.c @@ -47,6 +47,7 @@ #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/mutex.h> #include "saa5246a.h" diff --git a/linux/drivers/media/video/saa5249.c b/linux/drivers/media/video/saa5249.c index 3bc0f0604..6423a6762 100644 --- a/linux/drivers/media/video/saa5249.c +++ b/linux/drivers/media/video/saa5249.c @@ -58,6 +58,7 @@ #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/mutex.h> diff --git a/linux/drivers/media/video/saa7134/saa7134-core.c b/linux/drivers/media/video/saa7134/saa7134-core.c index 8f3d280af..254a04717 100644 --- a/linux/drivers/media/video/saa7134/saa7134-core.c +++ b/linux/drivers/media/video/saa7134/saa7134-core.c @@ -859,7 +859,7 @@ static struct video_device *vdev_init(struct saa7134_dev *dev, return NULL; *vfd = *template; vfd->minor = -1; - vfd->dev = &dev->pci->dev; + vfd->parent = &dev->pci->dev; vfd->release = video_device_release; vfd->debug = video_debug; snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", diff --git a/linux/drivers/media/video/saa7134/saa7134-empress.c b/linux/drivers/media/video/saa7134/saa7134-empress.c index d4afbce9d..dc3c2a6cb 100644 --- a/linux/drivers/media/video/saa7134/saa7134-empress.c +++ b/linux/drivers/media/video/saa7134/saa7134-empress.c @@ -473,7 +473,7 @@ static int empress_init(struct saa7134_dev *dev) if (NULL == dev->empress_dev) return -ENOMEM; *(dev->empress_dev) = saa7134_empress_template; - dev->empress_dev->dev = &dev->pci->dev; + dev->empress_dev->parent = &dev->pci->dev; dev->empress_dev->release = video_device_release; snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name), "%s empress (%s)", dev->name, diff --git a/linux/drivers/media/video/saa7134/saa7134.h b/linux/drivers/media/video/saa7134/saa7134.h index c438682cd..053c358ff 100644 --- a/linux/drivers/media/video/saa7134/saa7134.h +++ b/linux/drivers/media/video/saa7134/saa7134.h @@ -35,6 +35,7 @@ #include "compat.h" #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/tuner.h> #include <media/ir-common.h> #include <media/ir-kbd-i2c.h> diff --git a/linux/drivers/media/video/se401.h b/linux/drivers/media/video/se401.h index 81f2c2c74..0be02c48b 100644 --- a/linux/drivers/media/video/se401.h +++ b/linux/drivers/media/video/se401.h @@ -6,6 +6,7 @@ #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/mutex.h> #define se401_DEBUG /* Turn on debug messages */ diff --git a/linux/drivers/media/video/sn9c102/sn9c102.h b/linux/drivers/media/video/sn9c102/sn9c102.h index 491a803e5..bcb7ed001 100644 --- a/linux/drivers/media/video/sn9c102/sn9c102.h +++ b/linux/drivers/media/video/sn9c102/sn9c102.h @@ -25,6 +25,7 @@ #include <linux/usb.h> #include <linux/videodev2.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/device.h> #include <linux/list.h> #include <linux/spinlock.h> diff --git a/linux/drivers/media/video/sn9c102/sn9c102_core.c b/linux/drivers/media/video/sn9c102/sn9c102_core.c index 6747c4d7c..ea062da55 100644 --- a/linux/drivers/media/video/sn9c102/sn9c102_core.c +++ b/linux/drivers/media/video/sn9c102/sn9c102_core.c @@ -1042,8 +1042,7 @@ static ssize_t sn9c102_show_reg(struct device* cd, if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) { mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; @@ -1068,8 +1067,7 @@ sn9c102_store_reg(struct device* cd, struct device_attribute *attr, if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) { mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; @@ -1102,8 +1100,7 @@ static ssize_t sn9c102_show_val(struct device* cd, if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) { mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; @@ -1136,8 +1133,7 @@ sn9c102_store_val(struct device* cd, struct device_attribute *attr, if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) { mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; @@ -1174,8 +1170,7 @@ static ssize_t sn9c102_show_i2c_reg(struct device* cd, if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) { mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; @@ -1202,8 +1197,7 @@ sn9c102_store_i2c_reg(struct device* cd, struct device_attribute *attr, if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) { mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; @@ -1236,8 +1230,7 @@ static ssize_t sn9c102_show_i2c_val(struct device* cd, if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) { mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; @@ -1275,8 +1268,7 @@ sn9c102_store_i2c_val(struct device* cd, struct device_attribute *attr, if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) { mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; @@ -1322,8 +1314,7 @@ sn9c102_store_green(struct device* cd, struct device_attribute *attr, if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) return -ERESTARTSYS; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) { mutex_unlock(&sn9c102_sysfs_lock); return -ENODEV; @@ -1404,8 +1395,7 @@ static ssize_t sn9c102_show_frame_header(struct device* cd, struct sn9c102_device* cam; ssize_t count; - cam = video_get_drvdata(container_of(cd, struct video_device, - class_dev)); + cam = video_get_drvdata(container_of(cd, struct video_device, dev)); if (!cam) return -ENODEV; @@ -1432,49 +1422,49 @@ static DEVICE_ATTR(frame_header, S_IRUGO, sn9c102_show_frame_header, NULL); static int sn9c102_create_sysfs(struct sn9c102_device* cam) { - struct device *classdev = &(cam->v4ldev->class_dev); + struct device *dev = &(cam->v4ldev->dev); int err = 0; - if ((err = device_create_file(classdev, &dev_attr_reg))) + if ((err = device_create_file(dev, &dev_attr_reg))) goto err_out; - if ((err = device_create_file(classdev, &dev_attr_val))) + if ((err = device_create_file(dev, &dev_attr_val))) goto err_reg; - if ((err = device_create_file(classdev, &dev_attr_frame_header))) + if ((err = device_create_file(dev, &dev_attr_frame_header))) goto err_val; if (cam->sensor.sysfs_ops) { - if ((err = device_create_file(classdev, &dev_attr_i2c_reg))) + if ((err = device_create_file(dev, &dev_attr_i2c_reg))) goto err_frame_header; - if ((err = device_create_file(classdev, &dev_attr_i2c_val))) + if ((err = device_create_file(dev, &dev_attr_i2c_val))) goto err_i2c_reg; } if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) { - if ((err = device_create_file(classdev, &dev_attr_green))) + if ((err = device_create_file(dev, &dev_attr_green))) goto err_i2c_val; } else { - if ((err = device_create_file(classdev, &dev_attr_blue))) + if ((err = device_create_file(dev, &dev_attr_blue))) goto err_i2c_val; - if ((err = device_create_file(classdev, &dev_attr_red))) + if ((err = device_create_file(dev, &dev_attr_red))) goto err_blue; } return 0; err_blue: - device_remove_file(classdev, &dev_attr_blue); + device_remove_file(dev, &dev_attr_blue); err_i2c_val: if (cam->sensor.sysfs_ops) - device_remove_file(classdev, &dev_attr_i2c_val); + device_remove_file(dev, &dev_attr_i2c_val); err_i2c_reg: if (cam->sensor.sysfs_ops) - device_remove_file(classdev, &dev_attr_i2c_reg); + device_remove_file(dev, &dev_attr_i2c_reg); err_frame_header: - device_remove_file(classdev, &dev_attr_frame_header); + device_remove_file(dev, &dev_attr_frame_header); err_val: - device_remove_file(classdev, &dev_attr_val); + device_remove_file(dev, &dev_attr_val); err_reg: - device_remove_file(classdev, &dev_attr_reg); + device_remove_file(dev, &dev_attr_reg); err_out: return err; } diff --git a/linux/drivers/media/video/soc_camera.c b/linux/drivers/media/video/soc_camera.c index e39b98f1e..b01749088 100644 --- a/linux/drivers/media/video/soc_camera.c +++ b/linux/drivers/media/video/soc_camera.c @@ -25,6 +25,7 @@ #include <linux/vmalloc.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/v4l2-dev.h> #include <media/videobuf-core.h> #include <media/soc_camera.h> @@ -193,7 +194,7 @@ static int soc_camera_open(struct inode *inode, struct file *file) mutex_lock(&video_lock); vdev = video_devdata(file); - icd = container_of(vdev->dev, struct soc_camera_device, dev); + icd = container_of(vdev->parent, struct soc_camera_device, dev); ici = to_soc_camera_host(icd->dev.parent); if (!try_module_get(icd->ops->owner)) { @@ -258,7 +259,7 @@ static int soc_camera_close(struct inode *inode, struct file *file) vfree(icf); - dev_dbg(vdev->dev, "camera device close\n"); + dev_dbg(vdev->parent, "camera device close\n"); return 0; } @@ -271,7 +272,7 @@ static ssize_t soc_camera_read(struct file *file, char __user *buf, struct video_device *vdev = icd->vdev; int err = -EINVAL; - dev_err(vdev->dev, "camera device read not implemented\n"); + dev_err(vdev->parent, "camera device read not implemented\n"); return err; } @@ -877,7 +878,7 @@ int soc_camera_video_start(struct soc_camera_device *icd) strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name)); /* Maybe better &ici->dev */ - vdev->dev = &icd->dev; + vdev->parent = &icd->dev; vdev->type = VID_TYPE_CAPTURE; vdev->current_norm = V4L2_STD_UNKNOWN; vdev->fops = &soc_camera_fops; @@ -915,7 +916,7 @@ int soc_camera_video_start(struct soc_camera_device *icd) err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor); if (err < 0) { - dev_err(vdev->dev, "video_register_device failed\n"); + dev_err(vdev->parent, "video_register_device failed\n"); goto evidregd; } icd->vdev = vdev; diff --git a/linux/drivers/media/video/stk-webcam.c b/linux/drivers/media/video/stk-webcam.c index 28abeec05..0c605632b 100644 --- a/linux/drivers/media/video/stk-webcam.c +++ b/linux/drivers/media/video/stk-webcam.c @@ -35,6 +35,7 @@ #include "compat.h" #include <linux/videodev2.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include "stk-webcam.h" @@ -1370,7 +1371,7 @@ static int stk_register_video_device(struct stk_camera *dev) dev->vdev = stk_v4l_data; dev->vdev.debug = debug; - dev->vdev.dev = &dev->interface->dev; + dev->vdev.parent = &dev->interface->dev; dev->vdev.priv = dev; err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1); if (err) diff --git a/linux/drivers/media/video/stv680.c b/linux/drivers/media/video/stv680.c index 7aa94abfd..29c62e534 100644 --- a/linux/drivers/media/video/stv680.c +++ b/linux/drivers/media/video/stv680.c @@ -66,6 +66,7 @@ #include <linux/errno.h> #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/usb.h> #include <linux/mutex.h> #include "compat.h" @@ -1459,7 +1460,7 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id goto error; } memcpy(stv680->vdev, &stv680_template, sizeof(stv680_template)); - stv680->vdev->dev = &intf->dev; + stv680->vdev->parent = &intf->dev; video_set_drvdata(stv680->vdev, stv680); memcpy (stv680->vdev->name, stv680->camera_name, strlen (stv680->camera_name)); diff --git a/linux/drivers/media/video/tda7432.c b/linux/drivers/media/video/tda7432.c index 29bcbd0f7..1e70a7710 100644 --- a/linux/drivers/media/video/tda7432.c +++ b/linux/drivers/media/video/tda7432.c @@ -48,6 +48,7 @@ #include <linux/i2c.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/i2c-addr.h> #include "compat.h" diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index 60d26aa03..9649281a9 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -20,6 +20,7 @@ #include <media/tuner.h> #include <media/tuner-types.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/v4l2-i2c-drv-legacy.h> #include "mt20xx.h" #include "tda8290.h" diff --git a/linux/drivers/media/video/usbvideo/usbvideo.c b/linux/drivers/media/video/usbvideo/usbvideo.c index f1aafd97d..f399db543 100644 --- a/linux/drivers/media/video/usbvideo/usbvideo.c +++ b/linux/drivers/media/video/usbvideo/usbvideo.c @@ -1040,7 +1040,7 @@ int usbvideo_RegisterVideoDevice(struct uvd *uvd) err("%s: uvd->dev == NULL", __func__); return -EINVAL; } - uvd->vdev.dev = &uvd->dev->dev; + uvd->vdev.parent = &uvd->dev->dev; if (video_register_device(&uvd->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { err("%s: video_register_device failed", __func__); return -EPIPE; diff --git a/linux/drivers/media/video/usbvideo/usbvideo.h b/linux/drivers/media/video/usbvideo/usbvideo.h index 03b3add3d..b5f5f53bf 100644 --- a/linux/drivers/media/video/usbvideo/usbvideo.h +++ b/linux/drivers/media/video/usbvideo/usbvideo.h @@ -18,6 +18,7 @@ #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/usb.h> #include <linux/mutex.h> #include "compat.h" diff --git a/linux/drivers/media/video/usbvision/usbvision-video.c b/linux/drivers/media/video/usbvision/usbvision-video.c index cd6c41d67..56cd685d3 100644 --- a/linux/drivers/media/video/usbvision/usbvision-video.c +++ b/linux/drivers/media/video/usbvision/usbvision-video.c @@ -65,6 +65,7 @@ #include <media/saa7115.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <media/tuner.h> #include <media/audiochip.h> @@ -184,7 +185,7 @@ MODULE_ALIAS(DRIVER_ALIAS); static inline struct usb_usbvision *cd_to_usbvision(struct device *cd) { struct video_device *vdev = - container_of(cd, struct video_device, class_dev); + container_of(cd, struct video_device, dev); return video_get_drvdata(vdev); } @@ -199,7 +200,7 @@ static ssize_t show_model(struct device *cd, struct device_attribute *attr, char *buf) { struct video_device *vdev = - container_of(cd, struct video_device, class_dev); + container_of(cd, struct video_device, dev); struct usb_usbvision *usbvision = video_get_drvdata(vdev); return sprintf(buf, "%s\n", usbvision_device_data[usbvision->DevModel].ModelString); @@ -210,7 +211,7 @@ static ssize_t show_hue(struct device *cd, struct device_attribute *attr, char *buf) { struct video_device *vdev = - container_of(cd, struct video_device, class_dev); + container_of(cd, struct video_device, dev); struct usb_usbvision *usbvision = video_get_drvdata(vdev); struct v4l2_control ctrl; ctrl.id = V4L2_CID_HUE; @@ -225,7 +226,7 @@ static ssize_t show_contrast(struct device *cd, struct device_attribute *attr, char *buf) { struct video_device *vdev = - container_of(cd, struct video_device, class_dev); + container_of(cd, struct video_device, dev); struct usb_usbvision *usbvision = video_get_drvdata(vdev); struct v4l2_control ctrl; ctrl.id = V4L2_CID_CONTRAST; @@ -240,7 +241,7 @@ static ssize_t show_brightness(struct device *cd, struct device_attribute *attr, char *buf) { struct video_device *vdev = - container_of(cd, struct video_device, class_dev); + container_of(cd, struct video_device, dev); struct usb_usbvision *usbvision = video_get_drvdata(vdev); struct v4l2_control ctrl; ctrl.id = V4L2_CID_BRIGHTNESS; @@ -255,7 +256,7 @@ static ssize_t show_saturation(struct device *cd, struct device_attribute *attr, char *buf) { struct video_device *vdev = - container_of(cd, struct video_device, class_dev); + container_of(cd, struct video_device, dev); struct usb_usbvision *usbvision = video_get_drvdata(vdev); struct v4l2_control ctrl; ctrl.id = V4L2_CID_SATURATION; @@ -270,7 +271,7 @@ static ssize_t show_streaming(struct device *cd, struct device_attribute *attr, char *buf) { struct video_device *vdev = - container_of(cd, struct video_device, class_dev); + container_of(cd, struct video_device, dev); struct usb_usbvision *usbvision = video_get_drvdata(vdev); return sprintf(buf, "%s\n", YES_NO(usbvision->streaming==Stream_On?1:0)); @@ -281,7 +282,7 @@ static ssize_t show_compression(struct device *cd, struct device_attribute *attr, char *buf) { struct video_device *vdev = - container_of(cd, struct video_device, class_dev); + container_of(cd, struct video_device, dev); struct usb_usbvision *usbvision = video_get_drvdata(vdev); return sprintf(buf, "%s\n", YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); @@ -292,7 +293,7 @@ static ssize_t show_device_bridge(struct device *cd, struct device_attribute *attr, char *buf) { struct video_device *vdev = - container_of(cd, struct video_device, class_dev); + container_of(cd, struct video_device, dev); struct usb_usbvision *usbvision = video_get_drvdata(vdev); return sprintf(buf, "%d\n", usbvision->bridgeType); } @@ -304,40 +305,31 @@ static void usbvision_create_sysfs(struct video_device *vdev) if (!vdev) return; do { - res = device_create_file(&vdev->class_dev, - &dev_attr_version); + res = device_create_file(&vdev->dev, &dev_attr_version); if (res<0) break; - res = device_create_file(&vdev->class_dev, - &dev_attr_model); + res = device_create_file(&vdev->dev, &dev_attr_model); if (res<0) break; - res = device_create_file(&vdev->class_dev, - &dev_attr_hue); + res = device_create_file(&vdev->dev, &dev_attr_hue); if (res<0) break; - res = device_create_file(&vdev->class_dev, - &dev_attr_contrast); + res = device_create_file(&vdev->dev, &dev_attr_contrast); if (res<0) break; - res = device_create_file(&vdev->class_dev, - &dev_attr_brightness); + res = device_create_file(&vdev->dev, &dev_attr_brightness); if (res<0) break; - res = device_create_file(&vdev->class_dev, - &dev_attr_saturation); + res = device_create_file(&vdev->dev, &dev_attr_saturation); if (res<0) break; - res = device_create_file(&vdev->class_dev, - &dev_attr_streaming); + res = device_create_file(&vdev->dev, &dev_attr_streaming); if (res<0) break; - res = device_create_file(&vdev->class_dev, - &dev_attr_compression); + res = device_create_file(&vdev->dev, &dev_attr_compression); if (res<0) break; - res = device_create_file(&vdev->class_dev, - &dev_attr_bridge); + res = device_create_file(&vdev->dev, &dev_attr_bridge); if (res>=0) return; } while (0); @@ -348,24 +340,15 @@ static void usbvision_create_sysfs(struct video_device *vdev) static void usbvision_remove_sysfs(struct video_device *vdev) { if (vdev) { - device_remove_file(&vdev->class_dev, - &dev_attr_version); - device_remove_file(&vdev->class_dev, - &dev_attr_model); - device_remove_file(&vdev->class_dev, - &dev_attr_hue); - device_remove_file(&vdev->class_dev, - &dev_attr_contrast); - device_remove_file(&vdev->class_dev, - &dev_attr_brightness); - device_remove_file(&vdev->class_dev, - &dev_attr_saturation); - device_remove_file(&vdev->class_dev, - &dev_attr_streaming); - device_remove_file(&vdev->class_dev, - &dev_attr_compression); - device_remove_file(&vdev->class_dev, - &dev_attr_bridge); + device_remove_file(&vdev->dev, &dev_attr_version); + device_remove_file(&vdev->dev, &dev_attr_model); + device_remove_file(&vdev->dev, &dev_attr_hue); + device_remove_file(&vdev->dev, &dev_attr_contrast); + device_remove_file(&vdev->dev, &dev_attr_brightness); + device_remove_file(&vdev->dev, &dev_attr_saturation); + device_remove_file(&vdev->dev, &dev_attr_streaming); + device_remove_file(&vdev->dev, &dev_attr_compression); + device_remove_file(&vdev->dev, &dev_attr_bridge); } } @@ -1506,7 +1489,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision, } *vdev = *vdev_template; // vdev->minor = -1; - vdev->dev = &usb_dev->dev; + vdev->parent = &usb_dev->dev; snprintf(vdev->name, sizeof(vdev->name), "%s", name); video_set_drvdata(vdev, usbvision); return vdev; diff --git a/linux/drivers/media/video/uvc/uvc_driver.c b/linux/drivers/media/video/uvc/uvc_driver.c index f2b2983fe..79d6821c4 100644 --- a/linux/drivers/media/video/uvc/uvc_driver.c +++ b/linux/drivers/media/video/uvc/uvc_driver.c @@ -1458,7 +1458,7 @@ static int uvc_register_video(struct uvc_device *dev) * unregistered before the reference is released, so we don't need to * get another one. */ - vdev->dev = &dev->intf->dev; + vdev->parent = &dev->intf->dev; vdev->type = 0; vdev->type2 = 0; vdev->minor = -1; diff --git a/linux/drivers/media/video/uvc/uvc_v4l2.c b/linux/drivers/media/video/uvc/uvc_v4l2.c index b5a11eb8f..d7bd71be4 100644 --- a/linux/drivers/media/video/uvc/uvc_v4l2.c +++ b/linux/drivers/media/video/uvc/uvc_v4l2.c @@ -23,6 +23,7 @@ #include <asm/atomic.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include "uvcvideo.h" diff --git a/linux/drivers/media/video/v4l1-compat.c b/linux/drivers/media/video/v4l1-compat.c index 9fe2f491d..5d8a65aa5 100644 --- a/linux/drivers/media/video/v4l1-compat.c +++ b/linux/drivers/media/video/v4l1-compat.c @@ -30,6 +30,7 @@ #include <linux/slab.h> #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <asm/uaccess.h> #include <asm/system.h> diff --git a/linux/drivers/media/video/v4l2-dev.c b/linux/drivers/media/video/v4l2-dev.c new file mode 100644 index 000000000..279f436fe --- /dev/null +++ b/linux/drivers/media/video/v4l2-dev.c @@ -0,0 +1,495 @@ +/* + * Video capture interface for Linux version 2 + * + * A generic video device interface for the LINUX operating system + * using a set of device structures/vectors for low level operations. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Alan Cox, <alan@redhat.com> (version 1) + * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2) + * + * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com> + * - Added procfs support + */ + +#include <linux/module.h> +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/mm.h> +#include <linux/string.h> +#include <linux/errno.h> +#include <linux/init.h> +#include <linux/kmod.h> +#include <linux/slab.h> +#include <linux/smp_lock.h> +#include <asm/uaccess.h> +#include <asm/system.h> + +#include <media/v4l2-common.h> +#include "compat.h" + +#define VIDEO_NUM_DEVICES 256 +#define VIDEO_NAME "video4linux" + +/* + * sysfs stuff + */ + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) +static ssize_t show_index(struct device *cd, + struct device_attribute *attr, char *buf) +{ + struct video_device *vfd = container_of(cd, struct video_device, dev); + return sprintf(buf, "%i\n", vfd->index); +} + +static ssize_t show_name(struct device *cd, + struct device_attribute *attr, char *buf) +{ + struct video_device *vfd = container_of(cd, struct video_device, dev); + return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name); +} + +static struct device_attribute video_device_attrs[] = { + __ATTR(name, S_IRUGO, show_name, NULL), + __ATTR(index, S_IRUGO, show_index, NULL), + __ATTR_NULL +}; +#else +static ssize_t show_index(struct class_device *cd, char *buf) +{ + struct video_device *vfd = container_of(cd, struct video_device, dev); + return sprintf(buf, "%i\n", vfd->index); +} + +static ssize_t show_name(struct class_device *cd, char *buf) +{ + struct video_device *vfd = container_of(cd, struct video_device, dev); + return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name); +} + +static CLASS_DEVICE_ATTR(index, S_IRUGO, show_index, NULL); +static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL); +#endif + +struct video_device *video_device_alloc(void) +{ + struct video_device *vfd; + + vfd = kzalloc(sizeof(*vfd), GFP_KERNEL); + return vfd; +} +EXPORT_SYMBOL(video_device_alloc); + +void video_device_release(struct video_device *vfd) +{ + kfree(vfd); +} +EXPORT_SYMBOL(video_device_release); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) +static void video_release(struct class_device *cd) +#else +static void video_release(struct device *cd) +#endif +{ + struct video_device *vfd = container_of(cd, struct video_device, dev); + +#if 1 /* keep */ + /* needed until all drivers are fixed */ + if (!vfd->release) + return; +#endif + vfd->release(vfd); +} + +static struct class video_class = { + .name = VIDEO_NAME, +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) + .release = video_release, +#else + .dev_attrs = video_device_attrs, + .dev_release = video_release, +#endif +}; + +/* + * Active devices + */ + +static struct video_device *video_device[VIDEO_NUM_DEVICES]; +static DEFINE_MUTEX(videodev_lock); + +struct video_device *video_devdata(struct file *file) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) + return video_device[iminor(file->f_dentry->d_inode)]; +#else + return video_device[iminor(file->f_path.dentry->d_inode)]; +#endif +} +EXPORT_SYMBOL(video_devdata); + +/* + * Open a video device - FIXME: Obsoleted + */ +static int video_open(struct inode *inode, struct file *file) +{ + unsigned int minor = iminor(inode); + int err = 0; + struct video_device *vfl; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) + const struct file_operations *old_fops; +#else + struct file_operations *old_fops; +#endif + + if (minor >= VIDEO_NUM_DEVICES) + return -ENODEV; + lock_kernel(); + mutex_lock(&videodev_lock); + vfl = video_device[minor]; + if (vfl == NULL) { + mutex_unlock(&videodev_lock); + request_module("char-major-%d-%d", VIDEO_MAJOR, minor); + mutex_lock(&videodev_lock); + vfl = video_device[minor]; + if (vfl == NULL) { + mutex_unlock(&videodev_lock); + unlock_kernel(); + return -ENODEV; + } + } + old_fops = file->f_op; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) + file->f_op = fops_get(vfl->fops); +#else + file->f_op = (struct file_operations *)fops_get(vfl->fops); +#endif + if (file->f_op->open) + err = file->f_op->open(inode, file); + if (err) { + fops_put(file->f_op); + file->f_op = fops_get(old_fops); + } + fops_put(old_fops); + mutex_unlock(&videodev_lock); + unlock_kernel(); + return err; +} + +/* + * open/release helper functions -- handle exclusive opens + * Should be removed soon + */ +int video_exclusive_open(struct inode *inode, struct file *file) +{ + struct video_device *vfl = video_devdata(file); + int retval = 0; + + mutex_lock(&vfl->lock); + if (vfl->users) + retval = -EBUSY; + else + vfl->users++; + mutex_unlock(&vfl->lock); + return retval; +} +EXPORT_SYMBOL(video_exclusive_open); + +int video_exclusive_release(struct inode *inode, struct file *file) +{ + struct video_device *vfl = video_devdata(file); + + vfl->users--; + return 0; +} +EXPORT_SYMBOL(video_exclusive_release); + +/** + * get_index - assign stream number based on parent device + * @vdev: video_device to assign index number to, vdev->dev should be assigned + * @num: -1 if auto assign, requested number otherwise + * + * + * returns -ENFILE if num is already in use, a free index number if + * successful. + */ +static int get_index(struct video_device *vdev, int num) +{ + u32 used = 0; + const int max_index = sizeof(used) * 8 - 1; + int i; + + /* Currently a single v4l driver instance cannot create more than + 32 devices. + Increase to u64 or an array of u32 if more are needed. */ + if (num > max_index) { + printk(KERN_ERR "videodev: %s num is too large\n", __func__); + return -EINVAL; + } + + for (i = 0; i < VIDEO_NUM_DEVICES; i++) { + if (video_device[i] != NULL && + video_device[i] != vdev && + video_device[i]->parent == vdev->parent) { + used |= 1 << video_device[i]->index; + } + } + + if (num >= 0) { + if (used & (1 << num)) + return -ENFILE; + return num; + } + + i = ffz(used); + return i > max_index ? -ENFILE : i; +} + +static const struct file_operations video_fops; + +int video_register_device(struct video_device *vfd, int type, int nr) +{ + return video_register_device_index(vfd, type, nr, -1); +} +EXPORT_SYMBOL(video_register_device); + +/** + * video_register_device - register video4linux devices + * @vfd: video device structure we want to register + * @type: type of device to register + * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ... + * -1 == first free) + * + * The registration code assigns minor numbers based on the type + * requested. -ENFILE is returned in all the device slots for this + * category are full. If not then the minor field is set and the + * driver initialize function is called (if non %NULL). + * + * Zero is returned on success. + * + * Valid types are + * + * %VFL_TYPE_GRABBER - A frame grabber + * + * %VFL_TYPE_VTX - A teletext device + * + * %VFL_TYPE_VBI - Vertical blank data (undecoded) + * + * %VFL_TYPE_RADIO - A radio card + */ + +int video_register_device_index(struct video_device *vfd, int type, int nr, + int index) +{ + int i = 0; + int base; + int end; + int ret; + char *name_base; + + switch (type) { + case VFL_TYPE_GRABBER: + base = MINOR_VFL_TYPE_GRABBER_MIN; + end = MINOR_VFL_TYPE_GRABBER_MAX+1; + name_base = "video"; + break; + case VFL_TYPE_VTX: + base = MINOR_VFL_TYPE_VTX_MIN; + end = MINOR_VFL_TYPE_VTX_MAX+1; + name_base = "vtx"; + break; + case VFL_TYPE_VBI: + base = MINOR_VFL_TYPE_VBI_MIN; + end = MINOR_VFL_TYPE_VBI_MAX+1; + name_base = "vbi"; + break; + case VFL_TYPE_RADIO: + base = MINOR_VFL_TYPE_RADIO_MIN; + end = MINOR_VFL_TYPE_RADIO_MAX+1; + name_base = "radio"; + break; + default: + printk(KERN_ERR "%s called with unknown type: %d\n", + __func__, type); + return -1; + } + + /* pick a minor number */ + mutex_lock(&videodev_lock); + if (nr >= 0 && nr < end-base) { + /* use the one the driver asked for */ + i = base + nr; + if (NULL != video_device[i]) { + mutex_unlock(&videodev_lock); + return -ENFILE; + } + } else { + /* use first free */ + for (i = base; i < end; i++) + if (NULL == video_device[i]) + break; + if (i == end) { + mutex_unlock(&videodev_lock); + return -ENFILE; + } + } + video_device[i] = vfd; + vfd->minor = i; + + ret = get_index(vfd, index); + vfd->index = ret; + + mutex_unlock(&videodev_lock); + + if (ret < 0) { + printk(KERN_ERR "%s: get_index failed\n", __func__); + goto fail_minor; + } + + mutex_init(&vfd->lock); + + /* sysfs class */ + memset(&vfd->dev, 0x00, sizeof(vfd->dev)); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18) + vfd->dev.class = &video_class; + vfd->dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) + if (vfd->parent) + vfd->dev.dev = vfd->parent; + sprintf(vfd->dev.class_id, "%s%d", name_base, i - base); + ret = class_device_register(&vfd->dev); +#else + if (vfd->parent) + vfd->dev.parent = vfd->parent; + sprintf(vfd->dev.bus_id, "%s%d", name_base, i - base); + ret = device_register(&vfd->dev); +#endif + if (ret < 0) { + printk(KERN_ERR "%s: device_register failed\n", __func__); + goto fail_minor; + } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) + ret = class_device_create_file(&vfd->dev, + &class_device_attr_name); + if (ret < 0) { + printk(KERN_ERR "%s: class_device_create_file 'name' failed\n", + __func__); + class_device_unregister(&vfd->dev); + goto fail_minor; + } + ret = class_device_create_file(&vfd->dev, + &class_device_attr_index); + if (ret < 0) { + printk(KERN_ERR "%s: class_device_create_file 'index' failed\n", + __func__); + class_device_unregister(&vfd->dev); + goto fail_minor; + } +#endif + +#if 1 /* keep */ + /* needed until all drivers are fixed */ + if (!vfd->release) + printk(KERN_WARNING "videodev: \"%s\" has no release callback. " + "Please fix your driver for proper sysfs support, see " + "http://lwn.net/Articles/36850/\n", vfd->name); +#endif + return 0; + +fail_minor: + mutex_lock(&videodev_lock); + video_device[vfd->minor] = NULL; + vfd->minor = -1; + mutex_unlock(&videodev_lock); + return ret; +} +EXPORT_SYMBOL(video_register_device_index); + +/** + * video_unregister_device - unregister a video4linux device + * @vfd: the device to unregister + * + * This unregisters the passed device and deassigns the minor + * number. Future open calls will be met with errors. + */ + +void video_unregister_device(struct video_device *vfd) +{ + mutex_lock(&videodev_lock); + if (video_device[vfd->minor] != vfd) + panic("videodev: bad unregister"); + + video_device[vfd->minor] = NULL; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) + class_device_unregister(&vfd->dev); +#else + device_unregister(&vfd->dev); +#endif + mutex_unlock(&videodev_lock); +} +EXPORT_SYMBOL(video_unregister_device); + +/* + * Video fs operations + */ +static const struct file_operations video_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .open = video_open, +}; + +/* + * Initialise video for linux + */ + +static int __init videodev_init(void) +{ + int ret; + + printk(KERN_INFO "Linux video capture interface: v2.00\n"); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) + if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, &video_fops)) { +#else + if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, + (struct file_operations *)&video_fops)) { +#endif + printk(KERN_WARNING "video_dev: unable to get major %d\n", VIDEO_MAJOR); + return -EIO; + } + + ret = class_register(&video_class); + if (ret < 0) { + unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME); + printk(KERN_WARNING "video_dev: class_register failed\n"); + return -EIO; + } + + return 0; +} + +static void __exit videodev_exit(void) +{ + class_unregister(&video_class); + unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME); +} + +module_init(videodev_init) +module_exit(videodev_exit) + +MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>"); +MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2"); +MODULE_LICENSE("GPL"); + + +/* + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/linux/drivers/media/video/videodev.c b/linux/drivers/media/video/v4l2-ioctl.c index 48e03618a..61c244d87 100644 --- a/linux/drivers/media/video/videodev.c +++ b/linux/drivers/media/video/v4l2-ioctl.c @@ -1,21 +1,32 @@ /* * Video capture interface for Linux version 2 * - * A generic video device interface for the LINUX operating system - * using a set of device structures/vectors for low level operations. + * A generic framework to process V4L2 ioctl commands. * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. * * Authors: Alan Cox, <alan@redhat.com> (version 1) * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2) - * - * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com> - * - Added procfs support */ +#include <linux/module.h> +#include <linux/types.h> +#include <linux/kernel.h> + +#define __OLD_VIDIOC_ /* To allow fixing old calls */ +#include <linux/videodev2.h> + +#ifdef CONFIG_VIDEO_V4L1 +#include <linux/videodev.h> +#endif +#include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> +#include <linux/video_decoder.h> +#include "compat.h" + #define dbgarg(cmd, fmt, arg...) \ do { \ if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \ @@ -31,32 +42,6 @@ printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\ } while (0) -#include <linux/module.h> -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/mm.h> -#include <linux/string.h> -#include <linux/errno.h> -#include <linux/init.h> -#include <linux/kmod.h> -#include <linux/slab.h> -#include <linux/smp_lock.h> -#include <asm/uaccess.h> -#include <asm/system.h> - -#define __OLD_VIDIOC_ /* To allow fixing old calls*/ -#include <linux/videodev2.h> - -#ifdef CONFIG_VIDEO_V4L1 -#include <linux/videodev.h> -#endif -#include <media/v4l2-common.h> -#include <linux/video_decoder.h> -#include "compat.h" - -#define VIDEO_NUM_DEVICES 256 -#define VIDEO_NAME "video4linux" - struct std_descr { v4l2_std_id std; const char *descr; @@ -374,158 +359,6 @@ void v4l_printk_ioctl(unsigned int cmd) EXPORT_SYMBOL(v4l_printk_ioctl); /* - * sysfs stuff - */ - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) -static ssize_t show_index(struct device *cd, - struct device_attribute *attr, char *buf) -{ - struct video_device *vfd = container_of(cd, struct video_device, - class_dev); - return sprintf(buf, "%i\n", vfd->index); -} - -static ssize_t show_name(struct device *cd, - struct device_attribute *attr, char *buf) -{ - struct video_device *vfd = container_of(cd, struct video_device, - class_dev); - return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name); -} - -static struct device_attribute video_device_attrs[] = { - __ATTR(name, S_IRUGO, show_name, NULL), - __ATTR(index, S_IRUGO, show_index, NULL), - __ATTR_NULL -}; -#else -static ssize_t show_index(struct class_device *cd, char *buf) -{ - struct video_device *vfd = container_of(cd, struct video_device, - class_dev); - return sprintf(buf, "%i\n", vfd->index); -} - -static ssize_t show_name(struct class_device *cd, char *buf) -{ - struct video_device *vfd = container_of(cd, struct video_device, - class_dev); - return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name); -} - -static CLASS_DEVICE_ATTR(index, S_IRUGO, show_index, NULL); -static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL); -#endif - -struct video_device *video_device_alloc(void) -{ - struct video_device *vfd; - - vfd = kzalloc(sizeof(*vfd),GFP_KERNEL); - return vfd; -} -EXPORT_SYMBOL(video_device_alloc); - -void video_device_release(struct video_device *vfd) -{ - kfree(vfd); -} -EXPORT_SYMBOL(video_device_release); - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) -static void video_release(struct class_device *cd) -#else -static void video_release(struct device *cd) -#endif -{ - struct video_device *vfd = container_of(cd, struct video_device, - class_dev); - -#if 1 /* keep */ - /* needed until all drivers are fixed */ - if (!vfd->release) - return; -#endif - vfd->release(vfd); -} - -static struct class video_class = { - .name = VIDEO_NAME, -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) - .release = video_release, -#else - .dev_attrs = video_device_attrs, - .dev_release = video_release, -#endif -}; - -/* - * Active devices - */ - -static struct video_device *video_device[VIDEO_NUM_DEVICES]; -static DEFINE_MUTEX(videodev_lock); - -struct video_device* video_devdata(struct file *file) -{ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) - return video_device[iminor(file->f_dentry->d_inode)]; -#else - return video_device[iminor(file->f_path.dentry->d_inode)]; -#endif -} -EXPORT_SYMBOL(video_devdata); - -/* - * Open a video device - FIXME: Obsoleted - */ -static int video_open(struct inode *inode, struct file *file) -{ - unsigned int minor = iminor(inode); - int err = 0; - struct video_device *vfl; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) - const struct file_operations *old_fops; -#else - struct file_operations *old_fops; -#endif - - if(minor>=VIDEO_NUM_DEVICES) - return -ENODEV; - lock_kernel(); - mutex_lock(&videodev_lock); - vfl=video_device[minor]; - if(vfl==NULL) { - mutex_unlock(&videodev_lock); - request_module("char-major-%d-%d", VIDEO_MAJOR, minor); - mutex_lock(&videodev_lock); - vfl=video_device[minor]; - if (vfl==NULL) { - mutex_unlock(&videodev_lock); - unlock_kernel(); - return -ENODEV; - } - } - old_fops = file->f_op; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) - file->f_op = fops_get(vfl->fops); -#else - file->f_op = (struct file_operations *)fops_get(vfl->fops); -#endif - if(file->f_op->open) - err = file->f_op->open(inode,file); - if (err) { - fops_put(file->f_op); - file->f_op = fops_get(old_fops); - } - fops_put(old_fops); - mutex_unlock(&videodev_lock); - unlock_kernel(); - return err; -} - -/* * helper function -- handles userspace copying for ioctl arguments */ @@ -592,7 +425,7 @@ video_usercopy(struct inode *inode, struct file *file, parg = sbuf; } else { /* too big to allocate from stack */ - mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); + mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL); if (NULL == mbuf) return -ENOMEM; parg = mbuf; @@ -642,8 +475,7 @@ video_usercopy(struct inode *inode, struct file *file, out_ext_ctrl: /* Copy results into user buffer */ - switch (_IOC_DIR(cmd)) - { + switch (_IOC_DIR(cmd)) { case _IOC_READ: case (_IOC_WRITE | _IOC_READ): if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd))) @@ -657,46 +489,17 @@ out: } EXPORT_SYMBOL(video_usercopy); -/* - * open/release helper functions -- handle exclusive opens - * Should be removed soon - */ -int video_exclusive_open(struct inode *inode, struct file *file) -{ - struct video_device *vfl = video_devdata(file); - int retval = 0; - - mutex_lock(&vfl->lock); - if (vfl->users) { - retval = -EBUSY; - } else { - vfl->users++; - } - mutex_unlock(&vfl->lock); - return retval; -} -EXPORT_SYMBOL(video_exclusive_open); - -int video_exclusive_release(struct inode *inode, struct file *file) -{ - struct video_device *vfl = video_devdata(file); - - vfl->users--; - return 0; -} -EXPORT_SYMBOL(video_exclusive_release); - static void dbgbuf(unsigned int cmd, struct video_device *vfd, struct v4l2_buffer *p) { - struct v4l2_timecode *tc=&p->timecode; + struct v4l2_timecode *tc = &p->timecode; - dbgarg (cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, " + dbgarg(cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, " "bytesused=%d, flags=0x%08d, " "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx, length=%d\n", - (p->timestamp.tv_sec/3600), - (int)(p->timestamp.tv_sec/60)%60, - (int)(p->timestamp.tv_sec%60), + p->timestamp.tv_sec / 3600, + (int)(p->timestamp.tv_sec / 60) % 60, + (int)(p->timestamp.tv_sec % 60), p->timestamp.tv_usec, p->index, prt_names(p->type, v4l2_type_names), @@ -706,8 +509,8 @@ static void dbgbuf(unsigned int cmd, struct video_device *vfd, p->m.userptr, p->length); dbgarg2("timecode=%02d:%02d:%02d type=%d, " "flags=0x%08d, frames=%d, userbits=0x%08x\n", - tc->hours,tc->minutes,tc->seconds, - tc->type, tc->flags, tc->frames, *(__u32 *) tc->userbits); + tc->hours, tc->minutes, tc->seconds, + tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); } static inline void dbgrect(struct video_device *vfd, char *s, @@ -717,12 +520,12 @@ static inline void dbgrect(struct video_device *vfd, char *s, r->width, r->height); }; -static inline void v4l_print_pix_fmt (struct video_device *vfd, +static inline void v4l_print_pix_fmt(struct video_device *vfd, struct v4l2_pix_format *fmt) { - dbgarg2 ("width=%d, height=%d, format=%c%c%c%c, field=%s, " + dbgarg2("width=%d, height=%d, format=%c%c%c%c, field=%s, " "bytesperline=%d sizeimage=%d, colorspace=%d\n", - fmt->width,fmt->height, + fmt->width, fmt->height, (fmt->pixelformat & 0xff), (fmt->pixelformat >> 8) & 0xff, (fmt->pixelformat >> 16) & 0xff, @@ -777,47 +580,47 @@ static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) return 1; } -static int check_fmt (struct video_device *vfd, enum v4l2_buf_type type) +static int check_fmt(struct video_device *vfd, enum v4l2_buf_type type) { switch (type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: if (vfd->vidioc_try_fmt_vid_cap) - return (0); + return 0; break; case V4L2_BUF_TYPE_VIDEO_OVERLAY: if (vfd->vidioc_try_fmt_vid_overlay) - return (0); + return 0; break; case V4L2_BUF_TYPE_VIDEO_OUTPUT: if (vfd->vidioc_try_fmt_vid_out) - return (0); + return 0; break; case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: if (vfd->vidioc_try_fmt_vid_out_overlay) - return (0); + return 0; break; case V4L2_BUF_TYPE_VBI_CAPTURE: if (vfd->vidioc_try_fmt_vbi_cap) - return (0); + return 0; break; case V4L2_BUF_TYPE_VBI_OUTPUT: if (vfd->vidioc_try_fmt_vbi_out) - return (0); + return 0; break; case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: if (vfd->vidioc_try_fmt_sliced_vbi_cap) - return (0); + return 0; break; case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: if (vfd->vidioc_try_fmt_sliced_vbi_out) - return (0); + return 0; break; case V4L2_BUF_TYPE_PRIVATE: if (vfd->vidioc_try_fmt_type_private) - return (0); + return 0; break; } - return (-EINVAL); + return -EINVAL; } static int __video_do_ioctl(struct inode *inode, struct file *file, @@ -827,10 +630,10 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, void *fh = file->private_data; int ret = -EINVAL; - if ( (vfd->debug & V4L2_DEBUG_IOCTL) && + if ((vfd->debug & V4L2_DEBUG_IOCTL) && !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { v4l_print_ioctl(vfd->name, cmd); - printk("\n"); + printk(KERN_CONT "\n"); } #ifdef CONFIG_VIDEO_V4L1_COMPAT @@ -842,15 +645,15 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, /* --- streaming capture ------------------------------------- */ if (cmd == VIDIOCGMBUF) { - struct video_mbuf *p=arg; + struct video_mbuf *p = arg; memset(p, 0, sizeof(*p)); if (!vfd->vidiocgmbuf) return ret; - ret=vfd->vidiocgmbuf(file, fh, p); + ret = vfd->vidiocgmbuf(file, fh, p); if (!ret) - dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n", + dbgarg(cmd, "size=%d, frames=%d, offsets=0x%08lx\n", p->size, p->frames, (unsigned long)p->offsets); return ret; @@ -862,27 +665,27 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, __video_do_ioctl will be called again, with one or more V4L2 ioctls. ********************************************************/ - if (_IOC_TYPE(cmd)=='v') - return v4l_compat_translate_ioctl(inode,file,cmd,arg, + if (_IOC_TYPE(cmd) == 'v') + return v4l_compat_translate_ioctl(inode, file, cmd, arg, __video_do_ioctl); #endif - switch(cmd) { + switch (cmd) { /* --- capabilities ------------------------------------------ */ case VIDIOC_QUERYCAP: { - struct v4l2_capability *cap = (struct v4l2_capability*)arg; + struct v4l2_capability *cap = (struct v4l2_capability *)arg; memset(cap, 0, sizeof(*cap)); if (!vfd->vidioc_querycap) break; - ret=vfd->vidioc_querycap(file, fh, cap); + ret = vfd->vidioc_querycap(file, fh, cap); if (!ret) - dbgarg (cmd, "driver=%s, card=%s, bus=%s, " + dbgarg(cmd, "driver=%s, card=%s, bus=%s, " "version=0x%08x, " "capabilities=0x%08x\n", - cap->driver,cap->card,cap->bus_info, + cap->driver, cap->card, cap->bus_info, cap->version, cap->capabilities); break; @@ -891,23 +694,23 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, /* --- priority ------------------------------------------ */ case VIDIOC_G_PRIORITY: { - enum v4l2_priority *p=arg; + enum v4l2_priority *p = arg; if (!vfd->vidioc_g_priority) break; - ret=vfd->vidioc_g_priority(file, fh, p); + ret = vfd->vidioc_g_priority(file, fh, p); if (!ret) dbgarg(cmd, "priority is %d\n", *p); break; } case VIDIOC_S_PRIORITY: { - enum v4l2_priority *p=arg; + enum v4l2_priority *p = arg; if (!vfd->vidioc_s_priority) break; dbgarg(cmd, "setting priority to %d\n", *p); - ret=vfd->vidioc_s_priority(file, fh, *p); + ret = vfd->vidioc_s_priority(file, fh, *p); break; } @@ -920,7 +723,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, index = f->index; type = f->type; - memset(f,0,sizeof(*f)); + memset(f, 0, sizeof(*f)); f->index = index; f->type = type; @@ -959,14 +762,14 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, break; } if (!ret) - dbgarg (cmd, "index=%d, type=%d, flags=%d, " - "pixelformat=%c%c%c%c, description='%s'\n", - f->index, f->type, f->flags, - (f->pixelformat & 0xff), - (f->pixelformat >> 8) & 0xff, - (f->pixelformat >> 16) & 0xff, - (f->pixelformat >> 24) & 0xff, - f->description); + dbgarg(cmd, "index=%d, type=%d, flags=%d, " + "pixelformat=%c%c%c%c, description='%s'\n", + f->index, f->type, f->flags, + (f->pixelformat & 0xff), + (f->pixelformat >> 8) & 0xff, + (f->pixelformat >> 16) & 0xff, + (f->pixelformat >> 24) & 0xff, + f->description); break; } case VIDIOC_G_FMT: @@ -1087,7 +890,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, struct v4l2_format *f = (struct v4l2_format *)arg; /* FIXME: Should be one dump per type */ - dbgarg (cmd, "type=%s\n", prt_names(f->type, + dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names)); switch (f->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: @@ -1145,16 +948,16 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, */ case VIDIOC_REQBUFS: { - struct v4l2_requestbuffers *p=arg; + struct v4l2_requestbuffers *p = arg; if (!vfd->vidioc_reqbufs) break; - ret = check_fmt (vfd, p->type); + ret = check_fmt(vfd, p->type); if (ret) break; - ret=vfd->vidioc_reqbufs(file, fh, p); - dbgarg (cmd, "count=%d, type=%s, memory=%s\n", + ret = vfd->vidioc_reqbufs(file, fh, p); + dbgarg(cmd, "count=%d, type=%s, memory=%s\n", p->count, prt_names(p->type, v4l2_type_names), prt_names(p->memory, v4l2_memory_names)); @@ -1162,46 +965,47 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, } case VIDIOC_QUERYBUF: { - struct v4l2_buffer *p=arg; + struct v4l2_buffer *p = arg; if (!vfd->vidioc_querybuf) break; - ret = check_fmt (vfd, p->type); + ret = check_fmt(vfd, p->type); if (ret) break; - ret=vfd->vidioc_querybuf(file, fh, p); + ret = vfd->vidioc_querybuf(file, fh, p); if (!ret) - dbgbuf(cmd,vfd,p); + dbgbuf(cmd, vfd, p); break; } case VIDIOC_QBUF: { - struct v4l2_buffer *p=arg; + struct v4l2_buffer *p = arg; if (!vfd->vidioc_qbuf) break; - ret = check_fmt (vfd, p->type); + ret = check_fmt(vfd, p->type); if (ret) break; - ret=vfd->vidioc_qbuf(file, fh, p); + ret = vfd->vidioc_qbuf(file, fh, p); if (!ret) - dbgbuf(cmd,vfd,p); + dbgbuf(cmd, vfd, p); break; } case VIDIOC_DQBUF: { - struct v4l2_buffer *p=arg; + struct v4l2_buffer *p = arg; + if (!vfd->vidioc_dqbuf) break; - ret = check_fmt (vfd, p->type); + ret = check_fmt(vfd, p->type); if (ret) break; - ret=vfd->vidioc_dqbuf(file, fh, p); + ret = vfd->vidioc_dqbuf(file, fh, p); if (!ret) - dbgbuf(cmd,vfd,p); + dbgbuf(cmd, vfd, p); break; } case VIDIOC_OVERLAY: @@ -1210,8 +1014,8 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, if (!vfd->vidioc_overlay) break; - dbgarg (cmd, "value=%d\n",*i); - ret=vfd->vidioc_overlay(file, fh, *i); + dbgarg(cmd, "value=%d\n", *i); + ret = vfd->vidioc_overlay(file, fh, *i); break; } case VIDIOC_G_FBUF: @@ -1244,10 +1048,11 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, case VIDIOC_STREAMON: { enum v4l2_buf_type i = *(int *)arg; + if (!vfd->vidioc_streamon) break; dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); - ret=vfd->vidioc_streamon(file, fh,i); + ret = vfd->vidioc_streamon(file, fh, i); break; } case VIDIOC_STREAMOFF: @@ -1257,7 +1062,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, if (!vfd->vidioc_streamoff) break; dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); - ret=vfd->vidioc_streamoff(file, fh, i); + ret = vfd->vidioc_streamoff(file, fh, i); break; } /* ---------- tv norms ---------- */ @@ -1317,35 +1122,34 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, } case VIDIOC_S_STD: { - v4l2_std_id *id = arg,norm; + v4l2_std_id *id = arg, norm; dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id); norm = (*id) & vfd->tvnorms; - if ( vfd->tvnorms && !norm) /* Check if std is supported */ + if (vfd->tvnorms && !norm) /* Check if std is supported */ break; /* Calls the specific handler */ if (vfd->vidioc_s_std) - ret=vfd->vidioc_s_std(file, fh, &norm); + ret = vfd->vidioc_s_std(file, fh, &norm); else - ret=-EINVAL; + ret = -EINVAL; /* Updates standard information */ - if (ret>=0) - vfd->current_norm=norm; - + if (ret >= 0) + vfd->current_norm = norm; break; } case VIDIOC_QUERYSTD: { - v4l2_std_id *p=arg; + v4l2_std_id *p = arg; if (!vfd->vidioc_querystd) break; - ret=vfd->vidioc_querystd(file, fh, arg); + ret = vfd->vidioc_querystd(file, fh, arg); if (!ret) - dbgarg (cmd, "detected std=%08Lx\n", + dbgarg(cmd, "detected std=%08Lx\n", (unsigned long long)*p); break; } @@ -1353,23 +1157,23 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, /* FIXME: Inputs can be handled inside videodev2 */ case VIDIOC_ENUMINPUT: { - struct v4l2_input *p=arg; - int i=p->index; + struct v4l2_input *p = arg; + int i = p->index; if (!vfd->vidioc_enum_input) break; memset(p, 0, sizeof(*p)); - p->index=i; + p->index = i; - ret=vfd->vidioc_enum_input(file, fh, p); + ret = vfd->vidioc_enum_input(file, fh, p); if (!ret) - dbgarg (cmd, "index=%d, name=%s, type=%d, " - "audioset=%d, " - "tuner=%d, std=%08Lx, status=%d\n", - p->index,p->name,p->type,p->audioset, - p->tuner, - (unsigned long long)p->std, - p->status); + dbgarg(cmd, "index=%d, name=%s, type=%d, " + "audioset=%d, " + "tuner=%d, std=%08Lx, status=%d\n", + p->index, p->name, p->type, p->audioset, + p->tuner, + (unsigned long long)p->std, + p->status); break; } case VIDIOC_G_INPUT: @@ -1378,9 +1182,9 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, if (!vfd->vidioc_g_input) break; - ret=vfd->vidioc_g_input(file, fh, i); + ret = vfd->vidioc_g_input(file, fh, i); if (!ret) - dbgarg (cmd, "value=%d\n",*i); + dbgarg(cmd, "value=%d\n", *i); break; } case VIDIOC_S_INPUT: @@ -1389,8 +1193,8 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, if (!vfd->vidioc_s_input) break; - dbgarg (cmd, "value=%d\n",*i); - ret=vfd->vidioc_s_input(file, fh, *i); + dbgarg(cmd, "value=%d\n", *i); + ret = vfd->vidioc_s_input(file, fh, *i); break; } @@ -1420,9 +1224,9 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, if (!vfd->vidioc_g_output) break; - ret=vfd->vidioc_g_output(file, fh, i); + ret = vfd->vidioc_g_output(file, fh, i); if (!ret) - dbgarg (cmd, "value=%d\n",*i); + dbgarg(cmd, "value=%d\n", *i); break; } case VIDIOC_S_OUTPUT: @@ -1431,8 +1235,8 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, if (!vfd->vidioc_s_output) break; - dbgarg (cmd, "value=%d\n",*i); - ret=vfd->vidioc_s_output(file, fh, *i); + dbgarg(cmd, "value=%d\n", *i); + ret = vfd->vidioc_s_output(file, fh, *i); break; } @@ -1609,92 +1413,95 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, } case VIDIOC_ENUMAUDOUT: { - struct v4l2_audioout *p=arg; + struct v4l2_audioout *p = arg; if (!vfd->vidioc_enumaudout) break; dbgarg(cmd, "Enum for index=%d\n", p->index); - ret=vfd->vidioc_enumaudout(file, fh, p); + ret = vfd->vidioc_enumaudout(file, fh, p); if (!ret) dbgarg2("index=%d, name=%s, capability=%d, " "mode=%d\n", p->index, p->name, - p->capability,p->mode); + p->capability, p->mode); break; } case VIDIOC_G_AUDOUT: { - struct v4l2_audioout *p=arg; + struct v4l2_audioout *p = arg; if (!vfd->vidioc_g_audout) break; dbgarg(cmd, "Enum for index=%d\n", p->index); - ret=vfd->vidioc_g_audout(file, fh, p); + ret = vfd->vidioc_g_audout(file, fh, p); if (!ret) dbgarg2("index=%d, name=%s, capability=%d, " "mode=%d\n", p->index, p->name, - p->capability,p->mode); + p->capability, p->mode); break; } case VIDIOC_S_AUDOUT: { - struct v4l2_audioout *p=arg; + struct v4l2_audioout *p = arg; if (!vfd->vidioc_s_audout) break; dbgarg(cmd, "index=%d, name=%s, capability=%d, " "mode=%d\n", p->index, p->name, - p->capability,p->mode); + p->capability, p->mode); - ret=vfd->vidioc_s_audout(file, fh, p); + ret = vfd->vidioc_s_audout(file, fh, p); break; } case VIDIOC_G_MODULATOR: { - struct v4l2_modulator *p=arg; + struct v4l2_modulator *p = arg; + if (!vfd->vidioc_g_modulator) break; - ret=vfd->vidioc_g_modulator(file, fh, p); + ret = vfd->vidioc_g_modulator(file, fh, p); if (!ret) dbgarg(cmd, "index=%d, name=%s, " "capability=%d, rangelow=%d," " rangehigh=%d, txsubchans=%d\n", - p->index, p->name,p->capability, + p->index, p->name, p->capability, p->rangelow, p->rangehigh, p->txsubchans); break; } case VIDIOC_S_MODULATOR: { - struct v4l2_modulator *p=arg; + struct v4l2_modulator *p = arg; + if (!vfd->vidioc_s_modulator) break; dbgarg(cmd, "index=%d, name=%s, capability=%d, " "rangelow=%d, rangehigh=%d, txsubchans=%d\n", - p->index, p->name,p->capability,p->rangelow, - p->rangehigh,p->txsubchans); - ret=vfd->vidioc_s_modulator(file, fh, p); + p->index, p->name, p->capability, p->rangelow, + p->rangehigh, p->txsubchans); + ret = vfd->vidioc_s_modulator(file, fh, p); break; } case VIDIOC_G_CROP: { - struct v4l2_crop *p=arg; + struct v4l2_crop *p = arg; + if (!vfd->vidioc_g_crop) break; dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); - ret=vfd->vidioc_g_crop(file, fh, p); - if (!ret) { + ret = vfd->vidioc_g_crop(file, fh, p); + if (!ret) dbgrect(vfd, "", &p->c); - } break; } case VIDIOC_S_CROP: { - struct v4l2_crop *p=arg; + struct v4l2_crop *p = arg; + if (!vfd->vidioc_s_crop) break; dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); dbgrect(vfd, "", &p->c); - ret=vfd->vidioc_s_crop(file, fh, p); + ret = vfd->vidioc_s_crop(file, fh, p); break; } case VIDIOC_CROPCAP: @@ -1714,40 +1521,42 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, } case VIDIOC_G_JPEGCOMP: { - struct v4l2_jpegcompression *p=arg; + struct v4l2_jpegcompression *p = arg; + if (!vfd->vidioc_g_jpegcomp) break; - ret=vfd->vidioc_g_jpegcomp(file, fh, p); + ret = vfd->vidioc_g_jpegcomp(file, fh, p); if (!ret) - dbgarg (cmd, "quality=%d, APPn=%d, " - "APP_len=%d, COM_len=%d, " - "jpeg_markers=%d\n", - p->quality,p->APPn,p->APP_len, - p->COM_len,p->jpeg_markers); + dbgarg(cmd, "quality=%d, APPn=%d, " + "APP_len=%d, COM_len=%d, " + "jpeg_markers=%d\n", + p->quality, p->APPn, p->APP_len, + p->COM_len, p->jpeg_markers); break; } case VIDIOC_S_JPEGCOMP: { - struct v4l2_jpegcompression *p=arg; + struct v4l2_jpegcompression *p = arg; + if (!vfd->vidioc_g_jpegcomp) break; - dbgarg (cmd, "quality=%d, APPn=%d, APP_len=%d, " + dbgarg(cmd, "quality=%d, APPn=%d, APP_len=%d, " "COM_len=%d, jpeg_markers=%d\n", - p->quality,p->APPn,p->APP_len, - p->COM_len,p->jpeg_markers); - ret=vfd->vidioc_s_jpegcomp(file, fh, p); + p->quality, p->APPn, p->APP_len, + p->COM_len, p->jpeg_markers); + ret = vfd->vidioc_s_jpegcomp(file, fh, p); break; } case VIDIOC_G_ENC_INDEX: { - struct v4l2_enc_idx *p=arg; + struct v4l2_enc_idx *p = arg; if (!vfd->vidioc_g_enc_index) break; - ret=vfd->vidioc_g_enc_index(file, fh, p); + ret = vfd->vidioc_g_enc_index(file, fh, p); if (!ret) - dbgarg (cmd, "entries=%d, entries_cap=%d\n", - p->entries,p->entries_cap); + dbgarg(cmd, "entries=%d, entries_cap=%d\n", + p->entries, p->entries_cap); break; } case VIDIOC_ENCODER_CMD: @@ -1776,14 +1585,14 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, } case VIDIOC_G_PARM: { - struct v4l2_streamparm *p=arg; - __u32 type=p->type; + struct v4l2_streamparm *p = arg; + __u32 type = p->type; - memset(p,0,sizeof(*p)); - p->type=type; + memset(p, 0, sizeof(*p)); + p->type = type; if (vfd->vidioc_g_parm) { - ret=vfd->vidioc_g_parm(file, fh, p); + ret = vfd->vidioc_g_parm(file, fh, p); } else { struct v4l2_standard s; @@ -1794,19 +1603,20 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, v4l2_norm_to_name(vfd->current_norm)); p->parm.capture.timeperframe = s.frameperiod; - ret=0; + ret = 0; } - dbgarg (cmd, "type=%d\n", p->type); + dbgarg(cmd, "type=%d\n", p->type); break; } case VIDIOC_S_PARM: { - struct v4l2_streamparm *p=arg; + struct v4l2_streamparm *p = arg; + if (!vfd->vidioc_s_parm) break; - dbgarg (cmd, "type=%d\n", p->type); - ret=vfd->vidioc_s_parm(file, fh, p); + dbgarg(cmd, "type=%d\n", p->type); + ret = vfd->vidioc_s_parm(file, fh, p); break; } case VIDIOC_G_TUNER: @@ -1866,12 +1676,13 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, } case VIDIOC_S_FREQUENCY: { - struct v4l2_frequency *p=arg; + struct v4l2_frequency *p = arg; + if (!vfd->vidioc_s_frequency) break; - dbgarg (cmd, "tuner=%d, type=%d, frequency=%d\n", - p->tuner,p->type,p->frequency); - ret=vfd->vidioc_s_frequency(file, fh, p); + dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n", + p->tuner, p->type, p->frequency); + ret = vfd->vidioc_s_frequency(file, fh, p); break; } case VIDIOC_G_SLICED_VBI_CAP: @@ -1893,37 +1704,40 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, { if (!vfd->vidioc_log_status) break; - ret=vfd->vidioc_log_status(file, fh); + ret = vfd->vidioc_log_status(file, fh); break; } #ifdef CONFIG_VIDEO_ADV_DEBUG case VIDIOC_DBG_G_REGISTER: { - struct v4l2_register *p=arg; + struct v4l2_register *p = arg; + if (!capable(CAP_SYS_ADMIN)) - ret=-EPERM; + ret = -EPERM; else if (vfd->vidioc_g_register) - ret=vfd->vidioc_g_register(file, fh, p); + ret = vfd->vidioc_g_register(file, fh, p); break; } case VIDIOC_DBG_S_REGISTER: { - struct v4l2_register *p=arg; + struct v4l2_register *p = arg; + if (!capable(CAP_SYS_ADMIN)) - ret=-EPERM; + ret = -EPERM; else if (vfd->vidioc_s_register) - ret=vfd->vidioc_s_register(file, fh, p); + ret = vfd->vidioc_s_register(file, fh, p); break; } #endif case VIDIOC_G_CHIP_IDENT: { - struct v4l2_chip_ident *p=arg; + struct v4l2_chip_ident *p = arg; + if (!vfd->vidioc_g_chip_ident) break; - ret=vfd->vidioc_g_chip_ident(file, fh, p); + ret = vfd->vidioc_g_chip_ident(file, fh, p); if (!ret) - dbgarg (cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); + dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); break; } default: @@ -1936,6 +1750,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, case VIDIOC_S_HW_FREQ_SEEK: { struct v4l2_hw_freq_seek *p = arg; + if (!vfd->vidioc_s_hw_freq_seek) break; dbgarg(cmd, @@ -1956,7 +1771,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, return ret; } -int video_ioctl2 (struct inode *inode, struct file *file, +int video_ioctl2(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { char sbuf[128]; @@ -1985,7 +1800,7 @@ int video_ioctl2 (struct inode *inode, struct file *file, parg = sbuf; } else { /* too big to allocate from stack */ - mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); + mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL); if (NULL == mbuf) return -ENOMEM; parg = mbuf; @@ -2036,8 +1851,7 @@ int video_ioctl2 (struct inode *inode, struct file *file, out_ext_ctrl: /* Copy results into user buffer */ - switch (_IOC_DIR(cmd)) - { + switch (_IOC_DIR(cmd)) { case _IOC_READ: case (_IOC_WRITE | _IOC_READ): if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd))) @@ -2050,289 +1864,3 @@ out: return err; } EXPORT_SYMBOL(video_ioctl2); - -/** - * get_index - assign stream number based on parent device - * @vdev: video_device to assign index number to, vdev->dev should be assigned - * @num: -1 if auto assign, requested number otherwise - * - * - * returns -ENFILE if num is already in use, a free index number if - * successful. - */ -static int get_index(struct video_device *vdev, int num) -{ - u32 used = 0; - const int max_index = sizeof(used) * 8 - 1; - int i; - - /* Currently a single v4l driver instance cannot create more than - 32 devices. - Increase to u64 or an array of u32 if more are needed. */ - if (num > max_index) { - printk(KERN_ERR "videodev: %s num is too large\n", __func__); - return -EINVAL; - } - - for (i = 0; i < VIDEO_NUM_DEVICES; i++) { - if (video_device[i] != NULL && - video_device[i] != vdev && - video_device[i]->dev == vdev->dev) { - used |= 1 << video_device[i]->index; - } - } - - if (num >= 0) { - if (used & (1 << num)) - return -ENFILE; - return num; - } - - i = ffz(used); - return i > max_index ? -ENFILE : i; -} - -static const struct file_operations video_fops; - -int video_register_device(struct video_device *vfd, int type, int nr) -{ - return video_register_device_index(vfd, type, nr, -1); -} -EXPORT_SYMBOL(video_register_device); - -/** - * video_register_device - register video4linux devices - * @vfd: video device structure we want to register - * @type: type of device to register - * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ... - * -1 == first free) - * - * The registration code assigns minor numbers based on the type - * requested. -ENFILE is returned in all the device slots for this - * category are full. If not then the minor field is set and the - * driver initialize function is called (if non %NULL). - * - * Zero is returned on success. - * - * Valid types are - * - * %VFL_TYPE_GRABBER - A frame grabber - * - * %VFL_TYPE_VTX - A teletext device - * - * %VFL_TYPE_VBI - Vertical blank data (undecoded) - * - * %VFL_TYPE_RADIO - A radio card - */ - -int video_register_device_index(struct video_device *vfd, int type, int nr, - int index) -{ - int i=0; - int base; - int end; - int ret; - char *name_base; - - switch(type) - { - case VFL_TYPE_GRABBER: - base=MINOR_VFL_TYPE_GRABBER_MIN; - end=MINOR_VFL_TYPE_GRABBER_MAX+1; - name_base = "video"; - break; - case VFL_TYPE_VTX: - base=MINOR_VFL_TYPE_VTX_MIN; - end=MINOR_VFL_TYPE_VTX_MAX+1; - name_base = "vtx"; - break; - case VFL_TYPE_VBI: - base=MINOR_VFL_TYPE_VBI_MIN; - end=MINOR_VFL_TYPE_VBI_MAX+1; - name_base = "vbi"; - break; - case VFL_TYPE_RADIO: - base=MINOR_VFL_TYPE_RADIO_MIN; - end=MINOR_VFL_TYPE_RADIO_MAX+1; - name_base = "radio"; - break; - default: - printk(KERN_ERR "%s called with unknown type: %d\n", - __func__, type); - return -1; - } - - /* pick a minor number */ - mutex_lock(&videodev_lock); - if (nr >= 0 && nr < end-base) { - /* use the one the driver asked for */ - i = base+nr; - if (NULL != video_device[i]) { - mutex_unlock(&videodev_lock); - return -ENFILE; - } - } else { - /* use first free */ - for(i=base;i<end;i++) - if (NULL == video_device[i]) - break; - if (i == end) { - mutex_unlock(&videodev_lock); - return -ENFILE; - } - } - video_device[i]=vfd; - vfd->minor=i; - - ret = get_index(vfd, index); - vfd->index = ret; - - mutex_unlock(&videodev_lock); - - if (ret < 0) { - printk(KERN_ERR "%s: get_index failed\n", __func__); - goto fail_minor; - } - - mutex_init(&vfd->lock); - - /* sysfs class */ - memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev)); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18) - vfd->class_dev.class = &video_class; - vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); -#endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) - if (vfd->dev) - vfd->class_dev.dev = vfd->dev; - sprintf(vfd->class_dev.class_id, "%s%d", name_base, i - base); - ret = class_device_register(&vfd->class_dev); -#else - if (vfd->dev) - vfd->class_dev.parent = vfd->dev; - sprintf(vfd->class_dev.bus_id, "%s%d", name_base, i - base); - ret = device_register(&vfd->class_dev); -#endif - if (ret < 0) { - printk(KERN_ERR "%s: device_register failed\n", __func__); - goto fail_minor; - } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) - ret = class_device_create_file(&vfd->class_dev, - &class_device_attr_name); - if (ret < 0) { - printk(KERN_ERR "%s: class_device_create_file 'name' failed\n", - __func__); - class_device_unregister(&vfd->class_dev); - goto fail_minor; - } - ret = class_device_create_file(&vfd->class_dev, - &class_device_attr_index); - if (ret < 0) { - printk(KERN_ERR "%s: class_device_create_file 'index' failed\n", - __func__); - class_device_unregister(&vfd->class_dev); - goto fail_minor; - } -#endif - -#if 1 /* keep */ - /* needed until all drivers are fixed */ - if (!vfd->release) - printk(KERN_WARNING "videodev: \"%s\" has no release callback. " - "Please fix your driver for proper sysfs support, see " - "http://lwn.net/Articles/36850/\n", vfd->name); -#endif - return 0; - -fail_minor: - mutex_lock(&videodev_lock); - video_device[vfd->minor] = NULL; - vfd->minor = -1; - mutex_unlock(&videodev_lock); - return ret; -} -EXPORT_SYMBOL(video_register_device_index); - -/** - * video_unregister_device - unregister a video4linux device - * @vfd: the device to unregister - * - * This unregisters the passed device and deassigns the minor - * number. Future open calls will be met with errors. - */ - -void video_unregister_device(struct video_device *vfd) -{ - mutex_lock(&videodev_lock); - if(video_device[vfd->minor]!=vfd) - panic("videodev: bad unregister"); - - video_device[vfd->minor]=NULL; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) - class_device_unregister(&vfd->class_dev); -#else - device_unregister(&vfd->class_dev); -#endif - mutex_unlock(&videodev_lock); -} -EXPORT_SYMBOL(video_unregister_device); - -/* - * Video fs operations - */ -static const struct file_operations video_fops= -{ - .owner = THIS_MODULE, - .llseek = no_llseek, - .open = video_open, -}; - -/* - * Initialise video for linux - */ - -static int __init videodev_init(void) -{ - int ret; - - printk(KERN_INFO "Linux video capture interface: v2.00\n"); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) - if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, &video_fops)) { -#else - if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, - (struct file_operations *)&video_fops)) { -#endif - printk(KERN_WARNING "video_dev: unable to get major %d\n", VIDEO_MAJOR); - return -EIO; - } - - ret = class_register(&video_class); - if (ret < 0) { - unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME); - printk(KERN_WARNING "video_dev: class_register failed\n"); - return -EIO; - } - - return 0; -} - -static void __exit videodev_exit(void) -{ - class_unregister(&video_class); - unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME); -} - -module_init(videodev_init) -module_exit(videodev_exit) - -MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>"); -MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2"); -MODULE_LICENSE("GPL"); - - -/* - * Local variables: - * c-basic-offset: 8 - * End: - */ diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c index 78108a4e0..7f4a53077 100644 --- a/linux/drivers/media/video/vivi.c +++ b/linux/drivers/media/video/vivi.c @@ -36,6 +36,7 @@ #include <linux/interrupt.h> #include <media/videobuf-vmalloc.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/kthread.h> #include <linux/highmem.h> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) diff --git a/linux/drivers/media/video/w9966.c b/linux/drivers/media/video/w9966.c index 9b77f268c..66c730b8b 100644 --- a/linux/drivers/media/video/w9966.c +++ b/linux/drivers/media/video/w9966.c @@ -60,6 +60,7 @@ #include "compat.h" #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/parport.h> /*#define DEBUG*/ /* Undef me for production */ diff --git a/linux/drivers/media/video/w9968cf.c b/linux/drivers/media/video/w9968cf.c index 712c8c066..55f677243 100644 --- a/linux/drivers/media/video/w9968cf.c +++ b/linux/drivers/media/video/w9968cf.c @@ -3563,7 +3563,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) cam->v4ldev->minor = video_nr[dev_nr]; cam->v4ldev->release = video_device_release; video_set_drvdata(cam->v4ldev, cam); - cam->v4ldev->dev = &cam->dev; + cam->v4ldev->parent = &cam->dev; err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, video_nr[dev_nr]); diff --git a/linux/drivers/media/video/zc0301/zc0301.h b/linux/drivers/media/video/zc0301/zc0301.h index a7c7b1116..7bd0d02b3 100644 --- a/linux/drivers/media/video/zc0301/zc0301.h +++ b/linux/drivers/media/video/zc0301/zc0301.h @@ -26,6 +26,7 @@ #include "compat.h" #include <linux/videodev2.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include <linux/device.h> #include <linux/list.h> #include <linux/spinlock.h> diff --git a/linux/drivers/media/video/zoran_driver.c b/linux/drivers/media/video/zoran_driver.c index 844c688e8..989a6f7e0 100644 --- a/linux/drivers/media/video/zoran_driver.c +++ b/linux/drivers/media/video/zoran_driver.c @@ -71,6 +71,7 @@ #include <linux/videodev.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include "videocodec.h" #include <asm/byteorder.h> diff --git a/linux/drivers/media/video/zr364xx.c b/linux/drivers/media/video/zr364xx.c index b1a65e3f5..0967cdb3f 100644 --- a/linux/drivers/media/video/zr364xx.c +++ b/linux/drivers/media/video/zr364xx.c @@ -35,6 +35,7 @@ #include <linux/proc_fs.h> #include <linux/highmem.h> #include <media/v4l2-common.h> +#include <media/v4l2-ioctl.h> #include "compat.h" |