samples: drivers: video: capture: don't apply format unless needed

Do not apply format setting unless needed. Also, correct the check for
the RGB565 format setting- the zephyr display API treats RGB565 and
BGR565 as big endian, so the format needed here is BGR565.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
Daniel DeGrasse 2024-10-04 16:22:31 -05:00 committed by Anas Nashif
parent 22cb79d221
commit 20cce995da
1 changed files with 6 additions and 2 deletions

View File

@ -36,10 +36,14 @@ static inline int display_setup(const struct device *const display_dev, const ui
/* Set display pixel format to match the one in use by the camera */
switch (pixfmt) {
case VIDEO_PIX_FMT_RGB565:
ret = display_set_pixel_format(display_dev, PIXEL_FORMAT_RGB_565);
if (capabilities.current_pixel_format != PIXEL_FORMAT_BGR_565) {
ret = display_set_pixel_format(display_dev, PIXEL_FORMAT_BGR_565);
}
break;
case VIDEO_PIX_FMT_XRGB32:
ret = display_set_pixel_format(display_dev, PIXEL_FORMAT_ARGB_8888);
if (capabilities.current_pixel_format != PIXEL_FORMAT_ARGB_8888) {
ret = display_set_pixel_format(display_dev, PIXEL_FORMAT_ARGB_8888);
}
break;
default:
return -ENOTSUP;