From patchwork Wed Nov 9 14:18:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp359796wru; Wed, 9 Nov 2022 06:20:07 -0800 (PST) X-Google-Smtp-Source: AMsMyM5zmj/Vts5fizvbecAMo4u6mLYSA7s9mU/jHnatI902X7JGY3gJmfTIsPbT3uTk6gq51QBO X-Received: by 2002:a17:902:e883:b0:187:27a7:c8a3 with SMTP id w3-20020a170902e88300b0018727a7c8a3mr48586233plg.32.1668003607723; Wed, 09 Nov 2022 06:20:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003607; cv=none; d=google.com; s=arc-20160816; b=fSPEu+KSobAsM14Kr4BqttoPtPOfunvHbZLgUBvDxEpR+mLQTwYHd+OLkeU0Kk9epO XrI6DKGVJmydpl7ESKbNgduqEzqzSwnEFF4VrUNwI9R+qFUbWYmNiIyn7iO3JOmpOiIp VQGY9c+p64sn9OUFfLlqKOVgId+Zvs+TDtz1/M7F2VOp7n+aW9yKfeRSKdJOcM/64UaA y4E0MJfz4ZzbXMyY2PysgvlsfdGHGGxPim2VDhW3SStGmD6d5Zj3HC0fvHIj7V4KS/Mz XeSwbOnAVzN3Itf94PTEbV7Y0MZL+Sab+XYGZzzxOFu0V1TOpIlh6AjEbUl6QKgkyP9m kRZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z8rIUrLhA+Lys0DpzxE+dR11SBu/CxJni8I2xKpyyL0=; b=NfeP9i5ezCj4QCsOBABUGYc/99vqpaQ2y38oUWF5IcDs3odnW2vDSM4eb3GljYjL+g BoGa5okk9kDPiNKahuPJDL4OWiwO0nTlUeldZNNoUDnxZV7sNr212zBge0R3HFggMaC2 gjVWXJ9EYA3OuB0p0fffFFV+nKxaIjEUYkhKlFhpcTWB2+QDGKGwSoYCN7oQ9V9LhF5Z FrX/pwIY/34C1IisxHeYbl9pwb2wcVAUSK0xtDeiK2rJUUzXYqp7xc+DXzQaxpy87qm/ Z54uL5cOO1BVyVl4fsH6+CA7DC+NyyeStgo8oCJVkebSzRrLDSw6YgMz7aGxh6b3zahk PyQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LNvLhUNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020a627902000000b00564874e14e9si16294737pfc.280.2022.11.09.06.19.52; Wed, 09 Nov 2022 06:20:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LNvLhUNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231143AbiKIOT1 (ORCPT + 99 others); Wed, 9 Nov 2022 09:19:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbiKIOTV (ORCPT ); Wed, 9 Nov 2022 09:19:21 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 082191C92C; Wed, 9 Nov 2022 06:19:19 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id F16C5FF807; Wed, 9 Nov 2022 14:19:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z8rIUrLhA+Lys0DpzxE+dR11SBu/CxJni8I2xKpyyL0=; b=LNvLhUNmruqY3aFYVWygJ5mj7BGfU3/OFjXHcwjsKMkpX23BVk/O87yGy6QTFckRxkzWB+ fnDY3VSanqka07MED0xdqZzF5AubTy8tGiCDXYJDI7AufVWTtdZ9g3Jn3A/08sQm9M3Xzh OnqxDPjP6cYu4jF75ihgrIsliIaPSbYLfsuJwIMFn8t4ln/iP300IOeapxnqJm3QUjrdwt 8s2oh6e5I2agyeADPzhaqRDvY7DX6atDnjEDU6+SQG9T0whHq5mXlNHtUizxy7fA1naL9m BjDiI6M2Ryk38vv6J5+U8v/509v81Jv9acb/dhc/ugl3UDQYX0Fk0SaYvLl3rA== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 01/23] dt-bindings: display: tegra: add bindings for Tegra20 VIP Date: Wed, 9 Nov 2022 15:18:30 +0100 Message-Id: <20221109141852.729246-2-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028551073331346?= X-GMAIL-MSGID: =?utf-8?q?1749028551073331346?= From: Luca Ceresoli VIP is the parallel video capture component within the video input subsystem of Tegra20 (and other Tegra chips, apparently). Signed-off-by: Luca Ceresoli --- .../display/tegra/nvidia,tegra20-vip.yaml | 64 +++++++++++++++++++ MAINTAINERS | 7 ++ 2 files changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file mode 100644 index 000000000000..934dabfd2307 --- /dev/null +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/tegra/nvidia,tegra20-vip.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra VIP (parallel video capture) controller + +maintainers: + - Luca Ceresoli + +properties: + $nodename: + const: vip + + compatible: + enum: + - nvidia,tegra20-vip + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + channel@0: + type: object + + properties: + reg: true + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Port receiving the video stream from the sensor + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: + Port sending the video stream to the VI + + required: + - port@0 + - port@1 + + additionalProperties: false + + required: + - reg + - ports + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + - channel@0 + +# see nvidia,tegra20-vi.yaml for an example diff --git a/MAINTAINERS b/MAINTAINERS index 046ff06ff97f..b43f6f4e8ccf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20279,6 +20279,13 @@ S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml F: drivers/staging/media/tegra-video/ +TEGRA VIDEO DRIVER FOR TEGRA20 VIP (PARALLEL VIDEO CAPTURE) +M: Luca Ceresoli +L: linux-media@vger.kernel.org +L: linux-tegra@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml + TEGRA XUSB PADCTL DRIVER M: JC Kuo S: Supported From patchwork Wed Nov 9 14:18:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp359738wru; Wed, 9 Nov 2022 06:20:02 -0800 (PST) X-Google-Smtp-Source: AMsMyM5CE20fLA6a1v3Fp2a3kgb1GuixwGyaCQrxZ8wYYrqXFhZJtrMpHOYepoezS3vGyiOT04Qj X-Received: by 2002:a17:90a:20c:b0:213:1179:1fff with SMTP id c12-20020a17090a020c00b0021311791fffmr64383999pjc.23.1668003602115; Wed, 09 Nov 2022 06:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003602; cv=none; d=google.com; s=arc-20160816; b=puGO/O+RF2iNY+innwSRY8U009Ls17egxeXoGYOELHlvZqoJv1XatVyCz3tD1i911L xkL4/i6ir3G07wdn4ke5gdo6jrWCUxtXc2GuDNmj06lNm3h7rY6Y/UdU3ojZ3DUQmuDP Sa5QoV61JVW3SAhEbB1D1YWNB/+1+NMTilpfl/hUWgxuhQNEBxWu4P7V+nWltDUQpEPd PVAzQVdoNsvfK5glLE6nCRxoymdO83vMwSYgLLtGTZUrY6EZsgUdqIJxa96ayuetM81W VZ3Zu/NySluv/xPRM+heIe5tBWAerITpiEAcUkZr3jWqx6pB797k5eSoK7c+uoT1rvQL nyWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PbIcdoBUbNEn6Y5YPfAT65AjVDHZNeQtTTtmrwc4noQ=; b=XRwD4ziy81EXrFSNIn5nORCS7W5k8AS/XcdSNLokb/swOs9NnFPu7dmEqu06fYbUDs fiCzm95Q+ELYDjibJzk0wCn8enAXwwrB7V+ynPjjBoWMsi6cNdJHdpo88gBU9jnbtT5v nCKm18Dzmgt+Y3vnhs8rgaCZSPvrdVhirr6xCcUkR15bNndDJOAff1cQ0wsfX7LY8aoU O+EBfcY/kBmbbD/LDS6bqUtQZwIrx/UGlN4WVzZBXol6JoPdVvJrcn1A0Ya/dWZz4zfs kzKcC7WE3tj1mzn5QIIjZMRWdhHbeIjgvUBqDJXeE1yrQweYaVLncHnKIhzKwSA2b8g4 cgjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bP7tDi5c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v27-20020a637a1b000000b00450200a1078si17649774pgc.853.2022.11.09.06.19.46; Wed, 09 Nov 2022 06:20:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bP7tDi5c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231133AbiKIOTZ (ORCPT + 99 others); Wed, 9 Nov 2022 09:19:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231143AbiKIOTX (ORCPT ); Wed, 9 Nov 2022 09:19:23 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 376611BEB4; Wed, 9 Nov 2022 06:19:21 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 97842FF808; Wed, 9 Nov 2022 14:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003560; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PbIcdoBUbNEn6Y5YPfAT65AjVDHZNeQtTTtmrwc4noQ=; b=bP7tDi5cvmzh1tA7Rh7yplOM6iQqIn0Tra14zST5XG8da961HgUpkQ/uVNfg300UONuIv6 9WvuwyyeswR0y7w00r+1oBejYgk+XqEkkrtm+3oPsMNdJK2Ei9bll/64VpHcrkdbtNvPlG Z1nwlOgsIDbH3GHpZYpF3eRnKSMQH5JfbelvkFtA5kOKfSzz9YN8aJSexDz44A9QLS6YCP PFHrnZrEJs8V2A/gOm/pk11Fo34ortDU+9WDHFtO7w8cWyUS0O/MYBpocfCoGOGo8DuIdC fFSvcVtEnAC7pLeHNScOSa+en+K8F3f6tKvlhMCrdv/ocvZll0Cinr107HKhSA== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 02/23] dt-bindings: display: tegra: vi: add 'vip' property and example Date: Wed, 9 Nov 2022 15:18:31 +0100 Message-Id: <20221109141852.729246-3-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028545050179821?= X-GMAIL-MSGID: =?utf-8?q?1749028545050179821?= From: Luca Ceresoli The Tegra20 VI peripheral can receive parallel input from the VIP parallel input module. Add it to the allowed properties and augment the existing nvidia,tegra20-vi example to show a 'vip' property. Signed-off-by: Luca Ceresoli Reviewed-by: Krzysztof Kozlowski --- .../display/tegra/nvidia,tegra20-vi.yaml | 68 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 69 insertions(+) diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml index 782a4b10150a..aab795241dd6 100644 --- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml @@ -74,6 +74,22 @@ properties: avdd-dsi-csi-supply: description: DSI/CSI power supply. Must supply 1.2 V. + vip: + $ref: /schemas/display/tegra/nvidia,tegra20-vip.yaml + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Input from the VIP (parallel input capture) module + + properties: + endpoint: + $ref: /schemas/graph.yaml#/properties/endpoint + patternProperties: "^csi@[0-9a-f]+$": type: object @@ -109,6 +125,22 @@ examples: #include #include + i2c3 { + #address-cells = <1>; + #size-cells = <0>; + camera@48 { + compatible = "aptina,mt9v111"; + reg = <0x48>; + clocks = <&camera_clk>; + + port { + mt9v111_out: endpoint { + remote-endpoint = <&vi_vip_in>; + }; + }; + }; + }; + vi@54080000 { compatible = "nvidia,tegra20-vi"; reg = <0x54080000 0x00040000>; @@ -116,6 +148,42 @@ examples: clocks = <&tegra_car TEGRA20_CLK_VI>; resets = <&tegra_car 100>; reset-names = "vi"; + + vip { + compatible = "nvidia,tegra20-vip"; + #address-cells = <1>; + #size-cells = <0>; + channel@0 { + reg = <0>; + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + vi_vip_in: endpoint { + remote-endpoint = <&mt9v111_out>; + }; + }; + port@1 { + reg = <1>; + vi_vip_out: endpoint { + remote-endpoint = <&vi_in>; + }; + }; + }; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + vi_in: endpoint { + remote-endpoint = <&vi_vip_out>; + }; + }; + }; }; - | diff --git a/MAINTAINERS b/MAINTAINERS index b43f6f4e8ccf..0a4f66a32e45 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20284,6 +20284,7 @@ M: Luca Ceresoli L: linux-media@vger.kernel.org L: linux-tegra@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml TEGRA XUSB PADCTL DRIVER From patchwork Wed Nov 9 14:18:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp359937wru; Wed, 9 Nov 2022 06:20:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6KdB9LTFQjxfSlx8rqrlKcTwYh3in6qDkJlUwiGQA+kbk/ZfG39Rqyb8K6sjsPvSkeqJLi X-Received: by 2002:a63:d850:0:b0:470:60a4:3792 with SMTP id k16-20020a63d850000000b0047060a43792mr17906514pgj.399.1668003621213; Wed, 09 Nov 2022 06:20:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003621; cv=none; d=google.com; s=arc-20160816; b=HupW9R48J8c1lOJ/pX4bXpLv8kt3F+wEfo3JritHVHmIGjwmK+XS0MtEkqUdT5tzbe IKqYvJiEJh9cfebI3ka3b+tWmp5Fl//loE9IzwR+TIWAnNoAUN9YtVYVfT7Z5J7XbDc1 FBAMvZipvuZlgevqVUZkDcCkLKiMU24sNg4YAUsqDfKduJ6kF4mGIOgUZe2C+mPdt9G4 WpSJYlSPwVQSy3naZG+R81GRIELbVNLcv1L9uH2bMf1ggWJfMRKWasDRYw7bArzCrtRC BRSXMEfrsnp8cCrExASW/b3mI6C/H2rx1/CzPGcAEJ/ZCCraBWHKCsLnvto3D5tnngxo rOwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Uqci2qSaw6deqAW4JCdUl71iNVBKipcC1QthJWE93Lo=; b=RXy/KnN9et0THxme2WRiq0o4MCZZYBwkbn5lD+c6V20aYQ1+gz4OKHzn5JZ33q0Hrk OR8A1ykjDHJh5WUW2xQE+tNrglC88MHlxi5boSbGvdF4Q6haRj9ShEeR7Fbv/fX+7PVB yZB50eC9Si7lrFf6NnvKYQLEH/Hs/W9WneNSwtKwgNPWTRjbkyvDUR74gaJeKczKYIrJ 33lEK/vJyIhN9sfChf52Hox/b6DwyDjmjtUNYPbjE+MjwxE3+0KMoYFF5HGJckB4xKIy fHnCtYqVzDabfTl7u2+yn5RrljbwCvfMi5blNk4Olkk69BPew7XmsyiJ+MDHDCqadYI7 fO0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=N6PXCZts; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a626206000000b0056befaa95a1si14578681pfb.50.2022.11.09.06.20.07; Wed, 09 Nov 2022 06:20:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=N6PXCZts; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231211AbiKIOTd (ORCPT + 99 others); Wed, 9 Nov 2022 09:19:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231182AbiKIOT1 (ORCPT ); Wed, 9 Nov 2022 09:19:27 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 523C81D65C; Wed, 9 Nov 2022 06:19:25 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 2166CFF80E; Wed, 9 Nov 2022 14:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uqci2qSaw6deqAW4JCdUl71iNVBKipcC1QthJWE93Lo=; b=N6PXCZtsSKg2pkyPWymdvDszipVUVpU/oaIUEzH71VndneJOkkEOlkTlEqBo8DEnAdB4eU EMgIiqgIzHUuk/iWx4WO9F8kiyKg191Sh/sUSi9gMubFmnkhFNb08YD/ea/ftAoLRpUbhx /zbxxFiUDYUwz6yzmIqfQw/Qa4RW2uzaDHkXsBhVNlY1soxsfdc/aKKDFEi0M8MKr3Mjul J4rewTX2sHdm+Cn/hiU93LVuSG4Z/ihmeIU3AcadUrbLG6FyTs5A0qA9bjqD/T7acwhT1W AYujGYWTCYfoXSg2lui4+WJvuZ0O+AMsi7NOY/vLiSe1wzc17WLyp2FXP53drQ== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 03/23] ARM: dts: tegra20: add label to nvidia,tegra20-vi node Date: Wed, 9 Nov 2022 15:18:32 +0100 Message-Id: <20221109141852.729246-4-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028564993812434?= X-GMAIL-MSGID: =?utf-8?q?1749028564993812434?= From: Luca Ceresoli Useful to enable it from a board DTS. Signed-off-by: Luca Ceresoli --- arch/arm/boot/dts/tegra20.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi index ee757dc8c6a2..5e71dcbe8b12 100644 --- a/arch/arm/boot/dts/tegra20.dtsi +++ b/arch/arm/boot/dts/tegra20.dtsi @@ -62,7 +62,7 @@ mpe@54040000 { status = "disabled"; }; - vi@54080000 { + tegra_vi: vi@54080000 { compatible = "nvidia,tegra20-vi"; reg = <0x54080000 0x00040000>; interrupts = ; From patchwork Wed Nov 9 14:18:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp360173wru; Wed, 9 Nov 2022 06:20:46 -0800 (PST) X-Google-Smtp-Source: AMsMyM6OLvUJnirca/YUs+vc+QXo3miuv5TNPn6ohxlTWsd9KhWVX4uRK6lFA5G96FZT2YX4Rbri X-Received: by 2002:aa7:c6cd:0:b0:461:87ab:3255 with SMTP id b13-20020aa7c6cd000000b0046187ab3255mr60278734eds.193.1668003646249; Wed, 09 Nov 2022 06:20:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003646; cv=none; d=google.com; s=arc-20160816; b=GGDYQXQMKPPQJBQYr/PFxWg+NrZCAzjSjlpKiEodUZdLJNgR8H1tzWqKkmHyXHsFw6 YDXc3OBWd/zCvtdhMpU09V2sBEYj5MbJomvT/BXtzZW7d6L6ikRcYvBMaiwGwjZO5IAp U0FhTgOurHqQQMnBEkym/HML2EiU9TFwSzTl1g3pXQg08NS4R9aw0XUVb//4G0v5mM6s dxn9iK3ytHmAO8O3AnwOusteO9SmazYeSFTD1bKElvQDp5o7Q4LO92ZG1nj5EAECAOW6 LtrcR8WqrcR3N2+VAP4lJo+I5wvEHDbVZcNrWBusgpmLOmoN9dMoJPU8mp8hjmpM7scC z0Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=07aa8e8fT8doZikfGZmbSjdF5gbvueSS4qnnav2hELw=; b=a03t2qQ8Fr/Nbfi7gXl9TSK2jSL2YRT8vy4ZKEeNcofjyAui0CZgzCjhtwNAOKCUnd Z/6yQtYoPSSnAV0vvMZ2eNdU2b7yJ+wfqcNebuuJsJKSsmO8bnbrUFdVBwgxMaKxDBK4 egRhHDCHYCdK05h9mDLQCb898zJNpuml0Veleh4TRzM7oZ7ddpemphpIuwFsBN/RVkjs 8P+36cvtWjSoxTQjraLQqv/U7L4QchVl1vCkJWiC6H4IlesPzeFqjkH/EFcauYWflyor kwYLkwraH29cojO9bWwJDdGp9qd03LgCE89kG/RUB/DXNBSntN/b1vONss1c1djo3bXS 7dpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="WF/bT8xY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv16-20020a17090760d000b007ae4717bf11si16091010ejc.80.2022.11.09.06.20.20; Wed, 09 Nov 2022 06:20:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="WF/bT8xY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231303AbiKIOTt (ORCPT + 99 others); Wed, 9 Nov 2022 09:19:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231182AbiKIOTg (ORCPT ); Wed, 9 Nov 2022 09:19:36 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D36D01E3D5; Wed, 9 Nov 2022 06:19:27 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 5234DFF803; Wed, 9 Nov 2022 14:19:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=07aa8e8fT8doZikfGZmbSjdF5gbvueSS4qnnav2hELw=; b=WF/bT8xY6heplVG8iPYA60kQYXK5xpTQmnjVVbPc8xzh7WmGRpvhCMu015ps/0Zm/zejA1 bRDsJTvC9OumkIhRW79VmwZgb4WrT9q4jahAEZDgQDPMmUVJrcrSSy/ESpp5RwgvWOBT8X DLk6gV3C8qoXr/3oemLP8fDbct4oXfHnuRrC9PBPSEUi7+n/Mg6qVR8AzOGdw8eToABYDy 6zu+rDF9vFejFMD4F/50FqvnKS++agbfO5WRegmKuxeCAnbRSr+x4vSiC/ek/1ZoQefNy6 zOModhZGUskX91Jb/5C9xcIcCTo+mee6pTMIBIusSLhKtJIhBSquXvMuQ8af3g== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 04/23] ARM: dts: tegra20-tamonten: add label to avdd_vdac regulator Date: Wed, 9 Nov 2022 15:18:33 +0100 Message-Id: <20221109141852.729246-5-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028591082373546?= X-GMAIL-MSGID: =?utf-8?q?1749028591082373546?= From: Luca Ceresoli Useful to enable it from a board DTS. Signed-off-by: Luca Ceresoli --- arch/arm/boot/dts/tegra20-tamonten.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/tegra20-tamonten.dtsi b/arch/arm/boot/dts/tegra20-tamonten.dtsi index 6d51a5572a34..703293e9bd41 100644 --- a/arch/arm/boot/dts/tegra20-tamonten.dtsi +++ b/arch/arm/boot/dts/tegra20-tamonten.dtsi @@ -418,7 +418,7 @@ ldo5 { regulator-max-microvolt = <2850000>; }; - ldo6 { + avdd_vdac_reg: ldo6 { regulator-name = "vdd_ldo6,avdd_vdac"; /* * According to the Tegra 2 Automotive From patchwork Wed Nov 9 14:18:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp360395wru; Wed, 9 Nov 2022 06:21:10 -0800 (PST) X-Google-Smtp-Source: AMsMyM6Km2mBERUpjUpMh98iYQQ2EnHr3o8H6bfu63zY0A6utSQti7N5Xl8PpIVNT7fCzmKv/Z91 X-Received: by 2002:a05:6402:22c7:b0:463:cc1:42a2 with SMTP id dm7-20020a05640222c700b004630cc142a2mr56210630edb.217.1668003670675; Wed, 09 Nov 2022 06:21:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003670; cv=none; d=google.com; s=arc-20160816; b=bhjkACwufvFS67mmJeuUwCXFwo3d5tYhVrvBblnTGMP7MfMnR/bjKln5BZpzmavet/ 74tXbqLqCC1u8wef7+XwxzpJZTS4+t+o5V3bUaIoM25NEGlopgOm60VDOCxLKL3RtJ94 I0ad+zNLxUUPMd9HzJNkroMsj1WGjMBye2o0LaOTm0+wkQEv26lF3zc+LREiRe0q5vHD 0pDUnMH4KLnwuWmEpc4D0mGp/7nL19Y+7lyeg9IM6v5pYvHd/pnBdLfUHNr/+0jvuDMW pQhPwyajHvGjJH6t9sMovE3pm73P7c5BGtd6dLkLVEWfW9PbtaJCdBluE2HaHTY7/WJ7 2rwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e20EWbXrBPy3QzNZWf2olVP57UrPbhm3BTtHH1d5Tec=; b=GAS+qWb8I7kmmrV2UN7s8uhkjMNwMsFy8h+daW35BjtxdLYzZ/1Qw7RFj19uRd1j4N CqUWyfrftBUZD5sGuwKiqTT0U5XBN0b874Jhtjf8MPPM0Xs1oq2sB0lx7GRMkPK6wUee q2pnnEripi/EEwtNHWUrmh9yZBhImitnhJ0P26fTEC8vbK8LijPoWHTOy7k2mNW3is9c V/6NVjsNx3EqCF4Z2IZBrf6nd/AIZEVrLbGpSbgANjuuMR7FZ+FPOSykQgrJUHUxBcoM U4RGxHc4kUIXNuDi1zNO8dfLhUktxeypO20fF/RJQA/YZ1AoZLhiG2cP33/9q4tlEWRR pKbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Q1IaFjYG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t15-20020a1709067c0f00b007ae43ee86aesi11111036ejo.69.2022.11.09.06.20.45; Wed, 09 Nov 2022 06:21:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Q1IaFjYG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231288AbiKIOUK (ORCPT + 99 others); Wed, 9 Nov 2022 09:20:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231282AbiKIOTr (ORCPT ); Wed, 9 Nov 2022 09:19:47 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F7971F9CA; Wed, 9 Nov 2022 06:19:35 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id C4AD0FF80C; Wed, 9 Nov 2022 14:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e20EWbXrBPy3QzNZWf2olVP57UrPbhm3BTtHH1d5Tec=; b=Q1IaFjYGEKwnUEhQtgcZLBV3WuWVYx5SkiEOmS3mW9KVotLACerg1QxXzFvnK/NHeWrqX3 6ljntUpMYWgtjBQAdTnctcY/YxQuPPLHvON3sv2UgeToatjb/wbrF+e3BSgIM+w/FAFrk6 OTg6X41Hmoq8or4WPWyZ9Mh9uxPJ43UYppsSUUnx1w97cjMSgKsakga/holeF3gGBOoWTH YFc6fqh9FpaZNRH9VTeFane3NM28e2B5ZPxNGGloSkjVLERg9T6Sjt6Mn0tybuVq+ArmQ+ rz4ki0fDadVQAaXSI/6NlsSMDfdgXMebWs5LSyEFPUm336A2rTjR+zqD2N3zMw== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 05/23] staging: media: tegra-video: fix .vidioc_enum_fmt_vid_cap to return all formats Date: Wed, 9 Nov 2022 15:18:34 +0100 Message-Id: <20221109141852.729246-6-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028616883081294?= X-GMAIL-MSGID: =?utf-8?q?1749028616883081294?= From: Luca Ceresoli The .vidioc_enum_fmt_vid_cap (called tegra_channel_enum_format() here) should return all the supported formats. Instead the current implementation computes the intersection between the formats it supports and those supported by the first subdev in the stream (typically the image sensor). Remove all the unnecessary logic that supports such algorithm. In order to do this, also change the Tegra210 CSI TPG formats from the current open-coded implementation in vi_tpg_fmts_bitmap_init() to a const array in tegra210.c, just like the one that describes the regular formats. Fixes: 3d8a97eabef0 ("media: tegra-video: Add Tegra210 Video input driver") Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/tegra210.c | 7 +- drivers/staging/media/tegra-video/vi.c | 103 +------------------ drivers/staging/media/tegra-video/vi.h | 4 - 3 files changed, 9 insertions(+), 105 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra210.c b/drivers/staging/media/tegra-video/tegra210.c index d58370a84737..eb19dd5107ce 100644 --- a/drivers/staging/media/tegra-video/tegra210.c +++ b/drivers/staging/media/tegra-video/tegra210.c @@ -683,8 +683,12 @@ enum tegra210_image_format { V4L2_PIX_FMT_##FOURCC, \ } -/* Tegra210 supported video formats */ static const struct tegra_video_format tegra210_video_formats[] = { +#if IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG) + /* VI only support 2 formats in TPG mode */ + TEGRA210_VIDEO_FMT(RAW10, 10, SRGGB10_1X10, 2, T_R16_I, SRGGB10), + TEGRA210_VIDEO_FMT(RGB888, 24, RGB888_1X32_PADHI, 4, T_A8B8G8R8, RGBX32), +#else /* RAW 8 */ TEGRA210_VIDEO_FMT(RAW8, 8, SRGGB8_1X8, 1, T_L8, SRGGB8), TEGRA210_VIDEO_FMT(RAW8, 8, SGRBG8_1X8, 1, T_L8, SGRBG8), @@ -714,6 +718,7 @@ static const struct tegra_video_format tegra210_video_formats[] = { TEGRA210_VIDEO_FMT(YUV422_8, 16, VYUY8_2X8, 2, T_V8_Y8__U8_Y8, YUYV), TEGRA210_VIDEO_FMT(YUV422_8, 16, YUYV8_2X8, 2, T_Y8_U8__Y8_V8, VYUY), TEGRA210_VIDEO_FMT(YUV422_8, 16, YVYU8_2X8, 2, T_Y8_V8__Y8_U8, UYVY), +#endif }; /* Tegra210 VI operations */ diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 9d46a36cc014..0fe3c7f6d234 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -3,7 +3,6 @@ * Copyright (C) 2020 NVIDIA CORPORATION. All rights reserved. */ -#include #include #include #include @@ -73,15 +72,6 @@ static int tegra_get_format_idx_by_code(struct tegra_vi *vi, return -1; } -static u32 tegra_get_format_fourcc_by_idx(struct tegra_vi *vi, - unsigned int index) -{ - if (index >= vi->soc->nformats) - return -EINVAL; - - return vi->soc->video_formats[index].fourcc; -} - static const struct tegra_video_format * tegra_get_format_by_fourcc(struct tegra_vi *vi, u32 fourcc) { @@ -430,19 +420,12 @@ static int tegra_channel_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f) { struct tegra_vi_channel *chan = video_drvdata(file); - unsigned int index = 0, i; - unsigned long *fmts_bitmap = chan->tpg_fmts_bitmap; - - if (!IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) - fmts_bitmap = chan->fmts_bitmap; + const struct tegra_vi_soc *soc = chan->vi->soc; - if (f->index >= bitmap_weight(fmts_bitmap, MAX_FORMAT_NUM)) + if (f->index >= soc->nformats) return -EINVAL; - for (i = 0; i < f->index + 1; i++, index++) - index = find_next_bit(fmts_bitmap, MAX_FORMAT_NUM, index); - - f->pixelformat = tegra_get_format_fourcc_by_idx(chan->vi, index - 1); + f->pixelformat = soc->video_formats[f->index].fourcc; return 0; } @@ -1059,78 +1042,6 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) return 0; } -/* VI only support 2 formats in TPG mode */ -static void vi_tpg_fmts_bitmap_init(struct tegra_vi_channel *chan) -{ - int index; - - bitmap_zero(chan->tpg_fmts_bitmap, MAX_FORMAT_NUM); - - index = tegra_get_format_idx_by_code(chan->vi, - MEDIA_BUS_FMT_SRGGB10_1X10, 0); - bitmap_set(chan->tpg_fmts_bitmap, index, 1); - - index = tegra_get_format_idx_by_code(chan->vi, - MEDIA_BUS_FMT_RGB888_1X32_PADHI, - 0); - bitmap_set(chan->tpg_fmts_bitmap, index, 1); -} - -static int vi_fmts_bitmap_init(struct tegra_vi_channel *chan) -{ - int index, ret, match_code = 0; - struct v4l2_subdev *subdev; - struct v4l2_subdev_mbus_code_enum code = { - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - }; - - bitmap_zero(chan->fmts_bitmap, MAX_FORMAT_NUM); - - /* - * Set the bitmap bits based on all the matched formats between the - * available media bus formats of sub-device and the pre-defined Tegra - * supported video formats. - */ - subdev = tegra_channel_get_remote_source_subdev(chan); - while (1) { - ret = v4l2_subdev_call(subdev, pad, enum_mbus_code, - NULL, &code); - if (ret < 0) - break; - - index = tegra_get_format_idx_by_code(chan->vi, code.code, 0); - while (index >= 0) { - bitmap_set(chan->fmts_bitmap, index, 1); - if (!match_code) - match_code = code.code; - /* look for other formats with same mbus code */ - index = tegra_get_format_idx_by_code(chan->vi, - code.code, - index + 1); - } - - code.index++; - } - - /* - * Set the bitmap bit corresponding to default tegra video format if - * there are no matched formats. - */ - if (!match_code) { - match_code = tegra_default_format.code; - index = tegra_get_format_idx_by_code(chan->vi, match_code, 0); - if (WARN_ON(index < 0)) - return -EINVAL; - - bitmap_set(chan->fmts_bitmap, index, 1); - } - - /* initialize channel format to the sub-device active format */ - tegra_channel_set_subdev_active_fmt(chan); - - return 0; -} - static void tegra_channel_host1x_syncpts_free(struct tegra_vi_channel *chan) { int i; @@ -1501,7 +1412,6 @@ int tegra_v4l2_nodes_setup_tpg(struct tegra_video_device *vid) goto cleanup; v4l2_set_subdev_hostdata(&csi_chan->subdev, vi_chan); - vi_tpg_fmts_bitmap_init(vi_chan); csi_chan = list_next_entry(csi_chan, list); } @@ -1721,13 +1631,6 @@ static int tegra_vi_graph_notify_complete(struct v4l2_async_notifier *notifier) goto unregister_video; } - ret = vi_fmts_bitmap_init(chan); - if (ret < 0) { - dev_err(vi->dev, - "failed to initialize formats bitmap: %d\n", ret); - goto unregister_video; - } - subdev = tegra_channel_get_remote_csi_subdev(chan); if (!subdev) { ret = -ENODEV; diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index a68e2c02c7b0..183796c8a46a 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -163,8 +163,6 @@ struct tegra_vi_graph_entity { * * @ctrl_handler: V4L2 control handler of this video channel * @syncpt_timeout_retry: syncpt timeout retry count for the capture - * @fmts_bitmap: a bitmap for supported formats matching v4l2 subdev formats - * @tpg_fmts_bitmap: a bitmap for supported TPG formats * @pg_mode: test pattern generator mode (disabled/direct/patch) * @notifier: V4L2 asynchronous subdevs notifier */ @@ -205,8 +203,6 @@ struct tegra_vi_channel { struct v4l2_ctrl_handler ctrl_handler; unsigned int syncpt_timeout_retry; - DECLARE_BITMAP(fmts_bitmap, MAX_FORMAT_NUM); - DECLARE_BITMAP(tpg_fmts_bitmap, MAX_FORMAT_NUM); enum tegra_vi_pg_mode pg_mode; struct v4l2_async_notifier notifier; From patchwork Wed Nov 9 14:18:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17579 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp360214wru; Wed, 9 Nov 2022 06:20:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf676g6u9PbmZdszgXzL2bMk8WBzIMd99RrYjySR1dn1eBiLVBzrqkB8N7I4y5HQ8b0Xeg62 X-Received: by 2002:a05:6402:1d84:b0:466:7ef1:bc0f with SMTP id dk4-20020a0564021d8400b004667ef1bc0fmr11787903edb.12.1668003650230; Wed, 09 Nov 2022 06:20:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003650; cv=none; d=google.com; s=arc-20160816; b=v1r2fxVj584XeQFiRjtWJSJ5W4UIAzZpoYZB6RGZkI/h/ADBqCqnbs6KcuSouWF54H pQOfe72vGZROu7ceY+6tAY9viLvCXwDo8vyHsEdNWxXqkQMZFXJaT9gEnJVlQdDZ9Yb6 M0Ea8X2rYrRMwoLAM0lKDuhvATSNBqkkhpCGHdFV6i5tX6H6Uier3NbQvrQZC6PCO56N bPkDfmKFqnDCcGVLkVeY+lXCCEaikv5BROAps1SICL27X/K6QZva1tKPqEe++f2QHHb5 q0Gi/1u9Xaa30pQzDWiF3/C/okw13gqNxIEbKYIzIGrJKf4REraUBMzLZGAomJhYGVWt HD2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BJlzuVONFEpiaYrldIzh/q/NNHairzTg7dXH/ruzq4U=; b=FDWZARrz71Ma4kaqQJAOXEFivmHLg6ppjFX0PXgLD9eTkxWklWoY7YJL1MNLEeClIF hPoTBxmIrF2Mfh8QaR4r64CVVGnFA3RoxipAOuI+4jITLY02HIGNP9vzjweQN8aMfvD4 6jdW/Xb5NM4vzqIiEyzSaK54OPzsKIC34mPQeQD2C9H1rNgXs9jlXvXtViWshHyTgndp K6vEvYIBs7dDAu9GtuufkJW28rI37Aiu1sjGR8C5fzRJJXTrGFmgzQ2qfNLkb++hi0zW xBxYM+KMmBY4XDb83p/iv28a3o3rhtUqoobeqs356Mr528Q+sdDGSx4wGn1IuUfPFFKS t6Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=o6F8fyvz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a15-20020a170906368f00b007aa6262f627si12304824ejc.640.2022.11.09.06.20.25; Wed, 09 Nov 2022 06:20:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=o6F8fyvz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231221AbiKIOT4 (ORCPT + 99 others); Wed, 9 Nov 2022 09:19:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbiKIOTp (ORCPT ); Wed, 9 Nov 2022 09:19:45 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2A601F2FA; Wed, 9 Nov 2022 06:19:33 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 20AD5FF810; Wed, 9 Nov 2022 14:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BJlzuVONFEpiaYrldIzh/q/NNHairzTg7dXH/ruzq4U=; b=o6F8fyvzViN80butPvVwZpXC84UKR7GjN5NQ82XS+sU72u6cLrxeMuiIGiJyurEXqc/Bpw N+MzMlbjA+vznUbrYouCBdp8k58Oidykv/pvnvkT29+DEj/5QFSeosfqRd70WTXex0c6Hz GKmATB8Gk+2Ax00n40Mq7+6MRt0JgpDl8a4StvaBLd+sDD6iHtbAEx5r6+Or3Gho8egSRl z5frJDQ4K9uBc5qk3FjblsGmgk9S43S+gvp4LT8PiljWuy2G1YCD670M7p3IYlWt4t2iBy boxqxfkBKojS9oo4NFKcxUFNh9skPGdehq8t4THr+w0FQubANtr+O2+yW5kL+w== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 06/23] staging: media: tegra-video: improve documentation of tegra_video_format fields Date: Wed, 9 Nov 2022 15:18:35 +0100 Message-Id: <20221109141852.729246-7-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028595521357515?= X-GMAIL-MSGID: =?utf-8?q?1749028595521357515?= From: Luca Ceresoli Some fields are irrelevant for Tegra20/VIP. Add a note to clarify that. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 183796c8a46a..dd35c3ac992b 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -256,11 +256,11 @@ enum tegra_image_dt { /** * struct tegra_video_format - Tegra video format description * - * @img_dt: image data type - * @bit_width: format width in bits per component + * @img_dt: MIPI CSI-2 data type (for CSI-2 only) + * @bit_width: format width in bits per component (for CSI/Tegra210 only) * @code: media bus format code * @bpp: bytes per pixel (when stored in memory) - * @img_fmt: image format + * @img_fmt: image format (for CSI/Tegra210 only) * @fourcc: V4L2 pixel format FCC identifier */ struct tegra_video_format { From patchwork Wed Nov 9 14:18:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp360260wru; Wed, 9 Nov 2022 06:20:55 -0800 (PST) X-Google-Smtp-Source: AMsMyM5lbxUKHtYsWOfdcBbKcYRCuo3+vbySkpcVZiUTy2ISrkH3agwHBc/yVDoXhvQNH5PRSnbE X-Received: by 2002:a17:902:bb98:b0:186:988d:a0f0 with SMTP id m24-20020a170902bb9800b00186988da0f0mr60753558pls.10.1668003654800; Wed, 09 Nov 2022 06:20:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003654; cv=none; d=google.com; s=arc-20160816; b=Q33L8uniVLV4fywZKnXmu6TyOnYnf8Vosbi//yvZ0/t4Ra6ultYhjrPZB+71czGze9 +azHjseTjyf2DGyPfHIG4LPLNgWbWQGO528b8foYhEW9VbPi/VAewKaD0sarZSe+3AEP gTLFmWe8mGiAs6teR1YopxYYZv3m4PRLWKLqRXotKyHiKMOtbXF606/NcrTJJQM4tkqC x+nzrM6ASVRGHAHFvbOg33actsUc7HguTMq6Ch2PIYEq0H15tYNDktfFsjdAsfjjwgoD VsIMTsZW24ihO0LLAt8hYb+clBMq6HKw/q2hQw8bM13RcP3yRb9MjJU5eWTKhnS6E+L4 oNTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f3PNKMdE0RdXN+WZAH+jyICgofcfEBOVB1XLcjAJPYg=; b=s9TBAbGHubSIUZ5pFRwa9eMwqCWNskUsschM+lo/FTmK0yY2tB2igsqsvsyGaDXFCE eiIdVGzuTNhV4V7C2xsoQzpLKvYP7+PNvxlAHGk81AApgKk8L+fRyjKPWdw4N0b0e+YD cBfDvFOnDamgIwQAHeDNwbOF98xeE1B/9PQJ7VsbtZsTKU+a+P+KG1m+me+9HXdbE/Sj UyjtylnR98640c7Zg23vtmtv1/pkHlvb3nAQ50g+rbqgvSJrk74QBn7+ckhBwkCUewLj e+WtxaLvdMvoyO7UFv+6v+KgkdqYyzViB8btn1YPhIp3JXU+Yfl+ZbvoA0Xmqqp34MEU jP/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kUCW3Dmg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a170902b18600b0017ef8bf8a91si15855470plr.439.2022.11.09.06.20.36; Wed, 09 Nov 2022 06:20:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kUCW3Dmg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231277AbiKIOUH (ORCPT + 99 others); Wed, 9 Nov 2022 09:20:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbiKIOTq (ORCPT ); Wed, 9 Nov 2022 09:19:46 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3BC71CFCF; Wed, 9 Nov 2022 06:19:36 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id C8C17FF816; Wed, 9 Nov 2022 14:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f3PNKMdE0RdXN+WZAH+jyICgofcfEBOVB1XLcjAJPYg=; b=kUCW3DmgNBxhDT17iQQtq7wcue3w6JrwUt/g0ar9zWGvH3hoFA6gLKC6DTVI0ifxYfHAV3 My6pfQeMHKG+M/dmj8M1wSd26Tuio6ftjajAUxTcgOaNVWp01LYEuU6da/ja/5WWAS2QvQ qETmB0VfhJljXyuvFcptHxZTmsN0zFDpWfl2X9FINLSuvXz4h9LlK13XX8gGvTfb27zUPv ThI1DYj+g3dd3ZnMTyiCpC5SZoOOeRTdCcEiG+S2vW7bz2jp5AhjzzwhARFjVWai7NvVOx 63D2j5DDnna7fKYrJwc4OVVpIu3gbJUPFJXkUUHmZYHFYEdFA3xvGkcGc1PhaA== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 07/23] staging: media: tegra-video: document tegra_channel_get_remote_source_subdev Date: Wed, 9 Nov 2022 15:18:36 +0100 Message-Id: <20221109141852.729246-8-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028600331003928?= X-GMAIL-MSGID: =?utf-8?q?1749028600331003928?= From: Luca Ceresoli Clarify what this function does. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 0fe3c7f6d234..8a7512ce2273 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -154,6 +154,9 @@ tegra_channel_get_remote_csi_subdev(struct tegra_vi_channel *chan) return media_entity_to_v4l2_subdev(pad->entity); } +/* + * Walk up the chain until the initial source (e.g. image sensor) + */ struct v4l2_subdev * tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan) { From patchwork Wed Nov 9 14:18:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp360418wru; Wed, 9 Nov 2022 06:21:13 -0800 (PST) X-Google-Smtp-Source: AMsMyM6y2Vgw6JFJjVsQO1mVARvavn/7Y/ql2K4HGGbP6kAnr7TSkmKC8K4DOLqa99WBjWrL5Cdc X-Received: by 2002:a05:6402:4411:b0:437:b723:72 with SMTP id y17-20020a056402441100b00437b7230072mr61291605eda.38.1668003673502; Wed, 09 Nov 2022 06:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003673; cv=none; d=google.com; s=arc-20160816; b=EZCki3vADj8U/fpN2Mvb1bj1i0J5YRTrXLIfFz2jLjlxa1VREhSqvJlu2Dp68d1y1j PpNzKDBG+7Q1htzPgbu81EUq1EqG+O6gfXzdRc4rUXn37dFAQ0YbH3fJckj1BWiEIZJ3 2VGH3/mZJQc7YAcLOHo/9Gi6L5R+qQM+Rfm5ujwk/kk9aVBb0HsjHze2ar9xI0d45igY oeM7WLJfXe4Gg8e7RpQ1Gv5tgyulDYxF0I4GMFiM43KGePIxK55YxCEQfnSvyqJMlSsq CfWe1kOge5pM6iX6eiOpTKq9UbBF/FKUgkuCBqBuya+ew138c7VChRdU8HbUoqkpmMFx a+nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/BzvYI+82AsJNmU/oztfOvlLmRSAFV6HnDtwxGnWX6I=; b=EyjVYtcp4VXDFOkLga7ZD87cABwusxu+ZxYzrkhzBY4YHqPsrIO87LYazRy+6v/8XP MUX4wA5A17zbCE4cOOlL7B7IqvzblWHDXvGRyuKGOLmzKVq/GeXziQiAT1py+8Hbh6oy 0CECf+UdqCicRKI7aunTnxikvh0d2F8WWIyXIkYK5E9xItDuizH0yIUaQ3mmq67iHGxN YZS3KRQqGNryYxEbqVhvEH28xFqlaS3JdvNvRETmPHp812rIJ6lw1tCG6a8ezUCJEQ6G RiMUzwTEeAgh0xRv54A2Mqxk5bsjHXdJr4nqZurImSxGZnSiqU84H3o92VzTCWid+q5g vs4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mjHH7meD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss28-20020a170907c01c00b00787803711f9si13439681ejc.353.2022.11.09.06.20.49; Wed, 09 Nov 2022 06:21:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mjHH7meD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231325AbiKIOUX (ORCPT + 99 others); Wed, 9 Nov 2022 09:20:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231311AbiKIOTu (ORCPT ); Wed, 9 Nov 2022 09:19:50 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B19EA21E0B; Wed, 9 Nov 2022 06:19:42 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 8731BFF817; Wed, 9 Nov 2022 14:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/BzvYI+82AsJNmU/oztfOvlLmRSAFV6HnDtwxGnWX6I=; b=mjHH7meDLl/qOGRKmwohShYMZj/CGk50NwS94SI6WvY/N4mUQywNBBMRKMRcyRFSlDo0YF aYj9oagjh8OvFG34wtZlzIHiHs31HKS4bio4n15QdGFFLY6bFCURWtT2Gcxf7+izHgk0v4 7skD7rvUaR1eMy8g1dXASDZVzk6aXnjpsdRb4V6XlhyGi5g2ODCTT23BTSAiZ78RrmLFS7 9zvUNPbV9jnyFLZSq05Tb+PAK8QIUdchzrFTtI++MTTGUAW2opsMbLuuA7hiQ3c9Wih3zA IJ9vgFiq3KAwp8wLXhZpGPGGu854ZukyxfDcUvAf91dC4T8yg39oytBTJIfp2Q== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 08/23] staging: media: tegra-video: fix typos in comment Date: Wed, 9 Nov 2022 15:18:37 +0100 Message-Id: <20221109141852.729246-9-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028619693782484?= X-GMAIL-MSGID: =?utf-8?q?1749028619693782484?= From: Luca Ceresoli Add "skip" in "so we can *skip* the current channel" or it doesn't make sense. Also add articles where appropriate to fix English grammar. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 8a7512ce2273..b24b9353077f 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1762,10 +1762,10 @@ static int tegra_vi_graph_init(struct tegra_vi *vi) * Walk the links to parse the full graph. Each channel will have * one endpoint of the composite node. Start by parsing the * composite node and parse the remote entities in turn. - * Each channel will register v4l2 async notifier to make the graph - * independent between the channels so we can the current channel + * Each channel will register a v4l2 async notifier to make the graph + * independent between the channels so we can skip the current channel * in case of something wrong during graph parsing and continue with - * next channels. + * the next channels. */ list_for_each_entry(chan, &vi->vi_chans, list) { struct fwnode_handle *ep, *remote; From patchwork Wed Nov 9 14:18:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17585 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp360825wru; Wed, 9 Nov 2022 06:21:58 -0800 (PST) X-Google-Smtp-Source: AMsMyM77c9npRQhi2WkFYlWzSkPuKNJxQXbe+XoFxzZdfNfCiu/jQTtMXJrTh83IysB9+ZxTZdqf X-Received: by 2002:a17:906:dac9:b0:780:ab6f:591f with SMTP id xi9-20020a170906dac900b00780ab6f591fmr57147636ejb.77.1668003718502; Wed, 09 Nov 2022 06:21:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003718; cv=none; d=google.com; s=arc-20160816; b=c/CGXlVkyd82QMtX+WZCSSFBPj4UjytARMMMeYbMY0CoQSs94N083niL6OS3l454fF f/AEv0HmY2IOKBO2G1ZcdTr2/F3cy8PHAbf95J6cjXhmLEO0nozuldipNZS8r3VJ+gcV 5YOJHhBOjY6RQjZhrWqyYK1nOENGQMNlz5CVf/9nzmaRJyv2U5f5+VkZpf20IKNvbt6b IZOBcBWp3fmyrNx44ciM+Z+sVgw/hXD9v8/D1ujsmtv8pbjchWlAnCQye87fbZqKd44Q rJEIv2LVLsLqyqdIAlaTFRosA5+rCzHlJ819A9ZfP5TIrpOY9cJ4y5RHwzAwGxMBoLhx bDFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6RsU9udyOxbtNMCtf0EHobHgYEBuyM2u9K+TcM2I99E=; b=zjeYoZNpApP3jaN5z2lDEo5e2yRMm/wsph/MaDvHgiUwrQNADT4P+NfGY36t3RHYDz uOQJBLpDvOQQLzGJDmhFYzEgTsc0+JmM4529ON7Mo7nFp18b+XPhGTpq+S3gIkZ4mo0R rBRC2ixlbShjoiUT91E5lpGfVbpedomgYdQetbd//GXE7VGLAz9vadTMvZXsHdqthAMh OJcs82oPm1O/wcopNLTTBSrn0vgv3qgt6XqOM5mpH7joieTlYyha/bt1i6C6H/JDVlft 33ez7L7pMmMYIhve/EUezR56+nPIRLpqKuoKay3Qvmp0NA3BP7/322yl1WgOU4FA/fRz CGiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=biRjzYCK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw19-20020a170907a0d300b007aa493b067asi11749282ejc.396.2022.11.09.06.21.33; Wed, 09 Nov 2022 06:21:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=biRjzYCK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231393AbiKIOUa (ORCPT + 99 others); Wed, 9 Nov 2022 09:20:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231270AbiKIOT7 (ORCPT ); Wed, 9 Nov 2022 09:19:59 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D123A21E3E; Wed, 9 Nov 2022 06:19:44 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 06392FF803; Wed, 9 Nov 2022 14:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6RsU9udyOxbtNMCtf0EHobHgYEBuyM2u9K+TcM2I99E=; b=biRjzYCKiMiK3svK2VKWNf11WrjwfSmb93QTki/yAX5a4oGK9goYuwsp74LGimY6D8+sKX nys7/la8xEr3zJzK5ZZqcUPCi0b36LSY+ZV279xJAgoDTTCvaHzeJacDH00xOcHHs5RZ2i l2V1Z0CxzaSfrz2xQd0nBs1C15rdfqt/oWwEYcndru3Kgovd51zcTkThHNjbbBWQuVWHU1 o54R5jFItRiHIqe21ThCJ0l0LZcK68kGMLiUfhiR8u4VkfwN4gKBhtv3rI9ljRcHBe2IrP 5RyAcHEkpHwSpDlE2qBF9AeSiMW4hJg8Zd+ebdUepgjORZC9TFcfDnx4KVuscA== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 09/23] staging: media: tegra-video: improve error messages Date: Wed, 9 Nov 2022 15:18:38 +0100 Message-Id: <20221109141852.729246-10-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028666856615572?= X-GMAIL-MSGID: =?utf-8?q?1749028666856615572?= From: Luca Ceresoli tegra_vi_channels_alloc() can primarily fail for two reasons: 1. "ports" node not found 2. port_num > vi->soc->vi_max_channels Case 1 prints nothing, case 2 has a dev_err(). The caller [tegra_vi_init()] has a generic dev_err() on any failure. This mean that in case 2 we print two messages, and in case 1 we only print a generic message. Remove the generic message and add a specific message when case 1 happens, so that we always have one specific message without even increasing the number of dev_dbg*() calls. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index b24b9353077f..24de4ed1eaf0 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1272,7 +1272,7 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) ports = of_get_child_by_name(node, "ports"); if (!ports) - return -ENODEV; + return dev_err_probe(vi->dev, -ENODEV, "%pOF: missing 'ports' node\n", node); for_each_child_of_node(ports, port) { if (!of_node_name_eq(port, "port")) @@ -1824,11 +1824,8 @@ static int tegra_vi_init(struct host1x_client *client) ret = tegra_vi_tpg_channels_alloc(vi); else ret = tegra_vi_channels_alloc(vi); - if (ret < 0) { - dev_err(vi->dev, - "failed to allocate vi channels: %d\n", ret); + if (ret < 0) goto free_chans; - } ret = tegra_vi_channels_init(vi); if (ret < 0) From patchwork Wed Nov 9 14:18:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17583 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp360672wru; Wed, 9 Nov 2022 06:21:40 -0800 (PST) X-Google-Smtp-Source: AMsMyM5VeGHRc3vEm8Cu0rrJbKAQWIWILWFRqCqPKpv8LZ2NRsFQdSu5se86SyHLAFyGhUVWIzoz X-Received: by 2002:a17:906:5a56:b0:7ad:c391:42ee with SMTP id my22-20020a1709065a5600b007adc39142eemr53119196ejc.127.1668003700298; Wed, 09 Nov 2022 06:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003700; cv=none; d=google.com; s=arc-20160816; b=C9+XYblCfWHf96Vh3sSRciBoPWmI0m4Z1Q90A2lkdLVtR6oX0SY+hhma/fm3sLIzyo MuHemB9JQmTafdcnTJxeQGxsIT66DXWIv+VRizuZrHqn7TGCHkD3Sz0Nfdwh6k1qD6R2 XMYJNnWsPqYUIu5pJd255QBYD6geB/pgWFsj/4JgTDioJYpia3bI4bTBql/TiYt1h9Bw C4AAUBeZpo/c42YF/tCygMedYT89ncCUIhHqyuAEpLOt6NumxVOK4Ai7BzO+ofvVmEwh zedyrUAIsWqap/Z7QdtiFimJVOz400qYRGZPSeGolvTy0Zd8kEUMMIm/XEWNRd+mwoci i9cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k3EpwzVmWOzCEKjlHybKoyyKiKdw/13nJEA6CHMat30=; b=R/V68oA1mEq3A+DzcOJggTwwdbTofqRnvfAYwe1d1Ug7wnf9BSOwspqH+Df2isXGc8 MCjFL0yWlyckYgBZNoxOyZsHQctPUz7vg5TJt3vDsOKs+9rVlKeRtN/hWlwp2F/EeS2Y C5KO5Ccwku9FlmTuietvLbl6RPffX+iBxriNpn0E2b+mUSx/fUrL/dkwOOlvskhfposb yq/OKeeQpboj29ESSdbMsg7SdAub+RnuUPBmIQYmd+r+8Z80YyzXfvMQlDssPB8VcnQI LPi2JfRUmq5w+xvd2AQPSu4YvKgwdqJxjyBJ6twi12kjSTRDkfK1U7+/X3euqsbt4Ko0 qS2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=o6tnVo96; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a17090699c200b0078081036bdasi14353288ejn.501.2022.11.09.06.21.16; Wed, 09 Nov 2022 06:21:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=o6tnVo96; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231226AbiKIOUo (ORCPT + 99 others); Wed, 9 Nov 2022 09:20:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231347AbiKIOUH (ORCPT ); Wed, 9 Nov 2022 09:20:07 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D21E61EEF7; Wed, 9 Nov 2022 06:19:47 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 844EBFF80A; Wed, 9 Nov 2022 14:19:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k3EpwzVmWOzCEKjlHybKoyyKiKdw/13nJEA6CHMat30=; b=o6tnVo96a0eSlbSkQp8oYkb3vb9txGsF3WjNTB79swFuWe920qZYMHsmBqfDfe3y/cmNmB /CDOjMHZcErwRv4CAcP3g0uKnF4ZbXbNmh1vLZj3pxzflmTLOVseg6JOTsVoULzcXvU09/ ooqT9Gmo+IaGRDXYR6FgnwGRKrghqFuPnrg608ACwABOwIQKAIBEOb556nxet1W/syJpXm 54h5WKA393IEHyt8oJukRkp+QbT6+t5lGci5XqI8pfeRD+tJVoSj1jX7GGFKV2xj/iNgi3 smb4NQr3qFI1YoG/fA7Bpc2dOcBoV69O6o8Bo9BrlHNk/g8BoccJPTxmUAOTsQ== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 10/23] staging: media: tegra-video: slightly simplify cleanup on errors Date: Wed, 9 Nov 2022 15:18:39 +0100 Message-Id: <20221109141852.729246-11-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028648488667167?= X-GMAIL-MSGID: =?utf-8?q?1749028648488667167?= From: Luca Ceresoli of_node_put(node) does nothing if node == NULL, so it can be moved to the cleanup section at the bottom. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 24de4ed1eaf0..2657207e5b7d 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1263,7 +1263,7 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) struct device_node *node = vi->dev->of_node; struct device_node *ep = NULL; struct device_node *ports; - struct device_node *port; + struct device_node *port = NULL; unsigned int port_num; struct device_node *parent; struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 }; @@ -1286,7 +1286,6 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) dev_err(vi->dev, "invalid port num %d for %pOF\n", port_num, port); ret = -EINVAL; - of_node_put(port); goto cleanup; } @@ -1309,13 +1308,12 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) lanes = v4l2_ep.bus.mipi_csi2.num_data_lanes; ret = tegra_vi_channel_alloc(vi, port_num, port, lanes); - if (ret < 0) { - of_node_put(port); + if (ret < 0) goto cleanup; - } } cleanup: + of_node_put(port); of_node_put(ports); return ret; } From patchwork Wed Nov 9 14:18:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp360739wru; Wed, 9 Nov 2022 06:21:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4vjOY4T9uEWMWzt1bGfWESiEWJZt7IF2JHQZqfd/P/AtB7ZJTD/lgc8yTPO4S6ehXmY3NY X-Received: by 2002:a17:907:90d0:b0:7ae:6811:8ea7 with SMTP id gk16-20020a17090790d000b007ae68118ea7mr14375547ejb.325.1668003706722; Wed, 09 Nov 2022 06:21:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003706; cv=none; d=google.com; s=arc-20160816; b=pDyorxqkcBPw1A2DvKKaaEXDppgKBAxu/a1zbM15NTRr2Ep0xOY0pTT6AbStE2vPch 7oDWJrdiWJ+j1h4nEkY7OMywTsJzyXUF2vRv8JqqY7IMnlXC8zdk4sUP6FHJtx7Mg4bL HzbaxLLjvf8APYVP2PjK/BipE9+gp7DgXpibTcHuHiSs0DVXW3V7LaP8ff/OR4EcvS0m 0j6ZjBk7JNUrhm6itP7wz0lNpAoVJ9JO+lOa9HeHJUV12cKr8MlgvsimgMO6qeKo0XLv BVLGTwnVc27yF2n8lJOXwO0A8Qh8slVuntvKabxhglVtjjrNrYLxbP3g1aSceGtwOsCh Kl7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1MfEY6qNJmle8dG3mVnv/FdB23DDX5FGvXt/PgtRbi0=; b=W1g1bxxcvhhwWWMtY+oGTWuR0htmz0l8nZ4/0UcRj2BPe3rETHA1b+ZHD/KW1z4o1G gpYtB8Flx+TTLavNNoYKZNUYp8TwfpNT/yqgHCscZujFwc6mez4Yutw78oSDd2b7QxmF SJUMMYi+ehmlTDqYGK4qBz7thteagfIUUdmp1YHu5OlQ0GtuvSsWh8KPp8N1LdP742Mo Muyk+trcDPph1R+rG2V8PaM3QlGWDQU7caZ2IXbvv4woS36zovy9oGt3EavUKCjmYu6x eA4I1PmYL+vFd6g5PSW9eCOv/NPUROFErQo8sRFx5DiH9NBGmovjK8IEOiBKfMAs67/X PUwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=EFRdtXEF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y2-20020a056402358200b0045d050f0fa3si19735220edc.565.2022.11.09.06.21.21; Wed, 09 Nov 2022 06:21:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=EFRdtXEF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231431AbiKIOUr (ORCPT + 99 others); Wed, 9 Nov 2022 09:20:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbiKIOUI (ORCPT ); Wed, 9 Nov 2022 09:20:08 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B0D81F629; Wed, 9 Nov 2022 06:19:50 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 3E45AFF810; Wed, 9 Nov 2022 14:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1MfEY6qNJmle8dG3mVnv/FdB23DDX5FGvXt/PgtRbi0=; b=EFRdtXEFhEhia1JbEDNKzAwCB9Mh+yP6b4KjqO4lqyA2HbNmAGzMByMAiDqMOXS1ueUluO PWumd/t60Oh3NdRsm0rCUdtc5XHCxGQrEyml82bS/b/0oZAFq14Ce3aMwJ2Brd+68GdR2G Oyp8hY/RQz+lE71RibbuIhjfevqZkIr9VOWmZVlOQDV1jdwQE1BmbPgzk8PPytXC4W6cRw AKaQTUcpWHBrUDAORmfyhX2tljzxmsysZJEcD6l+ljZIhr9MbV3B/yji3VL/cCN7hMejaA 0l+Olv6wYYRjXDtKe5urnbxXIObp77ERXqeiiIz1vw9WWgCeIz1qTiwSIQ/xpg== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 11/23] staging: media: tegra-video: move private struct declaration to C file Date: Wed, 9 Nov 2022 15:18:40 +0100 Message-Id: <20221109141852.729246-12-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028654533601587?= X-GMAIL-MSGID: =?utf-8?q?1749028654533601587?= From: Luca Ceresoli struct tegra_vi_graph_entity is an internal implementation detail of the VI module. Move its declaration from vi.h to vi.c. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.c | 13 +++++++++++++ drivers/staging/media/tegra-video/vi.h | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 2657207e5b7d..55a135bef1a9 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -31,6 +31,19 @@ #define MAX_CID_CONTROLS 1 +/** + * struct tegra_vi_graph_entity - Entity in the video graph + * + * @asd: subdev asynchronous registration information + * @entity: media entity from the corresponding V4L2 subdev + * @subdev: V4L2 subdev + */ +struct tegra_vi_graph_entity { + struct v4l2_async_subdev asd; + struct media_entity *entity; + struct v4l2_subdev *subdev; +}; + static const struct tegra_video_format tegra_default_format = { .img_dt = TEGRA_IMAGE_DT_RAW10, .bit_width = 10, diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index dd35c3ac992b..dfd834a69848 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -98,19 +98,6 @@ struct tegra_vi { struct list_head vi_chans; }; -/** - * struct tegra_vi_graph_entity - Entity in the video graph - * - * @asd: subdev asynchronous registration information - * @entity: media entity from the corresponding V4L2 subdev - * @subdev: V4L2 subdev - */ -struct tegra_vi_graph_entity { - struct v4l2_async_subdev asd; - struct media_entity *entity; - struct v4l2_subdev *subdev; -}; - /** * struct tegra_vi_channel - Tegra video channel * From patchwork Wed Nov 9 14:18:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17586 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp360953wru; Wed, 9 Nov 2022 06:22:12 -0800 (PST) X-Google-Smtp-Source: AMsMyM4oIzb7k4TrY1Zozp9W+67yLs+NqXm1dw9xGQAKRYI+GvK4sIWxufEYq6LNhWJ84tcGU1s1 X-Received: by 2002:a17:907:d04:b0:76e:e208:27ba with SMTP id gn4-20020a1709070d0400b0076ee20827bamr58447703ejc.652.1668003732508; Wed, 09 Nov 2022 06:22:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003732; cv=none; d=google.com; s=arc-20160816; b=IKsMQnZTdiUkaHgwfuZlCIHIUVah8050Pc4BJ+VQlxpXFhvzd0RLCiP11/Euu+IQP4 EIvk44QWEYNcb7dadSVPZHpe4X6QHklC4PnBcQhsUbzMWsA1Fiy6b5DsxfLTibi533eu NXnUtSgB9/QCkfQWqvFHZ3mjDazGCbDpUqbq1zXzbvnkLut7bDvkRnL3J2YFLEO6UQTB jw7eR8GsIJ2OOqX5tpe8NzJCAqlxqZuDcV5I5OtWN2edxQZHEqMR2g6ljRBP4wsic7iZ ULB5qJwbIEwNGlp1looEIx9SXDqzWp2JAER/Xfm/4SzX0wgp2C8Xs2+UusEoX7ob8e1b aYTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QFFI30QzE1G3IA3G1EY9+AlTR76QBFRpn0adqyIw2mo=; b=AkN3ZdI5Zh5zan5ULNLH8M9WVYMLAMhqpKMMz1rE0EWRhTWBxhrGBjq4LEdsnNBw20 mPQLY9AO9t6qTk61+LSQbYiUJtjN0EkLEBuW2iOV26tqhNaTmJ/HNbsCkumhQP7BibBV ZUSXp3MG67h3RRa3X71WxLH4WNZ9WSaHFYe+ABjHOY4MG+iKlpm0d+nhpJ/HvhK1Qjzc ZySnuJIueltvmf5bSNbfZcM+LAI7NKNHZeLz7uOkBYLOPzcDHTRMIKm2rIMS9S34WMsF 74NpL2pXfdDfluvdXlPMSb3TSbpdqsZ1QVc0ZTGgaGcni5pcCNCkfv9z5ZDyjch8djRE ZhVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=RHmJUClN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w5-20020a50d785000000b004592ebc28a9si16523872edi.59.2022.11.09.06.21.48; Wed, 09 Nov 2022 06:22:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=RHmJUClN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231239AbiKIOUx (ORCPT + 99 others); Wed, 9 Nov 2022 09:20:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbiKIOUI (ORCPT ); Wed, 9 Nov 2022 09:20:08 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C1E51F2FA; Wed, 9 Nov 2022 06:19:50 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 0A89EFF80C; Wed, 9 Nov 2022 14:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QFFI30QzE1G3IA3G1EY9+AlTR76QBFRpn0adqyIw2mo=; b=RHmJUClNhsoJQKGef2L2nMwo+u+sk7ShPTcZ/6LJ0l+ivqZ486KMaattzm3VfDTYZoxcIf u0wJH6gSY2oNrl3IHpSwpl0ICnhKcgc4RrSwAM4R/Vih8XsH7Ck8m/Lm10MYQnt36l+57s NJmxNDH9RpYNxbe+S7TIXlhkpz/Mkc5tH9jlOY2ttXdXMdD3nZImS4Ze1CsHXGjnz57A/f j03vGPknXdi5ZuAAozKnWDTOU+OBTJIVPTBLsNT1Di4wnpWFyzdtGimAW6jnrb7fjw6rnJ pyOgfZcgoaopr3tC/qmtjZTTsSl2Y3ce+7wTUU58ieauhe4kbwWkfomyMwYjSA== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 12/23] staging: media: tegra-video: remove unneeded include Date: Wed, 9 Nov 2022 15:18:41 +0100 Message-Id: <20221109141852.729246-13-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028681981182960?= X-GMAIL-MSGID: =?utf-8?q?1749028681981182960?= From: Luca Ceresoli There is only a pointer reference to struct tegra_vi in video.h, thus vi.h is not needed. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/video.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/media/tegra-video/video.h b/drivers/staging/media/tegra-video/video.h index fadaf2189dc9..1e9be1474a9c 100644 --- a/drivers/staging/media/tegra-video/video.h +++ b/drivers/staging/media/tegra-video/video.h @@ -12,7 +12,6 @@ #include #include "vi.h" -#include "csi.h" struct tegra_video_device { struct v4l2_device v4l2_dev; From patchwork Wed Nov 9 14:18:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17588 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361024wru; Wed, 9 Nov 2022 06:22:22 -0800 (PST) X-Google-Smtp-Source: AMsMyM4URgPK+T3OLEXX3IDHR3h5EgjePvW7hlXrl0IconJCz6gQRPRu5RkduISm4WH1kIQ9e/5g X-Received: by 2002:a17:907:b14:b0:7ad:c0d5:bdf6 with SMTP id h20-20020a1709070b1400b007adc0d5bdf6mr52402076ejl.222.1668003741866; Wed, 09 Nov 2022 06:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003741; cv=none; d=google.com; s=arc-20160816; b=jwm6wM0vFozhP8+bwrsBiyvIPvN5f31GFofsuzUxe+dJ9NI6o87ZBm2aWBrZDZ7pVI wGAHJaHDZSHWc5M4g/zf4oQINAfFz2Sla+D/mu2W3ZrVckEL3u3L1foJKRuEwGfZKLyh ZQ+knyeXuGejuSgKmqNGnk9eRIry1OAF3OFDUaOm8kIGJKw5n5nPTKJmyel/E/vGpDwQ Rf3d5sGf1QGFJOQb4CTUvDZjjPDKiFG///fSbCDlohngm1w64Ic3YPB0kyTZs53DkihA ZgLTrVYm6gGVjNP2UO/DMVCxRkaehae4C3TuVwnelRXoiqUNiTOcZ5E2v89cNosXWijj KhrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7jipryZ7SK5OxbJXJ4X894J5+2GVN2YC9kvIJJr1YcE=; b=IqfZ5iklEMVEUurRvfL2MVvvSpo1lm+es6bAy8t1ZAGAMcs/GVu7f5tBJsv6ssU+Fh juomSNlJ9b2IdZRWbLnYTYl4zfw/Jdboir+JZAYwvHMYa1p/bnMocUBkc8oMLl5pDPv7 3ntxJtVJ8XlzDYQWO6V3Ey5dKC9Z1JHN98GuHs59hm5LnAopnWHTPg/0+30jrSO1apmo P0KK24f54s1apIJtt+mq+Pwc8MMxFcFmfYlmtpjl4t0FWviZwZdDJh5uSskHvqdsrtGh PilCgHULgR17HJp63l/Sck1yQ8us6NKqLeFoX9FozP7cNXLiFMRKu2rqxm91BWl3Y/ik ouJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aOnpvol8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg25-20020a170907971900b0078dc5b2b6c4si15418793ejc.666.2022.11.09.06.21.57; Wed, 09 Nov 2022 06:22:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aOnpvol8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231436AbiKIOVM (ORCPT + 99 others); Wed, 9 Nov 2022 09:21:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbiKIOUU (ORCPT ); Wed, 9 Nov 2022 09:20:20 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0908222B1; Wed, 9 Nov 2022 06:19:55 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 70A7AFF80D; Wed, 9 Nov 2022 14:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7jipryZ7SK5OxbJXJ4X894J5+2GVN2YC9kvIJJr1YcE=; b=aOnpvol8ufqql9DUeHYkTlfTAYTBw8/04Sv75/xiRvolKFZyljn/aSKAsPImycJUjj8RZ9 wWkuBByAME+D/OFFaZx7C3dawiOxBlpCiw11va2xyycqyLl2VFWWpHymVs2i+NgWYB3AuG Go4HWQa+u9WGMHlwPBwiHVvuL/ZZwop24DOE2Iw/cqfkjcg/x9EO91I70cjeluBmghQC6u O1MAUqngYUR4Yxn31Ak787Msbwo6GHYNTXDIcRR1ays4Vjok6skGIgBObfwS3jxTAubLoR MFWbijMlsJVMPf7cQ/z6YfPwqK1bVjEPvho4cY8Clcjbn7NIU97gzFVNn2fSMA== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 13/23] staging: media: tegra-video: Kconfig: allow TPG only on Tegra210 Date: Wed, 9 Nov 2022 15:18:42 +0100 Message-Id: <20221109141852.729246-14-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028691983917948?= X-GMAIL-MSGID: =?utf-8?q?1749028691983917948?= From: Luca Ceresoli We are about to add support for the Tegra20 parallel video capture, which has no TPG. In preparation for that, limit the VIDEO_TEGRA_TPG option to Tegra210 which is the only implementation currently provided by this driver. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/tegra-video/Kconfig b/drivers/staging/media/tegra-video/Kconfig index df1b2cff2417..c53441822fdf 100644 --- a/drivers/staging/media/tegra-video/Kconfig +++ b/drivers/staging/media/tegra-video/Kconfig @@ -15,5 +15,6 @@ config VIDEO_TEGRA config VIDEO_TEGRA_TPG bool "NVIDIA Tegra VI driver TPG mode" depends on VIDEO_TEGRA + depends on ARCH_TEGRA_210_SOC help Say yes here to enable Tegra internal TPG mode From patchwork Wed Nov 9 14:18:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361017wru; Wed, 9 Nov 2022 06:22:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6be/of4wotW9j8BaepYhJi47oSJExkTxk6GUzG9CUUKsotrFff/kqBnqabAaKFQlWTeK9C X-Received: by 2002:a17:907:8b94:b0:7ae:5884:b344 with SMTP id tb20-20020a1709078b9400b007ae5884b344mr18602860ejc.373.1668003741326; Wed, 09 Nov 2022 06:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003741; cv=none; d=google.com; s=arc-20160816; b=CSzApiPh0rSYbOV9X6y5Xc1MbmmoKjsoYiCoF/LVZVfn2hGxq7mIRi1nE40X7mq1lE JzeZ86p66RwG4sYDEsjTFYYnFlVcSGVZYxl/YquwqMaRILTRPztqkU9q2KVL7Map+bIV 39lyXHmLMWYWC6ddb3tEDJAUMJObOpowqmANVKD5ry3HQrbGB+Q5GQNkwrlJ8m400lSW DG2PY5Juo2DAdTIzPy1tMScCoH3kYA+/u0VBbzmZXp4THRIB46v3zZ47WnUy8M8qE/YV 8pNEzjTB3aeX352D426yV/8vbLNpIzRIiCgxQRwo8dFRGUh2My3gCJq5hUmWZrZz/BSL ituQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QKprQ7SbVR7rzqWBK4mw37A5/0gO98awJ5lSVwD8c70=; b=vB8VRa37v8lo4Ao8T7OLO42KkzvmftNVU73xLFyCxxcwatlocqPo3xddqz7kUiZvJc BjyYIm7Vqc3IHc/3ruF928YW5dnQohv8/rKzJJe7dMwVPrywIDAA6neoC6otmeEL/wFk eWGgkVoxSO3UQTJfK8OW9L/jvdaVer6l+3Ibf2ASilfDpAMk5+yIDzbE5KdYe5Np3w4H T7y4x6KpobUfV4Ctb7x9VmAsqgWkLFAIGB+8AINxW24YcrJDvlxPizB9NPQOCY8dk6JY FLmVQSfGf+i36xe+oe/A7eR/DOpO+BZIvUkoXezBbEVckZqx1xBAaXwxsP4+JdRQtIq7 B21w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aL6gP9Dv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i34-20020a0564020f2200b00458b42ff246si15461185eda.236.2022.11.09.06.21.57; Wed, 09 Nov 2022 06:22:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aL6gP9Dv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231464AbiKIOVR (ORCPT + 99 others); Wed, 9 Nov 2022 09:21:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbiKIOUX (ORCPT ); Wed, 9 Nov 2022 09:20:23 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CC6C222A8; Wed, 9 Nov 2022 06:19:58 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 1B9CEFF80B; Wed, 9 Nov 2022 14:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003594; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QKprQ7SbVR7rzqWBK4mw37A5/0gO98awJ5lSVwD8c70=; b=aL6gP9DvixSUvsUugNBQYHmrdHc2cn0Cvu6RrfJwtH+9fUFobPkPPvzlNkj3RNCR7vxe/g oRPync1l/P2A+9u7VG1o5UXXFE8VUMgoM+joYz68qudFQRSbrJ4LIiGslfjoGoFYT6j2Uu 3vU7GDgdbGhCZoAajmZedUBDbKRJOw4eEyFO4eMku3ecL7250h5ONuVszDlQdJaWyqwaEH EbMCJp3nrZsBVtlz3MwsQXx372mokoFa7uGfDSn+N3j98GKd/7Lp6IGcFSaI2TS+1N/4A2 d0AHvvP3wnpX6qhNEB/CN5QcXz+9emYTTCK+0WzD1A06X5yjeW7irEGrO5uUmg== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 14/23] staging: media: tegra-video: move tegra_channel_fmt_align to a per-soc op Date: Wed, 9 Nov 2022 15:18:43 +0100 Message-Id: <20221109141852.729246-15-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028691253911326?= X-GMAIL-MSGID: =?utf-8?q?1749028691253911326?= From: Luca Ceresoli tegra_channel_fmt_align() takes care of the size constraints, alignment and rounding requirements of the Tegra210 VI peripheral. Tegra20 has different constraints. In preparation for adding Tegra20 support, move this function to a new op in the soc-specific `struct tegra_vi_ops` . Also move to tegra210.c the T210-specific defines used in the moved code. No functional changes. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/tegra210.c | 36 ++++++++++++++++++ drivers/staging/media/tegra-video/vi.c | 40 +++----------------- drivers/staging/media/tegra-video/vi.h | 9 ++--- 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra210.c b/drivers/staging/media/tegra-video/tegra210.c index eb19dd5107ce..71483d0c19bf 100644 --- a/drivers/staging/media/tegra-video/tegra210.c +++ b/drivers/staging/media/tegra-video/tegra210.c @@ -17,6 +17,13 @@ #include "csi.h" #include "vi.h" +#define TEGRA210_MIN_WIDTH 32U +#define TEGRA210_MAX_WIDTH 32768U +#define TEGRA210_MIN_HEIGHT 32U +#define TEGRA210_MAX_HEIGHT 32768U + +#define SURFACE_ALIGN_BYTES 64 + #define TEGRA_VI_SYNCPT_WAIT_TIMEOUT msecs_to_jiffies(200) /* Tegra210 VI registers */ @@ -172,6 +179,34 @@ static u32 vi_csi_read(struct tegra_vi_channel *chan, u8 portno, /* * Tegra210 VI channel capture operations */ +static void tegra210_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp) +{ + unsigned int min_bpl; + unsigned int max_bpl; + unsigned int bpl; + + /* + * The transfer alignment requirements are expressed in bytes. + * Clamp the requested width and height to the limits. + */ + pix->width = clamp(pix->width, TEGRA210_MIN_WIDTH, TEGRA210_MAX_WIDTH); + pix->height = clamp(pix->height, TEGRA210_MIN_HEIGHT, TEGRA210_MAX_HEIGHT); + + /* Clamp the requested bytes per line value. If the maximum bytes per + * line value is zero, the module doesn't support user configurable + * line sizes. Override the requested value with the minimum in that + * case. + */ + min_bpl = pix->width * bpp; + max_bpl = rounddown(TEGRA210_MAX_WIDTH, SURFACE_ALIGN_BYTES); + bpl = roundup(pix->bytesperline, SURFACE_ALIGN_BYTES); + + pix->bytesperline = clamp(bpl, min_bpl, max_bpl); + pix->sizeimage = pix->bytesperline * pix->height; + if (pix->pixelformat == V4L2_PIX_FMT_NV16) + pix->sizeimage *= 2; +} + static int tegra_channel_capture_setup(struct tegra_vi_channel *chan, u8 portno) { @@ -723,6 +758,7 @@ static const struct tegra_video_format tegra210_video_formats[] = { /* Tegra210 VI operations */ static const struct tegra_vi_ops tegra210_vi_ops = { + .vi_fmt_align = tegra210_fmt_align, .vi_start_streaming = tegra210_vi_start_streaming, .vi_stop_streaming = tegra210_vi_stop_streaming, }; diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 55a135bef1a9..12c2fa760c81 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -456,36 +456,6 @@ static int tegra_channel_get_format(struct file *file, void *fh, return 0; } -static void tegra_channel_fmt_align(struct tegra_vi_channel *chan, - struct v4l2_pix_format *pix, - unsigned int bpp) -{ - unsigned int min_bpl; - unsigned int max_bpl; - unsigned int bpl; - - /* - * The transfer alignment requirements are expressed in bytes. - * Clamp the requested width and height to the limits. - */ - pix->width = clamp(pix->width, TEGRA_MIN_WIDTH, TEGRA_MAX_WIDTH); - pix->height = clamp(pix->height, TEGRA_MIN_HEIGHT, TEGRA_MAX_HEIGHT); - - /* Clamp the requested bytes per line value. If the maximum bytes per - * line value is zero, the module doesn't support user configurable - * line sizes. Override the requested value with the minimum in that - * case. - */ - min_bpl = pix->width * bpp; - max_bpl = rounddown(TEGRA_MAX_WIDTH, SURFACE_ALIGN_BYTES); - bpl = roundup(pix->bytesperline, SURFACE_ALIGN_BYTES); - - pix->bytesperline = clamp(bpl, min_bpl, max_bpl); - pix->sizeimage = pix->bytesperline * pix->height; - if (pix->pixelformat == V4L2_PIX_FMT_NV16) - pix->sizeimage *= 2; -} - static int __tegra_channel_try_format(struct tegra_vi_channel *chan, struct v4l2_pix_format *pix) { @@ -561,7 +531,7 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, return ret; v4l2_fill_pix_format(pix, &fmt.format); - tegra_channel_fmt_align(chan, pix, fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(pix, fmtinfo->bpp); __v4l2_subdev_state_free(sd_state); @@ -613,7 +583,7 @@ static int tegra_channel_set_format(struct file *file, void *fh, return ret; v4l2_fill_pix_format(pix, &fmt.format); - tegra_channel_fmt_align(chan, pix, fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(pix, fmtinfo->bpp); chan->format = *pix; chan->fmtinfo = fmtinfo; @@ -649,7 +619,7 @@ static int tegra_channel_set_subdev_active_fmt(struct tegra_vi_channel *chan) chan->format.bytesperline = chan->format.width * chan->fmtinfo->bpp; chan->format.sizeimage = chan->format.bytesperline * chan->format.height; - tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); tegra_channel_update_gangports(chan); return 0; @@ -818,7 +788,7 @@ static int tegra_channel_s_dv_timings(struct file *file, void *fh, chan->format.height = bt->height; chan->format.bytesperline = bt->width * chan->fmtinfo->bpp; chan->format.sizeimage = chan->format.bytesperline * bt->height; - tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); tegra_channel_update_gangports(chan); return 0; @@ -1149,7 +1119,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) chan->format.height = TEGRA_DEF_HEIGHT; chan->format.bytesperline = TEGRA_DEF_WIDTH * chan->fmtinfo->bpp; chan->format.sizeimage = chan->format.bytesperline * TEGRA_DEF_HEIGHT; - tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); ret = tegra_channel_host1x_syncpt_init(chan); if (ret) diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index dfd834a69848..1021c730b595 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -25,17 +25,11 @@ #define V4L2_CID_TEGRA_SYNCPT_TIMEOUT_RETRY (V4L2_CTRL_CLASS_CAMERA | 0x1001) -#define TEGRA_MIN_WIDTH 32U -#define TEGRA_MAX_WIDTH 32768U -#define TEGRA_MIN_HEIGHT 32U -#define TEGRA_MAX_HEIGHT 32768U - #define TEGRA_DEF_WIDTH 1920 #define TEGRA_DEF_HEIGHT 1080 #define TEGRA_IMAGE_FORMAT_DEF 32 #define MAX_FORMAT_NUM 64 -#define SURFACE_ALIGN_BYTES 64 enum tegra_vi_pg_mode { TEGRA_VI_PG_DISABLED = 0, @@ -45,6 +39,8 @@ enum tegra_vi_pg_mode { /** * struct tegra_vi_ops - Tegra VI operations + * @vi_fmt_align: modify `pix` to fit the hardware alignment + * requirements and fill image geometry * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up * VI for capture and runs capture start and capture finish * kthreads for capturing frames to buffer and returns them back. @@ -52,6 +48,7 @@ enum tegra_vi_pg_mode { * back any queued buffers. */ struct tegra_vi_ops { + void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); }; From patchwork Wed Nov 9 14:18:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361034wru; Wed, 9 Nov 2022 06:22:22 -0800 (PST) X-Google-Smtp-Source: AMsMyM5QjlfsDhxgi0LZYBMMFie0PpZ1b4nTDQVkdcavFYxmI4G+DppkhDIT3l0setbbGHammF+0 X-Received: by 2002:a17:907:728e:b0:78d:f5c2:70d3 with SMTP id dt14-20020a170907728e00b0078df5c270d3mr56213980ejc.506.1668003742549; Wed, 09 Nov 2022 06:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003742; cv=none; d=google.com; s=arc-20160816; b=YEBbmoypj44iZ/V3PWZaSCwVjkKcNiAuJEyzUfz7VzDzi2y5s7zy8xe1Sg8Hr3MbO5 70n9NZF0M3hbhFzDNjL2S9tI2h9pKBghG1z7q1OjTvVViNHwkPEy1aEE2k5j1vQpRXHu Itcl+7Q+nzG66UrGTC2A+WWXvPE0ppYciIb1TqLSbtPSOryXpRq3HW2yeWBeYXHZHXJk Vy+UzKGGu0I18EtMuMIHAEp/dUegQPiCR9Fzd7Fxu7v0lKTw6bgBe3di585+KAkpHF/8 v6xhiKjKpmv/LsAWPHu9S79PE/q8T3T6kNGP/fhNmK+7CcL79rHh51H62/b32RRZr4lh 5EWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dg0fu+XSx3Xw9THFytzVz1KPMday3mZFzGI1Ra6KD+w=; b=wr9t4d3qXiJwfhOyhEU2LMecDlI5+TCaXL3+fAXJX9q7Fb6z4sDE2tvZDltoTm7rrM Wjqk1Zat6tOrZv+1JgnhXb+67Tf6fZz7MjFocSrD71wWPQUnQt6aDhJoMYVSpn6/9aPc hhl4VD7M+mT3Y7bFgtmE8AgtF2tBhoJbntFx8JF6T9LcQuMf/hfa91dMHWgFgUlYIHzD Jr3pxbMi5wjscaOAwnhVhSl3DyOOHj1UA2hAUngP3FytdV6nDtnMBvHgf1/cat5YGA6k KG2LtM23DYNWJB5lf4xr/ct7CqWtqXkjo4QCUM8S8tHU4zjcOevni96Af/2stZNBYsEx dU5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Yz2sOcMx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd39-20020a17090762a700b007adacdfd08asi17333360ejc.295.2022.11.09.06.21.59; Wed, 09 Nov 2022 06:22:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Yz2sOcMx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbiKIOVV (ORCPT + 99 others); Wed, 9 Nov 2022 09:21:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbiKIOUZ (ORCPT ); Wed, 9 Nov 2022 09:20:25 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF78922537; Wed, 9 Nov 2022 06:20:01 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id C540BFF816; Wed, 9 Nov 2022 14:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dg0fu+XSx3Xw9THFytzVz1KPMday3mZFzGI1Ra6KD+w=; b=Yz2sOcMxUhnsOzPMRzMU6MDIDC3RmnAfjaPMDA+4XtRgw9nKyR29yUhye/C866hkjra2Oa rzd1UoyznXgTsCWKXhLGJ4mF3T3vnkka0BChhaUsf2oaFcivVAbQ5PgQs3bx/QW6Nhv2oT OfBKgeh8TBKk/CwwQsiisOhJvXg4XiMt4XgpiTJ4LqKBIuqw6qHxYvOVX7vjEK2rafVYRd Wa3WFkEGj5HbnG+ROrxsc2nYoRbhb0iKwMb9F2gq7R2uq2vGM7ZidiBMOvSf3O1Um25vzS JK4eYwlorF4TkV26MhrwMW7kQxhDquWuuziXAga3Cp1lVgnNAQ2CyYvgEKNkhg== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 15/23] staging: media: tegra-video: move default format to soc-specific data Date: Wed, 9 Nov 2022 15:18:44 +0100 Message-Id: <20221109141852.729246-16-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028692186847755?= X-GMAIL-MSGID: =?utf-8?q?1749028692186847755?= From: Luca Ceresoli The tegra_default_format in vi.c is specific to Tegra210 CSI. In preparation for adding Tegra20 VIP support, move the default format to a new field in the soc-specific `struct tegra_vi_soc`. Instead of an entire format struct, only store a pointer to an item in the existing format array. No functional changes. The format pointed to is the same that used to be in vi.c. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/tegra210.c | 2 ++ drivers/staging/media/tegra-video/vi.c | 11 +---------- drivers/staging/media/tegra-video/vi.h | 2 ++ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra210.c b/drivers/staging/media/tegra-video/tegra210.c index 71483d0c19bf..28d3d05c12c4 100644 --- a/drivers/staging/media/tegra-video/tegra210.c +++ b/drivers/staging/media/tegra-video/tegra210.c @@ -771,8 +771,10 @@ const struct tegra_vi_soc tegra210_vi_soc = { .hw_revision = 3, .vi_max_channels = 6, #if IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG) + .default_video_format = &tegra210_video_formats[0], .vi_max_clk_hz = 499200000, #else + .default_video_format = &tegra210_video_formats[4], .vi_max_clk_hz = 998400000, #endif }; diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 12c2fa760c81..8b6cf50e1eae 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -44,15 +44,6 @@ struct tegra_vi_graph_entity { struct v4l2_subdev *subdev; }; -static const struct tegra_video_format tegra_default_format = { - .img_dt = TEGRA_IMAGE_DT_RAW10, - .bit_width = 10, - .code = MEDIA_BUS_FMT_SRGGB10_1X10, - .bpp = 2, - .img_fmt = TEGRA_IMAGE_FORMAT_DEF, - .fourcc = V4L2_PIX_FMT_SRGGB10, -}; - static inline struct tegra_vi * host1x_client_to_vi(struct host1x_client *client) { @@ -1111,7 +1102,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) init_waitqueue_head(&chan->done_wait); /* initialize the video format */ - chan->fmtinfo = &tegra_default_format; + chan->fmtinfo = chan->vi->soc->default_video_format; chan->format.pixelformat = chan->fmtinfo->fourcc; chan->format.colorspace = V4L2_COLORSPACE_SRGB; chan->format.field = V4L2_FIELD_NONE; diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 1021c730b595..879547073371 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -58,6 +58,7 @@ struct tegra_vi_ops { * * @video_formats: supported video formats * @nformats: total video formats + * @default_video_format: default video format (pointer to a @video_formats item) * @ops: vi operations * @hw_revision: VI hw_revision * @vi_max_channels: supported max streaming channels @@ -66,6 +67,7 @@ struct tegra_vi_ops { struct tegra_vi_soc { const struct tegra_video_format *video_formats; const unsigned int nformats; + const struct tegra_video_format *default_video_format; const struct tegra_vi_ops *ops; u32 hw_revision; unsigned int vi_max_channels; From patchwork Wed Nov 9 14:18:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17590 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361124wru; Wed, 9 Nov 2022 06:22:31 -0800 (PST) X-Google-Smtp-Source: AMsMyM4zs6DkK70TZ9bEYOKqnC3KOE3ndii3jRHG/sXAZHYSc2kXeUhDPrUddh/6Y1fFyuWAXBLr X-Received: by 2002:a05:6402:2949:b0:451:fabf:d88a with SMTP id ed9-20020a056402294900b00451fabfd88amr58306056edb.324.1668003751462; Wed, 09 Nov 2022 06:22:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003751; cv=none; d=google.com; s=arc-20160816; b=NEH5veUTXqHsGGcj3pRLFDSEOvJQkyDW0UUnwOrbf7wUZgVNW3gLz/yQEgm5D7bWqh //Mud2jdVOpjrWx+x4+ViIXe8HgSBXUTNt5GWEpVM0p0U4Tp4e1LGo0kT8arI22zZtL0 gS6ZjpAa/VGAaTMb8NAfzC2wk0KtXFLFr4Q3B0zUuDOjhcNfvo5u4R/Vpy2p/8pAkYvi ncd/tVtgSJlbu+o/kPfPlR/qK8D2UN1QtZYH+EcxVuDrvKVofw5t25NBx1STrayIw4J6 oq7yyp34CcuvHWBbsS+tnJQC3qMLYUNaeTg5wxDa6IFWdcUBnxwvmr3nkR+m2g5Sqt1w 5isw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MC/YmsEtqdTSByaeOX415RJyVZ6P5QJjcVFPlc87iB8=; b=GVdSsRwRM7neB878SoLdsFA6AQ9S3TzB6Nx54BXl0o1wJ8uDw22mn9mLp5jazM2gBn x3OML281Ad9OPDqtjVY0/tgmDplEWU6rTGzI/TTsMP2pFEfdj1rnVDKcApOPLt1KM8E8 KIC83ao5tpAVP8D9fbRdAsdxaYIzyykhKnneJVze4JBfuBodX4evG3PUkm/0PZBOoBSu l7YwTmo4Ns9RMpI/QA7nV25q/UjoDN4eyJlboz+QzsjkKefsAjDQv+yT+plnQ94Jp7AB kfvxNYbUzzRF2BF8Puf9KpmtAyw5OyQDQq7RyeiuZMvulBHcm7N3AkY9EB/CdkeTPCdm LVMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cPTWyP1C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a17090628cd00b0078e267ea163si12376879ejd.557.2022.11.09.06.22.06; Wed, 09 Nov 2022 06:22:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cPTWyP1C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231215AbiKIOVZ (ORCPT + 99 others); Wed, 9 Nov 2022 09:21:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbiKIOUX (ORCPT ); Wed, 9 Nov 2022 09:20:23 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58B2E22530; Wed, 9 Nov 2022 06:20:01 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id B190DFF80E; Wed, 9 Nov 2022 14:19:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MC/YmsEtqdTSByaeOX415RJyVZ6P5QJjcVFPlc87iB8=; b=cPTWyP1CnotTQnFE1p5k390efrYHE9Yc79f+aM3E+L8nJlAMWdqYXwyM325u0Pg6XbhaqU UxEkHvdc1onsHVujk4p19UcqpH3x1E9sQl0mn7VM2+ifY6roFE47p14wSKf1v+mgiQaCwB 4EUawypB8T+slKVN/hzJHX5VecQ9czuDoQDeDmDPqyl1ClF7gUS0TxM920j+CWRIlziIJN XqzO4vuUSoqOWf23TCl3Ja44S+ZS6cADypLu8qGuCeyk2zulqoScohJ0vVQXor+MAug/b4 YF+cuP/qexQwFG/lz/3znGy3HIBIaSHjyUglnRiwVA6e5mAtMxZxoG+0JJPiBA== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 16/23] staging: media: tegra-video: move MIPI calibration calls from VI to CSI Date: Wed, 9 Nov 2022 15:18:45 +0100 Message-Id: <20221109141852.729246-17-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028702047237386?= X-GMAIL-MSGID: =?utf-8?q?1749028702047237386?= From: Luca Ceresoli The CSI module does not handle all the MIPI lane calibration procedure, leaving a small part of it to the VI module. In doing this, tegra_channel_enable_stream() (vi.c) manipulates the private data of the upstream subdev casting it to struct 'tegra_csi_channel', which will be wrong after introducing a VIP (parallel video input) channel. This prevents adding support for the VIP module. It also breaks the logical isolation between modules. Since the lane calibration requirement does not exist in the parallel input module, moving the calibration function to a per-module op is not optimal. Instead move the calibration procedure in the CSI module, together with the rest of the calibration procedures. After this change, tegra_channel_enable_stream() just calls v4l2_subdev_call() to ask for a stream start/stop to the CSI module, which in turn knows all the CSI-specific details to implement it. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/csi.c | 44 ++++++++++++++++++++ drivers/staging/media/tegra-video/vi.c | 54 ++----------------------- 2 files changed, 48 insertions(+), 50 deletions(-) diff --git a/drivers/staging/media/tegra-video/csi.c b/drivers/staging/media/tegra-video/csi.c index 426e653bd55d..3a614f568a31 100644 --- a/drivers/staging/media/tegra-video/csi.c +++ b/drivers/staging/media/tegra-video/csi.c @@ -328,12 +328,42 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev) } csi_chan->pg_mode = chan->pg_mode; + + /* + * Tegra CSI receiver can detect the first LP to HS transition. + * So, start the CSI stream-on prior to sensor stream-on and + * vice-versa for stream-off. + */ ret = csi->ops->csi_start_streaming(csi_chan); if (ret < 0) goto finish_calibration; + if (csi_chan->mipi) { + struct v4l2_subdev *src_subdev; + /* + * TRM has incorrectly documented to wait for done status from + * calibration logic after CSI interface power on. + * As per the design, calibration results are latched and applied + * to the pads only when the link is in LP11 state which will happen + * during the sensor stream-on. + * CSI subdev stream-on triggers start of MIPI pads calibration. + * Wait for calibration to finish here after sensor subdev stream-on. + */ + src_subdev = tegra_channel_get_remote_source_subdev(chan); + ret = v4l2_subdev_call(src_subdev, video, s_stream, true); + err = tegra_mipi_finish_calibration(csi_chan->mipi); + + if (ret < 0 && ret != -ENOIOCTLCMD) + goto disable_csi_stream; + + if (err < 0) + dev_warn(csi->dev, "MIPI calibration failed: %d\n", err); + } + return 0; +disable_csi_stream: + csi->ops->csi_stop_streaming(csi_chan); finish_calibration: if (csi_chan->mipi) tegra_mipi_finish_calibration(csi_chan->mipi); @@ -352,10 +382,24 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev) static int tegra_csi_disable_stream(struct v4l2_subdev *subdev) { + struct tegra_vi_channel *chan = v4l2_get_subdev_hostdata(subdev); struct tegra_csi_channel *csi_chan = to_csi_chan(subdev); struct tegra_csi *csi = csi_chan->csi; int err; + /* + * Stream-off subdevices in reverse order to stream-on. + * Remote source subdev in TPG mode is same as CSI subdev. + */ + if (csi_chan->mipi) { + struct v4l2_subdev *src_subdev; + + src_subdev = tegra_channel_get_remote_source_subdev(chan); + err = v4l2_subdev_call(src_subdev, video, s_stream, false); + if (err < 0 && err != -ENOIOCTLCMD) + dev_err_probe(csi->dev, err, "source subdev stream off failed\n"); + } + csi->ops->csi_stop_streaming(csi_chan); if (csi_chan->mipi) { diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 8b6cf50e1eae..2dd3c6c944a2 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -187,49 +187,15 @@ tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan) static int tegra_channel_enable_stream(struct tegra_vi_channel *chan) { - struct v4l2_subdev *csi_subdev, *src_subdev; - struct tegra_csi_channel *csi_chan; - int ret, err; + struct v4l2_subdev *subdev; + int ret; - /* - * Tegra CSI receiver can detect the first LP to HS transition. - * So, start the CSI stream-on prior to sensor stream-on and - * vice-versa for stream-off. - */ - csi_subdev = tegra_channel_get_remote_csi_subdev(chan); - ret = v4l2_subdev_call(csi_subdev, video, s_stream, true); + subdev = tegra_channel_get_remote_csi_subdev(chan); + ret = v4l2_subdev_call(subdev, video, s_stream, true); if (ret < 0 && ret != -ENOIOCTLCMD) return ret; - if (IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) - return 0; - - csi_chan = v4l2_get_subdevdata(csi_subdev); - /* - * TRM has incorrectly documented to wait for done status from - * calibration logic after CSI interface power on. - * As per the design, calibration results are latched and applied - * to the pads only when the link is in LP11 state which will happen - * during the sensor stream-on. - * CSI subdev stream-on triggers start of MIPI pads calibration. - * Wait for calibration to finish here after sensor subdev stream-on. - */ - src_subdev = tegra_channel_get_remote_source_subdev(chan); - ret = v4l2_subdev_call(src_subdev, video, s_stream, true); - err = tegra_mipi_finish_calibration(csi_chan->mipi); - - if (ret < 0 && ret != -ENOIOCTLCMD) - goto err_disable_csi_stream; - - if (err < 0) - dev_warn(csi_chan->csi->dev, - "MIPI calibration failed: %d\n", err); - return 0; - -err_disable_csi_stream: - v4l2_subdev_call(csi_subdev, video, s_stream, false); - return ret; } static int tegra_channel_disable_stream(struct tegra_vi_channel *chan) @@ -237,18 +203,6 @@ static int tegra_channel_disable_stream(struct tegra_vi_channel *chan) struct v4l2_subdev *subdev; int ret; - /* - * Stream-off subdevices in reverse order to stream-on. - * Remote source subdev in TPG mode is same as CSI subdev. - */ - subdev = tegra_channel_get_remote_source_subdev(chan); - ret = v4l2_subdev_call(subdev, video, s_stream, false); - if (ret < 0 && ret != -ENOIOCTLCMD) - return ret; - - if (IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) - return 0; - subdev = tegra_channel_get_remote_csi_subdev(chan); ret = v4l2_subdev_call(subdev, video, s_stream, false); if (ret < 0 && ret != -ENOIOCTLCMD) From patchwork Wed Nov 9 14:18:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17592 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361388wru; Wed, 9 Nov 2022 06:22:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf43BVtyryCIQ2i3Z8RQ6TDvp4ExgcCaVy8xr/30bAuTU4ZM1OHWJ6jYCCam6czPyl2spj8U X-Received: by 2002:a17:906:748:b0:7ae:8d01:8202 with SMTP id z8-20020a170906074800b007ae8d018202mr2899699ejb.384.1668003777865; Wed, 09 Nov 2022 06:22:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003777; cv=none; d=google.com; s=arc-20160816; b=K0A6XYJP1davjjwWY9aMBsthYkD3ZUzlI8ze+LDfTRXQgP1Z1toMq+iBkpfQi7B/xV oLQsG9boD+UtdnXiY2VWgYI7boxf2y3gRtLSe6JLLgNvskj9A1HdtbqyQzuG7Hvmx7i5 LyIAW2csE/QzDHsYXWv0MUeFV+NzB6fNooSxvpHuIhioeZuoi4uASIg1mKVQPUIwVCpK m3p2ugOoIfegJM4AVFKSr32X2fQCT7JqQ8CLdlTvMkqKjZK60yNvIcFQsolsddHkw3py rN8qAudPob7DkgKvcOEIOdB21IyfMgX4nztYgnnPhgLTMDjyggpBnMRRhd/VjV7pCJKL NGMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WqadaQ7yXjv/t0SavSa/yt7ba9txtNTuK1AiW/yRmsI=; b=QgdyReTGvYYdPKT4QyfvdF1zf4i0JLaT2OJZgxcwwUN91svLjTegcI7U8rxIwJ9E34 Ur2S6MevJpluuFpvPgMQhRzHiKpIR4AloPBWHyWuurBuyCsvZYtma24vRJ7QVcTNHzlX PLkB+CBuHMLh8xEldnhna38sOO/jPH4mvmRsybtRQQp3ttgd6Iy0UNkJqk+XRw8BSCC8 qqDQJ9LspvQpbxrmwWn0n4BgepzgQvXSeTYczotcCH3g+IVEoddjJzBYe5jYxrWbgSyL I3h6ftqvuf5x2M9Mkf4hFNMrFCLKo1ri/ZmYj1oaHBzAvKRkJfG3g8yHpJJnyT80at3c 9FGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KQg2bF+9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a056402511100b0045cfb63a033si19142534edd.551.2022.11.09.06.22.34; Wed, 09 Nov 2022 06:22:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KQg2bF+9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231426AbiKIOV3 (ORCPT + 99 others); Wed, 9 Nov 2022 09:21:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231407AbiKIOUo (ORCPT ); Wed, 9 Nov 2022 09:20:44 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ECE21F9CA; Wed, 9 Nov 2022 06:20:07 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 65DDCFF80A; Wed, 9 Nov 2022 14:20:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WqadaQ7yXjv/t0SavSa/yt7ba9txtNTuK1AiW/yRmsI=; b=KQg2bF+92M9dGL/Jc82k7ZMsuv/EInDiLTZ64PwJkkakvn2TAfYiSFF/kn0L4bBS1LX6ut v2ETBf0Es1FnH+CZSnVxyUg4fsUaCZwqPJMizdu5JvDODlGWOjyxyfi2ACjoVghepyKnSp tNTAqWB2EeAIhC4KWJT5qZoF3bB/iJL0iZqqksn5E2C5ly+CIFeMdzx76G2dwE1iCIjNWX N6jGvJkdfg9QvbbnE00xGS3Wd6v2fbWnyjc3GydNwvL9ytsbpgSY3UUM6A7uLj3zsBGcDq bDP4cSD08hL/u3UXmnDL6nCRHTsQL6dEy1ipeHVtCL7xBB6TeJ0+pHYbKOJx7g== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 17/23] staging: media: tegra-video: add a per-soc enable/disable op Date: Wed, 9 Nov 2022 15:18:46 +0100 Message-Id: <20221109141852.729246-18-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028729271441594?= X-GMAIL-MSGID: =?utf-8?q?1749028729271441594?= From: Luca Ceresoli The Tegra20 VI needs an additional operation to enable the VI, add an operation for that. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.c | 7 +++++++ drivers/staging/media/tegra-video/vi.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 2dd3c6c944a2..d0c387873d4e 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1853,6 +1853,9 @@ static int tegra_vi_probe(struct platform_device *pdev) vi->client.ops = &vi_client_ops; vi->client.dev = &pdev->dev; + if (vi->ops->vi_enable) + vi->ops->vi_enable(vi, true); + ret = host1x_client_register(&vi->client); if (ret < 0) { dev_err(&pdev->dev, @@ -1863,6 +1866,8 @@ static int tegra_vi_probe(struct platform_device *pdev) return 0; rpm_disable: + if (vi->ops->vi_enable) + vi->ops->vi_enable(vi, false); pm_runtime_disable(&pdev->dev); return ret; } @@ -1879,6 +1884,8 @@ static int tegra_vi_remove(struct platform_device *pdev) return err; } + if (vi->ops->vi_enable) + vi->ops->vi_enable(vi, false); pm_runtime_disable(&pdev->dev); return 0; diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 879547073371..851c4f3fcb91 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -37,8 +37,11 @@ enum tegra_vi_pg_mode { TEGRA_VI_PG_PATCH, }; +struct tegra_vi; + /** * struct tegra_vi_ops - Tegra VI operations + * @vi_enable: soc-specific operations needed to enable/disable the VI peripheral * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up @@ -48,6 +51,7 @@ enum tegra_vi_pg_mode { * back any queued buffers. */ struct tegra_vi_ops { + int (*vi_enable)(struct tegra_vi *vi, bool on); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); From patchwork Wed Nov 9 14:18:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17591 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361188wru; Wed, 9 Nov 2022 06:22:38 -0800 (PST) X-Google-Smtp-Source: AMsMyM5++8IuZqQj0C7Yx+AGgsYNWQC2dz6GORyGLdgOqYGM8h84OoIxPbUhLaoWEg5nXmFzWEc/ X-Received: by 2002:a17:906:d555:b0:7ae:fdd:d0b4 with SMTP id cr21-20020a170906d55500b007ae0fddd0b4mr34185983ejc.185.1668003758199; Wed, 09 Nov 2022 06:22:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003758; cv=none; d=google.com; s=arc-20160816; b=eLIws9nAckq05ruBvWOucGq0KVE+768OAXkagwWWPARBaWcnMHVBWKJ1KTX2rVVEcc 4VGjDyP0+Ts2M4hG9giMExvIqf7u38DmfMqs459N+Bj6k2qYV8pZu5F4accan2y485gq 5kwCmb7zmb/RheC6+GXc1SBUglZlHwShhOErF+UoIfh5azd2H+R3QcBMrAMngXqt5coV nN67BNlGMFTzGVAxl1tn+3LV5h9EVqW3ZQPSvEdIwlarNsw2OmWZ/YFyrs8ZcautorQl h0sETYh82EQctz5hf3Q2heF5OgLn4YZF1FgOqrvGIsa6cOsKDsVlAj4V8WLfXkXZO81L HsZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u7/iNfm4oerh3eWw2mnfLB/WRIyASBXURnoM2MXHFm4=; b=GJoIu4UhCvfgssEvh0wPKNlnoAugs/EUvQoivi4Fsq+QKlUw12kH4pT7NbjF5/feyj ttk0ERX2D8G7exlIV9PgqUxU4uzOpBsnnvIzqyS4jJChkCJSXZDvjGcLrCg5GnBiOhYw oihzncQg68x7wyCC8dAUqyKj5NH4wfXeXqkyaHQC+y8E9HO8KBrR8yX/uV8ihCMLzLw0 iwjCVaLzcP/LH4RxnKDyHp0BHyozAL1g4Oyy60TAQwMIaUxpOoZoQ01HFPi6yLCwumeJ smjr0BowZXXqSrs66A0AiNuDCIxuxBhSyggWu6yCJe2LGsohoBqQmCtG7ZIwvrweZoju FcBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=otW6ul+y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gh30-20020a1709073c1e00b007ae29da29e4si10759881ejc.962.2022.11.09.06.22.13; Wed, 09 Nov 2022 06:22:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=otW6ul+y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231490AbiKIOVb (ORCPT + 99 others); Wed, 9 Nov 2022 09:21:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231409AbiKIOUo (ORCPT ); Wed, 9 Nov 2022 09:20:44 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B560A1FFAB; Wed, 9 Nov 2022 06:20:07 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id BA897FF819; Wed, 9 Nov 2022 14:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003606; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u7/iNfm4oerh3eWw2mnfLB/WRIyASBXURnoM2MXHFm4=; b=otW6ul+yRbDFj8p+1NecC4vsPuOUImJaJ6Dq76HQl/+LB4DcZeR6/h4S5PIk1mz+YLdGzK kMOAa4QTA6MqTc8VzN3PXe4P7qCR0BzGFVdbYmuHSZD9wM1v4X7qlD5LpZmRyoLX3b3VCG WBQ8zX85EdW/W6EpqCRuFM+TloCvcEKdEKecLpbEjopI9OfNyCBUDt2u9EHfMWZTMb6uCI OIkXLZ+Ib2nQVvFwXy5V4jd7WvFQZ6XzYA9/O6Q6kgf6yTHGy3xOekmvLWYSP2e4GuPvux IrVF2YaYjt93oPJd+ilM63Q81pvNTkcjM0B7gm0uoadl53N6sJ4Wu+GzJppuwg== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 18/23] staging: media: tegra-video: move syncpt init/free to a per-soc op Date: Wed, 9 Nov 2022 15:18:47 +0100 Message-Id: <20221109141852.729246-19-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028708726933380?= X-GMAIL-MSGID: =?utf-8?q?1749028708726933380?= From: Luca Ceresoli tegra_channel_host1x_syncpt_init() gets the host1x syncpts needed for the Tegra210 implementation, and tegra_channel_host1x_syncpts_free() puts them. Tegra20 needs to get and put a different syncpt. In preparation for adding Tegra20 support, move these functions to new ops in the soc-specific `struct tegra_vi_ops` . No functional changes. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/tegra210.c | 52 ++++++++++++++++++++ drivers/staging/media/tegra-video/vi.c | 52 ++------------------ drivers/staging/media/tegra-video/vi.h | 5 ++ 3 files changed, 60 insertions(+), 49 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra210.c b/drivers/staging/media/tegra-video/tegra210.c index 28d3d05c12c4..d47ba79bac75 100644 --- a/drivers/staging/media/tegra-video/tegra210.c +++ b/drivers/staging/media/tegra-video/tegra210.c @@ -179,6 +179,56 @@ static u32 vi_csi_read(struct tegra_vi_channel *chan, u8 portno, /* * Tegra210 VI channel capture operations */ + +static int tegra210_channel_host1x_syncpt_init(struct tegra_vi_channel *chan) +{ + struct tegra_vi *vi = chan->vi; + unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED; + struct host1x_syncpt *fs_sp; + struct host1x_syncpt *mw_sp; + int ret, i; + + for (i = 0; i < chan->numgangports; i++) { + fs_sp = host1x_syncpt_request(&vi->client, flags); + if (!fs_sp) { + dev_err(vi->dev, "failed to request frame start syncpoint\n"); + ret = -ENOMEM; + goto free_syncpts; + } + + mw_sp = host1x_syncpt_request(&vi->client, flags); + if (!mw_sp) { + dev_err(vi->dev, "failed to request memory ack syncpoint\n"); + host1x_syncpt_put(fs_sp); + ret = -ENOMEM; + goto free_syncpts; + } + + chan->frame_start_sp[i] = fs_sp; + chan->mw_ack_sp[i] = mw_sp; + spin_lock_init(&chan->sp_incr_lock[i]); + } + + return 0; + +free_syncpts: + for (i = 0; i < chan->numgangports; i++) { + host1x_syncpt_put(chan->mw_ack_sp[i]); + host1x_syncpt_put(chan->frame_start_sp[i]); + } + return ret; +} + +static void tegra210_channel_host1x_syncpt_free(struct tegra_vi_channel *chan) +{ + int i; + + for (i = 0; i < chan->numgangports; i++) { + host1x_syncpt_put(chan->mw_ack_sp[i]); + host1x_syncpt_put(chan->frame_start_sp[i]); + } +} + static void tegra210_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp) { unsigned int min_bpl; @@ -758,6 +808,8 @@ static const struct tegra_video_format tegra210_video_formats[] = { /* Tegra210 VI operations */ static const struct tegra_vi_ops tegra210_vi_ops = { + .channel_host1x_syncpt_init = tegra210_channel_host1x_syncpt_init, + .channel_host1x_syncpt_free = tegra210_channel_host1x_syncpt_free, .vi_fmt_align = tegra210_fmt_align, .vi_start_streaming = tegra210_vi_start_streaming, .vi_stop_streaming = tegra210_vi_stop_streaming, diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index d0c387873d4e..854ffb4b5617 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -973,21 +973,11 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) return 0; } -static void tegra_channel_host1x_syncpts_free(struct tegra_vi_channel *chan) -{ - int i; - - for (i = 0; i < chan->numgangports; i++) { - host1x_syncpt_put(chan->mw_ack_sp[i]); - host1x_syncpt_put(chan->frame_start_sp[i]); - } -} - static void tegra_channel_cleanup(struct tegra_vi_channel *chan) { v4l2_ctrl_handler_free(&chan->ctrl_handler); media_entity_cleanup(&chan->video.entity); - tegra_channel_host1x_syncpts_free(chan); + chan->vi->ops->channel_host1x_syncpt_free(chan); mutex_destroy(&chan->video_lock); } @@ -1005,42 +995,6 @@ void tegra_channels_cleanup(struct tegra_vi *vi) } } -static int tegra_channel_host1x_syncpt_init(struct tegra_vi_channel *chan) -{ - struct tegra_vi *vi = chan->vi; - unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED; - struct host1x_syncpt *fs_sp; - struct host1x_syncpt *mw_sp; - int ret, i; - - for (i = 0; i < chan->numgangports; i++) { - fs_sp = host1x_syncpt_request(&vi->client, flags); - if (!fs_sp) { - dev_err(vi->dev, "failed to request frame start syncpoint\n"); - ret = -ENOMEM; - goto free_syncpts; - } - - mw_sp = host1x_syncpt_request(&vi->client, flags); - if (!mw_sp) { - dev_err(vi->dev, "failed to request memory ack syncpoint\n"); - host1x_syncpt_put(fs_sp); - ret = -ENOMEM; - goto free_syncpts; - } - - chan->frame_start_sp[i] = fs_sp; - chan->mw_ack_sp[i] = mw_sp; - spin_lock_init(&chan->sp_incr_lock[i]); - } - - return 0; - -free_syncpts: - tegra_channel_host1x_syncpts_free(chan); - return ret; -} - static int tegra_channel_init(struct tegra_vi_channel *chan) { struct tegra_vi *vi = chan->vi; @@ -1066,7 +1020,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) chan->format.sizeimage = chan->format.bytesperline * TEGRA_DEF_HEIGHT; vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); - ret = tegra_channel_host1x_syncpt_init(chan); + ret = vi->ops->channel_host1x_syncpt_init(chan); if (ret) return ret; @@ -1129,7 +1083,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) cleanup_media: media_entity_cleanup(&chan->video.entity); free_syncpts: - tegra_channel_host1x_syncpts_free(chan); + vi->ops->channel_host1x_syncpt_free(chan); return ret; } diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 851c4f3fcb91..8fadca33bcc9 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -38,10 +38,13 @@ enum tegra_vi_pg_mode { }; struct tegra_vi; +struct tegra_vi_channel; /** * struct tegra_vi_ops - Tegra VI operations * @vi_enable: soc-specific operations needed to enable/disable the VI peripheral + * @channel_host1x_syncpt_init: initialize synchronization points + * @channel_host1x_syncpt_free: free all synchronization points * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up @@ -52,6 +55,8 @@ struct tegra_vi; */ struct tegra_vi_ops { int (*vi_enable)(struct tegra_vi *vi, bool on); + int (*channel_host1x_syncpt_init)(struct tegra_vi_channel *chan); + void (*channel_host1x_syncpt_free)(struct tegra_vi_channel *chan); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); From patchwork Wed Nov 9 14:18:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17593 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361575wru; Wed, 9 Nov 2022 06:23:15 -0800 (PST) X-Google-Smtp-Source: AMsMyM4mwZL8kUih95UHuJjuqqyZ/bpjVVAleTsxDZXq7ViKPGuPURK0QzwcCLfNmrkxRwkEHz0U X-Received: by 2002:a17:906:cc0e:b0:7ad:a4c4:8745 with SMTP id ml14-20020a170906cc0e00b007ada4c48745mr57767364ejb.175.1668003795346; Wed, 09 Nov 2022 06:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003795; cv=none; d=google.com; s=arc-20160816; b=dIMzrb0BpKFmAaePG2Nf2F5AMcjIyAk3rfulF4Fhl9/7ppqBR06XthvjBs/cRtCuzk 6vbPTOhIR77ByZ6O8T4UybjNIDDa63A1J5HNi4bvZTkUEd/vpnqQdzAgZboPigDZPXB3 OElq8EGP5W6kZQDDEmk6sNC4TUCLNJbWxbgCQ2QuyA31ukMQf8vMsXI33b08FtpVa0eq i8z0hntfeirthE7zvkHrKKoTuuLXjUD01C5FF2LYGTS3uPaueFeTVbvn65xGCCapQ0Vq C7S2wDG/vIzrMzCRliebmPkwHg6umoG8ciWdm+Lto00OO1k9S33mUDL9ckiAvOQeA0Ts yqWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=htGRYXVJHCm+VjabaduYJWZ2LBkEOdCNwzZfPxcpLAk=; b=mobX+QOYl9vhGkEhmZEQpyP0mIqD3WtnUmi+Z+WR3qPvU+eGRnMI1w3b5CD//UfGoP I6ZOSGea0h2X9SUVPaZwcvyjLVNsOm8TuS/JnY0HXB+8sSqcaGhVL5LBcIQbJtKEIB6d V5s632RYjmAWwmC0lM/Nw/GMJo/oHgSJZhlBINiuptvJjv/J5wGnM6q1onBc6gE/UHuB wIxTPBx862CTc3N/B9fvhzDgDXzNsuyZ+qItsNXUl3PkiHcGH9AeZxUPB2stt8MlC21D rsE7XD9ikQBNMEMjt+w18tFymMpqxvSWhCdTT5fDKVk4SbwN+mwvKlWSB/s3j68c1SrG SlrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dIFQPstr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg41-20020a170907972900b007add8160fd9si9750236ejc.765.2022.11.09.06.22.50; Wed, 09 Nov 2022 06:23:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dIFQPstr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231383AbiKIOV6 (ORCPT + 99 others); Wed, 9 Nov 2022 09:21:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231313AbiKIOVL (ORCPT ); Wed, 9 Nov 2022 09:21:11 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2EA8233BF; Wed, 9 Nov 2022 06:20:12 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id B5EE6FF80D; Wed, 9 Nov 2022 14:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=htGRYXVJHCm+VjabaduYJWZ2LBkEOdCNwzZfPxcpLAk=; b=dIFQPstrZBE9F39CDeMweJNRNdwH9ovs1sNOXltT4zqaZEY7cfZc6BySALsx3umUd4nfrQ JjowYHiwMbJb3gR8NkfOQQ/jrjo5Ch0thJyUXxc3bPJ1HFCeGMpICQYXjQJvTa9ZC9CdOn rWu5Fg0xArIN52xsjhbDh+lnQe+5+wfuBoGP2TkMruFyOma6t9om7bvBqQJQVL/3cWFJhY uqvc97cyA2x8dSH3snjEb/v2+kj/3Nc96Hvl7AELJ1rLHvPrqPxBlicYyg9ISwT52S9xMV XgkKsV+iO0g+VAmVHlXxPoaLvGdX41eYHY3gaKDHZ6gvNEqOIxplqHPF76Mzew== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 19/23] staging: media: tegra-video: add syncpts for Tegra20 to struct tegra_vi Date: Wed, 9 Nov 2022 15:18:48 +0100 Message-Id: <20221109141852.729246-20-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028747562815009?= X-GMAIL-MSGID: =?utf-8?q?1749028747562815009?= From: Luca Ceresoli In preparation to implement Tegra20 parallel video capture, add variables to hold the required syncpt. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 8fadca33bcc9..ba563cd17296 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -117,11 +117,13 @@ struct tegra_vi { * @vi: Tegra video input device structure * @frame_start_sp: host1x syncpoint pointer to synchronize programmed capture * start condition with hardware frame start events through host1x - * syncpoint counters. + * syncpoint counters. (Tegra210) * @mw_ack_sp: host1x syncpoint pointer to synchronize programmed memory write * ack trigger condition with hardware memory write done at end of - * frame through host1x syncpoint counters. + * frame through host1x syncpoint counters. (Tegra210) * @sp_incr_lock: protects cpu syncpoint increment. + * @out_sp: host1x syncpoint pointer for frame sync (Tegra20) + * @next_out_sp_idx: next expected value for @out_sp (Tegra20) * * @kthread_start_capture: kthread to start capture of single frame when * vb buffer is available. This thread programs VI CSI hardware @@ -173,6 +175,8 @@ struct tegra_vi_channel { struct host1x_syncpt *mw_ack_sp[GANG_PORTS_MAX]; /* protects the cpu syncpoint increment */ spinlock_t sp_incr_lock[GANG_PORTS_MAX]; + struct host1x_syncpt *out_sp; + u32 next_out_sp_idx; struct task_struct *kthread_start_capture; wait_queue_head_t start_wait; From patchwork Wed Nov 9 14:18:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17597 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361860wru; Wed, 9 Nov 2022 06:23:44 -0800 (PST) X-Google-Smtp-Source: AMsMyM6LXOGqyDYrArq0u6dvFNtf/H7PQRpcMTlwL2RNiq0S9wDjhwG+yZvqL4NPRKk/Xoe5oGV8 X-Received: by 2002:a17:907:3e03:b0:722:e694:438 with SMTP id hp3-20020a1709073e0300b00722e6940438mr57828995ejc.755.1668003824135; Wed, 09 Nov 2022 06:23:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003824; cv=none; d=google.com; s=arc-20160816; b=y1GdkUR83J1SLj5lgyP/CsAYS+YoBV+Hc5uYhAt4RjSEAwlb3GAt0Wlkgyvwt+c0Jw WGcV9SpeL1vTQEmcppuTj7gONNUJYr2ro19m7lCr4EzZmO7f7K9osmRNufmOflCQGrjM T0Koxfs6Tn2LQe1pARCpnvxhLIFZVfw8nAcGi/8V+jpPVPjlRFpsbhUPugoWtA7/KXsp WpXX71JeMrf9GKVzW3IAZ83mD0okexufN0FDxr76Ku2gGLAcPevMUtz/mk6OmpON1Evc VR50WVzF9pFxomPJwlxxEeGP+ZmW0H2eZ3+DmJ+UfrWHhAHB1cNLGd9ypz5Zam7I60JF nLUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ip9bY6YtCyentpwiI3F4YXAllQWzlsRpRMRpuGovH+Q=; b=d8uVtBvRoyIN6923sa1pihCaIRMXUUgU7+7JrgzcvyuH1+xrmjPWOMHS/Lqn7WNlw6 d9PVM8KMHjFaikT/LZI2BX5XLFAZiyB+jEYGevK40dWAUaa8dnR29RlYrpvZcOr75EKZ vPOnKJ3sVzwDbsXpOsd+eCYupo0sz8U9uASylW+yt9pXX7K+Nm2sCHXew6W/m/onbnbS C2WANYXoCwmmbrf0E992/fjRfClEjr8TjG/sFAdqbloAqHjSj6SC6jPqL59aezcnbqm3 7OQA9KSYUWh3pFc4IM2XqJZL7ODoVneaVaCz9q0ZEk5XfA30zAbalQ0wm1/T4izV1Rm4 tZag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Lr4nREZO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d31-20020a056402401f00b00459ff7667b4si15510201eda.203.2022.11.09.06.23.19; Wed, 09 Nov 2022 06:23:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Lr4nREZO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231569AbiKIOWB (ORCPT + 99 others); Wed, 9 Nov 2022 09:22:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231440AbiKIOVN (ORCPT ); Wed, 9 Nov 2022 09:21:13 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB11423BD6; Wed, 9 Nov 2022 06:20:15 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 37FB6FF814; Wed, 9 Nov 2022 14:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ip9bY6YtCyentpwiI3F4YXAllQWzlsRpRMRpuGovH+Q=; b=Lr4nREZOfO+LFPK3DCjfLBoqjPwcJMm0VPhDXTEdDRxLmH+lBToivka/UFWywVGmbD5SUa +6DuJxmUMe/q4dNgwBg1mRPc8f+lGDJYhwdFV1mZi0f1P1V7dLymPgM1+uFDddAOjzIFO/ 5wNFy1+Iesd50jZ8Hdyy3EXny1sapeVpGDRQDItYeGTEEswF2IlxsoQt/pNZmAM4nEWIB1 kBL/eGrRml71m5H8yWHsZKDYHsCguA7qsAxL1gRpYWL8Wgo/5YNmFeCt4//iIA24EjeKy/ R05LZwXvYa8Vgg0VCU/XW9YQeeILJzWotjDUIUq4+Lph4RH9xLzvR5N/zyAkFA== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 20/23] staging: media: tegra-video: add hooks for planar YUV and H/V flip Date: Wed, 9 Nov 2022 15:18:49 +0100 Message-Id: <20221109141852.729246-21-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028778203463803?= X-GMAIL-MSGID: =?utf-8?q?1749028778203463803?= From: Luca Ceresoli Tegra20 supports planar YUV422 capture, which can be implemented by writing U and V base address registers in addition to the "main" base buffer address register. It also supports H and V flip, which among others requires to write the start address (i.e. the 1st offset to write, at the end of the buffer or line) in more registers for Y and, for planar formats, U and V. Add minimal hooks in VI to allow per-SoC optional support to those features: - variables in struct tegra_vi for the U and V buffer base offsets - variables in struct tegra_vi for the Y, U and V buffer start offsets - an optional per-soc VI operation to compute those values on queue setup Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.c | 4 ++++ drivers/staging/media/tegra-video/vi.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 854ffb4b5617..ebb502a45e96 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -92,6 +92,7 @@ tegra_get_format_by_fourcc(struct tegra_vi *vi, u32 fourcc) /* * videobuf2 queue operations */ + static int tegra_channel_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, unsigned int *nplanes, @@ -107,6 +108,9 @@ static int tegra_channel_queue_setup(struct vb2_queue *vq, sizes[0] = chan->format.sizeimage; alloc_devs[0] = chan->vi->dev; + if (chan->vi->ops->channel_queue_setup) + chan->vi->ops->channel_queue_setup(chan); + return 0; } diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index ba563cd17296..a23ee8800d33 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -47,6 +47,7 @@ struct tegra_vi_channel; * @channel_host1x_syncpt_free: free all synchronization points * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry + * @channel_queue_setup: additional operations at the end of vb2_ops::queue_setup * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up * VI for capture and runs capture start and capture finish * kthreads for capturing frames to buffer and returns them back. @@ -58,6 +59,7 @@ struct tegra_vi_ops { int (*channel_host1x_syncpt_init)(struct tegra_vi_channel *chan); void (*channel_host1x_syncpt_free)(struct tegra_vi_channel *chan); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); + void (*channel_queue_setup)(struct tegra_vi_channel *chan); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); }; @@ -148,6 +150,12 @@ struct tegra_vi { * @queue: vb2 buffers queue * @sequence: V4L2 buffers sequence number * + * @addr_offset_u: U plane base address, relative to buffer base address (only for planar) + * @addr_offset_v: V plane base address, relative to buffer base address (only for planar) + * @start_offset: 1st Y byte to write, relative to buffer base address (for H/V flip) + * @start_offset_u: 1st U byte to write, relative to buffer base address (for H/V flip) + * @start_offset_v: 1st V byte to write, relative to buffer base address (for H/V flip) + * * @capture: list of queued buffers for capture * @start_lock: protects the capture queued list * @done: list of capture done queued buffers @@ -188,6 +196,12 @@ struct tegra_vi_channel { struct vb2_queue queue; u32 sequence; + unsigned int addr_offset_u; + unsigned int addr_offset_v; + unsigned int start_offset; + unsigned int start_offset_u; + unsigned int start_offset_v; + struct list_head capture; /* protects the capture queued list */ spinlock_t start_lock; From patchwork Wed Nov 9 14:18:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17594 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361676wru; Wed, 9 Nov 2022 06:23:25 -0800 (PST) X-Google-Smtp-Source: AMsMyM4G22B/KgoZSo6G1d7xeAvDduFH0Z9xweeMoXZccbAI7RsWP5fac4SvyXMiH9tFpX4IjKAc X-Received: by 2002:a50:ee8f:0:b0:44e:cd80:843b with SMTP id f15-20020a50ee8f000000b0044ecd80843bmr1126987edr.126.1668003805718; Wed, 09 Nov 2022 06:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003805; cv=none; d=google.com; s=arc-20160816; b=w9Kf+bqu9aEUHYZravTOC6DCtg9B2xFCVSVq8E2+pSDOh6FYAnlADufxEBdrp2swML hjlCOMkFUg9z6+AIcRgBcHYY1tXy5G2qVBvejtL4ebaXRk1js2227jDK2RbE7w6P5TW+ l7Tz+Yw6JwgMIDz8JcH+D3gzkM4ZWcG3g9qYMTov25vFp1VrTyNpU/yua+QJBpsQGhJi JnToFnhwZVlnUtyiixJtn+nvMfWLOahIbwZMBqbQBASfBM8jus9cVjZevXz0eFK/7oiF AjVWbp58j2AunZdf8tsGlPX7Q86kHL+kB2EgtYnz6DgiBfevGe5cf4iAg5zP9rQhotvs btrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HSVYZovD1TAgVblUZpBlNNL+t9V++IJQO3Isa2vGQCk=; b=gmfYoiErS3WWsZibU9SUOEmWOSYERvvCFDPvuOjin+wTKvS5QWYFWoJTX5JRaGCEYj TCL67rxN1znlzRzOQFvfokZpN4m5aDF/fdUXgjN/M0IH5kioJcZm1bpNGYh7gZH49RxN Bor9K/Y3zwFg2QrJ5xLGXwgdnRdHbw1egqJiQgOL+2snZo/5Z1n8wg1SfFVudaZ9IHFA 2ZY/38+lxpfGwWgHPcC6vFgsLM99cLG+gGUWq8DvC8QP5qpO4RdOIy6KAtBgTp0QCM+V 6Tl8aJEXbdN8srX6bduZ/Al4eakB00gHZO2DRhaxpWDwUXifSrPs8QjtyvuoosuPrYTa YUkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=CRfLYcSZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd10-20020a170907628a00b007ae199ea55asi16754963ejc.817.2022.11.09.06.23.00; Wed, 09 Nov 2022 06:23:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=CRfLYcSZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbiKIOWF (ORCPT + 99 others); Wed, 9 Nov 2022 09:22:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231381AbiKIOVN (ORCPT ); Wed, 9 Nov 2022 09:21:13 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7E323BD5; Wed, 9 Nov 2022 06:20:15 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id BA999FF805; Wed, 9 Nov 2022 14:20:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HSVYZovD1TAgVblUZpBlNNL+t9V++IJQO3Isa2vGQCk=; b=CRfLYcSZmOynYgH0wnczOygJKS8k70dhMyr41WYqMN3XP9NM+VYZmiwT2nLokQZQP5qRye rrW5jxOJCuxPlkkVTUBL4yxIMxzV/VcxKvTS5+H6GkRx2M5T7XQVg6yuBCl+lpWGVozc9I QEpGpYRmmXEgj0Ar0sEeogu70S2Cr4DYI7kcrw/e40Dt9G7wqxbI1tA2SBnqqcEyaMdSWz iPiRVMQABPtyAvWI1YSSp0uH+SNs5Bjzzs0qYSI4orXnY+yijlFslVkB5az+qt2UE5yhnn x3Re8bFv2gXsTU+V9Jq3FWVMy/ljD/RrT7dWnB99AFRWnsd3G1Fyd4r89r2URg== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 21/23] staging: media: tegra-video: add H/V flip controls Date: Wed, 9 Nov 2022 15:18:50 +0100 Message-Id: <20221109141852.729246-22-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028758719771477?= X-GMAIL-MSGID: =?utf-8?q?1749028758719771477?= From: Luca Ceresoli Tegra20 can do horizontal and vertical image flip, but Tegra210 cannot (either the hardware, or this driver). In preparation to adding Tegra20 support, add a flag in struct tegra_vi_soc so the generic vi.c code knows whether the flip controls should be added or not. Also provide a generic implementation that simply sets two flags in the channel struct. The Tegra20 implementation will enable flipping at stream start based on those flags. Signed-off-by: Luca Ceresoli --- drivers/staging/media/tegra-video/vi.c | 14 +++++++++++++- drivers/staging/media/tegra-video/vi.h | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index ebb502a45e96..0dbc3da6f98c 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -29,7 +29,7 @@ #include "vi.h" #include "video.h" -#define MAX_CID_CONTROLS 1 +#define MAX_CID_CONTROLS 3 /** * struct tegra_vi_graph_entity - Entity in the video graph @@ -893,6 +893,12 @@ static int vi_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_TEGRA_SYNCPT_TIMEOUT_RETRY: chan->syncpt_timeout_retry = ctrl->val; break; + case V4L2_CID_HFLIP: + chan->hflip = ctrl->val; + break; + case V4L2_CID_VFLIP: + chan->vflip = ctrl->val; + break; default: return -EINVAL; } @@ -964,6 +970,12 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) v4l2_ctrl_handler_free(&chan->ctrl_handler); return ret; } + + if (chan->vi->soc->has_h_v_flip) { + v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); + v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); + } + #endif /* setup the controls */ diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index a23ee8800d33..7cb038957f1b 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -74,6 +74,7 @@ struct tegra_vi_ops { * @hw_revision: VI hw_revision * @vi_max_channels: supported max streaming channels * @vi_max_clk_hz: VI clock max frequency + * @has_h_v_flip: the chip can do H adn V flip, and the driver implements it */ struct tegra_vi_soc { const struct tegra_video_format *video_formats; @@ -83,6 +84,7 @@ struct tegra_vi_soc { u32 hw_revision; unsigned int vi_max_channels; unsigned int vi_max_clk_hz; + bool has_h_v_flip:1; }; /** @@ -170,6 +172,9 @@ struct tegra_vi { * @syncpt_timeout_retry: syncpt timeout retry count for the capture * @pg_mode: test pattern generator mode (disabled/direct/patch) * @notifier: V4L2 asynchronous subdevs notifier + * + * @hflip: Horizontal flip is enabled + * @vflip: Vertical flip is enabled */ struct tegra_vi_channel { struct list_head list; @@ -219,6 +224,9 @@ struct tegra_vi_channel { enum tegra_vi_pg_mode pg_mode; struct v4l2_async_notifier notifier; + + bool hflip:1; + bool vflip:1; }; /** From patchwork Wed Nov 9 14:18:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361789wru; Wed, 9 Nov 2022 06:23:36 -0800 (PST) X-Google-Smtp-Source: AMsMyM5lnqAMfyqqLv8RZjiBN1CDQQbbv9LAVl+WRu+0HMlX2xxXjgDuIe3zmgjfU8mx2GAiWNor X-Received: by 2002:a05:6402:4444:b0:458:f355:ce04 with SMTP id o4-20020a056402444400b00458f355ce04mr61344960edb.422.1668003816115; Wed, 09 Nov 2022 06:23:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003816; cv=none; d=google.com; s=arc-20160816; b=uw5LeoRhRoc2XqvEQBw2VW//Nw7395HhjzygNfTtVNIkfKstpLNx3PvVvc+EROxIjj bgaOo1pKP29SB3EB1NoC20VLnRzDnfkcuTpWJrVgt4fOhfmrM87B9oaogkZXadZ2MRUZ KrXYZLk551ESHe6o6JM3BTGdvDNV5qfnV7+ju4ou2MUOtcUoCaC3qcXVHvgnX2KJy7Nw E9shLoG6mpsaI0trfeSmWm0ylD6QZ3yxDwYdsaf/PWJhEZouRLQhVtw3bJ5+v7JwbE4V HP4VR9nWeAvVyVttBYAY/v3TkZ5oJTgNfBIeBruv8R8Kg0XjRwkzgWfTwpPvw0Lr9C8h VZ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Hf+ndFwOk7J0RzX3PZJg+38Xr2MdPQZz58Tt3uS2qMk=; b=D4myfUOqMqaoUi4jBrnWd9YwmDkTVySqjr+CUvMklNED0sDGyqXQcIlp/ZOF9uhUVH BbgKRMr3y2gOKraDpLjTyCbWJTdMaHbmIILwEXntVcDPF1KCfjPN+Ly175qn8MsKx/6R XnP6+7auZXF4K3pI7v9MIPr3ty0cMf83aDxh8WoORH7iJxK9Yd5xdznPYofw6YRYiBna 6WXe6JKoPqJei6eDFVNV5KOZjf9Gn2NRdGDtHhiI2ufDSChMTFnp7E0VQXDnTk4CPoFI nSDnQkySNWwkTIrOWsaTfzim+qGfkx3YD6LkF7ZE4qBbHuOlDEpHxOulJyXEDyv5earC LvdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kzS9LrpG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q5-20020a50cc85000000b0046402025290si13988881edi.387.2022.11.09.06.23.10; Wed, 09 Nov 2022 06:23:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kzS9LrpG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231300AbiKIOWG (ORCPT + 99 others); Wed, 9 Nov 2022 09:22:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231461AbiKIOVQ (ORCPT ); Wed, 9 Nov 2022 09:21:16 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AE9923EBB; Wed, 9 Nov 2022 06:20:18 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 6BD6BFF816; Wed, 9 Nov 2022 14:20:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003616; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hf+ndFwOk7J0RzX3PZJg+38Xr2MdPQZz58Tt3uS2qMk=; b=kzS9LrpGkpAq+LZGFg4saIWfSv6XDggJoiqAPWCDc4SBe3YQmRxAlahvbfXm9j8l8o62YI f1wXO5JRU8JYnmTX4Zuid5sUWIiXycwGbmlZYbiw3ZNFBOkLpEQKO6bbVYEZpBYoPvGjT/ jpyRmhxuS8jEQDQh24cjaDBgoTuJaETbbwqsMgCZRUFrkLL/wkMu4ZLkLRpB7mgq9Ih0r4 3DoeWg8qibyfA8YdGOAPiLLf57Vd8CDeMssaQIFIWNWYU4U06PcVeknoYzWeZdkgXj3iK5 vgc6UMhBXv2wK2VNqqFlqhvTSYqw53e5dwkacAnoCtR0WdKx5l902yuCGokzGQ== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 22/23] staging: media: tegra-video: add support for VIP (parallel video input) Date: Wed, 9 Nov 2022 15:18:51 +0100 Message-Id: <20221109141852.729246-23-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028769303415999?= X-GMAIL-MSGID: =?utf-8?q?1749028769303415999?= From: Luca Ceresoli The VI peripheral of Tegra supports capturing from MIPI CSI-2 or parallel video (called VIP in the docs). MIPI CSI-2 is already implemented. Add a VIP implementation. Signed-off-by: Luca Ceresoli --- MAINTAINERS | 1 + drivers/staging/media/tegra-video/Makefile | 1 + drivers/staging/media/tegra-video/vip.c | 298 +++++++++++++++++++++ drivers/staging/media/tegra-video/vip.h | 72 +++++ 4 files changed, 372 insertions(+) create mode 100644 drivers/staging/media/tegra-video/vip.c create mode 100644 drivers/staging/media/tegra-video/vip.h diff --git a/MAINTAINERS b/MAINTAINERS index 0a4f66a32e45..9d3ba90967db 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20286,6 +20286,7 @@ L: linux-tegra@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml +F: drivers/staging/media/tegra-video/vip.* TEGRA XUSB PADCTL DRIVER M: JC Kuo diff --git a/drivers/staging/media/tegra-video/Makefile b/drivers/staging/media/tegra-video/Makefile index dfa2ef8f99ef..3c8ec1bb1f3e 100644 --- a/drivers/staging/media/tegra-video/Makefile +++ b/drivers/staging/media/tegra-video/Makefile @@ -2,6 +2,7 @@ tegra-video-objs := \ video.o \ vi.o \ + vip.o \ csi.o tegra-video-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o diff --git a/drivers/staging/media/tegra-video/vip.c b/drivers/staging/media/tegra-video/vip.c new file mode 100644 index 000000000000..cbf0c36fb098 --- /dev/null +++ b/drivers/staging/media/tegra-video/vip.c @@ -0,0 +1,298 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Parallel video capture module (VIP) for the Tegra VI. + * + * This file implements the VIP-specific infrastructure. + * + * Copyright (C) 2022 SKIDATA GmbH + * Author: Luca Ceresoli + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "vip.h" + +static inline struct tegra_vip *host1x_client_to_vip(struct host1x_client *client) +{ + return container_of(client, struct tegra_vip, client); +} + +static inline struct tegra_vip_channel *subdev_to_vip_channel(struct v4l2_subdev *subdev) +{ + return container_of(subdev, struct tegra_vip_channel, subdev); +} + +static inline struct tegra_vip *vip_channel_to_vip(struct tegra_vip_channel *chan) +{ + return container_of(chan, struct tegra_vip, chan); +} + +/* Find the previous subdev in the pipeline (i.e. the one connected to our sink pad) */ +static struct v4l2_subdev *tegra_vip_channel_get_prev_subdev(struct tegra_vip_channel *chan) +{ + struct media_pad *remote_pad; + + remote_pad = media_pad_remote_pad_first(&chan->pads[TEGRA_VIP_PAD_SINK]); + if (!remote_pad) + return NULL; + + return media_entity_to_v4l2_subdev(remote_pad->entity); +} + +static int tegra_vip_enable_stream(struct v4l2_subdev *subdev) +{ + struct tegra_vip_channel *vip_chan = subdev_to_vip_channel(subdev); + struct tegra_vip *vip = vip_channel_to_vip(vip_chan); + struct v4l2_subdev *prev_subdev = tegra_vip_channel_get_prev_subdev(vip_chan); + int err; + + err = pm_runtime_resume_and_get(vip->dev); + if (err) + return dev_err_probe(vip->dev, err, "failed to get runtime PM\n"); + + err = vip->soc->ops->vip_start_streaming(vip_chan); + if (err < 0) + goto err_start_streaming; + + err = v4l2_subdev_call(prev_subdev, video, s_stream, true); + if (err < 0 && err != -ENOIOCTLCMD) + goto err_prev_subdev_start_stream; + + return 0; + +err_prev_subdev_start_stream: +err_start_streaming: + pm_runtime_put(vip->dev); + return err; +} + +static int tegra_vip_disable_stream(struct v4l2_subdev *subdev) +{ + struct tegra_vip_channel *vip_chan = subdev_to_vip_channel(subdev); + struct tegra_vip *vip = vip_channel_to_vip(vip_chan); + struct v4l2_subdev *prev_subdev = tegra_vip_channel_get_prev_subdev(vip_chan); + + v4l2_subdev_call(prev_subdev, video, s_stream, false); + + pm_runtime_put(vip->dev); + + return 0; +} + +static int tegra_vip_s_stream(struct v4l2_subdev *subdev, int enable) +{ + int err; + + if (enable) + err = tegra_vip_enable_stream(subdev); + else + err = tegra_vip_disable_stream(subdev); + + return err; +} + +static const struct v4l2_subdev_video_ops tegra_vip_video_ops = { + .s_stream = tegra_vip_s_stream, +}; + +static const struct v4l2_subdev_ops tegra_vip_ops = { + .video = &tegra_vip_video_ops, +}; + +static int tegra_vip_channel_of_parse(struct tegra_vip *vip) +{ + struct device *dev = vip->dev; + struct device_node *node; + struct v4l2_fwnode_endpoint v4l2_ep = { + .bus_type = V4L2_MBUS_PARALLEL + }; + struct fwnode_handle *fwh; + struct device_node *ep; + unsigned int portno, num_pads; + int err; + + node = of_get_child_by_name(dev->of_node, "channel"); + + err = of_property_read_u32(node, "reg", &portno); + if (err < 0) { + dev_err_probe(dev, err, "%pOF: error reading reg property\n", node); + goto err_node_put; + } + + if (portno != 0) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: invalid reg property\n", node); + goto err_node_put; + } + + ep = of_graph_get_endpoint_by_regs(node, 0, 0); + if (!ep) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: error getting endpoint node\n", node); + goto err_node_put; + } + + fwh = of_fwnode_handle(ep); + err = v4l2_fwnode_endpoint_parse(fwh, &v4l2_ep); + of_node_put(ep); + if (err) { + dev_err_probe(dev, err, "%pOF: failed to parse v4l2 endpoint\n", node); + goto err_node_put; + } + + num_pads = of_graph_get_endpoint_count(node); + if (num_pads != TEGRA_VIP_PADS_NUM) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: need 2 pads, got %d\n", node, num_pads); + goto err_node_put; + } + + vip->chan.of_node = of_node_get(node); + vip->chan.pads[TEGRA_VIP_PAD_SINK].flags = MEDIA_PAD_FL_SINK; + vip->chan.pads[TEGRA_VIP_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; + + return 0; + +err_node_put: + of_node_put(node); + return err; +} + +static int tegra_vip_channel_init(struct tegra_vip *vip) +{ + struct v4l2_subdev *subdev; + int err; + + subdev = &vip->chan.subdev; + v4l2_subdev_init(subdev, &tegra_vip_ops); + subdev->dev = vip->dev; + snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "%s", + kbasename(vip->chan.of_node->full_name)); + + v4l2_set_subdevdata(subdev, &vip->chan); + subdev->fwnode = of_fwnode_handle(vip->chan.of_node); + subdev->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; + + err = media_entity_pads_init(&subdev->entity, TEGRA_VIP_PADS_NUM, vip->chan.pads); + if (err) + return dev_err_probe(vip->dev, err, "failed to initialize media entity\n"); + + err = v4l2_async_register_subdev(subdev); + if (err) { + dev_err_probe(vip->dev, err, "failed to register subdev\n"); + goto err_register_subdev; + } + + return 0; + +err_register_subdev: + media_entity_cleanup(&subdev->entity); + return err; +} + +static int tegra_vip_init(struct host1x_client *client) +{ + struct tegra_vip *vip = host1x_client_to_vip(client); + int err; + + err = tegra_vip_channel_of_parse(vip); + if (err) + return err; + + err = tegra_vip_channel_init(vip); + if (err) + goto err_init; + + return 0; + +err_init: + of_node_put(vip->chan.of_node); + return err; +} + +static int tegra_vip_exit(struct host1x_client *client) +{ + struct tegra_vip *vip = host1x_client_to_vip(client); + struct v4l2_subdev *subdev = &vip->chan.subdev; + + v4l2_async_unregister_subdev(subdev); + media_entity_cleanup(&subdev->entity); + of_node_put(vip->chan.of_node); + + return 0; +} + +static const struct host1x_client_ops vip_client_ops = { + .init = tegra_vip_init, + .exit = tegra_vip_exit, +}; + +static int tegra_vip_probe(struct platform_device *pdev) +{ + struct tegra_vip *vip; + int err; + + dev_dbg(&pdev->dev, "Probing VIP \"%s\" from %pOF\n", pdev->name, pdev->dev.of_node); + + vip = devm_kzalloc(&pdev->dev, sizeof(*vip), GFP_KERNEL); + if (!vip) + return -ENOMEM; + + vip->soc = of_device_get_match_data(&pdev->dev); + + vip->dev = &pdev->dev; + platform_set_drvdata(pdev, vip); + + /* initialize host1x interface */ + INIT_LIST_HEAD(&vip->client.list); + vip->client.ops = &vip_client_ops; + vip->client.dev = &pdev->dev; + + err = host1x_client_register(&vip->client); + if (err) + return dev_err_probe(&pdev->dev, err, "failed to register host1x client\n"); + + pm_runtime_enable(&pdev->dev); + + return 0; +} + +static int tegra_vip_remove(struct platform_device *pdev) +{ + struct tegra_vip *vip = platform_get_drvdata(pdev); + int err; + + err = host1x_client_unregister(&vip->client); + if (err) + return dev_err_probe(&pdev->dev, err, "failed to unregister host1x client\n"); + + pm_runtime_disable(&pdev->dev); + + return 0; +} + +static const struct of_device_id tegra_vip_of_id_table[] = { +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-vip", .data = &tegra20_vip_soc }, +#endif + { } +}; +MODULE_DEVICE_TABLE(of, tegra_vip_of_id_table); + +struct platform_driver tegra_vip_driver = { + .driver = { + .name = "tegra-vip", + .of_match_table = tegra_vip_of_id_table, + }, + .probe = tegra_vip_probe, + .remove = tegra_vip_remove, +}; diff --git a/drivers/staging/media/tegra-video/vip.h b/drivers/staging/media/tegra-video/vip.h new file mode 100644 index 000000000000..58b3ec28c364 --- /dev/null +++ b/drivers/staging/media/tegra-video/vip.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2022 SKIDATA GmbH + * Author: Luca Ceresoli + */ + +#ifndef __TEGRA_VIP_H__ +#define __TEGRA_VIP_H__ + +#include +#include +#include + +enum { + TEGRA_VIP_PAD_SINK, + TEGRA_VIP_PAD_SOURCE, + TEGRA_VIP_PADS_NUM, +}; + +struct tegra_vip; + +/** + * struct tegra_vip_channel - Tegra VIP (parallel video capture) channel + * + * @subdev: V4L2 subdevice associated with this channel + * @pads: media pads for the subdevice entity + * @of_node: vip device tree node + */ +struct tegra_vip_channel { + struct v4l2_subdev subdev; + struct media_pad pads[TEGRA_VIP_PADS_NUM]; + struct device_node *of_node; +}; + +/** + * struct tegra_vip_ops - Tegra VIP operations + * + * @vip_start_streaming: programs vip hardware to enable streaming. + */ +struct tegra_vip_ops { + int (*vip_start_streaming)(struct tegra_vip_channel *vip_chan); +}; + +/** + * struct tegra_vip_soc - NVIDIA Tegra VIP SoC structure + * + * @ops: vip hardware operations + */ +struct tegra_vip_soc { + const struct tegra_vip_ops *ops; +}; + +/** + * struct tegra_vip - NVIDIA Tegra VIP device structure + * + * @dev: device struct + * @client: host1x_client struct + * @soc: pointer to SoC data structure + * @chan: the VIP channel + */ +struct tegra_vip { + struct device *dev; + struct host1x_client client; + const struct tegra_vip_soc *soc; + struct tegra_vip_channel chan; +}; + +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) +extern const struct tegra_vip_soc tegra20_vip_soc; +#endif + +#endif From patchwork Wed Nov 9 14:18:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 17596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp361817wru; Wed, 9 Nov 2022 06:23:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5xMkWJFxocxkdqqi7MeJDqRJ1Cw0a2Asl84lC111SU5XmPIahjnEgcifQNAeDXgYip1GzZ X-Received: by 2002:a50:fe96:0:b0:466:8766:7e7d with SMTP id d22-20020a50fe96000000b0046687667e7dmr11706216edt.427.1668003820104; Wed, 09 Nov 2022 06:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668003820; cv=none; d=google.com; s=arc-20160816; b=nbfD60tHWKI3WSwD4aFyji+W2OCwtSjDJtFLsN4i1z+qBi2zBoZcdvpN4LBImHoggr WBxhl0aavPCAFS52oDWeNXQAKE/h/r0dJYezrV/1Ck2EXWs7jgwYFpnT9nVj/6NLlK8B DLmoAVjcOpRpNnb9Hlnn8meA4+Ri+xoolLDF+9VjFckHFmq+rnF4aRbhbKSHDE6IyR36 rQVeEVy3XIIrPkZZQz2qc9qBEltVQx6aJOdSkOO2hhI2I1rA8h3sdJhqPtSivUgA+hJj EWtVHjHRUyZLABaKC4iFl0J4Z7xFiF7IR7lPBYMMaVqL8vwNFq4boLaKEHboJfgwBEw9 tBvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XOLUMSs/zi0Wvfd8Aq4qDZOrpQuHUD6DmK7SPod4pTE=; b=Lq20Kpwe7RP4LDWo/Tzuedxhq/iuPoP9oRcWaRTmaitTs/7uZ+kPG0aPmZZCK/h6ui te33gXJ9W3NwW46I7FGVswD6nsnKUKqNMonVFdS21f4ZDNvnWJxHz6TFo0999Zl+f1Iw cG3CNOwxtE88QHjTEOq9q4wtyi5z/exWgNbg8jtLeOVpGvS5YhlyaK+p444W6iIXD3gv cj5ZgSe1Jich3IFlOITCt1k5p7B4/1CqThDO2MoKWuCGVY0ymoaZwCfnZYuU3yu3txNx s0mnawMPWzCrYvO66qy0WFg3Nbt4U66FcQCxSuwHq4PF42Zcx9cle/GYAFRT3xwAeYE0 Ex+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NX3svI3q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd27-20020a170907629b00b007ae30b550e5si4142035ejc.854.2022.11.09.06.23.15; Wed, 09 Nov 2022 06:23:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NX3svI3q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231481AbiKIOWJ (ORCPT + 99 others); Wed, 9 Nov 2022 09:22:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231362AbiKIOVV (ORCPT ); Wed, 9 Nov 2022 09:21:21 -0500 X-Greylist: delayed 64 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 09 Nov 2022 06:20:21 PST Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5499D21801; Wed, 9 Nov 2022 06:20:20 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 253C2FF80D; Wed, 9 Nov 2022 14:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1668003619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XOLUMSs/zi0Wvfd8Aq4qDZOrpQuHUD6DmK7SPod4pTE=; b=NX3svI3qKXSOHndNVJhsZp1OCReiF+Psjgg1DNja98C/Za1BKRgoS0P37ctC+xDUZCKntD iUMaTn7lJUxqtZnc6k4FYE5tMHhp72YONSRphQTlHOUubWm5AfSLBLzA3EioXhmGAkhDg4 U/gcjmQJd0DDghOTqaaMYNejven2PTYRu6tn+Gis6Qd7gfIVFBbjJNE4IbL7F/YRmg80mZ KMrp1mTiU7UQ5JqwLA+Dwr3q9IRDSG3CeH4jRMG0IJ6hpUmZy1mUHq/BbFWvo2EeD8+efL gxVAQ6RAtX8SziKz4Ip43G6/RvxHQ2FX9zNNdhe/njsghi4dKrxVShirJKAOqw== From: luca.ceresoli@bootlin.com To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Dmitry Osipenko Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Richard Leitner Subject: [PATCH 23/23] staging: media: tegra-video: add tegra20 variant Date: Wed, 9 Nov 2022 15:18:52 +0100 Message-Id: <20221109141852.729246-24-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109141852.729246-1-luca.ceresoli@bootlin.com> References: <20221109141852.729246-1-luca.ceresoli@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749028773816677261?= X-GMAIL-MSGID: =?utf-8?q?1749028773816677261?= From: Luca Ceresoli The staging tegra-video driver currently implements MIPI CSI-2 video capture for Tegra210. Add support for parallel video capture (VIP) on Tegra20. With the generalizations added to the VI driver in previous commits, this is only a matter of adding the tegra20.c implementation and registering it. Unfortunately there was no documentation available for the VI or VIP peripherals of Tegra20 (or any other Tegra chips). This implementation has been based entirely on the code from a vendor kernel based on Linux 3.1 and massively adapted to fit into the tegra-video driver. Parts of this code is definitely non-optimal to say the least (especially tegra20_vi_enable() and the single-frame capture logic), but it was impossible to improve it. Signed-off-by: Luca Ceresoli --- MAINTAINERS | 1 + drivers/staging/media/tegra-video/Makefile | 1 + drivers/staging/media/tegra-video/tegra20.c | 649 ++++++++++++++++++++ drivers/staging/media/tegra-video/vi.c | 3 + drivers/staging/media/tegra-video/vi.h | 3 + drivers/staging/media/tegra-video/video.c | 5 + drivers/staging/media/tegra-video/video.h | 1 + 7 files changed, 663 insertions(+) create mode 100644 drivers/staging/media/tegra-video/tegra20.c diff --git a/MAINTAINERS b/MAINTAINERS index 9d3ba90967db..aacc3b4e1a5c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20286,6 +20286,7 @@ L: linux-tegra@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml +F: drivers/staging/media/tegra-video/tegra20.c F: drivers/staging/media/tegra-video/vip.* TEGRA XUSB PADCTL DRIVER diff --git a/drivers/staging/media/tegra-video/Makefile b/drivers/staging/media/tegra-video/Makefile index 3c8ec1bb1f3e..6c7552e05109 100644 --- a/drivers/staging/media/tegra-video/Makefile +++ b/drivers/staging/media/tegra-video/Makefile @@ -5,5 +5,6 @@ tegra-video-objs := \ vip.o \ csi.o +tegra-video-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20.o tegra-video-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o obj-$(CONFIG_VIDEO_TEGRA) += tegra-video.o diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c new file mode 100644 index 000000000000..4b2eecc3014f --- /dev/null +++ b/drivers/staging/media/tegra-video/tegra20.c @@ -0,0 +1,649 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Tegra20-specific VI implementation + * + * Copyright (C) 2022 SKIDATA GmbH + * Author: Luca Ceresoli + */ + +/* + * This source file contains Tegra20 supported video formats, + * VI and VIP SoC specific data, operations and registers accessors. + */ + +#include +#include +#include +#include +#include + +#include "vip.h" +#include "vi.h" + +#define TEGRA_VI_SYNCPT_WAIT_TIMEOUT msecs_to_jiffies(200) + +/* -------------------------------------------------------------------------- + * Registers + */ + +#define TEGRA_VI_CONT_SYNCPT_OUT_1 0x0060 +#define VI_CONT_SYNCPT_OUT_1_CONTINUOUS_SYNCPT BIT(8) +#define VI_CONT_SYNCPT_OUT_1_SYNCPT_IDX_SFT 0 + +#define TEGRA_VI_VI_INPUT_CONTROL 0x0088 +#define VI_INPUT_FIELD_DETECT BIT(27) +#define VI_INPUT_BT656 BIT(25) +#define VI_INPUT_YUV_INPUT_FORMAT_SFT 8 /* bits [9:8] */ +#define VI_INPUT_YUV_INPUT_FORMAT_UYVY (0 << VI_INPUT_YUV_INPUT_FORMAT_SFT) +#define VI_INPUT_YUV_INPUT_FORMAT_VYUY (1 << VI_INPUT_YUV_INPUT_FORMAT_SFT) +#define VI_INPUT_YUV_INPUT_FORMAT_YUYV (2 << VI_INPUT_YUV_INPUT_FORMAT_SFT) +#define VI_INPUT_YUV_INPUT_FORMAT_YVYU (3 << VI_INPUT_YUV_INPUT_FORMAT_SFT) +#define VI_INPUT_INPUT_FORMAT_SFT 2 /* bits [5:2] */ +#define VI_INPUT_INPUT_FORMAT_YUV422 (0 << VI_INPUT_INPUT_FORMAT_SFT) +#define VI_INPUT_VIP_INPUT_ENABLE BIT(1) + +#define TEGRA_VI_VI_CORE_CONTROL 0x008c +#define VI_VI_CORE_CONTROL_PLANAR_CONV_IN_SEL_EXT BIT(31) +#define VI_VI_CORE_CONTROL_CSC_INPUT_SEL_EXT BIT(30) +#define VI_VI_CORE_CONTROL_INPUT_TO_ALT_MUX_SFT 27 +#define VI_VI_CORE_CONTROL_INPUT_TO_CORE_EXT_SFT 24 +#define VI_VI_CORE_CONTROL_OUTPUT_TO_ISP_EXT_SFT 21 +#define VI_VI_CORE_CONTROL_ISP_HOST_STALL_OFF BIT(20) +#define VI_VI_CORE_CONTROL_V_DOWNSCALING BIT(19) +#define VI_VI_CORE_CONTROL_V_AVERAGING BIT(18) +#define VI_VI_CORE_CONTROL_H_DOWNSCALING BIT(17) +#define VI_VI_CORE_CONTROL_H_AVERAGING BIT(16) +#define VI_VI_CORE_CONTROL_CSC_INPUT_SEL BIT(11) +#define VI_VI_CORE_CONTROL_PLANAR_CONV_INPUT_SEL BIT(10) +#define VI_VI_CORE_CONTROL_INPUT_TO_CORE_SFT 8 +#define VI_VI_CORE_CONTROL_ISP_DOWNSAMPLE_SFT 5 +#define VI_VI_CORE_CONTROL_OUTPUT_TO_EPP_SFT 2 +#define VI_VI_CORE_CONTROL_OUTPUT_TO_ISP_SFT 0 + +#define TEGRA_VI_VI_FIRST_OUTPUT_CONTROL 0x0090 +#define VI_OUTPUT_FORMAT_EXT BIT(22) +#define VI_OUTPUT_V_DIRECTION BIT(20) +#define VI_OUTPUT_H_DIRECTION BIT(19) +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT 17 +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_UYVY (0 << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_VYUY (1 << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_YUYV (2 << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_YVYU (3 << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_OUTPUT_BYTE_SWAP BIT(16) +#define VI_OUTPUT_LAST_PIXEL_DUPLICATION BIT(8) +#define VI_OUTPUT_OUTPUT_FORMAT_SFT 0 +#define VI_OUTPUT_OUTPUT_FORMAT_YUV422POST (3 << VI_OUTPUT_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_OUTPUT_FORMAT_YUV420PLANAR (6 << VI_OUTPUT_OUTPUT_FORMAT_SFT) + +#define TEGRA_VI_VIP_H_ACTIVE 0x00a4 +#define VI_VIP_H_ACTIVE_PERIOD_SFT 16 /* active pixels/line, must be even */ +#define VI_VIP_H_ACTIVE_START_SFT 0 + +#define TEGRA_VI_VIP_V_ACTIVE 0x00a8 +#define VI_VIP_V_ACTIVE_PERIOD_SFT 16 /* active lines */ +#define VI_VIP_V_ACTIVE_START_SFT 0 + +#define TEGRA_VI_VB0_START_ADDRESS_FIRST 0x00c4 +#define TEGRA_VI_VB0_BASE_ADDRESS_FIRST 0x00c8 +#define TEGRA_VI_VB0_START_ADDRESS_U 0x00cc +#define TEGRA_VI_VB0_BASE_ADDRESS_U 0x00d0 +#define TEGRA_VI_VB0_START_ADDRESS_V 0x00d4 +#define TEGRA_VI_VB0_BASE_ADDRESS_V 0x00d8 + +#define TEGRA_VI_FIRST_OUTPUT_FRAME_SIZE 0x00e0 +#define VI_FIRST_OUTPUT_FRAME_HEIGHT_SFT 16 +#define VI_FIRST_OUTPUT_FRAME_WIDTH_SFT 0 + +#define TEGRA_VI_VB0_COUNT_FIRST 0x00e4 + +#define TEGRA_VI_VB0_SIZE_FIRST 0x00e8 +#define VI_VB0_SIZE_FIRST_V_SFT 16 +#define VI_VB0_SIZE_FIRST_H_SFT 0 + +#define TEGRA_VI_VB0_BUFFER_STRIDE_FIRST 0x00ec +#define VI_VB0_BUFFER_STRIDE_FIRST_CHROMA_SFT 30 +#define VI_VB0_BUFFER_STRIDE_FIRST_LUMA_SFT 0 + +#define TEGRA_VI_H_LPF_CONTROL 0x0108 +#define VI_H_LPF_CONTROL_CHROMA_SFT 16 +#define VI_H_LPF_CONTROL_LUMA_SFT 0 + +#define TEGRA_VI_H_DOWNSCALE_CONTROL 0x010c +#define TEGRA_VI_V_DOWNSCALE_CONTROL 0x0110 + +#define TEGRA_VI_VIP_INPUT_STATUS 0x0144 + +#define TEGRA_VI_VI_DATA_INPUT_CONTROL 0x0168 +#define VI_DATA_INPUT_SFT 0 /* [11:0] = mask pin inputs to VI core */ + +#define TEGRA_VI_PIN_INPUT_ENABLE 0x016c +#define VI_PIN_INPUT_VSYNC BIT(14) +#define VI_PIN_INPUT_HSYNC BIT(13) +#define VI_PIN_INPUT_VD_SFT 0 /* [11:0] = data bin N input enable */ + +#define TEGRA_VI_PIN_INVERSION 0x0174 +#define VI_PIN_INVERSION_VSYNC_ACTIVE_HIGH BIT(1) +#define VI_PIN_INVERSION_HSYNC_ACTIVE_HIGH BIT(0) + +#define TEGRA_VI_CAMERA_CONTROL 0x01a0 +#define VI_CAMERA_CONTROL_STOP_CAPTURE BIT(2) +#define VI_CAMERA_CONTROL_TEST_MODE BIT(1) +#define VI_CAMERA_CONTROL_VIP_ENABLE BIT(0) + +#define TEGRA_VI_VI_ENABLE 0x01a4 +#define VI_VI_ENABLE_SW_FLOW_CONTROL_OUT1 BIT(1) +#define VI_VI_ENABLE_FIRST_OUTPUT_TO_MEM_DISABLE BIT(0) + +#define TEGRA_VI_VI_RAISE 0x01ac +#define VI_VI_RAISE_ON_EDGE BIT(0) + +/* -------------------------------------------------------------------------- + * VI + */ + +static void tegra20_vi_write(struct tegra_vi_channel *chan, unsigned int addr, u32 val) +{ + writel(val, chan->vi->iomem + addr); +} + +/* + * Get the main input format (YUV/RGB...) and the YUV variant as values to + * be written into registers for the current VI input mbus code. + */ +static void tegra20_vi_get_input_formats(struct tegra_vi_channel *chan, + unsigned int *main_input_format, + unsigned int *yuv_input_format) +{ + unsigned int input_mbus_code = chan->fmtinfo->code; + + (*main_input_format) = VI_INPUT_INPUT_FORMAT_YUV422; + + switch (input_mbus_code) { + case MEDIA_BUS_FMT_UYVY8_2X8: + (*yuv_input_format) = VI_INPUT_YUV_INPUT_FORMAT_UYVY; + break; + case MEDIA_BUS_FMT_VYUY8_2X8: + (*yuv_input_format) = VI_INPUT_YUV_INPUT_FORMAT_VYUY; + break; + case MEDIA_BUS_FMT_YUYV8_2X8: + (*yuv_input_format) = VI_INPUT_YUV_INPUT_FORMAT_YUYV; + break; + case MEDIA_BUS_FMT_YVYU8_2X8: + (*yuv_input_format) = VI_INPUT_YUV_INPUT_FORMAT_YVYU; + break; + } +} + +/* + * Get the main output format (YUV/RGB...) and the YUV variant as values to + * be written into registers for the current VI output pixel format. + */ +static void tegra20_vi_get_output_formats(struct tegra_vi_channel *chan, + unsigned int *main_output_format, + unsigned int *yuv_output_format) +{ + u32 output_fourcc = chan->format.pixelformat; + + /* Default to YUV422 non-planar (U8Y8V8Y8) after downscaling */ + (*main_output_format) = VI_OUTPUT_OUTPUT_FORMAT_YUV422POST; + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_UYVY; + + switch (output_fourcc) { + case V4L2_PIX_FMT_UYVY: + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_UYVY; + break; + case V4L2_PIX_FMT_VYUY: + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_VYUY; + break; + case V4L2_PIX_FMT_YUYV: + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_YUYV; + break; + case V4L2_PIX_FMT_YVYU: + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_YVYU; + break; + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + (*main_output_format) = VI_OUTPUT_OUTPUT_FORMAT_YUV420PLANAR; + break; + } +} + +/* + * Make the VI to be accessible (needed on Tegra20). + * + * This function writes an unknown bit into an unknown register. The code + * comes from a downstream 3.1 kernel that has a working VIP driver for + * Tegra20, and removing it makes the VI completely unaccessible. It should + * be rewritten and possibly moved elsewhere, but the appropriate location + * and implementation is unknown due to a total lack of documentation. + */ +static int tegra20_vi_enable(struct tegra_vi *vi, bool on) +{ + /* from arch/arm/mach-tegra/iomap.h */ + const phys_addr_t TEGRA_APB_MISC_BASE = 0x70000000; + const unsigned long reg_offset = 0x42c; + void __iomem *apb_misc; + u32 val; + + apb_misc = ioremap(TEGRA_APB_MISC_BASE, PAGE_SIZE); + if (!apb_misc) + apb_misc = ERR_PTR(-ENOENT); + if (IS_ERR(apb_misc)) + return dev_err_probe(vi->dev, PTR_ERR(apb_misc), "cannot access APB_MISC"); + + val = readl(apb_misc + reg_offset); + writel(val | (!!on), apb_misc + reg_offset); + iounmap(apb_misc); + + return 0; +} + +static int tegra20_channel_host1x_syncpt_init(struct tegra_vi_channel *chan) +{ + struct tegra_vi *vi = chan->vi; + struct host1x_syncpt *out_sp; + + out_sp = host1x_syncpt_request(&vi->client, HOST1X_SYNCPT_CLIENT_MANAGED); + if (!out_sp) + return dev_err_probe(vi->dev, -ENOMEM, "failed to request syncpoint\n"); + + chan->out_sp = out_sp; + + return 0; +} + +static void tegra20_channel_host1x_syncpt_free(struct tegra_vi_channel *chan) +{ + host1x_syncpt_put(chan->out_sp); +} + +static void tegra20_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp) +{ + switch (pix->pixelformat) { + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_YVYU: + pix->bytesperline = roundup(pix->width, 2) * 2; + pix->sizeimage = roundup(pix->width, 2) * 2 * pix->height; + break; + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + pix->bytesperline = roundup(pix->width, 8); + pix->sizeimage = roundup(pix->width, 8) * pix->height * 3 / 2; + break; + } +} + +/* + * Compute buffer offsets once per stream so that + * tegra20_channel_vi_buffer_setup() only has to do very simple maths for + * each buffer. + */ +static void tegra20_channel_queue_setup(struct tegra_vi_channel *chan) +{ + unsigned int stride = chan->format.bytesperline; + unsigned int height = chan->format.height; + + chan->start_offset = 0; + + switch (chan->format.pixelformat) { + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_YVYU: + if (chan->vflip) + chan->start_offset += stride * (height - 1); + if (chan->hflip) + chan->start_offset += stride - 1; + break; + + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + chan->addr_offset_u = stride * height; + chan->addr_offset_v = chan->addr_offset_u + stride * height / 4; + + /* For YVU420, we swap the locations of the U and V planes. */ + if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420) { + unsigned long temp; + + temp = chan->addr_offset_u; + chan->addr_offset_u = chan->addr_offset_v; + chan->addr_offset_v = temp; + } + + chan->start_offset_u = chan->addr_offset_u; + chan->start_offset_v = chan->addr_offset_v; + + if (chan->vflip) { + chan->start_offset += stride * (height - 1); + chan->start_offset_u += (stride / 2) * ((height / 2) - 1); + chan->start_offset_v += (stride / 2) * ((height / 2) - 1); + } + if (chan->hflip) { + chan->start_offset += stride - 1; + chan->start_offset_u += (stride / 2) - 1; + chan->start_offset_v += (stride / 2) - 1; + } + break; + } +} + +static void release_buffer(struct tegra_vi_channel *chan, + struct tegra_channel_buffer *buf, + enum vb2_buffer_state state) +{ + struct vb2_v4l2_buffer *vb = &buf->buf; + + vb->sequence = chan->sequence++; + vb->field = V4L2_FIELD_NONE; + vb->vb2_buf.timestamp = ktime_get_ns(); + vb2_buffer_done(&vb->vb2_buf, state); +} + +static void tegra20_channel_vi_buffer_setup(struct tegra_vi_channel *chan, + struct tegra_channel_buffer *buf) +{ + dma_addr_t base = buf->addr; + + switch (chan->fmtinfo->fourcc) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + tegra20_vi_write(chan, TEGRA_VI_VB0_BASE_ADDRESS_U, base + chan->addr_offset_u); + tegra20_vi_write(chan, TEGRA_VI_VB0_START_ADDRESS_U, base + chan->start_offset_u); + tegra20_vi_write(chan, TEGRA_VI_VB0_BASE_ADDRESS_V, base + chan->addr_offset_v); + tegra20_vi_write(chan, TEGRA_VI_VB0_START_ADDRESS_V, base + chan->start_offset_v); + fallthrough; + + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_YVYU: + tegra20_vi_write(chan, TEGRA_VI_VB0_BASE_ADDRESS_FIRST, base); + tegra20_vi_write(chan, TEGRA_VI_VB0_START_ADDRESS_FIRST, base + chan->start_offset); + break; + } +} + +static int tegra20_channel_capture_frame(struct tegra_vi_channel *chan, + struct tegra_channel_buffer *buf) +{ + u32 value; + int err; + + chan->next_out_sp_idx++; + + tegra20_channel_vi_buffer_setup(chan, buf); + + tegra20_vi_write(chan, TEGRA_VI_CAMERA_CONTROL, VI_CAMERA_CONTROL_VIP_ENABLE); + + /* Wait for syncpt counter to reach frame start event threshold */ + err = host1x_syncpt_wait(chan->out_sp, chan->next_out_sp_idx, + TEGRA_VI_SYNCPT_WAIT_TIMEOUT, &value); + if (err) { + host1x_syncpt_incr(chan->out_sp); + dev_err_ratelimited(&chan->video.dev, "frame start syncpt timeout: %d\n", err); + release_buffer(chan, buf, VB2_BUF_STATE_ERROR); + return err; + } + + tegra20_vi_write(chan, TEGRA_VI_CAMERA_CONTROL, + VI_CAMERA_CONTROL_STOP_CAPTURE | VI_CAMERA_CONTROL_VIP_ENABLE); + + release_buffer(chan, buf, VB2_BUF_STATE_DONE); + + return 0; +} + +static int tegra20_chan_capture_kthread_start(void *data) +{ + struct tegra_vi_channel *chan = data; + struct tegra_channel_buffer *buf; + unsigned int retries = 0; + int err = 0; + + while (1) { + /* + * Source is not streaming if error is non-zero. + * So, do not dequeue buffers on error and let the thread sleep + * till kthread stop signal is received. + */ + wait_event_interruptible(chan->start_wait, + kthread_should_stop() || + (!list_empty(&chan->capture) && !err)); + + if (kthread_should_stop()) + break; + + /* dequeue the buffer and start capture */ + spin_lock(&chan->start_lock); + if (list_empty(&chan->capture)) { + spin_unlock(&chan->start_lock); + continue; + } + + buf = list_first_entry(&chan->capture, struct tegra_channel_buffer, queue); + list_del_init(&buf->queue); + spin_unlock(&chan->start_lock); + + err = tegra20_channel_capture_frame(chan, buf); + if (!err) { + retries = 0; + continue; + } + + if (retries++ > chan->syncpt_timeout_retry) + vb2_queue_error(&chan->queue); + else + err = 0; + } + + return 0; +} + +static void tegra20_camera_capture_setup(struct tegra_vi_channel *chan) +{ + u32 output_fourcc = chan->format.pixelformat; + int width = chan->format.width; + int height = chan->format.height; + int stride_l = chan->format.bytesperline; + int stride_c = (output_fourcc == V4L2_PIX_FMT_YUV420 || + output_fourcc == V4L2_PIX_FMT_YVU420) ? 1 : 0; + int main_output_format; + int yuv_output_format; + + tegra20_vi_get_output_formats(chan, &main_output_format, &yuv_output_format); + + /* + * Set up low pass filter. Use 0x240 for chromaticity and 0x240 + * for luminance, which is the default and means not to touch + * anything. + */ + tegra20_vi_write(chan, TEGRA_VI_H_LPF_CONTROL, + 0x0240 << VI_H_LPF_CONTROL_LUMA_SFT | + 0x0240 << VI_H_LPF_CONTROL_CHROMA_SFT); + + /* Set up raise-on-edge, so we get an interrupt on end of frame. */ + tegra20_vi_write(chan, TEGRA_VI_VI_RAISE, VI_VI_RAISE_ON_EDGE); + + tegra20_vi_write(chan, TEGRA_VI_VI_FIRST_OUTPUT_CONTROL, + (chan->vflip ? VI_OUTPUT_V_DIRECTION : 0) | + (chan->hflip ? VI_OUTPUT_H_DIRECTION : 0) | + yuv_output_format << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT | + main_output_format << VI_OUTPUT_OUTPUT_FORMAT_SFT); + + /* Set up frame size */ + tegra20_vi_write(chan, TEGRA_VI_FIRST_OUTPUT_FRAME_SIZE, + height << VI_FIRST_OUTPUT_FRAME_HEIGHT_SFT | + width << VI_FIRST_OUTPUT_FRAME_WIDTH_SFT); + + /* First output memory enabled */ + tegra20_vi_write(chan, TEGRA_VI_VI_ENABLE, 0); + + /* Set the number of frames in the buffer */ + tegra20_vi_write(chan, TEGRA_VI_VB0_COUNT_FIRST, 1); + + /* Set up buffer frame size */ + tegra20_vi_write(chan, TEGRA_VI_VB0_SIZE_FIRST, + height << VI_VB0_SIZE_FIRST_V_SFT | + width << VI_VB0_SIZE_FIRST_H_SFT); + + tegra20_vi_write(chan, TEGRA_VI_VB0_BUFFER_STRIDE_FIRST, + stride_l << VI_VB0_BUFFER_STRIDE_FIRST_LUMA_SFT | + stride_c << VI_VB0_BUFFER_STRIDE_FIRST_CHROMA_SFT); + + tegra20_vi_write(chan, TEGRA_VI_VI_ENABLE, 0); +} + +static int tegra20_vi_start_streaming(struct vb2_queue *vq, u32 count) +{ + struct tegra_vi_channel *chan = vb2_get_drv_priv(vq); + struct media_pipeline *pipe = &chan->video.pipe; + int err; + + chan->next_out_sp_idx = host1x_syncpt_read(chan->out_sp); + + err = video_device_pipeline_start(&chan->video, pipe); + if (err) + goto error_pipeline_start; + + tegra20_camera_capture_setup(chan); + + err = tegra_channel_set_stream(chan, true); + if (err) + goto error_set_stream; + + chan->sequence = 0; + + chan->kthread_start_capture = kthread_run(tegra20_chan_capture_kthread_start, + chan, "%s:0", chan->video.name); + if (IS_ERR(chan->kthread_start_capture)) { + err = PTR_ERR(chan->kthread_start_capture); + chan->kthread_start_capture = NULL; + dev_err_probe(&chan->video.dev, err, "failed to run capture kthread\n"); + goto error_kthread_start; + } + + return 0; + +error_kthread_start: + tegra_channel_set_stream(chan, false); +error_set_stream: + video_device_pipeline_stop(&chan->video); +error_pipeline_start: + tegra_channel_release_buffers(chan, VB2_BUF_STATE_QUEUED); + + return err; +} + +static void tegra20_vi_stop_streaming(struct vb2_queue *vq) +{ + struct tegra_vi_channel *chan = vb2_get_drv_priv(vq); + + if (chan->kthread_start_capture) { + kthread_stop(chan->kthread_start_capture); + chan->kthread_start_capture = NULL; + } + + tegra_channel_release_buffers(chan, VB2_BUF_STATE_ERROR); + tegra_channel_set_stream(chan, false); + video_device_pipeline_stop(&chan->video); +} + +static const struct tegra_vi_ops tegra20_vi_ops = { + .vi_enable = tegra20_vi_enable, + .channel_host1x_syncpt_init = tegra20_channel_host1x_syncpt_init, + .channel_host1x_syncpt_free = tegra20_channel_host1x_syncpt_free, + .vi_fmt_align = tegra20_fmt_align, + .channel_queue_setup = tegra20_channel_queue_setup, + .vi_start_streaming = tegra20_vi_start_streaming, + .vi_stop_streaming = tegra20_vi_stop_streaming, +}; + +#define TEGRA20_VIDEO_FMT(MBUS_CODE, BPP, FOURCC) \ +{ \ + .code = MEDIA_BUS_FMT_##MBUS_CODE, \ + .bpp = BPP, \ + .fourcc = V4L2_PIX_FMT_##FOURCC, \ +} + +static const struct tegra_video_format tegra20_video_formats[] = { + TEGRA20_VIDEO_FMT(UYVY8_2X8, 2, UYVY), + TEGRA20_VIDEO_FMT(VYUY8_2X8, 2, VYUY), + TEGRA20_VIDEO_FMT(YUYV8_2X8, 2, YUYV), + TEGRA20_VIDEO_FMT(YVYU8_2X8, 2, YVYU), + TEGRA20_VIDEO_FMT(UYVY8_2X8, 1, YUV420), + TEGRA20_VIDEO_FMT(UYVY8_2X8, 1, YVU420), +}; + +const struct tegra_vi_soc tegra20_vi_soc = { + .video_formats = tegra20_video_formats, + .nformats = ARRAY_SIZE(tegra20_video_formats), + .default_video_format = &tegra20_video_formats[0], + .ops = &tegra20_vi_ops, + .vi_max_channels = 1, /* parallel input (VIP) */ + .vi_max_clk_hz = 150000000, + .has_h_v_flip = true, +}; + +/* -------------------------------------------------------------------------- + * VIP + */ + +/* + * VIP-specific configuration for stream start. + * + * Whatever is common among VIP and CSI is done by the VI component (see + * tegra20_vi_start_streaming()). Here we do what is VIP-specific. + */ +static int tegra20_vip_start_streaming(struct tegra_vip_channel *vip_chan) +{ + struct tegra_vi_channel *vi_chan = v4l2_get_subdev_hostdata(&vip_chan->subdev); + int width = vi_chan->format.width; + int height = vi_chan->format.height; + + unsigned int main_input_format; + unsigned int yuv_input_format; + + tegra20_vi_get_input_formats(vi_chan, &main_input_format, &yuv_input_format); + + tegra20_vi_write(vi_chan, TEGRA_VI_VI_CORE_CONTROL, 0); + + tegra20_vi_write(vi_chan, TEGRA_VI_VI_INPUT_CONTROL, + VI_INPUT_VIP_INPUT_ENABLE | main_input_format | yuv_input_format); + + tegra20_vi_write(vi_chan, TEGRA_VI_V_DOWNSCALE_CONTROL, 0); + tegra20_vi_write(vi_chan, TEGRA_VI_H_DOWNSCALE_CONTROL, 0); + + tegra20_vi_write(vi_chan, TEGRA_VI_VIP_V_ACTIVE, height << VI_VIP_V_ACTIVE_PERIOD_SFT); + tegra20_vi_write(vi_chan, TEGRA_VI_VIP_H_ACTIVE, + roundup(width, 2) << VI_VIP_H_ACTIVE_PERIOD_SFT); + + /* + * For VIP, D9..D2 is mapped to the video decoder's P7..P0. + * Disable/mask out the other Dn wires. When not in BT656 + * mode we also need the V/H sync. + */ + tegra20_vi_write(vi_chan, TEGRA_VI_PIN_INPUT_ENABLE, + GENMASK(9, 2) << VI_PIN_INPUT_VD_SFT | + VI_PIN_INPUT_HSYNC | VI_PIN_INPUT_VSYNC); + tegra20_vi_write(vi_chan, TEGRA_VI_VI_DATA_INPUT_CONTROL, + GENMASK(9, 2) << VI_DATA_INPUT_SFT); + tegra20_vi_write(vi_chan, TEGRA_VI_PIN_INVERSION, 0); + + tegra20_vi_write(vi_chan, TEGRA_VI_CONT_SYNCPT_OUT_1, + VI_CONT_SYNCPT_OUT_1_CONTINUOUS_SYNCPT | + host1x_syncpt_id(vi_chan->out_sp) << VI_CONT_SYNCPT_OUT_1_SYNCPT_IDX_SFT); + + tegra20_vi_write(vi_chan, TEGRA_VI_CAMERA_CONTROL, VI_CAMERA_CONTROL_STOP_CAPTURE); + + return 0; +} + +static const struct tegra_vip_ops tegra20_vip_ops = { + .vip_start_streaming = tegra20_vip_start_streaming, +}; + +const struct tegra_vip_soc tegra20_vip_soc = { + .ops = &tegra20_vip_ops, +}; diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 0dbc3da6f98c..193ef948542a 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1862,6 +1862,9 @@ static int tegra_vi_remove(struct platform_device *pdev) } static const struct of_device_id tegra_vi_of_id_table[] = { +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-vi", .data = &tegra20_vi_soc }, +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC) { .compatible = "nvidia,tegra210-vi", .data = &tegra210_vi_soc }, #endif diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 7cb038957f1b..d11822c7b6ed 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -293,6 +293,9 @@ struct tegra_video_format { u32 fourcc; }; +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) +extern const struct tegra_vi_soc tegra20_vi_soc; +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC) extern const struct tegra_vi_soc tegra210_vi_soc; #endif diff --git a/drivers/staging/media/tegra-video/video.c b/drivers/staging/media/tegra-video/video.c index d966b319553f..074ad0dc56ca 100644 --- a/drivers/staging/media/tegra-video/video.c +++ b/drivers/staging/media/tegra-video/video.c @@ -123,6 +123,10 @@ static int host1x_video_remove(struct host1x_device *dev) } static const struct of_device_id host1x_video_subdevs[] = { +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-vip", }, + { .compatible = "nvidia,tegra20-vi", }, +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC) { .compatible = "nvidia,tegra210-csi", }, { .compatible = "nvidia,tegra210-vi", }, @@ -141,6 +145,7 @@ static struct host1x_driver host1x_video_driver = { static struct platform_driver * const drivers[] = { &tegra_csi_driver, + &tegra_vip_driver, &tegra_vi_driver, }; diff --git a/drivers/staging/media/tegra-video/video.h b/drivers/staging/media/tegra-video/video.h index 1e9be1474a9c..7275affa6558 100644 --- a/drivers/staging/media/tegra-video/video.h +++ b/drivers/staging/media/tegra-video/video.h @@ -24,5 +24,6 @@ int tegra_v4l2_nodes_setup_tpg(struct tegra_video_device *vid); void tegra_v4l2_nodes_cleanup_tpg(struct tegra_video_device *vid); extern struct platform_driver tegra_vi_driver; +extern struct platform_driver tegra_vip_driver; extern struct platform_driver tegra_csi_driver; #endif