All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH] omap3isp: video: Don't WARN() on unknown pixel formats
Date: Wed, 30 Nov 2011 10:35:38 +0200	[thread overview]
Message-ID: <4ED5EADA.502@iki.fi> (raw)
In-Reply-To: <201111300306.41892.laurent.pinchart@ideasonboard.com>

Laurent Pinchart wrote:
> Hi Sakari,
> 
> On Monday 28 November 2011 17:01:12 Sakari Ailus wrote:
>> On Mon, Nov 28, 2011 at 12:37:34PM +0100, Laurent Pinchart wrote:
>>> When mapping from a V4L2 pixel format to a media bus format in the
>>> VIDIOC_TRY_FMT and VIDIOC_S_FMT handlers, the requested format may be
>>> unsupported by the driver. Return a hardcoded format instead of
>>> WARN()ing in that case.
>>>
>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>>
>>>  drivers/media/video/omap3isp/ispvideo.c |    8 ++++----
>>>  1 files changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/media/video/omap3isp/ispvideo.c
>>> b/drivers/media/video/omap3isp/ispvideo.c index d100072..ffe7ce9 100644
>>> --- a/drivers/media/video/omap3isp/ispvideo.c
>>> +++ b/drivers/media/video/omap3isp/ispvideo.c
>>> @@ -210,14 +210,14 @@ static void isp_video_pix_to_mbus(const struct
>>> v4l2_pix_format *pix,
>>>
>>>  	mbus->width = pix->width;
>>>  	mbus->height = pix->height;
>>>
>>> -	for (i = 0; i < ARRAY_SIZE(formats); ++i) {
>>> +	/* Skip the last format in the loop so that it will be selected if no
>>> +	 * match is found.
>>> +	 */
>>> +	for (i = 0; i < ARRAY_SIZE(formats) - 1; ++i) {
>>>
>>>  		if (formats[i].pixelformat == pix->pixelformat)
>>>  		
>>>  			break;
>>>  	
>>>  	}
>>>
>>> -	if (WARN_ON(i == ARRAY_SIZE(formats)))
>>> -		return;
>>> -
>>>
>>>  	mbus->code = formats[i].code;
>>>  	mbus->colorspace = pix->colorspace;
>>>  	mbus->field = pix->field;
>>
>> In case of setting or trying an invalid format, instead of selecting a
>> default format, shouldn't we leave the format unchanced --- the current
>> setting is valid after all.
> 
> TRY/SET operations must succeed. The format we select when an invalid format 
> is requested isn't specified. We could keep the current format, but wouldn't 
> that be more confusing for applications ? The format they would get in 
> response to a TRY/SET operation would then potentially depend on the previous 
> SET operations.

I don't think a change to something that has nothing to do what was
requested is better than not changing it. The application has requested
a particular format; changing it to something else isn't useful for the
application. And if the application would try more than invalid format
in a row, they both would yield to the same default format.

I would personally not change it.

What I can find in the spec is this:

"When the application calls the VIDIOC_S_FMT ioctl with a pointer to a
v4l2_format structure the driver checks and adjusts the parameters
against hardware abilities."

I wonder how other drivers behave.

-- 
Sakari Ailus
sakari.ailus@iki.fi

  reply	other threads:[~2011-11-30  8:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-28 11:37 [PATCH] omap3isp: video: Don't WARN() on unknown pixel formats Laurent Pinchart
2011-11-28 16:01 ` Sakari Ailus
2011-11-30  2:06   ` Laurent Pinchart
2011-11-30  8:35     ` Sakari Ailus [this message]
2011-11-30 23:26       ` Laurent Pinchart
2011-12-01 14:34         ` Sakari Ailus
2011-12-07 13:44           ` Laurent Pinchart
2011-12-07 18:19             ` Sakari Ailus

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=4ED5EADA.502@iki.fi \
    --to=sakari.ailus@iki.fi \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /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.