Lines Matching refs:inst

194 	struct vpu_inst *inst = ctrl_to_inst(ctrl);  in vdec_op_s_ctrl()  local
195 struct vdec_t *vdec = inst->priv; in vdec_op_s_ctrl()
198 vpu_inst_lock(inst); in vdec_op_s_ctrl()
210 vpu_inst_unlock(inst); in vdec_op_s_ctrl()
220 static int vdec_ctrl_init(struct vpu_inst *inst) in vdec_ctrl_init() argument
225 ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 20); in vdec_ctrl_init()
229 v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, in vdec_ctrl_init()
233 v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, in vdec_ctrl_init()
237 ctrl = v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, in vdec_ctrl_init()
242 ctrl = v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, in vdec_ctrl_init()
247 if (inst->ctrl_handler.error) { in vdec_ctrl_init()
248 ret = inst->ctrl_handler.error; in vdec_ctrl_init()
249 v4l2_ctrl_handler_free(&inst->ctrl_handler); in vdec_ctrl_init()
253 ret = v4l2_ctrl_handler_setup(&inst->ctrl_handler); in vdec_ctrl_init()
255 dev_err(inst->dev, "[%d] setup ctrls fail, ret = %d\n", inst->id, ret); in vdec_ctrl_init()
256 v4l2_ctrl_handler_free(&inst->ctrl_handler); in vdec_ctrl_init()
263 static void vdec_handle_resolution_change(struct vpu_inst *inst) in vdec_handle_resolution_change() argument
265 struct vdec_t *vdec = inst->priv; in vdec_handle_resolution_change()
268 if (!inst->fh.m2m_ctx) in vdec_handle_resolution_change()
271 if (inst->state != VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE) in vdec_handle_resolution_change()
276 q = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); in vdec_handle_resolution_change()
281 vpu_notify_source_change(inst); in vdec_handle_resolution_change()
282 vpu_set_last_buffer_dequeued(inst, false); in vdec_handle_resolution_change()
285 static int vdec_update_state(struct vpu_inst *inst, enum vpu_codec_state state, u32 force) in vdec_update_state() argument
287 struct vdec_t *vdec = inst->priv; in vdec_update_state()
288 enum vpu_codec_state pre_state = inst->state; in vdec_update_state()
291 if (inst->state == VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE) in vdec_update_state()
292 vdec->state = inst->state; in vdec_update_state()
296 if (inst->state != VPU_CODEC_STATE_SEEK || force) in vdec_update_state()
297 inst->state = state; in vdec_update_state()
301 if (inst->state != pre_state) in vdec_update_state()
302 vpu_trace(inst->dev, "[%d] %s -> %s\n", inst->id, in vdec_update_state()
303 vpu_codec_state_name(pre_state), vpu_codec_state_name(inst->state)); in vdec_update_state()
305 if (inst->state == VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE) in vdec_update_state()
306 vdec_handle_resolution_change(inst); in vdec_update_state()
311 static void vdec_set_last_buffer_dequeued(struct vpu_inst *inst) in vdec_set_last_buffer_dequeued() argument
313 struct vdec_t *vdec = inst->priv; in vdec_set_last_buffer_dequeued()
315 if (inst->state == VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE) in vdec_set_last_buffer_dequeued()
319 if (!vpu_set_last_buffer_dequeued(inst, true)) { in vdec_set_last_buffer_dequeued()
321 vdec_update_state(inst, VPU_CODEC_STATE_DRAIN, 0); in vdec_set_last_buffer_dequeued()
337 struct vpu_inst *inst = to_inst(file); in vdec_enum_fmt() local
338 struct vdec_t *vdec = inst->priv; in vdec_enum_fmt()
342 vpu_inst_lock(inst); in vdec_enum_fmt()
344 fmt = vpu_get_format(inst, f->type); in vdec_enum_fmt()
346 fmt = vpu_helper_find_sibling(inst, f->type, fmt->pixfmt); in vdec_enum_fmt()
350 fmt = vpu_helper_enum_format(inst, f->type, f->index); in vdec_enum_fmt()
360 vpu_inst_unlock(inst); in vdec_enum_fmt()
366 struct vpu_inst *inst = to_inst(file); in vdec_g_fmt() local
367 struct vdec_t *vdec = inst->priv; in vdec_g_fmt()
372 vpu_inst_lock(inst); in vdec_g_fmt()
373 cur_fmt = vpu_get_format(inst, f->type); in vdec_g_fmt()
390 vpu_inst_unlock(inst); in vdec_g_fmt()
397 struct vpu_inst *inst = to_inst(file); in vdec_try_fmt() local
398 struct vdec_t *vdec = inst->priv; in vdec_try_fmt()
401 vpu_inst_lock(inst); in vdec_try_fmt()
403 struct vpu_format *cap_fmt = vpu_get_format(inst, f->type); in vdec_try_fmt()
405 if (!vpu_helper_match_format(inst, cap_fmt->type, cap_fmt->pixfmt, in vdec_try_fmt()
410 vpu_try_fmt_common(inst, f, &fmt); in vdec_try_fmt()
423 vpu_inst_unlock(inst); in vdec_try_fmt()
428 static int vdec_s_fmt_common(struct vpu_inst *inst, struct v4l2_format *f) in vdec_s_fmt_common() argument
434 struct vdec_t *vdec = inst->priv; in vdec_s_fmt_common()
437 if (!inst->fh.m2m_ctx) in vdec_s_fmt_common()
440 q = v4l2_m2m_get_vq(inst->fh.m2m_ctx, f->type); in vdec_s_fmt_common()
446 if (vpu_try_fmt_common(inst, f, &fmt)) in vdec_s_fmt_common()
449 cur_fmt = vpu_get_format(inst, f->type); in vdec_s_fmt_common()
450 if (V4L2_TYPE_IS_OUTPUT(f->type) && inst->state != VPU_CODEC_STATE_DEINIT) { in vdec_s_fmt_common()
459 if (vpu_helper_match_format(inst, f->type, cur_fmt->pixfmt, pixmp->pixelformat)) { in vdec_s_fmt_common()
483 inst->crop.left = 0; in vdec_s_fmt_common()
484 inst->crop.top = 0; in vdec_s_fmt_common()
485 inst->crop.width = cur_fmt->width; in vdec_s_fmt_common()
486 inst->crop.height = cur_fmt->height; in vdec_s_fmt_common()
490 vpu_trace(inst->dev, "[%d] %c%c%c%c %dx%d\n", inst->id, in vdec_s_fmt_common()
503 struct vpu_inst *inst = to_inst(file); in vdec_s_fmt() local
505 struct vdec_t *vdec = inst->priv; in vdec_s_fmt()
508 vpu_inst_lock(inst); in vdec_s_fmt()
509 ret = vdec_s_fmt_common(inst, f); in vdec_s_fmt()
517 fc.type = inst->cap_format.type; in vdec_s_fmt()
518 fc.fmt.pix_mp.pixelformat = inst->cap_format.pixfmt; in vdec_s_fmt()
521 vdec_s_fmt_common(inst, &fc); in vdec_s_fmt()
530 vpu_inst_unlock(inst); in vdec_s_fmt()
536 struct vpu_inst *inst = to_inst(file); in vdec_g_selection() local
545 s->r = inst->crop; in vdec_g_selection()
550 s->r.width = inst->cap_format.width; in vdec_g_selection()
551 s->r.height = inst->cap_format.height; in vdec_g_selection()
560 static int vdec_drain(struct vpu_inst *inst) in vdec_drain() argument
562 struct vdec_t *vdec = inst->priv; in vdec_drain()
564 if (!inst->fh.m2m_ctx) in vdec_drain()
570 if (!vpu_is_source_empty(inst)) in vdec_drain()
574 vpu_set_last_buffer_dequeued(inst, true); in vdec_drain()
578 vpu_iface_add_scode(inst, SCODE_PADDING_EOS); in vdec_drain()
580 vpu_iface_set_decode_params(inst, &vdec->params, 1); in vdec_drain()
582 vpu_trace(inst->dev, "[%d] frame_count = %d\n", inst->id, vdec->params.frame_count); in vdec_drain()
587 static int vdec_cmd_start(struct vpu_inst *inst) in vdec_cmd_start() argument
589 struct vdec_t *vdec = inst->priv; in vdec_cmd_start()
591 switch (inst->state) { in vdec_cmd_start()
595 vdec_update_state(inst, VPU_CODEC_STATE_ACTIVE, 0); in vdec_cmd_start()
600 vpu_process_capture_buffer(inst); in vdec_cmd_start()
602 vdec_set_last_buffer_dequeued(inst); in vdec_cmd_start()
606 static int vdec_cmd_stop(struct vpu_inst *inst) in vdec_cmd_stop() argument
608 struct vdec_t *vdec = inst->priv; in vdec_cmd_stop()
610 vpu_trace(inst->dev, "[%d]\n", inst->id); in vdec_cmd_stop()
612 if (inst->state == VPU_CODEC_STATE_DEINIT) { in vdec_cmd_stop()
613 vpu_set_last_buffer_dequeued(inst, true); in vdec_cmd_stop()
616 vdec_drain(inst); in vdec_cmd_stop()
624 struct vpu_inst *inst = to_inst(file); in vdec_decoder_cmd() local
631 vpu_inst_lock(inst); in vdec_decoder_cmd()
634 vdec_cmd_start(inst); in vdec_decoder_cmd()
637 vdec_cmd_stop(inst); in vdec_decoder_cmd()
642 vpu_inst_unlock(inst); in vdec_decoder_cmd()
689 static bool vdec_check_ready(struct vpu_inst *inst, unsigned int type) in vdec_check_ready() argument
691 struct vdec_t *vdec = inst->priv; in vdec_check_ready()
702 static struct vb2_v4l2_buffer *vdec_get_src_buffer(struct vpu_inst *inst, u32 count) in vdec_get_src_buffer() argument
705 vpu_skip_frame(inst, count - 1); in vdec_get_src_buffer()
707 return vpu_next_src_buf(inst); in vdec_get_src_buffer()
710 static int vdec_frame_decoded(struct vpu_inst *inst, void *arg) in vdec_frame_decoded() argument
712 struct vdec_t *vdec = inst->priv; in vdec_frame_decoded()
722 vpu_inst_lock(inst); in vdec_frame_decoded()
725 dev_err(inst->dev, "[%d] decoded invalid frame[%d]\n", inst->id, info->id); in vdec_frame_decoded()
730 src_buf = vdec_get_src_buffer(inst, info->consumed_count); in vdec_frame_decoded()
734 v4l2_m2m_src_buf_remove(inst->fh.m2m_ctx); in vdec_frame_decoded()
742 dev_info(inst->dev, "[%d] buf[%d] has been decoded\n", inst->id, info->id); in vdec_frame_decoded()
748 cur_fmt = vpu_get_format(inst, inst->cap_format.type); in vdec_frame_decoded()
755 dev_dbg(inst->dev, "[%d][OUTPUT TS]%32lld\n", inst->id, vbuf->vb2_buf.timestamp); in vdec_frame_decoded()
761 vpu_inst_unlock(inst); in vdec_frame_decoded()
766 static struct vpu_vb2_buffer *vdec_find_buffer(struct vpu_inst *inst, u32 luma) in vdec_find_buffer() argument
768 struct vdec_t *vdec = inst->priv; in vdec_find_buffer()
781 static void vdec_buf_done(struct vpu_inst *inst, struct vpu_frame_info *frame) in vdec_buf_done() argument
783 struct vdec_t *vdec = inst->priv; in vdec_buf_done()
792 vpu_inst_lock(inst); in vdec_buf_done()
795 vpu_buf = vdec_find_buffer(inst, frame->luma); in vdec_buf_done()
796 vpu_inst_unlock(inst); in vdec_buf_done()
798 dev_err(inst->dev, "[%d] can't find buffer, id = %d, addr = 0x%x\n", in vdec_buf_done()
799 inst->id, frame->id, frame->luma); in vdec_buf_done()
803 dev_dbg(inst->dev, "[%d] frame skip\n", inst->id); in vdec_buf_done()
807 cur_fmt = vpu_get_format(inst, inst->cap_format.type); in vdec_buf_done()
810 dev_err(inst->dev, "[%d] buffer id(%d, %d) dismatch\n", in vdec_buf_done()
811 inst->id, vbuf->vb2_buf.index, frame->id); in vdec_buf_done()
817 dev_err(inst->dev, "[%d] buffer(%d) ready without decoded\n", inst->id, frame->id); in vdec_buf_done()
824 dev_dbg(inst->dev, "[%d][OUTPUT TS]%32lld\n", inst->id, vbuf->vb2_buf.timestamp); in vdec_buf_done()
827 vpu_inst_lock(inst); in vdec_buf_done()
829 vpu_inst_unlock(inst); in vdec_buf_done()
830 dev_dbg(inst->dev, "[%d] decoded : %d, display : %d, sequence : %d\n", in vdec_buf_done()
831 inst->id, vdec->decoded_frame_count, vdec->display_frame_count, vdec->sequence); in vdec_buf_done()
834 static void vdec_stop_done(struct vpu_inst *inst) in vdec_stop_done() argument
836 struct vdec_t *vdec = inst->priv; in vdec_stop_done()
838 vpu_inst_lock(inst); in vdec_stop_done()
839 vdec_update_state(inst, VPU_CODEC_STATE_DEINIT, 0); in vdec_stop_done()
853 inst->total_input_count = 0; in vdec_stop_done()
854 vpu_inst_unlock(inst); in vdec_stop_done()
857 static bool vdec_check_source_change(struct vpu_inst *inst) in vdec_check_source_change() argument
859 struct vdec_t *vdec = inst->priv; in vdec_check_source_change()
862 if (!inst->fh.m2m_ctx) in vdec_check_source_change()
868 sibling = vpu_helper_find_sibling(inst, inst->cap_format.type, inst->cap_format.pixfmt); in vdec_check_source_change()
870 vdec->codec_info.pixfmt = inst->cap_format.pixfmt; in vdec_check_source_change()
872 if (!vb2_is_streaming(v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx))) in vdec_check_source_change()
874 if (inst->cap_format.pixfmt != vdec->codec_info.pixfmt) in vdec_check_source_change()
876 if (inst->cap_format.width != vdec->codec_info.decoded_width) in vdec_check_source_change()
878 if (inst->cap_format.height != vdec->codec_info.decoded_height) in vdec_check_source_change()
880 if (vpu_get_num_buffers(inst, inst->cap_format.type) < inst->min_buffer_cap) in vdec_check_source_change()
882 if (inst->crop.left != vdec->codec_info.offset_x) in vdec_check_source_change()
884 if (inst->crop.top != vdec->codec_info.offset_y) in vdec_check_source_change()
886 if (inst->crop.width != vdec->codec_info.width) in vdec_check_source_change()
888 if (inst->crop.height != vdec->codec_info.height) in vdec_check_source_change()
894 static void vdec_init_fmt(struct vpu_inst *inst) in vdec_init_fmt() argument
896 struct vdec_t *vdec = inst->priv; in vdec_init_fmt()
900 f.type = inst->cap_format.type; in vdec_init_fmt()
908 vpu_try_fmt_common(inst, &f, &inst->cap_format); in vdec_init_fmt()
910 inst->out_format.width = vdec->codec_info.width; in vdec_init_fmt()
911 inst->out_format.height = vdec->codec_info.height; in vdec_init_fmt()
914 static void vdec_init_crop(struct vpu_inst *inst) in vdec_init_crop() argument
916 struct vdec_t *vdec = inst->priv; in vdec_init_crop()
918 inst->crop.left = vdec->codec_info.offset_x; in vdec_init_crop()
919 inst->crop.top = vdec->codec_info.offset_y; in vdec_init_crop()
920 inst->crop.width = vdec->codec_info.width; in vdec_init_crop()
921 inst->crop.height = vdec->codec_info.height; in vdec_init_crop()
924 static void vdec_init_mbi(struct vpu_inst *inst) in vdec_init_mbi() argument
926 struct vdec_t *vdec = inst->priv; in vdec_init_mbi()
935 static void vdec_init_dcp(struct vpu_inst *inst) in vdec_init_dcp() argument
937 struct vdec_t *vdec = inst->priv; in vdec_init_dcp()
953 static int vdec_alloc_fs_buffer(struct vpu_inst *inst, struct vdec_fs_info *fs) in vdec_alloc_fs_buffer() argument
969 return vpu_alloc_dma(inst->core, buffer); in vdec_alloc_fs_buffer()
972 static void vdec_alloc_fs(struct vpu_inst *inst, struct vdec_fs_info *fs) in vdec_alloc_fs() argument
977 ret = vdec_alloc_fs_buffer(inst, fs); in vdec_alloc_fs()
996 static int vdec_response_fs(struct vpu_inst *inst, struct vdec_fs_info *fs) in vdec_response_fs() argument
1010 ret = vpu_session_alloc_fs(inst, &info); in vdec_response_fs()
1018 static int vdec_response_frame_abnormal(struct vpu_inst *inst) in vdec_response_frame_abnormal() argument
1020 struct vdec_t *vdec = inst->priv; in vdec_response_frame_abnormal()
1030 ret = vpu_session_alloc_fs(inst, &info); in vdec_response_frame_abnormal()
1038 static int vdec_response_frame(struct vpu_inst *inst, struct vb2_v4l2_buffer *vbuf) in vdec_response_frame() argument
1040 struct vdec_t *vdec = inst->priv; in vdec_response_frame()
1045 if (inst->state != VPU_CODEC_STATE_ACTIVE) in vdec_response_frame()
1058 dev_err(inst->dev, "[%d] repeat alloc fs %d\n", in vdec_response_frame()
1059 inst->id, vbuf->vb2_buf.index); in vdec_response_frame()
1063 dev_dbg(inst->dev, "[%d] state = %s, alloc fs %d, tag = 0x%x\n", in vdec_response_frame()
1064 inst->id, vpu_codec_state_name(inst->state), vbuf->vb2_buf.index, vdec->seq_tag); in vdec_response_frame()
1072 info.luma_size = inst->cap_format.sizeimage[0]; in vdec_response_frame()
1077 info.chromau_size = inst->cap_format.sizeimage[1]; in vdec_response_frame()
1078 info.bytesperline = inst->cap_format.bytesperline[0]; in vdec_response_frame()
1079 ret = vpu_session_alloc_fs(inst, &info); in vdec_response_frame()
1094 static void vdec_response_fs_request(struct vpu_inst *inst, bool force) in vdec_response_fs_request() argument
1096 struct vdec_t *vdec = inst->priv; in vdec_response_fs_request()
1102 vdec_response_frame_abnormal(inst); in vdec_response_fs_request()
1107 ret = vpu_process_capture_buffer(inst); in vdec_response_fs_request()
1115 if (vdec_response_fs(inst, &vdec->mbi)) in vdec_response_fs_request()
1121 if (vdec_response_fs(inst, &vdec->dcp)) in vdec_response_fs_request()
1128 static void vdec_response_fs_release(struct vpu_inst *inst, u32 id, u32 tag) in vdec_response_fs_release() argument
1135 vpu_session_release_fs(inst, &info); in vdec_response_fs_release()
1138 static void vdec_recycle_buffer(struct vpu_inst *inst, struct vb2_v4l2_buffer *vbuf) in vdec_recycle_buffer() argument
1140 if (!inst->fh.m2m_ctx) in vdec_recycle_buffer()
1144 if (vpu_find_buf_by_idx(inst, vbuf->vb2_buf.type, vbuf->vb2_buf.index)) in vdec_recycle_buffer()
1146 v4l2_m2m_buf_queue(inst->fh.m2m_ctx, vbuf); in vdec_recycle_buffer()
1149 static void vdec_clear_slots(struct vpu_inst *inst) in vdec_clear_slots() argument
1151 struct vdec_t *vdec = inst->priv; in vdec_clear_slots()
1163 vpu_trace(inst->dev, "clear slot %d\n", i); in vdec_clear_slots()
1164 vdec_response_fs_release(inst, i, vpu_buf->tag); in vdec_clear_slots()
1165 vdec_recycle_buffer(inst, vbuf); in vdec_clear_slots()
1171 static void vdec_event_seq_hdr(struct vpu_inst *inst, struct vpu_dec_codec_info *hdr) in vdec_event_seq_hdr() argument
1173 struct vdec_t *vdec = inst->priv; in vdec_event_seq_hdr()
1175 vpu_inst_lock(inst); in vdec_event_seq_hdr()
1178 vpu_trace(inst->dev, "[%d] %d x %d, crop : (%d, %d) %d x %d, %d, %d\n", in vdec_event_seq_hdr()
1179 inst->id, in vdec_event_seq_hdr()
1188 inst->min_buffer_cap = hdr->num_ref_frms + hdr->num_dpb_frms; in vdec_event_seq_hdr()
1189 vdec->is_source_changed = vdec_check_source_change(inst); in vdec_event_seq_hdr()
1190 vdec_init_fmt(inst); in vdec_event_seq_hdr()
1191 vdec_init_crop(inst); in vdec_event_seq_hdr()
1192 vdec_init_mbi(inst); in vdec_event_seq_hdr()
1193 vdec_init_dcp(inst); in vdec_event_seq_hdr()
1197 vdec_update_state(inst, VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE, 0); in vdec_event_seq_hdr()
1199 vdec_handle_resolution_change(inst); in vdec_event_seq_hdr()
1204 vdec_response_fs_request(inst, true); in vdec_event_seq_hdr()
1205 vpu_trace(inst->dev, "[%d] seq tag change: %d -> %d\n", in vdec_event_seq_hdr()
1206 inst->id, vdec->seq_tag, vdec->codec_info.tag); in vdec_event_seq_hdr()
1210 vpu_inst_unlock(inst); in vdec_event_seq_hdr()
1213 static void vdec_event_resolution_change(struct vpu_inst *inst) in vdec_event_resolution_change() argument
1215 struct vdec_t *vdec = inst->priv; in vdec_event_resolution_change()
1217 vpu_trace(inst->dev, "[%d]\n", inst->id); in vdec_event_resolution_change()
1218 vpu_inst_lock(inst); in vdec_event_resolution_change()
1222 vdec_clear_slots(inst); in vdec_event_resolution_change()
1223 vdec_init_mbi(inst); in vdec_event_resolution_change()
1224 vdec_init_dcp(inst); in vdec_event_resolution_change()
1226 vdec_update_state(inst, VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE, 0); in vdec_event_resolution_change()
1228 vdec_handle_resolution_change(inst); in vdec_event_resolution_change()
1231 vpu_inst_unlock(inst); in vdec_event_resolution_change()
1234 static void vdec_event_req_fs(struct vpu_inst *inst, struct vpu_fs_info *fs) in vdec_event_req_fs() argument
1236 struct vdec_t *vdec = inst->priv; in vdec_event_req_fs()
1241 vpu_inst_lock(inst); in vdec_event_req_fs()
1257 vdec_alloc_fs(inst, &vdec->mbi); in vdec_event_req_fs()
1258 vdec_alloc_fs(inst, &vdec->dcp); in vdec_event_req_fs()
1260 vdec_response_fs_request(inst, false); in vdec_event_req_fs()
1262 vpu_inst_unlock(inst); in vdec_event_req_fs()
1265 static void vdec_evnet_rel_fs(struct vpu_inst *inst, struct vpu_fs_info *fs) in vdec_evnet_rel_fs() argument
1267 struct vdec_t *vdec = inst->priv; in vdec_evnet_rel_fs()
1276 if (fs->id >= vpu_get_num_buffers(inst, inst->cap_format.type)) { in vdec_evnet_rel_fs()
1277 dev_err(inst->dev, "[%d] invalid fs(%d) to release\n", inst->id, fs->id); in vdec_evnet_rel_fs()
1281 vpu_inst_lock(inst); in vdec_evnet_rel_fs()
1286 dev_dbg(inst->dev, "[%d] fs[%d] has bee released\n", inst->id, fs->id); in vdec_evnet_rel_fs()
1292 dev_dbg(inst->dev, "[%d] frame skip\n", inst->id); in vdec_evnet_rel_fs()
1296 vdec_response_fs_release(inst, fs->id, vpu_buf->tag); in vdec_evnet_rel_fs()
1298 vdec_recycle_buffer(inst, vbuf); in vdec_evnet_rel_fs()
1301 vpu_process_capture_buffer(inst); in vdec_evnet_rel_fs()
1304 vpu_inst_unlock(inst); in vdec_evnet_rel_fs()
1307 static void vdec_event_eos(struct vpu_inst *inst) in vdec_event_eos() argument
1309 struct vdec_t *vdec = inst->priv; in vdec_event_eos()
1311 vpu_trace(inst->dev, "[%d] input : %d, decoded : %d, display : %d, sequence : %d\n", in vdec_event_eos()
1312 inst->id, in vdec_event_eos()
1317 vpu_inst_lock(inst); in vdec_event_eos()
1320 inst->min_buffer_cap = VDEC_MIN_BUFFER_CAP; in vdec_event_eos()
1321 vdec_set_last_buffer_dequeued(inst); in vdec_event_eos()
1322 vpu_inst_unlock(inst); in vdec_event_eos()
1325 static void vdec_event_notify(struct vpu_inst *inst, u32 event, void *data) in vdec_event_notify() argument
1329 vdec_event_seq_hdr(inst, data); in vdec_event_notify()
1332 vdec_event_resolution_change(inst); in vdec_event_notify()
1335 vdec_event_req_fs(inst, data); in vdec_event_notify()
1338 vdec_evnet_rel_fs(inst, data); in vdec_event_notify()
1341 vdec_event_eos(inst); in vdec_event_notify()
1348 static int vdec_process_output(struct vpu_inst *inst, struct vb2_buffer *vb) in vdec_process_output() argument
1350 struct vdec_t *vdec = inst->priv; in vdec_process_output()
1357 dev_dbg(inst->dev, "[%d] dec output [%d] %d : %ld\n", in vdec_process_output()
1358 inst->id, vbuf->sequence, vb->index, vb2_get_plane_payload(vb, 0)); in vdec_process_output()
1360 if (inst->state == VPU_CODEC_STATE_DEINIT) in vdec_process_output()
1365 if (inst->state == VPU_CODEC_STATE_STARTED) in vdec_process_output()
1366 vdec_update_state(inst, VPU_CODEC_STATE_ACTIVE, 0); in vdec_process_output()
1368 ret = vpu_iface_get_stream_buffer_desc(inst, &desc); in vdec_process_output()
1372 free_space = vpu_helper_get_free_space(inst); in vdec_process_output()
1377 ret = vpu_iface_input_frame(inst, vb); in vdec_process_output()
1381 dev_dbg(inst->dev, "[%d][INPUT TS]%32lld\n", inst->id, vb->timestamp); in vdec_process_output()
1385 vdec_drain(inst); in vdec_process_output()
1390 static int vdec_process_capture(struct vpu_inst *inst, struct vb2_buffer *vb) in vdec_process_capture() argument
1392 struct vdec_t *vdec = inst->priv; in vdec_process_capture()
1396 if (inst->state == VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE) in vdec_process_capture()
1401 ret = vdec_response_frame(inst, vbuf); in vdec_process_capture()
1404 v4l2_m2m_dst_buf_remove_by_buf(inst->fh.m2m_ctx, vbuf); in vdec_process_capture()
1408 static void vdec_on_queue_empty(struct vpu_inst *inst, u32 type) in vdec_on_queue_empty() argument
1410 struct vdec_t *vdec = inst->priv; in vdec_on_queue_empty()
1415 vdec_handle_resolution_change(inst); in vdec_on_queue_empty()
1417 vdec_set_last_buffer_dequeued(inst); in vdec_on_queue_empty()
1420 static void vdec_abort(struct vpu_inst *inst) in vdec_abort() argument
1422 struct vdec_t *vdec = inst->priv; in vdec_abort()
1426 vpu_trace(inst->dev, "[%d] state = %s\n", inst->id, vpu_codec_state_name(inst->state)); in vdec_abort()
1429 vpu_iface_add_scode(inst, SCODE_PADDING_ABORT); in vdec_abort()
1431 vpu_iface_set_decode_params(inst, &vdec->params, 1); in vdec_abort()
1433 vpu_session_abort(inst); in vdec_abort()
1435 ret = vpu_iface_get_stream_buffer_desc(inst, &desc); in vdec_abort()
1437 vpu_iface_update_stream_buffer(inst, desc.rptr, 1); in vdec_abort()
1439 vpu_session_rst_buf(inst); in vdec_abort()
1440 vpu_trace(inst->dev, "[%d] input : %d, decoded : %d, display : %d, sequence : %d\n", in vdec_abort()
1441 inst->id, in vdec_abort()
1455 inst->extra_size = 0; in vdec_abort()
1458 static void vdec_stop(struct vpu_inst *inst, bool free) in vdec_stop() argument
1460 struct vdec_t *vdec = inst->priv; in vdec_stop()
1462 vdec_clear_slots(inst); in vdec_stop()
1463 if (inst->state != VPU_CODEC_STATE_DEINIT) in vdec_stop()
1464 vpu_session_stop(inst); in vdec_stop()
1469 vpu_free_dma(&inst->stream_buffer); in vdec_stop()
1471 vdec_update_state(inst, VPU_CODEC_STATE_DEINIT, 1); in vdec_stop()
1475 static void vdec_release(struct vpu_inst *inst) in vdec_release() argument
1477 if (inst->id != VPU_INST_NULL_ID) in vdec_release()
1478 vpu_trace(inst->dev, "[%d]\n", inst->id); in vdec_release()
1479 vdec_stop(inst, true); in vdec_release()
1482 static void vdec_cleanup(struct vpu_inst *inst) in vdec_cleanup() argument
1486 if (!inst) in vdec_cleanup()
1489 vdec = inst->priv; in vdec_cleanup()
1491 inst->priv = NULL; in vdec_cleanup()
1492 vfree(inst); in vdec_cleanup()
1501 static int vdec_start(struct vpu_inst *inst) in vdec_start() argument
1503 struct vdec_t *vdec = inst->priv; in vdec_start()
1507 if (inst->state != VPU_CODEC_STATE_DEINIT) in vdec_start()
1510 vpu_trace(inst->dev, "[%d]\n", inst->id); in vdec_start()
1513 ret = vpu_alloc_dma(inst->core, &vdec->udata); in vdec_start()
1515 dev_err(inst->dev, "[%d] alloc udata fail\n", inst->id); in vdec_start()
1520 if (!inst->stream_buffer.virt) { in vdec_start()
1521 stream_buffer_size = vpu_iface_get_stream_buffer_size(inst->core); in vdec_start()
1523 inst->stream_buffer.length = stream_buffer_size; in vdec_start()
1524 ret = vpu_alloc_dma(inst->core, &inst->stream_buffer); in vdec_start()
1526 dev_err(inst->dev, "[%d] alloc stream buffer fail\n", inst->id); in vdec_start()
1529 inst->use_stream_buffer = true; in vdec_start()
1533 if (inst->use_stream_buffer) in vdec_start()
1534 vpu_iface_config_stream_buffer(inst, &inst->stream_buffer); in vdec_start()
1535 vpu_iface_init_instance(inst); in vdec_start()
1538 ret = vpu_iface_set_decode_params(inst, &vdec->params, 0); in vdec_start()
1540 dev_err(inst->dev, "[%d] set decode params fail\n", inst->id); in vdec_start()
1545 ret = vpu_session_start(inst); in vdec_start()
1547 dev_err(inst->dev, "[%d] start fail\n", inst->id); in vdec_start()
1551 vdec_update_state(inst, VPU_CODEC_STATE_STARTED, 0); in vdec_start()
1556 vpu_free_dma(&inst->stream_buffer); in vdec_start()
1560 static int vdec_start_session(struct vpu_inst *inst, u32 type) in vdec_start_session() argument
1562 struct vdec_t *vdec = inst->priv; in vdec_start_session()
1567 vdec_stop(inst, false); in vdec_start_session()
1568 if (inst->state == VPU_CODEC_STATE_DEINIT) { in vdec_start_session()
1569 ret = vdec_start(inst); in vdec_start_session()
1576 vdec_update_state(inst, vdec->state, 1); in vdec_start_session()
1578 vpu_process_output_buffer(inst); in vdec_start_session()
1580 vdec_cmd_start(inst); in vdec_start_session()
1582 if (inst->state == VPU_CODEC_STATE_ACTIVE) in vdec_start_session()
1583 vdec_response_fs_request(inst, false); in vdec_start_session()
1588 static int vdec_stop_session(struct vpu_inst *inst, u32 type) in vdec_stop_session() argument
1590 struct vdec_t *vdec = inst->priv; in vdec_stop_session()
1592 if (inst->state == VPU_CODEC_STATE_DEINIT) in vdec_stop_session()
1596 vdec_update_state(inst, VPU_CODEC_STATE_SEEK, 0); in vdec_stop_session()
1599 if (inst->state != VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE) { in vdec_stop_session()
1600 vdec_abort(inst); in vdec_stop_session()
1603 vdec_clear_slots(inst); in vdec_stop_session()
1609 static int vdec_get_debug_info(struct vpu_inst *inst, char *str, u32 size, u32 i) in vdec_get_debug_info() argument
1611 struct vdec_t *vdec = inst->priv; in vdec_get_debug_info()
1694 struct vpu_inst *inst = to_inst(file); in vdec_init() local
1703 vdec_s_fmt(file, &inst->fh, &f); in vdec_init()
1711 vdec_s_fmt(file, &inst->fh, &f); in vdec_init()
1716 struct vpu_inst *inst; in vdec_open() local
1720 inst = vzalloc(sizeof(*inst)); in vdec_open()
1721 if (!inst) in vdec_open()
1726 vfree(inst); in vdec_open()
1730 inst->ops = &vdec_inst_ops; in vdec_open()
1731 inst->formats = vdec_formats; in vdec_open()
1732 inst->type = VPU_CORE_TYPE_DEC; in vdec_open()
1733 inst->priv = vdec; in vdec_open()
1735 ret = vpu_v4l2_open(file, inst); in vdec_open()
1741 inst->min_buffer_cap = VDEC_MIN_BUFFER_CAP; in vdec_open()
1742 inst->min_buffer_out = VDEC_MIN_BUFFER_OUT; in vdec_open()