Linux kernel staging patches
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-staging@lists.linux.dev,
	Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 031/113] ALSA: core: oss: use snd_pcm_is_playback/capture()
Date: Mon, 5 Aug 2024 00:37:28 +0000	[thread overview]
Message-ID: <87v80fztx3.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <874j7z3j1a.wl-kuninori.morimoto.gx@renesas.com>

We can use snd_pcm_is_playback/capture(). Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/core/oss/io.c         |  2 +-
 sound/core/oss/pcm_oss.c    | 20 ++++++++++----------
 sound/core/oss/pcm_plugin.c | 10 +++++-----
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/sound/core/oss/io.c b/sound/core/oss/io.c
index d870b2d93135d..86d25f2e01ea6 100644
--- a/sound/core/oss/io.c
+++ b/sound/core/oss/io.c
@@ -128,7 +128,7 @@ int snd_pcm_plugin_build_io(struct snd_pcm_substream *plug,
 	if (err < 0)
 		return err;
 	plugin->access = params_access(params);
-	if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(snd_pcm_plug_stream(plug))) {
 		plugin->transfer = io_playback_transfer;
 		if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED)
 			plugin->client_channels = io_src_channels;
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 7386982cf40ed..aeaf9c69e791f 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -986,7 +986,7 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
 					"snd_pcm_plugin_build_io failed: %i\n", err);
 				goto failure;
 			}
-			if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+			if (snd_pcm_is_playback(substream)) {
 				err = snd_pcm_plugin_append(plugin);
 			} else {
 				err = snd_pcm_plugin_insert(plugin);
@@ -1003,13 +1003,13 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
 		sw_params->start_threshold = runtime->boundary;
 	}
 	if (atomic_read(&substream->mmap_count) ||
-	    substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+	    snd_pcm_is_capture(substream))
 		sw_params->stop_threshold = runtime->boundary;
 	else
 		sw_params->stop_threshold = runtime->buffer_size;
 	sw_params->tstamp_mode = SNDRV_PCM_TSTAMP_NONE;
 	sw_params->period_step = 1;
-	sw_params->avail_min = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
+	sw_params->avail_min = snd_pcm_is_playback(substream) ?
 		1 : runtime->period_size;
 	if (atomic_read(&substream->mmap_count) ||
 	    substream->oss.setup.nosilence) {
@@ -2017,7 +2017,7 @@ static int snd_pcm_oss_get_caps1(struct snd_pcm_substream *substream, int res)
 		return res;
 	}
 #ifdef DSP_CAP_MULTI
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		if (substream->pstr->substream_count > 1)
 			res |= DSP_CAP_MULTI;
 #endif
