From patchwork Mon Nov 1 00:11:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595537 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9275C433EF for ; Mon, 1 Nov 2021 00:11:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C74F861051 for ; Mon, 1 Nov 2021 00:11:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230303AbhKAAOA (ORCPT ); Sun, 31 Oct 2021 20:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230222AbhKAAN7 (ORCPT ); Sun, 31 Oct 2021 20:13:59 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE749C061746 for ; Sun, 31 Oct 2021 17:11:26 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id t30so947209wra.10 for ; Sun, 31 Oct 2021 17:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/bxjYb6n9S0JXORpKNDGou8wcIBVx4S43SiHjxxXlMc=; b=KXCtC8ZcFEsxo5Jn7X2/wTaXsQFk+/1EG6VzVH0U6Snw0d7AApH26jA60Gwhzkxncu JXF+xJ9yasianYa27N8mrOacI/hKpBqrsyI/3VtkelkLwTcYpuz8NUwOqpSSvIPOCRoW 84uOcBqHJvynxdIyJ7NPvLAdT7YsDGNFBmxVyLrwrEzPgZAgTII0BwYxoHuFFlOiWoI+ L+p9VNAWNS3cfC4fl2mMsgUcUmYHFfpZvzHclVVvRzwOUDuNMg+yYcMQ0l4IosM4FPx4 B776MAGsz0Dzr0CqZMQdJ1HUYeDuM+4zFcq8ocx9LsbpG6Akj66DfhBrTqydzMXpnrJk 1tfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/bxjYb6n9S0JXORpKNDGou8wcIBVx4S43SiHjxxXlMc=; b=SkdfuOqfgtGYw5G0UAq785Osha7+gKm82Qm4+MBfPIBe9X/6ZwyF5sv8m03sKEPJ0B +g3/Q3YvrMthpeK9ft4oeViDgfrQImvruby5k8QT33eaAlaRXKwgk9qGkDB1CU1Z73Pq IXCz3d1BtK9shdCsYjsCgr3tvjBuGl2kpvzVu3e0xaORhNWXCJ+OlCcX3BJBUoD6ysSS QgHCHKhg3icO8pBPzH6KwG+RWusxGQALaU5sa5fc4qm1LDn88PmvXchCaKWz7xBapAOC l632iXPd9guI1pfrnm9asctlafcHOgtsSH+3vWyZCx9g5wy2ZzQF5IQwmn3P5Zm8gL83 A5oA== X-Gm-Message-State: AOAM532wtzv7uN0cF92qCLWV4m5HQZssH1lBTa0hKiuKKbnLqJdinkzu /telMVnFvLIfygqZVkRevuI= X-Google-Smtp-Source: ABdhPJxvtNneAlzvvVWRNR1BrXsEInIwqRhdj6zFIDLejp0Uu/ZXlRDeeR2ycwyCdZneXjzbznsxDA== X-Received: by 2002:a05:6000:2c6:: with SMTP id o6mr33059470wry.321.1635725485535; Sun, 31 Oct 2021 17:11:25 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:25 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 01/16] media: i2c: Add ACPI support to ov8865 Date: Mon, 1 Nov 2021 00:11:04 +0000 Message-Id: <20211101001119.46056-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ov8865 sensor is sometimes found on x86 platforms enumerated via ACPI. Add an ACPI match table to the driver so that it's probed on those platforms. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index ce50f3ea87b8..7626c8608f8f 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -2946,6 +2947,12 @@ static const struct dev_pm_ops ov8865_pm_ops = { SET_RUNTIME_PM_OPS(ov8865_suspend, ov8865_resume, NULL) }; +static const struct acpi_device_id ov8865_acpi_match[] = { + {"INT347A"}, + { } +}; +MODULE_DEVICE_TABLE(acpi, ov8865_acpi_match); + static const struct of_device_id ov8865_of_match[] = { { .compatible = "ovti,ov8865" }, { } @@ -2956,6 +2963,7 @@ static struct i2c_driver ov8865_driver = { .driver = { .name = "ov8865", .of_match_table = ov8865_of_match, + .acpi_match_table = ov8865_acpi_match, .pm = &ov8865_pm_ops, }, .probe_new = ov8865_probe, From patchwork Mon Nov 1 00:11:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595539 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BA70C4332F for ; Mon, 1 Nov 2021 00:11:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E271E60F58 for ; Mon, 1 Nov 2021 00:11:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbhKAAOB (ORCPT ); Sun, 31 Oct 2021 20:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbhKAAOA (ORCPT ); Sun, 31 Oct 2021 20:14:00 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCC47C061746 for ; Sun, 31 Oct 2021 17:11:27 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 133so3050535wme.0 for ; Sun, 31 Oct 2021 17:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PGdbJPgEvrFRTG4FV5SGOie0HxOPXnmoerqu6Z+UpHA=; b=GGMtZGD7m5vPaAJDLDKmgaqTxQkaVhu0Ld6OBL1XyPqCsgoOxhg/LAVfVL917Bcz2p X61Zb0UjzCFKF2uX+e8VAxTbY8ebUjrX3/A3Lc4SaEVZTdlwX8SvmFlCCjKyMbgbgAiR fwF/5QNqLHNEokAbUeR0Znqb2GmbAhg61f7Nh6rczG9ASLkAVRJEK+o7839VqIt96QQZ wqXwYLxNemmbVqeNTCBoU9Vhe0G2tYV8dxs97TbItlZ3rVfudB3j1aFUBVbh84oWD8kn hSXSVflOgteERiVYtJT98iNPx9y8aNLQ1kOd/Ry242MuVNiEn6aBXKTOLANx6RT69UXI gBng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PGdbJPgEvrFRTG4FV5SGOie0HxOPXnmoerqu6Z+UpHA=; b=f4Xx7onxT9h/68Z44zhfGcuOvlw00FpKj2Q7sXX/66zV1gxu19uJMZWagJzoNzVI35 aWvhPzyTMR1n0+HTt3SImLIySQIplhh0f+8cJRIuIwe8jLu0qjJTWHsyckwOsC7KdG3k rTYRZurx7E5T7Tp+rcRR+evSXpUabP657HyfFLr5Rq6LfZwy4gd+2N3xNUPFBkGMMjoi xoDugPQzFToQHo/W9i0ztXbbtgRswQFQj1ifFMr6+Sn0KV4JdTRS52IO6fgv46ndbu1a OfziuID+63W/a8ZLylkqlgR0iBdVA0uzGamgz1QBjp3GYsoHMHdmnM66EECeQLNCMx1J Krwg== X-Gm-Message-State: AOAM531ws0RHJG9RV0mY+hMgTvwqPbA0S0ROUVIQM4unZPQ86Xw89LGj lxUmu8v0r6kqzF4Bil+o8yU= X-Google-Smtp-Source: ABdhPJwrvS4FMmu1RPYtVHjRPceJGeVlT/zFX9ShW0zIXz142l6fz9TKLI52qiv5QNRCNVfvDVqn/g== X-Received: by 2002:a05:600c:211a:: with SMTP id u26mr163971wml.8.1635725486501; Sun, 31 Oct 2021 17:11:26 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:26 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 02/16] media: i2c: Fix incorrect value in comment Date: Mon, 1 Nov 2021 00:11:05 +0000 Message-Id: <20211101001119.46056-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The PLL configuration defined here sets 72MHz (which is correct), not 80MHz. Correct the comment. Reviewed-by: Paul Kocialkowski Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 7626c8608f8f..8e3f8a554452 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -713,7 +713,7 @@ static const struct ov8865_pll2_config ov8865_pll2_config_native = { /* * EXTCLK = 24 MHz * DAC_CLK = 360 MHz - * SCLK = 80 MHz + * SCLK = 72 MHz */ static const struct ov8865_pll2_config ov8865_pll2_config_binning = { From patchwork Mon Nov 1 00:11:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595541 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B2C7C433F5 for ; Mon, 1 Nov 2021 00:11:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD7EC60F58 for ; Mon, 1 Nov 2021 00:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230321AbhKAAOC (ORCPT ); Sun, 31 Oct 2021 20:14:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbhKAAOB (ORCPT ); Sun, 31 Oct 2021 20:14:01 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A2BC061714 for ; Sun, 31 Oct 2021 17:11:28 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id m22so25880066wrb.0 for ; Sun, 31 Oct 2021 17:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bYnE53sxt9EV2GvZuCKcpnnthXDrxGNArdfz3SURGLA=; b=RhAoK5E6EmqwM0sYGDN7oxU5Cm0PfjDISMBlP6V2kOmvvZ7OU7RI2SpPZVYjeiRxPE wapM72XDbpjPdraPtdL8Jc01QBzCauzxmjvcA6+BaG0mMhix6ZnTSAOmXbSI8bgZrcaU 8dpiqWB/63XSDWsAq3JEdBOonqudkjoNEyaPc5+LafORJwoLE0J82yfXdhjGib0IjouD Cp8njFMs8cRYlTCi8qad7+zEru9cMKcU8WylAaroAFDoS9byVQxXKbIU3UUk9eK7s2Fv CWP/9k2wjOLMJcYlXtpXriSkwN4K+Zo6Bx3o+yd12Iz6Cw+nawTC95jwCXd7A/CPjfnX YHOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bYnE53sxt9EV2GvZuCKcpnnthXDrxGNArdfz3SURGLA=; b=A8YIEyx7G/spt0Hkh75XwLmMmUYUNMw+cQCiHHatQVmVqk9mE9gVwlaxmaCtssz2iy uGdPZdD43+55ZagKGRUdJ/03Zgvu+QshNpbZYDaNVDKgSSlRETtBaVi0aWvpLueefSnC h3neiGI7F7pE0ukLg24dTbcNyT2YRTfQi82vwT6lqNsIqCL0GhBUJBhVd6M+7ZoLxZbV 3id9J4PymojWbq3wA0nPk0lZwA60cRVbbNhdws2FsjmZ1CZMcSAF9R5lKCnTGhnRRn0E PURGJIMnIwLQMu7MHEgPDFezBaR+lQeEyVB5JbcORQxlnevogECEhousrqf2ruUFAoMs i6YQ== X-Gm-Message-State: AOAM532Nchf37RBTdTjyC94WFAw4coFAwMVvdMJiMiN8zdZRFoEBXY7z KEXvHoQecwidkVzQsKMslEBUCMHRvds= X-Google-Smtp-Source: ABdhPJzF2UA9chRxGDy3k+ufPNfZkRfrkHsWkARTW9S4rg6UTtyl8PiRvY6Luw4q0PEuR+Uex2rJjw== X-Received: by 2002:a5d:63ca:: with SMTP id c10mr34764428wrw.407.1635725487504; Sun, 31 Oct 2021 17:11:27 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:27 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 03/16] media: i2c: Defer probe if not endpoint found Date: Mon, 1 Nov 2021 00:11:06 +0000 Message-Id: <20211101001119.46056-4-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ov8865 driver is one of those that can be connected to a CIO2 device by the cio2-bridge code. This means that the absence of an endpoint for this device is not necessarily fatal, as one might be built by the cio2-bridge when it probes. Return -EPROBE_DEFER if no endpoint is found rather than a fatal error. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 8e3f8a554452..9bc8d5d8199b 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2796,10 +2796,8 @@ static int ov8865_probe(struct i2c_client *client) /* Graph Endpoint */ handle = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL); - if (!handle) { - dev_err(dev, "unable to find endpoint node\n"); - return -EINVAL; - } + if (!handle) + return -EPROBE_DEFER; sensor->endpoint.bus_type = V4L2_MBUS_CSI2_DPHY; From patchwork Mon Nov 1 00:11:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595543 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BCFCC433EF for ; Mon, 1 Nov 2021 00:11:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 813FD604D2 for ; Mon, 1 Nov 2021 00:11:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbhKAAOD (ORCPT ); Sun, 31 Oct 2021 20:14:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbhKAAOC (ORCPT ); Sun, 31 Oct 2021 20:14:02 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A128C061714 for ; Sun, 31 Oct 2021 17:11:30 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id s13so18632451wrb.3 for ; Sun, 31 Oct 2021 17:11:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Skpn2R40ggtKv7nFehMq9AGAkuUhV60uGH+l9RMqV7Y=; b=GEyePCwYsRoDguxz2DRGemRMnk4ybHvm0QfthjRc+bLJhdwrlOyUjFyZXTG3iQu2+x FywchDf0nvk/qyzthI5l80m0YfH95R1rz6PzOQ7G5xsUJGw5bXz4nT5iRNYEap4x9wZf GBv0ITuCH/fqQ75vsDKxrDmtD/kaDU7nKOrC5t4tz/2eVGrYq138FISeTHduVSBHGQ6h xxGIwrkm29X91tqu2+omOcBpoQZWrwJtMqXPcRFXGK3GRhXrqAiFm8w47tGYLkea///u tudVUSNtrOBZJT6YLcTmEdPxRTc+VG809aZ7a8DynKfAaBlyYVKaM7XIg9fKxdcmzfcJ mKbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Skpn2R40ggtKv7nFehMq9AGAkuUhV60uGH+l9RMqV7Y=; b=6+o14bd+YDMJoyoYrI3DWl0LTa2zA3JA5o7BLV6Zfdc6XwQ4xW3G1l9us6SJkri6TY NIzV1hAWxHtwJxEIm47LbifIIVzX6TVyDlU+Hx8mwrQ26hr2oCR056tUBzQyDmc2KIRf UgDGeo6yUY6v/+bplJju24DqCvGiAVU67L7hmDw2FG2p9SlivkjK1aF76oDW/YYA93TR bZRIftxZYJ/mv4s3bbxxcNAI0yZjF+DjHsI2m0cjRa9/8Xg6r43lbjhFSyapryoSZo52 ufb4xJgQoN9pj9UwO2pCU7G/e54QH1k5W6ND7PYtoBqU4ZDJHnRm6xWDS+W2GZWNCV6e Df/g== X-Gm-Message-State: AOAM531VxsbNpf/qcJUiRbyvw/pVBuQNoNq6yLAJAUe2eOyK2YMquTWe ojoi2xvvz9U91FS52+LSO+K3mcjsvNM= X-Google-Smtp-Source: ABdhPJwQa3276N54BUbV1VVABSLKiX5KlAJhtsQC7qXi5nofHtEI4/8rW8zUevPAJK1zS8vDwcnmLA== X-Received: by 2002:a05:6000:1a86:: with SMTP id f6mr33718667wry.343.1635725488873; Sun, 31 Oct 2021 17:11:28 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:28 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 04/16] media: i2c: Support 19.2MHz input clock in ov8865 Date: Mon, 1 Nov 2021 00:11:07 +0000 Message-Id: <20211101001119.46056-5-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ov8865 driver as written expects a 24MHz input clock, but the sensor is sometimes found on x86 platforms with a 19.2MHz input clock supplied. Add a set of PLL configurations to the driver to support that rate too. As ACPI doesn't auto-configure the clock rate, check for a clock-frequency during probe and set that rate if one is found. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 186 +++++++++++++++++++++++++++---------- 1 file changed, 135 insertions(+), 51 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 9bc8d5d8199b..4ddc1b277cc0 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -21,10 +21,6 @@ #include #include -/* Clock rate */ - -#define OV8865_EXTCLK_RATE 24000000 - /* Register definitions */ /* System */ @@ -567,6 +563,25 @@ struct ov8865_sclk_config { unsigned int sclk_div; }; +struct ov8865_pll_configs { + const struct ov8865_pll1_config *pll1_config; + const struct ov8865_pll2_config *pll2_config_native; + const struct ov8865_pll2_config *pll2_config_binning; +}; + +/* Clock rate */ + +enum extclk_rate { + OV8865_19_2_MHZ, + OV8865_24_MHZ, + OV8865_NUM_SUPPORTED_RATES +}; + +static const unsigned long supported_extclk_rates[] = { + [OV8865_19_2_MHZ] = 19200000, + [OV8865_24_MHZ] = 24000000, +}; + /* * General formulas for (array-centered) mode calculation: * - photo_array_width = 3296 @@ -635,9 +650,7 @@ struct ov8865_mode { struct v4l2_fract frame_interval; - const struct ov8865_pll1_config *pll1_config; - const struct ov8865_pll2_config *pll2_config; - const struct ov8865_sclk_config *sclk_config; + bool pll2_binning; const struct ov8865_register_value *register_values; unsigned int register_values_count; @@ -665,6 +678,9 @@ struct ov8865_sensor { struct regulator *avdd; struct regulator *dvdd; struct regulator *dovdd; + + unsigned long extclk_rate; + const struct ov8865_pll_configs *pll_configs; struct clk *extclk; struct v4l2_fwnode_endpoint endpoint; @@ -680,43 +696,70 @@ struct ov8865_sensor { /* Static definitions */ /* - * EXTCLK = 24 MHz * PHY_SCLK = 720 MHz * MIPI_PCLK = 90 MHz */ -static const struct ov8865_pll1_config ov8865_pll1_config_native = { - .pll_pre_div_half = 1, - .pll_pre_div = 0, - .pll_mul = 30, - .m_div = 1, - .mipi_div = 3, - .pclk_div = 1, - .sys_pre_div = 1, - .sys_div = 2, + +static const struct ov8865_pll1_config ov8865_pll1_config_native_19_2mhz = { + .pll_pre_div_half = 1, + .pll_pre_div = 2, + .pll_mul = 75, + .m_div = 1, + .mipi_div = 3, + .pclk_div = 1, + .sys_pre_div = 1, + .sys_div = 2, +}; + +static const struct ov8865_pll1_config ov8865_pll1_config_native_24mhz = { + .pll_pre_div_half = 1, + .pll_pre_div = 0, + .pll_mul = 30, + .m_div = 1, + .mipi_div = 3, + .pclk_div = 1, + .sys_pre_div = 1, + .sys_div = 2, }; /* - * EXTCLK = 24 MHz * DAC_CLK = 360 MHz * SCLK = 144 MHz */ -static const struct ov8865_pll2_config ov8865_pll2_config_native = { - .pll_pre_div_half = 1, - .pll_pre_div = 0, - .pll_mul = 30, - .dac_div = 2, - .sys_pre_div = 5, - .sys_div = 0, +static const struct ov8865_pll2_config ov8865_pll2_config_native_19_2mhz = { + .pll_pre_div_half = 1, + .pll_pre_div = 5, + .pll_mul = 75, + .dac_div = 1, + .sys_pre_div = 1, + .sys_div = 3, +}; + +static const struct ov8865_pll2_config ov8865_pll2_config_native_24mhz = { + .pll_pre_div_half = 1, + .pll_pre_div = 0, + .pll_mul = 30, + .dac_div = 2, + .sys_pre_div = 5, + .sys_div = 0, }; /* - * EXTCLK = 24 MHz * DAC_CLK = 360 MHz * SCLK = 72 MHz */ -static const struct ov8865_pll2_config ov8865_pll2_config_binning = { +static const struct ov8865_pll2_config ov8865_pll2_config_binning_19_2mhz = { + .pll_pre_div_half = 1, + .pll_pre_div = 2, + .pll_mul = 75, + .dac_div = 2, + .sys_pre_div = 10, + .sys_div = 0, +}; + +static const struct ov8865_pll2_config ov8865_pll2_config_binning_24mhz = { .pll_pre_div_half = 1, .pll_pre_div = 0, .pll_mul = 30, @@ -725,6 +768,23 @@ static const struct ov8865_pll2_config ov8865_pll2_config_binning = { .sys_div = 0, }; +static struct ov8865_pll_configs ov8865_pll_configs_19_2mhz = { + .pll1_config = &ov8865_pll1_config_native_19_2mhz, + .pll2_config_native = &ov8865_pll2_config_native_19_2mhz, + .pll2_config_binning = &ov8865_pll2_config_binning_19_2mhz, +}; + +static struct ov8865_pll_configs ov8865_pll_configs_24mhz = { + .pll1_config = &ov8865_pll1_config_native_24mhz, + .pll2_config_native = &ov8865_pll2_config_native_24mhz, + .pll2_config_binning = &ov8865_pll2_config_binning_24mhz, +}; + +static const struct ov8865_pll_configs *ov8865_pll_configs[] = { + &ov8865_pll_configs_19_2mhz, + &ov8865_pll_configs_24mhz, +}; + static const struct ov8865_sclk_config ov8865_sclk_config_native = { .sys_sel = 1, .sclk_sel = 0, @@ -934,9 +994,7 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 }, /* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, - .sclk_config = &ov8865_sclk_config_native, + .pll2_binning = false, /* Registers */ .register_values = ov8865_register_values_native, @@ -990,9 +1048,7 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 }, /* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, - .sclk_config = &ov8865_sclk_config_native, + .pll2_binning = false, /* Registers */ .register_values = ov8865_register_values_native, @@ -1050,9 +1106,7 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 }, /* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, - .sclk_config = &ov8865_sclk_config_native, + .pll2_binning = true, /* Registers */ .register_values = ov8865_register_values_binning, @@ -1116,9 +1170,7 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 90 }, /* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, - .sclk_config = &ov8865_sclk_config_native, + .pll2_binning = true, /* Registers */ .register_values = ov8865_register_values_binning, @@ -1513,12 +1565,11 @@ static int ov8865_isp_configure(struct ov8865_sensor *sensor) static unsigned long ov8865_mode_pll1_rate(struct ov8865_sensor *sensor, const struct ov8865_mode *mode) { - const struct ov8865_pll1_config *config = mode->pll1_config; - unsigned long extclk_rate; + const struct ov8865_pll1_config *config; unsigned long pll1_rate; - extclk_rate = clk_get_rate(sensor->extclk); - pll1_rate = extclk_rate * config->pll_mul / config->pll_pre_div_half; + config = sensor->pll_configs->pll1_config; + pll1_rate = sensor->extclk_rate * config->pll_mul / config->pll_pre_div_half; switch (config->pll_pre_div) { case 0: @@ -1552,10 +1603,12 @@ static int ov8865_mode_pll1_configure(struct ov8865_sensor *sensor, const struct ov8865_mode *mode, u32 mbus_code) { - const struct ov8865_pll1_config *config = mode->pll1_config; + const struct ov8865_pll1_config *config; u8 value; int ret; + config = sensor->pll_configs->pll1_config; + switch (mbus_code) { case MEDIA_BUS_FMT_SBGGR10_1X10: value = OV8865_MIPI_BIT_SEL(10); @@ -1622,9 +1675,12 @@ static int ov8865_mode_pll1_configure(struct ov8865_sensor *sensor, static int ov8865_mode_pll2_configure(struct ov8865_sensor *sensor, const struct ov8865_mode *mode) { - const struct ov8865_pll2_config *config = mode->pll2_config; + const struct ov8865_pll2_config *config; int ret; + config = mode->pll2_binning ? sensor->pll_configs->pll2_config_binning : + sensor->pll_configs->pll2_config_native; + ret = ov8865_write(sensor, OV8865_PLL_CTRL12_REG, OV8865_PLL_CTRL12_PRE_DIV_HALF(config->pll_pre_div_half) | OV8865_PLL_CTRL12_DAC_DIV(config->dac_div)); @@ -1658,7 +1714,7 @@ static int ov8865_mode_pll2_configure(struct ov8865_sensor *sensor, static int ov8865_mode_sclk_configure(struct ov8865_sensor *sensor, const struct ov8865_mode *mode) { - const struct ov8865_sclk_config *config = mode->sclk_config; + const struct ov8865_sclk_config *config = &ov8865_sclk_config_native; int ret; ret = ov8865_write(sensor, OV8865_CLK_SEL0_REG, @@ -2053,9 +2109,11 @@ static int ov8865_mode_configure(struct ov8865_sensor *sensor, static unsigned long ov8865_mode_mipi_clk_rate(struct ov8865_sensor *sensor, const struct ov8865_mode *mode) { - const struct ov8865_pll1_config *config = mode->pll1_config; + const struct ov8865_pll1_config *config; unsigned long pll1_rate; + config = sensor->pll_configs->pll1_config; + pll1_rate = ov8865_mode_pll1_rate(sensor, mode); return pll1_rate / config->m_div / 2; @@ -2783,7 +2841,8 @@ static int ov8865_probe(struct i2c_client *client) struct ov8865_sensor *sensor; struct v4l2_subdev *subdev; struct media_pad *pad; - unsigned long rate; + unsigned int rate; + unsigned int i; int ret; sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); @@ -2858,13 +2917,38 @@ static int ov8865_probe(struct i2c_client *client) goto error_endpoint; } - rate = clk_get_rate(sensor->extclk); - if (rate != OV8865_EXTCLK_RATE) { - dev_err(dev, "clock rate %lu Hz is unsupported\n", rate); + /* + * We could have either a 24MHz or 19.2MHz clock rate. Check for a + * clock-frequency property and if found, set that rate. This should + * cover the ACPI case. If the system uses devicetree then the + * configured rate should already be set, so we'll have to check it. + */ + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &rate); + if (!ret) { + ret = clk_set_rate(sensor->extclk, rate); + if (ret) { + dev_err(dev, "failed to set clock rate\n"); + return ret; + } + } + + sensor->extclk_rate = clk_get_rate(sensor->extclk); + + for (i = 0; i < ARRAY_SIZE(supported_extclk_rates); i++) { + if (sensor->extclk_rate == supported_extclk_rates[i]) + break; + } + + if (i == ARRAY_SIZE(supported_extclk_rates)) { + dev_err(dev, "clock rate %lu Hz is unsupported\n", + sensor->extclk_rate); ret = -EINVAL; goto error_endpoint; } + sensor->pll_configs = ov8865_pll_configs[i]; + /* Subdev, entity and pad */ subdev = &sensor->subdev; From patchwork Mon Nov 1 00:11:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595545 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 903E0C433FE for ; Mon, 1 Nov 2021 00:11:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77D04604D2 for ; Mon, 1 Nov 2021 00:11:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbhKAAOE (ORCPT ); Sun, 31 Oct 2021 20:14:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbhKAAOD (ORCPT ); Sun, 31 Oct 2021 20:14:03 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44FD0C061714 for ; Sun, 31 Oct 2021 17:11:31 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id r8so12963408wra.7 for ; Sun, 31 Oct 2021 17:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xgOUjYYiQc+X4eaADEk4n8rT6/67K8ZQHcBHPRdDd+I=; b=l1cZibRAtkNqTexW2HBkxrVKcesRjY93pdsHJAqPx7JeGG257jYCK88GlvR49i2hJ8 7qzlqguihKNzkCyLomtdieWjBei1O/bmseSuWBpGad+oGRuhBh8MMSFB8qEy0DIxNlbM jSfufSxGwl4MSivuRJDEp2FifiZTxuQU7UDj6ICbarh98u2o99GR5M6WUEcDPylrRidk Wy5a878X7E5XWvsFnAWDXjwlgsuPJHwjZfSDTPzroNfT91ren0WfDAC3ed6whob1WOOb 5GmocuEmzp2gZEZ5+i9Eq+LUEV7dX/SvQHhxV9m0z9DRn+/B5/57qGGLAoY7tYgC7wbu tWSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xgOUjYYiQc+X4eaADEk4n8rT6/67K8ZQHcBHPRdDd+I=; b=LGj57n9riTmabXYu/avETLxQWlF+rRCbplYKjRRDbO1eb9OHOIKByBGEMX43DKkYwT 1NR7EPd4EuPNkEOFq0JTlY5u6RnjXw/g9VT2x9Ca5ViQLC4CcN0uy1iRNC/NrI5ihEHu nelcT89ywAtp2rYV/MF1t0H8SFylvCrHkjbCMecJQ4BWftYFzyYHWLa/6WP4rDz1JCT7 o2CqOourPvyJuewAq9fF7iw5nWcZJn6e51NoTlqMtghbaWQy+FFgCGgoXy35qov7bDUe CrPvX680/7r/33psMCSmIaMVpJCKIznxzcxaPy6BGc09m4cpQ+HD7Gt1GwW04SuNHIXK FOLQ== X-Gm-Message-State: AOAM531lI5Y34rzTJ+ONHLSCufsGrif/K16EyHN5Fs8Jom2gGTpM8n92 7jmsBnaLgj+/LFZqsJeSCVA= X-Google-Smtp-Source: ABdhPJzBA5aD+xinKDW9BMPUBwwtGAJ0I6ZwnvDoXt6kaPPvwjqFMEesZ74fpWyDDU45C+O38n1I4A== X-Received: by 2002:a5d:5850:: with SMTP id i16mr7653816wrf.410.1635725489873; Sun, 31 Oct 2021 17:11:29 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:29 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 05/16] media: i2c: Add .get_selection() support to ov8865 Date: Mon, 1 Nov 2021 00:11:08 +0000 Message-Id: <20211101001119.46056-6-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ov8865 driver's v4l2_subdev_pad_ops currently does not include .get_selection() - add support for that callback. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 4ddc1b277cc0..0f2776390a8e 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -450,6 +450,15 @@ #define OV8865_PRE_CTRL0_PATTERN_COLOR_SQUARES 2 #define OV8865_PRE_CTRL0_PATTERN_BLACK 3 +/* Pixel Array */ + +#define OV8865_NATIVE_WIDTH 3296 +#define OV8865_NATIVE_HEIGHT 2528 +#define OV8865_ACTIVE_START_TOP 32 +#define OV8865_ACTIVE_START_LEFT 80 +#define OV8865_ACTIVE_WIDTH 3264 +#define OV8865_ACTIVE_HEIGHT 2448 + /* Macros */ #define ov8865_subdev_sensor(s) \ @@ -2756,12 +2765,67 @@ static int ov8865_enum_frame_interval(struct v4l2_subdev *subdev, return 0; } +static void +__ov8865_get_pad_crop(struct ov8865_sensor *sensor, + struct v4l2_subdev_state *state, unsigned int pad, + enum v4l2_subdev_format_whence which, struct v4l2_rect *r) +{ + const struct ov8865_mode *mode = sensor->state.mode; + + switch (which) { + case V4L2_SUBDEV_FORMAT_TRY: + *r = *v4l2_subdev_get_try_crop(&sensor->subdev, state, pad); + break; + case V4L2_SUBDEV_FORMAT_ACTIVE: + r->height = mode->output_size_y; + r->width = mode->output_size_x; + r->top = (OV8865_NATIVE_HEIGHT - mode->output_size_y) / 2; + r->left = (OV8865_NATIVE_WIDTH - mode->output_size_x) / 2; + break; + } +} + +static int ov8865_get_selection(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, + struct v4l2_subdev_selection *sel) +{ + struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); + + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + mutex_lock(&sensor->mutex); + __ov8865_get_pad_crop(sensor, state, sel->pad, + sel->which, &sel->r); + mutex_unlock(&sensor->mutex); + break; + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = OV8865_NATIVE_WIDTH; + sel->r.height = OV8865_NATIVE_HEIGHT; + break; + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_CROP_DEFAULT: + sel->r.top = OV8865_ACTIVE_START_TOP; + sel->r.left = OV8865_ACTIVE_START_LEFT; + sel->r.width = OV8865_ACTIVE_WIDTH; + sel->r.height = OV8865_ACTIVE_HEIGHT; + break; + default: + return -EINVAL; + } + + return 0; +} + static const struct v4l2_subdev_pad_ops ov8865_subdev_pad_ops = { .enum_mbus_code = ov8865_enum_mbus_code, .get_fmt = ov8865_get_fmt, .set_fmt = ov8865_set_fmt, .enum_frame_size = ov8865_enum_frame_size, .enum_frame_interval = ov8865_enum_frame_interval, + .get_selection = ov8865_get_selection, + .set_selection = ov8865_get_selection, }; static const struct v4l2_subdev_ops ov8865_subdev_ops = { From patchwork Mon Nov 1 00:11:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595547 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D34DC433F5 for ; Mon, 1 Nov 2021 00:11:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E876604D2 for ; Mon, 1 Nov 2021 00:11:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230395AbhKAAOF (ORCPT ); Sun, 31 Oct 2021 20:14:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230346AbhKAAOE (ORCPT ); Sun, 31 Oct 2021 20:14:04 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B490C061714 for ; Sun, 31 Oct 2021 17:11:32 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id b12so21334538wrh.4 for ; Sun, 31 Oct 2021 17:11:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/akcoC6jSXq6p1wh0JzIQGx3c3Ax4JMABtbei41wxdw=; b=pSHsLALmo1AblZAW7GlUaKQtYDznSSSfU/hOw1JZXM49GyGrYP+DlB9h/egTzQ5BSx fhceyM+z+EXdphxeGU3w9mWbnqB3ZvuD57t35YAPj3iWhwKfGWXCQQS2pTtT6Jt0TvOr jaOkMDVCfIcRzCvKXD1idH9iEv0moYPxxRHu1O4vtoINLHz8qwrdvjDUIuGburQ1pjJQ ozzwi95f3HD4DSKWlcdkCTdngG1s9s/XezR8t1NeDRGZ5IiCrsBujaGWBEGwkQ2ycXpX bAilusyXZwvmWXSK8z2wpmEXqBjMeRs2d9H/Va9AJlILovZDkTrgT6ECzOj8eORUO7xs cXHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/akcoC6jSXq6p1wh0JzIQGx3c3Ax4JMABtbei41wxdw=; b=WLsb1AnMmkabR8gW8dmYsmdK8HSpnQhmJertjiQSooExDotjN6patvdXp/stnxCGJ4 LLhxqYsRw4qlWD7kUeeEoBoqul+frSz4by84sa6gI4IP6gygMgzP/mhIuXzQLvrMs749 kNjWCasXrvnkYWwZojogev+V1BJInLVNk3AJxVDHB0y0kV5cicHG060CB689gxgMVwbw 7B844XsJqVmbxeCnAyxT7PDW7i1LfxFA0NLLMyyPaFwutohca8AJr7xSYS96xInLTWpr cHXefXTv5SBpYHoLSpinQDmgiuNb7lrYju9oQdfMcZFEzfMfzgpa6YoUUndwT2PJ5wzJ 9YSg== X-Gm-Message-State: AOAM532NuaIJojj+Pzvnx5bynwtk+WLwzAKfKarZVRAOMWTK9Nugl4BH kMRt+wxHPQBj3upc+ux3WjU= X-Google-Smtp-Source: ABdhPJybDC7439Jgm4Yn0lve+IILKY72ZQgblhMCnG9Oc5TgE+XhQFQwTt9SnypPWGfFuIceumX+QA== X-Received: by 2002:a5d:6481:: with SMTP id o1mr33705381wri.60.1635725490842; Sun, 31 Oct 2021 17:11:30 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:30 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 06/16] media: i2c: Switch control to V4L2_CID_ANALOGUE_GAIN Date: Mon, 1 Nov 2021 00:11:09 +0000 Message-Id: <20211101001119.46056-7-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The V4L2_CID_GAIN control for this driver configures registers that the datasheet specifies as analogue gain. Switch the control's ID to V4L2_CID_ANALOGUE_GAIN. Reviewed-by: Paul Kocialkowski Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 0f2776390a8e..a832938c33b6 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2150,7 +2150,7 @@ static int ov8865_exposure_configure(struct ov8865_sensor *sensor, u32 exposure) /* Gain */ -static int ov8865_gain_configure(struct ov8865_sensor *sensor, u32 gain) +static int ov8865_analog_gain_configure(struct ov8865_sensor *sensor, u32 gain) { int ret; @@ -2460,8 +2460,8 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl) if (ret) return ret; break; - case V4L2_CID_GAIN: - ret = ov8865_gain_configure(sensor, ctrl->val); + case V4L2_CID_ANALOGUE_GAIN: + ret = ov8865_analog_gain_configure(sensor, ctrl->val); if (ret) return ret; break; @@ -2506,7 +2506,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) /* Gain */ - v4l2_ctrl_new_std(handler, ops, V4L2_CID_GAIN, 128, 8191, 128, 128); + v4l2_ctrl_new_std(handler, ops, V4L2_CID_ANALOGUE_GAIN, 128, 8191, 128, + 128); /* White Balance */ From patchwork Mon Nov 1 00:11:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595549 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C363C433EF for ; Mon, 1 Nov 2021 00:11:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1879361077 for ; Mon, 1 Nov 2021 00:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbhKAAOG (ORCPT ); Sun, 31 Oct 2021 20:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbhKAAOF (ORCPT ); Sun, 31 Oct 2021 20:14:05 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C3DBC061714 for ; Sun, 31 Oct 2021 17:11:33 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id t30so947354wra.10 for ; Sun, 31 Oct 2021 17:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dMlcJbJVuEU779Zc7PeprkSxRDWo4sAfwzQpoKqyDy0=; b=kiYBmckvNYT/8/u320/xQPiaSs7OB/KN5vUzfxDQS7etLUl5ai/JPsiK/ZpySXDbLs Fs1svMTYLjExyA+6CpivMBryh45pO3Ondvb2tHHx/ca5kdaENYjc76Sn20C+wUtuVREQ //zYvq13Z80bVZpDNbygBj51R5VhXgyaEKi6m0XBdtGaVumpR2T3d0AqNYOg1i8tnBhM uoe05zfEhUGTJQ8ZbxvJsJ1QFs5g2obnXHz66KPCtp7ECh5ubmwEGqsMnGxy4Rx8s4iQ xjxLjzIPuiy5G9A2Sfqq/FXDvq6WKL0TWto/Aan8gh8FDvK+q6z55p3mqlkA2HfQrl6r cmvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dMlcJbJVuEU779Zc7PeprkSxRDWo4sAfwzQpoKqyDy0=; b=o1eYULI8OO/KE+/KyE9lfY2J7JHQDXgB4TiI9WBVm45dunRltTDEGIk3gtelCt6m/G 9iVgN6vs3VQ7lwKmVzrxAMxx0SU33ubHq1hZFAirIkjIvqKTQXu1y/rJU3/9AWmJff3/ SGSciPvj5zv6WaRciGLwwHMWp/uiFm4Cz9EIsihySbs7keAPDpcqEZFMctl0TRZuLsAD LzwTNPcMP/T2XEu0iZPbAon5d6wG7mIt/wRpUG+tfNwMRAUH346ZU4elHtbv2BoQ70J7 mpu1x5jvNz6f+OFZR9XQSb/+QqUuprbRTkWgSXttUBUpXovATuI4Pk0U4a1stbf0e2aE ZAzg== X-Gm-Message-State: AOAM532O1WUT1iDCQypt5mzUa+cWF64eg8hghQ2QM7S9yT0I5XQDjmDn fyk7qS8PX/zVpucxxE5QbdU= X-Google-Smtp-Source: ABdhPJxQm/Z+yQbFYcBOV2vXww84U+zRLZ4Qlr/tVj6QPno7/u0fA8VHrskV5JXdayXhp6ndVA1k+w== X-Received: by 2002:a05:6000:18ce:: with SMTP id w14mr33758343wrq.230.1635725491797; Sun, 31 Oct 2021 17:11:31 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:31 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 07/16] media: i2c: Add vblank control to ov8865 Date: Mon, 1 Nov 2021 00:11:10 +0000 Message-Id: <20211101001119.46056-8-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a V4L2_CID_VBLANK control to the ov8865 driver. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index a832938c33b6..f741c0713ca4 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -183,6 +183,8 @@ #define OV8865_VTS_H(v) (((v) & GENMASK(11, 8)) >> 8) #define OV8865_VTS_L_REG 0x380f #define OV8865_VTS_L(v) ((v) & GENMASK(7, 0)) +#define OV8865_TIMING_MAX_VTS 0xffff +#define OV8865_TIMING_MIN_VTS 0x04 #define OV8865_OFFSET_X_H_REG 0x3810 #define OV8865_OFFSET_X_H(v) (((v) & GENMASK(15, 8)) >> 8) #define OV8865_OFFSET_X_L_REG 0x3811 @@ -675,6 +677,7 @@ struct ov8865_state { struct ov8865_ctrls { struct v4l2_ctrl *link_freq; struct v4l2_ctrl *pixel_rate; + struct v4l2_ctrl *vblank; struct v4l2_ctrl_handler handler; }; @@ -2225,6 +2228,20 @@ static int ov8865_test_pattern_configure(struct ov8865_sensor *sensor, ov8865_test_pattern_bits[index]); } +/* Blanking */ + +static int ov8865_vts_configure(struct ov8865_sensor *sensor, u32 vblank) +{ + u16 vts = sensor->state.mode->output_size_y + vblank; + int ret; + + ret = ov8865_write(sensor, OV8865_VTS_H_REG, OV8865_VTS_H(vts)); + if (ret) + return ret; + + return ov8865_write(sensor, OV8865_VTS_L_REG, OV8865_VTS_L(vts)); +} + /* State */ static int ov8865_state_mipi_configure(struct ov8865_sensor *sensor, @@ -2476,6 +2493,8 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_TEST_PATTERN: index = (unsigned int)ctrl->val; return ov8865_test_pattern_configure(sensor, index); + case V4L2_CID_VBLANK: + return ov8865_vts_configure(sensor, ctrl->val); default: return -EINVAL; } @@ -2492,6 +2511,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) struct ov8865_ctrls *ctrls = &sensor->ctrls; struct v4l2_ctrl_handler *handler = &ctrls->handler; const struct v4l2_ctrl_ops *ops = &ov8865_ctrl_ops; + const struct ov8865_mode *mode = sensor->state.mode; + unsigned int vblank_max, vblank_def; int ret; v4l2_ctrl_handler_init(handler, 32); @@ -2528,6 +2549,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) ARRAY_SIZE(ov8865_test_pattern_menu) - 1, 0, 0, ov8865_test_pattern_menu); + /* Blanking */ + vblank_max = OV8865_TIMING_MAX_VTS - mode->output_size_y; + vblank_def = mode->vts - mode->output_size_y; + ctrls->vblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_VBLANK, + OV8865_TIMING_MIN_VTS, vblank_max, 1, + vblank_def); + /* MIPI CSI-2 */ ctrls->link_freq = @@ -2708,6 +2736,10 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev, sensor->state.mbus_code != mbus_code) ret = ov8865_state_configure(sensor, mode, mbus_code); + __v4l2_ctrl_modify_range(sensor->ctrls.vblank, OV8865_TIMING_MIN_VTS, + OV8865_TIMING_MAX_VTS - mode->output_size_y, + 1, mode->vts - mode->output_size_y); + complete: mutex_unlock(&sensor->mutex); @@ -3035,6 +3067,8 @@ static int ov8865_probe(struct i2c_client *client) /* Sensor */ + sensor->state.mode = &ov8865_modes[0]; + ret = ov8865_ctrls_init(sensor); if (ret) goto error_mutex; From patchwork Mon Nov 1 00:11:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595551 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 033EEC433FE for ; Mon, 1 Nov 2021 00:11:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAF8360F58 for ; Mon, 1 Nov 2021 00:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbhKAAOH (ORCPT ); Sun, 31 Oct 2021 20:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230396AbhKAAOG (ORCPT ); Sun, 31 Oct 2021 20:14:06 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02902C061714 for ; Sun, 31 Oct 2021 17:11:34 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id d13so25768230wrf.11 for ; Sun, 31 Oct 2021 17:11:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZcCZdZv2McYGN4HECCxbzglyXFjRyQVs2bX/Y1cX2WI=; b=bLHhdugPb1jOCJ5mC3CtB8S3LFZeDahgeyhT49sV+D0mmhp9YqTqPhCnzkLiPMciFH CRNTRwIna6Nc6lzJnVqWDSyZVu06gjhVdmF+4Nt3YJG+9HpJUHNxkNdF+SOAB6l/9JQE 8Xa+6U3tLuGcmWPpzi6jcK7slmR7MYmQB/z+54O1G8TDDKE/os+9Lz1yw88eV3TYZFvN QtJhaKJgANmsH+6gmZkuPTmGexMxjoU3NAFw9CRIskEFcH2BtgEo65UleoIB1H7iwS35 wco10x+H3/eEC0lBMnp4iEkA0YMCD4+RtXZq+AMNKKTfPOnWo2OocXQqR4QF9q3IvPvf TSGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZcCZdZv2McYGN4HECCxbzglyXFjRyQVs2bX/Y1cX2WI=; b=B24vu80IhYPQa/WpD2M8jeZYji3lMzz6zB5wD/3qR21v/OKvj2LYv7s2SF2CfCf9UZ qc3RtP2OFaDfOALm1aKLLZB482vNA2ebXXSV5WY58husCqxWVO05SYWzSrtuzwl/+rgl 1EV7q6ooyD2uWYbWZEmx7xGFVNq0aDjYIPDK6qa14zd0slfUcpWQbti/1MRC+g8gcFPw SgoY4rQIrbc9fH+ihu+KGMHhM92lENS4z2LFvhxCf6JPG8g0r9wT6UuBapIyDTZh4bw7 qMpXUCA4divC8YOXFTRzTF9l40PvjMUdMwg4u2jmhhhF3Pfzd87VYcpx/9ADJcaRNjTU E7LQ== X-Gm-Message-State: AOAM531e5IUlUGRgztAD31wbxrSWHK9mQZI290H+hVkhfYCL0PNgpDyo OCZkUrXUCRi8ueiqRh7k5E8= X-Google-Smtp-Source: ABdhPJwPFtvrDSuYCdn8RxzwjXpUVzbQRt3scfDctqoo1U8ob8MnaPTZhu0SHFLdlR3AXcXC8yogSQ== X-Received: by 2002:a5d:6e8c:: with SMTP id k12mr32523080wrz.401.1635725492694; Sun, 31 Oct 2021 17:11:32 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:32 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 08/16] media: i2c: Add hblank control to ov8865 Date: Mon, 1 Nov 2021 00:11:11 +0000 Message-Id: <20211101001119.46056-9-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a V4L2_CID_HBLANK control to the ov8865 driver. This is read only with timing control intended to be done via vblanking alone. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index f741c0713ca4..4b18cc80f985 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -677,6 +677,7 @@ struct ov8865_state { struct ov8865_ctrls { struct v4l2_ctrl *link_freq; struct v4l2_ctrl *pixel_rate; + struct v4l2_ctrl *hblank; struct v4l2_ctrl *vblank; struct v4l2_ctrl_handler handler; @@ -2513,6 +2514,7 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) const struct v4l2_ctrl_ops *ops = &ov8865_ctrl_ops; const struct ov8865_mode *mode = sensor->state.mode; unsigned int vblank_max, vblank_def; + unsigned int hblank; int ret; v4l2_ctrl_handler_init(handler, 32); @@ -2550,6 +2552,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu); /* Blanking */ + hblank = mode->hts - mode->output_size_x; + ctrls->hblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_HBLANK, hblank, + hblank, 1, hblank); + + if (ctrls->hblank) + ctrls->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; + vblank_max = OV8865_TIMING_MAX_VTS - mode->output_size_y; vblank_def = mode->vts - mode->output_size_y; ctrls->vblank = v4l2_ctrl_new_std(handler, ops, V4L2_CID_VBLANK, @@ -2696,6 +2705,7 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev, struct v4l2_mbus_framefmt *mbus_format = &format->format; const struct ov8865_mode *mode; u32 mbus_code = 0; + unsigned int hblank; unsigned int index; int ret = 0; @@ -2740,6 +2750,10 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev, OV8865_TIMING_MAX_VTS - mode->output_size_y, 1, mode->vts - mode->output_size_y); + hblank = mode->hts - mode->output_size_x; + __v4l2_ctrl_modify_range(sensor->ctrls.hblank, hblank, hblank, 1, + hblank); + complete: mutex_unlock(&sensor->mutex); From patchwork Mon Nov 1 00:11:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595553 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F35A1C433F5 for ; Mon, 1 Nov 2021 00:11:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAB6C60F58 for ; Mon, 1 Nov 2021 00:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230417AbhKAAOI (ORCPT ); Sun, 31 Oct 2021 20:14:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230407AbhKAAOH (ORCPT ); Sun, 31 Oct 2021 20:14:07 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCB79C061714 for ; Sun, 31 Oct 2021 17:11:34 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id b12so21334662wrh.4 for ; Sun, 31 Oct 2021 17:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=esHTjxcAIpT5/NpHLc1ZVkLS0+NllgitPYn2F2gHVFg=; b=IB0VhCX1qVVKYyk+Asa6dcl+O4LTRKba/0lO/LI7wuu8/Xd6ufTG1ZIMgHl5gEjd// eYP4e8AAWPjZ1EVR1ZLp/wKgIFhYcbnJxnckB6T8DJ2qN9AKCci3cyQRz/f5dW3G2kuH SZTtOiwxy86ztMtsqv9iy1dhNMD4CGs/lkdGWSnHUb1tmR9uWg7Yjhb4rsi7d9/Lq2n7 N9boNbRTA56zRBa5y5PLAOZnOFL3hLykHlE8i9hEamus6/8uKdVMVVM5ADXL10bQeysQ /F+mRmsSh1UWuVCjfLbmqxoZe5MOMiHttrup83TfD7fIu5QLkYA1dEVFxXZITa+BZY/n ZtHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=esHTjxcAIpT5/NpHLc1ZVkLS0+NllgitPYn2F2gHVFg=; b=oKxYLhRShh/RKviYDDmJ3qnrsg2cqklpdiMOC6zTymYxHd5Ye7buEwZRJMnJcYtmlZ l6xnZU0j14B4bC0bu/IDj+a+RTw/HNWatkecMogbamgi1B2hmcn0xiNqnpXpotf1mXRe YfN5IH7E94ID+/McOukmwLn+SfZic3JMYlNMMVGTGL1gffZFxx91ba5rsCSmy+59DFmM wSpPw5bUFjVcMf8HVkT5x3q1q8SrEt9UZSqZwhhoFq+7grYNMw/t8cAW+9CKt84qQ4Fr 5KljBdZDDE7tKrJN2AjoucPs2L89cHjoXCBO3YYmSuYIJwcHglj6p07co1tih1Zqj3JW BlVQ== X-Gm-Message-State: AOAM532/kIhSrpTN68Kis5I33O+vmrY7Hra/uw0nPhusZLzEhhEG3YWI yKu91z0UbL3O0kfWpVy7Y08= X-Google-Smtp-Source: ABdhPJzP9BW106Nuzw+ZCHJ5ETA5IjL4tFttw9eT4ob4ngnSVgnizp4YwWoIj/zdbp45D8YybCKKsw== X-Received: by 2002:adf:f904:: with SMTP id b4mr33798525wrr.403.1635725493543; Sun, 31 Oct 2021 17:11:33 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:33 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 09/16] media: i2c: Update HTS values in ov8865 Date: Mon, 1 Nov 2021 00:11:12 +0000 Message-Id: <20211101001119.46056-10-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The HTS values for some of the modes in the ov8865 driver are a bit unusual, coming in lower than the output_size_x is set to. It seems like they might be calculated to fit the desired framerate into a configuration with just two data lanes. To bring this more in line with expected behaviour, raise the HTS values above the output_size_x. The corollary of that change is that the hardcoded frame intervals against the modes no longer make sense, so remove those entirely. Update the .g/s_frame_interval() callbacks to calculate the frame interval based on the current mode and the vblank and hblank settings. The implementation of the .enum_frame_interval() callback is no longer suitable since the possible frame rate is now a continuous range depending on the vblank control setting, so remove that callback entirely. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 65 +++++++------------------------------- 1 file changed, 11 insertions(+), 54 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 4b18cc80f985..1b8674152750 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -659,8 +659,6 @@ struct ov8865_mode { unsigned int blc_anchor_right_start; unsigned int blc_anchor_right_end; - struct v4l2_fract frame_interval; - bool pll2_binning; const struct ov8865_register_value *register_values; @@ -964,7 +962,7 @@ static const struct ov8865_mode ov8865_modes[] = { { /* Horizontal */ .output_size_x = 3264, - .hts = 1944, + .hts = 3888, /* Vertical */ .output_size_y = 2448, @@ -1003,9 +1001,6 @@ static const struct ov8865_mode ov8865_modes[] = { .blc_anchor_right_start = 1984, .blc_anchor_right_end = 2239, - /* Frame Interval */ - .frame_interval = { 1, 30 }, - /* PLL */ .pll2_binning = false, @@ -1018,11 +1013,11 @@ static const struct ov8865_mode ov8865_modes[] = { { /* Horizontal */ .output_size_x = 3264, - .hts = 2582, + .hts = 3888, /* Vertical */ .output_size_y = 1836, - .vts = 2002, + .vts = 2470, .size_auto = true, .size_auto_boundary_x = 8, @@ -1057,9 +1052,6 @@ static const struct ov8865_mode ov8865_modes[] = { .blc_anchor_right_start = 1984, .blc_anchor_right_end = 2239, - /* Frame Interval */ - .frame_interval = { 1, 30 }, - /* PLL */ .pll2_binning = false, @@ -1115,9 +1107,6 @@ static const struct ov8865_mode ov8865_modes[] = { .blc_anchor_right_start = 992, .blc_anchor_right_end = 1119, - /* Frame Interval */ - .frame_interval = { 1, 30 }, - /* PLL */ .pll2_binning = true, @@ -1179,9 +1168,6 @@ static const struct ov8865_mode ov8865_modes[] = { .blc_anchor_right_start = 992, .blc_anchor_right_end = 1119, - /* Frame Interval */ - .frame_interval = { 1, 90 }, - /* PLL */ .pll2_binning = true, @@ -2628,11 +2614,18 @@ static int ov8865_g_frame_interval(struct v4l2_subdev *subdev, { struct ov8865_sensor *sensor = ov8865_subdev_sensor(subdev); const struct ov8865_mode *mode; + unsigned int framesize; + unsigned int fps; mutex_lock(&sensor->mutex); mode = sensor->state.mode; - interval->interval = mode->frame_interval; + framesize = mode->hts * (mode->output_size_y + + sensor->ctrls.vblank->val); + fps = DIV_ROUND_CLOSEST(sensor->ctrls.pixel_rate->val, framesize); + + interval->interval.numerator = 1; + interval->interval.denominator = fps; mutex_unlock(&sensor->mutex); @@ -2777,41 +2770,6 @@ static int ov8865_enum_frame_size(struct v4l2_subdev *subdev, return 0; } -static int ov8865_enum_frame_interval(struct v4l2_subdev *subdev, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_frame_interval_enum *interval_enum) -{ - const struct ov8865_mode *mode = NULL; - unsigned int mode_index; - unsigned int interval_index; - - if (interval_enum->index > 0) - return -EINVAL; - /* - * Multiple modes with the same dimensions may have different frame - * intervals, so look up each relevant mode. - */ - for (mode_index = 0, interval_index = 0; - mode_index < ARRAY_SIZE(ov8865_modes); mode_index++) { - mode = &ov8865_modes[mode_index]; - - if (mode->output_size_x == interval_enum->width && - mode->output_size_y == interval_enum->height) { - if (interval_index == interval_enum->index) - break; - - interval_index++; - } - } - - if (mode_index == ARRAY_SIZE(ov8865_modes)) - return -EINVAL; - - interval_enum->interval = mode->frame_interval; - - return 0; -} - static void __ov8865_get_pad_crop(struct ov8865_sensor *sensor, struct v4l2_subdev_state *state, unsigned int pad, @@ -2870,7 +2828,6 @@ static const struct v4l2_subdev_pad_ops ov8865_subdev_pad_ops = { .get_fmt = ov8865_get_fmt, .set_fmt = ov8865_set_fmt, .enum_frame_size = ov8865_enum_frame_size, - .enum_frame_interval = ov8865_enum_frame_interval, .get_selection = ov8865_get_selection, .set_selection = ov8865_get_selection, }; From patchwork Mon Nov 1 00:11:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595555 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CE8EC433FE for ; Mon, 1 Nov 2021 00:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F348560F58 for ; Mon, 1 Nov 2021 00:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbhKAAOJ (ORCPT ); Sun, 31 Oct 2021 20:14:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230407AbhKAAOI (ORCPT ); Sun, 31 Oct 2021 20:14:08 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9ABDC061714 for ; Sun, 31 Oct 2021 17:11:35 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id m22so25880337wrb.0 for ; Sun, 31 Oct 2021 17:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pMeL2ZMTwgQaas5FyK+wnxkmsgi4q2MxWhpMVqxDmVg=; b=jS2h0hxX7/uIe3bpUT3+Inly81S8F2XOu/UIWp2h0dwGuIF4yoLDDhzvJJU0QCtqxL QRefwvpEV7t3rkqIaSl43uaVis2fuozuMrqbnNeB/tW2GI07aX7Wo8CNZ4tqdOde8/x3 oR6Rf5apCTSE3ndvfQu+ygnIPwHelMuPR6mDvnMp0XNJBQLMZt7gb2X+JBeg8+l6Afdd 5vKVjy7zTxeKT7SDM5I/LZ6pP+g6yw5QglD7p9nGQl9rfFgDVE2BByDBJbgy1PUDsy4C 48oTqxIDtcLpKbrDc574G3jjIbtiQMgJg0ykJn2YNbRkOUQC9a0sciSA+uqTEM101bwt Nz2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pMeL2ZMTwgQaas5FyK+wnxkmsgi4q2MxWhpMVqxDmVg=; b=Rts1P/NP7TMg1sx2EsVjCdkIt4XenIJt33QaRfpULC0Zat7w919LsKkxvfUQt8F27T 4VawudNeLDjO2n4dAUS3EzKjDvk43tPLM1zYMmmVR4XFwABjPRwpkY+LDtZqyHBVvpzh CF2u/eLK4ZiaNZdEQfCBttcC+XruKkl6XdwzBOMF1L0UUY/XwLNCwUITfHOHjF943kTO csyEZuKGoWeNpNJ5kigk0wqgB5kxoYUBUkMxO/GRx0FMmp2YHcTPI4nGthx6vNYz7FkY Xjeqv03s123aoUXnLAgn3wAxiu41/XCE5S+sGlf32n7b3CSB/qjkxDVzMThuiiZm2aBQ exZg== X-Gm-Message-State: AOAM531dk7Dcg8BscZ6yq7o04wrFV3AVR4td/JyEFtDTBKXXFWuVl/bh HQ45NF30HW42iTkvD+5TlxI= X-Google-Smtp-Source: ABdhPJw2Iw2AGbyvOE2Wbrhr2N5JizhD9tsffbUmHM8iJm1GzVC4++pMPO3ktzglFgxr78uogsSAkA== X-Received: by 2002:adf:a489:: with SMTP id g9mr20234533wrb.235.1635725494506; Sun, 31 Oct 2021 17:11:34 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:34 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 10/16] media: i2c: cap exposure at height + vblank in ov8865 Date: Mon, 1 Nov 2021 00:11:13 +0000 Message-Id: <20211101001119.46056-11-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Exposure limits depend on the total height; when vblank is altered (and thus the total height is altered), change the exposure limits to reflect the new cap. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 1b8674152750..99548ad15dcd 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -677,6 +677,7 @@ struct ov8865_ctrls { struct v4l2_ctrl *pixel_rate; struct v4l2_ctrl *hblank; struct v4l2_ctrl *vblank; + struct v4l2_ctrl *exposure; struct v4l2_ctrl_handler handler; }; @@ -2454,6 +2455,19 @@ static int ov8865_s_ctrl(struct v4l2_ctrl *ctrl) unsigned int index; int ret; + /* If VBLANK is altered we need to update exposure to compensate */ + if (ctrl->id == V4L2_CID_VBLANK) { + int exposure_max; + + exposure_max = sensor->state.mode->output_size_y + ctrl->val; + __v4l2_ctrl_modify_range(sensor->ctrls.exposure, + sensor->ctrls.exposure->minimum, + exposure_max, + sensor->ctrls.exposure->step, + min(sensor->ctrls.exposure->val, + exposure_max)); + } + /* Wait for the sensor to be on before setting controls. */ if (pm_runtime_suspended(sensor->dev)) return 0; @@ -2510,8 +2524,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) /* Exposure */ - v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16, 1048575, 16, - 512); + ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16, + 1048575, 16, 512); /* Gain */ @@ -2700,6 +2714,7 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev, u32 mbus_code = 0; unsigned int hblank; unsigned int index; + int exposure_max; int ret = 0; mutex_lock(&sensor->mutex); @@ -2747,6 +2762,13 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev, __v4l2_ctrl_modify_range(sensor->ctrls.hblank, hblank, hblank, 1, hblank); + exposure_max = mode->vts; + __v4l2_ctrl_modify_range(sensor->ctrls.exposure, + sensor->ctrls.exposure->minimum, exposure_max, + sensor->ctrls.exposure->step, + min(sensor->ctrls.exposure->val, + exposure_max)); + complete: mutex_unlock(&sensor->mutex); From patchwork Mon Nov 1 00:11:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595557 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D2E2C433EF for ; Mon, 1 Nov 2021 00:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 722E3604D2 for ; Mon, 1 Nov 2021 00:11:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230476AbhKAAOK (ORCPT ); Sun, 31 Oct 2021 20:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbhKAAOJ (ORCPT ); Sun, 31 Oct 2021 20:14:09 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D2BC061714 for ; Sun, 31 Oct 2021 17:11:36 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id d3so25758362wrh.8 for ; Sun, 31 Oct 2021 17:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BRADf3qIhaoSYgsOv/1Z1tOMSrTm5zFBbvc1XG3wKTg=; b=FJu0aqq7GcAlA2Q84GLb6fDp/LvehuE5MoxPHmDgtD6UWtvuhDr/UnVxPbrfYnsFgA /iBwwuPx9XTBF7jhewaJZqqskN3I2yOnWzmq20Kp5Q6h6+Vrflj9qIzyiCAHmp5yjTVZ G6Sl3gKKZn7/3dRuHWQHcGrrNHPRXPd4d8WlsPlIJtHq/4woKK1AuSmisOmJtEZTZag3 4fhrf4RG0JIjiaKme4AkfmqFa0uXzX+HEC9j4CbALtwonZwO/cBTsR/6heCJF1gAWR1p ZJ1u9KO2uUgFwr7gu2z5OUzMXW0DGQNwbKag2QhL3S+Yf0qWXt4sZoX7BnsyjLps3vmw RFlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BRADf3qIhaoSYgsOv/1Z1tOMSrTm5zFBbvc1XG3wKTg=; b=m4zLeTDbQzASufdbL2g2MFwUCCR9S9knY6OH9fppj3ffWYEvSmrUulksP4kXqH3jYO NqUndQUddfPHU7VxulLnWS5W+dTyCG83PYgBOseqLtmGFFcuZD4zcu7iJbjSMVE9aLxY EAzDCDJTed3fvS5WxJKofGD+06oKNm3bRoCgFGk68Nx/2w/cCDG1Xqo47AA9UqV0yYHU goR6paIroiMEBzwNUC/fMoRibPNJBEBs5+CFpcJ91Bk+8Pigrhe1wknGiGfZdJPBcMLz scQiY0nZUi1PHE4qSNLWchr5LgV5O2bYLya4jmStPTlMKrE4DN1uQ80+lWsAN/C3QZuH aemA== X-Gm-Message-State: AOAM5327mMppSvlWPRshzmhjBiFBxqIOvbfqY3+u2WfFsEclUm1wzyTI aqzHV6NxIIv4eGpROMgNakc= X-Google-Smtp-Source: ABdhPJzuOh0dDeBcoNe+sjwRYM1PTCWI6zVIGYGjZW4ygi3J2DHPnxwGoyzQ2BGSB7/ekq7Rpt6opg== X-Received: by 2002:a5d:64ed:: with SMTP id g13mr7454160wri.222.1635725495399; Sun, 31 Oct 2021 17:11:35 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:35 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 11/16] media: i2c: Add controls from fwnode to ov8865 Date: Mon, 1 Nov 2021 00:11:14 +0000 Message-Id: <20211101001119.46056-12-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 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 ov8865 driver by attempting to parse them from firmware. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 99548ad15dcd..dfb5095ef16b 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2513,6 +2513,7 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) struct v4l2_ctrl_handler *handler = &ctrls->handler; const struct v4l2_ctrl_ops *ops = &ov8865_ctrl_ops; const struct ov8865_mode *mode = sensor->state.mode; + struct v4l2_fwnode_device_properties props; unsigned int vblank_max, vblank_def; unsigned int hblank; int ret; @@ -2576,6 +2577,15 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) v4l2_ctrl_new_std(handler, NULL, V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); + /* set properties from fwnode (e.g. rotation, orientation) */ + ret = v4l2_fwnode_device_parse(sensor->dev, &props); + if (ret) + goto error_ctrls; + + ret = v4l2_ctrl_new_fwnode_properties(handler, ops, &props); + if (ret) + goto error_ctrls; + if (handler->error) { ret = handler->error; goto error_ctrls; From patchwork Mon Nov 1 00:11:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595559 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F3C3C4332F for ; Mon, 1 Nov 2021 00:11:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6617B604D2 for ; Mon, 1 Nov 2021 00:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbhKAAOK (ORCPT ); Sun, 31 Oct 2021 20:14:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbhKAAOK (ORCPT ); Sun, 31 Oct 2021 20:14:10 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FBEEC061714 for ; Sun, 31 Oct 2021 17:11:37 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id y84-20020a1c7d57000000b00330cb84834fso6757965wmc.2 for ; Sun, 31 Oct 2021 17:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1n8iLSsdmHQDyOZdyj1jMWnsuvmlHh+nf2NgpfdMpFQ=; b=jjIjDT4bY1IJMusL1TwjDnNxj5Rt420BzP+tm3mOfSKNq5GFYrxTkRjML6/JBalitH YbE59cX7zY9Yl8od9WEz5kkKTg6xXpPVSeY2p6GjaNZEqsTwS00V6ELa0S22D4lcPn24 Ua5AesYeiqiHxMCBY4UnCztDXtTkqL2qB2dtuUfrp9m5zjc71Og4YFK+vg+o5lvBqbBD S7NGFmiuQJn+MGYf3erXJAW0FK/U8Wt8UkG3hoxhmgOlfZXOmRjpLydt9djRKIyVCEeH YniOOSOQI0I/cyyE8qEAU98BmgbX1sBM2VgwicRp3rW6IYTRcdhSFxq9HnotA6FY4kRt Vn+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1n8iLSsdmHQDyOZdyj1jMWnsuvmlHh+nf2NgpfdMpFQ=; b=NAhyCDQ3GTeCK91vwiGlWcrAAxgQ1Qqwy07aN8Z5OQ/GBrY8eMVxJxMsLwt3+yIDQ6 pTCR7FCnC1wVtBIJB/z8eGGdX//eIZFUXxw25KPjiWtA7e2eRFDA/UedCgCzLymIf0Ym Z1AG63Iz2hX15oMDzkYmvh7mQGGWNOy1aLElnAqYKjW/M40k4hO//sjmjsheix0WhlY3 uNYOmwcUtl9r4LkQoPxIlSgkJ4R8faj0fl62gxN9J1c89J/xSyKjwqhEYxpZWdHq7vWJ ViPhnVj3hBwhxWoimqzvR0VAt0fK/IGlO0y9vwipjjTYExyJkviD9piOcEBhmqvkzqqT oUjg== X-Gm-Message-State: AOAM530aOMvqpGl9VAdvZkcZyJqSBhpqcjMX7r9YDuFvnN+wECLbXlKi IizMChREitbBFSzuLFryzlk= X-Google-Smtp-Source: ABdhPJxvW8IN3wx5HUrrAiT92UebrIdh4pKwuskJQ8Db4z8pPcA48LeuvzqwofQbZ3vJ8IzWXzbGfw== X-Received: by 2002:a1c:a984:: with SMTP id s126mr35913770wme.156.1635725496293; Sun, 31 Oct 2021 17:11:36 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:35 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 12/16] media: i2c: Switch exposure control unit to lines Date: Mon, 1 Nov 2021 00:11:15 +0000 Message-Id: <20211101001119.46056-13-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ov8865 driver currently has the unit of the V4L2_CID_EXPOSURE control as 1/16th of a line. This is what the sensor expects, but isn't very intuitive. Switch the control to be in units of a line and simply do the 16x multiplication before passing the value to the sensor. The datasheet for this sensor gives minimum exposure as 2 lines, so take the opportunity to correct the lower bounds of the control. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index dfb5095ef16b..5f19d82554df 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2125,6 +2125,9 @@ static int ov8865_exposure_configure(struct ov8865_sensor *sensor, u32 exposure) { int ret; + /* The sensor stores exposure in units of 1/16th of a line */ + exposure *= 16; + ret = ov8865_write(sensor, OV8865_EXPOSURE_CTRL_HH_REG, OV8865_EXPOSURE_CTRL_HH(exposure)); if (ret) @@ -2525,8 +2528,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) /* Exposure */ - ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16, - 1048575, 16, 512); + ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 2, + 65535, 1, 32); /* Gain */ From patchwork Mon Nov 1 00:11:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595561 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61EE4C433EF for ; Mon, 1 Nov 2021 00:11:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B912604D2 for ; Mon, 1 Nov 2021 00:11:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230501AbhKAAOL (ORCPT ); Sun, 31 Oct 2021 20:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbhKAAOL (ORCPT ); Sun, 31 Oct 2021 20:14:11 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1724C061714 for ; Sun, 31 Oct 2021 17:11:38 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id z200so11394631wmc.1 for ; Sun, 31 Oct 2021 17:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hafVvi465P3sPwGgXMo1mcvsH6Eg9wims/dDxx08Hn0=; b=pk4CuIywMvkod6jpLCMV8SOCEtiF5HTmUt2eNcH9rWDfAEJ1jfz/M0qhbW3WZFjjD9 EXxbpmkUu7WjjjTuij9guU8fdQie5Dd/EgA9cg6mY7Pr/wHOwuXxL3ofVmxLXqdVMRcx g/+h2kBSqLUeR1SHO+bv96t77d+xLhLWVNtOp94nOYnKvVJe6F1zitBnwBxNLs41a8Ml zzA2xuUHqJHWwwlork6V5NUms95RiZWZ8BoiEJZcFO3TX1ovxeK43mi3g41mgG+/J/aU q5eDpqvjo186UYdSR8okJLiMOReMDByCCAyaj99xZg/AP4U/hEwF+Sdiao7P39TUmeJ4 gJVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hafVvi465P3sPwGgXMo1mcvsH6Eg9wims/dDxx08Hn0=; b=4r8QgXIf+GXiDn5Oi6KHOsu6SXjCJRN7i0iUx9wNCLkFO7gNUd22ydYW+jWEXo/FyQ hFk4q2LqmMEOKFJQHAr6xms94lCRq5HALVKJAfqU74IgJfLajSk3ZcDm/B6k4BoxfUup OzjXhrbq5ormpubIREK1fC/xnPEKWiKVyovfR7MJ+FFzKyEsRHCBUPMRjBveUvi2z3O0 qgbYH02kajxJIDis4H+Js6xv7gOHl+bLq7Y6UCsz1hHgZeqd69e7q60xop1UOU7GEA4V Gw7eZIaiXVreud9hWIpKtqI7bjrBXJT8dg68QVgAeQRaywizrQFnqYSkr9P+a3XZmTRN tTSQ== X-Gm-Message-State: AOAM532i5IfgCFNJplFu30e4eBVMogzFcTGMsjtBdhfs2lg1B7h/H4jF AUWPxir9W+otoHkl2Ttubug= X-Google-Smtp-Source: ABdhPJytEmjYDlbVhNGAmtnVxvCjJXQvtIBkpdeBR07IbMPfC9qsNrjAYrO5A48WJn8Rg/81BD+EwA== X-Received: by 2002:a1c:8090:: with SMTP id b138mr13522817wmd.25.1635725497296; Sun, 31 Oct 2021 17:11:37 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:36 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 13/16] media: i2c: Re-order runtime pm initialisation Date: Mon, 1 Nov 2021 00:11:16 +0000 Message-Id: <20211101001119.46056-14-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The kerneldoc for pm_runtime_set_suspended() says: "It is not valid to call this function for devices with runtime PM enabled" To satisfy that requirement, re-order the calls so that pm_runtime_enable() is the last one. Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 5f19d82554df..18b5f1e8e9a7 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -3085,8 +3085,8 @@ static int ov8865_probe(struct i2c_client *client) /* Runtime PM */ - pm_runtime_enable(sensor->dev); pm_runtime_set_suspended(sensor->dev); + pm_runtime_enable(sensor->dev); /* V4L2 subdev register */ From patchwork Mon Nov 1 00:11:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595563 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 773B1C433F5 for ; Mon, 1 Nov 2021 00:11:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58A5660F58 for ; Mon, 1 Nov 2021 00:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbhKAAOM (ORCPT ); Sun, 31 Oct 2021 20:14:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbhKAAOM (ORCPT ); Sun, 31 Oct 2021 20:14:12 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A08DC061714 for ; Sun, 31 Oct 2021 17:11:40 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id y84-20020a1c7d57000000b00330cb84834fso6757998wmc.2 for ; Sun, 31 Oct 2021 17:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=803UQJ142AWpcyjy/zsRr+1MK6Z6851rVoDTYMduLxY=; b=CDJwZnkGfiDubUh6fx1xlyV3IZQYTGhg1i+ebim2CS+F1drLZ4f6rjOyfV+Vnpm0Py CkZlK6upPUfUK4e//SGZ9m58NCicLnAA7UbSluTbBc9Oehc15knxXV9VdQWpcz80youe dg+7oevwQwy1gIyqzSeDvLZ4V7/POlj7SvOZa6kUcn+LA1RxzFOHxtpdVso5KSrIwRZY 4YEIj3P3bXC8LoV238BpNskCUli+9IR9yEdC1Atg1XcEK+5lHG2YvN3dj+fPYsgJaFj+ ZdgVxkow4LDvOvxWQL/qV1LKXA+4v6Rm0lWgwnGZ2lF/d5dDHuSTE5G4qDvFYXJy4AFu 5jeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=803UQJ142AWpcyjy/zsRr+1MK6Z6851rVoDTYMduLxY=; b=MPrhU5feAJH9XnDEVC9zJ4kJlaBZTRB75qBOdaEquEUrTkii3VWaSmc841rNvPt5g3 ci0/rHij+0rt+RBSaM8LEFGg79mg5Qrhr3N6eaCIEzSQ06m+PWM5szzaZiCPJUMQtazv MUim69zhwVmb8Kws8qmqbYLVFLc6CTLtyvhdn89NDdV7doanhPWk6LKWyr5lm7UoLY/R xrKmulFy99CzmYLRTeHHPvGY0bD34IP5AfZy9tkEqdtS3eAv4rXJWfARDGIaTHwU+bdj iLVdy5P5/i3gStMFtxVFP4YInyZKkvWMOyKpkc1898mCYt1aC019//Dg0k5Hbc095lO3 N80A== X-Gm-Message-State: AOAM5309mhn5ZQQNAgZnXn4h6b3/SHhlX2fOkx7PHBijlclnh61ECjad H0MIgKJ0nGEoL7bVkyzmwJQ= X-Google-Smtp-Source: ABdhPJx1Bk9jWV68oGJoC3iLsEOlPXwL5lkO8BD56dWjTSmBix7WtiTl7OVKK9NonD+eMV4FVQVo/Q== X-Received: by 2002:a7b:c1cb:: with SMTP id a11mr3169438wmj.30.1635725498657; Sun, 31 Oct 2021 17:11:38 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:37 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 14/16] media: i2c: Use dev_err_probe() in ov8865 Date: Mon, 1 Nov 2021 00:11:17 +0000 Message-Id: <20211101001119.46056-15-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There is a chance that regulator_get() returns -EPROBE_DEFER, in which case printing an error message is undesirable. To avoid spurious messages in dmesg in the event that -EPROBE_DEFER is returned, use dev_err_probe() on error paths for regulator_get(). Signed-off-by: Daniel Scally --- drivers/media/i2c/ov8865.c | 46 +++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 18b5f1e8e9a7..ab225fb616b9 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2955,6 +2955,26 @@ static int ov8865_probe(struct i2c_client *client) sensor->dev = dev; sensor->i2c_client = client; + /* Regulators */ + + /* DVDD: digital core */ + sensor->dvdd = devm_regulator_get(dev, "dvdd"); + if (IS_ERR(sensor->dvdd)) + return dev_err_probe(dev, PTR_ERR(sensor->dvdd), + "cannot get DVDD regulator\n"); + + /* DOVDD: digital I/O */ + sensor->dovdd = devm_regulator_get(dev, "dovdd"); + if (IS_ERR(sensor->dovdd)) + return dev_err_probe(dev, PTR_ERR(sensor->dovdd), + "cannot get DOVDD regulator\n"); + + /* AVDD: analog */ + sensor->avdd = devm_regulator_get(dev, "avdd"); + if (IS_ERR(sensor->avdd)) + return dev_err_probe(dev, PTR_ERR(sensor->avdd), + "cannot get AVDD (analog) regulator\n"); + /* Graph Endpoint */ handle = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL); @@ -2985,32 +3005,6 @@ static int ov8865_probe(struct i2c_client *client) goto error_endpoint; } - /* Regulators */ - - /* DVDD: digital core */ - sensor->dvdd = devm_regulator_get(dev, "dvdd"); - if (IS_ERR(sensor->dvdd)) { - dev_err(dev, "cannot get DVDD (digital core) regulator\n"); - ret = PTR_ERR(sensor->dvdd); - goto error_endpoint; - } - - /* DOVDD: digital I/O */ - sensor->dovdd = devm_regulator_get(dev, "dovdd"); - if (IS_ERR(sensor->dovdd)) { - dev_err(dev, "cannot get DOVDD (digital I/O) regulator\n"); - ret = PTR_ERR(sensor->dovdd); - goto error_endpoint; - } - - /* AVDD: analog */ - sensor->avdd = devm_regulator_get(dev, "avdd"); - if (IS_ERR(sensor->avdd)) { - dev_err(dev, "cannot get AVDD (analog) regulator\n"); - ret = PTR_ERR(sensor->avdd); - goto error_endpoint; - } - /* External Clock */ sensor->extclk = devm_clk_get(dev, NULL); From patchwork Mon Nov 1 00:11:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595565 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D09A1C433FE for ; Mon, 1 Nov 2021 00:11:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B737260F58 for ; Mon, 1 Nov 2021 00:11:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbhKAAOO (ORCPT ); Sun, 31 Oct 2021 20:14:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbhKAAON (ORCPT ); Sun, 31 Oct 2021 20:14:13 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03B90C061714 for ; Sun, 31 Oct 2021 17:11:41 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 71so9960780wma.4 for ; Sun, 31 Oct 2021 17:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b3XbTTgU2h7a9joE3RqUnaluJG8j12IWj/XD0gr/nRQ=; b=HJEQ5lFyx/tPApnhXD7gMJK9L0hEnw0j3aVcakPPusiln2d8PvDxBqajtzAIPlm3iz gs0uY4Ms6wUQUehNeEwsb+BdrCDlvnWv9Tmt3E2ZZHIRouo68tc7WnxUtBIppA0eGS+J P62ynjv00t7CUXrol/788deKnN894c8NBjw1hHGA8urq+YpvRofC9TEgqjXPR/0I5ZNm QjYvWMDiY5Jb+SA0qd4CAKNH6x2QG/2XCtbgTi/3A4kt6w4u9SHkhxmhp1I+QWpttrhG QL9p26sLu0azO3H/DBcuP2Bym1SXa0V1JDNAoa1jkppUE8F9PCSf5SeoQAkCSKXMq4Gw 4skQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b3XbTTgU2h7a9joE3RqUnaluJG8j12IWj/XD0gr/nRQ=; b=gAaLM7aH6lah5UH+BPQQhuh/Wp+8Y2yEbAY1+FCc6yRkotFL0e+mXmONPDQPjhffe4 EVfvowgRMueLRx0VJZuy1vfkOx4CPiaTVYgSWqRcvg1fpsb79NlPAmRq5heAJopMKf1x fjZFEbw+oywGLRm8C+G9nw2rMgTeElEQ611KkvXqgliOmV1RXMlrwF8S9VDiCz1TD+Qv 287LqD5sIKc9Qwu/dw72YqlBSNNu1t4Fz3/ig6cu1vVANvGgLV11ZMaM3uRD8j27iJ4N ATvXSJt176aNOxKmZs+bznSKXBUbTujPhRQ7C/3b1NTmCOCvQ1DWi9nS9aMvX55vUzoc 7TWQ== X-Gm-Message-State: AOAM531CMBR616WLVvb4rDBq9lWo/pcXPvVnn59m8ZztYM/GIZhBwOPW XDBeAqkwgmexbDRAQVOFvVINHr7NvTY= X-Google-Smtp-Source: ABdhPJzhrdeCDCr2XNNNwukzBtiK8NOW8lZ5iPp5TpP5CpA9rkrESiASwuoBgfqFXI6Q2NZpEt19vA== X-Received: by 2002:a1c:730a:: with SMTP id d10mr35195106wmb.105.1635725499656; Sun, 31 Oct 2021 17:11:39 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:39 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham , Andy Shevchenko Subject: [PATCH v4 15/16] media: ipu3-cio2: Add INT347A to cio2-bridge Date: Mon, 1 Nov 2021 00:11:18 +0000 Message-Id: <20211101001119.46056-16-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org ACPI _HID INT347A represents the OV8865 sensor, the driver for which can support the platforms that the cio2-bridge serves. Add it to the array of supported sensors so the bridge will connect the sensor to the CIO2 device. Reviewed-by: Andy Shevchenko Signed-off-by: Daniel Scally --- drivers/media/pci/intel/ipu3/cio2-bridge.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c index 59a36f922675..fb7d708b16e2 100644 --- a/drivers/media/pci/intel/ipu3/cio2-bridge.c +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c @@ -22,6 +22,8 @@ static const struct cio2_sensor_config cio2_supported_sensors[] = { /* Omnivision OV5693 */ CIO2_SENSOR_CONFIG("INT33BE", 0), + /* Omnivision OV8865 */ + CIO2_SENSOR_CONFIG("INT347A", 1, 360000000), /* Omnivision OV2680 */ CIO2_SENSOR_CONFIG("OVTI2680", 0), }; From patchwork Mon Nov 1 00:11:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12595567 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91DBEC433F5 for ; Mon, 1 Nov 2021 00:11:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79EC360FC4 for ; Mon, 1 Nov 2021 00:11:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230520AbhKAAOP (ORCPT ); Sun, 31 Oct 2021 20:14:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbhKAAOO (ORCPT ); Sun, 31 Oct 2021 20:14:14 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDFACC061714 for ; Sun, 31 Oct 2021 17:11:41 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 71so9960797wma.4 for ; Sun, 31 Oct 2021 17:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Lf87r12qxO68BXDuIGNnYQNQjUznr0ZaTkZGfQbHXlU=; b=mfLpg74+eMXxduYla1KtSEkzFEikqA54TmCXSa41wai691vz+UvwPQZXR3z1yGhuHf qec1samOPyiTBl9IOW6wNzPL5U5bkvpJXwUSYdmWOAJoKPkQ5ta1ogE/xaPRduExX+b/ jkfP4cKT3JFaV24KPKGH6rrh4Z8fSkTd65YVyZg+PTp5D28zl0vCSo6AUl9fM8bc9iru yZdgnVui+y7L/lQHkUgkfBUMoeqNMISBI8j7uNrexviy/EacDpWdJ453MpH+CKXwmIrT iaqhlmvcMpA86IinzBpBA/K0Y3+gL4FIewHBVVqFvp/DgsoCSui+dMg50UvQ2h+zcYeE /4dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lf87r12qxO68BXDuIGNnYQNQjUznr0ZaTkZGfQbHXlU=; b=iwzd6vgp+pYUo08uAJkbL/WmlHDeizfRkxhrvuNDmGZd21uPSVQKEnFIFK0NBU46QK kcWAA1AE7eDJ7eUWb+iTIcm8R5N1C1jQnDeKOPTGTb917p5eqQxmVogL4GHy5ey1JxX3 9HbsEbChpox1ksHCrSvYrxzC54vSfmziLt+IvB9q+w07pp8XDz04ZigULRP/B7nVefht 4hbt6yBZdk2s0xxtYAbN13z9Q3dY4o/8tVy1F9M1JZC+tdm9n6Cqh/cSBkCftK9nTWnt uFMyXTRwOZmp8aX3Z63bDL6RCfpPFskRBxPIU4AW0G8+agPoVLu0mwfBsEh75wRLPhCI MpHg== X-Gm-Message-State: AOAM530xbgHiu/JSdz64VARFYKO0+I4qRrB9qflp0FXUwk1vVnDdfBRb X7CujNXlejgJH2O6VV59ioI= X-Google-Smtp-Source: ABdhPJwV/+hk3locqVIrD468sTimUc23Ac/+kcTvcX3WJGTipz8S8OrlZY3H0NTKZyBdSWcNERHPIQ== X-Received: by 2002:a1c:1fcf:: with SMTP id f198mr24363146wmf.66.1635725500605; Sun, 31 Oct 2021 17:11:40 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id k6sm12557678wri.83.2021.10.31.17.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 17:11:40 -0700 (PDT) From: Daniel Scally To: Paul Kocialkowski , Daniel Scally , linux-media@vger.kernel.org Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Andy Shevchenko , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v4 16/16] media: i2c: ov8865: Fix lockdep error Date: Mon, 1 Nov 2021 00:11:19 +0000 Message-Id: <20211101001119.46056-17-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101001119.46056-1-djrscally@gmail.com> References: <20211101001119.46056-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Hans de Goede ov8865_state_init() calls ov8865_state_mipi_configure() which uses __v4l2_ctrl_s_ctrl[_int64](). This means that sensor->mutex (which is also sensor->ctrls.handler.lock) must be locked before calling ov8865_state_init(). Note ov8865_state_mipi_configure() is also used in other places where the lock is already held so it cannot be changed itself. This fixes the following lockdep kernel WARN: [ 13.233413] ------------[ cut here ]------------ [ 13.233421] WARNING: CPU: 0 PID: 8 at drivers/media/v4l2-core/v4l2-ctrls-api.c:833 __v4l2_ctrl_s_ctrl+0x4d/0x60 [videodev] ... [ 13.234063] Call Trace: [ 13.234074] ov8865_state_configure+0x98b/0xc00 [ov8865] [ 13.234095] ov8865_probe+0x4b1/0x54c [ov8865] [ 13.234117] i2c_device_probe+0x13c/0x2d0 Signed-off-by: Hans de Goede --- drivers/media/i2c/ov8865.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index ab225fb616b9..c5fe290317e8 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -3073,7 +3073,9 @@ static int ov8865_probe(struct i2c_client *client) if (ret) goto error_mutex; + mutex_lock(&sensor->mutex); ret = ov8865_state_init(sensor); + mutex_unlock(&sensor->mutex); if (ret) goto error_ctrls;