libdrm: Add NVIDIA Tegra support

Add the libdrm_tegra helper library to encapsulate Tegra-specific
interfaces to the DRM.

Furthermore, Tegra is added to the list of supported chips in the
modetest and vbltest programs.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
tegra: Add simple test for drm_tegra_open()

This test opens a device, dumps the version information and checks that
a Tegra DRM context can be opened on it.

Signed-off-by: Thierry Reding <treding@nvidia.com>
tegra: Add GET/SET_TILING IOCTLs

Currently the tiling parameters of buffer objects can only be set at
allocation time, and only a single tiled mode is supported. This new
DRM_TEGRA_GEM_SET_TILING IOCTL allows more modes to be set and also
allows the tiling mode to be changed after the allocation. This will
enable the Tegra DRM driver to import buffers from a GPU and directly
scan them out by configuring the display controller appropriately.

To complement this, the DRM_TEGRA_GEM_GET_TILING IOCTL can query the
current tiling mode of a buffer object. This is necessary when importing
buffers via handle (as is done in Mesa for example) so that userspace
can determine the proper parameters for the 2D or 3D engines.

Signed-off-by: Thierry Reding <treding@nvidia.com>
tegra: Add SET/GET_FLAGS IOCTLs

The DRM_TEGRA_GEM_SET_FLAGS IOCTL can be used to set the flags of a
buffer object after it has been allocated or imported. Flags associated
with a buffer object can be queried using the DRM_TEGRA_GEM_GET_FLAGS
IOCTL.

Signed-off-by: Thierry Reding <treding@nvidia.com>
tegra: Implement drm_tegra_bo_{get,set}_flags()

These two functions are simple wrappers around the corresponding IOCTLs
and operate on drm_tegra_bo objects.

Signed-off-by: Thierry Reding <treding@nvidia.com>
tegra: Implement drm_tegra_bo_{get,set}_tiling()

These two functions are simple wrappers around the corresponding IOCTLs
and operate on drm_tegra_bo objects.

Signed-off-by: Thierry Reding <treding@nvidia.com>
nouveau: deprecate the object back-pointer

Um, I'm not really sure what the point of this was.  Nothing used it,
but have to keep the struct member to avoid breaking ABI.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
nouveau: kill device_open_existing()

Any need to keep this around should be long-gone by now.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
nouveau: move header definitions around a bit

No code changes, making it more obvious how things relate.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
nouveau: refcount objects

Due to an unfortunate thinko a long time back (embedding nouveau_object
directly into nouveau_device) it's not possible to just tack the refcnt
onto the end of nouveau_object without breaking the libdrm<->client ABI.

The solution is to prepend (from the libdrm_nouveau struct private) all
struct nouveau_object with a struct nouveau_object_refs, and use a
container_of() macro to get at them.

As a result, this looks pretty ugly, but it's workable and doesn't need
an ABI break.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
nouveau: handle abi16 objects completely in abi16.c

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
nouveau: update headers from kernel

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
nouveau: split device into drm + device

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
nouveau: basic support for new kernel interfaces

Enough to allow method calls on objects (perfctrs, zbc, etc).

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
export missing includes