aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/max98090_mixer.c
blob: d721f69c174bd0a7e645c5cd31fb7d54acad1d60 (plain) (blame)
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
/*
 * max98090.c -- MAX98090 ALSA SoC Audio driver
 *
 * Copyright 2010 Maxim Integrated Products
 *
 * 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.
 */

#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <linux/delay.h>
#include <asm/io.h>
#include <asm/gpio.h>
#include <plat/gpio-cfg.h>
#include <plat/map-base.h>
#include <mach/regs-clock.h>

#include <sound/max98090.h>
#include "max98090.h"

//----------------------------------------------------------------------------------------
// audio gain parameter
//----------------------------------------------------------------------------------------
#define   TUNNING_DAI1_VOL    	0x00 // 0dB
#define   TUNNING_DAI1_RCV_VOL  0x00 // 0dB

#define   TUNNING_SPKMIX_VOL    0x00 // 0dB
#define   TUNNING_HPMIX_VOL     0x00 // 0dB

#define   TUNNING_RCV_VOL    	0x1F // +8dB
#define   TUNNING_SPK_VOL    	0x2C // 0dB
#define   TUNNING_HP_VOL     	0x1A // 0dB

#define 	MIC_PRE_AMP_GAIN	(3<<5) // +30dB
#define 	MIC_PGA_GAIN		(0x00) // +20dB
#define   	TUNNING_MIC_PGA_GAIN    0x40

#define   	TUNNING_MIC_BIAS_VOL    0x00	// 2.2V

#define 	MIC_ADC_GAIN		(3<<4) // +18dB
#define 	MIC_ADC_VOLUME		(0x03) // 0dB
#define   	TUNNING_ADC_GAIN    0x30

//----------------------------------------------------------------------------------------
// playback function
//----------------------------------------------------------------------------------------
void max98090_set_playback_speaker(struct snd_soc_codec *codec)
{
	printk("\t[MAX98090] %s(%d)\n",__FUNCTION__,__LINE__);
	return;
}

//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
void max98090_set_playback_headset(struct snd_soc_codec *codec)
{
	printk("\t[MAX98090] %s(%d)\n",__FUNCTION__,__LINE__);
	return;
}

//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
void max98090_set_playback_earpiece(struct snd_soc_codec *codec)
{

	printk("\t[MAX98090] %s(%d)\n",__FUNCTION__,__LINE__);
	return;
}

//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
void max98090_set_playback_speaker_headset(struct snd_soc_codec *codec)
{
	int reg;
	
	// 0x92 Power DAC L/R, SPLEN
	reg = snd_soc_read(codec, M98090_03F_OUTPUT_ENABLE);
	reg &= ~(M98090_DAREN|M98090_DALEN|M98090_RCVREN|M98090_RCVLEN|M98090_SPREN|M98090_SPLEN|M98090_HPREN|M98090_HPLEN);
	reg |= (M98090_DAREN|M98090_DALEN|M98090_HPREN|M98090_HPLEN);
	snd_soc_write(codec, M98090_03F_OUTPUT_ENABLE, reg);

//	// Stereo DAC to SPK_L, SPK_R Mute
//	reg = M98090_DACL_TO_SPKL;
//	snd_soc_write(codec, M98090_02E_MIX_SPK_L, reg);
//	reg = M98090_DACR_TO_SPKR;
//	snd_soc_write(codec, M98090_02F_MIX_SPK_R, reg);

	// DAC L/R to HP L/R
	reg = M98090_DACL_TO_HPL;
	snd_soc_write(codec, M98090_029_MIX_HP_L, reg);
	reg = M98090_DACR_TO_HPR;
	snd_soc_write(codec, M98090_02A_MIX_HP_R, reg);

//	reg = TUNNING_SPK_VOL;
//	snd_soc_write(codec, M98090_031_SPK_L_VOL, reg);
//	snd_soc_write(codec, M98090_032_SPK_R_VOL, reg);
//
//	reg = TUNNING_SPKMIX_VOL;
//	snd_soc_write(codec, M98090_030_MIX_SPK_CNTL, reg);

	// HPMIX L/R to HP_AMP L/R
//	reg = M98090_HPNORMAL;
	reg = TUNNING_HPMIX_VOL;
	snd_soc_write(codec, M98090_02B_MIX_HP_CNTL, reg);

	reg = TUNNING_HP_VOL;
	snd_soc_write(codec, M98090_02C_HP_L_VOL, reg);
	snd_soc_write(codec, M98090_02D_HP_R_VOL, reg);

	printk("\t[MAX98090] %s(%d)\n",__FUNCTION__,__LINE__);
	return;
}

//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
void max98090_disable_playback_path(struct snd_soc_codec *codec, enum playback_path path)
{

	return;
}

//----------------------------------------------------------------------------------------
// recording function
//----------------------------------------------------------------------------------------
void max98090_set_record_main_mic(struct snd_soc_codec *codec)
{
	int reg;

	// 0x4C Mic bias, ADC L enable
	reg = snd_soc_read(codec, M98090_03E_IPUT_ENABLE);
	reg &= ~(M98090_ADLEN | M98090_ADREN | M98090_MBEN | M98090_LINEAEN | M98090_LINEBEN);
	reg |= (M98090_ADLEN | M98090_ADREN | M98090_MBEN);
	snd_soc_write(codec, M98090_03E_IPUT_ENABLE, reg);

	reg = TUNNING_MIC_BIAS_VOL;
	snd_soc_write(codec, M98090_012_MIC_BIAS_VOL, reg);

	reg = M98090_MIC1_TO_ADCL; // MIC2 to ADC L/R Mixer
	snd_soc_write(codec, M98090_015_MIX_ADC_L, reg);
	snd_soc_write(codec, M98090_016_MIX_ADC_R, reg);

	reg = TUNNING_MIC_PGA_GAIN;
	snd_soc_write(codec, M98090_010_MIC1_LVL, reg);

	reg = TUNNING_ADC_GAIN;
	snd_soc_write(codec, M98090_017_ADC_L_LVL, reg);
	snd_soc_write(codec, M98090_018_ADC_R_LVL, reg);

	printk("\t[MAX98090] %s(%d)\n",__FUNCTION__,__LINE__);
	return;
}

//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
void max98090_set_record_headset_mic(struct snd_soc_codec *codec)
{
	printk("\t[MAX98090] %s(%d)\n",__FUNCTION__,__LINE__);
	return;
}

//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
void max98090_disable_record_path(struct snd_soc_codec *codec, enum record_path rec_path)
{
	printk("\t[MAX98090] %s(%d)\n",__FUNCTION__,__LINE__);
	return;	
}