PASDK-53: Reducing the arbitrary per-call time to invoke platform_delay with. Few...
authorGovind Jeyaram <govind.j@ti.com>
Thu, 16 Feb 2017 22:31:49 +0000 (14:31 -0800)
committerGovind Jeyaram <govind.j@ti.com>
Thu, 16 Feb 2017 22:31:49 +0000 (14:31 -0800)
pasdk/test_dsp/sap/audio_dc_cfg.c

index e4d5fef79d6444ea9bc99f4b614ad32f067e62a7..d391d45e7ea473172fea5968aef4f44a8145a28e 100644 (file)
@@ -44,6 +44,8 @@ All rights reserved.
 #include "vproccmds_a.h"
 #include <stdarg.h>
 #include "string.h"
+#include <xdc/runtime/Log.h>
+
 
 Platform_STATUS audioHDMIConfig(void);
 
@@ -274,7 +276,7 @@ Platform_STATUS audioDirConfig(void)
                }
 
                IFPRINT(platform_write("audioDirConfig : Waiting for DIR to Enter PLL Mode...\n"));
-               platform_delay(1000);
+               platform_delay(10);
                timeout--;
        }
 
@@ -384,12 +386,13 @@ void set_audio_desc(unsigned char var1,unsigned char var2,unsigned char var3,uns
 {
        int ret_val=I2C_RET_OK;
 
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_EDID_AUDIO_DESC_FORMAT(var1, var2));}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_EDID_AUDIO_DESC_NUM_CHANNELS(var1, var3));}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_EDID_AUDIO_DESC_SAMPLE_RATES(var1, var4));}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_EDID_AUDIO_DESC_MISC(var1, var5));}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_EDID_AUDIO_DESC_FORMAT(var1, var2));}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_EDID_AUDIO_DESC_NUM_CHANNELS(var1, var3));}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_EDID_AUDIO_DESC_SAMPLE_RATES(var1, var4));}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_EDID_AUDIO_DESC_MISC(var1, var5));}while (ret_val !=I2C_RET_OK);
 }
 
+int gI2Ccnt=0;
 
 // Program HDMI CEA / EDID values, as necessary.
 void hrptredid()
@@ -397,14 +400,17 @@ void hrptredid()
        int ret_val=I2C_RET_OK;
 
        do{
-               platform_delay(1000);
+               platform_delay(10);
                ret_val=alpha_i2c_write(HSDIO_EDID_SPEAKER_ALLOCATION_BLOCK(0xFF));
         if (ret_val !=I2C_RET_OK)
-            i2cConfig(HSR4_I2C_PORT_NUM);        
+        {
+               gI2Ccnt++;
+               i2cConfig(HSR4_I2C_PORT_NUM);
+        }
             
        }while (ret_val !=I2C_RET_OK);
 
-       platform_delay(1000);
+       platform_delay(10);
        do{ret_val=alpha_i2c_write(HSDIO_EDID_SPEAKER_ALLOCATION_BLOCK_2(0x7));}while (ret_val !=I2C_RET_OK);
 
        set_audio_desc(0,1,2,0x7f,7);   // PCM 2 channel, 32kHz, 44.1kHz, 48kHz, 88.2kHz, 96kHz, 176.4 KHz, 192 KHz, 16bit, 20bit, 24bit
@@ -429,7 +435,7 @@ void hrptredid()
        set_audio_desc(17,0,0,0,0);
        set_audio_desc(18,0,0,0,0);
        set_audio_desc(19,0,0,0,0);
-       platform_delay(1000);
+       platform_delay(10);
        do{ret_val=alpha_i2c_write(HSDIO_EDID_GO);}while (ret_val !=I2C_RET_OK);
 }
 
@@ -439,14 +445,14 @@ void  hdmi128()
 {
        int ret_val=I2C_RET_OK;
 
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_ALERT(HSDIO_ALERT_INPUT_AUDIO_CHANGE_msk));}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_ALERT(HSDIO_ALERT_INPUT_AUDIO_MUTE_msk));}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_AUDIO_MCLK_TO_HOST(HSDIO_AudioMClk_128X));}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_AUDIO_UNMUTE_DELAY_TO_HOST(HSDIO_AudioUnMuteDelay_NO_DELAY));}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_AUDIO_FORMAT_TO_HOST(HSDIO_AudioFmt_I2S));}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_IMPLEMENT_AUDIO_TO_HOST_CMDS);}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_AUDIO_ROUTING(HSDIO_AudioRouting_HSDIOIN_NOOUT));}while (ret_val !=I2C_RET_OK);
-       platform_delay(1000);do{ret_val=alpha_i2c_write(HSDIO_SYS_CFG_GO);}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_ALERT(HSDIO_ALERT_INPUT_AUDIO_CHANGE_msk));}while (ret_val !=I2C_RET_OK);
+       //platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_ALERT(HSDIO_ALERT_INPUT_AUDIO_MUTE_msk));}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_AUDIO_MCLK_TO_HOST(HSDIO_AudioMClk_128X));}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_AUDIO_UNMUTE_DELAY_TO_HOST(HSDIO_AudioUnMuteDelay_NO_DELAY));}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_AUDIO_FORMAT_TO_HOST(HSDIO_AudioFmt_I2S));}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_IMPLEMENT_AUDIO_TO_HOST_CMDS);}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_AUDIO_ROUTING(HSDIO_AudioRouting_HSDIOIN_NOOUT));}while (ret_val !=I2C_RET_OK);
+       platform_delay(10);do{ret_val=alpha_i2c_write(HSDIO_SYS_CFG_GO);}while (ret_val !=I2C_RET_OK);
 }
 
 //
@@ -529,10 +535,13 @@ unsigned int read_hdmi_samprate()
        Uint8 length;
        int ret_val=7;
 
+       Log_info0("Audio DC CFG: Entered read_hdmi_samprate");
        ret_val=alpha_i2c_write(HSDIO_AUDIO_INPUT_FREQ_STS);
-
        if(!ret_val) i2cRead(HSR4_I2C_PORT_NUM, HSR4_I2C_ADDR,&length,0,1,1);
        if(!ret_val) i2cRead(HSR4_I2C_PORT_NUM, HSR4_I2C_ADDR,&data[0],0,1,length);
+
+       Log_info0("Audio DC CFG: Leaving read_hdmi_samprate");
+
        if(!ret_val) ret_val= data[3]; // indicates sample rate
        else
        ret_val = 0;