linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] msm: audio: qdsp6v2: simplify linked lists
@ 2011-02-15 12:08 eero.nurkkala
  2011-02-15 12:08 ` [PATCH 2/4] msm: audio: qdsp6v2: remove unused mixer_post_event() eero.nurkkala
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: eero.nurkkala @ 2011-02-15 12:08 UTC (permalink / raw)
  To: linux-arm-msm; +Cc: Eero Nurkkala

From: Eero Nurkkala <eero.nurkkala@offcode.fi>

There's no point in introducing linked lists as they're
already provided by the kernel. Remove the proprietary
linked lists which may actually introduce risks.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
---
branch: android-msm-2.6.35
 .../mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h  |    5 +-
 arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c          |  110 +++++---------------
 2 files changed, 27 insertions(+), 88 deletions(-)

diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
index a72d21a..53a641b 100644
--- a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
+++ b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
@@ -193,12 +193,11 @@ struct msm_snd_evt_listner {
 	void (*auddev_evt_listener)(u32 evt_id,
 		union auddev_evt_data *evt_payload,
 		void *private_data);
-	struct msm_snd_evt_listner *cb_next;
-	struct msm_snd_evt_listner *cb_prev;
+	struct list_head list;
 };
 
 struct event_listner {
-	struct msm_snd_evt_listner *cb;
+	struct list_head list;
 	u32 num_listner;
 	int state; /* Call state */ /* TODO remove this if not req*/
 };
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
index 38cf132..8ac8c63 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
@@ -664,7 +664,6 @@ int auddev_register_evt_listner(u32 evt_id, u32 clnt_type, u32 clnt_id,
 		void *private_data)
 {
 	int rc;
-	struct msm_snd_evt_listner *callback = NULL;
 	struct msm_snd_evt_listner *new_cb;
 
 	new_cb = kzalloc(sizeof(struct msm_snd_evt_listner), GFP_KERNEL);
@@ -674,28 +673,12 @@ int auddev_register_evt_listner(u32 evt_id, u32 clnt_type, u32 clnt_id,
 	}
 
 	mutex_lock(&session_lock);
-	new_cb->cb_next = NULL;
 	new_cb->auddev_evt_listener = listner;
 	new_cb->evt_id = evt_id;
 	new_cb->clnt_type = clnt_type;
 	new_cb->clnt_id = clnt_id;
 	new_cb->private_data = private_data;
-	if (event.cb == NULL) {
-		event.cb = new_cb;
-		new_cb->cb_prev = NULL;
-	} else {
-		callback = event.cb;
-		for (; ;) {
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-		callback->cb_next = new_cb;
-		new_cb->cb_prev = callback;
-	}
+	list_add_tail(&new_cb->list, &event.list);
 	event.num_listner++;
 	mutex_unlock(&session_lock);
 	rc = 0;
@@ -705,34 +688,23 @@ EXPORT_SYMBOL(auddev_register_evt_listner);
 
 int auddev_unregister_evt_listner(u32 clnt_type, u32 clnt_id)
 {
-	struct msm_snd_evt_listner *callback = event.cb;
+	struct msm_snd_evt_listner *callback;
 	struct msm_snddev_info *info;
 	u64 session_mask = 0;
 	int i = 0;
 
 	mutex_lock(&session_lock);
-	while (callback != NULL) {
-		if ((callback->clnt_type == clnt_type)
-			&& (callback->clnt_id == clnt_id))
-			break;
-		 callback = callback->cb_next;
-	}
-	if (callback == NULL) {
-		mutex_unlock(&session_lock);
-		return -EINVAL;
-	}
 
-	if ((callback->cb_next == NULL) && (callback->cb_prev == NULL))
-		event.cb = NULL;
-	else if (callback->cb_next == NULL)
-		callback->cb_prev->cb_next = NULL;
-	else if (callback->cb_prev == NULL) {
-		callback->cb_next->cb_prev = NULL;
-		event.cb = callback->cb_next;
-	} else {
-		callback->cb_prev->cb_next = callback->cb_next;
-		callback->cb_next->cb_prev = callback->cb_prev;
+	list_for_each_entry(callback, &event.list, list) {
+		if ((callback->clnt_type == clnt_type) &&
+			(callback->clnt_id == clnt_id))
+			goto found_listner;
 	}
+	mutex_unlock(&session_lock);
+	return -EINVAL;
+
+found_listner:
+	list_del(&callback->list);
 	kfree(callback);
 
 	session_mask = (((u64)0x1) << clnt_id) << (MAX_BIT_PER_CLIENT * \
@@ -1046,10 +1018,9 @@ void broadcast_event(u32 evt_id, u32 dev_id, u64 session_id)
 		&& (evt_id != AUDDEV_EVT_VOICE_STATE_CHG))
 		dev_info = audio_dev_ctrl_find_dev(dev_id);
 
-	if (event.cb != NULL)
-		callback = event.cb;
-	else
+	if (list_empty(&event.list))
 		return;
+
 	mutex_lock(&session_lock);
 
 	if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
@@ -1058,15 +1029,10 @@ void broadcast_event(u32 evt_id, u32 dev_id, u64 session_id)
 	evt_payload = kzalloc(sizeof(union auddev_evt_data),
 			GFP_KERNEL);
 
-	for (; ;) {
-		if (!(evt_id & callback->evt_id)) {
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
+	list_for_each_entry(callback, &event.list, list) {
+		if (!(evt_id & callback->evt_id))
+			continue;
+
 		clnt_id = callback->clnt_id;
 		memset(evt_payload, 0, sizeof(union auddev_evt_data));
 
@@ -1091,14 +1057,9 @@ void broadcast_event(u32 evt_id, u32 dev_id, u64 session_id)
 
 		if ((!session_id && !(dev_info->sessions & session_mask)) ||
 			(session_id && ((dev_info->sessions & session_mask) !=
-						session_id))) {
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
+						session_id)))
+			continue;
+
 		if (evt_id == AUDDEV_EVT_DEV_CHG_VOICE)
 			goto voc_events;
 
@@ -1143,13 +1104,7 @@ sent_dec:
 				(evt_id != AUDDEV_EVT_VOICE_STATE_CHG))
 				routing_info.dec_freq[clnt_id].freq
 						= dev_info->set_sample_rate;
-
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
+			continue;
 		}
 		if (callback->clnt_type == AUDDEV_CLNT_ENC) {
 			pr_debug("AUDDEV_CLNT_ENC\n");
@@ -1176,12 +1131,7 @@ sent_dec:
 					evt_payload,
 					callback->private_data);
 sent_enc:
-			if (callback->cb_next == NULL)
-					break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
+			continue;
 		}
 aud_cal:
 		if (callback->clnt_type == AUDDEV_CLNT_AUDIOCAL) {
@@ -1210,12 +1160,7 @@ aud_cal:
 				callback->private_data);
 
 sent_aud_cal:
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
+			continue;
 		}
 skip_check:
 voc_events:
@@ -1300,12 +1245,7 @@ voc_events:
 			if (evt_id == AUDDEV_EVT_DEV_RLS)
 				dev_info->sessions &= ~(0xFFFF);
 sent_voc:
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
+			continue;
 		}
 	}
 	kfree(evt_payload);
@@ -1360,7 +1300,7 @@ static int __init audio_dev_ctrl_init(void)
 {
 	init_waitqueue_head(&audio_dev_ctrl.wait);
 
-	event.cb = NULL;
+	INIT_LIST_HEAD(&event.list);
 
 	atomic_set(&audio_dev_ctrl.opened, 0);
 	audio_dev_ctrl.num_dev = 0;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] msm: audio: qdsp6v2: remove unused mixer_post_event()
  2011-02-15 12:08 [PATCH 1/4] msm: audio: qdsp6v2: simplify linked lists eero.nurkkala
@ 2011-02-15 12:08 ` eero.nurkkala
  2011-02-15 12:08 ` [PATCH 3/4] msm: audio: qdsp6v2: fix potential memory corruption eero.nurkkala
  2011-02-15 12:08 ` [PATCH/RFC 4/4] msm: audio: qdsp6v2: simplify broadcast_event() eero.nurkkala
  2 siblings, 0 replies; 5+ messages in thread
