Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

+80 -57
+2 -2
include/sound/cs35l41.h
··· 896 896 int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap); 897 897 int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsigned int reg_revid); 898 898 int cs35l41_set_channels(struct device *dev, struct regmap *reg, 899 - unsigned int tx_num, unsigned int *tx_slot, 900 - unsigned int rx_num, unsigned int *rx_slot); 899 + unsigned int tx_num, const unsigned int *tx_slot, 900 + unsigned int rx_num, const unsigned int *rx_slot); 901 901 int cs35l41_gpio_config(struct regmap *regmap, struct cs35l41_hw_cfg *hw_cfg); 902 902 void cs35l41_configure_cs_dsp(struct device *dev, struct regmap *reg, struct cs_dsp *dsp); 903 903 int cs35l41_set_cspl_mbox_cmd(struct device *dev, struct regmap *regmap,
+4 -4
include/sound/soc-dai.h
··· 188 188 unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width); 189 189 190 190 int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai, 191 - unsigned int tx_num, unsigned int *tx_slot, 192 - unsigned int rx_num, unsigned int *rx_slot); 191 + unsigned int tx_num, const unsigned int *tx_slot, 192 + unsigned int rx_num, const unsigned int *rx_slot); 193 193 194 194 int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate); 195 195 ··· 305 305 unsigned int tx_mask, unsigned int rx_mask, 306 306 int slots, int slot_width); 307 307 int (*set_channel_map)(struct snd_soc_dai *dai, 308 - unsigned int tx_num, unsigned int *tx_slot, 309 - unsigned int rx_num, unsigned int *rx_slot); 308 + unsigned int tx_num, const unsigned int *tx_slot, 309 + unsigned int rx_num, const unsigned int *rx_slot); 310 310 int (*get_channel_map)(struct snd_soc_dai *dai, 311 311 unsigned int *tx_num, unsigned int *tx_slot, 312 312 unsigned int *rx_num, unsigned int *rx_slot);
+4 -2
sound/soc/codecs/adau7118.c
··· 121 121 }; 122 122 123 123 static int adau7118_set_channel_map(struct snd_soc_dai *dai, 124 - unsigned int tx_num, unsigned int *tx_slot, 125 - unsigned int rx_num, unsigned int *rx_slot) 124 + unsigned int tx_num, 125 + const unsigned int *tx_slot, 126 + unsigned int rx_num, 127 + const unsigned int *rx_slot) 126 128 { 127 129 struct adau7118_data *st = 128 130 snd_soc_component_get_drvdata(dai->component);
+2 -2
sound/soc/codecs/cs35l41-lib.c
··· 936 936 EXPORT_SYMBOL_GPL(cs35l41_register_errata_patch); 937 937 938 938 int cs35l41_set_channels(struct device *dev, struct regmap *reg, 939 - unsigned int tx_num, unsigned int *tx_slot, 940 - unsigned int rx_num, unsigned int *rx_slot) 939 + unsigned int tx_num, const unsigned int *tx_slot, 940 + unsigned int rx_num, const unsigned int *rx_slot) 941 941 { 942 942 unsigned int val, mask; 943 943 int i;
+2 -1
sound/soc/codecs/cs35l41.c
··· 673 673 }; 674 674 675 675 static int cs35l41_set_channel_map(struct snd_soc_dai *dai, unsigned int tx_n, 676 - unsigned int *tx_slot, unsigned int rx_n, unsigned int *rx_slot) 676 + const unsigned int *tx_slot, 677 + unsigned int rx_n, const unsigned int *rx_slot) 677 678 { 678 679 struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); 679 680
+4 -2
sound/soc/codecs/max98504.c
··· 220 220 return 0; 221 221 } 222 222 static int max98504_set_channel_map(struct snd_soc_dai *dai, 223 - unsigned int tx_num, unsigned int *tx_slot, 224 - unsigned int rx_num, unsigned int *rx_slot) 223 + unsigned int tx_num, 224 + const unsigned int *tx_slot, 225 + unsigned int rx_num, 226 + const unsigned int *rx_slot) 225 227 { 226 228 struct max98504_priv *max98504 = snd_soc_dai_get_drvdata(dai); 227 229 struct regmap *map = max98504->regmap;
+4 -2
sound/soc/codecs/wcd9335.c
··· 1983 1983 } 1984 1984 1985 1985 static int wcd9335_set_channel_map(struct snd_soc_dai *dai, 1986 - unsigned int tx_num, unsigned int *tx_slot, 1987 - unsigned int rx_num, unsigned int *rx_slot) 1986 + unsigned int tx_num, 1987 + const unsigned int *tx_slot, 1988 + unsigned int rx_num, 1989 + const unsigned int *rx_slot) 1988 1990 { 1989 1991 struct wcd9335_codec *wcd; 1990 1992 int i;
+4 -2
sound/soc/codecs/wcd934x.c
··· 1923 1923 } 1924 1924 1925 1925 static int wcd934x_set_channel_map(struct snd_soc_dai *dai, 1926 - unsigned int tx_num, unsigned int *tx_slot, 1927 - unsigned int rx_num, unsigned int *rx_slot) 1926 + unsigned int tx_num, 1927 + const unsigned int *tx_slot, 1928 + unsigned int rx_num, 1929 + const unsigned int *rx_slot) 1928 1930 { 1929 1931 struct wcd934x_codec *wcd; 1930 1932 int i;
+7 -23
sound/soc/qcom/qdsp6/audioreach.c
··· 267 267 } 268 268 EXPORT_SYMBOL_GPL(audioreach_alloc_apm_cmd_pkt); 269 269 270 - static void audioreach_set_channel_mapping(u8 *ch_map, int num_channels) 270 + void audioreach_set_default_channel_mapping(u8 *ch_map, int num_channels) 271 271 { 272 272 if (num_channels == 1) { 273 273 ch_map[0] = PCM_CHANNEL_FL; ··· 281 281 ch_map[3] = PCM_CHANNEL_RS; 282 282 } 283 283 } 284 + EXPORT_SYMBOL_GPL(audioreach_set_default_channel_mapping); 284 285 285 286 static void apm_populate_container_config(struct apm_container_obj *cfg, 286 287 struct audioreach_container *cont) ··· 820 819 uint32_t num_channels = cfg->num_channels; 821 820 int payload_size; 822 821 struct gpr_pkt *pkt; 823 - int rc; 822 + int rc, i; 824 823 void *p; 825 824 826 825 payload_size = APM_MFC_CFG_PSIZE(media_format, num_channels) + ··· 843 842 media_format->sample_rate = cfg->sample_rate; 844 843 media_format->bit_width = cfg->bit_width; 845 844 media_format->num_channels = cfg->num_channels; 846 - 847 - if (num_channels == 1) { 848 - media_format->channel_mapping[0] = PCM_CHANNEL_FL; 849 - } else if (num_channels == 2) { 850 - media_format->channel_mapping[0] = PCM_CHANNEL_FL; 851 - media_format->channel_mapping[1] = PCM_CHANNEL_FR; 852 - } else if (num_channels == 4) { 853 - media_format->channel_mapping[0] = PCM_CHANNEL_FL; 854 - media_format->channel_mapping[1] = PCM_CHANNEL_FR; 855 - media_format->channel_mapping[2] = PCM_CHANNEL_LS; 856 - media_format->channel_mapping[3] = PCM_CHANNEL_RS; 857 - } 845 + for (i = 0; i < num_channels; i++) 846 + media_format->channel_mapping[i] = cfg->channel_map[i]; 858 847 859 848 rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); 860 849 ··· 874 883 mp3_cfg->q_factor = mcfg->bit_width - 1; 875 884 mp3_cfg->endianness = PCM_LITTLE_ENDIAN; 876 885 mp3_cfg->num_channels = mcfg->num_channels; 877 - 878 - audioreach_set_channel_mapping(mp3_cfg->channel_mapping, 879 - mcfg->num_channels); 880 886 break; 881 887 case SND_AUDIOCODEC_AAC: 882 888 media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED; ··· 1092 1104 media_cfg->num_channels = mcfg->num_channels; 1093 1105 media_cfg->q_factor = mcfg->bit_width - 1; 1094 1106 media_cfg->bits_per_sample = mcfg->bit_width; 1095 - 1096 - audioreach_set_channel_mapping(media_cfg->channel_mapping, 1097 - num_channels); 1107 + memcpy(media_cfg->channel_mapping, mcfg->channel_map, mcfg->num_channels); 1098 1108 1099 1109 rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); 1100 1110 ··· 1149 1163 cfg->q_factor = mcfg->bit_width - 1; 1150 1164 cfg->endianness = PCM_LITTLE_ENDIAN; 1151 1165 cfg->num_channels = mcfg->num_channels; 1152 - 1153 - audioreach_set_channel_mapping(cfg->channel_mapping, 1154 - num_channels); 1166 + memcpy(cfg->channel_mapping, mcfg->channel_map, mcfg->num_channels); 1155 1167 } else { 1156 1168 rc = audioreach_set_compr_media_format(header, p, mcfg); 1157 1169 if (rc) {
+1 -1
sound/soc/qcom/qdsp6/audioreach.h
··· 755 755 756 756 u16 data_format; 757 757 u16 num_channels; 758 - u16 active_channels_mask; 759 758 u16 dp_idx; 760 759 u32 channel_allocation; 761 760 u32 sd_line_mask; ··· 766 767 /* Packet Allocation routines */ 767 768 void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t 768 769 token); 770 + void audioreach_set_default_channel_mapping(u8 *ch_map, int num_channels); 769 771 void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode, 770 772 uint32_t token, uint32_t src_port, 771 773 uint32_t dest_port);
+10 -6
sound/soc/qcom/qdsp6/q6afe-dai.c
··· 172 172 } 173 173 174 174 static int q6tdm_set_channel_map(struct snd_soc_dai *dai, 175 - unsigned int tx_num, unsigned int *tx_slot, 176 - unsigned int rx_num, unsigned int *rx_slot) 175 + unsigned int tx_num, const unsigned int *tx_slot, 176 + unsigned int rx_num, const unsigned int *rx_slot) 177 177 { 178 178 179 179 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); ··· 250 250 } 251 251 252 252 static int q6dma_set_channel_map(struct snd_soc_dai *dai, 253 - unsigned int tx_num, unsigned int *tx_ch_mask, 254 - unsigned int rx_num, unsigned int *rx_ch_mask) 253 + unsigned int tx_num, 254 + const unsigned int *tx_ch_mask, 255 + unsigned int rx_num, 256 + const unsigned int *rx_ch_mask) 255 257 { 256 258 257 259 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); ··· 409 407 } 410 408 411 409 static int q6slim_set_channel_map(struct snd_soc_dai *dai, 412 - unsigned int tx_num, unsigned int *tx_slot, 413 - unsigned int rx_num, unsigned int *rx_slot) 410 + unsigned int tx_num, 411 + const unsigned int *tx_slot, 412 + unsigned int rx_num, 413 + const unsigned int *rx_slot) 414 414 { 415 415 struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); 416 416 struct q6afe_port_config *pcfg = &dai_data->port_config[dai->id];
+3
sound/soc/qcom/qdsp6/q6apm-dai.c
··· 239 239 cfg.num_channels = runtime->channels; 240 240 cfg.bit_width = prtd->bits_per_sample; 241 241 cfg.fmt = SND_AUDIOCODEC_PCM; 242 + audioreach_set_default_channel_mapping(cfg.channel_map, runtime->channels); 242 243 243 244 if (prtd->state) { 244 245 /* clear the previous setup if any */ ··· 666 665 cfg.num_channels = 2; 667 666 cfg.bit_width = prtd->bits_per_sample; 668 667 cfg.fmt = codec->id; 668 + audioreach_set_default_channel_mapping(cfg.channel_map, 669 + cfg.num_channels); 669 670 memcpy(&cfg.codec, codec, sizeof(*codec)); 670 671 671 672 ret = q6apm_graph_media_format_shmem(prtd->graph, &cfg);
+13 -8
sound/soc/qcom/qdsp6/q6apm-lpass-dais.c
··· 25 25 }; 26 26 27 27 static int q6dma_set_channel_map(struct snd_soc_dai *dai, 28 - unsigned int tx_num, unsigned int *tx_ch_mask, 29 - unsigned int rx_num, unsigned int *rx_ch_mask) 28 + unsigned int tx_num, 29 + const unsigned int *tx_ch_mask, 30 + unsigned int rx_num, 31 + const unsigned int *rx_ch_mask) 30 32 { 31 33 32 34 struct q6apm_lpass_dai_data *dai_data = dev_get_drvdata(dai->dev); 33 35 struct audioreach_module_config *cfg = &dai_data->module_config[dai->id]; 34 - int ch_mask; 36 + int i; 35 37 36 38 switch (dai->id) { 37 39 case WSA_CODEC_DMA_TX_0: ··· 58 56 tx_num); 59 57 return -EINVAL; 60 58 } 61 - ch_mask = *tx_ch_mask; 59 + for (i = 0; i < tx_num; i++) 60 + cfg->channel_map[i] = tx_ch_mask[i]; 62 61 63 62 break; 64 63 case WSA_CODEC_DMA_RX_0: ··· 82 79 rx_num); 83 80 return -EINVAL; 84 81 } 85 - ch_mask = *rx_ch_mask; 82 + for (i = 0; i < rx_num; i++) 83 + cfg->channel_map[i] = rx_ch_mask[i]; 86 84 87 85 break; 88 86 default: ··· 91 87 __func__, dai->id); 92 88 return -EINVAL; 93 89 } 94 - 95 - cfg->active_channels_mask = ch_mask; 96 90 97 91 return 0; 98 92 } ··· 106 104 cfg->bit_width = params_width(params); 107 105 cfg->sample_rate = params_rate(params); 108 106 cfg->num_channels = channels; 107 + audioreach_set_default_channel_mapping(cfg->channel_map, channels); 109 108 110 109 switch (dai->id) { 111 110 case DISPLAY_PORT_RX_0: ··· 131 128 { 132 129 struct q6apm_lpass_dai_data *dai_data = dev_get_drvdata(dai->dev); 133 130 struct audioreach_module_config *cfg = &dai_data->module_config[dai->id]; 131 + int channels = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max; 134 132 135 133 cfg->bit_width = params_width(params); 136 134 cfg->sample_rate = params_rate(params); 137 - cfg->num_channels = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max; 135 + cfg->num_channels = channels; 136 + audioreach_set_default_channel_mapping(cfg->channel_map, channels); 138 137 139 138 return 0; 140 139 }
+18
sound/soc/qcom/x1e80100.c
··· 12 12 13 13 #include "common.h" 14 14 #include "qdsp6/q6afe.h" 15 + #include "qdsp6/q6dsp-common.h" 15 16 #include "sdw.h" 16 17 17 18 struct x1e80100_snd_data { ··· 81 80 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 82 81 struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 83 82 struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; 83 + const unsigned int rx_slot[4] = { PCM_CHANNEL_FL, 84 + PCM_CHANNEL_LB, 85 + PCM_CHANNEL_FR, 86 + PCM_CHANNEL_RB }; 87 + int ret; 88 + 89 + switch (cpu_dai->id) { 90 + case WSA_CODEC_DMA_RX_0: 91 + case WSA_CODEC_DMA_RX_1: 92 + ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, 93 + ARRAY_SIZE(rx_slot), rx_slot); 94 + if (ret) 95 + return ret; 96 + break; 97 + default: 98 + break; 99 + } 84 100 85 101 return qcom_snd_sdw_prepare(substream, sruntime, 86 102 &data->stream_prepared[cpu_dai->id]);
+2 -2
sound/soc/soc-dai.c
··· 304 304 * configure the relationship between channel number and TDM slot number. 305 305 */ 306 306 int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai, 307 - unsigned int tx_num, unsigned int *tx_slot, 308 - unsigned int rx_num, unsigned int *rx_slot) 307 + unsigned int tx_num, const unsigned int *tx_slot, 308 + unsigned int rx_num, const unsigned int *rx_slot) 309 309 { 310 310 int ret = -ENOTSUPP; 311 311