Commit Graph

204 Commits

Author SHA1 Message Date
Sylvain 1d7966df15
Remove un-needed check for NULL pointer. They were previously checked just before. 2022-11-16 21:27:16 +01:00
Eric Curtin 57b5c9107e kmsdrm: only negative devindex's are not allowed
ad874536 removed an unnecessary limit as we *can* have a devindex
greater than 99, this error message does not reflect the support for
values greater than 99.
2022-09-28 10:29:02 -04:00
antonino 5f79cd1600 Fixed spacing 2022-08-24 10:10:49 -07:00
antonino dd68eb5c01 free drm prop before returning 2022-08-24 10:10:49 -07:00
antonino aae566e196 Use SDL_bool 2022-08-22 18:43:43 -07:00
antonino e3ea9b5b7c restore vrr state on exit 2022-08-22 18:43:43 -07:00
antonino 450e9857cc Use SDL_TRUE and SDL_FALSE 2022-08-22 18:43:43 -07:00
antonino 605b50fcd9 kmsdrm: added missing checks 2022-08-22 18:43:43 -07:00
Sam Lantinga 20715fa014 Fixed build errors 2022-08-22 17:09:42 -07:00
antonino ad874536a4 kmsdrm: enable vrr on displays that support it 2022-08-19 09:45:03 -07:00
Ryan C. Gordon 42165fe8d1
kmsdrm: slightly better device index hint parsing. 2022-07-27 12:12:36 -04:00
Sam Lantinga 613ce7850e Fixed interpreting SDL_KMSDRM_DEVICE_INDEX="" as index 0 2022-07-26 13:34:27 -07:00
Ryan C. Gordon cc982ea7a7 kmsdrm: let device indexes be > 2 digits. 2022-07-26 15:43:34 -04:00
Ryan C. Gordon 542a4da3d6
kmsdrm: check SDL_HINT_KMSDRM_DEVICE_INDEX hint in dri_getindex().
Otherwise, it would work for Init but not Available.
2022-07-26 15:11:19 -04:00
Ryan C. Gordon 5d85c7d300
kmsdrm: Added a hint to specify device index.
Fixes #2811.
2022-07-26 00:19:54 -04:00
Ryan C. Gordon 20a76b0e3e
video: removed unused devindex argument from bootstrap's create method. 2022-07-26 00:19:52 -04:00
Eric Curtin c0eada2019
Fix assumption that DRI_DEVNAME begins at 0 (#5865)
* Fix assumption that DRI_DEVNAME begins at 0

The existing logic of the code was to count every possible entry in
KMSDRM_DRI_PATH. After this a for loop would start trying to open
filename0, filename1, filename2, etc. In recent Linux kernels (say
5.18) with simpledrm, the lowest KMSDRM_DRI_DEVNAME is often
/dev/dri/card1, rather than /dev/dri/card0, causing the code to fail
once /dev/dri/card0 has failed to open. Running:

modprobe foodrm && modprobe bardrm && rmmod foodrm

before you try to run an application with SDL KMSDRM would have also
made this fail.

* Various changes from review

- Removed newline and period from SDL error
- Explicitely compare memcmp to zero (also changed to SDL_memcmp)
- Changed memcpy to strncpy
- Less aggressive line wrapping

* Various changes from review

- strncpy to SDL_strlcpy
- removed size hardcodings for KMSDRM_DRI_PATHSIZE and
  KMSDRM_DRI_DEVNAMESIZE
- made all KMSDRM_DRI defines, run-time variables to reduce bugs caused
  by these defines being more build-time on Linux and more run-rime on
  OpenBSD
- renamed openbsd69orgreater variable to moderndri
- altered comment from "if on OpenBSD" to add difference in 6.9

* Various changes from review

- Use max size of destination, rather than max size of source
- Less hardcodings
2022-07-06 09:00:16 -07:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Davis Mosenkovs 66b0a6ee15 workaround for libmali gbm_device_get_fd()
gbm_device_get_fd() in at least some libmali versions duplicates handle.
Other implementations do not do duplication. To prevent handle leak save
drm_fd in SDL_DisplayData.
2021-11-30 16:20:24 -08:00
Sylvain fae7034901
Fix warnings: static, include, un-initialized vairables 2021-11-23 10:33:12 +01:00
Sam Lantinga 665865eda2 If the hardware is in an error state, the final page flip may not come.
We should either put a timeout on the wait when destroying the window, or skip it entirely.
2021-11-19 09:58:13 -08:00
Sam Lantinga 345c161feb Fixed some accidental uses of external C runtime functions 2021-09-22 09:06:45 -07:00
Ozkan Sezer 33b84c8d15 s/memcmp/SDL_memcmp/ for conistency 2021-06-24 23:10:56 +03:00
Anthony Pesch c262569cd8 kmsdrm: fix KMSDRM_SetDisplayMode being called for the default desktop mode doing nothing 2021-06-24 12:12:29 -07:00
Anthony Pesch 98bda39186 kmsdrm: sync the display's current mode with what's set in KMSDRM_CreateSurfaces 2021-06-24 12:12:29 -07:00
Anthony Pesch d031a24e00 kmsdrm: defer surface recreation inside of KMSDRM_SetWindowSize and
KMSDRM_SetWindowFullscreen as is done in KMSDRM_SetWindowDisplayMode
2021-06-24 12:12:29 -07:00
Anthony Pesch 5a296e2589 kmsdrm: avoid overriding the mode requested by SDL_SetWindowDisplayMode
when recreating surfaces
2021-06-24 12:12:29 -07:00
Ryan C. Gordon 37d35a3e34
kmsdrm: hook up KMSDRM_GLES_DefaultProfileConfig for use.
Fixes #3678.
2021-06-11 21:03:35 -04:00
Anthony Pesch fc508eabe2 kmsdrm: remove redundant modeset_pending flag
this variable was added in commit 2067a7db8e and
ultimately tracks if this is a surface's first present. checking if the current
bo is NULL provides the same functionality and cuts down on a redundant piece
of state potentially getting out of sync in the future
2021-06-01 15:32:02 -07:00
Anthony Pesch 4c965b7a8d kmsdrm: fix SetDisplayMode binding the the wrong surface / context
SetDisplayMode needs to recreate the EGL surfaces, which then need to be
bound along with the correct context in each rendering thread

commit 3a1d7d9c9a removed this behavior which
has broken using SetDisplayMode when rendering with multiple contexts

the commit message was rather vague, but if the surfaces do need to be
created immediately, this process probably needs to be split such that
surface is created immediately, but the binding is deferred
2021-06-01 15:32:02 -07:00
Anthony Pesch 0219928dd5 kmsdrm: honor mode previously set by SDL_SetWindowDisplayMode when enabling fullscreen
and remove duplicate SDL_WINDOWEVENT_RESIZED event

commit 2067a7db8e made SDL_SetWindowSize and
SDL_SetWindowFullscreen modify the display mode previously set by a call to
SDL_SetWindowDisplayMode

as far as I understand the SDL API, calling SDL_SetWindowDisplayMode followed
by calling SDL_SetWindowFullscreen(..., SDL_WINDOW_FULLSCREEN) is the correct
way to mode set / switch to fullscreen

this change restores that functionaliy when switching to SDL_WINDOW_FULLSCREEN,
but other cases are still modifying the display mode set by the user. rather
than modifying the display mode set by the user, it seems this logic inside of
KMSDRM_ReconfigureWindow should be pushed further down into KMSDRM_CreateSurfaces
(as it was originally) to only modify the final mode that's set (based on the
fullscreen flags), but not override the mode requested by the user
2021-06-01 15:32:02 -07:00
Anthony Pesch fd5de93a02 kmsdrm: fix gbm surface dimensions not matching the mode being set
commit 2067a7db8e introduced new surface_w and surface_h
variables which were passed to gbm_surface_create rather than the dimensions from the
drmModeModeInfo structure. commit 5105ecf8b1 further
refactored this code and no longer synchronized these variables inside
KMSDRM_SetDisplayMode, breaking it

