| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* mt8189-nau8825.c -- mt8189 nau8825 ALSA SoC machine driver |
| 4 |
* |
| 5 |
* Copyright (c) 2025 MediaTek Inc. |
| 6 |
* Author: Darren Ye <[email protected]> |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <linux/input.h> |
| 10 |
#include <linux/module.h> |
| 11 |
#include <linux/of_device.h> |
| 12 |
#include <linux/pm_runtime.h> |
| 13 |
|
| 14 |
#include <sound/soc.h> |
| 15 |
#include <sound/jack.h> |
| 16 |
#include <sound/pcm_params.h> |
| 17 |
|
| 18 |
#include "mt8189-afe-common.h" |
| 19 |
|
| 20 |
#include "../common/mtk-soc-card.h" |
| 21 |
#include "../common/mtk-soundcard-driver.h" |
| 22 |
#include "../common/mtk-afe-platform-driver.h" |
| 23 |
|
| 24 |
#include "../../codecs/cs35l41.h" |
| 25 |
#include "../../codecs/nau8825.h" |
| 26 |
#include "../../codecs/rt5682s.h" |
| 27 |
#include "../../codecs/rt5682.h" |
| 28 |
|
| 29 |
#define NAU8825_HS_PRESENT BIT(0) |
| 30 |
#define RT5682S_HS_PRESENT BIT(1) |
| 31 |
#define RT5650_HS_PRESENT BIT(2) |
| 32 |
#define RT5682I_HS_PRESENT BIT(3) |
| 33 |
#define ES8326_HS_PRESENT BIT(4) |
| 34 |
|
| 35 |
/* |
| 36 |
* Nau88l25 |
| 37 |
*/ |
| 38 |
#define NAU8825_CODEC_DAI "nau8825-hifi" |
| 39 |
|
| 40 |
/* |
| 41 |
* Rt5682s |
| 42 |
*/ |
| 43 |
#define RT5682S_CODEC_DAI "rt5682s-aif1" |
| 44 |
|
| 45 |
/* |
| 46 |
* Rt5650 |
| 47 |
*/ |
| 48 |
#define RT5650_CODEC_DAI "rt5645-aif1" |
| 49 |
|
| 50 |
/* |
| 51 |
* Rt5682i |
| 52 |
*/ |
| 53 |
#define RT5682I_CODEC_DAI "rt5682-aif1" |
| 54 |
|
| 55 |
/* |
| 56 |
* Cs35l41 |
| 57 |
*/ |
| 58 |
#define CS35L41_CODEC_DAI "cs35l41-pcm" |
| 59 |
#define CS35L41_DEV0_NAME "cs35l41.7-0040" |
| 60 |
#define CS35L41_DEV1_NAME "cs35l41.7-0042" |
| 61 |
|
| 62 |
/* |
| 63 |
* ES8326 |
| 64 |
*/ |
| 65 |
#define ES8326_CODEC_DAI "ES8326 HiFi" |
| 66 |
|
| 67 |
enum mt8189_jacks { |
| 68 |
MT8189_JACK_HEADSET, |
| 69 |
MT8189_JACK_DP, |
| 70 |
MT8189_JACK_HDMI, |
| 71 |
MT8189_JACK_MAX, |
| 72 |
}; |
| 73 |
|
| 74 |
static struct snd_soc_jack_pin mt8189_dp_jack_pins[] = { |
| 75 |
{ |
| 76 |
.pin = "DP", |
| 77 |
.mask = SND_JACK_LINEOUT, |
| 78 |
}, |
| 79 |
}; |
| 80 |
|
| 81 |
static struct snd_soc_jack_pin mt8189_hdmi_jack_pins[] = { |
| 82 |
{ |
| 83 |
.pin = "HDMI", |
| 84 |
.mask = SND_JACK_LINEOUT, |
| 85 |
}, |
| 86 |
}; |
| 87 |
|
| 88 |
static struct snd_soc_jack_pin mt8189_headset_jack_pins[] = { |
| 89 |
{ |
| 90 |
.pin = "Headphone Jack", |
| 91 |
.mask = SND_JACK_HEADPHONE, |
| 92 |
}, |
| 93 |
{ |
| 94 |
.pin = "Headset Mic", |
| 95 |
.mask = SND_JACK_MICROPHONE, |
| 96 |
}, |
| 97 |
}; |
| 98 |
|
| 99 |
static const struct snd_kcontrol_new mt8189_dumb_spk_controls[] = { |
| 100 |
SOC_DAPM_PIN_SWITCH("Ext Spk"), |
| 101 |
}; |
| 102 |
|
| 103 |
static const struct snd_soc_dapm_widget mt8189_dumb_spk_widgets[] = { |
| 104 |
SND_SOC_DAPM_SPK("Ext Spk", NULL), |
| 105 |
}; |
| 106 |
|
| 107 |
static const struct snd_soc_dapm_widget mt8189_headset_widgets[] = { |
| 108 |
SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 109 |
SND_SOC_DAPM_MIC("Headset Mic", NULL), |
| 110 |
}; |
| 111 |
|
| 112 |
static const struct snd_kcontrol_new mt8189_headset_controls[] = { |
| 113 |
SOC_DAPM_PIN_SWITCH("Headphone Jack"), |
| 114 |
SOC_DAPM_PIN_SWITCH("Headset Mic"), |
| 115 |
}; |
| 116 |
|
| 117 |
static const struct snd_soc_dapm_widget mt8189_nau8825_card_widgets[] = { |
| 118 |
SND_SOC_DAPM_SINK("DP"), |
| 119 |
}; |
| 120 |
|
| 121 |
static int mt8189_common_i2s_startup(struct snd_pcm_substream *substream) |
| 122 |
{ |
| 123 |
static const unsigned int rates[] = { |
| 124 |
48000, |
| 125 |
}; |
| 126 |
static const struct snd_pcm_hw_constraint_list constraints_rates = { |
| 127 |
.count = ARRAY_SIZE(rates), |
| 128 |
.list = rates, |
| 129 |
}; |
| 130 |
|
| 131 |
return snd_pcm_hw_constraint_list(substream->runtime, 0, |
| 132 |
SNDRV_PCM_HW_PARAM_RATE, |
| 133 |
&constraints_rates); |
| 134 |
} |
| 135 |
|
| 136 |
static int mt8189_common_i2s_hw_params(struct snd_pcm_substream *substream, |
| 137 |
struct snd_pcm_hw_params *params) |
| 138 |
{ |
| 139 |
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); |
| 140 |
unsigned int rate = params_rate(params); |
| 141 |
unsigned int mclk_fs_ratio = 128; |
| 142 |
unsigned int mclk_fs = rate * mclk_fs_ratio; |
| 143 |
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); |
| 144 |
|
| 145 |
return snd_soc_dai_set_sysclk(cpu_dai, |
| 146 |
0, mclk_fs, SND_SOC_CLOCK_OUT); |
| 147 |
} |
| 148 |
|
| 149 |
static const struct snd_soc_ops mt8189_common_i2s_ops = { |
| 150 |
.startup = mt8189_common_i2s_startup, |
| 151 |
.hw_params = mt8189_common_i2s_hw_params, |
| 152 |
}; |
| 153 |
|
| 154 |
static int mt8189_dptx_hw_params(struct snd_pcm_substream *substream, |
| 155 |
struct snd_pcm_hw_params *params) |
| 156 |
{ |
| 157 |
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); |
| 158 |
unsigned int rate = params_rate(params); |
| 159 |
unsigned int mclk_fs_ratio = 256; |
| 160 |
unsigned int mclk_fs = rate * mclk_fs_ratio; |
| 161 |
struct snd_soc_dai *dai = snd_soc_rtd_to_cpu(rtd, 0); |
| 162 |
|
| 163 |
return snd_soc_dai_set_sysclk(dai, 0, mclk_fs, SND_SOC_CLOCK_OUT); |
| 164 |
} |
| 165 |
|
| 166 |
static const struct snd_soc_ops mt8189_dptx_ops = { |
| 167 |
.hw_params = mt8189_dptx_hw_params, |
| 168 |
}; |
| 169 |
|
| 170 |
static int mt8189_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 171 |
struct snd_pcm_hw_params *params) |
| 172 |
{ |
| 173 |
dev_dbg(rtd->dev, "%s(), fix format to 32bit\n", __func__); |
| 174 |
|
| 175 |
/* fix BE i2s format to 32bit, clean param mask first */ |
| 176 |
snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), |
| 177 |
0, (__force unsigned int)SNDRV_PCM_FORMAT_LAST); |
| 178 |
|
| 179 |
params_set_format(params, SNDRV_PCM_FORMAT_S32_LE); |
| 180 |
|
| 181 |
return 0; |
| 182 |
} |
| 183 |
|
| 184 |
static const struct snd_soc_ops mt8189_pcm_ops = { |
| 185 |
.startup = mt8189_common_i2s_startup, |
| 186 |
}; |
| 187 |
|
| 188 |
static int mt8189_nau8825_hw_params(struct snd_pcm_substream *substream, |
| 189 |
struct snd_pcm_hw_params *params) |
| 190 |
{ |
| 191 |
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); |
| 192 |
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); |
| 193 |
unsigned int rate = params_rate(params); |
| 194 |
unsigned int bit_width = params_width(params); |
| 195 |
int clk_freq, ret; |
| 196 |
|
| 197 |
clk_freq = rate * 2 * bit_width; |
| 198 |
dev_dbg(codec_dai->dev, "clk_freq %d, rate: %d, bit_width: %d\n", |
| 199 |
clk_freq, rate, bit_width); |
| 200 |
|
| 201 |
/* Configure clock for codec */ |
| 202 |
ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_BLK, 0, |
| 203 |
SND_SOC_CLOCK_IN); |
| 204 |
if (ret < 0) { |
| 205 |
dev_err(codec_dai->dev, "can't set BCLK clock %d\n", ret); |
| 206 |
return ret; |
| 207 |
} |
| 208 |
|
| 209 |
/* Configure pll for codec */ |
| 210 |
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, clk_freq, |
| 211 |
rate * 256); |
| 212 |
if (ret < 0) { |
| 213 |
dev_err(codec_dai->dev, "can't set BCLK: %d\n", ret); |
| 214 |
return ret; |
| 215 |
} |
| 216 |
|
| 217 |
return 0; |
| 218 |
} |
| 219 |
|
| 220 |
static const struct snd_soc_ops mt8189_nau8825_ops = { |
| 221 |
.startup = mt8189_common_i2s_startup, |
| 222 |
.hw_params = mt8189_nau8825_hw_params, |
| 223 |
}; |
| 224 |
|
| 225 |
static int mt8189_rtxxxx_i2s_hw_params(struct snd_pcm_substream *substream, |
| 226 |
struct snd_pcm_hw_params *params) |
| 227 |
{ |
| 228 |
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); |
| 229 |
struct snd_soc_card *card = rtd->card; |
| 230 |
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); |
| 231 |
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); |
| 232 |
unsigned int rate = params_rate(params); |
| 233 |
int bitwidth; |
| 234 |
int ret; |
| 235 |
|
| 236 |
bitwidth = snd_pcm_format_width(params_format(params)); |
| 237 |
if (bitwidth < 0) { |
| 238 |
dev_err(card->dev, "invalid bit width: %d\n", bitwidth); |
| 239 |
return bitwidth; |
| 240 |
} |
| 241 |
|
| 242 |
ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x00, 0x0, 0x2, bitwidth); |
| 243 |
if (ret) { |
| 244 |
dev_err(card->dev, "failed to set tdm slot\n"); |
| 245 |
return ret; |
| 246 |
} |
| 247 |
|
| 248 |
ret = snd_soc_dai_set_pll(codec_dai, 0, 1, rate * 32, rate * 512); |
| 249 |
if (ret) { |
| 250 |
dev_err(card->dev, "failed to set pll\n"); |
| 251 |
return ret; |
| 252 |
} |
| 253 |
|
| 254 |
ret = snd_soc_dai_set_sysclk(codec_dai, 1, rate * 512, SND_SOC_CLOCK_IN); |
| 255 |
if (ret) { |
| 256 |
dev_err(card->dev, "failed to set sysclk\n"); |
| 257 |
return ret; |
| 258 |
} |
| 259 |
|
| 260 |
return snd_soc_dai_set_sysclk(cpu_dai, 0, rate * 512, |
| 261 |
SND_SOC_CLOCK_OUT); |
| 262 |
} |
| 263 |
|
| 264 |
static const struct snd_soc_ops mt8189_rtxxxx_i2s_ops = { |
| 265 |
.startup = mt8189_common_i2s_startup, |
| 266 |
.hw_params = mt8189_rtxxxx_i2s_hw_params, |
| 267 |
}; |
| 268 |
|
| 269 |
static int mt8189_cs35l41_i2s_hw_params(struct snd_pcm_substream *substream, |
| 270 |
struct snd_pcm_hw_params *params) |
| 271 |
{ |
| 272 |
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); |
| 273 |
unsigned int rate = params_rate(params); |
| 274 |
unsigned int mclk_fs = rate * 128; |
| 275 |
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); |
| 276 |
struct snd_soc_dai *codec_dai; |
| 277 |
int clk_freq = rate * 32; |
| 278 |
int rx_slot[] = {0, 1}; |
| 279 |
int i, ret; |
| 280 |
|
| 281 |
for_each_rtd_codec_dais(rtd, i, codec_dai) { |
| 282 |
ret = snd_soc_component_set_sysclk(codec_dai->component, |
| 283 |
CS35L41_CLKID_SCLK, 0, |
| 284 |
clk_freq, SND_SOC_CLOCK_IN); |
| 285 |
if (ret < 0) { |
| 286 |
dev_err(codec_dai->dev, "set component sysclk fail: %d\n", |
| 287 |
ret); |
| 288 |
return ret; |
| 289 |
} |
| 290 |
|
| 291 |
ret = snd_soc_dai_set_sysclk(codec_dai, CS35L41_CLKID_SCLK, |
| 292 |
clk_freq, SND_SOC_CLOCK_IN); |
| 293 |
if (ret < 0) { |
| 294 |
dev_err(codec_dai->dev, "set sysclk fail: %d\n", |
| 295 |
ret); |
| 296 |
return ret; |
| 297 |
} |
| 298 |
|
| 299 |
ret = snd_soc_dai_set_channel_map(codec_dai, 0, NULL, |
| 300 |
1, &rx_slot[i]); |
| 301 |
if (ret < 0) { |
| 302 |
dev_err(codec_dai->dev, "set channel map fail: %d\n", |
| 303 |
ret); |
| 304 |
return ret; |
| 305 |
} |
| 306 |
} |
| 307 |
|
| 308 |
return snd_soc_dai_set_sysclk(cpu_dai, |
| 309 |
0, mclk_fs, SND_SOC_CLOCK_OUT); |
| 310 |
} |
| 311 |
|
| 312 |
static const struct snd_soc_ops mt8189_cs35l41_i2s_ops = { |
| 313 |
.startup = mt8189_common_i2s_startup, |
| 314 |
.hw_params = mt8189_cs35l41_i2s_hw_params, |
| 315 |
}; |
| 316 |
|
| 317 |
static int mt8189_es8326_hw_params(struct snd_pcm_substream *substream, |
| 318 |
struct snd_pcm_hw_params *params) |
| 319 |
{ |
| 320 |
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); |
| 321 |
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); |
| 322 |
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); |
| 323 |
unsigned int rate = params_rate(params); |
| 324 |
int ret; |
| 325 |
|
| 326 |
/* Configure MCLK for codec */ |
| 327 |
ret = snd_soc_dai_set_sysclk(codec_dai, 0, rate * 256, SND_SOC_CLOCK_IN); |
| 328 |
if (ret < 0) { |
| 329 |
dev_err(codec_dai->dev, "can't set MCLK %d\n", ret); |
| 330 |
return ret; |
| 331 |
} |
| 332 |
|
| 333 |
/* Configure MCLK for cpu */ |
| 334 |
return snd_soc_dai_set_sysclk(cpu_dai, 0, rate * 256, SND_SOC_CLOCK_OUT); |
| 335 |
} |
| 336 |
|
| 337 |
static const struct snd_soc_ops mt8189_es8326_ops = { |
| 338 |
.startup = mt8189_common_i2s_startup, |
| 339 |
.hw_params = mt8189_es8326_hw_params, |
| 340 |
}; |
| 341 |
|
| 342 |
static int mt8189_dumb_amp_init(struct snd_soc_pcm_runtime *rtd) |
| 343 |
{ |
| 344 |
struct snd_soc_card *card = rtd->card; |
| 345 |
struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card); |
| 346 |
int ret; |
| 347 |
|
| 348 |
ret = snd_soc_dapm_new_controls(dapm, mt8189_dumb_spk_widgets, |
| 349 |
ARRAY_SIZE(mt8189_dumb_spk_widgets)); |
| 350 |
if (ret) { |
| 351 |
dev_err(rtd->dev, "unable to add Dumb Speaker dapm, ret %d\n", ret); |
| 352 |
return ret; |
| 353 |
} |
| 354 |
|
| 355 |
ret = snd_soc_add_card_controls(card, mt8189_dumb_spk_controls, |
| 356 |
ARRAY_SIZE(mt8189_dumb_spk_controls)); |
| 357 |
if (ret) { |
| 358 |
dev_err(rtd->dev, "unable to add Dumb card controls, ret %d\n", ret); |
| 359 |
return ret; |
| 360 |
} |
| 361 |
|
| 362 |
return 0; |
| 363 |
} |
| 364 |
|
| 365 |
static int mt8189_dptx_codec_init(struct snd_soc_pcm_runtime *rtd) |
| 366 |
{ |
| 367 |
struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card); |
| 368 |
struct snd_soc_jack *jack = &soc_card_data->card_data->jacks[MT8189_JACK_DP]; |
| 369 |
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; |
| 370 |
int ret; |
| 371 |
|
| 372 |
ret = snd_soc_card_jack_new_pins(rtd->card, "DP Jack", SND_JACK_LINEOUT, |
| 373 |
jack, mt8189_dp_jack_pins, |
| 374 |
ARRAY_SIZE(mt8189_dp_jack_pins)); |
| 375 |
if (ret) { |
| 376 |
dev_err(rtd->dev, "%s, new jack failed: %d\n", __func__, ret); |
| 377 |
return ret; |
| 378 |
} |
| 379 |
|
| 380 |
ret = snd_soc_component_set_jack(component, jack, NULL); |
| 381 |
if (ret) { |
| 382 |
dev_err(rtd->dev, "%s, set jack failed on %s (ret=%d)\n", |
| 383 |
__func__, component->name, ret); |
| 384 |
return ret; |
| 385 |
} |
| 386 |
|
| 387 |
return 0; |
| 388 |
} |
| 389 |
|
| 390 |
static int mt8189_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd) |
| 391 |
{ |
| 392 |
struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card); |
| 393 |
struct snd_soc_jack *jack = &soc_card_data->card_data->jacks[MT8189_JACK_HDMI]; |
| 394 |
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; |
| 395 |
int ret; |
| 396 |
|
| 397 |
ret = snd_soc_card_jack_new_pins(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, |
| 398 |
jack, mt8189_hdmi_jack_pins, |
| 399 |
ARRAY_SIZE(mt8189_hdmi_jack_pins)); |
| 400 |
if (ret) { |
| 401 |
dev_err(rtd->dev, "%s, new jack failed: %d\n", __func__, ret); |
| 402 |
return ret; |
| 403 |
} |
| 404 |
|
| 405 |
ret = snd_soc_component_set_jack(component, jack, NULL); |
| 406 |
if (ret) { |
| 407 |
dev_err(rtd->dev, "%s, set jack failed on %s (ret=%d)\n", |
| 408 |
__func__, component->name, ret); |
| 409 |
return ret; |
| 410 |
} |
| 411 |
|
| 412 |
return 0; |
| 413 |
} |
| 414 |
|
| 415 |
static int mt8189_headset_codec_init(struct snd_soc_pcm_runtime *rtd) |
| 416 |
{ |
| 417 |
struct snd_soc_card *card = rtd->card; |
| 418 |
struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card); |
| 419 |
struct snd_soc_jack *jack = &soc_card_data->card_data->jacks[MT8189_JACK_HEADSET]; |
| 420 |
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; |
| 421 |
struct mtk_platform_card_data *card_data = soc_card_data->card_data; |
| 422 |
struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card); |
| 423 |
int ret; |
| 424 |
int type; |
| 425 |
|
| 426 |
ret = snd_soc_dapm_new_controls(dapm, mt8189_headset_widgets, |
| 427 |
ARRAY_SIZE(mt8189_headset_widgets)); |
| 428 |
if (ret) { |
| 429 |
dev_err(rtd->dev, "unable to add nau8825 card widget, ret %d\n", ret); |
| 430 |
return ret; |
| 431 |
} |
| 432 |
|
| 433 |
ret = snd_soc_add_card_controls(card, mt8189_headset_controls, |
| 434 |
ARRAY_SIZE(mt8189_headset_controls)); |
| 435 |
if (ret) { |
| 436 |
dev_err(rtd->dev, "unable to add nau8825 card controls, ret %d\n", ret); |
| 437 |
return ret; |
| 438 |
} |
| 439 |
|
| 440 |
ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", |
| 441 |
SND_JACK_HEADSET | SND_JACK_BTN_0 | |
| 442 |
SND_JACK_BTN_1 | SND_JACK_BTN_2 | |
| 443 |
SND_JACK_BTN_3, |
| 444 |
jack, |
| 445 |
mt8189_headset_jack_pins, |
| 446 |
ARRAY_SIZE(mt8189_headset_jack_pins)); |
| 447 |
if (ret) { |
| 448 |
dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); |
| 449 |
return ret; |
| 450 |
} |
| 451 |
|
| 452 |
if (card_data->flags & ES8326_HS_PRESENT) { |
| 453 |
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); |
| 454 |
snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); |
| 455 |
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); |
| 456 |
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); |
| 457 |
} else { |
| 458 |
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); |
| 459 |
snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); |
| 460 |
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); |
| 461 |
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); |
| 462 |
} |
| 463 |
|
| 464 |
type = SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3; |
| 465 |
ret = snd_soc_component_set_jack(component, jack, (void *)&type); |
| 466 |
if (ret) { |
| 467 |
dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret); |
| 468 |
return ret; |
| 469 |
} |
| 470 |
|
| 471 |
return 0; |
| 472 |
}; |
| 473 |
|
| 474 |
static void mt8189_headset_codec_exit(struct snd_soc_pcm_runtime *rtd) |
| 475 |
{ |
| 476 |
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; |
| 477 |
|
| 478 |
snd_soc_component_set_jack(component, NULL, NULL); |
| 479 |
} |
| 480 |
|
| 481 |
/* FE */ |
| 482 |
SND_SOC_DAILINK_DEFS(playback0, |
| 483 |
DAILINK_COMP_ARRAY(COMP_CPU("DL0")), |
| 484 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 485 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 486 |
SND_SOC_DAILINK_DEFS(playback1, |
| 487 |
DAILINK_COMP_ARRAY(COMP_CPU("DL1")), |
| 488 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 489 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 490 |
SND_SOC_DAILINK_DEFS(playback2, |
| 491 |
DAILINK_COMP_ARRAY(COMP_CPU("DL2")), |
| 492 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 493 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 494 |
SND_SOC_DAILINK_DEFS(playback3, |
| 495 |
DAILINK_COMP_ARRAY(COMP_CPU("DL3")), |
| 496 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 497 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 498 |
SND_SOC_DAILINK_DEFS(playback4, |
| 499 |
DAILINK_COMP_ARRAY(COMP_CPU("DL4")), |
| 500 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 501 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 502 |
SND_SOC_DAILINK_DEFS(playback5, |
| 503 |
DAILINK_COMP_ARRAY(COMP_CPU("DL5")), |
| 504 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 505 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 506 |
SND_SOC_DAILINK_DEFS(playback6, |
| 507 |
DAILINK_COMP_ARRAY(COMP_CPU("DL6")), |
| 508 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 509 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 510 |
SND_SOC_DAILINK_DEFS(playback7, |
| 511 |
DAILINK_COMP_ARRAY(COMP_CPU("DL7")), |
| 512 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 513 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 514 |
SND_SOC_DAILINK_DEFS(playback8, |
| 515 |
DAILINK_COMP_ARRAY(COMP_CPU("DL8")), |
| 516 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 517 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 518 |
SND_SOC_DAILINK_DEFS(playback23, |
| 519 |
DAILINK_COMP_ARRAY(COMP_CPU("DL23")), |
| 520 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 521 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 522 |
SND_SOC_DAILINK_DEFS(playback24, |
| 523 |
DAILINK_COMP_ARRAY(COMP_CPU("DL24")), |
| 524 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 525 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 526 |
SND_SOC_DAILINK_DEFS(playback25, |
| 527 |
DAILINK_COMP_ARRAY(COMP_CPU("DL25")), |
| 528 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 529 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 530 |
SND_SOC_DAILINK_DEFS(playback_24ch, |
| 531 |
DAILINK_COMP_ARRAY(COMP_CPU("DL_24CH")), |
| 532 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 533 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 534 |
SND_SOC_DAILINK_DEFS(capture0, |
| 535 |
DAILINK_COMP_ARRAY(COMP_CPU("UL0")), |
| 536 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 537 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 538 |
SND_SOC_DAILINK_DEFS(capture1, |
| 539 |
DAILINK_COMP_ARRAY(COMP_CPU("UL1")), |
| 540 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 541 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 542 |
SND_SOC_DAILINK_DEFS(capture2, |
| 543 |
DAILINK_COMP_ARRAY(COMP_CPU("UL2")), |
| 544 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 545 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 546 |
SND_SOC_DAILINK_DEFS(capture3, |
| 547 |
DAILINK_COMP_ARRAY(COMP_CPU("UL3")), |
| 548 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 549 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 550 |
SND_SOC_DAILINK_DEFS(capture4, |
| 551 |
DAILINK_COMP_ARRAY(COMP_CPU("UL4")), |
| 552 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 553 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 554 |
SND_SOC_DAILINK_DEFS(capture5, |
| 555 |
DAILINK_COMP_ARRAY(COMP_CPU("UL5")), |
| 556 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 557 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 558 |
SND_SOC_DAILINK_DEFS(capture6, |
| 559 |
DAILINK_COMP_ARRAY(COMP_CPU("UL6")), |
| 560 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 561 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 562 |
SND_SOC_DAILINK_DEFS(capture7, |
| 563 |
DAILINK_COMP_ARRAY(COMP_CPU("UL7")), |
| 564 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 565 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 566 |
SND_SOC_DAILINK_DEFS(capture8, |
| 567 |
DAILINK_COMP_ARRAY(COMP_CPU("UL8")), |
| 568 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 569 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 570 |
SND_SOC_DAILINK_DEFS(capture9, |
| 571 |
DAILINK_COMP_ARRAY(COMP_CPU("UL9")), |
| 572 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 573 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 574 |
SND_SOC_DAILINK_DEFS(capture10, |
| 575 |
DAILINK_COMP_ARRAY(COMP_CPU("UL10")), |
| 576 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 577 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 578 |
SND_SOC_DAILINK_DEFS(capture24, |
| 579 |
DAILINK_COMP_ARRAY(COMP_CPU("UL24")), |
| 580 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 581 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 582 |
SND_SOC_DAILINK_DEFS(capture25, |
| 583 |
DAILINK_COMP_ARRAY(COMP_CPU("UL25")), |
| 584 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 585 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 586 |
SND_SOC_DAILINK_DEFS(capture_cm0, |
| 587 |
DAILINK_COMP_ARRAY(COMP_CPU("UL_CM0")), |
| 588 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 589 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 590 |
SND_SOC_DAILINK_DEFS(capture_cm1, |
| 591 |
DAILINK_COMP_ARRAY(COMP_CPU("UL_CM1")), |
| 592 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 593 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 594 |
SND_SOC_DAILINK_DEFS(capture_etdm_in0, |
| 595 |
DAILINK_COMP_ARRAY(COMP_CPU("UL_ETDM_IN0")), |
| 596 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 597 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 598 |
SND_SOC_DAILINK_DEFS(capture_etdm_in1, |
| 599 |
DAILINK_COMP_ARRAY(COMP_CPU("UL_ETDM_IN1")), |
| 600 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 601 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 602 |
SND_SOC_DAILINK_DEFS(playback_hdmi, |
| 603 |
DAILINK_COMP_ARRAY(COMP_CPU("HDMI")), |
| 604 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 605 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 606 |
/* BE */ |
| 607 |
SND_SOC_DAILINK_DEFS(ap_dmic, |
| 608 |
DAILINK_COMP_ARRAY(COMP_CPU("AP_DMIC")), |
| 609 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 610 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 611 |
SND_SOC_DAILINK_DEFS(ap_dmic_ch34, |
| 612 |
DAILINK_COMP_ARRAY(COMP_CPU("AP_DMIC_CH34")), |
| 613 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 614 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 615 |
SND_SOC_DAILINK_DEFS(i2sin0, |
| 616 |
DAILINK_COMP_ARRAY(COMP_CPU("I2SIN0")), |
| 617 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 618 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 619 |
SND_SOC_DAILINK_DEFS(i2sin1, |
| 620 |
DAILINK_COMP_ARRAY(COMP_CPU("I2SIN1")), |
| 621 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 622 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 623 |
SND_SOC_DAILINK_DEFS(i2sout0, |
| 624 |
DAILINK_COMP_ARRAY(COMP_CPU("I2SOUT0")), |
| 625 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 626 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 627 |
SND_SOC_DAILINK_DEFS(i2sout1, |
| 628 |
DAILINK_COMP_ARRAY(COMP_CPU("I2SOUT1")), |
| 629 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 630 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 631 |
SND_SOC_DAILINK_DEFS(pcm0, |
| 632 |
DAILINK_COMP_ARRAY(COMP_CPU("PCM 0")), |
| 633 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 634 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 635 |
SND_SOC_DAILINK_DEFS(tdm_dptx, |
| 636 |
DAILINK_COMP_ARRAY(COMP_CPU("TDM_DPTX")), |
| 637 |
DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 638 |
DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 639 |
|
| 640 |
static struct snd_soc_dai_link mt8189_nau8825_dai_links[] = { |
| 641 |
/* Front End DAI links */ |
| 642 |
{ |
| 643 |
.name = "DL0_FE", |
| 644 |
.stream_name = "DL0 Playback", |
| 645 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 646 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 647 |
.dynamic = 1, |
| 648 |
.playback_only = 1, |
| 649 |
.dpcm_merged_format = 1, |
| 650 |
SND_SOC_DAILINK_REG(playback0), |
| 651 |
}, |
| 652 |
{ |
| 653 |
.name = "DL1_FE", |
| 654 |
.stream_name = "DL1 Playback", |
| 655 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 656 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 657 |
.dynamic = 1, |
| 658 |
.playback_only = 1, |
| 659 |
.dpcm_merged_format = 1, |
| 660 |
SND_SOC_DAILINK_REG(playback1), |
| 661 |
}, |
| 662 |
{ |
| 663 |
.name = "UL0_FE", |
| 664 |
.stream_name = "UL0 Capture", |
| 665 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 666 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 667 |
.dynamic = 1, |
| 668 |
.capture_only = 1, |
| 669 |
.dpcm_merged_format = 1, |
| 670 |
SND_SOC_DAILINK_REG(capture0), |
| 671 |
}, |
| 672 |
{ |
| 673 |
.name = "UL1_FE", |
| 674 |
.stream_name = "UL1 Capture", |
| 675 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 676 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 677 |
.dynamic = 1, |
| 678 |
.capture_only = 1, |
| 679 |
.dpcm_merged_format = 1, |
| 680 |
SND_SOC_DAILINK_REG(capture1), |
| 681 |
}, |
| 682 |
{ |
| 683 |
.name = "UL2_FE", |
| 684 |
.stream_name = "UL2 Capture", |
| 685 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 686 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 687 |
.dynamic = 1, |
| 688 |
.capture_only = 1, |
| 689 |
.dpcm_merged_format = 1, |
| 690 |
SND_SOC_DAILINK_REG(capture2), |
| 691 |
}, |
| 692 |
{ |
| 693 |
.name = "HDMI_FE", |
| 694 |
.stream_name = "HDMI Playback", |
| 695 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 696 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 697 |
.dynamic = 1, |
| 698 |
.playback_only = 1, |
| 699 |
SND_SOC_DAILINK_REG(playback_hdmi), |
| 700 |
}, |
| 701 |
{ |
| 702 |
.name = "DL2_FE", |
| 703 |
.stream_name = "DL2 Playback", |
| 704 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 705 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 706 |
.dynamic = 1, |
| 707 |
.playback_only = 1, |
| 708 |
SND_SOC_DAILINK_REG(playback2), |
| 709 |
}, |
| 710 |
{ |
| 711 |
.name = "DL3_FE", |
| 712 |
.stream_name = "DL3 Playback", |
| 713 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 714 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 715 |
.dynamic = 1, |
| 716 |
.playback_only = 1, |
| 717 |
SND_SOC_DAILINK_REG(playback3), |
| 718 |
}, |
| 719 |
{ |
| 720 |
.name = "DL4_FE", |
| 721 |
.stream_name = "DL4 Playback", |
| 722 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 723 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 724 |
.dynamic = 1, |
| 725 |
.playback_only = 1, |
| 726 |
SND_SOC_DAILINK_REG(playback4), |
| 727 |
}, |
| 728 |
{ |
| 729 |
.name = "DL5_FE", |
| 730 |
.stream_name = "DL5 Playback", |
| 731 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 732 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 733 |
.dynamic = 1, |
| 734 |
.playback_only = 1, |
| 735 |
SND_SOC_DAILINK_REG(playback5), |
| 736 |
}, |
| 737 |
{ |
| 738 |
.name = "DL6_FE", |
| 739 |
.stream_name = "DL6 Playback", |
| 740 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 741 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 742 |
.dynamic = 1, |
| 743 |
.playback_only = 1, |
| 744 |
SND_SOC_DAILINK_REG(playback6), |
| 745 |
}, |
| 746 |
{ |
| 747 |
.name = "DL7_FE", |
| 748 |
.stream_name = "DL7 Playback", |
| 749 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 750 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 751 |
.dynamic = 1, |
| 752 |
.playback_only = 1, |
| 753 |
SND_SOC_DAILINK_REG(playback7), |
| 754 |
}, |
| 755 |
{ |
| 756 |
.name = "DL8 FE", |
| 757 |
.stream_name = "DL8 Playback", |
| 758 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 759 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 760 |
.dynamic = 1, |
| 761 |
.playback_only = 1, |
| 762 |
SND_SOC_DAILINK_REG(playback8), |
| 763 |
}, |
| 764 |
{ |
| 765 |
.name = "DL23 FE", |
| 766 |
.stream_name = "DL23 Playback", |
| 767 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 768 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 769 |
.dynamic = 1, |
| 770 |
.playback_only = 1, |
| 771 |
SND_SOC_DAILINK_REG(playback23), |
| 772 |
}, |
| 773 |
{ |
| 774 |
.name = "DL24 FE", |
| 775 |
.stream_name = "DL24 Playback", |
| 776 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 777 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 778 |
.dynamic = 1, |
| 779 |
.playback_only = 1, |
| 780 |
SND_SOC_DAILINK_REG(playback24), |
| 781 |
}, |
| 782 |
{ |
| 783 |
.name = "DL25 FE", |
| 784 |
.stream_name = "DL25 Playback", |
| 785 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 786 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 787 |
.dynamic = 1, |
| 788 |
.playback_only = 1, |
| 789 |
SND_SOC_DAILINK_REG(playback25), |
| 790 |
}, |
| 791 |
{ |
| 792 |
.name = "DL_24CH_FE", |
| 793 |
.stream_name = "DL_24CH Playback", |
| 794 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 795 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 796 |
.dynamic = 1, |
| 797 |
.playback_only = 1, |
| 798 |
SND_SOC_DAILINK_REG(playback_24ch), |
| 799 |
}, |
| 800 |
{ |
| 801 |
.name = "UL9_FE", |
| 802 |
.stream_name = "UL9 Capture", |
| 803 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 804 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 805 |
.dynamic = 1, |
| 806 |
.capture_only = 1, |
| 807 |
SND_SOC_DAILINK_REG(capture9), |
| 808 |
}, |
| 809 |
{ |
| 810 |
.name = "UL3_FE", |
| 811 |
.stream_name = "UL3 Capture", |
| 812 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 813 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 814 |
.dynamic = 1, |
| 815 |
.capture_only = 1, |
| 816 |
SND_SOC_DAILINK_REG(capture3), |
| 817 |
}, |
| 818 |
{ |
| 819 |
.name = "UL7_FE", |
| 820 |
.stream_name = "UL7 Capture", |
| 821 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 822 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 823 |
.dynamic = 1, |
| 824 |
.capture_only = 1, |
| 825 |
SND_SOC_DAILINK_REG(capture7), |
| 826 |
}, |
| 827 |
{ |
| 828 |
.name = "UL4_FE", |
| 829 |
.stream_name = "UL4 Capture", |
| 830 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 831 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 832 |
.dynamic = 1, |
| 833 |
.capture_only = 1, |
| 834 |
SND_SOC_DAILINK_REG(capture4), |
| 835 |
}, |
| 836 |
{ |
| 837 |
.name = "UL5_FE", |
| 838 |
.stream_name = "UL5 Capture", |
| 839 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 840 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 841 |
.dynamic = 1, |
| 842 |
.capture_only = 1, |
| 843 |
SND_SOC_DAILINK_REG(capture5), |
| 844 |
}, |
| 845 |
{ |
| 846 |
.name = "UL_CM0_FE", |
| 847 |
.stream_name = "UL_CM0 Capture", |
| 848 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 849 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 850 |
.dynamic = 1, |
| 851 |
.capture_only = 1, |
| 852 |
SND_SOC_DAILINK_REG(capture_cm0), |
| 853 |
}, |
| 854 |
{ |
| 855 |
.name = "UL_CM1_FE", |
| 856 |
.stream_name = "UL_CM1 Capture", |
| 857 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 858 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 859 |
.dynamic = 1, |
| 860 |
.capture_only = 1, |
| 861 |
SND_SOC_DAILINK_REG(capture_cm1), |
| 862 |
}, |
| 863 |
{ |
| 864 |
.name = "UL10_FE", |
| 865 |
.stream_name = "UL10 Capture", |
| 866 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 867 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 868 |
.dynamic = 1, |
| 869 |
.capture_only = 1, |
| 870 |
SND_SOC_DAILINK_REG(capture10), |
| 871 |
}, |
| 872 |
{ |
| 873 |
.name = "UL6_FE", |
| 874 |
.stream_name = "UL6 Capture", |
| 875 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 876 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 877 |
.dynamic = 1, |
| 878 |
.capture_only = 1, |
| 879 |
SND_SOC_DAILINK_REG(capture6), |
| 880 |
}, |
| 881 |
{ |
| 882 |
.name = "UL25_FE", |
| 883 |
.stream_name = "UL25 Capture", |
| 884 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 885 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 886 |
.dynamic = 1, |
| 887 |
.capture_only = 1, |
| 888 |
SND_SOC_DAILINK_REG(capture25), |
| 889 |
}, |
| 890 |
{ |
| 891 |
.name = "UL8_FE", |
| 892 |
.stream_name = "UL8 Capture_Mono_1", |
| 893 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 894 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 895 |
.dynamic = 1, |
| 896 |
.capture_only = 1, |
| 897 |
SND_SOC_DAILINK_REG(capture8), |
| 898 |
}, |
| 899 |
{ |
| 900 |
.name = "UL24_FE", |
| 901 |
.stream_name = "UL24 Capture_Mono_2", |
| 902 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 903 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 904 |
.dynamic = 1, |
| 905 |
.capture_only = 1, |
| 906 |
SND_SOC_DAILINK_REG(capture24), |
| 907 |
}, |
| 908 |
{ |
| 909 |
.name = "UL_ETDM_In0_FE", |
| 910 |
.stream_name = "UL_ETDM_In0 Capture", |
| 911 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 912 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 913 |
.dynamic = 1, |
| 914 |
.capture_only = 1, |
| 915 |
SND_SOC_DAILINK_REG(capture_etdm_in0), |
| 916 |
}, |
| 917 |
{ |
| 918 |
.name = "UL_ETDM_In1_FE", |
| 919 |
.stream_name = "UL_ETDM_In1 Capture", |
| 920 |
.trigger = {SND_SOC_DPCM_TRIGGER_PRE, |
| 921 |
SND_SOC_DPCM_TRIGGER_PRE}, |
| 922 |
.dynamic = 1, |
| 923 |
.capture_only = 1, |
| 924 |
SND_SOC_DAILINK_REG(capture_etdm_in1), |
| 925 |
}, |
| 926 |
/* Back End DAI links */ |
| 927 |
{ |
| 928 |
.name = "I2SIN0_BE", |
| 929 |
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBC_CFC |
| 930 |
| SND_SOC_DAIFMT_GATED, |
| 931 |
.ops = &mt8189_common_i2s_ops, |
| 932 |
.no_pcm = 1, |
| 933 |
.capture_only = 1, |
| 934 |
.ignore_suspend = 1, |
| 935 |
SND_SOC_DAILINK_REG(i2sin0), |
| 936 |
}, |
| 937 |
{ |
| 938 |
.name = "I2SIN1_BE", |
| 939 |
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBC_CFC |
| 940 |
| SND_SOC_DAIFMT_GATED, |
| 941 |
.ops = &mt8189_common_i2s_ops, |
| 942 |
.no_pcm = 1, |
| 943 |
.capture_only = 1, |
| 944 |
.ignore_suspend = 1, |
| 945 |
SND_SOC_DAILINK_REG(i2sin1), |
| 946 |
}, |
| 947 |
{ |
| 948 |
.name = "I2SOUT0_BE", |
| 949 |
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBC_CFC |
| 950 |
| SND_SOC_DAIFMT_GATED, |
| 951 |
.ops = &mt8189_common_i2s_ops, |
| 952 |
.no_pcm = 1, |
| 953 |
.playback_only = 1, |
| 954 |
.ignore_suspend = 1, |
| 955 |
SND_SOC_DAILINK_REG(i2sout0), |
| 956 |
}, |
| 957 |
{ |
| 958 |
.name = "I2SOUT1_BE", |
| 959 |
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBC_CFC |
| 960 |
| SND_SOC_DAIFMT_GATED, |
| 961 |
.ops = &mt8189_common_i2s_ops, |
| 962 |
.no_pcm = 1, |
| 963 |
.playback_only = 1, |
| 964 |
.ignore_suspend = 1, |
| 965 |
SND_SOC_DAILINK_REG(i2sout1), |
| 966 |
}, |
| 967 |
{ |
| 968 |
.name = "AP_DMIC_BE", |
| 969 |
.no_pcm = 1, |
| 970 |
.capture_only = 1, |
| 971 |
.ignore_suspend = 1, |
| 972 |
SND_SOC_DAILINK_REG(ap_dmic), |
| 973 |
}, |
| 974 |
{ |
| 975 |
.name = "AP_DMIC_CH34_BE", |
| 976 |
.no_pcm = 1, |
| 977 |
.capture_only = 1, |
| 978 |
.ignore_suspend = 1, |
| 979 |
SND_SOC_DAILINK_REG(ap_dmic_ch34), |
| 980 |
}, |
| 981 |
{ |
| 982 |
.name = "TDM_DPTX_BE", |
| 983 |
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBC_CFC |
| 984 |
| SND_SOC_DAIFMT_GATED, |
| 985 |
.ops = &mt8189_dptx_ops, |
| 986 |
.be_hw_params_fixup = mt8189_dptx_hw_params_fixup, |
| 987 |
.no_pcm = 1, |
| 988 |
.playback_only = 1, |
| 989 |
.ignore_suspend = 1, |
| 990 |
SND_SOC_DAILINK_REG(tdm_dptx), |
| 991 |
}, |
| 992 |
{ |
| 993 |
.name = "PCM_0_BE", |
| 994 |
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBC_CFC |
| 995 |
| SND_SOC_DAIFMT_GATED, |
| 996 |
.no_pcm = 1, |
| 997 |
.ops = &mt8189_pcm_ops, |
| 998 |
.playback_only = 1, |
| 999 |
.ignore_suspend = 1, |
| 1000 |
SND_SOC_DAILINK_REG(pcm0), |
| 1001 |
}, |
| 1002 |
}; |
| 1003 |
|
| 1004 |
static struct snd_soc_codec_conf mt8189_cs35l41_codec_conf[] = { |
| 1005 |
{ |
| 1006 |
.dlc = COMP_CODEC_CONF(CS35L41_DEV0_NAME), |
| 1007 |
.name_prefix = "Right", |
| 1008 |
}, |
| 1009 |
{ |
| 1010 |
.dlc = COMP_CODEC_CONF(CS35L41_DEV1_NAME), |
| 1011 |
.name_prefix = "Left", |
| 1012 |
}, |
| 1013 |
}; |
| 1014 |
|
| 1015 |
static int mt8189_nau8825_soc_card_probe(struct mtk_soc_card_data *soc_card_data, bool legacy) |
| 1016 |
{ |
| 1017 |
struct snd_soc_card *card = soc_card_data->card_data->card; |
| 1018 |
struct snd_soc_dai_link *dai_link; |
| 1019 |
bool init_nau8825 = false; |
| 1020 |
bool init_rt5682s = false; |
| 1021 |
bool init_rt5650 = false; |
| 1022 |
bool init_rt5682i = false; |
| 1023 |
bool init_es8326 = false; |
| 1024 |
bool init_dumb = false; |
| 1025 |
int i; |
| 1026 |
|
| 1027 |
for_each_card_prelinks(card, i, dai_link) { |
| 1028 |
if (strcmp(dai_link->name, "TDM_DPTX_BE") == 0) { |
| 1029 |
if (dai_link->num_codecs && |
| 1030 |
strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) |
| 1031 |
dai_link->init = mt8189_dptx_codec_init; |
| 1032 |
} else if (strcmp(dai_link->name, "PCM_0_BE") == 0) { |
| 1033 |
if (dai_link->num_codecs && |
| 1034 |
strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) |
| 1035 |
dai_link->init = mt8189_hdmi_codec_init; |
| 1036 |
} else if (strcmp(dai_link->name, "I2SOUT0_BE") == 0 || |
| 1037 |
strcmp(dai_link->name, "I2SIN0_BE") == 0) { |
| 1038 |
if (!strcmp(dai_link->codecs->dai_name, NAU8825_CODEC_DAI)) { |
| 1039 |
dai_link->ops = &mt8189_nau8825_ops; |
| 1040 |
if (!init_nau8825) { |
| 1041 |
dai_link->init = mt8189_headset_codec_init; |
| 1042 |
dai_link->exit = mt8189_headset_codec_exit; |
| 1043 |
init_nau8825 = true; |
| 1044 |
} |
| 1045 |
} else if (!strcmp(dai_link->codecs->dai_name, RT5682S_CODEC_DAI)) { |
| 1046 |
dai_link->ops = &mt8189_rtxxxx_i2s_ops; |
| 1047 |
if (!init_rt5682s) { |
| 1048 |
dai_link->init = mt8189_headset_codec_init; |
| 1049 |
dai_link->exit = mt8189_headset_codec_exit; |
| 1050 |
init_rt5682s = true; |
| 1051 |
} |
| 1052 |
} else if (!strcmp(dai_link->codecs->dai_name, RT5650_CODEC_DAI)) { |
| 1053 |
dai_link->ops = &mt8189_rtxxxx_i2s_ops; |
| 1054 |
if (!init_rt5650) { |
| 1055 |
dai_link->init = mt8189_headset_codec_init; |
| 1056 |
dai_link->exit = mt8189_headset_codec_exit; |
| 1057 |
init_rt5650 = true; |
| 1058 |
} |
| 1059 |
} else if (!strcmp(dai_link->codecs->dai_name, RT5682I_CODEC_DAI)) { |
| 1060 |
dai_link->ops = &mt8189_rtxxxx_i2s_ops; |
| 1061 |
if (!init_rt5682i) { |
| 1062 |
dai_link->init = mt8189_headset_codec_init; |
| 1063 |
dai_link->exit = mt8189_headset_codec_exit; |
| 1064 |
init_rt5682i = true; |
| 1065 |
} |
| 1066 |
} else if (!strcmp(dai_link->codecs->dai_name, ES8326_CODEC_DAI)) { |
| 1067 |
dai_link->ops = &mt8189_es8326_ops; |
| 1068 |
if (!init_es8326) { |
| 1069 |
dai_link->init = mt8189_headset_codec_init; |
| 1070 |
dai_link->exit = mt8189_headset_codec_exit; |
| 1071 |
init_es8326 = true; |
| 1072 |
} |
| 1073 |
} else { |
| 1074 |
if (strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) { |
| 1075 |
if (!init_dumb) { |
| 1076 |
dai_link->init = mt8189_dumb_amp_init; |
| 1077 |
init_dumb = true; |
| 1078 |
} |
| 1079 |
} |
| 1080 |
} |
| 1081 |
} else if (strcmp(dai_link->name, "I2SOUT1_BE") == 0) { |
| 1082 |
if (!strcmp(dai_link->codecs->dai_name, CS35L41_CODEC_DAI)) { |
| 1083 |
dai_link->ops = &mt8189_cs35l41_i2s_ops; |
| 1084 |
card->num_configs = ARRAY_SIZE(mt8189_cs35l41_codec_conf); |
| 1085 |
card->codec_conf = mt8189_cs35l41_codec_conf; |
| 1086 |
} |
| 1087 |
} |
| 1088 |
} |
| 1089 |
|
| 1090 |
return 0; |
| 1091 |
} |
| 1092 |
|
| 1093 |
static struct snd_soc_card mt8189_nau8825_soc_card = { |
| 1094 |
.owner = THIS_MODULE, |
| 1095 |
.dai_link = mt8189_nau8825_dai_links, |
| 1096 |
.num_links = ARRAY_SIZE(mt8189_nau8825_dai_links), |
| 1097 |
.dapm_widgets = mt8189_nau8825_card_widgets, |
| 1098 |
.num_dapm_widgets = ARRAY_SIZE(mt8189_nau8825_card_widgets), |
| 1099 |
}; |
| 1100 |
|
| 1101 |
static const struct mtk_soundcard_pdata mt8189_nau8825_card = { |
| 1102 |
.card_name = "mt8189_nau8825", |
| 1103 |
.card_data = &(struct mtk_platform_card_data) { |
| 1104 |
.card = &mt8189_nau8825_soc_card, |
| 1105 |
.num_jacks = MT8189_JACK_MAX, |
| 1106 |
.flags = NAU8825_HS_PRESENT |
| 1107 |
}, |
| 1108 |
.sof_priv = NULL, |
| 1109 |
.soc_probe = mt8189_nau8825_soc_card_probe, |
| 1110 |
}; |
| 1111 |
|
| 1112 |
static const struct mtk_soundcard_pdata mt8189_rt5650_card = { |
| 1113 |
.card_name = "mt8189_rt5650", |
| 1114 |
.card_data = &(struct mtk_platform_card_data) { |
| 1115 |
.card = &mt8189_nau8825_soc_card, |
| 1116 |
.num_jacks = MT8189_JACK_MAX, |
| 1117 |
.flags = RT5650_HS_PRESENT |
| 1118 |
}, |
| 1119 |
.sof_priv = NULL, |
| 1120 |
.soc_probe = mt8189_nau8825_soc_card_probe, |
| 1121 |
}; |
| 1122 |
|
| 1123 |
static const struct mtk_soundcard_pdata mt8189_rt5682s_card = { |
| 1124 |
.card_name = "mt8189_rt5682s", |
| 1125 |
.card_data = &(struct mtk_platform_card_data) { |
| 1126 |
.card = &mt8189_nau8825_soc_card, |
| 1127 |
.num_jacks = MT8189_JACK_MAX, |
| 1128 |
.flags = RT5682S_HS_PRESENT |
| 1129 |
}, |
| 1130 |
.sof_priv = NULL, |
| 1131 |
.soc_probe = mt8189_nau8825_soc_card_probe, |
| 1132 |
}; |
| 1133 |
|
| 1134 |
static const struct mtk_soundcard_pdata mt8189_rt5682i_card = { |
| 1135 |
.card_name = "mt8189_rt5682i", |
| 1136 |
.card_data = &(struct mtk_platform_card_data) { |
| 1137 |
.card = &mt8189_nau8825_soc_card, |
| 1138 |
.num_jacks = MT8189_JACK_MAX, |
| 1139 |
.flags = RT5682I_HS_PRESENT |
| 1140 |
}, |
| 1141 |
.sof_priv = NULL, |
| 1142 |
.soc_probe = mt8189_nau8825_soc_card_probe, |
| 1143 |
}; |
| 1144 |
|
| 1145 |
static const struct mtk_soundcard_pdata mt8188_es8326_card = { |
| 1146 |
.card_name = "mt8188_es8326", |
| 1147 |
.card_data = &(struct mtk_platform_card_data) { |
| 1148 |
.card = &mt8189_nau8825_soc_card, |
| 1149 |
.num_jacks = MT8189_JACK_MAX, |
| 1150 |
.flags = ES8326_HS_PRESENT |
| 1151 |
}, |
| 1152 |
.sof_priv = NULL, |
| 1153 |
.soc_probe = mt8189_nau8825_soc_card_probe, |
| 1154 |
}; |
| 1155 |
|
| 1156 |
static const struct of_device_id mt8189_nau8825_dt_match[] = { |
| 1157 |
{.compatible = "mediatek,mt8189-nau8825", .data = &mt8189_nau8825_card,}, |
| 1158 |
{.compatible = "mediatek,mt8189-rt5650", .data = &mt8189_rt5650_card,}, |
| 1159 |
{.compatible = "mediatek,mt8189-rt5682s", .data = &mt8189_rt5682s_card,}, |
| 1160 |
{.compatible = "mediatek,mt8189-rt5682i", .data = &mt8189_rt5682i_card,}, |
| 1161 |
{.compatible = "mediatek,mt8189-es8326", .data = &mt8188_es8326_card,}, |
| 1162 |
{} |
| 1163 |
}; |
| 1164 |
MODULE_DEVICE_TABLE(of, mt8189_nau8825_dt_match); |
| 1165 |
|
| 1166 |
static struct platform_driver mt8189_nau8825_driver = { |
| 1167 |
.driver = { |
| 1168 |
.name = "mt8189-nau8825", |
| 1169 |
.of_match_table = mt8189_nau8825_dt_match, |
| 1170 |
.pm = &snd_soc_pm_ops, |
| 1171 |
}, |
| 1172 |
.probe = mtk_soundcard_common_probe, |
| 1173 |
}; |
| 1174 |
module_platform_driver(mt8189_nau8825_driver); |
| 1175 |
|
| 1176 |
/* Module information */ |
| 1177 |
MODULE_DESCRIPTION("MT8189 NAU8825 ALSA SoC machine driver"); |
| 1178 |
MODULE_AUTHOR("Darren Ye <[email protected]>"); |
| 1179 |
MODULE_AUTHOR("Cyril Chao <[email protected]>"); |
| 1180 |
MODULE_LICENSE("GPL"); |