diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-07-05 05:37:08 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-30 19:23:05 -0400 |
commit | 82b655bfc32b793344ef0ddd46df8af8b98b55c7 (patch) | |
tree | ebc3479357b9909b8c76f3867322ad3592d69c12 /drivers/media | |
parent | 3d687b49ff085b325488e7aeb2ee4df99dd7ca6e (diff) |
[media] v4l2: add core support for the new VIDIOC_ENUM_FREQ_BANDS ioctl
This adds the usual core support code for this new ioctl.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/v4l2-compat-ioctl32.c | 1 | ||||
-rw-r--r-- | drivers/media/video/v4l2-dev.c | 2 | ||||
-rw-r--r-- | drivers/media/video/v4l2-ioctl.c | 83 |
3 files changed, 84 insertions, 2 deletions
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c index ac365cfb3706..9ebd5c540d10 100644 --- a/drivers/media/video/v4l2-compat-ioctl32.c +++ b/drivers/media/video/v4l2-compat-ioctl32.c | |||
@@ -1025,6 +1025,7 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) | |||
1025 | case VIDIOC_ENUM_DV_TIMINGS: | 1025 | case VIDIOC_ENUM_DV_TIMINGS: |
1026 | case VIDIOC_QUERY_DV_TIMINGS: | 1026 | case VIDIOC_QUERY_DV_TIMINGS: |
1027 | case VIDIOC_DV_TIMINGS_CAP: | 1027 | case VIDIOC_DV_TIMINGS_CAP: |
1028 | case VIDIOC_ENUM_FREQ_BANDS: | ||
1028 | ret = do_video_ioctl(file, cmd, arg); | 1029 | ret = do_video_ioctl(file, cmd, arg); |
1029 | break; | 1030 | break; |
1030 | 1031 | ||
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 1b2f1c52e6c3..625248585c85 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -730,6 +730,8 @@ static void determine_valid_ioctls(struct video_device *vdev) | |||
730 | SET_VALID_IOCTL(ops, VIDIOC_UNSUBSCRIBE_EVENT, vidioc_unsubscribe_event); | 730 | SET_VALID_IOCTL(ops, VIDIOC_UNSUBSCRIBE_EVENT, vidioc_unsubscribe_event); |
731 | SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs); | 731 | SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs); |
732 | SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf); | 732 | SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf); |
733 | if (ops->vidioc_enum_freq_bands || ops->vidioc_g_tuner || ops->vidioc_g_modulator) | ||
734 | set_bit(_IOC_NR(VIDIOC_ENUM_FREQ_BANDS), valid_ioctls); | ||
733 | bitmap_andnot(vdev->valid_ioctls, valid_ioctls, vdev->valid_ioctls, | 735 | bitmap_andnot(vdev->valid_ioctls, valid_ioctls, vdev->valid_ioctls, |
734 | BASE_VIDIOC_PRIVATE); | 736 | BASE_VIDIOC_PRIVATE); |
735 | } | 737 | } |
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 3e4db2c1c3d6..0f54f8efe66b 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -825,6 +825,17 @@ static void v4l_print_sliced_vbi_cap(const void *arg, bool write_only) | |||
825 | p->service_lines[1][i]); | 825 | p->service_lines[1][i]); |
826 | } | 826 | } |
827 | 827 | ||
828 | static void v4l_print_freq_band(const void *arg, bool write_only) | ||
829 | { | ||
830 | const struct v4l2_frequency_band *p = arg; | ||
831 | |||
832 | pr_cont("tuner=%u, type=%u, index=%u, capability=0x%x, " | ||
833 | "rangelow=%u, rangehigh=%u, modulation=0x%x\n", | ||
834 | p->tuner, p->type, p->index, | ||
835 | p->capability, p->rangelow, | ||
836 | p->rangehigh, p->modulation); | ||
837 | } | ||
838 | |||
828 | static void v4l_print_u32(const void *arg, bool write_only) | 839 | static void v4l_print_u32(const void *arg, bool write_only) |
829 | { | 840 | { |
830 | pr_cont("value=%u\n", *(const u32 *)arg); | 841 | pr_cont("value=%u\n", *(const u32 *)arg); |
@@ -1245,10 +1256,14 @@ static int v4l_g_tuner(const struct v4l2_ioctl_ops *ops, | |||
1245 | { | 1256 | { |
1246 | struct video_device *vfd = video_devdata(file); | 1257 | struct video_device *vfd = video_devdata(file); |
1247 | struct v4l2_tuner *p = arg; | 1258 | struct v4l2_tuner *p = arg; |
1259 | int err; | ||
1248 | 1260 | ||
1249 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1261 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
1250 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1262 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
1251 | return ops->vidioc_g_tuner(file, fh, p); | 1263 | err = ops->vidioc_g_tuner(file, fh, p); |
1264 | if (!err) | ||
1265 | p->capability |= V4L2_TUNER_CAP_FREQ_BANDS; | ||
1266 | return err; | ||
1252 | } | 1267 | } |
1253 | 1268 | ||
1254 | static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, | 1269 | static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, |
@@ -1262,6 +1277,18 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, | |||
1262 | return ops->vidioc_s_tuner(file, fh, p); | 1277 | return ops->vidioc_s_tuner(file, fh, p); |
1263 | } | 1278 | } |
1264 | 1279 | ||
1280 | static int v4l_g_modulator(const struct v4l2_ioctl_ops *ops, | ||
1281 | struct file *file, void *fh, void *arg) | ||
1282 | { | ||
1283 | struct v4l2_modulator *p = arg; | ||
1284 | int err; | ||
1285 | |||
1286 | err = ops->vidioc_g_modulator(file, fh, p); | ||
1287 | if (!err) | ||
1288 | p->capability |= V4L2_TUNER_CAP_FREQ_BANDS; | ||
1289 | return err; | ||
1290 | } | ||
1291 | |||
1265 | static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops, | 1292 | static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops, |
1266 | struct file *file, void *fh, void *arg) | 1293 | struct file *file, void *fh, void *arg) |
1267 | { | 1294 | { |
@@ -1805,6 +1832,57 @@ static int v4l_g_sliced_vbi_cap(const struct v4l2_ioctl_ops *ops, | |||
1805 | return ops->vidioc_g_sliced_vbi_cap(file, fh, p); | 1832 | return ops->vidioc_g_sliced_vbi_cap(file, fh, p); |
1806 | } | 1833 | } |
1807 | 1834 | ||
1835 | static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops, | ||
1836 | struct file *file, void *fh, void *arg) | ||
1837 | { | ||
1838 | struct video_device *vfd = video_devdata(file); | ||
1839 | struct v4l2_frequency_band *p = arg; | ||
1840 | enum v4l2_tuner_type type; | ||
1841 | int err; | ||
1842 | |||
1843 | type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | ||
1844 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | ||
1845 | |||
1846 | if (type != p->type) | ||
1847 | return -EINVAL; | ||
1848 | if (ops->vidioc_enum_freq_bands) | ||
1849 | return ops->vidioc_enum_freq_bands(file, fh, p); | ||
1850 | if (ops->vidioc_g_tuner) { | ||
1851 | struct v4l2_tuner t = { | ||
1852 | .index = p->tuner, | ||
1853 | .type = type, | ||
1854 | }; | ||
1855 | |||
1856 | err = ops->vidioc_g_tuner(file, fh, &t); | ||
1857 | if (err) | ||
1858 | return err; | ||
1859 | p->capability = t.capability | V4L2_TUNER_CAP_FREQ_BANDS; | ||
1860 | p->rangelow = t.rangelow; | ||
1861 | p->rangehigh = t.rangehigh; | ||
1862 | p->modulation = (type == V4L2_TUNER_RADIO) ? | ||
1863 | V4L2_BAND_MODULATION_FM : V4L2_BAND_MODULATION_VSB; | ||
1864 | return 0; | ||
1865 | } | ||
1866 | if (ops->vidioc_g_modulator) { | ||
1867 | struct v4l2_modulator m = { | ||
1868 | .index = p->tuner, | ||
1869 | }; | ||
1870 | |||
1871 | if (type != V4L2_TUNER_RADIO) | ||
1872 | return -EINVAL; | ||
1873 | err = ops->vidioc_g_modulator(file, fh, &m); | ||
1874 | if (err) | ||
1875 | return err; | ||
1876 | p->capability = m.capability | V4L2_TUNER_CAP_FREQ_BANDS; | ||
1877 | p->rangelow = m.rangelow; | ||
1878 | p->rangehigh = m.rangehigh; | ||
1879 | p->modulation = (type == V4L2_TUNER_RADIO) ? | ||
1880 | V4L2_BAND_MODULATION_FM : V4L2_BAND_MODULATION_VSB; | ||
1881 | return 0; | ||
1882 | } | ||
1883 | return -ENOTTY; | ||
1884 | } | ||
1885 | |||
1808 | struct v4l2_ioctl_info { | 1886 | struct v4l2_ioctl_info { |
1809 | unsigned int ioctl; | 1887 | unsigned int ioctl; |
1810 | u32 flags; | 1888 | u32 flags; |
@@ -1886,7 +1964,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { | |||
1886 | IOCTL_INFO_FNC(VIDIOC_ENUMOUTPUT, v4l_enumoutput, v4l_print_enumoutput, INFO_FL_CLEAR(v4l2_output, index)), | 1964 | IOCTL_INFO_FNC(VIDIOC_ENUMOUTPUT, v4l_enumoutput, v4l_print_enumoutput, INFO_FL_CLEAR(v4l2_output, index)), |
1887 | IOCTL_INFO_STD(VIDIOC_G_AUDOUT, vidioc_g_audout, v4l_print_audioout, 0), | 1965 | IOCTL_INFO_STD(VIDIOC_G_AUDOUT, vidioc_g_audout, v4l_print_audioout, 0), |
1888 | IOCTL_INFO_STD(VIDIOC_S_AUDOUT, vidioc_s_audout, v4l_print_audioout, INFO_FL_PRIO), | 1966 | IOCTL_INFO_STD(VIDIOC_S_AUDOUT, vidioc_s_audout, v4l_print_audioout, INFO_FL_PRIO), |
1889 | IOCTL_INFO_STD(VIDIOC_G_MODULATOR, vidioc_g_modulator, v4l_print_modulator, INFO_FL_CLEAR(v4l2_modulator, index)), | 1967 | IOCTL_INFO_FNC(VIDIOC_G_MODULATOR, v4l_g_modulator, v4l_print_modulator, INFO_FL_CLEAR(v4l2_modulator, index)), |
1890 | IOCTL_INFO_STD(VIDIOC_S_MODULATOR, vidioc_s_modulator, v4l_print_modulator, INFO_FL_PRIO), | 1968 | IOCTL_INFO_STD(VIDIOC_S_MODULATOR, vidioc_s_modulator, v4l_print_modulator, INFO_FL_PRIO), |
1891 | IOCTL_INFO_FNC(VIDIOC_G_FREQUENCY, v4l_g_frequency, v4l_print_frequency, INFO_FL_CLEAR(v4l2_frequency, tuner)), | 1969 | IOCTL_INFO_FNC(VIDIOC_G_FREQUENCY, v4l_g_frequency, v4l_print_frequency, INFO_FL_CLEAR(v4l2_frequency, tuner)), |
1892 | IOCTL_INFO_FNC(VIDIOC_S_FREQUENCY, v4l_s_frequency, v4l_print_frequency, INFO_FL_PRIO), | 1970 | IOCTL_INFO_FNC(VIDIOC_S_FREQUENCY, v4l_s_frequency, v4l_print_frequency, INFO_FL_PRIO), |
@@ -1933,6 +2011,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { | |||
1933 | IOCTL_INFO_STD(VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings, v4l_print_enum_dv_timings, 0), | 2011 | IOCTL_INFO_STD(VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings, v4l_print_enum_dv_timings, 0), |
1934 | IOCTL_INFO_STD(VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings, v4l_print_dv_timings, 0), | 2012 | IOCTL_INFO_STD(VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings, v4l_print_dv_timings, 0), |
1935 | IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, v4l_print_dv_timings_cap, INFO_FL_CLEAR(v4l2_dv_timings_cap, type)), | 2013 | IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, v4l_print_dv_timings_cap, INFO_FL_CLEAR(v4l2_dv_timings_cap, type)), |
2014 | IOCTL_INFO_FNC(VIDIOC_ENUM_FREQ_BANDS, v4l_enum_freq_bands, v4l_print_freq_band, 0), | ||
1936 | }; | 2015 | }; |
1937 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | 2016 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) |
1938 | 2017 | ||