From 5bc5efa30ce3a53b69c2560ab50e1a3d9367fdac Mon Sep 17 00:00:00 2001 From: Ren Zhaohan Date: Wed, 5 May 2010 16:19:39 +0800 Subject: [PATCH] add new va_DisplayContextGetDriverName, remove 'x11/XX' include folder name --- va/Android.mk | 1 + va/android/va_android.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++--- va/va_android.h | 3 +-- va/va_backend.h | 25 +++++------------------ 4 files changed, 57 insertions(+), 25 deletions(-) diff --git a/va/Android.mk b/va/Android.mk index eb9967d..5eb8e6d 100644 --- a/va/Android.mk +++ b/va/Android.mk @@ -17,6 +17,7 @@ LOCAL_CFLAGS += -DHAVE_CONFIG_H \ LOCAL_C_INCLUDES += \ $(TOPDIR)kernel/include \ $(TARGET_OUT_HEADERS)/libva \ + $(LOCAL_PATH)/x11 \ $(TOPDIR)kernel/include/drm LOCAL_COPY_HEADERS_TO := libva/va diff --git a/va/android/va_android.c b/va/android/va_android.c index 5ccf998..39b1876 100644 --- a/va/android/va_android.c +++ b/va/android/va_android.c @@ -26,7 +26,7 @@ #include "va.h" #include "va_backend.h" #include "va_android.h" -#include "x11/va_dricommon.h" /* needs some helper functions from this file */ +#include "va_dricommon.h" /* needs some helper functions from this file */ #include #include #include @@ -37,6 +37,10 @@ #include #include #include +#ifndef ANDROID +#include +#include "drm_test.h" +#endif #define CHECK_SYMBOL(func) { if (!func) printf("func %s not found\n", #func); return VA_STATUS_ERROR_UNKNOWN; } #define DEVICE_NAME "/dev/dri/card0" @@ -110,7 +114,7 @@ static void va_DisplayContextDestroy ( free(pDisplayContext); } - +#ifdef ANDROID static VAStatus va_DisplayContextGetDriverName ( VADisplayContextP pDisplayContext, char **driver_name @@ -154,7 +158,51 @@ static VAStatus va_DisplayContextGetDriverName ( return VA_STATUS_SUCCESS; } +#else +static VAStatus va_DisplayContextGetDriverName ( + VADisplayContextP pDisplayContext, + char **driver_name +) +{ + VADriverContextP ctx = pDisplayContext->pDriverContext; + struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; + char *driver_name_env; + + struct { + unsigned int vendor_id; + unsigned int device_id; + char driver_name[64]; + } devices[] = { + { 0x8086, 0x4100, "pvr" }, + }; + memset(dri_state, 0, sizeof(*dri_state)); + dri_state->fd = drm_open_any_master(); + if (dri_state->fd < 0) { + fprintf(stderr, "open DRM device by udev failed, try /dev/dri/card0\n"); + dri_state->fd = open("/dev/dri/card0", O_RDWR); + } + + if (dri_state->fd < 0) { + fprintf(stderr,"can't open DRM devices\n"); + return VA_STATUS_ERROR_UNKNOWN; + } + + if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL + && geteuid() == getuid()) + { + /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ + *driver_name = strdup(driver_name_env); + return VA_STATUS_SUCCESS; + } else /* TBD: other vendor driver names */ + *driver_name = strdup(devices[0].driver_name); + + + dri_state->driConnectedFlag = VA_DUMMY; + + return VA_STATUS_SUCCESS; +} +#endif VADisplay vaGetDisplay ( void *native_dpy /* implementation specific */ @@ -245,7 +293,6 @@ VAStatus vaPutSurface ( CHECK_DISPLAY(dpy); ctx = CTX(dpy); - return ctx->vtable.vaPutSurface( ctx, surface, (void *)draw, srcx, srcy, srcw, srch, destx, desty, destw, desth, cliprects, number_cliprects, flags ); diff --git a/va/va_android.h b/va/va_android.h index 3e050b8..43b2730 100644 --- a/va/va_android.h +++ b/va/va_android.h @@ -5,7 +5,6 @@ #ifdef __cplusplus extern "C" { #endif - /* * Returns a suitable VADisplay for VA API */ @@ -16,7 +15,7 @@ VADisplay vaGetDisplay ( #if ANDROID //#include //class Surface; - + /* * Output rendering * Following is the rendering interface for X windows, diff --git a/va/va_backend.h b/va/va_backend.h index 54db430..f457cc4 100644 --- a/va/va_backend.h +++ b/va/va_backend.h @@ -185,7 +185,11 @@ struct VADriverVTable VAStatus (*vaPutSurface) ( VADriverContextP ctx, VASurfaceID surface, - void * draw, /* Drawable of window system */ +#ifdef ANDROID + Surface* draw, /* Drawable of window system */ +#else + Drawable draw, +#endif short srcx, short srcy, unsigned short srcw, @@ -199,25 +203,6 @@ struct VADriverVTable unsigned int flags /* de-interlacing flags */ ); - VAStatus (*vaPutSurfaceBuf) ( - VADriverContextP ctx, - VASurfaceID surface, - Drawable draw, /* X Drawable */ - unsigned char* data, - int* data_len, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth, - VARectangle *cliprects, /* client supplied clip list */ - unsigned int number_cliprects, /* number of clip rects in the clip list */ - unsigned int flags /* de-interlacing flags */ - ); - VAStatus (*vaQueryImageFormats) ( VADriverContextP ctx, VAImageFormat *format_list, /* out */ -- 2.7.4