From patchwork Mon Nov 28 15:23:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26818 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5749082wrr; Mon, 28 Nov 2022 07:26:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf7c0QR1c5ndrbvLyd3zxwb+0NVvkjKjnmfGEaeJPe0imYujPC47gs0f42C6mJttpwhvonjJ X-Received: by 2002:a17:906:6403:b0:7b2:9667:241e with SMTP id d3-20020a170906640300b007b29667241emr44823143ejm.115.1669649196675; Mon, 28 Nov 2022 07:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649196; cv=none; d=google.com; s=arc-20160816; b=VZFhQ6fER6US496fPgug3BP8FKtPUrKCBOYIT/DKttRLEl908C8WvPxZ8fkx8Cy4li EBFXA6MAmFF7S6NUetyS+IPb/VbB4aOEuvjkcXzAxL3ZTgcfCwFAYUt1kV1Ah+T0aKx1 5cTOWXnzRe8CSZ63mOltI5295lfNWjEo48+nMLQSPMYpw3dHuCjE0WSE3mtsJf/rn/+D Ibms3Um+b1372XWHd7HJ/MwSGBepZMrcLfhVzuwqKnZlJasD12Iqnj/5hOf48uJ84DSX 70Pwj2YcvidZFrCuyzFGAQzeSsb+UV/8qvqwqgT9647oa3ayveDj85aw5gpjK7M0XMgn E5xw== 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=ZKHAg1cVHEhagz6zCtsb8zjr1ngIs6Y68PTvy+DOXVk=; b=lEYt+9emUetYCIR/AqAHxo+lGRZPVBvKrN0/sJdwe01s8Csp/iBdu768wFlNMrZkcL 9CPmb/EHD6JqTRRw+duSMvrtOPm8hRBhLdOska/sYunNfpNydhKnEK/tFOdU/MA/DoMS aruD7cibvJNY/HYNVlFv87ixRSRQv2JBW/VMvR/wd7U89EwOR22Ihp5xNRxeTtSd6KWd ub+hpIksZudNGpIW8P6SgBLhsuV/NGpYX8BcwG5GSlyFIcsmvzQRSuXPvCibm1/TMWEv 1WCtwiAuO+JHkma6lkPazukGGC+pRxjnQYt85a+jDf7dARSWy6XRD6KTcC+76VikIaL6 Fp2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=BeUo6hYV; 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 g8-20020a056402090800b004690009024csi11487365edz.503.2022.11.28.07.26.12; Mon, 28 Nov 2022 07:26: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=BeUo6hYV; 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 S231853AbiK1PYm (ORCPT + 99 others); Mon, 28 Nov 2022 10:24:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231852AbiK1PY2 (ORCPT ); Mon, 28 Nov 2022 10:24:28 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 014CA20367; Mon, 28 Nov 2022 07:23:57 -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 3E8A7100002; Mon, 28 Nov 2022 15:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649036; 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=ZKHAg1cVHEhagz6zCtsb8zjr1ngIs6Y68PTvy+DOXVk=; b=BeUo6hYVFhdXTHv65hQpc0YqNxqpX68WHeUq/wdKu3YJ/al/Nv9Y9OFhG8e8ro21iGjJyp UvgU29eXk4d0z5JOT+dWT36nwdSEVLhd5OdIwba+FnWRmsuDdSTrrNcrf5m0IAEWJItPOV 65LtlT72/Hm7oaYq5mClLm5Zq7GPdFyy9ad5LWL1CSQNhG3rqI2jk2RVVrCXQydELdmYui LTRcotkGB2a4bN3WWgw7tF77GA4yMB3Fh5gXqh8HiMrV7bUV26+thagCmk3S30/CWyKQRm 0qySvMNWAVodKy8LwQ7r1ZuFk1qPncpqPrFHCMPJY5Xp72oB47+1fQFif6m6iw== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 01/21] dt-bindings: display: tegra: add Tegra20 VIP Date: Mon, 28 Nov 2022 16:23:16 +0100 Message-Id: <20221128152336.133953-2-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754075971223249?= X-GMAIL-MSGID: =?utf-8?q?1750754075971223249?= VIP is the parallel video capture component within the video input subsystem of Tegra20 (and other Tegra chips, apparently). Signed-off-by: Luca Ceresoli --- 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 | 63 +++++++++++++++++++ MAINTAINERS | 7 +++ 2 files changed, 70 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..44be2e16c9b4 --- /dev/null +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml @@ -0,0 +1,63 @@ +# 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 + + channel@0: + description: parallel video capture interface for the VI + type: object + + properties: + reg: + 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 + + additionalProperties: false + + required: + - reg + - ports + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + - channel@0 + +# see nvidia,tegra20-vi.yaml for an example diff --git a/MAINTAINERS b/MAINTAINERS index 69565ac0c224..92c762f85f17 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20315,6 +20315,13 @@ S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml F: drivers/staging/media/tegra-video/ +TEGRA VIDEO DRIVER FOR TEGRA20 VIP (PARALLEL VIDEO CAPTURE) +M: Luca Ceresoli +L: linux-media@vger.kernel.org +L: linux-tegra@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml + TEGRA XUSB PADCTL DRIVER M: JC Kuo S: Supported From patchwork Mon Nov 28 15:23:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5749205wrr; Mon, 28 Nov 2022 07:26:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Y/Qv9DTNvILSXPgtamHZ3czSumqATNO5/gjayP5t6tow6e6m4kzolhvIfk3/IIbD2+l/r X-Received: by 2002:a05:6402:2993:b0:462:845:ba98 with SMTP id eq19-20020a056402299300b004620845ba98mr29521278edb.12.1669649207299; Mon, 28 Nov 2022 07:26:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649207; cv=none; d=google.com; s=arc-20160816; b=DpjnnGMRHq089t9zkslBr328U9Lgln3XmYGoKB8DNrOu8uC1gxqAxH0DvoDfmktRCP VFlRJcJ2iJmn2m1rqn0zF3lkEj/sv7Qz0vbUQjaHkayeGZ8uu4kwpSA6cPPkBjNOO5JG ls/kwMSRF3CNTGMP+eeQ9DOi1rGZp5ptXln3IrJUCSD/0QDGMVNio/21WCatGGurVEaO DEsE1xyMEy9gqv0Ziy3xxwQRsl9leZHt768t/1d1JULbLGx+BJl+jMj640XDRABG3DfS 5I76cXSdkEabxqpk6/NWRVyBPF5BH4Pm4ynK9F59ODQgKbXwjJWnqfyPPuROu/pv35cf JacQ== 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=xyo/FmBThIW23NziE2w8WS8gyVQzTbmEFzYd5s8d+Vs=; b=c+mTD7anMFxHqWnMu6zC0/nHYY8X/Al0muFnapwwKLvt8jHq1FII8G3Ftp7yqUyH/d pe8FW67PZ8qU/Sf8lVlKecLd47AfYkbUbqwr7RzuiK7qprg6QQG2yWa6K+7TlCYqLBjT 2s5I96NUUHtKes7xdHPQJUCETw/3d/ZwAsaDahwGRJZg2sWi8MXtHlvpEOf7jANLGtiN VIZ3oriGd+pNtx+pwgZrGIk0bFDplovEBFtlqKRcIXdqYUWKDQYCx+sHfVHizDlhKiIF M7NaTHAUTdTNGv639jRZYkikk9+f0IW7R5rAKReNCC1EF/5Mqmp0478yUGrXojaYX+JR wH3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VfmhFJx4; 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 h4-20020a056402280400b0046b10fbb20fsi4346013ede.13.2022.11.28.07.26.18; Mon, 28 Nov 2022 07:26: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=VfmhFJx4; 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 S230076AbiK1PY4 (ORCPT + 99 others); Mon, 28 Nov 2022 10:24:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232056AbiK1PYc (ORCPT ); Mon, 28 Nov 2022 10:24:32 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 921E223BDE; Mon, 28 Nov 2022 07:24:02 -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 CD248100004; Mon, 28 Nov 2022 15:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649041; 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=xyo/FmBThIW23NziE2w8WS8gyVQzTbmEFzYd5s8d+Vs=; b=VfmhFJx4tj0FHpwNIu1sXRL0zxnfhpXFFMKmdYkyVUisG4JjvSRapvWfmkxtPvSEN41fM/ UFprOsV0J+7Tiv9lYHxDn/5/iJqsJ92c74U7gYZj6yTd5nHS5vY3Kx8fM9TXcUYP5JnuGj Tu6IVyjSJJX0Qna8QrWJb4C6pgUeAuIqxYUlRKklf3+7DXDQIeRhJjI4gjYG/CMZxc1gzc 47QbYNURSsQogl4YBg+d/DumyLAzjQs/KliwZEKX9RUWlMmUMgf0D4bldByEazzBIPbBPT nOLkhJ6i+ss3mLC8wlenZbH0lam30NeaiO1fdyo+yBO9u0tbClNUoCkS76kJwg== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner , Krzysztof Kozlowski Subject: [PATCH v2 02/21] dt-bindings: display: tegra: vi: add 'vip' property and example Date: Mon, 28 Nov 2022 16:23:17 +0100 Message-Id: <20221128152336.133953-3-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754086891779464?= X-GMAIL-MSGID: =?utf-8?q?1750754086891779464?= 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 v2 (suggested by Krzysztof Kozlowski): - rename "i2c3" -> "ic2" - add review tag --- .../display/tegra/nvidia,tegra20-vi.yaml | 68 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 69 insertions(+) diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml index 782a4b10150a..5b5583c2b562 100644 --- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml @@ -74,6 +74,22 @@ properties: avdd-dsi-csi-supply: description: DSI/CSI power supply. Must supply 1.2 V. + vip: + $ref: /schemas/display/tegra/nvidia,tegra20-vip.yaml + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Input from the VIP (parallel input capture) module + + properties: + endpoint: + $ref: /schemas/graph.yaml#/properties/endpoint + patternProperties: "^csi@[0-9a-f]+$": type: object @@ -109,6 +125,22 @@ examples: #include #include + 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 +148,42 @@ examples: clocks = <&tegra_car TEGRA20_CLK_VI>; resets = <&tegra_car 100>; reset-names = "vi"; + + vip { + compatible = "nvidia,tegra20-vip"; + #address-cells = <1>; + #size-cells = <0>; + channel@0 { + reg = <0>; + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + vi_vip_in: endpoint { + remote-endpoint = <&mt9v111_out>; + }; + }; + port@1 { + reg = <1>; + vi_vip_out: endpoint { + remote-endpoint = <&vi_in>; + }; + }; + }; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + vi_in: endpoint { + remote-endpoint = <&vi_vip_out>; + }; + }; + }; }; - | diff --git a/MAINTAINERS b/MAINTAINERS index 92c762f85f17..0c97ce22735d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20320,6 +20320,7 @@ M: Luca Ceresoli L: linux-media@vger.kernel.org L: linux-tegra@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml TEGRA XUSB PADCTL DRIVER From patchwork Mon Nov 28 15:23:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750732wrr; Mon, 28 Nov 2022 07:28:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf5jigzRUDrztkkueIgpl5NSQDhCNguFmA708rX7PWd1C591WN+kppWGqE/dNQm79giiNUZh X-Received: by 2002:a17:907:989a:b0:7c0:7bd1:6436 with SMTP id ja26-20020a170907989a00b007c07bd16436mr2704828ejc.718.1669649335481; Mon, 28 Nov 2022 07:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649335; cv=none; d=google.com; s=arc-20160816; b=ai3j0u7aMDLzmpPQYZ4CEgXEOzwWv+TaaDhX0rO6/iEiFiI/KBjr404aEWnPM4dRhl 93F75xTjjUa8GNw1WHScllkYmFbdkkLl+B1BYeszJPMYEQx5RA8bHuJ50yJWhcmzKru6 bV7kJVQAHW5mUYiQ1Gq/b4fb6fnhZHyS6oWK1yuIkxYir8CBTeRO7yfLVgm+PCQmB1WJ sPyv95WvGLXGdhdP999v+lXgcFroqVEoxSUf8wuJai60h1YpN2Ez2+UfRmhq+ZPsjadI 5lWRR55GhsFc9wsXsylFOEIgOvGOlyiucrpwBUxcACyR0vbn3k8Z4PILvfGGRaNatlI7 EGTQ== 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=bPx4tBfw7h+gvsEPNb76cRKwFVYUpeaYbykLmUstGkw=; b=PugzEfYFeZMZdCRbjWiOBgtt8F99MVtMM/8jtt18gUHldqt2m/ZWCvqy2onS64qvfQ BX+DjQFIKJvoCoWR5zdzuZ2ga8/K1KNESwmVjSrFOSCeX1fwaCp807Ckyp7YRmnHQj2W hKNlcyJo4N26hAlnUQPIBMU1n7MRXuUVz3jWZ8B4tszJoNejqur4uoJkVA5WZ+FpJHKR AEIOAVK9zVrPBInl0KPtnCmYX19XkufIQBK0pAfsnd5WqqsPOkVCpvAPgXI7nyOxllg9 Du5X/nLWlOe4CaLQgdEzRqZuMrfrWhRdPI2gtzTc5FNSCFz96JP16qyhzXtnBWhQd0Sh UMKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kjQw2nZm; 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 i10-20020a05640242ca00b0046453c385e4si12787462edc.365.2022.11.28.07.28.29; Mon, 28 Nov 2022 07:28: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=kjQw2nZm; 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 S231856AbiK1PZQ (ORCPT + 99 others); Mon, 28 Nov 2022 10:25:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231472AbiK1PYm (ORCPT ); Mon, 28 Nov 2022 10:24:42 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73828248E1; Mon, 28 Nov 2022 07:24: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 B9D7A10000B; Mon, 28 Nov 2022 15:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649048; 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=bPx4tBfw7h+gvsEPNb76cRKwFVYUpeaYbykLmUstGkw=; b=kjQw2nZmpzWvV47Q8nEaUsV0ORj3ynAsAhaeVn+fffVJ2xInY+ahcLjklYKWP+hF7RuisI CB4AUefXpTAAzCit4sk/AbzyWf00e1a4j1um275MAEqGBCAymqfRco67WICoBka+cC+5wt c0JQaszFd9ldtCVXBqDh/KUxvOZdhcaPko727MLSxCDuj6NoJGTsMItga8oJfqm8pckKZW ANisFPuuKgsaUwNie0JZe7BfY1XeyEoo2p0hW8nafFS0n5CFNgDzEGacl+5npR0ecaoaq3 wPhktVbNiTh00I72kN+pgJw1e0BCMjaI8mwCJwfec5fipk4O/iSPh7PjwrFwIg== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 03/21] staging: media: tegra-video: fix .vidioc_enum_fmt_vid_cap to return all formats Date: Mon, 28 Nov 2022 16:23:18 +0100 Message-Id: <20221128152336.133953-4-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754221699799280?= X-GMAIL-MSGID: =?utf-8?q?1750754221699799280?= 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 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 9d46a36cc014..0fe3c7f6d234 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -3,7 +3,6 @@ * Copyright (C) 2020 NVIDIA CORPORATION. All rights reserved. */ -#include #include #include #include @@ -73,15 +72,6 @@ static int tegra_get_format_idx_by_code(struct tegra_vi *vi, return -1; } -static u32 tegra_get_format_fourcc_by_idx(struct tegra_vi *vi, - unsigned int index) -{ - if (index >= vi->soc->nformats) - return -EINVAL; - - return vi->soc->video_formats[index].fourcc; -} - static const struct tegra_video_format * tegra_get_format_by_fourcc(struct tegra_vi *vi, u32 fourcc) { @@ -430,19 +420,12 @@ static int tegra_channel_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f) { struct tegra_vi_channel *chan = video_drvdata(file); - unsigned int index = 0, i; - unsigned long *fmts_bitmap = chan->tpg_fmts_bitmap; - - if (!IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) - fmts_bitmap = chan->fmts_bitmap; + const struct tegra_vi_soc *soc = chan->vi->soc; - if (f->index >= bitmap_weight(fmts_bitmap, MAX_FORMAT_NUM)) + if (f->index >= soc->nformats) return -EINVAL; - for (i = 0; i < f->index + 1; i++, index++) - index = find_next_bit(fmts_bitmap, MAX_FORMAT_NUM, index); - - f->pixelformat = tegra_get_format_fourcc_by_idx(chan->vi, index - 1); + f->pixelformat = soc->video_formats[f->index].fourcc; return 0; } @@ -1059,78 +1042,6 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) return 0; } -/* VI only support 2 formats in TPG mode */ -static void vi_tpg_fmts_bitmap_init(struct tegra_vi_channel *chan) -{ - int index; - - bitmap_zero(chan->tpg_fmts_bitmap, MAX_FORMAT_NUM); - - index = tegra_get_format_idx_by_code(chan->vi, - MEDIA_BUS_FMT_SRGGB10_1X10, 0); - bitmap_set(chan->tpg_fmts_bitmap, index, 1); - - index = tegra_get_format_idx_by_code(chan->vi, - MEDIA_BUS_FMT_RGB888_1X32_PADHI, - 0); - bitmap_set(chan->tpg_fmts_bitmap, index, 1); -} - -static int vi_fmts_bitmap_init(struct tegra_vi_channel *chan) -{ - int index, ret, match_code = 0; - struct v4l2_subdev *subdev; - struct v4l2_subdev_mbus_code_enum code = { - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - }; - - bitmap_zero(chan->fmts_bitmap, MAX_FORMAT_NUM); - - /* - * Set the bitmap bits based on all the matched formats between the - * available media bus formats of sub-device and the pre-defined Tegra - * supported video formats. - */ - subdev = tegra_channel_get_remote_source_subdev(chan); - while (1) { - ret = v4l2_subdev_call(subdev, pad, enum_mbus_code, - NULL, &code); - if (ret < 0) - break; - - index = tegra_get_format_idx_by_code(chan->vi, code.code, 0); - while (index >= 0) { - bitmap_set(chan->fmts_bitmap, index, 1); - if (!match_code) - match_code = code.code; - /* look for other formats with same mbus code */ - index = tegra_get_format_idx_by_code(chan->vi, - code.code, - index + 1); - } - - code.index++; - } - - /* - * Set the bitmap bit corresponding to default tegra video format if - * there are no matched formats. - */ - if (!match_code) { - match_code = tegra_default_format.code; - index = tegra_get_format_idx_by_code(chan->vi, match_code, 0); - if (WARN_ON(index < 0)) - return -EINVAL; - - bitmap_set(chan->fmts_bitmap, index, 1); - } - - /* initialize channel format to the sub-device active format */ - tegra_channel_set_subdev_active_fmt(chan); - - return 0; -} - static void tegra_channel_host1x_syncpts_free(struct tegra_vi_channel *chan) { int i; @@ -1501,7 +1412,6 @@ int tegra_v4l2_nodes_setup_tpg(struct tegra_video_device *vid) goto cleanup; v4l2_set_subdev_hostdata(&csi_chan->subdev, vi_chan); - vi_tpg_fmts_bitmap_init(vi_chan); csi_chan = list_next_entry(csi_chan, list); } @@ -1721,13 +1631,6 @@ static int tegra_vi_graph_notify_complete(struct v4l2_async_notifier *notifier) goto unregister_video; } - ret = vi_fmts_bitmap_init(chan); - if (ret < 0) { - dev_err(vi->dev, - "failed to initialize formats bitmap: %d\n", ret); - goto unregister_video; - } - subdev = tegra_channel_get_remote_csi_subdev(chan); if (!subdev) { ret = -ENODEV; diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index a68e2c02c7b0..183796c8a46a 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -163,8 +163,6 @@ struct tegra_vi_graph_entity { * * @ctrl_handler: V4L2 control handler of this video channel * @syncpt_timeout_retry: syncpt timeout retry count for the capture - * @fmts_bitmap: a bitmap for supported formats matching v4l2 subdev formats - * @tpg_fmts_bitmap: a bitmap for supported TPG formats * @pg_mode: test pattern generator mode (disabled/direct/patch) * @notifier: V4L2 asynchronous subdevs notifier */ @@ -205,8 +203,6 @@ struct tegra_vi_channel { struct v4l2_ctrl_handler ctrl_handler; unsigned int syncpt_timeout_retry; - DECLARE_BITMAP(fmts_bitmap, MAX_FORMAT_NUM); - DECLARE_BITMAP(tpg_fmts_bitmap, MAX_FORMAT_NUM); enum tegra_vi_pg_mode pg_mode; struct v4l2_async_notifier notifier; From patchwork Mon Nov 28 15:23:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26837 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5751209wrr; Mon, 28 Nov 2022 07:29:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf6HxYCjV2cWUkwnMuk0x+iTS9HMesaTLzozw67hFhMkdrHp2gl/j79gTtlLiAcP7fFHk66h X-Received: by 2002:aa7:c04f:0:b0:45c:f13b:4b96 with SMTP id k15-20020aa7c04f000000b0045cf13b4b96mr13345102edo.129.1669649377141; Mon, 28 Nov 2022 07:29:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649377; cv=none; d=google.com; s=arc-20160816; b=KDdeiRj0DiqXsOjGkG1V5tPCmq3K5YYBDr7huIHSHGWMjiktSWeGarKBoQevLHFRNu Y691Fw2urdFDzgK/zUDvx99ThQe9qn7fH9gP/P4VqlomUCmv4QsqGoHP5kaK3KnSl28y MdAWn61LVwMcES2qEPpacBdQnNzOrN7SkfZ8/ZpCzPzTKMfwy51i8iEFXZNylBasrWKV XpVN6tUt2bSy+roMTeqVKKig+C8lqfr4snhZ6y8bzqVqrbGe/hE4G8U+Sh2/ngzsYS+1 45ZSdUI+wbgC511GN7lGXKKqPCciEniE7gdWvZ4OMtUUseo+1SchIBtjXcOwsuJaj2vG eIMQ== 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=gl15CMrLV9vsbPaK+roIAuV2iVcUDUEVC8Co3Fa64Tw=; b=wFOfqQrTRCPUjMEkeBJFPj3GU7/4DasVYi4TQt6Q8KqulLs9yFmwb0nlBAOgj2BDGC 5MndrCa2uIiXFPYb2+X+fQD6EjNKi4ymxtKSxmXcRg+OS9+MP5VYib2J/TAuaAqDqECs Dc7PrFKge7eO/iEaoQN6bE7CyHtYCl8ot74aG3EJQOB+EtCerbG8azdYtWxGsiSsRp4l HgQ8yf1QShhBQB3c5XUBkpfb6Gh069WiZvOevy+weU11Ew96ahvkjYOTNP+fPHJzh+kx 3rRYV4JW3UfHXnaMCJYk/wHo29nUgbY/L0q84B1Ad4ND8GE6+X4Qac5Vl+QvfcmeAjlt On5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=JcaxoD+j; 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 sa24-20020a1709076d1800b0073866c0672asi11547143ejc.73.2022.11.28.07.29.13; Mon, 28 Nov 2022 07:29: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=JcaxoD+j; 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 S231917AbiK1PZb (ORCPT + 99 others); Mon, 28 Nov 2022 10:25:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbiK1PY5 (ORCPT ); Mon, 28 Nov 2022 10:24:57 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF9482495A; Mon, 28 Nov 2022 07:24:15 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id F310610000C; Mon, 28 Nov 2022 15:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649054; 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=gl15CMrLV9vsbPaK+roIAuV2iVcUDUEVC8Co3Fa64Tw=; b=JcaxoD+jtOTUia4RUNIlp0lGRono/OPNcAE/+CmDa0K8UH9gd4/czBa8FoaqIrxOYIOr2z wiAT/jQLxCpJu1VEGRX1OrPUm/8B3tjj7/WcxMPt9B+ZdUW00EqVlLbKQBPjNPsuZ7P81c Dx+eCxNOMBHU9gITrAZmHUc3tMC9tFzx16mjST6tt+1q8NHwKbwHH0+ZE9tfC2dI8Tl6zv Sm0A7g3cvPcRifrggvZq8rf+56dLA7xixfOagpR9YHS2wEs9z6H6VOtq5Cqigx3d9jRoX9 zVGD8QsPHPTOfEoqTIhnfTiP1b83YxBojgnp8hL4L5XlqsNabpBV63zkhU6+ew== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 04/21] staging: media: tegra-video: improve documentation of tegra_video_format fields Date: Mon, 28 Nov 2022 16:23:19 +0100 Message-Id: <20221128152336.133953-5-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754265415056761?= X-GMAIL-MSGID: =?utf-8?q?1750754265415056761?= Some fields are irrelevant for Tegra20/VIP. Add a note to clarify that. Signed-off-by: Luca Ceresoli --- 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 Mon Nov 28 15:23:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26820 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5749705wrr; Mon, 28 Nov 2022 07:27:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5aUkpQ4YbMA3NMayKmHUriR9OCAJHdBkVVZnKySnr8IXFGDdpb0D9dvuT3YXHiGxKpiAOA X-Received: by 2002:a17:907:76e6:b0:7c0:543a:5229 with SMTP id kg6-20020a17090776e600b007c0543a5229mr3451324ejc.58.1669649252100; Mon, 28 Nov 2022 07:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649252; cv=none; d=google.com; s=arc-20160816; b=YcWVcvmMtRHD+oXr2tsUC5nENA5qTTMZIMziMlLpU05luD48qwmRfl5RZF194E3KdG pRvmnV/R1qseLIjuMvzH7t65TiNexHBjh5V9Em/TZ6tSOppwKYfQjmUDVzSdzi9lMkMG vHas19f0dP+zXXHuhncaAX0+FzoEzn7QdS2aumpPBGZ39j8wpx4cy3dXaacKRL5k0xhJ dlWxTAdICUbiVDIzr2un/tY4S+byiMQPWwM9Xe9q0oy3OPB9IyTHL/+bWxSbBkDnZH4d TWspOZ6EL5DC8N9zEb/DWWBZcXaA1d8lhW/4m0Ov4J1+7KDw0RDHKZggAQT+W+3BNwlK giVg== 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=RoMDwf3xqKYueuSpR2HfCTCREn/qoJjq+QmVjrebPsE=; b=O0gebn8TH2U9goTlVmqamQfM5SheOk0nno3zQIs97xh6XOx/DXJEmGf7OEPOa5xWAS ncPsx6kZDzyllf3T9cOtZOe3tkfrub5et0Badfrs8ys/Wd6/SC+iqAf4Jme2frduYNB9 CBbwu1Gg0X8IGYChy+5gXpa4hKXuWDgoQfwNU8Oc6I8A69II/0a4FPKm0nnM3rPuAANo /0K87yGqwH8Wh6JhJZmvp678Ht/QWFZXvm/lbkkrPsmbmLaIYfHowtopt3BpC/Z/4Ups t1/murS0U+85lI9L9fpMm3DVBvLwsabzYrUy+rLITD1T5YXIcIU1QVzAX9vuoBz1Xqt7 RGrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mmGQEmMV; 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 ht14-20020a170907608e00b007ad7e81a30csi10067777ejc.167.2022.11.28.07.27.05; Mon, 28 Nov 2022 07:27:32 -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=mmGQEmMV; 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 S232091AbiK1PZw (ORCPT + 99 others); Mon, 28 Nov 2022 10:25:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232003AbiK1PZM (ORCPT ); Mon, 28 Nov 2022 10:25:12 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8121324BD3; Mon, 28 Nov 2022 07:24:20 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id B75B8100006; Mon, 28 Nov 2022 15:24:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649059; 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=RoMDwf3xqKYueuSpR2HfCTCREn/qoJjq+QmVjrebPsE=; b=mmGQEmMV8d3XHqD1H8VmQoYs68HeMrY7q/TucHaOrkeVwbWWr/khMJDOoSi+pD5sJDbBT5 hg4De2APQO1tZN+xoYlh8NfOiTLG9oC2MmhWErTzfsX4olF9nF9mq8xDaOAxCsjJ811LeM 5HCr/+tVzMRbppr4b6GaD+R9lZzv2wX/pliD/wevIASIoICmbzV8U0Jj9uISuwgbITKDST 1OpS25XYCScDlSlU4D8rRGmey0+WUdnYPO2FXKLV6nZgMd28gR96bz1+5MhZMcZ1Gf60rZ 65K7EqsJDsGnn0K3oErzgxy79eG54sAwGiOEkG/3shbrzTAZbVGoaElaXBg/pg== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 05/21] staging: media: tegra-video: document tegra_channel_get_remote_source_subdev Date: Mon, 28 Nov 2022 16:23:20 +0100 Message-Id: <20221128152336.133953-6-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754134385670091?= X-GMAIL-MSGID: =?utf-8?q?1750754134385670091?= Clarify what this function does. Signed-off-by: Luca Ceresoli --- 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 0fe3c7f6d234..8a7512ce2273 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -154,6 +154,9 @@ tegra_channel_get_remote_csi_subdev(struct tegra_vi_channel *chan) return media_entity_to_v4l2_subdev(pad->entity); } +/* + * Walk up the chain until the initial source (e.g. image sensor) + */ struct v4l2_subdev * tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan) { From patchwork Mon Nov 28 15:23:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5749998wrr; Mon, 28 Nov 2022 07:27:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf4X7pzRDIll0seLht2qoaJ9RNbKVPB+tjsiVTrAQHcY1KuSaMcT9eIi9HCI0u4YwKeBkmKb X-Received: by 2002:a17:906:60d0:b0:78d:3f87:1725 with SMTP id f16-20020a17090660d000b0078d3f871725mr27596467ejk.492.1669649272790; Mon, 28 Nov 2022 07:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649272; cv=none; d=google.com; s=arc-20160816; b=Z/CAKifXZF49BsukQT/MM+Qssueyr8CPVGIJ9ARlaB88IzxbuH1SR6IkD9sJ0YL62N XcKbYZJQ7E+vCexAsLU3zXDiPw0U7OkQ4sSTgxIOWx1px8XGoByDSnVzDAz6/mVCle1M mqAdWOEjHW1qO3bf3dJrylLQK1y5ndhar9iRXAZNEXEkYlxObLGIyazYutFJ6G7186fR RLjvIoh/CMKDWgC3tJ/LD+SVxq3yqorNZ6x1YGBbVuH/pF9RnU2RDaDWcatRItrdP8QG m3cffJiua7ZqCMDLpNCOKXbDAuVh0dOgISbUnk5L+wq7fRG0tPabFJ0Zyh85ek2hMHSX KSxw== 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=xURqg5VhnwpWjIFhJeVPGCVtr+haaQvdgkjCNGPG9f8=; b=t7sCaplRXOqIUBGQbyQ/KcJaiecUWRJEjQZfF4PC6s2V4I18Mjk/MNQnEY1g2u466j +5mrOnyAUQ5TZArGTvXtnODbn2iVHTp8u9C/KGgMaxyDb7gvq9Z8w6aWY5S4PytbBWnK Qut1tZjczn+ivSy+u3qVWLmTFBHBAO1r3JIOSJyJ+vYycOGCcCWgDPJdQk0y/Vrx7LGX iUIvJ7aZ/L9+o8Kyj7wV+e44Dm5FPE62NEbjb6GLKeGWs9jHRvOZDIHQwZWuTy/tfrZh j0fLigXvEyuurUo5vHbeEUyiGScsrLWZcrQZz2OP/DbsivX2lXyi340fS90IwJ6xCN99 X+NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jVYFNWHq; 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 js18-20020a17090797d200b007807e1ea26csi10667338ejc.637.2022.11.28.07.27.22; Mon, 28 Nov 2022 07:27:52 -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=jVYFNWHq; 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 S232208AbiK1P0X (ORCPT + 99 others); Mon, 28 Nov 2022 10:26:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232046AbiK1P0C (ORCPT ); Mon, 28 Nov 2022 10:26:02 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2F1CBCAA; Mon, 28 Nov 2022 07:24:36 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 5FD1910000F; Mon, 28 Nov 2022 15:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649075; 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=xURqg5VhnwpWjIFhJeVPGCVtr+haaQvdgkjCNGPG9f8=; b=jVYFNWHq+sJjS7uz59THV4bh6mQnodC7z6V/HeqtYVk19/PWhr3CfgtbuE5/Gk80yr9NWX Xh9ypfvpZdVy/j8Ms/UgNsXY/cG09cRREuwahll5Xi2WWNGYfLu8G6ubPcCgmlYpjvandq yp0XJqQtjKfBjxbyU9gAoA12KjT8GAfX4Ucc1/gx9Pgb9367tx4P850y23//ElUCLmvoj4 LQwjVeS/KbIsf/3RI+dMQsM4s3lrs3bGP7kRLF5UpnL2mTQk4ruE3g2btcOOcsJIwnKMSe 7f7x9X7aYHjRaPwvHhweyBnyfsgx4P3stT2BijC7AwZP2mUxZZ7bXym8/sxkMg== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 06/21] staging: media: tegra-video: fix typos in comment Date: Mon, 28 Nov 2022 16:23:21 +0100 Message-Id: <20221128152336.133953-7-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754155392262012?= X-GMAIL-MSGID: =?utf-8?q?1750754155392262012?= 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 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 8a7512ce2273..b24b9353077f 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1762,10 +1762,10 @@ static int tegra_vi_graph_init(struct tegra_vi *vi) * Walk the links to parse the full graph. Each channel will have * one endpoint of the composite node. Start by parsing the * composite node and parse the remote entities in turn. - * Each channel will register v4l2 async notifier to make the graph - * independent between the channels so we can the current channel + * Each channel will register a v4l2 async notifier to make the graph + * independent between the channels so we can skip the current channel * in case of something wrong during graph parsing and continue with - * next channels. + * the next channels. */ list_for_each_entry(chan, &vi->vi_chans, list) { struct fwnode_handle *ep, *remote; From patchwork Mon Nov 28 15:23:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750067wrr; Mon, 28 Nov 2022 07:27:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf5EnVHlGJvSdKfp1CbIp+j83ajU2P3m8tH/mKsGt6PvNADkTnwObJrftT1GCBKEHonSqx5j X-Received: by 2002:a50:fc0b:0:b0:46b:5812:a03a with SMTP id i11-20020a50fc0b000000b0046b5812a03amr2357314edr.91.1669649279282; Mon, 28 Nov 2022 07:27:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649279; cv=none; d=google.com; s=arc-20160816; b=t2HnAE76aQ0Du1gD+UpEcw4A5NRFXONjk/+WTNCOi48diJh09QUCtIT09D7amRsm+u cGEF+3gIbGvDSB+BqnPNB+MQvVNfmCuxOveIH244usSvSsoCoMk2S3JGae7L0MQRvy+a aeKB+MXOpehrLuy04dSsisSOTQyyWhIYTbZWFd4O+QQ4tRFHvPQM2wVhKv9DhW8cbfDU WbUYQgHCU0JUWUr9ZCHACODmX9+bHDF/gRyn6n4P2cBN7OjTK3CgQRRoLR3MP3S5SWC4 4cyS05Ji41T7ACn2nAD8LiH+wJzK7MdrOGgD2f1cvHHw3yIlPYHgZlqtYL+OwnGhGtjB 1E0A== 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=J271X6sQL9QKZKy2Whlnvafa/eus3qhzYlvnxAfUjx4=; b=ESBAFYep/ZHPXsfUybjJ4gPLbXsChsbOL1olaaIDtUDyxSNh6C9XNqos1DGZW/MuE2 B9jHdOptCkUefXAk90xVMSykF9kXZxJLgQ0jOMIuYA2xQqnGbem6YJLozApZSL7GlSlg okdYg8dxTRdXuoR9DrU6cdQGtglnZTT/3zDovP+K+ElmkcPtNDjcTtVrzpi+wQPUeoYP dZ71nQMZs0HSTEm2tj0OOgUNS9aqWjJj8Q21pi63pfmsvfyrxKNKXmJdODlN2qjDBhhY lsGZEoxhZnkB9GUYh91zFfr5Vz03RltvVgEnnZkm/xcB6nRWFWx1IV6elXr1gV7NdIcY OcOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KlaNEP9t; 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 b15-20020a056402084f00b0046453c36c4csi12595037edz.513.2022.11.28.07.27.31; Mon, 28 Nov 2022 07:27: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=KlaNEP9t; 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 S231701AbiK1P02 (ORCPT + 99 others); Mon, 28 Nov 2022 10:26:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbiK1P0G (ORCPT ); Mon, 28 Nov 2022 10:26:06 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F541252A2; Mon, 28 Nov 2022 07:24:45 -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 8628B100004; Mon, 28 Nov 2022 15:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649083; 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=J271X6sQL9QKZKy2Whlnvafa/eus3qhzYlvnxAfUjx4=; b=KlaNEP9tZOiHw7nNF+L1AK3syIXiKdGT3edGbAZ+kCUMKS/rqgSLt/hIogg5K/uU0Iv5NT KPe8LTa4lWCiiQsyoa3CejGA6Uis0mwlWlPgt8SMwY4DSWYhP99wI4NntEwVzGTTsNQwjU FEx4S+LxBDuPHqPCHiJHYnVxsTS7ff8AM+2X4njaLzTeHWtfetV8Gazgwyh+/FY0ToIAc2 y6cQCKMAZh5v6Wz1Ta63j9LC3E94MMjTGm7uUHdtnZ1lLWHuFJg6KORGYZBJzsmBqaeoVd /sK9Kf7el1iRv+bDEqXJVJ01mhbB5XjdsaEizz7XeTBzfWUzXVfjgZEO+plgpA== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 07/21] staging: media: tegra-video: improve error messages Date: Mon, 28 Nov 2022 16:23:22 +0100 Message-Id: <20221128152336.133953-8-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754162826675801?= X-GMAIL-MSGID: =?utf-8?q?1750754162826675801?= 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 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 b24b9353077f..24de4ed1eaf0 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1272,7 +1272,7 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) ports = of_get_child_by_name(node, "ports"); if (!ports) - return -ENODEV; + return dev_err_probe(vi->dev, -ENODEV, "%pOF: missing 'ports' node\n", node); for_each_child_of_node(ports, port) { if (!of_node_name_eq(port, "port")) @@ -1824,11 +1824,8 @@ static int tegra_vi_init(struct host1x_client *client) ret = tegra_vi_tpg_channels_alloc(vi); else ret = tegra_vi_channels_alloc(vi); - if (ret < 0) { - dev_err(vi->dev, - "failed to allocate vi channels: %d\n", ret); + if (ret < 0) goto free_chans; - } ret = tegra_vi_channels_init(vi); if (ret < 0) From patchwork Mon Nov 28 15:23:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750349wrr; Mon, 28 Nov 2022 07:28:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf61qg98KlAjwxLxi6HmoV7bhWJCVsrT+Z39GP0OBqeUPf/Qa88BI3xm9QD3MY3QqTOBoxEl X-Received: by 2002:a17:907:a705:b0:78d:3e6b:d402 with SMTP id vw5-20020a170907a70500b0078d3e6bd402mr27942213ejc.563.1669649300026; Mon, 28 Nov 2022 07:28:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649300; cv=none; d=google.com; s=arc-20160816; b=Qmm8auZlwt+/pZoib2WQxoSjp0OFhs5lmYXxnQAIK/CXvWqDOTnyEMjsFJcClIaPmZ HlVFO86e7Us63wgRysXxuvJDLAQKDmOg5ZQaBrdBiiMLo+6w2SfEkT8a7x6dI0twPXAR YXSTMaU/wvvRegdWjZhEdACjxwDiVPH0XXjRD8z5m86ynL+vRlzCr5/tmeQSmox4NY4y 4e6rqK3hhXUoqqoi3amQCuy2m1tq6qx+FLWuikfEF/FM2tpPAue9xtR9+GE0Vq+k/kil lZOm4tEeVEJN8K/yQpGKge1+67sW3EhnAygFMLgrFI5giSMXYmRnbnYe3jymXJycoD6U 1lVw== 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=eZduwFmDHtlgeg2+JJFukQVp7zp/Hiu/ppOmNookfL8=; b=P4SWVME9lJeoc7/c7pO+LQiwDnJkYIJWh8oc0BFP7kkUhMi+ijiZrO0CMiRkUysoNo v/tMy5UJw0KBG4Lc1sPvWglEXLwAcLpPF3dqtY+gI/7mSfXlMR+sKAMftwiC/sNiUx/f UDU3gY/KNAimTR8jhAq4pm5s+1w4BefsqqPe+rhMkJmAwZxhn6h79Ut+swupGJ9XRNo/ 1VDzRyWaBVu4j3Za3wm24l2f2Owj4e6ZlfkWbbXCHjzRkCq2Np+6o/trZ1tHcaiHLxam 3HFztzXR6QnXJ+V21XCYexNOP+6Yygj5aza/Ccqk2+lTsfP0c0EEq7VjRwKO821gLdJa hkww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QOEPE5eR; 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 dr17-20020a170907721100b0078decbc3f73si10489375ejc.460.2022.11.28.07.27.53; Mon, 28 Nov 2022 07:28:20 -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=QOEPE5eR; 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 S232037AbiK1P0i (ORCPT + 99 others); Mon, 28 Nov 2022 10:26:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231974AbiK1P0K (ORCPT ); Mon, 28 Nov 2022 10:26:10 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABA5223384; Mon, 28 Nov 2022 07:24:50 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 69BC3100008; Mon, 28 Nov 2022 15:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649089; 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=eZduwFmDHtlgeg2+JJFukQVp7zp/Hiu/ppOmNookfL8=; b=QOEPE5eRfqnQ3j613rQ7mMZuJ/rFEB12Hl+JJqJQOH9Z+xA15tht4tK6thY9dHGLiU7ZC7 y5+PiJhtcy4noYvoSyj8giSSz1v2hn6qDVReFuSM1eFZ7kio8JnxsqfUv5z1OKzJSO4emr giBxKdtqbeDivPv8IkgDVH/EsO2kWA1c6I725kyByrWjuMyiwxCosFsMTS6x+dHGoLB2sU 0XGHpKzIE4rZi+PSTW4EmJS8JoEdl2LLMcN1ajlHNN7GZ20WalhBwyw1306Foo/3EmpNg3 21EMsfQg7U0HtuBEnHN9zlSK6kc33eLVkeOhOiVy7gYTNACuu6ZpkVTIpVeH9w== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 08/21] staging: media: tegra-video: slightly simplify cleanup on errors Date: Mon, 28 Nov 2022 16:23:23 +0100 Message-Id: <20221128152336.133953-9-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754184700519579?= X-GMAIL-MSGID: =?utf-8?q?1750754184700519579?= 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 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 24de4ed1eaf0..2657207e5b7d 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1263,7 +1263,7 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) struct device_node *node = vi->dev->of_node; struct device_node *ep = NULL; struct device_node *ports; - struct device_node *port; + struct device_node *port = NULL; unsigned int port_num; struct device_node *parent; struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 }; @@ -1286,7 +1286,6 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) dev_err(vi->dev, "invalid port num %d for %pOF\n", port_num, port); ret = -EINVAL; - of_node_put(port); goto cleanup; } @@ -1309,13 +1308,12 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) lanes = v4l2_ep.bus.mipi_csi2.num_data_lanes; ret = tegra_vi_channel_alloc(vi, port_num, port, lanes); - if (ret < 0) { - of_node_put(port); + if (ret < 0) goto cleanup; - } } cleanup: + of_node_put(port); of_node_put(ports); return ret; } From patchwork Mon Nov 28 15:23:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750461wrr; Mon, 28 Nov 2022 07:28:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Fx480fwr076R2oXKs9V2tq5mZQHwpzv12QDiGB0TDTcaLmQrGr0uegcFCeVCaK5s2EgX6 X-Received: by 2002:a17:907:2a10:b0:7a7:9b01:2a6c with SMTP id fd16-20020a1709072a1000b007a79b012a6cmr44107263ejc.153.1669649310108; Mon, 28 Nov 2022 07:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649310; cv=none; d=google.com; s=arc-20160816; b=o2qqsIaraSJkgPDGIi1/K/4zyQkOIfICdaAWZfal22KpzbopOelVvW9K3tbj6NxywP SujLzxEgFV53lbPc5S/JauQuD1zBpykp7SKYffKcgEim8BxVxfRxFdxqNyjbaJdajjDE zpbv6wQBbuWGeLuGZ+ZqBYPJYemwCHzqptbO60sPaAB9RXaYhZ0hMvyF1SfHjAdpQVbC cPGvqau8E4+adQSL9WQGdUVHuuYWluca6AyHpedel8g7IYChmg4OfXW/Im6zxoa8GdFO EI9ylT7s4QMOsvPUtU+lCrRyrbdzE8LCUPCf4dQ/s8AUr4wnDuwz9GGEe/cBw835HbRR dTWg== 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=EgVAaPNMJa89SI0rNjqHrlIDAE7eORtVFsqm8m2Ny+g=; b=TMyVBsXKvE+zpS9R3OKUXbed57ffUWrR9Usz/Wnr6BAhgbOzp0W0uWzo5yngxbMMAJ 3S2qPV2Ld7jMrxCvwJuKOL/0LF/HpajI2mBIo3qtAXo1+ry+Fi6VwdQ2B7k3dsHoZrJT 3IAu8IFAaL93plsrccy2SgG2ywZqptjWfARMEZrjK+9VXHbGPYvoIxqQbx1HDKuEkOmW ThNqIGu2jevWuQ1iL9hTMVN4Fp6g1n/9wEKCXaC+A+2UjqDbirzF3ffGuk3xAUC3km79 8PGzk1awQHPCxjyJVow4Db1m2YfyGK9uFn+xxXL3HRMNOZdROPmhWlFt5c8xWcH0dZO0 tiwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=WUrJKg9y; 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 hq29-20020a1709073f1d00b007ae29da29b3si11702943ejc.731.2022.11.28.07.28.01; Mon, 28 Nov 2022 07:28:30 -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=WUrJKg9y; 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 S231425AbiK1P0l (ORCPT + 99 others); Mon, 28 Nov 2022 10:26:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232087AbiK1P0L (ORCPT ); Mon, 28 Nov 2022 10:26:11 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A70AA25E82; Mon, 28 Nov 2022 07:24: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 DCC0D100006; Mon, 28 Nov 2022 15:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649097; 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=EgVAaPNMJa89SI0rNjqHrlIDAE7eORtVFsqm8m2Ny+g=; b=WUrJKg9yzZ9NkoBqASH+lKBV0cype1yTj8T7j+hkookcsGFW/g/E2W01bYccLE5OVRR6kc FnMbKA74Fl+OTsb7Z9E1HHq7NcQZLY+KXfN0kaXo1V/5d8REQGbOIDRM9YOyc3Jo/caoIU CitO7VOwYMpKDfuE45PFXe2KjydQBANpYbJXDbjQKj0Dn5hI85GmJ69aqWe4qSf8USMsIj f+LQo5ZAW8o3IWBR3zX1xkmHIqofnvrtH45WSC5qMWi4aKnkp6CkHNK5M47J+aPe9dhsh1 D2pCbaw4aw3A2At9xVe68RNkMj6BoJRUWZiSpiJhPYr3/Gj0zbVghLvc4eVEMQ== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 09/21] staging: media: tegra-video: move private struct declaration to C file Date: Mon, 28 Nov 2022 16:23:24 +0100 Message-Id: <20221128152336.133953-10-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754194945459324?= X-GMAIL-MSGID: =?utf-8?q?1750754194945459324?= 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 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 2657207e5b7d..55a135bef1a9 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -31,6 +31,19 @@ #define MAX_CID_CONTROLS 1 +/** + * struct tegra_vi_graph_entity - Entity in the video graph + * + * @asd: subdev asynchronous registration information + * @entity: media entity from the corresponding V4L2 subdev + * @subdev: V4L2 subdev + */ +struct tegra_vi_graph_entity { + struct v4l2_async_subdev asd; + struct media_entity *entity; + struct v4l2_subdev *subdev; +}; + static const struct tegra_video_format tegra_default_format = { .img_dt = TEGRA_IMAGE_DT_RAW10, .bit_width = 10, diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index dd35c3ac992b..dfd834a69848 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -98,19 +98,6 @@ struct tegra_vi { struct list_head vi_chans; }; -/** - * struct tegra_vi_graph_entity - Entity in the video graph - * - * @asd: subdev asynchronous registration information - * @entity: media entity from the corresponding V4L2 subdev - * @subdev: V4L2 subdev - */ -struct tegra_vi_graph_entity { - struct v4l2_async_subdev asd; - struct media_entity *entity; - struct v4l2_subdev *subdev; -}; - /** * struct tegra_vi_channel - Tegra video channel * From patchwork Mon Nov 28 15:23:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750532wrr; Mon, 28 Nov 2022 07:28:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf4W85pfz2spZS4e3jMMsAksxdVAPjErCP9pgEu0Yv1/si70vzhb1QarxgG7MOAL2q0u6Vui X-Received: by 2002:a17:906:a1cb:b0:781:fcf6:e73a with SMTP id bx11-20020a170906a1cb00b00781fcf6e73amr42947854ejb.352.1669649317208; Mon, 28 Nov 2022 07:28:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649317; cv=none; d=google.com; s=arc-20160816; b=tPSrrMZZooCHORS0WDFd4Lyqh6vcQL9mI7NVoVz1fNTfaDkxet8in73PWHcl3LM0hF aSB9K+yODKZxyxZDHuvkXxPgSZRAT25AMO+PEAAJK0yYxzg/rr87GnqPm1XXPIccZgLJ rO3fwk85ei78fP4hSogCwwaV90dmICSuJKgcMiw9W0c5CV+uu5830hrqEnXWI7GusYqz 6snwuUDUGhzddANnCD0dD8UDeeM5KYlEcVmcOzV0784ltCY46+Ov6UOmEnRtjHgDz61r 4vNLxhaixNf2ygbuvRudpmgti3acpzkv1zxUs03gSEgs02ADfX17YpleOU6MY61rrzut 57NA== 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=Htge0wtQQvYLlWXFmvq8n3+3IQEsvyaTThTVMkcCXaE=; b=jNqFUh6f0p/m9coEidVRXBUIOX4SM9LcQAXqzEXPsQxCEwNdm6ib/qwx+rosWTUovW t8BNdvxM+X8fV2hNDpO3pfKhwHsTJdFdP9Z0fwzBTT9Tc/eWV3RNpR3ErfQELYhzmlL2 CtMy46eyrmiQf7iULkxZWURujSXWukUHR3j06NxYxK+XrqAeOPmnnr+OP0EWNk1vGuai kFg7SfMUlTBcF7Zo7cepgG3ZK44Ga7KQGqm5hqHUA9tqmv6DNwe81eAbn9deyCYkjMbi kwAQzwxU+uKAJ50dkUx5tLoyqbUJiIzpZJjKbt82/9QSv9FR1iuFL0tUVshciqJXetFt lXVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hAkG4pyT; 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 v12-20020a50d08c000000b00462f85ee700si10664572edd.65.2022.11.28.07.28.10; Mon, 28 Nov 2022 07:28: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=hAkG4pyT; 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 S232308AbiK1P0x (ORCPT + 99 others); Mon, 28 Nov 2022 10:26:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232013AbiK1P0V (ORCPT ); Mon, 28 Nov 2022 10:26:21 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6416F2657B; Mon, 28 Nov 2022 07:25:03 -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 6854810000C; Mon, 28 Nov 2022 15:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649102; 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=Htge0wtQQvYLlWXFmvq8n3+3IQEsvyaTThTVMkcCXaE=; b=hAkG4pyTCIhF/6NAagPJb4l3gSP6gMxdSn9GS5vYhnTn6qjc7yh2f5t18WR3uwlBk+lI2Z 4CBcffSDuXmyLcOIRtzrJqTaZkUa+gkL7HVVHydK8nF/VEjQY2V7azFG7Ugx/MF48f5N0G gm+krpdO+FI7Aiz0yM+79OIA7D2/5gdJnhUyXELFXBhcWo1fo/144Egqa6di2u0GLP1h53 pwr8GQBBRXJldFL/tXdXN7g1CVCt8rYnIFkJeKmojHBUj496FCnipH6/Lc8E2o8drtfYCC lZ1gozOwBUrt7XJTr3EKoKM+CTx+cWOK/mMCpWMMQhtCTsVkcUj5q+1xadcZow== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 10/21] staging: media: tegra-video: remove unneeded include Date: Mon, 28 Nov 2022 16:23:25 +0100 Message-Id: <20221128152336.133953-11-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754202315378079?= X-GMAIL-MSGID: =?utf-8?q?1750754202315378079?= 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 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 Mon Nov 28 15:23:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26844 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5752100wrr; Mon, 28 Nov 2022 07:30:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4eGgOiu75F9vY65vHgzwNTe/0cQTuLQAaYEjJA+rtpTPEQBGOaXnK7OE6CpZvHdj4MxA0q X-Received: by 2002:aa7:c042:0:b0:462:2f5a:8618 with SMTP id k2-20020aa7c042000000b004622f5a8618mr48155235edo.42.1669649449974; Mon, 28 Nov 2022 07:30:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649449; cv=none; d=google.com; s=arc-20160816; b=A1rAZzmU/5w8WvLeipZXbZNPvGFU5dA8gFKEXC+Fo+SVuiNmX5uaOoal6mOn1KEfNR ZVqJP8IBuBVbjogqSQdOcQlfwqjUnmF9ueHDBIdF4NLUSkMiNY8qzDBm4o/F7evsrX34 UOWz5PHno5Gl3VGEXMsfp3jiL+19ehteB8XJWGCao++ZeJ0/TLaBHheykep/LgOKzijg cAVN10w1kxEKSUhDLrcxlnC2A9+BXhv+VDHO1yKbRaYXFBSnbLm19BaUY3CwAxvGeJTu zlz5JtY+vy/5LPSFBpjvgzH4kAhT+gmVf5rVbjmAJCWps7WvBZydhbwDQ8Ww2QjDsd/F pT7Q== 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=7GBrmkxGUxB90OXm4GjTfStVLla9ZUuwuKwKG2o+/lk=; b=pHdHL4mC/fMXFanzHWMCH3ry7mqpU43nKwvJyFlTL6ddo1cn1HLMFKwqw7ZcAIUurv cIJMg6sU6GGJhwYEpzhgam19Kwr6PQ3BG1AdVxg6Me3K/6EZGW+cbwmowr3wrSIQ5U/d 8NbXTLoSAIlMvgkqQ2mZpUc47ACHYWG8khe26rV3o5H8onrh8oh9FKTyWycTft3YUG3p UEajzQcMdCck/dDzEMoVp8lFach6yWs7YMWS5Qw/xKPWkVXmlz4UHPtIQt398fvkJgY4 JYBI5pDvwrByuhPW9kXly6hyDbExP5qL8MrYG7pXTvd4v5u1NTMdXQvxAhXvlp/7skmo kybw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NXeyMEmb; 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 hc13-20020a170907168d00b0078debc9d30esi11650924ejc.29.2022.11.28.07.30.24; Mon, 28 Nov 2022 07:30:49 -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=NXeyMEmb; 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 S232080AbiK1P1H (ORCPT + 99 others); Mon, 28 Nov 2022 10:27:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231843AbiK1P0h (ORCPT ); Mon, 28 Nov 2022 10:26:37 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 035DE240A1; Mon, 28 Nov 2022 07:25: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 DE242100019; Mon, 28 Nov 2022 15:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649110; 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=7GBrmkxGUxB90OXm4GjTfStVLla9ZUuwuKwKG2o+/lk=; b=NXeyMEmbp4qKoa/ZO0xNT9bueu0uHpG7m9N/wxlNvQx7rXHiM/b2a1/Nplufw8q4rHIMfB A/7onnKi+/WXuoxBPDZ7rMnD0UnGH+6kJPwiHGHRfm1vPjJztl8hcnFDPD0+aN49H7jCW2 cMvxGuGUmkZIaEu5bkD4+1IQIhTvEDiQUCGEPuMUuD1pGaHAK4O/FD2RfoFgKV8UODeLNZ kj+Y/sUiZG0G0KsYU69qyghSXBYIiY2mnetog3tsK8B4M5g6q22wMNVQVJFfBDdHgJuth1 IqxSKqUZWjTy/6Go+b9r+q2IyuCnwRIxDl7QsMjwwdyiA9rEaBJH8gwaSNSYdw== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 11/21] staging: media: tegra-video: Kconfig: allow TPG only on Tegra210 Date: Mon, 28 Nov 2022 16:23:26 +0100 Message-Id: <20221128152336.133953-12-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754341153828454?= X-GMAIL-MSGID: =?utf-8?q?1750754341153828454?= 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 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 Mon Nov 28 15:23:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750999wrr; Mon, 28 Nov 2022 07:29:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf6kWR5kWmzJ50SKmIJkOiBjRV9KkYsCrV4JDMxCxJm3ooJOE7kDPrZJD21g5qEL3GHx6OsY X-Received: by 2002:a17:906:a084:b0:7bd:f57f:76a4 with SMTP id q4-20020a170906a08400b007bdf57f76a4mr9169304ejy.413.1669649357947; Mon, 28 Nov 2022 07:29:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649357; cv=none; d=google.com; s=arc-20160816; b=w1PCqaYQ8tU4ne/AuWVEGiChLzW9kbQw2nFuflI4vYuzlrxYScE6P8aYIe/hdySfK0 caGYymVEjznTDZH6h46vL9s9Lvq/yc64581Owv0RwX8xfL5wSB7riHd22DVT3kH6n+M9 AnLchRX/DyD3F/dnkBNqLz3Od78/qL8x0WOpwTRCStycSmCbUNJTqMM8pnwHRCJQcsrH GbOVGxLRFIfQD0QtVciKQWW4EsqvfzCPECXLT17dH1MwOi4QMvWz25sZiyCLn4v0+Zjp D1pprb44q/dk2I5GFPsjgIUlym6iL9VaI+oA3tiW0eQX5bO8koFvOngSR0UqRsghMI7g 4gkw== 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=aXLPFC0kycNRZx/bctD3Dn2zkVipVfkGhwxHoAJIOfU=; b=WXOFVR0AWijAWlV2t18b4on36+sfD6OjM/nG35EpvTZJxgt2IBp/nlwJLa3er9rmQ9 e37uEikO7ROinQYCXK1pSCoRYmqPdFefVnFcLgP/doShDbSdK7KIxdsSPFDmK0dITPG0 N1CjRJcfTquiIPSmhcMP0a6M1jINA4LdYvlBIZ8z+aDFuAN+vYBJh1pCqNB82MCgmSXn tNwp7at+isX0W72TaCJOnz0W5zdST++FsrNNpl0QB5dDnon113ob/6z9JiHcYX1bBHwj CkKaFVlVj/8VOMSpLt+Ysy1S/xNCAEW9DshDNdPsFAGdEV+F9VDmerHpAM0slCccpGEu 1whQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=InmxmfBe; 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 w10-20020a05640234ca00b004627d582888si10415856edc.24.2022.11.28.07.28.50; Mon, 28 Nov 2022 07:29:17 -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=InmxmfBe; 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 S231263AbiK1P1R (ORCPT + 99 others); Mon, 28 Nov 2022 10:27:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbiK1P0s (ORCPT ); Mon, 28 Nov 2022 10:26:48 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06B9725C4F; Mon, 28 Nov 2022 07:25:15 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id DC178100003; Mon, 28 Nov 2022 15:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649114; 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=aXLPFC0kycNRZx/bctD3Dn2zkVipVfkGhwxHoAJIOfU=; b=InmxmfBeX7SoSP6tR+DIOKg2WkahVGkqydpOdtZIUMxyRoZdXkS7vDN1Eyp2S0yVBl/NGi 7GKTsjEosWWlLD9NU5QnVodKRrEzptOO9fBGteyWlnfxlS91TnMLPXVRHrKImospAFAAj1 no+BkKJ6XyoMX+VauCW6xs/unHsMSKtXnmuezpx/FJOLKoRpzwDZagxvoGCXcMeo/5+vx4 x0E0fqz2Xye6edEDKDZAstQoWx9iagG9VGc/kH9Wd/8woLK9qGO+o9Z7EtDGlOnOh4j0ES hckQuYiWByeLuRDJsq0eQ52sHgE9GRuMn9BDwFWXrnhd050O7/Gnbi5zsm0XgQ== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 12/21] staging: media: tegra-video: move tegra_channel_fmt_align to a per-soc op Date: Mon, 28 Nov 2022 16:23:27 +0100 Message-Id: <20221128152336.133953-13-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754245507822592?= X-GMAIL-MSGID: =?utf-8?q?1750754245507822592?= 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 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 55a135bef1a9..12c2fa760c81 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -456,36 +456,6 @@ static int tegra_channel_get_format(struct file *file, void *fh, return 0; } -static void tegra_channel_fmt_align(struct tegra_vi_channel *chan, - struct v4l2_pix_format *pix, - unsigned int bpp) -{ - unsigned int min_bpl; - unsigned int max_bpl; - unsigned int bpl; - - /* - * The transfer alignment requirements are expressed in bytes. - * Clamp the requested width and height to the limits. - */ - pix->width = clamp(pix->width, TEGRA_MIN_WIDTH, TEGRA_MAX_WIDTH); - pix->height = clamp(pix->height, TEGRA_MIN_HEIGHT, TEGRA_MAX_HEIGHT); - - /* Clamp the requested bytes per line value. If the maximum bytes per - * line value is zero, the module doesn't support user configurable - * line sizes. Override the requested value with the minimum in that - * case. - */ - min_bpl = pix->width * bpp; - max_bpl = rounddown(TEGRA_MAX_WIDTH, SURFACE_ALIGN_BYTES); - bpl = roundup(pix->bytesperline, SURFACE_ALIGN_BYTES); - - pix->bytesperline = clamp(bpl, min_bpl, max_bpl); - pix->sizeimage = pix->bytesperline * pix->height; - if (pix->pixelformat == V4L2_PIX_FMT_NV16) - pix->sizeimage *= 2; -} - static int __tegra_channel_try_format(struct tegra_vi_channel *chan, struct v4l2_pix_format *pix) { @@ -561,7 +531,7 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, return ret; v4l2_fill_pix_format(pix, &fmt.format); - tegra_channel_fmt_align(chan, pix, fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(pix, fmtinfo->bpp); __v4l2_subdev_state_free(sd_state); @@ -613,7 +583,7 @@ static int tegra_channel_set_format(struct file *file, void *fh, return ret; v4l2_fill_pix_format(pix, &fmt.format); - tegra_channel_fmt_align(chan, pix, fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(pix, fmtinfo->bpp); chan->format = *pix; chan->fmtinfo = fmtinfo; @@ -649,7 +619,7 @@ static int tegra_channel_set_subdev_active_fmt(struct tegra_vi_channel *chan) chan->format.bytesperline = chan->format.width * chan->fmtinfo->bpp; chan->format.sizeimage = chan->format.bytesperline * chan->format.height; - tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); tegra_channel_update_gangports(chan); return 0; @@ -818,7 +788,7 @@ static int tegra_channel_s_dv_timings(struct file *file, void *fh, chan->format.height = bt->height; chan->format.bytesperline = bt->width * chan->fmtinfo->bpp; chan->format.sizeimage = chan->format.bytesperline * bt->height; - tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); tegra_channel_update_gangports(chan); return 0; @@ -1149,7 +1119,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) chan->format.height = TEGRA_DEF_HEIGHT; chan->format.bytesperline = TEGRA_DEF_WIDTH * chan->fmtinfo->bpp; chan->format.sizeimage = chan->format.bytesperline * TEGRA_DEF_HEIGHT; - tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); ret = tegra_channel_host1x_syncpt_init(chan); if (ret) diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index dfd834a69848..1021c730b595 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -25,17 +25,11 @@ #define V4L2_CID_TEGRA_SYNCPT_TIMEOUT_RETRY (V4L2_CTRL_CLASS_CAMERA | 0x1001) -#define TEGRA_MIN_WIDTH 32U -#define TEGRA_MAX_WIDTH 32768U -#define TEGRA_MIN_HEIGHT 32U -#define TEGRA_MAX_HEIGHT 32768U - #define TEGRA_DEF_WIDTH 1920 #define TEGRA_DEF_HEIGHT 1080 #define TEGRA_IMAGE_FORMAT_DEF 32 #define MAX_FORMAT_NUM 64 -#define SURFACE_ALIGN_BYTES 64 enum tegra_vi_pg_mode { TEGRA_VI_PG_DISABLED = 0, @@ -45,6 +39,8 @@ enum tegra_vi_pg_mode { /** * struct tegra_vi_ops - Tegra VI operations + * @vi_fmt_align: modify `pix` to fit the hardware alignment + * requirements and fill image geometry * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up * VI for capture and runs capture start and capture finish * kthreads for capturing frames to buffer and returns them back. @@ -52,6 +48,7 @@ enum tegra_vi_pg_mode { * back any queued buffers. */ struct tegra_vi_ops { + void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); }; From patchwork Mon Nov 28 15:23:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26833 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750800wrr; Mon, 28 Nov 2022 07:29:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf739KXsAucOO73meE7iHbs/sBOawcz+d/09Yhg+6LlqiABnkZej7sjOONgJE6cWGM17cAnK X-Received: by 2002:a17:906:3510:b0:781:b7f2:bce9 with SMTP id r16-20020a170906351000b00781b7f2bce9mr44780815eja.269.1669649340436; Mon, 28 Nov 2022 07:29:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649340; cv=none; d=google.com; s=arc-20160816; b=uE1+0m9NjbA/3dLGyYAlls/VKI0IyZPQHnLJOp/zScGXVPJQ2ZKlcPVNlL+4iuLKi6 g1peXxEzOZ1YO+/UZ2PPNl8rpKOGzWIUqbtuyHRNUYeWQBYVgD1FshXy450X680we4Xn 0EZpJGYXQmqmNIWFnpBoGhCov5EibdkoqoZzYUFyGDuRKdb6ZvePkWvLjRbEt92eSM3v UpqP412djlyI/80Xa00MWhU2MXrYKl5P04GQXVGBwwqKLBkqAxVlj7XO//3Dlqrg+wvO mAeXE/M2BPAgENsZrod2Bhy+Iw9/CgiLGHMrEz2C/9VxkpI/JmY5XDkISwYe9MtmPQx9 /OsA== 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=UjvGbhMIPshNH6r+U4pNOMQErXxL1R+/BUmp5ombR6g=; b=lJPGYuU/po3c7VXDNQcmTn3NEK8iKdkClhIRxUUypERBr1MMzgu+982A2AtBBBDDom /wCc+nCj7oHaYfrlCjLa5/N4W7n9+Dye513DKgys8PkdnLOoFsXMbHtvxgoWA5/WY94f kBOaBmlRylOj15bO3rsRak3g6C3ydp13YAKWtkjExtVn5LUQkXg6gTja2lVWBnp3Evdn pvMN8F4IMSV92tBFD7IHAK1ew2zo3DpS/Seu3Do7BqgCwyC3Cco+iHMsBI3hRVJOjWqh W5ios9TRiGEtF4r42Wvreg+iYuhn6JxgnzpLQ/XQ80IG4mtDZqbHhUTrPV3QqIPAIx5V ZmVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=pUno4S6k; 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 hq35-20020a1709073f2300b0079ddb52369bsi11447766ejc.61.2022.11.28.07.28.34; Mon, 28 Nov 2022 07:29:00 -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=pUno4S6k; 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 S231950AbiK1P12 (ORCPT + 99 others); Mon, 28 Nov 2022 10:27:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232191AbiK1P1C (ORCPT ); Mon, 28 Nov 2022 10:27:02 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D47925EA8; Mon, 28 Nov 2022 07:25:20 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id AD58F100007; Mon, 28 Nov 2022 15:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649119; 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=UjvGbhMIPshNH6r+U4pNOMQErXxL1R+/BUmp5ombR6g=; b=pUno4S6koP2DDFvf1tyavj8bIjzBQKJ9UhviqdzkeKljSy1SYXaxgh9n4q+ZrFyx5KXhv0 mbLWxIN00431CfuZ0Q8CT6iCCKCOUjrWQ6JnuFYFCueA6mqVoszHjbDLYPvqj2TW6CDI0O bj6I9fTW1t3VbFBhJO2XoKxjFo0sobjnTB3KqFGj6mv7of1nVxmuOlIllQudrtp8cZH7uY UBYY2XzYzywcAlX3SuZymw9JB/K4cjKfFCnDJYlaJGFdiM5JBG0IgUpexZK6dYxIZkewPb ioNdaCTTJvdw1GPQoNUQk+oKJynjdTSK0gJ6Zv4igUvI5s9QkuTZDgNSdAbalg== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 13/21] staging: media: tegra-video: move default format to soc-specific data Date: Mon, 28 Nov 2022 16:23:28 +0100 Message-Id: <20221128152336.133953-14-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754227023944698?= X-GMAIL-MSGID: =?utf-8?q?1750754227023944698?= 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 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 12c2fa760c81..8b6cf50e1eae 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -44,15 +44,6 @@ struct tegra_vi_graph_entity { struct v4l2_subdev *subdev; }; -static const struct tegra_video_format tegra_default_format = { - .img_dt = TEGRA_IMAGE_DT_RAW10, - .bit_width = 10, - .code = MEDIA_BUS_FMT_SRGGB10_1X10, - .bpp = 2, - .img_fmt = TEGRA_IMAGE_FORMAT_DEF, - .fourcc = V4L2_PIX_FMT_SRGGB10, -}; - static inline struct tegra_vi * host1x_client_to_vi(struct host1x_client *client) { @@ -1111,7 +1102,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) init_waitqueue_head(&chan->done_wait); /* initialize the video format */ - chan->fmtinfo = &tegra_default_format; + chan->fmtinfo = chan->vi->soc->default_video_format; chan->format.pixelformat = chan->fmtinfo->fourcc; chan->format.colorspace = V4L2_COLORSPACE_SRGB; chan->format.field = V4L2_FIELD_NONE; diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 1021c730b595..879547073371 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -58,6 +58,7 @@ struct tegra_vi_ops { * * @video_formats: supported video formats * @nformats: total video formats + * @default_video_format: default video format (pointer to a @video_formats item) * @ops: vi operations * @hw_revision: VI hw_revision * @vi_max_channels: supported max streaming channels @@ -66,6 +67,7 @@ struct tegra_vi_ops { struct tegra_vi_soc { const struct tegra_video_format *video_formats; const unsigned int nformats; + const struct tegra_video_format *default_video_format; const struct tegra_vi_ops *ops; u32 hw_revision; unsigned int vi_max_channels; From patchwork Mon Nov 28 15:23:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26834 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750858wrr; Mon, 28 Nov 2022 07:29:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf57GGB8MuY4PflcA+/50SF5nTGNFnv6E0oiVr1BdvrCn9TSvBeFM3yEH5LJ413AW4D8lqoU X-Received: by 2002:a05:6402:910:b0:468:74:9668 with SMTP id g16-20020a056402091000b0046800749668mr30005466edz.394.1669649345194; Mon, 28 Nov 2022 07:29:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649345; cv=none; d=google.com; s=arc-20160816; b=0HziLHuJq+Bdr7W4zq8RzK+7RiUgtdGeCvxUzRhYOz/eumDyQmJT9sq6omMxki07yU EE7ZYCERijgT3vrnw0off7GxeJsoBg6l0JaS29who9bOx2o3W+EcVz5ujcefijcoPka1 AcMlW1Ju31qv+nqW6olwcSu+L3g0apHmFd1BTJEu4Bfu9UE0tp62pZ1kVvCFzgsIPgFc P2dwcJZMy4YL7O8nnlQsE37vrp9uRLU90m1EHZCAH4806/YYET+QIv3MOr7D6+UQm3KT bva5i3R/oNFiRKLa3tkxwIn8sdrwzWo+jlDEp/3p8e6ZILCVWM4ElcttyAVGhq2Haawk 3e6A== 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=oP8NU7I43xDY/ZPEn0/gmn7Nbc0npEub8Nu+wM5IK7w=; b=Vymu1q6w3T/7NUE+HyLFwMsyFYso3pC7meZ3aieljkOS1gBP8fHQqClC2y7Ac2u8jL joags1Qf7B/iJJC9xPa8oqvosJDeGoQhCqkIbxlfxlDTejYGLB1pBd1h3uyqHgkK65U+ 0Kb/YFmuX+bSu4i33oPJqlCH+u1IXT4mP1wYIYvDP0ZK5z/GgpF6mJL2KZ8valDKKW6H pBydS41U5bxub0xvkepm2aS0Yycs/MjvXMspVhG1AF8ALuuKCUUXsibDmSoB46IrfwiO XUCoNRhPeziCmiPh/jW8o6jln8PFqYxuT8M1p6eDAQz//HYgbs1rn8lDZoLs0mKR3L0+ XFBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hYIrZn61; 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 9-20020a508749000000b0046b6615703esi650894edv.181.2022.11.28.07.28.38; Mon, 28 Nov 2022 07:29: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=hYIrZn61; 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 S232191AbiK1P1d (ORCPT + 99 others); Mon, 28 Nov 2022 10:27:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232336AbiK1P1E (ORCPT ); Mon, 28 Nov 2022 10:27:04 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF75624947; Mon, 28 Nov 2022 07:25:24 -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 6C134100016; Mon, 28 Nov 2022 15:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649123; 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=oP8NU7I43xDY/ZPEn0/gmn7Nbc0npEub8Nu+wM5IK7w=; b=hYIrZn61Zm0+zP0YbUM2rRBF5L0sS4xUTIJ9knElrY5WL/+IVCVOdg9btrq2Ob/BLmJ+Ef 4TK8eBwREDfCNcJ9Le24os7b9E6yw+ye7wmjx2LrCP0I4GcAoVJQAkBrGS2P2M7jszw8YD X5j9s0dmDq3hkCBOTROKqaY8XN+RPZhKb9Wy4hH7ouk3je3jcP1BA/RpbTsa450DeZBKRE TkeJVM93/s5lMk8BwS9oMM0dNy28J+aIMIIWPczyoM5NYnM4KNgwJ11L5IV88tanQEUpmb l+ev8stvAcIn+rELl1d3+6tblqgl1X3BEbWp+kjS79Z5XeznyaYJyEzGJpME5A== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 14/21] staging: media: tegra-video: move MIPI calibration calls from VI to CSI Date: Mon, 28 Nov 2022 16:23:29 +0100 Message-Id: <20221128152336.133953-15-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754231811569889?= X-GMAIL-MSGID: =?utf-8?q?1750754231811569889?= 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 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 426e653bd55d..3a614f568a31 100644 --- a/drivers/staging/media/tegra-video/csi.c +++ b/drivers/staging/media/tegra-video/csi.c @@ -328,12 +328,42 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev) } csi_chan->pg_mode = chan->pg_mode; + + /* + * Tegra CSI receiver can detect the first LP to HS transition. + * So, start the CSI stream-on prior to sensor stream-on and + * vice-versa for stream-off. + */ ret = csi->ops->csi_start_streaming(csi_chan); if (ret < 0) goto finish_calibration; + if (csi_chan->mipi) { + struct v4l2_subdev *src_subdev; + /* + * TRM has incorrectly documented to wait for done status from + * calibration logic after CSI interface power on. + * As per the design, calibration results are latched and applied + * to the pads only when the link is in LP11 state which will happen + * during the sensor stream-on. + * CSI subdev stream-on triggers start of MIPI pads calibration. + * Wait for calibration to finish here after sensor subdev stream-on. + */ + src_subdev = tegra_channel_get_remote_source_subdev(chan); + ret = v4l2_subdev_call(src_subdev, video, s_stream, true); + err = tegra_mipi_finish_calibration(csi_chan->mipi); + + if (ret < 0 && ret != -ENOIOCTLCMD) + goto disable_csi_stream; + + if (err < 0) + dev_warn(csi->dev, "MIPI calibration failed: %d\n", err); + } + return 0; +disable_csi_stream: + csi->ops->csi_stop_streaming(csi_chan); finish_calibration: if (csi_chan->mipi) tegra_mipi_finish_calibration(csi_chan->mipi); @@ -352,10 +382,24 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev) static int tegra_csi_disable_stream(struct v4l2_subdev *subdev) { + struct tegra_vi_channel *chan = v4l2_get_subdev_hostdata(subdev); struct tegra_csi_channel *csi_chan = to_csi_chan(subdev); struct tegra_csi *csi = csi_chan->csi; int err; + /* + * Stream-off subdevices in reverse order to stream-on. + * Remote source subdev in TPG mode is same as CSI subdev. + */ + if (csi_chan->mipi) { + struct v4l2_subdev *src_subdev; + + src_subdev = tegra_channel_get_remote_source_subdev(chan); + err = v4l2_subdev_call(src_subdev, video, s_stream, false); + if (err < 0 && err != -ENOIOCTLCMD) + dev_err_probe(csi->dev, err, "source subdev stream off failed\n"); + } + csi->ops->csi_stop_streaming(csi_chan); if (csi_chan->mipi) { diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 8b6cf50e1eae..2dd3c6c944a2 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -187,49 +187,15 @@ tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan) static int tegra_channel_enable_stream(struct tegra_vi_channel *chan) { - struct v4l2_subdev *csi_subdev, *src_subdev; - struct tegra_csi_channel *csi_chan; - int ret, err; + struct v4l2_subdev *subdev; + int ret; - /* - * Tegra CSI receiver can detect the first LP to HS transition. - * So, start the CSI stream-on prior to sensor stream-on and - * vice-versa for stream-off. - */ - csi_subdev = tegra_channel_get_remote_csi_subdev(chan); - ret = v4l2_subdev_call(csi_subdev, video, s_stream, true); + subdev = tegra_channel_get_remote_csi_subdev(chan); + ret = v4l2_subdev_call(subdev, video, s_stream, true); if (ret < 0 && ret != -ENOIOCTLCMD) return ret; - if (IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) - return 0; - - csi_chan = v4l2_get_subdevdata(csi_subdev); - /* - * TRM has incorrectly documented to wait for done status from - * calibration logic after CSI interface power on. - * As per the design, calibration results are latched and applied - * to the pads only when the link is in LP11 state which will happen - * during the sensor stream-on. - * CSI subdev stream-on triggers start of MIPI pads calibration. - * Wait for calibration to finish here after sensor subdev stream-on. - */ - src_subdev = tegra_channel_get_remote_source_subdev(chan); - ret = v4l2_subdev_call(src_subdev, video, s_stream, true); - err = tegra_mipi_finish_calibration(csi_chan->mipi); - - if (ret < 0 && ret != -ENOIOCTLCMD) - goto err_disable_csi_stream; - - if (err < 0) - dev_warn(csi_chan->csi->dev, - "MIPI calibration failed: %d\n", err); - return 0; - -err_disable_csi_stream: - v4l2_subdev_call(csi_subdev, video, s_stream, false); - return ret; } static int tegra_channel_disable_stream(struct tegra_vi_channel *chan) @@ -237,18 +203,6 @@ static int tegra_channel_disable_stream(struct tegra_vi_channel *chan) struct v4l2_subdev *subdev; int ret; - /* - * Stream-off subdevices in reverse order to stream-on. - * Remote source subdev in TPG mode is same as CSI subdev. - */ - subdev = tegra_channel_get_remote_source_subdev(chan); - ret = v4l2_subdev_call(subdev, video, s_stream, false); - if (ret < 0 && ret != -ENOIOCTLCMD) - return ret; - - if (IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) - return 0; - subdev = tegra_channel_get_remote_csi_subdev(chan); ret = v4l2_subdev_call(subdev, video, s_stream, false); if (ret < 0 && ret != -ENOIOCTLCMD) From patchwork Mon Nov 28 15:23:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750975wrr; Mon, 28 Nov 2022 07:29:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5c+Q3vNHL65pe4aw46aJ2fULhX3vJYZm9UJNMuw8y3z3tTAnrXj4uGr+fbcpv4ukYRlzrh X-Received: by 2002:aa7:cc12:0:b0:462:79ec:55eb with SMTP id q18-20020aa7cc12000000b0046279ec55ebmr46839061edt.151.1669649354898; Mon, 28 Nov 2022 07:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649354; cv=none; d=google.com; s=arc-20160816; b=nqI50PyDSieEzjYJo2s90oQpyYGI2xYT7s+yVD6qtjOYkWkWzreOtqGj6LkWYvwLNV Dq2ziIsiV+V5vtF+wAd7ZQ/SPpTG/H57O+ammPklN3GwSv+ttlYS7PpPK2ndEqHL+opS 0yjWAW3mPKB6g99ne5g0zoWtMKlIjQ6nJKBYH+0wgTO2LWo8WYn/24psTxaSblNAUfPs 1vjVepV6QEUpOpd91WDWgz+/fLgHHI98h3rUJXyAN/N5Ea+b7LTAF+e4Jj5BquX3NGt7 pDmD5I/EsdAdJmAZ4iziICcWGwsPwp0fnoQ3XBFhPPwzhn6nOFqmqh7yahJe0d923SgY 1y0A== 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=4L2vAgix/FUBMn0M/99DVyke1fXls4rI0uUzO7MX+jc=; b=VxcvtVYLipaATX20AXfdfLKtWYQY+8hNbadUcuFXcQN7QnRmH9VVOPIeGJdvWb32Vb U2RGiKd6aMVKyQ0eVpz1eGpFbK8MW4zKyean2ZYy/40m9Z026PJxr5fAqAE9ZBU8Nw+g cNHPw+NvryIT7Y+3SwzubT1i59vv4wgQqDPp6UJRvK9io509tp4qik1n8gAoSDGGBb30 LSUcfgwfuoI8RueCYtyED0pkK9teI1cSX3l08P3sjhtrGIMZMbG5f1leBRCG/pa6k2Xr afEsPnrDI9CmQmbmGLrgEBwfIq88/p3bhZ0vSkkTXggSRMan1S60lfJQgpRSAeli/m4i HDWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iCt69+yl; 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 wt7-20020a170906ee8700b0078333d9f17bsi10209643ejb.819.2022.11.28.07.28.48; Mon, 28 Nov 2022 07:29:14 -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=iCt69+yl; 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 S231921AbiK1P1v (ORCPT + 99 others); Mon, 28 Nov 2022 10:27:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232197AbiK1P1H (ORCPT ); Mon, 28 Nov 2022 10:27:07 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CED924943; Mon, 28 Nov 2022 07:25:27 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 70852100008; Mon, 28 Nov 2022 15:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649126; 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=4L2vAgix/FUBMn0M/99DVyke1fXls4rI0uUzO7MX+jc=; b=iCt69+ylDHxiA2gkJhoPgSh+HTmr7PctRzItlxinwTagRevlXhbFQC4vdNlKMJWjUuGb09 YhYsA+DaD9xw6vR5a8aeBkcGnct2o4RJhx75x5QpZfcQsJfVxIADbhMfweVGUNWJXFCiMQ 6PEujs/MXTwEp1InPRytovxTJkJ+H0U2i6oY/kcw211LRtEAIdouwMP04Wvy0NK5DILnG9 sTqRtD/fJN3/ZTUO+lZtTjhGrTKrxl/hDa0D0jiAIrjeB0lzHcb/qdTp4mnm/ZnGMsZ12I MBBHOEuzgB+eS+To20n4cQDUGYyiniGfLspyGHphbHHI1KI8L4PaIaXJDRRKsg== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 15/21] staging: media: tegra-video: add a per-soc enable/disable op Date: Mon, 28 Nov 2022 16:23:30 +0100 Message-Id: <20221128152336.133953-16-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754242051829861?= X-GMAIL-MSGID: =?utf-8?q?1750754242051829861?= The Tegra20 VI needs an additional operation to enable the VI, add an operation for that. Signed-off-by: Luca Ceresoli --- 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 2dd3c6c944a2..d0c387873d4e 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1853,6 +1853,9 @@ static int tegra_vi_probe(struct platform_device *pdev) vi->client.ops = &vi_client_ops; vi->client.dev = &pdev->dev; + if (vi->ops->vi_enable) + vi->ops->vi_enable(vi, true); + ret = host1x_client_register(&vi->client); if (ret < 0) { dev_err(&pdev->dev, @@ -1863,6 +1866,8 @@ static int tegra_vi_probe(struct platform_device *pdev) return 0; rpm_disable: + if (vi->ops->vi_enable) + vi->ops->vi_enable(vi, false); pm_runtime_disable(&pdev->dev); return ret; } @@ -1879,6 +1884,8 @@ static int tegra_vi_remove(struct platform_device *pdev) return err; } + if (vi->ops->vi_enable) + vi->ops->vi_enable(vi, false); pm_runtime_disable(&pdev->dev); return 0; diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 879547073371..851c4f3fcb91 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -37,8 +37,11 @@ enum tegra_vi_pg_mode { TEGRA_VI_PG_PATCH, }; +struct tegra_vi; + /** * struct tegra_vi_ops - Tegra VI operations + * @vi_enable: soc-specific operations needed to enable/disable the VI peripheral * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up @@ -48,6 +51,7 @@ enum tegra_vi_pg_mode { * back any queued buffers. */ struct tegra_vi_ops { + int (*vi_enable)(struct tegra_vi *vi, bool on); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); From patchwork Mon Nov 28 15:23:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5751417wrr; Mon, 28 Nov 2022 07:29:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf636QzkGckHH/556r55lZi64XBzr1aJhkY6WzHXToDmFnZUadz9aq4eHQtVkYUKR+WK2k/7 X-Received: by 2002:a17:906:b08e:b0:7ad:b9a0:8a9b with SMTP id x14-20020a170906b08e00b007adb9a08a9bmr36086720ejy.509.1669649393619; Mon, 28 Nov 2022 07:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649393; cv=none; d=google.com; s=arc-20160816; b=LdgAn581KtgYIjsocyIbLLK5P0zjVaGd9PS+IQ+zuNMx1ehkkOPoXc0zlLEScrihQy ebqt0GG4C5XGmKXCEhB0Hcgd2G5MtPJY1vdn4pCZsmE6Z7NZlItkELEuIG0vVEIqaI5K NnyNfVcis7Sg2LZHamK9oDT4/dr0mEcJsOeWsh2wlrk17NtV/DlyT4iHxap+E0i8JQGq cOhvY+2CLhVO/1PN3Xw3pKjzSz1IOI4kZR0qHGFa+WfPumZAeVYMAVwaYCMouHjwoG6l pkap0umo1MnbAn9TIBXVtNPA+W/GPyQPWAb9SA36fm6lNUL+GMUqJ4J0Qqaxe874zidh sTLg== 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=oI61dlUOXaATSsX6dZBG7dsSutwFDp6QpvpLxRsKUR0=; b=0VaxJGFEbyTwrWX0dya3DiMS9D8s+Cjshg6orvADVb6Myj3p/wgx8+VZbusdXSvo38 ASjiwr+cZCNXdeFdxNWAqizjKkpg8VeEDgX3QhLfS5La6RO/G7jk/GgyD3a3X3gizTj4 KAy+52NqFRFdKEkZNbHAP2LvfuSr9xeJH+T9E3qGWFAYQS5Qa9abHwwxyLkEs9gxJ2Pt 6301f5RO4onKRtBtpHI9f9+8+ACH063ewKNWx+gYWxAVbGYuoe0yaui07Rx9civPYwV+ 72HLtH7YM5J8jWQHlbknF83IxbA9zt6O+k5vDSRR4/9HvjdgScWI71Nz/5lSmtrpdcrI CEYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iScIt5nr; 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 qm5-20020a170907674500b007836ec6999dsi9423678ejc.904.2022.11.28.07.29.29; Mon, 28 Nov 2022 07:29:53 -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=iScIt5nr; 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 S232418AbiK1P2B (ORCPT + 99 others); Mon, 28 Nov 2022 10:28:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230228AbiK1P1J (ORCPT ); Mon, 28 Nov 2022 10:27:09 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8120E25E99; Mon, 28 Nov 2022 07:25:30 -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 7899F100012; Mon, 28 Nov 2022 15:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649129; 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=oI61dlUOXaATSsX6dZBG7dsSutwFDp6QpvpLxRsKUR0=; b=iScIt5nrmmfM39onDVYzyVy5NbkiDcNNGHSs7E6KH4Nqj5Xr8eFeXky+cx4kkJDtqgrXIg 19UHgT/owPCgkPVTAMpOGCIbzzKX1NEEb4JNDCMjIqZj98a0ZoWCRkn5DZBU1aWlKgTGE7 kig2zNWPIsRleZIGPkUJOdi1tmWFdwR+RJOVzK7CTg4oejxaLf7Oxy57n1Au8BYBwIfScF oStpc/03x/HgEqx3s1Eqd0RQ+5k3vJZ24lY7bCB+F+RsR6C2BBRsiSjgyLLrnm8Iv0APiu FsggON6ouJ8gGfaYNmievBaWVFI72zszmbcpzzqjfFYcF3DaOq6Gm3/38HEAAg== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 16/21] staging: media: tegra-video: move syncpt init/free to a per-soc op Date: Mon, 28 Nov 2022 16:23:31 +0100 Message-Id: <20221128152336.133953-17-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754282149005284?= X-GMAIL-MSGID: =?utf-8?q?1750754282149005284?= 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 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 d0c387873d4e..854ffb4b5617 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -973,21 +973,11 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) return 0; } -static void tegra_channel_host1x_syncpts_free(struct tegra_vi_channel *chan) -{ - int i; - - for (i = 0; i < chan->numgangports; i++) { - host1x_syncpt_put(chan->mw_ack_sp[i]); - host1x_syncpt_put(chan->frame_start_sp[i]); - } -} - static void tegra_channel_cleanup(struct tegra_vi_channel *chan) { v4l2_ctrl_handler_free(&chan->ctrl_handler); media_entity_cleanup(&chan->video.entity); - tegra_channel_host1x_syncpts_free(chan); + chan->vi->ops->channel_host1x_syncpt_free(chan); mutex_destroy(&chan->video_lock); } @@ -1005,42 +995,6 @@ void tegra_channels_cleanup(struct tegra_vi *vi) } } -static int tegra_channel_host1x_syncpt_init(struct tegra_vi_channel *chan) -{ - struct tegra_vi *vi = chan->vi; - unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED; - struct host1x_syncpt *fs_sp; - struct host1x_syncpt *mw_sp; - int ret, i; - - for (i = 0; i < chan->numgangports; i++) { - fs_sp = host1x_syncpt_request(&vi->client, flags); - if (!fs_sp) { - dev_err(vi->dev, "failed to request frame start syncpoint\n"); - ret = -ENOMEM; - goto free_syncpts; - } - - mw_sp = host1x_syncpt_request(&vi->client, flags); - if (!mw_sp) { - dev_err(vi->dev, "failed to request memory ack syncpoint\n"); - host1x_syncpt_put(fs_sp); - ret = -ENOMEM; - goto free_syncpts; - } - - chan->frame_start_sp[i] = fs_sp; - chan->mw_ack_sp[i] = mw_sp; - spin_lock_init(&chan->sp_incr_lock[i]); - } - - return 0; - -free_syncpts: - tegra_channel_host1x_syncpts_free(chan); - return ret; -} - static int tegra_channel_init(struct tegra_vi_channel *chan) { struct tegra_vi *vi = chan->vi; @@ -1066,7 +1020,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) chan->format.sizeimage = chan->format.bytesperline * TEGRA_DEF_HEIGHT; vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); - ret = tegra_channel_host1x_syncpt_init(chan); + ret = vi->ops->channel_host1x_syncpt_init(chan); if (ret) return ret; @@ -1129,7 +1083,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) cleanup_media: media_entity_cleanup(&chan->video.entity); free_syncpts: - tegra_channel_host1x_syncpts_free(chan); + vi->ops->channel_host1x_syncpt_free(chan); return ret; } diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 851c4f3fcb91..8fadca33bcc9 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -38,10 +38,13 @@ enum tegra_vi_pg_mode { }; struct tegra_vi; +struct tegra_vi_channel; /** * struct tegra_vi_ops - Tegra VI operations * @vi_enable: soc-specific operations needed to enable/disable the VI peripheral + * @channel_host1x_syncpt_init: initialize synchronization points + * @channel_host1x_syncpt_free: free all synchronization points * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up @@ -52,6 +55,8 @@ struct tegra_vi; */ struct tegra_vi_ops { int (*vi_enable)(struct tegra_vi *vi, bool on); + int (*channel_host1x_syncpt_init)(struct tegra_vi_channel *chan); + void (*channel_host1x_syncpt_free)(struct tegra_vi_channel *chan); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); From patchwork Mon Nov 28 15:23:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5751444wrr; Mon, 28 Nov 2022 07:29:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7co3M6grMykRp0QEsVoP4JTJ8Jy0/IJtlgzQII2OaDZWFH44jZobXViq7ty6GijYtZHdgW X-Received: by 2002:a17:906:901:b0:7ae:23c:3cb4 with SMTP id i1-20020a170906090100b007ae023c3cb4mr702477ejd.599.1669649396102; Mon, 28 Nov 2022 07:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649396; cv=none; d=google.com; s=arc-20160816; b=CjJQVhcUWT13el1Ew921oSyJSw8zDbuhDrjsQjBE0xtIQN5BS9aDwKCe/PrzhXVxW4 30rEZDndrmA91HHDxotfxA9alfiPJTRHAbg9VWzmddqoqtDb0XK1R4EtPe6BZGntALez JaJJ1YrOR0iwN9pHE5Kxd/SS9TTPGEJovp2uprl+IRnboUrD8aHgJWLBFgYAUGjMduQp uEmm3WqpGsYh3pDvM7TetuEUMa9bNY3u1rQ1yQSteLcH/qO6LFO3ZjsWVzBirfdCbghq 5V4KomvGLCV59d8WpaiE/tAaHeHjVToFwIPDtHjo1XC2a1KaVTQuUGUFsL+EH+V2IfcG AMFQ== 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=KAKVyFgksg4NSXevr0L+QPIAsthqMqdls7iQD9SYOTY=; b=cBZkjulq8aGypxpPoLglraDh3SKpFB0rPBaPI6Qb898CU4UwmQLmuPq0p8FH2oYUsJ BbVI0hdcxnrbdPrCkMO5Uck1XsJNr/p2O44IEDJ5CMxgPcXL4aUvZHcHm9PNIh0gov/I Al1uDo5YR5geC1r+jJRepJOMNsp2W2rxsZFNR+gRGW75vci54lMfH6la9T8c3+l0BxlY xz4lIzlP466mnzNOE86/gxpsY4FNusG2VuCsgLv2PCLkhDOV01hNymTcCOch4mBIxT5W UJAdxDIVJuXgYGZsss1NBVOB/76jtfLezCnrEc0X5UGVcNHD+lv8aOLjBHiZTINCYoCr fwfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="WTSsCb/E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv16-20020a17090760d000b00782e85ae302si10947193ejc.574.2022.11.28.07.29.32; Mon, 28 Nov 2022 07:29:56 -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="WTSsCb/E"; 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 S232016AbiK1P2K (ORCPT + 99 others); Mon, 28 Nov 2022 10:28:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231886AbiK1P1T (ORCPT ); Mon, 28 Nov 2022 10:27:19 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15CBE24970; Mon, 28 Nov 2022 07:25: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 E9413100002; Mon, 28 Nov 2022 15:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649137; 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=KAKVyFgksg4NSXevr0L+QPIAsthqMqdls7iQD9SYOTY=; b=WTSsCb/En4Ownxk3os3UhuBlYqEUxtb6B/S8PprqoJD6aWUVoaSSaCII0LMlcBh04drJ3a f1DzEn9XS/FONn/DxlMs7/AvCfYs3TLi1B6TJFfA9ZICSR3L0YiZIipStoENaWEqIQy20I +zjXU/a30rR3nGsgR+McYkjWV2XmSMMdp/1ZR1GgAWVD8oBx6igjyfmLQubPELjFg35dLT ntMCWBWqsG4hgCvpoE8tYkSb9/Nc9T5qaYGfB5otk8BrHNSO75opiZ3jQm3HuYGGX86vHS DBAyOdITvRJyV2wA7Ok+rFojWYg5nJJ+2kH9kugnmTNVYdGrFmVwYW+7cr429w== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 17/21] staging: media: tegra-video: add syncpts for Tegra20 to struct tegra_vi Date: Mon, 28 Nov 2022 16:23:32 +0100 Message-Id: <20221128152336.133953-18-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754284783981041?= X-GMAIL-MSGID: =?utf-8?q?1750754284783981041?= In preparation to implement Tegra20 parallel video capture, add variables to hold the required syncpt. Signed-off-by: Luca Ceresoli --- No changes in v2 --- drivers/staging/media/tegra-video/vi.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 8fadca33bcc9..ba563cd17296 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -117,11 +117,13 @@ struct tegra_vi { * @vi: Tegra video input device structure * @frame_start_sp: host1x syncpoint pointer to synchronize programmed capture * start condition with hardware frame start events through host1x - * syncpoint counters. + * syncpoint counters. (Tegra210) * @mw_ack_sp: host1x syncpoint pointer to synchronize programmed memory write * ack trigger condition with hardware memory write done at end of - * frame through host1x syncpoint counters. + * frame through host1x syncpoint counters. (Tegra210) * @sp_incr_lock: protects cpu syncpoint increment. + * @out_sp: host1x syncpoint pointer for frame sync (Tegra20) + * @next_out_sp_idx: next expected value for @out_sp (Tegra20) * * @kthread_start_capture: kthread to start capture of single frame when * vb buffer is available. This thread programs VI CSI hardware @@ -173,6 +175,8 @@ struct tegra_vi_channel { struct host1x_syncpt *mw_ack_sp[GANG_PORTS_MAX]; /* protects the cpu syncpoint increment */ spinlock_t sp_incr_lock[GANG_PORTS_MAX]; + struct host1x_syncpt *out_sp; + u32 next_out_sp_idx; struct task_struct *kthread_start_capture; wait_queue_head_t start_wait; From patchwork Mon Nov 28 15:23:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26838 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5751267wrr; Mon, 28 Nov 2022 07:29:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7jLGokAIBmTeyG5oAktFNzzVjrcLMA4wWhI9Yj/Tf9BfqP84BLE0GVNkV6kzhhH4lM9QCA X-Received: by 2002:a17:906:edce:b0:7ad:dd43:5d18 with SMTP id sb14-20020a170906edce00b007addd435d18mr46695ejb.389.1669649381838; Mon, 28 Nov 2022 07:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649381; cv=none; d=google.com; s=arc-20160816; b=V9fP6on+IZOzsw2dH07XvFiBH9XsOUFbi9GLeyDCL+BPwfh2voT/Y+sM8AhQSDzi7f mDqc4y9UaVU8gvFvCMGqVhGK1y6coZ6bllkUrp8vt4Sy/k8YCwSEbfbk4nLvevBw+j7i P0wURnJwGyTI9DtJzCtIRo6ES6cv4Xf6y0BpCJkbhxqhp1eTU8KcEWcUvW5YmKqnk0hI /FoCBoIXZO6DLYy4p09hSqRtD2wzcNVnRSEiE0QQYp+fBK3agmGLz6gLfR3TXjvz+T4I 2Z8FkmjLxwECJDTfvDgQFPRT+uXpo39gVwlZklORZQkwd1U58LOAOW457HPEqMRrCSWV 1PzQ== 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=Zg4ShTE2huAFd/l9HQyuWaIeflGT7A+U2vvBjt6V8/U=; b=xj8G8bxrD9yOlsCuMyYPqNzSmW5dwGa1AQ9NXXsJ5as7w3BDMwD4Fy92xSWNe5NYwL gYWQUhkfh8rz/BZy6e1SWfeXmQtq9Z0Z8XHMzJ8II92y523EK8L7a54xIDo19LOEXaGy a2M9tAypJFVgGsqAXjFoZBO80hbUZODrwoWQ/E433KDfhqjozlJYJEGNLXwc7Gzx7x6a Gwd5So0AqaR9Sf0GavRT9XkWznS7uUdP+0r3RHrDlKPi/0GXrhXZjX2K8IcWBR7McKdr eSkFMxFJihjqE3QRtaE62wX2+yK6E6VZOWWjbpA5LgCQS+4A6dfkdf60B4HJgezPorjV 82Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=FdpTFgus; 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 a21-20020a1709066d5500b007c07d0dbe85si989557ejt.463.2022.11.28.07.29.18; Mon, 28 Nov 2022 07:29: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=FdpTFgus; 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 S232369AbiK1P21 (ORCPT + 99 others); Mon, 28 Nov 2022 10:28:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232251AbiK1P1h (ORCPT ); Mon, 28 Nov 2022 10:27:37 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86097264BC; Mon, 28 Nov 2022 07:25:47 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 31C9810000F; Mon, 28 Nov 2022 15:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649146; 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=Zg4ShTE2huAFd/l9HQyuWaIeflGT7A+U2vvBjt6V8/U=; b=FdpTFgusnl2zyvqc/Wv5msDgnsUMatIcyGziizyckkGp6EEdkYDEY/l9Ujwin0ov1Xr3ou Zd0EjDwPuVibQAn+VWFGGrQzqKA1SqeXIA0wwS5YpvylrSUzs8pLthm4EaWN33PFqSoG+b rt9g/ghi4JUR+MwRXAYKXN9XBdDfP55lMKXYQGrsh6Z1lIHhKIQgvxHRHNzc09NN0q0u0y pT5e4Ff47uWICAcvaO0WFu9Rt+WzNLZXQdJpwVsn7HYuWxSufS+cRfcpvqKpM1HL2wu3OM 7YxH3ZT3Sr73AYSrsWzJc/aiIIgduytKhJsJad74pZtzP1D8+5wUMkMgWO0b3A== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 18/21] staging: media: tegra-video: add hooks for planar YUV and H/V flip Date: Mon, 28 Nov 2022 16:23:33 +0100 Message-Id: <20221128152336.133953-19-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754269751179136?= X-GMAIL-MSGID: =?utf-8?q?1750754269751179136?= 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 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 854ffb4b5617..ebb502a45e96 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -92,6 +92,7 @@ tegra_get_format_by_fourcc(struct tegra_vi *vi, u32 fourcc) /* * videobuf2 queue operations */ + static int tegra_channel_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, unsigned int *nplanes, @@ -107,6 +108,9 @@ static int tegra_channel_queue_setup(struct vb2_queue *vq, sizes[0] = chan->format.sizeimage; alloc_devs[0] = chan->vi->dev; + if (chan->vi->ops->channel_queue_setup) + chan->vi->ops->channel_queue_setup(chan); + return 0; } diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index ba563cd17296..a23ee8800d33 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -47,6 +47,7 @@ struct tegra_vi_channel; * @channel_host1x_syncpt_free: free all synchronization points * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry + * @channel_queue_setup: additional operations at the end of vb2_ops::queue_setup * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up * VI for capture and runs capture start and capture finish * kthreads for capturing frames to buffer and returns them back. @@ -58,6 +59,7 @@ struct tegra_vi_ops { int (*channel_host1x_syncpt_init)(struct tegra_vi_channel *chan); void (*channel_host1x_syncpt_free)(struct tegra_vi_channel *chan); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); + void (*channel_queue_setup)(struct tegra_vi_channel *chan); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); }; @@ -148,6 +150,12 @@ struct tegra_vi { * @queue: vb2 buffers queue * @sequence: V4L2 buffers sequence number * + * @addr_offset_u: U plane base address, relative to buffer base address (only for planar) + * @addr_offset_v: V plane base address, relative to buffer base address (only for planar) + * @start_offset: 1st Y byte to write, relative to buffer base address (for H/V flip) + * @start_offset_u: 1st U byte to write, relative to buffer base address (for H/V flip) + * @start_offset_v: 1st V byte to write, relative to buffer base address (for H/V flip) + * * @capture: list of queued buffers for capture * @start_lock: protects the capture queued list * @done: list of capture done queued buffers @@ -188,6 +196,12 @@ struct tegra_vi_channel { struct vb2_queue queue; u32 sequence; + unsigned int addr_offset_u; + unsigned int addr_offset_v; + unsigned int start_offset; + unsigned int start_offset_u; + unsigned int start_offset_v; + struct list_head capture; /* protects the capture queued list */ spinlock_t start_lock; From patchwork Mon Nov 28 15:23:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26842 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5751699wrr; Mon, 28 Nov 2022 07:30:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf5+dysiace5rDtXy4luA4A1Kh1sNgamNB/++BgFqTyvK1cNYsHuBXuUFDNJ+1joim/RqN/Z X-Received: by 2002:a17:907:2144:b0:7bd:c280:e94d with SMTP id rk4-20020a170907214400b007bdc280e94dmr9991866ejb.562.1669649417532; Mon, 28 Nov 2022 07:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649417; cv=none; d=google.com; s=arc-20160816; b=1LSb5BZ87mjNNSvN23sGO3ckss1S+dN7EcULwbXqVxFqZAZvgFksal+qfuXMVu8fwu 0WBKgcIDS7D0GjdFnJRg/2iLlCK7HU3gSp+84Zz+ag3qnI7EEQMzCbLHF+e1cDwdFB4z v91m7LO2WS7o7nc8E9jq4cMzl1hCQyhK67DnUf6uLAint5dRz6CPlnoCFseJWwHhYbcq d01zk9zUqklbUigNamcAi17tlGq3wx3HI7daNCL1EJ3KwaX7T+UAGEQfDBKEs+HozagN nmTY7vAl3WTCcbn/7RMonlu03IuyxmL3Lg6wxzAVVqhosaDpmFy8QrwZBcC5D1jUq4RM /+cw== 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=SYnld2X6HcsXPPtJtXGrLJjXqLCvd2LPM1sx8+DcKyY=; b=h448aAujkGgt0F5eFRoqtfbPXr3RZRb3/mqZXx6McP8VGKSKI0oNcEaHam1M7uLWTU cNGr2hB7I5ciitY4YK6nouZQJDz7PSuzXa0v1J99U0cnaHiGfDhO/ym/CZSqt/dI0JHL GQWNZt0xSdJ1hkb7vYxNvDwoNa/wJU3EYOJPjDK5vw/+g4zic2Vi7xcU+T0dMgJDXB8s GlBb4Y3E7srjxZwppCmqy16ku6UhuJFPmRflOE7LK3TMFPQJ4pBd4gmKhVdY/65/yO3F oWqQukkLqSHRfEjbiza7MFRfrEikhTd4PqLxGuXKmK8KzaDTFks1rdqa4IAwUkcoRMnf Xcxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=fKl4MEug; 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 cs12-20020a170906dc8c00b0073da0ce043csi10964013ejc.619.2022.11.28.07.29.52; Mon, 28 Nov 2022 07:30:17 -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=fKl4MEug; 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 S232164AbiK1P2c (ORCPT + 99 others); Mon, 28 Nov 2022 10:28:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232283AbiK1P2A (ORCPT ); Mon, 28 Nov 2022 10:28:00 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8664724BFD; Mon, 28 Nov 2022 07:25: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 67DC9100008; Mon, 28 Nov 2022 15:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649150; 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=SYnld2X6HcsXPPtJtXGrLJjXqLCvd2LPM1sx8+DcKyY=; b=fKl4MEugk9wkcRAnckj6mIHVyzraMJAvyicMm5eAsBgil27HnzbnqG5zeEe+s834II43EJ gpmegpjJfV+JVak7mhJOnOVW3Jydf8xPIoqgjwObVv2RH7+Kz0DSDvUxsG6ima+6MHcamv aSSReyh27CgIaAQKhNUpEKYXA+pjbmjq72H4+PC9N9ftHq7x2s6UnKbUxHmKNF/uZi1/7N 01ldNvqchsKV3o0+2P9NpuwOsrDCQ/of1eQ7jmJDzlG321BHzyo5gdeS+FIGhdwR8AuLoA K5FUfOxNRW82SdePOl6MkEemZrznZNYb/Ia2ETLJojRfO/EEu9Rp60O5MB2kXA== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 19/21] staging: media: tegra-video: add H/V flip controls Date: Mon, 28 Nov 2022 16:23:34 +0100 Message-Id: <20221128152336.133953-20-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754307674163332?= X-GMAIL-MSGID: =?utf-8?q?1750754307674163332?= 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 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 ebb502a45e96..0dbc3da6f98c 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -29,7 +29,7 @@ #include "vi.h" #include "video.h" -#define MAX_CID_CONTROLS 1 +#define MAX_CID_CONTROLS 3 /** * struct tegra_vi_graph_entity - Entity in the video graph @@ -893,6 +893,12 @@ static int vi_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_TEGRA_SYNCPT_TIMEOUT_RETRY: chan->syncpt_timeout_retry = ctrl->val; break; + case V4L2_CID_HFLIP: + chan->hflip = ctrl->val; + break; + case V4L2_CID_VFLIP: + chan->vflip = ctrl->val; + break; default: return -EINVAL; } @@ -964,6 +970,12 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) v4l2_ctrl_handler_free(&chan->ctrl_handler); return ret; } + + if (chan->vi->soc->has_h_v_flip) { + v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); + v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); + } + #endif /* setup the controls */ diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index a23ee8800d33..7cb038957f1b 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -74,6 +74,7 @@ struct tegra_vi_ops { * @hw_revision: VI hw_revision * @vi_max_channels: supported max streaming channels * @vi_max_clk_hz: VI clock max frequency + * @has_h_v_flip: the chip can do H adn V flip, and the driver implements it */ struct tegra_vi_soc { const struct tegra_video_format *video_formats; @@ -83,6 +84,7 @@ struct tegra_vi_soc { u32 hw_revision; unsigned int vi_max_channels; unsigned int vi_max_clk_hz; + bool has_h_v_flip:1; }; /** @@ -170,6 +172,9 @@ struct tegra_vi { * @syncpt_timeout_retry: syncpt timeout retry count for the capture * @pg_mode: test pattern generator mode (disabled/direct/patch) * @notifier: V4L2 asynchronous subdevs notifier + * + * @hflip: Horizontal flip is enabled + * @vflip: Vertical flip is enabled */ struct tegra_vi_channel { struct list_head list; @@ -219,6 +224,9 @@ struct tegra_vi_channel { enum tegra_vi_pg_mode pg_mode; struct v4l2_async_notifier notifier; + + bool hflip:1; + bool vflip:1; }; /** From patchwork Mon Nov 28 15:23:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5751551wrr; Mon, 28 Nov 2022 07:30:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf51tuJF7aI44JbAph6+9ZcHe7UwsXJQ99UDk+QqFC9P0ibmLPO7PacxbqQ+4++/R6ZeCTAN X-Received: by 2002:aa7:c758:0:b0:469:b3fc:8d7c with SMTP id c24-20020aa7c758000000b00469b3fc8d7cmr33721091eds.393.1669649404353; Mon, 28 Nov 2022 07:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649404; cv=none; d=google.com; s=arc-20160816; b=MOpR/vUlWBzdjDgjWf6RX1zljCrb4wrxPwPVD0MkDyMMaURN+fbPwfw7fOBaUbQKwy lYBREArMXFx3M7wLrovJSbDz8yfExwniNRZdToNTedFeA2eoIKb7pPJ9ARbswXZO4HAn KPwcGhu05uUZyvM7n0a7F3IZzMPvdVb0ld64mDmf+3yYZCfoe0chvBqmfVKXD4T8kbf+ +vkH8ix4CyB2Gsu0G2OzcatCjIcynVdMSyfFTUSO9Lyvhscu/dWExwHwuj696ZB4R8ss aZKXzNrAa7btkPZPC5AMHVJbh82dX4ubIfvC3GQaJoUif6dz8SSsbAOc1zcqxinJ/6mX RQmw== 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=OoXUT9AdbVFMNOQAniPu8hp8jV2YODAHFkN2Ysky5NE=; b=gwxOQ8uP6h9gUWARJfLXaE4o73JYSMy7Y+F5O2FwI9x52IRzRWNYFI6vmtGcYmRq4y GF6LpGkw06Ci2B4GOgOvP3Oj3gkxvED90wqamiM/vOV14nTljImZhsEfkVrBFNfAIwtk sB/fYKWDC3Fchx5j+p3BD0BRvxw8ZRfwzejGZEHYBcu1mJNFvwsandOV8s/Z5YsJG+ar xk6EliYWshy15wnlYL8krqgv1r0ZYYghA7iPuUkGo+ht1BPXdlEDnJU5xxQzG2lW7/iR /toPLpP9kK2NoErzrV6DWeZK4P2625zAiDrTNdcBmZGZ3niFkhRmqYhePs3AN1vSUbEV 2O7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="ZZN3c1/U"; 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 fi8-20020a170906da0800b007b7eb087819si7810484ejb.200.2022.11.28.07.29.38; Mon, 28 Nov 2022 07:30:04 -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="ZZN3c1/U"; 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 S232304AbiK1P2i (ORCPT + 99 others); Mon, 28 Nov 2022 10:28:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232003AbiK1P2C (ORCPT ); Mon, 28 Nov 2022 10:28:02 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CFDA24F01; Mon, 28 Nov 2022 07:26:00 -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 22A3010000F; Mon, 28 Nov 2022 15:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649158; 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=OoXUT9AdbVFMNOQAniPu8hp8jV2YODAHFkN2Ysky5NE=; b=ZZN3c1/UkAfE2mAI9i9VugV9EwP3ltAetbNEdfatM0P4bWuqUbGZ/WIsF/Jfp/TDqw2OnR 93aFCAzh1KMRD+mW9WM750syDgxEchH3qN24mi9SmJ5VIOWpQDUBfavE7LGxTQtxKLhVtJ P+BJ+6Lse5F2EDyB8UTQhkQ0YcLK7No8Pankwd/hlGhQ/PkmOPTplJmNAkuaUoNDEgyNzt d2sL5+hCfWF11pHPQD0X63njO0X0MyVn4Hp7zWBBtSG3WiOR6B45mx/P2sb17/QRTaRgUl 3632NUAPAS237mR69QoKaiIUxG2Rav33WDllPYzWGzLriAq3Cw8MElxsGIOLVA== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 20/21] staging: media: tegra-video: add support for VIP (parallel video input) Date: Mon, 28 Nov 2022 16:23:35 +0100 Message-Id: <20221128152336.133953-21-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754293458465620?= X-GMAIL-MSGID: =?utf-8?q?1750754293458465620?= The VI peripheral of Tegra supports capturing from MIPI CSI-2 or parallel video (called VIP in the docs). MIPI CSI-2 is already implemented. Add a VIP implementation. Signed-off-by: Luca Ceresoli --- No changes in v2 --- MAINTAINERS | 1 + drivers/staging/media/tegra-video/Makefile | 1 + drivers/staging/media/tegra-video/vip.c | 298 +++++++++++++++++++++ drivers/staging/media/tegra-video/vip.h | 72 +++++ 4 files changed, 372 insertions(+) create mode 100644 drivers/staging/media/tegra-video/vip.c create mode 100644 drivers/staging/media/tegra-video/vip.h diff --git a/MAINTAINERS b/MAINTAINERS index 0c97ce22735d..1601465e8e31 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20322,6 +20322,7 @@ L: linux-tegra@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml +F: drivers/staging/media/tegra-video/vip.* TEGRA XUSB PADCTL DRIVER M: JC Kuo diff --git a/drivers/staging/media/tegra-video/Makefile b/drivers/staging/media/tegra-video/Makefile index dfa2ef8f99ef..3c8ec1bb1f3e 100644 --- a/drivers/staging/media/tegra-video/Makefile +++ b/drivers/staging/media/tegra-video/Makefile @@ -2,6 +2,7 @@ tegra-video-objs := \ video.o \ vi.o \ + vip.o \ csi.o tegra-video-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o diff --git a/drivers/staging/media/tegra-video/vip.c b/drivers/staging/media/tegra-video/vip.c new file mode 100644 index 000000000000..cbf0c36fb098 --- /dev/null +++ b/drivers/staging/media/tegra-video/vip.c @@ -0,0 +1,298 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Parallel video capture module (VIP) for the Tegra VI. + * + * This file implements the VIP-specific infrastructure. + * + * Copyright (C) 2022 SKIDATA GmbH + * Author: Luca Ceresoli + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "vip.h" + +static inline struct tegra_vip *host1x_client_to_vip(struct host1x_client *client) +{ + return container_of(client, struct tegra_vip, client); +} + +static inline struct tegra_vip_channel *subdev_to_vip_channel(struct v4l2_subdev *subdev) +{ + return container_of(subdev, struct tegra_vip_channel, subdev); +} + +static inline struct tegra_vip *vip_channel_to_vip(struct tegra_vip_channel *chan) +{ + return container_of(chan, struct tegra_vip, chan); +} + +/* Find the previous subdev in the pipeline (i.e. the one connected to our sink pad) */ +static struct v4l2_subdev *tegra_vip_channel_get_prev_subdev(struct tegra_vip_channel *chan) +{ + struct media_pad *remote_pad; + + remote_pad = media_pad_remote_pad_first(&chan->pads[TEGRA_VIP_PAD_SINK]); + if (!remote_pad) + return NULL; + + return media_entity_to_v4l2_subdev(remote_pad->entity); +} + +static int tegra_vip_enable_stream(struct v4l2_subdev *subdev) +{ + struct tegra_vip_channel *vip_chan = subdev_to_vip_channel(subdev); + struct tegra_vip *vip = vip_channel_to_vip(vip_chan); + struct v4l2_subdev *prev_subdev = tegra_vip_channel_get_prev_subdev(vip_chan); + int err; + + err = pm_runtime_resume_and_get(vip->dev); + if (err) + return dev_err_probe(vip->dev, err, "failed to get runtime PM\n"); + + err = vip->soc->ops->vip_start_streaming(vip_chan); + if (err < 0) + goto err_start_streaming; + + err = v4l2_subdev_call(prev_subdev, video, s_stream, true); + if (err < 0 && err != -ENOIOCTLCMD) + goto err_prev_subdev_start_stream; + + return 0; + +err_prev_subdev_start_stream: +err_start_streaming: + pm_runtime_put(vip->dev); + return err; +} + +static int tegra_vip_disable_stream(struct v4l2_subdev *subdev) +{ + struct tegra_vip_channel *vip_chan = subdev_to_vip_channel(subdev); + struct tegra_vip *vip = vip_channel_to_vip(vip_chan); + struct v4l2_subdev *prev_subdev = tegra_vip_channel_get_prev_subdev(vip_chan); + + v4l2_subdev_call(prev_subdev, video, s_stream, false); + + pm_runtime_put(vip->dev); + + return 0; +} + +static int tegra_vip_s_stream(struct v4l2_subdev *subdev, int enable) +{ + int err; + + if (enable) + err = tegra_vip_enable_stream(subdev); + else + err = tegra_vip_disable_stream(subdev); + + return err; +} + +static const struct v4l2_subdev_video_ops tegra_vip_video_ops = { + .s_stream = tegra_vip_s_stream, +}; + +static const struct v4l2_subdev_ops tegra_vip_ops = { + .video = &tegra_vip_video_ops, +}; + +static int tegra_vip_channel_of_parse(struct tegra_vip *vip) +{ + struct device *dev = vip->dev; + struct device_node *node; + struct v4l2_fwnode_endpoint v4l2_ep = { + .bus_type = V4L2_MBUS_PARALLEL + }; + struct fwnode_handle *fwh; + struct device_node *ep; + unsigned int portno, num_pads; + int err; + + node = of_get_child_by_name(dev->of_node, "channel"); + + err = of_property_read_u32(node, "reg", &portno); + if (err < 0) { + dev_err_probe(dev, err, "%pOF: error reading reg property\n", node); + goto err_node_put; + } + + if (portno != 0) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: invalid reg property\n", node); + goto err_node_put; + } + + ep = of_graph_get_endpoint_by_regs(node, 0, 0); + if (!ep) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: error getting endpoint node\n", node); + goto err_node_put; + } + + fwh = of_fwnode_handle(ep); + err = v4l2_fwnode_endpoint_parse(fwh, &v4l2_ep); + of_node_put(ep); + if (err) { + dev_err_probe(dev, err, "%pOF: failed to parse v4l2 endpoint\n", node); + goto err_node_put; + } + + num_pads = of_graph_get_endpoint_count(node); + if (num_pads != TEGRA_VIP_PADS_NUM) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: need 2 pads, got %d\n", node, num_pads); + goto err_node_put; + } + + vip->chan.of_node = of_node_get(node); + vip->chan.pads[TEGRA_VIP_PAD_SINK].flags = MEDIA_PAD_FL_SINK; + vip->chan.pads[TEGRA_VIP_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; + + return 0; + +err_node_put: + of_node_put(node); + return err; +} + +static int tegra_vip_channel_init(struct tegra_vip *vip) +{ + struct v4l2_subdev *subdev; + int err; + + subdev = &vip->chan.subdev; + v4l2_subdev_init(subdev, &tegra_vip_ops); + subdev->dev = vip->dev; + snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "%s", + kbasename(vip->chan.of_node->full_name)); + + v4l2_set_subdevdata(subdev, &vip->chan); + subdev->fwnode = of_fwnode_handle(vip->chan.of_node); + subdev->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; + + err = media_entity_pads_init(&subdev->entity, TEGRA_VIP_PADS_NUM, vip->chan.pads); + if (err) + return dev_err_probe(vip->dev, err, "failed to initialize media entity\n"); + + err = v4l2_async_register_subdev(subdev); + if (err) { + dev_err_probe(vip->dev, err, "failed to register subdev\n"); + goto err_register_subdev; + } + + return 0; + +err_register_subdev: + media_entity_cleanup(&subdev->entity); + return err; +} + +static int tegra_vip_init(struct host1x_client *client) +{ + struct tegra_vip *vip = host1x_client_to_vip(client); + int err; + + err = tegra_vip_channel_of_parse(vip); + if (err) + return err; + + err = tegra_vip_channel_init(vip); + if (err) + goto err_init; + + return 0; + +err_init: + of_node_put(vip->chan.of_node); + return err; +} + +static int tegra_vip_exit(struct host1x_client *client) +{ + struct tegra_vip *vip = host1x_client_to_vip(client); + struct v4l2_subdev *subdev = &vip->chan.subdev; + + v4l2_async_unregister_subdev(subdev); + media_entity_cleanup(&subdev->entity); + of_node_put(vip->chan.of_node); + + return 0; +} + +static const struct host1x_client_ops vip_client_ops = { + .init = tegra_vip_init, + .exit = tegra_vip_exit, +}; + +static int tegra_vip_probe(struct platform_device *pdev) +{ + struct tegra_vip *vip; + int err; + + dev_dbg(&pdev->dev, "Probing VIP \"%s\" from %pOF\n", pdev->name, pdev->dev.of_node); + + vip = devm_kzalloc(&pdev->dev, sizeof(*vip), GFP_KERNEL); + if (!vip) + return -ENOMEM; + + vip->soc = of_device_get_match_data(&pdev->dev); + + vip->dev = &pdev->dev; + platform_set_drvdata(pdev, vip); + + /* initialize host1x interface */ + INIT_LIST_HEAD(&vip->client.list); + vip->client.ops = &vip_client_ops; + vip->client.dev = &pdev->dev; + + err = host1x_client_register(&vip->client); + if (err) + return dev_err_probe(&pdev->dev, err, "failed to register host1x client\n"); + + pm_runtime_enable(&pdev->dev); + + return 0; +} + +static int tegra_vip_remove(struct platform_device *pdev) +{ + struct tegra_vip *vip = platform_get_drvdata(pdev); + int err; + + err = host1x_client_unregister(&vip->client); + if (err) + return dev_err_probe(&pdev->dev, err, "failed to unregister host1x client\n"); + + pm_runtime_disable(&pdev->dev); + + return 0; +} + +static const struct of_device_id tegra_vip_of_id_table[] = { +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-vip", .data = &tegra20_vip_soc }, +#endif + { } +}; +MODULE_DEVICE_TABLE(of, tegra_vip_of_id_table); + +struct platform_driver tegra_vip_driver = { + .driver = { + .name = "tegra-vip", + .of_match_table = tegra_vip_of_id_table, + }, + .probe = tegra_vip_probe, + .remove = tegra_vip_remove, +}; diff --git a/drivers/staging/media/tegra-video/vip.h b/drivers/staging/media/tegra-video/vip.h new file mode 100644 index 000000000000..58b3ec28c364 --- /dev/null +++ b/drivers/staging/media/tegra-video/vip.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2022 SKIDATA GmbH + * Author: Luca Ceresoli + */ + +#ifndef __TEGRA_VIP_H__ +#define __TEGRA_VIP_H__ + +#include +#include +#include + +enum { + TEGRA_VIP_PAD_SINK, + TEGRA_VIP_PAD_SOURCE, + TEGRA_VIP_PADS_NUM, +}; + +struct tegra_vip; + +/** + * struct tegra_vip_channel - Tegra VIP (parallel video capture) channel + * + * @subdev: V4L2 subdevice associated with this channel + * @pads: media pads for the subdevice entity + * @of_node: vip device tree node + */ +struct tegra_vip_channel { + struct v4l2_subdev subdev; + struct media_pad pads[TEGRA_VIP_PADS_NUM]; + struct device_node *of_node; +}; + +/** + * struct tegra_vip_ops - Tegra VIP operations + * + * @vip_start_streaming: programs vip hardware to enable streaming. + */ +struct tegra_vip_ops { + int (*vip_start_streaming)(struct tegra_vip_channel *vip_chan); +}; + +/** + * struct tegra_vip_soc - NVIDIA Tegra VIP SoC structure + * + * @ops: vip hardware operations + */ +struct tegra_vip_soc { + const struct tegra_vip_ops *ops; +}; + +/** + * struct tegra_vip - NVIDIA Tegra VIP device structure + * + * @dev: device struct + * @client: host1x_client struct + * @soc: pointer to SoC data structure + * @chan: the VIP channel + */ +struct tegra_vip { + struct device *dev; + struct host1x_client client; + const struct tegra_vip_soc *soc; + struct tegra_vip_channel chan; +}; + +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) +extern const struct tegra_vip_soc tegra20_vip_soc; +#endif + +#endif From patchwork Mon Nov 28 15:23:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 26843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5751959wrr; Mon, 28 Nov 2022 07:30:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5HvfxHO4fGZVWmkc7HH2oUUC6MTJGQgxMvlSIpB1CFzpYKNO7qX3OIwh3ryDbZpYUPhU2Z X-Received: by 2002:a05:6402:899:b0:46a:c6d3:eeb1 with SMTP id e25-20020a056402089900b0046ac6d3eeb1mr15039137edy.141.1669649440681; Mon, 28 Nov 2022 07:30:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649440; cv=none; d=google.com; s=arc-20160816; b=mJIEFsyr0jiVaIuN9sFWQf6/NQd94Mi4K8ef2omWVRiR5CXAfMm7wyo95Ug2PvTHBY F4EuVF6Al40jjTjnB1GloXAxoutDfIGeIlufmLbB4LQbbWEqiWlWIGFRKT7nttmCB6mD zZABUEDXaT0NJUfTNBTozwuuhrpiNCluILhrclhCL22V/vr6rC2xFvKJ1r7Lqiq5k0nB 8Un/74udatVvW1h7ErsfpfSqOIbOb4ZKGnLe+SOKq+3kN7y3mW2jDDi4dwi077EwYDLV nPXydbS/Kru/zWC7HTxnVDyTQiN5zezvX7WV8vXHsW2jNgsEnh+b91cdFyrvniQvM/kQ 5yQg== 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=xdXrhPG0nMnVZkGqWG5Nps9bsJmZujugVgt8Zlukom8=; b=C+l0O7fRDI03lDAZZqh2RVA9oSA6GU1YrbDzKunyapkcx1Jyhj1ezCDlPkImpWnT5K gguiN3GcnQXYEP5+LE9rM6aKvApeIVCphHTym8Z+3TO/b+lIanlFx9dWERPXGccmugqf i1IZc9xyuq5KfZ6ebEtVWgUk7aZ4ib3lymfBR84pvXBGTMpa2T/paG8okIOt4+2kxgB1 q9J13MuIsEzKXwdxgwpNVrXqqGCfAsVF4NyigevQGXVXwG1RjIffrCYMgp+6QK+3bO+Q YIAhLnzL97/hn4aCLWF4gG60oM7+QoSBJ+GhD2ge3BaDyCP7BBnhkWNiKKsmIFDFeHmB f6PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="LA/NfJby"; 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 cs17-20020a170906dc9100b00780def41dc4si10166653ejc.527.2022.11.28.07.30.15; Mon, 28 Nov 2022 07:30: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="LA/NfJby"; 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 S232463AbiK1P2r (ORCPT + 99 others); Mon, 28 Nov 2022 10:28:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbiK1P2K (ORCPT ); Mon, 28 Nov 2022 10:28:10 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1E9111A18; Mon, 28 Nov 2022 07:26:10 -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 4C34F100009; Mon, 28 Nov 2022 15:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669649169; 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=xdXrhPG0nMnVZkGqWG5Nps9bsJmZujugVgt8Zlukom8=; b=LA/NfJbyp4jY8FSmkomNVhPTCA2X/oeH8sfLShC+zvUW9c4a97ktYsRs9dQKqCfurz0uOG jOk/XI4kTK1AoJzEKXGbIwboCdjpCdWxC3RV3aOzGyLY9kX3jAdIWlynp/l0B/5/VyY+xi 06UcF1GWVD70E5EqcWtUzSVX5qBdXBKxPIT+i4YHdmG3JuyOdoFkX2wlfUfaqNQneoRxf+ 8aSVbAPf38NFGERVlh4owFza8oLF6O8CB3cQNCrGjemcvKLDMQ8M4Hus90pjuw0Qy+gt7X bRmUSIOTtRxNPcErUh5aV8+/3YntDhjeHBSuUnI5E4SIHRjQ5aL0ywplK3q8xg== From: Luca Ceresoli To: David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Mauro Carvalho Chehab , Greg Kroah-Hartman , Dmitry Osipenko , Hans Verkuil Cc: Luca Ceresoli , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Thomas Petazzoni , Paul Kocialkowski , Richard Leitner Subject: [PATCH v2 21/21] staging: media: tegra-video: add tegra20 variant Date: Mon, 28 Nov 2022 16:23:36 +0100 Message-Id: <20221128152336.133953-22-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221128152336.133953-1-luca.ceresoli@bootlin.com> References: <20221128152336.133953-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?1750754331844592879?= X-GMAIL-MSGID: =?utf-8?q?1750754331844592879?= The staging tegra-video driver currently implements MIPI CSI-2 video capture for Tegra210. Add support for parallel video capture (VIP) on Tegra20. With the generalizations added to the VI driver in previous commits, this is only a matter of adding the tegra20.c implementation and registering it. Unfortunately there was no documentation available for the VI or VIP peripherals of Tegra20 (or any other Tegra chips). This implementation has been based entirely on the code from a vendor kernel based on Linux 3.1 and massively adapted to fit into the tegra-video driver. Parts of this code is definitely non-optimal to say the least (especially tegra20_vi_enable() and the single-frame capture logic), but it was impossible to improve it. Signed-off-by: Luca Ceresoli --- 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) --- MAINTAINERS | 1 + drivers/staging/media/tegra-video/Makefile | 1 + 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 + 7 files changed, 675 insertions(+) create mode 100644 drivers/staging/media/tegra-video/tegra20.c diff --git a/MAINTAINERS b/MAINTAINERS index 1601465e8e31..9869746863b2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20322,6 +20322,7 @@ L: linux-tegra@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml +F: drivers/staging/media/tegra-video/tegra20.c F: drivers/staging/media/tegra-video/vip.* TEGRA XUSB PADCTL DRIVER diff --git a/drivers/staging/media/tegra-video/Makefile b/drivers/staging/media/tegra-video/Makefile index 3c8ec1bb1f3e..6c7552e05109 100644 --- a/drivers/staging/media/tegra-video/Makefile +++ b/drivers/staging/media/tegra-video/Makefile @@ -5,5 +5,6 @@ tegra-video-objs := \ vip.o \ csi.o +tegra-video-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20.o tegra-video-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o obj-$(CONFIG_VIDEO_TEGRA) += tegra-video.o diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c new file mode 100644 index 000000000000..002a66d12ecb --- /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->out_sp = out_sp; + + return 0; +} + +static void tegra20_channel_host1x_syncpt_free(struct tegra_vi_channel *chan) +{ + host1x_syncpt_put(chan->out_sp); +} + +static void tegra20_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp) +{ + 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) +{ + u32 value; + int err; + + chan->next_out_sp_idx++; + + tegra20_channel_vi_buffer_setup(chan, buf); + + tegra20_vi_write(chan, TEGRA_VI_CAMERA_CONTROL, VI_CAMERA_CONTROL_VIP_ENABLE); + + /* Wait for syncpt counter to reach frame start event threshold */ + err = host1x_syncpt_wait(chan->out_sp, chan->next_out_sp_idx, + TEGRA_VI_SYNCPT_WAIT_TIMEOUT, &value); + if (err) { + host1x_syncpt_incr(chan->out_sp); + dev_err_ratelimited(&chan->video.dev, "frame start syncpt timeout: %d\n", err); + release_buffer(chan, buf, VB2_BUF_STATE_ERROR); + return err; + } + + tegra20_vi_write(chan, TEGRA_VI_CAMERA_CONTROL, + VI_CAMERA_CONTROL_STOP_CAPTURE | VI_CAMERA_CONTROL_VIP_ENABLE); + + release_buffer(chan, buf, VB2_BUF_STATE_DONE); + + return 0; +} + +static int tegra20_chan_capture_kthread_start(void *data) +{ + struct tegra_vi_channel *chan = data; + struct tegra_channel_buffer *buf; + unsigned int retries = 0; + int err = 0; + + while (1) { + /* + * Source is not streaming if error is non-zero. + * So, do not dequeue buffers on error and let the thread sleep + * till kthread stop signal is received. + */ + wait_event_interruptible(chan->start_wait, + kthread_should_stop() || + (!list_empty(&chan->capture) && !err)); + + if (kthread_should_stop()) + break; + + /* dequeue the buffer and start capture */ + spin_lock(&chan->start_lock); + if (list_empty(&chan->capture)) { + spin_unlock(&chan->start_lock); + continue; + } + + buf = list_first_entry(&chan->capture, struct tegra_channel_buffer, queue); + list_del_init(&buf->queue); + spin_unlock(&chan->start_lock); + + err = tegra20_channel_capture_frame(chan, buf); + if (!err) { + retries = 0; + continue; + } + + if (retries++ > chan->syncpt_timeout_retry) + vb2_queue_error(&chan->queue); + else + err = 0; + } + + return 0; +} + +static void tegra20_camera_capture_setup(struct tegra_vi_channel *chan) +{ + u32 output_fourcc = chan->format.pixelformat; + int width = chan->format.width; + int height = chan->format.height; + int stride_l = chan->format.bytesperline; + int stride_c = (output_fourcc == V4L2_PIX_FMT_YUV420 || + output_fourcc == V4L2_PIX_FMT_YVU420) ? 1 : 0; + int main_output_format; + int yuv_output_format; + + tegra20_vi_get_output_formats(chan, &main_output_format, &yuv_output_format); + + /* + * Set up low pass filter. Use 0x240 for chromaticity and 0x240 + * for luminance, which is the default and means not to touch + * anything. + */ + tegra20_vi_write(chan, TEGRA_VI_H_LPF_CONTROL, + 0x0240 << VI_H_LPF_CONTROL_LUMA_SFT | + 0x0240 << VI_H_LPF_CONTROL_CHROMA_SFT); + + /* Set up raise-on-edge, so we get an interrupt on end of frame. */ + tegra20_vi_write(chan, TEGRA_VI_VI_RAISE, VI_VI_RAISE_ON_EDGE); + + tegra20_vi_write(chan, TEGRA_VI_VI_FIRST_OUTPUT_CONTROL, + (chan->vflip ? VI_OUTPUT_V_DIRECTION : 0) | + (chan->hflip ? VI_OUTPUT_H_DIRECTION : 0) | + yuv_output_format << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT | + main_output_format << VI_OUTPUT_OUTPUT_FORMAT_SFT); + + /* Set up frame size */ + tegra20_vi_write(chan, TEGRA_VI_FIRST_OUTPUT_FRAME_SIZE, + height << VI_FIRST_OUTPUT_FRAME_HEIGHT_SFT | + width << VI_FIRST_OUTPUT_FRAME_WIDTH_SFT); + + /* First output memory enabled */ + tegra20_vi_write(chan, TEGRA_VI_VI_ENABLE, 0); + + /* Set the number of frames in the buffer */ + tegra20_vi_write(chan, TEGRA_VI_VB0_COUNT_FIRST, 1); + + /* Set up buffer frame size */ + tegra20_vi_write(chan, TEGRA_VI_VB0_SIZE_FIRST, + height << VI_VB0_SIZE_FIRST_V_SFT | + width << VI_VB0_SIZE_FIRST_H_SFT); + + tegra20_vi_write(chan, TEGRA_VI_VB0_BUFFER_STRIDE_FIRST, + stride_l << VI_VB0_BUFFER_STRIDE_FIRST_LUMA_SFT | + stride_c << VI_VB0_BUFFER_STRIDE_FIRST_CHROMA_SFT); + + tegra20_vi_write(chan, TEGRA_VI_VI_ENABLE, 0); +} + +static int tegra20_vi_start_streaming(struct vb2_queue *vq, u32 count) +{ + struct tegra_vi_channel *chan = vb2_get_drv_priv(vq); + struct media_pipeline *pipe = &chan->video.pipe; + int err; + + chan->next_out_sp_idx = host1x_syncpt_read(chan->out_sp); + + err = video_device_pipeline_start(&chan->video, pipe); + if (err) + goto error_pipeline_start; + + tegra20_camera_capture_setup(chan); + + err = tegra_channel_set_stream(chan, true); + if (err) + goto error_set_stream; + + chan->sequence = 0; + + chan->kthread_start_capture = kthread_run(tegra20_chan_capture_kthread_start, + chan, "%s:0", chan->video.name); + if (IS_ERR(chan->kthread_start_capture)) { + err = PTR_ERR(chan->kthread_start_capture); + chan->kthread_start_capture = NULL; + dev_err_probe(&chan->video.dev, err, "failed to run capture kthread\n"); + goto error_kthread_start; + } + + return 0; + +error_kthread_start: + tegra_channel_set_stream(chan, false); +error_set_stream: + video_device_pipeline_stop(&chan->video); +error_pipeline_start: + tegra_channel_release_buffers(chan, VB2_BUF_STATE_QUEUED); + + return err; +} + +static void tegra20_vi_stop_streaming(struct vb2_queue *vq) +{ + struct tegra_vi_channel *chan = vb2_get_drv_priv(vq); + + if (chan->kthread_start_capture) { + kthread_stop(chan->kthread_start_capture); + chan->kthread_start_capture = NULL; + } + + tegra_channel_release_buffers(chan, VB2_BUF_STATE_ERROR); + tegra_channel_set_stream(chan, false); + video_device_pipeline_stop(&chan->video); +} + +static const struct tegra_vi_ops tegra20_vi_ops = { + .vi_enable = tegra20_vi_enable, + .channel_host1x_syncpt_init = tegra20_channel_host1x_syncpt_init, + .channel_host1x_syncpt_free = tegra20_channel_host1x_syncpt_free, + .vi_fmt_align = tegra20_fmt_align, + .channel_queue_setup = tegra20_channel_queue_setup, + .vi_start_streaming = tegra20_vi_start_streaming, + .vi_stop_streaming = tegra20_vi_stop_streaming, +}; + +#define TEGRA20_VIDEO_FMT(MBUS_CODE, BPP, FOURCC) \ +{ \ + .code = MEDIA_BUS_FMT_##MBUS_CODE, \ + .bpp = BPP, \ + .fourcc = V4L2_PIX_FMT_##FOURCC, \ +} + +static const struct tegra_video_format tegra20_video_formats[] = { + TEGRA20_VIDEO_FMT(UYVY8_2X8, 2, UYVY), + TEGRA20_VIDEO_FMT(VYUY8_2X8, 2, VYUY), + TEGRA20_VIDEO_FMT(YUYV8_2X8, 2, YUYV), + TEGRA20_VIDEO_FMT(YVYU8_2X8, 2, YVYU), + TEGRA20_VIDEO_FMT(UYVY8_2X8, 1, YUV420), + TEGRA20_VIDEO_FMT(UYVY8_2X8, 1, YVU420), +}; + +const struct tegra_vi_soc tegra20_vi_soc = { + .video_formats = tegra20_video_formats, + .nformats = ARRAY_SIZE(tegra20_video_formats), + .default_video_format = &tegra20_video_formats[0], + .ops = &tegra20_vi_ops, + .vi_max_channels = 1, /* parallel input (VIP) */ + .vi_max_clk_hz = 150000000, + .has_h_v_flip = true, +}; + +/* -------------------------------------------------------------------------- + * VIP + */ + +/* + * VIP-specific configuration for stream start. + * + * Whatever is common among VIP and CSI is done by the VI component (see + * tegra20_vi_start_streaming()). Here we do what is VIP-specific. + */ +static int tegra20_vip_start_streaming(struct tegra_vip_channel *vip_chan) +{ + struct tegra_vi_channel *vi_chan = v4l2_get_subdev_hostdata(&vip_chan->subdev); + int width = vi_chan->format.width; + int height = vi_chan->format.height; + + unsigned int main_input_format; + unsigned int yuv_input_format; + + tegra20_vi_get_input_formats(vi_chan, &main_input_format, &yuv_input_format); + + tegra20_vi_write(vi_chan, TEGRA_VI_VI_CORE_CONTROL, 0); + + tegra20_vi_write(vi_chan, TEGRA_VI_VI_INPUT_CONTROL, + VI_INPUT_VIP_INPUT_ENABLE | main_input_format | yuv_input_format); + + tegra20_vi_write(vi_chan, TEGRA_VI_V_DOWNSCALE_CONTROL, 0); + tegra20_vi_write(vi_chan, TEGRA_VI_H_DOWNSCALE_CONTROL, 0); + + tegra20_vi_write(vi_chan, TEGRA_VI_VIP_V_ACTIVE, height << VI_VIP_V_ACTIVE_PERIOD_SFT); + tegra20_vi_write(vi_chan, TEGRA_VI_VIP_H_ACTIVE, + roundup(width, 2) << VI_VIP_H_ACTIVE_PERIOD_SFT); + + /* + * For VIP, D9..D2 is mapped to the video decoder's P7..P0. + * Disable/mask out the other Dn wires. When not in BT656 + * mode we also need the V/H sync. + */ + tegra20_vi_write(vi_chan, TEGRA_VI_PIN_INPUT_ENABLE, + GENMASK(9, 2) << VI_PIN_INPUT_VD_SFT | + VI_PIN_INPUT_HSYNC | VI_PIN_INPUT_VSYNC); + tegra20_vi_write(vi_chan, TEGRA_VI_VI_DATA_INPUT_CONTROL, + GENMASK(9, 2) << VI_DATA_INPUT_SFT); + tegra20_vi_write(vi_chan, TEGRA_VI_PIN_INVERSION, 0); + + tegra20_vi_write(vi_chan, TEGRA_VI_CONT_SYNCPT_OUT_1, + VI_CONT_SYNCPT_OUT_1_CONTINUOUS_SYNCPT | + host1x_syncpt_id(vi_chan->out_sp) << VI_CONT_SYNCPT_OUT_1_SYNCPT_IDX_SFT); + + tegra20_vi_write(vi_chan, TEGRA_VI_CAMERA_CONTROL, VI_CAMERA_CONTROL_STOP_CAPTURE); + + return 0; +} + +static const struct tegra_vip_ops tegra20_vip_ops = { + .vip_start_streaming = tegra20_vip_start_streaming, +}; + +const struct tegra_vip_soc tegra20_vip_soc = { + .ops = &tegra20_vip_ops, +}; diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 0dbc3da6f98c..193ef948542a 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1862,6 +1862,9 @@ static int tegra_vi_remove(struct platform_device *pdev) } static const struct of_device_id tegra_vi_of_id_table[] = { +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-vi", .data = &tegra20_vi_soc }, +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC) { .compatible = "nvidia,tegra210-vi", .data = &tegra210_vi_soc }, #endif diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 7cb038957f1b..d11822c7b6ed 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -293,6 +293,9 @@ struct tegra_video_format { u32 fourcc; }; +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) +extern const struct tegra_vi_soc tegra20_vi_soc; +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC) extern const struct tegra_vi_soc tegra210_vi_soc; #endif diff --git a/drivers/staging/media/tegra-video/video.c b/drivers/staging/media/tegra-video/video.c index d966b319553f..074ad0dc56ca 100644 --- a/drivers/staging/media/tegra-video/video.c +++ b/drivers/staging/media/tegra-video/video.c @@ -123,6 +123,10 @@ static int host1x_video_remove(struct host1x_device *dev) } static const struct of_device_id host1x_video_subdevs[] = { +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-vip", }, + { .compatible = "nvidia,tegra20-vi", }, +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC) { .compatible = "nvidia,tegra210-csi", }, { .compatible = "nvidia,tegra210-vi", }, @@ -141,6 +145,7 @@ static struct host1x_driver host1x_video_driver = { static struct platform_driver * const drivers[] = { &tegra_csi_driver, + &tegra_vip_driver, &tegra_vi_driver, }; diff --git a/drivers/staging/media/tegra-video/video.h b/drivers/staging/media/tegra-video/video.h index 1e9be1474a9c..7275affa6558 100644 --- a/drivers/staging/media/tegra-video/video.h +++ b/drivers/staging/media/tegra-video/video.h @@ -24,5 +24,6 @@ int tegra_v4l2_nodes_setup_tpg(struct tegra_video_device *vid); void tegra_v4l2_nodes_cleanup_tpg(struct tegra_video_device *vid); extern struct platform_driver tegra_vi_driver; +extern struct platform_driver tegra_vip_driver; extern struct platform_driver tegra_csi_driver; #endif