@@ -460,8 +460,12 @@ static int chipio_send(struct hda_codec *codec,
460
460
static int chipio_write_address (struct hda_codec * codec ,
461
461
unsigned int chip_addx )
462
462
{
463
+ struct ca0132_spec * spec = codec -> spec ;
463
464
int res ;
464
465
466
+ if (spec -> curr_chip_addx == chip_addx )
467
+ return 0 ;
468
+
465
469
/* send low 16 bits of the address */
466
470
res = chipio_send (codec , VENDOR_CHIPIO_ADDRESS_LOW ,
467
471
chip_addx & 0xffff );
@@ -472,37 +476,14 @@ static int chipio_write_address(struct hda_codec *codec,
472
476
chip_addx >> 16 );
473
477
}
474
478
475
- return res ;
476
- }
477
-
478
- static int chipio_write_addx (struct hda_codec * codec , u32 chip_addx )
479
- {
480
- struct ca0132_spec * spec = codec -> spec ;
481
- int status ;
482
-
483
- if (spec -> curr_chip_addx == chip_addx )
484
- return 0 ;
485
-
486
- /* send low 16 bits of the address */
487
- status = chipio_send (codec , VENDOR_CHIPIO_ADDRESS_LOW ,
488
- chip_addx & 0xffff );
489
-
490
- if (status < 0 )
491
- return status ;
492
-
493
- /* send high 16 bits of the address */
494
- status = chipio_send (codec , VENDOR_CHIPIO_ADDRESS_HIGH ,
495
- chip_addx >> 16 );
496
-
497
- spec -> curr_chip_addx = (status < 0 ) ? ~0UL : chip_addx ;
479
+ spec -> curr_chip_addx = (res < 0 ) ? ~0UL : chip_addx ;
498
480
499
- return status ;
481
+ return res ;
500
482
}
501
483
502
484
/*
503
485
* Write data through the vendor widget -- NOT protected by the Mutex!
504
486
*/
505
-
506
487
static int chipio_write_data (struct hda_codec * codec , unsigned int data )
507
488
{
508
489
int res ;
@@ -604,7 +585,7 @@ static int chipio_write_multiple(struct hda_codec *codec,
604
585
int status ;
605
586
606
587
mutex_lock (& spec -> chipio_mutex );
607
- status = chipio_write_addx (codec , chip_addx );
588
+ status = chipio_write_address (codec , chip_addx );
608
589
if (status < 0 )
609
590
goto error ;
610
591
@@ -742,18 +723,17 @@ static int dspio_send(struct hda_codec *codec, unsigned int reg,
742
723
*/
743
724
static void dspio_write_wait (struct hda_codec * codec )
744
725
{
745
- int cur_val , prv_val ;
746
- int retry = 50 ;
726
+ int status ;
727
+ unsigned long timeout = jiffies + msecs_to_jiffies ( 1000 ) ;
747
728
748
- cur_val = 0 ;
749
729
do {
750
- prv_val = cur_val ;
751
- msleep ( 20 );
752
- dspio_send ( codec , VENDOR_DSPIO_SCP_POST_COUNT_QUERY , 1 );
753
- dspio_send ( codec , VENDOR_DSPIO_STATUS , 0 );
754
- cur_val = snd_hda_codec_read ( codec , WIDGET_DSP_CTRL , 0 ,
755
- VENDOR_DSPIO_SCP_READ_COUNT , 0 );
756
- } while (cur_val && ( cur_val == prv_val ) && -- retry );
730
+ status = snd_hda_codec_read ( codec , WIDGET_DSP_CTRL , 0 ,
731
+ VENDOR_DSPIO_STATUS , 0 );
732
+ if (( status == VENDOR_STATUS_DSPIO_OK ) ||
733
+ ( status == VENDOR_STATUS_DSPIO_SCP_RESPONSE_QUEUE_EMPTY ))
734
+ break ;
735
+ msleep ( 1 );
736
+ } while (time_before ( jiffies , timeout ) );
757
737
}
758
738
759
739
/*
0 commit comments