[PATCH libdrm 5/5] tests/drmdevice: use drmGetDevice[s]2

2016-12-05 Thread Michel Dänzer
On 03/12/16 01:32 AM, Emil Velikov wrote:
> From: Emil Velikov 
> 
> Pass along DRM_DEVICE_GET_PCI_REVISION only when the individual nodes
> are opened and update the printed messages accordingly.
> 
> v2: Attribute for the flag rename, call drmGetDevices2 w/o the flag.
> 
> Signed-off-by: Emil Velikov 
> Reviewed-by: Michel Dänzer 

[...]

> diff --git a/xf86drm.c b/xf86drm.c
> index 52e9b9f..a886768 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -3019,7 +3019,7 @@ static int drmParsePciDeviceInfo(int maj, int min,
>   uint32_t flags)
>  {
>  #ifdef __linux__
> -if (flags & DRM_DEVICE_GET_PCI_REVISION == 0)
> +if (!(flags & DRM_DEVICE_GET_PCI_REVISION))
>  return parse_separate_sysfs_files(maj, min, device, true);
>  
>  if (parse_separate_sysfs_files(maj, min, device, false))
> 

Please squash this hunk into patch 4 before pushing.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer


[PATCH libdrm 5/5] tests/drmdevice: use drmGetDevice[s]2

2016-12-02 Thread Emil Velikov
From: Emil Velikov 

Pass along DRM_DEVICE_GET_PCI_REVISION only when the individual nodes
are opened and update the printed messages accordingly.

v2: Attribute for the flag rename, call drmGetDevices2 w/o the flag.

Signed-off-by: Emil Velikov 
Reviewed-by: Michel Dänzer 
---
 tests/drmdevice.c | 23 ++-
 xf86drm.c |  2 +-
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/tests/drmdevice.c b/tests/drmdevice.c
index 72e7066..8c4f091 100644
--- a/tests/drmdevice.c
+++ b/tests/drmdevice.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -32,7 +33,7 @@


 static void
-print_device_info(drmDevicePtr device, int i)
+print_device_info(drmDevicePtr device, int i, bool print_revision)
 {
 printf("device[%i]\n", i);
 printf("\tavailable_nodes %04x\n", device->available_nodes);
@@ -56,7 +57,11 @@ print_device_info(drmDevicePtr device, int i)
 printf("\t\t\tdevice_id\t%04x\n", device->deviceinfo.pci->device_id);
 printf("\t\t\tsubvendor_id\t%04x\n", 
device->deviceinfo.pci->subvendor_id);
 printf("\t\t\tsubdevice_id\t%04x\n", 
device->deviceinfo.pci->subdevice_id);
-printf("\t\t\trevision_id\t%02x\n", 
device->deviceinfo.pci->revision_id);
+if (print_revision)
+printf("\t\t\trevision_id\t%02x\n", 
device->deviceinfo.pci->revision_id);
+else
+printf("\t\t\trevision_id\tIGNORED\n");
+
 } else {
 printf("Unknown/unhandled bustype\n");
 }
@@ -70,10 +75,10 @@ main(void)
 drmDevicePtr device;
 int fd, ret, max_devices;

-max_devices = drmGetDevices(NULL, 0);
+max_devices = drmGetDevices2(0, NULL, 0);

 if (max_devices <= 0) {
-printf("drmGetDevices() has returned %d\n", max_devices);
+printf("drmGetDevices2() has returned %d\n", max_devices);
 return -1;
 }

@@ -83,15 +88,15 @@ main(void)
 return -1;
 }

-ret = drmGetDevices(devices, max_devices);
+ret = drmGetDevices2(0, devices, max_devices);
 if (ret < 0) {
-printf("drmGetDevices() returned an error %d\n", ret);
+printf("drmGetDevices2() returned an error %d\n", ret);
 free(devices);
 return -1;
 }

 for (int i = 0; i < ret; i++) {
-print_device_info(devices[i], i);
+print_device_info(devices[i], i, false);

 for (int j = 0; j < DRM_NODE_MAX; j++) {
 if (devices[i]->available_nodes & 1 << j) {
@@ -102,8 +107,8 @@ main(void)
 continue;
 }

-if (drmGetDevice(fd, ) == 0) {
-print_device_info(device, i);
+if (drmGetDevice2(fd, DRM_DEVICE_GET_PCI_REVISION, ) == 
0) {
+print_device_info(device, i, true);
 drmFreeDevice();
 }
 close(fd);
diff --git a/xf86drm.c b/xf86drm.c
index 52e9b9f..a886768 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3019,7 +3019,7 @@ static int drmParsePciDeviceInfo(int maj, int min,
  uint32_t flags)
 {
 #ifdef __linux__
-if (flags & DRM_DEVICE_GET_PCI_REVISION == 0)
+if (!(flags & DRM_DEVICE_GET_PCI_REVISION))
 return parse_separate_sysfs_files(maj, min, device, true);

 if (parse_separate_sysfs_files(maj, min, device, false))
-- 
2.10.2



[PATCH libdrm 5/5] tests/drmdevice: use drmGetDevice[s]2

2016-11-30 Thread Emil Velikov
From: Emil Velikov 

... alongside the DRM_DEVICE_IGNORE_PCI_REVISION flag.

Signed-off-by: Emil Velikov 
---
 tests/drmdevice.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/drmdevice.c b/tests/drmdevice.c
index 72e7066..dcad527 100644
--- a/tests/drmdevice.c
+++ b/tests/drmdevice.c
@@ -70,7 +70,7 @@ main(void)
 drmDevicePtr device;
 int fd, ret, max_devices;

-max_devices = drmGetDevices(NULL, 0);
+max_devices = drmGetDevices2(DRM_DEVICE_IGNORE_PCI_REVISION, NULL, 0);

 if (max_devices <= 0) {
 printf("drmGetDevices() has returned %d\n", max_devices);
@@ -83,7 +83,7 @@ main(void)
 return -1;
 }

-ret = drmGetDevices(devices, max_devices);
+ret = drmGetDevices2(DRM_DEVICE_IGNORE_PCI_REVISION, devices, max_devices);
 if (ret < 0) {
 printf("drmGetDevices() returned an error %d\n", ret);
 free(devices);
@@ -102,7 +102,7 @@ main(void)
 continue;
 }

-if (drmGetDevice(fd, ) == 0) {
+if (drmGetDevice2(fd, DRM_DEVICE_IGNORE_PCI_REVISION, ) 
== 0) {
 print_device_info(device, i);
 drmFreeDevice();
 }
-- 
2.10.2