kms/update: Make change updates to take MetaKmsMode

This will be needed for state keeping connected to turning mode infos
into blobs later used by the atomic modesetting implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
Jonas Ådahl 2020-07-02 15:58:59 +02:00 committed by Marge Bot
parent abac217617
commit 309651df6b
6 changed files with 31 additions and 24 deletions

View File

@ -176,7 +176,7 @@ meta_crtc_kms_set_mode (MetaCrtcKms *crtc_kms,
MetaCrtc *crtc = META_CRTC (crtc_kms);
MetaGpu *gpu = meta_crtc_get_gpu (crtc);
GList *connectors;
const drmModeModeInfo *mode;
MetaKmsMode *kms_mode;
connectors = generate_crtc_connector_list (gpu, crtc);
@ -184,17 +184,15 @@ meta_crtc_kms_set_mode (MetaCrtcKms *crtc_kms,
{
const MetaCrtcConfig *crtc_config = meta_crtc_get_config (crtc);
MetaCrtcModeKms *crtc_mode_kms = META_CRTC_MODE_KMS (crtc_config->mode);
MetaKmsMode *kms_mode;
kms_mode = meta_crtc_mode_kms_get_kms_mode (crtc_mode_kms);
mode = meta_kms_mode_get_drm_mode (kms_mode);
g_debug ("Setting CRTC (%" G_GUINT64_FORMAT ") mode to %s",
meta_crtc_get_id (crtc), mode->name);
meta_crtc_get_id (crtc), meta_kms_mode_get_name (kms_mode));
}
else
{
mode = NULL;
kms_mode = NULL;
g_debug ("Unsetting CRTC (%" G_GUINT64_FORMAT ") mode",
meta_crtc_get_id (crtc));
@ -203,7 +201,7 @@ meta_crtc_kms_set_mode (MetaCrtcKms *crtc_kms,
meta_kms_update_mode_set (kms_update,
meta_crtc_kms_get_kms_crtc (crtc_kms),
g_steal_pointer (&connectors),
mode);
kms_mode);
}
void

View File

@ -24,6 +24,7 @@
#include "backends/native/meta-kms-device-private.h"
#include "backends/native/meta-kms-impl-device.h"
#include "backends/native/meta-kms-mode.h"
#include "backends/native/meta-kms-update-private.h"
struct _MetaKmsCrtc
@ -168,17 +169,19 @@ meta_kms_crtc_predict_state (MetaKmsCrtc *crtc,
if (mode_set->crtc != crtc)
continue;
if (mode_set->drm_mode)
if (mode_set->mode)
{
MetaKmsPlaneAssignment *plane_assignment;
const drmModeModeInfo *drm_mode;
plane_assignment =
meta_kms_update_get_primary_plane_assignment (update, crtc);
drm_mode = meta_kms_mode_get_drm_mode (mode_set->mode);
crtc->current_state.rect =
meta_fixed_16_rectangle_to_rectangle (plane_assignment->src_rect);
crtc->current_state.is_drm_mode_valid = TRUE;
crtc->current_state.drm_mode = *mode_set->drm_mode;
crtc->current_state.drm_mode = *drm_mode;
}
else
{

View File

@ -29,6 +29,7 @@
#include "backends/native/meta-kms-connector.h"
#include "backends/native/meta-kms-crtc.h"
#include "backends/native/meta-kms-device-private.h"
#include "backends/native/meta-kms-mode.h"
#include "backends/native/meta-kms-page-flip-private.h"
#include "backends/native/meta-kms-plane.h"
#include "backends/native/meta-kms-private.h"
@ -192,6 +193,7 @@ process_mode_set (MetaKmsImpl *impl,
g_autofree uint32_t *connectors = NULL;
int n_connectors;
MetaKmsPlaneAssignment *plane_assignment;
drmModeModeInfo *drm_mode;
uint32_t x, y;
uint32_t fb_id;
int fd;
@ -199,10 +201,13 @@ process_mode_set (MetaKmsImpl *impl,
crtc = mode_set->crtc;
if (mode_set->drm_mode)
if (mode_set->mode)
{
GList *l;
drm_mode = g_alloca (sizeof *drm_mode);
*drm_mode = *meta_kms_mode_get_drm_mode (mode_set->mode);
fill_connector_ids_array (mode_set->connectors,
&connectors,
&n_connectors);
@ -233,6 +238,7 @@ process_mode_set (MetaKmsImpl *impl,
}
else
{
drm_mode = NULL;
x = y = 0;
n_connectors = 0;
connectors = NULL;
@ -245,23 +251,23 @@ process_mode_set (MetaKmsImpl *impl,
fb_id,
x, y,
connectors, n_connectors,
mode_set->drm_mode);
drm_mode);
if (ret != 0)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret),
"Failed to set mode %s on CRTC %u: %s",
mode_set->drm_mode ? mode_set->drm_mode->name : "off",
drm_mode ? drm_mode->name : "off",
meta_kms_crtc_get_id (crtc),
g_strerror (-ret));
return FALSE;
}
if (mode_set->drm_mode)
if (drm_mode)
{
g_hash_table_replace (impl_simple->cached_mode_sets,
crtc,
cached_mode_set_new (mode_set->connectors,
mode_set->drm_mode));
drm_mode));
}
else
{

View File

@ -63,7 +63,7 @@ typedef struct _MetaKmsModeSet
{
MetaKmsCrtc *crtc;
GList *connectors;
drmModeModeInfo *drm_mode;
MetaKmsMode *mode;
} MetaKmsModeSet;
typedef struct _MetaKmsConnectorProperty

View File

@ -23,6 +23,7 @@
#include "backends/native/meta-kms-update-private.h"
#include "backends/meta-display-config-shared.h"
#include "backends/native/meta-kms-mode-private.h"
#include "backends/native/meta-kms-plane.h"
struct _MetaKmsUpdate
@ -149,7 +150,6 @@ meta_kms_plane_assignment_free (MetaKmsPlaneAssignment *plane_assignment)
static void
meta_kms_mode_set_free (MetaKmsModeSet *mode_set)
{
g_free (mode_set->drm_mode);
g_list_free (mode_set->connectors);
g_free (mode_set);
}
@ -211,7 +211,7 @@ void
meta_kms_update_mode_set (MetaKmsUpdate *update,
MetaKmsCrtc *crtc,
GList *connectors,
const drmModeModeInfo *drm_mode)
MetaKmsMode *mode)
{
MetaKmsModeSet *mode_set;
@ -221,7 +221,7 @@ meta_kms_update_mode_set (MetaKmsUpdate *update,
*mode_set = (MetaKmsModeSet) {
.crtc = crtc,
.connectors = connectors,
.drm_mode = drm_mode ? g_memdup (drm_mode, sizeof *drm_mode) : NULL,
.mode = mode,
};
update->mode_sets = g_list_prepend (update->mode_sets, mode_set);

View File

@ -88,7 +88,7 @@ void meta_kms_update_free (MetaKmsUpdate *update);
void meta_kms_update_mode_set (MetaKmsUpdate *update,
MetaKmsCrtc *crtc,
GList *connectors,
const drmModeModeInfo *drm_mode);
MetaKmsMode *mode);
MetaKmsPlaneAssignment * meta_kms_update_assign_plane (MetaKmsUpdate *update,
MetaKmsCrtc *crtc,