buffer: Use object buffer structure directly instead of abstract type

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
This commit is contained in:
Paul Kocialkowski
2018-04-23 09:53:51 +02:00
parent 60b782ba51
commit 5c26862913
10 changed files with 23 additions and 25 deletions
+6 -6
View File
@@ -49,7 +49,7 @@ VAStatus sunxi_cedrus_CreateBuffer(VADriverContextP ctx, VAContextID context,
INIT_DRIVER_DATA INIT_DRIVER_DATA
int bufferID; int bufferID;
struct v4l2_plane plane[1]; struct v4l2_plane plane[1];
object_buffer_p obj_buffer; struct object_buffer *obj_buffer;
memset(plane, 0, sizeof(struct v4l2_plane)); memset(plane, 0, sizeof(struct v4l2_plane));
@@ -123,7 +123,7 @@ VAStatus sunxi_cedrus_BufferSetNumElements(VADriverContextP ctx,
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
VAStatus vaStatus = VA_STATUS_SUCCESS; VAStatus vaStatus = VA_STATUS_SUCCESS;
object_buffer_p obj_buffer = BUFFER(buf_id); struct object_buffer *obj_buffer = BUFFER(buf_id);
assert(obj_buffer); assert(obj_buffer);
if ((num_elements < 0) || (num_elements > obj_buffer->max_num_elements)) if ((num_elements < 0) || (num_elements > obj_buffer->max_num_elements))
@@ -139,7 +139,7 @@ VAStatus sunxi_cedrus_MapBuffer(VADriverContextP ctx, VABufferID buf_id,
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
object_buffer_p obj_buffer = BUFFER(buf_id); struct object_buffer *obj_buffer = BUFFER(buf_id);
assert(obj_buffer); assert(obj_buffer);
if (NULL == obj_buffer) if (NULL == obj_buffer)
@@ -159,7 +159,7 @@ VAStatus sunxi_cedrus_MapBuffer(VADriverContextP ctx, VABufferID buf_id,
VAStatus sunxi_cedrus_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id) VAStatus sunxi_cedrus_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id)
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
object_buffer_p obj_buffer = BUFFER(buf_id); struct object_buffer *obj_buffer = BUFFER(buf_id);
if (obj_buffer == NULL) if (obj_buffer == NULL)
return VA_STATUS_ERROR_INVALID_BUFFER; return VA_STATUS_ERROR_INVALID_BUFFER;
@@ -169,7 +169,7 @@ VAStatus sunxi_cedrus_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id)
} }
void sunxi_cedrus_destroy_buffer(struct sunxi_cedrus_driver_data *driver_data, void sunxi_cedrus_destroy_buffer(struct sunxi_cedrus_driver_data *driver_data,
object_buffer_p obj_buffer) struct object_buffer *obj_buffer)
{ {
if (obj_buffer->buffer_data != NULL) { if (obj_buffer->buffer_data != NULL) {
if (obj_buffer->type != VASliceDataBufferType) if (obj_buffer->type != VASliceDataBufferType)
@@ -187,7 +187,7 @@ void sunxi_cedrus_destroy_buffer(struct sunxi_cedrus_driver_data *driver_data,
VAStatus sunxi_cedrus_DestroyBuffer(VADriverContextP ctx, VABufferID buffer_id) VAStatus sunxi_cedrus_DestroyBuffer(VADriverContextP ctx, VABufferID buffer_id)
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
object_buffer_p obj_buffer = BUFFER(buffer_id); struct object_buffer *obj_buffer = BUFFER(buffer_id);
assert(obj_buffer); assert(obj_buffer);
sunxi_cedrus_destroy_buffer(driver_data, obj_buffer); sunxi_cedrus_destroy_buffer(driver_data, obj_buffer);
+2 -4
View File
@@ -31,7 +31,7 @@
#include "object_heap.h" #include "object_heap.h"
#include "sunxi_cedrus_drv_video.h" #include "sunxi_cedrus_drv_video.h"
#define BUFFER(id) ((object_buffer_p) object_heap_lookup(&driver_data->buffer_heap, id)) #define BUFFER(id) ((struct object_buffer *) object_heap_lookup(&driver_data->buffer_heap, id))
#define BUFFER_ID_OFFSET 0x08000000 #define BUFFER_ID_OFFSET 0x08000000
struct object_buffer { struct object_buffer {
@@ -45,8 +45,6 @@ struct object_buffer {
unsigned int map_size; unsigned int map_size;
}; };
typedef struct object_buffer *object_buffer_p;
VAStatus sunxi_cedrus_CreateBuffer(VADriverContextP ctx, VAContextID context, VAStatus sunxi_cedrus_CreateBuffer(VADriverContextP ctx, VAContextID context,
VABufferType type, unsigned int size, unsigned int num_elements, VABufferType type, unsigned int size, unsigned int num_elements,
void *data, VABufferID *buf_id); void *data, VABufferID *buf_id);
@@ -60,7 +58,7 @@ VAStatus sunxi_cedrus_MapBuffer(VADriverContextP ctx, VABufferID buf_id,
VAStatus sunxi_cedrus_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id); VAStatus sunxi_cedrus_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id);
void sunxi_cedrus_destroy_buffer(struct sunxi_cedrus_driver_data *driver_data, void sunxi_cedrus_destroy_buffer(struct sunxi_cedrus_driver_data *driver_data,
object_buffer_p obj_buffer); struct object_buffer *obj_buffer);
VAStatus sunxi_cedrus_DestroyBuffer(VADriverContextP ctx, VABufferID buffer_id); VAStatus sunxi_cedrus_DestroyBuffer(VADriverContextP ctx, VABufferID buffer_id);
+1 -1
View File
@@ -93,7 +93,7 @@ VAStatus sunxi_cedrus_DeriveImage(VADriverContextP ctx, VASurfaceID surface,
INIT_DRIVER_DATA INIT_DRIVER_DATA
object_surface_p obj_surface; object_surface_p obj_surface;
VAImageFormat fmt; VAImageFormat fmt;
object_buffer_p obj_buffer; struct object_buffer *obj_buffer;
VAStatus ret; VAStatus ret;
obj_surface = SURFACE(surface); obj_surface = SURFACE(surface);
+2 -2
View File
@@ -41,7 +41,7 @@
VAStatus sunxi_cedrus_render_mpeg2_slice_data(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg2_slice_data(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer) struct object_buffer *obj_buffer)
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
VAStatus vaStatus = VA_STATUS_SUCCESS; VAStatus vaStatus = VA_STATUS_SUCCESS;
@@ -54,7 +54,7 @@ VAStatus sunxi_cedrus_render_mpeg2_slice_data(VADriverContextP ctx,
VAStatus sunxi_cedrus_render_mpeg2_picture_parameter(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg2_picture_parameter(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer) struct object_buffer *obj_buffer)
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
VAStatus vaStatus = VA_STATUS_SUCCESS; VAStatus vaStatus = VA_STATUS_SUCCESS;
+2 -2
View File
@@ -35,10 +35,10 @@
VAStatus sunxi_cedrus_render_mpeg2_slice_data(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg2_slice_data(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer); struct object_buffer *obj_buffer);
VAStatus sunxi_cedrus_render_mpeg2_picture_parameter(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg2_picture_parameter(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer); struct object_buffer *obj_buffer);
#endif /* _MPEG2_H_ */ #endif /* _MPEG2_H_ */
+3 -3
View File
@@ -41,7 +41,7 @@
VAStatus sunxi_cedrus_render_mpeg4_slice_data(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg4_slice_data(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer) struct object_buffer *obj_buffer)
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
VAStatus vaStatus = VA_STATUS_SUCCESS; VAStatus vaStatus = VA_STATUS_SUCCESS;
@@ -72,7 +72,7 @@ VAStatus sunxi_cedrus_render_mpeg4_slice_data(VADriverContextP ctx,
VAStatus sunxi_cedrus_render_mpeg4_picture_parameter(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg4_picture_parameter(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer) struct object_buffer *obj_buffer)
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
VAStatus vaStatus = VA_STATUS_SUCCESS; VAStatus vaStatus = VA_STATUS_SUCCESS;
@@ -123,7 +123,7 @@ VAStatus sunxi_cedrus_render_mpeg4_picture_parameter(VADriverContextP ctx,
VAStatus sunxi_cedrus_render_mpeg4_slice_parameter(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg4_slice_parameter(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer) struct object_buffer *obj_buffer)
{ {
VASliceParameterBufferMPEG4 *slice_param = (VASliceParameterBufferMPEG4 *)obj_buffer->buffer_data; VASliceParameterBufferMPEG4 *slice_param = (VASliceParameterBufferMPEG4 *)obj_buffer->buffer_data;
+3 -3
View File
@@ -35,14 +35,14 @@
VAStatus sunxi_cedrus_render_mpeg4_slice_data(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg4_slice_data(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer); struct object_buffer *obj_buffer);
VAStatus sunxi_cedrus_render_mpeg4_picture_parameter(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg4_picture_parameter(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer); struct object_buffer *obj_buffer);
VAStatus sunxi_cedrus_render_mpeg4_slice_parameter(VADriverContextP ctx, VAStatus sunxi_cedrus_render_mpeg4_slice_parameter(VADriverContextP ctx,
object_context_p obj_context, object_surface_p obj_surface, object_context_p obj_context, object_surface_p obj_surface,
object_buffer_p obj_buffer); struct object_buffer *obj_buffer);
#endif /* _MPEG4_H_ */ #endif /* _MPEG4_H_ */
+1 -1
View File
@@ -106,7 +106,7 @@ VAStatus sunxi_cedrus_RenderPicture(VADriverContextP ctx, VAContextID context,
/* verify that we got valid buffer references */ /* verify that we got valid buffer references */
for(i = 0; i < num_buffers; i++) for(i = 0; i < num_buffers; i++)
{ {
object_buffer_p obj_buffer = BUFFER(buffers[i]); struct object_buffer *obj_buffer = BUFFER(buffers[i]);
assert(obj_buffer); assert(obj_buffer);
if (NULL == obj_buffer) if (NULL == obj_buffer)
{ {
+3 -3
View File
@@ -64,7 +64,7 @@ void sunxi_cedrus_msg(const char *msg, ...)
VAStatus sunxi_cedrus_Terminate(VADriverContextP ctx) VAStatus sunxi_cedrus_Terminate(VADriverContextP ctx)
{ {
INIT_DRIVER_DATA INIT_DRIVER_DATA
object_buffer_p obj_buffer; struct object_buffer *obj_buffer;
object_config_p obj_config; object_config_p obj_config;
object_heap_iterator iter; object_heap_iterator iter;
@@ -75,12 +75,12 @@ VAStatus sunxi_cedrus_Terminate(VADriverContextP ctx)
close(driver_data->mem2mem_fd); close(driver_data->mem2mem_fd);
/* Clean up left over buffers */ /* Clean up left over buffers */
obj_buffer = (object_buffer_p) object_heap_first(&driver_data->buffer_heap, &iter); obj_buffer = (struct object_buffer *) object_heap_first(&driver_data->buffer_heap, &iter);
while (obj_buffer) while (obj_buffer)
{ {
sunxi_cedrus_msg("vaTerminate: bufferID %08x still allocated, destroying\n", obj_buffer->base.id); sunxi_cedrus_msg("vaTerminate: bufferID %08x still allocated, destroying\n", obj_buffer->base.id);
sunxi_cedrus_destroy_buffer(driver_data, obj_buffer); sunxi_cedrus_destroy_buffer(driver_data, obj_buffer);
obj_buffer = (object_buffer_p) object_heap_next(&driver_data->buffer_heap, &iter); obj_buffer = (struct object_buffer *) object_heap_next(&driver_data->buffer_heap, &iter);
} }
object_heap_destroy(&driver_data->buffer_heap); object_heap_destroy(&driver_data->buffer_heap);
View File