Commit e3c97a05 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2: recognize MM21 format

MM21 is a proprietary pixel format used on Kukui devices. This CL adds
the hooks necessary for the V4L2 decoder and IP to use it.

Bug: b:123551776
Test: VDA unittest passing on Kukui

Change-Id: I3da9f7b316d31feb5c1a8b99dfc7bf4cf8adf71e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1743298
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685492}
parent 509b249d
......@@ -1015,6 +1015,10 @@ VideoPixelFormat V4L2Device::V4L2PixFmtToVideoPixelFormat(uint32_t pix_fmt) {
// we map V4L2_PIX_FMT_MT21C to PIXEL_FORMAT_NV12 as their layout are the
// same.
case V4L2_PIX_FMT_MT21C:
// V4L2_PIX_FMT_MM21 is used for MT8183 hardware video decoder. It is
// similar to V4L2_PIX_FMT_MT21C but is not compressed ; thus it can also
// be mapped to PIXEL_FORMAT_NV12.
case V4L2_PIX_FMT_MM21:
return PIXEL_FORMAT_NV12;
case V4L2_PIX_FMT_YUV420:
......@@ -1519,8 +1523,8 @@ base::Optional<VideoFrameLayout> V4L2Device::V4L2FormatToVideoFrameLayout(
// static
bool V4L2Device::IsMultiPlanarV4L2PixFmt(uint32_t pix_fmt) {
constexpr uint32_t kMultiV4L2PixFmts[] = {
V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_MT21C, V4L2_PIX_FMT_YUV420M,
V4L2_PIX_FMT_YVU420M, V4L2_PIX_FMT_YUV422M,
V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_MT21C, V4L2_PIX_FMT_MM21,
V4L2_PIX_FMT_YUV420M, V4L2_PIX_FMT_YVU420M, V4L2_PIX_FMT_YUV422M,
};
return std::find(std::cbegin(kMultiV4L2PixFmts), std::cend(kMultiV4L2PixFmts),
pix_fmt) != std::cend(kMultiV4L2PixFmts);
......
......@@ -41,6 +41,12 @@
#define V4L2_CID_JPEG_CHROMA_QUANTIZATION (V4L2_CID_JPEG_CLASS_BASE + 6)
#endif
// TODO(b/132589320): remove this once V4L2 header is updated.
#ifndef V4L2_PIX_FMT_MM21
// MTK 8-bit block mode, two non-contiguous planes.
#define V4L2_PIX_FMT_MM21 v4l2_fourcc('M', 'M', '2', '1')
#endif
namespace media {
class V4L2Queue;
......
......@@ -19,23 +19,28 @@ base::Optional<VideoFrameLayout> CreateLayout(uint32_t fourcc,
// format and now is only used for MT8173 VDA output and its image processor
// input, we set VideoFrameLayout for image processor's input with format
// PIXEL_FORMAT_NV12 as NV12's layout is the same as MT21.
if (fourcc == V4L2_PIX_FMT_MT21C) {
size_t num_planes = 2;
return VideoFrameLayout::CreateMultiPlanar(
PIXEL_FORMAT_NV12, size,
std::vector<VideoFrameLayout::Plane>(num_planes));
} else {
VideoPixelFormat pixel_format =
V4L2Device::V4L2PixFmtToVideoPixelFormat(fourcc);
if (pixel_format == PIXEL_FORMAT_UNKNOWN)
return base::nullopt;
size_t num_planes = VideoFrame::NumPlanes(pixel_format);
if (num_planes == 1) {
return VideoFrameLayout::Create(pixel_format, size);
} else {
size_t num_planes;
switch (fourcc) {
case V4L2_PIX_FMT_MT21C:
case V4L2_PIX_FMT_MM21:
num_planes = 2;
return VideoFrameLayout::CreateMultiPlanar(
pixel_format, size, std::vector<VideoFrameLayout::Plane>(num_planes));
}
PIXEL_FORMAT_NV12, size,
std::vector<VideoFrameLayout::Plane>(num_planes));
default:
VideoPixelFormat pixel_format =
V4L2Device::V4L2PixFmtToVideoPixelFormat(fourcc);
if (pixel_format == PIXEL_FORMAT_UNKNOWN)
return base::nullopt;
num_planes = VideoFrame::NumPlanes(pixel_format);
if (num_planes == 1)
return VideoFrameLayout::Create(pixel_format, size);
else
return VideoFrameLayout::CreateMultiPlanar(
pixel_format, size,
std::vector<VideoFrameLayout::Plane>(num_planes));
break;
}
}
} // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment