Пример #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_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;
}
Пример #3
0
u32 ddl_close(u32 **ddl_handle)
{
	struct ddl_context *ddl_context;
	struct ddl_client_context **pp_ddl =
		(struct ddl_client_context **)ddl_handle;

	DDL_MSG_HIGH("ddl_close");
	if (!pp_ddl || !*pp_ddl) {
		DDL_MSG_ERROR("ddl_close:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_close:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!DDLCLIENT_STATE_IS(*pp_ddl, DDL_CLIENT_OPEN)) {
		DDL_MSG_ERROR("ddl_close:Not_in_open_state");
		return VCD_ERR_ILLEGAL_OP;
	}
	ddl_pmem_free(&(*pp_ddl)->shared_mem[0]);
	if (ddl_context->frame_channel_depth ==
		VCD_DUAL_FRAME_COMMAND_CHANNEL)
		ddl_pmem_free(&(*pp_ddl)->shared_mem[1]);
	DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_INVALID",
	ddl_get_state_string((*pp_ddl)->client_state));
	(*pp_ddl)->client_state = DDL_CLIENT_INVALID;
	ddl_codec_type_transact(*pp_ddl, true, (enum vcd_codec)0);
	ddl_client_transact(DDL_FREE_CLIENT, pp_ddl);
	return VCD_S_SUCCESS;
}
Пример #4
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;
}
Пример #5
0
u32 ddl_close(u32 **ddl_handle)
{
	struct ddl_context *ddl_context;
	struct ddl_client_context **ddl =
	    (struct ddl_client_context **)ddl_handle;

	if (!ddl || !*ddl) {
		VIDC_LOGERR_STRING("ddl_close:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}

	ddl_context = ddl_get_context();

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

	if (!DDLCLIENT_STATE_IS(*ddl, DDL_CLIENT_OPEN)) {
		VIDC_LOGERR_STRING("ddl_close:Not_in_open_state");
		return VCD_ERR_ILLEGAL_OP;
	}

	ddl_move_client_state(*ddl, DDL_CLIENT_INVALID);
	if ((*ddl)->decoding) {
		vcd_fw_transact(false, true,
			(*ddl)->codec_data.decoder.codec.codec);
	} else {
		vcd_fw_transact(false, false,
			(*ddl)->codec_data.encoder.codec.codec);
	}
	ddl_client_transact(DDL_FREE_CLIENT, ddl);

	return VCD_S_SUCCESS;
}
Пример #6
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;
}
Пример #7
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;
}
Пример #8
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;
}
Пример #9
0
u32 ddl_close(u32 **p_ddl_handle)
{
    struct ddl_context_type *p_ddl_context;
    struct ddl_client_context_type **pp_ddl =
        (struct ddl_client_context_type **)p_ddl_handle;

    if (NULL == pp_ddl || NULL == *pp_ddl) {
        VIDC_LOGERR_STRING("ddl_close:Bad_handle");
        return VCD_ERR_BAD_HANDLE;
    }

    p_ddl_context = ddl_get_context();

    if (!DDL_IS_INITIALIZED(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_close:Not_inited");
        return VCD_ERR_ILLEGAL_OP;
    }

    if (!DDLCLIENT_STATE_IS(*pp_ddl, DDL_CLIENT_OPEN)) {
        VIDC_LOGERR_STRING("ddl_close:Not_in_open_state");
        return VCD_ERR_ILLEGAL_OP;
    }

    ddl_move_client_state(*pp_ddl, DDL_CLIENT_INVALID);
    if ((*pp_ddl)->b_decoding) {
        vcd_fw_transact(FALSE, TRUE,
                        (*pp_ddl)->codec_data.decoder.codec_type.e_codec);
    } else {
        vcd_fw_transact(FALSE, FALSE,
                        (*pp_ddl)->codec_data.encoder.codec_type.e_codec);
    }
    ddl_client_transact(DDL_FREE_CLIENT, pp_ddl);

    return VCD_S_SUCCESS;
}
Пример #10
0
u32 ddl_open(u32 **ddl_handle, u32 decoding)
{
	struct ddl_context *ddl_context;
	struct ddl_client_context *ddl;
	u32 status;

	if (!ddl_handle) {
		VIDC_LOGERR_STRING("ddl_open:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}

	ddl_context = ddl_get_context();

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

	status = ddl_client_transact(DDL_GET_CLIENT, &ddl);

	if (status) {
		VIDC_LOGERR_STRING("ddl_open:Client_trasac_failed");
		return status;
	}

	ddl_move_client_state(ddl, 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;
	return VCD_S_SUCCESS;
}
Пример #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 = 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;
}
Пример #12
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;
}
Пример #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;
	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;
}
Пример #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;
}