From: eero.nurkkala @ 2011-02-15 12:08 UTC (permalink / raw)
  To: linux-arm-msm; +Cc: Eero Nurkkala

From: Eero Nurkkala <eero.nurkkala@offcode.fi>

Remove unused mixer_post_event() which is not referenced
anywhere.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
---
branch: android-msm-2.6.35
 .../mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h  |    1 -
 arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c          |   43 --------------------
 2 files changed, 0 insertions(+), 44 deletions(-)

diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
index 53a641b..39039a1 100644
--- a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
+++ b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
@@ -209,7 +209,6 @@ int auddev_register_evt_listner(u32 evt_id, u32 clnt_type, u32 clnt_id,
 			void *private_data),
 		void *private_data);
 int auddev_unregister_evt_listner(u32 clnt_type, u32 clnt_id);
-void mixer_post_event(u32 evt_id, u32 dev_id);
 void broadcast_event(u32 evt_id, u32 dev_id, u64 session_id);
 int auddev_cfg_tx_copp_topology(int session_id, int cfg);
 int msm_snddev_request_freq(int *freq, u32 session_id,
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
index 8ac8c63..2d848d5 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
@@ -1253,49 +1253,6 @@ sent_voc:
 }
 EXPORT_SYMBOL(broadcast_event);
 
