From patchwork Mon Dec 11 12:59:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 176700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7027127vqy; Mon, 11 Dec 2023 05:01:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeJfCmSCLOXBlc04sKxHB0JVa7D9sEZxsaVF7kyBK4Dx/0UQCY6nEDtOnsZXZ++mX4b+FX X-Received: by 2002:a05:6a00:98e:b0:6ce:6185:44e1 with SMTP id u14-20020a056a00098e00b006ce618544e1mr1598136pfg.66.1702299673207; Mon, 11 Dec 2023 05:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702299673; cv=none; d=google.com; s=arc-20160816; b=iXOIsUSexeaJclfQciYFA8RO/7uL/1AmXkhr24iSc81YlWOySuhYlOX9sbIWVzs3p/ 3yj0utclLKuqLRGLeBYEsIBZsNpJlOwuBVPy1GEVI8/tDpeuDTgLqmZlXvcUI/aOCqZL KuAUEiFVFtRR+jD5VRrLVrs4SQazpNmMwddYP08TyW1BMWvF1QuE0CaAv5LpuwSLaAqw sVum5OPv0NKd3wY04ZeElqMYyHtjr7F0aETbN1QLknaitf4caZAawfI+i+xXxFGcpSDy 6XV8XTLLWmnaIQwVUZgN5aLPJ3XMTrZdaJ8Cvq57/2GiIVVWrXezZ87oj1p/otYM5xdO vOlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9raE1iEe7VHLrDxpp1Eq2fGIzfERIgvV3vdrTJYvbf0=; fh=bLq+AfyUG0PvDD86sBC3PjYv3mcdi6nM0HmnqDX7KHg=; b=oBijGuTsyZMVil0wPBcPzfFyw6vgAXbUOjLiwbxdN8kKIjrxEwLZ6r+9HB49V/7MWr u3H2OxUPLJgUo6ZuUocYyEhVBul6Aj9nIh6F9+6y29TUnE+6BNcxCaDN4OevOvip+OMD eNbPbjWTChDNtJBK10z4iZw9/OMHz+L1Xj8pL/TAweX6F9gwVtxPRutrCXmxOXZLT/PJ iVWh1mYa3I2X0FpYVRRe7wpPoSADhKFWPU+bapQuFF5FLHeItstlbABRTZ9mcE2ljfmn w9fTT1mN2wQJ0f0MmEtQFvDR9nQHA9xKU8Cjw/HFRHO+nZYRmOLLoBOr4NF3fSAmyGgr EMIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=LfM0MBLh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id c8-20020a63d508000000b005c65f924f6csi5866976pgg.319.2023.12.11.05.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:01:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=LfM0MBLh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 678DB8080C69; Mon, 11 Dec 2023 05:00:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234877AbjLKNAI (ORCPT + 99 others); Mon, 11 Dec 2023 08:00:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234810AbjLKNAI (ORCPT ); Mon, 11 Dec 2023 08:00:08 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55EFCD1; Mon, 11 Dec 2023 05:00:13 -0800 (PST) Received: from umang.jain (unknown [103.251.226.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 67275C58; Mon, 11 Dec 2023 13:59:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702299565; bh=z/kiy682Dt+Hkip6mn8zt4qO+eGw8bGSkyh8qcwql68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LfM0MBLhxg3j2w3rYKk5q/H2G70LXzKtypbsgoo/NCdpovsNsjZMfuFdvzbabrXyG bacs4rFE+JjgBMyG3h9hE4gi7Z3PUIgtXGYzAB29vIkGV3nZ9t1La82Jub5p55wwab MDbeMjwqQpLAJaF5/7BUiI2B1ZkTlOhtujrNpPpA= From: Umang Jain To: devicetree@vger.kernel.org, linux-media@vger.kernel.org Cc: "Paul J . Murphy" , Daniele Alessandrelli , Sakari Ailus , Mauro Carvalho Chehab , Kieran Bingham , Umang Jain , Marco Felsch , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Bartosz Golaszewski , Sebastian Reichel , Wolfram Sang , linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 1/7] media: dt-bindings: media: imx335: Add supply bindings Date: Mon, 11 Dec 2023 18:29:43 +0530 Message-ID: <20231211125950.108092-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211125950.108092-1-umang.jain@ideasonboard.com> References: <20231211125950.108092-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:00:18 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784990582380065264 X-GMAIL-MSGID: 1784990582380065264 From: Kieran Bingham Add the bindings for the supply references used on the IMX335. Reviewed-by: Umang Jain Reviewed-by: Marco Felsch Signed-off-by: Kieran Bingham Acked-by: Conor Dooley --- .../devicetree/bindings/media/i2c/sony,imx335.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx335.yaml b/Documentation/devicetree/bindings/media/i2c/sony,imx335.yaml index a167dcdb3a32..106c36ee966d 100644 --- a/Documentation/devicetree/bindings/media/i2c/sony,imx335.yaml +++ b/Documentation/devicetree/bindings/media/i2c/sony,imx335.yaml @@ -32,6 +32,15 @@ properties: description: Clock frequency from 6 to 27 MHz, 37.125MHz, 74.25MHz maxItems: 1 + avdd-supply: + description: Analog power supply (2.9V) + + ovdd-supply: + description: Interface power supply (1.8V) + + dvdd-supply: + description: Digital power supply (1.2V) + reset-gpios: description: Reference to the GPIO connected to the XCLR pin, if any. maxItems: 1 @@ -79,6 +88,10 @@ examples: assigned-clock-parents = <&imx335_clk_parent>; assigned-clock-rates = <24000000>; + avdd-supply = <&camera_vdda_2v9>; + ovdd-supply = <&camera_vddo_1v8>; + dvdd-supply = <&camera_vddd_1v2>; + port { imx335: endpoint { remote-endpoint = <&cam>; From patchwork Mon Dec 11 12:59:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 176703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7027557vqy; Mon, 11 Dec 2023 05:01:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHiTR3pqAfwNsILToX9fo9Y8KhrBNT0M0AulK8NE4YPCminCPtM+FcCyASDHn62mUsJDkY X-Received: by 2002:a05:6a00:1808:b0:6cd:fbb8:e364 with SMTP id y8-20020a056a00180800b006cdfbb8e364mr1611024pfa.4.1702299697244; Mon, 11 Dec 2023 05:01:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702299697; cv=none; d=google.com; s=arc-20160816; b=Bp18sL9hPOp4xn2OznOfZ1dBWXQwNmml19lhWao/7wk4sVqNs5+fqJbTItN0+3wS6h qOideJb+w5QKpkeqshPHYH0421VjmLzTKZFnabGX5cVkaBPhljXsMzkWvGU5NzgApojc YbGUlYbVVcfCHrrQjQI/tA/f4xTaf65LdNG5PLxjlemcszWLb5lFOzek8h6nhTDxZ+/Y ti4Qaxqrld86JmnyOBR69BWXSCkdZefnpJy1R4nO2YJqP3VCE88V05WGh56TNuqkBLll ipw02IE/Ijp2fTggAbBm3dipTPotg01reGOjs0ANdHgSkSIn/7GSKLuJvDlie5bifaEv MYyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b3kR+VQCZYja6LRk02SmdJgmEQaRE49JSb60jV4TQwY=; fh=Yk9qGc+v7LukZZWXmqWgCONZxO+gXHLBxo5X+kiGegE=; b=dZoogyFiPkaPa+Ngx9OIOeX5/ThJjR6XOG1mm0SlbuN4Om5JJHEWKFll8Tq0ddto9P K7ZTSVdM1VEUjKO+ogV3My0L4UwND50NIo01frGYz/WsbRTDk/nY04BGhNo0aIrncQzI wIW+b1kBnTtOwpiY9INkSMHETC4hEnYz2f0xkFTu6zJ2fjmDG/HqTlpz++IwYZg2Effv lqEgcMDQU7v/GtKxHQhrD45L3A9q27N5ITahgLI9ZFy5ro57Z0fVC2g1QbApHa92oX4D Zwnqwa9/iZdJl3OToYgNG4XNfr/b6x0eTnbNY5IgZgUFsyqLSdQcU7Y1x5OP6ZxCSiG1 9mvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=uO++KGBK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ct19-20020a056a000f9300b006ce36ffa533si6074924pfb.374.2023.12.11.05.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:01:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=uO++KGBK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id F1B31807E45C; Mon, 11 Dec 2023 05:00:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343541AbjLKNAK (ORCPT + 99 others); Mon, 11 Dec 2023 08:00:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234876AbjLKNAI (ORCPT ); Mon, 11 Dec 2023 08:00:08 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B891CC4; Mon, 11 Dec 2023 05:00:13 -0800 (PST) Received: from umang.jain (unknown [103.251.226.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 61CB113C5; Mon, 11 Dec 2023 13:59:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702299568; bh=vdBDEHa63Ev7PN0hPwHFfzuEjM8qmpReQEme7VFbTz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uO++KGBKFVP61ImqE8QyJtq+YmFINCTePMPi/C58iNFxWROSP7D8YBc3GS6R/Jg6J gKqOqfR6Ss6YShqjiDDBpPye/yLBi/Qm901Dfmvst/XasV8vx5KpumN+H+fwOdTD1t 0TZ1m39/Nn1oEjNV4ZMUSaBd52md6gYB6l9yYfME= From: Umang Jain To: devicetree@vger.kernel.org, linux-media@vger.kernel.org Cc: "Paul J . Murphy" , Daniele Alessandrelli , Sakari Ailus , Mauro Carvalho Chehab , Kieran Bingham , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 2/7] media: i2c: imx335: Fix logging line endings Date: Mon, 11 Dec 2023 18:29:44 +0530 Message-ID: <20231211125950.108092-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211125950.108092-1-umang.jain@ideasonboard.com> References: <20231211125950.108092-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:00:58 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784990607186134627 X-GMAIL-MSGID: 1784990607186134627 From: Kieran Bingham The use of \n as a line ending throughout the driver is inconsistent. While it is possible for logging messages to automatically have newlines added by the kernel printk mechanisms, this is specifically to support continued lines with PR_CONT and the lack of a new line character indicates that the text is a fragment of a continuation line. As each of these lines are whole and not fragments, explicitly define the newline for consistency. Signed-off-by: Kieran Bingham --- drivers/media/i2c/imx335.c | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index ec729126274b..cbabef968e21 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -396,7 +396,7 @@ static int imx335_update_exp_gain(struct imx335 *imx335, u32 exposure, u32 gain) lpfr = imx335->vblank + imx335->cur_mode->height; shutter = lpfr - exposure; - dev_dbg(imx335->dev, "Set exp %u, analog gain %u, shutter %u, lpfr %u", + dev_dbg(imx335->dev, "Set exp %u, analog gain %u, shutter %u, lpfr %u\n", exposure, gain, shutter, lpfr); ret = imx335_write_reg(imx335, IMX335_REG_HOLD, 1, 1); @@ -443,7 +443,7 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_VBLANK: imx335->vblank = imx335->vblank_ctrl->val; - dev_dbg(imx335->dev, "Received vblank %u, new lpfr %u", + dev_dbg(imx335->dev, "Received vblank %u, new lpfr %u\n", imx335->vblank, imx335->vblank + imx335->cur_mode->height); @@ -462,7 +462,7 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl) exposure = ctrl->val; analog_gain = imx335->again_ctrl->val; - dev_dbg(imx335->dev, "Received exp %u, analog gain %u", + dev_dbg(imx335->dev, "Received exp %u, analog gain %u\n", exposure, analog_gain); ret = imx335_update_exp_gain(imx335, exposure, analog_gain); @@ -471,7 +471,7 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl) break; default: - dev_err(imx335->dev, "Invalid control %d", ctrl->id); + dev_err(imx335->dev, "Invalid control %d\n", ctrl->id); ret = -EINVAL; } @@ -652,14 +652,14 @@ static int imx335_start_streaming(struct imx335 *imx335) ret = imx335_write_regs(imx335, reg_list->regs, reg_list->num_of_regs); if (ret) { - dev_err(imx335->dev, "fail to write initial registers"); + dev_err(imx335->dev, "fail to write initial registers\n"); return ret; } /* Setup handler will write actual exposure and gain */ ret = __v4l2_ctrl_handler_setup(imx335->sd.ctrl_handler); if (ret) { - dev_err(imx335->dev, "fail to setup handler"); + dev_err(imx335->dev, "fail to setup handler\n"); return ret; } @@ -667,7 +667,7 @@ static int imx335_start_streaming(struct imx335 *imx335) ret = imx335_write_reg(imx335, IMX335_REG_MODE_SELECT, 1, IMX335_MODE_STREAMING); if (ret) { - dev_err(imx335->dev, "fail to start streaming"); + dev_err(imx335->dev, "fail to start streaming\n"); return ret; } @@ -744,7 +744,7 @@ static int imx335_detect(struct imx335 *imx335) return ret; if (val != IMX335_ID) { - dev_err(imx335->dev, "chip id mismatch: %x!=%x", + dev_err(imx335->dev, "chip id mismatch: %x!=%x\n", IMX335_ID, val); return -ENXIO; } @@ -776,7 +776,7 @@ static int imx335_parse_hw_config(struct imx335 *imx335) imx335->reset_gpio = devm_gpiod_get_optional(imx335->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(imx335->reset_gpio)) { - dev_err(imx335->dev, "failed to get reset gpio %ld", + dev_err(imx335->dev, "failed to get reset gpio %ld\n", PTR_ERR(imx335->reset_gpio)); return PTR_ERR(imx335->reset_gpio); } @@ -784,13 +784,13 @@ static int imx335_parse_hw_config(struct imx335 *imx335) /* Get sensor input clock */ imx335->inclk = devm_clk_get(imx335->dev, NULL); if (IS_ERR(imx335->inclk)) { - dev_err(imx335->dev, "could not get inclk"); + dev_err(imx335->dev, "could not get inclk\n"); return PTR_ERR(imx335->inclk); } rate = clk_get_rate(imx335->inclk); if (rate != IMX335_INCLK_RATE) { - dev_err(imx335->dev, "inclk frequency mismatch"); + dev_err(imx335->dev, "inclk frequency mismatch\n"); return -EINVAL; } @@ -805,14 +805,14 @@ static int imx335_parse_hw_config(struct imx335 *imx335) if (bus_cfg.bus.mipi_csi2.num_data_lanes != IMX335_NUM_DATA_LANES) { dev_err(imx335->dev, - "number of CSI2 data lanes %d is not supported", + "number of CSI2 data lanes %d is not supported\n", bus_cfg.bus.mipi_csi2.num_data_lanes); ret = -EINVAL; goto done_endpoint_free; } if (!bus_cfg.nr_of_link_frequencies) { - dev_err(imx335->dev, "no link frequencies defined"); + dev_err(imx335->dev, "no link frequencies defined\n"); ret = -EINVAL; goto done_endpoint_free; } @@ -863,7 +863,7 @@ static int imx335_power_on(struct device *dev) ret = clk_prepare_enable(imx335->inclk); if (ret) { - dev_err(imx335->dev, "fail to enable inclk"); + dev_err(imx335->dev, "fail to enable inclk\n"); goto error_reset; } @@ -969,7 +969,7 @@ static int imx335_init_controls(struct imx335 *imx335) imx335->hblank_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; if (ctrl_hdlr->error) { - dev_err(imx335->dev, "control init failed: %d", + dev_err(imx335->dev, "control init failed: %d\n", ctrl_hdlr->error); v4l2_ctrl_handler_free(ctrl_hdlr); return ctrl_hdlr->error; @@ -1002,7 +1002,7 @@ static int imx335_probe(struct i2c_client *client) ret = imx335_parse_hw_config(imx335); if (ret) { - dev_err(imx335->dev, "HW configuration is not supported"); + dev_err(imx335->dev, "HW configuration is not supported\n"); return ret; } @@ -1010,14 +1010,14 @@ static int imx335_probe(struct i2c_client *client) ret = imx335_power_on(imx335->dev); if (ret) { - dev_err(imx335->dev, "failed to power-on the sensor"); + dev_err(imx335->dev, "failed to power-on the sensor\n"); goto error_mutex_destroy; } /* Check module identity */ ret = imx335_detect(imx335); if (ret) { - dev_err(imx335->dev, "failed to find sensor: %d", ret); + dev_err(imx335->dev, "failed to find sensor: %d\n", ret); goto error_power_off; } @@ -1027,7 +1027,7 @@ static int imx335_probe(struct i2c_client *client) ret = imx335_init_controls(imx335); if (ret) { - dev_err(imx335->dev, "failed to init controls: %d", ret); + dev_err(imx335->dev, "failed to init controls: %d\n", ret); goto error_power_off; } @@ -1039,14 +1039,14 @@ static int imx335_probe(struct i2c_client *client) imx335->pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_pads_init(&imx335->sd.entity, 1, &imx335->pad); if (ret) { - dev_err(imx335->dev, "failed to init entity pads: %d", ret); + dev_err(imx335->dev, "failed to init entity pads: %d\n", ret); goto error_handler_free; } ret = v4l2_async_register_subdev_sensor(&imx335->sd); if (ret < 0) { dev_err(imx335->dev, - "failed to register async subdev: %d", ret); + "failed to register async subdev: %d\n", ret); goto error_media_entity; } From patchwork Mon Dec 11 12:59:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 176698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7026750vqy; Mon, 11 Dec 2023 05:00:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw3i3ywLQeQywBO735KxHPxtuVHFELvfGtk28uNn771yJaKk+WvP1R9v5ZRqQLRyzz8YTk X-Received: by 2002:a17:902:8301:b0:1d0:bcb2:4b8a with SMTP id bd1-20020a170902830100b001d0bcb24b8amr1518409plb.131.1702299650833; Mon, 11 Dec 2023 05:00:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702299650; cv=none; d=google.com; s=arc-20160816; b=0rE5kriO7enwCxu8Lp5p0ZE9hvKnxIQUOKGV7iOQf754OqKHAYfd7FeoBr0COCtY5c WMG5y+MQUIRML2GyFfq1OkRJBEGwW752eyYO6IbN30gmcVFTG3rXpGVKIuiDnUBcrB36 HNI+gIJ8cHRFRlEXQZ+LxiBHzFp06DQHBzESm7zvoN9lxC0mG8mSxvPOeEPKYq3+RK7m k/7EHGfsRDiXwPHUapjm5LexUSKVqfGIVKf4qs/yK0spR3US2hmnwcyW6FwC7JaQXI8M IZwq3sjMA1/sIxQ6gMjWU5fj7e/igNQVgVL0RKScToPi+cQ7Z42lWuJ/VRMVtry+wvee U7Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Xei5QZR7EI9E2ALHhuyyu7xvQSP/1ScbuB7sw/eepHw=; fh=5WFlYumxFb4YMTIyFXnieMfGzo3YjRfO3j2f2Wqiw4A=; b=kZXeY0Sfc/p334ncb31WxIOB5EWNWh7+wYxgMTxoTKOmynSWJV/PjsUdU0rkJYtyjd k4A+pQyFzpYGAUISYgua+V3i8YquH/u0JovPvOgWgJFYOrE3vqySofc39d+nFzDGINb/ vkX6PwauDZFJoltstNYWzmDkKesBp2nYmYeiq88ce3NvPh9DXj7GJmiId0KZes6y8VAt 41856r5GNe1Y8OzNVcTK27e9SsyoQXe0KUizmaQbUrqz4Nn0H72Lpnl/qh2uH25Re87B OljMOeenXlgTh8WXqvfSGBUdsNCG4SMrCvIfU3G9Oqpi2chhkhdI36FezuHq5xddjM8C FQdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SxighCXQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id e9-20020a17090301c900b001cfaeeb91a3si6047004plh.474.2023.12.11.05.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:00:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SxighCXQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 89D0D8096463; Mon, 11 Dec 2023 05:00:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234880AbjLKNAS (ORCPT + 99 others); Mon, 11 Dec 2023 08:00:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343569AbjLKNAK (ORCPT ); Mon, 11 Dec 2023 08:00:10 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E522C3; Mon, 11 Dec 2023 05:00:16 -0800 (PST) Received: from umang.jain (unknown [103.251.226.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1D33F1515; Mon, 11 Dec 2023 13:59:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702299571; bh=nrEAdhHZwA2L0AvxJ6FGfgqEfXwThQSUE+QCVNTuuhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SxighCXQ1l/fbMew3D4DHzVOHOVrQheuTYk5MLyvbcd2T0B/Py5iVrOursO8VWZTi KIzyYBkzkKkq3Vy8srl0yz3FvAoa0SOAdvNoId6iqSfHP222DugtUir/2acfy5m+lZ 0pO4DSI9apyNgWDWuhfW0fnqyZ152HnpUmbr0GWU= From: Umang Jain To: devicetree@vger.kernel.org, linux-media@vger.kernel.org Cc: "Paul J . Murphy" , Daniele Alessandrelli , Sakari Ailus , Mauro Carvalho Chehab , Kieran Bingham , Umang Jain , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 3/7] media: i2c: imx335: Improve configuration error reporting Date: Mon, 11 Dec 2023 18:29:45 +0530 Message-ID: <20231211125950.108092-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211125950.108092-1-umang.jain@ideasonboard.com> References: <20231211125950.108092-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:00:33 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784990558416326970 X-GMAIL-MSGID: 1784990558416326970 From: Kieran Bingham The existing imx335_parse_hw_config function has two paths that can be taken without reporting to the user the reason for failing to accept the hardware configuration. Extend the error reporting paths to identify failures when probing the device. Reviewed-by: Umang Jain Signed-off-by: Kieran Bingham --- drivers/media/i2c/imx335.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index cbabef968e21..31c612c6bdd8 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -795,8 +795,10 @@ static int imx335_parse_hw_config(struct imx335 *imx335) } ep = fwnode_graph_get_next_endpoint(fwnode, NULL); - if (!ep) + if (!ep) { + dev_err(imx335->dev, "Failed to get next endpoint\n"); return -ENXIO; + } ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); fwnode_handle_put(ep); @@ -821,6 +823,8 @@ static int imx335_parse_hw_config(struct imx335 *imx335) if (bus_cfg.link_frequencies[i] == IMX335_LINK_FREQ) goto done_endpoint_free; + dev_err(imx335->dev, "no compatible link frequencies found\n"); + ret = -EINVAL; done_endpoint_free: From patchwork Mon Dec 11 12:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 176697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7026645vqy; Mon, 11 Dec 2023 05:00:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IElY+nE8vpKQgvYzOL6VcIlF0RTmQNkJSmqDP6QMTfzrkYgNyPjSps026ilHZvWS6KqM8xN X-Received: by 2002:a17:902:a386:b0:1d0:6ffd:adef with SMTP id x6-20020a170902a38600b001d06ffdadefmr1617188pla.86.1702299645136; Mon, 11 Dec 2023 05:00:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702299645; cv=none; d=google.com; s=arc-20160816; b=yVqOvDsbTqbmsa5xzDY9qpGhgfYyzuHUGVrYc0A4bZA3T6KB9c5yCk/rKqkLQSr6qz BGX0u9Uhb4I5heu1aJSZ7d35YAmfppB1qG2LHx08C2Sc6CcI/6xNqlom/z14Z+9mV0vP 1kAJvoqn6k3PbxdUEno6/5lAbshHs0PR9twQmyM16M5oav9Z85wa6XYJsnE+1r1fCACD jiTYU7PGzIxM1tAtN17BL94JWbU/imBMPNvSCCsdkv4jCjMXpBjiOe5/REDRbTdMNYpI d5ZlUHZE+HWXvRTH3wUp6Z7FGNXzAHmwJ/bXnUEcw1XkKTtQUZc4znYQEcibam4Y4Kec 05OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GtNDvssx05zcXGmlLTUeNnm/+fzL17sxCVTQvB1LrbY=; fh=Yk9qGc+v7LukZZWXmqWgCONZxO+gXHLBxo5X+kiGegE=; b=0G4DrBR/FJgLeZJdTTbb7fJtbNNnl0FNsnJ0o/0lhUGL/CdvBukfaZI6jiCCISIQvd mMyjWD6pXHgkYVzm3ahbU0RfYgTgpnKfSNq57nYuU7qBExScou2Wpn/swUgf1Yc/CWS7 J7G133qbRwGQK99pRWmClQjSuCG9rDvyYft7D1YNV0vBRdVFs7v4WP0FsFJXk4EWElLF 26mkB8kAsFvomRYvL2FwMpdcc8e6IyBBM38MaT/iTY/nivDQgROIKFhrtIwnGDvyzkwF lu3c625AEpQK5HTQIT2P2cEbQaazQ3myQfYiZgXqG2xSxft+7zDgQ3E3gSX39+e8iYu6 Kmjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="jjHaR/rQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b13-20020a170902d50d00b001c73626a1ffsi6213713plg.412.2023.12.11.05.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:00:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="jjHaR/rQ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AC876805F94C; Mon, 11 Dec 2023 05:00:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343619AbjLKNAV (ORCPT + 99 others); Mon, 11 Dec 2023 08:00:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234916AbjLKNAQ (ORCPT ); Mon, 11 Dec 2023 08:00:16 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41805DB; Mon, 11 Dec 2023 05:00:19 -0800 (PST) Received: from umang.jain (unknown [103.251.226.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 12B45922; Mon, 11 Dec 2023 13:59:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702299574; bh=dPSuxJaKB+CIuZJvHrsCSRjEJHKIU9bjVIDtso3S4bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jjHaR/rQcngM1nQ/l0Xc9DCaiAyJQ4ZinqGTuD+FseBnDZYKTHCAm+cmXtdC/B5U/ nbgbcoP3jRqZdIo9F9PebiZf44YtPZ9vFrI8V3vD9QLaJjlJ+/TpbfvJPIeoO+atoP jaS807uwnhmijG54E2egOP2RfEIgxpa3yW7k1PpA= From: Umang Jain To: devicetree@vger.kernel.org, linux-media@vger.kernel.org Cc: "Paul J . Murphy" , Daniele Alessandrelli , Sakari Ailus , Mauro Carvalho Chehab , Kieran Bingham , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 4/7] media: i2c: imx335: Enable regulator supplies Date: Mon, 11 Dec 2023 18:29:46 +0530 Message-ID: <20231211125950.108092-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211125950.108092-1-umang.jain@ideasonboard.com> References: <20231211125950.108092-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:00:35 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784990552879239485 X-GMAIL-MSGID: 1784990552879239485 From: Kieran Bingham Provide support for enabling and disabling regulator supplies to control power to the camera sensor. While updating the power on function, document that a sleep is represented as 'T4' in the datasheet power on sequence. Signed-off-by: Kieran Bingham --- drivers/media/i2c/imx335.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index 31c612c6bdd8..b25216b3350e 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -75,6 +75,12 @@ struct imx335_reg_list { const struct imx335_reg *regs; }; +static const char * const imx335_supply_name[] = { + "avdd", /* Analog (2.9V) supply */ + "ovdd", /* Digital I/O (1.8V) supply */ + "dvdd", /* Digital Core (1.2V) supply */ +}; + /** * struct imx335_mode - imx335 sensor mode structure * @width: Frame width @@ -108,6 +114,7 @@ struct imx335_mode { * @sd: V4L2 sub-device * @pad: Media pad. Only one pad supported * @reset_gpio: Sensor reset gpio + * @supplies: Regulator supplies to handle power control * @inclk: Sensor input clock * @ctrl_handler: V4L2 control handler * @link_freq_ctrl: Pointer to link frequency control @@ -126,6 +133,8 @@ struct imx335 { struct v4l2_subdev sd; struct media_pad pad; struct gpio_desc *reset_gpio; + struct regulator_bulk_data supplies[ARRAY_SIZE(imx335_supply_name)]; + struct clk *inclk; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *link_freq_ctrl; @@ -781,6 +790,17 @@ static int imx335_parse_hw_config(struct imx335 *imx335) return PTR_ERR(imx335->reset_gpio); } + for (i = 0; i < ARRAY_SIZE(imx335_supply_name); i++) + imx335->supplies[i].supply = imx335_supply_name[i]; + + ret = devm_regulator_bulk_get(imx335->dev, + ARRAY_SIZE(imx335_supply_name), + imx335->supplies); + if (ret) { + dev_err(imx335->dev, "Failed to get regulators\n"); + return ret; + } + /* Get sensor input clock */ imx335->inclk = devm_clk_get(imx335->dev, NULL); if (IS_ERR(imx335->inclk)) { @@ -863,6 +883,17 @@ static int imx335_power_on(struct device *dev) struct imx335 *imx335 = to_imx335(sd); int ret; + ret = regulator_bulk_enable(ARRAY_SIZE(imx335_supply_name), + imx335->supplies); + if (ret) { + dev_err(dev, "%s: failed to enable regulators\n", + __func__); + return ret; + } + + usleep_range(500, 550); /* Tlow */ + + /* Set XCLR */ gpiod_set_value_cansleep(imx335->reset_gpio, 1); ret = clk_prepare_enable(imx335->inclk); @@ -871,12 +902,13 @@ static int imx335_power_on(struct device *dev) goto error_reset; } - usleep_range(20, 22); + usleep_range(20, 22); /* T4 */ return 0; error_reset: gpiod_set_value_cansleep(imx335->reset_gpio, 0); + regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies); return ret; } @@ -893,8 +925,8 @@ static int imx335_power_off(struct device *dev) struct imx335 *imx335 = to_imx335(sd); gpiod_set_value_cansleep(imx335->reset_gpio, 0); - clk_disable_unprepare(imx335->inclk); + regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies); return 0; } From patchwork Mon Dec 11 12:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 176702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7027191vqy; Mon, 11 Dec 2023 05:01:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSE3uLziuJ23ThS+7tkGrQ0bDsVDxPEno3XjCbtkLedE7l0mgFaGwOH+f7OnYjyMQABq/C X-Received: by 2002:a05:6a20:748f:b0:187:932f:e249 with SMTP id p15-20020a056a20748f00b00187932fe249mr5677702pzd.4.1702299677779; Mon, 11 Dec 2023 05:01:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702299677; cv=none; d=google.com; s=arc-20160816; b=jCma/APveycGtS8aZFd0g6zcyfqTU/6EiDqsWZq8+duyRCQY7X5FDcLqnU4ib3h/lO eKk2grbPT84jx8AKyvrr55wz4Jj0BsatwgRT566QKpv0+9OxM2c48WR87w84q/eJDLP5 QvhcyGRCZpLCqrQpXY0jvQ8MCnnGvjXv1kUCxygOaULiEmtCrkWChywHRWmssSfEj7fw 1EJFais7CLlqwXg72rYC6xnLKcciuCNgO1SXJbiKgzmY8MpEybVkHZRR0sIEf1EWMd3Q Mw1WtOjUb8LD/mJ3e7vrYW0xzA5676hWdVUHoZh/0xHUXj5NQlecWFrG9igAD6LyewYI jf8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/CkAdQDunTbs+4VpihCudAB31cApQmVeADbuKzwehwU=; fh=5WFlYumxFb4YMTIyFXnieMfGzo3YjRfO3j2f2Wqiw4A=; b=xsgt1Afp9hMACaB848cxVeqUSM8wwg0jqmgy0ZErLveXPcX9pkveAbOy6avY3gx1Pn kTzpsJIgmGRIwom5mA8CHQ2uXqqx4vDapAVLcybbpXl1wcrkFVsBi9tS86qkgdx+2CJq UfHcONj6USouMfFDzAE4DBj0fo+JMa3rg+cCAmkWfP5f+oytK4UG5ECuG5cyFnapuDm4 NpznKP8Ae2FHo43ca+zQ2h+my/+8Vfaoex3Xpx2JdtIuDiuY72LdEXy1P0YY+mP1xAId 8P2ePJdY4EmZSOHB/tDirIVEFdsoZBEtizYcjtS1y2bxFeFlVz0+rEksKJh8DUwpZNO7 7sOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=CWPrdnvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c31-20020a631c5f000000b0058556a636dbsi5821166pgm.434.2023.12.11.05.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:01:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=CWPrdnvc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CDC6A807501F; Mon, 11 Dec 2023 05:00:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234943AbjLKNAZ (ORCPT + 99 others); Mon, 11 Dec 2023 08:00:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234950AbjLKNAT (ORCPT ); Mon, 11 Dec 2023 08:00:19 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EF11FF; Mon, 11 Dec 2023 05:00:22 -0800 (PST) Received: from umang.jain (unknown [103.251.226.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C35841515; Mon, 11 Dec 2023 13:59:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702299577; bh=v4zXIcoXuUwhPMrAke1jILyP8oPZPN1RS9zYrSyz7ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CWPrdnvcj1ATNUi9LlVubPvyrBxQ8bFZ6UwWDhK7CA814WS+OQr4Il860MjthLyWG XrspKJBRN3g9vhELPgtdhLth6LU+/t0hbxPKekj3g0OTJWM1RiIz26L4Bf5Uzox/CT jbq53RkQxVZj6zt7S7z0FDFTdsF1nsa6ZQtkZt44= From: Umang Jain To: devicetree@vger.kernel.org, linux-media@vger.kernel.org Cc: "Paul J . Murphy" , Daniele Alessandrelli , Sakari Ailus , Mauro Carvalho Chehab , Kieran Bingham , Umang Jain , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 5/7] media: i2c: imx335: Implement get selection API Date: Mon, 11 Dec 2023 18:29:47 +0530 Message-ID: <20231211125950.108092-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211125950.108092-1-umang.jain@ideasonboard.com> References: <20231211125950.108092-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:00:50 -0800 (PST) X-Spam-Level: * X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784990586759793751 X-GMAIL-MSGID: 1784990586759793751 From: Kieran Bingham Support reporting of the Sensor Native and Active pixel array areas through the Selection API. The implementation reports a single target crop only for the mode that is presently exposed by the driver. Reviewed-by: Umang Jain Signed-off-by: Kieran Bingham --- drivers/media/i2c/imx335.c | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index b25216b3350e..a924b7222ca3 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -55,6 +55,14 @@ #define IMX335_REG_MIN 0x00 #define IMX335_REG_MAX 0xfffff +/* IMX335 native and active pixel array size. */ +#define IMX335_NATIVE_WIDTH 2616U +#define IMX335_NATIVE_HEIGHT 1964U +#define IMX335_PIXEL_ARRAY_LEFT 12U +#define IMX335_PIXEL_ARRAY_TOP 12U +#define IMX335_PIXEL_ARRAY_WIDTH 2592U +#define IMX335_PIXEL_ARRAY_HEIGHT 1944U + /** * struct imx335_reg - imx335 sensor register * @address: Register address @@ -645,6 +653,41 @@ static int imx335_init_pad_cfg(struct v4l2_subdev *sd, return imx335_set_pad_format(sd, sd_state, &fmt); } +/** + * imx335_get_selection() - Selection API + * @sd: pointer to imx335 V4L2 sub-device structure + * @sd_state: V4L2 sub-device configuration + * @sel: V4L2 selection info + * + * Return: 0 if successful, error code otherwise. + */ +static int imx335_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = IMX335_NATIVE_WIDTH; + sel->r.height = IMX335_NATIVE_HEIGHT; + + return 0; + + case V4L2_SEL_TGT_CROP: + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.top = IMX335_PIXEL_ARRAY_TOP; + sel->r.left = IMX335_PIXEL_ARRAY_LEFT; + sel->r.width = IMX335_PIXEL_ARRAY_WIDTH; + sel->r.height = IMX335_PIXEL_ARRAY_HEIGHT; + + return 0; + } + + return -EINVAL; +} + /** * imx335_start_streaming() - Start sensor stream * @imx335: pointer to imx335 device @@ -862,6 +905,8 @@ static const struct v4l2_subdev_pad_ops imx335_pad_ops = { .init_cfg = imx335_init_pad_cfg, .enum_mbus_code = imx335_enum_mbus_code, .enum_frame_size = imx335_enum_frame_size, + .get_selection = imx335_get_selection, + .set_selection = imx335_get_selection, .get_fmt = imx335_get_pad_format, .set_fmt = imx335_set_pad_format, }; From patchwork Mon Dec 11 12:59:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 176699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7026818vqy; Mon, 11 Dec 2023 05:00:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVu7TYgIl0KjLN1ZBOx6Zhkcz0Pt4z/ifsEBT9rYwXIeTh0rO8qATOs0XAYy4FnIVcd6Wf X-Received: by 2002:a05:6a20:5486:b0:18f:726d:dcdf with SMTP id i6-20020a056a20548600b0018f726ddcdfmr2364765pzk.115.1702299655313; Mon, 11 Dec 2023 05:00:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702299655; cv=none; d=google.com; s=arc-20160816; b=tHEdbHAmPJQZkodQlkbQPaFqTkYURniG+ltRQaZenhCRVXWy3VnvAKhTTGhsM5+PSS X0GPZDXUs4g7kiWvWEgBtzhbKtD9vqR7egePsQj0ZwfQldgN62o1ayZ7WtzxsDGzfQMo DZ/pbRfFqkv3yFVPcJ2eoFrNdy4nxSSKyGt7toQCEbnzP35fxMFpl7KNSZGpgeilXnIi Fs417kOeVFHN9BftmoRX00yo0bnwCsSXdD81AlFYm2WFmQ584MNUmgvXvH3RgRUJIhR9 qcntJ7FbnkaPvK1gynpcBh0IwAqrMyMkZEZnZlFmU/jw3JecvR6xhCF38WBQJgLOXonX Ia0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4T7ed2Ee4yZdpGZPSTxswX9DQ89SUBNNb7TyAoVhjnM=; fh=5WFlYumxFb4YMTIyFXnieMfGzo3YjRfO3j2f2Wqiw4A=; b=bBq0yO9SnRvR+XzrrgVVkj+OkgxFoSZ7rkYxt0Auwo2nQFd9F6sQR2I6nYwMKngwL3 sMjzOpoGMLURg8KN8LeexuUR/SjT2WiHKz4irTMbjZSjdFP1EnmIqeSm0W7bSi43NOFw IzBOGMnJx8wFoXFDf99VUtFTfrJgUc6IRWsJww8GJ/4D1IqSKX6yvqTAeLmyW9wX1Ose O8jMgg6fyhx3pd776FTqLTwYHVtmUsx5oVpxFcdfRti2e7vf8K+tha+KjBdH6jQxF7es V3f5KcqJ6MEE+/4gnR7dcJMiOyyz5McXOOK5UstZN7jKdO6Ocb9X1NlJW7fRPkIthO3j dsaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=BmxCJ8mZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id h3-20020a655183000000b005c65d0dd99fsi5900387pgq.505.2023.12.11.05.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:00:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=BmxCJ8mZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 6F3928042D3B; Mon, 11 Dec 2023 05:00:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343581AbjLKNAl (ORCPT + 99 others); Mon, 11 Dec 2023 08:00:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343613AbjLKNAV (ORCPT ); Mon, 11 Dec 2023 08:00:21 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35445127; Mon, 11 Dec 2023 05:00:25 -0800 (PST) Received: from umang.jain (unknown [103.251.226.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B3716922; Mon, 11 Dec 2023 13:59:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702299580; bh=zV/RIEdgSrvIS1kxne2Y4K//Y+viiimnpU5CN163GOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BmxCJ8mZlLxROcoDIpc4daiKA/1PPC02aFqo2RmKA50OPJLZ6M38kdGTYyfuHzpUk P0wdmSUmWyoQs2dMaUnW5p1ADX6qEXt6qvEaMDeOTCM2ILzXFWYv6SNW8XxH28hRdQ rRik7C39Q39KKZv3GqdG3Phd2IBKTueS+rLbe6EQ= From: Umang Jain To: devicetree@vger.kernel.org, linux-media@vger.kernel.org Cc: "Paul J . Murphy" , Daniele Alessandrelli , Sakari Ailus , Mauro Carvalho Chehab , Kieran Bingham , Umang Jain , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 6/7] media: i2c: imx335: Fix hblank min/max values Date: Mon, 11 Dec 2023 18:29:48 +0530 Message-ID: <20231211125950.108092-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211125950.108092-1-umang.jain@ideasonboard.com> References: <20231211125950.108092-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:00:51 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784990563296985953 X-GMAIL-MSGID: 1784990563296985953 From: Kieran Bingham The V4L2_CID_HBLANK control is marked as readonly and can only be a single value. Set the minimum and maximum value to match the mode value. Reviewed-by: Umang Jain Signed-off-by: Kieran Bingham --- drivers/media/i2c/imx335.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index a924b7222ca3..f353647a0d4e 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -1043,8 +1043,8 @@ static int imx335_init_controls(struct imx335 *imx335) imx335->hblank_ctrl = v4l2_ctrl_new_std(ctrl_hdlr, &imx335_ctrl_ops, V4L2_CID_HBLANK, - IMX335_REG_MIN, - IMX335_REG_MAX, + mode->hblank, + mode->hblank, 1, mode->hblank); if (imx335->hblank_ctrl) imx335->hblank_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; From patchwork Mon Dec 11 12:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 176701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7027138vqy; Mon, 11 Dec 2023 05:01:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9sFA2MeJ781LjhZyHFjqUNzrWCpgTfiuCFUtJM1mVE7zaDvjgcZnot8AHfcT/+iZKYDMD X-Received: by 2002:a05:6a00:22c3:b0:6ce:3876:d730 with SMTP id f3-20020a056a0022c300b006ce3876d730mr2248982pfj.24.1702299673882; Mon, 11 Dec 2023 05:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702299673; cv=none; d=google.com; s=arc-20160816; b=IPLTnFOdEdj6K9kEDCkfC+DRNvuNKLS1eT9uOis5LISV4EeMfJkjsgI1xowAQVVwop n82xlFTCuZD9zqQihlrwBsb51T4a3maKcrwLA5FZjELGYad0JoOxqppXvUGJuWevb4Ru vvxRbPFSV8kU3X5eriQMYUu4r+IxSMdtsPw2BYzoJpdGqOhT5zhvGAQNwvpfMNSJW7JI CUdh4reE6ckxGg/0mMo+YzbCmsk49l2orlXO1t5uaR63gaot0/fwKV0veB2Cm3j5eXz/ dyiSELuWmmOdRa247x/UYBA0wRX2mXvesC1AQ223+uLESE3MWLWR50sy2r5JIcHwMuta 2Xvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gpBw1F8uEoJbd9fnggl+0s6sMbLq+MYDcN9+4Kzqmx4=; fh=fFgsm/J7MMH1r6rAo+pYAyWeEkuY+uwsSt6+FFNjqLg=; b=SQcHwlwWvkuwCVElwxOFpLialADA0d8ruYqaMBtxzC/b4YUJm1TJoLBKn/7BcGcmBB aJszvpp7kKWRMSkwcHP8Z8sc6Vtqt/zkGIVwvsmgFJDOVdgzysiaN2NXbm9D3aoWvjQj LvPs9IaT5Zg/BFm18fFduWatEmpzaIKw0XVOuHUfvfXzvJfGjdrnkHreIa4dw70yPIic uD4Qi1BzvzTWUfnTFs9sanKZbEgbuHflyn4qAxADMnipXMNOEC2kBjgGEMrd1TISFRGk +6hW9kc8KUs3edCGu1a8k18RBzRhoV4JWpUEj2nVbyp2NFrf1jwgko98/mp2DOiLGux3 4cmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=qggPT1UQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id f9-20020a056a00228900b006cde5241c15si6170682pfe.306.2023.12.11.05.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:01:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=qggPT1UQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7E42E807C65E; Mon, 11 Dec 2023 05:01:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234925AbjLKNAo (ORCPT + 99 others); Mon, 11 Dec 2023 08:00:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234938AbjLKNAZ (ORCPT ); Mon, 11 Dec 2023 08:00:25 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE93ACB; Mon, 11 Dec 2023 05:00:27 -0800 (PST) Received: from umang.jain (unknown [103.251.226.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ABAB613C5; Mon, 11 Dec 2023 13:59:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702299582; bh=IIHzhLeJ2uWKFZ++JpqPDkX4rPrwuTAjp5fcEGektbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qggPT1UQ7u59H/4OBICLVFNpf+MjNbBxuBJy4wHKRilWPrdbLm6XY0O1jj4X7/2VR Ws9r7j6254sOB5iVrZ9nTiF/B+aH0RCVUBH/pDwPc/64RKkKrsjVx/wFUC6Eey32oJ yZA1hyF8whJRs93TP8WKP9l8QgGwKid7jzXjsYv8= From: Umang Jain To: devicetree@vger.kernel.org, linux-media@vger.kernel.org Cc: "Paul J . Murphy" , Daniele Alessandrelli , Sakari Ailus , Mauro Carvalho Chehab , Umang Jain , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 7/7] media: i2c: imx335: Support 2592x1940 10-bit mode Date: Mon, 11 Dec 2023 18:29:49 +0530 Message-ID: <20231211125950.108092-8-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211125950.108092-1-umang.jain@ideasonboard.com> References: <20231211125950.108092-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:01:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784990582566924211 X-GMAIL-MSGID: 1784990582566924211 In addition to the existing 2592x1940 12-bit mode, introduce support for 2592x1940 10-bit mode. Following are the register set which control the 10/12 bit mode setting: MDBIT 0x319d ADBIT 0x3050 ADBIT1 0x341c 0x341d Signed-off-by: Umang Jain --- drivers/media/i2c/imx335.c | 78 ++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index f353647a0d4e..5cca8d637952 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -134,6 +134,7 @@ struct imx335_mode { * @vblank: Vertical blanking in lines * @cur_mode: Pointer to current selected sensor mode * @mutex: Mutex for serializing sensor controls + * @cur_mbus_code: Currently selected media bus format code */ struct imx335 { struct device *dev; @@ -156,6 +157,7 @@ struct imx335 { u32 vblank; const struct imx335_mode *cur_mode; struct mutex mutex; + u32 cur_mbus_code; }; static const s64 link_freq[] = { @@ -250,6 +252,25 @@ static const struct imx335_reg mode_2592x1940_regs[] = { {0x3a00, 0x01}, }; +static const struct imx335_reg raw10_framefmt_regs[] = { + {0x3050, 0x00}, + {0x319d, 0x00}, + {0x341c, 0xff}, + {0x341d, 0x01}, +}; + +static const struct imx335_reg raw12_framefmt_regs[] = { + {0x3050, 0x01}, + {0x319d, 0x01}, + {0x341c, 0x47}, + {0x341d, 0x00}, +}; + +static const u32 imx335_mbus_codes[] = { + MEDIA_BUS_FMT_SRGGB12_1X12, + MEDIA_BUS_FMT_SRGGB10_1X10, +}; + /* Supported sensor mode configurations */ static const struct imx335_mode supported_mode = { .width = 2592, @@ -260,7 +281,6 @@ static const struct imx335_mode supported_mode = { .vblank_max = 133060, .pclk = 396000000, .link_freq_idx = 0, - .code = MEDIA_BUS_FMT_SRGGB12_1X12, .reg_list = { .num_of_regs = ARRAY_SIZE(mode_2592x1940_regs), .regs = mode_2592x1940_regs, @@ -500,6 +520,18 @@ static const struct v4l2_ctrl_ops imx335_ctrl_ops = { .s_ctrl = imx335_set_ctrl, }; +static int imx335_get_format_code(struct imx335 *imx335, u32 code) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(imx335_mbus_codes); i++) { + if (imx335_mbus_codes[i] == code) + return imx335_mbus_codes[i]; + } + + return imx335_mbus_codes[0]; +} + /** * imx335_enum_mbus_code() - Enumerate V4L2 sub-device mbus codes * @sd: pointer to imx335 V4L2 sub-device structure @@ -512,10 +544,10 @@ static int imx335_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) { - if (code->index > 0) + if (code->index >= ARRAY_SIZE(imx335_mbus_codes)) return -EINVAL; - code->code = supported_mode.code; + code->code = imx335_mbus_codes[code->index]; return 0; } @@ -532,10 +564,14 @@ static int imx335_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_frame_size_enum *fsize) { - if (fsize->index > 0) + struct imx335 *imx335 = to_imx335(sd); + u32 code; + + if (fsize->index > ARRAY_SIZE(imx335_mbus_codes)) return -EINVAL; - if (fsize->code != supported_mode.code) + code = imx335_get_format_code(imx335, fsize->code); + if (fsize->code != code) return -EINVAL; fsize->min_width = supported_mode.width; @@ -559,7 +595,7 @@ static void imx335_fill_pad_format(struct imx335 *imx335, { fmt->format.width = mode->width; fmt->format.height = mode->height; - fmt->format.code = mode->code; + fmt->format.code = imx335->cur_mbus_code; fmt->format.field = V4L2_FIELD_NONE; fmt->format.colorspace = V4L2_COLORSPACE_RAW; fmt->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; @@ -611,11 +647,16 @@ static int imx335_set_pad_format(struct v4l2_subdev *sd, { struct imx335 *imx335 = to_imx335(sd); const struct imx335_mode *mode; - int ret = 0; + int i, ret = 0; mutex_lock(&imx335->mutex); mode = &supported_mode; + for (i = 0; i < ARRAY_SIZE(imx335_mbus_codes); i++) { + if (imx335_mbus_codes[i] == fmt->format.code) + imx335->cur_mbus_code = imx335_mbus_codes[i]; + } + imx335_fill_pad_format(imx335, mode, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { @@ -688,6 +729,21 @@ static int imx335_get_selection(struct v4l2_subdev *sd, return -EINVAL; } +static int imx335_set_framefmt(struct imx335 *imx335) +{ + switch (imx335->cur_mbus_code) { + case MEDIA_BUS_FMT_SRGGB10_1X10: + return imx335_write_regs(imx335, raw10_framefmt_regs, + ARRAY_SIZE(raw10_framefmt_regs)); + + case MEDIA_BUS_FMT_SRGGB12_1X12: + return imx335_write_regs(imx335, raw12_framefmt_regs, + ARRAY_SIZE(raw12_framefmt_regs)); + } + + return -EINVAL; +} + /** * imx335_start_streaming() - Start sensor stream * @imx335: pointer to imx335 device @@ -708,6 +764,13 @@ static int imx335_start_streaming(struct imx335 *imx335) return ret; } + ret = imx335_set_framefmt(imx335); + if (ret) { + dev_err(imx335->dev, "%s failed to set frame format: %d\n", + __func__, ret); + return ret; + } + /* Setup handler will write actual exposure and gain */ ret = __v4l2_ctrl_handler_setup(imx335->sd.ctrl_handler); if (ret) { @@ -1104,6 +1167,7 @@ static int imx335_probe(struct i2c_client *client) /* Set default mode to max resolution */ imx335->cur_mode = &supported_mode; + imx335->cur_mbus_code = imx335_mbus_codes[0]; imx335->vblank = imx335->cur_mode->vblank; ret = imx335_init_controls(imx335);