Skip to contentSkip to conversation

Add ISP RAW for StarFive

PATCH Superseded Changhuang Liang 2 participants 19 messages Mar 6, 2024 – Mar 7, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add ISP RAW for StarFive

This series implements the ISP RAW function to the Camera Subsystem on StarFive JH7110 SoC. The series has been tested on the VisionFive 2 board.

This series should be applied after the patch [1]:
[1]: https://lore.kernel.org/all/[email protected]/

This series will conflict with series [2]:
[2]: https://lore.kernel.org/all/[email protected]/

The following are the media graph for the device and the v4l2-compliance output.

==========================================================================================

[the media graph]:

digraph board {
	rankdir=TB
	n00000001 [label="{{<port0> 0} | stf_isp\n/dev/v4l-subdev0 | {<port1> 1 | <port2> 2}}", shape=Mrecord, style=filled, fillcolor=green]
	n00000001:port1 -> n00000009 [style=dashed]
	n00000001:port2 -> n0000000d [style=dashed]
	n00000005 [label="capture_dump\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
	n00000009 [label="capture_yuv\n/dev/video1", shape=box, style=filled, fillcolor=yellow]
	n0000000d [label="capture_raw\n/dev/video2", shape=box, style=filled, fillcolor=yellow]
	n00000015 [label="{{<port0> 0} | cdns_csi2rx.19800000.csi\n/dev/v4l-subdev1 | {<port1> 1 | <port2> 2 | <port3> 3 | <port4> 4}}", shape=Mrecord, style=filled, fillcolor=green]
	n00000015:port1 -> n00000001:port0 [style=dashed]
	n00000015:port1 -> n00000005 [style=dashed]
	n0000001f [label="{{} | imx219 6-0010\n/dev/v4l-subdev2 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]
	n0000001f:port0 -> n00000015:port0 [style=bold]
}

[v4l2-compliance test]:

# v4l2-compliance -m /dev/media0
v4l2-compliance 1.27.0, 64 bits, 64-bit time_t

Compliance test for starfive-camss device /dev/media0:

Media Driver Info:

	Driver name      : starfive-camss
	Model            : Starfive Camera Subsystem
	Serial           :
	Bus info         : platform:19840000.isp
	Media version    : 6.8.0
	Hardware revision: 0x00000000 (0)
	Driver version   : 6.8.0

Required ioctls:
test MEDIA_IOC_DEVICE_INFO: OK
test invalid ioctls: OK

Allow for multiple opens:
test second /dev/media0 open: OK
test MEDIA_IOC_DEVICE_INFO: OK
test for unlimited opens: OK

Media Controller ioctls:
test MEDIA_IOC_G_TOPOLOGY: OK
Entities: 6 Interfaces: 6 Pads: 12 Links: 11 test MEDIA_IOC_ENUM_ENTITIES/LINKS: OK test MEDIA_IOC_SETUP_LINK: OK

Total for starfive-camss device /dev/media0: 8, Succeeded: 8, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for starfive-camss device /dev/video0:

Driver Info:

	Driver name      : starfive-camss
	Card type        : Starfive Camera Subsystem
	Bus info         : platform:19840000.isp
	Driver version   : 6.8.0
	Capabilities     : 0x84200001

Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:

	Driver name      : starfive-camss
	Model            : Starfive Camera Subsystem
	Serial           :
	Bus info         : platform:19840000.isp
	Media version    : 6.8.0
	Hardware revision: 0x00000000 (0)
	Driver version   : 6.8.0
Interface Info:
	ID               : 0x03000007
	Type             : V4L Video
Entity Info:
	ID               : 0x00000005 (5)
	Name             : capture_dump
	Function         : V4L2 I/O
	Pad 0x01000006   : 0: Sink
	  Link 0x0200001d: from remote pad 0x1000017 of entity 'cdns_csi2rx.19800000.csi' (Video Interface Bridge): Data

Required 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 (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 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 (Not Supported) 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:
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:
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

Codec ioctls:
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:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Total for starfive-camss device /dev/video0: 47, Succeeded: 47, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for starfive-camss device /dev/video1:

Driver Info:

	Driver name      : starfive-camss
	Card type        : Starfive Camera Subsystem
	Bus info         : platform:19840000.isp
	Driver version   : 6.8.0
	Capabilities     : 0x84200001

Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:

	Driver name      : starfive-camss
	Model            : Starfive Camera Subsystem
	Serial           :
	Bus info         : platform:19840000.isp
	Media version    : 6.8.0
	Hardware revision: 0x00000000 (0)
	Driver version   : 6.8.0
Interface Info:
	ID               : 0x0300000b
	Type             : V4L Video
Entity Info:
	ID               : 0x00000009 (9)
	Name             : capture_yuv
	Function         : V4L2 I/O
	Pad 0x0100000a   : 0: Sink
	  Link 0x02000011: from remote pad 0x1000003 of entity 'stf_isp' (Image Signal Processor): Data

Required 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/video1 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 (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 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 (Not Supported) 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:
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:
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

Codec ioctls:
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:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Total for starfive-camss device /dev/video1: 47, Succeeded: 47, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for starfive-camss device /dev/video2:

Driver Info:

	Driver name      : starfive-camss
	Card type        : Starfive Camera Subsystem
	Bus info         : platform:19840000.isp
	Driver version   : 6.8.0
	Capabilities     : 0x84200001

Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:

	Driver name      : starfive-camss
	Model            : Starfive Camera Subsystem
	Serial           :
	Bus info         : platform:19840000.isp
	Media version    : 6.8.0
	Hardware revision: 0x00000000 (0)
	Driver version   : 6.8.0
Interface Info:
	ID               : 0x0300000f
	Type             : V4L Video
Entity Info:
	ID               : 0x0000000d (13)
	Name             : capture_raw
	Function         : V4L2 I/O
	Pad 0x0100000e   : 0: Sink
	  Link 0x02000013: from remote pad 0x1000004 of entity 'stf_isp' (Image Signal Processor): Data

Required 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/video2 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 (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 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 (Not Supported) 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:
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:
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

Codec ioctls:
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:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Total for starfive-camss device /dev/video2: 47, Succeeded: 47, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for starfive-camss device /dev/v4l-subdev0:

Driver Info:

	Driver version   : 6.8.0
	Capabilities     : 0x00000000
	Client Capabilities: 0x0000000000000002
interval-uses-which Media Driver Info:
	Driver name      : starfive-camss
	Model            : Starfive Camera Subsystem
	Serial           :
	Bus info         : platform:19840000.isp
	Media version    : 6.8.0
	Hardware revision: 0x00000000 (0)
	Driver version   : 6.8.0
Interface Info:
	ID               : 0x03000023
	Type             : V4L Sub-Device
Entity Info:
	ID               : 0x00000001 (1)
	Name             : stf_isp
	Function         : Image Signal Processor
	Pad 0x01000002   : 0: Sink
	  Link 0x0200001b: from remote pad 0x1000017 of entity 'cdns_csi2rx.19800000.csi' (Video Interface Bridge): Data
	Pad 0x01000003   : 1: Source
	  Link 0x02000011: to remote pad 0x100000a of entity 'capture_yuv' (V4L2 I/O): Data
	Pad 0x01000004   : 2: Source
	  Link 0x02000013: to remote pad 0x100000e of entity 'capture_raw' (V4L2 I/O): Data

Required ioctls:
test MC information (see 'Media Driver Info' above): OK test VIDIOC_SUDBEV_QUERYCAP: OK
test invalid ioctls: OK

Allow for multiple opens:
test second /dev/v4l-subdev0 open: OK
test VIDIOC_SUBDEV_QUERYCAP: OK
test for unlimited opens: OK

Debug ioctls:
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 (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 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 (Not Supported) 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)

Sub-Device ioctls (Sink Pad 0):
Try Stream 0
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Try VIDIOC_SUBDEV_G/S_FMT: OK
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK
Active Stream 0
test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Active VIDIOC_SUBDEV_G/S_FMT: OK
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK
test Active VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: OK (Not Supported)

Sub-Device ioctls (Source Pad 1):
Try Stream 0
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Try VIDIOC_SUBDEV_G/S_FMT: OK
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK
Active Stream 0
test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Active VIDIOC_SUBDEV_G/S_FMT: OK
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK
test Active VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: OK (Not Supported)

Sub-Device ioctls (Source Pad 2):
Try Stream 0
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Try VIDIOC_SUBDEV_G/S_FMT: OK
fail: v4l2-test-subdevs.cpp(528): sel.r.width == ~0U
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: FAIL
Active Stream 0
test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Active VIDIOC_SUBDEV_G/S_FMT: OK
fail: v4l2-test-subdevs.cpp(528): sel.r.width == ~0U
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: FAIL
test Active VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: OK (Not Supported)

Control ioctls:
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:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK (Not Supported) test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK (Not Supported)
test VIDIOC_TRY_FMT: OK (Not Supported)
test VIDIOC_S_FMT: OK (Not Supported)
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:
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:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK (Not Supported) test CREATE_BUFS maximum buffers: OK
test VIDIOC_EXPBUF: OK (Not Supported)
test Requests: OK (Not Supported)

Total for starfive-camss device /dev/v4l-subdev0: 66, Succeeded: 64, Failed: 2, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for starfive-camss device /dev/v4l-subdev1:

Driver Info:

	Driver version   : 6.8.0
	Capabilities     : 0x00000000
	Client Capabilities: 0x0000000000000002
interval-uses-which Media Driver Info:
	Driver name      : starfive-camss
	Model            : Starfive Camera Subsystem
	Serial           :
	Bus info         : platform:19840000.isp
	Media version    : 6.8.0
	Hardware revision: 0x00000000 (0)
	Driver version   : 6.8.0
Interface Info:
	ID               : 0x03000025
	Type             : V4L Sub-Device
Entity Info:
	ID               : 0x00000015 (21)
	Name             : cdns_csi2rx.19800000.csi
	Function         : Video Interface Bridge
	Pad 0x01000016   : 0: Sink
	  Link 0x02000021: from remote pad 0x1000020 of entity 'imx219 6-0010' (Camera Sensor): Data, Enabled, Immutable
	Pad 0x01000017   : 1: Source
	  Link 0x0200001b: to remote pad 0x1000002 of entity 'stf_isp' (Image Signal Processor): Data
	  Link 0x0200001d: to remote pad 0x1000006 of entity 'capture_dump' (V4L2 I/O): Data
	Pad 0x01000018   : 2: Source
	Pad 0x01000019   : 3: Source
	Pad 0x0100001a   : 4: Source

Required ioctls:
test MC information (see 'Media Driver Info' above): OK test VIDIOC_SUDBEV_QUERYCAP: OK
test invalid ioctls: OK

Allow for multiple opens:
test second /dev/v4l-subdev1 open: OK
test VIDIOC_SUBDEV_QUERYCAP: OK
test for unlimited opens: OK

Debug ioctls:
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 (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 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 (Not Supported) 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)

Sub-Device ioctls (Sink Pad 0):
Try Stream 0
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Try VIDIOC_SUBDEV_G/S_FMT: OK
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) Active Stream 0
test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Active VIDIOC_SUBDEV_G/S_FMT: OK
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test Active VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: OK (Not Supported)

Sub-Device ioctls (Source Pad 1):
Try Stream 0
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Try VIDIOC_SUBDEV_G/S_FMT: OK
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) Active Stream 0
test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Active VIDIOC_SUBDEV_G/S_FMT: OK
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test Active VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: OK (Not Supported)

Sub-Device ioctls (Source Pad 2):
Try Stream 0
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Try VIDIOC_SUBDEV_G/S_FMT: OK
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) Active Stream 0
test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Active VIDIOC_SUBDEV_G/S_FMT: OK
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test Active VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: OK (Not Supported)

Sub-Device ioctls (Source Pad 3):
Try Stream 0
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Try VIDIOC_SUBDEV_G/S_FMT: OK
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) Active Stream 0
test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Active VIDIOC_SUBDEV_G/S_FMT: OK
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test Active VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: OK (Not Supported)

Sub-Device ioctls (Source Pad 4):
Try Stream 0
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Try VIDIOC_SUBDEV_G/S_FMT: OK
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) Active Stream 0
test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK test Active VIDIOC_SUBDEV_G/S_FMT: OK
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test Active VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: OK (Not Supported)

