media: imx: imx7-mipi-csis: Cleanup and fix subdev pad format handling
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Thu, 12 Mar 2020 23:47:09 +0000 (00:47 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:30:49 +0000 (09:30 +0200)
commit68aeaeac683b82b8dc2f696449a8d13256ce32f3
treec5ad9f239d71ee7720b665281d0f5e338db7899e
parentff41c7b3c7db7f35df451f4cad4ceb55de7fda20
media: imx: imx7-mipi-csis: Cleanup and fix subdev pad format handling

[ Upstream commit d321dd233b9f2bb407b8e6b4759408f09ec207c3 ]

The subdev set pad format operation currently misbehaves in multiple ways:

- mipi_csis_try_format() unconditionally stores the format in the device
  state, even for V4L2_SUBDEV_FORMAT_TRY.

- The format is never stored in the pad cfg, but the pad cfg format
  always overwrites the format requested by the user.

- The sink format is not propagated to the source.

Fix all this by reworking the set format operation as follows:

1. For the source pad, turn set() into get() as the source format is not
   modifiable.
2. Validate the requested format and updated the stored format
   accordingly.
3. Return the format actually set.
4. Propagate the format from sink to source.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/media/imx/imx7-mipi-csis.c