Register video format directly instead of tiled indicator

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
This commit is contained in:
Paul Kocialkowski
2018-09-07 12:46:52 +02:00
parent 8857fc7019
commit 25a8ac4d7e
6 changed files with 28 additions and 21 deletions
+2 -2
View File
@@ -27,6 +27,7 @@
#include "context.h"
#include "request.h"
#include "surface.h"
#include "video.h"
#include <unistd.h>
#include <fcntl.h>
@@ -37,7 +38,6 @@
#include <sys/mman.h>
#include <va/va_drmcommon.h>
#include <linux/videodev2.h>
#include "utils.h"
@@ -201,7 +201,7 @@ VAStatus RequestAcquireBufferHandle(VADriverContextP context,
int rc;
if (buffer_info->mem_type != VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME ||
driver_data->tiled_format)
!video_format_is_linear(driver_data->video_format))
return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE;
buffer_object = BUFFER(driver_data, buffer_id);
+2 -1
View File
@@ -27,6 +27,7 @@
#include "buffer.h"
#include "request.h"
#include "surface.h"
#include "video.h"
#include <assert.h>
#include <string.h>
@@ -148,7 +149,7 @@ VAStatus RequestDeriveImage(VADriverContextP context, VASurfaceID surface_id,
return VA_STATUS_ERROR_INVALID_BUFFER;
for (i = 0; i < surface_object->destination_planes_count; i++) {
if (driver_data->tiled_format)
if (!video_format_is_linear(driver_data->video_format))
tiled_to_planar(surface_object->destination_data[i],
buffer_object->data + image->offsets[i],
image->pitches[i], image->width,
+1 -1
View File
@@ -52,7 +52,7 @@ struct request_data {
int video_fd;
int media_fd;
bool tiled_format;
struct video_format *video_format;
};
VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context);
+12 -7
View File
@@ -37,7 +37,7 @@
#include <sys/mman.h>
#include <va/va_drmcommon.h>
#include <drm_fourcc.h>
#include <linux/videodev2.h>
#include "media.h"
@@ -54,7 +54,7 @@ VAStatus RequestCreateSurfaces2(VADriverContextP context, unsigned int format,
{
struct request_data *driver_data = context->pDriverData;
struct object_surface *surface_object;
struct video_format *video_format;
struct video_format *video_format = NULL;
unsigned int destination_sizes[VIDEO_MAX_PLANES];
unsigned int destination_bytesperlines[VIDEO_MAX_PLANES];
unsigned int destination_planes_count;
@@ -68,18 +68,23 @@ VAStatus RequestCreateSurfaces2(VADriverContextP context, unsigned int format,
if (format != VA_RT_FORMAT_YUV420)
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
driver_data->tiled_format = true;
found = v4l2_find_format(driver_data->video_fd,
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
V4L2_PIX_FMT_SUNXI_TILED_NV12);
if (found)
video_format = video_format_find(V4L2_PIX_FMT_SUNXI_TILED_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;
video_format = video_format_find(V4L2_PIX_FMT_NV12);
video_format = video_format_find(driver_data->tiled_format);
if (video_format == NULL)
return VA_STATUS_ERROR_OPERATION_FAILED;
driver_data->video_format = video_format;
rc = v4l2_set_format(driver_data->video_fd,
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
video_format->v4l2_format, width, height);
@@ -356,7 +361,7 @@ VAStatus RequestQuerySurfaceAttributes(VADriverContextP context,
* that are required for supporting the tiled output format.
*/
if (!driver_data->tiled_format)
if (video_format_is_linear(driver_data->video_format))
memory_types |= VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME;
attributes_list[i].value.value.i = memory_types;
@@ -454,7 +459,7 @@ VAStatus RequestExportSurfaceHandle(VADriverContextP context,
planes_count = surface_object->destination_planes_count;
video_format = video_format_find(driver_data->tiled_format);
video_format = driver_data->video_format;
if (video_format == NULL) {
status = VA_STATUS_ERROR_OPERATION_FAILED;
goto error;
+9 -9
View File
@@ -34,11 +34,6 @@
#include "utils.h"
#include "video.h"
static inline unsigned int video_v4l2_format(bool tiled_format)
{
return tiled_format ? V4L2_PIX_FMT_SUNXI_TILED_NV12 : V4L2_PIX_FMT_NV12;
}
static struct video_format formats[] = {
{
.description = "NV12 YUV",
@@ -62,16 +57,21 @@ static struct video_format formats[] = {
static unsigned int formats_count = sizeof(formats) / sizeof(formats[0]);
struct video_format *video_format_find(bool tiled_format)
struct video_format *video_format_find(unsigned int pixelformat)
{
unsigned int pixelformat;
unsigned int i;
pixelformat = video_v4l2_format(tiled_format);
for (i = 0; i < formats_count; i++)
if (formats[i].v4l2_format == pixelformat)
return &formats[i];
return NULL;
}
bool video_format_is_linear(struct video_format *format)
{
if (format == NULL)
return true;
return format->drm_modifier == DRM_FORMAT_MOD_NONE;
}
+2 -1
View File
@@ -37,6 +37,7 @@ struct video_format {
unsigned int bpp;
};
struct video_format *video_format_find(bool tiled_format);
struct video_format *video_format_find(unsigned int pixelformat);
bool video_format_is_linear(struct video_format *format);
#endif