static void ddl_channel_end_callback(struct ddl_context *ddl_context)
{
	struct ddl_client_context *ddl;

	DDL_MSG_MED("ddl_channel_end_callback");
	ddl = ddl_get_current_ddl_client_for_command(ddl_context,
			DDL_CMD_CHANNEL_END);
	if (ddl) {
		ddl->cmd_state = DDL_CMD_INVALID;
		if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_CHEND)) {
			DDL_MSG_LOW("STATE-CRITICAL-CHEND");
		} else {
			DDL_MSG_LOW("CH_END_DONE");
			ddl_release_client_internal_buffers(ddl);
			ddl_context->ddl_callback(VCD_EVT_RESP_STOP,
				VCD_S_SUCCESS, NULL, 0, (u32 *)ddl,
				ddl->client_data);
			DDL_MSG_LOW("ddl_state_transition: %s ~~>"
				"DDL_CLIENT_OPEN",
				ddl_get_state_string(ddl->client_state));
			ddl->client_state = DDL_CLIENT_OPEN;
		}
		ddl_release_command_channel(ddl_context,
			ddl->command_channel);
	}
}
static u32 ddl_encoder_seq_done_callback(struct ddl_context_type *p_ddl_context,
	struct ddl_client_context_type *p_ddl)
{
	struct ddl_encoder_data_type *p_encoder;

	DDL_MSG_MED("ddl_encoder_seq_done_callback");
	if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-INITCODEC");
		ddl_client_fatal_cb(p_ddl);
		return TRUE;
	}
	p_ddl->e_cmd_state = DDL_CMD_INVALID;
	DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_WAIT_FOR_FRAME",
	ddl_get_state_string(p_ddl->e_client_state));
	p_ddl->e_client_state = DDL_CLIENT_WAIT_FOR_FRAME;
	DDL_MSG_LOW("INIT_CODEC_DONE");
	p_encoder = &p_ddl->codec_data.encoder;
	vidc_1080p_get_encoder_sequence_header_size(
		&p_encoder->n_seq_header_length);
	p_ddl_context->ddl_callback(VCD_EVT_RESP_START, VCD_S_SUCCESS,
		NULL, 0, (u32 *) p_ddl, p_ddl->p_client_data);
	ddl_release_command_channel(p_ddl_context,
		p_ddl->n_command_channel);
	return TRUE;
}
static u32 ddl_encoder_seq_done_callback(struct ddl_context *ddl_context,
	struct ddl_client_context *ddl)
{
	struct ddl_encoder_data *encoder;

	DDL_MSG_MED("ddl_encoder_seq_done_callback");
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-INITCODEC");
		ddl_client_fatal_cb(ddl);
		return true;
	}
	if (vidc_msg_timing)
		ddl_calc_core_proc_time(__func__, ENC_OP_TIME);
	ddl->cmd_state = DDL_CMD_INVALID;
	DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_WAIT_FOR_FRAME",
	ddl_get_state_string(ddl->client_state));
	ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME;
	DDL_MSG_LOW("INIT_CODEC_DONE");
	encoder = &ddl->codec_data.encoder;
	vidc_1080p_get_encoder_sequence_header_size(
		&encoder->seq_header_length);
	if ((encoder->codec.codec == VCD_CODEC_H264) &&
		(encoder->profile.profile == VCD_PROFILE_H264_BASELINE))
		if ((encoder->seq_header.align_virtual_addr) &&
			(encoder->seq_header_length > 6))
			encoder->seq_header.align_virtual_addr[6] = 0xC0;
	ddl_context->ddl_callback(VCD_EVT_RESP_START, VCD_S_SUCCESS,
		NULL, 0, (u32 *) ddl, ddl->client_data);
	ddl_release_command_channel(ddl_context,
		ddl->command_channel);
	return true;
}
static u32 ddl_dpb_buffers_set_done_callback(
	struct ddl_context *ddl_context)
{
	struct ddl_client_context *ddl;
	u32 channel_inst_id, ret_status = true;

