mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-11 18:13:41 +00:00
v4p: turn off the display after timeout
This commit is contained in:
@@ -172,17 +172,20 @@ static void _main_loop(void) {
|
||||
dev->dma_required = true;
|
||||
|
||||
int once = 0;
|
||||
ldf blank_at_ts = 0;
|
||||
int drm_opened = -1;
|
||||
while (!atomic_load(&_g_stop)) {
|
||||
# define CHECK(x_arg) if ((x_arg) < 0) { goto close; }
|
||||
|
||||
if (drm_opened <= 0) {
|
||||
blank_at_ts = 0;
|
||||
CHECK(drm_opened = us_drm_open(drm, NULL));
|
||||
}
|
||||
assert(drm_opened > 0);
|
||||
|
||||
if (atomic_load(&_g_ustreamer_online)) {
|
||||
US_ONCE({ US_LOG_ERROR("DRM: Online stream is active, stopping capture ..."); });
|
||||
blank_at_ts = 0;
|
||||
US_ONCE({ US_LOG_INFO("DRM: Online stream is active, stopping capture ..."); });
|
||||
CHECK(us_drm_wait_for_vsync(drm));
|
||||
CHECK(us_drm_expose_stub(drm, US_DRM_STUB_BUSY, NULL));
|
||||
_slowdown();
|
||||
@@ -190,18 +193,26 @@ static void _main_loop(void) {
|
||||
}
|
||||
|
||||
if (us_device_open(dev) < 0) {
|
||||
/*CHECK(us_drm_wait_for_vsync(drm));
|
||||
CHECK(us_drm_expose_stub(drm, US_DRM_STUB_NO_SIGNAL, NULL));*/
|
||||
CHECK(us_drm_dpms_power_off(drm));
|
||||
ldf now_ts = us_get_now_monotonic();
|
||||
if (blank_at_ts == 0) {
|
||||
blank_at_ts = now_ts + 5;
|
||||
}
|
||||
if (now_ts <= blank_at_ts) {
|
||||
CHECK(us_drm_wait_for_vsync(drm));
|
||||
CHECK(us_drm_expose_stub(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(drm));
|
||||
}
|
||||
_slowdown();
|
||||
continue;
|
||||
}
|
||||
|
||||
once = 0;
|
||||
blank_at_ts = 0;
|
||||
us_drm_close(drm);
|
||||
CHECK(drm_opened = us_drm_open(drm, dev));
|
||||
|
||||
once = 0;
|
||||
|
||||
us_hw_buffer_s *prev_hw = NULL;
|
||||
while (!atomic_load(&_g_stop)) {
|
||||
if (atomic_load(&_g_ustreamer_online)) {
|
||||
|
||||
Reference in New Issue
Block a user