Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux...
[linux-btrfs-devel.git] / drivers / staging / intel_sst / intelmid.h
blob14a7ba078b7c9f447b56042a3a996f33a0d7858f
1 /*
2 * intelmid.h - Intel Sound card driver for MID
4 * Copyright (C) 2008-10 Intel Corp
5 * Authors: Harsha Priya <priya.harsha@intel.com>
6 * Vinod Koul <vinod.koul@intel.com>
7 * Dharageswari R <dharageswari.r@intel.com>
8 * KP Jeeja <jeeja.kp@intel.com>
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation version 2 of the License.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 * ALSA driver header for Intel MAD chipset
27 #ifndef __INTELMID_H
28 #define __INTELMID_H
30 #include <linux/time.h>
31 #include <sound/jack.h>
33 #define DRIVER_NAME_MFLD "msic_audio"
34 #define DRIVER_NAME_MRST "pmic_audio"
35 #define DRIVER_NAME "intelmid_audio"
36 #define PMIC_SOUND_IRQ_TYPE_MASK (1 << 15)
37 #define AUDINT_BASE (0xFFFFEFF8 + (6 * sizeof(u8)))
38 #define REG_IRQ
39 /* values #defined */
40 /* will differ for different hw - to be taken from config */
41 #define MAX_DEVICES 1
42 #define MIN_RATE 8000
43 #define MAX_RATE 48000
44 #define MAX_BUFFER (800*1024) /* for PCM */
45 #define MIN_BUFFER (800*1024)
46 #define MAX_PERIODS (1024*2)
47 #define MIN_PERIODS 2
48 #define MAX_PERIOD_BYTES MAX_BUFFER
49 #define MIN_PERIOD_BYTES 32
50 /*#define MIN_PERIOD_BYTES 160*/
51 #define MAX_MUTE 1
52 #define MIN_MUTE 0
53 #define MONO_CNTL 1
54 #define STEREO_CNTL 2
55 #define MIN_CHANNEL 1
56 #define MAX_CHANNEL_AMIC 2
57 #define MAX_CHANNEL_DMIC 5
58 #define FIFO_SIZE 0 /* fifo not being used */
59 #define INTEL_MAD "Intel MAD"
60 #define MAX_CTRL_MRST 8
61 #define MAX_CTRL_MFLD 7
62 #define MAX_CTRL 8
63 #define MAX_VENDORS 4
64 /* TODO +6 db */
65 #define MAX_VOL 64
66 /* TODO -57 db */
67 #define MIN_VOL 0
68 #define PLAYBACK_COUNT 1
69 #define CAPTURE_COUNT 1
70 #define ADC_ONE_LSB_MULTIPLIER 2346
72 #define MID_JACK_HS_LONG_PRESS SND_JACK_BTN_0
73 #define MID_JACK_HS_SHORT_PRESS SND_JACK_BTN_1
75 extern int sst_card_vendor_id;
77 struct mad_jack {
78 struct snd_jack jack;
79 int jack_status;
80 int jack_dev_state;
81 struct timeval buttonpressed;
82 struct timeval buttonreleased;
85 struct mad_jack_msg_wq {
86 u8 intsts;
87 struct snd_intelmad *intelmaddata;
88 struct work_struct wq;
92 struct snd_intelmad_probe_info {
93 unsigned int cpu_id;
94 unsigned int irq_cache;
95 unsigned int size;
98 /**
99 * struct snd_intelmad - intelmad driver structure
101 * @card: ptr to the card details
102 * @card_index: sound card index
103 * @card_id: sound card id detected
104 * @sstdrv_ops: ptr to sst driver ops
105 * @pdev: ptr to platform device
106 * @irq: interrupt number detected
107 * @pmic_status: Device status of sound card
108 * @int_base: ptr to MMIO interrupt region
109 * @output_sel: device selected as o/p
110 * @input_sel: device selected as i/p
111 * @master_mute: master mute status
112 * @jack: jack status
113 * @playback_cnt: active pb streams
114 * @capture_cnt: active cp streams
115 * @mad_jack_msg: wq struct for jack interrupt processing
116 * @mad_jack_wq: wq for jack interrupt processing
117 * @jack_prev_state: Previos state of jack detected
118 * @cpu_id: current cpu id loaded for
120 struct snd_intelmad {
121 struct snd_card *card; /* ptr to the card details */
122 int card_index;/* card index */
123 char *card_id; /* card id */
124 struct intel_sst_card_ops *sstdrv_ops;/* ptr to sst driver ops */
125 struct platform_device *pdev;
126 int irq;
127 int pmic_status;
128 void __iomem *int_base;
129 int output_sel;
130 int input_sel;
131 int lineout_sel;
132 int master_mute;
133 struct mad_jack jack[4];
134 int playback_cnt;
135 int capture_cnt;
136 u16 adc_address;
137 struct mad_jack_msg_wq mad_jack_msg;
138 struct workqueue_struct *mad_jack_wq;
139 u8 jack_prev_state;
140 unsigned int cpu_id;
143 struct snd_control_val {
144 int playback_vol_max;
145 int playback_vol_min;
146 int capture_vol_max;
147 int capture_vol_min;
148 int master_vol_max;
149 int master_vol_min;
152 struct mad_stream_pvt {
153 int stream_status;
154 int stream_ops;
155 struct snd_pcm_substream *substream;
156 struct pcm_stream_info stream_info;
157 ssize_t dbg_cum_bytes;
158 enum snd_sst_device_type device;
161 enum mad_drv_status {
162 INIT = 1,
163 STARTED,
164 RUNNING,
165 PAUSED,
166 DROPPED,
169 enum mad_pmic_status {
170 PMIC_UNINIT = 1,
171 PMIC_INIT,
173 enum _widget_ctrl {
174 OUTPUT_SEL = 1,
175 INPUT_SEL,
176 PLAYBACK_VOL,
177 PLAYBACK_MUTE,
178 CAPTURE_VOL,
179 CAPTURE_MUTE,
180 MASTER_VOL,
181 MASTER_MUTE
183 enum _widget_ctrl_mfld {
184 LINEOUT_SEL_MFLD = 3,
186 enum hw_chs {
187 HW_CH0 = 0,
188 HW_CH1,
189 HW_CH2,
190 HW_CH3
193 void period_elapsed(void *mad_substream);
194 int snd_intelmad_alloc_stream(struct snd_pcm_substream *substream);
195 int snd_intelmad_init_stream(struct snd_pcm_substream *substream);
197 int sst_sc_reg_access(struct sc_reg_access *sc_access,
198 int type, int num_val);
199 #define CPU_CHIP_LINCROFT 1 /* System running lincroft */
200 #define CPU_CHIP_PENWELL 2 /* System running penwell */
202 extern struct snd_control_val intelmad_ctrl_val[];
203 extern struct snd_kcontrol_new snd_intelmad_controls_mrst[];
204 extern struct snd_kcontrol_new snd_intelmad_controls_mfld[];
205 extern struct snd_pmic_ops *intelmad_vendor_ops[];
206 void sst_mad_send_jack_report(struct snd_jack *jack,
207 int buttonpressevent , int status);
209 #endif /* __INTELMID_H */