mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
kms: Add MetaKmsMode abstraction
This contains a copy of a drmModeModeInfo, describing a mode. It also has an unused pointer to the impl device it is associated with. It'll later be used to get a blob ID for the mode. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
parent
22b926eea7
commit
f0d3201dab
@ -41,6 +41,7 @@
|
||||
#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-mode.h"
|
||||
#include "backends/native/meta-kms-update.h"
|
||||
#include "backends/native/meta-kms-utils.h"
|
||||
#include "backends/native/meta-kms.h"
|
||||
@ -410,13 +411,20 @@ init_modes (MetaGpuKms *gpu_kms)
|
||||
{
|
||||
MetaKmsConnector *kms_connector = l->data;
|
||||
const MetaKmsConnectorState *state;
|
||||
GList *l_mode;
|
||||
|
||||
state = meta_kms_connector_get_current_state (kms_connector);
|
||||
if (!state)
|
||||
continue;
|
||||
|
||||
for (i = 0; i < state->n_modes; i++)
|
||||
g_hash_table_add (modes_table, &state->modes[i]);
|
||||
for (l_mode = state->modes; l_mode; l_mode = l_mode->next)
|
||||
{
|
||||
MetaKmsMode *kms_mode = l_mode->data;
|
||||
const drmModeModeInfo *drm_mode =
|
||||
meta_kms_mode_get_drm_mode (kms_mode);
|
||||
|
||||
g_hash_table_add (modes_table, (drmModeModeInfo *) drm_mode);
|
||||
}
|
||||
}
|
||||
|
||||
modes = NULL;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "backends/native/meta-kms-crtc.h"
|
||||
#include "backends/native/meta-kms-device-private.h"
|
||||
#include "backends/native/meta-kms-impl-device.h"
|
||||
#include "backends/native/meta-kms-mode-private.h"
|
||||
#include "backends/native/meta-kms-update-private.h"
|
||||
|
||||
struct _MetaKmsConnector
|
||||
@ -354,12 +355,19 @@ state_set_physical_dimensions (MetaKmsConnectorState *state,
|
||||
|
||||
static void
|
||||
state_set_modes (MetaKmsConnectorState *state,
|
||||
MetaKmsImplDevice *impl_device,
|
||||
drmModeConnector *drm_connector)
|
||||
{
|
||||
state->modes =
|
||||
g_memdup (drm_connector->modes,
|
||||
drm_connector->count_modes * sizeof (drmModeModeInfo));
|
||||
state->n_modes = drm_connector->count_modes;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < drm_connector->count_modes; i++)
|
||||
{
|
||||
MetaKmsMode *mode;
|
||||
|
||||
mode = meta_kms_mode_new (impl_device, &drm_connector->modes[i]);
|
||||
state->modes = g_list_prepend (state->modes, mode);
|
||||
}
|
||||
state->modes = g_list_reverse (state->modes);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -452,7 +460,7 @@ static void
|
||||
meta_kms_connector_state_free (MetaKmsConnectorState *state)
|
||||
{
|
||||
g_clear_pointer (&state->edid_data, g_bytes_unref);
|
||||
g_free (state->modes);
|
||||
g_list_free_full (state->modes, (GDestroyNotify) meta_kms_mode_free);
|
||||
g_free (state);
|
||||
}
|
||||
|
||||
@ -480,7 +488,7 @@ meta_kms_connector_read_state (MetaKmsConnector *connector,
|
||||
|
||||
state_set_physical_dimensions (state, drm_connector);
|
||||
|
||||
state_set_modes (state, drm_connector);
|
||||
state_set_modes (state, impl_device, drm_connector);
|
||||
|
||||
state_set_crtc_state (state, drm_connector, impl_device, drm_resources);
|
||||
|
||||
|
@ -39,8 +39,7 @@ typedef struct _MetaKmsConnectorState
|
||||
uint32_t common_possible_clones;
|
||||
uint32_t encoder_device_idxs;
|
||||
|
||||
drmModeModeInfo *modes;
|
||||
int n_modes;
|
||||
GList *modes;
|
||||
|
||||
uint32_t width_mm;
|
||||
uint32_t height_mm;
|
||||
|
30
src/backends/native/meta-kms-mode-private.h
Normal file
30
src/backends/native/meta-kms-mode-private.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 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_KMS_MODE_PRIVATE_H
|
||||
#define META_KMS_MODE_PRIVATE_H
|
||||
|
||||
#include "backends/native/meta-kms-mode.h"
|
||||
|
||||
void meta_kms_mode_free (MetaKmsMode *mode);
|
||||
|
||||
MetaKmsMode * meta_kms_mode_new (MetaKmsImplDevice *impl_device,
|
||||
const drmModeModeInfo *drm_mode);
|
||||
|
||||
#endif /* META_KMS_MODE_PRIVATE_H */
|
55
src/backends/native/meta-kms-mode.c
Normal file
55
src/backends/native/meta-kms-mode.c
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 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-kms-mode-private.h"
|
||||
|
||||
#include "backends/native/meta-kms-impl-device.h"
|
||||
|
||||
struct _MetaKmsMode
|
||||
{
|
||||
MetaKmsImplDevice *impl_device;
|
||||
drmModeModeInfo drm_mode;
|
||||
};
|
||||
|
||||
const drmModeModeInfo *
|
||||
meta_kms_mode_get_drm_mode (MetaKmsMode *mode)
|
||||
{
|
||||
return &mode->drm_mode;
|
||||
}
|
||||
|
||||
void
|
||||
meta_kms_mode_free (MetaKmsMode *mode)
|
||||
{
|
||||
g_free (mode);
|
||||
}
|
||||
|
||||
MetaKmsMode *
|
||||
meta_kms_mode_new (MetaKmsImplDevice *impl_device,
|
||||
const drmModeModeInfo *drm_mode)
|
||||
{
|
||||
MetaKmsMode *mode;
|
||||
|
||||
mode = g_new0 (MetaKmsMode, 1);
|
||||
mode->impl_device = impl_device;
|
||||
mode->drm_mode = *drm_mode;
|
||||
|
||||
return mode;
|
||||
}
|
31
src/backends/native/meta-kms-mode.h
Normal file
31
src/backends/native/meta-kms-mode.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 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_KMS_MODE_H
|
||||
#define META_KMS_MODE_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include "backends/native/meta-kms-types.h"
|
||||
|
||||
const drmModeModeInfo * meta_kms_mode_get_drm_mode (MetaKmsMode *mode);
|
||||
|
||||
#endif /* META_KMS_MODE_H */
|
@ -33,6 +33,8 @@ typedef struct _MetaKmsUpdate MetaKmsUpdate;
|
||||
typedef struct _MetaKmsPlaneAssignment MetaKmsPlaneAssignment;
|
||||
typedef struct _MetaKmsModeSet MetaKmsModeSet;
|
||||
|
||||
typedef struct _MetaKmsMode MetaKmsMode;
|
||||
|
||||
typedef struct _MetaKmsFeedback MetaKmsFeedback;
|
||||
|
||||
typedef struct _MetaKmsPageFlipFeedback MetaKmsPageFlipFeedback;
|
||||
|
@ -83,6 +83,12 @@
|
||||
* should be presented on a CRTC. Planes can either be primary planes, used as
|
||||
* a backdrop for CRTCs, overlay planes, and cursor planes.
|
||||
*
|
||||
* #MetaKmsMode:
|
||||
*
|
||||
* Represents a mode a CRTC and connector can be configured with.
|
||||
* Represents both modes directly derived from the devices, as well as
|
||||
* fall back modes when the CRTC supports scaling.
|
||||
*
|
||||
* #MetaKmsUpdate:
|
||||
*
|
||||
* A KMS transaction object, meant to be processed potentially atomically when
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "backends/meta-crtc.h"
|
||||
#include "backends/native/meta-kms-connector.h"
|
||||
#include "backends/native/meta-kms-mode.h"
|
||||
#include "backends/native/meta-kms-utils.h"
|
||||
#include "backends/native/meta-crtc-kms.h"
|
||||
#include "backends/native/meta-crtc-mode-kms.h"
|
||||
@ -240,17 +241,19 @@ init_output_modes (MetaOutputInfo *output_info,
|
||||
GError **error)
|
||||
{
|
||||
const MetaKmsConnectorState *connector_state;
|
||||
GList *l;
|
||||
int i;
|
||||
|
||||
connector_state = meta_kms_connector_get_current_state (kms_connector);
|
||||
|
||||
output_info->preferred_mode = NULL;
|
||||
|
||||
output_info->n_modes = connector_state->n_modes;
|
||||
output_info->n_modes = g_list_length (connector_state->modes);
|
||||
output_info->modes = g_new0 (MetaCrtcMode *, output_info->n_modes);
|
||||
for (i = 0; i < connector_state->n_modes; i++)
|
||||
for (l = connector_state->modes, i = 0; l; l = l->next, i++)
|
||||
{
|
||||
drmModeModeInfo *drm_mode = &connector_state->modes[i];
|
||||
MetaKmsMode *kms_mode = l->data;
|
||||
const drmModeModeInfo *drm_mode = meta_kms_mode_get_drm_mode (kms_mode);
|
||||
MetaCrtcMode *crtc_mode;
|
||||
|
||||
crtc_mode = meta_gpu_kms_get_mode_from_drm_mode (gpu_kms, drm_mode);
|
||||
|
@ -684,6 +684,8 @@ if have_native_backend
|
||||
'backends/native/meta-kms-impl-simple.h',
|
||||
'backends/native/meta-kms-impl.c',
|
||||
'backends/native/meta-kms-impl.h',
|
||||
'backends/native/meta-kms-mode.c',
|
||||
'backends/native/meta-kms-mode.h',
|
||||
'backends/native/meta-kms-page-flip.c',
|
||||
'backends/native/meta-kms-page-flip-private.h',
|
||||
'backends/native/meta-kms-plane.c',
|
||||
|
Loading…
Reference in New Issue
Block a user