[Feature][ZXW-33]merge ZXW 0428 version

Change-Id: I11f167edfea428d9fab198ff00ff1364932d1b0b
diff --git a/ap/lib/libtinyalsa/audio_mixer_ctrl.c b/ap/lib/libtinyalsa/audio_mixer_ctrl.c
index 68448ab..c4ffb76 100755
--- a/ap/lib/libtinyalsa/audio_mixer_ctrl.c
+++ b/ap/lib/libtinyalsa/audio_mixer_ctrl.c
@@ -930,6 +930,143 @@
 	}
 }
 
+#elif defined _ALSA_CODEC_IN_CAP
+
+static struct audio_para_conf init_default_para[] = { 
+};
+
+static struct audio_para_conf  common_out_para_audio[] = {  
+
+};
+
+
+
+static struct audio_para_conf  common_in_para_audio[] = { 
+};
+
+static struct audio_para_conf  hp_outpath_para_audio[] = { 
+};
+
+
+static struct audio_para_conf  spk_outpath_para_audio[] = {  
+};
+
+static  struct  audio_para_conf  main_mic_inpath_para_audio[] = { 
+};
+
+static  struct  audio_para_conf  aux_mic_inpath_para_audio[] = {
+};
+
+static struct audio_para_conf  handset_inoutpath_para_voice[] = { 
+	{"voice processing path select", {"handset"}},  // handset speak headset bluetooth	
+};
+
+static struct audio_para_conf  headset_inoutpath_para_voice[] = { 
+	{"voice processing path select", {"headset"}},  // handset speak headset bluetooth	
+};
+
+static struct audio_para_conf  spk_inoutpath_para_voice[] = {
+	{"voice processing path select", {"speak"}},  // handset speak headset bluetooth	
+};
+
+static struct audio_para_conf output_dac_vol = 	{};
+
+static struct audio_para_conf input_adc_vol = {};
+
+static struct audio_para_conf dac_mute = {};
+static struct audio_para_conf adc_mute = {};
+
+static struct audio_para_conf spk_path_onoff[] = {
+	
+};
+static struct audio_para_conf rcv_path_onoff[] = {
+
+};
+static struct audio_para_conf earp_path_onoff[] = {
+
+};
+static int output_vol_conversion(int vol)
+{
+
+	return 24;
+}
+
+static int input_vol_conversion(int vol)
+{
+	
+	return 24;
+
+}
+
+#else 
+
+static struct audio_para_conf init_default_para[] = { 
+};
+
+static struct audio_para_conf  common_out_para_audio[] = {  
+
+};
+
+
+
+static struct audio_para_conf  common_in_para_audio[] = { 
+};
+
+static struct audio_para_conf  hp_outpath_para_audio[] = { 
+};
+
+
+static struct audio_para_conf  spk_outpath_para_audio[] = {  
+};
+
+static  struct  audio_para_conf  main_mic_inpath_para_audio[] = { 
+};
+
+static  struct  audio_para_conf  aux_mic_inpath_para_audio[] = {
+};
+
+static struct audio_para_conf  handset_inoutpath_para_voice[] = { 
+	
+};
+
+static struct audio_para_conf  headset_inoutpath_para_voice[] = { 
+};
+
+static struct audio_para_conf  spk_inoutpath_para_voice[] = {
+};
+
+static struct audio_para_conf output_dac_vol = 	{};
+
+static struct audio_para_conf input_adc_vol = {};
+
+static struct audio_para_conf dac_mute = {};
+static struct audio_para_conf adc_mute = {};
+
+static struct audio_para_conf spk_path_onoff[] = {
+	
+};
+static struct audio_para_conf rcv_path_onoff[] = {
+
+};
+static struct audio_para_conf earp_path_onoff[] = {
+
+};
+static int output_vol_conversion(int vol)
+{
+
+	return 24;
+}
+
+static int input_vol_conversion(int vol)
+{
+	
+	return 24;
+
+}
+
+
+
+
 #endif
 
 //static struct audio_para_conf nxp_voice_vol = 	{"voice processing path Volume",{"3"}}; //(range 0->5)
@@ -947,7 +1084,7 @@
 		ctl = mixer_get_ctl_by_name(mixer, control);
 
 	if (!ctl) {
-		fprintf(stderr, "Invalid mixer control\n");
+		fprintf(stderr, "Invalid mixer control(%s)\n",control);
 		return;
 	}
 
@@ -977,6 +1114,38 @@
 	}
 }
 
