[Libva] [PATCH intel 1/2] render: prepare for display attributes.
Gwenole Beauchesne
gb.devel at gmail.com
Wed Aug 29 09:49:02 PDT 2012
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
---
src/i965_drv_video.c | 129 +++++++++++++++++++++++++++++++++++++++++++-------
src/i965_drv_video.h | 4 +-
2 files changed, 116 insertions(+), 17 deletions(-)
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index a0a8388..e487871 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -110,6 +110,10 @@ enum {
I965_SURFACETYPE_INDEXED
};
+/* List of supported display attributes */
+static const VADisplayAttribute i965_display_attributes[] = {
+};
+
/* List of supported image formats */
typedef struct {
unsigned int type;
@@ -1934,6 +1938,52 @@ i965_QuerySurfaceStatus(VADriverContextP ctx,
return VA_STATUS_SUCCESS;
}
+static VADisplayAttribute *
+get_display_attribute(VADriverContextP ctx, VADisplayAttribType type)
+{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+ unsigned int i;
+
+ if (!i965->display_attributes)
+ return NULL;
+
+ for (i = 0; i < i965->num_display_attributes; i++) {
+ if (i965->display_attributes[i].type == type)
+ return &i965->display_attributes[i];
+ }
+ return NULL;
+}
+
+static bool
+i965_display_attributes_init(VADriverContextP ctx)
+{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+
+ i965->num_display_attributes = ARRAY_ELEMS(i965_display_attributes);
+ i965->display_attributes = malloc(
+ i965->num_display_attributes * sizeof(i965->display_attributes[0]));
+ if (!i965->display_attributes)
+ return false;
+
+ memcpy(
+ i965->display_attributes,
+ i965_display_attributes,
+ sizeof(i965_display_attributes)
+ );
+ return true;
+}
+
+static void
+i965_display_attributes_terminate(VADriverContextP ctx)
+{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+
+ if (i965->display_attributes) {
+ free(i965->display_attributes);
+ i965->display_attributes = NULL;
+ i965->num_display_attributes = 0;
+ }
+}
/*
* Query display attributes
@@ -1942,12 +1992,19 @@ i965_QuerySurfaceStatus(VADriverContextP ctx,
* returned in "attr_list" is returned in "num_attributes".
*/
VAStatus
-i965_QueryDisplayAttributes(VADriverContextP ctx,
- VADisplayAttribute *attr_list, /* out */
- int *num_attributes) /* out */
+i965_QueryDisplayAttributes(
+ VADriverContextP ctx,
+ VADisplayAttribute *attribs, /* out */
+ int *num_attribs_ptr /* out */
+)
{
- if (num_attributes)
- *num_attributes = 0;
+ const int num_attribs = ARRAY_ELEMS(i965_display_attributes);
+
+ if (attribs && num_attribs > 0)
+ memcpy(attribs, i965_display_attributes, sizeof(i965_display_attributes));
+
+ if (num_attribs_ptr)
+ *num_attribs_ptr = num_attribs;
return VA_STATUS_SUCCESS;
}
@@ -1959,12 +2016,27 @@ i965_QueryDisplayAttributes(VADriverContextP ctx,
* from vaQueryDisplayAttributes() can have their values retrieved.
*/
VAStatus
-i965_GetDisplayAttributes(VADriverContextP ctx,
- VADisplayAttribute *attr_list, /* in/out */
- int num_attributes)
+i965_GetDisplayAttributes(
+ VADriverContextP ctx,
+ VADisplayAttribute *attribs, /* inout */
+ int num_attribs /* in */
+)
{
- /* TODO */
- return VA_STATUS_ERROR_UNIMPLEMENTED;
+ int i;
+
+ for (i = 0; i < num_attribs; i++) {
+ VADisplayAttribute *src_attrib, * const dst_attrib = &attribs[i];
+
+ src_attrib = get_display_attribute(ctx, dst_attrib->type);
+ if (src_attrib && (src_attrib->flags & VA_DISPLAY_ATTRIB_GETTABLE)) {
+ dst_attrib->min_value = src_attrib->min_value;
+ dst_attrib->max_value = src_attrib->max_value;
+ dst_attrib->value = src_attrib->value;
+ }
+ else
+ dst_attrib->flags = VA_DISPLAY_ATTRIB_NOT_SUPPORTED;
+ }
+ return VA_STATUS_SUCCESS;
}
/*
@@ -1974,12 +2046,32 @@ i965_GetDisplayAttributes(VADriverContextP ctx,
* the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
*/
VAStatus
-i965_SetDisplayAttributes(VADriverContextP ctx,
- VADisplayAttribute *attr_list,
- int num_attributes)
+i965_SetDisplayAttributes(
+ VADriverContextP ctx,
+ VADisplayAttribute *attribs, /* in */
+ int num_attribs /* in */
+)
{
- /* TODO */
- return VA_STATUS_ERROR_UNIMPLEMENTED;
+ int i;
+
+ for (i = 0; i < num_attribs; i++) {
+ VADisplayAttribute *dst_attrib, * const src_attrib = &attribs[i];
+
+ dst_attrib = get_display_attribute(ctx, src_attrib->type);
+ if (!dst_attrib)
+ return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED;
+
+ if (!(dst_attrib->flags & VA_DISPLAY_ATTRIB_SETTABLE))
+ continue;
+
+ if (src_attrib->value < dst_attrib->min_value ||
+ src_attrib->value > dst_attrib->max_value)
+ return VA_STATUS_ERROR_INVALID_VALUE;
+
+ dst_attrib->value = src_attrib->value;
+ /* XXX: track modified attributes through timestamps */
+ }
+ return VA_STATUS_SUCCESS;
}
VAStatus
@@ -2013,6 +2105,9 @@ i965_Init(VADriverContextP ctx)
i965->batch = intel_batchbuffer_new(&i965->intel, I915_EXEC_RENDER);
+ if (!i965_display_attributes_init(ctx))
+ return VA_STATUS_ERROR_UNKNOWN;
+
if (i965_post_processing_init(ctx) == False)
return VA_STATUS_ERROR_UNKNOWN;
@@ -3361,6 +3456,8 @@ i965_Terminate(VADriverContextP ctx)
if (intel_driver_terminate(ctx) == False)
return VA_STATUS_ERROR_UNKNOWN;
+ i965_display_attributes_terminate(ctx);
+
i965_destroy_heap(&i965->buffer_heap, i965_destroy_buffer);
i965_destroy_heap(&i965->image_heap, i965_destroy_image);
i965_destroy_heap(&i965->subpic_heap, i965_destroy_subpic);
@@ -3806,7 +3903,7 @@ VA_DRIVER_INIT_FUNC( VADriverContextP ctx )
ctx->max_attributes = I965_MAX_CONFIG_ATTRIBUTES;
ctx->max_image_formats = I965_MAX_IMAGE_FORMATS;
ctx->max_subpic_formats = I965_MAX_SUBPIC_FORMATS;
- ctx->max_display_attributes = I965_MAX_DISPLAY_ATTRIBUTES;
+ ctx->max_display_attributes = 1 + ARRAY_ELEMS(i965_display_attributes);
vtable->vaTerminate = i965_Terminate;
vtable->vaQueryConfigEntrypoints = i965_QueryConfigEntrypoints;
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 557d3bd..5e6220e 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -45,7 +45,6 @@
#define I965_MAX_CONFIG_ATTRIBUTES 10
#define I965_MAX_IMAGE_FORMATS 10
#define I965_MAX_SUBPIC_FORMATS 4
-#define I965_MAX_DISPLAY_ATTRIBUTES 4
#define INTEL_STR_DRIVER_VENDOR "Intel"
#define INTEL_STR_DRIVER_NAME "i965"
@@ -278,6 +277,9 @@ struct i965_driver_data
VAContextID current_context_id;
+ VADisplayAttribute *display_attributes;
+ unsigned int num_display_attributes;
+
/* VA/DRI (X11) specific data */
struct va_dri_output *dri_output;
--
1.7.9.5
More information about the Libva
mailing list