0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

75 Commits

Author SHA1 Message Date
Dudemanguy
111571bd05 options: remove some options with .deprecation_message
In both cases, setting these options did nothing other than give you a
warning that they may be removed in the future. Remove them now.
2024-06-25 02:18:58 +00:00
nanahi
9f5edd4eed various: fix indentation 2024-05-07 11:23:08 +02:00
nanahi
5fea0f9a47 various: use thread safe mp_strerror() 2024-03-19 19:30:27 +01:00
sfan5
aa75a0e9d2 vo_drm: add support for YUYV format
As the first aligned format this required a fix to reconfig().

Adding the other component-swapped formats in this group would be trivial
but I checked the DRM database [1] and no driver exists that supports
one of those but not YUYV and this is quite fringe as-is, so I opted not to.

[1] <https://drmdb.emersion.fr/formats>
2024-03-16 13:27:34 +01:00
Kacper Michajłow
0897604298 various: avoid function pointer casts
The opt validator functions are casted to generic validator, which has
erased type for value. Calling function by pointer of different
definition is an UB.

Avoid that by generating wrapper function that does proper argument type
conversion and calls validator function. Type erased functions have
mangled type in the name.

Fixes UBSAN failures on Clang 17, which enabled fsanitize=function by
default.
2024-02-28 16:04:02 +00:00
Kacper Michajłow
7d86807a5f vo: don't sleep 1ms always when requested time is in the past
Fixes a899e14b which changed clamp from 0 to 1 ms which effectivelly
introduced 1ms sleep always, even if requested until_time_ns is in the
past and should request 0 timeout.

While at it also fix mp_poll wrapper to respect negative timeout which
should mean infinite wait.

Also keep the 37d6604 behaviour for very short timeouts, but round only
the ones > 100us, anything else is 0.

Fixes: a899e14b
2023-11-09 21:31:58 +00:00
Dudemanguy
4aa3866400 present_sync: remove unneeded clear_values function
This was specifically special logic for drm. Before present_sync, it
would also clear out all of its vsync values like this. The old drm code
would save a bunch of samples which would confuse vo.c when unpausing
since it got old, bogus values. Since we make sure to match successive
vsync samples with the swapchain depth and that present sync samples
also match the swapchain depth, this is unneeded.
2023-11-07 00:52:46 +00:00
Dudemanguy
2872e929bb present_sync: only save as many entries as the swapchain depth
Saving more than the swapchain depth is just wasteful. We can just save
a copy of the vo_opts here and check the value whenever we're updating
values.
2023-11-07 00:52:46 +00:00
Dudemanguy
cf69fa03ca vo: replace max swapchain depth magic number 2023-11-07 00:52:46 +00:00
Dudemanguy
a96d04f19d drm: use present_sync mechanism for presentation feedback
A ton of code and drm-specific abstractions can be dropped with this.
One important thing to note is that the usage of sbc is completely
dropped here. The utility of that is not particularly clear since the
sbc value was manually incremented before the flip and it's not as if
the drm page flip event gives it to us like it does with the msec and
ust. It can be reintroduced later if there is a need. For drm, we also
add a present_sync_clear_values helper since all presentation feedback
needs to be cleared on pause/resume for it.
2023-11-06 15:44:45 +00:00
Guido Cella
040622f6b7 various: remove trailing whitespace 2023-10-30 16:45:47 +00:00
Kacper Michajłow
34d99840a5 timer: use MP_TIME macros 2023-10-26 16:49:38 +00:00
NRK
e41add29d4 drm_common: don't spoil errno in signal handler
same rationale as last commit
2023-10-13 11:36:01 +02:00
Dudemanguy
5d44cf93df vo: use mp_poll wrapper in wait_events when applicable
On linux, several platforms poll for events over a fd. This has ms
accuracy, but mpv's timer is in ns now so lots of precision is lost. We
can use an mp_poll wrapper to use ppoll instead which takes a timespec
directly with nanosecond precision. On systems without ppoll this falls
back to old poll behavior. On wayland, we don't actually use this
because ppoll completely messes up the event loop for some unknown
reason.
2023-10-10 19:10:55 +00:00
Dudemanguy
a899e14bcc vo: change vo->driver->wait_events to nanoseconds
In many cases, this is purely cosmetic because poll still only accepts
microseconds. There's still a gain here however since
pthread_cond_timedwait can take a realtime ts now.

