// SPDX-License-Identifier: GPL-2.0-only /* * hdac-ext-stream.c - HD-audio extended stream operations. * * Copyright (C) 2015 Intel Corp * Author: Jeeja KP <[email protected]> * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include <linux/delay.h> #include <linux/pci.h> #include <linux/pci_ids.h> #include <linux/slab.h> #include <sound/pcm.h> #include <sound/hda_register.h> #include <sound/hdaudio_ext.h> #include <sound/compress_driver.h> /** * snd_hdac_ext_host_stream_setup - Setup a HOST stream. * @hext_stream: HDAudio stream to set up. * @code_loading: Whether the stream is for PCM or code-loading. * * Return: Zero on success or negative error code. */ int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream, bool code_loading) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hdac_apl_host_stream_setup - Setup a HOST stream following procedure * recommended for ApolloLake devices. * @hstream: HDAudio stream to set up. * @code_loading: Whether the stream is for PCM or code-loading. * * Return: Zero on success or negative error code. */ static int snd_hdac_apl_host_stream_setup(struct hdac_stream *hstream, bool code_loading) { … } /** * snd_hdac_ext_stream_init - initialize each stream (aka device) * @bus: HD-audio core bus * @hext_stream: HD-audio ext core stream object to initialize * @idx: stream index number * @direction: stream direction (SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE) * @tag: the tag id to assign * * initialize the stream, if ppcap is enabled then init those and then * invoke hdac stream initialization routine */ static void snd_hdac_ext_stream_init(struct hdac_bus *bus, struct hdac_ext_stream *hext_stream, int idx, int direction, int tag) { … } /** * snd_hdac_ext_stream_init_all - create and initialize the stream objects * for an extended hda bus * @bus: HD-audio core bus * @start_idx: start index for streams * @num_stream: number of streams to initialize * @dir: direction of streams */ int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx, int num_stream, int dir) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hdac_ext_stream_free_all - free hdac extended stream objects * * @bus: HD-audio core bus */ void snd_hdac_ext_stream_free_all(struct hdac_bus *bus) { … } EXPORT_SYMBOL_GPL(…); void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus, struct hdac_ext_stream *hext_stream, bool decouple) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hdac_ext_stream_decouple - decouple the hdac stream * @bus: HD-audio core bus * @hext_stream: HD-audio ext core stream object to initialize * @decouple: flag to decouple */ void snd_hdac_ext_stream_decouple(struct hdac_bus *bus, struct hdac_ext_stream *hext_stream, bool decouple) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hdac_ext_stream_start - start a stream * @hext_stream: HD-audio ext core stream to start */ void snd_hdac_ext_stream_start(struct hdac_ext_stream *hext_stream) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hdac_ext_stream_clear - stop a stream DMA * @hext_stream: HD-audio ext core stream to stop */ void snd_hdac_ext_stream_clear(struct hdac_ext_stream *hext_stream) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hdac_ext_stream_reset - reset a stream * @hext_stream: HD-audio ext core stream to reset */ void snd_hdac_ext_stream_reset(struct hdac_ext_stream *hext_stream) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hdac_ext_stream_setup - set up the SD for streaming * @hext_stream: HD-audio ext core stream to set up * @fmt: stream format */ int snd_hdac_ext_stream_setup(struct hdac_ext_stream *hext_stream, int fmt) { … } EXPORT_SYMBOL_GPL(…); static struct hdac_ext_stream * hdac_ext_link_dma_stream_assign(struct hdac_bus *bus, struct snd_pcm_substream *substream) { … } static struct hdac_ext_stream * hdac_ext_host_dma_stream_assign(struct hdac_bus *bus, struct snd_pcm_substream *substream) { … } /** * snd_hdac_ext_stream_assign - assign a stream for the PCM * @bus: HD-audio core bus * @substream: PCM substream to assign * @type: type of stream (coupled, host or link stream) * * This assigns the stream based on the type (coupled/host/link), for the * given PCM substream, assigns it and returns the stream object * * coupled: Looks for an unused stream * host: Looks for an unused decoupled host stream * link: Looks for an unused decoupled link stream * * If no stream is free, returns NULL. The function tries to keep using * the same stream object when it's used beforehand. when a stream is * decoupled, it becomes a host stream and link stream. */ struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus, struct snd_pcm_substream *substream, int type) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hdac_ext_stream_release - release the assigned stream * @hext_stream: HD-audio ext core stream to release * @type: type of stream (coupled, host or link stream) * * Release the stream that has been assigned by snd_hdac_ext_stream_assign(). */ void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hdac_ext_cstream_assign - assign a host stream for compress * @bus: HD-audio core bus * @cstream: Compress stream to assign * * Assign an unused host stream for the given compress stream. * If no stream is free, NULL is returned. Stream is decoupled * before assignment. */ struct hdac_ext_stream *snd_hdac_ext_cstream_assign(struct hdac_bus *bus, struct snd_compr_stream *cstream) { … } EXPORT_SYMBOL_GPL(…);