All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Chew <AChew@nvidia.com>
To: "'Guennadi Liakhovetski'" <g.liakhovetski@gmx.de>
Cc: "mchehab@redhat.com" <mchehab@redhat.com>,
	"olof@lixom.net" <olof@lixom.net>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 4/5 v2] [media] ov9740: Remove hardcoded resolution regs
Date: Tue, 31 May 2011 18:50:45 -0700	[thread overview]
Message-ID: <643E69AA4436674C8F39DCC2C05F76382A75BF37C3@HQMAIL03.nvidia.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1105291221450.18788@axis700.grange>

> > +	/* Width must be a multiple of 4 pixels. */
> > +	*width += *width % 4;
> 
> No, this doesn't make it a multiple of 4, unless it was 
> even;) Just take 5 
> as an example. What you really want here is

Geez, you're right.  Not sure what was going on in my head when I did this.  Thanks for catching it.


> > +	/*
> > +	 * Try to use as much of the sensor area as possible 
> when supporting
> > +	 * smaller resolutions.  Depending on the aspect ratio of the
> > +	 * chosen resolution, we can either use the full width 
> of the sensor,
> > +	 * or the full height of the sensor (or both if the 
> aspect ratio is
> > +	 * the same as 1280x720.
> > +	 */
> > +	if ((OV9740_MAX_WIDTH * height) > (OV9740_MAX_HEIGHT * width)) {
> > +		scale_input_x = (OV9740_MAX_HEIGHT * width) / height;
> > +		scale_input_y = OV9740_MAX_HEIGHT;
> >  	} else {
> > -		dev_err(&client->dev, "Failed to select resolution!\n");
> > -		return -EINVAL;
> > +		scale_input_x = OV9740_MAX_WIDTH;
> > +		scale_input_y = (OV9740_MAX_WIDTH * height) / width;
> >  	}
> 
> I don'z know how this sensor works, but the above two divisions round 
> down. And these are input sizes. Cannot it possibly lead to 
> the output 
> window being smaller, than required? Maybe you have to round 
> up (hint: 
> use DIV_ROUND_UP())?

The intention is to do some ratio math without floating point instructions, which resulted in some algebraic twiddling (which is why that math looks so weird).  I think what's there is okay.  If there's any rounding at all (and there shouldn't be any rounding, if "standard" image dimensions are called for), then there's going to be some aspect ratio weirdness no matter which way you round that division.

  reply	other threads:[~2011-06-01  1:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26  0:04 [PATCH 1/5 v2] [media] ov9740: Cleanup hex casing inconsistencies achew
2011-05-26  0:04 ` [PATCH 2/5 v2] [media] ov9740: Correct print in ov9740_reg_rmw() achew
2011-05-26  0:04 ` [PATCH 3/5 v2] [media] ov9740: Fixed some settings achew
2011-05-29 10:21   ` Guennadi Liakhovetski
2011-06-01  1:12     ` Andrew Chew
2011-05-26  0:04 ` [PATCH 4/5 v2] [media] ov9740: Remove hardcoded resolution regs achew
2011-05-29 10:36   ` Guennadi Liakhovetski
2011-06-01  1:50     ` Andrew Chew [this message]
2011-06-01 19:35       ` Guennadi Liakhovetski
2011-05-26  0:04 ` [PATCH 5/5 v2] [media] ov9740: Add suspend/resume achew
2011-05-29 10:58   ` Guennadi Liakhovetski
2011-06-01  1:58     ` Andrew Chew
2011-06-01 19:51       ` Guennadi Liakhovetski

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=643E69AA4436674C8F39DCC2C05F76382A75BF37C3@HQMAIL03.nvidia.com \
    --to=achew@nvidia.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    --cc=olof@lixom.net \
    /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.