Skip to content

Commit 584c08c

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 bc3b0e2 commit 584c08c

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
@@ -55,6 +55,7 @@ static const struct video_format_cap fmts[] = {
5555
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_YUYV),
5656
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_RGB565),
5757
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_XRGB32),
58+
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_RGB24),
5859
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_RGGB8),
5960
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_GRBG8),
6061
VIDEO_SW_GENERATOR_FORMAT_CAP(VIDEO_PIX_FMT_BGGR8),
@@ -152,6 +153,16 @@ static int video_sw_generator_fill_xrgb32(uint8_t *buffer, uint16_t pitch)
152153
return 1;
153154
}
154155

156+
static int video_sw_generator_fill_rgb24(uint8_t *buffer, uint16_t pitch)
157+
{
158+
for (size_t i = 0; i < pitch; i += 3) {
159+
buffer[i + 0] = pattern_8bars_rgb[8 * i / pitch][0];
160+
buffer[i + 1] = pattern_8bars_rgb[8 * i / pitch][1];
161+
buffer[i + 2] = pattern_8bars_rgb[8 * i / pitch][2];
162+
}
163+
return 1;
164+
}
165+
155166
static int video_sw_generator_fill_rgb565(uint8_t *buffer, uint16_t pitch)
156167
{
157168
for (size_t i = 0; i < pitch; i += 1) {
@@ -198,6 +209,9 @@ static void video_sw_generator_fill(const struct device *const dev, struct video
198209
case VIDEO_PIX_FMT_XRGB32:
199210
lines = video_sw_generator_fill_xrgb32(vbuf->buffer, fmt->pitch);
200211
break;
212+
case VIDEO_PIX_FMT_RGB24:
213+
lines = video_sw_generator_fill_rgb24(vbuf->buffer, fmt->pitch);
214+
break;
201215
case VIDEO_PIX_FMT_RGB565:
202216
lines = video_sw_generator_fill_rgb565(vbuf->buffer, fmt->pitch);
203217
break;

0 commit comments

Comments
 (0)