static int deregister_memory(void)
{
	int	result = 0;
	pr_debug("%s\n", __func__);

	if (acdb_data.mem_len == 0)
		goto done;

	pr_debug("Remove existing memory\n");
	acdb_data.mem_len = 0;

	/* unmap all cal data */
	result = unmap_cal_tables();
	if (result < 0)
		pr_err("%s: unmap_cal_tables failed, err = %d\n",
			__func__, result);

	msm_audio_ion_free(acdb_data.ion_client, acdb_data.ion_handle);
	acdb_data.ion_client = NULL;
	acdb_data.ion_handle = NULL;

	deallocate_col_data();
	deallocate_hw_delay_entries();
done:
	return result;
}
static int deregister_memory(void)
{
	int	result = 0;
	int	i;
	pr_debug("%s\n", __func__);

	mutex_lock(&acdb_data.acdb_mutex);
	kfree(acdb_data.hw_delay_tx.delay_info);
	kfree(acdb_data.hw_delay_rx.delay_info);

	if (atomic64_read(&acdb_data.mem_len)) {
		/* unmap all cal data */
		result = unmap_cal_tables();
		if (result < 0)
			pr_err("%s: unmap_cal_tables failed, err = %d\n",
				__func__, result);

		atomic64_set(&acdb_data.mem_len, 0);

		for (i = 0; i < MAX_VOCPROC_TYPES; i++) {
			kfree(acdb_data.col_data[i]);
			acdb_data.col_data[i] = NULL;
		}
		msm_audio_ion_free(acdb_data.ion_client, acdb_data.ion_handle);
		acdb_data.ion_client = NULL;
		acdb_data.ion_handle = NULL;
		mutex_unlock(&acdb_data.acdb_mutex);
	}
	mutex_unlock(&acdb_data.acdb_mutex);
	return 0;
}
int rtac_free_cal_buffer(uint32_t cal_type)
{
	int result = 0;
	pr_debug("%s\n", __func__);

	if (cal_type >= MAX_RTAC_BLOCKS) {
		pr_err("%s: cal_type %d is invalid!\n",
		       __func__, cal_type);
		result =  -EINVAL;
		goto done;
	}

	if (rtac_cal[cal_type].map_data.ion_client == NULL) {
		pr_debug("%s: cal_type %d not allocated!\n",
		       __func__, cal_type);
		goto done;
	}

	result = msm_audio_ion_free(rtac_cal[cal_type].map_data.ion_client,
				rtac_cal[cal_type].map_data.ion_handle);
	if (result < 0) {
		pr_err("%s: ION free for RTAC failed! cal_type %d, paddr 0x%x\n",
		       __func__, cal_type, rtac_cal[cal_type].cal_data.paddr);
		goto done;
	}

	rtac_cal[cal_type].map_data.map_handle = 0;
	rtac_cal[cal_type].map_data.ion_client = NULL;
	rtac_cal[cal_type].map_data.ion_handle = NULL;
	rtac_cal[cal_type].cal_data.size = 0;
	rtac_cal[cal_type].cal_data.kvaddr = 0;
	rtac_cal[cal_type].cal_data.paddr = 0;
done:
	return result;
}
Пример #4
0
int q6lsm_snd_model_buf_free(struct lsm_client *client)
{
	int rc;

	pr_debug("%s: Session id %d\n", __func__, client->session);
	if (CHECK_SESSION(client->session))
		return -EINVAL;

	mutex_lock(&client->cmd_lock);
	rc = q6lsm_memory_unmap_regions(client,
					client->sound_model.mem_map_handle);
	if (rc < 0)
		pr_err("%s CMD Memory_unmap_regions failed\n", __func__);

	if (client->sound_model.data) {
		msm_audio_ion_free(client->sound_model.client,
				 client->sound_model.handle);
		client->sound_model.client = NULL;
		client->sound_model.handle = NULL;
		client->sound_model.data = NULL;
		client->sound_model.phys = 0;
		client->lsm_cal_phy_addr = 0;
		client->lsm_cal_size = 0;
	}
	mutex_unlock(&client->cmd_lock);
	return rc;
}
static int deregister_memory(void)
{
	int	result = 0;
	int	i;
	pr_debug("%s\n", __func__);

	if (acdb_data.mem_len == 0)
		goto done;

	pr_debug("Remove existing memory\n");
	acdb_data.mem_len = 0;

	/* unmap all cal data */
	result = unmap_cal_tables();
	if (result < 0)
		pr_err("%s: unmap_cal_tables failed, err = %d\n",
			__func__, result);

	msm_audio_ion_free(acdb_data.ion_client, acdb_data.ion_handle);
	acdb_data.ion_client = NULL;
	acdb_data.ion_handle = NULL;

	for (i = 0; i < MAX_VOCPROC_TYPES; i++) {
		kfree(acdb_data.col_data[i]);
		acdb_data.col_data[i] = NULL;
	}

	kfree(acdb_data.hw_delay_tx.delay_info);
	kfree(acdb_data.hw_delay_rx.delay_info);
done:
	return result;
}
static int register_memory(void)
{
	int			result;
	int			i;
	ion_phys_addr_t		paddr;
	void                    *kvptr;
	unsigned long		kvaddr;
	unsigned long		mem_len;
	pr_debug("%s\n", __func__);

	mutex_lock(&acdb_data.acdb_mutex);
	allocate_hw_delay_entries();
	for (i = 0; i < MAX_VOCPROC_TYPES; i++) {
		acdb_data.col_data[i] = kmalloc(MAX_COL_SIZE, GFP_KERNEL);
		atomic_set(&acdb_data.vocproc_col_cal[i].cal_kvaddr,
			(uint32_t)acdb_data.col_data[i]);
	}

	result = msm_audio_ion_import("audio_acdb_client",
				&acdb_data.ion_client,
				&acdb_data.ion_handle,
				atomic_read(&acdb_data.map_handle),
				NULL, 0,
				&paddr, (size_t *)&mem_len, &kvptr);
	if (result) {
		pr_err("%s: audio ION alloc failed, rc = %d\n",
			__func__, result);
		result = PTR_ERR(acdb_data.ion_client);
		goto err_ion_handle;
	}
	kvaddr = (unsigned long)kvptr;
	atomic64_set(&acdb_data.paddr, paddr);
	atomic64_set(&acdb_data.kvaddr, kvaddr);
	atomic64_set(&acdb_data.mem_len, mem_len);
	mutex_unlock(&acdb_data.acdb_mutex);

	pr_debug("%s done! paddr = 0x%lx, kvaddr = 0x%lx, len = x%lx\n",
		 __func__,
		(long)atomic64_read(&acdb_data.paddr),
		(long)atomic64_read(&acdb_data.kvaddr),
		(long)atomic64_read(&acdb_data.mem_len));

	return result;
err_ion_handle:
	msm_audio_ion_free(acdb_data.ion_client, acdb_data.ion_handle);

	atomic64_set(&acdb_data.mem_len, 0);
	mutex_unlock(&acdb_data.acdb_mutex);
	return result;
}
Пример #7
0
static int deregister_memory(void)
{
	int i;

	if (atomic64_read(&acdb_data.mem_len)) {
		mutex_lock(&acdb_data.acdb_mutex);
		atomic64_set(&acdb_data.mem_len, 0);

		for (i = 0; i < MAX_VOCPROC_TYPES; i++) {
			kfree(acdb_data.col_data[i]);
			acdb_data.col_data[i] = NULL;
		}
		msm_audio_ion_free(acdb_data.ion_client, acdb_data.ion_handle);
		mutex_unlock(&acdb_data.acdb_mutex);
	}
	return 0;
}
Пример #8
0
int q6usm_us_param_buf_free(unsigned int dir,
			struct us_client *usc)
{
	struct us_port_data *port;
	int rc = 0;

	if ((usc == NULL) ||
		((dir != IN) && (dir != OUT)))
		return -EINVAL;

	mutex_lock(&usc->cmd_lock);
	port = &usc->port[dir];
	if (port == NULL) {
		mutex_unlock(&usc->cmd_lock);
		return -EINVAL;
	}

	if (port->param_buf == NULL) {
		mutex_unlock(&usc->cmd_lock);
		return 0;
	}

	rc = q6usm_memory_unmap(port->param_phys, dir, usc->session,
				*((uint32_t *)port->param_buf_mem_handle));
	pr_debug("%s: data[%p]phys[%llx][%p]\n", __func__,
		 (void *)port->param_buf, (u64)port->param_phys,
		 (void *)&port->param_phys);

	msm_audio_ion_free(port->param_client, port->param_handle);

	port->param_buf = NULL;
	port->param_phys = 0;
	port->param_buf_size = 0;
	port->param_client = NULL;
	port->param_handle = NULL;

	mutex_unlock(&usc->cmd_lock);
	return rc;
}