1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 00:07:33 +00:00

drm_atomic: Add general primary/overlay plane option

Add general primary/overlay plane option to drm-osd-plane-id and
drm-video-plane-id, so that the user can just request any usable
primary or overlay plane for either of these two options. This should
be somewhat more user-friendly (especially as neither of these two
options currently have a useful help function), as usually you would
only be interested in the type of the plane, and not exactly which
plane gets picked.
This commit is contained in:
Anton Kindestam 2018-06-02 12:54:05 +02:00 committed by Jan Ekström
parent b6a431ec55
commit c151fae054
5 changed files with 51 additions and 30 deletions

View File

@ -20,6 +20,11 @@ Interface changes
:: ::
--- mpv 0.30.0 --- --- mpv 0.30.0 ---
- the `--drm-osd-plane-id` and `--drm-video-plane-id`
options now accept either an integer index, or the values primary or overlay.
`--drm-osd-plane-id` now defaults to primary and `--drm-video-plane-id`
defaults to overlay. This should be similar to previous behavior on most drivers
due to how planes are usually sorted.
- rename --opensles-frames-per-buffer to --opensles-frames-per-enqueue to - rename --opensles-frames-per-buffer to --opensles-frames-per-enqueue to
better reflect its purpose. In the past it overrides the buffer size the AO better reflect its purpose. In the past it overrides the buffer size the AO
requests (but not the default/value of the generic --audio-buffer option). requests (but not the default/value of the generic --audio-buffer option).

View File

@ -488,19 +488,21 @@ 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-osd-plane-id=<number>`` ``--drm-osd-plane-id=<primary|overlay|N>``
Select the DRM plane index to use for OSD (or OSD and video). Select the DRM plane to use for OSD (or OSD and video). The plane can be
Index is zero based, and related to crtc. specified as ``primary``, which will pick the first applicable primary
When using this option with the drm_prime renderer, it will only affect plane; ``overlay``, which will pick the first applicable overlay plane;
the OSD contents. Otherwise it will set OSD & video plane. or by index. The index is zero based, and related to the CRTC. When using
(default: primary plane) this option with the drm_prime renderer, it will only affect the OSD
contents. Otherwise it will set OSD & video plane.
(default: primary)
``--drm-video-plane-id=<number>`` ``--drm-video-plane-id=<primary|overlay|N>``
Select the DRM plane index to use for video layer. Select the DRM plane index to use for video layer. This option accepts
Index is zero based, and related to crtc. the same values as ``--drm-osd-plane-id``. This option has an effect
This option only has effect when using the drm_prime renderer (which only when using the drm_prime renderer (which supports several layers)
supports several layers) together with ``vo=gpu`` and ``gpu-context=drm``. together with ``vo=gpu`` and ``gpu-context=drm``.
(default: first overlay plane) (default: overlay)
``--drm-format=<xrgb8888|xrgb2101010>`` ``--drm-format=<xrgb8888|xrgb2101010>``
Select the DRM format to use (default: xrgb8888). This allows you to Select the DRM format to use (default: xrgb8888). This allows you to

View File