+static void mix_get_value_wrap(struct mixer *mixer, const char *control, int *values)
+{
+	struct mixer_ctl *ctl;
+	enum mixer_ctl_type type;
+	unsigned int num_ctl_values;
+	unsigned int i;
+	int val;
+
+	if (isdigit(control[0]))
+		ctl = mixer_get_ctl(mixer, atoi(control));
+	else
+		ctl = mixer_get_ctl_by_name(mixer, control);
+
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control(%s)\n",control);
+		return;
+	}
+
+	type = mixer_ctl_get_type(ctl);
+	num_ctl_values = mixer_ctl_get_num_values(ctl);
+
+
+	for (i = 0; i < num_ctl_values; i++) {
+		val = mixer_ctl_get_value(ctl, i);
+		if (val == -EINVAL) {
+			fprintf(stderr, "Error: invalid value for index %d\n", i);
+			return;
+		}
+		*(values+i) = val;
+	}
+
+}
 #ifdef _CPE_AUDIO_PRJ
 int mix_set_output_path(struct mixer *mixer, int path)
 {
@@ -1032,6 +1201,26 @@
 
 	return 0;
 }
+int mix_get_voice_vol(struct mixer *mixer, int *volume)
+{
+
+	return 0;
+}
+
+
+
+int mix_set_tx_voice_vol(struct mixer *mixer, int volume)
+{
+
+	return 0;
+}
+
+int mix_get_tx_voice_vol(struct mixer *mixer, int *volume)
+{
+
+	return 0;
+}
+
 
 int mix_set_voice_mute(struct mixer *mixer, bool enable)
 {
@@ -1040,6 +1229,41 @@
 	return 0;
 }
 
+int mix_get_voice_mute(struct mixer *mixer, bool *enable)
+{
+
+	return 0;
+}
+
+
+int mix_set_rx_voice_mute(struct mixer *mixer, bool enable)
+{
+
+	
+	return 0;
+}
+
+int mix_get_rx_voice_mute(struct mixer *mixer, bool *enable)
+{
+
+	return 0;
+}
+
+
+
+int mix_set_vp_path(struct mixer *mixer, int path)
+{
+
+	return 0;
+}
+
+int mix_get_vp_path(struct mixer *mixer, int *path)
+{
+
+	return 0;
+}
+
+
 int mix_set_voice_path(struct mixer *mixer, int path)
 {
 	int i;
@@ -1061,6 +1285,10 @@
 
 	return 0;
 }
+int set_voice_device_mode(int dev_mode)
+{
+		return 0;
+}
 #else
 int mix_set_output_path(struct mixer *mixer, int path)
 {
@@ -1249,6 +1477,66 @@
 	return 0;
 }
 
+int mix_get_voice_vol(struct mixer *mixer, int *volume)
+{
+	struct mixer_ctl *ctl;
+	int val;
+	
+	printf("%s: start !\n",__func__);
+	char name[] = "voice processing path Volume";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+
+	val = mixer_ctl_get_value(ctl, 0);
+	if((val < 0)||(val > 11)){
+		fprintf(stderr, "Invalid val=%d\n",val);
+		return -2;		
+	}
+	*volume = val;
+	return 0;
+}
+
+int mix_set_tx_voice_vol(struct mixer *mixer, int volume)
+{
+	struct mixer_ctl *ctl;
+	char name[] = "voice processing tx path Volume";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+
+	mixer_ctl_set_value(ctl, 0, volume);
+
+	return 0;
+}
+
+int mix_get_tx_voice_vol(struct mixer *mixer, int *volume)
+{
+	struct mixer_ctl *ctl;
+	int val;
+	
+	printf("%s: start !\n",__func__);
+	char name[] = "voice processing tx path Volume";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+
+	val = mixer_ctl_get_value(ctl, 0);
+	if((val < 0)||(val > 11)){
+		fprintf(stderr, "Invalid val=%d\n",val);
+		return -2;		
+	}
+	*volume = val;
+	return 0;
+}
+
+
 int mix_set_voice_mute(struct mixer *mixer, bool enable)
 {
 	struct mixer_ctl *ctl;
@@ -1264,6 +1552,182 @@
 	return 0;
 }
 
