summaryrefslogtreecommitdiff
path: root/drivers/staging/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-04-25 12:16:45 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-05-01 08:24:13 -0300
commit44a38dfb6a00dcc4ef6010b39bc4dfc6a54263d8 (patch)
tree97f94a5a690fdcce3df3b62ef177b06f65c65f63 /drivers/staging/media
parent5c9ede4442ac4e4b27ddf75dfd1d78578e244980 (diff)
[media] dt3155v4l: fix format handling
Fix various v4l2-compliance issues regarding format handling. Main problem was a missing colorspace value and incorrect format checks. This driver supports a single format only. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/staging/media')
-rw-r--r--drivers/staging/media/dt3155v4l/dt3155v4l.c52
1 files changed, 8 insertions, 44 deletions
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index f026ab63bbca..450728f7ff83 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -29,18 +29,6 @@
#define DT3155_DEVICE_ID 0x1223
-static const struct v4l2_fmtdesc frame_std[] = {
- {
- .index = 0,
- .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
- .flags = 0,
- .description = "8-bit Greyscale",
- .pixelformat = V4L2_PIX_FMT_GREY,
- },
-};
-
-#define NUM_OF_FORMATS ARRAY_SIZE(frame_std)
-
/**
* read_i2c_reg - reads an internal i2c register
*
@@ -330,51 +318,27 @@ static int dt3155_querycap(struct file *filp, void *p, struct v4l2_capability *c
static int dt3155_enum_fmt_vid_cap(struct file *filp, void *p, struct v4l2_fmtdesc *f)
{
- if (f->index >= NUM_OF_FORMATS)
+ if (f->index)
return -EINVAL;
- *f = frame_std[f->index];
+ f->pixelformat = V4L2_PIX_FMT_GREY;
+ strcpy(f->description, "8-bit Greyscale");
return 0;
}
-static int dt3155_g_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
+static int dt3155_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
{
struct dt3155_priv *pd = video_drvdata(filp);
- if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
- return -EINVAL;
f->fmt.pix.width = pd->width;
f->fmt.pix.height = pd->height;
f->fmt.pix.pixelformat = V4L2_PIX_FMT_GREY;
f->fmt.pix.field = V4L2_FIELD_NONE;
f->fmt.pix.bytesperline = f->fmt.pix.width;
f->fmt.pix.sizeimage = f->fmt.pix.width * f->fmt.pix.height;
- f->fmt.pix.colorspace = 0;
- f->fmt.pix.priv = 0;
+ f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
return 0;
}
-static int dt3155_try_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
-{
- struct dt3155_priv *pd = video_drvdata(filp);
-
- if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
- return -EINVAL;
- if (f->fmt.pix.width == pd->width &&
- f->fmt.pix.height == pd->height &&
- f->fmt.pix.pixelformat == V4L2_PIX_FMT_GREY &&
- f->fmt.pix.field == V4L2_FIELD_NONE &&
- f->fmt.pix.bytesperline == f->fmt.pix.width &&
- f->fmt.pix.sizeimage == f->fmt.pix.width * f->fmt.pix.height)
- return 0;
- else
- return -EINVAL;
-}
-
-static int dt3155_s_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f)
-{
- return dt3155_g_fmt_vid_cap(filp, p, f);
-}
-
static int dt3155_g_std(struct file *filp, void *p, v4l2_std_id *norm)
{
struct dt3155_priv *pd = video_drvdata(filp);
@@ -431,9 +395,9 @@ static int dt3155_s_input(struct file *filp, void *p, unsigned int i)
static const struct v4l2_ioctl_ops dt3155_ioctl_ops = {
.vidioc_querycap = dt3155_querycap,
.vidioc_enum_fmt_vid_cap = dt3155_enum_fmt_vid_cap,
- .vidioc_try_fmt_vid_cap = dt3155_try_fmt_vid_cap,
- .vidioc_g_fmt_vid_cap = dt3155_g_fmt_vid_cap,
- .vidioc_s_fmt_vid_cap = dt3155_s_fmt_vid_cap,
+ .vidioc_try_fmt_vid_cap = dt3155_fmt_vid_cap,
+ .vidioc_g_fmt_vid_cap = dt3155_fmt_vid_cap,
+ .vidioc_s_fmt_vid_cap = dt3155_fmt_vid_cap,
.vidioc_reqbufs = vb2_ioctl_reqbufs,
.vidioc_create_bufs = vb2_ioctl_create_bufs,
.vidioc_querybuf = vb2_ioctl_querybuf,