forked from KolibriOS/kolibrios
Mesa: i915_dri driver
git-svn-id: svn://kolibrios.org@4548 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
241079c114
commit
96d11ce70a
@ -13,7 +13,7 @@ LDFLAGS = -nostdlib -shared -s --image-base 0 -T ../newlib/dll.lds --out-implib
|
||||
STRIP = $(PREFIX)strip
|
||||
|
||||
INC_MESA= -I../newlib/include -I./include -I./src -I./src/glsl -I./src/mesa -I./src/mapi
|
||||
INC_EGL= -I../newlib/include -I./include -I../libdrm -I../libdrm/include/drm -I./src/egl/main -I./src/gbm/backends/dri -I./src/gbm/main
|
||||
INC_EGL= -I../newlib/include -I../../includes -I./include -I../libdrm -I../libdrm/include/drm -I./src/egl/main -I./src/gbm/backends/dri -I./src/gbm/main
|
||||
|
||||
LIBPATH:= -L../../lib
|
||||
|
||||
@ -46,6 +46,7 @@ EGL_SRC = \
|
||||
src/egl/main/eglstring.c \
|
||||
src/egl/main/eglsurface.c \
|
||||
src/egl/main/eglsync.c \
|
||||
src/gbm/backends/dri/driver_name.c \
|
||||
src/gbm/backends/dri/gbm_dri.c \
|
||||
src/gbm/main/backend.c \
|
||||
src/gbm/main/gbm.c \
|
||||
|
@ -28,8 +28,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libudev.h>
|
||||
#include <pciaccess.h>
|
||||
#include <kos32sys.h>
|
||||
|
||||
#include "gbm_driint.h"
|
||||
#define DRIVER_MAP_DRI2_ONLY
|
||||
@ -38,52 +38,44 @@
|
||||
char *
|
||||
dri_fd_get_driver_name(int fd)
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_device *device, *parent;
|
||||
const char *pci_id;
|
||||
ioctl_t io;
|
||||
struct pci_device device;
|
||||
char *driver = NULL;
|
||||
int vendor_id, chip_id, i, j;
|
||||
int i, j;
|
||||
|
||||
udev = udev_new();
|
||||
device = _gbm_udev_device_new_from_fd(udev, fd);
|
||||
if (device == NULL)
|
||||
io.handle = fd;
|
||||
io.io_code = SRV_GET_PCI_INFO;
|
||||
io.input = &device;
|
||||
io.inp_size = sizeof(device);
|
||||
io.output = NULL;
|
||||
io.out_size = 0;
|
||||
|
||||
if (call_service(&io)!=0)
|
||||
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)
|
||||
for (i = 0; driver_map[i].driver; i++)
|
||||
{
|
||||
if (device.vendor_id != driver_map[i].vendor_id)
|
||||
continue;
|
||||
if (driver_map[i].num_chips_ids == -1) {
|
||||
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);
|
||||
printf("pci id for %d: %04x:%04x, driver %s\n",
|
||||
fd, device.vendor_id, device.device_id, driver);
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (j = 0; j < driver_map[i].num_chips_ids; j++)
|
||||
if (driver_map[i].chip_ids[j] == chip_id) {
|
||||
if (driver_map[i].chip_ids[j] == device.device_id)
|
||||
{
|
||||
driver = strdup(driver_map[i].driver);
|
||||
_gbm_log("pci id for %d: %04x:%04x, driver %s",
|
||||
fd, vendor_id, chip_id, driver);
|
||||
printf("pci id for %d: %04x:%04x, driver %s\n",
|
||||
fd, device.vendor_id, device.device_id, driver);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
udev_device_unref(device);
|
||||
udev_unref(udev);
|
||||
|
||||
return driver;
|
||||
}
|
||||
|
@ -174,49 +174,15 @@ static int
|
||||
dri_load_driver(struct gbm_dri_device *dri)
|
||||
{
|
||||
const __DRIextension **extensions;
|
||||
// char path[PATH_MAX], *search_paths, *p, *next, *end;
|
||||
char *search_paths;
|
||||
char path[64];
|
||||
|
||||
search_paths = NULL;
|
||||
snprintf(path, sizeof path,"/kolibrios/lib/%s_dri.drv", dri->base.driver_name);
|
||||
|
||||
#if 0
|
||||
|
||||
if (geteuid() == getuid()) {
|
||||
/* don't allow setuid apps to use GBM_DRIVERS_PATH */
|
||||
search_paths = getenv("GBM_DRIVERS_PATH");
|
||||
}
|
||||
if (search_paths == NULL)
|
||||
search_paths = DEFAULT_DRIVER_DIR;
|
||||
|
||||
dri->driver = NULL;
|
||||
end = search_paths + strlen(search_paths);
|
||||
for (p = search_paths; p < end && dri->driver == NULL; p = next + 1) {
|
||||
int len;
|
||||
next = strchr(p, ':');
|
||||
if (next == NULL)
|
||||
next = end;
|
||||
|
||||
len = next - p;
|
||||
#if GLX_USE_TLS
|
||||
snprintf(path, sizeof path,
|
||||
"%.*s/tls/%s_dri.so", len, p, dri->base.driver_name);
|
||||
dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
|
||||
#endif
|
||||
if (dri->driver == NULL) {
|
||||
snprintf(path, sizeof path,
|
||||
"%.*s/%s_dri.so", len, p, dri->base.driver_name);
|
||||
dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
|
||||
if (dri->driver == NULL)
|
||||
fprintf(stderr, "failed to open %s: %s\n", path, dlerror());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
dri->driver = load_library("libGL.dll");
|
||||
dri->driver = load_library(path);
|
||||
|
||||
if (dri->driver == NULL) {
|
||||
fprintf(stderr, "gbm: failed to open any driver (search paths %s)",
|
||||
search_paths);
|
||||
path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -243,7 +209,7 @@ dri_screen_create(struct gbm_dri_device *dri)
|
||||
const __DRIextension **extensions;
|
||||
int ret = 0;
|
||||
|
||||
dri->base.driver_name = strdup("drm"); //dri_fd_get_driver_name(dri->base.base.fd);
|
||||
dri->base.driver_name = dri_fd_get_driver_name(dri->base.base.fd);
|
||||
if (dri->base.driver_name == NULL)
|
||||
return -1;
|
||||
|
||||
@ -588,9 +554,6 @@ gbm_dri_bo_create(struct gbm_device *gbm,
|
||||
dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
|
||||
(int *) &bo->base.base.stride);
|
||||
|
||||
printf("%s handle %d w %d h%d\n",__FUNCTION__, bo->base.base.handle.s32,
|
||||
width, height);
|
||||
|
||||
return &bo->base.base;
|
||||
}
|
||||
|
||||
|
@ -62,3 +62,8 @@ _glapi_set_dispatch(struct _glapi_table *dispatch)
|
||||
{
|
||||
u_current_set((const struct mapi_table *) dispatch);
|
||||
}
|
||||
|
||||
int atexit(void (*func)(void))
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
|
@ -51,22 +51,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _GLAPI_NO_EXPORTS
|
||||
# define _GLAPI_EXPORT
|
||||
#else /* _GLAPI_NO_EXPORTS */
|
||||
# ifdef _WIN32
|
||||
# ifdef _GLAPI_DLL_EXPORTS
|
||||
# define _GLAPI_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define _GLAPI_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
# elif defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
|
||||
# define _GLAPI_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
# define _GLAPI_EXPORT
|
||||
# endif
|
||||
#endif /* _GLAPI_NO_EXPORTS */
|
||||
#ifdef _GLAPI_DLL_EXPORTS
|
||||
# define _GLAPI_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
# define _GLAPI_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
|
||||
/* Is this needed? It is incomplete anyway. */
|
||||
|
@ -627,3 +627,8 @@ driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv)
|
||||
assert(fb->Height == dPriv->h);
|
||||
}
|
||||
}
|
||||
|
||||
int atexit(void (*func)(void))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ intel_batchbuffer_free(struct intel_context *intel)
|
||||
drm_intel_bo_unreference(intel->batch.bo);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
do_batch_dump(struct intel_context *intel)
|
||||
{
|
||||
@ -107,6 +108,7 @@ do_batch_dump(struct intel_context *intel)
|
||||
intel->vtbl.debug_batch(intel);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* TODO: Push this whole function into bufmgr.
|
||||
*/
|
||||
@ -127,8 +129,8 @@ do_flush_locked(struct intel_context *intel)
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
|
||||
do_batch_dump(intel);
|
||||
// if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
|
||||
// do_batch_dump(intel);
|
||||
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "intel_do_flush_locked failed: %s\n", strerror(-ret));
|
||||
|
@ -39,7 +39,7 @@
|
||||
* last moment.
|
||||
*/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
//#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "main/hash.h"
|
||||
@ -205,6 +205,7 @@ intel_region_alloc_for_handle(struct intel_screen *screen,
|
||||
return region;
|
||||
}
|
||||
|
||||
#if 0
|
||||
struct intel_region *
|
||||
intel_region_alloc_for_fd(struct intel_screen *screen,
|
||||
GLuint cpp,
|
||||
@ -237,6 +238,7 @@ intel_region_alloc_for_fd(struct intel_screen *screen,
|
||||
|
||||
return region;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
intel_region_reference(struct intel_region **dst, struct intel_region *src)
|
||||
|
@ -103,7 +103,7 @@ get_time(void)
|
||||
{
|
||||
struct timespec tp;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
// clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
|
||||
return tp.tv_sec + tp.tv_nsec / 1000000000.0;
|
||||
}
|
||||
@ -528,8 +528,8 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
|
||||
*value = image->planar_format->components;
|
||||
return true;
|
||||
case __DRI_IMAGE_ATTRIB_FD:
|
||||
if (drm_intel_bo_gem_export_to_prime(image->region->bo, value) == 0)
|
||||
return true;
|
||||
// if (drm_intel_bo_gem_export_to_prime(image->region->bo, value) == 0)
|
||||
// return true;
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
@ -620,6 +620,7 @@ intel_create_image_from_names(__DRIscreen *screen,
|
||||
return image;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static __DRIimage *
|
||||
intel_create_image_from_fds(__DRIscreen *screen,
|
||||
int width, int height, int fourcc,
|
||||
@ -664,7 +665,7 @@ intel_create_image_from_fds(__DRIscreen *screen,
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static __DRIimage *
|
||||
intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
|
||||
@ -737,7 +738,7 @@ static struct __DRIimageExtensionRec intelImageExtension = {
|
||||
.createImageFromNames = intel_create_image_from_names,
|
||||
.fromPlanar = intel_from_planar,
|
||||
.createImageFromTexture = intel_create_image_from_texture,
|
||||
.createImageFromFds = intel_create_image_from_fds
|
||||
// .createImageFromFds = intel_create_image_from_fds
|
||||
};
|
||||
|
||||
static const __DRIextension *intelScreenExtensions[] = {
|
||||
@ -758,7 +759,7 @@ intel_get_param(__DRIscreen *psp, int param, int *value)
|
||||
gp.param = param;
|
||||
gp.value = value;
|
||||
|
||||
ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
|
||||
ret = drmIoctl(psp->fd, DRM_IOCTL_I915_GETPARAM, &gp);
|
||||
if (ret) {
|
||||
if (ret != -EINVAL)
|
||||
_mesa_warning(NULL, "drm_i915_getparam: %d", ret);
|
||||
@ -768,6 +769,7 @@ intel_get_param(__DRIscreen *psp, int param, int *value)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
intel_get_boolean(__DRIscreen *psp, int param)
|
||||
{
|
||||
@ -1226,7 +1228,7 @@ const struct __DriverAPIRec driDriverAPI = {
|
||||
};
|
||||
|
||||
/* This is the table of extensions that the loader will dlsym() for. */
|
||||
PUBLIC const __DRIextension *__driDriverExtensions[] = {
|
||||
__declspec(dllexport) const __DRIextension *__driDriverExtensions[] = {
|
||||
&driCoreExtension.base,
|
||||
&driDRI2Extension.base,
|
||||
NULL
|
||||
|
Loading…
Reference in New Issue
Block a user