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