Control ioctls:
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:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK (Not Supported) test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK (Not Supported)
test VIDIOC_TRY_FMT: OK (Not Supported)
test VIDIOC_S_FMT: OK (Not Supported)
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:
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:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK (Not Supported) test CREATE_BUFS maximum buffers: OK
test VIDIOC_EXPBUF: OK (Not Supported)
test Requests: OK (Not Supported)

Total for starfive-camss device /dev/v4l-subdev1: 80, Succeeded: 80, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for starfive-camss device /dev/v4l-subdev2:

Driver Info:

	Driver version   : 6.8.0
	Capabilities     : 0x00000000
	Client Capabilities: 0x0000000000000002
interval-uses-which Media Driver Info:
	Driver name      : starfive-camss
	Model            : Starfive Camera Subsystem
	Serial           :
	Bus info         : platform:19840000.isp
	Media version    : 6.8.0
	Hardware revision: 0x00000000 (0)
	Driver version   : 6.8.0
Interface Info:
	ID               : 0x03000027
	Type             : V4L Sub-Device
Entity Info:
	ID               : 0x0000001f (31)
	Name             : imx219 6-0010
	Function         : Camera Sensor
	Pad 0x01000020   : 0: Source
	  Link 0x02000021: to remote pad 0x1000016 of entity 'cdns_csi2rx.19800000.csi' (Video Interface Bridge): Data, Enabled, Immutable

Required ioctls:
test MC information (see 'Media Driver Info' above): OK test VIDIOC_SUDBEV_QUERYCAP: OK
test invalid ioctls: OK

Allow for multiple opens:
test second /dev/v4l-subdev2 open: OK
test VIDIOC_SUBDEV_QUERYCAP: OK
test for unlimited opens: OK

Debug ioctls:
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 (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 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 (Not Supported) 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)

Sub-Device ioctls (Source Pad 0):
Try Stream 0
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK
test Try VIDIOC_SUBDEV_G/S_FMT: OK
warn: v4l2-test-subdevs.cpp(566): VIDIOC_SUBDEV_G_SELECTION is supported for target 0 but not VIDIOC_SUBDEV_S_SELECTION
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK
Active Stream 0
test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK
test Active VIDIOC_SUBDEV_G/S_FMT: OK
warn: v4l2-test-subdevs.cpp(566): VIDIOC_SUBDEV_G_SELECTION is supported for target 0 but not VIDIOC_SUBDEV_S_SELECTION
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK
test Active VIDIOC_SUBDEV_G/S_FRAME_INTERVAL: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 17 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK (Not Supported) test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK (Not Supported)
test VIDIOC_TRY_FMT: OK (Not Supported)
test VIDIOC_S_FMT: OK (Not Supported)
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:
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:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK (Not Supported) test CREATE_BUFS maximum buffers: OK
test VIDIOC_EXPBUF: OK (Not Supported)
test Requests: OK (Not Supported)

Total for starfive-camss device /dev/v4l-subdev2: 52, Succeeded: 52, Failed: 0, Warnings: 2

Grand Total for starfive-camss device /dev/media0: 347, Succeeded: 345, Failed: 2, Warnings: 2

Two warnings are from the imx219, can ignore them.

Changhuang Liang (7):
staging: media: starfive: Replaced current_fmt with get from sd_state
staging: media: starfive: Add raw pad for ISP
staging: media: starfive: Sink rectangle set to ISP source pad
staging: media: starfive: Add multi streams for ISP
staging: media: starfive: Add ISP raw video device
staging: media: starfive: Add raw output stride configure
admin-guide: media: Update documents for StarFive Camera Subsystem

 .../admin-guide/media/starfive_camss.rst      | 11 ++-
 .../media/starfive_camss_graph.dot            | 20 +++--
 .../staging/media/starfive/camss/stf-camss.c  | 19 +++++
 .../media/starfive/camss/stf-capture.c        | 58 ++++++++++++-
 .../media/starfive/camss/stf-isp-hw-ops.c     | 23 +++--
 .../staging/media/starfive/camss/stf-isp.c    | 83 ++++++++++++++-----
 .../staging/media/starfive/camss/stf-isp.h    |  9 +-
 .../staging/media/starfive/camss/stf-video.h  |  1 +
 8 files changed, 178 insertions(+), 46 deletions(-)

