From patchwork Wed Feb 1 17:06:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 649499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0492C38142 for ; Wed, 1 Feb 2023 17:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231644AbjBARHU (ORCPT ); Wed, 1 Feb 2023 12:07:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjBARHT (ORCPT ); Wed, 1 Feb 2023 12:07:19 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F859019; Wed, 1 Feb 2023 09:07:16 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id A4A83CD5EB; Wed, 1 Feb 2023 17:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=z3ntu.xyz; s=z3ntu; t=1675271234; bh=mU7WO+CJjepkCD5wdLsQaRzi/CFzaplHDhayDwUy6aA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=b2Bh+LKHoX3KAH1UKadOHh9E1tdN13Qf7BuwSpo4jr4/dV+jESpmtLqltSTbn+W6B ZeMUfubzDnlr4P2/GQu/M4Xg4U0FlRH/Uo4qQVJAF2o95WFuH3lkSDp4ti/dGwTari 9oKigdBt5w7Cbj1Y2di0ip5TYjKV8pavVdk1EPxg= From: Luca Weiss Date: Wed, 01 Feb 2023 18:06:58 +0100 Subject: [PATCH v2 1/4] media: i2c: ov2685: Make reset gpio optional MIME-Version: 1.0 Message-Id: <20230129-ov2685-improvements-v2-1-210400f2b63e@z3ntu.xyz> References: <20230129-ov2685-improvements-v2-0-210400f2b63e@z3ntu.xyz> In-Reply-To: <20230129-ov2685-improvements-v2-0-210400f2b63e@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=953; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=mU7WO+CJjepkCD5wdLsQaRzi/CFzaplHDhayDwUy6aA=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj2pw/44cBYLYqME0Suaw12Qm51b7+wZrJgODj3ilO BGXhH0GJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY9qcPwAKCRBy2EO4nU3XViUND/ 9LDqVTJP5Rq64Wk2VvpY4Kz4p77GTLO8ULRGU/cQzF9ce9oPOrGCTLMm35RI1QpXS10X2WTVjKoRGZ ErDeZuhgw/nusCg+uBfdL15c2h5rHyKll/H712EMKY70GiQ6bnNuQr4FlBc+z0H2h+P3YYGPMWGqq4 SDBQrb2tzjJ6EebqFVZoR4ualFXX0vTz+rzcQ7WKb9aauur46h9HFrVutNjK4TKJip0ZS4TdRMD0zi 95yx9SjOCG8sulKzcAACmJcerQBGqYRtWMVLHTo8VWFCJyVcylUyseZuRYttTDXV57Nkp81S0v5RNy Lr5bz4zpQIRS6WRrmRGDTWhRDrp+La5nvkHZSLJcdEfjxgtitamQwcVSK5gge17PMpmDchS98T1Oez 25NWpq0a4Td4pIyYtXIp8dZFS7r15DkmLufsWY2DXAkvP86pgmC8DZ5wkCwmzqL96IUGzid3tAJr1d fdz5cpXscgJtEG6ZZLXnvwwdjxBct3E+WBpS65vFu/xaodmbXfudPPBnmvzBbZyH2Z8AwY4l+V2K/v hCeZJa2cMM69abm6oFA3fb4DooVgoAGBDAy0dR2wK3IXLsCOfyE9fewbTnxfFfNDqoYA2FhQtqqi3W +ReNa9fXd2Yj4YqFc2yESBzF5MUp/rH+LMCJXGsphhQP2KfNLsCSjC4bHokg== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org In some setups XSHUTDOWN is connected to DOVDD when it's unused, therefore treat the reset gpio as optional. Reviewed-by: Jacopo Mondi Signed-off-by: Luca Weiss --- 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 Wed Feb 1 17:06:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 650756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED411C63797 for ; Wed, 1 Feb 2023 17:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231890AbjBARHv (ORCPT ); Wed, 1 Feb 2023 12:07:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbjBARHt (ORCPT ); Wed, 1 Feb 2023 12:07:49 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77CAF751BE; Wed, 1 Feb 2023 09:07:46 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id D9309CD5F1; Wed, 1 Feb 2023 17:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=z3ntu.xyz; s=z3ntu; t=1675271235; bh=irj9IbvoRsw66nkVg8fECEY8qTjAkErYN2bE/CDzO1k=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=AIHR0LAX2GCZa7AqZ0Ti2SMxSU/cE8GePFBaImWEszsTPAi4h24Rm9Kzuze2h1DjP deucvASgC8kjCMV4v4a66gODrZCh23arpDbBgGPw4DFrgghfl9ls7M0kxwM2kXalSg qlVK/JDrA3nJFEwiYMMpRB7HZbggi+si+9+3XPIU= From: Luca Weiss Date: Wed, 01 Feb 2023 18:06:59 +0100 Subject: [PATCH v2 2/4] media: i2c: ov2685: Add print for power on write failed MIME-Version: 1.0 Message-Id: <20230129-ov2685-improvements-v2-2-210400f2b63e@z3ntu.xyz> References: <20230129-ov2685-improvements-v2-0-210400f2b63e@z3ntu.xyz> In-Reply-To: <20230129-ov2685-improvements-v2-0-210400f2b63e@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=911; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=irj9IbvoRsw66nkVg8fECEY8qTjAkErYN2bE/CDzO1k=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj2pxAsZR3upyzyoEiKg3AO7AyD0lBdOly7HaeOIFc BV3KvH6JAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY9qcQAAKCRBy2EO4nU3XVn16D/ 4ppyzkdy2azwUaBozrFRetdxhmkT29cWTgaiYzDZS8dJCXnRiD/6VJeMUYtGzt27eH9lGqvJTuRiDB 7chgAeNMjiSLbdbeJmS9YycrUMI5uEpCGifFhkrJ5pCUO5ForyHZwCl2av704XzWbGRDqtB/nk2oIh Gtw6SaCHYSC/O1zgwlz3mYMp7ZhwvGYFKJfsf79owOGI6wDSIn3hNgtpAg8RzK204VdyGO6DIYj6ZI 9PFKz4T2U+I8jAXvhFR+U7jKt213oVnbX8f9FDXFUnJn0GPkVTCYmNbiwuZ0Q7KoZnXCPAhbksw4sV DCcP5CrX0U6FabYWp+K8NgXyM5bjuYPGrluc1FlnAWfHRYCADaxaybgxVh+3L7+idpJRYBQ5tqHaMr l88SqyxVBtHyrTKhPuUWvZPDcdS1h2uYsLeZHchb00QtdOmB9dXVwkJh7RqebR+iP54zDY2CK/3qGr QJY+5g1qPeCPe6xKe3dXZEJ5HAysNVaFhiA4LMF95xJDh+hbr+Z4q7nWfx0r2/29R6ees+QZV03meM mV/9vzJpqWNYV13bLQ28ie/+22xn/v+lymCB9HgZVK75k8uQ0mxEgGE9vzkcPG/QzTezFqpsyQmj6+ u0W6ZG9qAc5cQcOl+hvdOS7OkRXubTHxXXPH7/8MhN4JoKjOQWL32jvKKcuA== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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. Reviewed-by: Jacopo Mondi Signed-off-by: Luca Weiss --- 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 Wed Feb 1 17:07:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 650757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ABEFC636D7 for ; Wed, 1 Feb 2023 17:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231786AbjBARHV (ORCPT ); Wed, 1 Feb 2023 12:07:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbjBARHT (ORCPT ); Wed, 1 Feb 2023 12:07:19 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D717113D77; Wed, 1 Feb 2023 09:07:16 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id 1D103CDFDF; Wed, 1 Feb 2023 17:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=z3ntu.xyz; s=z3ntu; t=1675271235; bh=oEhtXi5Cp2INDY3zPTIo52DB0I1+lAGCjPcLcIpaDFU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hlmabRtzYoS1PcRzF0Rb+tgv0qZCuNrfPMKRHpBMLEix5ztcgu6t6Je1Ss+os9QTw 0lxMpVc+QbkGAs61I4+V9fzsrPRuSLXIbhV0T/cbeX5qb7WFaRgRlGff1KVIA61/v5 u2/2Tb/ka6IJxApszJLb6Hk1GwlnXKzO5MKBe5SY= From: Luca Weiss Date: Wed, 01 Feb 2023 18:07:00 +0100 Subject: [PATCH v2 3/4] media: i2c: ov2685: Add controls from fwnode MIME-Version: 1.0 Message-Id: <20230129-ov2685-improvements-v2-3-210400f2b63e@z3ntu.xyz> References: <20230129-ov2685-improvements-v2-0-210400f2b63e@z3ntu.xyz> In-Reply-To: <20230129-ov2685-improvements-v2-0-210400f2b63e@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=1764; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=oEhtXi5Cp2INDY3zPTIo52DB0I1+lAGCjPcLcIpaDFU=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj2pxAEugegsWx8BDNcW3lxPTH2z+UdUfc568iKMji Zluxm/mJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY9qcQAAKCRBy2EO4nU3XVvW9D/ 91MFrxf/QOOEiv+4vFvK8Wf5vYcQof0Z5w6csy8eCFOzHeAnm15N292R4is+ezXc3veNWsWxhKkp2B erO6x1vXHVtmnLUPKarMU+USkID+984KH1QufKZU9pRtTJ0MPSKAmeBbzjTyROBf0EYbgV/NwyF6+y R1xYnEzA6RhLlheOX4TltTu19t7eixtfHZkTmwk62OCNZDQSdademjz3SwuIF1rJTFphNgvh0ErYoW tT0xDKsw0wABEOSAOPk8vHJl70pBcAjwFjcNGpbQbi3lAZ+X0FJhTa+acCtIV/PuUGSiMRL4OKinug JL3l899Vu2eqx7+DnBBzWkxwTvGejd9M0A2EgVPRaKdml8MbJm7K8M5XQ0/UaCyJtX4WD5w4DQyl+D F01WgDpJTyH/9yahUdIMWIIp/nSqGd6tMsf8AQ+i53qYZ+YAmXumIaRmTCbpeK1wJuvAbSxdjoj+Ql noTvPy+3sHuZ0/ZyuEtBuY5Jntd5YAr8hsjNuukhxZ11Inmg7zaOi7mba0dFlWpQ9hl7EPB23vc4fQ oczHsjjc0EuDzkd2lQjXHO3HLJzSQGkM43hBpcLRPlkW3Axyy0KLnQ0a8HCf7JbOB8QQu+HjTOH9Sz qPHuW2S4lZCb3qZpUdrRgLc+8Y2yAc0ZTyjSlYSw+DW03H6bxhubpJ/JmZ/w== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c index 844a91dbc8e5..e9e59a3ed7d5 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,13 +614,14 @@ 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; handler = &ov2685->ctrl_handler; mode = ov2685->cur_mode; - ret = v4l2_ctrl_handler_init(handler, 8); + ret = v4l2_ctrl_handler_init(handler, 10); if (ret) return ret; handler->lock = &ov2685->mutex; @@ -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 Wed Feb 1 17:07:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 649497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51C65C05027 for ; Wed, 1 Feb 2023 17:07:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231835AbjBARH4 (ORCPT ); Wed, 1 Feb 2023 12:07:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbjBARHu (ORCPT ); Wed, 1 Feb 2023 12:07:50 -0500 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D104676417; Wed, 1 Feb 2023 09:07:46 -0800 (PST) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id 53DA8CDFFE; Wed, 1 Feb 2023 17:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=z3ntu.xyz; s=z3ntu; t=1675271235; bh=UQT65ChprtN3gV14x3uUiuk8ir1KP67ljLyDOelPHJI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=IVWwbXGlTc3RyXWi1RTKNy877hXfKoupkBBxqYNnJtXhOEmmU2Wv9lPYcynUqAIHr V9IGqNIo8+ocrQB6pihtXsqKFr01y4r9hfdkKGeZ5Yhgiujvq0IfSJyD1Z0hi5aN42 7AtIH5geQj23cTA8EyCuDiXrnL98J1QJukqeo+Oc= From: Luca Weiss Date: Wed, 01 Feb 2023 18:07:01 +0100 Subject: [PATCH v2 4/4] media: i2c: ov2685: Add .get_selection() support MIME-Version: 1.0 Message-Id: <20230129-ov2685-improvements-v2-4-210400f2b63e@z3ntu.xyz> References: <20230129-ov2685-improvements-v2-0-210400f2b63e@z3ntu.xyz> In-Reply-To: <20230129-ov2685-improvements-v2-0-210400f2b63e@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=3378; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=UQT65ChprtN3gV14x3uUiuk8ir1KP67ljLyDOelPHJI=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBj2pxBJ4iicO0LkfxV1yugSDBcmc6zjaWTd1jPdLQG 0cnQbqyJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCY9qcQQAKCRBy2EO4nU3XVnHBD/ 9XcfG2wVAZuEO3H7+OSzyE00DbeQM54+siYcsvhCjsxdu+0U8APxYKvE6gL1Z79EjZwxNgCt+MUZk+ 4Y/3pe9Ann6jeeuD0Km3chLBHLYBJqjqnz8tfzPBgsIYwKftUsfvc3pNs1kfI1oWc3O6T17iw78+5T ly12MIxwfbqJBYYQ0ZKtPy9fahKish8AGAFVoqsQ2T/xTay97kSNiy4djpM+dhTxSffGEZCSSmt/0s yXqxW9DxNTY2fyiUfim03bwbvVU1kARXe7KNSyMtYXse6dn68ShJ0O55Pq0AOub6lpNG81r6yTtxmK DZvNepkeI75hawCnnyknKlFKC2c4PidmTjA1Hg0KayeElmRwj9hxZmzu1r1pABczWBtp2YL5LWS2BD gKDArWv8DPSgz2giEeCWZeoLEB4M9FmEJUiFSjb/bPc9kXSwNT5LRVZqciFYSWvFpy3bTxw21ax2F9 j3du5sAy8CJtxvsTftX0/1ulj9hJeAE6CwlQ/yEVcesT4LDAyWlaAqE8wHRnRzLnlVtWbbVV93ziQu HOdmO0Vk4Bv3wjXjKJEtQST/WdOszKubgnj96dgbl9c+9BsoNMtstGk6kv+o4smMGirYjqjIPgnlTw M/4h8T6bp7g7MuGVUjoALH9VgoMd0U+2X/PpybZI/98CuWXfpSlelUpDVPuw== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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. Reviewed-by: Jacopo Mondi Signed-off-by: Luca Weiss --- 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 e9e59a3ed7d5..52f66e7813be 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 = {