Skip to content

Commit 04912d4

Browse files
josuahkartben
authored andcommitted
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 d1e71ae commit 04912d4

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),
@@ -166,6 +167,18 @@ static uint16_t video_sw_generator_fill_xrgb32(uint8_t *buffer, uint16_t width,
166167
return 1;
167168
}
168169

170+
static uint16_t video_sw_generator_fill_rgb24(uint8_t *buffer, uint16_t width, bool hflip)
171+
{
172+
for (size_t w = 0; w < width; w++) {
173+
int color_idx = video_sw_generator_get_color_idx(w, width, hflip);
174+
175+
buffer[w * 3 + 0] = pattern_8bars_rgb[color_idx][0];
176+
buffer[w * 3 + 1] = pattern_8bars_rgb[color_idx][1];
177+
buffer[w * 3 + 2] = pattern_8bars_rgb[color_idx][2];
178+
}
179+
return 1;
180+
}
181+
169182
static uint16_t video_sw_generator_fill_rgb565(uint8_t *buffer, uint16_t width, bool hflip)
170183
{
171184
for (size_t w = 0; w < width; w++) {
@@ -222,6 +235,9 @@ static int video_sw_generator_fill(const struct device *const dev, struct video_
222235
case VIDEO_PIX_FMT_XRGB32:
223236
lines = video_sw_generator_fill_xrgb32(vbuf->buffer, fmt->width, hflip);
224237
break;
238+
case VIDEO_PIX_FMT_RGB24:
239+
lines = video_sw_generator_fill_rgb24(vbuf->buffer, fmt->width, hflip);
240+
break;
225241
case VIDEO_PIX_FMT_RGB565:
226242
lines = video_sw_generator_fill_rgb565(vbuf->buffer, fmt->width, hflip);
227243
break;

0 commit comments

Comments
 (0)