@@ -3953,7 +3953,7 @@ static signed char *hdsp_channel_buffer_location(struct hdsp *hdsp,
if (mapped_channel < 0)
return NULL;
- if (stream == SNDRV_PCM_STREAM_CAPTURE)
+ if (snd_pcm_is_capture(stream))
return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES);
else
return hdsp->playback_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES);
@@ -4014,7 +4014,7 @@ static int snd_hdsp_reset(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
struct hdsp *hdsp = snd_pcm_substream_chip(substream);
struct snd_pcm_substream *other;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(substream))
other = hdsp->capture_substream;
else
other = hdsp->playback_substream;
@@ -4051,7 +4051,7 @@ static int snd_hdsp_hw_params(struct snd_pcm_substream *substream,
spin_lock_irq(&hdsp->lock);
- if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(substream->pstr->stream)) {
hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis);
hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= hdsp->creg_spdif_stream);
this_pid = hdsp->playback_pid;
@@ -4172,7 +4172,7 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
spin_unlock(&hdsp->lock);
return -EINVAL;
}
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(substream))
other = hdsp->capture_substream;
else
other = hdsp->playback_substream;
@@ -4191,15 +4191,15 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
}
if (cmd == SNDRV_PCM_TRIGGER_START) {
if (!(running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) &&
- substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+ snd_pcm_is_capture(substream))
hdsp_silence_playback(hdsp);
} else {
if (running &&
- substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ snd_pcm_is_playback(substream))
hdsp_silence_playback(hdsp);
}
} else {
- if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+ if (snd_pcm_is_capture(substream))
hdsp_silence_playback(hdsp);
}
_ok:
@@ -5465,7 +5465,7 @@ static int snd_hdspm_reset(struct snd_pcm_substream *substream)
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
struct snd_pcm_substream *other;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(substream))
other = hdspm->capture_substream;
else
other = hdspm->playback_substream;
@@ -5499,7 +5499,7 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
spin_lock_irq(&hdspm->lock);
- if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(substream->pstr->stream)) {
this_pid = hdspm->playback_pid;
other_pid = hdspm->capture_pid;
} else {
@@ -5570,7 +5570,7 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
return err;
}
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(substream)) {
for (i = 0; i < params_channels(params); ++i) {
int c = hdspm->channel_map_out[i];
@@ -5656,7 +5656,7 @@ static int snd_hdspm_hw_free(struct snd_pcm_substream *substream)
int i;
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(substream)) {
/* Just disable all channels. The saving when disabling a */
/* smaller set is not worth the trouble. */
for (i = 0; i < HDSPM_MAX_CHANNELS; ++i)
@@ -5682,7 +5682,7 @@ static int snd_hdspm_channel_info(struct snd_pcm_substream *substream,
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
unsigned int channel = info->channel;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(substream)) {
if (snd_BUG_ON(channel >= hdspm->max_channels_out)) {
dev_info(hdspm->card->dev,
"snd_hdspm_channel_info: output channel out of range (%d)\n",
@@ -5765,7 +5765,7 @@ static int snd_hdspm_trigger(struct snd_pcm_substream *substream, int cmd)
spin_unlock(&hdspm->lock);
return -EINVAL;
}
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(substream))
other = hdspm->capture_substream;
else
other = hdspm->playback_substream;
@@ -5784,16 +5784,15 @@ static int snd_hdspm_trigger(struct snd_pcm_substream *substream, int cmd)
}
if (cmd == SNDRV_PCM_TRIGGER_START) {
if (!(running & (1 << SNDRV_PCM_STREAM_PLAYBACK))
- && substream->stream ==
- SNDRV_PCM_STREAM_CAPTURE)
+ && snd_pcm_is_capture(substream))
hdspm_silence_playback(hdspm);
} else {
if (running &&
- substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ snd_pcm_is_playback(substream))
hdspm_silence_playback(hdspm);
}
} else {
- if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+ if (snd_pcm_is_capture(substream))
hdspm_silence_playback(hdspm);
}
_ok:
@@ -6046,7 +6045,7 @@ static int snd_hdspm_open(struct snd_pcm_substream *substream)
{
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
- bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+ bool playback = snd_pcm_is_playback(substream);
spin_lock_irq(&hdspm->lock);
snd_pcm_set_sync(substream);
@@ -6121,7 +6120,7 @@ static int snd_hdspm_open(struct snd_pcm_substream *substream)
static int snd_hdspm_release(struct snd_pcm_substream *substream)
{
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
- bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+ bool playback = snd_pcm_is_playback(substream);
spin_lock_irq(&hdspm->lock);
@@ -1833,7 +1833,7 @@ static signed char *rme9652_channel_buffer_location(struct snd_rme9652 *rme9652,
if (mapped_channel < 0)
return NULL;
- if (stream == SNDRV_PCM_STREAM_CAPTURE) {
+ if (snd_pcm_is_capture(stream)) {
return rme9652->capture_buffer +
(mapped_channel * RME9652_CHANNEL_BUFFER_BYTES);
} else {
@@ -1903,7 +1903,7 @@ static int snd_rme9652_reset(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
struct snd_pcm_substream *other;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(substream))
other = rme9652->capture_substream;
else
other = rme9652->playback_substream;
@@ -1934,7 +1934,7 @@ static int snd_rme9652_hw_params(struct snd_pcm_substream *substream,
spin_lock_irq(&rme9652->lock);
- if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if (snd_pcm_is_playback(substream->pstr->stream)) {
rme9652->control_register &= ~(RME9652_PRO | RME9652_Dolby | RME9652_EMP);
rme9652_write(rme9652, RME9652_control_register, rme9652->control_register |= rme9652->creg_spdif_stream);
this_pid = rme9652->playback_pid;
@@ -2056,7 +2056,7 @@ static int snd_rme9652_trigger(struct snd_pcm_substream *substream,
spin_unlock(&rme9652->lock);
return -EINVAL;
}
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ if (snd_pcm_is_playback(substream))
other = rme9652->capture_substream;
else
other = rme9652->playback_substream;
@@ -2075,15 +2075,15 @@ static int snd_rme9652_trigger(struct snd_pcm_substream *substream,
}
if (cmd == SNDRV_PCM_TRIGGER_START) {
if (!(running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) &&
- substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+ snd_pcm_is_capture(substream))
rme9652_silence_playback(rme9652);
} else {
if (running &&
- substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ snd_pcm_is_playback(substream))
rme9652_silence_playback(rme9652);
}
} else {
- if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+ if (snd_pcm_is_capture(substream))
rme9652_silence_playback(rme9652);
}
_ok:
We can use snd_pcm_is_playback/capture(). Let's use it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> --- sound/pci/rme9652/hdsp.c | 14 +++++++------- sound/pci/rme9652/hdspm.c | 23 +++++++++++------------ sound/pci/rme9652/rme9652.c | 14 +++++++------- 3 files changed, 25 insertions(+), 26 deletions(-)