	DDL_MSG_MED("ddl_dpb_buffers_set_done_callback");
	vidc_1080p_get_returned_channel_inst_id(&channel_inst_id);
	vidc_1080p_clear_returned_channel_inst_id();
	ddl = ddl_get_current_ddl_client_for_command(ddl_context,
			DDL_CMD_DECODE_SET_DPB);
	if (ddl) {
		ddl->cmd_state = DDL_CMD_INVALID;
		if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPBDONE)) {
			DDL_MSG_ERROR("STATE-CRITICAL-DPBDONE");
			ddl_client_fatal_cb(ddl);
		} else {
			DDL_MSG_LOW("INTR_DPBDONE");
			DDL_MSG_LOW("ddl_state_transition: %s ~~>"
				"DDL_CLIENT_WAIT_FOR_FRAME",
				ddl_get_state_string(ddl->client_state));
			if (vidc_msg_timing) {
				ddl_calc_core_proc_time(__func__, DEC_OP_TIME);
				ddl_reset_core_time_variables(DEC_OP_TIME);
			}
			ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME;
			ddl_vidc_decode_frame_run(ddl);
			ret_status = false;
		}
	}
	return ret_status;
}
static void ddl_sys_init_done_callback(struct ddl_context *ddl_context,
	u32 fw_size)
{
	u32 vcd_status = VCD_S_SUCCESS;
	u8 *fw_ver;

	DDL_MSG_MED("ddl_sys_init_done_callback");
	if (!DDLCOMMAND_STATE_IS(ddl_context, DDL_CMD_DMA_INIT)) {
		DDL_MSG_ERROR("UNKNOWN_SYS_INIT_DONE");
	} else {
		ddl_context->cmd_state = DDL_CMD_INVALID;
		DDL_MSG_LOW("SYS_INIT_DONE");
		vidc_1080p_get_fw_version(&ddl_context->fw_version);
		fw_ver = (u8 *)&ddl_context->fw_version;
		DDL_MSG_ERROR("fw_version %x:%x:20%x",
			fw_ver[1]&0xFF, fw_ver[0]&0xFF, fw_ver[2]&0xFF);
		if (ddl_context->fw_memory_size >= fw_size) {
			ddl_context->device_state = DDL_DEVICE_INITED;
			vcd_status = VCD_S_SUCCESS;
		} else
			vcd_status = VCD_ERR_FAIL;
		ddl_context->ddl_callback(VCD_EVT_RESP_DEVICE_INIT,
			vcd_status, NULL, 0, NULL,
			ddl_context->client_data);
		DDL_IDLE(ddl_context);
	}
}
static void ddl_fw_status_done_callback(struct ddl_context_type *p_ddl_context)
{
	DDL_MSG_MED("ddl_fw_status_done_callback");
	if (!DDLCOMMAND_STATE_IS(p_ddl_context, DDL_CMD_DMA_INIT)) {
		DDL_MSG_ERROR("UNKWN_DMADONE");
	} else {
		DDL_MSG_LOW("FW_STATUS_DONE");
		vidc_1080p_set_host2risc_cmd(VIDC_1080P_HOST2RISC_CMD_SYS_INIT,
			p_ddl_context->n_fw_ctxt_memory_size, 0, 0, 0);
	}
}
static void ddl_edfu_callback(struct ddl_context *ddl_context)
{
	struct ddl_client_context *ddl;
	u32 channel_inst_id;

	DDL_MSG_MED("ddl_edfu_callback");
	vidc_1080p_get_returned_channel_inst_id(&channel_inst_id);
	vidc_1080p_clear_returned_channel_inst_id();
	ddl = ddl_get_current_ddl_client_for_channel_id(ddl_context,
			ddl_context->response_cmd_ch_id);
	if (ddl) {
		if (ddl->cmd_state != DDL_CMD_ENCODE_FRAME)
			DDL_MSG_LOW("UNKWN_EDFU");
	}
}
static u32 ddl_channel_set_callback(struct ddl_context *ddl_context,
	u32 instance_id)
{
	struct ddl_client_context *ddl;
	u32 ret = false;

	DDL_MSG_MED("ddl_channel_open_callback");
	ddl = ddl_get_current_ddl_client_for_command(ddl_context,
			DDL_CMD_CHANNEL_SET);
	if (ddl) {
		ddl->cmd_state = DDL_CMD_INVALID;
		if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_CHDONE)) {
			DDL_MSG_ERROR("STATE-CRITICAL-CHSET");
			ddl_release_command_channel(ddl_context,
			ddl->command_channel);
		} else {
			DDL_MSG_LOW("CH_SET_DONE");
			DDL_MSG_LOW("ddl_state_transition: %s ~~>"
				"DDL_CLIENT_WAIT_FOR_INITCODEC",
				ddl_get_state_string(ddl->client_state));
			ddl->client_state = DDL_CLIENT_WAIT_FOR_INITCODEC;
			ddl->instance_id = instance_id;
			if (ddl->decoding) {
				if (vidc_msg_timing)
					ddl_calc_core_proc_time(__func__,
						DEC_OP_TIME);
				if (ddl->codec_data.decoder.header_in_start)
					ddl_vidc_decode_init_codec(ddl);
				else {
					ddl_context->ddl_callback(
						VCD_EVT_RESP_START,
						VCD_S_SUCCESS, NULL, 0,
						(u32 *)ddl,
						ddl->client_data);
					ddl_release_command_channel(
						ddl_context,
						ddl->command_channel);
					ret = true;
				}
			} else
				ddl_vidc_encode_init_codec(ddl);
		}
	}
	return ret;
}
static u32 ddl_channel_set_callback(struct ddl_context_type *p_ddl_context,
	u32 n_instance_id)
{
	struct ddl_client_context_type *p_ddl;
	u32 b_ret = FALSE;

	DDL_MSG_MED("ddl_channel_open_callback");
	p_ddl = ddl_get_current_ddl_client_for_command(p_ddl_context,
			DDL_CMD_CHANNEL_SET);
	if (p_ddl) {
		p_ddl->e_cmd_state = DDL_CMD_INVALID;
		if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_CHDONE)) {
			DDL_MSG_ERROR("STATE-CRITICAL-CHSET");
			ddl_release_command_channel(p_ddl_context,
			p_ddl->n_command_channel);
		} else {
			DDL_MSG_LOW("CH_SET_DONE");
			DDL_MSG_LOW("ddl_state_transition: %s ~~>\
				DDL_CLIENT_WAIT_FOR_INITCODEC",
				ddl_get_state_string(p_ddl->e_client_state));
			p_ddl->e_client_state = DDL_CLIENT_WAIT_FOR_INITCODEC;
			p_ddl->n_channel_id = n_instance_id;
			if (p_ddl->b_decoding) {
				if (p_ddl->codec_data.decoder.b_header_in_start)
					ddl_vidc_decode_init_codec(p_ddl);
				else {
					p_ddl_context->ddl_callback(
						VCD_EVT_RESP_START,
						VCD_S_SUCCESS, NULL, 0,
						(u32 *)p_ddl,
						p_ddl->p_client_data);
					ddl_release_command_channel(
						p_ddl_context,
						p_ddl->n_command_channel);
					b_ret = TRUE;
				}
			} else
				ddl_vidc_encode_init_codec(p_ddl);
		}
	}
	return b_ret;
}
static void ddl_sys_init_done_callback(struct ddl_context_type *p_ddl_context,
	u32 n_fw_size)
{
	u32 vcd_status = VCD_S_SUCCESS;

	DDL_MSG_MED("ddl_sys_init_done_callback");
	if (!DDLCOMMAND_STATE_IS(p_ddl_context, DDL_CMD_DMA_INIT)) {
		DDL_MSG_ERROR("UNKNOWN_SYS_INIT_DONE");
	} else {
		p_ddl_context->e_cmd_state = DDL_CMD_INVALID;
		DDL_MSG_LOW("SYS_INIT_DONE");
		vidc_1080p_get_fw_version(&p_ddl_context->n_fw_version);
		if (p_ddl_context->n_fw_memory_size >= n_fw_size) {
			p_ddl_context->n_device_state = DDL_DEVICE_INITED;
			vcd_status = VCD_S_SUCCESS;
		} else
			vcd_status = VCD_ERR_FAIL;
		p_ddl_context->ddl_callback(VCD_EVT_RESP_DEVICE_INIT,
			vcd_status, NULL, 0, NULL,
			p_ddl_context->p_client_data);
		DDL_IDLE(p_ddl_context);
	}
}
static void ddl_encoder_frame_run_callback(
	struct ddl_client_context *ddl)
{
	struct ddl_context *ddl_context = ddl->ddl_context;
	struct ddl_encoder_data *encoder =
		&(ddl->codec_data.encoder);
	struct vcd_frame_data *output_frame =
		&(ddl->output_frame.vcd_frm);
	u32 bottom_frame_tag;

