Commit e95a1915 authored by Mike Isely's avatar Mike Isely Committed by Mauro Carvalho Chehab

V4L/DVB (4375): Eliminate hardcoded limits in VIDIOC_[S|TRY]_FMT for pvrusb2

The pvrusb2 implementation for VIDIOC_[S|TRY]_FMT was hardcoding
limits on the range for allowed resolution, but it would be much
better if we instead just queried the internal control for these
values.  This then opens the door for the driver to adjust these
limits based on the detected hardware.
Signed-off-by: default avatarMike Isely <isely@pobox.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 434449f4
...@@ -459,18 +459,26 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, ...@@ -459,18 +459,26 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
ret = 0; ret = 0;
switch(vf->type) { switch(vf->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: { case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
int lmin,lmax;
struct pvr2_ctrl *hcp,*vcp;
int h = vf->fmt.pix.height; int h = vf->fmt.pix.height;
int w = vf->fmt.pix.width; int w = vf->fmt.pix.width;
hcp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_HRES);
if (h < 200) { vcp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_VRES);
h = 200;
} else if (h > 625) { lmin = pvr2_ctrl_get_min(hcp);
h = 625; lmax = pvr2_ctrl_get_max(hcp);
if (h < lmin) {
h = lmin;
} else if (h > lmax) {
h = lmax;
} }
if (w < 320) { lmin = pvr2_ctrl_get_min(vcp);
w = 320; lmax = pvr2_ctrl_get_max(vcp);
} else if (w > 720) { if (w < lmin) {
w = 720; w = lmin;
} else if (w > lmax) {
w = lmax;
} }
memcpy(vf, &pvr_format[PVR_FORMAT_PIX], memcpy(vf, &pvr_format[PVR_FORMAT_PIX],
...@@ -479,14 +487,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, ...@@ -479,14 +487,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
vf->fmt.pix.height = h; vf->fmt.pix.height = h;
if (cmd == VIDIOC_S_FMT) { if (cmd == VIDIOC_S_FMT) {
pvr2_ctrl_set_value( pvr2_ctrl_set_value(hcp,vf->fmt.pix.width);
pvr2_hdw_get_ctrl_by_id(hdw, pvr2_ctrl_set_value(vcp,vf->fmt.pix.height);
PVR2_CID_HRES),
vf->fmt.pix.width);
pvr2_ctrl_set_value(
pvr2_hdw_get_ctrl_by_id(hdw,
PVR2_CID_VRES),
vf->fmt.pix.height);
} }
} break; } break;
case V4L2_BUF_TYPE_VBI_CAPTURE: case V4L2_BUF_TYPE_VBI_CAPTURE:
......
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