hardware/intel/common/libva
修订版 | 1b04587eee33537fe862baf6fc6fc3937dccfdcc (tree) |
---|---|
时间 | 2017-09-27 13:48:16 |
作者 | Mark Thompson <sw@jkqx...> |
Commiter | Xiang, Haihao |
Move VADisplay allocation to common code
This is slightly cleaner, and will be required to set common
options on a newly-created display.
Signed-off-by: Mark Thompson <sw@jkqxz.net>
@@ -26,6 +26,7 @@ | ||
26 | 26 | #include "sysdeps.h" |
27 | 27 | #include "va.h" |
28 | 28 | #include "va_backend.h" |
29 | +#include "va_internal.h" | |
29 | 30 | #include "va_trace.h" |
30 | 31 | #include "va_fool.h" |
31 | 32 | #include "va_android.h" |
@@ -135,13 +136,11 @@ VADisplay vaGetDisplay ( | ||
135 | 136 | /* create new entry */ |
136 | 137 | VADriverContextP pDriverContext = 0; |
137 | 138 | struct drm_state *drm_state = 0; |
138 | - pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext)); | |
139 | + pDisplayContext = va_newDisplayContext(); | |
139 | 140 | pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext)); |
140 | 141 | drm_state = (struct drm_state*)calloc(1, sizeof(*drm_state)); |
141 | 142 | if (pDisplayContext && pDriverContext && drm_state) |
142 | 143 | { |
143 | - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; | |
144 | - | |
145 | 144 | pDriverContext->native_dpy = (void *)native_dpy; |
146 | 145 | pDriverContext->display_type = VA_DISPLAY_ANDROID; |
147 | 146 | pDisplayContext->pDriverContext = pDriverContext; |
@@ -26,6 +26,7 @@ | ||
26 | 26 | #include <xf86drm.h> |
27 | 27 | #include "va_drm.h" |
28 | 28 | #include "va_backend.h" |
29 | +#include "va_internal.h" | |
29 | 30 | #include "va_drmcommon.h" |
30 | 31 | #include "va_drm_auth.h" |
31 | 32 | #include "va_drm_utils.h" |
@@ -109,11 +110,10 @@ vaGetDisplayDRM(int fd) | ||
109 | 110 | VA_DISPLAY_DRM_RENDERNODES : VA_DISPLAY_DRM; |
110 | 111 | pDriverContext->drm_state = drm_state; |
111 | 112 | |
112 | - pDisplayContext = calloc(1, sizeof(*pDisplayContext)); | |
113 | + pDisplayContext = va_newDisplayContext(); | |
113 | 114 | if (!pDisplayContext) |
114 | 115 | goto error; |
115 | 116 | |
116 | - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; | |
117 | 117 | pDisplayContext->pDriverContext = pDriverContext; |
118 | 118 | pDisplayContext->vaIsValid = va_DisplayContextIsValid; |
119 | 119 | pDisplayContext->vaDestroy = va_DisplayContextDestroy; |
@@ -27,6 +27,7 @@ | ||
27 | 27 | #include "va.h" |
28 | 28 | #include "va_backend.h" |
29 | 29 | #include "va_backend_vpp.h" |
30 | +#include "va_internal.h" | |
30 | 31 | #include "va_trace.h" |
31 | 32 | #include "va_fool.h" |
32 | 33 |
@@ -234,6 +235,17 @@ void va_infoMessage(const char *msg, ...) | ||
234 | 235 | #endif |
235 | 236 | } |
236 | 237 | |
238 | +VADisplayContextP va_newDisplayContext(void) | |
239 | +{ | |
240 | + VADisplayContextP dctx = calloc(1, sizeof(*dctx)); | |
241 | + if (!dctx) | |
242 | + return NULL; | |
243 | + | |
244 | + dctx->vadpy_magic = VA_DISPLAY_MAGIC; | |
245 | + | |
246 | + return dctx; | |
247 | +} | |
248 | + | |
237 | 249 | static bool va_checkVtable(void *ptr, char *function) |
238 | 250 | { |
239 | 251 | if (!ptr) { |
@@ -33,4 +33,6 @@ void va_infoMessage(const char *msg, ...); | ||
33 | 33 | |
34 | 34 | int va_parseConfig(char *env, char *env_value); |
35 | 35 | |
36 | +VADisplayContextP va_newDisplayContext(void); | |
37 | + | |
36 | 38 | #endif /* VA_INTERNAL_H */ |
@@ -32,6 +32,7 @@ | ||
32 | 32 | #include "va_wayland_private.h" |
33 | 33 | #include "va_backend.h" |
34 | 34 | #include "va_backend_wayland.h" |
35 | +#include "va_internal.h" | |
35 | 36 | |
36 | 37 | static inline VADriverContextP |
37 | 38 | get_driver_context(VADisplay dpy) |
@@ -120,11 +121,10 @@ vaGetDisplayWl(struct wl_display *display) | ||
120 | 121 | struct VADriverVTableWayland *vtable; |
121 | 122 | unsigned int i; |
122 | 123 | |
123 | - pDisplayContext = calloc(1, sizeof(*pDisplayContext)); | |
124 | + pDisplayContext = va_newDisplayContext(); | |
124 | 125 | if (!pDisplayContext) |
125 | 126 | return NULL; |
126 | 127 | |
127 | - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; | |
128 | 128 | pDisplayContext->vaIsValid = va_DisplayContextIsValid; |
129 | 129 | pDisplayContext->vaDestroy = va_DisplayContextDestroy; |
130 | 130 | pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; |
@@ -26,6 +26,7 @@ | ||
26 | 26 | #include "sysdeps.h" |
27 | 27 | #include "va.h" |
28 | 28 | #include "va_backend.h" |
29 | +#include "va_internal.h" | |
29 | 30 | #include "va_trace.h" |
30 | 31 | #include "va_fool.h" |
31 | 32 | #include "va_x11.h" |
@@ -163,13 +164,11 @@ VADisplay vaGetDisplay ( | ||
163 | 164 | /* create new entry */ |
164 | 165 | VADriverContextP pDriverContext; |
165 | 166 | struct dri_state *dri_state; |
166 | - pDisplayContext = calloc(1, sizeof(*pDisplayContext)); | |
167 | + pDisplayContext = va_newDisplayContext(); | |
167 | 168 | pDriverContext = calloc(1, sizeof(*pDriverContext)); |
168 | 169 | dri_state = calloc(1, sizeof(*dri_state)); |
169 | 170 | if (pDisplayContext && pDriverContext && dri_state) |
170 | 171 | { |
171 | - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; | |
172 | - | |
173 | 172 | pDriverContext->native_dpy = (void *)native_dpy; |
174 | 173 | pDriverContext->x11_screen = XDefaultScreen(native_dpy); |
175 | 174 | pDriverContext->display_type = VA_DISPLAY_X11; |