Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4471 → Rev 4548

/contrib/sdk/sources/Mesa/src/gbm/backends/dri/driver_name.c
28,9 → 28,9
 
#include <stdio.h>
#include <string.h>
#include <pciaccess.h>
#include <kos32sys.h>
 
#include <libudev.h>
 
#include "gbm_driint.h"
#define DRIVER_MAP_DRI2_ONLY
#include "pci_ids/pci_id_driver_map.h"
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;
}
/contrib/sdk/sources/Mesa/src/gbm/backends/dri/gbm_dri.c
174,49 → 174,15
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
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) {
fprintf(stderr, "gbm: failed to open any driver (search paths %s)",
search_paths);
path);
return -1;
}
 
243,7 → 209,7
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
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;
}