Skip to contentSkip to conversation

TDA1997x HDMI video reciver

PATCH Superseded Tim Harvey 2 participants 15 messages Feb 7, 2018 – Feb 9, 2018

Subsystems (6)

v9 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Tim Harvey

author maintainer
#0 lore raw

v9 cover TDA1997x HDMI video reciver

This is a v4l2 subdev driver supporting the TDA1997x HDMI video receiver.

I've tested this on a Gateworks GW54xx/GW551x with an IMX6Q/IMX6DL which uses the TDA19971 with 16bits connected to the IMX6 CSI and single-lane I2S audio providing 2-channel audio.

For this configuration I've tested both 16bit YUV422 and 8bit BT656 parallel video bus modes.

While the driver should support the TDA1993 I do not have one for testing.

Further potential development efforts include:
- CEC support
- HDCP support
- TDA19972 support (2 inputs)

Media graphs can be found at http://dev.gateworks.com/docs/linux/media

History:
v9:
- add digital video decoder video interface entity function

v8:
- fix clearing pad for VIDIOC_DV_TIMIGNS_CAP
- support full range of input modes based on timings_cap
- add patch to fix clearing pad for VIDIOC_DV_TIMIGINGS
- fix available formats for tda19971 bt656 bus width >12
- fix set_format (compliance)
- fixed get/set edid (compliance)
- add init_cfg to setup default pad config (compliance)
- added missing pad checks to get_dv_timings_cap/enum_dv_timings (compliance)
- fix alignment of if statement and whitespace in comment (Hans)
- move regs to tda1997x_regs.h to clean up (Hans)
- add define and sanity check for num of mbus_codes (Hans)

v7:
- fix interlaced mode
- support no AVI infoframe (ie DVI) (Hans)
- add support for multiple output formats (Hans)

v6:
- tda1997x: fix return on regulator enablei in tda1997x_set_power() (Fabio)
- tda1997x: fix colorspace handling (Hans)
- bindings: added Robs's ack (Rob)
- replace copyright with SPDX tag (Philippe)

v5:
- added v4l2_hdmi_colorimetry() patch from Hans to series
- bindings: added Sakari's ack
- tda1997x: uppercase string constants
- tda1997x: use v4l2_hdmi_rx_coloriemtry to fill format
- tda1997x: fix V4L2_CID_DV_RX_RGB_RANGE
- tda1997x: fix interlaced mode format
- dts: remove leading 0 from unit address
- dts: add newline between property list and child node
- dts: added missing audmux in GW551x dts

v4:
- move include/dt-bindings/media/tda1997x.h to bindings patch
- clarify port node details in bindings
- fix typos
- fix default quant range for VGA
- fix quant range handling and conv matrix
- add additional standards and capabilities to timings_cap

v3:
- fix typo in dt bindings
- added dt bindings for GW551x
- use V4L2_DV_BT_FRAME_WIDTH/HEIGHT macros
- fixed missing break
- use only hdmi_infoframe_log for infoframe logging
- simplify tda1997x_s_stream error handling
- add delayed work proc to handle hotplug enable/disable
- fix set_edid (disable HPD before writing, enable after)
- remove enabling edid by default
- initialize timings
- take quant range into account in colorspace conversion
- remove vendor/product tracking (we provide this in log_status via infoframes)
- add v4l_controls
- add more detail to log_status
- calculate vhref generator timings
- timing detection fixes (rounding errors, hswidth errors)
- rename configure_input/configure_conv functions

v2:
- encorporate feedback into dt bindings
- change audio dt bindings
- implement dv timings enum/cap
- remove deprecated g_mbus_config op
- fix dv_query_timings
- add EDID get/set handling
- remove max-pixel-rate support
- add audio codec DAI support
- added media-ctl and v4l2-compliance details

v1:
- initial RFC

# media-ctl -d /dev/media0 -p
Media controller API version 4.15.0

Media device information
------------------------
driver imx-media
model imx-media
serial
bus info
hw revision 0x0
driver version 4.15.0

Device topology
- entity 1: adv7180 2-0020 (1 pad, 1 link)
type V4L2 subdev subtype Unknown flags 20004
device node name /dev/v4l-subdev0
pad0: Source
[fmt:UYVY8_2X8/720x480 field:interlaced colorspace:smpte170m] -> "ipu2_csi1_mux":1 []

- entity 3: tda19971 2-0048 (1 pad, 1 link)

            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev1
	pad0: Source
		[fmt:UYVY8_2X8/1280x720 field:none colorspace:srgb]
		[dv.caps:BT.656/1120 min:640x350@13000000 max:1920x1200@165000000 stds:CEA-861,DMT,CVT,GTF caps:interlaced,progressive,reduced-blanking,custom]
		[dv.detect:BT.656/1120 1280x720p60 (1650x750) stds:CEA-861 flags:can-reduce-fps,CE-video,has-cea861-vic]
		[dv.current:BT.656/1120 1280x720p60 (1650x750) stds:CEA-861 flags:can-reduce-fps,CE-video,has-cea861-vic]
		-> "ipu1_csi0_mux":1 [ENABLED]

