video: driver: add nv12 format support

add nv12 format support

Change-Id: I6a9f2eb814504e35797fb91053417f16cfdf8b25
Signed-off-by: Darshana Patil <darshana@codeaurora.org>
This commit is contained in:
Darshana Patil
2021-01-12 12:23:57 -08:00
szülő 3415b0e23e
commit 60b7435a4c
6 fájl változott, egészen pontosan 246 új sor hozzáadva és 30 régi sor törölve

Fájl megtekintése

@@ -155,8 +155,8 @@ typedef HFI_U32 HFI_BOOL;
* frame dimensions NV12_UBWC format (including interlace UBWC)
* (calculation includes all data & metadata planes)
*/
#define HFI_NV12_UBWC_IL_CALC_BUF_SIZE_V2 \
(buf_size, frame_width, frame_height, y_stride_multiple,\
#define HFI_NV12_UBWC_IL_CALC_BUF_SIZE_V2(buf_size,\
frame_width, frame_height, y_stride_multiple,\
y_buffer_height_multiple, uv_stride_multiple, \
uv_buffer_height_multiple, y_metadata_stride_multiple, \
y_metadata_buffer_height_multiple, \
@@ -164,35 +164,35 @@ typedef HFI_U32 HFI_BOOL;
do \
{ \
HFI_U32 y_buf_size, uv_buf_size, y_meta_size, uv_meta_size; \
HFI_U32 stride, height; \
HFI_U32 halfHeight = (frame_height + 1) >> 1; \
HFI_U32 stride, _height; \
HFI_U32 half_height = (frame_height + 1) >> 1; \
HFI_NV12_IL_CALC_Y_STRIDE(stride, frame_width,\
y_stride_multiple); \
HFI_NV12_IL_CALC_Y_BUFHEIGHT(height, half_height,\
HFI_NV12_IL_CALC_Y_BUFHEIGHT(_height, half_height,\
y_buffer_height_multiple); \
HFI_NV12_UBWC_IL_CALC_Y_BUF_SIZE(y_buf_size, stride, height);\
HFI_NV12_UBWC_IL_CALC_Y_BUF_SIZE(y_buf_size, stride, _height);\
HFI_NV12_IL_CALC_UV_STRIDE(stride, frame_width, \
uv_stride_multiple); \
HFI_NV12_IL_CALC_UV_BUFHEIGHT(height, half_height, \
HFI_NV12_IL_CALC_UV_BUFHEIGHT(_height, half_height, \
uv_buffer_height_multiple); \
HFI_NV12_UBWC_IL_CALC_UV_BUF_SIZE(uv_buf_size, stride, height);\
HFI_NV12_UBWC_IL_CALC_UV_BUF_SIZE(uv_buf_size, stride, _height);\
HFI_UBWC_CALC_METADATA_PLANE_STRIDE(stride, frame_width,\
y_metadata_stride_multiple, \
HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_WIDTH);\
HFI_UBWC_METADATA_PLANE_BUFHEIGHT(height, half_height, \
HFI_UBWC_METADATA_PLANE_BUFHEIGHT(_height, half_height, \
y_metadata_buffer_height_multiple,\
HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_HEIGHT);\
HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(y_meta_size, stride, \
height); \
_height); \
HFI_UBWC_UV_METADATA_PLANE_STRIDE(stride, frame_width,\
uv_metadata_stride_multiple, \
HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_WIDTH); \
HFI_UBWC_UV_METADATA_PLANE_BUFHEIGHT(height, half_height,\
HFI_UBWC_UV_METADATA_PLANE_BUFHEIGHT(_height, half_height,\
uv_metadata_buffer_height_multiple,\
HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_HEIGHT);\
HFI_UBWC_METADATA_PLANE_BUFFER_SIZE(uv_meta_size, stride, \
height); \
bufSize = (y_buf_size + uv_buf_size + y_meta_size + \
_height); \
buf_size = (y_buf_size + uv_buf_size + y_meta_size + \
uv_meta_size) << 1;\
} while (0)

Fájl megtekintése

@@ -12,6 +12,7 @@
#include "msm_vidc_platform.h"
#include "msm_vidc_driver.h"
#include "msm_vidc_debug.h"
#include "msm_media_info.h"
static u32 msm_vidc_decoder_bin_size_iris2(struct msm_vidc_inst *inst)
{
@@ -189,6 +190,51 @@ static u32 msm_vidc_decoder_persist_size_iris2(struct msm_vidc_inst *inst)
return size;
}
static u32 msm_vidc_decoder_dpb_size_iris2(struct msm_vidc_inst *inst)
{
u32 size = 0;
u32 color_fmt, media_fmt;
u32 width, height;
struct v4l2_format *f;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return size;
}
color_fmt = inst->capabilities->cap[PIX_FMTS].value;
if (!is_linear_colorformat(color_fmt))
return size;
f = &inst->fmts[OUTPUT_PORT];
width = f->fmt.pix_mp.width;
height = f->fmt.pix_mp.height;
if (color_fmt == MSM_VIDC_FMT_NV12) {
media_fmt = COLOR_FMT_NV12_UBWC;
HFI_NV12_UBWC_IL_CALC_BUF_SIZE_V2(size, width, height,
VENUS_Y_STRIDE(media_fmt, width), VENUS_Y_SCANLINES(media_fmt, height),
VENUS_UV_STRIDE(media_fmt, width), VENUS_UV_SCANLINES(media_fmt, height),
VENUS_Y_META_STRIDE(media_fmt, width), VENUS_Y_META_SCANLINES(media_fmt,
height),
VENUS_UV_META_STRIDE(media_fmt, width), VENUS_UV_META_SCANLINES(media_fmt,
height));
} else if (color_fmt == MSM_VIDC_FMT_P010) {
media_fmt = COLOR_FMT_P010_UBWC;
HFI_YUV420_TP10_UBWC_CALC_BUF_SIZE(size,
VENUS_Y_STRIDE(media_fmt, width), VENUS_Y_SCANLINES(media_fmt, height),
VENUS_UV_STRIDE(media_fmt, width), VENUS_UV_SCANLINES(media_fmt, height),
VENUS_Y_META_STRIDE(media_fmt, width), VENUS_Y_META_SCANLINES(media_fmt,
height),
VENUS_UV_META_STRIDE(media_fmt, width), VENUS_UV_META_SCANLINES(media_fmt,
height));
}
s_vpr_l(inst->sid, "%s: size %d\n", __func__, size);
return size;
}
/* encoder internal buffers */
static u32 msm_vidc_encoder_bin_size_iris2(struct msm_vidc_inst *inst)
{
@@ -436,6 +482,9 @@ int msm_buffer_size_iris2(struct msm_vidc_inst *inst,
case MSM_VIDC_BUF_PERSIST:
size = msm_vidc_decoder_persist_size_iris2(inst);
break;
case MSM_VIDC_BUF_DPB:
size = msm_vidc_decoder_dpb_size_iris2(inst);
break;
default:
break;
}
@@ -482,6 +531,44 @@ int msm_buffer_size_iris2(struct msm_vidc_inst *inst,
return size;
}
static int msm_buffer_encoder_dpb_count(struct msm_vidc_inst *inst)
{
int count = 0;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return 0;
}
if (inst->codec == MSM_VIDC_H264) {
// TODO: replace zeros with appropriate variables
HFI_IRIS2_ENC_RECON_BUF_COUNT(count, 0, 0, 0, 0, 0,
HFI_CODEC_ENCODE_AVC);
} else if (inst->codec == MSM_VIDC_HEVC) {
// TODO: replace zeros with appropriate variables
HFI_IRIS2_ENC_RECON_BUF_COUNT(count, 0, 0, 0, 0, 0,
HFI_CODEC_ENCODE_HEVC);
}
return count;
}
static int msm_buffer_decoder_dpb_count(struct msm_vidc_inst *inst)
{
int count = 0;
u32 color_fmt;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return 0;
}
color_fmt = inst->capabilities->cap[PIX_FMTS].value;
if (is_linear_colorformat(color_fmt))
count = inst->buffers.output.min_count;
return count;
}
int msm_buffer_min_count_iris2(struct msm_vidc_inst *inst,
enum msm_vidc_buffer_type buffer_type)
{
@@ -489,7 +576,7 @@ int msm_buffer_min_count_iris2(struct msm_vidc_inst *inst,
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
return 0;
}
if (is_decode_session(inst)) {
@@ -509,7 +596,9 @@ int msm_buffer_min_count_iris2(struct msm_vidc_inst *inst,
case MSM_VIDC_BUF_PERSIST:
count = 1;
break;
//todo: add DPB
case MSM_VIDC_BUF_DPB:
count = msm_buffer_decoder_dpb_count(inst);
break;
default:
break;
}
@@ -527,12 +616,12 @@ int msm_buffer_min_count_iris2(struct msm_vidc_inst *inst,
case MSM_VIDC_BUF_COMV:
case MSM_VIDC_BUF_NON_COMV:
case MSM_VIDC_BUF_LINE:
case MSM_VIDC_BUF_DPB:
//todo: add DPB count
case MSM_VIDC_BUF_ARP:
case MSM_VIDC_BUF_VPSS:
count = 1;
break;
case MSM_VIDC_BUF_DPB:
count = msm_buffer_encoder_dpb_count(inst);
default:
break;
}
@@ -548,7 +637,7 @@ int msm_buffer_extra_count_iris2(struct msm_vidc_inst *inst,
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
return 0;
}
switch (buffer_type) {