-
-void mixer_post_event(u32 evt_id, u32 id)
-{
-
-	pr_debug("evt_id = %d\n", evt_id);
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_CHG_VOICE: /* Called from Voice_route */
-		broadcast_event(AUDDEV_EVT_DEV_CHG_VOICE, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_DEV_RDY:
-		broadcast_event(AUDDEV_EVT_DEV_RDY, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		broadcast_event(AUDDEV_EVT_DEV_RLS, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_REL_PENDING:
-		broadcast_event(AUDDEV_EVT_REL_PENDING, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_DEVICE_VOL_MUTE_CHG:
-		broadcast_event(AUDDEV_EVT_DEVICE_VOL_MUTE_CHG, id,
-							SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		broadcast_event(AUDDEV_EVT_STREAM_VOL_CHG, id,
-							SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_START_VOICE:
-		broadcast_event(AUDDEV_EVT_START_VOICE,
-				id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_END_VOICE:
-		broadcast_event(AUDDEV_EVT_END_VOICE,
-				id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_FREQ_CHG:
-		broadcast_event(AUDDEV_EVT_FREQ_CHG, id, SESSION_IGNORE);
-		break;
-	default:
-		break;
-	}
-}
-EXPORT_SYMBOL(mixer_post_event);
-
 static int __init audio_dev_ctrl_init(void)
 {
 	init_waitqueue_head(&audio_dev_ctrl.wait);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] msm: audio: qdsp6v2: fix potential memory corruption
  2011-02-15 12:08 [PATCH 1/4] msm: audio: qdsp6v2: simplify linked lists eero.nurkkala
  2011-02-15 12:08 ` [PATCH 2/4] msm: audio: qdsp6v2: remove unused mixer_post_event() eero.nurkkala
@ 2011-02-15 12:08 ` eero.nurkkala
  2011-02-15 12:08 ` [PATCH/RFC 4/4] msm: audio: qdsp6v2: simplify broadcast_event() eero.nurkkala
  2 siblings, 0 replies; 5+ messages in thread
From: eero.nurkkala @ 2011-02-15 12:08 UTC (permalink / raw)
  To: linux-arm-msm; +Cc: Eero Nurkkala

From: Eero Nurkkala <eero.nurkkala@offcode.fi>

kzalloc() may fail, which can result in memory corruption later
in the code.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
---
branch: android-msm-2.6.35
 arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
index 2d848d5..b414f3e 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
@@ -1028,6 +1028,11 @@ void broadcast_event(u32 evt_id, u32 dev_id, u64 session_id)
 
 	evt_payload = kzalloc(sizeof(union auddev_evt_data),
 			GFP_KERNEL);
+	if (!evt_payload) {
+		pr_err("%s:Out of memory\n", __func__);
+		mutex_unlock(&session_lock);
+		return;
+	}
 
 	list_for_each_entry(callback, &event.list, list) {
 		if (!(evt_id & callback->evt_id))
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH/RFC 4/4] msm: audio: qdsp6v2: simplify broadcast_event()
  2011-02-15 12:08 [PATCH 1/4] msm: audio: qdsp6v2: simplify linked lists eero.nurkkala
  2011-02-15 12:08 ` [PATCH 2/4] msm: audio: qdsp6v2: remove unused mixer_post_event() eero.nurkkala
  2011-02-15 12:08 ` [PATCH 3/4] msm: audio: qdsp6v2: fix potential memory corruption eero.nurkkala
@ 2011-02-15 12:08 ` eero.nurkkala
  2011-02-16 23:58   ` Patrick Lai
  2 siblings, 1 reply; 5+ messages in thread
From: eero.nurkkala @ 2011-02-15 12:08 UTC (permalink / raw)
  To: linux-arm-msm; +Cc: Eero Nurkkala

From: Eero Nurkkala <eero.nurkkala@offcode.fi>

Instead of having a large broadcast_event() - function, split
it with a sub function msm_fill_evt_payload() that fills the
structures. This makes the broadcast_event() more readable.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
---
branch: android-msm-2.6.35
 .../mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h  |    2 +
 arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c          |  149 +++++++++++---------
 2 files changed, 82 insertions(+), 69 deletions(-)

diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
index 39039a1..4ef22d6 100644
--- a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
+++ b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h
@@ -179,6 +179,8 @@ struct message_header {
 #define AUDDEV_EVT_VOICE_STATE_CHG 0x200 /* Change in voice state */
 
 #define AUDDEV_CLNT_VOC 0x1 /*Vocoder clients*/
+#define AUDDEV_CLNT_VOC_S1 0x11 /* subtypes for msm_fill_evt_payload() */
+#define AUDDEV_CLNT_VOC_S2 0x12
 #define AUDDEV_CLNT_DEC 0x2 /*Decoder clients*/
 #define AUDDEV_CLNT_ENC 0x3 /* Encoder clients */
 #define AUDDEV_CLNT_AUDIOCAL 0x4 /* AudioCalibration client */
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
index b414f3e..6b81197 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
@@ -995,6 +995,71 @@ struct miscdevice audio_dev_ctrl_misc = {
 	.fops	= &audio_dev_ctrl_fops,
 };
 
+static void msm_fill_evt_payload(struct msm_snddev_info *dev_info,
+				union auddev_evt_data *evt_payload,
+				uint32_t clnt_type)
+{
+	int i;
+
+	switch (clnt_type) {
+	case AUDDEV_CLNT_VOC:
+		evt_payload->voc_vm_info.acdb_dev_id =
+					dev_info->acdb_id;
+		if (dev_info->capability & SNDDEV_CAP_TX) {
+			evt_payload->voc_vm_info.dev_type = SNDDEV_CAP_TX;
+			evt_payload->voc_vm_info.dev_vm_val.mute =
+					routing_info.tx_mute;
+		} else {
+			evt_payload->voc_vm_info.dev_type = SNDDEV_CAP_RX;
+			evt_payload->voc_vm_info.dev_vm_val.vol =
+					routing_info.voice_rx_vol;
+		}
+		break;
+
+	case AUDDEV_CLNT_VOC_S2:
+		evt_payload->voc_devinfo.dev_type = (dev_info->capability &
+				SNDDEV_CAP_TX) ? SNDDEV_CAP_TX : SNDDEV_CAP_RX;
+		evt_payload->voc_devinfo.acdb_dev_id = dev_info->acdb_id;
+		evt_payload->voc_devinfo.dev_port_id = dev_info->copp_id;
+		evt_payload->voc_devinfo.dev_sample =
+					dev_info->set_sample_rate ?
+					dev_info->set_sample_rate :
+					dev_info->sample_rate;
+		if (dev_info->capability & SNDDEV_CAP_RX) {
+			for (i = 0; i < VOC_RX_VOL_ARRAY_NUM; i++) {
+				evt_payload->voc_devinfo.max_rx_vol[i] =
+						dev_info->max_voc_rx_vol[i];
+				evt_payload->voc_devinfo.min_rx_vol[i] =
+						dev_info->min_voc_rx_vol[i];
+			}
+		}
+		break;
+
+	case AUDDEV_CLNT_VOC_S1:
+	case AUDDEV_CLNT_DEC:
+	case AUDDEV_CLNT_ENC:
+		evt_payload->freq_info.sample_rate = dev_info->set_sample_rate;
+		evt_payload->freq_info.dev_type	= dev_info->capability;
+		evt_payload->freq_info.acdb_dev_id = dev_info->acdb_id;
+		break;
+
+	case AUDDEV_CLNT_AUDIOCAL:
+		evt_payload->audcal_info.dev_id = dev_info->copp_id;
+		evt_payload->audcal_info.acdb_id = dev_info->acdb_id;
+		evt_payload->audcal_info.dev_type = (dev_info->capability &
+				SNDDEV_CAP_TX) ? SNDDEV_CAP_TX : SNDDEV_CAP_RX;
+		evt_payload->audcal_info.sample_rate =
+					dev_info->set_sample_rate ?
+					dev_info->set_sample_rate :
+					dev_info->sample_rate;
+		break;
+
+	default:
+		pr_err("%s: Unknown case.\n", __func__);
+		break;
+	}
+}
+
 /* session id is 64 bit routing mask per device
  * 0-15 for voice clients
  * 16-31 for Decoder clients
@@ -1003,7 +1068,7 @@ struct miscdevice audio_dev_ctrl_misc = {
  */
 void broadcast_event(u32 evt_id, u32 dev_id, u64 session_id)
 {
-	int clnt_id = 0, i;
+	int clnt_id = 0;
 	union auddev_evt_data *evt_payload;
 	struct msm_snd_evt_listner *callback;
 	struct msm_snddev_info *dev_info = NULL;
@@ -1088,12 +1153,8 @@ volume_strm:
 					== dev_info->set_sample_rate)
 					goto sent_dec;
 				else {
-					evt_payload->freq_info.sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.dev_type
-						= dev_info->capability;
-					evt_payload->freq_info.acdb_dev_id
-						= dev_info->acdb_id;
+					msm_fill_evt_payload(dev_info,
+						evt_payload, AUDDEV_CLNT_DEC);
 				}
 			} else if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
 				evt_payload->voice_state =
@@ -1119,12 +1180,8 @@ sent_dec:
 							= 0;
 					goto sent_enc;
 				 } else {
-					evt_payload->freq_info.sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.dev_type
-						= dev_info->capability;
-					evt_payload->freq_info.acdb_dev_id
-						= dev_info->acdb_id;
+					msm_fill_evt_payload(dev_info,
+						evt_payload, AUDDEV_CLNT_ENC);
 				}
 			} else if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
 				evt_payload->voice_state =
@@ -1147,17 +1204,9 @@ aud_cal:
 			else if (!dev_info->sessions)
 				goto sent_aud_cal;
 			else {
-				evt_payload->audcal_info.dev_id =
-						dev_info->copp_id;
-				evt_payload->audcal_info.acdb_id =
-						dev_info->acdb_id;
-				evt_payload->audcal_info.dev_type =
-					(dev_info->capability & SNDDEV_CAP_TX) ?
-					SNDDEV_CAP_TX : SNDDEV_CAP_RX;
-				evt_payload->audcal_info.sample_rate =
-					dev_info->set_sample_rate ?
-					dev_info->set_sample_rate :
-					dev_info->sample_rate;
+				msm_fill_evt_payload(dev_info,
+						evt_payload,
+						AUDDEV_CLNT_AUDIOCAL);
 			}
 			callback->auddev_evt_listener(
 				evt_id,
@@ -1181,23 +1230,8 @@ voc_events:
 				pending_sent = 1;
 
 			if (evt_id == AUDDEV_EVT_DEVICE_VOL_MUTE_CHG) {
-				if (dev_info->capability & SNDDEV_CAP_TX) {
-					evt_payload->voc_vm_info.dev_type =
-						SNDDEV_CAP_TX;
-					evt_payload->voc_vm_info.acdb_dev_id =
-						dev_info->acdb_id;
-					evt_payload->
-					voc_vm_info.dev_vm_val.mute =
-						routing_info.tx_mute;
-				} else {
-					evt_payload->voc_vm_info.dev_type =
-						SNDDEV_CAP_RX;
-					evt_payload->voc_vm_info.acdb_dev_id =
-						dev_info->acdb_id;
-					evt_payload->
-					voc_vm_info.dev_vm_val.vol =
-						routing_info.voice_rx_vol;
-				}
+					msm_fill_evt_payload(dev_info,
+						evt_payload, AUDDEV_CLNT_VOC);
 			} else if ((evt_id == AUDDEV_EVT_START_VOICE)
 					|| (evt_id == AUDDEV_EVT_END_VOICE))
 				memset(evt_payload, 0,
@@ -1207,41 +1241,18 @@ voc_events:
 						!= dev_info->set_sample_rate) {
 					routing_info.voice_tx_sample_rate
 						= dev_info->set_sample_rate;
-					evt_payload->freq_info.sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.dev_type
-						= dev_info->capability;
-					evt_payload->freq_info.acdb_dev_id
-						= dev_info->acdb_id;
+					msm_fill_evt_payload(dev_info,
+						evt_payload,
+						AUDDEV_CLNT_VOC_S1);
 				} else
 					goto sent_voc;
 			} else if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
 				evt_payload->voice_state =
 						routing_info.voice_state;
 			else {
-				evt_payload->voc_devinfo.dev_type =
-					(dev_info->capability & SNDDEV_CAP_TX) ?
-					SNDDEV_CAP_TX : SNDDEV_CAP_RX;
-				evt_payload->voc_devinfo.acdb_dev_id =
-					dev_info->acdb_id;
-				evt_payload->voc_devinfo.dev_port_id =
-					dev_info->copp_id;
-				evt_payload->voc_devinfo.dev_sample =
-					dev_info->set_sample_rate ?
-					dev_info->set_sample_rate :
-					dev_info->sample_rate;
+				msm_fill_evt_payload(dev_info, evt_payload,
+						AUDDEV_CLNT_VOC_S2);
 				evt_payload->voc_devinfo.dev_id = dev_id;
-				if (dev_info->capability & SNDDEV_CAP_RX) {
-					for (i = 0; i < VOC_RX_VOL_ARRAY_NUM;
-						i++) {
-						evt_payload->
-						voc_devinfo.max_rx_vol[i] =
-						dev_info->max_voc_rx_vol[i];
-						evt_payload
-						->voc_devinfo.min_rx_vol[i] =
-						dev_info->min_voc_rx_vol[i];
-					}
-				}
 			}
 			callback->auddev_evt_listener(
 				evt_id,
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH/RFC 4/4] msm: audio: qdsp6v2: simplify broadcast_event()
  2011-02-15 12:08 ` [PATCH/RFC 4/4] msm: audio: qdsp6v2: simplify broadcast_event() eero.nurkkala
@ 2011-02-16 23:58   ` Patrick Lai
  0 siblings, 0 replies; 5+ messages in thread
From: Patrick Lai @ 2011-02-16 23:58 UTC (permalink / raw)
  To: eero.nurkkala; +Cc: linux-arm-msm

On 2/15/2011 4:08 AM, eero.nurkkala@offcode.fi wrote:
> From: Eero Nurkkala<eero.nurkkala@offcode.fi>
>
> Instead of having a large broadcast_event() - function, split
> it with a sub function msm_fill_evt_payload() that fills the
> structures. This makes the broadcast_event() more readable.
>
> Signed-off-by: Eero Nurkkala<eero.nurkkala@offcode.fi>

Thanks for the patches. We will pull in all four patches and test them out.

Patrick

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-02-16 23:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-15 12:08 [PATCH 1/4] msm: audio: qdsp6v2: simplify linked lists eero.nurkkala
2011-02-15 12:08 ` [PATCH 2/4] msm: audio: qdsp6v2: remove unused mixer_post_event() eero.nurkkala
2011-02-15 12:08 ` [PATCH 3/4] msm: audio: qdsp6v2: fix potential memory corruption eero.nurkkala
2011-02-15 12:08 ` [PATCH/RFC 4/4] msm: audio: qdsp6v2: simplify broadcast_event() eero.nurkkala
2011-02-16 23:58   ` Patrick Lai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).