From 22e0c6c3e142ac5b0c4d10c451589d0891242782 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 17 Jul 2018 16:43:58 +0200 Subject: tree: Rename the libva name for real Change the autotools files, and with them the name of the libva. Signed-off-by: Maxime Ripard --- src/Makefile.am | 14 +-- src/request.c | 257 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/sunxi_cedrus.c | 257 ----------------------------------------------------- 3 files changed, 264 insertions(+), 264 deletions(-) create mode 100644 src/request.c delete mode 100644 src/sunxi_cedrus.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 2741cff..0d3c33f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ backend_cflags = -Wall -fvisibility=hidden backend_ldflags = -module -avoid-version -no-undefined -Wl,--no-undefined backend_libs = -lpthread -ldl $(DRM_LIBS) $(LIBVA_DEPS_LIBS) -backend_c = sunxi_cedrus.c object_heap.c config.c surface.c context.c buffer.c \ +backend_c = request.c object_heap.c config.c surface.c context.c buffer.c \ mpeg2.c picture.c subpicture.c image.c v4l2.c video.c media.c utils.c \ h264.c @@ -14,12 +14,12 @@ backend_h = request.h object_heap.h config.h surface.h context.h buffer.h \ mpeg2.h picture.h subpicture.h image.h v4l2.h video.h media.h utils.h \ tiled_yuv.h h264.h -sunxi_cedrus_drv_video_la_LTLIBRARIES = sunxi_cedrus_drv_video.la -sunxi_cedrus_drv_video_ladir = $(LIBVA_DRIVERS_PATH) -sunxi_cedrus_drv_video_la_CFLAGS = $(backend_cflags) -sunxi_cedrus_drv_video_la_LDFLAGS = $(backend_ldflags) -sunxi_cedrus_drv_video_la_LIBADD = $(backend_libs) -sunxi_cedrus_drv_video_la_SOURCES = $(backend_c) $(backend_s) +v4l2_request_drv_video_la_LTLIBRARIES = v4l2_request_drv_video.la +v4l2_request_drv_video_ladir = $(LIBVA_DRIVERS_PATH) +v4l2_request_drv_video_la_CFLAGS = $(backend_cflags) +v4l2_request_drv_video_la_LDFLAGS = $(backend_ldflags) +v4l2_request_drv_video_la_LIBADD = $(backend_libs) +v4l2_request_drv_video_la_SOURCES = $(backend_c) $(backend_s) noinst_HEADERS = $(backend_h) MAINTAINERCLEANFILES = Makefile.in autoconfig.h.in diff --git a/src/request.c b/src/request.c new file mode 100644 index 0000000..19f39b1 --- /dev/null +++ b/src/request.c @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2016 Florent Revest, + * 2007 Intel Corporation. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "buffer.h" +#include "config.h" +#include "context.h" +#include "image.h" +#include "picture.h" +#include "subpicture.h" +#include "surface.h" + +#include "autoconfig.h" + +#include + +#include "request.h" +#include "utils.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +/* Set default visibility for the init function only. */ +VAStatus __attribute__((visibility("default"))) +VA_DRIVER_INIT_FUNC(VADriverContextP context); + +VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context) +{ + struct request_data *driver_data; + struct VADriverVTable *vtable = context->vtable; + struct v4l2_capability capability; + VAStatus status; + int video_fd = -1; + int media_fd = -1; + char *video_path; + char *media_path; + int rc; + + context->version_major = VA_MAJOR_VERSION; + context->version_minor = VA_MINOR_VERSION; + context->max_profiles = V4L2_REQUEST_MAX_PROFILES; + context->max_entrypoints = V4L2_REQUEST_MAX_ENTRYPOINTS; + context->max_attributes = V4L2_REQUEST_MAX_CONFIG_ATTRIBUTES; + context->max_image_formats = V4L2_REQUEST_MAX_IMAGE_FORMATS; + context->max_subpic_formats = V4L2_REQUEST_MAX_SUBPIC_FORMATS; + context->max_display_attributes = V4L2_REQUEST_MAX_DISPLAY_ATTRIBUTES; + context->str_vendor = V4L2_REQUEST_STR_VENDOR; + + vtable->vaTerminate = RequestTerminate; + vtable->vaQueryConfigEntrypoints = RequestQueryConfigEntrypoints; + vtable->vaQueryConfigProfiles = RequestQueryConfigProfiles; + vtable->vaQueryConfigEntrypoints = RequestQueryConfigEntrypoints; + vtable->vaQueryConfigAttributes = RequestQueryConfigAttributes; + vtable->vaCreateConfig = RequestCreateConfig; + vtable->vaDestroyConfig = RequestDestroyConfig; + vtable->vaGetConfigAttributes = RequestGetConfigAttributes; + vtable->vaCreateSurfaces = RequestCreateSurfaces; + vtable->vaDestroySurfaces = RequestDestroySurfaces; + vtable->vaCreateContext = RequestCreateContext; + vtable->vaDestroyContext = RequestDestroyContext; + vtable->vaCreateBuffer = RequestCreateBuffer; + vtable->vaBufferSetNumElements = RequestBufferSetNumElements; + vtable->vaMapBuffer = RequestMapBuffer; + vtable->vaUnmapBuffer = RequestUnmapBuffer; + vtable->vaDestroyBuffer = RequestDestroyBuffer; + vtable->vaBeginPicture = RequestBeginPicture; + vtable->vaRenderPicture = RequestRenderPicture; + vtable->vaEndPicture = RequestEndPicture; + vtable->vaSyncSurface = RequestSyncSurface; + vtable->vaQuerySurfaceStatus = RequestQuerySurfaceStatus; + vtable->vaPutSurface = RequestPutSurface; + vtable->vaQueryImageFormats = RequestQueryImageFormats; + vtable->vaCreateImage = RequestCreateImage; + vtable->vaDeriveImage = RequestDeriveImage; + vtable->vaDestroyImage = RequestDestroyImage; + vtable->vaSetImagePalette = RequestSetImagePalette; + vtable->vaGetImage = RequestGetImage; + vtable->vaPutImage = RequestPutImage; + vtable->vaQuerySubpictureFormats = RequestQuerySubpictureFormats; + vtable->vaCreateSubpicture = RequestCreateSubpicture; + vtable->vaDestroySubpicture = RequestDestroySubpicture; + vtable->vaSetSubpictureImage = RequestSetSubpictureImage; + vtable->vaSetSubpictureChromakey = RequestSetSubpictureChromakey; + vtable->vaSetSubpictureGlobalAlpha = RequestSetSubpictureGlobalAlpha; + vtable->vaAssociateSubpicture = RequestAssociateSubpicture; + vtable->vaDeassociateSubpicture = RequestDeassociateSubpicture; + vtable->vaQueryDisplayAttributes = RequestQueryDisplayAttributes; + vtable->vaGetDisplayAttributes = RequestGetDisplayAttributes; + vtable->vaSetDisplayAttributes = RequestSetDisplayAttributes; + vtable->vaLockSurface = RequestLockSurface; + vtable->vaUnlockSurface = RequestUnlockSurface; + vtable->vaBufferInfo = RequestBufferInfo; + + driver_data = malloc(sizeof(*driver_data)); + memset(driver_data, 0, sizeof(*driver_data)); + + context->pDriverData = driver_data; + + object_heap_init(&driver_data->config_heap, + sizeof(struct object_config), CONFIG_ID_OFFSET); + object_heap_init(&driver_data->context_heap, + sizeof(struct object_context), CONTEXT_ID_OFFSET); + object_heap_init(&driver_data->surface_heap, + sizeof(struct object_surface), SURFACE_ID_OFFSET); + object_heap_init(&driver_data->buffer_heap, + sizeof(struct object_buffer), BUFFER_ID_OFFSET); + object_heap_init(&driver_data->image_heap, sizeof(struct object_image), + IMAGE_ID_OFFSET); + + video_path = getenv("LIBVA_CEDRUS_VIDEO_PATH"); + if (video_path == NULL) + video_path = "/dev/video0"; + + video_fd = open(video_path, O_RDWR | O_NONBLOCK); + if (video_fd < 0) + return VA_STATUS_ERROR_OPERATION_FAILED; + + rc = ioctl(video_fd, VIDIOC_QUERYCAP, &capability); + if (rc < 0 || !(capability.capabilities & V4L2_CAP_VIDEO_M2M_MPLANE)) { + request_log("Video device %s does not support m2m mplanes\n", + video_path); + status = VA_STATUS_ERROR_OPERATION_FAILED; + goto error; + } + + media_path = getenv("LIBVA_CEDRUS_MEDIA_PATH"); + if (media_path == NULL) + media_path = "/dev/media0"; + + media_fd = open(media_path, O_RDWR | O_NONBLOCK); + if (media_fd < 0) + return VA_STATUS_ERROR_OPERATION_FAILED; + + driver_data->video_fd = video_fd; + driver_data->media_fd = media_fd; + + status = VA_STATUS_SUCCESS; + goto complete; + +error: + status = VA_STATUS_ERROR_OPERATION_FAILED; + + if (video_fd >= 0) + close(video_fd); + + if (media_fd >= 0) + close(media_fd); + +complete: + return status; +} + +VAStatus RequestTerminate(VADriverContextP context) +{ + struct request_data *driver_data = context->pDriverData; + struct object_buffer *buffer_object; + struct object_image *image_object; + struct object_surface *surface_object; + struct object_context *context_object; + struct object_config *config_object; + int iterator; + + close(driver_data->video_fd); + close(driver_data->media_fd); + + /* Cleanup leftover buffers. */ + + image_object = (struct object_image *) + object_heap_first(&driver_data->image_heap, &iterator); + while (image_object != NULL) { + RequestDestroyImage(context, (VAImageID)image_object->base.id); + image_object = (struct object_image *) + object_heap_next(&driver_data->image_heap, &iterator); + } + + object_heap_destroy(&driver_data->image_heap); + + buffer_object = (struct object_buffer *) + object_heap_first(&driver_data->buffer_heap, &iterator); + while (buffer_object != NULL) { + RequestDestroyBuffer(context, + (VABufferID)buffer_object->base.id); + buffer_object = (struct object_buffer *) + object_heap_next(&driver_data->buffer_heap, &iterator); + } + + object_heap_destroy(&driver_data->buffer_heap); + + surface_object = (struct object_surface *) + object_heap_first(&driver_data->surface_heap, &iterator); + while (surface_object != NULL) { + RequestDestroySurfaces(context, + (VASurfaceID *)&surface_object->base.id, 1); + surface_object = (struct object_surface *) + object_heap_next(&driver_data->surface_heap, &iterator); + } + + object_heap_destroy(&driver_data->surface_heap); + + context_object = (struct object_context *) + object_heap_first(&driver_data->context_heap, &iterator); + while (context_object != NULL) { + RequestDestroyContext(context, + (VAContextID)context_object->base.id); + context_object = (struct object_context *) + object_heap_next(&driver_data->context_heap, &iterator); + } + + object_heap_destroy(&driver_data->context_heap); + + config_object = (struct object_config *) + object_heap_first(&driver_data->config_heap, &iterator); + while (config_object != NULL) { + RequestDestroyConfig(context, + (VAConfigID)config_object->base.id); + config_object = (struct object_config *) + object_heap_next(&driver_data->config_heap, &iterator); + } + + object_heap_destroy(&driver_data->config_heap); + + free(context->pDriverData); + context->pDriverData = NULL; + + return VA_STATUS_SUCCESS; +} diff --git a/src/sunxi_cedrus.c b/src/sunxi_cedrus.c deleted file mode 100644 index 19f39b1..0000000 --- a/src/sunxi_cedrus.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2016 Florent Revest, - * 2007 Intel Corporation. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "buffer.h" -#include "config.h" -#include "context.h" -#include "image.h" -#include "picture.h" -#include "subpicture.h" -#include "surface.h" - -#include "autoconfig.h" - -#include - -#include "request.h" -#include "utils.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -/* Set default visibility for the init function only. */ -VAStatus __attribute__((visibility("default"))) -VA_DRIVER_INIT_FUNC(VADriverContextP context); - -VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context) -{ - struct request_data *driver_data; - struct VADriverVTable *vtable = context->vtable; - struct v4l2_capability capability; - VAStatus status; - int video_fd = -1; - int media_fd = -1; - char *video_path; - char *media_path; - int rc; - - context->version_major = VA_MAJOR_VERSION; - context->version_minor = VA_MINOR_VERSION; - context->max_profiles = V4L2_REQUEST_MAX_PROFILES; - context->max_entrypoints = V4L2_REQUEST_MAX_ENTRYPOINTS; - context->max_attributes = V4L2_REQUEST_MAX_CONFIG_ATTRIBUTES; - context->max_image_formats = V4L2_REQUEST_MAX_IMAGE_FORMATS; - context->max_subpic_formats = V4L2_REQUEST_MAX_SUBPIC_FORMATS; - context->max_display_attributes = V4L2_REQUEST_MAX_DISPLAY_ATTRIBUTES; - context->str_vendor = V4L2_REQUEST_STR_VENDOR; - - vtable->vaTerminate = RequestTerminate; - vtable->vaQueryConfigEntrypoints = RequestQueryConfigEntrypoints; - vtable->vaQueryConfigProfiles = RequestQueryConfigProfiles; - vtable->vaQueryConfigEntrypoints = RequestQueryConfigEntrypoints; - vtable->vaQueryConfigAttributes = RequestQueryConfigAttributes; - vtable->vaCreateConfig = RequestCreateConfig; - vtable->vaDestroyConfig = RequestDestroyConfig; - vtable->vaGetConfigAttributes = RequestGetConfigAttributes; - vtable->vaCreateSurfaces = RequestCreateSurfaces; - vtable->vaDestroySurfaces = RequestDestroySurfaces; - vtable->vaCreateContext = RequestCreateContext; - vtable->vaDestroyContext = RequestDestroyContext; - vtable->vaCreateBuffer = RequestCreateBuffer; - vtable->vaBufferSetNumElements = RequestBufferSetNumElements; - vtable->vaMapBuffer = RequestMapBuffer; - vtable->vaUnmapBuffer = RequestUnmapBuffer; - vtable->vaDestroyBuffer = RequestDestroyBuffer; - vtable->vaBeginPicture = RequestBeginPicture; - vtable->vaRenderPicture = RequestRenderPicture; - vtable->vaEndPicture = RequestEndPicture; - vtable->vaSyncSurface = RequestSyncSurface; - vtable->vaQuerySurfaceStatus = RequestQuerySurfaceStatus; - vtable->vaPutSurface = RequestPutSurface; - vtable->vaQueryImageFormats = RequestQueryImageFormats; - vtable->vaCreateImage = RequestCreateImage; - vtable->vaDeriveImage = RequestDeriveImage; - vtable->vaDestroyImage = RequestDestroyImage; - vtable->vaSetImagePalette = RequestSetImagePalette; - vtable->vaGetImage = RequestGetImage; - vtable->vaPutImage = RequestPutImage; - vtable->vaQuerySubpictureFormats = RequestQuerySubpictureFormats; - vtable->vaCreateSubpicture = RequestCreateSubpicture; - vtable->vaDestroySubpicture = RequestDestroySubpicture; - vtable->vaSetSubpictureImage = RequestSetSubpictureImage; - vtable->vaSetSubpictureChromakey = RequestSetSubpictureChromakey; - vtable->vaSetSubpictureGlobalAlpha = RequestSetSubpictureGlobalAlpha; - vtable->vaAssociateSubpicture = RequestAssociateSubpicture; - vtable->vaDeassociateSubpicture = RequestDeassociateSubpicture; - vtable->vaQueryDisplayAttributes = RequestQueryDisplayAttributes; - vtable->vaGetDisplayAttributes = RequestGetDisplayAttributes; - vtable->vaSetDisplayAttributes = RequestSetDisplayAttributes; - vtable->vaLockSurface = RequestLockSurface; - vtable->vaUnlockSurface = RequestUnlockSurface; - vtable->vaBufferInfo = RequestBufferInfo; - - driver_data = malloc(sizeof(*driver_data)); - memset(driver_data, 0, sizeof(*driver_data)); - - context->pDriverData = driver_data; - - object_heap_init(&driver_data->config_heap, - sizeof(struct object_config), CONFIG_ID_OFFSET); - object_heap_init(&driver_data->context_heap, - sizeof(struct object_context), CONTEXT_ID_OFFSET); - object_heap_init(&driver_data->surface_heap, - sizeof(struct object_surface), SURFACE_ID_OFFSET); - object_heap_init(&driver_data->buffer_heap, - sizeof(struct object_buffer), BUFFER_ID_OFFSET); - object_heap_init(&driver_data->image_heap, sizeof(struct object_image), - IMAGE_ID_OFFSET); - - video_path = getenv("LIBVA_CEDRUS_VIDEO_PATH"); - if (video_path == NULL) - video_path = "/dev/video0"; - - video_fd = open(video_path, O_RDWR | O_NONBLOCK); - if (video_fd < 0) - return VA_STATUS_ERROR_OPERATION_FAILED; - - rc = ioctl(video_fd, VIDIOC_QUERYCAP, &capability); - if (rc < 0 || !(capability.capabilities & V4L2_CAP_VIDEO_M2M_MPLANE)) { - request_log("Video device %s does not support m2m mplanes\n", - video_path); - status = VA_STATUS_ERROR_OPERATION_FAILED; - goto error; - } - - media_path = getenv("LIBVA_CEDRUS_MEDIA_PATH"); - if (media_path == NULL) - media_path = "/dev/media0"; - - media_fd = open(media_path, O_RDWR | O_NONBLOCK); - if (media_fd < 0) - return VA_STATUS_ERROR_OPERATION_FAILED; - - driver_data->video_fd = video_fd; - driver_data->media_fd = media_fd; - - status = VA_STATUS_SUCCESS; - goto complete; - -error: - status = VA_STATUS_ERROR_OPERATION_FAILED; - - if (video_fd >= 0) - close(video_fd); - - if (media_fd >= 0) - close(media_fd); - -complete: - return status; -} - -VAStatus RequestTerminate(VADriverContextP context) -{ - struct request_data *driver_data = context->pDriverData; - struct object_buffer *buffer_object; - struct object_image *image_object; - struct object_surface *surface_object; - struct object_context *context_object; - struct object_config *config_object; - int iterator; - - close(driver_data->video_fd); - close(driver_data->media_fd); - - /* Cleanup leftover buffers. */ - - image_object = (struct object_image *) - object_heap_first(&driver_data->image_heap, &iterator); - while (image_object != NULL) { - RequestDestroyImage(context, (VAImageID)image_object->base.id); - image_object = (struct object_image *) - object_heap_next(&driver_data->image_heap, &iterator); - } - - object_heap_destroy(&driver_data->image_heap); - - buffer_object = (struct object_buffer *) - object_heap_first(&driver_data->buffer_heap, &iterator); - while (buffer_object != NULL) { - RequestDestroyBuffer(context, - (VABufferID)buffer_object->base.id); - buffer_object = (struct object_buffer *) - object_heap_next(&driver_data->buffer_heap, &iterator); - } - - object_heap_destroy(&driver_data->buffer_heap); - - surface_object = (struct object_surface *) - object_heap_first(&driver_data->surface_heap, &iterator); - while (surface_object != NULL) { - RequestDestroySurfaces(context, - (VASurfaceID *)&surface_object->base.id, 1); - surface_object = (struct object_surface *) - object_heap_next(&driver_data->surface_heap, &iterator); - } - - object_heap_destroy(&driver_data->surface_heap); - - context_object = (struct object_context *) - object_heap_first(&driver_data->context_heap, &iterator); - while (context_object != NULL) { - RequestDestroyContext(context, - (VAContextID)context_object->base.id); - context_object = (struct object_context *) - object_heap_next(&driver_data->context_heap, &iterator); - } - - object_heap_destroy(&driver_data->context_heap); - - config_object = (struct object_config *) - object_heap_first(&driver_data->config_heap, &iterator); - while (config_object != NULL) { - RequestDestroyConfig(context, - (VAConfigID)config_object->base.id); - config_object = (struct object_config *) - object_heap_next(&driver_data->config_heap, &iterator); - } - - object_heap_destroy(&driver_data->config_heap); - - free(context->pDriverData); - context->pDriverData = NULL; - - return VA_STATUS_SUCCESS; -} -- cgit v1.2.3