RK312x -- 添加312x内置codec三段四段耳机检测

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
阅读终点,创作起航,您可以撰写心得或摘录文章要点写篇博文。去创作
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

linux er

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值