Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[pandora-kernel.git] / drivers / staging / intel_sst / intel_sst.h
1 #ifndef __INTEL_SST_H__
2 #define __INTEL_SST_H__
3 /*
4  *  intel_sst.h - Intel SST Driver for audio engine
5  *
6  *  Copyright (C) 2008-10 Intel Corporation
7  *  Authors:    Vinod Koul <vinod.koul@intel.com>
8  *              Harsha Priya <priya.harsha@intel.com>
9  *              Dharageswari R <dharageswari.r@intel.com>
10  *              KP Jeeja <jeeja.kp@intel.com>
11  *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12  *
13  *  This program is free software; you can redistribute it and/or modify
14  *  it under the terms of the GNU General Public License as published by
15  *  the Free Software Foundation; version 2 of the License.
16  *
17  *  This program is distributed in the hope that it will be useful, but
18  *  WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  *  General Public License for more details.
21  *
22  *  You should have received a copy of the GNU General Public License along
23  *  with this program; if not, write to the Free Software Foundation, Inc.,
24  *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25  *
26  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27  *
28  *  This driver exposes the audio engine functionalities to the ALSA
29  *      and middleware.
30  *  This file is shared between the SST and MAD drivers
31  */
32 #include "intel_sst_ioctl.h"
33 #include <sound/jack.h>
34
35 #define SST_CARD_NAMES "intel_mid_card"
36
37 #define MFLD_MAX_HW_CH 4
38 /* control list Pmic & Lpe */
39 /* Input controls */
40 enum port_status {
41         ACTIVATE = 1,
42         DEACTIVATE,
43 };
44
45 /* Card states */
46 enum sst_card_states {
47         SND_CARD_UN_INIT = 0,
48         SND_CARD_INIT_DONE,
49 };
50
51 enum sst_controls {
52         SST_SND_ALLOC =                 0x1000,
53         SST_SND_PAUSE =                 0x1001,
54         SST_SND_RESUME =                0x1002,
55         SST_SND_DROP =                  0x1003,
56         SST_SND_FREE =                  0x1004,
57         SST_SND_BUFFER_POINTER =        0x1005,
58         SST_SND_STREAM_INIT =           0x1006,
59         SST_SND_START    =              0x1007,
60         SST_SND_STREAM_PROCESS =        0x1008,
61         SST_MAX_CONTROLS =              0x1008,
62         SST_CONTROL_BASE =              0x1000,
63         SST_ENABLE_RX_TIME_SLOT =       0x1009,
64 };
65
66 enum SND_CARDS {
67         SND_FS = 0,
68         SND_MX,
69         SND_NC,
70         SND_MSIC
71 };
72
73 struct pcm_stream_info {
74         int str_id;
75         void *mad_substream;
76         void (*period_elapsed) (void *mad_substream);
77         unsigned long long buffer_ptr;
78         int sfreq;
79 };
80
81 struct snd_pmic_ops {
82         int card_status;
83         int master_mute;
84         int num_channel;
85         int input_dev_id;
86         int mute_status;
87         struct mutex lock;
88         int pb_on, pbhs_on;
89         int cap_on;
90         int output_dev_id;
91         int lineout_dev_id, line_out_names_cnt;
92         int prev_lineout_dev_id;
93         bool jack_interrupt_status;
94         int (*set_input_dev) (u8 value);
95         int (*set_output_dev) (u8 value);
96         int (*set_lineout_dev) (u8 value);
97         int (*set_mute) (int dev_id, u8 value);
98         int (*get_mute) (int dev_id, u8 *value);
99
100         int (*set_vol) (int dev_id, int value);
101         int (*get_vol) (int dev_id, int *value);
102
103         int (*init_card) (void);
104         int (*set_pcm_audio_params)
105                 (int sfreq, int word_size , int num_channel);
106         int (*set_pcm_voice_params) (void);
107         int (*set_voice_port) (int status);
108         int (*set_audio_port) (int status);
109
110         int (*power_up_pmic_pb) (unsigned int port);
111         int (*power_up_pmic_cp) (unsigned int port);
112         int (*power_down_pmic_pb) (unsigned int device);
113         int (*power_down_pmic_cp) (unsigned int device);
114         int (*power_down_pmic) (void);
115         void (*pmic_irq_cb) (void *cb_data, u8 value);
116         void (*pmic_irq_enable)(void *data);
117         int (*pmic_jack_enable) (void);
118         int (*pmic_get_mic_bias)(void *intelmaddata);
119         int (*pmic_set_headset_state)(int state);
120
121         unsigned int hw_dmic_map[MFLD_MAX_HW_CH];
122         unsigned int available_dmics;
123         int (*set_hw_dmic_route) (u8 index);
124
125         int gpio_amp;
126 };
127
128 extern void sst_mad_send_jack_report(struct snd_jack *jack,
129                                      int buttonpressevent,
130                                      int status);
131
132
133 int intemad_set_headset_state(int state);
134 int intelmad_get_mic_bias(void);
135
136 struct intel_sst_pcm_control {
137         int (*open) (struct snd_sst_params *str_param);
138         int (*device_control) (int cmd, void *arg);
139         int (*close) (unsigned int str_id);
140 };
141 struct intel_sst_card_ops {
142         char *module_name;
143         unsigned int  vendor_id;
144         struct intel_sst_pcm_control *pcm_control;
145         struct snd_pmic_ops *scard_ops;
146 };
147
148 /* modified for generic access */
149 struct sc_reg_access {
150         u16 reg_addr;
151         u8 value;
152         u8 mask;
153 };
154 enum sc_reg_access_type {
155         PMIC_READ = 0,
156         PMIC_WRITE,
157         PMIC_READ_MODIFY,
158 };
159
160 int register_sst_card(struct intel_sst_card_ops *card);
161 void unregister_sst_card(struct intel_sst_card_ops *card);
162 #endif /* __INTEL_SST_H__ */