audio: fix spdif not work on soundbar [1/1]
authoryujie.wu <yujie.wu@amlogic.com>
Thu, 11 Apr 2019 02:38:54 +0000 (10:38 +0800)
committerNick Xie <nick@khadas.com>
Mon, 5 Aug 2019 06:44:38 +0000 (14:44 +0800)
PD#SWPL-6801

Problem:
  There is too much kernel print which
  blocks the system

Solution:
  Add condition to remove the print log

Verify:
  A113

Change-Id: I5762893b424e8201e2725f33854473097f1246b9
Signed-off-by: yujie.wu <yujie.wu@amlogic.com>
sound/soc/amlogic/auge/extn.c
sound/soc/amlogic/auge/resample.c
sound/soc/amlogic/auge/resample.h
sound/soc/amlogic/auge/spdif.c

index e90909d..d414ddd 100644 (file)
@@ -395,7 +395,7 @@ static void extn_dai_shutdown(
        struct snd_pcm_substream *substream,
        struct snd_soc_dai *cpu_dai)
 {
-       //resample_set(RESAMPLE_A, RATE_OFF);
+       //resample_set(RESAMPLE_A, RATE_OFF, false);
 }
 
 static int extn_dai_prepare(
index 6b2fb6d..4348189 100644 (file)
@@ -265,7 +265,8 @@ static int resample_get_enum(
        return 0;
 }
 
-int resample_set(enum resample_idx id, enum samplerate_index index)
+/* force set to new rate index whatever the resampler holds */
+int resample_set(enum resample_idx id, enum samplerate_index index, bool force)
 {
        int resample_rate = 0;
        struct audioresample *p_resample = get_audioresample(id);
@@ -279,16 +280,15 @@ int resample_set(enum resample_idx id, enum samplerate_index index)
                return 0;
        }
 
+       if (index == p_resample->asrc_rate_idx && !force)
+               return 0;
+
        pr_info("%s resample_%c to %s, last %s\n",
                __func__,
                (id == RESAMPLE_A) ? 'a' : 'b',
                auge_resample_texts[index],
                auge_resample_texts[p_resample->asrc_rate_idx]);
 
-#if 0
-       if (index == p_resample->asrc_rate_idx)
-               return 0;
-#endif
        set_resample_rate_index(id, index);
 
        resample_rate = resample_idx2rate(index);
@@ -313,7 +313,7 @@ int resample_set_inner_rate(enum resample_idx id)
 
        pr_debug("%s() index %d\n", __func__, id);
 
-       return resample_set(id, index);
+       return resample_set(id, index, true);
 }
 
 static int resample_set_enum(
index b82aac3..c973522 100644 (file)
@@ -21,7 +21,8 @@
 
 extern int card_add_resample_kcontrols(struct snd_soc_card *card);
 
-extern int resample_set(enum resample_idx id, enum samplerate_index index);
+extern int resample_set(enum resample_idx id,
+       enum samplerate_index index, bool force);
 
 extern int get_resample_module_num(void);
 
index e8bead0..375a3a0 100644 (file)
@@ -483,10 +483,10 @@ static void spdifin_audio_type_work_func(struct work_struct *work)
 
        if (val & 0x2)
                /* nonpcm, resample disable */
-               resample_set(p_spdif->asrc_id, RATE_OFF);
+               resample_set(p_spdif->asrc_id, RATE_OFF, false);
        else
                /* pcm, resample which rate ? */
-               resample_set(p_spdif->asrc_id, p_spdif->auto_asrc);
+               resample_set(p_spdif->asrc_id, p_spdif->auto_asrc, false);
 }
 
 static void spdifin_audio_type_detect_init(struct aml_spdif *p_spdif)
@@ -672,7 +672,7 @@ static void spdifin_status_event(struct aml_spdif *p_spdif)
                                /* resample enable, by hw */
                                if (!spdifin_check_audiotype_by_sw(p_spdif))
                                        resample_set(p_spdif->asrc_id,
-                                               p_spdif->auto_asrc);
+                                               p_spdif->auto_asrc, false);
 #endif
                                extcon_set_state(p_spdif->edev,
                                        EXTCON_SPDIFIN_SAMPLERATE, 1);
@@ -694,7 +694,7 @@ static void spdifin_status_event(struct aml_spdif *p_spdif)
 #ifdef __SPDIFIN_AUDIO_TYPE_HW__
                        /* resample disable, by hw */
                        if (!spdifin_check_audiotype_by_sw(p_spdif))
-                               resample_set(p_spdif->asrc_id, RATE_OFF);
+                               resample_set(p_spdif->asrc_id, RATE_OFF, false);
 #endif
 #endif
                }
@@ -728,7 +728,8 @@ static void spdifin_status_event(struct aml_spdif *p_spdif)
 #ifdef __SPDIFIN_AUDIO_TYPE_HW__
                /* resample to 48k, by hw */
                if (!spdifin_check_audiotype_by_sw(p_spdif))
-                       resample_set(p_spdif->asrc_id, p_spdif->auto_asrc);
+                       resample_set(p_spdif->asrc_id,
+                               p_spdif->auto_asrc, false);
 #endif
        }
        if (intrpt_status & 0x40)
@@ -1097,7 +1098,8 @@ static int aml_dai_spdif_startup(
 #ifdef __SPDIFIN_AUDIO_TYPE_HW__
                /* resample to 48k in default, by hw */
                if (!spdifin_check_audiotype_by_sw(p_spdif))
-                       resample_set(p_spdif->asrc_id, p_spdif->auto_asrc);
+                       resample_set(p_spdif->asrc_id,
+                               p_spdif->auto_asrc, false);
 #endif
        }
 
@@ -1128,7 +1130,7 @@ static void aml_dai_spdif_shutdown(
 #ifdef __SPDIFIN_AUDIO_TYPE_HW__
                /* resample disabled, by hw */
                if (!spdifin_check_audiotype_by_sw(p_spdif))
-                       resample_set(p_spdif->asrc_id, RATE_OFF);
+                       resample_set(p_spdif->asrc_id, RATE_OFF, false);
 #endif
                clk_disable_unprepare(p_spdif->clk_spdifin);
                clk_disable_unprepare(p_spdif->fixed_clk);