Skip to content

Commit 14c8f41

Browse files
committed
drivers: video: sw_generator: introduce the RGB24 test pattern
This complements the 32-bit RGB (XRGB32) test pattern with an equivalent 24-bit RGB (RGB24) implementation. Signed-off-by: Josuah Demangeon <me@josuah.net>
1 parent 18c5c9b commit 14c8f41

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/video/video_sw_generator.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct video_sw_generator_data {
5858
}
5959

6060
static const struct video_format_cap fmts[] = {
61+
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_RGB24),
6162
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_YUYV),
6263
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_RGB565),
6364
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_XRGB32),
@@ -164,6 +165,18 @@ static uint16_t video_sw_generator_fill_xrgb32(uint8_t *buffer, uint16_t width,
164165
return 1;
165166
}
166167

168+
static uint16_t video_sw_generator_fill_rgb24(uint8_t *buffer, uint16_t width, bool hflip)
169+
{
170+
for (size_t w = 0; w < width; w++) {
171+
int color_idx = video_sw_generator_get_color_idx(w, width, hflip);
172+
173+
buffer[w * 3 + 0] = pattern_8bars_rgb[color_idx][0];
174+
buffer[w * 3 + 1] = pattern_8bars_rgb[color_idx][1];
175+
buffer[w * 3 + 2] = pattern_8bars_rgb[color_idx][2];
176+
}
177+
return 1;
178+
}
179+
167180
static uint16_t video_sw_generator_fill_rgb565(uint8_t *buffer, uint16_t width, bool hflip)
168181
{
169182
for (size_t w = 0; w < width; w++) {
@@ -220,6 +233,9 @@ static int video_sw_generator_fill(const struct device *const dev, struct video_
220233
case VIDEO_PIX_FMT_XRGB32:
221234
lines = video_sw_generator_fill_xrgb32(vbuf->buffer, fmt->width, hflip);
222235
break;
236+
case VIDEO_PIX_FMT_RGB24:
237+
lines = video_sw_generator_fill_rgb24(vbuf->buffer, fmt->width, hflip);
238+
break;
223239
case VIDEO_PIX_FMT_RGB565:
224240
lines = video_sw_generator_fill_rgb565(vbuf->buffer, fmt->width, hflip);
225241
break;

0 commit comments

Comments
 (0)