aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/ivtv
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-10-01 06:22:06 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-01 16:24:19 -0400
commitbfd063cebb75d3305089e9eeedbd25469d3dc1e6 (patch)
tree80b5397e1634de6f0c224b3484921b954c71c74b /drivers/media/pci/ivtv
parent5f9c82c021cca74ad9a2dd48353c01bad567815e (diff)
[media] ivtv: fix format enumeration: don't show invalid formats
Depending on the device node only the compressed or the uncompressed format should be shown, not both. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/pci/ivtv')
-rw-r--r--drivers/media/pci/ivtv/ivtv-ioctl.c68
1 files changed, 35 insertions, 33 deletions
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 3b32518dbc02..949ae230e119 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -928,51 +928,53 @@ static int ivtv_g_crop(struct file *file, void *fh, struct v4l2_crop *crop)
928 928
929static int ivtv_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *fmt) 929static int ivtv_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *fmt)
930{ 930{
931 static struct v4l2_fmtdesc formats[] = { 931 static const struct v4l2_fmtdesc hm12 = {
932 { 0, 0, 0, 932 0, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
933 "HM12 (YUV 4:2:0)", V4L2_PIX_FMT_HM12, 933 "HM12 (YUV 4:2:0)", V4L2_PIX_FMT_HM12,
934 { 0, 0, 0, 0 } 934 { 0, 0, 0, 0 }
935 }, 935 };
936 { 1, 0, V4L2_FMT_FLAG_COMPRESSED, 936 static const struct v4l2_fmtdesc mpeg = {
937 "MPEG", V4L2_PIX_FMT_MPEG, 937 0, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FMT_FLAG_COMPRESSED,
938 { 0, 0, 0, 0 } 938 "MPEG", V4L2_PIX_FMT_MPEG,
939 } 939 { 0, 0, 0, 0 }
940 }; 940 };
941 enum v4l2_buf_type type = fmt->type; 941 struct ivtv *itv = fh2id(fh)->itv;
942 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
942 943
943 if (fmt->index > 1) 944 if (fmt->index)
945 return -EINVAL;
946 if (s->type == IVTV_ENC_STREAM_TYPE_MPG)
947 *fmt = mpeg;
948 else if (s->type == IVTV_ENC_STREAM_TYPE_YUV)
949 *fmt = hm12;
950 else
944 return -EINVAL; 951 return -EINVAL;
945
946 *fmt = formats[fmt->index];
947 fmt->type = type;
948 return 0; 952 return 0;
949} 953}
950 954
951static int ivtv_enum_fmt_vid_out(struct file *file, void *fh, struct v4l2_fmtdesc *fmt) 955static int ivtv_enum_fmt_vid_out(struct file *file, void *fh, struct v4l2_fmtdesc *fmt)
952{ 956{
953 struct ivtv *itv = fh2id(fh)->itv; 957 static const struct v4l2_fmtdesc hm12 = {
954 958 0, V4L2_BUF_TYPE_VIDEO_OUTPUT, 0,
955 static struct v4l2_fmtdesc formats[] = { 959 "HM12 (YUV 4:2:0)", V4L2_PIX_FMT_HM12,
956 { 0, 0, 0, 960 { 0, 0, 0, 0 }
957 "HM12 (YUV 4:2:0)", V4L2_PIX_FMT_HM12, 961 };
958 { 0, 0, 0, 0 } 962 static const struct v4l2_fmtdesc mpeg = {
959 }, 963 0, V4L2_BUF_TYPE_VIDEO_OUTPUT, V4L2_FMT_FLAG_COMPRESSED,
960 { 1, 0, V4L2_FMT_FLAG_COMPRESSED, 964 "MPEG", V4L2_PIX_FMT_MPEG,
961 "MPEG", V4L2_PIX_FMT_MPEG, 965 { 0, 0, 0, 0 }
962 { 0, 0, 0, 0 }
963 }
964 }; 966 };
965 enum v4l2_buf_type type = fmt->type; 967 struct ivtv *itv = fh2id(fh)->itv;
968 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
966 969
967 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) 970 if (fmt->index)
968 return -EINVAL; 971 return -EINVAL;
969 972 if (s->type == IVTV_DEC_STREAM_TYPE_MPG)
970 if (fmt->index > 1) 973 *fmt = mpeg;
974 else if (s->type == IVTV_DEC_STREAM_TYPE_YUV)
975 *fmt = hm12;
976 else
971 return -EINVAL; 977 return -EINVAL;
972
973 *fmt = formats[fmt->index];
974 fmt->type = type;
975
976 return 0; 978 return 0;
977} 979}
978 980