Пример #1
0
u32 ddl_open(u32 **ddl_handle, u32 decoding)
{
	struct ddl_context *ddl_context;
	struct ddl_client_context *ddl;
	void *ptr;
	u32 status;

	DDL_MSG_HIGH("ddl_open");
	if (!ddl_handle) {
		DDL_MSG_ERROR("ddl_open:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_open:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	status = ddl_client_transact(DDL_GET_CLIENT, &ddl);
	if (status) {
		DDL_MSG_ERROR("ddl_open:Client_trasac_failed");
		return status;
	}
	ptr = ddl_pmem_alloc(&ddl->shared_mem[0],
			DDL_FW_AUX_HOST_CMD_SPACE_SIZE, sizeof(u32));
	if (!ptr)
		status = VCD_ERR_ALLOC_FAIL;
	if (!status && ddl_context->frame_channel_depth
		== VCD_DUAL_FRAME_COMMAND_CHANNEL) {
		ptr = ddl_pmem_alloc(&ddl->shared_mem[1],
				DDL_FW_AUX_HOST_CMD_SPACE_SIZE, sizeof(u32));
		if (!ptr) {
			ddl_pmem_free(&ddl->shared_mem[0]);
			status = VCD_ERR_ALLOC_FAIL;
		}
	}
	if (!status) {
		memset(ddl->shared_mem[0].align_virtual_addr, 0,
			DDL_FW_AUX_HOST_CMD_SPACE_SIZE);
		if (ddl_context->frame_channel_depth ==
			VCD_DUAL_FRAME_COMMAND_CHANNEL) {
			memset(ddl->shared_mem[1].align_virtual_addr, 0,
				DDL_FW_AUX_HOST_CMD_SPACE_SIZE);
		}
		DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_OPEN",
		ddl_get_state_string(ddl->client_state));
		ddl->client_state = DDL_CLIENT_OPEN;
		ddl->codec_data.hdr.decoding = decoding;
		ddl->decoding = decoding;
		ddl_set_default_meta_data_hdr(ddl);
		ddl_set_initial_default_values(ddl);
		*ddl_handle	= (u32 *) ddl;
	} else {
		ddl_pmem_free(&ddl->shared_mem[0]);
		if (ddl_context->frame_channel_depth
			== VCD_DUAL_FRAME_COMMAND_CHANNEL)
			ddl_pmem_free(&ddl->shared_mem[1]);
		ddl_client_transact(DDL_FREE_CLIENT, &ddl);
	}
	return status;
}
Пример #2
0
u32 ddl_encode_start(u32 *ddl_handle, void *client_data)
{
	struct ddl_client_context *ddl =
		(struct ddl_client_context *) ddl_handle;
	struct ddl_context *ddl_context;
	struct ddl_encoder_data *encoder;
	void *ptr;
	u32 status = VCD_S_SUCCESS;

	DDL_MSG_HIGH("ddl_encode_start");
#ifdef DDL_PROFILE
	if (first_time < 2) {
		ddl_reset_time_variables(1);
		first_time++;
	 }
	ddl_get_core_start_time(1);
#endif
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || ddl->decoding) {
		DDL_MSG_ERROR("ddl_enc_start:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_opened");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!ddl_encoder_ready_to_start(ddl)) {
		DDL_MSG_ERROR("ddl_enc_start:Err_param_settings");
		return VCD_ERR_ILLEGAL_OP;
	}
	encoder = &ddl->codec_data.encoder;
	status = ddl_allocate_enc_hw_buffers(ddl);
	if (status)
		return status;
#ifdef DDL_BUF_LOG
	ddl_list_buffers(ddl);
#endif

	ptr = ddl_pmem_alloc(&encoder->seq_header,
		DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES);
	if (!ptr) {
		ddl_free_enc_hw_buffers(ddl);
		DDL_MSG_ERROR("ddl_enc_start:Seq_hdr_alloc_failed");
		return VCD_ERR_ALLOC_FAIL;
	}
	if (!ddl_take_command_channel(ddl_context, ddl, client_data))
		return VCD_ERR_BUSY;
	ddl_vidc_channel_set(ddl);
	return status;
}
Пример #3
0
static u32 vcd_fw_prepare(struct ddl_buf_addr *fw_details,
			 const unsigned char fw_array[],
			 const unsigned int fw_array_size, u32 change_endian)
{
	u32 *buffer;

	ddl_pmem_alloc(fw_details, fw_array_size,
		       DDL_LINEAR_BUFFER_ALIGN_BYTES);
	if (!fw_details->virtual_base_addr)
		return false;

	fw_details->buffer_size = fw_array_size / 4;

	buffer = fw_details->align_virtual_addr;

	memcpy(buffer, fw_array, fw_array_size);
	if (change_endian)
		vcd_fw_change_endian((unsigned char *)buffer, fw_array_size);
	return true;
}
Пример #4
0
u32 ddl_encode_start(u32 *ddl_handle, void *client_data)
{
	struct ddl_client_context *ddl =
		(struct ddl_client_context *) ddl_handle;
	struct ddl_context *ddl_context;
	struct ddl_encoder_data *encoder;
	void *ptr;
	u32 status = VCD_S_SUCCESS;
	DDL_MSG_HIGH("ddl_encode_start");
	if (first_time < 2) {
		ddl_reset_core_time_variables(ENC_OP_TIME);
		first_time++;
	 }
	ddl_set_core_start_time(__func__, ENC_OP_TIME);
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || ddl->decoding) {
		DDL_MSG_ERROR("ddl_enc_start:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_opened");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!ddl_encoder_ready_to_start(ddl)) {
		DDL_MSG_ERROR("ddl_enc_start:Err_param_settings");
		return VCD_ERR_ILLEGAL_OP;
	}
	encoder = &ddl->codec_data.encoder;
	if (DDL_IS_LTR_ENABLED(encoder)) {
		DDL_MSG_HIGH("LTR enabled, mode %u count %u",
			(u32)encoder->ltr_control.ltrmode.ltr_mode,
			(u32)encoder->ltr_control.ltr_count);
		status = ddl_allocate_ltr_list(&encoder->ltr_control);
		if (status) {
			DDL_MSG_ERROR("%s: allocate ltr list failed",
				__func__);
			return status;
		} else {
			ddl_clear_ltr_list(&encoder->ltr_control, false);
		}
		encoder->num_references_for_p_frame = 2;
		encoder->ltr_control.callback_reqd = false;
		encoder->ltr_control.curr_ltr_id = (u32)DDL_LTR_FRAME_START_ID;
		DDL_MSG_HIGH("num_ref_for_p_frames %u, curr_ltr_id = %u",
			(u32)encoder->num_references_for_p_frame,
			(u32)encoder->ltr_control.curr_ltr_id);
	}
	status = ddl_allocate_enc_hw_buffers(ddl);
	if (status)
		return status;
