summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2021-01-22 23:07:38 +0200
committersfan5 <sfan5@live.de>2021-10-25 20:37:03 +0200
commitf56043759494dd584c8d82e7890f92fada18e34b (patch)
tree367d00e4b23f53d76a4229b42a69b1a960f4f4af
parente6cf918eb8ba3e6892f7d22a6bbcbbae3e6b5bf5 (diff)
downloadmpv-f56043759494dd584c8d82e7890f92fada18e34b.tar.bz2
mpv-f56043759494dd584c8d82e7890f92fada18e34b.tar.xz
drm_common: enable specific device selection by means of path
-rw-r--r--DOCS/interface-changes.rst2
-rw-r--r--DOCS/man/vo.rst9
-rw-r--r--video/out/drm_common.c18
-rw-r--r--video/out/drm_common.h5
-rw-r--r--video/out/opengl/context_drm_egl.c4
-rw-r--r--video/out/vo_drm.c1
6 files changed, 33 insertions, 6 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 6e20fa2329..329ca044ae 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -27,6 +27,8 @@ Interface changes
::
--- mpv 0.34.0 ---
+ - deprecate selecting by card number with `--drm-connector`, add
+ `--drm-device` which can be used instead
- add `--screen-name` and `--fs-screen-name` flags to allow selecting the
screen by its name instead of the index
- add `--macos-geometry-calculation` to change the rectangle used for screen
diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst
index d6774920a7..7632f3c406 100644
--- a/DOCS/man/vo.rst
+++ b/DOCS/man/vo.rst
@@ -552,8 +552,13 @@ Available video output drivers are:
Select the connector to use (usually this is a monitor.) If ``<name>``
is empty or ``auto``, mpv renders the output on the first available
connector. Use ``--drm-connector=help`` to get a list of available
- connectors. When using multiple graphic cards, use the ``<gpu_number>``
- argument to disambiguate.
+ connectors. The ``<gpu_number>`` argument can be used to disambiguate
+ multiple graphic cards, but is deprecated in favor of ``--drm-device``.
+ (default: empty)
+
+ ``--drm-device=<path>``
+ Select the DRM device file to use. If specified this overrides automatic
+ card selection and any card number specified ``--drm-connector``.
(default: empty)
``--drm-mode=<preferred|highest|N|WxH[@R]>``
diff --git a/video/out/drm_common.c b/video/out/drm_common.c
index 07c6815209..b631ee656c 100644
--- a/video/out/drm_common.c
+++ b/video/out/drm_common.c
@@ -74,6 +74,7 @@ static double mode_get_Hz(const drmModeModeInfo *mode);
#define OPT_BASE_STRUCT struct drm_opts
const struct m_sub_options drm_conf = {
.opts = (const struct m_option[]) {
+ {"drm-device", OPT_STRING(drm_device_path), .flags = M_OPT_FILE},
{"drm-connector", OPT_STRING(drm_connector_spec),
.help = drm_connector_opt_help},
{"drm-mode", OPT_STRING_VALIDATE(drm_mode_spec, drm_validate_mode_opt),
@@ -570,6 +571,8 @@ static void parse_connector_spec(struct mp_log *log,
}
char *dot_ptr = strchr(connector_spec, '.');
if (dot_ptr) {
+ mp_warn(log, "Warning: Selecting a connector by index with drm-connector "
+ "is deprecated. Use the drm-device option instead.\n");
*card_no = atoi(connector_spec);
*connector_name = talloc_strdup(log, dot_ptr + 1);
} else {
@@ -578,15 +581,26 @@ static void parse_connector_spec(struct mp_log *log,
}
}
-struct kms *kms_create(struct mp_log *log, const char *connector_spec,
+struct kms *kms_create(struct mp_log *log,
+ const char *drm_device_path,
+ const char *connector_spec,
const char* mode_spec,
int draw_plane, int drmprime_video_plane,
bool use_atomic)
{
int card_no = -1;
char *connector_name = NULL;
+
parse_connector_spec(log, connector_spec, &card_no, &connector_name);
- char *primary_node_path = get_primary_device_path(log, &card_no);
+ if (drm_device_path && card_no != -1)
+ mp_warn(log, "Both DRM device and card number (as part of "
+ "drm-connector) are set! Will prefer given device path "
+ "'%s'!\n",
+ drm_device_path);
+
+ char *primary_node_path = drm_device_path ?
+ talloc_strdup(log, drm_device_path) :
+ get_primary_device_path(log, &card_no);
if (!primary_node_path) {
mp_err(log,
diff --git a/video/out/drm_common.h b/video/out/drm_common.h
index e11d240dca..5aa3681ea8 100644
--- a/video/out/drm_common.h
+++ b/video/out/drm_common.h
@@ -47,6 +47,7 @@ struct vt_switcher {
};
struct drm_opts {
+ char *drm_device_path;
char *drm_connector_spec;
char *drm_mode_spec;
int drm_atomic;
@@ -80,7 +81,9 @@ void vt_switcher_acquire(struct vt_switcher *s, void (*handler)(void*),
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,
+struct kms *kms_create(struct mp_log *log,
+ const char *drm_device_path,
+ const char *connector_spec,
const char *mode_spec,
int draw_plane, int drmprime_video_plane,
bool use_atomic);
diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c
index fe87f5ccc4..99cc6116fb 100644
--- a/video/out/opengl/context_drm_egl.c
+++ b/video/out/opengl/context_drm_egl.c
@@ -732,7 +732,9 @@ static bool drm_egl_init(struct ra_ctx *ctx)
}
MP_VERBOSE(ctx, "Initializing KMS\n");
- p->kms = kms_create(ctx->log, ctx->vo->opts->drm_opts->drm_connector_spec,
+ p->kms = kms_create(ctx->log,
+ ctx->vo->opts->drm_opts->drm_device_path,
+ ctx->vo->opts->drm_opts->drm_connector_spec,
ctx->vo->opts->drm_opts->drm_mode_spec,
ctx->vo->opts->drm_opts->drm_draw_plane,
ctx->vo->opts->drm_opts->drm_drmprime_video_plane,
diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c
index c0ce1707ff..129aa12b7a 100644
--- a/video/out/vo_drm.c
+++ b/video/out/vo_drm.c
@@ -566,6 +566,7 @@ static int preinit(struct vo *vo)
}
p->kms = kms_create(vo->log,
+ vo->opts->drm_opts->drm_device_path,
vo->opts->drm_opts->drm_connector_spec,
vo->opts->drm_opts->drm_mode_spec,
0, 0, false);