Skip to content

Commit abc296f

Browse files
Finomnisnashif
authored andcommitted
drivers: display: display_sdl: implement display_show
Adds frame synchronization to every frame. This prevents frame tearing. Signed-off-by: Martin Stumpf <[email protected]>
1 parent 2e0687c commit abc296f

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

doc/releases/release-notes-4.1.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ Drivers and Sensors
9595
* Added flag ``frame_incomplete`` to ``display_write`` that indicates whether a write is the last
9696
write of the frame, allowing display drivers to implement double buffering / tearing enable
9797
signal handling (:github:`81250`)
98+
* Added ``frame_incomplete`` handling to SDL display driver (:dtcompatible:`zephyr,sdl-dc`)
99+
(:github:`81250`)
98100

99101
* Ethernet
100102

drivers/display/display_sdl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ static int sdl_display_write(const struct device *dev, const uint16_t x,
260260
sdl_display_write_bgr565(disp_data->buf, desc, buf);
261261
}
262262

263-
sdl_display_write_bottom(desc->height, desc->width, x, y,
264-
disp_data->renderer, disp_data->mutex, disp_data->texture,
265-
disp_data->buf, disp_data->display_on);
263+
sdl_display_write_bottom(desc->height, desc->width, x, y, disp_data->renderer,
264+
disp_data->mutex, disp_data->texture, disp_data->buf,
265+
disp_data->display_on, desc->frame_incomplete);
266266

267267
return 0;
268268
}

drivers/display/display_sdl_bottom.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* SPDX-License-Identifier: Apache-2.0
66
*/
77

8+
#include "display_sdl_bottom.h"
9+
810
#include <stdint.h>
911
#include <stddef.h>
1012
#include <stdbool.h>
@@ -64,10 +66,9 @@ int sdl_display_init_bottom(uint16_t height, uint16_t width, uint16_t zoom_pct,
6466
return 0;
6567
}
6668

67-
void sdl_display_write_bottom(const uint16_t height, const uint16_t width,
68-
const uint16_t x, const uint16_t y,
69-
void *renderer, void *mutex, void *texture,
70-
uint8_t *buf, bool display_on)
69+
void sdl_display_write_bottom(const uint16_t height, const uint16_t width, const uint16_t x,
70+
const uint16_t y, void *renderer, void *mutex, void *texture,
71+
uint8_t *buf, bool display_on, bool frame_incomplete)
7172
{
7273
SDL_Rect rect;
7374
int err;
@@ -85,7 +86,7 @@ void sdl_display_write_bottom(const uint16_t height, const uint16_t width,
8586

8687
SDL_UpdateTexture(texture, &rect, buf, 4 * rect.w);
8788

88-
if (display_on) {
89+
if (display_on && !frame_incomplete) {
8990
SDL_RenderClear(renderer);
9091
SDL_RenderCopy(renderer, texture, NULL, NULL);
9192
SDL_RenderPresent(renderer);

drivers/display/display_sdl_bottom.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ extern "C" {
2323
int sdl_display_init_bottom(uint16_t height, uint16_t width, uint16_t zoom_pct,
2424
bool use_accelerator, void **window, void **renderer, void **mutex,
2525
void **texture, void **read_texture);
26-
void sdl_display_write_bottom(const uint16_t height, const uint16_t width,
27-
const uint16_t x, const uint16_t y,
28-
void *renderer, void *mutex, void *texture,
29-
uint8_t *buf, bool display_on);
30-
int sdl_display_read_bottom(const uint16_t height, const uint16_t width,
31-
const uint16_t x, const uint16_t y,
32-
void *renderer, void *buf, uint16_t pitch,
33-
void *mutex, void *texture, void **read_texture);
26+
void sdl_display_write_bottom(const uint16_t height, const uint16_t width, const uint16_t x,
27+
const uint16_t y, void *renderer, void *mutex, void *texture,
28+
uint8_t *buf, bool display_on, bool frame_incomplete);
29+
int sdl_display_read_bottom(const uint16_t height, const uint16_t width, const uint16_t x,
30+
const uint16_t y, void *renderer, void *buf, uint16_t pitch,
31+
void *mutex, void *texture, void *read_texture);
3432
void sdl_display_blanking_off_bottom(void *renderer, void *texture);
3533
void sdl_display_blanking_on_bottom(void *renderer);
3634
void sdl_display_cleanup_bottom(void **window, void **renderer, void **mutex, void **texture,

0 commit comments

Comments
 (0)