10114f6781
Fourier's local patch already wired multiplanar plumbing through
src/v4l2.c (helpers v4l2_type_video_{output,capture}() at lines 59-69,
struct v4l2_plane planes[] threading in QUERYBUF/QBUF/DQBUF, per-plane
EXPBUF loop at line 411) and through src/context.c, src/buffer.c,
src/picture.c via the v4l2_type_video_{output,capture}(video_format
->v4l2_mplane) helper calls.
The remaining gap: the NV12 entry in src/video.c was hardcoded to
v4l2_mplane=false, and the bootstrap path in src/surface.c was
hardcoded to singleplanar literals before video_format is populated.
This patch flips the NV12 entry to v4l2_mplane=true and updates the
two singleplanar literals in src/surface.c to their MPLANE variants:
- src/video.c:42 v4l2_mplane=false -> true (NV12 only;
Sunxi-tiled NV12 left at false for cedrus compatibility)
- src/surface.c:84 output_type = v4l2_type_video_output(true)
- src/surface.c:109 v4l2_find_format(..., CAPTURE_MPLANE, NV12)
Empirically, hantro-vpu (RK3568 mainline) advertises NV12 only under
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; querying the singleplanar type
returns no match (verified via VIDIOC_ENUM_FMT in Phase 3 GStreamer
strace baseline).
Trade-off accepted: legacy sunxi-cedrus singleplanar NV12 paths are
left unchanged via the SUNXI_TILED_NV12 entry (still mplane=false,
__arm__ only). Pure-NV12 cedrus on aarch64 would regress, but the
known userbase here is RK3566/RK3568 hantro.
Signed-off-by: Markus Fritsche <fritsche.markus@gmail.com>
83 lines
2.4 KiB
C
83 lines
2.4 KiB
C
/*
|
|
* 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 <errno.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <drm_fourcc.h>
|
|
#include <linux/videodev2.h>
|
|
|
|
#include "utils.h"
|
|
#include "video.h"
|
|
|
|
static struct video_format formats[] = {
|
|
{
|
|
.description = "NV12 YUV",
|
|
.v4l2_format = V4L2_PIX_FMT_NV12,
|
|
.v4l2_buffers_count = 1,
|
|
.v4l2_mplane = true,
|
|
.drm_format = DRM_FORMAT_NV12,
|
|
.drm_modifier = DRM_FORMAT_MOD_NONE,
|
|
.planes_count = 2,
|
|
.bpp = 16,
|
|
},
|
|
// Code to handle this DRM_FORMAT is __arm__ only
|
|
#ifdef __arm__
|
|
{
|
|
.description = "Sunxi tiled NV12 YUV",
|
|
.v4l2_format = V4L2_PIX_FMT_SUNXI_TILED_NV12,
|
|
.v4l2_buffers_count = 1,
|
|
.v4l2_mplane = false,
|
|
.drm_format = DRM_FORMAT_NV12,
|
|
.drm_modifier = DRM_FORMAT_MOD_ALLWINNER_TILED,
|
|
.planes_count = 2,
|
|
.bpp = 16
|
|
},
|
|
#endif
|
|
};
|
|
|
|
static unsigned int formats_count = sizeof(formats) / sizeof(formats[0]);
|
|
|
|
struct video_format *video_format_find(unsigned int pixelformat)
|
|
{
|
|
unsigned int i;
|
|
|
|
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;
|
|
}
|