cs35l56.c (6f47c7ae8c7afaf9ad291d39f0d3974f191a7946) | cs35l56.c (5d7e328e20b3d2bd3e1e8bea7a868ab8892aeed1) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2// 3// Driver for Cirrus Logic CS35L56 smart amp 4// 5// Copyright (C) 2023 Cirrus Logic, Inc. and 6// Cirrus Logic International Semiconductor Ltd. 7 8#include <linux/acpi.h> | 1// SPDX-License-Identifier: GPL-2.0-only 2// 3// Driver for Cirrus Logic CS35L56 smart amp 4// 5// Copyright (C) 2023 Cirrus Logic, Inc. and 6// Cirrus Logic International Semiconductor Ltd. 7 8#include <linux/acpi.h> |
9#include <linux/array_size.h> |
|
9#include <linux/completion.h> 10#include <linux/debugfs.h> 11#include <linux/delay.h> 12#include <linux/err.h> 13#include <linux/gpio/consumer.h> 14#include <linux/interrupt.h> 15#include <linux/math.h> 16#include <linux/module.h> --- 40 unchanged lines hidden (view full) --- 57{ 58 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); 59 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); 60 61 cs35l56_wait_dsp_ready(cs35l56); 62 return snd_soc_put_volsw(kcontrol, ucontrol); 63} 64 | 10#include <linux/completion.h> 11#include <linux/debugfs.h> 12#include <linux/delay.h> 13#include <linux/err.h> 14#include <linux/gpio/consumer.h> 15#include <linux/interrupt.h> 16#include <linux/math.h> 17#include <linux/module.h> --- 40 unchanged lines hidden (view full) --- 58{ 59 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); 60 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); 61 62 cs35l56_wait_dsp_ready(cs35l56); 63 return snd_soc_put_volsw(kcontrol, ucontrol); 64} 65 |
65static const unsigned short cs35l56_asp1_mixer_regs[] = { 66 CS35L56_ASP1TX1_INPUT, CS35L56_ASP1TX2_INPUT, 67 CS35L56_ASP1TX3_INPUT, CS35L56_ASP1TX4_INPUT, 68}; 69 70static const char * const cs35l56_asp1_mux_control_names[] = { 71 "ASP1 TX1 Source", "ASP1 TX2 Source", "ASP1 TX3 Source", "ASP1 TX4 Source" 72}; 73 74static int cs35l56_sync_asp1_mixer_widgets_with_firmware(struct cs35l56_private *cs35l56) 75{ 76 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cs35l56->component); 77 const char *prefix = cs35l56->component->name_prefix; 78 char full_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 79 const char *name; 80 struct snd_kcontrol *kcontrol; 81 struct soc_enum *e; 82 unsigned int val[4]; 83 int i, item, ret; 84 85 if (cs35l56->asp1_mixer_widgets_initialized) 86 return 0; 87 88 /* 89 * Resume so we can read the registers from silicon if the regmap 90 * cache has not yet been populated. 91 */ 92 ret = pm_runtime_resume_and_get(cs35l56->base.dev); 93 if (ret < 0) 94 return ret; 95 96 /* Wait for firmware download and reboot */ 97 cs35l56_wait_dsp_ready(cs35l56); 98 99 ret = regmap_bulk_read(cs35l56->base.regmap, CS35L56_ASP1TX1_INPUT, 100 val, ARRAY_SIZE(val)); 101 102 pm_runtime_mark_last_busy(cs35l56->base.dev); 103 pm_runtime_put_autosuspend(cs35l56->base.dev); 104 105 if (ret) { 106 dev_err(cs35l56->base.dev, "Failed to read ASP1 mixer regs: %d\n", ret); 107 return ret; 108 } 109 110 for (i = 0; i < ARRAY_SIZE(cs35l56_asp1_mux_control_names); ++i) { 111 name = cs35l56_asp1_mux_control_names[i]; 112 113 if (prefix) { 114 snprintf(full_name, sizeof(full_name), "%s %s", prefix, name); 115 name = full_name; 116 } 117 118 kcontrol = snd_soc_card_get_kcontrol_locked(dapm->card, name); 119 if (!kcontrol) { 120 dev_warn(cs35l56->base.dev, "Could not find control %s\n", name); 121 continue; 122 } 123 124 e = (struct soc_enum *)kcontrol->private_value; 125 item = snd_soc_enum_val_to_item(e, val[i] & CS35L56_ASP_TXn_SRC_MASK); 126 snd_soc_dapm_mux_update_power(dapm, kcontrol, item, e, NULL); 127 } 128 129 cs35l56->asp1_mixer_widgets_initialized = true; 130 131 return 0; 132} 133 134static int cs35l56_dspwait_asp1tx_get(struct snd_kcontrol *kcontrol, 135 struct snd_ctl_elem_value *ucontrol) 136{ 137 struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); 138 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); 139 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 140 int index = e->shift_l; 141 unsigned int addr, val; 142 int ret; 143 144 ret = cs35l56_sync_asp1_mixer_widgets_with_firmware(cs35l56); 145 if (ret) 146 return ret; 147 148 addr = cs35l56_asp1_mixer_regs[index]; 149 ret = regmap_read(cs35l56->base.regmap, addr, &val); 150 if (ret) 151 return ret; 152 153 val &= CS35L56_ASP_TXn_SRC_MASK; 154 ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val); 155 156 return 0; 157} 158 159static int cs35l56_dspwait_asp1tx_put(struct snd_kcontrol *kcontrol, 160 struct snd_ctl_elem_value *ucontrol) 161{ 162 struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); 163 struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); 164 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); 165 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 166 int item = ucontrol->value.enumerated.item[0]; 167 int index = e->shift_l; 168 unsigned int addr, val; 169 bool changed; 170 int ret; 171 172 ret = cs35l56_sync_asp1_mixer_widgets_with_firmware(cs35l56); 173 if (ret) 174 return ret; 175 176 addr = cs35l56_asp1_mixer_regs[index]; 177 val = snd_soc_enum_item_to_val(e, item); 178 179 ret = regmap_update_bits_check(cs35l56->base.regmap, addr, 180 CS35L56_ASP_TXn_SRC_MASK, val, &changed); 181 if (ret) 182 return ret; 183 184 if (changed) 185 snd_soc_dapm_mux_update_power(dapm, kcontrol, item, e, NULL); 186 187 return changed; 188} 189 | |
190static DECLARE_TLV_DB_SCALE(vol_tlv, -10000, 25, 0); 191 192static const struct snd_kcontrol_new cs35l56_controls[] = { 193 SOC_SINGLE_EXT("Speaker Switch", 194 CS35L56_MAIN_RENDER_USER_MUTE, 0, 1, 1, 195 cs35l56_dspwait_get_volsw, cs35l56_dspwait_put_volsw), 196 SOC_SINGLE_S_EXT_TLV("Speaker Volume", 197 CS35L56_MAIN_RENDER_USER_VOLUME, 198 6, -400, 400, 9, 0, 199 cs35l56_dspwait_get_volsw, 200 cs35l56_dspwait_put_volsw, 201 vol_tlv), 202 SOC_SINGLE_EXT("Posture Number", CS35L56_MAIN_POSTURE_NUMBER, 203 0, 255, 0, 204 cs35l56_dspwait_get_volsw, cs35l56_dspwait_put_volsw), 205}; 206 207static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx1_enum, | 66static DECLARE_TLV_DB_SCALE(vol_tlv, -10000, 25, 0); 67 68static const struct snd_kcontrol_new cs35l56_controls[] = { 69 SOC_SINGLE_EXT("Speaker Switch", 70 CS35L56_MAIN_RENDER_USER_MUTE, 0, 1, 1, 71 cs35l56_dspwait_get_volsw, cs35l56_dspwait_put_volsw), 72 SOC_SINGLE_S_EXT_TLV("Speaker Volume", 73 CS35L56_MAIN_RENDER_USER_VOLUME, 74 6, -400, 400, 9, 0, 75 cs35l56_dspwait_get_volsw, 76 cs35l56_dspwait_put_volsw, 77 vol_tlv), 78 SOC_SINGLE_EXT("Posture Number", CS35L56_MAIN_POSTURE_NUMBER, 79 0, 255, 0, 80 cs35l56_dspwait_get_volsw, cs35l56_dspwait_put_volsw), 81}; 82 83static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx1_enum, |
208 SND_SOC_NOPM, 209 0, 0, | 84 CS35L56_ASP1TX1_INPUT, 85 0, CS35L56_ASP_TXn_SRC_MASK, |
210 cs35l56_tx_input_texts, 211 cs35l56_tx_input_values); 212 213static const struct snd_kcontrol_new asp1_tx1_mux = | 86 cs35l56_tx_input_texts, 87 cs35l56_tx_input_values); 88 89static const struct snd_kcontrol_new asp1_tx1_mux = |
214 SOC_DAPM_ENUM_EXT("ASP1TX1 SRC", cs35l56_asp1tx1_enum, 215 cs35l56_dspwait_asp1tx_get, cs35l56_dspwait_asp1tx_put); | 90 SOC_DAPM_ENUM("ASP1TX1 SRC", cs35l56_asp1tx1_enum); |
216 217static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx2_enum, | 91 92static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx2_enum, |
218 SND_SOC_NOPM, 219 1, 0, | 93 CS35L56_ASP1TX2_INPUT, 94 0, CS35L56_ASP_TXn_SRC_MASK, |
220 cs35l56_tx_input_texts, 221 cs35l56_tx_input_values); 222 223static const struct snd_kcontrol_new asp1_tx2_mux = | 95 cs35l56_tx_input_texts, 96 cs35l56_tx_input_values); 97 98static const struct snd_kcontrol_new asp1_tx2_mux = |
224 SOC_DAPM_ENUM_EXT("ASP1TX2 SRC", cs35l56_asp1tx2_enum, 225 cs35l56_dspwait_asp1tx_get, cs35l56_dspwait_asp1tx_put); | 99 SOC_DAPM_ENUM("ASP1TX2 SRC", cs35l56_asp1tx2_enum); |
226 227static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx3_enum, | 100 101static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx3_enum, |
228 SND_SOC_NOPM, 229 2, 0, | 102 CS35L56_ASP1TX3_INPUT, 103 0, CS35L56_ASP_TXn_SRC_MASK, |
230 cs35l56_tx_input_texts, 231 cs35l56_tx_input_values); 232 233static const struct snd_kcontrol_new asp1_tx3_mux = | 104 cs35l56_tx_input_texts, 105 cs35l56_tx_input_values); 106 107static const struct snd_kcontrol_new asp1_tx3_mux = |
234 SOC_DAPM_ENUM_EXT("ASP1TX3 SRC", cs35l56_asp1tx3_enum, 235 cs35l56_dspwait_asp1tx_get, cs35l56_dspwait_asp1tx_put); | 108 SOC_DAPM_ENUM("ASP1TX3 SRC", cs35l56_asp1tx3_enum); |
236 237static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx4_enum, | 109 110static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx4_enum, |
238 SND_SOC_NOPM, 239 3, 0, | 111 CS35L56_ASP1TX4_INPUT, 112 0, CS35L56_ASP_TXn_SRC_MASK, |
240 cs35l56_tx_input_texts, 241 cs35l56_tx_input_values); 242 243static const struct snd_kcontrol_new asp1_tx4_mux = | 113 cs35l56_tx_input_texts, 114 cs35l56_tx_input_values); 115 116static const struct snd_kcontrol_new asp1_tx4_mux = |
244 SOC_DAPM_ENUM_EXT("ASP1TX4 SRC", cs35l56_asp1tx4_enum, 245 cs35l56_dspwait_asp1tx_get, cs35l56_dspwait_asp1tx_put); | 117 SOC_DAPM_ENUM("ASP1TX4 SRC", cs35l56_asp1tx4_enum); |
246 247static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_sdw1tx1_enum, 248 CS35L56_SWIRE_DP3_CH1_INPUT, 249 0, CS35L56_SWIRETXn_SRC_MASK, 250 cs35l56_tx_input_texts, 251 cs35l56_tx_input_values); 252 253static const struct snd_kcontrol_new sdw1_tx1_mux = --- 21 unchanged lines hidden (view full) --- 275 CS35L56_SWIRE_DP3_CH4_INPUT, 276 0, CS35L56_SWIRETXn_SRC_MASK, 277 cs35l56_tx_input_texts, 278 cs35l56_tx_input_values); 279 280static const struct snd_kcontrol_new sdw1_tx4_mux = 281 SOC_DAPM_ENUM("SDW1TX4 SRC", cs35l56_sdw1tx4_enum); 282 | 118 119static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_sdw1tx1_enum, 120 CS35L56_SWIRE_DP3_CH1_INPUT, 121 0, CS35L56_SWIRETXn_SRC_MASK, 122 cs35l56_tx_input_texts, 123 cs35l56_tx_input_values); 124 125static const struct snd_kcontrol_new sdw1_tx1_mux = --- 21 unchanged lines hidden (view full) --- 147 CS35L56_SWIRE_DP3_CH4_INPUT, 148 0, CS35L56_SWIRETXn_SRC_MASK, 149 cs35l56_tx_input_texts, 150 cs35l56_tx_input_values); 151 152static const struct snd_kcontrol_new sdw1_tx4_mux = 153 SOC_DAPM_ENUM("SDW1TX4 SRC", cs35l56_sdw1tx4_enum); 154 |
283static int cs35l56_asp1_cfg_event(struct snd_soc_dapm_widget *w, 284 struct snd_kcontrol *kcontrol, int event) 285{ 286 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 287 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); 288 289 switch (event) { 290 case SND_SOC_DAPM_PRE_PMU: 291 /* Override register values set by firmware boot */ 292 return cs35l56_force_sync_asp1_registers_from_cache(&cs35l56->base); 293 default: 294 return 0; 295 } 296} 297 | |
298static int cs35l56_play_event(struct snd_soc_dapm_widget *w, 299 struct snd_kcontrol *kcontrol, int event) 300{ 301 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 302 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); 303 unsigned int val; 304 int ret; 305 --- 20 unchanged lines hidden (view full) --- 326 return 0; 327 } 328} 329 330static const struct snd_soc_dapm_widget cs35l56_dapm_widgets[] = { 331 SND_SOC_DAPM_REGULATOR_SUPPLY("VDD_B", 0, 0), 332 SND_SOC_DAPM_REGULATOR_SUPPLY("VDD_AMP", 0, 0), 333 | 155static int cs35l56_play_event(struct snd_soc_dapm_widget *w, 156 struct snd_kcontrol *kcontrol, int event) 157{ 158 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 159 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); 160 unsigned int val; 161 int ret; 162 --- 20 unchanged lines hidden (view full) --- 183 return 0; 184 } 185} 186 187static const struct snd_soc_dapm_widget cs35l56_dapm_widgets[] = { 188 SND_SOC_DAPM_REGULATOR_SUPPLY("VDD_B", 0, 0), 189 SND_SOC_DAPM_REGULATOR_SUPPLY("VDD_AMP", 0, 0), 190 |
334 SND_SOC_DAPM_SUPPLY("ASP1 CFG", SND_SOC_NOPM, 0, 0, cs35l56_asp1_cfg_event, 335 SND_SOC_DAPM_PRE_PMU), 336 | |
337 SND_SOC_DAPM_SUPPLY("PLAY", SND_SOC_NOPM, 0, 0, cs35l56_play_event, 338 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 339 340 SND_SOC_DAPM_OUT_DRV("AMP", SND_SOC_NOPM, 0, 0, NULL, 0), 341 SND_SOC_DAPM_OUTPUT("SPK"), 342 343 SND_SOC_DAPM_PGA_E("DSP1", SND_SOC_NOPM, 0, 0, NULL, 0, cs35l56_dsp_event, 344 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), --- 51 unchanged lines hidden (view full) --- 396 { name" Source", "INTERPOLATOR", "AMP" }, \ 397 { name" Source", "SDW1RX1", "SDW1 Playback" }, \ 398 { name" Source", "SDW1RX2", "SDW1 Playback" }, 399 400static const struct snd_soc_dapm_route cs35l56_audio_map[] = { 401 { "AMP", NULL, "VDD_B" }, 402 { "AMP", NULL, "VDD_AMP" }, 403 | 191 SND_SOC_DAPM_SUPPLY("PLAY", SND_SOC_NOPM, 0, 0, cs35l56_play_event, 192 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 193 194 SND_SOC_DAPM_OUT_DRV("AMP", SND_SOC_NOPM, 0, 0, NULL, 0), 195 SND_SOC_DAPM_OUTPUT("SPK"), 196 197 SND_SOC_DAPM_PGA_E("DSP1", SND_SOC_NOPM, 0, 0, NULL, 0, cs35l56_dsp_event, 198 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), --- 51 unchanged lines hidden (view full) --- 250 { name" Source", "INTERPOLATOR", "AMP" }, \ 251 { name" Source", "SDW1RX1", "SDW1 Playback" }, \ 252 { name" Source", "SDW1RX2", "SDW1 Playback" }, 253 254static const struct snd_soc_dapm_route cs35l56_audio_map[] = { 255 { "AMP", NULL, "VDD_B" }, 256 { "AMP", NULL, "VDD_AMP" }, 257 |
404 { "ASP1 Playback", NULL, "ASP1 CFG" }, 405 { "ASP1 Capture", NULL, "ASP1 CFG" }, 406 | |
407 { "ASP1 Playback", NULL, "PLAY" }, 408 { "SDW1 Playback", NULL, "PLAY" }, 409 410 { "ASP1RX1", NULL, "ASP1 Playback" }, 411 { "ASP1RX2", NULL, "ASP1 Playback" }, 412 { "DSP1", NULL, "ASP1RX1" }, 413 { "DSP1", NULL, "ASP1RX2" }, 414 { "DSP1", NULL, "SDW1 Playback" }, --- 34 unchanged lines hidden (view full) --- 449 450 return wm_adsp_event(w, kcontrol, event); 451} 452 453static int cs35l56_asp_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) 454{ 455 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(codec_dai->component); 456 unsigned int val; | 258 { "ASP1 Playback", NULL, "PLAY" }, 259 { "SDW1 Playback", NULL, "PLAY" }, 260 261 { "ASP1RX1", NULL, "ASP1 Playback" }, 262 { "ASP1RX2", NULL, "ASP1 Playback" }, 263 { "DSP1", NULL, "ASP1RX1" }, 264 { "DSP1", NULL, "ASP1RX2" }, 265 { "DSP1", NULL, "SDW1 Playback" }, --- 34 unchanged lines hidden (view full) --- 300 301 return wm_adsp_event(w, kcontrol, event); 302} 303 304static int cs35l56_asp_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) 305{ 306 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(codec_dai->component); 307 unsigned int val; |
457 int ret; | |
458 459 dev_dbg(cs35l56->base.dev, "%s: %#x\n", __func__, fmt); 460 | 308 309 dev_dbg(cs35l56->base.dev, "%s: %#x\n", __func__, fmt); 310 |
461 ret = cs35l56_init_asp1_regs_for_driver_control(&cs35l56->base); 462 if (ret) 463 return ret; 464 | |
465 switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { 466 case SND_SOC_DAIFMT_CBC_CFC: 467 break; 468 default: 469 dev_err(cs35l56->base.dev, "Unsupported clock source mode\n"); 470 return -EINVAL; 471 } 472 --- 57 unchanged lines hidden (view full) --- 530 531 return reg_val; 532} 533 534static int cs35l56_asp_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 535 unsigned int rx_mask, int slots, int slot_width) 536{ 537 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); | 311 switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { 312 case SND_SOC_DAIFMT_CBC_CFC: 313 break; 314 default: 315 dev_err(cs35l56->base.dev, "Unsupported clock source mode\n"); 316 return -EINVAL; 317 } 318 --- 57 unchanged lines hidden (view full) --- 376 377 return reg_val; 378} 379 380static int cs35l56_asp_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 381 unsigned int rx_mask, int slots, int slot_width) 382{ 383 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); |
538 int ret; | |
539 | 384 |
540 ret = cs35l56_init_asp1_regs_for_driver_control(&cs35l56->base); 541 if (ret) 542 return ret; 543 | |
544 if ((slots == 0) || (slot_width == 0)) { 545 dev_dbg(cs35l56->base.dev, "tdm config cleared\n"); 546 cs35l56->asp_slot_width = 0; 547 cs35l56->asp_slot_count = 0; 548 return 0; 549 } 550 551 if (slot_width > (CS35L56_ASP_RX_WIDTH_MASK >> CS35L56_ASP_RX_WIDTH_SHIFT)) { --- 31 unchanged lines hidden (view full) --- 583 584static int cs35l56_asp_dai_hw_params(struct snd_pcm_substream *substream, 585 struct snd_pcm_hw_params *params, 586 struct snd_soc_dai *dai) 587{ 588 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); 589 unsigned int rate = params_rate(params); 590 u8 asp_width, asp_wl; | 385 if ((slots == 0) || (slot_width == 0)) { 386 dev_dbg(cs35l56->base.dev, "tdm config cleared\n"); 387 cs35l56->asp_slot_width = 0; 388 cs35l56->asp_slot_count = 0; 389 return 0; 390 } 391 392 if (slot_width > (CS35L56_ASP_RX_WIDTH_MASK >> CS35L56_ASP_RX_WIDTH_SHIFT)) { --- 31 unchanged lines hidden (view full) --- 424 425static int cs35l56_asp_dai_hw_params(struct snd_pcm_substream *substream, 426 struct snd_pcm_hw_params *params, 427 struct snd_soc_dai *dai) 428{ 429 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); 430 unsigned int rate = params_rate(params); 431 u8 asp_width, asp_wl; |
591 int ret; | |
592 | 432 |
593 ret = cs35l56_init_asp1_regs_for_driver_control(&cs35l56->base); 594 if (ret) 595 return ret; 596 | |
597 asp_wl = params_width(params); 598 if (cs35l56->asp_slot_width) 599 asp_width = cs35l56->asp_slot_width; 600 else 601 asp_width = asp_wl; 602 603 dev_dbg(cs35l56->base.dev, "%s: wl=%d, width=%d, rate=%d", 604 __func__, asp_wl, asp_width, rate); --- 39 unchanged lines hidden (view full) --- 644 645 return 0; 646} 647 648static int cs35l56_asp_dai_set_sysclk(struct snd_soc_dai *dai, 649 int clk_id, unsigned int freq, int dir) 650{ 651 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); | 433 asp_wl = params_width(params); 434 if (cs35l56->asp_slot_width) 435 asp_width = cs35l56->asp_slot_width; 436 else 437 asp_width = asp_wl; 438 439 dev_dbg(cs35l56->base.dev, "%s: wl=%d, width=%d, rate=%d", 440 __func__, asp_wl, asp_width, rate); --- 39 unchanged lines hidden (view full) --- 480 481 return 0; 482} 483 484static int cs35l56_asp_dai_set_sysclk(struct snd_soc_dai *dai, 485 int clk_id, unsigned int freq, int dir) 486{ 487 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component); |
652 int freq_id, ret; | 488 int freq_id; |
653 | 489 |
654 ret = cs35l56_init_asp1_regs_for_driver_control(&cs35l56->base); 655 if (ret) 656 return ret; 657 | |
658 if (freq == 0) { 659 cs35l56->sysclk_set = false; 660 return 0; 661 } 662 663 freq_id = cs35l56_get_bclk_freq_id(freq); 664 if (freq_id < 0) 665 return freq_id; --- 363 unchanged lines hidden (view full) --- 1029 1030 cs35l56->component = component; 1031 wm_adsp2_component_probe(&cs35l56->dsp, component); 1032 1033 debugfs_create_bool("init_done", 0444, debugfs_root, &cs35l56->base.init_done); 1034 debugfs_create_bool("can_hibernate", 0444, debugfs_root, &cs35l56->base.can_hibernate); 1035 debugfs_create_bool("fw_patched", 0444, debugfs_root, &cs35l56->base.fw_patched); 1036 | 490 if (freq == 0) { 491 cs35l56->sysclk_set = false; 492 return 0; 493 } 494 495 freq_id = cs35l56_get_bclk_freq_id(freq); 496 if (freq_id < 0) 497 return freq_id; --- 363 unchanged lines hidden (view full) --- 861 862 cs35l56->component = component; 863 wm_adsp2_component_probe(&cs35l56->dsp, component); 864 865 debugfs_create_bool("init_done", 0444, debugfs_root, &cs35l56->base.init_done); 866 debugfs_create_bool("can_hibernate", 0444, debugfs_root, &cs35l56->base.can_hibernate); 867 debugfs_create_bool("fw_patched", 0444, debugfs_root, &cs35l56->base.fw_patched); 868 |
1037 /* 1038 * The widgets for the ASP1TX mixer can't be initialized 1039 * until the firmware has been downloaded and rebooted. 1040 */ 1041 regcache_drop_region(cs35l56->base.regmap, CS35L56_ASP1TX1_INPUT, CS35L56_ASP1TX4_INPUT); 1042 cs35l56->asp1_mixer_widgets_initialized = false; 1043 | |
1044 queue_work(cs35l56->dsp_wq, &cs35l56->dsp_work); 1045 1046 return 0; 1047} 1048 1049static void cs35l56_component_remove(struct snd_soc_component *component) 1050{ 1051 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); --- 374 unchanged lines hidden (view full) --- 1426{ 1427 int ret; 1428 1429 init_completion(&cs35l56->init_completion); 1430 mutex_init(&cs35l56->base.irq_lock); 1431 cs35l56->base.cal_index = -1; 1432 cs35l56->speaker_id = -ENOENT; 1433 | 869 queue_work(cs35l56->dsp_wq, &cs35l56->dsp_work); 870 871 return 0; 872} 873 874static void cs35l56_component_remove(struct snd_soc_component *component) 875{ 876 struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); --- 374 unchanged lines hidden (view full) --- 1251{ 1252 int ret; 1253 1254 init_completion(&cs35l56->init_completion); 1255 mutex_init(&cs35l56->base.irq_lock); 1256 cs35l56->base.cal_index = -1; 1257 cs35l56->speaker_id = -ENOENT; 1258 |
1434 /* Assume that the firmware owns ASP1 until we know different */ 1435 cs35l56->base.fw_owns_asp1 = true; 1436 | |
1437 dev_set_drvdata(cs35l56->base.dev, cs35l56); 1438 1439 cs35l56_fill_supply_names(cs35l56->supplies); 1440 ret = devm_regulator_bulk_get(cs35l56->base.dev, ARRAY_SIZE(cs35l56->supplies), 1441 cs35l56->supplies); 1442 if (ret != 0) 1443 return dev_err_probe(cs35l56->base.dev, ret, "Failed to request supplies\n"); 1444 --- 185 unchanged lines hidden --- | 1259 dev_set_drvdata(cs35l56->base.dev, cs35l56); 1260 1261 cs35l56_fill_supply_names(cs35l56->supplies); 1262 ret = devm_regulator_bulk_get(cs35l56->base.dev, ARRAY_SIZE(cs35l56->supplies), 1263 cs35l56->supplies); 1264 if (ret != 0) 1265 return dev_err_probe(cs35l56->base.dev, ret, "Failed to request supplies\n"); 1266 --- 185 unchanged lines hidden --- |