summaryrefslogtreecommitdiff
path: root/src/gbm
AgeCommit message (Collapse)AuthorFilesLines
2017-06-15gbm: implement FD import with modifierLucas Stach1-0/+54
This implements a way to import FDs with modifiers on plain GBM devices, without the need to go through EGL. This is mostly to the benefit of gbm_gralloc, which can keep its dependencies low. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Tested-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-15gbm: add API to to import FD with modifierLucas Stach1-0/+12
This allows to import an FD with an explicit modifier passed through userspace protocols. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Tested-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-05-29gbm: manage only the required set of DRI extensionsEmil Velikov2-2/+0
Currently GBM attempts to know all the extensions that might be required by EGL/DRM [at some later stage]. That is a bit unclear and we often forget to update GBM as EGL gets attention. To avoid that, simply let EGL manage it's own required extensions based on the base primitive (screen) we provide it. v2: Rework the approach - GBM should not dive into EGL/DRM. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Tested-by: Rob Herring <robh@kernel.org>
2017-05-29gbm: remove unneeded gbm_drm_device abstractionEmil Velikov4-74/+27
Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Tested-by: Rob Herring <robh@kernel.org>
2017-05-29gbm: move gbm_drm_device::driver_name to gbm_dri_deviceEmil Velikov3-10/+10
The former already keeps track of the DRI module opened, based on the driver_name provided. So let's keep them together. As a nice bonus this Will allows us to remove the gbm_drm_device all together with next patch. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Tested-by: Rob Herring <robh@kernel.org>
2017-05-29gbm: remove "struct gbm_drm_bo" abstractionEmil Velikov3-31/+27
The struct is a simple wraper around gbm_bo and brings no actual benefit. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Tested-by: Rob Herring <robh@kernel.org>
2017-05-29gbm: remove unused gbm_dri_device::loaderEmil Velikov1-1/+0
Introduced back in 2012 with fd6acb97fb9 ("gbm: Create hooks for dri2_loader_extension in dri backend") and hasn't been used since. Seemingly a copy/paste thinko from development stage. Cc: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com> Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Tested-by: Rob Herring <robh@kernel.org>
2017-05-19configure: set HAVE_foo_PLATFORM as applicableEmil Velikov1-1/+0
Rather than having multiple places that define the macros, do it just once in configure. Makes existing code a bit shorter and easier to manage as we fix the VL targets with follow-up commits. Cc: mesa-stable@lists.freedesktop.org Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2017-05-02gbm/dri: Fix sign-extension in modifier queryDaniel Stone1-1/+1
When we were assembling the unsigned 64-bit query return from its two signed 32-bit component parts, the lower half was getting sign-extended into the top half. Be more explicit about what we want to do. Fixes gbm_bo_get_modifier() returning ((1 << 64) - 1) rather than ((1 << 56) - 1), i.e. DRM_FORMAT_MOD_INVALID. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
2017-04-09gbm: Assert modifiers and count are copaceticBen Widawsky1-0/+3
The API/entry point in mesa already checks the correct behavior, however, it's possible to be handled by another implementation and those implementations should not be able to abuse a weird combination of count and pointer. This fixes CID 1403193 Cc: Mark Janes <mark.a.janes@intel.com> Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-31gbm/dri: Check dri extension version before flush after unmapThomas Hellstrom1-2/+3
The commit mentioned below required the __DRI2FlushExtension to have version 4 or above, for GBM functionality. That broke GBM with some classic dri drivers. Relax that requirement so that we only flush after unmap if we have version 4 or above. Drivers that require the flush for correct functionality should implement the desired version. Fixes: ba8df228 ("gbm/dri: Flush after unmap") Cc: <mesa-stable@lists.freedesktop.org> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Tested-by: Dylan Baker <dylan@pnwbakers.com>
2017-03-29gbm/dri: Flush after unmapThomas Hellstrom1-1/+8
Drivers may queue dma operations on the context at unmap time so we need to flush to make sure the data gets to the bo. Ideally the application would take care of this, but since there appears to be no exported gbm flush functionality we need to explicitly flush at unmap time. This fixes a problem where kmscube on vmwgfx in rgba textured mode would render using an uninitialized texture rather than the intended rgba pattern. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2017-03-23gbm: Use unsigned for BO offset getterDaniel Stone4-12/+13
The actual offset returned is uint32_t, however int64_t was used as the return type from gbm_bo_get_offset to allow negative returns to signal errors to the caller. In case of an error getting the offset, the user will also be unable to get the handle/FD, and thus have nothing to offset into. This means that returning 0 as an error value is harmless, allowing us to change the return type to uint32_t in order to avoid signed/unsigned confusion in callers. Signed-off-by: Daniel Stone <daniels@collabora.com> Cc: Ben Widawsky <ben@bwidawsk.net> Cc: Jason Ekstrand <jason@jlekstrand.net>
2017-03-21gbm: Disallow INVALID modifiers returned upon image creationBen Widawsky1-0/+32
v2: Add a TODO about modifier validation (Jason) Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-15gbm: Export a get modifiersBen Widawsky5-0/+66
This patch originally had i965 specific code and was named: commit 61cd3c52b868cf8cb90b06e53a382a921eb42754 Author: Ben Widawsky <ben@bwidawsk.net> Date: Thu Oct 20 18:21:24 2016 -0700 gbm: Get modifiers from DRI To accomplish this, two new query tokens are added to the extension: __DRI_IMAGE_ATTRIB_MODIFIER_UPPER __DRI_IMAGE_ATTRIB_MODIFIER_LOWER The query extension only supported 32b queries, and modifiers are 64b, so we needed two of them. NOTE: The extension version is still set to 13, so none of this will actually be called. v2: Error handling of queryImage (Emil) Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-03-15gbm: Introduce modifiers into surface/bo creationBen Widawsky5-12/+116
The idea behind modifiers like this is that the user of GBM will have some mechanism to query what properties the hardware supports for its BO or surface. This information is directly passed in (and stored) so that the DRI implementation can create an image with the appropriate attributes. A getter() will be added later so that the user GBM will be able to query what modifier should be used. Only in surface creation, the modifiers are stored until the BO is actually allocated. In regular buffer allocation, the correct modifier can (will be, in future patches be chosen at creation time. v2: Make sure to check if count is non-zero in addition to testing if calloc fails. (Daniel) v3: Remove "usage" and "flags" from modifier creation. Requested by Kristian. v4: Take advantage of the "INVALID" modifier added by the GET_PLANE2 series. v5: Don't bother with storing modifiers for gbm_bo_create because that's a synchronous operation and we can actually select the correct modifier at create time (done in a later patch) (Jason) v6: Make modifier condition outside the check so that dri_use will work properly (Jason) Cc: Kristian Høgsberg <krh@bitplanet.net> References (v4): https://lists.freedesktop.org/archives/intel-gfx/2017-January/116636.html Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (v1) Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Acked-by: Daniel Stone <daniels@collabora.com>
2017-03-10gbm/gbm-symbols-check: do not mandate bashEmil Velikov1-1/+1
Analogous to previous commit. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Andreas Boll <andreas.boll.dev@gmail.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-03-09gbm: Export a per plane getter for offsetBen Widawsky5-0/+55
Unlike stride, there was no previous offset getter, so it can be right on the first try. v2: Return EINVAL when plane is greater than total planes to make it match the similar APIs. Avoid leak after fromPlanar (Daniel) Make sure when getting offsets we consider dumb images (Daniel) v3: Use Jason's recommendation for handling the non-planar case. v4: Return int64_t so we can get real errors v5: Add an assertion for dumb BOs (Jason) Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Acked-by: Daniel Stone <daniels@collabora.com>
2017-03-09gbm: Export a per plane getter for strideBen Widawsky4-2/+52
v2: Preserve legacy behavior when plane is 0 (Jason Ekstrand) EINVAL when input plane is greater than total planes (Jason Ekstrand) Don't leak the image after fromPlanar (Daniel) Move bo->image check below plane count preventing bad index succeeding (Daniel) v3: Fix DRIimage leak (using Jason's recommended change) Make plane 0 return planar stride. This might break legacy behavior (Jason) v4: Move bogus hunk for get_handle_for_plane to the right patch (Jason) Fix error handling path to be cleaner (Jason) v5: Add assert for dumb BOs to make sure plane == 0 (Jason) Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (v1) Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Acked-by: Daniel Stone <daniels@collabora.com>
2017-03-09gbm: Create a gbm_device getter for strideBen Widawsky3-1/+9
This will be used so we can query information per plane. Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Cc: Jason Ekstrand <jason@jlekstrand.net> Acked-by: Daniel Stone <daniels@collabora.com>
2017-03-09gbm: Export a getter for per plane handlesBen Widawsky5-0/+61
v2: Make the error return be -1 instead of 0 because I think 0 is actually valid. v3: Set errno to EINVAL when the specified plane is above the total planes. (Jason Ekstrand) Return the bo's handle if there is no image ie. for dumb images like cursor (Daniel) v4: - Add assertions about plane == 0 (Jason) - Add a comment about new restriction on planar dumb bo which is not an earlier patch in the series. - Correctly refactor from v2 in this patch; it ended up rebased into the wrong patch. Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Acked-by: Daniel Stone <daniels@collabora.com>
2017-03-09gbm: Export a plane getter functionBen Widawsky5-0/+42
This will be used by clients that need to know the number of planes allocated for them on behalf of the GL or other API. The best current example of this is when an extra "plane" is allocated to store compression data for the primary plane. v2: Return 1 for cases where there is no image, ie. dumb bo (Daniel) Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Acked-by: Daniel Stone <daniels@collabora.com>
2017-03-09gbm: Explicitly disallow a planar dumb BOBen Widawsky1-0/+31
As more GBM functionality support planes is being evaluated, it becomes clear that a dumb bo can never actually be planar. It's questionable whether it was ever feasible to do this, and later functionality will implicitly assume a dumb BO is non-planar. v2: Include stdbool.h Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Acked-by: Daniel Stone <daniels@collabora.com>
2017-01-27gbm/dri: fix memory leaks in error pathEric Engestrom1-1/+6
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com> [Emil Velikov: make sure it builds] Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2017-01-23gbm: Fix width height getters return type (trivial)Ben Widawsky1-2/+2
v2: Other way round... to make consistent, make both return type have the fixed width - uint32_t. Cc: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Acked-by: Daniel Stone <daniels@collabora.com>
2017-01-23gbm: Move getters to match order in header file (trivial)Ben Widawsky1-11/+11
Other things are out of order, but I need to add a getter so I'm just fixing those. This helps people adding to GBM know where the right place to put things is. Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Acked-by: Daniel Stone <daniels@collabora.com>
2016-11-22gbm: request correct version of the DRI2_FENCE extensionLucas Stach1-1/+1
There is no version 2 of the DRI2_FENCE extension. So only a request for version 1 has a chance to succeed. Fixes: 74b1969d717f (gbm: wire up fence extension) Cc: "13.0" <mesa-stable@lists.freedesktop.org> Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-21gbm: automake: remove unused definesEmil Velikov1-2/+0
Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
2016-11-15dri: make use of loader_get_extensions_name(..) helperChristian Gmeiner1-2/+2
Changes since v1: - removed not needed includes - use the loader version of the helper v2 [Emil Velikov] - Keep the includes - they are required. Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-15Revert "dri: make use of dri_get_extensions_name(..) helper"Emil Velikov1-3/+2
This reverts commit 1a21d21580965eff751414d140b3c176eeee2eb3. Pushed the wrong version of the patch.
2016-11-15dri: make use of dri_get_extensions_name(..) helperChristian Gmeiner1-2/+3
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-01gbm: set up the interop extension for egl/drmMarek Olšák2-0/+2
breaking libgbm -> libEGL ABI? Acked-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-10-18loader: remove loader_get_driver_for_fd() driver_typeEmil Velikov1-1/+1
Reminiscent from the pre-loader days, were we had multiple instances of the loader logic in separate places and one could build a "GALLIUM_ONLY" version. Since that is no longer the case and the loaders (glx/egl/gbm) do not (and should not) require to know any classic/gallium specific we can drop the argument and the related code. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-18gbm: remove superfluous/incorrect udev commentEmil Velikov1-1/+0
The gbm_device_get_backend_name() provides an (somewhat) internal name of the implementation/backend used. Is has nothing to do with the udev, one cannot and should not attempt to derive the name from it. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-17gbm: add a couple missing includesEric Engestrom1-0/+2
Needed for memset() and drmIoctl(). Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2016-10-14gbm: rename gbm_dri_device::{,loader_}extensionsEmil Velikov2-7/+7
To align with the name used in the EGL and GLX loaders. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2016-09-27gbm: return appropriate error when queryImage() failsNicholas Bishop2-2/+4
Change gbm_dri_bo_get_fd to check the return value of queryImage and return -1 (an invalid file descriptor) if an error occurs. Update the comment for gbm_bo_get_fd to return -1, since (apart from the above) we've already return -1 on error. Cc: mesa-stable@lists.freedesktop.org Signed-off-by: Nicholas Bishop <nbishop@neverware.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (v1) [Emil Velikov: Split from larger patch, polish coding style, cc stable] Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-09-14gbm: remove left-over arrayEric Engestrom1-12/+0
e7c8c85785b3a8f29e3f ("gbm: Removed unused function.") forgot to remove the global array used only by that function. Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-09-12gbm: fix potential NULL deref of mapImage/unmapImage.Chuanbo Weng1-2/+3
The mapImage/unmapImage functions of DRIimage extension can be NULL, so we should add additional check for them. Cc: <mesa-stable@lists.freedesktop.org> Signed-off-by: Chuanbo Weng <chuanbo.weng@intel.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-09-07gbm: wire up fence extensionRob Clark2-1/+4
v2: make fence extension optional to not break non-i965 classic drivers, and move __DRI2_FENCE into core extensions, based on comments from Emil Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-09-07gbm: add missing R8 and GR88 formatsRob Clark2-1/+13
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-08-03gbm: Correct bo_import documentation (trivial)Ben Widawsky1-1/+1
Missed here: commit a43d286ef7ff65087b1f051d071b829ca7b02073 Author: Kristian Høgsberg <krh@bitplanet.net> Date: Fri Mar 28 10:17:11 2014 -0700 gbm: Add import from fd Cc: Kristian Høgsberg <krh@bitplanet.net> Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
2016-08-01gbm: Removed unused function.Ben Widawsky2-29/+0
AFAICT, it's never been used. It was briefly nudged in the right direction here: commit 10e5ffd4961055ebba5be4d85a93cc66cdd5a635 Author: Emil Velikov <emil.l.velikov@gmail.com> Date: Sat Jan 25 17:19:10 2014 +0000 gbm: do not export _gbm_mesa_get_device Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
2016-07-26mesa: Use AC_HEADER_MAJOR to include correct header for major().Matt Turner1-1/+6
Gentoo has been smoke testing an upcoming change to glibc. Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=580392
2016-06-23gbm: Fix commentsGurkirpal Singh1-2/+2
Reviewed-by: Chad Versace <chad.versace@intel.com>
2016-06-23gbm: doc fixesEric Engestrom2-4/+4
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Chad Versace <chad.versace@intel.com>
2016-06-23Remove wrongly repeated words in commentsGiuseppe Bilotta1-1/+1
Clean up misrepetitions ('if if', 'the the' etc) found throughout the comments. This has been done manually, after grepping case-insensitively for duplicate if, is, the, then, do, for, an, plus a few other typos corrected in fly-by v2: * proper commit message and non-joke title; * replace two 'as is' followed by 'is' to 'as-is'. v3: * 'a integer' => 'an integer' and similar (originally spotted by Jason Ekstrand, I fixed a few other similar ones while at it) Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Reviewed-by: Chad Versace <chad.versace@intel.com>
2016-06-13Android: move libdrm settings to top-level Android.common.mkRob Herring1-1/+0
Fix warnings like these due to HAVE_LIBDRM being inconsistently defined: external/libdrm/include/drm/drm.h:839:30: warning: redefinition of typedef 'drm_clip_rect_t' is a C11 feature [-Wtypedef-redefinition] typedef struct drm_clip_rect drm_clip_rect_t; HAVE_LIBDRM needs to be set project wide to fix this. This change also harmlessly links libdrm with everything, but simplifies the makefiles a bit. Signed-off-by: Rob Herring <robh@kernel.org> Acked-by: Emil Velikov <emil.velikov@collabora.com>
2016-05-23gbm: remove define _DEFAULT_SOURCEEmil Velikov1-2/+0
The build systems already add this as applicable. There's no need to have this in the source file. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2016-05-23gbm: remove define _BSD_SOURCEEmil Velikov1-1/+0
The build systems already add this as applicable. There's no need to have this in the source file. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>