#include <linux/spi/cpcap-regbits.h>
#include <linux/spi/spi.h>
+void tegra_cpcap_audio_dock_state(bool connected);
#define SENSE_USB_CLIENT (CPCAP_BIT_ID_FLOAT_S | \
CPCAP_BIT_VBUSVLD_S | \
switch_set_state(&di->csdev, 0);
memset(di->dock_id, 0, CPCAP_WHISPER_ID_SIZE);
memset(di->dock_prop, 0, CPCAP_WHISPER_PROP_SIZE);
+ tegra_cpcap_audio_dock_state(false);
}
}
audio = (req.result[CPCAP_ADC_USB_ID] > ADC_AUDIO_THRES) ? 1 : 0;
switch_set_state(&di->asdev, audio);
+ tegra_cpcap_audio_dock_state(!!audio);
pr_info("%s: Audio cable %s present\n", __func__,
(audio ? "is" : "not"));
};
static int codec_rate;
static int stdac_rate;
+static bool dock_connected;
static int cpcap_audio_ctl_open(struct inode *inode, struct file *file)
{
.fops = &cpcap_audio_ctl_fops,
};
+/* Couple the CPCAP and Dock audio state, to avoid pops */
+void tegra_cpcap_audio_dock_state(bool connected)
+{
+ pr_debug("%s: %s", __func__, connected ? "connected" : "disconnected");
+
+ mutex_lock(&cpcap_lock);
+ dock_connected = connected;
+ /* Borrow (unused) "ext output" to keep dock speaker amplifier on. */
+ pdata->state->ext_primary_speaker = dock_connected ?
+ CPCAP_AUDIO_OUT_EMU_STEREO : CPCAP_AUDIO_OUT_NONE;
+ cpcap_audio_set_audio_state(pdata->state);
+ mutex_unlock(&cpcap_lock);
+}
+EXPORT_SYMBOL(tegra_cpcap_audio_dock_state);
+
static int cpcap_audio_probe(struct platform_device *pdev)
{
int rc;