media: imx: capture: Simplify capture_validate_fmt() implementation
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 15 Feb 2021 04:26:49 +0000 (05:26 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 11 Mar 2021 10:59:48 +0000 (11:59 +0100)
commita9512b261afd1aec188d3b3a760b69115e0d1209
treee1272383e7fd317495426ed4154c7d3de38827c5
parent7edcce6cc082f5b164382e0ca3291ade5c164fdb
media: imx: capture: Simplify capture_validate_fmt() implementation

capture_validate_fmt() delegates the media bus format to pixel format
conversion to __capture_legacy_try_fmt(). It turns out that this can be
simplified quite a lot:

- The format lookup from media bus code can be performed by the recently
  added capture_find_format() function instead of receiving the
  information from a side effect of __capture_legacy_try_fmt().

- The validation of the pixel format size isn't needed, as they
  duplicate the validation of the compose rectangle. The pixel format
  size is directly derived from the size of the incoming stream, which
  is stored in the compose rectangle. If the compose rectangle is valid,
  the pixel format size will be valid too.

By removing the validation of the pixel format size and using
capture_find_format() to lookup the format, we can stop using
__capture_legacy_try_fmt() and simplify capture_validate_fmt().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-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>
drivers/staging/media/imx/imx-media-capture.c