summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Yuan <shengquan.yuan@gmail.com>2010-04-29 07:20:56 +0800
committerAustin Yuan <shengquan.yuan@gmail.com>2010-04-29 07:20:56 +0800
commit1f4d9627ffd6594380f67ee1085c7aa132397e6b (patch)
tree3fd287e06fc6fc3563d17ef007055766f4f57521
parentbe467652b91634b7f6c8989a78c25469ffc1827e (diff)
parentc4a03c1016cd41e22ecc3410be6759aa0e1a71cf (diff)
downloadlibva-1f4d9627ffd6594380f67ee1085c7aa132397e6b.tar.gz
Merge branch 'va_backend' into PO
Conflicts: va/android/va_android.c va/va_android.h va/va_backend.h Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>
-rw-r--r--va/Android.mk16
-rw-r--r--va/android/drmtest.c18
-rw-r--r--va/android/drmtest.h4
-rw-r--r--va/android/va_android.c71
-rw-r--r--va/va.c10
-rw-r--r--va/va.h11
-rw-r--r--va/va_android.h28
-rw-r--r--va/va_backend.h8
-rw-r--r--va/x11/va_dricommon.h3
9 files changed, 84 insertions, 85 deletions
diff --git a/va/Android.mk b/va/Android.mk
index da0d705..1c49aa9 100644
--- a/va/Android.mk
+++ b/va/Android.mk
@@ -1,19 +1,24 @@
LOCAL_PATH:= $(call my-dir)
+LIBVA_MINOR_VERSION := 31
+LIBVA_MAJOR_VERSION := 0
+
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- android/va_android.c
+ va.c \
+ va_trace.c \
+ android/va_android.c \
+ android/drmtest.c \
+
LOCAL_CFLAGS += -DHAVE_CONFIG_H \
- -DIN_LIBVA \
+ -DANDROID \
LOCAL_C_INCLUDES += \
$(TOPDIR)kernel/include \
$(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)kernel/include/drm
-
-LOCAL_CC := g++
+ $(TOPDIR)kernel/include/drm
LOCAL_COPY_HEADERS_TO := libva/va
@@ -21,6 +26,7 @@ LOCAL_COPY_HEADERS := \
va.h \
va_backend.h \
va_version.h.in \
+ x11/va_dricommon.h \
va_android.h
LOCAL_MODULE := libva_android
diff --git a/va/android/drmtest.c b/va/android/drmtest.c
index 3a8bd0d..85be50a 100644
--- a/va/android/drmtest.c
+++ b/va/android/drmtest.c
@@ -55,7 +55,7 @@ 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 drm_open_matching(const char *pci_glob, int flags, int *device_id)
{
struct udev *udev;
struct udev_enumerate *e;
@@ -64,10 +64,13 @@ int drm_open_matching(const char *pci_glob, int flags)
const char *pci_id, *path;
int fd;
+ *device_id = ~0;
+
udev = udev_new();
if (udev == NULL) {
fprintf(stderr, "failed to initialize udev context\n");
- abort();
+ //abort();
+ return -1;
}
fd = -1;
@@ -97,13 +100,16 @@ int drm_open_matching(const char *pci_glob, int flags)
}
udev_enumerate_unref(e);
udev_unref(udev);
-
+ *device_id = pci_id;
+
return fd;
}
int drm_open_any(void)
{
- int fd = drm_open_matching("*:*", 0);
+ int dev_id;
+
+ int fd = drm_open_matching("*:*", 0, &dev_id);
if (fd < 0) {
fprintf(stderr, "failed to open any drm device\n");
@@ -116,9 +122,9 @@ 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(void)
+int drm_open_any_master(int *device_id)
{
- int fd = drm_open_matching("*:*", DRM_TEST_MASTER);
+ int fd = drm_open_matching("*:*", DRM_TEST_MASTER, device_id);
if (fd < 0) {
fprintf(stderr, "failed to open any drm device\n");
diff --git a/va/android/drmtest.h b/va/android/drmtest.h
index 55bb446..875b03f 100644
--- a/va/android/drmtest.h
+++ b/va/android/drmtest.h
@@ -36,5 +36,5 @@
#define DRM_TEST_MASTER 0x01
int drm_open_any(void);
-int drm_open_any_master(void);
-int drm_open_matching(const char *pci_glob, int flags);
+int drm_open_any_master(int *device_id);
+int drm_open_matching(const char *pci_glob, int flags, int *device_id);
diff --git a/va/android/va_android.c b/va/android/va_android.c
index 6868084..e9140e6 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 "va_dricommon.h"
+#include "va_dricommon.h" /* needs some helper functions from this file */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -35,11 +35,15 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <dlfcn.h>
#include <errno.h>
+#define CHECK_SYMBOL(func) { if (!func) printf("func %s not found\n", #func); return VA_STATUS_ERROR_UNKNOWN; }
+#define DEVICE_NAME "/dev/dri/card0"
static VADisplayContextP pDisplayContexts = NULL;
+
static int va_DisplayContextIsValid (
VADisplayContextP pDisplayContext
)
@@ -86,21 +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;
struct {
- unsigned int verndor_id;
- unsigned int device_id;
+ int verndor_id;
+ int device_id;
char driver_name[64];
} devices[] = {
{ 0x8086, 0x4100, "pvr" },
+ { 0x8086, 0x0310, "pvr" },
+ { 0x0, 0x0, "\0" },
};
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);
- }
+ dri_state->fd = drm_open_any_master(&dev_id);
if (dri_state->fd < 0) {
fprintf(stderr,"can't open DRM devices\n");
@@ -108,14 +111,24 @@ static VAStatus va_DisplayContextGetDriverName (
}
if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL
- && geteuid() == getuid())
- {
+ && 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);
-
+ } else { /* TBD: other vendor driver names */
+ int i=0;
+
+ while ((devices[i].device_id !=0) &&
+ (devices[i].device_id != dev_id))
+ i++;
+
+ if (devices[i].device_id != 0)
+ *driver_name = strdup(devices[0].driver_name);
+ else {
+ fprintf(stderr,"device (0x%04x) is not supported\n", dev_id);
+ return VA_STATUS_ERROR_UNKNOWN;
+ }
+ }
dri_state->driConnectedFlag = VA_DUMMY;
@@ -144,6 +157,7 @@ VADisplay vaGetDisplay (
pDisplayContext = pDisplayContext->pNext;
}
+
if (!dpy)
{
/* create new entry */
@@ -152,7 +166,6 @@ VADisplay vaGetDisplay (
pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext));
pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext));
dri_state = calloc(1, sizeof(*dri_state));
-
if (pDisplayContext && pDriverContext && dri_state)
{
pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
@@ -181,7 +194,6 @@ VADisplay vaGetDisplay (
return dpy;
}
-
#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
@@ -214,36 +226,9 @@ VAStatus vaPutSurface (
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
+ return ctx->vtable.vaPutSurface( ctx, surface, (void *)draw, srcx, srcy, srcw, srch,
destx, desty, destw, desth,
cliprects, number_cliprects, flags );
}
-VAStatus vaPutSurfaceBuf (
- VADisplay dpy,
- VASurfaceID surface,
- Drawable draw, /* Android Surface/Window */
- 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 */
-)
-{
- VADriverContextP ctx;
-
- CHECK_DISPLAY(dpy);
- ctx = CTX(dpy);
-
- return ctx->vtable.vaPutSurfaceBuf( ctx, surface, draw, data, data_len, srcx, srcy, srcw, srch,
- destx, desty, destw, desth, cliprects, number_cliprects, flags );
-}
#endif
diff --git a/va/va.c b/va/va.c
index 0369044..b91c588 100644
--- a/va/va.c
+++ b/va/va.c
@@ -25,6 +25,7 @@
#define _GNU_SOURCE 1
#include "va.h"
#include "va_backend.h"
+#include "config.h"
#include <assert.h>
#include <stdarg.h>
@@ -54,6 +55,10 @@ extern int trace_flag;
trace_func(__VA_ARGS__); \
}
+#define VA_MAJOR_VERSION (0)
+#define VA_MINOR_VERSION (31)
+#define VA_VERSION_S "0.31.1"
+
static int vaDisplayIsValid(VADisplay dpy)
{
VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
@@ -153,8 +158,11 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) );
va_infoMessage("Trying to open %s\n", driver_path);
-
+#ifndef ANDROID
handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE );
+#else
+ handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL);
+#endif
if (!handle)
{
/* Don't give errors for non-existing files */
diff --git a/va/va.h b/va/va.h
index de962df..66334b4 100644
--- a/va/va.h
+++ b/va/va.h
@@ -1804,6 +1804,17 @@ VAStatus vaSetDisplayAttributes (
int num_attributes
);
+#ifdef ANDROID
+#define Display unsigned int
+#define Drawable unsigned int
+#define XID unsigned int
+#define Bool int
+#define Status int
+#define True 1
+#define False 0
+#define Xfree(ptr) free((ptr))
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/va/va_android.h b/va/va_android.h
index 4b92c88..bba85f7 100644
--- a/va/va_android.h
+++ b/va/va_android.h
@@ -2,22 +2,18 @@
#define _VA_ANDROID_H_
#include <va/va.h>
-
-
#ifdef __cplusplus
extern "C" {
#endif
-
/*
* Returns a suitable VADisplay for VA API
*/
VADisplay vaGetDisplay (
- void *dpy
+ void *android_dpy
);
-#ifdef ANDROID
-
+#if ANDROID
#include <ui/Surface.h>
class Surface;
@@ -45,26 +41,6 @@ VAStatus vaPutSurface (
unsigned int number_cliprects, /* number of clip rects in the clip list */
unsigned int flags /* PutSurface 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 */
-);
-
#endif
#ifdef __cplusplus
diff --git a/va/va_backend.h b/va/va_backend.h
index a857857..54db430 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -30,12 +30,18 @@
#define _VA_BACKEND_H_
#include <va/va.h>
+#ifndef ANDROID
#include <X11/Xlib.h>
+#endif
#include <linux/videodev2.h>
typedef struct VADriverContext *VADriverContextP;
typedef struct VADisplayContext *VADisplayContextP;
+#ifdef ANDROID
+#define Surface void
+#endif
+
struct VADriverVTable
{
VAStatus (*vaTerminate) ( VADriverContextP ctx );
@@ -179,7 +185,7 @@ struct VADriverVTable
VAStatus (*vaPutSurface) (
VADriverContextP ctx,
VASurfaceID surface,
- void* draw, /* X Drawable */
+ void * draw, /* Drawable of window system */
short srcx,
short srcy,
unsigned short srcw,
diff --git a/va/x11/va_dricommon.h b/va/x11/va_dricommon.h
index 437b64f..8345816 100644
--- a/va/x11/va_dricommon.h
+++ b/va/x11/va_dricommon.h
@@ -1,8 +1,9 @@
#ifndef _VA_DRICOMMON_H_
#define _VA_DRICOMMON_H_
+#ifndef ANDROID
#include <X11/Xlib.h>
-
+#endif
#include <xf86drm.h>
#include <drm.h>
#include <drm_sarea.h>