summaryrefslogtreecommitdiffstats
path: root/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2019-01-03 20:46:54 -0500
committerSolomon Peachy <pizza@shaftnet.org>2019-01-04 23:52:42 +0100
commitd24edc605b9b52d3610efbb9cf691c437ea00746 (patch)
treebd8e6119e4611c6ff83bd316816e0b9534d84deb /firmware/target/mips/ingenic_jz47xx/codec-jz4760.c
parent100f4338deea5239423a0b8974784939d520385c (diff)
downloadrockbox-d24edc605b9b52d3610efbb9cf691c437ea00746.tar.gz
rockbox-d24edc605b9b52d3610efbb9cf691c437ea00746.tar.bz2
rockbox-d24edc605b9b52d3610efbb9cf691c437ea00746.zip
Add HAVE_LINEOUT_DETECTION and associated logic
This allows targets to automatically switch audio settings when the line out is plugged/unplugged. Only hooked up on the xDuoo X3, but there are other potential users. Change-Id: Ic46a329bc955cca2e2ad0335ca16295eab24ad59
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/codec-jz4760.c')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/codec-jz4760.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c b/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c
index 09d4858b34..a2de80a914 100644
--- a/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c
+++ b/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c
@@ -26,6 +26,7 @@
#include "pcm_sw_volume.h"
#include "cs4398.h"
#include "kernel.h"
+#include "button.h"
#define PIN_CS_RST (32*1+10)
#define PIN_CODEC_PWRON (32*1+13)
@@ -140,7 +141,11 @@ static int vol_tenthdb2hw(const int tdb)
}
}
-void audiohw_set_volume(int vol_l, int vol_r)
+#ifdef HAVE_LINEOUT_DETECTION
+static int real_vol_l, real_vol_r;
+#endif
+
+static void jz4760_set_vol(int vol_l, int vol_r)
{
uint8_t val = cs4398_read_reg(CS4398_REG_MISC) &~ CS4398_FREEZE;
cs4398_write_reg(CS4398_REG_MISC, val | CS4398_FREEZE);
@@ -149,14 +154,31 @@ void audiohw_set_volume(int vol_l, int vol_r)
cs4398_write_reg(CS4398_REG_MISC, val);
}
+void audiohw_set_volume(int vol_l, int vol_r)
+{
+#ifdef HAVE_LINEOUT_DETECTION
+ real_vol_l = vol_l;
+ real_vol_r = vol_r;
+
+ if (lineout_inserted()) {
+ vol_l = 0;
+ vol_r = 0;
+ }
+#endif
+ jz4760_set_vol(vol_l, vol_r);
+}
+
void audiohw_set_lineout_volume(int vol_l, int vol_r)
{
-#if 0 /* unused */
- cs4398_write_reg(CS4398_REG_VOL_A, vol_tenthdb2hw(vol_l));
- cs4398_write_reg(CS4398_REG_VOL_B, vol_tenthdb2hw(vol_r));
-#else
(void)vol_l;
(void)vol_r;
+
+#ifdef HAVE_LINEOUT_DETECTION
+ if (lineout_inserted()) {
+ jz4760_set_vol(0, 0);
+ } else {
+ jz4760_set_vol(real_vol_l, real_vol_r);
+ }
#endif
}