| 1 |
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ |
| 2 |
/* |
| 3 |
* This file is provided under a dual BSD/GPLv2 license. When using or |
| 4 |
* redistributing this file, you may do so under either license. |
| 5 |
* |
| 6 |
* Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved. |
| 7 |
* |
| 8 |
* Author: Ajit Kumar Pandey <[email protected]> |
| 9 |
*/ |
| 10 |
#ifndef __ACP_MACH_H |
| 11 |
#define __ACP_MACH_H |
| 12 |
|
| 13 |
#include <sound/core.h> |
| 14 |
#include <sound/jack.h> |
| 15 |
#include <sound/pcm_params.h> |
| 16 |
#include <sound/soc-dapm.h> |
| 17 |
#include <linux/input.h> |
| 18 |
#include <linux/module.h> |
| 19 |
#include <sound/soc.h> |
| 20 |
|
| 21 |
#include "acp_common.h" |
| 22 |
|
| 23 |
#define TDM_CHANNELS 8 |
| 24 |
|
| 25 |
#define ACP_OPS(priv, cb) ((priv)->ops.cb) |
| 26 |
|
| 27 |
#define acp_get_drvdata(card) ((struct acp_card_drvdata *)(card)->drvdata) |
| 28 |
|
| 29 |
/* List of DMI quirks - check acp-mach-common.c for usage. */ |
| 30 |
#define QUIRK_TDM_MODE_ENABLE 1 |
| 31 |
#define QUIRK_REMAP_DMIC_BT 2 |
| 32 |
|
| 33 |
enum be_id { |
| 34 |
HEADSET_BE_ID = 0, |
| 35 |
AMP_BE_ID, |
| 36 |
DMIC_BE_ID, |
| 37 |
BT_BE_ID, |
| 38 |
}; |
| 39 |
|
| 40 |
enum cpu_endpoints { |
| 41 |
NONE = 0, |
| 42 |
I2S_HS, |
| 43 |
I2S_SP, |
| 44 |
I2S_BT, |
| 45 |
DMIC, |
| 46 |
}; |
| 47 |
|
| 48 |
enum codec_endpoints { |
| 49 |
DUMMY = 0, |
| 50 |
RT5682, |
| 51 |
RT1019, |
| 52 |
MAX98360A, |
| 53 |
RT5682S, |
| 54 |
NAU8825, |
| 55 |
NAU8821, |
| 56 |
MAX98388, |
| 57 |
ES83XX, |
| 58 |
}; |
| 59 |
|
| 60 |
struct acp_mach_ops { |
| 61 |
int (*probe)(struct snd_soc_card *card); |
| 62 |
int (*configure_link)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); |
| 63 |
int (*configure_widgets)(struct snd_soc_card *card); |
| 64 |
int (*suspend_pre)(struct snd_soc_card *card); |
| 65 |
int (*resume_post)(struct snd_soc_card *card); |
| 66 |
}; |
| 67 |
|
| 68 |
struct acp_card_drvdata { |
| 69 |
unsigned int hs_cpu_id; |
| 70 |
unsigned int amp_cpu_id; |
| 71 |
unsigned int bt_cpu_id; |
| 72 |
unsigned int dmic_cpu_id; |
| 73 |
unsigned int hs_codec_id; |
| 74 |
unsigned int amp_codec_id; |
| 75 |
unsigned int bt_codec_id; |
| 76 |
unsigned int dmic_codec_id; |
| 77 |
unsigned int dai_fmt; |
| 78 |
unsigned int acp_rev; |
| 79 |
struct clk *wclk; |
| 80 |
struct clk *bclk; |
| 81 |
struct acp_mach_ops ops; |
| 82 |
struct snd_soc_acpi_mach *acpi_mach; |
| 83 |
void *mach_priv; |
| 84 |
bool soc_mclk; |
| 85 |
bool tdm_mode; |
| 86 |
}; |
| 87 |
|
| 88 |
int acp_sofdsp_dai_links_create(struct snd_soc_card *card); |
| 89 |
int acp_legacy_dai_links_create(struct snd_soc_card *card); |
| 90 |
extern const struct dmi_system_id acp_quirk_table[]; |
| 91 |
|
| 92 |
static inline int acp_ops_probe(struct snd_soc_card *card) |
| 93 |
{ |
| 94 |
int ret = 1; |
| 95 |
struct acp_card_drvdata *priv = acp_get_drvdata(card); |
| 96 |
|
| 97 |
if (ACP_OPS(priv, probe)) |
| 98 |
ret = ACP_OPS(priv, probe)(card); |
| 99 |
return ret; |
| 100 |
} |
| 101 |
|
| 102 |
static inline int acp_ops_configure_link(struct snd_soc_card *card, |
| 103 |
struct snd_soc_dai_link *dai_link) |
| 104 |
{ |
| 105 |
int ret = 1; |
| 106 |
struct acp_card_drvdata *priv = acp_get_drvdata(card); |
| 107 |
|
| 108 |
if (ACP_OPS(priv, configure_link)) |
| 109 |
ret = ACP_OPS(priv, configure_link)(card, dai_link); |
| 110 |
return ret; |
| 111 |
} |
| 112 |
|
| 113 |
static inline int acp_ops_configure_widgets(struct snd_soc_card *card) |
| 114 |
{ |
| 115 |
int ret = 1; |
| 116 |
struct acp_card_drvdata *priv = acp_get_drvdata(card); |
| 117 |
|
| 118 |
if (ACP_OPS(priv, configure_widgets)) |
| 119 |
ret = ACP_OPS(priv, configure_widgets)(card); |
| 120 |
return ret; |
| 121 |
} |
| 122 |
|
| 123 |
static inline int acp_ops_suspend_pre(struct snd_soc_card *card) |
| 124 |
{ |
| 125 |
int ret = 1; |
| 126 |
struct acp_card_drvdata *priv = acp_get_drvdata(card); |
| 127 |
|
| 128 |
if (ACP_OPS(priv, suspend_pre)) |
| 129 |
ret = ACP_OPS(priv, suspend_pre)(card); |
| 130 |
return ret; |
| 131 |
} |
| 132 |
|
| 133 |
static inline int acp_ops_resume_post(struct snd_soc_card *card) |
| 134 |
{ |
| 135 |
int ret = 1; |
| 136 |
struct acp_card_drvdata *priv = acp_get_drvdata(card); |
| 137 |
|
| 138 |
if (ACP_OPS(priv, resume_post)) |
| 139 |
ret = ACP_OPS(priv, resume_post)(card); |
| 140 |
return ret; |
| 141 |
} |
| 142 |
|
| 143 |
#endif |