Mesa: i915_dri driver

git-svn-id: svn://kolibrios.org@4548 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2014-01-29 12:35:00 +00:00
parent 241079c114
commit 96d11ce70a
9 changed files with 62 additions and 101 deletions

View File

@ -13,7 +13,7 @@ LDFLAGS = -nostdlib -shared -s --image-base 0 -T ../newlib/dll.lds --out-implib
STRIP = $(PREFIX)strip STRIP = $(PREFIX)strip
INC_MESA= -I../newlib/include -I./include -I./src -I./src/glsl -I./src/mesa -I./src/mapi 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 LIBPATH:= -L../../lib
@ -46,6 +46,7 @@ EGL_SRC = \
src/egl/main/eglstring.c \ src/egl/main/eglstring.c \
src/egl/main/eglsurface.c \ src/egl/main/eglsurface.c \
src/egl/main/eglsync.c \ src/egl/main/eglsync.c \
src/gbm/backends/dri/driver_name.c \
src/gbm/backends/dri/gbm_dri.c \ src/gbm/backends/dri/gbm_dri.c \
src/gbm/main/backend.c \ src/gbm/main/backend.c \
src/gbm/main/gbm.c \ src/gbm/main/gbm.c \

View File

@ -28,8 +28,8 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <pciaccess.h>
#include <libudev.h> #include <kos32sys.h>
#include "gbm_driint.h" #include "gbm_driint.h"
#define DRIVER_MAP_DRI2_ONLY #define DRIVER_MAP_DRI2_ONLY
@ -38,52 +38,44 @@
char * char *
dri_fd_get_driver_name(int fd) dri_fd_get_driver_name(int fd)
{ {
struct udev *udev; ioctl_t io;
struct udev_device *device, *parent; struct pci_device device;
const char *pci_id;
char *driver = NULL; char *driver = NULL;
int vendor_id, chip_id, i, j; int i, j;
udev = udev_new(); io.handle = fd;
device = _gbm_udev_device_new_from_fd(udev, fd); io.io_code = SRV_GET_PCI_INFO;
if (device == NULL) io.input = &device;
io.inp_size = sizeof(device);
io.output = NULL;
io.out_size = 0;
if (call_service(&io)!=0)
return NULL; return NULL;
parent = udev_device_get_parent(device); for (i = 0; driver_map[i].driver; i++)
if (parent == NULL) { {
fprintf(stderr, "gbm: could not get parent device"); if (device.vendor_id != driver_map[i].vendor_id)
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; continue;
if (driver_map[i].num_chips_ids == -1) { if (driver_map[i].num_chips_ids == -1)
{
driver = strdup(driver_map[i].driver); driver = strdup(driver_map[i].driver);
_gbm_log("pci id for %d: %04x:%04x, driver %s", printf("pci id for %d: %04x:%04x, driver %s\n",
fd, vendor_id, chip_id, driver); fd, device.vendor_id, device.device_id, driver);
goto out; goto out;
} }
for (j = 0; j < driver_map[i].num_chips_ids; j++) 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); driver = strdup(driver_map[i].driver);
_gbm_log("pci id for %d: %04x:%04x, driver %s", printf("pci id for %d: %04x:%04x, driver %s\n",
fd, vendor_id, chip_id, driver); fd, device.vendor_id, device.device_id, driver);
goto out; goto out;
} }
} }
out: out:
udev_device_unref(device);
udev_unref(udev);
return driver; return driver;
} }

View File

@ -174,49 +174,15 @@ static int
dri_load_driver(struct gbm_dri_device *dri) dri_load_driver(struct gbm_dri_device *dri)
{ {
const __DRIextension **extensions; const __DRIextension **extensions;
// char path[PATH_MAX], *search_paths, *p, *next, *end; char path[64];
char *search_paths;
search_paths = NULL; snprintf(path, sizeof path,"/kolibrios/lib/%s_dri.drv", dri->base.driver_name);
#if 0 dri->driver = load_library(path);
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");
if (dri->driver == NULL) { if (dri->driver == NULL) {
fprintf(stderr, "gbm: failed to open any driver (search paths %s)", fprintf(stderr, "gbm: failed to open any driver (search paths %s)",
search_paths); path);
return -1; return -1;
} }
@ -243,7 +209,7 @@ dri_screen_create(struct gbm_dri_device *dri)
const __DRIextension **extensions; const __DRIextension **extensions;
int ret = 0; 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) if (dri->base.driver_name == NULL)
return -1; return -1;
@ -588,9 +554,6 @@ gbm_dri_bo_create(struct gbm_device *gbm,
dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE, dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
(int *) &bo->base.base.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; return &bo->base.base;
} }

View File

@ -62,3 +62,8 @@ _glapi_set_dispatch(struct _glapi_table *dispatch)
{ {
u_current_set((const struct mapi_table *) dispatch); u_current_set((const struct mapi_table *) dispatch);
} }
int atexit(void (*func)(void))
{
return 0;
};

View File

