@@ -533,67 +533,65 @@ static int arizona_hpdet_do_id(struct arizona_extcon_info *info, int *reading,
533
533
struct arizona * arizona = info -> arizona ;
534
534
int id_gpio = arizona -> pdata .hpdet_id_gpio ;
535
535
536
+ if (!arizona -> pdata .hpdet_acc_id )
537
+ return 0 ;
538
+
536
539
/*
537
540
* If we're using HPDET for accessory identification we need
538
541
* to take multiple measurements, step through them in sequence.
539
542
*/
540
- if (arizona -> pdata .hpdet_acc_id ) {
541
- info -> hpdet_res [info -> num_hpdet_res ++ ] = * reading ;
543
+ info -> hpdet_res [info -> num_hpdet_res ++ ] = * reading ;
542
544
543
- /* Only check the mic directly if we didn't already ID it */
544
- if (id_gpio && info -> num_hpdet_res == 1 ) {
545
- dev_dbg (arizona -> dev , "Measuring mic\n" );
546
-
547
- regmap_update_bits (arizona -> regmap ,
548
- ARIZONA_ACCESSORY_DETECT_MODE_1 ,
549
- ARIZONA_ACCDET_MODE_MASK |
550
- ARIZONA_ACCDET_SRC ,
551
- ARIZONA_ACCDET_MODE_HPR |
552
- info -> micd_modes [0 ].src );
545
+ /* Only check the mic directly if we didn't already ID it */
546
+ if (id_gpio && info -> num_hpdet_res == 1 ) {
547
+ dev_dbg (arizona -> dev , "Measuring mic\n" );
553
548
554
- gpio_set_value_cansleep (id_gpio , 1 );
549
+ regmap_update_bits (arizona -> regmap ,
550
+ ARIZONA_ACCESSORY_DETECT_MODE_1 ,
551
+ ARIZONA_ACCDET_MODE_MASK |
552
+ ARIZONA_ACCDET_SRC ,
553
+ ARIZONA_ACCDET_MODE_HPR |
554
+ info -> micd_modes [0 ].src );
555
555
556
- regmap_update_bits (arizona -> regmap ,
557
- ARIZONA_HEADPHONE_DETECT_1 ,
558
- ARIZONA_HP_POLL , ARIZONA_HP_POLL );
559
- return - EAGAIN ;
560
- }
556
+ gpio_set_value_cansleep (id_gpio , 1 );
561
557
562
- /* OK, got both. Now, compare... */
563
- dev_dbg (arizona -> dev , "HPDET measured %d %d\n" ,
564
- info -> hpdet_res [0 ], info -> hpdet_res [1 ]);
558
+ regmap_update_bits (arizona -> regmap , ARIZONA_HEADPHONE_DETECT_1 ,
559
+ ARIZONA_HP_POLL , ARIZONA_HP_POLL );
560
+ return - EAGAIN ;
561
+ }
565
562
566
- /* Take the headphone impedance for the main report */
567
- * reading = info -> hpdet_res [0 ];
563
+ /* OK, got both. Now, compare... */
564
+ dev_dbg (arizona -> dev , "HPDET measured %d %d\n" ,
565
+ info -> hpdet_res [0 ], info -> hpdet_res [1 ]);
568
566
569
- /* Sometimes we get false readings due to slow insert */
570
- if (* reading >= ARIZONA_HPDET_MAX && !info -> hpdet_retried ) {
571
- dev_dbg (arizona -> dev , "Retrying high impedance\n" );
572
- info -> num_hpdet_res = 0 ;
573
- info -> hpdet_retried = true;
574
- arizona_start_hpdet_acc_id (info );
575
- pm_runtime_put (info -> dev );
576
- return - EAGAIN ;
577
- }
567
+ /* Take the headphone impedance for the main report */
568
+ * reading = info -> hpdet_res [0 ];
578
569
579
- /*
580
- * If we measure the mic as high impedance
581
- */
582
- if (!id_gpio || info -> hpdet_res [1 ] > 50 ) {
583
- dev_dbg (arizona -> dev , "Detected mic\n" );
584
- * mic = true;
585
- info -> detecting = true;
586
- } else {
587
- dev_dbg (arizona -> dev , "Detected headphone\n" );
588
- }
570
+ /* Sometimes we get false readings due to slow insert */
571
+ if (* reading >= ARIZONA_HPDET_MAX && !info -> hpdet_retried ) {
572
+ dev_dbg (arizona -> dev , "Retrying high impedance\n" );
573
+ info -> num_hpdet_res = 0 ;
574
+ info -> hpdet_retried = true;
575
+ arizona_start_hpdet_acc_id (info );
576
+ pm_runtime_put (info -> dev );
577
+ return - EAGAIN ;
578
+ }
589
579
590
- /* Make sure everything is reset back to the real polarity */
591
- regmap_update_bits (arizona -> regmap ,
592
- ARIZONA_ACCESSORY_DETECT_MODE_1 ,
593
- ARIZONA_ACCDET_SRC ,
594
- info -> micd_modes [0 ].src );
580
+ /*
581
+ * If we measure the mic as high impedance
582
+ */
583
+ if (!id_gpio || info -> hpdet_res [1 ] > 50 ) {
584
+ dev_dbg (arizona -> dev , "Detected mic\n" );
585
+ * mic = true;
586
+ info -> detecting = true;
587
+ } else {
588
+ dev_dbg (arizona -> dev , "Detected headphone\n" );
595
589
}
596
590
591
+ /* Make sure everything is reset back to the real polarity */
592
+ regmap_update_bits (arizona -> regmap , ARIZONA_ACCESSORY_DETECT_MODE_1 ,
593
+ ARIZONA_ACCDET_SRC , info -> micd_modes [0 ].src );
594
+
597
595
return 0 ;
598
596
}
599
597
0 commit comments