mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
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.
This commit is contained in:
parent
23a324215b
commit
a776628d88
@ -488,6 +488,16 @@ Available video output drivers are:
|
|||||||
Mode ID to use (resolution and frame rate).
|
Mode ID to use (resolution and frame rate).
|
||||||
(default: 0)
|
(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>``
|
``--drm-draw-plane=<primary|overlay|N>``
|
||||||
Select the DRM plane to which video and OSD is drawn to, under normal
|
Select the DRM plane to which video and OSD is drawn to, under normal
|
||||||
circumstances. The plane can be specified as ``primary``, which will
|
circumstances. The plane can be specified as ``primary``, which will
|
||||||
|
@ -48,6 +48,9 @@ const struct m_sub_options drm_conf = {
|
|||||||
OPT_STRING_VALIDATE("drm-connector", drm_connector_spec,
|
OPT_STRING_VALIDATE("drm-connector", drm_connector_spec,
|
||||||
0, drm_validate_connector_opt),
|
0, drm_validate_connector_opt),
|
||||||
OPT_INT("drm-mode", drm_mode_id, 0),
|
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,
|
OPT_CHOICE_OR_INT("drm-draw-plane", drm_draw_plane, 0, 0, INT_MAX,
|
||||||
({"primary", DRM_OPTS_PRIMARY_PLANE},
|
({"primary", DRM_OPTS_PRIMARY_PLANE},
|
||||||
{"overlay", DRM_OPTS_OVERLAY_PLANE})),
|
{"overlay", DRM_OPTS_OVERLAY_PLANE})),
|
||||||
@ -65,6 +68,7 @@ const struct m_sub_options drm_conf = {
|
|||||||
{0},
|
{0},
|
||||||
},
|
},
|
||||||
.defaults = &(const struct drm_opts) {
|
.defaults = &(const struct drm_opts) {
|
||||||
|
.drm_atomic = 1,
|
||||||
.drm_draw_plane = DRM_OPTS_PRIMARY_PLANE,
|
.drm_draw_plane = DRM_OPTS_PRIMARY_PLANE,
|
||||||
.drm_drmprime_video_plane = DRM_OPTS_OVERLAY_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,
|
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;
|
int card_no = -1;
|
||||||
char *connector_name = NULL;
|
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");
|
mp_err(log, "Failed to set Universal planes capability\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drmSetClientCap(kms->fd, DRM_CLIENT_CAP_ATOMIC, 1)) {
|
if (!use_atomic) {
|
||||||
mp_verbose(log, "No DRM Atomic support found\n");
|
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 {
|
} else {
|
||||||
mp_verbose(log, "DRM Atomic support found\n");
|
mp_verbose(log, "DRM Atomic support found\n");
|
||||||
kms->atomic_context = drm_atomic_create_context(kms->log, kms->fd, kms->crtc_id,
|
kms->atomic_context = drm_atomic_create_context(kms->log, kms->fd, kms->crtc_id,
|
||||||
|
@ -48,6 +48,7 @@ struct vt_switcher {
|
|||||||
struct drm_opts {
|
struct drm_opts {
|
||||||
char *drm_connector_spec;
|
char *drm_connector_spec;
|
||||||
int drm_mode_id;
|
int drm_mode_id;
|
||||||
|
int drm_atomic;
|
||||||
int drm_draw_plane;
|
int drm_draw_plane;
|
||||||
int drm_drmprime_video_plane;
|
int drm_drmprime_video_plane;
|
||||||
int drm_format;
|
int drm_format;
|
||||||
@ -65,7 +66,8 @@ void vt_switcher_release(struct vt_switcher *s, void (*handler)(void*),
|
|||||||
void *user_data);
|
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 *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);
|
void kms_destroy(struct kms *kms);
|
||||||
double kms_get_display_fps(const struct kms *kms);
|
double kms_get_display_fps(const struct kms *kms);
|
||||||
|
|
||||||
|
@ -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,
|
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_mode_id,
|
||||||
ctx->vo->opts->drm_opts->drm_draw_plane,
|
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) {
|
if (!p->kms) {
|
||||||
MP_ERR(ctx, "Failed to create KMS.\n");
|
MP_ERR(ctx, "Failed to create KMS.\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -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");
|
MP_WARN(vo, "Failed to set up VT switcher. Terminal switching will be unavailable.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
p->kms = kms_create(
|
p->kms = kms_create(vo->log,
|
||||||
vo->log, vo->opts->drm_opts->drm_connector_spec,
|
vo->opts->drm_opts->drm_connector_spec,
|
||||||
vo->opts->drm_opts->drm_mode_id,
|
vo->opts->drm_opts->drm_mode_id,
|
||||||
vo->opts->drm_opts->drm_draw_plane,
|
0, 0, false);
|
||||||
vo->opts->drm_opts->drm_drmprime_video_plane);
|
|
||||||
if (!p->kms) {
|
if (!p->kms) {
|
||||||
MP_ERR(vo, "Failed to create KMS.\n");
|
MP_ERR(vo, "Failed to create KMS.\n");
|
||||||
goto err;
|
goto err;
|
||||||
|
Loading…
Reference in New Issue
Block a user