From c193c161a59e7e890074e2f4934ee133f77af5e4 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Tue, 3 Sep 2024 19:13:32 +0200 Subject: media: cedrus: Add support for the NV16 pixel format Signed-off-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus_hw.c | 20 ++++++++++++++++++++ drivers/staging/media/sunxi/cedrus/cedrus_video.c | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c index efb6a5f70fd2..17e91bb5c26a 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c @@ -106,6 +106,26 @@ void cedrus_dst_format_set(struct cedrus_dev *dev, cedrus_write(dev, VE_PRIMARY_FB_LINE_STRIDE, reg); cedrus_write(dev, VE_SECONDARY_FB_LINE_STRIDE, reg); + break; + case V4L2_PIX_FMT_NV16: + chroma_size = ALIGN(width, 16) * ALIGN(height, 16); + + reg = VE_PRIMARY_OUT_FMT_NV12 | VE_SECONDARY_OUT_FMT_EXT_NV12; + cedrus_write(dev, VE_PRIMARY_OUT_FMT, reg); + + reg = chroma_size / 2; + cedrus_write(dev, VE_PRIMARY_CHROMA_BUF_LEN, reg); + + reg = VE_CHROMA_BUF_LEN_SDRT(chroma_size / 2) | + VE_CHROMA_WIDTH_ALIGN_8 | + VE_SECONDARY_OUT_FMT_EXT; + cedrus_write(dev, VE_CHROMA_BUF_LEN, reg); + + reg = VE_FB_LINE_STRIDE_LUMA(ALIGN(width, 16)) | + VE_FB_LINE_STRIDE_CHROMA(ALIGN(width, 16) / 2); + cedrus_write(dev, VE_PRIMARY_FB_LINE_STRIDE, reg); + cedrus_write(dev, VE_SECONDARY_FB_LINE_STRIDE, reg); + break; case V4L2_PIX_FMT_NV12_32L32: case V4L2_PIX_FMT_NV16_32L32: diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 0fbd12bc71c7..9e51afd6c4b7 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -65,6 +65,11 @@ static struct cedrus_format cedrus_formats[] = { .directions = CEDRUS_DECODE_DST, .capabilities = CEDRUS_CAPABILITY_UNTILED, }, + { + .pixelformat = V4L2_PIX_FMT_NV16, + .directions = CEDRUS_DECODE_DST, + .capabilities = CEDRUS_CAPABILITY_UNTILED, + }, { .pixelformat = V4L2_PIX_FMT_NV12_32L32, .directions = CEDRUS_DECODE_DST, @@ -177,6 +182,21 @@ void cedrus_prepare_format(struct v4l2_pix_format *pix_fmt) /* Chroma plane size. */ sizeimage += bytesperline * height / 2; + break; + + case V4L2_PIX_FMT_NV16: + /* 16-aligned stride. */ + bytesperline = ALIGN(width, 16); + + /* 16-aligned height. */ + height = ALIGN(height, 16); + + /* Luma plane size. */ + sizeimage = bytesperline * height; + + /* Chroma plane size. */ + sizeimage += bytesperline * height; + break; } -- cgit v1.2.3