hardware/intel/libva
修订版 | c4a03c1016cd41e22ecc3410be6759aa0e1a71cf (tree) |
---|---|
时间 | 2010-04-27 15:36:24 |
作者 | Ren Zhaohan <zhaohan.ren@inte...> |
Commiter | Ren Zhaohan |
libva backend
@@ -1,19 +1,23 @@ | ||
1 | 1 | LOCAL_PATH:= $(call my-dir) |
2 | 2 | |
3 | +LIBVA_MINOR_VERSION := 31 | |
4 | +LIBVA_MAJOR_VERSION := 0 | |
5 | + | |
3 | 6 | include $(CLEAR_VARS) |
4 | 7 | |
5 | 8 | LOCAL_SRC_FILES := \ |
6 | - android/va_android.c | |
9 | + va.c \ | |
10 | + va_trace.c \ | |
11 | + android/va_android.c \ | |
7 | 12 | |
8 | 13 | LOCAL_CFLAGS += -DHAVE_CONFIG_H \ |
9 | 14 | -DIN_LIBVA \ |
15 | + -DANDROID \ | |
10 | 16 | |
11 | 17 | LOCAL_C_INCLUDES += \ |
12 | 18 | $(TOPDIR)kernel/include \ |
13 | 19 | $(TARGET_OUT_HEADERS)/libva \ |
14 | - $(TOPDIR)kernel/include/drm | |
15 | - | |
16 | -LOCAL_CC := g++ | |
20 | + $(TOPDIR)kernel/include/drm | |
17 | 21 | |
18 | 22 | LOCAL_COPY_HEADERS_TO := libva/va |
19 | 23 |
@@ -21,6 +25,7 @@ LOCAL_COPY_HEADERS := \ | ||
21 | 25 | va.h \ |
22 | 26 | va_backend.h \ |
23 | 27 | va_version.h.in \ |
28 | + x11/va_dricommon.h \ | |
24 | 29 | va_android.h |
25 | 30 | |
26 | 31 | LOCAL_MODULE := libva_android |
@@ -23,9 +23,10 @@ | ||
23 | 23 | */ |
24 | 24 | |
25 | 25 | #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" | |
29 | 30 | #include <stdio.h> |
30 | 31 | #include <stdlib.h> |
31 | 32 | #include <stdarg.h> |
@@ -34,10 +35,44 @@ | ||
34 | 35 | #include <sys/types.h> |
35 | 36 | #include <sys/stat.h> |
36 | 37 | #include <fcntl.h> |
38 | +#include <dlfcn.h> | |
37 | 39 | #include <errno.h> |
38 | 40 | |
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 | + | |
39 | 44 | static VADisplayContextP pDisplayContexts = NULL; |
40 | 45 | |
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 | + | |
41 | 76 | static int va_DisplayContextIsValid ( |
42 | 77 | VADisplayContextP pDisplayContext |
43 | 78 | ) |
@@ -78,7 +113,7 @@ static VAStatus va_DisplayContextGetDriverName ( | ||
78 | 113 | unsigned int device_id; |
79 | 114 | char driver_name[64]; |
80 | 115 | } devices[] = { |
81 | - { 0x8086, 0x4100, "android" }, | |
116 | + { 0x8086, 0x4100, "psb" }, | |
82 | 117 | }; |
83 | 118 | |
84 | 119 | if (driver_name) |
@@ -111,13 +146,27 @@ VADisplay vaGetDisplay ( | ||
111 | 146 | pDisplayContext = pDisplayContext->pNext; |
112 | 147 | } |
113 | 148 | |
149 | + | |
114 | 150 | if (!dpy) |
115 | 151 | { |
116 | 152 | /* create new entry */ |
117 | 153 | VADriverContextP pDriverContext; |
154 | + struct dri_state *dri_state; | |
155 | + | |
118 | 156 | pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext)); |
119 | 157 | 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) | |
121 | 170 | { |
122 | 171 | pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; |
123 | 172 |
@@ -128,6 +177,7 @@ VADisplay vaGetDisplay ( | ||
128 | 177 | pDisplayContext->vaDestroy = va_DisplayContextDestroy; |
129 | 178 | pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; |
130 | 179 | pDisplayContexts = pDisplayContext; |
180 | + pDriverContext->dri_state = dri_state; | |
131 | 181 | dpy = (VADisplay)pDisplayContext; |
132 | 182 | } |
133 | 183 | else |
@@ -136,13 +186,14 @@ VADisplay vaGetDisplay ( | ||
136 | 186 | free(pDisplayContext); |
137 | 187 | if (pDriverContext) |
138 | 188 | free(pDriverContext); |
189 | + if (dri_state) | |
190 | + free(dri_state); | |
139 | 191 | } |
140 | 192 | } |
141 | 193 | |
142 | 194 | return dpy; |
143 | 195 | } |
144 | 196 | |
145 | - | |
146 | 197 | #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) |
147 | 198 | #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } |
148 | 199 |
@@ -155,7 +206,8 @@ static int vaDisplayIsValid(VADisplay dpy) | ||
155 | 206 | VAStatus vaPutSurface ( |
156 | 207 | VADisplay dpy, |
157 | 208 | VASurfaceID surface, |
158 | - Surface *draw, /* Android Surface/Window */ | |
209 | + //Surface *draw, /* Android Surface/Window */ | |
210 | + void *draw, | |
159 | 211 | short srcx, |
160 | 212 | short srcy, |
161 | 213 | unsigned short srcw, |
@@ -178,3 +230,4 @@ VAStatus vaPutSurface ( | ||
178 | 230 | destx, desty, destw, desth, |
179 | 231 | cliprects, number_cliprects, flags ); |
180 | 232 | } |
233 | + |
@@ -25,6 +25,7 @@ | ||
25 | 25 | #define _GNU_SOURCE 1 |
26 | 26 | #include "va.h" |
27 | 27 | #include "va_backend.h" |
28 | +#include "config.h" | |
28 | 29 | |
29 | 30 | #include <assert.h> |
30 | 31 | #include <stdarg.h> |
@@ -54,6 +55,10 @@ extern int trace_flag; | ||
54 | 55 | trace_func(__VA_ARGS__); \ |
55 | 56 | } |
56 | 57 | |
58 | +#define VA_MAJOR_VERSION (0) | |
59 | +#define VA_MINOR_VERSION (31) | |
60 | +#define VA_VERSION_S "0.31.1" | |
61 | + | |
57 | 62 | static int vaDisplayIsValid(VADisplay dpy) |
58 | 63 | { |
59 | 64 | VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; |
@@ -153,8 +158,11 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) | ||
153 | 158 | strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) ); |
154 | 159 | |
155 | 160 | va_infoMessage("Trying to open %s\n", driver_path); |
156 | - | |
161 | +#ifndef ANDROID | |
157 | 162 | handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE ); |
163 | +#else | |
164 | + handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL); | |
165 | +#endif | |
158 | 166 | if (!handle) |
159 | 167 | { |
160 | 168 | /* Don't give errors for non-existing files */ |
@@ -1789,6 +1789,17 @@ VAStatus vaSetDisplayAttributes ( | ||
1789 | 1789 | int num_attributes |
1790 | 1790 | ); |
1791 | 1791 | |
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 | + | |
1792 | 1803 | #ifdef __cplusplus |
1793 | 1804 | } |
1794 | 1805 | #endif |
@@ -2,16 +2,16 @@ | ||
2 | 2 | #define _VA_ANDROID_H_ |
3 | 3 | |
4 | 4 | #include <va/va.h> |
5 | - | |
6 | 5 | #ifdef __cplusplus |
7 | 6 | extern "C" { |
8 | 7 | #endif |
9 | 8 | |
9 | +//#define Surface void | |
10 | 10 | /* |
11 | 11 | * Returns a suitable VADisplay for VA API |
12 | 12 | */ |
13 | 13 | VADisplay vaGetDisplay ( |
14 | - void *dpy | |
14 | + Display *dpy | |
15 | 15 | ); |
16 | 16 | |
17 | 17 | /* |
@@ -25,7 +25,8 @@ VADisplay vaGetDisplay ( | ||
25 | 25 | VAStatus vaPutSurface ( |
26 | 26 | VADisplay dpy, |
27 | 27 | VASurfaceID surface, |
28 | - Surface *draw, /* Android Window/Surface */ | |
28 | + //Surface *draw, /* Android Window/Surface */ | |
29 | + void* draw, | |
29 | 30 | short srcx, |
30 | 31 | short srcy, |
31 | 32 | unsigned short srcw, |
@@ -38,7 +39,6 @@ VAStatus vaPutSurface ( | ||
38 | 39 | unsigned int number_cliprects, /* number of clip rects in the clip list */ |
39 | 40 | unsigned int flags /* PutSurface flags */ |
40 | 41 | ); |
41 | - | |
42 | 42 | #ifdef __cplusplus |
43 | 43 | } |
44 | 44 | #endif |
@@ -30,15 +30,18 @@ | ||
30 | 30 | #define _VA_BACKEND_H_ |
31 | 31 | |
32 | 32 | #include <va/va.h> |
33 | +#ifndef ANDROID | |
33 | 34 | #include <X11/Xlib.h> |
35 | +#endif | |
34 | 36 | #include <linux/videodev2.h> |
35 | -#include <ui/Surface.h> | |
36 | - | |
37 | -class Surface; | |
38 | 37 | |
39 | 38 | typedef struct VADriverContext *VADriverContextP; |
40 | 39 | typedef struct VADisplayContext *VADisplayContextP; |
41 | 40 | |
41 | +#ifdef ANDROID | |
42 | +#define Surface void | |
43 | +#endif | |
44 | + | |
42 | 45 | struct VADriverVTable |
43 | 46 | { |
44 | 47 | VAStatus (*vaTerminate) ( VADriverContextP ctx ); |
@@ -182,7 +185,11 @@ struct VADriverVTable | ||
182 | 185 | VAStatus (*vaPutSurface) ( |
183 | 186 | VADriverContextP ctx, |
184 | 187 | VASurfaceID surface, |
188 | + #ifdef ANDROID | |
185 | 189 | Surface* draw, /* X Drawable */ |
190 | + #else | |
191 | + Drawable draw, | |
192 | + #endif | |
186 | 193 | short srcx, |
187 | 194 | short srcy, |
188 | 195 | unsigned short srcw, |
@@ -1,8 +1,9 @@ | ||
1 | 1 | #ifndef _VA_DRICOMMON_H_ |
2 | 2 | #define _VA_DRICOMMON_H_ |
3 | 3 | |
4 | +#ifndef ANDROID | |
4 | 5 | #include <X11/Xlib.h> |
5 | - | |
6 | +#endif | |
6 | 7 | #include <xf86drm.h> |
7 | 8 | #include <drm.h> |
8 | 9 | #include <drm_sarea.h> |