diff --git a/msm/vidc/msm_venc.c b/msm/vidc/msm_venc.c index 1688cbd897fa..6b3e29f16859 100644 --- a/msm/vidc/msm_venc.c +++ b/msm/vidc/msm_venc.c @@ -1249,6 +1249,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"); @@ -1327,6 +1336,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);