From patchwork Sat Oct 28 08:41: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: 159242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1109634vqb; Sat, 28 Oct 2023 01:43:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrX5VChz8owppi5CEpkN4qTJLuYOq3xgceAx9ME+wQG4puMNHrYCG8DwL+X4BguRgo+n/8 X-Received: by 2002:a05:6a21:47c6:b0:17d:9da4:5eb3 with SMTP id as6-20020a056a2147c600b0017d9da45eb3mr4676708pzc.56.1698482617951; Sat, 28 Oct 2023 01:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698482617; cv=none; d=google.com; s=arc-20160816; b=tTCbQp1hqJmJm2DllLTfvKMzx2BqVQntsY6FuB2p5olN33KJm3GgJSHbWd/UT2KGbz TzP5quEjMt3KVmWYDvLfhO34EUaFxvMJO8gyXNS5aSC1K+gEhNb0FWjmApV5sDIVlJMO pomR27SqQHN24HbJvfn30EO+hhmbceI2FgEnfjtToRKNm5M6k2ZAy7XjQK+xrdHaXA4I 4fzqGn3wSjtSScwNF+XT3VMO49fN0QDVefwURvWxk/CbJUtccaoKXPY6+Mxa5G1gmJm9 ElSzk5m7fDzbJfB1j7owZW+6+8c+O3LxoZL/sbBRFbhak3E/iT5GeTnEiZGNC+wR63oo 0AZA== 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=L03NHJCri0rBWyMjjLZJGJOiDjGuK7RUtp2YoCG9gZDwfEh+XJAmvZLxfMSY1xbjhk d/xxFnWFNg7uQVn7Hj6228MF2C83IRkn8lLN1gqY6EuELdF2EYQ3bfCQNSszswhoNytS zl1IiXM/kCYs1RqRW8joB1RZFtZVicpYw9rb4A/bYxPmcqiYo5KkE0Qwtzs4PAVLpJvQ 2lTlHTvyiqixQ7zHiC84qN4f2hmGjOHnO36YNoxXo0Z9N3ZFNEf3qJhMC00vktWxTZxR pMGpxzUvZvxW8olxrqlV3fxWU/PK0mn3L7pku5AQfvjVPr8MtNztK6mhV0ZXuckgfBoP XA3Q== 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 t9-20020a170902b20900b001c4660cd474si2241871plr.634.2023.10.28.01.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 01:43:37 -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 8A54180A184C; Sat, 28 Oct 2023 01:42:43 -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 S231945AbjJ1Imb (ORCPT + 28 others); Sat, 28 Oct 2023 04:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjJ1ImW (ORCPT ); Sat, 28 Oct 2023 04:42:22 -0400 Received: from smtprelay07.ispgateway.de (smtprelay07.ispgateway.de [134.119.228.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EEF710A; Sat, 28 Oct 2023 01:42:19 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay07.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwetc-0006mt-0x; Sat, 28 Oct 2023 10:42:16 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 10:41:45 +0200 Subject: [PATCH v3 1/4] media: i2c: imx214: Explain some magic numbers MIME-Version: 1.0 Message-Id: <20231028-imx214-v3-1-cd4bf77f9690@apitzsch.eu> References: <20231028-imx214-v3-0-cd4bf77f9690@apitzsch.eu> In-Reply-To: <20231028-imx214-v3-0-cd4bf77f9690@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_NONE, 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 01:42:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780988109994393850 X-GMAIL-MSGID: 1780988109994393850 Code refinement, no functional changes. Reviewed-by: Ricardo Ribalda Signed-off-by: André Apitzsch Reviewed-by: Kieran Bingham --- 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 08:41: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: 159243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1109647vqb; Sat, 28 Oct 2023 01:43:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4MSCq/kqbS+I1jUwn3KSgcWWggtDDCF/6D42WivuhRGrcIH3ZmXUhY+oIKAqapAp3qoJ0 X-Received: by 2002:a05:6a00:1390:b0:6bf:5131:884a with SMTP id t16-20020a056a00139000b006bf5131884amr5848722pfg.6.1698482619748; Sat, 28 Oct 2023 01:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698482619; cv=none; d=google.com; s=arc-20160816; b=SmL5lNf5XFB0TI5BgUs3ZXVtgLfvgaBG7wA1M0dJMuSxLJTYqs4lQykNd+I5PKdLgQ 3sse+vgK09SLVRxXlgEfh0njtLeJkMX9TeB5/svyVRJ8meoxHPWtuO4lEfbi9Edy/1wf KuqekqgwyLpDMtSPCJVnOjlOXnRrCSlSk5Uz/rWk2suICXLeOcQUWUe5ybca9CbUcGHq VXF02t3STu7Oc63Q7/NPmsSNKC0tw7Yd+KBN2XHIg+4TqYBLlh2i4anmqF9XbpuXWBlj DYKf4KIb006UXL86HlcPRMtz/PtBKzYGPfaGvdkBacpb/79qfYWMonYXEEywfteDbQo1 lDzQ== 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=vzZR30MHN9CXyqIDJlpGP28cMH5CFjDbwArClKm19vA=; fh=Zgky+q+8PvhHkxojJIPDJHGW0QVIUIBdH6AVhu4TA4w=; b=N5Xqg/RlWNgUpNlUwTALvfB9DxaDo4UZlbfSHEjSuOKLKU0zF8N71mIsOwgiyA2HsM jM0JBrlvgFvwponkDn2FEbIVd8B6xuOw/a0l8iBplILRX9cK9HoYdWXor3PC+N2VEl1h 1wDjwJyu8l2PQI7j+9P/Uvckfco1TDAAqnJkNfT526eOnIRJrzNRBGYJ17w/TT4uca73 rcLIvnsiy+EBNNixiooUW2rWZ1h1YK7yBqUUaEger7jxjQsC+5jTuR54Z+7ZldzOudx8 Lkrx1ErjdFKKHptL+RRLAnLFQQcomiLXl8AqXxmmysjubCxsLcn5sHi5Shs8WpeIKb8y LDnQ== 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 q18-20020aa79612000000b006935df3019esi2138179pfg.235.2023.10.28.01.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 01:43:39 -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 2464B8050F91; Sat, 28 Oct 2023 01:42:51 -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 S232255AbjJ1Imf (ORCPT + 28 others); Sat, 28 Oct 2023 04:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjJ1ImW (ORCPT ); Sat, 28 Oct 2023 04:42:22 -0400 Received: from smtprelay07.ispgateway.de (smtprelay07.ispgateway.de [134.119.228.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EF4A119; Sat, 28 Oct 2023 01:42:19 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay07.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwetc-0006mt-2F; Sat, 28 Oct 2023 10:42:16 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 10:41:46 +0200 Subject: [PATCH v3 2/4] media: i2c: imx214: Move controls init to separate function MIME-Version: 1.0 Message-Id: <20231028-imx214-v3-2-cd4bf77f9690@apitzsch.eu> References: <20231028-imx214-v3-0-cd4bf77f9690@apitzsch.eu> In-Reply-To: <20231028-imx214-v3-0-cd4bf77f9690@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_NONE, 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 01:42:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780988111137767381 X-GMAIL-MSGID: 1780988111137767381 Code refinement. While at it, don't destroy the mutex not initialized yet if the controls are initialized incorrectly. Reviewed-by: Jacopo Mondi Reviewed-by: Ricardo Ribalda Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 115 ++++++++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 48 deletions(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 1c30f6666d35..f62cd131164e 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); - goto free_ctrl; - } + ret = imx214_ctrls_init(imx214); + if (ret < 0) + goto error_power_off; - imx214->sd.ctrl_handler = &imx214->ctrls; mutex_init(&imx214->mutex); imx214->ctrls.lock = &imx214->mutex; @@ -1050,6 +1068,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; From patchwork Sat Oct 28 08:41: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: 159241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1109632vqb; Sat, 28 Oct 2023 01:43:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7marDnD2qlLTvVcW96+VP0wQQfHozI7qawGcaR2xtMK7NT7ZfotIUf0ZUIkkvxOJSVbvE X-Received: by 2002:a05:6a20:7f92:b0:157:64e4:4260 with SMTP id d18-20020a056a207f9200b0015764e44260mr7452254pzj.9.1698482617740; Sat, 28 Oct 2023 01:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698482617; cv=none; d=google.com; s=arc-20160816; b=Xbpzvr04aoxybxLFRKeH8RKz5M4oq3T7amzYaR67QWHHhCJuVW5OCFY9w0f/nvqgzx qUTAeJKTyc8vcOWrQGMCjjR9DUSfjDABWfruh/5Yqbp0s8FoCvPGQDKxspIpKoxEIz29 RAEgj8dgKT94La70BPHSpz1TiVlvEaa+5NmW5KQGwREL7CRxS7nMsNFRT41yyMr6G4Cb ESaiyt9vfDxp9ayzj5exus2gzTLWMGAee9PhDy+kPrL8S+LVnYeZt3Dx81fakbCrQ2Yr cNF4+pmkjaorbDPMVhp77EcT30rwEiLCL7poFN0Z2FKzdSn4PGE3Cbr7oubw9h4Pmj7w pXEw== 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=CqwfF3/ehzQlG+EhvICyU3RuDWgayNY7TsG1/k6yXl0=; fh=Zgky+q+8PvhHkxojJIPDJHGW0QVIUIBdH6AVhu4TA4w=; b=HdLI8Z4TeBnDfFfHZWa9iqrOafaL7pXWM3TZ1TnyE093ZUbnjzwkyDTPftmLOR5dHi DJDiQNf3KtJlDayD2eS9LnFgE8uwKpDVekYZoTD9CcRNdcXPyZep/9OXnkotH27KXcyq tvb0bAGt7dAT05YRX84ovm8QV/HPS3MqjgcWIZclvxTjU5NOvVb7iJGDrRqGhbJjmr9g dG9LlogJ6KCUrwIhFBEoHD1Z03oiGr1QyfM7l///BjE6g7pk02dlNeOlb1uIyRKmbN0v fxAh3WtEvx9dSQvxQHp22xxBKZr8es2CWcFxLtJS9NSKxhyOgsnHoMCTWvkx+31VSlal 2EIg== 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 f15-20020aa79d8f000000b00690dbcb75d8si2161661pfq.386.2023.10.28.01.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 01:43:37 -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 76390806664D; Sat, 28 Oct 2023 01:42:41 -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 S229945AbjJ1Im2 (ORCPT + 28 others); Sat, 28 Oct 2023 04:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjJ1ImW (ORCPT ); Sat, 28 Oct 2023 04:42:22 -0400 Received: from smtprelay07.ispgateway.de (smtprelay07.ispgateway.de [134.119.228.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84FD611F; Sat, 28 Oct 2023 01:42:19 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay07.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwetd-0006mt-0K; Sat, 28 Oct 2023 10:42:17 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 10:41:47 +0200 Subject: [PATCH v3 3/4] media: i2c: imx214: Read orientation and rotation from system firmware MIME-Version: 1.0 Message-Id: <20231028-imx214-v3-3-cd4bf77f9690@apitzsch.eu> References: <20231028-imx214-v3-0-cd4bf77f9690@apitzsch.eu> In-Reply-To: <20231028-imx214-v3-0-cd4bf77f9690@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_NONE, 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 01:42:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780988109410503543 X-GMAIL-MSGID: 1780988109410503543 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 f62cd131164e..81f126a1b145 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 08:41: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: 159240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1109463vqb; Sat, 28 Oct 2023 01:43:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPyET+4Rp2RgaP45F1KdQqXfswVNfHHLe1iNzXKG6/RvfRye4VSaKk3NVRaWQzdaONAVuc X-Received: by 2002:a17:903:4345:b0:1cc:2526:1e4 with SMTP id lo5-20020a170903434500b001cc252601e4mr2749673plb.52.1698482583558; Sat, 28 Oct 2023 01:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698482583; cv=none; d=google.com; s=arc-20160816; b=oUjnZym8oj/qMg+//Ll2faA1s/K/CaB1AzFuQf000gdFyYkKwvN0tXnhSGFHhqIF3B ibklBysieeJcGHzihdX7bjE36qjcQ9PgrDJQsKoJX2TF/y8SZXSgFw2Cb9g72bhxuAo3 jplMuP/v0S7ZoxREZNRpzyE6N2OjYwn7daw7TJ5IpLoOrwjb3C2moOgYWFtBx/so5+rq Keo0JC1ifXE7pn/89CjeTteV7WGAD+IgmQE6npXfllHXmkk3xCUQsXgrfVYZ5HYrlWF0 V3tebgDqmxDdCzl5LgAZ9tdMorccJ5hSf13V8VWclwEDdLI9XtsU0swpltlVOKW2Nj0p r8wA== 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=/iDa0/PFXQS9HVxupIKe9gKZ0fPF20TIJE5T+tr/XhU=; fh=Gadr0aUB8zty8NH/YaNy5EBNIZUlZSGENDAW2PTeJWI=; b=uxtR352nvmMxa0oj0p2kffGQnggbXKVIgLnwwIEALeDfB29vhQMo3BpFxuLcwFaywq AsApZdSwTN/5DT2zIADKhj4fTQ/EfVPOY90jbCn6zW1udot/1k8FV+Zab7kLJaeiZZ2n bEguChbmzPZ/Ush5HlBmtIbkaP3Uzlnm8ajgDH+im90waRjoElrsajlfTsUHziI+sgjA pXpw1EXxZLNP6t3mBkRPL7NxyY1Tgk+O+vUdIJnmYdHfknr6DIkPxB9khFi/3OkGUbWr CJ8/TdsFuP1/VQsbcGs38BcqQvLqZKWvooZcQ/pV2McA38yO2350HlD5mBJmBNEN9rk4 Juog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l6-20020a170903120600b001cc0d2e97f8si2371828plh.575.2023.10.28.01.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 01:43:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 5E3F68076C85; Sat, 28 Oct 2023 01:43:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232405AbjJ1Imj (ORCPT + 28 others); Sat, 28 Oct 2023 04:42:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjJ1ImX (ORCPT ); Sat, 28 Oct 2023 04:42:23 -0400 Received: from smtprelay07.ispgateway.de (smtprelay07.ispgateway.de [134.119.228.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85064121; Sat, 28 Oct 2023 01:42:19 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay07.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwetd-0006mt-1Y; Sat, 28 Oct 2023 10:42:17 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 10:41:48 +0200 Subject: [PATCH v3 4/4] media: i2c: imx214: Add sensor's pixel matrix size MIME-Version: 1.0 Message-Id: <20231028-imx214-v3-4-cd4bf77f9690@apitzsch.eu> References: <20231028-imx214-v3-0-cd4bf77f9690@apitzsch.eu> In-Reply-To: <20231028-imx214-v3-0-cd4bf77f9690@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=1.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Sat, 28 Oct 2023 01:43:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780988073063658392 X-GMAIL-MSGID: 1780988073063658392 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 81f126a1b145..0aba28d6dc2f 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,