mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-07 06:08:05 +02:00
backend-drm: move drm_colorop_3x1d_lut_blob functions to colorop.c
Follow-up of "backend-drm: offload post-blend only if libdrm >= 2.4.130". This moves code related to offloading post-blend color xform to colorops.c, which is built only if libdrm >= 2.4.130 is available. Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
parent
a62be1d582
commit
e060a434a5
3 changed files with 104 additions and 56 deletions
|
|
@ -32,6 +32,84 @@
|
|||
#include "shared/weston-assert.h"
|
||||
#include "shared/xalloc.h"
|
||||
|
||||
static void
|
||||
drm_colorop_3x1d_lut_blob_destroy(struct drm_colorop_3x1d_lut_blob *lut)
|
||||
{
|
||||
wl_list_remove(&lut->destroy_listener.link);
|
||||
wl_list_remove(&lut->link);
|
||||
drmModeDestroyPropertyBlob(lut->device->kms_device->fd, lut->blob_id);
|
||||
free(lut);
|
||||
}
|
||||
|
||||
static void
|
||||
drm_colorop_3x1d_lut_blob_destroy_handler(struct wl_listener *l, void *data)
|
||||
{
|
||||
struct drm_colorop_3x1d_lut_blob *lut;
|
||||
|
||||
lut = wl_container_of(l, lut, destroy_listener);
|
||||
assert(lut->xform == data);
|
||||
|
||||
drm_colorop_3x1d_lut_blob_destroy(lut);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for a 3x1D LUT colorop blob in a DRM device.
|
||||
*
|
||||
* \param device The DRM device in which we want to look for the blob.
|
||||
* \param xform The xform from which the LUT comes from.
|
||||
* \param lut_len How many taps each of the 1D LUT has.
|
||||
*/
|
||||
struct drm_colorop_3x1d_lut_blob *
|
||||
drm_colorop_3x1d_lut_blob_search(struct drm_device *device,
|
||||
struct weston_color_transform *xform,
|
||||
uint32_t lut_len)
|
||||
{
|
||||
struct drm_colorop_3x1d_lut_blob *lut;
|
||||
|
||||
wl_list_for_each(lut, &device->drm_colorop_3x1d_lut_blob_list, link)
|
||||
if (lut->xform == xform && lut->lut_len == lut_len)
|
||||
return lut;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a 3x1D LUT colorop blob.
|
||||
*
|
||||
* A Weston colorop is an object associated with a step from a struct
|
||||
* weston_color_transform and that can be used to program KMS color operations.
|
||||
* This function creates a blob for such kind of object and cache that in the
|
||||
* given DRM device, so we can avoid re-creating it.
|
||||
*
|
||||
* \param device The DRM device in which this colorop blob is stored.
|
||||
* \param xform The xform from which the LUT comes from. This object matches its
|
||||
* lifetime.
|
||||
* \param lut_len The number of taps for each of the 1D LUT.
|
||||
* \param blob_id The KMS blob id (associated to the DRM device).
|
||||
* \return The 3x1D LUT colorop blob.
|
||||
*/
|
||||
struct drm_colorop_3x1d_lut_blob *
|
||||
drm_colorop_3x1d_lut_blob_create(struct drm_device *device,
|
||||
struct weston_color_transform *xform,
|
||||
uint32_t lut_len, uint32_t blob_id)
|
||||
{
|
||||
struct drm_colorop_3x1d_lut_blob *lut;
|
||||
|
||||
lut = xzalloc(sizeof(*lut));
|
||||
|
||||
lut->device = device;
|
||||
lut->blob_id = blob_id;
|
||||
lut->xform = xform;
|
||||
lut->lut_len = lut_len;
|
||||
|
||||
wl_list_insert(&device->drm_colorop_3x1d_lut_blob_list, &lut->link);
|
||||
|
||||
lut->destroy_listener.notify = drm_colorop_3x1d_lut_blob_destroy_handler;
|
||||
wl_signal_add(&lut->xform->destroy_signal, &lut->destroy_listener);
|
||||
|
||||
return lut;
|
||||
}
|
||||
|
||||
static void
|
||||
drm_colorop_destroy(struct drm_colorop *colorop)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,6 +54,16 @@ struct drm_color_pipeline {
|
|||
|
||||
#if CAN_OFFLOAD_COLOR_PIPELINE
|
||||
|
||||
struct drm_colorop_3x1d_lut_blob *
|
||||
drm_colorop_3x1d_lut_blob_create(struct drm_device *device,
|
||||
struct weston_color_transform *xform,
|
||||
uint32_t lut_len, uint32_t blob_id);
|
||||
|
||||
struct drm_colorop_3x1d_lut_blob *
|
||||
drm_colorop_3x1d_lut_blob_search(struct drm_device *device,
|
||||
struct weston_color_transform *xform,
|
||||
uint32_t lut_len);
|
||||
|
||||
void
|
||||
drm_plane_populate_color_pipelines(struct drm_plane *plane,
|
||||
drmModeObjectPropertiesPtr plane_props);
|
||||
|
|
@ -63,6 +73,22 @@ drm_plane_release_color_pipelines(struct drm_plane *plane);
|
|||
|
||||
#else /* CAN_OFFLOAD_COLOR_PIPELINE */
|
||||
|
||||
static inline struct drm_colorop_3x1d_lut_blob *
|
||||
drm_colorop_3x1d_lut_blob_create(struct drm_device *device,
|
||||
struct weston_color_transform *xform,
|
||||
uint32_t lut_len, uint32_t blob_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct drm_colorop_3x1d_lut_blob *
|
||||
drm_colorop_3x1d_lut_blob_search(struct drm_device *device,
|
||||
struct weston_color_transform *xform,
|
||||
uint32_t lut_len)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void
|
||||
drm_plane_populate_color_pipelines(struct drm_plane *plane,
|
||||
drmModeObjectPropertiesPtr plane_props)
|
||||
|
|
|
|||
|
|
@ -2235,62 +2235,6 @@ drm_output_init_legacy_gamma_size(struct drm_output *output)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
drm_colorop_3x1d_lut_blob_destroy(struct drm_colorop_3x1d_lut_blob *lut)
|
||||
{
|
||||
wl_list_remove(&lut->destroy_listener.link);
|
||||
wl_list_remove(&lut->link);
|
||||
drmModeDestroyPropertyBlob(lut->device->kms_device->fd, lut->blob_id);
|
||||
free(lut);
|
||||
}
|
||||
|
||||
static void
|
||||
drm_colorop_3x1d_lut_blob_destroy_handler(struct wl_listener *l, void *data)
|
||||
{
|
||||
struct drm_colorop_3x1d_lut_blob *lut;
|
||||
|
||||
lut = wl_container_of(l, lut, destroy_listener);
|
||||
assert(lut->xform == data);
|
||||
|
||||
drm_colorop_3x1d_lut_blob_destroy(lut);
|
||||
}
|
||||
|
||||
static struct drm_colorop_3x1d_lut_blob *
|
||||
drm_colorop_3x1d_lut_blob_search(struct drm_device *device,
|
||||
struct weston_color_transform *xform,
|
||||
uint32_t lut_len)
|
||||
{
|
||||
struct drm_colorop_3x1d_lut_blob *lut;
|
||||
|
||||
wl_list_for_each(lut, &device->drm_colorop_3x1d_lut_blob_list, link)
|
||||
if (lut->xform == xform && lut->lut_len == lut_len)
|
||||
return lut;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct drm_colorop_3x1d_lut_blob *
|
||||
drm_colorop_3x1d_lut_blob_create(struct drm_device *device,
|
||||
struct weston_color_transform *xform,
|
||||
uint32_t lut_len, uint32_t blob_id)
|
||||
{
|
||||
struct drm_colorop_3x1d_lut_blob *lut;
|
||||
|
||||
lut = xzalloc(sizeof(*lut));
|
||||
|
||||
lut->device = device;
|
||||
lut->blob_id = blob_id;
|
||||
lut->xform = xform;
|
||||
lut->lut_len = lut_len;
|
||||
|
||||
wl_list_insert(&device->drm_colorop_3x1d_lut_blob_list, &lut->link);
|
||||
|
||||
lut->destroy_listener.notify = drm_colorop_3x1d_lut_blob_destroy_handler;
|
||||
wl_signal_add(&lut->xform->destroy_signal, &lut->destroy_listener);
|
||||
|
||||
return lut;
|
||||
}
|
||||
|
||||
static struct weston_vec3f *
|
||||
lut_3x1d_from_blend_to_output(struct weston_compositor *compositor,
|
||||
struct weston_color_transform *xform,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue