Skip to content

Commit 541f4e1

Browse files
committed
generic: add frame_incomplete where missing
The newly introduced `frame_incomplete` flag of `display_buffer_descriptor` needed to be added at several places to avoid uninitialized memory. Signed-off-by: Martin Stumpf <[email protected]>
1 parent a0b223a commit 541f4e1

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

drivers/display/display_gc9x01x.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ static int gc9x01x_write(const struct device *dev, const uint16_t x, const uint1
541541
mipi_desc.width = desc->width;
542542
/* Per MIPI API, pitch must always match width */
543543
mipi_desc.pitch = desc->width;
544+
mipi_desc.frame_incomplete = desc->frame_incomplete;
544545

545546
ret = gc9x01x_transmit(dev, GC9X01X_CMD_MEMWR, NULL, 0);
546547
if (ret < 0) {

drivers/display/display_ili9xxx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static int ili9xxx_write(const struct device *dev, const uint16_t x,
163163
mipi_desc.width = desc->width;
164164
/* Per MIPI API, pitch must always match width */
165165
mipi_desc.pitch = desc->width;
166+
mipi_desc.frame_incomplete = desc->frame_incomplete;
166167

167168
r = ili9xxx_transmit(dev, ILI9XXX_RAMWR, NULL, 0);
168169
if (r < 0) {

samples/drivers/display/src/main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ int main(void)
297297
buf_desc.width = capabilities.x_resolution;
298298
buf_desc.height = h_step;
299299

300+
/*
301+
* The following writes will only render parts of the image,
302+
* so turn this option on.
303+
* This allows double-buffered displays to hold the pixels
304+
* back until the image is complete.
305+
*/
306+
buf_desc.frame_incomplete = true;
307+
300308
for (int idx = 0; idx < capabilities.y_resolution; idx += h_step) {
301309
/*
302310
* Tweaking the height value not to draw outside of the display.
@@ -323,6 +331,13 @@ int main(void)
323331
y = 0;
324332
display_write(display_dev, x, y, &buf_desc, buf);
325333

334+
/*
335+
* This is the last write of the frame, so turn this off.
336+
* Double-buffered displays will now present the new image
337+
* to the user.
338+
*/
339+
buf_desc.frame_incomplete = false;
340+
326341
fill_buffer_fnc(BOTTOM_RIGHT, 0, buf, buf_size);
327342
x = capabilities.x_resolution - rect_w;
328343
y = capabilities.y_resolution - rect_h;

samples/drivers/video/capture/src/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ static inline void video_display_frame(const struct device *const display_dev,
7070
const struct video_buffer *const vbuf,
7171
const struct video_format fmt)
7272
{
73-
struct display_buffer_descriptor buf_desc;
74-
75-
buf_desc.buf_size = vbuf->bytesused;
76-
buf_desc.width = fmt.width;
77-
buf_desc.pitch = buf_desc.width;
78-
buf_desc.height = vbuf->bytesused / fmt.pitch;
73+
struct display_buffer_descriptor buf_desc = {
74+
.buf_size = vbuf->bytesused,
75+
.width = fmt.width,
76+
.pitch = buf_desc.width,
77+
.height = vbuf->bytesused / fmt.pitch,
78+
};
7979

8080
display_write(display_dev, 0, vbuf->line_offset, &buf_desc, vbuf->buffer);
8181
}

subsys/fb/cfb.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,17 +460,18 @@ int cfb_framebuffer_finalize(const struct device *dev)
460460
{
461461
const struct display_driver_api *api = dev->api;
462462
const struct char_framebuffer *fb = &char_fb;
463-
struct display_buffer_descriptor desc;
464463
int err;
465464

466465
if (!fb || !fb->buf) {
467466
return -ENODEV;
468467
}
469468

470-
desc.buf_size = fb->size;
471-
desc.width = fb->x_res;
472-
desc.height = fb->y_res;
473-
desc.pitch = fb->x_res;
469+
struct display_buffer_descriptor desc = {
470+
.buf_size = fb->size,
471+
.width = fb->x_res,
472+
.height = fb->y_res,
473+
.pitch = fb->x_res,
474+
};
474475

475476
if (!(fb->pixel_format & PIXEL_FORMAT_MONO10) != !(fb->inverted)) {
476477
cfb_invert(fb);

0 commit comments

Comments
 (0)