Loading drivers/media/platform/msm/vidc/msm_vdec.c +79 −79 Original line number Diff line number Diff line Loading @@ -514,6 +514,36 @@ static bool msm_vidc_check_for_vp9d_overload(struct msm_vidc_core *core) return false; } int msm_vdec_update_stream_output_mode(struct msm_vidc_inst *inst) { u32 format; u32 stream_output_mode; u32 fourcc; if (!inst) { dprintk(VIDC_ERR, "%s invalid parameters\n", __func__); return -EINVAL; } format = inst->fmts[CAPTURE_PORT].fourcc; stream_output_mode = HAL_VIDEO_DECODER_PRIMARY; if ((format == V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS) || (format == V4L2_PIX_FMT_NV12)) { stream_output_mode = HAL_VIDEO_DECODER_SECONDARY; } msm_comm_set_stream_output_mode(inst, stream_output_mode); fourcc = V4L2_PIX_FMT_NV12_UBWC; if (inst->bit_depth == MSM_VIDC_BIT_DEPTH_10) fourcc = V4L2_PIX_FMT_NV12_TP10_UBWC; inst->clk_data.dpb_fourcc = fourcc; return 0; } int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) { struct msm_vidc_format *fmt = NULL; Loading Loading @@ -550,6 +580,13 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) memcpy(&inst->fmts[fmt->type], fmt, sizeof(struct msm_vidc_format)); inst->bit_depth = MSM_VIDC_BIT_DEPTH_8; if ((f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_NV12_TP10_UBWC) || (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS)) { inst->bit_depth = MSM_VIDC_BIT_DEPTH_10; } inst->prop.width[CAPTURE_PORT] = f->fmt.pix_mp.width; inst->prop.height[CAPTURE_PORT] = f->fmt.pix_mp.height; rc = msm_vidc_check_session_supported(inst); Loading Loading @@ -577,6 +614,13 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) f->fmt.pix_mp.plane_fmt[i].sizeimage; } rc = msm_vdec_update_stream_output_mode(inst); if (rc) { dprintk(VIDC_ERR, "%s: failed to update output stream mode\n", __func__); goto err_invalid_fmt; } } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats, Loading Loading @@ -695,9 +739,13 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst) inst->buffer_mode_set[OUTPUT_PORT] = HAL_BUFFER_MODE_STATIC; inst->buffer_mode_set[CAPTURE_PORT] = HAL_BUFFER_MODE_DYNAMIC; inst->stream_output_mode = HAL_VIDEO_DECODER_PRIMARY; /* To start with, both ports are 1 plane each */ /* To start with, in port is 1 plane and out is 2 */ inst->bufq[OUTPUT_PORT].num_planes = 1; inst->bufq[CAPTURE_PORT].num_planes = 1; inst->bufq[CAPTURE_PORT].num_planes = 2; inst->bufq[CAPTURE_PORT].plane_sizes[1] = VENUS_EXTRADATA_SIZE( inst->prop.height[CAPTURE_PORT], inst->prop.width[CAPTURE_PORT]); inst->prop.fps = DEFAULT_FPS; inst->clk_data.operating_rate = 0; if (core->resources.decode_batching) Loading Loading @@ -794,8 +842,6 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) bufreq->buffer_count_actual = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) return -EINVAL; Loading @@ -807,28 +853,6 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) bufreq->buffer_count_actual = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT2); if (!bufreq) return -EINVAL; bufreq->buffer_count_min = MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS; bufreq->buffer_count_min_host = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; bufreq->buffer_count_actual = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; } else { bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) return -EINVAL; bufreq->buffer_count_min = MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS; bufreq->buffer_count_min_host = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; bufreq->buffer_count_actual = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; } break; case V4L2_CID_MPEG_VIDC_VIDEO_SECURE: inst->flags &= ~VIDC_SECURE; Loading Loading @@ -1022,7 +1046,8 @@ int msm_vdec_set_output_buffer_counts(struct msm_vidc_inst *inst) hdev = inst->core->device; buffer_type = msm_comm_get_hal_output_buffer(inst); bufreq = get_buff_req_buffer(inst, buffer_type); /* Correct buffer counts is always stored in HAL_BUFFER_OUTPUT */ bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) { dprintk(VIDC_ERR, "%s: failed to set bufreqs(%#x)\n", __func__, buffer_type); Loading Loading @@ -1215,9 +1240,7 @@ int msm_vdec_set_secure_mode(struct msm_vidc_inst *inst) int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) { int rc = 0; int fourcc; struct hfi_device *hdev; u32 output_stream_mode; struct hal_multi_stream multi_stream; struct hal_frame_size frame_sz; Loading @@ -1227,18 +1250,14 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) } hdev = inst->core->device; /* Decide split/combined mode here */ output_stream_mode = V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_PRIMARY; switch (output_stream_mode) { case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_PRIMARY: if (is_primary_output_mode(inst)) { multi_stream.buffer_type = HAL_BUFFER_OUTPUT; multi_stream.enable = true; rc = call_hfi_op(hdev, session_set_property, inst->session, HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream); if (rc) { dprintk(VIDC_ERR, "%s: set prop multistream primary (output) failed\n", "%s: set prop multistream primary failed : %d\n", __func__, rc); return rc; } Loading @@ -1248,25 +1267,13 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream); if (rc) { dprintk(VIDC_ERR, "%s: set prop multistream primary (output2) failed\n", "%s: set prop multistream primary2 failed : %d\n", __func__, rc); return rc; } break; case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_SECONDARY: switch (inst->bit_depth) { case MSM_VIDC_BIT_DEPTH_8: fourcc = V4L2_PIX_FMT_NV12_UBWC; break; case MSM_VIDC_BIT_DEPTH_10: fourcc = V4L2_PIX_FMT_NV12_TP10_UBWC; break; default: dprintk(VIDC_ERR, "%s: invalid bitdepth\n", __func__); return -EINVAL; } } else { rc = msm_comm_set_color_format(inst, HAL_BUFFER_OUTPUT, fourcc); HAL_BUFFER_OUTPUT, inst->clk_data.dpb_fourcc); if (rc) return rc; Loading @@ -1276,7 +1283,7 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream); if (rc) { dprintk(VIDC_ERR, "%s: set prop multistream (output2) failed\n", "%s: set prop multistream secondary failed : %d\n", __func__, rc); return rc; } Loading @@ -1286,7 +1293,7 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream); if (rc) { dprintk(VIDC_ERR, "%s: set prop multistream (output) failed\n", "%s: set prop multistream secondary2 failed : %d\n", __func__, rc); return rc; } Loading @@ -1304,13 +1311,6 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) __func__, rc); return rc; } break; default: dprintk(VIDC_ERR, "%s: unknown multistream type %#x\n", __func__, output_stream_mode); rc = -EINVAL; return rc; } return rc; Loading Loading @@ -1462,7 +1462,7 @@ int msm_vdec_set_extradata(struct msm_vidc_inst *inst) HAL_EXTRADATA_UBWC_CR_STATS_INFO, 0x0); msm_comm_set_extradata(inst, HAL_EXTRADATA_NUM_CONCEALED_MB, 0x0); if (inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_HEVC) { if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_HEVC) { msm_comm_set_extradata(inst, HAL_EXTRADATA_MASTERING_DISPLAY_COLOUR_SEI, 0x0); Loading @@ -1489,7 +1489,7 @@ int msm_vdec_set_extradata(struct msm_vidc_inst *inst) msm_comm_set_extradata(inst, display_info, 0x1); msm_comm_set_extradata(inst, HAL_EXTRADATA_NUM_CONCEALED_MB, 0x1); if (inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_HEVC) { if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_HEVC) { msm_comm_set_extradata(inst, HAL_EXTRADATA_MASTERING_DISPLAY_COLOUR_SEI, 0x1); Loading Loading @@ -1559,10 +1559,10 @@ int msm_vdec_set_properties(struct msm_vidc_inst *inst) rc = msm_vdec_set_color_format(inst); if (rc) goto exit; rc = msm_vdec_set_output_buffer_counts(inst); rc = msm_vdec_set_output_stream_mode(inst); if (rc) goto exit; rc = msm_vdec_set_output_stream_mode(inst); rc = msm_vdec_set_output_buffer_counts(inst); if (rc) goto exit; rc = msm_vdec_set_operating_rate(inst); Loading drivers/media/platform/msm/vidc/msm_vidc.c +17 −23 Original line number Diff line number Diff line Loading @@ -744,7 +744,6 @@ static int msm_vidc_queue_setup(struct vb2_queue *q, int rc = 0; unsigned int i = 0; struct hal_buffer_requirements *bufreq; enum hal_buffer buffer_type; if (!q || !num_buffers || !num_planes || !sizes || !q->drv_priv) { Loading Loading @@ -786,13 +785,12 @@ static int msm_vidc_queue_setup(struct vb2_queue *q, } break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: { buffer_type = msm_comm_get_hal_output_buffer(inst); bufreq = get_buff_req_buffer(inst, buffer_type); HAL_BUFFER_OUTPUT); if (!bufreq) { dprintk(VIDC_ERR, "Failed : No buffer requirements : %x\n", buffer_type); HAL_BUFFER_OUTPUT); return -EINVAL; } if (inst->session_type != MSM_VIDC_DECODER && Loading Loading @@ -845,8 +843,7 @@ static inline int msm_vidc_verify_buffer_counts(struct msm_vidc_inst *inst) for (i = 0; i < HAL_BUFFER_MAX; i++) { struct hal_buffer_requirements *req = &inst->buff_req.buffer[i]; if (req && (msm_comm_get_hal_output_buffer(inst) == req->buffer_type)) { if (req && (req->buffer_type == HAL_BUFFER_OUTPUT)) { dprintk(VIDC_DBG, "Verifying Buffer : %d\n", req->buffer_type); if (req->buffer_count_actual < Loading Loading @@ -1087,6 +1084,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst) goto fail_start; } b.buffer_type = HAL_BUFFER_OUTPUT; if (inst->session_type == MSM_VIDC_ENCODER) { rc = msm_vidc_set_rotation(inst); if (rc) { Loading @@ -1094,7 +1092,9 @@ static inline int start_streaming(struct msm_vidc_inst *inst) "Set rotation for encoder failed %pK\n"); goto fail_start; } } } else if ((inst->session_type == MSM_VIDC_DECODER) && (is_secondary_output_mode(inst))) b.buffer_type = HAL_BUFFER_OUTPUT2; /* HEIC HW/FWK tiling encode is supported only for CQ RC mode */ if (inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) { Loading Loading @@ -1152,13 +1152,6 @@ static inline int start_streaming(struct msm_vidc_inst *inst) goto fail_start; } if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { b.buffer_type = HAL_BUFFER_OUTPUT2; } else { b.buffer_type = HAL_BUFFER_OUTPUT; } rc = msm_comm_try_get_bufreqs(inst); b.buffer_size = inst->bufq[CAPTURE_PORT].plane_sizes[0]; Loading Loading @@ -1196,7 +1189,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst) if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { rc = msm_comm_set_output_buffers(inst); rc = msm_comm_set_dpb_only_buffers(inst); if (rc) { dprintk(VIDC_ERR, "Failed to set output buffers: %d\n", rc); Loading Loading @@ -1239,7 +1232,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst) if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { rc = msm_comm_queue_output_buffers(inst); rc = msm_comm_queue_dpb_only_buffers(inst); if (rc) { dprintk(VIDC_ERR, "Failed to queue output buffers: %d\n", rc); Loading Loading @@ -1688,7 +1681,6 @@ static int try_get_ctrl_for_instance(struct msm_vidc_inst *inst, { int rc = 0; struct hal_buffer_requirements *bufreq = NULL; enum hal_buffer buffer_type; switch (ctrl->id) { Loading Loading @@ -1726,18 +1718,17 @@ static int try_get_ctrl_for_instance(struct msm_vidc_inst *inst, break; case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: buffer_type = msm_comm_get_hal_output_buffer(inst); bufreq = get_buff_req_buffer(inst, buffer_type); bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) { dprintk(VIDC_ERR, "Failed to find bufreqs for buffer type = %d\n", buffer_type); HAL_BUFFER_OUTPUT); return -EINVAL; } ctrl->val = bufreq->buffer_count_min_host; dprintk(VIDC_DBG, "g_min: %x : hal_buffer %d min buffers %d\n", hash32_ptr(inst->session), buffer_type, ctrl->val); hash32_ptr(inst->session), HAL_BUFFER_OUTPUT, ctrl->val); break; case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT: bufreq = get_buff_req_buffer(inst, HAL_BUFFER_INPUT); Loading Loading @@ -1883,6 +1874,8 @@ void *msm_vidc_open(int core_id, int session_type) inst->state = MSM_VIDC_CORE_UNINIT_DONE; inst->core = core; inst->clk_data.core_id = VIDC_CORE_ID_DEFAULT; inst->clk_data.dpb_fourcc = V4L2_PIX_FMT_NV12_UBWC; inst->clk_data.opb_fourcc = V4L2_PIX_FMT_NV12_UBWC; inst->bit_depth = MSM_VIDC_BIT_DEPTH_8; inst->pic_struct = MSM_VIDC_PIC_STRUCT_PROGRESSIVE; inst->colour_space = MSM_VIDC_BT601_6_525; Loading @@ -1891,6 +1884,7 @@ void *msm_vidc_open(int core_id, int session_type) inst->entropy_mode = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC; inst->smem_ops = &msm_vidc_smem_ops; inst->rc_type = RATE_CONTROL_OFF; inst->dpb_extra_binfo = NULL; for (i = SESSION_MSG_INDEX(SESSION_MSG_START); i <= SESSION_MSG_INDEX(SESSION_MSG_END); i++) { Loading Loading @@ -2041,7 +2035,7 @@ static void msm_vidc_cleanup_instance(struct msm_vidc_inst *inst) msm_comm_release_eos_buffers(inst); if (msm_comm_release_output_buffers(inst, true)) if (msm_comm_release_dpb_only_buffers(inst, true)) dprintk(VIDC_ERR, "Failed to release output buffers\n"); Loading drivers/media/platform/msm/vidc/msm_vidc_clocks.c +3 −14 Original line number Diff line number Diff line Loading @@ -1134,7 +1134,7 @@ void msm_clock_data_reset(struct msm_vidc_inst *inst) __func__, HAL_BUFFER_INPUT); } else if (inst->session_type == MSM_VIDC_DECODER) { dcvs->buffer_type = msm_comm_get_hal_output_buffer(inst); dcvs->buffer_type = HAL_BUFFER_OUTPUT; buf_req = get_buff_req_buffer(inst, dcvs->buffer_type); if (buf_req) dcvs->max_threshold = Loading Loading @@ -1179,17 +1179,6 @@ void msm_clock_data_reset(struct msm_vidc_inst *inst) __func__); } static bool is_output_buffer(struct msm_vidc_inst *inst, enum hal_buffer buffer_type) { if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { return buffer_type == HAL_BUFFER_OUTPUT2; } else { return buffer_type == HAL_BUFFER_OUTPUT; } } int msm_vidc_get_extra_buff_count(struct msm_vidc_inst *inst, enum hal_buffer buffer_type) { Loading @@ -1209,7 +1198,7 @@ int msm_vidc_get_extra_buff_count(struct msm_vidc_inst *inst, /* Add DCVS extra buffer count */ if (inst->core->resources.dcvs) { if (is_decode_session(inst) && is_output_buffer(inst, buffer_type)) { buffer_type == HAL_BUFFER_OUTPUT) { count += DCVS_DEC_EXTRA_OUTPUT_BUFFERS; } else if ((is_encode_session(inst) && buffer_type == HAL_BUFFER_INPUT)) { Loading @@ -1221,7 +1210,7 @@ int msm_vidc_get_extra_buff_count(struct msm_vidc_inst *inst, * if platform supports decode batching ensure minimum * batch size count of extra buffers added on output port */ if (is_output_buffer(inst, buffer_type)) { if (buffer_type == HAL_BUFFER_OUTPUT) { if (inst->core->resources.decode_batching && is_decode_session(inst) && count < inst->batch.size) Loading drivers/media/platform/msm/vidc/msm_vidc_common.c +84 −96 Original line number Diff line number Diff line Loading @@ -1592,36 +1592,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data) inst->reconfig_width = event_notify->width; inst->bit_depth = event_notify->bit_depth; if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) { mutex_unlock(&inst->lock); return; } /* No need to add extra buffers to DPBs */ bufreq->buffer_count_min = event_notify->capture_buf_count; bufreq->buffer_count_min_host = bufreq->buffer_count_min; bufreq = NULL; bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT2); if (!bufreq) { mutex_unlock(&inst->lock); return; } extra_buff_count = msm_vidc_get_extra_buff_count(inst, HAL_BUFFER_OUTPUT2); bufreq->buffer_count_min = event_notify->capture_buf_count; bufreq->buffer_count_min_host = bufreq->buffer_count_min + extra_buff_count; } else { bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) { mutex_unlock(&inst->lock); return; Loading @@ -1632,7 +1603,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data) bufreq->buffer_count_min = event_notify->capture_buf_count; bufreq->buffer_count_min_host = bufreq->buffer_count_min + extra_buff_count; } dprintk(VIDC_DBG, "%s: buffer[%d] count: min %d min_host %d\n", __func__, bufreq->buffer_type, bufreq->buffer_count_min, bufreq->buffer_count_min_host); Loading Loading @@ -1840,12 +1811,11 @@ void msm_comm_validate_output_buffers(struct msm_vidc_inst *inst) } } int msm_comm_queue_output_buffers(struct msm_vidc_inst *inst) int msm_comm_queue_dpb_only_buffers(struct msm_vidc_inst *inst) { struct internal_buf *binfo; struct internal_buf *binfo, *extra_info; struct hfi_device *hdev; struct vidc_frame_data frame_data = {0}; struct hal_buffer_requirements *output_buf, *extra_buf; int rc = 0; if (!inst || !inst->core || !inst->core->device) { Loading @@ -1855,43 +1825,30 @@ int msm_comm_queue_output_buffers(struct msm_vidc_inst *inst) hdev = inst->core->device; output_buf = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!output_buf) { dprintk(VIDC_DBG, "This output buffer not required, buffer_type: %x\n", HAL_BUFFER_OUTPUT); return 0; } dprintk(VIDC_DBG, "output: num = %d, size = %d\n", output_buf->buffer_count_actual, output_buf->buffer_size); extra_buf = get_buff_req_buffer(inst, HAL_BUFFER_EXTRADATA_OUTPUT); extra_info = inst->dpb_extra_binfo; mutex_lock(&inst->outputbufs.lock); list_for_each_entry(binfo, &inst->outputbufs.list, list) { if (binfo->buffer_ownership != DRIVER) continue; if (binfo->mark_remove) continue; frame_data.alloc_len = output_buf->buffer_size; frame_data.alloc_len = binfo->smem.size; frame_data.filled_len = 0; frame_data.offset = 0; frame_data.device_addr = binfo->smem.device_addr; frame_data.flags = 0; frame_data.extradata_addr = binfo->smem.device_addr + output_buf->buffer_size; frame_data.extradata_addr = extra_info ? extra_info->smem.device_addr : 0; frame_data.buffer_type = HAL_BUFFER_OUTPUT; frame_data.extradata_size = extra_buf ? extra_buf->buffer_size : 0; frame_data.extradata_size = extra_info ? extra_info->smem.size : 0; rc = call_hfi_op(hdev, session_ftb, (void *) inst->session, &frame_data); binfo->buffer_ownership = FIRMWARE; } mutex_unlock(&inst->outputbufs.lock); return 0; return rc; } static void handle_session_flush(enum hal_command_response cmd, void *data) Loading Loading @@ -1924,7 +1881,7 @@ static void handle_session_flush(enum hal_command_response cmd, void *data) msm_comm_validate_output_buffers(inst); if (!inst->in_reconfig) { rc = msm_comm_queue_output_buffers(inst); rc = msm_comm_queue_dpb_only_buffers(inst); if (rc) { dprintk(VIDC_ERR, "Failed to queue output buffers: %d\n", Loading Loading @@ -3455,12 +3412,28 @@ struct hal_buffer_requirements *get_buff_req_buffer( return NULL; } static int set_output_buffers(struct msm_vidc_inst *inst, static int convert_color_fmt(int v4l2_fmt) { switch (v4l2_fmt) { case V4L2_PIX_FMT_NV12: return COLOR_FMT_NV12; case V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS: return COLOR_FMT_P010; case V4L2_PIX_FMT_NV12_UBWC: return COLOR_FMT_NV12_UBWC; case V4L2_PIX_FMT_NV12_TP10_UBWC: return COLOR_FMT_NV12_BPP10_UBWC; default: return COLOR_FMT_NV12; } } static int set_dpb_only_buffers(struct msm_vidc_inst *inst, enum hal_buffer buffer_type) { int rc = 0; struct internal_buf *binfo = NULL; u32 smem_flags = SMEM_UNCACHED, buffer_size; u32 smem_flags = SMEM_UNCACHED, buffer_size, num_buffers, hfi_fmt; struct hal_buffer_requirements *output_buf, *extradata_buf; unsigned int i; struct hfi_device *hdev; Loading @@ -3477,15 +3450,16 @@ static int set_output_buffers(struct msm_vidc_inst *inst, } /* For DPB buffers, Always use FW count */ output_buf->buffer_count_actual = output_buf->buffer_count_min_host = output_buf->buffer_count_min; num_buffers = output_buf->buffer_count_min; hfi_fmt = convert_color_fmt(inst->clk_data.dpb_fourcc); buffer_size = VENUS_BUFFER_SIZE(hfi_fmt, inst->prop.width[CAPTURE_PORT], inst->prop.height[CAPTURE_PORT]); dprintk(VIDC_DBG, "output: num = %d, size = %d\n", output_buf->buffer_count_actual, output_buf->buffer_size); num_buffers, buffer_size); buffer_size = output_buf->buffer_size; b.buffer_type = buffer_type; b.buffer_size = buffer_size; rc = call_hfi_op(hdev, session_set_property, Loading @@ -3498,7 +3472,21 @@ static int set_output_buffers(struct msm_vidc_inst *inst, "extradata: num = %d, size = %d\n", extradata_buf->buffer_count_actual, extradata_buf->buffer_size); buffer_size += extradata_buf->buffer_size; inst->dpb_extra_binfo = NULL; inst->dpb_extra_binfo = kzalloc(sizeof(*binfo), GFP_KERNEL); if (!inst->dpb_extra_binfo) { dprintk(VIDC_ERR, "Out of memory\n"); rc = -ENOMEM; goto fail_kzalloc; } rc = msm_comm_smem_alloc(inst, extradata_buf->buffer_size, 1, smem_flags, buffer_type, 0, &inst->dpb_extra_binfo->smem); if (rc) { dprintk(VIDC_ERR, "Failed to allocate output memory\n"); goto err_no_mem; } } else { dprintk(VIDC_DBG, "This extradata buffer not required, buffer_type: %x\n", Loading @@ -3508,9 +3496,8 @@ static int set_output_buffers(struct msm_vidc_inst *inst, if (inst->flags & VIDC_SECURE) smem_flags |= SMEM_SECURE; if (output_buf->buffer_size) { for (i = 0; i < output_buf->buffer_count_actual; i++) { if (buffer_size) { for (i = 0; i < num_buffers; i++) { binfo = kzalloc(sizeof(*binfo), GFP_KERNEL); if (!binfo) { dprintk(VIDC_ERR, "Out of memory\n"); Loading @@ -3534,18 +3521,15 @@ static int set_output_buffers(struct msm_vidc_inst *inst, HAL_BUFFER_MODE_STATIC) { struct vidc_buffer_addr_info buffer_info = {0}; buffer_info.buffer_size = output_buf->buffer_size; buffer_info.buffer_size = buffer_size; buffer_info.buffer_type = buffer_type; buffer_info.num_buffers = 1; buffer_info.align_device_addr = binfo->smem.device_addr; buffer_info.extradata_addr = binfo->smem.device_addr + output_buf->buffer_size; if (extradata_buf) inst->dpb_extra_binfo->smem.device_addr; buffer_info.extradata_size = extradata_buf->buffer_size; inst->dpb_extra_binfo->smem.size; rc = call_hfi_op(hdev, session_set_buffers, (void *) inst->session, &buffer_info); if (rc) { Loading Loading @@ -4483,7 +4467,7 @@ int msm_comm_try_get_prop(struct msm_vidc_inst *inst, enum hal_property ptype, return rc; } int msm_comm_release_output_buffers(struct msm_vidc_inst *inst, int msm_comm_release_dpb_only_buffers(struct msm_vidc_inst *inst, bool force_release) { struct msm_smem *handle; Loading Loading @@ -4555,6 +4539,12 @@ int msm_comm_release_output_buffers(struct msm_vidc_inst *inst, kfree(buf); } if (inst->dpb_extra_binfo) { msm_comm_smem_free(inst, &inst->dpb_extra_binfo->smem); kfree(inst->dpb_extra_binfo); inst->dpb_extra_binfo = NULL; } mutex_unlock(&inst->outputbufs.lock); return rc; } Loading Loading @@ -4835,7 +4825,7 @@ int msm_comm_set_buffer_count(struct msm_vidc_inst *inst, return rc; } int msm_comm_set_output_buffers(struct msm_vidc_inst *inst) int msm_comm_set_dpb_only_buffers(struct msm_vidc_inst *inst) { int rc = 0; bool force_release = true; Loading @@ -4848,15 +4838,15 @@ int msm_comm_set_output_buffers(struct msm_vidc_inst *inst) if (inst->fmts[OUTPUT_PORT].defer_outputs) force_release = false; if (msm_comm_release_output_buffers(inst, force_release)) if (msm_comm_release_dpb_only_buffers(inst, force_release)) dprintk(VIDC_WARN, "Failed to release output buffers\n"); rc = set_output_buffers(inst, HAL_BUFFER_OUTPUT); rc = set_dpb_only_buffers(inst, HAL_BUFFER_OUTPUT); if (rc) goto error; return rc; error: msm_comm_release_output_buffers(inst, true); msm_comm_release_dpb_only_buffers(inst, true); return rc; } Loading Loading @@ -4906,15 +4896,13 @@ int msm_comm_set_recon_buffers(struct msm_vidc_inst *inst) return -EINVAL; } if (inst->session_type == MSM_VIDC_ENCODER) if (inst->session_type != MSM_VIDC_ENCODER) { dprintk(VIDC_DBG, "Recon buffs not req for decoder/cvp\n"); return 0; } internal_buf = get_buff_req_buffer(inst, HAL_BUFFER_INTERNAL_RECON); else if (inst->session_type == MSM_VIDC_DECODER) internal_buf = get_buff_req_buffer(inst, msm_comm_get_hal_output_buffer(inst)); else return -EINVAL; if (!internal_buf || !internal_buf->buffer_count_actual) { dprintk(VIDC_DBG, "Inst : %pK Recon buffers not required\n", inst); Loading Loading @@ -5713,7 +5701,7 @@ int msm_comm_session_continue(void *instance) inst->prop.width[OUTPUT_PORT] = inst->reconfig_width; if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { rc = msm_comm_queue_output_buffers(inst); rc = msm_comm_queue_dpb_only_buffers(inst); if (rc) { dprintk(VIDC_ERR, "Failed to queue output buffers: %d\n", Loading drivers/media/platform/msm/vidc/msm_vidc_common.h +3 −3 Original line number Diff line number Diff line Loading @@ -151,8 +151,8 @@ int msm_comm_set_scratch_buffers(struct msm_vidc_inst *inst); int msm_comm_set_persist_buffers(struct msm_vidc_inst *inst); int msm_comm_set_buffer_count(struct msm_vidc_inst *inst, int host_count, int act_count, enum hal_buffer type); int msm_comm_set_output_buffers(struct msm_vidc_inst *inst); int msm_comm_queue_output_buffers(struct msm_vidc_inst *inst); int msm_comm_set_dpb_only_buffers(struct msm_vidc_inst *inst); int msm_comm_queue_dpb_only_buffers(struct msm_vidc_inst *inst); int msm_comm_qbuf(struct msm_vidc_inst *inst, struct msm_vidc_buffer *mbuf); int msm_comm_qbufs(struct msm_vidc_inst *inst); void msm_comm_flush_dynamic_buffers(struct msm_vidc_inst *inst); Loading @@ -162,7 +162,7 @@ int msm_comm_release_scratch_buffers(struct msm_vidc_inst *inst, int msm_comm_release_persist_buffers(struct msm_vidc_inst *inst); int msm_comm_release_recon_buffers(struct msm_vidc_inst *inst); void msm_comm_release_eos_buffers(struct msm_vidc_inst *inst); int msm_comm_release_output_buffers(struct msm_vidc_inst *inst, int msm_comm_release_dpb_only_buffers(struct msm_vidc_inst *inst, bool force_release); void msm_comm_validate_output_buffers(struct msm_vidc_inst *inst); int msm_comm_force_cleanup(struct msm_vidc_inst *inst); Loading Loading
drivers/media/platform/msm/vidc/msm_vdec.c +79 −79 Original line number Diff line number Diff line Loading @@ -514,6 +514,36 @@ static bool msm_vidc_check_for_vp9d_overload(struct msm_vidc_core *core) return false; } int msm_vdec_update_stream_output_mode(struct msm_vidc_inst *inst) { u32 format; u32 stream_output_mode; u32 fourcc; if (!inst) { dprintk(VIDC_ERR, "%s invalid parameters\n", __func__); return -EINVAL; } format = inst->fmts[CAPTURE_PORT].fourcc; stream_output_mode = HAL_VIDEO_DECODER_PRIMARY; if ((format == V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS) || (format == V4L2_PIX_FMT_NV12)) { stream_output_mode = HAL_VIDEO_DECODER_SECONDARY; } msm_comm_set_stream_output_mode(inst, stream_output_mode); fourcc = V4L2_PIX_FMT_NV12_UBWC; if (inst->bit_depth == MSM_VIDC_BIT_DEPTH_10) fourcc = V4L2_PIX_FMT_NV12_TP10_UBWC; inst->clk_data.dpb_fourcc = fourcc; return 0; } int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) { struct msm_vidc_format *fmt = NULL; Loading Loading @@ -550,6 +580,13 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) memcpy(&inst->fmts[fmt->type], fmt, sizeof(struct msm_vidc_format)); inst->bit_depth = MSM_VIDC_BIT_DEPTH_8; if ((f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_NV12_TP10_UBWC) || (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS)) { inst->bit_depth = MSM_VIDC_BIT_DEPTH_10; } inst->prop.width[CAPTURE_PORT] = f->fmt.pix_mp.width; inst->prop.height[CAPTURE_PORT] = f->fmt.pix_mp.height; rc = msm_vidc_check_session_supported(inst); Loading Loading @@ -577,6 +614,13 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f) f->fmt.pix_mp.plane_fmt[i].sizeimage; } rc = msm_vdec_update_stream_output_mode(inst); if (rc) { dprintk(VIDC_ERR, "%s: failed to update output stream mode\n", __func__); goto err_invalid_fmt; } } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats, Loading Loading @@ -695,9 +739,13 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst) inst->buffer_mode_set[OUTPUT_PORT] = HAL_BUFFER_MODE_STATIC; inst->buffer_mode_set[CAPTURE_PORT] = HAL_BUFFER_MODE_DYNAMIC; inst->stream_output_mode = HAL_VIDEO_DECODER_PRIMARY; /* To start with, both ports are 1 plane each */ /* To start with, in port is 1 plane and out is 2 */ inst->bufq[OUTPUT_PORT].num_planes = 1; inst->bufq[CAPTURE_PORT].num_planes = 1; inst->bufq[CAPTURE_PORT].num_planes = 2; inst->bufq[CAPTURE_PORT].plane_sizes[1] = VENUS_EXTRADATA_SIZE( inst->prop.height[CAPTURE_PORT], inst->prop.width[CAPTURE_PORT]); inst->prop.fps = DEFAULT_FPS; inst->clk_data.operating_rate = 0; if (core->resources.decode_batching) Loading Loading @@ -794,8 +842,6 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) bufreq->buffer_count_actual = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) return -EINVAL; Loading @@ -807,28 +853,6 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl) bufreq->buffer_count_actual = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT2); if (!bufreq) return -EINVAL; bufreq->buffer_count_min = MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS; bufreq->buffer_count_min_host = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; bufreq->buffer_count_actual = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; } else { bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) return -EINVAL; bufreq->buffer_count_min = MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS; bufreq->buffer_count_min_host = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; bufreq->buffer_count_actual = MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS; } break; case V4L2_CID_MPEG_VIDC_VIDEO_SECURE: inst->flags &= ~VIDC_SECURE; Loading Loading @@ -1022,7 +1046,8 @@ int msm_vdec_set_output_buffer_counts(struct msm_vidc_inst *inst) hdev = inst->core->device; buffer_type = msm_comm_get_hal_output_buffer(inst); bufreq = get_buff_req_buffer(inst, buffer_type); /* Correct buffer counts is always stored in HAL_BUFFER_OUTPUT */ bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) { dprintk(VIDC_ERR, "%s: failed to set bufreqs(%#x)\n", __func__, buffer_type); Loading Loading @@ -1215,9 +1240,7 @@ int msm_vdec_set_secure_mode(struct msm_vidc_inst *inst) int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) { int rc = 0; int fourcc; struct hfi_device *hdev; u32 output_stream_mode; struct hal_multi_stream multi_stream; struct hal_frame_size frame_sz; Loading @@ -1227,18 +1250,14 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) } hdev = inst->core->device; /* Decide split/combined mode here */ output_stream_mode = V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_PRIMARY; switch (output_stream_mode) { case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_PRIMARY: if (is_primary_output_mode(inst)) { multi_stream.buffer_type = HAL_BUFFER_OUTPUT; multi_stream.enable = true; rc = call_hfi_op(hdev, session_set_property, inst->session, HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream); if (rc) { dprintk(VIDC_ERR, "%s: set prop multistream primary (output) failed\n", "%s: set prop multistream primary failed : %d\n", __func__, rc); return rc; } Loading @@ -1248,25 +1267,13 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream); if (rc) { dprintk(VIDC_ERR, "%s: set prop multistream primary (output2) failed\n", "%s: set prop multistream primary2 failed : %d\n", __func__, rc); return rc; } break; case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_SECONDARY: switch (inst->bit_depth) { case MSM_VIDC_BIT_DEPTH_8: fourcc = V4L2_PIX_FMT_NV12_UBWC; break; case MSM_VIDC_BIT_DEPTH_10: fourcc = V4L2_PIX_FMT_NV12_TP10_UBWC; break; default: dprintk(VIDC_ERR, "%s: invalid bitdepth\n", __func__); return -EINVAL; } } else { rc = msm_comm_set_color_format(inst, HAL_BUFFER_OUTPUT, fourcc); HAL_BUFFER_OUTPUT, inst->clk_data.dpb_fourcc); if (rc) return rc; Loading @@ -1276,7 +1283,7 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream); if (rc) { dprintk(VIDC_ERR, "%s: set prop multistream (output2) failed\n", "%s: set prop multistream secondary failed : %d\n", __func__, rc); return rc; } Loading @@ -1286,7 +1293,7 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) HAL_PARAM_VDEC_MULTI_STREAM, &multi_stream); if (rc) { dprintk(VIDC_ERR, "%s: set prop multistream (output) failed\n", "%s: set prop multistream secondary2 failed : %d\n", __func__, rc); return rc; } Loading @@ -1304,13 +1311,6 @@ int msm_vdec_set_output_stream_mode(struct msm_vidc_inst *inst) __func__, rc); return rc; } break; default: dprintk(VIDC_ERR, "%s: unknown multistream type %#x\n", __func__, output_stream_mode); rc = -EINVAL; return rc; } return rc; Loading Loading @@ -1462,7 +1462,7 @@ int msm_vdec_set_extradata(struct msm_vidc_inst *inst) HAL_EXTRADATA_UBWC_CR_STATS_INFO, 0x0); msm_comm_set_extradata(inst, HAL_EXTRADATA_NUM_CONCEALED_MB, 0x0); if (inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_HEVC) { if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_HEVC) { msm_comm_set_extradata(inst, HAL_EXTRADATA_MASTERING_DISPLAY_COLOUR_SEI, 0x0); Loading @@ -1489,7 +1489,7 @@ int msm_vdec_set_extradata(struct msm_vidc_inst *inst) msm_comm_set_extradata(inst, display_info, 0x1); msm_comm_set_extradata(inst, HAL_EXTRADATA_NUM_CONCEALED_MB, 0x1); if (inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_HEVC) { if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_HEVC) { msm_comm_set_extradata(inst, HAL_EXTRADATA_MASTERING_DISPLAY_COLOUR_SEI, 0x1); Loading Loading @@ -1559,10 +1559,10 @@ int msm_vdec_set_properties(struct msm_vidc_inst *inst) rc = msm_vdec_set_color_format(inst); if (rc) goto exit; rc = msm_vdec_set_output_buffer_counts(inst); rc = msm_vdec_set_output_stream_mode(inst); if (rc) goto exit; rc = msm_vdec_set_output_stream_mode(inst); rc = msm_vdec_set_output_buffer_counts(inst); if (rc) goto exit; rc = msm_vdec_set_operating_rate(inst); Loading
drivers/media/platform/msm/vidc/msm_vidc.c +17 −23 Original line number Diff line number Diff line Loading @@ -744,7 +744,6 @@ static int msm_vidc_queue_setup(struct vb2_queue *q, int rc = 0; unsigned int i = 0; struct hal_buffer_requirements *bufreq; enum hal_buffer buffer_type; if (!q || !num_buffers || !num_planes || !sizes || !q->drv_priv) { Loading Loading @@ -786,13 +785,12 @@ static int msm_vidc_queue_setup(struct vb2_queue *q, } break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: { buffer_type = msm_comm_get_hal_output_buffer(inst); bufreq = get_buff_req_buffer(inst, buffer_type); HAL_BUFFER_OUTPUT); if (!bufreq) { dprintk(VIDC_ERR, "Failed : No buffer requirements : %x\n", buffer_type); HAL_BUFFER_OUTPUT); return -EINVAL; } if (inst->session_type != MSM_VIDC_DECODER && Loading Loading @@ -845,8 +843,7 @@ static inline int msm_vidc_verify_buffer_counts(struct msm_vidc_inst *inst) for (i = 0; i < HAL_BUFFER_MAX; i++) { struct hal_buffer_requirements *req = &inst->buff_req.buffer[i]; if (req && (msm_comm_get_hal_output_buffer(inst) == req->buffer_type)) { if (req && (req->buffer_type == HAL_BUFFER_OUTPUT)) { dprintk(VIDC_DBG, "Verifying Buffer : %d\n", req->buffer_type); if (req->buffer_count_actual < Loading Loading @@ -1087,6 +1084,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst) goto fail_start; } b.buffer_type = HAL_BUFFER_OUTPUT; if (inst->session_type == MSM_VIDC_ENCODER) { rc = msm_vidc_set_rotation(inst); if (rc) { Loading @@ -1094,7 +1092,9 @@ static inline int start_streaming(struct msm_vidc_inst *inst) "Set rotation for encoder failed %pK\n"); goto fail_start; } } } else if ((inst->session_type == MSM_VIDC_DECODER) && (is_secondary_output_mode(inst))) b.buffer_type = HAL_BUFFER_OUTPUT2; /* HEIC HW/FWK tiling encode is supported only for CQ RC mode */ if (inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ) { Loading Loading @@ -1152,13 +1152,6 @@ static inline int start_streaming(struct msm_vidc_inst *inst) goto fail_start; } if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { b.buffer_type = HAL_BUFFER_OUTPUT2; } else { b.buffer_type = HAL_BUFFER_OUTPUT; } rc = msm_comm_try_get_bufreqs(inst); b.buffer_size = inst->bufq[CAPTURE_PORT].plane_sizes[0]; Loading Loading @@ -1196,7 +1189,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst) if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { rc = msm_comm_set_output_buffers(inst); rc = msm_comm_set_dpb_only_buffers(inst); if (rc) { dprintk(VIDC_ERR, "Failed to set output buffers: %d\n", rc); Loading Loading @@ -1239,7 +1232,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst) if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { rc = msm_comm_queue_output_buffers(inst); rc = msm_comm_queue_dpb_only_buffers(inst); if (rc) { dprintk(VIDC_ERR, "Failed to queue output buffers: %d\n", rc); Loading Loading @@ -1688,7 +1681,6 @@ static int try_get_ctrl_for_instance(struct msm_vidc_inst *inst, { int rc = 0; struct hal_buffer_requirements *bufreq = NULL; enum hal_buffer buffer_type; switch (ctrl->id) { Loading Loading @@ -1726,18 +1718,17 @@ static int try_get_ctrl_for_instance(struct msm_vidc_inst *inst, break; case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: buffer_type = msm_comm_get_hal_output_buffer(inst); bufreq = get_buff_req_buffer(inst, buffer_type); bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) { dprintk(VIDC_ERR, "Failed to find bufreqs for buffer type = %d\n", buffer_type); HAL_BUFFER_OUTPUT); return -EINVAL; } ctrl->val = bufreq->buffer_count_min_host; dprintk(VIDC_DBG, "g_min: %x : hal_buffer %d min buffers %d\n", hash32_ptr(inst->session), buffer_type, ctrl->val); hash32_ptr(inst->session), HAL_BUFFER_OUTPUT, ctrl->val); break; case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT: bufreq = get_buff_req_buffer(inst, HAL_BUFFER_INPUT); Loading Loading @@ -1883,6 +1874,8 @@ void *msm_vidc_open(int core_id, int session_type) inst->state = MSM_VIDC_CORE_UNINIT_DONE; inst->core = core; inst->clk_data.core_id = VIDC_CORE_ID_DEFAULT; inst->clk_data.dpb_fourcc = V4L2_PIX_FMT_NV12_UBWC; inst->clk_data.opb_fourcc = V4L2_PIX_FMT_NV12_UBWC; inst->bit_depth = MSM_VIDC_BIT_DEPTH_8; inst->pic_struct = MSM_VIDC_PIC_STRUCT_PROGRESSIVE; inst->colour_space = MSM_VIDC_BT601_6_525; Loading @@ -1891,6 +1884,7 @@ void *msm_vidc_open(int core_id, int session_type) inst->entropy_mode = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC; inst->smem_ops = &msm_vidc_smem_ops; inst->rc_type = RATE_CONTROL_OFF; inst->dpb_extra_binfo = NULL; for (i = SESSION_MSG_INDEX(SESSION_MSG_START); i <= SESSION_MSG_INDEX(SESSION_MSG_END); i++) { Loading Loading @@ -2041,7 +2035,7 @@ static void msm_vidc_cleanup_instance(struct msm_vidc_inst *inst) msm_comm_release_eos_buffers(inst); if (msm_comm_release_output_buffers(inst, true)) if (msm_comm_release_dpb_only_buffers(inst, true)) dprintk(VIDC_ERR, "Failed to release output buffers\n"); Loading
drivers/media/platform/msm/vidc/msm_vidc_clocks.c +3 −14 Original line number Diff line number Diff line Loading @@ -1134,7 +1134,7 @@ void msm_clock_data_reset(struct msm_vidc_inst *inst) __func__, HAL_BUFFER_INPUT); } else if (inst->session_type == MSM_VIDC_DECODER) { dcvs->buffer_type = msm_comm_get_hal_output_buffer(inst); dcvs->buffer_type = HAL_BUFFER_OUTPUT; buf_req = get_buff_req_buffer(inst, dcvs->buffer_type); if (buf_req) dcvs->max_threshold = Loading Loading @@ -1179,17 +1179,6 @@ void msm_clock_data_reset(struct msm_vidc_inst *inst) __func__); } static bool is_output_buffer(struct msm_vidc_inst *inst, enum hal_buffer buffer_type) { if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { return buffer_type == HAL_BUFFER_OUTPUT2; } else { return buffer_type == HAL_BUFFER_OUTPUT; } } int msm_vidc_get_extra_buff_count(struct msm_vidc_inst *inst, enum hal_buffer buffer_type) { Loading @@ -1209,7 +1198,7 @@ int msm_vidc_get_extra_buff_count(struct msm_vidc_inst *inst, /* Add DCVS extra buffer count */ if (inst->core->resources.dcvs) { if (is_decode_session(inst) && is_output_buffer(inst, buffer_type)) { buffer_type == HAL_BUFFER_OUTPUT) { count += DCVS_DEC_EXTRA_OUTPUT_BUFFERS; } else if ((is_encode_session(inst) && buffer_type == HAL_BUFFER_INPUT)) { Loading @@ -1221,7 +1210,7 @@ int msm_vidc_get_extra_buff_count(struct msm_vidc_inst *inst, * if platform supports decode batching ensure minimum * batch size count of extra buffers added on output port */ if (is_output_buffer(inst, buffer_type)) { if (buffer_type == HAL_BUFFER_OUTPUT) { if (inst->core->resources.decode_batching && is_decode_session(inst) && count < inst->batch.size) Loading
drivers/media/platform/msm/vidc/msm_vidc_common.c +84 −96 Original line number Diff line number Diff line Loading @@ -1592,36 +1592,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data) inst->reconfig_width = event_notify->width; inst->bit_depth = event_notify->bit_depth; if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) { mutex_unlock(&inst->lock); return; } /* No need to add extra buffers to DPBs */ bufreq->buffer_count_min = event_notify->capture_buf_count; bufreq->buffer_count_min_host = bufreq->buffer_count_min; bufreq = NULL; bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT2); if (!bufreq) { mutex_unlock(&inst->lock); return; } extra_buff_count = msm_vidc_get_extra_buff_count(inst, HAL_BUFFER_OUTPUT2); bufreq->buffer_count_min = event_notify->capture_buf_count; bufreq->buffer_count_min_host = bufreq->buffer_count_min + extra_buff_count; } else { bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); bufreq = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!bufreq) { mutex_unlock(&inst->lock); return; Loading @@ -1632,7 +1603,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data) bufreq->buffer_count_min = event_notify->capture_buf_count; bufreq->buffer_count_min_host = bufreq->buffer_count_min + extra_buff_count; } dprintk(VIDC_DBG, "%s: buffer[%d] count: min %d min_host %d\n", __func__, bufreq->buffer_type, bufreq->buffer_count_min, bufreq->buffer_count_min_host); Loading Loading @@ -1840,12 +1811,11 @@ void msm_comm_validate_output_buffers(struct msm_vidc_inst *inst) } } int msm_comm_queue_output_buffers(struct msm_vidc_inst *inst) int msm_comm_queue_dpb_only_buffers(struct msm_vidc_inst *inst) { struct internal_buf *binfo; struct internal_buf *binfo, *extra_info; struct hfi_device *hdev; struct vidc_frame_data frame_data = {0}; struct hal_buffer_requirements *output_buf, *extra_buf; int rc = 0; if (!inst || !inst->core || !inst->core->device) { Loading @@ -1855,43 +1825,30 @@ int msm_comm_queue_output_buffers(struct msm_vidc_inst *inst) hdev = inst->core->device; output_buf = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT); if (!output_buf) { dprintk(VIDC_DBG, "This output buffer not required, buffer_type: %x\n", HAL_BUFFER_OUTPUT); return 0; } dprintk(VIDC_DBG, "output: num = %d, size = %d\n", output_buf->buffer_count_actual, output_buf->buffer_size); extra_buf = get_buff_req_buffer(inst, HAL_BUFFER_EXTRADATA_OUTPUT); extra_info = inst->dpb_extra_binfo; mutex_lock(&inst->outputbufs.lock); list_for_each_entry(binfo, &inst->outputbufs.list, list) { if (binfo->buffer_ownership != DRIVER) continue; if (binfo->mark_remove) continue; frame_data.alloc_len = output_buf->buffer_size; frame_data.alloc_len = binfo->smem.size; frame_data.filled_len = 0; frame_data.offset = 0; frame_data.device_addr = binfo->smem.device_addr; frame_data.flags = 0; frame_data.extradata_addr = binfo->smem.device_addr + output_buf->buffer_size; frame_data.extradata_addr = extra_info ? extra_info->smem.device_addr : 0; frame_data.buffer_type = HAL_BUFFER_OUTPUT; frame_data.extradata_size = extra_buf ? extra_buf->buffer_size : 0; frame_data.extradata_size = extra_info ? extra_info->smem.size : 0; rc = call_hfi_op(hdev, session_ftb, (void *) inst->session, &frame_data); binfo->buffer_ownership = FIRMWARE; } mutex_unlock(&inst->outputbufs.lock); return 0; return rc; } static void handle_session_flush(enum hal_command_response cmd, void *data) Loading Loading @@ -1924,7 +1881,7 @@ static void handle_session_flush(enum hal_command_response cmd, void *data) msm_comm_validate_output_buffers(inst); if (!inst->in_reconfig) { rc = msm_comm_queue_output_buffers(inst); rc = msm_comm_queue_dpb_only_buffers(inst); if (rc) { dprintk(VIDC_ERR, "Failed to queue output buffers: %d\n", Loading Loading @@ -3455,12 +3412,28 @@ struct hal_buffer_requirements *get_buff_req_buffer( return NULL; } static int set_output_buffers(struct msm_vidc_inst *inst, static int convert_color_fmt(int v4l2_fmt) { switch (v4l2_fmt) { case V4L2_PIX_FMT_NV12: return COLOR_FMT_NV12; case V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS: return COLOR_FMT_P010; case V4L2_PIX_FMT_NV12_UBWC: return COLOR_FMT_NV12_UBWC; case V4L2_PIX_FMT_NV12_TP10_UBWC: return COLOR_FMT_NV12_BPP10_UBWC; default: return COLOR_FMT_NV12; } } static int set_dpb_only_buffers(struct msm_vidc_inst *inst, enum hal_buffer buffer_type) { int rc = 0; struct internal_buf *binfo = NULL; u32 smem_flags = SMEM_UNCACHED, buffer_size; u32 smem_flags = SMEM_UNCACHED, buffer_size, num_buffers, hfi_fmt; struct hal_buffer_requirements *output_buf, *extradata_buf; unsigned int i; struct hfi_device *hdev; Loading @@ -3477,15 +3450,16 @@ static int set_output_buffers(struct msm_vidc_inst *inst, } /* For DPB buffers, Always use FW count */ output_buf->buffer_count_actual = output_buf->buffer_count_min_host = output_buf->buffer_count_min; num_buffers = output_buf->buffer_count_min; hfi_fmt = convert_color_fmt(inst->clk_data.dpb_fourcc); buffer_size = VENUS_BUFFER_SIZE(hfi_fmt, inst->prop.width[CAPTURE_PORT], inst->prop.height[CAPTURE_PORT]); dprintk(VIDC_DBG, "output: num = %d, size = %d\n", output_buf->buffer_count_actual, output_buf->buffer_size); num_buffers, buffer_size); buffer_size = output_buf->buffer_size; b.buffer_type = buffer_type; b.buffer_size = buffer_size; rc = call_hfi_op(hdev, session_set_property, Loading @@ -3498,7 +3472,21 @@ static int set_output_buffers(struct msm_vidc_inst *inst, "extradata: num = %d, size = %d\n", extradata_buf->buffer_count_actual, extradata_buf->buffer_size); buffer_size += extradata_buf->buffer_size; inst->dpb_extra_binfo = NULL; inst->dpb_extra_binfo = kzalloc(sizeof(*binfo), GFP_KERNEL); if (!inst->dpb_extra_binfo) { dprintk(VIDC_ERR, "Out of memory\n"); rc = -ENOMEM; goto fail_kzalloc; } rc = msm_comm_smem_alloc(inst, extradata_buf->buffer_size, 1, smem_flags, buffer_type, 0, &inst->dpb_extra_binfo->smem); if (rc) { dprintk(VIDC_ERR, "Failed to allocate output memory\n"); goto err_no_mem; } } else { dprintk(VIDC_DBG, "This extradata buffer not required, buffer_type: %x\n", Loading @@ -3508,9 +3496,8 @@ static int set_output_buffers(struct msm_vidc_inst *inst, if (inst->flags & VIDC_SECURE) smem_flags |= SMEM_SECURE; if (output_buf->buffer_size) { for (i = 0; i < output_buf->buffer_count_actual; i++) { if (buffer_size) { for (i = 0; i < num_buffers; i++) { binfo = kzalloc(sizeof(*binfo), GFP_KERNEL); if (!binfo) { dprintk(VIDC_ERR, "Out of memory\n"); Loading @@ -3534,18 +3521,15 @@ static int set_output_buffers(struct msm_vidc_inst *inst, HAL_BUFFER_MODE_STATIC) { struct vidc_buffer_addr_info buffer_info = {0}; buffer_info.buffer_size = output_buf->buffer_size; buffer_info.buffer_size = buffer_size; buffer_info.buffer_type = buffer_type; buffer_info.num_buffers = 1; buffer_info.align_device_addr = binfo->smem.device_addr; buffer_info.extradata_addr = binfo->smem.device_addr + output_buf->buffer_size; if (extradata_buf) inst->dpb_extra_binfo->smem.device_addr; buffer_info.extradata_size = extradata_buf->buffer_size; inst->dpb_extra_binfo->smem.size; rc = call_hfi_op(hdev, session_set_buffers, (void *) inst->session, &buffer_info); if (rc) { Loading Loading @@ -4483,7 +4467,7 @@ int msm_comm_try_get_prop(struct msm_vidc_inst *inst, enum hal_property ptype, return rc; } int msm_comm_release_output_buffers(struct msm_vidc_inst *inst, int msm_comm_release_dpb_only_buffers(struct msm_vidc_inst *inst, bool force_release) { struct msm_smem *handle; Loading Loading @@ -4555,6 +4539,12 @@ int msm_comm_release_output_buffers(struct msm_vidc_inst *inst, kfree(buf); } if (inst->dpb_extra_binfo) { msm_comm_smem_free(inst, &inst->dpb_extra_binfo->smem); kfree(inst->dpb_extra_binfo); inst->dpb_extra_binfo = NULL; } mutex_unlock(&inst->outputbufs.lock); return rc; } Loading Loading @@ -4835,7 +4825,7 @@ int msm_comm_set_buffer_count(struct msm_vidc_inst *inst, return rc; } int msm_comm_set_output_buffers(struct msm_vidc_inst *inst) int msm_comm_set_dpb_only_buffers(struct msm_vidc_inst *inst) { int rc = 0; bool force_release = true; Loading @@ -4848,15 +4838,15 @@ int msm_comm_set_output_buffers(struct msm_vidc_inst *inst) if (inst->fmts[OUTPUT_PORT].defer_outputs) force_release = false; if (msm_comm_release_output_buffers(inst, force_release)) if (msm_comm_release_dpb_only_buffers(inst, force_release)) dprintk(VIDC_WARN, "Failed to release output buffers\n"); rc = set_output_buffers(inst, HAL_BUFFER_OUTPUT); rc = set_dpb_only_buffers(inst, HAL_BUFFER_OUTPUT); if (rc) goto error; return rc; error: msm_comm_release_output_buffers(inst, true); msm_comm_release_dpb_only_buffers(inst, true); return rc; } Loading Loading @@ -4906,15 +4896,13 @@ int msm_comm_set_recon_buffers(struct msm_vidc_inst *inst) return -EINVAL; } if (inst->session_type == MSM_VIDC_ENCODER) if (inst->session_type != MSM_VIDC_ENCODER) { dprintk(VIDC_DBG, "Recon buffs not req for decoder/cvp\n"); return 0; } internal_buf = get_buff_req_buffer(inst, HAL_BUFFER_INTERNAL_RECON); else if (inst->session_type == MSM_VIDC_DECODER) internal_buf = get_buff_req_buffer(inst, msm_comm_get_hal_output_buffer(inst)); else return -EINVAL; if (!internal_buf || !internal_buf->buffer_count_actual) { dprintk(VIDC_DBG, "Inst : %pK Recon buffers not required\n", inst); Loading Loading @@ -5713,7 +5701,7 @@ int msm_comm_session_continue(void *instance) inst->prop.width[OUTPUT_PORT] = inst->reconfig_width; if (msm_comm_get_stream_output_mode(inst) == HAL_VIDEO_DECODER_SECONDARY) { rc = msm_comm_queue_output_buffers(inst); rc = msm_comm_queue_dpb_only_buffers(inst); if (rc) { dprintk(VIDC_ERR, "Failed to queue output buffers: %d\n", Loading
drivers/media/platform/msm/vidc/msm_vidc_common.h +3 −3 Original line number Diff line number Diff line Loading @@ -151,8 +151,8 @@ int msm_comm_set_scratch_buffers(struct msm_vidc_inst *inst); int msm_comm_set_persist_buffers(struct msm_vidc_inst *inst); int msm_comm_set_buffer_count(struct msm_vidc_inst *inst, int host_count, int act_count, enum hal_buffer type); int msm_comm_set_output_buffers(struct msm_vidc_inst *inst); int msm_comm_queue_output_buffers(struct msm_vidc_inst *inst); int msm_comm_set_dpb_only_buffers(struct msm_vidc_inst *inst); int msm_comm_queue_dpb_only_buffers(struct msm_vidc_inst *inst); int msm_comm_qbuf(struct msm_vidc_inst *inst, struct msm_vidc_buffer *mbuf); int msm_comm_qbufs(struct msm_vidc_inst *inst); void msm_comm_flush_dynamic_buffers(struct msm_vidc_inst *inst); Loading @@ -162,7 +162,7 @@ int msm_comm_release_scratch_buffers(struct msm_vidc_inst *inst, int msm_comm_release_persist_buffers(struct msm_vidc_inst *inst); int msm_comm_release_recon_buffers(struct msm_vidc_inst *inst); void msm_comm_release_eos_buffers(struct msm_vidc_inst *inst); int msm_comm_release_output_buffers(struct msm_vidc_inst *inst, int msm_comm_release_dpb_only_buffers(struct msm_vidc_inst *inst, bool force_release); void msm_comm_validate_output_buffers(struct msm_vidc_inst *inst); int msm_comm_force_cleanup(struct msm_vidc_inst *inst); Loading