From: Hans Verkuil Date: Mon, 22 Mar 2010 08:22:34 +0000 (-0300) Subject: V4L/DVB: meye: remove last V4L1 remnants from the code and add v4l2_device X-Git-Tag: v2.6.35.3~880^2~291 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/linux-imx.git/commitdiff_plain/51270617a52793c423ef68ddd3f18745e9abd15b V4L/DVB: meye: remove last V4L1 remnants from the code and add v4l2_device Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 9644cf760aaa..2ed76f97bf6c 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -740,7 +740,7 @@ source "drivers/media/video/zoran/Kconfig" config VIDEO_MEYE tristate "Sony Vaio Picturebook Motion Eye Video For Linux" - depends on PCI && SONY_LAPTOP && VIDEO_V4L1 + depends on PCI && SONY_LAPTOP && VIDEO_V4L2 ---help--- This is the video4linux driver for the Motion Eye camera found in the Vaio Picturebook laptops. Please read the material in diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c index 4404e5ef818f..2be23bccd3c8 100644 --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c @@ -30,9 +30,10 @@ #include #include #include -#include #include +#include #include +#include #include #include #include @@ -1168,22 +1169,22 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c) case V4L2_CID_BRIGHTNESS: sony_pic_camera_command( SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, c->value); - meye.picture.brightness = c->value << 10; + meye.brightness = c->value << 10; break; case V4L2_CID_HUE: sony_pic_camera_command( SONY_PIC_COMMAND_SETCAMERAHUE, c->value); - meye.picture.hue = c->value << 10; + meye.hue = c->value << 10; break; case V4L2_CID_CONTRAST: sony_pic_camera_command( SONY_PIC_COMMAND_SETCAMERACONTRAST, c->value); - meye.picture.contrast = c->value << 10; + meye.contrast = c->value << 10; break; case V4L2_CID_SATURATION: sony_pic_camera_command( SONY_PIC_COMMAND_SETCAMERACOLOR, c->value); - meye.picture.colour = c->value << 10; + meye.colour = c->value << 10; break; case V4L2_CID_AGC: sony_pic_camera_command( @@ -1221,16 +1222,16 @@ static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *c) mutex_lock(&meye.lock); switch (c->id) { case V4L2_CID_BRIGHTNESS: - c->value = meye.picture.brightness >> 10; + c->value = meye.brightness >> 10; break; case V4L2_CID_HUE: - c->value = meye.picture.hue >> 10; + c->value = meye.hue >> 10; break; case V4L2_CID_CONTRAST: - c->value = meye.picture.contrast >> 10; + c->value = meye.contrast >> 10; break; case V4L2_CID_SATURATION: - c->value = meye.picture.colour >> 10; + c->value = meye.colour >> 10; break; case V4L2_CID_AGC: c->value = meye.params.agc; @@ -1729,6 +1730,7 @@ static int meye_resume(struct pci_dev *pdev) static int __devinit meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent) { + struct v4l2_device *v4l2_dev = &meye.v4l2_dev; int ret = -EBUSY; unsigned long mchip_adr; @@ -1737,70 +1739,75 @@ static int __devinit meye_probe(struct pci_dev *pcidev, goto outnotdev; } + ret = v4l2_device_register(&pcidev->dev, v4l2_dev); + if (ret < 0) { + v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); + return ret; + } ret = -ENOMEM; meye.mchip_dev = pcidev; - meye.video_dev = video_device_alloc(); - if (!meye.video_dev) { - printk(KERN_ERR "meye: video_device_alloc() failed!\n"); + meye.vdev = video_device_alloc(); + if (!meye.vdev) { + v4l2_err(v4l2_dev, "video_device_alloc() failed!\n"); goto outnotdev; } meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE); if (!meye.grab_temp) { - printk(KERN_ERR "meye: grab buffer allocation failed\n"); + v4l2_err(v4l2_dev, "grab buffer allocation failed\n"); goto outvmalloc; } spin_lock_init(&meye.grabq_lock); if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL)) { - printk(KERN_ERR "meye: fifo allocation failed\n"); + v4l2_err(v4l2_dev, "fifo allocation failed\n"); goto outkfifoalloc1; } spin_lock_init(&meye.doneq_lock); if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL)) { - printk(KERN_ERR "meye: fifo allocation failed\n"); + v4l2_err(v4l2_dev, "fifo allocation failed\n"); goto outkfifoalloc2; } - memcpy(meye.video_dev, &meye_template, sizeof(meye_template)); - meye.video_dev->parent = &meye.mchip_dev->dev; + memcpy(meye.vdev, &meye_template, sizeof(meye_template)); + meye.vdev->v4l2_dev = &meye.v4l2_dev; ret = -EIO; if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) { - printk(KERN_ERR "meye: unable to power on the camera\n"); - printk(KERN_ERR "meye: did you enable the camera in " + v4l2_err(v4l2_dev, "meye: unable to power on the camera\n"); + v4l2_err(v4l2_dev, "meye: did you enable the camera in " "sonypi using the module options ?\n"); goto outsonypienable; } if ((ret = pci_enable_device(meye.mchip_dev))) { - printk(KERN_ERR "meye: pci_enable_device failed\n"); + v4l2_err(v4l2_dev, "meye: pci_enable_device failed\n"); goto outenabledev; } mchip_adr = pci_resource_start(meye.mchip_dev,0); if (!mchip_adr) { - printk(KERN_ERR "meye: mchip has no device base address\n"); + v4l2_err(v4l2_dev, "meye: mchip has no device base address\n"); goto outregions; } if (!request_mem_region(pci_resource_start(meye.mchip_dev, 0), pci_resource_len(meye.mchip_dev, 0), "meye")) { - printk(KERN_ERR "meye: request_mem_region failed\n"); + v4l2_err(v4l2_dev, "meye: request_mem_region failed\n"); goto outregions; } meye.mchip_mmregs = ioremap(mchip_adr, MCHIP_MM_REGS); if (!meye.mchip_mmregs) { - printk(KERN_ERR "meye: ioremap failed\n"); + v4l2_err(v4l2_dev, "meye: ioremap failed\n"); goto outremap; } meye.mchip_irq = pcidev->irq; if (request_irq(meye.mchip_irq, meye_irq, IRQF_DISABLED | IRQF_SHARED, "meye", meye_irq)) { - printk(KERN_ERR "meye: request_irq failed\n"); + v4l2_err(v4l2_dev, "request_irq failed\n"); goto outreqirq; } @@ -1824,21 +1831,18 @@ static int __devinit meye_probe(struct pci_dev *pcidev, msleep(1); mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK); - if (video_register_device(meye.video_dev, VFL_TYPE_GRABBER, + if (video_register_device(meye.vdev, VFL_TYPE_GRABBER, video_nr) < 0) { - printk(KERN_ERR "meye: video_register_device failed\n"); + v4l2_err(v4l2_dev, "video_register_device failed\n"); goto outvideoreg; } mutex_init(&meye.lock); init_waitqueue_head(&meye.proc_list); - meye.picture.depth = 16; - meye.picture.palette = VIDEO_PALETTE_YUV422; - meye.picture.brightness = 32 << 10; - meye.picture.hue = 32 << 10; - meye.picture.colour = 32 << 10; - meye.picture.contrast = 32 << 10; - meye.picture.whiteness = 0; + meye.brightness = 32 << 10; + meye.hue = 32 << 10; + meye.colour = 32 << 10; + meye.contrast = 32 << 10; meye.params.subsample = 0; meye.params.quality = 8; meye.params.sharpness = 32; @@ -1854,9 +1858,9 @@ static int __devinit meye_probe(struct pci_dev *pcidev, sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE, 0); sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAAGC, 48); - printk(KERN_INFO "meye: Motion Eye Camera Driver v%s.\n", + v4l2_info(v4l2_dev, "Motion Eye Camera Driver v%s.\n", MEYE_DRIVER_VERSION); - printk(KERN_INFO "meye: mchip KL5A72002 rev. %d, base %lx, irq %d\n", + v4l2_info(v4l2_dev, "mchip KL5A72002 rev. %d, base %lx, irq %d\n", meye.mchip_dev->revision, mchip_adr, meye.mchip_irq); return 0; @@ -1879,14 +1883,14 @@ outkfifoalloc2: outkfifoalloc1: vfree(meye.grab_temp); outvmalloc: - video_device_release(meye.video_dev); + video_device_release(meye.vdev); outnotdev: return ret; } static void __devexit meye_remove(struct pci_dev *pcidev) { - video_unregister_device(meye.video_dev); + video_unregister_device(meye.vdev); mchip_hic_stop(); diff --git a/drivers/media/video/meye.h b/drivers/media/video/meye.h index 1321ad5d6597..4bdeb03f1644 100644 --- a/drivers/media/video/meye.h +++ b/drivers/media/video/meye.h @@ -31,7 +31,7 @@ #define _MEYE_PRIV_H_ #define MEYE_DRIVER_MAJORVERSION 1 -#define MEYE_DRIVER_MINORVERSION 13 +#define MEYE_DRIVER_MINORVERSION 14 #define MEYE_DRIVER_VERSION __stringify(MEYE_DRIVER_MAJORVERSION) "." \ __stringify(MEYE_DRIVER_MINORVERSION) @@ -289,6 +289,7 @@ struct meye_grab_buffer { /* Motion Eye device structure */ struct meye { + struct v4l2_device v4l2_dev; /* Main v4l2_device struct */ struct pci_dev *mchip_dev; /* pci device */ u8 mchip_irq; /* irq */ u8 mchip_mode; /* actual mchip mode: HIC_MODE... */ @@ -308,8 +309,11 @@ struct meye { struct kfifo doneq; /* queue for grabbed buffers */ spinlock_t doneq_lock; /* lock protecting the queue */ wait_queue_head_t proc_list; /* wait queue */ - struct video_device *video_dev; /* video device parameters */ - struct video_picture picture; /* video picture parameters */ + struct video_device *vdev; /* video device parameters */ + u16 brightness; + u16 hue; + u16 contrast; + u16 colour; struct meye_params params; /* additional parameters */ unsigned long in_use; /* set to 1 if the device is in use */ #ifdef CONFIG_PM diff --git a/include/linux/meye.h b/include/linux/meye.h index 12010ace1f04..0dd49954f746 100644 --- a/include/linux/meye.h +++ b/include/linux/meye.h @@ -44,17 +44,17 @@ struct meye_params { }; /* query the extended parameters */ -#define MEYEIOC_G_PARAMS _IOR ('v', BASE_VIDIOCPRIVATE+0, struct meye_params) +#define MEYEIOC_G_PARAMS _IOR ('v', BASE_VIDIOC_PRIVATE+0, struct meye_params) /* set the extended parameters */ -#define MEYEIOC_S_PARAMS _IOW ('v', BASE_VIDIOCPRIVATE+1, struct meye_params) +#define MEYEIOC_S_PARAMS _IOW ('v', BASE_VIDIOC_PRIVATE+1, struct meye_params) /* queue a buffer for mjpeg capture */ -#define MEYEIOC_QBUF_CAPT _IOW ('v', BASE_VIDIOCPRIVATE+2, int) +#define MEYEIOC_QBUF_CAPT _IOW ('v', BASE_VIDIOC_PRIVATE+2, int) /* sync a previously queued mjpeg buffer */ -#define MEYEIOC_SYNC _IOWR('v', BASE_VIDIOCPRIVATE+3, int) +#define MEYEIOC_SYNC _IOWR('v', BASE_VIDIOC_PRIVATE+3, int) /* get a still uncompressed snapshot */ -#define MEYEIOC_STILLCAPT _IO ('v', BASE_VIDIOCPRIVATE+4) +#define MEYEIOC_STILLCAPT _IO ('v', BASE_VIDIOC_PRIVATE+4) /* get a jpeg compressed snapshot */ -#define MEYEIOC_STILLJCAPT _IOR ('v', BASE_VIDIOCPRIVATE+5, int) +#define MEYEIOC_STILLJCAPT _IOR ('v', BASE_VIDIOC_PRIVATE+5, int) /* V4L2 private controls */ #define V4L2_CID_AGC V4L2_CID_PRIVATE_BASE