Add Tegra20 parallel video input capture
Subsystems (7)
Luca Ceresoli
maintainerv2 cover Add Tegra20 parallel video input capture
Tegra20 and other Tegra SoCs have a video input (VI) peripheral that can receive from either MIPI CSI-2 or parallel video (called respectively "CSI" and "VIP" in the documentation). The kernel currently has a staging driver for Tegra210 CSI capture. This patch set adds support for Tegra20 VIP capture.
Unfortunately I had no real documentation available to base this work on. I only had a working downstream 3.1 kernel, so I started with the driver found there and heavily reworked it to fit into the mainline tegra-video driver structure. The existing code appears written with the intent of being modular and allow adding new input mechanisms and new SoCs while keeping a unique VI core module. However its modularity and extensibility was not enough to add Tegra20 VIP support, so I added some hooks to turn hard-coded behaviour into per-SoC or per-bus customizable code. There are also a fix, some generic cleanups and DT bindings.
Quick tour of the patches:
* Device tree bindings and minor DTS improvements
01. dt-bindings: display: tegra: add Tegra20 VIP
02. dt-bindings: display: tegra: vi: add 'vip' property and example
* A fix
03. staging: media: tegra-video: fix .vidioc_enum_fmt_vid_cap to return all formats
* Minor improvements to logging, comments, cleanups
04. staging: media: tegra-video: improve documentation of tegra_video_format fields
05. staging: media: tegra-video: document tegra_channel_get_remote_source_subdev
06. staging: media: tegra-video: fix typos in comment
07. staging: media: tegra-video: improve error messages
08. staging: media: tegra-video: slightly simplify cleanup on errors
09. staging: media: tegra-video: move private struct declaration to C file
10. staging: media: tegra-video: remove unneeded include
* Preparation to make the VI module generic enough to host Tegra20 and VIP
11. staging: media: tegra-video: Kconfig: allow TPG only on Tegra210
12. staging: media: tegra-video: move tegra_channel_fmt_align to a per-soc op
13. staging: media: tegra-video: move default format to soc-specific data
14. staging: media: tegra-video: move MIPI calibration calls from VI to CSI
15. staging: media: tegra-video: add a per-soc enable/disable op
16. staging: media: tegra-video: move syncpt init/free to a per-soc op
17. staging: media: tegra-video: add syncpts for Tegra20 to struct tegra_vi
18. staging: media: tegra-video: add hooks for planar YUV and H/V flip
19. staging: media: tegra-video: add H/V flip controls
* Implementation of VIP and Tegra20
20. staging: media: tegra-video: add support for VIP (parallel video input)
21. staging: media: tegra-video: add tegra20 variant
Enjoy!
Changed in v2:
- improved dt-bindings patches based on reviews
- removed patches 3 and 4 adding DT labels without a mainline user
- two small fixes to the last patch
[v1] https://lore.kernel.org/linux-tegra/20221124155634.5bc2a423@booty/T/#t
Luca
Luca Ceresoli (21):
dt-bindings: display: tegra: add Tegra20 VIP
dt-bindings: display: tegra: vi: add 'vip' property and example
staging: media: tegra-video: fix .vidioc_enum_fmt_vid_cap to return
all formats
staging: media: tegra-video: improve documentation of
tegra_video_format fields
staging: media: tegra-video: document
tegra_channel_get_remote_source_subdev
staging: media: tegra-video: fix typos in comment
staging: media: tegra-video: improve error messages
staging: media: tegra-video: slightly simplify cleanup on errors
staging: media: tegra-video: move private struct declaration to C file
staging: media: tegra-video: remove unneeded include
staging: media: tegra-video: Kconfig: allow TPG only on Tegra210
staging: media: tegra-video: move tegra_channel_fmt_align to a per-soc
op
staging: media: tegra-video: move default format to soc-specific data
staging: media: tegra-video: move MIPI calibration calls from VI to
CSI
staging: media: tegra-video: add a per-soc enable/disable op
staging: media: tegra-video: move syncpt init/free to a per-soc op
staging: media: tegra-video: add syncpts for Tegra20 to struct
tegra_vi
staging: media: tegra-video: add hooks for planar YUV and H/V flip
staging: media: tegra-video: add H/V flip controls
staging: media: tegra-video: add support for VIP (parallel video
input)
staging: media: tegra-video: add tegra20 variant
.../display/tegra/nvidia,tegra20-vi.yaml | 68 ++ .../display/tegra/nvidia,tegra20-vip.yaml | 63 ++ MAINTAINERS | 10 + drivers/staging/media/tegra-video/Kconfig | 1 + drivers/staging/media/tegra-video/Makefile | 2 + drivers/staging/media/tegra-video/csi.c | 44 ++ drivers/staging/media/tegra-video/tegra20.c | 661 ++++++++++++++++++ drivers/staging/media/tegra-video/tegra210.c | 97 ++- drivers/staging/media/tegra-video/vi.c | 321 ++------- drivers/staging/media/tegra-video/vi.h | 76 +- drivers/staging/media/tegra-video/video.c | 5 + drivers/staging/media/tegra-video/video.h | 2 +- drivers/staging/media/tegra-video/vip.c | 298 ++++++++ drivers/staging/media/tegra-video/vip.h | 72 ++ 14 files changed, 1434 insertions(+), 286 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml 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
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 1/21 dt-bindings: display: tegra: add Tegra20 VIP
VIP is the parallel video capture component within the video input subsystem of Tegra20 (and other Tegra chips, apparently).
---
Changed in v2 (suggested by Krzysztof Kozlowski):
- remove redundant "bindings" from subject line
- remove $nodename
- add channel@0 description
- add reg: const: 0
--- .../display/tegra/nvidia,tegra20-vip.yaml | 63 +++++++++++++++++++ MAINTAINERS | 7 +++ 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/tegra/nvidia,tegra20-vip.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra VIP (parallel video capture) controller + +maintainers: + - Luca Ceresoli <[email protected]> + +properties: + compatible: + enum: + - nvidia,tegra20-vip + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + channel@0: + description: parallel video capture interface for the VI + type: object + + properties: + reg: + const: 0 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Port receiving the video stream from the sensor + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: + Port sending the video stream to the VI + + required: + - port@0 + - port@1 + + additionalProperties: false + + required: + - reg + - ports + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + - channel@0 + +# see nvidia,tegra20-vi.yaml for an example
MAINTAINERS +7 -0
@@ -20315,6 +20315,13 @@ S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml F: drivers/staging/media/tegra-video/ +TEGRA VIDEO DRIVER FOR TEGRA20 VIP (PARALLEL VIDEO CAPTURE) +M: Luca Ceresoli <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml + TEGRA XUSB PADCTL DRIVER M: JC Kuo <[email protected]> S: Supported
Signature · 1 line
2.34.1
Rob Herring
maintainerRe: [PATCH v2 01/21] dt-bindings: display: tegra: add Tegra20 VIP
Quoted 37 lines · Luca Ceresoli
VIP is the parallel video capture component within the video input subsystem of Tegra20 (and other Tegra chips, apparently).
Signed-off-by Luca Ceresoli <[email protected]>---
Changed in v2 (suggested by Krzysztof Kozlowski):
- remove redundant "bindings" from subject line
- remove $nodename
- add channel@0 description
- add reg: const: 0--- .../display/tegra/nvidia,tegra20-vip.yaml | 63 +++++++++++++++++++ MAINTAINERS | 7 +++ 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yamlDocumentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +13
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/tegra/nvidia,tegra20-vip.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra VIP (parallel video capture) controller + +maintainers: + - Luca Ceresoli <[email protected]> + +properties: + compatible:
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +10
-0+ enum: + - nvidia,tegra20-vip + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + channel@0:
Kind of odd there is only 1 channel with a unit-address. Are more channels coming? Please make the binding as complete as possible even if no driver support yet.
Quoted 16 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +16
-0+ description: parallel video capture interface for the VI + type: object + + properties: + reg: + const: 0 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Port receiving the video stream from the sensor +
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml line 49
Quoted 10 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +10
-0+ port@1: + $ref: /schemas/graph.yaml#/properties/port + description: + Port sending the video stream to the VI + + required: + - port@0 + - port@1 + + additionalProperties: false
A bit easier to read the indented cases if this is above 'properties'.
Quoted 36 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +14
-0+ + required: + - reg + - ports + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + - channel@0 + +# see nvidia,tegra20-vi.yaml for an exampleMAINTAINERS +7
-0@@ -20315,6 +20315,13 @@ S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml F: drivers/staging/media/tegra-video/ +TEGRA VIDEO DRIVER FOR TEGRA20 VIP (PARALLEL VIDEO CAPTURE) +M: Luca Ceresoli <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml + TEGRA XUSB PADCTL DRIVER M: JC Kuo <[email protected]> S: SupportedSignature · 1 line
2.34.1
Luca Ceresoli
maintainerRe: [PATCH v2 01/21] dt-bindings: display: tegra: add Tegra20 VIP
Hello Rob,
Thanks for your review.
Quoted 44 lines · On Thu, 1 Dec 2022 17:19:36 -0600 Rob Herring <[email protected]> wrote:
Quoted 43 lines · Luca Ceresoli
VIP is the parallel video capture component within the video input subsystem of Tegra20 (and other Tegra chips, apparently).
Signed-off-by Luca Ceresoli <[email protected]>---
Changed in v2 (suggested by Krzysztof Kozlowski):
- remove redundant "bindings" from subject line
- remove $nodename
- add channel@0 description
- add reg: const: 0--- .../display/tegra/nvidia,tegra20-vip.yaml | 63 +++++++++++++++++++ MAINTAINERS | 7 +++ 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yamlDocumentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +19
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/tegra/nvidia,tegra20-vip.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra VIP (parallel video capture) controller + +maintainers: + - Luca Ceresoli <[email protected]> + +properties: + compatible: + enum: + - nvidia,tegra20-vip + + "#address-cells": + const: 1 +
Quoted 8 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml line 23
Quoted 4 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +4
-0+ "#size-cells": + const: 0 + + channel@0:Kind of odd there is only 1 channel with a unit-address. Are more channels coming? Please make the binding as complete as possible even if no driver support yet.
This was discussed in v1 with Krzysztof and the outcome was that it's OK because it's likely that other SoCs have more, but the documentation is not public so I cannot add examples.
Full discussion (pretty short indeed):
https://lore.kernel.org/linux-devicetree/[email protected]/
Do you agree that the unit-address should be kept?
Quoted 20 lines
Quoted 20 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +20
-0+ description: parallel video capture interface for the VI + type: object + + properties: + reg: + const: 0 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Port receiving the video stream from the sensor + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: + Port sending the video stream to the VI
Quoted 8 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml line 49
Quoted 6 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +6
-0+ + required: + - port@0 + - port@1 + + additionalProperties: falseA bit easier to read the indented cases if this is above 'properties'.
Sure, will do in v3.
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v2 01/21] dt-bindings: display: tegra: add Tegra20 VIP
02.12.2022 11:11, Luca Ceresoli пишет:
Quoted 62 lines
Hello Rob,
Thanks for your review.
Quoted 43 lines · On Thu, 1 Dec 2022 17:19:36 -0600 Rob Herring <[email protected]> wrote:
Quoted 42 lines · Luca Ceresoli
VIP is the parallel video capture component within the video input subsystem of Tegra20 (and other Tegra chips, apparently).
Signed-off-by Luca Ceresoli <[email protected]>---
Changed in v2 (suggested by Krzysztof Kozlowski):
- remove redundant "bindings" from subject line
- remove $nodename
- add channel@0 description
- add reg: const: 0--- .../display/tegra/nvidia,tegra20-vip.yaml | 63 +++++++++++++++++++ MAINTAINERS | 7 +++ 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yamlDocumentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +18
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/tegra/nvidia,tegra20-vip.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra VIP (parallel video capture) controller + +maintainers: + - Luca Ceresoli <[email protected]> + +properties: + compatible: + enum: + - nvidia,tegra20-vip + + "#address-cells": + const: 1Quoted 8 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml line 23
Quoted 5 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +5
-0+ + "#size-cells": + const: 0 + + channel@0:Kind of odd there is only 1 channel with a unit-address. Are more channels coming? Please make the binding as complete as possible even if no driver support yet.
This was discussed in v1 with Krzysztof and the outcome was that it's OK because it's likely that other SoCs have more, but the documentation is not public so I cannot add examples.
Quoted 5 lines
Full discussion (pretty short indeed):
https://lore.kernel.org/linux-devicetree/[email protected]/
Do you agree that the unit-address should be kept?
It's doubtful that there is a SoC having a VIP with multiple channels. I'd expect it to be multiple VIPs rather than channels. There are NVIDIA people to confirm that.
The "channel" itself looks redundant to me, i.e. the reg and ports should be moved to the vip node.
Luca Ceresoli
maintainerRe: [PATCH v2 01/21] dt-bindings: display: tegra: add Tegra20 VIP
Hello Dmitry,
Quoted 1 line · On Tue, 20 Dec 2022 23:13:05 +0300 Dmitry Osipenko <[email protected]> wrote:
02.12.2022 11:11, Luca Ceresoli пишет:
...
Quoted 37 lines
Quoted 37 lines
Quoted 21 lines
Quoted 21 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +18
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/tegra/nvidia,tegra20-vip.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra VIP (parallel video capture) controller + +maintainers: + - Luca Ceresoli <[email protected]> + +properties: + compatible: + enum: + - nvidia,tegra20-vip + + "#address-cells": + const: 1Quoted 8 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml line 23
Quoted 5 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml new file +5
-0+ + "#size-cells": + const: 0 + + channel@0:Kind of odd there is only 1 channel with a unit-address. Are more channels coming? Please make the binding as complete as possible even if no driver support yet.
This was discussed in v1 with Krzysztof and the outcome was that it's OK because it's likely that other SoCs have more, but the documentation is not public so I cannot add examples.
Full discussion (pretty short indeed):
Quoted 8 lines
Quoted 1 line
Do you agree that the unit-address should be kept?
It's doubtful that there is a SoC having a VIP with multiple channels. I'd expect it to be multiple VIPs rather than channels. There are NVIDIA people to confirm that.
The "channel" itself looks redundant to me, i.e. the reg and ports should be moved to the vip node.
OK, will do in v3 unless there are different opinions.
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Luca Ceresoli
maintainerPATCH v2 2/21 dt-bindings: display: tegra: vi: add 'vip' property and example
In reply to Luca CeresoliThe 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.
---
Changed in v2 (suggested by Krzysztof Kozlowski):
- rename "i2c3" -> "ic2"
- add review tag
--- .../display/tegra/nvidia,tegra20-vi.yaml | 68 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 69 insertions(+)
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +68 -0
@@ -74,6 +74,22 @@ properties: avdd-dsi-csi-supply: description: DSI/CSI power supply. Must supply 1.2 V. + vip: + $ref: /schemas/display/tegra/nvidia,tegra20-vip.yaml + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Input from the VIP (parallel input capture) module + + properties: + endpoint: + $ref: /schemas/graph.yaml#/properties/endpoint + patternProperties: "^csi@[0-9a-f]+$": type: object
@@ -109,6 +125,22 @@ examples: #include <dt-bindings/clock/tegra20-car.h> #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + camera@48 { + compatible = "aptina,mt9v111"; + reg = <0x48>; + clocks = <&camera_clk>; + + port { + mt9v111_out: endpoint { + remote-endpoint = <&vi_vip_in>; + }; + }; + }; + }; + vi@54080000 { compatible = "nvidia,tegra20-vi"; reg = <0x54080000 0x00040000>;
@@ -116,6 +148,42 @@ examples: clocks = <&tegra_car TEGRA20_CLK_VI>; resets = <&tegra_car 100>; reset-names = "vi"; + + vip { + compatible = "nvidia,tegra20-vip"; + #address-cells = <1>; + #size-cells = <0>; + channel@0 { + reg = <0>; + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + vi_vip_in: endpoint { + remote-endpoint = <&mt9v111_out>; + }; + }; + port@1 { + reg = <1>; + vi_vip_out: endpoint { + remote-endpoint = <&vi_in>; + }; + }; + }; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + vi_in: endpoint { + remote-endpoint = <&vi_vip_out>; + }; + }; + }; }; - |
MAINTAINERS +1 -0
@@ -20320,6 +20320,7 @@ M: Luca Ceresoli <[email protected]> L: [email protected] L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml TEGRA XUSB PADCTL DRIVER
Signature · 1 line
2.34.1
Rob Herring
maintainerRe: [PATCH v2 02/21] dt-bindings: display: tegra: vi: add 'vip' property and example
Quoted 30 lines · Luca Ceresoli
The Tegra20 VI peripheral can receive parallel input from the VIP parallel input module. Add it to the allowed properties and augment the existing nvidia,tegra20-vi example to show a 'vip' property.
Reviewed-by Krzysztof Kozlowski <[email protected]>Signed-off-by Luca Ceresoli <[email protected]>---
Changed in v2 (suggested by Krzysztof Kozlowski):
- rename "i2c3" -> "ic2"
- add review tag--- .../display/tegra/nvidia,tegra20-vi.yaml | 68 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 69 insertions(+)Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +5
-0@@ -74,6 +74,22 @@ properties: avdd-dsi-csi-supply: description: DSI/CSI power supply. Must supply 1.2 V. + vip: + $ref: /schemas/display/tegra/nvidia,tegra20-vip.yaml + + ports: + $ref: /schemas/graph.yaml#/properties/ports
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml properties: · line 91
Quoted 10 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +10
-0+ + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Input from the VIP (parallel input capture) module + + properties: + endpoint: + $ref: /schemas/graph.yaml#/properties/endpoint
You can drop 'endpoint'. You only need port nodes if there's no extra properties in the endpoints.
Quoted 86 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +53
-0+ patternProperties: "^csi@[0-9a-f]+$": type: object@@ -109,6 +125,22 @@ examples: #include <dt-bindings/clock/tegra20-car.h> #include <dt-bindings/interrupt-controller/arm-gic.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + camera@48 { + compatible = "aptina,mt9v111"; + reg = <0x48>; + clocks = <&camera_clk>; + + port { + mt9v111_out: endpoint { + remote-endpoint = <&vi_vip_in>; + }; + }; + }; + }; + vi@54080000 { compatible = "nvidia,tegra20-vi"; reg = <0x54080000 0x00040000>;@@ -116,6 +148,42 @@ examples: clocks = <&tegra_car TEGRA20_CLK_VI>; resets = <&tegra_car 100>; reset-names = "vi"; + + vip { + compatible = "nvidia,tegra20-vip"; + #address-cells = <1>; + #size-cells = <0>; + channel@0 { + reg = <0>; + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + vi_vip_in: endpoint { + remote-endpoint = <&mt9v111_out>; + }; + }; + port@1 { + reg = <1>; + vi_vip_out: endpoint { + remote-endpoint = <&vi_in>; + }; + }; + }; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + vi_in: endpoint { + remote-endpoint = <&vi_vip_out>; + }; + }; + }; }; - |MAINTAINERS +1
-0@@ -20320,6 +20320,7 @@ M: Luca Ceresoli <[email protected]> L: [email protected] L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml TEGRA XUSB PADCTL DRIVERSignature · 1 line
2.34.1
Luca Ceresoli
maintainerRe: [PATCH v2 02/21] dt-bindings: display: tegra: vi: add 'vip' property and example
Hello Rob,
Quoted 36 lines · On Thu, 1 Dec 2022 17:16:36 -0600 Rob Herring <[email protected]> wrote:
Quoted 35 lines · Luca Ceresoli
The Tegra20 VI peripheral can receive parallel input from the VIP parallel input module. Add it to the allowed properties and augment the existing nvidia,tegra20-vi example to show a 'vip' property.
Reviewed-by Krzysztof Kozlowski <[email protected]>Signed-off-by Luca Ceresoli <[email protected]>---
Changed in v2 (suggested by Krzysztof Kozlowski):
- rename "i2c3" -> "ic2"
- add review tag--- .../display/tegra/nvidia,tegra20-vi.yaml | 68 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 69 insertions(+)Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +10
-0@@ -74,6 +74,22 @@ properties: avdd-dsi-csi-supply: description: DSI/CSI power supply. Must supply 1.2 V. + vip: + $ref: /schemas/display/tegra/nvidia,tegra20-vip.yaml + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description:
Quoted 8 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml properties: · line 91
Quoted 5 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +5
-0+ Input from the VIP (parallel input capture) module + + properties: + endpoint: + $ref: /schemas/graph.yaml#/properties/endpointYou can drop 'endpoint'. You only need port nodes if there's no extra properties in the endpoints.
Oh, nice, will remove in v3.
Krzysztof, can I keep your Reviewed-by after this change?
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v2 02/21] dt-bindings: display: tegra: vi: add 'vip' property and example
Quoted 50 lines · Luca Ceresoli
Hello Rob,
Quoted 36 lines · On Thu, 1 Dec 2022 17:16:36 -0600 Rob Herring <[email protected]> wrote:
Quoted 35 lines · Luca Ceresoli
The Tegra20 VI peripheral can receive parallel input from the VIP parallel input module. Add it to the allowed properties and augment the existing nvidia,tegra20-vi example to show a 'vip' property.
Reviewed-by Krzysztof Kozlowski <[email protected]>Signed-off-by Luca Ceresoli <[email protected]>---
Changed in v2 (suggested by Krzysztof Kozlowski):
- rename "i2c3" -> "ic2"
- add review tag--- .../display/tegra/nvidia,tegra20-vi.yaml | 68 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 69 insertions(+)Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +10
-0@@ -74,6 +74,22 @@ properties: avdd-dsi-csi-supply: description: DSI/CSI power supply. Must supply 1.2 V. + vip: + $ref: /schemas/display/tegra/nvidia,tegra20-vip.yaml + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description:Quoted 8 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml properties: · line 91
Quoted 5 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml +5
-0+ Input from the VIP (parallel input capture) module + + properties: + endpoint: + $ref: /schemas/graph.yaml#/properties/endpointYou can drop 'endpoint'. You only need port nodes if there's no extra properties in the endpoints.
Quoted 3 lines
Oh, nice, will remove in v3.
Krzysztof, can I keep your Reviewed-by after this change?
Yes.
Best regards,
Krzysztof
Luca Ceresoli
maintainerPATCH v2 3/21 staging: media: tegra-video: fix .vidioc_enum_fmt_vid_cap to return all formats
In reply to Luca CeresoliThe .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.
---
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(-)
drivers/staging/media/tegra-video/tegra210.c +6 -1
@@ -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 */
drivers/staging/media/tegra-video/vi.c +3 -100
142 lines not on this page · raw message
drivers/staging/media/tegra-video/vi.h +0 -4
@@ -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;
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 4/21 staging: media: tegra-video: improve documentation of tegra_video_format fields
In reply to Luca CeresoliSome fields are irrelevant for Tegra20/VIP. Add a note to clarify that.
---
No changes in v2
--- drivers/staging/media/tegra-video/vi.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/tegra-video/vi.h +3 -3
@@ -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 {
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 5/21 staging: media: tegra-video: document tegra_channel_get_remote_source_subdev
In reply to Luca CeresoliClarify what this function does.
---
No changes in v2
--- drivers/staging/media/tegra-video/vi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/staging/media/tegra-video/vi.c +3 -0
@@ -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) {
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 6/21 staging: media: tegra-video: fix typos in comment
In reply to Luca CeresoliAdd "skip" in "so we can *skip* the current channel" or it doesn't make sense.
Also add articles where appropriate to fix English grammar.
---
No changes in v2
--- drivers/staging/media/tegra-video/vi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/tegra-video/vi.c +3 -3
@@ -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;
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 7/21 staging: media: tegra-video: improve error messages
In reply to Luca Ceresolitegra_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.
---
No changes in v2
--- drivers/staging/media/tegra-video/vi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/media/tegra-video/vi.c +2 -5
@@ -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 )
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 8/21 staging: media: tegra-video: slightly simplify cleanup on errors
In reply to Luca Ceresoliof_node_put(node) does nothing if node == NULL, so it can be moved to the cleanup section at the bottom.
---
No changes in v2
--- drivers/staging/media/tegra-video/vi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/media/tegra-video/vi.c +3 -5
@@ -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; }
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 9/21 staging: media: tegra-video: move private struct declaration to C file
In reply to Luca Ceresolistruct tegra_vi_graph_entity is an internal implementation detail of the VI module. Move its declaration from vi.h to vi.c.
---
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(-)
drivers/staging/media/tegra-video/vi.c +13 -0
@@ -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 ,
drivers/staging/media/tegra-video/vi.h +0 -13
@@ -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 *
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 10/21 staging: media: tegra-video: remove unneeded include
In reply to Luca CeresoliThere is only a pointer reference to struct tegra_vi in video.h, thus vi.h is not needed.
---
No changes in v2
--- drivers/staging/media/tegra-video/video.h | 1 - 1 file changed, 1 deletion(-)
drivers/staging/media/tegra-video/video.h +0 -1
@@ -12,7 +12,6 @@#include <media/v4l2-device.h> #include "vi.h" -#include "csi.h" struct tegra_video_device {struct v4l2_device v4l2_dev;
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 11/21 staging: media: tegra-video: Kconfig: allow TPG only on Tegra210
In reply to Luca CeresoliWe 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.
---
No changes in v2
--- drivers/staging/media/tegra-video/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/staging/media/tegra-video/Kconfig +1 -0
@@ -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
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 12/21 staging: media: tegra-video: move tegra_channel_fmt_align to a per-soc op
In reply to Luca Ceresolitegra_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.
---
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(-)
drivers/staging/media/tegra-video/tegra210.c +36 -0
@@ -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, };
drivers/staging/media/tegra-video/vi.c +5 -35
@@ -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)
drivers/staging/media/tegra-video/vi.h +3 -6
@@ -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 64enum 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); };
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 13/21 staging: media: tegra-video: move default format to soc-specific data
In reply to Luca CeresoliThe 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.
---
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(-)
drivers/staging/media/tegra-video/tegra210.c +2 -0
@@ -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 };
drivers/staging/media/tegra-video/vi.c +1 -10
@@ -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 ;
drivers/staging/media/tegra-video/vi.h +2 -0
@@ -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;
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 14/21 staging: media: tegra-video: move MIPI calibration calls from VI to CSI
In reply to Luca CeresoliThe 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.
---
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(-)
drivers/staging/media/tegra-video/csi.c +44 -0
@@ -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) {
drivers/staging/media/tegra-video/vi.c +4 -50
71 lines not on this page · raw message
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 15/21 staging: media: tegra-video: add a per-soc enable/disable op
In reply to Luca CeresoliThe Tegra20 VI needs an additional operation to enable the VI, add an operation for that.
---
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(+)
drivers/staging/media/tegra-video/vi.c +7 -0
@@ -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 ;
drivers/staging/media/tegra-video/vi.h +4 -0
@@ -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);
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 16/21 staging: media: tegra-video: move syncpt init/free to a per-soc op
In reply to Luca Ceresolitegra_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.
---
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(-)
drivers/staging/media/tegra-video/tegra210.c +52 -0
@@ -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,
drivers/staging/media/tegra-video/vi.c +3 -49
80 lines not on this page · raw message
drivers/staging/media/tegra-video/vi.h +5 -0
@@ -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);
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 17/21 staging: media: tegra-video: add syncpts for Tegra20 to struct tegra_vi
In reply to Luca CeresoliIn preparation to implement Tegra20 parallel video capture, add variables to hold the required syncpt.
---
No changes in v2
--- drivers/staging/media/tegra-video/vi.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/media/tegra-video/vi.h +6 -2
@@ -117,11 +117,13 @@ struct tegra_vi {* @vi: Tegra video input device structure * @frame_start_sp: host1x syncpoint pointer to synchronize programmed capture * start condition with hardware frame start events through host1x -* syncpoint counters. +* syncpoint counters. (Tegra210) * @mw_ack_sp: host1x syncpoint pointer to synchronize programmed memory write * ack trigger condition with hardware memory write done at end of -* frame through host1x syncpoint counters. +* frame through host1x syncpoint counters. (Tegra210) * @sp_incr_lock: protects cpu syncpoint increment. +* @out_sp: host1x syncpoint pointer for frame sync (Tegra20) +* @next_out_sp_idx: next expected value for @out_sp (Tegra20) * * @kthread_start_capture: kthread to start capture of single frame when * vb buffer is available. This thread programs VI CSI hardware
@@ -173,6 +175,8 @@ struct tegra_vi_channel {struct host1x_syncpt *mw_ack_sp[GANG_PORTS_MAX ];/* protects the cpu syncpoint increment */ spinlock_t sp_incr_lock[GANG_PORTS_MAX ]; +struct host1x_syncpt *out_sp; +u32 next_out_sp_idx;struct task_struct *kthread_start_capture;wait_queue_head_t start_wait;
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 18/21 staging: media: tegra-video: add hooks for planar YUV and H/V flip
In reply to Luca CeresoliTegra20 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
---
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(+)
drivers/staging/media/tegra-video/vi.c +4 -0
@@ -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 ; }
drivers/staging/media/tegra-video/vi.h +14 -0
@@ -47,6 +47,7 @@ struct tegra_vi_channel;* @channel_host1x_syncpt_free: free all synchronization points * @vi_fmt_align: modify `pix` to fit the hardware alignment * requirements and fill image geometry +* @channel_queue_setup: additional operations at the end of vb2_ops::queue_setup * @vi_start_streaming: starts media pipeline, subdevice streaming, sets up * VI for capture and runs capture start and capture finish * kthreads for capturing frames to buffer and returns them back.
@@ -58,6 +59,7 @@ struct tegra_vi_ops {int (*channel_host1x_syncpt_init)(struct tegra_vi_channel *chan);void (*channel_host1x_syncpt_free)(struct tegra_vi_channel *chan);void (*vi_fmt_align)(struct v4l2_pix_format *pix,unsigned int bpp); +void (*channel_queue_setup)(struct tegra_vi_channel *chan);int (*vi_start_streaming)(struct vb2_queue *vq,u32 count);void (*vi_stop_streaming)(struct vb2_queue *vq); };
@@ -148,6 +150,12 @@ struct tegra_vi {* @queue: vb2 buffers queue * @sequence: V4L2 buffers sequence number * +* @addr_offset_u: U plane base address, relative to buffer base address (only for planar) +* @addr_offset_v: V plane base address, relative to buffer base address (only for planar) +* @start_offset: 1st Y byte to write, relative to buffer base address (for H/V flip) +* @start_offset_u: 1st U byte to write, relative to buffer base address (for H/V flip) +* @start_offset_v: 1st V byte to write, relative to buffer base address (for H/V flip) +* * @capture: list of queued buffers for capture * @start_lock: protects the capture queued list * @done: list of capture done queued buffers
@@ -188,6 +196,12 @@ struct tegra_vi_channel {struct vb2_queue queue;u32 sequence; +unsigned int addr_offset_u; +unsigned int addr_offset_v; +unsigned int start_offset; +unsigned int start_offset_u; +unsigned int start_offset_v; +struct list_head capture;/* protects the capture queued list */ spinlock_t start_lock;
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 19/21 staging: media: tegra-video: add H/V flip controls
In reply to Luca CeresoliTegra20 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.
---
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(-)
drivers/staging/media/tegra-video/vi.c +13 -1
@@ -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 */
drivers/staging/media/tegra-video/vi.h +8 -0
@@ -74,6 +74,7 @@ struct tegra_vi_ops {* @hw_revision: VI hw_revision * @vi_max_channels: supported max streaming channels * @vi_max_clk_hz: VI clock max frequency +* @has_h_v_flip: the chip can do H adn V flip, and the driver implements it */ struct tegra_vi_soc {const struct tegra_video_format *video_formats;
@@ -83,6 +84,7 @@ struct tegra_vi_soc {u32 hw_revision;unsigned int vi_max_channels;unsigned int vi_max_clk_hz; + bool has_h_v_flip:1; };/**
@@ -170,6 +172,9 @@ struct tegra_vi {* @syncpt_timeout_retry: syncpt timeout retry count for the capture * @pg_mode: test pattern generator mode (disabled/direct/patch) * @notifier: V4L2 asynchronous subdevs notifier +* +* @hflip: Horizontal flip is enabled +* @vflip: Vertical flip is enabled */ struct tegra_vi_channel {struct list_head list;
@@ -219,6 +224,9 @@ struct tegra_vi_channel {enum tegra_vi_pg_mode pg_mode;struct v4l2_async_notifier notifier; + + bool hflip:1; + bool vflip:1; };/**
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 20/21 staging: media: tegra-video: add support for VIP (parallel video input)
In reply to Luca CeresoliThe VI peripheral of Tegra supports capturing from MIPI CSI-2 or parallel video (called VIP in the docs). MIPI CSI-2 is already implemented. Add a VIP implementation.
---
No changes in v2
--- MAINTAINERS | 1 + drivers/staging/media/tegra-video/Makefile | 1 + drivers/staging/media/tegra-video/vip.c | 298 +++++++++++++++++++++ drivers/staging/media/tegra-video/vip.h | 72 +++++ 4 files changed, 372 insertions(+) create mode 100644 drivers/staging/media/tegra-video/vip.c create mode 100644 drivers/staging/media/tegra-video/vip.h
MAINTAINERS +1 -0
@@ -20322,6 +20322,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml +F: drivers/staging/media/tegra-video/vip.* TEGRA XUSB PADCTL DRIVER M: JC Kuo <[email protected]>
drivers/staging/media/tegra-video/Makefile +1 -0
@@ -2,6 +2,7 @@ tegra-video-objs := \ video.o \ vi.o \ + vip.o \ csi.o tegra-video-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o
drivers/staging/media/tegra-video/vip.c new file +298 -0
298 lines not on this page · raw message
drivers/staging/media/tegra-video/vip.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.34.1
Luca Ceresoli
maintainerPATCH v2 21/21 staging: media: tegra-video: add tegra20 variant
In reply to Luca CeresoliThe staging tegra-video driver currently implements MIPI CSI-2 video capture for Tegra210. Add support for parallel video capture (VIP) on Tegra20. With the generalizations added to the VI driver in previous commits, this is only a matter of adding the tegra20.c implementation and registering it.
Unfortunately there was no documentation available for the VI or VIP peripherals of Tegra20 (or any other Tegra chips). This implementation has been based entirely on the code from a vendor kernel based on Linux 3.1 and massively adapted to fit into the tegra-video driver. Parts of this code is definitely non-optimal to say the least (especially tegra20_vi_enable() and the single-frame capture logic), but it was impossible to improve it.
---
Changed in v2:
- fix tegra20_vi_enable() to clear bit when on==false
- clamp width/height from set/try_fmt to avoid returning sizeimage=0 (fixes v4l2-compliance)
--- MAINTAINERS | 1 + drivers/staging/media/tegra-video/Makefile | 1 + drivers/staging/media/tegra-video/tegra20.c | 661 ++++++++++++++++++++ drivers/staging/media/tegra-video/vi.c | 3 + drivers/staging/media/tegra-video/vi.h | 3 + drivers/staging/media/tegra-video/video.c | 5 + drivers/staging/media/tegra-video/video.h | 1 + 7 files changed, 675 insertions(+) create mode 100644 drivers/staging/media/tegra-video/tegra20.c
MAINTAINERS +1 -0
@@ -20322,6 +20322,7 @@ L: [email protected] S: Maintained F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vi.yaml F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-vip.yaml +F: drivers/staging/media/tegra-video/tegra20.c F: drivers/staging/media/tegra-video/vip.* TEGRA XUSB PADCTL DRIVER
drivers/staging/media/tegra-video/Makefile +1 -0
@@ -5,5 +5,6 @@ tegra-video-objs := \ vip.o \ csi.o +tegra-video-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra20.o tegra-video-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o obj-$(CONFIG_VIDEO_TEGRA) += tegra-video.o
drivers/staging/media/tegra-video/tegra20.c new file +661 -0
661 lines not on this page · raw message
drivers/staging/media/tegra-video/vi.c +3 -0
@@ -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
drivers/staging/media/tegra-video/vi.h +3 -0
@@ -293,6 +293,9 @@ struct tegra_video_format {u32 fourcc; }; +#if defined(CONFIG_ARCH_TEGRA_2x_SOC) +extern const struct tegra_vi_soc tegra20_vi_soc; +#endif #if defined(CONFIG_ARCH_TEGRA_210_SOC )extern const struct tegra_vi_soc tegra210_vi_soc;#endif
drivers/staging/media/tegra-video/video.c +5 -0
@@ -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, };
drivers/staging/media/tegra-video/video.h +1 -0
@@ -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
Signature · 1 line
2.34.1
Re: [PATCH v2 21/21] staging: media: tegra-video: add tegra20 variant
28.11.2022 18:23, Luca Ceresoli пишет:
Quoted 5 lines
drivers/staging/media/tegra-video/tegra20.c new file +5
-0+static int tegra20_channel_capture_frame (struct tegra_vi_channel *chan, +struct tegra_channel_buffer *buf) +{ +u32 value; +int err;
drivers/staging/media/tegra-video/tegra20.c line 394
Quoted 10 lines
drivers/staging/media/tegra-video/tegra20.c new file +10
-0+ + chan->next_out_sp_idx++; + +tegra20_channel_vi_buffer_setup (chan, buf); + +tegra20_vi_write (chan,TEGRA_VI_CAMERA_CONTROL ,VI_CAMERA_CONTROL_VIP_ENABLE ); + +/* Wait for syncpt counter to reach frame start event threshold */ + err =host1x_syncpt_wait (chan->out_sp, chan->next_out_sp_idx, +TEGRA_VI_SYNCPT_WAIT_TIMEOUT , &value);
You're not using the "value" variable, it should be NULL.
The "chan->out_sp" looks redundant, it duplicates the chan->mw_ack_sp. AFAICS from the doc, T20 has two VI channels, and thus, two mw_ack_sp, like T210.
Luca Ceresoli
maintainerRe: [PATCH v2 21/21] staging: media: tegra-video: add tegra20 variant
Hello Dmitry,
Quoted 10 lines · On Wed, 21 Dec 2022 00:40:20 +0300 Dmitry Osipenko <[email protected]> wrote:
28.11.2022 18:23, Luca Ceresoli пишет:
Quoted 9 lines
drivers/staging/media/tegra-video/tegra20.c new file +9
-0+static int tegra20_channel_capture_frame (struct tegra_vi_channel *chan, +struct tegra_channel_buffer *buf) +{ +u32 value; +int err; + + chan->next_out_sp_idx++; + +tegra20_channel_vi_buffer_setup (chan, buf);
Quoted 8 lines
drivers/staging/media/tegra-video/tegra20.c line 394
Quoted 6 lines
drivers/staging/media/tegra-video/tegra20.c new file +6
-0+ +tegra20_vi_write (chan,TEGRA_VI_CAMERA_CONTROL ,VI_CAMERA_CONTROL_VIP_ENABLE ); + +/* Wait for syncpt counter to reach frame start event threshold */ + err =host1x_syncpt_wait (chan->out_sp, chan->next_out_sp_idx, +TEGRA_VI_SYNCPT_WAIT_TIMEOUT , &value);You're not using the "value" variable, it should be NULL.
Ah, sure, good catch.
Quoted 1 line
The "
chan->out_sp" looks redundant, it duplicates thechan->mw_ack_sp.
I agree it is redundant and can be improved.
Quoted 2 lines
AFAICS from the doc, T20 has two VI channels, and thus, two
mw_ack_sp, like T210.
I'm confused by this. In the current driver, each VI channel has an array of 2 mw_ack_sp, the second of which is only used the ganged CSI ports. I have no docs mentioning ganged ports so I don't know exactly how they work and whether T20 might need more than 1 syncpt per channel or not for CSI. Definitely when using VIP only one such syncpt per each VI (or per each VIP, as per your reply to patch 1) is needed.
Bottom line: I think I can simply remove the out_sp and in the VIP code always use chan->mw_ack_sp[0], and document that it's what is called OUT in VIP terms.
Does this plan seem good?
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v2 21/21] staging: media: tegra-video: add tegra20 variant
22.12.2022 12:03, Luca Ceresoli пишет:
Quoted 40 lines
Hello Dmitry,
Quoted 10 lines · On Wed, 21 Dec 2022 00:40:20 +0300 Dmitry Osipenko <[email protected]> wrote:
28.11.2022 18:23, Luca Ceresoli пишет:
Quoted 9 lines
drivers/staging/media/tegra-video/tegra20.c new file +9
-0+static int tegra20_channel_capture_frame (struct tegra_vi_channel *chan, +struct tegra_channel_buffer *buf) +{ +u32 value; +int err; + + chan->next_out_sp_idx++; + +tegra20_channel_vi_buffer_setup (chan, buf);Quoted 8 lines
drivers/staging/media/tegra-video/tegra20.c line 394
Quoted 6 lines
drivers/staging/media/tegra-video/tegra20.c new file +6
-0+ +tegra20_vi_write (chan,TEGRA_VI_CAMERA_CONTROL ,VI_CAMERA_CONTROL_VIP_ENABLE ); + +/* Wait for syncpt counter to reach frame start event threshold */ + err =host1x_syncpt_wait (chan->out_sp, chan->next_out_sp_idx, +TEGRA_VI_SYNCPT_WAIT_TIMEOUT , &value);You're not using the "value" variable, it should be NULL.
Ah, sure, good catch.
Quoted 1 line
The "
chan->out_sp" looks redundant, it duplicates thechan->mw_ack_sp.I agree it is redundant and can be improved.
Quoted 2 lines
AFAICS from the doc, T20 has two VI channels, and thus, two
mw_ack_sp, like T210.I'm confused by this. In the current driver, each VI channel has an array of 2
mw_ack_sp, the second of which is only used the ganged CSI ports. I have no docs mentioning ganged ports so I don't know exactly how they work and whether T20 might need more than 1 syncpt per channel or not for CSI. Definitely when using VIP only one such syncpt per each VI (or per each VIP, as per your reply to patch 1) is needed.
Quoted 5 lines
Bottom line: I think I can simply remove the
out_spand in the VIP code always use chan->mw_ack_sp[0], and document that it's what is called OUT in VIP terms.Does this plan seem good?
Older Tegra VI doesn't have ganged ports, but two memory/CSI channels. It feels to me that Tegra VI can capture both channels independently, though downstream driver stack used only one of the channels, IIRC.
There is a VI header file from nvddk in downstream kernel, which is pretty much the doc by itself.
Re: [PATCH v2 21/21] staging: media: tegra-video: add tegra20 variant
23.12.2022 15:15, Dmitry Osipenko пишет:
Quoted 47 lines
22.12.2022 12:03, Luca Ceresoli пишет:
Quoted 40 lines
Hello Dmitry,
Quoted 10 lines · On Wed, 21 Dec 2022 00:40:20 +0300 Dmitry Osipenko <[email protected]> wrote:
28.11.2022 18:23, Luca Ceresoli пишет:
Quoted 9 lines
drivers/staging/media/tegra-video/tegra20.c new file +9
-0+static int tegra20_channel_capture_frame (struct tegra_vi_channel *chan, +struct tegra_channel_buffer *buf) +{ +u32 value; +int err; + + chan->next_out_sp_idx++; + +tegra20_channel_vi_buffer_setup (chan, buf);Quoted 8 lines
drivers/staging/media/tegra-video/tegra20.c line 394
Quoted 6 lines
drivers/staging/media/tegra-video/tegra20.c new file +6
-0+ +tegra20_vi_write (chan,TEGRA_VI_CAMERA_CONTROL ,VI_CAMERA_CONTROL_VIP_ENABLE ); + +/* Wait for syncpt counter to reach frame start event threshold */ + err =host1x_syncpt_wait (chan->out_sp, chan->next_out_sp_idx, +TEGRA_VI_SYNCPT_WAIT_TIMEOUT , &value);You're not using the "value" variable, it should be NULL.
Ah, sure, good catch.
Quoted 1 line
The "
chan->out_sp" looks redundant, it duplicates thechan->mw_ack_sp.I agree it is redundant and can be improved.
Quoted 2 lines
AFAICS from the doc, T20 has two VI channels, and thus, two
mw_ack_sp, like T210.I'm confused by this. In the current driver, each VI channel has an array of 2
mw_ack_sp, the second of which is only used the ganged CSI ports. I have no docs mentioning ganged ports so I don't know exactly how they work and whether T20 might need more than 1 syncpt per channel or not for CSI. Definitely when using VIP only one such syncpt per each VI (or per each VIP, as per your reply to patch 1) is needed.Quoted 5 lines
Bottom line: I think I can simply remove the
out_spand in the VIP code always use chan->mw_ack_sp[0], and document that it's what is called OUT in VIP terms.Does this plan seem good?
Quoted 8 lines
Older Tegra VI doesn't have ganged ports, but two memory/CSI channels. It feels to me that Tegra VI can capture both channels independently, though downstream driver stack used only one of the channels, IIRC.
There is a VI header file from nvddk in downstream kernel, which is pretty much the doc by itself.
Although, after a bit closer look, I see that there is only one port selector there. Hence there only one port can be active at a time.
Re: [PATCH v2 21/21] staging: media: tegra-video: add tegra20 variant
In reply to Luca Ceresoli28.11.2022 18:23, Luca Ceresoli пишет:
Quoted 51 lines
drivers/staging/media/tegra-video/tegra20.c new file +51
-0+/* -------------------------------------------------------------------------- +* VIP +*/ + +/* +* VIP-specific configuration for stream start. +* +* Whatever is common among VIP and CSI is done by the VI component (see +* tegra20_vi_start_streaming()). Here we do what is VIP-specific. +*/ +static int tegra20_vip_start_streaming (struct tegra_vip_channel *vip_chan) +{ +struct tegra_vi_channel *vi_chan =v4l2_get_subdev_hostdata (&vip_chan->subdev); +int width = vi_chan->format.width; +int height = vi_chan->format.height; + +unsigned int main_input_format; +unsigned int yuv_input_format; + +tegra20_vi_get_input_formats (vi_chan, &main_input_format, &yuv_input_format); + +tegra20_vi_write (vi_chan,TEGRA_VI_VI_CORE_CONTROL ,0 ); + +tegra20_vi_write (vi_chan,TEGRA_VI_VI_INPUT_CONTROL , +VI_INPUT_VIP_INPUT_ENABLE | main_input_format | yuv_input_format); + +tegra20_vi_write (vi_chan,TEGRA_VI_V_DOWNSCALE_CONTROL ,0 ); +tegra20_vi_write (vi_chan,TEGRA_VI_H_DOWNSCALE_CONTROL ,0 ); + +tegra20_vi_write (vi_chan,TEGRA_VI_VIP_V_ACTIVE , height <<VI_VIP_V_ACTIVE_PERIOD_SFT ); +tegra20_vi_write (vi_chan,TEGRA_VI_VIP_H_ACTIVE , +roundup (width,2 ) <<VI_VIP_H_ACTIVE_PERIOD_SFT ); + +/* +* For VIP, D9..D2 is mapped to the video decoder's P7..P0. +* Disable/mask out the other Dn wires. When not in BT656 +* mode we also need the V/H sync. +*/ +tegra20_vi_write (vi_chan,TEGRA_VI_PIN_INPUT_ENABLE , +GENMASK (9 ,2 ) <<VI_PIN_INPUT_VD_SFT | +VI_PIN_INPUT_HSYNC |VI_PIN_INPUT_VSYNC ); +tegra20_vi_write (vi_chan,TEGRA_VI_VI_DATA_INPUT_CONTROL , +GENMASK (9 ,2 ) <<VI_DATA_INPUT_SFT ); +tegra20_vi_write (vi_chan,TEGRA_VI_PIN_INVERSION ,0 ); + +tegra20_vi_write (vi_chan,TEGRA_VI_CONT_SYNCPT_OUT_1 , +VI_CONT_SYNCPT_OUT_1_CONTINUOUS_SYNCPT | +host1x_syncpt_id (vi_chan->out_sp) <<VI_CONT_SYNCPT_OUT_1_SYNCPT_IDX_SFT ); + +tegra20_vi_write (vi_chan,TEGRA_VI_CAMERA_CONTROL ,VI_CAMERA_CONTROL_STOP_CAPTURE ); +
drivers/staging/media/tegra-video/tegra20.c line 661
Quoted 10 lines
drivers/staging/media/tegra-video/tegra20.c new file +10
-0+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, +};
Shouldn't this be placed in vip.c? Also looks like patch #20 won't link because tegra20_vip_soc is defined in patch #21.
Luca Ceresoli
maintainerRe: [PATCH v2 21/21] staging: media: tegra-video: add tegra20 variant
Quoted 1 line · On Fri, 23 Dec 2022 15:35:58 +0300 Dmitry Osipenko <[email protected]> wrote:
28.11.2022 18:23, Luca Ceresoli пишет:
...
Quoted 9 lines
drivers/staging/media/tegra-video/tegra20.c line 661
Quoted 7 lines
drivers/staging/media/tegra-video/tegra20.c new file +7
-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, +};Shouldn't this be placed in
vip.c?
Indeed. Which means tegra210_csi_soc can be moved as well, so I'm adding a small patch to the series to do that.
Quoted 2 lines
Also looks like patch #20 won't link
becausetegra20_vip_socis defined in patch #21.
You're right, we have a chicken-egg problem here. One solution would be leaving tegra_vip_of_id_table empty in patch 20 and fill it only in patch 21, but that would not be bisectable as patch 20 would introduce code that nobody uses until patch 21. So I think it's better to squash together patches 20+21.
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v2 21/21] staging: media: tegra-video: add tegra20 variant
In reply to Luca Ceresoli28.11.2022 18:23, Luca Ceresoli пишет:
Quoted 28 lines
drivers/staging/media/tegra-video/tegra20.c new file +28
-0+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. +*/
drivers/staging/media/tegra-video/tegra20.c line 648
Quoted 10 lines
drivers/staging/media/tegra-video/tegra20.c new file +10
-0+tegra20_vi_write (vi_chan,TEGRA_VI_PIN_INPUT_ENABLE , +GENMASK (9 ,2 ) <<VI_PIN_INPUT_VD_SFT | +VI_PIN_INPUT_HSYNC |VI_PIN_INPUT_VSYNC ); +tegra20_vi_write (vi_chan,TEGRA_VI_VI_DATA_INPUT_CONTROL , +GENMASK (9 ,2 ) <<VI_DATA_INPUT_SFT ); +tegra20_vi_write (vi_chan,TEGRA_VI_PIN_INVERSION ,0 ); + +tegra20_vi_write (vi_chan,TEGRA_VI_CONT_SYNCPT_OUT_1 , +VI_CONT_SYNCPT_OUT_1_CONTINUOUS_SYNCPT | +host1x_syncpt_id (vi_chan->out_sp) <<VI_CONT_SYNCPT_OUT_1_SYNCPT_IDX_SFT );
Wondering whether you also need to set up the sypct_incr condition to op_done, it should be immediate by default. I see that T210 VI code sets up the incr condition.
Re: [PATCH v2 21/21] staging: media: tegra-video: add tegra20 variant
23.12.2022 16:02, Dmitry Osipenko пишет:
Quoted 35 lines
28.11.2022 18:23, Luca Ceresoli пишет:
Quoted 34 lines
drivers/staging/media/tegra-video/tegra20.c new file +34
-0+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 );
Quoted 8 lines
drivers/staging/media/tegra-video/tegra20.c line 648
Quoted 4 lines
drivers/staging/media/tegra-video/tegra20.c new file +4
-0+ +tegra20_vi_write (vi_chan,TEGRA_VI_CONT_SYNCPT_OUT_1 , +VI_CONT_SYNCPT_OUT_1_CONTINUOUS_SYNCPT | +host1x_syncpt_id (vi_chan->out_sp) <<VI_CONT_SYNCPT_OUT_1_SYNCPT_IDX_SFT );Wondering whether you also need to set up the
sypct_incrcondition toop_done, it should be immediate by default. I see that T210 VI code sets up the incr condition.
Found in the doc "Continuous syncpt always use OP_DONE as condition", the current code is fine.
28.11.2022 18:23, Luca Ceresoli пишет:
Quoted 16 lines
Tegra20 and other Tegra SoCs have a video input (VI) peripheral that can receive from either MIPI CSI-2 or parallel video (called respectively "CSI" and "VIP" in the documentation). The kernel currently has a staging driver for Tegra210 CSI capture. This patch set adds support for Tegra20 VIP capture.
Unfortunately I had no real documentation available to base this work on. I only had a working downstream 3.1 kernel, so I started with the driver found there and heavily reworked it to fit into the mainline tegra-video driver structure. The existing code appears written with the intent of being modular and allow adding new input mechanisms and new SoCs while keeping a unique VI core module. However its modularity and extensibility was not enough to add Tegra20 VIP support, so I added some hooks to turn hard-coded behaviour into per-SoC or per-bus customizable code. There are also a fix, some generic cleanups and DT bindings.
Quoted 6 lines
Quick tour of the patches:
* Device tree bindings and minor DTS improvements
01. dt-bindings: display: tegra: add Tegra20 VIP
02. dt-bindings: display: tegra: vi: add 'vip' property and example
This series adds the new DT node, but there are no board DTs in upstream that will use VIP? Will we see the board patches?
In any case, given that you're likely the only one here who has access to hardware with VIP, you should promote yourself to the tegra-video driver maintainers and confirm that you will be able to maintain and test this code for years to come.
Luca Ceresoli
maintainerHello Dmitry,
thanks for your review.
Quoted 19 lines · On Tue, 20 Dec 2022 23:21:49 +0300 Dmitry Osipenko <[email protected]> wrote:
28.11.2022 18:23, Luca Ceresoli пишет:
Quoted 18 lines
Tegra20 and other Tegra SoCs have a video input (VI) peripheral that can receive from either MIPI CSI-2 or parallel video (called respectively "CSI" and "VIP" in the documentation). The kernel currently has a staging driver for Tegra210 CSI capture. This patch set adds support for Tegra20 VIP capture.
Unfortunately I had no real documentation available to base this work on. I only had a working downstream 3.1 kernel, so I started with the driver found there and heavily reworked it to fit into the mainline tegra-video driver structure. The existing code appears written with the intent of being modular and allow adding new input mechanisms and new SoCs while keeping a unique VI core module. However its modularity and extensibility was not enough to add Tegra20 VIP support, so I added some hooks to turn hard-coded behaviour into per-SoC or per-bus customizable code. There are also a fix, some generic cleanups and DT bindings.
Quick tour of the patches:
Quoted 7 lines
Quoted 4 lines
* Device tree bindings and minor DTS improvements
01. dt-bindings: display: tegra: add Tegra20 VIP
02. dt-bindings: display: tegra: vi: add 'vip' property and exampleThis series adds the new DT node, but there are no board DTs in upstream that will use VIP? Will we see the board patches?
I'm afraid I have no such plan. I don't have any public hardware with Tegra20, with or without a parallel sensor. I have a custom board.
Quoted 2 lines
In any case, given that you're likely the only one here who has access to hardware with VIP,
Likely indeed.
Quoted 3 lines
you should promote yourself to the tegra-video
driver maintainers and confirm that you will be able to maintain and test this code for years to come.
I can definitely add myself as a maintainer of this driver and join the maintenance effort, I'm adding that in v3. I also have a board that I can permanently use for testing.
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com