diff options
author | TS Shi Fu | 2019-08-12 00:37:36 -0500 |
---|---|---|
committer | TS Shi Fu | 2019-08-12 00:37:36 -0500 |
commit | 6719d43b6cf24f71a41f21ff28a461cde5905874 (patch) | |
tree | c4e752db971081f5b4493737e51e1649327ad974 | |
parent | 6f49f1b753e7fee19ded11247c7ff6208d40e905 (diff) | |
download | tas2562-stereo-android-driver-6719d43b6cf24f71a41f21ff28a461cde5905874.tar.gz tas2562-stereo-android-driver-6719d43b6cf24f71a41f21ff28a461cde5905874.tar.xz tas2562-stereo-android-driver-6719d43b6cf24f71a41f21ff28a461cde5905874.zip |
Fix interrupt issue and add the pm_ops
-rw-r--r-- | tas2562-codec.c | 13 | ||||
-rw-r--r-- | tas2562-regmap.c | 36 |
2 files changed, 43 insertions, 6 deletions
diff --git a/tas2562-codec.c b/tas2562-codec.c index 0ba978a..6f31d94 100644 --- a/tas2562-codec.c +++ b/tas2562-codec.c | |||
@@ -245,6 +245,7 @@ static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562, | |||
245 | return n_result; | 245 | return n_result; |
246 | } | 246 | } |
247 | 247 | ||
248 | #if 0 | ||
248 | static int tas2562_codec_suspend(struct snd_soc_codec *codec) | 249 | static int tas2562_codec_suspend(struct snd_soc_codec *codec) |
249 | { | 250 | { |
250 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); | 251 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); |
@@ -272,6 +273,7 @@ static int tas2562_codec_resume(struct snd_soc_codec *codec) | |||
272 | mutex_unlock(&p_tas2562->codec_lock); | 273 | mutex_unlock(&p_tas2562->codec_lock); |
273 | return ret; | 274 | return ret; |
274 | } | 275 | } |
276 | #endif | ||
275 | 277 | ||
276 | static int tas2562_set_power_state(struct tas2562_priv *p_tas2562, | 278 | static int tas2562_set_power_state(struct tas2562_priv *p_tas2562, |
277 | enum channel chn, int state) | 279 | enum channel chn, int state) |
@@ -557,8 +559,7 @@ static int tas2562_set_bitwidth(struct tas2562_priv *p_tas2562, int bitwidth) | |||
557 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_MASK, | 559 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_MASK, |
558 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_16BITS); | 560 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_16BITS); |
559 | p_tas2562->mn_ch_size = 16; | 561 | p_tas2562->mn_ch_size = 16; |
560 | if (p_tas2562->mn_slot_width == 0) | 562 | slot_width_tmp = 16; |
561 | slot_width_tmp = 16; | ||
562 | break; | 563 | break; |
563 | case SNDRV_PCM_FORMAT_S24_LE: | 564 | case SNDRV_PCM_FORMAT_S24_LE: |
564 | p_tas2562->update_bits(p_tas2562, channel_both, | 565 | p_tas2562->update_bits(p_tas2562, channel_both, |
@@ -566,8 +567,7 @@ static int tas2562_set_bitwidth(struct tas2562_priv *p_tas2562, int bitwidth) | |||
566 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_MASK, | 567 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_MASK, |
567 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_24BITS); | 568 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_24BITS); |
568 | p_tas2562->mn_ch_size = 24; | 569 | p_tas2562->mn_ch_size = 24; |
569 | if (p_tas2562->mn_slot_width == 0) | 570 | slot_width_tmp = 32; |
570 | slot_width_tmp = 32; | ||
571 | break; | 571 | break; |
572 | case SNDRV_PCM_FORMAT_S32_LE: | 572 | case SNDRV_PCM_FORMAT_S32_LE: |
573 | p_tas2562->update_bits(p_tas2562, channel_both, | 573 | p_tas2562->update_bits(p_tas2562, channel_both, |
@@ -575,8 +575,7 @@ static int tas2562_set_bitwidth(struct tas2562_priv *p_tas2562, int bitwidth) | |||
575 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_MASK, | 575 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_MASK, |
576 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_32BITS); | 576 | TAS2562_TDMCONFIGURATIONREG2_RXWLEN32_32BITS); |
577 | p_tas2562->mn_ch_size = 32; | 577 | p_tas2562->mn_ch_size = 32; |
578 | if (p_tas2562->mn_slot_width == 0) | 578 | slot_width_tmp = 32; |
579 | slot_width_tmp = 32; | ||
580 | break; | 579 | break; |
581 | 580 | ||
582 | default: | 581 | default: |
@@ -1015,8 +1014,10 @@ static struct snd_soc_codec_driver soc_codec_driver_tas2562 = { | |||
1015 | .remove = tas2562_codec_remove, | 1014 | .remove = tas2562_codec_remove, |
1016 | .read = tas2562_codec_read, | 1015 | .read = tas2562_codec_read, |
1017 | .write = tas2562_codec_write, | 1016 | .write = tas2562_codec_write, |
1017 | #if 0 | ||
1018 | .suspend = tas2562_codec_suspend, | 1018 | .suspend = tas2562_codec_suspend, |
1019 | .resume = tas2562_codec_resume, | 1019 | .resume = tas2562_codec_resume, |
1020 | #endif | ||
1020 | .component_driver = { | 1021 | .component_driver = { |
1021 | .controls = tas2562_snd_controls, | 1022 | .controls = tas2562_snd_controls, |
1022 | .num_controls = ARRAY_SIZE(tas2562_snd_controls), | 1023 | .num_controls = ARRAY_SIZE(tas2562_snd_controls), |
diff --git a/tas2562-regmap.c b/tas2562-regmap.c index e6058d8..71e850b 100644 --- a/tas2562-regmap.c +++ b/tas2562-regmap.c | |||
@@ -824,6 +824,34 @@ static int tas2562_runtime_resume(struct tas2562_priv *p_tas2562) | |||
824 | return 0; | 824 | return 0; |
825 | } | 825 | } |
826 | 826 | ||
827 | static int tas2562_pm_suspend(struct device *dev) | ||
828 | { | ||
829 | struct tas2562_priv *p_tas2562 = dev_get_drvdata(dev); | ||
830 | |||
831 | if(!p_tas2562){ | ||
832 | dev_err(p_tas2562->dev, "drvdata is NULL\n"); | ||
833 | return -EINVAL; | ||
834 | } | ||
835 | |||
836 | mutex_lock(&p_tas2562->codec_lock); | ||
837 | tas2562_runtime_suspend(p_tas2562); | ||
838 | mutex_unlock(&p_tas2562->codec_lock); | ||
839 | return 0; | ||
840 | } | ||
841 | static int tas2562_pm_resume(struct device *dev) | ||
842 | { | ||
843 | struct tas2562_priv *p_tas2562 = dev_get_drvdata(dev); | ||
844 | |||
845 | if(!p_tas2562){ | ||
846 | dev_err(p_tas2562->dev, "drvdata is NULL\n"); | ||
847 | return -EINVAL; | ||
848 | } | ||
849 | mutex_lock(&p_tas2562->codec_lock); | ||
850 | tas2562_runtime_resume(p_tas2562); | ||
851 | mutex_unlock(&p_tas2562->codec_lock); | ||
852 | return 0; | ||
853 | } | ||
854 | |||
827 | static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *p_tas2562) | 855 | static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *p_tas2562) |
828 | { | 856 | { |
829 | struct device_node *np = dev->of_node; | 857 | struct device_node *np = dev->of_node; |
@@ -978,9 +1006,12 @@ static int tas2562_i2c_probe(struct i2c_client *p_client, | |||
978 | p_tas2562->update_bits = tas2562_dev_update_bits; | 1006 | p_tas2562->update_bits = tas2562_dev_update_bits; |
979 | p_tas2562->hw_reset = tas2562_hw_reset; | 1007 | p_tas2562->hw_reset = tas2562_hw_reset; |
980 | p_tas2562->enable_irq = tas2562_enable_irq; | 1008 | p_tas2562->enable_irq = tas2562_enable_irq; |
1009 | #if 0 | ||
981 | p_tas2562->runtime_suspend = tas2562_runtime_suspend; | 1010 | p_tas2562->runtime_suspend = tas2562_runtime_suspend; |
982 | p_tas2562->runtime_resume = tas2562_runtime_resume; | 1011 | p_tas2562->runtime_resume = tas2562_runtime_resume; |
983 | p_tas2562->mn_power_state = TAS2562_POWER_SHUTDOWN; | 1012 | p_tas2562->mn_power_state = TAS2562_POWER_SHUTDOWN; |
1013 | #endif | ||
1014 | p_tas2562->mn_power_state = TAS2562_POWER_SHUTDOWN; | ||
984 | p_tas2562->spk_l_control = 1; | 1015 | p_tas2562->spk_l_control = 1; |
985 | 1016 | ||
986 | mutex_init(&p_tas2562->dev_lock); | 1017 | mutex_init(&p_tas2562->dev_lock); |
@@ -1115,6 +1146,10 @@ static const struct of_device_id tas2562_of_match[] = { | |||
1115 | MODULE_DEVICE_TABLE(of, tas2562_of_match); | 1146 | MODULE_DEVICE_TABLE(of, tas2562_of_match); |
1116 | #endif | 1147 | #endif |
1117 | 1148 | ||
1149 | static const struct dev_pm_ops tas2562_pm_ops = { | ||
1150 | .suspend = tas2562_pm_suspend, | ||
1151 | .resume = tas2562_pm_resume | ||
1152 | }; | ||
1118 | 1153 | ||
1119 | static struct i2c_driver tas2562_i2c_driver = { | 1154 | static struct i2c_driver tas2562_i2c_driver = { |
1120 | .driver = { | 1155 | .driver = { |
@@ -1123,6 +1158,7 @@ static struct i2c_driver tas2562_i2c_driver = { | |||
1123 | #if defined(CONFIG_OF) | 1158 | #if defined(CONFIG_OF) |
1124 | .of_match_table = of_match_ptr(tas2562_of_match), | 1159 | .of_match_table = of_match_ptr(tas2562_of_match), |
1125 | #endif | 1160 | #endif |
1161 | .pm = &tas2562_pm_ops, | ||
1126 | }, | 1162 | }, |
1127 | .probe = tas2562_i2c_probe, | 1163 | .probe = tas2562_i2c_probe, |
1128 | .remove = tas2562_i2c_remove, | 1164 | .remove = tas2562_i2c_remove, |