linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo@jmondi.org>
To: "Krzysztof Hałasa" <khalasa@piap.pl>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Sakari Ailus" <sakari.ailus@iki.fi>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>
Cc: Jacopo Mondi <jacopo@jmondi.org>, linux-media@vger.kernel.org
Subject: [PATCH 03/10] media: ar0521: Set maximum resolution to 2592x1944
Date: Wed,  5 Oct 2022 21:06:06 +0200	[thread overview]
Message-ID: <20221005190613.394277-4-jacopo@jmondi.org> (raw)
In-Reply-To: <20221005190613.394277-1-jacopo@jmondi.org>

Change the largest visibile resolution to 2592x1944, which corresponds
to the active pixel array area size. Take into account the horizontal
and vertical limits when programming the visible sizes to skip
dummy/inactive pixels.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 drivers/media/i2c/ar0521.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/media/i2c/ar0521.c b/drivers/media/i2c/ar0521.c
index 581f5e42994d..2b19ba898ce8 100644
--- a/drivers/media/i2c/ar0521.c
+++ b/drivers/media/i2c/ar0521.c
@@ -28,10 +28,17 @@
 #define AR0521_PIXEL_CLOCK_MIN	 (168 * 1000 * 1000)
 #define AR0521_PIXEL_CLOCK_MAX	 (414 * 1000 * 1000)
 
+#define AR0521_NATIVE_WIDTH		2604u
+#define AR0521_NATIVE_HEIGHT		1964u
+#define AR0521_MIN_X_ADDR_START		4u
+#define AR0521_MIN_Y_ADDR_START		4u
+#define AR0521_MAX_X_ADDR_END		2603u
+#define AR0521_MAX_Y_ADDR_END		1963u
+
 #define AR0521_WIDTH_MIN	       8u
-#define AR0521_WIDTH_MAX	    2608u
+#define AR0521_WIDTH_MAX	    2592u
 #define AR0521_HEIGHT_MIN	       8u
-#define AR0521_HEIGHT_MAX	    1958u
+#define AR0521_HEIGHT_MAX	    1944u
 
 #define AR0521_WIDTH_BLANKING_MIN     572u
 #define AR0521_HEIGHT_BLANKING_MIN     38u /* must be even */