@ -138,7 +138,8 @@ void drm_object_print_info(struct mp_log *log, struct drm_object *object)
} }
struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, int crtc_id, struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, int crtc_id,
int connector_id, int osd_plane_id, int video_plane_id) int connector_id,
int osd_plane_idx, int video_plane_idx)
{ {
drmModePlaneRes *plane_res = NULL; drmModePlaneRes *plane_res = NULL;
drmModeRes *res = NULL; drmModeRes *res = NULL;
@ -228,12 +229,12 @@ struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd,
if ((!overlay_id) && (value == DRM_PLANE_TYPE_OVERLAY)) if ((!overlay_id) && (value == DRM_PLANE_TYPE_OVERLAY))
overlay_id = plane_id; overlay_id = plane_id;
if (layercount == osd_plane_id) { if (layercount == osd_plane_idx) {
ctx->osd_plane = plane; ctx->osd_plane = plane;
continue; continue;
} }
if (layercount == video_plane_id) { if (layercount == video_plane_idx) {
ctx->video_plane = plane; ctx->video_plane = plane;
continue; continue;
} }
@ -244,26 +245,31 @@ struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd,
} }
} }
// default OSD plane to primary if unspecified // OSD plane was specified as either of the special options: any primary plane or any overlay plane
if (!ctx->osd_plane) { if (!ctx->osd_plane) {
if (primary_id) { const int osd_plane_id = (osd_plane_idx == DRM_OPTS_OVERLAY_PLANE) ? overlay_id : primary_id;
mp_verbose(log, "Using default plane %d for OSD\n", primary_id); const char *plane_type = (osd_plane_idx == DRM_OPTS_OVERLAY_PLANE) ? "overlay" : "primary";
ctx->osd_plane = drm_object_create(log, ctx->fd, primary_id, DRM_MODE_OBJECT_PLANE); if (osd_plane_id) {
mp_verbose(log, "Using %s plane %d for OSD\n", plane_type, osd_plane_id);
ctx->osd_plane = drm_object_create(log, ctx->fd, osd_plane_id, DRM_MODE_OBJECT_PLANE);
} else { } else {
mp_err(log, "Failed to find OSD plane with id=%d\n", osd_plane_id); mp_err(log, "Failed to find OSD plane with idx=%d\n", osd_plane_idx);
goto fail; goto fail;
} }
} else { } else {
mp_verbose(log, "Found OSD plane with ID %d\n", ctx->osd_plane->id); mp_verbose(log, "Found OSD plane with ID %d\n", ctx->osd_plane->id);
} }
// default video plane to overlay if unspecified // video plane was specified as either of the special options: any primary plane or any overlay plane
if (!ctx->video_plane) { if (!ctx->video_plane) {
if (overlay_id) { const int video_plane_id = (video_plane_idx == DRM_OPTS_PRIMARY_PLANE) ? primary_id : overlay_id;
mp_verbose(log, "Using default plane %d for video\n", overlay_id); const char *plane_type = (video_plane_idx == DRM_OPTS_PRIMARY_PLANE) ? "primary" : "overlay";
ctx->video_plane = drm_object_create(log, ctx->fd, overlay_id, DRM_MODE_OBJECT_PLANE);
if (video_plane_id) {
mp_verbose(log, "Using %s plane %d for video\n", plane_type, video_plane_id);
ctx->video_plane = drm_object_create(log, ctx->fd, video_plane_id, DRM_MODE_OBJECT_PLANE);
} else { } else {
mp_verbose(log, "Failed to find video plane with id=%d. drmprime-drm hwdec interop will not work\n", video_plane_id); mp_verbose(log, "Failed to find video plane with idx=%d. drmprime-drm hwdec interop will not work\n", video_plane_idx);
} }
} else { } else {
mp_verbose(log, "Found video plane with ID %d\n", ctx->video_plane->id); mp_verbose(log, "Found video plane with ID %d\n", ctx->video_plane->id);

View File

@ -25,6 +25,9 @@
#include "common/msg.h" #include "common/msg.h"
#define DRM_OPTS_PRIMARY_PLANE -1
#define DRM_OPTS_OVERLAY_PLANE -2
struct drm_mode { struct drm_mode {
drmModeModeInfo mode; drmModeModeInfo mode;
uint32_t blob_id; uint32_t blob_id;
@ -89,7 +92,7 @@ struct drm_object * drm_object_create(struct mp_log *log, int fd, uint32_t objec
void drm_object_free(struct drm_object *object); void drm_object_free(struct drm_object *object);
void drm_object_print_info(struct mp_log *log, struct drm_object *object); void drm_object_print_info(struct mp_log *log, struct drm_object *object);
struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, int crtc_id, int connector_id, struct drm_atomic_context *drm_atomic_create_context(struct mp_log *log, int fd, int crtc_id, int connector_id,
int osd_plane_id, int video_plane_id); int osd_plane_idx, int video_plane_idx);
void drm_atomic_destroy_context(struct drm_atomic_context *ctx); void drm_atomic_destroy_context(struct drm_atomic_context *ctx);
bool drm_atomic_save_old_state(struct drm_atomic_context *ctx); bool drm_atomic_save_old_state(struct drm_atomic_context *ctx);

View File

@ -23,6 +23,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/vt.h> #include <sys/vt.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h>
#include "drm_common.h" #include "drm_common.h"
@ -47,8 +48,12 @@ 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_INT("drm-osd-plane-id", drm_osd_plane_id, 0), OPT_CHOICE_OR_INT("drm-osd-plane-id", drm_osd_plane_id, 0, 0, INT_MAX,
OPT_INT("drm-video-plane-id", drm_video_plane_id, 0), ({"primary", DRM_OPTS_PRIMARY_PLANE},
{"overlay", DRM_OPTS_OVERLAY_PLANE})),
OPT_CHOICE_OR_INT("drm-video-plane-id", drm_video_plane_id, 0, 0, INT_MAX,
({"primary", DRM_OPTS_PRIMARY_PLANE},
{"overlay", DRM_OPTS_OVERLAY_PLANE})),
OPT_CHOICE("drm-format", drm_format, 0, OPT_CHOICE("drm-format", drm_format, 0,
({"xrgb8888", DRM_OPTS_FORMAT_XRGB8888}, ({"xrgb8888", DRM_OPTS_FORMAT_XRGB8888},
{"xrgb2101010", DRM_OPTS_FORMAT_XRGB2101010})), {"xrgb2101010", DRM_OPTS_FORMAT_XRGB2101010})),
@ -56,8 +61,8 @@ const struct m_sub_options drm_conf = {
{0}, {0},
}, },
.defaults = &(const struct drm_opts) { .defaults = &(const struct drm_opts) {
.drm_osd_plane_id = -1, .drm_osd_plane_id = DRM_OPTS_PRIMARY_PLANE,
.drm_video_plane_id = -1, .drm_video_plane_id = DRM_OPTS_OVERLAY_PLANE,
}, },
.size = sizeof(struct drm_opts), .size = sizeof(struct drm_opts),
}; };