diff --git a/arch/arm/mach-msm/qdsp6_1550/audio_ctl.c b/arch/arm/mach-msm/qdsp6_1550/audio_ctl.c index 8606f183..8a07cbad 100644 --- a/arch/arm/mach-msm/qdsp6_1550/audio_ctl.c +++ b/arch/arm/mach-msm/qdsp6_1550/audio_ctl.c @@ -25,7 +25,7 @@ #define BUFSZ (0) -#if 1 +#if 0 #define AUDIO_INFO(x...) pr_info("Audio: "x) #else #define AUDIO_INFO(x...) do{}while(0) @@ -48,7 +48,7 @@ static int q6_voice_start(uint32_t rx_acdb_id, uint32_t tx_acdb_id) { int rc = 0; - printk("VOICE START (%d %d)\n", rx_acdb_id, tx_acdb_id); + AUDIO_INFO("VOICE START (%d %d)\n", rx_acdb_id, tx_acdb_id); mutex_lock(&voice_lock); if (voice_started) { @@ -82,12 +82,12 @@ static int q6_voice_stop(void) { mutex_lock(&voice_lock); global_now_phone_call = 0; - if (voice_started) + if (voice_started) { q6voice_close(voc_tx_clnt); q6voice_close(voc_rx_clnt); - voice_started = 0; - } + voice_started = 0; + } mutex_unlock(&voice_lock); return 0; } diff --git a/arch/arm/mach-msm/qdsp6_1550/dal.c b/arch/arm/mach-msm/qdsp6_1550/dal.c index d05ccfb0..0755c70a 100644 --- a/arch/arm/mach-msm/qdsp6_1550/dal.c +++ b/arch/arm/mach-msm/qdsp6_1550/dal.c @@ -31,258 +31,258 @@ #define DAL_TRACE 0 struct dal_hdr { - uint32_t length:16; /* message length (header inclusive) */ - uint32_t version:8; /* DAL protocol version */ - uint32_t priority:7; - uint32_t async:1; - uint32_t ddi:16; /* DDI method number */ - uint32_t prototype:8; /* DDI serialization format */ - uint32_t msgid:8; /* message id (DDI, ATTACH, DETACH, ...) */ - void *from; - void *to; + uint32_t length:16; /* message length (header inclusive) */ + uint32_t version:8; /* DAL protocol version */ + uint32_t priority:7; + uint32_t async:1; + uint32_t ddi:16; /* DDI method number */ + uint32_t prototype:8; /* DDI serialization format */ + uint32_t msgid:8; /* message id (DDI, ATTACH, DETACH, ...) */ + void *from; + void *to; } __attribute__((packed)); -#define TRACE_DATA_MAX 128 -#define TRACE_LOG_MAX 32 -#define TRACE_LOG_MASK (TRACE_LOG_MAX - 1) +#define TRACE_DATA_MAX 128 +#define TRACE_LOG_MAX 32 +#define TRACE_LOG_MASK (TRACE_LOG_MAX - 1) struct dal_trace { - unsigned timestamp; - struct dal_hdr hdr; - uint32_t data[TRACE_DATA_MAX]; + unsigned timestamp; + struct dal_hdr hdr; + uint32_t data[TRACE_DATA_MAX]; }; -#define DAL_HDR_SIZE (sizeof(struct dal_hdr)) -#define DAL_DATA_MAX 512 -#define DAL_MSG_MAX (DAL_HDR_SIZE + DAL_DATA_MAX) +#define DAL_HDR_SIZE (sizeof(struct dal_hdr)) +#define DAL_DATA_MAX 512 +#define DAL_MSG_MAX (DAL_HDR_SIZE + DAL_DATA_MAX) -#define DAL_VERSION 0x11 +#define DAL_VERSION 0x11 -#define DAL_MSGID_DDI 0x00 -#define DAL_MSGID_ATTACH 0x01 -#define DAL_MSGID_DETACH 0x02 -#define DAL_MSGID_ASYNCH 0xC0 -#define DAL_MSGID_REPLY 0x80 +#define DAL_MSGID_DDI 0x00 +#define DAL_MSGID_ATTACH 0x01 +#define DAL_MSGID_DETACH 0x02 +#define DAL_MSGID_ASYNCH 0xC0 +#define DAL_MSGID_REPLY 0x80 struct dal_channel { - struct list_head list; - struct list_head clients; + struct list_head list; + struct list_head clients; - /* synchronization for changing channel state, - * adding/removing clients, smd callbacks, etc - */ - spinlock_t lock; + /* synchronization for changing channel state, + * adding/removing clients, smd callbacks, etc + */ + spinlock_t lock; - struct smd_channel *sch; - char *name; + struct smd_channel *sch; + char *name; - /* events are delivered at IRQ context immediately, so - * we only need one assembly buffer for the entire channel - */ - struct dal_hdr hdr; - unsigned char data[DAL_DATA_MAX]; + /* events are delivered at IRQ context immediately, so + * we only need one assembly buffer for the entire channel + */ + struct dal_hdr hdr; + unsigned char data[DAL_DATA_MAX]; - unsigned count; - void *ptr; + unsigned count; + void *ptr; - /* client which the current inbound message is for */ - struct dal_client *active; + /* client which the current inbound message is for */ + struct dal_client *active; }; struct dal_client { - struct list_head list; - struct dal_channel *dch; - void *cookie; - dal_event_func_t event; + struct list_head list; + struct dal_channel *dch; + void *cookie; + dal_event_func_t event; - /* opaque handle for the far side */ - void *remote; + /* opaque handle for the far side */ + void *remote; - /* dal rpc calls are fully synchronous -- only one call may be - * active per client at a time - */ - struct mutex write_lock; - wait_queue_head_t wait; + /* dal rpc calls are fully synchronous -- only one call may be + * active per client at a time + */ + struct mutex write_lock; + wait_queue_head_t wait; - unsigned char data[DAL_DATA_MAX]; + unsigned char data[DAL_DATA_MAX]; - void *reply; - int reply_max; - int status; - unsigned msgid; /* msgid of expected reply */ + void *reply; + int reply_max; + int status; + unsigned msgid; /* msgid of expected reply */ - spinlock_t tr_lock; - unsigned tr_head; - unsigned tr_tail; - struct dal_trace *tr_log; + spinlock_t tr_lock; + unsigned tr_head; + unsigned tr_tail; + struct dal_trace *tr_log; }; static unsigned now(void) { - struct timespec ts; - ktime_get_ts(&ts); - return (ts.tv_nsec / 1000000) + (ts.tv_sec * 1000); + struct timespec ts; + ktime_get_ts(&ts); + return (ts.tv_nsec / 1000000) + (ts.tv_sec * 1000); } void dal_trace(struct dal_client *c) { - if (c->tr_log) - return; - c->tr_log = kzalloc(sizeof(struct dal_trace) * TRACE_LOG_MAX, - GFP_KERNEL); + if (c->tr_log) + return; + c->tr_log = kzalloc(sizeof(struct dal_trace) * TRACE_LOG_MAX, + GFP_KERNEL); } void dal_trace_print(struct dal_hdr *hdr, unsigned *data, int len, unsigned when) { - int i; - printk("DAL %08x -> %08x L=%03x A=%d D=%04x P=%02x M=%02x T=%d", - (unsigned) hdr->from, (unsigned) hdr->to, - hdr->length, hdr->async, - hdr->ddi, hdr->prototype, hdr->msgid, - when); - len /= 4; - for (i = 0; i < len; i++) { - if (!(i & 7)) - printk("\n%03x", i * 4); - printk(" %08x", data[i]); - } - printk("\n"); + int i; + printk("DAL %08x -> %08x L=%03x A=%d D=%04x P=%02x M=%02x T=%d", + (unsigned) hdr->from, (unsigned) hdr->to, + hdr->length, hdr->async, + hdr->ddi, hdr->prototype, hdr->msgid, + when); + len /= 4; + for (i = 0; i < len; i++) { + if (!(i & 7)) + printk("\n%03x", i * 4); + printk(" %08x", data[i]); + } + printk("\n"); } void dal_trace_dump(struct dal_client *c) { - struct dal_trace *dt; - unsigned n, len; + struct dal_trace *dt; + unsigned n, len; - if (!c->tr_log) - return; + if (!c->tr_log) + return; - for (n = c->tr_tail; n != c->tr_head; n = (n + 1) & TRACE_LOG_MASK) { - dt = c->tr_log + n; - len = dt->hdr.length; - if (len > TRACE_DATA_MAX) - len = TRACE_DATA_MAX; - dal_trace_print(&dt->hdr, dt->data, len, dt->timestamp); - } + for (n = c->tr_tail; n != c->tr_head; n = (n + 1) & TRACE_LOG_MASK) { + dt = c->tr_log + n; + len = dt->hdr.length; + if (len > TRACE_DATA_MAX) + len = TRACE_DATA_MAX; + dal_trace_print(&dt->hdr, dt->data, len, dt->timestamp); + } } static void dal_trace_log(struct dal_client *c, - struct dal_hdr *hdr, void *data, unsigned len) + struct dal_hdr *hdr, void *data, unsigned len) { - unsigned long flags; - unsigned t, n; - struct dal_trace *dt; + unsigned long flags; + unsigned t, n; + struct dal_trace *dt; - t = now(); - if (len > TRACE_DATA_MAX) - len = TRACE_DATA_MAX; + t = now(); + if (len > TRACE_DATA_MAX) + len = TRACE_DATA_MAX; - spin_lock_irqsave(&c->tr_lock, flags); - n = (c->tr_head + 1) & TRACE_LOG_MASK; - if (c->tr_tail == n) - c->tr_tail = (c->tr_tail + 1) & TRACE_LOG_MASK; - dt = c->tr_log + n; - dt->timestamp = t; - memcpy(&dt->hdr, hdr, sizeof(struct dal_hdr)); - memcpy(dt->data, data, len); - c->tr_head = n; + spin_lock_irqsave(&c->tr_lock, flags); + n = (c->tr_head + 1) & TRACE_LOG_MASK; + if (c->tr_tail == n) + c->tr_tail = (c->tr_tail + 1) & TRACE_LOG_MASK; + dt = c->tr_log + n; + dt->timestamp = t; + memcpy(&dt->hdr, hdr, sizeof(struct dal_hdr)); + memcpy(dt->data, data, len); + c->tr_head = n; - spin_unlock_irqrestore(&c->tr_lock, flags); + spin_unlock_irqrestore(&c->tr_lock, flags); } static void dal_channel_notify(void *priv, unsigned event) { - struct dal_channel *dch = priv; - struct dal_hdr *hdr = &dch->hdr; - struct dal_client *client; - unsigned long flags; - int len; - int r; + struct dal_channel *dch = priv; + struct dal_hdr *hdr = &dch->hdr; + struct dal_client *client; + unsigned long flags; + int len; + int r; - spin_lock_irqsave(&dch->lock, flags); + spin_lock_irqsave(&dch->lock, flags); again: - if (dch->count == 0) { - if (smd_read_avail(dch->sch) < DAL_HDR_SIZE) - goto done; + if (dch->count == 0) { + if (smd_read_avail(dch->sch) < DAL_HDR_SIZE) + goto done; - smd_read(dch->sch, hdr, DAL_HDR_SIZE); + smd_read(dch->sch, hdr, DAL_HDR_SIZE); - if (hdr->length < DAL_HDR_SIZE) - goto done; + if (hdr->length < DAL_HDR_SIZE) + goto done; - if (hdr->length > DAL_MSG_MAX) - panic("oversize message"); + if (hdr->length > DAL_MSG_MAX) + panic("oversize message"); - dch->count = hdr->length - DAL_HDR_SIZE; + dch->count = hdr->length - DAL_HDR_SIZE; - /* locate the client this message is targeted to */ - list_for_each_entry(client, &dch->clients, list) { - if (dch->hdr.to == client) { - dch->active = client; - dch->ptr = client->data; - goto check_data; - } - } - pr_err("$$$ receiving unknown message len = %d $$$\n", - dch->count); - dch->active = 0; - dch->ptr = dch->data; - } + /* locate the client this message is targeted to */ + list_for_each_entry(client, &dch->clients, list) { + if (dch->hdr.to == client) { + dch->active = client; + dch->ptr = client->data; + goto check_data; + } + } + pr_err("$$$ receiving unknown message len = %d $$$\n", + dch->count); + dch->active = 0; + dch->ptr = dch->data; + } check_data: - len = dch->count; - if (len > 0) { - if (smd_read_avail(dch->sch) < len) - goto done; + len = dch->count; + if (len > 0) { + if (smd_read_avail(dch->sch) < len) + goto done; - r = smd_read(dch->sch, dch->ptr, len); - if (r != len) - panic("invalid read"); + r = smd_read(dch->sch, dch->ptr, len); + if (r != len) + panic("invalid read"); #if DAL_TRACE - pr_info("dal recv %p <- %p %02x:%04x:%02x %d\n", - hdr->to, hdr->from, hdr->msgid, hdr->ddi, - hdr->prototype, hdr->length - sizeof(*hdr)); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, dch->ptr, len); + pr_info("dal recv %p <- %p %02x:%04x:%02x %d\n", + hdr->to, hdr->from, hdr->msgid, hdr->ddi, + hdr->prototype, hdr->length - sizeof(*hdr)); + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, dch->ptr, len); #endif - dch->count = 0; + dch->count = 0; - client = dch->active; - if (!client) { - pr_err("dal: message to %p discarded\n", dch->hdr.to); - goto again; - } + client = dch->active; + if (!client) { + pr_err("dal: message to %p discarded\n", dch->hdr.to); + goto again; + } - if (client->tr_log) - dal_trace_log(client, hdr, dch->ptr, len); + if (client->tr_log) + dal_trace_log(client, hdr, dch->ptr, len); - if (hdr->msgid == DAL_MSGID_ASYNCH) { - if (client->event) - client->event(dch->ptr, len, client->cookie); - else - pr_err("dal: client %p has no event handler\n", client); - goto again; - } + if (hdr->msgid == DAL_MSGID_ASYNCH) { + if (client->event) + client->event(dch->ptr, len, client->cookie); + else + pr_err("dal: client %p has no event handler\n", client); + goto again; + } - if (hdr->msgid == client->msgid) { - if (!client->remote) - client->remote = hdr->from; - if (len > client->reply_max) - len = client->reply_max; - memcpy(client->reply, client->data, len); - client->status = len; - wake_up(&client->wait); - goto again; - } + if (hdr->msgid == client->msgid) { + if (!client->remote) + client->remote = hdr->from; + if (len > client->reply_max) + len = client->reply_max; + memcpy(client->reply, client->data, len); + client->status = len; + wake_up(&client->wait); + goto again; + } - pr_err("dal: cannot find client %p\n", dch->hdr.to); - goto again; - } + pr_err("dal: cannot find client %p\n", dch->hdr.to); + goto again; + } done: - spin_unlock_irqrestore(&dch->lock, flags); + spin_unlock_irqrestore(&dch->lock, flags); } static LIST_HEAD(dal_channel_list); @@ -290,456 +290,456 @@ static DEFINE_MUTEX(dal_channel_list_lock); static struct dal_channel *dal_open_channel(const char *name) { - struct dal_channel *dch; + struct dal_channel *dch; - /* quick sanity check to avoid trying to talk to - * some non-DAL channel... - */ - if (strncmp(name, "DSP_DAL", 7) && strncmp(name, "SMD_DAL", 7)) - return 0; + /* quick sanity check to avoid trying to talk to + * some non-DAL channel... + */ + if (strncmp(name, "DSP_DAL", 7) && strncmp(name, "SMD_DAL", 7)) + return 0; - mutex_lock(&dal_channel_list_lock); + mutex_lock(&dal_channel_list_lock); - list_for_each_entry(dch, &dal_channel_list, list) { - if (!strcmp(dch->name, name)) - goto found_it; - } + list_for_each_entry(dch, &dal_channel_list, list) { + if (!strcmp(dch->name, name)) + goto found_it; + } - dch = kzalloc(sizeof(*dch) + strlen(name) + 1, GFP_KERNEL); - if (!dch) - goto fail; + dch = kzalloc(sizeof(*dch) + strlen(name) + 1, GFP_KERNEL); + if (!dch) + goto fail; - dch->name = (char *) (dch + 1); - strcpy(dch->name, name); - spin_lock_init(&dch->lock); - INIT_LIST_HEAD(&dch->clients); + dch->name = (char *) (dch + 1); + strcpy(dch->name, name); + spin_lock_init(&dch->lock); + INIT_LIST_HEAD(&dch->clients); - list_add(&dch->list, &dal_channel_list); + list_add(&dch->list, &dal_channel_list); found_it: - if (!dch->sch) { - if (smd_open(name, &dch->sch, dch, dal_channel_notify)) - dch = NULL; - /* FIXME: wait for channel to open before returning */ - msleep(100); - } + if (!dch->sch) { + if (smd_open(name, &dch->sch, dch, dal_channel_notify)) + dch = NULL; + /* FIXME: wait for channel to open before returning */ + msleep(100); + } fail: - mutex_unlock(&dal_channel_list_lock); + mutex_unlock(&dal_channel_list_lock); - return dch; + return dch; } int dal_call_raw(struct dal_client *client, - struct dal_hdr *hdr, - void *data, int data_len, - void *reply, int reply_max) + struct dal_hdr *hdr, + void *data, int data_len, + void *reply, int reply_max) { - struct dal_channel *dch = client->dch; - unsigned long flags; + struct dal_channel *dch = client->dch; + unsigned long flags; - client->reply = reply; - client->reply_max = reply_max; - client->msgid = hdr->msgid | DAL_MSGID_REPLY; - client->status = -EBUSY; + client->reply = reply; + client->reply_max = reply_max; + client->msgid = hdr->msgid | DAL_MSGID_REPLY; + client->status = -EBUSY; #if DAL_TRACE - pr_info("dal send %p -> %p %02x:%04x:%02x %d\n", - hdr->from, hdr->to, hdr->msgid, hdr->ddi, - hdr->prototype, hdr->length - sizeof(*hdr)); - print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, data_len); + pr_info("dal send %p -> %p %02x:%04x:%02x %d\n", + hdr->from, hdr->to, hdr->msgid, hdr->ddi, + hdr->prototype, hdr->length - sizeof(*hdr)); + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, data_len); #endif - if (client->tr_log) - dal_trace_log(client, hdr, data, data_len); + if (client->tr_log) + dal_trace_log(client, hdr, data, data_len); - spin_lock_irqsave(&dch->lock, flags); - /* FIXME: ensure entire message is written or none. */ - smd_write(dch->sch, hdr, sizeof(*hdr)); - smd_write(dch->sch, data, data_len); - spin_unlock_irqrestore(&dch->lock, flags); + spin_lock_irqsave(&dch->lock, flags); + /* FIXME: ensure entire message is written or none. */ + smd_write(dch->sch, hdr, sizeof(*hdr)); + smd_write(dch->sch, data, data_len); + spin_unlock_irqrestore(&dch->lock, flags); - if (!wait_event_timeout(client->wait, (client->status != -EBUSY), 5*HZ)) - { - dal_trace_dump(client); - pr_err("dal: call timed out. dsp is probably dead.\n"); - dal_trace_print(hdr, data, data_len, 0); -// BUG(); - } + if (!wait_event_timeout(client->wait, (client->status != -EBUSY), 5*HZ)) + { + dal_trace_dump(client); + pr_err("dal: call timed out. dsp is probably dead.\n"); + dal_trace_print(hdr, data, data_len, 0); +// BUG(); + } - return client->status; + return client->status; } int dal_call(struct dal_client *client, - unsigned ddi, unsigned prototype, - void *data, int data_len, - void *reply, int reply_max) + unsigned ddi, unsigned prototype, + void *data, int data_len, + void *reply, int reply_max) { - struct dal_hdr hdr; - int r; + struct dal_hdr hdr; + int r; - memset(&hdr, 0, sizeof(hdr)); + memset(&hdr, 0, sizeof(hdr)); - hdr.length = data_len + sizeof(hdr); - hdr.version = DAL_VERSION; - hdr.msgid = DAL_MSGID_DDI; - hdr.ddi = ddi; - hdr.prototype = prototype; - hdr.from = client; - hdr.to = client->remote; + hdr.length = data_len + sizeof(hdr); + hdr.version = DAL_VERSION; + hdr.msgid = DAL_MSGID_DDI; + hdr.ddi = ddi; + hdr.prototype = prototype; + hdr.from = client; + hdr.to = client->remote; - if (hdr.length > DAL_MSG_MAX) - return -EINVAL; + if (hdr.length > DAL_MSG_MAX) + return -EINVAL; - mutex_lock(&client->write_lock); - r = dal_call_raw(client, &hdr, data, data_len, reply, reply_max); - mutex_unlock(&client->write_lock); + mutex_lock(&client->write_lock); + r = dal_call_raw(client, &hdr, data, data_len, reply, reply_max); + mutex_unlock(&client->write_lock); #if 1 - if ((r > 3) && (((uint32_t*) reply)[0] == 0)) { - // pr_info("dal call OK\n"); - } else { - pr_info("dal call %d %d ERROR\n", ddi, prototype); - } + if ((r > 3) && (((uint32_t*) reply)[0] == 0)) { + // pr_info("dal call OK\n"); + } else { + pr_info("dal call %d %d ERROR\n", ddi, prototype); + } #endif - return r; + return r; } struct dal_msg_attach { - uint32_t device_id; - char attach[64]; - char service_name[32]; + uint32_t device_id; + char attach[64]; + char service_name[32]; } __attribute__((packed)); struct dal_reply_attach { - uint32_t status; - char name[64]; + uint32_t status; + char name[64]; }; struct dal_client *dal_attach_ex(uint32_t device_id, const char *aname, const char *name, dal_event_func_t func, void *cookie) { - struct dal_hdr hdr; - struct dal_msg_attach msg; - struct dal_reply_attach reply; - struct dal_channel *dch; - struct dal_client *client; - unsigned long flags; - int r; + struct dal_hdr hdr; + struct dal_msg_attach msg; + struct dal_reply_attach reply; + struct dal_channel *dch; + struct dal_client *client; + unsigned long flags; + int r; - dch = dal_open_channel(name); - if (!dch) - return 0; + dch = dal_open_channel(name); + if (!dch) + return 0; - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client) - return 0; + client = kzalloc(sizeof(*client), GFP_KERNEL); + if (!client) + return 0; - client->dch = dch; - client->event = func; - client->cookie = cookie; - mutex_init(&client->write_lock); - spin_lock_init(&client->tr_lock); - init_waitqueue_head(&client->wait); + client->dch = dch; + client->event = func; + client->cookie = cookie; + mutex_init(&client->write_lock); + spin_lock_init(&client->tr_lock); + init_waitqueue_head(&client->wait); - spin_lock_irqsave(&dch->lock, flags); - list_add(&client->list, &dch->clients); - spin_unlock_irqrestore(&dch->lock, flags); + spin_lock_irqsave(&dch->lock, flags); + list_add(&client->list, &dch->clients); + spin_unlock_irqrestore(&dch->lock, flags); - memset(&hdr, 0, sizeof(hdr)); - memset(&msg, 0, sizeof(msg)); + memset(&hdr, 0, sizeof(hdr)); + memset(&msg, 0, sizeof(msg)); - hdr.length = sizeof(hdr) + sizeof(msg); - hdr.version = DAL_VERSION; - hdr.msgid = DAL_MSGID_ATTACH; - hdr.from = client; - msg.device_id = device_id; - if (aname) - strcpy(msg.attach, aname); + hdr.length = sizeof(hdr) + sizeof(msg); + hdr.version = DAL_VERSION; + hdr.msgid = DAL_MSGID_ATTACH; + hdr.from = client; + msg.device_id = device_id; + if (aname) + strcpy(msg.attach, aname); - r = dal_call_raw(client, &hdr, &msg, sizeof(msg), - &reply, sizeof(reply)); + r = dal_call_raw(client, &hdr, &msg, sizeof(msg), + &reply, sizeof(reply)); - if ((r == sizeof(reply)) && (reply.status == 0)) { - reply.name[63] = 0; - pr_info("dal_attach: status = %d, name = '%s'\n", - reply.status, reply.name); - return client; - } + if ((r == sizeof(reply)) && (reply.status == 0)) { + reply.name[63] = 0; + pr_info("dal_attach: status = %d, name = '%s'\n", + reply.status, reply.name); + return client; + } - pr_err("dal_attach: failure\n"); + pr_err("dal_attach: failure\n"); - dal_detach(client); - return 0; + dal_detach(client); + return 0; } struct dal_client *dal_attach(uint32_t device_id, const char *name, - dal_event_func_t func, void *cookie) + dal_event_func_t func, void *cookie) { - struct dal_hdr hdr; - struct dal_msg_attach msg; - struct dal_reply_attach reply; - struct dal_channel *dch; - struct dal_client *client; - unsigned long flags; - int r; + struct dal_hdr hdr; + struct dal_msg_attach msg; + struct dal_reply_attach reply; + struct dal_channel *dch; + struct dal_client *client; + unsigned long flags; + int r; - dch = dal_open_channel(name); - if (!dch) - return 0; + dch = dal_open_channel(name); + if (!dch) + return 0; - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client) - return 0; + client = kzalloc(sizeof(*client), GFP_KERNEL); + if (!client) + return 0; - client->dch = dch; - client->event = func; - client->cookie = cookie; - mutex_init(&client->write_lock); - spin_lock_init(&client->tr_lock); - init_waitqueue_head(&client->wait); + client->dch = dch; + client->event = func; + client->cookie = cookie; + mutex_init(&client->write_lock); + spin_lock_init(&client->tr_lock); + init_waitqueue_head(&client->wait); - spin_lock_irqsave(&dch->lock, flags); - list_add(&client->list, &dch->clients); - spin_unlock_irqrestore(&dch->lock, flags); + spin_lock_irqsave(&dch->lock, flags); + list_add(&client->list, &dch->clients); + spin_unlock_irqrestore(&dch->lock, flags); - memset(&hdr, 0, sizeof(hdr)); - memset(&msg, 0, sizeof(msg)); + memset(&hdr, 0, sizeof(hdr)); + memset(&msg, 0, sizeof(msg)); - hdr.length = sizeof(hdr) + sizeof(msg); - hdr.version = DAL_VERSION; - hdr.msgid = DAL_MSGID_ATTACH; - hdr.from = client; - msg.device_id = device_id; + hdr.length = sizeof(hdr) + sizeof(msg); + hdr.version = DAL_VERSION; + hdr.msgid = DAL_MSGID_ATTACH; + hdr.from = client; + msg.device_id = device_id; - r = dal_call_raw(client, &hdr, &msg, sizeof(msg), - &reply, sizeof(reply)); + r = dal_call_raw(client, &hdr, &msg, sizeof(msg), + &reply, sizeof(reply)); - if ((r == sizeof(reply)) && (reply.status == 0)) { - reply.name[63] = 0; - pr_info("dal_attach: status = %d, name = '%s'\n", - reply.status, reply.name); - return client; - } + if ((r == sizeof(reply)) && (reply.status == 0)) { + reply.name[63] = 0; + pr_info("dal_attach: status = %d, name = '%s'\n", + reply.status, reply.name); + return client; + } - pr_err("dal_attach: failure\n"); + pr_err("dal_attach: failure\n"); - dal_detach(client); - return 0; + dal_detach(client); + return 0; } int dal_detach(struct dal_client *client) { - struct dal_channel *dch; - unsigned long flags; + struct dal_channel *dch; + unsigned long flags; - mutex_lock(&client->write_lock); - if (client->remote) { - struct dal_hdr hdr; - uint32_t data; + mutex_lock(&client->write_lock); + if (client->remote) { + struct dal_hdr hdr; + uint32_t data; - memset(&hdr, 0, sizeof(hdr)); - hdr.length = sizeof(hdr) + sizeof(data); - hdr.version = DAL_VERSION; - hdr.msgid = DAL_MSGID_DETACH; - hdr.from = client; - hdr.to = client->remote; - data = (uint32_t) client; + memset(&hdr, 0, sizeof(hdr)); + hdr.length = sizeof(hdr) + sizeof(data); + hdr.version = DAL_VERSION; + hdr.msgid = DAL_MSGID_DETACH; + hdr.from = client; + hdr.to = client->remote; + data = (uint32_t) client; - dal_call_raw(client, &hdr, &data, sizeof(data), - &data, sizeof(data)); - } + dal_call_raw(client, &hdr, &data, sizeof(data), + &data, sizeof(data)); + } - dch = client->dch; - spin_lock_irqsave(&dch->lock, flags); - if (dch->active == client) { - /* We have received a message header for this client - * but not the body of the message. Ensure that when - * the body arrives we don't write it into the now-closed - * client. In *theory* this should never happen. - */ - dch->active = 0; - dch->ptr = dch->data; - } - list_del(&client->list); - spin_unlock_irqrestore(&dch->lock, flags); + dch = client->dch; + spin_lock_irqsave(&dch->lock, flags); + if (dch->active == client) { + /* We have received a message header for this client + * but not the body of the message. Ensure that when + * the body arrives we don't write it into the now-closed + * client. In *theory* this should never happen. + */ + dch->active = 0; + dch->ptr = dch->data; + } + list_del(&client->list); + spin_unlock_irqrestore(&dch->lock, flags); - mutex_unlock(&client->write_lock); + mutex_unlock(&client->write_lock); - kfree(client); - return 0; + kfree(client); + return 0; } void *dal_get_remote_handle(struct dal_client *client) { - return client->remote; + return client->remote; } /* convenience wrappers */ int dal_call_f0(struct dal_client *client, uint32_t ddi, uint32_t arg1) { - uint32_t tmp = arg1; - int res; - res = dal_call(client, ddi, 0, &tmp, sizeof(tmp), &tmp, sizeof(tmp)); - if (res >= 4) - return (int) tmp; - return res; + uint32_t tmp = arg1; + int res; + res = dal_call(client, ddi, 0, &tmp, sizeof(tmp), &tmp, sizeof(tmp)); + if (res >= 4) + return (int) tmp; + return res; } int dal_call_f1(struct dal_client *client, uint32_t ddi, uint32_t arg1, uint32_t arg2) { - uint32_t tmp[2]; - int res; - tmp[0] = arg1; - tmp[1] = arg2; - res = dal_call(client, ddi, 1, tmp, sizeof(tmp), tmp, sizeof(uint32_t)); - if (res >= 4) - return (int) tmp[0]; - return res; + uint32_t tmp[2]; + int res; + tmp[0] = arg1; + tmp[1] = arg2; + res = dal_call(client, ddi, 1, tmp, sizeof(tmp), tmp, sizeof(uint32_t)); + if (res >= 4) + return (int) tmp[0]; + return res; } int dal_call_f5(struct dal_client *client, uint32_t ddi, void *ibuf, uint32_t ilen) { -// uint32_t tmp[128]; - uint32_t tmp[DAL_DATA_MAX]; - int res; - int param_idx = 0; +// uint32_t tmp[128]; + uint32_t tmp[DAL_DATA_MAX]; + int res; + int param_idx = 0; - if (ilen + 4 > DAL_DATA_MAX) - return -EINVAL; + if (ilen + 4 > DAL_DATA_MAX) + return -EINVAL; - tmp[param_idx] = ilen; - param_idx++; + tmp[param_idx] = ilen; + param_idx++; - memcpy(&tmp[param_idx], ibuf, ilen); - param_idx += DIV_ROUND_UP(ilen, 4); + memcpy(&tmp[param_idx], ibuf, ilen); + param_idx += DIV_ROUND_UP(ilen, 4); - res = dal_call(client, ddi, 5, tmp, param_idx * 4, tmp, sizeof(tmp)); + res = dal_call(client, ddi, 5, tmp, param_idx * 4, tmp, sizeof(tmp)); - if (res >= 4) - return (int) tmp[0]; - return res; + if (res >= 4) + return (int) tmp[0]; + return res; } int dal_call_f6(struct dal_client *client, uint32_t ddi, uint32_t cmd, void *ibuf, uint32_t ilen) { - uint32_t tmp[DAL_DATA_MAX]; - int res; - int param_idx = 0; + uint32_t tmp[DAL_DATA_MAX]; + int res; + int param_idx = 0; - if (ilen + 4 > DAL_DATA_MAX) - return -EINVAL; + if (ilen + 4 > DAL_DATA_MAX) + return -EINVAL; - tmp[param_idx] = cmd; - param_idx++; - tmp[param_idx] = ilen; - param_idx++; + tmp[param_idx] = cmd; + param_idx++; + tmp[param_idx] = ilen; + param_idx++; - memcpy(&tmp[param_idx], ibuf, ilen); - param_idx += DIV_ROUND_UP(ilen, 4); + memcpy(&tmp[param_idx], ibuf, ilen); + param_idx += DIV_ROUND_UP(ilen, 4); - res = dal_call(client, ddi, 6, tmp, param_idx * 4, tmp, sizeof(tmp)); + res = dal_call(client, ddi, 6, tmp, param_idx * 4, tmp, sizeof(tmp)); - if (res >= 4) - return (int) tmp[0]; - return res; + if (res >= 4) + return (int) tmp[0]; + return res; } int dal_call_f8(struct dal_client *client, uint32_t ddi, void *ibuf, uint32_t ilen, void *obuf, uint32_t olen) { - uint32_t tmp[128]; - int res; - int param_idx = 0; + uint32_t tmp[128]; + int res; + int param_idx = 0; - if (ilen + 8 > DAL_DATA_MAX) - return -EINVAL; + if (ilen + 8 > DAL_DATA_MAX) + return -EINVAL; - tmp[param_idx] = ilen; - param_idx++; + tmp[param_idx] = ilen; + param_idx++; - memcpy(&tmp[param_idx], ibuf, ilen); - param_idx += DIV_ROUND_UP(ilen, 4); + memcpy(&tmp[param_idx], ibuf, ilen); + param_idx += DIV_ROUND_UP(ilen, 4); - tmp[param_idx++] = olen; - res = dal_call(client, ddi, 8, tmp, param_idx * 4, tmp, sizeof(tmp)); + tmp[param_idx++] = olen; + res = dal_call(client, ddi, 8, tmp, param_idx * 4, tmp, sizeof(tmp)); - if (res >= 4) - { - res = (int)tmp[0]; - } + if (res >= 4) + { + res = (int)tmp[0]; + } - if (!res) - { - if (tmp[1] > olen) - return -EIO; - memcpy(obuf, &tmp[2], tmp[1]); - } - return res; + if (!res) + { + if (tmp[1] > olen) + return -EIO; + memcpy(obuf, &tmp[2], tmp[1]); + } + return res; } int dal_call_f9(struct dal_client *client, uint32_t ddi, void *obuf, uint32_t olen) { - uint32_t tmp[128]; - int res; - int param_idx = 0; + uint32_t tmp[128]; + int res; + int param_idx = 0; - if (olen + 8 > DAL_DATA_MAX) - return -EINVAL; + if (olen + 8 > DAL_DATA_MAX) + return -EINVAL; - tmp[param_idx++] = olen; - res = dal_call(client, ddi, 9, tmp, param_idx * 4, tmp, sizeof(tmp)); + tmp[param_idx++] = olen; + res = dal_call(client, ddi, 9, tmp, param_idx * 4, tmp, sizeof(tmp)); - if (res >= 4) - { - res = (int)tmp[0]; - } + if (res >= 4) + { + res = (int)tmp[0]; + } - if (!res) - { - if (tmp[1] > olen) - return -EIO; - memcpy(obuf, &tmp[2], tmp[1]); - } - return res; + if (!res) + { + if (tmp[1] > olen) + return -EIO; + memcpy(obuf, &tmp[2], tmp[1]); + } + return res; } int dal_call_f13(struct dal_client *client, uint32_t ddi, void *ibuf1, - uint32_t ilen1, void *ibuf2, uint32_t ilen2, void *obuf, uint32_t olen) + uint32_t ilen1, void *ibuf2, uint32_t ilen2, void *obuf, uint32_t olen) { - uint32_t tmp[128]; - int res; - int param_idx = 0; + uint32_t tmp[128]; + int res; + int param_idx = 0; - if (ilen1 + ilen2 + 8 > DAL_DATA_MAX) - return -EINVAL; + if (ilen1 + ilen2 + 8 > DAL_DATA_MAX) + return -EINVAL; - tmp[param_idx] = ilen1; - param_idx++; + tmp[param_idx] = ilen1; + param_idx++; - memcpy(&tmp[param_idx], ibuf1, ilen1); - param_idx += DIV_ROUND_UP(ilen1, 4); + memcpy(&tmp[param_idx], ibuf1, ilen1); + param_idx += DIV_ROUND_UP(ilen1, 4); - tmp[param_idx++] = ilen2; - memcpy(&tmp[param_idx], ibuf2, ilen2); - param_idx += DIV_ROUND_UP(ilen2, 4); + tmp[param_idx++] = ilen2; + memcpy(&tmp[param_idx], ibuf2, ilen2); + param_idx += DIV_ROUND_UP(ilen2, 4); - tmp[param_idx++] = olen; - res = dal_call(client, ddi, 13, tmp, param_idx * 4, tmp, sizeof(tmp)); + tmp[param_idx++] = olen; + res = dal_call(client, ddi, 13, tmp, param_idx * 4, tmp, sizeof(tmp)); - if (res >= 4) - res = (int)tmp[0]; + if (res >= 4) + res = (int)tmp[0]; - if (!res) { - if (tmp[1] > olen) - return -EIO; - memcpy(obuf, &tmp[2], tmp[1]); - } - return res; + if (!res) { + if (tmp[1] > olen) + return -EIO; + memcpy(obuf, &tmp[2], tmp[1]); + } + return res; } diff --git a/arch/arm/mach-msm/qdsp6_1550/dal_audio.h b/arch/arm/mach-msm/qdsp6_1550/dal_audio.h index f9ea9c72..549283b9 100644 --- a/arch/arm/mach-msm/qdsp6_1550/dal_audio.h +++ b/arch/arm/mach-msm/qdsp6_1550/dal_audio.h @@ -36,22 +36,16 @@ #define AUDIO_DAL_DEVICE 0x02000028 #define AUDIO_DAL_PORT "DSP_DAL_AQ_AUD" + enum { -#if defined(CONFIG_MACH_HTCLEO) - AUDIO_OP_OPEN = DAL_OP_FIRST_DEVICE_API, - AUDIO_OP_WRITE, - AUDIO_OP_READ, - AUDIO_OP_IOCTL, - AUDIO_OP_INIT, - AUDIO_OP_CLOSE, - AUDIO_OP_FLUSH -#else - AUDIO_OP_CONTROL = DAL_OP_FIRST_DEVICE_API, - AUDIO_OP_DATA, - AUDIO_OP_INIT, - -#endif + AUDIO_OP_OPEN = DAL_OP_FIRST_DEVICE_API, + AUDIO_OP_WRITE, + AUDIO_OP_READ, + AUDIO_OP_IOCTL, + AUDIO_OP_INIT, + AUDIO_OP_CLOSE, + AUDIO_OP_FLUSH }; /* ---- common audio structures ---- */ @@ -84,14 +78,14 @@ enum #define ADSP_AUDIO_BUFFER_FLAG_CONTINUATION 0x40 struct adsp_audio_buffer { - u32 addr; /* Physical Address of buffer */ - u32 max_size; /* Maximum size of buffer */ - u32 actual_size; /* Actual size of valid data in the buffer */ - u32 offset; /* Offset to the first valid byte */ - u32 flags; /* ADSP_AUDIO_BUFFER_FLAGs that has been set */ - s64 start; /* Start timestamp, if any */ - s64 stop; /* Stop timestamp, if any */ - s64 preroll; /* Preroll timestamp, if any */ + u32 addr; /* Physical Address of buffer */ + u32 max_size; /* Maximum size of buffer */ + u32 actual_size; /* Actual size of valid data in the buffer */ + u32 offset; /* Offset to the first valid byte */ + u32 flags; /* ADSP_AUDIO_BUFFER_FLAGs that has been set */ + s64 start; /* Start timestamp, if any */ + s64 stop; /* Stop timestamp, if any */ + s64 preroll; /* Preroll timestamp, if any */ } __attribute__ ((packed)); @@ -102,31 +96,31 @@ struct adsp_audio_buffer { #define ADSP_AUDIO_RESPONSE_COMMAND 0 #define ADSP_AUDIO_RESPONSE_ASYNC 1 -#if !defined(CONFIG_MACH_HTCLEO) +#if 0 struct adsp_command_hdr { - u32 size; /* sizeof(cmd) - sizeof(u32) */ + u32 size; /* sizeof(cmd) - sizeof(u32) */ - u32 dst; - u32 src; + u32 dst; + u32 src; - u32 opcode; - u32 response_type; - u32 seq_number; + u32 opcode; + u32 response_type; + u32 seq_number; - u32 context; /* opaque to DSP */ - u32 data; + u32 context; /* opaque to DSP */ + u32 data; - u32 padding; + u32 padding; } __attribute__ ((packed)); +#endif -#else struct adsp_command_hdr { - u32 context; - u32 data; + u32 context; + u32 data; } __attribute__ ((packed)); -#endif + #define AUDIO_DOMAIN_APP 0 #define AUDIO_DOMAIN_MODEM 1 @@ -147,8 +141,8 @@ struct adsp_command_hdr #define ADSP_AUDIO_ENC_ENHANCED_AAC_PLUS_MODE 2 struct adsp_audio_aac_enc_cfg { - u32 bit_rate; /* bits per second */ - u32 encoder_mode; /* ADSP_AUDIO_ENC_* */ + u32 bit_rate; /* bits per second */ + u32 encoder_mode; /* ADSP_AUDIO_ENC_* */ } __attribute__ ((packed)); #define ADSP_AUDIO_ENC_SBC_ALLOCATION_METHOD_LOUNDNESS 0 @@ -160,11 +154,11 @@ struct adsp_audio_aac_enc_cfg { #define ADSP_AUDIO_ENC_SBC_CHANNEL_MODE_JOINT_STEREO 9 struct adsp_audio_sbc_encoder_cfg { - u32 num_subbands; - u32 block_len; - u32 channel_mode; - u32 allocation_method; - u32 bit_rate; + u32 num_subbands; + u32 block_len; + u32 channel_mode; + u32 allocation_method; + u32 bit_rate; } __attribute__ ((packed)); /* AMR NB encoder modes */ @@ -185,27 +179,27 @@ struct adsp_audio_sbc_encoder_cfg { /* AMR Encoder configuration */ struct adsp_audio_amr_enc_cfg { - u32 mode; /* ADSP_AUDIO_AMR_MR* */ - u32 dtx_mode; /* ADSP_AUDIO_AMR_DTX_MODE* */ - u32 enable; /* 1 = enable, 0 = disable */ + u32 mode; /* ADSP_AUDIO_AMR_MR* */ + u32 dtx_mode; /* ADSP_AUDIO_AMR_DTX_MODE* */ + u32 enable; /* 1 = enable, 0 = disable */ } __attribute__ ((packed)); struct adsp_audio_qcelp13k_enc_cfg { - u16 min_rate; - u16 max_rate; + u16 min_rate; + u16 max_rate; } __attribute__ ((packed)); struct adsp_audio_evrc_enc_cfg { - u16 min_rate; - u16 max_rate; + u16 min_rate; + u16 max_rate; } __attribute__ ((packed)); union adsp_audio_codec_config { - struct adsp_audio_amr_enc_cfg amr; - struct adsp_audio_aac_enc_cfg aac; - struct adsp_audio_qcelp13k_enc_cfg qcelp13k; - struct adsp_audio_evrc_enc_cfg evrc; - struct adsp_audio_sbc_encoder_cfg sbc; + struct adsp_audio_amr_enc_cfg amr; + struct adsp_audio_aac_enc_cfg aac; + struct adsp_audio_qcelp13k_enc_cfg qcelp13k; + struct adsp_audio_evrc_enc_cfg evrc; + struct adsp_audio_sbc_encoder_cfg sbc; } __attribute__ ((packed)); @@ -222,68 +216,61 @@ union adsp_audio_codec_config { /* This bit, if set, indicates that the sync clock is enabled */ #define ADSP_AUDIO_OPEN_STREAM_MODE_ENABLE_SYNC_CLOCK 0x0004 -#if !defined(CONFIG_MACH_HTCLEO) +#if 0 struct adsp_open_command { - struct adsp_command_hdr hdr; + struct adsp_command_hdr hdr; - u32 device; - u32 endpoint; /* address */ + u32 device; + u32 endpoint; /* address */ - u32 stream_context; - u32 mode; + u32 stream_context; + u32 mode; - u32 buf_max_size; + u32 buf_max_size; - union adsp_audio_format format; - union adsp_audio_codec_config config; + union adsp_audio_format format; + union adsp_audio_codec_config config; } __attribute__ ((packed)); - -/* Opcode to open a device stream session to capture audio */ -#define ADSP_AUDIO_IOCTL_CMD_OPEN_READ 0x0108dd79 - -/* Opcode to open a device stream session to render audio */ -#define ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE 0x0108dd7a - -/* Opcode to open a device session, must open a device */ -#define ADSP_AUDIO_IOCTL_CMD_OPEN_DEVICE 0x0108dd7b - -/* Close an existing stream or device */ -#define ADSP_AUDIO_IOCTL_CMD_CLOSE 0x0108d8bc - -#else +#endif struct adsp_open_command { - struct adsp_command_hdr hdr; - - u32 opcode; - u32 numdev; - u32 dev[4]; - u32 stream_context; + struct adsp_command_hdr hdr; + + u32 opcode; + u32 numdev; + u32 dev[4]; + u32 stream_context; - u32 format; - u32 pblock; - u32 blocklen; + u32 format; + u32 pblock; + u32 blocklen; + + u32 buf_max_size; + u32 priority; - u32 buf_max_size; - u32 priority; - - union adsp_audio_codec_config config; - u32 mode; + union adsp_audio_codec_config config; + u32 mode; } __attribute__ ((packed)); /* --- audio control and stream session ioctls ---- */ /* Opcode to open a device stream session to capture audio */ #define ADSP_AUDIO_OPCODE_OPEN_READ 0x01 +//#define ADSP_AUDIO_IOCTL_CMD_OPEN_READ 0x0108dd79 /* Opcode to open a device stream session to render audio */ #define ADSP_AUDIO_OPCODE_OPEN_WRITE 0x02 +//#define ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE 0x0108dd7a /* Opcode to open a device session, must open a device */ #define ADSP_AUDIO_OPCODE_OPEN_DEV 0x04 +//#define ADSP_AUDIO_IOCTL_CMD_OPEN_DEVICE 0x0108dd7b + +/* Close an existing stream or device */ +//#define ADSP_AUDIO_IOCTL_CMD_CLOSE 0x0108d8bc + -#endif /* A device switch requires three IOCTL */ /* commands in the following sequence: PREPARE, STANDBY, COMMIT */ @@ -307,11 +294,11 @@ struct adsp_open_command #define ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_COMMIT 0x01075ee7 struct adsp_device_switch_command { - struct adsp_command_hdr hdr; - u32 old_device; - u32 new_device; - u8 device_class; /* 0 = i.rx, 1 = i.tx, 2 = e.rx, 3 = e.tx */ - u8 device_type; /* 0 = rx, 1 = tx, 2 = both */ + struct adsp_command_hdr hdr; + u32 old_device; + u32 new_device; + u8 device_class; /* 0 = i.rx, 1 = i.tx, 2 = e.rx, 3 = e.tx */ + u8 device_type; /* 0 = rx, 1 = tx, 2 = both */ } __attribute__ ((packed)); @@ -330,10 +317,10 @@ struct adsp_device_switch_command { #define ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_VOL 0x0107605c struct adsp_set_dev_volume_command { - struct adsp_command_hdr hdr; - u32 device_id; - u32 path; /* 0 = rx, 1 = tx, 2 = both */ - s32 volume; + struct adsp_command_hdr hdr; + u32 device_id; + u32 path; /* 0 = rx, 1 = tx, 2 = both */ + s32 volume; } __attribute__ ((packed)); /* Set Device stereo volume. This command has data payload, */ @@ -348,10 +335,10 @@ struct adsp_set_dev_volume_command { #define ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_MUTE 0x0107605f struct adsp_set_dev_mute_command { - struct adsp_command_hdr hdr; - u32 device_id; - u32 path; /* 0 = rx, 1 = tx, 2 = both */ - u32 mute; /* 1 = mute */ + struct adsp_command_hdr hdr; + u32 device_id; + u32 path; /* 0 = rx, 1 = tx, 2 = both */ + u32 mute; /* 1 = mute */ } __attribute__ ((packed)); /* Configure Equalizer for a device. */ @@ -363,24 +350,24 @@ struct adsp_set_dev_mute_command { #define ADSP_AUDIO_IOCTL_SET_DEVICE_CONFIG 0x0108b6cb struct adsp_set_dev_cfg_command { - struct adsp_command_hdr hdr; - u32 device_id; - u32 block_id; - u32 interface_id; - u32 phys_addr; - u32 phys_size; - u32 phys_used; + struct adsp_command_hdr hdr; + u32 device_id; + u32 block_id; + u32 interface_id; + u32 phys_addr; + u32 phys_size; + u32 phys_used; } __attribute__ ((packed)); /* Set configuration data for all interfaces of a device. */ #define ADSP_AUDIO_IOCTL_SET_DEVICE_CONFIG_TABLE 0x0108b6bf struct adsp_set_dev_cfg_table_command { - struct adsp_command_hdr hdr; - u32 device_id; - u32 phys_addr; - u32 phys_size; - u32 phys_used; + struct adsp_command_hdr hdr; + u32 device_id; + u32 phys_addr; + u32 phys_size; + u32 phys_used; } __attribute__ ((packed)); /* ---- audio stream data commands ---- */ @@ -389,8 +376,8 @@ struct adsp_set_dev_cfg_table_command { #define ADSP_AUDIO_IOCTL_CMD_DATA_RX 0x0108dd80 struct adsp_buffer_command { - struct adsp_command_hdr hdr; - struct adsp_audio_buffer buffer; + struct adsp_command_hdr hdr; + struct adsp_audio_buffer buffer; } __attribute__ ((packed)); @@ -487,18 +474,18 @@ struct adsp_buffer_command { /* Definition for any one band of Equalizer. */ struct adsp_audio_eq_band { - u16 band_idx; - u32 filter_type; - u32 center_freq_hz; - s32 filter_gain; - s32 q_factor; + u16 band_idx; + u32 filter_type; + u32 center_freq_hz; + s32 filter_gain; + s32 q_factor; } __attribute__ ((packed)); struct adsp_audio_set_equalizer_command { - struct adsp_command_hdr hdr; - u32 enable; - u32 num_bands; - struct adsp_audio_eq_band eq_bands[ADSP_AUDIO_MAX_EQ_BANDS]; + struct adsp_command_hdr hdr; + u32 enable; + u32 num_bands; + struct adsp_audio_eq_band eq_bands[ADSP_AUDIO_MAX_EQ_BANDS]; } __attribute__ ((packed)); @@ -514,13 +501,13 @@ struct adsp_audio_set_equalizer_command { /* these command structures are used for both STREAM and SESSION ioctls */ struct adsp_set_volume_command { - struct adsp_command_hdr hdr; - s32 volume; + struct adsp_command_hdr hdr; + s32 volume; } __attribute__ ((packed)); struct adsp_set_mute_command { - struct adsp_command_hdr hdr; - u32 mute; /* 1 == mute */ + struct adsp_command_hdr hdr; + u32 mute; /* 1 == mute */ } __attribute__ ((packed)); @@ -558,58 +545,58 @@ struct adsp_set_mute_command { struct adsp_event_hdr { - u32 evt_handle; /* DAL common header */ - u32 evt_cookie; - u32 evt_length; + u32 evt_handle; /* DAL common header */ + u32 evt_cookie; + u32 evt_length; - u32 src; /* "source" audio address */ - u32 dst; /* "destination" audio address */ + u32 src; /* "source" audio address */ + u32 dst; /* "destination" audio address */ - u32 event_id; - u32 response_type; - u32 seq_number; + u32 event_id; + u32 response_type; + u32 seq_number; - u32 context; /* opaque to DSP */ - u32 data; + u32 context; /* opaque to DSP */ + u32 data; - u32 status; + u32 status; } __attribute__ ((packed)); -#if defined(CONFIG_MACH_HTCLEO) + union adsp_event_data { - u32 val32; - uint8_t data[32]; + u32 val32; + uint8_t data[32]; } __attribute__ ((packed)); struct adsp_audio_event { - struct adsp_command_hdr hdr; - u32 session; - u32 event_id; - u32 status; - u32 datalen; - union adsp_event_data data; + struct adsp_command_hdr hdr; + u32 session; + u32 event_id; + u32 status; + u32 datalen; + union adsp_event_data data; } __attribute__ ((packed)); struct adsp_audio_dal_event { - u32 cb_evt; - u32 loc_evt; - u32 size; - struct adsp_audio_event ae; + u32 cb_evt; + u32 loc_evt; + u32 size; + struct adsp_audio_event ae; } __attribute__ ((packed)); -#else +/* struct adsp_buffer_event { - struct adsp_event_hdr hdr; - struct adsp_audio_buffer buffer; + struct adsp_event_hdr hdr; + struct adsp_audio_buffer buffer; } __attribute__ ((packed)); -#endif +*/ /* ---- audio device IDs ---- */ @@ -680,9 +667,9 @@ struct adsp_buffer_event #define ADSP_AUDIO_EQUALIZER_BAND_CUT 6 struct cad_audio_eq_cfg { - u32 enable; - u32 num_bands; - struct adsp_audio_eq_band eq_bands[ADSP_AUDIO_MAX_EQ_BANDS]; + u32 enable; + u32 num_bands; + struct adsp_audio_eq_band eq_bands[ADSP_AUDIO_MAX_EQ_BANDS]; } __attribute__ ((packed)); int q6audio_set_stream_eq(struct audio_client *ac, struct cad_audio_eq_cfg *eq_cfg); diff --git a/arch/arm/mach-msm/qdsp6_1550/q6audio.c b/arch/arm/mach-msm/qdsp6_1550/q6audio.c index e5b75a2c..d9d9fb9b 100644 --- a/arch/arm/mach-msm/qdsp6_1550/q6audio.c +++ b/arch/arm/mach-msm/qdsp6_1550/q6audio.c @@ -60,34 +60,34 @@ #if 1 // LEO -static struct q6_hw_info q6_audio_hw[Q6_HW_COUNT] = +static struct q6_hw_info q6_audio_hw[Q6_HW_COUNT] = { - [Q6_HW_HANDSET] = + [Q6_HW_HANDSET] = { .min_gain = -2000, .max_gain = 0, }, - [Q6_HW_HEADSET] = + [Q6_HW_HEADSET] = { .min_gain = -2000, .max_gain = 0, }, - [Q6_HW_SPEAKER] = + [Q6_HW_SPEAKER] = { .min_gain = -1000, .max_gain = 500, }, - [Q6_HW_TTY] = + [Q6_HW_TTY] = { .min_gain = 0, .max_gain = 0, }, - [Q6_HW_BT_SCO] = + [Q6_HW_BT_SCO] = { .min_gain = -1100, .max_gain = 400, }, - [Q6_HW_BT_A2DP] = + [Q6_HW_BT_A2DP] = { .min_gain = -1100, .max_gain = 400, @@ -97,7 +97,7 @@ static struct q6_hw_info q6_audio_hw[Q6_HW_COUNT] = #else // Old one (from Desire) -static struct q6_hw_info q6_audio_hw[Q6_HW_COUNT] = +static struct q6_hw_info q6_audio_hw[Q6_HW_COUNT] = { [Q6_HW_HANDSET] = { .min_gain = -2000, @@ -493,7 +493,7 @@ static int audio_out_open(struct audio_client *ac, uint32_t bufsz, struct adsp_open_command rpc; union adsp_audio_format *ptr; - printk("audio_out_open: %x %d %d\n", bufsz, rate, channels); + TRACE("audio_out_open: %x %d %d\n", bufsz, rate, channels); mutex_lock(&open_mem_lock); memset(&rpc, 0, sizeof(rpc)); @@ -543,7 +543,7 @@ static int audio_in_open(struct audio_client *ac, uint32_t bufsz, struct adsp_open_command rpc; union adsp_audio_format *ptr; - printk("audio_in_open: %x %d %d\n", bufsz, rate, channels); + TRACE("audio_in_open: %x %d %d\n", bufsz, rate, channels); mutex_lock(&open_mem_lock); memset(&rpc, 0, sizeof(rpc)); ptr = (union adsp_audio_format*)params_data; @@ -587,7 +587,7 @@ static int audio_mp3_open(struct audio_client *ac, uint32_t bufsz, struct adsp_open_command rpc; union adsp_audio_format *ptr; - printk("audio_mp3_open: %x %d %d\n", bufsz, rate, channels); + TRACE("audio_mp3_open: %x %d %d\n", bufsz, rate, channels); mutex_lock(&open_mem_lock); memset(&rpc, 0, sizeof(rpc)); ptr = (union adsp_audio_format*)params_data; @@ -613,7 +613,7 @@ static int audio_mp3_open(struct audio_client *ac, uint32_t bufsz, // wait for async event if (!wait_event_timeout(ac->wait, (ac->open_done == 1), 3 * HZ)) { - mutex_unlock(&open_mem_lock); + mutex_unlock(&open_mem_lock); pr_err("wait for open async event failed (MP3)!\n"); return -1; } @@ -1218,7 +1218,7 @@ static int q6audio_init(void) sdac_clk = clk_get(0, "sdac_clk"); audio_data = dma_alloc_coherent(NULL, 4096, &audio_phys, GFP_KERNEL); params_data = dma_alloc_coherent(NULL, 4096, ¶ms_phys, GFP_KERNEL); -// printk("allocated: %p %x\n", params_data, params_phys); +// printk("allocated: %p %x\n", params_data, params_phys); // pr_info("audio: init: INIT\n"); @@ -1290,7 +1290,7 @@ done: if ((res < 0) && ac) { audio_client_free(ac); - printk(" init failed!\n"); + pr_err(" init failed!\n"); } mutex_unlock(&audio_lock); return res; @@ -1303,7 +1303,7 @@ static int map_cad_dev_to_virtual(int cd) { return cd; } - + switch (cd) { case 1: return 507; @@ -1313,8 +1313,8 @@ static int map_cad_dev_to_virtual(int cd) case 6: return 507; case 7: return 607; case 17: return 408; - default: return cd; - } + default: return cd; + } return 0; } @@ -1350,7 +1350,7 @@ static int acdb_get_config_table(uint32_t device_id, uint32_t sample_rate) r = dal_call(acdb, ACDB_OP_IOCTL, 8, &rpc, sizeof(rpc), &res, sizeof(res)); // r = dal_call_f8(acdb, ACDB_OP_IOCTL, &rpc, sizeof(rpc), &res, sizeof(res)); - pr_info("acdb ret: %d %X %X %X %d\n", res. dal_status, res.size, res.unmapped_buf, res.used_bytes, res.result); + pr_info("acdb ret: %d %X %X %X %d\n", res. dal_status, res.size, res.unmapped_buf, res.used_bytes, res.result); if ((r == sizeof(res)) && (res.result == 0)) { pr_info("acdb: %d bytes for device %d, rate %d.\n", res.used_bytes, device_id, sample_rate); @@ -1518,17 +1518,17 @@ static int audio_update_acdb(uint32_t adev, uint32_t acdb_id) { sz = acdb_get_config_table(acdb_id, sample_rate); } - printk("res1 = %d\n", sz); + TRACE("res1 = %d\n", sz); if (sz <= 0) { acdb_id = q6_device_to_cad_id(adev); printk(" new acdb = %d\n", acdb_id); sz = acdb_get_config_table(acdb_id, sample_rate); } - printk("res2 = %d\n", sz); + TRACE("res2 = %d\n", sz); if (sz > 0) { - printk("call audio_set_table\n"); + TRACE("call audio_set_table\n"); audio_set_table(ac_control, adev, sz); } return 0; @@ -1951,7 +1951,7 @@ int q6audio_set_rx_dev_volume(int level) mutex_lock(&audio_path_lock); vol = q6_device_volume(audio_rx_device_id, level); - printk("$$ DEV=%08X: vol is %d\n", audio_rx_device_id, vol); + TRACE("$$ DEV=%08X: vol is %d\n", audio_rx_device_id, vol); audio_rx_volume(ac_control, audio_rx_device_id, vol); mutex_unlock(&audio_path_lock); @@ -1994,14 +1994,14 @@ static int q6audio_init_rx_volumes() mutex_lock(&audio_path_lock); - printk("$$$ q6audio_init_rx_volumes\n"); + TRACE("$$$ q6audio_init_rx_volumes\n"); while (1) { if (di->id == 0) break; vol = q6_device_volume(di->id, 100); audio_rx_volume(ac_control, di->id, vol); - printk("$$ DEV=%08X: vol is %d\n", di->id, vol); + TRACE("$$ DEV=%08X: vol is %d\n", di->id, vol); di++; } @@ -2149,7 +2149,7 @@ struct audio_client *q6audio_open_pcm(uint32_t bufsz, uint32_t rate, ac = audio_client_alloc(bufsz); if (!ac) { - printk("audio_client_alloc failed\n"); + pr_err("audio_client_alloc failed\n"); return 0; } // printk("after alloc);\n"); @@ -2301,9 +2301,20 @@ struct audio_client *q6voice_open(uint32_t flags, uint32_t acdb_id) if (ac->flags & AUDIO_FLAG_WRITE) { audio_rx_path_enable(1, acdb_id); audio_rx_mute(ac_control, ADSP_AUDIO_DEVICE_ID_VOICE, 0); +// fix for non update acdb at start of call, if other stream is active + audio_update_acdb(audio_rx_device_id, rx_acdb); + qdsp6_devchg_notify(ac_control, ADSP_AUDIO_RX_DEVICE, audio_rx_device_id); + qdsp6_standby(ac_control); + qdsp6_start(ac_control); + } else { tx_clk_freq = 8000; audio_tx_path_enable(1, acdb_id); +// fix for non update acdb at start of call, if other stream is active + audio_update_acdb(audio_tx_device_id, tx_acdb); + qdsp6_devchg_notify(ac_control, ADSP_AUDIO_TX_DEVICE, audio_tx_device_id); + qdsp6_standby(ac_control); + qdsp6_start(ac_control); } return ac; @@ -2327,7 +2338,7 @@ struct audio_client *q6audio_open_mp3(uint32_t bufsz, uint32_t rate, { struct audio_client *ac; - printk("q6audio_open_mp3()\n"); + TRACE("q6audio_open_mp3()\n"); if (q6audio_init()) return 0; @@ -2531,7 +2542,7 @@ static struct audio_client * audio_test(void) sdac_clk = clk_get(0, "sdac_clk"); audio_data = dma_alloc_coherent(NULL, 4096, &audio_phys, GFP_KERNEL); params_data = dma_alloc_coherent(NULL, 4096, ¶ms_phys, GFP_KERNEL); - printk("allocated: %p %08X\n", params_data, params_phys); + TRACE("allocated: %p %08X\n", params_data, params_phys); clk_set_rate(icodec_rx_clk, 12288000); clk_enable(icodec_rx_clk);