From patchwork Thu Oct 21 21:43: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: 12576679 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 E4523C433F5 for ; Thu, 21 Oct 2021 21:43:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C42A961359 for ; Thu, 21 Oct 2021 21:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232140AbhJUVqP (ORCPT ); Thu, 21 Oct 2021 17:46:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbhJUVqO (ORCPT ); Thu, 21 Oct 2021 17:46:14 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEAFCC061764 for ; Thu, 21 Oct 2021 14:43:57 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id p21so961192wmq.1 for ; Thu, 21 Oct 2021 14:43:57 -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=/w7EfRJhx2E8HGxcWfzRpVehPHP9jiRH6aIMpFoZSXk=; b=ceyAZX/bCJ2wwsHYUTng40w7DwGEjqdJTPiqES/QBWczEC2Wy76jzdPKaJtVqoXJmh 1zALB+5Va/IeU4lcD10cfYnAABiKPz3qKfvoi7x1LsYDXucd2N3JaqbvOfPjsP7rP9Tz SNpF/AeSazFiyE89SzPa+VdTWBr1JaBsdTgapGa0YH4lfmJFOFjNWd2sBdZB2xuyaQ05 Nf8lZAisn9Xxu9KlX0R6RY1/4l9XqdD0xuQlDuPe3VEw1XSHqtpZm6+EEeVyYAJvqkXb 81WUs/mKPiUI/l4oelvcsacQyxplerzES32qrViyUe3xhtAK/kLkgN++K4v2w2fPzo7x jbyQ== 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=/w7EfRJhx2E8HGxcWfzRpVehPHP9jiRH6aIMpFoZSXk=; b=v4Xj9wSOsUw7f9k6EyykLLFQq1iXWQc1GY1W9PwAtFQ4Cfy3Biw6zl2UVm2Ru1qeYS DZf7nFjlyKAGcZ5fbUPZJiFRKqsPtTJ8U/C64gxQ+nELzwY1tMa6lRjVuTMrnmIIayuM Zc5PNvrPIHvsGQGBeiluBtluxiZv1MBmKzFN0R/YHHNUkjYcGlPVJu3oN/fTPfigfiiL drBusfRqWcpU/joU1lEmZzNabpt2aFq3X3pxzAvU9IfTEF/3tylO+gSmMc2yrGgY6Xar Fm1NuKYYV4X5ntvTnBF4b5z1IxKc/iVLaCDunRUXd9xnRjKdiQlLyyjDY837pp5Fc49H i7rg== X-Gm-Message-State: AOAM531NvTiuAZZYLzDn9JeUXMMOKTBde5U6NS892ORQQ5D0vvki2prV lPebxkfRseu4sNS31di4xpo+7uHiOIY= X-Google-Smtp-Source: ABdhPJyFOVBYaGac+qsH7xOXUIgizIPRA2bgC40bLToGYOH8rV5MyKN34Gu9Zxb7JO6lg91nrmKMDA== X-Received: by 2002:a7b:c8ce:: with SMTP id f14mr23136834wml.177.1634852636667; Thu, 21 Oct 2021 14:43:56 -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 r205sm6378507wma.3.2021.10.21.14.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:43:56 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 01/16] media: i2c: Add ACPI support to ov8865 Date: Thu, 21 Oct 2021 22:43:16 +0100 Message-Id: <20211021214331.1188787-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 d82c80274a7a..4c3039be9fe3 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 Thu Oct 21 21:43: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: 12576681 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 8AA4DC4332F for ; Thu, 21 Oct 2021 21:44:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E0C461359 for ; Thu, 21 Oct 2021 21:44:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbhJUVqQ (ORCPT ); Thu, 21 Oct 2021 17:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbhJUVqP (ORCPT ); Thu, 21 Oct 2021 17:46:15 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B4FC061348 for ; Thu, 21 Oct 2021 14:43:58 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id o20so1637419wro.3 for ; Thu, 21 Oct 2021 14:43:58 -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=rVsX/c7kjoIBrsa1pB/uPlnMXLUXd3Lv33bxgw1Tcn8=; b=X2hgBu6EmOq+5+GbdwchkLW3jUqmjbZnpd4As3IHlUmmXtbkr1cMIQ8Hr2WyFcb0Wg si6N7tos0Buplu1KQu7bapZJRH7/MzZCCgMOVa1sIfST4BALanCJkW7xXxT14WYYYRij y6zqEhwV8SiZ/DApAmNIemT5CtSp4Q/DPbDfIc5y+ht6Ce2gjjGKSG4HDETIhR/hNy+K UPWemCJ/IhsoldswDq6fC/+vPNiNI6OYj4dh0b5q3WEEKFfksfZAF00/B35ij90X7zCI zlNEj7yQQMRUKUQqGDcfCXYntFsLjLAujxD9hJB8/3VlAcCl7+pxtiGnw1m67yVNz3JB r+yw== 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=rVsX/c7kjoIBrsa1pB/uPlnMXLUXd3Lv33bxgw1Tcn8=; b=nF5jr18gD8OxSN6dlTUR4YrWr+zGUajBunGprz1ufwtLYEdcfMTQ4Whf3NS/ijRtkr 4dzm+T1nQzHIHCKhOS3MIzhUb9VPrxbizM4ECcVSQfsXZ6nhN4bb4w4e6C0ou+XmLJ/u h+FzbPwl1usi3AlScAA3oP2EHTXY/64wV8ynK5fiVlWa+WryqdO4c1py/HWXEL8rbskh gPdBv2HN7E7+mZtVTsQBAwmK30X8Jyo90n86xFgq6Oq5qL82obb5HkqzhbtlhOir2LCN sN9fgTD0wTll+fYH6bf6HolsZIpIeKDqiWcF3thKO7bprCPHIGTovIGaVuESF1HEkoz5 Z7ng== X-Gm-Message-State: AOAM531Mbj2a6TtXlzCLkQtaZZUoF6e9gKQhOAAmISFk65gaUsjmni2b gpRdlOO1/w77IZ6pU1kkecyFSFcdv+w= X-Google-Smtp-Source: ABdhPJyy+9WS5jRdEoUAk2HOa1k4XwMomH9IGFzxaGtgd+srl+JmvN3d+gUcRRleiD36inHkj2v2CQ== X-Received: by 2002:a05:6000:2a1:: with SMTP id l1mr10753108wry.87.1634852637551; Thu, 21 Oct 2021 14:43:57 -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 r205sm6378507wma.3.2021.10.21.14.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:43:57 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 02/16] media: i2c: Fix incorrect value in comment Date: Thu, 21 Oct 2021 22:43:17 +0100 Message-Id: <20211021214331.1188787-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 4c3039be9fe3..7513b54a2aa8 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 Thu Oct 21 21:43: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: 12576683 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 668F3C433EF for ; Thu, 21 Oct 2021 21:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E538603E7 for ; Thu, 21 Oct 2021 21:44:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232154AbhJUVqQ (ORCPT ); Thu, 21 Oct 2021 17:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbhJUVqQ (ORCPT ); Thu, 21 Oct 2021 17:46:16 -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 AA8D1C061764 for ; Thu, 21 Oct 2021 14:43:59 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id g79-20020a1c2052000000b00323023159e1so1147838wmg.2 for ; Thu, 21 Oct 2021 14:43:59 -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=Q80H4X8cmtIQEgUB2e56kv+SIwIlfsWDwStJzV882LY=; b=Z/SpehXI+VeKxH6aJhlVNsQAYiojDOfc1FiLTUYGgrtXGgpAU/gIWQTvlp/kEFF1mf um7Xg7G9Vk0abUVp560QIlKUnWV3K+bHmUYmGTeh9wV/Dxk88L51Vz6w0hbX8eoR3Ety 64/cxoUagN9qa76fgj8N140tJP294wIWZb5Y6aYQAl5KCOFGCoR/wxePIgN/6QmIYr8U Fh6oSdq6s5zKSRozZ79pDMZkkOeHumkueiYToqHQmqu6WxWJdc3XAjvVQb7jvvD/xfo1 zgXvQL8qwdnFgpvi35E+QS7I2f9eD/BC5P4N7WU8cwpKqnB4NZS3NJqdoJKs3VSYxGfU uNmA== 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=Q80H4X8cmtIQEgUB2e56kv+SIwIlfsWDwStJzV882LY=; b=5ch4HqqIP2t3ecsrmSaMAZFTZoAM/1pN6RX63r2rb5Rdh9Ov3amad/XZGrle1ilQDn MWq7UV7fRydruhYcSkjfjKp4AWaIBAqIQmcPVanHAqSU2ufPuqKgZS1fxkUojm/tRlcQ R1nFnDcR07pctOjdh7SYknBLcLiNpH1l78Ee/5030AamcH8ZsRpF6zPo2nrjun4GMmr3 d14GepKFzvHIB1t/T/oxqIaSBn0var1vrWQTY5mWGqKwYBRSXOL32tluB49g+R9vm+6j /0zZ7WfY87qJIoyu2gfELVmyswnZ/1+Xycb60RJyw6BPQzCZlk6F4PDZJCdRc9BiGptX Bunw== X-Gm-Message-State: AOAM531ycWg9mzRWtyostPU/RRctJwNaHrtygsmLUAa+CDs2wG8izyc0 gUVDmGLdw3Lo5rX9u/Jz/DhSbQpwWns= X-Google-Smtp-Source: ABdhPJy+oWMZIlqDyw04/0XFGXV7jtb/88/buDdUsyChMEvQqzWwGv0/RgGVSB0I2Nvt5OKkdXeaaA== X-Received: by 2002:a7b:c08b:: with SMTP id r11mr9304744wmh.167.1634852638390; Thu, 21 Oct 2021 14:43:58 -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 r205sm6378507wma.3.2021.10.21.14.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:43:58 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 03/16] media: i2c: Defer probe if not endpoint found Date: Thu, 21 Oct 2021 22:43:18 +0100 Message-Id: <20211021214331.1188787-4-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 7513b54a2aa8..ae3902d3de95 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 Thu Oct 21 21:43: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: 12576685 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 239BEC433FE for ; Thu, 21 Oct 2021 21:44:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D7A36128E for ; Thu, 21 Oct 2021 21:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232187AbhJUVqR (ORCPT ); Thu, 21 Oct 2021 17:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbhJUVqR (ORCPT ); Thu, 21 Oct 2021 17:46:17 -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 96A25C061764 for ; Thu, 21 Oct 2021 14:44:00 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id k7so1571743wrd.13 for ; Thu, 21 Oct 2021 14:44:00 -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=9RvxVegX1FXBoOxhaC4k1bmOAp6kDipSv5INLjBBFwQ=; b=MJilh3lL4kjBbe8qBv26wuejT9Hz2v6d5XBEsFjox28M9kVO3InU9Gd+2P/kE1oTVh gr8Io4TIPhfhSJOsfPR+J3kZsRTLT5AZosjzp+9uc+75juY9Hvosu2Dh4KcpY0MZpIda p6YRgFi74AN54/dGlN6wir+ytfCum/RbUJGUWuHQ8Lg3XCKniBW5EKuqbOlO6WKj/DkT GgOiHMVNsgj5A+ruCVhKb+FplJNootXSu0GTCwxZ4tH+4rtpNyVFFRyKUyepp2d8eoLz guoe7jMjWMAmsZouvkR5MeaBRujqFG6+5n8ogDdXIifkQwVKhIH1mJUrCXR5uetHmiTk mQ8w== 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=9RvxVegX1FXBoOxhaC4k1bmOAp6kDipSv5INLjBBFwQ=; b=c+690RsiAbzwSGExYwxXBCqXEW0cHIhp0hAVolzjydAgGfyYOrTnXMKYHkbZbMf/k4 aCambDd9YLPyD8yu5Gst+j/TzRwwV5Y/ow37cCm7QSawHWfwa1mjHVP2EK016A9t4MKH 2x49uF3pgwK8ET1iiNo81vonxFz5br+ol98cSSl6DnKNzV7gjQ9be40ppT8gyZZ0uiR2 DmmAJkuUs8o40zywqXOK6A5L6KKZdwN5epR3W1a4wDCcsf+VI8f6lfIkjvfjq3gT4SSX n73rErRIByak0BX9RJmfPYEiqDov7civhF/XFZo6lj3tKR1304DO9T+ffhZ2bRd2wav8 SM1Q== X-Gm-Message-State: AOAM533e0X4TRwVn78KiofdOtDTXj+h85wElZkcnzgakaMDf2nn0OyHV L2kIScwbHX/7US1RFnjVCU7+ZiGoR1I= X-Google-Smtp-Source: ABdhPJx2rmDik9Hobn8cg6hMIa32V8HIs60ouz9UlBvwZup7t8rWjtmwoWmoo0Mgg/BfddxZs2ZXjQ== X-Received: by 2002:adf:bbc2:: with SMTP id z2mr10492346wrg.359.1634852639268; Thu, 21 Oct 2021 14:43:59 -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 r205sm6378507wma.3.2021.10.21.14.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:43:58 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 04/16] media: i2c: Support 19.2MHz input clock in ov8865 Date: Thu, 21 Oct 2021 22:43:19 +0100 Message-Id: <20211021214331.1188787-5-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - Switched to a frequency specific struct for each possible frequency (sakari - hope I understood you right here!) 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 ae3902d3de95..23e80d8114d7 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 Thu Oct 21 21:43:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576687 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 37FD1C433EF for ; Thu, 21 Oct 2021 21:44:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1ED8A603E7 for ; Thu, 21 Oct 2021 21:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232192AbhJUVqS (ORCPT ); Thu, 21 Oct 2021 17:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbhJUVqS (ORCPT ); Thu, 21 Oct 2021 17:46:18 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9420C061764 for ; Thu, 21 Oct 2021 14:44:01 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id u8-20020a05600c440800b0030d90076dabso7896264wmn.1 for ; Thu, 21 Oct 2021 14:44:01 -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=6q8zbUSbQQbOo/L1tTIpt7sLV2QEP76RgaqAvhzS0t8=; b=CY+RbVENe3nxfyGLrYtAEsw+43mh9hfYU4eJg0PsMsrySZRtprPiL+ImIH2nlqOtNU gB/SDSzLSO5yvmlAjoCAkbkAPgZDVuSLrFqRfxVcPEPNS6Qg/xK4FlWEl6B6eHqBrOxg 9VusoNBaJiOrO7HFEJC8EjNq6wFjQM4OtrVo6tO26oBRrU1vwHVX/Q14Znmgm0nezL6i WFm8+qBpy4VQPIJ4ODTyJIMws+xQ9KIa2hDH5s+i1UYq4dGzADeqddLB+QJpHXeLmHOI zvd5kUKoGchBxLLcpAty6Fdlka3+jiSKgo2s2MzCQiiSMY6f5yXOlz89q7AHDrYxB6/N Qrog== 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=6q8zbUSbQQbOo/L1tTIpt7sLV2QEP76RgaqAvhzS0t8=; b=Tf5gG5YZBKePG7fBA8Ou1JMPiipW7x/hRpSZTgiMl4CtpxHBfdEkqHlIIl4bWbr+v7 Oy18eD5YFB3tHEpcwNB74ZxnwYfBNDEkpm5yGJVnplhzqE4KvogOqrZyw0sGhe4Ke/FQ BaVzCC89mtsRMQnQGv5CjZOEfSNIAX3O+wFyJVgHVvZtSbVZ4xWBENOineQukjIA+ZNX jdUA8kaLQjRqXNT1cUbJbHzaTbOy99JNVFj/rb6oC9k/bt85AzK0czmVsp62CwqiJ8I1 bz5hFKhnGhU0rL2Gn6ynswTglujz87F6Wwu25GC7K0Gg/DvehvHhvy9TjotDu6LbWppi gfow== X-Gm-Message-State: AOAM53116ZL4LFZqoM5i8GdL8bKBC/yyGGqqt8k5t6g4fqgu4qqtQUeU TbmfTv4+hzLntu9/JdbIctrYAw3JMdM= X-Google-Smtp-Source: ABdhPJzS71ptcStFBRa/tQJZhwyykjl76C5ZYvESvgCzDTdeSv6ers105htN50MwR4Q2VEp/CVFstg== X-Received: by 2002:a7b:c441:: with SMTP id l1mr9185899wmi.69.1634852640106; Thu, 21 Oct 2021 14:44:00 -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 r205sm6378507wma.3.2021.10.21.14.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:43:59 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 05/16] media: i2c: Add .get_selection() support to ov8865 Date: Thu, 21 Oct 2021 22:43:20 +0100 Message-Id: <20211021214331.1188787-6-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - Used the same function for .set_select() (sakari) 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 23e80d8114d7..c16b31f13e37 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 Thu Oct 21 21:43:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576689 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 0D330C4332F for ; Thu, 21 Oct 2021 21:44:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBDCE6128E for ; Thu, 21 Oct 2021 21:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232195AbhJUVqT (ORCPT ); Thu, 21 Oct 2021 17:46:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232190AbhJUVqS (ORCPT ); Thu, 21 Oct 2021 17:46:18 -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 38A92C061348 for ; Thu, 21 Oct 2021 14:44:02 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id y3so1353960wrl.1 for ; Thu, 21 Oct 2021 14:44:02 -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=6vLlz/ma2Xjm3BA1QgDENMrA+E5R2qMKvxxwoPgy8nk=; b=OyYD/jsNhYpw2B+69cskht1Sm8rnWFr3NOR4PXBZCLVWfKkhBGmPNnE+ACaueMixEz IYsG8XlIrM+r6ChS0AWJUxLpX4+in4WcHRBJEXo2oyKs2OPiEXK//u1vhJlJKAR8wWQF Nn9KbbMW4CbeKty5lwweke+ytAJE1CaQd62GY2CiX2wIxemvam5ZytlxvmRCHHnBbTUv 108+SgZ1seIVB+N318B4Gu94ladx00Y13RZPiGzd+8Oy7sbaVxj93a2Opi1XQ6i3We8h 5tloYboRy0Dww2fmsXuZ6/5c4iPYDqOr2yBuMtjzA/r9MObB8v90zz4DWRK3mWs831se Uvyg== 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=6vLlz/ma2Xjm3BA1QgDENMrA+E5R2qMKvxxwoPgy8nk=; b=3dYZk0P6TJMwMqnk7i9VsKYpkPiGMEeWHKg7zeX4eAK3hI9W3K7abpBkQV3D8rOoY3 BYPvCFyjH9D4aSz3NsHdoGd0PHhLNqomFDVr+rvktc3Q6e2+mjqdBuwxWMO7DXEnxvIJ mDFdOc9Z6rYjYUSDeoIv9fYsrAXk88w6alKIR+uZsiyXm/jYuwcK2oqd9mnzikai5Db/ aV+IB0pc2Hc4Qq6fUVIeHBsssX8ovjVKNkGTgYhMkS3UONdC9vwuVKUYxAtB+/0Wqh9w KvVVtygm67SumPbATovz783iIHxazfXn4XWv8CjInizuKapfHgxaY2WJJiZg8zu9B1Va 0/mg== X-Gm-Message-State: AOAM533P/yYoX82Qei+0nxyPm+DI7dLzYEEJ/Z6PsgRD7aK1osPFAjya v//6aaY9n1eQ42yPQFCj5XKanFHNU/w= X-Google-Smtp-Source: ABdhPJwqkqZ2GgfQW/rp5/PrCLnNEtv/GfRub1HV/E3LEWmEwGIvpVwtpGX/S31yp5u9FPf2V5zj6A== X-Received: by 2002:adf:8bd2:: with SMTP id w18mr10620495wra.432.1634852640928; Thu, 21 Oct 2021 14:44:00 -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 r205sm6378507wma.3.2021.10.21.14.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:00 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 06/16] media: i2c: Switch control to V4L2_CID_ANALOGUE_GAIN Date: Thu, 21 Oct 2021 22:43:21 +0100 Message-Id: <20211021214331.1188787-7-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 c16b31f13e37..ce7e7da6ae92 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 Thu Oct 21 21:43:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576691 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 D338DC433EF for ; Thu, 21 Oct 2021 21:44:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA23C603E7 for ; Thu, 21 Oct 2021 21:44:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232206AbhJUVqU (ORCPT ); Thu, 21 Oct 2021 17:46:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232190AbhJUVqT (ORCPT ); Thu, 21 Oct 2021 17:46:19 -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 12158C061764 for ; Thu, 21 Oct 2021 14:44:03 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 193-20020a1c01ca000000b00327775075f7so1105257wmb.5 for ; Thu, 21 Oct 2021 14:44:03 -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=vqUWLx8DrSjUck5kly87/Hy7v743FYKVE6iviUutRY8=; b=IUygNOa+myxleGwG4iCk7KTNJPxJu2mc9EMfjdxpfcQUwSOhgbxm6K09CqTuiaXatL IQMTLyYTwmh0U6KBFeUO6cGsQ1FREfeU6N4BQpdnqtyHjCcoLqfXcUhHoT2JhgZwP5UK YCFLAgm76zCB17Mc7/yEgtzeZUOVFO2lnPm7kU0fF0C6eEKNekS4GOFVL7W7T56cSPZZ nxEtLUDS5T7xpvYK/fhsH4HHlmdGtXv7X7u5OSbUYsMRZQtcYQkz9ZV3JkIOmAgpIDit 1T1uzvTxyV+O5i7om89gge8Wq1hXjy7v256s6Fj4j4VmzfrzNWa9g46SGAgOOc9BBr2q bVOg== 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=vqUWLx8DrSjUck5kly87/Hy7v743FYKVE6iviUutRY8=; b=e7ecSViKYeTYhEHEqbOwcOEmdqxtJlZzrf5ZBDipR4aXqmmvmGIUzC2cWQPKLxn1bx MfBtKOQQgJtEDzJ9Mw0SZl6OzYErzMIhWRwErjrti7TsbiWX5RMKAWinWQp+g1PQ7X/7 DXquRbUkQNOmc1ryIC27d1qLgrvqzyFkH5EOavcrmgBX/iU3+CLVNQsyTUXk/bpKwRrc ArmHbGIJ/n5hz+yrBNAyTjSmtEoFRsZUtObe5MCFPKZ8BZ3UG/+oFQsmQYz2L7lZQOJT xIbijKEwwFeuuhai2JlsrSHAVV5APPclyER6ugm6nSCOO//ZWPGwie+UTd9yTgiE7m7E S0yA== X-Gm-Message-State: AOAM532AA1WaurG1x2CNxGF9sn6yx/yXcs/qJ6JIlizJSmehwxcdy38G 8M8uCbIEP8jgCi49VLSaYL16B2qUUQQ= X-Google-Smtp-Source: ABdhPJzrjNtLWA+bPRc8I7UjpjxQK2UVXh1nVFqnaIpXF9TJvwo71PWfUUUYuIha4JCBHvj6CRkQ5Q== X-Received: by 2002:a1c:c908:: with SMTP id f8mr23856889wmb.142.1634852641747; Thu, 21 Oct 2021 14:44:01 -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 r205sm6378507wma.3.2021.10.21.14.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:01 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 07/16] media: i2c: Add vblank control to ov8865 Date: Thu, 21 Oct 2021 22:43:22 +0100 Message-Id: <20211021214331.1188787-8-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 ce7e7da6ae92..e1e23b3e4311 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 Thu Oct 21 21:43:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576693 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 6821BC433FE for ; Thu, 21 Oct 2021 21:44:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5133E61354 for ; Thu, 21 Oct 2021 21:44:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232216AbhJUVqV (ORCPT ); Thu, 21 Oct 2021 17:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbhJUVqU (ORCPT ); Thu, 21 Oct 2021 17:46:20 -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 E8658C061764 for ; Thu, 21 Oct 2021 14:44:03 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id e12so818850wra.4 for ; Thu, 21 Oct 2021 14:44:03 -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=RFoNc5WK3YuWxoh0RHxbwK62szBKgK0McCCQ1W0H+24=; b=dGyBmuYBf22AanxILdF9k3e7ZavrKl8bqsrndWSfrZi7XuW2fXGz51OQHHZrZpYQa5 DzLn7cWatXgGI1KfUb+OLYyiHmlrUjHXDJpk3w1a1a961vpoPXEx62RytlrInsgUuHwp mNi4c1/kdiyQFgw34npz9ibmA+vKUgg3em0QCHBOip3ScCzLGLNiwHPmJy20XVC0WS7H AFoSc6k3QMW8mLAifBZF5YdB3zFNLL5IsLk9q6MutM+IdXbGSV3Zobnc1kO7F71T60zc f/XNe1ZupCqGAot/e3nFDVVJuFM5xluJK0DzivqfvsFYvrEAiXi/fPbIvtB9R/1u0D1I d7AA== 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=RFoNc5WK3YuWxoh0RHxbwK62szBKgK0McCCQ1W0H+24=; b=3FxhW85rYHzpo6T8zTCizsO2MtV5kGUFCsGTGvkbrzykUz+MDZ6Vwi2Ziv7+IfFkaE w07CfJMY7R3ld3CYzyByKsx14zz/gddhRQHOB+uVtBg3VS0R/fuVwZsHpo06O8AJD6FN qTMdDVEKpj4xQOAfewmtDwWJmjnTNmfG1m0EFNe3zq8KQcWZtB8h0On2t0l2Q81MSGeR 26TDTxbb0oe1Ce6fkqOOAUk3TDHcmCeDMNm/zYsntN8Lj41M7VbiVvjB8/B4suT77aaM eyXFCOKp4ULDlFW7mhnknmrj+N/8pb0bvz5Jlg6RRCgODmsUilK0q5VhuBf+eoRqFqTH r2KA== X-Gm-Message-State: AOAM5313ZkX3lQhSJD7BghhL2cQ0BoLgoU7UqF8IoWBfzY9m8pqj+P3O OV51VGTrKthJAa/ghmwe1MEuz9ITzJE= X-Google-Smtp-Source: ABdhPJz6oXyBhfWbb/n8YWV4nJAS8WLW47Gyg9Mc8mRcEjzwaoQrAVASBYbPmdfzfbfkZnbJlCyGMg== X-Received: by 2002:adf:eccb:: with SMTP id s11mr3397639wro.22.1634852642590; Thu, 21 Oct 2021 14:44:02 -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 r205sm6378507wma.3.2021.10.21.14.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:02 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 08/16] media: i2c: Add hblank control to ov8865 Date: Thu, 21 Oct 2021 22:43:23 +0100 Message-Id: <20211021214331.1188787-9-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - Stopped trying to accomodate the modes where HTS > output_size_x 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 e1e23b3e4311..3945883a2ed7 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 Thu Oct 21 21:43:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576695 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 A8CEAC433F5 for ; Thu, 21 Oct 2021 21:44:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E23E61354 for ; Thu, 21 Oct 2021 21:44:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbhJUVqW (ORCPT ); Thu, 21 Oct 2021 17:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbhJUVqV (ORCPT ); Thu, 21 Oct 2021 17:46:21 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B5AC061764 for ; Thu, 21 Oct 2021 14:44:05 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id p21so961412wmq.1 for ; Thu, 21 Oct 2021 14:44:04 -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=wMW/murp3nNoMigJuEdrF8lzU6nIsdKWf9OT7JgAy/U=; b=JRaTyB8oKXifciAGtdPMNZ5wV+QKNcS+hLK2fvfmO41IXUbIFNkguEVureEidaOkxL rZG+FfrGbCZ/EMFZPSp53AXgOApITAVpwDVZEBACI9hbkfoETx5EmqLY/7YZGxVBl54Q jcjmQ73Tfwc5RJfsSx3Tf9IZx7Rzp/SLuwYdb8TBg9hONTXvHDiOi2VWQ/8UXwANcVNt WCIUt59wOeRnlFZ3ba0D+PfvK6Vi+pN9WAl4gjWkqFpv4SSZMjdlZfxHuhn/S8+oEhT4 E9Qan1cffsu5JP1nOMYdLoI3zSTvpl9QgWX0sE32McMZn0V257vKUsdI9sqQfpRS0r3I M2dw== 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=wMW/murp3nNoMigJuEdrF8lzU6nIsdKWf9OT7JgAy/U=; b=RF6dF35xLXzNsRF1oiJu1fFMRHHDxGZYxqMkXk1nyMrnhIQYy4o01sH90kHactN69a 6n1AsFHwjBBWQMoy1wEkvR2G+WEtrX5xm2QjjVFBGPRXAcd6R/ssvki3PeU26//EFNgK 0Y72BVDA3NlCz88zpGm0XF7asveQF7J1NsV5qZpDq0VvjBMFni64LUOu7VZbSOM3F+RM RpykgiWhJ4qBbkxyqq3FXB+KIGWg1L0NyGbnyPKtSi9YfYNlk/XMX/lmnbxudwyCT5AK Fkc6xMDZEWSDlxj9P8oo+xwUm/3jPmjsCQBBwG7iKibCI6iHGu04d6tIyVJTDT8IX9Ol RjqA== X-Gm-Message-State: AOAM5314jXqbSE9U9aYaQsSJ1ZaVh7Uqt1NWRl3KuA7SL/rbMkq60b9D aKpElk+J0FdZs78EiounoaOwhoZAYX8= X-Google-Smtp-Source: ABdhPJyF2yBXM53gavak69XhmrzPVlhijJJvL0+BYKqaItzjrcq+WtDTOXWTfdfEI4a3UFNEJWrOqA== X-Received: by 2002:a05:600c:35d0:: with SMTP id r16mr23751586wmq.97.1634852643600; Thu, 21 Oct 2021 14:44:03 -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 r205sm6378507wma.3.2021.10.21.14.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:03 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 09/16] media: i2c: Update HTS values in ov8865 Date: Thu, 21 Oct 2021 22:43:24 +0100 Message-Id: <20211021214331.1188787-10-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 plus the number of data lanes detected from firmware. 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 --- Changes in v3: - Patch introduced 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 3945883a2ed7..dccbc23afd2f 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 Thu Oct 21 21:43:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576697 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 92088C433EF for ; Thu, 21 Oct 2021 21:44:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C5196135F for ; Thu, 21 Oct 2021 21:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232259AbhJUVq0 (ORCPT ); Thu, 21 Oct 2021 17:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232230AbhJUVqW (ORCPT ); Thu, 21 Oct 2021 17:46:22 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF71BC061764 for ; Thu, 21 Oct 2021 14:44:05 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id i12so1604895wrb.7 for ; Thu, 21 Oct 2021 14:44:05 -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=dLvw5T1WDItF4vTR3Zgsm+pRVTM/FpHw0z8/bM9ZpVU=; b=Krkre2RdpZa8/7YYOZ+pedJhM0XtWg8/KUgWvvHXLcED+W0u+M8/y9h0sUfAC1/5L2 Aqj1NkkYppcJdlFZ1BHtPjTk4Q3J0REhZ0ZQkp5dL82EbfSqzYOfi+DKilc4Bv6pbW0J PpB8j8us4foChGOZ4YyRiJAy+95esQNp6FAORcJNhyPIIbe1eyjJsosAVAE0lk84zTwI YuHNJTzXbXOwL5MNqUDRmveBJqXx8Qzk8P3IXPw4xzxz4fKoNMQ8cJDUsaxFPb0heohd EfilEAC3JxzGyykBuLlnWpVRykAjt/CTYan0wXKWep1Xyxg5gvUUm86gawCaAy4JTrwp 0eow== 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=dLvw5T1WDItF4vTR3Zgsm+pRVTM/FpHw0z8/bM9ZpVU=; b=kni8rLchhiBF0+/aKVM9vBY/sTQQygWyk4XiOPYIkF1j11nJMGP7feXfxuaKPzbGZi GqUSYmE9NT0beDg0prFCygHxpu8UuxtpoUuc2Py2lDZoSZIpg6YUqBWN3Xe9PFoEHpg/ GrWDesDZ0CQdWPhFk3FM2T9cTgSMUddLdchF/uGLRN9Fbs5Bd0E/z4+QVdb5kImxui5f XoG9X7BTKimrVp/ZvFnhWIZsWuVimddSKAbxaiWoJC7nkwKdbZkJhdzFEWYDikkz2Svv jT/xo+OkYoMvQ1YGTL3soFNV9I9W/mCn7xN0uPUtZoJWc28bUwkPhBvyZhiyCOrLyywS qAVw== X-Gm-Message-State: AOAM532FNwqJ4lpY/yDFGFfgLaU+ji4czpwwGYlUFibl0rIriEVTZXnw 6QhN7Fy+EaF2RNDGBhkZ/Vph98VjCDE= X-Google-Smtp-Source: ABdhPJz8U4zccPlCvQG5V1Sj5Z6mkSyu7J4hdkMMVO1r3h9glJCBmqyYulUO2DMkOI0AQ+Jpk4xVtA== X-Received: by 2002:a05:6000:1289:: with SMTP id f9mr10516941wrx.192.1634852644550; Thu, 21 Oct 2021 14:44:04 -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 r205sm6378507wma.3.2021.10.21.14.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:04 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 10/16] media: i2c: cap exposure at height + vblank in ov8865 Date: Thu, 21 Oct 2021 22:43:25 +0100 Message-Id: <20211021214331.1188787-11-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 dccbc23afd2f..16c5ce80353c 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 Thu Oct 21 21:43:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576701 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 0F587C4332F for ; Thu, 21 Oct 2021 21:44:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F07EF61359 for ; Thu, 21 Oct 2021 21:44:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232263AbhJUVq2 (ORCPT ); Thu, 21 Oct 2021 17:46:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232233AbhJUVqZ (ORCPT ); Thu, 21 Oct 2021 17:46:25 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F33C061764 for ; Thu, 21 Oct 2021 14:44:06 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id g141so932688wmg.4 for ; Thu, 21 Oct 2021 14:44:06 -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=vz+RGnr815S40szO261I+Y15bFOsQiW7l3SOXVgc2UI=; b=ew8s2YykeErG3e3hvnogp2+L3WcwL/bgXmBCqSu7hUA8pr6xubRa8tV4Lh9T0JuAg1 28JUh8oi7DKuequIbSo3aLyOS/LHdG3L/k2t5untsnklbAAwiobdQ7BZQKnaKq2wPcCS euAd7sYlYbgHxknaEE78iLdwIjQl8mE8hmD1qjuZNHkpOPU6KDdz7LbIqviOW9OE5uxR M0ERGn/u40zAw9wcwfAMkGxqNulh889N00kbyIH7YdZAk2VfK2jFbA8k/UufmqAEfDSq SEBm8UO6nyJe0KW6jaTBcnuj0q29XCKO+ZAtrKWGZoB50KkK54hzoq2RaT5sCuHkNerd DF+A== 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=vz+RGnr815S40szO261I+Y15bFOsQiW7l3SOXVgc2UI=; b=ms9u7kQgsd4RAcwczgnSidatfeN+9aU6vUJV40LSurXbpm6ZA+79K4Z82ymXewQI9q xQnr6bTvUJYfcuThnJPP2ZExspStJXny45LTqKjQfItiwHuLmOnpXNPvmawIcxdKkslY +h1dXNFA///HV+eyDQ1YgwiKRDfSf/claF8rAk94zLtOffc2NNAMdXUNGb3ymQ/L9rG4 MMJFFnzylN8h72mCo/Y1j7f2CbYvJYPiXA60n2ipqW8lZBRfT/mYFl/5Y9ryoLjWy9X0 QBv7ldohz1YeyBwXpIpwNts4nOYY6gWC35uPnutTVVTUKDuAay6HmWQ1X/5dI7yuhsyu 5ETQ== X-Gm-Message-State: AOAM530J8Olx2pNozPaYFIMFPZWCecDbpw2hbJ52ebccTtzmV5sxzXaD tF96J68a0XPq76zsL975BvJr6GTmvSI= X-Google-Smtp-Source: ABdhPJw1L8tBE5IIPT8Ggqm5MMqyTdrT7/2i5B4TdSoTVt1b0pxNMBmJ+idSjyAeqEs/PN8eXqHy5Q== X-Received: by 2002:a05:600c:2505:: with SMTP id d5mr9432891wma.36.1634852645425; Thu, 21 Oct 2021 14:44:05 -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 r205sm6378507wma.3.2021.10.21.14.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:05 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 11/16] media: i2c: Add controls from fwnode to ov8865 Date: Thu, 21 Oct 2021 22:43:26 +0100 Message-Id: <20211021214331.1188787-12-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 16c5ce80353c..5fec1e35eea5 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 Thu Oct 21 21:43:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576699 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 425B7C433F5 for ; Thu, 21 Oct 2021 21:44:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2364B61354 for ; Thu, 21 Oct 2021 21:44:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232253AbhJUVq1 (ORCPT ); Thu, 21 Oct 2021 17:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbhJUVqZ (ORCPT ); Thu, 21 Oct 2021 17:46:25 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E814C061348 for ; Thu, 21 Oct 2021 14:44:07 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id m22so973334wrb.0 for ; Thu, 21 Oct 2021 14:44:07 -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=2JZ9/8cBu22M+2eTYtbMSzCqMZGrUlTquwKJPNKV33g=; b=NJ5CLb9EEYAL5Btq1dU0c2dM+H1s1MeC2BIrfKxrdlh//UUC4+sIvvv7XIfpWdJsX3 fHj0qWixQXGTtRt3hHbZvKuAtanHIV7H57Qxj9OH/yaaxDARI0EIrExPZ23DtphvJYT5 TfddFxLaQrthyKQe2MZ4U1nZ1q8ZI6+feBw1L6rzDe6mJGB4x95DMJjHWKNF04zItDCN HUvoOEINqW1AlGAlUt5o30COuyDD6HomGB0CkmOuIGh05r0mRTrAMDiJdlKFLFD1KY+7 6hs/tkPz9FBOoQapgPYYhgke2h9+Yp6ZE921fSaoU3FeoBqDVaSz6u55tYefBXwtc24Y fseg== 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=2JZ9/8cBu22M+2eTYtbMSzCqMZGrUlTquwKJPNKV33g=; b=YPIoPuKP6+p/RPuBzUujUO4sgVrMx4ECTZrAHqhcjJX1DHd8o989Tv8Xg1oWJBVwKq FS1uaIGw1R73rMfMFhgDtheOsvAiiWabsxcEF4U7Ri98Yv465kDAT6H7MXM1yzu0gTgn 3xoI503k7PdUlwQj5o6UKkwSLd2PclkOgEXCuvz3dyLoLSRzQDwJW5HzhT4Kgoy3unYm QR6kGSqynsmS62jbK8RqRzvVtmyvxZkcnU5t5Ysze9i1ibd3YiiP7Ench+NG0/aANuYD wMrNE0lDjspmU7M+8IEnGys0HAEsDQ/vHUUlGaXPs+ceCM6noEISn/JW9CzpodLTrhWQ +VPA== X-Gm-Message-State: AOAM530UaYlG+mE8XXv2ENf6P/SL5ERzto/UVENyaqtgKgs6QCePyKfA uRNhhV1AF8vv+jFDbCpTbZ6HR7cn29g= X-Google-Smtp-Source: ABdhPJzQ5D7+iOw4AUzwdONSnaiVC737O/4/10UsEO3y2tPefzirITevhZkjW7gLLqsEBYh+17Ui+w== X-Received: by 2002:adf:8b1a:: with SMTP id n26mr10490260wra.182.1634852646318; Thu, 21 Oct 2021 14:44:06 -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 r205sm6378507wma.3.2021.10.21.14.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:06 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 12/16] media: i2c: Switch exposure control unit to lines Date: Thu, 21 Oct 2021 22:43:27 +0100 Message-Id: <20211021214331.1188787-13-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 5fec1e35eea5..0bf3f72892f7 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 Thu Oct 21 21:43:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576703 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 A69ABC433F5 for ; Thu, 21 Oct 2021 21:44:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9045E61359 for ; Thu, 21 Oct 2021 21:44:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232268AbhJUVq3 (ORCPT ); Thu, 21 Oct 2021 17:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232249AbhJUVq0 (ORCPT ); Thu, 21 Oct 2021 17:46:26 -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 692B4C061243 for ; Thu, 21 Oct 2021 14:44:08 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id k7so1572126wrd.13 for ; Thu, 21 Oct 2021 14:44:08 -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=qstZiRiLUFrlQU1DowMt14WiuOpUvjb5Tv4Ka3RUSR0=; b=UeQXXz5lrF3f3C0uBTi9jvimjXWehy7Mz/klAybFBdWC/Po3V8LobKahtL5taFqDkX jB11F8oCJIR/kmcM1nFSZR97BVjbSY+3O74Jo+7lx6d0BMO1TNPZhcvzIJernUTiUVkE 3lZMN6K8YMjut/IuSYwM5v+17IcgndyaW678yJaZQCRcvT0QKF/YArEd3KQ3a4wR+GSO kgvpmH1I1Mdit6Y6rQKc04rmBrQcRhwmyM1c5gkSze85Cl8tsc2d5COMNhuTZLmTWdu/ MNNWzReTYEdBL78gwF6ChTC3yoeUM5dPJslVe3VMR2v/fKVH86IjofwkeOZMtqmLRcE6 0oTQ== 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=qstZiRiLUFrlQU1DowMt14WiuOpUvjb5Tv4Ka3RUSR0=; b=E5+B4glfbcZqSJ2NkHBZS0IIEUA4Sx0tBtjLQaQjOP6gnA8Q3CcJVheHkP/1dbVTGY Mnj+4NXTj1aCr6+EhuV+v6BBADYTJZh26r+PQSlap2u5E6LbMP06SzzSdNB4xAq+wEvw XBFiZ0wngV4jKxqr48SHAslMl8LPg742Em+dvJLMN7fvFTLURHWOnLEBMWThJzI79HlH sBeLSAANpucSICRBLJ9N4dB+penxEVdnSCwjv4Q7dAgKsWN40lJu6K0aYl+CwiF+d5gU R880/B/+Kc5Qbvw4GD2VnBB5z2kN+B9C48DOgQ15i6N5nUA/cIKAKkmCgGP0p1ZVgPJJ znLw== X-Gm-Message-State: AOAM532rRkL+sk1U7/8136858UhZTZDXTonAZRi2vCYWmyCELrESMeqz d1Rlmol4k8tB5Xb/eLxIs7vazjMnevs= X-Google-Smtp-Source: ABdhPJzbMwblFyWbfKKgBW2DezxustAG2ItKFIYkILc7P4leeS7Z0lHna91T53eNa0kyRie2E2QEuA== X-Received: by 2002:a5d:59ae:: with SMTP id p14mr10366405wrr.76.1634852647205; Thu, 21 Oct 2021 14:44:07 -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 r205sm6378507wma.3.2021.10.21.14.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:06 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 13/16] media: i2c: Re-order runtime pm initialisation Date: Thu, 21 Oct 2021 22:43:28 +0100 Message-Id: <20211021214331.1188787-14-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - Patch introduced 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 0bf3f72892f7..572b9818e950 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 Thu Oct 21 21:43:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576705 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 45986C433EF for ; Thu, 21 Oct 2021 21:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F98E603E7 for ; Thu, 21 Oct 2021 21:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232271AbhJUVq3 (ORCPT ); Thu, 21 Oct 2021 17:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232258AbhJUVq0 (ORCPT ); Thu, 21 Oct 2021 17:46:26 -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 6986CC061220 for ; Thu, 21 Oct 2021 14:44:09 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id p21so961593wmq.1 for ; Thu, 21 Oct 2021 14:44:09 -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=W6hpRDl94S/Eeu0a3abgL9PES9y85INw0M97kjxmgOQ=; b=Ih/Jcq+oOxg2Kc7BYSo87rAgWBvl4tnjkQp60ggKpyZcm+chc/h83C6yY2ilTRiEly mP518M8x8oG5H78DIKDfnL6N9vBhs42YVO30TqyVL8W7pgCBYWwLV+vMP6macJmIvUc2 mCqxM2q8sec2A1H41v7Q+WfJeAEoHPNOy/qQkD1kYKKblUVE62wG4IG8rYbWHtX2sgoJ syDohBYrMIy612tYz36mlYKzku3InNUak3AXoml/GTIYuoD9hoo8VH1M1vE/qMd9i12y 7pBUXMxWn6YKLjBFnOknfM5T3qtrHIlmHLOj4GGGVYLViOgR7+zWdf884vegDZUjcIIX uFpQ== 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=W6hpRDl94S/Eeu0a3abgL9PES9y85INw0M97kjxmgOQ=; b=ytiGT+7iRKdu9AtMKkZzTviO40+DuqYwlKkx/aqvpbqRzZup24Hc8tx6uC73UCuznV UTMtXoVPojA8yvsdDl0yavWUch9MLxpn+nW8YpS7GdiGpgAR9MFpBqqpJgCLjgPR2g4w vF3OsovaoJF5KRnWNM1Tk3gQDGHeDtHV0ImWPJWDFsOFHlQ6cB2J8f3Jy48PUb372DAO Py6zJ4pXIdns1g7DF67dUOsJiphqy0AvTkEHN10zkzA5mNNfMhhoqsMFDeLRDDQaP/0G zDsmzVMYcfy1Zgo2SI0yxbEPM4H6theHk2cBC5dZ/oXDqWalhAsDISuynCv8lKNKv2t/ W2Ag== X-Gm-Message-State: AOAM533e3+J6deHg3/hKBTQ4BI4hc+DAS5kqvrnD8p8k+TN1evnOGnfM NiLanVUrKh1DjzaNAw3bFFZkHibwFjg= X-Google-Smtp-Source: ABdhPJxKxUeisc4f4VMKftmhh4FGBPjPd/LPlsam1YowFPl5sYnRU5PYzYrDDDT+gh0Pcr0UXvu12A== X-Received: by 2002:a05:600c:3b88:: with SMTP id n8mr9222297wms.93.1634852648059; Thu, 21 Oct 2021 14:44:08 -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 r205sm6378507wma.3.2021.10.21.14.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:07 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 14/16] media: i2c: Use dev_err_probe() in ov8865 Date: Thu, 21 Oct 2021 22:43:29 +0100 Message-Id: <20211021214331.1188787-15-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 572b9818e950..685539744041 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, "tps68470-clk"); From patchwork Thu Oct 21 21:43:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576707 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 BF33BC4332F for ; Thu, 21 Oct 2021 21:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AACD161371 for ; Thu, 21 Oct 2021 21:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232274AbhJUVqa (ORCPT ); Thu, 21 Oct 2021 17:46:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232261AbhJUVq0 (ORCPT ); Thu, 21 Oct 2021 17:46:26 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EDB8C061764 for ; Thu, 21 Oct 2021 14:44:10 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id o24so997447wms.0 for ; Thu, 21 Oct 2021 14:44:10 -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=sHrUsYFVYm+IkCidB9wUGrczs/x78/ITOW6ys69BRks=; b=LlMNKP/J6vlxUvOjfHav6NuhYch26Feoz2LDmkB2ABpNm41LB2DsOZVafnud9AIagf Ae8N92ZrJAfOTj8OVb3dbym4XAhVnubs6EYJWQa8gE87340OnNoCjGdjwjz8GsmZk7wK 7tQZC62L7dfOpWOY/pGSbPsKo/SY1jpReP9lLoLkhdIfWmH6Xgwx0Haihn1dbuGs379H jjn8jUP7tld+ShvZRRHnWc7erXP7nNS1IzqyAya6DtjKFaobYWQwHCkDxUe40sc+kpAM g56m7Xb2ti2MY/SOfcL7JLVHOtGqA69YZo2CAdrllDpwIxAokEGSDBuThtNUx6WIIqrl jekw== 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=sHrUsYFVYm+IkCidB9wUGrczs/x78/ITOW6ys69BRks=; b=SiggLeSzKApz1wIqwtr3vdjRqyxXjjoj84x8W//reu6Lsq2ZcQK2+zbc4NUtPdFkv6 rkgLw2+dDN/2f/lvvTMdsYcdutAkWjPsQhXT5zo7W+1BU783D8uhc+shY+vN/h9CKFHX cvRDLfzpl6XvJxVIe2t3XrBVRcb/JtEazypFSaknidWY8shTD8pfPpui4PqUM06vdrMB yvpiHCRKR79CkWDFT7bZ5nlJ1VTRPfwHwtq9cH1DKvecPNFFuSr+/tn4+Nq/wjY7MtVu KyIitU9iGnAaVS/CAlVhoE5h8fjsywhYbIpXxdrk4joFXzxRMAGVg6/s6g8TfOQxIY5O YEgw== X-Gm-Message-State: AOAM53318cGE9Wol+o88q9x5LpFc9ipHTxCFihKQoGWCwI0EzDdYTg9b XXOVM20ePnWgGPj6tEUn8ABh+21w6AE= X-Google-Smtp-Source: ABdhPJxk0V0gdHC+Azy/CDp+kZlkAHqz2Ty0lVC1tOh2ovOjvYvTSaji6BspBb9l+IYwGfWhavxoBg== X-Received: by 2002:a05:600c:21c4:: with SMTP id x4mr24303974wmj.111.1634852648944; Thu, 21 Oct 2021 14:44:08 -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 r205sm6378507wma.3.2021.10.21.14.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:08 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 15/16] media: ipu3-cio2: Add INT347A to cio2-bridge Date: Thu, 21 Oct 2021 22:43:30 +0100 Message-Id: <20211021214331.1188787-16-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - None 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 Thu Oct 21 21:43:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12576709 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 4FD92C433F5 for ; Thu, 21 Oct 2021 21:44:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BC6B6135E for ; Thu, 21 Oct 2021 21:44:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232277AbhJUVqa (ORCPT ); Thu, 21 Oct 2021 17:46:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbhJUVq1 (ORCPT ); Thu, 21 Oct 2021 17:46:27 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 659DAC061764 for ; Thu, 21 Oct 2021 14:44:11 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id k7so1572264wrd.13 for ; Thu, 21 Oct 2021 14:44:11 -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=eYXk6mu1t2LWygmapm0MdeihIPOCQMZuJBpibJeSFrg=; b=pipLd9DaH9X9ot+mnSW7A9glsVMiXNt8jyPO6ryvQPeufIgoWxUTYpO5pxiziBFTiw /wfs81v1wfp5uuD964VhdPODilAzmvCRV/hvVnKdcV+oyYSYbKDeN6VgYEsVeo6fV516 zayL5cnKNaw3D/H1Vvtr7J1vallwZTvTuE7uBUTuERitc6IGcm5etPkAMVbp9UOK10hr bPKZP+BmkXhVI9ypnjyCSMGFlFDG8Lq+yB+FIcwdgRuuMihAWuwVHiBy/KpbRui/iSij tuTdZoOnGDFCddH8+2WpV7XXlq09e+BE9ACwihiJonKhGBkhuqVdxbNkimJQV5O4jY9k 6AlA== 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=eYXk6mu1t2LWygmapm0MdeihIPOCQMZuJBpibJeSFrg=; b=3B8Gcrs7G+/fsig076X1flLuxWTDQZ89KAT5/KyTDSqwr49xZST4OGu/rpM0KuW4LD gwElWJSjT+kfmdnaXYfaey6SosMkWmM1kV73Cg0p5wdBrSB+qY5DfYQ0H2/h2Hrr8J2t UhMVMj1XgHtsgOGoRmu2Wkhx881eKFgHLRiUiuNaP8GlTIfnr12mHIHCj2GtDcXxXzBY RP/kZ1ZehlZA4EvRZdE/2IAxL+uPy85S/sg14sCF8fBYZs9A+QvB2QVZS5DE9z4NJQZU y7ohVLQRc4ZemAGqTwczgOAweMC7ty/m04fw5Gzlg/q1SPxLLOtTdhulOcJ7yLS5GBb4 UB2g== X-Gm-Message-State: AOAM5312X8v/X9t6+3wBxHI9EaGSQeTSE/m6BgrulAW74mzEcwLFprB8 RVvjm28WrhpS+0PMINdLC7xWKSb/GAA= X-Google-Smtp-Source: ABdhPJwgPGAP5hFSP4iGuCwPIy0Br+h5i0piF24KZGoZ418Y4BJRsZaQgpqSb/QkgoOMR0hSjqK5tw== X-Received: by 2002:adf:b350:: with SMTP id k16mr10436592wrd.368.1634852650001; Thu, 21 Oct 2021 14:44:10 -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 r205sm6378507wma.3.2021.10.21.14.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 14:44:09 -0700 (PDT) From: Daniel Scally To: linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Cc: Yong Zhi , Sakari Ailus , Bingbu Cao , Dan Scally , Tianshu Qiu , Andy Shevchenko , hdegoede@redhat.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v3 16/16] media: i2c: ov8865: Fix lockdep error Date: Thu, 21 Oct 2021 22:43:31 +0100 Message-Id: <20211021214331.1188787-17-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021214331.1188787-1-djrscally@gmail.com> References: <20211021214331.1188787-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 --- Changes in v3: - New patch fixing a problem Hans noticed - thank you! 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 685539744041..27179f1d5cb8 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;