	DDL_MSG_MED("ddl_encoder_frame_run_callback");
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE) &&
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-ENCFRMRUN");
		ddl_client_fatal_cb(ddl);
	} else {
		if (vidc_msg_timing)
			ddl_calc_core_proc_time(__func__, ENC_OP_TIME);
		DDL_MSG_LOW("ENC_FRM_RUN_DONE");
		ddl->cmd_state = DDL_CMD_INVALID;
		vidc_1080p_get_encode_frame_info(&encoder->enc_frame_info);
		vidc_sm_get_frame_tags(&ddl->shared_mem
			[ddl->command_channel],
			&output_frame->ip_frm_tag, &bottom_frame_tag);

		if (encoder->meta_data_enable_flag)
			vidc_sm_get_metadata_status(&ddl->shared_mem
				[ddl->command_channel],
				&encoder->enc_frame_info.meta_data_exists);

		if (encoder->enc_frame_info.enc_frame_size ||
			(encoder->enc_frame_info.enc_frame ==
			VIDC_1080P_ENCODE_FRAMETYPE_SKIPPED) ||
			DDLCLIENT_STATE_IS(ddl,
			DDL_CLIENT_WAIT_FOR_EOS_DONE)) {
			u8 *input_buffer_address = NULL;
			output_frame->data_len =
				encoder->enc_frame_info.enc_frame_size;
			output_frame->flags |= VCD_FRAME_FLAG_ENDOFFRAME;
			ddl_get_encoded_frame(output_frame,
				encoder->codec.codec,
				encoder->enc_frame_info.enc_frame);
			ddl_process_encoder_metadata(ddl);
			ddl_vidc_encode_dynamic_property(ddl, false);
			ddl->input_frame.frm_trans_end = false;
			input_buffer_address = ddl_context->dram_base_a.\
				align_physical_addr +
				encoder->enc_frame_info.enc_luma_address;
			ddl_get_input_frame_from_pool(ddl,
				input_buffer_address);
			ddl_context->ddl_callback(VCD_EVT_RESP_INPUT_DONE,
				VCD_S_SUCCESS, &(ddl->input_frame),
				sizeof(struct ddl_frame_data_tag),
				(u32 *)ddl, ddl->client_data);
			ddl->output_frame.frm_trans_end =
				DDLCLIENT_STATE_IS(ddl,
				DDL_CLIENT_WAIT_FOR_EOS_DONE) ? false : true;
			ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE,
				VCD_S_SUCCESS, &(ddl->output_frame),
				sizeof(struct ddl_frame_data_tag),
				(u32 *)ddl, ddl->client_data);

			if (DDLCLIENT_STATE_IS(ddl,
				DDL_CLIENT_WAIT_FOR_EOS_DONE) &&
				encoder->i_period.b_frames) {
				if ((ddl->extra_output_buf_count < 0) ||
					(ddl->extra_output_buf_count >
					encoder->i_period.b_frames)) {
					DDL_MSG_ERROR("Invalid B frame output"
								"buffer index");
				} else {
					struct vidc_1080p_enc_frame_start_param
						enc_param;
					ddl->output_frame = ddl->\
					extra_output_frame[ddl->\
					extra_output_buf_count];
					ddl->\
					extra_output_buf_count--;
					output_frame =
					&ddl->output_frame.\
					vcd_frm;
					memset(&enc_param, 0,
						sizeof(enc_param));
					enc_param.cmd_seq_num =
						++ddl_context->cmd_seq_num;
					enc_param.inst_id = ddl->instance_id;
					enc_param.shared_mem_addr_offset =
					   DDL_ADDR_OFFSET(ddl_context->\
						dram_base_a, ddl->shared_mem
						[ddl->command_channel]);
					enc_param.stream_buffer_addr_offset =
						DDL_OFFSET(ddl_context->\
						dram_base_a.\
						align_physical_addr,
						output_frame->physical);
					enc_param.stream_buffer_size =
					encoder->client_output_buf_req.sz;
					enc_param.encode =
					VIDC_1080P_ENC_TYPE_LAST_FRAME_DATA;
					ddl->cmd_state = DDL_CMD_ENCODE_FRAME;
					ddl_context->vidc_encode_frame_start
						[ddl->command_channel]
						(&enc_param);
				} } else {
				DDL_MSG_LOW("ddl_state_transition: %s ~~>"
					"DDL_CLIENT_WAIT_FOR_FRAME",
					ddl_get_state_string(
					ddl->client_state));
				ddl->client_state =
					DDL_CLIENT_WAIT_FOR_FRAME;
				ddl_release_command_channel(ddl_context,
				ddl->command_channel);
			}
		} else {
			ddl_context->ddl_callback(
				VCD_EVT_RESP_TRANSACTION_PENDING,
				VCD_S_SUCCESS, NULL, 0, (u32 *)ddl,
				ddl->client_data);
			DDL_MSG_LOW("ddl_state_transition: %s ~~>"
				"DDL_CLIENT_WAIT_FOR_FRAME",
			ddl_get_state_string(ddl->client_state));
			ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME;
			ddl_release_command_channel(ddl_context,
			ddl->command_channel);
		}
	}
}
static u32 ddl_decoder_seq_done_callback(struct ddl_context *ddl_context,
	struct ddl_client_context *ddl)
{
	struct ddl_decoder_data *decoder = &ddl->codec_data.decoder;
	struct vidc_1080p_seq_hdr_info seq_hdr_info;
	u32 process_further = true;

