mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
ASoC: qcom: x1e80100: Correct channel mapping
Merge series from Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>: X1E80100 CRD is the first board, which comes with four speakers, so we still keep fixing and adding missing pieces. The board has speaker arranged as left front+back and then right front+back. Using default channel mapping causes front right speaker to play left back stream. Adjust the channel maps for frontend DAIs to fix stereo and four-channel playback.
This commit is contained in:
commit
8a8554e646
@ -896,8 +896,8 @@ int cs35l41_test_key_lock(struct device *dev, struct regmap *regmap);
|
||||
int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap);
|
||||
int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsigned int reg_revid);
|
||||
int cs35l41_set_channels(struct device *dev, struct regmap *reg,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot);
|
||||
unsigned int tx_num, const unsigned int *tx_slot,
|
||||
unsigned int rx_num, const unsigned int *rx_slot);
|
||||
int cs35l41_gpio_config(struct regmap *regmap, struct cs35l41_hw_cfg *hw_cfg);
|
||||
void cs35l41_configure_cs_dsp(struct device *dev, struct regmap *reg, struct cs_dsp *dsp);
|
||||
int cs35l41_set_cspl_mbox_cmd(struct device *dev, struct regmap *regmap,
|
||||
|
@ -188,8 +188,8 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
|
||||
unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width);
|
||||
|
||||
int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot);
|
||||
unsigned int tx_num, const unsigned int *tx_slot,
|
||||
unsigned int rx_num, const unsigned int *rx_slot);
|
||||
|
||||
int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
|
||||
|
||||
@ -305,8 +305,8 @@ struct snd_soc_dai_ops {
|
||||
unsigned int tx_mask, unsigned int rx_mask,
|
||||
int slots, int slot_width);
|
||||
int (*set_channel_map)(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot);
|
||||
unsigned int tx_num, const unsigned int *tx_slot,
|
||||
unsigned int rx_num, const unsigned int *rx_slot);
|
||||
int (*get_channel_map)(struct snd_soc_dai *dai,
|
||||
unsigned int *tx_num, unsigned int *tx_slot,
|
||||
unsigned int *rx_num, unsigned int *rx_slot);
|
||||
|
@ -121,8 +121,10 @@ static const struct snd_soc_dapm_widget adau7118_widgets[] = {
|
||||
};
|
||||
|
||||
static int adau7118_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot)
|
||||
unsigned int tx_num,
|
||||
const unsigned int *tx_slot,
|
||||
unsigned int rx_num,
|
||||
const unsigned int *rx_slot)
|
||||
{
|
||||
struct adau7118_data *st =
|
||||
snd_soc_component_get_drvdata(dai->component);
|
||||
|
@ -936,8 +936,8 @@ int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsign
|
||||
EXPORT_SYMBOL_GPL(cs35l41_register_errata_patch);
|
||||
|
||||
int cs35l41_set_channels(struct device *dev, struct regmap *reg,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot)
|
||||
unsigned int tx_num, const unsigned int *tx_slot,
|
||||
unsigned int rx_num, const unsigned int *rx_slot)
|
||||
{
|
||||
unsigned int val, mask;
|
||||
int i;
|
||||
|
@ -673,7 +673,8 @@ static const struct snd_soc_dapm_route cs35l41_audio_map[] = {
|
||||
};
|
||||
|
||||
static int cs35l41_set_channel_map(struct snd_soc_dai *dai, unsigned int tx_n,
|
||||
unsigned int *tx_slot, unsigned int rx_n, unsigned int *rx_slot)
|
||||
const unsigned int *tx_slot,
|
||||
unsigned int rx_n, const unsigned int *rx_slot)
|
||||
{
|
||||
struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component);
|
||||
|
||||
|
@ -220,8 +220,10 @@ static int max98504_set_tdm_slot(struct snd_soc_dai *dai,
|
||||
return 0;
|
||||
}
|
||||
static int max98504_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot)
|
||||
unsigned int tx_num,
|
||||
const unsigned int *tx_slot,
|
||||
unsigned int rx_num,
|
||||
const unsigned int *rx_slot)
|
||||
{
|
||||
struct max98504_priv *max98504 = snd_soc_dai_get_drvdata(dai);
|
||||
struct regmap *map = max98504->regmap;
|
||||
|
@ -1983,8 +1983,10 @@ static int wcd9335_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||
}
|
||||
|
||||
static int wcd9335_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot)
|
||||
unsigned int tx_num,
|
||||
const unsigned int *tx_slot,
|
||||
unsigned int rx_num,
|
||||
const unsigned int *rx_slot)
|
||||
{
|
||||
struct wcd9335_codec *wcd;
|
||||
int i;
|
||||
|
@ -1923,8 +1923,10 @@ static int wcd934x_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||
}
|
||||
|
||||
static int wcd934x_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot)
|
||||
unsigned int tx_num,
|
||||
const unsigned int *tx_slot,
|
||||
unsigned int rx_num,
|
||||
const unsigned int *rx_slot)
|
||||
{
|
||||
struct wcd934x_codec *wcd;
|
||||
int i;
|
||||
|
@ -267,7 +267,7 @@ void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t token
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(audioreach_alloc_apm_cmd_pkt);
|
||||
|
||||
static void audioreach_set_channel_mapping(u8 *ch_map, int num_channels)
|
||||
void audioreach_set_default_channel_mapping(u8 *ch_map, int num_channels)
|
||||
{
|
||||
if (num_channels == 1) {
|
||||
ch_map[0] = PCM_CHANNEL_FL;
|
||||
@ -281,6 +281,7 @@ static void audioreach_set_channel_mapping(u8 *ch_map, int num_channels)
|
||||
ch_map[3] = PCM_CHANNEL_RS;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(audioreach_set_default_channel_mapping);
|
||||
|
||||
static void apm_populate_container_config(struct apm_container_obj *cfg,
|
||||
struct audioreach_container *cont)
|
||||
@ -819,7 +820,7 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
|
||||
uint32_t num_channels = cfg->num_channels;
|
||||
int payload_size;
|
||||
struct gpr_pkt *pkt;
|
||||
int rc;
|
||||
int rc, i;
|
||||
void *p;
|
||||
|
||||
payload_size = APM_MFC_CFG_PSIZE(media_format, num_channels) +
|
||||
@ -842,18 +843,8 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
|
||||
media_format->sample_rate = cfg->sample_rate;
|
||||
media_format->bit_width = cfg->bit_width;
|
||||
media_format->num_channels = cfg->num_channels;
|
||||
|
||||
if (num_channels == 1) {
|
||||
media_format->channel_mapping[0] = PCM_CHANNEL_FL;
|
||||
} else if (num_channels == 2) {
|
||||
media_format->channel_mapping[0] = PCM_CHANNEL_FL;
|
||||
media_format->channel_mapping[1] = PCM_CHANNEL_FR;
|
||||
} else if (num_channels == 4) {
|
||||
media_format->channel_mapping[0] = PCM_CHANNEL_FL;
|
||||
media_format->channel_mapping[1] = PCM_CHANNEL_FR;
|
||||
media_format->channel_mapping[2] = PCM_CHANNEL_LS;
|
||||
media_format->channel_mapping[3] = PCM_CHANNEL_RS;
|
||||
}
|
||||
for (i = 0; i < num_channels; i++)
|
||||
media_format->channel_mapping[i] = cfg->channel_map[i];
|
||||
|
||||
rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
|
||||
|
||||
@ -883,9 +874,6 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr,
|
||||
mp3_cfg->q_factor = mcfg->bit_width - 1;
|
||||
mp3_cfg->endianness = PCM_LITTLE_ENDIAN;
|
||||
mp3_cfg->num_channels = mcfg->num_channels;
|
||||
|
||||
audioreach_set_channel_mapping(mp3_cfg->channel_mapping,
|
||||
mcfg->num_channels);
|
||||
break;
|
||||
case SND_AUDIOCODEC_AAC:
|
||||
media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED;
|
||||
@ -1104,9 +1092,7 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph,
|
||||
media_cfg->num_channels = mcfg->num_channels;
|
||||
media_cfg->q_factor = mcfg->bit_width - 1;
|
||||
media_cfg->bits_per_sample = mcfg->bit_width;
|
||||
|
||||
audioreach_set_channel_mapping(media_cfg->channel_mapping,
|
||||
num_channels);
|
||||
memcpy(media_cfg->channel_mapping, mcfg->channel_map, mcfg->num_channels);
|
||||
|
||||
rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
|
||||
|
||||
@ -1163,9 +1149,7 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph,
|
||||
cfg->q_factor = mcfg->bit_width - 1;
|
||||
cfg->endianness = PCM_LITTLE_ENDIAN;
|
||||
cfg->num_channels = mcfg->num_channels;
|
||||
|
||||
audioreach_set_channel_mapping(cfg->channel_mapping,
|
||||
num_channels);
|
||||
memcpy(cfg->channel_mapping, mcfg->channel_map, mcfg->num_channels);
|
||||
} else {
|
||||
rc = audioreach_set_compr_media_format(header, p, mcfg);
|
||||
if (rc) {
|
||||
|
@ -755,7 +755,6 @@ struct audioreach_module_config {
|
||||
|
||||
u16 data_format;
|
||||
u16 num_channels;
|
||||
u16 active_channels_mask;
|
||||
u16 dp_idx;
|
||||
u32 channel_allocation;
|
||||
u32 sd_line_mask;
|
||||
@ -767,6 +766,7 @@ struct audioreach_module_config {
|
||||
/* Packet Allocation routines */
|
||||
void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t
|
||||
token);
|
||||
void audioreach_set_default_channel_mapping(u8 *ch_map, int num_channels);
|
||||
void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode,
|
||||
uint32_t token, uint32_t src_port,
|
||||
uint32_t dest_port);
|
||||
|
@ -172,8 +172,8 @@ static int q6tdm_set_tdm_slot(struct snd_soc_dai *dai,
|
||||
}
|
||||
|
||||
static int q6tdm_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot)
|
||||
unsigned int tx_num, const unsigned int *tx_slot,
|
||||
unsigned int rx_num, const unsigned int *rx_slot)
|
||||
{
|
||||
|
||||
struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
|
||||
@ -250,8 +250,10 @@ static int q6tdm_hw_params(struct snd_pcm_substream *substream,
|
||||
}
|
||||
|
||||
static int q6dma_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_ch_mask,
|
||||
unsigned int rx_num, unsigned int *rx_ch_mask)
|
||||
unsigned int tx_num,
|
||||
const unsigned int *tx_ch_mask,
|
||||
unsigned int rx_num,
|
||||
const unsigned int *rx_ch_mask)
|
||||
{
|
||||
|
||||
struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
|
||||
@ -407,8 +409,10 @@ static int q6afe_dai_prepare(struct snd_pcm_substream *substream,
|
||||
}
|
||||
|
||||
static int q6slim_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot)
|
||||
unsigned int tx_num,
|
||||
const unsigned int *tx_slot,
|
||||
unsigned int rx_num,
|
||||
const unsigned int *rx_slot)
|
||||
{
|
||||
struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
|
||||
struct q6afe_port_config *pcfg = &dai_data->port_config[dai->id];
|
||||
|
@ -239,6 +239,7 @@ static int q6apm_dai_prepare(struct snd_soc_component *component,
|
||||
cfg.num_channels = runtime->channels;
|
||||
cfg.bit_width = prtd->bits_per_sample;
|
||||
cfg.fmt = SND_AUDIOCODEC_PCM;
|
||||
audioreach_set_default_channel_mapping(cfg.channel_map, runtime->channels);
|
||||
|
||||
if (prtd->state) {
|
||||
/* clear the previous setup if any */
|
||||
@ -665,6 +666,8 @@ static int q6apm_dai_compr_set_params(struct snd_soc_component *component,
|
||||
cfg.num_channels = 2;
|
||||
cfg.bit_width = prtd->bits_per_sample;
|
||||
cfg.fmt = codec->id;
|
||||
audioreach_set_default_channel_mapping(cfg.channel_map,
|
||||
cfg.num_channels);
|
||||
memcpy(&cfg.codec, codec, sizeof(*codec));
|
||||
|
||||
ret = q6apm_graph_media_format_shmem(prtd->graph, &cfg);
|
||||
|
@ -25,13 +25,15 @@ struct q6apm_lpass_dai_data {
|
||||
};
|
||||
|
||||
static int q6dma_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_ch_mask,
|
||||
unsigned int rx_num, unsigned int *rx_ch_mask)
|
||||
unsigned int tx_num,
|
||||
const unsigned int *tx_ch_mask,
|
||||
unsigned int rx_num,
|
||||
const unsigned int *rx_ch_mask)
|
||||
{
|
||||
|
||||
struct q6apm_lpass_dai_data *dai_data = dev_get_drvdata(dai->dev);
|
||||
struct audioreach_module_config *cfg = &dai_data->module_config[dai->id];
|
||||
int ch_mask;
|
||||
int i;
|
||||
|
||||
switch (dai->id) {
|
||||
case WSA_CODEC_DMA_TX_0:
|
||||
@ -56,7 +58,8 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai,
|
||||
tx_num);
|
||||
return -EINVAL;
|
||||
}
|
||||
ch_mask = *tx_ch_mask;
|
||||
for (i = 0; i < tx_num; i++)
|
||||
cfg->channel_map[i] = tx_ch_mask[i];
|
||||
|
||||
break;
|
||||
case WSA_CODEC_DMA_RX_0:
|
||||
@ -79,7 +82,8 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai,
|
||||
rx_num);
|
||||
return -EINVAL;
|
||||
}
|
||||
ch_mask = *rx_ch_mask;
|
||||
for (i = 0; i < rx_num; i++)
|
||||
cfg->channel_map[i] = rx_ch_mask[i];
|
||||
|
||||
break;
|
||||
default:
|
||||
@ -88,8 +92,6 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cfg->active_channels_mask = ch_mask;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -104,6 +106,7 @@ static int q6hdmi_hw_params(struct snd_pcm_substream *substream,
|
||||
cfg->bit_width = params_width(params);
|
||||
cfg->sample_rate = params_rate(params);
|
||||
cfg->num_channels = channels;
|
||||
audioreach_set_default_channel_mapping(cfg->channel_map, channels);
|
||||
|
||||
switch (dai->id) {
|
||||
case DISPLAY_PORT_RX_0:
|
||||
@ -128,10 +131,12 @@ static int q6dma_hw_params(struct snd_pcm_substream *substream,
|
||||
{
|
||||
struct q6apm_lpass_dai_data *dai_data = dev_get_drvdata(dai->dev);
|
||||
struct audioreach_module_config *cfg = &dai_data->module_config[dai->id];
|
||||
int channels = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max;
|
||||
|
||||
cfg->bit_width = params_width(params);
|
||||
cfg->sample_rate = params_rate(params);
|
||||
cfg->num_channels = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max;
|
||||
cfg->num_channels = channels;
|
||||
audioreach_set_default_channel_mapping(cfg->channel_map, channels);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "qdsp6/q6afe.h"
|
||||
#include "qdsp6/q6dsp-common.h"
|
||||
#include "sdw.h"
|
||||
|
||||
struct x1e80100_snd_data {
|
||||
@ -80,6 +81,23 @@ static int x1e80100_snd_prepare(struct snd_pcm_substream *substream)
|
||||
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
|
||||
struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id];
|
||||
const unsigned int rx_slot[4] = { PCM_CHANNEL_FL,
|
||||
PCM_CHANNEL_LB,
|
||||
PCM_CHANNEL_FR,
|
||||
PCM_CHANNEL_RB };
|
||||
int ret;
|
||||
|
||||
switch (cpu_dai->id) {
|
||||
case WSA_CODEC_DMA_RX_0:
|
||||
case WSA_CODEC_DMA_RX_1:
|
||||
ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
|
||||
ARRAY_SIZE(rx_slot), rx_slot);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return qcom_snd_sdw_prepare(substream, sruntime,
|
||||
&data->stream_prepared[cpu_dai->id]);
|
||||
|
@ -304,8 +304,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot);
|
||||
* configure the relationship between channel number and TDM slot number.
|
||||
*/
|
||||
int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
|
||||
unsigned int tx_num, unsigned int *tx_slot,
|
||||
unsigned int rx_num, unsigned int *rx_slot)
|
||||
unsigned int tx_num, const unsigned int *tx_slot,
|
||||
unsigned int rx_num, const unsigned int *rx_slot)
|
||||
{
|
||||
int ret = -ENOTSUPP;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user