linux_dsm_epyc7002/drivers/media
Benjamin Drung aa57b2d6b3 media: uvcvideo: Fix pixel format change for Elgato Cam Link 4K
commit 4c6e0976295add7f0ed94d276c04a3d6f1ea8f83 upstream.

The Elgato Cam Link 4K HDMI video capture card reports to support three
different pixel formats, where the first format depends on the connected
HDMI device.

```
$ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'NV12' (Y/CbCr 4:2:0)
		Size: Discrete 3840x2160
			Interval: Discrete 0.033s (29.970 fps)
	[1]: 'NV12' (Y/CbCr 4:2:0)
		Size: Discrete 3840x2160
			Interval: Discrete 0.033s (29.970 fps)
	[2]: 'YU12' (Planar YUV 4:2:0)
		Size: Discrete 3840x2160
			Interval: Discrete 0.033s (29.970 fps)
```

Changing the pixel format to anything besides the first pixel format
does not work:

```
$ v4l2-ctl -d /dev/video0 --try-fmt-video pixelformat=YU12
Format Video Capture:
	Width/Height      : 3840/2160
	Pixel Format      : 'NV12' (Y/CbCr 4:2:0)
	Field             : None
	Bytes per Line    : 3840
	Size Image        : 12441600
	Colorspace        : sRGB
	Transfer Function : Rec. 709
	YCbCr/HSV Encoding: Rec. 709
	Quantization      : Default (maps to Limited Range)
	Flags             :
```

User space applications like VLC might show an error message on the
terminal in that case:

```
libv4l2: error set_fmt gave us a different result than try_fmt!
```

Depending on the error handling of the user space applications, they
might display a distorted video, because they use the wrong pixel format
for decoding the stream.

The Elgato Cam Link 4K responds to the USB video probe
VS_PROBE_CONTROL/VS_COMMIT_CONTROL with a malformed data structure: The
second byte contains bFormatIndex (instead of being the second byte of
bmHint). The first byte is always zero. The third byte is always 1.

The firmware bug was reported to Elgato on 2020-12-01 and it was
forwarded by the support team to the developers as feature request.
There is no firmware update available since then. The latest firmware
for Elgato Cam Link 4K as of 2021-03-23 has MCU 20.02.19 and FPGA 67.

Therefore correct the malformed data structure for this device. The
change was successfully tested with VLC, OBS, and Chromium using
different pixel formats (YUYV, NV12, YU12), resolutions (3840x2160,
1920x1080), and frame rates (29.970 and 59.940 fps).

Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Drung <bdrung@posteo.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-19 09:45:02 +02:00
..
cec media: s5p_cec: decrement usage count if disabled 2021-07-14 16:56:02 +02:00
common media: siano: Fix out-of-bounds warnings in smscore_load_firmware_family2() 2021-07-14 16:56:05 +02:00
dvb-core media: dvb_net: avoid speculation from net slot 2021-07-14 16:55:54 +02:00
dvb-frontends media: dvb: Add check on sp8870_readreg return 2021-06-03 09:00:42 +02:00
firewire media: firewire: fix memory leak 2020-09-27 11:29:45 +02:00
i2c media: subdev: disallow ioctl for saa6588/davinci 2021-07-19 09:45:02 +02:00
mc media: Fix Media Controller API config checks 2021-07-14 16:55:56 +02:00
mmc media updates for v5.8-rc1 2020-06-03 20:59:38 -07:00
pci media: subdev: disallow ioctl for saa6588/davinci 2021-07-19 09:45:02 +02:00
platform media: subdev: disallow ioctl for saa6588/davinci 2021-07-19 09:45:02 +02:00
radio Linux 5.9-rc4 2020-09-07 16:13:06 +02:00
rc media, bpf: Do not copy more entries than user space requested 2021-07-19 09:44:53 +02:00
spi media: i2c/Kconfig: use sub-menus for I2C support 2020-04-16 10:34:40 +02:00
test-drivers media: vivid: fix assignment of dev->fbuf_out_flags 2021-05-14 09:50:22 +02:00
tuners media: m88rs6000t: avoid potential out-of-bounds reads on arrays 2021-05-14 09:50:23 +02:00
usb media: uvcvideo: Fix pixel format change for Elgato Cam Link 4K 2021-07-19 09:45:02 +02:00
v4l2-core media: v4l2-async: Clean v4l2_async_notifier_add_fwnode_remote_subdev 2021-07-14 16:56:11 +02:00
Kconfig media: media/test_drivers: rename to test-drivers 2020-04-16 10:38:31 +02:00
Makefile media: media/test_drivers: rename to test-drivers 2020-04-16 10:38:31 +02:00