Beispiel #1
0
int q6usm_us_client_buf_free(unsigned int dir,
			     struct us_client *usc)
{
	struct us_port_data *port;
	int rc = 0;
	uint32_t size = 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->data == NULL) {
		mutex_unlock(&usc->cmd_lock);
		return 0;
	}

	rc = q6usm_memory_unmap(usc, port->phys, dir);
	if (rc)
		pr_err("%s: CMD Memory_unmap* failed\n", __func__);

	pr_debug("%s: data[%p]phys[%p][%p]\n", __func__,
		 (void *)port->data, (void *)port->phys, (void *)&port->phys);
	size = port->buf_size * port->buf_cnt;
	dma_free_coherent(NULL, size, port->data, port->phys);
	port->data = NULL;
	port->phys = 0;
	port->buf_size = 0;
	port->buf_cnt = 0;

	mutex_unlock(&usc->cmd_lock);
	return 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;
}
Beispiel #3
0
int q6usm_us_param_buf_free(unsigned int dir,
                            struct us_client *usc)
{
    struct us_port_data *port;
    int rc = 0;
    uint32_t size = 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[%p][%p]\n", __func__,
             (void *)port->param_buf, (void *)port->param_phys,
             (void *)&port->param_phys);
    /* 4K boundary is required by the API with QDSP6 */
    size = (port->param_buf_size + MEM_4K_OFFSET) & MEM_4K_MASK;
    dma_free_coherent(NULL, size, port->param_buf, port->param_phys);
    port->param_buf = NULL;
    port->param_phys = 0;
    port->param_buf_size = 0;

    mutex_unlock(&usc->cmd_lock);
    return rc;
}
int q6usm_us_client_buf_free(unsigned int dir,
			     struct us_client *usc)
{
	struct us_port_data *port;
	int rc = 0;
	uint32_t size = 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->data == NULL) {
		mutex_unlock(&usc->cmd_lock);
		return 0;
	}

	rc = q6usm_memory_unmap(port->phys, dir, usc->session,
				*((uint32_t *)port->ext));
	pr_debug("%s: data[%p]phys[%p][%p]\n", __func__,
		 (void *)port->data, (void *)port->phys, (void *)&port->phys);
	
	size = (port->buf_size * port->buf_cnt + MEM_4K_OFFSET) & MEM_4K_MASK;
	dma_free_coherent(NULL, size, port->data, port->phys);
	port->data = NULL;
	port->phys = 0;
	port->buf_size = 0;
	port->buf_cnt = 0;

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