	DDL_MSG_MED("ddl_decoder_seq_done_callback");
	if (!ddl->decoding ||
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-HDDONE");
		ddl_client_fatal_cb(ddl);
	} else {
		ddl->cmd_state = DDL_CMD_INVALID;
		DDL_MSG_LOW("ddl_state_transition: %s ~~>"
			"DDL_CLIENT_WAIT_FOR_DPB",
			ddl_get_state_string(ddl->client_state));
		ddl->client_state = DDL_CLIENT_WAIT_FOR_DPB;
		DDL_MSG_LOW("HEADER_DONE");
		vidc_1080p_get_decode_seq_start_result(&seq_hdr_info);
		parse_hdr_size_data(ddl, &seq_hdr_info);
		if (!seq_hdr_info.img_size_x || !seq_hdr_info.img_size_y) {
			DDL_MSG_ERROR("FATAL:ZeroImageSize");
			ddl_client_fatal_cb(ddl);
			return process_further;
		}
		vidc_sm_get_profile_info(&ddl->shared_mem
			[ddl->command_channel],
			&seq_hdr_info.profile, &seq_hdr_info.level);
		ddl_get_dec_profile_level(decoder, seq_hdr_info.profile,
			seq_hdr_info.level);
		ddl_calculate_stride(&decoder->frame_size,
			!decoder->progressive_only);
		decoder->frame_size.scan_lines =
		DDL_ALIGN(decoder->frame_size.height, DDL_TILE_ALIGN_HEIGHT);
		decoder->frame_size.stride =
		DDL_ALIGN(decoder->frame_size.width, DDL_TILE_ALIGN_WIDTH);
		parse_hdr_crop_data(ddl, &seq_hdr_info);
		if (decoder->codec.codec == VCD_CODEC_H264 &&
			seq_hdr_info.level > VIDC_1080P_H264_LEVEL4) {
			DDL_MSG_ERROR("WARNING: H264MaxLevelExceeded : %d",
				seq_hdr_info.level);
		}
		ddl_set_default_decoder_buffer_req(decoder, false);
		if (decoder->header_in_start) {
			decoder->client_frame_size = decoder->frame_size;
			decoder->client_output_buf_req =
				decoder->actual_output_buf_req;
			if ((decoder->frame_size.width *
				decoder->frame_size.height) >=
				 VCD_DDL_WVGA_BUF_SIZE) {
				if ((decoder->actual_output_buf_req.\
					actual_count + 2) < 10)
					decoder->client_output_buf_req.\
						actual_count = 10;
				else
					decoder->client_output_buf_req.\
						actual_count += 2;
			} else
				decoder->client_output_buf_req.\
					actual_count = decoder->\
					actual_output_buf_req.\
					actual_count + 5;
			decoder->client_input_buf_req =
				decoder->actual_input_buf_req;
			ddl_context->ddl_callback(VCD_EVT_RESP_START,
				VCD_S_SUCCESS, NULL, 0, (u32 *) ddl,
				ddl->client_data);
			ddl_release_command_channel(ddl_context,
				ddl->command_channel);
		} else {
			u32 seq_hdr_only_frame = false;
			u32 need_reconfig = true;
			struct vcd_frame_data *input_vcd_frm =
				&ddl->input_frame.vcd_frm;

			if ((input_vcd_frm->flags &
				  VCD_FRAME_FLAG_EOS) ||
				((decoder->frame_size.width ==
				decoder->client_frame_size.width) &&
				(decoder->frame_size.height ==
				decoder->client_frame_size.height) &&
				(decoder->actual_output_buf_req.sz <=
				decoder->client_output_buf_req.sz) &&
				(decoder->actual_output_buf_req.actual_count ==
				 decoder->client_output_buf_req.actual_count) &&
				(decoder->frame_size.scan_lines ==
				decoder->client_frame_size.scan_lines) &&
				(decoder->frame_size.stride ==
				 decoder->client_frame_size.stride)))
					need_reconfig = false;
			if (((input_vcd_frm->flags &
				VCD_FRAME_FLAG_CODECCONFIG) &&
				(!(input_vcd_frm->flags &
				VCD_FRAME_FLAG_SYNCFRAME))) ||
				input_vcd_frm->data_len <=
				seq_hdr_info.dec_frm_size) {
				seq_hdr_only_frame = true;
				input_vcd_frm->offset +=
					seq_hdr_info.dec_frm_size;
				input_vcd_frm->data_len = 0;
				input_vcd_frm->flags |=
					VCD_FRAME_FLAG_CODECCONFIG;
				ddl->input_frame.frm_trans_end =
					!need_reconfig;
				ddl_context->ddl_callback(
					VCD_EVT_RESP_INPUT_DONE,
					VCD_S_SUCCESS, &ddl->input_frame,
					sizeof(struct ddl_frame_data_tag),
					(u32 *) ddl, ddl->client_data);
			} else {
				if (decoder->codec.codec ==
					VCD_CODEC_VC1_RCV) {
					vidc_sm_set_start_byte_number(
						&ddl->shared_mem
						[ddl->command_channel],
						seq_hdr_info.dec_frm_size);
				}
			}
			if (need_reconfig) {
				struct ddl_frame_data_tag *payload =
					&ddl->input_frame;
				u32 payload_size =
					sizeof(struct ddl_frame_data_tag);

				decoder->client_frame_size =
					decoder->frame_size;
				decoder->client_output_buf_req =
					decoder->actual_output_buf_req;
				decoder->client_input_buf_req =
					decoder->actual_input_buf_req;
				if (seq_hdr_only_frame) {
					payload = NULL;
					payload_size = 0;
				}
				ddl_context->ddl_callback(
					VCD_EVT_IND_OUTPUT_RECONFIG,
					VCD_S_SUCCESS, payload,
					payload_size, (u32 *) ddl,
					ddl->client_data);
			}
			if (!need_reconfig && !seq_hdr_only_frame) {
				if (!ddl_vidc_decode_set_buffers(ddl))
					process_further = false;
				else {
					DDL_MSG_ERROR("ddl_vidc_decode_set_"
						"buffers failed");
					ddl_client_fatal_cb(ddl);
				}
			} else
				ddl_release_command_channel(ddl_context,
					ddl->command_channel);
		}
	}
	return process_further;
}
static u32 ddl_decoder_frame_run_callback(struct ddl_client_context *ddl)
{
	struct ddl_context *ddl_context = ddl->ddl_context;
	u32 callback_end = false, ret_status = false;
	u32 eos_present = false, rsl_chg;
	enum vidc_1080p_display_status disp_status;
	DDL_MSG_MED("ddl_decoder_frame_run_callback");
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-DECFRMRUN");
		ddl_client_fatal_cb(ddl);
		ret_status = true;
	} else {
		DDL_MSG_LOW("DEC_FRM_RUN_DONE");
		ddl->cmd_state = DDL_CMD_INVALID;
		get_dec_status(&ddl->codec_data.decoder.dec_disp_info,
			ddl->codec_data.decoder.output_order,
			&disp_status, &rsl_chg);
		ddl_vidc_decode_dynamic_property(ddl, false);
		if (rsl_chg) {
			DDL_MSG_ERROR("DEC_RECONFIG_NOT_SUPPORTED");
			ddl_client_fatal_cb(ddl);
#if (1) //PANTECH Qualcomm SBA Àû¿ë: Case No.517406
			ret_status = true;  
#endif
		} else {
			if ((VCD_FRAME_FLAG_EOS &
				ddl->input_frame.vcd_frm.flags)) {
				callback_end = false;
				eos_present = true;
			}
			if (disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_ONLY ||
				disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY) {
				if (!eos_present)
					callback_end =
					(disp_status ==
					VIDC_1080P_DISPLAY_STATUS_DECODE_ONLY);
				ddl_decoder_input_done_callback(ddl,
					callback_end);
			}
			if (disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY ||
				disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY) {
				if (!eos_present)
					callback_end = (disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY);
				if (ddl_decoder_output_done_callback(
					ddl, callback_end))
					ret_status = true;
			}
			if (!ret_status) {
				if (disp_status ==
					VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY
					|| disp_status ==
					VIDC_1080P_DISPLAY_STATUS_DPB_EMPTY ||
					disp_status ==
					VIDC_1080P_DISPLAY_STATUS_NOOP) {
					ddl_vidc_decode_frame_run(ddl);
				} else if (eos_present)
					ddl_vidc_decode_eos_run(ddl);
				else {
					ddl->client_state =
						DDL_CLIENT_WAIT_FOR_FRAME;
					ddl_release_command_channel(ddl_context,
						ddl->command_channel);
					ret_status = true;
				}
			}
		}
	}
	return ret_status;
}
static u32 ddl_decoder_seq_done_callback(struct ddl_context_type *p_ddl_context,
	struct ddl_client_context_type *p_ddl)
{
	struct ddl_decoder_data_type *p_decoder = &p_ddl->codec_data.decoder;
	struct vidc_1080p_seq_hdr_info_type seq_hdr_info;
	u32 b_process_further = TRUE;

