From patchwork Sun Jan 29 09:42:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 49956 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1689846wrn; Sun, 29 Jan 2023 02:22:06 -0800 (PST) X-Google-Smtp-Source: AK7set/M+PSLuRqhgoi6iScCKoI48nYtnOIWeQ7Hcho7nMWoU4nAp+B9kZ8mn4RipsbT5hyMmFej X-Received: by 2002:a17:902:e14d:b0:194:d78a:fc80 with SMTP id d13-20020a170902e14d00b00194d78afc80mr3724655pla.61.1674987726342; Sun, 29 Jan 2023 02:22:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674987726; cv=none; d=google.com; s=arc-20160816; b=YohSui6nYcW47RLGEEusgOXV9F8cIE5VEiZBSHadVofNMcK0Ugxlz6/dcjM/OmUFBe 3iP89mYOh39tTgJ6QwIB+0iYLPd7pp5PTz4bFIjJXFQrke07pozqj/4b5+JyJLyiY9Sc rZipMyKPzMvIKvxv6EpkpGVy+tTDfsVDQf441FFTW8u9h5DTKwzaWICmDCA6KA3ioTbK LRN0GeHW5qRpF7Lu9obRuqIFyBblmbgDRWiCcVap4A46Bh37lLPIfwEa7Wu/3+w1H291 1bXBtCbVdx3GdQDAydHB2gTZyc/b3ANWZZuY+o6Fddo2pceLGnPY2tEm9txXzofz2JhA +szg== 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 :dkim-signature; bh=E6B2aH34g6KXWjZuydpb5EgoV6jPXjQCvmNo5MaNj8o=; b=cQSSzSsfOynImJhQQReYi5hggW00Cfm6okLUZ1h1mpFkD7/i90LT4effMGmGFXzInL GgzbmKFJrFNrWjWSNL7wi4vKZa29+PYGILPjiLmVRng0khaPopg5BRQiDdxkVSFAWtZY x6mI+VB4FmWAvM0H0CjJdLnJCbNCP2MgRJbgXi9QwN13z9Vl9bBHv2mUOdsIjUaJ/1L9 XY5a/g8hQnNtRgLE/ZCNGmhcDlmDeIpVjny3Iqf5XOdX/FwrXBl76PjNbnHXhqpUMwCO iNrufCHg2xLIBdCpjrGwGYM4xUM048uNZeuTxJFsYDIjImldC5CV+Q4VX3tXEfOPU8pZ eV7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@z3ntu.xyz header.s=z3ntu header.b=ivN5DlAa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a170903230900b0017808c0aa8bsi11305392plh.115.2023.01.29.02.21.53; Sun, 29 Jan 2023 02:22:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@z3ntu.xyz header.s=z3ntu header.b=ivN5DlAa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234573AbjA2Jnz (ORCPT + 99 others); Sun, 29 Jan 2023 04:43:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233753AbjA2Jnw (ORCPT ); Sun, 29 Jan 2023 04:43:52 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC4BA23326; Sun, 29 Jan 2023 01:43:32 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id A38ABCDE1D; Sun, 29 Jan 2023 09:42:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=z3ntu.xyz; s=z3ntu; t=1674985371; bh=R9ZNv09De8WL7qrMjmRnJkXWIPy46lSI3OBIO9SIMXw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ivN5DlAay/Hh9eYY92OY3MiwQqPK1AZ7vS/IK61LJjgNMI6thBRPgHCA5D2b+LGxb NCP0ts+2Ma8ytP9ZE8hebnc0y2dqimIG9T1O2LB7pBlym9mAsv//tZwbr8Tv2F2zez 96/JiNP5DRVYD1P0FPccJPzeXtv3wLVLO9bQL0pI= From: Luca Weiss Date: Sun, 29 Jan 2023 10:42:35 +0100 Subject: [PATCH 1/4] media: i2c: ov2685: Make reset gpio optional MIME-Version: 1.0 Message-Id: <20230129-ov2685-improvements-v1-1-f281bd49399c@z3ntu.xyz> References: <20230129-ov2685-improvements-v1-0-f281bd49399c@z3ntu.xyz> In-Reply-To: <20230129-ov2685-improvements-v1-0-f281bd49399c@z3ntu.xyz> To: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Shunqian Zheng , Mauro Carvalho Chehab , Jacopo Mondi Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=894; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=R9ZNv09De8WL7qrMjmRnJkXWIPy46lSI3OBIO9SIMXw=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj1j+Xi0vA9+m7kad3e3/xYUSgehrk6D7zWpUwkTFv iITbT3KJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY9Y/lwAKCRBy2EO4nU3XVoIVD/ 983IJ5BCQZ0Uw820dThLSGKfcgcUMb1aHUe5yyai4hN92eHKNAfpkEN9h2/xtYCW8CyTfzEci07FYv eONEJWos9uWfzxoC4juKEhAJ70KMPOicze6zCVX+c5++oEht045JWULh/9rjM+Sk2qHalWwOHTlQ+H N6FKv7Ya1eJtzzhvr5SuOf0DqpF+NXcqQmVKtmAQ1BuvAo1LV+PGDWElLi9lvOAREJmRelQMMScgtS nKJPSdGI+jvd+hER+/qTvvbm67Q6GSi7YsnFKUIcgFFe72yzqQ5IpEARyPpKqqcZ3y4E4nMU/NLYrz bWO4JtHyAM5866EX81uL5JYoziFPSgq62Exf7Fa4FdgUuieAMAD8ARKg+Muz/2yH5CmvlkH71VuvTh sp2MLlk9ekO4bPGVSJUkLUXU5Fd75XSiDxCnk0DZAis+nnDJNHAcjgZo1T1rdzbu5iwh2fWh5qT8P6 /oqjc49GMZljZxcVNFMeJRmrXGkjgb6hJgCPYDv7vhP7483tr+qNeyll/h8eJrtVzfakw8xll78lGV +kD2QuDihaxxWxXwI5cZHMOzuptkpo5NM9jPEHYGE7pKKzBDX9IH34XmymTO7TfvEcNobxkt8UnqHf ZSZ4R4C8RXog4eSqzxviCtVhPEHd+KVCsttRqp/rrOl+C1W6nSjYBMJyJHLQ== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, SPF_HELO_NONE,SPF_PASS,T_PDS_OTHER_BAD_TLD 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756351929715062013?= X-GMAIL-MSGID: =?utf-8?q?1756351929715062013?= In some setups XSHUTDOWN is connected to DOVDD when it's unused, therefore treat the reset gpio as optional. Signed-off-by: Luca Weiss Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov2685.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c index a3b524f15d89..a422f4c8a2eb 100644 --- a/drivers/media/i2c/ov2685.c +++ b/drivers/media/i2c/ov2685.c @@ -734,7 +734,7 @@ static int ov2685_probe(struct i2c_client *client, if (clk_get_rate(ov2685->xvclk) != OV2685_XVCLK_FREQ) dev_warn(dev, "xvclk mismatched, modes are based on 24MHz\n"); - ov2685->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); + ov2685->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(ov2685->reset_gpio)) { dev_err(dev, "Failed to get reset-gpios\n"); return -EINVAL; From patchwork Sun Jan 29 09:42:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 49954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1680888wrn; Sun, 29 Jan 2023 01:48:32 -0800 (PST) X-Google-Smtp-Source: AK7set+yKeW7e+k7hWIg8Oxgojs/rXNhuFMVkqlviNa+DJbWOlzv6C63F2k8q5JU1nrH4bGc3xhj X-Received: by 2002:a17:902:f682:b0:196:8292:e879 with SMTP id l2-20020a170902f68200b001968292e879mr206358plg.1.1674985712553; Sun, 29 Jan 2023 01:48:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674985712; cv=none; d=google.com; s=arc-20160816; b=kJdU6hp2LJdtoCKNSOTdmHdnBQX7khF/4fZCt0K3VMc1O5OBLpS/vQkZ6pXd0YvJ3X lZ0J8WQiYSbPqvo8T2c6tgcCiHcZ0WnMZmx2YmmADDUP3LTIWM3VR4wTVrirrNCPb/rd aPWJSQQY931cUEqCsIUWOsnhUVKcx86TXeWhvIkwgcHLKp/Elz66v7RAHGhfKT873z+e vBA5/akZpQpot2+m1kWliAJJcrbpF9MZ2hYSTDUdlxkWlcj2KlEQ6SsX2tKCsheP9g23 scYZ316u8GOZY2GRE9QH0C0MUSoo/kjqJqxHbHknBDWq8EbAkU58hx26nDTUpwGCkmI7 mu9Q== 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 :dkim-signature; bh=YTL7CRdAXs8Pyl9kerGcE/pnuD8CiF76VaRu3T2KY38=; b=geVgx4HhlKgJ6/Pa+QSjNMTYMTwaVVGcTHQVnNkukNzPaK6SmiL3dBj2HanUTxUKCb Xqs+LlasCSPVnB7qhjkedPWXMU3O0O3DuxhnQgTxoBnUmlQeX6d256z2d1lQKnsiY9Zn 9mKrDaydGgS5OQxKHN7WFcq07E1jVsVrk+wuAbmj0a9tnMcQg/2AHLYuADu2a78JtcbT N119QNjvyXGrIR3+QwMBBz3U99obkUtQBnLQ5X/1cfnZjXRF3M0fQcxo/R7R9jqioYfE +Zstef+xkgv6kGoBVvrgzRHHyCqF6lzNx7n2JTehUx5uIBk32gjkdV1B4qF4Z5ipPCYY 9Sdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@z3ntu.xyz header.s=z3ntu header.b=PAjFT6mw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q78-20020a632a51000000b00462a6f64703si10135630pgq.376.2023.01.29.01.48.20; Sun, 29 Jan 2023 01:48:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@z3ntu.xyz header.s=z3ntu header.b=PAjFT6mw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231336AbjA2JnF (ORCPT + 99 others); Sun, 29 Jan 2023 04:43:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232759AbjA2Jm6 (ORCPT ); Sun, 29 Jan 2023 04:42:58 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3E206EA2; Sun, 29 Jan 2023 01:42:53 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id DA49CCDE29; Sun, 29 Jan 2023 09:42:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=z3ntu.xyz; s=z3ntu; t=1674985372; bh=fIplo9JpImpQeisw7bapzCgXeb9xPVwhFZKge8ht7KI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=PAjFT6mwjS3L63nLMj10WYEUkN6ll5AQt/IXGx9zhBGCAMY7TUoZiYvqDmZ8eeJhX rbF8T3QfrTBf8d/CNrsNSuKi73B+OFlRqJVSXMWbF3gg3m8nhNv+gRUPxA7UHez2gJ G05jw65ZTIAMg/zrkpfTy7pIpkOU9OLfrlUlOE2s= From: Luca Weiss Date: Sun, 29 Jan 2023 10:42:36 +0100 Subject: [PATCH 2/4] media: i2c: ov2685: Add print for power on write failed MIME-Version: 1.0 Message-Id: <20230129-ov2685-improvements-v1-2-f281bd49399c@z3ntu.xyz> References: <20230129-ov2685-improvements-v1-0-f281bd49399c@z3ntu.xyz> In-Reply-To: <20230129-ov2685-improvements-v1-0-f281bd49399c@z3ntu.xyz> To: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Shunqian Zheng , Mauro Carvalho Chehab , Jacopo Mondi Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=852; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=fIplo9JpImpQeisw7bapzCgXeb9xPVwhFZKge8ht7KI=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj1j+YkQM6n+QsokVKigwFK5cBsCkYGjl+8gx6I8bu mnqR84qJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY9Y/mAAKCRBy2EO4nU3XVtWbEA CFHa4eVdFWJ8fw5jhJA6GUKKjvGnkKmp8SPepUjCxRSp9SWvzZG4B+Am4tgUAjz303KwyiYd4CEetP Qhd5pPtPWmq+lxt39gc7nltKjLAwqktTtOrH3F3gytBi9+6cozRA9BFxlNknhGXWxa8ipGge41NC0r 01OIpLD+LWRCMUdUs8XzzOV/3+M5a+Yk0z7vNPM7b/IZvwyjIF3Q3VUM1PgJi4rX/71+ZZQJtByJUU oY0NJRMThJmIWu9ez69YQI5f8jtuLE+0o4yiuTEyFH7/ShdILqfmGMeBn+H0UFASF75p8DSonirkZr +67nc3SR15+azeZPYP7nChALEaN+nW7nv5u5a2keQ/AVAkKyEV7pgm30+Or1Aa5UivFQirbTdod951 7S1mwnCj6Nh7Z7pOynxvP1F9+mRUj54sWiMmCUqHay1SP+ZuvmJghCnWgkNe7YdJKXuec7UMqK3LKj wHgDqsC00j7L+bcg5yWDIUfqvAgv7dethCmvKqSAPYZTHqt/vJSGeCMs5C1OrnRM1yIfgOjUoNUeKQ mpg82wl6evHnTZVKYYQJP1QOZvDb5LcRomULoVjeCyn2czk+s5H241OgvHlq2SYEufGsj8yKtqTpZ+ zwsXfkNdfS7Cm+JfgRUaTP+w/KXWS24yarh5RKm1LLCwcxN2p8C0YdFmASLg== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, SPF_HELO_NONE,SPF_PASS,T_PDS_OTHER_BAD_TLD 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756349818130307411?= X-GMAIL-MSGID: =?utf-8?q?1756349818130307411?= If the sensor doens't power up correctly, for example due to incorrect devicetree description, the power up i2c writes will fail. Add an error print for this situation. Signed-off-by: Luca Weiss Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov2685.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c index a422f4c8a2eb..844a91dbc8e5 100644 --- a/drivers/media/i2c/ov2685.c +++ b/drivers/media/i2c/ov2685.c @@ -419,8 +419,10 @@ static int __ov2685_power_on(struct ov2685 *ov2685) * writing register before .s_stream() as a workaround */ ret = ov2685_write_array(ov2685->client, ov2685->cur_mode->reg_list); - if (ret) + if (ret) { + dev_err(dev, "Failed to set regs for power on\n"); goto disable_supplies; + } return 0; From patchwork Sun Jan 29 09:42:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 49953 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1680849wrn; Sun, 29 Jan 2023 01:48:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXvnkgjQm0eTbOTedkjmKxbnE6FTvrdb0jE7z3s8ZO4PasMrFYS+guxxvVqo0CesCDfSqSUO X-Received: by 2002:aa7:9259:0:b0:58d:948f:2acd with SMTP id 25-20020aa79259000000b0058d948f2acdmr44781435pfp.33.1674985700385; Sun, 29 Jan 2023 01:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674985700; cv=none; d=google.com; s=arc-20160816; b=m3LPRTQv/o98frIdRnVTtw/6MwvFzq+jWwhsoYMQpI8Mw5bQrTmtVDqVo6aL9ID7CC Y5kOrD28vpvUFaTdTyPKsxa5vgXjcbVcDrv+S9IOu3lbcBndJTYij08kfNdaD3c2+iRt Faw8VaJy4xac+/rQW422dl7hkivCc5VFwBKgIOVsgBD+BhPhpGEn/W02zLDE40AiaRdu w7m2YdBIGoUZUZa/g6q6UhpQGMMkt1BJZMOPCVcsOhkTe+UB+5H1MRimAyG2MIl8jhb/ D2NhsXiQhsp5x0NQrrNS2hpy/k2mYzot7oweGh2oOoyWhqFW7ThUpU/AidGU3sB0YD+G OVDw== 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 :dkim-signature; bh=IIa35XuitZEDU7n+JhFP5pWxeydDoLBwa+r2PqAFNC0=; b=uIXD3SqqG70kbdP44gCfhXOAnYG7/eXYq4HBNrPJOcgzmsezQd87CKGjtATtXfdqY7 HEII9TIZ5YYnlmiMBr8I4SW8rr1jyj1uz3H/lAhVk5dbgv3iTQ+rA0x4TOH93SlAngj7 JtH09GYBwAmQIvyKE4ZZAg1Qu0Ntu/FBO1e6xfvt9zOGA+GjKpDxoNjx3stPxAcRpnRS vTyy5HyWMFzA2hlH2FNal/VuVJL5kadDZhEoql5FjaqGKIOm1/CCqUwZjsIPmdUVPcN9 3v1PK8imxoqJwzc3rJPleymVieStXxtHUBoVlkHmr0OQsLu/0ODDV/Wy5GR/RLLFNg0k QjEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@z3ntu.xyz header.s=z3ntu header.b=l48RjCz+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 63-20020a620542000000b005916a333bffsi9211959pff.264.2023.01.29.01.48.07; Sun, 29 Jan 2023 01:48:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@z3ntu.xyz header.s=z3ntu header.b=l48RjCz+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234449AbjA2JnB (ORCPT + 99 others); Sun, 29 Jan 2023 04:43:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232549AbjA2Jm6 (ORCPT ); Sun, 29 Jan 2023 04:42:58 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3E797683; Sun, 29 Jan 2023 01:42:53 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id 1997FCDE2A; Sun, 29 Jan 2023 09:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=z3ntu.xyz; s=z3ntu; t=1674985372; bh=wpSIFiFaQeJjpP8EjFtZNN2+bMm1UD9zAgvnDvRYovM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=l48RjCz+Cfmfm0bJfpsAWmWNGlylZQM+N2a+m5yTqO/S5SVwqCKHpK9bUuR+ME0kV 7lcOBpk/pP2AXdDHSGtQVyJhz91qZX7Pox432PdnN+Lzt8y3iRiVn3s2p5ewu6Zv3c bQnlbJToe7mxGen7DZv44iR4jfRXNtPKCqG/gBOo= From: Luca Weiss Date: Sun, 29 Jan 2023 10:42:37 +0100 Subject: [PATCH 3/4] media: i2c: ov2685: Add controls from fwnode MIME-Version: 1.0 Message-Id: <20230129-ov2685-improvements-v1-3-f281bd49399c@z3ntu.xyz> References: <20230129-ov2685-improvements-v1-0-f281bd49399c@z3ntu.xyz> In-Reply-To: <20230129-ov2685-improvements-v1-0-f281bd49399c@z3ntu.xyz> To: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Shunqian Zheng , Mauro Carvalho Chehab , Jacopo Mondi Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1524; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=wpSIFiFaQeJjpP8EjFtZNN2+bMm1UD9zAgvnDvRYovM=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj1j+ZRG8/vFXpNlQCejfrorbGALJ4DzE5NPq2PhbN gmDYKE+JAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY9Y/mQAKCRBy2EO4nU3XVqfMD/ 9BlHLJDxQXyX2cvIcxslpCQxeF8y8lfwJcDX/CrSmPEhMdn6FEsJFLBC/VoWdYxj9n2F8Jjo8/hSA7 bev0yJAnvZkB+YzYzJQ7/I+S15dRUdy9Y7KBQp5k1qxHdslgVy1TV2yXmXaYMdUWu3JxQbHFTUo0YJ WGV2jjBd96d+qgEjCojCrSouM3iDNVN0JLUd7QMtuNsSTw7lw6piceP9ovQwZTd90U1fV3rItn+bpQ Kvsu+2jBFol2KurLWre0YQUGu7TM29f9fIer0vzI49bXHxS8a3DEGt6GMmP62NPL1BXrjTYgdK8qtn r+ZClWu/t0XiTdi/2TtdQHQmgn4BMbN3SM6KLRL5qUDQd4/nAYENWACDlybU/XV194F14E7jXwuBc+ TVb5IULaggBbhLsj7htcA3PQAzXpVwCmGxe0t5j6FiJyeZIl/z/OmfZ46F0ApOiiTSgA85qS/7NjnB 25exPZf7PYcjYKyNPmW6KVCV6RjJBNe3NvRW67JNusoXKbfGUDH57PkpqIBbwDLRmk37Vhwyrh4+NZ mUB+N3VYXfiSkHQZKG+1a27nbhIz3cfafnQM23SIVhJKcaaB+ttL79AnmUimuqoM8JveDbASgxznfG 47VpcdiPrlPWy35N9i36O3NcVDHeW7mra0+hOwReaPkdTE/uOSg52dv4sUTg== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, SPF_HELO_NONE,SPF_PASS,T_PDS_OTHER_BAD_TLD 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756349805796716476?= X-GMAIL-MSGID: =?utf-8?q?1756349805796716476?= Add V4L2_CID_CAMERA_ORIENTATION and V4L2_CID_CAMERA_SENSOR_ROTATION controls to the ov2685 driver by attempting to parse them from firmware. Signed-off-by: Luca Weiss --- drivers/media/i2c/ov2685.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c index 844a91dbc8e5..bfced11b178b 100644 --- a/drivers/media/i2c/ov2685.c +++ b/drivers/media/i2c/ov2685.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #define CHIP_ID 0x2685 @@ -613,6 +614,7 @@ static int ov2685_initialize_controls(struct ov2685 *ov2685) const struct ov2685_mode *mode; struct v4l2_ctrl_handler *handler; struct v4l2_ctrl *ctrl; + struct v4l2_fwnode_device_properties props; u64 exposure_max; u32 pixel_rate, h_blank; int ret; @@ -661,6 +663,15 @@ static int ov2685_initialize_controls(struct ov2685 *ov2685) ARRAY_SIZE(ov2685_test_pattern_menu) - 1, 0, 0, ov2685_test_pattern_menu); + /* set properties from fwnode (e.g. rotation, orientation) */ + ret = v4l2_fwnode_device_parse(&ov2685->client->dev, &props); + if (ret) + goto err_free_handler; + + ret = v4l2_ctrl_new_fwnode_properties(handler, &ov2685_ctrl_ops, &props); + if (ret) + goto err_free_handler; + if (handler->error) { ret = handler->error; dev_err(&ov2685->client->dev, From patchwork Sun Jan 29 09:42:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 49957 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1691233wrn; Sun, 29 Jan 2023 02:27:23 -0800 (PST) X-Google-Smtp-Source: AK7set+God6eVk4+AlEnvccfKeNxDHiPr8KeMKCyDk+xOd8XI35Rhj+Kjo5eGoD+8/QHsYJ0+GjL X-Received: by 2002:a17:906:475a:b0:883:3661:97e5 with SMTP id j26-20020a170906475a00b00883366197e5mr4857977ejs.50.1674988043385; Sun, 29 Jan 2023 02:27:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674988043; cv=none; d=google.com; s=arc-20160816; b=e6JjvTy/H5k158G2tI9NTqcZvjYeTZUB3AfztsukuNjxxGtRFezrlSwz6lSmhCkJsW 7fe+itrn0bfvpIfrxzVcQELYsRRXeYhrgNMBk6N6jtmrnHFPX3Scen58+HjdZE4N5/QS d7agmxWxXxltlF0oCKzmULBL3QDFONcu8i8Z6V8euXRWdyDYuToNI/+8L3Uq2L8zgAH3 mVGHwCcXQ/fOthRK5KFANpXvxzaZ6wS2bcCCoQsTTGoSfV+ayCETtuSpN+LCwv0mEEgk nJq007ywf12n6syv9B+K7bJjvKlNX+pb1YolpAIYghJSLFUZtxH+8c2BgADkxvCwiapA fdtA== 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 :dkim-signature; bh=Ha6t38PzOAwx7WX1N1Bo8HXCAgjEGbA0QfMquVUyfgQ=; b=mHw/ZLxn7AF1XpuOobMJtIiKBSLF977UWsoffMH62ermdnuQ1iY/UWsev6pkSfcdDb zoUGMzzpje8JRde+0kXEuLun2n/xk6OqQquAMZkEdNy5cySQ2tjSMFgqqQG7LGYRSvOd SxhApcYVJNtpcf64IGpnn4md5R4sr/lMG3rLMv51TZ5pgaxQaaQlKlxQPFqWgVuiYz13 7cJROldK6EcTynixTNPhga6MrfsaGXONtlf1XymtcRdAmrGrhRaSAivlOK094++GqnFO s0w/nj+/S2cF1fXmuCdrPP5rh2qpnkmE1/JcKsFo8TUd3fQPWW3AGjPZXyKOEMOEW5i4 Y4Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@z3ntu.xyz header.s=z3ntu header.b=DstNmFfp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vg13-20020a170907d30d00b00870dfbd036csi12272375ejc.653.2023.01.29.02.26.59; Sun, 29 Jan 2023 02:27:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@z3ntu.xyz header.s=z3ntu header.b=DstNmFfp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234675AbjA2JnN (ORCPT + 99 others); Sun, 29 Jan 2023 04:43:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232515AbjA2Jm7 (ORCPT ); Sun, 29 Jan 2023 04:42:59 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01D7FA250; Sun, 29 Jan 2023 01:42:53 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id 52C50CDE2B; Sun, 29 Jan 2023 09:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=z3ntu.xyz; s=z3ntu; t=1674985372; bh=R963XiWG8I087EIGFoGr/eGgPVKChoDVSb6l1Zl4J0Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=DstNmFfp95SRGDa92uNqmd5yQrsVFsuidzdBloW+r035OXLeNNME4CP1bFq3Aluk/ VtwJ+2o7ePhRyctRSK/pmXjRwheISmhPlT4zBtxkp0OBQHP/LRp00i7SqBzj8BdNHn 9+RHvFeXH6kOa1gN0ucF0Wz53d7gQoIpJe+Os1H4= From: Luca Weiss Date: Sun, 29 Jan 2023 10:42:38 +0100 Subject: [PATCH 4/4] media: i2c: ov2685: Add .get_selection() support MIME-Version: 1.0 Message-Id: <20230129-ov2685-improvements-v1-4-f281bd49399c@z3ntu.xyz> References: <20230129-ov2685-improvements-v1-0-f281bd49399c@z3ntu.xyz> In-Reply-To: <20230129-ov2685-improvements-v1-0-f281bd49399c@z3ntu.xyz> To: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Shunqian Zheng , Mauro Carvalho Chehab , Jacopo Mondi Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Weiss X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3319; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=R963XiWG8I087EIGFoGr/eGgPVKChoDVSb6l1Zl4J0Q=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj1j+aqBXyjFkPdby91LLjF/yrKIZSCZpCNPcCKsav /6FCtoyJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY9Y/mgAKCRBy2EO4nU3XVvgkD/ 9NpFgf8l4TLxIgs+R9/TAQlDzNPv5QDgG+gXK2m+S1tgZ4MufPtjAbO7LlF1SFJROrgEr6povkje5o AgYamk0Jn5Ct6+7+HB6AL+Oqk24T9z1VzFuI/3XIGrIEPHUgabMpCvCcPe5EU4iWdo43/tK4vsRS4u lsgRVMflNbUwwFpff1TWT055ruX8I17wVh/M90spfuY9Cyu23QibeldcBXolToLeiY346k6Z3zJ8i0 pwfHxock/kn51jo4u6xhONLjDW3a0JMMtWg98okaxhSgZZYwqnFE8wGXyNIvgHDoeHxxVA7SHrJt6l 6T5kHnELqHeAN/YJaaE58Sbp7MtveS2o9ByjFwFmwbuYnmKf/WzxQIHswLRWBa44zp/B7c/YkoHIHg TXPdoUZ2+OWkwtBXDvInALMzDNIlJxwtc8txA60FiFbFGg9MQteIKoSjOm2qvyoVa5rm8/pgWCsuki FntIJMh9QOdw9SSDDc9O8y1pPVmHgxHuTXRUDjKFaBfH3wF4XPSoPBY6cfy4jgjZHwfiGXlSuK/Pld usPXHEoR5kdGLrghO4NHxueDiICr/tBLKBC40hEri9E91nK0xsRw9q0Dsdj28ge/K5IhHYqhVWOB2K MSckuuN+zbsY8QqPYfeMx6NtyA+Myqp3yUAgjZJaXASt4+dfsv5J5QaBz+AA== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, SPF_HELO_NONE,SPF_PASS,T_PDS_OTHER_BAD_TLD 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756352262703283118?= X-GMAIL-MSGID: =?utf-8?q?1756352262703283118?= Add support for the .get_selection() pad operation to the ov2685 sensor driver. Report the native sensor size (pixel array), the crop bounds (readable pixel array area) and the current and default analog crop rectangles. Signed-off-by: Luca Weiss Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov2685.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c index bfced11b178b..7ebf36d1a8cc 100644 --- a/drivers/media/i2c/ov2685.c +++ b/drivers/media/i2c/ov2685.c @@ -56,6 +56,9 @@ #define OV2685_REG_VALUE_16BIT 2 #define OV2685_REG_VALUE_24BIT 3 +#define OV2685_NATIVE_WIDTH 1616 +#define OV2685_NATIVE_HEIGHT 1216 + #define OV2685_LANES 1 #define OV2685_BITS_PER_SAMPLE 10 @@ -78,6 +81,7 @@ struct ov2685_mode { u32 exp_def; u32 hts_def; u32 vts_def; + const struct v4l2_rect *analog_crop; const struct regval *reg_list; }; @@ -231,6 +235,13 @@ static const int ov2685_test_pattern_val[] = { OV2685_TEST_PATTERN_COLOR_SQUARE, }; +static const struct v4l2_rect ov2685_analog_crop = { + .left = 8, + .top = 8, + .width = 1600, + .height = 1200, +}; + static const struct ov2685_mode supported_modes[] = { { .width = 1600, @@ -238,6 +249,7 @@ static const struct ov2685_mode supported_modes[] = { .exp_def = 0x04ee, .hts_def = 0x06a4, .vts_def = 0x050e, + .analog_crop = &ov2685_analog_crop, .reg_list = ov2685_1600x1200_regs, }, }; @@ -384,6 +396,53 @@ static int ov2685_enum_frame_sizes(struct v4l2_subdev *sd, return 0; } +static const struct v4l2_rect * +__ov2685_get_pad_crop(struct ov2685 *ov2685, + struct v4l2_subdev_state *state, unsigned int pad, + enum v4l2_subdev_format_whence which) +{ + const struct ov2685_mode *mode = ov2685->cur_mode; + + switch (which) { + case V4L2_SUBDEV_FORMAT_TRY: + return v4l2_subdev_get_try_crop(&ov2685->subdev, state, pad); + case V4L2_SUBDEV_FORMAT_ACTIVE: + return mode->analog_crop; + } + + return NULL; +} + +static int ov2685_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + struct ov2685 *ov2685 = to_ov2685(sd); + + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + mutex_lock(&ov2685->mutex); + sel->r = *__ov2685_get_pad_crop(ov2685, sd_state, sel->pad, + sel->which); + mutex_unlock(&ov2685->mutex); + break; + case V4L2_SEL_TGT_NATIVE_SIZE: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = OV2685_NATIVE_WIDTH; + sel->r.height = OV2685_NATIVE_HEIGHT; + break; + case V4L2_SEL_TGT_CROP_DEFAULT: + sel->r = ov2685_analog_crop; + break; + default: + return -EINVAL; + } + + return 0; +} + /* Calculate the delay in us by clock rate and clock cycles */ static inline u32 ov2685_cal_delay(u32 cycles) { @@ -592,6 +651,8 @@ static const struct v4l2_subdev_pad_ops ov2685_pad_ops = { .enum_frame_size = ov2685_enum_frame_sizes, .get_fmt = ov2685_get_fmt, .set_fmt = ov2685_set_fmt, + .get_selection = ov2685_get_selection, + .set_selection = ov2685_get_selection, }; static const struct v4l2_subdev_ops ov2685_subdev_ops = {