Additionally, 37d6604d70 changed the value
added to timeout_ms in X11 and Wayland to ensure that it would never be
0 and rounded up. This was both incomplete, several other parts of the
player have this same problem like drm, and not really needed. Instead
the MPCLAMP is just adjusted to have a min of 1.
2023-10-10 19:10:55 +00:00
Kacper Michajłow
df764bc0c3 vo: change vsync base to nanoseconds
There is no reason to use microseconds precision. We have precise timers
all all relevant platforms.
2023-09-29 20:48:58 +00:00
Dudemanguy
be89e07229 drm: remove selecting the card number with --drm-connector
f560437594 deprecated this since the
--drm-device path option was added as a replacement. Drop the card
number selection logic.
2023-09-21 16:06:29 +00:00
Dudemanguy
969c19c9cb options: remove ancient option fallbacks/deprecation
We've got an ungodly amount of OPT_REPLACED and OPT_REMOVED sitting
around in the code. This is harmless, but the vast majority of these are
ancient. 26f4f18c06 is the last commit
that touched the majority of these and of course that only changed how
options were declared so all of this stuff was deprecated even before
that. No use in keeping these, so just delete them all. As an aside,
there was actually a cocoa_opts but it had only a single option which
was replaced by something else and empty otherwise. So that entire thing
was just simply removed. OPT_REPLACED/OPT_REMOVED declarations that were
added in 0.35 or later were kept as is.
2023-09-21 16:06:29 +00:00
llyyr
bf1e1a7961 drm_common: skip cards that don't have connected outputs
It's possible for systems to have multiple cards, and the first capable
card to not have a connected output. Skip such cards and continue
iterating until we find one with a connected output.
2023-08-20 19:59:36 +02:00
LaserEyess
3b19866882 drm: bump minimum version to 2.4.105
Debian 12 is out, with 2.4.114, and Ubuntu 22.04 has 2.4.110, this
 #ifdef is no longer needed
2023-07-31 21:40:10 +02:00
Christoph Heinrich
c0807e98fb options: remove explicit initialization of integers to 0 2023-02-21 17:15:17 +00:00
Dudemanguy
92a6f2d687 drm: rewrite based around vo_drm_state
A longstanding pain point of the drm VOs is the relative lack of state
sharing. While drm_common does provide some sharing, it's far less than
other platforms like x11 or wayland. What we do here is essentially copy
them by creating a new vo_drm_state struct and using it in vo_drm and
context_drm_egl. Much of the functionality that was essentially
duplicated in both VOs/contexts is now reduced simple functions in
drm_common. The usage of the term 'kms' was also mostly eliminated since
this is libdrm nowadays from a userspace perspective.
2023-01-21 17:08:29 +00:00
LaserEyess
ba20f60add drm: remove legacy API
The legacy DRM API adds some complexity to the DRM code. There
are only 4 drivers that do not support the DRM Atomic API:

1. radeon (early GCN amd cards)
2. gma500 (ancient intel GPUs)
3. ast (ASPEED SoCs)
4. nouveau

Going forward, new DRM drivers will be guaranteed to support the atomic
API so this is a safe removal.
2022-11-16 09:32:55 +01:00
sfan5
f2ef942ef5 drm_common: remove hard dependency on drmIsKMS()
ae768a1e14 forgot to bump the required
libdrm version however Debian 11 just barely misses the requirement,
which is a good reason not to require it unconditionally anyway.
2022-08-11 18:31:04 +02:00
sfan5
ae768a1e14 drm_common: skip cards that don't support KMS for autodetection
Avoids another pitfall on systems where the first card has a primary
node but is not capable of KMS. With this change --drm-context=drm
should work correctly out-of-the-box in all cases.
2022-08-03 16:43:08 +02:00
Dudemanguy
0ec3bd6ba9 wayland: use mp_tag_str not drm_format_string
So it turns out that mpv already has an mp_tag_str which makes a
readable string out of fourccs (drm formats are these).
drm_format_string, on the other hand, has a ton of baggage with having
to check different libdrm versions for certain headers, adding
compile-time defines (because there are no version defines in the libdrm
headers), etc. It's a lot simpler to just use what mpv already has and
it returns what you actually care about: i.e. is this format supported
or not. Fixes https://github.com/mpv-player/mpv-build/issues/184
2022-05-30 19:51:46 +00:00
Aaron Boxer
defb02daa4 vo: add new vaapi-wayland driver
This driver makes use of dmabuffer and viewporter interfaces
to enable efficient display of vaapi surfaces, avoiding
any unnecessary colour space conversion, and avoiding scaling
or colour conversion using GPU shader resources.
2022-05-24 21:39:34 +00:00
Philip Langdale
73a06ffae6 drm: context_drm_egl: add support for enabling VRR
Variable Refresh Rate (VRR), aka Freesync or Adaptive Sync can be used
with DRM by setting the VRR_ENABLED property on a crtc if the
connector reports that it is VRR_CAPABLE. This is a useful feature
for us as it is common to play 24/25/50 fps content on displays that
are nominally locked to 60Hz. VRR can allow this content to play at
native framerates.

