2019-05-27 06:55:06 +00:00
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-02-28 23:41:22 +00:00
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* Implementation of primary alsa driver code base for Intel HD Audio.
|
|
|
|
|
*
|
|
|
|
|
* Copyright(c) 2004 Intel Corporation. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
|
|
|
|
|
* PeiSen Hou <pshou@realtek.com.tw>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <linux/clocksource.h>
|
|
|
|
|
#include <linux/delay.h>
|
2014-02-28 23:41:29 +00:00
|
|
|
|
#include <linux/interrupt.h>
|
2014-02-28 23:41:22 +00:00
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
#include <linux/module.h>
|
2014-02-28 23:41:30 +00:00
|
|
|
|
#include <linux/pm_runtime.h>
|
2014-02-28 23:41:22 +00:00
|
|
|
|
#include <linux/slab.h>
|
2016-08-04 10:16:04 +00:00
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86
|
|
|
|
|
/* for art-tsc conversion */
|
|
|
|
|
#include <asm/tsc.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-02-28 23:41:22 +00:00
|
|
|
|
#include <sound/core.h>
|
|
|
|
|
#include <sound/initval.h>
|
|
|
|
|
#include "hda_controller.h"
|
|
|
|
|
|
2015-04-16 09:44:58 +00:00
|
|
|
|
#define CREATE_TRACE_POINTS
|
2015-05-12 01:43:21 +00:00
|
|
|
|
#include "hda_controller_trace.h"
|
2015-04-16 09:44:58 +00:00
|
|
|
|
|
2014-02-28 23:41:24 +00:00
|
|
|
|
/* DSP lock helpers */
|
2015-04-14 16:13:13 +00:00
|
|
|
|
#define dsp_lock(dev) snd_hdac_dsp_lock(azx_stream(dev))
|
|
|
|
|
#define dsp_unlock(dev) snd_hdac_dsp_unlock(azx_stream(dev))
|
|
|
|
|
#define dsp_is_locked(dev) snd_hdac_stream_is_locked(azx_stream(dev))
|
2014-02-28 23:41:24 +00:00
|
|
|
|
|
2014-02-28 23:41:22 +00:00
|
|
|
|
/* assign a stream for the PCM */
|
|
|
|
|
static inline struct azx_dev *
|
|
|
|
|
azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
|
|
|
|
|
{
|
2015-04-14 16:13:13 +00:00
|
|
|
|
struct hdac_stream *s;
|
|
|
|
|
|
|
|
|
|
s = snd_hdac_stream_assign(azx_bus(chip), substream);
|
|
|
|
|
if (!s)
|
|
|
|
|
return NULL;
|
|
|
|
|
return stream_to_azx_dev(s);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* release the assigned stream */
|
|
|
|
|
static inline void azx_release_device(struct azx_dev *azx_dev)
|
|
|
|
|
{
|
2015-04-14 16:13:13 +00:00
|
|
|
|
snd_hdac_stream_release(azx_stream(azx_dev));
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 11:50:46 +00:00
|
|
|
|
static inline struct hda_pcm_stream *
|
|
|
|
|
to_hda_pcm_stream(struct snd_pcm_substream *substream)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
|
|
|
|
return &apcm->info->stream[substream->stream];
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-28 23:41:22 +00:00
|
|
|
|
static u64 azx_adjust_codec_delay(struct snd_pcm_substream *substream,
|
|
|
|
|
u64 nsec)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
2015-02-20 11:50:46 +00:00
|
|
|
|
struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
u64 codec_frames, codec_nsecs;
|
|
|
|
|
|
|
|
|
|
if (!hinfo->ops.get_delay)
|
|
|
|
|
return nsec;
|
|
|
|
|
|
|
|
|
|
codec_frames = hinfo->ops.get_delay(hinfo, apcm->codec, substream);
|
|
|
|
|
codec_nsecs = div_u64(codec_frames * 1000000000LL,
|
|
|
|
|
substream->runtime->rate);
|
|
|
|
|
|
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
|
|
|
|
|
return nsec + codec_nsecs;
|
|
|
|
|
|
|
|
|
|
return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* PCM ops
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int azx_pcm_close(struct snd_pcm_substream *substream)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
2015-02-20 11:50:46 +00:00
|
|
|
|
struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
struct azx *chip = apcm->chip;
|
|
|
|
|
struct azx_dev *azx_dev = get_azx_dev(substream);
|
|
|
|
|
|
2015-05-12 01:43:21 +00:00
|
|
|
|
trace_azx_pcm_close(chip, azx_dev);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
mutex_lock(&chip->open_mutex);
|
|
|
|
|
azx_release_device(azx_dev);
|
2015-02-27 16:57:55 +00:00
|
|
|
|
if (hinfo->ops.close)
|
|
|
|
|
hinfo->ops.close(hinfo, apcm->codec, substream);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
snd_hda_power_down(apcm->codec);
|
|
|
|
|
mutex_unlock(&chip->open_mutex);
|
2015-02-27 17:17:28 +00:00
|
|
|
|
snd_hda_codec_pcm_put(apcm->info);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
|
struct snd_pcm_hw_params *hw_params)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
|
|
|
|
struct azx *chip = apcm->chip;
|
2015-04-16 05:53:08 +00:00
|
|
|
|
struct azx_dev *azx_dev = get_azx_dev(substream);
|
2019-12-09 09:49:12 +00:00
|
|
|
|
int ret = 0;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
2015-05-12 01:43:21 +00:00
|
|
|
|
trace_azx_pcm_hw_params(chip, azx_dev);
|
2015-04-16 05:53:08 +00:00
|
|
|
|
dsp_lock(azx_dev);
|
|
|
|
|
if (dsp_is_locked(azx_dev)) {
|
2014-02-28 23:41:22 +00:00
|
|
|
|
ret = -EBUSY;
|
|
|
|
|
goto unlock;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-16 05:53:08 +00:00
|
|
|
|
azx_dev->core.bufsize = 0;
|
|
|
|
|
azx_dev->core.period_bytes = 0;
|
|
|
|
|
azx_dev->core.format_val = 0;
|
2018-08-08 15:12:58 +00:00
|
|
|
|
|
2014-02-28 23:41:22 +00:00
|
|
|
|
unlock:
|
2015-04-16 05:53:08 +00:00
|
|
|
|
dsp_unlock(azx_dev);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
|
|
|
|
struct azx_dev *azx_dev = get_azx_dev(substream);
|
2015-02-20 11:50:46 +00:00
|
|
|
|
struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
/* reset BDL address */
|
|
|
|
|
dsp_lock(azx_dev);
|
2015-04-14 20:06:53 +00:00
|
|
|
|
if (!dsp_is_locked(azx_dev))
|
|
|
|
|
snd_hdac_stream_cleanup(azx_stream(azx_dev));
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
|
|
|
|
|
|
2015-04-17 11:34:30 +00:00
|
|
|
|
azx_stream(azx_dev)->prepared = 0;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
dsp_unlock(azx_dev);
|
2019-12-09 09:49:12 +00:00
|
|
|
|
return 0;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int azx_pcm_prepare(struct snd_pcm_substream *substream)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
|
|
|
|
struct azx *chip = apcm->chip;
|
|
|
|
|
struct azx_dev *azx_dev = get_azx_dev(substream);
|
2015-02-20 11:50:46 +00:00
|
|
|
|
struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
2015-04-18 07:59:38 +00:00
|
|
|
|
unsigned int format_val, stream_tag;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
int err;
|
|
|
|
|
struct hda_spdif_out *spdif =
|
|
|
|
|
snd_hda_spdif_out_of_nid(apcm->codec, hinfo->nid);
|
|
|
|
|
unsigned short ctls = spdif ? spdif->ctls : 0;
|
|
|
|
|
|
2015-05-12 01:43:21 +00:00
|
|
|
|
trace_azx_pcm_prepare(chip, azx_dev);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
dsp_lock(azx_dev);
|
|
|
|
|
if (dsp_is_locked(azx_dev)) {
|
|
|
|
|
err = -EBUSY;
|
|
|
|
|
goto unlock;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-14 16:13:13 +00:00
|
|
|
|
snd_hdac_stream_reset(azx_stream(azx_dev));
|
2015-04-16 06:19:06 +00:00
|
|
|
|
format_val = snd_hdac_calc_stream_format(runtime->rate,
|
2014-02-28 23:41:22 +00:00
|
|
|
|
runtime->channels,
|
|
|
|
|
runtime->format,
|
|
|
|
|
hinfo->maxbps,
|
|
|
|
|
ctls);
|
|
|
|
|
if (!format_val) {
|
|
|
|
|
dev_err(chip->card->dev,
|
|
|
|
|
"invalid format_val, rate=%d, ch=%d, format=%d\n",
|
|
|
|
|
runtime->rate, runtime->channels, runtime->format);
|
|
|
|
|
err = -EINVAL;
|
|
|
|
|
goto unlock;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-18 07:59:38 +00:00
|
|
|
|
err = snd_hdac_stream_set_params(azx_stream(azx_dev), format_val);
|
|
|
|
|
if (err < 0)
|
|
|
|
|
goto unlock;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
2015-04-14 20:06:53 +00:00
|
|
|
|
snd_hdac_stream_setup(azx_stream(azx_dev));
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
2015-04-14 16:13:13 +00:00
|
|
|
|
stream_tag = azx_dev->core.stream_tag;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
/* 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,
|
2015-04-14 16:13:13 +00:00
|
|
|
|
azx_dev->core.format_val, substream);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
unlock:
|
|
|
|
|
if (!err)
|
2015-04-17 11:34:30 +00:00
|
|
|
|
azx_stream(azx_dev)->prepared = 1;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
dsp_unlock(azx_dev);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
|
|
|
|
struct azx *chip = apcm->chip;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct hdac_bus *bus = azx_bus(chip);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
struct azx_dev *azx_dev;
|
|
|
|
|
struct snd_pcm_substream *s;
|
2015-04-14 20:06:53 +00:00
|
|
|
|
struct hdac_stream *hstr;
|
|
|
|
|
bool start;
|
|
|
|
|
int sbits = 0;
|
|
|
|
|
int sync_reg;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
azx_dev = get_azx_dev(substream);
|
2015-04-16 09:44:58 +00:00
|
|
|
|
trace_azx_pcm_trigger(chip, azx_dev, cmd);
|
|
|
|
|
|
2015-04-14 20:06:53 +00:00
|
|
|
|
hstr = azx_stream(azx_dev);
|
|
|
|
|
if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
|
|
|
|
|
sync_reg = AZX_REG_OLD_SSYNC;
|
|
|
|
|
else
|
|
|
|
|
sync_reg = AZX_REG_SSYNC;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
2015-04-17 11:34:30 +00:00
|
|
|
|
if (dsp_is_locked(azx_dev) || !hstr->prepared)
|
2014-02-28 23:41:22 +00:00
|
|
|
|
return -EPIPE;
|
|
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
case SNDRV_PCM_TRIGGER_START:
|
|
|
|
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
|
|
|
|
case SNDRV_PCM_TRIGGER_RESUME:
|
2015-04-14 20:06:53 +00:00
|
|
|
|
start = true;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
break;
|
|
|
|
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
|
|
|
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
|
|
|
|
case SNDRV_PCM_TRIGGER_STOP:
|
2015-04-14 20:06:53 +00:00
|
|
|
|
start = false;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snd_pcm_group_for_each_entry(s, substream) {
|
|
|
|
|
if (s->pcm->card != substream->pcm->card)
|
|
|
|
|
continue;
|
|
|
|
|
azx_dev = get_azx_dev(s);
|
2015-04-14 16:13:13 +00:00
|
|
|
|
sbits |= 1 << azx_dev->core.index;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
snd_pcm_trigger_done(s, substream);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_lock(&bus->reg_lock);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
/* first, set SYNC bits of corresponding streams */
|
2015-04-14 20:06:53 +00:00
|
|
|
|
snd_hdac_stream_sync_trigger(hstr, true, sbits, sync_reg);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
snd_pcm_group_for_each_entry(s, substream) {
|
|
|
|
|
if (s->pcm->card != substream->pcm->card)
|
|
|
|
|
continue;
|
|
|
|
|
azx_dev = get_azx_dev(s);
|
|
|
|
|
if (start) {
|
2015-04-14 16:13:13 +00:00
|
|
|
|
azx_dev->insufficient = 1;
|
|
|
|
|
snd_hdac_stream_start(azx_stream(azx_dev), true);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
} else {
|
2015-04-14 16:13:13 +00:00
|
|
|
|
snd_hdac_stream_stop(azx_stream(azx_dev));
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_unlock(&bus->reg_lock);
|
2015-04-14 20:06:53 +00:00
|
|
|
|
|
|
|
|
|
snd_hdac_stream_sync(hstr, start, sbits);
|
|
|
|
|
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_lock(&bus->reg_lock);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
/* reset SYNC bits */
|
2015-04-14 20:06:53 +00:00
|
|
|
|
snd_hdac_stream_sync_trigger(hstr, false, sbits, sync_reg);
|
|
|
|
|
if (start)
|
|
|
|
|
snd_hdac_stream_timecounter_init(hstr, sbits);
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_unlock(&bus->reg_lock);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-26 14:50:16 +00:00
|
|
|
|
unsigned int azx_get_pos_lpib(struct azx *chip, struct azx_dev *azx_dev)
|
2014-02-28 23:41:22 +00:00
|
|
|
|
{
|
2015-04-14 16:13:13 +00:00
|
|
|
|
return snd_hdac_stream_get_pos_lpib(azx_stream(azx_dev));
|
2014-06-26 14:50:16 +00:00
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL_GPL(azx_get_pos_lpib);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
2014-06-26 14:50:16 +00:00
|
|
|
|
unsigned int azx_get_pos_posbuf(struct azx *chip, struct azx_dev *azx_dev)
|
|
|
|
|
{
|
2015-04-14 16:13:13 +00:00
|
|
|
|
return snd_hdac_stream_get_pos_posbuf(azx_stream(azx_dev));
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
2014-06-26 14:50:16 +00:00
|
|
|
|
EXPORT_SYMBOL_GPL(azx_get_pos_posbuf);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
unsigned int azx_get_position(struct azx *chip,
|
2014-06-26 14:50:16 +00:00
|
|
|
|
struct azx_dev *azx_dev)
|
2014-02-28 23:41:22 +00:00
|
|
|
|
{
|
2015-04-14 16:13:13 +00:00
|
|
|
|
struct snd_pcm_substream *substream = azx_dev->core.substream;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
unsigned int pos;
|
|
|
|
|
int stream = substream->stream;
|
|
|
|
|
int delay = 0;
|
|
|
|
|
|
2014-06-26 14:50:16 +00:00
|
|
|
|
if (chip->get_position[stream])
|
|
|
|
|
pos = chip->get_position[stream](chip, azx_dev);
|
|
|
|
|
else /* use the position buffer as default */
|
|
|
|
|
pos = azx_get_pos_posbuf(chip, azx_dev);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
2015-04-14 16:13:13 +00:00
|
|
|
|
if (pos >= azx_dev->core.bufsize)
|
2014-02-28 23:41:22 +00:00
|
|
|
|
pos = 0;
|
|
|
|
|
|
|
|
|
|
if (substream->runtime) {
|
2014-06-26 14:50:16 +00:00
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
2015-02-20 11:50:46 +00:00
|
|
|
|
struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream);
|
2014-06-26 14:50:16 +00:00
|
|
|
|
|
|
|
|
|
if (chip->get_delay[stream])
|
|
|
|
|
delay += chip->get_delay[stream](chip, azx_dev, pos);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
if (hinfo->ops.get_delay)
|
|
|
|
|
delay += hinfo->ops.get_delay(hinfo, apcm->codec,
|
|
|
|
|
substream);
|
|
|
|
|
substream->runtime->delay = delay;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-16 09:44:58 +00:00
|
|
|
|
trace_azx_get_position(chip, azx_dev, pos, delay);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
return pos;
|
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL_GPL(azx_get_position);
|
|
|
|
|
|
|
|
|
|
static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
|
|
|
|
struct azx *chip = apcm->chip;
|
|
|
|
|
struct azx_dev *azx_dev = get_azx_dev(substream);
|
|
|
|
|
return bytes_to_frames(substream->runtime,
|
2014-06-26 14:50:16 +00:00
|
|
|
|
azx_get_position(chip, azx_dev));
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-04 10:16:04 +00:00
|
|
|
|
/*
|
|
|
|
|
* azx_scale64: Scale base by mult/div while not overflowing sanely
|
|
|
|
|
*
|
|
|
|
|
* Derived from scale64_check_overflow in kernel/time/timekeeping.c
|
|
|
|
|
*
|
|
|
|
|
* The tmestamps for a 48Khz stream can overflow after (2^64/10^9)/48K which
|
|
|
|
|
* is about 384307 ie ~4.5 days.
|
|
|
|
|
*
|
|
|
|
|
* This scales the calculation so that overflow will happen but after 2^64 /
|
|
|
|
|
* 48000 secs, which is pretty large!
|
|
|
|
|
*
|
|
|
|
|
* In caln below:
|
|
|
|
|
* base may overflow, but since there isn’t any additional division
|
|
|
|
|
* performed on base it’s OK
|
|
|
|
|
* rem can’t overflow because both are 32-bit values
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86
|
|
|
|
|
static u64 azx_scale64(u64 base, u32 num, u32 den)
|
|
|
|
|
{
|
|
|
|
|
u64 rem;
|
|
|
|
|
|
|
|
|
|
rem = do_div(base, den);
|
|
|
|
|
|
|
|
|
|
base *= num;
|
|
|
|
|
rem *= num;
|
|
|
|
|
|
|
|
|
|
do_div(rem, den);
|
|
|
|
|
|
|
|
|
|
return base + rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int azx_get_sync_time(ktime_t *device,
|
|
|
|
|
struct system_counterval_t *system, void *ctx)
|
|
|
|
|
{
|
|
|
|
|
struct snd_pcm_substream *substream = ctx;
|
|
|
|
|
struct azx_dev *azx_dev = get_azx_dev(substream);
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
|
|
|
|
struct azx *chip = apcm->chip;
|
|
|
|
|
struct snd_pcm_runtime *runtime;
|
|
|
|
|
u64 ll_counter, ll_counter_l, ll_counter_h;
|
|
|
|
|
u64 tsc_counter, tsc_counter_l, tsc_counter_h;
|
|
|
|
|
u32 wallclk_ctr, wallclk_cycles;
|
|
|
|
|
bool direction;
|
|
|
|
|
u32 dma_select;
|
2020-02-08 22:27:56 +00:00
|
|
|
|
u32 timeout;
|
2016-08-04 10:16:04 +00:00
|
|
|
|
u32 retry_count = 0;
|
|
|
|
|
|
|
|
|
|
runtime = substream->runtime;
|
|
|
|
|
|
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
|
|
|
|
direction = 1;
|
|
|
|
|
else
|
|
|
|
|
direction = 0;
|
|
|
|
|
|
|
|
|
|
/* 0th stream tag is not used, so DMA ch 0 is for 1st stream tag */
|
|
|
|
|
do {
|
|
|
|
|
timeout = 100;
|
|
|
|
|
dma_select = (direction << GTSCC_CDMAS_DMA_DIR_SHIFT) |
|
|
|
|
|
(azx_dev->core.stream_tag - 1);
|
|
|
|
|
snd_hdac_chip_writel(azx_bus(chip), GTSCC, dma_select);
|
|
|
|
|
|
|
|
|
|
/* Enable the capture */
|
|
|
|
|
snd_hdac_chip_updatel(azx_bus(chip), GTSCC, 0, GTSCC_TSCCI_MASK);
|
|
|
|
|
|
|
|
|
|
while (timeout) {
|
|
|
|
|
if (snd_hdac_chip_readl(azx_bus(chip), GTSCC) &
|
|
|
|
|
GTSCC_TSCCD_MASK)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
timeout--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!timeout) {
|
|
|
|
|
dev_err(chip->card->dev, "GTSCC capture Timedout!\n");
|
|
|
|
|
return -EIO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read wall clock counter */
|
|
|
|
|
wallclk_ctr = snd_hdac_chip_readl(azx_bus(chip), WALFCC);
|
|
|
|
|
|
|
|
|
|
/* Read TSC counter */
|
|
|
|
|
tsc_counter_l = snd_hdac_chip_readl(azx_bus(chip), TSCCL);
|
|
|
|
|
tsc_counter_h = snd_hdac_chip_readl(azx_bus(chip), TSCCU);
|
|
|
|
|
|
|
|
|
|
/* Read Link counter */
|
|
|
|
|
ll_counter_l = snd_hdac_chip_readl(azx_bus(chip), LLPCL);
|
|
|
|
|
ll_counter_h = snd_hdac_chip_readl(azx_bus(chip), LLPCU);
|
|
|
|
|
|
|
|
|
|
/* Ack: registers read done */
|
|
|
|
|
snd_hdac_chip_writel(azx_bus(chip), GTSCC, GTSCC_TSCCD_SHIFT);
|
|
|
|
|
|
|
|
|
|
tsc_counter = (tsc_counter_h << TSCCU_CCU_SHIFT) |
|
|
|
|
|
tsc_counter_l;
|
|
|
|
|
|
|
|
|
|
ll_counter = (ll_counter_h << LLPC_CCU_SHIFT) | ll_counter_l;
|
|
|
|
|
wallclk_cycles = wallclk_ctr & WALFCC_CIF_MASK;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* An error occurs near frame "rollover". The clocks in
|
|
|
|
|
* frame value indicates whether this error may have
|
|
|
|
|
* occurred. Here we use the value of 10 i.e.,
|
|
|
|
|
* HDA_MAX_CYCLE_OFFSET
|
|
|
|
|
*/
|
|
|
|
|
if (wallclk_cycles < HDA_MAX_CYCLE_VALUE - HDA_MAX_CYCLE_OFFSET
|
|
|
|
|
&& wallclk_cycles > HDA_MAX_CYCLE_OFFSET)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Sleep before we read again, else we may again get
|
|
|
|
|
* value near to MAX_CYCLE. Try to sleep for different
|
|
|
|
|
* amount of time so we dont hit the same number again
|
|
|
|
|
*/
|
|
|
|
|
udelay(retry_count++);
|
|
|
|
|
|
|
|
|
|
} while (retry_count != HDA_MAX_CYCLE_READ_RETRY);
|
|
|
|
|
|
|
|
|
|
if (retry_count == HDA_MAX_CYCLE_READ_RETRY) {
|
|
|
|
|
dev_err_ratelimited(chip->card->dev,
|
|
|
|
|
"Error in WALFCC cycle count\n");
|
|
|
|
|
return -EIO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*device = ns_to_ktime(azx_scale64(ll_counter,
|
|
|
|
|
NSEC_PER_SEC, runtime->rate));
|
|
|
|
|
*device = ktime_add_ns(*device, (wallclk_cycles * NSEC_PER_SEC) /
|
|
|
|
|
((HDA_MAX_CYCLE_VALUE + 1) * runtime->rate));
|
|
|
|
|
|
|
|
|
|
*system = convert_art_to_tsc(tsc_counter);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
static int azx_get_sync_time(ktime_t *device,
|
|
|
|
|
struct system_counterval_t *system, void *ctx)
|
|
|
|
|
{
|
|
|
|
|
return -ENXIO;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static int azx_get_crosststamp(struct snd_pcm_substream *substream,
|
|
|
|
|
struct system_device_crosststamp *xtstamp)
|
|
|
|
|
{
|
|
|
|
|
return get_device_system_crosststamp(azx_get_sync_time,
|
|
|
|
|
substream, NULL, xtstamp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline bool is_link_time_supported(struct snd_pcm_runtime *runtime,
|
|
|
|
|
struct snd_pcm_audio_tstamp_config *ts)
|
|
|
|
|
{
|
|
|
|
|
if (runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME)
|
|
|
|
|
if (ts->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-13 21:14:07 +00:00
|
|
|
|
static int azx_get_time_info(struct snd_pcm_substream *substream,
|
2018-04-24 12:06:08 +00:00
|
|
|
|
struct timespec64 *system_ts, struct timespec64 *audio_ts,
|
2015-02-13 21:14:07 +00:00
|
|
|
|
struct snd_pcm_audio_tstamp_config *audio_tstamp_config,
|
|
|
|
|
struct snd_pcm_audio_tstamp_report *audio_tstamp_report)
|
2014-02-28 23:41:22 +00:00
|
|
|
|
{
|
|
|
|
|
struct azx_dev *azx_dev = get_azx_dev(substream);
|
2016-08-04 10:16:04 +00:00
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
|
|
|
struct system_device_crosststamp xtstamp;
|
|
|
|
|
int ret;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
u64 nsec;
|
|
|
|
|
|
2015-02-13 21:14:07 +00:00
|
|
|
|
if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
|
|
|
|
|
(audio_tstamp_config->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK)) {
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
2015-02-13 21:14:07 +00:00
|
|
|
|
snd_pcm_gettime(substream->runtime, system_ts);
|
|
|
|
|
|
2015-04-14 16:13:13 +00:00
|
|
|
|
nsec = timecounter_read(&azx_dev->core.tc);
|
2015-02-13 21:14:07 +00:00
|
|
|
|
nsec = div_u64(nsec, 3); /* can be optimized */
|
|
|
|
|
if (audio_tstamp_config->report_delay)
|
|
|
|
|
nsec = azx_adjust_codec_delay(substream, nsec);
|
|
|
|
|
|
2018-04-24 12:06:08 +00:00
|
|
|
|
*audio_ts = ns_to_timespec64(nsec);
|
2015-02-13 21:14:07 +00:00
|
|
|
|
|
|
|
|
|
audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
|
|
|
|
|
audio_tstamp_report->accuracy_report = 1; /* rest of structure is valid */
|
|
|
|
|
audio_tstamp_report->accuracy = 42; /* 24 MHz WallClock == 42ns resolution */
|
|
|
|
|
|
2016-08-04 10:16:04 +00:00
|
|
|
|
} else if (is_link_time_supported(runtime, audio_tstamp_config)) {
|
|
|
|
|
|
|
|
|
|
ret = azx_get_crosststamp(substream, &xtstamp);
|
|
|
|
|
if (ret)
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
switch (runtime->tstamp_type) {
|
|
|
|
|
case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC:
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW:
|
2018-04-24 12:06:08 +00:00
|
|
|
|
*system_ts = ktime_to_timespec64(xtstamp.sys_monoraw);
|
2016-08-04 10:16:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2018-04-24 12:06:08 +00:00
|
|
|
|
*system_ts = ktime_to_timespec64(xtstamp.sys_realtime);
|
2016-08-04 10:16:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-24 12:06:08 +00:00
|
|
|
|
*audio_ts = ktime_to_timespec64(xtstamp.device);
|
2016-08-04 10:16:04 +00:00
|
|
|
|
|
|
|
|
|
audio_tstamp_report->actual_type =
|
|
|
|
|
SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED;
|
|
|
|
|
audio_tstamp_report->accuracy_report = 1;
|
|
|
|
|
/* 24 MHz WallClock == 42ns resolution */
|
|
|
|
|
audio_tstamp_report->accuracy = 42;
|
|
|
|
|
|
|
|
|
|
} else {
|
2015-02-13 21:14:07 +00:00
|
|
|
|
audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
|
2016-08-04 10:16:04 +00:00
|
|
|
|
}
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-01 07:43:20 +00:00
|
|
|
|
static const struct snd_pcm_hardware azx_pcm_hw = {
|
2014-02-28 23:41:22 +00:00
|
|
|
|
.info = (SNDRV_PCM_INFO_MMAP |
|
|
|
|
|
SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER |
|
|
|
|
|
SNDRV_PCM_INFO_MMAP_VALID |
|
|
|
|
|
/* No full-resume yet implemented */
|
|
|
|
|
/* SNDRV_PCM_INFO_RESUME |*/
|
|
|
|
|
SNDRV_PCM_INFO_PAUSE |
|
|
|
|
|
SNDRV_PCM_INFO_SYNC_START |
|
2015-02-13 21:14:07 +00:00
|
|
|
|
SNDRV_PCM_INFO_HAS_WALL_CLOCK | /* legacy */
|
|
|
|
|
SNDRV_PCM_INFO_HAS_LINK_ATIME |
|
2014-02-28 23:41:22 +00:00
|
|
|
|
SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
|
|
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
|
|
|
|
.rates = SNDRV_PCM_RATE_48000,
|
|
|
|
|
.rate_min = 48000,
|
|
|
|
|
.rate_max = 48000,
|
|
|
|
|
.channels_min = 2,
|
|
|
|
|
.channels_max = 2,
|
|
|
|
|
.buffer_bytes_max = AZX_MAX_BUF_SIZE,
|
|
|
|
|
.period_bytes_min = 128,
|
|
|
|
|
.period_bytes_max = AZX_MAX_BUF_SIZE / 2,
|
|
|
|
|
.periods_min = 2,
|
|
|
|
|
.periods_max = AZX_MAX_FRAG,
|
|
|
|
|
.fifo_size = 0,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int azx_pcm_open(struct snd_pcm_substream *substream)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
2015-02-20 11:50:46 +00:00
|
|
|
|
struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
struct azx *chip = apcm->chip;
|
|
|
|
|
struct azx_dev *azx_dev;
|
|
|
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
|
|
|
int err;
|
|
|
|
|
int buff_step;
|
|
|
|
|
|
2015-02-27 17:17:28 +00:00
|
|
|
|
snd_hda_codec_pcm_get(apcm->info);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
mutex_lock(&chip->open_mutex);
|
|
|
|
|
azx_dev = azx_assign_device(chip, substream);
|
2015-05-12 01:43:21 +00:00
|
|
|
|
trace_azx_pcm_open(chip, azx_dev);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
if (azx_dev == NULL) {
|
2015-02-27 16:57:55 +00:00
|
|
|
|
err = -EBUSY;
|
|
|
|
|
goto unlock;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
2015-04-14 20:06:53 +00:00
|
|
|
|
runtime->private_data = azx_dev;
|
2016-08-04 10:16:03 +00:00
|
|
|
|
|
2014-02-28 23:41:22 +00:00
|
|
|
|
runtime->hw = azx_pcm_hw;
|
2019-08-06 12:03:56 +00:00
|
|
|
|
if (chip->gts_present)
|
|
|
|
|
runtime->hw.info |= SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
runtime->hw.channels_min = hinfo->channels_min;
|
|
|
|
|
runtime->hw.channels_max = hinfo->channels_max;
|
|
|
|
|
runtime->hw.formats = hinfo->formats;
|
|
|
|
|
runtime->hw.rates = hinfo->rates;
|
|
|
|
|
snd_pcm_limit_hw_rates(runtime);
|
|
|
|
|
snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
|
|
|
|
|
|
|
|
|
|
/* avoid wrap-around with wall-clock */
|
|
|
|
|
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
|
|
|
|
|
20,
|
|
|
|
|
178000000);
|
|
|
|
|
|
ALSA: hda - Workaround for crackled sound on AMD controller (1022:1457)
A long-time problem on the recent AMD chip (X370, X470, B450, etc with
PCI ID 1022:1457) with Realtek codecs is the crackled or distorted
sound for capture streams, as well as occasional playback hiccups.
After lengthy debugging sessions, the workarounds we've found are like
the following:
- Set up the proper driver caps for this controller, similar as the
other AMD controller.
- Correct the DMA position reporting with the fixed FIFO size, which
is similar like as workaround used for VIA chip set.
- Even after the position correction, PulseAudio still shows
mysterious stalls of playback streams when a capture is triggered in
timer-scheduled mode. Since we have no clear way to eliminate the
stall, pass the BATCH PCM flag for PA to suppress the tsched mode as
a temporary workaround.
This patch implements the workarounds. For the driver caps, it
defines a new preset, AXZ_DCAPS_PRESET_AMD_SB. It enables the FIFO-
corrected position reporting (corresponding to the new position_fix=6)
and enforces the SNDRV_PCM_INFO_BATCH flag.
Note that the current implementation is merely a workaround.
Hopefully we'll find a better alternative in future, especially about
removing the BATCH flag hack again.
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=195303
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-08-06 15:31:48 +00:00
|
|
|
|
/* by some reason, the playback stream stalls on PulseAudio with
|
|
|
|
|
* tsched=1 when a capture stream triggers. Until we figure out the
|
|
|
|
|
* real cause, disable tsched mode by telling the PCM info flag.
|
|
|
|
|
*/
|
|
|
|
|
if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND)
|
|
|
|
|
runtime->hw.info |= SNDRV_PCM_INFO_BATCH;
|
|
|
|
|
|
2014-02-28 23:41:22 +00:00
|
|
|
|
if (chip->align_buffer_size)
|
|
|
|
|
/* constrain buffer sizes to be multiple of 128
|
|
|
|
|
bytes. This is more efficient in terms of memory
|
|
|
|
|
access but isn't required by the HDA spec and
|
|
|
|
|
prevents users from specifying exact period/buffer
|
|
|
|
|
sizes. For example for 44.1kHz, a period size set
|
|
|
|
|
to 20ms will be rounded to 19.59ms. */
|
|
|
|
|
buff_step = 128;
|
|
|
|
|
else
|
|
|
|
|
/* Don't enforce steps on buffer sizes, still need to
|
|
|
|
|
be multiple of 4 bytes (HDA spec). Tested on Intel
|
|
|
|
|
HDA controllers, may not work on all devices where
|
|
|
|
|
option needs to be disabled */
|
|
|
|
|
buff_step = 4;
|
|
|
|
|
|
|
|
|
|
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
|
|
|
|
|
buff_step);
|
|
|
|
|
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
|
|
|
|
|
buff_step);
|
2015-02-19 15:00:22 +00:00
|
|
|
|
snd_hda_power_up(apcm->codec);
|
2015-02-27 16:57:55 +00:00
|
|
|
|
if (hinfo->ops.open)
|
|
|
|
|
err = hinfo->ops.open(hinfo, apcm->codec, substream);
|
|
|
|
|
else
|
|
|
|
|
err = -ENODEV;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
if (err < 0) {
|
|
|
|
|
azx_release_device(azx_dev);
|
2015-02-27 16:57:55 +00:00
|
|
|
|
goto powerdown;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
snd_pcm_limit_hw_rates(runtime);
|
|
|
|
|
/* sanity check */
|
|
|
|
|
if (snd_BUG_ON(!runtime->hw.channels_min) ||
|
|
|
|
|
snd_BUG_ON(!runtime->hw.channels_max) ||
|
|
|
|
|
snd_BUG_ON(!runtime->hw.formats) ||
|
|
|
|
|
snd_BUG_ON(!runtime->hw.rates)) {
|
|
|
|
|
azx_release_device(azx_dev);
|
2015-02-27 16:57:55 +00:00
|
|
|
|
if (hinfo->ops.close)
|
|
|
|
|
hinfo->ops.close(hinfo, apcm->codec, substream);
|
|
|
|
|
err = -EINVAL;
|
|
|
|
|
goto powerdown;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-13 21:14:07 +00:00
|
|
|
|
/* disable LINK_ATIME timestamps for capture streams
|
2014-02-28 23:41:22 +00:00
|
|
|
|
until we figure out how to handle digital inputs */
|
2015-02-13 21:14:07 +00:00
|
|
|
|
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
|
|
|
|
|
runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK; /* legacy */
|
|
|
|
|
runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_LINK_ATIME;
|
|
|
|
|
}
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
snd_pcm_set_sync(substream);
|
|
|
|
|
mutex_unlock(&chip->open_mutex);
|
|
|
|
|
return 0;
|
2015-02-27 16:57:55 +00:00
|
|
|
|
|
|
|
|
|
powerdown:
|
|
|
|
|
snd_hda_power_down(apcm->codec);
|
|
|
|
|
unlock:
|
|
|
|
|
mutex_unlock(&chip->open_mutex);
|
2015-02-27 17:17:28 +00:00
|
|
|
|
snd_hda_codec_pcm_put(apcm->info);
|
2015-02-27 16:57:55 +00:00
|
|
|
|
return err;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int azx_pcm_mmap(struct snd_pcm_substream *substream,
|
|
|
|
|
struct vm_area_struct *area)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
|
|
|
|
|
struct azx *chip = apcm->chip;
|
|
|
|
|
if (chip->ops->pcm_mmap_prepare)
|
|
|
|
|
chip->ops->pcm_mmap_prepare(substream, area);
|
|
|
|
|
return snd_pcm_lib_default_mmap(substream, area);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-01 22:13:10 +00:00
|
|
|
|
static const struct snd_pcm_ops azx_pcm_ops = {
|
2014-02-28 23:41:22 +00:00
|
|
|
|
.open = azx_pcm_open,
|
|
|
|
|
.close = azx_pcm_close,
|
|
|
|
|
.hw_params = azx_pcm_hw_params,
|
|
|
|
|
.hw_free = azx_pcm_hw_free,
|
|
|
|
|
.prepare = azx_pcm_prepare,
|
|
|
|
|
.trigger = azx_pcm_trigger,
|
|
|
|
|
.pointer = azx_pcm_pointer,
|
2015-02-13 21:14:07 +00:00
|
|
|
|
.get_time_info = azx_get_time_info,
|
2014-02-28 23:41:22 +00:00
|
|
|
|
.mmap = azx_pcm_mmap,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void azx_pcm_free(struct snd_pcm *pcm)
|
|
|
|
|
{
|
|
|
|
|
struct azx_pcm *apcm = pcm->private_data;
|
|
|
|
|
if (apcm) {
|
|
|
|
|
list_del(&apcm->list);
|
2015-02-20 11:50:46 +00:00
|
|
|
|
apcm->info->pcm = NULL;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
kfree(apcm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define MAX_PREALLOC_SIZE (32 * 1024 * 1024)
|
|
|
|
|
|
2015-04-16 21:25:02 +00:00
|
|
|
|
int snd_hda_attach_pcm_stream(struct hda_bus *_bus, struct hda_codec *codec,
|
|
|
|
|
struct hda_pcm *cpcm)
|
2014-02-28 23:41:22 +00:00
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct hdac_bus *bus = &_bus->core;
|
|
|
|
|
struct azx *chip = bus_to_azx(bus);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
struct snd_pcm *pcm;
|
|
|
|
|
struct azx_pcm *apcm;
|
|
|
|
|
int pcm_dev = cpcm->device;
|
|
|
|
|
unsigned int size;
|
|
|
|
|
int s, err;
|
2018-08-08 20:23:30 +00:00
|
|
|
|
int type = SNDRV_DMA_TYPE_DEV_SG;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
|
|
|
|
|
list_for_each_entry(apcm, &chip->pcm_list, list) {
|
|
|
|
|
if (apcm->pcm->device == pcm_dev) {
|
|
|
|
|
dev_err(chip->card->dev, "PCM %d already exists\n",
|
|
|
|
|
pcm_dev);
|
|
|
|
|
return -EBUSY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
|
|
|
|
|
cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams,
|
|
|
|
|
cpcm->stream[SNDRV_PCM_STREAM_CAPTURE].substreams,
|
|
|
|
|
&pcm);
|
|
|
|
|
if (err < 0)
|
|
|
|
|
return err;
|
ALSA: Convert strlcpy to strscpy when return value is unused
strlcpy is deprecated. see: Documentation/process/deprecated.rst
Change the calls that do not use the strlcpy return value to the
preferred strscpy.
Done with cocci script:
@@
expression e1, e2, e3;
@@
- strlcpy(
+ strscpy(
e1, e2, e3);
This cocci script leaves the instances where the return value is
used unchanged.
After this patch, sound/ has 3 uses of strlcpy() that need to be
manually inspected for conversion and changed one day.
$ git grep -w strlcpy sound/
sound/usb/card.c: len = strlcpy(card->longname, s, sizeof(card->longname));
sound/usb/mixer.c: return strlcpy(buf, p->name, buflen);
sound/usb/mixer.c: return strlcpy(buf, p->names[index], buflen);
Miscellenea:
o Remove trailing whitespace in conversion of sound/core/hwdep.c
Link: https://lore.kernel.org/lkml/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/22b393d1790bb268769d0bab7bacf0866dcb0c14.camel@perches.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-04 17:17:34 +00:00
|
|
|
|
strscpy(pcm->name, cpcm->name, sizeof(pcm->name));
|
2014-02-28 23:41:22 +00:00
|
|
|
|
apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
|
2018-05-31 22:35:18 +00:00
|
|
|
|
if (apcm == NULL) {
|
|
|
|
|
snd_device_free(chip->card, pcm);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
return -ENOMEM;
|
2018-05-31 22:35:18 +00:00
|
|
|
|
}
|
2014-02-28 23:41:22 +00:00
|
|
|
|
apcm->chip = chip;
|
|
|
|
|
apcm->pcm = pcm;
|
|
|
|
|
apcm->codec = codec;
|
2015-02-20 11:50:46 +00:00
|
|
|
|
apcm->info = cpcm;
|
2014-02-28 23:41:22 +00:00
|
|
|
|
pcm->private_data = apcm;
|
|
|
|
|
pcm->private_free = azx_pcm_free;
|
|
|
|
|
if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM)
|
|
|
|
|
pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
|
|
|
|
|
list_add_tail(&apcm->list, &chip->pcm_list);
|
|
|
|
|
cpcm->pcm = pcm;
|
|
|
|
|
for (s = 0; s < 2; s++) {
|
|
|
|
|
if (cpcm->stream[s].substreams)
|
|
|
|
|
snd_pcm_set_ops(pcm, s, &azx_pcm_ops);
|
|
|
|
|
}
|
|
|
|
|
/* buffer pre-allocation */
|
|
|
|
|
size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
|
|
|
|
|
if (size > MAX_PREALLOC_SIZE)
|
|
|
|
|
size = MAX_PREALLOC_SIZE;
|
2018-08-08 20:23:30 +00:00
|
|
|
|
if (chip->uc_buffer)
|
|
|
|
|
type = SNDRV_DMA_TYPE_DEV_UC_SG;
|
2019-12-09 09:49:12 +00:00
|
|
|
|
snd_pcm_set_managed_buffer_all(pcm, type, chip->card->dev,
|
|
|
|
|
size, MAX_PREALLOC_SIZE);
|
2014-02-28 23:41:22 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-28 23:41:25 +00:00
|
|
|
|
static unsigned int azx_command_addr(u32 cmd)
|
|
|
|
|
{
|
|
|
|
|
unsigned int addr = cmd >> 28;
|
|
|
|
|
|
|
|
|
|
if (addr >= AZX_MAX_CODECS) {
|
|
|
|
|
snd_BUG();
|
|
|
|
|
addr = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* receive a response */
|
2015-04-14 20:13:18 +00:00
|
|
|
|
static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr,
|
2015-03-25 16:57:00 +00:00
|
|
|
|
unsigned int *res)
|
2014-02-28 23:41:25 +00:00
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct azx *chip = bus_to_azx(bus);
|
|
|
|
|
struct hda_bus *hbus = &chip->bus;
|
2019-12-12 19:11:01 +00:00
|
|
|
|
int err;
|
2014-02-28 23:41:25 +00:00
|
|
|
|
|
|
|
|
|
again:
|
2019-12-12 19:11:01 +00:00
|
|
|
|
err = snd_hdac_bus_get_response(bus, addr, res);
|
|
|
|
|
if (!err)
|
|
|
|
|
return 0;
|
2019-12-10 14:57:27 +00:00
|
|
|
|
|
2015-04-14 20:13:18 +00:00
|
|
|
|
if (hbus->no_response_fallback)
|
2015-03-25 16:57:00 +00:00
|
|
|
|
return -EIO;
|
2014-02-28 23:41:25 +00:00
|
|
|
|
|
2019-05-26 16:58:34 +00:00
|
|
|
|
if (!bus->polling_mode) {
|
2014-02-28 23:41:25 +00:00
|
|
|
|
dev_warn(chip->card->dev,
|
|
|
|
|
"azx_get_response timeout, switching to polling mode: last cmd=0x%08x\n",
|
2015-04-14 20:13:18 +00:00
|
|
|
|
bus->last_cmd[addr]);
|
2019-05-26 16:58:34 +00:00
|
|
|
|
bus->polling_mode = 1;
|
2014-02-28 23:41:25 +00:00
|
|
|
|
goto again;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chip->msi) {
|
|
|
|
|
dev_warn(chip->card->dev,
|
|
|
|
|
"No response from codec, disabling MSI: last cmd=0x%08x\n",
|
2015-04-14 20:13:18 +00:00
|
|
|
|
bus->last_cmd[addr]);
|
|
|
|
|
if (chip->ops->disable_msi_reset_irq &&
|
2015-03-25 16:57:00 +00:00
|
|
|
|
chip->ops->disable_msi_reset_irq(chip) < 0)
|
|
|
|
|
return -EIO;
|
2014-02-28 23:41:25 +00:00
|
|
|
|
goto again;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chip->probing) {
|
|
|
|
|
/* If this critical timeout happens during the codec probing
|
|
|
|
|
* phase, this is likely an access to a non-existing codec
|
|
|
|
|
* slot. Better to return an error and reset the system.
|
|
|
|
|
*/
|
2015-03-25 16:57:00 +00:00
|
|
|
|
return -EIO;
|
2014-02-28 23:41:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-12 16:13:21 +00:00
|
|
|
|
/* no fallback mechanism? */
|
|
|
|
|
if (!chip->fallback_to_single_cmd)
|
|
|
|
|
return -EIO;
|
|
|
|
|
|
2014-02-28 23:41:25 +00:00
|
|
|
|
/* a fatal communication error; need either to reset or to fallback
|
|
|
|
|
* to the single_cmd mode
|
|
|
|
|
*/
|
2015-04-14 20:13:18 +00:00
|
|
|
|
if (hbus->allow_bus_reset && !hbus->response_reset && !hbus->in_reset) {
|
|
|
|
|
hbus->response_reset = 1;
|
2019-07-26 09:42:34 +00:00
|
|
|
|
dev_err(chip->card->dev,
|
|
|
|
|
"No response from codec, resetting bus: last cmd=0x%08x\n",
|
|
|
|
|
bus->last_cmd[addr]);
|
2015-03-25 16:57:00 +00:00
|
|
|
|
return -EAGAIN; /* give a chance to retry */
|
2014-02-28 23:41:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-16 15:12:24 +00:00
|
|
|
|
dev_err(chip->card->dev,
|
2014-02-28 23:41:25 +00:00
|
|
|
|
"azx_get_response timeout, switching to single_cmd mode: last cmd=0x%08x\n",
|
2015-04-14 20:13:18 +00:00
|
|
|
|
bus->last_cmd[addr]);
|
2014-02-28 23:41:25 +00:00
|
|
|
|
chip->single_cmd = 1;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
hbus->response_reset = 0;
|
|
|
|
|
snd_hdac_bus_stop_cmd_io(bus);
|
2015-03-25 16:57:00 +00:00
|
|
|
|
return -EIO;
|
2014-02-28 23:41:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Use the single immediate command instead of CORB/RIRB for simplicity
|
|
|
|
|
*
|
|
|
|
|
* Note: according to Intel, this is not preferred use. The command was
|
|
|
|
|
* intended for the BIOS only, and may get confused with unsolicited
|
|
|
|
|
* responses. So, we shouldn't use it for normal operation from the
|
|
|
|
|
* driver.
|
|
|
|
|
* I left the codes, however, for debugging/testing purposes.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* receive a response */
|
|
|
|
|
static int azx_single_wait_for_response(struct azx *chip, unsigned int addr)
|
|
|
|
|
{
|
|
|
|
|
int timeout = 50;
|
|
|
|
|
|
|
|
|
|
while (timeout--) {
|
|
|
|
|
/* check IRV busy bit */
|
2014-06-26 15:54:37 +00:00
|
|
|
|
if (azx_readw(chip, IRS) & AZX_IRS_VALID) {
|
2014-02-28 23:41:25 +00:00
|
|
|
|
/* reuse rirb.res as the response return value */
|
2015-04-14 20:13:18 +00:00
|
|
|
|
azx_bus(chip)->rirb.res[addr] = azx_readl(chip, IR);
|
2014-02-28 23:41:25 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
udelay(1);
|
|
|
|
|
}
|
|
|
|
|
if (printk_ratelimit())
|
|
|
|
|
dev_dbg(chip->card->dev, "get_response timeout: IRS=0x%x\n",
|
|
|
|
|
azx_readw(chip, IRS));
|
2015-04-14 20:13:18 +00:00
|
|
|
|
azx_bus(chip)->rirb.res[addr] = -1;
|
2014-02-28 23:41:25 +00:00
|
|
|
|
return -EIO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* send a command */
|
2015-04-14 20:13:18 +00:00
|
|
|
|
static int azx_single_send_cmd(struct hdac_bus *bus, u32 val)
|
2014-02-28 23:41:25 +00:00
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct azx *chip = bus_to_azx(bus);
|
2014-02-28 23:41:25 +00:00
|
|
|
|
unsigned int addr = azx_command_addr(val);
|
|
|
|
|
int timeout = 50;
|
|
|
|
|
|
2015-04-14 20:13:18 +00:00
|
|
|
|
bus->last_cmd[azx_command_addr(val)] = val;
|
2014-02-28 23:41:25 +00:00
|
|
|
|
while (timeout--) {
|
|
|
|
|
/* check ICB busy bit */
|
2014-06-26 15:54:37 +00:00
|
|
|
|
if (!((azx_readw(chip, IRS) & AZX_IRS_BUSY))) {
|
2014-02-28 23:41:25 +00:00
|
|
|
|
/* Clear IRV valid bit */
|
|
|
|
|
azx_writew(chip, IRS, azx_readw(chip, IRS) |
|
2014-06-26 15:54:37 +00:00
|
|
|
|
AZX_IRS_VALID);
|
2014-02-28 23:41:25 +00:00
|
|
|
|
azx_writel(chip, IC, val);
|
|
|
|
|
azx_writew(chip, IRS, azx_readw(chip, IRS) |
|
2014-06-26 15:54:37 +00:00
|
|
|
|
AZX_IRS_BUSY);
|
2014-02-28 23:41:25 +00:00
|
|
|
|
return azx_single_wait_for_response(chip, addr);
|
|
|
|
|
}
|
|
|
|
|
udelay(1);
|
|
|
|
|
}
|
|
|
|
|
if (printk_ratelimit())
|
|
|
|
|
dev_dbg(chip->card->dev,
|
|
|
|
|
"send_cmd timeout: IRS=0x%x, val=0x%x\n",
|
|
|
|
|
azx_readw(chip, IRS), val);
|
|
|
|
|
return -EIO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* receive a response */
|
2015-04-14 20:13:18 +00:00
|
|
|
|
static int azx_single_get_response(struct hdac_bus *bus, unsigned int addr,
|
2015-03-25 16:57:00 +00:00
|
|
|
|
unsigned int *res)
|
2014-02-28 23:41:25 +00:00
|
|
|
|
{
|
2015-03-25 16:57:00 +00:00
|
|
|
|
if (res)
|
2015-04-14 20:13:18 +00:00
|
|
|
|
*res = bus->rirb.res[addr];
|
2015-03-25 16:57:00 +00:00
|
|
|
|
return 0;
|
2014-02-28 23:41:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The below are the main callbacks from hda_codec.
|
|
|
|
|
*
|
|
|
|
|
* They are just the skeleton to call sub-callbacks according to the
|
|
|
|
|
* current setting of chip->single_cmd.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* send a command */
|
2015-04-14 20:13:18 +00:00
|
|
|
|
static int azx_send_cmd(struct hdac_bus *bus, unsigned int val)
|
2014-02-28 23:41:25 +00:00
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct azx *chip = bus_to_azx(bus);
|
2014-02-28 23:41:25 +00:00
|
|
|
|
|
|
|
|
|
if (chip->disabled)
|
|
|
|
|
return 0;
|
|
|
|
|
if (chip->single_cmd)
|
|
|
|
|
return azx_single_send_cmd(bus, val);
|
|
|
|
|
else
|
2015-04-14 20:13:18 +00:00
|
|
|
|
return snd_hdac_bus_send_cmd(bus, val);
|
2014-02-28 23:41:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get a response */
|
2015-04-14 20:13:18 +00:00
|
|
|
|
static int azx_get_response(struct hdac_bus *bus, unsigned int addr,
|
2015-03-25 16:57:00 +00:00
|
|
|
|
unsigned int *res)
|
2014-02-28 23:41:25 +00:00
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct azx *chip = bus_to_azx(bus);
|
|
|
|
|
|
2014-02-28 23:41:25 +00:00
|
|
|
|
if (chip->disabled)
|
|
|
|
|
return 0;
|
|
|
|
|
if (chip->single_cmd)
|
2015-03-25 16:57:00 +00:00
|
|
|
|
return azx_single_get_response(bus, addr, res);
|
2014-02-28 23:41:25 +00:00
|
|
|
|
else
|
2015-03-25 16:57:00 +00:00
|
|
|
|
return azx_rirb_get_response(bus, addr, res);
|
2014-02-28 23:41:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-14 14:55:31 +00:00
|
|
|
|
static const struct hdac_bus_ops bus_core_ops = {
|
|
|
|
|
.command = azx_send_cmd,
|
|
|
|
|
.get_response = azx_get_response,
|
|
|
|
|
};
|
|
|
|
|
|
2014-02-28 23:41:24 +00:00
|
|
|
|
#ifdef CONFIG_SND_HDA_DSP_LOADER
|
|
|
|
|
/*
|
|
|
|
|
* DSP loading code (e.g. for CA0132)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* use the first stream for loading DSP */
|
|
|
|
|
static struct azx_dev *
|
|
|
|
|
azx_get_dsp_loader_dev(struct azx *chip)
|
|
|
|
|
{
|
2015-04-14 16:13:13 +00:00
|
|
|
|
struct hdac_bus *bus = azx_bus(chip);
|
|
|
|
|
struct hdac_stream *s;
|
|
|
|
|
|
|
|
|
|
list_for_each_entry(s, &bus->stream_list, list)
|
|
|
|
|
if (s->index == chip->playback_index_offset)
|
|
|
|
|
return stream_to_azx_dev(s);
|
|
|
|
|
|
|
|
|
|
return NULL;
|
2014-02-28 23:41:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-16 21:25:02 +00:00
|
|
|
|
int snd_hda_codec_load_dsp_prepare(struct hda_codec *codec, unsigned int format,
|
|
|
|
|
unsigned int byte_size,
|
|
|
|
|
struct snd_dma_buffer *bufp)
|
2014-02-28 23:41:24 +00:00
|
|
|
|
{
|
2015-04-16 21:25:02 +00:00
|
|
|
|
struct hdac_bus *bus = &codec->bus->core;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct azx *chip = bus_to_azx(bus);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
struct azx_dev *azx_dev;
|
2015-04-14 20:06:53 +00:00
|
|
|
|
struct hdac_stream *hstr;
|
|
|
|
|
bool saved = false;
|
2014-02-28 23:41:24 +00:00
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
azx_dev = azx_get_dsp_loader_dev(chip);
|
2015-04-14 20:06:53 +00:00
|
|
|
|
hstr = azx_stream(azx_dev);
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_lock_irq(&bus->reg_lock);
|
2015-04-14 20:06:53 +00:00
|
|
|
|
if (hstr->opened) {
|
|
|
|
|
chip->saved_azx_dev = *azx_dev;
|
|
|
|
|
saved = true;
|
2014-02-28 23:41:24 +00:00
|
|
|
|
}
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_unlock_irq(&bus->reg_lock);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
|
2015-04-14 20:06:53 +00:00
|
|
|
|
err = snd_hdac_dsp_prepare(hstr, format, byte_size, bufp);
|
|
|
|
|
if (err < 0) {
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_lock_irq(&bus->reg_lock);
|
2015-04-14 20:06:53 +00:00
|
|
|
|
if (saved)
|
|
|
|
|
*azx_dev = chip->saved_azx_dev;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_unlock_irq(&bus->reg_lock);
|
2015-04-14 20:06:53 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
2014-02-28 23:41:24 +00:00
|
|
|
|
|
2015-04-17 11:34:30 +00:00
|
|
|
|
hstr->prepared = 0;
|
2014-02-28 23:41:24 +00:00
|
|
|
|
return err;
|
|
|
|
|
}
|
2015-04-16 21:25:02 +00:00
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hda_codec_load_dsp_prepare);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
|
2015-04-16 21:25:02 +00:00
|
|
|
|
void snd_hda_codec_load_dsp_trigger(struct hda_codec *codec, bool start)
|
2014-02-28 23:41:24 +00:00
|
|
|
|
{
|
2015-04-16 21:25:02 +00:00
|
|
|
|
struct hdac_bus *bus = &codec->bus->core;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct azx *chip = bus_to_azx(bus);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
|
|
|
|
|
|
2015-04-14 20:06:53 +00:00
|
|
|
|
snd_hdac_dsp_trigger(azx_stream(azx_dev), start);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
}
|
2015-04-16 21:25:02 +00:00
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hda_codec_load_dsp_trigger);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
|
2015-04-16 21:25:02 +00:00
|
|
|
|
void snd_hda_codec_load_dsp_cleanup(struct hda_codec *codec,
|
|
|
|
|
struct snd_dma_buffer *dmab)
|
2014-02-28 23:41:24 +00:00
|
|
|
|
{
|
2015-04-16 21:25:02 +00:00
|
|
|
|
struct hdac_bus *bus = &codec->bus->core;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct azx *chip = bus_to_azx(bus);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
|
2015-04-14 20:06:53 +00:00
|
|
|
|
struct hdac_stream *hstr = azx_stream(azx_dev);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
|
2015-04-16 21:25:02 +00:00
|
|
|
|
if (!dmab->area || !hstr->locked)
|
2014-02-28 23:41:24 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2015-04-14 20:06:53 +00:00
|
|
|
|
snd_hdac_dsp_cleanup(hstr, dmab);
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_lock_irq(&bus->reg_lock);
|
2015-04-14 20:06:53 +00:00
|
|
|
|
if (hstr->opened)
|
2014-02-28 23:41:24 +00:00
|
|
|
|
*azx_dev = chip->saved_azx_dev;
|
2015-04-14 20:06:53 +00:00
|
|
|
|
hstr->locked = false;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_unlock_irq(&bus->reg_lock);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
}
|
2015-04-16 21:25:02 +00:00
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hda_codec_load_dsp_cleanup);
|
2014-02-28 23:41:24 +00:00
|
|
|
|
#endif /* CONFIG_SND_HDA_DSP_LOADER */
|
|
|
|
|
|
2014-02-28 23:41:27 +00:00
|
|
|
|
/*
|
|
|
|
|
* reset and start the controller registers
|
|
|
|
|
*/
|
2014-04-09 10:30:57 +00:00
|
|
|
|
void azx_init_chip(struct azx *chip, bool full_reset)
|
2014-02-28 23:41:27 +00:00
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
if (snd_hdac_bus_init_chip(azx_bus(chip), full_reset)) {
|
|
|
|
|
/* correct RINTCNT for CXT */
|
|
|
|
|
if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
|
|
|
|
|
azx_writew(chip, RINTCNT, 0xc0);
|
|
|
|
|
}
|
2014-02-28 23:41:27 +00:00
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL_GPL(azx_init_chip);
|
|
|
|
|
|
2015-04-14 16:13:13 +00:00
|
|
|
|
void azx_stop_all_streams(struct azx *chip)
|
|
|
|
|
{
|
|
|
|
|
struct hdac_bus *bus = azx_bus(chip);
|
|
|
|
|
struct hdac_stream *s;
|
|
|
|
|
|
|
|
|
|
list_for_each_entry(s, &bus->stream_list, list)
|
|
|
|
|
snd_hdac_stream_stop(s);
|
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL_GPL(azx_stop_all_streams);
|
|
|
|
|
|
2014-02-28 23:41:27 +00:00
|
|
|
|
void azx_stop_chip(struct azx *chip)
|
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
snd_hdac_bus_stop_chip(azx_bus(chip));
|
2014-02-28 23:41:27 +00:00
|
|
|
|
}
|
2014-02-28 23:41:30 +00:00
|
|
|
|
EXPORT_SYMBOL_GPL(azx_stop_chip);
|
2014-02-28 23:41:27 +00:00
|
|
|
|
|
2014-02-28 23:41:29 +00:00
|
|
|
|
/*
|
|
|
|
|
* interrupt handler
|
|
|
|
|
*/
|
2015-04-14 16:13:13 +00:00
|
|
|
|
static void stream_update(struct hdac_bus *bus, struct hdac_stream *s)
|
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct azx *chip = bus_to_azx(bus);
|
2015-04-14 16:13:13 +00:00
|
|
|
|
struct azx_dev *azx_dev = stream_to_azx_dev(s);
|
|
|
|
|
|
|
|
|
|
/* check whether this IRQ is really acceptable */
|
|
|
|
|
if (!chip->ops->position_check ||
|
|
|
|
|
chip->ops->position_check(chip, azx_dev)) {
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_unlock(&bus->reg_lock);
|
|
|
|
|
snd_pcm_period_elapsed(azx_stream(azx_dev)->substream);
|
|
|
|
|
spin_lock(&bus->reg_lock);
|
2015-04-14 16:13:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-28 23:41:29 +00:00
|
|
|
|
irqreturn_t azx_interrupt(int irq, void *dev_id)
|
|
|
|
|
{
|
|
|
|
|
struct azx *chip = dev_id;
|
2015-04-14 16:13:13 +00:00
|
|
|
|
struct hdac_bus *bus = azx_bus(chip);
|
2014-02-28 23:41:29 +00:00
|
|
|
|
u32 status;
|
2016-02-23 14:54:47 +00:00
|
|
|
|
bool active, handled = false;
|
|
|
|
|
int repeat = 0; /* count for avoiding endless loop */
|
2014-02-28 23:41:29 +00:00
|
|
|
|
|
2014-12-12 23:42:18 +00:00
|
|
|
|
#ifdef CONFIG_PM
|
2015-02-19 15:51:17 +00:00
|
|
|
|
if (azx_has_pm_runtime(chip))
|
2014-04-08 19:06:18 +00:00
|
|
|
|
if (!pm_runtime_active(chip->card->dev))
|
2014-02-28 23:41:29 +00:00
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_lock(&bus->reg_lock);
|
2014-02-28 23:41:29 +00:00
|
|
|
|
|
2016-02-23 14:54:47 +00:00
|
|
|
|
if (chip->disabled)
|
|
|
|
|
goto unlock;
|
2014-02-28 23:41:29 +00:00
|
|
|
|
|
2016-02-23 14:54:47 +00:00
|
|
|
|
do {
|
|
|
|
|
status = azx_readl(chip, INTSTS);
|
|
|
|
|
if (status == 0 || status == 0xffffffff)
|
|
|
|
|
break;
|
2014-02-28 23:41:29 +00:00
|
|
|
|
|
2016-02-23 14:54:47 +00:00
|
|
|
|
handled = true;
|
|
|
|
|
active = false;
|
|
|
|
|
if (snd_hdac_bus_handle_stream_irq(bus, status, stream_update))
|
|
|
|
|
active = true;
|
|
|
|
|
|
|
|
|
|
status = azx_readb(chip, RIRBSTS);
|
|
|
|
|
if (status & RIRB_INT_MASK) {
|
2020-02-06 10:10:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* Clearing the interrupt status here ensures that no
|
|
|
|
|
* interrupt gets masked after the RIRB wp is read in
|
|
|
|
|
* snd_hdac_bus_update_rirb. This avoids a possible
|
|
|
|
|
* race condition where codec response in RIRB may
|
|
|
|
|
* remain unserviced by IRQ, eventually falling back
|
|
|
|
|
* to polling mode in azx_rirb_get_response.
|
|
|
|
|
*/
|
|
|
|
|
azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
|
2016-02-23 14:54:47 +00:00
|
|
|
|
active = true;
|
|
|
|
|
if (status & RIRB_INT_RESPONSE) {
|
|
|
|
|
if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
|
|
|
|
|
udelay(80);
|
|
|
|
|
snd_hdac_bus_update_rirb(bus);
|
|
|
|
|
}
|
2014-02-28 23:41:29 +00:00
|
|
|
|
}
|
2016-02-23 14:54:47 +00:00
|
|
|
|
} while (active && ++repeat < 10);
|
2014-02-28 23:41:29 +00:00
|
|
|
|
|
2016-02-23 14:54:47 +00:00
|
|
|
|
unlock:
|
2015-04-14 20:13:18 +00:00
|
|
|
|
spin_unlock(&bus->reg_lock);
|
2014-02-28 23:41:29 +00:00
|
|
|
|
|
2016-02-23 14:54:47 +00:00
|
|
|
|
return IRQ_RETVAL(handled);
|
2014-02-28 23:41:29 +00:00
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL_GPL(azx_interrupt);
|
|
|
|
|
|
2014-02-28 23:41:30 +00:00
|
|
|
|
/*
|
|
|
|
|
* Codec initerface
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Probe the given codec address
|
|
|
|
|
*/
|
|
|
|
|
static int probe_codec(struct azx *chip, int addr)
|
|
|
|
|
{
|
|
|
|
|
unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
|
|
|
|
|
(AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
|
2015-04-14 16:13:13 +00:00
|
|
|
|
struct hdac_bus *bus = azx_bus(chip);
|
2015-03-25 16:57:00 +00:00
|
|
|
|
int err;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
unsigned int res = -1;
|
2014-02-28 23:41:30 +00:00
|
|
|
|
|
2015-04-14 14:55:31 +00:00
|
|
|
|
mutex_lock(&bus->cmd_mutex);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
chip->probing = 1;
|
2015-04-14 14:55:31 +00:00
|
|
|
|
azx_send_cmd(bus, cmd);
|
|
|
|
|
err = azx_get_response(bus, addr, &res);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
chip->probing = 0;
|
2015-04-14 14:55:31 +00:00
|
|
|
|
mutex_unlock(&bus->cmd_mutex);
|
2015-03-25 16:57:00 +00:00
|
|
|
|
if (err < 0 || res == -1)
|
2014-02-28 23:41:30 +00:00
|
|
|
|
return -EIO;
|
|
|
|
|
dev_dbg(chip->card->dev, "codec #%d probed OK\n", addr);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-16 21:25:02 +00:00
|
|
|
|
void snd_hda_bus_reset(struct hda_bus *bus)
|
2014-02-28 23:41:30 +00:00
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct azx *chip = bus_to_azx(&bus->core);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
|
|
|
|
|
bus->in_reset = 1;
|
|
|
|
|
azx_stop_chip(chip);
|
2014-04-09 10:30:57 +00:00
|
|
|
|
azx_init_chip(chip, true);
|
2015-04-14 20:13:18 +00:00
|
|
|
|
if (bus->core.chip_init)
|
2015-04-16 21:25:02 +00:00
|
|
|
|
snd_hda_bus_reset_codecs(bus);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
bus->in_reset = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-19 17:12:22 +00:00
|
|
|
|
/* HD-audio bus initialization */
|
2019-08-07 18:32:08 +00:00
|
|
|
|
int azx_bus_init(struct azx *chip, const char *model)
|
2014-02-28 23:41:30 +00:00
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct hda_bus *bus = &chip->bus;
|
2015-02-19 17:12:22 +00:00
|
|
|
|
int err;
|
2014-02-28 23:41:30 +00:00
|
|
|
|
|
2019-08-07 18:32:08 +00:00
|
|
|
|
err = snd_hdac_bus_init(&bus->core, chip->card->dev, &bus_core_ops);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
if (err < 0)
|
|
|
|
|
return err;
|
|
|
|
|
|
2015-04-14 20:13:18 +00:00
|
|
|
|
bus->card = chip->card;
|
|
|
|
|
mutex_init(&bus->prepare_mutex);
|
2015-02-17 12:56:29 +00:00
|
|
|
|
bus->pci = chip->pci;
|
|
|
|
|
bus->modelname = model;
|
2015-10-17 16:25:38 +00:00
|
|
|
|
bus->mixer_assigned = -1;
|
2015-04-14 20:06:53 +00:00
|
|
|
|
bus->core.snoop = azx_snoop(chip);
|
|
|
|
|
if (chip->get_position[0] != azx_get_pos_lpib ||
|
|
|
|
|
chip->get_position[1] != azx_get_pos_lpib)
|
|
|
|
|
bus->core.use_posbuf = true;
|
2015-12-10 15:44:08 +00:00
|
|
|
|
bus->core.bdl_pos_adj = chip->bdl_pos_adj;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
if (chip->driver_caps & AZX_DCAPS_CORBRP_SELF_CLEAR)
|
|
|
|
|
bus->core.corbrp_self_clear = true;
|
2015-02-17 12:56:29 +00:00
|
|
|
|
|
2015-11-02 16:35:34 +00:00
|
|
|
|
if (chip->driver_caps & AZX_DCAPS_4K_BDLE_BOUNDARY)
|
|
|
|
|
bus->core.align_bdle_4k = true;
|
|
|
|
|
|
2020-06-18 14:40:51 +00:00
|
|
|
|
/* enable sync_write flag for stable communication as default */
|
|
|
|
|
bus->core.sync_write = 1;
|
2015-02-19 17:12:22 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2015-04-14 20:13:18 +00:00
|
|
|
|
EXPORT_SYMBOL_GPL(azx_bus_init);
|
2015-02-19 17:12:22 +00:00
|
|
|
|
|
|
|
|
|
/* Probe codecs */
|
|
|
|
|
int azx_probe_codecs(struct azx *chip, unsigned int max_slots)
|
|
|
|
|
{
|
2015-04-14 20:13:18 +00:00
|
|
|
|
struct hdac_bus *bus = azx_bus(chip);
|
2015-02-19 17:12:22 +00:00
|
|
|
|
int c, codecs, err;
|
|
|
|
|
|
2014-02-28 23:41:30 +00:00
|
|
|
|
codecs = 0;
|
|
|
|
|
if (!max_slots)
|
|
|
|
|
max_slots = AZX_DEFAULT_CODECS;
|
|
|
|
|
|
|
|
|
|
/* First try to probe all given codec slots */
|
|
|
|
|
for (c = 0; c < max_slots; c++) {
|
2015-04-14 20:13:18 +00:00
|
|
|
|
if ((bus->codec_mask & (1 << c)) & chip->codec_probe_mask) {
|
2014-02-28 23:41:30 +00:00
|
|
|
|
if (probe_codec(chip, c) < 0) {
|
|
|
|
|
/* Some BIOSen give you wrong codec addresses
|
|
|
|
|
* that don't exist
|
|
|
|
|
*/
|
|
|
|
|
dev_warn(chip->card->dev,
|
|
|
|
|
"Codec #%d probe error; disabling it...\n", c);
|
2015-04-14 20:13:18 +00:00
|
|
|
|
bus->codec_mask &= ~(1 << c);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
/* More badly, accessing to a non-existing
|
|
|
|
|
* codec often screws up the controller chip,
|
|
|
|
|
* and disturbs the further communications.
|
|
|
|
|
* Thus if an error occurs during probing,
|
|
|
|
|
* better to reset the controller chip to
|
|
|
|
|
* get back to the sanity state.
|
|
|
|
|
*/
|
|
|
|
|
azx_stop_chip(chip);
|
2014-04-09 10:30:57 +00:00
|
|
|
|
azx_init_chip(chip, true);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Then create codec instances */
|
|
|
|
|
for (c = 0; c < max_slots; c++) {
|
2015-04-14 20:13:18 +00:00
|
|
|
|
if ((bus->codec_mask & (1 << c)) & chip->codec_probe_mask) {
|
2014-02-28 23:41:30 +00:00
|
|
|
|
struct hda_codec *codec;
|
2015-04-14 20:13:18 +00:00
|
|
|
|
err = snd_hda_codec_new(&chip->bus, chip->card, c, &codec);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
if (err < 0)
|
|
|
|
|
continue;
|
2018-08-30 05:58:50 +00:00
|
|
|
|
codec->jackpoll_interval = chip->jackpoll_interval;
|
2014-02-28 23:41:30 +00:00
|
|
|
|
codec->beep_mode = chip->beep_mode;
|
|
|
|
|
codecs++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!codecs) {
|
|
|
|
|
dev_err(chip->card->dev, "no codecs initialized\n");
|
|
|
|
|
return -ENXIO;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2015-02-19 17:12:22 +00:00
|
|
|
|
EXPORT_SYMBOL_GPL(azx_probe_codecs);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
|
|
|
|
|
/* configure each codec instance */
|
|
|
|
|
int azx_codec_configure(struct azx *chip)
|
|
|
|
|
{
|
2017-06-28 10:02:02 +00:00
|
|
|
|
struct hda_codec *codec, *next;
|
|
|
|
|
|
|
|
|
|
/* use _safe version here since snd_hda_codec_configure() deregisters
|
|
|
|
|
* the device upon error and deletes itself from the bus list.
|
|
|
|
|
*/
|
|
|
|
|
list_for_each_codec_safe(codec, next, &chip->bus) {
|
2014-02-28 23:41:30 +00:00
|
|
|
|
snd_hda_codec_configure(codec);
|
|
|
|
|
}
|
2017-06-28 10:45:34 +00:00
|
|
|
|
|
|
|
|
|
if (!azx_bus(chip)->num_codecs)
|
|
|
|
|
return -ENODEV;
|
2014-02-28 23:41:30 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL_GPL(azx_codec_configure);
|
|
|
|
|
|
2015-04-14 16:13:13 +00:00
|
|
|
|
static int stream_direction(struct azx *chip, unsigned char index)
|
2014-12-19 00:44:30 +00:00
|
|
|
|
{
|
2015-04-14 16:13:13 +00:00
|
|
|
|
if (index >= chip->capture_index_offset &&
|
|
|
|
|
index < chip->capture_index_offset + chip->capture_streams)
|
|
|
|
|
return SNDRV_PCM_STREAM_CAPTURE;
|
|
|
|
|
return SNDRV_PCM_STREAM_PLAYBACK;
|
2014-12-19 00:44:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-28 23:41:30 +00:00
|
|
|
|
/* initialize SD streams */
|
2015-04-14 20:13:18 +00:00
|
|
|
|
int azx_init_streams(struct azx *chip)
|
2014-02-28 23:41:30 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
2015-04-14 16:13:13 +00:00
|
|
|
|
int stream_tags[2] = { 0, 0 };
|
2014-02-28 23:41:30 +00:00
|
|
|
|
|
|
|
|
|
/* initialize each stream (aka device)
|
|
|
|
|
* assign the starting bdl address to each stream (device)
|
|
|
|
|
* and initialize
|
|
|
|
|
*/
|
|
|
|
|
for (i = 0; i < chip->num_streams; i++) {
|
2015-04-14 16:13:13 +00:00
|
|
|
|
struct azx_dev *azx_dev = kzalloc(sizeof(*azx_dev), GFP_KERNEL);
|
|
|
|
|
int dir, tag;
|
|
|
|
|
|
|
|
|
|
if (!azx_dev)
|
|
|
|
|
return -ENOMEM;
|
2014-12-19 00:44:30 +00:00
|
|
|
|
|
2015-04-14 16:13:13 +00:00
|
|
|
|
dir = stream_direction(chip, i);
|
2014-12-19 00:44:30 +00:00
|
|
|
|
/* stream tag must be unique throughout
|
|
|
|
|
* the stream direction group,
|
|
|
|
|
* valid values 1...15
|
|
|
|
|
* use separate stream tag if the flag
|
|
|
|
|
* AZX_DCAPS_SEPARATE_STREAM_TAG is used
|
|
|
|
|
*/
|
|
|
|
|
if (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG)
|
2015-04-14 16:13:13 +00:00
|
|
|
|
tag = ++stream_tags[dir];
|
2014-12-19 00:44:30 +00:00
|
|
|
|
else
|
2015-04-14 16:13:13 +00:00
|
|
|
|
tag = i + 1;
|
|
|
|
|
snd_hdac_stream_init(azx_bus(chip), azx_stream(azx_dev),
|
|
|
|
|
i, dir, tag);
|
2014-02-28 23:41:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2015-04-14 20:13:18 +00:00
|
|
|
|
EXPORT_SYMBOL_GPL(azx_init_streams);
|
|
|
|
|
|
|
|
|
|
void azx_free_streams(struct azx *chip)
|
|
|
|
|
{
|
|
|
|
|
struct hdac_bus *bus = azx_bus(chip);
|
|
|
|
|
struct hdac_stream *s;
|
|
|
|
|
|
|
|
|
|
while (!list_empty(&bus->stream_list)) {
|
|
|
|
|
s = list_first_entry(&bus->stream_list, struct hdac_stream, list);
|
|
|
|
|
list_del(&s->list);
|
|
|
|
|
kfree(stream_to_azx_dev(s));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL_GPL(azx_free_streams);
|