Beispiel #1
0
void res_trk_init(struct device *device, u32 irq)
{
	if (resource_context.device || resource_context.irq_num ||
		!device) {
		VCDRES_MSG_ERROR("%s() Resource Tracker Init error\n",
			__func__);
	} else {
		memset(&resource_context, 0, sizeof(resource_context));
		mutex_init(&resource_context.lock);
		mutex_init(&resource_context.secure_lock);
		resource_context.device = device;
		resource_context.irq_num = irq;
		resource_context.vidc_platform_data =
			(struct msm_vidc_platform_data *) device->platform_data;
		if (resource_context.vidc_platform_data) {
			resource_context.memtype =
			resource_context.vidc_platform_data->memtype;
			resource_context.fw_mem_type =
			resource_context.vidc_platform_data->memtype;
			resource_context.cmd_mem_type =
			resource_context.vidc_platform_data->memtype;
			if (resource_context.vidc_platform_data->enable_ion) {
				resource_context.res_ion_client =
					res_trk_create_ion_client();
				if (!(resource_context.res_ion_client)) {
					VCDRES_MSG_ERROR("%s()ION createfail\n",
							__func__);
					return;
				}
				resource_context.fw_mem_type =
				ION_MM_FIRMWARE_HEAP_ID;
				resource_context.cmd_mem_type =
				ION_CP_MFC_HEAP_ID;
			}
			resource_context.disable_dmx =
			resource_context.vidc_platform_data->disable_dmx;
			resource_context.disable_fullhd =
			resource_context.vidc_platform_data->disable_fullhd;
#ifdef CONFIG_MSM_BUS_SCALING
			resource_context.vidc_bus_client_pdata =
			resource_context.vidc_platform_data->
				vidc_bus_client_pdata;
#endif
		} else {
			resource_context.memtype = -1;
			resource_context.disable_dmx = 0;
		}
		resource_context.core_type = VCD_CORE_1080P;
		resource_context.firmware_addr.mem_type = DDL_FW_MEM;
		if (!res_trk_pmem_alloc(&resource_context.firmware_addr,
			VIDC_FW_SIZE, DDL_KILO_BYTE(128))) {
			pr_err("%s() Firmware buffer allocation failed",
				   __func__);
			if (!res_trk_check_for_sec_session())
				memset(&resource_context.firmware_addr, 0,
						sizeof(resource_context.firmware_addr));
		}
	}
}
u32 res_trk_get_firmware_addr(struct ddl_buf_addr *firm_addr)
{
	int rc = 0;
	size_t size = 0;
	if (!firm_addr || resource_context.firmware_addr.mapped_buffer) {
		pr_err("%s() invalid params", __func__);
		return -EINVAL;
	}
	if (res_trk_is_cp_enabled() && res_trk_check_for_sec_session())
		size = PIL_FW_SIZE;
	else
		size = VIDC_FW_SIZE;

	if (res_trk_pmem_alloc(&resource_context.firmware_addr,
				size, DDL_KILO_BYTE(128))) {
		pr_err("%s() Firmware buffer allocation failed",
				__func__);
		memset(&resource_context.firmware_addr, 0,
				sizeof(resource_context.firmware_addr));
		rc = -ENOMEM;
		goto fail_alloc;
	}
	if (!res_trk_pmem_map(&resource_context.firmware_addr,
		resource_context.firmware_addr.buffer_size,
		DDL_KILO_BYTE(128))) {
		pr_err("%s() Firmware buffer mapping failed",
			   __func__);
		rc = -ENOMEM;
		goto fail_map;
	}
	memcpy(firm_addr, &resource_context.firmware_addr,
		sizeof(struct ddl_buf_addr));
	return 0;
fail_map:
	res_trk_pmem_free(&resource_context.firmware_addr);
fail_alloc:
	return rc;
}