summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Kindestam <antonki@kth.se>2018-06-28 15:23:19 +0200
committersfan5 <sfan5@live.de>2019-05-04 14:17:11 +0200
commita776628d88cb6dab677ba8977d54861d24571c69 (patch)
treeade431e9ed65e686f9a3e44f873ef4875598e46e
parent23a324215b5aa9ea66a5d19fe7c5322c871eda64 (diff)
downloadmpv-a776628d88cb6dab677ba8977d54861d24571c69.tar.bz2
mpv-a776628d88cb6dab677ba8977d54861d24571c69.tar.xz
drm_common: Add option to toggle use of atomic modesetting
It is useful when debugging to be able to force atomic off, or as a workaround if atomic breaks for some user. Legacy modesetting is less likely to break by virtue of being a less complex API.
-rw-r--r--DOCS/man/vo.rst10
-rw-r--r--video/out/drm_common.c14
-rw-r--r--video/out/drm_common.h4
-rw-r--r--video/out/opengl/context_drm_egl.c3
-rw-r--r--video/out/vo_drm.c9
5 files changed, 29 insertions, 11 deletions
diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst
index 69e4341b44..a735dbc059 100644
--- a/DOCS/man/vo.rst
+++ b/DOCS/man/vo.rst
@@ -488,6 +488,16 @@ Available video output drivers are:
Mode ID to use (resolution and frame rate).
(default: 0)
+ ``--drm-atomic=<no|auto>``
+ Toggle use of atomic modesetting. Mostly useful for debugging.
+
+ :no: Use legacy modesetting.
+ :auto: Use atomic modesetting, falling back to legacy modesetting if
+ not available. (default)
+
+ Note: Only affects ``gpu-context=drm``. ``vo=drm`` supports legacy
+ modesetting only.
+
``--drm-draw-plane=<primary|overlay|N>``
Select the DRM plane to which video and OSD is drawn to, under normal
circumstances. The plane can be specified as ``primary``, which will
diff --git a/video/out/drm_common.c b/video/out/drm_common.c
index 2971d77094..36e72b3b9a 100644
--- a/video/out/drm_common.c
+++ b/video/out/drm_common.c
@@ -48,6 +48,9 @@ const struct m_sub_options drm_conf = {
OPT_STRING_VALIDATE("drm-connector", drm_connector_spec,
0, drm_validate_connector_opt),
OPT_INT("drm-mode", drm_mode_id, 0),
+ OPT_CHOICE("drm-atomic", drm_atomic, 0,
+ ({"no", 0},
+ {"auto", 1})),
OPT_CHOICE_OR_INT("drm-draw-plane", drm_draw_plane, 0, 0, INT_MAX,
({"primary", DRM_OPTS_PRIMARY_PLANE},
{"overlay", DRM_OPTS_OVERLAY_PLANE})),
@@ -65,6 +68,7 @@ const struct m_sub_options drm_conf = {
{0},
},
.defaults = &(const struct drm_opts) {
+ .drm_atomic = 1,
.drm_draw_plane = DRM_OPTS_PRIMARY_PLANE,
.drm_drmprime_video_plane = DRM_OPTS_OVERLAY_PLANE,
},
@@ -276,9 +280,9 @@ static void parse_connector_spec(struct mp_log *log,
}
}
-
struct kms *kms_create(struct mp_log *log, const char *connector_spec,
- int mode_id, int draw_plane, int drmprime_video_plane)
+ int mode_id, int draw_plane, int drmprime_video_plane,
+ bool use_atomic)
{
int card_no = -1;
char *connector_name = NULL;
@@ -321,8 +325,10 @@ struct kms *kms_create(struct mp_log *log, const char *connector_spec,
mp_err(log, "Failed to set Universal planes capability\n");
}
- if (drmSetClientCap(kms->fd, DRM_CLIENT_CAP_ATOMIC, 1)) {
- mp_verbose(log, "No DRM Atomic support found\n");
+ if (!use_atomic) {
+ mp_verbose(log, "Using Legacy Modesetting\n");
+ } else if (drmSetClientCap(kms->fd, DRM_CLIENT_CAP_ATOMIC, 1)) {
+ mp_verbose(log, "No DRM Atomic support found. Falling back to legacy modesetting\n");
} else {
mp_verbose(log, "DRM Atomic support found\n");
kms->atomic_context = drm_atomic_create_context(kms->log, kms->fd, kms->crtc_id,
diff --git a/video/out/drm_common.h b/video/out/drm_common.h
index d9f086cd4e..f700e90ef5 100644
--- a/video/out/drm_common.h
+++ b/video/out/drm_common.h
@@ -48,6 +48,7 @@ struct vt_switcher {
struct drm_opts {
char *drm_connector_spec;
int drm_mode_id;
+ int drm_atomic;
int drm_draw_plane;
int drm_drmprime_video_plane;
int drm_format;
@@ -65,7 +66,8 @@ void vt_switcher_release(struct vt_switcher *s, void (*handler)(void*),
void *user_data);
struct kms *kms_create(struct mp_log *log, const char *connector_spec,
- int mode_id, int draw_plane, int drmprime_video_plane);
+ int mode_id, int draw_plane, int drmprime_video_plane,
+ bool use_atomic);
void kms_destroy(struct kms *kms);
double kms_get_display_fps(const struct kms *kms);
diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c
index d015eaa87e..f8360d3e62 100644
--- a/video/out/opengl/context_drm_egl.c
+++ b/video/out/opengl/context_drm_egl.c
@@ -766,7 +766,8 @@ static bool drm_egl_init(struct ra_ctx *ctx)
p->kms = kms_create(ctx->log, ctx->vo->opts->drm_opts->drm_connector_spec,
ctx->vo->opts->drm_opts->drm_mode_id,
ctx->vo->opts->drm_opts->drm_draw_plane,
- ctx->vo->opts->drm_opts->drm_drmprime_video_plane);
+ ctx->vo->opts->drm_opts->drm_drmprime_video_plane,
+ ctx->vo->opts->drm_opts->drm_atomic);
if (!p->kms) {
MP_ERR(ctx, "Failed to create KMS.\n");
return false;
diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c
index fbd644005c..61553f7eee 100644
--- a/video/out/vo_drm.c
+++ b/video/out/vo_drm.c
@@ -417,11 +417,10 @@ static int preinit(struct vo *vo)
MP_WARN(vo, "Failed to set up VT switcher. Terminal switching will be unavailable.\n");
}
- p->kms = kms_create(
- vo->log, vo->opts->drm_opts->drm_connector_spec,
- vo->opts->drm_opts->drm_mode_id,
- vo->opts->drm_opts->drm_draw_plane,
- vo->opts->drm_opts->drm_drmprime_video_plane);
+ p->kms = kms_create(vo->log,
+ vo->opts->drm_opts->drm_connector_spec,
+ vo->opts->drm_opts->drm_mode_id,
+ 0, 0, false);
if (!p->kms) {
MP_ERR(vo, "Failed to create KMS.\n");
goto err;