All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/7] hfpmodem: Watch for changes in the selected codec
@ 2013-04-10 19:37 Vinicius Costa Gomes
  2013-04-10 19:37 ` [PATCH v2 2/7] include: ofono_handsfree_card_select_codec() Vinicius Costa Gomes
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Vinicius Costa Gomes @ 2013-04-10 19:37 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1875 bytes --]

This patch adds a function to monitor when the AG sends a new codec
before establishing the SCO connection.
---
 plugins/hfp_hf_bluez5.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index c63b1a2..efbb209 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -314,9 +314,60 @@ static struct ofono_modem_driver hfp_driver = {
 	.post_sim	= hfp_post_sim,
 };
 
+static void bcs_notify(GAtResult *result, gpointer user_data)
+{
+	struct hfp *hfp = user_data;
+	struct hfp_slc_info *info = &hfp->info;
+	GAtResultIter iter;
+	char str[32];
+	int value;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+BCS:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &value))
+		return;
+
+	memset(str, 0, sizeof(str));
+
+	switch (value) {
+	case HFP_CODEC_MSBC:
+		if (!ofono_handsfree_audio_has_wideband()) {
+			/* No wideband speech support, so we only have CVSD */
+			sprintf(str, "AT+BAC=%d", HFP_CODEC_CVSD);
+			break;
+		}
+
+		/* fall through */
+
+	case HFP_CODEC_CVSD:
+		/* Confirm the codec */
+		sprintf(str, "AT+BCS=%d", value);
+		break;
+
+	default:
+		/* Unsupported codec, re-send our codecs */
+		if (ofono_handsfree_audio_has_wideband())
+			sprintf(str, "AT+BAC=%d,%d", HFP_CODEC_CVSD,
+							HFP_CODEC_MSBC);
+		else
+			sprintf(str, "AT+BAC=%d", HFP_CODEC_CVSD);
+	}
+
+	g_at_chat_send(info->chat, str, NULL, NULL, NULL, NULL);
+}
+
 static int hfp16_card_probe(struct ofono_handsfree_card *card,
 					unsigned int vendor, void *data)
 {
+	struct hfp *hfp = data;
+	struct hfp_slc_info *info = &hfp->info;
+
+	g_at_chat_register(info->chat, "+BCS:", bcs_notify, FALSE,
+								hfp, NULL);
+
 	return 0;
 }
 
-- 
1.8.2


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

end of thread, other threads:[~2013-04-13 23:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-10 19:37 [PATCH v2 1/7] hfpmodem: Watch for changes in the selected codec Vinicius Costa Gomes
2013-04-10 19:37 ` [PATCH v2 2/7] include: ofono_handsfree_card_select_codec() Vinicius Costa Gomes
2013-04-12 23:12   ` Denis Kenzior
2013-04-13 23:34     ` Vinicius Costa Gomes
2013-04-10 19:37 ` [PATCH v2 3/7] handsfree-audio: Implement ofono_handsfree_card_select_codec() Vinicius Costa Gomes
2013-04-10 19:37 ` [PATCH v2 4/7] hfp_hf_bluez5: Set the audio codec in the card Vinicius Costa Gomes
2013-04-10 19:37 ` [PATCH v2 5/7] handsfree-audio: Send the selected codec Vinicius Costa Gomes
2013-04-10 19:37 ` [PATCH v2 6/7] handsfree-audio: Set CVSD as default in the card Vinicius Costa Gomes
2013-04-12 23:14   ` Denis Kenzior
2013-04-10 19:37 ` [PATCH v2 7/7] handsfree-audio: Enable wideband speech if defer is enabled Vinicius Costa Gomes
2013-04-12 23:16   ` Denis Kenzior
2013-04-12 23:07 ` [PATCH v2 1/7] hfpmodem: Watch for changes in the selected codec Denis Kenzior
2013-04-12 23:20   ` Vinicius Costa Gomes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.