+int mix_get_voice_mute(struct mixer *mixer, bool *enable)
+{
+	struct mixer_ctl *ctl;
+	int val;
+	
+	printf("%s: start !\n",__func__);
+	char name[] = "voice uplink mute";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+
+	val = mixer_ctl_get_value(ctl, 0);
+	if((val != 0)&&(val != 1)){
+		fprintf(stderr, "Invalid val=%d\n",val);
+		return -2;		
+	}
+	*enable = val;
+	return 0;
+}
+
+
+int mix_set_rx_voice_mute(struct mixer *mixer, bool enable)
+{
+	struct mixer_ctl *ctl;
+	char name[] = "voice downlink mute";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+
+	mixer_ctl_set_value(ctl, 0, enable);
+	
+	return 0;
+}
+
+int mix_get_rx_voice_mute(struct mixer *mixer, bool *enable)
+{
+	struct mixer_ctl *ctl;
+	int val;
+	
+	printf("%s: start !\n",__func__);
+	char name[] = "voice downlink mute";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+
+	val = mixer_ctl_get_value(ctl, 0);
+	if((val != 0)&&(val != 1)){
+		fprintf(stderr, "Invalid val=%d\n",val);
+		return -2;		
+	}
+	*enable = val;
+	return 0;
+}
+
+int mix_set_vp_path(struct mixer *mixer, int path)
+{
+    int ret = 0;
+	unsigned int  num_enums;
+	struct mixer_ctl *ctl;
+	char name[] = "voice processing path select";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+    num_enums = mixer_ctl_get_num_enums(ctl);
+
+	if((path < 0)||(path >= num_enums)){
+		fprintf(stderr, "Invalid val=%d\n",path);
+		return -2;		
+	}
+	ret = mixer_ctl_set_value(ctl, 0, path);
+
+	if (ret){
+		fprintf(stderr, "Error: set value,ret=%d\n",ret);	
+		return -2;	
+	}
+	return 0;
+}
+
+
+
+
+int mix_get_vp_path(struct mixer *mixer, int *path)
+{
+	struct mixer_ctl *ctl;
+	int val;
+    unsigned int num_enums;
+	
+	printf("%s: start !\n",__func__);
+	char name[] = "voice processing path select";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+
+    num_enums = mixer_ctl_get_num_enums(ctl);
+
+
+	val = mixer_ctl_get_value(ctl, 0);
+	if((val < 0)||(val >= num_enums)){
+		fprintf(stderr, "Invalid val=%d\n",val);
+		return -2;		
+	}
+	printf("%s: val=%d !\n",__func__,val);
+	*path = val;
+	return 0;
+}
+
+
+
+int mix_set_vp_path_st(struct mixer *mixer, char *path)
+{
+	struct mixer_ctl *ctl;
+	char name[] = "voice processing path select";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+
+	//mixer_ctl_set_value(ctl, 0, path);
+	if (mixer_ctl_set_enum_by_string(ctl, path))
+		fprintf(stderr, "Error: invalid enum value\n");	
+	return 0;
+}
+
+
+
+
+int mix_get_vp_path_st(struct mixer *mixer, int *path)
+{
+	struct mixer_ctl *ctl;
+	int val;
+    unsigned int num_enums;
+    unsigned int i;
+    const char *string;
+	
+	printf("%s: start !\n",__func__);
+	char name[] = "voice processing path select";
+	ctl = mixer_get_ctl_by_name(mixer, name);
+	if (!ctl) {
+		fprintf(stderr, "Invalid mixer control\n");
+		return -1;
+	}
+
+    num_enums = mixer_ctl_get_num_enums(ctl);
+
+
+	val = mixer_ctl_get_value(ctl, 0);
+	if((val < 0)||(val >= num_enums)){
+		fprintf(stderr, "Invalid val=%d\n",val);
+		return -2;		
+	}
+	printf("%s: val=%d !\n",__func__,val);
+	
+    string = mixer_ctl_get_enum_string(ctl, val);	
+
+	if(string == NULL){
+		fprintf(stderr, "Invalid string=%d\n",string);
+		return -2;		
+	}
+	printf("%s: string=%s !\n",__func__,string);
+	path = string;
+	return 0;
+}
+
+
+
 int mix_set_voice_path(struct mixer *mixer, int path)
 {
 	int i;
@@ -1324,4 +1788,51 @@
 	
 	return 0;
 }
+
+int mix_get_voice_path(struct mixer *mixer, int *path)
+{
+
+	mix_get_value_wrap(mixer, "audio path select", path);
+
+	return 0;
+
+}
+#define VOCIE_SND_CARD_NUM 0
+
+
+
+//ÉèÖÃvoiceÒôƵÉ豸ģʽ	dev_mode£ºhandset,speaker,headset	0 ±íʾ³É¹¦£¬ ÆäËü±íʾÓдíÎó
+int set_voice_device_mode(int dev_mode)
+{
+
+	struct mixer *voice_mixer = NULL;
+	printf("%s: start dev_mode=%d!\n",__func__, dev_mode);
+
+	if ((dev_mode < T_OUTPUT_HANDSET ) ||(dev_mode > T_OUTPUT_HEADSET)){
+		printf("%s: dev_mode not support, dev_mode=%d!\n",__func__, dev_mode);
+		return -1;
+	}
+
+	//open mixer dev for  control
+	voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
+	if (!voice_mixer) {
+		printf("voice_mixer open failed!\n");
+		return -1;
+	}
+
+	//config mixer dev
+	mix_set_voice_path(voice_mixer, dev_mode);
+
+	//close mixer
+	mixer_close(voice_mixer);
+	voice_mixer = NULL;
+
+
+	return 0;
+	
+	
+}
+
+
+
 #endif