Commit 21229613eff5b6241d27e2588d10588d5656d500
1 parent
1dc669fed6
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
ALSA: hda - Introduce get_delay codec PCM ops
Add a new codec PCM ops, get_delay(), to obtain the codec/stream- specific PCM delay count. When it's NULL, nothing changes. This new feature was requested for CA0132, which has significant delays in the path depending on the running DSP code. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Showing 2 changed files with 17 additions and 4 deletions Side-by-side Diff
sound/pci/hda/hda_codec.h
... | ... | @@ -757,6 +757,9 @@ |
757 | 757 | struct snd_pcm_substream *substream); |
758 | 758 | int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec, |
759 | 759 | struct snd_pcm_substream *substream); |
760 | + unsigned int (*get_delay)(struct hda_pcm_stream *info, | |
761 | + struct hda_codec *codec, | |
762 | + struct snd_pcm_substream *substream); | |
760 | 763 | }; |
761 | 764 | |
762 | 765 | /* PCM information for each substream */ |
sound/pci/hda/hda_intel.c
... | ... | @@ -2349,8 +2349,11 @@ |
2349 | 2349 | struct azx_dev *azx_dev, |
2350 | 2350 | bool with_check) |
2351 | 2351 | { |
2352 | + struct snd_pcm_substream *substream = azx_dev->substream; | |
2353 | + struct azx_pcm *apcm = snd_pcm_substream_chip(substream); | |
2352 | 2354 | unsigned int pos; |
2353 | - int stream = azx_dev->substream->stream; | |
2355 | + int stream = substream->stream; | |
2356 | + struct hda_pcm_stream *hinfo = apcm->hinfo[stream]; | |
2354 | 2357 | int delay = 0; |
2355 | 2358 | |
2356 | 2359 | switch (chip->position_fix[stream]) { |
... | ... | @@ -2381,7 +2384,7 @@ |
2381 | 2384 | pos = 0; |
2382 | 2385 | |
2383 | 2386 | /* calculate runtime delay from LPIB */ |
2384 | - if (azx_dev->substream->runtime && | |
2387 | + if (substream->runtime && | |
2385 | 2388 | chip->position_fix[stream] == POS_FIX_POSBUF && |
2386 | 2389 | (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { |
2387 | 2390 | unsigned int lpib_pos = azx_sd_readl(azx_dev, SD_LPIB); |
2388 | 2391 | |
... | ... | @@ -2399,9 +2402,16 @@ |
2399 | 2402 | delay = 0; |
2400 | 2403 | chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; |
2401 | 2404 | } |
2402 | - azx_dev->substream->runtime->delay = | |
2403 | - bytes_to_frames(azx_dev->substream->runtime, delay); | |
2405 | + delay = bytes_to_frames(substream->runtime, delay); | |
2404 | 2406 | } |
2407 | + | |
2408 | + if (substream->runtime) { | |
2409 | + if (hinfo->ops.get_delay) | |
2410 | + delay += hinfo->ops.get_delay(hinfo, apcm->codec, | |
2411 | + substream); | |
2412 | + substream->runtime->delay = delay; | |
2413 | + } | |
2414 | + | |
2405 | 2415 | trace_azx_get_position(chip, azx_dev, pos, delay); |
2406 | 2416 | return pos; |
2407 | 2417 | } |