Commit 44a38dfb authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 5c9ede44
......@@ -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,49 +318,25 @@ 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;
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)
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
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)
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment