[pvrusb2] [patch] 24xxx capture window cropping support (2)

vdb128 at picaros.org vdb128 at picaros.org
Sat Sep 12 10:24:55 CDT 2009


With hindsight the patch for pvrusb2-i2c-cmd-v4l2.c 
set_crop(struct pvr2_hdw *hdw) contains an inconsistency.  It only 
calls VIDIOC_G_CROP after a successful VIDIOC_S_CROP.  

However, if the command _S_CROP fails with -ERANGE it is still 
advisable to call _G_CROP as to reset the values hdw->crop*_val.  Thus 
the ctl_crop_*/cur_val always contains the currently applied value.  

--- pvrusb2-i2c-cmd-v4l2.c~	2009-09-05 06:25:43.000000000 +0200
+++ pvrusb2-i2c-cmd-v4l2.c	2009-09-12 15:29:39.000000000 +0200
@@ -238,7 +238,7 @@ static void set_crop(struct pvr2_hdw *hd
 {
 	struct v4l2_crop crop;
 	struct v4l2_rect *c=&crop.c;
-	int err;
+	int errs, errg;
 
 	memset(&crop, 0, sizeof crop);
 	crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -247,22 +247,19 @@ static void set_crop(struct pvr2_hdw *hd
 	c->height = hdw->croph_val;
 	c->width = hdw->cropw_val;
 
-	pvr2_trace(PVR2_TRACE_CHIPS,
-		   "i2c v4l2 set_crop S crop=%d:%d:%d:%d",
+	pvr2_trace(PVR2_TRACE_CHIPS, "i2c v4l2 set_crop crop=%d:%d:%d:%d",
 		   c->width, c->height, c->left, c->top);
 
-	err=pvr2_i2c_core_cmd(hdw, VIDIOC_S_CROP, &crop);
-	if(!err) {
-	  err=pvr2_i2c_core_cmd(hdw, VIDIOC_G_CROP, &crop);
-	  pvr2_trace(PVR2_TRACE_CHIPS,
-		     "i2c v4l2 set_crop G err=%i %d:%d:%d:%d", err, 
-		     c->width, c->height, c->left, c->top);
-	  if(!err) {
-	    hdw->cropl_val = c->left;
-	    hdw->cropt_val = c->top;
-	    hdw->croph_val = c->height;
-	    hdw->cropw_val = c->width;
-	  }
+	errs=pvr2_i2c_core_cmd(hdw, VIDIOC_S_CROP, &crop);
+	errg=pvr2_i2c_core_cmd(hdw, VIDIOC_G_CROP, &crop);
+	pvr2_trace(PVR2_TRACE_CHIPS, "i2c v4l2 set_crop S err=%i G err=%i"
+		   " %d:%d:%d:%d", errs, errg, c->width, c->height, c->left, 
+		   c->top);
+	if(!errg) {
+	  hdw->cropl_val = c->left;
+	  hdw->cropt_val = c->top;
+	  hdw->croph_val = c->height;
+	  hdw->cropw_val = c->width;
 	}
 }
 


More information about the pvrusb2 mailing list