summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeeyush Gupta2020-01-28 01:01:05 -0600
committerPeeyush Gupta2020-01-28 01:01:05 -0600
commit9ce779a592de307829498398064c47d1c9975273 (patch)
tree2650133bf463cabca3be57277d328c8b85808050
parent05f0e1f9f47b4b21c259b9128e0614a7b1e4a806 (diff)
downloadtas2562-stereo-android-driver-9ce779a592de307829498398064c47d1c9975273.tar.gz
tas2562-stereo-android-driver-9ce779a592de307829498398064c47d1c9975273.tar.xz
tas2562-stereo-android-driver-9ce779a592de307829498398064c47d1c9975273.zip
support for Linux Kernel above 4.19 has been added
-rw-r--r--Kconfig2
-rw-r--r--tas2562-codec.c280
-rw-r--r--tas2562-regmap.c99
-rw-r--r--tas25xx-calib.c31
4 files changed, 323 insertions, 89 deletions
diff --git a/Kconfig b/Kconfig
index c06e735..041fa2c 100644
--- a/Kconfig
+++ b/Kconfig
@@ -22,7 +22,7 @@ config PLATFORM_EXYNOS
22 bool "Exynos platform support" 22 bool "Exynos platform support"
23 default y 23 default y
24 help 24 help
25 Enable support for Exynos platformt. 25 Enable support for Exynos platform.
26config TAS25XX_ALGO 26config TAS25XX_ALGO
27 bool "TAS2562 Calibration Support" 27 bool "TAS2562 Calibration Support"
28 depends on SND_SOC_TAS2562 28 depends on SND_SOC_TAS2562
diff --git a/tas2562-codec.c b/tas2562-codec.c
index ff16375..f7592e7 100644
--- a/tas2562-codec.c
+++ b/tas2562-codec.c
@@ -41,6 +41,7 @@
41#include <sound/soc.h> 41#include <sound/soc.h>
42#include <sound/initval.h> 42#include <sound/initval.h>
43#include <sound/tlv.h> 43#include <sound/tlv.h>
44#include <linux/version.h>
44 45
45#include "tas2562.h" 46#include "tas2562.h"
46#ifdef CONFIG_TAS25XX_ALGO 47#ifdef CONFIG_TAS25XX_ALGO
@@ -61,8 +62,8 @@ static int mb_mute;
61static const struct soc_enum tas2562_enum[] = { 62static const struct soc_enum tas2562_enum[] = {
62 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(iv_enable_text), iv_enable_text), 63 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(iv_enable_text), iv_enable_text),
63}; 64};
64static int tas2562_set_fmt(struct tas2562_priv *p_tas2562, unsigned int fmt); 65static int tas2562_set_fmt(struct tas2562_priv *p_tas2562,
65 66 unsigned int fmt);
66static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562, 67static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562,
67 enum channel chn, unsigned int *p_data); 68 enum channel chn, unsigned int *p_data);
68static int tas2562_system_mute_ctrl_get(struct snd_kcontrol *pKcontrol, 69static int tas2562_system_mute_ctrl_get(struct snd_kcontrol *pKcontrol,
@@ -91,7 +92,19 @@ static unsigned int p_tas2562_classh_d_data[] = {
91 0xFFFFFFFF, 0xFFFFFFFF 92 0xFFFFFFFF, 0xFFFFFFFF
92}; 93};
93 94
95#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
96static unsigned int tas2562_codec_read(struct snd_soc_component *codec,
97 unsigned int reg)
98{
99 unsigned int value = 0;
100 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
94 101
102 p_tas2562->read (p_tas2562, channel_left, reg, &value);
103 dev_dbg(p_tas2562->dev, "%s, reg=%d, value=%d", __func__, reg, value);
104
105 return value;
106}
107#else
95static unsigned int tas2562_codec_read(struct snd_soc_codec *codec, 108static unsigned int tas2562_codec_read(struct snd_soc_codec *codec,
96 unsigned int reg) 109 unsigned int reg)
97{ 110{
@@ -103,6 +116,7 @@ static unsigned int tas2562_codec_read(struct snd_soc_codec *codec,
103 116
104 return value; 117 return value;
105} 118}
119#endif
106 120
107static int tas2562_iv_enable(struct tas2562_priv *p_tas2562, int enable) 121static int tas2562_iv_enable(struct tas2562_priv *p_tas2562, int enable)
108{ 122{
@@ -133,7 +147,12 @@ static int tas2562_iv_enable(struct tas2562_priv *p_tas2562, int enable)
133static int tas2562iv_put(struct snd_kcontrol *kcontrol, 147static int tas2562iv_put(struct snd_kcontrol *kcontrol,
134 struct snd_ctl_elem_value *ucontrol) 148 struct snd_ctl_elem_value *ucontrol)
135{ 149{
150#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
151 struct snd_soc_component *codec
152 = snd_soc_kcontrol_component(kcontrol);
153#else
136 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 154 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
155#endif
137 struct tas2562_priv *p_tas2562 = NULL; 156 struct tas2562_priv *p_tas2562 = NULL;
138 int iv_enable = 0, n_result = 0; 157 int iv_enable = 0, n_result = 0;
139 158
@@ -142,7 +161,11 @@ static int tas2562iv_put(struct snd_kcontrol *kcontrol,
142 return 0; 161 return 0;
143 } 162 }
144 163
164#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
165 p_tas2562 = snd_soc_component_get_drvdata(codec);
166#else
145 p_tas2562 = snd_soc_codec_get_drvdata(codec); 167 p_tas2562 = snd_soc_codec_get_drvdata(codec);
168#endif
146 if (p_tas2562 == NULL) { 169 if (p_tas2562 == NULL) {
147 pr_err("%s:p_tas2562 is NULL\n", __func__); 170 pr_err("%s:p_tas2562 is NULL\n", __func__);
148 return 0; 171 return 0;
@@ -160,7 +183,11 @@ static int tas2562iv_put(struct snd_kcontrol *kcontrol,
160static int tas2562iv_get(struct snd_kcontrol *kcontrol, 183static int tas2562iv_get(struct snd_kcontrol *kcontrol,
161 struct snd_ctl_elem_value *ucontrol) 184 struct snd_ctl_elem_value *ucontrol)
162{ 185{
186#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
187 struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
188#else
163 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 189 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
190#endif
164 struct tas2562_priv *p_tas2562 = NULL; 191 struct tas2562_priv *p_tas2562 = NULL;
165 int ret, value; 192 int ret, value;
166 193
@@ -169,7 +196,11 @@ static int tas2562iv_get(struct snd_kcontrol *kcontrol,
169 return 0; 196 return 0;
170 } 197 }
171 198
199#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
200 p_tas2562 = snd_soc_component_get_drvdata(codec);
201#else
172 p_tas2562 = snd_soc_codec_get_drvdata(codec); 202 p_tas2562 = snd_soc_codec_get_drvdata(codec);
203#endif
173 if (p_tas2562 == NULL) { 204 if (p_tas2562 == NULL) {
174 pr_err("%s:p_tas2562 is NULL\n", __func__); 205 pr_err("%s:p_tas2562 is NULL\n", __func__);
175 return 0; 206 return 0;
@@ -201,8 +232,20 @@ SOC_ENUM_EXT("TAS2562 IVSENSE ENABLE", tas2562_enum[0],
201 tas2562iv_get, tas2562iv_put), 232 tas2562iv_get, tas2562iv_put),
202}; 233};
203 234
204static int tas2562_codec_write(struct snd_soc_codec *codec, unsigned int reg, 235#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
205 unsigned int value) 236static int tas2562_codec_write(struct snd_soc_component *codec,
237 unsigned int reg, unsigned int value)
238{
239 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
240
241 dev_dbg(p_tas2562->dev, "%s: %d, %d", __func__, reg, value);
242 p_tas2562->write (p_tas2562, channel_both, reg, value);
243
244 return 0;
245}
246#else
247static int tas2562_codec_write(struct snd_soc_codec *codec,
248 unsigned int reg, unsigned int value)
206{ 249{
207 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 250 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
208 251
@@ -211,6 +254,7 @@ static int tas2562_codec_write(struct snd_soc_codec *codec, unsigned int reg,
211 254
212 return 0; 255 return 0;
213} 256}
257#endif
214 258
215static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562, 259static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562,
216 enum channel chn, 260 enum channel chn,
@@ -270,6 +314,35 @@ static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562,
270} 314}
271 315
272#ifdef CODEC_PM 316#ifdef CODEC_PM
317#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
318static int tas2562_codec_suspend(struct snd_soc_component *codec)
319{
320 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
321 int ret = 0;
322
323 mutex_lock(&p_tas2562->codec_lock);
324
325 dev_dbg(p_tas2562->dev, "%s\n", __func__);
326 p_tas2562->runtime_suspend(p_tas2562);
327
328 mutex_unlock(&p_tas2562->codec_lock);
329 return ret;
330}
331
332static int tas2562_codec_resume(struct snd_soc_component *codec)
333{
334 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
335 int ret = 0;
336
337 mutex_lock(&p_tas2562->codec_lock);
338
339 dev_dbg(p_tas2562->dev, "%s\n", __func__);
340 p_tas2562->runtime_resume(p_tas2562);
341
342 mutex_unlock(&p_tas2562->codec_lock);
343 return ret;
344}
345#else
273static int tas2562_codec_suspend(struct snd_soc_codec *codec) 346static int tas2562_codec_suspend(struct snd_soc_codec *codec)
274{ 347{
275 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 348 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
@@ -298,6 +371,7 @@ static int tas2562_codec_resume(struct snd_soc_codec *codec)
298 return ret; 371 return ret;
299} 372}
300#endif 373#endif
374#endif
301 375
302static int tas2562_set_power_state(struct tas2562_priv *p_tas2562, 376static int tas2562_set_power_state(struct tas2562_priv *p_tas2562,
303 enum channel chn, int state) 377 enum channel chn, int state)
@@ -389,9 +463,13 @@ static int tas2562_set_power_state(struct tas2562_priv *p_tas2562,
389static int tas2562_dac_event(struct snd_soc_dapm_widget *w, 463static int tas2562_dac_event(struct snd_soc_dapm_widget *w,
390 struct snd_kcontrol *kcontrol, int event) 464 struct snd_kcontrol *kcontrol, int event)
391{ 465{
466#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
467 struct snd_soc_component *codec = snd_soc_dapm_to_component(w->dapm);
468 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
469#else
392 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 470 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
393 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 471 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
394 472#endif
395 switch (event) { 473 switch (event) {
396 case SND_SOC_DAPM_POST_PMU: 474 case SND_SOC_DAPM_POST_PMU:
397 dev_info(p_tas2562->dev, "SND_SOC_DAPM_POST_PMU\n"); 475 dev_info(p_tas2562->dev, "SND_SOC_DAPM_POST_PMU\n");
@@ -420,9 +498,14 @@ static const struct snd_soc_dapm_route tas2562_audio_map[] = {
420static int tas2562_get_left_speaker_switch(struct snd_kcontrol *pKcontrol, 498static int tas2562_get_left_speaker_switch(struct snd_kcontrol *pKcontrol,
421 struct snd_ctl_elem_value *p_u_control) 499 struct snd_ctl_elem_value *p_u_control)
422{ 500{
501#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
502 struct snd_soc_component *codec
503 = snd_soc_kcontrol_component(pKcontrol);
504 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
505#else
423 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 506 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
424 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 507 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
425 508#endif
426 dev_info(p_tas2562->dev, "%s, p_u_control = %ld\n", 509 dev_info(p_tas2562->dev, "%s, p_u_control = %ld\n",
427 __func__, p_u_control->value.integer.value[0]); 510 __func__, p_u_control->value.integer.value[0]);
428 p_u_control->value.integer.value[0] = p_tas2562->spk_l_control; 511 p_u_control->value.integer.value[0] = p_tas2562->spk_l_control;
@@ -432,33 +515,46 @@ static int tas2562_get_left_speaker_switch(struct snd_kcontrol *pKcontrol,
432static int tas2562_set_left_speaker_switch(struct snd_kcontrol *pKcontrol, 515static int tas2562_set_left_speaker_switch(struct snd_kcontrol *pKcontrol,
433 struct snd_ctl_elem_value *p_u_control) 516 struct snd_ctl_elem_value *p_u_control)
434{ 517{
518#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
519 struct snd_soc_component *codec = snd_soc_kcontrol_component(pKcontrol);
520 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
521#else
435 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 522 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
436 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 523 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
437 524#endif
438 dev_info(p_tas2562->dev, "%s, spk_l_control = %d\n", 525 dev_info(p_tas2562->dev, "%s, spk_l_control = %d\n",
439 __func__, p_tas2562->spk_l_control); 526 __func__, p_tas2562->spk_l_control);
440 p_tas2562->spk_l_control = p_u_control->value.integer.value[0]; 527 p_tas2562->spk_l_control = p_u_control->value.integer.value[0];
441 return 0; 528 return 0;
442} 529}
443 530
444static int tas2562_get_right_speaker_switch(struct snd_kcontrol *pKcontrol, 531static int tas2562_get_right_speaker_switch(
445 struct snd_ctl_elem_value *p_u_control) 532 struct snd_kcontrol *pKcontrol, struct snd_ctl_elem_value *p_u_control)
446{ 533{
534#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
535 struct snd_soc_component *codec = snd_soc_kcontrol_component(pKcontrol);
536 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
537#else
447 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 538 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
448 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 539 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
449 540#endif
450 dev_info(p_tas2562->dev, "%s, p_u_control = %ld\n", 541 dev_info(p_tas2562->dev, "%s, p_u_control = %ld\n",
451 __func__, p_u_control->value.integer.value[0]); 542 __func__, p_u_control->value.integer.value[0]);
452 p_u_control->value.integer.value[0] = p_tas2562->spk_r_control; 543 p_u_control->value.integer.value[0] = p_tas2562->spk_r_control;
453 return 0; 544 return 0;
454} 545}
455 546
456static int tas2562_set_right_speaker_switch(struct snd_kcontrol *pKcontrol, 547static int tas2562_set_right_speaker_switch(
457 struct snd_ctl_elem_value *p_u_control) 548 struct snd_kcontrol *pKcontrol, struct snd_ctl_elem_value *p_u_control)
458{ 549{
550#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
551 struct snd_soc_component *codec = snd_soc_kcontrol_component(pKcontrol);
552 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
553
554#else
459 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 555 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
460 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 556 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
461 557#endif
462 dev_info(p_tas2562->dev, "%s, spk_r_control = %d\n", 558 dev_info(p_tas2562->dev, "%s, spk_r_control = %d\n",
463 __func__, p_tas2562->spk_r_control); 559 __func__, p_tas2562->spk_r_control);
464 p_tas2562->spk_r_control = p_u_control->value.integer.value[0]; 560 p_tas2562->spk_r_control = p_u_control->value.integer.value[0];
@@ -467,8 +563,13 @@ static int tas2562_set_right_speaker_switch(struct snd_kcontrol *pKcontrol,
467 563
468static int tas2562_mute(struct snd_soc_dai *dai, int mute) 564static int tas2562_mute(struct snd_soc_dai *dai, int mute)
469{ 565{
566#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
567 struct snd_soc_component *codec = dai->component;
568 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
569#else
470 struct snd_soc_codec *codec = dai->codec; 570 struct snd_soc_codec *codec = dai->codec;
471 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 571 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
572#endif
472 enum channel chn; 573 enum channel chn;
473 574
474 dev_dbg(p_tas2562->dev, "%s,%d\n", __func__, mute); 575 dev_dbg(p_tas2562->dev, "%s,%d\n", __func__, mute);
@@ -602,7 +703,8 @@ static int tas2562_iv_bitwidth_config(struct tas2562_priv *p_tas2562)
602 return ret; 703 return ret;
603} 704}
604 705
605static int tas2562_set_slot(struct tas2562_priv *p_tas2562, int slot_width) 706static int tas2562_set_slot(struct tas2562_priv *p_tas2562,
707 int slot_width)
606{ 708{
607 int ret = 0; 709 int ret = 0;
608 710
@@ -643,7 +745,8 @@ static int tas2562_set_slot(struct tas2562_priv *p_tas2562, int slot_width)
643 return ret; 745 return ret;
644} 746}
645 747
646static int tas2562_set_bitwidth(struct tas2562_priv *p_tas2562, int bitwidth) 748static int tas2562_set_bitwidth(struct tas2562_priv *p_tas2562,
749 int bitwidth)
647{ 750{
648 int slot_width_tmp = 16; 751 int slot_width_tmp = 16;
649 752
@@ -663,7 +766,7 @@ static int tas2562_set_bitwidth(struct tas2562_priv *p_tas2562, int bitwidth)
663 TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_MASK, 766 TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_MASK,
664 TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_24BITS); 767 TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_24BITS);
665 p_tas2562->mn_ch_size = 24; 768 p_tas2562->mn_ch_size = 24;
666 slot_width_tmp = 32; 769 slot_width_tmp = 24;
667 break; 770 break;
668 case SNDRV_PCM_FORMAT_S32_LE: 771 case SNDRV_PCM_FORMAT_S32_LE:
669 p_tas2562->update_bits(p_tas2562, channel_both, 772 p_tas2562->update_bits(p_tas2562, channel_both,
@@ -774,9 +877,14 @@ static int tas2562_set_samplerate(struct tas2562_priv *p_tas2562,
774static int tas2562_system_mute_ctrl_get(struct snd_kcontrol *pKcontrol, 877static int tas2562_system_mute_ctrl_get(struct snd_kcontrol *pKcontrol,
775 struct snd_ctl_elem_value *pValue) 878 struct snd_ctl_elem_value *pValue)
776{ 879{
880#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
881 struct snd_soc_component *codec
882 = snd_soc_kcontrol_component(pKcontrol);
883 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
884#else
777 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 885 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
778 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 886 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
779 887#endif
780 pValue->value.integer.value[0] = p_tas2562->mb_mute; 888 pValue->value.integer.value[0] = p_tas2562->mb_mute;
781 dev_dbg(p_tas2562->dev, "%s = %d\n", 889 dev_dbg(p_tas2562->dev, "%s = %d\n",
782 __func__, p_tas2562->mb_mute); 890 __func__, p_tas2562->mb_mute);
@@ -787,9 +895,13 @@ static int tas2562_system_mute_ctrl_get(struct snd_kcontrol *pKcontrol,
787static int tas2562_system_mute_ctrl_put(struct snd_kcontrol *pKcontrol, 895static int tas2562_system_mute_ctrl_put(struct snd_kcontrol *pKcontrol,
788 struct snd_ctl_elem_value *pValue) 896 struct snd_ctl_elem_value *pValue)
789{ 897{
898#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
899 struct snd_soc_component *codec = snd_soc_kcontrol_component(pKcontrol);
900 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
901#else
790 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 902 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
791 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 903 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
792 904#endif
793 mb_mute = pValue->value.integer.value[0]; 905 mb_mute = pValue->value.integer.value[0];
794 906
795 dev_dbg(p_tas2562->dev, "%s = %d\n", __func__, mb_mute); 907 dev_dbg(p_tas2562->dev, "%s = %d\n", __func__, mb_mute);
@@ -802,9 +914,13 @@ static int tas2562_system_mute_ctrl_put(struct snd_kcontrol *pKcontrol,
802static int tas2562_mute_ctrl_get(struct snd_kcontrol *pKcontrol, 914static int tas2562_mute_ctrl_get(struct snd_kcontrol *pKcontrol,
803 struct snd_ctl_elem_value *pValue) 915 struct snd_ctl_elem_value *pValue)
804{ 916{
917#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
918 struct snd_soc_component *codec = snd_soc_kcontrol_component(pKcontrol);
919 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
920#else
805 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 921 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
806 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 922 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
807 923#endif
808 pValue->value.integer.value[0] = p_tas2562->mb_mute; 924 pValue->value.integer.value[0] = p_tas2562->mb_mute;
809 925
810 if((p_tas2562->mb_power_up == true)&& 926 if((p_tas2562->mb_power_up == true)&&
@@ -822,8 +938,13 @@ static int tas2562_mute_ctrl_get(struct snd_kcontrol *pKcontrol,
822static int tas2562_mute_ctrl_put(struct snd_kcontrol *pKcontrol, 938static int tas2562_mute_ctrl_put(struct snd_kcontrol *pKcontrol,
823 struct snd_ctl_elem_value *pValue) 939 struct snd_ctl_elem_value *pValue)
824{ 940{
941#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
942 struct snd_soc_component *codec = snd_soc_kcontrol_component(pKcontrol);
943 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
944#else
825 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 945 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
826 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 946 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
947#endif
827 enum channel chn; 948 enum channel chn;
828 int mute = pValue->value.integer.value[0]; 949 int mute = pValue->value.integer.value[0];
829 950
@@ -856,8 +977,14 @@ static int tas2562_hw_params(struct snd_pcm_substream *substream,
856 struct snd_pcm_hw_params *params, 977 struct snd_pcm_hw_params *params,
857 struct snd_soc_dai *dai) 978 struct snd_soc_dai *dai)
858{ 979{
980#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
981 struct snd_soc_component *codec = dai->component;
982 struct tas2562_priv *p_tas2562
983 = snd_soc_component_get_drvdata(codec);
984#else
859 struct snd_soc_codec *codec = dai->codec; 985 struct snd_soc_codec *codec = dai->codec;
860 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 986 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
987#endif
861 /* int blr_clk_ratio; */ 988 /* int blr_clk_ratio; */
862 int n_result = 0; 989 int n_result = 0;
863 990
@@ -884,7 +1011,8 @@ ret:
884 return n_result; 1011 return n_result;
885} 1012}
886 1013
887static int tas2562_set_fmt(struct tas2562_priv *p_tas2562, unsigned int fmt) 1014static int tas2562_set_fmt(struct tas2562_priv *p_tas2562,
1015 unsigned int fmt)
888{ 1016{
889 u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0; 1017 u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
890 int ret = 0; 1018 int ret = 0;
@@ -955,8 +1083,13 @@ static int tas2562_set_fmt(struct tas2562_priv *p_tas2562, unsigned int fmt)
955 1083
956static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) 1084static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
957{ 1085{
1086#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1087 struct snd_soc_component *codec = dai->component;
1088 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
1089#else
958 struct snd_soc_codec *codec = dai->codec; 1090 struct snd_soc_codec *codec = dai->codec;
959 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 1091 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
1092#endif
960 int ret = 0; 1093 int ret = 0;
961 1094
962 dev_dbg(p_tas2562->dev, "%s, format=0x%x\n", __func__, fmt); 1095 dev_dbg(p_tas2562->dev, "%s, format=0x%x\n", __func__, fmt);
@@ -970,12 +1103,17 @@ static int tas2562_set_dai_tdm_slot(struct snd_soc_dai *dai,
970 int slots, int slot_width) 1103 int slots, int slot_width)
971{ 1104{
972 int ret = 0; 1105 int ret = 0;
1106#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1107 struct snd_soc_component *codec = dai->component;
1108 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
1109#else
973 struct snd_soc_codec *codec = dai->codec; 1110 struct snd_soc_codec *codec = dai->codec;
974 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 1111 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
975 1112#endif
976 dev_dbg(p_tas2562->dev, "%s, tx_mask:%d, rx_mask:%d, slots:%d, slot_width:%d", 1113 dev_dbg(p_tas2562->dev, "%s, tx_mask:%d, rx_mask:%d",
977 __func__, tx_mask, rx_mask, slots, slot_width); 1114 __func__, tx_mask, rx_mask);
978 1115 dev_dbg(p_tas2562->dev, "%s, slots:%d,slot_width:%d",
1116 __func__, slots, slot_width);
979 ret = tas2562_set_slot(p_tas2562, slot_width); 1117 ret = tas2562_set_slot(p_tas2562, slot_width);
980 1118
981 return ret; 1119 return ret;
@@ -988,15 +1126,17 @@ static struct snd_soc_dai_ops tas2562_dai_ops = {
988 .set_tdm_slot = tas2562_set_dai_tdm_slot, 1126 .set_tdm_slot = tas2562_set_dai_tdm_slot,
989}; 1127};
990 1128
991#define TAS2562_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 1129#define TAS2562_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
992 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 1130 SNDRV_PCM_FMTBIT_S20_3LE |\
1131 SNDRV_PCM_FMTBIT_S24_LE |\
1132 SNDRV_PCM_FMTBIT_S32_LE)
993 1133
994#define TAS2562_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 \ 1134#define TAS2562_RATES (SNDRV_PCM_RATE_44100 |\
1135 SNDRV_PCM_RATE_48000 \
995 SNDRV_PCM_RATE_88200 |\ 1136 SNDRV_PCM_RATE_88200 |\
996 SNDRV_PCM_RATE_96000 |\ 1137 SNDRV_PCM_RATE_96000 |\
997 SNDRV_PCM_RATE_176400 |\ 1138 SNDRV_PCM_RATE_176400 |\
998 SNDRV_PCM_RATE_192000\ 1139 SNDRV_PCM_RATE_192000)
999 )
1000 1140
1001static struct snd_soc_dai_driver tas2562_dai_driver[] = { 1141static struct snd_soc_dai_driver tas2562_dai_driver[] = {
1002 { 1142 {
@@ -1078,6 +1218,27 @@ static int tas2562_load_init(struct tas2562_priv *p_tas2562)
1078 return ret; 1218 return ret;
1079} 1219}
1080 1220
1221#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1222static int tas2562_codec_probe(struct snd_soc_component *codec)
1223{
1224 int ret;
1225 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
1226
1227 ret = snd_soc_add_component_controls(codec, tas2562_controls,
1228 ARRAY_SIZE(tas2562_controls));
1229 if (ret < 0) {
1230 pr_err("%s: add_codec_controls failed, err %d\n",
1231 __func__, ret);
1232 return ret;
1233 }
1234
1235 tas2562_load_init(p_tas2562);
1236 tas2562_iv_enable(p_tas2562, 1);
1237 dev_dbg(p_tas2562->dev, "%s\n", __func__);
1238
1239 return 0;
1240}
1241#else
1081static int tas2562_codec_probe(struct snd_soc_codec *codec) 1242static int tas2562_codec_probe(struct snd_soc_codec *codec)
1082{ 1243{
1083 int ret; 1244 int ret;
@@ -1097,11 +1258,18 @@ static int tas2562_codec_probe(struct snd_soc_codec *codec)
1097 1258
1098 return 0; 1259 return 0;
1099} 1260}
1261#endif
1100 1262
1263#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1264static void tas2562_codec_remove(struct snd_soc_component *codec)
1265{
1266}
1267#else
1101static int tas2562_codec_remove(struct snd_soc_codec *codec) 1268static int tas2562_codec_remove(struct snd_soc_codec *codec)
1102{ 1269{
1103 return 0; 1270 return 0;
1104} 1271}
1272#endif
1105 1273
1106static DECLARE_TLV_DB_SCALE(tas2562_digital_tlv, 1100, 50, 0); 1274static DECLARE_TLV_DB_SCALE(tas2562_digital_tlv, 1100, 50, 0);
1107 1275
@@ -1119,8 +1287,14 @@ static const struct soc_enum icn_sw_enum[] = {
1119static int tas2562_get_icn_switch(struct snd_kcontrol *pKcontrol, 1287static int tas2562_get_icn_switch(struct snd_kcontrol *pKcontrol,
1120 struct snd_ctl_elem_value *p_u_control) 1288 struct snd_ctl_elem_value *p_u_control)
1121{ 1289{
1290#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1291 struct snd_soc_component *codec
1292 = snd_soc_kcontrol_component(pKcontrol);
1293 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
1294#else
1122 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 1295 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
1123 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 1296 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
1297#endif
1124 dev_info(p_tas2562->dev, "%s, icn_sw = %ld\n", 1298 dev_info(p_tas2562->dev, "%s, icn_sw = %ld\n",
1125 __func__, p_u_control->value.integer.value[0]); 1299 __func__, p_u_control->value.integer.value[0]);
1126 p_u_control->value.integer.value[0] = p_tas2562->icn_sw; 1300 p_u_control->value.integer.value[0] = p_tas2562->icn_sw;
@@ -1129,8 +1303,14 @@ static int tas2562_get_icn_switch(struct snd_kcontrol *pKcontrol,
1129static int tas2562_set_icn_switch(struct snd_kcontrol *pKcontrol, 1303static int tas2562_set_icn_switch(struct snd_kcontrol *pKcontrol,
1130 struct snd_ctl_elem_value *p_u_control) 1304 struct snd_ctl_elem_value *p_u_control)
1131{ 1305{
1306#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1307 struct snd_soc_component *codec
1308 = snd_soc_kcontrol_component(pKcontrol);
1309 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
1310#else
1132 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 1311 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
1133 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 1312 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
1313#endif
1134 p_tas2562->icn_sw = p_u_control->value.integer.value[0]; 1314 p_tas2562->icn_sw = p_u_control->value.integer.value[0];
1135 if (p_tas2562->icn_sw == 0) { 1315 if (p_tas2562->icn_sw == 0) {
1136 p_tas2562->update_bits(p_tas2562, channel_both, 1316 p_tas2562->update_bits(p_tas2562, channel_both,
@@ -1152,9 +1332,13 @@ static int tas2562_set_icn_switch(struct snd_kcontrol *pKcontrol,
1152static int tas2562_dac_mute_ctrl_get(struct snd_kcontrol *pKcontrol, 1332static int tas2562_dac_mute_ctrl_get(struct snd_kcontrol *pKcontrol,
1153 struct snd_ctl_elem_value *pValue) 1333 struct snd_ctl_elem_value *pValue)
1154{ 1334{
1335#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1336 struct snd_soc_component *codec = snd_soc_kcontrol_component(pKcontrol);
1337 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
1338 #else
1155 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 1339 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
1156 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 1340 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
1157 1341 #endif
1158 pValue->value.integer.value[0] = p_tas2562->dac_mute; 1342 pValue->value.integer.value[0] = p_tas2562->dac_mute;
1159 1343
1160 dev_dbg(p_tas2562->dev, "%s = %ld\n", 1344 dev_dbg(p_tas2562->dev, "%s = %ld\n",
@@ -1169,9 +1353,13 @@ static int tas2562_dac_mute_ctrl_put(struct snd_kcontrol *pKcontrol,
1169 int n_result = 0; 1353 int n_result = 0;
1170 enum channel chn; 1354 enum channel chn;
1171 int mute = pValue->value.integer.value[0]; 1355 int mute = pValue->value.integer.value[0];
1356#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1357 struct snd_soc_component *codec = snd_soc_kcontrol_component(pKcontrol);
1358 struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec);
1359#else
1172 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); 1360 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
1173 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); 1361 struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec);
1174 1362#endif
1175 dev_dbg(p_tas2562->dev, "%s, %d\n", __func__, mute); 1363 dev_dbg(p_tas2562->dev, "%s, %d\n", __func__, mute);
1176 mutex_lock(&p_tas2562->codec_lock); 1364 mutex_lock(&p_tas2562->codec_lock);
1177 1365
@@ -1225,6 +1413,24 @@ static const struct snd_kcontrol_new tas2562_snd_controls[] = {
1225 tas2562_set_icn_switch), 1413 tas2562_set_icn_switch),
1226}; 1414};
1227 1415
1416#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1417static const struct snd_soc_component_driver soc_codec_driver_tas2562 = {
1418 .probe = tas2562_codec_probe,
1419 .remove = tas2562_codec_remove,
1420 .read = tas2562_codec_read,
1421 .write = tas2562_codec_write,
1422#ifdef CODEC_PM
1423 .suspend = tas2562_codec_suspend,
1424 .resume = tas2562_codec_resume,
1425#endif
1426 .controls = tas2562_snd_controls,
1427 .num_controls = ARRAY_SIZE(tas2562_snd_controls),
1428 .dapm_widgets = tas2562_dapm_widgets,
1429 .num_dapm_widgets = ARRAY_SIZE(tas2562_dapm_widgets),
1430 .dapm_routes = tas2562_audio_map,
1431 .num_dapm_routes = ARRAY_SIZE(tas2562_audio_map),
1432};
1433#else
1228static struct snd_soc_codec_driver soc_codec_driver_tas2562 = { 1434static struct snd_soc_codec_driver soc_codec_driver_tas2562 = {
1229 .probe = tas2562_codec_probe, 1435 .probe = tas2562_codec_probe,
1230 .remove = tas2562_codec_remove, 1436 .remove = tas2562_codec_remove,
@@ -1243,15 +1449,22 @@ static struct snd_soc_codec_driver soc_codec_driver_tas2562 = {
1243 .num_dapm_routes = ARRAY_SIZE(tas2562_audio_map), 1449 .num_dapm_routes = ARRAY_SIZE(tas2562_audio_map),
1244 }, 1450 },
1245}; 1451};
1452#endif
1246 1453
1247int tas2562_register_codec(struct tas2562_priv *p_tas2562) 1454int tas2562_register_codec(struct tas2562_priv *p_tas2562)
1248{ 1455{
1249 int n_result = 0; 1456 int n_result = 0;
1250 1457
1251 dev_info(p_tas2562->dev, "%s, enter\n", __func__); 1458 dev_info(p_tas2562->dev, "%s, enter\n", __func__);
1459#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1460 n_result = devm_snd_soc_register_component(p_tas2562->dev,
1461 &soc_codec_driver_tas2562,
1462 tas2562_dai_driver, ARRAY_SIZE(tas2562_dai_driver));
1463 #else
1252 n_result = snd_soc_register_codec(p_tas2562->dev, 1464 n_result = snd_soc_register_codec(p_tas2562->dev,
1253 &soc_codec_driver_tas2562, 1465 &soc_codec_driver_tas2562,
1254 tas2562_dai_driver, ARRAY_SIZE(tas2562_dai_driver)); 1466 tas2562_dai_driver, ARRAY_SIZE(tas2562_dai_driver));
1467 #endif
1255#ifdef CONFIG_TAS25XX_ALGO 1468#ifdef CONFIG_TAS25XX_ALGO
1256 smartamp_add_algo(p_tas2562->mn_channels); 1469 smartamp_add_algo(p_tas2562->mn_channels);
1257 tas_calib_init(); 1470 tas_calib_init();
@@ -1264,8 +1477,11 @@ int tas2562_deregister_codec(struct tas2562_priv *p_tas2562)
1264#ifdef CONFIG_TAS25XX_ALGO 1477#ifdef CONFIG_TAS25XX_ALGO
1265 smartamp_remove_algo(); 1478 smartamp_remove_algo();
1266#endif /*CONFIG_TAS25XX_ALGO*/ 1479#endif /*CONFIG_TAS25XX_ALGO*/
1480#if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE
1481 snd_soc_unregister_component(p_tas2562->dev);
1482#else
1267 snd_soc_unregister_codec(p_tas2562->dev); 1483 snd_soc_unregister_codec(p_tas2562->dev);
1268 1484#endif
1269 return 0; 1485 return 0;
1270} 1486}
1271 1487
diff --git a/tas2562-regmap.c b/tas2562-regmap.c
index a7dc564..7d5ab21 100644
--- a/tas2562-regmap.c
+++ b/tas2562-regmap.c
@@ -55,8 +55,7 @@ static int tas2562_regmap_write(struct tas2562_priv *p_tas2562,
55 if(p_tas2562->i2c_suspend) 55 if(p_tas2562->i2c_suspend)
56 return ERROR_I2C_SUSPEND; 56 return ERROR_I2C_SUSPEND;
57 57
58 while(retry_count--) 58 while (retry_count--) {
59 {
60 nResult = regmap_write(p_tas2562->regmap, reg, 59 nResult = regmap_write(p_tas2562->regmap, reg,
61 value); 60 value);
62 if (nResult >= 0) 61 if (nResult >= 0)
@@ -78,8 +77,7 @@ static int tas2562_regmap_bulk_write(struct tas2562_priv *p_tas2562,
78 if(p_tas2562->i2c_suspend) 77 if(p_tas2562->i2c_suspend)
79 return ERROR_I2C_SUSPEND; 78 return ERROR_I2C_SUSPEND;
80 79
81 while(retry_count --) 80 while (retry_count--) {
82 {
83 nResult = regmap_bulk_write(p_tas2562->regmap, reg, 81 nResult = regmap_bulk_write(p_tas2562->regmap, reg,
84 pData, nLength); 82 pData, nLength);
85 if (nResult >= 0) 83 if (nResult >= 0)
@@ -101,8 +99,7 @@ static int tas2562_regmap_read(struct tas2562_priv *p_tas2562,
101 if(p_tas2562->i2c_suspend) 99 if(p_tas2562->i2c_suspend)
102 return ERROR_I2C_SUSPEND; 100 return ERROR_I2C_SUSPEND;
103 101
104 while(retry_count --) 102 while (retry_count--) {
105 {
106 nResult = regmap_read(p_tas2562->regmap, reg, 103 nResult = regmap_read(p_tas2562->regmap, reg,
107 value); 104 value);
108 if (nResult >= 0) 105 if (nResult >= 0)
@@ -124,8 +121,7 @@ static int tas2562_regmap_bulk_read(struct tas2562_priv *p_tas2562,
124 if(p_tas2562->i2c_suspend) 121 if(p_tas2562->i2c_suspend)
125 return ERROR_I2C_SUSPEND; 122 return ERROR_I2C_SUSPEND;
126 123
127 while(retry_count --) 124 while (retry_count--) {
128 {
129 nResult = regmap_bulk_read(p_tas2562->regmap, reg, 125 nResult = regmap_bulk_read(p_tas2562->regmap, reg,
130 pData, nLength); 126 pData, nLength);
131 if (nResult >= 0) 127 if (nResult >= 0)
@@ -147,8 +143,7 @@ static int tas2562_regmap_update_bits(struct tas2562_priv *p_tas2562,
147 if(p_tas2562->i2c_suspend) 143 if(p_tas2562->i2c_suspend)
148 return ERROR_I2C_SUSPEND; 144 return ERROR_I2C_SUSPEND;
149 145
150 while(retry_count--) 146 while (retry_count--) {
151 {
152 nResult = regmap_update_bits(p_tas2562->regmap, reg, 147 nResult = regmap_update_bits(p_tas2562->regmap, reg,
153 mask, value); 148 mask, value);
154 if (nResult >= 0) 149 if (nResult >= 0)
@@ -477,20 +472,26 @@ static void tas2562_hw_reset(struct tas2562_priv *p_tas2562)
477 if (gpio_is_valid(p_tas2562->mn_reset_gpio)) { 472 if (gpio_is_valid(p_tas2562->mn_reset_gpio)) {
478 gpio_direction_output(p_tas2562->mn_reset_gpio, 0); 473 gpio_direction_output(p_tas2562->mn_reset_gpio, 0);
479 if(p_tas2562->mn_channels != 1) { 474 if(p_tas2562->mn_channels != 1) {
480 dev_dbg(p_tas2562->dev, "Reset gpio: not mono case, resetting second gpio"); 475 dev_dbg(p_tas2562->dev,
481 if(gpio_is_valid(p_tas2562->mn_reset_gpio2)) 476 "Reset gpio: not mono case, resetting second gpio");
482 gpio_direction_output(p_tas2562->mn_reset_gpio2, 0); 477 if (gpio_is_valid(p_tas2562->mn_reset_gpio2))
478 gpio_direction_output(p_tas2562->mn_reset_gpio2, 0);
483 } else { 479 } else {
484 dev_dbg(p_tas2562->dev, "Reset gpio: mono case, not resetting second gpio"); 480 dev_dbg(p_tas2562->dev,
481 "Reset gpio: mono case, not resetting second gpio");
485 } 482 }
486 msleep(20); 483 msleep(20);
487 gpio_direction_output(p_tas2562->mn_reset_gpio, 1); 484
488 if(p_tas2562->mn_channels != 1) { 485 gpio_direction_output(p_tas2562->mn_reset_gpio, 1);
489 dev_dbg(p_tas2562->dev, "Reset gpio: not mono case, resetting second gpio"); 486
490 if(gpio_is_valid(p_tas2562->mn_reset_gpio2)) 487 if (p_tas2562->mn_channels != 1) {
491 gpio_direction_output(p_tas2562->mn_reset_gpio2, 1); 488 dev_dbg(p_tas2562->dev,
489 "Reset gpio: not mono case, resetting second gpio");
490 if (gpio_is_valid(p_tas2562->mn_reset_gpio2))
491 gpio_direction_output(p_tas2562->mn_reset_gpio2, 1);
492 } else { 492 } else {
493 dev_dbg(p_tas2562->dev, "Reset gpio: mono case, not resetting second gpio"); 493 dev_dbg(p_tas2562->dev,
494 "Reset gpio: mono case, not resetting second gpio");
494 } 495 }
495 496
496 msleep(20); 497 msleep(20);
@@ -512,27 +513,31 @@ void tas2562_enable_irq(struct tas2562_priv *p_tas2562, bool enable)
512 if (p_tas2562->mb_irq_eable) 513 if (p_tas2562->mb_irq_eable)
513 return; 514 return;
514 515
515 if (gpio_is_valid(p_tas2562->mn_irq_gpio) && irq1_enabled == 0) { 516 if (gpio_is_valid(p_tas2562->mn_irq_gpio) &&
517 irq1_enabled == 0) {
516 desc = irq_to_desc(p_tas2562->mn_irq); 518 desc = irq_to_desc(p_tas2562->mn_irq);
517 if (desc && desc->depth > 0) { 519 if (desc && desc->depth > 0)
518 enable_irq(p_tas2562->mn_irq); 520 enable_irq(p_tas2562->mn_irq);
519 } else { 521 else
520 dev_info (p_tas2562->dev, "### irq already enabled"); 522 dev_info(p_tas2562->dev, "### irq already enabled");
521 } 523
522 irq1_enabled = 1; 524 irq1_enabled = 1;
523 } 525 }
524 if (gpio_is_valid(p_tas2562->mn_irq_gpio2) && irq2_enabled == 0) { 526 if (gpio_is_valid(p_tas2562->mn_irq_gpio2)
527 && irq2_enabled == 0) {
525 enable_irq(p_tas2562->mn_irq2); 528 enable_irq(p_tas2562->mn_irq2);
526 irq2_enabled = 1; 529 irq2_enabled = 1;
527 } 530 }
528 531
529 p_tas2562->mb_irq_eable = true; 532 p_tas2562->mb_irq_eable = true;
530 } else { 533 } else {
531 if (gpio_is_valid(p_tas2562->mn_irq_gpio) && irq1_enabled == 1) { 534 if (gpio_is_valid(p_tas2562->mn_irq_gpio)
535 && irq1_enabled == 1) {
532 disable_irq_nosync(p_tas2562->mn_irq); 536 disable_irq_nosync(p_tas2562->mn_irq);
533 irq1_enabled = 0; 537 irq1_enabled = 0;
534 } 538 }
535 if (gpio_is_valid(p_tas2562->mn_irq_gpio2) && irq2_enabled == 1) { 539 if (gpio_is_valid(p_tas2562->mn_irq_gpio2)
540 && irq2_enabled == 1) {
536 disable_irq_nosync(p_tas2562->mn_irq2); 541 disable_irq_nosync(p_tas2562->mn_irq2);
537 irq2_enabled = 0; 542 irq2_enabled = 0;
538 } 543 }
@@ -890,14 +895,16 @@ static int tas2562_pm_resume(struct device *dev)
890 return 0; 895 return 0;
891} 896}
892 897
893static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *p_tas2562) 898static int tas2562_parse_dt(struct device *dev,
899 struct tas2562_priv *p_tas2562)
894{ 900{
895 struct device_node *np = dev->of_node; 901 struct device_node *np = dev->of_node;
896 int rc = 0, ret = 0; 902 int rc = 0, ret = 0;
897 903
898 rc = of_property_read_u32(np, "ti,channels", &p_tas2562->mn_channels); 904 rc = of_property_read_u32(np, "ti,channels", &p_tas2562->mn_channels);
899 if (rc) { 905 if (rc) {
900 dev_err(p_tas2562->dev, "Looking up %s property in node %s failed %d\n", 906 dev_err(p_tas2562->dev,
907 "Looking up %s property in node %s failed %d\n",
901 "ti,channels", np->full_name, rc); 908 "ti,channels", np->full_name, rc);
902 } else { 909 } else {
903 dev_dbg(p_tas2562->dev, "ti,channels=%d", 910 dev_dbg(p_tas2562->dev, "ti,channels=%d",
@@ -906,7 +913,8 @@ static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *p_tas2562)
906 913
907 rc = of_property_read_u32(np, "ti,left-channel", &p_tas2562->mn_l_addr); 914 rc = of_property_read_u32(np, "ti,left-channel", &p_tas2562->mn_l_addr);
908 if (rc) { 915 if (rc) {
909 dev_err(p_tas2562->dev, "Looking up %s property in node %s failed %d\n", 916 dev_err(p_tas2562->dev,
917 "Looking up %s property in node %s failed %d\n",
910 "ti,left-channel", np->full_name, rc); 918 "ti,left-channel", np->full_name, rc);
911 } else { 919 } else {
912 dev_dbg(p_tas2562->dev, "ti,left-channel=0x%x", 920 dev_dbg(p_tas2562->dev, "ti,left-channel=0x%x",
@@ -917,7 +925,8 @@ static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *p_tas2562)
917 rc = of_property_read_u32(np, "ti,right-channel", 925 rc = of_property_read_u32(np, "ti,right-channel",
918 &p_tas2562->mn_r_addr); 926 &p_tas2562->mn_r_addr);
919 if (rc) { 927 if (rc) {
920 dev_err(p_tas2562->dev, "Looking up %s property in node %s failed %d\n", 928 dev_err(p_tas2562->dev,
929 "Looking up %s property in node %s failed %d\n",
921 "ti,right-channel", np->full_name, rc); 930 "ti,right-channel", np->full_name, rc);
922 } else { 931 } else {
923 dev_dbg(p_tas2562->dev, "ti,right-channel=0x%x", 932 dev_dbg(p_tas2562->dev, "ti,right-channel=0x%x",
@@ -926,7 +935,8 @@ static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *p_tas2562)
926 } 935 }
927 p_tas2562->mn_reset_gpio = of_get_named_gpio(np, "ti,reset-gpio", 0); 936 p_tas2562->mn_reset_gpio = of_get_named_gpio(np, "ti,reset-gpio", 0);
928 if (!gpio_is_valid(p_tas2562->mn_reset_gpio)) { 937 if (!gpio_is_valid(p_tas2562->mn_reset_gpio)) {
929 dev_err(p_tas2562->dev, "Looking up %s property in node %s failed %d\n", 938 dev_err(p_tas2562->dev,
939 "Looking up %s property in node %s failed %d\n",
930 "ti,reset-gpio", np->full_name, 940 "ti,reset-gpio", np->full_name,
931 p_tas2562->mn_reset_gpio); 941 p_tas2562->mn_reset_gpio);
932 } else { 942 } else {
@@ -934,9 +944,11 @@ static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *p_tas2562)
934 p_tas2562->mn_reset_gpio); 944 p_tas2562->mn_reset_gpio);
935 } 945 }
936 if(p_tas2562->mn_channels != 1) { 946 if(p_tas2562->mn_channels != 1) {
937 p_tas2562->mn_reset_gpio2 = of_get_named_gpio(np, "ti,reset-gpio2", 0); 947 p_tas2562->mn_reset_gpio2
948 = of_get_named_gpio(np, "ti,reset-gpio2", 0);
938 if (!gpio_is_valid(p_tas2562->mn_reset_gpio2)) { 949 if (!gpio_is_valid(p_tas2562->mn_reset_gpio2)) {
939 dev_dbg(p_tas2562->dev, "Looking up %s property in node %s failed %d\n", 950 dev_dbg(p_tas2562->dev,
951 "Looking up %s property in node %s failed %d\n",
940 "ti,reset-gpio2", np->full_name, 952 "ti,reset-gpio2", np->full_name,
941 p_tas2562->mn_reset_gpio2); 953 p_tas2562->mn_reset_gpio2);
942 } else { 954 } else {
@@ -947,19 +959,20 @@ static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *p_tas2562)
947 959
948 p_tas2562->mn_irq_gpio = of_get_named_gpio(np, "ti,irq-gpio", 0); 960 p_tas2562->mn_irq_gpio = of_get_named_gpio(np, "ti,irq-gpio", 0);
949 if (!gpio_is_valid(p_tas2562->mn_irq_gpio)) { 961 if (!gpio_is_valid(p_tas2562->mn_irq_gpio)) {
950 dev_err(p_tas2562->dev, "Looking up %s property in node %s failed %d\n", 962 dev_err(p_tas2562->dev,
963 "Looking up %s property in node %s failed %d\n",
951 "ti,irq-gpio", np->full_name, p_tas2562->mn_irq_gpio); 964 "ti,irq-gpio", np->full_name, p_tas2562->mn_irq_gpio);
952 } else { 965 } else {
953 dev_dbg(p_tas2562->dev, "ti,irq-gpio=%d", 966 dev_dbg(p_tas2562->dev, "ti,irq-gpio=%d",
954 p_tas2562->mn_irq_gpio); 967 p_tas2562->mn_irq_gpio);
955 } 968 }
956 969
957 if(p_tas2562->mn_channels != 1) { 970 if (p_tas2562->mn_channels != 1) {
958 971 p_tas2562->mn_irq_gpio2
959 972 = of_get_named_gpio(np, "ti,irq-gpio2", 0);
960 p_tas2562->mn_irq_gpio2 = of_get_named_gpio(np, "ti,irq-gpio2", 0);
961 if (!gpio_is_valid(p_tas2562->mn_irq_gpio2)) { 973 if (!gpio_is_valid(p_tas2562->mn_irq_gpio2)) {
962 dev_dbg(p_tas2562->dev, "Looking up %s property in node %s failed %d\n", 974 dev_dbg(p_tas2562->dev,
975 "Looking up %s property in node %s failed %d\n",
963 "ti,irq-gpio2", np->full_name, p_tas2562->mn_irq_gpio2); 976 "ti,irq-gpio2", np->full_name, p_tas2562->mn_irq_gpio2);
964 } else { 977 } else {
965 dev_dbg(p_tas2562->dev, "ti,irq-gpio2=%d", 978 dev_dbg(p_tas2562->dev, "ti,irq-gpio2=%d",
diff --git a/tas25xx-calib.c b/tas25xx-calib.c
index 0328ed1..0381c25 100644
--- a/tas25xx-calib.c
+++ b/tas25xx-calib.c
@@ -55,7 +55,8 @@ static int smartamp_params_ctrl(uint8_t *input, u8 dir, u8 count)
55 int special_index = 0; 55 int special_index = 0;
56 struct tas_dsp_pkt *ppacket; 56 struct tas_dsp_pkt *ppacket;
57 57
58 ppacket = (struct tas_dsp_pkt*)kmalloc (sizeof(struct tas_dsp_pkt), GFP_KERNEL); 58 ppacket = (struct tas_dsp_pkt *)kmalloc(sizeof(struct tas_dsp_pkt),
59 GFP_KERNEL);
59 if (!ppacket) { 60 if (!ppacket) {
60 pr_err ("[TI-SmartPA:%s] pperror kmalloc failed!", __func__); 61 pr_err ("[TI-SmartPA:%s] pperror kmalloc failed!", __func__);
61 return -ENOMEM; 62 return -ENOMEM;
@@ -79,17 +80,18 @@ static int smartamp_params_ctrl(uint8_t *input, u8 dir, u8 count)
79 return -1; 80 return -1;
80 } 81 }
81 } 82 }
82 pr_info("[TI-SmartPA:%s] Valid Index. special = %s\n", __func__, special_index ? "Yes" : "No"); 83 pr_info("[TI-SmartPA:%s] Valid Index. special = %s\n",
84 __func__, special_index ? "Yes" : "No");
83 85
84 /* speakers are differentiated by slave ids */ 86 /* speakers are differentiated by slave ids */
85 if (ppacket->slave_id == SLAVE1 ) 87 if (ppacket->slave_id == SLAVE1) {
86 { 88 paramid = (paramid | (index) | (length << 16) | (1 << 24));
87 paramid = (paramid | (index ) | (length << 16) | (1 << 24)); 89 pr_info("[TI-SmartPA:%s] Rcvd Slave id for slave 1, %x\n",
88 pr_info("[TI-SmartPA:%s] Rcvd Slave id for slave 1, %x\n", __func__, ppacket->slave_id); 90 __func__, ppacket->slave_id);
89 }else if (ppacket->slave_id == SLAVE2 ) 91 } else if (ppacket->slave_id == SLAVE2) {
90 { 92 paramid = (paramid | (index) | (length << 16) | (2 << 24));
91 paramid = (paramid | (index ) | (length << 16) | (2 << 24)); 93 pr_info("[TI-SmartPA:%s] Rcvd Slave id for slave 2, %x\n",
92 pr_info("[TI-SmartPA:%s] Rcvd Slave id for slave 2, %x\n", __func__, ppacket->slave_id); 94 __func__, ppacket->slave_id);
93 }else{ 95 }else{
94 pr_err("[TI-SmartPA:%s] Wrong slaveid = %x\n", __func__, ppacket->slave_id); 96 pr_err("[TI-SmartPA:%s] Wrong slaveid = %x\n", __func__, ppacket->slave_id);
95 } 97 }
@@ -120,7 +122,8 @@ static int smartamp_params_ctrl(uint8_t *input, u8 dir, u8 count)
120 if (dir == TAS_GET_PARAM) { 122 if (dir == TAS_GET_PARAM) {
121 ret = copy_to_user(input, ppacket, sizeof(struct tas_dsp_pkt)); 123 ret = copy_to_user(input, ppacket, sizeof(struct tas_dsp_pkt));
122 if (ret) { 124 if (ret) {
123 pr_err("[TI-SmartPA:%s] Error copying to user after DSP", __func__); 125 pr_err("[TI-SmartPA:%s] Error copying to user after DSP",
126 __func__);
124 ret = -EFAULT; 127 ret = -EFAULT;
125 } 128 }
126 } 129 }
@@ -138,7 +141,8 @@ static ssize_t tas_calib_write(struct file *file,
138 const char __user *buffer, size_t count, loff_t *offp) 141 const char __user *buffer, size_t count, loff_t *offp)
139{ 142{
140 int rc = 0; 143 int rc = 0;
141 rc = smartamp_params_ctrl((uint8_t *)buffer, TAS_SET_PARAM, count); 144 rc = smartamp_params_ctrl((uint8_t *)buffer,
145 TAS_SET_PARAM, count);
142 return rc; 146 return rc;
143} 147}
144 148
@@ -183,7 +187,8 @@ int tas_calib_init(void)
183 pr_err("[TI-SmartPA:%s]",__func__); 187 pr_err("[TI-SmartPA:%s]",__func__);
184 rc = misc_register(&tas_calib_misc); 188 rc = misc_register(&tas_calib_misc);
185 if (rc) 189 if (rc)
186 pr_err("[TI-SmartPA:%s] register calib misc failed\n", __func__); 190 pr_err("[TI-SmartPA:%s] register calib misc failed\n",
191 __func__);
187 return rc; 192 return rc;
188} 193}
189 194