Merge "[Feature][T106]version update to T106-V2.01.01.02P56U03.AP.13.01_CAP.13.01"
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
index d441a1a..b4124b6 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
@@ -486,17 +486,19 @@
 				status = "disabled";
 			};	
 			codec_ti3104: ti3104@18 {         
+				//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound start
 				compatible = "ti,tlv320aic3104";
-				reg = <0x18>;		
-				reset-gpios = <&bgpio 122 GPIO_ACTIVE_HIGH>;/*RST*/
+				reg = <0x18>;
+				//reset-gpios = <&bgpio 122 GPIO_ACTIVE_HIGH>;/*RST*/
 				ai3x-micbias-vg = <MICBIAS_2_0V>;
 
-				clocks = <&clkc CLKOUT1_CLK>;
-				clock-names = "clk_out";			
-				pinctrl-names = "clk_out","reset_gpio122";			
-				pinctrl-0 = <&clk1_func_pins>;
+				clocks = <&clkc CLKOUT2_CLK>;
+				clock-names = "clk_out";
+				pinctrl-names = "clk_out","reset_gpio122";
+				pinctrl-0 = <&clk2_func_pins>;
 				pinctrl-1 = <&codec_reset_pins>;
 				status = "disabled";
+				//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound end
 			};
 			codec_max9867: max9867@18 {         
 				compatible = "maxim,max9867";
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c
index 1bc3004..899ab9c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c
@@ -1044,73 +1044,8 @@
 

 static int es8311_resume(struct snd_soc_component *component)

 {

-	struct es8311_private *es8311 = snd_soc_component_get_drvdata(component);

-

 	printk("Enter into %s()\n", __func__);

-	snd_soc_component_write(component, ES8311_GP_REG45, 0x00);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x30);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x00);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x10);

-	snd_soc_component_write(component, ES8311_ADC_REG16, 0x24);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x10);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00);

-	snd_soc_component_write(component, ES8311_SDPIN_REG09, 0x00);

-	snd_soc_component_write(component, ES8311_SDPOUT_REG0A, 0x00);

-	snd_soc_component_write(component, ES8311_SYSTEM_REG0B, 0x00);

-	snd_soc_component_write(component, ES8311_SYSTEM_REG0C, 0x00);

-

-	if (ES8311_AVDD == ES8311_1V8) {

-		snd_soc_component_write(component, ES8311_SYSTEM_REG10, 0x61);

-		snd_soc_component_write(component, ES8311_SYSTEM_REG11, 0x7B);

-	} else {

-		snd_soc_component_write(component, ES8311_SYSTEM_REG10, 0x03);

-		snd_soc_component_write(component, ES8311_SYSTEM_REG11, 0x57);

-	}

-	if (es8311->mclk_src == ES8311_MCLK_PIN) {

-		snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x3F);

-		snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0xBF);

-	}

-	if (es8311->mastermode == 1)

-		snd_soc_component_write(component, ES8311_RESET_REG00, 0xC0);

-	else

-		snd_soc_component_write(component, ES8311_RESET_REG00, 0x80);

-

-	usleep_range(1500, 3000);

-	snd_soc_component_write(component, ES8311_SYSTEM_REG0D, 0x01);

-

-	if (es8311->mclkinv == true) {

-		snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG01,

-				0x40, 0x40);

-	} else {

-		snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG01,

-				0x40, 0x00);

-	}

-	if (es8311->sclkinv == true) {

-		snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG06,

-				0x20, 0x20);

-	} else {

-		snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG06,

-				0x20, 0x00);

-	}

-	snd_soc_component_write(component, ES8311_SYSTEM_REG14, 0x1A);

-	if (es8311->dmic_enable == true) {

-		snd_soc_component_update_bits(component, ES8311_SYSTEM_REG14,

-				0x40, 0x40);

-	} else {

-		snd_soc_component_update_bits(component, ES8311_SYSTEM_REG14,

-				0x40, 0x00);

-	}

-	snd_soc_component_write(component, ES8311_SYSTEM_REG12, 0x00);

-	snd_soc_component_write(component, ES8311_SYSTEM_REG13, 0x10);

-	snd_soc_component_write(component, ES8311_SYSTEM_REG0E, 0x02);

-	snd_soc_component_write(component, ES8311_SYSTEM_REG0F, 0x7F);

