Skip to content

Commit 2e57ed7

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 <[email protected]>
1 parent fd213b4 commit 2e57ed7

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),
@@ -158,6 +159,16 @@ static int video_sw_generator_fill_xrgb32(uint8_t *buffer, uint16_t width)
158159
return 1;
159160
}
160161

162+
static int video_sw_generator_fill_rgb24(uint8_t *buffer, uint16_t width)
163+
{
164+
for (size_t w = 0; w < width; w++) {
165+
buffer[w * 3 + 0] = pattern_8bars_rgb[8 * w / width][0];
166+
buffer[w * 3 + 1] = pattern_8bars_rgb[8 * w / width][1];
167+
buffer[w * 3 + 2] = pattern_8bars_rgb[8 * w / width][2];
168+
}
169+
return 1;
170+
}
171+
161172
static int video_sw_generator_fill_rgb565(uint8_t *buffer, uint16_t width)
162173
{
163174
for (size_t w = 0; w < width; w++) {
@@ -203,6 +214,9 @@ static void video_sw_generator_fill(const struct device *const dev, struct video
203214
case VIDEO_PIX_FMT_XRGB32:
204215
lines = video_sw_generator_fill_xrgb32(vbuf->buffer, fmt->width);
205216
break;
217+
case VIDEO_PIX_FMT_RGB24:
218+
lines = video_sw_generator_fill_rgb24(vbuf->buffer, fmt->width);
219+
break;
206220
case VIDEO_PIX_FMT_RGB565:
207221
lines = video_sw_generator_fill_rgb565(vbuf->buffer, fmt->width);
208222
break;

0 commit comments

Comments
 (0)