	DDL_MSG_MED("ddl_decoder_seq_done_callback");
	if (!p_ddl->b_decoding ||
		!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-HDDONE");
		ddl_client_fatal_cb(p_ddl);
	} else {
		p_ddl->e_cmd_state = DDL_CMD_INVALID;
		DDL_MSG_LOW("ddl_state_transition: %s ~~>\
			DDL_CLIENT_WAIT_FOR_DPB",\
			ddl_get_state_string(p_ddl->e_client_state));
		p_ddl->e_client_state = DDL_CLIENT_WAIT_FOR_DPB;
		DDL_MSG_LOW("HEADER_DONE");
		vidc_1080p_get_decode_seq_start_result(&seq_hdr_info);
		p_decoder->frame_size.n_width = seq_hdr_info.n_img_size_x;
		p_decoder->frame_size.n_height = seq_hdr_info.n_img_size_y;
		p_decoder->n_min_dpb_num = seq_hdr_info.n_min_num_dpb;
		vidc_sm_get_min_yc_dpb_sizes(
			&p_ddl->shared_mem[p_ddl->n_command_channel],
			&seq_hdr_info.n_min_luma_dpb_size,
			&seq_hdr_info.n_min_chroma_dpb_size);
		p_decoder->n_y_cb_cr_size = seq_hdr_info.n_min_luma_dpb_size +
			seq_hdr_info.n_min_chroma_dpb_size;
		p_decoder->dpb_buf_size.n_size_yuv = p_decoder->n_y_cb_cr_size;
		p_decoder->dpb_buf_size.n_size_y =
			seq_hdr_info.n_min_luma_dpb_size;
		p_decoder->dpb_buf_size.n_size_c =
			seq_hdr_info.n_min_chroma_dpb_size;
		p_decoder->n_progressive_only = 1 - seq_hdr_info.n_progressive;
		if (!seq_hdr_info.n_img_size_x || !seq_hdr_info.n_img_size_y) {
			DDL_MSG_ERROR("FATAL:ZeroImageSize");
			ddl_client_fatal_cb(p_ddl);
			return b_process_further;
		}
		vidc_sm_get_profile_info(&p_ddl->shared_mem
			[p_ddl->n_command_channel],
			&seq_hdr_info.n_profile, &seq_hdr_info.n_level);
		ddl_get_dec_profile_level(p_decoder, seq_hdr_info.n_profile,
			seq_hdr_info.n_level);
		ddl_calculate_stride(&p_decoder->frame_size,
			!p_decoder->n_progressive_only);
		vidc_sm_get_crop_info(
			&p_ddl->shared_mem[p_ddl->n_command_channel],
			&seq_hdr_info.n_crop_left_offset,
			&seq_hdr_info.n_crop_right_offset,
			&seq_hdr_info.n_crop_top_offset,
			&seq_hdr_info.n_crop_bottom_offset);
		seq_hdr_info.n_crop_exists = (seq_hdr_info.n_crop_left_offset ||
			seq_hdr_info.n_crop_right_offset ||
			seq_hdr_info.n_crop_top_offset ||
			seq_hdr_info.n_crop_bottom_offset);
		if (seq_hdr_info.n_crop_exists) {
			p_decoder->frame_size.n_width -=
				seq_hdr_info.n_crop_right_offset +
				seq_hdr_info.n_crop_left_offset;
			p_decoder->frame_size.n_height -=
				seq_hdr_info.n_crop_top_offset +
				seq_hdr_info.n_crop_bottom_offset;
		}
		ddl_set_default_decoder_buffer_req(p_decoder, FALSE);
		if (p_decoder->b_header_in_start) {
			p_decoder->client_frame_size = p_decoder->frame_size;
			p_decoder->client_output_buf_req =
				p_decoder->actual_output_buf_req;
			if ((p_decoder->frame_size.n_width *
				p_decoder->frame_size.n_height) >=
				 VCD_DDL_WVGA_BUF_SIZE) {
				if ((p_decoder->actual_output_buf_req.\
					n_actual_count + 2) < 10)
					p_decoder->client_output_buf_req.\
						n_actual_count = 10;
				else
					p_decoder->client_output_buf_req.\
						n_actual_count += 2;
			} else
				p_decoder->client_output_buf_req.\
					n_actual_count = p_decoder->\
					actual_output_buf_req.\
					n_actual_count + 5;
			p_decoder->client_input_buf_req =
				p_decoder->actual_input_buf_req;
			p_ddl_context->ddl_callback(VCD_EVT_RESP_START,
				VCD_S_SUCCESS, NULL, 0, (u32 *) p_ddl,
				p_ddl->p_client_data);
			ddl_release_command_channel(p_ddl_context,
				p_ddl->n_command_channel);
		} else {
			u32 b_seq_hdr_only_frame = FALSE;
			u32 b_need_reconfig = TRUE;
			struct vcd_frame_data_type *p_input_vcd_frm =
				&p_ddl->input_frame.vcd_frm;

			if ((p_decoder->frame_size.n_width <=
				p_decoder->client_frame_size.n_stride) &&
				(p_decoder->frame_size.n_height <=
				p_decoder->client_frame_size.n_scan_lines) &&
				(p_decoder->actual_output_buf_req.n_size <=
				p_decoder->client_output_buf_req.n_size) &&
				(p_decoder->n_min_dpb_num <= p_decoder->\
				client_output_buf_req.n_actual_count))
				b_need_reconfig = FALSE;
			if (((p_input_vcd_frm->n_flags &
				VCD_FRAME_FLAG_CODECCONFIG) &&
				(!(p_input_vcd_frm->n_flags &
				VCD_FRAME_FLAG_SYNCFRAME))) ||
				p_input_vcd_frm->n_data_len ==
				seq_hdr_info.n_dec_frm_size) {
				b_seq_hdr_only_frame = TRUE;
				p_input_vcd_frm->n_offset +=
					seq_hdr_info.n_dec_frm_size;
				p_input_vcd_frm->n_data_len -=
					seq_hdr_info.n_dec_frm_size;
				p_input_vcd_frm->n_flags |=
					VCD_FRAME_FLAG_CODECCONFIG;
				p_ddl->input_frame.b_frm_trans_end =
					!b_need_reconfig;
				p_ddl_context->ddl_callback(
					VCD_EVT_RESP_INPUT_DONE,
					VCD_S_SUCCESS, &p_ddl->input_frame,
					sizeof(struct ddl_frame_data_type_tag),
					(u32 *) p_ddl, p_ddl->p_client_data);
			}
			if (b_need_reconfig) {
				struct ddl_frame_data_type_tag *p_payload =
					&p_ddl->input_frame;
				u32 n_payload_size =
					sizeof(struct ddl_frame_data_type_tag);

				p_decoder->client_frame_size =
					p_decoder->frame_size;
				p_decoder->client_output_buf_req =
					p_decoder->actual_output_buf_req;
				p_decoder->client_input_buf_req =
					p_decoder->actual_input_buf_req;
				if (b_seq_hdr_only_frame) {
					p_payload = NULL;
					n_payload_size = 0;
				}
				p_ddl_context->ddl_callback(
					VCD_EVT_IND_OUTPUT_RECONFIG,
					VCD_S_SUCCESS, p_payload,
					n_payload_size, (u32 *) p_ddl,
					p_ddl->p_client_data);
			}
			if (!b_need_reconfig && !b_seq_hdr_only_frame) {
				if (!ddl_vidc_decode_set_buffers(p_ddl))
					b_process_further = FALSE;
				else {
					DDL_MSG_ERROR("ddl_vidc_decode_set_\
						buffers failed");
					ddl_client_fatal_cb(p_ddl);
				}
			} else
				ddl_release_command_channel(p_ddl_context,
					p_ddl->n_command_channel);
		}
	}
예제 #15
0
static u32 ddl_decoder_frame_run_callback(
	struct ddl_client_context *ddl)
{
	struct ddl_context *ddl_context = ddl->ddl_context;
	struct vidc_1080p_dec_disp_info *dec_disp_info =
		&ddl->codec_data.decoder.dec_disp_info;
	u32 callback_end = false, ret_status = true, eos_present = false;

