dsp: update MSM Audio ION wrappers to align with upstream

Between Linux-4.9 and Linux-4.14, upstream has updated the
ION APIs significantly to make ION ready to bring out of
staging folder. This has changed the way ION and dma_buf
APIs used to work together for allocating, mapping and
deallocating ION buffers.
Update MSM Audio ION wrapper functions used by audio drivers
to reflect these ION API changes as per upstream ION.

Change-Id: I63097e147a397aa3a538f69ac88b6fb10871c3dc
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
This commit is contained in:
Banajit Goswami
2017-11-03 22:48:23 -07:00
parent b05cd67f29
commit 08bb73698a
22 changed files with 592 additions and 918 deletions

View File

@@ -1,6 +1,6 @@
/* Copyright (C) 2008 Google, Inc.
* Copyright (C) 2008 HTC Corporation
* Copyright (c) 2009-2017, The Linux Foundation. All rights reserved.
* Copyright (c) 2009-2018, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -420,7 +420,7 @@ void audio_aio_reset_ion_region(struct q6audio_aio *audio)
list_for_each_safe(ptr, next, &audio->ion_region_queue) {
region = list_entry(ptr, struct audio_aio_ion_region, list);
list_del(&region->list);
msm_audio_ion_free_legacy(audio->client, region->handle);
msm_audio_ion_free(region->dma_buf);
kfree(region);
}
}
@@ -614,7 +614,6 @@ int audio_aio_release(struct inode *inode, struct file *file)
audio_aio_disable(audio);
audio_aio_unmap_ion_region(audio);
audio_aio_reset_ion_region(audio);
msm_audio_ion_client_destroy(audio->client);
audio->event_abort = 1;
wake_up(&audio->event_wait);
audio_aio_reset_event_queue(audio);
@@ -960,11 +959,11 @@ static int audio_aio_ion_check(struct q6audio_aio *audio,
static int audio_aio_ion_add(struct q6audio_aio *audio,
struct msm_audio_ion_info *info)
{
ion_phys_addr_t paddr = 0;
dma_addr_t paddr = 0;
size_t len = 0;
struct audio_aio_ion_region *region;
int rc = -EINVAL;
struct ion_handle *handle = NULL;
struct dma_buf *dma_buf = NULL;
unsigned long ionflag;
void *kvaddr = NULL;
@@ -976,8 +975,7 @@ static int audio_aio_ion_add(struct q6audio_aio *audio,
goto end;
}
rc = msm_audio_ion_import_legacy("Audio_Dec_Client", audio->client,
&handle, info->fd, &ionflag,
rc = msm_audio_ion_import(&dma_buf, info->fd, &ionflag,
0, &paddr, &len, &kvaddr);
if (rc) {
pr_err("%s: msm audio ion alloc failed\n", __func__);
@@ -990,7 +988,7 @@ static int audio_aio_ion_add(struct q6audio_aio *audio,
goto ion_error;
}
region->handle = handle;
region->dma_buf = dma_buf;
region->vaddr = info->vaddr;
region->fd = info->fd;
region->paddr = paddr;
@@ -1012,7 +1010,7 @@ static int audio_aio_ion_add(struct q6audio_aio *audio,
mmap_error:
list_del(&region->list);
ion_error:
msm_audio_ion_free_legacy(audio->client, handle);
msm_audio_ion_free(dma_buf);
import_error:
kfree(region);
end:
@@ -1049,8 +1047,7 @@ static int audio_aio_ion_remove(struct q6audio_aio *audio,
__func__, audio);
list_del(&region->list);
msm_audio_ion_free_legacy(audio->client,
region->handle);
msm_audio_ion_free(region->dma_buf);
kfree(region);
rc = 0;
break;
@@ -1378,22 +1375,12 @@ int audio_aio_open(struct q6audio_aio *audio, struct file *file)
goto cleanup;
}
}
audio->client = msm_audio_ion_client_create("Audio_Dec_Client");
if (IS_ERR_OR_NULL(audio->client)) {
pr_err("Unable to create ION client\n");
rc = -ENOMEM;
goto cleanup;
}
pr_debug("Ion client create in audio_aio_open %pK", audio->client);
rc = register_volume_listener(audio);
if (rc < 0)
goto ion_cleanup;
goto cleanup;
return 0;
ion_cleanup:
msm_audio_ion_client_destroy(audio->client);
audio->client = NULL;
cleanup:
list_for_each_safe(ptr, next, &audio->free_event_queue) {
e_node = list_first_entry(&audio->free_event_queue,