OSDN Git Service

ALSA: hda/cs8409: Add Support to disable jack type detection for CS42L42
authorStefan Binding <sbinding@opensource.cirrus.com>
Wed, 11 Aug 2021 18:56:47 +0000 (19:56 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 12 Aug 2021 11:41:54 +0000 (13:41 +0200)
Some hardware configurations do not support jack type detection.
Instead, for those configurations, only tip detection is supported.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-21-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/patch_cs8409-tables.c
sound/pci/hda/patch_cs8409.c
sound/pci/hda/patch_cs8409.h

index 117c705..be9feb8 100644 (file)
@@ -246,6 +246,7 @@ struct sub_codec cs8409_cs42l42_codec = {
        .mic_jack_in = 0,
        .paged = 1,
        .suspended = 1,
+       .no_type_dect = 0,
 };
 
 /******************************************************************************
index 5b3221d..7ea46c8 100644 (file)
@@ -559,6 +559,39 @@ static void cs42l42_run_jack_detect(struct sub_codec *cs42l42)
        usleep_range(10000, 25000);
 }
 
+static int cs42l42_handle_tip_sense(struct sub_codec *cs42l42, unsigned int reg_ts_status)
+{
+       int status_changed = 0;
+
+       /* TIP_SENSE INSERT/REMOVE */
+       switch (reg_ts_status) {
+       case CS42L42_JACK_INSERTED:
+               if (!cs42l42->hp_jack_in) {
+                       if (cs42l42->no_type_dect) {
+                               status_changed = 1;
+                               cs42l42->hp_jack_in = 1;
+                               cs42l42->mic_jack_in = 0;
+                       } else {
+                               cs42l42_run_jack_detect(cs42l42);
+                       }
+               }
+               break;
+
+       case CS42L42_JACK_REMOVED:
+               if (cs42l42->hp_jack_in || cs42l42->mic_jack_in) {
+                       status_changed = 1;
+                       cs42l42->hp_jack_in = 0;
+                       cs42l42->mic_jack_in = 0;
+               }
+               break;
+       default:
+               /* jack in transition */
+               break;
+       }
+
+       return status_changed;
+}
+
 static int cs42l42_jack_unsol_event(struct sub_codec *cs42l42)
 {
        int status_changed = 0;
@@ -583,10 +616,13 @@ static int cs42l42_jack_unsol_event(struct sub_codec *cs42l42)
                cs8409_i2c_write(cs42l42, 0x131b, 0xFF);
 
                type = ((reg_hs_status & CS42L42_HSTYPE_MASK) + 1);
-               /* CS42L42 reports optical jack as type 4
-                * We don't handle optical jack
-                */
-               if (type != 4) {
+
+               if (cs42l42->no_type_dect) {
+                       status_changed = cs42l42_handle_tip_sense(cs42l42, reg_ts_status);
+               } else if (type == 4) {
+                       /* Type 4 not supported */
+                       status_changed = cs42l42_handle_tip_sense(cs42l42, CS42L42_JACK_REMOVED);
+               } else {
                        if (!cs42l42->hp_jack_in) {
                                status_changed = 1;
                                cs42l42->hp_jack_in = 1;
@@ -596,37 +632,11 @@ static int cs42l42_jack_unsol_event(struct sub_codec *cs42l42)
                                status_changed = 1;
                                cs42l42->mic_jack_in = 1;
                        }
-               } else {
-                       if (cs42l42->hp_jack_in || cs42l42->mic_jack_in) {
-                               status_changed = 1;
-                               cs42l42->hp_jack_in = 0;
-                               cs42l42->mic_jack_in = 0;
-                       }
                }
-
                /* Re-Enable Tip Sense Interrupt */
                cs8409_i2c_write(cs42l42, 0x1320, 0xF3);
-
        } else {
-               /* TIP_SENSE INSERT/REMOVE */
-               switch (reg_ts_status) {
-               case CS42L42_JACK_INSERTED:
-                       cs42l42_run_jack_detect(cs42l42);
-                       break;
-
-               case CS42L42_JACK_REMOVED:
-                       if (cs42l42->hp_jack_in || cs42l42->mic_jack_in) {
-                               status_changed = 1;
-                               cs42l42->hp_jack_in = 0;
-                               cs42l42->mic_jack_in = 0;
-                       }
-                       break;
-
-               default:
-                       /* jack in transition */
-                       status_changed = 0;
-                       break;
-               }
+               status_changed = cs42l42_handle_tip_sense(cs42l42, reg_ts_status);
        }
 
        return status_changed;
index 817df29..a105c3c 100644 (file)
@@ -285,6 +285,7 @@ struct sub_codec {
        unsigned int last_page;
        unsigned int hsbias_hiz;
        unsigned int full_scale_vol:1;
+       unsigned int no_type_dect:1;
 
        s8 vol[CS42L42_VOLUMES];
 };