	DDL_MSG_MED("ddl_decoder_frame_run_callback");
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-DECFRMRUN");
		ddl_client_fatal_cb(ddl);
	} else {
		DDL_MSG_LOW("DEC_FRM_RUN_DONE");
		ddl->cmd_state = DDL_CMD_INVALID;
		vidc_1080p_get_display_frame_result(dec_disp_info);
		ddl_vidc_decode_dynamic_property(ddl, false);
		if (dec_disp_info->resl_change) {
			DDL_MSG_ERROR("DEC_RECONFIG_NOT_SUPPORTED");
			ddl_client_fatal_cb(ddl);
		} else {
			if ((VCD_FRAME_FLAG_EOS &
				ddl->input_frame.vcd_frm.flags)) {
				callback_end = false;
				eos_present = true;
			}
			if (dec_disp_info->display_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_ONLY ||
				dec_disp_info->display_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY) {
				if (!eos_present)
					callback_end =
					(dec_disp_info->display_status ==
					VIDC_1080P_DISPLAY_STATUS_DECODE_ONLY);
				ddl_decoder_input_done_callback(ddl,
					callback_end);
			}
			if (dec_disp_info->display_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY ||
				dec_disp_info->display_status ==
				VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY) {
				u32 vcd_status;
				if (!eos_present)
					callback_end = (dec_disp_info->\
					display_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY);

				vcd_status = ddl_decoder_ouput_done_callback(
					ddl, callback_end);
				if (vcd_status)
					return true;
			}
			if (dec_disp_info->display_status ==
				VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY ||
				dec_disp_info->display_status ==
				VIDC_1080P_DISPLAY_STATUS_DPB_EMPTY) {
				ddl_vidc_decode_frame_run(ddl);
				ret_status = false;
			} else if (eos_present) {
				ddl_vidc_decode_eos_run(ddl);
				ret_status = false;
			} else {
				ddl->client_state =
					DDL_CLIENT_WAIT_FOR_FRAME;
				ddl_release_command_channel(ddl_context,
					ddl->command_channel);
			}
		}
	}
	return ret_status;
}
static u32 ddl_decoder_seq_done_callback(struct ddl_context *ddl_context,
	struct ddl_client_context *ddl)
{
	struct ddl_decoder_data *decoder = &ddl->codec_data.decoder;
	struct vidc_1080p_seq_hdr_info seq_hdr_info;
	u32 process_further = true;

