2017-07-04 00:11:44 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2013-2017 Red Hat
|
2018-10-11 10:15:37 -04:00
|
|
|
* Copyright (C) 2018 DisplayLink (UK) Ltd.
|
2017-07-04 00:11:44 -04:00
|
|
|
*
|
|
|
|
* 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-output-kms.h"
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "backends/meta-crtc.h"
|
2019-03-08 10:23:15 -05:00
|
|
|
#include "backends/native/meta-kms-connector.h"
|
2019-03-11 06:13:01 -04:00
|
|
|
#include "backends/native/meta-kms-utils.h"
|
2017-07-04 04:04:39 -04:00
|
|
|
#include "backends/native/meta-crtc-kms.h"
|
2018-07-07 09:28:41 -04:00
|
|
|
|
|
|
|
#include "meta-default-modes.h"
|
2017-07-04 00:11:44 -04:00
|
|
|
|
|
|
|
#define SYNC_TOLERANCE 0.01 /* 1 percent */
|
|
|
|
|
|
|
|
typedef struct _MetaOutputKms
|
|
|
|
{
|
|
|
|
MetaOutput parent;
|
|
|
|
|
2019-03-08 10:23:15 -05:00
|
|
|
MetaKmsConnector *kms_connector;
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
} MetaOutputKms;
|
2019-03-08 10:23:15 -05:00
|
|
|
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
MetaKmsConnector *
|
|
|
|
meta_output_kms_get_kms_connector (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputKms *output_kms = output->driver_private;
|
2017-07-04 00:11:44 -04:00
|
|
|
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
return output_kms->kms_connector;
|
|
|
|
}
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2017-07-04 04:04:39 -04:00
|
|
|
void
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
meta_output_kms_set_underscan (MetaOutput *output,
|
|
|
|
MetaKmsUpdate *kms_update)
|
2017-07-04 04:04:39 -04:00
|
|
|
{
|
2019-03-26 05:09:45 -04:00
|
|
|
MetaOutputKms *output_kms = output->driver_private;
|
2017-11-03 06:25:30 -04:00
|
|
|
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
if (!output->supports_underscanning)
|
2017-07-04 04:04:39 -04:00
|
|
|
return;
|
|
|
|
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
if (output->is_underscanning)
|
2019-03-26 05:09:45 -04:00
|
|
|
{
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
MetaCrtc *crtc;
|
2020-01-14 16:34:44 -05:00
|
|
|
MetaCrtcConfig *crtc_config;
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
uint64_t hborder, vborder;
|
|
|
|
|
|
|
|
crtc = meta_output_get_assigned_crtc (output);
|
2020-01-14 16:34:44 -05:00
|
|
|
crtc_config = crtc->config;
|
|
|
|
hborder = MIN (128, (uint64_t) round (crtc_config->mode->width * 0.05));
|
|
|
|
vborder = MIN (128, (uint64_t) round (crtc_config->mode->height * 0.05));
|
2019-04-26 03:53:25 -04:00
|
|
|
|
2019-09-06 05:49:48 -04:00
|
|
|
g_debug ("Setting underscan of connector %s to %" G_GUINT64_FORMAT " x %" G_GUINT64_FORMAT,
|
2019-04-26 03:53:25 -04:00
|
|
|
meta_kms_connector_get_name (output_kms->kms_connector),
|
|
|
|
hborder, vborder);
|
|
|
|
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
meta_kms_connector_set_underscanning (output_kms->kms_connector,
|
|
|
|
kms_update,
|
|
|
|
hborder,
|
|
|
|
vborder);
|
2019-03-26 05:09:45 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-26 03:53:25 -04:00
|
|
|
g_debug ("Unsetting underscan of connector %s",
|
|
|
|
meta_kms_connector_get_name (output_kms->kms_connector));
|
|
|
|
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
meta_kms_connector_unset_underscanning (output_kms->kms_connector,
|
|
|
|
kms_update);
|
2019-03-26 05:09:45 -04:00
|
|
|
}
|
2017-07-04 04:04:39 -04:00
|
|
|
}
|
|
|
|
|
2018-10-11 10:15:37 -04:00
|
|
|
uint32_t
|
|
|
|
meta_output_kms_get_connector_id (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputKms *output_kms = output->driver_private;
|
|
|
|
|
2019-03-08 10:23:15 -05:00
|
|
|
return meta_kms_connector_get_id (output_kms->kms_connector);
|
2018-10-11 10:15:37 -04:00
|
|
|
}
|
|
|
|
|
2017-07-04 00:11:44 -04:00
|
|
|
void
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
meta_output_kms_set_power_save_mode (MetaOutput *output,
|
|
|
|
uint64_t dpms_state,
|
|
|
|
MetaKmsUpdate *kms_update)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
|
|
|
MetaOutputKms *output_kms = output->driver_private;
|
|
|
|
|
2019-09-06 05:49:48 -04:00
|
|
|
g_debug ("Setting DPMS state of connector %s to %" G_GUINT64_FORMAT,
|
2019-04-26 03:53:25 -04:00
|
|
|
meta_kms_connector_get_name (output_kms->kms_connector),
|
|
|
|
dpms_state);
|
|
|
|
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
meta_kms_connector_update_set_dpms_state (output_kms->kms_connector,
|
|
|
|
kms_update,
|
|
|
|
dpms_state);
|
2017-07-04 00:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_output_kms_can_clone (MetaOutput *output,
|
|
|
|
MetaOutput *other_output)
|
|
|
|
{
|
|
|
|
MetaOutputKms *output_kms = output->driver_private;
|
|
|
|
MetaOutputKms *other_output_kms = other_output->driver_private;
|
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
return meta_kms_connector_can_clone (output_kms->kms_connector,
|
|
|
|
other_output_kms->kms_connector);
|
2017-07-04 00:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GBytes *
|
|
|
|
meta_output_kms_read_edid (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputKms *output_kms = output->driver_private;
|
2019-03-09 09:55:24 -05:00
|
|
|
const MetaKmsConnectorState *connector_state;
|
|
|
|
GBytes *edid_data;
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
connector_state =
|
|
|
|
meta_kms_connector_get_current_state (output_kms->kms_connector);
|
|
|
|
edid_data = connector_state->edid_data;
|
|
|
|
if (!edid_data)
|
2017-07-04 00:11:44 -04:00
|
|
|
return NULL;
|
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
return g_bytes_new_from_bytes (edid_data, 0, g_bytes_get_size (edid_data));
|
2017-07-04 00:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_output_destroy_notify (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputKms *output_kms;
|
|
|
|
|
|
|
|
output_kms = output->driver_private;
|
|
|
|
|
|
|
|
g_slice_free (MetaOutputKms, output_kms);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-07-10 06:19:32 -04:00
|
|
|
add_common_modes (MetaOutput *output,
|
|
|
|
MetaGpuKms *gpu_kms)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
2017-10-24 09:47:30 -04:00
|
|
|
const drmModeModeInfo *drm_mode;
|
|
|
|
MetaCrtcMode *crtc_mode;
|
2017-07-04 00:11:44 -04:00
|
|
|
GPtrArray *array;
|
2017-10-24 09:47:30 -04:00
|
|
|
float refresh_rate;
|
2017-07-04 00:11:44 -04:00
|
|
|
unsigned i;
|
|
|
|
unsigned max_hdisplay = 0;
|
|
|
|
unsigned max_vdisplay = 0;
|
|
|
|
float max_refresh_rate = 0.0;
|
|
|
|
|
|
|
|
for (i = 0; i < output->n_modes; i++)
|
|
|
|
{
|
|
|
|
drm_mode = output->modes[i]->driver_private;
|
|
|
|
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);
|
|
|
|
max_refresh_rate = MAX (max_refresh_rate, refresh_rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
max_refresh_rate = MAX (max_refresh_rate, 60.0);
|
|
|
|
max_refresh_rate *= (1 + SYNC_TOLERANCE);
|
|
|
|
|
|
|
|
array = g_ptr_array_new ();
|
2017-10-24 09:47:30 -04:00
|
|
|
if (max_hdisplay > max_vdisplay)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
2017-10-24 09:47:30 -04:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (meta_default_landscape_drm_mode_infos); i++)
|
|
|
|
{
|
|
|
|
drm_mode = &meta_default_landscape_drm_mode_infos[i];
|
|
|
|
refresh_rate = meta_calculate_drm_mode_refresh_rate (drm_mode);
|
|
|
|
if (drm_mode->hdisplay > max_hdisplay ||
|
|
|
|
drm_mode->vdisplay > max_vdisplay ||
|
|
|
|
refresh_rate > max_refresh_rate)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
crtc_mode = meta_gpu_kms_get_mode_from_drm_mode (gpu_kms,
|
|
|
|
drm_mode);
|
|
|
|
g_ptr_array_add (array, crtc_mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (meta_default_portrait_drm_mode_infos); i++)
|
|
|
|
{
|
|
|
|
drm_mode = &meta_default_portrait_drm_mode_infos[i];
|
|
|
|
refresh_rate = meta_calculate_drm_mode_refresh_rate (drm_mode);
|
|
|
|
if (drm_mode->hdisplay > max_hdisplay ||
|
|
|
|
drm_mode->vdisplay > max_vdisplay ||
|
|
|
|
refresh_rate > max_refresh_rate)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
crtc_mode = meta_gpu_kms_get_mode_from_drm_mode (gpu_kms,
|
|
|
|
drm_mode);
|
|
|
|
g_ptr_array_add (array, crtc_mode);
|
|
|
|
}
|
2017-07-04 00:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
output->modes = g_renew (MetaCrtcMode *, output->modes,
|
|
|
|
output->n_modes + array->len);
|
|
|
|
memcpy (output->modes + output->n_modes, array->pdata,
|
|
|
|
array->len * sizeof (MetaCrtcMode *));
|
|
|
|
output->n_modes += array->len;
|
|
|
|
|
|
|
|
g_ptr_array_free (array, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
compare_modes (const void *one,
|
|
|
|
const void *two)
|
|
|
|
{
|
|
|
|
MetaCrtcMode *a = *(MetaCrtcMode **) one;
|
|
|
|
MetaCrtcMode *b = *(MetaCrtcMode **) two;
|
|
|
|
|
|
|
|
if (a->width != b->width)
|
|
|
|
return a->width > b->width ? -1 : 1;
|
|
|
|
if (a->height != b->height)
|
|
|
|
return a->height > b->height ? -1 : 1;
|
|
|
|
if (a->refresh_rate != b->refresh_rate)
|
|
|
|
return a->refresh_rate > b->refresh_rate ? -1 : 1;
|
|
|
|
|
|
|
|
return g_strcmp0 (b->name, a->name);
|
|
|
|
}
|
|
|
|
|
2017-11-03 03:55:07 -04:00
|
|
|
static gboolean
|
|
|
|
init_output_modes (MetaOutput *output,
|
|
|
|
MetaGpuKms *gpu_kms,
|
|
|
|
GError **error)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
|
|
|
MetaOutputKms *output_kms = output->driver_private;
|
2019-03-09 09:55:24 -05:00
|
|
|
const MetaKmsConnectorState *connector_state;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
connector_state =
|
|
|
|
meta_kms_connector_get_current_state (output_kms->kms_connector);
|
2017-07-04 00:11:44 -04:00
|
|
|
|
|
|
|
output->preferred_mode = NULL;
|
2019-03-09 09:55:24 -05:00
|
|
|
|
|
|
|
output->n_modes = connector_state->n_modes;
|
2017-07-04 00:11:44 -04:00
|
|
|
output->modes = g_new0 (MetaCrtcMode *, output->n_modes);
|
2019-03-09 09:55:24 -05:00
|
|
|
for (i = 0; i < connector_state->n_modes; i++)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
2019-03-09 09:55:24 -05:00
|
|
|
drmModeModeInfo *drm_mode = &connector_state->modes[i];
|
2017-07-04 00:11:44 -04:00
|
|
|
MetaCrtcMode *crtc_mode;
|
|
|
|
|
2017-07-10 06:19:32 -04:00
|
|
|
crtc_mode = meta_gpu_kms_get_mode_from_drm_mode (gpu_kms, drm_mode);
|
2017-07-04 00:11:44 -04:00
|
|
|
output->modes[i] = crtc_mode;
|
2019-03-09 09:55:24 -05:00
|
|
|
if (drm_mode->type & DRM_MODE_TYPE_PREFERRED)
|
2017-07-04 00:11:44 -04:00
|
|
|
output->preferred_mode = output->modes[i];
|
|
|
|
}
|
|
|
|
|
2017-11-03 03:55:07 -04:00
|
|
|
/* FIXME: MSC feature bit? */
|
|
|
|
/* Presume that if the output supports scaling, then we have
|
|
|
|
* a panel fitter capable of adjusting any mode to suit.
|
|
|
|
*/
|
2019-03-09 09:55:24 -05:00
|
|
|
if (connector_state->has_scaling)
|
2017-11-03 03:55:07 -04:00
|
|
|
add_common_modes (output, gpu_kms);
|
|
|
|
|
|
|
|
if (!output->modes)
|
|
|
|
{
|
|
|
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
|
|
"No modes available");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort (output->modes, output->n_modes,
|
|
|
|
sizeof (MetaCrtcMode *), compare_modes);
|
|
|
|
|
2017-07-04 00:11:44 -04:00
|
|
|
if (!output->preferred_mode)
|
|
|
|
output->preferred_mode = output->modes[0];
|
2017-11-03 03:55:07 -04:00
|
|
|
|
|
|
|
return TRUE;
|
2017-07-04 00:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaOutput *
|
2017-11-03 03:55:07 -04:00
|
|
|
meta_create_kms_output (MetaGpuKms *gpu_kms,
|
2019-03-08 10:23:15 -05:00
|
|
|
MetaKmsConnector *kms_connector,
|
2017-11-03 03:55:07 -04:00
|
|
|
MetaOutput *old_output,
|
|
|
|
GError **error)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
2017-07-10 06:19:32 -04:00
|
|
|
MetaGpu *gpu = META_GPU (gpu_kms);
|
2017-07-04 00:11:44 -04:00
|
|
|
MetaOutput *output;
|
|
|
|
MetaOutputKms *output_kms;
|
2019-03-09 09:55:24 -05:00
|
|
|
const MetaKmsConnectorState *connector_state;
|
2019-03-08 10:23:15 -05:00
|
|
|
uint32_t connector_id;
|
2017-07-04 00:11:44 -04:00
|
|
|
GArray *crtcs;
|
|
|
|
GList *l;
|
2019-03-08 10:23:15 -05:00
|
|
|
uint32_t gpu_id;
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2020-02-25 04:54:40 -05:00
|
|
|
output = g_object_new (META_TYPE_OUTPUT,
|
|
|
|
"gpu", gpu,
|
|
|
|
NULL);
|
2017-07-04 00:11:44 -04:00
|
|
|
|
|
|
|
output_kms = g_slice_new0 (MetaOutputKms);
|
|
|
|
output->driver_private = output_kms;
|
|
|
|
output->driver_notify = (GDestroyNotify) meta_output_destroy_notify;
|
|
|
|
|
2019-03-08 10:23:15 -05:00
|
|
|
output->name = g_strdup (meta_kms_connector_get_name (kms_connector));
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2019-03-08 10:23:15 -05:00
|
|
|
gpu_id = meta_gpu_kms_get_id (gpu_kms);
|
|
|
|
connector_id = meta_kms_connector_get_id (kms_connector);
|
|
|
|
output->winsys_id = ((uint64_t) gpu_id << 32) | connector_id;
|
2018-10-11 10:20:00 -04:00
|
|
|
|
2019-03-08 10:23:15 -05:00
|
|
|
output_kms->kms_connector = kms_connector;
|
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
connector_state = meta_kms_connector_get_current_state (kms_connector);
|
|
|
|
|
2019-11-10 10:50:36 -05:00
|
|
|
output->panel_orientation_transform =
|
|
|
|
connector_state->panel_orientation_transform;
|
|
|
|
if (meta_monitor_transform_is_rotated (output->panel_orientation_transform))
|
2017-10-25 09:44:10 -04:00
|
|
|
{
|
2019-03-09 09:55:24 -05:00
|
|
|
output->width_mm = connector_state->height_mm;
|
|
|
|
output->height_mm = connector_state->width_mm;
|
2017-10-25 09:44:10 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-09 09:55:24 -05:00
|
|
|
output->width_mm = connector_state->width_mm;
|
|
|
|
output->height_mm = connector_state->height_mm;
|
2017-10-25 09:44:10 -04:00
|
|
|
}
|
|
|
|
|
2017-11-03 03:55:07 -04:00
|
|
|
if (!init_output_modes (output, gpu_kms, error))
|
|
|
|
{
|
|
|
|
g_object_unref (output);
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
crtcs = g_array_new (FALSE, FALSE, sizeof (MetaCrtc *));
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
for (l = meta_gpu_get_crtcs (gpu); l; l = l->next)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
2019-03-09 09:55:24 -05:00
|
|
|
MetaCrtc *crtc = l->data;
|
|
|
|
MetaKmsCrtc *kms_crtc = meta_crtc_kms_get_kms_crtc (crtc);
|
|
|
|
uint32_t crtc_idx;
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
crtc_idx = meta_kms_crtc_get_idx (kms_crtc);
|
|
|
|
if (connector_state->common_possible_crtcs & (1 << crtc_idx))
|
|
|
|
g_array_append_val (crtcs, crtc);
|
2017-07-04 00:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
output->n_possible_crtcs = crtcs->len;
|
2019-03-09 09:55:24 -05:00
|
|
|
output->possible_crtcs = (MetaCrtc **) g_array_free (crtcs, FALSE);
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
if (connector_state->current_crtc_id)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
2017-07-10 06:19:32 -04:00
|
|
|
for (l = meta_gpu_get_crtcs (gpu); l; l = l->next)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
|
|
|
MetaCrtc *crtc = l->data;
|
|
|
|
|
2020-02-25 05:34:43 -05:00
|
|
|
if (meta_crtc_get_id (crtc) == connector_state->current_crtc_id)
|
2017-07-04 00:11:44 -04:00
|
|
|
{
|
2017-11-03 06:25:30 -04:00
|
|
|
meta_output_assign_crtc (output, crtc);
|
2017-07-04 00:11:44 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-03 06:25:30 -04:00
|
|
|
meta_output_unassign_crtc (output);
|
2017-07-04 00:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (old_output)
|
|
|
|
{
|
|
|
|
output->is_primary = old_output->is_primary;
|
|
|
|
output->is_presentation = old_output->is_presentation;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
output->is_primary = FALSE;
|
|
|
|
output->is_presentation = FALSE;
|
|
|
|
}
|
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
output->suggested_x = connector_state->suggested_x;
|
|
|
|
output->suggested_y = connector_state->suggested_y;
|
|
|
|
output->hotplug_mode_update = connector_state->hotplug_mode_update;
|
backend/native: Add and use transactional KMS API
This commit introduces, and makes use of, a transactional API used for
setting up KMS state, later to be applied, potentially atomically. From
an API point of view, so is always the case, but in the current
implementation, it still uses legacy drmMode* API to apply the state
non-atomically.
The API consists of various buliding blocks:
* MetaKmsUpdate - a set of configuration changes, the higher level
handle for handing over configuration to the impl backend. It's used to
set mode, assign framebuffers to planes, queue page flips and set
connector properties.
* MetaKmsPlaneAssignment - the assignment of a framebuffer to a plane.
Currently used to map a framebuffer to the primary plane of a CRTC. In
the legacy KMS implementation, the plane assignment is used to derive
the framebuffer used for mode setting and page flipping.
This also means various high level changes:
State, excluding configuring the cursor plane and creating/destroying
DRM framebuffer handles, are applied in the end of a clutter frame, in
one go. From an API point of view, this is done atomically, but as
mentioned, only the non-atomic implementation exists so far.
From MetaRendererNative's point of view, a page flip now initially
always succeeds; the handling of EBUSY errors are done asynchronously in
the MetaKmsImpl backend (still by retrying at refresh rate, but
postponing flip callbacks instead of manipulating the frame clock).
Handling of falling back to mode setting instead of page flipping is
notified after the fact by a more precise page flip feedback API.
EGLStream based page flipping relies on the impl backend not being
atomic, as the page flipping is done in the EGLStream backend (e.g.
nvidia driver). It uses a 'custom' page flip queueing method, keeping
the EGLStream logic inside meta-renderer-native.c.
Page flip handling is moved to meta-kms-impl-device.c from
meta-gpu-kms.c. It goes via an extra idle callback before reaching
meta-renderer-native.c to make sure callbacks are invoked outside of the
impl context.
While dummy power save page flipping is kept in meta-renderer-native.c, the
EBUSY handling is moved to meta-kms-impl-simple.c. Instead of freezing the
frame clock, actual page flip callbacks are postponed until all EBUSY retries
have either succeeded or failed due to some other error than EBUSY. This
effectively inhibits new frames to be drawn, meaning we won't stall waiting on
the file descriptor for pending page flips.
https://gitlab.gnome.org/GNOME/mutter/issues/548
https://gitlab.gnome.org/GNOME/mutter/merge_requests/525
2019-04-04 16:36:41 -04:00
|
|
|
output->supports_underscanning =
|
|
|
|
meta_kms_connector_is_underscanning_supported (kms_connector);
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
meta_output_parse_edid (output, connector_state->edid_data);
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2019-03-08 10:23:15 -05:00
|
|
|
output->connector_type = meta_kms_connector_get_connector_type (kms_connector);
|
2017-07-04 00:11:44 -04:00
|
|
|
|
2019-03-09 09:55:24 -05:00
|
|
|
output->tile_info = connector_state->tile_info;
|
2017-07-04 00:11:44 -04:00
|
|
|
|
|
|
|
/* FIXME: backlight is a very driver specific thing unfortunately,
|
|
|
|
every DDX does its own thing, and the dumb KMS API does not include it.
|
|
|
|
|
|
|
|
For example, xf86-video-intel has a list of paths to probe in /sys/class/backlight
|
|
|
|
(one for each major HW maker, and then some).
|
|
|
|
We can't do the same because we're not root.
|
|
|
|
It might be best to leave backlight out of the story and rely on the setuid
|
|
|
|
helper in gnome-settings-daemon.
|
|
|
|
*/
|
|
|
|
output->backlight_min = 0;
|
|
|
|
output->backlight_max = 0;
|
|
|
|
output->backlight = -1;
|
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|