From 3c18f3199642f2849c498cc88cf8cac69e75c489 Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Fri, 4 Oct 2024 16:22:31 -0500 Subject: [PATCH] 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 --- samples/drivers/video/capture/src/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/samples/drivers/video/capture/src/main.c b/samples/drivers/video/capture/src/main.c index 311049284498a2b..aafa70d29a2632d 100644 --- a/samples/drivers/video/capture/src/main.c +++ b/samples/drivers/video/capture/src/main.c @@ -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;