1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
/*
* wm8994_samsung.h -- WM8994 Soc Audio driver
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _WM8994_SAMSUNG_H
#define _WM8994_SAMSUNG_H
#include <sound/soc.h>
#include <linux/mfd/wm8994/wm8994_pdata.h>
/* Sources for AIF1/2 SYSCLK - use with set_dai_sysclk() */
#define WM8994_SYSCLK_MCLK1 1
#define WM8994_SYSCLK_MCLK2 2
#define WM8994_SYSCLK_FLL1 3
#define WM8994_SYSCLK_FLL2 4
#define WM8994_FLL1 1
#define WM8994_FLL2 2
/* Added belows codes by Samsung Electronics.*/
#include "wm8994_def.h"
#define WM8994_SYSCLK_MCLK 1
#define WM8994_SYSCLK_FLL 2
//#define WM8994_CACHE_SIZE 1570
#define AUDIO_COMMON_DEBUG 0
#define DEACTIVE 0x00
#define PLAYBACK_ACTIVE 0x01
#define CAPTURE_ACTIVE 0x02
#define CALL_ACTIVE 0x04
#define PCM_STREAM_DEACTIVE 0x00
#define PCM_STREAM_PLAYBACK 0x01
#define PCM_STREAM_CAPTURE 0x02
/*
Codec Output Path BIT
[0:11] : For output device
[12:15] : For mode
[16] : For gain code
*/
#define PLAYBACK_MODE (0x01 << 12)
#define VOICECALL_MODE (0x01 << 13)
#define RECORDING_MODE (0x01 << 14)
#define FMRADIO_MODE (0x01 << 15)
/*
* devide codec gain table
* GAIN_DIVISION_BIT_1 : EUR
* GAIN_DIVISION_BIT_2 : AT&T
* GAIN_DIVISION_BIT_3 : EUR_T
*/
#define GAIN_DIVISION_BIT_1 (0x01 << 16)
#define GAIN_DIVISION_BIT_2 (0x01 << 17)
#define GAIN_DIVISION_BIT_3 (0x01 << 18)
#define COMMON_SET_BIT (0x01 << 0)
#define PLAYBACK_RCV (0x01 << 1)
#define PLAYBACK_SPK (0x01 << 2)
#define PLAYBACK_HP (0x01 << 3)
#define PLAYBACK_BT (0x01 << 4)
#define PLAYBACK_SPK_HP (0x01 << 5)
#define PLAYBACK_RING_SPK (0x01 << 6)
#define PLAYBACK_RING_HP (0x01 << 7)
#define PLAYBACK_RING_SPK_HP (0x01 << 8)
#define PLAYBACK_HP_NO_MIC (0x01 << 9)
#define VOICECALL_RCV (0x01 << 1)
#define VOICECALL_SPK (0x01 << 2)
#define VOICECALL_HP (0x01 << 3)
#define VOICECALL_HP_NO_MIC (0x01 << 4)
#define VOICECALL_BT (0x01 << 5)
#define VOICECALL_TTY_VCO (0x01 << 6)
#define VOICECALL_TTY_HCO (0x01 << 7)
#define VOICECALL_TTY_FULL (0x01 << 8)
#define RECORDING_MAIN (0x01 << 1)
#define RECORDING_HP (0x01 << 2)
#define RECORDING_BT (0x01 << 3)
#define RECORDING_REC_MAIN (0x01 << 4)
#define RECORDING_REC_HP (0x01 << 5)
#define RECORDING_REC_BT (0x01 << 6)
#define RECORDING_CAM_MAIN (0x01 << 7)
#define RECORDING_CAM_HP (0x01 << 8)
#define RECORDING_CAM_BT (0x01 << 9)
#define RECORDING_VC_MAIN (0x01 << 10)
#define RECORDING_VC_HP (0x01 << 11)
#define RECORDING_VC_BT (0x01 << 12)
#define PLAYBACK_GAIN_NUM 43
#define VOICECALL_GAIN_NUM 38
#define RECORDING_GAIN_NUM 32
#define GAIN_CODE_NUM 13
/*
* Definitions of enum type
*/
enum audio_path {
OFF, RCV, SPK, HP, HP_NO_MIC, BT, SPK_HP,
RING_SPK, RING_HP, RING_NO_MIC, RING_SPK_HP
};
enum call_path {
CALL_OFF, CALL_RCV, CALL_SPK, CALL_HP,
CALL_HP_NO_MIC, CALL_BT, CALL_TTY_VCO,
CALL_TTY_HCO, CALL_TTY_FULL
};
enum mic_path {MAIN, SUB, BT_REC, MIC_OFF};
enum power_state {CODEC_OFF, CODEC_ON };
enum ringtone_state {RING_OFF, RING_ON};
enum input_source_state {DEFAULT, RECOGNITION, CAMCORDER, VOICE_COMMUNICATION};
typedef void (*select_route)(struct snd_soc_codec *);
typedef void (*select_mic_route)(struct snd_soc_codec *);
typedef int (*select_clock_control)(struct snd_soc_codec *, int);
struct wm8994_setup_data {
int i2c_bus;
unsigned short i2c_address;
};
enum wm8994_dc_servo_slots {
DCS_MEDIA = 0,
DCS_VOICE = 1,
DCS_SPK_HP = 2,
};
struct wm8994_priv {
struct snd_soc_codec *codec;
int master;
int sysclk_source;
unsigned int mclk_rate;
unsigned int sysclk_rate;
unsigned int fs;
unsigned int bclk;
unsigned int hw_version;
unsigned int codec_state;
unsigned int stream_state;
enum audio_path cur_path;
enum mic_path rec_path;
enum power_state power_state;
enum input_source_state input_source;
enum ringtone_state ringtone_active;
select_route *universal_playback_path;
select_route *universal_voicecall_path;
select_mic_route *universal_mic_path;
select_clock_control universal_clock_control;
struct wm8994_platform_data *pdata;
struct clk *codec_clk;
int gain_code;
u16 dc_servo[3];
};
struct gain_info_t {
int mode;
int reg;
int mask;
int gain;
};
#if AUDIO_COMMON_DEBUG
#define DEBUG_LOG(format, ...)\
printk(KERN_INFO "[ "SUBJECT " (%s,%d) ] " format "\n", \
__func__, __LINE__, ## __VA_ARGS__);
#else
#define DEBUG_LOG(format, ...)
#endif
#define DEBUG_LOG_ERR(format, ...)\
printk(KERN_ERR "[ "SUBJECT " (%s,%d) ] " format "\n", \
__func__, __LINE__, ## __VA_ARGS__);
/* Definitions of function prototype. */
unsigned int wm8994_read(struct snd_soc_codec *codec, unsigned int reg);
int wm8994_write(struct snd_soc_codec *codec,
unsigned int reg, unsigned int value);
int wm8994_configure_clock(struct snd_soc_codec *codec, int en);
void wm8994_disable_path(struct snd_soc_codec *codec);
void wm8994_disable_rec_path(struct snd_soc_codec *codec);
void wm8994_record_main_mic(struct snd_soc_codec *codec);
void wm8994_record_headset_mic(struct snd_soc_codec *codec);
void wm8994_record_bluetooth(struct snd_soc_codec *codec);
void wm8994_set_playback_receiver(struct snd_soc_codec *codec);
void wm8994_set_playback_headset(struct snd_soc_codec *codec);
void wm8994_set_playback_speaker(struct snd_soc_codec *codec);
void wm8994_set_playback_bluetooth(struct snd_soc_codec *codec);
void wm8994_set_playback_speaker_headset(struct snd_soc_codec *codec);
void wm8994_set_voicecall_common_setting(struct snd_soc_codec *codec);
void wm8994_set_voicecall_receiver(struct snd_soc_codec *codec);
void wm8994_set_voicecall_headset(struct snd_soc_codec *codec);
void wm8994_set_voicecall_headphone(struct snd_soc_codec *codec);
void wm8994_set_voicecall_speaker(struct snd_soc_codec *codec);
void wm8994_set_voicecall_bluetooth(struct snd_soc_codec *codec);
void wm8994_set_voicecall_tty_vco(struct snd_soc_codec *codec);
void wm8994_set_voicecall_tty_hco(struct snd_soc_codec *codec);
void wm8994_set_voicecall_tty_full(struct snd_soc_codec *codec);
int wm8994_set_codec_gain(struct snd_soc_codec *codec, u16 mode, u16 device);
extern int gain_code_check(void);
#endif
|