Commit 94b49e9a authored by Austin Yuan's avatar Austin Yuan

android and dummy backend

Signed-off-by: default avatarAustin Yuan <shengquan.yuan@gmail.com>
parent 1f4d9627
...@@ -22,6 +22,8 @@ AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 $(DRM_CFLAGS) ...@@ -22,6 +22,8 @@ AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 $(DRM_CFLAGS)
noinst_LTLIBRARIES = libva_dummy.la noinst_LTLIBRARIES = libva_dummy.la
libva_dummy_la_LIBADD = $(LIBVA_LIBS) -ldl -ludev
libva_dummyincludedir = ${includedir}/va libva_dummyincludedir = ${includedir}/va
libva_dummy_la_SOURCES = va_android.c drmtest.c libva_dummy_la_SOURCES = va_android.c drmtest.c
......
...@@ -55,22 +55,24 @@ static int is_master(int fd) ...@@ -55,22 +55,24 @@ static int is_master(int fd)
} }
/** Open the first DRM device matching the criteria */ /** Open the first DRM device matching the criteria */
int drm_open_matching(const char *pci_glob, int flags, int *device_id) int drm_open_matching(const char *pci_glob, int flags, int *vendor_id, int *device_id)
{ {
struct udev *udev; struct udev *udev;
struct udev_enumerate *e; struct udev_enumerate *e;
struct udev_device *device, *parent; struct udev_device *device, *parent;
struct udev_list_entry *entry; struct udev_list_entry *entry;
const char *pci_id, *path; const char *pci_id, *path;
char *tmp;
int fd; int fd;
*device_id = ~0; *vendor_id = 0;
*device_id = 0;
udev = udev_new(); udev = udev_new();
if (udev == NULL) { if (udev == NULL) {
fprintf(stderr, "failed to initialize udev context\n"); fprintf(stderr, "failed to initialize udev context\n");
//abort();
return -1; return -1;
//abort();
} }
fd = -1; fd = -1;
...@@ -100,16 +102,16 @@ int drm_open_matching(const char *pci_glob, int flags, int *device_id) ...@@ -100,16 +102,16 @@ int drm_open_matching(const char *pci_glob, int flags, int *device_id)
} }
udev_enumerate_unref(e); udev_enumerate_unref(e);
udev_unref(udev); udev_unref(udev);
*device_id = pci_id;
*vendor_id = (int) strtol(pci_id, &tmp, 16);
*device_id = (int) strtol((tmp+1), NULL, 16);
return fd; return fd;
} }
int drm_open_any(void) int drm_open_any(int *vendor_id, int *device_id)
{ {
int dev_id; int fd = drm_open_matching("*:*", 0, vendor_id, device_id);
int fd = drm_open_matching("*:*", 0, &dev_id);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "failed to open any drm device\n"); fprintf(stderr, "failed to open any drm device\n");
...@@ -122,13 +124,14 @@ int drm_open_any(void) ...@@ -122,13 +124,14 @@ int drm_open_any(void)
/** /**
* Open the first DRM device we can find where we end up being the master. * Open the first DRM device we can find where we end up being the master.
*/ */
int drm_open_any_master(int *device_id) int drm_open_any_master(void)
{ {
int fd = drm_open_matching("*:*", DRM_TEST_MASTER, device_id); int vendor_id, device_id;
int fd = drm_open_matching("*:*", DRM_TEST_MASTER, &vendor_id, &device_id);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "failed to open any drm device\n"); fprintf(stderr, "failed to open any drm device\n");
//abort(); abort();
} }
return fd; return fd;
......
...@@ -35,6 +35,6 @@ ...@@ -35,6 +35,6 @@
#define DRM_TEST_MASTER 0x01 #define DRM_TEST_MASTER 0x01
int drm_open_any(void); int drm_open_any(int *vendor_id, int *device_id);
int drm_open_any_master(int *device_id); int drm_open_any_master(void);
int drm_open_matching(const char *pci_glob, int flags, int *device_id); int drm_open_matching(const char *pci_glob, int flags, int *vendor_id, int *device_id);
...@@ -90,20 +90,20 @@ static VAStatus va_DisplayContextGetDriverName ( ...@@ -90,20 +90,20 @@ static VAStatus va_DisplayContextGetDriverName (
VADriverContextP ctx = pDisplayContext->pDriverContext; VADriverContextP ctx = pDisplayContext->pDriverContext;
struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
char *driver_name_env; char *driver_name_env;
int dev_id; int vendor_id, device_id;
struct { struct {
int verndor_id; int vendor_id;
int device_id; int device_id;
char driver_name[64]; char driver_name[64];
} devices[] = { } devices[] = {
{ 0x8086, 0x4100, "pvr" }, { 0x8086, 0x4100, "pvr" },
{ 0x8086, 0x0310, "pvr" }, { 0x8086, 0x0130, "pvr" },
{ 0x0, 0x0, "\0" }, { 0x0, 0x0, "\0" },
}; };
memset(dri_state, 0, sizeof(*dri_state)); memset(dri_state, 0, sizeof(*dri_state));
dri_state->fd = drm_open_any_master(&dev_id); dri_state->fd = drm_open_any(&vendor_id, &device_id);
if (dri_state->fd < 0) { if (dri_state->fd < 0) {
fprintf(stderr,"can't open DRM devices\n"); fprintf(stderr,"can't open DRM devices\n");
...@@ -116,19 +116,27 @@ static VAStatus va_DisplayContextGetDriverName ( ...@@ -116,19 +116,27 @@ static VAStatus va_DisplayContextGetDriverName (
*driver_name = strdup(driver_name_env); *driver_name = strdup(driver_name_env);
return VA_STATUS_SUCCESS; return VA_STATUS_SUCCESS;
} else { /* TBD: other vendor driver names */ } else { /* TBD: other vendor driver names */
int i=0; int i = 0;
while ((devices[i].device_id !=0) && while (devices[i].device_id != 0) {
(devices[i].device_id != dev_id)) if ((devices[i].vendor_id == vendor_id) &&
(devices[i].device_id == device_id))
break;
i++; i++;
}
if (devices[i].device_id != 0) if (devices[i].device_id != 0)
*driver_name = strdup(devices[0].driver_name); *driver_name = strdup(devices[i].driver_name);
else { else {
fprintf(stderr,"device (0x%04x) is not supported\n", dev_id); fprintf(stderr,"device (0x%04x:0x%04x) is not supported\n",
vendor_id, device_id);
return VA_STATUS_ERROR_UNKNOWN; return VA_STATUS_ERROR_UNKNOWN;
} }
} }
printf("DRM device is opened, loading driver %s for device 0x%04x:0x%04x\n",
driver_name, vendor_id, device_id);
dri_state->driConnectedFlag = VA_DUMMY; dri_state->driConnectedFlag = VA_DUMMY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment