Commit Graph

139 Commits

Author SHA1 Message Date
Rob Herring a3d98ca62f Android: use symlinks for driver loading
Instead of having special driver loading logic for Android, create
symlinks to gallium_dri.so so we can use the standard loading logic.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Rob Herring <robh@kernel.org>
2017-06-29 09:09:49 -05:00
Lucas Stach 4026744fcb gbm: implement FD import with modifier
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-15 10:43:36 +01:00
Emil Velikov 46cc022d5d gbm: manage only the required set of DRI extensions
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-29 16:50:12 +01:00
Emil Velikov 628af2bc96 gbm: remove unneeded gbm_drm_device abstraction
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Rob Herring <robh@kernel.org>
2017-05-29 16:49:47 +01:00
Emil Velikov e183c55275 gbm: move gbm_drm_device::driver_name to gbm_dri_device
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-29 16:49:44 +01:00
Emil Velikov 2204ea6464 gbm: remove "struct gbm_drm_bo" abstraction
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-29 16:49:42 +01:00
Emil Velikov b5ab59ce37 gbm: remove unused gbm_dri_device::loader
Introduced back in 2012 with fd6acb97fb ("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-29 16:49:39 +01:00
Daniel Stone 80ac89a952 gbm/dri: Fix sign-extension in modifier query
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-05-02 19:55:13 +01:00
Ben Widawsky 6e907812f8 gbm: Assert modifiers and count are copacetic
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-04-09 09:29:57 -07:00
Thomas Hellstrom 18e2aa063c gbm/dri: Check dri extension version before flush after unmap
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-31 10:25:46 +02:00
Thomas Hellstrom ba8df2286a gbm/dri: Flush after unmap
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-29 09:17:21 +02:00
Daniel Stone 378025ca8b gbm: Use unsigned for BO offset getter
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-23 15:28:41 +00:00
Ben Widawsky 2a16de9e4b gbm: Disallow INVALID modifiers returned upon image creation
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-21 14:48:11 -07:00
Ben Widawsky 8378c576ab gbm: Export a get modifiers
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-15 10:36:05 -07:00
Ben Widawsky 63bd2ae745 gbm: Introduce modifiers into surface/bo creation
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-15 10:36:05 -07:00
Ben Widawsky 2ee34bd5dc gbm: Export a per plane getter for offset
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-09 15:35:44 -08:00
Ben Widawsky 7f6209e46f gbm: Export a per plane getter for stride
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-09 15:35:44 -08:00
Ben Widawsky ed4cf2440d gbm: Create a gbm_device getter for stride
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-09 15:35:44 -08:00
Ben Widawsky f9567ab435 gbm: Export a getter for per plane handles
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-09 15:35:44 -08:00
Ben Widawsky 42eacddfc0 gbm: Export a plane getter function
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-09 15:35:44 -08:00
Ben Widawsky 770b06588f gbm: Explicitly disallow a planar dumb BO
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-03-09 15:35:44 -08:00
Eric Engestrom 5f301fe2e6 gbm/dri: fix memory leaks in error path
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-27 17:56:58 +00:00
Lucas Stach d9a3ad94ca gbm: request correct version of the DRI2_FENCE extension
There is no version 2 of the DRI2_FENCE extension. So only a request
for version 1 has a chance to succeed.

Fixes: 74b1969d71 (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-22 15:56:44 +00:00
Christian Gmeiner 0c73a3b7d0 dri: make use of loader_get_extensions_name(..) helper
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-15 18:15:16 +00:00
Emil Velikov fb10c89877 Revert "dri: make use of dri_get_extensions_name(..) helper"
This reverts commit 1a21d21580.

Pushed the wrong version of the patch.
2016-11-15 18:15:15 +00:00
Christian Gmeiner 1a21d21580 dri: make use of dri_get_extensions_name(..) helper
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-15 15:56:52 +00:00
Marek Olšák 6b309f7368 gbm: set up the interop extension for egl/drm
breaking libgbm -> libEGL ABI?

Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-01 22:33:13 +01:00
Emil Velikov af7abc512c loader: remove loader_get_driver_for_fd() driver_type
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-18 17:06:29 +01:00
Eric Engestrom e9864f93c6 gbm: add a couple missing includes
Needed for memset() and drmIoctl().

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
2016-10-17 08:47:38 -07:00
Emil Velikov d5342c6ff2 gbm: rename gbm_dri_device::{,loader_}extensions
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-10-14 12:45:54 +01:00
Nicholas Bishop 2d05ba2ca0 gbm: return appropriate error when queryImage() fails
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-27 13:37:21 +01:00
Chuanbo Weng 9a1eb54237 gbm: fix potential NULL deref of mapImage/unmapImage.
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-12 16:52:55 +01:00
Rob Clark 74b1969d71 gbm: wire up fence extension
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-07 11:54:00 -04:00
Rob Clark b4e88b500c gbm: add missing R8 and GR88 formats
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-09-07 11:30:41 -04:00
Rob Herring 8aeb6d768b gbm: Add map/unmap functions
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 <robh@kernel.org>
[Emil Velikov: drop no longer relevant hunk from commit message.]
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2016-05-23 12:07:46 +01:00
Rob Herring 0a4275b534 gbm: rename gbm_dri_bo_{map,unmap} to gbm_dri_bo_{map,unmap}_dumb
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 <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2016-05-23 12:07:46 +01:00
Rob Herring 64a005e3ee gbm: add Android gallium_dri.so library loading support
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 <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2016-05-23 12:07:46 +01:00
Rob Herring 1ba203a085 gbm: add GBM_FORMAT_XBGR8888 format support
Add GBM_FORMAT_XBGR8888/__DRI_IMAGE_FORMAT_XBGR8888 format support which
is needed for Android.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2016-04-21 14:45:56 +01:00
Ray Strode 4bf151e662 gbm: convert gbm bo format to fourcc format on dma-buf import
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" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2015-09-15 12:27:45 +01:00
Frank Henigman 828f13330c gbm: dlopen libglapi so gbm_create_device works
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" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Frank Henigman <fjhenigman@google.com>
[Emil Velikov: Drop misleading bugzilla link, mention that libname differs]
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-06-23 17:08:05 +01:00
Flora Cui f78b2c432f gbm: Add GBM_BO_USE_LINEAR flag
Signed-off-by: Flora Cui <flora.cui@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-04-16 15:49:15 +09:00
Kristian Høgsberg 9bf2c7166a gbm/dri: Fix const confusion
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 <krh@bitplanet.net>
2015-01-16 14:29:40 -08:00
Thierry Reding 631090e155 dri/kms: Always zero out struct drm_mode_create_dumb
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 <treding@nvidia.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-11-16 01:03:40 +00:00
Emil Velikov f6432c4d72 gbm/dri: cleanup memory leak on teardown
During teardown we free the driver_configs list pointer, but we forget
to deallocate each config in that list.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-and-tested-by: Kenneth Graunke <kenneth@whitecape.org>
2014-11-07 18:32:07 +00:00
Eric Anholt 1da4bb5b97 gbm: Log at least one dlerror() when we fail to open any drivers.
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 <michel.daenzer@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-07-30 22:31:30 -07:00
Eric Anholt ef81ce9909 gbm: Fix a debug log message
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-07-30 22:30:19 -07:00
Giovanni Campagna 3b176c441b gallium: Add a dumb drm/kms winsys backed swrast provider
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 <emil.l.velikov@gmail.com>
2014-07-30 16:33:09 +01:00
Giovanni Campagna 8430af5ebe Add support for swrast to the DRM EGL platform
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 <emil.l.velikov@gmail.com>
2014-07-30 16:33:09 +01:00
Dylan Baker bf1247936a gbm: Search LIBGL_DRIVERS_PATH if GBM_DRIVERS_PATH is not set
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: [jordan.l.justen@intel.com] - Make LIBGL_DRIVERS_PATH the fallback

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-07-24 23:15:06 -07:00
Michel Dänzer be5e5b6c93 gbm: Remove 64x64 restriction from GBM_BO_USE_CURSOR
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 <alexander.deucher@amd.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-06-12 16:13:39 +09:00
Emil Velikov 5457caa58c gbm: cleanup __DRI*extension handling
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 <emil.l.velikov@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-04-28 19:13:38 +01:00
Ander Conselvan de Oliveira 49964fa28b gbm: Set errno on errors
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 <emil.l.velikov@gmail.com>
2014-04-25 21:16:45 +01:00
Ander Conselvan de Oliveira aa91fe1c09 gbm/dri: Fix out-of-memory error path in dri_device_create()
Cc: "10.0" "10.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-04-25 21:16:00 +01:00
Kristian Høgsberg a43d286ef7 gbm: Add import from fd
Add a new import type that lets us create a gbm bo from a
DMA-BUF file descriptor.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2014-04-01 12:27:26 -07:00
Kristian Høgsberg f54f5891be gbm: Add gbm_bo_get_fd()
Add gbm function to get a DMA-BUF file descriptor for a gbm bo.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2014-04-01 12:27:13 -07:00
Siavash Eliasi f4416323fc gbm/dri: Fixed buffer object memory leak in case of failure.
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-02-28 15:57:15 -08:00
Emil Velikov 4e229a6e86 gbm: explicitly set __DRIimageLoaderExtension members
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-02-23 16:42:17 +00:00
Emil Velikov 8b45bc0ad5 gbm: explicitly set __DRIdri2LoaderExtension members
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>y
2014-02-23 16:42:16 +00:00
Emil Velikov fae0dfa59b gbm: use the loader util lib
Additionally this commit removes the following exported functions

   _gbm_udev_device_new_from_fd()
   _gbm_fd_get_device_name()
   _gbm_log()

All three were erroneously marked as exported since their inception.
Neither of them has ever been a part of the API thus there should be
no users of them.

Cc: Chad Versace <chad.versace@linux.intel.com>
Cc: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-01-18 18:47:48 +00:00
Quanxian Wang 1413a09f34 egl: break instead of looping after driver is found
Stop searching for a driver after success.

Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
Reviewed-By: Gong, Zhigang <zhigang.gong@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2013-12-19 12:44:11 -07:00
Maarten Lankhorst 5455c818b5 gbm/dri: hide extension loader symbols
They should not be exposed.

Cc: "10.0" <mesa-stable@lists.freedesktop.org>
2013-11-25 13:13:47 +01:00
Kristian Høgsberg 04e3ef00db gbm: Add support for __DRIimage based getBuffers when available
This lets us allocate color buffers as __DRIimages and pass them into
the driver instead of having to create a __DRIbuffer with the flink
that requires.

With this patch, we can now run gbm on render-nodes.  A render-node is a
drm device that doesn't support modesetting and all the legacy DRI ioctls.
flink is also not supported, but now that gbm doesn't need flink, we can
run piglit on head-less gbm or head-less GPGPU.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Tested-by: Jordan Justen <jordan.l.justen@intel.com>
Cc: "10.0" <mesa-stable@lists.freedesktop.org>
2013-11-12 16:01:40 -08:00
Eric Anholt f93533d118 dri: Pass in the dlsym()ed driver extension to screen creation.
This will allow a megadrivers build to reference the actual driver being
loaded from the shared dri_util screen creation code.

v2: Fix indentation, fallback case in EGL (review by Emil).

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com> (v1)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2013-10-24 14:04:20 -07:00
Eric Anholt 67caf36489 gbm: Add support for the new __driDriverGetExtensions interface.
v2: Fix uninitialized variable use in the old-ABI case.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com> (v1)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2013-10-24 14:04:20 -07:00
Kristian Høgsberg 1a2a30ba20 gbm-dri: Support importing RGB565 buffers 2013-10-21 20:56:17 -07:00
Kristian Høgsberg 6e444a72c1 gbm: Add support for gbm bos and surfaces using GBM_FORMAT_ARGB2101010
We can now add GBM support for the 10 bit/channel formats which lets us
create a gbm surface that we can use with KMS for display hardware that
support the format.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2013-10-15 22:07:52 -07:00
Kristian Høgsberg 360a141f24 wayland: Don't rely on static variable for identifying wl_drm buffers
Now that libEGL has been fixed to not leak all kinds of symbols, gbm
links to its own copy of the libwayland-drm.a helper library.  That means
we can't rely on comparing the addresses of a static vtable symbol in that
library to determine if a wl_buffer is a wl_drm_buffer.  Instead, we
move the vtable into the wl_drm struct and use that for comparing.

https://bugs.freedesktop.org/show_bug.cgi?id=69437

Cc: 9.2 <mesa-stable@lists.freedesktop.org>
2013-10-11 15:14:35 -07:00
Ander Conselvan de Oliveira 8d29b5271a egl: Update to Wayland 1.2 server API
Since Wayland 1.2, struct wl_buffer and a few functions are deprecated.

References to wl_buffer are replaced with wl_resource and some getter
functions and calls to deprecated functions are replaced with the proper
new API. The latter changes are related to resource versioning.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2013-08-07 10:37:58 -07:00
Daniel van Vugt 6e226ab5ac gbm: Remember to init format on gbm_dri_bo_create.
https://bugs.freedesktop.org/show_bug.cgi?id=60143
2013-02-07 20:00:52 -05:00
Kristian Høgsberg 259fc154f1 gbm: Use the kms dumb ioctls for cursor instead of libkms
We need to create bos suitable for cursor usage that we can map and
write data into.  The kms dumb ioctls is all we need for this, so drop
the dependency on libkms.
2012-10-21 13:00:49 -04:00
Kristian Høgsberg 017c6fb324 gbm: Reject buffers that are not wl_drm buffers in gbm_bo_import()
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2012-10-15 22:33:04 -04:00
Jakob Bornecrantz 6a7dea93fa dri: Rework planar image interface
As discussed with Kristian on #wayland. Pushes the decision of components into
the dri driver giving it greater freedom to allow t to implement YUV samplers
in hardware, and which mode to use.

This interface will also allow drivers like SVGA to implement YUV surfaces
without the need to sub-allocate and instead send 3 seperate buffers for each
channel, currently not implemented.

I have tested these changes on Gallium Svga. Scott tested them on both intel
and Gallium Radeon. Kristan and Pekka tested them on intel.

v2: Fix typo in dri2_from_planar.
v3: Merge in intel changes.

Tested-by: Scott Moreau <oreaus@gmail.com>
Tested-by: Pekka Paalanen <ppaalanen@gmail.com>
Tested-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
2012-08-31 19:51:02 +02:00
Jakob Bornecrantz 93ebec87ed dri: Make query image WIDTH and HEIGHT be version 4
Tested-by: Scott Moreau <oreaus@gmail.com>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
2012-08-26 15:39:50 +02:00
Jakob Bornecrantz 6bb71b8cbe dri: Remove image write function
Since its not used by anything anymore and no release has gone out
where it was being used.

Tested-by: Scott Moreau <oreaus@gmail.com>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
2012-08-26 15:39:41 +02:00
Jakob Bornecrantz a669a5055e gbm: Use libkms to replace DRI cursor images
Uses libkms instead of dri image cursor. Since this is the only user of the
DRI cursor and write interface we can remove cursor surfaces entirely from
the DRI interface and as a consequence also from the Gallium interface as
well. Tho to make everybody happy with this it would probably should add a
kms_bo_write function, but that is probably wise in anyways.

The only downside is that it adds a dependancy on libkms, this could how ever
be replaced with the dumb_bo drm ioctl interface.

Tested-by: Scott Moreau <oreaus@gmail.com>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
2012-08-26 15:39:23 +02:00
Jakob Bornecrantz 61e95b8a5f gbm: Add shared usage on images created
Tested-by: Scott Moreau <oreaus@gmail.com>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
2012-08-22 00:01:28 +02:00
Kristian Høgsberg 7250cd506b gbm: Rename gbm_bo_get_pitch to gbm_bo_get_stride
We use pitch for 'pixels per row' and stride for 'bytes per row' pretty
consistently in mesa and most other places, so rename the gbm API.
2012-07-16 16:29:16 -04:00
Kristian Høgsberg 44f066b9ff gbm: Add new gbm_bo_import entry point
This generalizes and replaces gbm_bo_create_for_egl_image.  gbm_bo_import
will create a gbm_bo from either an EGLImage or a struct wl_buffer.
2012-07-16 16:29:15 -04:00
Kristian Høgsberg 4fddb2ba21 gbm: Add gbm_bo_write entry point
This new gbm entry point allows writing data into a gbm bo.  The bo has
to be created with the GBM_BO_USE_WRITE flag, and it's only required to
work for GBM_BO_USE_CURSOR_64X64 bos.

The gbm API is designed to be the glue layer between EGL and KMS, but there
was never a mechanism initialize a buffer suitable for use with KMS
hw cursors.  The hw cursor bo is typically not compatible with anything EGL
can render to, and thus there's no way to get data into such a bo.

gbm_bo_write() fills that gap while staying out of the efficient
cpu->gpu pixel transfer business.

Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
2012-05-03 10:57:32 -04:00
Ander Conselvan de Oliveira f641c57cfa gbm: remove unused fields from gbm_dri_surface 2012-04-30 13:09:39 -04:00
Ander Conselvan de Oliveira fd6acb97fb gbm: Create hooks for dri2_loader_extension in dri backend
Pass a dri2_loader extension to the dri driver when gbm creates the dri
screen.  The implementation jumps through pointers in the gbm device
so that an EGL on GBM implementation can provide the real implementations.
2012-03-28 22:14:34 -04:00
Ander Conselvan de Oliveira 0d1ef1f57f gbm: Add gbm_surface interface
The idea here is to be able to create an egl window surface from a
gbm_surface.  This avoids the need for the surfaceless extension and
lets the EGL platform handle buffer allocation, while keeping the user
in charge of somehow presenting the buffers (using kms page flipping,
for example).

gbm_surface_lock_front_buffer() locks a surface's front buffer and
returns a gbm bo representing it.  This bo should later be returned
to the gbm surface using gbm_surface_release_buffer().
2012-03-28 22:14:34 -04:00
Ander Conselvan de Oliveira 410aa3eb45 egl_dri2: make flush extension useable by drm platform 2012-03-27 08:28:07 -04:00
Benjamin Franzke ab6e081914 gbm_dri: Fix DRIimage lookup callback
That is by making the dri extension variables static in gbm_dri.c.

The image_lookup_extension is provided by egl_dri2 when using x11 or wayland
platforms, when using the drm platform, gbm_dri has a wrapper for it.
Both use the same variables name image_lookup_extension.

Since -fvisibility=hidden was (probably by mistake) removed when converting to
automake, the "image_lookup_extension" symbol from egl_dri2.c became exported
in libEGL.so, so "image_lookup_extension" from gbm_dri.c was ignored.
This resulted in calling incorrect callbacks.

We cant make the image_lookup_extension static in egl_dri2.c right now,
since its used across multiple files.

Bugzilla: https://bugs.freedesktop.org/attachment.cgi?id=58099
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2012-03-07 18:17:56 +01:00
Jesse Barnes 8de5c355fa gbm: track buffer format through DRI drivers
GBM needs the buffer format in order to communicate with DRM and clients
for things like scanout.

So track the DRI format requested in the various back ends and use it to
return the DRI format back to GBM when requested.  GBM will then map
this into the GBM surface type (which is in turn based on the DRM fb
format list).

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2012-02-22 09:41:40 -08:00
Matt Turner 06ad64ad29 automake: src/gbm
libgbm.so.1.0.0 (instead of libgbm.so.1.0) is installed now
along with libgbm.so.1 (no change).
2012-01-23 15:18:12 -05:00
Kristian Høgsberg 221c678329 gbm: Validate usage flags in gbm_bo_create_from_egl_image()
The entry point is supposed to validate that the EGLImage is suitable for
the passed in usage flags, but that was never implemented.
2012-01-18 15:32:51 -05:00
RALOVICH, Kristóf eeed782ecb gbm/dri: avoid crash in dri_screen_create 2011-08-04 14:09:34 +02:00
Benjamin Franzke 2ff797060d gbm: Add dri backend 2011-06-23 21:07:17 +02:00