[mutter] renderer/native: Get 'uses-monotonic' state from MetaKmsDevice
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] renderer/native: Get 'uses-monotonic' state from MetaKmsDevice
- Date: Wed, 7 Jul 2021 19:45:13 +0000 (UTC)
commit e567cb972d2eb3c69a015b78886e94e5949707ea
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon Mar 29 11:56:49 2021 +0200
renderer/native: Get 'uses-monotonic' state from MetaKmsDevice
It's better suited to be handled by the MetaKmsDevice abstraction.
This eliminates the last caller of drmGetCaps() from outside
MetaKmsImplDevice.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
src/backends/native/meta-gpu-kms.c | 20 --------------------
src/backends/native/meta-gpu-kms.h | 2 --
src/backends/native/meta-kms-device.c | 6 ++++++
src/backends/native/meta-kms-device.h | 2 ++
src/backends/native/meta-kms-impl-device.c | 6 ++++++
src/backends/native/meta-kms-impl-device.h | 1 +
src/backends/native/meta-onscreen-native.c | 9 ++++-----
7 files changed, 19 insertions(+), 27 deletions(-)
---
diff --git a/src/backends/native/meta-gpu-kms.c b/src/backends/native/meta-gpu-kms.c
index e81c90a022..6c0342113c 100644
--- a/src/backends/native/meta-gpu-kms.c
+++ b/src/backends/native/meta-gpu-kms.c
@@ -57,8 +57,6 @@ struct _MetaGpuKms
uint32_t id;
int fd;
- clockid_t clock_id;
-
gboolean resources_init_failed_before;
};
@@ -124,12 +122,6 @@ meta_gpu_kms_get_file_path (MetaGpuKms *gpu_kms)
return meta_kms_device_get_path (gpu_kms->kms_device);
}
-gboolean
-meta_gpu_kms_is_clock_monotonic (MetaGpuKms *gpu_kms)
-{
- return gpu_kms->clock_id == CLOCK_MONOTONIC;
-}
-
gboolean
meta_gpu_kms_is_boot_vga (MetaGpuKms *gpu_kms)
{
@@ -316,17 +308,6 @@ init_crtcs (MetaGpuKms *gpu_kms)
meta_gpu_take_crtcs (gpu, crtcs);
}
-static void
-init_frame_clock (MetaGpuKms *gpu_kms)
-{
- uint64_t uses_monotonic;
-
- if (drmGetCap (gpu_kms->fd, DRM_CAP_TIMESTAMP_MONOTONIC, &uses_monotonic) != 0)
- uses_monotonic = 0;
-
- gpu_kms->clock_id = uses_monotonic ? CLOCK_MONOTONIC : CLOCK_REALTIME;
-}
-
static void
init_outputs (MetaGpuKms *gpu_kms)
{
@@ -391,7 +372,6 @@ meta_gpu_kms_read_current (MetaGpu *gpu,
init_modes (gpu_kms);
init_crtcs (gpu_kms);
init_outputs (gpu_kms);
- init_frame_clock (gpu_kms);
return TRUE;
}
diff --git a/src/backends/native/meta-gpu-kms.h b/src/backends/native/meta-gpu-kms.h
index f13a141f49..051ea374ae 100644
--- a/src/backends/native/meta-gpu-kms.h
+++ b/src/backends/native/meta-gpu-kms.h
@@ -57,8 +57,6 @@ uint32_t meta_gpu_kms_get_id (MetaGpuKms *gpu_kms);
const char * meta_gpu_kms_get_file_path (MetaGpuKms *gpu_kms);
-gboolean meta_gpu_kms_is_clock_monotonic (MetaGpuKms *gpu_kms);
-
void meta_gpu_kms_set_power_save_mode (MetaGpuKms *gpu_kms,
uint64_t state,
MetaKmsUpdate *kms_update);
diff --git a/src/backends/native/meta-kms-device.c b/src/backends/native/meta-kms-device.c
index 49516bde64..d958e0be6d 100644
--- a/src/backends/native/meta-kms-device.c
+++ b/src/backends/native/meta-kms-device.c
@@ -127,6 +127,12 @@ meta_kms_device_prefers_shadow_buffer (MetaKmsDevice *device)
return device->caps.prefers_shadow_buffer;
}
+gboolean
+meta_kms_device_uses_monotonic_clock (MetaKmsDevice *device)
+{
+ return device->caps.uses_monotonic_clock;
+}
+
GList *
meta_kms_device_get_connectors (MetaKmsDevice *device)
{
diff --git a/src/backends/native/meta-kms-device.h b/src/backends/native/meta-kms-device.h
index c8bf948435..c5e734a4c1 100644
--- a/src/backends/native/meta-kms-device.h
+++ b/src/backends/native/meta-kms-device.h
@@ -47,6 +47,8 @@ gboolean meta_kms_device_get_cursor_size (MetaKmsDevice *device,
gboolean meta_kms_device_prefers_shadow_buffer (MetaKmsDevice *device);
+gboolean meta_kms_device_uses_monotonic_clock (MetaKmsDevice *device);
+
GList * meta_kms_device_get_connectors (MetaKmsDevice *device);
GList * meta_kms_device_get_crtcs (MetaKmsDevice *device);
diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c
index 4194b9ffa2..dbc6c57dec 100644
--- a/src/backends/native/meta-kms-impl-device.c
+++ b/src/backends/native/meta-kms-impl-device.c
@@ -301,6 +301,7 @@ init_caps (MetaKmsImplDevice *impl_device)
int fd;
uint64_t cursor_width, cursor_height;
uint64_t prefer_shadow;
+ uint64_t uses_monotonic_clock;
fd = meta_device_file_get_fd (priv->device_file);
if (drmGetCap (fd, DRM_CAP_CURSOR_WIDTH, &cursor_width) == 0 &&
@@ -318,6 +319,11 @@ init_caps (MetaKmsImplDevice *impl_device)
priv->caps.prefers_shadow_buffer = prefer_shadow;
}
+
+ if (drmGetCap (fd, DRM_CAP_TIMESTAMP_MONOTONIC, &uses_monotonic_clock) == 0)
+ {
+ priv->caps.uses_monotonic_clock = uses_monotonic_clock;
+ }
}
static void
diff --git a/src/backends/native/meta-kms-impl-device.h b/src/backends/native/meta-kms-impl-device.h
index 9e20705273..4256cc20bd 100644
--- a/src/backends/native/meta-kms-impl-device.h
+++ b/src/backends/native/meta-kms-impl-device.h
@@ -39,6 +39,7 @@ typedef struct _MetaKmsDeviceCaps
uint64_t cursor_height;
gboolean prefers_shadow_buffer;
+ gboolean uses_monotonic_clock;
} MetaKmsDeviceCaps;
typedef struct _MetaKmsProp MetaKmsProp;
diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c
index 02cd5da2e8..016533df7a 100644
--- a/src/backends/native/meta-onscreen-native.c
+++ b/src/backends/native/meta-onscreen-native.c
@@ -38,6 +38,7 @@
#include "backends/native/meta-drm-buffer-gbm.h"
#include "backends/native/meta-drm-buffer-import.h"
#include "backends/native/meta-drm-buffer.h"
+#include "backends/native/meta-kms-device.h"
#include "backends/native/meta-kms-utils.h"
#include "backends/native/meta-kms.h"
#include "backends/native/meta-output-kms.h"
@@ -246,8 +247,7 @@ page_flip_feedback_flipped (MetaKmsCrtc *kms_crtc,
{
MetaRendererView *view = user_data;
struct timeval page_flip_time;
- MetaCrtc *crtc;
- MetaGpuKms *gpu_kms;
+ MetaKmsDevice *kms_device;
int64_t presentation_time_us;
CoglFrameInfoFlag flags = COGL_FRAME_INFO_FLAG_VSYNC;
@@ -256,9 +256,8 @@ page_flip_feedback_flipped (MetaKmsCrtc *kms_crtc,
.tv_usec = tv_usec,
};
- crtc = META_CRTC (meta_crtc_kms_from_kms_crtc (kms_crtc));
- gpu_kms = META_GPU_KMS (meta_crtc_get_gpu (crtc));
- if (meta_gpu_kms_is_clock_monotonic (gpu_kms))
+ kms_device = meta_kms_crtc_get_device (kms_crtc);
+ if (meta_kms_device_uses_monotonic_clock (kms_device))
{
presentation_time_us = timeval_to_microseconds (&page_flip_time);
flags |= COGL_FRAME_INFO_FLAG_HW_CLOCK;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]