diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-02-06 07:00:41 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-02-18 09:15:14 -0500 |
commit | 1e7ad56f1fef94a7d8c1050bf3548d957fe67c01 (patch) | |
tree | 3ed254e7f3654307160de8942ee885a169fe8def /drivers/media/video | |
parent | 7463dda2ae868d3e0a6c98f65d6331481fc73ca3 (diff) |
V4L/DVB (7160): em28xx: Allow register dump/setting for debug
Adds vidioc_[g|s]_register handlers. This allows getting/setting register
from em28xx.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index c4126055bec3..4c836ad5cf41 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -830,6 +830,64 @@ 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 | |||
841 | return 2; | ||
842 | default: | ||
843 | return 1; | ||
844 | } | ||
845 | } | ||
846 | |||
847 | static int vidioc_g_register(struct file *file, void *priv, | ||
848 | struct v4l2_register *reg) | ||
849 | { | ||
850 | struct em28xx_fh *fh = priv; | ||
851 | struct em28xx *dev = fh->dev; | ||
852 | int ret; | ||
853 | |||
854 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | ||
855 | return -EINVAL; | ||
856 | |||
857 | if (em28xx_reg_len(reg->reg) == 1) { | ||
858 | ret = em28xx_read_reg(dev, reg->reg); | ||
859 | if (ret < 0) | ||
860 | return ret; | ||
861 | |||
862 | reg->val = ret; | ||
863 | } else { | ||
864 | u16 val; | ||
865 | ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, | ||
866 | reg->reg, (char *)&val, 2); | ||
867 | if (ret < 0) | ||
868 | return ret; | ||
869 | |||
870 | reg->val = val; | ||
871 | } | ||
872 | |||
873 | return 0; | ||
874 | } | ||
875 | |||
876 | static int vidioc_s_register(struct file *file, void *priv, | ||
877 | struct v4l2_register *reg) | ||
878 | { | ||
879 | struct em28xx_fh *fh = priv; | ||
880 | struct em28xx *dev = fh->dev; | ||
881 | u16 buf; | ||
882 | |||
883 | buf = be16_to_cpu((__u16)reg->val); | ||
884 | |||
885 | return em28xx_write_regs(dev, reg->reg, (char *)&buf, | ||
886 | em28xx_reg_len(reg->reg)); | ||
887 | } | ||
888 | #endif | ||
889 | |||
890 | |||
833 | static int vidioc_cropcap(struct file *file, void *priv, | 891 | static int vidioc_cropcap(struct file *file, void *priv, |
834 | struct v4l2_cropcap *cc) | 892 | struct v4l2_cropcap *cc) |
835 | { | 893 | { |
@@ -1730,6 +1788,10 @@ static const struct video_device em28xx_video_template = { | |||
1730 | .vidioc_s_tuner = vidioc_s_tuner, | 1788 | .vidioc_s_tuner = vidioc_s_tuner, |
1731 | .vidioc_g_frequency = vidioc_g_frequency, | 1789 | .vidioc_g_frequency = vidioc_g_frequency, |
1732 | .vidioc_s_frequency = vidioc_s_frequency, | 1790 | .vidioc_s_frequency = vidioc_s_frequency, |
1791 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1792 | .vidioc_g_register = vidioc_g_register, | ||
1793 | .vidioc_s_register = vidioc_s_register, | ||
1794 | #endif | ||
1733 | 1795 | ||
1734 | .tvnorms = V4L2_STD_ALL, | 1796 | .tvnorms = V4L2_STD_ALL, |
1735 | .current_norm = V4L2_STD_PAL, | 1797 | .current_norm = V4L2_STD_PAL, |
@@ -1752,6 +1814,10 @@ static struct video_device em28xx_radio_template = { | |||
1752 | .vidioc_s_ctrl = vidioc_s_ctrl, | 1814 | .vidioc_s_ctrl = vidioc_s_ctrl, |
1753 | .vidioc_g_frequency = vidioc_g_frequency, | 1815 | .vidioc_g_frequency = vidioc_g_frequency, |
1754 | .vidioc_s_frequency = vidioc_s_frequency, | 1816 | .vidioc_s_frequency = vidioc_s_frequency, |
1817 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1818 | .vidioc_g_register = vidioc_g_register, | ||
1819 | .vidioc_s_register = vidioc_s_register, | ||
1820 | #endif | ||
1755 | }; | 1821 | }; |
1756 | 1822 | ||
1757 | /******************************** usb interface *****************************************/ | 1823 | /******************************** usb interface *****************************************/ |