diff options
author | vdb128@picaros.org <vdb128@picaros.org> | 2008-08-30 18:26:39 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 09:36:57 -0200 |
commit | e784bfb93c155ba4b354452c69ac02a29d336d97 (patch) | |
tree | da8d1a7ec7803cef22510c505307fd222f05d912 /drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c | |
parent | fe15f13679bf52bb5c8acb8b4847e6d73ba62c17 (diff) | |
download | op-kernel-dev-e784bfb93c155ba4b354452c69ac02a29d336d97.zip op-kernel-dev-e784bfb93c155ba4b354452c69ac02a29d336d97.tar.gz |
V4L/DVB (8896): pvrusb2: Implement crop support
Implement pvrusb2 driver plumbing to support cropping. Submitted by a
pvrusb2 user.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c index 55f04a0..4408579 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c +++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c @@ -233,6 +233,55 @@ const struct pvr2_i2c_op pvr2_i2c_op_v4l2_size = { }; +static void set_crop(struct pvr2_hdw *hdw) +{ + struct v4l2_cropcap cap; + struct v4l2_crop crop; + int stat; + + memset(&cap, 0, sizeof cap); + cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + stat = pvr2_i2c_core_cmd(hdw, VIDIOC_CROPCAP, &cap); + hdw->cropcap = cap; + + memset(&crop, 0, sizeof crop); + crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + crop.c = cap.defrect; + crop.c.left += hdw->cropl_val; + crop.c.top += hdw->cropt_val; + crop.c.height = hdw->croph_val; + crop.c.width = hdw->cropw_val; + + pvr2_trace(PVR2_TRACE_CHIPS, + "i2c v4l2 set_crop stat=%d cap=%d:%d:%d:%d" + " crop=%d:%d:%d:%d", stat, cap.bounds.width, + cap.bounds.height, cap.bounds.left, cap.bounds.top, + crop.c.width, crop.c.height, crop.c.left, crop.c.top); + + if (stat >= 0) { + /* This comment is present purely to keep + checkpatch.pl quiet */ + pvr2_i2c_core_cmd(hdw, VIDIOC_S_CROP, &crop); + } +} + +static int check_crop(struct pvr2_hdw *hdw) +{ + /* The "0 +" stupidity is present only to get checkpatch.pl to + shut up. I _want_ those parantheses present so that the + two lines automatically line up in my editor. I despise + checkpatch.pl. */ + return 0 + (hdw->cropl_dirty || hdw->cropt_dirty || + hdw->cropw_dirty || hdw->croph_dirty); +} + +const struct pvr2_i2c_op pvr2_i2c_op_v4l2_crop = { + .check = check_crop, + .update = set_crop, + .name = "v4l2_crop", +}; + + static void do_log(struct pvr2_hdw *hdw) { pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 do_log()"); |