summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorSebastien Guiriec <s-guiriec@ti.com>2010-09-15 15:45:01 +0200
committerSebastien Jan <s-jan@ti.com>2010-09-28 14:58:16 +0200
commit243da62082e13bdd6df195a01442e0c8d4c9e3a1 (patch)
treeca8a0b9b47c4e5fe098f7e7a99b5342ec4d45d66 /sound
parentcd5d0fdf05f1b60e895464aa58c3b9f2b237e804 (diff)
ASoC: ABE HAL - Update gain control to implement mute/unmute on HAL 08.00
Add API to manage umute/unmute of ABE gain on top of ABE HAL 00.08.00 This feature is needed in order to set and restore the good gain inside new multicomponent driver. It should be inside next ABE HAL release. Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com> Signed-off-by: Margarita Olaya Cabrera <magi.olaya@ti.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/omap/abe/abe_api.c139
-rw-r--r--sound/soc/omap/abe/abe_api.h5
2 files changed, 140 insertions, 4 deletions
diff --git a/sound/soc/omap/abe/abe_api.c b/sound/soc/omap/abe/abe_api.c
index c76b6d3c1e9d..412c0d8df394 100644
--- a/sound/soc/omap/abe/abe_api.c
+++ b/sound/soc/omap/abe/abe_api.c
@@ -24,6 +24,26 @@
#include "abe_initxxx_labels.h"
#include "abe_dbg.h"
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/workqueue.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/pm_runtime.h>
+
+struct abe_gain {
+ u32 gain;
+ int mute;
+};
+struct abe_gain *abe_gain_table;
+
/**
* abe_reset_hal - reset the ABE/HAL
* @rdev: regulator source
@@ -48,6 +68,8 @@ abehal_status abe_reset_hal(void)
abe_dbg_mask = (abe_dbg_t) (0);
#endif
abe_hw_configuration();
+ abe_gain_table = kzalloc(sizeof(struct abe_gain)*34, GFP_KERNEL);
+
return 0;
}
@@ -1455,11 +1477,107 @@ abehal_status abe_write_aps(u32 id, abe_aps_t * param)
_log(id_write_aps, id, 0, 0)
return 0;
}
-
EXPORT_SYMBOL(abe_write_aps);
+int abe_get_gain_index(u32 id, u32 p)
+{
+ int index;
+
+ switch (id) {
+ default:
+ case GAINS_DMIC1:
+ index = 0;
+ break;
+ case GAINS_DMIC2:
+ index = 2;
+ break;
+ case GAINS_DMIC3:
+ index = 4;
+ break;
+ case GAINS_AMIC:
+ index = 6;
+ break;
+ case GAINS_DL1:
+ index = 8;
+ break;
+ case GAINS_DL2:
+ index = 10;
+ break;
+ case GAINS_SPLIT:
+ index = 12;
+ break;
+ case MIXDL1:
+ index = 14;
+ break;
+ case MIXDL2:
+ index = 18;
+ break;
+ case MIXECHO:
+ index = 22;
+ break;
+ case MIXSDT:
+ index = 24;
+ break;
+ case MIXVXREC:
+ index = 26;
+ break;
+ case MIXAUDUL:
+ index = 30;
+ break;
+ }
+ index += p;
+
+ return(index);
+
+}
+
/**
- * abe_write_mixer
+ * abe_mute_gain
+ * @id: name of the mixer
+ * @p: port corresponding to the above gains
+ *
+ * Mute ABE gain
+ */
+abehal_status abe_mute_gain(u32 id, u32 p)
+{
+ int index;
+
+ index = abe_get_gain_index(id, p);
+
+ if (abe_gain_table[index].mute == 0) {
+ abe_gain_table[index].mute = 1;
+ abe_read_gain(id, &abe_gain_table[index].gain, p);
+ abe_update_gain(id, MUTE_GAIN, RAMP_5MS, p);
+ } else
+ abe_gain_table[index].mute = 1;
+ return 0;
+
+}
+EXPORT_SYMBOL(abe_mute_gain);
+
+
+/**
+ * abe_unmute_gain
+ * @id: name of the mixer
+ * @p: port corresponding to the above gains
+ *
+ * UnMute ABE gain
+ */
+abehal_status abe_unmute_gain(u32 id, u32 p)
+{
+ int index;
+
+ index = abe_get_gain_index(id, p);
+
+ abe_gain_table[index].mute = 0;
+ abe_update_gain(id, abe_gain_table[index].gain, RAMP_5MS, p);
+
+ return 0;
+}
+EXPORT_SYMBOL(abe_unmute_gain);
+
+/**
+ * abe_update_gain
* @id: name of the mixer
* @param: list of input gains of the mixer
* @p: list of port corresponding to the above gains
@@ -1470,7 +1588,7 @@ EXPORT_SYMBOL(abe_write_aps);
* in mute state". A mixer is disabled with a network reconfiguration
* corresponding to an OPP value.
*/
-abehal_status abe_write_gain(u32 id, u32 f_g, u32 ramp, u32 p)
+abehal_status abe_update_gain(u32 id, u32 f_g, u32 ramp, u32 p)
{
u32 lin_g, mixer_target, mixer_offset;
s32 gain_index;
@@ -1582,7 +1700,22 @@ abehal_status abe_write_gain(u32 id, u32 f_g, u32 ramp, u32 p)
return 0;
}
+EXPORT_SYMBOL(abe_update_gain);
+abehal_status abe_write_gain (u32 id, u32 f_g, u32 ramp, u32 p)
+{
+ int index;
+
+ index = abe_get_gain_index(id, p);
+
+ if (abe_gain_table[index].mute == 0) {
+ abe_gain_table[index].gain = f_g;
+ abe_update_gain(id, f_g,ramp, p);
+ } else
+ abe_gain_table[index].gain = f_g;
+
+ return 0;
+}
EXPORT_SYMBOL(abe_write_gain);
/**
diff --git a/sound/soc/omap/abe/abe_api.h b/sound/soc/omap/abe/abe_api.h
index 5f7bbe71c532..eaa4d2481cb7 100644
--- a/sound/soc/omap/abe/abe_api.h
+++ b/sound/soc/omap/abe/abe_api.h
@@ -392,7 +392,10 @@ abehal_status abe_write_aps (u32 id, abe_aps_t *param);
* in mute state". A mixer is disabled with a network reconfiguration
* corresponding to an OPP value.
*/
-abehal_status abe_write_gain (u32 id, u32 f_g, u32 ramp, u32 p);
+abehal_status abe_mute_gain(u32 id, u32 p);
+abehal_status abe_unmute_gain(u32 id, u32 p);
+abehal_status abe_update_gain(u32 id, u32 f_g, u32 ramp, u32 p);
+abehal_status abe_write_gain(u32 id, u32 f_g, u32 ramp, u32 p);
/**
* abe_write_mixer