• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/libva


Commit MetaInfo

修订版c4a03c1016cd41e22ecc3410be6759aa0e1a71cf (tree)
时间2010-04-27 15:36:24
作者Ren Zhaohan <zhaohan.ren@inte...>
CommiterRen Zhaohan

Log Message

libva backend

更改概述

差异

--- a/va/Android.mk
+++ b/va/Android.mk
@@ -1,19 +1,23 @@
11 LOCAL_PATH:= $(call my-dir)
22
3+LIBVA_MINOR_VERSION := 31
4+LIBVA_MAJOR_VERSION := 0
5+
36 include $(CLEAR_VARS)
47
58 LOCAL_SRC_FILES := \
6- android/va_android.c
9+ va.c \
10+ va_trace.c \
11+ android/va_android.c \
712
813 LOCAL_CFLAGS += -DHAVE_CONFIG_H \
914 -DIN_LIBVA \
15+ -DANDROID \
1016
1117 LOCAL_C_INCLUDES += \
1218 $(TOPDIR)kernel/include \
1319 $(TARGET_OUT_HEADERS)/libva \
14- $(TOPDIR)kernel/include/drm
15-
16-LOCAL_CC := g++
20+ $(TOPDIR)kernel/include/drm
1721
1822 LOCAL_COPY_HEADERS_TO := libva/va
1923
@@ -21,6 +25,7 @@ LOCAL_COPY_HEADERS := \
2125 va.h \
2226 va_backend.h \
2327 va_version.h.in \
28+ x11/va_dricommon.h \
2429 va_android.h
2530
2631 LOCAL_MODULE := libva_android
--- a/va/android/va_android.c
+++ b/va/android/va_android.c
@@ -23,9 +23,10 @@
2323 */
2424
2525 #define _GNU_SOURCE 1
26-#include "../va.h"
27-#include "../va_backend.h"
28-#include "../va_android.h"
26+#include "va.h"
27+#include "va_backend.h"
28+#include "va_android.h"
29+#include "x11/va_dricommon.h"
2930 #include <stdio.h>
3031 #include <stdlib.h>
3132 #include <stdarg.h>
@@ -34,10 +35,44 @@
3435 #include <sys/types.h>
3536 #include <sys/stat.h>
3637 #include <fcntl.h>
38+#include <dlfcn.h>
3739 #include <errno.h>
3840
41+#define CHECK_SYMBOL(func) { if (!func) printf("func %s not found\n", #func); return VA_STATUS_ERROR_UNKNOWN; }
42+#define DEVICE_NAME "/dev/dri/card0"
43+
3944 static VADisplayContextP pDisplayContexts = NULL;
4045
46+static int open_device (char *dev_name)
47+{
48+ struct stat st;
49+ int fd;
50+
51+ if (-1 == stat (dev_name, &st))
52+ {
53+ printf ("Cannot identify '%s': %d, %s\n",
54+ dev_name, errno, strerror (errno));
55+ return -1;
56+ }
57+
58+ if (!S_ISCHR (st.st_mode))
59+ {
60+ printf ("%s is no device\n", dev_name);
61+ return -1;
62+ }
63+
64+ fd = open (dev_name, O_RDWR /* required */ | O_NONBLOCK, 0);
65+
66+ if (-1 == fd)
67+ {
68+ fprintf (stderr, "Cannot open '%s': %d, %s\n",
69+ dev_name, errno, strerror (errno));
70+ return -1;
71+ }
72+
73+ return fd;
74+}
75+
4176 static int va_DisplayContextIsValid (
4277 VADisplayContextP pDisplayContext
4378 )
@@ -78,7 +113,7 @@ static VAStatus va_DisplayContextGetDriverName (
78113 unsigned int device_id;
79114 char driver_name[64];
80115 } devices[] = {
81- { 0x8086, 0x4100, "android" },
116+ { 0x8086, 0x4100, "psb" },
82117 };
83118
84119 if (driver_name)
@@ -111,13 +146,27 @@ VADisplay vaGetDisplay (
111146 pDisplayContext = pDisplayContext->pNext;
112147 }
113148
149+
114150 if (!dpy)
115151 {
116152 /* create new entry */
117153 VADriverContextP pDriverContext;
154+ struct dri_state *dri_state;
155+
118156 pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext));
119157 pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext));
120- if (pDisplayContext && pDriverContext)
158+ dri_state = (struct dri_state*)calloc(1, sizeof(*dri_state));
159+
160+ /* assgin necessary dri_state struct variable */
161+ dri_state->driConnectedFlag = VA_DRI2;
162+ dri_state->fd = open_device(DEVICE_NAME);
163+ dri_state->createDrawable = NULL;
164+ dri_state->destroyDrawable = NULL;
165+ dri_state->swapBuffer = NULL;
166+ dri_state->getRenderingBuffer = NULL;
167+ dri_state->close = NULL;
168+
169+ if (pDisplayContext && pDriverContext && dri_state)
121170 {
122171 pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
123172
@@ -128,6 +177,7 @@ VADisplay vaGetDisplay (
128177 pDisplayContext->vaDestroy = va_DisplayContextDestroy;
129178 pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
130179 pDisplayContexts = pDisplayContext;
180+ pDriverContext->dri_state = dri_state;
131181 dpy = (VADisplay)pDisplayContext;
132182 }
133183 else
@@ -136,13 +186,14 @@ VADisplay vaGetDisplay (
136186 free(pDisplayContext);
137187 if (pDriverContext)
138188 free(pDriverContext);
189+ if (dri_state)
190+ free(dri_state);
139191 }
140192 }
141193
142194 return dpy;
143195 }
144196
145-
146197 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
147198 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
148199
@@ -155,7 +206,8 @@ static int vaDisplayIsValid(VADisplay dpy)
155206 VAStatus vaPutSurface (
156207 VADisplay dpy,
157208 VASurfaceID surface,
158- Surface *draw, /* Android Surface/Window */
209+ //Surface *draw, /* Android Surface/Window */
210+ void *draw,
159211 short srcx,
160212 short srcy,
161213 unsigned short srcw,
@@ -178,3 +230,4 @@ VAStatus vaPutSurface (
178230 destx, desty, destw, desth,
179231 cliprects, number_cliprects, flags );
180232 }
233+
--- a/va/va.c
+++ b/va/va.c
@@ -25,6 +25,7 @@
2525 #define _GNU_SOURCE 1
2626 #include "va.h"
2727 #include "va_backend.h"
28+#include "config.h"
2829
2930 #include <assert.h>
3031 #include <stdarg.h>
@@ -54,6 +55,10 @@ extern int trace_flag;
5455 trace_func(__VA_ARGS__); \
5556 }
5657
58+#define VA_MAJOR_VERSION (0)
59+#define VA_MINOR_VERSION (31)
60+#define VA_VERSION_S "0.31.1"
61+
5762 static int vaDisplayIsValid(VADisplay dpy)
5863 {
5964 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
@@ -153,8 +158,11 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
153158 strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) );
154159
155160 va_infoMessage("Trying to open %s\n", driver_path);
156-
161+#ifndef ANDROID
157162 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE );
163+#else
164+ handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL);
165+#endif
158166 if (!handle)
159167 {
160168 /* Don't give errors for non-existing files */
--- a/va/va.h
+++ b/va/va.h
@@ -1789,6 +1789,17 @@ VAStatus vaSetDisplayAttributes (
17891789 int num_attributes
17901790 );
17911791
1792+#ifdef ANDROID
1793+#define Display unsigned int
1794+#define Drawable unsigned int
1795+#define XID unsigned int
1796+#define Bool int
1797+#define Status int
1798+#define True 1
1799+#define False 0
1800+#define Xfree(ptr) free((ptr))
1801+#endif
1802+
17921803 #ifdef __cplusplus
17931804 }
17941805 #endif
--- a/va/va_android.h
+++ b/va/va_android.h
@@ -2,16 +2,16 @@
22 #define _VA_ANDROID_H_
33
44 #include <va/va.h>
5-
65 #ifdef __cplusplus
76 extern "C" {
87 #endif
98
9+//#define Surface void
1010 /*
1111 * Returns a suitable VADisplay for VA API
1212 */
1313 VADisplay vaGetDisplay (
14- void *dpy
14+ Display *dpy
1515 );
1616
1717 /*
@@ -25,7 +25,8 @@ VADisplay vaGetDisplay (
2525 VAStatus vaPutSurface (
2626 VADisplay dpy,
2727 VASurfaceID surface,
28- Surface *draw, /* Android Window/Surface */
28+ //Surface *draw, /* Android Window/Surface */
29+ void* draw,
2930 short srcx,
3031 short srcy,
3132 unsigned short srcw,
@@ -38,7 +39,6 @@ VAStatus vaPutSurface (
3839 unsigned int number_cliprects, /* number of clip rects in the clip list */
3940 unsigned int flags /* PutSurface flags */
4041 );
41-
4242 #ifdef __cplusplus
4343 }
4444 #endif
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -30,15 +30,18 @@
3030 #define _VA_BACKEND_H_
3131
3232 #include <va/va.h>
33+#ifndef ANDROID
3334 #include <X11/Xlib.h>
35+#endif
3436 #include <linux/videodev2.h>
35-#include <ui/Surface.h>
36-
37-class Surface;
3837
3938 typedef struct VADriverContext *VADriverContextP;
4039 typedef struct VADisplayContext *VADisplayContextP;
4140
41+#ifdef ANDROID
42+#define Surface void
43+#endif
44+
4245 struct VADriverVTable
4346 {
4447 VAStatus (*vaTerminate) ( VADriverContextP ctx );
@@ -182,7 +185,11 @@ struct VADriverVTable
182185 VAStatus (*vaPutSurface) (
183186 VADriverContextP ctx,
184187 VASurfaceID surface,
188+ #ifdef ANDROID
185189 Surface* draw, /* X Drawable */
190+ #else
191+ Drawable draw,
192+ #endif
186193 short srcx,
187194 short srcy,
188195 unsigned short srcw,
--- a/va/x11/va_dricommon.h
+++ b/va/x11/va_dricommon.h
@@ -1,8 +1,9 @@
11 #ifndef _VA_DRICOMMON_H_
22 #define _VA_DRICOMMON_H_
33
4+#ifndef ANDROID
45 #include <X11/Xlib.h>
5-
6+#endif
67 #include <xf86drm.h>
78 #include <drm.h>
89 #include <drm_sarea.h>