From patchwork Mon Oct 23 21:47:50 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: 157121 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1571362vqx; Mon, 23 Oct 2023 14:49:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdPpnOgM3cvZr1eN8NnXix/+3DzqFVAoB3PDKU3EUQPRIVX0ZlNLvcRHx+5kL3iCdgGGm3 X-Received: by 2002:a05:6a20:8f1d:b0:153:b16e:8db1 with SMTP id b29-20020a056a208f1d00b00153b16e8db1mr1018220pzk.10.1698097786953; Mon, 23 Oct 2023 14:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698097786; cv=none; d=google.com; s=arc-20160816; b=rFEYF7ACxRpdMyymrBWJzpOOvUHJXwo9YdAMjWcgZlBwQJFlA7gYItksXRu6C8PneC Md96kTdbVJkyDxOVQ397YHfBaMqEWJfnZWtC8oKHECzgZSJGGJcbprinbyz51/5AM0ZE bVudBlC9JmUo5tkZmMmDI8AVxOnots9+/yet/onNSLLJEW1oxFA+lazqBy46RM15lAYC KiAqNviKu3MXzJWZO2oytuYvG67x2prcGlwsxGcf4Reelqs5gVq+V6E4ncRN+IzlC39r lG1fqnuSitlJOu2IQRXD+OrfjrFwqyZnNP5E39Thfez5CJCqBhnBp/YH3GmhXX0G/VcK QtjQ== 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=hjfXoVN3bkEwgLziR1nECUia4TO+JXVJv/b8AD785OA=; fh=p+mi5Td8bOurAzEd8CdVTJhDRtapyUXUHLHoRH6vUVQ=; b=rCxUVSbfh+FRCUvX6rqYnuBz6s9Vx3ACnqOPkjJlUYd5h7uwdXQ6UgwENJXQkK6Ken 2KCs8WA7G8PzO1oXsL1JPLip3Hi4+nr4GexgCVeEAOQ60vWbZDob+NZg8l43GsY+8wOr BDo8f7eydF6Z02n1b9Df963DHCv261kGKq9hR8jsBQK/kwgokUXBLbbjAfSG44CxChS/ V33FpuFAhVMJt7300PBn6jQ+vwJkfTcTAj+QZiy/KVqDYLpRrinzTbGytuqMQ60A4tzb iqNdp91yOpNwpau4FiCc8ouz0/nbSvmaOOrZ001GeGuWppVBlMN1faABKtS2dv5qgMVm JxDg== 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 v19-20020a17090ac91300b0027e022bd420si8225911pjt.77.2023.10.23.14.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:49:46 -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 D7BEF80C055A; Mon, 23 Oct 2023 14:49:45 -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 S232475AbjJWVtk (ORCPT + 27 others); Mon, 23 Oct 2023 17:49:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbjJWVtf (ORCPT ); Mon, 23 Oct 2023 17:49:35 -0400 Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.18.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1653FD for ; Mon, 23 Oct 2023 14:49:32 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qv2ng-0004Kz-1Y; Mon, 23 Oct 2023 23:49:28 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Mon, 23 Oct 2023 23:47:50 +0200 Subject: [PATCH 1/4] media: i2c: imx214: Explain some magic numbers MIME-Version: 1.0 Message-Id: <20231023-imx214-v1-1-b33f1bbd1fcf@apitzsch.eu> References: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> In-Reply-To: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: 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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL,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]); Mon, 23 Oct 2023 14:49:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780584585492167583 X-GMAIL-MSGID: 1780584585492167583 Code refinement, no functional changes. Signed-off-by: André Apitzsch Reviewed-by: Ricardo Ribalda --- 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..9218c149d4c8 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 0x0c70 + 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 Mon Oct 23 21:47:51 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: 157122 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1571407vqx; Mon, 23 Oct 2023 14:49:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdOB/9yCAAA+GcyIBlqT7gZPnFXS8ubx8oiGd7M/BGO+LfWd7QSY7/fwhypsp2+GlM3YGg X-Received: by 2002:a17:90b:8c:b0:27d:1aa:32b8 with SMTP id bb12-20020a17090b008c00b0027d01aa32b8mr18717680pjb.9.1698097797014; Mon, 23 Oct 2023 14:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698097797; cv=none; d=google.com; s=arc-20160816; b=dhfGHvEAFLS4lU8TrUdZaPjWkb1SOa82UtuvXc4lWx3Tl5xrI019rU1K1Vdmw29WcJ KJ0IadmS26nlQlTNTYIxyOx2ouHlGyDc9dEY6pneSK4I9h26bYsiDIXrglZQB02QWe3q bQAQJHku/IUkhoDu78Y5T2iJX4tGpQ5uNeC24XI/BXGZQGhHD88O2rC4p4Pu0fhaJp9X S+rgarisL8KalNXKngMmTfxRPDHpqOIT1jjfdcs0jymXRUnRbaibrkURVFQ00YiWnjJe ZrVJOUS2G/bpnesinjLaCupVfb2bq2fZ/cIAvPLLTLkmmi6pc2SKk3R8vnyXuXbesDwc 18TA== 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=6I2FXD13hiBCqbCQPq2oxt+7ru3eVatfnIfFFL1qIys=; fh=p+mi5Td8bOurAzEd8CdVTJhDRtapyUXUHLHoRH6vUVQ=; b=V6MpoNop/726NutADbdmjDRFUVY0Iz1ncxkaQHGz4UQBauCF4+U0/XmuFJqRBeuPiI oVomtlKfWUbVgTOewTeBIK8S/Hh2jfBaT/Lp/OcCpwgQmqAVDX0rGTvt9aaMHpuzfjEA V8mcAZf7QakvHwS+XfljLZ+Zu1Y3YHHk92aEV2KQdaABRgz192on0LJJ69/N6KWZLtG4 CJJrX0bw9Dms4COBb5/h6PZD1a45/SBaEQhZXZzBsVwho0s7UnaNdrQg3i2x9OmWmvFF 2xS2yDre4oed1r/Y+Uvd1nTsvqmYC70VkrsgMD9Djmxj/1BtvSjcxT7j6uWRNOUsB3ty +BWw== 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:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id o14-20020a17090ab88e00b0027d1b42875bsi6909569pjr.64.2023.10.23.14.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:49:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 CEE9980A8500; Mon, 23 Oct 2023 14:49:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231873AbjJWVth (ORCPT + 27 others); Mon, 23 Oct 2023 17:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbjJWVtf (ORCPT ); Mon, 23 Oct 2023 17:49:35 -0400 Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.18.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1555DE for ; Mon, 23 Oct 2023 14:49:32 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qv2ng-0004Kz-2b; Mon, 23 Oct 2023 23:49:28 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Mon, 23 Oct 2023 23:47:51 +0200 Subject: [PATCH 2/4] media: i2c: imx214: Move controls init to separate function MIME-Version: 1.0 Message-Id: <20231023-imx214-v1-2-b33f1bbd1fcf@apitzsch.eu> References: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> In-Reply-To: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: 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 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, 23 Oct 2023 14:49:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780584595461714515 X-GMAIL-MSGID: 1780584595461714515 Code refinement, no functional changes. Signed-off-by: André Apitzsch Reviewed-by: Jacopo Mondi Reviewed-by: Ricardo Ribalda --- drivers/media/i2c/imx214.c | 111 ++++++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 47 deletions(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 9218c149d4c8..554fc4733128 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -695,6 +695,68 @@ 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); + return dev_err_probe(imx214->dev, ret, "failed to add controls\n"); + } + + 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 +980,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 +1034,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 Mon Oct 23 21:47:52 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: 157123 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1571423vqx; Mon, 23 Oct 2023 14:50:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXYdmk23UVYCrGb6F3CzMZiv89SbPCnDAJIhJx0tI3PnyXnEo2+DqXa6dbgryD7tegmwo5 X-Received: by 2002:a17:903:27ce:b0:1c1:f6d1:3118 with SMTP id km14-20020a17090327ce00b001c1f6d13118mr9522918plb.27.1698097800411; Mon, 23 Oct 2023 14:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698097800; cv=none; d=google.com; s=arc-20160816; b=UP4rCLf/DYb8xbTcZ8ygZnjbas6NvO6Gnku+oeKRwSMYXG8B0xh2RRJXxGLaNFXSx7 7pmtxYUkGcfJ7lHZNVCBAWMjhrSuRnaaOZnZitNSCd/FkfXV3ANdXBzsvyKMZAfbTju7 qB5L09LACWcJtWaPplyxYRdQbVOrmxlycqcsclASpGBmnQII7LfQO+ejPcbNKn58dlqg UGaQyqVGdcs3QFkCIfZuIPzzI2XjztInKtZiZ/KNtIj0z8Lb8+y/NSrEhBQiWTziIdKW KWOVo217KlDbwm8T0Xnfng6gfs2gP1wui3zVwQDGLXykB49+5QaPdKR/S9yvq5Ue5uAV iq/w== 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=eRpkYQ1yWHzXIQiDaWA2X9B6aGOEDEmshNF9lUm8s1E=; fh=p+mi5Td8bOurAzEd8CdVTJhDRtapyUXUHLHoRH6vUVQ=; b=mJPUyOvoQLARC9Xs1uinVLhKwMMzMq4Z2HWfxJ4zoBJbY3IlcGzdFRzfpQLetkCFgn mTRQFFcdcccNEMJjZRaHIvEAEO+UW/WmBJSkK28MMonQYbPLMNUBoMR13awdVTYdoWPr M0Q7LntREXpZzcUUlyd2rBEG0kyFulneUmel9wMHsQqKGpNA64JlcxAVYPxoMmmQjcmD kaFpD4A6oRtsaHmTI4WsQjUiWux/lph14ve5ECelZPEqB+Tsjk0P2ZesMJJHFeKDuX2C uvMDf6ZP6mVZ+4Br1sHR6Bh0Omfrq8w7dTFm07amDrmaGGFGzyHVu5wYX+9pARHjn+zV dSyA== 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: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 i8-20020a170902c94800b001bbacfdad2fsi7199783pla.291.2023.10.23.14.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:50:00 -0700 (PDT) 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; 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 AEB5D8031137; Mon, 23 Oct 2023 14:49:57 -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 S231533AbjJWVtf (ORCPT + 27 others); Mon, 23 Oct 2023 17:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjJWVte (ORCPT ); Mon, 23 Oct 2023 17:49:34 -0400 Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.18.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B18E810C for ; Mon, 23 Oct 2023 14:49:32 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qv2nh-0004Kz-0O; Mon, 23 Oct 2023 23:49:29 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Mon, 23 Oct 2023 23:47:52 +0200 Subject: [PATCH 3/4] media: i2c: imx214: Read orientation and rotation from system firmware MIME-Version: 1.0 Message-Id: <20231023-imx214-v1-3-b33f1bbd1fcf@apitzsch.eu> References: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> In-Reply-To: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: 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]); Mon, 23 Oct 2023 14:49:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780584599113407357 X-GMAIL-MSGID: 1780584599113407357 Obtain rotation and orientation information from system firmware and register the appropriate controls. Signed-off-by: André Apitzsch Reviewed-by: Jacopo Mondi Reviewed-by: Ricardo Ribalda --- drivers/media/i2c/imx214.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 554fc4733128..bef8dc36e2d0 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -704,9 +704,14 @@ 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); if (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 Mon Oct 23 21:47:53 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: 157124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1571560vqx; Mon, 23 Oct 2023 14:50:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG29+3K9U3f+YMDEygUj03IQaHqSj434lJS8V5W8+dBMpx39NGox82h+83i+QxFzmJnTZsb X-Received: by 2002:a05:6a21:3289:b0:17a:4891:e33 with SMTP id yt9-20020a056a21328900b0017a48910e33mr1077566pzb.4.1698097821587; Mon, 23 Oct 2023 14:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698097821; cv=none; d=google.com; s=arc-20160816; b=lbRgKB/tvuEIiwiPOjyiwVqmPsug0Ugv03fqt/3wK4RTHI6Prb4Uy1Vw6Yd3AjlFaM YQkYdiF0dhVpgXD8sdCRzSBmcbYt5O0c5Lq+Kb9OsJuCVT+MkGMKehgfwEiOt4knP/NQ mpn4kQ9B7sR+nk/hziUiZaS079cbHsa17XcioXAStXyBwTVCKA9sOabnBSSVSNM+/REa agWmvdcCBL37YzCkR3ys9kl1+/E8bivNcWwwAgQWxsyCLVVpecyJqOCh26uMc43YOoea ersrrUCp/1wgSXlG4x3AsvA1OlYnfIn8yYuCTCARKUmxx3jFlC2rSrlZxsAikgjQ5jUZ GhAg== 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=vgnquDODJh0Bumd4uVhwWrsoPUmOHur4QQeopR137RI=; fh=p+mi5Td8bOurAzEd8CdVTJhDRtapyUXUHLHoRH6vUVQ=; b=e8ZWgdgxtv26o31h9dBMoO1kzGlO4wBjb67TFPm5nIZdWh2TrfQcqmzC3rPvgbxULo NFC7qVJ+ANbdj/cA+brK4ZYE0buazt2DAiQrx6ZQWvl08QTdcG7rasxrxqdU1csht8Q1 TiZZ8Vs/Rc2fHUFeus95QkojztdukqEvnpYH4t7hyUcKPB6wbis9KmQSdPG4HDICWtyK VhsXwZ0wAu/c95w5jPXfEwt8Arw0m5in6oj0NufuVSInbrz6welfDkx0ZC5WpLjXr1Oh PqJ4REvrNvJQz3OjsEOnZQ4wTsuzOIyrSNnWEsFnWibXgGI3v9cqi6JzOPl4v1/WBSf2 kwFQ== 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:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d5-20020a170902c18500b001b3bd85f54bsi6889526pld.35.2023.10.23.14.50.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:50:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 92AE38055AFA; Mon, 23 Oct 2023 14:50:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233441AbjJWVtp (ORCPT + 27 others); Mon, 23 Oct 2023 17:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232377AbjJWVtj (ORCPT ); Mon, 23 Oct 2023 17:49:39 -0400 Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.18.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83276BD for ; Mon, 23 Oct 2023 14:49:32 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qv2nh-0004Kz-1P; Mon, 23 Oct 2023 23:49:29 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Mon, 23 Oct 2023 23:47:53 +0200 Subject: [PATCH 4/4] media: i2c: imx214: Add sensor's pixel matrix size MIME-Version: 1.0 Message-Id: <20231023-imx214-v1-4-b33f1bbd1fcf@apitzsch.eu> References: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> In-Reply-To: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: 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 howler.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 (howler.vger.email [0.0.0.0]); Mon, 23 Oct 2023 14:50:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780584621210660187 X-GMAIL-MSGID: 1780584621210660187 Set effictive and active sensor pixel sizes as shown in product brief[1]. [1]: https://www.mouser.com/datasheet/2/897/ProductBrief_IMX214_20150428-1289331.pdf Signed-off-by: André Apitzsch Reviewed-by: Jacopo Mondi --- 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 bef8dc36e2d0..a2d441cd8dcd 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 0x0c70 +/* 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,