Move device_test_commit to device.c

This commit is contained in:
Simon Ser 2020-01-13 12:22:47 +01:00
parent b16078769e
commit 95d16704b9
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 24 additions and 20 deletions

20
alloc.c
View file

@ -343,26 +343,6 @@ bool check_alloc_valid(struct alloc_result *result, struct alloc_step *step)
return true;
}
static bool device_test_commit(struct liftoff_device *device,
drmModeAtomicReq *req, bool *compatible)
{
int ret;
ret = drmModeAtomicCommit(device->drm_fd, req,
DRM_MODE_ATOMIC_TEST_ONLY, NULL);
if (ret == 0) {
*compatible = true;
} else if (-ret == EINVAL || -ret == ERANGE) {
*compatible = false;
} else {
liftoff_log_errno(LIFTOFF_ERROR, "drmModeAtomicCommit");
*compatible = false;
return false;
}
return true;
}
bool output_choose_layers(struct liftoff_output *output,
struct alloc_result *result, struct alloc_step *step)
{

View file

@ -1,3 +1,4 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@ -81,3 +82,23 @@ void liftoff_device_destroy(struct liftoff_device *device)
free(device->crtcs);
free(device);
}
bool device_test_commit(struct liftoff_device *device,
drmModeAtomicReq *req, bool *compatible)
{
int ret;
ret = drmModeAtomicCommit(device->drm_fd, req,
DRM_MODE_ATOMIC_TEST_ONLY, NULL);
if (ret == 0) {
*compatible = true;
} else if (-ret == EINVAL || -ret == ERANGE) {
*compatible = false;
} else {
liftoff_log_errno(LIFTOFF_ERROR, "drmModeAtomicCommit");
*compatible = false;
return false;
}
return true;
}

View file

@ -78,6 +78,9 @@ struct liftoff_rect {
int width, height;
};
bool device_test_commit(struct liftoff_device *device,
drmModeAtomicReq *req, bool *compatible);
struct liftoff_layer_property *layer_get_property(struct liftoff_layer *layer,
const char *name);
void layer_get_rect(struct liftoff_layer *layer, struct liftoff_rect *rect);