@@ -681,13 +681,13 @@ void AV_Mode_Switch(int is_pal) {
681681 }
682682}
683683
684- void Source_AV (source_t mode ) // 0=rtc6715; 1=AV_in
684+ void Source_AV (source_t mode )
685685{
686686 pthread_mutex_lock (& hardware_mutex );
687687 Screen_Display (0 );
688688 // I2C_Write(ADDR_FPGA, 0x8C, 0x00);
689689
690- g_hw_stat .av_chid = SOURCE_AV_MODULE == mode ? 0 : 1 ;
690+ g_hw_stat .av_chid = SOURCE_AV_MODULE == mode ? 1 : 0 ;
691691
692692 if (SOURCE_AV_MODULE == mode ) {
693693 RTC6715_Open (1 );
@@ -696,7 +696,7 @@ void Source_AV(source_t mode) // 0=rtc6715; 1=AV_in
696696 }
697697
698698 TP2825_Switch_Mode (g_setting .source .analog_format );
699- TP2825_Switch_CH (g_hw_stat .av_chid ? SOURCE_AV_IN : SOURCE_AV_MODULE );
699+ TP2825_Switch_CH (g_hw_stat .av_chid ? SOURCE_AV_MODULE : SOURCE_AV_IN );
700700
701701 AV_Mode_Switch_fpga (g_setting .source .analog_format );
702702 g_hw_stat .av_pal_w = g_setting .source .analog_format ;
@@ -734,19 +734,22 @@ int AV_in_detect() // return = 1: vtmg to V536 changed
734734 pthread_mutex_lock (& hardware_mutex );
735735
736736 if (g_hw_stat .source_mode == SOURCE_MODE_UI ) { // detect in UI mode
737- if (g_hw_stat .av_chid == 0 ) {
738- g_hw_stat .av_chid = 1 ; // 1=AV_in
737+ if (g_hw_stat .av_chid == 1 ) {
738+ g_hw_stat .av_chid = 0 ; // 0=AV_in
739+ det_last = -1 ;
740+ g_hw_stat .av_valid [g_hw_stat .av_chid ] = 0 ;
739741 TP2825_Switch_CH (g_hw_stat .av_chid ? SOURCE_AV_IN : SOURCE_AV_MODULE );
740742 }
741743
742744 rdat = I2C_Read (ADDR_TP2825 , 0x01 );
745+ rdat &= 0xc9 ;
746+
747+ det = ((rdat == 0x48 ) || (rdat == 0x49 ));
743748
744- det = (rdat & 0x80 ) ? 0 : 1 ;
745749 if (det_last != det ) {
746750 det_last = det ;
747751 } else {
748752 g_hw_stat .av_valid [g_hw_stat .av_chid ] = det ;
749- g_hw_stat .av_pal [g_hw_stat .av_chid ] = (rdat & 0x01 ) ? 0 : 1 ;
750753 }
751754
752755 det_cnt = 0 ;
0 commit comments