Lines 1-4
Link Here
|
1 |
--- xf86drm.c.orig 2018-08-02 20:12:58 UTC |
1 |
--- xf86drm.c.orig 2018-10-18 18:33:47 UTC |
2 |
+++ xf86drm.c |
2 |
+++ xf86drm.c |
3 |
@@ -46,6 +46,9 @@ |
3 |
@@ -46,6 +46,9 @@ |
4 |
#include <signal.h> |
4 |
#include <signal.h> |
Lines 41-47
Link Here
|
41 |
#endif |
41 |
#endif |
42 |
|
42 |
|
43 |
#ifdef __NetBSD__ |
43 |
#ifdef __NetBSD__ |
44 |
@@ -177,7 +174,7 @@ void drmFree(void *pt) |
44 |
@@ -177,7 +174,7 @@ drm_public void drmFree(void *pt) |
45 |
} |
45 |
} |
46 |
|
46 |
|
47 |
/** |
47 |
/** |
Lines 48-56
Link Here
|
48 |
- * Call ioctl, restarting if it is interupted |
48 |
- * Call ioctl, restarting if it is interupted |
49 |
+ * Call ioctl, restarting if it is interrupted |
49 |
+ * Call ioctl, restarting if it is interrupted |
50 |
*/ |
50 |
*/ |
51 |
int |
51 |
drm_public int |
52 |
drmIoctl(int fd, unsigned long request, void *arg) |
52 |
drmIoctl(int fd, unsigned long request, void *arg) |
53 |
@@ -220,6 +217,89 @@ drmHashEntry *drmGetEntry(int fd) |
53 |
@@ -220,6 +217,89 @@ drm_public drmHashEntry *drmGetEntry(int fd) |
54 |
return entry; |
54 |
return entry; |
55 |
} |
55 |
} |
56 |
|
56 |
|
Lines 222-228
Link Here
|
222 |
if ((fd = open(buf, O_RDWR | O_CLOEXEC, 0)) >= 0) |
222 |
if ((fd = open(buf, O_RDWR | O_CLOEXEC, 0)) >= 0) |
223 |
return fd; |
223 |
return fd; |
224 |
return -errno; |
224 |
return -errno; |
225 |
@@ -514,51 +580,6 @@ int drmAvailable(void) |
225 |
@@ -514,51 +580,6 @@ drm_public int drmAvailable(void) |
226 |
return retval; |
226 |
return retval; |
227 |
} |
227 |
} |
228 |
|
228 |
|
Lines 274-282
Link Here
|
274 |
/** |
274 |
/** |
275 |
* Open the device by bus ID. |
275 |
* Open the device by bus ID. |
276 |
* |
276 |
* |
277 |
@@ -2737,33 +2758,40 @@ int drmDropMaster(int fd) |
277 |
@@ -2743,28 +2764,22 @@ drm_public int drmDropMaster(int fd) |
278 |
|
278 |
|
279 |
char *drmGetDeviceNameFromFd(int fd) |
279 |
drm_public char *drmGetDeviceNameFromFd(int fd) |
280 |
{ |
280 |
{ |
281 |
- char name[128]; |
281 |
- char name[128]; |
282 |
- struct stat sbuf; |
282 |
- struct stat sbuf; |
Lines 308-314
Link Here
|
308 |
+ return NULL; |
308 |
+ return NULL; |
309 |
} |
309 |
} |
310 |
|
310 |
|
311 |
int drmGetNodeTypeFromFd(int fd) |
311 |
static bool drmNodeIsDRM(int maj, int min) |
|
|
312 |
@@ -2777,13 +2792,26 @@ static bool drmNodeIsDRM(int maj, int min) |
313 |
maj, min); |
314 |
return stat(path, &sbuf) == 0; |
315 |
#else |
316 |
- return maj == DRM_MAJOR; |
317 |
+ return !DRM_MAJOR || maj == DRM_MAJOR; |
318 |
#endif |
319 |
} |
320 |
|
321 |
drm_public int drmGetNodeTypeFromFd(int fd) |
312 |
{ |
322 |
{ |
313 |
- struct stat sbuf; |
323 |
- struct stat sbuf; |
314 |
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) |
324 |
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) |
Lines 328-334
Link Here
|
328 |
int maj, min, type; |
338 |
int maj, min, type; |
329 |
|
339 |
|
330 |
if (fstat(fd, &sbuf)) |
340 |
if (fstat(fd, &sbuf)) |
331 |
@@ -2781,6 +2809,7 @@ int drmGetNodeTypeFromFd(int fd) |
341 |
@@ -2801,6 +2829,7 @@ drm_public int drmGetNodeTypeFromFd(int fd) |
332 |
if (type == -1) |
342 |
if (type == -1) |
333 |
errno = ENODEV; |
343 |
errno = ENODEV; |
334 |
return type; |
344 |
return type; |
Lines 335-342
Link Here
|
335 |
+#endif |
345 |
+#endif |
336 |
} |
346 |
} |
337 |
|
347 |
|
338 |
int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd) |
348 |
drm_public int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, |
339 |
@@ -2820,7 +2849,7 @@ static char *drmGetMinorNameForFD(int fd, int type) |
349 |
@@ -2841,7 +2870,7 @@ static char *drmGetMinorNameForFD(int fd, int type) |
340 |
#ifdef __linux__ |
350 |
#ifdef __linux__ |
341 |
DIR *sysdir; |
351 |
DIR *sysdir; |
342 |
struct dirent *ent; |
352 |
struct dirent *ent; |
Lines 345-351
Link Here
|
345 |
const char *name = drmGetMinorName(type); |
355 |
const char *name = drmGetMinorName(type); |
346 |
int len; |
356 |
int len; |
347 |
char dev_name[64], buf[64]; |
357 |
char dev_name[64], buf[64]; |
348 |
@@ -2858,13 +2887,35 @@ static char *drmGetMinorNameForFD(int fd, int type) |
358 |
@@ -2879,13 +2908,35 @@ static char *drmGetMinorNameForFD(int fd, int type) |
349 |
|
359 |
|
350 |
closedir(sysdir); |
360 |
closedir(sysdir); |
351 |
return NULL; |
361 |
return NULL; |
Lines 384-391
Link Here
|
384 |
if (fstat(fd, &sbuf)) |
394 |
if (fstat(fd, &sbuf)) |
385 |
return NULL; |
395 |
return NULL; |
386 |
|
396 |
|
387 |
@@ -2874,20 +2925,6 @@ static char *drmGetMinorNameForFD(int fd, int type) |
397 |
@@ -2895,20 +2946,6 @@ static char *drmGetMinorNameForFD(int fd, int type) |
388 |
if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) |
398 |
if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode)) |
389 |
return NULL; |
399 |
return NULL; |
390 |
|
400 |
|
391 |
- switch (type) { |
401 |
- switch (type) { |
Lines 405-411
Link Here
|
405 |
base = drmGetMinorBase(type); |
415 |
base = drmGetMinorBase(type); |
406 |
if (base < 0) |
416 |
if (base < 0) |
407 |
return NULL; |
417 |
return NULL; |
408 |
@@ -2990,7 +3027,7 @@ static int drmParseSubsystemType(int maj, int min) |
418 |
@@ -3011,7 +3048,7 @@ static int drmParseSubsystemType(int maj, int min) |
409 |
return DRM_BUS_VIRTIO; |
419 |
return DRM_BUS_VIRTIO; |
410 |
|
420 |
|
411 |
return -EINVAL; |
421 |
return -EINVAL; |
Lines 414-421
Link Here
|
414 |
return DRM_BUS_PCI; |
424 |
return DRM_BUS_PCI; |
415 |
#else |
425 |
#else |
416 |
#warning "Missing implementation of drmParseSubsystemType" |
426 |
#warning "Missing implementation of drmParseSubsystemType" |
417 |
@@ -3014,7 +3051,8 @@ get_real_pci_path(int maj, int min, char *real_path) |
427 |
@@ -3035,7 +3072,8 @@ get_pci_path(int maj, int min, char *pci_path) |
418 |
return real_path; |
428 |
*term = 0; |
419 |
} |
429 |
} |
420 |
|
430 |
|
421 |
-static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) |
431 |
-static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) |
Lines 424-430
Link Here
|
424 |
{ |
434 |
{ |
425 |
#ifdef __linux__ |
435 |
#ifdef __linux__ |
426 |
unsigned int domain, bus, dev, func; |
436 |
unsigned int domain, bus, dev, func; |
427 |
@@ -3064,6 +3102,60 @@ static int drmParsePciBusInfo(int maj, int min, drmPci |
437 |
@@ -3084,6 +3122,60 @@ static int drmParsePciBusInfo(int maj, int min, drmPci |
428 |
info->func = pinfo.func; |
438 |
info->func = pinfo.func; |
429 |
|
439 |
|
430 |
return 0; |
440 |
return 0; |
Lines 485-491
Link Here
|
485 |
#else |
495 |
#else |
486 |
#warning "Missing implementation of drmParsePciBusInfo" |
496 |
#warning "Missing implementation of drmParsePciBusInfo" |
487 |
return -EINVAL; |
497 |
return -EINVAL; |
488 |
@@ -3098,32 +3190,6 @@ int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b) |
498 |
@@ -3118,32 +3210,6 @@ drm_public int drmDevicesEqual(drmDevicePtr a, drmDevi |
489 |
return 0; |
499 |
return 0; |
490 |
} |
500 |
} |
491 |
|
501 |
|
Lines 518-524
Link Here
|
518 |
#ifdef __linux__ |
528 |
#ifdef __linux__ |
519 |
static int parse_separate_sysfs_files(int maj, int min, |
529 |
static int parse_separate_sysfs_files(int maj, int min, |
520 |
drmPciDeviceInfoPtr device, |
530 |
drmPciDeviceInfoPtr device, |
521 |
@@ -3198,6 +3264,7 @@ static int parse_config_sysfs_file(int maj, int min, |
531 |
@@ -3216,6 +3282,7 @@ static int parse_config_sysfs_file(int maj, int min, |
522 |
#endif |
532 |
#endif |
523 |
|
533 |
|
524 |
static int drmParsePciDeviceInfo(int maj, int min, |
534 |
static int drmParsePciDeviceInfo(int maj, int min, |
Lines 526-532
Link Here
|
526 |
drmPciDeviceInfoPtr device, |
536 |
drmPciDeviceInfoPtr device, |
527 |
uint32_t flags) |
537 |
uint32_t flags) |
528 |
{ |
538 |
{ |
529 |
@@ -3234,6 +3301,43 @@ static int drmParsePciDeviceInfo(int maj, int min, |
539 |
@@ -3252,6 +3319,43 @@ static int drmParsePciDeviceInfo(int maj, int min, |
530 |
device->subdevice_id = pinfo.subdevice_id; |
540 |
device->subdevice_id = pinfo.subdevice_id; |
531 |
|
541 |
|
532 |
return 0; |
542 |
return 0; |
Lines 570-576
Link Here
|
570 |
#else |
580 |
#else |
571 |
#warning "Missing implementation of drmParsePciDeviceInfo" |
581 |
#warning "Missing implementation of drmParsePciDeviceInfo" |
572 |
return -EINVAL; |
582 |
return -EINVAL; |
573 |
@@ -3314,7 +3418,7 @@ static drmDevicePtr drmDeviceAlloc(unsigned int type, |
583 |
@@ -3332,7 +3436,7 @@ static drmDevicePtr drmDeviceAlloc(unsigned int type, |
574 |
unsigned int i; |
584 |
unsigned int i; |
575 |
char *ptr; |
585 |
char *ptr; |
576 |
|
586 |
|
Lines 579-585
Link Here
|
579 |
extra = DRM_NODE_MAX * (sizeof(void *) + max_node_length); |
589 |
extra = DRM_NODE_MAX * (sizeof(void *) + max_node_length); |
580 |
|
590 |
|
581 |
size = sizeof(*device) + extra + bus_size + device_size; |
591 |
size = sizeof(*device) + extra + bus_size + device_size; |
582 |
@@ -3360,7 +3464,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, |
592 |
@@ -3378,7 +3482,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, |
583 |
|
593 |
|
584 |
dev->businfo.pci = (drmPciBusInfoPtr)addr; |
594 |
dev->businfo.pci = (drmPciBusInfoPtr)addr; |
585 |
|
595 |
|
Lines 588-594
Link Here
|
588 |
if (ret) |
598 |
if (ret) |
589 |
goto free_device; |
599 |
goto free_device; |
590 |
|
600 |
|
591 |
@@ -3369,7 +3473,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, |
601 |
@@ -3387,7 +3491,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, |
592 |
addr += sizeof(drmPciBusInfo); |
602 |
addr += sizeof(drmPciBusInfo); |
593 |
dev->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; |
603 |
dev->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; |
594 |
|
604 |
|
Lines 597-603
Link Here
|
597 |
if (ret) |
607 |
if (ret) |
598 |
goto free_device; |
608 |
goto free_device; |
599 |
} |
609 |
} |
600 |
@@ -3709,8 +3813,8 @@ process_device(drmDevicePtr *device, const char *d_nam |
610 |
@@ -3727,8 +3831,8 @@ process_device(drmDevicePtr *device, const char *d_nam |
601 |
int req_subsystem_type, |
611 |
int req_subsystem_type, |
602 |
bool fetch_deviceinfo, uint32_t flags) |
612 |
bool fetch_deviceinfo, uint32_t flags) |
603 |
{ |
613 |
{ |
Lines 608-614
Link Here
|
608 |
int node_type, subsystem_type; |
618 |
int node_type, subsystem_type; |
609 |
unsigned int maj, min; |
619 |
unsigned int maj, min; |
610 |
|
620 |
|
611 |
@@ -3718,14 +3822,14 @@ process_device(drmDevicePtr *device, const char *d_nam |
621 |
@@ -3736,7 +3840,7 @@ process_device(drmDevicePtr *device, const char *d_nam |
612 |
if (node_type < 0) |
622 |
if (node_type < 0) |
613 |
return -1; |
623 |
return -1; |
614 |
|
624 |
|
Lines 617-631
Link Here
|
617 |
if (stat(node, &sbuf)) |
627 |
if (stat(node, &sbuf)) |
618 |
return -1; |
628 |
return -1; |
619 |
|
629 |
|
620 |
maj = major(sbuf.st_rdev); |
630 |
@@ -3784,7 +3888,7 @@ static void drmFoldDuplicatedDevices(drmDevicePtr loca |
621 |
min = minor(sbuf.st_rdev); |
|
|
622 |
|
623 |
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) |
624 |
+ if (DRM_MAJOR && maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) |
625 |
return -1; |
626 |
|
627 |
subsystem_type = drmParseSubsystemType(maj, min); |
628 |
@@ -3766,7 +3870,7 @@ static void drmFoldDuplicatedDevices(drmDevicePtr loca |
629 |
local_devices[i]->available_nodes |= local_devices[j]->available_nodes; |
631 |
local_devices[i]->available_nodes |= local_devices[j]->available_nodes; |
630 |
node_type = log2(local_devices[j]->available_nodes); |
632 |
node_type = log2(local_devices[j]->available_nodes); |
631 |
memcpy(local_devices[i]->nodes[node_type], |
633 |
memcpy(local_devices[i]->nodes[node_type], |
Lines 634-640
Link Here
|
634 |
drmFreeDevice(&local_devices[j]); |
636 |
drmFreeDevice(&local_devices[j]); |
635 |
} |
637 |
} |
636 |
} |
638 |
} |
637 |
@@ -3806,7 +3910,7 @@ drm_device_has_rdev(drmDevicePtr device, dev_t find_rd |
639 |
@@ -3824,7 +3928,7 @@ drm_device_has_rdev(drmDevicePtr device, dev_t find_rd |
638 |
* Get information about the opened drm device |
640 |
* Get information about the opened drm device |
639 |
* |
641 |
* |
640 |
* \param fd file descriptor of the drm device |
642 |
* \param fd file descriptor of the drm device |
Lines 643-649
Link Here
|
643 |
* \param device the address of a drmDevicePtr where the information |
645 |
* \param device the address of a drmDevicePtr where the information |
644 |
* will be allocated in stored |
646 |
* will be allocated in stored |
645 |
* |
647 |
* |
646 |
@@ -3824,8 +3928,8 @@ int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr |
648 |
@@ -3842,8 +3946,8 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, d |
647 |
* Avoid stat'ing all of /dev needlessly by implementing this custom path. |
649 |
* Avoid stat'ing all of /dev needlessly by implementing this custom path. |
648 |
*/ |
650 |
*/ |
649 |
drmDevicePtr d; |
651 |
drmDevicePtr d; |
Lines 654-660
Link Here
|
654 |
const char *dev_name; |
656 |
const char *dev_name; |
655 |
int node_type, subsystem_type; |
657 |
int node_type, subsystem_type; |
656 |
int maj, min, n, ret, base; |
658 |
int maj, min, n, ret, base; |
657 |
@@ -3846,26 +3950,16 @@ int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr |
659 |
@@ -3864,26 +3968,16 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, d |
658 |
if (node_type == -1) |
660 |
if (node_type == -1) |
659 |
return -ENODEV; |
661 |
return -ENODEV; |
660 |
|
662 |
|
Lines 685-700
Link Here
|
685 |
return -errno; |
687 |
return -errno; |
686 |
if (stat(node, &sbuf)) |
688 |
if (stat(node, &sbuf)) |
687 |
return -EINVAL; |
689 |
return -EINVAL; |
688 |
@@ -3905,7 +3999,7 @@ int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr |
690 |
@@ -3989,7 +4083,7 @@ drm_public int drmGetDevice(int fd, drmDevicePtr *devi |
689 |
maj = major(sbuf.st_rdev); |
|
|
690 |
min = minor(sbuf.st_rdev); |
691 |
|
692 |
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) |
693 |
+ if ((DRM_MAJOR && maj != DRM_MAJOR) || !S_ISCHR(sbuf.st_mode)) |
694 |
return -EINVAL; |
695 |
|
696 |
subsystem_type = drmParseSubsystemType(maj, min); |
697 |
@@ -3971,7 +4065,7 @@ int drmGetDevice(int fd, drmDevicePtr *device) |
698 |
/** |
691 |
/** |
699 |
* Get drm devices on the system |
692 |
* Get drm devices on the system |
700 |
* |
693 |
* |
Lines 703-710
Link Here
|
703 |
* \param devices the array of devices with drmDevicePtr elements |
696 |
* \param devices the array of devices with drmDevicePtr elements |
704 |
* can be NULL to get the device number first |
697 |
* can be NULL to get the device number first |
705 |
* \param max_devices the maximum number of devices for the array |
698 |
* \param max_devices the maximum number of devices for the array |
706 |
@@ -4055,7 +4149,7 @@ int drmGetDevices(drmDevicePtr devices[], int max_devi |
699 |
@@ -4074,7 +4168,7 @@ drm_public int drmGetDevices(drmDevicePtr devices[], i |
707 |
char *drmGetDeviceNameFromFd2(int fd) |
700 |
drm_public char *drmGetDeviceNameFromFd2(int fd) |
708 |
{ |
701 |
{ |
709 |
#ifdef __linux__ |
702 |
#ifdef __linux__ |
710 |
- struct stat sbuf; |
703 |
- struct stat sbuf; |
Lines 712-718
Link Here
|
712 |
char path[PATH_MAX + 1], *value; |
705 |
char path[PATH_MAX + 1], *value; |
713 |
unsigned int maj, min; |
706 |
unsigned int maj, min; |
714 |
|
707 |
|
715 |
@@ -4078,9 +4172,26 @@ char *drmGetDeviceNameFromFd2(int fd) |
708 |
@@ -4097,9 +4191,26 @@ drm_public char *drmGetDeviceNameFromFd2(int fd) |
716 |
free(value); |
709 |
free(value); |
717 |
|
710 |
|
718 |
return strdup(path); |
711 |
return strdup(path); |
Lines 741-747
Link Here
|
741 |
const char *dev_name; |
734 |
const char *dev_name; |
742 |
int node_type; |
735 |
int node_type; |
743 |
int maj, min, n, base; |
736 |
int maj, min, n, base; |
744 |
@@ -4098,26 +4209,16 @@ char *drmGetDeviceNameFromFd2(int fd) |
737 |
@@ -4117,26 +4228,16 @@ drm_public char *drmGetDeviceNameFromFd2(int fd) |
745 |
if (node_type == -1) |
738 |
if (node_type == -1) |
746 |
return NULL; |
739 |
return NULL; |
747 |
|
740 |
|