Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created August 21, 2014 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Constellation/a0130e59964c2450ae18 to your computer and use it in GitHub Desktop.
Save Constellation/a0130e59964c2450ae18 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <errno.h>
#include "xf86drm.h"
#include "xf86drmMode.h"
#include "nouveau_drm.h"
#include "nouveau.h"
int
pvdrm_device_open(const char *busid, struct nouveau_device **pdev)
{
int ret = -ENODEV, fd = drmOpen("pvdrm", busid);
if (fd >= 0) {
ret = nouveau_device_wrap(fd, 1, pdev);
if (ret)
drmClose(fd);
}
return ret;
}
int main(int argc, char** argv) {
struct nouveau_device *dev;
struct nouveau_client *priv;
if (!drmAvailable()) {
printf("not available\n");
return 1;
}
int ret = -ENODEV;
int fd = drmOpen("pvdrm", NULL);
if (fd < 0) {
printf("fail\n");
return 1;
}
if (pvdrm_device_open(0, &dev)) {
printf("out\n");
return 1;
}
printf("%u\n", dev->chipset);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment