summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-06-19 19:09:16 +0100
committerXiang, Haihao <haihao.xiang@intel.com>2017-09-27 12:48:16 +0800
commit1b04587eee33537fe862baf6fc6fc3937dccfdcc (patch)
tree16d3d7e0efec7648b725032148b1db813ef7f5e0
parentb0e7feda096d7ae8146ba2e0c22b7bd59b768950 (diff)
downloadlibva-1b04587eee33537fe862baf6fc6fc3937dccfdcc.tar.gz
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>
-rw-r--r--va/android/va_android.cpp5
-rw-r--r--va/drm/va_drm.c4
-rw-r--r--va/va.c12
-rw-r--r--va/va_internal.h2
-rw-r--r--va/wayland/va_wayland.c4
-rw-r--r--va/x11/va_x11.c5
6 files changed, 22 insertions, 10 deletions
diff --git a/va/android/va_android.cpp b/va/android/va_android.cpp
index 873609c..31b4453 100644
--- a/va/android/va_android.cpp
+++ b/va/android/va_android.cpp
@@ -26,6 +26,7 @@
#include "sysdeps.h"
#include "va.h"
#include "va_backend.h"
+#include "va_internal.h"
#include "va_trace.h"
#include "va_fool.h"
#include "va_android.h"
@@ -135,13 +136,11 @@ VADisplay vaGetDisplay (
/* create new entry */
VADriverContextP pDriverContext = 0;
struct drm_state *drm_state = 0;
- pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext));
+ pDisplayContext = va_newDisplayContext();
pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext));
drm_state = (struct drm_state*)calloc(1, sizeof(*drm_state));
if (pDisplayContext && pDriverContext && drm_state)
{
- pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
-
pDriverContext->native_dpy = (void *)native_dpy;
pDriverContext->display_type = VA_DISPLAY_ANDROID;
pDisplayContext->pDriverContext = pDriverContext;
diff --git a/va/drm/va_drm.c b/va/drm/va_drm.c
index 59e33fa..bccd108 100644
--- a/va/drm/va_drm.c
+++ b/va/drm/va_drm.c
@@ -26,6 +26,7 @@
#include <xf86drm.h>
#include "va_drm.h"
#include "va_backend.h"
+#include "va_internal.h"
#include "va_drmcommon.h"
#include "va_drm_auth.h"
#include "va_drm_utils.h"
@@ -109,11 +110,10 @@ vaGetDisplayDRM(int fd)
VA_DISPLAY_DRM_RENDERNODES : VA_DISPLAY_DRM;
pDriverContext->drm_state = drm_state;
- pDisplayContext = calloc(1, sizeof(*pDisplayContext));
+ pDisplayContext = va_newDisplayContext();
if (!pDisplayContext)
goto error;
- pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
pDisplayContext->pDriverContext = pDriverContext;
pDisplayContext->vaIsValid = va_DisplayContextIsValid;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
diff --git a/va/va.c b/va/va.c
index bc267d4..6378127 100644
--- a/va/va.c
+++ b/va/va.c
@@ -27,6 +27,7 @@
#include "va.h"
#include "va_backend.h"
#include "va_backend_vpp.h"
+#include "va_internal.h"
#include "va_trace.h"
#include "va_fool.h"
@@ -234,6 +235,17 @@ void va_infoMessage(const char *msg, ...)
#endif
}
+VADisplayContextP va_newDisplayContext(void)
+{
+ VADisplayContextP dctx = calloc(1, sizeof(*dctx));
+ if (!dctx)
+ return NULL;
+
+ dctx->vadpy_magic = VA_DISPLAY_MAGIC;
+
+ return dctx;
+}
+
static bool va_checkVtable(void *ptr, char *function)
{
if (!ptr) {
diff --git a/va/va_internal.h b/va/va_internal.h
index 6639803..b51c1e5 100644
--- a/va/va_internal.h
+++ b/va/va_internal.h
@@ -33,4 +33,6 @@ void va_infoMessage(const char *msg, ...);
int va_parseConfig(char *env, char *env_value);
+VADisplayContextP va_newDisplayContext(void);
+
#endif /* VA_INTERNAL_H */
diff --git a/va/wayland/va_wayland.c b/va/wayland/va_wayland.c
index 88a841f..f7ddfe8 100644
--- a/va/wayland/va_wayland.c
+++ b/va/wayland/va_wayland.c
@@ -32,6 +32,7 @@
#include "va_wayland_private.h"
#include "va_backend.h"
#include "va_backend_wayland.h"
+#include "va_internal.h"
static inline VADriverContextP
get_driver_context(VADisplay dpy)
@@ -120,11 +121,10 @@ vaGetDisplayWl(struct wl_display *display)
struct VADriverVTableWayland *vtable;
unsigned int i;
- pDisplayContext = calloc(1, sizeof(*pDisplayContext));
+ pDisplayContext = va_newDisplayContext();
if (!pDisplayContext)
return NULL;
- pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
pDisplayContext->vaIsValid = va_DisplayContextIsValid;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c
index ab53b9b..b5fe6e9 100644
--- a/va/x11/va_x11.c
+++ b/va/x11/va_x11.c
@@ -26,6 +26,7 @@
#include "sysdeps.h"
#include "va.h"
#include "va_backend.h"
+#include "va_internal.h"
#include "va_trace.h"
#include "va_fool.h"
#include "va_x11.h"
@@ -163,13 +164,11 @@ VADisplay vaGetDisplay (
/* create new entry */
VADriverContextP pDriverContext;
struct dri_state *dri_state;
- pDisplayContext = calloc(1, sizeof(*pDisplayContext));
+ pDisplayContext = va_newDisplayContext();
pDriverContext = calloc(1, sizeof(*pDriverContext));
dri_state = calloc(1, sizeof(*dri_state));
if (pDisplayContext && pDriverContext && dri_state)
{
- pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
-
pDriverContext->native_dpy = (void *)native_dpy;
pDriverContext->x11_screen = XDefaultScreen(native_dpy);
pDriverContext->display_type = VA_DISPLAY_X11;