aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/v4l2-ioctl.c')
-rw-r--r--drivers/media/video/v4l2-ioctl.c83
1 files changed, 81 insertions, 2 deletions
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
828static 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
828static void v4l_print_u32(const void *arg, bool write_only) 839static 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
1254static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, 1269static 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
1280static 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
1265static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops, 1292static 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
1835static 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
1808struct v4l2_ioctl_info { 1886struct 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