@ -51,22 +51,11 @@
extern "C" { extern "C" {
#endif #endif
#ifdef _GLAPI_DLL_EXPORTS
#ifdef _GLAPI_NO_EXPORTS # define _GLAPI_EXPORT __declspec(dllexport)
# define _GLAPI_EXPORT #else
#else /* _GLAPI_NO_EXPORTS */ # define _GLAPI_EXPORT __declspec(dllimport)
# ifdef _WIN32 #endif
# 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 */
/* Is this needed? It is incomplete anyway. */ /* Is this needed? It is incomplete anyway. */

View File

@ -627,3 +627,8 @@ driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv)
assert(fb->Height == dPriv->h); assert(fb->Height == dPriv->h);
} }
} }
int atexit(void (*func)(void))
{
return 0;
}

View File

@ -68,6 +68,7 @@ intel_batchbuffer_free(struct intel_context *intel)
drm_intel_bo_unreference(intel->batch.bo); drm_intel_bo_unreference(intel->batch.bo);
} }
#if 0
static void static void
do_batch_dump(struct intel_context *intel) do_batch_dump(struct intel_context *intel)
{ {
@ -107,6 +108,7 @@ do_batch_dump(struct intel_context *intel)
intel->vtbl.debug_batch(intel); intel->vtbl.debug_batch(intel);
} }
} }
#endif
/* TODO: Push this whole function into bufmgr. /* TODO: Push this whole function into bufmgr.
*/ */
@ -127,8 +129,8 @@ do_flush_locked(struct intel_context *intel)
} }
} }
if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) // if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
do_batch_dump(intel); // do_batch_dump(intel);
if (ret != 0) { if (ret != 0) {
fprintf(stderr, "intel_do_flush_locked failed: %s\n", strerror(-ret)); fprintf(stderr, "intel_do_flush_locked failed: %s\n", strerror(-ret));

View File

@ -39,7 +39,7 @@
* last moment. * last moment.
*/ */
#include <sys/ioctl.h> //#include <sys/ioctl.h>
#include <errno.h> #include <errno.h>
#include "main/hash.h" #include "main/hash.h"
@ -205,6 +205,7 @@ intel_region_alloc_for_handle(struct intel_screen *screen,
return region; return region;
} }
#if 0
struct intel_region * struct intel_region *
intel_region_alloc_for_fd(struct intel_screen *screen, intel_region_alloc_for_fd(struct intel_screen *screen,
GLuint cpp, GLuint cpp,
@ -237,6 +238,7 @@ intel_region_alloc_for_fd(struct intel_screen *screen,
return region; return region;
} }
#endif
void void
intel_region_reference(struct intel_region **dst, struct intel_region *src) intel_region_reference(struct intel_region **dst, struct intel_region *src)

View File

@ -103,7 +103,7 @@ get_time(void)
{ {
struct timespec tp; struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp); // clock_gettime(CLOCK_MONOTONIC, &tp);
return tp.tv_sec + tp.tv_nsec / 1000000000.0; 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; *value = image->planar_format->components;
return true; return true;
case __DRI_IMAGE_ATTRIB_FD: case __DRI_IMAGE_ATTRIB_FD:
if (drm_intel_bo_gem_export_to_prime(image->region->bo, value) == 0) // if (drm_intel_bo_gem_export_to_prime(image->region->bo, value) == 0)
return true; // return true;
return false; return false;
default: default:
return false; return false;
@ -620,6 +620,7 @@ intel_create_image_from_names(__DRIscreen *screen,
return image; return image;
} }
#if 0
static __DRIimage * static __DRIimage *
intel_create_image_from_fds(__DRIscreen *screen, intel_create_image_from_fds(__DRIscreen *screen,
int width, int height, int fourcc, int width, int height, int fourcc,
@ -664,7 +665,7 @@ intel_create_image_from_fds(__DRIscreen *screen,
return image; return image;
} }
#endif
static __DRIimage * static __DRIimage *
intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate) intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
@ -737,7 +738,7 @@ static struct __DRIimageExtensionRec intelImageExtension = {
.createImageFromNames = intel_create_image_from_names, .createImageFromNames = intel_create_image_from_names,
.fromPlanar = intel_from_planar, .fromPlanar = intel_from_planar,
.createImageFromTexture = intel_create_image_from_texture, .createImageFromTexture = intel_create_image_from_texture,
.createImageFromFds = intel_create_image_from_fds // .createImageFromFds = intel_create_image_from_fds
}; };
static const __DRIextension *intelScreenExtensions[] = { static const __DRIextension *intelScreenExtensions[] = {
@ -758,7 +759,7 @@ intel_get_param(__DRIscreen *psp, int param, int *value)
gp.param = param; gp.param = param;
gp.value = value; 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) {
if (ret != -EINVAL) if (ret != -EINVAL)
_mesa_warning(NULL, "drm_i915_getparam: %d", ret); _mesa_warning(NULL, "drm_i915_getparam: %d", ret);
@ -768,6 +769,7 @@ intel_get_param(__DRIscreen *psp, int param, int *value)
return true; return true;
} }
static bool static bool
intel_get_boolean(__DRIscreen *psp, int param) 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. */ /* This is the table of extensions that the loader will dlsym() for. */
PUBLIC const __DRIextension *__driDriverExtensions[] = { __declspec(dllexport) const __DRIextension *__driDriverExtensions[] = {
&driCoreExtension.base, &driCoreExtension.base,
&driDRI2Extension.base, &driDRI2Extension.base,
NULL NULL