Re: [RFCv2 API PATCH 15/28] DocBook: Mark CROPCAP as optional instead of as compulsory.

2012-09-13 Thread Laurent Pinchart
Hi Hans,

Thanks for the patch.

On Friday 07 September 2012 15:29:15 Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> While the documentation says that VIDIOC_CROPCAP is compulsory for
> all video capture and output devices, in practice VIDIOC_CROPCAP is
> only implemented for devices that can do cropping and/or scaling.
> 
> Update the documentation to no longer require VIDIOC_CROPCAP if the
> driver does not support cropping or scaling or non-square pixels.
> 
> Signed-off-by: Hans Verkuil 
> ---
>  Documentation/DocBook/media/v4l/common.xml |  145 -
>  Documentation/DocBook/media/v4l/vidioc-cropcap.xml |   10 +-
>  2 files changed, 75 insertions(+), 80 deletions(-)
> 
> diff --git a/Documentation/DocBook/media/v4l/common.xml
> b/Documentation/DocBook/media/v4l/common.xml index 9378d7b..454258b 100644
> --- a/Documentation/DocBook/media/v4l/common.xml
> +++ b/Documentation/DocBook/media/v4l/common.xml
> @@ -628,7 +628,7 @@ are available for the device.
>  if (-1 == ioctl (fd, &VIDIOC-G-STD;, &std_id)) {
>   /* Note when VIDIOC_ENUMSTD always returns EINVAL this
>  is no video device or it falls under the USB exception,
> -and VIDIOC_G_STD returning EINVAL is no error. */
> +and VIDIOC_G_STD returning ENOTTY is no error. */
> 
>   perror ("VIDIOC_G_STD");
>   exit (EXIT_FAILURE);

Would this hunk make more sense in patch 11/28 ?

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 API PATCH 15/28] DocBook: Mark CROPCAP as optional instead of as compulsory.

2012-09-07 Thread Hans Verkuil
From: Hans Verkuil 

While the documentation says that VIDIOC_CROPCAP is compulsory for
all video capture and output devices, in practice VIDIOC_CROPCAP is
only implemented for devices that can do cropping and/or scaling.

Update the documentation to no longer require VIDIOC_CROPCAP if the
driver does not support cropping or scaling or non-square pixels.

Signed-off-by: Hans Verkuil 
---
 Documentation/DocBook/media/v4l/common.xml |  145 +---
 Documentation/DocBook/media/v4l/vidioc-cropcap.xml |   10 +-
 2 files changed, 75 insertions(+), 80 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/common.xml 
b/Documentation/DocBook/media/v4l/common.xml
index 9378d7b..454258b 100644
--- a/Documentation/DocBook/media/v4l/common.xml
+++ b/Documentation/DocBook/media/v4l/common.xml
@@ -628,7 +628,7 @@ are available for the device.
 if (-1 == ioctl (fd, &VIDIOC-G-STD;, &std_id)) {
/* Note when VIDIOC_ENUMSTD always returns EINVAL this
   is no video device or it falls under the USB exception,
-  and VIDIOC_G_STD returning EINVAL is no error. */
+  and VIDIOC_G_STD returning ENOTTY is no error. */
 
perror ("VIDIOC_G_STD");
exit (EXIT_FAILURE);
@@ -905,9 +905,9 @@ inserted.
 Source and target rectangles are defined even if the device
 does not support scaling or the VIDIOC_G/S_CROP
 ioctls. Their size (and position where applicable) will be fixed in
-this case. All capture and output device must support the
-VIDIOC_CROPCAP ioctl such that applications can
-determine if scaling takes place.
+this case. All capture and output device that support cropping
+and/or scaling and/or have non-square pixels must support the 
VIDIOC_CROPCAP
+ioctl such that applications can determine if scaling takes 
place.
 
 
   Cropping Structures
@@ -1032,24 +1032,21 @@ devices.)
 &v4l2-cropcap; cropcap;
 &v4l2-crop; crop;
 
