All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Stanislawski <t.stanislaws@samsung.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, m.szyprowski@samsung.com,
	kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com
Subject: Re: [PATCH 3/5] [media] v4l: simulate old crop API using extended crop/compose API
Date: Wed, 28 Sep 2011 12:27:19 +0200	[thread overview]
Message-ID: <4E82F687.3050200@samsung.com> (raw)
In-Reply-To: <201109271130.55602.hverkuil@xs4all.nl>

Hi Hans,

On 09/27/2011 11:30 AM, Hans Verkuil wrote:
> On Friday, August 26, 2011 15:06:05 Tomasz Stanislawski wrote:
>> This patch allows new video drivers to work correctly with applications that
>> use the old-style crop API.  The old crop ioctl is simulated by using selection
>> callbacks.
>>
>> Signed-off-by: Tomasz Stanislawski<t.stanislaws@samsung.com>
>> Signed-off-by: Kyungmin Park<kyungmin.park@samsung.com>
>> ---
>>   drivers/media/video/v4l2-ioctl.c |   86 +++++++++++++++++++++++++++++++++----
>>   1 files changed, 76 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
>> index 6e02b45..543405b 100644
>> --- a/drivers/media/video/v4l2-ioctl.c
>> +++ b/drivers/media/video/v4l2-ioctl.c
>> @@ -1696,11 +1696,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;
>> @@ -1709,11 +1729,26 @@ 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
>> +		if (ops->vidioc_s_selection) {
>> +			/* 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_s_selection(file, fh,&s);
>> +		}
>>   		break;
>>   	}
>>   	case VIDIOC_G_SELECTION:
>> @@ -1746,12 +1781,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 = ops->vidioc_cropcap(file, fh, p);
>> +		/*FIXME: Should also show v4l2_fract pixelaspect */
>
> We really need a solution for this. I'm not happy that this hasn't been
> resolved yet.
>
> What about this: if ops->vidioc_g_selection is non-NULL, then fill in bounds
> and defrect as above. But also call ops->vidioc_cropcap at the end if non-NULL,
> so that the driver can fill in the pixelaspect.
>
> So the code would look like this:
>
> 	if (ops->vidioc_g_selection) {
> 		fill in bounds and defrect and set pixelaspect to 1, 1
> 	}
> 	if (ops->vidioc_cropcap)
> 		ops->vidioc_cropcap();
>
> If a driver supports g_selection, then cropcap only needs to fill in the
> pixelaspect.

If cropcap ioctl is missing there is no way to obtain pixelaspect from 
the driver, so 1/1 value is used. On the other hand, if cropcap is 
present there is no need to call g_selection calls to get defrect and 
bounds.

I think that there is a problem with pixel aspect field. Please refer to 
post:

http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/38440/focus=38730

The idea was to move pixelaspect to v4l2_standard. The value would be 
selected from look-up table using standard returned by vidioc_g_std or 
using 1/1 is no analog TV is used. It should work well because majority 
of drivers use 1/1 value. Only some TV drivers behaves differently 
returning values depending on refresh rate that depends only on TV standard.

What do think about this idea?

Best regards,
Tomasz Stanislawski

>
>>   		if (!ret) {
>>   			dbgrect(vfd, "bounds ",&p->bounds);
>>   			dbgrect(vfd, "defrect ",&p->defrect);
>>
>
> And let's show the pixelaspect here as well.
>
> Does this sounds reasonable?
>
> Regards,
>
> 	Hans


  reply	other threads:[~2011-09-28 10:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26 13:06 [PATCH v4 0/5] v4l: extended crop/compose api Tomasz Stanislawski
2011-08-26 13:06 ` [PATCH 1/5] [media] v4l: add support for selection api Tomasz Stanislawski
2011-08-26 14:57   ` Laurent Pinchart
2011-08-26 15:01   ` Laurent Pinchart
2011-08-30 18:38     ` Tomasz Stanislawski
2011-08-30 21:30   ` Sakari Ailus
2011-08-26 13:06 ` [PATCH 2/5] [media] v4l: add documentation for selection API Tomasz Stanislawski
2011-08-26 13:06 ` [PATCH 3/5] [media] v4l: simulate old crop API using extended crop/compose API Tomasz Stanislawski
2011-08-26 15:05   ` Laurent Pinchart
2011-09-27  9:30   ` Hans Verkuil
2011-09-28 10:27     ` Tomasz Stanislawski [this message]
2011-08-26 13:06 ` [PATCH 4/5] [media] v4l: fix copying ioctl results on failure Tomasz Stanislawski
2011-08-26 15:09   ` Laurent Pinchart
2011-08-29  8:01     ` Tomasz Stanislawski
2011-08-29  8:56       ` Laurent Pinchart
2011-08-29 11:55         ` Tomasz Stanislawski
2011-08-29 12:58           ` Laurent Pinchart
2011-08-26 13:06 ` [PATCH 5/5] [media] v4l: s5p-tv: mixer: add support for selection API Tomasz Stanislawski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E82F687.3050200@samsung.com \
    --to=t.stanislaws@samsung.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.