4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __AVSYS_AUDIO_PATH_H__
23 #define __AVSYS_AUDIO_PATH_H__
25 #include "avsys-audio.h"
26 #include "avsys-audio-handle.h"
28 #include <sys/types.h>
32 AVSYS_AUDIO_INSERTED_NONE = 0,
33 AVSYS_AUDIO_INSERTED_3,
34 AVSYS_AUDIO_INSERTED_4,
35 AVSYS_AUDIO_INSERTED_AV
38 enum avsys_audio_playback_gain{
39 AVSYS_AUDIO_PLAYBACK_GAIN_AP = 0,
40 AVSYS_AUDIO_PLAYBACK_GAIN_FMRADIO,
41 AVSYS_AUDIO_PLAYBACK_GAIN_VOICECALL,
42 AVSYS_AUDIO_PLAYBACK_GAIN_VIDEOCALL,
43 AVSYS_AUDIO_PLAYBACK_GAIN_CALLALERT,
44 AVSYS_AUDIO_PLAYBACK_GAIN_MAX
47 enum avsys_audio_capture_gain{
48 AVSYS_AUDIO_CAPTURE_GAIN_AP = 0,
49 AVSYS_AUDIO_CAPTURE_GAIN_FMRADIO,
50 AVSYS_AUDIO_CAPTURE_GAIN_VOICECALL,
51 AVSYS_AUDIO_CAPTURE_GAIN_VIDEOCALL,
52 AVSYS_AUDIO_CAPTURE_GAIN_MAX
55 enum avsys_audio_ear_ctrl {
56 AVSYS_AUDIO_EAR_SWITCH_MANUAL,
57 AVSYS_AUDIO_EAR_SWITCH_AUTO_WITH_MUTE,
58 AVSYS_AUDIO_EAR_SWITCH_AUTO_WITHOUT_MUTE,
61 struct avsys_audio_jack_event {
68 #define PATH_MASK_MAX 23
69 #define GAIN_MASK_MAX 30
70 /* sound path status bit */
71 #define PS_PATH_NONE (0)
72 #define PS_AP_TO_SPK (1 << 0)
73 #define PS_AP_TO_HEADSET (1 << 1)
74 #define PS_AP_TO_RECV (1 << 2)
75 #define PS_AP_TO_HDMI (1 << 3)
76 #define PS_AP_TO_BT (1 << 4)
77 #define PS_AP_TO_MODEM (1 << 5)
78 #define PS_MODEM_TO_SPK (1 << 6)
79 #define PS_MODEM_TO_HEADSET (1 << 7)
80 #define PS_MODEM_TO_RECV (1 << 8)
81 #define PS_MODEM_TO_BT (1 << 9)
82 #define PS_MODEM_TO_AP (1 << 10)
83 #define PS_FMRADIO_TO_SPK (1 << 11)
84 #define PS_FMRADIO_TO_HEADSET (1 << 12)
85 #define PS_MAINMIC_TO_AP (1 << 13)
86 #define PS_MAINMIC_TO_MODEM (1 << 14)
87 #define PS_SUBMIC_TO_AP (1 << 15)
88 #define PS_SUBMIC_TO_MODEM (1 << 16)
89 #define PS_STEREOMIC_TO_AP (1 << 17)
90 #define PS_EARMIC_TO_AP (1 << 18)
91 #define PS_EARMIC_TO_MODEM (1 << 19)
92 #define PS_BTMIC_TO_AP (1 << 20)
93 #define PS_BTMIC_TO_MODEM (1 << 21)
94 #define PS_FMRADIO_TO_AP (1 << 22)
95 #define PS_CODEC_DISABLE_ON_SUSPEND (1 << 23)
96 #define PS_CP_TO_AP (1 << PATH_MASK_MAX)
99 /* hw gain status enum */
100 #define GS_GAIN_NONE (0)
101 #define GS_AP_TO_SPK (1 << 0)
102 #define GS_AP_TO_SPK_CALLALERT (1 << 1)
103 #define GS_AP_TO_HEADSET (1 << 2)
104 #define GS_AP_TO_HEADSET_CALLALERT (1 << 3)
105 #define GS_AP_TO_RECV (1 << 4)
106 #define GS_AP_TO_HDMI (1 << 5)
107 #define GS_AP_TO_BT (1 << 6)
108 #define GS_AP_TO_MODEM (1 << 7)
109 #define GS_MODEM_TO_SPK_VOICE (1 << 8)
110 #define GS_MODEM_TO_HEADSET_VOICE (1 << 9)
111 #define GS_MODEM_TO_RECV_VOICE (1 << 10)
112 #define GS_MODEM_TO_BT_VOICE (1 << 11)
113 #define GS_MODEM_TO_AP_VOICE (1 << 12)
114 #define GS_MODEM_TO_SPK_VIDEO (1 << 13)
115 #define GS_MODEM_TO_HEADSET_VIDEO (1 << 14)
116 #define GS_MODEM_TO_RECV_VIDEO (1 << 15)
117 #define GS_MODEM_TO_BT_VIDEO (1 << 16)
118 #define GS_MODEM_TO_AP_VIDEO (1 << 17)
119 #define GS_FMRADIO_TO_SPK (1 << 18)
120 #define GS_FMRADIO_TO_HEADSET (1 << 19)
121 #define GS_MAINMIC_TO_AP (1 << 20)
122 #define GS_MAINMIC_TO_MODEM_VOICE (1 << 21)
123 #define GS_SUBMIC_TO_AP (1 << 22)
124 #define GS_SUBMIC_TO_MODEM_VOICE (1 << 23)
125 #define GS_STEREOMIC_TO_AP (1 << 24)
126 #define GS_EARMIC_TO_AP (1 << 25)
127 #define GS_EARMIC_TO_MODEM_VOICE (1 << 26)
128 #define GS_BTMIC_TO_AP (1 << 27)
129 #define GS_BTMIC_TO_MODEM_VOICE (1 << 28)
130 #define GS_FMRADIO_TO_AP (1 << 29)
131 #define GS_CP_TO_AP (1 << GAIN_MASK_MAX)
133 #define TYPE_EVENT_SWITCH 0x05
134 #define CODE_HEADPHONE_INSERT 0x02
135 #define CODE_MICROPHONE_INSERT 0x04
136 #define CODE_LINEOUT_INSERT 0x06
137 #define CODE_JACK_PHYSICAL_INSERT 0x07
139 #define PATH_FIXED_NONE (0x00000000)
140 #define PATH_FIXED_WITH_FMRADIO (1 << PATH_FIXED_TYPE_FMRADIO) /* 0x00000001 */
141 #define PATH_FIXED_WITH_CALL (1 << PATH_FIXED_TYPE_CALL) /* 0x00000002 */
143 enum avsys_audio_amp_t {
144 AVSYS_AUDIO_AMP_OFF = 0, /**< AMP OFF in pda out */
145 AVSYS_AUDIO_AMP_ON, /**< AMP ON in pda out */
146 AVSYS_AUDIO_AMP_OFF_ALL,
149 enum path_fixed_type_t {
150 PATH_FIXED_TYPE_FMRADIO = 0,
151 PATH_FIXED_TYPE_CALL,
155 struct audio_route_info_t {
160 typedef struct audio_route_info_t gain_info_t;
161 typedef struct audio_route_info_t path_info_t;
162 typedef struct audio_route_info_t option_info_t;
163 typedef struct audio_route_info_t gain_status_t;
164 typedef struct audio_route_info_t path_status_t;
170 gain_info_t backup_gain;
171 path_info_t backup_path;
176 option_info_t option;
178 /* path fixed information */
180 pid_t path_fixed_pid[PATH_FIXED_TYPE_MAX];
185 /* For earphone control */
189 /* for alsa scenario, aquila */
190 gain_status_t gain_status;
191 path_status_t path_status;
193 gain_status_t p_gain_status;
194 path_status_t p_path_status;
199 /* For Lock debugging */
200 pid_t pathlock_pid[AVSYS_AUDIO_LOCK_SLOT_MAX];
202 /* system route policy */
203 avsys_audio_route_policy_t route_policy;
206 } avsys_audio_path_ex_info_t;
208 int avsys_audio_path_ex_init(void);
209 int avsys_audio_path_ex_fini(void);
210 int avsys_audio_path_ex_reset(int forced);
211 int avsys_audio_path_ex_dump(void);
212 int avsys_audio_path_ex_set_path(int gain, int out, int in, int option);
213 int avsys_audio_path_ex_get_path(int *gain, int *out, int *in, int *option);
214 int avsys_audio_path_manage_earjack(void);
215 int avsys_audio_path_ex_set_amp(const int onoff);
216 int avsys_audio_path_ex_set_mute(const int mute);
217 int avsys_audio_path_ex_get_mute(int *mute);
218 int avsys_audio_path_set_volume(int handle);
220 int avsys_audio_path_earjack_init(int *init_type, int *outfd);
221 int avsys_audio_path_earjack_wait(int fd, int *current_type, int *new_type, int *is_auto_mute);
222 int avsys_audio_path_earjack_process(int new_type);
223 int avsys_audio_path_earjack_deinit(int fd);
224 int avsys_audio_path_earjack_unlock(void);
226 int avsys_audio_path_set_route_policy(avsys_audio_route_policy_t route);
227 int avsys_audio_path_get_route_policy(avsys_audio_route_policy_t *route);
228 int avsys_audio_path_check_loud(bool *loud);
229 int avsys_audio_path_check_cp_audio(bool *cpaudio, bool *btpath);
230 int avsys_audio_path_set_single_ascn(char *str);
232 #endif /* __AVSYS_AUDIO_PATH_H__ */