media: rockchip: Add a driver for Rockchip's camera interface
Subsystems (3)
v6 cover media: rockchip: Add a driver for Rockchip's camera interface
Hello everyone,
This series is based on the fifth iteration of the series introducing the rockchip vip driver for the PX30 camera interface: sent 29 Dec 2020 [1]
Most of this driver was written following the BSP driver from rockchip, removing the parts that either didn't fit correctly the guidelines, or that couldn't be tested.
In the BSP, this driver is known as the "cif" driver, but this was renamed to "vip" to better fit the controller denomination in the datasheet.
This version of the driver supports ONLY the parallel interface BT656 and was tested/implemented using an SDTV video decoder
base-commit: 2c1bae27df787c9535e48cc27bbd11c3c3e0a235
Changes since fifth iteration in [1]:
vip/capture.c vip/dev.c vip/dev.h
- added a video g_input_status subdev call, V4L2_IN_CAP_STD and the supported stds in rk_vip_enum_input callback
- added rk_vip_g_std, rk_vip_s_std and rk_vip_querystd callbacks
- added the supported video_device->tvnorms
- s_std will now update the format as this depends on the standard NTSC/PAL (as suggested by Hans in [1])
- removed STD_ATSC
- moved the colorimetry information to come from the subdev
- removed the core s_power subdev calls
- dropped cropping in rk_vip_stream struct
rockchip-vip.yaml:
- fixed a mistake in the name of third clock plckin -> plck
- changed the reg maxItems 2 -> 1
[1] https://lore.kernel.org/linux-media/[email protected]/
I used v4l-utils with HEAD: commit 1ee258e5bb91a12df378e19eb255c5219d6bc36b
# v4l2-compliance v4l2-compliance 1.25.0, 64 bits, 64-bit time_t
Compliance test for rk_vip device /dev/video0:
Driver Info:
Driver name : rk_vip
Card type : rk_vip
Bus info : platform:ff490000.vip
Driver version : 6.6.0
Capabilities : 0x84201000 Video Capture Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Media Driver Info:
Driver name : rk_vip
Model : rk_vip
Serial :
Bus info : platform:ff490000.vip
Media version : 6.6.0 Hardware revision: 0x00000000 (0)
Driver version : 6.6.0
Interface Info:
ID : 0x03000002
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : video_rkvip
Function : V4L2 I/O
Pad 0x01000004 : 0: Sink
Link 0x02000009: from remote pad 0x1000006 of entity 'tw9900 2-0044' (Digital Video Decoder): Data, EnabledRequired ioctls:
test MC information (see 'Media Driver Info' above): OK test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK (Not Supported) test VIDIOC_QUERYCTRL: OK (Not Supported)
test VIDIOC_G/S_CTRL: OK (Not Supported)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK (Not Supported) test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not Supported) test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 0 Private Controls: 0
Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
Total for rk_vip device /dev/video0: 46, Succeeded: 46, Failed: 0, Warnings: 0
Mehdi Djait (3):
media: dt-bindings: media: add rockchip-vip
media: rockchip: Add a driver for Rockhip's camera interface
arm64: dts: rockchip: Add the camera interface
Mehdi Djait (3):
media: dt-bindings: media: add rockchip-vip
media: rockchip: Add a driver for Rockhip's camera interface
arm64: dts: rockchip: Add the camera interface
.../bindings/media/rockchip-vip.yaml | 91 ++ arch/arm64/boot/dts/rockchip/px30.dtsi | 12 + drivers/media/platform/rockchip/Kconfig | 1 + drivers/media/platform/rockchip/Makefile | 1 + drivers/media/platform/rockchip/vip/Kconfig | 14 + drivers/media/platform/rockchip/vip/Makefile | 3 + drivers/media/platform/rockchip/vip/capture.c | 1197 +++++++++++++++++ drivers/media/platform/rockchip/vip/dev.c | 332 +++++ drivers/media/platform/rockchip/vip/dev.h | 163 +++ drivers/media/platform/rockchip/vip/regs.h | 260 ++++ 10 files changed, 2074 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip-vip.yaml create mode 100644 drivers/media/platform/rockchip/vip/Kconfig create mode 100644 drivers/media/platform/rockchip/vip/Makefile create mode 100644 drivers/media/platform/rockchip/vip/capture.c create mode 100644 drivers/media/platform/rockchip/vip/dev.c create mode 100644 drivers/media/platform/rockchip/vip/dev.h create mode 100644 drivers/media/platform/rockchip/vip/regs.h
Signature · 1 line
2.41.0
PATCH v6 1/3 media: dt-bindings: media: add rockchip-vip
Add a documentation for the Rockchip Camera Interface controller binding.
This controller can be found on platforms such as the PX30 or RK1808, RK3128 and RK3288. The PX30 is the only platform supported so far.
--- .../bindings/media/rockchip-vip.yaml | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip-vip.yaml
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +91 -0
@@ -0,0 +1,91 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/rockchip-vip.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip VIP Camera Interface + +maintainers: + - Mehdi Djait <[email protected]> + +description: |- + Rockchip Video Input Processor present on PX30, RK1808, RK3128 and RK3288 + +properties: + compatible: + const: rockchip,px30-vip + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: ACLK + - description: HCLK + - description: PCLK + + clock-names: + items: + - const: aclk + - const: hclk + - const: pclk + + resets: + items: + - description: AXI + - description: AHB + - description: PCLK IN + + reset-names: + items: + - const: axi + - const: ahb + - const: pclkin + + power-domains: + maxItems: 1 + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + description: A connection to a sensor or decoder + +required: + - compatible + - reg + - interrupts + - clocks + - port + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/px30-cru.h> + #include <dt-bindings/power/px30-power.h> + + parent0: parent { + #address-cells = <2>; + #size-cells = <2>; + + vip: vip@ff490000 { + compatible = "rockchip,px30-vip"; + reg = <0x0 0xff490000 0x0 0x200>; + interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cru ACLK_CIF>, <&cru HCLK_CIF>, <&cru PCLK_CIF>; + clock-names = "aclk", "hclk", "pclk"; + resets = <&cru SRST_CIF_A>, <&cru SRST_CIF_H>, <&cru SRST_CIF_PCLKIN>; + reset-names = "axi", "ahb", "pclkin"; + power-domains = <&power PX30_PD_VI>; + port { + vip_in: endpoint { + remote-endpoint = <&tw9900_out>; + }; + }; + }; + }; +...
Signature · 1 line
2.41.0
Rob Herring
maintainerRe: [PATCH v6 1/3] media: dt-bindings: media: add rockchip-vip
Quoted 10 lines · Mehdi Djait
Add a documentation for the Rockchip Camera Interface controller binding.
This controller can be found on platforms such as the PX30 or RK1808, RK3128 and RK3288. The PX30 is the only platform supported so far.
Signed-off-by Mehdi Djait <[email protected]>--- .../bindings/media/rockchip-vip.yaml | 91 +++++++++++++++++++
filename should match compatible.
Quoted 11 lines
1 file changed, 91 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip-vip.yamlDocumentation/devicetree/bindings/media/rockchip-vip.yaml new file +2
-0@@ -0,0 +1,91 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2
Documentation/devicetree/bindings/media/rockchip-vip.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/media/rockchip-vip.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip VIP Camera Interface + +maintainers: + - Mehdi Djait <[email protected]> + +description: |-
Don't need '|-'.
Documentation/devicetree/bindings/media/rockchip-vip.yaml line 13
Quoted 1 line
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +1
-0+ Rockchip Video Input Processor present on PX30, RK1808, RK3128 and RK3288
Write complete sentences.
Documentation/devicetree/bindings/media/rockchip-vip.yaml line 17
Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +4
-0+ +properties: + compatible: + const: rockchip,px30-vip
I see 4 SoCs listed, but only 1 compatible.
Quoted 26 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +26
-0+ + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: ACLK + - description: HCLK + - description: PCLK + + clock-names: + items: + - const: aclk + - const: hclk + - const: pclk + + resets: + items: + - description: AXI + - description: AHB + - description: PCLK IN + + reset-names:
Documentation/devicetree/bindings/media/rockchip-vip.yaml line 53
Quoted 10 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +10
-0+ items: + - const: axi + - const: ahb + - const: pclkin + + power-domains: + maxItems: 1 + + port: + $ref: /schemas/graph.yaml#/$defs/port-base
/schemas/graph.yaml#/properties/port
if there are no extra properties (such as defined in video-interfaces.yaml).
Quoted 8 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +8
-0+ description: A connection to a sensor or decoder + +required: + - compatible + - reg + - interrupts + - clocks + - port
Documentation/devicetree/bindings/media/rockchip-vip.yaml line 71
Quoted 10 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +10
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/px30-cru.h> + #include <dt-bindings/power/px30-power.h> + + parent0: parent {
Drop unused labels.
Quoted 23 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +20
-0+ #address-cells = <2>; + #size-cells = <2>; + + vip: vip@ff490000 { + compatible = "rockchip,px30-vip"; + reg = <0x0 0xff490000 0x0 0x200>; + interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cru ACLK_CIF>, <&cru HCLK_CIF>, <&cru PCLK_CIF>; + clock-names = "aclk", "hclk", "pclk"; + resets = <&cru SRST_CIF_A>, <&cru SRST_CIF_H>, <&cru SRST_CIF_PCLKIN>; + reset-names = "axi", "ahb", "pclkin"; + power-domains = <&power PX30_PD_VI>; + port { + vip_in: endpoint { + remote-endpoint = <&tw9900_out>; + }; + }; + }; + }; +...Signature · 1 line
2.41.0
Re: [PATCH v6 1/3] media: dt-bindings: media: add rockchip-vip
Hello Rob,
Thank you for the review!
Quoted 44 lines · Rob Herring
Quoted 10 lines · Mehdi Djait
Add a documentation for the Rockchip Camera Interface controller binding.
This controller can be found on platforms such as the PX30 or RK1808, RK3128 and RK3288. The PX30 is the only platform supported so far.
Signed-off-by Mehdi Djait <[email protected]>--- .../bindings/media/rockchip-vip.yaml | 91 +++++++++++++++++++filename should match compatible.
Quoted 11 lines
1 file changed, 91 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/rockchip-vip.yamlDocumentation/devicetree/bindings/media/rockchip-vip.yaml new file +2
-0@@ -0,0 +1,91 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2Documentation/devicetree/bindings/media/rockchip-vip.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/media/rockchip-vip.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip VIP Camera Interface + +maintainers: + - Mehdi Djait <[email protected]> + +description: |-Don't need '|-'.
Documentation/devicetree/bindings/media/rockchip-vip.yaml line 13
Quoted 1 line
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +1
-0+ Rockchip Video Input Processor present on PX30, RK1808, RK3128 and RK3288Write complete sentences.
Quoted 7 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml line 17
Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +4
-0+ +properties: + compatible: + const: rockchip,px30-vipI see 4 SoCs listed, but only 1 compatible.
PX30 is the only SoC I have used to test the driver. What is the best way to proceed here ? Change the description ?
ack for all the other comments.
--
Kind Regards
Mehdi Djait
Re: [PATCH v6 1/3] media: dt-bindings: media: add rockchip-vip
Quoted 21 lines · Mehdi Djait
Quoted 13 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml line 12
Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +4
-0+maintainers: + - Mehdi Djait <[email protected]> + +description: |-Don't need '|-'.
Quoted 1 line
+ Rockchip Video Input Processor present on PX30, RK1808, RK3128 and RK3288
Write complete sentences.
Quoted 7 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml line 17
Quoted 4 lines
Documentation/devicetree/bindings/media/rockchip-vip.yaml new file +4
-0+ +properties: + compatible: + const: rockchip,px30-vipI see 4 SoCs listed, but only 1 compatible.
Quoted 3 lines
PX30 is the only SoC I have used to test the driver. What is the best way to proceed here ? Change the description ?
The best is to have bindings complete for all of the four SoCs, even if you did not test the driver on them. The "complete" means hardware-complete, so what the datasheet/spec is saying.
If anything is missing, could be added later.
You can change the description and drop other SoCs as well.
Best regards,
Krzysztof
PATCH v6 2/3 media: rockchip: Add a driver for Rockhip's camera interface
In reply to Mehdi DjaitIntroduce a driver for the camera interface on some Rockchip platforms.
This controller supports CSI2 and BT656 interfaces, but for now only the BT656 interface could be tested, hence it's the only one that's supported in the first version of this driver.
This controller can be found on PX30, RK1808, RK3128 and RK3288, but for now it's only been tested on PX30.
Most of this driver was written following the BSP driver from rockchip, removing the parts that either didn't fit correctly the guidelines, or that couldn't be tested.
In the BSP, this driver is known as the "cif" driver, but this was renamed to "vip" to better fit the controller denomination in the datasheet.
This basic version doesn't support cropping nor scaling, and is only designed with one SDTV video decoder being attached to it a any time.
This version uses the "pingpong" mode of the controller, which is a double-buffering mechanism.
--- drivers/media/platform/rockchip/Kconfig | 1 + drivers/media/platform/rockchip/Makefile | 1 + drivers/media/platform/rockchip/vip/Kconfig | 14 + drivers/media/platform/rockchip/vip/Makefile | 3 + drivers/media/platform/rockchip/vip/capture.c | 1197 +++++++++++++++++ drivers/media/platform/rockchip/vip/dev.c | 332 +++++ drivers/media/platform/rockchip/vip/dev.h | 163 +++ drivers/media/platform/rockchip/vip/regs.h | 260 ++++ 8 files changed, 1971 insertions(+) create mode 100644 drivers/media/platform/rockchip/vip/Kconfig create mode 100644 drivers/media/platform/rockchip/vip/Makefile create mode 100644 drivers/media/platform/rockchip/vip/capture.c create mode 100644 drivers/media/platform/rockchip/vip/dev.c create mode 100644 drivers/media/platform/rockchip/vip/dev.h create mode 100644 drivers/media/platform/rockchip/vip/regs.h
drivers/media/platform/rockchip/Kconfig +1 -0
@@ -4,3 +4,4 @@ comment "Rockchip media platform drivers" source "drivers/media/platform/rockchip/rga/Kconfig" source "drivers/media/platform/rockchip/rkisp1/Kconfig" +source "drivers/media/platform/rockchip/vip/Kconfig"
drivers/media/platform/rockchip/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only obj-y += rga/ obj-y += rkisp1/ +obj-y += vip/
drivers/media/platform/rockchip/vip/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +config VIDEO_ROCKCHIP_VIP + tristate "Rockchip VIP (Video InPut) Camera Interface" + depends on VIDEO_DEV + depends on ARCH_ROCKCHIP || COMPILE_TEST + select VIDEOBUF2_DMA_SG + select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE + select V4L2_MEM2MEM_DEV + help + This is a v4l2 driver for Rockchip SOC Camera interface. It supports + BT.656 and CSI2 inputs. + + To compile this driver as a module choose m here : the module will + be called video_rkvip.
drivers/media/platform/rockchip/vip/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_VIDEO_ROCKCHIP_VIP) += video_rkvip.o +video_rkvip-objs += dev.o capture.o
drivers/media/platform/rockchip/vip/capture.c new file +1197 -0
1,197 lines not on this page · raw message
drivers/media/platform/rockchip/vip/dev.c new file +332 -0
332 lines not on this page · raw message
drivers/media/platform/rockchip/vip/dev.h new file +163 -0
163 lines not on this page · raw message
drivers/media/platform/rockchip/vip/regs.h new file +260 -0
260 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH v6 2/3] media: rockchip: Add a driver for Rockhip's camera interface
Quoted 2 lines · Mehdi Djait
Introduce a driver for the camera interface on some Rockchip platforms.
...
Quoted 20 lines
drivers/media/platform/rockchip/vip/dev.c new file +20
-0+static const struct of_device_id rk_vip_plat_of_match[] = { + { + .compatible ="rockchip,px30-vip" , + .data = &px30_vip_match_data, + }, + {}, +}; + +void rk_vip_soft_reset (struct rk_vip_device *vip_dev) +{ +reset_control_assert (vip_dev->vip_rst); + +udelay (5 ); + +reset_control_deassert (vip_dev->vip_rst); +} + +static int rk_vip_plat_probe (struct platform_device *pdev) +{ +const struct of_device_id *match;
drivers/media/platform/rockchip/vip/dev.c line 195
Quoted 10 lines
drivers/media/platform/rockchip/vip/dev.c new file +10
-0+struct device_node *node = pdev->dev.of_node; +struct device *dev = &pdev->dev; +struct v4l2_device *v4l2_dev; +struct rk_vip_device *vip_dev; +const struct vip_match_data *data; +struct resource *res; +int i, ret, irq; + + match =of_match_node (rk_vip_plat_of_match, node); +if (IS_ERR (match))
of_match_node does no return ERR_PTR.
Quoted 4 lines
drivers/media/platform/rockchip/vip/dev.c new file +4
-0+return PTR_ERR (match); + + vip_dev =devm_kzalloc (dev,sizeof (*vip_dev),GFP_KERNEL ); +if (!vip_dev)
drivers/media/platform/rockchip/vip/dev.c line 209
Quoted 10 lines
drivers/media/platform/rockchip/vip/dev.c new file +10
-0+return -ENOMEM ; + +dev_set_drvdata (dev, vip_dev); + vip_dev->dev = dev; + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return irq; + + ret = devm_request_irq(dev, irq, rk_vip_irq_pingpong, IRQF_SHARED,
Shared? With devm? This is error-prone pattern (as discussed few times on the list). Are you 100% sure that all your use-cases are correct?
drivers/media/platform/rockchip/vip/dev.c line 212
Quoted 3 lines
drivers/media/platform/rockchip/vip/dev.c new file +3
-0+ dev_driver_string(dev), dev); +if (ret <0 ) { +dev_err (dev,"request irq failed: %d\n" , ret);
return dev_err_probe
drivers/media/platform/rockchip/vip/dev.c line 221
Quoted 9 lines
drivers/media/platform/rockchip/vip/dev.c new file +9
-0+return ret; + } + + vip_dev->irq = irq; + data = match->data; + vip_dev->chip_id = data->chip_id; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + vip_dev->base_addr =devm_ioremap_resource (dev, res);
Use wrapper for these two.
Quoted 91 lines
drivers/media/platform/rockchip/vip/dev.c new file +91
-0+ +if (IS_ERR (vip_dev->base_addr)) +return PTR_ERR (vip_dev->base_addr); + +for (i =0 ; i < data->clks_num; i++) + vip_dev->clks[i].id = data->clks[i]; + + vip_dev->num_clk = data->clks_num; + + ret =devm_clk_bulk_get (dev, vip_dev->num_clk, vip_dev->clks); +if (ret) +return ret; + + vip_dev->vip_rst =devm_reset_control_array_get (dev, false, false); +if (IS_ERR (vip_dev->vip_rst)) +return PTR_ERR (vip_dev->vip_rst); + +/* Initialize the stream */ +rk_vip_stream_init (vip_dev); +strscpy (vip_dev->media_dev.model,"rk_vip" , +sizeof (vip_dev->media_dev.model)); + vip_dev->media_dev.dev = &pdev->dev; + v4l2_dev = &vip_dev->v4l2_dev; + v4l2_dev->mdev = &vip_dev->media_dev; +strscpy (v4l2_dev->name,"rk_vip" ,sizeof (v4l2_dev->name)); + + ret =v4l2_device_register (vip_dev->dev, &vip_dev->v4l2_dev); +if (ret <0 ) +return ret; + +media_device_init (&vip_dev->media_dev); + + ret =media_device_register (&vip_dev->media_dev); +if (ret <0 ) { +v4l2_err (v4l2_dev,"Failed to register media device: %d\n" , + ret); + goto err_unreg_v4l2_dev; + } + +/* create & register platform subdev (from of_node) */ + ret =rk_vip_register_platform_subdevs (vip_dev); +if (ret <0 ) + goto err_unreg_media_dev; + + vip_dev->sensor.std =V4L2_STD_NTSC ; +rk_vip_set_default_format (vip_dev); +pm_runtime_enable (&pdev->dev); + +return 0 ; + +err_unreg_media_dev: +media_device_unregister (&vip_dev->media_dev); +err_unreg_v4l2_dev: +v4l2_device_unregister (&vip_dev->v4l2_dev); +return ret; +} + +static int rk_vip_plat_remove (struct platform_device *pdev) +{ +struct rk_vip_device *vip_dev =platform_get_drvdata (pdev); + +pm_runtime_disable (&pdev->dev); + +media_device_unregister (&vip_dev->media_dev); +v4l2_device_unregister (&vip_dev->v4l2_dev); +rk_vip_unregister_stream_vdev (vip_dev); + +return 0 ; +} + +static int __maybe_unused rk_vip_runtime_suspend (struct device *dev) +{ +struct rk_vip_device *vip_dev =dev_get_drvdata (dev); + +clk_bulk_disable_unprepare (vip_dev->num_clk, vip_dev->clks); + +return pinctrl_pm_select_sleep_state (dev); +} + +static int __maybe_unused rk_vip_runtime_resume (struct device *dev) +{ +struct rk_vip_device *vip_dev =dev_get_drvdata (dev); +int ret; + + ret =pinctrl_pm_select_default_state (dev); +if (ret <0 ) +return ret; + +return clk_bulk_prepare_enable (vip_dev->num_clk, vip_dev->clks); +} +
drivers/media/platform/rockchip/vip/dev.c line 322
Quoted 10 lines
drivers/media/platform/rockchip/vip/dev.c new file +10
-0+static const struct dev_pm_ops rk_vip_plat_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) +SET_RUNTIME_PM_OPS (rk_vip_runtime_suspend, rk_vip_runtime_resume,NULL ) +}; + +static struct platform_driver rk_vip_plat_drv = { + .driver = { + .name =VIP_DRIVER_NAME , + .of_match_table =of_match_ptr (rk_vip_plat_of_match),
drop of_match_ptr, causes warnings in your code.
Best regards,
Krzysztof
PATCH v6 3/3 arm64: dts: rockchip: Add the camera interface
In reply to Mehdi DjaitThe PX30 has a camera interface, supporting CSI2 and BT656 modes. Add a DT description for this interface.
--- arch/arm64/boot/dts/rockchip/px30.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/rockchip/px30.dtsi +12 -0
@@ -1281,6 +1281,18 @@ isp_mmu: iommu@ff4a8000 { #iommu-cells = <0>; }; + vip: vip@ff490000 { + compatible = "rockchip,px30-vip"; + reg = <0x0 0xff490000 0x0 0x200>; + interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cru ACLK_CIF>, <&cru HCLK_CIF>, <&cru PCLK_CIF>; + clock-names = "aclk", "hclk", "pclk"; + power-domains = <&power PX30_PD_VI>; + resets = <&cru SRST_CIF_A>, <&cru SRST_CIF_H>, <&cru SRST_CIF_PCLKIN>; + reset-names = "axi", "ahb", "pclkin"; + status = "disabled"; + }; + qos_gmac: qos@ff518000 { compatible = "rockchip,px30-qos", "syscon"; reg = <0x0 0xff518000 0x0 0x20>;
Signature · 1 line
2.41.0