Commit | Line | Data |
---|---|---|
fffa1cca VK |
1 | /* |
2 | * intelmid.h - Intel Sound card driver for MID | |
3 | * | |
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 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
10 | * | |
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. | |
14 | * | |
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. | |
19 | * | |
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. | |
23 | * | |
24 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
25 | * ALSA driver header for Intel MAD chipset | |
26 | */ | |
27 | #ifndef __INTELMID_H | |
28 | #define __INTELMID_H | |
29 | ||
30 | #include <linux/time.h> | |
31 | ||
32 | #define DRIVER_NAME_MFLD "msic_audio" | |
33 | #define DRIVER_NAME_MRST "pmic_audio" | |
34 | #define DRIVER_NAME "intelmid_audio" | |
35 | #define PMIC_SOUND_IRQ_TYPE_MASK (1 << 15) | |
36 | #define AUDINT_BASE (0xFFFFEFF8 + (6 * sizeof(u8))) | |
37 | #define REG_IRQ | |
38 | /* values #defined */ | |
39 | /* will differ for different hw - to be taken from config */ | |
40 | #define MAX_DEVICES 1 | |
41 | #define MIN_RATE 8000 | |
42 | #define MAX_RATE 48000 | |
43 | #define MAX_BUFFER (800*1024) /* for PCM */ | |
44 | #define MIN_BUFFER (800*1024) | |
45 | #define MAX_PERIODS (1024*2) | |
46 | #define MIN_PERIODS 1 | |
47 | #define MAX_PERIOD_BYTES MAX_BUFFER | |
48 | #define MIN_PERIOD_BYTES 32 | |
49 | /*#define MIN_PERIOD_BYTES 160*/ | |
50 | #define MAX_MUTE 1 | |
51 | #define MIN_MUTE 0 | |
52 | #define MONO_CNTL 1 | |
53 | #define STEREO_CNTL 2 | |
54 | #define MIN_CHANNEL 1 | |
55 | #define MAX_CHANNEL_AMIC 2 | |
56 | #define MAX_CHANNEL_DMIC 4 | |
57 | #define FIFO_SIZE 0 /* fifo not being used */ | |
58 | #define INTEL_MAD "Intel MAD" | |
59 | #define MAX_CTRL_MRST 7 | |
60 | #define MAX_CTRL_MFLD 2 | |
61 | #define MAX_CTRL 7 | |
62 | #define MAX_VENDORS 4 | |
63 | /* TODO +6 db */ | |
64 | #define MAX_VOL 64 | |
65 | /* TODO -57 db */ | |
66 | #define MIN_VOL 0 | |
67 | #define PLAYBACK_COUNT 1 | |
68 | #define CAPTURE_COUNT 1 | |
69 | ||
70 | extern int sst_card_vendor_id; | |
71 | ||
72 | struct mad_jack { | |
73 | struct snd_jack jack; | |
74 | int jack_status; | |
75 | struct timeval buttonpressed; | |
76 | struct timeval buttonreleased; | |
77 | }; | |
78 | ||
79 | struct mad_jack_msg_wq { | |
80 | u8 intsts; | |
81 | struct snd_intelmad *intelmaddata; | |
82 | struct work_struct wq; | |
83 | ||
84 | }; | |
85 | ||
86 | /** | |
87 | * struct snd_intelmad - intelmad driver structure | |
88 | * | |
89 | * @card: ptr to the card details | |
90 | * @card_index: sound card index | |
91 | * @card_id: sound card id detected | |
92 | * @sstdrv_ops: ptr to sst driver ops | |
25985edc | 93 | * @pdev: ptr to platform device |
fffa1cca VK |
94 | * @irq: interrupt number detected |
95 | * @pmic_status: Device status of sound card | |
96 | * @int_base: ptr to MMIO interrupt region | |
3173a5ec UKK |
97 | * @output_sel: device selected as o/p |
98 | * @input_sel: device selected as i/p | |
fffa1cca VK |
99 | * @master_mute: master mute status |
100 | * @jack: jack status | |
101 | * @playback_cnt: active pb streams | |
102 | * @capture_cnt: active cp streams | |
103 | * @mad_jack_msg: wq struct for jack interrupt processing | |
104 | * @mad_jack_wq: wq for jack interrupt processing | |
105 | * @jack_prev_state: Previos state of jack detected | |
106 | * @cpu_id: current cpu id loaded for | |
107 | */ | |
108 | struct snd_intelmad { | |
109 | struct snd_card *card; /* ptr to the card details */ | |
110 | int card_index;/* card index */ | |
111 | char *card_id; /* card id */ | |
112 | struct intel_sst_card_ops *sstdrv_ops;/* ptr to sst driver ops */ | |
113 | struct platform_device *pdev; | |
114 | int irq; | |
115 | int pmic_status; | |
116 | void __iomem *int_base; | |
117 | int output_sel; | |
118 | int input_sel; | |
119 | int master_mute; | |
120 | struct mad_jack jack[4]; | |
121 | int playback_cnt; | |
122 | int capture_cnt; | |
123 | struct mad_jack_msg_wq mad_jack_msg; | |
124 | struct workqueue_struct *mad_jack_wq; | |
125 | u8 jack_prev_state; | |
126 | unsigned int cpu_id; | |
127 | }; | |
128 | ||
129 | struct snd_control_val { | |
130 | int playback_vol_max; | |
131 | int playback_vol_min; | |
132 | int capture_vol_max; | |
133 | int capture_vol_min; | |
134 | }; | |
135 | ||
136 | struct mad_stream_pvt { | |
137 | int stream_status; | |
138 | int stream_ops; | |
139 | struct snd_pcm_substream *substream; | |
140 | struct pcm_stream_info stream_info; | |
141 | ssize_t dbg_cum_bytes; | |
142 | enum snd_sst_device_type device; | |
143 | }; | |
144 | ||
145 | enum mad_drv_status { | |
146 | INIT = 1, | |
147 | STARTED, | |
148 | RUNNING, | |
149 | PAUSED, | |
150 | DROPPED, | |
151 | }; | |
152 | ||
153 | enum mad_pmic_status { | |
154 | PMIC_UNINIT = 1, | |
155 | PMIC_INIT, | |
156 | }; | |
157 | enum _widget_ctrl { | |
158 | OUTPUT_SEL = 1, | |
159 | INPUT_SEL, | |
160 | PLAYBACK_VOL, | |
161 | PLAYBACK_MUTE, | |
162 | CAPTURE_VOL, | |
163 | CAPTURE_MUTE, | |
164 | MASTER_MUTE | |
165 | }; | |
166 | ||
167 | void period_elapsed(void *mad_substream); | |
168 | int snd_intelmad_alloc_stream(struct snd_pcm_substream *substream); | |
169 | int snd_intelmad_init_stream(struct snd_pcm_substream *substream); | |
170 | ||
171 | int sst_sc_reg_access(struct sc_reg_access *sc_access, | |
172 | int type, int num_val); | |
173 | #define CPU_CHIP_LINCROFT 1 /* System running lincroft */ | |
174 | #define CPU_CHIP_PENWELL 2 /* System running penwell */ | |
175 | ||
176 | extern struct snd_control_val intelmad_ctrl_val[]; | |
177 | extern struct snd_kcontrol_new snd_intelmad_controls_mrst[]; | |
178 | extern struct snd_kcontrol_new snd_intelmad_controls_mfld[]; | |
179 | extern struct snd_pmic_ops *intelmad_vendor_ops[]; | |
180 | ||
fffa1cca | 181 | #endif /* __INTELMID_H */ |