[Libva] [PATCH 4/4] Enable the output to XV only user set the render mode attribute to overlay.
Ung, Teng En
teng.en.ung at intel.com
Thu Sep 12 19:16:20 PDT 2013
Signed-off-by: Ung, Teng En <teng.en.ung at intel.com>
---
src/i965_drv_video.c | 11 +++++++++++
src/i965_output_xv.c | 46 +++++++++++++++++++++++++++++++++++++++-------
src/i965_output_xv.h | 4 ++++
3 files changed, 54 insertions(+), 7 deletions(-)
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index fb23c8d..d2b8456 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -2532,6 +2532,17 @@ i965_SetDisplayAttributes(
src_attrib->value > dst_attrib->max_value)
return VA_STATUS_ERROR_INVALID_PARAMETER;
+#ifdef HAVE_X11_XV
+ if (dst_attrib->type == VADisplayAttribRenderMode) {
+ if ((src_attrib->value == VA_RENDER_MODE_LOCAL_OVERLAY)) {
+ if (!i965_output_xv_enable(ctx))
+ return VA_STATUS_ERROR_OPERATION_FAILED;
+ } else {
+ i965_output_xv_disable(ctx);
+ }
+ }
+#endif
+
dst_attrib->value = src_attrib->value;
/* XXX: track modified attributes through timestamps */
}
diff --git a/src/i965_output_xv.c b/src/i965_output_xv.c
index 0138e99..d884ed1 100644
--- a/src/i965_output_xv.c
+++ b/src/i965_output_xv.c
@@ -96,7 +96,6 @@ i965_output_xv_init(VADriverContextP ctx)
{
struct i965_driver_data * const i965 = i965_driver_data(ctx);
unsigned short major = 0, minor = 0;
- int port_id = 0;
if (va_xvQueryVersion(ctx, &major, &minor) != VA_XV_STATUS_SUCCESS)
goto error;
@@ -111,12 +110,6 @@ i965_output_xv_init(VADriverContextP ctx)
i965->xv_output->vaxv_format_index = -1;
}
- if ((va_xvFindAndReservePort(ctx, &port_id) != VA_XV_STATUS_SUCCESS) &&
- (!port_id))
- goto error;
-
- i965->xv_output->vaxv_port = port_id;
-
return true;
error :
@@ -152,6 +145,45 @@ i965_output_xv_terminate(VADriverContextP ctx)
i965->xv_output = NULL;
}
+bool i965_output_xv_enable(VADriverContextP ctx)
+{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+ int port_id = 0;
+
+ /* If the port alreay grabed, just return true */
+ if (i965->xv_output->vaxv_port)
+ return true;
+
+ if ((va_xvFindAndReservePort(ctx, &port_id) != VA_XV_STATUS_SUCCESS) &&
+ (!port_id))
+ return false;
+
+ i965->xv_output->vaxv_port = port_id;
+
+ return true;
+}
+
+void i965_output_xv_disable(VADriverContextP ctx)
+{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+ struct va_xv_output * const xv_output = i965->xv_output;
+ int i = 0;
+
+ if (!xv_output)
+ return;
+
+ if (xv_output->vaxv_port) {
+ va_xvFreePort(ctx, xv_output->vaxv_port);
+ xv_output->vaxv_port = 0;
+ }
+
+ for (i = 0; i < (NUM_VAXV_BUF - 1); ++i) {
+ if (xv_output->va_surf_id[i]) {
+ i965_DestroyVAXVBuffer(ctx, xv_output, i);
+ }
+ }
+}
+
VAStatus
i965_put_surface_xv(
VADriverContextP ctx,
diff --git a/src/i965_output_xv.h b/src/i965_output_xv.h
index 7d0cb91..0d39996 100644
--- a/src/i965_output_xv.h
+++ b/src/i965_output_xv.h
@@ -46,4 +46,8 @@ i965_put_surface_xv(
unsigned int flags
);
+bool i965_output_xv_enable(VADriverContextP ctx);
+
+void i965_output_xv_disable(VADriverContextP ctx);
+
#endif /* I965_OUTPUT_XV_H */
--
1.8.4
More information about the Libva
mailing list