forked from marfrit/libva-v4l2-request-fourier
tree: Run clang-format to conform to the kernel coding style
The coding style has been a bit erratic. Enforce the linux kernel coding style by reusing their .clang-format file, running clang-format on the source, and ignoring the few shortcomings that clang-format has at the moment (especially on aligning the define values). Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
This commit is contained in:
+97
-48
@@ -23,30 +23,31 @@
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "sunxi_cedrus.h"
|
||||
#include "surface.h"
|
||||
#include "sunxi_cedrus.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "v4l2.h"
|
||||
#include "video.h"
|
||||
#include "media.h"
|
||||
#include "utils.h"
|
||||
#include "v4l2.h"
|
||||
#include "video.h"
|
||||
|
||||
VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
||||
int height, int format, int surfaces_count, VASurfaceID *surfaces_ids)
|
||||
int height, int format, int surfaces_count,
|
||||
VASurfaceID *surfaces_ids)
|
||||
{
|
||||
struct cedrus_data *driver_data =
|
||||
(struct cedrus_data *) context->pDriverData;
|
||||
(struct cedrus_data *)context->pDriverData;
|
||||
struct object_surface *surface_object;
|
||||
struct video_format *video_format;
|
||||
unsigned int destination_sizes[VIDEO_MAX_PLANES];
|
||||
@@ -62,7 +63,9 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
||||
|
||||
driver_data->tiled_format = true;
|
||||
|
||||
found = v4l2_find_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, V4L2_PIX_FMT_NV12);
|
||||
found = v4l2_find_format(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
|
||||
V4L2_PIX_FMT_NV12);
|
||||
if (found)
|
||||
driver_data->tiled_format = false;
|
||||
|
||||
@@ -70,15 +73,22 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
||||
if (video_format == NULL)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
rc = v4l2_set_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, video_format->v4l2_format, width, height);
|
||||
rc = v4l2_set_format(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
|
||||
video_format->v4l2_format, width, height);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
rc = v4l2_get_format(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, NULL, NULL, destination_bytesperlines, destination_sizes, &destination_planes_count);
|
||||
rc = v4l2_get_format(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, NULL, NULL,
|
||||
destination_bytesperlines, destination_sizes,
|
||||
&destination_planes_count);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
rc = v4l2_create_buffers(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, surfaces_count);
|
||||
rc = v4l2_create_buffers(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
|
||||
surfaces_count);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
|
||||
@@ -88,29 +98,47 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
||||
if (surface_object == NULL)
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
|
||||
rc = v4l2_request_buffer(driver_data->video_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, i, surface_object->destination_map_lengths, surface_object->destination_map_offsets, video_format->v4l2_buffers_count);
|
||||
rc = v4l2_request_buffer(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, i,
|
||||
surface_object->destination_map_lengths,
|
||||
surface_object->destination_map_offsets,
|
||||
video_format->v4l2_buffers_count);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
|
||||
for (j = 0; j < video_format->v4l2_buffers_count; j++) {
|
||||
surface_object->destination_map[j] = mmap(NULL, surface_object->destination_map_lengths[j], PROT_READ | PROT_WRITE, MAP_SHARED, driver_data->video_fd, surface_object->destination_map_offsets[j]);
|
||||
surface_object->destination_map[j] =
|
||||
mmap(NULL,
|
||||
surface_object->destination_map_lengths[j],
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
driver_data->video_fd,
|
||||
surface_object->destination_map_offsets[j]);
|
||||
|
||||
if (surface_object->destination_map[j] == MAP_FAILED)
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
|
||||
if (video_format->v4l2_buffers_count == 1) {
|
||||
for (j = 0; j < destination_planes_count; j++) {
|
||||
surface_object->destination_offsets[j] = j > 0 ? destination_sizes[j-1] : 0;
|
||||
surface_object->destination_data[j] = (void *) ((unsigned char *) surface_object->destination_map[0] + surface_object->destination_offsets[j]);
|
||||
surface_object->destination_sizes[j] = destination_sizes[j];
|
||||
surface_object->destination_bytesperlines[j] = destination_bytesperlines[j];
|
||||
surface_object->destination_offsets[j] =
|
||||
j > 0 ? destination_sizes[j - 1] : 0;
|
||||
surface_object->destination_data[j] =
|
||||
(void *)((unsigned char *)surface_object->destination_map[0] +
|
||||
surface_object->destination_offsets[j]);
|
||||
surface_object->destination_sizes[j] =
|
||||
destination_sizes[j];
|
||||
surface_object->destination_bytesperlines[j] =
|
||||
destination_bytesperlines[j];
|
||||
}
|
||||
} else if (video_format->v4l2_buffers_count == destination_planes_count) {
|
||||
for (j = 0; j < destination_planes_count; j++) {
|
||||
surface_object->destination_offsets[j] = 0;
|
||||
surface_object->destination_data[j] = surface_object->destination_map[j];
|
||||
surface_object->destination_sizes[j] = destination_sizes[j];
|
||||
surface_object->destination_bytesperlines[j] = destination_bytesperlines[j];
|
||||
surface_object->destination_data[j] =
|
||||
surface_object->destination_map[j];
|
||||
surface_object->destination_sizes[j] =
|
||||
destination_sizes[j];
|
||||
surface_object->destination_bytesperlines[j] =
|
||||
destination_bytesperlines[j];
|
||||
}
|
||||
} else {
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
@@ -126,10 +154,13 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
||||
|
||||
surface_object->destination_index = 0;
|
||||
|
||||
surface_object->destination_planes_count = destination_planes_count;
|
||||
surface_object->destination_buffers_count = video_format->v4l2_buffers_count;
|
||||
surface_object->destination_planes_count =
|
||||
destination_planes_count;
|
||||
surface_object->destination_buffers_count =
|
||||
video_format->v4l2_buffers_count;
|
||||
|
||||
memset(&surface_object->params, 0, sizeof(surface_object->params));
|
||||
memset(&surface_object->params, 0,
|
||||
sizeof(surface_object->params));
|
||||
surface_object->slices_size = 0;
|
||||
|
||||
surface_object->request_fd = -1;
|
||||
@@ -141,10 +172,11 @@ VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
|
||||
}
|
||||
|
||||
VAStatus SunxiCedrusDestroySurfaces(VADriverContextP context,
|
||||
VASurfaceID *surfaces_ids, int surfaces_count)
|
||||
VASurfaceID *surfaces_ids,
|
||||
int surfaces_count)
|
||||
{
|
||||
struct cedrus_data *driver_data =
|
||||
(struct cedrus_data *) context->pDriverData;
|
||||
(struct cedrus_data *)context->pDriverData;
|
||||
struct object_surface *surface_object;
|
||||
unsigned int i, j;
|
||||
|
||||
@@ -153,30 +185,35 @@ VAStatus SunxiCedrusDestroySurfaces(VADriverContextP context,
|
||||
if (surface_object == NULL)
|
||||
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||
|
||||
if (surface_object->source_data != NULL && surface_object->source_size > 0)
|
||||
munmap(surface_object->source_data, surface_object->source_size);
|
||||
if (surface_object->source_data != NULL &&
|
||||
surface_object->source_size > 0)
|
||||
munmap(surface_object->source_data,
|
||||
surface_object->source_size);
|
||||
|
||||
if (surface_object->request_fd >= 0)
|
||||
close(surface_object->request_fd);
|
||||
|
||||
for (j = 0; j < surface_object->destination_buffers_count; j++)
|
||||
if (surface_object->destination_map[j] != NULL && surface_object->destination_map_lengths[j] > 0)
|
||||
munmap(surface_object->destination_map[j], surface_object->destination_map_lengths[j]);
|
||||
if (surface_object->destination_map[j] != NULL &&
|
||||
surface_object->destination_map_lengths[j] > 0)
|
||||
munmap(surface_object->destination_map[j],
|
||||
surface_object->destination_map_lengths[j]);
|
||||
|
||||
if (surface_object->request_fd > 0)
|
||||
close(surface_object->request_fd);
|
||||
|
||||
object_heap_free(&driver_data->surface_heap, (struct object_base *) surface_object);
|
||||
object_heap_free(&driver_data->surface_heap,
|
||||
(struct object_base *)surface_object);
|
||||
}
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VAStatus SunxiCedrusSyncSurface(VADriverContextP context,
|
||||
VASurfaceID surface_id)
|
||||
VASurfaceID surface_id)
|
||||
{
|
||||
struct cedrus_data *driver_data =
|
||||
(struct cedrus_data *) context->pDriverData;
|
||||
(struct cedrus_data *)context->pDriverData;
|
||||
struct object_surface *surface_object;
|
||||
VAStatus status;
|
||||
int request_fd = -1;
|
||||
@@ -217,13 +254,18 @@ VAStatus SunxiCedrusSyncSurface(VADriverContextP context,
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = v4l2_dequeue_buffer(driver_data->video_fd, -1, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, surface_object->source_index, 1);
|
||||
rc = v4l2_dequeue_buffer(driver_data->video_fd, -1,
|
||||
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
|
||||
surface_object->source_index, 1);
|
||||
if (rc < 0) {
|
||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = v4l2_dequeue_buffer(driver_data->video_fd, -1, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, surface_object->destination_index, surface_object->destination_buffers_count);
|
||||
rc = v4l2_dequeue_buffer(driver_data->video_fd, -1,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
|
||||
surface_object->destination_index,
|
||||
surface_object->destination_buffers_count);
|
||||
if (rc < 0) {
|
||||
status = VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
goto error;
|
||||
@@ -245,10 +287,11 @@ complete:
|
||||
}
|
||||
|
||||
VAStatus SunxiCedrusQuerySurfaceStatus(VADriverContextP context,
|
||||
VASurfaceID surface_id, VASurfaceStatus *status)
|
||||
VASurfaceID surface_id,
|
||||
VASurfaceStatus *status)
|
||||
{
|
||||
struct cedrus_data *driver_data =
|
||||
(struct cedrus_data *) context->pDriverData;
|
||||
(struct cedrus_data *)context->pDriverData;
|
||||
struct object_surface *surface_object;
|
||||
|
||||
surface_object = SURFACE(driver_data, surface_id);
|
||||
@@ -261,26 +304,32 @@ VAStatus SunxiCedrusQuerySurfaceStatus(VADriverContextP context,
|
||||
}
|
||||
|
||||
VAStatus SunxiCedrusPutSurface(VADriverContextP context, VASurfaceID surface_id,
|
||||
void *draw, short src_x, short src_y, unsigned short src_width,
|
||||
unsigned short src_height, short dst_x, short dst_y,
|
||||
unsigned short dst_width, unsigned short dst_height,
|
||||
VARectangle *cliprects, unsigned int cliprects_count,
|
||||
unsigned int flags)
|
||||
void *draw, short src_x, short src_y,
|
||||
unsigned short src_width,
|
||||
unsigned short src_height, short dst_x,
|
||||
short dst_y, unsigned short dst_width,
|
||||
unsigned short dst_height,
|
||||
VARectangle *cliprects,
|
||||
unsigned int cliprects_count, unsigned int flags)
|
||||
{
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
VAStatus SunxiCedrusLockSurface(VADriverContextP context,
|
||||
VASurfaceID surface_id, unsigned int *fourcc, unsigned int *luma_stride,
|
||||
unsigned int *chroma_u_stride, unsigned int *chroma_v_stride,
|
||||
unsigned int *luma_offset, unsigned int *chroma_u_offset,
|
||||
unsigned int *chroma_v_offset, unsigned int *buffer_name, void **buffer)
|
||||
VASurfaceID surface_id, unsigned int *fourcc,
|
||||
unsigned int *luma_stride,
|
||||
unsigned int *chroma_u_stride,
|
||||
unsigned int *chroma_v_stride,
|
||||
unsigned int *luma_offset,
|
||||
unsigned int *chroma_u_offset,
|
||||
unsigned int *chroma_v_offset,
|
||||
unsigned int *buffer_name, void **buffer)
|
||||
{
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
VAStatus SunxiCedrusUnlockSurface(VADriverContextP context,
|
||||
VASurfaceID surface_id)
|
||||
VASurfaceID surface_id)
|
||||
{
|
||||
return VA_STATUS_ERROR_UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user