mirror of
https://github.com/brl/mutter.git
synced 2024-11-10 07:56:14 -05:00
crtc-kms: Make KMS CRTC mode a type inheriting MetaCrtcMode
It carries the drmModeModeInfo copy in it's instance struct, instead of the `driver_private` it was using before. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
This commit is contained in:
parent
352c2ec7b8
commit
09078762ac
@ -152,9 +152,6 @@ meta_crtc_mode_finalize (GObject *object)
|
||||
MetaCrtcMode *crtc_mode = META_CRTC_MODE (object);
|
||||
MetaCrtcModePrivate *priv = meta_crtc_mode_get_instance_private (crtc_mode);
|
||||
|
||||
if (crtc_mode->driver_notify)
|
||||
crtc_mode->driver_notify (crtc_mode);
|
||||
|
||||
g_clear_pointer (&priv->name, g_free);
|
||||
g_clear_pointer (&priv->info, meta_crtc_mode_info_unref);
|
||||
|
||||
|
@ -57,20 +57,17 @@ typedef struct _MetaCrtcModeInfo
|
||||
MetaCrtcModeFlag flags;
|
||||
} MetaCrtcModeInfo;
|
||||
|
||||
struct _MetaCrtcMode
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
gpointer driver_private;
|
||||
GDestroyNotify driver_notify;
|
||||
};
|
||||
|
||||
#define META_TYPE_CRTC_MODE (meta_crtc_mode_get_type ())
|
||||
META_EXPORT_TEST
|
||||
G_DECLARE_FINAL_TYPE (MetaCrtcMode, meta_crtc_mode,
|
||||
G_DECLARE_DERIVABLE_TYPE (MetaCrtcMode, meta_crtc_mode,
|
||||
META, CRTC_MODE,
|
||||
GObject)
|
||||
|
||||
struct _MetaCrtcModeClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
#define META_TYPE_CRTC_MODE_INFO (meta_crtc_mode_info_get_type ())
|
||||
GType meta_crtc_mode_info_get_type (void);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "backends/meta-logical-monitor.h"
|
||||
#include "backends/native/meta-crtc-mode-kms.h"
|
||||
#include "backends/native/meta-gpu-kms.h"
|
||||
#include "backends/native/meta-output-kms.h"
|
||||
#include "backends/native/meta-kms-device.h"
|
||||
@ -172,15 +173,16 @@ meta_crtc_kms_set_mode (MetaCrtcKms *crtc_kms,
|
||||
MetaCrtc *crtc = META_CRTC (crtc_kms);
|
||||
MetaGpu *gpu = meta_crtc_get_gpu (crtc);
|
||||
GList *connectors;
|
||||
drmModeModeInfo *mode;
|
||||
const drmModeModeInfo *mode;
|
||||
|
||||
connectors = generate_crtc_connector_list (gpu, crtc);
|
||||
|
||||
if (connectors)
|
||||
{
|
||||
const MetaCrtcConfig *crtc_config = meta_crtc_get_config (crtc);
|
||||
MetaCrtcModeKms *crtc_mode_kms = META_CRTC_MODE_KMS (crtc_config->mode);
|
||||
|
||||
mode = crtc_config->mode->driver_private;
|
||||
mode = meta_crtc_mode_kms_get_drm_mode (crtc_mode_kms);
|
||||
|
||||
g_debug ("Setting CRTC (%ld) mode to %s",
|
||||
meta_crtc_get_id (crtc), mode->name);
|
||||
|
88
src/backends/native/meta-crtc-mode-kms.c
Normal file
88
src/backends/native/meta-crtc-mode-kms.c
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Red Hat
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "backends/native/meta-crtc-mode-kms.h"
|
||||
|
||||
#include "backends/native/meta-kms-utils.h"
|
||||
|
||||
struct _MetaCrtcModeKms
|
||||
{
|
||||
drmModeModeInfo *drm_mode;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaCrtcModeKms, meta_crtc_mode_kms,
|
||||
META_TYPE_CRTC_MODE)
|
||||
|
||||
const drmModeModeInfo *
|
||||
meta_crtc_mode_kms_get_drm_mode (MetaCrtcModeKms *mode_kms)
|
||||
{
|
||||
return mode_kms->drm_mode;
|
||||
}
|
||||
|
||||
MetaCrtcModeKms *
|
||||
meta_crtc_mode_kms_new (const drmModeModeInfo *drm_mode,
|
||||
uint64_t id)
|
||||
{
|
||||
g_autoptr (MetaCrtcModeInfo) crtc_mode_info = NULL;
|
||||
g_autofree char *crtc_mode_name = NULL;
|
||||
MetaCrtcModeKms *mode_kms;
|
||||
|
||||
crtc_mode_info = meta_crtc_mode_info_new ();
|
||||
crtc_mode_info->width = drm_mode->hdisplay;
|
||||
crtc_mode_info->height = drm_mode->vdisplay;
|
||||
crtc_mode_info->flags = drm_mode->flags;
|
||||
crtc_mode_info->refresh_rate =
|
||||
meta_calculate_drm_mode_refresh_rate (drm_mode);
|
||||
|
||||
crtc_mode_name = g_strndup (drm_mode->name, DRM_DISPLAY_MODE_LEN);
|
||||
mode_kms = g_object_new (META_TYPE_CRTC_MODE_KMS,
|
||||
"id", id,
|
||||
"name", crtc_mode_name,
|
||||
"info", crtc_mode_info,
|
||||
NULL);
|
||||
|
||||
mode_kms->drm_mode = g_slice_dup (drmModeModeInfo, drm_mode);
|
||||
|
||||
return mode_kms;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_crtc_mode_kms_finalize (GObject *object)
|
||||
{
|
||||
MetaCrtcModeKms *mode_kms = META_CRTC_MODE_KMS (object);
|
||||
|
||||
g_slice_free (drmModeModeInfo, mode_kms->drm_mode);
|
||||
|
||||
G_OBJECT_CLASS (meta_crtc_mode_kms_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_crtc_mode_kms_init (MetaCrtcModeKms *mode_kms)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
meta_crtc_mode_kms_class_init (MetaCrtcModeKmsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = meta_crtc_mode_kms_finalize;
|
||||
}
|
38
src/backends/native/meta-crtc-mode-kms.h
Normal file
38
src/backends/native/meta-crtc-mode-kms.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Red Hat
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef META_CRTC_MODE_KMS_H
|
||||
#define META_CRTC_MODE_KMS_H
|
||||
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include "backends/meta-crtc-mode.h"
|
||||
|
||||
#define META_TYPE_CRTC_MODE_KMS (meta_crtc_mode_kms_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (MetaCrtcModeKms, meta_crtc_mode_kms,
|
||||
META, CRTC_MODE_KMS,
|
||||
MetaCrtcMode)
|
||||
|
||||
const drmModeModeInfo * meta_crtc_mode_kms_get_drm_mode (MetaCrtcModeKms *crtc_mode_kms);
|
||||
|
||||
MetaCrtcModeKms * meta_crtc_mode_kms_new (const drmModeModeInfo *drm_mode,
|
||||
uint64_t id);
|
||||
|
||||
#endif /* META_CRTC_MODE_KMS_H */
|
@ -38,6 +38,7 @@
|
||||
#include "backends/meta-output.h"
|
||||
#include "backends/native/meta-backend-native.h"
|
||||
#include "backends/native/meta-crtc-kms.h"
|
||||
#include "backends/native/meta-crtc-mode-kms.h"
|
||||
#include "backends/native/meta-kms-connector.h"
|
||||
#include "backends/native/meta-kms-device.h"
|
||||
#include "backends/native/meta-kms-update.h"
|
||||
@ -273,12 +274,6 @@ compare_outputs (gconstpointer one,
|
||||
return strcmp (output_info_one->name, output_info_two->name);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_crtc_mode_destroy_notify (MetaCrtcMode *mode)
|
||||
{
|
||||
g_slice_free (drmModeModeInfo, mode->driver_private);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_drm_mode_equal (const drmModeModeInfo *one,
|
||||
const drmModeModeInfo *two)
|
||||
@ -329,10 +324,11 @@ meta_gpu_kms_get_mode_from_drm_mode (MetaGpuKms *gpu_kms,
|
||||
|
||||
for (l = meta_gpu_get_modes (gpu); l; l = l->next)
|
||||
{
|
||||
MetaCrtcMode *mode = l->data;
|
||||
MetaCrtcModeKms *crtc_mode_kms = l->data;
|
||||
|
||||
if (meta_drm_mode_equal (drm_mode, mode->driver_private))
|
||||
return mode;
|
||||
if (meta_drm_mode_equal (drm_mode,
|
||||
meta_crtc_mode_kms_get_drm_mode (crtc_mode_kms)))
|
||||
return META_CRTC_MODE (crtc_mode_kms);
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
@ -361,9 +357,6 @@ create_mode (const drmModeModeInfo *drm_mode,
|
||||
"info", crtc_mode_info,
|
||||
NULL);
|
||||
|
||||
mode->driver_private = g_slice_dup (drmModeModeInfo, drm_mode);
|
||||
mode->driver_notify = (GDestroyNotify) meta_crtc_mode_destroy_notify;
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ void
|
||||
meta_kms_update_mode_set (MetaKmsUpdate *update,
|
||||
MetaKmsCrtc *crtc,
|
||||
GList *connectors,
|
||||
drmModeModeInfo *drm_mode)
|
||||
const drmModeModeInfo *drm_mode)
|
||||
{
|
||||
MetaKmsModeSet *mode_set;
|
||||
|
||||
|
@ -82,7 +82,7 @@ void meta_kms_update_free (MetaKmsUpdate *update);
|
||||
void meta_kms_update_mode_set (MetaKmsUpdate *update,
|
||||
MetaKmsCrtc *crtc,
|
||||
GList *connectors,
|
||||
drmModeModeInfo *drm_mode);
|
||||
const drmModeModeInfo *drm_mode);
|
||||
|
||||
MetaKmsPlaneAssignment * meta_kms_update_assign_plane (MetaKmsUpdate *update,
|
||||
MetaKmsCrtc *crtc,
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "backends/native/meta-kms-connector.h"
|
||||
#include "backends/native/meta-kms-utils.h"
|
||||
#include "backends/native/meta-crtc-kms.h"
|
||||
#include "backends/native/meta-crtc-mode-kms.h"
|
||||
|
||||
#include "meta-default-modes.h"
|
||||
|
||||
@ -153,7 +154,10 @@ add_common_modes (MetaOutputInfo *output_info,
|
||||
|
||||
for (i = 0; i < output_info->n_modes; i++)
|
||||
{
|
||||
drm_mode = output_info->modes[i]->driver_private;
|
||||
MetaCrtcMode *crtc_mode = output_info->modes[i];
|
||||
MetaCrtcModeKms *crtc_mode_kms = META_CRTC_MODE_KMS (crtc_mode);
|
||||
|
||||
drm_mode = meta_crtc_mode_kms_get_drm_mode (crtc_mode_kms);
|
||||
refresh_rate = meta_calculate_drm_mode_refresh_rate (drm_mode);
|
||||
max_hdisplay = MAX (max_hdisplay, drm_mode->hdisplay);
|
||||
max_vdisplay = MAX (max_vdisplay, drm_mode->vdisplay);
|
||||
|
@ -632,6 +632,8 @@ if have_native_backend
|
||||
'backends/native/meta-clutter-backend-native.h',
|
||||
'backends/native/meta-crtc-kms.c',
|
||||
'backends/native/meta-crtc-kms.h',
|
||||
'backends/native/meta-crtc-mode-kms.c',
|
||||
'backends/native/meta-crtc-mode-kms.h',
|
||||
'backends/native/meta-cursor-renderer-native.c',
|
||||
'backends/native/meta-cursor-renderer-native.h',
|
||||
'backends/native/meta-drm-buffer-dumb.c',
|
||||
|
Loading…
Reference in New Issue
Block a user