public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: a.andreyanau@sam-solutions.com
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>
Subject: Re: mt9p031 camera driver issue
Date: Thu, 25 Apr 2013 13:45:17 +0200	[thread overview]
Message-ID: <2367258.ZkP6tu2Tsn@avalon> (raw)
In-Reply-To: <517787DC.5070309@sam-solutions.com>

Hi Andrei,

On Wednesday 24 April 2013 10:21:00 Andrei Andreyanau wrote:
> Hi, Guennadi!
> I have found interesting issue with mt9p031 camera driver.
> As far as I got the value of hblank in the kernel driver is not
> calculated correctly. According to the datasheet, the minimum horizontal
> blanking value should be calculated using the following formula:
> 346 x (Row_Bin + 1) + 64 + (Wdc / 2)
> If I'm right, it should look like in the code attached.

Row_Bin is ybin, not xbin. Furthermore, the Row_Bin value starts at 0, while 
the ybin value starts at 1. I thus I believe the driver code is correct.

> Also I wonder why it is decided to use the default value for vblank,
> when it's said that is also should be calculated like this:
> vblank = max(8, SW - H) + 1,
> where SW - shutter width, H - output image height.

That could be fixed, indeed.

> Also, there might be an issue with the calculation of xskip/yskip within
> the same function (mt9p031_set_params).
> 
> xskip = DIV_ROUND_CLOSEST(crop->width, format->width);
> yskip = DIV_ROUND_CLOSEST(crop->height, format->height);
> 
> As far as I got, these values are calculated using the predefined macros,
> that rounds the calculated value to the nearest integer number. I faced
> with the problem, that these values rounded correctly when the result
> is > 1 (e.g. 1,5 will be rounded to 1).
> But what concerns the value 0,8 it will be rounded to 0 by this function
> (DIV_ROUND_CLOSEST). Could you please confirm this issue?

The format rectangle should always be smaller than or equal to the crop 
rectangle, so the xskip and yskip values should never be smaller than 1. If 
that happens, it's a driver bug.

> Signed-off-by: Andrei Andreyanau <a.andreyanau@sam-solutions.com>
> diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
> index e328332..838b300 100644
> --- a/drivers/media/i2c/mt9p031.c
> +++ b/drivers/media/i2c/mt9p031.c
> @@ -368,7 +368,7 @@ static int mt9p031_set_params(struct mt9p031 *mt9p031)
>  	/* Blanking - use minimum value for horizontal blanking and default
>  	 * value for vertical blanking.
>  	 */
> -	hblank = 346 * ybin + 64 + (80 >> min_t(unsigned int, xbin, 3));
> +	hblank = 346 * (xbin + 1) + 64 + ((80 >> clamp_t(unsigned int, xbin,
> 0, 3)) / 2);
>  	vblank = MT9P031_VERTICAL_BLANK_DEF;
> 
>  	ret = mt9p031_write(client, MT9P031_HORIZONTAL_BLANK, hblank - 1);

-- 
Regards,

Laurent Pinchart

      reply	other threads:[~2013-04-25 11:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-24  7:21 mt9p031 camera driver issue Andrei Andreyanau
2013-04-25 11:45 ` Laurent Pinchart [this message]

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=2367258.ZkP6tu2Tsn@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=a.andreyanau@sam-solutions.com \
    --cc=g.liakhovetski@gmx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox