2015-04-19 07:39:58 +00:00
|
|
|
/*
|
|
|
|
* This file is part of mpv.
|
|
|
|
*
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2015-04-19 07:39:58 +00:00
|
|
|
*
|
|
|
|
* mpv 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
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2015-04-19 07:39:58 +00:00
|
|
|
*
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2015-04-19 07:39:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MP_VT_SWITCHER_H
|
|
|
|
#define MP_VT_SWITCHER_H
|
|
|
|
|
2015-11-07 20:11:04 +00:00
|
|
|
#include <stdbool.h>
|
2015-11-07 12:41:40 +00:00
|
|
|
#include <xf86drm.h>
|
|
|
|
#include <xf86drmMode.h>
|
2023-01-05 03:34:26 +00:00
|
|
|
#include "vo.h"
|
2015-11-07 12:41:40 +00:00
|
|
|
|
2018-02-13 17:40:47 +00:00
|
|
|
#define DRM_OPTS_FORMAT_XRGB8888 0
|
|
|
|
#define DRM_OPTS_FORMAT_XRGB2101010 1
|
2021-11-06 03:05:42 +00:00
|
|
|
#define DRM_OPTS_FORMAT_XBGR8888 2
|
|
|
|
#define DRM_OPTS_FORMAT_XBGR2101010 3
|
2018-02-13 17:40:47 +00:00
|
|
|
|
2023-01-05 03:34:26 +00:00
|
|
|
struct framebuffer {
|
2015-11-07 12:41:40 +00:00
|
|
|
int fd;
|
2023-01-05 03:34:26 +00:00
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t stride;
|
|
|
|
uint32_t size;
|
|
|
|
uint32_t handle;
|
|
|
|
uint8_t *map;
|
|
|
|
uint32_t id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_vsync_tuple {
|
|
|
|
uint64_t ust;
|
|
|
|
unsigned int msc;
|
|
|
|
unsigned int sbc;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_mode {
|
|
|
|
drmModeModeInfo mode;
|
|
|
|
uint32_t blob_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_opts {
|
|
|
|
char *device_path;
|
|
|
|
char *connector_spec;
|
|
|
|
char *mode_spec;
|
|
|
|
int drm_atomic;
|
|
|
|
int draw_plane;
|
|
|
|
int drmprime_video_plane;
|
|
|
|
int drm_format;
|
|
|
|
struct m_geometry draw_surface_size;
|
|
|
|
int vrr_enabled;
|
2015-11-07 12:41:40 +00:00
|
|
|
};
|
|
|
|
|
2015-04-19 07:39:58 +00:00
|
|
|
struct vt_switcher {
|
|
|
|
int tty_fd;
|
|
|
|
struct mp_log *log;
|
|
|
|
void (*handlers[2])(void*);
|
|
|
|
void *handler_data[2];
|
|
|
|
};
|
|
|
|
|
2023-01-05 03:34:26 +00:00
|
|
|
struct vo_drm_state {
|
|
|
|
drmModeConnector *connector;
|
|
|
|
drmModeEncoder *encoder;
|
|
|
|
drmEventContext ev;
|
2017-10-23 06:59:58 +00:00
|
|
|
|
2023-01-05 03:34:26 +00:00
|
|
|
struct drm_atomic_context *atomic_context;
|
|
|
|
struct drm_mode mode;
|
|
|
|
struct drm_opts *opts;
|
|
|
|
struct drm_vsync_tuple vsync;
|
|
|
|
struct framebuffer *fb;
|
|
|
|
struct mp_log *log;
|
|
|
|
struct vo *vo;
|
|
|
|
struct vt_switcher vt_switcher;
|
|
|
|
struct vo_vsync_info vsync_info;
|
|
|
|
|
|
|
|
bool active;
|
|
|
|
bool paused;
|
|
|
|
bool still;
|
|
|
|
bool vt_switcher_active;
|
|
|
|
bool waiting_for_flip;
|
|
|
|
|
|
|
|
char *card_path;
|
|
|
|
int card_no;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
uint32_t crtc_id;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t width;
|
2019-04-14 14:03:22 +00:00
|
|
|
};
|
|
|
|
|
2019-07-29 17:32:29 +00:00
|
|
|
struct drm_pflip_cb_closure {
|
|
|
|
struct drm_vsync_tuple *frame_vsync; // vsync tuple when the frame that just flipped was queued
|
|
|
|
struct drm_vsync_tuple *vsync; // vsync tuple of the latest page flip. drm_pflip_cb updates this
|
|
|
|
struct vo_vsync_info *vsync_info; // where the drm_pflip_cb routine writes its output
|
|
|
|
bool *waiting_for_flip; // drm_pflip_cb writes false here before returning
|
2019-12-07 17:23:42 +00:00
|
|
|
struct mp_log *log; // Needed to print error messages that shame bad drivers
|
2019-07-29 17:32:29 +00:00
|
|
|
};
|
|
|
|
|
2023-01-05 03:34:26 +00:00
|
|
|
bool vo_drm_init(struct vo *vo);
|
|
|
|
int vo_drm_control(struct vo *vo, int *events, int request, void *arg);
|
|
|
|
|
|
|
|
double vo_drm_get_display_fps(struct vo_drm_state *drm);
|
|
|
|
void vo_drm_get_vsync(struct vo *vo, struct vo_vsync_info *info);
|
|
|
|
void vo_drm_set_monitor_par(struct vo *vo);
|
|
|
|
void vo_drm_uninit(struct vo *vo);
|
|
|
|
void vo_drm_wait_events(struct vo *vo, int64_t until_time_us);
|
|
|
|
void vo_drm_wait_on_flip(struct vo_drm_state *drm);
|
|
|
|
void vo_drm_wakeup(struct vo *vo);
|
|
|
|
|
|
|
|
bool vo_drm_acquire_crtc(struct vo_drm_state *drm);
|
|
|
|
void vo_drm_release_crtc(struct vo_drm_state *drm);
|
2019-07-29 17:32:29 +00:00
|
|
|
|
2015-04-19 07:39:58 +00:00
|
|
|
#endif
|