Message ID | 20231218174042.794012-16-mike.rudenko@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-4200-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1415923dyi; Mon, 18 Dec 2023 09:48:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtNM7WWYsB1dds7azCpVDjQVKvxAVQSmag71wG/VXz2OmY+VFx76AoB3XBJd5cdC2WrWpX X-Received: by 2002:a05:6358:e911:b0:170:17ea:f4e5 with SMTP id gk17-20020a056358e91100b0017017eaf4e5mr15586500rwb.50.1702921722425; Mon, 18 Dec 2023 09:48:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702921722; cv=none; d=google.com; s=arc-20160816; b=nHm97HY+wqldYwZTleTmGzFjC6bjMsaFGaU6fZ15tfs+eS9DfhjjmDQ3q9Ebe5ymNj 6Efbt6QzlLePUL8KIAGDRZIgJpibyDI3eI1fxJizR6rcKsa4dqq2MqjpZteRHeqBz6X9 Iofk9BF906pBSgv8gNrBrq43p3+KXqhqnQFPZFkYCv1ct0Z7KOOBPSR2z/4cyE0Ezoqo wlB7HMRumJ5O6i0ZpOkrPOK7tTE1SwdQ4dNhH1A+UTYV8m/CesFAP09m1MlG2vrBSiO5 4LQlsi3DWQbyCZcNb2i0hv+huaLSs4a+e2MF6KrbAefSLO4lpi7oCe6Ym6jj39uHNMBS j/lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4SjlvAuV+ITVZU87l8JftGavoBHWbV2WagI03hZeup4=; fh=Ft8dYvEuFIKwnehVwpL0WG7QMIrRLMi0wgN4ll940k8=; b=mDp1BX+cemYbOMIkz6XTi/vM795iPUoBObQrL8dbirk2MXl94PtEUD1M5dVvXlr89r 5JFGYfbk3fU/q6eY0azQbP8d7AXHl7KWGMcOkdcG2q9iNV0FQvUzMNsHmeEdvoUxwC7i ImPeRlyAyNZor6xJYgS0gMlrywyd8X28KBR/nZ7OIujgOODb/A3FqnxOJBkNCu0X5HjD habY3IS/KGQ0LTuSAdLfbGVYOydAxICI+83vb46b9ypSjFFBe4Ev5ULNAkJETq/CBNa2 WkTtmQhpDPJzKZU+Z8nnY8jxjQ1pxaya1H9Jhsfu2t9q/fVFZN4O4QLiok1PdBgG23FN OOpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NzD3u9KZ; spf=pass (google.com: domain of linux-kernel+bounces-4200-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4200-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id bz16-20020a056a02061000b005cd9b52f8b1si2160852pgb.792.2023.12.18.09.48.42 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 09:48:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4200-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NzD3u9KZ; spf=pass (google.com: domain of linux-kernel+bounces-4200-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4200-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 99B73B23032 for <ouuuleilei@gmail.com>; Mon, 18 Dec 2023 17:47:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 444B87C66A; Mon, 18 Dec 2023 17:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NzD3u9KZ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7826B79955; Mon, 18 Dec 2023 17:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-50bf2d9b3fdso4627940e87.3; Mon, 18 Dec 2023 09:41:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702921277; x=1703526077; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4SjlvAuV+ITVZU87l8JftGavoBHWbV2WagI03hZeup4=; b=NzD3u9KZ6UbCKI8H7DB1Z3O7fH8g3PkrclL6XA/Wn8Gp4jCt4ozpGz1fQRdG7ykA9c /s4gAaTORzIqOiduM403whLdWgr0dXbK8YHoyVm7oSPjoNU3k5WBkpWkB9/gH7v7OloP mGtM2kc6SEWZSDslkfncHQhnx8vHtZr2ks+nYAc/pbK2h9wLWWuW77bNiRc5HT3TRPRM g2UdkNFe4XP0o6cfaDHakr38O783eQhJQeAtpXn4vU7rcoHR3H5A/f2ufevoO0Nq5SUx nPZPOQ2ct03xuK5BzRd4Bi04xljL4hITeVSwTvGKr/SZlj5oCZ+gvYf/WLrFTL7wAq9t ksdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702921277; x=1703526077; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4SjlvAuV+ITVZU87l8JftGavoBHWbV2WagI03hZeup4=; b=Ca3YdSxwHNcqjksxti0zSct4SFbCJAS3unlCIKXOr6YrRCt0kDCfTJCqoVbXqTQb2x mDBdPf+N6iz8nQuWSx6hSHiFo9PF5TuaR7/unq5Kzg/d/GmCcMhJpKBtW1SJ2HYPHJw7 ZwnS9h8m2F4q4b/CgQYg83TlQwLeR32qifHIq6W6DBP9n2X6FSUDOceF00w5jCwJoY/X XDK+Bymk+F619qDkT+62okgs22iHtVoXh9eBberecydnPz0MhlezZWWx7tXRNiK+xax6 tlWt5TtX8uFfm2txN7zF7cX5vSeegreLpq8eY5YUcgu9HQIUfJF3MU/nZneIBivoUcwr uwjg== X-Gm-Message-State: AOJu0YxkLZnLCF4I/s8Web6HdWrwWoGxKkOAVjGiOi8T71lYGZCzsqur 25GHnU0XxIqFkrTTDKojTTMGh05MvGd5xg== X-Received: by 2002:ac2:419a:0:b0:50c:222b:2489 with SMTP id z26-20020ac2419a000000b0050c222b2489mr6965947lfh.135.1702921276912; Mon, 18 Dec 2023 09:41:16 -0800 (PST) Received: from localhost ([83.149.246.185]) by smtp.gmail.com with ESMTPSA id f9-20020a0565123b0900b0050e3b2646a0sm265645lfv.152.2023.12.18.09.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 09:41:16 -0800 (PST) From: Mikhail Rudenko <mike.rudenko@gmail.com> To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sakari Ailus <sakari.ailus@linux.intel.com>, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Jacopo Mondi <jacopo@jmondi.org>, Tommaso Merciai <tomm.merciai@gmail.com>, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, Dave Stevenson <dave.stevenson@raspberrypi.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Mikhail Rudenko <mike.rudenko@gmail.com> Subject: [PATCH v2 15/20] media: i2c: ov4689: Move pixel array size out of struct ov4689_mode Date: Mon, 18 Dec 2023 20:40:36 +0300 Message-ID: <20231218174042.794012-16-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218174042.794012-1-mike.rudenko@gmail.com> References: <20231218174042.794012-1-mike.rudenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785642848445229289 X-GMAIL-MSGID: 1785642848445229289 |
Series |
Omnivision OV4689 refactoring and improvements
|
|
Commit Message
Mikhail Rudenko
Dec. 18, 2023, 5:40 p.m. UTC
Pixel array dimensions and default crop size do not belong to the
ov4689_mode structure, since they are mode independent. Make them
defines instead.
Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>
---
drivers/media/i2c/ov4689.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
Comments
Hi Mikhail, Thank you for the patch. On Mon, Dec 18, 2023 at 08:40:36PM +0300, Mikhail Rudenko wrote: > Pixel array dimensions and default crop size do not belong to the > ov4689_mode structure, since they are mode independent. Make them > defines instead. > > Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com> > --- > drivers/media/i2c/ov4689.c | 29 +++++++++++++---------------- > 1 file changed, 13 insertions(+), 16 deletions(-) > > diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c > index b43fb1d7b15f..475508559e3e 100644 > --- a/drivers/media/i2c/ov4689.c > +++ b/drivers/media/i2c/ov4689.c > @@ -70,6 +70,11 @@ > #define OV4689_LANES 4 > #define OV4689_XVCLK_FREQ 24000000 > > +#define OV4689_PIXEL_ARRAY_WIDTH 2720 > +#define OV4689_PIXEL_ARRAY_HEIGHT 1536 > +#define OV4689_DUMMY_ROWS 8 > +#define OV4689_DUMMY_COLUMNS 16 Adding a comment here to indicate that there are dummy columns in each side would be useful: #define OV4689_DUMMY_ROWS 8 /* 8 dummy rows on each side */ #define OV4689_DUMMY_COLUMNS 16 /* 16 dummy columns on each side */ Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > + > static const char *const ov4689_supply_names[] = { > "avdd", /* Analog power */ > "dovdd", /* Digital I/O power */ > @@ -90,10 +95,6 @@ struct ov4689_mode { > u32 vts_def; > u32 exp_def; > u32 pixel_rate; > - u32 sensor_width; > - u32 sensor_height; > - u32 crop_top; > - u32 crop_left; > const struct cci_reg_sequence *reg_list; > unsigned int num_regs; > }; > @@ -254,10 +255,6 @@ static const struct ov4689_mode supported_modes[] = { > .id = OV4689_MODE_2688_1520, > .width = 2688, > .height = 1520, > - .sensor_width = 2720, > - .sensor_height = 1536, > - .crop_top = 8, > - .crop_left = 16, > .exp_def = 1536, > .hts_def = 10296, > .hts_min = 3432, > @@ -385,8 +382,6 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, > struct v4l2_subdev_state *state, > struct v4l2_subdev_selection *sel) > { > - const struct ov4689_mode *mode = to_ov4689(sd)->cur_mode; > - > if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE) > return -EINVAL; > > @@ -394,15 +389,17 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, > case V4L2_SEL_TGT_CROP_BOUNDS: > sel->r.top = 0; > sel->r.left = 0; > - sel->r.width = mode->sensor_width; > - sel->r.height = mode->sensor_height; > + sel->r.width = OV4689_PIXEL_ARRAY_WIDTH; > + sel->r.height = OV4689_PIXEL_ARRAY_HEIGHT; > return 0; > case V4L2_SEL_TGT_CROP: > case V4L2_SEL_TGT_CROP_DEFAULT: > - sel->r.top = mode->crop_top; > - sel->r.left = mode->crop_left; > - sel->r.width = mode->width; > - sel->r.height = mode->height; > + sel->r.top = OV4689_DUMMY_ROWS; > + sel->r.left = OV4689_DUMMY_COLUMNS; > + sel->r.width = > + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_COLUMNS; > + sel->r.height = > + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_ROWS; > return 0; > } >
On Fri, Feb 23, 2024 at 01:33:01PM +0200, Laurent Pinchart wrote: > Hi Mikhail, > > Thank you for the patch. > > On Mon, Dec 18, 2023 at 08:40:36PM +0300, Mikhail Rudenko wrote: > > Pixel array dimensions and default crop size do not belong to the > > ov4689_mode structure, since they are mode independent. Make them > > defines instead. > > > > Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com> > > --- > > drivers/media/i2c/ov4689.c | 29 +++++++++++++---------------- > > 1 file changed, 13 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c > > index b43fb1d7b15f..475508559e3e 100644 > > --- a/drivers/media/i2c/ov4689.c > > +++ b/drivers/media/i2c/ov4689.c > > @@ -70,6 +70,11 @@ > > #define OV4689_LANES 4 > > #define OV4689_XVCLK_FREQ 24000000 > > > > +#define OV4689_PIXEL_ARRAY_WIDTH 2720 > > +#define OV4689_PIXEL_ARRAY_HEIGHT 1536 > > +#define OV4689_DUMMY_ROWS 8 > > +#define OV4689_DUMMY_COLUMNS 16 > > Adding a comment here to indicate that there are dummy columns in each > side would be useful: > > #define OV4689_DUMMY_ROWS 8 /* 8 dummy rows on each side */ > #define OV4689_DUMMY_COLUMNS 16 /* 16 dummy columns on each side */ > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > > + > > static const char *const ov4689_supply_names[] = { > > "avdd", /* Analog power */ > > "dovdd", /* Digital I/O power */ > > @@ -90,10 +95,6 @@ struct ov4689_mode { > > u32 vts_def; > > u32 exp_def; > > u32 pixel_rate; > > - u32 sensor_width; > > - u32 sensor_height; > > - u32 crop_top; > > - u32 crop_left; > > const struct cci_reg_sequence *reg_list; > > unsigned int num_regs; > > }; > > @@ -254,10 +255,6 @@ static const struct ov4689_mode supported_modes[] = { > > .id = OV4689_MODE_2688_1520, > > .width = 2688, > > .height = 1520, > > - .sensor_width = 2720, > > - .sensor_height = 1536, > > - .crop_top = 8, > > - .crop_left = 16, > > .exp_def = 1536, > > .hts_def = 10296, > > .hts_min = 3432, > > @@ -385,8 +382,6 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, > > struct v4l2_subdev_state *state, > > struct v4l2_subdev_selection *sel) > > { > > - const struct ov4689_mode *mode = to_ov4689(sd)->cur_mode; > > - > > if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE) > > return -EINVAL; > > > > @@ -394,15 +389,17 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, > > case V4L2_SEL_TGT_CROP_BOUNDS: > > sel->r.top = 0; > > sel->r.left = 0; > > - sel->r.width = mode->sensor_width; > > - sel->r.height = mode->sensor_height; > > + sel->r.width = OV4689_PIXEL_ARRAY_WIDTH; > > + sel->r.height = OV4689_PIXEL_ARRAY_HEIGHT; > > return 0; > > case V4L2_SEL_TGT_CROP: > > case V4L2_SEL_TGT_CROP_DEFAULT: > > - sel->r.top = mode->crop_top; > > - sel->r.left = mode->crop_left; > > - sel->r.width = mode->width; > > - sel->r.height = mode->height; > > + sel->r.top = OV4689_DUMMY_ROWS; > > + sel->r.left = OV4689_DUMMY_COLUMNS; > > + sel->r.width = > > + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_COLUMNS; > > + sel->r.height = > > + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_ROWS; I spoke too fast: this should be OV4689_PIXEL_ARRAY_HEIGHT, not OV4689_PIXEL_ARRAY_WIDTH. > > return 0; > > } > >
Hi Laurent, and thanks for the review! On 2024-02-23 at 13:33 +02, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > Hi Mikhail, > > Thank you for the patch. > > On Mon, Dec 18, 2023 at 08:40:36PM +0300, Mikhail Rudenko wrote: >> Pixel array dimensions and default crop size do not belong to the >> ov4689_mode structure, since they are mode independent. Make them >> defines instead. >> >> Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com> >> --- >> drivers/media/i2c/ov4689.c | 29 +++++++++++++---------------- >> 1 file changed, 13 insertions(+), 16 deletions(-) >> >> diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c >> index b43fb1d7b15f..475508559e3e 100644 >> --- a/drivers/media/i2c/ov4689.c >> +++ b/drivers/media/i2c/ov4689.c >> @@ -70,6 +70,11 @@ >> #define OV4689_LANES 4 >> #define OV4689_XVCLK_FREQ 24000000 >> >> +#define OV4689_PIXEL_ARRAY_WIDTH 2720 >> +#define OV4689_PIXEL_ARRAY_HEIGHT 1536 >> +#define OV4689_DUMMY_ROWS 8 >> +#define OV4689_DUMMY_COLUMNS 16 > > Adding a comment here to indicate that there are dummy columns in each > side would be useful: > > #define OV4689_DUMMY_ROWS 8 /* 8 dummy rows on each side */ > #define OV4689_DUMMY_COLUMNS 16 /* 16 dummy columns on each side */ Will add the comments in v3. > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > >> + >> static const char *const ov4689_supply_names[] = { >> "avdd", /* Analog power */ >> "dovdd", /* Digital I/O power */ >> @@ -90,10 +95,6 @@ struct ov4689_mode { >> u32 vts_def; >> u32 exp_def; >> u32 pixel_rate; >> - u32 sensor_width; >> - u32 sensor_height; >> - u32 crop_top; >> - u32 crop_left; >> const struct cci_reg_sequence *reg_list; >> unsigned int num_regs; >> }; >> @@ -254,10 +255,6 @@ static const struct ov4689_mode supported_modes[] = { >> .id = OV4689_MODE_2688_1520, >> .width = 2688, >> .height = 1520, >> - .sensor_width = 2720, >> - .sensor_height = 1536, >> - .crop_top = 8, >> - .crop_left = 16, >> .exp_def = 1536, >> .hts_def = 10296, >> .hts_min = 3432, >> @@ -385,8 +382,6 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, >> struct v4l2_subdev_state *state, >> struct v4l2_subdev_selection *sel) >> { >> - const struct ov4689_mode *mode = to_ov4689(sd)->cur_mode; >> - >> if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE) >> return -EINVAL; >> >> @@ -394,15 +389,17 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, >> case V4L2_SEL_TGT_CROP_BOUNDS: >> sel->r.top = 0; >> sel->r.left = 0; >> - sel->r.width = mode->sensor_width; >> - sel->r.height = mode->sensor_height; >> + sel->r.width = OV4689_PIXEL_ARRAY_WIDTH; >> + sel->r.height = OV4689_PIXEL_ARRAY_HEIGHT; >> return 0; >> case V4L2_SEL_TGT_CROP: >> case V4L2_SEL_TGT_CROP_DEFAULT: >> - sel->r.top = mode->crop_top; >> - sel->r.left = mode->crop_left; >> - sel->r.width = mode->width; >> - sel->r.height = mode->height; >> + sel->r.top = OV4689_DUMMY_ROWS; >> + sel->r.left = OV4689_DUMMY_COLUMNS; >> + sel->r.width = >> + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_COLUMNS; >> + sel->r.height = >> + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_ROWS; >> return 0; >> } >> -- Best regards, Mikhail Rudenko
Hi Laurent, and thanks for the review! On 2024-02-23 at 13:36 +02, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > On Fri, Feb 23, 2024 at 01:33:01PM +0200, Laurent Pinchart wrote: >> Hi Mikhail, >> >> Thank you for the patch. >> >> On Mon, Dec 18, 2023 at 08:40:36PM +0300, Mikhail Rudenko wrote: >> > Pixel array dimensions and default crop size do not belong to the >> > ov4689_mode structure, since they are mode independent. Make them >> > defines instead. >> > >> > Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com> >> > --- >> > drivers/media/i2c/ov4689.c | 29 +++++++++++++---------------- >> > 1 file changed, 13 insertions(+), 16 deletions(-) >> > >> > diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c >> > index b43fb1d7b15f..475508559e3e 100644 >> > --- a/drivers/media/i2c/ov4689.c >> > +++ b/drivers/media/i2c/ov4689.c >> > @@ -70,6 +70,11 @@ >> > #define OV4689_LANES 4 >> > #define OV4689_XVCLK_FREQ 24000000 >> > >> > +#define OV4689_PIXEL_ARRAY_WIDTH 2720 >> > +#define OV4689_PIXEL_ARRAY_HEIGHT 1536 >> > +#define OV4689_DUMMY_ROWS 8 >> > +#define OV4689_DUMMY_COLUMNS 16 >> >> Adding a comment here to indicate that there are dummy columns in each >> side would be useful: >> >> #define OV4689_DUMMY_ROWS 8 /* 8 dummy rows on each side */ >> #define OV4689_DUMMY_COLUMNS 16 /* 16 dummy columns on each side */ >> >> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> >> >> > + >> > static const char *const ov4689_supply_names[] = { >> > "avdd", /* Analog power */ >> > "dovdd", /* Digital I/O power */ >> > @@ -90,10 +95,6 @@ struct ov4689_mode { >> > u32 vts_def; >> > u32 exp_def; >> > u32 pixel_rate; >> > - u32 sensor_width; >> > - u32 sensor_height; >> > - u32 crop_top; >> > - u32 crop_left; >> > const struct cci_reg_sequence *reg_list; >> > unsigned int num_regs; >> > }; >> > @@ -254,10 +255,6 @@ static const struct ov4689_mode supported_modes[] = { >> > .id = OV4689_MODE_2688_1520, >> > .width = 2688, >> > .height = 1520, >> > - .sensor_width = 2720, >> > - .sensor_height = 1536, >> > - .crop_top = 8, >> > - .crop_left = 16, >> > .exp_def = 1536, >> > .hts_def = 10296, >> > .hts_min = 3432, >> > @@ -385,8 +382,6 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, >> > struct v4l2_subdev_state *state, >> > struct v4l2_subdev_selection *sel) >> > { >> > - const struct ov4689_mode *mode = to_ov4689(sd)->cur_mode; >> > - >> > if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE) >> > return -EINVAL; >> > >> > @@ -394,15 +389,17 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, >> > case V4L2_SEL_TGT_CROP_BOUNDS: >> > sel->r.top = 0; >> > sel->r.left = 0; >> > - sel->r.width = mode->sensor_width; >> > - sel->r.height = mode->sensor_height; >> > + sel->r.width = OV4689_PIXEL_ARRAY_WIDTH; >> > + sel->r.height = OV4689_PIXEL_ARRAY_HEIGHT; >> > return 0; >> > case V4L2_SEL_TGT_CROP: >> > case V4L2_SEL_TGT_CROP_DEFAULT: >> > - sel->r.top = mode->crop_top; >> > - sel->r.left = mode->crop_left; >> > - sel->r.width = mode->width; >> > - sel->r.height = mode->height; >> > + sel->r.top = OV4689_DUMMY_ROWS; >> > + sel->r.left = OV4689_DUMMY_COLUMNS; >> > + sel->r.width = >> > + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_COLUMNS; >> > + sel->r.height = >> > + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_ROWS; > > I spoke too fast: this should be OV4689_PIXEL_ARRAY_HEIGHT, not > OV4689_PIXEL_ARRAY_WIDTH. Good catch, will fix in v3. >> > return 0; >> > } >> > -- Best regards, Mikhail Rudenko
diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c index b43fb1d7b15f..475508559e3e 100644 --- a/drivers/media/i2c/ov4689.c +++ b/drivers/media/i2c/ov4689.c @@ -70,6 +70,11 @@ #define OV4689_LANES 4 #define OV4689_XVCLK_FREQ 24000000 +#define OV4689_PIXEL_ARRAY_WIDTH 2720 +#define OV4689_PIXEL_ARRAY_HEIGHT 1536 +#define OV4689_DUMMY_ROWS 8 +#define OV4689_DUMMY_COLUMNS 16 + static const char *const ov4689_supply_names[] = { "avdd", /* Analog power */ "dovdd", /* Digital I/O power */ @@ -90,10 +95,6 @@ struct ov4689_mode { u32 vts_def; u32 exp_def; u32 pixel_rate; - u32 sensor_width; - u32 sensor_height; - u32 crop_top; - u32 crop_left; const struct cci_reg_sequence *reg_list; unsigned int num_regs; }; @@ -254,10 +255,6 @@ static const struct ov4689_mode supported_modes[] = { .id = OV4689_MODE_2688_1520, .width = 2688, .height = 1520, - .sensor_width = 2720, - .sensor_height = 1536, - .crop_top = 8, - .crop_left = 16, .exp_def = 1536, .hts_def = 10296, .hts_min = 3432, @@ -385,8 +382,6 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, struct v4l2_subdev_selection *sel) { - const struct ov4689_mode *mode = to_ov4689(sd)->cur_mode; - if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE) return -EINVAL; @@ -394,15 +389,17 @@ static int ov4689_get_selection(struct v4l2_subdev *sd, case V4L2_SEL_TGT_CROP_BOUNDS: sel->r.top = 0; sel->r.left = 0; - sel->r.width = mode->sensor_width; - sel->r.height = mode->sensor_height; + sel->r.width = OV4689_PIXEL_ARRAY_WIDTH; + sel->r.height = OV4689_PIXEL_ARRAY_HEIGHT; return 0; case V4L2_SEL_TGT_CROP: case V4L2_SEL_TGT_CROP_DEFAULT: - sel->r.top = mode->crop_top; - sel->r.left = mode->crop_left; - sel->r.width = mode->width; - sel->r.height = mode->height; + sel->r.top = OV4689_DUMMY_ROWS; + sel->r.left = OV4689_DUMMY_COLUMNS; + sel->r.width = + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_COLUMNS; + sel->r.height = + OV4689_PIXEL_ARRAY_WIDTH - 2 * OV4689_DUMMY_ROWS; return 0; }