Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp548838lqm; Wed, 1 May 2024 08:30:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbztTOd3nBUTQuQLAKF26Qjt6yaNriUG+VD4/lw1ODwx/HkKu6qbwJXKis7gs6ysguklE29Lg2BfuY8CRxpe9aw6nCtqA1IBEyLB4NWQ== X-Google-Smtp-Source: AGHT+IHCzLl14hD4HNmPpwcqbOn8fOriu4bKNj6yqMpkHr9vLcagZM2OAIRGdCWEsyWe+7otGJFO X-Received: by 2002:a17:907:1703:b0:a58:7982:6282 with SMTP id le3-20020a170907170300b00a5879826282mr2053738ejc.62.1714577438702; Wed, 01 May 2024 08:30:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714577438; cv=pass; d=google.com; s=arc-20160816; b=ofTOGZyhXDvmBLrhAuyqcMAwGMC1ns143DXUxWFMPB47frHH+2+vzmVyB6nGSQovxh yk7OAXB+sbmFAA/C29y8hAN+ZI7xMOo32rLR5hSxo881KBPvggZbBvtjJc5qp8ZHCCfP mOeLthefg/Iuzy/JcsFcUdGO9FrhGAhP3VwC4Hvxm798vcgUDSKINR6AXEwf+TZ5q9am 8xFAvPyJwV4HsCCIkQIUJPxJjmcIjIwqhyxJdbSckYk5K5DbSlNhNu0RuL4k3kVEDa10 s68o8mlSV1YlB4SyzYofsZlEtXKuW71+3JB/d+TjjMZzl5oWU4lqD0JUBdWqd8pTK+xx a/sw== ARC-Message-Signature: i=2; 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=IrtZw3b4fhqGfwqS79xHpjO252TynNZZi9NyZ5yPxfc=; fh=ng0FUFwPgHHqIHtWcUlLUSBs0e7fHIUGeuUhfcQSRgA=; b=GkhdSvoJqwL+/44a7bsPq//tzCyGuskDS4957kdxNZyi5oeUHNQrQMvqfyAJXddzB2 aoj5GFEtS2VkzYRkB8Os6axvix5oaap5EqvGD1b3Oen1CixsS7WeFJStayyClIPbTj5o B/x28tVte2Qm7XAiDvBSKuN0TZybhKGmOr5TnPcK8p74rSygDgzLcu0OWhIzM+myESLH B65NaPlNsyc1c+U/GnxEAbuawWbyHDcG9Vcv+ZaE5hcr2IoV9JSXSfdBdFLCKWpemw1d 181/DXvMWuxYc1Jutk291Lb3o2disc3PA/NL4jsLB/rpBr78lsyqxzOCsKQZVKsY3etR cg+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@luigi311.com header.s=x header.b=uNcbOdjs; arc=pass (i=1 spf=pass spfdomain=luigi311.com dkim=pass dkdomain=luigi311.com); spf=pass (google.com: domain of linux-kernel+bounces-165477-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165477-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x5-20020a1709064bc500b00a5886064b7asi9258843ejv.740.2024.05.01.08.30.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 08:30:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165477-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=fail header.i=@luigi311.com header.s=x header.b=uNcbOdjs; arc=pass (i=1 spf=pass spfdomain=luigi311.com dkim=pass dkdomain=luigi311.com); spf=pass (google.com: domain of linux-kernel+bounces-165477-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165477-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 465961F214C8 for ; Wed, 1 May 2024 15:30:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3403312FF77; Wed, 1 May 2024 15:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=luigi311.com header.i=@luigi311.com header.b="uNcbOdjs" Received: from mail-108-mta13.mxroute.com (mail-108-mta13.mxroute.com [136.175.108.13]) (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 A03B112F5B6 for ; Wed, 1 May 2024 15:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=136.175.108.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714577413; cv=none; b=Dsg7Of/cGS8VOlqLeN59gImz+CtPe+AqHKNzes0Ni0QCSfhcL8KnlBk49fuA18XyMQ++hb0PUNJuJhr4TVzOeDy9383Ix0ImhOqy3JZImQtPLYJIONxJQepbgqAFDITlB6+t2A0XaEYOZ/uqMXuWu7V9dLiARVSims712COGlj4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714577413; c=relaxed/simple; bh=8VdBRsDDSp5wkUn0ulACN2P9epAxMpmNx+w+XhJIpks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ADVK7eM3cHpuGpeCHqmsCouLwtRbnnrjDdEuZxs0vrMQJolx1UxiylUUafu3YCyIhS2BCtca9rdpoS8rumDN8ejZkHDoMoWQmlzBM+pI5TDT93IT+6YMY56WeKuAcNZkn9YuNndLOLBDfVG7sCs1hsSLqOj5ziQQ7fc9vD/awI4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=luigi311.com; spf=pass smtp.mailfrom=luigi311.com; dkim=pass (2048-bit key) header.d=luigi311.com header.i=@luigi311.com header.b=uNcbOdjs; arc=none smtp.client-ip=136.175.108.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=luigi311.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=luigi311.com Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta13.mxroute.com (ZoneMTA) with ESMTPSA id 18f34c238d50008ca2.010 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 01 May 2024 15:24:54 +0000 X-Zone-Loop: f9d88afe67590ae59047f148333fffbf6a6920e2762d DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=luigi311.com; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=IrtZw3b4fhqGfwqS79xHpjO252TynNZZi9NyZ5yPxfc=; b=uNcbOdjsWkvLbKOmpCj4jjzEVH IXhyTDvyNMA16+G4C3codJmOjbtx0lH5NRmCJS8Lvybwk1ioplEKIjF4mxUc2+fMa3v9ubwqbenQH KcByf4jIM0m7z9rNdAI7AotoMY60+YU/l2lajvZkSgxqM6LBvz1AoVVHhTpH3LcoRZfKLi0fPY+E/ kihyb7RQYu9CciQIQpx9PX+WKikap5ERid16n3Ch19zyHnfmFKlTpR9yr+NrD8nmDL4O5/DEpYy+V H21PJ5eiFNh59xqGRsh8SugCbIOqUVwlMRmExvQRQlmJU5OFQDvoGJZhX8BYVtLp/mFzDVWPoeV9q ELMxnhCg==; From: git@luigi311.com To: linux-media@vger.kernel.org Cc: dave.stevenson@raspberrypi.com, jacopo.mondi@ideasonboard.com, mchehab@kernel.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, sakari.ailus@linux.intel.com, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, pavel@ucw.cz, phone-devel@vger.kernel.org, Luis Garcia Subject: [PATCH v5 02/25] media: i2c: imx258: Make image geometry meet sensor requirements Date: Wed, 1 May 2024 09:24:19 -0600 Message-ID: <20240501152442.1072627-3-git@luigi311.com> In-Reply-To: <20240501152442.1072627-1-git@luigi311.com> References: <20240501152442.1072627-1-git@luigi311.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Authenticated-Id: personal@luigi311.com From: Dave Stevenson The output image is defined as being 4208x3118 pixels in size. Y_ADD_STA register was set to 0, and Y_ADD_END to 3118, giving 3119 lines total. The datasheet lists a requirement for Y_ADD_STA to be a multiple of a power of 2 depending on binning/scaling mode (2 for full pixel, 4 for x2-bin/scale, 8 for (x2-bin)+(x2-subsample) or x4-bin, or 16 for (x4-bin)+(x2-subsample)). (Y_ADD_END – Y_ADD_STA + 1) also has to be a similar power of 2. The current configuration for the full res modes breaks that second requirement, and we can't increase Y_ADD_STA to 1 to retain exactly the same field of view as that then breaks the first requirement. For the binned modes, they are worse off as 3118 is not a multiple of 4. Increase the main mode to 4208x3120 so that it is the same FOV as the binned modes, with Y_ADD_STA at 0. Fix Y_ADD_STA and Y_ADD_END for the binned modes so that they meet the sensor requirements. This does change the Bayer order as the default configuration is for H&V flips to be enabled, so readout is from Y_STA_END to Y_ADD_STA, and this patch has changed Y_STA_END. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi Signed-off-by: Luis Garcia Reviewed-by: Pavel Machek --- drivers/media/i2c/imx258.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c index 2dbafd21dd70..4a7048d834c6 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -111,7 +111,7 @@ struct imx258_mode { struct imx258_reg_list reg_list; }; -/* 4208x3118 needs 1267Mbps/lane, 4 lanes */ +/* 4208x3120 needs 1267Mbps/lane, 4 lanes */ static const struct imx258_reg mipi_data_rate_1267mbps[] = { { 0x0301, 0x05 }, { 0x0303, 0x02 }, @@ -148,7 +148,7 @@ static const struct imx258_reg mipi_data_rate_640mbps[] = { { 0x0823, 0x00 }, }; -static const struct imx258_reg mode_4208x3118_regs[] = { +static const struct imx258_reg mode_4208x3120_regs[] = { { 0x0136, 0x13 }, { 0x0137, 0x33 }, { 0x3051, 0x00 }, @@ -210,7 +210,7 @@ static const struct imx258_reg mode_4208x3118_regs[] = { { 0x0348, 0x10 }, { 0x0349, 0x6F }, { 0x034A, 0x0C }, - { 0x034B, 0x2E }, + { 0x034B, 0x2F }, { 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, @@ -329,7 +329,7 @@ static const struct imx258_reg mode_2104_1560_regs[] = { { 0x0348, 0x10 }, { 0x0349, 0x6F }, { 0x034A, 0x0C }, - { 0x034B, 0x2E }, + { 0x034B, 0x2F }, { 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, @@ -448,7 +448,7 @@ static const struct imx258_reg mode_1048_780_regs[] = { { 0x0348, 0x10 }, { 0x0349, 0x6F }, { 0x034A, 0x0C }, - { 0x034B, 0x2E }, + { 0x034B, 0x2F }, { 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, @@ -562,12 +562,12 @@ static const struct imx258_link_freq_config link_freq_configs[] = { static const struct imx258_mode supported_modes[] = { { .width = 4208, - .height = 3118, + .height = 3120, .vts_def = IMX258_VTS_30FPS, .vts_min = IMX258_VTS_30FPS, .reg_list = { - .num_of_regs = ARRAY_SIZE(mode_4208x3118_regs), - .regs = mode_4208x3118_regs, + .num_of_regs = ARRAY_SIZE(mode_4208x3120_regs), + .regs = mode_4208x3120_regs, }, .link_freq_index = IMX258_LINK_FREQ_1267MBPS, }, @@ -707,7 +707,7 @@ static int imx258_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) /* Initialize try_fmt */ try_fmt->width = supported_modes[0].width; try_fmt->height = supported_modes[0].height; - try_fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; + try_fmt->code = MEDIA_BUS_FMT_SBGGR10_1X10; try_fmt->field = V4L2_FIELD_NONE; return 0; @@ -819,7 +819,7 @@ static int imx258_enum_mbus_code(struct v4l2_subdev *sd, if (code->index > 0) return -EINVAL; - code->code = MEDIA_BUS_FMT_SGRBG10_1X10; + code->code = MEDIA_BUS_FMT_SBGGR10_1X10; return 0; } @@ -831,7 +831,7 @@ static int imx258_enum_frame_size(struct v4l2_subdev *sd, if (fse->index >= ARRAY_SIZE(supported_modes)) return -EINVAL; - if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) + if (fse->code != MEDIA_BUS_FMT_SBGGR10_1X10) return -EINVAL; fse->min_width = supported_modes[fse->index].width; @@ -847,7 +847,7 @@ static void imx258_update_pad_format(const struct imx258_mode *mode, { fmt->format.width = mode->width; fmt->format.height = mode->height; - fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; + fmt->format.code = MEDIA_BUS_FMT_SBGGR10_1X10; fmt->format.field = V4L2_FIELD_NONE; } @@ -894,7 +894,7 @@ static int imx258_set_pad_format(struct v4l2_subdev *sd, mutex_lock(&imx258->mutex); /* Only one raw bayer(GBRG) order is supported */ - fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; + fmt->format.code = MEDIA_BUS_FMT_SBGGR10_1X10; mode = v4l2_find_nearest_size(supported_modes, ARRAY_SIZE(supported_modes), width, height, -- 2.44.0