Skip to content

Commit

Permalink
ustreamer: blank drm output by timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mdevaev committed Mar 26, 2024
1 parent 7dc492d commit 8c92ab6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/ustreamer/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,18 +652,36 @@ static int _stream_init_loop(us_stream_s *stream) {
#ifdef WITH_V4P
static void _stream_drm_ensure_no_signal(us_stream_s *stream) {
us_stream_runtime_s *const run = stream->run;

if (!stream->v4p) {
return;
}

# define CHECK(x_arg) if ((x_arg) < 0) { goto close; }
if (run->drm_opened <= 0) {
us_drm_close(run->drm);
run->drm_opened = us_drm_open(run->drm, NULL);
run->drm_blank_at_ts = 0;
CHECK(run->drm_opened = us_drm_open(run->drm, NULL));
}
if (run->drm_opened > 0) {
if (us_drm_wait_for_vsync(run->drm) == 0) {
us_drm_expose_stub(run->drm, US_DRM_STUB_NO_SIGNAL, NULL);
}

ldf now_ts = us_get_now_monotonic();
if (run->drm_blank_at_ts == 0) {
run->drm_blank_at_ts = now_ts + 5;
}

if (now_ts <= run->drm_blank_at_ts) {
CHECK(us_drm_wait_for_vsync(run->drm));
CHECK(us_drm_expose_stub(run->drm, US_DRM_STUB_NO_SIGNAL, NULL));
} else {
// US_ONCE({ US_LOG_INFO("DRM: Turning off the display by timeout ..."); });
CHECK(us_drm_dpms_power_off(run->drm));
}
return;
# undef CHECK

close:
us_drm_close(run->drm);
run->drm_opened = -1;
}
#endif

Expand Down
1 change: 1 addition & 0 deletions src/ustreamer/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef struct {
# ifdef WITH_V4P
us_drm_s *drm;
int drm_opened;
ldf drm_blank_at_ts;
# endif

us_ring_s *http_jpeg_ring;
Expand Down

0 comments on commit 8c92ab6

Please sign in to comment.