@@ -1534,7 +1534,7 @@ int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
1534
1534
be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_CLOSE ;
1535
1535
goto unwind ;
1536
1536
}
1537
-
1537
+ be -> dpcm [ stream ]. be_start = 0 ;
1538
1538
be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_OPEN ;
1539
1539
count ++ ;
1540
1540
}
@@ -2001,6 +2001,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2001
2001
int ret = 0 ;
2002
2002
unsigned long flags ;
2003
2003
enum snd_soc_dpcm_state state ;
2004
+ bool do_trigger ;
2004
2005
2005
2006
for_each_dpcm_be (fe , stream , dpcm ) {
2006
2007
struct snd_pcm_substream * be_substream ;
@@ -2015,6 +2016,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2015
2016
dev_dbg (be -> dev , "ASoC: trigger BE %s cmd %d\n" ,
2016
2017
be -> dai_link -> name , cmd );
2017
2018
2019
+ do_trigger = false;
2018
2020
switch (cmd ) {
2019
2021
case SNDRV_PCM_TRIGGER_START :
2020
2022
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
@@ -2025,13 +2027,20 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2025
2027
continue ;
2026
2028
}
2027
2029
state = be -> dpcm [stream ].state ;
2030
+ if (be -> dpcm [stream ].be_start == 0 )
2031
+ do_trigger = true;
2032
+ be -> dpcm [stream ].be_start ++ ;
2028
2033
be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_START ;
2029
2034
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2030
2035
2036
+ if (!do_trigger )
2037
+ continue ;
2038
+
2031
2039
ret = soc_pcm_trigger (be_substream , cmd );
2032
2040
if (ret ) {
2033
2041
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2034
2042
be -> dpcm [stream ].state = state ;
2043
+ be -> dpcm [stream ].be_start -- ;
2035
2044
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2036
2045
goto end ;
2037
2046
}
@@ -2045,13 +2054,20 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2045
2054
}
2046
2055
2047
2056
state = be -> dpcm [stream ].state ;
2057
+ if (be -> dpcm [stream ].be_start == 0 )
2058
+ do_trigger = true;
2059
+ be -> dpcm [stream ].be_start ++ ;
2048
2060
be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_START ;
2049
2061
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2050
2062
2063
+ if (!do_trigger )
2064
+ continue ;
2065
+
2051
2066
ret = soc_pcm_trigger (be_substream , cmd );
2052
2067
if (ret ) {
2053
2068
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2054
2069
be -> dpcm [stream ].state = state ;
2070
+ be -> dpcm [stream ].be_start -- ;
2055
2071
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2056
2072
goto end ;
2057
2073
}
@@ -2065,13 +2081,20 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2065
2081
}
2066
2082
2067
2083
state = be -> dpcm [stream ].state ;
2084
+ if (be -> dpcm [stream ].be_start == 0 )
2085
+ do_trigger = true;
2086
+ be -> dpcm [stream ].be_start ++ ;
2068
2087
be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_START ;
2069
2088
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2070
2089
2090
+ if (!do_trigger )
2091
+ continue ;
2092
+
2071
2093
ret = soc_pcm_trigger (be_substream , cmd );
2072
2094
if (ret ) {
2073
2095
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2074
2096
be -> dpcm [stream ].state = state ;
2097
+ be -> dpcm [stream ].be_start -- ;
2075
2098
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2076
2099
goto end ;
2077
2100
}
@@ -2084,9 +2107,15 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2084
2107
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2085
2108
continue ;
2086
2109
}
2110
+ if ((be -> dpcm [stream ].state == SND_SOC_DPCM_STATE_START &&
2111
+ be -> dpcm [stream ].be_start == 1 ) ||
2112
+ (be -> dpcm [stream ].state == SND_SOC_DPCM_STATE_PAUSED &&
2113
+ be -> dpcm [stream ].be_start == 0 ))
2114
+ do_trigger = true;
2115
+ be -> dpcm [stream ].be_start -- ;
2087
2116
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2088
2117
2089
- if (!snd_soc_dpcm_can_be_free_stop ( fe , be , stream ) )
2118
+ if (!do_trigger )
2090
2119
continue ;
2091
2120
2092
2121
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
@@ -2098,6 +2127,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2098
2127
if (ret ) {
2099
2128
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2100
2129
be -> dpcm [stream ].state = state ;
2130
+ be -> dpcm [stream ].be_start ++ ;
2101
2131
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2102
2132
goto end ;
2103
2133
}
@@ -2109,9 +2139,12 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2109
2139
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2110
2140
continue ;
2111
2141
}
2142
+ if (be -> dpcm [stream ].be_start == 1 )
2143
+ do_trigger = true;
2144
+ be -> dpcm [stream ].be_start -- ;
2112
2145
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2113
2146
2114
- if (!snd_soc_dpcm_can_be_free_stop ( fe , be , stream ) )
2147
+ if (!do_trigger )
2115
2148
continue ;
2116
2149
2117
2150
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
@@ -2123,6 +2156,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2123
2156
if (ret ) {
2124
2157
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2125
2158
be -> dpcm [stream ].state = state ;
2159
+ be -> dpcm [stream ].be_start ++ ;
2126
2160
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2127
2161
goto end ;
2128
2162
}
@@ -2134,9 +2168,12 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2134
2168
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2135
2169
continue ;
2136
2170
}
2171
+ if (be -> dpcm [stream ].be_start == 1 )
2172
+ do_trigger = true;
2173
+ be -> dpcm [stream ].be_start -- ;
2137
2174
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2138
2175
2139
- if (!snd_soc_dpcm_can_be_free_stop ( fe , be , stream ) )
2176
+ if (!do_trigger )
2140
2177
continue ;
2141
2178
2142
2179
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
@@ -2148,6 +2185,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2148
2185
if (ret ) {
2149
2186
spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2150
2187
be -> dpcm [stream ].state = state ;
2188
+ be -> dpcm [stream ].be_start ++ ;
2151
2189
spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2152
2190
goto end ;
2153
2191
}
0 commit comments