	DDL_MSG_MED("ddl_decoder_seq_done_callback");
	if (!ddl->decoding ||
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-HDDONE");
		ddl_client_fatal_cb(ddl);
	} else {
		ddl->cmd_state = DDL_CMD_INVALID;
		DDL_MSG_LOW("ddl_state_transition: %s ~~>\
			DDL_CLIENT_WAIT_FOR_DPB",\
			ddl_get_state_string(ddl->client_state));
		ddl->client_state = DDL_CLIENT_WAIT_FOR_DPB;
		DDL_MSG_LOW("HEADER_DONE");
		vidc_1080p_get_decode_seq_start_result(&seq_hdr_info);
		decoder->frame_size.width = seq_hdr_info.img_size_x;
		decoder->frame_size.height = seq_hdr_info.img_size_y;
		decoder->min_dpb_num = seq_hdr_info.min_num_dpb;
		vidc_sm_get_min_yc_dpb_sizes(
			&ddl->shared_mem[ddl->command_channel],
			&seq_hdr_info.min_luma_dpb_size,
			&seq_hdr_info.min_chroma_dpb_size);
		decoder->y_cb_cr_size = seq_hdr_info.min_luma_dpb_size +
			seq_hdr_info.min_chroma_dpb_size;
		decoder->dpb_buf_size.size_yuv = decoder->y_cb_cr_size;
		decoder->dpb_buf_size.size_y =
			seq_hdr_info.min_luma_dpb_size;
		decoder->dpb_buf_size.size_c =
			seq_hdr_info.min_chroma_dpb_size;
		decoder->progressive_only = 1 - seq_hdr_info.progressive;
		if (!seq_hdr_info.img_size_x || !seq_hdr_info.img_size_y) {
			DDL_MSG_ERROR("FATAL:ZeroImageSize");
			ddl_client_fatal_cb(ddl);
			return process_further;
		}
		vidc_sm_get_profile_info(&ddl->shared_mem
			[ddl->command_channel],
			&seq_hdr_info.profile, &seq_hdr_info.level);
		ddl_get_dec_profile_level(decoder, seq_hdr_info.profile,
			seq_hdr_info.level);
		ddl_calculate_stride(&decoder->frame_size,
			!decoder->progressive_only);
		vidc_sm_get_crop_info(
			&ddl->shared_mem[ddl->command_channel],
			&seq_hdr_info.crop_left_offset,
			&seq_hdr_info.crop_right_offset,
			&seq_hdr_info.crop_top_offset,
			&seq_hdr_info.crop_bottom_offset);
		seq_hdr_info.crop_exists = (seq_hdr_info.crop_left_offset ||
			seq_hdr_info.crop_right_offset ||
			seq_hdr_info.crop_top_offset ||
			seq_hdr_info.crop_bottom_offset);
		if (seq_hdr_info.crop_exists) {
			decoder->frame_size.width -=
				seq_hdr_info.crop_right_offset +
				seq_hdr_info.crop_left_offset;
			decoder->frame_size.height -=
				seq_hdr_info.crop_top_offset +
				seq_hdr_info.crop_bottom_offset;
		}
		ddl_set_default_decoder_buffer_req(decoder, false);
		if (decoder->header_in_start) {
			decoder->client_frame_size = decoder->frame_size;
			decoder->client_output_buf_req =
				decoder->actual_output_buf_req;
			if ((decoder->frame_size.width *
				decoder->frame_size.height) >=
				 VCD_DDL_WVGA_BUF_SIZE) {
				if ((decoder->actual_output_buf_req.\
					actual_count + 2) < 10)
					decoder->client_output_buf_req.\
						actual_count = 10;
				else
					decoder->client_output_buf_req.\
						actual_count += 2;
			} else
				decoder->client_output_buf_req.\
					actual_count = decoder->\
					actual_output_buf_req.\
					actual_count + 5;
			decoder->client_input_buf_req =
				decoder->actual_input_buf_req;
			ddl_context->ddl_callback(VCD_EVT_RESP_START,
				VCD_S_SUCCESS, NULL, 0, (u32 *) ddl,
				ddl->client_data);
			ddl_release_command_channel(ddl_context,
				ddl->command_channel);
		} else {
			u32 seq_hdr_only_frame = false;
			u32 need_reconfig = true;
			struct vcd_frame_data *input_vcd_frm =
				&ddl->input_frame.vcd_frm;

			if ((decoder->frame_size.width ==
				decoder->client_frame_size.width) &&
				(decoder->frame_size.height ==
				decoder->client_frame_size.height) &&
				(decoder->actual_output_buf_req.sz <=
				decoder->client_output_buf_req.sz) &&
				(decoder->actual_output_buf_req.actual_count <=
				 decoder->client_output_buf_req.actual_count) &&
				(decoder->frame_size.scan_lines ==
				decoder->client_frame_size.scan_lines) &&
				(decoder->frame_size.stride ==
				 decoder->client_frame_size.stride))
					need_reconfig = false;
			if (((input_vcd_frm->flags &
				VCD_FRAME_FLAG_CODECCONFIG) &&
				(!(input_vcd_frm->flags &
				VCD_FRAME_FLAG_SYNCFRAME))) ||
				input_vcd_frm->data_len ==
				seq_hdr_info.dec_frm_size) {
				seq_hdr_only_frame = true;
				input_vcd_frm->offset +=
					seq_hdr_info.dec_frm_size;
				input_vcd_frm->data_len -=
					seq_hdr_info.dec_frm_size;
				input_vcd_frm->flags |=
					VCD_FRAME_FLAG_CODECCONFIG;
				ddl->input_frame.frm_trans_end =
					!need_reconfig;
				ddl_context->ddl_callback(
					VCD_EVT_RESP_INPUT_DONE,
					VCD_S_SUCCESS, &ddl->input_frame,
					sizeof(struct ddl_frame_data_tag),
					(u32 *) ddl, ddl->client_data);
			}
			if (need_reconfig) {
				struct ddl_frame_data_tag *payload =
					&ddl->input_frame;
				u32 payload_size =
					sizeof(struct ddl_frame_data_tag);

				decoder->client_frame_size =
					decoder->frame_size;
				decoder->client_output_buf_req =
					decoder->actual_output_buf_req;
				decoder->client_input_buf_req =
					decoder->actual_input_buf_req;
				if (seq_hdr_only_frame) {
					payload = NULL;
					payload_size = 0;
				}
				ddl_context->ddl_callback(
					VCD_EVT_IND_OUTPUT_RECONFIG,
					VCD_S_SUCCESS, payload,
					payload_size, (u32 *) ddl,
					ddl->client_data);
			}
			if (!need_reconfig && !seq_hdr_only_frame) {
				if (!ddl_vidc_decode_set_buffers(ddl))
					process_further = false;
				else {
					DDL_MSG_ERROR("ddl_vidc_decode_set_\
						buffers failed");
					ddl_client_fatal_cb(ddl);
				}
			} else
				ddl_release_command_channel(ddl_context,
					ddl->command_channel);
		}
	}
static u32 ddl_decoder_seq_done_callback(struct ddl_context *ddl_context,
	struct ddl_client_context *ddl)
{
	struct ddl_decoder_data *decoder = &ddl->codec_data.decoder;
	struct vidc_1080p_seq_hdr_info seq_hdr_info;
	u32 process_further = true;
	struct ddl_profile_info_type disp_profile_info;
/*HTC_START Fix Klocwork issue*/
	seq_hdr_info.profile = 0;
	seq_hdr_info.level = 0;
/*HTC_END*/
	DDL_MSG_MED("ddl_decoder_seq_done_callback");
	if (!ddl->decoding ||
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-HDDONE");
		ddl_client_fatal_cb(ddl);
	} else {
		if (vidc_msg_timing)
			ddl_calc_core_proc_time(__func__, DEC_OP_TIME);
		ddl->cmd_state = DDL_CMD_INVALID;
		DDL_MSG_LOW("ddl_state_transition: %s ~~>"
			"DDL_CLIENT_WAIT_FOR_DPB",
			ddl_get_state_string(ddl->client_state));
		ddl->client_state = DDL_CLIENT_WAIT_FOR_DPB;
		DDL_MSG_LOW("HEADER_DONE");
		vidc_1080p_get_decode_seq_start_result(&seq_hdr_info);
		parse_hdr_size_data(ddl, &seq_hdr_info);
		if (!seq_hdr_info.img_size_x || !seq_hdr_info.img_size_y) {
			DDL_MSG_ERROR("FATAL:ZeroImageSize");
			ddl_client_fatal_cb(ddl);
			return process_further;
		}
		vidc_sm_get_profile_info(&ddl->shared_mem
			[ddl->command_channel], &disp_profile_info);
		disp_profile_info.pic_profile = seq_hdr_info.profile;
		disp_profile_info.pic_level = seq_hdr_info.level;
		ddl_get_dec_profile_level(decoder, seq_hdr_info.profile,
			seq_hdr_info.level);
		switch (decoder->codec.codec) {
		case VCD_CODEC_H264:
			if (decoder->profile.profile == VCD_PROFILE_H264_HIGH ||
				decoder->profile.profile ==
				VCD_PROFILE_UNKNOWN) {
				if ((disp_profile_info.chroma_format_idc >
					VIDC_1080P_IDCFORMAT_420) ||
					(disp_profile_info.bit_depth_luma_minus8
					 || disp_profile_info.
					bit_depth_chroma_minus8)) {
					DDL_MSG_ERROR("Unsupported H.264 "
						"feature: IDC "
						"format : %d, Bitdepth: %d",
						disp_profile_info.
						chroma_format_idc,
						(disp_profile_info.
						 bit_depth_luma_minus8
						 ||	disp_profile_info.
					bit_depth_chroma_minus8));
					ddl_client_fatal_cb(ddl);
					return process_further;
				}
			}
			break;
		case VCD_CODEC_MPEG4:
		case VCD_CODEC_DIVX_4:
		case VCD_CODEC_DIVX_5:
		case VCD_CODEC_DIVX_6:
		case VCD_CODEC_XVID:
			if (seq_hdr_info.data_partition)
				if ((seq_hdr_info.img_size_x *
				seq_hdr_info.img_size_y) > (720 * 576)) {
					DDL_MSG_ERROR("Unsupported DP clip");
					ddl_client_fatal_cb(ddl);
					return process_further;
				}
			break;
		default:
			break;
		}
		ddl_calculate_stride(&decoder->frame_size,
			!decoder->progressive_only);
		decoder->frame_size.scan_lines =
		DDL_ALIGN(decoder->frame_size.height, DDL_TILE_ALIGN_HEIGHT);
		decoder->frame_size.stride =
		DDL_ALIGN(decoder->frame_size.width, DDL_TILE_ALIGN_WIDTH);
		parse_hdr_crop_data(ddl, &seq_hdr_info);
		if (decoder->codec.codec == VCD_CODEC_H264 &&
			seq_hdr_info.level > VIDC_1080P_H264_LEVEL4) {
			DDL_MSG_ERROR("WARNING: H264MaxLevelExceeded : %d",
				seq_hdr_info.level);
		}
		ddl_set_default_decoder_buffer_req(decoder, false);
		if (decoder->header_in_start) {
			if (!(decoder->cont_mode) ||
				(decoder->min_dpb_num >
				 decoder->client_output_buf_req.min_count) ||
				(decoder->actual_output_buf_req.sz >
				 decoder->client_output_buf_req.sz)) {
				decoder->client_frame_size =
					 decoder->frame_size;
			decoder->client_output_buf_req =
				decoder->actual_output_buf_req;
			decoder->client_input_buf_req =
				decoder->actual_input_buf_req;
			}
			ddl_context->ddl_callback(VCD_EVT_RESP_START,
				VCD_S_SUCCESS, NULL, 0, (u32 *) ddl,
				ddl->client_data);
			ddl_release_command_channel(ddl_context,
				ddl->command_channel);
		} else {
			u32 seq_hdr_only_frame = false;
			u32 need_reconfig = false;
			struct vcd_frame_data *input_vcd_frm =
				&ddl->input_frame.vcd_frm;
			need_reconfig = ddl_check_reconfig(ddl);
			DDL_MSG_HIGH("%s : need_reconfig = %u\n", __func__,
				 need_reconfig);
			if (input_vcd_frm->flags &
				  VCD_FRAME_FLAG_EOS) {
					need_reconfig = false;
			}
			if (((input_vcd_frm->flags &
				VCD_FRAME_FLAG_CODECCONFIG) &&
				(!(input_vcd_frm->flags &
				VCD_FRAME_FLAG_SYNCFRAME))) ||
				input_vcd_frm->data_len <=
				seq_hdr_info.dec_frm_size) {
				seq_hdr_only_frame = true;
				input_vcd_frm->offset +=
					seq_hdr_info.dec_frm_size;
				input_vcd_frm->data_len = 0;
				input_vcd_frm->flags |=
					VCD_FRAME_FLAG_CODECCONFIG;
				ddl->input_frame.frm_trans_end =
					!need_reconfig;
				ddl_context->ddl_callback(
					VCD_EVT_RESP_INPUT_DONE,
					VCD_S_SUCCESS, &ddl->input_frame,
					sizeof(struct ddl_frame_data_tag),
					(u32 *) ddl, ddl->client_data);
			} else {
				if (decoder->codec.codec ==
					VCD_CODEC_VC1_RCV) {
					vidc_sm_set_start_byte_number(
						&ddl->shared_mem
						[ddl->command_channel],
						seq_hdr_info.dec_frm_size);
				}
			}
			if (need_reconfig) {
				struct ddl_frame_data_tag *payload =
					&ddl->input_frame;
				u32 payload_size =
					sizeof(struct ddl_frame_data_tag);
				decoder->client_frame_size =
					decoder->frame_size;
				decoder->client_output_buf_req =
					decoder->actual_output_buf_req;
				decoder->client_input_buf_req =
					decoder->actual_input_buf_req;
				if (seq_hdr_only_frame) {
					payload = NULL;
					payload_size = 0;
				}
				DDL_MSG_HIGH("%s : sending port reconfig\n",
					 __func__);
				ddl_context->ddl_callback(
					VCD_EVT_IND_OUTPUT_RECONFIG,
					VCD_S_SUCCESS, payload,
					payload_size, (u32 *) ddl,
					ddl->client_data);
			}
			if (!need_reconfig && !seq_hdr_only_frame) {
				if (!ddl_vidc_decode_set_buffers(ddl))
					process_further = false;
				else {
					DDL_MSG_ERROR("ddl_vidc_decode_set_"
						"buffers failed");
					ddl_client_fatal_cb(ddl);
				}
			} else
				ddl_release_command_channel(ddl_context,
					ddl->command_channel);
		}
	}
	return process_further;
}
static u32 ddl_decoder_frame_run_callback(struct ddl_client_context *ddl)
{
	struct ddl_context *ddl_context = ddl->ddl_context;
	struct ddl_decoder_data *decoder = &ddl->codec_data.decoder;
	u32 callback_end = false, ret_status = false;
	u32 eos_present = false, rsl_chg;
	u32 more_field_needed, extended_rsl_chg;
	enum vidc_1080p_display_status disp_status;
	DDL_MSG_MED("ddl_decoder_frame_run_callback");
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-DECFRMRUN");
		ddl_client_fatal_cb(ddl);
		ret_status = true;
	} else {
		DDL_MSG_LOW("DEC_FRM_RUN_DONE");
		ddl->cmd_state = DDL_CMD_INVALID;
		get_dec_status(ddl, &ddl->codec_data.decoder.dec_disp_info,
			ddl->codec_data.decoder.output_order,
			&disp_status, &rsl_chg);

		vidc_sm_get_extended_decode_status(
			&ddl->shared_mem[ddl->command_channel],
			&more_field_needed,
			&extended_rsl_chg);
		decoder->field_needed_for_prev_ip =
			more_field_needed;
		decoder->prev_ip_frm_tag =
			ddl->input_frame.vcd_frm.ip_frm_tag;

		ddl_vidc_decode_dynamic_property(ddl, false);
		if (rsl_chg != DDL_RESL_CHANGE_NO_CHANGE) {
			ddl_handle_reconfig(rsl_chg, ddl);
			ret_status = false;
		} else {
			if ((VCD_FRAME_FLAG_EOS &
				ddl->input_frame.vcd_frm.flags)) {
				callback_end = false;
				eos_present = true;
			}
			if (disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_ONLY ||
				disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY) {
				if (!eos_present)
					callback_end =
					(disp_status ==
					VIDC_1080P_DISPLAY_STATUS_DECODE_ONLY);
				ddl_decoder_input_done_callback(ddl,
					callback_end);
			}
			if (disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY ||
				disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY) {
				if (!eos_present)
					callback_end = (disp_status ==
				VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY);
				if (ddl_decoder_output_done_callback(
					ddl, callback_end))
					ret_status = true;
			}
			if (!ret_status) {
				if (disp_status ==
					VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY
					|| disp_status ==
					VIDC_1080P_DISPLAY_STATUS_DPB_EMPTY ||
					disp_status ==
					VIDC_1080P_DISPLAY_STATUS_NOOP) {
					ddl_vidc_decode_frame_run(ddl);
				} else if (eos_present)
					ddl_vidc_decode_eos_run(ddl);
				else {
					ddl->client_state =
						DDL_CLIENT_WAIT_FOR_FRAME;
					ddl_release_command_channel(ddl_context,
						ddl->command_channel);
					ret_status = true;
				}
			}
		}
	}
	return ret_status;
}
예제 #19
0
u32 ddl_decode_frame(u32 *ddl_handle,
	struct ddl_frame_data_tag *input_bits, void *client_data)
{
	u32 vcd_status = VCD_S_SUCCESS;
	struct ddl_client_context *ddl =
		(struct ddl_client_context *) ddl_handle;
	struct ddl_context *ddl_context;
	struct ddl_decoder_data *decoder;
	DDL_MSG_MED("ddl_decode_frame");
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_dec_frame:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		DDL_MSG_ERROR("ddl_dec_frame:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || !ddl->decoding) {
		DDL_MSG_ERROR("ddl_dec_frame:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!input_bits || ((!input_bits->vcd_frm.physical ||
		!input_bits->vcd_frm.data_len) &&
		(!(VCD_FRAME_FLAG_EOS &	input_bits->vcd_frm.flags)))) {
		DDL_MSG_ERROR("ddl_dec_frame:Bad_input_param");
		return VCD_ERR_ILLEGAL_PARM;
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) &&
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) &&
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) {
		DDL_MSG_ERROR("Dec_frame:Wrong_state");
		return VCD_ERR_ILLEGAL_OP;
	}
	decoder = &(ddl->codec_data.decoder);
	if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC)	&&
		!ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) {
		DDL_MSG_ERROR("ddl_dec_frame:Dpbs_requied");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!ddl_take_command_channel(ddl_context, ddl, client_data))
		return VCD_ERR_BUSY;

	ddl->input_frame = *input_bits;
	if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME))
		ddl_vidc_decode_frame_run(ddl);
	else {
		if (!ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) {
			DDL_MSG_ERROR("ddl_dec_frame:Dpbs_requied");
			vcd_status = VCD_ERR_ILLEGAL_OP;
		} else if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) {
			vcd_status = ddl_vidc_decode_set_buffers(ddl);
		if (vcd_status)
			ddl_release_command_channel(ddl_context,
				ddl->command_channel);
		} else if (DDLCLIENT_STATE_IS(ddl,
			DDL_CLIENT_WAIT_FOR_INITCODEC)) {
			if (decoder->codec.codec == VCD_CODEC_DIVX_3) {
				if ((!decoder->client_frame_size.width) ||
				(!decoder->client_frame_size.height))
					return VCD_ERR_ILLEGAL_OP;
		}
		ddl->codec_data.decoder.decode_config.sequence_header =
			ddl->input_frame.vcd_frm.physical;
		ddl->codec_data.decoder.decode_config.sequence_header_len =
			ddl->input_frame.vcd_frm.data_len;
		ddl_vidc_decode_init_codec(ddl);
		} else {
			DDL_MSG_ERROR("Dec_frame:Wrong_state");
			vcd_status = VCD_ERR_ILLEGAL_OP;
		}
		if (vcd_status)
			DDL_IDLE(ddl_context);
		}
	return vcd_status;
}