Commit 51270617a52793c423ef68ddd3f18745e9abd15b
Committed by
Mauro Carvalho Chehab
1 parent
c1f2b0f29e
Exists in
master
and in
39 other branches
V4L/DVB: meye: remove last V4L1 remnants from the code and add v4l2_device
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Showing 4 changed files with 55 additions and 47 deletions Side-by-side Diff
drivers/media/video/Kconfig
... | ... | @@ -740,7 +740,7 @@ |
740 | 740 | |
741 | 741 | config VIDEO_MEYE |
742 | 742 | tristate "Sony Vaio Picturebook Motion Eye Video For Linux" |
743 | - depends on PCI && SONY_LAPTOP && VIDEO_V4L1 | |
743 | + depends on PCI && SONY_LAPTOP && VIDEO_V4L2 | |
744 | 744 | ---help--- |
745 | 745 | This is the video4linux driver for the Motion Eye camera found |
746 | 746 | in the Vaio Picturebook laptops. Please read the material in |
drivers/media/video/meye.c
... | ... | @@ -30,9 +30,10 @@ |
30 | 30 | #include <linux/pci.h> |
31 | 31 | #include <linux/sched.h> |
32 | 32 | #include <linux/init.h> |
33 | -#include <linux/videodev.h> | |
34 | 33 | #include <linux/gfp.h> |
34 | +#include <linux/videodev2.h> | |
35 | 35 | #include <media/v4l2-common.h> |
36 | +#include <media/v4l2-device.h> | |
36 | 37 | #include <media/v4l2-ioctl.h> |
37 | 38 | #include <asm/uaccess.h> |
38 | 39 | #include <asm/io.h> |
39 | 40 | |
40 | 41 | |
41 | 42 | |
... | ... | @@ -1168,22 +1169,22 @@ |
1168 | 1169 | case V4L2_CID_BRIGHTNESS: |
1169 | 1170 | sony_pic_camera_command( |
1170 | 1171 | SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, c->value); |
1171 | - meye.picture.brightness = c->value << 10; | |
1172 | + meye.brightness = c->value << 10; | |
1172 | 1173 | break; |
1173 | 1174 | case V4L2_CID_HUE: |
1174 | 1175 | sony_pic_camera_command( |
1175 | 1176 | SONY_PIC_COMMAND_SETCAMERAHUE, c->value); |
1176 | - meye.picture.hue = c->value << 10; | |
1177 | + meye.hue = c->value << 10; | |
1177 | 1178 | break; |
1178 | 1179 | case V4L2_CID_CONTRAST: |
1179 | 1180 | sony_pic_camera_command( |
1180 | 1181 | SONY_PIC_COMMAND_SETCAMERACONTRAST, c->value); |
1181 | - meye.picture.contrast = c->value << 10; | |
1182 | + meye.contrast = c->value << 10; | |
1182 | 1183 | break; |
1183 | 1184 | case V4L2_CID_SATURATION: |
1184 | 1185 | sony_pic_camera_command( |
1185 | 1186 | SONY_PIC_COMMAND_SETCAMERACOLOR, c->value); |
1186 | - meye.picture.colour = c->value << 10; | |
1187 | + meye.colour = c->value << 10; | |
1187 | 1188 | break; |
1188 | 1189 | case V4L2_CID_AGC: |
1189 | 1190 | sony_pic_camera_command( |
1190 | 1191 | |
1191 | 1192 | |
1192 | 1193 | |
... | ... | @@ -1221,16 +1222,16 @@ |
1221 | 1222 | mutex_lock(&meye.lock); |
1222 | 1223 | switch (c->id) { |
1223 | 1224 | case V4L2_CID_BRIGHTNESS: |
1224 | - c->value = meye.picture.brightness >> 10; | |
1225 | + c->value = meye.brightness >> 10; | |
1225 | 1226 | break; |
1226 | 1227 | case V4L2_CID_HUE: |
1227 | - c->value = meye.picture.hue >> 10; | |
1228 | + c->value = meye.hue >> 10; | |
1228 | 1229 | break; |
1229 | 1230 | case V4L2_CID_CONTRAST: |
1230 | - c->value = meye.picture.contrast >> 10; | |
1231 | + c->value = meye.contrast >> 10; | |
1231 | 1232 | break; |
1232 | 1233 | case V4L2_CID_SATURATION: |
1233 | - c->value = meye.picture.colour >> 10; | |
1234 | + c->value = meye.colour >> 10; | |
1234 | 1235 | break; |
1235 | 1236 | case V4L2_CID_AGC: |
1236 | 1237 | c->value = meye.params.agc; |
... | ... | @@ -1729,6 +1730,7 @@ |
1729 | 1730 | static int __devinit meye_probe(struct pci_dev *pcidev, |
1730 | 1731 | const struct pci_device_id *ent) |
1731 | 1732 | { |
1733 | + struct v4l2_device *v4l2_dev = &meye.v4l2_dev; | |
1732 | 1734 | int ret = -EBUSY; |
1733 | 1735 | unsigned long mchip_adr; |
1734 | 1736 | |
1735 | 1737 | |
1736 | 1738 | |
1737 | 1739 | |
1738 | 1740 | |
1739 | 1741 | |
1740 | 1742 | |
1741 | 1743 | |
1742 | 1744 | |
1743 | 1745 | |
1744 | 1746 | |
1745 | 1747 | |
... | ... | @@ -1737,70 +1739,75 @@ |
1737 | 1739 | goto outnotdev; |
1738 | 1740 | } |
1739 | 1741 | |
1742 | + ret = v4l2_device_register(&pcidev->dev, v4l2_dev); | |
1743 | + if (ret < 0) { | |
1744 | + v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); | |
1745 | + return ret; | |
1746 | + } | |
1740 | 1747 | ret = -ENOMEM; |
1741 | 1748 | meye.mchip_dev = pcidev; |
1742 | - meye.video_dev = video_device_alloc(); | |
1743 | - if (!meye.video_dev) { | |
1744 | - printk(KERN_ERR "meye: video_device_alloc() failed!\n"); | |
1749 | + meye.vdev = video_device_alloc(); | |
1750 | + if (!meye.vdev) { | |
1751 | + v4l2_err(v4l2_dev, "video_device_alloc() failed!\n"); | |
1745 | 1752 | goto outnotdev; |
1746 | 1753 | } |
1747 | 1754 | |
1748 | 1755 | meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE); |
1749 | 1756 | if (!meye.grab_temp) { |
1750 | - printk(KERN_ERR "meye: grab buffer allocation failed\n"); | |
1757 | + v4l2_err(v4l2_dev, "grab buffer allocation failed\n"); | |
1751 | 1758 | goto outvmalloc; |
1752 | 1759 | } |
1753 | 1760 | |
1754 | 1761 | spin_lock_init(&meye.grabq_lock); |
1755 | 1762 | if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS, |
1756 | 1763 | GFP_KERNEL)) { |
1757 | - printk(KERN_ERR "meye: fifo allocation failed\n"); | |
1764 | + v4l2_err(v4l2_dev, "fifo allocation failed\n"); | |
1758 | 1765 | goto outkfifoalloc1; |
1759 | 1766 | } |
1760 | 1767 | spin_lock_init(&meye.doneq_lock); |
1761 | 1768 | if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS, |
1762 | 1769 | GFP_KERNEL)) { |
1763 | - printk(KERN_ERR "meye: fifo allocation failed\n"); | |
1770 | + v4l2_err(v4l2_dev, "fifo allocation failed\n"); | |
1764 | 1771 | goto outkfifoalloc2; |
1765 | 1772 | } |
1766 | 1773 | |
1767 | - memcpy(meye.video_dev, &meye_template, sizeof(meye_template)); | |
1768 | - meye.video_dev->parent = &meye.mchip_dev->dev; | |
1774 | + memcpy(meye.vdev, &meye_template, sizeof(meye_template)); | |
1775 | + meye.vdev->v4l2_dev = &meye.v4l2_dev; | |
1769 | 1776 | |
1770 | 1777 | ret = -EIO; |
1771 | 1778 | if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) { |
1772 | - printk(KERN_ERR "meye: unable to power on the camera\n"); | |
1773 | - printk(KERN_ERR "meye: did you enable the camera in " | |
1779 | + v4l2_err(v4l2_dev, "meye: unable to power on the camera\n"); | |
1780 | + v4l2_err(v4l2_dev, "meye: did you enable the camera in " | |
1774 | 1781 | "sonypi using the module options ?\n"); |
1775 | 1782 | goto outsonypienable; |
1776 | 1783 | } |
1777 | 1784 | |
1778 | 1785 | if ((ret = pci_enable_device(meye.mchip_dev))) { |
1779 | - printk(KERN_ERR "meye: pci_enable_device failed\n"); | |
1786 | + v4l2_err(v4l2_dev, "meye: pci_enable_device failed\n"); | |
1780 | 1787 | goto outenabledev; |
1781 | 1788 | } |
1782 | 1789 | |
1783 | 1790 | mchip_adr = pci_resource_start(meye.mchip_dev,0); |
1784 | 1791 | if (!mchip_adr) { |
1785 | - printk(KERN_ERR "meye: mchip has no device base address\n"); | |
1792 | + v4l2_err(v4l2_dev, "meye: mchip has no device base address\n"); | |
1786 | 1793 | goto outregions; |
1787 | 1794 | } |
1788 | 1795 | if (!request_mem_region(pci_resource_start(meye.mchip_dev, 0), |
1789 | 1796 | pci_resource_len(meye.mchip_dev, 0), |
1790 | 1797 | "meye")) { |
1791 | - printk(KERN_ERR "meye: request_mem_region failed\n"); | |
1798 | + v4l2_err(v4l2_dev, "meye: request_mem_region failed\n"); | |
1792 | 1799 | goto outregions; |
1793 | 1800 | } |
1794 | 1801 | meye.mchip_mmregs = ioremap(mchip_adr, MCHIP_MM_REGS); |
1795 | 1802 | if (!meye.mchip_mmregs) { |
1796 | - printk(KERN_ERR "meye: ioremap failed\n"); | |
1803 | + v4l2_err(v4l2_dev, "meye: ioremap failed\n"); | |
1797 | 1804 | goto outremap; |
1798 | 1805 | } |
1799 | 1806 | |
1800 | 1807 | meye.mchip_irq = pcidev->irq; |
1801 | 1808 | if (request_irq(meye.mchip_irq, meye_irq, |
1802 | 1809 | IRQF_DISABLED | IRQF_SHARED, "meye", meye_irq)) { |
1803 | - printk(KERN_ERR "meye: request_irq failed\n"); | |
1810 | + v4l2_err(v4l2_dev, "request_irq failed\n"); | |
1804 | 1811 | goto outreqirq; |
1805 | 1812 | } |
1806 | 1813 | |
1807 | 1814 | |
1808 | 1815 | |
... | ... | @@ -1824,21 +1831,18 @@ |
1824 | 1831 | msleep(1); |
1825 | 1832 | mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK); |
1826 | 1833 | |
1827 | - if (video_register_device(meye.video_dev, VFL_TYPE_GRABBER, | |
1834 | + if (video_register_device(meye.vdev, VFL_TYPE_GRABBER, | |
1828 | 1835 | video_nr) < 0) { |
1829 | - printk(KERN_ERR "meye: video_register_device failed\n"); | |
1836 | + v4l2_err(v4l2_dev, "video_register_device failed\n"); | |
1830 | 1837 | goto outvideoreg; |
1831 | 1838 | } |
1832 | 1839 | |
1833 | 1840 | mutex_init(&meye.lock); |
1834 | 1841 | init_waitqueue_head(&meye.proc_list); |
1835 | - meye.picture.depth = 16; | |
1836 | - meye.picture.palette = VIDEO_PALETTE_YUV422; | |
1837 | - meye.picture.brightness = 32 << 10; | |
1838 | - meye.picture.hue = 32 << 10; | |
1839 | - meye.picture.colour = 32 << 10; | |
1840 | - meye.picture.contrast = 32 << 10; | |
1841 | - meye.picture.whiteness = 0; | |
1842 | + meye.brightness = 32 << 10; | |
1843 | + meye.hue = 32 << 10; | |
1844 | + meye.colour = 32 << 10; | |
1845 | + meye.contrast = 32 << 10; | |
1842 | 1846 | meye.params.subsample = 0; |
1843 | 1847 | meye.params.quality = 8; |
1844 | 1848 | meye.params.sharpness = 32; |
1845 | 1849 | |
... | ... | @@ -1854,9 +1858,9 @@ |
1854 | 1858 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE, 0); |
1855 | 1859 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAAGC, 48); |
1856 | 1860 | |
1857 | - printk(KERN_INFO "meye: Motion Eye Camera Driver v%s.\n", | |
1861 | + v4l2_info(v4l2_dev, "Motion Eye Camera Driver v%s.\n", | |
1858 | 1862 | MEYE_DRIVER_VERSION); |
1859 | - printk(KERN_INFO "meye: mchip KL5A72002 rev. %d, base %lx, irq %d\n", | |
1863 | + v4l2_info(v4l2_dev, "mchip KL5A72002 rev. %d, base %lx, irq %d\n", | |
1860 | 1864 | meye.mchip_dev->revision, mchip_adr, meye.mchip_irq); |
1861 | 1865 | |
1862 | 1866 | return 0; |
1863 | 1867 | |
... | ... | @@ -1879,14 +1883,14 @@ |
1879 | 1883 | outkfifoalloc1: |
1880 | 1884 | vfree(meye.grab_temp); |
1881 | 1885 | outvmalloc: |
1882 | - video_device_release(meye.video_dev); | |
1886 | + video_device_release(meye.vdev); | |
1883 | 1887 | outnotdev: |
1884 | 1888 | return ret; |
1885 | 1889 | } |
1886 | 1890 | |
1887 | 1891 | static void __devexit meye_remove(struct pci_dev *pcidev) |
1888 | 1892 | { |
1889 | - video_unregister_device(meye.video_dev); | |
1893 | + video_unregister_device(meye.vdev); | |
1890 | 1894 | |
1891 | 1895 | mchip_hic_stop(); |
1892 | 1896 |
drivers/media/video/meye.h
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | #define _MEYE_PRIV_H_ |
32 | 32 | |
33 | 33 | #define MEYE_DRIVER_MAJORVERSION 1 |
34 | -#define MEYE_DRIVER_MINORVERSION 13 | |
34 | +#define MEYE_DRIVER_MINORVERSION 14 | |
35 | 35 | |
36 | 36 | #define MEYE_DRIVER_VERSION __stringify(MEYE_DRIVER_MAJORVERSION) "." \ |
37 | 37 | __stringify(MEYE_DRIVER_MINORVERSION) |
... | ... | @@ -289,6 +289,7 @@ |
289 | 289 | |
290 | 290 | /* Motion Eye device structure */ |
291 | 291 | struct meye { |
292 | + struct v4l2_device v4l2_dev; /* Main v4l2_device struct */ | |
292 | 293 | struct pci_dev *mchip_dev; /* pci device */ |
293 | 294 | u8 mchip_irq; /* irq */ |
294 | 295 | u8 mchip_mode; /* actual mchip mode: HIC_MODE... */ |
... | ... | @@ -308,8 +309,11 @@ |
308 | 309 | struct kfifo doneq; /* queue for grabbed buffers */ |
309 | 310 | spinlock_t doneq_lock; /* lock protecting the queue */ |
310 | 311 | wait_queue_head_t proc_list; /* wait queue */ |
311 | - struct video_device *video_dev; /* video device parameters */ | |
312 | - struct video_picture picture; /* video picture parameters */ | |
312 | + struct video_device *vdev; /* video device parameters */ | |
313 | + u16 brightness; | |
314 | + u16 hue; | |
315 | + u16 contrast; | |
316 | + u16 colour; | |
313 | 317 | struct meye_params params; /* additional parameters */ |
314 | 318 | unsigned long in_use; /* set to 1 if the device is in use */ |
315 | 319 | #ifdef CONFIG_PM |
include/linux/meye.h
... | ... | @@ -44,17 +44,17 @@ |
44 | 44 | }; |
45 | 45 | |
46 | 46 | /* query the extended parameters */ |
47 | -#define MEYEIOC_G_PARAMS _IOR ('v', BASE_VIDIOCPRIVATE+0, struct meye_params) | |
47 | +#define MEYEIOC_G_PARAMS _IOR ('v', BASE_VIDIOC_PRIVATE+0, struct meye_params) | |
48 | 48 | /* set the extended parameters */ |
49 | -#define MEYEIOC_S_PARAMS _IOW ('v', BASE_VIDIOCPRIVATE+1, struct meye_params) | |
49 | +#define MEYEIOC_S_PARAMS _IOW ('v', BASE_VIDIOC_PRIVATE+1, struct meye_params) | |
50 | 50 | /* queue a buffer for mjpeg capture */ |
51 | -#define MEYEIOC_QBUF_CAPT _IOW ('v', BASE_VIDIOCPRIVATE+2, int) | |
51 | +#define MEYEIOC_QBUF_CAPT _IOW ('v', BASE_VIDIOC_PRIVATE+2, int) | |
52 | 52 | /* sync a previously queued mjpeg buffer */ |
53 | -#define MEYEIOC_SYNC _IOWR('v', BASE_VIDIOCPRIVATE+3, int) | |
53 | +#define MEYEIOC_SYNC _IOWR('v', BASE_VIDIOC_PRIVATE+3, int) | |
54 | 54 | /* get a still uncompressed snapshot */ |
55 | -#define MEYEIOC_STILLCAPT _IO ('v', BASE_VIDIOCPRIVATE+4) | |
55 | +#define MEYEIOC_STILLCAPT _IO ('v', BASE_VIDIOC_PRIVATE+4) | |
56 | 56 | /* get a jpeg compressed snapshot */ |
57 | -#define MEYEIOC_STILLJCAPT _IOR ('v', BASE_VIDIOCPRIVATE+5, int) | |
57 | +#define MEYEIOC_STILLJCAPT _IOR ('v', BASE_VIDIOC_PRIVATE+5, int) | |
58 | 58 | |
59 | 59 | /* V4L2 private controls */ |
60 | 60 | #define V4L2_CID_AGC V4L2_CID_PRIVATE_BASE |