@@ -208,13 +215,17 @@ static int ar0521_read_reg(struct ar0521_dev *sensor, u16 reg, u16 *val)
 
 static int ar0521_set_geometry(struct ar0521_dev *sensor)
 {
+	/* Center the image in the visible ouput window. */
+	u16 x = clamp((AR0521_WIDTH_MAX - sensor->fmt.width) / 2,
+		       AR0521_MIN_X_ADDR_START, AR0521_MAX_X_ADDR_END);
+	u16 y = clamp(((AR0521_HEIGHT_MAX - sensor->fmt.height) / 2) & ~1,
+		       AR0521_MIN_Y_ADDR_START, AR0521_MAX_Y_ADDR_END);
+
 	/* All dimensions are unsigned 12-bit integers */
-	u16 x = (AR0521_WIDTH_MAX - sensor->fmt.width) / 2;
-	u16 y = ((AR0521_HEIGHT_MAX - sensor->fmt.height) / 2) & ~1;
 	__be16 regs[] = {
 		be(AR0521_REG_FRAME_LENGTH_LINES),
-		be(sensor->total_height),
-		be(sensor->total_width),
+		be(sensor->fmt.height + sensor->ctrls.vblank->val),
+		be(sensor->fmt.width + sensor->ctrls.hblank->val),
 		be(x),
 		be(y),
 		be(x + sensor->fmt.width - 1),
-- 
2.37.3


  parent reply	other threads:[~2022-10-05 19:06 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 19:06 [PATCH 00/10] media: ar0521: Add analog gain, rework clock tree Jacopo Mondi
2022-10-05 19:06 ` [PATCH 01/10] media: ar0521: Implement enum_frame_sizes Jacopo Mondi
2022-10-06 14:37   ` Dave Stevenson
2022-10-06 16:33   ` Laurent Pinchart
2022-10-07  4:57     ` Krzysztof Hałasa
2022-10-07  8:08       ` Laurent Pinchart
2022-10-07  7:29     ` Jacopo Mondi
2022-10-07  8:11       ` Laurent Pinchart
2022-10-07 10:32         ` Dave Stevenson
2022-10-07 12:05           ` Sakari Ailus
2022-10-07 12:12             ` Laurent Pinchart
2022-10-05 19:06 ` [PATCH 02/10] media: ar0521: Add V4L2_CID_ANALOG_GAIN Jacopo Mondi
2022-10-06 14:44   ` Dave Stevenson
2022-10-06 15:00     ` Jacopo Mondi
2022-10-06 15:05       ` Laurent Pinchart
2022-10-07  5:28         ` Krzysztof Hałasa
2022-10-07  8:20           ` Laurent Pinchart
2022-10-12 18:54             ` Sakari Ailus
2022-10-13  9:30               ` Laurent Pinchart
2022-10-07  5:20   ` Krzysztof Hałasa
2022-10-07  7:17     ` Jacopo Mondi
2022-10-07  8:30       ` Laurent Pinchart
2022-10-07 12:01         ` Krzysztof Hałasa
2022-10-07 12:07           ` Laurent Pinchart
2022-10-07 14:02             ` Krzysztof Hałasa
2022-10-17 15:10         ` Jacopo Mondi
2022-10-17 15:57           ` Sakari Ailus
2022-10-17 16:31             ` Jacopo Mondi
2022-10-17 16:37               ` Sakari Ailus
2022-10-17 16:42               ` Dave Stevenson
2022-10-07 11:56       ` Krzysztof Hałasa
2022-10-07 12:11         ` Laurent Pinchart
2022-10-07 14:00           ` Krzysztof Hałasa
2022-10-05 19:06 ` Jacopo Mondi [this message]
2022-10-06 14:57   ` [PATCH 03/10] media: ar0521: Set maximum resolution to 2592x1944 Dave Stevenson
2022-10-07 13:06     ` Laurent Pinchart
2022-10-20 11:23       ` Jacopo Mondi
2022-10-07  5:33   ` Krzysztof Hałasa
2022-10-07 12:42     ` Jacopo Mondi
2022-10-07 14:07       ` Krzysztof Hałasa
2022-10-05 19:06 ` [PATCH 04/10] media: ar0521: Rework PLL computation Jacopo Mondi
2022-10-07 13:56   ` Laurent Pinchart
2022-10-12 19:02     ` Sakari Ailus
2022-10-13  9:31       ` Laurent Pinchart
2022-10-05 19:06 ` [PATCH 05/10] media: ar0521: Add LINK_FREQ control Jacopo Mondi
2022-10-06 15:10   ` Dave Stevenson
2022-10-07 14:01     ` Laurent Pinchart
2022-10-07 14:26       ` Dave Stevenson
2022-10-16  1:53         ` Laurent Pinchart
2022-10-17 11:21           ` Dave Stevenson
2022-10-17  9:24         ` Jacopo Mondi
2022-10-17 11:00           ` Dave Stevenson
2022-10-17 12:00             ` Jacopo Mondi
2022-10-05 19:06 ` [PATCH 06/10] media: ar0521: Configure pixel rate using LINK_FREQ Jacopo Mondi
2022-10-06  5:51   ` kernel test robot
2022-10-06 15:42   ` Sakari Ailus
2022-10-07  7:25     ` Jacopo Mondi
2022-10-07  5:52   ` Krzysztof Hałasa
2022-10-05 19:06 ` [PATCH 07/10] media: ar0521: Adjust exposure and blankings limits Jacopo Mondi
2022-10-06  2:08   ` kernel test robot
2022-10-06  4:17   ` kernel test robot
2022-10-06 15:41   ` Dave Stevenson
2022-10-05 19:06 ` [PATCH 08/10] media: ar0521: Setup controls at s_stream time Jacopo Mondi
2022-10-06 15:43   ` Dave Stevenson
2022-10-07  7:23     ` Jacopo Mondi
2022-10-05 19:06 ` [PATCH 09/10] media: ar0521: Rework startup sequence Jacopo Mondi
2022-10-06 15:45   ` Dave Stevenson
2022-10-05 19:06 ` [PATCH 10/10] media: ar0521: Tab-align definitions Jacopo Mondi
2022-10-06 15:48   ` Dave Stevenson
2022-10-06 16:11   ` Laurent Pinchart
2022-10-07  5:42   ` Krzysztof Hałasa

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=20221005190613.394277-4-jacopo@jmondi.org \
    --to=jacopo@jmondi.org \
    --cc=khalasa@piap.pl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@iki.fi \
    /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;
as well as URLs for NNTP newsgroup(s).