ustreamer: blank drm output by timeout

This commit is contained in:
Maxim Devaev 2024-03-26 22:20:08 +02:00
parent 7dc492d875
commit 8c92ab6f47
2 changed files with 24 additions and 5 deletions

View File

@ -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

View File

@ -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;