video: driver: handle private codecs defines

Move the usage of v4l2 macros in helper functions to
avoid compilation issues on upstream kernel with private
codec defines.
Use vidc macros defines in code instead of v4l2 defines
wherever applicable.

Change-Id: I43d7deb4f84c502689ceaec3273803444f30f379
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
This commit is contained in:
Dikshita Agarwal
2022-07-20 13:07:24 +05:30
parent c5c78e3ba2
commit 88dc4a0593
3 changed files with 16 additions and 11 deletions

View File

@@ -557,6 +557,7 @@ static u32 msm_vidc_encoder_output_size_iris3(struct msm_vidc_inst *inst)
bool is_ten_bit = false; bool is_ten_bit = false;
int bitrate_mode, frame_rc; int bitrate_mode, frame_rc;
u32 hfi_rc_type = HFI_RC_VBR_CFR; u32 hfi_rc_type = HFI_RC_VBR_CFR;
enum msm_vidc_codec_type codec;
if (!inst || !inst->capabilities) { if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
@@ -564,8 +565,8 @@ static u32 msm_vidc_encoder_output_size_iris3(struct msm_vidc_inst *inst)
} }
f = &inst->fmts[OUTPUT_PORT]; f = &inst->fmts[OUTPUT_PORT];
if (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEVC || codec = v4l2_codec_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEIC) if (codec == MSM_VIDC_HEVC || codec == MSM_VIDC_HEIC)
is_ten_bit = true; is_ten_bit = true;
bitrate_mode = inst->capabilities->cap[BITRATE_MODE].value; bitrate_mode = inst->capabilities->cap[BITRATE_MODE].value;

View File

@@ -1082,6 +1082,7 @@ int msm_venc_s_fmt_output(struct msm_vidc_inst *inst, struct v4l2_format *f)
struct msm_vidc_core *core; struct msm_vidc_core *core;
u32 codec_align; u32 codec_align;
u32 width, height; u32 width, height;
enum msm_vidc_codec_type codec;
if (!inst || !inst->core || !f) { if (!inst || !inst->core || !f) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
@@ -1098,8 +1099,10 @@ int msm_venc_s_fmt_output(struct msm_vidc_inst *inst, struct v4l2_format *f)
} }
fmt->type = OUTPUT_MPLANE; fmt->type = OUTPUT_MPLANE;
codec_align = (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEVC || codec = v4l2_codec_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEIC) ? 32 : 16;
codec_align = (codec == MSM_VIDC_HEVC ||
codec == MSM_VIDC_HEIC) ? 32 : 16;
/* use rotated width height if rotation is enabled */ /* use rotated width height if rotation is enabled */
width = inst->compose.width; width = inst->compose.width;
height = inst->compose.height; height = inst->compose.height;

View File

@@ -210,6 +210,7 @@ u32 msm_vidc_decoder_input_size(struct msm_vidc_inst *inst)
u32 base_res_mbs = NUM_MBS_4k; u32 base_res_mbs = NUM_MBS_4k;
struct v4l2_format *f; struct v4l2_format *f;
u32 bitstream_size_overwrite = 0; u32 bitstream_size_overwrite = 0;
enum msm_vidc_codec_type codec;
if (!inst || !inst->capabilities) { if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
@@ -233,13 +234,14 @@ u32 msm_vidc_decoder_input_size(struct msm_vidc_inst *inst)
* 4k mbs for VP8/VP9 and 4k / 2 for remaining codecs. * 4k mbs for VP8/VP9 and 4k / 2 for remaining codecs.
*/ */
f = &inst->fmts[INPUT_PORT]; f = &inst->fmts[INPUT_PORT];
codec = v4l2_codec_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
num_mbs = msm_vidc_get_mbs_per_frame(inst); num_mbs = msm_vidc_get_mbs_per_frame(inst);
if (num_mbs > NUM_MBS_4k) { if (num_mbs > NUM_MBS_4k) {
div_factor = 4; div_factor = 4;
base_res_mbs = inst->capabilities->cap[MBPF].value; base_res_mbs = inst->capabilities->cap[MBPF].value;
} else { } else {
base_res_mbs = NUM_MBS_4k; base_res_mbs = NUM_MBS_4k;
if (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_VP9) if (codec == MSM_VIDC_VP9)
div_factor = 1; div_factor = 1;
else else
div_factor = 2; div_factor = 2;
@@ -257,10 +259,8 @@ u32 msm_vidc_decoder_input_size(struct msm_vidc_inst *inst)
frame_size = base_res_mbs * MB_SIZE_IN_PIXEL * 3 / 2 / div_factor; frame_size = base_res_mbs * MB_SIZE_IN_PIXEL * 3 / 2 / div_factor;
/* multiply by 10/8 (1.25) to get size for 10 bit case */ /* multiply by 10/8 (1.25) to get size for 10 bit case */
if (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_VP9 || if (codec == MSM_VIDC_VP9 || codec == MSM_VIDC_AV1 ||
f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_AV1 || codec == MSM_VIDC_HEVC || codec == MSM_VIDC_HEIC)
f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEVC ||
f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEIC)
frame_size = frame_size + (frame_size >> 2); frame_size = frame_size + (frame_size >> 2);
i_vpr_h(inst, "set input buffer size to %d\n", frame_size); i_vpr_h(inst, "set input buffer size to %d\n", frame_size);
@@ -363,6 +363,7 @@ u32 msm_vidc_encoder_output_size(struct msm_vidc_inst *inst)
u32 mbs_per_frame; u32 mbs_per_frame;
u32 width, height; u32 width, height;
struct v4l2_format *f; struct v4l2_format *f;
enum msm_vidc_codec_type codec;
if (!inst || !inst->capabilities) { if (!inst || !inst->capabilities) {
d_vpr_e("%s: invalid params\n", __func__); d_vpr_e("%s: invalid params\n", __func__);
@@ -370,6 +371,7 @@ u32 msm_vidc_encoder_output_size(struct msm_vidc_inst *inst)
} }
f = &inst->fmts[OUTPUT_PORT]; f = &inst->fmts[OUTPUT_PORT];
codec = v4l2_codec_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
/* /*
* Encoder output size calculation: 32 Align width/height * Encoder output size calculation: 32 Align width/height
* For heic session : YUVsize * 2 * For heic session : YUVsize * 2
@@ -405,8 +407,7 @@ u32 msm_vidc_encoder_output_size(struct msm_vidc_inst *inst)
skip_calc: skip_calc:
/* multiply by 10/8 (1.25) to get size for 10 bit case */ /* multiply by 10/8 (1.25) to get size for 10 bit case */
if (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEVC || if (codec == MSM_VIDC_HEVC || codec == MSM_VIDC_HEIC)
f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEIC)
frame_size = frame_size + (frame_size >> 2); frame_size = frame_size + (frame_size >> 2);
frame_size = ALIGN(frame_size, SZ_4K); frame_size = ALIGN(frame_size, SZ_4K);