mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
kms/update: Assign planes with MetaDrmBuffer instead of fb ids
This will eventually allow better lifetime control. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
parent
7842517519
commit
28facbfa3a
@ -98,7 +98,7 @@ meta_crtc_kms_apply_transform (MetaCrtcKms *crtc_kms,
|
||||
|
||||
void
|
||||
meta_crtc_kms_assign_primary_plane (MetaCrtcKms *crtc_kms,
|
||||
uint32_t fb_id,
|
||||
MetaDrmBuffer *buffer,
|
||||
MetaKmsUpdate *kms_update)
|
||||
{
|
||||
MetaCrtc *crtc = META_CRTC (crtc_kms);
|
||||
@ -137,7 +137,7 @@ meta_crtc_kms_assign_primary_plane (MetaCrtcKms *crtc_kms,
|
||||
plane_assignment = meta_kms_update_assign_plane (kms_update,
|
||||
kms_crtc,
|
||||
primary_kms_plane,
|
||||
fb_id,
|
||||
buffer,
|
||||
src_rect,
|
||||
dst_rect,
|
||||
flags);
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "backends/meta-backend-types.h"
|
||||
#include "backends/meta-crtc.h"
|
||||
#include "backends/native/meta-drm-buffer.h"
|
||||
#include "backends/native/meta-gpu-kms.h"
|
||||
#include "backends/native/meta-kms-crtc.h"
|
||||
#include "backends/native/meta-kms-update.h"
|
||||
@ -49,7 +50,7 @@ void meta_crtc_kms_apply_transform (MetaCrtcKms *crtc_kms,
|
||||
MetaKmsPlaneAssignment *kms_plane_assignment);
|
||||
|
||||
void meta_crtc_kms_assign_primary_plane (MetaCrtcKms *crtc_kms,
|
||||
uint32_t fb_id,
|
||||
MetaDrmBuffer *buffer,
|
||||
MetaKmsUpdate *kms_update);
|
||||
|
||||
void meta_crtc_kms_set_mode (MetaCrtcKms *crtc_kms,
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "backends/meta-monitor-manager-private.h"
|
||||
#include "backends/meta-output.h"
|
||||
#include "backends/native/meta-crtc-kms.h"
|
||||
#include "backends/native/meta-drm-buffer-gbm.h"
|
||||
#include "backends/native/meta-kms-device.h"
|
||||
#include "backends/native/meta-kms-update.h"
|
||||
#include "backends/native/meta-kms.h"
|
||||
@ -100,19 +101,19 @@ typedef struct _MetaCursorRendererNativeGpuData
|
||||
uint64_t cursor_height;
|
||||
} MetaCursorRendererNativeGpuData;
|
||||
|
||||
typedef enum _MetaCursorGbmBoState
|
||||
typedef enum _MetaCursorBufferState
|
||||
{
|
||||
META_CURSOR_GBM_BO_STATE_NONE,
|
||||
META_CURSOR_GBM_BO_STATE_SET,
|
||||
META_CURSOR_GBM_BO_STATE_INVALIDATED,
|
||||
} MetaCursorGbmBoState;
|
||||
META_CURSOR_BUFFER_STATE_NONE,
|
||||
META_CURSOR_BUFFER_STATE_SET,
|
||||
META_CURSOR_BUFFER_STATE_INVALIDATED,
|
||||
} MetaCursorBufferState;
|
||||
|
||||
typedef struct _MetaCursorNativeGpuState
|
||||
{
|
||||
MetaGpu *gpu;
|
||||
unsigned int active_bo;
|
||||
MetaCursorGbmBoState pending_bo_state;
|
||||
struct gbm_bo *bos[HW_CURSOR_BUFFER_COUNT];
|
||||
unsigned int active_buffer_idx;
|
||||
MetaCursorBufferState pending_buffer_state;
|
||||
MetaDrmBuffer *buffers[HW_CURSOR_BUFFER_COUNT];
|
||||
} MetaCursorNativeGpuState;
|
||||
|
||||
typedef struct _MetaCursorNativePrivate
|
||||
@ -186,41 +187,43 @@ meta_cursor_renderer_native_finalize (GObject *object)
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
get_pending_cursor_sprite_gbm_bo_index (MetaCursorNativeGpuState *cursor_gpu_state)
|
||||
get_pending_cursor_sprite_buffer_index (MetaCursorNativeGpuState *cursor_gpu_state)
|
||||
{
|
||||
return (cursor_gpu_state->active_bo + 1) % HW_CURSOR_BUFFER_COUNT;
|
||||
return (cursor_gpu_state->active_buffer_idx + 1) % HW_CURSOR_BUFFER_COUNT;
|
||||
}
|
||||
|
||||
static struct gbm_bo *
|
||||
get_pending_cursor_sprite_gbm_bo (MetaCursorNativeGpuState *cursor_gpu_state)
|
||||
static MetaDrmBuffer *
|
||||
get_pending_cursor_sprite_buffer (MetaCursorNativeGpuState *cursor_gpu_state)
|
||||
{
|
||||
unsigned int pending_bo;
|
||||
unsigned int pending_buffer_idx;
|
||||
|
||||
pending_bo = get_pending_cursor_sprite_gbm_bo_index (cursor_gpu_state);
|
||||
return cursor_gpu_state->bos[pending_bo];
|
||||
pending_buffer_idx =
|
||||
get_pending_cursor_sprite_buffer_index (cursor_gpu_state);
|
||||
return cursor_gpu_state->buffers[pending_buffer_idx];
|
||||
}
|
||||
|
||||
static struct gbm_bo *
|
||||
get_active_cursor_sprite_gbm_bo (MetaCursorNativeGpuState *cursor_gpu_state)
|
||||
static MetaDrmBuffer *
|
||||
get_active_cursor_sprite_buffer (MetaCursorNativeGpuState *cursor_gpu_state)
|
||||
{
|
||||
return cursor_gpu_state->bos[cursor_gpu_state->active_bo];
|
||||
return cursor_gpu_state->buffers[cursor_gpu_state->active_buffer_idx];
|
||||
}
|
||||
|
||||
static void
|
||||
set_pending_cursor_sprite_gbm_bo (MetaCursorSprite *cursor_sprite,
|
||||
set_pending_cursor_sprite_buffer (MetaCursorSprite *cursor_sprite,
|
||||
MetaGpuKms *gpu_kms,
|
||||
struct gbm_bo *bo)
|
||||
MetaDrmBuffer *buffer)
|
||||
{
|
||||
MetaCursorNativePrivate *cursor_priv;
|
||||
MetaCursorNativeGpuState *cursor_gpu_state;
|
||||
unsigned int pending_bo;
|
||||
unsigned int pending_buffer_idx;
|
||||
|
||||
cursor_priv = ensure_cursor_priv (cursor_sprite);
|
||||
cursor_gpu_state = ensure_cursor_gpu_state (cursor_priv, gpu_kms);
|
||||
|
||||
pending_bo = get_pending_cursor_sprite_gbm_bo_index (cursor_gpu_state);
|
||||
cursor_gpu_state->bos[pending_bo] = bo;
|
||||
cursor_gpu_state->pending_bo_state = META_CURSOR_GBM_BO_STATE_SET;
|
||||
pending_buffer_idx =
|
||||
get_pending_cursor_sprite_buffer_index (cursor_gpu_state);
|
||||
cursor_gpu_state->buffers[pending_buffer_idx] = buffer;
|
||||
cursor_gpu_state->pending_buffer_state = META_CURSOR_BUFFER_STATE_SET;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -268,29 +271,26 @@ set_crtc_cursor (MetaCursorRendererNative *native,
|
||||
MetaKmsCrtc *kms_crtc;
|
||||
MetaKmsDevice *kms_device;
|
||||
MetaKmsPlane *cursor_plane;
|
||||
struct gbm_bo *bo;
|
||||
union gbm_bo_handle handle;
|
||||
MetaDrmBuffer *buffer;
|
||||
int cursor_width, cursor_height;
|
||||
MetaFixed16Rectangle src_rect;
|
||||
MetaRectangle dst_rect;
|
||||
struct gbm_bo *crtc_bo;
|
||||
MetaDrmBuffer *crtc_buffer;
|
||||
MetaKmsAssignPlaneFlag flags;
|
||||
int cursor_hotspot_x;
|
||||
int cursor_hotspot_y;
|
||||
MetaKmsPlaneAssignment *plane_assignment;
|
||||
|
||||
if (cursor_gpu_state->pending_bo_state == META_CURSOR_GBM_BO_STATE_SET)
|
||||
bo = get_pending_cursor_sprite_gbm_bo (cursor_gpu_state);
|
||||
if (cursor_gpu_state->pending_buffer_state == META_CURSOR_BUFFER_STATE_SET)
|
||||
buffer = get_pending_cursor_sprite_buffer (cursor_gpu_state);
|
||||
else
|
||||
bo = get_active_cursor_sprite_gbm_bo (cursor_gpu_state);
|
||||
buffer = get_active_cursor_sprite_buffer (cursor_gpu_state);
|
||||
|
||||
kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
|
||||
kms_device = meta_kms_crtc_get_device (kms_crtc);
|
||||
cursor_plane = meta_kms_device_get_cursor_plane_for (kms_device, kms_crtc);
|
||||
g_return_if_fail (cursor_plane);
|
||||
|
||||
handle = gbm_bo_get_handle (bo);
|
||||
|
||||
cursor_width = cursor_renderer_gpu_data->cursor_width;
|
||||
cursor_height = cursor_renderer_gpu_data->cursor_height;
|
||||
src_rect = (MetaFixed16Rectangle) {
|
||||
@ -307,14 +307,14 @@ set_crtc_cursor (MetaCursorRendererNative *native,
|
||||
};
|
||||
|
||||
flags = META_KMS_ASSIGN_PLANE_FLAG_NONE;
|
||||
crtc_bo = meta_crtc_kms_get_cursor_renderer_private (crtc_kms);
|
||||
if (!priv->hw_state_invalidated && bo == crtc_bo)
|
||||
crtc_buffer = meta_crtc_kms_get_cursor_renderer_private (crtc_kms);
|
||||
if (!priv->hw_state_invalidated && buffer == crtc_buffer)
|
||||
flags |= META_KMS_ASSIGN_PLANE_FLAG_FB_UNCHANGED;
|
||||
|
||||
plane_assignment = meta_kms_update_assign_plane (kms_update,
|
||||
kms_crtc,
|
||||
cursor_plane,
|
||||
handle.u32,
|
||||
buffer,
|
||||
src_rect,
|
||||
dst_rect,
|
||||
flags);
|
||||
@ -326,13 +326,13 @@ set_crtc_cursor (MetaCursorRendererNative *native,
|
||||
cursor_hotspot_x,
|
||||
cursor_hotspot_y);
|
||||
|
||||
meta_crtc_kms_set_cursor_renderer_private (crtc_kms, bo);
|
||||
meta_crtc_kms_set_cursor_renderer_private (crtc_kms, buffer);
|
||||
|
||||
if (cursor_gpu_state->pending_bo_state == META_CURSOR_GBM_BO_STATE_SET)
|
||||
if (cursor_gpu_state->pending_buffer_state == META_CURSOR_BUFFER_STATE_SET)
|
||||
{
|
||||
cursor_gpu_state->active_bo =
|
||||
(cursor_gpu_state->active_bo + 1) % HW_CURSOR_BUFFER_COUNT;
|
||||
cursor_gpu_state->pending_bo_state = META_CURSOR_GBM_BO_STATE_NONE;
|
||||
cursor_gpu_state->active_buffer_idx =
|
||||
(cursor_gpu_state->active_buffer_idx + 1) % HW_CURSOR_BUFFER_COUNT;
|
||||
cursor_gpu_state->pending_buffer_state = META_CURSOR_BUFFER_STATE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,10 +346,10 @@ unset_crtc_cursor (MetaCursorRendererNative *native,
|
||||
MetaKmsCrtc *kms_crtc;
|
||||
MetaKmsDevice *kms_device;
|
||||
MetaKmsPlane *cursor_plane;
|
||||
struct gbm_bo *crtc_bo;
|
||||
MetaDrmBuffer *crtc_buffer;
|
||||
|
||||
crtc_bo = meta_crtc_kms_get_cursor_renderer_private (crtc_kms);
|
||||
if (!priv->hw_state_invalidated && !crtc_bo)
|
||||
crtc_buffer = meta_crtc_kms_get_cursor_renderer_private (crtc_kms);
|
||||
if (!priv->hw_state_invalidated && !crtc_buffer)
|
||||
return;
|
||||
|
||||
kms_crtc = meta_crtc_kms_get_kms_crtc (crtc_kms);
|
||||
@ -615,7 +615,7 @@ update_hw_cursor (MetaCursorRendererNative *native,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
has_valid_cursor_sprite_gbm_bo (MetaCursorSprite *cursor_sprite,
|
||||
has_valid_cursor_sprite_buffer (MetaCursorSprite *cursor_sprite,
|
||||
MetaGpuKms *gpu_kms)
|
||||
{
|
||||
MetaCursorNativePrivate *cursor_priv;
|
||||
@ -629,13 +629,13 @@ has_valid_cursor_sprite_gbm_bo (MetaCursorSprite *cursor_sprite,
|
||||
if (!cursor_gpu_state)
|
||||
return FALSE;
|
||||
|
||||
switch (cursor_gpu_state->pending_bo_state)
|
||||
switch (cursor_gpu_state->pending_buffer_state)
|
||||
{
|
||||
case META_CURSOR_GBM_BO_STATE_NONE:
|
||||
return get_active_cursor_sprite_gbm_bo (cursor_gpu_state) != NULL;
|
||||
case META_CURSOR_GBM_BO_STATE_SET:
|
||||
case META_CURSOR_BUFFER_STATE_NONE:
|
||||
return get_active_cursor_sprite_buffer (cursor_gpu_state) != NULL;
|
||||
case META_CURSOR_BUFFER_STATE_SET:
|
||||
return TRUE;
|
||||
case META_CURSOR_GBM_BO_STATE_INVALIDATED:
|
||||
case META_CURSOR_BUFFER_STATE_INVALIDATED:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -903,7 +903,7 @@ should_have_hw_cursor (MetaCursorRenderer *renderer,
|
||||
if (cursor_renderer_gpu_data->hw_cursor_broken)
|
||||
return FALSE;
|
||||
|
||||
if (!has_valid_cursor_sprite_gbm_bo (cursor_sprite, gpu_kms))
|
||||
if (!has_valid_cursor_sprite_buffer (cursor_sprite, gpu_kms))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1059,17 +1059,17 @@ meta_cursor_renderer_native_update_cursor (MetaCursorRenderer *renderer,
|
||||
|
||||
static void
|
||||
unset_crtc_cursor_renderer_privates (MetaGpu *gpu,
|
||||
struct gbm_bo *bo)
|
||||
MetaDrmBuffer *buffer)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = meta_gpu_get_crtcs (gpu); l; l = l->next)
|
||||
{
|
||||
MetaCrtcKms *crtc_kms = META_CRTC_KMS (l->data);
|
||||
struct gbm_bo *crtc_bo;
|
||||
MetaDrmBuffer *crtc_buffer;
|
||||
|
||||
crtc_bo = meta_crtc_kms_get_cursor_renderer_private (crtc_kms);
|
||||
if (bo == crtc_bo)
|
||||
crtc_buffer = meta_crtc_kms_get_cursor_renderer_private (crtc_kms);
|
||||
if (buffer == crtc_buffer)
|
||||
meta_crtc_kms_set_cursor_renderer_private (crtc_kms, NULL);
|
||||
}
|
||||
}
|
||||
@ -1078,14 +1078,15 @@ static void
|
||||
cursor_gpu_state_free (MetaCursorNativeGpuState *cursor_gpu_state)
|
||||
{
|
||||
int i;
|
||||
struct gbm_bo *active_bo;
|
||||
MetaDrmBuffer *active_buffer;
|
||||
|
||||
active_bo = get_active_cursor_sprite_gbm_bo (cursor_gpu_state);
|
||||
if (active_bo)
|
||||
unset_crtc_cursor_renderer_privates (cursor_gpu_state->gpu, active_bo);
|
||||
active_buffer = get_active_cursor_sprite_buffer (cursor_gpu_state);
|
||||
if (active_buffer)
|
||||
unset_crtc_cursor_renderer_privates (cursor_gpu_state->gpu,
|
||||
active_buffer);
|
||||
|
||||
for (i = 0; i < HW_CURSOR_BUFFER_COUNT; i++)
|
||||
g_clear_pointer (&cursor_gpu_state->bos[i], gbm_bo_destroy);
|
||||
g_clear_object (&cursor_gpu_state->buffers[i]);
|
||||
g_free (cursor_gpu_state);
|
||||
}
|
||||
|
||||
@ -1123,11 +1124,12 @@ invalidate_cursor_gpu_state (MetaCursorSprite *cursor_sprite)
|
||||
g_hash_table_iter_init (&iter, cursor_priv->gpu_states);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &cursor_gpu_state))
|
||||
{
|
||||
unsigned int pending_bo;
|
||||
pending_bo = get_pending_cursor_sprite_gbm_bo_index (cursor_gpu_state);
|
||||
g_clear_pointer (&cursor_gpu_state->bos[pending_bo],
|
||||
gbm_bo_destroy);
|
||||
cursor_gpu_state->pending_bo_state = META_CURSOR_GBM_BO_STATE_INVALIDATED;
|
||||
unsigned int pending_buffer_idx;
|
||||
|
||||
pending_buffer_idx = get_pending_cursor_sprite_buffer_index (cursor_gpu_state);
|
||||
g_clear_object (&cursor_gpu_state->buffers[pending_buffer_idx]);
|
||||
cursor_gpu_state->pending_buffer_state =
|
||||
META_CURSOR_BUFFER_STATE_INVALIDATED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1211,9 +1213,12 @@ load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
|
||||
if (gbm_device_is_format_supported (gbm_device, gbm_format,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
|
||||
{
|
||||
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
|
||||
struct gbm_bo *bo;
|
||||
uint8_t buf[4 * cursor_width * cursor_height];
|
||||
uint i;
|
||||
g_autoptr (GError) error = NULL;
|
||||
MetaDrmBufferGbm *buffer_gbm;
|
||||
|
||||
bo = gbm_bo_create (gbm_device, cursor_width, cursor_height,
|
||||
gbm_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
||||
@ -1234,7 +1239,17 @@ load_cursor_sprite_gbm_buffer_for_gpu (MetaCursorRendererNative *native,
|
||||
return;
|
||||
}
|
||||
|
||||
set_pending_cursor_sprite_gbm_bo (cursor_sprite, gpu_kms, bo);
|
||||
buffer_gbm = meta_drm_buffer_gbm_new_take (kms_device, bo, FALSE, &error);
|
||||
if (!buffer_gbm)
|
||||
{
|
||||
meta_warning ("Failed to create DRM buffer wrapper: %s",
|
||||
error->message);
|
||||
gbm_bo_destroy (bo);
|
||||
return;
|
||||
}
|
||||
|
||||
set_pending_cursor_sprite_buffer (cursor_sprite, gpu_kms,
|
||||
META_DRM_BUFFER (buffer_gbm));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1257,12 +1272,12 @@ is_cursor_hw_state_valid (MetaCursorSprite *cursor_sprite,
|
||||
if (!cursor_gpu_state)
|
||||
return FALSE;
|
||||
|
||||
switch (cursor_gpu_state->pending_bo_state)
|
||||
switch (cursor_gpu_state->pending_buffer_state)
|
||||
{
|
||||
case META_CURSOR_GBM_BO_STATE_SET:
|
||||
case META_CURSOR_GBM_BO_STATE_NONE:
|
||||
case META_CURSOR_BUFFER_STATE_SET:
|
||||
case META_CURSOR_BUFFER_STATE_NONE:
|
||||
return TRUE;
|
||||
case META_CURSOR_GBM_BO_STATE_INVALIDATED:
|
||||
case META_CURSOR_BUFFER_STATE_INVALIDATED:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1509,8 +1524,11 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
|
||||
}
|
||||
else
|
||||
{
|
||||
MetaKmsDevice *kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
|
||||
struct gbm_device *gbm_device;
|
||||
struct gbm_bo *bo;
|
||||
g_autoptr (GError) error = NULL;
|
||||
MetaDrmBufferGbm *buffer_gbm;
|
||||
|
||||
/* HW cursors have a predefined size (at least 64x64), which usually is
|
||||
* bigger than cursor theme size, so themed cursors must be padded with
|
||||
@ -1544,7 +1562,17 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
|
||||
|
||||
unset_can_preprocess (cursor_sprite);
|
||||
|
||||
set_pending_cursor_sprite_gbm_bo (cursor_sprite, gpu_kms, bo);
|
||||
buffer_gbm = meta_drm_buffer_gbm_new_take (kms_device, bo, FALSE, &error);
|
||||
if (!buffer_gbm)
|
||||
{
|
||||
meta_warning ("Failed to create DRM buffer wrapper: %s",
|
||||
error->message);
|
||||
gbm_bo_destroy (bo);
|
||||
return;
|
||||
}
|
||||
|
||||
set_pending_cursor_sprite_buffer (cursor_sprite, gpu_kms,
|
||||
META_DRM_BUFFER (buffer_gbm));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "backends/native/meta-kms-impl-device-simple.h"
|
||||
|
||||
#include "backends/native/meta-drm-buffer-gbm.h"
|
||||
#include "backends/native/meta-kms-connector-private.h"
|
||||
#include "backends/native/meta-kms-crtc-private.h"
|
||||
#include "backends/native/meta-kms-device-private.h"
|
||||
@ -259,6 +260,8 @@ process_mode_set (MetaKmsImplDevice *impl_device,
|
||||
|
||||
if (mode_set->mode)
|
||||
{
|
||||
MetaDrmBuffer *buffer;
|
||||
|
||||
drm_mode = g_alloca (sizeof *drm_mode);
|
||||
*drm_mode = *meta_kms_mode_get_drm_mode (mode_set->mode);
|
||||
|
||||
@ -288,7 +291,8 @@ process_mode_set (MetaKmsImplDevice *impl_device,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fb_id = plane_assignment->fb_id;
|
||||
buffer = plane_assignment->buffer;
|
||||
fb_id = meta_drm_buffer_get_fb_id (buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -641,6 +645,7 @@ mode_set_fallback (MetaKmsImplDeviceSimple *impl_device_simple,
|
||||
CachedModeSet *cached_mode_set;
|
||||
g_autofree uint32_t *connectors = NULL;
|
||||
int n_connectors;
|
||||
uint32_t fb_id;
|
||||
uint32_t x, y;
|
||||
int fd;
|
||||
int ret;
|
||||
@ -658,13 +663,15 @@ mode_set_fallback (MetaKmsImplDeviceSimple *impl_device_simple,
|
||||
&connectors,
|
||||
&n_connectors);
|
||||
|
||||
fb_id = meta_drm_buffer_get_fb_id (plane_assignment->buffer);
|
||||
|
||||
x = meta_fixed_16_to_int (plane_assignment->src_rect.x);
|
||||
y = meta_fixed_16_to_int (plane_assignment->src_rect.y);
|
||||
|
||||
fd = meta_kms_impl_device_get_fd (impl_device);
|
||||
ret = drmModeSetCrtc (fd,
|
||||
meta_kms_crtc_get_id (crtc),
|
||||
plane_assignment->fb_id,
|
||||
fb_id,
|
||||
x, y,
|
||||
connectors, n_connectors,
|
||||
cached_mode_set->drm_mode);
|
||||
@ -730,9 +737,12 @@ process_page_flip (MetaKmsImplDevice *impl_device,
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t fb_id;
|
||||
|
||||
fb_id = meta_drm_buffer_get_fb_id (plane_assignment->buffer);
|
||||
ret = drmModePageFlip (fd,
|
||||
meta_kms_crtc_get_id (crtc),
|
||||
plane_assignment->fb_id,
|
||||
fb_id,
|
||||
DRM_MODE_PAGE_FLIP_EVENT,
|
||||
meta_kms_page_flip_data_ref (page_flip_data));
|
||||
}
|
||||
@ -747,15 +757,19 @@ process_page_flip (MetaKmsImplDevice *impl_device,
|
||||
cached_mode_set = get_cached_mode_set (impl_device_simple, crtc);
|
||||
if (cached_mode_set)
|
||||
{
|
||||
uint32_t fb_id;
|
||||
drmModeModeInfo *drm_mode;
|
||||
float refresh_rate;
|
||||
|
||||
if (plane_assignment)
|
||||
fb_id = meta_drm_buffer_get_fb_id (plane_assignment->buffer);
|
||||
else
|
||||
fb_id = 0;
|
||||
drm_mode = cached_mode_set->drm_mode;
|
||||
refresh_rate = meta_calculate_drm_mode_refresh_rate (drm_mode);
|
||||
schedule_retry_page_flip (impl_device_simple,
|
||||
crtc,
|
||||
plane_assignment ?
|
||||
plane_assignment->fb_id : 0,
|
||||
fb_id,
|
||||
refresh_rate,
|
||||
page_flip_data,
|
||||
custom_page_flip_func,
|
||||
@ -851,15 +865,32 @@ process_cursor_plane_assignment (MetaKmsImplDevice *impl_device,
|
||||
{
|
||||
int width, height;
|
||||
int ret = -1;
|
||||
uint32_t handle_u32;
|
||||
|
||||
width = plane_assignment->dst_rect.width;
|
||||
height = plane_assignment->dst_rect.height;
|
||||
|
||||
if (plane_assignment->buffer)
|
||||
{
|
||||
MetaDrmBufferGbm *buffer_gbm =
|
||||
META_DRM_BUFFER_GBM (plane_assignment->buffer);
|
||||
struct gbm_bo *bo;
|
||||
union gbm_bo_handle handle;
|
||||
|
||||
bo = meta_drm_buffer_gbm_get_bo (buffer_gbm);
|
||||
handle = gbm_bo_get_handle (bo);
|
||||
handle_u32 = handle.u32;
|
||||
}
|
||||
else
|
||||
{
|
||||
handle_u32 = 0;
|
||||
}
|
||||
|
||||
if (plane_assignment->cursor_hotspot.is_valid)
|
||||
{
|
||||
ret = drmModeSetCursor2 (fd,
|
||||
crtc_id,
|
||||
plane_assignment->fb_id,
|
||||
handle_u32,
|
||||
width, height,
|
||||
plane_assignment->cursor_hotspot.x,
|
||||
plane_assignment->cursor_hotspot.y);
|
||||
@ -868,7 +899,7 @@ process_cursor_plane_assignment (MetaKmsImplDevice *impl_device,
|
||||
if (ret != 0)
|
||||
{
|
||||
ret = drmModeSetCursor (fd, crtc_id,
|
||||
plane_assignment->fb_id,
|
||||
handle_u32,
|
||||
width, height);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ typedef struct _MetaKmsPlaneAssignment
|
||||
MetaKmsUpdate *update;
|
||||
MetaKmsCrtc *crtc;
|
||||
MetaKmsPlane *plane;
|
||||
uint32_t fb_id;
|
||||
MetaDrmBuffer *buffer;
|
||||
MetaFixed16Rectangle src_rect;
|
||||
MetaRectangle dst_rect;
|
||||
MetaKmsAssignPlaneFlag flags;
|
||||
|
@ -139,7 +139,7 @@ MetaKmsPlaneAssignment *
|
||||
meta_kms_update_assign_plane (MetaKmsUpdate *update,
|
||||
MetaKmsCrtc *crtc,
|
||||
MetaKmsPlane *plane,
|
||||
uint32_t fb_id,
|
||||
MetaDrmBuffer *buffer,
|
||||
MetaFixed16Rectangle src_rect,
|
||||
MetaRectangle dst_rect,
|
||||
MetaKmsAssignPlaneFlag flags)
|
||||
@ -155,7 +155,7 @@ meta_kms_update_assign_plane (MetaKmsUpdate *update,
|
||||
.update = update,
|
||||
.crtc = crtc,
|
||||
.plane = plane,
|
||||
.fb_id = fb_id,
|
||||
.buffer = buffer,
|
||||
.src_rect = src_rect,
|
||||
.dst_rect = dst_rect,
|
||||
.flags = flags,
|
||||
@ -183,7 +183,7 @@ meta_kms_update_unassign_plane (MetaKmsUpdate *update,
|
||||
.update = update,
|
||||
.crtc = crtc,
|
||||
.plane = plane,
|
||||
.fb_id = 0,
|
||||
.buffer = NULL,
|
||||
};
|
||||
|
||||
update->plane_assignments = g_list_prepend (update->plane_assignments,
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include "backends/meta-monitor-transform.h"
|
||||
#include "backends/native/meta-drm-buffer.h"
|
||||
#include "backends/native/meta-kms-types.h"
|
||||
#include "meta/boxes.h"
|
||||
|
||||
@ -112,7 +113,7 @@ void meta_kms_update_set_crtc_gamma (MetaKmsUpdate *update,
|
||||
MetaKmsPlaneAssignment * meta_kms_update_assign_plane (MetaKmsUpdate *update,
|
||||
MetaKmsCrtc *crtc,
|
||||
MetaKmsPlane *plane,
|
||||
uint32_t fb_id,
|
||||
MetaDrmBuffer *buffer,
|
||||
MetaFixed16Rectangle src_rect,
|
||||
MetaRectangle dst_rect,
|
||||
MetaKmsAssignPlaneFlag flags);
|
||||
|
@ -1266,7 +1266,7 @@ meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen,
|
||||
MetaKms *kms;
|
||||
MetaKmsUpdate *kms_update;
|
||||
MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state = NULL;
|
||||
uint32_t fb_id;
|
||||
MetaDrmBuffer *buffer;
|
||||
|
||||
gpu_kms = META_GPU_KMS (meta_crtc_get_gpu (crtc));
|
||||
kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
|
||||
@ -1282,15 +1282,15 @@ meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen,
|
||||
case META_RENDERER_NATIVE_MODE_GBM:
|
||||
if (gpu_kms == render_gpu)
|
||||
{
|
||||
fb_id = meta_drm_buffer_get_fb_id (onscreen_native->gbm.next_fb);
|
||||
buffer = onscreen_native->gbm.next_fb;
|
||||
}
|
||||
else
|
||||
{
|
||||
secondary_gpu_state = onscreen_native->secondary_gpu_state;
|
||||
fb_id = meta_drm_buffer_get_fb_id (secondary_gpu_state->gbm.next_fb);
|
||||
buffer = secondary_gpu_state->gbm.next_fb;
|
||||
}
|
||||
|
||||
meta_crtc_kms_assign_primary_plane (crtc_kms, fb_id, kms_update);
|
||||
meta_crtc_kms_assign_primary_plane (crtc_kms, buffer, kms_update);
|
||||
meta_crtc_kms_page_flip (crtc_kms,
|
||||
&page_flip_feedback,
|
||||
flags,
|
||||
@ -1338,9 +1338,7 @@ meta_onscreen_native_set_crtc_mode (CoglOnscreen *onscreen,
|
||||
MetaDrmBuffer *buffer;
|
||||
|
||||
buffer = META_DRM_BUFFER (onscreen_native->egl.dumb_fb);
|
||||
meta_crtc_kms_assign_primary_plane (crtc_kms,
|
||||
meta_drm_buffer_get_fb_id (buffer),
|
||||
kms_update);
|
||||
meta_crtc_kms_assign_primary_plane (crtc_kms, buffer, kms_update);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user