--
2.25.1

#1 lore raw

PATCH 1/7 staging: media: starfive: Replaced current_fmt with get from sd_state

current_fmt only can store one pad format, when setting other pad it will be overwrote. Replaced it with get from sd_state directly.

---
 .../media/starfive/camss/stf-isp-hw-ops.c     | 10 ++++---
 .../staging/media/starfive/camss/stf-isp.c    | 26 +++++++++++++++----
 .../staging/media/starfive/camss/stf-isp.h    |  3 ++-
 3 files changed, 30 insertions(+), 9 deletions(-)
drivers/staging/media/starfive/camss/stf-isp-hw-ops.c +7 -3
index c34631ff9422..b933d425cbd0 100644
@@ -345,7 +345,6 @@ void stf_isp_init_cfg(struct stf_isp_dev *isp_dev)
 static void stf_isp_config_crop(struct stfcamss *stfcamss,
 				struct v4l2_rect *crop)
 {
-	u32 bpp = stfcamss->isp_dev.current_fmt->bpp;
 	u32 val;
 
 	val = VSTART_CAP(crop->top) | HSTART_CAP(crop->left);
@@ -357,9 +356,14 @@ static void stf_isp_config_crop(struct stfcamss *stfcamss,
 
 	val = H_ACT_CAP(crop->height) | W_ACT_CAP(crop->width);
 	stf_isp_reg_write(stfcamss, ISP_REG_PIPELINE_XY_SIZE, val);
+}
+
+void stf_isp_config_yuv_out_stride(struct stf_isp_dev *isp_dev,
+				   u32 width, u8 bpp)
+{
+	u32 val = ALIGN(width * bpp / 8, STFCAMSS_FRAME_WIDTH_ALIGN_8);
 
-	val = ALIGN(crop->width * bpp / 8, STFCAMSS_FRAME_WIDTH_ALIGN_8);
-	stf_isp_reg_write(stfcamss, ISP_REG_STRIDE, val);
+	stf_isp_reg_write(isp_dev->stfcamss, ISP_REG_STRIDE, val);
 }
 
 static void stf_isp_config_raw_fmt(struct stfcamss *stfcamss, u32 mcode)
drivers/staging/media/starfive/camss/stf-isp.c +21 -5
index d50616ef351e..a5573abe0d7b 100644
@@ -46,6 +46,19 @@ stf_g_fmt_by_mcode(const struct stf_isp_format_table *fmt_table, u32 mcode)
 	return NULL;
 }
 
+static int stf_isp_g_index_by_mcode(const struct stf_isp_format_table *fmt_table,
+				    u32 mcode)
+{
+	int i;
+
+	for (i = 0; i < fmt_table->nfmts; i++) {
+		if (fmt_table->fmts[i].code == mcode)
+			return i;
+	}
+
+	return -EINVAL;
+}
+
 int stf_isp_init(struct stfcamss *stfcamss)
 {
 	struct stf_isp_dev *isp_dev = &stfcamss->isp_dev;
@@ -53,7 +66,6 @@ int stf_isp_init(struct stfcamss *stfcamss)
 	isp_dev->stfcamss = stfcamss;
 	isp_dev->formats = isp_formats_st7110;
 	isp_dev->nformats = ARRAY_SIZE(isp_formats_st7110);
-	isp_dev->current_fmt = &isp_formats_source[0];
 
 	return 0;
 }
@@ -61,18 +73,25 @@ int stf_isp_init(struct stfcamss *stfcamss)
 static int isp_set_stream(struct v4l2_subdev *sd, int enable)
 {
 	struct stf_isp_dev *isp_dev = v4l2_get_subdevdata(sd);
+	const struct stf_isp_format_table *fmt_t_src;
+	struct v4l2_mbus_framefmt *fmt, *fmt_src;
 	struct v4l2_subdev_state *sd_state;
-	struct v4l2_mbus_framefmt *fmt;
 	struct v4l2_rect *crop;
+	int src;
 
 	sd_state = v4l2_subdev_lock_and_get_active_state(sd);
+	fmt_t_src = &isp_dev->formats[STF_ISP_PAD_SRC];
 	fmt = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SINK);
+	fmt_src = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SRC);
 	crop = v4l2_subdev_state_get_crop(sd_state, STF_ISP_PAD_SRC);
+	src = stf_isp_g_index_by_mcode(fmt_t_src, fmt_src->code);
 
 	if (enable) {
 		stf_isp_reset(isp_dev);
 		stf_isp_init_cfg(isp_dev);
 		stf_isp_settings(isp_dev, crop, fmt->code);
+		stf_isp_config_yuv_out_stride(isp_dev, crop->width,
+					      fmt_t_src->fmts[src].bpp);
 		stf_isp_stream_set(isp_dev);
 	}
 
@@ -157,9 +176,6 @@ static int isp_set_format(struct v4l2_subdev *sd,
 	isp_try_format(isp_dev, state, fmt->pad, &fmt->format);
 	*format = fmt->format;
 
-	isp_dev->current_fmt = stf_g_fmt_by_mcode(&isp_dev->formats[fmt->pad],
-						  fmt->format.code);
-
 	/* Propagate to in crop */
 	if (fmt->pad == STF_ISP_PAD_SINK) {
 		struct v4l2_subdev_selection sel = { 0 };
drivers/staging/media/starfive/camss/stf-isp.h +2 -1
index 955cbb048363..07d6c2758253 100644
@@ -413,7 +413,6 @@ struct stf_isp_dev {
 	const struct stf_isp_format_table *formats;
 	unsigned int nformats;
 	struct v4l2_subdev *source_subdev;
-	const struct stf_isp_format *current_fmt;
 };
 
 int stf_isp_reset(struct stf_isp_dev *isp_dev);
@@ -421,6 +420,8 @@ void stf_isp_init_cfg(struct stf_isp_dev *isp_dev);
 void stf_isp_settings(struct stf_isp_dev *isp_dev,
 		      struct v4l2_rect *crop, u32 mcode);
 void stf_isp_stream_set(struct stf_isp_dev *isp_dev);
+void stf_isp_config_yuv_out_stride(struct stf_isp_dev *isp_dev,
+				   u32 width, u8 bpp);
 int stf_isp_init(struct stfcamss *stfcamss);
 int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev);
 int stf_isp_unregister(struct stf_isp_dev *isp_dev);
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v1 1/7] staging: media: starfive: Replaced current_fmt with get from sd_state

Quoted 3 lines · Changhuang Liang

current_fmt only can store one pad format, when setting other pad it will be overwrote. Replaced it with get from sd_state directly.

These commit descriptions are kind of hard to understand so I have proposed new commit messages.

Subject: staging: media: starfive: Get rid of current_fmt

We want to support mutiple formats so saving one "current_fmt" doesn't work. This was only used to set the ISP_REG_STRIDE so use the sd_state directly for that and delete the ->current_fmt pointer. No functional change.

regards,
dan carpenter

#3 lore raw

回复: [PATCH v1 1/7] staging: media: starfive: Replaced current_fmt with get from sd_state

Hi, Dan

Thanks for your comments.

Quoted 17 lines

-----邮件原件-----
发件人: Dan Carpenter <[email protected]>
发送时间: 2024年3月6日 22:23
收件人: Changhuang Liang <[email protected]>
抄送: Mauro Carvalho Chehab <[email protected]>; Greg Kroah-Hartman <[email protected]>; Hans Verkuil <[email protected]>; Laurent Pinchart <[email protected]>; Jack Zhu <[email protected]>; [email protected]; [email protected]; [email protected] 主题: Re: [PATCH v1 1/7] staging: media: starfive: Replaced current_fmt with get from sd_state

Quoted 3 lines · Changhuang Liang

current_fmt only can store one pad format, when setting other pad it will be overwrote. Replaced it with get from sd_state directly.

Quoted 9 lines

These commit descriptions are kind of hard to understand so I have proposed new commit messages.

Subject: staging: media: starfive: Get rid of current_fmt

We want to support mutiple formats so saving one "current_fmt" doesn't work. This was only used to set the ISP_REG_STRIDE so use the sd_state directly for that and delete the ->current_fmt pointer. No functional change.

I will re-change the patch description and add more details to all the patches.

Thanks

#4 lore raw

PATCH 2/7 staging: media: starfive: Add raw pad for ISP

In reply to Changhuang Liang

