summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRen Zhaohan <zhaohan.ren@intel.com>2010-04-27 14:36:24 +0800
committerRen Zhaohan <zhaohan.ren@intel.com>2010-04-27 14:36:24 +0800
commitc4a03c1016cd41e22ecc3410be6759aa0e1a71cf (patch)
treef2956c9fa8df9b84a15b65e6a4f5c1c912149fc2
parent24914b55e70e2012682eecd8e81bb3bd5fada310 (diff)
downloadlibva-c4a03c1016cd41e22ecc3410be6759aa0e1a71cf.tar.gz
libva backend
-rw-r--r--va/Android.mk13
-rw-r--r--va/android/va_android.c67
-rw-r--r--va/va.c10
-rw-r--r--va/va.h11
-rw-r--r--va/va_android.h8
-rw-r--r--va/va_backend.h13
-rw-r--r--va/x11/va_dricommon.h3
7 files changed, 105 insertions, 20 deletions
diff --git a/va/Android.mk b/va/Android.mk
index da0d705..5398ce9 100644
--- a/va/Android.mk
+++ b/va/Android.mk
@@ -1,19 +1,23 @@
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 \
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 +25,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/va_android.c b/va/android/va_android.c
index ec15d6a..637922a 100644
--- a/va/android/va_android.c
+++ b/va/android/va_android.c
@@ -23,9 +23,10 @@
*/
#define _GNU_SOURCE 1
-#include "../va.h"
-#include "../va_backend.h"
-#include "../va_android.h"
+#include "va.h"
+#include "va_backend.h"
+#include "va_android.h"
+#include "x11/va_dricommon.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -34,10 +35,44 @@
#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 open_device (char *dev_name)
+{
+ struct stat st;
+ int fd;
+
+ if (-1 == stat (dev_name, &st))
+ {
+ printf ("Cannot identify '%s': %d, %s\n",
+ dev_name, errno, strerror (errno));
+ return -1;
+ }
+
+ if (!S_ISCHR (st.st_mode))
+ {
+ printf ("%s is no device\n", dev_name);
+ return -1;
+ }
+
+ fd = open (dev_name, O_RDWR /* required */ | O_NONBLOCK, 0);
+
+ if (-1 == fd)
+ {
+ fprintf (stderr, "Cannot open '%s': %d, %s\n",
+ dev_name, errno, strerror (errno));
+ return -1;
+ }
+
+ return fd;
+}
+
static int va_DisplayContextIsValid (
VADisplayContextP pDisplayContext
)
@@ -78,7 +113,7 @@ static VAStatus va_DisplayContextGetDriverName (
unsigned int device_id;
char driver_name[64];
} devices[] = {
- { 0x8086, 0x4100, "android" },
+ { 0x8086, 0x4100, "psb" },
};
if (driver_name)
@@ -111,13 +146,27 @@ VADisplay vaGetDisplay (
pDisplayContext = pDisplayContext->pNext;
}
+
if (!dpy)
{
/* create new entry */
VADriverContextP pDriverContext;
+ struct dri_state *dri_state;
+
pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext));
pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext));
- if (pDisplayContext && pDriverContext)
+ dri_state = (struct dri_state*)calloc(1, sizeof(*dri_state));
+
+ /* assgin necessary dri_state struct variable */
+ dri_state->driConnectedFlag = VA_DRI2;
+ dri_state->fd = open_device(DEVICE_NAME);
+ dri_state->createDrawable = NULL;
+ dri_state->destroyDrawable = NULL;
+ dri_state->swapBuffer = NULL;
+ dri_state->getRenderingBuffer = NULL;
+ dri_state->close = NULL;
+
+ if (pDisplayContext && pDriverContext && dri_state)
{
pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
@@ -128,6 +177,7 @@ VADisplay vaGetDisplay (
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
pDisplayContexts = pDisplayContext;
+ pDriverContext->dri_state = dri_state;
dpy = (VADisplay)pDisplayContext;
}
else
@@ -136,13 +186,14 @@ VADisplay vaGetDisplay (
free(pDisplayContext);
if (pDriverContext)
free(pDriverContext);
+ if (dri_state)
+ free(dri_state);
}
}
return dpy;
}
-
#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
@@ -155,7 +206,8 @@ static int vaDisplayIsValid(VADisplay dpy)
VAStatus vaPutSurface (
VADisplay dpy,
VASurfaceID surface,
- Surface *draw, /* Android Surface/Window */
+ //Surface *draw, /* Android Surface/Window */
+ void *draw,
short srcx,
short srcy,
unsigned short srcw,
@@ -178,3 +230,4 @@ VAStatus vaPutSurface (
destx, desty, destw, desth,
cliprects, number_cliprects, flags );
}
+
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 394b810..c2a811b 100644
--- a/va/va.h
+++ b/va/va.h
@@ -1789,6 +1789,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 9858049..27ffff3 100644
--- a/va/va_android.h
+++ b/va/va_android.h
@@ -2,16 +2,16 @@
#define _VA_ANDROID_H_
#include <va/va.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+//#define Surface void
/*
* Returns a suitable VADisplay for VA API
*/
VADisplay vaGetDisplay (
- void *dpy
+ Display *dpy
);
/*
@@ -25,7 +25,8 @@ VADisplay vaGetDisplay (
VAStatus vaPutSurface (
VADisplay dpy,
VASurfaceID surface,
- Surface *draw, /* Android Window/Surface */
+ //Surface *draw, /* Android Window/Surface */
+ void* draw,
short srcx,
short srcy,
unsigned short srcw,
@@ -38,7 +39,6 @@ VAStatus vaPutSurface (
unsigned int number_cliprects, /* number of clip rects in the clip list */
unsigned int flags /* PutSurface flags */
);
-
#ifdef __cplusplus
}
#endif
diff --git a/va/va_backend.h b/va/va_backend.h
index cd6201e..b496b35 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -30,15 +30,18 @@
#define _VA_BACKEND_H_
#include <va/va.h>
+#ifndef ANDROID
#include <X11/Xlib.h>
+#endif
#include <linux/videodev2.h>
-#include <ui/Surface.h>
-
-class Surface;
typedef struct VADriverContext *VADriverContextP;
typedef struct VADisplayContext *VADisplayContextP;
+#ifdef ANDROID
+#define Surface void
+#endif
+
struct VADriverVTable
{
VAStatus (*vaTerminate) ( VADriverContextP ctx );
@@ -182,7 +185,11 @@ struct VADriverVTable
VAStatus (*vaPutSurface) (
VADriverContextP ctx,
VASurfaceID surface,
+ #ifdef ANDROID
Surface* draw, /* X Drawable */
+ #else
+ Drawable draw,
+ #endif
short srcx,
short srcy,
unsigned short srcw,
diff --git a/va/x11/va_dricommon.h b/va/x11/va_dricommon.h
index b762bd0..cae8fdd 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>