-	snd_soc_component_write(component, ES8311_ADC_REG15, 0x40);

-	snd_soc_component_write(component, ES8311_ADC_REG1B, 0x0A);

-	snd_soc_component_write(component, ES8311_ADC_REG1C, 0x6A);

-	snd_soc_component_write(component, ES8311_DAC_REG37, 0x48);

-	snd_soc_component_write(component, ES8311_ADC_REG17, 0xBF);

-	snd_soc_component_write(component, ES8311_DAC_REG32, 0xBF);

-

+	//yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment
 	return 0;

 }

 

@@ -1251,19 +1186,9 @@
 

 	unsigned tmp;

 	printk("Enter into %s()\n", __func__);

-

-

-	#if 1

-	 void __iomem 	*reg_base;

-     reg_base = ioremap(0x13B000+0x94 ,4);

-     tmp  = ioread32(reg_base);

-     tmp |= (1<<0)|(1<<2);

-	 iowrite32(tmp,reg_base);

-	 

-	

-	#endif

-

-

+
+	//yu.dong@20240416[T106BUG-551][codec] codec 8311 sleep power consumption does not go down
+
 	dev_info(dev, "%s:start!\n", __func__);

 

 	if(dev == NULL){

@@ -1357,6 +1282,91 @@
 			

 }

 

+//yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment start
+static void es8311_reinit(struct snd_soc_component *component, struct es8311_private *es8311)
+{
+    pr_info("%s:begin!\n", __func__);
+
+    snd_soc_component_write(component, ES8311_GP_REG45, 0x00);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x30);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x00);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x10);
+    //snd_soc_component_write(component, ES8311_ADC_REG16, 0x24);
+    snd_soc_component_write(component, ES8311_ADC_REG16, 0x21);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x10);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00);
+    snd_soc_component_write(component, ES8311_SDPIN_REG09, 0x00);
+    snd_soc_component_write(component, ES8311_SDPOUT_REG0A, 0x00);
+    snd_soc_component_write(component, ES8311_SYSTEM_REG0B, 0x00);
+    snd_soc_component_write(component, ES8311_SYSTEM_REG0C, 0x00);
+
+    if (ES8311_AVDD == ES8311_1V8) {
+        snd_soc_component_write(component, ES8311_SYSTEM_REG10, 0x61);
+        snd_soc_component_write(component, ES8311_SYSTEM_REG11, 0x7B);
+    } else {
+        snd_soc_component_write(component, ES8311_SYSTEM_REG10, 0x03);
+        snd_soc_component_write(component, ES8311_SYSTEM_REG11, 0x57);
+    }
+
+    if (es8311->mclk_src == ES8311_MCLK_PIN) {
+        snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x3F);
+    } else {
+        snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0xBF);
+    }
+
+    if (es8311->mastermode == 1) {
+        snd_soc_component_write(component, ES8311_RESET_REG00, 0xC0);
+    } else {
+        snd_soc_component_write(component, ES8311_RESET_REG00, 0x80);
+    }
+
+    usleep_range(1500, 3000);
+    snd_soc_component_write(component, ES8311_SYSTEM_REG0D, 0x01);
+
+    if (es8311->mclkinv == true) {
+        snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG01, 0x40, 0x40);
+    } else {
+        snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG01, 0x40, 0x00);
+    }
+
+    if (es8311->sclkinv == true) {
+        snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG06, 0x20, 0x20);
+    } else {
+        snd_soc_component_update_bits(component, ES8311_CLK_MANAGER_REG06, 0x20, 0x00);
+    }
+
+    snd_soc_component_write(component, ES8311_SYSTEM_REG14, 0x1A);
+
+    if (es8311->dmic_enable == true) {
+        snd_soc_component_update_bits(component, ES8311_SYSTEM_REG14, 0x40, 0x40);
+    } else {
+        snd_soc_component_update_bits(component, ES8311_SYSTEM_REG14, 0x40, 0x00);
+    }
+
+    snd_soc_component_write(component, ES8311_SYSTEM_REG12, 0x00);
+    snd_soc_component_write(component, ES8311_SYSTEM_REG13, 0x10);
+    snd_soc_component_write(component, ES8311_SYSTEM_REG0E, 0x02);
+    snd_soc_component_write(component, ES8311_SYSTEM_REG0F, 0x7F);
+    snd_soc_component_write(component, ES8311_ADC_REG15, 0x40);
+    snd_soc_component_write(component, ES8311_ADC_REG1B, 0x0A);
+    snd_soc_component_write(component, ES8311_ADC_REG1C, 0x6A);
+    snd_soc_component_write(component, ES8311_DAC_REG37, 0x48);
+    snd_soc_component_write(component, ES8311_ADC_REG17, 0xBF);
+    snd_soc_component_write(component, ES8311_DAC_REG32, 0xBF);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x98);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1b);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1b);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0xbb);
+
+    msleep(100);
+    es8311_set_bias_level(component, SND_SOC_BIAS_STANDBY);
+
+    pr_info("%s:end!\n", __func__);
+}
+
+extern int zx29_i2s_config_sleep_pin(void);
+extern int zx29_i2s_config_default_pin(void);
+
 static int component_open(struct snd_soc_component *component,

 	struct snd_pcm_substream *substream)

 {

@@ -1373,6 +1383,12 @@
 		}

 	}

 	

