RK SDK版本号:RK312X_ANDROID6.0
说明:硬件上 HP_HOOK 需要连接到 SARADC,HP_HOOK 端 VCC_MICBIAS 需拉高提供电压给 HP_HOOK。HP_DET 接 3128 codec CODEC_HPDET 引脚。
DTS配置:
&codec {
+ codec_hp_det = <1>; //使能耳机检测
+ io-channels = <&adc 2>;//HP_HOOK 连接到SARADC 2
};
codec 驱动:
diff --git a/sound/soc/codecs/rk312x_codec.c b/sound/soc/codecs/rk312x_codec.c
index 1322702..385f126 100755
--- a/sound/soc/codecs/rk312x_codec.c
+++ b/sound/soc/codecs/rk312x_codec.c
@@ -42,7 +42,14 @@
#include <linux/switch.h>
#include "rk312x_codec.h"
-static int debug = -1;
+#include <linux/input.h>
+#include <linux/iio/consumer.h>
+
+static int debug = 1;
+
+bool hp_state = false;
+struct snd_soc_codec *hp_codec;
+
module_param(debug, int, S_IRUGO|S_IWUSR);
#define dbg_codec(level, fmt, arg...) \
@@ -57,8 +64,9 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
#define CODEC_SET_SPK 1
#define CODEC_SET_HP 2
#define SWITCH_SPK 1
-#define BIT_HEADSET (1 << 0)
-#define BIT_HEADSET_NO_MIC (1 << 1)
+#define BIT_NO_HP 0
+#define BIT_HEADSET 1
+#define BIT_HEADSET_NO_MIC 2
#define GRF_ACODEC_CON 0x013c
#define GRF_SOC_STATUS0 0x014c
/* volume setting
@@ -119,6 +127,9 @@ struct rk312x_codec_priv {
struct work_struct work;
struct delayed_work init_delayed_work;
struct delayed_work hpdet_work;
+
+ struct iio_channel *chan;
+ struct d