From: Greg Meiste <w30289@motorola.com>
Date: Wed, 15 Sep 2010 18:55:22 +0000 (-0500)
Subject: [ARM] mfd: cpcap-whisper: Add interface to update audio switch
X-Git-Tag: firefly_0821_release~9834^2~524
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=82bd615a2d37049b1f568db1820630338ef450e6;p=firefly-linux-kernel-4.4.55.git

[ARM] mfd: cpcap-whisper: Add interface to update audio switch

The Motorola HID driver needs an interface to call when an audio cable
is inserted/removed from a Smart Dock.  The interface should update
the audio switch so the audio driver can properly route audio.

Change-Id: Ifad06400c5895f7545f702cdb09be02fe716412a
Signed-off-by: Greg Meiste <w30289@motorola.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
---

diff --git a/drivers/mfd/cpcap-whisper.c b/drivers/mfd/cpcap-whisper.c
index 06cb9a5b828d..0d7dae5e6245 100644
--- a/drivers/mfd/cpcap-whisper.c
+++ b/drivers/mfd/cpcap-whisper.c
@@ -120,6 +120,8 @@ struct cpcap_whisper_data {
 	struct otg_transceiver *otg;
 };
 
+static struct cpcap_whisper_data *whisper_di;
+
 static int whisper_debug;
 module_param(whisper_debug, int, S_IRUGO | S_IWUSR | S_IWGRP);
 
@@ -607,6 +609,21 @@ int cpcap_accy_whisper(struct cpcap_device *cpcap, unsigned int cmd,
 	return retval;
 }
 
+void cpcap_accy_whisper_spdif_set_state(int state)
+{
+	if (!whisper_di)
+		return;
+
+	if (!switch_get_state(&whisper_di->dsdev))
+		return;
+
+	state = ((state > 0) ? 1 : 0);
+	switch_set_state(&whisper_di->asdev, state);
+
+	pr_info("%s: Audio cable %s present\n", __func__,
+		(state ? "is" : "not"));
+}
+
 static int cpcap_whisper_probe(struct platform_device *pdev)
 {
 	int retval;
@@ -683,6 +700,7 @@ static int cpcap_whisper_probe(struct platform_device *pdev)
 #endif
 
 	data->cpcap->accydata = data;
+	whisper_di = data;
 	dev_info(&pdev->dev, "CPCAP Whisper detection probed\n");
 
 	/* Perform initial detection */
diff --git a/include/linux/spi/cpcap.h b/include/linux/spi/cpcap.h
index 4b71450cf0eb..4774dbb3fbae 100644
--- a/include/linux/spi/cpcap.h
+++ b/include/linux/spi/cpcap.h
@@ -782,6 +782,8 @@ unsigned char cpcap_uc_status(struct cpcap_device *cpcap,
 int cpcap_accy_whisper(struct cpcap_device *cpcap, unsigned int cmd,
 		       char *dock_id);
 
+void cpcap_accy_whisper_spdif_set_state(int state);
+
 #define  cpcap_driver_register platform_driver_register
 #define  cpcap_driver_unregister platform_driver_unregister