Commit 2ff79706 authored by Benjamin Franzke's avatar Benjamin Franzke 😀

gbm: Add dri backend

parent eddcecbf
......@@ -1271,6 +1271,13 @@ if test "x$enable_gbm" = xyes; then
PKG_CHECK_MODULES([LIBUDEV], [libudev], [],
AC_MSG_ERROR([gbm needs udev]))
GBM_LIB_DEPS="$DLOPEN_LIBS $LIBUDEV_LIBS"
if test "$mesa_driver" = dri; then
GBM_BACKEND_DIRS="$GBM_BACKEND_DIRS dri"
if test "$SHARED_GLAPI" -eq 0; then
AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi])
fi
fi
fi
AC_SUBST([GBM_LIB_DEPS])
AC_SUBST([GBM_BACKEND_DIRS])
......
# src/gbm/backends/dri/Makefile
TOP = ../../../..
include $(TOP)/configs/current
GBM_BACKEND = gbm_dri
GBM_SOURCES = gbm_dri.c driver_name.c
GBM_INCLUDES = \
-I$(TOP)/include \
-I$(TOP)/src/gbm/main \
GBM_LIBS = $(LIBUDEV_LIBS) $(LIBDRM_LIB) -L$(TOP)/lib -lglapi
GBM_CFLAGS = \
-DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \
$(LIBUDEV_CFLAGS) \
$(LIBDRM_CFLAGS)
GBM_BUILTIN=true
include ../Makefile.template
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Kristian Høgsberg <krh@bitplanet.net>
* Benjamin Franzke <benjaminfranzke@googlemail.com>
*/
#include <stdio.h>
#include <string.h>
#include <libudev.h>
#include "gbm_driint.h"
#define DRIVER_MAP_DRI2_ONLY
#include "pci_ids/pci_id_driver_map.h"
char *
dri_fd_get_driver_name(int fd)
{
struct udev *udev;
struct udev_device *device, *parent;
const char *pci_id;
char *driver = NULL;
int vendor_id, chip_id, i, j;
udev = udev_new();
device = _gbm_udev_device_new_from_fd(udev, fd);
if (device == NULL)
return NULL;
parent = udev_device_get_parent(device);
if (parent == NULL) {
fprintf(stderr, "gbm: could not get parent device");
goto out;
}
pci_id = udev_device_get_property_value(parent, "PCI_ID");
if (pci_id == NULL ||
sscanf(pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
fprintf(stderr, "gbm: malformed or no PCI ID");
goto out;
}
for (i = 0; driver_map[i].driver; i++) {
if (vendor_id != driver_map[i].vendor_id)
continue;
if (driver_map[i].num_chips_ids == -1) {
driver = strdup(driver_map[i].driver);
_gbm_log("pci id for %d: %04x:%04x, driver %s",
fd, vendor_id, chip_id, driver);
goto out;
}
for (j = 0; j < driver_map[i].num_chips_ids; j++)
if (driver_map[i].chip_ids[j] == chip_id) {
driver = strdup(driver_map[i].driver);
_gbm_log("pci id for %d: %04x:%04x, driver %s",
fd, vendor_id, chip_id, driver);
goto out;
}
}
out:
udev_device_unref(device);
udev_unref(udev);
return driver;
}
This diff is collapsed.
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Benjamin Franzke <benjaminfranzke@googlemail.com>
*/
#ifndef _GBM_DRI_INTERNAL_H_
#define _GBM_DRI_INTERNAL_H_
#include "gbmint.h"
#include "common.h"
#include "common_drm.h"
#include <GL/gl.h> /* dri_interface needs GL types */
#include "GL/internal/dri_interface.h"
struct gbm_dri_device {
struct gbm_drm_device base;
void *driver;
__DRIscreen *screen;
__DRIcoreExtension *core;
__DRIdri2Extension *dri2;
__DRIimageExtension *image;
const __DRIconfig **driver_configs;
const __DRIextension *extensions[3];
__DRIimage *(*lookup_image)(__DRIscreen *screen, void *image, void *data);
void *lookup_user_data;
};
struct gbm_dri_bo {
struct gbm_drm_bo base;
__DRIimage *image;
};
static inline struct gbm_dri_device *
gbm_dri_device(struct gbm_device *gbm)
{
return (struct gbm_dri_device *) gbm;
}
static inline struct gbm_dri_bo *
gbm_dri_bo(struct gbm_bo *bo)
{
return (struct gbm_dri_bo *) bo;
}
char *
dri_fd_get_driver_name(int fd);
#endif
......@@ -23,6 +23,11 @@ LOCAL_CFLAGS = $(LIBUDEV_CFLAGS) $(DLOPEN_CFLAGS) \
-D_OS_UNIX=1 -DMODULEDIR='"$(GBM_BACKEND_INSTALL_DIR)"'
LOCAL_LIBS =
# Builtin backends
ifeq ($(filter dri, $(GBM_BACKEND_DIRS)),dri)
LOCAL_LIBS += $(TOP)/src/gbm/backends/dri/libgbm_dri.a
endif
.c.o:
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@
......
......@@ -36,12 +36,15 @@
#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
extern const struct gbm_backend gbm_dri_backend;
struct backend_desc {
const char *name;
const struct gbm_backend *builtin;
};
static const struct backend_desc backends[] = {
{ "gbm_dri.so", &gbm_dri_backend },
};
static const void *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment