mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-26 21:59:18 +01:00
Rename display to device
"Display" can also mean "screen"/"monitor", so it's kind of confusing for this usage.
This commit is contained in:
parent
5f39331f78
commit
b0e2b083f9
6 changed files with 83 additions and 83 deletions
64
alloc.c
64
alloc.c
|
@ -189,7 +189,7 @@ static bool has_allocated_layer_over(struct liftoff_output *output,
|
||||||
}
|
}
|
||||||
|
|
||||||
i = -1;
|
i = -1;
|
||||||
liftoff_list_for_each(other_plane, &output->display->planes, link) {
|
liftoff_list_for_each(other_plane, &output->device->planes, link) {
|
||||||
i++;
|
i++;
|
||||||
if (i >= (ssize_t)step->plane_idx) {
|
if (i >= (ssize_t)step->plane_idx) {
|
||||||
break;
|
break;
|
||||||
|
@ -230,7 +230,7 @@ static bool has_allocated_plane_under(struct liftoff_output *output,
|
||||||
plane = liftoff_container_of(step->plane_link, plane, link);
|
plane = liftoff_container_of(step->plane_link, plane, link);
|
||||||
|
|
||||||
i = -1;
|
i = -1;
|
||||||
liftoff_list_for_each(other_plane, &output->display->planes, link) {
|
liftoff_list_for_each(other_plane, &output->device->planes, link) {
|
||||||
i++;
|
i++;
|
||||||
if (i >= (ssize_t)step->plane_idx) {
|
if (i >= (ssize_t)step->plane_idx) {
|
||||||
break;
|
break;
|
||||||
|
@ -343,12 +343,12 @@ bool check_alloc_valid(struct alloc_result *result, struct alloc_step *step)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool display_test_commit(struct liftoff_display *display,
|
static bool device_test_commit(struct liftoff_device *device,
|
||||||
drmModeAtomicReq *req, bool *compatible)
|
drmModeAtomicReq *req, bool *compatible)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = drmModeAtomicCommit(display->drm_fd, req,
|
ret = drmModeAtomicCommit(device->drm_fd, req,
|
||||||
DRM_MODE_ATOMIC_TEST_ONLY, NULL);
|
DRM_MODE_ATOMIC_TEST_ONLY, NULL);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
*compatible = true;
|
*compatible = true;
|
||||||
|
@ -366,7 +366,7 @@ static bool display_test_commit(struct liftoff_display *display,
|
||||||
bool output_choose_layers(struct liftoff_output *output,
|
bool output_choose_layers(struct liftoff_output *output,
|
||||||
struct alloc_result *result, struct alloc_step *step)
|
struct alloc_result *result, struct alloc_step *step)
|
||||||
{
|
{
|
||||||
struct liftoff_display *display;
|
struct liftoff_device *device;
|
||||||
struct liftoff_plane *plane;
|
struct liftoff_plane *plane;
|
||||||
struct liftoff_layer *layer;
|
struct liftoff_layer *layer;
|
||||||
int cursor;
|
int cursor;
|
||||||
|
@ -374,9 +374,9 @@ bool output_choose_layers(struct liftoff_output *output,
|
||||||
bool compatible;
|
bool compatible;
|
||||||
struct alloc_step next_step;
|
struct alloc_step next_step;
|
||||||
|
|
||||||
display = output->display;
|
device = output->device;
|
||||||
|
|
||||||
if (step->plane_link == &display->planes) { /* Allocation finished */
|
if (step->plane_link == &device->planes) { /* Allocation finished */
|
||||||
if (step->score > result->best_score &&
|
if (step->score > result->best_score &&
|
||||||
check_alloc_valid(result, step)) {
|
check_alloc_valid(result, step)) {
|
||||||
/* We found a better allocation */
|
/* We found a better allocation */
|
||||||
|
@ -437,7 +437,7 @@ bool output_choose_layers(struct liftoff_output *output,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!display_test_commit(display, result->req, &compatible)) {
|
if (!device_test_commit(device, result->req, &compatible)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (compatible) {
|
if (compatible) {
|
||||||
|
@ -465,7 +465,7 @@ skip:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool apply_current(struct liftoff_display *display,
|
static bool apply_current(struct liftoff_device *device,
|
||||||
drmModeAtomicReq *req)
|
drmModeAtomicReq *req)
|
||||||
{
|
{
|
||||||
struct liftoff_plane *plane;
|
struct liftoff_plane *plane;
|
||||||
|
@ -474,7 +474,7 @@ static bool apply_current(struct liftoff_display *display,
|
||||||
|
|
||||||
cursor = drmModeAtomicGetCursor(req);
|
cursor = drmModeAtomicGetCursor(req);
|
||||||
|
|
||||||
liftoff_list_for_each(plane, &display->planes, link) {
|
liftoff_list_for_each(plane, &device->planes, link) {
|
||||||
if (!plane_apply(plane, plane->layer, req, &compatible)) {
|
if (!plane_apply(plane, plane->layer, req, &compatible)) {
|
||||||
drmModeAtomicSetCursor(req, cursor);
|
drmModeAtomicSetCursor(req, cursor);
|
||||||
return false;
|
return false;
|
||||||
|
@ -509,7 +509,7 @@ static bool layer_needs_realloc(struct liftoff_layer *layer)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool reuse_previous_alloc(struct liftoff_display *display,
|
static bool reuse_previous_alloc(struct liftoff_device *device,
|
||||||
drmModeAtomicReq *req)
|
drmModeAtomicReq *req)
|
||||||
{
|
{
|
||||||
struct liftoff_output *output;
|
struct liftoff_output *output;
|
||||||
|
@ -517,7 +517,7 @@ static bool reuse_previous_alloc(struct liftoff_display *display,
|
||||||
int cursor;
|
int cursor;
|
||||||
bool compatible;
|
bool compatible;
|
||||||
|
|
||||||
liftoff_list_for_each(output, &display->outputs, link) {
|
liftoff_list_for_each(output, &device->outputs, link) {
|
||||||
liftoff_list_for_each(layer, &output->layers, link) {
|
liftoff_list_for_each(layer, &output->layers, link) {
|
||||||
if (layer_needs_realloc(layer)) {
|
if (layer_needs_realloc(layer)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -527,10 +527,10 @@ static bool reuse_previous_alloc(struct liftoff_display *display,
|
||||||
|
|
||||||
cursor = drmModeAtomicGetCursor(req);
|
cursor = drmModeAtomicGetCursor(req);
|
||||||
|
|
||||||
if (!apply_current(display, req)) {
|
if (!apply_current(device, req)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!display_test_commit(display, req, &compatible) || !compatible) {
|
if (!device_test_commit(device, req, &compatible) || !compatible) {
|
||||||
drmModeAtomicSetCursor(req, cursor);
|
drmModeAtomicSetCursor(req, cursor);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -538,38 +538,38 @@ static bool reuse_previous_alloc(struct liftoff_display *display,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mark_layers_clean(struct liftoff_display *display)
|
static void mark_layers_clean(struct liftoff_device *device)
|
||||||
{
|
{
|
||||||
struct liftoff_output *output;
|
struct liftoff_output *output;
|
||||||
struct liftoff_layer *layer;
|
struct liftoff_layer *layer;
|
||||||
|
|
||||||
liftoff_list_for_each(output, &display->outputs, link) {
|
liftoff_list_for_each(output, &device->outputs, link) {
|
||||||
liftoff_list_for_each(layer, &output->layers, link) {
|
liftoff_list_for_each(layer, &output->layers, link) {
|
||||||
layer_mark_clean(layer);
|
layer_mark_clean(layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_layers_priority(struct liftoff_display *display)
|
static void update_layers_priority(struct liftoff_device *device)
|
||||||
{
|
{
|
||||||
struct liftoff_output *output;
|
struct liftoff_output *output;
|
||||||
struct liftoff_layer *layer;
|
struct liftoff_layer *layer;
|
||||||
|
|
||||||
display->page_flip_counter++;
|
device->page_flip_counter++;
|
||||||
bool period_elapsed =
|
bool period_elapsed =
|
||||||
display->page_flip_counter >= LIFTOFF_PRIORITY_PERIOD;
|
device->page_flip_counter >= LIFTOFF_PRIORITY_PERIOD;
|
||||||
if (period_elapsed) {
|
if (period_elapsed) {
|
||||||
display->page_flip_counter = 0;
|
device->page_flip_counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
liftoff_list_for_each(output, &display->outputs, link) {
|
liftoff_list_for_each(output, &device->outputs, link) {
|
||||||
liftoff_list_for_each(layer, &output->layers, link) {
|
liftoff_list_for_each(layer, &output->layers, link) {
|
||||||
layer_update_priority(layer, period_elapsed);
|
layer_update_priority(layer, period_elapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool liftoff_display_apply(struct liftoff_display *display, drmModeAtomicReq *req)
|
bool liftoff_device_apply(struct liftoff_device *device, drmModeAtomicReq *req)
|
||||||
{
|
{
|
||||||
struct liftoff_output *output;
|
struct liftoff_output *output;
|
||||||
struct liftoff_plane *plane;
|
struct liftoff_plane *plane;
|
||||||
|
@ -579,15 +579,15 @@ bool liftoff_display_apply(struct liftoff_display *display, drmModeAtomicReq *re
|
||||||
size_t i;
|
size_t i;
|
||||||
bool compatible;
|
bool compatible;
|
||||||
|
|
||||||
update_layers_priority(display);
|
update_layers_priority(device);
|
||||||
|
|
||||||
if (reuse_previous_alloc(display, req)) {
|
if (reuse_previous_alloc(device, req)) {
|
||||||
liftoff_log(LIFTOFF_DEBUG, "Re-using previous plane allocation");
|
liftoff_log(LIFTOFF_DEBUG, "Re-using previous plane allocation");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unset all existing plane and layer mappings. */
|
/* Unset all existing plane and layer mappings. */
|
||||||
liftoff_list_for_each(plane, &display->planes, link) {
|
liftoff_list_for_each(plane, &device->planes, link) {
|
||||||
if (plane->layer != NULL) {
|
if (plane->layer != NULL) {
|
||||||
plane->layer->plane = NULL;
|
plane->layer->plane = NULL;
|
||||||
plane->layer = NULL;
|
plane->layer = NULL;
|
||||||
|
@ -596,7 +596,7 @@ bool liftoff_display_apply(struct liftoff_display *display, drmModeAtomicReq *re
|
||||||
|
|
||||||
/* Disable all planes. Do it before building mappings to make sure not
|
/* Disable all planes. Do it before building mappings to make sure not
|
||||||
to hit bandwidth limits because too many planes are enabled. */
|
to hit bandwidth limits because too many planes are enabled. */
|
||||||
liftoff_list_for_each(plane, &display->planes, link) {
|
liftoff_list_for_each(plane, &device->planes, link) {
|
||||||
if (plane->layer == NULL) {
|
if (plane->layer == NULL) {
|
||||||
liftoff_log(LIFTOFF_DEBUG,
|
liftoff_log(LIFTOFF_DEBUG,
|
||||||
"Disabling plane %d", plane->id);
|
"Disabling plane %d", plane->id);
|
||||||
|
@ -608,7 +608,7 @@ bool liftoff_display_apply(struct liftoff_display *display, drmModeAtomicReq *re
|
||||||
}
|
}
|
||||||
|
|
||||||
result.req = req;
|
result.req = req;
|
||||||
result.planes_len = liftoff_list_length(&display->planes);
|
result.planes_len = liftoff_list_length(&device->planes);
|
||||||
|
|
||||||
step.alloc = malloc(result.planes_len * sizeof(*step.alloc));
|
step.alloc = malloc(result.planes_len * sizeof(*step.alloc));
|
||||||
result.best = malloc(result.planes_len * sizeof(*result.best));
|
result.best = malloc(result.planes_len * sizeof(*result.best));
|
||||||
|
@ -622,7 +622,7 @@ bool liftoff_display_apply(struct liftoff_display *display, drmModeAtomicReq *re
|
||||||
* issues? Also: be fair when mapping planes to outputs, don't give all
|
* issues? Also: be fair when mapping planes to outputs, don't give all
|
||||||
* planes to a single output. Also: don't treat each output separately,
|
* planes to a single output. Also: don't treat each output separately,
|
||||||
* allocate planes for all outputs at once. */
|
* allocate planes for all outputs at once. */
|
||||||
liftoff_list_for_each(output, &display->outputs, link) {
|
liftoff_list_for_each(output, &device->outputs, link) {
|
||||||
/* For each plane, try to find a layer. Don't do it the other
|
/* For each plane, try to find a layer. Don't do it the other
|
||||||
* way around (ie. for each layer, try to find a plane) because
|
* way around (ie. for each layer, try to find a plane) because
|
||||||
* some drivers want user-space to enable the primary plane
|
* some drivers want user-space to enable the primary plane
|
||||||
|
@ -636,7 +636,7 @@ bool liftoff_display_apply(struct liftoff_display *display, drmModeAtomicReq *re
|
||||||
if (output->composition_layer != NULL) {
|
if (output->composition_layer != NULL) {
|
||||||
result.non_composition_layers_len--;
|
result.non_composition_layers_len--;
|
||||||
}
|
}
|
||||||
step.plane_link = display->planes.next;
|
step.plane_link = device->planes.next;
|
||||||
step.plane_idx = 0;
|
step.plane_idx = 0;
|
||||||
step.score = 0;
|
step.score = 0;
|
||||||
step.last_layer_zpos = INT_MAX;
|
step.last_layer_zpos = INT_MAX;
|
||||||
|
@ -651,7 +651,7 @@ bool liftoff_display_apply(struct liftoff_display *display, drmModeAtomicReq *re
|
||||||
|
|
||||||
/* Apply the best allocation */
|
/* Apply the best allocation */
|
||||||
i = 0;
|
i = 0;
|
||||||
liftoff_list_for_each(plane, &display->planes, link) {
|
liftoff_list_for_each(plane, &device->planes, link) {
|
||||||
layer = result.best[i];
|
layer = result.best[i];
|
||||||
i++;
|
i++;
|
||||||
if (layer == NULL) {
|
if (layer == NULL) {
|
||||||
|
@ -668,7 +668,7 @@ bool liftoff_display_apply(struct liftoff_display *display, drmModeAtomicReq *re
|
||||||
layer->plane = plane;
|
layer->plane = plane;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!apply_current(display, req)) {
|
if (!apply_current(device, req)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -676,7 +676,7 @@ bool liftoff_display_apply(struct liftoff_display *display, drmModeAtomicReq *re
|
||||||
free(step.alloc);
|
free(step.alloc);
|
||||||
free(result.best);
|
free(result.best);
|
||||||
|
|
||||||
mark_layers_clean(display);
|
mark_layers_clean(device);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
48
display.c
48
display.c
|
@ -4,45 +4,45 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
struct liftoff_display *liftoff_display_create(int drm_fd)
|
struct liftoff_device *liftoff_device_create(int drm_fd)
|
||||||
{
|
{
|
||||||
struct liftoff_display *display;
|
struct liftoff_device *device;
|
||||||
drmModeRes *drm_res;
|
drmModeRes *drm_res;
|
||||||
drmModePlaneRes *drm_plane_res;
|
drmModePlaneRes *drm_plane_res;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
display = calloc(1, sizeof(*display));
|
device = calloc(1, sizeof(*device));
|
||||||
if (display == NULL) {
|
if (device == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "calloc");
|
liftoff_log_errno(LIFTOFF_ERROR, "calloc");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
liftoff_list_init(&display->planes);
|
liftoff_list_init(&device->planes);
|
||||||
liftoff_list_init(&display->outputs);
|
liftoff_list_init(&device->outputs);
|
||||||
|
|
||||||
display->drm_fd = dup(drm_fd);
|
device->drm_fd = dup(drm_fd);
|
||||||
if (display->drm_fd < 0) {
|
if (device->drm_fd < 0) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "dup");
|
liftoff_log_errno(LIFTOFF_ERROR, "dup");
|
||||||
liftoff_display_destroy(display);
|
liftoff_device_destroy(device);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_res = drmModeGetResources(drm_fd);
|
drm_res = drmModeGetResources(drm_fd);
|
||||||
if (drm_res == NULL) {
|
if (drm_res == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetResources");
|
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetResources");
|
||||||
liftoff_display_destroy(display);
|
liftoff_device_destroy(device);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
display->crtcs = malloc(drm_res->count_crtcs * sizeof(uint32_t));
|
device->crtcs = malloc(drm_res->count_crtcs * sizeof(uint32_t));
|
||||||
if (display->crtcs == NULL) {
|
if (device->crtcs == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "malloc");
|
liftoff_log_errno(LIFTOFF_ERROR, "malloc");
|
||||||
drmModeFreeResources(drm_res);
|
drmModeFreeResources(drm_res);
|
||||||
liftoff_display_destroy(display);
|
liftoff_device_destroy(device);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
display->crtcs_len = drm_res->count_crtcs;
|
device->crtcs_len = drm_res->count_crtcs;
|
||||||
memcpy(display->crtcs, drm_res->crtcs,
|
memcpy(device->crtcs, drm_res->crtcs,
|
||||||
drm_res->count_crtcs * sizeof(uint32_t));
|
drm_res->count_crtcs * sizeof(uint32_t));
|
||||||
|
|
||||||
drmModeFreeResources(drm_res);
|
drmModeFreeResources(drm_res);
|
||||||
|
@ -51,29 +51,29 @@ struct liftoff_display *liftoff_display_create(int drm_fd)
|
||||||
drm_plane_res = drmModeGetPlaneResources(drm_fd);
|
drm_plane_res = drmModeGetPlaneResources(drm_fd);
|
||||||
if (drm_plane_res == NULL) {
|
if (drm_plane_res == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetPlaneResources");
|
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetPlaneResources");
|
||||||
liftoff_display_destroy(display);
|
liftoff_device_destroy(device);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < drm_plane_res->count_planes; i++) {
|
for (i = 0; i < drm_plane_res->count_planes; i++) {
|
||||||
if (plane_create(display, drm_plane_res->planes[i]) == NULL) {
|
if (plane_create(device, drm_plane_res->planes[i]) == NULL) {
|
||||||
liftoff_display_destroy(display);
|
liftoff_device_destroy(device);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drmModeFreePlaneResources(drm_plane_res);
|
drmModeFreePlaneResources(drm_plane_res);
|
||||||
|
|
||||||
return display;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
void liftoff_display_destroy(struct liftoff_display *display)
|
void liftoff_device_destroy(struct liftoff_device *device)
|
||||||
{
|
{
|
||||||
struct liftoff_plane *plane, *tmp;
|
struct liftoff_plane *plane, *tmp;
|
||||||
|
|
||||||
close(display->drm_fd);
|
close(device->drm_fd);
|
||||||
liftoff_list_for_each_safe(plane, tmp, &display->planes, link) {
|
liftoff_list_for_each_safe(plane, tmp, &device->planes, link) {
|
||||||
plane_destroy(plane);
|
plane_destroy(plane);
|
||||||
}
|
}
|
||||||
free(display->crtcs);
|
free(device->crtcs);
|
||||||
free(display);
|
free(device);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
|
|
||||||
struct liftoff_display;
|
struct liftoff_device;
|
||||||
struct liftoff_output;
|
struct liftoff_output;
|
||||||
struct liftoff_layer;
|
struct liftoff_layer;
|
||||||
|
|
||||||
|
@ -15,21 +15,21 @@ struct liftoff_layer;
|
||||||
* Initialize libliftoff for a DRM node. The node is expected to have
|
* Initialize libliftoff for a DRM node. The node is expected to have
|
||||||
* DRM_CLIENT_CAP_UNIVERSAL_PLANES and DRM_CLIENT_CAP_ATOMIC enabled.
|
* DRM_CLIENT_CAP_UNIVERSAL_PLANES and DRM_CLIENT_CAP_ATOMIC enabled.
|
||||||
*/
|
*/
|
||||||
struct liftoff_display *liftoff_display_create(int drm_fd);
|
struct liftoff_device *liftoff_device_create(int drm_fd);
|
||||||
void liftoff_display_destroy(struct liftoff_display *display);
|
void liftoff_device_destroy(struct liftoff_device *device);
|
||||||
/**
|
/**
|
||||||
* Build a layer to plane mapping and append the plane configuration to `req`.
|
* Build a layer to plane mapping and append the plane configuration to `req`.
|
||||||
* Callers are expected to commit `req` afterwards and can read the layer to
|
* Callers are expected to commit `req` afterwards and can read the layer to
|
||||||
* plane mapping with `liftoff_layer_get_plane_id`.
|
* plane mapping with `liftoff_layer_get_plane_id`.
|
||||||
*/
|
*/
|
||||||
bool liftoff_display_apply(struct liftoff_display *display,
|
bool liftoff_device_apply(struct liftoff_device *device,
|
||||||
drmModeAtomicReq *req);
|
drmModeAtomicReq *req);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the display manage a CRTC's planes. The returned output allows callers
|
* Make the device manage a CRTC's planes. The returned output allows callers
|
||||||
* to attach layers.
|
* to attach layers.
|
||||||
*/
|
*/
|
||||||
struct liftoff_output *liftoff_output_create(struct liftoff_display *display,
|
struct liftoff_output *liftoff_output_create(struct liftoff_device *device,
|
||||||
uint32_t crtc_id);
|
uint32_t crtc_id);
|
||||||
void liftoff_output_destroy(struct liftoff_output *output);
|
void liftoff_output_destroy(struct liftoff_output *output);
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* given number of page-flips */
|
* given number of page-flips */
|
||||||
#define LIFTOFF_PRIORITY_PERIOD 60
|
#define LIFTOFF_PRIORITY_PERIOD 60
|
||||||
|
|
||||||
struct liftoff_display {
|
struct liftoff_device {
|
||||||
int drm_fd;
|
int drm_fd;
|
||||||
|
|
||||||
struct liftoff_list planes; /* liftoff_plane.link */
|
struct liftoff_list planes; /* liftoff_plane.link */
|
||||||
|
@ -22,10 +22,10 @@ struct liftoff_display {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct liftoff_output {
|
struct liftoff_output {
|
||||||
struct liftoff_display *display;
|
struct liftoff_device *device;
|
||||||
uint32_t crtc_id;
|
uint32_t crtc_id;
|
||||||
size_t crtc_index;
|
size_t crtc_index;
|
||||||
struct liftoff_list link; /* liftoff_display.outputs */
|
struct liftoff_list link; /* liftoff_device.outputs */
|
||||||
|
|
||||||
struct liftoff_layer *composition_layer;
|
struct liftoff_layer *composition_layer;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ struct liftoff_plane {
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
int zpos; /* greater values mean closer to the eye */
|
int zpos; /* greater values mean closer to the eye */
|
||||||
/* TODO: formats */
|
/* TODO: formats */
|
||||||
struct liftoff_list link; /* liftoff_display.planes */
|
struct liftoff_list link; /* liftoff_device.planes */
|
||||||
|
|
||||||
struct liftoff_plane_property *props;
|
struct liftoff_plane_property *props;
|
||||||
size_t props_len;
|
size_t props_len;
|
||||||
|
@ -81,7 +81,7 @@ bool layer_intersects(struct liftoff_layer *a, struct liftoff_layer *b);
|
||||||
void layer_mark_clean(struct liftoff_layer *layer);
|
void layer_mark_clean(struct liftoff_layer *layer);
|
||||||
void layer_update_priority(struct liftoff_layer *layer, bool make_current);
|
void layer_update_priority(struct liftoff_layer *layer, bool make_current);
|
||||||
|
|
||||||
struct liftoff_plane *plane_create(struct liftoff_display *display, uint32_t id);
|
struct liftoff_plane *plane_create(struct liftoff_device *device, uint32_t id);
|
||||||
void plane_destroy(struct liftoff_plane *plane);
|
void plane_destroy(struct liftoff_plane *plane);
|
||||||
struct liftoff_plane_property *plane_get_property(struct liftoff_plane *plane,
|
struct liftoff_plane_property *plane_get_property(struct liftoff_plane *plane,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
|
10
output.c
10
output.c
|
@ -4,7 +4,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
struct liftoff_output *liftoff_output_create(struct liftoff_display *display,
|
struct liftoff_output *liftoff_output_create(struct liftoff_device *device,
|
||||||
uint32_t crtc_id)
|
uint32_t crtc_id)
|
||||||
{
|
{
|
||||||
struct liftoff_output *output;
|
struct liftoff_output *output;
|
||||||
|
@ -12,8 +12,8 @@ struct liftoff_output *liftoff_output_create(struct liftoff_display *display,
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
crtc_index = -1;
|
crtc_index = -1;
|
||||||
for (i = 0; i < display->crtcs_len; i++) {
|
for (i = 0; i < device->crtcs_len; i++) {
|
||||||
if (display->crtcs[i] == crtc_id) {
|
if (device->crtcs[i] == crtc_id) {
|
||||||
crtc_index = i;
|
crtc_index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,11 @@ struct liftoff_output *liftoff_output_create(struct liftoff_display *display,
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
output->display = display;
|
output->device = device;
|
||||||
output->crtc_id = crtc_id;
|
output->crtc_id = crtc_id;
|
||||||
output->crtc_index = crtc_index;
|
output->crtc_index = crtc_index;
|
||||||
liftoff_list_init(&output->layers);
|
liftoff_list_init(&output->layers);
|
||||||
liftoff_list_insert(&display->outputs, &output->link);
|
liftoff_list_insert(&device->outputs, &output->link);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
plane.c
22
plane.c
|
@ -3,7 +3,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
static int guess_plane_zpos_from_type(struct liftoff_display *display,
|
static int guess_plane_zpos_from_type(struct liftoff_device *device,
|
||||||
uint32_t plane_id, uint32_t type)
|
uint32_t plane_id, uint32_t type)
|
||||||
{
|
{
|
||||||
struct liftoff_plane *primary;
|
struct liftoff_plane *primary;
|
||||||
|
@ -16,10 +16,10 @@ static int guess_plane_zpos_from_type(struct liftoff_display *display,
|
||||||
case DRM_PLANE_TYPE_CURSOR:
|
case DRM_PLANE_TYPE_CURSOR:
|
||||||
return 2;
|
return 2;
|
||||||
case DRM_PLANE_TYPE_OVERLAY:
|
case DRM_PLANE_TYPE_OVERLAY:
|
||||||
if (liftoff_list_empty(&display->planes)) {
|
if (liftoff_list_empty(&device->planes)) {
|
||||||
return 0; /* No primary plane, shouldn't happen */
|
return 0; /* No primary plane, shouldn't happen */
|
||||||
}
|
}
|
||||||
primary = liftoff_container_of(display->planes.next,
|
primary = liftoff_container_of(device->planes.next,
|
||||||
primary, link);
|
primary, link);
|
||||||
if (plane_id < primary->id) {
|
if (plane_id < primary->id) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -30,7 +30,7 @@ static int guess_plane_zpos_from_type(struct liftoff_display *display,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct liftoff_plane *plane_create(struct liftoff_display *display, uint32_t id)
|
struct liftoff_plane *plane_create(struct liftoff_device *device, uint32_t id)
|
||||||
{
|
{
|
||||||
struct liftoff_plane *plane, *cur;
|
struct liftoff_plane *plane, *cur;
|
||||||
drmModePlane *drm_plane;
|
drmModePlane *drm_plane;
|
||||||
|
@ -47,7 +47,7 @@ struct liftoff_plane *plane_create(struct liftoff_display *display, uint32_t id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_plane = drmModeGetPlane(display->drm_fd, id);
|
drm_plane = drmModeGetPlane(device->drm_fd, id);
|
||||||
if (drm_plane == NULL) {
|
if (drm_plane == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetPlane");
|
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetPlane");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -56,7 +56,7 @@ struct liftoff_plane *plane_create(struct liftoff_display *display, uint32_t id)
|
||||||
plane->possible_crtcs = drm_plane->possible_crtcs;
|
plane->possible_crtcs = drm_plane->possible_crtcs;
|
||||||
drmModeFreePlane(drm_plane);
|
drmModeFreePlane(drm_plane);
|
||||||
|
|
||||||
drm_props = drmModeObjectGetProperties(display->drm_fd, id,
|
drm_props = drmModeObjectGetProperties(device->drm_fd, id,
|
||||||
DRM_MODE_OBJECT_PLANE);
|
DRM_MODE_OBJECT_PLANE);
|
||||||
if (drm_props == NULL) {
|
if (drm_props == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "drmModeObjectGetProperties");
|
liftoff_log_errno(LIFTOFF_ERROR, "drmModeObjectGetProperties");
|
||||||
|
@ -70,7 +70,7 @@ struct liftoff_plane *plane_create(struct liftoff_display *display, uint32_t id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
for (i = 0; i < drm_props->count_props; i++) {
|
for (i = 0; i < drm_props->count_props; i++) {
|
||||||
drm_prop = drmModeGetProperty(display->drm_fd,
|
drm_prop = drmModeGetProperty(device->drm_fd,
|
||||||
drm_props->props[i]);
|
drm_props->props[i]);
|
||||||
if (drm_prop == NULL) {
|
if (drm_prop == NULL) {
|
||||||
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetProperty");
|
liftoff_log_errno(LIFTOFF_ERROR, "drmModeGetProperty");
|
||||||
|
@ -101,7 +101,7 @@ struct liftoff_plane *plane_create(struct liftoff_display *display, uint32_t id)
|
||||||
free(plane);
|
free(plane);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (!has_zpos) {
|
} else if (!has_zpos) {
|
||||||
plane->zpos = guess_plane_zpos_from_type(display, plane->id,
|
plane->zpos = guess_plane_zpos_from_type(device, plane->id,
|
||||||
plane->type);
|
plane->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,9 +110,9 @@ struct liftoff_plane *plane_create(struct liftoff_display *display, uint32_t id)
|
||||||
* far from the primary planes, then planes closer and closer to the
|
* far from the primary planes, then planes closer and closer to the
|
||||||
* primary plane. */
|
* primary plane. */
|
||||||
if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
|
if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
|
||||||
liftoff_list_insert(&display->planes, &plane->link);
|
liftoff_list_insert(&device->planes, &plane->link);
|
||||||
} else {
|
} else {
|
||||||
liftoff_list_for_each(cur, &display->planes, link) {
|
liftoff_list_for_each(cur, &device->planes, link) {
|
||||||
if (cur->type != DRM_PLANE_TYPE_PRIMARY &&
|
if (cur->type != DRM_PLANE_TYPE_PRIMARY &&
|
||||||
plane->zpos >= cur->zpos) {
|
plane->zpos >= cur->zpos) {
|
||||||
liftoff_list_insert(cur->link.prev, &plane->link);
|
liftoff_list_insert(cur->link.prev, &plane->link);
|
||||||
|
@ -121,7 +121,7 @@ struct liftoff_plane *plane_create(struct liftoff_display *display, uint32_t id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plane->link.next == NULL) { /* not inserted */
|
if (plane->link.next == NULL) { /* not inserted */
|
||||||
liftoff_list_insert(display->planes.prev, &plane->link);
|
liftoff_list_insert(device->planes.prev, &plane->link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue