diff options
author | Antti Palosaari <crope@iki.fi> | 2013-12-12 11:44:14 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-03-05 12:15:20 -0500 |
commit | 582c52cb9cd2616ab0d41127b22ad56ee49d40b4 (patch) | |
tree | a307760a7c7e1b56a9327228558454b36bc60815 | |
parent | 855df1dc6fdb519c7552053bc095f821bc360905 (diff) |
[media] v4l: enable some IOCTLs for SDR receiver
Enable stream format (FMT) IOCTLs for SDR use. These are used for negotiate
used data stream format.
Reorganise some some IOCTL selection logic.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/v4l2-core/v4l2-dev.c | 21 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ioctl.c | 35 |
2 files changed, 53 insertions, 3 deletions
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 9764ca04f8e2..98099e827614 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c | |||
@@ -553,7 +553,7 @@ static void determine_valid_ioctls(struct video_device *vdev) | |||
553 | const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops; | 553 | const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops; |
554 | bool is_vid = vdev->vfl_type == VFL_TYPE_GRABBER; | 554 | bool is_vid = vdev->vfl_type == VFL_TYPE_GRABBER; |
555 | bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI; | 555 | bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI; |
556 | bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO; | 556 | bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR; |
557 | bool is_rx = vdev->vfl_dir != VFL_DIR_TX; | 557 | bool is_rx = vdev->vfl_dir != VFL_DIR_TX; |
558 | bool is_tx = vdev->vfl_dir != VFL_DIR_RX; | 558 | bool is_tx = vdev->vfl_dir != VFL_DIR_RX; |
559 | 559 | ||
@@ -662,9 +662,20 @@ static void determine_valid_ioctls(struct video_device *vdev) | |||
662 | ops->vidioc_try_fmt_sliced_vbi_out))) | 662 | ops->vidioc_try_fmt_sliced_vbi_out))) |
663 | set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls); | 663 | set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls); |
664 | SET_VALID_IOCTL(ops, VIDIOC_G_SLICED_VBI_CAP, vidioc_g_sliced_vbi_cap); | 664 | SET_VALID_IOCTL(ops, VIDIOC_G_SLICED_VBI_CAP, vidioc_g_sliced_vbi_cap); |
665 | } else if (is_sdr) { | ||
666 | /* SDR specific ioctls */ | ||
667 | if (ops->vidioc_enum_fmt_sdr_cap) | ||
668 | set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls); | ||
669 | if (ops->vidioc_g_fmt_sdr_cap) | ||
670 | set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls); | ||
671 | if (ops->vidioc_s_fmt_sdr_cap) | ||
672 | set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls); | ||
673 | if (ops->vidioc_try_fmt_sdr_cap) | ||
674 | set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls); | ||
665 | } | 675 | } |
666 | if (!is_radio) { | 676 | |
667 | /* ioctls valid for video or vbi */ | 677 | if (is_vid || is_vbi || is_sdr) { |
678 | /* ioctls valid for video, vbi or sdr */ | ||
668 | SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs); | 679 | SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs); |
669 | SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf); | 680 | SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf); |
670 | SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf); | 681 | SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf); |
@@ -672,6 +683,10 @@ static void determine_valid_ioctls(struct video_device *vdev) | |||
672 | SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf); | 683 | SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf); |
673 | SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs); | 684 | SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs); |
674 | SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf); | 685 | SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf); |
686 | } | ||
687 | |||
688 | if (is_vid || is_vbi) { | ||
689 | /* ioctls valid for video or vbi */ | ||
675 | if (ops->vidioc_s_std) | 690 | if (ops->vidioc_s_std) |
676 | set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls); | 691 | set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls); |
677 | SET_VALID_IOCTL(ops, VIDIOC_S_STD, vidioc_s_std); | 692 | SET_VALID_IOCTL(ops, VIDIOC_S_STD, vidioc_s_std); |
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 9a2acaf75426..95dd4f15ab6e 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c | |||
@@ -246,6 +246,7 @@ static void v4l_print_format(const void *arg, bool write_only) | |||
246 | const struct v4l2_vbi_format *vbi; | 246 | const struct v4l2_vbi_format *vbi; |
247 | const struct v4l2_sliced_vbi_format *sliced; | 247 | const struct v4l2_sliced_vbi_format *sliced; |
248 | const struct v4l2_window *win; | 248 | const struct v4l2_window *win; |
249 | const struct v4l2_format_sdr *sdr; | ||
249 | unsigned i; | 250 | unsigned i; |
250 | 251 | ||
251 | pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); | 252 | pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); |
@@ -319,6 +320,14 @@ static void v4l_print_format(const void *arg, bool write_only) | |||
319 | sliced->service_lines[0][i], | 320 | sliced->service_lines[0][i], |
320 | sliced->service_lines[1][i]); | 321 | sliced->service_lines[1][i]); |
321 | break; | 322 | break; |
323 | case V4L2_BUF_TYPE_SDR_CAPTURE: | ||
324 | sdr = &p->fmt.sdr; | ||
325 | pr_cont(", pixelformat=%c%c%c%c\n", | ||
326 | (sdr->pixelformat >> 0) & 0xff, | ||
327 | (sdr->pixelformat >> 8) & 0xff, | ||
328 | (sdr->pixelformat >> 16) & 0xff, | ||
329 | (sdr->pixelformat >> 24) & 0xff); | ||
330 | break; | ||
322 | } | 331 | } |
323 | } | 332 | } |
324 | 333 | ||
@@ -882,6 +891,7 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type) | |||
882 | const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; | 891 | const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; |
883 | bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; | 892 | bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; |
884 | bool is_vbi = vfd->vfl_type == VFL_TYPE_VBI; | 893 | bool is_vbi = vfd->vfl_type == VFL_TYPE_VBI; |
894 | bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR; | ||
885 | bool is_rx = vfd->vfl_dir != VFL_DIR_TX; | 895 | bool is_rx = vfd->vfl_dir != VFL_DIR_TX; |
886 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; | 896 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; |
887 | 897 | ||
@@ -931,6 +941,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type) | |||
931 | if (is_vbi && is_tx && ops->vidioc_g_fmt_sliced_vbi_out) | 941 | if (is_vbi && is_tx && ops->vidioc_g_fmt_sliced_vbi_out) |
932 | return 0; | 942 | return 0; |
933 | break; | 943 | break; |
944 | case V4L2_BUF_TYPE_SDR_CAPTURE: | ||
945 | if (is_sdr && is_rx && ops->vidioc_g_fmt_sdr_cap) | ||
946 | return 0; | ||
947 | break; | ||
934 | default: | 948 | default: |
935 | break; | 949 | break; |
936 | } | 950 | } |
@@ -1050,6 +1064,10 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, | |||
1050 | if (unlikely(!is_tx || !ops->vidioc_enum_fmt_vid_out_mplane)) | 1064 | if (unlikely(!is_tx || !ops->vidioc_enum_fmt_vid_out_mplane)) |
1051 | break; | 1065 | break; |
1052 | return ops->vidioc_enum_fmt_vid_out_mplane(file, fh, arg); | 1066 | return ops->vidioc_enum_fmt_vid_out_mplane(file, fh, arg); |
1067 | case V4L2_BUF_TYPE_SDR_CAPTURE: | ||
1068 | if (unlikely(!is_rx || !ops->vidioc_enum_fmt_sdr_cap)) | ||
1069 | break; | ||
1070 | return ops->vidioc_enum_fmt_sdr_cap(file, fh, arg); | ||
1053 | } | 1071 | } |
1054 | return -EINVAL; | 1072 | return -EINVAL; |
1055 | } | 1073 | } |
@@ -1060,6 +1078,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, | |||
1060 | struct v4l2_format *p = arg; | 1078 | struct v4l2_format *p = arg; |
1061 | struct video_device *vfd = video_devdata(file); | 1079 | struct video_device *vfd = video_devdata(file); |
1062 | bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; | 1080 | bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; |
1081 | bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR; | ||
1063 | bool is_rx = vfd->vfl_dir != VFL_DIR_TX; | 1082 | bool is_rx = vfd->vfl_dir != VFL_DIR_TX; |
1064 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; | 1083 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; |
1065 | 1084 | ||
@@ -1104,6 +1123,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, | |||
1104 | if (unlikely(!is_tx || is_vid || !ops->vidioc_g_fmt_sliced_vbi_out)) | 1123 | if (unlikely(!is_tx || is_vid || !ops->vidioc_g_fmt_sliced_vbi_out)) |
1105 | break; | 1124 | break; |
1106 | return ops->vidioc_g_fmt_sliced_vbi_out(file, fh, arg); | 1125 | return ops->vidioc_g_fmt_sliced_vbi_out(file, fh, arg); |
1126 | case V4L2_BUF_TYPE_SDR_CAPTURE: | ||
1127 | if (unlikely(!is_rx || !is_sdr || !ops->vidioc_g_fmt_sdr_cap)) | ||
1128 | break; | ||
1129 | return ops->vidioc_g_fmt_sdr_cap(file, fh, arg); | ||
1107 | } | 1130 | } |
1108 | return -EINVAL; | 1131 | return -EINVAL; |
1109 | } | 1132 | } |
@@ -1114,6 +1137,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, | |||
1114 | struct v4l2_format *p = arg; | 1137 | struct v4l2_format *p = arg; |
1115 | struct video_device *vfd = video_devdata(file); | 1138 | struct video_device *vfd = video_devdata(file); |
1116 | bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; | 1139 | bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; |
1140 | bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR; | ||
1117 | bool is_rx = vfd->vfl_dir != VFL_DIR_TX; | 1141 | bool is_rx = vfd->vfl_dir != VFL_DIR_TX; |
1118 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; | 1142 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; |
1119 | 1143 | ||
@@ -1168,6 +1192,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, | |||
1168 | break; | 1192 | break; |
1169 | CLEAR_AFTER_FIELD(p, fmt.sliced); | 1193 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
1170 | return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg); | 1194 | return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg); |
1195 | case V4L2_BUF_TYPE_SDR_CAPTURE: | ||
1196 | if (unlikely(!is_rx || !is_sdr || !ops->vidioc_s_fmt_sdr_cap)) | ||
1197 | break; | ||
1198 | CLEAR_AFTER_FIELD(p, fmt.sdr); | ||
1199 | return ops->vidioc_s_fmt_sdr_cap(file, fh, arg); | ||
1171 | } | 1200 | } |
1172 | return -EINVAL; | 1201 | return -EINVAL; |
1173 | } | 1202 | } |
@@ -1178,6 +1207,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, | |||
1178 | struct v4l2_format *p = arg; | 1207 | struct v4l2_format *p = arg; |
1179 | struct video_device *vfd = video_devdata(file); | 1208 | struct video_device *vfd = video_devdata(file); |
1180 | bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; | 1209 | bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; |
1210 | bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR; | ||
1181 | bool is_rx = vfd->vfl_dir != VFL_DIR_TX; | 1211 | bool is_rx = vfd->vfl_dir != VFL_DIR_TX; |
1182 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; | 1212 | bool is_tx = vfd->vfl_dir != VFL_DIR_RX; |
1183 | 1213 | ||
@@ -1232,6 +1262,11 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, | |||
1232 | break; | 1262 | break; |
1233 | CLEAR_AFTER_FIELD(p, fmt.sliced); | 1263 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
1234 | return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg); | 1264 | return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg); |
1265 | case V4L2_BUF_TYPE_SDR_CAPTURE: | ||
1266 | if (unlikely(!is_rx || !is_sdr || !ops->vidioc_try_fmt_sdr_cap)) | ||
1267 | break; | ||
1268 | CLEAR_AFTER_FIELD(p, fmt.sdr); | ||
1269 | return ops->vidioc_try_fmt_sdr_cap(file, fh, arg); | ||
1235 | } | 1270 | } |
1236 | return -EINVAL; | 1271 | return -EINVAL; |
1237 | } | 1272 | } |