Skip to contentSkip to conversation

ALSA: hda: use azx_stream() helper in all places

PATCH In review Jaroslav Kysela 2 participants 3 messages Jan 31, 2024 – Feb 1, 2024 Sound

lore
Share & tools
lore

Jaroslav Kysela

author maintainer
#0 lore raw

PATCH 1/1 ALSA: hda: use azx_stream() helper in all places

Make code more readable with azx_stream() helper. No functional change.

---
 sound/pci/hda/hda_controller.c | 20 +++++++-------
 sound/pci/hda/hda_intel.c      | 50 +++++++++++++++++-----------------
 2 files changed, 35 insertions(+), 35 deletions(-)
sound/pci/hda/hda_controller.c +10 -10
index 3e7bfeee84fd..0ec1e7192d72 100644
@@ -117,9 +117,9 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
 		goto unlock;
 	}
 
-	azx_dev->core.bufsize = 0;
-	azx_dev->core.period_bytes = 0;
-	azx_dev->core.format_val = 0;
+	azx_stream(azx_dev)->bufsize = 0;
+	azx_stream(azx_dev)->period_bytes = 0;
+	azx_stream(azx_dev)->format_val = 0;
 
 unlock:
 	dsp_unlock(azx_dev);
@@ -182,13 +182,13 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
 
 	snd_hdac_stream_setup(azx_stream(azx_dev), false);
 
-	stream_tag = azx_dev->core.stream_tag;
+	stream_tag = azx_stream(azx_dev)->stream_tag;
 	/* CA-IBG chips need the playback stream starting from 1 */
 	if ((chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND) &&
 	    stream_tag > chip->capture_streams)
 		stream_tag -= chip->capture_streams;
 	err = snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag,
-				     azx_dev->core.format_val, substream);
+				     azx_stream(azx_dev)->format_val, substream);
 
  unlock:
 	if (!err)
@@ -240,7 +240,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		if (s->pcm->card != substream->pcm->card)
 			continue;
 		azx_dev = get_azx_dev(s);
-		sbits |= 1 << azx_dev->core.index;
+		sbits |= 1 << azx_stream(azx_dev)->index;
 		snd_pcm_trigger_done(s, substream);
 	}
 
@@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(azx_get_pos_posbuf);
 unsigned int azx_get_position(struct azx *chip,
 			      struct azx_dev *azx_dev)
 {
-	struct snd_pcm_substream *substream = azx_dev->core.substream;
+	struct snd_pcm_substream *substream = azx_stream(azx_dev)->substream;
 	unsigned int pos;
 	int stream = substream->stream;
 	int delay = 0;
@@ -298,7 +298,7 @@ unsigned int azx_get_position(struct azx *chip,
 	else /* use the position buffer as default */
 		pos = azx_get_pos_posbuf(chip, azx_dev);
 
-	if (pos >= azx_dev->core.bufsize)
+	if (pos >= azx_stream(azx_dev)->bufsize)
 		pos = 0;
 
 	if (substream->runtime) {
@@ -386,7 +386,7 @@ static int azx_get_sync_time(ktime_t *device,
 	do {
 		timeout = 100;
 		dma_select = (direction << GTSCC_CDMAS_DMA_DIR_SHIFT) |
-					(azx_dev->core.stream_tag - 1);
+					(azx_stream(azx_dev)->stream_tag - 1);
 		snd_hdac_chip_writel(azx_bus(chip), GTSCC, dma_select);
 
 		/* Enable the capture */
@@ -501,7 +501,7 @@ static int azx_get_time_info(struct snd_pcm_substream *substream,
 
 		snd_pcm_gettime(substream->runtime, system_ts);
 
-		nsec = timecounter_read(&azx_dev->core.tc);
+		nsec = timecounter_read(&azx_stream(azx_dev)->tc);
 		if (audio_tstamp_config->report_delay)
 			nsec = azx_adjust_codec_delay(substream, nsec);
 
sound/pci/hda/hda_intel.c +25 -25

138 lines not on this page · raw message

Signature · 1 line
2.43.0
#1 lore raw
Quoted 4 lines · Jaroslav Kysela

Make code more readable with azx_stream() helper. No functional change.

I have no much preference, but using the macro doesn't look like a significant improvement to me, honestly speaking...

But I'm open for those. If you have further changes based on those updates, I can take now, too.

thanks,

Takashi

author maintainer
#2 lore raw
Quoted 9 lines · Takashi Iwai
Quoted 4 lines · Jaroslav Kysela

Make code more readable with azx_stream() helper. No functional change.

I have no much preference, but using the macro doesn't look like a significant improvement to me, honestly speaking...

If you look to some functions, there's a mixture of azx_stream() and ->core. access to the same structure members. I found that it's an extra step for the reader to identify that both are same source. I don't mind to remove azx_stream macro or use it everywhere as I proposed, too.

I just dig to the sources wondering if 192k analog support is possible and this was visible mismatch.

More patches will probably follow.

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.