From 1f3b5821fe8929d93ef6098b0a57b5be60f04ac7 Mon Sep 17 00:00:00 2001 From: Akshata Sahukar Date: Mon, 10 Jun 2019 14:15:28 -0700 Subject: [PATCH] msm: vidc: Provide default profile type in s_fmt Set default profile type to avoid error when client has not set any profile type. Change-Id: I89b81f5167f65685e47073b5e73d3bd7c4fe81d6 Signed-off-by: Akshata Sahukar --- msm/vidc/msm_venc.c | 29 +++++++++++++++++++++++++++++ msm/vidc/msm_venc.h | 1 + 2 files changed, 30 insertions(+) diff --git a/msm/vidc/msm_venc.c b/msm/vidc/msm_venc.c index c4f7db5b5add..49d03ffcf0f5 100644 --- a/msm/vidc/msm_venc.c +++ b/msm/vidc/msm_venc.c @@ -1248,6 +1248,15 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) mplane->width = f->fmt.pix_mp.width; mplane->height = f->fmt.pix_mp.height; mplane->pixelformat = f->fmt.pix_mp.pixelformat; + + if (!inst->profile) { + rc = msm_venc_set_default_profile(inst); + if (rc) { + dprintk(VIDC_ERR, "%s: Failed to set default profile type\n", __func__); + goto exit; + } + } + rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE); if (rc) { dprintk(VIDC_ERR, "Failed to open instance\n"); @@ -1326,6 +1335,26 @@ exit: return rc; } +int msm_venc_set_default_profile(struct msm_vidc_inst *inst) +{ + if (!inst) { + dprintk(VIDC_ERR, + "%s: invalid params\n", __func__); + return -EINVAL; + } + + if (get_v4l2_codec(inst) == V4L2_PIX_FMT_HEVC) + inst->profile = HFI_HEVC_PROFILE_MAIN; + else if (get_v4l2_codec(inst) == V4L2_PIX_FMT_VP8) + inst->profile = HFI_VP8_PROFILE_MAIN; + else if (get_v4l2_codec(inst) == V4L2_PIX_FMT_H264) + inst->profile = HFI_H264_PROFILE_HIGH; + else + dprintk(VIDC_ERR, + "%s: Invalid codec type %#x\n", __func__, get_v4l2_codec(inst)); + return 0; +} + int msm_venc_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) { struct v4l2_format *fmt; diff --git a/msm/vidc/msm_venc.h b/msm/vidc/msm_venc.h index f8c0b0a666a6..dd17266814f6 100644 --- a/msm/vidc/msm_venc.h +++ b/msm/vidc/msm_venc.h @@ -18,6 +18,7 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f); int msm_venc_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f); +int msm_venc_set_default_profile(struct msm_vidc_inst *inst); int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl); int msm_venc_set_properties(struct msm_vidc_inst *inst);