aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/meye.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-03-22 04:22:34 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:52:36 -0400
commit51270617a52793c423ef68ddd3f18745e9abd15b (patch)
treea3e3f622458f1423b6c6d7fcaeb7f3e253a37066 /drivers/media/video/meye.c
parentc1f2b0f29e51cf44eb6addff1b90f99988055a92 (diff)
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>
Diffstat (limited to 'drivers/media/video/meye.c')
-rw-r--r--drivers/media/video/meye.c78
1 files changed, 41 insertions, 37 deletions
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 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/videodev.h>
34#include <linux/gfp.h> 33#include <linux/gfp.h>
34#include <linux/videodev2.h>
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <media/v4l2-device.h>
36#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38#include <asm/io.h> 39#include <asm/io.h>
@@ -1168,22 +1169,22 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)
1168 case V4L2_CID_BRIGHTNESS: 1169 case V4L2_CID_BRIGHTNESS:
1169 sony_pic_camera_command( 1170 sony_pic_camera_command(
1170 SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, c->value); 1171 SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, c->value);
1171 meye.picture.brightness = c->value << 10; 1172 meye.brightness = c->value << 10;
1172 break; 1173 break;
1173 case V4L2_CID_HUE: 1174 case V4L2_CID_HUE:
1174 sony_pic_camera_command( 1175 sony_pic_camera_command(
1175 SONY_PIC_COMMAND_SETCAMERAHUE, c->value); 1176 SONY_PIC_COMMAND_SETCAMERAHUE, c->value);
1176 meye.picture.hue = c->value << 10; 1177 meye.hue = c->value << 10;
1177 break; 1178 break;
1178 case V4L2_CID_CONTRAST: 1179 case V4L2_CID_CONTRAST:
1179 sony_pic_camera_command( 1180 sony_pic_camera_command(
1180 SONY_PIC_COMMAND_SETCAMERACONTRAST, c->value); 1181 SONY_PIC_COMMAND_SETCAMERACONTRAST, c->value);
1181 meye.picture.contrast = c->value << 10; 1182 meye.contrast = c->value << 10;
1182 break; 1183 break;
1183 case V4L2_CID_SATURATION: 1184 case V4L2_CID_SATURATION:
1184 sony_pic_camera_command( 1185 sony_pic_camera_command(
1185 SONY_PIC_COMMAND_SETCAMERACOLOR, c->value); 1186 SONY_PIC_COMMAND_SETCAMERACOLOR, c->value);
1186 meye.picture.colour = c->value << 10; 1187 meye.colour = c->value << 10;
1187 break; 1188 break;
1188 case V4L2_CID_AGC: 1189 case V4L2_CID_AGC:
1189 sony_pic_camera_command( 1190 sony_pic_camera_command(
@@ -1221,16 +1222,16 @@ static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *c)
1221 mutex_lock(&meye.lock); 1222 mutex_lock(&meye.lock);
1222 switch (c->id) { 1223 switch (c->id) {
1223 case V4L2_CID_BRIGHTNESS: 1224 case V4L2_CID_BRIGHTNESS:
1224 c->value = meye.picture.brightness >> 10; 1225 c->value = meye.brightness >> 10;
1225 break; 1226 break;
1226 case V4L2_CID_HUE: 1227 case V4L2_CID_HUE:
1227 c->value = meye.picture.hue >> 10; 1228 c->value = meye.hue >> 10;
1228 break; 1229 break;
1229 case V4L2_CID_CONTRAST: 1230 case V4L2_CID_CONTRAST:
1230 c->value = meye.picture.contrast >> 10; 1231 c->value = meye.contrast >> 10;
1231 break; 1232 break;
1232 case V4L2_CID_SATURATION: 1233 case V4L2_CID_SATURATION:
1233 c->value = meye.picture.colour >> 10; 1234 c->value = meye.colour >> 10;
1234 break; 1235 break;
1235 case V4L2_CID_AGC: 1236 case V4L2_CID_AGC:
1236 c->value = meye.params.agc; 1237 c->value = meye.params.agc;
@@ -1729,6 +1730,7 @@ static int meye_resume(struct pci_dev *pdev)
1729static int __devinit meye_probe(struct pci_dev *pcidev, 1730static int __devinit meye_probe(struct pci_dev *pcidev,
1730 const struct pci_device_id *ent) 1731 const struct pci_device_id *ent)
1731{ 1732{
1733 struct v4l2_device *v4l2_dev = &meye.v4l2_dev;
1732 int ret = -EBUSY; 1734 int ret = -EBUSY;
1733 unsigned long mchip_adr; 1735 unsigned long mchip_adr;
1734 1736
@@ -1737,70 +1739,75 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1737 goto outnotdev; 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 ret = -ENOMEM; 1747 ret = -ENOMEM;
1741 meye.mchip_dev = pcidev; 1748 meye.mchip_dev = pcidev;
1742 meye.video_dev = video_device_alloc(); 1749 meye.vdev = video_device_alloc();
1743 if (!meye.video_dev) { 1750 if (!meye.vdev) {
1744 printk(KERN_ERR "meye: video_device_alloc() failed!\n"); 1751 v4l2_err(v4l2_dev, "video_device_alloc() failed!\n");
1745 goto outnotdev; 1752 goto outnotdev;
1746 } 1753 }
1747 1754
1748 meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE); 1755 meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
1749 if (!meye.grab_temp) { 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 goto outvmalloc; 1758 goto outvmalloc;
1752 } 1759 }
1753 1760
1754 spin_lock_init(&meye.grabq_lock); 1761 spin_lock_init(&meye.grabq_lock);
1755 if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS, 1762 if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS,
1756 GFP_KERNEL)) { 1763 GFP_KERNEL)) {
1757 printk(KERN_ERR "meye: fifo allocation failed\n"); 1764 v4l2_err(v4l2_dev, "fifo allocation failed\n");
1758 goto outkfifoalloc1; 1765 goto outkfifoalloc1;
1759 } 1766 }
1760 spin_lock_init(&meye.doneq_lock); 1767 spin_lock_init(&meye.doneq_lock);
1761 if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS, 1768 if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS,
1762 GFP_KERNEL)) { 1769 GFP_KERNEL)) {
1763 printk(KERN_ERR "meye: fifo allocation failed\n"); 1770 v4l2_err(v4l2_dev, "fifo allocation failed\n");
1764 goto outkfifoalloc2; 1771 goto outkfifoalloc2;
1765 } 1772 }
1766 1773
1767 memcpy(meye.video_dev, &meye_template, sizeof(meye_template)); 1774 memcpy(meye.vdev, &meye_template, sizeof(meye_template));
1768 meye.video_dev->parent = &meye.mchip_dev->dev; 1775 meye.vdev->v4l2_dev = &meye.v4l2_dev;
1769 1776
1770 ret = -EIO; 1777 ret = -EIO;
1771 if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) { 1778 if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) {
1772 printk(KERN_ERR "meye: unable to power on the camera\n"); 1779 v4l2_err(v4l2_dev, "meye: unable to power on the camera\n");
1773 printk(KERN_ERR "meye: did you enable the camera in " 1780 v4l2_err(v4l2_dev, "meye: did you enable the camera in "
1774 "sonypi using the module options ?\n"); 1781 "sonypi using the module options ?\n");
1775 goto outsonypienable; 1782 goto outsonypienable;
1776 } 1783 }
1777 1784
1778 if ((ret = pci_enable_device(meye.mchip_dev))) { 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 goto outenabledev; 1787 goto outenabledev;
1781 } 1788 }
1782 1789
1783 mchip_adr = pci_resource_start(meye.mchip_dev,0); 1790 mchip_adr = pci_resource_start(meye.mchip_dev,0);
1784 if (!mchip_adr) { 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 goto outregions; 1793 goto outregions;
1787 } 1794 }
1788 if (!request_mem_region(pci_resource_start(meye.mchip_dev, 0), 1795 if (!request_mem_region(pci_resource_start(meye.mchip_dev, 0),
1789 pci_resource_len(meye.mchip_dev, 0), 1796 pci_resource_len(meye.mchip_dev, 0),
1790 "meye")) { 1797 "meye")) {
1791 printk(KERN_ERR "meye: request_mem_region failed\n"); 1798 v4l2_err(v4l2_dev, "meye: request_mem_region failed\n");
1792 goto outregions; 1799 goto outregions;
1793 } 1800 }
1794 meye.mchip_mmregs = ioremap(mchip_adr, MCHIP_MM_REGS); 1801 meye.mchip_mmregs = ioremap(mchip_adr, MCHIP_MM_REGS);
1795 if (!meye.mchip_mmregs) { 1802 if (!meye.mchip_mmregs) {
1796 printk(KERN_ERR "meye: ioremap failed\n"); 1803 v4l2_err(v4l2_dev, "meye: ioremap failed\n");
1797 goto outremap; 1804 goto outremap;
1798 } 1805 }
1799 1806
1800 meye.mchip_irq = pcidev->irq; 1807 meye.mchip_irq = pcidev->irq;
1801 if (request_irq(meye.mchip_irq, meye_irq, 1808 if (request_irq(meye.mchip_irq, meye_irq,
1802 IRQF_DISABLED | IRQF_SHARED, "meye", meye_irq)) { 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 goto outreqirq; 1811 goto outreqirq;
1805 } 1812 }
1806 1813
@@ -1824,21 +1831,18 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1824 msleep(1); 1831 msleep(1);
1825 mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK); 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 video_nr) < 0) { 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 goto outvideoreg; 1837 goto outvideoreg;
1831 } 1838 }
1832 1839
1833 mutex_init(&meye.lock); 1840 mutex_init(&meye.lock);
1834 init_waitqueue_head(&meye.proc_list); 1841 init_waitqueue_head(&meye.proc_list);
1835 meye.picture.depth = 16; 1842 meye.brightness = 32 << 10;
1836 meye.picture.palette = VIDEO_PALETTE_YUV422; 1843 meye.hue = 32 << 10;
1837 meye.picture.brightness = 32 << 10; 1844 meye.colour = 32 << 10;
1838 meye.picture.hue = 32 << 10; 1845 meye.contrast = 32 << 10;
1839 meye.picture.colour = 32 << 10;
1840 meye.picture.contrast = 32 << 10;
1841 meye.picture.whiteness = 0;
1842 meye.params.subsample = 0; 1846 meye.params.subsample = 0;
1843 meye.params.quality = 8; 1847 meye.params.quality = 8;
1844 meye.params.sharpness = 32; 1848 meye.params.sharpness = 32;
@@ -1854,9 +1858,9 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1854 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE, 0); 1858 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE, 0);
1855 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAAGC, 48); 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 MEYE_DRIVER_VERSION); 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 meye.mchip_dev->revision, mchip_adr, meye.mchip_irq); 1864 meye.mchip_dev->revision, mchip_adr, meye.mchip_irq);
1861 1865
1862 return 0; 1866 return 0;
@@ -1879,14 +1883,14 @@ outkfifoalloc2:
1879outkfifoalloc1: 1883outkfifoalloc1:
1880 vfree(meye.grab_temp); 1884 vfree(meye.grab_temp);
1881outvmalloc: 1885outvmalloc:
1882 video_device_release(meye.video_dev); 1886 video_device_release(meye.vdev);
1883outnotdev: 1887outnotdev:
1884 return ret; 1888 return ret;
1885} 1889}
1886 1890
1887static void __devexit meye_remove(struct pci_dev *pcidev) 1891static 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 mchip_hic_stop(); 1895 mchip_hic_stop();
1892 1896