Move log function to a dedicated file and rename it along the way

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
This commit is contained in:
Paul Kocialkowski
2018-04-24 17:12:29 +02:00
parent 9de2ba88b5
commit 6cd00b758c
10 changed files with 89 additions and 26 deletions
+1
View File
@@ -36,6 +36,7 @@
#include <linux/videodev2.h>
#include "utils.h"
#include "v4l2.h"
VAStatus SunxiCedrusCreateBuffer(VADriverContextP context,
+1
View File
@@ -34,6 +34,7 @@
#include <linux/videodev2.h>
#include "v4l2.h"
#include "utils.h"
VAStatus SunxiCedrusCreateConfig(VADriverContextP context, VAProfile profile,
VAEntrypoint entrypoint, VAConfigAttrib *attributes,
+5 -5
View File
@@ -36,7 +36,7 @@ int media_request_alloc(int media_fd)
rc = ioctl(media_fd, MEDIA_IOC_REQUEST_ALLOC, &request_alloc);
if (rc < 0) {
sunxi_cedrus_msg("Unable to allocate media request: %s\n", strerror(errno));
sunxi_cedrus_log("Unable to allocate media request: %s\n", strerror(errno));
return -1;
}
@@ -49,7 +49,7 @@ int media_request_reinit(int request_fd)
rc = ioctl(request_fd, MEDIA_REQUEST_IOC_REINIT, NULL);
if (rc < 0) {
sunxi_cedrus_msg("Unable to reinit media request: %s\n", strerror(errno));
sunxi_cedrus_log("Unable to reinit media request: %s\n", strerror(errno));
return -1;
}
@@ -62,7 +62,7 @@ int media_request_queue(int request_fd)
rc = ioctl(request_fd, MEDIA_REQUEST_IOC_QUEUE, NULL);
if (rc < 0) {
sunxi_cedrus_msg("Unable to queue media request: %s\n", strerror(errno));
sunxi_cedrus_log("Unable to queue media request: %s\n", strerror(errno));
return -1;
}
@@ -79,10 +79,10 @@ int media_request_wait_completion(int request_fd)
rc = select(request_fd + 1, NULL, NULL, &except_fds, &tv);
if (rc == 0) {
sunxi_cedrus_msg("Timeout when waiting for media request\n");
sunxi_cedrus_log("Timeout when waiting for media request\n");
return -1;
} else if (rc < 0) {
sunxi_cedrus_msg("Unable to select media request: %s\n", strerror(errno));
sunxi_cedrus_log("Unable to select media request: %s\n", strerror(errno));
return -1;
}
+2 -1
View File
@@ -42,6 +42,7 @@
#include <linux/videodev2.h>
#include "v4l2.h"
#include "utils.h"
VAStatus SunxiCedrusBeginPicture(VADriverContextP context,
VAContextID context_id, VASurfaceID surface_id)
@@ -119,7 +120,7 @@ VAStatus SunxiCedrusRenderPicture(VADriverContextP context,
if (rc < 0)
return VA_STATUS_ERROR_OPERATION_FAILED;
} else {
sunxi_cedrus_msg("Unsupported buffer type: %d\n", buffer_object->type);
sunxi_cedrus_log("Unsupported buffer type: %d\n", buffer_object->type);
}
break;
+2 -12
View File
@@ -36,6 +36,7 @@
#include <va/va_backend.h>
#include "sunxi_cedrus.h"
#include "utils.h"
#include <assert.h>
#include <stdlib.h>
@@ -49,17 +50,6 @@
#include <linux/videodev2.h>
void sunxi_cedrus_msg(const char *msg, ...)
{
va_list args;
/* We need to use stderr if we want to be heard */
fprintf(stderr, "sunxi_cedrus_drv_video: ");
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
}
/* Set default visibility for the init function only. */
VAStatus __attribute__((visibility("default")))
VA_DRIVER_INIT_FUNC(VADriverContextP context);
@@ -153,7 +143,7 @@ VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context)
rc = ioctl(driver_data->video_fd, VIDIOC_QUERYCAP, &capability);
if (rc < 0 || !(capability.capabilities & V4L2_CAP_VIDEO_M2M_MPLANE)) {
sunxi_cedrus_msg("%s does not support m2m mplanes\n", path);
sunxi_cedrus_log("%s does not support m2m mplanes\n", path);
return VA_STATUS_ERROR_OPERATION_FAILED;
}
-2
View File
@@ -56,8 +56,6 @@ struct sunxi_cedrus_driver_data {
int slice_offset[INPUT_BUFFERS_NB];
};
void sunxi_cedrus_msg(const char *msg, ...);
VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context);
VAStatus SunxiCedrusTerminate(VADriverContextP context);
+3 -2
View File
@@ -39,6 +39,7 @@
#include <X11/Xlib.h>
#include "v4l2.h"
#include "utils.h"
VAStatus SunxiCedrusCreateSurfaces(VADriverContextP context, int width,
int height, int format, int surfaces_count, VASurfaceID *surfaces)
@@ -204,11 +205,11 @@ VAStatus SunxiCedrusPutSurface(VADriverContextP context, VASurfaceID surface_id,
display = XOpenDisplay(getenv("DISPLAY"));
if (display == NULL) {
sunxi_cedrus_msg("Cannot connect to X server\n");
sunxi_cedrus_log("Cannot connect to X server\n");
exit(1);
}
sunxi_cedrus_msg("warning: using vaPutSurface with sunxi-cedrus is not recommended\n");
sunxi_cedrus_log("warning: using vaPutSurface with sunxi-cedrus is not recommended\n");
screen = DefaultScreen(display);
gc = XCreateGC(display, RootWindow(display, screen), 0, NULL);
XSync(display, False);
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
* Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
*
* 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 <stdlib.h>
#include "sunxi_cedrus.h"
#include "utils.h"
void sunxi_cedrus_log(const char *format, ...)
{
va_list arguments;
fprintf(stderr, "%s: ", SUNXI_CEDRUS_STR_VENDOR);
va_start(arguments, format);
vfprintf(stderr, format, arguments);
va_end(arguments);
}
+31
View File
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2016 Florent Revest <florent.revest@free-electrons.com>
* Copyright (C) 2018 Paul Kocialkowski <paul.kocialkowski@bootlin.com>
*
* 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.
*/
#ifndef _UTILS_H_
#define _UTILS_H_
void sunxi_cedrus_log(const char *format, ...);
#endif
+4 -4
View File
@@ -69,7 +69,7 @@ int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat,
rc = ioctl(video_fd, VIDIOC_S_FMT, &format);
if (rc < 0) {
sunxi_cedrus_msg("Unable to set format for type %d: %s\n", type, strerror(errno));
sunxi_cedrus_log("Unable to set format for type %d: %s\n", type, strerror(errno));
return -1;
}
@@ -89,13 +89,13 @@ int v4l2_create_buffers(int video_fd, unsigned int type,
rc = ioctl(video_fd, VIDIOC_G_FMT, &buffers.format);
if (rc < 0) {
sunxi_cedrus_msg("Unable to get format for type %d: %s\n", type, strerror(errno));
sunxi_cedrus_log("Unable to get format for type %d: %s\n", type, strerror(errno));
return -1;
}
rc = ioctl(video_fd, VIDIOC_CREATE_BUFS, &buffers);
if (rc < 0) {
sunxi_cedrus_msg("Unable to create buffer for type %d: %s\n", type, strerror(errno));
sunxi_cedrus_log("Unable to create buffer for type %d: %s\n", type, strerror(errno));
return -1;
}
@@ -241,7 +241,7 @@ int v4l2_set_stream(int video_fd, unsigned int type, bool enable)
rc = ioctl(video_fd, enable ? VIDIOC_STREAMON : VIDIOC_STREAMOFF, &buf_type);
if (rc < 0) {
sunxi_cedrus_msg("Unable to %sable stream: %s\n", enable ? "en" : "dis", strerror(errno));
sunxi_cedrus_log("Unable to %sable stream: %s\n", enable ? "en" : "dis", strerror(errno));
return -1;
}