From patchwork Thu Mar 9 14:43:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp342407wrd; Thu, 9 Mar 2023 07:09:15 -0800 (PST) X-Google-Smtp-Source: AK7set/SG2NE0s9f8pXNjTt75XY6JmvR9+i3q9lETQ9hR90qmo6Hp4okFZ2KtU4YaAmD2AKdtXQs X-Received: by 2002:a05:6e02:1e06:b0:315:5467:4a3f with SMTP id g6-20020a056e021e0600b0031554674a3fmr18604425ila.30.1678374555328; Thu, 09 Mar 2023 07:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374555; cv=none; d=google.com; s=arc-20160816; b=bvs2MjB/I2N/MOJSORiCKI9376FgELF/tYdkXlDJtuZ5RzMVtshq6Eiz+lQQzP9d9Q ytnBzsoIHGG/iP+ihBqnz6IRQSsXLH7TtWkOnR4TNylONmAp0IBafUnx2ZgMD0Mnpd9D LBPq9/5mNHdLwYODHm8577oX49jKhz4RzALhduH9XyjcrvNQCwx5Ch8nMGMexjbeeK5B wh+VNCt5MNJU5vfbmd2LjDJY6HRSO/0MjQvIhcVUNfw5wiUzCcN7wAw7Gcp3ejrlNNmB 5m4T3+vbSc4YXKm3wk0P5GQhsRvPy27ZbVwsdvyTHZp1f63hlQKV2eaR/wXg3jELGqQT ROXQ== 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=CT67MMLTBEUvKlkZQjsLOaHRSzjrMn01Y3mlBcSceNI=; b=HROICujKGOkYtoDhTAlQHOxRJeITexZ6lbs/VOAj/DaXzt7gWR52lUuaDLEcSHmDPi h4DCxPLNyip0l8dQpQik1+tRpz00jTDVxQKnuqK9m1k5nvGaE9Hafwq1s2gp8pmZBEbw kPRBY2TcC4ZvttNl8ucs2oD6SxdY5mw0MIxe8JKCMTVgYGYVEOjC+sV2UNJml5V7EhL/ G536udGFb+IgHuickYIWgDqaF/JVEo516bYl+UfOhB/qPuVz4MqV9mkw3mtQpsqNrbER YunsJEcy5PKJX2o7tK4+gz4Rvvu633WMCO3FZydxO9gVxZiwkR9qissJFdkMql1mR49w EunQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=S6lR2S4o; 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 o8-20020a02cc28000000b003de32f6fbcbsi18632752jap.4.2023.03.09.07.09.01; Thu, 09 Mar 2023 07:09:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=S6lR2S4o; 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 S231653AbjCIOnu (ORCPT + 99 others); Thu, 9 Mar 2023 09:43:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbjCIOnn (ORCPT ); Thu, 9 Mar 2023 09:43:43 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ED605DCAC; Thu, 9 Mar 2023 06:43: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 970E2FF80E; Thu, 9 Mar 2023 14:43:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373009; 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=CT67MMLTBEUvKlkZQjsLOaHRSzjrMn01Y3mlBcSceNI=; b=S6lR2S4ozCZk/ldMp002bGQ1jQt7jiiC2U9cUtom6TGz7iGG58WLdLPbn/fVbueihv0iaz oPkkB3vsCBLIAMK3p7j5mwJ0IPRMjrGyaXOPH70BGQsLRrDeEad+f61Z96FOI0Xtvsg2Fu 1d3Sraz6QdjbOOZ56Yy4lxByY0Nv4hCb5gQ1TxaOUo638mzUIw0A4XEipgPbGqUSkKpdSx 0bEDlURPmJ77DoLpvmDa7WrCDsjkt5ZxxNCyRWW0YN/nrjaVSsuTsCU0vOfi04JxQtqX8C +l4hGhRCgoqJxIOIYC1lb5lwkLjkS0lgSQ4ruoEceTe4jQyV3AcOj5O7p3tyQg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 01/21] dt-bindings: display: tegra: add Tegra20 VIP Date: Thu, 9 Mar 2023 15:43:00 +0100 Message-Id: <20230309144320.2937553-2-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903277963107200?= X-GMAIL-MSGID: =?utf-8?q?1759903277963107200?= VIP is the parallel video capture component within the video input subsystem of Tegra20 (and other Tegra chips, apparently). Signed-off-by: Luca Ceresoli Reviewed-by: Krzysztof Kozlowski Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags - remove leftover lines after removal of 'channel@0' Changed in v3: - remove channel@0 node (Krzysztof, Rob, Dmitry) - add myself as a maintainer of the whole Tegra video driver (Dmitry) Changed in v2 (suggested by Krzysztof Kozlowski): - remove redundant "bindings" from subject line - remove $nodename - add channel@0 description - add reg: const: 0 --- .../display/tegra/nvidia,tegra20-vip.yaml | 41 +++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 43 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..14294edb8d8c --- /dev/null +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml @@ -0,0 +1,41 @@ +# 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 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Port receiving the video stream from the sensor + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: + Port sending the video stream to the VI + + required: + - port@0 + - port@1 + +unevaluatedProperties: false + +required: + - compatible + - ports + +# see nvidia,tegra20-vi.yaml for an example diff --git a/MAINTAINERS b/MAINTAINERS index 8d5bc223f305..40c069c23d61 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20621,10 +20621,12 @@ TEGRA VIDEO DRIVER M: Thierry Reding M: Jonathan Hunter M: Sowjanya Komatineni +M: Luca Ceresoli L: linux-media@vger.kernel.org L: linux-tegra@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml F: drivers/staging/media/tegra-video/ TEGRA XUSB PADCTL DRIVER From patchwork Thu Mar 9 14:43:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp340892wrd; Thu, 9 Mar 2023 07:07:07 -0800 (PST) X-Google-Smtp-Source: AK7set8SpgUwygHgXGrGU+wG9q3smGNetOQCP0ijckS31GL83bYhaL3c5qxROrJAppt8Mi7gPoSt X-Received: by 2002:a05:6e02:1b89:b0:313:bbf8:29e9 with SMTP id h9-20020a056e021b8900b00313bbf829e9mr18712445ili.29.1678374427156; Thu, 09 Mar 2023 07:07:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374427; cv=none; d=google.com; s=arc-20160816; b=baKPjL8NGjrOn94MUZL4G9a5wArnUZd53QaSzQWv76Mzq1Nn4JnjeiEqU8EjcK6YU+ Hz/foE3xzV59gPbcOKSTHOunjMOtif9HZ2czEUwJCIMRZLNi8qu7+VtPAd8OPY4HWXTq ynOaOPEGmVbNaa8KuyOJ9T4KOdPKWxwazhZKwACHDOagBhE/Bxl1LlZFujB4lhaXm1xO w3op7502Qr8ATpV3ct8ClosfHjSDxgWeHe7ZjoKmeiyteFUJclzk6BEi93gD/abFrxPp NO8FkJckOlgBYv6O0xkLZKAPEevsx/O3ik8bml8x1QJtZ6l37FOeSTfJ/pP916OmL1yc 0ANg== 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=lfp1JTnwPTfj/UjslDrqJ1/mYiwVcdfrSzAoMsSMEwg=; b=HXc6vXnL87Ucv/OfyTCtl3Yuub8vrrO0UI2EnqiLCdG/R4NVgRIYr6JvHUA9ozz/Zy Su26uyFXDC8Y9rbCOQHYo6yOxM5scyDRMX6iE5pmZnbkp4eE8AFueCxgWrq1eHmJ1BUv vJBdtmGQZ37dywM/sgXQnkDBK1kPSNgzOMmd+Bi5oy+WTS0NH+8bTLQEbMX9iujJx7Fc dKjq5r38KX4CDLjOxIU0RW8j3GGGpn3as4mhlKPQ9FXfTSz7zGErDjAd0cUAyb8TIG7q 1s5uAeesiy5RomOM3hJQDtYTK5c3valMnYZXwrRSApsPZCoClWaN5lw2iJDcxcQNDF/a Eazg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jukT71uo; 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 a12-20020a056638018c00b003b204d76712si17147150jaq.27.2023.03.09.07.06.51; Thu, 09 Mar 2023 07:07:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jukT71uo; 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 S231744AbjCIOn6 (ORCPT + 99 others); Thu, 9 Mar 2023 09:43:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbjCIOno (ORCPT ); Thu, 9 Mar 2023 09:43:44 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8668658C26; Thu, 9 Mar 2023 06:43:33 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 8DD3DFF812; Thu, 9 Mar 2023 14:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373012; 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=lfp1JTnwPTfj/UjslDrqJ1/mYiwVcdfrSzAoMsSMEwg=; b=jukT71uo1zA9LDdqESCfOEfCVbHt2dRsvybS7/h6OTBXpmXN+2Xx3DfqsfnZRVv4VHagX3 1cOdcEUc6ej4Ca3R6Qt6lU/6HswF+L5f5ZSIfLUiP3Z2efSuP7VLYVV6k1pHPNobMsd5Lx PxnBzZsB+iRMgLdkOKoBp7zZuvZ4/899eUvzQVCGR68jEOgFP5ZEJAi7AVFzhO/s9EV2SB lDKuCADS8qWKscFHsurBkSnOO4+4sxdpeNmL1w0jOQtErFGnIym8P/Vy12DVP7hGMCvDU/ cec+K4GxuVvw8pN/4opMSvqYOzJHYebTWoxLPmb2vzhmV+jxIQWL6rP/pkFYEQ== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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 , Rob Herring Subject: [RESEND PATCH v4 02/21] dt-bindings: display: tegra: vi: add 'vip' property and example Date: Thu, 9 Mar 2023 15:43:01 +0100 Message-Id: <20230309144320.2937553-3-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903143023069690?= X-GMAIL-MSGID: =?utf-8?q?1759903143023069690?= The Tegra20 VI peripheral can receive parallel input from the VIP parallel input module. Add it to the allowed properties and augment the existing nvidia,tegra20-vi example to show a 'vip' property. Signed-off-by: Luca Ceresoli Reviewed-by: Rob Herring --- Changed in RESEND,v4: - Add Reviewed-by: Rob Herring Changed in v4: - complete the removal of 'channel@0' Changed in v3 (suggested by Rob Herring): - drop 'endpoint', unneeded as there's no extra properties in the endpoints Changed in v2 (suggested by Krzysztof Kozlowski): - rename "i2c3" -> "ic2" - add review tag --- .../display/tegra/nvidia,tegra20-vi.yaml | 59 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 60 insertions(+) diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml index a42bf33d1e7d..2181855a0920 100644 --- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml @@ -73,6 +73,18 @@ properties: avdd-dsi-csi-supply: description: DSI/CSI power supply. Must supply 1.2 V. + vip: + $ref: /schemas/display/tegra/nvidia,tegra20-vip.yaml + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Input from the VIP (parallel input capture) module + patternProperties: "^csi@[0-9a-f]+$": type: object @@ -108,6 +120,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>; @@ -115,6 +143,37 @@ examples: clocks = <&tegra_car TEGRA20_CLK_VI>; resets = <&tegra_car 100>; reset-names = "vi"; + + vip { + compatible = "nvidia,tegra20-vip"; + 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 40c069c23d61..9442f3458924 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20626,6 +20626,7 @@ L: linux-media@vger.kernel.org L: linux-tegra@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml F: drivers/staging/media/tegra-video/ From patchwork Thu Mar 9 14:43:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp340721wrd; Thu, 9 Mar 2023 07:06:53 -0800 (PST) X-Google-Smtp-Source: AK7set8HfZUCidwK5E01+BS6Ld/oNdjWKbRO6nBhMy8+50wZDGPPrWpi1JEnPeGBM4RJZ9ycCqHk X-Received: by 2002:a1f:fe09:0:b0:401:bc11:c051 with SMTP id l9-20020a1ffe09000000b00401bc11c051mr3393843vki.4.1678374413181; Thu, 09 Mar 2023 07:06:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374413; cv=none; d=google.com; s=arc-20160816; b=OeWDBfKJJESC661XufOVeXSAy/bIh0++iz81/BSZNhCBtAuIx3+d2dAsP7J7+1vvb7 dqkEGFMS8ra9ZLv4waCeZ1dXPgtLogW75OXgt7UWHbKWv35SRwHKS3F+tRh/wDuc/qqE ISYK3u5pqPUrwmua9lryL3480zlSnZ9kzxEJtocK1qIKU4+S8fYpKOIIK8OcSARBUBSq ROObkloqH+VwvZELaxdllOaKJ54xo5BCUZlPvzvYjC5rPKjZ5Q4QCQWAxJjkKQ65lDHB GPiIErBWmxor5Tm00KpUpvunRG4ZdkPVYeWfFNwXFZOZyQA/zw9mK5tA01TyPm55PC85 xgsQ== 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=iCnzSU9SA8/jWqoK96sIMGM1+kIb0sYFhLxz86NmmIE=; b=jM9hVp3nZY2REd3mCatGLIJ0KzTdOVyr3eCFHY7QV1+BIoKVqyxffTGW5Ym2akTm67 Cq8htnR4uJBQqIDk1KCAq9Uej6ekpdJeLutfpswkMcGQgDuxsu95RTa2nrmOtYbNH5Sd qBZkQMTZaueohLE2FTRTp+Zkqnsx/EiYunGWFR7OkYg7DcH5BA2twHm1O84x9FKamPlN kHROt6OZuhg9T0PNmyspWvve5SQBHlpsqG7UIyXk8YaTGv0dl00963JVdLkNHZ7fESk2 iG6bVtP6A2IzJyQ3/LmaMGUoZacIU7no/zHncYpzV7Wa9O1SDBCXRjouknmB0qfWhpGp zTNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=GyGIWm41; 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 b14-20020a67f84e000000b003d2358bc1f6si5872002vsp.213.2023.03.09.07.06.37; Thu, 09 Mar 2023 07:06: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=GyGIWm41; 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 S231847AbjCIOny (ORCPT + 99 others); Thu, 9 Mar 2023 09:43:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbjCIOno (ORCPT ); Thu, 9 Mar 2023 09:43:44 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 442866421D; Thu, 9 Mar 2023 06:43: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 4188DFF809; Thu, 9 Mar 2023 14:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373015; 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=iCnzSU9SA8/jWqoK96sIMGM1+kIb0sYFhLxz86NmmIE=; b=GyGIWm41Y3q8+iXXgLllCek3R1zHEhOCi4l6u1dR0bWCol+Iag1+LIRvKmwRNnw+n3AljT MpvuGSXXtn620bM7KjSZsu74ExbSAfiA/m+KcU3oRvRuaeU1Y+MOTiCzIEbhKIllVAkbDE Zm9M/u3+1N2bCzWiSuDMrxp9VaMgCkFtliqefMo5hvdXSbmmSSdfrXvXPkSNLIOmSClfho 01dL4eZRtnJsSVwwvZf8yAn9aU80TouT0o7yqvpPnqjbFJt1XosTZNwnvgxebhr1DeOhNk DmH3b2dK9HKUOH6suJS5fKIQUMbxhGhzHb3vuW6iW8WaiUr5UzxuFTRa18dNmw== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 03/21] staging: media: tegra-video: fix .vidioc_enum_fmt_vid_cap to return all formats Date: Thu, 9 Mar 2023 15:43:02 +0100 Message-Id: <20230309144320.2937553-4-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903128598740712?= X-GMAIL-MSGID: =?utf-8?q?1759903128598740712?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/tegra210.c | 7 +- drivers/staging/media/tegra-video/vi.c | 103 +------------------ drivers/staging/media/tegra-video/vi.h | 4 - 3 files changed, 9 insertions(+), 105 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra210.c b/drivers/staging/media/tegra-video/tegra210.c index d58370a84737..eb19dd5107ce 100644 --- a/drivers/staging/media/tegra-video/tegra210.c +++ b/drivers/staging/media/tegra-video/tegra210.c @@ -683,8 +683,12 @@ enum tegra210_image_format { V4L2_PIX_FMT_##FOURCC, \ } -/* Tegra210 supported video formats */ static const struct tegra_video_format tegra210_video_formats[] = { +#if IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG) + /* VI only support 2 formats in TPG mode */ + TEGRA210_VIDEO_FMT(RAW10, 10, SRGGB10_1X10, 2, T_R16_I, SRGGB10), + TEGRA210_VIDEO_FMT(RGB888, 24, RGB888_1X32_PADHI, 4, T_A8B8G8R8, RGBX32), +#else /* RAW 8 */ TEGRA210_VIDEO_FMT(RAW8, 8, SRGGB8_1X8, 1, T_L8, SRGGB8), TEGRA210_VIDEO_FMT(RAW8, 8, SGRBG8_1X8, 1, T_L8, SGRBG8), @@ -714,6 +718,7 @@ static const struct tegra_video_format tegra210_video_formats[] = { TEGRA210_VIDEO_FMT(YUV422_8, 16, VYUY8_2X8, 2, T_V8_Y8__U8_Y8, YUYV), TEGRA210_VIDEO_FMT(YUV422_8, 16, YUYV8_2X8, 2, T_Y8_U8__Y8_V8, VYUY), TEGRA210_VIDEO_FMT(YUV422_8, 16, YVYU8_2X8, 2, T_Y8_V8__Y8_U8, UYVY), +#endif }; /* Tegra210 VI operations */ diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 11dd142c98c5..9dba6e97ebdd 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -3,7 +3,6 @@ * Copyright (C) 2020 NVIDIA CORPORATION. All rights reserved. */ -#include #include #include #include @@ -73,15 +72,6 @@ static int tegra_get_format_idx_by_code(struct tegra_vi *vi, return -1; } -static u32 tegra_get_format_fourcc_by_idx(struct tegra_vi *vi, - unsigned int index) -{ - if (index >= vi->soc->nformats) - return -EINVAL; - - return vi->soc->video_formats[index].fourcc; -} - static const struct tegra_video_format * tegra_get_format_by_fourcc(struct tegra_vi *vi, u32 fourcc) { @@ -430,19 +420,12 @@ static int tegra_channel_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f) { struct tegra_vi_channel *chan = video_drvdata(file); - unsigned int index = 0, i; - unsigned long *fmts_bitmap = chan->tpg_fmts_bitmap; - - if (!IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) - fmts_bitmap = chan->fmts_bitmap; + const struct tegra_vi_soc *soc = chan->vi->soc; - if (f->index >= bitmap_weight(fmts_bitmap, MAX_FORMAT_NUM)) + if (f->index >= soc->nformats) return -EINVAL; - for (i = 0; i < f->index + 1; i++, index++) - index = find_next_bit(fmts_bitmap, MAX_FORMAT_NUM, index); - - f->pixelformat = tegra_get_format_fourcc_by_idx(chan->vi, index - 1); + f->pixelformat = soc->video_formats[f->index].fourcc; return 0; } @@ -1059,78 +1042,6 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) return 0; } -/* VI only support 2 formats in TPG mode */ -static void vi_tpg_fmts_bitmap_init(struct tegra_vi_channel *chan) -{ - int index; - - bitmap_zero(chan->tpg_fmts_bitmap, MAX_FORMAT_NUM); - - index = tegra_get_format_idx_by_code(chan->vi, - MEDIA_BUS_FMT_SRGGB10_1X10, 0); - bitmap_set(chan->tpg_fmts_bitmap, index, 1); - - index = tegra_get_format_idx_by_code(chan->vi, - MEDIA_BUS_FMT_RGB888_1X32_PADHI, - 0); - bitmap_set(chan->tpg_fmts_bitmap, index, 1); -} - -static int vi_fmts_bitmap_init(struct tegra_vi_channel *chan) -{ - int index, ret, match_code = 0; - struct v4l2_subdev *subdev; - struct v4l2_subdev_mbus_code_enum code = { - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - }; - - bitmap_zero(chan->fmts_bitmap, MAX_FORMAT_NUM); - - /* - * Set the bitmap bits based on all the matched formats between the - * available media bus formats of sub-device and the pre-defined Tegra - * supported video formats. - */ - subdev = tegra_channel_get_remote_source_subdev(chan); - while (1) { - ret = v4l2_subdev_call(subdev, pad, enum_mbus_code, - NULL, &code); - if (ret < 0) - break; - - index = tegra_get_format_idx_by_code(chan->vi, code.code, 0); - while (index >= 0) { - bitmap_set(chan->fmts_bitmap, index, 1); - if (!match_code) - match_code = code.code; - /* look for other formats with same mbus code */ - index = tegra_get_format_idx_by_code(chan->vi, - code.code, - index + 1); - } - - code.index++; - } - - /* - * Set the bitmap bit corresponding to default tegra video format if - * there are no matched formats. - */ - if (!match_code) { - match_code = tegra_default_format.code; - index = tegra_get_format_idx_by_code(chan->vi, match_code, 0); - if (WARN_ON(index < 0)) - return -EINVAL; - - bitmap_set(chan->fmts_bitmap, index, 1); - } - - /* initialize channel format to the sub-device active format */ - tegra_channel_set_subdev_active_fmt(chan); - - return 0; -} - static void tegra_channel_host1x_syncpts_free(struct tegra_vi_channel *chan) { int i; @@ -1501,7 +1412,6 @@ int tegra_v4l2_nodes_setup_tpg(struct tegra_video_device *vid) goto cleanup; v4l2_set_subdev_hostdata(&csi_chan->subdev, vi_chan); - vi_tpg_fmts_bitmap_init(vi_chan); csi_chan = list_next_entry(csi_chan, list); } @@ -1721,13 +1631,6 @@ static int tegra_vi_graph_notify_complete(struct v4l2_async_notifier *notifier) goto unregister_video; } - ret = vi_fmts_bitmap_init(chan); - if (ret < 0) { - dev_err(vi->dev, - "failed to initialize formats bitmap: %d\n", ret); - goto unregister_video; - } - subdev = tegra_channel_get_remote_csi_subdev(chan); if (!subdev) { ret = -ENODEV; diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index a68e2c02c7b0..183796c8a46a 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -163,8 +163,6 @@ struct tegra_vi_graph_entity { * * @ctrl_handler: V4L2 control handler of this video channel * @syncpt_timeout_retry: syncpt timeout retry count for the capture - * @fmts_bitmap: a bitmap for supported formats matching v4l2 subdev formats - * @tpg_fmts_bitmap: a bitmap for supported TPG formats * @pg_mode: test pattern generator mode (disabled/direct/patch) * @notifier: V4L2 asynchronous subdevs notifier */ @@ -205,8 +203,6 @@ struct tegra_vi_channel { struct v4l2_ctrl_handler ctrl_handler; unsigned int syncpt_timeout_retry; - DECLARE_BITMAP(fmts_bitmap, MAX_FORMAT_NUM); - DECLARE_BITMAP(tpg_fmts_bitmap, MAX_FORMAT_NUM); enum tegra_vi_pg_mode pg_mode; struct v4l2_async_notifier notifier; From patchwork Thu Mar 9 14:43:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp342698wrd; Thu, 9 Mar 2023 07:09:42 -0800 (PST) X-Google-Smtp-Source: AK7set8gUnawNnBWzMCIvXHOO3uRfP/kDuTY9ugID1Z4cuQOx+bTSI4oro+ZeAl93kfzCSTdsPHI X-Received: by 2002:a05:6e02:1527:b0:317:9d52:23c7 with SMTP id i7-20020a056e02152700b003179d5223c7mr4807052ilu.16.1678374582188; Thu, 09 Mar 2023 07:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374582; cv=none; d=google.com; s=arc-20160816; b=nL0/S6uIabatc5ZwVGZm7OHbjaK2TaA+BCQuvrs0Ts5Bq1yEQqq8exvEYbWqOpapQV Djgb+U9GjDVeC3kadeGEeGmLC5MTFUj4u2u8UDosca92fKbEAlJXjbiPPBphkEz3ksgI Map/yvPUk91gLiOIiOlU8Z6KFfUXbYXVtnW784LfZVJAit0YhHSh2N4C062labgV1tAt 04oaXfJYQ5pCespl1YwUtHz31NQhnleISwF8whVWpcbbeRpzIVVMXPY00q4dC8ovagnz s6JGvBlNV1kdgoMgCK093+as1poBgy2lq8s3UbqTUw5ZRpCpJthvodh0fkbts8jta7e5 U73Q== 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=9N6QfVVrKZcw1ffwFaVTv55AGDMNh1cJeI7q8gczYrk=; b=eTlt+SkoMwzRlwDH1i6KetTxTM8FbCWXCpf5/pJ//DMGUaBWGOogRASTp/paktrMVX ovQOLF+EvV5eG9aNODlpm0nuadMSqa2sPmPXGuInKfS5eQGp1+vBHz1ziZWbdMtmG38Z Tt9shwOX1sP4KD3IsHNQ/lvsmwyYs0yeIvmBFI4Cvahgfd1NBWiUI5lz33jTbau5RGVJ yx7LmCEU9ZVKbhZByaenV/8kak1Ki4DkhbWSWej9X6ohok3es3lwA3oEcnU/It+hs+Jx sd1fv0ESetqRC3Z1cwX4WINAfQ+jSBHnd+aPTn62g8cVFkWMABjhWUTr1/ChUrywe5f2 hb7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Uv3eV5mZ; 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 p7-20020a02c807000000b003e32e669e09si18772108jao.66.2023.03.09.07.09.26; Thu, 09 Mar 2023 07:09:42 -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=Uv3eV5mZ; 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 S231826AbjCIOoI (ORCPT + 99 others); Thu, 9 Mar 2023 09:44:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231529AbjCIOno (ORCPT ); Thu, 9 Mar 2023 09:43:44 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8061B6700A; Thu, 9 Mar 2023 06:43:39 -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 3B20FFF80B; Thu, 9 Mar 2023 14:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373018; 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=9N6QfVVrKZcw1ffwFaVTv55AGDMNh1cJeI7q8gczYrk=; b=Uv3eV5mZCvY3KesWZXC5+0mFnK2PEZ92/mQaqV0loDu/+jGzyUMGtjjdJnSne9Y2IG2OLe o1/Huyfjcn2U/GM7Dv1u6XS2xxNjEoBB2s/UZl+y0B3lvOh0oabbYuBdcPo/7JRbFR3zOh YmwQna/9i7ONlzSkxChfNfEECKVzliYQi3lRs1SGc+e3dvGYTglbDIL98IVI9E9IVrpYVv ok4o31CQGqjMh0S9UVLben+xuoca9090/eSF/K/ZRg82KbGzaQt1kZ0rL8QDtO1kKthWGL v7qCtw10/02P5CGDgylkRvl1IENo62u0ugtDLpSutrVDfu4WrQGh8r93S82cdg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 04/21] staging: media: tegra-video: improve documentation of tegra_video_format fields Date: Thu, 9 Mar 2023 15:43:03 +0100 Message-Id: <20230309144320.2937553-5-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903305764941821?= X-GMAIL-MSGID: =?utf-8?q?1759903305764941821?= Some fields are irrelevant for Tegra20/VIP. Add a note to clarify that. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 183796c8a46a..dd35c3ac992b 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -256,11 +256,11 @@ enum tegra_image_dt { /** * struct tegra_video_format - Tegra video format description * - * @img_dt: image data type - * @bit_width: format width in bits per component + * @img_dt: MIPI CSI-2 data type (for CSI-2 only) + * @bit_width: format width in bits per component (for CSI/Tegra210 only) * @code: media bus format code * @bpp: bytes per pixel (when stored in memory) - * @img_fmt: image format + * @img_fmt: image format (for CSI/Tegra210 only) * @fourcc: V4L2 pixel format FCC identifier */ struct tegra_video_format { From patchwork Thu Mar 9 14:43:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66901 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp339274wrd; Thu, 9 Mar 2023 07:04:55 -0800 (PST) X-Google-Smtp-Source: AK7set9tuTA30GYgCKZ9umOfB0G3EaAsKO7iOScaNsI53igiZd9Y40tR4PBs3NauAUeBfZT7e0b4 X-Received: by 2002:a05:6102:3e1f:b0:3f1:4f38:3ced with SMTP id j31-20020a0561023e1f00b003f14f383cedmr11790536vsv.25.1678374295234; Thu, 09 Mar 2023 07:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374295; cv=none; d=google.com; s=arc-20160816; b=oX8nI4DDXif75lAK15AnM8onoaEEnL+/7PHOE8U2DssyXDXoVG8+QLMFaDA7pqa6Ts qT9AEH36YKFhTyts65oWObfcTBae7fQRvbuhMA2WqZ++rjYr58KRAv4kg1+fUn0aKtYO vjqkNU6ncMFl8i7QeboKvZauxk5rlIXxtiu1y7TYBCAbgymXlXeL3gggmDxCnAhE7lj6 4wXLWlQBc7u0se9zTeRbvwQjeHMu/bmTsg5F9L2OfZMqxOx84Shayv+sQ8HhsBfJ26Hh 41VvAHRAFdXAuYM5zEqfSreu9NSfVvrv8jnWLrKtk+fN3YmDfI98BjD0ERsxy0PGC2mm PmzQ== 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=sSPKBUlHMxZ38nxoDS7iekTdWfdlYMqEzH/0zTPar3c=; b=ikxAPD7Vvk1m7tAFVkPYuAf4nAiPEaqcb80WwASZuDnGqjgpuSGd7OynjZeNbvM0Tb v0t7pi9buWvH17pGL9PKpDkoJ8gFGBlKtFdw9z7+rBwAxnmMTD0mG/9UC0WU8qc27fa2 16hQOibU3hOxxsBhaKIOuqx5sHRdu5nrmU8tNGiP4CbJy0njoU6wUqeRwlmS0Q0W9NB8 CZKvlxCSi44ykWJDI+sdZBqOT02ecTh9pp5qq1HmZ5Ni0TQLtfRFt4+eu4PIE3JQeHG7 EGRIQJHjTTEG3gWQQIYoOP/P+/0uq4XTWCd2a2f08e69M1lQMb+klPDXkQo5Ev8aCzO0 RTEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LVAzo6U4; 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 q19-20020a67de13000000b00421a3968318si5733237vsk.492.2023.03.09.07.04.39; Thu, 09 Mar 2023 07:04: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=LVAzo6U4; 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 S231895AbjCIOoC (ORCPT + 99 others); Thu, 9 Mar 2023 09:44:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231578AbjCIOnp (ORCPT ); Thu, 9 Mar 2023 09:43:45 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CFDB69225; Thu, 9 Mar 2023 06:43:42 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 7E5E1FF80D; Thu, 9 Mar 2023 14:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373021; 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=sSPKBUlHMxZ38nxoDS7iekTdWfdlYMqEzH/0zTPar3c=; b=LVAzo6U4GRI3Wv3Vtn6jsbj3QAABlzPp/YkjzsOrHYXfBCg1GQm5JjQw6kQLvVs4jAlRkS dadwxj6hKnAqWVuQhA/tZWdv7VHkL5utB++BKEGwY9vJZFQZShAM0pvZd+MsLECi51UbMb z4TJD1cs+n4YpU4q5vM38asta5I02JlJ3M+a9ouFnKluo0/IKKSi0MQeoLZg7AyjVA/kGr cNOgEfUpw02ARHR1OOMZit3Rd/rfa+44nZuSLeNEg/TNVCFgg4DLWlpJbDfpkazBzcmMCk KNpEtEg1taMAJa+UoGXh7PBCV6MTFrmh/d1Tin8Wi6grhY6Iivts07Gcrkk1tg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 05/21] staging: media: tegra-video: document tegra_channel_get_remote_source_subdev Date: Thu, 9 Mar 2023 15:43:04 +0100 Message-Id: <20230309144320.2937553-6-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903005039218578?= X-GMAIL-MSGID: =?utf-8?q?1759903005039218578?= Clarify what this function does. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 9dba6e97ebdd..6aecdd28bd82 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -154,6 +154,9 @@ tegra_channel_get_remote_csi_subdev(struct tegra_vi_channel *chan) return media_entity_to_v4l2_subdev(pad->entity); } +/* + * Walk up the chain until the initial source (e.g. image sensor) + */ struct v4l2_subdev * tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan) { From patchwork Thu Mar 9 14:43:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp339240wrd; Thu, 9 Mar 2023 07:04:52 -0800 (PST) X-Google-Smtp-Source: AK7set/8ZOnPMf05qMYiNXM60bl0NRMmsx64LBBOPQiWihR4j5oM8dWmtBzmuhmCTHVgDAc9XHbJ X-Received: by 2002:a1f:7c07:0:b0:40b:fc2:c06b with SMTP id x7-20020a1f7c07000000b0040b0fc2c06bmr12355927vkc.12.1678374292224; Thu, 09 Mar 2023 07:04:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374292; cv=none; d=google.com; s=arc-20160816; b=DSE/8syzN7uVIUhUtAX3syt6qI/z0r1uiGrv6KXqN6yOZffSurxDqDRk8Ib0E6Epsm ICDy2/fBwM0Wvw96DhdwE6xHu7PfDThFhcqRCMV0J2SnyApCkqwS5G4Vj8VpZ+c1P6ff 7hbp2XqncXYuHozgZ8NnOh0opNDp2RHlESsk44E2eN90hpTZqWX8Mxe9HZXF4rxBKTgu KzFoWY5/ct7GAgTPTpcRHDbqPG0ds2nCLi+RlvW3Ie0hXD3do1zYcSNZbJoHbV0wOS5m 3b7m8V+EX4zgU/VCCmv+Mv80RDTEJIb0djz3qWU8dmoSSqLjMQniM5xQ8FUCO5q407pw 4Wzg== 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=btI7/3wHZD79pSqQcpjZGNx3/m1OdsrdYrwOU237Q0U=; b=SAk6BAcbGsaBlM39WYnGoGpkfEnIe62BZ/2A9mMKjAlh+8tZgzzfXoB8xGQ/WUJbs6 FF1aX8jvSinhQqRltPoY7rqpgROFrEOcqdsNNEMxprYkyQ0rD3lNSIQ1W7/lOrEWNsDv 9lLycvLs/OQ2C/U4LsZ03LxPKdjLCUucVi8AirImgvsXYwjvQ/1QLnRaTtWujcKF1bsd rTKyUn4LEAizgYhts67GDfN83myeLJx8sXuOcRgwByGHEVUG7BPpiXdijdSN106DQp/4 bIQ7lMT2I6KZ4H5i4DJIc4nPKtyFJDLLRJk6vTi9JqmgzTvBufdcfrdca6M1t+9MLP5H 8XDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=BI2lNyYD; 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 g10-20020a67d48a000000b004134cb4d5dbsi5957058vsj.155.2023.03.09.07.04.33; Thu, 09 Mar 2023 07:04: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=BI2lNyYD; 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 S231901AbjCIOoE (ORCPT + 99 others); Thu, 9 Mar 2023 09:44:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231693AbjCIOnr (ORCPT ); Thu, 9 Mar 2023 09:43:47 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B66A13644D; Thu, 9 Mar 2023 06:43: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 757A0FF80A; Thu, 9 Mar 2023 14:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373024; 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=btI7/3wHZD79pSqQcpjZGNx3/m1OdsrdYrwOU237Q0U=; b=BI2lNyYDsVgKoDXhUghhDgOH+DYZNZBcqLr+nynN/ytbsgkIwF7+L525eowZAy6hkfcGBt ZJ+BujNToMxi3/PeEbdqTp7y8mUja3BV1fCYOhID9LZ4WsBogNYC1ufhZd+rIcBbHye6XB nSzWadFcdinilTm0F/inCZtvEGjUjLejxDQtA/pHnCo9dzDIex45fXdL8Tz6m7UGI7JqgX SlK6EpvSkNWQfAFVRr72ZgjzVrg9BYxkPQgToUyeq9PbS7ey7S/nH3rT+qR7LnMss5gAV0 pvimvqbqHtyvJwGOAgX1cAVI21eBskExMg8rwhh+DOxDjZozjYPa4hyjuajBsQ== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 06/21] staging: media: tegra-video: fix typos in comment Date: Thu, 9 Mar 2023 15:43:05 +0100 Message-Id: <20230309144320.2937553-7-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903001575757185?= X-GMAIL-MSGID: =?utf-8?q?1759903001575757185?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 6aecdd28bd82..ae7adf640e76 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1762,10 +1762,10 @@ static int tegra_vi_graph_init(struct tegra_vi *vi) * Walk the links to parse the full graph. Each channel will have * one endpoint of the composite node. Start by parsing the * composite node and parse the remote entities in turn. - * Each channel will register v4l2 async notifier to make the graph - * independent between the channels so we can the current channel + * Each channel will register a v4l2 async notifier to make the graph + * independent between the channels so we can skip the current channel * in case of something wrong during graph parsing and continue with - * next channels. + * the next channels. */ list_for_each_entry(chan, &vi->vi_chans, list) { struct fwnode_handle *ep, *remote; From patchwork Thu Mar 9 14:43:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp340761wrd; Thu, 9 Mar 2023 07:06:56 -0800 (PST) X-Google-Smtp-Source: AK7set++lr0vKy/ZO6ahHx/lfgVz3ghMVHYE7ok/SxTP62gvoJjzxTL4+jwHBbG4qYWx5MvVJyaX X-Received: by 2002:a05:6e02:1686:b0:318:8674:bf3 with SMTP id f6-20020a056e02168600b0031886740bf3mr18959659ila.19.1678374416734; Thu, 09 Mar 2023 07:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374416; cv=none; d=google.com; s=arc-20160816; b=Mt1UWcI8cidiwahd0E8JOgIJTHhgE0xDgKk0ZqpqfIpU7AmDpOHKV3L2WIhDQ6LyE5 hgbnzqiA9yDqTiWozSxUUd8PJv77H6VerDTE9LlSAQ0tcErX7zA4E6JGJY3US2wDg7Fo hFtRrkm0UpenzXsgijjryCdp5EFBVRLJTF5LcU7u1egc5wBMOuUjrkfCseAcrDDGSE2F RfMcNTtXZirhwE7WLX/cycFTIdjl/WT49tb+CADcV0v6+oUz0P9l3sXpcJTl+ndHctf5 NV4GJAcfFTNTxf+/I5gO2IisgVzTJkwK1EOYm3oCGrXjdaR5zJb/5tY3QrWd8ianHADH 5qRA== 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=451TUx22H90CFmnHFXlFDNWmX76XdwcrQAhLbpfaKUw=; b=twAoXo4lZCW7hfA3gckiUflRhwjhVmHIvnlUkkFcD3pgeePbnU3tNFjMCtBo6ovOYm b7ZbDM9aLyym9wpoSvj0oubUDZ5B0Jl1TuPjtGuD+40yoGXKS0l7YGvOkUJyAWOzOWk4 RJnsU1fkK/Y4m0qK6b2EVwPrV7idz3BwTOEqx3VhGSc1g+tcLCrD7iWWdpgevhw+NWoY q77FjlJBXnM9dvWqXwugmDAF6pW897UX+6dxl2AlPF3SWyzojEFsoB17GzS0kTlFwiMz MN7ZA81rB6XaPS/GdxfRExCFO4LL8NFiP/i4Iq0WvIT0PPzZ4XL7jCDoTgD5RLsU364B LMMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mq7+KrTV; 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 k11-20020a056e0205ab00b002ffbdf63f5asi17450072ils.165.2023.03.09.07.06.39; Thu, 09 Mar 2023 07:06: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=mq7+KrTV; 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 S231922AbjCIOoM (ORCPT + 99 others); Thu, 9 Mar 2023 09:44:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbjCIOnu (ORCPT ); Thu, 9 Mar 2023 09:43:50 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7338B9CBCF; Thu, 9 Mar 2023 06:43:48 -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 A2EADFF80E; Thu, 9 Mar 2023 14:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373027; 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=451TUx22H90CFmnHFXlFDNWmX76XdwcrQAhLbpfaKUw=; b=mq7+KrTVPw6s95NSvdNILqbdbuExDhvq2IrgGbVPAZe+Cn1ZUhHwsMX9UP/lO0wwOce5M3 G/6KyxfULvjL12il1akQ8amMHmb3BNsR2+fVLKJDd3hfjYx+S5N3C3pSZN4RcvoWEUulkQ qKejO8ictNddYclgwQylD42APTe9gx4lZ8iWhIJ+pvGjrJwXZAaBlU+tuz7e2PhDpPTYfL lQnftjmaL0CYD3tCOoFzfQtj5KvvsfsGrRihHK/BWLtIugjH6FWPTHiJGAjLE9nuzVNAkS CVqH5K+s9nLNLHUkWoI0xi6TvwX8PIhr+LWDJm+6D7OJIk/iTPbeClJC+WBhHg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 07/21] staging: media: tegra-video: improve error messages Date: Thu, 9 Mar 2023 15:43:06 +0100 Message-Id: <20230309144320.2937553-8-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903132076994524?= X-GMAIL-MSGID: =?utf-8?q?1759903132076994524?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index ae7adf640e76..0e5067a7986a 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1272,7 +1272,7 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) ports = of_get_child_by_name(node, "ports"); if (!ports) - return -ENODEV; + return dev_err_probe(vi->dev, -ENODEV, "%pOF: missing 'ports' node\n", node); for_each_child_of_node(ports, port) { if (!of_node_name_eq(port, "port")) @@ -1824,11 +1824,8 @@ static int tegra_vi_init(struct host1x_client *client) ret = tegra_vi_tpg_channels_alloc(vi); else ret = tegra_vi_channels_alloc(vi); - if (ret < 0) { - dev_err(vi->dev, - "failed to allocate vi channels: %d\n", ret); + if (ret < 0) goto free_chans; - } ret = tegra_vi_channels_init(vi); if (ret < 0) From patchwork Thu Mar 9 14:43:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66907 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp340584wrd; Thu, 9 Mar 2023 07:06:42 -0800 (PST) X-Google-Smtp-Source: AK7set/xKM5ksDSiVxKHLMsTWRFxN6v0EGtP/JLbvpGsVZjK4DszRrXXTeN17L3vcJfCLDj7soNs X-Received: by 2002:a92:8e0d:0:b0:318:d56e:9efa with SMTP id c13-20020a928e0d000000b00318d56e9efamr1974004ild.24.1678374402472; Thu, 09 Mar 2023 07:06:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374402; cv=none; d=google.com; s=arc-20160816; b=ufpjasM+V8dR7rjVnNsUSZqaJR16XRmjg0jMPJYO4o0X96yQAFikXAT7BGb8szzeln 09SmQVw9ggVRdtLJ+JJfI1g5kSpSw+5DdBnYnF77H7gpsTDQKHrPcXYUrTh02LJROBaD ODNfns4rwf4p0+FFcLIqjOeUdzH0L7nNRPqqPUJQQH58Cp+wsly7viynnxyv0ffLw925 LWx9ldtkXG8+XpfSFhB7VqdS5PjZdamwNFUJsy2vT1wPGi2VIvYvQ+yMNj8gqkDn8frV cGguew2WTDg5K128xoa88Wrgv0IhVxtiuCAojLYDmI1fSXveh4foiZ6/MQHRaBYTnOm4 fvVw== 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=wDKaDW07jRg6JKv4FccRmW/KLxnvUIW9HGrFo7N25X0=; b=I2eRjBB0fM4DzCKPBP0gdwBrOcDxkImxgPKyXy00yEFbH/wilrK3vF9FiFaymykMA+ Hg/TKvwUFAP8azlSdxE+AfGhq4p4NRQ6SU30njeNkYEUsMxxVkoL6NmfGPi4OsUAloR0 K7zPwooOm0saNob91SNSebkHtIz8ya/lGAMgfA7r7Ur1HG0LdJUnSaiIERyr/e0BlhDd IDPiz6OpGBWIoejio8fCrt+BeSFfin2nu1qn1Sq1GGSIvkHEPncKeecyC11IVxDl9tEM t7WuPWe1BtEd7o4koGu3q2sSczbWUAwk9LcHamPvQbyn5GKwK2BAGFIM1oR3/6kwR2iB C+Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=IYV03bgQ; 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 p14-20020a056e0206ce00b0031402bfcb5esi12115734ils.3.2023.03.09.07.06.28; Thu, 09 Mar 2023 07:06:42 -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=IYV03bgQ; 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 S231935AbjCIOoR (ORCPT + 99 others); Thu, 9 Mar 2023 09:44:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231857AbjCIOn4 (ORCPT ); Thu, 9 Mar 2023 09:43:56 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E479DBB7F; Thu, 9 Mar 2023 06:43: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 86648FF810; Thu, 9 Mar 2023 14:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373030; 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=wDKaDW07jRg6JKv4FccRmW/KLxnvUIW9HGrFo7N25X0=; b=IYV03bgQEurBUO/OPg+HK+WEGb/emCGeExOkkFBB27AQWtCJYUk00e0VfecSb1gqvBtzBM Z2dpgp6GXB4827yzcn6D10cZWAastWGmZD7aZR+x+JOHOIHljU81fxVG6QfSvnb+XwC97b EKrH0eXdhSMZFr541wcDo2hR6Z1JgXd0YuC9GyqotRZrlw1jd9fkIryvgRd/nc+wHObZPD 1o4U48bmto72p4fJ88Z4I6XtsT0Mi/w2EA35C6b574mwVm/hQx+bM6vFCuJbHKiC+z3ts/ Mjobgbyj+Ly6FkCvCdrFDjZ6kSLczoiEjS/f89c99Vo32+H97o3G79WuMhryng== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 08/21] staging: media: tegra-video: slightly simplify cleanup on errors Date: Thu, 9 Mar 2023 15:43:07 +0100 Message-Id: <20230309144320.2937553-9-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903117247524380?= X-GMAIL-MSGID: =?utf-8?q?1759903117247524380?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 0e5067a7986a..c2724e1ecafb 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1263,7 +1263,7 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) struct device_node *node = vi->dev->of_node; struct device_node *ep = NULL; struct device_node *ports; - struct device_node *port; + struct device_node *port = NULL; unsigned int port_num; struct device_node *parent; struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 }; @@ -1286,7 +1286,6 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) dev_err(vi->dev, "invalid port num %d for %pOF\n", port_num, port); ret = -EINVAL; - of_node_put(port); goto cleanup; } @@ -1309,13 +1308,12 @@ static int tegra_vi_channels_alloc(struct tegra_vi *vi) lanes = v4l2_ep.bus.mipi_csi2.num_data_lanes; ret = tegra_vi_channel_alloc(vi, port_num, port, lanes); - if (ret < 0) { - of_node_put(port); + if (ret < 0) goto cleanup; - } } cleanup: + of_node_put(port); of_node_put(ports); return ret; } From patchwork Thu Mar 9 14:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66918 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp342018wrd; Thu, 9 Mar 2023 07:08:35 -0800 (PST) X-Google-Smtp-Source: AK7set9GjrTMXgBrKV3kyfy+lErRLMuP7Md750Vxz/COmwBcEt5xTjC8UYWLw4U/k85Ca0osD7nD X-Received: by 2002:a92:c542:0:b0:317:9945:6058 with SMTP id a2-20020a92c542000000b0031799456058mr2780370ilj.9.1678374515381; Thu, 09 Mar 2023 07:08:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374515; cv=none; d=google.com; s=arc-20160816; b=fmtdSBxYWfWLAy4eVLi9tmCCES9JAb4IicBqkMEIe5LDWvCUercRgBMZ+o5e5Q+c7I yZnHAYnYU7wX95FWcoz9J47GpfswjNMMdb0fpuvuGSFWjUNgCd4eNbz+8D9jTDyz2niL QMM3tqgKPkPfx/FPKw6ffyXw6dR3dw03s1uxmeWWAZXVqY4Jook/EbWFcV5INTcFiKoN 9h8Fh//YDmzeGWOe9Y4nEghKSzn+64G3G2OZiVd6/jJmnWBtyHEmk4kqtku8NWR/3pk6 CqjfFSsZyHVfY9p/UPfwtp2VVNZ8umb+cuLqb1L0DX1UowuXHh13ZIaS6xRIRURCJ9jI y/4w== 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=YVn0bFe++VEmvAyVnkdMGRVeBq4VH9gdvivsVHKFovE=; b=SpN5SzwTR6cMwqnc/lOatE0VpIfp9A0NzdcXxdrfzNXbIxUYWTz+yXJFhAJeZeC7hf D1ce6Ihw7WXScEvCtr3gaxyuc27XZ5kMGrXV4/rpvUWV9Fu4TAZqwuUQq5UI/oeoVXdQ aKaAObFrWCmUskTaMZoE20dAWwfeFFQ5+JbaJpaIZcDfzI3pDRpRCnGAqbDjv6bboDlQ t3Lkjdcijtkur6wvWi2/5s7/p6OTm+R15plqTmTCqRDixmz/ppBWHM3WaNqwLek/jFvf t4tZb/owxRg9ZhNEW5gQYJ7+vELJVf5ymqs/i1BIc5YajcgKxwimgjSdtaW02sWv+ySZ cxHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=RhN+vML1; 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 c17-20020a92c8d1000000b0031791164fd3si18106244ilq.175.2023.03.09.07.08.19; Thu, 09 Mar 2023 07:08:35 -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=RhN+vML1; 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 S231874AbjCIOo3 (ORCPT + 99 others); Thu, 9 Mar 2023 09:44:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbjCIOn7 (ORCPT ); Thu, 9 Mar 2023 09:43:59 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88625D777; Thu, 9 Mar 2023 06:43:54 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 98A24FF80A; Thu, 9 Mar 2023 14:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373033; 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=YVn0bFe++VEmvAyVnkdMGRVeBq4VH9gdvivsVHKFovE=; b=RhN+vML1xYDK8Uh7AMFIzi08TOMhVqx87IIRB/AtGlfBEJTIbcy5pK11MDaGu984lmNTRA A9SArMgcG//YoQnbOXVfZwMZBn+eCUzHkh/H2Q3aDZ9biYoqNzf9ka2ygxY6AK876Lotk/ Wz+1qv9/VlIftJ/0T5uxDO1wE1DoX/XWlQkwMd8qTELEX0UNhXJE8p7yDeoLTiOQO/gc6R Vx7QssBa9zVudefR+kRdNFwJZh7O/2mnUJZHH+KFPiI4cPuI2v1pf8+yZmHnrKfwhfRK3x ppruKPTv69b2gJqZGG2P7twiH2tJ3pdOpVhdlvK7ZlvhrOaVM+69XuZ3Q010Iw== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 09/21] staging: media: tegra-video: move private struct declaration to C file Date: Thu, 9 Mar 2023 15:43:08 +0100 Message-Id: <20230309144320.2937553-10-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903235909529618?= X-GMAIL-MSGID: =?utf-8?q?1759903235909529618?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 13 +++++++++++++ drivers/staging/media/tegra-video/vi.h | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index c2724e1ecafb..4e48eaa0fbdc 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -31,6 +31,19 @@ #define MAX_CID_CONTROLS 1 +/** + * struct tegra_vi_graph_entity - Entity in the video graph + * + * @asd: subdev asynchronous registration information + * @entity: media entity from the corresponding V4L2 subdev + * @subdev: V4L2 subdev + */ +struct tegra_vi_graph_entity { + struct v4l2_async_subdev asd; + struct media_entity *entity; + struct v4l2_subdev *subdev; +}; + static const struct tegra_video_format tegra_default_format = { .img_dt = TEGRA_IMAGE_DT_RAW10, .bit_width = 10, diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index dd35c3ac992b..dfd834a69848 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -98,19 +98,6 @@ struct tegra_vi { struct list_head vi_chans; }; -/** - * struct tegra_vi_graph_entity - Entity in the video graph - * - * @asd: subdev asynchronous registration information - * @entity: media entity from the corresponding V4L2 subdev - * @subdev: V4L2 subdev - */ -struct tegra_vi_graph_entity { - struct v4l2_async_subdev asd; - struct media_entity *entity; - struct v4l2_subdev *subdev; -}; - /** * struct tegra_vi_channel - Tegra video channel * From patchwork Thu Mar 9 14:43:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66922 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp342334wrd; Thu, 9 Mar 2023 07:09:08 -0800 (PST) X-Google-Smtp-Source: AK7set+nxB/KSs3NIcCofk1U3LWKo7so0+JYggtszpHYToAnb1VtMh+/qgJIQKome9yfll+stKki X-Received: by 2002:a05:6e02:1907:b0:315:4169:c5ac with SMTP id w7-20020a056e02190700b003154169c5acmr20031178ilu.30.1678374547883; Thu, 09 Mar 2023 07:09:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374547; cv=none; d=google.com; s=arc-20160816; b=iM8oTwXXiGWMDUWeHpPwdRDbjymtTP2yrJepq+y18N2TIfD0R/ZiQi1Mndju8WmTQ7 9frtBu8QHD2VvSLNQTs/SX+9hlebdrhJzQJ4ZImA+Yv1K/pn1zGDWl212rpwhVBEvS58 QQLaeatiNCdJ8LOkn01QQyeIUth+bWWfeJ/PpgPXCeSB4m51ndtUmx8kyY+y3lkwYDeY Plrl9TLJw22q5CFTbkEM9ME9tuVp2UoG2vqZ8BAM2/9UJXlBDF9fieeaPOTUgAu4/6PK KqB8mhEOJGINSOOOeTapmNZJcFIrTmEA4H9rQ3H0St2iOHl/eOjwBcdvBE+3xEh8O3jU sIKw== 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=Q4BvN5HyJmKtSkjDUwF1rWQvQrWrP7q+NWC5eE97eRY=; b=Bx/5HiX73sn97rMf0QTAg9sJHFD4pBudYBq8r3f6KNASGl4qgPZfLFYn2FBTqRarW9 kvu4U/UkfbKJU1vOAUlk/c5c612HeGO+okoK5EscRqnD33JSpGl1NUaCauwtUb2pRQ3A 17AZwtILS8b52OZMjjpGC94sJ7RpKcnnO+eOD8poglX9EedwanG74j98suheZTtuPNcz 1oExoI0W5LlgVR+y7xqW9WJHJSyVJxXynUZqRrqTleKJQvuc/vMDxd1xOS61Llxpl7mI 1XUWU/DwRwJET9FgGTXiXyA/TG2BR4gp6oD22Z4DpCn1D0v2JiQot67imRMynNs9Q1dK EL3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HzODzW7t; 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 p7-20020a02c807000000b003e32e669e09si18772108jao.66.2023.03.09.07.08.49; Thu, 09 Mar 2023 07:09:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HzODzW7t; 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 S231865AbjCIOoe (ORCPT + 99 others); Thu, 9 Mar 2023 09:44:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231928AbjCIOoO (ORCPT ); Thu, 9 Mar 2023 09:44:14 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BB15E8AB4; Thu, 9 Mar 2023 06:43: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 484FBFF80D; Thu, 9 Mar 2023 14:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373035; 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=Q4BvN5HyJmKtSkjDUwF1rWQvQrWrP7q+NWC5eE97eRY=; b=HzODzW7t3QvOI5XCc1zDBndAcogj1UGvmYYo72CdTSH/Q9qOVdzu/7YKf05N8mGPvFZ4lA Y0o7DE0mHFpU7KChhvuVkURLo3mavQcMouiIRHPD0QqmSi1boFbCXb0f1zVUsE8iP1R9Sg bcFISDnyf9u0tLK7IMbjvG5hrGSkWQxaV88U/urXJ8qeFcTVDJGUclSdzSi8eBVthJudvQ ZiYGfz2hSZSuTv4fFvwA9MgQSBC+IZ29wEeV3+zRoWjJeyQfj5Sh78nBaaK7sCTUGSyzw7 uTLhMYzjpXyatcpq+BE0Z7+PWxP6baovJeI4FOFOTtDR+9yqV7VbzW/cJy4v1g== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 10/21] staging: media: tegra-video: move tegra210_csi_soc to C file Date: Thu, 9 Mar 2023 15:43:09 +0100 Message-Id: <20230309144320.2937553-11-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903269632729745?= X-GMAIL-MSGID: =?utf-8?q?1759903269632729745?= This declaration is used only in csi.c, no need to export it elsewhere. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags This patch was added in v3. --- drivers/staging/media/tegra-video/csi.c | 4 ++++ drivers/staging/media/tegra-video/csi.h | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/tegra-video/csi.c b/drivers/staging/media/tegra-video/csi.c index 426e653bd55d..9a03d5ccdf3c 100644 --- a/drivers/staging/media/tegra-video/csi.c +++ b/drivers/staging/media/tegra-video/csi.c @@ -792,6 +792,10 @@ static int tegra_csi_remove(struct platform_device *pdev) return 0; } +#if defined(CONFIG_ARCH_TEGRA_210_SOC) +extern const struct tegra_csi_soc tegra210_csi_soc; +#endif + static const struct of_device_id tegra_csi_of_id_table[] = { #if defined(CONFIG_ARCH_TEGRA_210_SOC) { .compatible = "nvidia,tegra210-csi", .data = &tegra210_csi_soc }, diff --git a/drivers/staging/media/tegra-video/csi.h b/drivers/staging/media/tegra-video/csi.h index 6960ea2e3d36..3e6e5ee1bb1e 100644 --- a/drivers/staging/media/tegra-video/csi.h +++ b/drivers/staging/media/tegra-video/csi.h @@ -151,10 +151,6 @@ struct tegra_csi { struct list_head csi_chans; }; -#if defined(CONFIG_ARCH_TEGRA_210_SOC) -extern const struct tegra_csi_soc tegra210_csi_soc; -#endif - void tegra_csi_error_recover(struct v4l2_subdev *subdev); void tegra_csi_calc_settle_time(struct tegra_csi_channel *csi_chan, u8 csi_port_num, From patchwork Thu Mar 9 14:43:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp337215wrd; Thu, 9 Mar 2023 07:02:25 -0800 (PST) X-Google-Smtp-Source: AK7set/9SLueVb62WqIHQWYVqn3eR9H8zjBUC5Yvz0xufJgfcKZH1HoSp9ZFyYwC7cycAPQ58TuZ X-Received: by 2002:a05:7500:d8c:b0:f8:1016:595f with SMTP id kn12-20020a0575000d8c00b000f81016595fmr329452gab.35.1678374144764; Thu, 09 Mar 2023 07:02:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374144; cv=none; d=google.com; s=arc-20160816; b=ixdsGA7Yi0Pul6p4By8qH47QI+ti7iYLPDqfKkUQ1qnFLBF+7JCBK18Dw0nHWoSx9y Z2vdM/QGZo7ApzFJnHK7D17WD1WrKqFvT6u5fRuy5rIZmJlq9acIZOTQ9npzA5PoXur/ ak6qCCGyEsqq5N4klBoV5+Bcn1DxUGDeth3es0d4aXCpmq/i0cCfMZCfOp5v5IfDllyY u1WeMnXx/ZB6wFas4D1xPbsLzipp+KNEk3R6Dq8MbOivBhXmQAR7rA2AIgeGPnKITjIj 180FR2J3rFTuHAR+N7ESkgAH48QxXZXpa1ugeFRLlWdbeHwX3YWUxWMss9kaeiaYI3fD tefQ== 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=DdRp15j/k4XeYmQe3luSEncUUhUk/h4Frh9ooM2yWbA=; b=pHzZH9XEhN9KN35XEbrBhuI5Xh4kzbW5UCVdkPSpqPfiNtPYqqK8etYNjj6q0tB9tw UL9lUoZ4lKpZuCt3dZXEpVKfSS9TltQV4NB2MBaOsM0g353+1La+nYoljSAcsakgrdVC PgxB01fAKiS0CdHeMyX+nX44wGXg6cZBmNNvFPE/BRggE/t5w5dprXNaVJVzV36hOHm7 HOdmpv1o1RiIbJoDQW0Fx5/X1tCY9Y5i63EOYlJyFIo4xaNj55ruv2LwxAIT/FKQTZdj 8m5+lTy6VXznQXsntUYoy/dty0e8OA6EZ9hgIYIC4CwcMUV+Wkp16Q1QmPZGe8MagDoH hFbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=GvPyYvV+; 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 m18-20020a67f292000000b0041203923455si5894439vsk.91.2023.03.09.07.02.05; Thu, 09 Mar 2023 07:02:24 -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=GvPyYvV+; 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 S232024AbjCIOoi (ORCPT + 99 others); Thu, 9 Mar 2023 09:44:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231940AbjCIOoU (ORCPT ); Thu, 9 Mar 2023 09:44:20 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4763CF05D6; Thu, 9 Mar 2023 06:43:59 -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 1CB95FF80F; Thu, 9 Mar 2023 14:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373038; 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=DdRp15j/k4XeYmQe3luSEncUUhUk/h4Frh9ooM2yWbA=; b=GvPyYvV+RzXgDfT9Ok4kHclraNH3fivV4H/83JhM5IkFib2D8XpQP7tq0BUEE2U6RbLGLY b13oOulz/W9mK3YUTUOCaAJ5hGm/YaN0zEdLyJP5+Pd1i4911ITHbxeR8gqV2QGxsnacLq 4+jNRFQQO0PhMo+wYmvliL0EVUMKkK8DBxQYI6FMREK3I6pOVjYaqxXGh3PYOSUHnOB4Rs bw3SZZkqCGbA1zAwZ9R2Cha4NXWNOTi17SPuzrqQacBsT3samqkek84U91cl4Zht69nYxN JkPWGnowFwT64h7oQuRXdRDvNiHDPscnpETIZQ78h2eprpU1qVO2iFREUEfRSw== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 11/21] staging: media: tegra-video: remove unneeded include Date: Thu, 9 Mar 2023 15:43:10 +0100 Message-Id: <20230309144320.2937553-12-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759902847397704228?= X-GMAIL-MSGID: =?utf-8?q?1759902847397704228?= There is only a pointer reference to struct tegra_vi in video.h, thus vi.h is not needed. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/video.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/media/tegra-video/video.h b/drivers/staging/media/tegra-video/video.h index fadaf2189dc9..1e9be1474a9c 100644 --- a/drivers/staging/media/tegra-video/video.h +++ b/drivers/staging/media/tegra-video/video.h @@ -12,7 +12,6 @@ #include #include "vi.h" -#include "csi.h" struct tegra_video_device { struct v4l2_device v4l2_dev; From patchwork Thu Mar 9 14:43:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp341390wrd; Thu, 9 Mar 2023 07:07:45 -0800 (PST) X-Google-Smtp-Source: AK7set8FAxrqCwz09q6OTcVTzK4aD9wPCTTac9BTQUCjnocTaMXXz0tsrIMA39z5KhAAqjTEFfqs X-Received: by 2002:a05:6e02:1d13:b0:317:d91d:93b with SMTP id i19-20020a056e021d1300b00317d91d093bmr19230102ila.13.1678374465103; Thu, 09 Mar 2023 07:07:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374465; cv=none; d=google.com; s=arc-20160816; b=X+ZBmAJdfmtl6SCieGSuYlK0IaZYEP2W9N4Gx2r0uc9K5kPR5WSdO/v+Ba2+M/vWol TzUrhBGEwtjLgmguCSwBQymc6uHF7VvRCnIVtzNARP4ROAljX5FSQhu1vksYz9Ws9sKg Gr+/zBBKUgxxQd3b+u2TmUC1FhvP2VtT4l+nACXYvdaSa1VSc5rz/6UFabofCf7zwGhk n3CfK0ULjWYP0QR2RJP1oSbzdy1k0vjU/l36MLvnhDvk5c507aM42887RvkB5aUgv3LG ddO7pSRC7sVeBye4ZNtHVnW7wWcPexnrDg5/k2xNrH6kxoX+Fuupn2itKALT4kwhgVnQ bcLg== 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=LS5vomXjVpVy5vUxgvr9Snjb35gKgVrb13Y7ThCyles=; b=hOQZJz408UwYZhxZwOIRjYr3w0GQkBJDX+yhPD/MzMIvi8FheIER3aLH9zSCyJb4GU imhtulOtPi8MOqQ9i75QVs1PugHTAF9w4sfwxxQvI6v0bTqLXs61G/vtnj7vlZaBJy0m Vu5uVCeoGb2t2UHJqXh3X8QJDtogkN88HX6pd+Il0viBAU7YYOQiuVbNMBrMiaYjyDMb BG6I3YxM/QbZLLUE+q0S1EYESX8y7bi69C1EzZMfvAI6IYbbWJzQuKwhVJvK8XUpxL3W /2NloOXEzEmzab1B7nRbEotrLPrbn7lsBN+SWJFkDO4N+wrFe/axsWbrcW1v6qTojKlD fjjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aTNXawSu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a0566380ece00b003c51893f1f3si16613577jas.64.2023.03.09.07.07.30; Thu, 09 Mar 2023 07:07:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aTNXawSu; 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 S231919AbjCIOpQ (ORCPT + 99 others); Thu, 9 Mar 2023 09:45:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231906AbjCIOo3 (ORCPT ); Thu, 9 Mar 2023 09:44:29 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 520187F033; Thu, 9 Mar 2023 06:44: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 F0C17FF810; Thu, 9 Mar 2023 14:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373042; 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=LS5vomXjVpVy5vUxgvr9Snjb35gKgVrb13Y7ThCyles=; b=aTNXawSudwJXUBEVv8IBeXw9QvwJkyslNX6e7Ii/uQ2juNLIb79AsGJrB27tb0nM9toA5A 976vUN8BeBkfa008O35gNoe2nVji1QZbhaolZ6+J0C4O+4gD+lXVIz8gPHT5FNn9xWvfwT 3ZdRJHN+0LkDRmBFOyWG7AQpkgB1NXvvoxOQRCUm91++dmvHgHQ7dO+plPJ11Yl0QV3yIh xllhBpgL8pUbhvyT7jSYBn5niBu9s1obli4nIphL32aRPheWEUEA0Eyl5hFIYvWo0YYkcR B6R34l2s4mGfw740Mx7KXa4hRIw28+nbTLx/l2Y2bdqm9rc0XxV3urWD7zXh1A== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 12/21] staging: media: tegra-video: Kconfig: allow TPG only on Tegra210 Date: Thu, 9 Mar 2023 15:43:11 +0100 Message-Id: <20230309144320.2937553-13-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903183523769860?= X-GMAIL-MSGID: =?utf-8?q?1759903183523769860?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/tegra-video/Kconfig b/drivers/staging/media/tegra-video/Kconfig index df1b2cff2417..c53441822fdf 100644 --- a/drivers/staging/media/tegra-video/Kconfig +++ b/drivers/staging/media/tegra-video/Kconfig @@ -15,5 +15,6 @@ config VIDEO_TEGRA config VIDEO_TEGRA_TPG bool "NVIDIA Tegra VI driver TPG mode" depends on VIDEO_TEGRA + depends on ARCH_TEGRA_210_SOC help Say yes here to enable Tegra internal TPG mode From patchwork Thu Mar 9 14:43:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66893 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp334652wrd; Thu, 9 Mar 2023 06:58:54 -0800 (PST) X-Google-Smtp-Source: AK7set+lYanWOTVBXrwpYS5ngwLzlF+GRhCuQE7YAFRZIEdSTitbLacq0PcycURLJVwXQduqJ2UA X-Received: by 2002:a17:90b:33c7:b0:237:7ed5:bbe2 with SMTP id lk7-20020a17090b33c700b002377ed5bbe2mr21638799pjb.3.1678373934325; Thu, 09 Mar 2023 06:58:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678373934; cv=none; d=google.com; s=arc-20160816; b=xwT3SJh4/8EyjSAZ3tBH8J2ppsWfU6dPMXIM2IGR/9KD4lQ9VgXiQKUkio0VXtaaRW yODbYGBmBkKh3Fh8paK5XUk0m5ftToTwDF3PqHEw00YTEbSIg6mPWnOaVau7INF5shqd 3s4gCfCU/8ibfPu0maXGRDIIKcMKDa5CctFf0TOY3mlW6DaUU9AEwfeV3BTwG1Svnqi1 uZvXa6YXhQi4/IJ68pvEYnt7yIWjH1dq4nFkjUGyqJ1qXQCgSpNznjL4JtnE1/1nYwA/ B+JwxtM1ehnafK1QKMj+UOcA4JPRXC0DOxeKL6atuuzvVXTtYtVc2Yh07a7n0xlj9HQo 88UQ== 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=qqcbbv4oJ6Pa0no5bwC/XjBbgUtwrXcWqjjFdMw9yUA=; b=Mg8KOFNAvIIy2AEfuxmhZLqUHz0pvqDP+yo5GvKooTBt03YZNG1n5z6Zg1JI9Wrt2w uTG1B6PQKYb7UpvnJMzE7e4ymCmJqXJlcG57luPubZaOjoVvt984n778l+HL0PyMK6rP uTxGkf9n5jA15KuJkJktu6ikcKsaO7vcJBGVx2TtiDX5DXpOswws4T6QLd5dqJx+qYkB JeT46Dx+IFR4fLVo+3kzhtbTqd4dAa/mtgFp9PVLyg41MDlbKnAj3CXTfuHx1YzFQml5 jpIQp2XT0ZrNiUtkKWOID+yqYtqJUim3lJ8wHt2Q9s09r4UkVSElFwEvIh3nq18MrCxi fONA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Zp8vIWAy; 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 x13-20020a17090ab00d00b002342ac76773si56749pjq.60.2023.03.09.06.58.35; Thu, 09 Mar 2023 06:58:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Zp8vIWAy; 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 S231875AbjCIOpN (ORCPT + 99 others); Thu, 9 Mar 2023 09:45:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232013AbjCIOog (ORCPT ); Thu, 9 Mar 2023 09:44:36 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85101EE757; Thu, 9 Mar 2023 06:44:06 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 57D33FF815; Thu, 9 Mar 2023 14:44:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373045; 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=qqcbbv4oJ6Pa0no5bwC/XjBbgUtwrXcWqjjFdMw9yUA=; b=Zp8vIWAyrfqW6JHl3Q0ZhmbySdBBK8lY1DXIX4FUEWoiomUodOlFMBslGHRrgQC+5f1Xq2 jUR/iUKGq93Y3TpDSkMTGqKgwUtKWQw3D7srVLCEiOIzUKOCtY1FW186BZK7jn/QiiUfrV +c+0lD4uud9mPd6WDuHNOqbYlqMqKBHtlOgGeP3IAwQbH6K+5APefwMTpfX85bjFg/5h+f tI7ADqcAe34ksq4yVGEvtn772GEoSGGJ7BGJtkES5VVdbh+flhP8feeQ1HTsrNw/jQHQRf AuyaKc7+hZ0HqQW7q3277k6KZcH45YVGSwSa6QDYJuDydQDMgRGCrpeLUAwczw== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 13/21] staging: media: tegra-video: move tegra_channel_fmt_align to a per-soc op Date: Thu, 9 Mar 2023 15:43:12 +0100 Message-Id: <20230309144320.2937553-14-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759902626573379607?= X-GMAIL-MSGID: =?utf-8?q?1759902626573379607?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/tegra210.c | 36 ++++++++++++++++++ drivers/staging/media/tegra-video/vi.c | 40 +++----------------- drivers/staging/media/tegra-video/vi.h | 9 ++--- 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra210.c b/drivers/staging/media/tegra-video/tegra210.c index eb19dd5107ce..71483d0c19bf 100644 --- a/drivers/staging/media/tegra-video/tegra210.c +++ b/drivers/staging/media/tegra-video/tegra210.c @@ -17,6 +17,13 @@ #include "csi.h" #include "vi.h" +#define TEGRA210_MIN_WIDTH 32U +#define TEGRA210_MAX_WIDTH 32768U +#define TEGRA210_MIN_HEIGHT 32U +#define TEGRA210_MAX_HEIGHT 32768U + +#define SURFACE_ALIGN_BYTES 64 + #define TEGRA_VI_SYNCPT_WAIT_TIMEOUT msecs_to_jiffies(200) /* Tegra210 VI registers */ @@ -172,6 +179,34 @@ static u32 vi_csi_read(struct tegra_vi_channel *chan, u8 portno, /* * Tegra210 VI channel capture operations */ +static void tegra210_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp) +{ + unsigned int min_bpl; + unsigned int max_bpl; + unsigned int bpl; + + /* + * The transfer alignment requirements are expressed in bytes. + * Clamp the requested width and height to the limits. + */ + pix->width = clamp(pix->width, TEGRA210_MIN_WIDTH, TEGRA210_MAX_WIDTH); + pix->height = clamp(pix->height, TEGRA210_MIN_HEIGHT, TEGRA210_MAX_HEIGHT); + + /* Clamp the requested bytes per line value. If the maximum bytes per + * line value is zero, the module doesn't support user configurable + * line sizes. Override the requested value with the minimum in that + * case. + */ + min_bpl = pix->width * bpp; + max_bpl = rounddown(TEGRA210_MAX_WIDTH, SURFACE_ALIGN_BYTES); + bpl = roundup(pix->bytesperline, SURFACE_ALIGN_BYTES); + + pix->bytesperline = clamp(bpl, min_bpl, max_bpl); + pix->sizeimage = pix->bytesperline * pix->height; + if (pix->pixelformat == V4L2_PIX_FMT_NV16) + pix->sizeimage *= 2; +} + static int tegra_channel_capture_setup(struct tegra_vi_channel *chan, u8 portno) { @@ -723,6 +758,7 @@ static const struct tegra_video_format tegra210_video_formats[] = { /* Tegra210 VI operations */ static const struct tegra_vi_ops tegra210_vi_ops = { + .vi_fmt_align = tegra210_fmt_align, .vi_start_streaming = tegra210_vi_start_streaming, .vi_stop_streaming = tegra210_vi_stop_streaming, }; diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 4e48eaa0fbdc..a76cad0e3026 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -456,36 +456,6 @@ static int tegra_channel_get_format(struct file *file, void *fh, return 0; } -static void tegra_channel_fmt_align(struct tegra_vi_channel *chan, - struct v4l2_pix_format *pix, - unsigned int bpp) -{ - unsigned int min_bpl; - unsigned int max_bpl; - unsigned int bpl; - - /* - * The transfer alignment requirements are expressed in bytes. - * Clamp the requested width and height to the limits. - */ - pix->width = clamp(pix->width, TEGRA_MIN_WIDTH, TEGRA_MAX_WIDTH); - pix->height = clamp(pix->height, TEGRA_MIN_HEIGHT, TEGRA_MAX_HEIGHT); - - /* Clamp the requested bytes per line value. If the maximum bytes per - * line value is zero, the module doesn't support user configurable - * line sizes. Override the requested value with the minimum in that - * case. - */ - min_bpl = pix->width * bpp; - max_bpl = rounddown(TEGRA_MAX_WIDTH, SURFACE_ALIGN_BYTES); - bpl = roundup(pix->bytesperline, SURFACE_ALIGN_BYTES); - - pix->bytesperline = clamp(bpl, min_bpl, max_bpl); - pix->sizeimage = pix->bytesperline * pix->height; - if (pix->pixelformat == V4L2_PIX_FMT_NV16) - pix->sizeimage *= 2; -} - static int __tegra_channel_try_format(struct tegra_vi_channel *chan, struct v4l2_pix_format *pix) { @@ -561,7 +531,7 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, return ret; v4l2_fill_pix_format(pix, &fmt.format); - tegra_channel_fmt_align(chan, pix, fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(pix, fmtinfo->bpp); __v4l2_subdev_state_free(sd_state); @@ -613,7 +583,7 @@ static int tegra_channel_set_format(struct file *file, void *fh, return ret; v4l2_fill_pix_format(pix, &fmt.format); - tegra_channel_fmt_align(chan, pix, fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(pix, fmtinfo->bpp); chan->format = *pix; chan->fmtinfo = fmtinfo; @@ -649,7 +619,7 @@ static int tegra_channel_set_subdev_active_fmt(struct tegra_vi_channel *chan) chan->format.bytesperline = chan->format.width * chan->fmtinfo->bpp; chan->format.sizeimage = chan->format.bytesperline * chan->format.height; - tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); tegra_channel_update_gangports(chan); return 0; @@ -818,7 +788,7 @@ static int tegra_channel_s_dv_timings(struct file *file, void *fh, chan->format.height = bt->height; chan->format.bytesperline = bt->width * chan->fmtinfo->bpp; chan->format.sizeimage = chan->format.bytesperline * bt->height; - tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + chan->vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); tegra_channel_update_gangports(chan); return 0; @@ -1149,7 +1119,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) chan->format.height = TEGRA_DEF_HEIGHT; chan->format.bytesperline = TEGRA_DEF_WIDTH * chan->fmtinfo->bpp; chan->format.sizeimage = chan->format.bytesperline * TEGRA_DEF_HEIGHT; - tegra_channel_fmt_align(chan, &chan->format, chan->fmtinfo->bpp); + vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); ret = tegra_channel_host1x_syncpt_init(chan); if (ret) diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index dfd834a69848..1021c730b595 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -25,17 +25,11 @@ #define V4L2_CID_TEGRA_SYNCPT_TIMEOUT_RETRY (V4L2_CTRL_CLASS_CAMERA | 0x1001) -#define TEGRA_MIN_WIDTH 32U -#define TEGRA_MAX_WIDTH 32768U -#define TEGRA_MIN_HEIGHT 32U -#define TEGRA_MAX_HEIGHT 32768U - #define TEGRA_DEF_WIDTH 1920 #define TEGRA_DEF_HEIGHT 1080 #define TEGRA_IMAGE_FORMAT_DEF 32 #define MAX_FORMAT_NUM 64 -#define SURFACE_ALIGN_BYTES 64 enum tegra_vi_pg_mode { TEGRA_VI_PG_DISABLED = 0, @@ -45,6 +39,8 @@ enum tegra_vi_pg_mode { /** * struct tegra_vi_ops - Tegra VI operations + * @vi_fmt_align: modify `pix` to fit the hardware alignment + * requirements and fill image geometry * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up * VI for capture and runs capture start and capture finish * kthreads for capturing frames to buffer and returns them back. @@ -52,6 +48,7 @@ enum tegra_vi_pg_mode { * back any queued buffers. */ struct tegra_vi_ops { + void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); }; From patchwork Thu Mar 9 14:43:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp338078wrd; Thu, 9 Mar 2023 07:03:26 -0800 (PST) X-Google-Smtp-Source: AK7set+b9IKAaPCzwCvGTlMekrACa1zOVosCoIg4XvtcnRRI4r096n6UAVO1unS8aqCfTdXkxJX7 X-Received: by 2002:a6b:5b08:0:b0:74c:822c:a6ac with SMTP id v8-20020a6b5b08000000b0074c822ca6acmr1264902ioh.15.1678374205427; Thu, 09 Mar 2023 07:03:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374205; cv=none; d=google.com; s=arc-20160816; b=MUJiHtdKaNxcFAY+vLAIlLR7jXEb2LWo0hf3IEEQGEzPpbesogKgqzG0vYAXGgKmZN f9cy+OVKpH+iDJBb/x+uG/wCLY1ZkXJRwBPUE9kmpnX74+blRWQiM6blRFy5yMatLcZR QJPljBj9lgkCAVdT4zzXO5mlqADN0y325HNPeeBv92tpNoWwaoab5+h4wNuKyzH8iZNg /rorLiPs2z/evzqakuG2IA5KDuE3obhqOkLjyuoGdDsIttAjAjmZQ3N+dm7n86R8DNm6 N40S9HXwX456mz9cPJ3SaVqkMiOla9Cc5YpHnLXKO5+GBDEAUxga4f/ACy4FJ/X0WsR0 9J4Q== 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=8x6ANxKmlQRR8yGJcgQ569q5zpdBXVx3vBAjyJdMrk4=; b=zA30Amj9AOWJqmRLL+0LHORVmG1GIAOWu7Hf4Ur6dxv94l9XzqajpaMjjSA9VqnqQd PcGIlGlV21GmEswjJN9cxaJBZfw1giV5zgTNhoo002MZOpQVaQ/ocw0kQOEXB4IuplrV A9JuCFUt9qZ5nFETpqUBZCcXbsH39Erdjkao+JS8MiEcZIiCkwQkvFWYA0oLunfIfr/w rwOcxUDU9vjl5Bo84omVTxl0qtSPTrYP1eDnPzEw1fUcYYGK3Mz/G2dD3x00elax4EcT mfmeuxGzod35rzd7gqJqWlYN3r5SVKbGTvypevAJYWZO31aQQOpYHvUj13PvJ9Fn2u4K HgIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SJz82fix; 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 l2-20020a6b7b02000000b0074e6f682f2esi6451932iop.103.2023.03.09.07.03.07; Thu, 09 Mar 2023 07:03:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SJz82fix; 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 S231962AbjCIOpb (ORCPT + 99 others); Thu, 9 Mar 2023 09:45:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232053AbjCIOoy (ORCPT ); Thu, 9 Mar 2023 09:44:54 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4765AF8A48; Thu, 9 Mar 2023 06:44: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 46671FF805; Thu, 9 Mar 2023 14:44:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373049; 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=8x6ANxKmlQRR8yGJcgQ569q5zpdBXVx3vBAjyJdMrk4=; b=SJz82fixkCCvzLZ1RiSQ9HMpHbJ82m2tdSyrffWE2WCG9pRxRbGMYm+njdDsq+cbGjSCap jJxPBUTqBt3Yupaveb0EAk1VOrJma6Heb2aVUoTSZAWFUSUfSn/P9TuJbdGNvM2zGI96EL P6AnwkivZI0FEYaWDXv56kuhcGNW6Q+BYoTj9i+mM2Zdb6K/AlNw+vBQ2CHQx8U90ek7Px BaEE4ad6w/cZLGH2TR/MRLJKeuGEsONr4vuqtlax7yB2neZLiRP3gZrKbvxLcaK5g2kmGa q0eDasU7+8PV4eh2CuTLg65DymWb8llMdsjKlKs9wV8GbVIRDv0ycKoiVSwRpg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 14/21] staging: media: tegra-video: move default format to soc-specific data Date: Thu, 9 Mar 2023 15:43:13 +0100 Message-Id: <20230309144320.2937553-15-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759902910600172730?= X-GMAIL-MSGID: =?utf-8?q?1759902910600172730?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/tegra210.c | 2 ++ drivers/staging/media/tegra-video/vi.c | 11 +---------- drivers/staging/media/tegra-video/vi.h | 2 ++ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra210.c b/drivers/staging/media/tegra-video/tegra210.c index 71483d0c19bf..28d3d05c12c4 100644 --- a/drivers/staging/media/tegra-video/tegra210.c +++ b/drivers/staging/media/tegra-video/tegra210.c @@ -771,8 +771,10 @@ const struct tegra_vi_soc tegra210_vi_soc = { .hw_revision = 3, .vi_max_channels = 6, #if IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG) + .default_video_format = &tegra210_video_formats[0], .vi_max_clk_hz = 499200000, #else + .default_video_format = &tegra210_video_formats[4], .vi_max_clk_hz = 998400000, #endif }; diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index a76cad0e3026..3762fd273514 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -44,15 +44,6 @@ struct tegra_vi_graph_entity { struct v4l2_subdev *subdev; }; -static const struct tegra_video_format tegra_default_format = { - .img_dt = TEGRA_IMAGE_DT_RAW10, - .bit_width = 10, - .code = MEDIA_BUS_FMT_SRGGB10_1X10, - .bpp = 2, - .img_fmt = TEGRA_IMAGE_FORMAT_DEF, - .fourcc = V4L2_PIX_FMT_SRGGB10, -}; - static inline struct tegra_vi * host1x_client_to_vi(struct host1x_client *client) { @@ -1111,7 +1102,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) init_waitqueue_head(&chan->done_wait); /* initialize the video format */ - chan->fmtinfo = &tegra_default_format; + chan->fmtinfo = chan->vi->soc->default_video_format; chan->format.pixelformat = chan->fmtinfo->fourcc; chan->format.colorspace = V4L2_COLORSPACE_SRGB; chan->format.field = V4L2_FIELD_NONE; diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 1021c730b595..879547073371 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -58,6 +58,7 @@ struct tegra_vi_ops { * * @video_formats: supported video formats * @nformats: total video formats + * @default_video_format: default video format (pointer to a @video_formats item) * @ops: vi operations * @hw_revision: VI hw_revision * @vi_max_channels: supported max streaming channels @@ -66,6 +67,7 @@ struct tegra_vi_ops { struct tegra_vi_soc { const struct tegra_video_format *video_formats; const unsigned int nformats; + const struct tegra_video_format *default_video_format; const struct tegra_vi_ops *ops; u32 hw_revision; unsigned int vi_max_channels; From patchwork Thu Mar 9 14:43:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp341176wrd; Thu, 9 Mar 2023 07:07:28 -0800 (PST) X-Google-Smtp-Source: AK7set/ptabfVInEl0VPVtClCmZb4tk5EiWRiZB8DXP0miCbn4QPkAkEVOysTLGFc4Q+gLE8p+38 X-Received: by 2002:a5d:8795:0:b0:74c:e1a4:a285 with SMTP id f21-20020a5d8795000000b0074ce1a4a285mr1024797ion.2.1678374447931; Thu, 09 Mar 2023 07:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374447; cv=none; d=google.com; s=arc-20160816; b=T+cj0Fw/nn/Qtqbwbqb2CDwiXCA1ZDBPkVqOxvieqEgb7De1HNYeHWwpNqjy2TD58W W06SAEU/rn08uK+z2ZYDYU2SKzO6rS/LihF0/NceeLzWfS6Zwd+sbnWghZ6lLkw7huZI 9jnObdKJ2Etawc6KdsygLF8+Z1TUf341iVNaBkSIp20Jn4dKZkKlo6+1dZSsli6gQ8ml Xa5JvbYM6Om0vQb6KH7PwJ7DXTHtUuqSJeD80mFEwgSwmeYXTIv2SZfYGfK+zTxJYZh6 gDlCIoG8xKjz8lPrOXXryMvJcm13iDQGGAUJpivrDPwsKPZattpRqs8RN65SrUe4+KRL T8Sw== 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=MDyvqcJLnh/rRPLNU2ZPgLh5AYWNHTEkdgruIRNFhf4=; b=VYDH2puu4uuQrPPPD1LSc5CF945HiskLlaIuwtLvVNo2xCJ3daTptNntAl+TVShWUC DI4rknA8l7Ktw2txrS3+ck+YV5vgn+KxAGFzBCuLpO3vz8D7d6V9E0mwM+sdbu97qLov vI1/PKryFZvs+pSlpOsjP+asvtVZv70DfeseFL7SyTTAhrml7gEwdaFuz6TY6UyPO5nh gDhXPqf1wrZIqnNxkmiVLpnYdN5lRRWeDwxbHXKpx4Q9PNfW/GQFh1WtoVIwhZVipedk BgC6vc+8agOerpAUR8pBIKrIxT4L1IOVK63YxS2in/cuFImnit1Zrci8Th4iEiGvccP3 xtNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="fNk/tmXj"; 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 r5-20020a5edb45000000b0074e6f682f24si6523857iop.89.2023.03.09.07.07.11; Thu, 09 Mar 2023 07:07:27 -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="fNk/tmXj"; 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 S231977AbjCIOqe (ORCPT + 99 others); Thu, 9 Mar 2023 09:46:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231975AbjCIOpu (ORCPT ); Thu, 9 Mar 2023 09:45:50 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BD44F0FE8; Thu, 9 Mar 2023 06:44:31 -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 CA553FF80B; Thu, 9 Mar 2023 14:44:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373053; 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=MDyvqcJLnh/rRPLNU2ZPgLh5AYWNHTEkdgruIRNFhf4=; b=fNk/tmXjOlIeSHjmlFwyBeDBN3ybWAYZD+jgEBolcdMCPxHc9l1LIMIv0U1aED8LUSX05O Z2bDVpWP1tlfHgmZoQFsjmy6/sUcqxb+njp+WM12ucj/dQhYq5g5XrQOgt1HXl9XUFwyXe 6Ih5vFsV0bKKeivrwjmgaWQ1qyNy4UAYKcZOABIZ2+6L1QgW3AXcJ3k9NrmhFsqVa2dlL6 spd+eyU92ye0wPeiAYDaM5YJo+7WgH0jYXXM2ohg4x+pkXZfBtCwjLaJ0gA2HZH9qPRp3a c06AEU9c48b/Yu9e2ZjflvFVh8D1i+q6ms+i3Mge+pomcCTeoXLEqw5Fm98cIg== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 15/21] staging: media: tegra-video: move MIPI calibration calls from VI to CSI Date: Thu, 9 Mar 2023 15:43:14 +0100 Message-Id: <20230309144320.2937553-16-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903164876258379?= X-GMAIL-MSGID: =?utf-8?q?1759903164876258379?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/csi.c | 44 ++++++++++++++++++++ drivers/staging/media/tegra-video/vi.c | 54 ++----------------------- 2 files changed, 48 insertions(+), 50 deletions(-) diff --git a/drivers/staging/media/tegra-video/csi.c b/drivers/staging/media/tegra-video/csi.c index 9a03d5ccdf3c..b93fc879ef3a 100644 --- a/drivers/staging/media/tegra-video/csi.c +++ b/drivers/staging/media/tegra-video/csi.c @@ -328,12 +328,42 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev) } csi_chan->pg_mode = chan->pg_mode; + + /* + * Tegra CSI receiver can detect the first LP to HS transition. + * So, start the CSI stream-on prior to sensor stream-on and + * vice-versa for stream-off. + */ ret = csi->ops->csi_start_streaming(csi_chan); if (ret < 0) goto finish_calibration; + if (csi_chan->mipi) { + struct v4l2_subdev *src_subdev; + /* + * TRM has incorrectly documented to wait for done status from + * calibration logic after CSI interface power on. + * As per the design, calibration results are latched and applied + * to the pads only when the link is in LP11 state which will happen + * during the sensor stream-on. + * CSI subdev stream-on triggers start of MIPI pads calibration. + * Wait for calibration to finish here after sensor subdev stream-on. + */ + src_subdev = tegra_channel_get_remote_source_subdev(chan); + ret = v4l2_subdev_call(src_subdev, video, s_stream, true); + err = tegra_mipi_finish_calibration(csi_chan->mipi); + + if (ret < 0 && ret != -ENOIOCTLCMD) + goto disable_csi_stream; + + if (err < 0) + dev_warn(csi->dev, "MIPI calibration failed: %d\n", err); + } + return 0; +disable_csi_stream: + csi->ops->csi_stop_streaming(csi_chan); finish_calibration: if (csi_chan->mipi) tegra_mipi_finish_calibration(csi_chan->mipi); @@ -352,10 +382,24 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev) static int tegra_csi_disable_stream(struct v4l2_subdev *subdev) { + struct tegra_vi_channel *chan = v4l2_get_subdev_hostdata(subdev); struct tegra_csi_channel *csi_chan = to_csi_chan(subdev); struct tegra_csi *csi = csi_chan->csi; int err; + /* + * Stream-off subdevices in reverse order to stream-on. + * Remote source subdev in TPG mode is same as CSI subdev. + */ + if (csi_chan->mipi) { + struct v4l2_subdev *src_subdev; + + src_subdev = tegra_channel_get_remote_source_subdev(chan); + err = v4l2_subdev_call(src_subdev, video, s_stream, false); + if (err < 0 && err != -ENOIOCTLCMD) + dev_err_probe(csi->dev, err, "source subdev stream off failed\n"); + } + csi->ops->csi_stop_streaming(csi_chan); if (csi_chan->mipi) { diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 3762fd273514..a26eb1ca869f 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -187,49 +187,15 @@ tegra_channel_get_remote_source_subdev(struct tegra_vi_channel *chan) static int tegra_channel_enable_stream(struct tegra_vi_channel *chan) { - struct v4l2_subdev *csi_subdev, *src_subdev; - struct tegra_csi_channel *csi_chan; - int ret, err; + struct v4l2_subdev *subdev; + int ret; - /* - * Tegra CSI receiver can detect the first LP to HS transition. - * So, start the CSI stream-on prior to sensor stream-on and - * vice-versa for stream-off. - */ - csi_subdev = tegra_channel_get_remote_csi_subdev(chan); - ret = v4l2_subdev_call(csi_subdev, video, s_stream, true); + subdev = tegra_channel_get_remote_csi_subdev(chan); + ret = v4l2_subdev_call(subdev, video, s_stream, true); if (ret < 0 && ret != -ENOIOCTLCMD) return ret; - if (IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) - return 0; - - csi_chan = v4l2_get_subdevdata(csi_subdev); - /* - * TRM has incorrectly documented to wait for done status from - * calibration logic after CSI interface power on. - * As per the design, calibration results are latched and applied - * to the pads only when the link is in LP11 state which will happen - * during the sensor stream-on. - * CSI subdev stream-on triggers start of MIPI pads calibration. - * Wait for calibration to finish here after sensor subdev stream-on. - */ - src_subdev = tegra_channel_get_remote_source_subdev(chan); - ret = v4l2_subdev_call(src_subdev, video, s_stream, true); - err = tegra_mipi_finish_calibration(csi_chan->mipi); - - if (ret < 0 && ret != -ENOIOCTLCMD) - goto err_disable_csi_stream; - - if (err < 0) - dev_warn(csi_chan->csi->dev, - "MIPI calibration failed: %d\n", err); - return 0; - -err_disable_csi_stream: - v4l2_subdev_call(csi_subdev, video, s_stream, false); - return ret; } static int tegra_channel_disable_stream(struct tegra_vi_channel *chan) @@ -237,18 +203,6 @@ static int tegra_channel_disable_stream(struct tegra_vi_channel *chan) struct v4l2_subdev *subdev; int ret; - /* - * Stream-off subdevices in reverse order to stream-on. - * Remote source subdev in TPG mode is same as CSI subdev. - */ - subdev = tegra_channel_get_remote_source_subdev(chan); - ret = v4l2_subdev_call(subdev, video, s_stream, false); - if (ret < 0 && ret != -ENOIOCTLCMD) - return ret; - - if (IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG)) - return 0; - subdev = tegra_channel_get_remote_csi_subdev(chan); ret = v4l2_subdev_call(subdev, video, s_stream, false); if (ret < 0 && ret != -ENOIOCTLCMD) From patchwork Thu Mar 9 14:43:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp342075wrd; Thu, 9 Mar 2023 07:08:41 -0800 (PST) X-Google-Smtp-Source: AK7set/WwI2fmw7oENXf87ej+EZu5zFq03QH5yDj1hgdauFN9sGj9qhk0Dxosqw2Wwg2/Gzom7l5 X-Received: by 2002:a05:6e02:1542:b0:313:d7fc:4c09 with SMTP id j2-20020a056e02154200b00313d7fc4c09mr871306ilu.18.1678374521511; Thu, 09 Mar 2023 07:08:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374521; cv=none; d=google.com; s=arc-20160816; b=0QNs1lJgvdWeVj5SMM92Hz6J4o02gbsML2Xfr5AgSkelGYTD4CnxZKAguItC3X5c3M qU0luUQU87XLd7Ouy6WHWjN/4wnIFfi7UDTVQAdp8E58aREzW1oHmpmBHqo8SVOdtWF9 oKwPXXcu+2TTJYIlpuEuvDnVrSWoTexxrfL76W+g3MJPA8jwio2+/cb05i5xxbBy8OOs xC2+v5BWuhG/fFuIbAyY5NCJ0tQsD0OLhF0GZ5S5ABBQ4X/D6038te620aal0CE2qju9 8YWesYuipA3V1MlPnS9Vgn8Mf2kE8dH3xb+RFmprMi2ZTVz66hm/+9j3sMwE4ZXfQeOc Y4Iw== 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=+JiyEr0aLb/Un5/rTb5g/3dOFycMN8fKhuwYurKD+kM=; b=BoZfoleY2e6+ddmOIZbnR9ahEhzrCumPM22vfthOnlLzV8feYBm/IF5d0KD+HHZ2d6 LyAG4JIHFUO9Fh/WDmx0E87IxEZDd8qg66R7fVTIgNy/ooy0B21zb66MutfTUpdftuei dQID9uWiV+sri4TNanZ2fbOkUUIiPYXq4sYJE74oKuc8Q94GdH98YWDTLVCthbxEJA+W 57j8057h0oLsFYLzr3hLGlAs5wK0NloW62/BJjpMRZusTPq5lobmK88HoUjcJSIFg/+J fbeCUH59BFn8/Xb5vJYCzQR7G1+tF0qGsXazNPp51WQMwblFEPUssy4JUxWtN1CryI6a Y6/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Y3sA0Twi; 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 u18-20020a02cb92000000b003c4f9014aecsi19738365jap.35.2023.03.09.07.08.27; Thu, 09 Mar 2023 07:08: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=Y3sA0Twi; 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 S232049AbjCIOqv (ORCPT + 99 others); Thu, 9 Mar 2023 09:46:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232035AbjCIOp4 (ORCPT ); Thu, 9 Mar 2023 09:45:56 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B30A2E8A97; Thu, 9 Mar 2023 06:44:37 -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 DA0B8FF814; Thu, 9 Mar 2023 14:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373057; 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=+JiyEr0aLb/Un5/rTb5g/3dOFycMN8fKhuwYurKD+kM=; b=Y3sA0TwiLqtyVBFKoONsoDkzlfvNjvP8Uh2nFHMH3N/p0h3MW2VqXthUm6SV9JkeawsupT buvD5REVKwR+ZWhhLxq5gMZQOX+AWT/k8adb2SNXmoNYkc+fFl1XGDpJSexLsG4PzGsxPn E+/A6xuzXlFkok/cJOBzfRT/hTuEGxF0FmAiI6VvLtsondX4bKvQfZpJgjZ2FNixKvmxLl kzus6ZKcfIu8CsdLTaLp0RObViDP5glYp4lVEX61Ak1u+s+a4gJZ3WttJ5UBLk80P/Td8G vkYGDe0dhLsq+ftbNNwmrhmaX0bdvLatjsTOiupKweysgfeukFQnPSVTa8tEbA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 16/21] staging: media: tegra-video: add a per-soc enable/disable op Date: Thu, 9 Mar 2023 15:43:15 +0100 Message-Id: <20230309144320.2937553-17-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903242551589084?= X-GMAIL-MSGID: =?utf-8?q?1759903242551589084?= The Tegra20 VI needs an additional operation to enable the VI, add an operation for that. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 7 +++++++ drivers/staging/media/tegra-video/vi.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index a26eb1ca869f..22f6d6478d3e 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1853,6 +1853,9 @@ static int tegra_vi_probe(struct platform_device *pdev) vi->client.ops = &vi_client_ops; vi->client.dev = &pdev->dev; + if (vi->ops->vi_enable) + vi->ops->vi_enable(vi, true); + ret = host1x_client_register(&vi->client); if (ret < 0) { dev_err(&pdev->dev, @@ -1863,6 +1866,8 @@ static int tegra_vi_probe(struct platform_device *pdev) return 0; rpm_disable: + if (vi->ops->vi_enable) + vi->ops->vi_enable(vi, false); pm_runtime_disable(&pdev->dev); return ret; } @@ -1879,6 +1884,8 @@ static int tegra_vi_remove(struct platform_device *pdev) return err; } + if (vi->ops->vi_enable) + vi->ops->vi_enable(vi, false); pm_runtime_disable(&pdev->dev); return 0; diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 879547073371..851c4f3fcb91 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -37,8 +37,11 @@ enum tegra_vi_pg_mode { TEGRA_VI_PG_PATCH, }; +struct tegra_vi; + /** * struct tegra_vi_ops - Tegra VI operations + * @vi_enable: soc-specific operations needed to enable/disable the VI peripheral * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up @@ -48,6 +51,7 @@ enum tegra_vi_pg_mode { * back any queued buffers. */ struct tegra_vi_ops { + int (*vi_enable)(struct tegra_vi *vi, bool on); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); From patchwork Thu Mar 9 14:43:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp338988wrd; Thu, 9 Mar 2023 07:04:31 -0800 (PST) X-Google-Smtp-Source: AK7set87l9LZaA5dwcCldGNJ7/bI7rMSvY08zwHYpbfUOz0xHH7ClWj/z14x5xNThxYbiQwTwcaF X-Received: by 2002:a05:6e02:1a82:b0:315:365d:5358 with SMTP id k2-20020a056e021a8200b00315365d5358mr16958587ilv.10.1678374271161; Thu, 09 Mar 2023 07:04:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374271; cv=none; d=google.com; s=arc-20160816; b=z0b9S76D0OvE1b7jsQMzBdlc22ksB/tHjTQ92AgN00I8da+6Vd8kV8iNYcBfBZdGNJ 4FNTMrMPaP7nPqDwgq4+F1e/0u+LS/XZHulkhVpLSshBb3+jFI1fapYdnbWsTBjo9hXo LwR0PxdN2mSoGkmOJrE751rbn/zLbRKGo3XCE+1Za3gq9jMAL6gB/0z5+2HM5k1xusJ0 O93HWTUWz4Wp0q9xb1dlfKtrtEiz3GpGbEWaGEcoyrz3U5mMS3DQhLn3gO6hCaIfDBEP 7HGij717EmTkOesW3GU7rP8CqSZaobbvZfqyr+KYCZlj16Coy1lEMk1EkFZE2HZ/oCvw oqIA== 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=eAvKkQlWuYYr6YxU/goHqRoXYfDwpGVohln81j6K6R8=; b=IBOPQ3LAXLcZry8P4T/kIBniGm6vh/SMFfPNjceD+BRwz7AAg4YnOtAME4vPXbZmtG m/1qk22NI9ul+CTOkzLCZlqrDggBYCCIE76Xixg4m20WdPJSbAoxCHdgqggU2u5cEqaL 1Rd0ev+GDRB98IJeUapOJKqSRUuXgb7Cc2ILF1z3zjU+IZzxbUfIXKb/4Na/wZ2PiaWZ n6PGXxct6Xt52v63s4BRlOpZr4EENNouzxqV10c1WyvhRChBgZXPAIMRkuMSUA2M7vjC AnQBS091VpOfWHbcFAFmgGLFp2bsmUSWPAcXCjxRrU9IaCKYKbBYywrpYZMz3soxp8BN Ch0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="eT/4q1Q7"; 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 k9-20020a02c769000000b003bb24b3460dsi19337863jao.38.2023.03.09.07.04.15; Thu, 09 Mar 2023 07:04:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="eT/4q1Q7"; 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 S232057AbjCIOp7 (ORCPT + 99 others); Thu, 9 Mar 2023 09:45:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232133AbjCIOpE (ORCPT ); Thu, 9 Mar 2023 09:45:04 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFACE7CA5; Thu, 9 Mar 2023 06:44:21 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 6A242FF809; Thu, 9 Mar 2023 14:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373060; 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=eAvKkQlWuYYr6YxU/goHqRoXYfDwpGVohln81j6K6R8=; b=eT/4q1Q7Jo5RTgzWZvhGuXRq7XTUBl+XmFekQqZFh4ZEW2kIMJOq7Nj5oyDKOF0mpT2cIu 0bz/pW32PfKXVdtIFcCNep/5TUGcFvSs23NgB3pK1paLY0jVSUO9ax84B9yxAYYZf+2+M7 IAU1qXAN8Zcd/ggaupqiiUFrK8gOklVlZ0zNwOG8gP/jk1Ddf9TZaYl/n7OsuTwNLvmuIp oeao6oTcUFlTRLWbGqLQmCCmspSJJ33+zMTQbHzE21LQ9rGy2shoCvJGH7NNw0VOGTrLRr /8P6eRQ5j+T5zxJAyAMefytWdarbqCEcRnspdXfZXxAX3rMeucJ0DM/TdsVLRQ== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 17/21] staging: media: tegra-video: move syncpt init/free to a per-soc op Date: Thu, 9 Mar 2023 15:43:16 +0100 Message-Id: <20230309144320.2937553-18-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759902979994001711?= X-GMAIL-MSGID: =?utf-8?q?1759902979994001711?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/tegra210.c | 52 ++++++++++++++++++++ drivers/staging/media/tegra-video/vi.c | 52 ++------------------ drivers/staging/media/tegra-video/vi.h | 5 ++ 3 files changed, 60 insertions(+), 49 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra210.c b/drivers/staging/media/tegra-video/tegra210.c index 28d3d05c12c4..d47ba79bac75 100644 --- a/drivers/staging/media/tegra-video/tegra210.c +++ b/drivers/staging/media/tegra-video/tegra210.c @@ -179,6 +179,56 @@ static u32 vi_csi_read(struct tegra_vi_channel *chan, u8 portno, /* * Tegra210 VI channel capture operations */ + +static int tegra210_channel_host1x_syncpt_init(struct tegra_vi_channel *chan) +{ + struct tegra_vi *vi = chan->vi; + unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED; + struct host1x_syncpt *fs_sp; + struct host1x_syncpt *mw_sp; + int ret, i; + + for (i = 0; i < chan->numgangports; i++) { + fs_sp = host1x_syncpt_request(&vi->client, flags); + if (!fs_sp) { + dev_err(vi->dev, "failed to request frame start syncpoint\n"); + ret = -ENOMEM; + goto free_syncpts; + } + + mw_sp = host1x_syncpt_request(&vi->client, flags); + if (!mw_sp) { + dev_err(vi->dev, "failed to request memory ack syncpoint\n"); + host1x_syncpt_put(fs_sp); + ret = -ENOMEM; + goto free_syncpts; + } + + chan->frame_start_sp[i] = fs_sp; + chan->mw_ack_sp[i] = mw_sp; + spin_lock_init(&chan->sp_incr_lock[i]); + } + + return 0; + +free_syncpts: + for (i = 0; i < chan->numgangports; i++) { + host1x_syncpt_put(chan->mw_ack_sp[i]); + host1x_syncpt_put(chan->frame_start_sp[i]); + } + return ret; +} + +static void tegra210_channel_host1x_syncpt_free(struct tegra_vi_channel *chan) +{ + int i; + + for (i = 0; i < chan->numgangports; i++) { + host1x_syncpt_put(chan->mw_ack_sp[i]); + host1x_syncpt_put(chan->frame_start_sp[i]); + } +} + static void tegra210_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp) { unsigned int min_bpl; @@ -758,6 +808,8 @@ static const struct tegra_video_format tegra210_video_formats[] = { /* Tegra210 VI operations */ static const struct tegra_vi_ops tegra210_vi_ops = { + .channel_host1x_syncpt_init = tegra210_channel_host1x_syncpt_init, + .channel_host1x_syncpt_free = tegra210_channel_host1x_syncpt_free, .vi_fmt_align = tegra210_fmt_align, .vi_start_streaming = tegra210_vi_start_streaming, .vi_stop_streaming = tegra210_vi_stop_streaming, diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 22f6d6478d3e..760606c65a97 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -973,21 +973,11 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) return 0; } -static void tegra_channel_host1x_syncpts_free(struct tegra_vi_channel *chan) -{ - int i; - - for (i = 0; i < chan->numgangports; i++) { - host1x_syncpt_put(chan->mw_ack_sp[i]); - host1x_syncpt_put(chan->frame_start_sp[i]); - } -} - static void tegra_channel_cleanup(struct tegra_vi_channel *chan) { v4l2_ctrl_handler_free(&chan->ctrl_handler); media_entity_cleanup(&chan->video.entity); - tegra_channel_host1x_syncpts_free(chan); + chan->vi->ops->channel_host1x_syncpt_free(chan); mutex_destroy(&chan->video_lock); } @@ -1005,42 +995,6 @@ void tegra_channels_cleanup(struct tegra_vi *vi) } } -static int tegra_channel_host1x_syncpt_init(struct tegra_vi_channel *chan) -{ - struct tegra_vi *vi = chan->vi; - unsigned long flags = HOST1X_SYNCPT_CLIENT_MANAGED; - struct host1x_syncpt *fs_sp; - struct host1x_syncpt *mw_sp; - int ret, i; - - for (i = 0; i < chan->numgangports; i++) { - fs_sp = host1x_syncpt_request(&vi->client, flags); - if (!fs_sp) { - dev_err(vi->dev, "failed to request frame start syncpoint\n"); - ret = -ENOMEM; - goto free_syncpts; - } - - mw_sp = host1x_syncpt_request(&vi->client, flags); - if (!mw_sp) { - dev_err(vi->dev, "failed to request memory ack syncpoint\n"); - host1x_syncpt_put(fs_sp); - ret = -ENOMEM; - goto free_syncpts; - } - - chan->frame_start_sp[i] = fs_sp; - chan->mw_ack_sp[i] = mw_sp; - spin_lock_init(&chan->sp_incr_lock[i]); - } - - return 0; - -free_syncpts: - tegra_channel_host1x_syncpts_free(chan); - return ret; -} - static int tegra_channel_init(struct tegra_vi_channel *chan) { struct tegra_vi *vi = chan->vi; @@ -1066,7 +1020,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) chan->format.sizeimage = chan->format.bytesperline * TEGRA_DEF_HEIGHT; vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp); - ret = tegra_channel_host1x_syncpt_init(chan); + ret = vi->ops->channel_host1x_syncpt_init(chan); if (ret) return ret; @@ -1129,7 +1083,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan) cleanup_media: media_entity_cleanup(&chan->video.entity); free_syncpts: - tegra_channel_host1x_syncpts_free(chan); + vi->ops->channel_host1x_syncpt_free(chan); return ret; } diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 851c4f3fcb91..8fadca33bcc9 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -38,10 +38,13 @@ enum tegra_vi_pg_mode { }; struct tegra_vi; +struct tegra_vi_channel; /** * struct tegra_vi_ops - Tegra VI operations * @vi_enable: soc-specific operations needed to enable/disable the VI peripheral + * @channel_host1x_syncpt_init: initialize synchronization points + * @channel_host1x_syncpt_free: free all synchronization points * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up @@ -52,6 +55,8 @@ struct tegra_vi; */ struct tegra_vi_ops { int (*vi_enable)(struct tegra_vi *vi, bool on); + int (*channel_host1x_syncpt_init)(struct tegra_vi_channel *chan); + void (*channel_host1x_syncpt_free)(struct tegra_vi_channel *chan); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); From patchwork Thu Mar 9 14:43:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp341512wrd; Thu, 9 Mar 2023 07:07:55 -0800 (PST) X-Google-Smtp-Source: AK7set/i6gpIB+i84D4LIdWBg6YHeOmGM+OEz1qps13rgB32agypTQIaYHcKLswicMgZQ2gB3exb X-Received: by 2002:a05:6e02:1c4d:b0:313:c32b:de26 with SMTP id d13-20020a056e021c4d00b00313c32bde26mr22616301ilg.9.1678374474759; Thu, 09 Mar 2023 07:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374474; cv=none; d=google.com; s=arc-20160816; b=tCtkWLZUUqtTQAOdtahecZGckjdNJ6wweW0AXBuDgfHQvH2NjYrYq2k3+A5YOvy/7c TDPV//JKvwhVfoF3vyhxUkYqHLhkgfMdo1smMautWL43TTsUA9mRK08uGdeP8m/4f7O/ ML0DHX9XmPl74UaYSqpm2cKjigWsNNyToQWviPJobzFvBi25kIOIbG0i+U+ZJpVUWnTV 8ctz7zu9xUiVezUvKPZKezNdULNt4iH8bYQHu12AOHzIsKMSCpZ9VnWWTvN98N6EgJxM c1M6PiZnn/g/eQgSsr8F9KPDUE1UQ4+wDsj5TThazx0du/0TOtrhf7QvrDKdnrN4mWHS 9Xeg== 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=W/OR7OgnmlOPfrWXLXRWbh6OKG8j6mLzoFN0/Tk8wec=; b=Xs76xyDjf1omhe57aRmB5k8PeDi5+pRVRtxJFrvdde49mzGAPRJ69CAX+ikmqcXpnG 1/kufvznf9peTdsHiD4Be+prrMWqtM1C3UlbB+74SvcBHniml3d9vvPXWt8AjUjIrPFH toUkfHRpfI7ndVpQVt5eudTnwVurk6q2P/XthQqypFW51uWLUQUHIC5AW8s38tI7xUy2 1RMwiiwHauwW1fTsuXlpqA0VVaHfreFH7wKY4/DLtNMT3psLF5pR5QMmhI6uLvVOJY/X A7cE7WK/ISou6Zky+nWLhW/5b2cuPyBdKBVrwDBN0+G/Z9cmf0Uc9x7QfJp8yLqSgejo 8uXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=CbKpbUvH; 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 g19-20020a02c553000000b003ad612459c1si19655444jaj.47.2023.03.09.07.07.37; Thu, 09 Mar 2023 07:07:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=CbKpbUvH; 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 S232107AbjCIOqO (ORCPT + 99 others); Thu, 9 Mar 2023 09:46:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbjCIOpK (ORCPT ); Thu, 9 Mar 2023 09:45:10 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFF2BF0FC6; Thu, 9 Mar 2023 06:44: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 4B1ADFF811; Thu, 9 Mar 2023 14:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373063; 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=W/OR7OgnmlOPfrWXLXRWbh6OKG8j6mLzoFN0/Tk8wec=; b=CbKpbUvHPKZKeLHRnz7WYILQ81JnStNHpLdpk3lWRK7nHH6k6JtfP7YndpftVUetHpL/rW EMwmLqY8PFFhIZyp1+kNqqrGcpdTrRg5LvefLp1YvNX0rlEEaAkOCVpW0g+e+IIm3YUXmo bS0/jBP7PiZdJBGkrnvWQ0kgaRA+PNhhosOa2WphrFDbk6Vat4wR/4q1KSK5iylQ6g5vhN S8tQ3EHCqtATBHpvO6dPHWi+YGCG6BzSEclBTKIs04x3yow213i5P3EkloHzlMAqUEs7mY 6WBA25JJRSyKpKMz+BGdZC1Jq16vqEK/V8nXL4NoM+dYU3NcoI3DWqtLD5I5+g== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 18/21] staging: media: tegra-video: add syncpts for Tegra20 to struct tegra_vi Date: Thu, 9 Mar 2023 15:43:17 +0100 Message-Id: <20230309144320.2937553-19-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903193215194102?= X-GMAIL-MSGID: =?utf-8?q?1759903193215194102?= In preparation to implement Tegra20 parallel video capture, add a variable to hold the required syncpt and document all the syncpt variables. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags Changed in v3: - recycle mw_ack_sp[0] instead of adding out_sp No changes in v2 --- drivers/staging/media/tegra-video/vi.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 8fadca33bcc9..d5e1ed4217e0 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -117,11 +117,13 @@ struct tegra_vi { * @vi: Tegra video input device structure * @frame_start_sp: host1x syncpoint pointer to synchronize programmed capture * start condition with hardware frame start events through host1x - * syncpoint counters. + * syncpoint counters. (Tegra210) * @mw_ack_sp: host1x syncpoint pointer to synchronize programmed memory write * ack trigger condition with hardware memory write done at end of - * frame through host1x syncpoint counters. + * frame through host1x syncpoint counters (On Tegra20 used for the + * OUT_1 syncpt) * @sp_incr_lock: protects cpu syncpoint increment. + * @next_out_sp_idx: next expected value for mw_ack_sp[0], i.e. OUT_1 (Tegra20) * * @kthread_start_capture: kthread to start capture of single frame when * vb buffer is available. This thread programs VI CSI hardware @@ -173,6 +175,7 @@ struct tegra_vi_channel { struct host1x_syncpt *mw_ack_sp[GANG_PORTS_MAX]; /* protects the cpu syncpoint increment */ spinlock_t sp_incr_lock[GANG_PORTS_MAX]; + u32 next_out_sp_idx; struct task_struct *kthread_start_capture; wait_queue_head_t start_wait; From patchwork Thu Mar 9 14:43:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp339962wrd; Thu, 9 Mar 2023 07:05:52 -0800 (PST) X-Google-Smtp-Source: AK7set91hwToGCEZpFmHUqyvmBEQ9k2ICz7zoUODz2JDZ9X6FDfy+0p9InKnBsXAo+IkFXS8Vuxv X-Received: by 2002:a05:7500:3604:b0:fb:70fb:5398 with SMTP id fo4-20020a057500360400b000fb70fb5398mr215461gab.19.1678374352338; Thu, 09 Mar 2023 07:05:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374352; cv=none; d=google.com; s=arc-20160816; b=o1eMT+8My2jy9Hhmq9W2DGPuK2mIxLW2ZnGYmMDzKRbcYFmcoRo2FTHKMkseqpJObd AlXs9tKu9jPQwK9+S1/I2mpcUU+aS2Sqg9oS0zCMjJ51g7Ft9MWt0tfpCD89B5AW9Ggr vvVu3rvKID6+J+GfP30J+fd89ZEpK+Y9MtliV/qELwjEgxllsCDPlrK1v96ylqxyxqbP pFuvBZl1wrcVE1k3N2kuQbZqh/p6sUyhPvZ/hs5y7vMmJ6+YioCKWuXc7J+V3/4LZNFN nC/iYCnIdE/KQ0EmXqoE9GucsaSvtgc8OJozljufzrfiQcTCVDWKzaoI/+e2F8B6z7/O 2vnw== 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=5GVBn/5Ejaf5yDv/899F9oxQ2OpzgLGi/GDA/rDDcis=; b=JwqEs7ECzkIQnDL+lJuXG2qX2sB2MpkSmTHXJ+t2W9trCPXuTip2q+Q0MI6SEZUefN J/FKp1DFLnvmD3w9Iecd31IzHuG9GQ4qfivgpQbxKGihKpyvB0AQyuu+Z+VUgrgj/gIW eLs/aINWE4Knmg6b+EpQUM54J7TIpJFkhQc4iWR6XSsuBgzLkOr+RFiyPLFHaLFw26pF EoV2zBB80RqgzfQQTsJceuUrsROLqkqxhJO54e8c4IsLbGPhgES2mc6pir0EF7o5wU9z NVwtTAElI12esl3ZqPhxqoxpSmM2TQId+UUO/Xq0yqPPKCvqnv/D6vOdfKdru6FKhglQ 1ljQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dJ5jqVrE; 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 a1-20020a05610234c100b00413ff0f5b97si5872802vst.655.2023.03.09.07.05.34; Thu, 09 Mar 2023 07:05: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=dJ5jqVrE; 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 S232122AbjCIOq1 (ORCPT + 99 others); Thu, 9 Mar 2023 09:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231927AbjCIOpZ (ORCPT ); Thu, 9 Mar 2023 09:45:25 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7D0BF0FC5; Thu, 9 Mar 2023 06:44:28 -0800 (PST) Received: from booty.fritz.box (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 5E39CFF807; Thu, 9 Mar 2023 14:44:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373065; 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=5GVBn/5Ejaf5yDv/899F9oxQ2OpzgLGi/GDA/rDDcis=; b=dJ5jqVrErf4aMIFYL9Tnicx/ID6BaIbpBc0BoJBmRolqO2WRgxOuPDtRZIj/y7MrZHAOB9 wDp+tGW+3TLEzifqx3gsHGOo3mrm3wiK4Qoh8njkxA3/+QZAyPCRVtoSLwBWkp4OrzzK5k 4kK7fxle76R6niQm2RWvl3+PF7S9eweoYvgXKlL1OCcWBue2+L2a9iP/oMzs/dYWnQIiPA 0M8+Uh35KmNUZGyl9T2Yo97NYLs1cL7gET6qi2tqgXWdUIeKFfn9L+g9pCjyU+NRqQM5X7 +RpNfosty9/0/ZGnVWbAO8+osEznmB2O9kV5mpST8ks0G1E/Zr6diUNSlhCzig== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 19/21] staging: media: tegra-video: add hooks for planar YUV and H/V flip Date: Thu, 9 Mar 2023 15:43:18 +0100 Message-Id: <20230309144320.2937553-20-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903064907127311?= X-GMAIL-MSGID: =?utf-8?q?1759903064907127311?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 4 ++++ drivers/staging/media/tegra-video/vi.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 760606c65a97..4a066b61ab8e 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -92,6 +92,7 @@ tegra_get_format_by_fourcc(struct tegra_vi *vi, u32 fourcc) /* * videobuf2 queue operations */ + static int tegra_channel_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, unsigned int *nplanes, @@ -107,6 +108,9 @@ static int tegra_channel_queue_setup(struct vb2_queue *vq, sizes[0] = chan->format.sizeimage; alloc_devs[0] = chan->vi->dev; + if (chan->vi->ops->channel_queue_setup) + chan->vi->ops->channel_queue_setup(chan); + return 0; } diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index d5e1ed4217e0..0503eb678556 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -47,6 +47,7 @@ struct tegra_vi_channel; * @channel_host1x_syncpt_free: free all synchronization points * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry + * @channel_queue_setup: additional operations at the end of vb2_ops::queue_setup * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up * VI for capture and runs capture start and capture finish * kthreads for capturing frames to buffer and returns them back. @@ -58,6 +59,7 @@ struct tegra_vi_ops { int (*channel_host1x_syncpt_init)(struct tegra_vi_channel *chan); void (*channel_host1x_syncpt_free)(struct tegra_vi_channel *chan); void (*vi_fmt_align)(struct v4l2_pix_format *pix, unsigned int bpp); + void (*channel_queue_setup)(struct tegra_vi_channel *chan); int (*vi_start_streaming)(struct vb2_queue *vq, u32 count); void (*vi_stop_streaming)(struct vb2_queue *vq); }; @@ -148,6 +150,12 @@ struct tegra_vi { * @queue: vb2 buffers queue * @sequence: V4L2 buffers sequence number * + * @addr_offset_u: U plane base address, relative to buffer base address (only for planar) + * @addr_offset_v: V plane base address, relative to buffer base address (only for planar) + * @start_offset: 1st Y byte to write, relative to buffer base address (for H/V flip) + * @start_offset_u: 1st U byte to write, relative to buffer base address (for H/V flip) + * @start_offset_v: 1st V byte to write, relative to buffer base address (for H/V flip) + * * @capture: list of queued buffers for capture * @start_lock: protects the capture queued list * @done: list of capture done queued buffers @@ -187,6 +195,12 @@ struct tegra_vi_channel { struct vb2_queue queue; u32 sequence; + unsigned int addr_offset_u; + unsigned int addr_offset_v; + unsigned int start_offset; + unsigned int start_offset_u; + unsigned int start_offset_v; + struct list_head capture; /* protects the capture queued list */ spinlock_t start_lock; From patchwork Thu Mar 9 14:43:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp341897wrd; Thu, 9 Mar 2023 07:08:24 -0800 (PST) X-Google-Smtp-Source: AK7set/WLx53UsbbCvK+LSd0k/75xbaHFnAju8xIkO1H1t6Lt3Ek/TekCmZjO/pYeuoQve3UphCd X-Received: by 2002:a92:c546:0:b0:319:593e:62d2 with SMTP id a6-20020a92c546000000b00319593e62d2mr20556575ilj.27.1678374503954; Thu, 09 Mar 2023 07:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374503; cv=none; d=google.com; s=arc-20160816; b=fi7ZB85X6Xfje91RGdCL7CY9zm9iwW6YR91MU1f2xbN2kKtDywKf5aojZ8rt0n06Hr 9QZs/kN7rDr0kLgajTPZ7thzyojc92LBudgv0U9SGt2I1UHYlx6xWdhvf966rXggCuCy p3tjazWaiMhOt8XVyUT8v+41/Lkh/xtTo5Cg1rqmzV3iPP4ndmsggKl7JBVoUPK6e38K nV4bGxGOHZdbEV++vIXczbz8RGnwIGVD72G111mvJS/HtQjNbSgu/v1b83KARNlGT+wN /JpoArMMRagT3BncFxoVEZy7h+qqHFdWYm0AyzdS74yXnlvzElol0oo5ANI2b/51apYG p9xQ== 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=hDiV5rOlFdW2m46RMT95urn/gnlTWYvRe5STpBeX4qE=; b=RQ7cU29WeootfybAwdbU0vcJBL1ge9fkAmEAMAZrE4BeAB45EB3AGekwfMsACpb3C9 V/7BXud0a2fgcy8cA6RBUh6WOtek+cAnwhdR+8TFsfNBT2QcsIAPvTlP1Si+Sfg7WEWt 8gbc6MbL7ZiqYOwR0PqA8sNSteE5UmV8jLYeh4suTncyVgwcPGo16lJvG052Jtx3qCyW 3wWQ+bJw68PHNucg/aiOqV+t5JSkejSzWwF+3U1Aeh+y+ga6S68hlOVAj+/P/P+MzvLh mLBthfPuPEAgwU8x+KpiZbjZyHcv7bXLdP292Pbi+pjipVdPD+lKRHcc3DyHs3St8a9y Mf7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lAz7R6EN; 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 p14-20020a056e0206ce00b0031402bfcb5esi12115734ils.3.2023.03.09.07.08.08; Thu, 09 Mar 2023 07:08:23 -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=lAz7R6EN; 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 S232012AbjCIOrM (ORCPT + 99 others); Thu, 9 Mar 2023 09:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbjCIOqs (ORCPT ); Thu, 9 Mar 2023 09:46:48 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 776E8F4018; Thu, 9 Mar 2023 06:44:59 -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 123CAFF80D; Thu, 9 Mar 2023 14:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373068; 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=hDiV5rOlFdW2m46RMT95urn/gnlTWYvRe5STpBeX4qE=; b=lAz7R6ENEmOVb3VuiZBSQo9DJOKmuQjU1rNxvD322vbsGHGH3FYqNA1ShRnnA0kv0yAzrl 7nipezhFoF6nzxveySCbLRSREGWJxP3Njbnf7YrlAIdxkXN4w8AyzDbkrtetbR5ABPclfU jIXWVmP472LO2Oza9HtwxzEOtLxigamVtYE3bsyv1fJ5HEOFqLSGiJX55+xW3nc7dDB5Bj e61zMckIIx8CL09GXDFNvEIVoYv0r0owpSnDrdoYE2njfrmPWMm6vQ90N2pJP2CRTrsncm uO8shr3cSCDWb8LJ/PmyuZg4o4gdL4KeiQX1F/Lb66gzbVBDg4pO4jUwauj0tA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 20/21] staging: media: tegra-video: add H/V flip controls Date: Thu, 9 Mar 2023 15:43:19 +0100 Message-Id: <20230309144320.2937553-21-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903223378257626?= X-GMAIL-MSGID: =?utf-8?q?1759903223378257626?= 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 Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags No changes in v3 No changes in v2 --- drivers/staging/media/tegra-video/vi.c | 14 +++++++++++++- drivers/staging/media/tegra-video/vi.h | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 4a066b61ab8e..d1c6877163c2 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -29,7 +29,7 @@ #include "vi.h" #include "video.h" -#define MAX_CID_CONTROLS 1 +#define MAX_CID_CONTROLS 3 /** * struct tegra_vi_graph_entity - Entity in the video graph @@ -893,6 +893,12 @@ static int vi_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_TEGRA_SYNCPT_TIMEOUT_RETRY: chan->syncpt_timeout_retry = ctrl->val; break; + case V4L2_CID_HFLIP: + chan->hflip = ctrl->val; + break; + case V4L2_CID_VFLIP: + chan->vflip = ctrl->val; + break; default: return -EINVAL; } @@ -964,6 +970,12 @@ static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan) v4l2_ctrl_handler_free(&chan->ctrl_handler); return ret; } + + if (chan->vi->soc->has_h_v_flip) { + v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); + v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); + } + #endif /* setup the controls */ diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 0503eb678556..8fa817757059 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -74,6 +74,7 @@ struct tegra_vi_ops { * @hw_revision: VI hw_revision * @vi_max_channels: supported max streaming channels * @vi_max_clk_hz: VI clock max frequency + * @has_h_v_flip: the chip can do H adn V flip, and the driver implements it */ struct tegra_vi_soc { const struct tegra_video_format *video_formats; @@ -83,6 +84,7 @@ struct tegra_vi_soc { u32 hw_revision; unsigned int vi_max_channels; unsigned int vi_max_clk_hz; + bool has_h_v_flip:1; }; /** @@ -170,6 +172,9 @@ struct tegra_vi { * @syncpt_timeout_retry: syncpt timeout retry count for the capture * @pg_mode: test pattern generator mode (disabled/direct/patch) * @notifier: V4L2 asynchronous subdevs notifier + * + * @hflip: Horizontal flip is enabled + * @vflip: Vertical flip is enabled */ struct tegra_vi_channel { struct list_head list; @@ -218,6 +223,9 @@ struct tegra_vi_channel { enum tegra_vi_pg_mode pg_mode; struct v4l2_async_notifier notifier; + + bool hflip:1; + bool vflip:1; }; /** From patchwork Thu Mar 9 14:43:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 66923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp342336wrd; Thu, 9 Mar 2023 07:09:08 -0800 (PST) X-Google-Smtp-Source: AK7set/PIQBaFWV/4yl53uc4ZJKyzYU8YS4ZqHqaqvNFsNQaPnJgFo3zbIqr/rp/m/CgcddmtSyk X-Received: by 2002:a05:6e02:1bea:b0:317:9c76:db69 with SMTP id y10-20020a056e021bea00b003179c76db69mr17624758ilv.1.1678374548244; Thu, 09 Mar 2023 07:09:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374548; cv=none; d=google.com; s=arc-20160816; b=cGstgNC0S3dhM4L8aJ+6zfUofuSYAtTgeWdap2nKKBzp1wjSOWeL0tJjEqiJ78h/AD RypOpXFLZKTxqXuYXh0ic/cg4cnObM63rXrkq3bT9wNwQmJfBppiBi60t+n/IbPrCSIo E7zhMEVNTemBS0UJ7xtn+nFHmo8V6h1uoxewNpinuQYO/OxmmyU+gr4lQmrMyuPqQX9B MzogZjGYP11VPYZIpiQ6XJMXZ/34tT3JP2/ucJYRtNHUAqz+N3zErz/g8DBlAE3KbGtA xAkeXsfGbWfLYs6sk/K06VHbdUJPV9KEzsHHA30OHKrfvF8x3e1ANrchdkkXwXF59yMl LhhQ== 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=vn4s+Ag8xYz7D9Ji26yuqXoUEBgTdB0/iDKSezYY4jU=; b=VVBukN6UbV/RROjDAj8WZZljN0za+41fOU7Q3bXAcwA3dIZ7AI8Ry0ft3FCMKu4Q5e ueAWmY716otkusczANINRpdGu6Ec/tzNxxLE/4ki55j3QuP6qJ2Z2X/caUlBymO9JeDY RjwKCsjUqFbsWLBiYAV9/yz9BdK2muloBXmmr1ThiRdzSUNnoQucjm6poKLDj35On3in UM3L8mEU7Wzzsr/+/Uj1mSv7wuaRpv8mID9bUC2GXu9/CcOtOGk82ZxfyX46aLUWfy9y ooR2oOlxUGdNeRq8Gk3HPuyNJsi46ASjJ7l2Nxga4A1E/pwBCC1ncJSQvQbpelbpO0Wk Nlaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XhVceUzW; 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 a12-20020a056638018c00b003b204d76712si17147457jaq.27.2023.03.09.07.08.53; Thu, 09 Mar 2023 07:09:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XhVceUzW; 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 S232151AbjCIOrZ (ORCPT + 99 others); Thu, 9 Mar 2023 09:47:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231928AbjCIOrC (ORCPT ); Thu, 9 Mar 2023 09:47:02 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3ADBF402A; Thu, 9 Mar 2023 06:45:05 -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 ED34AFF815; Thu, 9 Mar 2023 14:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678373071; 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=vn4s+Ag8xYz7D9Ji26yuqXoUEBgTdB0/iDKSezYY4jU=; b=XhVceUzWoSvnZFk6by/6SCdnLIBRc7ThttWLPbRZWNf8wzhaFSBWCpKyQYOgoCNTH0TfzZ 7ugHv8mh9tZ106YA1OnHgXeO/n2wqvu2HAFiP6S+jlm9luXs2JHhjFNUIzXly45BjpeDft na6UuB4ZpJ4ny3AzmZRtLv5LLorAinmEtGdy4j5/fD/dY/HnMEXohQsNh2eRc7ZnfRXzU5 b77Oac3BAUI5NMW8Q9vMV4QlA0qoIpG2rnAfPihqWno/Sxrsiaq1tkpcypokLlu4IS+hWz 3RMvOaPNjQVM73H3IltejpOjzJphZOK7MKn9IWxZzbH5u4o/16QF7Wg7lu1/sA== From: Luca Ceresoli To: Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , 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: [RESEND PATCH v4 21/21] staging: media: tegra-video: add support for Tegra20 parallel input Date: Thu, 9 Mar 2023 15:43:20 +0100 Message-Id: <20230309144320.2937553-22-luca.ceresoli@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309144320.2937553-1-luca.ceresoli@bootlin.com> References: <20230309144320.2937553-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?1759903270046005584?= X-GMAIL-MSGID: =?utf-8?q?1759903270046005584?= The VI peripheral of Tegra supports capturing from MIPI CSI-2 or parallel video (called VIP in the docs). The staging tegra-video driver currently implements MIPI CSI-2 video capture for Tegra210. Add support for parallel video capture (VIP) on Tegra20. With the generalizations added to the VI driver in previous commits, this is only a matter of adding the vip.c and tegra20.c implementations and registering them. Unfortunately there was no documentation available for the VI or VIP peripherals of Tegra20 (or any other Tegra chips). This implementation has been based entirely on the code from a vendor kernel based on Linux 3.1 and massively adapted to fit into the tegra-video driver. Parts of this code is definitely non-optimal to say the least (especially tegra20_vi_enable() and the single-frame capture logic), but it was impossible to improve it. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Osipenko --- Changed in v4: - Added review tags Changed in v3 (suggested by Dmitry Osipenko): - merged the VIP patch and the Tegra20 patch to avoid chicken-egg problem due to the two modules depending on each other at build time - move tegra20_vip_soc to vip.c - remove channel@0 node from device tree parsing - remove unused variable Changed in v2: - fix tegra20_vi_enable() to clear bit when on==false - clamp width/height from set/try_fmt to avoid returning sizeimage=0 (fixes v4l2-compliance) --- drivers/staging/media/tegra-video/Makefile | 2 + drivers/staging/media/tegra-video/tegra20.c | 661 ++++++++++++++++++++ drivers/staging/media/tegra-video/vi.c | 3 + drivers/staging/media/tegra-video/vi.h | 3 + drivers/staging/media/tegra-video/video.c | 5 + drivers/staging/media/tegra-video/video.h | 1 + drivers/staging/media/tegra-video/vip.c | 290 +++++++++ drivers/staging/media/tegra-video/vip.h | 68 ++ 8 files changed, 1033 insertions(+) create mode 100644 drivers/staging/media/tegra-video/tegra20.c create mode 100644 drivers/staging/media/tegra-video/vip.c create mode 100644 drivers/staging/media/tegra-video/vip.h diff --git a/drivers/staging/media/tegra-video/Makefile b/drivers/staging/media/tegra-video/Makefile index dfa2ef8f99ef..6c7552e05109 100644 --- a/drivers/staging/media/tegra-video/Makefile +++ b/drivers/staging/media/tegra-video/Makefile @@ -2,7 +2,9 @@ tegra-video-objs := \ video.o \ vi.o \ + vip.o \ csi.o +tegra-video-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20.o tegra-video-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o obj-$(CONFIG_VIDEO_TEGRA) += tegra-video.o diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c new file mode 100644 index 000000000000..ac048bbd58f0 --- /dev/null +++ b/drivers/staging/media/tegra-video/tegra20.c @@ -0,0 +1,661 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Tegra20-specific VI implementation + * + * Copyright (C) 2022 SKIDATA GmbH + * Author: Luca Ceresoli + */ + +/* + * This source file contains Tegra20 supported video formats, + * VI and VIP SoC specific data, operations and registers accessors. + */ + +#include +#include +#include +#include +#include +#include + +#include "vip.h" +#include "vi.h" + +#define TEGRA_VI_SYNCPT_WAIT_TIMEOUT msecs_to_jiffies(200) + +/* This are just good-sense numbers. The actual min/max is not documented. */ +#define TEGRA20_MIN_WIDTH 32U +#define TEGRA20_MIN_HEIGHT 32U +#define TEGRA20_MAX_WIDTH 2048U +#define TEGRA20_MAX_HEIGHT 2048U + +/* -------------------------------------------------------------------------- + * Registers + */ + +#define TEGRA_VI_CONT_SYNCPT_OUT_1 0x0060 +#define VI_CONT_SYNCPT_OUT_1_CONTINUOUS_SYNCPT BIT(8) +#define VI_CONT_SYNCPT_OUT_1_SYNCPT_IDX_SFT 0 + +#define TEGRA_VI_VI_INPUT_CONTROL 0x0088 +#define VI_INPUT_FIELD_DETECT BIT(27) +#define VI_INPUT_BT656 BIT(25) +#define VI_INPUT_YUV_INPUT_FORMAT_SFT 8 /* bits [9:8] */ +#define VI_INPUT_YUV_INPUT_FORMAT_UYVY (0 << VI_INPUT_YUV_INPUT_FORMAT_SFT) +#define VI_INPUT_YUV_INPUT_FORMAT_VYUY (1 << VI_INPUT_YUV_INPUT_FORMAT_SFT) +#define VI_INPUT_YUV_INPUT_FORMAT_YUYV (2 << VI_INPUT_YUV_INPUT_FORMAT_SFT) +#define VI_INPUT_YUV_INPUT_FORMAT_YVYU (3 << VI_INPUT_YUV_INPUT_FORMAT_SFT) +#define VI_INPUT_INPUT_FORMAT_SFT 2 /* bits [5:2] */ +#define VI_INPUT_INPUT_FORMAT_YUV422 (0 << VI_INPUT_INPUT_FORMAT_SFT) +#define VI_INPUT_VIP_INPUT_ENABLE BIT(1) + +#define TEGRA_VI_VI_CORE_CONTROL 0x008c +#define VI_VI_CORE_CONTROL_PLANAR_CONV_IN_SEL_EXT BIT(31) +#define VI_VI_CORE_CONTROL_CSC_INPUT_SEL_EXT BIT(30) +#define VI_VI_CORE_CONTROL_INPUT_TO_ALT_MUX_SFT 27 +#define VI_VI_CORE_CONTROL_INPUT_TO_CORE_EXT_SFT 24 +#define VI_VI_CORE_CONTROL_OUTPUT_TO_ISP_EXT_SFT 21 +#define VI_VI_CORE_CONTROL_ISP_HOST_STALL_OFF BIT(20) +#define VI_VI_CORE_CONTROL_V_DOWNSCALING BIT(19) +#define VI_VI_CORE_CONTROL_V_AVERAGING BIT(18) +#define VI_VI_CORE_CONTROL_H_DOWNSCALING BIT(17) +#define VI_VI_CORE_CONTROL_H_AVERAGING BIT(16) +#define VI_VI_CORE_CONTROL_CSC_INPUT_SEL BIT(11) +#define VI_VI_CORE_CONTROL_PLANAR_CONV_INPUT_SEL BIT(10) +#define VI_VI_CORE_CONTROL_INPUT_TO_CORE_SFT 8 +#define VI_VI_CORE_CONTROL_ISP_DOWNSAMPLE_SFT 5 +#define VI_VI_CORE_CONTROL_OUTPUT_TO_EPP_SFT 2 +#define VI_VI_CORE_CONTROL_OUTPUT_TO_ISP_SFT 0 + +#define TEGRA_VI_VI_FIRST_OUTPUT_CONTROL 0x0090 +#define VI_OUTPUT_FORMAT_EXT BIT(22) +#define VI_OUTPUT_V_DIRECTION BIT(20) +#define VI_OUTPUT_H_DIRECTION BIT(19) +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT 17 +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_UYVY (0 << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_VYUY (1 << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_YUYV (2 << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_YUV_OUTPUT_FORMAT_YVYU (3 << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_OUTPUT_BYTE_SWAP BIT(16) +#define VI_OUTPUT_LAST_PIXEL_DUPLICATION BIT(8) +#define VI_OUTPUT_OUTPUT_FORMAT_SFT 0 +#define VI_OUTPUT_OUTPUT_FORMAT_YUV422POST (3 << VI_OUTPUT_OUTPUT_FORMAT_SFT) +#define VI_OUTPUT_OUTPUT_FORMAT_YUV420PLANAR (6 << VI_OUTPUT_OUTPUT_FORMAT_SFT) + +#define TEGRA_VI_VIP_H_ACTIVE 0x00a4 +#define VI_VIP_H_ACTIVE_PERIOD_SFT 16 /* active pixels/line, must be even */ +#define VI_VIP_H_ACTIVE_START_SFT 0 + +#define TEGRA_VI_VIP_V_ACTIVE 0x00a8 +#define VI_VIP_V_ACTIVE_PERIOD_SFT 16 /* active lines */ +#define VI_VIP_V_ACTIVE_START_SFT 0 + +#define TEGRA_VI_VB0_START_ADDRESS_FIRST 0x00c4 +#define TEGRA_VI_VB0_BASE_ADDRESS_FIRST 0x00c8 +#define TEGRA_VI_VB0_START_ADDRESS_U 0x00cc +#define TEGRA_VI_VB0_BASE_ADDRESS_U 0x00d0 +#define TEGRA_VI_VB0_START_ADDRESS_V 0x00d4 +#define TEGRA_VI_VB0_BASE_ADDRESS_V 0x00d8 + +#define TEGRA_VI_FIRST_OUTPUT_FRAME_SIZE 0x00e0 +#define VI_FIRST_OUTPUT_FRAME_HEIGHT_SFT 16 +#define VI_FIRST_OUTPUT_FRAME_WIDTH_SFT 0 + +#define TEGRA_VI_VB0_COUNT_FIRST 0x00e4 + +#define TEGRA_VI_VB0_SIZE_FIRST 0x00e8 +#define VI_VB0_SIZE_FIRST_V_SFT 16 +#define VI_VB0_SIZE_FIRST_H_SFT 0 + +#define TEGRA_VI_VB0_BUFFER_STRIDE_FIRST 0x00ec +#define VI_VB0_BUFFER_STRIDE_FIRST_CHROMA_SFT 30 +#define VI_VB0_BUFFER_STRIDE_FIRST_LUMA_SFT 0 + +#define TEGRA_VI_H_LPF_CONTROL 0x0108 +#define VI_H_LPF_CONTROL_CHROMA_SFT 16 +#define VI_H_LPF_CONTROL_LUMA_SFT 0 + +#define TEGRA_VI_H_DOWNSCALE_CONTROL 0x010c +#define TEGRA_VI_V_DOWNSCALE_CONTROL 0x0110 + +#define TEGRA_VI_VIP_INPUT_STATUS 0x0144 + +#define TEGRA_VI_VI_DATA_INPUT_CONTROL 0x0168 +#define VI_DATA_INPUT_SFT 0 /* [11:0] = mask pin inputs to VI core */ + +#define TEGRA_VI_PIN_INPUT_ENABLE 0x016c +#define VI_PIN_INPUT_VSYNC BIT(14) +#define VI_PIN_INPUT_HSYNC BIT(13) +#define VI_PIN_INPUT_VD_SFT 0 /* [11:0] = data bin N input enable */ + +#define TEGRA_VI_PIN_INVERSION 0x0174 +#define VI_PIN_INVERSION_VSYNC_ACTIVE_HIGH BIT(1) +#define VI_PIN_INVERSION_HSYNC_ACTIVE_HIGH BIT(0) + +#define TEGRA_VI_CAMERA_CONTROL 0x01a0 +#define VI_CAMERA_CONTROL_STOP_CAPTURE BIT(2) +#define VI_CAMERA_CONTROL_TEST_MODE BIT(1) +#define VI_CAMERA_CONTROL_VIP_ENABLE BIT(0) + +#define TEGRA_VI_VI_ENABLE 0x01a4 +#define VI_VI_ENABLE_SW_FLOW_CONTROL_OUT1 BIT(1) +#define VI_VI_ENABLE_FIRST_OUTPUT_TO_MEM_DISABLE BIT(0) + +#define TEGRA_VI_VI_RAISE 0x01ac +#define VI_VI_RAISE_ON_EDGE BIT(0) + +/* -------------------------------------------------------------------------- + * VI + */ + +static void tegra20_vi_write(struct tegra_vi_channel *chan, unsigned int addr, u32 val) +{ + writel(val, chan->vi->iomem + addr); +} + +/* + * Get the main input format (YUV/RGB...) and the YUV variant as values to + * be written into registers for the current VI input mbus code. + */ +static void tegra20_vi_get_input_formats(struct tegra_vi_channel *chan, + unsigned int *main_input_format, + unsigned int *yuv_input_format) +{ + unsigned int input_mbus_code = chan->fmtinfo->code; + + (*main_input_format) = VI_INPUT_INPUT_FORMAT_YUV422; + + switch (input_mbus_code) { + case MEDIA_BUS_FMT_UYVY8_2X8: + (*yuv_input_format) = VI_INPUT_YUV_INPUT_FORMAT_UYVY; + break; + case MEDIA_BUS_FMT_VYUY8_2X8: + (*yuv_input_format) = VI_INPUT_YUV_INPUT_FORMAT_VYUY; + break; + case MEDIA_BUS_FMT_YUYV8_2X8: + (*yuv_input_format) = VI_INPUT_YUV_INPUT_FORMAT_YUYV; + break; + case MEDIA_BUS_FMT_YVYU8_2X8: + (*yuv_input_format) = VI_INPUT_YUV_INPUT_FORMAT_YVYU; + break; + } +} + +/* + * Get the main output format (YUV/RGB...) and the YUV variant as values to + * be written into registers for the current VI output pixel format. + */ +static void tegra20_vi_get_output_formats(struct tegra_vi_channel *chan, + unsigned int *main_output_format, + unsigned int *yuv_output_format) +{ + u32 output_fourcc = chan->format.pixelformat; + + /* Default to YUV422 non-planar (U8Y8V8Y8) after downscaling */ + (*main_output_format) = VI_OUTPUT_OUTPUT_FORMAT_YUV422POST; + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_UYVY; + + switch (output_fourcc) { + case V4L2_PIX_FMT_UYVY: + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_UYVY; + break; + case V4L2_PIX_FMT_VYUY: + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_VYUY; + break; + case V4L2_PIX_FMT_YUYV: + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_YUYV; + break; + case V4L2_PIX_FMT_YVYU: + (*yuv_output_format) = VI_OUTPUT_YUV_OUTPUT_FORMAT_YVYU; + break; + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + (*main_output_format) = VI_OUTPUT_OUTPUT_FORMAT_YUV420PLANAR; + break; + } +} + +/* + * Make the VI to be accessible (needed on Tegra20). + * + * This function writes an unknown bit into an unknown register. The code + * comes from a downstream 3.1 kernel that has a working VIP driver for + * Tegra20, and removing it makes the VI completely unaccessible. It should + * be rewritten and possibly moved elsewhere, but the appropriate location + * and implementation is unknown due to a total lack of documentation. + */ +static int tegra20_vi_enable(struct tegra_vi *vi, bool on) +{ + /* from arch/arm/mach-tegra/iomap.h */ + const phys_addr_t TEGRA_APB_MISC_BASE = 0x70000000; + const unsigned long reg_offset = 0x42c; + void __iomem *apb_misc; + u32 val; + + apb_misc = ioremap(TEGRA_APB_MISC_BASE, PAGE_SIZE); + if (!apb_misc) + apb_misc = ERR_PTR(-ENOENT); + if (IS_ERR(apb_misc)) + return dev_err_probe(vi->dev, PTR_ERR(apb_misc), "cannot access APB_MISC"); + + val = readl(apb_misc + reg_offset); + val &= ~BIT(0); + val |= on ? BIT(0) : 0; + writel(val, apb_misc + reg_offset); + iounmap(apb_misc); + + return 0; +} + +static int tegra20_channel_host1x_syncpt_init(struct tegra_vi_channel *chan) +{ + struct tegra_vi *vi = chan->vi; + struct host1x_syncpt *out_sp; + + out_sp = host1x_syncpt_request(&vi->client, HOST1X_SYNCPT_CLIENT_MANAGED); + if (!out_sp) + return dev_err_probe(vi->dev, -ENOMEM, "failed to request syncpoint\n"); + + chan->mw_ack_sp[0] = out_sp; + + return 0; +} + +static void tegra20_channel_host1x_syncpt_free(struct tegra_vi_channel *chan) +{ + host1x_syncpt_put(chan->mw_ack_sp[0]); +} + +static void tegra20_fmt_align(struct v4l2_pix_format *pix, unsigned int bpp) +{ + pix->width = clamp(pix->width, TEGRA20_MIN_WIDTH, TEGRA20_MAX_WIDTH); + pix->height = clamp(pix->height, TEGRA20_MIN_HEIGHT, TEGRA20_MAX_HEIGHT); + + switch (pix->pixelformat) { + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_YVYU: + pix->bytesperline = roundup(pix->width, 2) * 2; + pix->sizeimage = roundup(pix->width, 2) * 2 * pix->height; + break; + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + pix->bytesperline = roundup(pix->width, 8); + pix->sizeimage = roundup(pix->width, 8) * pix->height * 3 / 2; + break; + } +} + +/* + * Compute buffer offsets once per stream so that + * tegra20_channel_vi_buffer_setup() only has to do very simple maths for + * each buffer. + */ +static void tegra20_channel_queue_setup(struct tegra_vi_channel *chan) +{ + unsigned int stride = chan->format.bytesperline; + unsigned int height = chan->format.height; + + chan->start_offset = 0; + + switch (chan->format.pixelformat) { + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_YVYU: + if (chan->vflip) + chan->start_offset += stride * (height - 1); + if (chan->hflip) + chan->start_offset += stride - 1; + break; + + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + chan->addr_offset_u = stride * height; + chan->addr_offset_v = chan->addr_offset_u + stride * height / 4; + + /* For YVU420, we swap the locations of the U and V planes. */ + if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420) { + unsigned long temp; + + temp = chan->addr_offset_u; + chan->addr_offset_u = chan->addr_offset_v; + chan->addr_offset_v = temp; + } + + chan->start_offset_u = chan->addr_offset_u; + chan->start_offset_v = chan->addr_offset_v; + + if (chan->vflip) { + chan->start_offset += stride * (height - 1); + chan->start_offset_u += (stride / 2) * ((height / 2) - 1); + chan->start_offset_v += (stride / 2) * ((height / 2) - 1); + } + if (chan->hflip) { + chan->start_offset += stride - 1; + chan->start_offset_u += (stride / 2) - 1; + chan->start_offset_v += (stride / 2) - 1; + } + break; + } +} + +static void release_buffer(struct tegra_vi_channel *chan, + struct tegra_channel_buffer *buf, + enum vb2_buffer_state state) +{ + struct vb2_v4l2_buffer *vb = &buf->buf; + + vb->sequence = chan->sequence++; + vb->field = V4L2_FIELD_NONE; + vb->vb2_buf.timestamp = ktime_get_ns(); + vb2_buffer_done(&vb->vb2_buf, state); +} + +static void tegra20_channel_vi_buffer_setup(struct tegra_vi_channel *chan, + struct tegra_channel_buffer *buf) +{ + dma_addr_t base = buf->addr; + + switch (chan->fmtinfo->fourcc) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + tegra20_vi_write(chan, TEGRA_VI_VB0_BASE_ADDRESS_U, base + chan->addr_offset_u); + tegra20_vi_write(chan, TEGRA_VI_VB0_START_ADDRESS_U, base + chan->start_offset_u); + tegra20_vi_write(chan, TEGRA_VI_VB0_BASE_ADDRESS_V, base + chan->addr_offset_v); + tegra20_vi_write(chan, TEGRA_VI_VB0_START_ADDRESS_V, base + chan->start_offset_v); + fallthrough; + + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_YVYU: + tegra20_vi_write(chan, TEGRA_VI_VB0_BASE_ADDRESS_FIRST, base); + tegra20_vi_write(chan, TEGRA_VI_VB0_START_ADDRESS_FIRST, base + chan->start_offset); + break; + } +} + +static int tegra20_channel_capture_frame(struct tegra_vi_channel *chan, + struct tegra_channel_buffer *buf) +{ + int err; + + chan->next_out_sp_idx++; + + tegra20_channel_vi_buffer_setup(chan, buf); + + tegra20_vi_write(chan, TEGRA_VI_CAMERA_CONTROL, VI_CAMERA_CONTROL_VIP_ENABLE); + + /* Wait for syncpt counter to reach frame start event threshold */ + err = host1x_syncpt_wait(chan->mw_ack_sp[0], chan->next_out_sp_idx, + TEGRA_VI_SYNCPT_WAIT_TIMEOUT, NULL); + if (err) { + host1x_syncpt_incr(chan->mw_ack_sp[0]); + dev_err_ratelimited(&chan->video.dev, "frame start syncpt timeout: %d\n", err); + release_buffer(chan, buf, VB2_BUF_STATE_ERROR); + return err; + } + + tegra20_vi_write(chan, TEGRA_VI_CAMERA_CONTROL, + VI_CAMERA_CONTROL_STOP_CAPTURE | VI_CAMERA_CONTROL_VIP_ENABLE); + + release_buffer(chan, buf, VB2_BUF_STATE_DONE); + + return 0; +} + +static int tegra20_chan_capture_kthread_start(void *data) +{ + struct tegra_vi_channel *chan = data; + struct tegra_channel_buffer *buf; + unsigned int retries = 0; + int err = 0; + + while (1) { + /* + * Source is not streaming if error is non-zero. + * So, do not dequeue buffers on error and let the thread sleep + * till kthread stop signal is received. + */ + wait_event_interruptible(chan->start_wait, + kthread_should_stop() || + (!list_empty(&chan->capture) && !err)); + + if (kthread_should_stop()) + break; + + /* dequeue the buffer and start capture */ + spin_lock(&chan->start_lock); + if (list_empty(&chan->capture)) { + spin_unlock(&chan->start_lock); + continue; + } + + buf = list_first_entry(&chan->capture, struct tegra_channel_buffer, queue); + list_del_init(&buf->queue); + spin_unlock(&chan->start_lock); + + err = tegra20_channel_capture_frame(chan, buf); + if (!err) { + retries = 0; + continue; + } + + if (retries++ > chan->syncpt_timeout_retry) + vb2_queue_error(&chan->queue); + else + err = 0; + } + + return 0; +} + +static void tegra20_camera_capture_setup(struct tegra_vi_channel *chan) +{ + u32 output_fourcc = chan->format.pixelformat; + int width = chan->format.width; + int height = chan->format.height; + int stride_l = chan->format.bytesperline; + int stride_c = (output_fourcc == V4L2_PIX_FMT_YUV420 || + output_fourcc == V4L2_PIX_FMT_YVU420) ? 1 : 0; + int main_output_format; + int yuv_output_format; + + tegra20_vi_get_output_formats(chan, &main_output_format, &yuv_output_format); + + /* + * Set up low pass filter. Use 0x240 for chromaticity and 0x240 + * for luminance, which is the default and means not to touch + * anything. + */ + tegra20_vi_write(chan, TEGRA_VI_H_LPF_CONTROL, + 0x0240 << VI_H_LPF_CONTROL_LUMA_SFT | + 0x0240 << VI_H_LPF_CONTROL_CHROMA_SFT); + + /* Set up raise-on-edge, so we get an interrupt on end of frame. */ + tegra20_vi_write(chan, TEGRA_VI_VI_RAISE, VI_VI_RAISE_ON_EDGE); + + tegra20_vi_write(chan, TEGRA_VI_VI_FIRST_OUTPUT_CONTROL, + (chan->vflip ? VI_OUTPUT_V_DIRECTION : 0) | + (chan->hflip ? VI_OUTPUT_H_DIRECTION : 0) | + yuv_output_format << VI_OUTPUT_YUV_OUTPUT_FORMAT_SFT | + main_output_format << VI_OUTPUT_OUTPUT_FORMAT_SFT); + + /* Set up frame size */ + tegra20_vi_write(chan, TEGRA_VI_FIRST_OUTPUT_FRAME_SIZE, + height << VI_FIRST_OUTPUT_FRAME_HEIGHT_SFT | + width << VI_FIRST_OUTPUT_FRAME_WIDTH_SFT); + + /* First output memory enabled */ + tegra20_vi_write(chan, TEGRA_VI_VI_ENABLE, 0); + + /* Set the number of frames in the buffer */ + tegra20_vi_write(chan, TEGRA_VI_VB0_COUNT_FIRST, 1); + + /* Set up buffer frame size */ + tegra20_vi_write(chan, TEGRA_VI_VB0_SIZE_FIRST, + height << VI_VB0_SIZE_FIRST_V_SFT | + width << VI_VB0_SIZE_FIRST_H_SFT); + + tegra20_vi_write(chan, TEGRA_VI_VB0_BUFFER_STRIDE_FIRST, + stride_l << VI_VB0_BUFFER_STRIDE_FIRST_LUMA_SFT | + stride_c << VI_VB0_BUFFER_STRIDE_FIRST_CHROMA_SFT); + + tegra20_vi_write(chan, TEGRA_VI_VI_ENABLE, 0); +} + +static int tegra20_vi_start_streaming(struct vb2_queue *vq, u32 count) +{ + struct tegra_vi_channel *chan = vb2_get_drv_priv(vq); + struct media_pipeline *pipe = &chan->video.pipe; + int err; + + chan->next_out_sp_idx = host1x_syncpt_read(chan->mw_ack_sp[0]); + + err = video_device_pipeline_start(&chan->video, pipe); + if (err) + goto error_pipeline_start; + + tegra20_camera_capture_setup(chan); + + err = tegra_channel_set_stream(chan, true); + if (err) + goto error_set_stream; + + chan->sequence = 0; + + chan->kthread_start_capture = kthread_run(tegra20_chan_capture_kthread_start, + chan, "%s:0", chan->video.name); + if (IS_ERR(chan->kthread_start_capture)) { + err = PTR_ERR(chan->kthread_start_capture); + chan->kthread_start_capture = NULL; + dev_err_probe(&chan->video.dev, err, "failed to run capture kthread\n"); + goto error_kthread_start; + } + + return 0; + +error_kthread_start: + tegra_channel_set_stream(chan, false); +error_set_stream: + video_device_pipeline_stop(&chan->video); +error_pipeline_start: + tegra_channel_release_buffers(chan, VB2_BUF_STATE_QUEUED); + + return err; +} + +static void tegra20_vi_stop_streaming(struct vb2_queue *vq) +{ + struct tegra_vi_channel *chan = vb2_get_drv_priv(vq); + + if (chan->kthread_start_capture) { + kthread_stop(chan->kthread_start_capture); + chan->kthread_start_capture = NULL; + } + + tegra_channel_release_buffers(chan, VB2_BUF_STATE_ERROR); + tegra_channel_set_stream(chan, false); + video_device_pipeline_stop(&chan->video); +} + +static const struct tegra_vi_ops tegra20_vi_ops = { + .vi_enable = tegra20_vi_enable, + .channel_host1x_syncpt_init = tegra20_channel_host1x_syncpt_init, + .channel_host1x_syncpt_free = tegra20_channel_host1x_syncpt_free, + .vi_fmt_align = tegra20_fmt_align, + .channel_queue_setup = tegra20_channel_queue_setup, + .vi_start_streaming = tegra20_vi_start_streaming, + .vi_stop_streaming = tegra20_vi_stop_streaming, +}; + +#define TEGRA20_VIDEO_FMT(MBUS_CODE, BPP, FOURCC) \ +{ \ + .code = MEDIA_BUS_FMT_##MBUS_CODE, \ + .bpp = BPP, \ + .fourcc = V4L2_PIX_FMT_##FOURCC, \ +} + +static const struct tegra_video_format tegra20_video_formats[] = { + TEGRA20_VIDEO_FMT(UYVY8_2X8, 2, UYVY), + TEGRA20_VIDEO_FMT(VYUY8_2X8, 2, VYUY), + TEGRA20_VIDEO_FMT(YUYV8_2X8, 2, YUYV), + TEGRA20_VIDEO_FMT(YVYU8_2X8, 2, YVYU), + TEGRA20_VIDEO_FMT(UYVY8_2X8, 1, YUV420), + TEGRA20_VIDEO_FMT(UYVY8_2X8, 1, YVU420), +}; + +const struct tegra_vi_soc tegra20_vi_soc = { + .video_formats = tegra20_video_formats, + .nformats = ARRAY_SIZE(tegra20_video_formats), + .default_video_format = &tegra20_video_formats[0], + .ops = &tegra20_vi_ops, + .vi_max_channels = 1, /* parallel input (VIP) */ + .vi_max_clk_hz = 150000000, + .has_h_v_flip = true, +}; + +/* -------------------------------------------------------------------------- + * VIP + */ + +/* + * VIP-specific configuration for stream start. + * + * Whatever is common among VIP and CSI is done by the VI component (see + * tegra20_vi_start_streaming()). Here we do what is VIP-specific. + */ +static int tegra20_vip_start_streaming(struct tegra_vip_channel *vip_chan) +{ + struct tegra_vi_channel *vi_chan = v4l2_get_subdev_hostdata(&vip_chan->subdev); + int width = vi_chan->format.width; + int height = vi_chan->format.height; + + unsigned int main_input_format; + unsigned int yuv_input_format; + + tegra20_vi_get_input_formats(vi_chan, &main_input_format, &yuv_input_format); + + tegra20_vi_write(vi_chan, TEGRA_VI_VI_CORE_CONTROL, 0); + + tegra20_vi_write(vi_chan, TEGRA_VI_VI_INPUT_CONTROL, + VI_INPUT_VIP_INPUT_ENABLE | main_input_format | yuv_input_format); + + tegra20_vi_write(vi_chan, TEGRA_VI_V_DOWNSCALE_CONTROL, 0); + tegra20_vi_write(vi_chan, TEGRA_VI_H_DOWNSCALE_CONTROL, 0); + + tegra20_vi_write(vi_chan, TEGRA_VI_VIP_V_ACTIVE, height << VI_VIP_V_ACTIVE_PERIOD_SFT); + tegra20_vi_write(vi_chan, TEGRA_VI_VIP_H_ACTIVE, + roundup(width, 2) << VI_VIP_H_ACTIVE_PERIOD_SFT); + + /* + * For VIP, D9..D2 is mapped to the video decoder's P7..P0. + * Disable/mask out the other Dn wires. When not in BT656 + * mode we also need the V/H sync. + */ + tegra20_vi_write(vi_chan, TEGRA_VI_PIN_INPUT_ENABLE, + GENMASK(9, 2) << VI_PIN_INPUT_VD_SFT | + VI_PIN_INPUT_HSYNC | VI_PIN_INPUT_VSYNC); + tegra20_vi_write(vi_chan, TEGRA_VI_VI_DATA_INPUT_CONTROL, + GENMASK(9, 2) << VI_DATA_INPUT_SFT); + tegra20_vi_write(vi_chan, TEGRA_VI_PIN_INVERSION, 0); + + tegra20_vi_write(vi_chan, TEGRA_VI_CONT_SYNCPT_OUT_1, + VI_CONT_SYNCPT_OUT_1_CONTINUOUS_SYNCPT | + host1x_syncpt_id(vi_chan->mw_ack_sp[0]) + << VI_CONT_SYNCPT_OUT_1_SYNCPT_IDX_SFT); + + tegra20_vi_write(vi_chan, TEGRA_VI_CAMERA_CONTROL, VI_CAMERA_CONTROL_STOP_CAPTURE); + + return 0; +} + +static const struct tegra_vip_ops tegra20_vip_ops = { + .vip_start_streaming = tegra20_vip_start_streaming, +}; + +const struct tegra_vip_soc tegra20_vip_soc = { + .ops = &tegra20_vip_ops, +}; diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index d1c6877163c2..eae7b1b30b07 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1862,6 +1862,9 @@ static int tegra_vi_remove(struct platform_device *pdev) } static const struct of_device_id tegra_vi_of_id_table[] = { +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-vi", .data = &tegra20_vi_soc }, +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC) { .compatible = "nvidia,tegra210-vi", .data = &tegra210_vi_soc }, #endif diff --git a/drivers/staging/media/tegra-video/vi.h b/drivers/staging/media/tegra-video/vi.h index 8fa817757059..c864d4ef81a5 100644 --- a/drivers/staging/media/tegra-video/vi.h +++ b/drivers/staging/media/tegra-video/vi.h @@ -292,6 +292,9 @@ struct tegra_video_format { u32 fourcc; }; +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) +extern const struct tegra_vi_soc tegra20_vi_soc; +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC) extern const struct tegra_vi_soc tegra210_vi_soc; #endif diff --git a/drivers/staging/media/tegra-video/video.c b/drivers/staging/media/tegra-video/video.c index d966b319553f..074ad0dc56ca 100644 --- a/drivers/staging/media/tegra-video/video.c +++ b/drivers/staging/media/tegra-video/video.c @@ -123,6 +123,10 @@ static int host1x_video_remove(struct host1x_device *dev) } static const struct of_device_id host1x_video_subdevs[] = { +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-vip", }, + { .compatible = "nvidia,tegra20-vi", }, +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC) { .compatible = "nvidia,tegra210-csi", }, { .compatible = "nvidia,tegra210-vi", }, @@ -141,6 +145,7 @@ static struct host1x_driver host1x_video_driver = { static struct platform_driver * const drivers[] = { &tegra_csi_driver, + &tegra_vip_driver, &tegra_vi_driver, }; diff --git a/drivers/staging/media/tegra-video/video.h b/drivers/staging/media/tegra-video/video.h index 1e9be1474a9c..7275affa6558 100644 --- a/drivers/staging/media/tegra-video/video.h +++ b/drivers/staging/media/tegra-video/video.h @@ -24,5 +24,6 @@ int tegra_v4l2_nodes_setup_tpg(struct tegra_video_device *vid); void tegra_v4l2_nodes_cleanup_tpg(struct tegra_video_device *vid); extern struct platform_driver tegra_vi_driver; +extern struct platform_driver tegra_vip_driver; extern struct platform_driver tegra_csi_driver; #endif diff --git a/drivers/staging/media/tegra-video/vip.c b/drivers/staging/media/tegra-video/vip.c new file mode 100644 index 000000000000..a282e4b1a48e --- /dev/null +++ b/drivers/staging/media/tegra-video/vip.c @@ -0,0 +1,290 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Parallel video capture module (VIP) for the Tegra VI. + * + * This file implements the VIP-specific infrastructure. + * + * Copyright (C) 2022 SKIDATA GmbH + * Author: Luca Ceresoli + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "vip.h" + +static inline struct tegra_vip *host1x_client_to_vip(struct host1x_client *client) +{ + return container_of(client, struct tegra_vip, client); +} + +static inline struct tegra_vip_channel *subdev_to_vip_channel(struct v4l2_subdev *subdev) +{ + return container_of(subdev, struct tegra_vip_channel, subdev); +} + +static inline struct tegra_vip *vip_channel_to_vip(struct tegra_vip_channel *chan) +{ + return container_of(chan, struct tegra_vip, chan); +} + +/* Find the previous subdev in the pipeline (i.e. the one connected to our sink pad) */ +static struct v4l2_subdev *tegra_vip_channel_get_prev_subdev(struct tegra_vip_channel *chan) +{ + struct media_pad *remote_pad; + + remote_pad = media_pad_remote_pad_first(&chan->pads[TEGRA_VIP_PAD_SINK]); + if (!remote_pad) + return NULL; + + return media_entity_to_v4l2_subdev(remote_pad->entity); +} + +static int tegra_vip_enable_stream(struct v4l2_subdev *subdev) +{ + struct tegra_vip_channel *vip_chan = subdev_to_vip_channel(subdev); + struct tegra_vip *vip = vip_channel_to_vip(vip_chan); + struct v4l2_subdev *prev_subdev = tegra_vip_channel_get_prev_subdev(vip_chan); + int err; + + err = pm_runtime_resume_and_get(vip->dev); + if (err) + return dev_err_probe(vip->dev, err, "failed to get runtime PM\n"); + + err = vip->soc->ops->vip_start_streaming(vip_chan); + if (err < 0) + goto err_start_streaming; + + err = v4l2_subdev_call(prev_subdev, video, s_stream, true); + if (err < 0 && err != -ENOIOCTLCMD) + goto err_prev_subdev_start_stream; + + return 0; + +err_prev_subdev_start_stream: +err_start_streaming: + pm_runtime_put(vip->dev); + return err; +} + +static int tegra_vip_disable_stream(struct v4l2_subdev *subdev) +{ + struct tegra_vip_channel *vip_chan = subdev_to_vip_channel(subdev); + struct tegra_vip *vip = vip_channel_to_vip(vip_chan); + struct v4l2_subdev *prev_subdev = tegra_vip_channel_get_prev_subdev(vip_chan); + + v4l2_subdev_call(prev_subdev, video, s_stream, false); + + pm_runtime_put(vip->dev); + + return 0; +} + +static int tegra_vip_s_stream(struct v4l2_subdev *subdev, int enable) +{ + int err; + + if (enable) + err = tegra_vip_enable_stream(subdev); + else + err = tegra_vip_disable_stream(subdev); + + return err; +} + +static const struct v4l2_subdev_video_ops tegra_vip_video_ops = { + .s_stream = tegra_vip_s_stream, +}; + +static const struct v4l2_subdev_ops tegra_vip_ops = { + .video = &tegra_vip_video_ops, +}; + +static int tegra_vip_channel_of_parse(struct tegra_vip *vip) +{ + struct device *dev = vip->dev; + struct device_node *np = dev->of_node; + struct v4l2_fwnode_endpoint v4l2_ep = { + .bus_type = V4L2_MBUS_PARALLEL + }; + struct fwnode_handle *fwh; + struct device_node *ep; + unsigned int num_pads; + int err; + + dev_dbg(dev, "Parsing %pOF", np); + + ep = of_graph_get_endpoint_by_regs(np, 0, 0); + if (!ep) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: error getting endpoint node\n", np); + goto err_node_put; + } + + fwh = of_fwnode_handle(ep); + err = v4l2_fwnode_endpoint_parse(fwh, &v4l2_ep); + of_node_put(ep); + if (err) { + dev_err_probe(dev, err, "%pOF: failed to parse v4l2 endpoint\n", np); + goto err_node_put; + } + + num_pads = of_graph_get_endpoint_count(np); + if (num_pads != TEGRA_VIP_PADS_NUM) { + err = -EINVAL; + dev_err_probe(dev, err, "%pOF: need 2 pads, got %d\n", np, num_pads); + goto err_node_put; + } + + vip->chan.of_node = of_node_get(np); + vip->chan.pads[TEGRA_VIP_PAD_SINK].flags = MEDIA_PAD_FL_SINK; + vip->chan.pads[TEGRA_VIP_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; + + return 0; + +err_node_put: + of_node_put(np); + return err; +} + +static int tegra_vip_channel_init(struct tegra_vip *vip) +{ + struct v4l2_subdev *subdev; + int err; + + subdev = &vip->chan.subdev; + v4l2_subdev_init(subdev, &tegra_vip_ops); + subdev->dev = vip->dev; + snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "%s", + kbasename(vip->chan.of_node->full_name)); + + v4l2_set_subdevdata(subdev, &vip->chan); + subdev->fwnode = of_fwnode_handle(vip->chan.of_node); + subdev->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; + + err = media_entity_pads_init(&subdev->entity, TEGRA_VIP_PADS_NUM, vip->chan.pads); + if (err) + return dev_err_probe(vip->dev, err, "failed to initialize media entity\n"); + + err = v4l2_async_register_subdev(subdev); + if (err) { + dev_err_probe(vip->dev, err, "failed to register subdev\n"); + goto err_register_subdev; + } + + return 0; + +err_register_subdev: + media_entity_cleanup(&subdev->entity); + return err; +} + +static int tegra_vip_init(struct host1x_client *client) +{ + struct tegra_vip *vip = host1x_client_to_vip(client); + int err; + + err = tegra_vip_channel_of_parse(vip); + if (err) + return err; + + err = tegra_vip_channel_init(vip); + if (err) + goto err_init; + + return 0; + +err_init: + of_node_put(vip->chan.of_node); + return err; +} + +static int tegra_vip_exit(struct host1x_client *client) +{ + struct tegra_vip *vip = host1x_client_to_vip(client); + struct v4l2_subdev *subdev = &vip->chan.subdev; + + v4l2_async_unregister_subdev(subdev); + media_entity_cleanup(&subdev->entity); + of_node_put(vip->chan.of_node); + + return 0; +} + +static const struct host1x_client_ops vip_client_ops = { + .init = tegra_vip_init, + .exit = tegra_vip_exit, +}; + +static int tegra_vip_probe(struct platform_device *pdev) +{ + struct tegra_vip *vip; + int err; + + dev_dbg(&pdev->dev, "Probing VIP \"%s\" from %pOF\n", pdev->name, pdev->dev.of_node); + + vip = devm_kzalloc(&pdev->dev, sizeof(*vip), GFP_KERNEL); + if (!vip) + return -ENOMEM; + + vip->soc = of_device_get_match_data(&pdev->dev); + + vip->dev = &pdev->dev; + platform_set_drvdata(pdev, vip); + + /* initialize host1x interface */ + INIT_LIST_HEAD(&vip->client.list); + vip->client.ops = &vip_client_ops; + vip->client.dev = &pdev->dev; + + err = host1x_client_register(&vip->client); + if (err) + return dev_err_probe(&pdev->dev, err, "failed to register host1x client\n"); + + pm_runtime_enable(&pdev->dev); + + return 0; +} + +static int tegra_vip_remove(struct platform_device *pdev) +{ + struct tegra_vip *vip = platform_get_drvdata(pdev); + int err; + + err = host1x_client_unregister(&vip->client); + if (err) + return dev_err_probe(&pdev->dev, err, "failed to unregister host1x client\n"); + + pm_runtime_disable(&pdev->dev); + + return 0; +} + +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) +extern const struct tegra_vip_soc tegra20_vip_soc; +#endif + +static const struct of_device_id tegra_vip_of_id_table[] = { +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) + { .compatible = "nvidia,tegra20-vip", .data = &tegra20_vip_soc }, +#endif + { } +}; +MODULE_DEVICE_TABLE(of, tegra_vip_of_id_table); + +struct platform_driver tegra_vip_driver = { + .driver = { + .name = "tegra-vip", + .of_match_table = tegra_vip_of_id_table, + }, + .probe = tegra_vip_probe, + .remove = tegra_vip_remove, +}; diff --git a/drivers/staging/media/tegra-video/vip.h b/drivers/staging/media/tegra-video/vip.h new file mode 100644 index 000000000000..e192ede83f1f --- /dev/null +++ b/drivers/staging/media/tegra-video/vip.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2022 SKIDATA GmbH + * Author: Luca Ceresoli + */ + +#ifndef __TEGRA_VIP_H__ +#define __TEGRA_VIP_H__ + +#include +#include +#include + +enum { + TEGRA_VIP_PAD_SINK, + TEGRA_VIP_PAD_SOURCE, + TEGRA_VIP_PADS_NUM, +}; + +struct tegra_vip; + +/** + * struct tegra_vip_channel - Tegra VIP (parallel video capture) channel + * + * @subdev: V4L2 subdevice associated with this channel + * @pads: media pads for the subdevice entity + * @of_node: vip device tree node + */ +struct tegra_vip_channel { + struct v4l2_subdev subdev; + struct media_pad pads[TEGRA_VIP_PADS_NUM]; + struct device_node *of_node; +}; + +/** + * struct tegra_vip_ops - Tegra VIP operations + * + * @vip_start_streaming: programs vip hardware to enable streaming. + */ +struct tegra_vip_ops { + int (*vip_start_streaming)(struct tegra_vip_channel *vip_chan); +}; + +/** + * struct tegra_vip_soc - NVIDIA Tegra VIP SoC structure + * + * @ops: vip hardware operations + */ +struct tegra_vip_soc { + const struct tegra_vip_ops *ops; +}; + +/** + * struct tegra_vip - NVIDIA Tegra VIP device structure + * + * @dev: device struct + * @client: host1x_client struct + * @soc: pointer to SoC data structure + * @chan: the VIP channel + */ +struct tegra_vip { + struct device *dev; + struct host1x_client client; + const struct tegra_vip_soc *soc; + struct tegra_vip_channel chan; +}; + +#endif