summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/va/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/va/config.c')
-rw-r--r--src/gallium/state_trackers/va/config.c111
1 files changed, 99 insertions, 12 deletions
diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c
index 9ca0aa8b4ef..7742087e999 100644
--- a/src/gallium/state_trackers/va/config.c
+++ b/src/gallium/state_trackers/va/config.c
@@ -34,6 +34,8 @@
#include "va_private.h"
+#include "util/u_handle_table.h"
+
DEBUG_GET_ONCE_BOOL_OPTION(mpeg4, "VAAPI_MPEG4_ENABLED", false)
VAStatus
@@ -88,10 +90,18 @@ vlVaQueryConfigEntrypoints(VADriverContextP ctx, VAProfile profile,
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
pscreen = VL_VA_PSCREEN(ctx);
- if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, PIPE_VIDEO_CAP_SUPPORTED))
- return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ if (pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+ PIPE_VIDEO_CAP_SUPPORTED))
+ entrypoint_list[(*num_entrypoints)++] = VAEntrypointVLD;
- entrypoint_list[(*num_entrypoints)++] = VAEntrypointVLD;
+#if 0
+ if (pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE,
+ PIPE_VIDEO_CAP_SUPPORTED))
+ entrypoint_list[(*num_entrypoints)++] = VAEntrypointEncSlice;
+#endif
+
+ if (num_entrypoints == 0)
+ return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
return VA_STATUS_SUCCESS;
}
@@ -128,29 +138,73 @@ VAStatus
vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id)
{
+ vlVaDriver *drv;
+ vlVaConfig *config;
struct pipe_screen *pscreen;
enum pipe_video_profile p;
if (!ctx)
return VA_STATUS_ERROR_INVALID_CONTEXT;
+ drv = VL_VA_DRIVER(ctx);
+
+ if (!drv)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ config = CALLOC(1, sizeof(vlVaConfig));
+ if (!config)
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) {
- *config_id = PIPE_VIDEO_PROFILE_UNKNOWN;
+ config->entrypoint = VAEntrypointVideoProc;
+ config->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
+ pipe_mutex_lock(drv->mutex);
+ *config_id = handle_table_add(drv->htab, config);
+ pipe_mutex_unlock(drv->mutex);
return VA_STATUS_SUCCESS;
}
p = ProfileToPipe(profile);
- if (p == PIPE_VIDEO_PROFILE_UNKNOWN)
+ if (p == PIPE_VIDEO_PROFILE_UNKNOWN) {
+ FREE(config);
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ }
pscreen = VL_VA_PSCREEN(ctx);
- if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, PIPE_VIDEO_CAP_SUPPORTED))
- return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
- if (entrypoint != VAEntrypointVLD)
+ switch (entrypoint) {
+ case VAEntrypointVLD:
+ if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+ PIPE_VIDEO_CAP_SUPPORTED)) {
+ FREE(config);
+ return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ }
+
+ config->entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
+ break;
+
+#if 0
+ case VAEntrypointEncSlice:
+ if (!pscreen->get_video_param(pscreen, p, PIPE_VIDEO_ENTRYPOINT_ENCODE,
+ PIPE_VIDEO_CAP_SUPPORTED)) {
+ FREE(config);
+ return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ }
+
+ config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;
+ break;
+#endif
+
+ default:
+ FREE(config);
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+ }
- *config_id = p;
+ config->profile = p;
+
+ pipe_mutex_lock(drv->mutex);
+ *config_id = handle_table_add(drv->htab, config);
+ pipe_mutex_unlock(drv->mutex);
return VA_STATUS_SUCCESS;
}
@@ -158,9 +212,27 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
VAStatus
vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id)
{
+ vlVaDriver *drv;
+ vlVaConfig *config;
+
if (!ctx)
return VA_STATUS_ERROR_INVALID_CONTEXT;
+ drv = VL_VA_DRIVER(ctx);
+
+ if (!drv)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ pipe_mutex_lock(drv->mutex);
+ config = handle_table_get(drv->htab, config_id);
+
+ if (!config)
+ return VA_STATUS_ERROR_INVALID_CONFIG;
+
+ FREE(config);
+ handle_table_remove(drv->htab, config_id);
+ pipe_mutex_unlock(drv->mutex);
+
return VA_STATUS_SUCCESS;
}
@@ -168,18 +240,33 @@ VAStatus
vlVaQueryConfigAttributes(VADriverContextP ctx, VAConfigID config_id, VAProfile *profile,
VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs)
{
+ vlVaDriver *drv;
+ vlVaConfig *config;
+
if (!ctx)
return VA_STATUS_ERROR_INVALID_CONTEXT;
- *profile = PipeToProfile(config_id);
+ drv = VL_VA_DRIVER(ctx);
+
+ if (!drv)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ pipe_mutex_lock(drv->mutex);
+ config = handle_table_get(drv->htab, config_id);
+ pipe_mutex_unlock(drv->mutex);
+
+ if (!config)
+ return VA_STATUS_ERROR_INVALID_CONFIG;
+
+ *profile = PipeToProfile(config->profile);
- if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) {
+ if (config->profile == PIPE_VIDEO_PROFILE_UNKNOWN) {
*entrypoint = VAEntrypointVideoProc;
*num_attribs = 0;
return VA_STATUS_SUCCESS;
}
- *entrypoint = VAEntrypointVLD;
+ *entrypoint = config->entrypoint;
*num_attribs = 1;
attrib_list[0].type = VAConfigAttribRTFormat;