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>
|
2016-10-04 20:07:19 +00:00
|
|
|
#include "options/m_option.h"
|
2017-10-23 15:51:49 +00:00
|
|
|
#include "drm_atomic.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
|
|
|
|
|
2015-11-07 12:41:40 +00:00
|
|
|
struct kms {
|
|
|
|
struct mp_log *log;
|
|
|
|
int fd;
|
|
|
|
drmModeConnector *connector;
|
|
|
|
drmModeEncoder *encoder;
|
2018-06-02 10:53:54 +00:00
|
|
|
struct drm_mode mode;
|
2015-11-07 12:41:40 +00:00
|
|
|
uint32_t crtc_id;
|
2016-10-04 20:07:19 +00:00
|
|
|
int card_no;
|
2017-10-23 15:51:49 +00:00
|
|
|
struct drm_atomic_context *atomic_context;
|
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];
|
|
|
|
};
|
|
|
|
|
2017-10-23 06:59:58 +00:00
|
|
|
struct drm_opts {
|
|
|
|
char *drm_connector_spec;
|
2018-06-02 10:53:58 +00:00
|
|
|
char *drm_mode_spec;
|
2018-06-28 13:23:19 +00:00
|
|
|
int drm_atomic;
|
2018-12-01 11:01:17 +00:00
|
|
|
int drm_draw_plane;
|
|
|
|
int drm_drmprime_video_plane;
|
2018-02-13 17:40:47 +00:00
|
|
|
int drm_format;
|
2018-12-01 11:01:17 +00:00
|
|
|
struct m_geometry drm_draw_surface_size;
|
2017-10-23 06:59:58 +00:00
|
|
|
};
|
|
|
|
|
2019-04-14 14:03:22 +00:00
|
|
|
struct drm_vsync_tuple {
|
|
|
|
uint64_t ust;
|
|
|
|
unsigned int msc;
|
|
|
|
unsigned int sbc;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2015-11-07 20:11:04 +00:00
|
|
|
bool vt_switcher_init(struct vt_switcher *s, struct mp_log *log);
|
2015-04-19 07:39:58 +00:00
|
|
|
void vt_switcher_destroy(struct vt_switcher *s);
|
|
|
|
void vt_switcher_poll(struct vt_switcher *s, int timeout_ms);
|
|
|
|
void vt_switcher_interrupt_poll(struct vt_switcher *s);
|
|
|
|
|
2016-10-04 20:07:19 +00:00
|
|
|
void vt_switcher_acquire(struct vt_switcher *s, void (*handler)(void*),
|
|
|
|
void *user_data);
|
|
|
|
void vt_switcher_release(struct vt_switcher *s, void (*handler)(void*),
|
|
|
|
void *user_data);
|
2015-04-19 07:39:58 +00:00
|
|
|
|
2016-10-04 20:07:19 +00:00
|
|
|
struct kms *kms_create(struct mp_log *log, const char *connector_spec,
|
2018-06-02 10:53:58 +00:00
|
|
|
const char *mode_spec,
|
|
|
|
int draw_plane, int drmprime_video_plane,
|
2018-06-28 13:23:19 +00:00
|
|
|
bool use_atomic);
|
2015-11-07 12:41:40 +00:00
|
|
|
void kms_destroy(struct kms *kms);
|
2016-10-03 21:56:35 +00:00
|
|
|
double kms_get_display_fps(const struct kms *kms);
|
2015-11-07 12:41:40 +00:00
|
|
|
|
2019-07-29 17:32:29 +00:00
|
|
|
// DRM Page Flip callback
|
|
|
|
void drm_pflip_cb(int fd, unsigned int msc, unsigned int sec,
|
|
|
|
unsigned int usec, void *data);
|
|
|
|
|
2015-04-19 07:39:58 +00:00
|
|
|
#endif
|