From patchwork Sat Oct 28 07:17:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Patchwork-Id: 159230 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1083955vqb; Sat, 28 Oct 2023 00:19:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaEliSBhRBNNFQivV4Ss4EasU+mhR+DmygRtvLc3GxbrR+aImMMe96fTS6UXhTJldpietb X-Received: by 2002:a05:6871:5a88:b0:1ea:29a:8628 with SMTP id oo8-20020a0568715a8800b001ea029a8628mr6203778oac.15.1698477569277; Sat, 28 Oct 2023 00:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698477569; cv=none; d=google.com; s=arc-20160816; b=kxjQmBqBz+8OMWtAAgKWE9IN2RPyDZMZ7CsMVrxFSCp22+8IBsjF/saZVny3lVbNLD 1Vz/4+462nmQ2SOgkQGZDL3813W+wvfPNONeaDjlZzadNNhiE5QS1VCvrVw857bd6MBi Ir8GPVwBYSg0VyIfhWjlXdtTu+TeL2T6axjN/MLv9q1V1u1HkXdBAXYEdcKqNRyoVeoh 88cmz5OqfFWb/eK/DUN/A4nrB+LYMY7nJCwoUfx2cOr3gcNN3tpTxUUm8Dw6oM5crJoF jcRSHY0pCQkW2P/+Kz7hBBe2Pj+8KNB4CQ5QBSS4hIqidw9yBFshJTcvgNf+JaXyyCCD Oc8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=IRidpg4JVPRDAFnHMvszIf1boZcA1du4Z2zZ/L6U1Js=; fh=Zgky+q+8PvhHkxojJIPDJHGW0QVIUIBdH6AVhu4TA4w=; b=WXRonxK2pSuPiBOkDFYTiweyJDmV9peRtZEn/D8TuIPsSZTvfas1AmazG2ExaB3jT9 s7bcidFSrEcEryK1J7PM42HTIsoKUA2JkDUK3r7nKQ7kBlX3JU+lxwtdFKCnJo7OdPUE l4PBetsI02Nn7TGim4oyvR/GVQ7Hq70oU9v+SnB5UpMrFZRZuCRdWdWSa6UFMb6xMjsH GEnjSMjOLxQkMigcJCA2og8Pw6W1Pt3eFPgRDTbMSGIhDizrBccvW1KkZ/ILSgLFnWEd Tmqz4b8Z3m+8+eF1GxTUz2H1A4ntm5wSDql4j5ml2wZ8xhaQ2GDMCPZzLVHVSK84/cbB dAmA== ARC-Authentication-Results: i=1; mx.google.com; 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 bg26-20020a056a02011a00b0058a4883e6casi2163995pgb.225.2023.10.28.00.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 00:19:29 -0700 (PDT) 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; 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 79EEB829E5CE; Sat, 28 Oct 2023 00:19:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233178AbjJ1HTI (ORCPT + 27 others); Sat, 28 Oct 2023 03:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229584AbjJ1HSt (ORCPT ); Sat, 28 Oct 2023 03:18:49 -0400 Received: from smtprelay08.ispgateway.de (smtprelay08.ispgateway.de [134.119.228.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C95C11B; Sat, 28 Oct 2023 00:18:45 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay08.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwdak-0002T7-1M; Sat, 28 Oct 2023 09:18:42 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 09:17:44 +0200 Subject: [PATCH v2 1/5] media: i2c: imx214: Explain some magic numbers MIME-Version: 1.0 Message-Id: <20231028-imx214-v2-1-69a8fb730d6e@apitzsch.eu> References: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> In-Reply-To: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: Kieran Bingham , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Apitzsch?= , Ricardo Ribalda X-Mailer: b4 0.12.3 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS 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]); Sat, 28 Oct 2023 00:19:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780982815829291692 X-GMAIL-MSGID: 1780982815829291692 Code refinement, no functional changes. Reviewed-by: Ricardo Ribalda Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 4f77ea02cc27..1c30f6666d35 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -19,12 +19,23 @@ #include #include +#define IMX214_REG_MODE_SELECT 0x0100 +#define IMX214_MODE_STANDBY 0x00 +#define IMX214_MODE_STREAMING 0x01 + #define IMX214_DEFAULT_CLK_FREQ 24000000 #define IMX214_DEFAULT_LINK_FREQ 480000000 #define IMX214_DEFAULT_PIXEL_RATE ((IMX214_DEFAULT_LINK_FREQ * 8LL) / 10) #define IMX214_FPS 30 #define IMX214_MBUS_CODE MEDIA_BUS_FMT_SRGGB10_1X10 +/* Exposure control */ +#define IMX214_REG_EXPOSURE 0x0202 +#define IMX214_EXPOSURE_MIN 0 +#define IMX214_EXPOSURE_MAX 3184 +#define IMX214_EXPOSURE_STEP 1 +#define IMX214_EXPOSURE_DEFAULT 3184 + static const char * const imx214_supply_name[] = { "vdda", "vddd", @@ -665,7 +676,7 @@ static int imx214_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_EXPOSURE: vals[1] = ctrl->val; vals[0] = ctrl->val >> 8; - ret = regmap_bulk_write(imx214->regmap, 0x202, vals, 2); + ret = regmap_bulk_write(imx214->regmap, IMX214_REG_EXPOSURE, vals, 2); if (ret < 0) dev_err(imx214->dev, "Error %d\n", ret); ret = 0; @@ -743,7 +754,7 @@ static int imx214_start_streaming(struct imx214 *imx214) dev_err(imx214->dev, "could not sync v4l2 controls\n"); goto error; } - ret = regmap_write(imx214->regmap, 0x100, 1); + ret = regmap_write(imx214->regmap, IMX214_REG_MODE_SELECT, IMX214_MODE_STREAMING); if (ret < 0) { dev_err(imx214->dev, "could not sent start table %d\n", ret); goto error; @@ -761,7 +772,7 @@ static int imx214_stop_streaming(struct imx214 *imx214) { int ret; - ret = regmap_write(imx214->regmap, 0x100, 0); + ret = regmap_write(imx214->regmap, IMX214_REG_MODE_SELECT, IMX214_MODE_STANDBY); if (ret < 0) dev_err(imx214->dev, "could not sent stop table %d\n", ret); @@ -991,9 +1002,12 @@ static int imx214_probe(struct i2c_client *client) * * Yours sincerely, Ricardo. */ - imx214->exposure = v4l2_ctrl_new_std(&imx214->ctrls, &imx214_ctrl_ops, + imx214->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops, V4L2_CID_EXPOSURE, - 0, 3184, 1, 0x0c70); + IMX214_EXPOSURE_MIN, + IMX214_EXPOSURE_MAX, + IMX214_EXPOSURE_STEP, + IMX214_EXPOSURE_DEFAULT); imx214->unit_size = v4l2_ctrl_new_std_compound(&imx214->ctrls, NULL, From patchwork Sat Oct 28 07:17:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Patchwork-Id: 159228 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1083939vqb; Sat, 28 Oct 2023 00:19:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFA64nJUg6X8grrf4lM/kfQjB738KY1C55ow6pav9O22pbJjK4UUKL10V7v6DlXRGhghQsM X-Received: by 2002:a17:902:ea09:b0:1c5:de06:9e5a with SMTP id s9-20020a170902ea0900b001c5de069e5amr4717464plg.21.1698477565493; Sat, 28 Oct 2023 00:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698477565; cv=none; d=google.com; s=arc-20160816; b=mh8DAR/qS7QEReFarGtLWD6DMSfSBi4qcd1JVnVaVKu/6NIeBg3aZWDXbBZlkQqRZU 0qVVljxohIC2H+muGE3MqU8Wxcf+Ye9/8wqHcY9nmt9di2eatV0pKCuQbprYvrRaDTQ8 M/MNymK/Eza5D2cG7z5Ih+o88j1qI8C7KLcRdTsJfLnmJOXIvTlCeX05A8gNni0o5D1P FVfytOBlscRZJCIGbQWACPu5qrKMS/kninhgsLEnu+P33T2pKz8Aos/XbDZ5UixcKfEJ /F2gc5sLcS2c23rl/Kv2rPnd1FXd5dbQdDOX5C0IlIyLdKH8UfbihDjT5uMC4/ODlZgT xbdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=02+pko0QBbDxq3nAU4L9fvVv8qy/GJzFhMulYaCLAqo=; fh=Zgky+q+8PvhHkxojJIPDJHGW0QVIUIBdH6AVhu4TA4w=; b=e1GhhgTB8wjR3v5lb1EhBqs/wlpXwZGKFD8kDZdiNKfptzDTHsLoPmpQGlPpvoufH0 14z8r7hkOW+DwgJ1CFU6QmR/jG9R1rZu+8bmMVTN8gjIX2Y0nnEy6sWGGR7DnMEmxjA/ OoR51teJ5DaefAlQcwjmnau+oUDIeHCHQcvunLOhsG3mdpmJkTOmQKXpyiJ6nH/d3eLJ lYq8q5uCPlO+tRfcVlw0BcEK8LLojWaunRMrZYUSFukOVMII2MFDLB8B2fuWewOwEUkn VDpVBK2vCvA9N4oQnxJ2RFK+wRFq4HyKN72J/gUKEl09G2zazo2/RTq8RuxkJDf3NvWN DKlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n5-20020a170902e54500b001b9c3498526si2298815plf.433.2023.10.28.00.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 00:19:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 488758299912; Sat, 28 Oct 2023 00:19:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233158AbjJ1HTF (ORCPT + 27 others); Sat, 28 Oct 2023 03:19:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjJ1HSt (ORCPT ); Sat, 28 Oct 2023 03:18:49 -0400 Received: from smtprelay08.ispgateway.de (smtprelay08.ispgateway.de [134.119.228.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6050DB4; Sat, 28 Oct 2023 00:18:45 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay08.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwdak-0002T7-2R; Sat, 28 Oct 2023 09:18:42 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 09:17:45 +0200 Subject: [PATCH v2 2/5] media: i2c: imx214: Move controls init to separate function MIME-Version: 1.0 Message-Id: <20231028-imx214-v2-2-69a8fb730d6e@apitzsch.eu> References: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> In-Reply-To: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: Kieran Bingham , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Apitzsch?= , Ricardo Ribalda X-Mailer: b4 0.12.3 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS 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]); Sat, 28 Oct 2023 00:19:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780982811702484103 X-GMAIL-MSGID: 1780982811702484103 Code refinement, no functional changes. Reviewed-by: Jacopo Mondi Reviewed-by: Ricardo Ribalda Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 112 ++++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 47 deletions(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 1c30f6666d35..4181127dba12 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -695,6 +695,69 @@ static const struct v4l2_ctrl_ops imx214_ctrl_ops = { .s_ctrl = imx214_set_ctrl, }; +static int imx214_ctrls_init(struct imx214 *imx214) +{ + static const s64 link_freq[] = { + IMX214_DEFAULT_LINK_FREQ + }; + static const struct v4l2_area unit_size = { + .width = 1120, + .height = 1120, + }; + struct v4l2_ctrl_handler *ctrl_hdlr; + int ret; + + ctrl_hdlr = &imx214->ctrls; + ret = v4l2_ctrl_handler_init(&imx214->ctrls, 3); + if (ret) + return ret; + + imx214->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, NULL, + V4L2_CID_PIXEL_RATE, 0, + IMX214_DEFAULT_PIXEL_RATE, 1, + IMX214_DEFAULT_PIXEL_RATE); + + imx214->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, NULL, + V4L2_CID_LINK_FREQ, + ARRAY_SIZE(link_freq) - 1, + 0, link_freq); + if (imx214->link_freq) + imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; + + /* + * WARNING! + * Values obtained reverse engineering blobs and/or devices. + * Ranges and functionality might be wrong. + * + * Sony, please release some register set documentation for the + * device. + * + * Yours sincerely, Ricardo. + */ + imx214->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops, + V4L2_CID_EXPOSURE, + IMX214_EXPOSURE_MIN, + IMX214_EXPOSURE_MAX, + IMX214_EXPOSURE_STEP, + IMX214_EXPOSURE_DEFAULT); + + imx214->unit_size = v4l2_ctrl_new_std_compound(ctrl_hdlr, + NULL, + V4L2_CID_UNIT_CELL_SIZE, + v4l2_ctrl_ptr_create((void *)&unit_size)); + + ret = ctrl_hdlr->error; + if (ret) { + v4l2_ctrl_handler_free(ctrl_hdlr); + dev_err(imx214->dev, "failed to add controls: %d\n", ret); + return ret; + } + + imx214->sd.ctrl_handler = ctrl_hdlr; + + return 0; +}; + #define MAX_CMD 4 static int imx214_write_table(struct imx214 *imx214, const struct reg_8 table[]) @@ -918,13 +981,6 @@ static int imx214_probe(struct i2c_client *client) { struct device *dev = &client->dev; struct imx214 *imx214; - static const s64 link_freq[] = { - IMX214_DEFAULT_LINK_FREQ, - }; - static const struct v4l2_area unit_size = { - .width = 1120, - .height = 1120, - }; int ret; ret = imx214_parse_fwnode(dev); @@ -979,48 +1035,10 @@ static int imx214_probe(struct i2c_client *client) pm_runtime_enable(imx214->dev); pm_runtime_idle(imx214->dev); - v4l2_ctrl_handler_init(&imx214->ctrls, 3); - - imx214->pixel_rate = v4l2_ctrl_new_std(&imx214->ctrls, NULL, - V4L2_CID_PIXEL_RATE, 0, - IMX214_DEFAULT_PIXEL_RATE, 1, - IMX214_DEFAULT_PIXEL_RATE); - imx214->link_freq = v4l2_ctrl_new_int_menu(&imx214->ctrls, NULL, - V4L2_CID_LINK_FREQ, - ARRAY_SIZE(link_freq) - 1, - 0, link_freq); - if (imx214->link_freq) - imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; - - /* - * WARNING! - * Values obtained reverse engineering blobs and/or devices. - * Ranges and functionality might be wrong. - * - * Sony, please release some register set documentation for the - * device. - * - * Yours sincerely, Ricardo. - */ - imx214->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops, - V4L2_CID_EXPOSURE, - IMX214_EXPOSURE_MIN, - IMX214_EXPOSURE_MAX, - IMX214_EXPOSURE_STEP, - IMX214_EXPOSURE_DEFAULT); - - imx214->unit_size = v4l2_ctrl_new_std_compound(&imx214->ctrls, - NULL, - V4L2_CID_UNIT_CELL_SIZE, - v4l2_ctrl_ptr_create((void *)&unit_size)); - ret = imx214->ctrls.error; - if (ret) { - dev_err(&client->dev, "%s control init failed (%d)\n", - __func__, ret); + ret = imx214_ctrls_init(imx214); + if (ret < 0) goto free_ctrl; - } - imx214->sd.ctrl_handler = &imx214->ctrls; mutex_init(&imx214->mutex); imx214->ctrls.lock = &imx214->mutex; From patchwork Sat Oct 28 07:17:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Patchwork-Id: 159232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1084041vqb; Sat, 28 Oct 2023 00:19:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE91jWT+Keigp4JWG0bP24+6Vecgw4pKRTKwxsDPOi1wgi0938tXoZ/QxU5CyKqIiFt9q/s X-Received: by 2002:a05:6358:938f:b0:168:e685:a266 with SMTP id h15-20020a056358938f00b00168e685a266mr4764097rwb.30.1698477586527; Sat, 28 Oct 2023 00:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698477586; cv=none; d=google.com; s=arc-20160816; b=tuT1ofCGY8lBVvi40ySSzJ38H8Zp3OptTUTGYLNhKcU1Ey4647owAuQv6JzR8+3bP2 nmK6U8QHQtcekKpEDyX7xamD3RuWLALxcGEdFlc+cz7TwYTk8fxyAxoa+OABddNPrCjb ypT6T8ZxLDWovH0lo/O84Yf9HQazR4S3xV5OQbqObK6eJYHd0AsCpWUE4txT0oh+6UAk hDy5Cb/plivBCWYEVmKaQF+QJhinitvRFDb+1UjEWUOzFxBTdaTzxjJ8pQa4SaZeNsEl IRE2nBQjPelKBoziPVh/En/4cHn+LWUg2hLJuWFbdMZBNq8plzNOWEjuUR5QF+E6jiWY Tifw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=d035bNehBZtNzEjz5Udq/7L5OrBNr9IRhsGOEer4c60=; fh=Zgky+q+8PvhHkxojJIPDJHGW0QVIUIBdH6AVhu4TA4w=; b=vvuh1nq7aJdN5V/KelJSuRBv6UFMrzVpGP+rjCms4R7T4tPa1t7WeCWJzTPK6X8BO7 PE6gPGCH22L8qQKUCPpbbaO9LR8SPDzMekU9D6lL6kgKBnLve3c162NWSTYf5Z+TtZNJ QmA2e9e3N+AhCfnoMabPuJkIuvCubHLLIxxiue1cfxstTEVVWFRXEry6GzNbcjGSzKSG bSwauPKcUydvbjgr6umWBEDuYzRUUFKucHWz25kmoQxF4rs4bWIKG/p8Q6u/Dm/VIMkJ fMJtZsktjIOge3X9zZia2sQZ/r0ir3WkjaRzCZYus2ENw37W6pAzelQjxf/QVn8N7EmH fVsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h17-20020a17090ac39100b002800b13adb7si2067556pjt.72.2023.10.28.00.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 00:19:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 4F5EC80A1A33; Sat, 28 Oct 2023 00:19:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbjJ1HSv (ORCPT + 27 others); Sat, 28 Oct 2023 03:18:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjJ1HSs (ORCPT ); Sat, 28 Oct 2023 03:18:48 -0400 Received: from smtprelay08.ispgateway.de (smtprelay08.ispgateway.de [134.119.228.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 684DDE3; Sat, 28 Oct 2023 00:18:45 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay08.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwdal-0002T7-0I; Sat, 28 Oct 2023 09:18:43 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 09:17:46 +0200 Subject: [PATCH v2 3/5] media: i2c: imx214: Read orientation and rotation from system firmware MIME-Version: 1.0 Message-Id: <20231028-imx214-v2-3-69a8fb730d6e@apitzsch.eu> References: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> In-Reply-To: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: Kieran Bingham , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Apitzsch?= , Ricardo Ribalda X-Mailer: b4 0.12.3 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Sat, 28 Oct 2023 00:19:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780982833794035200 X-GMAIL-MSGID: 1780982833794035200 Obtain rotation and orientation information from system firmware and register the appropriate controls. While at it, update number of pre-allocated control slots. Reviewed-by: Jacopo Mondi Reviewed-by: Ricardo Ribalda Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 4181127dba12..574878e8c97d 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -704,11 +704,16 @@ static int imx214_ctrls_init(struct imx214 *imx214) .width = 1120, .height = 1120, }; + struct v4l2_fwnode_device_properties props; struct v4l2_ctrl_handler *ctrl_hdlr; int ret; + ret = v4l2_fwnode_device_parse(imx214->dev, &props); + if (ret < 0) + return ret; + ctrl_hdlr = &imx214->ctrls; - ret = v4l2_ctrl_handler_init(&imx214->ctrls, 3); + ret = v4l2_ctrl_handler_init(&imx214->ctrls, 6); if (ret) return ret; @@ -746,6 +751,8 @@ static int imx214_ctrls_init(struct imx214 *imx214) V4L2_CID_UNIT_CELL_SIZE, v4l2_ctrl_ptr_create((void *)&unit_size)); + v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &imx214_ctrl_ops, &props); + ret = ctrl_hdlr->error; if (ret) { v4l2_ctrl_handler_free(ctrl_hdlr); From patchwork Sat Oct 28 07:17:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Patchwork-Id: 159229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1083947vqb; Sat, 28 Oct 2023 00:19:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFr87k6xnuCYSQELb4vurOUKu2zFXRQ7+S0g88CVAvYRY+BA/tnEP3IUZhjmjQ/Qy83v0mD X-Received: by 2002:a05:6358:1904:b0:168:e0db:ce43 with SMTP id w4-20020a056358190400b00168e0dbce43mr4599780rwm.31.1698477566830; Sat, 28 Oct 2023 00:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698477566; cv=none; d=google.com; s=arc-20160816; b=C8+TQMD02YDS4o569NZ6mxSXJngUZvKYDfNYPBeFJHREa8SeaURMlXlEfNmdu+6zM5 /19rdkLtPEPGooG8H8NvurjQf3m8Cn/GnpnAm3UtHek563tNbL4o3nyghTLIbknsDUtG erhcU2IM/IYv71s6xxM8ztiowOL+3idM9jMvamOy13RR/UEdKfN697JTWklR7yzi/foK oE8/LTjO/6luCmqRSLiJDzcxM5x2nwTI4uul3BQuiYUYepjWhBt5a9c79yRxvmgXyUln SzQ5hkNs3SO1BAFSolT4JH7Xk9A5CwRJJ1Ypp3SxvNasHoRTnoqHwPKl1800hg6gJAUH 2izQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=2wk5fgs3WjFKFVTH0bKQhuqYPZYk6nC3YeSfBh8FDxo=; fh=Gadr0aUB8zty8NH/YaNy5EBNIZUlZSGENDAW2PTeJWI=; b=Vn8FzqO6p3H/wKBUkFOr20Iz1lUL+H4d0Q7b8v+zqy3n9dkK2pFODQpE+efcAlkokp RByx9USZeD+8oUUrwJiB8CMbeZA5vjKEXvJ13uQ+y6K2OCmxydHcuitor+jGLTdNZZni 4JBWJyZu4JoOGB8WP0z1MLK/Ah/RAnH/FQkFAMj/7cwtvGEZu0F2BfqM9/t1e1/gciJ9 ylGymY9t8JGR80tJznaT0XcLcYoEQINsealq7xbAbw2jXl56PJQq6crgzwRuJ4y+6bUW W95pG02G9OKMIBo51cg5Dt/K5QGBdcfMskh4cwZKvBvyKYkXhy3U4EobzygwcTHkYdn+ P1zQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id by17-20020a056a02059100b005abcd0ad422si261572pgb.533.2023.10.28.00.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 00:19:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 17750829BC72; Sat, 28 Oct 2023 00:19:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233133AbjJ1HTM (ORCPT + 27 others); Sat, 28 Oct 2023 03:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjJ1HSy (ORCPT ); Sat, 28 Oct 2023 03:18:54 -0400 Received: from smtprelay08.ispgateway.de (smtprelay08.ispgateway.de [134.119.228.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6950B126; Sat, 28 Oct 2023 00:18:46 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay08.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwdal-0002T7-1R; Sat, 28 Oct 2023 09:18:43 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 09:17:47 +0200 Subject: [PATCH v2 4/5] media: i2c: imx214: Add sensor's pixel matrix size MIME-Version: 1.0 Message-Id: <20231028-imx214-v2-4-69a8fb730d6e@apitzsch.eu> References: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> In-Reply-To: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: Kieran Bingham , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Mailer: b4 0.12.3 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,PDS_OTHER_BAD_TLD, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=no 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]); Sat, 28 Oct 2023 00:19:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780982812744063756 X-GMAIL-MSGID: 1780982812744063756 Set effective and active sensor pixel sizes as shown in product brief[1]. [1]: https://www.mouser.com/datasheet/2/897/ProductBrief_IMX214_20150428-1289331.pdf Reviewed-by: Jacopo Mondi Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 574878e8c97d..e0d9624a9d3f 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -36,6 +36,14 @@ #define IMX214_EXPOSURE_STEP 1 #define IMX214_EXPOSURE_DEFAULT 3184 +/* IMX214 native and active pixel array size */ +#define IMX214_NATIVE_WIDTH 4224U +#define IMX214_NATIVE_HEIGHT 3136U +#define IMX214_PIXEL_ARRAY_LEFT 8U +#define IMX214_PIXEL_ARRAY_TOP 8U +#define IMX214_PIXEL_ARRAY_WIDTH 4208U +#define IMX214_PIXEL_ARRAY_HEIGHT 3120U + static const char * const imx214_supply_name[] = { "vdda", "vddd", @@ -634,14 +642,31 @@ static int imx214_get_selection(struct v4l2_subdev *sd, { struct imx214 *imx214 = to_imx214(sd); - if (sel->target != V4L2_SEL_TGT_CROP) - return -EINVAL; + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + mutex_lock(&imx214->mutex); + sel->r = *__imx214_get_pad_crop(imx214, sd_state, sel->pad, + sel->which); + mutex_unlock(&imx214->mutex); + return 0; - mutex_lock(&imx214->mutex); - sel->r = *__imx214_get_pad_crop(imx214, sd_state, sel->pad, - sel->which); - mutex_unlock(&imx214->mutex); - return 0; + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = IMX214_NATIVE_WIDTH; + sel->r.height = IMX214_NATIVE_HEIGHT; + return 0; + + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.top = IMX214_PIXEL_ARRAY_TOP; + sel->r.left = IMX214_PIXEL_ARRAY_LEFT; + sel->r.width = IMX214_PIXEL_ARRAY_WIDTH; + sel->r.height = IMX214_PIXEL_ARRAY_HEIGHT; + return 0; + } + + return -EINVAL; } static int imx214_entity_init_cfg(struct v4l2_subdev *subdev, From patchwork Sat Oct 28 07:17:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Patchwork-Id: 159231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1083960vqb; Sat, 28 Oct 2023 00:19:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWsVG/bKr3YqyFoj2y1rDZVPAg37ckEZICsTCsXHhoZ4T8AUR8AYn96d7M4xexJIiJlmt8 X-Received: by 2002:a05:6a21:66c5:b0:17b:51a1:9c4 with SMTP id ze5-20020a056a2166c500b0017b51a109c4mr4683243pzb.61.1698477569822; Sat, 28 Oct 2023 00:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698477569; cv=none; d=google.com; s=arc-20160816; b=cOwn1aJaZOp7RYYgKdXORMSfY+R9MqxHbmf7jc0RMqKkku91gCsUMqJ5OvNZVXknvF uGXj9fEVi4L7GDD8dLbo16bWQNXbxMs13dGnQTqv7y52Qd8zfBqjzVRR05MZeuBPbfTt tuKj1plFYY7+RuBphuwMCEKnWT25xjRJnJGEIvArrPFzRHxSy2Alb6X5ybqlz4JBqn+B XwjnwL10LRKqQ7p1lVLWl9PrIdGvPE8ijUJ5nH0g+twgfN1VstctZ5lLMG79F/GzLbax EVNTimlF4po3OlfE+Ie3Dg/FyoA1r2hwcgB/BWL89AqMjKOgNlWhTnoebGlRnY6YH2Yj L+vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=izVRDdl6uRFarwqqDXOAI9MNSOsHXTtYRRc9GdvqkBo=; fh=Gadr0aUB8zty8NH/YaNy5EBNIZUlZSGENDAW2PTeJWI=; b=Oj5SOfPGe+bYifDLaD1NQmWbrFX/fSenjuioAjqk07hrj19wqEKj7qeOZ2heu+nmVX l3ofqrkQs0jU34tUdDFILXK3dASgoIZDM4HaDbHQAD3O/ov2zeC4lYD+ZiMJyWMCmPvv nDCcMobTDElZJaw2vqom5vvS9zqtNVwONGFWSVoLRwRkmqg8SO/Xnlaey/6wPoeCpvzO lsUDUiXu90MpT2FcCUZ7laCYmFLBu5aJdorI+nTZJRuYnjrkKO8JnQUF8CecHE/dnHhl 1blLwZmxTkgkg6BBELin4clbEMonkO7DwQW2TM4i577De9tAaxa1ntLFrpRBgwhG3/DV C3FA== ARC-Authentication-Results: i=1; mx.google.com; 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 r123-20020a632b81000000b005b3bacf3c68si2170078pgr.462.2023.10.28.00.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 00:19:29 -0700 (PDT) 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; 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 2E64181EEBD2; Sat, 28 Oct 2023 00:19:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233099AbjJ1HTC (ORCPT + 27 others); Sat, 28 Oct 2023 03:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjJ1HSt (ORCPT ); Sat, 28 Oct 2023 03:18:49 -0400 Received: from smtprelay08.ispgateway.de (smtprelay08.ispgateway.de [134.119.228.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B5F4121; Sat, 28 Oct 2023 00:18:46 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay08.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwdal-0002T7-2T; Sat, 28 Oct 2023 09:18:43 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 09:17:48 +0200 Subject: [PATCH v2 5/5] media: i2c: imx214: Fix cleanup after controls initialization error MIME-Version: 1.0 Message-Id: <20231028-imx214-v2-5-69a8fb730d6e@apitzsch.eu> References: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> In-Reply-To: <20231028-imx214-v2-0-69a8fb730d6e@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: Kieran Bingham , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Mailer: b4 0.12.3 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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]); Sat, 28 Oct 2023 00:19:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780982816160043105 X-GMAIL-MSGID: 1780982816160043105 If the controls are initialized incorrectly, don't destroy the mutex not initialized yet and don't free controls as that is handled in imx214_ctrls_init(). Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index e0d9624a9d3f..0aba28d6dc2f 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -1069,7 +1069,7 @@ static int imx214_probe(struct i2c_client *client) ret = imx214_ctrls_init(imx214); if (ret < 0) - goto free_ctrl; + goto error_power_off; mutex_init(&imx214->mutex); imx214->ctrls.lock = &imx214->mutex; @@ -1100,6 +1100,7 @@ static int imx214_probe(struct i2c_client *client) free_ctrl: mutex_destroy(&imx214->mutex); v4l2_ctrl_handler_free(&imx214->ctrls); +error_power_off: pm_runtime_disable(imx214->dev); return ret;