From patchwork Tue Mar 9 16:36:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126005 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MIME_HEADER_CTYPE_ONLY,SPF_HELO_NONE,SPF_PASS, T_TVD_MIME_NO_HEADERS 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 B55C0C433E6 for ; Tue, 9 Mar 2021 16:37:03 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 00BB564FF3 for ; Tue, 9 Mar 2021 16:37:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00BB564FF3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6216+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id 0TpoYY4521723xQJuDfOGlXX; Tue, 09 Mar 2021 08:37:02 -0800 X-Received: from relmlie6.idc.renesas.com (relmlie6.idc.renesas.com [210.160.252.172]) by mx.groups.io with SMTP id smtpd.web11.11724.1615307821262695682 for ; Tue, 09 Mar 2021 08:37:01 -0800 X-IronPort-AV: E=Sophos;i="5.81,234,1610377200"; d="scan'208";a="74342196" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:00 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id A786240A2DBD; Wed, 10 Mar 2021 01:36:59 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 01/40] media: ov5645: Remove unneeded regulator_set_voltage() Date: Tue, 9 Mar 2021 16:36:17 +0000 Message-Id: <20210309163656.20944-2-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: xuBZXdgQw9THsn2rfRJR2Qn6x4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307822; bh=vTUKpmMBpctPUaQmXhgi6waDVNhEKUcP2ADdiZ8W8ZU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=fsswVpZKEwbK3tS/wJGS4ph3/y4q6GY741XaFVqclzGiBYZkJsmtZ3aAAKd7Ed2ygBx nYN/XOKjfPJrYN3MyRlVbWK2MiLNxE9ztFlhNAbW6otgJG3nJev2r5GGf1/ULpcrye895 w4MlunPZINj2sY4xMhpJwlQQDmy/HIWw7Vc= From: Fabio Estevam commit 45ffbd15ede6add6e4fb150e4bab7a27cfe62552 upstream. There is no need to call regulator_set_voltage() for each regulator that powers the camera. The voltage value for each regulator should be retrieved from the device tree, so remove the unneeded regulator_set_voltage(). Signed-off-by: Fabio Estevam Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Lad Prabhakar --- drivers/media/i2c/ov5645.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 34343bc10007..5f3229bc68a5 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -42,10 +42,6 @@ #include #include -#define OV5645_VOLTAGE_ANALOG 2800000 -#define OV5645_VOLTAGE_DIGITAL_CORE 1500000 -#define OV5645_VOLTAGE_DIGITAL_IO 1800000 - #define OV5645_SYSTEM_CTRL0 0x3008 #define OV5645_SYSTEM_CTRL0_START 0x02 #define OV5645_SYSTEM_CTRL0_STOP 0x42 @@ -1174,42 +1170,18 @@ static int ov5645_probe(struct i2c_client *client, return PTR_ERR(ov5645->io_regulator); } - ret = regulator_set_voltage(ov5645->io_regulator, - OV5645_VOLTAGE_DIGITAL_IO, - OV5645_VOLTAGE_DIGITAL_IO); - if (ret < 0) { - dev_err(dev, "cannot set io voltage\n"); - return ret; - } - ov5645->core_regulator = devm_regulator_get(dev, "vddd"); if (IS_ERR(ov5645->core_regulator)) { dev_err(dev, "cannot get core regulator\n"); return PTR_ERR(ov5645->core_regulator); } - ret = regulator_set_voltage(ov5645->core_regulator, - OV5645_VOLTAGE_DIGITAL_CORE, - OV5645_VOLTAGE_DIGITAL_CORE); - if (ret < 0) { - dev_err(dev, "cannot set core voltage\n"); - return ret; - } - ov5645->analog_regulator = devm_regulator_get(dev, "vdda"); if (IS_ERR(ov5645->analog_regulator)) { dev_err(dev, "cannot get analog regulator\n"); return PTR_ERR(ov5645->analog_regulator); } - ret = regulator_set_voltage(ov5645->analog_regulator, - OV5645_VOLTAGE_ANALOG, - OV5645_VOLTAGE_ANALOG); - if (ret < 0) { - dev_err(dev, "cannot set analog voltage\n"); - return ret; - } - ov5645->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH); if (IS_ERR(ov5645->enable_gpio)) { dev_err(dev, "cannot get enable gpio\n"); From patchwork Tue Mar 9 16:36:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126007 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 95A2AC433E9 for ; Tue, 9 Mar 2021 16:37:04 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D7F9864F35 for ; Tue, 9 Mar 2021 16:37:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D7F9864F35 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6217+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id 92XPYY4521723xF4sv8scgio; Tue, 09 Mar 2021 08:37:03 -0800 X-Received: from relmlie5.idc.renesas.com (relmlie5.idc.renesas.com [210.160.252.171]) by mx.groups.io with SMTP id smtpd.web11.11726.1615307822860198874 for ; Tue, 09 Mar 2021 08:37:03 -0800 X-IronPort-AV: E=Sophos;i="5.81,236,1610377200"; d="scan'208";a="74590977" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:01 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 0155340A2DC7; Wed, 10 Mar 2021 01:37:00 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 02/40] media: device property: Add a function to test is a fwnode is a graph endpoint Date: Tue, 9 Mar 2021 16:36:18 +0000 Message-Id: <20210309163656.20944-3-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: KU5XLNB2FBDzZDrLnzyww6jEx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307823; bh=P17gzoTEmYgKwNkdd6Ytnaa7Mq6zoO8uBN3AcorYWAM=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=DhxSILyTr29MiPRTmdspCps04Kth0qA9G2HLVoUdk/EK+c8/+qrPCcDgvGqy7kGpR7w JxKjGuZ0+lDJpBgotDEzVfCZTFjjGNKC98a4Wg9e6HBJaqNx2aNm0OORhGmTHnt5NDQ4n kyHKn3JiYufvFZt/0qYLjI6hQxXb/ZwPcUY= From: Laurent Pinchart commit 35694afc92646ac24d7f3ef34a7387876d998fe7 upstream. Drivers may need to test if a fwnode is a graph endpoint. To avoid hand-written solutions that wouldn't work for all fwnode types, add a new fwnode_graph_is_endpoint() function for this purpose. We don't need to wire it up to different backends for OF and ACPI for now, as the implementation can simply be based on checkout the presence of a remote-endpoint property. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Lad Prabhakar Reviewed-by: Kieran Bingham Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab [PL: manually applied the changes] Signed-off-by: Lad Prabhakar --- include/linux/property.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/property.h b/include/linux/property.h index 216dcfe567df..ec8ebd73b2c4 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -308,6 +308,11 @@ struct fwnode_handle * fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port, u32 endpoint); +static inline bool fwnode_graph_is_endpoint(struct fwnode_handle *fwnode) +{ + return fwnode_property_present(fwnode, "remote-endpoint"); +} + #define fwnode_graph_for_each_endpoint(fwnode, child) \ for (child = NULL; \ (child = fwnode_graph_get_next_endpoint(fwnode, child)); ) From patchwork Tue Mar 9 16:36:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126011 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 5B4ADC433DB for ; Tue, 9 Mar 2021 16:37:05 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8E6564FF3 for ; Tue, 9 Mar 2021 16:37:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8E6564FF3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6218+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id YHQbYY4521723xchpBPljpEm; Tue, 09 Mar 2021 08:37:04 -0800 X-Received: from relmlie5.idc.renesas.com (relmlie5.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11726.1615307822860198874 for ; Tue, 09 Mar 2021 08:37:04 -0800 X-IronPort-AV: E=Sophos;i="5.81,236,1610377200"; d="scan'208";a="74590988" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:03 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4FB0040A2EDA; Wed, 10 Mar 2021 01:37:02 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 03/40] media: v4l2-async: Accept endpoints and devices for fwnode matching Date: Tue, 9 Mar 2021 16:36:19 +0000 Message-Id: <20210309163656.20944-4-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: 2AVHQu7qGfhYmnN86KEaI36Wx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307824; bh=72jXPlA5DEu7EffmBFpWdUTO32kf1oZRMLbPtXQthLU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=a17OZ0KGuvuWzmkIwbyOYibVF47sSWyky0Yc49H8ukNtYLb5fOxdLR6iIjvVtgGn43R jx+7POlJ0+sG1WPgEpC7IKok9mFIx7zACOxIx0n/PFC1f478DXkmSl/qtuOin6ARkkkN3 rxfjh1tRDvS5jk1c8a6PdfmbjJXpOFtInOk= From: Laurent Pinchart commit b98158d837efa0b2f2f59ee2ff77f4791f978d74 upstream. fwnode matching was designed to match on nodes corresponding to a device. Some drivers, however, needed to match on endpoints, and have passed endpoint fwnodes to v4l2-async. This works when both the subdev and the notifier use the same fwnode types (endpoint or device), but makes drivers that use different types incompatible. Fix this by extending the fwnode match to handle fwnodes of different types. When the types (deduced from the presence of remote endpoints) are different, retrieve the device fwnode for the side that provides an endpoint fwnode, and compare it with the device fwnode provided by the other side. This allows interoperability between all drivers, regardless of which type of fwnode they use for matching. Signed-off-by: Laurent Pinchart Tested-by: Lad Prabhakar Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Tested-by: Niklas Söderlund Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Lad Prabhakar --- drivers/media/v4l2-core/v4l2-async.c | 43 +++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 2b08d03b251d..72f8c070ad9d 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -73,7 +73,48 @@ static bool match_devname(struct v4l2_subdev *sd, static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { - return sd->fwnode == asd->match.fwnode; + struct fwnode_handle *other_fwnode; + struct fwnode_handle *dev_fwnode; + bool asd_fwnode_is_ep; + bool sd_fwnode_is_ep; + + /* + * Both the subdev and the async subdev can provide either an endpoint + * fwnode or a device fwnode. Start with the simple case of direct + * fwnode matching. + */ + if (sd->fwnode == asd->match.fwnode) + return true; + + /* + * Otherwise, check if the sd fwnode and the asd fwnode refer to an + * endpoint or a device. If they're of the same type, there's no match. + * Technically speaking this checks if the nodes refer to a connected + * endpoint, which is the simplest check that works for both OF and + * ACPI. This won't make a difference, as drivers should not try to + * match unconnected endpoints. + */ + sd_fwnode_is_ep = fwnode_graph_is_endpoint(sd->fwnode); + asd_fwnode_is_ep = fwnode_graph_is_endpoint(asd->match.fwnode); + + if (sd_fwnode_is_ep == asd_fwnode_is_ep) + return false; + + /* + * The sd and asd fwnodes are of different types. Get the device fwnode + * parent of the endpoint fwnode, and compare it with the other fwnode. + */ + if (sd_fwnode_is_ep) { + dev_fwnode = fwnode_graph_get_port_parent(sd->fwnode); + other_fwnode = asd->match.fwnode; + } else { + dev_fwnode = fwnode_graph_get_port_parent(asd->match.fwnode); + other_fwnode = sd->fwnode; + } + + fwnode_handle_put(dev_fwnode); + + return dev_fwnode == other_fwnode; } static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) From patchwork Tue Mar 9 16:36:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126009 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 4995CC433E0 for ; Tue, 9 Mar 2021 16:37:06 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE506651BB for ; Tue, 9 Mar 2021 16:37:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE506651BB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6219+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id NNVhYY4521723xp5pgZk4hmz; Tue, 09 Mar 2021 08:37:05 -0800 X-Received: from relmlie6.idc.renesas.com (relmlie6.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11724.1615307821262695682 for ; Tue, 09 Mar 2021 08:37:05 -0800 X-IronPort-AV: E=Sophos;i="5.81,234,1610377200"; d="scan'208";a="74342216" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:04 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id A028D40A2EDA; Wed, 10 Mar 2021 01:37:03 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 04/40] media: v4l2-async: Pass notifier pointer to match functions Date: Tue, 9 Mar 2021 16:36:20 +0000 Message-Id: <20210309163656.20944-5-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: AyzCLl9ZB8WnHLw1aYB1f0g8x4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307825; bh=51LkFWGE7ZbLUhIR74bQlaTAdbKseL6TYTELvGbyK/Q=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=mGVQ3RSSyN5l9RBGe+hchwUopMUSlmxHpPxTD4j9UbZGhx09thXwCgBOuhgomDUXs40 RxKXFIik72DymVTKy4YpiPAcI9Ysmrji3IGqHMbCv5Op3nd8pjQ1HNxa4P6Q/ntYSA0Fd eURIetzPl73MgHw9yuOeeyz/zN4tgV8IiFQ= From: Laurent Pinchart commit 3e33392a9561fd64515049317041646ab3bf32aa upstream. The notifier is useful to match functions to access information about the device matching a subdev. This will be used to print messages using the correct struct device and driver name. Signed-off-by: Laurent Pinchart Tested-by: Lad Prabhakar Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Tested-by: Niklas Söderlund Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab [PL: manually applied the changes] Signed-off-by: Lad Prabhakar --- drivers/media/v4l2-core/v4l2-async.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 72f8c070ad9d..0ee5e9f51877 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -53,7 +53,8 @@ static int v4l2_async_notifier_call_complete(struct v4l2_async_notifier *n) return n->ops->complete(n); } -static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) +static bool match_i2c(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { #if IS_ENABLED(CONFIG_I2C) struct i2c_client *client = i2c_verify_client(sd->dev); @@ -65,13 +66,14 @@ static bool match_i2c(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) #endif } -static bool match_devname(struct v4l2_subdev *sd, - struct v4l2_async_subdev *asd) +static bool match_devname(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { return !strcmp(asd->match.device_name, dev_name(sd->dev)); } -static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) +static bool match_fwnode(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { struct fwnode_handle *other_fwnode; struct fwnode_handle *dev_fwnode; @@ -117,7 +119,8 @@ static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) return dev_fwnode == other_fwnode; } -static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) +static bool match_custom(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { if (!asd->match.custom.match) /* Match always */ @@ -133,7 +136,8 @@ static DEFINE_MUTEX(list_lock); static struct v4l2_async_subdev *v4l2_async_find_match( struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd) { - bool (*match)(struct v4l2_subdev *, struct v4l2_async_subdev *); + bool (*match)(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, struct v4l2_async_subdev *asd); struct v4l2_async_subdev *asd; list_for_each_entry(asd, ¬ifier->waiting, list) { @@ -158,7 +162,7 @@ static struct v4l2_async_subdev *v4l2_async_find_match( } /* match cannot be NULL here */ - if (match(sd, asd)) + if (match(notifier, sd, asd)) return asd; } From patchwork Tue Mar 9 16:36:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126017 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 74418C43381 for ; Tue, 9 Mar 2021 16:37:07 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B95864F35 for ; Tue, 9 Mar 2021 16:37:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B95864F35 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6220+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id xiRAYY4521723xp0LPOSRYOM; Tue, 09 Mar 2021 08:37:06 -0800 X-Received: from relmlie6.idc.renesas.com (relmlie6.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11724.1615307821262695682 for ; Tue, 09 Mar 2021 08:37:06 -0800 X-IronPort-AV: E=Sophos;i="5.81,234,1610377200"; d="scan'208";a="74342219" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:05 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id EFB6A40A2EDA; Wed, 10 Mar 2021 01:37:04 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 05/40] media: v4l2-async: Log message in case of heterogeneous fwnode match Date: Tue, 9 Mar 2021 16:36:21 +0000 Message-Id: <20210309163656.20944-6-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: KdOIYHhCvFIAeT6yxpkfPIIpx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307826; bh=mU4EEW33vwf29SkXtH4XF0JEAJ2TlbVk2o3bWV/Fekc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=lzDfcnfT7xzAGZKSSZJC9AhYjkdOzuZcbJGruE7xnTEvwxlV7Ya36O9Dxm2vLetidGr BfIEz/QrXFjlBzxFWS5Po9s7cWOuFAkD2blRYZ791HX8aHG5LByKhU9nzC9nB8s0kNVnN RpuOMQgyY8Yd8eWTCvBwjrOiByobD2KSCv8= From: Laurent Pinchart commit e80cdf0a3843fe570c891cb976feb0c136b19fb7 upstream. When a notifier supplies a device fwnode and a subdev supplies an endpoint fwnode, incorrect matches may occur if multiple subdevs correspond to the same device fwnode. This can't be handled transparently in the framework, and requires the notifier to switch to endpoint fwnodes. Log a message to notify of this problem. A second message is added to help accelerating the transition to endpoint matching. Signed-off-by: Laurent Pinchart Tested-by: Lad Prabhakar Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Tested-by: Niklas Söderlund Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Lad Prabhakar --- drivers/media/v4l2-core/v4l2-async.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 0ee5e9f51877..72285709c4c2 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -79,6 +79,7 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier, struct fwnode_handle *dev_fwnode; bool asd_fwnode_is_ep; bool sd_fwnode_is_ep; + struct device *dev; /* * Both the subdev and the async subdev can provide either an endpoint @@ -116,7 +117,28 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier, fwnode_handle_put(dev_fwnode); - return dev_fwnode == other_fwnode; + if (dev_fwnode != other_fwnode) + return false; + + /* + * We have a heterogeneous match. Retrieve the struct device of the side + * that matched on a device fwnode to print its driver name. + */ + if (sd_fwnode_is_ep) + dev = notifier->v4l2_dev ? notifier->v4l2_dev->dev + : notifier->sd->dev; + else + dev = sd->dev; + + if (dev && dev->driver) { + if (sd_fwnode_is_ep) + dev_warn(dev, "Driver %s uses device fwnode, incorrect match may occur\n", + dev->driver->name); + dev_notice(dev, "Consider updating driver %s to match on endpoints\n", + dev->driver->name); + } + + return true; } static bool match_custom(struct v4l2_async_notifier *notifier, From patchwork Tue Mar 9 16:36:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126015 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MIME_HEADER_CTYPE_ONLY,SPF_HELO_NONE,SPF_PASS, T_TVD_MIME_NO_HEADERS 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 ED3A7C433DB for ; Tue, 9 Mar 2021 16:37:08 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 912C764FF3 for ; Tue, 9 Mar 2021 16:37:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 912C764FF3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6222+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id gihlYY4521723xhb6jIn7kDF; Tue, 09 Mar 2021 08:37:08 -0800 X-Received: from relmlie5.idc.renesas.com (relmlie5.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11726.1615307822860198874 for ; Tue, 09 Mar 2021 08:37:07 -0800 X-IronPort-AV: E=Sophos;i="5.81,236,1610377200"; d="scan'208";a="74591000" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:07 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 488AE40A2DC7; Wed, 10 Mar 2021 01:37:06 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 06/40] media: v4l: ctrl: Provide unlocked variant of v4l2_ctrl_grab Date: Tue, 9 Mar 2021 16:36:22 +0000 Message-Id: <20210309163656.20944-7-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: QPauzGI7KoiuF6UbQ6CN4N0vx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307828; bh=7vMrYFr52k5eUaBP04rDOLikcUlxyfcRLFbrZRGKHP0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=TAmcQrGA1Ir2ZCdwiiAu8mYeljKBYIt8QtNhd7d3SALyZfH7olOvcrqOnhT7eEKWb+r 4o86zfd6hq9D3g8cFiiEZMfF+umyNbWYIxukvzviMo3zoaSDA+2f8XNcO+9EVJzz/uBmW Q4/TwM1fABNbX92vYGRI3B8Sb7rnwf/YvjI= From: Sakari Ailus commit 7a9b109d91cfc6089006378efd515cc287bdef67 upstream. Sometimes it may be necessary to grab a control while holding the control handler's lock. Provide an unlocked variant of v4l2_ctrl_grab for the purpose --- it's called __v4l2_ctrl_grab. Signed-off-by: Sakari Ailus Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab [PL: manually applied the changes] Signed-off-by: Lad Prabhakar --- drivers/media/v4l2-core/v4l2-ctrls.c | 8 ++++---- include/media/v4l2-ctrls.h | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index f4ebff347d7a..6868c1990534 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -2517,14 +2517,15 @@ EXPORT_SYMBOL(v4l2_ctrl_activate); Just call this and the framework will block any attempts to change these controls. */ -void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) +void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) { bool old; if (ctrl == NULL) return; - v4l2_ctrl_lock(ctrl); + lockdep_assert_held(ctrl->handler->lock); + if (grabbed) /* set V4L2_CTRL_FLAG_GRABBED */ old = test_and_set_bit(1, &ctrl->flags); @@ -2533,9 +2534,8 @@ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) old = test_and_clear_bit(1, &ctrl->flags); if (old != grabbed) send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_FLAGS); - v4l2_ctrl_unlock(ctrl); } -EXPORT_SYMBOL(v4l2_ctrl_grab); +EXPORT_SYMBOL(__v4l2_ctrl_grab); /* Log the control name and value */ static void log_ctrl(const struct v4l2_ctrl *ctrl, diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index f615ba1b29dd..ff89df428f79 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -728,6 +728,22 @@ struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id); */ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active); +/** + * __v4l2_ctrl_grab() - Unlocked variant of v4l2_ctrl_grab. + * + * @ctrl: The control to (de)activate. + * @grabbed: True if the control should become grabbed. + * + * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically. + * Does nothing if @ctrl == NULL. + * The V4L2_EVENT_CTRL event will be generated afterwards. + * This will usually be called when starting or stopping streaming in the + * driver. + * + * This function assumes that the control handler is locked by the caller. + */ +void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); + /** * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed. * @@ -743,7 +759,15 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active); * This function assumes that the control handler is not locked and will * take the lock itself. */ -void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); +static inline void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) +{ + if (!ctrl) + return; + + v4l2_ctrl_lock(ctrl); + __v4l2_ctrl_grab(ctrl, grabbed); + v4l2_ctrl_unlock(ctrl); +} /** *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range() From patchwork Tue Mar 9 16:36:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126019 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 26A92C433E0 for ; Tue, 9 Mar 2021 16:37:11 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D516E64FF3 for ; Tue, 9 Mar 2021 16:37:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D516E64FF3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6223+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id IF1hYY4521723xvmUBC9AUg6; Tue, 09 Mar 2021 08:37:10 -0800 X-Received: from relmlie6.idc.renesas.com (relmlie6.idc.renesas.com [210.160.252.172]) by mx.groups.io with SMTP id smtpd.web11.11727.1615307829143333394 for ; Tue, 09 Mar 2021 08:37:09 -0800 X-IronPort-AV: E=Sophos;i="5.81,234,1610377200"; d="scan'208";a="74342222" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:08 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 9C19340A2DC7; Wed, 10 Mar 2021 01:37:07 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 07/40] media: rcar-vin: fix wrong return value in rvin_set_channel_routing() Date: Tue, 9 Mar 2021 16:36:23 +0000 Message-Id: <20210309163656.20944-8-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: Lyjp7KSq8wWd98lOUpaBNnqlx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307830; bh=n/gkZT6+WTgPY1GtfTLDg7oh51YKOG6AebF9fbtArx0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=loy2I5FaP24HX287dYLsFGOktXZlJcM+WtJxPRpRWswj1D2bxX/8TLetG3Qr/AFqTWQ QzRSies18nioKwFvqpWJH1OtgzVlITdtzQKDHT7PTvxuKoTXj6zhM4IMA/xJqzN6LY9ko xPdr2OrHKZNWewDQNcl7iNNYp2Ht7gSYqIw= From: Niklas Söderlund commit 8d19d5d03b4d09177b0ae87f964eb751e6f51b7b upstream. If the operation in rvin_set_channel_routing() is successful the 'ret' variable contains the runtime PM use count for the VIN master device. The intention is not to return the use count to the caller but to return 0 on success else none zero. Fix this by always returning 0 if the operation is successful. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Lad Prabhakar --- drivers/media/platform/rcar-vin/rcar-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index 70a8cc433a03..e51620c6cc40 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -1343,5 +1343,5 @@ int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel) pm_runtime_put(vin->dev); - return ret; + return 0; } From patchwork Tue Mar 9 16:36:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126021 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 9B96EC433DB for ; Tue, 9 Mar 2021 16:37:11 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 26CAE64F35 for ; Tue, 9 Mar 2021 16:37:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26CAE64F35 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6224+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id 9ADpYY4521723xO9zqxgCZ1v; Tue, 09 Mar 2021 08:37:10 -0800 X-Received: from relmlie6.idc.renesas.com (relmlie6.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11727.1615307829143333394 for ; Tue, 09 Mar 2021 08:37:10 -0800 X-IronPort-AV: E=Sophos;i="5.81,234,1610377200"; d="scan'208";a="74342226" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:09 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id E7E5540A2DC7; Wed, 10 Mar 2021 01:37:08 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 08/40] media: rcar-csi2: Update V3M and E3 start procedure Date: Tue, 9 Mar 2021 16:36:24 +0000 Message-Id: <20210309163656.20944-9-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: dvJCHoY1A9cvB6XxvwDKNIslx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307830; bh=xfsYAa8dDY8CuQ+UbpbdauCSbKf0FzbRVRh8gG84Kk0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Cv1SEtYZTg/F8HEk15Y9V6yxkclL6lCQSsSs79YlBV4C8weKCmZUsy+lY0dT0Ijldfz WkRCS0PndgzRRCqUiUWk+Z6WDs8KSAZiAaQkQP0EKa+292ebCLCzeNNC5NGLm8vXChFp/ 70AuLU6yJ+CnU7vo1YX+ci+ZboX6ctZ/PBo= From: Niklas Söderlund commit c1421f1d6c29d6b6234e5b0894ef16b3f2a172e0 upstream. The latest datasheet (rev 1.50) updates the start procedure for V3M and E3. Update the driver to match these changes. Signed-off-by: Niklas Söderlund Reviewed-by: Ulrich Hecht Reviewed-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Lad Prabhakar --- drivers/media/platform/rcar-vin/rcar-csi2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index 007e2383d34e..1c910fdbf4c0 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -898,11 +898,11 @@ static int rcsi2_init_phtw_v3m_e3(struct rcar_csi2 *priv, unsigned int mbps) static int rcsi2_confirm_start_v3m_e3(struct rcar_csi2 *priv) { static const struct phtw_value step1[] = { - { .data = 0xed, .code = 0x34 }, - { .data = 0xed, .code = 0x44 }, - { .data = 0xed, .code = 0x54 }, - { .data = 0xed, .code = 0x84 }, - { .data = 0xed, .code = 0x94 }, + { .data = 0xee, .code = 0x34 }, + { .data = 0xee, .code = 0x44 }, + { .data = 0xee, .code = 0x54 }, + { .data = 0xee, .code = 0x84 }, + { .data = 0xee, .code = 0x94 }, { /* sentinel */ }, }; From patchwork Tue Mar 9 16:36:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126023 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 E5207C433E9 for ; Tue, 9 Mar 2021 16:37:12 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 88634651BB for ; Tue, 9 Mar 2021 16:37:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 88634651BB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6225+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id ICmDYY4521723xybzZSTsAbY; Tue, 09 Mar 2021 08:37:12 -0800 X-Received: from relmlie6.idc.renesas.com (relmlie6.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11727.1615307829143333394 for ; Tue, 09 Mar 2021 08:37:11 -0800 X-IronPort-AV: E=Sophos;i="5.81,234,1610377200"; d="scan'208";a="74342229" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:11 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 41FE840A2DC7; Wed, 10 Mar 2021 01:37:10 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 09/40] media: rcar-vin: Invalidate pipeline if conversion is not possible on input formats Date: Tue, 9 Mar 2021 16:36:25 +0000 Message-Id: <20210309163656.20944-10-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: EobNw2kq3f3sEFAQ8HkqRVFrx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307832; bh=boJlbpMDVAlcZ/cQfEW5/6h0uW6GW3TZkSUXqYqe6ro=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Jsi/2iUus84m/C7KcQZs7xLwTQBm4CsdVZHFS2vZZ7eaQfMfP8dSvZPozTlxnP4W4FI gec400eXqWAsDtA9VRfZC6NWdvbgcgMcLHMkCvn14QruLf0jxtjUWRUfxTSjENSjxjh12 rS7/xa8N0mwyKX8URGNf+QKWX9M0DI31+Ec= commit fd22e8eb4145852223b36b0e6c7e308ed5905ad2 upstream. Up until now the VIN was capable to convert any of its supported input mbus formats to any of it's supported output pixel formats. With the addition of RAW formats this is no longer true. This patch invalidates the pipeline by adding a check if given vin input format can be converted to supported output pixel format. Signed-off-by: Lad Prabhakar Reviewed-by: Niklas Söderlund Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab [PL: dropped changes from rvin_enum_fmt_vid_cap()] Signed-off-by: Lad Prabhakar --- drivers/media/platform/rcar-vin/rcar-dma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index e51620c6cc40..5bab9f8159f6 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -1042,11 +1042,15 @@ static int rvin_mc_validate_format(struct rvin_dev *vin, struct v4l2_subdev *sd, case MEDIA_BUS_FMT_UYVY8_2X8: case MEDIA_BUS_FMT_UYVY10_2X10: case MEDIA_BUS_FMT_RGB888_1X24: - vin->mbus_code = fmt.format.code; + break; + case MEDIA_BUS_FMT_SRGGB8_1X8: + if (vin->format.pixelformat != V4L2_PIX_FMT_SRGGB8) + return -EPIPE; break; default: return -EPIPE; } + vin->mbus_code = fmt.format.code; switch (fmt.format.field) { case V4L2_FIELD_TOP: From patchwork Tue Mar 9 16:36:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126025 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 EC4BBC433DB for ; Tue, 9 Mar 2021 16:37:13 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B618E64F35 for ; Tue, 9 Mar 2021 16:37:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B618E64F35 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6226+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id 8rKqYY4521723xhjikRI5vGR; Tue, 09 Mar 2021 08:37:13 -0800 X-Received: from relmlie5.idc.renesas.com (relmlie5.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11726.1615307822860198874 for ; Tue, 09 Mar 2021 08:37:13 -0800 X-IronPort-AV: E=Sophos;i="5.81,236,1610377200"; d="scan'208";a="74591005" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:12 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 8F82040A2DC7; Wed, 10 Mar 2021 01:37:11 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 10/40] media: rcar-vin: Add support for MEDIA_BUS_FMT_SRGGB8_1X8 format Date: Tue, 9 Mar 2021 16:36:26 +0000 Message-Id: <20210309163656.20944-11-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: t0WGrhFaaPedyWfyWdKPj9SWx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307833; bh=9kArxn3Nw+BvONVIyApdqDWlt+LkIL9dtRpG+VYEkhI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=RP5ZxMbidCkdDE0NScZVQLiBvpqZSBkfiUN007dPfZjGa81cwAt8I0g6m98Fzho3MmD 6f7Q48UOGi92fLQWh0M23ZRjiz91TGfYxplsOLRUQZYIfca+oy+5e9TAqVYI1eIrRk9jo sxs6STXJ5oe+t7/GDA4l/bO2vnFXZ+hQaV8= commit e87c1a81f158d6fc7b3346eb88c2d76a044f837d upstream. Add support for MEDIA_BUS_FMT_SRGGB8_1X8 format in rcar-vin by setting format type to RAW8 in VNMC register and appropriately setting the bpp and bytesperline to enable V4L2_PIX_FMT_SRGGB8. Signed-off-by: Lad Prabhakar Reviewed-by: Niklas Söderlund Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab [PL: manually applied the changes; rvin_parallel_subdevice_attach() updated to handle MEDIA_BUS_FMT_SRGGB8_1X8 format; VNIS_REG is set accordingly in rvin_crop_scale_comp() for V4L2_PIX_FMT_SRGGB8] Signed-off-by: Lad Prabhakar --- drivers/media/platform/rcar-vin/rcar-core.c | 1 + drivers/media/platform/rcar-vin/rcar-dma.c | 9 +++++++++ drivers/media/platform/rcar-vin/rcar-v4l2.c | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c index bd298bbbc48d..79d1a8a730ad 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -447,6 +447,7 @@ static int rvin_parallel_subdevice_attach(struct rvin_dev *vin, case MEDIA_BUS_FMT_UYVY8_2X8: case MEDIA_BUS_FMT_UYVY10_2X10: case MEDIA_BUS_FMT_RGB888_1X24: + case MEDIA_BUS_FMT_SRGGB8_1X8: vin->mbus_code = code.code; vin_dbg(vin, "Found media bus format for %s: %d\n", subdev->name, vin->mbus_code); diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index 5bab9f8159f6..0d56957a54cc 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -85,6 +85,7 @@ #define VNMC_INF_YUV8_BT601 (1 << 16) #define VNMC_INF_YUV10_BT656 (2 << 16) #define VNMC_INF_YUV10_BT601 (3 << 16) +#define VNMC_INF_RAW8 (4 << 16) #define VNMC_INF_YUV16 (5 << 16) #define VNMC_INF_RGB888 (6 << 16) #define VNMC_VUP (1 << 10) @@ -599,6 +600,8 @@ void rvin_crop_scale_comp(struct rvin_dev *vin) if (vin->format.pixelformat == V4L2_PIX_FMT_NV16) rvin_write(vin, ALIGN(vin->format.width, 0x20), VNIS_REG); + else if (vin->format.pixelformat == V4L2_PIX_FMT_SRGGB8) + rvin_write(vin, ALIGN(vin->format.width / 2, 0x10), VNIS_REG); else rvin_write(vin, ALIGN(vin->format.width, 0x10), VNIS_REG); } @@ -677,6 +680,9 @@ static int rvin_setup(struct rvin_dev *vin) input_is_yuv = true; break; + case MEDIA_BUS_FMT_SRGGB8_1X8: + vnmc |= VNMC_INF_RAW8; + break; default: break; } @@ -730,6 +736,9 @@ static int rvin_setup(struct rvin_dev *vin) /* Note: not supported on M1 */ dmr = VNDMR_EXRGB; break; + case V4L2_PIX_FMT_SRGGB8: + dmr = 0; + break; default: vin_err(vin, "Invalid pixelformat (0x%x)\n", vin->format.pixelformat); diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 1236e6e8228c..c07e57f707ec 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -54,6 +54,10 @@ static const struct rvin_video_format rvin_formats[] = { .fourcc = V4L2_PIX_FMT_XBGR32, .bpp = 4, }, + { + .fourcc = V4L2_PIX_FMT_SRGGB8, + .bpp = 1, + }, }; const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat) From patchwork Tue Mar 9 16:36:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126027 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 991D3C433E6 for ; Tue, 9 Mar 2021 16:37:16 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BB4D64F35 for ; Tue, 9 Mar 2021 16:37:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BB4D64F35 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6227+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id ExMeYY4521723xVKX7puJOR3; Tue, 09 Mar 2021 08:37:16 -0800 X-Received: from relmlie6.idc.renesas.com (relmlie6.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11727.1615307829143333394 for ; Tue, 09 Mar 2021 08:37:14 -0800 X-IronPort-AV: E=Sophos;i="5.81,234,1610377200"; d="scan'208";a="74342232" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:13 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id DF5CB40A2DC7; Wed, 10 Mar 2021 01:37:12 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 11/40] media: rcar-csi2: Add support for MEDIA_BUS_FMT_SRGGB8_1X8 format Date: Tue, 9 Mar 2021 16:36:27 +0000 Message-Id: <20210309163656.20944-12-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: HJPpbv9y28YyML85ZFX2aAabx4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307836; bh=EnDWXVLRJ/f2UoKrw/9lJ3+y3PF1R3xtcMrNULYJx8c=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=g4L8xve0Uklz3LYny/UMxHm6VG4VPdkwEiR8RX0znxNWRlyExNhRRNmYqUOBbMuH/16 3reglMvGK6ziLWxOpaOsgFQU/VX54yJ0Uzi2Upb7q07MZejOUVXZegC8M2m+cc3KVhGa9 e6cXwpl9MRVeDPTZuS9Kg9LgE6T8usWtrlo= commit 675616554d0a5caff138008ee9bd4623bc4390b2 upstream. This patch adds support for MEDIA_BUS_FMT_SRGGB8_1X8 format for CSI2 input. Signed-off-by: Lad Prabhakar Reviewed-by: Niklas Söderlund Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Lad Prabhakar --- drivers/media/platform/rcar-vin/rcar-csi2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index 1c910fdbf4c0..e6a531c4fde5 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -315,6 +315,7 @@ static const struct rcar_csi2_format rcar_csi2_formats[] = { { .code = MEDIA_BUS_FMT_YUYV8_1X16, .datatype = 0x1e, .bpp = 16 }, { .code = MEDIA_BUS_FMT_UYVY8_2X8, .datatype = 0x1e, .bpp = 16 }, { .code = MEDIA_BUS_FMT_YUYV10_2X10, .datatype = 0x1e, .bpp = 20 }, + { .code = MEDIA_BUS_FMT_SRGGB8_1X8, .datatype = 0x2a, .bpp = 8 }, }; static const struct rcar_csi2_format *rcsi2_code_to_fmt(unsigned int code) From patchwork Tue Mar 9 16:36:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126029 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-18.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,MIME_HEADER_CTYPE_ONLY,SPF_HELO_NONE, SPF_PASS,T_TVD_MIME_NO_HEADERS 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 0C63AC433E0 for ; Tue, 9 Mar 2021 16:37:18 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5A3F64F35 for ; Tue, 9 Mar 2021 16:37:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5A3F64F35 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6228+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id GWt1YY4521723xCMJWKzyq1v; Tue, 09 Mar 2021 08:37:17 -0800 X-Received: from relmlie5.idc.renesas.com (relmlie5.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11726.1615307822860198874 for ; Tue, 09 Mar 2021 08:37:15 -0800 X-IronPort-AV: E=Sophos;i="5.81,236,1610377200"; d="scan'208";a="74591008" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:15 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 397F240A2DC7; Wed, 10 Mar 2021 01:37:14 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 12/40] media: dt-bindings: media: i2c: Add IMX219 CMOS sensor binding Date: Tue, 9 Mar 2021 16:36:28 +0000 Message-Id: <20210309163656.20944-13-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: 3VvuwrsJo6zl2KrKpMlmzhC1x4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307837; bh=+t0A8Hz0rwJdY2ZI0nBgzW1Lvp0EOrxrz083MRiLO1w=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=DJ30XfKb6SpRJUKGoya/rkfVbw6Std6a5FbwvE90AMTfv59SKigIBlMMos4xgmHYq4N FkWEXMPSxoLPXDqKbvIYJmwkP6mdJyaPJEoGDI7bVG0lVlvP2y0/TdCtQcb55XM6GNXow OURzkhrOu5NyX0RecBCUoLNbdCfGIx8xq7Q= From: Andrey Konovalov commit 9d730f2cf4c0391785855dd231577d2de2594df9 upstream. Add YAML device tree binding for IMX219 CMOS image sensor, and the relevant MAINTAINERS entries. Signed-off-by: Andrey Konovalov Reviewed-by: Rob Herring Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab [PL: manually applied changes to MAINTAINERS file] Signed-off-by: Lad Prabhakar --- .../devicetree/bindings/media/i2c/imx219.yaml | 114 ++++++++++++++++++ MAINTAINERS | 8 ++ 2 files changed, 122 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/imx219.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/imx219.yaml b/Documentation/devicetree/bindings/media/i2c/imx219.yaml new file mode 100644 index 000000000000..32d6b693274f --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/imx219.yaml @@ -0,0 +1,114 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/imx219.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony 1/4.0-Inch 8Mpixel CMOS Digital Image Sensor + +maintainers: + - Dave Stevenson + +description: |- + The Sony imx219 is a 1/4.0-inch CMOS active pixel digital image sensor + with an active array size of 3280H x 2464V. It is programmable through + I2C interface. The I2C address is fixed to 0x10 as per sensor data sheet. + Image data is sent through MIPI CSI-2, which is configured as either 2 or + 4 data lanes. + +properties: + compatible: + const: sony,imx219 + + reg: + description: I2C device address + maxItems: 1 + + clocks: + maxItems: 1 + + VDIG-supply: + description: + Digital I/O voltage supply, 1.8 volts + + VANA-supply: + description: + Analog voltage supply, 2.8 volts + + VDDL-supply: + description: + Digital core voltage supply, 1.2 volts + + reset-gpios: + description: |- + Reference to the GPIO connected to the xclr pin, if any. + Must be released (set high) after all supplies are applied. + + # See ../video-interfaces.txt for more details + port: + type: object + properties: + endpoint: + type: object + properties: + data-lanes: + description: |- + The sensor supports either two-lane, or four-lane operation. + If this property is omitted four-lane operation is assumed. + For two-lane operation the property must be set to <1 2>. + items: + - const: 1 + - const: 2 + + clock-noncontinuous: + type: boolean + description: |- + MIPI CSI-2 clock is non-continuous if this property is present, + otherwise it's continuous. + + link-frequencies: + allOf: + - $ref: /schemas/types.yaml#/definitions/uint64-array + description: + Allowed data bus frequencies. + + required: + - link-frequencies + +required: + - compatible + - reg + - clocks + - VANA-supply + - VDIG-supply + - VDDL-supply + - port + +additionalProperties: false + +examples: + - | + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + imx219: sensor@10 { + compatible = "sony,imx219"; + reg = <0x10>; + clocks = <&imx219_clk>; + VANA-supply = <&imx219_vana>; /* 2.8v */ + VDIG-supply = <&imx219_vdig>; /* 1.8v */ + VDDL-supply = <&imx219_vddl>; /* 1.2v */ + + port { + imx219_0: endpoint { + remote-endpoint = <&csi1_ep>; + data-lanes = <1 2>; + clock-noncontinuous; + link-frequencies = /bits/ 64 <456000000>; + }; + }; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 1061db6fbc32..47986d4b599a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13565,6 +13565,14 @@ S: Maintained F: drivers/ssb/ F: include/linux/ssb/ +SONY IMX219 SENSOR DRIVER +M: Dave Stevenson +L: linux-media@vger.kernel.org +T: git git://linuxtv.org/media_tree.git +S: Maintained +F: drivers/media/i2c/imx219.c +F: Documentation/devicetree/bindings/media/i2c/imx219.yaml + SONY IMX258 SENSOR DRIVER M: Sakari Ailus L: linux-media@vger.kernel.org From patchwork Tue Mar 9 16:36:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 12126033 X-Patchwork-Delegate: iwamatsu@nigauri.org 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=-13.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MIME_HEADER_CTYPE_ONLY,SPF_HELO_NONE,SPF_PASS, T_TVD_MIME_NO_HEADERS 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 91915C433DB for ; Tue, 9 Mar 2021 16:37:18 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55DC664F35 for ; Tue, 9 Mar 2021 16:37:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55DC664F35 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+6229+4520388+8129055@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id ZXIlYY4521723xhN6sXAEIzX; Tue, 09 Mar 2021 08:37:18 -0800 X-Received: from relmlie6.idc.renesas.com (relmlie6.idc.renesas.com []) by mx.groups.io with SMTP id smtpd.web11.11727.1615307829143333394 for ; Tue, 09 Mar 2021 08:37:17 -0800 X-IronPort-AV: E=Sophos;i="5.81,234,1610377200"; d="scan'208";a="74342235" X-Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Mar 2021 01:37:16 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 8C9BE40A2DC7; Wed, 10 Mar 2021 01:37:15 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.19.y-cip 13/40] media: i2c: Add driver for Sony IMX219 sensor Date: Tue, 9 Mar 2021 16:36:29 +0000 Message-Id: <20210309163656.20944-14-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210309163656.20944-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: FE7VIo1lvttvCk9uPEHxUWJex4520388AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1615307838; bh=fbiCRF4b1CRL3PieX/BEvsjEfuYDY+HX6zamlpjhi8g=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=wxeKxpX+hafO0vEj13TTa7/q/SHVOuqcwvtEWeVGLMNrKdq237enUZlT/OV7FfzLjC4 oqCiHkNPM9RpHe0dqXspGJHQdTVnqSpGmG55Qq7dIKjJbXncxegt4diTH0U+Ma6zNF0vZ f/wBpknuW/BPnHArE9/QCrne6h/M9THjNJ4= From: Dave Stevenson commit 1283b3b8f82b9004fbb94398cade5c8e797a2c8d upstream. Adds a driver for the 8MPix Sony IMX219 CSI2 sensor. Whilst the sensor supports 2 or 4 CSI2 data lanes, this driver currently only supports 2 lanes. 8MPix @ 15fps, 1080P @ 30fps (cropped FOV), and 1640x1232 (2x2 binned) @ 30fps are currently supported. [Sakari Ailus: make imx219_check_hwcfg static] Signed-off-by: Dave Stevenson Signed-off-by: Andrey Konovalov Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab [PL: passed single arg to v4l2_fwnode_endpoint_alloc_parse(); replaced fwnode_handle_put() with of_node_put(); included linux/of_graph.h; replaced fwnode_graph_get_next_endpoint() with of_graph_get_next_endpoint(); manually applied changes to Makefile] Signed-off-by: Lad Prabhakar --- drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/imx219.c | 1312 ++++++++++++++++++++++++++++++++++++ 3 files changed, 1324 insertions(+) create mode 100644 drivers/media/i2c/imx219.c diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 8b1ae1d6680b..e93ac35eca00 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -597,6 +597,17 @@ config VIDEO_APTINA_PLL config VIDEO_SMIAPP_PLL tristate +config VIDEO_IMX219 + tristate "Sony IMX219 sensor support" + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + help + This is a Video4Linux2 sensor driver for the Sony + IMX219 camera. + + To compile this driver as a module, choose M here: the + module will be called imx219. + config VIDEO_IMX258 tristate "Sony IMX258 sensor support" depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index 520b3c3bf48c..8b4fe01411b9 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -106,6 +106,7 @@ obj-$(CONFIG_VIDEO_I2C) += video-i2c.o obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o obj-$(CONFIG_VIDEO_OV2659) += ov2659.o obj-$(CONFIG_VIDEO_TC358743) += tc358743.o +obj-$(CONFIG_VIDEO_IMX219) += imx219.o obj-$(CONFIG_VIDEO_IMX258) += imx258.o obj-$(CONFIG_VIDEO_IMX274) += imx274.o diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c new file mode 100644 index 000000000000..c67b2cf5c32c --- /dev/null +++ b/drivers/media/i2c/imx219.c @@ -0,0 +1,1312 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * A V4L2 driver for Sony IMX219 cameras. + * Copyright (C) 2019, Raspberry Pi (Trading) Ltd + * + * Based on Sony imx258 camera driver + * Copyright (C) 2018 Intel Corporation + * + * DT / fwnode changes, and regulator / GPIO control taken from imx214 driver + * Copyright 2018 Qtechnology A/S + * + * Flip handling taken from the Sony IMX319 driver. + * Copyright (C) 2018 Intel Corporation + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define IMX219_REG_VALUE_08BIT 1 +#define IMX219_REG_VALUE_16BIT 2 + +#define IMX219_REG_MODE_SELECT 0x0100 +#define IMX219_MODE_STANDBY 0x00 +#define IMX219_MODE_STREAMING 0x01 + +/* Chip ID */ +#define IMX219_REG_CHIP_ID 0x0000 +#define IMX219_CHIP_ID 0x0219 + +/* External clock frequency is 24.0M */ +#define IMX219_XCLK_FREQ 24000000 + +/* Pixel rate is fixed at 182.4M for all the modes */ +#define IMX219_PIXEL_RATE 182400000 + +#define IMX219_DEFAULT_LINK_FREQ 456000000 + +/* V_TIMING internal */ +#define IMX219_REG_VTS 0x0160 +#define IMX219_VTS_15FPS 0x0dc6 +#define IMX219_VTS_30FPS_1080P 0x06e3 +#define IMX219_VTS_30FPS_BINNED 0x06e3 +#define IMX219_VTS_MAX 0xffff + +#define IMX219_VBLANK_MIN 4 + +/*Frame Length Line*/ +#define IMX219_FLL_MIN 0x08a6 +#define IMX219_FLL_MAX 0xffff +#define IMX219_FLL_STEP 1 +#define IMX219_FLL_DEFAULT 0x0c98 + +/* HBLANK control - read only */ +#define IMX219_PPL_DEFAULT 3448 + +/* Exposure control */ +#define IMX219_REG_EXPOSURE 0x015a +#define IMX219_EXPOSURE_MIN 4 +#define IMX219_EXPOSURE_STEP 1 +#define IMX219_EXPOSURE_DEFAULT 0x640 +#define IMX219_EXPOSURE_MAX 65535 + +/* Analog gain control */ +#define IMX219_REG_ANALOG_GAIN 0x0157 +#define IMX219_ANA_GAIN_MIN 0 +#define IMX219_ANA_GAIN_MAX 232 +#define IMX219_ANA_GAIN_STEP 1 +#define IMX219_ANA_GAIN_DEFAULT 0x0 + +/* Digital gain control */ +#define IMX219_REG_DIGITAL_GAIN 0x0158 +#define IMX219_DGTL_GAIN_MIN 0x0100 +#define IMX219_DGTL_GAIN_MAX 0x0fff +#define IMX219_DGTL_GAIN_DEFAULT 0x0100 +#define IMX219_DGTL_GAIN_STEP 1 + +#define IMX219_REG_ORIENTATION 0x0172 + +/* Test Pattern Control */ +#define IMX219_REG_TEST_PATTERN 0x0600 +#define IMX219_TEST_PATTERN_DISABLE 0 +#define IMX219_TEST_PATTERN_SOLID_COLOR 1 +#define IMX219_TEST_PATTERN_COLOR_BARS 2 +#define IMX219_TEST_PATTERN_GREY_COLOR 3 +#define IMX219_TEST_PATTERN_PN9 4 + +/* Test pattern colour components */ +#define IMX219_REG_TESTP_RED 0x0602 +#define IMX219_REG_TESTP_GREENR 0x0604 +#define IMX219_REG_TESTP_BLUE 0x0606 +#define IMX219_REG_TESTP_GREENB 0x0608 +#define IMX219_TESTP_COLOUR_MIN 0 +#define IMX219_TESTP_COLOUR_MAX 0x03ff +#define IMX219_TESTP_COLOUR_STEP 1 +#define IMX219_TESTP_RED_DEFAULT IMX219_TESTP_COLOUR_MAX +#define IMX219_TESTP_GREENR_DEFAULT 0 +#define IMX219_TESTP_BLUE_DEFAULT 0 +#define IMX219_TESTP_GREENB_DEFAULT 0 + +struct imx219_reg { + u16 address; + u8 val; +}; + +struct imx219_reg_list { + unsigned int num_of_regs; + const struct imx219_reg *regs; +}; + +/* Mode : resolution and related config&values */ +struct imx219_mode { + /* Frame width */ + unsigned int width; + /* Frame height */ + unsigned int height; + + /* V-timing */ + unsigned int vts_def; + + /* Default register values */ + struct imx219_reg_list reg_list; +}; + +/* + * Register sets lifted off the i2C interface from the Raspberry Pi firmware + * driver. + * 3280x2464 = mode 2, 1920x1080 = mode 1, and 1640x1232 = mode 4. + */ +static const struct imx219_reg mode_3280x2464_regs[] = { + {0x0100, 0x00}, + {0x30eb, 0x0c}, + {0x30eb, 0x05}, + {0x300a, 0xff}, + {0x300b, 0xff}, + {0x30eb, 0x05}, + {0x30eb, 0x09}, + {0x0114, 0x01}, + {0x0128, 0x00}, + {0x012a, 0x18}, + {0x012b, 0x00}, + {0x0164, 0x00}, + {0x0165, 0x00}, + {0x0166, 0x0c}, + {0x0167, 0xcf}, + {0x0168, 0x00}, + {0x0169, 0x00}, + {0x016a, 0x09}, + {0x016b, 0x9f}, + {0x016c, 0x0c}, + {0x016d, 0xd0}, + {0x016e, 0x09}, + {0x016f, 0xa0}, + {0x0170, 0x01}, + {0x0171, 0x01}, + {0x0174, 0x00}, + {0x0175, 0x00}, + {0x018c, 0x0a}, + {0x018d, 0x0a}, + {0x0301, 0x05}, + {0x0303, 0x01}, + {0x0304, 0x03}, + {0x0305, 0x03}, + {0x0306, 0x00}, + {0x0307, 0x39}, + {0x0309, 0x0a}, + {0x030b, 0x01}, + {0x030c, 0x00}, + {0x030d, 0x72}, + {0x0624, 0x0c}, + {0x0625, 0xd0}, + {0x0626, 0x09}, + {0x0627, 0xa0}, + {0x455e, 0x00}, + {0x471e, 0x4b}, + {0x4767, 0x0f}, + {0x4750, 0x14}, + {0x4540, 0x00}, + {0x47b4, 0x14}, + {0x4713, 0x30}, + {0x478b, 0x10}, + {0x478f, 0x10}, + {0x4793, 0x10}, + {0x4797, 0x0e}, + {0x479b, 0x0e}, + {0x0162, 0x0d}, + {0x0163, 0x78}, +}; + +static const struct imx219_reg mode_1920_1080_regs[] = { + {0x0100, 0x00}, + {0x30eb, 0x05}, + {0x30eb, 0x0c}, + {0x300a, 0xff}, + {0x300b, 0xff}, + {0x30eb, 0x05}, + {0x30eb, 0x09}, + {0x0114, 0x01}, + {0x0128, 0x00}, + {0x012a, 0x18}, + {0x012b, 0x00}, + {0x0162, 0x0d}, + {0x0163, 0x78}, + {0x0164, 0x02}, + {0x0165, 0xa8}, + {0x0166, 0x0a}, + {0x0167, 0x27}, + {0x0168, 0x02}, + {0x0169, 0xb4}, + {0x016a, 0x06}, + {0x016b, 0xeb}, + {0x016c, 0x07}, + {0x016d, 0x80}, + {0x016e, 0x04}, + {0x016f, 0x38}, + {0x0170, 0x01}, + {0x0171, 0x01}, + {0x0174, 0x00}, + {0x0175, 0x00}, + {0x018c, 0x0a}, + {0x018d, 0x0a}, + {0x0301, 0x05}, + {0x0303, 0x01}, + {0x0304, 0x03}, + {0x0305, 0x03}, + {0x0306, 0x00}, + {0x0307, 0x39}, + {0x0309, 0x0a}, + {0x030b, 0x01}, + {0x030c, 0x00}, + {0x030d, 0x72}, + {0x0624, 0x07}, + {0x0625, 0x80}, + {0x0626, 0x04}, + {0x0627, 0x38}, + {0x455e, 0x00}, + {0x471e, 0x4b}, + {0x4767, 0x0f}, + {0x4750, 0x14}, + {0x4540, 0x00}, + {0x47b4, 0x14}, + {0x4713, 0x30}, + {0x478b, 0x10}, + {0x478f, 0x10}, + {0x4793, 0x10}, + {0x4797, 0x0e}, + {0x479b, 0x0e}, + {0x0162, 0x0d}, + {0x0163, 0x78}, +}; + +static const struct imx219_reg mode_1640_1232_regs[] = { + {0x0100, 0x00}, + {0x30eb, 0x0c}, + {0x30eb, 0x05}, + {0x300a, 0xff}, + {0x300b, 0xff}, + {0x30eb, 0x05}, + {0x30eb, 0x09}, + {0x0114, 0x01}, + {0x0128, 0x00}, + {0x012a, 0x18}, + {0x012b, 0x00}, + {0x0164, 0x00}, + {0x0165, 0x00}, + {0x0166, 0x0c}, + {0x0167, 0xcf}, + {0x0168, 0x00}, + {0x0169, 0x00}, + {0x016a, 0x09}, + {0x016b, 0x9f}, + {0x016c, 0x06}, + {0x016d, 0x68}, + {0x016e, 0x04}, + {0x016f, 0xd0}, + {0x0170, 0x01}, + {0x0171, 0x01}, + {0x0174, 0x01}, + {0x0175, 0x01}, + {0x018c, 0x0a}, + {0x018d, 0x0a}, + {0x0301, 0x05}, + {0x0303, 0x01}, + {0x0304, 0x03}, + {0x0305, 0x03}, + {0x0306, 0x00}, + {0x0307, 0x39}, + {0x0309, 0x0a}, + {0x030b, 0x01}, + {0x030c, 0x00}, + {0x030d, 0x72}, + {0x0624, 0x06}, + {0x0625, 0x68}, + {0x0626, 0x04}, + {0x0627, 0xd0}, + {0x455e, 0x00}, + {0x471e, 0x4b}, + {0x4767, 0x0f}, + {0x4750, 0x14}, + {0x4540, 0x00}, + {0x47b4, 0x14}, + {0x4713, 0x30}, + {0x478b, 0x10}, + {0x478f, 0x10}, + {0x4793, 0x10}, + {0x4797, 0x0e}, + {0x479b, 0x0e}, + {0x0162, 0x0d}, + {0x0163, 0x78}, +}; + +static const char * const imx219_test_pattern_menu[] = { + "Disabled", + "Color Bars", + "Solid Color", + "Grey Color Bars", + "PN9" +}; + +static const int imx219_test_pattern_val[] = { + IMX219_TEST_PATTERN_DISABLE, + IMX219_TEST_PATTERN_COLOR_BARS, + IMX219_TEST_PATTERN_SOLID_COLOR, + IMX219_TEST_PATTERN_GREY_COLOR, + IMX219_TEST_PATTERN_PN9, +}; + +/* regulator supplies */ +static const char * const imx219_supply_name[] = { + /* Supplies can be enabled in any order */ + "VANA", /* Analog (2.8V) supply */ + "VDIG", /* Digital Core (1.8V) supply */ + "VDDL", /* IF (1.2V) supply */ +}; + +#define IMX219_NUM_SUPPLIES ARRAY_SIZE(imx219_supply_name) + +/* + * Initialisation delay between XCLR low->high and the moment when the sensor + * can start capture (i.e. can leave software stanby) must be not less than: + * t4 + max(t5, t6 +