-memset (&cropcap, 0, sizeof (cropcap));
+memset(&cropcap, 0, sizeof(cropcap));
 cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 
-if (-1 == ioctl (fd, &VIDIOC-CROPCAP;, &cropcap)) {
-   perror ("VIDIOC_CROPCAP");
-   exit (EXIT_FAILURE);
-}
-
-memset (&crop, 0, sizeof (crop));
-crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-crop.c = cropcap.defrect;
+if (0 == ioctl(fd, &VIDIOC-CROPCAP;, &cropcap)) {
+   memset(&crop, 0, sizeof(crop));
+   crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+   crop.c = cropcap.defrect;
 
-/* Ignore if cropping is not supported (EINVAL). */
+   /* Ignore if cropping is not supported (ENOTTY). */
 
-if (-1 == ioctl (fd, &VIDIOC-S-CROP;, &crop)
-&& errno != EINVAL) {
-   perror ("VIDIOC_S_CROP");
-   exit (EXIT_FAILURE);
+   if (-1 == ioctl(fd, &VIDIOC-S-CROP;, &crop)
+   && errno != ENOTTY) {
+   perror("VIDIOC_S_CROP");
+   exit(EXIT_FAILURE);
+   }
 }
   
   
@@ -1063,11 +1060,11 @@ if (-1 == ioctl (fd, &VIDIOC-S-CROP;, &crop)
 &v4l2-cropcap; cropcap;
 &v4l2-format; format;
 
-reset_cropping_parameters ();
+reset_cropping_parameters();
 
 /* Scale down to 1/4 size of full picture. */
 
-memset (&format, 0, sizeof (format)); /* defaults */
+memset(&format, 0, sizeof(format)); /* defaults */
 
 format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 
@@ -1075,9 +1072,9 @@ format.fmt.pix.width = cropcap.defrect.width >> 1;
 format.fmt.pix.height = cropcap.defrect.height >> 1;
 format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
 
-if (-1 == ioctl (fd, &VIDIOC-S-FMT;, &format)) {
-   perror ("VIDIOC_S_FORMAT");
-   exit (EXIT_FAILURE);
+if (-1 == ioctl(fd, &VIDIOC-S-FMT;, &format)) {
+   perror("VIDIOC_S_FORMAT");
+   exit(EXIT_FAILURE);
 }
 
 /* We could check the actual image size now, the actual scaling factor
@@ -1092,33 +1089,30 @@ if (-1 == ioctl (fd, &VIDIOC-S-FMT;, &format)) {
 &v4l2-cropcap; cropcap;
 &v4l2-crop; crop;
 
-memset (&cropcap, 0, sizeof (cropcap));
+memset(&cropcap, 0, sizeof (cropcap));
 cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
 
-if (-1 == ioctl (fd, VIDIOC_CROPCAP;, &cropcap)) {
-   perror ("VIDIOC_CROPCAP");
-   exit (EXIT_FAILURE);
-}
-
-memset (&crop, 0, sizeof (crop));
+if (0 == ioctl(fd, &VIDIOC-CROPCAP;, &cropcap)) {
+   memset(&crop, 0, sizeof (crop));
 
-crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-crop.c = cropcap.defrect;
+   crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+   crop.c = cropcap.defrect;
 
-/* Scale the width and height to 50 % of their original size
-   and center the output. */
+   /* Scale the width and height to 50 % of their original size
+  and center the output. */
 
-crop.c.width /= 2;
-crop.c.height /= 2;
-crop.c.left += crop.c.width / 2;
-crop.c.top += crop.c.height / 2;
+   crop.c.width /= 2;
+   crop.c.height /= 2;
+   crop.c.left += crop.c.width / 2;
+   crop.c.top += crop.c.height / 2;
 
-/* Ignore if cropping is not supported (EINVAL). */
+   /* Ignore if cropping is not supported (ENOTTY). */
 
-if (-1 == ioctl (fd, VIDIOC_S_CRO