Skip to content

Commit 678a10b

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 0eb3a59 commit 678a10b

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),
@@ -168,6 +169,18 @@ static int video_sw_generator_fill_xrgb32(uint8_t *buffer, uint16_t width, bool
168169
return 1;
169170
}
170171

172+
static int video_sw_generator_fill_rgb24(uint8_t *buffer, uint16_t width, bool hflip)
173+
{
174+
for (size_t w = 0; w < width; w++) {
175+
int color_idx = video_sw_generator_get_color_idx(w, width, hflip);
176+
177+
buffer[w * 3 + 0] = pattern_8bars_rgb[color_idx][0];
178+
buffer[w * 3 + 1] = pattern_8bars_rgb[color_idx][1];
179+
buffer[w * 3 + 2] = pattern_8bars_rgb[color_idx][2];
180+
}
181+
return 1;
182+
}
183+
171184
static int video_sw_generator_fill_rgb565(uint8_t *buffer, uint16_t width, bool hflip)
172185
{
173186
for (size_t w = 0; w < width; w++) {
@@ -217,6 +230,9 @@ static void video_sw_generator_fill(const struct device *const dev, struct video
217230
case VIDEO_PIX_FMT_XRGB32:
218231
lines = video_sw_generator_fill_xrgb32(vbuf->buffer, fmt->width, hflip);
219232
break;
233+
case VIDEO_PIX_FMT_RGB24:
234+
lines = video_sw_generator_fill_rgb24(vbuf->buffer, fmt->width, hflip);
235+
break;
220236
case VIDEO_PIX_FMT_RGB565:
221237
lines = video_sw_generator_fill_rgb565(vbuf->buffer, fmt->width, hflip);
222238
break;

0 commit comments

Comments
 (0)