#ifdef DDL_BUF_LOG
	ddl_list_buffers(ddl);
#endif
	encoder->seq_header.mem_type = DDL_MM_MEM;
	ptr = ddl_pmem_alloc(&encoder->seq_header,
		DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES);
	if (!ptr) {
		ddl_free_enc_hw_buffers(ddl);
		DDL_MSG_ERROR("ddl_enc_start:Seq_hdr_alloc_failed");
		return VCD_ERR_ALLOC_FAIL;
	}
	msm_ion_do_cache_op(ddl_context->video_ion_client,
				encoder->seq_header.alloc_handle,
				encoder->seq_header.virtual_base_addr,
				encoder->seq_header.buffer_size,
				ION_IOC_CLEAN_INV_CACHES);
	if (encoder->slice_delivery_info.enable) {
		DDL_MSG_LOW("%s: slice mode allocate memory for struct\n",
					__func__);
		ptr = ddl_pmem_alloc(&encoder->batch_frame.slice_batch_in,
				DDL_ENC_SLICE_BATCH_INPSTRUCT_SIZE,
				DDL_LINEAR_BUFFER_ALIGN_BYTES);
		if (ptr) {
			ptr = ddl_pmem_alloc(
				&encoder->batch_frame.slice_batch_out,
				DDL_ENC_SLICE_BATCH_OUTSTRUCT_SIZE,
				DDL_LINEAR_BUFFER_ALIGN_BYTES);
		}
		if (!ptr) {
			ddl_pmem_free(&encoder->batch_frame.slice_batch_in);
			ddl_pmem_free(&encoder->batch_frame.slice_batch_out);
			ddl_free_enc_hw_buffers(ddl);
			ddl_pmem_free(&encoder->seq_header);
			DDL_MSG_ERROR("ddlEncStart:SeqHdrAllocFailed");
			return VCD_ERR_ALLOC_FAIL;
		}
	}
	if (!ddl_take_command_channel(ddl_context, ddl, client_data))
		return VCD_ERR_BUSY;
	ddl_vidc_channel_set(ddl);
	return status;
}
Пример #5
0
u32 ddl_device_init(struct ddl_init_config *ddl_init_config,
	void *client_data)
{
	struct ddl_context *ddl_context;
	u32 status = VCD_S_SUCCESS;
	void *ptr = NULL;
	DDL_MSG_HIGH("ddl_device_init");

	if ((!ddl_init_config) || (!ddl_init_config->ddl_callback) ||
		(!ddl_init_config->core_virtual_base_addr)) {
		DDL_MSG_ERROR("ddl_dev_init:Bad_argument");
		return VCD_ERR_ILLEGAL_PARM;
	}
	ddl_context = ddl_get_context();
	if (DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_dev_init:Multiple_init");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!DDL_IS_IDLE(ddl_context)) {
		DDL_MSG_ERROR("ddl_dev_init:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	memset(ddl_context, 0, sizeof(struct ddl_context));
	DDL_BUSY(ddl_context);
	if (res_trk_get_enable_ion()) {
		DDL_MSG_LOW("ddl_dev_init:ION framework enabled");
		ddl_context->video_ion_client  =
			res_trk_get_ion_client();
		if (!ddl_context->video_ion_client) {
			DDL_MSG_ERROR("ION client create failed");
			return VCD_ERR_ILLEGAL_OP;
		}
	}
	ddl_context->ddl_callback = ddl_init_config->ddl_callback;
	if (ddl_init_config->interrupt_clr)
		ddl_context->interrupt_clr =
			ddl_init_config->interrupt_clr;
	ddl_context->core_virtual_base_addr =
		ddl_init_config->core_virtual_base_addr;
	ddl_context->client_data = client_data;
	ddl_context->ddl_hw_response.arg1 = DDL_INVALID_INTR_STATUS;

	ddl_context->frame_channel_depth = VCD_FRAME_COMMAND_DEPTH;

	DDL_MSG_LOW("%s() : virtual address of core(%x)\n", __func__,
		(u32) ddl_init_config->core_virtual_base_addr);
	vidc_1080p_set_device_base_addr(
		ddl_context->core_virtual_base_addr);
	ddl_context->cmd_state =	DDL_CMD_INVALID;
	ddl_client_transact(DDL_INIT_CLIENTS, NULL);
	ddl_context->fw_memory_size =
		DDL_FW_INST_GLOBAL_CONTEXT_SPACE_SIZE;
	if (res_trk_get_firmware_addr(&ddl_context->dram_base_a)) {
		DDL_MSG_ERROR("firmware allocation failed");
		ptr = NULL;
	} else {
		ptr = (void *)ddl_context->dram_base_a.virtual_base_addr;
	}
	if (!ptr) {
		DDL_MSG_ERROR("Memory Aocation Failed for FW Base");
		status = VCD_ERR_ALLOC_FAIL;
	} else {
		DDL_MSG_LOW("%s() : physical address of base(%x)\n",
			 __func__, (u32) ddl_context->dram_base_a.\
			align_physical_addr);
		ddl_context->dram_base_b.align_physical_addr =
			ddl_context->dram_base_a.align_physical_addr;
		ddl_context->dram_base_b.align_virtual_addr  =
			ddl_context->dram_base_a.align_virtual_addr;
	}
	if (!status) {
		if (res_trk_get_enable_sec_metadata()) {
			ddl_context->metadata_shared_input.mem_type =
				DDL_CMD_MEM;
		} else {
			ddl_context->metadata_shared_input.mem_type =
				DDL_FW_MEM;
		}
		ptr = ddl_pmem_alloc(&ddl_context->metadata_shared_input,
			DDL_METADATA_TOTAL_INPUTBUFSIZE,
			DDL_LINEAR_BUFFER_ALIGN_BYTES);
		if (!ptr) {
			DDL_MSG_ERROR("ddl_device_init: metadata alloc fail");
			status = VCD_ERR_ALLOC_FAIL;
		}
	}
	if (!status && !ddl_fw_init(&ddl_context->dram_base_a)) {
		DDL_MSG_ERROR("ddl_dev_init:fw_init_failed");
		status = VCD_ERR_ALLOC_FAIL;
	}
	if (!status) {
		ddl_context->cmd_state = DDL_CMD_DMA_INIT;
		ddl_vidc_core_init(ddl_context);
	} else {
		ddl_release_context_buffers(ddl_context);
		DDL_IDLE(ddl_context);
	}
	return status;
}
Пример #6
0
u32 ddl_decode_start(u32 *ddl_handle,
     struct vcd_sequence_hdr *header, void *client_data)
{
	struct ddl_client_context *ddl =
	    (struct ddl_client_context *)ddl_handle;
	struct ddl_context *ddl_context;
	struct ddl_decoder_data *decoder;

	ddl_context = ddl_get_context();

	if (!DDL_IS_INITIALIZED(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dec_start:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dec_start:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || !ddl->decoding) {
		VIDC_LOGERR_STRING("ddl_dec_start:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) {
		VIDC_LOGERR_STRING("ddl_dec_start:Not_in_opened_state");
		return VCD_ERR_ILLEGAL_OP;
	}

	if ((header) &&
	    ((!header->sequence_header_len) ||
	     (!header->sequence_header)
	    )
	    ) {
		VIDC_LOGERR_STRING("ddl_dec_start:Bad_param_seq_header");
		return VCD_ERR_ILLEGAL_PARM;
	}

	if (!ddl_decoder_ready_to_start(ddl, header)) {
		VIDC_LOGERR_STRING("ddl_dec_start:Err_param_settings");
		return VCD_ERR_ILLEGAL_OP;
	}

	DDL_BUSY(ddl_context);

	decoder = &ddl->codec_data.decoder;
	if (header) {
		decoder->header_in_start = true;
		decoder->decode_config = *header;
	} else {
		decoder->header_in_start = false;
		decoder->decode_config.sequence_header_len = 0;
	}

	if (decoder->codec.codec == VCD_CODEC_H264) {
		ddl_pmem_alloc(&decoder->h264Vsp_temp_buffer,
			       DDL_DECODE_H264_VSPTEMP_BUFSIZE,
			       DDL_LINEAR_BUFFER_ALIGN_BYTES);
		if (!decoder->h264Vsp_temp_buffer.virtual_base_addr) {
			DDL_IDLE(ddl_context);
			VIDC_LOGERR_STRING
			    ("ddl_dec_start:H264Sps_alloc_failed");
			return VCD_ERR_ALLOC_FAIL;
		}
	}

	ddl_context->current_ddl = ddl;
	ddl_context->client_data = client_data;

	ddl_channel_set(ddl);
	return VCD_S_SUCCESS;
}
Пример #7
0
u32 ddl_encode_start(u32 *ddl_handle, void *client_data)
{
	struct ddl_client_context *ddl =
	    (struct ddl_client_context *)ddl_handle;
	struct ddl_context *ddl_context;
	struct ddl_encoder_data *encoder;
	u32 dpb_size;

	ddl_context = ddl_get_context();

	if (!DDL_IS_INITIALIZED(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_enc_start:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_enc_start:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || ddl->decoding) {
		VIDC_LOGERR_STRING("ddl_enc_start:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}

	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) {
		VIDC_LOGERR_STRING("ddl_enc_start:Not_opened");
		return VCD_ERR_ILLEGAL_OP;
	}

	if (!ddl_encoder_ready_to_start(ddl)) {
		VIDC_LOGERR_STRING("ddl_enc_start:Err_param_settings");
		return VCD_ERR_ILLEGAL_OP;
	}

	encoder = &ddl->codec_data.encoder;

	dpb_size = ddl_get_yuv_buffer_size(&encoder->frame_size,
					&encoder->re_con_buf_format, false,
					encoder->codec.codec);

	dpb_size *= DDL_ENC_NUM_DPB_BUFFERS;
	ddl_pmem_alloc(&encoder->enc_dpb_addr,
		       dpb_size, DDL_TILE_BUFFER_ALIGN_BYTES);
	if (!encoder->enc_dpb_addr.virtual_base_addr) {
		VIDC_LOGERR_STRING("ddl_enc_start:Dpb_alloc_failed");
		return VCD_ERR_ALLOC_FAIL;
	}

	if ((encoder->codec.codec == VCD_CODEC_MPEG4 &&
	     !encoder->short_header.short_header) ||
	    encoder->codec.codec == VCD_CODEC_H264) {
		ddl_pmem_alloc(&encoder->seq_header,
			       DDL_ENC_SEQHEADER_SIZE,
			       DDL_LINEAR_BUFFER_ALIGN_BYTES);
		if (!encoder->seq_header.virtual_base_addr) {
			ddl_pmem_free(&encoder->enc_dpb_addr);
			VIDC_LOGERR_STRING
			    ("ddl_enc_start:Seq_hdr_alloc_failed");
			return VCD_ERR_ALLOC_FAIL;
		}
	} else {
		encoder->seq_header.buffer_size = 0;
		encoder->seq_header.virtual_base_addr = 0;
	}

	DDL_BUSY(ddl_context);

	ddl_context->current_ddl = ddl;
	ddl_context->client_data = client_data;
	ddl_channel_set(ddl);
	return VCD_S_SUCCESS;
}
Пример #8
0
u32 ddl_device_init(struct ddl_init_config *ddl_init_config,
		    void *client_data)
{
	struct ddl_context *ddl_context;
	u32 status = VCD_S_SUCCESS;

	if ((!ddl_init_config) ||
	    (!ddl_init_config->ddl_callback) ||
	    (!ddl_init_config->core_virtual_base_addr)
	    ) {
		VIDC_LOGERR_STRING("ddl_dev_init:Bad_argument");
		return VCD_ERR_ILLEGAL_PARM;
	}

	ddl_context = ddl_get_context();

	if (DDL_IS_INITIALIZED(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dev_init:Multiple_init");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dev_init:Ddl_busy");
		return VCD_ERR_BUSY;
	}

	DDL_MEMSET(ddl_context, 0, sizeof(struct ddl_context));

	DDL_BUSY(ddl_context);

	ddl_context->ddl_callback = ddl_init_config->ddl_callback;
	ddl_context->interrupt_clr = ddl_init_config->interrupt_clr;
	ddl_context->core_virtual_base_addr =
	    ddl_init_config->core_virtual_base_addr;
	ddl_context->client_data = client_data;

	vidc_720p_set_device_virtual_base(ddl_context->
					   core_virtual_base_addr);

	ddl_context->current_ddl = NULL;
	ddl_move_command_state(ddl_context, DDL_CMD_INVALID);

	ddl_client_transact(DDL_INIT_CLIENTS, NULL);

	ddl_pmem_alloc(&ddl_context->context_buf_addr,
		       DDL_CONTEXT_MEMORY, DDL_LINEAR_BUFFER_ALIGN_BYTES);
	if (!ddl_context->context_buf_addr.virtual_base_addr) {
		VIDC_LOGERR_STRING("ddl_dev_init:Context_alloc_fail");
		status = VCD_ERR_ALLOC_FAIL;
	}
	if (!status) {
		ddl_pmem_alloc(&ddl_context->db_line_buffer,
			       DDL_DB_LINE_BUF_SIZE,
			       DDL_TILE_BUFFER_ALIGN_BYTES);
		if (!ddl_context->db_line_buffer.virtual_base_addr) {
			VIDC_LOGERR_STRING("ddl_dev_init:Line_buf_alloc_fail");
			status = VCD_ERR_ALLOC_FAIL;
		}
	}

	if (!status) {
		ddl_pmem_alloc(&ddl_context->data_partition_tempbuf,
					   DDL_MPEG4_DATA_PARTITION_BUF_SIZE,
					   DDL_TILE_BUFFER_ALIGN_BYTES);
		if (ddl_context->data_partition_tempbuf.virtual_base_addr \
			== NULL) {
			VIDC_LOGERR_STRING
				("ddl_dev_init:Data_partition_buf_alloc_fail");
			status = VCD_ERR_ALLOC_FAIL;
		}
   }

   if (!status) {

		ddl_pmem_alloc(&ddl_context->metadata_shared_input,
					   DDL_METADATA_TOTAL_INPUTBUFSIZE,
					   DDL_LINEAR_BUFFER_ALIGN_BYTES);
		if (!ddl_context->metadata_shared_input.virtual_base_addr) {
			VIDC_LOGERR_STRING
			("ddl_dev_init:metadata_shared_input_alloc_fail");
			status = VCD_ERR_ALLOC_FAIL;
		}
	 }

	if (!status) {
		ddl_pmem_alloc(&ddl_context->dbg_core_dump, \
					   DDL_DBG_CORE_DUMP_SIZE,  \
					   DDL_LINEAR_BUFFER_ALIGN_BYTES);
		if (!ddl_context->dbg_core_dump.virtual_base_addr) {
			VIDC_LOGERR_STRING
				("ddl_dev_init:dbg_core_dump_alloc_failed");
			status = VCD_ERR_ALLOC_FAIL;
		}
		ddl_context->enable_dbg_core_dump = 0;
	}

	if (!status && !vcd_fw_init()) {
		VIDC_LOGERR_STRING("ddl_dev_init:fw_init_failed");
		status = VCD_ERR_ALLOC_FAIL;
	}
	if (status) {
		ddl_release_context_buffers(ddl_context);
		DDL_IDLE(ddl_context);
		return status;
	}

	ddl_move_command_state(ddl_context, DDL_CMD_DMA_INIT);

	ddl_core_init(ddl_context);

	return status;
}
Пример #9
0
u32 ddl_encode_start(u32 *ddl_handle, void *client_data)
{
	struct ddl_client_context *ddl =
		(struct ddl_client_context *) ddl_handle;
	struct ddl_context *ddl_context;
	struct ddl_encoder_data *encoder;
	void *ptr;
	u32 status = VCD_S_SUCCESS;
	DDL_MSG_HIGH("ddl_encode_start");
	if (vidc_msg_timing) {
		if (first_time < 2) {
			ddl_reset_core_time_variables(ENC_OP_TIME);
			first_time++;
		 }
		ddl_set_core_start_time(__func__, ENC_OP_TIME);
	}
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || ddl->decoding) {
		DDL_MSG_ERROR("ddl_enc_start:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_opened");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!ddl_encoder_ready_to_start(ddl)) {
		DDL_MSG_ERROR("ddl_enc_start:Err_param_settings");
		return VCD_ERR_ILLEGAL_OP;
	}
	encoder = &ddl->codec_data.encoder;
	status = ddl_allocate_enc_hw_buffers(ddl);
	if (status)
		return status;
#ifdef DDL_BUF_LOG
	ddl_list_buffers(ddl);
#endif
#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
	encoder->seq_header.mem_type = DDL_MM_MEM;
#endif
	ptr = ddl_pmem_alloc(&encoder->seq_header,
		DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES);
	if (!ptr) {
		ddl_free_enc_hw_buffers(ddl);
		DDL_MSG_ERROR("ddl_enc_start:Seq_hdr_alloc_failed");
		return VCD_ERR_ALLOC_FAIL;
	}
	if (encoder->slice_delivery_info.enable) {
		DDL_MSG_LOW("%s: slice mode allocate memory for struct\n",
					__func__);
		ptr = ddl_pmem_alloc(&encoder->batch_frame.slice_batch_in,
				DDL_ENC_SLICE_BATCH_INPSTRUCT_SIZE,
				DDL_LINEAR_BUFFER_ALIGN_BYTES);
		if (ptr) {
			ptr = ddl_pmem_alloc(
				&encoder->batch_frame.slice_batch_out,
				DDL_ENC_SLICE_BATCH_OUTSTRUCT_SIZE,
				DDL_LINEAR_BUFFER_ALIGN_BYTES);
		}
		if (!ptr) {
			ddl_pmem_free(&encoder->batch_frame.slice_batch_in);
			ddl_pmem_free(&encoder->batch_frame.slice_batch_out);
			ddl_free_enc_hw_buffers(ddl);
			ddl_pmem_free(&encoder->seq_header);
			DDL_MSG_ERROR("ddlEncStart:SeqHdrAllocFailed");
			return VCD_ERR_ALLOC_FAIL;
		}
	}
	if (!ddl_take_command_channel(ddl_context, ddl, client_data))
		return VCD_ERR_BUSY;
	ddl_vidc_channel_set(ddl);
	return status;
}
u32 ddl_encode_start(u32 *ddl_handle, void *client_data)
{
	struct ddl_client_context *ddl =
		(struct ddl_client_context *) ddl_handle;
	struct ddl_context *ddl_context;
	struct ddl_encoder_data *encoder;
	void *ptr;
	u32 status = VCD_S_SUCCESS;
	DDL_MSG_HIGH("ddl_encode_start");
	if (vidc_msg_timing) {
		if (first_time < 2) {
			ddl_reset_core_time_variables(ENC_OP_TIME);
			first_time++;
		 }
		ddl_set_core_start_time(__func__, ENC_OP_TIME);
	}
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || ddl->decoding) {
		DDL_MSG_ERROR("ddl_enc_start:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_opened");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!ddl_encoder_ready_to_start(ddl)) {
		DDL_MSG_ERROR("ddl_enc_start:Err_param_settings");
		return VCD_ERR_ILLEGAL_OP;
	}
	encoder = &ddl->codec_data.encoder;
	status = ddl_allocate_enc_hw_buffers(ddl);
	if (status)
		return status;
#ifdef DDL_BUF_LOG
	ddl_list_buffers(ddl);
#endif
	if ((encoder->codec.codec == VCD_CODEC_MPEG4 &&
		!encoder->short_header.short_header) ||
		encoder->codec.codec == VCD_CODEC_H264) {
		ptr = ddl_pmem_alloc(&encoder->seq_header,
			DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES);
		if (!ptr) {
			ddl_free_enc_hw_buffers(ddl);
			DDL_MSG_ERROR("ddl_enc_start:Seq_hdr_alloc_failed");
			return VCD_ERR_ALLOC_FAIL;
		}
	} else {
		encoder->seq_header.buffer_size = 0;
		encoder->seq_header.virtual_base_addr = 0;
		encoder->seq_header.align_physical_addr = 0;
		encoder->seq_header.align_virtual_addr = 0;
	}
	if (!ddl_take_command_channel(ddl_context, ddl, client_data))
		return VCD_ERR_BUSY;
	ddl_vidc_channel_set(ddl);
	return status;
}
Пример #11
0
u32 ddl_device_init(struct ddl_init_config *ddl_init_config,
	void *client_data)
{
	struct ddl_context *ddl_context;
	u32 status = VCD_S_SUCCESS;
	void *ptr;
	DDL_MSG_HIGH("ddl_device_init");

	if ((!ddl_init_config) || (!ddl_init_config->ddl_callback) ||
		(!ddl_init_config->core_virtual_base_addr)) {
		DDL_MSG_ERROR("ddl_dev_init:Bad_argument");
		return VCD_ERR_ILLEGAL_PARM;
	}
	ddl_context = ddl_get_context();
	if (DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_dev_init:Multiple_init");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!DDL_IS_IDLE(ddl_context)) {
		DDL_MSG_ERROR("ddl_dev_init:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	memset(ddl_context, 0, sizeof(struct ddl_context));
	DDL_BUSY(ddl_context);
	ddl_context->ddl_callback = ddl_init_config->ddl_callback;
	if (ddl_init_config->interrupt_clr)
		ddl_context->interrupt_clr =
			ddl_init_config->interrupt_clr;
	ddl_context->core_virtual_base_addr =
		ddl_init_config->core_virtual_base_addr;
	ddl_context->client_data = client_data;
	ddl_context->ddl_hw_response.arg1 = DDL_INVALID_INTR_STATUS;

	ddl_context->frame_channel_depth = VCD_FRAME_COMMAND_DEPTH;

	DDL_MSG_LOW("%s() : virtual address of core(%x)\n", __func__,
		(u32) ddl_init_config->core_virtual_base_addr);
	vidc_1080p_set_device_base_addr(
		ddl_context->core_virtual_base_addr);
	ddl_context->cmd_state =	DDL_CMD_INVALID;
	ddl_client_transact(DDL_INIT_CLIENTS, NULL);
	ddl_context->fw_memory_size =
		DDL_FW_INST_GLOBAL_CONTEXT_SPACE_SIZE;
	ptr = ddl_pmem_alloc(&ddl_context->dram_base_a,
		ddl_context->fw_memory_size, DDL_KILO_BYTE(128));
	if (!ptr) {
		DDL_MSG_ERROR("Memory Aocation Failed for FW Base");
		status = VCD_ERR_ALLOC_FAIL;
	} else {
		DDL_MSG_LOW("%s() : physical address of base(%x)\n",
			 __func__, (u32) ddl_context->dram_base_a.\
			align_physical_addr);
		ddl_context->dram_base_b.align_physical_addr =
			ddl_context->dram_base_a.align_physical_addr;
		ddl_context->dram_base_b.align_virtual_addr  =
			ddl_context->dram_base_a.align_virtual_addr;
	}
	if (!status && !ddl_fw_init(&ddl_context->dram_base_a)) {
		DDL_MSG_ERROR("ddl_dev_init:fw_init_failed");
		status = VCD_ERR_ALLOC_FAIL;
	}
	if (!status) {
		ddl_context->cmd_state = DDL_CMD_DMA_INIT;
		ddl_vidc_core_init(ddl_context);
	} else {
		ddl_release_context_buffers(ddl_context);
		DDL_IDLE(ddl_context);
	}
	return status;
}
Пример #12
0
u32 ddl_decode_start(u32 *ddl_handle,
                     struct vcd_sequence_hdr_type *p_header, void *p_client_data)
{
    struct ddl_client_context_type *p_ddl =
        (struct ddl_client_context_type *)ddl_handle;
    struct ddl_context_type *p_ddl_context;
    struct ddl_decoder_data_type *p_decoder;

    p_ddl_context = ddl_get_context();

    if (!DDL_IS_INITIALIZED(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_start:Not_inited");
        return VCD_ERR_ILLEGAL_OP;
    }
    if (DDL_IS_BUSY(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_start:Ddl_busy");
        return VCD_ERR_BUSY;
    }
    if (NULL == p_ddl || FALSE == p_ddl->b_decoding) {
        VIDC_LOGERR_STRING("ddl_dec_start:Bad_handle");
        return VCD_ERR_BAD_HANDLE;
    }
    if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_OPEN)) {
        VIDC_LOGERR_STRING("ddl_dec_start:Not_in_opened_state");
        return VCD_ERR_ILLEGAL_OP;
    }

    if ((NULL != p_header) &&
            ((0 == p_header->n_sequence_header_len) ||
             (NULL == p_header->p_sequence_header)
            )
       ) {
        VIDC_LOGERR_STRING("ddl_dec_start:Bad_param_seq_header");
        return VCD_ERR_ILLEGAL_PARM;
    }

    if (FALSE == ddl_decoder_ready_to_start(p_ddl, p_header)) {
        VIDC_LOGERR_STRING("ddl_dec_start:Err_param_settings");
        return VCD_ERR_ILLEGAL_OP;
    }

    DDL_BUSY(p_ddl_context);

    p_decoder = &p_ddl->codec_data.decoder;
    if (p_header) {
        p_decoder->b_header_in_start = TRUE;
        p_decoder->decode_config = *p_header;
    } else {
        p_decoder->b_header_in_start = FALSE;
        p_decoder->decode_config.n_sequence_header_len = 0;
    }

    if (p_decoder->codec_type.e_codec == VCD_CODEC_H264) {
        ddl_pmem_alloc(&p_decoder->h264Vsp_temp_buffer,
                       DDL_DECODE_H264_VSPTEMP_BUFSIZE,
                       DDL_LINEAR_BUFFER_ALIGN_BYTES);
        if (p_decoder->h264Vsp_temp_buffer.p_virtual_base_addr
                == NULL) {
            DDL_IDLE(p_ddl_context);
            VIDC_LOGERR_STRING
            ("ddl_dec_start:H264Sps_alloc_failed");
            return VCD_ERR_ALLOC_FAIL;
        }
    }

    p_ddl_context->p_current_ddl = p_ddl;
    p_ddl_context->p_client_data = p_client_data;

    ddl_channel_set(p_ddl);
    return VCD_S_SUCCESS;
}
Пример #13
0
u32 ddl_encode_start(u32 *ddl_handle, void *p_client_data)
{
    struct ddl_client_context_type *p_ddl =
        (struct ddl_client_context_type *)ddl_handle;
    struct ddl_context_type *p_ddl_context;
    struct ddl_encoder_data_type *p_encoder;
    u32 n_dpb_size;

    p_ddl_context = ddl_get_context();

    if (!DDL_IS_INITIALIZED(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_enc_start:Not_inited");
        return VCD_ERR_ILLEGAL_OP;
    }
    if (DDL_IS_BUSY(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_enc_start:Ddl_busy");
        return VCD_ERR_BUSY;
    }
    if (NULL == p_ddl || TRUE == p_ddl->b_decoding) {
        VIDC_LOGERR_STRING("ddl_enc_start:Bad_handle");
        return VCD_ERR_BAD_HANDLE;
    }

    if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_OPEN)) {
        VIDC_LOGERR_STRING("ddl_enc_start:Not_opened");
        return VCD_ERR_ILLEGAL_OP;
    }

    if (FALSE == ddl_encoder_ready_to_start(p_ddl)) {
        VIDC_LOGERR_STRING("ddl_enc_start:Err_param_settings");
        return VCD_ERR_ILLEGAL_OP;
    }

    p_encoder = &p_ddl->codec_data.encoder;

    n_dpb_size = ddl_get_yuv_buffer_size(&p_encoder->frame_size,
                                         &p_encoder->re_con_buf_format, FALSE);

    n_dpb_size *= DDL_ENC_NUM_DPB_BUFFERS;
    ddl_pmem_alloc(&p_encoder->enc_dpb_addr,
                   n_dpb_size, DDL_TILE_BUFFER_ALIGN_BYTES);
    if (NULL == p_encoder->enc_dpb_addr.p_virtual_base_addr) {
        VIDC_LOGERR_STRING("ddl_enc_start:Dpb_alloc_failed");
        return VCD_ERR_ALLOC_FAIL;
    }

    if ((VCD_CODEC_MPEG4 == p_encoder->codec_type.e_codec &&
            FALSE == p_encoder->short_header.b_short_header) ||
            VCD_CODEC_H264 == p_encoder->codec_type.e_codec) {
        ddl_pmem_alloc(&p_encoder->seq_header,
                       DDL_ENC_SEQHEADER_SIZE,
                       DDL_LINEAR_BUFFER_ALIGN_BYTES);
        if (NULL == p_encoder->seq_header.p_virtual_base_addr) {
            ddl_pmem_free(p_encoder->enc_dpb_addr);
            VIDC_LOGERR_STRING
            ("ddl_enc_start:Seq_hdr_alloc_failed");
            return VCD_ERR_ALLOC_FAIL;
        }
    } else {
        p_encoder->seq_header.n_buffer_size = 0;
        p_encoder->seq_header.p_virtual_base_addr = 0;
    }

    DDL_BUSY(p_ddl_context);

    p_ddl_context->p_current_ddl = p_ddl;
    p_ddl_context->p_client_data = p_client_data;
    ddl_channel_set(p_ddl);
    return VCD_S_SUCCESS;
}
Пример #14
0
u32 ddl_device_init(struct ddl_init_config *ddl_init_config,
	void *client_data)
{
	struct ddl_context *ddl_context;
	struct res_trk_firmware_addr firmware_addr;
	u32 status = VCD_S_SUCCESS, memorytype = PMEM_MEMTYPE;
	void *ptr = NULL;
	DDL_MSG_HIGH("ddl_device_init");

	if ((!ddl_init_config) || (!ddl_init_config->ddl_callback) ||
		(!ddl_init_config->core_virtual_base_addr)) {
		DDL_MSG_ERROR("ddl_dev_init:Bad_argument");
		return VCD_ERR_ILLEGAL_PARM;
	}
	ddl_context = ddl_get_context();
	if (DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_dev_init:Multiple_init");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!DDL_IS_IDLE(ddl_context)) {
		DDL_MSG_ERROR("ddl_dev_init:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	memset(ddl_context, 0, sizeof(struct ddl_context));
	DDL_BUSY(ddl_context);
	ddl_context->ddl_callback = ddl_init_config->ddl_callback;
	if (ddl_init_config->interrupt_clr)
		ddl_context->interrupt_clr =
			ddl_init_config->interrupt_clr;
	ddl_context->core_virtual_base_addr =
		ddl_init_config->core_virtual_base_addr;
	ddl_context->client_data = client_data;
	ddl_context->ddl_hw_response.arg1 = DDL_INVALID_INTR_STATUS;

	ddl_context->frame_channel_depth = VCD_FRAME_COMMAND_DEPTH;

	DDL_MSG_LOW("%s() : virtual address of core(%x)\n", __func__,
		(u32) ddl_init_config->core_virtual_base_addr);
	vidc_1080p_set_device_base_addr(
		ddl_context->core_virtual_base_addr);
	ddl_context->cmd_state =	DDL_CMD_INVALID;
	ddl_client_transact(DDL_INIT_CLIENTS, NULL);
	ddl_context->fw_memory_size =
		DDL_FW_INST_GLOBAL_CONTEXT_SPACE_SIZE;
	if (memorytype == PMEM_MEMTYPE_SMI) {
		ptr = ddl_pmem_alloc(&ddl_context->dram_base_a,
			ddl_context->fw_memory_size, DDL_KILO_BYTE(128));
	} else {
		if (!res_trk_get_firmware_addr(&firmware_addr) &&
		   firmware_addr.buf_size >= ddl_context->fw_memory_size) {
			if (DDL_ADDR_IS_ALIGNED(firmware_addr.device_addr,
				DDL_KILO_BYTE(128))) {
				ptr = (void *) firmware_addr.base_addr;
				ddl_context->dram_base_a.physical_base_addr =
				ddl_context->dram_base_a.align_physical_addr =
					(u8 *)firmware_addr.device_addr;
				ddl_context->dram_base_a.align_virtual_addr  =
				ddl_context->dram_base_a.virtual_base_addr =
					firmware_addr.base_addr;
				ddl_context->dram_base_a.buffer_size =
					ddl_context->fw_memory_size;
			} else {
				DDL_MSG_ERROR("firmware base not aligned %p",
					(void *)firmware_addr.device_addr);
			}
		}
	}
	if (!ptr) {
		DDL_MSG_ERROR("Memory Aocation Failed for FW Base");
		status = VCD_ERR_ALLOC_FAIL;
	} else {
		DDL_MSG_LOW("%s() : physical address of base(%x)\n",
			 __func__, (u32) ddl_context->dram_base_a.\
			align_physical_addr);
		ddl_context->dram_base_b.align_physical_addr =
			ddl_context->dram_base_a.align_physical_addr;
		ddl_context->dram_base_b.align_virtual_addr  =
			ddl_context->dram_base_a.align_virtual_addr;
	}
	if (!status) {
		ptr = ddl_pmem_alloc(&ddl_context->metadata_shared_input,
			DDL_METADATA_TOTAL_INPUTBUFSIZE,
			DDL_LINEAR_BUFFER_ALIGN_BYTES);
		if (!ptr) {
			DDL_MSG_ERROR("ddl_device_init: metadata alloc fail");
			status = VCD_ERR_ALLOC_FAIL;
		}
	}
	if (!status && !ddl_fw_init(&ddl_context->dram_base_a)) {
		DDL_MSG_ERROR("ddl_dev_init:fw_init_failed");
		status = VCD_ERR_ALLOC_FAIL;
	}
	if (!status && memorytype == PMEM_MEMTYPE_EBI1)
		clean_caches((unsigned long)firmware_addr.base_addr,
		firmware_addr.buf_size,	firmware_addr.device_addr);

	if (!status) {
		ddl_context->cmd_state = DDL_CMD_DMA_INIT;
		ddl_vidc_core_init(ddl_context);
	} else {
		ddl_release_context_buffers(ddl_context);
		DDL_IDLE(ddl_context);
	}
	return status;
}