this change removes the variables since they're seemingly redundant to begin with
2021-06-01 15:32:02 -07:00
Cacodemon345 99ef03b96e KMSDRM: Only use OpenBSD-specific defines on pre-6.9 releases 2021-04-20 19:44:55 -07:00
Cacodemon345 b0178fe518 KMSDRM: Report correct window position to the application 2021-04-13 16:01:44 -07:00
vanfanel 733b3278de [KMSDRM] Minor Vulkan code adjustments regarding pointers and display index. 2021-03-29 11:07:36 -07:00
Vanfanel 9de7eaf9ac [KMSDRM] Change error message. 2021-03-28 16:38:06 -07:00
Vanfanel 1ec60a38eb [KMSDRM] Remove unnecessary space. 2021-03-28 16:38:06 -07:00
Ozkan Sezer 5262b52ddd SDL_kmsdrmvideo.c: define EGL_PLATFORM_GBM_MESA if it's missing.
Fixes:		https://github.com/libsdl-org/SDL/issues/4232
2021-03-25 23:56:56 +03:00
vanfanel 5ac6bd5483 [KMSDRM] Ask for videomode on the correct display when creating a window. 2021-03-23 21:51:36 -07:00
Paul Cercueil c12f46b100 [KMSDRM] Fix segmentation fault
Deference the windata pointer *after* checking that it's non-NULL.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2021-03-22 22:20:01 +03:00
vanfanel 100166d7d7 [KMSDRM] Improve cursor management. 2021-03-22 10:48:02 -07:00
vanfanel cf7eef37b0 [KMSDRM] Better error handling: no more segfaults on window creation failure. 2021-03-20 11:03:52 -07:00
Vanfanel 4acd1dcad4 [KMSDRM] Improve the way to test if last window is being destroyed. 2021-03-18 11:04:28 -07:00
vanfanel 82ff6045fa [KMSDRM] Unload GL/EGL libs and destroy GBM only when we are destroying the last window. 2021-03-18 11:04:28 -07:00
vanfanel c35e71892e [KMSDRM] All non-vulkan windows have to be marked as OPENGL, not only the first created one. 2021-03-18 11:04:28 -07:00
vanfanel 281a7bdbb3 [KMSDRM] Make the gbm_init flag a viddata member to avoid GBM re-init when several displays are connected. 2021-03-18 11:04:28 -07:00
Vanfanel 7d1b9c9f15 [KMSDRM] Remove unneeded function calls and improve comments for future reference. 2021-03-17 11:29:13 -07:00
Cacodemon345 33598563b3 Fix coding style 2021-02-26 09:32:04 -08:00
Cacodemon345 69a600b00e Implement requested changes 2021-02-26 09:32:04 -08:00
Cacodemon345 0e35f0be1f Fix KMSDRM-related warnings 2021-02-26 09:32:04 -08:00