@@ -2201,7 +2201,7 @@ static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream
 			return -EFAULT;
 		return 0;
 	}
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &delay);
 		if (err == -EPIPE || err == -ESTRPIPE || (! err && delay < 0)) {
 			err = 0;
@@ -2225,12 +2225,12 @@ static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream
 			n += runtime->boundary;
 		info.blocks = n / runtime->period_size;
 		runtime->oss.prev_hw_ptr_period = delay;
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(substream))
 			snd_pcm_oss_simulate_fill(substream, delay);
 		info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX;
 	} else {
 		delay = snd_pcm_oss_bytes(substream, delay);
-		if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(stream)) {
 			if (substream->oss.setup.buggyptr)
 				info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes;
 			else
@@ -2272,7 +2272,7 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre
 	info.fragsize = runtime->oss.period_bytes;
 	info.fragstotal = runtime->periods;
 	if (runtime->oss.prepare) {
-		if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(stream)) {
 			info.bytes = runtime->oss.period_bytes * runtime->oss.periods;
 			info.fragments = runtime->oss.periods;
 		} else {
@@ -2280,7 +2280,7 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre
 			info.fragments = 0;
 		}
 	} else {
-		if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(stream)) {
 			err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &avail);
 			if (err == -EPIPE || err == -ESTRPIPE || (! err && avail < 0)) {
 				avail = runtime->buffer_size;
@@ -2429,7 +2429,7 @@ static int snd_pcm_oss_open_file(struct file *file,
 			continue;
 		if (! pcm->streams[idx].substream_count)
 			continue; /* no matching substream */
-		if (idx == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(idx)) {
 			if (! (f_mode & FMODE_WRITE))
 				continue;
 		} else {
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index 82e180c776ae1..47168e175c966 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -54,7 +54,7 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
 	unsigned int channel;
 	struct snd_pcm_plugin_channel *c;
 
-	if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(plugin->stream)) {
 		format = &plugin->src_format;
 	} else {
 		format = &plugin->dst_format;
@@ -110,7 +110,7 @@ int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames)
 	int err;
 	if (snd_BUG_ON(!snd_pcm_plug_first(plug)))
 		return -ENXIO;
-	if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(snd_pcm_plug_stream(plug))) {
 		struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug);
 		while (plugin->next) {
 			if (plugin->dst_frames)
@@ -174,7 +174,7 @@ int snd_pcm_plugin_build(struct snd_pcm_substream *plug,
 	plugin->dst_format = *dst_format;
 	plugin->dst_width = snd_pcm_format_physical_width(dst_format->format);
 	snd_BUG_ON(plugin->dst_width <= 0);
-	if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(plugin->stream))
 		channels = src_format->channels;
 	else
 		channels = dst_format->channels;
@@ -567,7 +567,7 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu
 
 	if (snd_BUG_ON(!buf))
 		return -ENXIO;
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		plugin = snd_pcm_plug_first(plug);
 		format = &plugin->src_format;
 	} else {
@@ -586,7 +586,7 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu
 	for (channel = 0; channel < nchannels; channel++, v++) {
 		v->frames = count;
 		v->enabled = 1;
-		v->wanted = (stream == SNDRV_PCM_STREAM_CAPTURE);
+		v->wanted = snd_pcm_is_capture(stream);
 		v->area.addr = buf;
 		v->area.first = channel * width;
 		v->area.step = nchannels * width;
-- 
2.43.0


  parent reply	other threads:[~2024-08-05  0:37 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05  0:33 [PATCH 000/113] ALSA: add snd_pcm_is_playback/capture() macro Kuninori Morimoto
2024-08-05  0:33 ` [PATCH 001/113] " Kuninori Morimoto
2024-08-05  0:34 ` [PATCH 002/113] slimbus: stream: use snd_pcm_is_playback/capture() Kuninori Morimoto
2024-08-05  0:34 ` [PATCH 003/113] staging: greybus: " Kuninori Morimoto
2024-08-05  0:34 ` [PATCH 004/113] soundwire: amd: " Kuninori Morimoto
2024-08-05  0:34 ` [PATCH 005/113] soundwire: qcom: " Kuninori Morimoto
2024-08-05  0:34 ` [PATCH 006/113] soundwire: intel: " Kuninori Morimoto
2024-08-05  0:34 ` [PATCH 007/113] soundwire: stream: " Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 008/113] usb: gadget: use for_each_pcm_streams() Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 009/113] usb: gadget: use snd_pcm_is_playback/capture() Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 010/113] ALSA: isa: " Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 011/113] ALSA: arm: " Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 012/113] ALSA: xen: " Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 013/113] ALSA: usb: " Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 014/113] ALSA: pci: hda: " Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 015/113] ALSA: pci: ac97: " Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 016/113] ALSA: pci: nm256: " Kuninori Morimoto
2024-08-05  0:35 ` [PATCH 017/113] ALSA: pci: pcxhr: " Kuninori Morimoto
2024-08-05  0:36 ` [PATCH 018/113] ALSA: pci: asihpi: " Kuninori Morimoto
2024-08-05  0:36 ` [PATCH 019/113] ALSA: pci: au88x0: " Kuninori Morimoto
2024-08-05  0:36 ` [PATCH 020/113] ALSA: pci: ca0106: " Kuninori Morimoto
2024-08-05  0:36 ` [PATCH 021/113] ALSA: pci: mixart: " Kuninori Morimoto
2024-08-05  0:36 ` [PATCH 022/113] ALSA: pci: emu10k1: " Kuninori Morimoto
2024-08-05  0:36 ` [PATCH 023/113] ALSA: pci: ice1712: " Kuninori Morimoto
2024-08-05  0:36 ` [PATCH 024/113] ALSA: pci: rme9652: " Kuninori Morimoto
2024-08-05  0:36 ` [PATCH 025/113] ALSA: pci: korg1212: " Kuninori Morimoto
2024-08-05  0:36 ` [PATCH 026/113] ALSA: pci: lx6464es: " Kuninori Morimoto
2024-08-05  0:37 ` [PATCH 027/113] ALSA: pci: " Kuninori Morimoto
2024-08-05  0:37 ` [PATCH 028/113] ALSA: ppc: " Kuninori Morimoto
2024-08-05  0:37 ` [PATCH 029/113] ALSA: mips: " Kuninori Morimoto
2024-08-05  0:37 ` [PATCH 030/113] ALSA: core: " Kuninori Morimoto
2024-08-05  0:37 ` Kuninori Morimoto [this message]
2024-08-05  0:37 ` [PATCH 032/113] ALSA: virtio: " Kuninori Morimoto
2024-08-05  0:37 ` [PATCH 033/113] ALSA: include: " Kuninori Morimoto
2024-08-05  0:37 ` [PATCH 034/113] ALSA: drivers: " Kuninori Morimoto
2024-08-05  0:37 ` [PATCH 035/113] ALSA: firewire: motu: " Kuninori Morimoto
2024-08-05  0:37 ` [PATCH 036/113] ALSA: firewire: oxfw: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 037/113] ALSA: firewire: dice: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 038/113] ALSA: firewire: bebob: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 039/113] ALSA: firewire: tascam: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 040/113] ALSA: firewire: digi00x: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 041/113] ALSA: firewire: fireface: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 042/113] ALSA: firewire: fireworks: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 043/113] ASoC: ti: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 044/113] ASoC: sh: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 045/113] ASoC: adi: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 046/113] ASoC: amd: " Kuninori Morimoto
2024-08-05  0:38 ` [PATCH 047/113] ASoC: bcm: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 048/113] ASoC: dwc: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 049/113] ASoC: fsl: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 050/113] ASoC: mxs: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 051/113] ASoC: pxa: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 052/113] ASoC: sti: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 053/113] ASoC: stm: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 054/113] ASoC: sof: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 055/113] ASoC: sof: intel: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 056/113] ASoC: qcom: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 057/113] ASoC: sprd: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 058/113] ASoC: au1x: " Kuninori Morimoto
2024-08-05  0:39 ` [PATCH 059/113] ASoC: apple: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 060/113] ASoC: atmel: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 061/113] ASoC: intel: avs: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 062/113] ASoC: intel: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 063/113] ASoC: soc-*: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 064/113] ASoC: spear: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 065/113] ASoC: sunxi: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 066/113] ASoC: tegra: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 067/113] ASoC: ux500: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 068/113] ASoC: cirrus: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 069/113] ASoC: google: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 070/113] ASoC: jz4740: " Kuninori Morimoto
2024-08-05  0:40 ` [PATCH 071/113] ASoC: xilinx: " Kuninori Morimoto
2024-08-05  0:41 ` [PATCH 072/113] ASoC: codecs: cs*: " Kuninori Morimoto
2024-08-05  0:41 ` [PATCH 073/113] ASoC: codecs: rt*: " Kuninori Morimoto
2024-08-05  0:41 ` [PATCH 074/113] ASoC: codecs: wm*: " Kuninori Morimoto
2024-08-05  0:41 ` [PATCH 075/113] ASoC: codecs: ac97: " Kuninori Morimoto
2024-08-05  0:41 ` [PATCH 076/113] ASoC: codecs: cpcap: " Kuninori Morimoto
2024-08-05  0:41 ` [PATCH 077/113] ASoC: codecs: es83xx: " Kuninori Morimoto
2024-08-05  0:41 ` [PATCH 078/113] ASoC: codecs: ad193x: " Kuninori Morimoto
2024-08-05  0:41 ` [PATCH 079/113] ASoC: codecs: ak46xx: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 080/113] ASoC: codecs: jz47xx: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 081/113] ASoC: codecs: mt635x: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 082/113] ASoC: codecs: sta529: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 083/113] ASoC: codecs: rk3308: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 084/113] ASoC: codecs: wl1273: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 085/113] ASoC: codecs: mc13783: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 086/113] ASoC: codecs: nau882x: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 087/113] ASoC: codecs: peb2466: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 088/113] ASoC: codecs: sma1303: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 089/113] ASoC: codecs: adav80x: " Kuninori Morimoto
2024-08-05  0:42 ` [PATCH 090/113] ASoC: codecs: twl4030: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 091/113] ASoC: codecs: uda1380: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 092/113] ASoC: codecs: wcd93xx: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 093/113] ASoC: codecs: zl38060: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 094/113] ASoC: codecs: adau17xx: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 095/113] ASoC: codecs: hdac_hda: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 096/113] ASoC: codecs: max983xx: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 097/113] ASoC: codecs: sgtl5000: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 098/113] ASoC: codecs: stac9766: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 099/113] ASoC: codecs: tscs4xxx: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 100/113] ASoC: codecs: idt821034: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 101/113] ASoC: codecs: sdw-mockup: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 102/113] ASoC: codecs: hdmi-codec: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 103/113] ASoC: codecs: tlv320aic23: " Kuninori Morimoto
2024-08-05  0:43 ` [PATCH 104/113] ASoC: codecs: framer-codec: " Kuninori Morimoto
2024-08-05  0:44 ` [PATCH 105/113] ASoC: samsung: " Kuninori Morimoto
2024-08-05  0:44 ` [PATCH 106/113] ASoC: kirkwood: " Kuninori Morimoto
2024-08-05  0:44 ` [PATCH 107/113] ASoC: loongson: " Kuninori Morimoto
2024-08-05  0:44 ` [PATCH 108/113] ASoC: mediatek: " Kuninori Morimoto
2024-08-05  0:44 ` [PATCH 109/113] ASoC: rockchip: " Kuninori Morimoto
2024-08-05  0:44 ` [PATCH 110/113] ASoC: starfive: " Kuninori Morimoto
2024-08-05  0:44 ` [PATCH 111/113] ASoC: uniphier: " Kuninori Morimoto
2024-08-05  0:44 ` [PATCH 112/113] ASoC: hisilicon: " Kuninori Morimoto
2024-08-05  0:44 ` [PATCH 113/113] ASoC: sdw_utils: " Kuninori Morimoto
2024-08-05 10:43 ` [PATCH 000/113] ALSA: add snd_pcm_is_playback/capture() macro Mark Brown
2024-08-05 14:04 ` Jaroslav Kysela
2024-08-05 19:37   ` Mark Brown
2024-09-13  1:35     ` Kuninori Morimoto
2024-09-13  7:14       ` Takashi Iwai
2024-09-16 23:41         ` Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v80fztx3.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox