From 94b49e9a8880f7f00e7996d2c13096a775482808 Mon Sep 17 00:00:00 2001 From: Austin Yuan Date: Thu, 29 Apr 2010 11:34:10 +0800 Subject: [PATCH] android and dummy backend Signed-off-by: Austin Yuan --- va/android/Makefile.am | 2 ++ va/android/drmtest.c | 25 ++++++++++++++----------- va/android/drmtest.h | 6 +++--- va/android/va_android.c | 26 +++++++++++++++++--------- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/va/android/Makefile.am b/va/android/Makefile.am index 3b8cbc9..748701d 100644 --- a/va/android/Makefile.am +++ b/va/android/Makefile.am @@ -22,6 +22,8 @@ AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 $(DRM_CFLAGS) noinst_LTLIBRARIES = libva_dummy.la +libva_dummy_la_LIBADD = $(LIBVA_LIBS) -ldl -ludev + libva_dummyincludedir = ${includedir}/va libva_dummy_la_SOURCES = va_android.c drmtest.c diff --git a/va/android/drmtest.c b/va/android/drmtest.c index 85be50a..444ef47 100644 --- a/va/android/drmtest.c +++ b/va/android/drmtest.c @@ -55,22 +55,24 @@ static int is_master(int fd) } /** 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_enumerate *e; struct udev_device *device, *parent; struct udev_list_entry *entry; const char *pci_id, *path; + char *tmp; int fd; - *device_id = ~0; + *vendor_id = 0; + *device_id = 0; udev = udev_new(); if (udev == NULL) { fprintf(stderr, "failed to initialize udev context\n"); - //abort(); return -1; + //abort(); } fd = -1; @@ -100,16 +102,16 @@ int drm_open_matching(const char *pci_glob, int flags, int *device_id) } udev_enumerate_unref(e); 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; } -int drm_open_any(void) +int drm_open_any(int *vendor_id, int *device_id) { - int dev_id; - - int fd = drm_open_matching("*:*", 0, &dev_id); + int fd = drm_open_matching("*:*", 0, vendor_id, device_id); if (fd < 0) { fprintf(stderr, "failed to open any drm device\n"); @@ -122,13 +124,14 @@ int drm_open_any(void) /** * 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) { fprintf(stderr, "failed to open any drm device\n"); - //abort(); + abort(); } return fd; diff --git a/va/android/drmtest.h b/va/android/drmtest.h index 875b03f..5f10f08 100644 --- a/va/android/drmtest.h +++ b/va/android/drmtest.h @@ -35,6 +35,6 @@ #define DRM_TEST_MASTER 0x01 -int drm_open_any(void); -int drm_open_any_master(int *device_id); -int drm_open_matching(const char *pci_glob, int flags, int *device_id); +int drm_open_any(int *vendor_id, int *device_id); +int drm_open_any_master(void); +int drm_open_matching(const char *pci_glob, int flags, int *vendor_id, int *device_id); diff --git a/va/android/va_android.c b/va/android/va_android.c index e9140e6..8c0a75e 100644 --- a/va/android/va_android.c +++ b/va/android/va_android.c @@ -90,20 +90,20 @@ static VAStatus va_DisplayContextGetDriverName ( VADriverContextP ctx = pDisplayContext->pDriverContext; struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; char *driver_name_env; - int dev_id; + int vendor_id, device_id; struct { - int verndor_id; + int vendor_id; int device_id; char driver_name[64]; } devices[] = { { 0x8086, 0x4100, "pvr" }, - { 0x8086, 0x0310, "pvr" }, + { 0x8086, 0x0130, "pvr" }, { 0x0, 0x0, "\0" }, }; 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) { fprintf(stderr,"can't open DRM devices\n"); @@ -116,19 +116,27 @@ static VAStatus va_DisplayContextGetDriverName ( *driver_name = strdup(driver_name_env); return VA_STATUS_SUCCESS; } else { /* TBD: other vendor driver names */ - int i=0; + int i = 0; - while ((devices[i].device_id !=0) && - (devices[i].device_id != dev_id)) + while (devices[i].device_id != 0) { + if ((devices[i].vendor_id == vendor_id) && + (devices[i].device_id == device_id)) + break; i++; + } if (devices[i].device_id != 0) - *driver_name = strdup(devices[0].driver_name); + *driver_name = strdup(devices[i].driver_name); 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; } } + + 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; -- 2.11.0