x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / drivers / staging / bcm2835-audio / bcm2835.h
blob36e3ef80e60cd1926fb66af57d5648086c55e7ec
1 /*****************************************************************************
2 * Copyright 2011 Broadcom Corporation. All rights reserved.
4 * Unless you and Broadcom execute a separate written software license
5 * agreement governing use of this software, this software is licensed to you
6 * under the terms of the GNU General Public License version 2, available at
7 * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
9 * Notwithstanding the above, under no circumstances may you combine this
10 * software in any way with any other Broadcom software provided under a
11 * license other than the GPL, without Broadcom's express prior written
12 * consent.
13 *****************************************************************************/
15 #ifndef __SOUND_ARM_BCM2835_H
16 #define __SOUND_ARM_BCM2835_H
18 #include <linux/device.h>
19 #include <linux/list.h>
20 #include <linux/interrupt.h>
21 #include <linux/wait.h>
22 #include <sound/core.h>
23 #include <sound/initval.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
26 #include <sound/pcm-indirect.h>
27 #include <linux/workqueue.h>
30 #define AUDIO_DEBUG_ENABLE
31 #define AUDIO_VERBOSE_DEBUG_ENABLE
34 /* Debug macros */
36 #ifdef AUDIO_DEBUG_ENABLE
37 #ifdef AUDIO_VERBOSE_DEBUG_ENABLE
39 #define audio_debug(fmt, arg...) \
40 printk(KERN_INFO"%s:%d " fmt, __func__, __LINE__, ##arg)
42 #define audio_info(fmt, arg...) \
43 printk(KERN_INFO"%s:%d " fmt, __func__, __LINE__, ##arg)
45 #else
47 #define audio_debug(fmt, arg...)
49 #define audio_info(fmt, arg...)
51 #endif /* AUDIO_VERBOSE_DEBUG_ENABLE */
53 #else
55 #define audio_debug(fmt, arg...)
57 #define audio_info(fmt, arg...)
59 #endif /* AUDIO_DEBUG_ENABLE */
61 #define audio_error(fmt, arg...) \
62 printk(KERN_ERR"%s:%d " fmt, __func__, __LINE__, ##arg)
64 #define audio_warning(fmt, arg...) \
65 printk(KERN_WARNING"%s:%d " fmt, __func__, __LINE__, ##arg)
67 #define audio_alert(fmt, arg...) \
68 printk(KERN_ALERT"%s:%d " fmt, __func__, __LINE__, ##arg)
70 #define MAX_SUBSTREAMS (8)
71 #define AVAIL_SUBSTREAMS_MASK (0xff)
73 enum {
74 CTRL_VOL_MUTE,
75 CTRL_VOL_UNMUTE
78 /* macros for alsa2chip and chip2alsa, instead of functions */
80 #define alsa2chip(vol) (uint)(-((vol << 8) / 100)) /* convert alsa to chip volume (defined as macro rather than function call) */
81 #define chip2alsa(vol) -((vol * 100) >> 8) /* convert chip to alsa volume */
83 /* Some constants for values .. */
84 enum snd_bcm2835_route {
85 AUDIO_DEST_AUTO = 0,
86 AUDIO_DEST_HEADPHONES = 1,
87 AUDIO_DEST_HDMI = 2,
88 AUDIO_DEST_MAX,
91 enum snd_bcm2835_ctrl {
92 PCM_PLAYBACK_VOLUME,
93 PCM_PLAYBACK_MUTE,
94 PCM_PLAYBACK_DEVICE,
97 /* definition of the chip-specific record */
98 struct bcm2835_chip {
99 struct snd_card *card;
100 struct snd_pcm *pcm;
101 struct snd_pcm *pcm_spdif;
102 /* Bitmat for valid reg_base and irq numbers */
103 unsigned int avail_substreams;
104 struct platform_device *pdev[MAX_SUBSTREAMS];
105 struct bcm2835_alsa_stream *alsa_stream[MAX_SUBSTREAMS];
107 int volume;
108 int old_volume; /* stores the volume value whist muted */
109 int dest;
110 int mute;
112 unsigned int opened;
113 unsigned int spdif_status;
114 struct mutex audio_mutex;
117 struct bcm2835_alsa_stream {
118 struct bcm2835_chip *chip;
119 struct snd_pcm_substream *substream;
120 struct snd_pcm_indirect pcm_indirect;
122 struct semaphore buffers_update_sem;
123 struct semaphore control_sem;
124 spinlock_t lock;
125 volatile unsigned int control;
126 volatile unsigned int status;
128 int open;
129 int running;
130 int draining;
132 int channels;
133 int params_rate;
134 int pcm_format_width;
136 unsigned int pos;
137 unsigned int buffer_size;
138 unsigned int period_size;
140 atomic_t retrieved;
141 struct bcm2835_audio_instance *instance;
142 struct workqueue_struct *my_wq;
143 int idx;
146 int snd_bcm2835_new_ctl(struct bcm2835_chip *chip);
147 int snd_bcm2835_new_pcm(struct bcm2835_chip *chip);
148 int snd_bcm2835_new_spdif_pcm(struct bcm2835_chip *chip);
150 int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream);
151 int bcm2835_audio_close(struct bcm2835_alsa_stream *alsa_stream);
152 int bcm2835_audio_set_params(struct bcm2835_alsa_stream *alsa_stream,
153 unsigned int channels, unsigned int samplerate,
154 unsigned int bps);
155 int bcm2835_audio_setup(struct bcm2835_alsa_stream *alsa_stream);
156 int bcm2835_audio_start(struct bcm2835_alsa_stream *alsa_stream);
157 int bcm2835_audio_stop(struct bcm2835_alsa_stream *alsa_stream);
158 int bcm2835_audio_set_ctls(struct bcm2835_chip *chip);
159 int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream,
160 unsigned int count,
161 void *src);
162 void bcm2835_playback_fifo(struct bcm2835_alsa_stream *alsa_stream);
163 unsigned int bcm2835_audio_retrieve_buffers(struct bcm2835_alsa_stream *alsa_stream);
164 void bcm2835_audio_flush_buffers(struct bcm2835_alsa_stream *alsa_stream);
165 void bcm2835_audio_flush_playback_buffers(struct bcm2835_alsa_stream *alsa_stream);
167 #endif /* __SOUND_ARM_BCM2835_H */