@@ -41,7 +41,7 @@ static void *cec_memcpy(void *memto, const void *memfrom, unsigned int size)
4141}
4242
4343static void waiting_aocec_free (void ) {
44- unsigned int cnt = 0 ;
44+ unsigned long cnt = 0 ;
4545 while (readl (P_AO_CEC_RW_REG ) & (1 <<23 ))
4646 {
4747 if (8192 <= cnt ++ )
@@ -146,8 +146,6 @@ void remote_cec_hw_reset(void)
146146static int cec_triggle_tx (unsigned char * msg , unsigned char len )
147147{
148148 unsigned int i , cnt = 0 ;
149- cec_dbg_print ("cec_triggle_tx len:0x" , len );
150- cec_dbg_prints ("\n" );
151149
152150 cec_dbg_prints (" T:" );
153151 for (i = 0 ; i < len ; i ++ ) {
@@ -168,6 +166,7 @@ static int cec_triggle_tx(unsigned char *msg, unsigned char len)
168166 cec_dbg_prints ("\n" );
169167 }
170168
169+ _udelay (150 );
171170 return 0 ;
172171}
173172
@@ -180,7 +179,7 @@ static int cec_triggle_tx(unsigned char *msg, unsigned char len)
180179#define DEVICE_PURE_CEC_SWITCH 6
181180#define DEVICE_VIDEO_PROCESSOR 7
182181
183- static unsigned char log_addr_to_devtype (unsigned int addr )
182+ static unsigned char log_addr_to_devtype (unsigned char addr )
184183{
185184 static unsigned char addr_map [] = {
186185 DEVICE_TV ,
@@ -211,7 +210,7 @@ static void cec_report_physical_address(void)
211210 msg [0 ] = ((cec_msg .log_addr & 0xf ) << 4 ) | CEC_BROADCAST_ADDR ;
212211 msg [1 ] = CEC_OC_REPORT_PHYSICAL_ADDRESS ;
213212 msg [2 ] = (cec_msg .phy_addr >> 8 ) & 0xff ;
214- msg [3 ] = cec_msg .phy_addr & 0xff ;
213+ msg [3 ] = ( cec_msg .phy_addr >> 0 ) & 0xff ;
215214 msg [4 ] = log_addr_to_devtype (cec_msg .log_addr );
216215
217216 cec_triggle_tx (msg , 5 );
@@ -245,18 +244,44 @@ static void cec_feature_abort(unsigned char reason, unsigned char initiator)
245244 cec_triggle_tx (msg , 4 );
246245}
247246
248- static void cec_set_stream_path (void )
247+ static void cec_menu_status (unsigned char menu_status , unsigned char initiator )
248+ {
249+ unsigned char msg [3 ];
250+ cec_dbg_print ("cec_menu_status menu_status:0x" , menu_status );
251+ cec_dbg_printx (", initiator:0x" , initiator , 4 );
252+ cec_dbg_prints ("\n" );
253+
254+ msg [0 ] = ((cec_msg .log_addr & 0xf ) << 4 ) | (initiator & 0xf );
255+ msg [1 ] = CEC_OC_MENU_STATUS ;
256+ msg [2 ] = menu_status ;
257+
258+ cec_triggle_tx (msg , 3 );
259+ }
260+
261+ static void cec_set_stream_path (unsigned char initiator )
249262{
250- unsigned char phy_addr_ab = (cec_msg .phy_addr >> 8 ) & 0xff ;
251- unsigned char phy_addr_cd = cec_msg .phy_addr & 0xff ;
252- cec_dbg_prints ("cec_set_stream_path\n" );
253-
254- if ((hdmi_cec_func_config >> AUTO_POWER_ON_MASK ) & 0x1 ) {
255- if ((hdmi_cec_func_config >> STREAMPATH_POWER_ON_MASK ) & 0x1 ) {
256- if ((phy_addr_ab == cec_msg .msg [2 ]) &&
257- (phy_addr_cd == cec_msg .msg [3 ])) {
258- cec_msg .cec_power = 0x1 ;
259- }
263+ unsigned int phy_addr = (cec_msg .msg [2 ] << 8 ) | cec_msg .msg [3 ];
264+ cec_dbg_printx ("cec_set_stream_path initiator:0x" , initiator , 4 );
265+ cec_dbg_printx (", phy_addr:0x" , phy_addr , 16 );
266+ cec_dbg_prints ("\n" );
267+
268+ if ((hdmi_cec_func_config >> STREAMPATH_POWER_ON_MASK ) & 0x1 ) {
269+ if (cec_msg .phy_addr == phy_addr && initiator == CEC_TV_ADDR ) {
270+ cec_msg .cec_power = 0x1 ;
271+ }
272+ }
273+ }
274+
275+ static void cec_routing_change (unsigned char initiator )
276+ {
277+ unsigned int phy_addr = (cec_msg .msg [4 ] << 8 ) | cec_msg .msg [5 ];
278+ cec_dbg_printx ("cec_routing_change initiator:0x" , initiator , 4 );
279+ cec_dbg_printx (", phy_addr:0x" , phy_addr , 16 );
280+ cec_dbg_prints ("\n" );
281+
282+ if ((hdmi_cec_func_config >> STREAMPATH_POWER_ON_MASK ) & 0x1 ) {
283+ if (cec_msg .phy_addr == phy_addr && initiator == CEC_TV_ADDR ) {
284+ cec_msg .cec_power = 0x1 ;
260285 }
261286 }
262287}
@@ -266,10 +291,14 @@ static void cec_user_control_pressed(void)
266291 cec_dbg_print ("cec_user_control_pressed operation:0x" , cec_msg .msg [2 ]);
267292 cec_dbg_prints ("\n" );
268293
269- if ((hdmi_cec_func_config >> AUTO_POWER_ON_MASK ) & 0x1 ) {
294+ if ((hdmi_cec_func_config >> ONE_TOUCH_STANDBY_MASK ) & 0x1 ) {
270295 if ((0x40 == cec_msg .msg [2 ]) || // Power
271296 (0x6b == cec_msg .msg [2 ]) || // Power Toggle Function
272297 (0x6d == cec_msg .msg [2 ]) || // Power On Function
298+ (0x0a == cec_msg .msg [2 ]) || // Setup Menu
299+ (0x0b == cec_msg .msg [2 ]) || // Contents Menu
300+ (0x10 == cec_msg .msg [2 ]) || // Media Top Menu
301+ (0x11 == cec_msg .msg [2 ]) || // Media Context-sensitive Menu
273302 (0x09 == cec_msg .msg [2 ])) { // Root Menu
274303 cec_msg .cec_power = 0x1 ;
275304 }
@@ -290,20 +319,6 @@ static void cec_device_vendor_id(void)
290319 cec_triggle_tx (msg , 5 );
291320}
292321
293- static void cec_menu_status (unsigned char menu_status , unsigned char initiator )
294- {
295- unsigned char msg [3 ];
296- cec_dbg_print ("cec_menu_status menu_status:0x" , menu_status );
297- cec_dbg_printx (", initiator:0x" , initiator , 4 );
298- cec_dbg_prints ("\n" );
299-
300- msg [0 ] = ((cec_msg .log_addr & 0xf ) << 4 ) | (initiator & 0xf );
301- msg [1 ] = CEC_OC_MENU_STATUS ;
302- msg [2 ] = menu_status ;
303-
304- cec_triggle_tx (msg , 3 );
305- }
306-
307322static void cec_deck_status (unsigned char initiator )
308323{
309324 unsigned char msg [3 ];
@@ -349,7 +364,7 @@ static unsigned int cec_handle_message(void)
349364 unsigned char initiator = (cec_msg .msg [0 ] >> 4 ) & 0xf ;
350365 unsigned char destination = cec_msg .msg [0 ] & 0xf ;
351366 unsigned char opcode = (cec_msg .msg_len > 1 ) ? cec_msg .msg [1 ] : CEC_OC_POLLING_MESSAGE ;
352- unsigned char directly_addressed = (destination != 0xf && destination == cec_msg .log_addr );
367+ unsigned char directly_addressed = (destination != CEC_BROADCAST_ADDR && destination == cec_msg .log_addr );
353368
354369 cec_dbg_printx ("cec_handle_message initiator:0x" , initiator , 4 );
355370 cec_dbg_printx (", destination:0x" , destination , 4 );
@@ -380,7 +395,10 @@ static unsigned int cec_handle_message(void)
380395 cec_set_osd_name (initiator );
381396 break ;
382397 case CEC_OC_SET_STREAM_PATH :
383- cec_set_stream_path ();
398+ cec_set_stream_path (initiator );
399+ break ;
400+ case CEC_OC_ROUTING_CHANGE :
401+ cec_routing_change (initiator );
384402 break ;
385403 case CEC_OC_GIVE_DEVICE_POWER_STATUS :
386404 if (directly_addressed )
@@ -494,16 +512,7 @@ unsigned int cec_handler(void)
494512void cec_node_init (void )
495513{
496514 unsigned int phy_addr = readl (P_AO_DEBUG_REG1 ) & 0xffff ;
497- unsigned int log_addr = readl (P_AO_DEBUG_REG3 ) & 0xf ;
498- if (!log_addr )
499- log_addr = 0xf ;
500-
501- cec_dbg_printx ("AO_DEBUG_REG0:0x" , readl (P_AO_DEBUG_REG0 ), 32 );
502- cec_dbg_printx (", AO_DEBUG_REG1:0x" , readl (P_AO_DEBUG_REG1 ), 32 );
503- cec_dbg_prints ("\n" );
504- cec_dbg_printx ("AO_DEBUG_REG2:0x" , readl (P_AO_DEBUG_REG2 ), 32 );
505- cec_dbg_printx (", AO_DEBUG_REG3:0x" , readl (P_AO_DEBUG_REG3 ), 32 );
506- cec_dbg_prints ("\n" );
515+ unsigned char log_addr = readl (P_AO_DEBUG_REG3 ) & 0xf ;
507516
508517 cec_dbg_print ("cec_node_init cec_config:0x" , hdmi_cec_func_config );
509518 cec_dbg_printx (", log_addr:0x" , log_addr , 4 );
@@ -515,6 +524,12 @@ void cec_node_init(void)
515524 cec_msg .log_addr = log_addr ;
516525 cec_msg .phy_addr = phy_addr ;
517526
527+ if (!cec_msg .log_addr || !cec_msg .phy_addr ) {
528+ cec_dbg_prints ("WARNING: log/phy_addr is not set, disabling cec wakeup\n" );
529+ hdmi_cec_func_config = hdmi_cec_func_config & ~(0x1 << CEC_FUNC_MASK );
530+ return ;
531+ }
532+
518533 cec_wr_reg (CEC_LOGICAL_ADDR0 , 0 );
519534 cec_hw_buf_clear ();
520535 cec_wr_reg (CEC_LOGICAL_ADDR0 , log_addr );
@@ -523,7 +538,6 @@ void cec_node_init(void)
523538 _udelay (100 );
524539
525540 cec_report_physical_address ();
526- _udelay (150 );
527541 cec_device_vendor_id ();
528542 cec_set_osd_name (CEC_TV_ADDR );
529543}
0 commit comments