+	ret = zx29_i2s_config_default_pin();
+	if(ret < 0) {
+		pr_err("%s select state failure %d !! \n", __func__, ret);
+	}
+	es8311_reinit(component, info);
+
 	pr_info("%s:clk en end!\n",__func__);

 

 	return ret;

@@ -1396,13 +1412,19 @@
 

 	}

 	pr_info("%s:clk dis end!\n",__func__);

-

+
+	ret = zx29_i2s_config_sleep_pin();
+        if(ret < 0) {
+                pr_err("%s select state failure %d !! \n", __func__, ret);
+        }
+
 	return ret;

 

 

 	

 

 }		

+//yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment end
 

 static const struct snd_soc_component_driver soc_component_dev_es8311 = {

 	.probe = es8311_probe,

diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/tlv320aic3x.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/tlv320aic3x.c
index 3690409..165d46d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/tlv320aic3x.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/tlv320aic3x.c
@@ -1203,13 +1203,15 @@
 		regmap_read(info->regmap, AIC3X_PAGE_SELECT, &pre_page);
 	
 		regmap_write(info->regmap, AIC3X_PAGE_SELECT, 0);
-		for (i = regmin; i < regmax; i++) {
+		//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound start
+		for (i = regmin; i <= regmax; i++) {
 	
 			//val = snd_soc_component_read(info->component, i); 	
 			regmap_read(info->regmap, i, &val);
 	
 			dev_info(dev,"cocec reg read ,Reg(%d)=0x%x \n",i, val);
 		}
+		//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound end
 	
 		regmap_write(info->regmap, AIC3X_PAGE_SELECT, pre_page);
 		return count;
@@ -1255,23 +1257,18 @@
 	
 	
 		dev_info(dev, "%s:cmd_str=%s \n",__func__,cmd_str); 
-	
 		ret = strcmp(cmd_str,"reg_read");
 		if( ret == 0)
 		{
 			dev_info(dev, "reg_read start\n");
-			if(param1 > 1){
-				dev_err(dev, "reg_read param invalidate fail,param1=%d \n",param1);
-				return -1;		
-			}
-			regpage = param1;	
-			if(param2 > regmax){
-				dev_err(dev, "reg_read param invalidate fail,param2=%d \n",param2);
-				return -1;		
-			}	
-	
 
-			
+			//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound start
+                        if(param1 < 0 || param1 > 109){
+				dev_err(dev, "reg_read param invalidate fail,param1=%d \n",param1);
+				return -1;
+			}
+			//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound end
+
 			regmap_read(info->regmap, AIC3X_PAGE_SELECT, &pre_page);
 			
 			regmap_write(info->regmap, AIC3X_PAGE_SELECT, regpage);
@@ -1295,17 +1292,14 @@
 			//u32 offset = param1;
 			//u32 mask = param2;
 			dev_info(dev, "reg_write start\n");  
-			if(param1 > 1){
-				dev_err(dev, "reg_write param invalidate fail,param1=%d \n",param1);
-				return -1;		
-			}
-			regpage = param1;	
-			if(param2 > regmax){
-				dev_err(dev, "reg_write param invalidate fail,param1=%d \n",param1);
-				return -1;		
-			}	
 
-			
+			//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound start
+			if(param1 < 0 || param1 > 109){
+				dev_err(dev, "reg_write param invalidate fail,param1=%d \n",param1);
+				return -1;
+			}
+			//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound end
+
 			regmap_read(info->regmap, AIC3X_PAGE_SELECT, &pre_page);
 			
 			regmap_write(info->regmap, AIC3X_PAGE_SELECT, regpage);
@@ -1842,23 +1836,25 @@
 	.no_capture_mute = 1,
 };
 
+//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound start
 static struct snd_soc_dai_driver aic3x_dai = {
 	.name = "tlv320aic3x-hifi",
 	.playback = {
 		.stream_name = "Playback",
-		.channels_min = 2,
+		.channels_min = 1,
 		.channels_max = 2,
 		.rates = AIC3X_RATES,
 		.formats = AIC3X_FORMATS,},
 	.capture = {
 		.stream_name = "Capture",
-		.channels_min = 2,
+		.channels_min = 1,
 		.channels_max = 2,
 		.rates = AIC3X_RATES,
 		.formats = AIC3X_FORMATS,},
 	.ops = &aic3x_dai_ops,
 	.symmetric_rates = 1,
 };
+//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound end
 
 static void aic3x_mono_init(struct snd_soc_component *component)
 {
@@ -2045,6 +2041,40 @@
 	return 0;
 }
 
+//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound start
+static int component_open(struct snd_soc_component *component,
+                struct snd_pcm_substream *substream)
+{
+        int ret = 0;
+        struct aic3x_priv *info = snd_soc_component_get_drvdata(component);
+        printk("Enter into %s()\n", __func__);
+
+        if(info->clk != NULL) {
+                ret = clk_enable(info->clk);
+                if(ret) {
+                        pr_err("failed to enable clkout");
+                }
+        }
+        pr_info("%s:clk en end!\n", __func__);
+
+        return ret;
+}
+
+static int component_close(struct snd_soc_component *component,
+                struct snd_pcm_substream *substream)
+{
+        int ret = 0;
+        struct aic3x_priv *info = snd_soc_component_get_drvdata(component);
+        printk("Enter into %s()\n", __func__);
+
+        if(info->clk != NULL) {
+                clk_disable(info->clk);
+        }
+        pr_info("%s:clk dis end!\n", __func__);
+
+        return ret;
+}
+
 static const struct snd_soc_component_driver soc_component_dev_aic3x = {
 	.set_bias_level		= aic3x_set_bias_level,
 	.probe			= aic3x_probe,
@@ -2057,7 +2087,10 @@
 	.use_pmdown_time	= 1,
 	.endianness		= 1,
 	.non_legacy_dai_naming	= 1,
+        .open = component_open,
+        .close = component_close,
 };
+//yu.dong@20240416[T106BUG-582]Modify codec to play recording without sound end
 
 static void aic3x_configure_ocmv(struct i2c_client *client)
 {
@@ -2252,7 +2285,6 @@
 					
 #endif
 
-	
 	pr_info( "alsa %s:end\n",__func__);
 
 	return 0;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
index e059a8d..4e56af4 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
@@ -851,8 +851,8 @@
 		info->s = s;
 		info->s_sleep = s_sleep;
 	}
-
-	ret = pinctrl_select_state(p, s);
+//yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment start
+	ret = pinctrl_select_state(p, s_sleep);
 	if (ret < 0) {
 		devm_pinctrl_put(p);
 		dev_err(dev, " select state failure!!\n");
@@ -862,6 +862,38 @@
 
 }
 
+int zx29_i2s_config_default_pin(void)
+{
+    struct zx29_board_data *info = s_board;
+    int ret;
+
+    if (!info || !info->p || !info->s)
+        return -ENODEV;
+
+    ret = pinctrl_select_state(info->p, info->s);
+    if (ret < 0) {
+        pr_err(" %s select state failure %d!!\n", __func__, ret);
+    }
+
+    return ret;
+}
+
+int zx29_i2s_config_sleep_pin(void)
+{
+    struct zx29_board_data *info = s_board;
+    int ret;
+
+    if (!info || !info->p || !info->s_sleep)
+        return -ENODEV;
+
+    ret = pinctrl_select_state(info->p, info->s_sleep);
+    if (ret < 0) {
+        pr_err(" %s select state failure %d!!\n", __func__, ret);
+    }
+
+    return ret;
+}
+//yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment end
 
 static int zx29_audio_probe(struct platform_device *pdev)
 {