mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
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>
This commit is contained in:
parent
86c4369f41
commit
e567cb972d
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -39,6 +39,7 @@ typedef struct _MetaKmsDeviceCaps
|
||||
uint64_t cursor_height;
|
||||
|
||||
gboolean prefers_shadow_buffer;
|
||||
gboolean uses_monotonic_clock;
|
||||
} MetaKmsDeviceCaps;
|
||||
|
||||
typedef struct _MetaKmsProp MetaKmsProp;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user