v4p: added some checks and asserts

This commit is contained in:
Maxim Devaev 2024-03-09 04:29:50 +02:00
parent 66572806a2
commit ac0944ae1a
2 changed files with 17 additions and 3 deletions

View File

@ -158,7 +158,8 @@ int us_drm_open(us_drm_s *drm, const us_device_s *dev) {
}
run->unplugged_reported = false;
_D_LOG_INFO("Opened for %s ...", (stub == 0 ? "DMA" : "STUB"));
run->stub = (stub > 0);
_D_LOG_INFO("Opened for %s ...", (run->stub ? "STUB" : "DMA"));
return stub;
error:
@ -227,6 +228,8 @@ void us_drm_close(us_drm_s *drm) {
int us_drm_wait_for_vsync(us_drm_s *drm) {
us_drm_runtime_s *const run = drm->run;
assert(run->fd >= 0);
switch (_drm_check_status(drm)) {
case 0: break;
case -2: return -2;
@ -277,7 +280,8 @@ static void _drm_vsync_callback(int fd, uint n_frame, uint sec, uint usec, void
int us_drm_expose_stub(us_drm_s *drm, us_drm_stub_e stub, const us_device_s *dev) {
us_drm_runtime_s *const run = drm->run;
assert(run->stub_n_buf >= 0);
assert(run->fd >= 0);
assert(run->stub);
switch (_drm_check_status(drm)) {
case 0: break;
@ -344,6 +348,15 @@ int us_drm_expose_dma(us_drm_s *drm, const us_hw_buffer_s *hw) {
us_drm_runtime_s *const run = drm->run;
us_drm_buffer_s *const buf = &run->bufs[hw->buf.index];
assert(run->fd >= 0);
assert(!run->stub);
switch (_drm_check_status(drm)) {
case 0: break;
case -2: return -2;
default: return -1;
}
run->has_vsync = false;
_D_LOG_DEBUG("Exposing DMA framebuffer n_buf=%u ...", hw->buf.index);

View File

@ -61,7 +61,8 @@ typedef struct {
uint n_bufs;
drmModeCrtc *saved_crtc;
bool has_vsync;
int stub_n_buf;
bool stub;
uint stub_n_buf;
us_frametext_s *ft;
bool unplugged_reported;
} us_drm_runtime_s;