Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp606427lqj; Sun, 2 Jun 2024 13:25:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSW0RFlbHBVuDwdsPcl5BVyINaJVT69CkAX9qwb7E1FmuTTdFsW2Dy4K4zDpYbBoy5tn0UNNZUvu4qdf8phBwYT+EKC9cGZUWe76MPUQ== X-Google-Smtp-Source: AGHT+IECsrcGeS9W2DSuUpgPcXUIv0S2uip4vH3hELjRjMLn8WfAGWedzt3FvrEmYfjb6ggi7rHI X-Received: by 2002:a05:620a:4043:b0:795:b3d:54b9 with SMTP id af79cd13be357-7950b3d56b6mr110514285a.10.1717359901969; Sun, 02 Jun 2024 13:25:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717359901; cv=pass; d=google.com; s=arc-20160816; b=uNDJofLLf013eSDdZV7ZZbucdzVdKQ14vZDNg8ampnvueR2QmXII5KE2gIGcz29WV8 q8Is6nR1LbjR2JhabMIZneFaAqd84Bu5faZP/GWBDBdpKTakNVmPUZmR4SSnAvaQ4TMt 2R6rVSvuUkMr+0p4eZw8SK8OCwUPutMa5VZUD6f/cwiXk11bpUE8fj8zyyW8xTxt7f0e 3MGqXXha6W+MTRamKvgs2VP/XUheOp+yUDb6f8eycBdHMA6JQ9uesFoNtjC+8FdEhrFP KR/pMH0mfNMx+5aCJJhUoQ1nOtXBvS+fe09f2CpWcVc5qX1Bsq3yRiOjxCk0eMMMIr+7 jpWw== 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=8JaICCDIbxfFQFB9p4l2NBR215uf+cJpoqKWqbp9IrI=; fh=ng0FUFwPgHHqIHtWcUlLUSBs0e7fHIUGeuUhfcQSRgA=; b=hm51km7O549OACA4Ld8qDD1w0Gqp2OGCh9phNDIlnK0S62l4/kRK/m+Mm/Hd7DRM5u 0ShoPwL85ARicdgWJtNkPLzU/px6XjpD1yIWofkJsCUmYlh5QW3Fei0yTswbxG5Tuk23 PlvpE67QvomooqAfYVjY2RVWN1EoezTo6S7CEMc1jSUwDNd30cfDMcajtfJEEjfKMKz3 JXZkU/G2iJ28bTRhLdnsBZn7Qg3ipAklMfp44r8+e4AheVPJLFJyLiAfG7A95u/fL+p/ 8H3mdqsv6yVQQymaxBJuIcbepJ/FlqzymAYpw0oL+x+TIHT9rxrfUFplA7awxK2inLIK PR2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@luigi311.com header.s=x header.b=EE7R9Cas; arc=pass (i=1 spf=pass spfdomain=luigi311.com dkim=pass dkdomain=luigi311.com); spf=pass (google.com: domain of linux-kernel+bounces-198422-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198422-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794f317faf9si716008485a.455.2024.06.02.13.25.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 13:25:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198422-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=fail header.i=@luigi311.com header.s=x header.b=EE7R9Cas; arc=pass (i=1 spf=pass spfdomain=luigi311.com dkim=pass dkdomain=luigi311.com); spf=pass (google.com: domain of linux-kernel+bounces-198422-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198422-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3C0AB1C22348 for ; Sun, 2 Jun 2024 20:25:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BCE8A85286; Sun, 2 Jun 2024 20:20:51 +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="EE7R9Cas" Received: from mail-108-mta204.mxroute.com (mail-108-mta204.mxroute.com [136.175.108.204]) (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 62BCA81730 for ; Sun, 2 Jun 2024 20:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=136.175.108.204 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717359650; cv=none; b=oyEYLmOoKTvDZeb/HlKKkDZmntEiHHpMTa+w6HBHsdtfWACsuTuUyb01Ms/qTKLrGeD5uVyIqbLyudIVAJJ+4O61U3fuLYA0XfWgHmaHKSuNVU1qZAPbkmddT9oQaPmiuAQznyJM0XrnT3oMuE+EW7hNq4f7asm9vCMoeDbVEXE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717359650; c=relaxed/simple; bh=/appuRh7QR4oppenmbepS6ozjwx24OFaCqI22tl7X/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=psbbVWl9/ZXV1Quy7VFpiz8rvHvg2oGJObMGtPKl1guEbL9KJC936pKUPm8PVcI9Zz+m/+Lj6hJjSA0iASHZO1dceI/Mj4TK1VoYUKoFZKknGLQbNoGj58JDcrGGu+pA6CzNVjGbVINGNP0PfUhTA/Jv9Rq+zzDdixzZXgzVrGg= 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=EE7R9Cas; arc=none smtp.client-ip=136.175.108.204 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.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta204.mxroute.com (ZoneMTA) with ESMTPSA id 18fda96e8c9000e2b6.010 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sun, 02 Jun 2024 20:14:34 +0000 X-Zone-Loop: 52e5fba3aa0f73a0e6aa9df5f207e8c064e2f6b0a497 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=luigi311.com; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: 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=8JaICCDIbxfFQFB9p4l2NBR215uf+cJpoqKWqbp9IrI=; b=EE7R9CasiTwutVKUKjVSoQe6TP tFHI6I2oIj67o/ApWq9Uiu1aat3KXnrP8jzaOes3esZ54wojMAgKSKu47N/Z5PJgwg4Magu8bcj5K nXeRnEsynI9kHr9/PLi5R9yobcny7iCZU/OfkL93llLsjdFQvdp5NnNRk6wZ8h7fvClLCafjQb7CP y1CJCDpGu13WUiff/MNUoFv2jfyQgW/qoZpU+iFohegZ7Tb6aSuFqRkkevtiH9S9QbXad78iQ8Hnc j+b8slpxlBc7GeGCKcgL3N4x9BglZn2vTm7YsYEad2CspU5pv2Osum6Xh6cO5JF42Mn5w8zIcjy5m h2mFpY7A==; 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 v6 19/23] media: i2c: imx258: Change register settings for variants of the sensor Date: Sun, 2 Jun 2024 14:13:41 -0600 Message-ID: <20240602201345.328737-20-git@luigi311.com> In-Reply-To: <20240602201345.328737-1-git@luigi311.com> References: <20240602201345.328737-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-Transfer-Encoding: 8bit X-Authenticated-Id: personal@luigi311.com From: Dave Stevenson Sony have advised that there are variants of the IMX258 sensor which require slightly different register configuration to the mainline imx258 driver defaults. There is no available run-time detection for the variant, so add configuration via the DT compatible string. The Vision Components imx258 module supports PDAF, so add the register differences for that variant Signed-off-by: Dave Stevenson Signed-off-by: Luis Garcia Reviewed-by: Pavel Machek --- drivers/media/i2c/imx258.c | 47 ++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c index 32267d36b8f3..54f7625e60a3 100644 --- a/drivers/media/i2c/imx258.c +++ b/drivers/media/i2c/imx258.c @@ -321,8 +321,6 @@ static const struct imx258_reg mipi_642mbps_24mhz_4l[] = { static const struct imx258_reg mode_common_regs[] = { { 0x3051, 0x00 }, - { 0x3052, 0x00 }, - { 0x4E21, 0x14 }, { 0x6B11, 0xCF }, { 0x7FF0, 0x08 }, { 0x7FF1, 0x0F }, @@ -345,7 +343,6 @@ static const struct imx258_reg mode_common_regs[] = { { 0x7FA8, 0x03 }, { 0x7FA9, 0xFE }, { 0x7B24, 0x81 }, - { 0x7B25, 0x00 }, { 0x6564, 0x07 }, { 0x6B0D, 0x41 }, { 0x653D, 0x04 }, @@ -460,6 +457,33 @@ static const struct imx258_reg mode_1048_780_regs[] = { { 0x034F, 0x0C }, }; +struct imx258_variant_cfg { + const struct imx258_reg *regs; + unsigned int num_regs; +}; + +static const struct imx258_reg imx258_cfg_regs[] = { + { 0x3052, 0x00 }, + { 0x4E21, 0x14 }, + { 0x7B25, 0x00 }, +}; + +static const struct imx258_variant_cfg imx258_cfg = { + .regs = imx258_cfg_regs, + .num_regs = ARRAY_SIZE(imx258_cfg_regs), +}; + +static const struct imx258_reg imx258_pdaf_cfg_regs[] = { + { 0x3052, 0x01 }, + { 0x4E21, 0x10 }, + { 0x7B25, 0x01 }, +}; + +static const struct imx258_variant_cfg imx258_pdaf_cfg = { + .regs = imx258_pdaf_cfg_regs, + .num_regs = ARRAY_SIZE(imx258_pdaf_cfg_regs), +}; + static const char * const imx258_test_pattern_menu[] = { "Disabled", "Solid Colour", @@ -637,6 +661,8 @@ struct imx258 { struct v4l2_subdev sd; struct media_pad pad; + const struct imx258_variant_cfg *variant_cfg; + struct v4l2_ctrl_handler ctrl_handler; /* V4L2 Controls */ struct v4l2_ctrl *link_freq; @@ -1104,6 +1130,14 @@ static int imx258_start_streaming(struct imx258 *imx258) return ret; } + ret = imx258_write_regs(imx258, imx258->variant_cfg->regs, + imx258->variant_cfg->num_regs); + if (ret) { + dev_err(&client->dev, "%s failed to set variant config\n", + __func__); + return ret; + } + ret = imx258_write_reg(imx258, IMX258_CLK_BLANK_STOP, IMX258_REG_VALUE_08BIT, !!(imx258->csi2_flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK)); @@ -1491,6 +1525,10 @@ static int imx258_probe(struct i2c_client *client) imx258->csi2_flags = ep.bus.mipi_csi2.flags; + imx258->variant_cfg = device_get_match_data(&client->dev); + if (!imx258->variant_cfg) + imx258->variant_cfg = &imx258_cfg; + /* Initialize subdev */ v4l2_i2c_subdev_init(&imx258->sd, client, &imx258_subdev_ops); @@ -1578,7 +1616,8 @@ MODULE_DEVICE_TABLE(acpi, imx258_acpi_ids); #endif static const struct of_device_id imx258_dt_ids[] = { - { .compatible = "sony,imx258" }, + { .compatible = "sony,imx258", .data = &imx258_cfg }, + { .compatible = "sony,imx258-pdaf", .data = &imx258_pdaf_cfg }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, imx258_dt_ids); -- 2.44.0