Esempio n. 1
0
u32 ddl_device_release(void *client_data)
{
	struct ddl_context *ddl_context;

	ddl_context = ddl_get_context();

	if (DDL_IS_BUSY(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dev_rel:Ddl_busy");
		return VCD_ERR_BUSY;
	}

	if (!DDL_IS_INITIALIZED(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dev_rel:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}

	if (!ddl_client_transact(DDL_ACTIVE_CLIENT, NULL)) {
		VIDC_LOGERR_STRING("ddl_dev_rel:Client_present_err");
		return VCD_ERR_CLIENT_PRESENT;
	}
	DDL_BUSY(ddl_context);

	ddl_context->device_state = DDL_DEVICE_NOTINIT;
	ddl_context->client_data = client_data;
	ddl_move_command_state(ddl_context, DDL_CMD_INVALID);
	vidc_720p_stop_fw();

	VIDC_LOG_STRING("FW_ENDDONE");
	ddl_release_context_buffers(ddl_context);

	DDL_IDLE(ddl_context);

	return VCD_S_SUCCESS;
}
Esempio n. 2
0
u32 ddl_device_release(void *client_data)
{
	struct ddl_context *ddl_context;

	DDL_MSG_HIGH("ddl_device_release");
	ddl_context = ddl_get_context();
	if (!DDL_IS_IDLE(ddl_context)) {
		DDL_MSG_ERROR("ddl_dev_rel:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_dev_rel:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!ddl_client_transact(DDL_ACTIVE_CLIENT, NULL)) {
		DDL_MSG_ERROR("ddl_dev_rel:Client_present_err");
		return VCD_ERR_CLIENT_PRESENT;
	}
	DDL_BUSY(ddl_context);
	ddl_context->device_state = DDL_DEVICE_NOTINIT;
	ddl_context->client_data = client_data;
	ddl_context->cmd_state = DDL_CMD_INVALID;
	ddl_vidc_core_term(ddl_context);
	DDL_MSG_LOW("FW_ENDDONE");
	ddl_context->core_virtual_base_addr = NULL;
	ddl_release_context_buffers(ddl_context);
	ddl_context->video_ion_client = NULL;
	DDL_IDLE(ddl_context);
	return VCD_S_SUCCESS;
}
Esempio n. 3
0
u32 ddl_reset_hw(u32 mode)
{
	struct ddl_context *ddl_context;
	struct ddl_client_context *ddl;
	int i_client_num;

	VIDC_LOG_STRING("ddl_reset_hw:called");
	ddl_context = ddl_get_context();
	ddl_move_command_state(ddl_context, DDL_CMD_INVALID);
	DDL_BUSY(ddl_context);

	if (ddl_context->core_virtual_base_addr)
		vidc_720p_do_sw_reset();

	ddl_context->device_state = DDL_DEVICE_NOTINIT;
	for (i_client_num = 0; i_client_num < VCD_MAX_NO_CLIENT;
			++i_client_num) {
		ddl = ddl_context->ddl_clients[i_client_num];
		ddl_context->ddl_clients[i_client_num] = NULL;
		if (ddl) {
			ddl_release_client_internal_buffers(ddl);
			ddl_client_transact(DDL_FREE_CLIENT, &ddl);
		}
	}

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

	return true;
}
Esempio n. 4
0
u32 ddl_reset_hw(u32 mode)
{
	struct ddl_context *ddl_context;
	struct ddl_client_context *ddl;
	u32 i;

	DDL_MSG_HIGH("ddl_reset_hw");
	DDL_MSG_LOW("ddl_reset_hw:called");
	ddl_context = ddl_get_context();
	ddl_context->cmd_state = DDL_CMD_INVALID;
	DDL_BUSY(ddl_context);
	if (ddl_context->core_virtual_base_addr) {
		vidc_1080p_do_sw_reset(VIDC_1080P_RESET_IN_SEQ_FIRST_STAGE);
		msleep(DDL_SW_RESET_SLEEP);
		vidc_1080p_do_sw_reset(VIDC_1080P_RESET_IN_SEQ_SECOND_STAGE);
		msleep(DDL_SW_RESET_SLEEP);
		ddl_context->core_virtual_base_addr = NULL;
	}
	ddl_context->device_state = DDL_DEVICE_NOTINIT;
	for (i = 0; i < VCD_MAX_NO_CLIENT; i++) {
		ddl = ddl_context->ddl_clients[i];
		ddl_context->ddl_clients[i] = NULL;
		if (ddl) {
			ddl_release_client_internal_buffers(ddl);
			ddl_client_transact(DDL_FREE_CLIENT, &ddl);
		}
	}
	ddl_release_context_buffers(ddl_context);
	memset(ddl_context, 0, sizeof(struct ddl_context));
	return true;
}
Esempio n. 5
0
u32 ddl_reset_hw(u32 n_mode)
{
    struct ddl_context_type *p_ddl_context;
    struct ddl_client_context_type *p_ddl;
    int i_client_num;

    VIDC_LOG_STRING("ddl_reset_hw:called");
    p_ddl_context = ddl_get_context();
    ddl_move_command_state(p_ddl_context, DDL_CMD_INVALID);
    DDL_BUSY(p_ddl_context);

    if (NULL != p_ddl_context->p_core_virtual_base_addr)
        vidc_720p_do_sw_reset();

    p_ddl_context->n_device_state = DDL_DEVICE_NOTINIT;
    for (i_client_num = 0; i_client_num < VCD_MAX_NO_CLIENT;
            ++i_client_num) {
        p_ddl = p_ddl_context->a_ddl_clients[i_client_num];
        p_ddl_context->a_ddl_clients[i_client_num] = NULL;
        if (p_ddl) {
            ddl_release_client_internal_buffers(p_ddl);
            ddl_client_transact(DDL_FREE_CLIENT, &p_ddl);
        }
    }

    ddl_release_context_buffers(p_ddl_context);
    DDL_MEMSET(p_ddl_context, 0, sizeof(struct ddl_context_type));

    VIDC_LOG_BUFFER_INIT;
    return TRUE;
}
Esempio n. 6
0
u32 ddl_decode_end(u32 *ddl_handle, void *client_data)
{
	struct ddl_client_context *ddl =
	    (struct ddl_client_context *)ddl_handle;
	struct ddl_context *ddl_context;

	ddl_context = ddl_get_context();

	if (vidc_msg_timing) {
		ddl_reset_core_time_variables(DEC_OP_TIME);
		ddl_reset_core_time_variables(DEC_IP_TIME);
	}

	if (!DDL_IS_INITIALIZED(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dec_end:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dec_end:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || !ddl->decoding) {
		VIDC_LOGERR_STRING("ddl_dec_end:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	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) &&
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_FATAL_ERROR)
	    ) {
		VIDC_LOGERR_STRING("ddl_dec_end:Wrong_state");
		return VCD_ERR_ILLEGAL_OP;
	}
	DDL_BUSY(ddl_context);

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

	ddl_channel_end(ddl);
	return VCD_S_SUCCESS;
}
Esempio n. 7
0
u32 ddl_decode_end(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;

    p_ddl_context = ddl_get_context();

#ifdef CORE_TIMING_INFO
    ddl_reset_time_variables(0);
#endif

    if (!DDL_IS_INITIALIZED(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_end:Not_inited");
        return VCD_ERR_ILLEGAL_OP;
    }
    if (DDL_IS_BUSY(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_end:Ddl_busy");
        return VCD_ERR_BUSY;
    }
    if (NULL == p_ddl || FALSE == p_ddl->b_decoding) {
        VIDC_LOGERR_STRING("ddl_dec_end:Bad_handle");
        return VCD_ERR_BAD_HANDLE;
    }
    if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_FRAME) &&
            !DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) &&
            !DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_DPB) &&
            !DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_FATAL_ERROR)
       ) {
        VIDC_LOGERR_STRING("ddl_dec_end:Wrong_state");
        return VCD_ERR_ILLEGAL_OP;
    }
    DDL_BUSY(p_ddl_context);

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

    ddl_channel_end(p_ddl);
    return VCD_S_SUCCESS;
}
Esempio n. 8
0
u32 ddl_encode_frame(u32 *ddl_handle,
     struct ddl_frame_data_tag *input_frame,
     struct ddl_frame_data_tag *output_bit, void *client_data)
{
	struct ddl_client_context *ddl =
	    (struct ddl_client_context *)ddl_handle;
	struct ddl_context *ddl_context = ddl_get_context();

	if (vidc_msg_timing)
		ddl_set_core_start_time(__func__, ENC_OP_TIME);

	if (!DDL_IS_INITIALIZED(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_enc_frame:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_enc_frame:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || ddl->decoding) {
		VIDC_LOGERR_STRING("ddl_enc_frame:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!input_frame ||
	    !input_frame->vcd_frm.physical ||
	    ddl->codec_data.encoder.input_buf_req.sz !=
	    input_frame->vcd_frm.data_len) {
		VIDC_LOGERR_STRING("ddl_enc_frame:Bad_input_params");
		return VCD_ERR_ILLEGAL_PARM;
	}
	if ((((u32) input_frame->vcd_frm.physical +
		   input_frame->vcd_frm.offset) &
		  (DDL_STREAMBUF_ALIGN_GUARD_BYTES)
	    )
	    ) {
		VIDC_LOGERR_STRING
		    ("ddl_enc_frame:Un_aligned_yuv_start_address");
		return VCD_ERR_ILLEGAL_PARM;
	}
	if (!output_bit ||
	    !output_bit->vcd_frm.physical ||
	    !output_bit->vcd_frm.alloc_len) {
		VIDC_LOGERR_STRING("ddl_enc_frame:Bad_output_params");
		return VCD_ERR_ILLEGAL_PARM;
	}
	if ((ddl->codec_data.encoder.output_buf_req.sz +
	     output_bit->vcd_frm.offset) >
	    output_bit->vcd_frm.alloc_len) {
		VIDC_LOGERR_STRING
		    ("ddl_enc_frame:offset_large, Exceeds_min_buf_size");
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) {
		VIDC_LOGERR_STRING("ddl_enc_frame:Wrong_state");
		return VCD_ERR_ILLEGAL_OP;
	}

	DDL_BUSY(ddl_context);

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

	ddl->input_frame = *input_frame;
	ddl->output_frame = *output_bit;

	ddl_encode_frame_run(ddl);
	return VCD_S_SUCCESS;
}
Esempio n. 9
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 = ddl_get_context();

	if (!DDL_IS_INITIALIZED(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dec_frame:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dec_frame:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || !ddl->decoding) {
		VIDC_LOGERR_STRING("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))
	    )
	    ) {
		VIDC_LOGERR_STRING("ddl_dec_frame:Bad_input_param");
		return VCD_ERR_ILLEGAL_PARM;
	}

	DDL_BUSY(ddl_context);

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

	ddl->input_frame = *input_bits;

	if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) {
		ddl_decode_frame_run(ddl);
	} else {
		if (!ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) {
			VIDC_LOGERR_STRING("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_decode_set_buffers(ddl);
		} else
		    if (DDLCLIENT_STATE_IS
			(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC)) {
			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_decode_init_codec(ddl);
		} else {
			VIDC_LOGERR_STRING("Dec_frame:Wrong_state");
			vcd_status = VCD_ERR_ILLEGAL_OP;
		}
		if (vcd_status)
			DDL_IDLE(ddl_context);
	}
	return vcd_status;
}
Esempio n. 10
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;
}
Esempio n. 11
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;
}
Esempio n. 12
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;
}
Esempio n. 13
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;
}
Esempio n. 14
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;
}
Esempio n. 15
0
u32 ddl_encode_frame(u32 *ddl_handle,
                     struct ddl_frame_data_type_tag *p_input_frame,
                     struct ddl_frame_data_type_tag *p_output_bit, 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 = ddl_get_context();

#ifdef CORE_TIMING_INFO
    ddl_get_core_start_time(1);
#endif

    if (!DDL_IS_INITIALIZED(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_enc_frame:Not_inited");
        return VCD_ERR_ILLEGAL_OP;
    }
    if (DDL_IS_BUSY(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_enc_frame:Ddl_busy");
        return VCD_ERR_BUSY;
    }
    if (NULL == p_ddl || TRUE == p_ddl->b_decoding) {
        VIDC_LOGERR_STRING("ddl_enc_frame:Bad_handle");
        return VCD_ERR_BAD_HANDLE;
    }
    if (NULL == p_input_frame ||
            NULL == p_input_frame->vcd_frm.p_physical ||
            p_ddl->codec_data.encoder.input_buf_req.n_size !=
            p_input_frame->vcd_frm.n_data_len) {
        VIDC_LOGERR_STRING("ddl_enc_frame:Bad_input_params");
        return VCD_ERR_ILLEGAL_PARM;
    }
    if (0 != (((u32) p_input_frame->vcd_frm.p_physical +
               p_input_frame->vcd_frm.n_offset) &
              (DDL_STREAMBUF_ALIGN_GUARD_BYTES)
             )
       ) {
        VIDC_LOGERR_STRING
        ("ddl_enc_frame:Un_aligned_yuv_start_address");
        return VCD_ERR_ILLEGAL_PARM;
    }
    if (NULL == p_output_bit ||
            NULL == p_output_bit->vcd_frm.p_physical ||
            0 == p_output_bit->vcd_frm.n_alloc_len) {
        VIDC_LOGERR_STRING("ddl_enc_frame:Bad_output_params");
        return VCD_ERR_ILLEGAL_PARM;
    }
    if ((p_ddl->codec_data.encoder.output_buf_req.n_size +
            p_output_bit->vcd_frm.n_offset) >
            p_output_bit->vcd_frm.n_alloc_len) {
        VIDC_LOGERR_STRING
        ("ddl_enc_frame:n_offset_large, Exceeds_min_buf_size");
    }
    if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_FRAME)) {
        VIDC_LOGERR_STRING("ddl_enc_frame:Wrong_state");
        return VCD_ERR_ILLEGAL_OP;
    }

    DDL_BUSY(p_ddl_context);

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

    p_ddl->input_frame = *p_input_frame;
    p_ddl->output_frame = *p_output_bit;

    ddl_encode_frame_run(p_ddl);
    return VCD_S_SUCCESS;
}
Esempio n. 16
0
u32 ddl_decode_frame(u32 *ddl_handle,
                     struct ddl_frame_data_type_tag *p_input_bits, void *p_client_data)
{
    u32 vcd_status = VCD_S_SUCCESS;
    struct ddl_client_context_type *p_ddl =
        (struct ddl_client_context_type *)ddl_handle;
    struct ddl_context_type *p_ddl_context = ddl_get_context();

#ifdef CORE_TIMING_INFO
    ddl_get_core_start_time(0);
#endif

