Skip to content

Commit 2eca75e

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 3bda8cc commit 2eca75e

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),
@@ -161,6 +162,16 @@ static int video_sw_generator_fill_xrgb32(uint8_t *buffer, uint16_t width)
161162
return 1;
162163
}
163164

165+
static int video_sw_generator_fill_rgb24(uint8_t *buffer, uint16_t width)
166+
{
167+
for (size_t w = 0; w < width; w++) {
168+
buffer[w * 3 + 0] = pattern_8bars_rgb[8 * w / width][0];
169+
buffer[w * 3 + 1] = pattern_8bars_rgb[8 * w / width][1];
170+
buffer[w * 3 + 2] = pattern_8bars_rgb[8 * w / width][2];
171+
}
172+
return 1;
173+
}
174+
164175
static int video_sw_generator_fill_rgb565(uint8_t *buffer, uint16_t width)
165176
{
166177
for (size_t w = 0; w < width; w++) {
@@ -207,6 +218,9 @@ static void video_sw_generator_fill(const struct device *const dev, struct video
207218
case VIDEO_PIX_FMT_XRGB32:
208219
lines = video_sw_generator_fill_xrgb32(vbuf->buffer, fmt->width);
209220
break;
221+
case VIDEO_PIX_FMT_RGB24:
222+
lines = video_sw_generator_fill_rgb24(vbuf->buffer, fmt->width);
223+
break;
210224
case VIDEO_PIX_FMT_RGB565:
211225
lines = video_sw_generator_fill_rgb565(vbuf->buffer, fmt->width);
212226
break;

0 commit comments

Comments
 (0)