#include "va.h"
#include "va_backend.h"
#include "va_android.h"
+#include "va_dricommon.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
+
static VADisplayContextP pDisplayContexts = NULL;
static int va_DisplayContextIsValid (
}
ctx = &((*ctx)->pNext);
}
+ free(pDisplayContext->pDriverContext->dri_state);
free(pDisplayContext->pDriverContext);
free(pDisplayContext);
}
VADisplayContextP pDisplayContext,
char **driver_name
)
-{
+{
+ VADriverContextP ctx = pDisplayContext->pDriverContext;
+ struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
char *driver_name_env;
+
struct {
unsigned int verndor_id;
unsigned int device_id;
{ 0x8086, 0x4100, "pvr" },
};
- if (driver_name)
- *driver_name = NULL;
+ memset(dri_state, 0, sizeof(*dri_state));
+ dri_state->fd = drm_open_any_master();
+ if (dri_state->fd < 0)
+ return VA_STATUS_ERROR_UNKNOWN;
+
+ if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL
+ && geteuid() == getuid())
+ {
+ /* don't allow setuid apps to use LIBVA_DRIVER_NAME */
+ *driver_name = strdup(driver_name_env);
+ return VA_STATUS_SUCCESS;
+ } else /* TBD: other vendor driver names */
+ *driver_name = strdup(devices[0].driver_name);
- *driver_name = strdup(devices[0].driver_name);
+
+ dri_state->driConnectedFlag = VA_DRI2;
return VA_STATUS_SUCCESS;
}
VADisplay vaGetDisplay (
- Display *native_dpy /* implementation specific */
+ void *native_dpy /* implementation specific */
)
{
VADisplay dpy = NULL;
{
/* 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 = calloc(1, sizeof(*dri_state));
+
+ if (pDisplayContext && pDriverContext && dri_state)
{
pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
pDisplayContexts = pDisplayContext;
+ pDriverContext->dri_state = dri_state;
dpy = (VADisplay)pDisplayContext;
}
else
free(pDisplayContext);
if (pDriverContext)
free(pDriverContext);
+ if (dri_state)
+ free(dri_state);
}
}
return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
}
+#ifdef ANDROID
VAStatus vaPutSurface (
VADisplay dpy,
VASurfaceID surface,
return ctx->vtable.vaPutSurfaceBuf( ctx, surface, draw, data, data_len, srcx, srcy, srcw, srch,
destx, desty, destw, desth, cliprects, number_cliprects, flags );
}
+#endif
#define _VA_ANDROID_H_
#include <va/va.h>
-#include <ui/Surface.h>
-class Surface;
+
#ifdef __cplusplus
extern "C" {
#endif
+
/*
* Returns a suitable VADisplay for VA API
*/
void *dpy
);
+#ifdef ANDROID
+
+#include <ui/Surface.h>
+class Surface;
+
/*
* Output rendering
* Following is the rendering interface for X windows,
);
VAStatus vaPutSurfaceBuf (
- VADriverContextP ctx,
- VASurfaceID surface,
- Drawable draw, /* X Drawable */
- unsigned char* data,
- int* data_len,
- short srcx,
- short srcy,
- unsigned short srcw,
- unsigned short srch,
- short destx,
- short desty,
- unsigned short destw,
- unsigned short desth,
- VARectangle *cliprects, /* client supplied clip list */
- unsigned int number_cliprects, /* number of clip rects in the clip list */
- unsigned int flags /* de-interlacing flags */
- );
+ VADriverContextP ctx,
+ VASurfaceID surface,
+ Drawable draw, /* X Drawable */
+ unsigned char* data,
+ int* data_len,
+ short srcx,
+ short srcy,
+ unsigned short srcw,
+ unsigned short srch,
+ short destx,
+ short desty,
+ unsigned short destw,
+ unsigned short desth,
+ VARectangle *cliprects, /* client supplied clip list */
+ unsigned int number_cliprects, /* number of clip rects in the clip list */
+ unsigned int flags /* de-interlacing flags */
+);
+
+#endif
+
#ifdef __cplusplus
}
#endif