mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
ASoC: rockchip: multicodecs: add codec_hp_det feature
This patch supports headphone jack for rockchip multi- codec machine driver. And we need to add CONFIG_SND_SOC_RK3308 macro to ensure compile correct on other SoCs that are without rk3308 codec. Change-Id: I80d2ca5e269aa62865bd6b9f2da9fc7736bce4c9 Signed-off-by: Xing Zheng <zhengxing@rock-chips.com>
This commit is contained in:
@@ -23,19 +23,25 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/jack.h>
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
|
||||
#include "../codecs/rk3308_codec_provider.h"
|
||||
|
||||
#define DRV_NAME "rk-multicodecs"
|
||||
#define MAX_CODECS 2
|
||||
#define DEFAULT_MCLK_FS 256
|
||||
|
||||
struct multicodecs_data {
|
||||
unsigned int mclk_fs;
|
||||
bool codec_hp_det;
|
||||
};
|
||||
|
||||
static struct snd_soc_jack mc_hp_jack;
|
||||
|
||||
static int rk_multicodecs_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
@@ -66,6 +72,23 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rk_dailink_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct multicodecs_data *mc_data = snd_soc_card_get_drvdata(rtd->card);
|
||||
|
||||
if (mc_data->codec_hp_det) {
|
||||
snd_soc_card_jack_new(rtd->card, "Headphones",
|
||||
SND_JACK_HEADPHONE,
|
||||
&mc_hp_jack, NULL, 0);
|
||||
|
||||
#ifdef CONFIG_SND_SOC_RK3308
|
||||
rk3308_codec_set_jack_detect(rtd->codec, &mc_hp_jack);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct snd_soc_ops rk_ops = {
|
||||
.hw_params = rk_multicodecs_hw_params,
|
||||
};
|
||||
@@ -73,6 +96,7 @@ static struct snd_soc_ops rk_ops = {
|
||||
static struct snd_soc_dai_link rk_dailink = {
|
||||
.name = "MULTICODECS",
|
||||
.stream_name = "MULTICODECS",
|
||||
.init = rk_dailink_init,
|
||||
.ops = &rk_ops,
|
||||
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
|
||||
SND_SOC_DAIFMT_CBS_CFS,
|
||||
@@ -154,6 +178,9 @@ static int rk_multicodecs_probe(struct platform_device *pdev)
|
||||
if (!of_property_read_u32(np, "rockchip,mclk-fs", &val))
|
||||
mc_data->mclk_fs = val;
|
||||
|
||||
mc_data->codec_hp_det =
|
||||
of_property_read_bool(np, "rockchip,codec-hp-det");
|
||||
|
||||
snd_soc_card_set_drvdata(card, mc_data);
|
||||
|
||||
ret = devm_snd_soc_register_card(&pdev->dev, card);
|
||||
|
||||
Reference in New Issue
Block a user