[MSM] revert qdsp backport, seems to break quite a lot of stuff, will fix it later.

This commit is contained in:
Shantanu Gupta 2012-05-03 21:30:12 +05:30
parent 48322595f9
commit e8bd623aa0
12 changed files with 233 additions and 497 deletions

View File

@ -24,7 +24,6 @@
#include <asm/gpio.h>
#include <mach/gpio.h>
#include <mach/htc_headset_mgr.h>
#include <mach/board-htcleo-audio.h>
#include "board-htcleo.h"
#include "devices.h"

View File

@ -19,14 +19,12 @@
#define AUDIO_FLAG_READ 0
#define AUDIO_FLAG_WRITE 1
#define AUDIO_FLAG_INCALL_MIXED 2
struct audio_buffer {
dma_addr_t phys;
void *data;
uint32_t size;
uint32_t used; /* 1 = CPU is waiting for DSP to consume this buf */
uint32_t actual_size; /* actual number of bytes read by DSP */
};
struct audio_client {
@ -81,10 +79,8 @@ struct audio_client *q6audio_open_mp3(uint32_t bufsz, uint32_t rate,
struct audio_client *q6fm_open(void);
struct audio_client *q6audio_open_aac(uint32_t bufsz, uint32_t samplerate,
uint32_t channels, uint32_t bitrate,
uint32_t stream_format, uint32_t flags,
uint32_t acdb_id);
struct audio_client *q6audio_open_aac(uint32_t bufsz, uint32_t rate,
uint32_t flags, void *data, uint32_t acdb_id);
struct audio_client *q6audio_open_qcelp(uint32_t bufsz, uint32_t rate,
void *data, uint32_t acdb_id);
@ -106,7 +102,7 @@ int q6audio_set_tx_mute(int mute);
int q6audio_reinit_acdb(char* filename);
int q6audio_update_acdb(uint32_t id_src, uint32_t id_dst);
int q6audio_set_rx_volume(int level);
int q6audio_set_tx_volume(int mute);
int q6audio_set_tx_volume(int level);
int q6audio_set_stream_volume(struct audio_client *ac, int vol);
int q6audio_set_tx_dev_volume(int device_id, int level);
int q6audio_get_tx_dev_volume(int device_id);

View File

@ -1,7 +1,7 @@
/*
/* arch/arm/mach-msm/qdsp6/aac_in.c
*
* Copyright (C) 2009 Google, Inc.
* Copyright (C) 2009 HTC Corporation
* Copyright (c) 2010, Code Aurora Forum. 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
@ -12,9 +12,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
*/
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/module.h>
#include <linux/miscdevice.h>
@ -22,449 +21,197 @@
#include <linux/sched.h>
#include <linux/wait.h>
#include <linux/uaccess.h>
#include <linux/kthread.h>
#include <linux/time.h>
#include <linux/wait.h>
#include <linux/msm_audio_1550.h>
#include <linux/msm_audio_aac.h>
#include <linux/msm_audio.h>
#include <mach/msm_qdsp6_audio_1550.h>
#include <mach/debug_mm.h>
#define AAC_FC_BUFF_CNT 10
#define AAC_READ_TIMEOUT 2000
struct aac_fc_buff {
struct mutex lock;
int empty;
void *data;
int size;
int actual_size;
};
#define BUFSZ (4096)
#define DMASZ (BUFSZ * 2)
struct aac_fc {
struct task_struct *task;
wait_queue_head_t fc_wq;
struct aac_fc_buff fc_buff[AAC_FC_BUFF_CNT];
int buff_index;
};
struct aac {
struct mutex lock;
struct msm_audio_aac_enc_config cfg;
struct msm_audio_stream_config str_cfg;
struct audio_client *audio_client;
struct msm_voicerec_mode voicerec_mode;
struct aac_fc *aac_fc;
};
#if 0
#define TRACE(x...) pr_info("Q6: "x)
#else
#define TRACE(x...) do{}while(0)
#endif
static int q6_aac_flowcontrol(void *data)
static DEFINE_MUTEX(aac_in_lock);
static int aac_in_opened = 0;
static struct aac_format *af;
void audio_client_dump(struct audio_client *ac);
static long aac_in_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct audio_client *ac;
struct audio_buffer *ab;
struct aac *aac = data;
int buff_index = 0;
int xfer = 0;
struct aac_fc *fc;
ac = aac->audio_client;
fc = aac->aac_fc;
if (!ac) {
pr_err("[%s:%s] audio_client is NULL\n", __MM_FILE__, __func__);
return 0;
}
while (!kthread_should_stop()) {
ab = ac->buf + ac->cpu_buf;
if (ab->used)
wait_event(ac->wait, (ab->used == 0));
pr_debug("[%s:%s] ab->data = %p, cpu_buf = %d\n", __MM_FILE__,
__func__, ab->data, ac->cpu_buf);
xfer = ab->actual_size;
mutex_lock(&(fc->fc_buff[buff_index].lock));
if (!fc->fc_buff[buff_index].empty) {
pr_err("[%s:%s] flow control buffer[%d] not read!\n",
__MM_FILE__, __func__, buff_index);
}
if (fc->fc_buff[buff_index].size < xfer) {
pr_err("[%s:%s] buffer %d too small\n", __MM_FILE__,
__func__, buff_index);
memcpy(fc->fc_buff[buff_index].data,
ab->data, fc->fc_buff[buff_index].size);
fc->fc_buff[buff_index].empty = 0;
fc->fc_buff[buff_index].actual_size =
fc->fc_buff[buff_index].size;
} else {
memcpy(fc->fc_buff[buff_index].data, ab->data, xfer);
fc->fc_buff[buff_index].empty = 0;
fc->fc_buff[buff_index].actual_size = xfer;
}
mutex_unlock(&(fc->fc_buff[buff_index].lock));
/*wake up client, if any*/
wake_up(&fc->fc_wq);
buff_index++;
if (buff_index >= AAC_FC_BUFF_CNT)
buff_index = 0;
ab->used = 1;
q6audio_read(ac, ab);
ac->cpu_buf ^= 1;
}
return 0;
}
static long q6_aac_in_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
struct aac *aac = file->private_data;
int rc = 0;
int i = 0;
struct aac_fc *fc;
int size = 0;
mutex_lock(&aac->lock);
switch (cmd) {
case AUDIO_SET_VOLUME:
break;
case AUDIO_GET_STATS:
{
case AUDIO_GET_STATS: {
struct msm_audio_stats stats;
pr_debug("[%s:%s] GET_STATS\n", __MM_FILE__, __func__);
memset(&stats, 0, sizeof(stats));
if (copy_to_user((void *) arg, &stats, sizeof(stats)))
if (copy_to_user((void*) arg, &stats, sizeof(stats)))
return -EFAULT;
return 0;
}
case AUDIO_START:
{
case AUDIO_START: {
uint32_t acdb_id;
pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
rc = 0;
if (arg == 0) {
acdb_id = 0;
} else {
if (copy_from_user(&acdb_id, (void *) arg,
sizeof(acdb_id))) {
rc = -EFAULT;
break;
}
}
if (aac->audio_client) {
rc = -EBUSY;
pr_err("[%s:%s] active session already existing\n",
__MM_FILE__, __func__);
} else if (copy_from_user(&acdb_id,
(void*) arg, sizeof(acdb_id))) {
rc = -EFAULT;
break;
}
mutex_lock(&aac_in_lock);
if (file->private_data) {
rc = -EBUSY;
} else {
aac->audio_client = q6audio_open_aac(
aac->str_cfg.buffer_size,
aac->cfg.sample_rate,
aac->cfg.channels,
aac->cfg.bit_rate,
aac->cfg.stream_format,
aac->voicerec_mode.rec_mode, acdb_id);
if (aac->audio_client < 0) {
pr_err("[%s:%s] aac open session failed\n",
__MM_FILE__, __func__);
file->private_data = q6audio_open_aac(
BUFSZ, 48000, AUDIO_FLAG_READ, af, acdb_id);
if (!file->private_data)
rc = -ENOMEM;
break;
}
}
/*allocate flow control buffers*/
fc = aac->aac_fc;
size = ((aac->str_cfg.buffer_size < 1543) ? 1543 :
aac->str_cfg.buffer_size);
for (i = 0; i < AAC_FC_BUFF_CNT; ++i) {
mutex_init(&(fc->fc_buff[i].lock));
fc->fc_buff[i].empty = 1;
fc->fc_buff[i].data = kmalloc(size, GFP_KERNEL);
if (fc->fc_buff[i].data == NULL) {
pr_err("[%s:%s] No memory for FC buffers\n",
__MM_FILE__, __func__);
rc = -ENOMEM;
goto fc_fail;
}
fc->fc_buff[i].size = size;
fc->fc_buff[i].actual_size = 0;
}
/*create flow control thread*/
fc->task = kthread_run(q6_aac_flowcontrol,
aac, "aac_flowcontrol");
if (IS_ERR(fc->task)) {
rc = PTR_ERR(fc->task);
pr_err("[%s:%s] error creating flow control thread\n",
__MM_FILE__, __func__);
goto fc_fail;
}
break;
fc_fail:
/*free flow control buffers*/
--i;
for (; i >= 0; i--) {
kfree(fc->fc_buff[i].data);
fc->fc_buff[i].data = NULL;
}
mutex_unlock(&aac_in_lock);
break;
}
case AUDIO_STOP:
pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
break;
case AUDIO_FLUSH:
break;
case AUDIO_SET_INCALL: {
pr_debug("[%s:%s] SET_INCALL\n", __MM_FILE__, __func__);
if (copy_from_user(&aac->voicerec_mode,
(void *)arg, sizeof(struct msm_voicerec_mode)))
case AUDIO_SET_CONFIG: {
struct msm_audio_config config;
if (copy_from_user(&config, (void*) arg, sizeof(config))) {
rc = -EFAULT;
break;
}
if (config.sample_rate != 48000)
pr_info("only 48KHz AAC encode supported\n");
af->channel_config = config.channel_count;
break;
}
case AUDIO_GET_CONFIG: {
struct msm_audio_config config;
config.buffer_size = BUFSZ;
config.buffer_count = 2;
config.sample_rate = 48000;
config.channel_count = af->channel_config;
config.unused[0] = 0;
config.unused[1] = 0;
config.unused[2] = 0;
if (copy_to_user((void*) arg, &config, sizeof(config))) {
rc = -EFAULT;
if (aac->voicerec_mode.rec_mode != AUDIO_FLAG_READ
&& aac->voicerec_mode.rec_mode !=
AUDIO_FLAG_INCALL_MIXED) {
aac->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
pr_err("[%s:%s] Invalid rec_mode\n", __MM_FILE__,
__func__);
rc = -EINVAL;
}
break;
}
case AUDIO_GET_STREAM_CONFIG:
if (copy_to_user((void *)arg, &aac->str_cfg,
sizeof(struct msm_audio_stream_config)))
rc = -EFAULT;
pr_debug("[%s:%s] GET_STREAM_CONFIG: buffsz=%d, buffcnt=%d\n",
__MM_FILE__, __func__, aac->str_cfg.buffer_size,
aac->str_cfg.buffer_count);
break;
case AUDIO_SET_STREAM_CONFIG:
if (copy_from_user(&aac->str_cfg, (void *)arg,
sizeof(struct msm_audio_stream_config))) {
rc = -EFAULT;
break;
}
pr_debug("[%s:%s] SET_STREAM_CONFIG: buffsz=%d, buffcnt=%d\n",
__MM_FILE__, __func__, aac->str_cfg.buffer_size,
aac->str_cfg.buffer_count);
if (aac->str_cfg.buffer_size < 1543) {
pr_err("[%s:%s] Buffer size too small\n", __MM_FILE__,
__func__);
rc = -EINVAL;
break;
}
if (aac->str_cfg.buffer_count != 2)
pr_info("[%s:%s] Buffer count set to 2\n", __MM_FILE__,
__func__);
break;
case AUDIO_SET_AAC_ENC_CONFIG:
if (copy_from_user(&aac->cfg, (void *) arg,
sizeof(struct msm_audio_aac_enc_config))) {
rc = -EFAULT;
}
pr_debug("[%s:%s] SET_AAC_ENC_CONFIG: channels=%d, rate=%d\n",
__MM_FILE__, __func__, aac->cfg.channels,
aac->cfg.sample_rate);
if (aac->cfg.channels < 1 || aac->cfg.channels > 2) {
pr_err("[%s:%s]invalid number of channels\n",
__MM_FILE__, __func__);
rc = -EINVAL;
}
if (aac->cfg.sample_rate != 48000) {
pr_err("[%s:%s] only 48KHz is supported\n",
__MM_FILE__, __func__);
rc = -EINVAL;
}
if (aac->cfg.stream_format != AUDIO_AAC_FORMAT_RAW &&
aac->cfg.stream_format != AUDIO_AAC_FORMAT_ADTS) {
pr_err("[%s:%s] unsupported AAC format\n", __MM_FILE__,
__func__);
rc = -EINVAL;
}
break;
case AUDIO_GET_AAC_ENC_CONFIG:
if (copy_to_user((void *) arg, &aac->cfg,
sizeof(struct msm_audio_aac_enc_config))) {
rc = -EFAULT;
}
pr_debug("[%s:%s] GET_AAC_ENC_CONFIG: channels=%d, rate=%d\n",
__MM_FILE__, __func__, aac->cfg.channels,
aac->cfg.sample_rate);
break;
default:
rc = -EINVAL;
}
mutex_unlock(&aac->lock);
pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc);
return rc;
}
static int q6_aac_in_open(struct inode *inode, struct file *file)
static int aac_in_open(struct inode *inode, struct file *file)
{
int rc;
struct aac *aac;
struct aac_fc *fc;
int i;
pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
aac = kmalloc(sizeof(struct aac), GFP_KERNEL);
if (aac == NULL) {
pr_err("[%s:%s] Could not allocate memory for aac driver\n",
__MM_FILE__, __func__);
return -ENOMEM;
}
pr_info("aac_in: open\n");
mutex_lock(&aac_in_lock);
if (aac_in_opened) {
pr_err("aac_in: busy\n");
rc = -EBUSY;
} else {
af = kzalloc(sizeof(*af), GFP_KERNEL);
memset(af, 0, sizeof(struct aac_format));
af->sample_rate = 3; /* 48000 */
af->channel_config = 1;
af->block_formats = AUDIO_AAC_FORMAT_ADTS;
af->audio_object_type = 2; /* CAD to ADSP format */
af->bit_rate = 192000;
mutex_init(&aac->lock);
file->private_data = aac;
aac->audio_client = NULL;
aac->str_cfg.buffer_size = 1543;
aac->str_cfg.buffer_count = 2;
aac->cfg.channels = 1;
aac->cfg.bit_rate = 192000;
aac->cfg.stream_format = AUDIO_AAC_FORMAT_ADTS;
aac->cfg.sample_rate = 48000;
aac->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
aac->aac_fc = kmalloc(sizeof(struct aac_fc), GFP_KERNEL);
if (aac->aac_fc == NULL) {
pr_err("[%s:%s] Could not allocate memory for aac_fc\n",
__MM_FILE__, __func__);
kfree(aac);
return -ENOMEM;
aac_in_opened = 1;
rc = 0;
}
fc = aac->aac_fc;
fc->task = NULL;
fc->buff_index = 0;
for (i = 0; i < AAC_FC_BUFF_CNT; ++i) {
fc->fc_buff[i].data = NULL;
fc->fc_buff[i].size = 0;
fc->fc_buff[i].actual_size = 0;
}
/*initialize wait queue head*/
init_waitqueue_head(&fc->fc_wq);
return 0;
mutex_unlock(&aac_in_lock);
return rc;
}
static ssize_t q6_aac_in_read(struct file *file, char __user *buf,
size_t count, loff_t *pos)
static ssize_t aac_in_read(struct file *file, char __user *buf,
size_t count, loff_t *pos)
{
struct audio_client *ac;
struct audio_buffer *ab;
const char __user *start = buf;
struct aac *aac = file->private_data;
struct aac_fc *fc;
int xfer = 0;
int res = 0;
pr_debug("[%s:%s] count = %d\n", __MM_FILE__, __func__, count);
mutex_lock(&aac->lock);
ac = aac->audio_client;
int xfer, res = 0;
mutex_lock(&aac_in_lock);
ac = file->private_data;
if (!ac) {
res = -ENODEV;
goto fail;
}
fc = aac->aac_fc;
while (count > 0) {
ab = ac->buf + ac->cpu_buf;
/*wait for buffer to full*/
if (fc->fc_buff[fc->buff_index].empty != 0) {
res = wait_event_interruptible_timeout(fc->fc_wq,
(fc->fc_buff[fc->buff_index].empty == 0),
msecs_to_jiffies(AAC_READ_TIMEOUT));
if (ab->used)
if (!wait_event_timeout(ac->wait, (ab->used == 0), 5*HZ)) {
audio_client_dump(ac);
pr_err("aac_read: timeout. dsp dead?\n");
BUG();
}
pr_debug("[%s:%s] buff_index = %d\n", __MM_FILE__,
__func__, fc->buff_index);
if (res == 0) {
pr_err("[%s:%s] Timeout!\n", __MM_FILE__, __func__);
res = -ETIMEDOUT;
goto fail;
} else if (res < 0) {
pr_err("[%s:%s] Returning on Interrupt\n", __MM_FILE__,
__func__);
xfer = count;
if (xfer > ab->size)
xfer = ab->size;
if (copy_to_user(buf, ab->data, xfer)) {
res = -EFAULT;
goto fail;
}
buf += xfer;
count -= xfer;
ab->used = 1;
q6audio_read(ac, ab);
ac->cpu_buf ^= 1;
}
/*lock the buffer*/
mutex_lock(&(fc->fc_buff[fc->buff_index].lock));
xfer = fc->fc_buff[fc->buff_index].actual_size;
if (xfer > count) {
mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
pr_err("[%s:%s] read failed! byte count too small\n",
__MM_FILE__, __func__);
res = -EINVAL;
goto fail;
}
if (copy_to_user(buf, fc->fc_buff[fc->buff_index].data, xfer)) {
mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
pr_err("[%s:%s] copy_to_user failed at index %d\n",
__MM_FILE__, __func__, fc->buff_index);
res = -EFAULT;
goto fail;
}
buf += xfer;
fc->fc_buff[fc->buff_index].empty = 1;
fc->fc_buff[fc->buff_index].actual_size = 0;
mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
++(fc->buff_index);
if (fc->buff_index >= AAC_FC_BUFF_CNT)
fc->buff_index = 0;
res = buf - start;
fail:
mutex_unlock(&aac->lock);
res = buf - start;
mutex_unlock(&aac_in_lock);
return res;
}
static int q6_aac_in_release(struct inode *inode, struct file *file)
static int aac_in_release(struct inode *inode, struct file *file)
{
int rc = 0;
struct aac *aac = file->private_data;
int i = 0;
struct aac_fc *fc;
mutex_lock(&aac->lock);
fc = aac->aac_fc;
kthread_stop(fc->task);
fc->task = NULL;
/*free flow control buffers*/
for (i = 0; i < AAC_FC_BUFF_CNT; ++i) {
kfree(fc->fc_buff[i].data);
fc->fc_buff[i].data = NULL;
}
kfree(fc);
if (aac->audio_client)
rc = q6audio_close(aac->audio_client);
mutex_unlock(&aac->lock);
kfree(aac);
pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
pr_info("aac_in: release\n");
mutex_lock(&aac_in_lock);
if (file->private_data)
rc = q6audio_close(file->private_data);
kfree(af);
aac_in_opened = 0;
mutex_unlock(&aac_in_lock);
return rc;
}
static const struct file_operations q6_aac_in_fops = {
.owner = THIS_MODULE,
.open = q6_aac_in_open,
.read = q6_aac_in_read,
.release = q6_aac_in_release,
.unlocked_ioctl = q6_aac_in_ioctl,
static struct file_operations aac_in_fops = {
.owner = THIS_MODULE,
.open = aac_in_open,
.read = aac_in_read,
.release = aac_in_release,
.unlocked_ioctl = aac_in_ioctl,
};
struct miscdevice q6_aac_in_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = "msm_aac_in",
.fops = &q6_aac_in_fops,
struct miscdevice aac_in_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = "msm_aac_in",
.fops = &aac_in_fops,
};
static int __init q6_aac_in_init(void)
{
return misc_register(&q6_aac_in_misc);
static int __init aac_in_init(void) {
return misc_register(&aac_in_misc);
}
device_initcall(q6_aac_in_init);
device_initcall(aac_in_init);

View File

@ -18,7 +18,7 @@
#include <linux/module.h>
#include <linux/miscdevice.h>
#include <linux/uaccess.h>
#include <linux/msm_audio_1550.h>
#include <linux/msm_audio.h>
#include <mach/msm_qdsp6_audio_1550.h>
#include <mach/htc_acoustic_qsd.h>
@ -133,7 +133,8 @@ static int q6_open(struct inode *inode, struct file *file)
return 0;
}
static long q6_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
static int q6_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
int rc;
uint32_t n;
@ -146,40 +147,28 @@ static long q6_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case AUDIO_SWITCH_DEVICE:
rc = copy_from_user(&id, (void *)arg, sizeof(id));
AUDIO_INFO("SWITCH DEVICE %d, acdb %d\n", id[0], id[1]);
if (rc) {
pr_err("%s: bad user address\n", __func__);
rc = -EFAULT;
} else
if (!rc)
rc = q6audio_do_routing(id[0], id[1]);
break;
case AUDIO_SET_VOLUME:
rc = copy_from_user(&n, (void *)arg, sizeof(n));
if (rc) {
pr_err("%s: bad user address\n", __func__);
rc = -EFAULT;
} else
if (!rc)
rc = q6audio_set_rx_volume(n);
break;
case AUDIO_SET_MUTE:
rc = copy_from_user(&n, (void *)arg, sizeof(n));
if (rc) {
pr_err("%s: bad user address\n", __func__);
rc = -EFAULT;
} else
if (!rc)
rc = q6audio_set_tx_mute(n);
break;
case AUDIO_UPDATE_ACDB:
rc = copy_from_user(&id, (void *)arg, sizeof(id));
if (rc) {
pr_err("%s: bad user address\n", __func__);
rc = -EFAULT;
} else
if (!rc)
rc = q6audio_update_acdb(id[0], id[1]);
break;
case AUDIO_START_VOICE:
if (arg == 0)
if (arg == 0) {
id[0] = id[1] = 0;
else if (copy_from_user(&id, (void*) arg, sizeof(id))) {
} else if (copy_from_user(&id, (void*) arg, sizeof(id))) {
pr_info("voice: copy acdb_id from user failed\n");
rc = -EFAULT;
break;

View File

@ -19,7 +19,6 @@
#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/errno.h>

View File

@ -19,7 +19,6 @@
#include <linux/miscdevice.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/uaccess.h>

View File

@ -41,7 +41,6 @@
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
#include <linux/wakelock.h>

View File

@ -42,7 +42,6 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
#include <linux/android_pmem.h>
@ -359,7 +358,7 @@ static int q6_encode(struct q6venc_dev *q6venc, struct encode_param *enc_param)
{
struct q6_encode_param *q6_param = &enc_param->q6_encode_param;
struct file *file;
struct buf_info *buf = 0;
struct buf_info *buf;
int i;
int ret;
int rlc_buf_index;

View File

@ -14,7 +14,6 @@
*
*/
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/module.h>
#include <linux/miscdevice.h>

View File

@ -19,7 +19,6 @@
#include <linux/miscdevice.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/uaccess.h>
@ -65,12 +64,6 @@ static long pcm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
switch (cmd) {
case AUDIO_SET_VOLUME: {
int vol;
if (!pcm->ac) {
pr_err("%s: cannot set volume before AUDIO_START!\n",
__func__);
rc = -EINVAL;
break;
}
if (copy_from_user(&vol, (void*) arg, sizeof(vol))) {
rc = -EFAULT;
break;

View File

@ -17,7 +17,6 @@
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/dma-mapping.h>
#include <linux/clk.h>
@ -33,12 +32,11 @@
#include "dal_acdb.h"
#include "dal_adie.h"
#include <mach/msm_qdsp6_audio_1550.h>
#include <linux/msm_audio_1550.h>
#include <linux/msm_audio.h>
#include <mach/htc_acoustic_qsd.h>
#include <mach/msm_audio_qcp.h>
#include <linux/gpio.h>
#include <linux/msm_audio_aac.h>
#include "q6audio_devices.h"
#include "../dex_comm.h"
@ -174,7 +172,7 @@ static struct audio_client * audio_test(void);
static void callback(void *data, int len, void *cookie);
static int audio_init(struct audio_client *ac);
static int audio_info(struct audio_client *ac);
static int q6audio_init_rx_volumes(void);
static int q6audio_init_rx_volumes();
static struct wake_lock wakelock;
static struct wake_lock idlelock;
@ -217,7 +215,6 @@ static char acdb_file[64] = "default.acdb";
static uint32_t tx_acdb = 0;
static uint32_t rx_acdb = 0;
static int acdb_use_rpc = 0;
static int acdb_use_map = 0;
/////////////////////////////////////////////////////////////////////////////////
// helper functions for device parameters
@ -702,18 +699,10 @@ static int audio_mp3_open(struct audio_client *ac, uint32_t bufsz,
return ac->open_status;
}
/*
* ported code for audio_aac_open from Code Aurora in order to work
* with new aac code from Code Aurora
* by marc1706
*/
static int audio_aac_open(struct audio_client *ac, uint32_t bufsz,
uint32_t sample_rate, uint32_t channels,
uint32_t bit_rate, uint32_t flags,
uint32_t stream_format)
static int audio_aac_open(struct audio_client *ac, uint32_t bufsz, void *data)
{
int r;
int audio_object_type;
struct aac_format *af = data;
struct adsp_open_command rpc;
uint32_t *aac_type;
int idx = 0; // sizeof(uint32_t);
@ -734,33 +723,77 @@ static int audio_aac_open(struct audio_client *ac, uint32_t bufsz,
rpc.pblock = params_phys;
aac_type = (uint32_t *)(fmt->data);
switch (stream_format)
switch (af->block_formats)
{
case AUDIO_AAC_FORMAT_ADTS:
/* AAC Encoder expect MPEG4_ADTS media type */
*aac_type = ADSP_AUDIO_AAC_MPEG4_ADTS;
break;
case AUDIO_AAC_FORMAT_RAW:
/* for ADIF recording */
*aac_type = ADSP_AUDIO_AAC_RAW;
break;
case 0xffff:
if (ac->flags & AUDIO_FLAG_WRITE)
*aac_type = ADSP_AUDIO_AAC_ADTS;
else
*aac_type = ADSP_AUDIO_AAC_MPEG4_ADTS;
break;
case 0:
if (ac->flags & AUDIO_FLAG_WRITE)
*aac_type = ADSP_AUDIO_AAC_ADIF;
else
*aac_type = ADSP_AUDIO_AAC_RAW;
break;
case 1:
*aac_type = ADSP_AUDIO_AAC_RAW;
break;
case 2:
*aac_type = ADSP_AUDIO_AAC_LOAS;
break;
case 3:
*aac_type = ADSP_AUDIO_AAC_FRAMED_RAW;
break;
case 4:
*aac_type = ADSP_AUDIO_AAC_RAW;
break;
default:
pr_err("unsupported AAC type %d\n", stream_format);
pr_err("unsupported AAC type %d\n", af->block_formats);
mutex_unlock(&open_mem_lock);
return -EINVAL;
}
/* AAC OBJECT LC */
audio_object_type = 2;
AUDIO_INFO("aac_open: type %x, obj %d, idx %d\n",
*aac_type, audio_object_type, idx);
*aac_type, af->audio_object_type, idx);
fmt->data[idx++] = (u8)(((af->audio_object_type & 0x1F) << 3) |
((af->sample_rate >> 1) & 0x7));
fmt->data[idx] = (u8)(((af->sample_rate & 0x1) << 7) |
((af->channel_config & 0x7) << 3));
fmt->data[idx++] = (u8)(((audio_object_type & 0x1F) << 3) |
((sample_rate >> 1) & 0x7));
fmt->data[idx] = (u8)(((sample_rate & 0x1) << 7) |
((channels & 0x7) << 3));
switch (af->audio_object_type) {
case AAC_OBJECT_ER_LC:
case AAC_OBJECT_ER_LTP:
case AAC_OBJECT_ER_LD:
/* extension flag */
fmt->data[idx++] |= 0x1;
fmt->data[idx] = (u8)(
((af->aac_section_data_resilience_flag & 0x1) << 7) |
((af->aac_scalefactor_data_resilience_flag & 0x1) << 6) |
((af->aac_spectral_data_resilience_flag & 0x1) << 5) |
((af->ep_config & 0x3) << 2));
break;
case AAC_OBJECT_ER_SCALABLE:
fmt->data[idx++] |= 0x1;
/* extension flag */
fmt->data[idx++] = (u8)(
((af->aac_section_data_resilience_flag & 0x1) << 4) |
((af->aac_scalefactor_data_resilience_flag & 0x1) << 3) |
((af->aac_spectral_data_resilience_flag & 0x1) << 2) |
((af->ep_config >> 1) & 0x1));
fmt->data[idx] = (u8)((af->ep_config & 0x1) << 7);
break;
case AAC_OBJECT_BSAC:
fmt->data[++idx] = (u8)((af->ep_config & 0x3) << 6);
break;
default:
pr_err("dbg unknown object type \n");
break;
}
// fmt->num_bytes = idx + 1;
rpc.blocklen = idx + 1;
@ -768,8 +801,8 @@ static int audio_aac_open(struct audio_client *ac, uint32_t bufsz,
fmt->data[0], fmt->data[1], fmt->data[2], fmt->data[3],
fmt->data[4], fmt->data[5], fmt->data[6], fmt->data[7]);
rpc.config.aac.bit_rate = bit_rate;
if (flags & AUDIO_FLAG_WRITE)
rpc.config.aac.bit_rate = af->bit_rate;
if (ac->flags & AUDIO_FLAG_WRITE)
{
rpc.opcode = ADSP_AUDIO_OPCODE_OPEN_WRITE;
rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_PLAYBACK;
@ -780,13 +813,25 @@ static int audio_aac_open(struct audio_client *ac, uint32_t bufsz,
rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
}
/*
* Always use ADSP_AUDIO_ENC_AAC_LC_ONLY_MODE as encoder_mode
* from Code Aurora
* by marc1706
*/
rpc.config.aac.encoder_mode = ADSP_AUDIO_ENC_AAC_LC_ONLY_MODE;
rpc.buf_max_size = bufsz;
if ((af->sbr_on_flag == 0) && (af->sbr_ps_on_flag == 0))
{
rpc.config.aac.encoder_mode = ADSP_AUDIO_ENC_AAC_LC_ONLY_MODE;
}
else if ((af->sbr_on_flag == 1) && (af->sbr_ps_on_flag == 0))
{
rpc.config.aac.encoder_mode = ADSP_AUDIO_ENC_AAC_PLUS_MODE;
}
else if ((af->sbr_on_flag == 1) && (af->sbr_ps_on_flag == 1))
{
rpc.config.aac.encoder_mode = ADSP_AUDIO_ENC_ENHANCED_AAC_PLUS_MODE;
}
else
{
pr_err("unsupported SBR flag\n");
mutex_unlock(&open_mem_lock);
return -EINVAL;
}
rpc.buf_max_size = bufsz; /* XXX ??? */
TRACE("aac_open: opcode %x, stream_context 0x%x, "
"mode %d, bytes %d, bbuffer size %d\n",
@ -1188,29 +1233,11 @@ static int acdb_init(char *filename)
const struct firmware *fw;
int n;
// return -ENODEV;
AUDIO_INFO("%s\n", __func__);
#ifdef CONFIG_MACH_HTCLEO
pr_info("acdb: trying htcleo.acdb\n");
if(request_firmware(&fw, "htcleo.acdb", q6_control_device.this_device) < 0) {
pr_info("acdb: load 'htcleo.acdb' failed, trying 'default.acdb'\n");
acdb_use_map = 0;
if (request_firmware(&fw, filename, q6_control_device.this_device) < 0) {
pr_err("acdb: load 'default.acdb' failed...\n");
return -ENODEV;
}
} else {
pr_info("acdb: 'htcleo.acdb' found, using translation\n");
acdb_use_map = 1;
}
#else
pr_info("acdb: load '%s'\n", filename);
acd_use_map = 0;
if (request_firmware(&fw, filename, q6_control_device.this_device) < 0) {
pr_err("acdb: load 'default.acdb' failed...\n");
return -ENODEV;
}
#endif
db = (void*) fw->data;
if (fw->size < sizeof(struct audio_config_database)) {
@ -1421,9 +1448,6 @@ static int acdb_get_config_table(uint32_t device_id, uint32_t sample_rate)
int n;
printk("table\n");
// htcleo use custom table with wince values, it must be mapped
if(acdb_use_map)
device_id = map_cad_dev_to_virtual(device_id);
db = acdb_data;
for (n = 0; n < db->entry_count; n++)
{
@ -2185,7 +2209,7 @@ int q6audio_set_rx_volume(int level)
}
EXPORT_SYMBOL_GPL(q6audio_set_rx_volume);
static int q6audio_init_rx_volumes(void)
static int q6audio_init_rx_volumes()
{
int vol;
struct q6_device_info *di = q6_audio_devices;
@ -2604,19 +2628,14 @@ int q6audio_async(struct audio_client *ac)
}
/*
* ported code for q6audio_open_aac from Code Aurora
* by marc1706
*/
struct audio_client *q6audio_open_aac(uint32_t bufsz, uint32_t samplerate,
uint32_t channels, uint32_t bitrate,
uint32_t stream_format, uint32_t flags,
uint32_t acdb_id)
struct audio_client *q6audio_open_aac(uint32_t bufsz, uint32_t rate,
uint32_t flags, void *data, uint32_t acdb_id)
{
struct audio_client *ac;
AUDIO_INFO("%s\n", __func__);
TRACE("q6audio_open_aac flags=%d samplerate=%d, channels = %d\n", flags, samplerate, channels);
TRACE("q6audio_open_aac flags=%d rate=%d\n", flags, rate);
if (q6audio_init())
return 0;
@ -2629,13 +2648,12 @@ struct audio_client *q6audio_open_aac(uint32_t bufsz, uint32_t samplerate,
if (ac->flags & AUDIO_FLAG_WRITE)
audio_rx_path_enable(1, acdb_id);
else {
if (!audio_tx_path_refcount)
tx_clk_freq = 48000;
/* TODO: consider concourrency with voice call */
tx_clk_freq = rate;
audio_tx_path_enable(1, acdb_id);
}
audio_aac_open(ac, bufsz, samplerate, channels, bitrate, flags,
stream_format);
audio_aac_open(ac, bufsz, data);
audio_command(ac, ADSP_AUDIO_IOCTL_CMD_SESSION_START);
if (!(ac->flags & AUDIO_FLAG_WRITE)) {

View File

@ -19,7 +19,6 @@
#include <linux/miscdevice.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/uaccess.h>
#include <linux/msm_audio.h>