@@ -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
- be -> dpcm [ stream ]. be_start = 0 ;
1537
+
1538
1538
be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_OPEN ;
1539
1539
count ++ ;
1540
1540
}
@@ -1999,9 +1999,6 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
1999
1999
struct snd_soc_pcm_runtime * be ;
2000
2000
struct snd_soc_dpcm * dpcm ;
2001
2001
int ret = 0 ;
2002
- unsigned long flags ;
2003
- enum snd_soc_dpcm_state state ;
2004
- bool do_trigger ;
2005
2002
2006
2003
for_each_dpcm_be (fe , stream , dpcm ) {
2007
2004
struct snd_pcm_substream * be_substream ;
@@ -2016,180 +2013,78 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2016
2013
dev_dbg (be -> dev , "ASoC: trigger BE %s cmd %d\n" ,
2017
2014
be -> dai_link -> name , cmd );
2018
2015
2019
- do_trigger = false;
2020
2016
switch (cmd ) {
2021
2017
case SNDRV_PCM_TRIGGER_START :
2022
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2023
2018
if ((be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_PREPARE ) &&
2024
2019
(be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_STOP ) &&
2025
- (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_PAUSED )) {
2026
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2027
- continue ;
2028
- }
2029
- state = be -> dpcm [stream ].state ;
2030
- if (be -> dpcm [stream ].be_start == 0 )
2031
- do_trigger = true;
2032
- be -> dpcm [stream ].be_start ++ ;
2033
- be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_START ;
2034
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2035
-
2036
- if (!do_trigger )
2020
+ (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_PAUSED ))
2037
2021
continue ;
2038
2022
2039
2023
ret = soc_pcm_trigger (be_substream , cmd );
2040
- if (ret ) {
2041
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2042
- be -> dpcm [stream ].state = state ;
2043
- be -> dpcm [stream ].be_start -- ;
2044
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2024
+ if (ret )
2045
2025
goto end ;
2046
- }
2047
2026
2027
+ be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_START ;
2048
2028
break ;
2049
2029
case SNDRV_PCM_TRIGGER_RESUME :
2050
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2051
- if (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_SUSPEND ) {
2052
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2053
- continue ;
2054
- }
2055
-
2056
- state = be -> dpcm [stream ].state ;
2057
- if (be -> dpcm [stream ].be_start == 0 )
2058
- do_trigger = true;
2059
- be -> dpcm [stream ].be_start ++ ;
2060
- be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_START ;
2061
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2062
-
2063
- if (!do_trigger )
2030
+ if ((be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_SUSPEND ))
2064
2031
continue ;
2065
2032
2066
2033
ret = soc_pcm_trigger (be_substream , cmd );
2067
- if (ret ) {
2068
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2069
- be -> dpcm [stream ].state = state ;
2070
- be -> dpcm [stream ].be_start -- ;
2071
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2034
+ if (ret )
2072
2035
goto end ;
2073
- }
2074
2036
2037
+ be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_START ;
2075
2038
break ;
2076
2039
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE :
2077
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2078
- if (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_PAUSED ) {
2079
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2080
- continue ;
2081
- }
2082
-
2083
- state = be -> dpcm [stream ].state ;
2084
- if (be -> dpcm [stream ].be_start == 0 )
2085
- do_trigger = true;
2086
- be -> dpcm [stream ].be_start ++ ;
2087
- be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_START ;
2088
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2089
-
2090
- if (!do_trigger )
2040
+ if ((be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_PAUSED ))
2091
2041
continue ;
2092
2042
2093
2043
ret = soc_pcm_trigger (be_substream , cmd );
2094
- if (ret ) {
2095
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2096
- be -> dpcm [stream ].state = state ;
2097
- be -> dpcm [stream ].be_start -- ;
2098
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2044
+ if (ret )
2099
2045
goto end ;
2100
- }
2101
2046
2047
+ be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_START ;
2102
2048
break ;
2103
2049
case SNDRV_PCM_TRIGGER_STOP :
2104
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2105
2050
if ((be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_START ) &&
2106
- (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_PAUSED )) {
2107
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2108
- continue ;
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 -- ;
2116
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2117
-
2118
- if (!do_trigger )
2051
+ (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_PAUSED ))
2119
2052
continue ;
2120
2053
2121
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2122
- state = be -> dpcm [stream ].state ;
2123
- be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_STOP ;
2124
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2054
+ if (!snd_soc_dpcm_can_be_free_stop (fe , be , stream ))
2055
+ continue ;
2125
2056
2126
2057
ret = soc_pcm_trigger (be_substream , cmd );
2127
- if (ret ) {
2128
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2129
- be -> dpcm [stream ].state = state ;
2130
- be -> dpcm [stream ].be_start ++ ;
2131
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2058
+ if (ret )
2132
2059
goto end ;
2133
- }
2134
2060
2061
+ be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_STOP ;
2135
2062
break ;
2136
2063
case SNDRV_PCM_TRIGGER_SUSPEND :
2137
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2138
- if (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_START ) {
2139
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2064
+ if (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_START )
2140
2065
continue ;
2141
- }
2142
- if (be -> dpcm [stream ].be_start == 1 )
2143
- do_trigger = true;
2144
- be -> dpcm [stream ].be_start -- ;
2145
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2146
2066
2147
- if (!do_trigger )
2067
+ if (!snd_soc_dpcm_can_be_free_stop ( fe , be , stream ) )
2148
2068
continue ;
2149
2069
2150
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2151
- state = be -> dpcm [stream ].state ;
2152
- be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_STOP ;
2153
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2154
-
2155
2070
ret = soc_pcm_trigger (be_substream , cmd );
2156
- if (ret ) {
2157
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2158
- be -> dpcm [stream ].state = state ;
2159
- be -> dpcm [stream ].be_start ++ ;
2160
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2071
+ if (ret )
2161
2072
goto end ;
2162
- }
2163
2073
2074
+ be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_SUSPEND ;
2164
2075
break ;
2165
2076
case SNDRV_PCM_TRIGGER_PAUSE_PUSH :
2166
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2167
- if (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_START ) {
2168
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2077
+ if (be -> dpcm [stream ].state != SND_SOC_DPCM_STATE_START )
2169
2078
continue ;
2170
- }
2171
- if (be -> dpcm [stream ].be_start == 1 )
2172
- do_trigger = true;
2173
- be -> dpcm [stream ].be_start -- ;
2174
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2175
2079
2176
- if (!do_trigger )
2080
+ if (!snd_soc_dpcm_can_be_free_stop ( fe , be , stream ) )
2177
2081
continue ;
2178
2082
2179
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2180
- state = be -> dpcm [stream ].state ;
2181
- be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_PAUSED ;
2182
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2183
-
2184
2083
ret = soc_pcm_trigger (be_substream , cmd );
2185
- if (ret ) {
2186
- spin_lock_irqsave (& fe -> card -> dpcm_lock , flags );
2187
- be -> dpcm [stream ].state = state ;
2188
- be -> dpcm [stream ].be_start ++ ;
2189
- spin_unlock_irqrestore (& fe -> card -> dpcm_lock , flags );
2084
+ if (ret )
2190
2085
goto end ;
2191
- }
2192
2086
2087
+ be -> dpcm [stream ].state = SND_SOC_DPCM_STATE_PAUSED ;
2193
2088
break ;
2194
2089
}
2195
2090
}
0 commit comments