From patchwork Mon Aug 9 22:58:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494628 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4294C432BE for ; Mon, 9 Aug 2021 22:59:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F00C61002 for ; Mon, 9 Aug 2021 22:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236943AbhHIW7V (ORCPT ); Mon, 9 Aug 2021 18:59:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236935AbhHIW7V (ORCPT ); Mon, 9 Aug 2021 18:59:21 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42C94C0613D3 for ; Mon, 9 Aug 2021 15:59:00 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id l34-20020a05600c1d22b02902573c214807so526903wms.2 for ; Mon, 09 Aug 2021 15:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y+CnuUk1MG8+nD9ogP5Gq1YiYRDWMee14Is8W0ErguM=; b=Dl63A4F6quXuq9FDELX65373t1MLLPMaxlWBDljwOJpR79qJseGxswbhv1ctEsnjwS T7bvJXbaYCIgWcddKx4wj2+3Dd+YofnYq1gQdMgB7NcJg4LvdNUCE5zyU97KtBVqbb7K C1aQAFhaBXz0zcROIFL+KQ6iOzMIi8Ghm6mseBi+WwhPG/7yL/vMbHd0e66qKzWo/V6j xEhHGnKDpXA16fs/UK9KsZ0mw4A32JPr73LuzNab2nVaRFfAnqDvjRds+yz/34dRNLdu BzyA9PJW2TaZVCGzv98yfNfyu8vrm4YnzJVB3nKTMvFDdeOc7VGt3ZzHLGd/7e+j8CPE PntA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y+CnuUk1MG8+nD9ogP5Gq1YiYRDWMee14Is8W0ErguM=; b=bKgpM16GNbFC90bYB+EsOVtvzhlaTnJhDiwT82J0VX9kuOIdEJ6PDcvxDN+c9P+LCO 95iuSBwdLCvoLt9FfuXk7+ZGEikg72wTCMOthd+ZW7jj1aKbi5y5tupjZl/TwyDnnuWx gu78wsZM0ZYWrcNv6Yni7lfzxgvIjoLOUh4qN6uRQJhKkHrkK5u3f+3gNnVnIjHHni4I YvoBFPuNmbiLWATcf0nsxyoApCtYF8xsiMBe6dhDyjFLqfZsptUtHJ0inQy2+l/xPHC3 cT2eJGF1ja+z22/0DPN4ToCJS8hNB6oNvdx+wJ6vywW5txZiRzinoxsk4XyP0knmCaCC wNkA== X-Gm-Message-State: AOAM530f8B+CPHOgSLGqLQ3k5G2zPU7on/CyMsT0y8iTIbeqOLbIt0kN jolv7ST2ZkpJ0hOAqX7O2II= X-Google-Smtp-Source: ABdhPJzUelipX/Ut3NHsZ/DI77imklltpETnbFt/ibjd0EW0fQXMq0dfQzRh/SISo8z2BMJC+Lc82g== X-Received: by 2002:a7b:c399:: with SMTP id s25mr1376766wmj.180.1628549938892; Mon, 09 Aug 2021 15:58: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 v12sm20437957wrq.59.2021.08.09.15.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:58:58 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 01/12] media: i2c: Add ACPI support to ov8865 Date: Mon, 9 Aug 2021 23:58:34 +0100 Message-Id: <20210809225845.916430-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - Fix the new include to be mod_devicetable.h, not acpi.h (Andy) drivers/media/i2c/ov8865.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index ce50f3ea87b8..cf6cc55e8506 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -2946,6 +2947,12 @@ static const struct dev_pm_ops ov8865_pm_ops = { SET_RUNTIME_PM_OPS(ov8865_suspend, ov8865_resume, NULL) }; +static const struct acpi_device_id ov8865_acpi_match[] = { + {"INT347A"}, + {}, +}; +MODULE_DEVICE_TABLE(acpi, ov8865_acpi_match); + static const struct of_device_id ov8865_of_match[] = { { .compatible = "ovti,ov8865" }, { } @@ -2956,6 +2963,7 @@ static struct i2c_driver ov8865_driver = { .driver = { .name = "ov8865", .of_match_table = ov8865_of_match, + .acpi_match_table = ov8865_acpi_match, .pm = &ov8865_pm_ops, }, .probe_new = ov8865_probe, From patchwork Mon Aug 9 22:58:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C859DC4320A for ; Mon, 9 Aug 2021 22:59:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A92F961002 for ; Mon, 9 Aug 2021 22:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236937AbhHIW7X (ORCPT ); Mon, 9 Aug 2021 18:59:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236935AbhHIW7W (ORCPT ); Mon, 9 Aug 2021 18:59:22 -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 52821C0613D3 for ; Mon, 9 Aug 2021 15:59:01 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id o7-20020a05600c5107b0290257f956e02dso530896wms.1 for ; Mon, 09 Aug 2021 15:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JFSSjbYlqWNB4qyyIhcdKV8vrcXxqSFwTVgPJEd6FCc=; b=XQqTfvIGHizXJuQgCq/3+/BsVg+DPvWb3xaXu40GXPQhsw3F+YvKIJZ7G9nuXeMWA+ VSBJbDBduCiGipav141lm69mgK8GRT27dY8xq4yZHQMwvQtl3le0TeRmyqf4SXhb+V3y /4HNBavnmPN64jHA3v2w53SxRLBYSyt2ExV5/y67pA+dH7bRM9hBw5kkmdAibmiVUT0g lFJ1H5mv2KyFh42VM0jSc1R5Uuv5kfmdKhn8ML62zYNkYV0RMG8HUFLtdcZ2ylR+kSR2 pD5qKZ9X37GRxDuqXkOFv0FPgF66hYXvxzo5w29w/NGycyG02pRD5sFJ3mmm8LtNlkGK d/XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JFSSjbYlqWNB4qyyIhcdKV8vrcXxqSFwTVgPJEd6FCc=; b=CkwvLAEYbdqD6fK5HRnJlRnE7NPaT+97AZmTBMxeCIeSx7p2IU/v8I+5aOn0eLSDOy EzprvjVolv0qZ2+rf1dsarrtqtfLT81FQcxSLj20RBoAP/VH8umE3Jh6EppzcbnWB6wM fz6IJKkIrsGQ15PsVQsFSNU6CCmhpgOo2ZkLdLzCt99ED0E7G2cku+jbJvEblZLDR89A zRN4Xe6zf0YC1fXG5L+iAE0YAtPSZuGHXVT3SQ1w/uEfgaQItOtclKdkpkcbP+SpaZPz u0oY9dWA5YwO94h0hrrOuJ48EzGroL6E8I2vFQUcGJIJNRugpAVJTCzEQc/+yV2orkvx IpJw== X-Gm-Message-State: AOAM530h8vSf85i2raasxsZ1PoRuabJHqGvBHv2i6gHZpxz+TR5sKvxv 5SP9URkuBtZGd6LLE0bidfQ= X-Google-Smtp-Source: ABdhPJxrG5LzYOMdmOOrajZMFO8fwd0yW49u902vBqaN4UQsLzp4hc/NpwsIiKEqW7mTma3S1xU5xA== X-Received: by 2002:a05:600c:4145:: with SMTP id h5mr772009wmm.7.1628549940020; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:58:59 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 02/12] media: i2c: Fix incorrect value in comment Date: Mon, 9 Aug 2021 23:58:35 +0100 Message-Id: <20210809225845.916430-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - 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 cf6cc55e8506..8d973117f611 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -713,7 +713,7 @@ static const struct ov8865_pll2_config ov8865_pll2_config_native = { /* * EXTCLK = 24 MHz * DAC_CLK = 360 MHz - * SCLK = 80 MHz + * SCLK = 72 MHz */ static const struct ov8865_pll2_config ov8865_pll2_config_binning = { From patchwork Mon Aug 9 22:58:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8E6AC4338F for ; Mon, 9 Aug 2021 22:59:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8B4F61002 for ; Mon, 9 Aug 2021 22:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236940AbhHIW7Y (ORCPT ); Mon, 9 Aug 2021 18:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhHIW7X (ORCPT ); Mon, 9 Aug 2021 18:59:23 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60FC2C0613D3 for ; Mon, 9 Aug 2021 15:59:02 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id f5so7709541wrm.13 for ; Mon, 09 Aug 2021 15:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KHFbtNkz90a+ly2u+ADdo6w6sm7cKULDRnnThID+zhc=; b=CjiSMJMmSHxGmgyj1ig1jtpYktq5bUjp6CBXvuIMFi1WHG6t0JFAKjY6zFPPSSTpBb SYXzJTiIK5VHRRB6KWDIoj7Oz/mZaUe8NcwvZv7wcZ0KzK8BjNnvWnWpRr2+gGDo8qNJ ql/Hop4mvzMwX+GHQ8HyW3AHJL+/ezqQMPYayF49VdewANuUgOyOUurAfmfZjh2othep e7etM67pumAgJFkbwfQU4bBkveERBREfQpMn3cgjOUss7qeI8cbh9Yp8Rw2QCJo/SIzo jYg9jr9ROkWZkbq2ModcLrrZKQSeEiBUxyQ4l+gKnL5qpG7qTayjlJT6FKymuwS821jQ XB1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KHFbtNkz90a+ly2u+ADdo6w6sm7cKULDRnnThID+zhc=; b=gGvDnmAMHTVOPzQ/8YEkmdpiIrAqo1ezI2/xV+aeuqnbF6PszFsVdrSWF7q6vUpgHn wOa4EfY7RIcI4g6eE4fjjpfHOYGaWVZgioyDi8h/2Hw40XMVjOhnyXtaccppHzreG12F Slb+H2Ba24EJpVH2r/E9663r7JaEPwsyMpuLxny/BMcL5S9Z0o3Hfxvv8hux8CsygQuS JFgWBEixdqK19bwutKZWEg4W2WY+paftl5lI8NC/qUpP/liG/bnIQPO+2FUwJfkcIoqD +kR75fvBq5F3S5yuSRv4W8OuRDVUYD0uANTP63OeVv3jZOTnZRRwjiGSkGQ+sxny3qI5 eCVQ== X-Gm-Message-State: AOAM5326zWiVg4/W2Ty/PNZNVRv8sxEhV5v4IrhVt8IytLr73gs5q3l/ gmvENatk1kdDIBdU0VrGrgM= X-Google-Smtp-Source: ABdhPJwPol+nSY0bp9PtUpjUzKAKjOmiokZV1sV1T5nCdTL/BlP0H0+DQb1QpC/M/s290OQgayrMlw== X-Received: by 2002:adf:b357:: with SMTP id k23mr10382348wrd.94.1628549941080; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:00 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 03/12] media: i2c: Defer probe if not endpoint found Date: Mon, 9 Aug 2021 23:58:36 +0100 Message-Id: <20210809225845.916430-4-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - 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 8d973117f611..fe700787bfb9 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2796,10 +2796,8 @@ static int ov8865_probe(struct i2c_client *client) /* Graph Endpoint */ handle = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL); - if (!handle) { - dev_err(dev, "unable to find endpoint node\n"); - return -EINVAL; - } + if (!handle) + return -EPROBE_DEFER; sensor->endpoint.bus_type = V4L2_MBUS_CSI2_DPHY; From patchwork Mon Aug 9 22:58:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFABAC432BE for ; Mon, 9 Aug 2021 22:59:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D318861002 for ; Mon, 9 Aug 2021 22:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236944AbhHIW7Z (ORCPT ); Mon, 9 Aug 2021 18:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhHIW7Y (ORCPT ); Mon, 9 Aug 2021 18:59:24 -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 78A79C0613D3 for ; Mon, 9 Aug 2021 15:59:03 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id f5so7709574wrm.13 for ; Mon, 09 Aug 2021 15:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SJrufKJjaLxdMoyjsvkVa1bnKNgVyDCa5SfbalBDx3M=; b=ux3mrfR7KxKshAB1dPtqQegTFA/4Mw49CG3CSr1ZYjZYlNzti87ryMaT78x+VuDuCo 8NADQlU8b3lKb+3hhyJAe6uxk6q+wv7gUKvDMRC7U5s8Gi7z9p/OLz4YQl7U76tJDXy5 jTWRpgRYgS6QLx4+6OiaAZ1JmFfUuX/gp3h25eMsnK5JKbaEPLrGArfCe9GvFsvKLtYo 4FOnKCfg4u51Co2bnHpuLdJG6Nc0NJEu/o4eDXHPFQUmXl5oqyGyR2uuV10B3AHAkR0D OtF9hCPmAt7VLlmu9KP9EB7qdmp8n+PWRCUCPYxp59Lykzq8JtTyokuFiuLzWgL2wME8 8Cjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SJrufKJjaLxdMoyjsvkVa1bnKNgVyDCa5SfbalBDx3M=; b=V3pTuT6HaVzkKfRkfWInQ2wUABqQPzNbfoPINU1t7LcZAyXgAMubrLLlioP/ZnSfM5 iIZaGsuomYD4esPSxrm+PJB4NiVuSf89vK3j8gIpbNjtb0xr//g4+cYoj4qY40JDSHVG AhHKrbH02q2qKq9OkuSnR3XE9E2l1gHyGF82yecdegtRKklcc1IgTUZaATlEnXy7WIHz RXxRblsQcCu3xgPV5irc0J5DNEVVhvsTYAcImLmBX9+XMWu4uv/DKx4LyWhYIk9xGTIF AlgSGQLxGM0C323YsC/yaHohCg2kbck1v9OQWzAMX4U9JQX0Sxbft5y6YNx22dJ37NBC BD5g== X-Gm-Message-State: AOAM532oslL9KlR9bnChJtUjK4Pi10i08Cz76IW2le98/ruzgEBgrmK1 pD0D06xpuBxBHFQTZoWbCXk= X-Google-Smtp-Source: ABdhPJwdvVxFqKwjqrnQ98qqmwzSIHqNdE386Gr2+n6T5VFdYB7DZwB0YFSafKeTa8LoTgVTOZ/FCw== X-Received: by 2002:a05:6000:1805:: with SMTP id m5mr12773826wrh.265.1628549942123; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:01 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 04/12] media: i2c: Support 19.2MHz input clock in ov8865 Date: Mon, 9 Aug 2021 23:58:37 +0100 Message-Id: <20210809225845.916430-5-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - Added an enum defining the possible frequency rates to index the array (Andy) drivers/media/i2c/ov8865.c | 164 +++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 43 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index fe700787bfb9..1382b16d1a09 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,19 @@ struct ov8865_sclk_config { unsigned int sclk_div; }; +/* 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 @@ -665,6 +674,9 @@ struct ov8865_sensor { struct regulator *avdd; struct regulator *dvdd; struct regulator *dovdd; + + unsigned long extclk_rate; + enum extclk_rate extclk_rate_idx; struct clk *extclk; struct v4l2_fwnode_endpoint endpoint; @@ -680,49 +692,83 @@ 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_configs_native[] = { + { /* 19.2 MHz input clock */ + .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, + }, + { /* 24MHz input clock */ + .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_configs_native[] = { + /* 19.2MHz input clock */ + { + .pll_pre_div_half = 1, + .pll_pre_div = 5, + .pll_mul = 75, + .dac_div = 1, + .sys_pre_div = 1, + .sys_div = 3, + }, + /* 24MHz input clock */ + { + .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_configs_binning[] = { + /* 19.2MHz input clock */ + { + .pll_pre_div_half = 1, + .pll_pre_div = 2, + .pll_mul = 75, + .dac_div = 2, + .sys_pre_div = 10, + .sys_div = 0, + }, + /* 24MHz input clock */ + { .pll_pre_div_half = 1, .pll_pre_div = 0, .pll_mul = 30, .dac_div = 2, .sys_pre_div = 10, .sys_div = 0, + } }; static const struct ov8865_sclk_config ov8865_sclk_config_native = { @@ -934,8 +980,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 }, /* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_native, .sclk_config = &ov8865_sclk_config_native, /* Registers */ @@ -990,8 +1036,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 }, /* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_native, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_native, .sclk_config = &ov8865_sclk_config_native, /* Registers */ @@ -1050,8 +1096,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 30 }, /* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_binning, .sclk_config = &ov8865_sclk_config_native, /* Registers */ @@ -1116,8 +1162,8 @@ static const struct ov8865_mode ov8865_modes[] = { .frame_interval = { 1, 90 }, /* PLL */ - .pll1_config = &ov8865_pll1_config_native, - .pll2_config = &ov8865_pll2_config_binning, + .pll1_config = ov8865_pll1_configs_native, + .pll2_config = ov8865_pll2_configs_binning, .sclk_config = &ov8865_sclk_config_native, /* Registers */ @@ -1513,12 +1559,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 = &mode->pll1_config[sensor->extclk_rate_idx]; + pll1_rate = sensor->extclk_rate * config->pll_mul / config->pll_pre_div_half; switch (config->pll_pre_div) { case 0: @@ -1552,10 +1597,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 = &mode->pll1_config[sensor->extclk_rate_idx]; + switch (mbus_code) { case MEDIA_BUS_FMT_SBGGR10_1X10: value = OV8865_MIPI_BIT_SEL(10); @@ -1622,9 +1669,11 @@ 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_config[sensor->extclk_rate_idx]; + 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)); @@ -2053,9 +2102,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 = &mode->pll1_config[sensor->extclk_rate_idx]; + pll1_rate = ov8865_mode_pll1_rate(sensor, mode); return pll1_rate / config->m_div / 2; @@ -2783,7 +2834,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 +2910,39 @@ 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 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->extclk_rate_idx = i; + /* Subdev, entity and pad */ subdev = &sensor->subdev; From patchwork Mon Aug 9 22:58:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494626 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FAD5C4338F for ; Mon, 9 Aug 2021 22:59:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F155861002 for ; Mon, 9 Aug 2021 22:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236948AbhHIW70 (ORCPT ); Mon, 9 Aug 2021 18:59:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhHIW7Z (ORCPT ); Mon, 9 Aug 2021 18:59:25 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86C77C0613D3 for ; Mon, 9 Aug 2021 15:59:04 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id b128so11641396wmb.4 for ; Mon, 09 Aug 2021 15:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xh0P4NTmPzYcjBqILM/Pjd/H6Y/GMmN8W7uqdPEVo30=; b=JIYC9CmAg9UEddcj/VhReoZhScehYl9oc4SK5t9fBnXG62WqL9zaXmj+T5qfvpgb3q VqoiML6uraeCvea7p/ecVtCckHNVYmDD2p3NFg5Fs0iuCAY6zlLrD6yAo/0kGyiG7u/I +fKtf7wi2wIhq3fspZD1deK2+llgM91sgSA2+5vQ2CWFJyPaS5FSXFFebqxxDpRYHpUS TQ9uS+oWjZnAHNWYmDoVU/ojR6fDSKvFqOCkD8ACRIEZtCQ8xfeiaILN1/xvMk6iUYTz fgD4HwHzo/eEBSmnF6haPuNUFkyJ4M7ls8FA0bpoVg8zj40HsdhzJMYVs4WfnoeTuUlN 8bnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xh0P4NTmPzYcjBqILM/Pjd/H6Y/GMmN8W7uqdPEVo30=; b=dJ5g8X8pFSywFglq4KTbtJRwO/w6omrrpeX+OFYgQeXSquXuCvipH2A0bKFiJ62lxY oqQ3/Pb5VuyilKK7Gtu6ID6LkiyD9YZsmJEhYuDHml5A2diF9u3GjxBBpbJrByQXGRGd 2U3QmkY1W0G611iCausvg7Y4a2amGXdnztTnrhOFBiPUnkPoh2IRHtqLnjhFmwI/+TDt luK/bOUKkomcTT+5yXDlKE9o1HuMK8yEyzrUys2dWEPSk2fkiviHepI/AfAoDtbdtHdT RBHOM6wTX1sL1v9VamQowoSLifqSc+KyyN9hxGTerqZsqOxQhaB2fNdVbjgj+eFxrx7u qnvA== X-Gm-Message-State: AOAM533RoIV2Eqn1KXYT3zLswaLp5nwnD5klLbLPBGF2Z3M+Q8swmeln ixG8yrc0WptDQQjb3HLXyGA= X-Google-Smtp-Source: ABdhPJxPtWjIZZj9X9wDeeK+/5O10/mnthkEFbpWjV9QdSlfyy97XpZ41vu7/nVUacJGHEXtkmazog== X-Received: by 2002:a1c:9884:: with SMTP id a126mr1369404wme.153.1628549943167; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:02 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 05/12] media: i2c: Add .get_selection() support to ov8865 Date: Mon, 9 Aug 2021 23:58:38 +0100 Message-Id: <20210809225845.916430-6-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - None drivers/media/i2c/ov8865.c | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 1382b16d1a09..8c2b7d3cbc8c 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) \ @@ -2749,12 +2758,64 @@ 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) +{ + 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 = sensor->state.mode->output_size_y; + r->width = sensor->state.mode->output_size_x; + r->top = (OV8865_NATIVE_HEIGHT - sensor->state.mode->output_size_y) / 2; + r->left = (OV8865_NATIVE_WIDTH - sensor->state.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, }; static const struct v4l2_subdev_ops ov8865_subdev_ops = { From patchwork Mon Aug 9 22:58:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4A20C4320A for ; Mon, 9 Aug 2021 22:59:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA9D561002 for ; Mon, 9 Aug 2021 22:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbhHIW71 (ORCPT ); Mon, 9 Aug 2021 18:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhHIW70 (ORCPT ); Mon, 9 Aug 2021 18:59:26 -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 80126C0613D3 for ; Mon, 9 Aug 2021 15:59:05 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id h13so23494922wrp.1 for ; Mon, 09 Aug 2021 15:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RtQ0UVLo3Cg4U1KcWjY50/YjcZqa3dRnlreBGiZao6A=; b=nZtS8fqtORUZEhZPlud2gyHnUT00BIhqqgtOjnVOBklGdi6ptNJHKiRdYqwHc/L7nQ 1b94HeKGsBufJPeju4zgYObTBNL/fDvyp4ybiUgEJZv3+gHL0sHwG3Pbvh5ykDjxMJGz EJ/2+wBs1bZi1EDfYRe7wT8Ikt/EQiQwhrtGMbitfcKBO8dnoWlhz2cbZYUDCKyIV4fm FXDN2siE/dE0fk0hx0BnEf8oVVlL5bFmMmXp7e136H34VSgb9Vq2mBYEB/1TIA/OWcJU W2Etw9dsj599LfXJXL1ITmSUIXilAxSWwnjXyYhHcJMesLRc7zaN2uNkotZeh8bLuWYw YdJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RtQ0UVLo3Cg4U1KcWjY50/YjcZqa3dRnlreBGiZao6A=; b=achFCeYNpTmkY4QWhztM5Xj8SrQRVKgs3P80h1w8+YLDANwR5Oxv5nt4YWf2QRHKL8 wGw9fzTuYoqbLYhCdHvuOMdvNIUjfXfeyHtEw12MQZjVF2OFhVWBSbySK98r2dIpbv6O cdMCUAO+OWZf+H/Kd313DaeR/Y6oH2LGNh3T/cW4jciBzCpSE2gv7YJps6QTu4+FGTMT V2S0c/rMppqkvHbxqZHq92CIwATF4kSuAK6GrFNmaOzWTyCg6wAxeGCJs4pEj1wrUxmc jSWUHsEOw5pOVnxF9UQWjdEIQtJB6sKgbbCA4faMqsfPv/bMSQsn9wQcNuT4l2gRfiAa LO8w== X-Gm-Message-State: AOAM5316YD92zr6Ga4F+LkyqmaeO6l7QWSxgLlafBo4vXNEwpzgIgfDd hBym/XES1+a9C1WrCDsL1oA= X-Google-Smtp-Source: ABdhPJxaB5eV5SrrORcqyp8cQjeBBioOTUWFkr/qYCXxMF5QwGGglXu98Kuart0xdBLbR5P5w+NVrQ== X-Received: by 2002:a5d:5987:: with SMTP id n7mr28128237wri.260.1628549944204; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:03 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 06/12] media: i2c: Switch control to V4L2_CID_ANALOGUE_GAIN Date: Mon, 9 Aug 2021 23:58:39 +0100 Message-Id: <20210809225845.916430-7-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - None drivers/media/i2c/ov8865.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index 8c2b7d3cbc8c..a97e355c1e07 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2143,7 +2143,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; @@ -2453,8 +2453,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; @@ -2499,7 +2499,7 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) /* Gain */ - v4l2_ctrl_new_std(handler, ops, V4L2_CID_GAIN, 128, 8191, 128, 128); + v4l2_ctrl_new_std(handler, ops, V4L2_CID_ANALOGUE_GAIN, 128, 8191, 128, 128); /* White Balance */ From patchwork Mon Aug 9 22:58:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E59AC4338F for ; Mon, 9 Aug 2021 22:59:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DA5561004 for ; Mon, 9 Aug 2021 22:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236954AbhHIW72 (ORCPT ); Mon, 9 Aug 2021 18:59:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbhHIW71 (ORCPT ); Mon, 9 Aug 2021 18:59:27 -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 80055C0613D3 for ; Mon, 9 Aug 2021 15:59:06 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id m12so23477234wru.12 for ; Mon, 09 Aug 2021 15:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AulG+7uf/LMgd2a1nsscaaOUSbzjsdDvDLyf58LSVQY=; b=kdLoBHTMTXdCEtxqstX0Vc4LqOTJrtIVk2Z3WkSGHHNhPcrOMqNJTmZMM3q1hJsShL Obi/McLC3VPlr5Nxowv4mfm+hhtC/+qkDeA6HjFcpVSngrS+bLpZcmjEtnm6iBcUDV57 v89/25y2ulVNrUV5pK0szA0w9puu5p4b84WFy4Z9RYySzIQtP8NuXCAPnnedqoMrsq4b rE3nSV3lyDGDB3Ww/TsdTzP82ZEtQMxUG5lzyw8wtPY41eYsbzX9UJZsI31wUUFlQu1E XgQ+FJIZmIRTZm+bmL0M8LznsDhPzJKBuC044KKFpFemdxyCgmX85kKPOflETAjRSKg4 nT5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AulG+7uf/LMgd2a1nsscaaOUSbzjsdDvDLyf58LSVQY=; b=dfOlZ++/yY//NLbJsRDN/5FKaMD8arNakPgiVqmXfta58GAaKbu1EWDAEAjWh0ZmoP iYkwKDFz5UggRpa5+0L9NT82JmkYvh7rsOP/4D3IwJryzIEXipk9nYwB3khHoStVoJFH sBZKGPvUrCycMW6O5/894eyQQW1xAJBBj5q3yMKYg6cdkROHXRcfGSOvXhXg8/KHvc6e 38g2YBMauzovlrSuktgg59JVQ4t13Ny56oPuubzDYtbptiyLt9YDFCuMp9k4Wfqj9oTy KMRTV441XRwCpSrhGMMA2FHRFzYIzUEC6bnF+FfnllBX8nxNmRaTOnWlTYxamAHY7rsa My9A== X-Gm-Message-State: AOAM530JMGfuLQcee9sEm+IzO9EH+9OAUQOLUe1UWIcuN2O6tUKsbvdS QxV4gHliXblVCALxEJqKbNiKSJKTC9c= X-Google-Smtp-Source: ABdhPJyHOJggXfNmPD16gN2ztCKzI1eGW20RWQSSxLDV5eJjvRKwxmiLhyYMJViNzT/XP6XQBryPZw== X-Received: by 2002:a05:6000:10c6:: with SMTP id b6mr27883000wrx.110.1628549945151; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:04 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 07/12] media: i2c: Add vblank control to ov8865 Date: Mon, 9 Aug 2021 23:58:40 +0100 Message-Id: <20210809225845.916430-8-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - 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 a97e355c1e07..810047c247b4 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 @@ -671,6 +673,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; }; @@ -2218,6 +2221,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, @@ -2469,6 +2486,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; } @@ -2485,6 +2504,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); @@ -2520,6 +2541,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 = @@ -2700,6 +2728,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); @@ -3025,6 +3057,8 @@ static int ov8865_probe(struct i2c_client *client) /* Sensor */ + sensor->state.mode = &ov8865_modes[0]; + ret = ov8865_ctrls_init(sensor); if (ret) goto error_mutex; From patchwork Mon Aug 9 22:58:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDAB1C4320A for ; Mon, 9 Aug 2021 22:59:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7C3B61004 for ; Mon, 9 Aug 2021 22:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236956AbhHIW73 (ORCPT ); Mon, 9 Aug 2021 18:59:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236955AbhHIW72 (ORCPT ); Mon, 9 Aug 2021 18:59:28 -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 862CDC0613D3 for ; Mon, 9 Aug 2021 15:59:07 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id m28-20020a05600c3b1cb02902b5a8c22575so1159924wms.0 for ; Mon, 09 Aug 2021 15:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9Un+B0jhmejBmLZ3u6D+YjTbwChkMhGgiY8G0w2wqxM=; b=c9p0qVF4oqHhyd/H5bAGg68H0Rq3obZEgX6s+2GKOkPu8znLSiKRcWmfR3gJeg5gvO VLD5X4NNDjt/EdhFf4fJpeaJMl82fNdz0zMxNWokBsvq6MvYQF1A/X9n8LvzmjIgYLKL dAkQJvzOp+aizHsu5+1H/QftHl/AMRzkP/97Vo5jNkm8nBP8uV5oc3PyNZKXieLhpf9k u+Qw76/In+54o6FJD0PA8Nb0ZZCljgBHbqpMIZ4shbVmThMHc6SoZvD82sBcGYk3L3O8 xRnycHmIAJaqM/VPHL1FGFgZu7Iw6TEUW1oh06Ox/Fgaccq3Ffy5e6imgo+Qp0ILH5Au TOWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Un+B0jhmejBmLZ3u6D+YjTbwChkMhGgiY8G0w2wqxM=; b=FkxLIv0Cs0YpkFJAgBi0xmeKh0PShduEU0i6gizXsVBc4mvpai3hn4GkT6yg8CPpG6 BBg59k3uGjmE2XC41SYvp+VDj+WX+QfIC/WXg4kN68M+jazQxp7MsTXsa2wpEvSFHN5E nT7s2/ThSzMKgWGP60TbZtNVn5LO/7/fuH+Ie1Nw1BUrAKUI3AeHpGNEAEkqva1uziVd CRO0K34kd9mEfIz1bqvc2TtiTlAhWAnC0JuQb1reL65FEmCbVzd4oOhftqL5OfyGlzGu EDWhbWMNr6zpiAP3IoB+VqA7Yel9YCMv5U9wHYEriG2QBCY1nsyd7yxKZHmB/sUSpOfT nPNg== X-Gm-Message-State: AOAM53269se5OJuy0iiZM/UDWwsUJWgp7DzzDF3PFu/Su0BLb2hOgd1j u3cxeiYRtu+NDYh4ihbVk7Y= X-Google-Smtp-Source: ABdhPJxoi72E/137uXqiyBw4nnmZ/TqpoM0nozaUTPeqQTYy0uVm4JJWm2jv5ONAjmMezGCbpvcqkA== X-Received: by 2002:a05:600c:1986:: with SMTP id t6mr14045514wmq.49.1628549946150; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:05 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 08/12] media: i2c: Add hblank control to ov8865 Date: Mon, 9 Aug 2021 23:58:41 +0100 Message-Id: <20210809225845.916430-9-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - None 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 810047c247b4..db84294b7a03 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -673,6 +673,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; @@ -2506,6 +2507,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); @@ -2542,6 +2544,13 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) 0, 0, ov8865_test_pattern_menu); /* Blanking */ + hblank = mode->hts < mode->output_size_x ? 0 : 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, @@ -2688,6 +2697,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; @@ -2732,6 +2742,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 ? 0 : mode->hts - mode->output_size_x; + __v4l2_ctrl_modify_range(sensor->ctrls.hblank, hblank, hblank, 1, + hblank); + complete: mutex_unlock(&sensor->mutex); From patchwork Mon Aug 9 22:58:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494624 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37539C432BE for ; Mon, 9 Aug 2021 22:59:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 164F160FE3 for ; Mon, 9 Aug 2021 22:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236958AbhHIW7a (ORCPT ); Mon, 9 Aug 2021 18:59:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236955AbhHIW73 (ORCPT ); Mon, 9 Aug 2021 18:59:29 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AF4EC0613D3 for ; Mon, 9 Aug 2021 15:59:08 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id h13so23495040wrp.1 for ; Mon, 09 Aug 2021 15:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sh2Qb+qpeQv9UKOTm6x4bxUXxIvNDNUgK/mc3R2l494=; b=eQIL+hWPUpjpZMHgx8Cd2sPsBp/SNPlDOQB6LFYERtsD7bBIS8wIuPhTJU9cEaPqNA 16SJ2a8ngW5XdLbklI1Pttms30ePw5JLF9XAmwNgnE8ddAuOoaXqhrt5YSbCtBrJNcgN scxtLuRJJnVBZQ9UUaNMe4spPsdaIQcmO0Sc09uEbUU9PMdEGm+xSrAx1MrzpwA21D3m idU0SnDCW+nRwhzqhlLh6/vkdxBMnZmLX8scnBWpFg4CyPV8xJaMJnAAjVHrL8v+wEyL 4W8QiUADML9yye1mBOQKtSCEvc89wPNJHOkKgGGSOOzurkhjrytB/TfdlAucss+hrbBy ZvNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Sh2Qb+qpeQv9UKOTm6x4bxUXxIvNDNUgK/mc3R2l494=; b=epW5/Qdulzr0uMvpJRjVRd/hTkDPYOhYhZxYmC0uqnZ+19MCZsQ4LWRhjjvCBCY973 c68bShU+tvviYgB7kBlLrSgWlzsTAhg/jsKSmc6lGAY3I4Z6L68WdNETlcZscdgPn30N 1r0pXpzmjGHfoppFZ1+IDHt+5C4KuqdD3NtZCQZchulTV5Ll4PutYL1fwJfpv2iBwElN OjI/mWYA+gp6iZv9g9kz5hTuLNhodwDA9B5dzBzPy3/ePK3YCWddzHQbGXdrbjH2jgOK PMziWYVkggzKgq1uzFw7sauqn3SfxcPJogS2q0CVwkf5aiT/rqYcxr1mbqMeWfPM/M4i Ecew== X-Gm-Message-State: AOAM530irL2BlHRqRLTSY6b//VV69nvHzYZGAYszSjTob5sdXFLkX69r JS1AikxqDfqPdVuVmnuITvgqOG+wBls= X-Google-Smtp-Source: ABdhPJyfHmsERimdIrzuEtNscycFpFt0BXZZgEBC/yOvHMLZvNm3Q5ZB3LAz48AYLFPiJuQ+Mfy6eA== X-Received: by 2002:adf:cd91:: with SMTP id q17mr13690903wrj.122.1628549947159; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:06 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 09/12] media: i2c: cap exposure at height + vblank in ov8865 Date: Mon, 9 Aug 2021 23:58:42 +0100 Message-Id: <20210809225845.916430-10-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - None drivers/media/i2c/ov8865.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index db84294b7a03..70747552e32a 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -675,6 +675,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; }; @@ -2461,6 +2462,18 @@ 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; @@ -2517,8 +2530,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 */ @@ -2699,6 +2712,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); @@ -2746,6 +2760,12 @@ static int ov8865_set_fmt(struct v4l2_subdev *subdev, __v4l2_ctrl_modify_range(sensor->ctrls.hblank, hblank, hblank, 1, hblank); + exposure_max = mode->vts; + __v4l2_ctrl_modify_range(sensor->ctrls.exposure, + sensor->ctrls.exposure->minimum, exposure_max, + sensor->ctrls.exposure->step, + min(sensor->ctrls.exposure->val, exposure_max)); + complete: mutex_unlock(&sensor->mutex); From patchwork Mon Aug 9 22:58:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 662D5C4338F for ; Mon, 9 Aug 2021 22:59:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C7D860FE3 for ; Mon, 9 Aug 2021 22:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236960AbhHIW7b (ORCPT ); Mon, 9 Aug 2021 18:59:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236955AbhHIW7a (ORCPT ); Mon, 9 Aug 2021 18:59:30 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6198AC0613D3 for ; Mon, 9 Aug 2021 15:59:09 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id w21-20020a7bc1150000b02902e69ba66ce6so1132367wmi.1 for ; Mon, 09 Aug 2021 15:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TnmFNtbiKQGa8at+MP7DPu15n/0g8nWr5PR8Vb/Jw8w=; b=KwF8Fv3bTBgIi7LPrqnAfikg13y6wbm0HDfauZDxzY8YUtSmq65p039TNTBAbXRHc6 UDZx1s7vWNwIbVGQ82k28nFofDJb4RxLkf7AfpnTVJr1ZfnPfRhAGaAirAPsyhx4ATR0 EpOVB++J1EAgVhRHQESD3KwZtfvZapAxwU61p02MINWHEP5Z4473fYqzh5KSCfTWVnoq KaowSxlvuKp/THKsGaTMzTOym4/LfWcDpP5Zs+OwMqyh2e0RtvVPZcY5NV9O9d+C0x5N lrLzEWmpiegv6S91v3GN0i77KwJfheaA4143EJhiMJ7YEk53ECgUyOyGu1SPomJ60xbH I4SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TnmFNtbiKQGa8at+MP7DPu15n/0g8nWr5PR8Vb/Jw8w=; b=iXKZWljKfbaHyYClVPrucXo30FodnaDKVqKPrjurMl5vSSQDOOZ2jRo5tzWbkZOmnR e0pCrzE48JVUkrwC4yR/yTxExwjzwtW/ZFCybRq/35uskT2PSJG+X3Ihkh07ALPqrBLP 5g3qETDD1BPIdJiyXYVYRsXJ2EWvf8cuf+56J5CegK3vCL2/Nh9wb+jJdHW9DzIrRN7K 1HwjqV4LWyc0YN4QIpyohd9KHaGi1T+NnLzZ4Vsw9BtfqWn7u4f3fzhy6VNjmm+Q9vFQ hSIJ/YrklPfzFLsbd6QPjrdrx5jJKojVa93Q1Su+6T2cso0/eVfAAJ89ytpoLsoCbKNd yE3g== X-Gm-Message-State: AOAM5314XcJ+nYDRvUZDH4QcvKAVBBsV/ffP2Z0FgWxk07lNasNQVX6o eudYvWOFuR7D5hzCUWDnb9uVE2Bo6Sw= X-Google-Smtp-Source: ABdhPJzDZ9GOZVOnhRnCCR80yU01c0qUPTq2jPKhZeBmcpsvreCYAhzCT8qPXelE9mOdWKzOWBiTug== X-Received: by 2002:a7b:c7d1:: with SMTP id z17mr1412431wmk.50.1628549948075; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:07 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 10/12] media: i2c: Add controls from fwnode to ov8865 Date: Mon, 9 Aug 2021 23:58:43 +0100 Message-Id: <20210809225845.916430-11-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - 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 70747552e32a..d7926cadce70 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2519,6 +2519,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; @@ -2581,6 +2582,15 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) v4l2_ctrl_new_std(handler, NULL, V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1); + /* set properties from fwnode (e.g. rotation, orientation) */ + ret = v4l2_fwnode_device_parse(sensor->dev, &props); + if (ret) + goto error_ctrls; + + ret = v4l2_ctrl_new_fwnode_properties(handler, ops, &props); + if (ret) + goto error_ctrls; + if (handler->error) { ret = handler->error; goto error_ctrls; From patchwork Mon Aug 9 22:58:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEE3DC4320E for ; Mon, 9 Aug 2021 22:59:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B066D61019 for ; Mon, 9 Aug 2021 22:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236961AbhHIW7c (ORCPT ); Mon, 9 Aug 2021 18:59:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236959AbhHIW7b (ORCPT ); Mon, 9 Aug 2021 18:59:31 -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 4ABAEC0613D3 for ; Mon, 9 Aug 2021 15:59:10 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id m36-20020a05600c3b24b02902e67543e17aso726297wms.0 for ; Mon, 09 Aug 2021 15:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o0f/gjsur0m8agv5cRQaJTm50HmVIODuIKfnxjp3LKE=; b=mvPLiFUy3sGIamuOnz2TUQFxmtnIsPvWU/aCg4EXTuBz+aS788myRcQdU8syCx2U8L p55ZVcpmWcxgEUo1WX3j61KcAyUvfYIsbFRhSry44mnykZXTgvz42wEw2YVypIub8ru8 r88l+uy9VUgmR540ZFqAccq+klWX9KaVFGu58HK73pcHU3bKiD85U1iBTkG5jG+WsZfh jAisgKeT/NrvkibTocBb9O2ANjXZ674Ztiz5SVevLvL12Cj/ajOtAFsj/D7UuN/x1EBu h9KWtWYzSR528z5YVxvBSd0Ct8CdK2PVSJokXQDexs+b2sfs/Ma/aTYoHsaV70QDv9PD TC2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o0f/gjsur0m8agv5cRQaJTm50HmVIODuIKfnxjp3LKE=; b=VQsox3MNfWNgvWWlhK0pMBOCTqhi/XwQ3y1UIjTsMDtDyX06MRybEP8xHD0zrwAtAa iIaYhd1ddFGfqT00c/BzUI9HTT1fbgpn7Kyq+kLlOll7HsvOU3zDl1I7bZDojRRsQsNn 0GHvPx7TsP/1GjS74i7G1tZa7Te+pGrZ631V0/MwZAFYNxA0s5CqpCzMidBTUDI3JiWG DQkOFczY+ovTFvU78CazRj/7aAN3HYVBZrzC2V1rGrqWJS96ZsLoGZneQfppXpdm9c4L qnHPs13Jt42DzlSOqqllnUax2VogpB/CNrVOHiDFCoy2+qqvy0zhwyCu6xAQwQLN6gV9 skDg== X-Gm-Message-State: AOAM5314dUKmWLdoH2a07E7TIOIH9FVx8NkcR0danDu95sQ4FjzMRoJn fjJOMFMaKxw6fbMS7bf/Yuw= X-Google-Smtp-Source: ABdhPJyKvLsEUeRohFQZShsc780pr4pMuWG0gfBBY4F7CHY0K9kZqlOo+CAGk9QuSf0SoeoeHfOStg== X-Received: by 2002:a1c:a90d:: with SMTP id s13mr9167435wme.132.1628549948986; Mon, 09 Aug 2021 15:59: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 v12sm20437957wrq.59.2021.08.09.15.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:08 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 11/12] media: i2c: Switch exposure control unit to lines Date: Mon, 9 Aug 2021 23:58:44 +0100 Message-Id: <20210809225845.916430-12-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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 v2: - 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 d7926cadce70..ce4e0ae2c4d3 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2132,6 +2132,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) @@ -2531,8 +2534,8 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor) /* Exposure */ - ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 16, - 1048575, 16, 512); + ctrls->exposure = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 2, + 65535, 1, 32); /* Gain */ From patchwork Mon Aug 9 22:58:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 494111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51361C4338F for ; Mon, 9 Aug 2021 22:59:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E77A61004 for ; Mon, 9 Aug 2021 22:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236965AbhHIW7d (ORCPT ); Mon, 9 Aug 2021 18:59:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236959AbhHIW7c (ORCPT ); Mon, 9 Aug 2021 18:59:32 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A1D1C0613D3 for ; Mon, 9 Aug 2021 15:59:11 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id l18so23523291wrv.5 for ; Mon, 09 Aug 2021 15:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TFqdzyp5+BdbPnTT62GNKNhDomjZASMOd7s1EVnkV/o=; b=P5Zckll8y3OrZst94+PUhm5q5zRUC21VgQyFSZReHwD28orHoIYakmPWzbnmilVNSg uhDXDDAO0GYju0mlvKhwupnOnAs3gRTwBhmmA7vN4ccdM4i9FoQlIFy7VW7QlhpnEMlT +NGELhLHM3+W4B6Wyer7LuKanC3AKu7GXbYxgDKllaUPOxr/Sp9pqLuQeW3lnz16UskR EzI9k9Dxd5BKDys7kzM44Lvw8+KWxL1BkIEnPJguor+j2/NFUttj7EPoxSjN2IUq3te3 EqlUNQlVLYevY3Pghg5OHgvUr3FJZZtCZT8Q6K2KzvnfWmP9QoUkhyn+hTu7qHK0EAOq QLJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TFqdzyp5+BdbPnTT62GNKNhDomjZASMOd7s1EVnkV/o=; b=WlBkmuMam3yvvU985+p4lwvk2u+g1fFoe5/+IUw77jE3ozHxZ4x950aYrtj0HncMEr B+dlqGcYKEqJ72X7sVwI8gRAdbcJhehYWIpR6LijIdrOej7i4mHPiCakz5T9MWZPJUy2 RcgkT6IM5kOYLCDuE20r5n4kQ8NjfqE8rn6D69zngWtoxSgV4/59smKhg3DKquD/LtvB NYV0ypHzMrFomb379uPmFMIILrU5odcI36crsULYcdRLQ2cPedfTqRjLTHIV/7RNXAOG RTQ46ww+V762iubc19Ck562aiVI27DuLuy6GNAagsMN4KNlnm2J5JEQxWUkG0xouXpZ/ GNvw== X-Gm-Message-State: AOAM530+UH6kAHshlURemWdtDT8le65t+zru+vWRu2czcOG4I2MUwsn1 y//xz8LV3xVfycKo5L0zEqI= X-Google-Smtp-Source: ABdhPJxSN+her5/ac0LviZFqRD8d8/OPH43S44ByjEGUk2EkjyxSJy1fg+AJLbzLUN9GmyQwJWTDpA== X-Received: by 2002:a5d:6b8f:: with SMTP id n15mr26971292wrx.103.1628549949960; Mon, 09 Aug 2021 15:59:09 -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 v12sm20437957wrq.59.2021.08.09.15.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:59:09 -0700 (PDT) From: Daniel Scally To: djrscally@gmail.com, sakari.ailus@linux.intel.com, paul.kocialkowski@bootlin.com, ezequiel@collabora.com, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org Cc: yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, kevin.lhopital@bootlin.com, yang.lee@linux.alibaba.com, andy.shevchenko@gmail.com, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: [PATCH v2 12/12] media: ipu3-cio2: Add INT347A to cio2-bridge Date: Mon, 9 Aug 2021 23:58:45 +0100 Message-Id: <20210809225845.916430-13-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809225845.916430-1-djrscally@gmail.com> References: <20210809225845.916430-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. Signed-off-by: Daniel Scally Reviewed-by: Andy Shevchenko --- Changes in V2: - Ordered the list by ACPI _HID (Andy) 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 4657e99df033..18a31196a4a3 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), };