    if (!DDL_IS_INITIALIZED(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_frame:Not_inited");
        return VCD_ERR_ILLEGAL_OP;
    }
    if (DDL_IS_BUSY(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_frame:Ddl_busy");
        return VCD_ERR_BUSY;
    }
    if (NULL == p_ddl || FALSE == p_ddl->b_decoding) {
        VIDC_LOGERR_STRING("ddl_dec_frame:Bad_handle");
        return VCD_ERR_BAD_HANDLE;
    }
    if (NULL == p_input_bits ||
            ((0 == p_input_bits->vcd_frm.p_physical ||
              0 == p_input_bits->vcd_frm.n_data_len) &&
             (0 == (VCD_FRAME_FLAG_EOS & p_input_bits->vcd_frm.n_flags))
            )
       ) {
        VIDC_LOGERR_STRING("ddl_dec_frame:Bad_input_param");
        return VCD_ERR_ILLEGAL_PARM;
    }

    DDL_BUSY(p_ddl_context);

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

    p_ddl->input_frame = *p_input_bits;

    if (DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_FRAME)) {
        ddl_decode_frame_run(p_ddl);
    } else {
        if (0 == p_ddl->codec_data.decoder.dp_buf.n_no_of_dec_pic_buf) {
            VIDC_LOGERR_STRING("ddl_dec_frame:Dpbs_requied");
            vcd_status = VCD_ERR_ILLEGAL_OP;
        } else if (DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_DPB)) {
            vcd_status = ddl_decode_set_buffers(p_ddl);
        } else if (DDLCLIENT_STATE_IS
                   (p_ddl, DDL_CLIENT_WAIT_FOR_INITCODEC)) {
            p_ddl->codec_data.decoder.decode_config.
            p_sequence_header =
                p_ddl->input_frame.vcd_frm.p_physical;
            p_ddl->codec_data.decoder.decode_config.
            n_sequence_header_len =
                p_ddl->input_frame.vcd_frm.n_data_len;
            ddl_decode_init_codec(p_ddl);
        } else {
            VIDC_LOGERR_STRING("Dec_frame:Wrong_state");
            vcd_status = VCD_ERR_ILLEGAL_OP;
        }
        if (VCD_S_SUCCESS != vcd_status)
            DDL_IDLE(p_ddl_context);
    }
    return vcd_status;
}
Esempio n. 17
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;
}
Esempio n. 18
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;
}
Esempio n. 19
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;
}