diff options
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 79 |
1 files changed, 72 insertions, 7 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index a0c334672488..4abe6701a770 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -189,7 +189,7 @@ static void video_mux(struct em28xx *dev, int index) | |||
189 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route); | 189 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route); |
190 | } | 190 | } |
191 | 191 | ||
192 | em28xx_set_audio_source(dev); | 192 | em28xx_audio_analog_set(dev); |
193 | } | 193 | } |
194 | 194 | ||
195 | /* Usage lock check functions */ | 195 | /* Usage lock check functions */ |
@@ -830,6 +830,63 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
830 | return 0; | 830 | return 0; |
831 | } | 831 | } |
832 | 832 | ||
833 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
834 | static int em28xx_reg_len(int reg) | ||
835 | { | ||
836 | switch (reg) { | ||
837 | case AC97LSB_REG: | ||
838 | case HSCALELOW_REG: | ||
839 | case VSCALELOW_REG: | ||
840 | return 2; | ||
841 | default: | ||
842 | return 1; | ||
843 | } | ||
844 | } | ||
845 | |||
846 | static int vidioc_g_register(struct file *file, void *priv, | ||
847 | struct v4l2_register *reg) | ||
848 | { | ||
849 | struct em28xx_fh *fh = priv; | ||
850 | struct em28xx *dev = fh->dev; | ||
851 | int ret; | ||
852 | |||
853 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | ||
854 | return -EINVAL; | ||
855 | |||
856 | if (em28xx_reg_len(reg->reg) == 1) { | ||
857 | ret = em28xx_read_reg(dev, reg->reg); | ||
858 | if (ret < 0) | ||
859 | return ret; | ||
860 | |||
861 | reg->val = ret; | ||
862 | } else { | ||
863 | u64 val = 0; | ||
864 | ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, | ||
865 | reg->reg, (char *)&val, 2); | ||
866 | if (ret < 0) | ||
867 | return ret; | ||
868 | |||
869 | reg->val = cpu_to_le64((__u64)val); | ||
870 | } | ||
871 | |||
872 | return 0; | ||
873 | } | ||
874 | |||
875 | static int vidioc_s_register(struct file *file, void *priv, | ||
876 | struct v4l2_register *reg) | ||
877 | { | ||
878 | struct em28xx_fh *fh = priv; | ||
879 | struct em28xx *dev = fh->dev; | ||
880 | u64 buf; | ||
881 | |||
882 | buf = le64_to_cpu((__u64)reg->val); | ||
883 | |||
884 | return em28xx_write_regs(dev, reg->reg, (char *)&buf, | ||
885 | em28xx_reg_len(reg->reg)); | ||
886 | } | ||
887 | #endif | ||
888 | |||
889 | |||
833 | static int vidioc_cropcap(struct file *file, void *priv, | 890 | static int vidioc_cropcap(struct file *file, void *priv, |
834 | struct v4l2_cropcap *cc) | 891 | struct v4l2_cropcap *cc) |
835 | { | 892 | { |
@@ -1295,8 +1352,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
1295 | filp->private_data = fh; | 1352 | filp->private_data = fh; |
1296 | 1353 | ||
1297 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { | 1354 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { |
1298 | em28xx_set_alternate(dev); | ||
1299 | |||
1300 | dev->width = norm_maxw(dev); | 1355 | dev->width = norm_maxw(dev); |
1301 | dev->height = norm_maxh(dev); | 1356 | dev->height = norm_maxh(dev); |
1302 | dev->frame_size = dev->width * dev->height * 2; | 1357 | dev->frame_size = dev->width * dev->height * 2; |
@@ -1305,6 +1360,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
1305 | dev->hscale = 0; | 1360 | dev->hscale = 0; |
1306 | dev->vscale = 0; | 1361 | dev->vscale = 0; |
1307 | 1362 | ||
1363 | em28xx_set_alternate(dev); | ||
1308 | em28xx_capture_start(dev, 1); | 1364 | em28xx_capture_start(dev, 1); |
1309 | em28xx_resolution_set(dev); | 1365 | em28xx_resolution_set(dev); |
1310 | 1366 | ||
@@ -1730,6 +1786,10 @@ static const struct video_device em28xx_video_template = { | |||
1730 | .vidioc_s_tuner = vidioc_s_tuner, | 1786 | .vidioc_s_tuner = vidioc_s_tuner, |
1731 | .vidioc_g_frequency = vidioc_g_frequency, | 1787 | .vidioc_g_frequency = vidioc_g_frequency, |
1732 | .vidioc_s_frequency = vidioc_s_frequency, | 1788 | .vidioc_s_frequency = vidioc_s_frequency, |
1789 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1790 | .vidioc_g_register = vidioc_g_register, | ||
1791 | .vidioc_s_register = vidioc_s_register, | ||
1792 | #endif | ||
1733 | 1793 | ||
1734 | .tvnorms = V4L2_STD_ALL, | 1794 | .tvnorms = V4L2_STD_ALL, |
1735 | .current_norm = V4L2_STD_PAL, | 1795 | .current_norm = V4L2_STD_PAL, |
@@ -1752,6 +1812,10 @@ static struct video_device em28xx_radio_template = { | |||
1752 | .vidioc_s_ctrl = vidioc_s_ctrl, | 1812 | .vidioc_s_ctrl = vidioc_s_ctrl, |
1753 | .vidioc_g_frequency = vidioc_g_frequency, | 1813 | .vidioc_g_frequency = vidioc_g_frequency, |
1754 | .vidioc_s_frequency = vidioc_s_frequency, | 1814 | .vidioc_s_frequency = vidioc_s_frequency, |
1815 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1816 | .vidioc_g_register = vidioc_g_register, | ||
1817 | .vidioc_s_register = vidioc_s_register, | ||
1818 | #endif | ||
1755 | }; | 1819 | }; |
1756 | 1820 | ||
1757 | /******************************** usb interface *****************************************/ | 1821 | /******************************** usb interface *****************************************/ |
@@ -1796,10 +1860,10 @@ void em28xx_unregister_extension(struct em28xx_ops *ops) | |||
1796 | } | 1860 | } |
1797 | EXPORT_SYMBOL(em28xx_unregister_extension); | 1861 | EXPORT_SYMBOL(em28xx_unregister_extension); |
1798 | 1862 | ||
1799 | struct video_device *em28xx_vdev_init(struct em28xx *dev, | 1863 | static struct video_device *em28xx_vdev_init(struct em28xx *dev, |
1800 | const struct video_device *template, | 1864 | const struct video_device *template, |
1801 | const int type, | 1865 | const int type, |
1802 | const char *type_name) | 1866 | const char *type_name) |
1803 | { | 1867 | { |
1804 | struct video_device *vfd; | 1868 | struct video_device *vfd; |
1805 | 1869 | ||
@@ -2064,6 +2128,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2064 | snprintf(dev->name, 29, "em28xx #%d", nr); | 2128 | snprintf(dev->name, 29, "em28xx #%d", nr); |
2065 | dev->devno = nr; | 2129 | dev->devno = nr; |
2066 | dev->model = id->driver_info; | 2130 | dev->model = id->driver_info; |
2131 | dev->alt = -1; | ||
2067 | 2132 | ||
2068 | /* Checks if audio is provided by some interface */ | 2133 | /* Checks if audio is provided by some interface */ |
2069 | for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { | 2134 | for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { |