Skip to content

Commit 09097b0

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 f980f35 commit 09097b0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/video/video_sw_generator.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct video_sw_generator_data {
5252
}
5353

5454
static const struct video_format_cap fmts[] = {
55+
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_RGB24),
5556
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_YUYV),
5657
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_RGB565),
5758
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_XRGB32),
@@ -156,6 +157,16 @@ static int video_sw_generator_fill_xrgb32(uint8_t *buffer, uint16_t width)
156157
return 1;
157158
}
158159

160+
static int video_sw_generator_fill_rgb24(uint8_t *buffer, uint16_t width)
161+
{
162+
for (size_t w = 0; w < width; w++) {
163+
buffer[w * 3 + 0] = pattern_8bars_rgb[8 * w / width][0];
164+
buffer[w * 3 + 1] = pattern_8bars_rgb[8 * w / width][1];
165+
buffer[w * 3 + 2] = pattern_8bars_rgb[8 * w / width][2];
166+
}
167+
return 1;
168+
}
169+
159170
static int video_sw_generator_fill_rgb565(uint8_t *buffer, uint16_t width)
160171
{
161172
for (size_t w = 0; w < width; w++) {
@@ -199,6 +210,9 @@ static void video_sw_generator_fill(const struct device *const dev, struct video
199210
case VIDEO_PIX_FMT_XRGB32:
200211
lines = video_sw_generator_fill_xrgb32(vbuf->buffer, fmt->width);
201212
break;
213+
case VIDEO_PIX_FMT_RGB24:
214+
lines = video_sw_generator_fill_rgb24(vbuf->buffer, fmt->width);
215+
break;
202216
case VIDEO_PIX_FMT_RGB565:
203217
lines = video_sw_generator_fill_rgb565(vbuf->buffer, fmt->width);
204218
break;

0 commit comments

Comments
 (0)