- entity 5: ipu1_vdic (3 pads, 3 links)

            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev2
	pad0: Sink
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		<- "ipu1_csi0":1 []
		<- "ipu1_csi1":1 []
	pad1: Sink
		[fmt:UYVY8_2X8/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
	pad2: Source
		[fmt:AYUV8_1X32/640x480@1/60 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu1_ic_prp":0 []

- entity 9: ipu2_vdic (3 pads, 3 links)

            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev3
	pad0: Sink
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		<- "ipu2_csi0":1 []
		<- "ipu2_csi1":1 []
	pad1: Sink
		[fmt:UYVY8_2X8/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
	pad2: Source
		[fmt:AYUV8_1X32/640x480@1/60 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu2_ic_prp":0 []

- entity 13: ipu1_ic_prp (3 pads, 5 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev4
	pad0: Sink
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		<- "ipu1_vdic":2 []
		<- "ipu1_csi0":1 []
		<- "ipu1_csi1":1 []
	pad1: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu1_ic_prpenc":0 []
	pad2: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu1_ic_prpvf":0 []

- entity 17: ipu1_ic_prpenc (2 pads, 2 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev5
	pad0: Sink
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		<- "ipu1_ic_prp":1 []
	pad1: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu1_ic_prpenc capture":0 []

- entity 20: ipu1_ic_prpenc capture (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video0
pad0: Sink
<- "ipu1_ic_prpenc":1 []

- entity 26: ipu1_ic_prpvf (2 pads, 2 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev6
	pad0: Sink
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		<- "ipu1_ic_prp":2 []
	pad1: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu1_ic_prpvf capture":0 []

- entity 29: ipu1_ic_prpvf capture (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video1
pad0: Sink
<- "ipu1_ic_prpvf":1 []

- entity 35: ipu2_ic_prp (3 pads, 5 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev7
	pad0: Sink
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		<- "ipu2_vdic":2 []
		<- "ipu2_csi0":1 []
		<- "ipu2_csi1":1 []
	pad1: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu2_ic_prpenc":0 []
	pad2: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu2_ic_prpvf":0 []

- entity 39: ipu2_ic_prpenc (2 pads, 2 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev8
	pad0: Sink
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		<- "ipu2_ic_prp":1 []
	pad1: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu2_ic_prpenc capture":0 []

- entity 42: ipu2_ic_prpenc capture (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video2
pad0: Sink
<- "ipu2_ic_prpenc":1 []

- entity 48: ipu2_ic_prpvf (2 pads, 2 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev9
	pad0: Sink
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		<- "ipu2_ic_prp":2 []
	pad1: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu2_ic_prpvf capture":0 []

- entity 51: ipu2_ic_prpvf capture (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video3
pad0: Sink
<- "ipu2_ic_prpvf":1 []

- entity 57: ipu1_csi0 (3 pads, 4 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev10
	pad0: Sink
		[fmt:UYVY8_2X8/1280x720@1/30 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range
		 crop.bounds:(0,0)/1280x720
		 crop:(0,0)/1280x720
		 compose.bounds:(0,0)/1280x720
		 compose:(0,0)/1280x720]
		<- "ipu1_csi0_mux":2 [ENABLED]
	pad1: Source
		[fmt:AYUV8_1X32/1280x720@1/30 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
		-> "ipu1_ic_prp":0 []
		-> "ipu1_vdic":0 []
	pad2: Source
		[fmt:AYUV8_1X32/1280x720@1/30 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
		-> "ipu1_csi0 capture":0 [ENABLED]

- entity 61: ipu1_csi0 capture (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video4
pad0: Sink
<- "ipu1_csi0":2 [ENABLED]

- entity 67: ipu1_csi1 (3 pads, 3 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev11
	pad0: Sink
		[fmt:UYVY8_2X8/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range
		 crop.bounds:(0,0)/640x480
		 crop:(0,0)/640x480
		 compose.bounds:(0,0)/640x480
		 compose:(0,0)/640x480]
	pad1: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu1_ic_prp":0 []
		-> "ipu1_vdic":0 []
	pad2: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu1_csi1 capture":0 []

- entity 71: ipu1_csi1 capture (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video5
pad0: Sink
<- "ipu1_csi1":2 []

- entity 77: ipu2_csi0 (3 pads, 3 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev12
	pad0: Sink
		[fmt:UYVY8_2X8/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range
		 crop.bounds:(0,0)/640x480
		 crop:(0,0)/640x480
		 compose.bounds:(0,0)/640x480
		 compose:(0,0)/640x480]
	pad1: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu2_ic_prp":0 []
		-> "ipu2_vdic":0 []
	pad2: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu2_csi0 capture":0 []

- entity 81: ipu2_csi0 capture (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video6
pad0: Sink
<- "ipu2_csi0":2 []

- entity 87: ipu2_csi1 (3 pads, 4 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev13
	pad0: Sink
		[fmt:UYVY8_2X8/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range
		 crop.bounds:(0,0)/640x480
		 crop:(0,0)/640x480
		 compose.bounds:(0,0)/640x480
		 compose:(0,0)/640x480]
		<- "ipu2_csi1_mux":2 []
	pad1: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu2_ic_prp":0 []
		-> "ipu2_vdic":0 []
	pad2: Source
		[fmt:AYUV8_1X32/640x480@1/30 field:none colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
		-> "ipu2_csi1 capture":0 []

- entity 91: ipu2_csi1 capture (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video7
pad0: Sink
<- "ipu2_csi1":2 []

- entity 97: ipu1_csi0_mux (3 pads, 2 links)

             type V4L2 subdev subtype Unknown flags 0
             device node name /dev/v4l-subdev14
	pad0: Sink
		[fmt:unknown/0x0]
	pad1: Sink
		[fmt:UYVY8_2X8/1280x720 field:none colorspace:srgb]
		<- "tda19971 2-0048":0 [ENABLED]
	pad2: Source
		[fmt:UYVY8_2X8/1280x720 field:none colorspace:srgb]
		-> "ipu1_csi0":0 [ENABLED]

- entity 101: ipu2_csi1_mux (3 pads, 2 links)

              type V4L2 subdev subtype Unknown flags 0
              device node name /dev/v4l-subdev15
	pad0: Sink
		[fmt:unknown/0x0]
	pad1: Sink
		[fmt:unknown/0x0]
		<- "adv7180 2-0020":0 []
	pad2: Source
		[fmt:unknown/0x0]
		-> "ipu2_csi1":0 []

v4l2-compliance test results:
- with the following kernel patches:
v4l2-subdev: clear reserved fields
v4l2-subdev: without controls return -ENOTTY

# v4l2-compliance -u1
v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8
Media Driver Info:
	Driver name      : imx-media
	Model            : imx-media
	Serial           : 
	Bus info         : 
	Media version    : 4.15.0
	Hardware revision: 0x00000000 (0)
	Driver version   : 4.15.0
Interface Info:
	ID               : 0x0300008f
	Type             : V4L Sub-Device
Entity Info:
	ID               : 0x00000003 (3)
	Name             : tda19971 2-0048
	Function         : FAIL: Unknown Function (00006001)
	Pad 0x01000004   : Source
	  Link 0x0200006f: to remote pad 0x1000063 of entity 'ipu1_csi0_mux': Data, Enabled

Compliance test for device /dev/v4l-subdev1:

Required ioctls:
test MC information: FAIL

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

Debug ioctls:
test VIDIOC_LOG_STATUS: OK

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 test VIDIOC_DV_TIMINGS_CAP: OK
test VIDIOC_G/S_EDID: OK

Sub-Device ioctls (Source Pad 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) 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 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: 4 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 VIDIOC_EXPBUF: OK (Not Supported)

Total: 47, Succeeded: 46, Failed: 1, Warnings: 0

# v4l2-compliance -m0 -M
v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8
Media Driver Info:
	Driver name      : imx-media
	Model            : imx-media
	Serial           : 
	Bus info         : 
	Media version    : 4.15.0
	Hardware revision: 0x00000000 (0)
	Driver version   : 4.15.0

Compliance test for device /dev/media0:

Required ioctls:
test MEDIA_IOC_DEVICE_INFO: 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:
fail: v4l2-test-media.cpp(94): function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
fail: v4l2-test-media.cpp(156): checkFunction(ent.function, true)
test MEDIA_IOC_G_TOPOLOGY: FAIL
fail: v4l2-test-media.cpp(275): num_data_links != num_links
test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL
test MEDIA_IOC_SETUP_LINK: OK

Total: 7, Succeeded: 5, Failed: 2, Warnings: 0
^^^^ above failures are due to imx/adv7180 not setting a valid entity function

Hans Verkuil (1):
v4l2-dv-timings: add v4l2_hdmi_colorimetry()

Tim Harvey (7):
media: v4l-ioctl: fix clearing pad for VIDIOC_DV_TIMIGNS_CAP
media: add digital video decoder video interface entity functions
MAINTAINERS: add entry for NXP TDA1997x driver
media: dt-bindings: Add bindings for TDA1997X
media: i2c: Add TDA1997x HDMI receiver driver
ARM: dts: imx: Add TDA19971 HDMI Receiver to GW54xx
ARM: dts: imx: Add TDA19971 HDMI Receiver to GW551x

 .../devicetree/bindings/media/i2c/tda1997x.txt     |  179 ++
 Documentation/media/uapi/mediactl/media-types.rst  |   11 +
 MAINTAINERS                                        |    8 +
 arch/arm/boot/dts/imx6q-gw54xx.dts                 |  105 +
 arch/arm/boot/dts/imx6qdl-gw54xx.dtsi              |   29 +-
 arch/arm/boot/dts/imx6qdl-gw551x.dtsi              |  138 +
 drivers/media/i2c/Kconfig                          |    9 +
 drivers/media/i2c/Makefile                         |    1 +
 drivers/media/i2c/tda1997x.c                       | 2848 ++++++++++++++++++++
 drivers/media/i2c/tda1997x_regs.h                  |  641 +++++
 drivers/media/v4l2-core/v4l2-dv-timings.c          |  141 +
 drivers/media/v4l2-core/v4l2-ioctl.c               |    2 +-
 include/dt-bindings/media/tda1997x.h               |   74 +
 include/media/i2c/tda1997x.h                       |   42 +
 include/media/v4l2-dv-timings.h                    |   21 +
 include/uapi/linux/media.h                         |    5 +
 16 files changed, 4250 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/tda1997x.txt
 create mode 100644 drivers/media/i2c/tda1997x.c
 create mode 100644 drivers/media/i2c/tda1997x_regs.h
 create mode 100644 include/dt-bindings/media/tda1997x.h
 create mode 100644 include/media/i2c/tda1997x.h
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH v9 1/8 v4l2-dv-timings: add v4l2_hdmi_colorimetry()

From: Hans Verkuil <[email protected]>

Add the v4l2_hdmi_colorimetry() function so we have a single function that determines the colorspace, YCbCr encoding, quantization range and transfer function from the InfoFrame data.

---
v9:
- fix kernel-doc format (Randy)
- remove redundant pad bounds check already in v4l2-subdev.c
- assign entity function (Hans)
- properly assign/check/free ctrl_handler (Hans)
- fixed typo 'Rull Range' -> 'Full Range'
- update csc after quant range change

 drivers/media/v4l2-core/v4l2-dv-timings.c | 141 ++++++++++++++++++++++++++++++
 include/media/v4l2-dv-timings.h           |  21 +++++
 2 files changed, 162 insertions(+)
drivers/media/v4l2-core/v4l2-dv-timings.c +141 -0
index 930f9c5..5663d86 100644
@@ -27,6 +27,7 @@
 #include <linux/v4l2-dv-timings.h>
 #include <media/v4l2-dv-timings.h>
 #include <linux/math64.h>
+#include <linux/hdmi.h>
 
 MODULE_AUTHOR("Hans Verkuil");
 MODULE_DESCRIPTION("V4L2 DV Timings Helper Functions");
@@ -814,3 +815,143 @@ struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait)
 	return aspect;
 }
 EXPORT_SYMBOL_GPL(v4l2_calc_aspect_ratio);
+
+/** v4l2_hdmi_rx_colorimetry - determine HDMI colorimetry information
+ *	based on various InfoFrames.
+ * @avi: the AVI InfoFrame
+ * @hdmi: the HDMI Vendor InfoFrame, may be NULL
+ * @height: the frame height
+ *
+ * Determines the HDMI colorimetry information, i.e. how the HDMI
+ * pixel color data should be interpreted.
+ *
+ * Note that some of the newer features (DCI-P3, HDR) are not yet
+ * implemented: the hdmi.h header needs to be updated to the HDMI 2.0
+ * and CTA-861-G standards.
+ */
+struct v4l2_hdmi_colorimetry
+v4l2_hdmi_rx_colorimetry(const struct hdmi_avi_infoframe *avi,
+			 const struct hdmi_vendor_infoframe *hdmi,
+			 unsigned int height)
+{
+	struct v4l2_hdmi_colorimetry c = {
+		V4L2_COLORSPACE_SRGB,
+		V4L2_YCBCR_ENC_DEFAULT,
+		V4L2_QUANTIZATION_FULL_RANGE,
+		V4L2_XFER_FUNC_SRGB
+	};
+	bool is_ce = avi->video_code || (hdmi && hdmi->vic);
+	bool is_sdtv = height <= 576;
+	bool default_is_lim_range_rgb = avi->video_code > 1;
+
+	switch (avi->colorspace) {
+	case HDMI_COLORSPACE_RGB:
+		/* RGB pixel encoding */
+		switch (avi->colorimetry) {
+		case HDMI_COLORIMETRY_EXTENDED:
+			switch (avi->extended_colorimetry) {
+			case HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB:
+				c.colorspace = V4L2_COLORSPACE_ADOBERGB;
+				c.xfer_func = V4L2_XFER_FUNC_ADOBERGB;
+				break;
+			case HDMI_EXTENDED_COLORIMETRY_BT2020:
+				c.colorspace = V4L2_COLORSPACE_BT2020;
+				c.xfer_func = V4L2_XFER_FUNC_709;
+				break;
+			default:
+				break;
+			}
+			break;
+		default:
+			break;
+		}
+		switch (avi->quantization_range) {
+		case HDMI_QUANTIZATION_RANGE_LIMITED:
+			c.quantization = V4L2_QUANTIZATION_LIM_RANGE;
+			break;
+		case HDMI_QUANTIZATION_RANGE_FULL:
+			break;
+		default:
+			if (default_is_lim_range_rgb)
+				c.quantization = V4L2_QUANTIZATION_LIM_RANGE;
+			break;
+		}
+		break;
+
+	default:
+		/* YCbCr pixel encoding */
+		c.quantization = V4L2_QUANTIZATION_LIM_RANGE;
+		switch (avi->colorimetry) {
+		case HDMI_COLORIMETRY_NONE:
+			if (!is_ce)
+				break;
+			if (is_sdtv) {
+				c.colorspace = V4L2_COLORSPACE_SMPTE170M;
+				c.ycbcr_enc = V4L2_YCBCR_ENC_601;
+			} else {
+				c.colorspace = V4L2_COLORSPACE_REC709;
+				c.ycbcr_enc = V4L2_YCBCR_ENC_709;
+			}
+			c.xfer_func = V4L2_XFER_FUNC_709;
+			break;
+		case HDMI_COLORIMETRY_ITU_601:
+			c.colorspace = V4L2_COLORSPACE_SMPTE170M;
+			c.ycbcr_enc = V4L2_YCBCR_ENC_601;
+			c.xfer_func = V4L2_XFER_FUNC_709;
+			break;
+		case HDMI_COLORIMETRY_ITU_709:
+			c.colorspace = V4L2_COLORSPACE_REC709;
+			c.ycbcr_enc = V4L2_YCBCR_ENC_709;
+			c.xfer_func = V4L2_XFER_FUNC_709;
+			break;
+		case HDMI_COLORIMETRY_EXTENDED:
+			switch (avi->extended_colorimetry) {
+			case HDMI_EXTENDED_COLORIMETRY_XV_YCC_601:
+				c.colorspace = V4L2_COLORSPACE_REC709;
+				c.ycbcr_enc = V4L2_YCBCR_ENC_XV709;
+				c.xfer_func = V4L2_XFER_FUNC_709;
+				break;
+			case HDMI_EXTENDED_COLORIMETRY_XV_YCC_709:
+				c.colorspace = V4L2_COLORSPACE_REC709;
+				c.ycbcr_enc = V4L2_YCBCR_ENC_XV601;
+				c.xfer_func = V4L2_XFER_FUNC_709;
+				break;
+			case HDMI_EXTENDED_COLORIMETRY_S_YCC_601:
+				c.colorspace = V4L2_COLORSPACE_SRGB;
+				c.ycbcr_enc = V4L2_YCBCR_ENC_601;
+				c.xfer_func = V4L2_XFER_FUNC_SRGB;
+				break;
+			case HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601:
+				c.colorspace = V4L2_COLORSPACE_ADOBERGB;
+				c.ycbcr_enc = V4L2_YCBCR_ENC_601;
+				c.xfer_func = V4L2_XFER_FUNC_ADOBERGB;
+				break;
+			case HDMI_EXTENDED_COLORIMETRY_BT2020:
+				c.colorspace = V4L2_COLORSPACE_BT2020;
+				c.ycbcr_enc = V4L2_YCBCR_ENC_BT2020;
+				c.xfer_func = V4L2_XFER_FUNC_709;
+				break;
+			case HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM:
+				c.colorspace = V4L2_COLORSPACE_BT2020;
+				c.ycbcr_enc = V4L2_YCBCR_ENC_BT2020_CONST_LUM;
+				c.xfer_func = V4L2_XFER_FUNC_709;
+				break;
+			default: /* fall back to ITU_709 */
+				c.colorspace = V4L2_COLORSPACE_REC709;
+				c.ycbcr_enc = V4L2_YCBCR_ENC_709;
+				c.xfer_func = V4L2_XFER_FUNC_709;
+				break;
+			}
+			break;
+		default:
+			break;
+		}
+		/*
+		 * YCC Quantization Range signaling is more-or-less broken,
+		 * let's just ignore this.
+		 */
+		break;
+	}
+	return c;
+}
+EXPORT_SYMBOL_GPL(v4l2_hdmi_rx_colorimetry);
include/media/v4l2-dv-timings.h +21 -0
index 61a1889..835aef7 100644
@@ -223,5 +223,26 @@ static inline  bool can_reduce_fps(struct v4l2_bt_timings *bt)
 	return false;
 }
 
+/**
+ * struct v4l2_hdmi_rx_colorimetry - describes the HDMI colorimetry information
+ * @colorspace:		enum v4l2_colorspace, the colorspace
+ * @ycbcr_enc:		enum v4l2_ycbcr_encoding, Y'CbCr encoding
+ * @quantization:	enum v4l2_quantization, colorspace quantization
+ * @xfer_func:		enum v4l2_xfer_func, colorspace transfer function
+ */
+struct v4l2_hdmi_colorimetry {
+	enum v4l2_colorspace colorspace;
+	enum v4l2_ycbcr_encoding ycbcr_enc;
+	enum v4l2_quantization quantization;
+	enum v4l2_xfer_func xfer_func;
+};
+
+struct hdmi_avi_infoframe;
+struct hdmi_vendor_infoframe;
+
+struct v4l2_hdmi_colorimetry
+v4l2_hdmi_rx_colorimetry(const struct hdmi_avi_infoframe *avi,
+			 const struct hdmi_vendor_infoframe *hdmi,
+			 unsigned int height);
 
 #endif
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

PATCH v9 2/8 media: v4l-ioctl: fix clearing pad for VIDIOC_DV_TIMIGNS_CAP

In reply to Tim Harvey
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-ioctl.c +1 -1
index 7961499..5f3670d 100644
@@ -2638,7 +2638,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
 	IOCTL_INFO_FNC(VIDIOC_PREPARE_BUF, v4l_prepare_buf, v4l_print_buffer, INFO_FL_QUEUE),
 	IOCTL_INFO_STD(VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings, v4l_print_enum_dv_timings, INFO_FL_CLEAR(v4l2_enum_dv_timings, pad)),
 	IOCTL_INFO_STD(VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings, v4l_print_dv_timings, INFO_FL_ALWAYS_COPY),
-	IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, v4l_print_dv_timings_cap, INFO_FL_CLEAR(v4l2_dv_timings_cap, type)),
+	IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, v4l_print_dv_timings_cap, INFO_FL_CLEAR(v4l2_dv_timings_cap, pad)),
 	IOCTL_INFO_FNC(VIDIOC_ENUM_FREQ_BANDS, v4l_enum_freq_bands, v4l_print_freq_band, 0),
 	IOCTL_INFO_FNC(VIDIOC_DBG_G_CHIP_INFO, v4l_dbg_g_chip_info, v4l_print_dbg_chip_info, INFO_FL_CLEAR(v4l2_dbg_chip_info, match)),
 	IOCTL_INFO_FNC(VIDIOC_QUERY_EXT_CTRL, v4l_query_ext_ctrl, v4l_print_query_ext_ctrl, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_query_ext_ctrl, id)),
Signature · 1 line
2.7.4
author maintainer
#3 lore raw

PATCH v9 3/8 media: add digital video decoder entity function

In reply to Tim Harvey

Add a new media entity function definition for digital TV decoders:
MEDIA_ENT_F_DTV_DECODER

---
 Documentation/media/uapi/mediactl/media-types.rst | 11 +++++++++++
 include/uapi/linux/media.h                        |  5 +++++
 2 files changed, 16 insertions(+)
Documentation/media/uapi/mediactl/media-types.rst +11 -0
index 8d64b0c..195400e 100644
@@ -321,6 +321,17 @@ Types and flags used to represent the media graph elements
          MIPI CSI-2, ...), and outputs them on its source pad to an output
          video bus of another type (eDP, MIPI CSI-2, parallel, ...).
 
+    -  ..  row 31
+
+       ..  _MEDIA-ENT-F-DTV-DECODER:
+
+       -  ``MEDIA_ENT_F_DTV_DECODER``
+
+       -  Digital video decoder. The basic function of the video decoder is
+	  to accept digital video from a wide variety of sources
+	  and output it in some digital video standard, with appropriate
+	  timing signals.
+
 ..  tabularcolumns:: |p{5.5cm}|p{12.0cm}|
 
 .. _media-entity-flag:
include/uapi/linux/media.h +5 -0
index b9b9446..2f12328 100644
@@ -110,6 +110,11 @@ struct media_device_info {
 #define MEDIA_ENT_F_VID_IF_BRIDGE		(MEDIA_ENT_F_BASE + 0x5002)
 
 /*
+ * Digital video decoder entities
+ */
+#define MEDIA_ENT_F_DTV_DECODER			(MEDIA_ENT_F_BASE + 0x6001)
+
+/*
  * Connectors
  */
 /* It is a responsibility of the entity drivers to add connectors and links */
Signature · 1 line
2.7.4
author maintainer
#4 lore raw

PATCH v9 4/8 MAINTAINERS: add entry for NXP TDA1997x driver

In reply to Tim Harvey
---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index 845fc25..439b500 100644
@@ -13262,6 +13262,14 @@ T:	git git://linuxtv.org/mkrufky/tuners.git
 S:	Maintained
 F:	drivers/media/tuners/tda18271*
 
+TDA1997x MEDIA DRIVER
+M:	Tim Harvey <tharvey-UMMOYl/[email protected]>
+L:	[email protected]
+W:	https://linuxtv.org
+Q:	http://patchwork.linuxtv.org/project/linux-media/list/
+S:	Maintained
+F:	drivers/media/i2c/tda1997x.*
+
 TDA827x MEDIA DRIVER
 M:	Michael Krufky <[email protected]>
 L:	[email protected]
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#5 lore raw

PATCH v9 5/8 media: dt-bindings: Add bindings for TDA1997X

In reply to Tim Harvey

---
v6:
- replace copyright with SPDX tag
- added Rob's ack

v5:
- added Sakari's ack

v4:
- move include/dt-bindings/media/tda1997x.h to bindings patch
- clarify port node details

v3:
- fix typo

v2:
- add vendor prefix and remove _ from vidout-portcfg
- remove _ from labels
- remove max-pixel-rate property
- describe and provide example for single output port
- update to new audio port bindings

 .../devicetree/bindings/media/i2c/tda1997x.txt     | 179 +++++++++++++++++++++
 include/dt-bindings/media/tda1997x.h               |  74 +++++++++
 2 files changed, 253 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/tda1997x.txt
 create mode 100644 include/dt-bindings/media/tda1997x.h
Documentation/devicetree/bindings/media/i2c/tda1997x.txt new file +179 -0
new file mode 100644
index 0000000..9ab53c3
@@ -0,0 +1,179 @@
+Device-Tree bindings for the NXP TDA1997x HDMI receiver
+
+The TDA19971/73 are HDMI video receivers.
+
+The TDA19971 Video port output pins can be used as follows:
+ - RGB 8bit per color (24 bits total): R[11:4] B[11:4] G[11:4]
+ - YUV444 8bit per color (24 bits total): Y[11:4] Cr[11:4] Cb[11:4]
+ - YUV422 semi-planar 8bit per component (16 bits total): Y[11:4] CbCr[11:4]
+ - YUV422 semi-planar 10bit per component (20 bits total): Y[11:2] CbCr[11:2]
+ - YUV422 semi-planar 12bit per component (24 bits total): - Y[11:0] CbCr[11:0]
+ - YUV422 BT656 8bit per component (8 bits total): YCbCr[11:4] (2-cycles)
+ - YUV422 BT656 10bit per component (10 bits total): YCbCr[11:2] (2-cycles)
+ - YUV422 BT656 12bit per component (12 bits total): YCbCr[11:0] (2-cycles)
+
+The TDA19973 Video port output pins can be used as follows:
+ - RGB 12bit per color (36 bits total): R[11:0] B[11:0] G[11:0]
+ - YUV444 12bit per color (36 bits total): Y[11:0] Cb[11:0] Cr[11:0]
+ - YUV422 semi-planar 12bit per component (24 bits total): Y[11:0] CbCr[11:0]
+ - YUV422 BT656 12bit per component (12 bits total): YCbCr[11:0] (2-cycles)
+
+The Video port output pins are mapped via 4-bit 'pin groups' allowing
+for a variety of connection possibilities including swapping pin order within
+pin groups. The video_portcfg device-tree property consists of register mapping
+pairs which map a chip-specific VP output register to a 4-bit pin group. If
+the pin group needs to be bit-swapped you can use the *_S pin-group defines.
+
+Required Properties:
+ - compatible          :
+  - "nxp,tda19971" for the TDA19971
+  - "nxp,tda19973" for the TDA19973
+ - reg                 : I2C slave address
+ - interrupts          : The interrupt number
+ - DOVDD-supply        : Digital I/O supply
+ - DVDD-supply         : Digital Core supply
+ - AVDD-supply         : Analog supply
+ - nxp,vidout-portcfg  : array of pairs mapping VP output pins to pin groups.
+
+Optional Properties:
+ - nxp,audout-format   : DAI bus format: "i2s" or "spdif".
+ - nxp,audout-width    : width of audio output data bus (1-4).
+ - nxp,audout-layout   : data layout (0=AP0 used, 1=AP0/AP1/AP2/AP3 used).
+ - nxp,audout-mclk-fs  : Multiplication factor between stream rate and codec
+                         mclk.
+
+The port node shall contain one endpoint child node for its digital
+output video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Optional Endpoint Properties:
+  The following three properties are defined in video-interfaces.txt and
+  are valid for the output parallel bus endpoint:
+  - hsync-active: Horizontal synchronization polarity. Defaults to active high.
+  - vsync-active: Vertical synchronization polarity. Defaults to active high.
+  - data-active: Data polarity. Defaults to active high.
+
+Examples:
+ - VP[15:0] connected to IMX6 CSI_DATA[19:4] for 16bit YUV422
+   16bit I2S layout0 with a 128*fs clock (A_WS, AP0, A_CLK pins)
+	hdmi-receiver@48 {
+		compatible = "nxp,tda19971";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_tda1997x>;
+		reg = <0x48>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+		DOVDD-supply = <&reg_3p3v>;
+		AVDD-supply = <&reg_1p8v>;
+		DVDD-supply = <&reg_1p8v>;
+		/* audio */
+		#sound-dai-cells = <0>;
+		nxp,audout-format = "i2s";
+		nxp,audout-layout = <0>;
+		nxp,audout-width = <16>;
+		nxp,audout-mclk-fs = <128>;
+		/*
+		 * The 8bpp YUV422 semi-planar mode outputs CbCr[11:4]
+		 * and Y[11:4] across 16bits in the same pixclk cycle.
+		 */
+		nxp,vidout-portcfg =
+			/* Y[11:8]<->VP[15:12]<->CSI_DATA[19:16] */
+			< TDA1997X_VP24_V15_12 TDA1997X_G_Y_11_8 >,
+			/* Y[7:4]<->VP[11:08]<->CSI_DATA[15:12] */
+			< TDA1997X_VP24_V11_08 TDA1997X_G_Y_7_4 >,
+			/* CbCc[11:8]<->VP[07:04]<->CSI_DATA[11:8] */
+			< TDA1997X_VP24_V07_04 TDA1997X_R_CR_CBCR_11_8 >,
+			/* CbCr[7:4]<->VP[03:00]<->CSI_DATA[7:4] */
+			< TDA1997X_VP24_V03_00 TDA1997X_R_CR_CBCR_7_4 >;
+
+		port {
+			tda1997x_to_ipu1_csi0_mux: endpoint {
+				remote-endpoint = <&ipu1_csi0_mux_from_parallel_sensor>;
+				bus-width = <16>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+				data-active = <1>;
+			};
+		};
+	};
+ - VP[15:8] connected to IMX6 CSI_DATA[19:12] for 8bit BT656
+   16bit I2S layout0 with a 128*fs clock (A_WS, AP0, A_CLK pins)
+	hdmi-receiver@48 {
+		compatible = "nxp,tda19971";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_tda1997x>;
+		reg = <0x48>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+		DOVDD-supply = <&reg_3p3v>;
+		AVDD-supply = <&reg_1p8v>;
+		DVDD-supply = <&reg_1p8v>;
+		/* audio */
+		#sound-dai-cells = <0>;
+		nxp,audout-format = "i2s";
+		nxp,audout-layout = <0>;
+		nxp,audout-width = <16>;
+		nxp,audout-mclk-fs = <128>;
+		/*
+		 * The 8bpp YUV422 semi-planar mode outputs CbCr[11:4]
+		 * and Y[11:4] across 16bits in the same pixclk cycle.
+		 */
+		nxp,vidout-portcfg =
+			/* Y[11:8]<->VP[15:12]<->CSI_DATA[19:16] */
+			< TDA1997X_VP24_V15_12 TDA1997X_G_Y_11_8 >,
+			/* Y[7:4]<->VP[11:08]<->CSI_DATA[15:12] */
+			< TDA1997X_VP24_V11_08 TDA1997X_G_Y_7_4 >,
+			/* CbCc[11:8]<->VP[07:04]<->CSI_DATA[11:8] */
+			< TDA1997X_VP24_V07_04 TDA1997X_R_CR_CBCR_11_8 >,
+			/* CbCr[7:4]<->VP[03:00]<->CSI_DATA[7:4] */
+			< TDA1997X_VP24_V03_00 TDA1997X_R_CR_CBCR_7_4 >;
+
+		port {
+			tda1997x_to_ipu1_csi0_mux: endpoint {
+				remote-endpoint = <&ipu1_csi0_mux_from_parallel_sensor>;
+				bus-width = <16>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+				data-active = <1>;
+			};
+		};
+	};
+ - VP[15:8] connected to IMX6 CSI_DATA[19:12] for 8bit BT656
+   16bit I2S layout0 with a 128*fs clock (A_WS, AP0, A_CLK pins)
+	hdmi-receiver@48 {
+		compatible = "nxp,tda19971";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_tda1997x>;
+		reg = <0x48>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+		DOVDD-supply = <&reg_3p3v>;
+		AVDD-supply = <&reg_1p8v>;
+		DVDD-supply = <&reg_1p8v>;
+		/* audio */
+		#sound-dai-cells = <0>;
+		nxp,audout-format = "i2s";
+		nxp,audout-layout = <0>;
+		nxp,audout-width = <16>;
+		nxp,audout-mclk-fs = <128>;
+		/*
+		 * The 8bpp BT656 mode outputs YCbCr[11:4] across 8bits over
+		 * 2 pixclk cycles.
+		 */
+		nxp,vidout-portcfg =
+			/* YCbCr[11:8]<->VP[15:12]<->CSI_DATA[19:16] */
+			< TDA1997X_VP24_V15_12 TDA1997X_R_CR_CBCR_11_8 >,
+			/* YCbCr[7:4]<->VP[11:08]<->CSI_DATA[15:12] */
+			< TDA1997X_VP24_V11_08 TDA1997X_R_CR_CBCR_7_4 >,
+
+		port {
+			tda1997x_to_ipu1_csi0_mux: endpoint {
+				remote-endpoint = <&ipu1_csi0_mux_from_parallel_sensor>;
+				bus-width = <16>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+				data-active = <1>;
+			};
+		};
+	};
+
include/dt-bindings/media/tda1997x.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#6 lore raw

PATCH v9 6/8 media: i2c: Add TDA1997x HDMI receiver driver

In reply to Tim Harvey

Add support for the TDA1997x HDMI receivers.

Cc Hans Verkuil <hverkuil-qWit8jRvyhVmR6Xm/[email protected]>

---
v9:
- remove redundant pad bounds check already in v4l2-subdev.c
- assign entity function (Hans)
- properly assign/check/free ctrl_handler (Hans)
- fixed typo 'Rull Range' -> 'Full Range'
- update csc after quant range change

v8:
- fix available formats for tda19971 bt656 bus width >12
- support full range of input modes based on timings_cap
- fix set_format (compliance)
- fixed get/set edid (compliance)
- add init_cfg to setup default pad config (compliance)
- added missing pad checks to get_dv_timings_cap/enum_dv_timings (compliance)
- fix alignment of if statement and whitespace in comment (Hans)
- move regs to tda1997x_regs.h to clean up (Hans)
- add define and sanity check for num of mbus_codes (Hans)

v7:
- fix interlaced mode
- support no AVI infoframe (ie DVI) (Hans)
- add support for multiple output formats (Hans)

v6:
- fix return on regulator enablei in tda1997x_set_power()
- replace copyright with SPDX tag
- fix colorspace handling

v5:
- uppercase string constants
- use v4l2_hdmi_rx_coloriemtry to fill format
- fix V4L2_CID_DV_RX_RGB_RANGE
- fix interlaced mode format

v4:
- move include/dt-bindings/media/tda1997x.h to bindings patch
- fix typos
- fix default quant range for VGA
- fix quant range handling and conv matrix
- add additional standards and capabilities to timings_cap

v3:
- use V4L2_DV_BT_FRAME_WIDTH/HEIGHT macros
- fixed missing break
- use only hdmi_infoframe_log for infoframe logging
- simplify tda1997x_s_stream error handling
- add delayed work proc to handle hotplug enable/disable
- fix set_edid (disable HPD before writing, enable after)
- remove enabling edid by default
- initialize timings
- take quant range into account in colorspace conversion
- remove vendor/product tracking (we provide this in log_status via infoframes)
- add v4l_controls
- add more detail to log_status
- calculate vhref generator timings
- timing detection fixes (rounding errors, hswidth errors)
- rename configure_input/configure_conv functions

v2:
- implement dv timings enum/cap
- remove deprecated g_mbus_config op
- fix dv_query_timings
- add EDID get/set handling
- remove max-pixel-rate support
- add audio codec DAI support
- change audio bindings

 drivers/media/i2c/Kconfig         |    9 +
 drivers/media/i2c/Makefile        |    1 +
 drivers/media/i2c/tda1997x.c      | 2848 +++++++++++++++++++++++++++++++++++++
 drivers/media/i2c/tda1997x_regs.h |  641 +++++++++
 include/media/i2c/tda1997x.h      |   42 +
 5 files changed, 3541 insertions(+)
 create mode 100644 drivers/media/i2c/tda1997x.c
 create mode 100644 drivers/media/i2c/tda1997x_regs.h
 create mode 100644 include/media/i2c/tda1997x.h
drivers/media/i2c/Kconfig +9 -0
index cb5d7ff..3522641 100644
@@ -56,6 +56,15 @@ config VIDEO_TDA9840
 	  To compile this driver as a module, choose M here: the
 	  module will be called tda9840.
 
+config VIDEO_TDA1997X
+	tristate "NXP TDA1997x HDMI receiver"
+	depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
+	---help---
+	  V4L2 subdevice driver for the NXP TDA1997x HDMI receivers.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tda1997x.
+
 config VIDEO_TEA6415C
 	tristate "Philips TEA6415C audio processor"
 	depends on I2C
drivers/media/i2c/Makefile +1 -0
index 548a9ef..adfcae9 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o
 obj-$(CONFIG_VIDEO_TDA7432) += tda7432.o
 obj-$(CONFIG_VIDEO_SAA6588) += saa6588.o
 obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o
+obj-$(CONFIG_VIDEO_TDA1997X) += tda1997x.o
 obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o
 obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o
 obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o
drivers/media/i2c/tda1997x.c new file +2848 -0

2,848 lines not on this page · raw message

drivers/media/i2c/tda1997x_regs.h new file +641 -0

130 lines not on this page · raw message

include/media/i2c/tda1997x.h new file +42 -0

42 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Part of the diff is not shown here. View the raw message.

author maintainer
#13 lore raw

PATCH v9 7/8 ARM: dts: imx: Add TDA19971 HDMI Receiver to GW54xx

In reply to Tim Harvey

The GW54xx has a front-panel microHDMI connector routed to a TDA19971 which is connected the the IPU CSI when using IMX6Q.

---
v5:
- remove leading 0 from unit address
- add newline between property list and child node

v4: no changes
v3: no changes

v2:
- add HDMI audio input support

 arch/arm/boot/dts/imx6q-gw54xx.dts    | 105 ++++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/imx6qdl-gw54xx.dtsi |  29 +++++++++-
 2 files changed, 131 insertions(+), 3 deletions(-)
arch/arm/boot/dts/imx6q-gw54xx.dts +105 -0
index 56e5b50..0477120 100644
@@ -12,10 +12,30 @@
 /dts-v1/;
 #include "imx6q.dtsi"
 #include "imx6qdl-gw54xx.dtsi"
+#include <dt-bindings/media/tda1997x.h>
 
 / {
 	model = "Gateworks Ventana i.MX6 Dual/Quad GW54XX";
 	compatible = "gw,imx6q-gw54xx", "gw,ventana", "fsl,imx6q";
+
+	sound-digital {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "tda1997x-audio";
+
+		simple-audio-card,dai-link@0 {
+			format = "i2s";
+
+			cpu {
+				sound-dai = <&ssi2>;
+			};
+
+			codec {
+				bitclock-master;
+				frame-master;
+				sound-dai = <&tda1997x>;
+			};
+		};
+	};
 };
 
 &i2c3 {
@@ -35,6 +55,61 @@
 			};
 		};
 	};
+
+	tda1997x: codec@48 {
+		compatible = "nxp,tda19971";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_tda1997x>;
+		reg = <0x48>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+		DOVDD-supply = <&reg_3p3v>;
+		AVDD-supply = <&sw4_reg>;
+		DVDD-supply = <&sw4_reg>;
+		#sound-dai-cells = <0>;
+		nxp,audout-format = "i2s";
+		nxp,audout-layout = <0>;
+		nxp,audout-width = <16>;
+		nxp,audout-mclk-fs = <128>;
+		/*
+		 * The 8bpp YUV422 semi-planar mode outputs CbCr[11:4]
+		 * and Y[11:4] across 16bits in the same cycle
+		 * which we map to VP[15:08]<->CSI_DATA[19:12]
+		 */
+		nxp,vidout-portcfg =
+			/*G_Y_11_8<->VP[15:12]<->CSI_DATA[19:16]*/
+			< TDA1997X_VP24_V15_12 TDA1997X_G_Y_11_8 >,
+			/*G_Y_7_4<->VP[11:08]<->CSI_DATA[15:12]*/
+			< TDA1997X_VP24_V11_08 TDA1997X_G_Y_7_4 >,
+			/*R_CR_CBCR_11_8<->VP[07:04]<->CSI_DATA[11:08]*/
+			< TDA1997X_VP24_V07_04 TDA1997X_R_CR_CBCR_11_8 >,
+			/*R_CR_CBCR_7_4<->VP[03:00]<->CSI_DATA[07:04]*/
+			< TDA1997X_VP24_V03_00 TDA1997X_R_CR_CBCR_7_4 >;
+
+		port {
+			tda1997x_to_ipu1_csi0_mux: endpoint {
+				remote-endpoint = <&ipu1_csi0_mux_from_parallel_sensor>;
+				bus-width = <16>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+				data-active = <1>;
+			};
+		};
+	};
+};
+
+&ipu1_csi0_from_ipu1_csi0_mux {
+	bus-width = <16>;
+};
+
+&ipu1_csi0_mux_from_parallel_sensor {
+	remote-endpoint = <&tda1997x_to_ipu1_csi0_mux>;
+	bus-width = <16>;
+};
+
+&ipu1_csi0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_ipu1_csi0>;
 };
 
 &ipu2_csi1_from_ipu2_csi1_mux {
@@ -63,6 +138,30 @@
 		>;
 	};
 
+	pinctrl_ipu1_csi0: ipu1_csi0grp {
+		fsl,pins = <
+			MX6QDL_PAD_CSI0_DAT4__IPU1_CSI0_DATA04		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT5__IPU1_CSI0_DATA05		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT6__IPU1_CSI0_DATA06		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT7__IPU1_CSI0_DATA07		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT8__IPU1_CSI0_DATA08		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT9__IPU1_CSI0_DATA09		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT10__IPU1_CSI0_DATA10		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT11__IPU1_CSI0_DATA11		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT12__IPU1_CSI0_DATA12		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT15__IPU1_CSI0_DATA15		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT16__IPU1_CSI0_DATA16		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT17__IPU1_CSI0_DATA17		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT18__IPU1_CSI0_DATA18		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT19__IPU1_CSI0_DATA19		0x1b0b0
+			MX6QDL_PAD_CSI0_MCLK__IPU1_CSI0_HSYNC		0x1b0b0
+			MX6QDL_PAD_CSI0_PIXCLK__IPU1_CSI0_PIXCLK	0x1b0b0
+			MX6QDL_PAD_CSI0_VSYNC__IPU1_CSI0_VSYNC		0x1b0b0
+		>;
+	};
+
 	pinctrl_ipu2_csi1: ipu2_csi1grp {
 		fsl,pins = <
 			MX6QDL_PAD_EIM_EB2__IPU2_CSI1_DATA19    0x1b0b0
@@ -78,4 +177,10 @@
 			MX6QDL_PAD_EIM_A16__IPU2_CSI1_PIXCLK    0x1b0b0
 		>;
 	};
+
+	pinctrl_tda1997x: tda1997xgrp {
+		fsl,pins = <
+			MX6QDL_PAD_GPIO_7__GPIO1_IO07	0x1b0b0
+		>;
+	};
 };
arch/arm/boot/dts/imx6qdl-gw54xx.dtsi +26 -3
index eab75f3..f9e1fb9 100644
@@ -10,6 +10,7 @@
  */
 
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/sound/fsl-imx-audmux.h>
 
 / {
 	/* these are used by bootloader for disabling nodes */
@@ -114,12 +115,12 @@
 		};
 	};
 
-	sound {
+	sound-analog {
 		compatible = "fsl,imx6q-ventana-sgtl5000",
 			     "fsl,imx-audio-sgtl5000";
 		model = "sgtl5000-audio";
 		ssi-controller = <&ssi1>;
-		audio-codec = <&codec>;
+		audio-codec = <&sgtl5000>;
 		audio-routing =
 			"MIC_IN", "Mic Jack",
 			"Mic Jack", "Mic Bias",
@@ -133,6 +134,25 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_audmux>; /* AUD4<->sgtl5000 */
 	status = "okay";
+
+	ssi2 {
+		fsl,audmux-port = <1>;
+		fsl,port-config = <
+			(IMX_AUDMUX_V2_PTCR_TFSDIR |
+			IMX_AUDMUX_V2_PTCR_TFSEL(4+8) | /* RXFS */
+			IMX_AUDMUX_V2_PTCR_TCLKDIR |
+			IMX_AUDMUX_V2_PTCR_TCSEL(4+8) | /* RXC */
+			IMX_AUDMUX_V2_PTCR_SYN)
+			IMX_AUDMUX_V2_PDCR_RXDSEL(4)
+		>;
+	};
+
+	aud5 {
+		fsl,audmux-port = <4>;
+		fsl,port-config = <
+			IMX_AUDMUX_V2_PTCR_SYN
+			IMX_AUDMUX_V2_PDCR_RXDSEL(1)>;
+	};
 };
 
 &can1 {
@@ -331,7 +351,7 @@
 	pinctrl-0 = <&pinctrl_i2c3>;
 	status = "okay";
 
-	codec: sgtl5000@a {
+	sgtl5000: codec@a {
 		compatible = "fsl,sgtl5000";
 		reg = <0x0a>;
 		clocks = <&clks IMX6QDL_CLK_CKO>;
@@ -475,6 +495,9 @@
 			MX6QDL_PAD_SD2_DAT2__AUD4_TXD		0x110b0
 			MX6QDL_PAD_SD2_DAT1__AUD4_TXFS		0x130b0
 			MX6QDL_PAD_GPIO_0__CCM_CLKO1		0x130b0 /* AUD4_MCK */
+			MX6QDL_PAD_EIM_D25__AUD5_RXC            0x130b0
+			MX6QDL_PAD_DISP0_DAT19__AUD5_RXD        0x130b0
+			MX6QDL_PAD_EIM_D24__AUD5_RXFS           0x130b0
 		>;
 	};
 
Signature · 1 line
2.7.4
author maintainer
#14 lore raw

PATCH v9 8/8 ARM: dts: imx: Add TDA19971 HDMI Receiver to GW551x

In reply to Tim Harvey

---
v5:
- add missing audmux config

 arch/arm/boot/dts/imx6qdl-gw551x.dtsi | 138 ++++++++++++++++++++++++++++++++++
 1 file changed, 138 insertions(+)
arch/arm/boot/dts/imx6qdl-gw551x.dtsi +138 -0
index 30d4662..749548a 100644
@@ -46,6 +46,8 @@
  */
 
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/media/tda1997x.h>
+#include <dt-bindings/sound/fsl-imx-audmux.h>
 
 / {
 	/* these are used by bootloader for disabling nodes */
@@ -98,6 +100,50 @@
 		regulator-min-microvolt = <5000000>;
 		regulator-max-microvolt = <5000000>;
 	};
+
+	sound-digital {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "tda1997x-audio";
+
+		simple-audio-card,dai-link@0 {
+			format = "i2s";
+
+			cpu {
+				sound-dai = <&ssi2>;
+			};
+
+			codec {
+				bitclock-master;
+				frame-master;
+				sound-dai = <&tda1997x>;
+			};
+		};
+	};
+};
+
+&audmux {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_audmux>; /* AUD5<->tda1997x */
+	status = "okay";
+
+	ssi1 {
+		fsl,audmux-port = <0>;
+		fsl,port-config = <
+			(IMX_AUDMUX_V2_PTCR_TFSDIR |
+			IMX_AUDMUX_V2_PTCR_TFSEL(4+8) | /* RXFS */
+			IMX_AUDMUX_V2_PTCR_TCLKDIR |
+			IMX_AUDMUX_V2_PTCR_TCSEL(4+8) | /* RXC */
+			IMX_AUDMUX_V2_PTCR_SYN)
+			IMX_AUDMUX_V2_PDCR_RXDSEL(4)
+		>;
+	};
+
+	aud5 {
+		fsl,audmux-port = <4>;
+		fsl,port-config = <
+			IMX_AUDMUX_V2_PTCR_SYN
+			IMX_AUDMUX_V2_PDCR_RXDSEL(0)>;
+	};
 };
 
 &can1 {
@@ -263,6 +309,60 @@
 		#gpio-cells = <2>;
 	};
 
+	tda1997x: tda1997x@48 {
+		compatible = "nxp,tda19971";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_tda1997x>;
+		reg = <0x48>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+		DOVDD-supply = <&reg_3p3>;
+		AVDD-supply = <&reg_1p8b>;
+		DVDD-supply = <&reg_1p8a>;
+		#sound-dai-cells = <0>;
+		nxp,audout-format = "i2s";
+		nxp,audout-layout = <0>;
+		nxp,audout-width = <16>;
+		nxp,audout-mclk-fs = <128>;
+		/*
+		 * The 8bpp YUV422 semi-planar mode outputs CbCr[11:4]
+		 * and Y[11:4] across 16bits in the same cycle
+		 * which we map to VP[15:08]<->CSI_DATA[19:12]
+		 */
+		nxp,vidout-portcfg =
+			/*G_Y_11_8<->VP[15:12]<->CSI_DATA[19:16]*/
+			< TDA1997X_VP24_V15_12 TDA1997X_G_Y_11_8 >,
+			/*G_Y_7_4<->VP[11:08]<->CSI_DATA[15:12]*/
+			< TDA1997X_VP24_V11_08 TDA1997X_G_Y_7_4 >,
+			/*R_CR_CBCR_11_8<->VP[07:04]<->CSI_DATA[11:08]*/
+			< TDA1997X_VP24_V07_04 TDA1997X_R_CR_CBCR_11_8 >,
+			/*R_CR_CBCR_7_4<->VP[03:00]<->CSI_DATA[07:04]*/
+			< TDA1997X_VP24_V03_00 TDA1997X_R_CR_CBCR_7_4 >;
+
+		port {
+			tda1997x_to_ipu1_csi0_mux: endpoint {
+				remote-endpoint = <&ipu1_csi0_mux_from_parallel_sensor>;
+				bus-width = <16>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+				data-active = <1>;
+			};
+		};
+	};
+};
+
+&ipu1_csi0_from_ipu1_csi0_mux {
+	bus-width = <16>;
+};
+
+&ipu1_csi0_mux_from_parallel_sensor {
+	remote-endpoint = <&tda1997x_to_ipu1_csi0_mux>;
+	bus-width = <16>;
+};
+
+&ipu1_csi0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_ipu1_csi0>;
 };
 
 &pcie {
@@ -320,6 +420,14 @@
 };
 
 &iomuxc {
+	pinctrl_audmux: audmuxgrp {
+		fsl,pins = <
+			MX6QDL_PAD_DISP0_DAT19__AUD5_RXD	0x130b0
+			MX6QDL_PAD_DISP0_DAT14__AUD5_RXC	0x130b0
+			MX6QDL_PAD_DISP0_DAT13__AUD5_RXFS	0x130b0
+		>;
+	};
+
 	pinctrl_flexcan1: flexcan1grp {
 		fsl,pins = <
 			MX6QDL_PAD_KEY_ROW2__FLEXCAN1_RX	0x1b0b1
@@ -375,6 +483,30 @@
 		>;
 	};
 
+	pinctrl_ipu1_csi0: ipu1_csi0grp {
+		fsl,pins = <
+			MX6QDL_PAD_CSI0_DAT4__IPU1_CSI0_DATA04		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT5__IPU1_CSI0_DATA05		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT6__IPU1_CSI0_DATA06		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT7__IPU1_CSI0_DATA07		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT8__IPU1_CSI0_DATA08		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT9__IPU1_CSI0_DATA09		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT10__IPU1_CSI0_DATA10		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT11__IPU1_CSI0_DATA11		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT12__IPU1_CSI0_DATA12		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT15__IPU1_CSI0_DATA15		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT16__IPU1_CSI0_DATA16		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT17__IPU1_CSI0_DATA17		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT18__IPU1_CSI0_DATA18		0x1b0b0
+			MX6QDL_PAD_CSI0_DAT19__IPU1_CSI0_DATA19		0x1b0b0
+			MX6QDL_PAD_CSI0_MCLK__IPU1_CSI0_HSYNC		0x1b0b0
+			MX6QDL_PAD_CSI0_PIXCLK__IPU1_CSI0_PIXCLK	0x1b0b0
+			MX6QDL_PAD_CSI0_VSYNC__IPU1_CSI0_VSYNC		0x1b0b0
+		>;
+	};
+
 	pinctrl_pcie: pciegrp {
 		fsl,pins = <
 			MX6QDL_PAD_GPIO_0__GPIO1_IO00		0x1b0b0 /* PCIE RST */
@@ -399,6 +531,12 @@
 		>;
 	};
 
+	pinctrl_tda1997x: tda1997xgrp {
+		fsl,pins = <
+			MX6QDL_PAD_GPIO_7__GPIO1_IO07		0x1b0b0
+		>;
+	};
+
 	pinctrl_uart2: uart2grp {
 		fsl,pins = <
 			MX6QDL_PAD_SD4_DAT7__UART2_TX_DATA	0x1b0b1
Signature · 1 line
2.7.4
#7 lore raw

Re: [PATCH v9 6/8] media: i2c: Add TDA1997x HDMI receiver driver

In reply to Tim Harvey

Hi Tim,

I was so hoping I could make a pull request for this, but I still found problems with g/s/query_dv_timings.

I strongly suspect that v4l2-compliance would fail if you boot up the system *without* a source connected.

And I discovered that I was missing additional checks in the timings tests for v4l2-compliance that would have found the same issue if run with a source connected. I've fixed and committed those tests now. I'll also try to test that a S_DV_TIMINGS calls updates the format.

Details below:

Quoted 1 line · Tim Harvey

+struct tda1997x_state {

...

Quoted 2 lines
drivers/media/i2c/tda1997x.c new file +2 -0
+	struct v4l2_dv_timings timings;
+	const struct v4l2_dv_timings *detected_timings;

...

Quoted 6 lines
drivers/media/i2c/tda1997x.c new file +6 -0
+/* Configure frame detection window and VHREF timing generator */
+static int
+tda1997x_configure_vhref(struct v4l2_subdev *sd)
+{
+	struct tda1997x_state *state = to_state(sd);
+	const struct v4l2_bt_timings *bt;

drivers/media/i2c/tda1997x.c line 760

Quoted 10 lines
drivers/media/i2c/tda1997x.c new file +10 -0
+	int width, lines;
+	u16 href_start, href_end;
+	u16 vref_f1_start, vref_f2_start;
+	u8 vref_f1_width, vref_f2_width;
+	u8 field_polarity;
+	u16 fieldref_f1_start, fieldref_f2_start;
+	u8 reg;
+
+	if (!state->detected_timings)
+		return -EINVAL;

Why this test? Who cares if there are no detected timings? It's certainly not a failure. S_DV_TIMINGS should succeed regardless of whether there is a signal or not and regardless of the current detected timings.

Review

Quoted 1 line
(quoted diff) +1 -0
+	bt = &state->detected_timings->bt;

Ouch. The timings passed in with S_DV_TIMINGS should be used.

Just use state->timings here, not detected_timings.

Quoted 72 lines
drivers/media/i2c/tda1997x.c new file +72 -0
+	href_start = bt->hbackporch + bt->hsync + 1;
+	href_end = href_start + bt->width;
+	vref_f1_start = bt->height + bt->vbackporch + bt->vsync +
+			bt->il_vbackporch + bt->il_vsync +
+			bt->il_vfrontporch;
+	vref_f1_width = bt->vbackporch + bt->vsync + bt->vfrontporch;
+	vref_f2_start = 0;
+	vref_f2_width = 0;
+	fieldref_f1_start = 0;
+	fieldref_f2_start = 0;
+	if (bt->interlaced) {
+		vref_f2_start = (bt->height / 2) +
+				(bt->il_vbackporch + bt->il_vsync - 1);
+		vref_f2_width = bt->il_vbackporch + bt->il_vsync +
+				bt->il_vfrontporch;
+		fieldref_f2_start = vref_f2_start + bt->il_vfrontporch +
+				    fieldref_f1_start;
+	}
+	field_polarity = 0;
+
+	width = V4L2_DV_BT_FRAME_WIDTH(bt);
+	lines = V4L2_DV_BT_FRAME_HEIGHT(bt);
+
+	/*
+	 * Configure Frame Detection Window:
+	 *  horiz area where the VHREF module consider a VSYNC a new frame
+	 */
+	io_write16(sd, REG_FDW_S, 0x2ef); /* start position */
+	io_write16(sd, REG_FDW_E, 0x141); /* end position */
+
+	/* Set Pixel And Line Counters */
+	if (state->chip_revision == 0)
+		io_write16(sd, REG_PXCNT_PR, 4);
+	else
+		io_write16(sd, REG_PXCNT_PR, 1);
+	io_write16(sd, REG_PXCNT_NPIX, width & MASK_VHREF);
+	io_write16(sd, REG_LCNT_PR, 1);
+	io_write16(sd, REG_LCNT_NLIN, lines & MASK_VHREF);
+
+	/*
+	 * Configure the VHRef timing generator responsible for rebuilding all
+	 * horiz and vert synch and ref signals from its input allowing auto
+	 * detection algorithms and forcing predefined modes (480i & 576i)
+	 */
+	reg = VHREF_STD_DET_OFF << VHREF_STD_DET_SHIFT;
+	io_write(sd, REG_VHREF_CTRL, reg);
+
+	/*
+	 * Configure the VHRef timing values. In case the VHREF generator has
+	 * been configured in manual mode, this will allow to manually set all
+	 * horiz and vert ref values (non-active pixel areas) of the generator
+	 * and allows setting the frame reference params.
+	 */
+	/* horizontal reference start/end */
+	io_write16(sd, REG_HREF_S, href_start & MASK_VHREF);
+	io_write16(sd, REG_HREF_E, href_end & MASK_VHREF);
+	/* vertical reference f1 start/end */
+	io_write16(sd, REG_VREF_F1_S, vref_f1_start & MASK_VHREF);
+	io_write(sd, REG_VREF_F1_WIDTH, vref_f1_width);
+	/* vertical reference f2 start/end */
+	io_write16(sd, REG_VREF_F2_S, vref_f2_start & MASK_VHREF);
+	io_write(sd, REG_VREF_F2_WIDTH, vref_f2_width);
+
+	/* F1/F2 FREF, field polarity */
+	reg = fieldref_f1_start & MASK_VHREF;
+	reg |= field_polarity << 8;
+	io_write16(sd, REG_FREF_F1_S, reg);
+	reg = fieldref_f2_start & MASK_VHREF;
+	io_write16(sd, REG_FREF_F2_S, reg);
+
+	return 0;
+}

...

Quoted 63 lines
drivers/media/i2c/tda1997x.c new file +63 -0
+static int
+tda1997x_detect_std(struct tda1997x_state *state)
+{
+	struct v4l2_subdev *sd = &state->sd;
+	u32 vper;
+	u16 hper;
+	u16 hsper;
+	int i;
+
+	/*
+	 * Read the FMT registers
+	 *   REG_V_PER: Period of a frame (or two fields) in MCLK(27MHz) cycles
+	 *   REG_H_PER: Period of a line in MCLK(27MHz) cycles
+	 *   REG_HS_WIDTH: Period of horiz sync pulse in MCLK(27MHz) cycles
+	 */
+	vper = io_read24(sd, REG_V_PER) & MASK_VPER;
+	hper = io_read16(sd, REG_H_PER) & MASK_HPER;
+	hsper = io_read16(sd, REG_HS_WIDTH) & MASK_HSWIDTH;
+	if (!vper || !hper || !hsper)
+		return -ENOLINK;
+	v4l2_dbg(1, debug, sd, "Signal Timings: %u/%u/%u\n", vper, hper, hsper);
+
+	for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
+		const struct v4l2_bt_timings *bt;
+		u32 lines, width, _hper, _hsper;
+		u32 vmin, vmax, hmin, hmax, hsmin, hsmax;
+		bool vmatch, hmatch, hsmatch;
+
+		bt = &v4l2_dv_timings_presets[i].bt;
+		width = V4L2_DV_BT_FRAME_WIDTH(bt);
+		lines = V4L2_DV_BT_FRAME_HEIGHT(bt);
+		_hper = (u32)bt->pixelclock / width;
+		if (bt->interlaced)
+			lines /= 2;
+		/* vper +/- 0.7% */
+		vmin = ((27000000 / 1000) * 993) / _hper * lines;
+		vmax = ((27000000 / 1000) * 1007) / _hper * lines;
+		/* hper +/- 1.0% */
+		hmin = ((27000000 / 100) * 99) / _hper;
+		hmax = ((27000000 / 100) * 101) / _hper;
+		/* hsper +/- 2 (take care to avoid 32bit overflow) */
+		_hsper = 27000 * bt->hsync / ((u32)bt->pixelclock/1000);
+		hsmin = _hsper - 2;
+		hsmax = _hsper + 2;
+
+		/* vmatch matches the framerate */
+		vmatch = ((vper <= vmax) && (vper >= vmin)) ? 1 : 0;
+		/* hmatch matches the width */
+		hmatch = ((hper <= hmax) && (hper >= hmin)) ? 1 : 0;
+		/* hsmatch matches the hswidth */
+		hsmatch = ((hsper <= hsmax) && (hsper >= hsmin)) ? 1 : 0;
+		if (hmatch && vmatch && hsmatch) {
+			state->detected_timings = &v4l2_dv_timings_presets[i];
+			v4l2_print_dv_timings(sd->name, "Detected format: ",
+					      state->detected_timings, false);
+			return 0;
+		}
+	}
+
+	v4l_err(state->client, "no resolution match for timings: %d/%d/%d\n",
+		vper, hper, hsper);
+	return -EINVAL;
+}

...

Quoted 36 lines
drivers/media/i2c/tda1997x.c new file +36 -0
+static void tda1997x_irq_sus(struct tda1997x_state *state, u8 *flags)
+{
+	struct v4l2_subdev *sd = &state->sd;
+	u8 reg, source;
+
+	source = io_read(sd, REG_INT_FLG_CLR_SUS);
+	io_write(sd, REG_INT_FLG_CLR_SUS, source);
+
+	if (source & MASK_MPT) {
+		/* reset MTP in use flag if set */
+		if (state->mptrw_in_progress)
+			state->mptrw_in_progress = 0;
+	}
+
+	if (source & MASK_SUS_END) {
+		/* reset audio FIFO */
+		reg = io_read(sd, REG_HDMI_INFO_RST);
+		reg |= MASK_SR_FIFO_FIFO_CTRL;
+		io_write(sd, REG_HDMI_INFO_RST, reg);
+		reg &= ~MASK_SR_FIFO_FIFO_CTRL;
+		io_write(sd, REG_HDMI_INFO_RST, reg);
+
+		/* reset HDMI flags */
+		state->hdmi_status = 0;
+	}
+
+	/* filter FMT interrupt based on SUS state */
+	reg = io_read(sd, REG_SUS_STATUS);
+	if (((reg & MASK_SUS_STATUS) != LAST_STATE_REACHED)
+	   || (source & MASK_MPT)) {
+		source &= ~MASK_FMT;
+	}
+
+	if (source & (MASK_FMT | MASK_SUS_END)) {
+		reg = io_read(sd, REG_SUS_STATUS);
+		if ((reg & MASK_SUS_STATUS) != LAST_STATE_REACHED) {

drivers/media/i2c/tda1997x.c line 1401

Quoted 10 lines
drivers/media/i2c/tda1997x.c new file +10 -0
+			v4l_err(state->client, "BAD SUS STATUS\n");
+			return;
+		}
+
+		/* There is new activity, the status for HDCP repeater state */
+		state->state_c5_reached = 0;
+
+		/* Detect the new resolution */
+		if (!tda1997x_detect_std(state))
+			v4l2_subdev_notify_event(&state->sd, &tda1997x_ev_fmt);

Why detect a new resolution here? That only need to be done when the user calls query_dv_timings. Just send the event unconditionally to tell userspace that the resolution changed.

Quoted 2 lines
(quoted diff) +2 -0
+	}
+}

...

drivers/media/i2c/tda1997x.c line 1635

Quoted 11 lines
drivers/media/i2c/tda1997x.c new file +11 -0
+/* -----------------------------------------------------------------------------
+ * v4l2_subdev_video_ops
+ */
+
+static int
+tda1997x_g_input_status(struct v4l2_subdev *sd, u32 *status)
+{
+	struct tda1997x_state *state = to_state(sd);
+
+	mutex_lock(&state->lock);
+	if (state->detected_timings)

What this actually tests if the driver was able to detect a valid signal and lock to it.

In practice you have three possible outcomes:

- There is no HDMI signal at all: return V4L2_IN_ST_NO_SIGNAL
- There is a signal, but the receiver could not lock to it: return V4L2_IN_ST_NO_SYNC
- There is a signal, and the receiver could lock: return 0.

Just because this returns 0, doesn't mean that QUERY_DV_TIMINGS will succeed. There may be other constraints (e.g. the driver doesn't support certain formats such as interlaced) that can cause QUERY_DV_TIMINGS to return an error, even though the receiver could sync.

Usually the hardware has some bits that tell whether there is a signal (usually the TMDS clock) and whether it could sync or not (H and V syncs).

That's really all you need to test here.

Quoted 7 lines
drivers/media/i2c/tda1997x.c new file +7 -0
+		*status = 0;
+	else
+		*status |= V4L2_IN_ST_NO_SIGNAL;
+	mutex_unlock(&state->lock);
+
+	return 0;
+};

drivers/media/i2c/tda1997x.c line 1652

Quoted 10 lines
drivers/media/i2c/tda1997x.c new file +10 -0
+
+static int tda1997x_s_dv_timings(struct v4l2_subdev *sd,
+				struct v4l2_dv_timings *timings)
+{
+	struct tda1997x_state *state = to_state(sd);
+	int ret;
+
+	v4l_dbg(1, debug, state->client, "%s\n", __func__);
+	if (!timings)
+		return -EINVAL;

These 'if (!timings)' tests are not needed and can be dropped here and elsewhere.

Quoted 48 lines
drivers/media/i2c/tda1997x.c new file +48 -0
+
+	if (v4l2_match_dv_timings(&state->timings, timings, 0, false))
+		return 0; /* no changes */
+
+	if (!v4l2_valid_dv_timings(timings, &tda1997x_dv_timings_cap,
+				   NULL, NULL))
+		return -ERANGE;
+
+	mutex_lock(&state->lock);
+	state->timings = *timings;
+	/* setup frame detection window and VHREF timing generator */
+	ret = tda1997x_configure_vhref(sd);
+	if (ret)
+		goto error;
+	/* configure colorspace conversion */
+	ret = tda1997x_configure_csc(sd);
+	if (ret)
+		goto error;
+	mutex_unlock(&state->lock);
+
+	return 0;
+
+error:
+	mutex_unlock(&state->lock);
+	return ret;
+}
+
+static int tda1997x_g_dv_timings(struct v4l2_subdev *sd,
+				 struct v4l2_dv_timings *timings)
+{
+	struct tda1997x_state *state = to_state(sd);
+
+	v4l_dbg(1, debug, state->client, "%s\n", __func__);
+	if (!timings)
+		return -EINVAL;
+
+	mutex_lock(&state->lock);
+	*timings = state->timings;
+	mutex_unlock(&state->lock);
+
+	return 0;
+}
+
+static int tda1997x_query_dv_timings(struct v4l2_subdev *sd,
+				     struct v4l2_dv_timings *timings)
+{
+	struct tda1997x_state *state = to_state(sd);
+	int ret;

drivers/media/i2c/tda1997x.c line 1710

Quoted 10 lines
drivers/media/i2c/tda1997x.c new file +10 -0
+
+	v4l_dbg(1, debug, state->client, "%s\n", __func__);
+	if (!timings)
+		return -EINVAL;
+
+	memset(timings, 0, sizeof(struct v4l2_dv_timings));
+	mutex_lock(&state->lock);
+	ret = tda1997x_detect_std(state);
+	if (!ret)
+		*timings = *state->detected_timings;

I think you can just drop the 'detected_timings' field and just do tda1997x_detect_std(state, timings); here. That way you are not tempted to use 'detected_timings' in places where you shouldn't :-)

Quoted 7 lines
drivers/media/i2c/tda1997x.c new file +7 -0
+	mutex_unlock(&state->lock);
+
+	return ret;
+}
+
+static int tda1997x_s_stream(struct v4l2_subdev *sd, int enable)
+{

drivers/media/i2c/tda1997x.c line 1727

Quoted 10 lines
drivers/media/i2c/tda1997x.c new file +10 -0
+	struct tda1997x_state *state = to_state(sd);
+
+	v4l_dbg(1, debug, state->client, "%s %d\n", __func__, enable);
+	mutex_lock(&state->lock);
+	if (!state->detected_timings)
+		v4l_dbg(1, debug, state->client, "Invalid HDMI signal\n");
+	mutex_unlock(&state->lock);
+
+	return 0;
+}

I'd drop this. It isn't helpful.

Quoted 44 lines
drivers/media/i2c/tda1997x.c new file +44 -0
+
+static const struct v4l2_subdev_video_ops tda1997x_video_ops = {
+	.g_input_status = tda1997x_g_input_status,
+	.s_dv_timings = tda1997x_s_dv_timings,
+	.g_dv_timings = tda1997x_g_dv_timings,
+	.query_dv_timings = tda1997x_query_dv_timings,
+	.s_stream = tda1997x_s_stream,
+};
+
+
+/* -----------------------------------------------------------------------------
+ * v4l2_subdev_pad_ops
+ */
+
+static int tda1997x_init_cfg(struct v4l2_subdev *sd,
+			     struct v4l2_subdev_pad_config *cfg)
+{
+	struct tda1997x_state *state = to_state(sd);
+	struct v4l2_mbus_framefmt *mf;
+
+	mf = v4l2_subdev_get_try_format(sd, cfg, 0);
+	mf->code = state->mbus_codes[0];
+
+	return 0;
+}
+
+static int tda1997x_enum_mbus_code(struct v4l2_subdev *sd,
+				  struct v4l2_subdev_pad_config *cfg,
+				  struct v4l2_subdev_mbus_code_enum *code)
+{
+	struct tda1997x_state *state = to_state(sd);
+
+	v4l_dbg(1, debug, state->client, "%s %d/%d\n", __func__,
+		code->index, ARRAY_SIZE(state->mbus_codes));
+	if (code->index >= ARRAY_SIZE(state->mbus_codes))
+		return -EINVAL;
+
+	if (!state->mbus_codes[code->index])
+		return -EINVAL;
+
+	code->code = state->mbus_codes[code->index];
+
+	return 0;
+}

drivers/media/i2c/tda1997x.c line 1781

Quoted 10 lines
drivers/media/i2c/tda1997x.c new file +10 -0
+
+static int tda1997x_fill_format(struct tda1997x_state *state,
+				struct v4l2_mbus_framefmt *format)
+{
+	const struct v4l2_bt_timings *bt;
+
+	v4l_dbg(1, debug, state->client, "%s\n", __func__);
+
+	if (!state->detected_timings)
+		return -EINVAL;

Ouch. Just drop this.

drivers/media/i2c/tda1997x.c line 1784

Quoted 3 lines
drivers/media/i2c/tda1997x.c new file +3 -0
+
+	memset(format, 0, sizeof(*format));
+	bt = &state->detected_timings->bt;

and use &state->timings.bt here. That is how the receiver is configured.

drivers/media/i2c/tda1997x.c line 1792

Quoted 8 lines
drivers/media/i2c/tda1997x.c new file +8 -0
+	format->width = bt->width;
+	format->height = bt->height;
+	format->colorspace = state->colorimetry.colorspace;
+	format->field = (bt->interlaced) ?
+		V4L2_FIELD_SEQ_TB : V4L2_FIELD_NONE;
+
+	return 0;
+}

The *only* time you need to care about the actual detected timings is when userspace calls QUERY_DV_TIMINGS. Never anywhere else.

s_input_status is used to test some basics (do I have a signal, can I lock) but doesn't go 'in-depth'.

If the interrupt routine detects a resolution change or it loses a stable signal, then it sends an event to userspace, but nothing else should change.

Look at adv7604.c: the only time it attempts to detect the timings with read_stdi() is when called from query_dv_timings (and log_status for debugging).

Regards,

Hans

author maintainer
#8 lore raw

Re: [PATCH v9 6/8] media: i2c: Add TDA1997x HDMI receiver driver

Quoted 37 lines · Hans Verkuil

Hi Tim,

I was so hoping I could make a pull request for this, but I still found problems with g/s/query_dv_timings.

I strongly suspect that v4l2-compliance would fail if you boot up the system *without* a source connected.

And I discovered that I was missing additional checks in the timings tests for v4l2-compliance that would have found the same issue if run with a source connected. I've fixed and committed those tests now. I'll also try to test that a S_DV_TIMINGS calls updates the format.

Details below:

Quoted 1 line · Tim Harvey

+struct tda1997x_state {

...

Quoted 2 lines
drivers/media/i2c/tda1997x.c new file +2 -0
+     struct v4l2_dv_timings timings;
+     const struct v4l2_dv_timings *detected_timings;

...

Quoted 12 lines
drivers/media/i2c/tda1997x.c new file +12 -0
+/* Configure frame detection window and VHREF timing generator */
+static int
+tda1997x_configure_vhref(struct v4l2_subdev *sd)
+{
+     struct tda1997x_state *state = to_state(sd);
+     const struct v4l2_bt_timings *bt;
+     int width, lines;
+     u16 href_start, href_end;
+     u16 vref_f1_start, vref_f2_start;
+     u8 vref_f1_width, vref_f2_width;
+     u8 field_polarity;
+     u16 fieldref_f1_start, fieldref_f2_start;
Quoted 9 lines

drivers/media/i2c/tda1997x.c line 760

Quoted 4 lines
drivers/media/i2c/tda1997x.c new file +4 -0
+     u8 reg;
+
+     if (!state->detected_timings)
+             return -EINVAL;

Why this test? Who cares if there are no detected timings? It's certainly not a failure. S_DV_TIMINGS should succeed regardless of whether there is a signal or not and regardless of the current detected timings.

good point. Both tda1997x_configure_vhref() and tda1997x_configure_csc() should never return an error - I'll change that.

Quoted 5 lines
Quoted 1 line

+ bt = &state->detected_timings->bt;

Ouch. The timings passed in with S_DV_TIMINGS should be used.

Just use state->timings here, not detected_timings.

Ok. I was thinking the VHREF generator responsible for output timings to the SoC should always match the input source but changing it async like that could mess with userspace buffers and the like so even though the output will be 'wrong' after a resolution change I get that I need to wait for userspace to come along and query then set the new resolution.

Quoted 73 lines
Quoted 73 lines
drivers/media/i2c/tda1997x.c new file +72 -0
+     href_start = bt->hbackporch + bt->hsync + 1;
+     href_end = href_start + bt->width;
+     vref_f1_start = bt->height + bt->vbackporch + bt->vsync +
+                     bt->il_vbackporch + bt->il_vsync +
+                     bt->il_vfrontporch;
+     vref_f1_width = bt->vbackporch + bt->vsync + bt->vfrontporch;
+     vref_f2_start = 0;
+     vref_f2_width = 0;
+     fieldref_f1_start = 0;
+     fieldref_f2_start = 0;
+     if (bt->interlaced) {
+             vref_f2_start = (bt->height / 2) +
+                             (bt->il_vbackporch + bt->il_vsync - 1);
+             vref_f2_width = bt->il_vbackporch + bt->il_vsync +
+                             bt->il_vfrontporch;
+             fieldref_f2_start = vref_f2_start + bt->il_vfrontporch +
+                                 fieldref_f1_start;
+     }
+     field_polarity = 0;
+
+     width = V4L2_DV_BT_FRAME_WIDTH(bt);
+     lines = V4L2_DV_BT_FRAME_HEIGHT(bt);
+
+     /*
+      * Configure Frame Detection Window:
+      *  horiz area where the VHREF module consider a VSYNC a new frame
+      */
+     io_write16(sd, REG_FDW_S, 0x2ef); /* start position */
+     io_write16(sd, REG_FDW_E, 0x141); /* end position */
+
+     /* Set Pixel And Line Counters */
+     if (state->chip_revision == 0)
+             io_write16(sd, REG_PXCNT_PR, 4);
+     else
+             io_write16(sd, REG_PXCNT_PR, 1);
+     io_write16(sd, REG_PXCNT_NPIX, width & MASK_VHREF);
+     io_write16(sd, REG_LCNT_PR, 1);
+     io_write16(sd, REG_LCNT_NLIN, lines & MASK_VHREF);
+
+     /*
+      * Configure the VHRef timing generator responsible for rebuilding all
+      * horiz and vert synch and ref signals from its input allowing auto
+      * detection algorithms and forcing predefined modes (480i & 576i)
+      */
+     reg = VHREF_STD_DET_OFF << VHREF_STD_DET_SHIFT;
+     io_write(sd, REG_VHREF_CTRL, reg);
+
+     /*
+      * Configure the VHRef timing values. In case the VHREF generator has
+      * been configured in manual mode, this will allow to manually set all
+      * horiz and vert ref values (non-active pixel areas) of the generator
+      * and allows setting the frame reference params.
+      */
+     /* horizontal reference start/end */
+     io_write16(sd, REG_HREF_S, href_start & MASK_VHREF);
+     io_write16(sd, REG_HREF_E, href_end & MASK_VHREF);
+     /* vertical reference f1 start/end */
+     io_write16(sd, REG_VREF_F1_S, vref_f1_start & MASK_VHREF);
+     io_write(sd, REG_VREF_F1_WIDTH, vref_f1_width);
+     /* vertical reference f2 start/end */
+     io_write16(sd, REG_VREF_F2_S, vref_f2_start & MASK_VHREF);
+     io_write(sd, REG_VREF_F2_WIDTH, vref_f2_width);
+
+     /* F1/F2 FREF, field polarity */
+     reg = fieldref_f1_start & MASK_VHREF;
+     reg |= field_polarity << 8;
+     io_write16(sd, REG_FREF_F1_S, reg);
+     reg = fieldref_f2_start & MASK_VHREF;
+     io_write16(sd, REG_FREF_F2_S, reg);
+
+     return 0;
+}

<snip>

Quoted 42 lines
Quoted 42 lines
drivers/media/i2c/tda1997x.c new file +42 -0
+static void tda1997x_irq_sus(struct tda1997x_state *state, u8 *flags)
+{
+     struct v4l2_subdev *sd = &state->sd;
+     u8 reg, source;
+
+     source = io_read(sd, REG_INT_FLG_CLR_SUS);
+     io_write(sd, REG_INT_FLG_CLR_SUS, source);
+
+     if (source & MASK_MPT) {
+             /* reset MTP in use flag if set */
+             if (state->mptrw_in_progress)
+                     state->mptrw_in_progress = 0;
+     }
+
+     if (source & MASK_SUS_END) {
+             /* reset audio FIFO */
+             reg = io_read(sd, REG_HDMI_INFO_RST);
+             reg |= MASK_SR_FIFO_FIFO_CTRL;
+             io_write(sd, REG_HDMI_INFO_RST, reg);
+             reg &= ~MASK_SR_FIFO_FIFO_CTRL;
+             io_write(sd, REG_HDMI_INFO_RST, reg);
+
+             /* reset HDMI flags */
+             state->hdmi_status = 0;
+     }
+
+     /* filter FMT interrupt based on SUS state */
+     reg = io_read(sd, REG_SUS_STATUS);
+     if (((reg & MASK_SUS_STATUS) != LAST_STATE_REACHED)
+        || (source & MASK_MPT)) {
+             source &= ~MASK_FMT;
+     }
+
+     if (source & (MASK_FMT | MASK_SUS_END)) {
+             reg = io_read(sd, REG_SUS_STATUS);
+             if ((reg & MASK_SUS_STATUS) != LAST_STATE_REACHED) {
+                     v4l_err(state->client, "BAD SUS STATUS\n");
+                     return;
+             }
+
+             /* There is new activity, the status for HDCP repeater state */
+             state->state_c5_reached = 0;
Quoted 9 lines

drivers/media/i2c/tda1997x.c line 1401

Quoted 4 lines
drivers/media/i2c/tda1997x.c new file +4 -0
+
+             /* Detect the new resolution */
+             if (!tda1997x_detect_std(state))
+                     v4l2_subdev_notify_event(&state->sd, &tda1997x_ev_fmt);

Why detect a new resolution here? That only need to be done when the user calls query_dv_timings. Just send the event unconditionally to tell userspace that the resolution changed.

Right - don't need to do 'anything' with the new detected timings until the user asks about them. I get it now.

Quoted 31 lines
Quoted 2 lines
(quoted diff) +2 -0
+     }
+}

...

drivers/media/i2c/tda1997x.c line 1635

Quoted 11 lines
drivers/media/i2c/tda1997x.c new file +11 -0
+/* -----------------------------------------------------------------------------
+ * v4l2_subdev_video_ops
+ */
+
+static int
+tda1997x_g_input_status(struct v4l2_subdev *sd, u32 *status)
+{
+     struct tda1997x_state *state = to_state(sd);
+
+     mutex_lock(&state->lock);
+     if (state->detected_timings)

What this actually tests if the driver was able to detect a valid signal and lock to it.

In practice you have three possible outcomes:

- There is no HDMI signal at all: return V4L2_IN_ST_NO_SIGNAL
- There is a signal, but the receiver could not lock to it: return V4L2_IN_ST_NO_SYNC
- There is a signal, and the receiver could lock: return 0.

Just because this returns 0, doesn't mean that QUERY_DV_TIMINGS will succeed. There may be other constraints (e.g. the driver doesn't support certain formats such as interlaced) that can cause QUERY_DV_TIMINGS to return an error, even though the receiver could sync.

Quoted 4 lines

Usually the hardware has some bits that tell whether there is a signal (usually the TMDS clock) and whether it could sync or not (H and V syncs).

That's really all you need to test here.

makes sense. I don't have any decent documentation on the TMDS regs used in tda1997x_read_activity_status but I can use the some other things to determine this.

I don't see v4l2-subdev.c (or anything) ever calling g_input_status. How do I test this?

Quoted 13 lines
Quoted 13 lines
drivers/media/i2c/tda1997x.c new file +12 -0
+             *status = 0;
+     else
+             *status |= V4L2_IN_ST_NO_SIGNAL;
+     mutex_unlock(&state->lock);
+
+     return 0;
+};
+
+static int tda1997x_s_dv_timings(struct v4l2_subdev *sd,
+                             struct v4l2_dv_timings *timings)
+{
+     struct tda1997x_state *state = to_state(sd);
Quoted 8 lines

drivers/media/i2c/tda1997x.c line 1652

Quoted 5 lines
drivers/media/i2c/tda1997x.c new file +5 -0
+     int ret;
+
+     v4l_dbg(1, debug, state->client, "%s\n", __func__);
+     if (!timings)
+             return -EINVAL;

These 'if (!timings)' tests are not needed and can be dropped here and elsewhere.

ok

Quoted 55 lines
Quoted 55 lines
drivers/media/i2c/tda1997x.c new file +54 -0
+
+     if (v4l2_match_dv_timings(&state->timings, timings, 0, false))
+             return 0; /* no changes */
+
+     if (!v4l2_valid_dv_timings(timings, &tda1997x_dv_timings_cap,
+                                NULL, NULL))
+             return -ERANGE;
+
+     mutex_lock(&state->lock);
+     state->timings = *timings;
+     /* setup frame detection window and VHREF timing generator */
+     ret = tda1997x_configure_vhref(sd);
+     if (ret)
+             goto error;
+     /* configure colorspace conversion */
+     ret = tda1997x_configure_csc(sd);
+     if (ret)
+             goto error;
+     mutex_unlock(&state->lock);
+
+     return 0;
+
+error:
+     mutex_unlock(&state->lock);
+     return ret;
+}
+
+static int tda1997x_g_dv_timings(struct v4l2_subdev *sd,
+                              struct v4l2_dv_timings *timings)
+{
+     struct tda1997x_state *state = to_state(sd);
+
+     v4l_dbg(1, debug, state->client, "%s\n", __func__);
+     if (!timings)
+             return -EINVAL;
+
+     mutex_lock(&state->lock);
+     *timings = state->timings;
+     mutex_unlock(&state->lock);
+
+     return 0;
+}
+
+static int tda1997x_query_dv_timings(struct v4l2_subdev *sd,
+                                  struct v4l2_dv_timings *timings)
+{
+     struct tda1997x_state *state = to_state(sd);
+     int ret;
+
+     v4l_dbg(1, debug, state->client, "%s\n", __func__);
+     if (!timings)
+             return -EINVAL;
+
+     memset(timings, 0, sizeof(struct v4l2_dv_timings));
Quoted 8 lines

drivers/media/i2c/tda1997x.c line 1710

Quoted 4 lines
drivers/media/i2c/tda1997x.c new file +4 -0
+     mutex_lock(&state->lock);
+     ret = tda1997x_detect_std(state);
+     if (!ret)
+             *timings = *state->detected_timings;

I think you can just drop the 'detected_timings' field and just do tda1997x_detect_std(state, timings); here. That way you are not tempted to use 'detected_timings' in places where you shouldn't :-)

done

Quoted 12 lines
Quoted 12 lines
drivers/media/i2c/tda1997x.c new file +11 -0
+     mutex_unlock(&state->lock);
+
+     return ret;
+}
+
+static int tda1997x_s_stream(struct v4l2_subdev *sd, int enable)
+{
+     struct tda1997x_state *state = to_state(sd);
+
+     v4l_dbg(1, debug, state->client, "%s %d\n", __func__, enable);
+     mutex_lock(&state->lock);
Quoted 8 lines

drivers/media/i2c/tda1997x.c line 1727

Quoted 6 lines
drivers/media/i2c/tda1997x.c new file +6 -0
+     if (!state->detected_timings)
+             v4l_dbg(1, debug, state->client, "Invalid HDMI signal\n");
+     mutex_unlock(&state->lock);
+
+     return 0;
+}

I'd drop this. It isn't helpful.

done

Quoted 76 lines
Quoted 45 lines
drivers/media/i2c/tda1997x.c new file +44 -0
+
+static const struct v4l2_subdev_video_ops tda1997x_video_ops = {
+     .g_input_status = tda1997x_g_input_status,
+     .s_dv_timings = tda1997x_s_dv_timings,
+     .g_dv_timings = tda1997x_g_dv_timings,
+     .query_dv_timings = tda1997x_query_dv_timings,
+     .s_stream = tda1997x_s_stream,
+};
+
+
+/* -----------------------------------------------------------------------------
+ * v4l2_subdev_pad_ops
+ */
+
+static int tda1997x_init_cfg(struct v4l2_subdev *sd,
+                          struct v4l2_subdev_pad_config *cfg)
+{
+     struct tda1997x_state *state = to_state(sd);
+     struct v4l2_mbus_framefmt *mf;
+
+     mf = v4l2_subdev_get_try_format(sd, cfg, 0);
+     mf->code = state->mbus_codes[0];
+
+     return 0;
+}
+
+static int tda1997x_enum_mbus_code(struct v4l2_subdev *sd,
+                               struct v4l2_subdev_pad_config *cfg,
+                               struct v4l2_subdev_mbus_code_enum *code)
+{
+     struct tda1997x_state *state = to_state(sd);
+
+     v4l_dbg(1, debug, state->client, "%s %d/%d\n", __func__,
+             code->index, ARRAY_SIZE(state->mbus_codes));
+     if (code->index >= ARRAY_SIZE(state->mbus_codes))
+             return -EINVAL;
+
+     if (!state->mbus_codes[code->index])
+             return -EINVAL;
+
+     code->code = state->mbus_codes[code->index];
+
+     return 0;
+}

drivers/media/i2c/tda1997x.c line 1781

Quoted 10 lines
drivers/media/i2c/tda1997x.c new file +10 -0
+
+static int tda1997x_fill_format(struct tda1997x_state *state,
+                             struct v4l2_mbus_framefmt *format)
+{
+     const struct v4l2_bt_timings *bt;
+
+     v4l_dbg(1, debug, state->client, "%s\n", __func__);
+
+     if (!state->detected_timings)
+             return -EINVAL;

Ouch. Just drop this.

drivers/media/i2c/tda1997x.c line 1784

Quoted 3 lines
drivers/media/i2c/tda1997x.c new file +3 -0
+
+     memset(format, 0, sizeof(*format));
+     bt = &state->detected_timings->bt;

and use &state->timings.bt here. That is how the receiver is configured.

drivers/media/i2c/tda1997x.c line 1792

Quoted 8 lines
drivers/media/i2c/tda1997x.c new file +8 -0
+     format->width = bt->width;
+     format->height = bt->height;
+     format->colorspace = state->colorimetry.colorspace;
+     format->field = (bt->interlaced) ?
+             V4L2_FIELD_SEQ_TB : V4L2_FIELD_NONE;
+
+     return 0;
+}

The *only* time you need to care about the actual detected timings is when userspace calls QUERY_DV_TIMINGS. Never anywhere else.

Quoted 8 lines

s_input_status is used to test some basics (do I have a signal, can I lock) but doesn't go 'in-depth'.

If the interrupt routine detects a resolution change or it loses a stable signal, then it sends an event to userspace, but nothing else should change.

Look at adv7604.c: the only time it attempts to detect the timings with read_stdi() is when called from query_dv_timings (and log_status for debugging).

ok - I get it. Finally sinking in I think!

v10 on the way.

Regards,

Tim

#9 lore raw

Re: [PATCH v9 6/8] media: i2c: Add TDA1997x HDMI receiver driver

Quoted 25 lines · Tim Harvey
Quoted 25 lines

drivers/media/i2c/tda1997x.c line 1635

Quoted 7 lines
drivers/media/i2c/tda1997x.c new file +7 -0
+static int
+tda1997x_g_input_status(struct v4l2_subdev *sd, u32 *status)
+{
+     struct tda1997x_state *state = to_state(sd);
+
+     mutex_lock(&state->lock);
+     if (state->detected_timings)

What this actually tests if the driver was able to detect a valid signal and lock to it.

In practice you have three possible outcomes:

- There is no HDMI signal at all: return V4L2_IN_ST_NO_SIGNAL
- There is a signal, but the receiver could not lock to it: return V4L2_IN_ST_NO_SYNC
- There is a signal, and the receiver could lock: return 0.

Just because this returns 0, doesn't mean that QUERY_DV_TIMINGS will succeed. There may be other constraints (e.g. the driver doesn't support certain formats such as interlaced) that can cause QUERY_DV_TIMINGS to return an error, even though the receiver could sync.

Usually the hardware has some bits that tell whether there is a signal (usually the TMDS clock) and whether it could sync or not (H and V syncs).

Quoted 8 lines
Quoted 1 line

That's really all you need to test here.

makes sense. I don't have any decent documentation on the TMDS regs used in tda1997x_read_activity_status but I can use the some other things to determine this.

I don't see v4l2-subdev.c (or anything) ever calling g_input_status. How do I test this?

Huh, that's a very good question! It is meant to be called by bridge drivers implementing VIDIOC_ENUMINPUT. But that doesn't apply to the imx driver since it is expecting userspace to talk directly to the subdev.

Now for the DV_TIMINGS API this doesn't matter all that much since QUERY_DV_TIMINGS can do the same job through the returned error code, but for analog TV there is no such option (QUERYSTD doesn't support such detailed feedback).

I see that you have an adv7180 in your system. Can you run 'v4l2-compliance -uX' for the adv7180 subdev and post the output here?

Analog TV receivers are rare in MC bridge drivers, and I see that the subdev API doesn't even support the G/S/QUERY/ENUM_STD ioctls! I think the adv7180 is basically unusable in your system. And we need a subdev replacement for VIDIOC_ENUMINPUT.

Was the adv7180 ever tested? Are you able to test it?

Regards,

Hans

author maintainer
#10 lore raw

Re: [PATCH v9 6/8] media: i2c: Add TDA1997x HDMI receiver driver

Quoted 9 lines · Hans Verkuil
Quoted 3 lines · Tim Harvey

I don't see v4l2-subdev.c (or anything) ever calling g_input_status. How do I test this?

Huh, that's a very good question! It is meant to be called by bridge drivers implementing VIDIOC_ENUMINPUT. But that doesn't apply to the imx driver since it is expecting userspace to talk directly to the subdev.

Quoted 8 lines

Now for the DV_TIMINGS API this doesn't matter all that much since QUERY_DV_TIMINGS can do the same job through the returned error code, but for analog TV there is no such option (QUERYSTD doesn't support such detailed feedback).

I see that you have an adv7180 in your system. Can you run 'v4l2-compliance -uX' for the adv7180 subdev and post the output here?

# v4l2-compliance -u0
v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8

Compliance test for device /d[ 2526.153591] adv7180 2-0020: ================= S TART STATUS =================
ev/v4l-subdev0:

Media Driver I[ 2526.162531] adv7180 2-0020: ================== END STATUS ===
===============
nfo:

        Driver name      : imx-media
        Model            : imx-media
        Serial           :
        Bus info         :
        Media version    : 4.15.0
        Hardware revision: 0x00000000 (0)
        Driver version   : 4.15.0

Interface Info:
ID : 0x0300008d
Type : V4L Sub-Device
Entity Info:

        ID               : 0x00000001 (1)
        Name             : adv7180 2-0020
        Function         : FAIL: Unknown V4L2 Sub-Device
        Pad 0x01000002   : Source
          Link 0x0200007f: to remote pad 0x1000067 of entity 'ipu2_csi1_mux': Da

ta

Required ioctls:
test MC information (see 'Media Driver Info' above): FAIL

Allow for multiple opens:
test second /dev/v4l-subdev0 open: 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):
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK
fail: v4l2-test-subdevs.cpp(301): fmt.width == 0 ||
fmt.width == ~0U

                fail: v4l2-test-subdevs.cpp(342):

checkMBusFrameFmt(node, fmt.format)
test Try VIDIOC_SUBDEV_G/S_FMT: FAIL
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK
fail: v4l2-test-subdevs.cpp(307): fmt.ycbcr_enc == 0xffff
fail: v4l2-test-subdevs.cpp(342):
checkMBusFrameFmt(node, fmt.format)
test Active VIDIOC_SUBDEV_G/S_FMT: FAIL
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test 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: 5 Private Controls: 1

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 VIDIOC_EXPBUF: OK (Not Supported)

Total: 47, Succeeded: 44, Failed: 3, Warnings: 0

Quoted 6 lines

Analog TV receivers are rare in MC bridge drivers, and I see that the subdev API doesn't even support the G/S/QUERY/ENUM_STD ioctls! I think the adv7180 is basically unusable in your system. And we need a subdev replacement for VIDIOC_ENUMINPUT.

Was the adv7180 ever tested? Are you able to test it?

Yes, it works - I've tested and used it.

Tim

#11 lore raw

Re: [PATCH v9 6/8] media: i2c: Add TDA1997x HDMI receiver driver

Quoted 75 lines · Tim Harvey
Quoted 9 lines · Hans Verkuil
Quoted 3 lines · Tim Harvey

I don't see v4l2-subdev.c (or anything) ever calling g_input_status. How do I test this?

Huh, that's a very good question! It is meant to be called by bridge drivers implementing VIDIOC_ENUMINPUT. But that doesn't apply to the imx driver since it is expecting userspace to talk directly to the subdev.

Quoted 8 lines

Now for the DV_TIMINGS API this doesn't matter all that much since QUERY_DV_TIMINGS can do the same job through the returned error code, but for analog TV there is no such option (QUERYSTD doesn't support such detailed feedback).

I see that you have an adv7180 in your system. Can you run 'v4l2-compliance -uX' for the adv7180 subdev and post the output here?

# v4l2-compliance -u0
v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8

Compliance test for device /d[ 2526.153591] adv7180 2-0020: ================= S TART STATUS =================
ev/v4l-subdev0:

Media Driver I[ 2526.162531] adv7180 2-0020: ================== END STATUS ===
===============
nfo:

        Driver name      : imx-media
        Model            : imx-media
        Serial           :
        Bus info         :
        Media version    : 4.15.0
        Hardware revision: 0x00000000 (0)
        Driver version   : 4.15.0

Interface Info:
ID : 0x0300008d
Type : V4L Sub-Device
Entity Info:

        ID               : 0x00000001 (1)
        Name             : adv7180 2-0020
        Function         : FAIL: Unknown V4L2 Sub-Device
        Pad 0x01000002   : Source
          Link 0x0200007f: to remote pad 0x1000067 of entity 'ipu2_csi1_mux': Da

ta

Required ioctls:
test MC information (see 'Media Driver Info' above): FAIL

Allow for multiple opens:
test second /dev/v4l-subdev0 open: 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

Quoted 2 lines

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)

Not Supported!

Quoted 52 lines

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):
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK
fail: v4l2-test-subdevs.cpp(301): fmt.width == 0 ||
fmt.width == ~0U

                fail: v4l2-test-subdevs.cpp(342):

checkMBusFrameFmt(node, fmt.format)
test Try VIDIOC_SUBDEV_G/S_FMT: FAIL
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK
fail: v4l2-test-subdevs.cpp(307): fmt.ycbcr_enc == 0xffff
fail: v4l2-test-subdevs.cpp(342):
checkMBusFrameFmt(node, fmt.format)
test Active VIDIOC_SUBDEV_G/S_FMT: FAIL
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test 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: 5 Private Controls: 1

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 VIDIOC_EXPBUF: OK (Not Supported)

Total: 47, Succeeded: 44, Failed: 3, Warnings: 0

Quoted 8 lines
Quoted 6 lines

Analog TV receivers are rare in MC bridge drivers, and I see that the subdev API doesn't even support the G/S/QUERY/ENUM_STD ioctls! I think the adv7180 is basically unusable in your system. And we need a subdev replacement for VIDIOC_ENUMINPUT.

Was the adv7180 ever tested? Are you able to test it?

Yes, it works - I've tested and used it.

How? Without STD support how can you even see what standards are supported and switch between standards? Did you try to switch between PAL and NTSC?

Regards,

Hans

author maintainer
#12 lore raw

Re: [PATCH v9 6/8] media: i2c: Add TDA1997x HDMI receiver driver

Quoted 138 lines · Hans Verkuil
Quoted 75 lines · Tim Harvey
Quoted 9 lines · Hans Verkuil
Quoted 3 lines · Tim Harvey

I don't see v4l2-subdev.c (or anything) ever calling g_input_status. How do I test this?

Huh, that's a very good question! It is meant to be called by bridge drivers implementing VIDIOC_ENUMINPUT. But that doesn't apply to the imx driver since it is expecting userspace to talk directly to the subdev.

Quoted 8 lines

Now for the DV_TIMINGS API this doesn't matter all that much since QUERY_DV_TIMINGS can do the same job through the returned error code, but for analog TV there is no such option (QUERYSTD doesn't support such detailed feedback).

I see that you have an adv7180 in your system. Can you run 'v4l2-compliance -uX' for the adv7180 subdev and post the output here?

# v4l2-compliance -u0
v4l2-compliance SHA   : b2f8f9049056eb6f9e028927dacb2c715a062df8

Compliance test for device /d[ 2526.153591] adv7180 2-0020: ================= S TART STATUS =================
ev/v4l-subdev0:

Media Driver I[ 2526.162531] adv7180 2-0020: ================== END STATUS ===
===============
nfo:

        Driver name      : imx-media
        Model            : imx-media
        Serial           :
        Bus info         :
        Media version    : 4.15.0
        Hardware revision: 0x00000000 (0)
        Driver version   : 4.15.0

Interface Info:
ID : 0x0300008d
Type : V4L Sub-Device
Entity Info:

        ID               : 0x00000001 (1)
        Name             : adv7180 2-0020
        Function         : FAIL: Unknown V4L2 Sub-Device
        Pad 0x01000002   : Source
          Link 0x0200007f: to remote pad 0x1000067 of entity 'ipu2_csi1_mux': Da

ta

Required ioctls:
test MC information (see 'Media Driver Info' above): FAIL

Allow for multiple opens:
test second /dev/v4l-subdev0 open: 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

Quoted 2 lines

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)

Not Supported!

Quoted 57 lines

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):
test Try VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK
fail: v4l2-test-subdevs.cpp(301): fmt.width == 0 ||
fmt.width == ~0U

                fail: v4l2-test-subdevs.cpp(342):

checkMBusFrameFmt(node, fmt.format)
test Try VIDIOC_SUBDEV_G/S_FMT: FAIL
test Try VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test Active VIDIOC_SUBDEV_ENUM_MBUS_CODE/FRAME_SIZE/FRAME_INTERVAL: OK
fail: v4l2-test-subdevs.cpp(307): fmt.ycbcr_enc == 0xffff
fail: v4l2-test-subdevs.cpp(342):
checkMBusFrameFmt(node, fmt.format)
test Active VIDIOC_SUBDEV_G/S_FMT: FAIL
test Active VIDIOC_SUBDEV_G/S_SELECTION/CROP: OK (Not Supported) test 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: 5 Private Controls: 1

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 VIDIOC_EXPBUF: OK (Not Supported)

Total: 47, Succeeded: 44, Failed: 3, Warnings: 0

Quoted 5 lines

Analog TV receivers are rare in MC bridge drivers, and I see that the subdev API doesn't even support the G/S/QUERY/ENUM_STD ioctls! I think the adv7180 is basically unusable in your system. And we need a subdev replacement for VIDIOC_ENUMINPUT.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Was the adv7180 ever tested? Are you able to test it?

Yes, it works - I've tested and used it.

How? Without STD support how can you even see what standards are supported and switch between standards? Did you try to switch between PAL and NTSC?

it was a few kernel versions ago and I doubt I tested both formats. I'll take a look at it again and report back.

Tim