RE: [PATCH 2/2] v4l: simulate old crop API using extended crop/compose API

2011-05-09 Thread Jonghun Han

Hi Tomasz Stanislawski,

On Thursday, May 05, 2011 6:40 PM Tomasz Stanislawski wrote:
 This patch allows new drivers to work correctly with applications that use
 old-style crop API.
 The old crop ioctl is simulated by using selection ioctls.
 
 Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
 ---
  drivers/media/video/v4l2-ioctl.c |   85
+
  1 files changed, 75 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-
 ioctl.c
 index aeef966..d0a4073 100644
 --- a/drivers/media/video/v4l2-ioctl.c
 +++ b/drivers/media/video/v4l2-ioctl.c
 @@ -1723,11 +1723,31 @@ static long __video_do_ioctl(struct file *file,
   {
   struct v4l2_crop *p = arg;
 
 - if (!ops-vidioc_g_crop)
 + dbgarg(cmd, type=%s\n, prt_names(p-type,
v4l2_type_names));
 +
 + if (ops-vidioc_g_crop) {
 + ret = ops-vidioc_g_crop(file, fh, p);
 + } else
 + if (ops-vidioc_g_selection) {
 + /* simulate capture crop using selection api */
 + struct v4l2_selection s = {
 + .type = p-type,
 + .target = V4L2_SEL_CROP_ACTIVE,
 + };
 +
 + /* crop means compose for output devices */
 + if (p-type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
 + s.target = V4L2_SEL_COMPOSE_ACTIVE;
 +

If it also supports V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
how about using Macro like V4L2_TYPE_IS_OUTPUT(type) ?

[snip]

Best regards,
Jonghun Han


--
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


Re: [PATCH 2/2] v4l: simulate old crop API using extended crop/compose API

2011-05-09 Thread Tomasz Stanislawski

Jonghun Han wrote:

Hi Tomasz Stanislawski,

On Thursday, May 05, 2011 6:40 PM Tomasz Stanislawski wrote:

This patch allows new drivers to work correctly with applications that use
old-style crop API.
The old crop ioctl is simulated by using selection ioctls.

Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
---
 drivers/media/video/v4l2-ioctl.c |   85

+

 1 files changed, 75 insertions(+), 10 deletions(-)

diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-
ioctl.c
index aeef966..d0a4073 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -1723,11 +1723,31 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_crop *p = arg;

-   if (!ops-vidioc_g_crop)
+   dbgarg(cmd, type=%s\n, prt_names(p-type,

v4l2_type_names));

+
+   if (ops-vidioc_g_crop) {
+   ret = ops-vidioc_g_crop(file, fh, p);
+   } else
+   if (ops-vidioc_g_selection) {
+   /* simulate capture crop using selection api */
+   struct v4l2_selection s = {
+   .type = p-type,
+   .target = V4L2_SEL_CROP_ACTIVE,
+   };
+
+   /* crop means compose for output devices */
+   if (p-type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   s.target = V4L2_SEL_COMPOSE_ACTIVE;
+


If it also supports V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
how about using Macro like V4L2_TYPE_IS_OUTPUT(type) ?

[snip]

Best regards,
Jonghun Han



Hi Jonghun,
Thank you for noticing MPLANE bug. I will fix it in next version.
There is some version of V4L2 with automatic conversion of buffer type.
However, the main purpose of this RFC is discussion over extended crop API.
Patches are a less relevant part at the moment.
I hope that the final consensus over API will emerge soon.
Do you have any comment or suggestions?

Best regards,
Tomasz Stanislawski
--
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


[PATCH 2/2] v4l: simulate old crop API using extended crop/compose API

2011-05-05 Thread Tomasz Stanislawski
This patch allows new drivers to work correctly with
applications that use old-style crop API.
The old crop ioctl is simulated by using selection ioctls.

Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
---
 drivers/media/video/v4l2-ioctl.c |   85 +
 1 files changed, 75 insertions(+), 10 deletions(-)

diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index aeef966..d0a4073 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -1723,11 +1723,31 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_crop *p = arg;
 
-   if (!ops-vidioc_g_crop)
+   dbgarg(cmd, type=%s\n, prt_names(p-type, v4l2_type_names));
+
+   if (ops-vidioc_g_crop) {
+   ret = ops-vidioc_g_crop(file, fh, p);
+   } else
+   if (ops-vidioc_g_selection) {
+   /* simulate capture crop using selection api */
+   struct v4l2_selection s = {
+   .type = p-type,
+   .target = V4L2_SEL_CROP_ACTIVE,
+   };
+
+   /* crop means compose for output devices */
+   if (p-type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   s.target = V4L2_SEL_COMPOSE_ACTIVE;
+
+   ret = ops-vidioc_g_selection(file, fh, s);
+
+   /* copying results to old structure on success */
+   if (!ret)
+   p-c = s.r;
+   } else {
break;
+   }
 
-   dbgarg(cmd, type=%s\n, prt_names(p-type, v4l2_type_names));
-   ret = ops-vidioc_g_crop(file, fh, p);
if (!ret)
dbgrect(vfd, , p-c);
break;
@@ -1736,11 +1756,25 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_crop *p = arg;
 
-   if (!ops-vidioc_s_crop)
-   break;
dbgarg(cmd, type=%s\n, prt_names(p-type, v4l2_type_names));
dbgrect(vfd, , p-c);
-   ret = ops-vidioc_s_crop(file, fh, p);
+
+   if (ops-vidioc_s_crop) {
+   ret = ops-vidioc_s_crop(file, fh, p);
+   } else {
+   /* simulate capture crop using selection api */
+   struct v4l2_selection s = {
+   .type = p-type,
+   .target = V4L2_SEL_CROP_ACTIVE,
+   .r = p-c,
+   };
+
+   /* crop means compose for output devices */
+   if (p-type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   s.target = V4L2_SEL_COMPOSE_ACTIVE;
+
+   ret = ops-vidioc_g_selection(file, fh, s);
+   }
break;
}
case VIDIOC_G_SELECTION:
@@ -1773,12 +1807,43 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_cropcap *p = arg;
 
-   /*FIXME: Should also show v4l2_fract pixelaspect */
-   if (!ops-vidioc_cropcap)
+   dbgarg(cmd, type=%s\n, prt_names(p-type, v4l2_type_names));
+   if (ops-vidioc_cropcap) {
+   ret = ops-vidioc_cropcap(file, fh, p);
+   } else
+   if (ops-vidioc_g_selection) {
+   struct v4l2_selection s = { .type = p-type };
+   struct v4l2_rect bounds;
+
+   /* obtaining bounds */
+   if (p-type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   s.target = V4L2_SEL_COMPOSE_BOUNDS;
+   else
+   s.target = V4L2_SEL_CROP_BOUNDS;
+   ret = ops-vidioc_g_selection(file, fh, s);
+   if (ret)
+   break;
+   bounds = s.r;
+
+   /* obtaining defrect */
+   if (p-type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   s.target = V4L2_SEL_COMPOSE_DEFAULT;
+   else
+   s.target = V4L2_SEL_CROP_DEFAULT;
+   ret = ops-vidioc_g_selection(file, fh, s);
+   if (ret)
+   break;
+
+   /* storing results */
+   p-bounds = bounds;
+   p-defrect = s.r;
+   p-pixelaspect.numerator = 1;
+   p-pixelaspect.denominator = 1;
+   } else {
break;
+   }
 
-   dbgarg(cmd, type=%s\n, prt_names(p-type, v4l2_type_names));
-   ret =