aboutsummaryrefslogtreecommitdiffstats
path: root/src/gbm/backends
Commit message (Collapse)AuthorAgeFilesLines
* gbm: Assert modifiers and count are copaceticBen Widawsky2017-04-091-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 <[email protected]> Signed-off-by: Ben Widawsky <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* gbm/dri: Check dri extension version before flush after unmapThomas Hellstrom2017-03-311-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: <[email protected]> Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Tested-by: Dylan Baker <[email protected]>
* gbm/dri: Flush after unmapThomas Hellstrom2017-03-291-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 <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* gbm: Use unsigned for BO offset getterDaniel Stone2017-03-231-9/+10
| | | | | | | | | | | | | | | | 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 <[email protected]> Cc: Ben Widawsky <[email protected]> Cc: Jason Ekstrand <[email protected]>
* gbm: Disallow INVALID modifiers returned upon image creationBen Widawsky2017-03-211-0/+32
| | | | | | | v2: Add a TODO about modifier validation (Jason) Signed-off-by: Ben Widawsky <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* gbm: Export a get modifiersBen Widawsky2017-03-151-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | This patch originally had i965 specific code and was named: commit 61cd3c52b868cf8cb90b06e53a382a921eb42754 Author: Ben Widawsky <[email protected]> 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 <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* gbm: Introduce modifiers into surface/bo creationBen Widawsky2017-03-151-8/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> References (v4): https://lists.freedesktop.org/archives/intel-gfx/2017-January/116636.html Signed-off-by: Ben Widawsky <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> (v1) Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Daniel Stone <[email protected]>
* gbm: Export a per plane getter for offsetBen Widawsky2017-03-091-0/+35
| | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Daniel Stone <[email protected]>
* gbm: Export a per plane getter for strideBen Widawsky2017-03-091-1/+34
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> (v1) Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Daniel Stone <[email protected]>
* gbm: Create a gbm_device getter for strideBen Widawsky2017-03-091-0/+7
| | | | | | | | | This will be used so we can query information per plane. Signed-off-by: Ben Widawsky <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Cc: Jason Ekstrand <[email protected]> Acked-by: Daniel Stone <[email protected]>
* gbm: Export a getter for per plane handlesBen Widawsky2017-03-091-0/+38
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Daniel Stone <[email protected]>
* gbm: Export a plane getter functionBen Widawsky2017-03-091-0/+27
| | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Daniel Stone <[email protected]>
* gbm: Explicitly disallow a planar dumb BOBen Widawsky2017-03-091-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 <[email protected]> Acked-by: Daniel Stone <[email protected]>
* gbm/dri: fix memory leaks in error pathEric Engestrom2017-01-271-1/+6
| | | | | | Signed-off-by: Eric Engestrom <[email protected]> [Emil Velikov: make sure it builds] Signed-off-by: Emil Velikov <[email protected]>
* gbm: request correct version of the DRI2_FENCE extensionLucas Stach2016-11-221-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" <[email protected]> Signed-off-by: Lucas Stach <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* dri: make use of loader_get_extensions_name(..) helperChristian Gmeiner2016-11-151-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 <[email protected]> Signed-off-by: Emil Velikov <[email protected]>
* Revert "dri: make use of dri_get_extensions_name(..) helper"Emil Velikov2016-11-151-3/+2
| | | | | | This reverts commit 1a21d21580965eff751414d140b3c176eeee2eb3. Pushed the wrong version of the patch.
* dri: make use of dri_get_extensions_name(..) helperChristian Gmeiner2016-11-151-2/+3
| | | | | Signed-off-by: Christian Gmeiner <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* gbm: set up the interop extension for egl/drmMarek Olšák2016-11-012-0/+2
| | | | | | | breaking libgbm -> libEGL ABI? Acked-by: Alex Deucher <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* loader: remove loader_get_driver_for_fd() driver_typeEmil Velikov2016-10-181-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 <[email protected]> Reviewed-by: Axel Davy <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* gbm: add a couple missing includesEric Engestrom2016-10-171-0/+2
| | | | | | | Needed for memset() and drmIoctl(). Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* gbm: rename gbm_dri_device::{,loader_}extensionsEmil Velikov2016-10-142-7/+7
| | | | | | | To align with the name used in the EGL and GLX loaders. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* gbm: return appropriate error when queryImage() failsNicholas Bishop2016-09-271-1/+2
| | | | | | | | | | | | | | 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: [email protected] Signed-off-by: Nicholas Bishop <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> (v1) [Emil Velikov: Split from larger patch, polish coding style, cc stable] Signed-off-by: Emil Velikov <[email protected]>
* gbm: fix potential NULL deref of mapImage/unmapImage.Chuanbo Weng2016-09-121-2/+3
| | | | | | | | | The mapImage/unmapImage functions of DRIimage extension can be NULL, so we should add additional check for them. Cc: <[email protected]> Signed-off-by: Chuanbo Weng <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* gbm: wire up fence extensionRob Clark2016-09-072-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 <[email protected]>
* gbm: add missing R8 and GR88 formatsRob Clark2016-09-071-1/+7
| | | | | Reviewed-by: Eric Engestrom <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* gbm: Add map/unmap functionsRob Herring2016-05-232-0/+65
| | | | | | | | | | | | | | | This adds map and unmap functions to GBM utilizing the DRIimage extension mapImage/unmapImage functions or existing internal mapping for dumb buffers. Unlike prior attempts, this version provides a region to map and usage flags for the mapping. The operation follows the same semantics as the gallium transfer_map() function. This was tested with GBM based gralloc on Android. Signed-off-by: Rob Herring <[email protected]> [Emil Velikov: drop no longer relevant hunk from commit message.] Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* gbm: rename gbm_dri_bo_{map,unmap} to gbm_dri_bo_{map,unmap}_dumbRob Herring2016-05-232-4/+4
| | | | | | | | | In preparation to add public map/unmap functions, rename the existing gbm_dri_bo_{map,unmap} functions to indicate that they are only for dumb buffers. Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* gbm: add Android gallium_dri.so library loading supportRob Herring2016-05-231-0/+9
| | | | | | | | | GBM needs the same special gallium_dri.so loading as EGL for Android, so copy over the same hunk from the EGL code. Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* gbm: add GBM_FORMAT_XBGR8888 format supportRob Herring2016-04-211-0/+7
| | | | | | | | | Add GBM_FORMAT_XBGR8888/__DRI_IMAGE_FORMAT_XBGR8888 format support which is needed for Android. Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* gbm: convert gbm bo format to fourcc format on dma-buf importRay Strode2015-09-151-1/+17
| | | | | | | | | | | | | | | | | | | | | At the moment if a gbm buffer is imported and the gbm buffer has an old-style GBM_BO_FORMAT format, the import will crash, since it's passed directly to DRI functions that expect a fourcc format (as provided by the newer GBM_FORMAT definitions) This commit addresses the problem in two ways: 1) it prevents invalid formats from leading to a crash by returning EINVAL if the image couldn't be created 2) it translates GBM_BO_FORMAT formats into the comparable GBM_FORMAT formats. Reference: https://bugzilla.gnome.org/show_bug.cgi?id=753531 CC: "10.6 11.0" <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* gbm: dlopen libglapi so gbm_create_device worksFrank Henigman2015-06-231-0/+8
| | | | | | | | | | | | | Dri driver libs are not linked to pull in libglapi so gbm_create_device() fails when it tries to dlopen them (unless the application is linked with something that does pull in libglapi, like libGL). Until dri drivers can be fixed properly, dlopen libglapi before trying to dlopen them. Cc: "10.5 10.6" <[email protected]> Signed-off-by: Frank Henigman <[email protected]> [Emil Velikov: Drop misleading bugzilla link, mention that libname differs] Reviewed-by: Emil Velikov <[email protected]>
* gbm: Add GBM_BO_USE_LINEAR flagFlora Cui2015-04-161-0/+2
| | | | | | | Signed-off-by: Flora Cui <[email protected]> Reviewed-by: Jammy Zhou <[email protected]> Reviewed-by: Michel Dänzer <[email protected]> Reviewed-by: Alex Deucher <[email protected]>
* gbm/dri: Fix const confusionKristian Høgsberg2015-01-161-4/+3
| | | | | | | | The driver name is no longer const, it's always allocated dynamically one way or another. Drop const from dri_screen_create_dri2 driver_name argument to avoid warning. Signed-off-by: Kristian Høgsberg <[email protected]>
* dri/kms: Always zero out struct drm_mode_create_dumbThierry Reding2014-11-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The DRM_IOCTL_MODE_CREATE_DUMB (and others) IOCTL isn't very rigorously specified, which has the effect that some kernel drivers do not consider the .pitch and .size fields of struct drm_mode_create_dumb outputs only. Instead they will use these as lower bounds and overwrite them only if the values that they compute are larger than what userspace provided. This works if and only if userspace initializes the fields explicitly to either 0 or some meaningful value. However, if userspace just leaves the values uninitialized and the struct drm_mode_create_dumb is allocated on the stack for example, the driver may try to overallocate buffers. Fortunately most userspace does zero out the structure before passing it to the IOCTL, but there are rare exceptions. Mesa is one of them. In an attempt to rectify this situation, kernel drivers are being updated to not use the .pitch and .size fields as inputs. However in order to fix the issue with older kernels, make sure that Mesa always zeros out the structure as well. Future IOCTLs should be more rigorously defined so that structures can be validated and IOCTLs rejected if output fields aren't set to zero. Signed-off-by: Thierry Reding <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* gbm/dri: cleanup memory leak on teardownEmil Velikov2014-11-071-0/+3
| | | | | | | | During teardown we free the driver_configs list pointer, but we forget to deallocate each config in that list. Signed-off-by: Emil Velikov <[email protected]> Reviewed-and-tested-by: Kenneth Graunke <[email protected]>
* gbm: Log at least one dlerror() when we fail to open any drivers.Eric Anholt2014-07-301-0/+1
| | | | | | | | | | | | We don't want to log every single error (such as all the ones where the file wasn't even present in our list of search paths), but if you didn't find any driver, then seeing at least one error is useful (since the common case as a developer is a single DEFAULT_DRIVER_DIR or GBM_DRIVERS_PATH entry). v2: Rebase on swrast changes. Reviewed-by: Michel Dänzer <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* gbm: Fix a debug log messageEric Anholt2014-07-301-1/+1
| | | | | Reviewed-by: Michel Dänzer <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* gallium: Add a dumb drm/kms winsys backed swrast providerGiovanni Campagna2014-07-301-4/+34
| | | | | | | | | | | | | | | | | | | | | | Add a new winsys and target that can be used with a dri2 state tracker and loader instead of drisw. This allows to use gbm as a dri2/image loader and avoid the extra copy from the backbuffer to the shadow frontbuffer. The new driver is called "kms_swrast", and is loaded by gbm as a fallback, because it is only useful with the gbm platform (as no buffer sharing is possible) To force select the driver set the environment variable GBM_ALWAYS_SOFTWARE [Emil Velikov] - Rebase on top of gallium megadriver. - s/text/test/ in configure.ac (Spotted by Andreas Pokorny). - Add scons support for winsys/sw/kms-dri and fix the build. - Provide separate DriverAPI, due to different InitScreen hook. Signed-off-by: Emil Velikov <[email protected]>
* Add support for swrast to the DRM EGL platformGiovanni Campagna2014-07-302-27/+233
| | | | | | | | | | | | | | | | | | | | Turn GBM into a swrast loader (providing putimage/getimage backed by a dumb KMS buffer). This allows to run KMS+DRM GL applications (such as weston or mutter-wayland) unmodified on cards that don't have any client side HW acceleration component but that can do modeset (examples include simpledrm and qxl) [Emil Velikov] - Fix make check. - Split dri_open_driver() from dri_load_driver(). - Don't try to bind the swrast extensions when using dri. - Handle swrast->CreateNewScreen() failure. - strdup the driver_name, as it's free'd at destruction. - s/LIBGL_ALWAYS_SOFTWARE/GBM_ALWAYS_SOFTWARE/ - Move gbm_dri_bo_map/unmap to gbm_driiint.h. - Correct swrast fallback logic. Signed-off-by: Emil Velikov <[email protected]>
* gbm: Search LIBGL_DRIVERS_PATH if GBM_DRIVERS_PATH is not setDylan Baker2014-07-241-1/+11
| | | | | | | | | | | | | | | | | | | | | The GBM_DRIVERS_PATH environment variable is not documented, and only used to set the location of gbm drivers, while LIBGL_DRIVERS_PATH is used for everything else, and is documented. Generally this split leads to confusion as to why gbm doesn't work. This patch will read LIBGL_DRIVERS_PATH as a fallback if GBM_DRIVERS_PATH is not set. The comments clearly indicate that using LIBGL_DRIVERS_PATH is preferred over GBM_DRIVERS_PATH. v2: - Use GBM_DRIVERS_PATH as a fallback v3: [[email protected]] - Make LIBGL_DRIVERS_PATH the fallback Signed-off-by: Dylan Baker <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* gbm: Remove 64x64 restriction from GBM_BO_USE_CURSORMichel Dänzer2014-06-121-4/+4
| | | | | | | | | | GBM_BO_USE_CURSOR_64X64 is kept so that existing users of GBM continue to build, but it no longer rejects widths or heights other than 64. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79809 Reviewed-by: Alex Deucher <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* gbm: cleanup __DRI*extension handlingEmil Velikov2014-04-282-14/+18
| | | | | | | | Use designated initialisers, store all extension pointers as const and use a const __DRIextensions array over assigning each element individually. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* gbm: Set errno on errorsAnder Conselvan de Oliveira2014-04-251-8/+28
| | | | | | | | | This should give the caller some information of what called the error. For the gbm_bo_import() case, for instance, it is possible to know if the import is not supported or the error was caused by an invalid parameter. Reviewed-by: Emil Velikov <[email protected]>
* gbm/dri: Fix out-of-memory error path in dri_device_create()Ander Conselvan de Oliveira2014-04-251-0/+2
| | | | | Cc: "10.0" "10.1" <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* gbm: Add import from fdKristian Høgsberg2014-04-011-2/+19
| | | | | | | Add a new import type that lets us create a gbm bo from a DMA-BUF file descriptor. Signed-off-by: Kristian Høgsberg <[email protected]>
* gbm: Add gbm_bo_get_fd()Kristian Høgsberg2014-04-011-0/+16
| | | | | | Add gbm function to get a DMA-BUF file descriptor for a gbm bo. Signed-off-by: Kristian Høgsberg <[email protected]>
* gbm/dri: Fixed buffer object memory leak in case of failure.Siavash Eliasi2014-02-281-2/+6
| | | | Reviewed-by: Kristian Høgsberg <[email protected]>
* gbm: explicitly set __DRIimageLoaderExtension membersEmil Velikov2014-02-231-3/+4
| | | | | Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* gbm: explicitly set __DRIdri2LoaderExtension membersEmil Velikov2014-02-231-4/+5
| | | | | Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Ian Romanick <[email protected]>y