Add raw pad for ISP, it supported the conversion of RAW10 into RAW12.

---
 .../staging/media/starfive/camss/stf-isp.c    | 26 ++++++++++++-------
 .../staging/media/starfive/camss/stf-isp.h    |  1 +
 2 files changed, 17 insertions(+), 10 deletions(-)
drivers/staging/media/starfive/camss/stf-isp.c +16 -10
index a5573abe0d7b..6bab0ac23120 100644
@@ -10,9 +10,6 @@
 
 #include "stf-camss.h"
 
-#define SINK_FORMATS_INDEX	0
-#define SOURCE_FORMATS_INDEX	1
-
 static int isp_set_selection(struct v4l2_subdev *sd,
 			     struct v4l2_subdev_state *state,
 			     struct v4l2_subdev_selection *sel);
@@ -28,9 +25,17 @@ static const struct stf_isp_format isp_formats_source[] = {
 	{ MEDIA_BUS_FMT_YUYV8_1_5X8, 8 },
 };
 
+static const struct stf_isp_format isp_formats_source_raw[] = {
+	{ MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
+	{ MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
+	{ MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
+	{ MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
+};
+
 static const struct stf_isp_format_table isp_formats_st7110[] = {
 	{ isp_formats_sink, ARRAY_SIZE(isp_formats_sink) },
 	{ isp_formats_source, ARRAY_SIZE(isp_formats_source) },
+	{ isp_formats_source_raw, ARRAY_SIZE(isp_formats_source_raw) },
 };
 
 static const struct stf_isp_format *
@@ -113,10 +118,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev,
 		return;
 	}
 
-	if (pad == STF_ISP_PAD_SINK)
-		formats = &isp_dev->formats[SINK_FORMATS_INDEX];
-	else if (pad == STF_ISP_PAD_SRC)
-		formats = &isp_dev->formats[SOURCE_FORMATS_INDEX];
+	formats = &isp_dev->formats[pad];
 
 	fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH,
 			     STFCAMSS_FRAME_MAX_WIDTH);
@@ -142,7 +144,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd,
 		if (code->index >= ARRAY_SIZE(isp_formats_sink))
 			return -EINVAL;
 
-		formats = &isp_dev->formats[SINK_FORMATS_INDEX];
+		formats = &isp_dev->formats[code->pad];
 		code->code = formats->fmts[code->index].code;
 	} else {
 		struct v4l2_mbus_framefmt *sink_fmt;
@@ -281,8 +283,11 @@ static int isp_set_selection(struct v4l2_subdev *sd,
 		crop.target = V4L2_SEL_TGT_CROP;
 		crop.r = *rect;
 		isp_set_selection(sd, state, &crop);
+
+		crop.pad = STF_ISP_PAD_SRC_RAW;
+		isp_set_selection(sd, state, &crop);
 	} else if (sel->target == V4L2_SEL_TGT_CROP &&
-		   sel->pad == STF_ISP_PAD_SRC) {
+		   (sel->pad == STF_ISP_PAD_SRC || sel->pad == STF_ISP_PAD_SRC_RAW)) {
 		struct v4l2_subdev_format fmt = { 0 };
 
 		rect = v4l2_subdev_state_get_crop(state, sel->pad);
@@ -294,7 +299,7 @@ static int isp_set_selection(struct v4l2_subdev *sd,
 
 		/* Reset source pad format width and height */
 		fmt.which = sel->which;
-		fmt.pad = STF_ISP_PAD_SRC;
+		fmt.pad = sel->pad;
 		fmt.format.width = rect->width;
 		fmt.format.height = rect->height;
 		isp_set_format(sd, state, &fmt);
@@ -361,6 +366,7 @@ int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev)
 
 	pads[STF_ISP_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
 	pads[STF_ISP_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE;
+	pads[STF_ISP_PAD_SRC_RAW].flags = MEDIA_PAD_FL_SOURCE;
 
 	sd->entity.function = MEDIA_ENT_F_PROC_VIDEO_ISP;
 	sd->entity.ops = &isp_media_ops;
drivers/staging/media/starfive/camss/stf-isp.h +1 -0
index 07d6c2758253..4fc5cfac115c 100644
@@ -393,6 +393,7 @@
 enum stf_isp_pad_id {
 	STF_ISP_PAD_SINK = 0,
 	STF_ISP_PAD_SRC,
+	STF_ISP_PAD_SRC_RAW,
 	STF_ISP_PAD_MAX
 };
 
Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH v1 2/7] staging: media: starfive: Add raw pad for ISP

Quoted 2 lines · Changhuang Liang

Add raw pad for ISP, it supported the conversion of RAW10 into RAW12.

To be honest, I don't understand what "it supported the conversion of RAW10 into RAW12" means. I don't think that this patch has any impact on user space but I'm not 100% sure.

A lot of this patch is just reformating stuff and it would be easier to review if the reformating were separated into a separate patch.

patch 2: Clean pad selection in isp_try_format()

The code to select isp_dev->formats[] is overly complicated. We can just use the "pad" as the index. This will making adding new pads easier in future patches. No functional change.

patch 3: Add raw pad for ISP

Quoted 11 lines
---
 .../staging/media/starfive/camss/stf-isp.c    | 26 ++++++++++++-------
 .../staging/media/starfive/camss/stf-isp.h    |  1 +
 2 files changed, 17 insertions(+), 10 deletions(-)
drivers/staging/media/starfive/camss/stf-isp.c +0 -0
index a5573abe0d7b..6bab0ac23120 100644

drivers/staging/media/starfive/camss/stf-isp.c line 15

Quoted 6 lines
drivers/staging/media/starfive/camss/stf-isp.c +0 -3
@@ -10,9 +10,6 @@
 
 #include "stf-camss.h"
 
-#define SINK_FORMATS_INDEX	0
-#define SOURCE_FORMATS_INDEX	1
-

This is cleanup. patch 2.

Quoted 4 lines
drivers/staging/media/starfive/camss/stf-isp.c +0 -0
 static int isp_set_selection(struct v4l2_subdev *sd,
 			     struct v4l2_subdev_state *state,
 			     struct v4l2_subdev_selection *sel);

drivers/staging/media/starfive/camss/stf-isp.c static const struct stf_isp_format isp_formats_source[] = { · line 34

Quoted 10 lines
drivers/staging/media/starfive/camss/stf-isp.c +7 -0
@@ -28,9 +25,17 @@ static const struct stf_isp_format isp_formats_source[] = {
 	{ MEDIA_BUS_FMT_YUYV8_1_5X8, 8 },
 };
 
+static const struct stf_isp_format isp_formats_source_raw[] = {
+	{ MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
+	{ MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
+	{ MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
+	{ MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
+};
+

patch 3.

drivers/staging/media/starfive/camss/stf-isp.c static const struct stf_isp_format isp_formats_source[] = { · line 39

Quoted 5 lines
drivers/staging/media/starfive/camss/stf-isp.c +1 -0
 static const struct stf_isp_format_table isp_formats_st7110[] = {
 	{ isp_formats_sink, ARRAY_SIZE(isp_formats_sink) },
 	{ isp_formats_source, ARRAY_SIZE(isp_formats_source) },
+	{ isp_formats_source_raw, ARRAY_SIZE(isp_formats_source_raw) },
 };

patch 3.

drivers/staging/media/starfive/camss/stf-isp.c static void isp_try_format(struct stf_isp_dev *isp_dev, · line 121

Quoted 11 lines
drivers/staging/media/starfive/camss/stf-isp.c +1 -4
 static const struct stf_isp_format *
@@ -113,10 +118,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev,
 		return;
 	}
 
-	if (pad == STF_ISP_PAD_SINK)
-		formats = &isp_dev->formats[SINK_FORMATS_INDEX];
-	else if (pad == STF_ISP_PAD_SRC)
-		formats = &isp_dev->formats[SOURCE_FORMATS_INDEX];
+	formats = &isp_dev->formats[pad];

patch 2.

drivers/staging/media/starfive/camss/stf-isp.c static int isp_enum_mbus_code(struct v4l2_subdev *sd, · line 147

Quoted 9 lines
drivers/staging/media/starfive/camss/stf-isp.c +1 -1
 	fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH,
 			     STFCAMSS_FRAME_MAX_WIDTH);
@@ -142,7 +144,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd,
 		if (code->index >= ARRAY_SIZE(isp_formats_sink))
 			return -EINVAL;
 
-		formats = &isp_dev->formats[SINK_FORMATS_INDEX];
+		formats = &isp_dev->formats[code->pad];

patch 2.

drivers/staging/media/starfive/camss/stf-isp.c static int isp_set_selection(struct v4l2_subdev *sd, · line 288

Quoted 10 lines
drivers/staging/media/starfive/camss/stf-isp.c +3 -0
 		code->code = formats->fmts[code->index].code;
 	} else {
 		struct v4l2_mbus_framefmt *sink_fmt;
@@ -281,8 +283,11 @@ static int isp_set_selection(struct v4l2_subdev *sd,
 		crop.target = V4L2_SEL_TGT_CROP;
 		crop.r = *rect;
 		isp_set_selection(sd, state, &crop);
+
+		crop.pad = STF_ISP_PAD_SRC_RAW;
+		isp_set_selection(sd, state, &crop);

patch 3.

drivers/staging/media/starfive/camss/stf-isp.c static int isp_set_selection(struct v4l2_subdev *sd, · line 290

Quoted 3 lines
drivers/staging/media/starfive/camss/stf-isp.c +1 -1
 	} else if (sel->target == V4L2_SEL_TGT_CROP &&
-		   sel->pad == STF_ISP_PAD_SRC) {
+		   (sel->pad == STF_ISP_PAD_SRC || sel->pad == STF_ISP_PAD_SRC_RAW)) {

patch 3.

drivers/staging/media/starfive/camss/stf-isp.c static int isp_set_selection(struct v4l2_subdev *sd, · line 302

Quoted 9 lines
drivers/staging/media/starfive/camss/stf-isp.c +1 -1
 		struct v4l2_subdev_format fmt = { 0 };
 
 		rect = v4l2_subdev_state_get_crop(state, sel->pad);
@@ -294,7 +299,7 @@ static int isp_set_selection(struct v4l2_subdev *sd,
 
 		/* Reset source pad format width and height */
 		fmt.which = sel->which;
-		fmt.pad = STF_ISP_PAD_SRC;
+		fmt.pad = sel->pad;

patch 2.

drivers/staging/media/starfive/camss/stf-isp.c int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev) · line 369

Quoted 8 lines
drivers/staging/media/starfive/camss/stf-isp.c +1 -0
 		fmt.format.width = rect->width;
 		fmt.format.height = rect->height;
 		isp_set_format(sd, state, &fmt);
@@ -361,6 +366,7 @@ int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev)
 
 	pads[STF_ISP_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
 	pads[STF_ISP_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE;
+	pads[STF_ISP_PAD_SRC_RAW].flags = MEDIA_PAD_FL_SOURCE;

patch 3.

drivers/staging/media/starfive/camss/stf-isp.h line 396

Quoted 12 lines
drivers/staging/media/starfive/camss/stf-isp.c +0 -0
 	sd->entity.function = MEDIA_ENT_F_PROC_VIDEO_ISP;
 	sd->entity.ops = &isp_media_ops;
drivers/staging/media/starfive/camss/stf-isp.h +1 -0
index 07d6c2758253..4fc5cfac115c 100644
@@ -393,6 +393,7 @@
 enum stf_isp_pad_id {
 	STF_ISP_PAD_SINK = 0,
 	STF_ISP_PAD_SRC,
+	STF_ISP_PAD_SRC_RAW,

patch 3.

drivers/staging/media/starfive/camss/stf-isp.h line 398

Quoted 2 lines
drivers/staging/media/starfive/camss/stf-isp.h +0 -0
 	STF_ISP_PAD_MAX
 };

regards,
dan carpenter

#6 lore raw

回复: [PATCH v1 2/7] staging: media: starfive: Add raw pad for ISP

Hi Dan

Quoted 10 lines

Re: [PATCH v1 2/7] staging: media: starfive: Add raw pad for ISP

Quoted 2 lines · Changhuang Liang

Add raw pad for ISP, it supported the conversion of RAW10 into RAW12.

To be honest, I don't understand what "it supported the conversion of RAW10 into RAW12" means. I don't think that this patch has any impact on user space but I'm not 100% sure.

For StarFive ISP, the input format is RAW 10, which is converted to RAW 12 after ISP RAW pad output.

Quoted 11 lines

A lot of this patch is just reformating stuff and it would be easier to review if the reformating were separated into a separate patch.

patch 2: Clean pad selection in isp_try_format()

The code to select isp_dev->formats[] is overly complicated. We can just use the "pad" as the index. This will making adding new pads easier in future patches. No functional change.

patch 3: Add raw pad for ISP

Yes, this patch can also be split into two patches

regards,
Changhuang

#7 lore raw

PATCH 3/7 staging: media: starfive: Sink rectangle set to ISP source pad

In reply to Changhuang Liang

Sink rectangle will be valid for all source pads.

---
 drivers/staging/media/starfive/camss/stf-isp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/starfive/camss/stf-isp.c +1 -1
index 6bab0ac23120..9b5745669fa6 100644
@@ -88,7 +88,7 @@ static int isp_set_stream(struct v4l2_subdev *sd, int enable)
 	fmt_t_src = &isp_dev->formats[STF_ISP_PAD_SRC];
 	fmt = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SINK);
 	fmt_src = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SRC);
-	crop = v4l2_subdev_state_get_crop(sd_state, STF_ISP_PAD_SRC);
+	crop = v4l2_subdev_state_get_crop(sd_state, STF_ISP_PAD_SINK);
 	src = stf_isp_g_index_by_mcode(fmt_t_src, fmt_src->code);
 
 	if (enable) {
Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH v1 3/7] staging: media: starfive: Sink rectangle set to ISP source pad

Quoted 2 lines · Changhuang Liang

Sink rectangle will be valid for all source pads.

This commit message is just really unclear. What does "Sink rectangle set to ISP source pad" even mean? A better subject would probably be "staging: media: starfive: Use PAD_SINK instead of PAD_SRC for crop"

But why are we making this change? It's not clear.

regards,
dan carpenter

#9 lore raw

PATCH 4/7 staging: media: starfive: Add multi streams for ISP

In reply to Changhuang Liang

ISP support multi streams output. Add stream_count to save the number of stream on.

---
 .../staging/media/starfive/camss/stf-isp.c    | 28 +++++++++++++------
 .../staging/media/starfive/camss/stf-isp.h    |  1 +
 2 files changed, 21 insertions(+), 8 deletions(-)
drivers/staging/media/starfive/camss/stf-isp.c +20 -8
index 9b5745669fa6..1bfd336b14a1 100644
@@ -92,15 +92,27 @@ static int isp_set_stream(struct v4l2_subdev *sd, int enable)
 	src = stf_isp_g_index_by_mcode(fmt_t_src, fmt_src->code);
 
 	if (enable) {
-		stf_isp_reset(isp_dev);
-		stf_isp_init_cfg(isp_dev);
-		stf_isp_settings(isp_dev, crop, fmt->code);
-		stf_isp_config_yuv_out_stride(isp_dev, crop->width,
-					      fmt_t_src->fmts[src].bpp);
-		stf_isp_stream_set(isp_dev);
-	}
+		if (!isp_dev->stream_count) {
+			stf_isp_reset(isp_dev);
+			stf_isp_init_cfg(isp_dev);
+			stf_isp_settings(isp_dev, crop, fmt->code);
+			stf_isp_config_yuv_out_stride(isp_dev, crop->width,
+						      fmt_t_src->fmts[src].bpp);
+			stf_isp_stream_set(isp_dev);
+
+			v4l2_subdev_call(isp_dev->source_subdev, video,
+					 s_stream, enable);
+		}
+
+		isp_dev->stream_count++;
+	} else {
+		isp_dev->stream_count--;
 
-	v4l2_subdev_call(isp_dev->source_subdev, video, s_stream, enable);
+		if (!isp_dev->stream_count) {
+			v4l2_subdev_call(isp_dev->source_subdev, video,
+					 s_stream, enable);
+		}
+	}
 
 	v4l2_subdev_unlock_state(sd_state);
 	return 0;
drivers/staging/media/starfive/camss/stf-isp.h +1 -0
index 4fc5cfac115c..30e4eb29f077 100644
@@ -414,6 +414,7 @@ struct stf_isp_dev {
 	const struct stf_isp_format_table *formats;
 	unsigned int nformats;
 	struct v4l2_subdev *source_subdev;
+	unsigned int stream_count;
 };
 
 int stf_isp_reset(struct stf_isp_dev *isp_dev);
Signature · 1 line
2.25.1
#10 lore raw

Re: [PATCH v1 4/7] staging: media: starfive: Add multi streams for ISP

Quoted 3 lines · Changhuang Liang

ISP support multi streams output. Add stream_count to save the number of stream on.

The ISP can support multiple output streams. Introduce stream_count to store the number of streams. No functional change.

Quoted 21 lines
---
 .../staging/media/starfive/camss/stf-isp.c    | 28 +++++++++++++------
 .../staging/media/starfive/camss/stf-isp.h    |  1 +
 2 files changed, 21 insertions(+), 8 deletions(-)
drivers/staging/media/starfive/camss/stf-isp.c +0 -7
index 9b5745669fa6..1bfd336b14a1 100644
@@ -92,15 +92,27 @@ static int isp_set_stream(struct v4l2_subdev *sd, int enable)
 	src = stf_isp_g_index_by_mcode(fmt_t_src, fmt_src->code);
 
 	if (enable) {
-		stf_isp_reset(isp_dev);
-		stf_isp_init_cfg(isp_dev);
-		stf_isp_settings(isp_dev, crop, fmt->code);
-		stf_isp_config_yuv_out_stride(isp_dev, crop->width,
-					      fmt_t_src->fmts[src].bpp);
-		stf_isp_stream_set(isp_dev);
-	}

drivers/staging/media/starfive/camss/stf-isp.c static int isp_set_stream(struct v4l2_subdev *sd, int enable) · line 104

Quoted 10 lines
drivers/staging/media/starfive/camss/stf-isp.c +10 -0
+		if (!isp_dev->stream_count) {
+			stf_isp_reset(isp_dev);
+			stf_isp_init_cfg(isp_dev);
+			stf_isp_settings(isp_dev, crop, fmt->code);
+			stf_isp_config_yuv_out_stride(isp_dev, crop->width,
+						      fmt_t_src->fmts[src].bpp);
+			stf_isp_stream_set(isp_dev);
+
+			v4l2_subdev_call(isp_dev->source_subdev, video,
+					 s_stream, enable);

s/enable/true/

drivers/staging/media/starfive/camss/stf-isp.c static int isp_set_stream(struct v4l2_subdev *sd, int enable) · line 113

Quoted 10 lines
drivers/staging/media/starfive/camss/stf-isp.c +8 -1
+		}
+
+		isp_dev->stream_count++;
+	} else {
+		isp_dev->stream_count--;
 
-	v4l2_subdev_call(isp_dev->source_subdev, video, s_stream, enable);
+		if (!isp_dev->stream_count) {
+			v4l2_subdev_call(isp_dev->source_subdev, video,
+					 s_stream, enable);

s/enable/false/

drivers/staging/media/starfive/camss/stf-isp.c static int isp_set_stream(struct v4l2_subdev *sd, int enable) · line 115

Quoted 2 lines
drivers/staging/media/starfive/camss/stf-isp.c +2 -0
+		}
+	}

regards,
dan carpenter

#11 lore raw

PATCH 5/7 staging: media: starfive: Add ISP raw video device

In reply to Changhuang Liang

Add raw video device to capture raw data from ISP.

---
 .../staging/media/starfive/camss/stf-camss.c  | 19 ++++++
 .../media/starfive/camss/stf-capture.c        | 58 ++++++++++++++++++-
 .../staging/media/starfive/camss/stf-video.h  |  1 +
 3 files changed, 77 insertions(+), 1 deletion(-)
drivers/staging/media/starfive/camss/stf-camss.c +19 -0
index 81fc39f20615..90ac8b67c76e 100644
@@ -126,6 +126,7 @@ static int stfcamss_of_parse_ports(struct stfcamss *stfcamss)
 static int stfcamss_register_devs(struct stfcamss *stfcamss)
 {
 	struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV];
+	struct stf_capture *cap_raw = &stfcamss->captures[STF_CAPTURE_RAW];
 	struct stf_isp_dev *isp_dev = &stfcamss->isp_dev;
 	int ret;
 
@@ -150,8 +151,18 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss)
 
 	cap_yuv->video.source_subdev = &isp_dev->subdev;
 
+	ret = media_create_pad_link(&isp_dev->subdev.entity, STF_ISP_PAD_SRC_RAW,
+				    &cap_raw->video.vdev.entity, 0, 0);
+	if (ret)
+		goto err_rm_links0;
+
+	cap_raw->video.source_subdev = &isp_dev->subdev;
+
 	return ret;
 
+err_rm_links0:
+	media_entity_remove_links(&isp_dev->subdev.entity);
+	media_entity_remove_links(&cap_yuv->video.vdev.entity);
 err_cap_unregister:
 	stf_capture_unregister(stfcamss);
 err_isp_unregister:
@@ -162,6 +173,14 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss)
 
 static void stfcamss_unregister_devs(struct stfcamss *stfcamss)
 {
+	struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV];
+	struct stf_capture *cap_raw = &stfcamss->captures[STF_CAPTURE_RAW];
+	struct stf_isp_dev *isp_dev = &stfcamss->isp_dev;
+
+	media_entity_remove_links(&isp_dev->subdev.entity);
+	media_entity_remove_links(&cap_raw->video.vdev.entity);
+	media_entity_remove_links(&cap_yuv->video.vdev.entity);
+
 	stf_isp_unregister(&stfcamss->isp_dev);
 	stf_capture_unregister(stfcamss);
 }
drivers/staging/media/starfive/camss/stf-capture.c +57 -1

135 lines not on this page · raw message

drivers/staging/media/starfive/camss/stf-video.h +1 -0
index 90c73c0dee89..cad861aae31c 100644
@@ -37,6 +37,7 @@ enum stf_v_line_id {
 enum stf_capture_type {
 	STF_CAPTURE_DUMP = 0,
 	STF_CAPTURE_YUV,
+	STF_CAPTURE_RAW,
 	STF_CAPTURE_NUM,
 };
 
Signature · 1 line
2.25.1
#12 lore raw

Re: [PATCH v1 5/7] staging: media: starfive: Add ISP raw video device

I wasn't able to get this patch to apply. I tried applying the patch mentioned in the cover letter first but it didn't help... It's not your fault, but it made reviewing the rest hard so I might have made some mistakes.

Quoted 26 lines · Changhuang Liang

Add raw video device to capture raw data from ISP.

---
 .../staging/media/starfive/camss/stf-camss.c  | 19 ++++++
 .../media/starfive/camss/stf-capture.c        | 58 ++++++++++++++++++-
 .../staging/media/starfive/camss/stf-video.h  |  1 +
 3 files changed, 77 insertions(+), 1 deletion(-)
drivers/staging/media/starfive/camss/stf-camss.c +2 -0
index 81fc39f20615..90ac8b67c76e 100644
@@ -126,6 +126,7 @@ static int stfcamss_of_parse_ports(struct stfcamss *stfcamss)
 static int stfcamss_register_devs(struct stfcamss *stfcamss)
 {
 	struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV];
+	struct stf_capture *cap_raw = &stfcamss->captures[STF_CAPTURE_RAW];
 	struct stf_isp_dev *isp_dev = &stfcamss->isp_dev;
 	int ret;
 
@@ -150,8 +151,18 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss)
 
 	cap_yuv->video.source_subdev = &isp_dev->subdev;
 
+	ret = media_create_pad_link(&isp_dev->subdev.entity, STF_ISP_PAD_SRC_RAW,

drivers/staging/media/starfive/camss/stf-camss.c static int stfcamss_register_devs(struct stfcamss *stfcamss) · line 164

Quoted 10 lines
drivers/staging/media/starfive/camss/stf-camss.c +8 -0
+				    &cap_raw->video.vdev.entity, 0, 0);
+	if (ret)
+		goto err_rm_links0;
+
+	cap_raw->video.source_subdev = &isp_dev->subdev;
+
 	return ret;
 
+err_rm_links0:
+	media_entity_remove_links(&isp_dev->subdev.entity);

I don't think this line is correct. I think we only need to remove &cap_yuv->video.vdev.entity.

drivers/staging/media/starfive/camss/stf-camss.c static int stfcamss_register_devs(struct stfcamss *stfcamss) · line 180

Quoted 13 lines
drivers/staging/media/starfive/camss/stf-camss.c +6 -0
+	media_entity_remove_links(&cap_yuv->video.vdev.entity);
 err_cap_unregister:
 	stf_capture_unregister(stfcamss);
 err_isp_unregister:
@@ -162,6 +173,14 @@ static int stfcamss_register_devs(struct stfcamss *stfcamss)
 
 static void stfcamss_unregister_devs(struct stfcamss *stfcamss)
 {
+	struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV];
+	struct stf_capture *cap_raw = &stfcamss->captures[STF_CAPTURE_RAW];
+	struct stf_isp_dev *isp_dev = &stfcamss->isp_dev;
+
+	media_entity_remove_links(&isp_dev->subdev.entity);

I think this line should be deleted.

drivers/staging/media/starfive/camss/stf-camss.c static int stfcamss_register_devs(struct stfcamss *stfcamss) · line 182

Quoted 2 lines
drivers/staging/media/starfive/camss/stf-camss.c +2 -0
+	media_entity_remove_links(&cap_raw->video.vdev.entity);
+	media_entity_remove_links(&cap_yuv->video.vdev.entity);

I think this "&cap_yuv" should be submitted by itself as a bugfix patch.

drivers/staging/media/starfive/camss/stf-camss.c static int stfcamss_register_devs(struct stfcamss *stfcamss) · line 186

Quoted 4 lines
drivers/staging/media/starfive/camss/stf-camss.c +1 -0
+
 	stf_isp_unregister(&stfcamss->isp_dev);
 	stf_capture_unregister(stfcamss);
 }

regards,
dan carpenter

#13 lore raw

回复: [PATCH v1 5/7] staging: media: starfive: Add ISP raw video device

Hi, Dan

[...]

Quoted 7 lines

drivers/staging/media/starfive/camss/stf-camss.c static int stfcamss_register_devs(struct stfcamss *stfcamss) · line 164

Quoted 3 lines
drivers/staging/media/starfive/camss/stf-camss.c +2 -0
+err_rm_links0:
+	media_entity_remove_links(&isp_dev->subdev.entity);

I don't think this line is correct. I think we only need to remove &cap_yuv->video.vdev.entity.

The instance I refer to needs to clear both the source entity and the sink entity. See
https://elixir.bootlin.com/linux/v6.8-rc7/source/drivers/media/platform/verisilicon/hantro_drv.c#L855

Quoted 18 lines

drivers/staging/media/starfive/camss/stf-camss.c static int stfcamss_register_devs(struct stfcamss · line 176

Quoted 9 lines
drivers/staging/media/starfive/camss/stf-camss.c +2 -0
+	media_entity_remove_links(&cap_yuv->video.vdev.entity);
 err_cap_unregister:
 	stf_capture_unregister(stfcamss);
 err_isp_unregister:
@@ -162,6 +173,14 @@ static int stfcamss_register_devs(struct stfcamss
 *stfcamss)
 
 static void stfcamss_unregister_devs(struct stfcamss *stfcamss)  {
+	struct stf_capture *cap_yuv =

&stfcamss->captures[STF_CAPTURE_YUV];

Review static int stfcamss_register_devs(struct stfcamss · line 177

Quoted 1 line
(quoted diff) +1 -0
+	struct stf_capture *cap_raw =

&stfcamss->captures[STF_CAPTURE_RAW];

drivers/staging/media/starfive/camss/stf-camss.c static int stfcamss_register_devs(struct stfcamss *stfcamss) · line 180

Quoted 3 lines
drivers/staging/media/starfive/camss/stf-camss.c +3 -0
+	struct stf_isp_dev *isp_dev = &stfcamss->isp_dev;
+
+	media_entity_remove_links(&isp_dev->subdev.entity);

I think this line should be deleted.

Quoted 5 lines

drivers/staging/media/starfive/camss/stf-camss.c static int stfcamss_register_devs(struct stfcamss *stfcamss) · line 182

Quoted 2 lines
drivers/staging/media/starfive/camss/stf-camss.c +2 -0
+	media_entity_remove_links(&cap_raw->video.vdev.entity);
+	media_entity_remove_links(&cap_yuv->video.vdev.entity);

I think this "&cap_yuv" should be submitted by itself as a bugfix patch.

Yes.

Regards
Changhuang

#14 lore raw

Re: 回复: [PATCH v1 5/7] staging: media: starfive: Add ISP raw video device

Quoted 11 lines · Changhuang Liang

Hi, Dan

[...]

Quoted 7 lines

drivers/staging/media/starfive/camss/stf-camss.c static int stfcamss_register_devs(struct stfcamss *stfcamss) · line 164

Quoted 3 lines
drivers/staging/media/starfive/camss/stf-camss.c +2 -0
+err_rm_links0:
+	media_entity_remove_links(&isp_dev->subdev.entity);

I don't think this line is correct. I think we only need to remove &cap_yuv->video.vdev.entity.

Quoted 3 lines

The instance I refer to needs to clear both the source entity and the sink entity. See
https://elixir.bootlin.com/linux/v6.8-rc7/source/drivers/media/platform/verisilicon/hantro_drv.c#L855

Oh yeah. It's the same in v4l2_m2m_register_media_controller().

regards,
dan carpenter

#15 lore raw

PATCH 6/7 staging: media: starfive: Add raw output stride configure

In reply to Changhuang Liang

Add raw output stride to enable sent the aligned raw data to memory.

---
 .../staging/media/starfive/camss/stf-isp-hw-ops.c   | 13 +++++++++----
 drivers/staging/media/starfive/camss/stf-isp.c      | 11 ++++++++---
 drivers/staging/media/starfive/camss/stf-isp.h      |  4 ++--
 3 files changed, 19 insertions(+), 9 deletions(-)
drivers/staging/media/starfive/camss/stf-isp-hw-ops.c +9 -4
index b933d425cbd0..e7f60616bd7c 100644
@@ -366,6 +366,15 @@ void stf_isp_config_yuv_out_stride(struct stf_isp_dev *isp_dev,
 	stf_isp_reg_write(isp_dev->stfcamss, ISP_REG_STRIDE, val);
 }
 
+void stf_isp_config_raw_out_stride(struct stf_isp_dev *isp_dev,
+				   u32 width, u8 bpp)
+{
+	u32 val = ALIGN(width * bpp / 8, STFCAMSS_FRAME_WIDTH_ALIGN_128);
+
+	stf_isp_reg_write(isp_dev->stfcamss, ISP_REG_DUMP_CFG_1,
+			  DUMP_BURST_LEN(3) | val);
+}
+
 static void stf_isp_config_raw_fmt(struct stfcamss *stfcamss, u32 mcode)
 {
 	u32 val, val1;
@@ -417,10 +426,6 @@ void stf_isp_settings(struct stf_isp_dev *isp_dev,
 	stf_isp_config_crop(stfcamss, crop);
 	stf_isp_config_raw_fmt(stfcamss, mcode);
 
-	stf_isp_reg_set_bit(stfcamss, ISP_REG_DUMP_CFG_1,
-			    DUMP_BURST_LEN_MASK | DUMP_SD_MASK,
-			    DUMP_BURST_LEN(3));
-
 	stf_isp_reg_write(stfcamss, ISP_REG_ITIIWSR,
 			  ITI_HSIZE(IMAGE_MAX_HEIGH) |
 			  ITI_WSIZE(IMAGE_MAX_WIDTH));
drivers/staging/media/starfive/camss/stf-isp.c +8 -3
index 1bfd336b14a1..845446ba279c 100644
@@ -78,18 +78,21 @@ int stf_isp_init(struct stfcamss *stfcamss)
 static int isp_set_stream(struct v4l2_subdev *sd, int enable)
 {
 	struct stf_isp_dev *isp_dev = v4l2_get_subdevdata(sd);
-	const struct stf_isp_format_table *fmt_t_src;
-	struct v4l2_mbus_framefmt *fmt, *fmt_src;
+	const struct stf_isp_format_table *fmt_t_src, *fmt_t_raw;
+	struct v4l2_mbus_framefmt *fmt, *fmt_src, *fmt_raw;
 	struct v4l2_subdev_state *sd_state;
 	struct v4l2_rect *crop;
-	int src;
+	int src, raw;
 
 	sd_state = v4l2_subdev_lock_and_get_active_state(sd);
 	fmt_t_src = &isp_dev->formats[STF_ISP_PAD_SRC];
+	fmt_t_raw = &isp_dev->formats[STF_ISP_PAD_SRC_RAW];
 	fmt = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SINK);
 	fmt_src = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SRC);
+	fmt_raw = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SRC_RAW);
 	crop = v4l2_subdev_state_get_crop(sd_state, STF_ISP_PAD_SINK);
 	src = stf_isp_g_index_by_mcode(fmt_t_src, fmt_src->code);
+	raw = stf_isp_g_index_by_mcode(fmt_t_raw, fmt_raw->code);
 
 	if (enable) {
 		if (!isp_dev->stream_count) {
@@ -98,6 +101,8 @@ static int isp_set_stream(struct v4l2_subdev *sd, int enable)
 			stf_isp_settings(isp_dev, crop, fmt->code);
 			stf_isp_config_yuv_out_stride(isp_dev, crop->width,
 						      fmt_t_src->fmts[src].bpp);
+			stf_isp_config_raw_out_stride(isp_dev, crop->width,
+						      fmt_t_raw->fmts[raw].bpp);
 			stf_isp_stream_set(isp_dev);
 
 			v4l2_subdev_call(isp_dev->source_subdev, video,
drivers/staging/media/starfive/camss/stf-isp.h +2 -2
index 30e4eb29f077..dcbc42f0dfe4 100644
@@ -76,8 +76,6 @@
 #define DUMP_SHT(n)				((n) << 20)
 #define DUMP_BURST_LEN(n)			((n) << 16)
 #define DUMP_SD(n)				((n) << 0)
-#define DUMP_BURST_LEN_MASK			GENMASK(17, 16)
-#define DUMP_SD_MASK				GENMASK(15, 0)
 
 #define ISP_REG_DEC_CFG				0x030
 #define DEC_V_KEEP(n)				((n) << 24)
@@ -424,6 +422,8 @@ void stf_isp_settings(struct stf_isp_dev *isp_dev,
 void stf_isp_stream_set(struct stf_isp_dev *isp_dev);
 void stf_isp_config_yuv_out_stride(struct stf_isp_dev *isp_dev,
 				   u32 width, u8 bpp);
+void stf_isp_config_raw_out_stride(struct stf_isp_dev *isp_dev,
+				   u32 width, u8 bpp);
 int stf_isp_init(struct stfcamss *stfcamss);
 int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev);
 int stf_isp_unregister(struct stf_isp_dev *isp_dev);
Signature · 1 line
2.25.1
#16 lore raw

Re: [PATCH v1 6/7] staging: media: starfive: Add raw output stride configure

Quoted 2 lines · Changhuang Liang

Add raw output stride to enable sent the aligned raw data to memory.

Subject: staging: media: starfive: Fix raw output stride configuration

I think this is bugfix? What is the impact of this change to the user?

But I can't really understand the commit message and it's hard to review the code without being able to apply it. I'm also new to this subsystem so maybe someone else would have been able to understand it better... Sorry...

regards,
dan carpenter

#17 lore raw

回复: [PATCH v1 6/7] staging: media: starfive: Add raw output stride configure

Hi, Dan

Quoted 13 lines · Changhuang Liang
Quoted 2 lines

Add raw output stride to enable sent the aligned raw data to memory.

Subject: staging: media: starfive: Fix raw output stride configuration

I think this is bugfix? What is the impact of this change to the user?

But I can't really understand the commit message and it's hard to review the code without being able to apply it. I'm also new to this subsystem so maybe someone else would have been able to understand it better... Sorry...

You can try to apply it on tag v6.8-rc7.

1.
Applying: staging: media: starfive: Renamed capture_raw to capture_dump

2.
Applying: staging: media: starfive: Replaced current_fmt with get from sd_state
Applying: staging: media: starfive: Add raw pad for ISP
Applying: staging: media: starfive: Sink rectangle set to ISP source pad
Applying: staging: media: starfive: Add multi streams for ISP
Applying: staging: media: starfive: Add ISP raw video device
Applying: staging: media: starfive: Add raw output stride configure
Applying: admin-guide: media: Update documents for StarFive Camera Subsystem

Regards,
Changhuang

#18 lore raw

PATCH 7/7 admin-guide: media: Update documents for StarFive Camera Subsystem

In reply to Changhuang Liang

Add ISP capture_raw video device in documents. It support output raw frames by ISP module.

---
 .../admin-guide/media/starfive_camss.rst      | 11 ++++++----
 .../media/starfive_camss_graph.dot            | 20 ++++++++++---------
 2 files changed, 18 insertions(+), 13 deletions(-)
Documentation/admin-guide/media/starfive_camss.rst +7 -4
index c224e6123042..b8d1ce878847 100644
@@ -44,7 +44,7 @@ The Starfive Camera Subsystem hardware consists of::
 - Parallel: The parallel interface,  receiving data from a parallel sensor.
 
 - ISP: The ISP, processing raw Bayer data from an image sensor and producing
-  YUV frames.
+  YUV frames, and also support output RAW frames.
 
 
 Topology
@@ -58,15 +58,18 @@ The media controller pipeline graph is as follows:
     :alt:   starfive_camss_graph.dot
     :align: center
 
-The driver has 2 video devices:
+The driver has 3 video devices:
 
 - capture_dump: The capture device, capturing image data directly from a sensor.
 - capture_yuv: The capture device, capturing YUV frame data processed by the
-  ISP module
+  ISP module.
+- capture_raw: The capture device, capturing RAW frame data processed by the
+  ISP module.
 
 The driver has 3 subdevices:
 
-- stf_isp: is responsible for all the isp operations, outputs YUV frames.
+- stf_isp: is responsible for all the isp operations, outputs YUV frames and
+  RAW frames.
 - cdns_csi2rx: a CSI-2 bridge supporting up to 4 CSI lanes in input, and 4
   different pixel streams in output.
 - imx219: an image sensor, image data is sent through MIPI CSI-2.
Documentation/admin-guide/media/starfive_camss_graph.dot +11 -9
index 5e8731e27701..dab3e3ccbe9a 100644
@@ -1,12 +1,14 @@
 digraph board {
 	rankdir=TB
-	n00000001 [label="{{<port0> 0} | stf_isp\n/dev/v4l-subdev0 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
-	n00000001:port1 -> n00000008 [style=dashed]
-	n00000004 [label="capture_dump\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
-	n00000008 [label="capture_yuv\n/dev/video1", shape=box, style=filled, fillcolor=yellow]
-	n0000000e [label="{{<port0> 0} | cdns_csi2rx.19800000.csi-bridge\n | {<port1> 1 | <port2> 2 | <port3> 3 | <port4> 4}}", shape=Mrecord, style=filled, fillcolor=green]
-	n0000000e:port1 -> n00000001:port0 [style=dashed]
-	n0000000e:port1 -> n00000004 [style=dashed]
-	n00000018 [label="{{} | imx219 6-0010\n/dev/v4l-subdev1 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]
-	n00000018:port0 -> n0000000e:port0 [style=bold]
+	n00000001 [label="{{<port0> 0} | stf_isp\n/dev/v4l-subdev0 | {<port1> 1 | <port2> 2}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000001:port1 -> n00000009 [style=dashed]
+	n00000001:port2 -> n0000000d [style=dashed]
+	n00000005 [label="capture_dump\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
+	n00000009 [label="capture_yuv\n/dev/video1", shape=box, style=filled, fillcolor=yellow]
+	n0000000d [label="capture_raw\n/dev/video2", shape=box, style=filled, fillcolor=yellow]
+	n00000015 [label="{{<port0> 0} | cdns_csi2rx.19800000.csi\n/dev/v4l-subdev1 | {<port1> 1 | <port2> 2 | <port3> 3 | <port4> 4}}", shape=Mrecord, style=filled, fillcolor=green]
+	n00000015:port1 -> n00000001:port0 [style=dashed]
+	n00000015:port1 -> n00000005 [style=dashed]
+	n0000001f [label="{{} | imx219 6-0010\n/dev/v4l-subdev2 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]
+	n0000001f:port0 -> n00000015:port0 [style=bold]
 }
Signature · 1 line
2.25.1