blob: 9ea6b44e033d079a1ac2d9dd16b723a6cf44c86d [file] [log] [blame]
Dylan Reid05e84872014-02-28 15:41:22 -08001/*
2 * Common functionality for the alsa driver code base for HD Audio.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 */
14
15#ifndef __SOUND_HDA_CONTROLLER_H
16#define __SOUND_HDA_CONTROLLER_H
17
18#include <sound/core.h>
19#include <sound/initval.h>
20#include "hda_codec.h"
21#include "hda_priv.h"
22
23/* PCM setup */
24int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
25 struct hda_pcm *cpcm);
26static inline struct azx_dev *get_azx_dev(struct snd_pcm_substream *substream)
27{
28 return substream->runtime->private_data;
29}
30unsigned int azx_get_position(struct azx *chip,
31 struct azx_dev *azx_dev,
32 bool with_check);
33
34/* Stream control. */
35void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev);
36void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev);
37void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev);
38int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev);
39int setup_bdle(struct azx *chip,
40 struct snd_dma_buffer *dmab,
41 struct azx_dev *azx_dev, u32 **bdlp,
42 int ofs, int size, int with_ioc);
43
44/* DSP lock helpers */
45#ifdef CONFIG_SND_HDA_DSP_LOADER
46#define dsp_lock_init(dev) mutex_init(&(dev)->dsp_mutex)
47#define dsp_lock(dev) mutex_lock(&(dev)->dsp_mutex)
48#define dsp_unlock(dev) mutex_unlock(&(dev)->dsp_mutex)
49#define dsp_is_locked(dev) ((dev)->locked)
50#else
51#define dsp_lock_init(dev) do {} while (0)
52#define dsp_lock(dev) do {} while (0)
53#define dsp_unlock(dev) do {} while (0)
54#define dsp_is_locked(dev) 0
55#endif
56
Dylan Reid67908992014-02-28 15:41:23 -080057/* Allocation functions. */
58int azx_alloc_stream_pages(struct azx *chip);
59void azx_free_stream_pages(struct azx *chip);
60
Dylan Reid05e84872014-02-28 15:41:22 -080061#endif /* __SOUND_HDA_CONTROLLER_H */