This is a simple change as we just need to check the capability
and set the enabled property if requested by the user. I've defaulted
it to disabled for now, but it might make sense to default to auto
in the long term.
2022-04-05 20:56:36 -07:00
Philip Langdale
2b9d8ae8b1 context_drm_egl: add support for BGR surface formats
The new GBM supporting nvidia drivers declare support for 10bit
surfaces using BGR ordering, rather than RGB, so add support for them.

We've also seen examples of hardware supporting BGR8888 but not
RGB8888 so let's support those too.

Of course, the nvidia EGL driver doesn't publish support for any 10bit
formats so you can't actually do 10bit display. Perhaps they'll
eventually fix that.
2021-11-10 09:57:58 -08:00
Noralf Trønnes
e6ab676d20 drm_common: add connector types USB, SPI and Writeback
Add support for the newly added USB connector type and also SPI and Writeback.
2021-10-26 17:44:54 +00:00
Noralf Trønnes
9cf95baaf3 drm_common: support unknown connector types
Avoid 'Segmentation fault' by using the connector type name UNKNOWN if
the connector type is not known to mpv.
2021-10-26 17:44:54 +00:00
Jan Ekström
f560437594 drm_common: enable specific device selection by means of path 2021-10-25 20:37:03 +02:00
Jan Ekström
e6cf918eb8 drm_common: utilize drmGetDevices when iterating over cards
Based on the idea behind emersion's change to drm_info
(869e789a64).

Lets us by default skip devices which are not capable of doing what
the DRM master output requires (not primary devices), as some devices
have card0 actually not be such.

Negative part is that the number given to drm-connector is no
longer a direct mapping against a file name.
2021-10-25 20:37:03 +02:00
Philip Langdale
3f006eced4 options: Make validation and help possible for all option types
Today, validation is only possible for string type options. But there's
no particular reason why it needs to be restricted in this way, and
there are potential uses, to allow other options to be validated
without forcing the option to have to reimplement parsing from
scratch.

The first part, simply making the validation function an explicit
field instead of overloading priv is simple enough. But if we only do
that, then the validation function still needs to deal with the raw
pre-parsed string. Instead, we want to allow the value to be parsed
before it is validated. That in turn leads to us having validator
functions that should be type aware. Unfortunately, that means we need
to keep the explicit macro like OPT_STRING_VALIDATE() as a way to
enforce the correct typing of the function. Otherwise, we'd have to
have the validator take a void * and hope the implementation can cast
it correctly.

For help, we don't have this problem, as help doesn't look at the
value.

Then, we turn validators that are really help generators into explicit
help functions and where a validator is help + validation, we split
them into two parts.

I have, however, left functions that need to query information for both
help and validation as single functions to avoid code duplication.

In this change, I have not added an other OPT_FOO_VALIDATE() macros as
they are not needed, but I will add some in a separate change to
illustrate the pattern.
2021-03-28 19:46:27 +03:00
Jan Beich
90737ec77d drm_common: set frsig to a valid signal
On FreeBSD and DragonFly kernel checks if `frsig` is valid and aborts
with `EINVAL` if not. However, `frsig` was never implemented.

$ build/mpv --gpu-context=drm /path/to/video.mkv
[...]
[vo/gpu] VT_SETMODE failed: Invalid argument
[vo/gpu/opengl] Failed to set up VT switcher. Terminal switching will be unavailable.
[...]
2020-04-22 11:27:18 +02:00
Jan Beich
427709575d build: detect VT_GETMODE on FreeBSD and DragonFly
$ ./waf configure
Checking for vt.h                       : no
Checking for DRM                        : vt.h not found
[...]
 ../test.c:1:10: fatal error: 'sys/vt.h' file not found
 #include <sys/vt.h>
          ^~~~~~~~~~

$ build/mpv --gpu-context=drm /path/to/video.mkv
Error parsing option gpu-context (option parameter could not be parsed)
Setting commandline option --gpu-context=drm failed.

