Skip to content

Commit ff7d7f6

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 c6b2644 commit ff7d7f6

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),
@@ -156,6 +157,16 @@ static int video_sw_generator_fill_xrgb32(uint8_t *buffer, uint16_t pitch)
156157
return 1;
157158
}
158159

160+
static int video_sw_generator_fill_rgb24(uint8_t *buffer, uint16_t pitch)
161+
{
162+
for (size_t i = 0; i < pitch; i += 3) {
163+
buffer[i + 0] = pattern_8bars_rgb[8 * i / pitch][0];
164+
buffer[i + 1] = pattern_8bars_rgb[8 * i / pitch][1];
165+
buffer[i + 2] = pattern_8bars_rgb[8 * i / pitch][2];
166+
}
167+
return 1;
168+
}
169+
159170
static int video_sw_generator_fill_rgb565(uint8_t *buffer, uint16_t pitch)
160171
{
161172
for (size_t i = 0; i < pitch; i += 1) {
@@ -202,6 +213,9 @@ static void video_sw_generator_fill(const struct device *const dev, struct video
202213
case VIDEO_PIX_FMT_XRGB32:
203214
lines = video_sw_generator_fill_xrgb32(vbuf->buffer, fmt->pitch);
204215
break;
216+
case VIDEO_PIX_FMT_RGB24:
217+
lines = video_sw_generator_fill_rgb24(vbuf->buffer, fmt->pitch);
218+
break;
205219
case VIDEO_PIX_FMT_RGB565:
206220
lines = video_sw_generator_fill_rgb565(vbuf->buffer, fmt->pitch);
207221
break;

0 commit comments

Comments
 (0)