From patchwork Thu Dec 29 13:31: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: 37386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402549wrt; Thu, 29 Dec 2022 05:33:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXvCcEjay2qDE2FNQLgjXBI1cPP3xAb9dA16VwPMeOaxolTNPS2hQqjk9HhL6SgZ6utD7zAf X-Received: by 2002:a17:902:a609:b0:192:5e53:15ca with SMTP id u9-20020a170902a60900b001925e5315camr23778163plq.35.1672320788488; Thu, 29 Dec 2022 05:33:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320788; cv=none; d=google.com; s=arc-20160816; b=XoGf5PLXYxEtEBwBAy8OGebk4aiSFr3qrzS8fRzHndt+ki92YMgCDC4/16P5XE8bpg 8+l2l/Fvot333xSSSaRBXsE66HieAMGG1909Exmyh+86euM/kTnDrjDGjlAKIPSX+KKA pm/WrgGtA/9Lj5fGuZs73Zaw0Lys6lNknl8je0UIpRW8/mQCNFtk/gf+vUGn/d+etCRb 9w+Q4A+DZBPR0Gr5V0njMIT9Fpi6oanZ6bhQw8Aa8K2we65zOtfveLii7g/Bqirj7aui OD2TOEOgyNhYaOm3PrZXCtB3+jgpaGuVjl3PBiLs7nQm/xdlYwUkA/5gXxeSLgzGDKb3 HTXA== 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=nYFhpIFJiKUL0dNC7iOtUPI3WT1NHiJuQjKvEVnXtFQ=; b=dbnai/SRf4T/euXirsFv5nPSq/DO8fh19YxMw0hxx432L0+V8sQ1vDqFONpdoCkL4t +z6i2W7zOtWTN6cWpoUUeDCbFHDNbnRU+/Ah2ty58QVFtje7ZAbTjS9br1YpTOzHsFZ9 zTsl/IHqtJZDarYMCiaWqoNQkEgLkBTWBRhcTyLZ+SllwFgPY6AwytJ90ODDf99C1O1N CkyVQlgTjEOmExys1SBrhWM/Xjr3XNFRi1HF9mn5evQRApPqqFXTqOPM8UXsZChYjtam OJWCNzwKgCxytmlf/OzhQzbYFtdrcoQn98Nz8bTp1gq4NMIIBA8WYNe3nONH1UJd4cEd dR7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=BUQVqSI1; 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 u17-20020a17090341d100b0017f7fffb591si20948762ple.374.2022.12.29.05.32.56; Thu, 29 Dec 2022 05:33:08 -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=BUQVqSI1; 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 S233421AbiL2Ncr (ORCPT + 99 others); Thu, 29 Dec 2022 08:32:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233284AbiL2NcT (ORCPT ); Thu, 29 Dec 2022 08:32:19 -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 3943311157; Thu, 29 Dec 2022 05:32:17 -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 BEE2AFF804; Thu, 29 Dec 2022 13:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320735; 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=nYFhpIFJiKUL0dNC7iOtUPI3WT1NHiJuQjKvEVnXtFQ=; b=BUQVqSI1muywST3IF1vYmQ/z5dZlPmdeRrE50exL+Y5Dwkz9Wd0A636GK+wlhQXTKFU/Uo JAqnyqGBBE31PvB+ugqmqoCiq1dcD1FbWdXK0goe4vWFqXFQFzuGxlVJ3kt9Hn66v6I3Au taMbHJUeCKjRUZ4UotvUrSl8sONKog/TzBEi1APHlx3u1F+/JYFWeJKmJgpL5vJ7PLwJMe SnUkv8JTO770db1jQcQ8Jsh1Q8gtSE3mvKs3S1VDrkmWpqfGJUFoJ/wTDJLVwkRSpAmRYb HX5Pu5QV19+U8T/hCVOERdTzDMTRgDTcFddN6AJna959iYWukgKu9xE7Jq3wQA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 01/21] dt-bindings: display: tegra: add Tegra20 VIP Date: Thu, 29 Dec 2022 14:31:45 +0100 Message-Id: <20221229133205.981397-2-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555442579901718?= X-GMAIL-MSGID: =?utf-8?q?1753555442579901718?= VIP is the parallel video capture component within the video input subsystem of Tegra20 (and other Tegra chips, apparently). Signed-off-by: Luca Ceresoli Reviewed-by: Krzysztof Kozlowski Reviewed-by: Dmitry Osipenko --- Changed in v3: - remove channel@0 node (Krzysztof, Rob, Dmitry) - add myself as a maintainer of the whole Tegra video driver (Dmitry) Changed in v2 (suggested by Krzysztof Kozlowski): - remove redundant "bindings" from subject line - remove $nodename - add channel@0 description - add reg: const: 0 --- .../display/tegra/nvidia,tegra20-vip.yaml | 49 +++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 51 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..c23fd02dd18e --- /dev/null +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml @@ -0,0 +1,49 @@ +# 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: + compatible: + enum: + - nvidia,tegra20-vip + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + 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 + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + - ports + +# see nvidia,tegra20-vi.yaml for an example diff --git a/MAINTAINERS b/MAINTAINERS index f61eb221415b..4feb2e1258ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20563,10 +20563,12 @@ TEGRA VIDEO DRIVER M: Thierry Reding M: Jonathan Hunter M: Sowjanya Komatineni +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-host1x.yaml +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml F: drivers/staging/media/tegra-video/ TEGRA XUSB PADCTL DRIVER From patchwork Thu Dec 29 13:31: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: 37387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402598wrt; Thu, 29 Dec 2022 05:33:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXuZZj7utoCbMn4hAkcesaWa/Egqbcb8QcKbJ/vNu2sNcfqgKaNT1fLDzgxWoPKcuxzU3YNh X-Received: by 2002:a17:902:dad0:b0:191:3ec0:9166 with SMTP id q16-20020a170902dad000b001913ec09166mr46390503plx.6.1672320795350; Thu, 29 Dec 2022 05:33:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320795; cv=none; d=google.com; s=arc-20160816; b=Nl2QSklpt/plnYWhlixT4KNgyVuavUxN2X0sGDz3DFIjQSs8vKhlmw7WPd9uyFLUOI tqvgHxvQ/duEXbxCc0N3SBGnnZa7rPPjE6NngmeP9LTOZ8Z3oExwWcAKQNZ1mdI/mM4u RrtZaxBV3Hx+tXjZSv8M1bNBuhspq70/cjxdOVtg0g8k1W5RoZbVRDZb+4FsGqgobnmt hTxnrvjf34CaAvjPW3UqvtcsJanuKSlbjYGg2pQfqAwyVUvqiMtK+H/QnP64eTYJdcR/ 4VIa5jnrMqPFkslqSzWdz8upDNGegPYmSTa747kH0rPEhhl8k0ujCWJa+DT+t9DLzt6d VeYQ== 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=4YeHQSTDdghV38Iy4vvyY44ldu+tM/1B9OLT37nvF4k=; b=hvB4xpIhUu3GA7tOEEcfcuGM7txhWJRdLBgi67JhxVV13Vm8hvkWDZ47Agh0F1RfyH kaN7cVKlJhZVeBpKgSLLXOM9w2EWZjEsUiqG7vRuLZpfGpJ5lKTzp3hdEiHsiX+6o/Oi wfx+gaej7NcS3SNRoWXZU14+0JjOE5/cJQ9TAH4qllxFLGDdnJ/YoJ5+B1sl1FdS6C1P p8CrOf/8lkkfawgD9Fp+vDA0VbvMwH1hVhArxest0bLEBkV87gNzpz6yJIsfUDRZJ1QA YFqe0bQPmm4RE2xIyiuyBYBLyt8HROQc6EkxinCsyyqkqjNqq1etpYpBQhUuJJb5YInp 7z4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=fgPMmhDS; 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 q136-20020a632a8e000000b004402f48dee0si19955572pgq.629.2022.12.29.05.33.02; Thu, 29 Dec 2022 05:33: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=fgPMmhDS; 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 S233454AbiL2Ncw (ORCPT + 99 others); Thu, 29 Dec 2022 08:32:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233306AbiL2NcV (ORCPT ); Thu, 29 Dec 2022 08:32: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 C5BFE10B7C; Thu, 29 Dec 2022 05:32: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 2242CFF803; Thu, 29 Dec 2022 13:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320738; 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=4YeHQSTDdghV38Iy4vvyY44ldu+tM/1B9OLT37nvF4k=; b=fgPMmhDS03mhaW4l3pbCCIQnF3QA7GGucEPDVi5rw7HVsfYdqLVLOAYsHOwxwSTxN4WTZc 2yIaBxw6LeMl86UEFtf3Tk5XPw37UmmHluFiBJtapD3J3gDxlNPnrOD9iLV4q0z61oLfHR 7wkq4AUCninWGzG/XQB/tMC7aolz2S7G7hZAMNVEwgyMLOL2Ln2v9Nqh8/XPmKu4BaDy8/ y5OUH+TZwm8HiwminM98M90+Svf5D7L1kD2jIo9peSJpNcGWw10bg76VPRh3kIwsD6e+mN HWZzt9pXrw+Szauq9YYzDkFEWO2TCRngiXtJxQdosFZ6SoW9YNVqIoCDkCAmCA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner , Krzysztof Kozlowski Subject: [PATCH v3 02/21] dt-bindings: display: tegra: vi: add 'vip' property and example Date: Thu, 29 Dec 2022 14:31:46 +0100 Message-Id: <20221229133205.981397-3-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555450603996561?= X-GMAIL-MSGID: =?utf-8?q?1753555450603996561?= 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. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Luca Ceresoli --- Changed in v3 (suggested by Rob Herring): - drop 'endpoint', unneeded as there's no extra properties in the endpoints Changed in v2 (suggested by Krzysztof Kozlowski): - rename "i2c3" -> "ic2" - add review tag --- .../display/tegra/nvidia,tegra20-vi.yaml | 64 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 65 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..da9ce76e15ef 100644 --- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml @@ -74,6 +74,18 @@ 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 + patternProperties: "^csi@[0-9a-f]+$": type: object @@ -109,6 +121,22 @@ examples: #include #include + i2c { + #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 +144,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 4feb2e1258ce..dca1c47706f3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20568,6 +20568,7 @@ L: linux-media@vger.kernel.org L: linux-tegra@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml +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/ From patchwork Thu Dec 29 13:31: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: 37388 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402683wrt; Thu, 29 Dec 2022 05:33:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXv3WlhA5w88RwngTh8pTX+UtOiI9biSCaarfrxSMho1PcakGwAVvNy7KU94nfBomyx1QrZ3 X-Received: by 2002:a17:902:e948:b0:191:309a:d752 with SMTP id b8-20020a170902e94800b00191309ad752mr32173690pll.47.1672320806313; Thu, 29 Dec 2022 05:33:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320806; cv=none; d=google.com; s=arc-20160816; b=EvO4ZTiwO+MifUHvave31F2dMC4kd4lKyRQtJamcfMcO+UCRwxbQ8263GhL0avOrAj cN0/3TStRDtSVku330Z0LHr9yq9CQxCZB/0yNJT7rMCXaufiAFE+ECUPNqdSFebaYvWB bdM3h+e+2F4rkerd3A3mNwzSnRzB9Q9B91bVBQoK1QAspDVo6gQMBnb2R832w5R6TJGz 1KwIUwApTqk3Vj12Vfk8BBLxnITPKZyF8eeCP/+9kK0AMSs1gMkFh4FEvfRzj9hIwTm5 do0i03phdKl9xmOuTsNZFLUipn95rEbehruKmC8in5IW9y4bdIGlCM4okq1pcK9QgnR2 z7xQ== 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=uMOVBX3i9Yuq+qWsthZ7lJRlX6Tmhuu9D40yhVIKTe8=; b=KrpRvF6bc4aKK8aeKU86Oo+N1e6eu6Sb1XZglmln6wAgpOVH37HIdPTGJ6L0T6Ujib iRuzEoQUymtKeVu3DR3qHlXC/1xCC8XOdkuDnelZRAndCveo1YD1d8F8dd+dxDPbbai+ w9XjPY5j6yiGreR6bttgbuAB9LYzHE3uiNxTwk3/dkzJ6+4qGjYDBJI6B2DugldDPgqX i54oFQyskTW+Eqn4n5VegN78WfQ0Z6BLW/LSNS0rz0P7sgydC0hJBnOsUUHWqOC/S5mj EYi6EP09W7dhupAxzyobv4GiatFTIPwRImcy2BjfRxfyMDq8+T8Jzls9C1pQL1FSA3tC uuSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=gpOKnj0c; 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 jh19-20020a170903329300b00179f8a3f838si17837094plb.593.2022.12.29.05.33.12; Thu, 29 Dec 2022 05:33:26 -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=gpOKnj0c; 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 S233318AbiL2Ncz (ORCPT + 99 others); Thu, 29 Dec 2022 08:32:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233326AbiL2NcY (ORCPT ); Thu, 29 Dec 2022 08:32:24 -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 3AF7410B7C; Thu, 29 Dec 2022 05:32:22 -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 A3C99FF80C; Thu, 29 Dec 2022 13:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320740; 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=uMOVBX3i9Yuq+qWsthZ7lJRlX6Tmhuu9D40yhVIKTe8=; b=gpOKnj0cbMg9uHqbVR2BZj5Zebutn9YUgn6njDrRiHuDZ8tTb4iqgGdI/+85Mjt3w1Ko5/ BjP8ed0YIBmvzyRCfCyONj8SzY87aigc6gE3AMBKN1kSAjKnNIOkRGwKXk6WjwCOvv0oBz EqQTp1ZI3YVyjJewmBXZQDCCQCwc0KP9lfIPf30hLgVq34EtinaORc2Q8P6yfkqY3yh/0Y TYHSb4A9YXv4FMgVdOMNkKJnf5iamWgcY78/jq6AsNTqS0mclqkCaGJYiU9OaznQXhXcAQ zJPixISHFXSYahpKqS3WYIfcfFiw6essspVcQjgpcI+uoSwDdS4RgOY/oIQkxA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 03/21] staging: media: tegra-video: fix .vidioc_enum_fmt_vid_cap to return all formats Date: Thu, 29 Dec 2022 14:31:47 +0100 Message-Id: <20221229133205.981397-4-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555461443000529?= X-GMAIL-MSGID: =?utf-8?q?1753555461443000529?= 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 --- No changes in v3 No changes in v2 --- 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 11dd142c98c5..9dba6e97ebdd 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 Thu Dec 29 13:31: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: 37389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402752wrt; Thu, 29 Dec 2022 05:33:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXt6v0DK0A4hKL7dMyn4hMptJVnsYDEmxIl3iX/+ZpPRjm/qLpQk0WGNyr+5nQoN2rbCG/jr X-Received: by 2002:a17:90a:b112:b0:219:813a:745 with SMTP id z18-20020a17090ab11200b00219813a0745mr32029719pjq.33.1672320816984; Thu, 29 Dec 2022 05:33:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320816; cv=none; d=google.com; s=arc-20160816; b=C1q9HEW9HBvyrdMZSUi0iWOsRLO27ibKi0a3VqqIUbw2SiQExkozA2zKRvrBGCB/H1 gDdl42fbX8D3KTeVZ3xv412NMXPnbWWKisVQzgxSGR/CZ2a3AcIywwV+UUK35QSDkIdM uiS/A1BjNvQDPM7tJJodOtE2+phWq2rjc1OJXgAiOnFQ6ULq6tJ8//SdpD40V0Dj2FP6 slBiXUfzK7AqqOFLixVCrFJZJOZsXrbUqvrCc7dPn5v4nMTfZ5zo+R76yLu1L1VbjXNS fUvRqRurIBxdyvrGKPPcDZbVvB9Zj5kRNNNH9RXTNYCTroWQKkc72elkT12ZlMYigNX9 YxLg== 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=p29c+GUNfmZWBqKxZlRywO6eW34k23duVEnJrnJGZho=; b=ko6iasZuV0WPraEGcrZNmim/zCPC7UwC4B6mKVFsHzCe7kGCn1VmrglmRlSUGSwxEt 6JPQ775tGdiSoyRQ1EZqypaJAwjNKl8Gsc9UfLrFr+XPxy+C8vh1UICFdQcp5E1/v0mV Z0CB+E+gyhViIPr2Y+fFJUUBO6YMhC1LHM+tJT9F9oPCj2a8OF+kYUnzvTj9Yromop7C yK95xTEjthUNxtBeeNnU+ezA0BIKapL53qu4RACtIVOdFmEFwm5TT2ehi3667zJWumCO zumJgm2hl/6/kdNH/zvxUp0mDcKfvI6ytj3l6guUnXV1G8wjgTm53x2lZ7cJTlhm2nEB FE2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SqK146vn; 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 oo16-20020a17090b1c9000b00205d58e9125si21393930pjb.68.2022.12.29.05.33.23; Thu, 29 Dec 2022 05:33: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=SqK146vn; 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 S233387AbiL2Nc7 (ORCPT + 99 others); Thu, 29 Dec 2022 08:32:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233337AbiL2Nc1 (ORCPT ); Thu, 29 Dec 2022 08:32:27 -0500 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 07C346240; Thu, 29 Dec 2022 05:32: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 12923FF811; Thu, 29 Dec 2022 13:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320743; 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=p29c+GUNfmZWBqKxZlRywO6eW34k23duVEnJrnJGZho=; b=SqK146vnktp4ptLaybN8gTF2MzLGHYUJjxGUckp7aDN8yZ/wPJf85YOCogpfowN3L/42ZE 9c2h/Fctpo9xJE5hoPiwwzyu4tGZlYwzAxc/QSdLtE8A5KyyA8FLoMp7pX0ibzS1M0sRH6 pmCPvLSx07/QGmbpgBVtC+WNYhSN5CPfA9UPc+sZZQ6Q3znpJFimREAsVHBueL/wgldBq9 tHrDEG2/txi7GZ4WClQvLqUKCSU7UnYFUnAuzhtCbdq4dRBTrKCUsupQeKcNd6evwZe3F8 FM2lyjwer016kpGKYDPW0zJvaZ5uS1ZXKExJcp1NhzzFijlLMgw1b3zsOmO4yg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 04/21] staging: media: tegra-video: improve documentation of tegra_video_format fields Date: Thu, 29 Dec 2022 14:31:48 +0100 Message-Id: <20221229133205.981397-5-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555472690040939?= X-GMAIL-MSGID: =?utf-8?q?1753555472690040939?= Some fields are irrelevant for Tegra20/VIP. Add a note to clarify that. Signed-off-by: Luca Ceresoli --- No changes in v3 No changes in v2 --- 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 Thu Dec 29 13:31: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: 37390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402755wrt; Thu, 29 Dec 2022 05:33:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXv07rCCfdzVMnn8tntSnyzKCAeRCqIQPRcOXhQiUl4HFdi67vCsd3muHUbEswrV2Ed3vueY X-Received: by 2002:a17:90b:812:b0:219:f993:7f30 with SMTP id bk18-20020a17090b081200b00219f9937f30mr46030203pjb.32.1672320817087; Thu, 29 Dec 2022 05:33:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320817; cv=none; d=google.com; s=arc-20160816; b=x0O9WtJGSI3UDqYWySDilhgs6f+0jrEVEHsZjCo28eggQvigfrRjc5S8mR7EBTV/lK m4EqGY9MHQ/mzQC9++5DCrwfPk6F1hu/LlvfFtKOwDzoKJg0MYP+xaRveSN5ydVA2tFd HSHHvxoAzSTlNSCKaMspCcS1fosnts0DaDWlrA+2i+Z9u4iM0b2OGvp3OP3SuoqQkf4v fJxm5ZVzt8cOM2apr9t9ju89AHL21v34qHAEQUzUn4+SNTByyx9i9b/wVxaiTdLpm/7U 5T085g2ZqQzZnYpzG3bNbNgEZfeGgbdz0CTSMULTk5HGwSmT6y6JKKCRN2axy/AwWOfA LjRA== 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=3nz5wNe+Z1nzIXUX/JoabalYq7SA6k1PNej8sIBUtyg=; b=u9ES37au1PDmSf5KHkovKeQB88MuW12myOQDTQcWjv51S4doaEunpgdV1adlMwkBe/ KGyVZDhmfvZeH07dOxUELCwBnlI+hU/6mUc25Z3k2GnR1msxmtEmr3HF8jWVZykezKgd 5NFZut9ZFHJjtKz37yABWuHzks/O+HnMhXMho6c3gce419gJTjbyKzhIt2c/TDxjBZJz IivuJwPfhoMbhWwNACj/J9x23RUSjJa1NDylpHXh0rrPD8J0a0OzBMVz91NCeMH5klFi +E7TeZmVT0M8arCfk3fAfuWxHrl/qZI3OP9THuoMLUpcyWbwr8F8pTN1a+nq6FwwRaCZ cqZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ataXZHP1; 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 my4-20020a17090b4c8400b002191a044fadsi24925644pjb.122.2022.12.29.05.33.25; Thu, 29 Dec 2022 05:33:37 -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=ataXZHP1; 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 S233478AbiL2NdE (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233351AbiL2Nca (ORCPT ); Thu, 29 Dec 2022 08:32:30 -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 B397E10B7C; Thu, 29 Dec 2022 05:32:28 -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 B4B8EFF80D; Thu, 29 Dec 2022 13:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320747; 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=3nz5wNe+Z1nzIXUX/JoabalYq7SA6k1PNej8sIBUtyg=; b=ataXZHP1ot1/L18b70FdiUNXNSN61iY8tQ871oCluO9n9CmpAW2lxnU9pxee/2+gugDcQO 4ZPuj9bE5yx/6/8Ynk3WIJwa7BRnEtH4ONGtoRCg+MfdgJ7UgfrZ9ONjwRAP+k+peLvM1x LKlGLQ8TE5ZJwDXL/MGpjROc+5ZvVeomKWk40F78p4zR7ci27RO/YW0n+sT9kdOV+4Huji Rm/sZSwF8AGvQaxwt6DExIaUm9FfrTC7UCUu7+QsMse1ZzvNJs3I7b3CoeKywI6dKfboq8 juamKewugOlvP/rGU3VVEmMIpyUV1/njUGp8LFSDoY6FRFhKBpTdOxwrBfpoyw== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 05/21] staging: media: tegra-video: document tegra_channel_get_remote_source_subdev Date: Thu, 29 Dec 2022 14:31:49 +0100 Message-Id: <20221229133205.981397-6-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555473018766865?= X-GMAIL-MSGID: =?utf-8?q?1753555473018766865?= Clarify what this function does. Signed-off-by: Luca Ceresoli --- No changes in v3 No changes in v2 --- 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 9dba6e97ebdd..6aecdd28bd82 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 Thu Dec 29 13:31: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: 37391 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402794wrt; Thu, 29 Dec 2022 05:33:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXvMjuRwMeSSv536VpjoWPMTRFI7Y3DFFd5MSV2UDBSVrtRh8hmBTj8Qcs8xjvwsXBEDnUjx X-Received: by 2002:a17:902:d4ca:b0:191:1f16:efa3 with SMTP id o10-20020a170902d4ca00b001911f16efa3mr30704704plg.65.1672320821421; Thu, 29 Dec 2022 05:33:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320821; cv=none; d=google.com; s=arc-20160816; b=D+rxpFmUUU35TSrOVE1Xxf2jlN95HYuRtq3+aob6zFXkEyM40Ge0hSqoX1UzmoXAYV hucUUTM2h5/MuWvdqxx0L7ZCVS4rT8ZbWidttLXGH8ye2MnHr5vA1GdswDrlTugLJexD yWSLA2VRFQE9S7Y7ATm6fQ9JyRZoSobYlnjaiwuhm6m93lZ26A+B1nHosJZGa+JYR/mx VSfP9wJ0iy5cUzV1BpA3kHHP1eigN+/rz6/jXBbHakcxy/xrexxEGRvMIOhja4SkoDBG h31W4HjjOxav1hR7lEJxZJj0VskkVeqZukZYeF6xkZof6qfTcSDZageE2LM2k3ADOhq8 mkSQ== 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=KSihM6Wjt78AkZJ7cO7U2XtTCOIBs2Jh3yvc+KsQGxk=; b=Ex47aziBfoTkNnAjQok5/Arx0kxduweKi+OTm8fec3ioSUwAA3TBui82DlkdSaEsgB XyqOyZl88XqldoUgZPc8zAfpA3w6hdORokBIq7CJwBqj7MWJR4MDASn4D2MAaAHqsQxq JQ5reWO7N75GKuRR0haZgcNOx+Ro+Hn7ZDEU8HqHtytyaYgGHq9P6aV6xUTt18N8phiZ xLcQjQDhzK1km76k3qoK/V4PZnbgrMlqoAu3aP+MDjMBl1bg8sU4g2S0Bq3iaCIZIPd7 ePQAxm0rEi2DjifLA2fHyV9G93HHmx1I7WVH6JS6EaPCKCW7uitn9hIDZzpFIsXuDT5f Ks2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=N7howy8i; 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 t13-20020a17090340cd00b001890c6ff01asi18636500pld.483.2022.12.29.05.33.25; Thu, 29 Dec 2022 05:33:41 -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=N7howy8i; 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 S233482AbiL2NdG (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233372AbiL2Ncd (ORCPT ); Thu, 29 Dec 2022 08:32:33 -0500 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 3A6CD6240; Thu, 29 Dec 2022 05:32:32 -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 B0825FF80F; Thu, 29 Dec 2022 13:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320750; 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=KSihM6Wjt78AkZJ7cO7U2XtTCOIBs2Jh3yvc+KsQGxk=; b=N7howy8iMtRhbikukCOsHdZDGVDGD42jrWpgooTf/2YbD0IMI+0hGRCEJoCi/8SEpjH+Iv UolNxWaFxO0LzzBrTtZRVwhYhRRJauYuIm4PBOjBiSRattAkNioGNZeCOGV+qhFnY2+oOA zKE9I2uSGACQ+EZuDYsVG7xRqSSYnflFPGK5nwU5S+umBtsxQsbTpG+4qCXTOuy4NF21g8 tQ2+eLAz/dOcplgnWeJSHSzHtZMM3t2Qj1mZId2JLP+U2+QXhWfn6uUinoXxR1nCRprILw aCePAM7v38sIHteoPV12S8R57E2TkXsy/Tj9j4jzTYa78zT4iUjvWuhKFAdsnA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 06/21] staging: media: tegra-video: fix typos in comment Date: Thu, 29 Dec 2022 14:31:50 +0100 Message-Id: <20221229133205.981397-7-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555477997604685?= X-GMAIL-MSGID: =?utf-8?q?1753555477997604685?= 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 --- No changes in v3 No changes in v2 --- 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 6aecdd28bd82..ae7adf640e76 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 Thu Dec 29 13:31: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: 37392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402828wrt; Thu, 29 Dec 2022 05:33:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXul8/7qgee8ZQvGE4dhw1eaaWeUZtRikbHXSBDMTfcHxtp/rr4eeMyw/3/39LqWEdDPT8j0 X-Received: by 2002:a17:902:b401:b0:189:aa51:e27f with SMTP id x1-20020a170902b40100b00189aa51e27fmr35910663plr.44.1672320825288; Thu, 29 Dec 2022 05:33:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320825; cv=none; d=google.com; s=arc-20160816; b=LFAyPVkpKnVYD+nIHBIw+5t7LlVLu8rB/cK39j/aOiyB8ni25OsW4CBIu5P3U9GWf8 GuMpGB8KYPvNjnjfUr7+20m1tT1hR3XNe20LhvKVsUBlU9FA/gNRVzJShwgNyqzil8rL AhbjK+8/ELYqbYirk+2oz3CpKzZK3jYcSRuSxPuEz7nngirRxpBxhwZ3LpY54wnxFrjz r3Z1/rSDJlQs4ospAH2d0FVI45sG7jQnoAitOa+XDvauOE+c4W2YPY7af+IS/NA+vcy1 8W5RjMV1WHtBgZC+JWo3VNiq8Kn/pn56Lp9S08bmuxvpdl7aaqyYoczVqQ37ksmNeIz2 +0ag== 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=lxGIJCef9c0twbq/D4ksS34yk0nVt24wbkjICVr+NEc=; b=xUBTVHN+AlM5o4JNSZWAZ1PnOWrL6xP5QgXGVk+7pqYddCq88qCSY7dO9xmL+VSsOH KbucF6iA7g9Kpg7lzFh5AVO07wnBVmvDIqwjlX/4UworQ+IKLVsxphPK4LqxSPYuFT0t UXYvd9wXfn3xFiz+9pcnN38n0DfDEO3z37L1ZbFRgi3P9uqJ9rMZ9DVg5HjVOVNKca6p mtjEUT64jd0eOuAG/FAy2MIjLnrnVMaYtDznMPoRgGBeEZ/Z/vqDJX3t6X46PcaYw6bL g1UhHiGVOT+Kdmwz+uWeUTj5drc9JBLDRohfdSsA7ycc1phkAsfOIcMUiK4Aq7bkNwuq lyYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SG3KV1fV; 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 i2-20020a170902c94200b0019294cce398si4931199pla.314.2022.12.29.05.33.32; Thu, 29 Dec 2022 05:33:45 -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=SG3KV1fV; 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 S233504AbiL2NdM (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233382AbiL2Nch (ORCPT ); Thu, 29 Dec 2022 08:32:37 -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 504C310FC7; Thu, 29 Dec 2022 05:32: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 22963FF810; Thu, 29 Dec 2022 13:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320754; 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=lxGIJCef9c0twbq/D4ksS34yk0nVt24wbkjICVr+NEc=; b=SG3KV1fVDNj7ijnQf7DjsPLWGdQNLQJ9QsZHfvRKpIiQLNxnrm8ZBK6eBeqX71Y0CTWwQC DOjboBANQ9XeA2Iw2AFaWFDZrwZLpDzl3TeANGWMBCvhGWOvAbtV2xZY2gS/8Ur9vhG/+m WDfo+85JinfsXhooviBIv95oZuSV7X5qvO2N1z50QO7BTfjH9JSUlycXD1doJ8OWHw8TEw vrzLMIf87wmDHKu6YpgFB9d832tbM7UTUsl6jFAceD9R9FqBvQgfhX06jw8OyZETLUQEaf 1lc82Kg1m+ur0RobyjLWAa3I8idQhtufehYoDiZARh5yjvmNgj9sS26Z3lQUEQ== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 07/21] staging: media: tegra-video: improve error messages Date: Thu, 29 Dec 2022 14:31:51 +0100 Message-Id: <20221229133205.981397-8-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555481572985877?= X-GMAIL-MSGID: =?utf-8?q?1753555481572985877?= 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 --- No changes in v3 No changes in v2 --- 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 ae7adf640e76..0e5067a7986a 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 Thu Dec 29 13:31: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: 37393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402941wrt; Thu, 29 Dec 2022 05:34:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXv68Io37Y0ay+5KHKu8KBslDlVr6rBPZfnI8QZ7cIi19paTnA6zr76EHuv9Mtx5Ixo8+E3N X-Received: by 2002:aa7:8c46:0:b0:575:ff07:cb1e with SMTP id e6-20020aa78c46000000b00575ff07cb1emr32726516pfd.31.1672320841553; Thu, 29 Dec 2022 05:34:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320841; cv=none; d=google.com; s=arc-20160816; b=B0wl5yp5mylABuvc+wFM7OcUJ2Fb2NBETo1cjuSBPQWm0RQFwSvzysnqLmykQ6aJI4 fdjNzyGViZlLUpcd9MSyFD4g/amam3jMTV5LXyC7PTwwRoXbH99sM4/LuqrfemO8jcsu l8O2L4A0zGNXJ9vW+S9E2m0LFa5IulnjVKAQjFnVaQDEiLA8/rUf878pKsp7v7GF8/re iQqsOkLZGhSWsZ6XVrTeJdk9NVyeoX6EZPthv5bysoQ4np399pvhTp96eh5/FFnMBqAb RWx0m1snZQBFWvXpdv+PzfynrJHnP3rgCMKrnXPs5lmiHhCCuAt+h0n+LEPjbJOK+ljZ G1/A== 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=nsmhIDmSSfH619hRw6C44IlZdoLkr++cNYpPRM0qeT8=; b=OE+GAoHOEXg+P8kB+RR00nYh3BmqDb4S+AZmctKqdoDIiT26PCqcydOOem0XR05WZA Q/6g7/B9yD4E3WMExvA91uNyga1qfpPzwe5KCw/bV5D4mb/lQdl/zUVMJhd0mTwPlMqH RCyDaNBq8zavPjGT6PliZAWA3BlXxSRejDYd1XZxec1tjsm/gDIWK3rnWQJRq8kvpEzR cQB9ppFEkcrgtPPPi0KWHZkfRh3ZGAaIyLT4eSCCKfPHWmNjfMYlk+WWfHxKgZQ/ybC2 bY3/vUh/o8oF2VsXTSmHaqIOSf2vAxSYNdqWtlMDmCE0s90oYFkNtiMjv8LUoPcu8efH MkXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bINMhtij; 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 h3-20020a62b403000000b0057af1413b10si17599164pfn.40.2022.12.29.05.33.44; Thu, 29 Dec 2022 05:34:01 -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=bINMhtij; 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 S233509AbiL2NdQ (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233386AbiL2Nck (ORCPT ); Thu, 29 Dec 2022 08:32:40 -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 C58C810B7C; Thu, 29 Dec 2022 05:32:38 -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 476C9FF805; Thu, 29 Dec 2022 13:32:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320757; 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=nsmhIDmSSfH619hRw6C44IlZdoLkr++cNYpPRM0qeT8=; b=bINMhtijHQXwSNYJl+84GZHHzEQtngyD0Ylkserq7dtkBOZvIdhn/O7XAbm/V7vHOPi6xZ Usu+/V2wW4TvKHHPFczFi66RoToaLtclBzZn6LBe6HFK09a3tml7UNABtJOTNtFT2a0Nmn ROAg9WQWPd0Qh4ooZjgNeIxeEgVrN99yyRGQSsQl/amX9ETq+ddGVBg2P04Msx7ilAY0cb DkPfgF3ez/DuhVwGXsO8bliwHH7q3t1O4G2G0A45tLcacMNNh8UbeKB7fNoxzEVYO0IS4t T8gPPH/v1s8XeZLZ1N+TJN9pHW3nisAm2c4+YOkxpsF/FQDWtjFqrlHIZr3kEg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 08/21] staging: media: tegra-video: slightly simplify cleanup on errors Date: Thu, 29 Dec 2022 14:31:52 +0100 Message-Id: <20221229133205.981397-9-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555498656435919?= X-GMAIL-MSGID: =?utf-8?q?1753555498656435919?= 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 --- No changes in v3 No changes in v2 --- 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 0e5067a7986a..c2724e1ecafb 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 Thu Dec 29 13:31:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37394 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402937wrt; Thu, 29 Dec 2022 05:34:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXtw7cyxCFXFpbqHNf3c/qUqLNhdmUbUdHxen3Jy1VyAEhuopFrkEcihqUJkBX8HTSgbTfV+ X-Received: by 2002:a05:6a20:d2c6:b0:af:7233:5bfc with SMTP id ir6-20020a056a20d2c600b000af72335bfcmr53138882pzb.8.1672320841505; Thu, 29 Dec 2022 05:34:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320841; cv=none; d=google.com; s=arc-20160816; b=vaqF2m6iIYV4nP2k/KqouGvGcOWG6xSapIf/KBKndrdkK+pjW4xXGs0cFgK6Vk12pL a/7khJvFaHJSd67PIBsTObbYROxVEOllqWdPNxTVzA8VauZTKyjtK7bnUhV5xRRhL808 ibwOeTnnvb9toGIuFUZCXC5oS93XkBWk6jKUN+YS+mnhPkqNdG1u8ShubL+uIHCaCfJF n3AH5u3v01tEc7IQDcUZhmOU4I6KSYbsjG6MX8Yenip4B8DBWAHaNy2XwJkjOoDk0HcK zjoUH+Mfv1Tpik9PiZ9d1c9hSVNDIRifG3WvEcN061b5tImrg27WYGykTL1ip9IOanTE iRQA== 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=Rxd5etkxm/QsMIFmem4kDzhHvir4o1D7dvjd5AYgtdE=; b=x4X3qL9XzlNfasllaLnjYA6jLQJDRW3y4JPne8p2yrNEVu3A6MbwS5j1wW51zlD849 tDL9dmYLpfa/x6YdnXLxRJaIrEtnBSMYZ/FzXdF/VPHK6PLUa0CW9Hr7BhFuJ59OMrhg 7YAhvCMz1jRB3xFOuJCKNxKQdHPCqnGKi7CKEJzia5M8Rv+fLykk5u6WSUpT/0qiidyy KFCf3T42BMu2+OHTuZdFf854VaQow5wZcnGzrF50YSNgeD2T6wC/V0MJSpqrhZ6rTQ6+ kvSgC+gMuY2f2/ZRk133/XyiL7ZZ8ifnuHa1R+Agkst94ReIVPsRFJcpFphWFwivPI0I 5jcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="m6Qu5Vp/"; 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 x30-20020a63171e000000b0047860cda19dsi17656391pgl.859.2022.12.29.05.33.47; Thu, 29 Dec 2022 05:34:01 -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="m6Qu5Vp/"; 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 S233514AbiL2NdT (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233392AbiL2Ncn (ORCPT ); Thu, 29 Dec 2022 08:32:43 -0500 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 7E1D41116F; Thu, 29 Dec 2022 05:32:41 -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 B7FACFF807; Thu, 29 Dec 2022 13:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320760; 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=Rxd5etkxm/QsMIFmem4kDzhHvir4o1D7dvjd5AYgtdE=; b=m6Qu5Vp/bAEdp58VnsZnJ6xKgmv8R10f3xFAf2DzU4DYXFUbuY8DsOMW43JIwedyRqW/OB iX8iZ9Njch9B2//I+NtNdgzkiG6g1mKMDp6izNTaJB8x+X/lRZubmblzzeNqxU66auFQqe K4t4hSjcenC/RqurzR5VfX/T1B59tqrXlIGfgvuPbWtbrZ+1Ut6I8ST3BSKoSZ6LWv2/6H pWv80yHJryuDoy+gIpzadfdUX2Rx/NjmOrzodelcaH3jzbtX4TuujT6bnWzC50Qndus1ZD EEVoesPF+fQPfJW8xm4bHdU4lTRPicziSWgds6mSaAfeSMU9k2c7tvh7SXBwsQ== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 09/21] staging: media: tegra-video: move private struct declaration to C file Date: Thu, 29 Dec 2022 14:31:53 +0100 Message-Id: <20221229133205.981397-10-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555498754197777?= X-GMAIL-MSGID: =?utf-8?q?1753555498754197777?= 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 --- No changes in v3 No changes in v2 --- 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 c2724e1ecafb..4e48eaa0fbdc 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 Thu Dec 29 13:31:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402957wrt; Thu, 29 Dec 2022 05:34:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXu5Ojne2UlXmjvMEse0N7qoyDaceWb2QCGCf/GRhuDTa/thUbV0tkatsFTzNc+eZ4YP0xvo X-Received: by 2002:a17:90b:3597:b0:219:b1f0:ddf0 with SMTP id mm23-20020a17090b359700b00219b1f0ddf0mr31781297pjb.36.1672320842662; Thu, 29 Dec 2022 05:34:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320842; cv=none; d=google.com; s=arc-20160816; b=HSwlikEkKx1ZPwCFmVOZzfXeo0yWHVPrlAYDEmwFUvoPIjs/+9ont46Ov8l5iRmjAJ QdsuXcnw4lqLF6ozcSDEBWpV7ALJyAm731Kxh/QjdYJPDvBVLrYJfAHw0GSIeok7xEcE 5u7OEZPwcETqN5dlCtyBNQ1mKQcO1VWIs3UMCy1ocGe5gBfiM9Mg+RRiWLc6sHBsBBx4 ycyKAmJJprWFDFDy8pm+YPKkAV3hGOk8bt8+dJukSEKOwWBZrPGbELv5HzJso8PLtzMq oup2IZ7R+wv67EoStoQYzHd1jD6YBA2fxommQpfrfvRxeo506whT0XO8tHGpuxbFPZnz 2Zdw== 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=Cyys6IQhZqQdeDitV1B9k0iSS99U0JPCbCQc+oTUNrs=; b=xg8KJx2tLFvtp0rMKIFZIA4vbrhuSdbU1Jeqm0Hi8dRdLhlfxvdCMsDuLQZgqndU0W 9bY5xC/PyuD2iLfsrWTZf75fY7uHNGnUPrNyziO4+ua3h8BOpKRhpSMlrBD3uOcvouZJ XhGJ3V/fijZ1blYelnhbvZcWceihOkhaAl27l7Oysn+aM1VBgpB+T4+RfjdwPJEAmHve Ny5yRPWcLfsdoQ+fCJegrCJ8ha5H2gifxZ6UGjygBwDOOOhM5nOGgakU1TlzLsH8MlCY cZ38fMe0dEClIZCLFl360ZmGpeA5i6PikOOnr7hiNzCiBJomUDz1f/3rHQLmekajvR6z cIGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=EUfCsfh0; 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 nn18-20020a17090b38d200b00219ed0bf12esi24728481pjb.190.2022.12.29.05.33.50; Thu, 29 Dec 2022 05:34: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=EUfCsfh0; 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 S233471AbiL2NdV (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233399AbiL2Ncp (ORCPT ); Thu, 29 Dec 2022 08:32: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 B61FE10FC7; Thu, 29 Dec 2022 05:32:43 -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 428CDFF812; Thu, 29 Dec 2022 13:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320762; 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=Cyys6IQhZqQdeDitV1B9k0iSS99U0JPCbCQc+oTUNrs=; b=EUfCsfh0zFwxwRpDvMicJuTb2DQfY0SlrZMy0lf43yq5B9J3Pw7JD2Usi0vjKXH1Zn6IHk H5pXfb6Y7vmZqhNzms+8lWh0DBM2vTJvRs+XEC4RfnZeNk4u/T3r3r/JnoWKp81nknf11V vgNCryoO2j821jK6dD2oMaIch4VYCSYcEANnzoOZXokRkvCbWEt3YeugsTtIQEwd+8dqt1 bjYmJBVM/H470Bast/LGVCo5RqBNs2EHfiV3JCKBFbGfTsa6quqCUMUJOSZfU3XrxsVXPf jCtynWsqfIoIQ1axDUEbNMSdPg20bC/xY6Y9kzPp6lPsNqC+cBqHoK1JUGq7RA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 10/21] staging: media: tegra-video: move tegra210_csi_soc to C file Date: Thu, 29 Dec 2022 14:31:54 +0100 Message-Id: <20221229133205.981397-11-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555499659871760?= X-GMAIL-MSGID: =?utf-8?q?1753555499659871760?= This declaration is used only in csi.c, no need to export it elsewhere. Signed-off-by: Luca Ceresoli --- This patch was added in v3. --- drivers/staging/media/tegra-video/csi.c | 4 ++++ drivers/staging/media/tegra-video/csi.h | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/tegra-video/csi.c b/drivers/staging/media/tegra-video/csi.c index 426e653bd55d..9a03d5ccdf3c 100644 --- a/drivers/staging/media/tegra-video/csi.c +++ b/drivers/staging/media/tegra-video/csi.c @@ -792,6 +792,10 @@ static int tegra_csi_remove(struct platform_device *pdev) return 0; } +#if defined(CONFIG_ARCH_TEGRA_210_SOC) +extern const struct tegra_csi_soc tegra210_csi_soc; +#endif + static const struct of_device_id tegra_csi_of_id_table[] = { #if defined(CONFIG_ARCH_TEGRA_210_SOC) { .compatible = "nvidia,tegra210-csi", .data = &tegra210_csi_soc }, diff --git a/drivers/staging/media/tegra-video/csi.h b/drivers/staging/media/tegra-video/csi.h index 6960ea2e3d36..3e6e5ee1bb1e 100644 --- a/drivers/staging/media/tegra-video/csi.h +++ b/drivers/staging/media/tegra-video/csi.h @@ -151,10 +151,6 @@ struct tegra_csi { struct list_head csi_chans; }; -#if defined(CONFIG_ARCH_TEGRA_210_SOC) -extern const struct tegra_csi_soc tegra210_csi_soc; -#endif - void tegra_csi_error_recover(struct v4l2_subdev *subdev); void tegra_csi_calc_settle_time(struct tegra_csi_channel *csi_chan, u8 csi_port_num, From patchwork Thu Dec 29 13:31:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402985wrt; Thu, 29 Dec 2022 05:34:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXuX+O4nSTAzN+dPxEtCPP34MmOStNg/HE1fOf2FUHAKPnNdl4DqqmvinH9WeuauMUHYAsAK X-Received: by 2002:a17:903:40d1:b0:18f:8f1e:e69f with SMTP id t17-20020a17090340d100b0018f8f1ee69fmr34391018pld.19.1672320845688; Thu, 29 Dec 2022 05:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320845; cv=none; d=google.com; s=arc-20160816; b=pOfY96PPMqHOapeo3ClfeoKFs+SEJ9Ri6Mw/YUyrHSXiL6EnHajxsj98lB9H3YD+R+ R4wSkekVzNRSZ/bHVqxo0lNKKbv+oDzjG0e3NKZynVxsd6CB+DWkPzqw1i0gO7oiKn3J wDt73f7Hp1vGqlrtUeIzkiGs35zsb+0fTsWQZ3vcSLSRoTuUSDjLr0xCmhtZpKtGhwWG 1NFmYHBKhxAoLjpgkeQOMKqlK21Gni4r8eJQNC89sNDXnYaSkToVxLdsUNRWLntsxZn2 jQnbQpGTe7b1EbCIms6qUMMPV63FmYnESg4FqzSZ3WuNHhEo0BjW4UoIcUFYIxuyCqhj sWZg== 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=UQTiPFKP+pEzeFCPyHTVzsA1IwLI4U0/drsR4PKKBSU=; b=lwb/LyH1eISEEN9Rxc/rpXnGhJWVzDzoqLl3sK0IxBSSFhy0jhD7KFjDOVXPi9omTs aedVZmGaWoFZrAqOzPEhipa4h60BZiD54Sp+thC1fODMSJD5z9nG4y0H/Wfw2M5yfWx5 zJB1ebjXYpJMtS1wloq+bYacWpRWvGcomOHyixwIIGFxF2J+CMnD3+fZDJH+SF47JAa1 AnFd8ZisZA+p66IqkS/dZ90t9uQEuYt445TB6BeKoEu1gr39ZxspbXMZWlXDyYFnW5ca nl0ZncrMI3OrYPwE6sryYHvKwOBKV19wEWCFtHB7WmjkHYBGfPVbrE7Ldd58JRFWlrML nXJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jJxTR6sX; 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 x12-20020a170902ec8c00b001755d722578si15460251plg.524.2022.12.29.05.33.53; Thu, 29 Dec 2022 05:34:05 -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=jJxTR6sX; 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 S229773AbiL2NdZ (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233424AbiL2Ncs (ORCPT ); Thu, 29 Dec 2022 08:32:48 -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 7916A10B7C; Thu, 29 Dec 2022 05:32:46 -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 A9FD3FF809; Thu, 29 Dec 2022 13:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320765; 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=UQTiPFKP+pEzeFCPyHTVzsA1IwLI4U0/drsR4PKKBSU=; b=jJxTR6sX02B1r6RER91pOhHPuAMjT62EBgid6twi6RQUkuei68KNY1ttV2w6doFEhmSaG/ Y5oghaGKxbz+eaH9F2MrYt1zIQRNyQhaotcVyPxVbQsjzSkrAcmBI5RAKNvv7wWJEuqaFl 2btbDk32rlAnAC6E0THIRbSzVsM3GCajppAmCI3UPFZ13P97ftvK+SfwZx2KsBvx+Y5lLZ ldikkapFRb9Kp5+i+fGAdxudTBLwahXhZ+IBNP2AF5xRsuDYXpQeurWpIhADocM1DKtiIC KVgo3C5OtjzocilwC5xW+MBZDLtoxMeXxkB5HuIO5aZaCvWfV76j9UKXjG6+Eg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 11/21] staging: media: tegra-video: remove unneeded include Date: Thu, 29 Dec 2022 14:31:55 +0100 Message-Id: <20221229133205.981397-12-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555502995506748?= X-GMAIL-MSGID: =?utf-8?q?1753555502995506748?= There is only a pointer reference to struct tegra_vi in video.h, thus vi.h is not needed. Signed-off-by: Luca Ceresoli --- No changes in v3 No changes in v2 --- 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 Thu Dec 29 13:31:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403008wrt; Thu, 29 Dec 2022 05:34:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXubVm8KvdDCS2gXI80XHLXxGo2Qdq3q1YV+RxsLLmGYjpK2s3RVS0y7qhvM5J+bkNpv8Gq+ X-Received: by 2002:a17:903:1091:b0:185:441e:222a with SMTP id u17-20020a170903109100b00185441e222amr27026013pld.37.1672320849515; Thu, 29 Dec 2022 05:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320849; cv=none; d=google.com; s=arc-20160816; b=Ju4Bo9OsqJxVKa8O6qm+sChtNfp0RZa5dpn6ECjdG9e12exFJLx5UQ5ZdCv0ZK9ZQ3 SOxOHDe6994u8nALaFjRjVqBCBWR8vQY4VLzR2CHX/A3TLIZOdUM+pdt3haBIO0JE8N+ LtzCe8ziuXPSQmE+QHHNu0EUwqTP06Id68F4OAJYZfq3rMuEETOIM8S3iyRijErM6bAQ YDTM6fagZNkg7c9XO5tO9HTmPwapCbHW8J28dlUptvMGpXfxUugxI3oFMjL0IxzfRfEw Qcla8mV6gtMlMRHEXEKsy5gcOWLptJKBE8fHC7jS9rpbm9RwFMGXDoG+SlK/x3G7sKKF womw== 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=QfVO7AZAqiYLzD7p45tSKrIhpVD/geNGM0ElIJ2Gj3E=; b=yUL4dxg/CxOXbY+qX0MIi76iWmaVpV3fw+eoo0JhB4PKYc0TrcPUV82kT4vArSfN0D dZYEAHb6lM0o9vamyKQHsCmLUun+Mfb3iijlHM9LMjaVldEq3KfF7VBs0xX4gZENUJFU vUQHxUYt9jX2wRxDX+ZEzWNMrzp1ktpUVdPrEOgGYX691YLs/FdvJJJ6U3yOme6nIXcz 8eMy3U6+HL/q/2qZzJSAjm74eAePrbKaTHGOv/3+79NuB6kbHk9VF/eNEhvt6h/TW1Hg s9p/3Hcwdt3jHpKBJCwvIZY0gVHjUAAIC2ooi93xsIpEqvTsOm74Qf46iohsfcl9ljt/ mB6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hUJ1YvTr; 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 a17-20020a170902ecd100b00188f0ca6838si20570382plh.569.2022.12.29.05.33.57; Thu, 29 Dec 2022 05:34:09 -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=hUJ1YvTr; 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 S233536AbiL2Nda (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233442AbiL2Ncu (ORCPT ); Thu, 29 Dec 2022 08:32:50 -0500 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 390756240; Thu, 29 Dec 2022 05:32:49 -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 7086FFF804; Thu, 29 Dec 2022 13:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320767; 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=QfVO7AZAqiYLzD7p45tSKrIhpVD/geNGM0ElIJ2Gj3E=; b=hUJ1YvTr+vM7giGxSR71JfxFiibfTv+I4udvv9swMdkMw6kub5wVMADusVZJycjTI08Ie8 QM6e3xQIyYH7VwiUHriFfheJi8W/NxgYwpp6PgSiu7wJkrhBDLqLWPIYhlJOLU/SQ+aQLC RxD3AcRkcF2o7daa6C1+7P0Hit2u1aNs6hizknpsnTUxoGgbXj1/4vo9Aar/agVmLtZxPv hdvQSO6sBqZmjJmmvEIpL6WK9JyjMxgwxNpMU9heG4rtFbqP4D6+TvkOh9c2tSeWSEA01M 7tc9QzqlHaO+eThox6OU1/E7RXm2FQdexUeUE8S+N9OJ9k95EVYmEQJE3LFBBA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 12/21] staging: media: tegra-video: Kconfig: allow TPG only on Tegra210 Date: Thu, 29 Dec 2022 14:31:56 +0100 Message-Id: <20221229133205.981397-13-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555507333708923?= X-GMAIL-MSGID: =?utf-8?q?1753555507333708923?= 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 --- No changes in v3 No changes in v2 --- 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 Thu Dec 29 13:31:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37398 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403040wrt; Thu, 29 Dec 2022 05:34:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXseMexehAy7wM01LeUv4kYknddH4pZzd8SCqJx90kUvLHXIKNE0WQCTcH/2vB8EfozLCXiR X-Received: by 2002:a05:6a21:3a46:b0:9f:3197:bfa1 with SMTP id zu6-20020a056a213a4600b0009f3197bfa1mr41429766pzb.7.1672320853888; Thu, 29 Dec 2022 05:34:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320853; cv=none; d=google.com; s=arc-20160816; b=hvmUkoku5koQ+I1LwIJKCaXjX5FCwZ4WZI/vGIz0M3ZlbiQwuaD/mhrXw9jvFnr8uU uVw672wSRY5uFo719BMFD+84mNxm+g4stjM8XNhNCwtbCl1qSMa7FTvmKS/pdbyiziUy X9hnVAuXQVS2zaG/YrBwn+ZIVczsTDe8UZQ5/P8JgLRc+34ifda6yyszSI9xeud0KtP9 G0eM+tPU35h4odMw81v5sM589ufmvZlrOOMM7bY//GkOQ2Y9BLYmwggrRd2/ZVOV+8Gw k5/C80JnXHoQ5lS3eHJsZl5xd4M+OtYBh1k6AI3ELAkU9ZzJ7B6ozRC9KpAsOh2+ZAG3 jOKw== 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=QpUjnvA46xMmwBUkncn2h7nPkRlvlM4H0yLJrPdnIDY=; b=khB6Y28iwQCTUxv+Mvl59g+Hxxru010k0Mpbb4gZlGxpqic9LO7pJJAAq2U8TjiOls E+e4hKYn1NV7XZqtD8dejECOUgGf75OdrfaL+TK2duyhsYRfcajUHsU3eZEcbk0zmbXG dGSWxzaSfrk+J9yV5YzICaOZrNMGCI/AeB7SL0TwF8+BEMsC2qu6renN0V1r22inrvs7 9rRz8IqIOXNmXI8T161T6S+4mxOp8lhmy+y+5XX79+zGtPTYHHDzLv8JZnkfuvTqrTXw TuYfuhKLsCYES2kyVsvyIgGuzUppNtdkJk8XU6py/XnMFv+xn3I6tDlhtGT/wHuB8PKE rFhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=AMMT6b6F; 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 n3-20020a6546c3000000b00498bfb45cffsi11540395pgr.797.2022.12.29.05.34.01; Thu, 29 Dec 2022 05:34: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=AMMT6b6F; 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 S233542AbiL2Ndd (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233467AbiL2Ncx (ORCPT ); Thu, 29 Dec 2022 08:32:53 -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 A2BE611A27; Thu, 29 Dec 2022 05:32:51 -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 ED55AFF80C; Thu, 29 Dec 2022 13:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320770; 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=QpUjnvA46xMmwBUkncn2h7nPkRlvlM4H0yLJrPdnIDY=; b=AMMT6b6FL7g+tbwa4eMyRNTGBa6YqjHzIj1YpVk4HeyCa0wim3fR0KyOuQFSi1Y4lZdnmS qxlD+RLe0f730qieL8vbkOQQQM0Zvw/Aam8i6+YOgsawuP8wwlBwKrTvu5T223YziApf0+ NnQy3C+BtEgF7lsTCkAXCA/zT0BGAnH16l7/4C0Jk0um2Oq7tkO8OHN2TlgGBnfqiaO54T 4QcoEcniuNE4+mxnlUFoHm3XWyB/h8m6DkfsAFXJDDGFnUBpSGZvGC5pulcnSGufVuDL3S DGG+7/FZrIUYyQ42VJRsCS9R8HSaFwAe4IbH3cIQTJS8YaSU5AaIQdUcbGxSzA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 13/21] staging: media: tegra-video: move tegra_channel_fmt_align to a per-soc op Date: Thu, 29 Dec 2022 14:31:57 +0100 Message-Id: <20221229133205.981397-14-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555511401986475?= X-GMAIL-MSGID: =?utf-8?q?1753555511401986475?= 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 --- No changes in v3 No changes in v2 --- 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 4e48eaa0fbdc..a76cad0e3026 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 Thu Dec 29 13:31:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37400 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403233wrt; Thu, 29 Dec 2022 05:34:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXtWH43gSbg721VZfBgABqlDfSSsob8cO+yx4yPsJEUi3ajZIW+LqRukBgXpRMtgvLjN47eH X-Received: by 2002:a17:90a:e516:b0:225:a520:e0a2 with SMTP id t22-20020a17090ae51600b00225a520e0a2mr29499574pjy.21.1672320878601; Thu, 29 Dec 2022 05:34:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320878; cv=none; d=google.com; s=arc-20160816; b=0h4hfuFXVeoDfmLwJsqQTnlldZSAthYCtpOe1wcBdWFutaE7hCMhSwliqCtdmgdP4T KPqVbY7zhxZsqbOQ2YZCNeTzhYq3DZv2eixR2fK7xBX/RfgKc83gM6EaJ8k0JwURTSCo OgqINFKrBm7fj5KCgalUj5PfzfSEZM5A4G8uSGPYu7QYFgIpoW8GoiDdzKhHmGVTxo3P 0Rd+CL4drrxwszyWDxQ4EPCeX21LBsMt9GAPuLnHyNUaSXVxotWEBbR81YyB7w4ps1fj hvlmyLsEUdOX2XBzWcXGjq7bhnRjrtdTjAAnmFv00SrYrqhjNDaEUh+uSnW+JtuaGcTo ax5w== 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=kZf6SSI8l57BVKe3J2dXVrQAA+mbF4i79MlGylHRxzY=; b=iirTAGfCXM8hbgw/GeJq6xGdjnZ6VaPBYkb4lmoX/iVB3+sWmpEk5VV0OWwvfbzDkS esUcqrqftFnFyBog2VnRtnXBpJ9UKmjWfpR8M+uolkMDJCO1EAhcMegkWaQP/ak/11mg GFmeIyi+4OF9Mjg7widps+Mpw3RBBH5h5dMTmb7+dQrLlJxY6XhSEoKtQVEGMAIBXit5 2zTqwUSm4ff4WvBODSdTYQULLlmWs5g/xZfmozWWD+LNb+MsALgdpXvo8mTQoJi/RKg5 p1hnZecINxOoGvSvEtQWepvR9i5jRcYs8KucMEvRGSa2Nskdnk/8Dghz1ZHycyLaJtk1 gfCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kCyu6Q9Q; 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 q92-20020a17090a17e500b00225cb856740si15669653pja.59.2022.12.29.05.34.26; Thu, 29 Dec 2022 05:34: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=kCyu6Q9Q; 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 S233559AbiL2Ndo (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233492AbiL2NdI (ORCPT ); Thu, 29 Dec 2022 08:33:08 -0500 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 50FBD1145D; Thu, 29 Dec 2022 05:32:54 -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 A6E1BFF816; Thu, 29 Dec 2022 13:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320772; 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=kZf6SSI8l57BVKe3J2dXVrQAA+mbF4i79MlGylHRxzY=; b=kCyu6Q9QCaWvbjmkNtXQItqLRk/ykSO+yUYX3ASC400D4CknoS8Q3DzDuTKaUO2+095NED 4QsDLEYyJ1aj2kQSAG90O46MF7rT9X1MSWC72E5+l/nZtbYig3G3z/P07lm5hSiDKo2IcH jqJZnaKyRDIbGHWNCA3tTX3O6Gv5qw4EnwXI+5pdmFNjRjE5IDeiAmiK/ySMmu9vvFkYX4 p6riBhot3F3itmrSzLeqVWVdVA8UDnqiQkYJAOfqW/EQYVCZcXvKqAHjGC5YnJut2eLHK9 6o46k/Jb1yqtE13eQATvzlJXBb4w6jxxWe7mOgVcxBWc5gunSJoRFGVuPJLUnQ== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 14/21] staging: media: tegra-video: move default format to soc-specific data Date: Thu, 29 Dec 2022 14:31:58 +0100 Message-Id: <20221229133205.981397-15-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555537213401002?= X-GMAIL-MSGID: =?utf-8?q?1753555537213401002?= 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 --- No changes in v3 No changes in v2 --- 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 a76cad0e3026..3762fd273514 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 Thu Dec 29 13:31:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37399 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403225wrt; Thu, 29 Dec 2022 05:34:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXv5p7PHBIQbprXiukEF2RypzeLKiKOdWFlmDVNZXbsmQ+fGd+LAMmaz/PQsw3sneWwWM80m X-Received: by 2002:a17:90a:4308:b0:219:6626:3b63 with SMTP id q8-20020a17090a430800b0021966263b63mr32115371pjg.25.1672320877808; Thu, 29 Dec 2022 05:34:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320877; cv=none; d=google.com; s=arc-20160816; b=XzNPjrVEiMu7ZD0r9sS9KwfVnzj8Iv383gfcGwhiKVDXNiEkyOCkhkrkWqszxu67IB sYAuOk8/mFUE9SrAPPkOCg6pYfeLxfka4wys1jY6HcdKfhF21AU9Bs5F4s3cLZY22R1a suH+BZkUaxhPLSxeStdxL7P73Ng3aMnmjrwMExCJNqLZLKIGSIOHIQppfjYaqeahxTrp RnDFc/CTFBdHBefdIKm1nVWZdi24LovwjaOqEx5HZHZ/mbXqhOhkGV8jmw/0BE7YobpZ YV4lYjy8T94/mvnJI7sMlNIYyL3x9NOENAPCY6BVEQNXnyvvg7hM6Vpl/NkPDz0L5V8a CgFw== 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=lGBa+7o6/9r9LqBwEry5jOCjAKB2CmT7ylXiBMEZX0s=; b=axJRIjDumrEGffM3qruNILSo7fdx+T/GEZH/ZQPIoqumbaHAQWv1DhIYQYvYWBcwBZ V5Y6zuzLbOjq+8744RfchETv0rBfzWgXejdCP8+tYGx8niTreREPfw+AEhoqRH9Pj0dj Rpj3xwDEsrciizJAvtj3+dDGwxkXHb2Agg56FGQwfWe0sHSIgIqof/zbgfJMeKcMsDO7 MhqU8ryUZYKUb2vhcAOxHKK72JmPoDX5Bon/ViOqZ4zxqCHqCg+Lt6ad18YiYBekQm38 tHR57UCmd7/+Z4MkyZLgdfhYrB8/yzIwRjiS9zNN6T/1uTFmK0l8gxUy1wHuP8jouMGP lEuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=WCQCJSFg; 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 ip3-20020a17090b314300b00225c475b3d2si18672812pjb.55.2022.12.29.05.34.25; Thu, 29 Dec 2022 05:34:37 -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=WCQCJSFg; 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 S233598AbiL2Ndu (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233520AbiL2NdU (ORCPT ); Thu, 29 Dec 2022 08:33: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 A125D11C34; Thu, 29 Dec 2022 05:32:56 -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 268C2FF806; Thu, 29 Dec 2022 13:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320775; 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=lGBa+7o6/9r9LqBwEry5jOCjAKB2CmT7ylXiBMEZX0s=; b=WCQCJSFg7uXKHV952mRhiEezldySXmzAmtF1wtF7tD3QDUGfeaN8hHsmv5Vlni0905HtuB MLW1NXy1XRhZbjM9TA1zK3yaH4eC38/9IDIa7xkNYjbhPo2KBFhwZ7FdciYmW6+nO41p8M QHCe4NzwYcSG++2SIGe/EfUpK4Qr8LTb9/IR25yJrq5DvdALP8x5skPFdkl7AUbOsb++nZ mSSkdmJH0RCJPaIZqGLqOQLg5DvsV+a7HLqFyqjfrijHZPF2e+tJLC7yQwu/+H3zSBMLhT 7UjdFVHjX2Pg/IvY49UYKR6C/RSaJk3q92qv9tcEyr4hcTDPJVmP+PH1eF/jxw== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 15/21] staging: media: tegra-video: move MIPI calibration calls from VI to CSI Date: Thu, 29 Dec 2022 14:31:59 +0100 Message-Id: <20221229133205.981397-16-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555536918580440?= X-GMAIL-MSGID: =?utf-8?q?1753555536918580440?= 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 --- No changes in v3 No changes in v2 --- 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 9a03d5ccdf3c..b93fc879ef3a 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 3762fd273514..a26eb1ca869f 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 Thu Dec 29 13:32:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37401 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403241wrt; Thu, 29 Dec 2022 05:34:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXteqcMuOB1Z/DNF7FnjOpFkoJ1qNrSLOaxRGzqOU/Vi6ZL/mVGVYI7g+GEaxelSCAW74gai X-Received: by 2002:a17:902:e054:b0:189:da57:be3d with SMTP id x20-20020a170902e05400b00189da57be3dmr26663714plx.51.1672320880149; Thu, 29 Dec 2022 05:34:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320880; cv=none; d=google.com; s=arc-20160816; b=QveerHgz1cHQ783pO4+fFNTBZPHsbbXhPZuuWvc50gZmogJgeylVq0ML5ETNtVuL/Y 9NstE03/3p9lv+8AfWOHDNVBZ03IRRQ8evxiOWsfFzewG0t8BtdxjWJ60yNVAwqO3XX1 XcO+MVjHx8rvg7Y3hsYV8K+fN7i3y+7VQVeQFs5znYAyUUHTxeT9Sy9ln05QVlof5fYh b9M4kEEz/UkQjvdC+5DI44o0nNKHMrv4MyAV+wI9h+RtKrQbkn057lEweSjpM2RDIK6c syfsPWhDPKZ9NldvJA/chM7vfOKR7ZYq4m5KH2LTZbkN5EGRSv0fj7tPoJZ2AxFGGULL NleQ== 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=EZCL6q95y8D550Hzr4bmsZG2h4Gj8Umd37yboOQuCjQ=; b=vq2aHwK+7q2/2WeXv53WJKLU9VqCWa7fFCm8h+ZhafgqiTATBiJatfg5DZagpT4kTj Y8Fp/9kv5MDh6SeyNkatOz41tBbMFMiqCIjBowtlk2t/TASmJHR9/8U6FxGlRyZ2LGWp 8HGt65g+dmWG0615MXGkFoThkPAR0xkbSUjHgINE1mLczw8/7BhkyQmhkyUJyaDtpuVd 0b+DQOLsNPC04Cej+x4b61MGLE026S8M3d3a3LpELd6hHdkN9RlZUrx44CEBxLvCbFJn WLJ+fAZAl/MWs8Df0Fe+M1fhOpmcvc6VbSVxzW4WPvkLSVzxm49Q7Cpe23FMC4EpdLkr hKnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=AoGiwJkn; 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-20020a170902ebcd00b00189b908dd2esi18262533plg.469.2022.12.29.05.34.28; Thu, 29 Dec 2022 05:34: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=AoGiwJkn; 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 S233608AbiL2Ndx (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233538AbiL2Ndb (ORCPT ); Thu, 29 Dec 2022 08:33:31 -0500 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 21EA012602; Thu, 29 Dec 2022 05:32: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 84017FF80F; Thu, 29 Dec 2022 13:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320777; 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=EZCL6q95y8D550Hzr4bmsZG2h4Gj8Umd37yboOQuCjQ=; b=AoGiwJknhnXDqyhyIBsmlxVbtQZwiDP0yFQLlvEbs2pYoFm+oFkJQ4RSVI+JuV3gOGZDXy ulYhdWiJO9Vh14vf31T6vMNjrszmdl2Q+iEFObvvprEn9tgvB0TwV2P31c/ztda1YQfWin mJiYh22/IUlRN0bYc/Nz3EgNYuuVz9uXNiHqCPei87x+ZBGWMrKt2GXNZpdO9D1k5S0zeO anxnA5SvNdcWBnfOMOx4mAn2cHczq2JGIxJ2yb6S2iAKUCLKiVZ3MD3WO89M9xazLUNZp5 X5OYVMMJXsOt3GreeZqTCWaag+CUxw2owybu4IyRTjXhEeOHhQVFds806eIwRQ== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 16/21] staging: media: tegra-video: add a per-soc enable/disable op Date: Thu, 29 Dec 2022 14:32:00 +0100 Message-Id: <20221229133205.981397-17-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555539698894987?= X-GMAIL-MSGID: =?utf-8?q?1753555539698894987?= The Tegra20 VI needs an additional operation to enable the VI, add an operation for that. Signed-off-by: Luca Ceresoli --- No changes in v3 No changes in v2 --- 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 a26eb1ca869f..22f6d6478d3e 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 Thu Dec 29 13:32:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37405 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403633wrt; Thu, 29 Dec 2022 05:35:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXthxDrV6jQzfI8mVQXDJ78GUVOlUEM516El3p3iz/+G/U5+oOku1mS+FOwDDhipmui/SFaJ X-Received: by 2002:a50:fd85:0:b0:461:e82b:be07 with SMTP id o5-20020a50fd85000000b00461e82bbe07mr24091216edt.2.1672320944293; Thu, 29 Dec 2022 05:35:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320944; cv=none; d=google.com; s=arc-20160816; b=pAptgmNuZsqE3rO1wgC1uoRB7E+OMqs/Lj2YwEpLoML9Avs8cVHViZkhJvyKZmykS+ rkp0cZJ0aFuEjHSb7raPjvNt/L0DHaWrkmSJUY7Suz6ADF8iVU1VacBOk8sXsbOek2N9 s2Fzioi12U1FPurkp7tI1jiq3wTcsD8QxwuMAfYUICRl6fdXITw/9bA6OPbw3sdF36cS dSHbTlR2taFppiw20mHYQriUbeTu6eZpBOR4tFQioHYCbxg/sSm9k6CtzVmz8zFVo8Cz SccBcLfz2HSbKb2X0iX/x5/kf3/SYFKIpYG7wm+NHz3ZBemcH6nVTaLbMp9H23wzgErH HDKA== 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=vXyRXdVsDWVqJ/iDjmvWRJtE+m7iy1Cp4wlBRq+rvNg=; b=QnKBxRHzd0WlPouky+y13wNNyBh50uXiCMq65PACeXXEn5aMxjvNSCI0ULaZ/NIwrS rWCsAU7lIDvg3Cw13zLfyG+ePsVhqhPE1/7VVMj0Y9I2gcrW7BJz+M5Sy+qfokYJtsXl caQw3zHM/W1WReAGiSb8uqVfE51P0bG2yztMF5FUvu515m144pEJjwi3BhhC0XEwcBtK cd6ioykY5tZ3FKFADWTlFZyxVJMWoDfG8G59RVwVPIxoQWUAE0c9pIgTNAXL+VjtCbYi /fcM3ZawAtebcuCOXf685Id8LFAv3ml29cU3AaO5vT2ZHTHSbtD3j4q1r/R+0TUguCGH gx4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=EWqDg8ST; 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 q14-20020a50cc8e000000b0046aeca41c55si15133866edi.212.2022.12.29.05.35.19; Thu, 29 Dec 2022 05:35: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=EWqDg8ST; 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 S233614AbiL2Nd6 (ORCPT + 99 others); Thu, 29 Dec 2022 08:33:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233539AbiL2Ndb (ORCPT ); Thu, 29 Dec 2022 08:33:31 -0500 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 878C611C1F; Thu, 29 Dec 2022 05:33: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 D389EFF80D; Thu, 29 Dec 2022 13:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320780; 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=vXyRXdVsDWVqJ/iDjmvWRJtE+m7iy1Cp4wlBRq+rvNg=; b=EWqDg8STf8q3g5vkzYZJfYQ9kcQGGCCB5F96yB2Y/NzVdJD2ufH7NxHy4Kq7AYuuKktvah I0U5EQzLCynDGXmedw14xBMC2VXYYMgKO3P80s7JXnv/WsIS+CJ7PLFluuCtqd1eeJcInD wKvj23DMbZCIV8S4l9PymFUB5PIjqtcVWufwNAUvT1PxjiYw0J+PnUM12ae7PlesAQTwcO j3pRjENlgaFO0TJgJBfE3tCqP1M7qJE39FvF6UT7UBUWyibx5yoKQ01lpjWSflmpE+OVaH lpDc/lOCp3gH2tbxbYN5qftjjZcxBdTdpfDiAB2UMKR88XA647Kt4QQUJNFGmA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 17/21] staging: media: tegra-video: move syncpt init/free to a per-soc op Date: Thu, 29 Dec 2022 14:32:01 +0100 Message-Id: <20221229133205.981397-18-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555606844613353?= X-GMAIL-MSGID: =?utf-8?q?1753555606844613353?= 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 --- No changes in v3 No changes in v2 --- 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 22f6d6478d3e..760606c65a97 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 Thu Dec 29 13:32:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37402 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403266wrt; Thu, 29 Dec 2022 05:34:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXt5yPUnpqnoIhFQ2RG5oDQd5ElB25yyB530S279yewQhAGqatCIl8IilbI4gFz8Q9YDCoSE X-Received: by 2002:a17:90a:6d03:b0:226:3232:2de2 with SMTP id z3-20020a17090a6d0300b0022632322de2mr1983583pjj.46.1672320885229; Thu, 29 Dec 2022 05:34:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320885; cv=none; d=google.com; s=arc-20160816; b=uBcOFaXQwZVUF5KCGfTtdRqUS324Ph17S951ZFbBZzacuM+7Zh5z7l1CBko0+5LKaU fs8xBnbr6YRLyzLKJ/UG4lesIa6kMNN0uigLYPbSSTWyKhf/pRJhyn4PxCucE2qscaCc pCssqbnFIc5MtkvCLuffGcj+7875vyz1mt8GGhb8WPFY5rWRYa3NDDt872Jo9qxkVPly 8MGQJNWm56gZxWyu9OK8MhBkkGdrZZozHRJNe3Iiw0vENrSK6hQKdAherFkhPGisNSwT 4HR5kLNRwyy05TCSx1thBw8UiVoKDCCDzlOEobNOKE6Lf2NZu1Bl9dTjjAFgtOuhUju/ l2JA== 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=CmVEahmNOu/9XkwMiVdBvL6gDHPQH+245qlFUC5ws4k=; b=yd9UxGJWmwy48ep6QHi0VyuXwzraz8PwDz9+DxhWOQGFZSLaSnLEAr4XWmH+rj7X+J RrGUphAK9uatCM3J9Uz71anft4YnEgMgK19oN/CSd4Fz5EbpVCDaCJ2huuuKqd5m4PfD +sMRXcEO+KVPv+8VQ/kpH8gcZrfF8OuEczSubAKZB3elnhIJBYkv0VrYGyAXxbHLTpM4 Es6kW5Rq8R57/HRVmux5XkdS3mPf34E+3P9cD7b5pkXCH0U/oWI6qimM2Gtqc5OR2/ak 2tzz1GmpWeHvfef6FCKg75W4daYCFTjXSP+mmkESClO0NqdXu06gjrcVugAxgxS1rZrE Z89g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=apw5+e6a; 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 a13-20020a65418d000000b004786230ec57si19954823pgq.454.2022.12.29.05.34.32; Thu, 29 Dec 2022 05:34:45 -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=apw5+e6a; 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 S233620AbiL2NeC (ORCPT + 99 others); Thu, 29 Dec 2022 08:34:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233553AbiL2Ndn (ORCPT ); Thu, 29 Dec 2022 08:33:43 -0500 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 2CC6311C24; Thu, 29 Dec 2022 05:33:04 -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 44FBCFF810; Thu, 29 Dec 2022 13:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320782; 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=CmVEahmNOu/9XkwMiVdBvL6gDHPQH+245qlFUC5ws4k=; b=apw5+e6aWCj4dRLTZ1BGruiImviQ2Nozxdv0Zt9IRaT2cggI2CvLG/RdR8P6eEKCJS8Suu u2kZIH+RbxSjpo2pbioNY10citwaaoC0g65Bze8BWzeYq0dDGKIuNrVbv/r8g7lyHgMh8G yi+2i6wK24vxoXxRI1Z2K5ZoezHMJ52dk8BFMsqHgKHTTIbAuTwPMVra3wnMXwUJatGf+H oGqK3rso5948BeoOnuCCYlZSKhraFuOdCooH5D2EB8LCzApNmFJudq/U2r04ERrMIq9fG9 gsU/9f1JMqHeMukH67OtEDfrA0XM7BCPmf1q5vDF7tsGnPDrSm3QBuZd4JrImg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 18/21] staging: media: tegra-video: add syncpts for Tegra20 to struct tegra_vi Date: Thu, 29 Dec 2022 14:32:02 +0100 Message-Id: <20221229133205.981397-19-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555544411964572?= X-GMAIL-MSGID: =?utf-8?q?1753555544411964572?= In preparation to implement Tegra20 parallel video capture, add a variable to hold the required syncpt and document all the syncpt variables. Signed-off-by: Luca Ceresoli --- Changed in v3: - recycle mw_ack_sp[0] instead of adding out_sp No changes in v2 --- drivers/staging/media/tegra-video/vi.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 8fadca33bcc9..d5e1ed4217e0 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 (On Tegra20 used for the + * OUT_1 syncpt) * @sp_incr_lock: protects cpu syncpoint increment. + * @next_out_sp_idx: next expected value for mw_ack_sp[0], i.e. OUT_1 (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,7 @@ 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]; + u32 next_out_sp_idx; struct task_struct *kthread_start_capture; wait_queue_head_t start_wait; From patchwork Thu Dec 29 13:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37406 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403648wrt; Thu, 29 Dec 2022 05:35:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXs+qeoO3W3W55oi386kSGyVq03jc+eUZEhn4oOfLcXa3mkMFzGG6ymk1QSoP7HO39dAloVs X-Received: by 2002:a05:6402:1458:b0:47d:a733:c051 with SMTP id d24-20020a056402145800b0047da733c051mr26134959edx.15.1672320947439; Thu, 29 Dec 2022 05:35:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320947; cv=none; d=google.com; s=arc-20160816; b=Yw9pAHRKG5sRHhHSFf8HV+LDaIUcZ6DyFSG5lHrdYkI4oVXMRKgrmHR/kIQoZK0LSy pA1whXbztm1D2Y75y8d5hI7rLTFS9FOqA+Iq/pTer6SjWNAtCNMqiqPE+VaaD2/qyz6O hMb7LSNju8yvb8ic5eIw8hrYufZvspWvk689cOEcp71lLtQ1IusElN1HqKx0agwTmG1n +cKRvMUj0RmC71cnR4uFUM2kcsHPsv8sI7tVU/u9HjuYCapw+TrDXgbT0qFJuz6Hkrdw dL9yJNMgYIMjQoDgnvL17uJLNpUX9NQmvVq7+OICaAoma2w1c3Dul9Hd2vBYFciAKGnV kp7g== 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=CW64MxchVb9saBnb7wZiFjtE7xT/bCq9uwLuPiV613I=; b=w5S29FYBt619wWahXKSoZFDE8FXMHPKNTvs5yE11oli+tyzp0Kcemi+aH3mIVnPnax xnfRoy8dVL9Tbs1KlEWi73/W9V1/FYiaO6eE6IJnsAx6aFl685x1HqeOUY34SDyBf87K QzOQlUDRu+GSV7xKsm2/+SvZ7tFasFgU89vV7wd16EIcRzO3pQLgYjT3xmbnYB14sPe6 vH1bnd+me78LakCsJa2SVaSXdpHTP3gNtL2YDyGkqHnd5zG3IVKqsj8s1ygQwuazaTfC t/EEZOppEMEyEXVp4z5nKzXDgsOURapUlv8uDo9uxlei9UKwQ8JBvdq2q1ZjLPIp7WT9 npGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="IcrYx/bg"; 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 m7-20020a50cc07000000b0046cd5d896c3si13723862edi.165.2022.12.29.05.35.22; Thu, 29 Dec 2022 05:35:47 -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="IcrYx/bg"; 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 S233659AbiL2NeV (ORCPT + 99 others); Thu, 29 Dec 2022 08:34:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233564AbiL2Ndo (ORCPT ); Thu, 29 Dec 2022 08:33: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 645C512755; Thu, 29 Dec 2022 05:33:06 -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 DEB21FF80E; Thu, 29 Dec 2022 13:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320785; 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=CW64MxchVb9saBnb7wZiFjtE7xT/bCq9uwLuPiV613I=; b=IcrYx/bguyUZYs+cfdCWOZKBpYj9tOyR/uyKoCnbhNn511p6uce8S6pEgH79ipOpwfdfWI PULqa9PHCX62Fy380xq/DcIFGNRnTVbtSM6eUOo10mhqBbycLGIzlmSkzc8Lh7oAqR6IRy fKKsxQ/XagTMVei/I0VjseCFLdV+7jlTZ5khTRvW9KtIjgZqcAqztSyLbB9D4jEMz0BZ5X PIbSqyF33yvcg4cwZ/z5H5r7IhitRZRDUisxuYFXFoD9MPBJH7qGOUUpHmjXYv5218Yars j4B8lo9DAnixhULyqLbMQ67b3d3nV2pfFkIE010b9Pk/tO9kGoIdDWQYy+7J6Q== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 19/21] staging: media: tegra-video: add hooks for planar YUV and H/V flip Date: Thu, 29 Dec 2022 14:32:03 +0100 Message-Id: <20221229133205.981397-20-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555609676809126?= X-GMAIL-MSGID: =?utf-8?q?1753555609676809126?= 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 --- No changes in v3 No changes in v2 --- 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 760606c65a97..4a066b61ab8e 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 d5e1ed4217e0..0503eb678556 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 @@ -187,6 +195,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 Thu Dec 29 13:32:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37403 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403371wrt; Thu, 29 Dec 2022 05:34:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXueazLS0v2RYiwFJaT1E5/Nt6xNNXfu4cBrb/mI0TKqEi44WucjWU2YIHOaRk2TzqJzr/TV X-Received: by 2002:a62:f20f:0:b0:566:900d:5ae8 with SMTP id m15-20020a62f20f000000b00566900d5ae8mr25204027pfh.24.1672320899460; Thu, 29 Dec 2022 05:34:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320899; cv=none; d=google.com; s=arc-20160816; b=eBK3IqaJ30Sr2OdzuaO/KUE+TilllVesZSOyybuaCLuOa7V4ZHASZ3V37VVzPXjEoX kPJRrzRqXGzDhIzKG9UmvHjW1B+eiWXwLWNCoCiN2h/aMP2rxbv1pMUXcnJGp6Om3e9B TQtFnsLRr4OhiCoHqRQKI3NmznzcmneV1mZTCmkuaV2AaoBoNL+NzWMOn3o0tdsbHlUH Fn/inTAmGGj3f99lxhl1g2gCy1gzAv8m/gUGNAZSf/1Y5uWY+R4DW4tnpe5P1XB/Lk8w MAW5wtpz0YgkWB4ICyNOuTPZ+DBjOk5c/IBUh7WBLIAVP+h9y9FAyoz5qz3awmDdf8z0 LIdw== 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=lDh7ovUv1NsjYYG9vHMcYl6Rlz2zcTrLvyA2JBDuVnw=; b=ZJQHz7lWMYNyZGqwUOozHRq9csl//PRjURbmhHIrqGcxgWtXWsHsuRo2Xu0X5A8s48 O5Y4UdDjZrer6ek1Wi4TvoAskDJ1JvuXPLPO3m4WtOUWbWppP7u+YKCc5yd2Im0pxmDi XlSJKfUcXWCCbzhKatN6wu6Fvl6iV56lgE/Udtc/wSm7CFA6eDoeevpGWpqb+oAbHzR1 AvPzupyvcH0W3NgeZRhv4/x1XbthXT9/Eb88lmZtQu34N3vOTEfdRatTxvw5SN4QEUKp xpMKWjpArR27jazAvy1s/5jO7Zg4VjaBbRhQMMEhrwmeJXrOdhAnPBvJJo7jTi2vmEa3 Qf/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=fGSubC0o; 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 i63-20020a626d42000000b005747a147929si18249755pfc.21.2022.12.29.05.34.46; Thu, 29 Dec 2022 05:34:59 -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=fGSubC0o; 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 S233597AbiL2NeY (ORCPT + 99 others); Thu, 29 Dec 2022 08:34:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233535AbiL2Ndq (ORCPT ); Thu, 29 Dec 2022 08:33:46 -0500 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 2AAA311A27; Thu, 29 Dec 2022 05:33:09 -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 5C276FF812; Thu, 29 Dec 2022 13:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320787; 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=lDh7ovUv1NsjYYG9vHMcYl6Rlz2zcTrLvyA2JBDuVnw=; b=fGSubC0oFfhQt6asu+w9xt+fwAuoCz2m40sDh4ZoSorud2DDeMoiObP4ktbgfaZfXJIxIJ umHOYKYtrgjWuTmg7PzyU0d8cyRRxszd8idImAWPpFG1UxQa6Y5ty5/Q4YjUSfnFd/jJ6Q d7EcocMwN9qOSsvyXOwt7AEg8mAG4A1fI4exxU0qXxTyhKwe+aVS8K74nONhs3/C67j294 6HuU6WxrceuuoPVWkYBNMm9kQrjuCoIFiNOxUBnQYxzgxSRD3BhNs7vvbfN4CnVhJLiNbl FEFk93AvRJ8JL/1hqhn/SIvz5T03VNKvaKr7y+8q6kct5zUPHEh28goCDVjFnw== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 20/21] staging: media: tegra-video: add H/V flip controls Date: Thu, 29 Dec 2022 14:32:04 +0100 Message-Id: <20221229133205.981397-21-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555559113019297?= X-GMAIL-MSGID: =?utf-8?q?1753555559113019297?= 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 --- No changes in v3 No changes in v2 --- 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 4a066b61ab8e..d1c6877163c2 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 0503eb678556..8fa817757059 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; @@ -218,6 +223,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 Thu Dec 29 13:32:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 37404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2403354wrt; Thu, 29 Dec 2022 05:34:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXvVWFMqJ4N4hvXEZpaksn93A75cxwcrBjckj2gz00gQIQzuuaQA/4cWjiWu9guuTNf5NO1A X-Received: by 2002:a17:90a:9f96:b0:219:5a12:e1d5 with SMTP id o22-20020a17090a9f9600b002195a12e1d5mr46269435pjp.5.1672320895711; Thu, 29 Dec 2022 05:34:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320895; cv=none; d=google.com; s=arc-20160816; b=c59FdZauCX0J0H3o1JIgDI0VmdZqH4hPrnzJyvk9lor1ZI3IuTbcZCPRQOTlTUqYxi NmZf74jSJGMgqNO8pllN0OnWRSozuCjx4IIjsx9+ETAyZYrxXHt7D2qiTwms6oj60DR0 qykfGlPlDiB3TIBTkeggSfYFL03H4BzXcRURIL9NbU5MqL2MdJDUL4MYclqMQyc6lGIh ogFuqz39nbQ/bUedePj/S7b1Zrq3U2sxmGuXEgSgoKMoWZc6DRqs6DtuhaAbkdr32DH5 giryMYI6NWxiKkB08WTkwAwj37XkLwTiy3KNMkKLcrTN1ypEWZ3Qu29w2WK2DdDs6KdN esAg== 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=nucF095QFaw4f6wI9a0wlRWMl7Kh8AU37AG/342AAzo=; b=KshJK9eeNr4wbNtOAHpc9MVjKeq6LY7ydxmdccKMTPvkQVF5lGFp3ydnv8Rl6XZa9F 7Y7E5odwMZ3MbDA6JgC5Qo8gXcQTWOuLO57LuPSthPf0pzhaQhOhugi48LORtI7HW5zS d3zdbZifA878q+imTptbnGBgr4yPU00607nITV8gjBm6LjkldOlbkG5JuoDj8AAzsuFS IFRt4ZGhQ70lpbXUB6Y7LrwA3rpL3GjCW28ohwyZhZvAg7X0FFNoKUwe/0YFsVI4jxxc 8jnVDRX80agUXPRrU4/O/VXPcmc7aZ9AIk1sfbjj0yD/PRFawj9fWIQWsYPfJRlTbuyK 1ivw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oV48ogxd; 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 my4-20020a17090b4c8400b002191a044fadsi24925644pjb.122.2022.12.29.05.34.43; Thu, 29 Dec 2022 05:34:55 -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=oV48ogxd; 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 S233685AbiL2Nea (ORCPT + 99 others); Thu, 29 Dec 2022 08:34:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233583AbiL2Ndq (ORCPT ); Thu, 29 Dec 2022 08:33:46 -0500 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 C82ED12AAA; Thu, 29 Dec 2022 05:33:11 -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 E578FFF809; Thu, 29 Dec 2022 13:33:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672320790; 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=nucF095QFaw4f6wI9a0wlRWMl7Kh8AU37AG/342AAzo=; b=oV48ogxdluxufePlF3Cus7O3h5eFFF0DTCW1M+02aTQXnGlckQ5FH3c1VMvlKlzMkqjJV1 fXalL93aZ0YcXb7CrV65XotlqXmC0I9k+mwB6pm/nI1mXXxDq8hCacnOII2kQylsdHsv0X ec8XShP1w4KbYvk1kblNUvQPFWA6+zq0E+lQmxJC5+fPao6+fmzmISHehzbQDqud55cZTk r1HpZ1eL0glcCZybUm8mVkAT4yFVRLjsU8s9f0PqB6sQgtyO7q/1/ho4l6KPPacFiCBZRK 5UR3V4dtH4XASH/TUrzP9SyJnXsEgbi3vvTcch39TceJt/GzWjRvx7HI6Qx/Qw== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: 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 , Paul Kocialkowski , Richard Leitner Subject: [PATCH v3 21/21] staging: media: tegra-video: add support for Tegra20 parallel input Date: Thu, 29 Dec 2022 14:32:05 +0100 Message-Id: <20221229133205.981397-22-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229133205.981397-1-luca.ceresoli@bootlin.com> References: <20221229133205.981397-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?1753555555721322395?= X-GMAIL-MSGID: =?utf-8?q?1753555555721322395?= The VI peripheral of Tegra supports capturing from MIPI CSI-2 or parallel video (called VIP in the docs). 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 vip.c and tegra20.c implementations and registering them. 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 --- Changed in v3 (suggested by Dmitry Osipenko): - merged the VIP patch and the Tegra20 patch to avoid chicken-egg problem due to the two modules depending on each other at build time - move tegra20_vip_soc to vip.c - remove channel@0 node from device tree parsing - remove unused variable Changed in v2: - fix tegra20_vi_enable() to clear bit when on==false - clamp width/height from set/try_fmt to avoid returning sizeimage=0 (fixes v4l2-compliance) --- drivers/staging/media/tegra-video/Makefile | 2 + drivers/staging/media/tegra-video/tegra20.c | 661 ++++++++++++++++++++ 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 + drivers/staging/media/tegra-video/vip.c | 290 +++++++++ drivers/staging/media/tegra-video/vip.h | 68 ++ 8 files changed, 1033 insertions(+) create mode 100644 drivers/staging/media/tegra-video/tegra20.c create mode 100644 drivers/staging/media/tegra-video/vip.c create mode 100644 drivers/staging/media/tegra-video/vip.h diff --git a/drivers/staging/media/tegra-video/Makefile b/drivers/staging/media/tegra-video/Makefile index dfa2ef8f99ef..6c7552e05109 100644 --- a/drivers/staging/media/tegra-video/Makefile +++ b/drivers/staging/media/tegra-video/Makefile @@ -2,7 +2,9 @@ tegra-video-objs := \ video.o \ vi.o \ + 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..ac048bbd58f0 --- /dev/null +++ b/drivers/staging/media/tegra-video/tegra20.c @@ -0,0 +1,661 @@ +// 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 + +#include "vip.h" +#include "vi.h" + +#define TEGRA_VI_SYNCPT_WAIT_TIMEOUT msecs_to_jiffies(200) + +/* This are just good-sense numbers. The actual min/max is not documented. */ +#define TEGRA20_MIN_WIDTH 32U +#define TEGRA20_MIN_HEIGHT 32U +#define TEGRA20_MAX_WIDTH 2048U +#define TEGRA20_MAX_HEIGHT 2048U + +/* -------------------------------------------------------------------------- + * 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); + val &= ~BIT(0); + val |= on ? BIT(0) : 0; + writel(val, 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->mw_ack_sp[0] = out_sp; + + return 0; +} + +static void tegra20_channel_host1x_syncpt_free(struct tegra_vi_channel *chan) +{ + host1x_syncpt_put(chan->mw_ack_sp[0]); +} + +static void tegra20_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp) +{ + pix->width = clamp(pix->width, TEGRA20_MIN_WIDTH, TEGRA20_MAX_WIDTH); + pix->height = clamp(pix->height, TEGRA20_MIN_HEIGHT, TEGRA20_MAX_HEIGHT); + + 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) +{ + 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->mw_ack_sp[0], chan->next_out_sp_idx, + TEGRA_VI_SYNCPT_WAIT_TIMEOUT, NULL); + if (err) { + host1x_syncpt_incr(chan->mw_ack_sp[0]); + 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->mw_ack_sp[0]); + + 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->mw_ack_sp[0]) + << 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 d1c6877163c2..eae7b1b30b07 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 8fa817757059..c864d4ef81a5 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -292,6 +292,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 diff --git a/drivers/staging/media/tegra-video/vip.c b/drivers/staging/media/tegra-video/vip.c new file mode 100644 index 000000000000..a282e4b1a48e --- /dev/null +++ b/drivers/staging/media/tegra-video/vip.c @@ -0,0 +1,290 @@ +// 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 *np = dev->of_node; + struct v4l2_fwnode_endpoint v4l2_ep = { + .bus_type = V4L2_MBUS_PARALLEL + }; + struct fwnode_handle *fwh; + struct device_node *ep; + unsigned int num_pads; + int err; + + dev_dbg(dev, "Parsing %pOF", np); + + ep = of_graph_get_endpoint_by_regs(np, 0, 0); + if (!ep) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: error getting endpoint node\n", np); + 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", np); + goto err_node_put; + } + + num_pads = of_graph_get_endpoint_count(np); + if (num_pads != TEGRA_VIP_PADS_NUM) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: need 2 pads, got %d\n", np, num_pads); + goto err_node_put; + } + + vip->chan.of_node = of_node_get(np); + 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(np); + 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; +} + +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) +extern const struct tegra_vip_soc tegra20_vip_soc; +#endif + +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..e192ede83f1f --- /dev/null +++ b/drivers/staging/media/tegra-video/vip.h @@ -0,0 +1,68 @@ +/* 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; +}; + +#endif