Exiting... (Fatal error)
2020-04-22 11:27:18 +02:00
wm4
26f4f18c06 options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with

   {"name", ...

followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.

I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.

Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.

Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.

In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-18 19:52:01 +01:00
Anton Kindestam
d5cabf7348 drm: avoid division by 0 in drm_pflip_cb with bad drivers
Seems like some drivers only increment msc every other page flip when
running in interlaced mode (I'm looking at you nouveau). I.e. it seems
to be incremented at the frame rate, rather than the field rate.
Obviously we can't work with this, so shame the driver and bail.

On intel this isn't an issue, as msc is incremented at field rate
there.

This means presentation feedback won't work correctly in interlaced
modes with those drivers, but who in their right mind uses an
interlaced mode these days, anyway?
2019-12-07 18:34:25 +01:00
sfan5
83b742df77 drm_common: fix display FPS estimation for interlaced modes 2019-12-07 16:44:27 +01:00
sfan5
823f52f91f drm_common: log more useful things 2019-12-07 16:44:27 +01:00
Anton Kindestam
9538fb5a7a drm: refactor page_flipped callback
Avoid duplicating the same callback function in both context_drm_egl
and vo_drm.
2019-09-28 14:10:01 +03:00
Anton Kindestam
bbf6e103b4 drm_common: add missing zero-initialization of struct vt_mode variable
Some fields were being left uninitialized. This could be a problem
particularly on non-Linux OS:s with vt_mode (see PR #6976).
2019-09-24 21:46:52 +02:00
Anton Kindestam
dcb7838bb7 drm_common: Support --drm-mode=<preferred|highest|N|WxH[@R]>
This allows to select the drm mode using a string specification. You
can either select the the preferred mode, the mode with the highest
resolution, by specifying WxH[@R] or by its index in the list of modes
as before.
2019-05-04 14:17:11 +02:00
Anton Kindestam
d155b7541f drm_common: Don't export functions only being used internally
As far as I know none of these functions were being used outside of
drm_common, nor should there really be a need to use them.
2019-05-04 14:17:11 +02:00
Anton Kindestam
8261924db9 drm_common: Add proper help option to drm-mode
This was implemented by using OPT_STRING_VALIDATE for drm-mode,
instead of OPT_INT. Using a string here also prepares for future
additions to drm-mode that aim to allow specifying a mode by its
resolution.
2019-05-04 14:17:11 +02:00
Anton Kindestam
a776628d88 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.
2019-05-04 14:17:11 +02:00
Anton Kindestam
f0509d3738 drm: rename plane options to better, invariant, names
This commit bumps the libmpv version to 1.102

drm-osd-plane -> drm-draw-plane
drm-video-plane -> drm-drmprime-video-plane
drm-osd-size -> drm-draw-surface-size

"draw plane", as in the plane that OpenGL draws to, whether it be
video + OSD or just OSD.

"drmprime video plane", as in the plane used for hwdec video imported
via drmprime.

"draw surface size", as in the size of the surface used for the draw plane

The new names are invariant whether or not hwdec_drmprime_drm is being
used or not. The original naming was very confusing, as when doing
regular rendering (swdec or vaapi) the video would be displayed on the
"OSD plane", and the "Video plane" would remain unused.
2018-12-01 15:42:20 +02:00
Anton Kindestam
c151fae054 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.
2018-12-01 15:42:20 +02:00
Anton Kindestam
7beee68f8d context_drm_egl: Fix CRTC setup and release code when using atomic
The previous code did not save enough information about the old state,
and could end up changing what plane the fbcon:s FB got attached to,
or in worse case causing a blank screen (observed in some multi-screen
setups on Sandy Bridge).

In addition refactor the handling of drmModeModeInfo property blobs to
not leak, as well as enable reuse of already created blobs.
2018-07-09 02:17:47 +03:00
Anton Kindestam
02d40eee1b drm_common: Be smarter when deciding on which CRTC and Encoder to use
Inspired by kmscube, first try to pick the Encoder and CRTC already
associated with the selected Connector, if any. Otherwise try to find
the first matching encoder & CRTC like before.

The previous behavior had problems when using atomic
modesetting (crtc_setup_atomic) when we picked an Encoder & CRTC that
was currently being used by the fbcon together with another Encoder.
drmModeSetCrtc was able to "steal" the CRTC in this case, but using
atomic modesetting we do not seem to get this behavior automatically.

This should also improve behavior somewhat when run on a multi screen
setup with regards to deinit and VT switching (still sometimes you end
up with a blank screen where you previously had a cloned display of
your fbcon)
2018-05-01 20:48:02 +03:00