Ignore:
Timestamp:
Aug 7, 2022, 6:11:12 PM (3 years ago)
Author:
David Azarewicz
Message:

Merge changes from next branch.

Location:
GPL/trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/pci/hda/hda_auto_parser.c

    r695 r717  
    828828}
    829829
    830 static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
     830void __snd_hda_apply_fixup(struct hda_codec *codec, int id, int action, int depth)
    831831{
    832832        const char *modelname = codec->fixup_name;
     
    838838                        break;
    839839                if (fix->chained_before)
    840                         apply_fixup(codec, fix->chain_id, action, depth + 1);
     840                        __snd_hda_apply_fixup(codec, fix->chain_id, action, depth + 1);
    841841
    842842                switch (fix->type) {
     
    879879        }
    880880}
     881EXPORT_SYMBOL_GPL(__snd_hda_apply_fixup);
    881882
    882883/**
     
    888889{
    889890        if (codec->fixup_list)
    890                 apply_fixup(codec, codec->fixup_id, action, 0);
     891                __snd_hda_apply_fixup(codec, codec->fixup_id, action, 0);
    891892}
    892893EXPORT_SYMBOL_GPL(snd_hda_apply_fixup);
     
    976977 *
    977978 * The function tries to find the matching model name at first, if given.
     979 * If the model string contains the SSID alias, try to look up with the given
     980 * alias ID.
    978981 * If nothing matched, try to look up the PCI SSID.
    979982 * If still nothing matched, try to look up the codec SSID.
     
    987990        int id = HDA_FIXUP_ID_NOT_SET;
    988991        const char *name = NULL;
     992        const char *type = NULL;
     993        unsigned int vendor, device;
    989994
    990995        if (codec->fixup_id != HDA_FIXUP_ID_NOT_SET)
     
    993998        /* when model=nofixup is given, don't pick up any fixups */
    994999        if (codec->modelname && !strcmp(codec->modelname, "nofixup")) {
    995                 codec->fixup_list = NULL;
    996                 codec->fixup_name = NULL;
    997                 codec->fixup_id = HDA_FIXUP_ID_NO_FIXUP;
     1000                id = HDA_FIXUP_ID_NO_FIXUP;
     1001                fixlist = NULL;
    9981002                codec_dbg(codec, "%s: picked no fixup (nofixup specified)\n",
    9991003                          codec->core.chip_name);
    1000                 return;
    1001         }
    1002 
     1004                goto found;
     1005        }
     1006
     1007        /* match with the model name string */
    10031008        if (codec->modelname && models) {
    10041009                while (models->name) {
    10051010                        if (!strcmp(codec->modelname, models->name)) {
    1006                                 codec->fixup_id = models->id;
    1007                                 codec->fixup_name = models->name;
    1008                                 codec->fixup_list = fixlist;
     1011                                id = models->id;
     1012                                name = models->name;
    10091013                                codec_dbg(codec, "%s: picked fixup %s (model specified)\n",
    10101014                                          codec->core.chip_name, codec->fixup_name);
    1011                                 return;
     1015                                goto found;
    10121016                        }
    10131017                        models++;
    10141018                }
    10151019        }
    1016         if (quirk) {
    1017                 q = snd_pci_quirk_lookup(codec->bus->pci, quirk);
     1020
     1021        if (!quirk)
     1022                return;
     1023
     1024        /* match with the SSID alias given by the model string "XXXX:YYYY" */
     1025        if (codec->modelname &&
     1026            sscanf(codec->modelname, "%04x:%04x", &vendor, &device) == 2) {
     1027                q = snd_pci_quirk_lookup_id(vendor, device, quirk);
    10181028                if (q) {
    1019                         id = q->value;
     1029                        type = "alias SSID";
     1030                        goto found_device;
     1031                }
     1032        }
     1033
     1034        /* match with the PCI SSID */
     1035        q = snd_pci_quirk_lookup(codec->bus->pci, quirk);
     1036        if (q) {
     1037                type = "PCI SSID";
     1038                goto found_device;
     1039        }
     1040
     1041        /* match with the codec SSID */
     1042        q = snd_pci_quirk_lookup_id(codec->core.subsystem_id >> 16,
     1043                                    codec->core.subsystem_id & 0xffff,
     1044                                    quirk);
     1045        if (q) {
     1046                type = "codec SSID";
     1047                goto found_device;
     1048        }
     1049
     1050        return; /* no matching */
     1051
     1052 found_device:
     1053        id = q->value;
    10201054#ifdef CONFIG_SND_DEBUG_VERBOSE
    1021                         name = q->name;
    1022                         codec_dbg(codec, "%s: picked fixup %s (PCI SSID%s)\n",
    1023                                   codec->core.chip_name, name, q->subdevice_mask ? "" : " - vendor generic");
     1055        name = q->name;
    10241056#endif
    1025                 }
    1026         }
    1027         if (id < 0 && quirk) {
    1028                 for (q = quirk; q->subvendor || q->subdevice; q++) {
    1029                         unsigned int vendorid =
    1030                                 q->subdevice | (q->subvendor << 16);
    1031                         unsigned int mask = 0xffff0000 | q->subdevice_mask;
    1032                         if ((codec->core.subsystem_id & mask) == (vendorid & mask)) {
    1033                                 id = q->value;
    1034 #ifdef CONFIG_SND_DEBUG_VERBOSE
    1035                                 name = q->name;
    1036                                 codec_dbg(codec, "%s: picked fixup %s (codec SSID)\n",
    1037                                           codec->core.chip_name, name);
    1038 #endif
    1039                                 break;
    1040                         }
    1041                 }
    1042         }
    1043 
     1057        codec_dbg(codec, "%s: picked fixup %s for %s %04x:%04x\n",
     1058                  codec->core.chip_name, name ? name : "",
     1059                  type, q->subvendor, q->subdevice);
     1060 found:
    10441061        codec->fixup_id = id;
    1045         if (id >= 0) {
    1046                 codec->fixup_list = fixlist;
    1047                 codec->fixup_name = name;
    1048         }
     1062        codec->fixup_list = fixlist;
     1063        codec->fixup_name = name;
    10491064}
    10501065EXPORT_SYMBOL_GPL(snd_hda_pick_fixup);
  • GPL/trunk/alsa-kernel/pci/hda/hda_bind.c

    r703 r717  
    159159        }
    160160
     161        refcount_dec(&codec->pcm_ref);
     162        snd_hda_codec_disconnect_pcms(codec);
     163        wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref));
     164        snd_power_sync_ref(codec->bus->card);
     165
    161166        if (codec->patch_ops.free)
    162167                codec->patch_ops.free(codec);
     
    168173static void hda_codec_driver_shutdown(struct device *dev)
    169174{
    170         struct hda_codec *codec = dev_to_hda_codec(dev);
    171 
    172         if (!pm_runtime_suspended(dev)) {
    173                 if (codec->patch_ops.reboot_notify)
    174                         codec->patch_ops.reboot_notify(codec);
    175                 snd_hda_codec_display_power(codec, false);
    176         }
     175        snd_hda_codec_shutdown(dev_to_hda_codec(dev));
    177176}
    178177
     
    309308        int err;
    310309
     310        if (codec->configured)
     311                return 0;
     312
    311313        if (is_generic_config(codec))
    312314                codec->probe_id = HDA_CODEC_ID_GENERIC;
     
    314316                codec->probe_id = 0;
    315317
    316         err = snd_hdac_device_register(&codec->core);
    317         if (err < 0)
    318                 return err;
     318        if (!device_is_registered(&codec->core.dev)) {
     319                err = snd_hdac_device_register(&codec->core);
     320                if (err < 0)
     321                        return err;
     322        }
    319323
    320324        if (!codec->preset)
     
    323327                err = codec_bind_generic(codec);
    324328                if (err < 0) {
    325                         codec_err(codec, "Unable to bind the codec\n");
    326                         goto error;
     329                        codec_dbg(codec, "Unable to bind the codec\n");
     330                        return err;
    327331                }
    328332        }
    329333
    330         return 0;
    331 
    332  error:
    333         snd_hdac_device_unregister(&codec->core);
    334         return err;
     334        codec->configured = 1;
     335        return 0;
    335336}
    336337EXPORT_SYMBOL_GPL(snd_hda_codec_configure);
  • GPL/trunk/alsa-kernel/pci/hda/hda_codec.c

    r703 r717  
    712712 * PCM device
    713713 */
    714 static void release_pcm(struct kref *kref)
    715 {
    716         struct hda_pcm *pcm = container_of(kref, struct hda_pcm, kref);
    717 #ifndef TARGET_OS2
    718 /* don't do this on OS/2 - results in the device being free'd and can't be re-opened */
    719         if (pcm->pcm)
    720                 snd_device_free(pcm->codec->card, pcm->pcm);
    721 #endif
    722         clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits);
    723         kfree(pcm->name);
    724         kfree(pcm);
    725 }
    726714
    727715void snd_hda_codec_pcm_put(struct hda_pcm *pcm)
    728716{
    729         kref_put(&pcm->kref, release_pcm);
     717        if (refcount_dec_and_test(&pcm->codec->pcm_ref))
     718                wake_up(&pcm->codec->remove_sleep);
    730719}
    731720EXPORT_SYMBOL_GPL(snd_hda_codec_pcm_put);
     
    742731
    743732        pcm->codec = codec;
    744         kref_init(&pcm->kref);
    745733        va_start(args, fmt);
    746734        pcm->name = kvasprintf(GFP_KERNEL, fmt, args);
     
    752740
    753741        list_add_tail(&pcm->list, &codec->pcm_list_head);
     742        refcount_inc(&codec->pcm_ref);
    754743        return pcm;
    755744}
     
    759748 * codec destructor
    760749 */
    761 static void codec_release_pcms(struct hda_codec *codec)
    762 {
    763         struct hda_pcm *pcm, *n;
    764 
    765         list_for_each_entry_safe(pcm, n, &codec->pcm_list_head, list, struct hda_pcm) {
    766                 list_del_init(&pcm->list);
     750void snd_hda_codec_disconnect_pcms(struct hda_codec *codec)
     751{
     752        struct hda_pcm *pcm;
     753
     754        list_for_each_entry(pcm, &codec->pcm_list_head, list, struct hda_pcm) {
     755                if (pcm->disconnected)
     756                        continue;
    767757                if (pcm->pcm)
    768758                        snd_device_disconnect(codec->card, pcm->pcm);
    769759                snd_hda_codec_pcm_put(pcm);
     760                pcm->disconnected = 1;
     761        }
     762}
     763
     764static void codec_release_pcms(struct hda_codec *codec)
     765{
     766        struct hda_pcm *pcm, *n;
     767
     768        list_for_each_entry_safe(pcm, n, &codec->pcm_list_head, list, struct hda_pcm) {
     769                list_del(&pcm->list);
     770#ifndef TARGET_OS2
     771                /* don't do this on OS/2 - results in the device being free'd and can't be re-opened */
     772                if (pcm->pcm)
     773                        snd_device_free(pcm->codec->card, pcm->pcm);
     774#endif
     775                clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits);
     776                kfree(pcm->name);
     777                kfree(pcm);
    770778        }
    771779}
     
    780788        }
    781789
     790        snd_hda_codec_disconnect_pcms(codec);
    782791        cancel_delayed_work_sync(&codec->jackpoll_work);
    783792        if (!codec->in_freeing)
     
    802811        remove_conn_list(codec);
    803812        snd_hdac_regmap_exit(&codec->core);
     813        codec->configured = 0;
     814        refcount_set(&codec->pcm_ref, 1); /* reset refcount */
    804815}
    805816EXPORT_SYMBOL_GPL(snd_hda_codec_cleanup_for_unbind);
     
    968979        INIT_LIST_HEAD(&codec->conn_list);
    969980        INIT_LIST_HEAD(&codec->pcm_list_head);
     981        refcount_set(&codec->pcm_ref, 1);
     982        init_waitqueue_head(&codec->remove_sleep);
    970983
    971984        INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work);
     
    17371750        int i;
    17381751        struct hda_nid_item *items = codec->mixers.list;
     1752
     1753        down_write(&codec->card->controls_rwsem);
    17391754        for (i = 0; i < codec->mixers.used; i++)
    17401755                snd_ctl_remove(codec->card, items[i].kctl);
     1756        up_write(&codec->card->controls_rwsem);
    17411757        snd_array_free(&codec->mixers);
    17421758        snd_array_free(&codec->nids);
     
    29983014                           NULL)
    29993015};
     3016
     3017/* suspend the codec at shutdown; called from driver's shutdown callback */
     3018void snd_hda_codec_shutdown(struct hda_codec *codec)
     3019{
     3020        struct hda_pcm *cpcm;
     3021
     3022        /* Skip the shutdown if codec is not registered */
     3023        if (!codec->registered)
     3024                return;
     3025
     3026        list_for_each_entry(cpcm, &codec->pcm_list_head, list, struct hda_pcm)
     3027                snd_pcm_suspend_all(cpcm->pcm);
     3028
     3029        pm_runtime_force_suspend(hda_codec_dev(codec));
     3030        pm_runtime_disable(hda_codec_dev(codec));
     3031}
    30003032
    30013033/*
  • GPL/trunk/alsa-kernel/pci/hda/hda_controller.c

    r695 r717  
    2626#include <sound/initval.h>
    2727#include "hda_controller.h"
     28#include "hda_local.h"
    2829
    2930#ifndef TARGET_OS2
     
    523524
    524525                nsec = timecounter_read(&azx_dev->core.tc);
    525                 nsec = div_u64(nsec, 3); /* can be optimized */
    526526                if (audio_tstamp_config->report_delay)
    527527                        nsec = azx_adjust_codec_delay(substream, nsec);
     
    690690}
    691691
    692 #ifndef TARGET_OS2
    693 static int azx_pcm_mmap(struct snd_pcm_substream *substream,
    694                         struct vm_area_struct *area)
    695 {
    696         struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
    697         struct azx *chip = apcm->chip;
    698         if (chip->ops->pcm_mmap_prepare)
    699                 chip->ops->pcm_mmap_prepare(substream, area);
    700         return snd_pcm_lib_default_mmap(substream, area);
    701 }
    702 #else
    703 #define azx_pcm_mmap    NULL
    704 #endif
    705 
    706692static const struct snd_pcm_ops azx_pcm_ops = {
    707693        .open = azx_pcm_open,
     
    713699        .pointer = azx_pcm_pointer,
    714700        .get_time_info =  azx_get_time_info,
    715         .mmap = azx_pcm_mmap,
    716701};
    717702
     
    778763                size = MAX_PREALLOC_SIZE;
    779764        if (chip->uc_buffer)
    780                 type = SNDRV_DMA_TYPE_DEV_UC_SG;
     765                type = SNDRV_DMA_TYPE_DEV_WC_SG;
    781766        snd_pcm_set_managed_buffer_all(pcm, type, chip->card->dev,
    782767                                       size, MAX_PREALLOC_SIZE);
     
    12931278{
    12941279        struct hda_codec *codec, *next;
    1295 
    1296         /* use _safe version here since snd_hda_codec_configure() deregisters
    1297          * the device upon error and deletes itself from the bus list.
    1298          */
    1299         list_for_each_codec_safe(codec, next, &chip->bus) {
    1300                 snd_hda_codec_configure(codec);
    1301         }
    1302 
    1303         if (!azx_bus(chip)->num_codecs)
    1304                 return -ENODEV;
    1305         return 0;
     1280        int success = 0;
     1281
     1282        list_for_each_codec(codec, &chip->bus) {
     1283                if (!snd_hda_codec_configure(codec))
     1284                        success++;
     1285        }
     1286
     1287        if (success) {
     1288                /* unregister failed codecs if any codec has been probed */
     1289                list_for_each_codec_safe(codec, next, &chip->bus) {
     1290                        if (!codec->configured) {
     1291                                codec_err(codec, "Unable to configure, disabling\n");
     1292                                snd_hdac_device_unregister(&codec->core);
     1293                        }
     1294                }
     1295        }
     1296
     1297        return success ? 0 : -ENODEV;
    13061298}
    13071299EXPORT_SYMBOL_GPL(azx_codec_configure);
  • GPL/trunk/alsa-kernel/pci/hda/hda_controller.h

    r679 r717  
    4242#define AZX_DCAPS_COUNT_LPIB_DELAY  (1 << 25)   /* Take LPIB as delay */
    4343#define AZX_DCAPS_PM_RUNTIME    (1 << 26)       /* runtime PM support */
    44 /* 27 unused */
     44#define AZX_DCAPS_RETRY_PROBE   (1 << 27)       /* retry probe if no codec is configured */
    4545#define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28)   /* CORBRP clears itself after reset */
    4646#define AZX_DCAPS_NO_MSI64      (1 << 29)       /* Stick to 32-bit MSIs */
     
    7575        /* Disable msi if supported, PCI only */
    7676        int (*disable_msi_reset_irq)(struct azx *);
    77         void (*pcm_mmap_prepare)(struct snd_pcm_substream *substream,
    78                                  struct vm_area_struct *area);
    7977        /* Check if current position is acceptable */
    8078        int (*position_check)(struct azx *chip, struct azx_dev *azx_dev);
     
    142140        unsigned int uc_buffer:1; /* non-cached pages for stream buffers */
    143141        unsigned int align_buffer_size:1;
    144         unsigned int region_requested:1;
    145142        unsigned int disabled:1; /* disabled by vga_switcheroo */
    146143        unsigned int pm_prepared:1;
  • GPL/trunk/alsa-kernel/pci/hda/hda_generic.c

    r703 r717  
    9595        snd_array_free(&spec->paths);
    9696        snd_array_free(&spec->loopback_list);
     97#ifdef CONFIG_SND_HDA_GENERIC_LEDS
     98        if (spec->led_cdevs[LED_AUDIO_MUTE])
     99                led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MUTE]);
     100        if (spec->led_cdevs[LED_AUDIO_MICMUTE])
     101                led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MICMUTE]);
     102#endif
    97103}
    98104
     
    39343940                                bool micmute)
    39353941{
     3942        struct hda_gen_spec *spec = codec->spec;
    39363943        struct led_classdev *cdev;
     3944        int idx = micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE;
     3945        int err;
    39373946
    39383947        cdev = devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL);
     
    39443953        cdev->default_trigger = micmute ? "audio-micmute" : "audio-mute";
    39453954        cdev->brightness_set_blocking = callback;
    3946         cdev->brightness = ledtrig_audio_get(micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE);
     3955        cdev->brightness = ledtrig_audio_get(idx);
    39473956        cdev->flags = LED_CORE_SUSPENDRESUME;
    39483957
    3949         return devm_led_classdev_register(&codec->core.dev, cdev);
     3958        err = led_classdev_register(&codec->core.dev, cdev);
     3959        if (err < 0)
     3960                return err;
     3961        spec->led_cdevs[idx] = cdev;
     3962        return 0;
    39503963}
    39513964
     
    60166029EXPORT_SYMBOL_GPL(snd_hda_gen_free);
    60176030
    6018 /**
    6019  * snd_hda_gen_reboot_notify - Make codec enter D3 before rebooting
    6020  * @codec: the HDA codec
    6021  *
    6022  * This can be put as patch_ops reboot_notify function.
    6023  */
    6024 void snd_hda_gen_reboot_notify(struct hda_codec *codec)
    6025 {
    6026         /* Make the codec enter D3 to avoid spurious noises from the internal
    6027          * speaker during (and after) reboot
    6028          */
    6029         snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
    6030         snd_hda_codec_write(codec, codec->core.afg, 0,
    6031                             AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
    6032         msleep(10);
    6033 }
    6034 EXPORT_SYMBOL_GPL(snd_hda_gen_reboot_notify);
    6035 
    60366031#ifdef CONFIG_PM
    60376032/**
     
    60616056        .free = snd_hda_gen_free,
    60626057        .unsol_event = snd_hda_jack_unsol_event,
    6063         .reboot_notify = snd_hda_gen_reboot_notify,
    60646058#ifdef CONFIG_PM
    60656059        .check_power_status = snd_hda_gen_check_power_status,
  • GPL/trunk/alsa-kernel/pci/hda/hda_generic.h

    r695 r717  
    295295        void (*mic_autoswitch_hook)(struct hda_codec *codec,
    296296                                    struct hda_jack_callback *cb);
     297
     298        /* leds */
     299        struct led_classdev *led_cdevs[NUM_AUDIO_LEDS];
    297300};
    298301
     
    325328int snd_hda_gen_build_controls(struct hda_codec *codec);
    326329int snd_hda_gen_build_pcms(struct hda_codec *codec);
    327 void snd_hda_gen_reboot_notify(struct hda_codec *codec);
    328330
    329331/* standard jack event callbacks */
  • GPL/trunk/alsa-kernel/pci/hda/hda_intel.c

    r703 r717  
    326326#define AZX_DCAPS_PRESET_AMD_SB \
    327327        (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_AMD_WORKAROUND |\
    328          AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME)
     328         AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME |\
     329         AZX_DCAPS_RETRY_PROBE)
    329330
    330331/* quirks for Nvidia */
     
    353354                                        ((pci)->device == 0x0d0c) || \
    354355                                        ((pci)->device == 0x160c) || \
    355                                         ((pci)->device == 0x490d))
     356                                        ((pci)->device == 0x490d) || \
     357                                        ((pci)->device == 0x4f90) || \
     358                                        ((pci)->device == 0x4f91) || \
     359                                        ((pci)->device == 0x4f92))
    356360
    357361#define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
     
    656660 * data is processed.  So, we need to process it afterwords in a
    657661 * workqueue.
     662 *
     663 * Returns 1 if OK to proceed, 0 for delay handling, -1 for skipping update
    658664 */
    659665static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
    660666{
    661667        struct snd_pcm_substream *substream = azx_dev->core.substream;
     668        struct snd_pcm_runtime *runtime = substream->runtime;
    662669        int stream = substream->stream;
    663670        u32 wallclk;
    664671        unsigned int pos;
     672        snd_pcm_uframes_t hwptr, target;
    665673
    666674        wallclk = azx_readl(chip, WALLCLK) - azx_dev->core.start_wallclk;
     
    706714                return chip->bdl_pos_adj ? 0 : -1;
    707715        azx_dev->core.start_wallclk += wallclk;
     716
     717        if (azx_dev->core.no_period_wakeup)
     718                return 1; /* OK, no need to check period boundary */
     719
     720        if (runtime->hw_ptr_base != runtime->hw_ptr_interrupt)
     721                return 1; /* OK, already in hwptr updating process */
     722
     723        /* check whether the period gets really elapsed */
     724        pos = bytes_to_frames(runtime, pos);
     725        hwptr = runtime->hw_ptr_base + pos;
     726        if (hwptr < runtime->status->hw_ptr)
     727                hwptr += runtime->buffer_size;
     728        target = runtime->hw_ptr_interrupt + runtime->period_size;
     729        if (hwptr < target) {
     730                /* too early wakeup, process it later */
     731                return chip->bdl_pos_adj ? 0 : -1;
     732        }
     733
    708734        return 1; /* OK, it's fine */
    709735}
     
    882908        /* just read back the calculated value in the above */
    883909        return substream->runtime->delay;
    884 }
    885 
    886 static unsigned int azx_skl_get_dpib_pos(struct azx *chip,
    887                                          struct azx_dev *azx_dev)
    888 {
    889         return _snd_hdac_chip_readl(azx_bus(chip),
    890                                     AZX_REG_VS_SDXDPIB_XBASE +
    891                                     (AZX_REG_VS_SDXDPIB_XINTERVAL *
    892                                      azx_dev->core.index));
    893 }
    894 
    895 /* get the current DMA position with correction on SKL+ chips */
    896 static unsigned int azx_get_pos_skl(struct azx *chip, struct azx_dev *azx_dev)
    897 {
    898         /* DPIB register gives a more accurate position for playback */
    899         if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
    900                 return azx_skl_get_dpib_pos(chip, azx_dev);
    901 
    902         /* For capture, we need to read posbuf, but it requires a delay
    903          * for the possible boundary overlap; the read of DPIB fetches the
    904          * actual posbuf
    905          */
    906         udelay(20);
    907         azx_skl_get_dpib_pos(chip, azx_dev);
    908         return azx_get_pos_posbuf(chip, azx_dev);
    909910}
    910911
     
    14071408        if (bus->irq >= 0)
    14081409                free_irq(bus->irq, (void*)chip);
    1409         if (chip->msi)
    1410                 pci_disable_msi(chip->pci);
    1411 #ifdef TARGET_OS2
    1412         iounmap((void *)bus->remap_addr);
    1413 #else
    1414         iounmap(bus->remap_addr);
    1415 #endif
    14161410
    14171411        azx_free_stream_pages(chip);
     
    14191413        snd_hdac_bus_exit(bus);
    14201414
    1421         if (chip->region_requested)
    1422                 pci_release_regions(chip->pci);
    1423 
    1424         pci_disable_device(chip->pci);
    14251415#ifdef CONFIG_SND_HDA_PATCH_LOADER
    14261416        release_firmware(chip->fw);
     
    16171607                [POS_FIX_VIACOMBO] = azx_via_get_position,
    16181608                [POS_FIX_COMBO] = azx_get_pos_lpib,
    1619                 [POS_FIX_SKL] = azx_get_pos_skl,
     1609                [POS_FIX_SKL] = azx_get_pos_posbuf,
    16201610                [POS_FIX_FIFO] = azx_get_pos_fifo,
    16211611        };
     
    16551645        SND_PCI_QUIRK(0x1043, 0x1262, "ASUS W5Fm", 0x103),
    16561646        SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103),
     1647        SND_PCI_QUIRK(0x1558, 0x0351, "Schenker Dock 15", 0x105),
    16571648        /* WinFast VP200 H (Teradici) user reported broken communication */
    16581649        SND_PCI_QUIRK(0x3a21, 0x040d, "WinFast VP200 H", 0x101),
     
    17681759static void azx_probe_work(struct work_struct *work)
    17691760{
    1770         struct hda_intel *hda = container_of(work, struct hda_intel, probe_work);
     1761        struct hda_intel *hda = container_of(work, struct hda_intel, probe_work.work);
    17711762        azx_probe_continue(&hda->chip);
    17721763}
     
    18201811        hda = kzalloc(sizeof(*hda), GFP_KERNEL);
    18211812#endif
    1822         if (!hda) {
    1823                 pci_disable_device(pci);
    1824                 return -ENOMEM;
    1825         }
     1813        if (!hda)
     1814                return -ENOMEM;
    18261815
    18271816        chip = &hda->chip;
     
    18441833        assign_position_fix(chip, check_position_fix(chip, position_fix[dev]));
    18451834
    1846         check_probe_mask(chip, dev);
    1847 
    18481835        if (single_cmd < 0) /* allow fallback to single_cmd at errors */
    18491836                chip->fallback_to_single_cmd = 1;
     
    18591846
    18601847        err = azx_bus_init(chip, model[dev]);
    1861         if (err < 0) {
    1862                 pci_disable_device(pci);
     1848        if (err < 0)
    18631849                return err;
    1864         }
    18651850
    18661851        /* use the non-cached pages in non-snoop mode */
    18671852        if (!azx_snoop(chip))
    1868                 azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_UC;
     1853                azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC;
    18691854
    18701855        if (chip->driver_type == AZX_DRIVER_NVIDIA) {
     
    18721857                chip->bus.core.needs_damn_long_delay = 1;
    18731858        }
     1859
     1860        check_probe_mask(chip, dev);
    18741861
    18751862        err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
     
    18811868
    18821869        /* continue probing in work context as may trigger request module */
    1883         INIT_WORK(&hda->probe_work, azx_probe_work);
     1870        INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work);
    18841871
    18851872        *rchip = chip;
     
    19081895#endif
    19091896
     1897#ifndef TARGET_OS2
     1898        err = pcim_iomap_regions(pci, 1 << 0, "ICH HD audio");
     1899#else
    19101900        err = pci_request_regions(pci, "ICH HD audio");
     1901#endif
    19111902        if (err < 0)
    19121903                return err;
    1913         chip->region_requested = 1;
    19141904
    19151905        bus->addr = pci_resource_start(pci, 0);
     1906#ifndef TARGET_OS2
     1907        bus->remap_addr = pcim_iomap_table(pci)[0];
     1908#else
    19161909        bus->remap_addr = pci_ioremap_bar(pci, 0);
    1917         if (bus->remap_addr == NULL) {
    1918                 dev_err(card->dev, "ioremap error\n");
    1919                 return -ENXIO;
    1920         }
    1921 
     1910#endif
    19221911        if (chip->driver_type == AZX_DRIVER_SKL)
    19231912                snd_hdac_bus_parse_capabilities(bus);
     
    21012090}
    21022091
    2103 static void pcm_mmap_prepare(struct snd_pcm_substream *substream,
    2104                              struct vm_area_struct *area)
    2105 {
    2106 #ifdef CONFIG_X86
    2107         struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
    2108         struct azx *chip = apcm->chip;
    2109         if (chip->uc_buffer)
    2110                 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
    2111 #endif
    2112 }
    2113 
    21142092/* Denylist for skipping the whole probe:
    21152093 * some HD-audio PCI entries are exposed without any codecs, and such devices
     
    21252103static const struct hda_controller_ops pci_hda_ops = {
    21262104        .disable_msi_reset_irq = disable_msi_reset_irq,
    2127         .pcm_mmap_prepare = pcm_mmap_prepare,
    21282105        .position_check = azx_position_check,
    21292106};
     
    22192196#else
    22202197        if (schedule_probe)
    2221                 schedule_work(&hda->probe_work);
     2198                schedule_delayed_work(&hda->probe_work, 0);
    22222199#endif
    22232200
     
    23062283        int err;
    23072284
     2285        if (chip->disabled || hda->init_failed)
     2286                return -EIO;
     2287        if (hda->probe_retry)
     2288                goto probe_retry;
     2289
    23082290        to_hda_bus(bus)->bus_probing = 1;
    23092291        hda->probe_continued = 1;
     
    23672349        }
    23682350#endif
     2351
     2352 probe_retry:
    23692353        if (bus->codec_mask && !(probe_only[dev] & 1)) {
    23702354                err = azx_codec_configure(chip);
    2371                 if (err < 0)
     2355                if (err) {
     2356                        if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) &&
     2357                            ++hda->probe_retry < 60) {
     2358                                schedule_delayed_work(&hda->probe_work,
     2359                                                      msecs_to_jiffies(1000));
     2360                                return 0; /* keep things up */
     2361                        }
     2362                        dev_err(chip->card->dev, "Cannot probe codecs, giving up\n");
    23722363                        goto out_free;
     2364                }
    23732365        }
    23742366
     
    23922384out_free:
    23932385        if (err < 0) {
    2394                 azx_free(chip);
     2386                pci_set_drvdata(pci, NULL);
     2387                snd_card_free(chip->card);
    23952388                return err;
    23962389        }
     
    24002393        complete_all(&hda->probe_wait);
    24012394        to_hda_bus(bus)->bus_probing = 0;
     2395        hda->probe_retry = 0;
    24022396        return 0;
    24032397}
     
    24252419                 */
    24262420                device_unlock(&pci->dev);
    2427                 cancel_work_sync(&hda->probe_work);
     2421                cancel_delayed_work_sync(&hda->probe_work);
    24282422                device_lock(&pci->dev);
    24292423
     
    25342528        /* DG1 */
    25352529        { PCI_DEVICE(0x8086, 0x490d),
     2530          .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
     2531        /* DG2 */
     2532        { PCI_DEVICE(0x8086, 0x4f90),
     2533          .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
     2534        { PCI_DEVICE(0x8086, 0x4f91),
     2535          .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
     2536        { PCI_DEVICE(0x8086, 0x4f92),
    25362537          .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
    25372538        /* Alderlake-S */
  • GPL/trunk/alsa-kernel/pci/hda/hda_intel.h

    r679 r717  
    1515        /* sync probing */
    1616        struct completion probe_wait;
    17         struct work_struct probe_work;
     17        struct delayed_work probe_work;
    1818
    1919        /* card list (for power_save trigger) */
     
    3131
    3232        bool need_i915_power:1; /* the hda controller needs i915 power */
     33
     34        int probe_retry;        /* being probe-retry */
    3335};
    3436
  • GPL/trunk/alsa-kernel/pci/hda/hda_local.h

    r703 r717  
    138138void snd_hda_codec_register(struct hda_codec *codec);
    139139void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec);
     140void snd_hda_codec_disconnect_pcms(struct hda_codec *codec);
    140141
    141142#define snd_hda_regmap_sync(codec)      snd_hdac_regmap_sync(&(codec)->core)
     
    364365                           const struct hda_pintbl *cfg);
    365366void snd_hda_apply_fixup(struct hda_codec *codec, int action);
     367void __snd_hda_apply_fixup(struct hda_codec *codec, int id, int action, int depth);
    366368void snd_hda_pick_fixup(struct hda_codec *codec,
    367369                        const struct hda_model_fixup *models,
     
    453455        for ((nid) = (codec)->core.start_nid; (nid) < (codec)->core.end_nid; (nid)++)
    454456
     457/* Set the codec power_state flag to indicate to allow unsol event handling;
     458 * see hda_codec_unsol_event() in hda_bind.c.  Calling this might confuse the
     459 * state tracking, so use with care.
     460 */
     461static inline void snd_hda_codec_allow_unsol_events(struct hda_codec *codec)
     462{
     463        codec->core.dev.power.power_state = PMSG_ON;
     464}
     465
    455466/*
    456467 * get widget capabilities
     
    629640                                             hda_nid_t nid,
    630641                                             unsigned int power_state);
     642
     643void snd_hda_codec_shutdown(struct hda_codec *codec);
    631644
    632645/*
  • GPL/trunk/alsa-kernel/pci/hda/patch_analog.c

    r679 r717  
    7676#endif
    7777
    78 
     78#ifdef CONFIG_PM
    7979static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
    8080                                hda_nid_t hp)
     
    116116}
    117117
    118 static void ad198x_shutup(struct hda_codec *codec)
     118static int ad198x_suspend(struct hda_codec *codec)
    119119{
    120120        snd_hda_shutup_pins(codec);
    121121        ad198x_power_eapd(codec);
    122 }
    123 
    124 #ifdef CONFIG_PM
    125 static int ad198x_suspend(struct hda_codec *codec)
    126 {
    127         ad198x_shutup(codec);
    128122        return 0;
    129123}
     
    172166        .suspend = ad198x_suspend,
    173167#endif
    174         .reboot_notify = ad198x_shutup,
    175168};
    176169
  • GPL/trunk/alsa-kernel/pci/hda/patch_ca0132.c

    r703 r717  
    22762276{
    22772277        struct ca0132_spec *spec = codec->spec;
    2278         int status = -1;
     2278        int status;
    22792279        unsigned int scp_send_size = 0;
    22802280        unsigned int total_size;
     
    97829782}
    97839783
    9784 static void ca0132_reboot_notify(struct hda_codec *codec)
    9785 {
    9786         codec->patch_ops.free(codec);
    9787 }
    9788 
    97899784#ifdef CONFIG_PM
    97909785static int ca0132_suspend(struct hda_codec *codec)
     
    98069801        .suspend = ca0132_suspend,
    98079802#endif
    9808         .reboot_notify = ca0132_reboot_notify,
    98099803};
    98109804
  • GPL/trunk/alsa-kernel/pci/hda/patch_cirrus.c

    r695 r717  
    1010#include <linux/module.h>
    1111#include <sound/core.h>
    12 #include <linux/mutex.h>
    1312#include <linux/pci.h>
    1413#include <sound/tlv.h>
     
    2625 */
    2726
    28 #define CS42L42_HP_CH     (2U)
    29 #define CS42L42_HS_MIC_CH (1U)
    30 
    3127struct cs_spec {
    3228        struct hda_gen_spec gen;
     
    4743        int (*spdif_sw_put)(struct snd_kcontrol *kcontrol,
    4844                            struct snd_ctl_elem_value *ucontrol);
    49 
    50         unsigned int cs42l42_hp_jack_in:1;
    51         unsigned int cs42l42_mic_jack_in:1;
    52         unsigned int cs42l42_volume_init:1;
    53         char cs42l42_hp_volume[CS42L42_HP_CH];
    54         char cs42l42_hs_mic_volume[CS42L42_HS_MIC_CH];
    55 
    56         struct mutex cs8409_i2c_mux;
    57 
    58         /* verb exec op override */
    59         int (*exec_verb)(struct hdac_device *dev, unsigned int cmd,
    60                                  unsigned int flags, unsigned int *res);
    6145};
    6246
     
    570554                .chain_id = CS420X_GPIO_13,
    571555        },
    572 #ifdef TARGET_OS2xxx
     556#ifndef TARGET_OS2
    573557        [CS420X_MBP81] = {
    574558                .type = HDA_FIXUP_VERBS,
     
    12461230}
    12471231
    1248 /* Cirrus Logic CS8409 HDA bridge with
    1249  * companion codec CS42L42
    1250  */
    1251 #define CS8409_VENDOR_NID 0x47
    1252 
    1253 #define CS8409_CS42L42_HP_PIN_NID       0x24
    1254 #define CS8409_CS42L42_SPK_PIN_NID      0x2c
    1255 #define CS8409_CS42L42_AMIC_PIN_NID     0x34
    1256 #define CS8409_CS42L42_DMIC_PIN_NID     0x44
    1257 #define CS8409_CS42L42_DMIC_ADC_PIN_NID 0x22
    1258 
    1259 #define CS42L42_HSDET_AUTO_DONE 0x02
    1260 #define CS42L42_HSTYPE_MASK             0x03
    1261 
    1262 #define CS42L42_JACK_INSERTED   0x0C
    1263 #define CS42L42_JACK_REMOVED    0x00
    1264 
    1265 #define GPIO3_INT (1 << 3)
    1266 #define GPIO4_INT (1 << 4)
    1267 #define GPIO5_INT (1 << 5)
    1268 
    1269 #define CS42L42_I2C_ADDR        (0x48 << 1)
    1270 
    1271 #define CIR_I2C_ADDR    0x0059
    1272 #define CIR_I2C_DATA    0x005A
    1273 #define CIR_I2C_CTRL    0x005B
    1274 #define CIR_I2C_STATUS  0x005C
    1275 #define CIR_I2C_QWRITE  0x005D
    1276 #define CIR_I2C_QREAD   0x005E
    1277 
    1278 #define CS8409_CS42L42_HP_VOL_REAL_MIN   (-63)
    1279 #define CS8409_CS42L42_HP_VOL_REAL_MAX   (0)
    1280 #define CS8409_CS42L42_AMIC_VOL_REAL_MIN (-97)
    1281 #define CS8409_CS42L42_AMIC_VOL_REAL_MAX (12)
    1282 #define CS8409_CS42L42_REG_HS_VOLUME_CHA (0x2301)
    1283 #define CS8409_CS42L42_REG_HS_VOLUME_CHB (0x2303)
    1284 #define CS8409_CS42L42_REG_AMIC_VOLUME   (0x1D03)
    1285 
    1286 struct cs8409_i2c_param {
    1287         unsigned int addr;
    1288         unsigned int reg;
    1289 };
    1290 
    1291 struct cs8409_cir_param {
    1292         unsigned int nid;
    1293         unsigned int cir;
    1294         unsigned int coeff;
    1295 };
    1296 
    1297 enum {
    1298         CS8409_BULLSEYE,
    1299         CS8409_WARLOCK,
    1300         CS8409_CYBORG,
    1301         CS8409_FIXUPS,
    1302 };
    1303 
    1304 static void cs8409_cs42l42_fixups(struct hda_codec *codec,
    1305                                     const struct hda_fixup *fix, int action);
    1306 static int cs8409_cs42l42_exec_verb(struct hdac_device *dev,
    1307                 unsigned int cmd, unsigned int flags, unsigned int *res);
    1308 
    1309 /* Dell Inspiron models with cs8409/cs42l42 */
    1310 static const struct hda_model_fixup cs8409_models[] = {
    1311         { .id = CS8409_BULLSEYE, .name = "bullseye" },
    1312         { .id = CS8409_WARLOCK, .name = "warlock" },
    1313         { .id = CS8409_CYBORG, .name = "cyborg" },
    1314         {0}
    1315 };
    1316 
    1317 /* Dell Inspiron platforms
    1318  * with cs8409 bridge and cs42l42 codec
    1319  */
    1320 static const struct snd_pci_quirk cs8409_fixup_tbl[] = {
    1321         SND_PCI_QUIRK(0x1028, 0x0A11, "Bullseye", CS8409_BULLSEYE),
    1322         SND_PCI_QUIRK(0x1028, 0x0A12, "Bullseye", CS8409_BULLSEYE),
    1323         SND_PCI_QUIRK(0x1028, 0x0A23, "Bullseye", CS8409_BULLSEYE),
    1324         SND_PCI_QUIRK(0x1028, 0x0A24, "Bullseye", CS8409_BULLSEYE),
    1325         SND_PCI_QUIRK(0x1028, 0x0A25, "Bullseye", CS8409_BULLSEYE),
    1326         SND_PCI_QUIRK(0x1028, 0x0A29, "Bullseye", CS8409_BULLSEYE),
    1327         SND_PCI_QUIRK(0x1028, 0x0A2A, "Bullseye", CS8409_BULLSEYE),
    1328         SND_PCI_QUIRK(0x1028, 0x0A2B, "Bullseye", CS8409_BULLSEYE),
    1329         SND_PCI_QUIRK(0x1028, 0x0AB0, "Warlock", CS8409_WARLOCK),
    1330         SND_PCI_QUIRK(0x1028, 0x0AB2, "Warlock", CS8409_WARLOCK),
    1331         SND_PCI_QUIRK(0x1028, 0x0AB1, "Warlock", CS8409_WARLOCK),
    1332         SND_PCI_QUIRK(0x1028, 0x0AB3, "Warlock", CS8409_WARLOCK),
    1333         SND_PCI_QUIRK(0x1028, 0x0AB4, "Warlock", CS8409_WARLOCK),
    1334         SND_PCI_QUIRK(0x1028, 0x0AB5, "Warlock", CS8409_WARLOCK),
    1335         SND_PCI_QUIRK(0x1028, 0x0AD9, "Warlock", CS8409_WARLOCK),
    1336         SND_PCI_QUIRK(0x1028, 0x0ADA, "Warlock", CS8409_WARLOCK),
    1337         SND_PCI_QUIRK(0x1028, 0x0ADB, "Warlock", CS8409_WARLOCK),
    1338         SND_PCI_QUIRK(0x1028, 0x0ADC, "Warlock", CS8409_WARLOCK),
    1339         SND_PCI_QUIRK(0x1028, 0x0AF4, "Warlock", CS8409_WARLOCK),
    1340         SND_PCI_QUIRK(0x1028, 0x0AF5, "Warlock", CS8409_WARLOCK),
    1341         SND_PCI_QUIRK(0x1028, 0x0A77, "Cyborg", CS8409_CYBORG),
    1342         SND_PCI_QUIRK(0x1028, 0x0A78, "Cyborg", CS8409_CYBORG),
    1343         SND_PCI_QUIRK(0x1028, 0x0A79, "Cyborg", CS8409_CYBORG),
    1344         SND_PCI_QUIRK(0x1028, 0x0A7A, "Cyborg", CS8409_CYBORG),
    1345         SND_PCI_QUIRK(0x1028, 0x0A7D, "Cyborg", CS8409_CYBORG),
    1346         SND_PCI_QUIRK(0x1028, 0x0A7E, "Cyborg", CS8409_CYBORG),
    1347         SND_PCI_QUIRK(0x1028, 0x0A7F, "Cyborg", CS8409_CYBORG),
    1348         SND_PCI_QUIRK(0x1028, 0x0A80, "Cyborg", CS8409_CYBORG),
    1349         SND_PCI_QUIRK(0x1028, 0x0ADF, "Cyborg", CS8409_CYBORG),
    1350         SND_PCI_QUIRK(0x1028, 0x0AE0, "Cyborg", CS8409_CYBORG),
    1351         SND_PCI_QUIRK(0x1028, 0x0AE1, "Cyborg", CS8409_CYBORG),
    1352         SND_PCI_QUIRK(0x1028, 0x0AE2, "Cyborg", CS8409_CYBORG),
    1353         SND_PCI_QUIRK(0x1028, 0x0AE9, "Cyborg", CS8409_CYBORG),
    1354         SND_PCI_QUIRK(0x1028, 0x0AEA, "Cyborg", CS8409_CYBORG),
    1355         SND_PCI_QUIRK(0x1028, 0x0AEB, "Cyborg", CS8409_CYBORG),
    1356         SND_PCI_QUIRK(0x1028, 0x0AEC, "Cyborg", CS8409_CYBORG),
    1357         SND_PCI_QUIRK(0x1028, 0x0AED, "Cyborg", CS8409_CYBORG),
    1358         SND_PCI_QUIRK(0x1028, 0x0AEE, "Cyborg", CS8409_CYBORG),
    1359         SND_PCI_QUIRK(0x1028, 0x0AEF, "Cyborg", CS8409_CYBORG),
    1360         SND_PCI_QUIRK(0x1028, 0x0AF0, "Cyborg", CS8409_CYBORG),
    1361         {0} /* terminator */
    1362 };
    1363 
    1364 static const struct hda_verb cs8409_cs42l42_init_verbs[] = {
    1365         { 0x01, AC_VERB_SET_GPIO_WAKE_MASK, 0x0018 }, /* WAKE from GPIO 3,4 */
    1366         { 0x47, AC_VERB_SET_PROC_STATE, 0x0001 },     /* Enable VPW processing  */
    1367         { 0x47, AC_VERB_SET_COEF_INDEX, 0x0002 },     /* Configure GPIO 6,7 */
    1368         { 0x47, AC_VERB_SET_PROC_COEF,  0x0080 },     /* I2C mode */
    1369         { 0x47, AC_VERB_SET_COEF_INDEX, 0x005b },     /* Set I2C bus speed */
    1370         { 0x47, AC_VERB_SET_PROC_COEF,  0x0200 },     /* 100kHz I2C_STO = 2 */
    1371         {0} /* terminator */
    1372 };
    1373 
    1374 static const struct hda_pintbl cs8409_cs42l42_pincfgs[] = {
    1375         { 0x24, 0x042120f0 }, /* ASP-1-TX */
    1376         { 0x34, 0x04a12050 }, /* ASP-1-RX */
    1377         { 0x2c, 0x901000f0 }, /* ASP-2-TX */
    1378         { 0x44, 0x90a00090 }, /* DMIC-1 */
    1379         {0} /* terminator */
    1380 };
    1381 
    1382 static const struct hda_fixup cs8409_fixups[] = {
    1383         [CS8409_BULLSEYE] = {
    1384                 .type = HDA_FIXUP_PINS,
    1385                 .v.pins = cs8409_cs42l42_pincfgs,
    1386                 .chained = true,
    1387                 .chain_id = CS8409_FIXUPS,
    1388         },
    1389         [CS8409_WARLOCK] = {
    1390                 .type = HDA_FIXUP_PINS,
    1391                 .v.pins = cs8409_cs42l42_pincfgs,
    1392                 .chained = true,
    1393                 .chain_id = CS8409_FIXUPS,
    1394         },
    1395         [CS8409_CYBORG] = {
    1396                 .type = HDA_FIXUP_PINS,
    1397                 .v.pins = cs8409_cs42l42_pincfgs,
    1398                 .chained = true,
    1399                 .chain_id = CS8409_FIXUPS,
    1400         },
    1401         [CS8409_FIXUPS] = {
    1402                 .type = HDA_FIXUP_FUNC,
    1403                 .v.func = cs8409_cs42l42_fixups,
    1404         },
    1405 };
    1406 
    1407 /* Vendor specific HW configuration for CS42L42 */
    1408 static const struct cs8409_i2c_param cs42l42_init_reg_seq[] = {
    1409         { 0x1010, 0xB0 },
    1410         { 0x1D01, 0x00 },
    1411         { 0x1D02, 0x06 },
    1412         { 0x1D03, 0x00 },
    1413         { 0x1107, 0x01 },
    1414         { 0x1009, 0x02 },
    1415         { 0x1007, 0x03 },
    1416         { 0x1201, 0x00 },
    1417         { 0x1208, 0x13 },
    1418         { 0x1205, 0xFF },
    1419         { 0x1206, 0x00 },
    1420         { 0x1207, 0x20 },
    1421         { 0x1202, 0x0D },
    1422         { 0x2A02, 0x02 },
    1423         { 0x2A03, 0x00 },
    1424         { 0x2A04, 0x00 },
    1425         { 0x2A05, 0x02 },
    1426         { 0x2A06, 0x00 },
    1427         { 0x2A07, 0x20 },
    1428         { 0x2A08, 0x02 },
    1429         { 0x2A09, 0x00 },
    1430         { 0x2A0A, 0x80 },
    1431         { 0x2A0B, 0x02 },
    1432         { 0x2A0C, 0x00 },
    1433         { 0x2A0D, 0xA0 },
    1434         { 0x2A01, 0x0C },
    1435         { 0x2902, 0x01 },
    1436         { 0x2903, 0x02 },
    1437         { 0x2904, 0x00 },
    1438         { 0x2905, 0x00 },
    1439         { 0x2901, 0x01 },
    1440         { 0x1101, 0x0A },
    1441         { 0x1102, 0x84 },
    1442         { 0x2301, 0x00 },
    1443         { 0x2303, 0x00 },
    1444         { 0x2302, 0x3f },
    1445         { 0x2001, 0x03 },
    1446         { 0x1B75, 0xB6 },
    1447         { 0x1B73, 0xC2 },
    1448         { 0x1129, 0x01 },
    1449         { 0x1121, 0xF3 },
    1450         { 0x1103, 0x20 },
    1451         { 0x1105, 0x00 },
    1452         { 0x1112, 0xC0 },
    1453         { 0x1113, 0x80 },
    1454         { 0x1C03, 0xC0 },
    1455         { 0x1105, 0x00 },
    1456         { 0x1112, 0xC0 },
    1457         { 0x1101, 0x02 },
    1458         {0} /* Terminator */
    1459 };
    1460 
    1461 /* Vendor specific hw configuration for CS8409 */
    1462 static const struct cs8409_cir_param cs8409_cs42l42_hw_cfg[] = {
    1463         { 0x47, 0x00, 0xb008 }, /* +PLL1/2_EN, +I2C_EN */
    1464         { 0x47, 0x01, 0x0002 }, /* ASP1/2_EN=0, ASP1_STP=1 */
    1465         { 0x47, 0x02, 0x0a80 }, /* ASP1/2_BUS_IDLE=10, +GPIO_I2C */
    1466         { 0x47, 0x19, 0x0800 }, /* ASP1.A: TX.LAP=0, TX.LSZ=24 bits, TX.LCS=0 */
    1467         { 0x47, 0x1a, 0x0820 }, /* ASP1.A: TX.RAP=0, TX.RSZ=24 bits, TX.RCS=32 */
    1468         { 0x47, 0x29, 0x0800 }, /* ASP2.A: TX.LAP=0, TX.LSZ=24 bits, TX.LCS=0 */
    1469         { 0x47, 0x2a, 0x2800 }, /* ASP2.A: TX.RAP=1, TX.RSZ=24 bits, TX.RCS=0 */
    1470         { 0x47, 0x39, 0x0800 }, /* ASP1.A: RX.LAP=0, RX.LSZ=24 bits, RX.LCS=0 */
    1471         { 0x47, 0x3a, 0x0800 }, /* ASP1.A: RX.RAP=0, RX.RSZ=24 bits, RX.RCS=0 */
    1472         { 0x47, 0x03, 0x8000 }, /* ASP1: LCHI = 00h */
    1473         { 0x47, 0x04, 0x28ff }, /* ASP1: MC/SC_SRCSEL=PLL1, LCPR=FFh */
    1474         { 0x47, 0x05, 0x0062 }, /* ASP1: MCEN=0, FSD=011, SCPOL_IN/OUT=0, SCDIV=1:4 */
    1475         { 0x47, 0x06, 0x801f }, /* ASP2: LCHI=1Fh */
    1476         { 0x47, 0x07, 0x283f }, /* ASP2: MC/SC_SRCSEL=PLL1, LCPR=3Fh */
    1477         { 0x47, 0x08, 0x805c }, /* ASP2: 5050=1, MCEN=0, FSD=010, SCPOL_IN/OUT=1, SCDIV=1:16 */
    1478         { 0x47, 0x09, 0x0023 }, /* DMIC1_MO=10b, DMIC1/2_SR=1 */
    1479         { 0x47, 0x0a, 0x0000 }, /* ASP1/2_BEEP=0 */
    1480         { 0x47, 0x01, 0x0062 }, /* ASP1/2_EN=1, ASP1_STP=1 */
    1481         { 0x47, 0x00, 0x9008 }, /* -PLL2_EN */
    1482         { 0x47, 0x68, 0x0000 }, /* TX2.A: pre-scale att.=0 dB */
    1483         { 0x47, 0x82, 0xfc03 }, /* ASP1/2_xxx_EN=1, ASP1/2_MCLK_EN=0, DMIC1_SCL_EN=1 */
    1484         { 0x47, 0xc0, 0x9999 }, /* test mode on */
    1485         { 0x47, 0xc5, 0x0000 }, /* GPIO hysteresis = 30 us */
    1486         { 0x47, 0xc0, 0x0000 }, /* test mode off */
    1487         {0} /* Terminator */
    1488 };
    1489 
    1490 static const struct cs8409_cir_param cs8409_cs42l42_bullseye_atn[] = {
    1491         { 0x47, 0x65, 0x4000 }, /* EQ_SEL=1, EQ1/2_EN=0 */
    1492         { 0x47, 0x64, 0x4000 }, /* +EQ_ACC */
    1493         { 0x47, 0x65, 0x4010 }, /* +EQ2_EN */
    1494         { 0x47, 0x63, 0x0647 }, /* EQ_DATA_HI=0x0647 */
    1495         { 0x47, 0x64, 0xc0c7 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=0, EQ_DATA_LO=0x67 */
    1496         { 0x47, 0x63, 0x0647 }, /* EQ_DATA_HI=0x0647 */
    1497         { 0x47, 0x64, 0xc1c7 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=1, EQ_DATA_LO=0x67 */
    1498         { 0x47, 0x63, 0xf370 }, /* EQ_DATA_HI=0xf370 */
    1499         { 0x47, 0x64, 0xc271 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=2, EQ_DATA_LO=0x71 */
    1500         { 0x47, 0x63, 0x1ef8 }, /* EQ_DATA_HI=0x1ef8 */
    1501         { 0x47, 0x64, 0xc348 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=3, EQ_DATA_LO=0x48 */
    1502         { 0x47, 0x63, 0xc110 }, /* EQ_DATA_HI=0xc110 */
    1503         { 0x47, 0x64, 0xc45a }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=4, EQ_DATA_LO=0x5a */
    1504         { 0x47, 0x63, 0x1f29 }, /* EQ_DATA_HI=0x1f29 */
    1505         { 0x47, 0x64, 0xc574 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=5, EQ_DATA_LO=0x74 */
    1506         { 0x47, 0x63, 0x1d7a }, /* EQ_DATA_HI=0x1d7a */
    1507         { 0x47, 0x64, 0xc653 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=6, EQ_DATA_LO=0x53 */
    1508         { 0x47, 0x63, 0xc38c }, /* EQ_DATA_HI=0xc38c */
    1509         { 0x47, 0x64, 0xc714 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=7, EQ_DATA_LO=0x14 */
    1510         { 0x47, 0x63, 0x1ca3 }, /* EQ_DATA_HI=0x1ca3 */
    1511         { 0x47, 0x64, 0xc8c7 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=8, EQ_DATA_LO=0xc7 */
    1512         { 0x47, 0x63, 0xc38c }, /* EQ_DATA_HI=0xc38c */
    1513         { 0x47, 0x64, 0xc914 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=9, EQ_DATA_LO=0x14 */
    1514         { 0x47, 0x64, 0x0000 }, /* -EQ_ACC, -EQ_WRT */
    1515         {0} /* Terminator */
    1516 };
    1517 
    1518 /**
    1519  * cs8409_enable_i2c_clock - Enable I2C clocks
    1520  * @codec: the codec instance
    1521  * @enable: Enable or disable I2C clocks
    1522  *
    1523  * Enable or Disable I2C clocks.
    1524  */
    1525 static void cs8409_enable_i2c_clock(struct hda_codec *codec, unsigned int enable)
    1526 {
    1527         unsigned int retval;
    1528         unsigned int newval;
    1529 
    1530         retval = cs_vendor_coef_get(codec, 0x0);
    1531         newval = (enable) ? (retval | 0x8) : (retval & 0xfffffff7);
    1532         cs_vendor_coef_set(codec, 0x0, newval);
    1533 }
    1534 
    1535 /**
    1536  * cs8409_i2c_wait_complete - Wait for I2C transaction
    1537  * @codec: the codec instance
    1538  *
    1539  * Wait for I2C transaction to complete.
    1540  * Return -1 if transaction wait times out.
    1541  */
    1542 static int cs8409_i2c_wait_complete(struct hda_codec *codec)
    1543 {
    1544         int repeat = 5;
    1545         unsigned int retval;
    1546 
    1547         do {
    1548                 retval = cs_vendor_coef_get(codec, CIR_I2C_STATUS);
    1549                 if ((retval & 0x18) != 0x18) {
    1550                         usleep_range(2000, 4000);
    1551                         --repeat;
    1552                 } else
    1553                         return 0;
    1554 
    1555         } while (repeat);
    1556 
    1557         return -1;
    1558 }
    1559 
    1560 /**
    1561  * cs8409_i2c_read - CS8409 I2C Read.
    1562  * @codec: the codec instance
    1563  * @i2c_address: I2C Address
    1564  * @i2c_reg: Register to read
    1565  * @paged: Is a paged transaction
    1566  *
    1567  * CS8409 I2C Read.
    1568  * Returns negative on error, otherwise returns read value in bits 0-7.
    1569  */
    1570 static int cs8409_i2c_read(struct hda_codec *codec,
    1571                 unsigned int i2c_address,
    1572                 unsigned int i2c_reg,
    1573                 unsigned int paged)
    1574 {
    1575         unsigned int i2c_reg_data;
    1576         unsigned int read_data;
    1577 
    1578         cs8409_enable_i2c_clock(codec, 1);
    1579         cs_vendor_coef_set(codec, CIR_I2C_ADDR, i2c_address);
    1580 
    1581         if (paged) {
    1582                 cs_vendor_coef_set(codec, CIR_I2C_QWRITE, i2c_reg >> 8);
    1583                 if (cs8409_i2c_wait_complete(codec) < 0) {
    1584                         codec_err(codec,
    1585                                 "%s() Paged Transaction Failed 0x%02x : 0x%04x\n",
    1586                                 __func__, i2c_address, i2c_reg);
    1587                         return -EIO;
    1588                 }
    1589         }
    1590 
    1591         i2c_reg_data = (i2c_reg << 8) & 0x0ffff;
    1592         cs_vendor_coef_set(codec, CIR_I2C_QREAD, i2c_reg_data);
    1593         if (cs8409_i2c_wait_complete(codec) < 0) {
    1594                 codec_err(codec, "%s() Transaction Failed 0x%02x : 0x%04x\n",
    1595                         __func__, i2c_address, i2c_reg);
    1596                 return -EIO;
    1597         }
    1598 
    1599         /* Register in bits 15-8 and the data in 7-0 */
    1600         read_data = cs_vendor_coef_get(codec, CIR_I2C_QREAD);
    1601 
    1602         cs8409_enable_i2c_clock(codec, 0);
    1603 
    1604         return read_data & 0x0ff;
    1605 }
    1606 
    1607 /**
    1608  * cs8409_i2c_write - CS8409 I2C Write.
    1609  * @codec: the codec instance
    1610  * @i2c_address: I2C Address
    1611  * @i2c_reg: Register to write to
    1612  * @i2c_data: Data to write
    1613  * @paged: Is a paged transaction
    1614  *
    1615  * CS8409 I2C Write.
    1616  * Returns negative on error, otherwise returns 0.
    1617  */
    1618 static int cs8409_i2c_write(struct hda_codec *codec,
    1619                 unsigned int i2c_address, unsigned int i2c_reg,
    1620                 unsigned int i2c_data,
    1621                 unsigned int paged)
    1622 {
    1623         unsigned int i2c_reg_data;
    1624 
    1625         cs8409_enable_i2c_clock(codec, 1);
    1626         cs_vendor_coef_set(codec, CIR_I2C_ADDR, i2c_address);
    1627 
    1628         if (paged) {
    1629                 cs_vendor_coef_set(codec, CIR_I2C_QWRITE, i2c_reg >> 8);
    1630                 if (cs8409_i2c_wait_complete(codec) < 0) {
    1631                         codec_err(codec,
    1632                                 "%s() Paged Transaction Failed 0x%02x : 0x%04x\n",
    1633                                 __func__, i2c_address, i2c_reg);
    1634                         return -EIO;
    1635                 }
    1636         }
    1637 
    1638         i2c_reg_data = ((i2c_reg << 8) & 0x0ff00) | (i2c_data & 0x0ff);
    1639         cs_vendor_coef_set(codec, CIR_I2C_QWRITE, i2c_reg_data);
    1640 
    1641         if (cs8409_i2c_wait_complete(codec) < 0) {
    1642                 codec_err(codec, "%s() Transaction Failed 0x%02x : 0x%04x\n",
    1643                         __func__, i2c_address, i2c_reg);
    1644                 return -EIO;
    1645         }
    1646 
    1647         cs8409_enable_i2c_clock(codec, 0);
    1648 
    1649         return 0;
    1650 }
    1651 
    1652 static int cs8409_cs42l42_volume_info(struct snd_kcontrol *kcontrol,
    1653                                   struct snd_ctl_elem_info *uinfo)
    1654 {
    1655         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1656         u16 nid = get_amp_nid(kcontrol);
    1657         u8 chs = get_amp_channels(kcontrol);
    1658 
    1659         codec_dbg(codec, "%s() nid: %d\n", __func__, nid);
    1660         switch (nid) {
    1661         case CS8409_CS42L42_HP_PIN_NID:
    1662                 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
    1663                 uinfo->count = chs == 3 ? 2 : 1;
    1664                 uinfo->value.integer.min = CS8409_CS42L42_HP_VOL_REAL_MIN;
    1665                 uinfo->value.integer.max = CS8409_CS42L42_HP_VOL_REAL_MAX;
    1666                 break;
    1667         case CS8409_CS42L42_AMIC_PIN_NID:
    1668                 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
    1669                 uinfo->count = chs == 3 ? 2 : 1;
    1670                 uinfo->value.integer.min = CS8409_CS42L42_AMIC_VOL_REAL_MIN;
    1671                 uinfo->value.integer.max = CS8409_CS42L42_AMIC_VOL_REAL_MAX;
    1672                 break;
    1673         default:
    1674                 break;
    1675         }
    1676         return 0;
    1677 }
    1678 
    1679 static void cs8409_cs42l42_update_volume(struct hda_codec *codec)
    1680 {
    1681         struct cs_spec *spec = codec->spec;
    1682         int data;
    1683 
    1684         mutex_lock(&spec->cs8409_i2c_mux);
    1685         data = cs8409_i2c_read(codec, CS42L42_I2C_ADDR,
    1686                                 CS8409_CS42L42_REG_HS_VOLUME_CHA, 1);
    1687         if (data >= 0)
    1688                 spec->cs42l42_hp_volume[0] = -data;
    1689         else
    1690                 spec->cs42l42_hp_volume[0] = CS8409_CS42L42_HP_VOL_REAL_MIN;
    1691         data = cs8409_i2c_read(codec, CS42L42_I2C_ADDR,
    1692                                 CS8409_CS42L42_REG_HS_VOLUME_CHB, 1);
    1693         if (data >= 0)
    1694                 spec->cs42l42_hp_volume[1] = -data;
    1695         else
    1696                 spec->cs42l42_hp_volume[1] = CS8409_CS42L42_HP_VOL_REAL_MIN;
    1697         data = cs8409_i2c_read(codec, CS42L42_I2C_ADDR,
    1698                                 CS8409_CS42L42_REG_AMIC_VOLUME, 1);
    1699         if (data >= 0)
    1700                 spec->cs42l42_hs_mic_volume[0] = -data;
    1701         else
    1702                 spec->cs42l42_hs_mic_volume[0] = CS8409_CS42L42_AMIC_VOL_REAL_MIN;
    1703         mutex_unlock(&spec->cs8409_i2c_mux);
    1704         spec->cs42l42_volume_init = 1;
    1705 }
    1706 
    1707 static int cs8409_cs42l42_volume_get(struct snd_kcontrol *kcontrol,
    1708                                  struct snd_ctl_elem_value *ucontrol)
    1709 {
    1710         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1711         struct cs_spec *spec = codec->spec;
    1712         hda_nid_t nid = get_amp_nid(kcontrol);
    1713         int chs = get_amp_channels(kcontrol);
    1714         long *valp = ucontrol->value.integer.value;
    1715 
    1716         if (!spec->cs42l42_volume_init) {
    1717                 snd_hda_power_up(codec);
    1718                 cs8409_cs42l42_update_volume(codec);
    1719                 snd_hda_power_down(codec);
    1720         }
    1721         switch (nid) {
    1722         case CS8409_CS42L42_HP_PIN_NID:
    1723                 if (chs & BIT(0))
    1724                         *valp++ = spec->cs42l42_hp_volume[0];
    1725                 if (chs & BIT(1))
    1726                         *valp++ = spec->cs42l42_hp_volume[1];
    1727                 break;
    1728         case CS8409_CS42L42_AMIC_PIN_NID:
    1729                 if (chs & BIT(0))
    1730                         *valp++ = spec->cs42l42_hs_mic_volume[0];
    1731                 break;
    1732         default:
    1733                 break;
    1734         }
    1735         return 0;
    1736 }
    1737 
    1738 static int cs8409_cs42l42_volume_put(struct snd_kcontrol *kcontrol,
    1739                                  struct snd_ctl_elem_value *ucontrol)
    1740 {
    1741         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    1742         struct cs_spec *spec = codec->spec;
    1743         hda_nid_t nid = get_amp_nid(kcontrol);
    1744         int chs = get_amp_channels(kcontrol);
    1745         long *valp = ucontrol->value.integer.value;
    1746         int change = 0;
    1747         char vol;
    1748 
    1749         snd_hda_power_up(codec);
    1750         switch (nid) {
    1751         case CS8409_CS42L42_HP_PIN_NID:
    1752                 mutex_lock(&spec->cs8409_i2c_mux);
    1753                 if (chs & BIT(0)) {
    1754                         vol = -(*valp);
    1755                         change = cs8409_i2c_write(codec, CS42L42_I2C_ADDR,
    1756                                 CS8409_CS42L42_REG_HS_VOLUME_CHA, vol, 1);
    1757                         valp++;
    1758                 }
    1759                 if (chs & BIT(1)) {
    1760                         vol = -(*valp);
    1761                         change |= cs8409_i2c_write(codec, CS42L42_I2C_ADDR,
    1762                                 CS8409_CS42L42_REG_HS_VOLUME_CHB, vol, 1);
    1763                 }
    1764                 mutex_unlock(&spec->cs8409_i2c_mux);
    1765                 break;
    1766         case CS8409_CS42L42_AMIC_PIN_NID:
    1767                 mutex_lock(&spec->cs8409_i2c_mux);
    1768                 if (chs & BIT(0)) {
    1769                         change = cs8409_i2c_write(
    1770                                 codec, CS42L42_I2C_ADDR,
    1771                                 CS8409_CS42L42_REG_AMIC_VOLUME, (char)*valp, 1);
    1772                         valp++;
    1773                 }
    1774                 mutex_unlock(&spec->cs8409_i2c_mux);
    1775                 break;
    1776         default:
    1777                 break;
    1778         }
    1779         cs8409_cs42l42_update_volume(codec);
    1780         snd_hda_power_down(codec);
    1781         return change;
    1782 }
    1783 
    1784 static const DECLARE_TLV_DB_SCALE(
    1785         cs8409_cs42l42_hp_db_scale,
    1786         CS8409_CS42L42_HP_VOL_REAL_MIN * 100, 100, 1);
    1787 
    1788 static const DECLARE_TLV_DB_SCALE(
    1789         cs8409_cs42l42_amic_db_scale,
    1790         CS8409_CS42L42_AMIC_VOL_REAL_MIN * 100, 100, 1);
    1791 
    1792 static const struct snd_kcontrol_new cs8409_cs42l42_hp_volume_mixer = {
    1793         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1794         .index = 0,
    1795         .name = "Headphone Playback Volume",
    1796         .subdevice = (HDA_SUBDEV_AMP_FLAG | HDA_SUBDEV_NID_FLAG),
    1797         .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE
    1798                          | SNDRV_CTL_ELEM_ACCESS_TLV_READ),
    1799         .info = cs8409_cs42l42_volume_info,
    1800         .get = cs8409_cs42l42_volume_get,
    1801         .put = cs8409_cs42l42_volume_put,
    1802         .tlv = { .p = cs8409_cs42l42_hp_db_scale },
    1803         .private_value = HDA_COMPOSE_AMP_VAL(
    1804                 CS8409_CS42L42_HP_PIN_NID, 3, 0, HDA_OUTPUT)
    1805                 | HDA_AMP_VAL_MIN_MUTE
    1806 };
    1807 
    1808 static const struct snd_kcontrol_new cs8409_cs42l42_amic_volume_mixer = {
    1809         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    1810         .index = 0,
    1811         .name = "Mic Capture Volume",
    1812         .subdevice = (HDA_SUBDEV_AMP_FLAG | HDA_SUBDEV_NID_FLAG),
    1813         .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE
    1814                          | SNDRV_CTL_ELEM_ACCESS_TLV_READ),
    1815         .info = cs8409_cs42l42_volume_info,
    1816         .get = cs8409_cs42l42_volume_get,
    1817         .put = cs8409_cs42l42_volume_put,
    1818         .tlv = { .p = cs8409_cs42l42_amic_db_scale },
    1819         .private_value = HDA_COMPOSE_AMP_VAL(
    1820                 CS8409_CS42L42_AMIC_PIN_NID, 1, 0, HDA_INPUT)
    1821                 | HDA_AMP_VAL_MIN_MUTE
    1822 };
    1823 
    1824 /* Assert/release RTS# line to CS42L42 */
    1825 static void cs8409_cs42l42_reset(struct hda_codec *codec)
    1826 {
    1827         struct cs_spec *spec = codec->spec;
    1828 
    1829         /* Assert RTS# line */
    1830         snd_hda_codec_write(codec,
    1831                         codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, 0);
    1832         /* wait ~10ms */
    1833         usleep_range(10000, 15000);
    1834         /* Release RTS# line */
    1835         snd_hda_codec_write(codec,
    1836                         codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, GPIO5_INT);
    1837         /* wait ~10ms */
    1838         usleep_range(10000, 15000);
    1839 
    1840         mutex_lock(&spec->cs8409_i2c_mux);
    1841 
    1842         /* Clear interrupts, by reading interrupt status registers */
    1843         cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1);
    1844         cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1309, 1);
    1845         cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130A, 1);
    1846         cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130F, 1);
    1847 
    1848         mutex_unlock(&spec->cs8409_i2c_mux);
    1849 
    1850 }
    1851 
    1852 /* Configure CS42L42 slave codec for jack autodetect */
    1853 static void cs8409_cs42l42_enable_jack_detect(struct hda_codec *codec)
    1854 {
    1855         struct cs_spec *spec = codec->spec;
    1856 
    1857         mutex_lock(&spec->cs8409_i2c_mux);
    1858 
    1859         /* Set TIP_SENSE_EN for analog front-end of tip sense. */
    1860         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b70, 0x0020, 1);
    1861         /* Clear WAKE# */
    1862         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b71, 0x0001, 1);
    1863         /* Wait ~2.5ms */
    1864         usleep_range(2500, 3000);
    1865         /* Set mode WAKE# output follows the combination logic directly */
    1866         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b71, 0x0020, 1);
    1867         /* Clear interrupts status */
    1868         cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130f, 1);
    1869         cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b7b, 1);
    1870         /* Enable interrupt */
    1871         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1320, 0x03, 1);
    1872         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b79, 0x00, 1);
    1873 
    1874         mutex_unlock(&spec->cs8409_i2c_mux);
    1875 }
    1876 
    1877 /* Enable and run CS42L42 slave codec jack auto detect */
    1878 static void cs8409_cs42l42_run_jack_detect(struct hda_codec *codec)
    1879 {
    1880         struct cs_spec *spec = codec->spec;
    1881 
    1882         mutex_lock(&spec->cs8409_i2c_mux);
    1883 
    1884         /* Clear interrupts */
    1885         cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1);
    1886         cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b77, 1);
    1887 
    1888         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1102, 0x87, 1);
    1889         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1f06, 0x86, 1);
    1890         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b74, 0x07, 1);
    1891         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x131b, 0x01, 1);
    1892         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1120, 0x80, 1);
    1893         /* Wait ~110ms*/
    1894         usleep_range(110000, 200000);
    1895         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x111f, 0x77, 1);
    1896         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1120, 0xc0, 1);
    1897         /* Wait ~10ms */
    1898         usleep_range(10000, 25000);
    1899 
    1900         mutex_unlock(&spec->cs8409_i2c_mux);
    1901 
    1902 }
    1903 
    1904 static void cs8409_cs42l42_reg_setup(struct hda_codec *codec)
    1905 {
    1906         const struct cs8409_i2c_param *seq = cs42l42_init_reg_seq;
    1907         struct cs_spec *spec = codec->spec;
    1908 
    1909         mutex_lock(&spec->cs8409_i2c_mux);
    1910 
    1911         for (; seq->addr; seq++)
    1912                 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, seq->addr, seq->reg, 1);
    1913 
    1914         mutex_unlock(&spec->cs8409_i2c_mux);
    1915 
    1916 }
    1917 
    1918 /*
    1919  * In the case of CS8409 we do not have unsolicited events from NID's 0x24
    1920  * and 0x34 where hs mic and hp are connected. Companion codec CS42L42 will
    1921  * generate interrupt via gpio 4 to notify jack events. We have to overwrite
    1922  * generic snd_hda_jack_unsol_event(), read CS42L42 jack detect status registers
    1923  * and then notify status via generic snd_hda_jack_unsol_event() call.
    1924  */
    1925 static void cs8409_jack_unsol_event(struct hda_codec *codec, unsigned int res)
    1926 {
    1927         struct cs_spec *spec = codec->spec;
    1928         int status_changed = 0;
    1929         int reg_cdc_status;
    1930         int reg_hs_status;
    1931         int reg_ts_status;
    1932         int type;
    1933         struct hda_jack_tbl *jk;
    1934 
    1935         /* jack_unsol_event() will be called every time gpio line changing state.
    1936          * In this case gpio4 line goes up as a result of reading interrupt status
    1937          * registers in previous cs8409_jack_unsol_event() call.
    1938          * We don't need to handle this event, ignoring...
    1939          */
    1940         if ((res & (1 << 4)))
    1941                 return;
    1942 
    1943         mutex_lock(&spec->cs8409_i2c_mux);
    1944 
    1945         /* Read jack detect status registers */
    1946         reg_cdc_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1);
    1947         reg_hs_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1124, 1);
    1948         reg_ts_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130f, 1);
    1949 
    1950         /* Clear interrupts, by reading interrupt status registers */
    1951         cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b7b, 1);
    1952 
    1953         mutex_unlock(&spec->cs8409_i2c_mux);
    1954 
    1955         /* If status values are < 0, read error has occurred. */
    1956         if (reg_cdc_status < 0 || reg_hs_status < 0 || reg_ts_status < 0)
    1957                 return;
    1958 
    1959         /* HSDET_AUTO_DONE */
    1960         if (reg_cdc_status & CS42L42_HSDET_AUTO_DONE) {
    1961 
    1962                 type = ((reg_hs_status & CS42L42_HSTYPE_MASK) + 1);
    1963                 /* CS42L42 reports optical jack as type 4
    1964                  * We don't handle optical jack
    1965                  */
    1966                 if (type != 4) {
    1967                         if (!spec->cs42l42_hp_jack_in) {
    1968                                 status_changed = 1;
    1969                                 spec->cs42l42_hp_jack_in = 1;
    1970                         }
    1971                         /* type = 3 has no mic */
    1972                         if ((!spec->cs42l42_mic_jack_in) && (type != 3)) {
    1973                                 status_changed = 1;
    1974                                 spec->cs42l42_mic_jack_in = 1;
    1975                         }
    1976                 } else {
    1977                         if (spec->cs42l42_hp_jack_in || spec->cs42l42_mic_jack_in) {
    1978                                 status_changed = 1;
    1979                                 spec->cs42l42_hp_jack_in = 0;
    1980                                 spec->cs42l42_mic_jack_in = 0;
    1981                         }
    1982                 }
    1983 
    1984         } else {
    1985                 /* TIP_SENSE INSERT/REMOVE */
    1986                 switch (reg_ts_status) {
    1987                 case CS42L42_JACK_INSERTED:
    1988                         cs8409_cs42l42_run_jack_detect(codec);
    1989                         break;
    1990 
    1991                 case CS42L42_JACK_REMOVED:
    1992                         if (spec->cs42l42_hp_jack_in || spec->cs42l42_mic_jack_in) {
    1993                                 status_changed = 1;
    1994                                 spec->cs42l42_hp_jack_in = 0;
    1995                                 spec->cs42l42_mic_jack_in = 0;
    1996                         }
    1997                         break;
    1998 
    1999                 default:
    2000                         /* jack in transition */
    2001                         status_changed = 0;
    2002                         break;
    2003                 }
    2004         }
    2005 
    2006         if (status_changed) {
    2007 
    2008                 snd_hda_set_pin_ctl(codec, CS8409_CS42L42_SPK_PIN_NID,
    2009                                 spec->cs42l42_hp_jack_in ? 0 : PIN_OUT);
    2010 
    2011                 /* Report jack*/
    2012                 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_HP_PIN_NID, 0);
    2013                 if (jk) {
    2014                         snd_hda_jack_unsol_event(codec,
    2015                                 (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & AC_UNSOL_RES_TAG);
    2016                 }
    2017                 /* Report jack*/
    2018                 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_AMIC_PIN_NID, 0);
    2019                 if (jk) {
    2020                         snd_hda_jack_unsol_event(codec,
    2021                                 (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & AC_UNSOL_RES_TAG);
    2022                 }
    2023         }
    2024 }
    2025 
    2026 #ifdef CONFIG_PM
    2027 /* Manage PDREF, when transition to D3hot */
    2028 static int cs8409_suspend(struct hda_codec *codec)
    2029 {
    2030         struct cs_spec *spec = codec->spec;
    2031 
    2032         mutex_lock(&spec->cs8409_i2c_mux);
    2033         /* Power down CS42L42 ASP/EQ/MIX/HP */
    2034         cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1101, 0xfe, 1);
    2035         mutex_unlock(&spec->cs8409_i2c_mux);
    2036         /* Assert CS42L42 RTS# line */
    2037         snd_hda_codec_write(codec,
    2038                         codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, 0);
    2039 
    2040         snd_hda_shutup_pins(codec);
    2041 
    2042         return 0;
    2043 }
    2044 #endif
    2045 
    2046 /* Enable/Disable Unsolicited Response for gpio(s) 3,4 */
    2047 static void cs8409_enable_ur(struct hda_codec *codec, int flag)
    2048 {
    2049         /* GPIO4 INT# and GPIO3 WAKE# */
    2050         snd_hda_codec_write(codec, codec->core.afg,
    2051                         0, AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK,
    2052                         flag ? (GPIO3_INT | GPIO4_INT) : 0);
    2053 
    2054         snd_hda_codec_write(codec, codec->core.afg,
    2055                         0, AC_VERB_SET_UNSOLICITED_ENABLE,
    2056                         flag ? AC_UNSOL_ENABLED : 0);
    2057 
    2058 }
    2059 
    2060 /* Vendor specific HW configuration
    2061  * PLL, ASP, I2C, SPI, GPIOs, DMIC etc...
    2062  */
    2063 static void cs8409_cs42l42_hw_init(struct hda_codec *codec)
    2064 {
    2065         const struct cs8409_cir_param *seq = cs8409_cs42l42_hw_cfg;
    2066         const struct cs8409_cir_param *seq_bullseye = cs8409_cs42l42_bullseye_atn;
    2067         struct cs_spec *spec = codec->spec;
    2068 
    2069         if (spec->gpio_mask) {
    2070                 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
    2071                                     spec->gpio_mask);
    2072                 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
    2073                                     spec->gpio_dir);
    2074                 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
    2075                                     spec->gpio_data);
    2076         }
    2077 
    2078         for (; seq->nid; seq++)
    2079                 cs_vendor_coef_set(codec, seq->cir, seq->coeff);
    2080 
    2081         if (codec->fixup_id == CS8409_BULLSEYE)
    2082                 for (; seq_bullseye->nid; seq_bullseye++)
    2083                         cs_vendor_coef_set(codec, seq_bullseye->cir, seq_bullseye->coeff);
    2084 
    2085         /* Disable Unsolicited Response during boot */
    2086         cs8409_enable_ur(codec, 0);
    2087 
    2088         /* Reset CS42L42 */
    2089         cs8409_cs42l42_reset(codec);
    2090 
    2091         /* Initialise CS42L42 companion codec */
    2092         cs8409_cs42l42_reg_setup(codec);
    2093 
    2094         if (codec->fixup_id == CS8409_WARLOCK ||
    2095                         codec->fixup_id == CS8409_CYBORG) {
    2096                 /* FULL_SCALE_VOL = 0 for Warlock / Cyborg */
    2097                 mutex_lock(&spec->cs8409_i2c_mux);
    2098                 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x2001, 0x01, 1);
    2099                 mutex_unlock(&spec->cs8409_i2c_mux);
    2100                 /* DMIC1_MO=00b, DMIC1/2_SR=1 */
    2101                 cs_vendor_coef_set(codec, 0x09, 0x0003);
    2102         }
    2103 
    2104         /* Restore Volumes after Resume */
    2105         if (spec->cs42l42_volume_init) {
    2106                 mutex_lock(&spec->cs8409_i2c_mux);
    2107                 cs8409_i2c_write(codec, CS42L42_I2C_ADDR,
    2108                                         CS8409_CS42L42_REG_HS_VOLUME_CHA,
    2109                                         -spec->cs42l42_hp_volume[0],
    2110                                         1);
    2111                 cs8409_i2c_write(codec, CS42L42_I2C_ADDR,
    2112                                         CS8409_CS42L42_REG_HS_VOLUME_CHB,
    2113                                         -spec->cs42l42_hp_volume[1],
    2114                                         1);
    2115                 cs8409_i2c_write(codec, CS42L42_I2C_ADDR,
    2116                                         CS8409_CS42L42_REG_AMIC_VOLUME,
    2117                                         spec->cs42l42_hs_mic_volume[0],
    2118                                         1);
    2119                 mutex_unlock(&spec->cs8409_i2c_mux);
    2120         }
    2121 
    2122         cs8409_cs42l42_update_volume(codec);
    2123 
    2124         cs8409_cs42l42_enable_jack_detect(codec);
    2125 
    2126         /* Enable Unsolicited Response */
    2127         cs8409_enable_ur(codec, 1);
    2128 }
    2129 
    2130 static int cs8409_cs42l42_init(struct hda_codec *codec)
    2131 {
    2132         int ret = snd_hda_gen_init(codec);
    2133 
    2134         if (!ret)
    2135                 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
    2136 
    2137         return ret;
    2138 }
    2139 
    2140 static const struct hda_codec_ops cs8409_cs42l42_patch_ops = {
    2141         .build_controls = cs_build_controls,
    2142         .build_pcms = snd_hda_gen_build_pcms,
    2143         .init = cs8409_cs42l42_init,
    2144         .free = cs_free,
    2145         .unsol_event = cs8409_jack_unsol_event,
    2146 #ifdef CONFIG_PM
    2147         .suspend = cs8409_suspend,
    2148 #endif
    2149 };
    2150 
    2151 static void cs8409_cs42l42_fixups(struct hda_codec *codec,
    2152                                     const struct hda_fixup *fix, int action)
    2153 {
    2154         struct cs_spec *spec = codec->spec;
    2155         int caps;
    2156 
    2157         switch (action) {
    2158         case HDA_FIXUP_ACT_PRE_PROBE:
    2159                 snd_hda_add_verbs(codec, cs8409_cs42l42_init_verbs);
    2160                 /* verb exec op override */
    2161                 spec->exec_verb = codec->core.exec_verb;
    2162                 codec->core.exec_verb = cs8409_cs42l42_exec_verb;
    2163 
    2164                 mutex_init(&spec->cs8409_i2c_mux);
    2165 
    2166                 codec->patch_ops = cs8409_cs42l42_patch_ops;
    2167 
    2168                 spec->gen.suppress_auto_mute = 1;
    2169                 spec->gen.no_primary_hp = 1;
    2170                 spec->gen.suppress_vmaster = 1;
    2171 
    2172                 /* GPIO 5 out, 3,4 in */
    2173                 spec->gpio_dir = GPIO5_INT;
    2174                 spec->gpio_data = 0;
    2175                 spec->gpio_mask = 0x03f;
    2176 
    2177                 spec->cs42l42_hp_jack_in = 0;
    2178                 spec->cs42l42_mic_jack_in = 0;
    2179 
    2180                 /* Basic initial sequence for specific hw configuration */
    2181                 snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs);
    2182 
    2183                 /* CS8409 is simple HDA bridge and intended to be used with a remote
    2184                  * companion codec. Most of input/output PIN(s) have only basic
    2185                  * capabilities. NID(s) 0x24 and 0x34 have only OUTC and INC
    2186                  * capabilities and no presence detect capable (PDC) and call to
    2187                  * snd_hda_gen_build_controls() will mark them as non detectable
    2188                  * phantom jacks. However, in this configuration companion codec
    2189                  * CS42L42 is connected to these pins and it has jack detect
    2190                  * capabilities. We have to override pin capabilities,
    2191                  * otherwise they will not be created as input devices.
    2192                  */
    2193                 caps = snd_hdac_read_parm(&codec->core, CS8409_CS42L42_HP_PIN_NID,
    2194                                 AC_PAR_PIN_CAP);
    2195                 if (caps >= 0)
    2196                         snd_hdac_override_parm(&codec->core,
    2197                                 CS8409_CS42L42_HP_PIN_NID, AC_PAR_PIN_CAP,
    2198                                 (caps | (AC_PINCAP_IMP_SENSE | AC_PINCAP_PRES_DETECT)));
    2199 
    2200                 caps = snd_hdac_read_parm(&codec->core, CS8409_CS42L42_AMIC_PIN_NID,
    2201                                 AC_PAR_PIN_CAP);
    2202                 if (caps >= 0)
    2203                         snd_hdac_override_parm(&codec->core,
    2204                                 CS8409_CS42L42_AMIC_PIN_NID, AC_PAR_PIN_CAP,
    2205                                 (caps | (AC_PINCAP_IMP_SENSE | AC_PINCAP_PRES_DETECT)));
    2206 
    2207                 snd_hda_override_wcaps(codec, CS8409_CS42L42_HP_PIN_NID,
    2208                         (get_wcaps(codec, CS8409_CS42L42_HP_PIN_NID) | AC_WCAP_UNSOL_CAP));
    2209 
    2210                 snd_hda_override_wcaps(codec, CS8409_CS42L42_AMIC_PIN_NID,
    2211                         (get_wcaps(codec, CS8409_CS42L42_AMIC_PIN_NID) | AC_WCAP_UNSOL_CAP));
    2212                 break;
    2213         case HDA_FIXUP_ACT_PROBE:
    2214 
    2215                 /* Set initial DMIC volume to -26 dB */
    2216                 snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID,
    2217                                 HDA_INPUT, 0, 0xff, 0x19);
    2218                 snd_hda_gen_add_kctl(&spec->gen,
    2219                         NULL, &cs8409_cs42l42_hp_volume_mixer);
    2220                 snd_hda_gen_add_kctl(&spec->gen,
    2221                         NULL, &cs8409_cs42l42_amic_volume_mixer);
    2222                 cs8409_cs42l42_hw_init(codec);
    2223                 snd_hda_codec_set_name(codec, "CS8409/CS42L42");
    2224                 break;
    2225         case HDA_FIXUP_ACT_INIT:
    2226                 cs8409_cs42l42_hw_init(codec);
    2227                 fallthrough;
    2228         case HDA_FIXUP_ACT_BUILD:
    2229                 /* Run jack auto detect first time on boot
    2230                  * after controls have been added, to check if jack has
    2231                  * been already plugged in.
    2232                  * Run immediately after init.
    2233                  */
    2234                 cs8409_cs42l42_run_jack_detect(codec);
    2235                 usleep_range(100000, 150000);
    2236                 break;
    2237         default:
    2238                 break;
    2239         }
    2240 }
    2241 
    2242 static int cs8409_cs42l42_exec_verb(struct hdac_device *dev,
    2243                 unsigned int cmd, unsigned int flags, unsigned int *res)
    2244 {
    2245         struct hda_codec *codec = container_of(dev, struct hda_codec, core);
    2246         struct cs_spec *spec = codec->spec;
    2247 
    2248         unsigned int nid = ((cmd >> 20) & 0x07f);
    2249         unsigned int verb = ((cmd >> 8) & 0x0fff);
    2250 
    2251         /* CS8409 pins have no AC_PINSENSE_PRESENCE
    2252          * capabilities. We have to intercept 2 calls for pins 0x24 and 0x34
    2253          * and return correct pin sense values for read_pin_sense() call from
    2254          * hda_jack based on CS42L42 jack detect status.
    2255          */
    2256         switch (nid) {
    2257         case CS8409_CS42L42_HP_PIN_NID:
    2258                 if (verb == AC_VERB_GET_PIN_SENSE) {
    2259                         *res = (spec->cs42l42_hp_jack_in) ? AC_PINSENSE_PRESENCE : 0;
    2260                         return 0;
    2261                 }
    2262                 break;
    2263 
    2264         case CS8409_CS42L42_AMIC_PIN_NID:
    2265                 if (verb == AC_VERB_GET_PIN_SENSE) {
    2266                         *res = (spec->cs42l42_mic_jack_in) ? AC_PINSENSE_PRESENCE : 0;
    2267                         return 0;
    2268                 }
    2269                 break;
    2270 
    2271         default:
    2272                 break;
    2273         }
    2274 
    2275         return spec->exec_verb(dev, cmd, flags, res);
    2276 }
    2277 
    2278 static int patch_cs8409(struct hda_codec *codec)
    2279 {
    2280         int err;
    2281 
    2282         if (!cs_alloc_spec(codec, CS8409_VENDOR_NID))
    2283                 return -ENOMEM;
    2284 
    2285         snd_hda_pick_fixup(codec,
    2286                         cs8409_models, cs8409_fixup_tbl, cs8409_fixups);
    2287 
    2288         codec_dbg(codec, "Picked ID=%d, VID=%08x, DEV=%08x\n",
    2289                         codec->fixup_id,
    2290                         codec->bus->pci->subsystem_vendor,
    2291                         codec->bus->pci->subsystem_device);
    2292 
    2293         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
    2294 
    2295         err = cs_parse_auto_config(codec);
    2296         if (err < 0) {
    2297                 cs_free(codec);
    2298                 return err;
    2299         }
    2300 
    2301         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
    2302         return 0;
    2303 }
    2304 
    23051232/*
    23061233 * patch entries
     
    23121239        HDA_CODEC_ENTRY(0x10134210, "CS4210", patch_cs4210),
    23131240        HDA_CODEC_ENTRY(0x10134213, "CS4213", patch_cs4213),
    2314         HDA_CODEC_ENTRY(0x10138409, "CS8409", patch_cs8409),
    23151241        {0} /* terminator */
    23161242};
  • GPL/trunk/alsa-kernel/pci/hda/patch_conexant.c

    r695 r717  
    184184}
    185185
    186 static void cx_auto_reboot_notify(struct hda_codec *codec)
     186static void cx_auto_shutdown(struct hda_codec *codec)
    187187{
    188188        struct conexant_spec *spec = codec->spec;
     
    191191           from the internal speaker during (and after) reboot */
    192192        cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false);
    193         snd_hda_gen_reboot_notify(codec);
    194193}
    195194
    196195static void cx_auto_free(struct hda_codec *codec)
    197196{
    198         cx_auto_reboot_notify(codec);
     197        cx_auto_shutdown(codec);
    199198        snd_hda_gen_free(codec);
    200199}
     200
     201#ifdef CONFIG_PM
     202static int cx_auto_suspend(struct hda_codec *codec)
     203{
     204        cx_auto_shutdown(codec);
     205        return 0;
     206}
     207#endif
    201208
    202209static const struct hda_codec_ops cx_auto_patch_ops = {
     
    204211        .build_pcms = snd_hda_gen_build_pcms,
    205212        .init = cx_auto_init,
    206         .reboot_notify = cx_auto_reboot_notify,
    207213        .free = cx_auto_free,
    208214        .unsol_event = snd_hda_jack_unsol_event,
    209215#ifdef CONFIG_PM
     216        .suspend = cx_auto_suspend,
    210217        .check_power_status = snd_hda_gen_check_power_status,
    211218#endif
     
    9981005        SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
    9991006        SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE),
     1007        SND_PCI_QUIRK(0x103c, 0x82b4, "HP ProDesk 600 G3", CXT_FIXUP_HP_MIC_NO_PRESENCE),
    10001008        SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO),
    10011009        SND_PCI_QUIRK(0x103c, 0x837f, "HP ProBook 470 G5", CXT_FIXUP_MUTE_LED_GPIO),
     
    11061114                                   cxt5051_fixups, cxt_fixups);
    11071115                break;
     1116        case 0x14f15098:
     1117                codec->pin_amp_workaround = 1;
     1118                spec->gen.mixer_nid = 0x22;
     1119                spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
     1120                snd_hda_pick_fixup(codec, cxt5066_fixup_models,
     1121                                   cxt5066_fixups, cxt_fixups);
     1122                break;
    11081123        case 0x14f150f2:
    11091124                codec->power_save_node = 1;
     
    11261141                goto error;
    11271142
    1128         err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
     1143        err = cx_auto_parse_beep(codec);
    11291144        if (err < 0)
    11301145                goto error;
    11311146
    1132         err = cx_auto_parse_beep(codec);
     1147        err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
    11331148        if (err < 0)
    11341149                goto error;
  • GPL/trunk/alsa-kernel/pci/hda/patch_hdmi.c

    r709 r717  
    5959module_param(enable_silent_stream, bool, 0644);
    6060MODULE_PARM_DESC(enable_silent_stream, "Enable Silent Stream for HDMI devices");
     61
     62static bool enable_all_pins;
     63module_param(enable_all_pins, bool, 0444);
     64MODULE_PARM_DESC(enable_all_pins, "Forcibly enable all pins");
    6165
    6266struct hdmi_spec_per_cvt {
     
    13961400 last_try:
    13971401        /* the last try; check the empty slots in pins */
    1398         for (i = 0; i < spec->num_nids; i++) {
     1402        for (i = 0; i < spec->pcm_used; i++) {
    13991403                if (!test_bit(i, &spec->pcm_bitmap))
    14001404                        return i;
     
    16261630        struct hdmi_spec *spec = codec->spec;
    16271631        struct hdmi_eld *eld = &spec->temp_eld;
     1632        struct device *dev = hda_codec_dev(codec);
    16281633        hda_nid_t pin_nid = per_pin->pin_nid;
    16291634        int dev_id = per_pin->dev_id;
     
    16391644        int ret;
    16401645
     1646#ifdef  CONFIG_PM
     1647        if (dev->power.runtime_status == RPM_SUSPENDING)
     1648                return;
     1649#endif
     1650
    16411651        ret = snd_hda_power_up_pm(codec);
    1642         if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec)))
     1652        if (ret < 0 && pm_runtime_suspended(dev))
    16431653                goto out;
    16441654
     
    19721982        }
    19731983
     1984        if (enable_all_pins)
     1985                spec->force_connect = true;
     1986
    19741987        q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list);
    19751988
     
    22692282         */
    22702283
    2271         if (codec->mst_no_extra_pcms)
     2284        if (spec->dyn_pcm_no_legacy && codec->mst_no_extra_pcms)
     2285                pcm_num = spec->num_cvts;
     2286        else if (codec->mst_no_extra_pcms)
    22722287                pcm_num = spec->num_nids;
    22732288        else
     
    29652980/* Intel Haswell and onwards; audio component with eld notifier */
    29662981static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid,
    2967                                  const int *port_map, int port_num, int dev_num)
     2982                                 const int *port_map, int port_num, int dev_num,
     2983                                 bool send_silent_stream)
    29682984{
    29692985        struct hdmi_spec *spec;
     
    29983014         * module param or Kconfig option
    29993015         */
    3000         if (enable_silent_stream)
     3016        if (send_silent_stream)
    30013017                spec->send_silent_stream = true;
    30023018
     
    30063022static int patch_i915_hsw_hdmi(struct hda_codec *codec)
    30073023{
    3008         return intel_hsw_common_init(codec, 0x08, NULL, 0, 3);
     3024        return intel_hsw_common_init(codec, 0x08, NULL, 0, 3,
     3025                                     enable_silent_stream);
    30093026}
    30103027
    30113028static int patch_i915_glk_hdmi(struct hda_codec *codec)
    30123029{
    3013         return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3);
     3030        /*
     3031         * Silent stream calls audio component .get_power() from
     3032         * .pin_eld_notify(). On GLK this will deadlock in i915 due
     3033         * to the audio vs. CDCLK workaround.
     3034         */
     3035        return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3, false);
    30143036}
    30153037
     
    30223044        static const int map[] = {0x0, 0x4, 0x6, 0x8, 0xa, 0xb};
    30233045
    3024         return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3);
     3046        return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3,
     3047                                     enable_silent_stream);
    30253048}
    30263049
     
    30343057        int ret;
    30353058
    3036         ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4);
     3059        ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4,
     3060                                    enable_silent_stream);
    30373061        if (!ret) {
    30383062                struct hdmi_spec *spec = codec->spec;
     
    43984422HDA_CODEC_ENTRY(0x80862814, "DG1 HDMI", patch_i915_tgl_hdmi),
    43994423HDA_CODEC_ENTRY(0x80862815, "Alderlake HDMI",   patch_i915_tgl_hdmi),
    4400 HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_tgl_hdmi),
    44014424HDA_CODEC_ENTRY(0x80862816, "Rocketlake HDMI",  patch_i915_tgl_hdmi),
     4425HDA_CODEC_ENTRY(0x80862819, "DG2 HDMI", patch_i915_tgl_hdmi),
    44024426HDA_CODEC_ENTRY(0x8086281a, "Jasperlake HDMI",  patch_i915_icl_hdmi),
    44034427HDA_CODEC_ENTRY(0x8086281b, "Elkhartlake HDMI", patch_i915_icl_hdmi),
     4428HDA_CODEC_ENTRY(0x8086281c, "Alderlake-P HDMI", patch_i915_tgl_hdmi),
    44044429HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI",  patch_generic_hdmi),
    44054430HDA_CODEC_ENTRY(0x80862882, "Valleyview2 HDMI", patch_i915_byt_hdmi),
  • GPL/trunk/alsa-kernel/pci/hda/patch_realtek.c

    r703 r717  
    103103        struct alc_coef_led mute_led_coef;
    104104        struct alc_coef_led mic_led_coef;
     105        struct mutex coef_mutex;
    105106
    106107        hda_nid_t headset_mic_pin;
     
    115116#endif
    116117        void (*shutup)(struct hda_codec *codec);
    117         void (*reboot_notify)(struct hda_codec *codec);
    118118
    119119        int init_amp;
     
    139139 */
    140140
    141 static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
    142                                unsigned int coef_idx)
     141static void coef_mutex_lock(struct hda_codec *codec)
     142{
     143        struct alc_spec *spec = codec->spec;
     144
     145        snd_hda_power_up_pm(codec);
     146        mutex_lock(&spec->coef_mutex);
     147}
     148
     149static void coef_mutex_unlock(struct hda_codec *codec)
     150{
     151        struct alc_spec *spec = codec->spec;
     152
     153        mutex_unlock(&spec->coef_mutex);
     154        snd_hda_power_down_pm(codec);
     155}
     156
     157static int __alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
     158                                 unsigned int coef_idx)
    143159{
    144160        unsigned int val;
     
    149165}
    150166
     167static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
     168                               unsigned int coef_idx)
     169{
     170        unsigned int val;
     171
     172        coef_mutex_lock(codec);
     173        val = __alc_read_coefex_idx(codec, nid, coef_idx);
     174        coef_mutex_unlock(codec);
     175        return val;
     176}
     177
    151178#define alc_read_coef_idx(codec, coef_idx) \
    152179        alc_read_coefex_idx(codec, 0x20, coef_idx)
    153180
     181static void __alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
     182                                   unsigned int coef_idx, unsigned int coef_val)
     183{
     184        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
     185        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
     186}
     187
    154188static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
    155189                                 unsigned int coef_idx, unsigned int coef_val)
    156190{
    157         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
    158         snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
     191        coef_mutex_lock(codec);
     192        __alc_write_coefex_idx(codec, nid, coef_idx, coef_val);
     193        coef_mutex_unlock(codec);
    159194}
    160195
    161196#define alc_write_coef_idx(codec, coef_idx, coef_val) \
    162197        alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
     198
     199static void __alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
     200                                    unsigned int coef_idx, unsigned int mask,
     201                                    unsigned int bits_set)
     202{
     203        unsigned int val = __alc_read_coefex_idx(codec, nid, coef_idx);
     204
     205        if (val != -1)
     206                __alc_write_coefex_idx(codec, nid, coef_idx,
     207                                       (val & ~mask) | bits_set);
     208}
    163209
    164210static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
     
    166212                                  unsigned int bits_set)
    167213{
    168         unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
    169 
    170         if (val != -1)
    171                 alc_write_coefex_idx(codec, nid, coef_idx,
    172                                      (val & ~mask) | bits_set);
     214        coef_mutex_lock(codec);
     215        __alc_update_coefex_idx(codec, nid, coef_idx, mask, bits_set);
     216        coef_mutex_unlock(codec);
    173217}
    174218
     
    203247                                const struct coef_fw *fw)
    204248{
     249        coef_mutex_lock(codec);
    205250        for (; fw->nid; fw++) {
    206251                if (fw->mask == (unsigned short)-1)
    207                         alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
     252                        __alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
    208253                else
    209                         alc_update_coefex_idx(codec, fw->nid, fw->idx,
    210                                               fw->mask, fw->val);
    211         }
     254                        __alc_update_coefex_idx(codec, fw->nid, fw->idx,
     255                                                fw->mask, fw->val);
     256        }
     257        coef_mutex_unlock(codec);
    212258}
    213259
     
    400446        case 0x10ec0255:
    401447        case 0x10ec0256:
     448        case 0x19e58326:
    402449        case 0x10ec0257:
    403450        case 0x10ec0282:
     
    535582
    536583        switch (codec->core.vendor_id) {
     584        case 0x10ec0236:
     585        case 0x10ec0256:
     586        case 0x19e58326:
    537587        case 0x10ec0283:
    538588        case 0x10ec0286:
     
    893943}
    894944
     945#define alc_free        snd_hda_gen_free
     946
     947#ifdef CONFIG_PM
    895948static inline void alc_shutup(struct hda_codec *codec)
    896949{
     
    906959}
    907960
    908 static void alc_reboot_notify(struct hda_codec *codec)
    909 {
    910         struct alc_spec *spec = codec->spec;
    911 
    912         if (spec && spec->reboot_notify)
    913                 spec->reboot_notify(codec);
    914         else
    915                 alc_shutup(codec);
    916 }
    917 
    918 #define alc_free        snd_hda_gen_free
    919 
    920 #ifdef CONFIG_PM
    921961static void alc_power_eapd(struct hda_codec *codec)
    922962{
     
    932972        return 0;
    933973}
    934 #endif
    935 
    936 #ifdef CONFIG_PM
     974
    937975static int alc_resume(struct hda_codec *codec)
    938976{
     
    961999        .check_power_status = snd_hda_gen_check_power_status,
    9621000#endif
    963         .reboot_notify = alc_reboot_notify,
    9641001};
    9651002
     
    11671204        codec->forced_resume = 1;
    11681205        codec->patch_ops = alc_patch_ops;
     1206        mutex_init(&spec->coef_mutex);
    11691207
    11701208        err = alc_codec_rename_from_preset(codec);
     
    22952333        ALC887_FIXUP_BASS_CHMAP,
    22962334        ALC1220_FIXUP_GB_DUAL_CODECS,
     2335        ALC1220_FIXUP_GB_X570,
    22972336        ALC1220_FIXUP_CLEVO_P950,
    22982337        ALC1220_FIXUP_CLEVO_PB51ED,
     
    23002339        ALC887_FIXUP_ASUS_AUDIO,
    23012340        ALC887_FIXUP_ASUS_HMIC,
     2341        ALCS1200A_FIXUP_MIC_VREF,
    23022342};
    23032343
     
    24802520                           "Rear-Panel Capture Switch" :
    24812521                           "Front-Panel Capture Switch");
     2522                break;
     2523        }
     2524}
     2525
     2526static void alc1220_fixup_gb_x570(struct hda_codec *codec,
     2527                                     const struct hda_fixup *fix,
     2528                                     int action)
     2529{
     2530        static const hda_nid_t conn1[] = { 0x0c };
     2531        static const struct coef_fw gb_x570_coefs[] = {
     2532                WRITE_COEF(0x07, 0x03c0),
     2533                WRITE_COEF(0x1a, 0x01c1),
     2534                WRITE_COEF(0x1b, 0x0202),
     2535                WRITE_COEF(0x43, 0x3005),
     2536                {0}
     2537        };
     2538
     2539        switch (action) {
     2540        case HDA_FIXUP_ACT_PRE_PROBE:
     2541                snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
     2542                snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
     2543                break;
     2544        case HDA_FIXUP_ACT_INIT:
     2545                alc_process_coef_fw(codec, gb_x570_coefs);
    24822546                break;
    24832547        }
     
    29723036                .v.func = alc1220_fixup_gb_dual_codecs,
    29733037        },
     3038        [ALC1220_FIXUP_GB_X570] = {
     3039                .type = HDA_FIXUP_FUNC,
     3040                .v.func = alc1220_fixup_gb_x570,
     3041        },
    29743042        [ALC1220_FIXUP_CLEVO_P950] = {
    29753043                .type = HDA_FIXUP_FUNC,
     
    30053073                .chain_id = ALC887_FIXUP_ASUS_AUDIO,
    30063074        },
     3075#ifdef TARGET_OS2xxx
     3076        [ALCS1200A_FIXUP_MIC_VREF] = {
     3077                .type = HDA_FIXUP_PINCTLS,
     3078                .v.pins = (const struct hda_pintbl[]) {
     3079                        { 0x18, PIN_VREF50 }, /* rear mic */
     3080                        { 0x19, PIN_VREF50 }, /* front mic */
     3081                        {}
     3082                }
     3083        },
     3084#endif
    30073085};
    30083086
     
    30423120        SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
    30433121        SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
     3122        SND_PCI_QUIRK(0x1043, 0x8797, "ASUS TUF B550M-PLUS", ALCS1200A_FIXUP_MIC_VREF),
    30443123        SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
    30453124        SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
     
    30763155        SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
    30773156        SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
    3078         SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_CLEVO_P950),
    3079         SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_CLEVO_P950),
     3157        SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_GB_X570),
     3158        SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_GB_X570),
     3159        SND_PCI_QUIRK(0x1458, 0xa0d5, "Gigabyte X570S Aorus Master", ALC1220_FIXUP_GB_X570),
    30803160        SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950),
    30813161        SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
     
    30943174        SND_PCI_QUIRK(0x1558, 0x65e1, "Clevo PB51[ED][DF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
    30953175        SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
     3176        SND_PCI_QUIRK(0x1558, 0x65f1, "Clevo PC50HS", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
     3177        SND_PCI_QUIRK(0x1558, 0x65f5, "Clevo PD50PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
    30963178        SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
    30973179        SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
    30983180        SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
     3181        SND_PCI_QUIRK(0x1558, 0x67f1, "Clevo PC70H[PRS]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
     3182        SND_PCI_QUIRK(0x1558, 0x67f5, "Clevo PD70PN[NRT]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
    30993183        SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
    3100         SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
     3184        SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
     3185        SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
    31013186        SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
    31023187        SND_PCI_QUIRK(0x1558, 0x9506, "Clevo P955HQ", ALC1220_FIXUP_CLEVO_P950),
     
    31493234        {.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
    31503235        {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
     3236        {.id = ALC1220_FIXUP_GB_X570, .name = "gb-x570"},
    31513237        {.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
    31523238        {0}
     
    36973783        ALC269_TYPE_ALC215,
    36983784        ALC269_TYPE_ALC225,
     3785        ALC269_TYPE_ALC245,
    36993786        ALC269_TYPE_ALC287,
    37003787        ALC269_TYPE_ALC294,
     
    37343821        case ALC269_TYPE_ALC215:
    37353822        case ALC269_TYPE_ALC225:
     3823        case ALC269_TYPE_ALC245:
    37363824        case ALC269_TYPE_ALC287:
    37373825        case ALC269_TYPE_ALC294:
     
    38033891        case 0x10ec0236:
    38043892        case 0x10ec0256:
     3893        case 0x19e58326:
    38053894                alc_write_coef_idx(codec, 0x48, 0x0);
    38063895                alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
     
    38313920        case 0x10ec0236:
    38323921        case 0x10ec0256:
     3922        case 0x19e58326:
    38333923                alc_write_coef_idx(codec, 0x48, 0xd011);
    38343924                alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
     
    41844274         * when booting with headset plugged. So skip setting it for the codec alc257
    41854275         */
    4186         if (codec->core.vendor_id != 0x10ec0257)
     4276        if (codec->core.vendor_id != 0x10ec0236 &&
     4277            codec->core.vendor_id != 0x10ec0257)
    41874278                alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
    41884279
     
    42624353        bool hp1_pin_sense, hp2_pin_sense;
    42634354
    4264         if (spec->codec_variant != ALC269_TYPE_ALC287)
     4355        if (spec->codec_variant != ALC269_TYPE_ALC287 &&
     4356                spec->codec_variant != ALC269_TYPE_ALC245)
    42654357                /* required only at boot or S3 and S4 resume time */
    42664358#ifndef TARGET_OS2
     
    50255117{
    50265118        alc_fixup_hp_gpio_led(codec, action, 0x10, 0);
     5119}
     5120
     5121static void alc245_fixup_hp_gpio_led(struct hda_codec *codec,
     5122                                const struct hda_fixup *fix, int action)
     5123{
     5124        struct alc_spec *spec = codec->spec;
     5125
     5126        if (action == HDA_FIXUP_ACT_PRE_PROBE)
     5127                spec->micmute_led_polarity = 1;
     5128        alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
    50275129}
    50285130
     
    55015603        case 0x10ec0236:
    55025604        case 0x10ec0256:
     5605        case 0x19e58326:
    55035606                alc_process_coef_fw(codec, coef0256);
    55045607                break;
     
    56165719        case 0x10ec0236:
    56175720        case 0x10ec0256:
     5721        case 0x19e58326:
    56185722                alc_write_coef_idx(codec, 0x45, 0xc489);
    56195723                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
     
    57665870        case 0x10ec0236:
    57675871        case 0x10ec0256:
     5872        case 0x19e58326:
    57685873                alc_write_coef_idx(codec, 0x1b, 0x0e4b);
    57695874                alc_write_coef_idx(codec, 0x45, 0xc089);
     
    58655970        case 0x10ec0236:
    58665971        case 0x10ec0256:
     5972        case 0x19e58326:
    58675973                alc_process_coef_fw(codec, coef0256);
    58685974                break;
     
    59796085        case 0x10ec0236:
    59806086        case 0x10ec0256:
     6087        case 0x19e58326:
    59816088                alc_process_coef_fw(codec, coef0256);
    59826089                break;
     
    60806187        case 0x10ec0236:
    60816188        case 0x10ec0256:
     6189        case 0x19e58326:
    60826190                alc_write_coef_idx(codec, 0x1b, 0x0e4b);
    60836191                alc_write_coef_idx(codec, 0x06, 0x6104);
     
    63766484        case 0x10ec0236:
    63776485        case 0x10ec0256:
     6486        case 0x19e58326:
    63786487                alc_process_coef_fw(codec, alc256fw);
    63796488                break;
     
    64666575
    64676576        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
    6468                 spec->reboot_notify = snd_hda_gen_reboot_notify; /* reduce noise */
    64696577                spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
    64706578                codec->power_save_node = 0; /* avoid click noises */
     
    69807088        case 0x10ec0255:
    69817089        case 0x10ec0256:
     7090        case 0x19e58326:
    69827091                alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
    69837092                alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
     
    71107219#endif /* NOT_USED */
    71117220
     7221/* GPIO1 = amplifier on/off
     7222 * GPIO3 = mic mute LED
     7223 */
     7224static void alc285_fixup_hp_spectre_x360_eb1(struct hda_codec *codec,
     7225                                          const struct hda_fixup *fix, int action)
     7226{
     7227        static const hda_nid_t conn[] = { 0x02 };
     7228
     7229        struct alc_spec *spec = codec->spec;
     7230        static const struct hda_pintbl pincfgs[] = {
     7231                { 0x14, 0x90170110 },  /* front/high speakers */
     7232                { 0x17, 0x90170130 },  /* back/bass speakers */
     7233                {0}
     7234        };
     7235
     7236        //enable micmute led
     7237        alc_fixup_hp_gpio_led(codec, action, 0x00, 0x04);
     7238
     7239        switch (action) {
     7240        case HDA_FIXUP_ACT_PRE_PROBE:
     7241                spec->micmute_led_polarity = 1;
     7242                /* needed for amp of back speakers */
     7243                spec->gpio_mask |= 0x01;
     7244                spec->gpio_dir |= 0x01;
     7245                snd_hda_apply_pincfgs(codec, pincfgs);
     7246                /* share DAC to have unified volume control */
     7247                snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
     7248                snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
     7249                break;
     7250        case HDA_FIXUP_ACT_INIT:
     7251                /* need to toggle GPIO to enable the amp of back speakers */
     7252                alc_update_gpio_data(codec, 0x01, true);
     7253                msleep(100);
     7254                alc_update_gpio_data(codec, 0x01, false);
     7255                break;
     7256        }
     7257}
     7258
    71127259static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
    71137260                                          const struct hda_fixup *fix, int action)
     
    71387285}
    71397286
     7287/* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */
     7288static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
     7289                                                  const struct hda_fixup *fix,
     7290                                                  int action)
     7291{
     7292        struct alc_spec *spec = codec->spec;
     7293
     7294        switch (action) {
     7295        case HDA_FIXUP_ACT_PRE_PROBE:
     7296                spec->gen.suppress_auto_mute = 1;
     7297                break;
     7298        }
     7299}
     7300
    71407301/* for alc295_fixup_hp_top_speakers */
    71417302#include "hp_x360_helper.c"
     
    71437304/* for alc285_fixup_ideapad_s740_coef() */
    71447305#include "ideapad_s740_helper.c"
     7306
     7307static const struct coef_fw alc256_fixup_set_coef_defaults_coefs[] = {
     7308        WRITE_COEF(0x10, 0x0020), WRITE_COEF(0x24, 0x0000),
     7309        WRITE_COEF(0x26, 0x0000), WRITE_COEF(0x29, 0x3000),
     7310        WRITE_COEF(0x37, 0xfe05), WRITE_COEF(0x45, 0x5089),
     7311        {0}
     7312};
     7313
     7314static void alc256_fixup_set_coef_defaults(struct hda_codec *codec,
     7315                                           const struct hda_fixup *fix,
     7316                                           int action)
     7317{
     7318        /*
     7319         * A certain other OS sets these coeffs to different values. On at least
     7320         * one TongFang barebone these settings might survive even a cold
     7321         * reboot. So to restore a clean slate the values are explicitly reset
     7322         * to default here. Without this, the external microphone is always in a
     7323         * plugged-in state, while the internal microphone is always in an
     7324         * unplugged state, breaking the ability to use the internal microphone.
     7325         */
     7326        alc_process_coef_fw(codec, alc256_fixup_set_coef_defaults_coefs);
     7327}
     7328
     7329static const struct coef_fw alc233_fixup_no_audio_jack_coefs[] = {
     7330        WRITE_COEF(0x1a, 0x9003), WRITE_COEF(0x1b, 0x0e2b), WRITE_COEF(0x37, 0xfe06),
     7331        WRITE_COEF(0x38, 0x4981), WRITE_COEF(0x45, 0xd489), WRITE_COEF(0x46, 0x0074),
     7332        WRITE_COEF(0x49, 0x0149),
     7333        {0}
     7334};
     7335
     7336static void alc233_fixup_no_audio_jack(struct hda_codec *codec,
     7337                                       const struct hda_fixup *fix,
     7338                                       int action)
     7339{
     7340        /*
     7341         * The audio jack input and output is not detected on the ASRock NUC Box
     7342         * 1100 series when cold booting without this fix. Warm rebooting from a
     7343         * certain other OS makes the audio functional, as COEF settings are
     7344         * preserved in this case. This fix sets these altered COEF values as
     7345         * the default.
     7346         */
     7347        alc_process_coef_fw(codec, alc233_fixup_no_audio_jack_coefs);
     7348}
     7349
     7350static void alc256_fixup_mic_no_presence_and_resume(struct hda_codec *codec,
     7351                                                    const struct hda_fixup *fix,
     7352                                                    int action)
     7353{
     7354        /*
     7355         * The Clevo NJ51CU comes either with the ALC293 or the ALC256 codec,
     7356         * but uses the 0x8686 subproduct id in both cases. The ALC256 codec
     7357         * needs an additional quirk for sound working after suspend and resume.
     7358         */
     7359        if (codec->core.vendor_id == 0x10ec0256) {
     7360                alc_update_coef_idx(codec, 0x10, 1<<9, 0);
     7361                snd_hda_codec_set_pincfg(codec, 0x19, 0x04a11120);
     7362        } else {
     7363                snd_hda_codec_set_pincfg(codec, 0x1a, 0x04a1113c);
     7364        }
     7365}
    71457366
    71467367enum {
     
    72307451        ALC280_FIXUP_HP_9480M,
    72317452        ALC245_FIXUP_HP_X360_AMP,
     7453        ALC285_FIXUP_HP_SPECTRE_X360_EB1,
    72327454        ALC288_FIXUP_DELL_HEADSET_MODE,
    72337455        ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
     
    72567478        ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
    72577479        ALC269_FIXUP_ATIV_BOOK_8,
     7480        ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE,
    72587481        ALC221_FIXUP_HP_MIC_NO_PRESENCE,
    72597482        ALC256_FIXUP_ASUS_HEADSET_MODE,
     
    73177540        ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
    73187541        ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
     7542        ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
    73197543        ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
    73207544        ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS,
     
    73427566        ALC287_FIXUP_HP_GPIO_LED,
    73437567        ALC256_FIXUP_HP_HEADSET_MIC,
     7568        ALC245_FIXUP_HP_GPIO_LED,
    73447569        ALC236_FIXUP_DELL_AIO_HEADSET_MIC,
    73457570        ALC282_FIXUP_ACER_DISABLE_LINEOUT,
     
    73557580        ALC255_FIXUP_ACER_HEADPHONE_AND_MIC,
    73567581        ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST,
    7357 };
     7582        ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
     7583        ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
     7584        ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
     7585        ALC298_FIXUP_LENOVO_C940_DUET7,
     7586        ALC287_FIXUP_13S_GEN2_SPEAKERS,
     7587        ALC256_FIXUP_SET_COEF_DEFAULTS,
     7588        ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
     7589        ALC233_FIXUP_NO_AUDIO_JACK,
     7590        ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME,
     7591        ALC285_FIXUP_LEGION_Y9000X_SPEAKERS,
     7592        ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE,
     7593};
     7594
     7595#ifdef NOT_USED
     7596/* A special fixup for Lenovo C940 and Yoga Duet 7;
     7597 * both have the very same PCI SSID, and we need to apply different fixups
     7598 * depending on the codec ID
     7599 */
     7600static void alc298_fixup_lenovo_c940_duet7(struct hda_codec *codec,
     7601                                           const struct hda_fixup *fix,
     7602                                           int action)
     7603{
     7604        int id;
     7605
     7606        if (codec->core.vendor_id == 0x10ec0298)
     7607                id = ALC298_FIXUP_LENOVO_SPK_VOLUME; /* C940 */
     7608        else
     7609                id = ALC287_FIXUP_YOGA7_14ITL_SPEAKERS; /* Duet 7 */
     7610        __snd_hda_apply_fixup(codec, id, action, 0);
     7611}
     7612#endif
    73587613
    73597614#ifdef TARGET_OS2
     
    82488503                .type = HDA_FIXUP_FUNC,
    82498504                .v.func = alc245_fixup_hp_x360_amp,
     8505                .chained = true,
     8506                .chain_id = ALC245_FIXUP_HP_GPIO_LED
    82508507        },
    82518508        [ALC288_FIXUP_DELL_HEADSET_MODE] = {
     
    84498706        },
    84508707#ifdef TARGET_OS2xxx
     8708        [ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE] = {
     8709                .type = HDA_FIXUP_PINS,
     8710                .v.pins = (const struct hda_pintbl[]) {
     8711                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
     8712                        { 0x1a, 0x01813030 }, /* use as headphone mic, without its own jack detect */
     8713                        { }
     8714                },
     8715                .chained = true,
     8716                .chain_id = ALC269_FIXUP_HEADSET_MODE
     8717        },
    84518718        [ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
    84528719                .type = HDA_FIXUP_PINS,
     
    89489215                },
    89499216        },
     9217        [ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
     9218                .type = HDA_FIXUP_VERBS,
     9219                .v.verbs = (const struct hda_verb[]) {
     9220                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x08},
     9221                        { 0x20, AC_VERB_SET_PROC_COEF, 0x2fcf},
     9222                        { }
     9223                },
     9224        },
    89509225        [ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = {
    89519226                .type = HDA_FIXUP_PINS,
     
    92279502                .v.func = alc285_fixup_hp_spectre_x360,
    92289503        },
     9504        [ALC285_FIXUP_HP_SPECTRE_X360_EB1] = {
     9505                .type = HDA_FIXUP_FUNC,
     9506                .v.func = alc285_fixup_hp_spectre_x360_eb1
     9507        },
    92299508        [ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = {
    92309509                .type = HDA_FIXUP_FUNC,
     
    92559534                .chained = true,
    92569535                .chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
     9536        },
     9537        [ALC285_FIXUP_LEGION_Y9000X_SPEAKERS] = {
     9538                .type = HDA_FIXUP_FUNC,
     9539                .v.func = alc285_fixup_ideapad_s740_coef,
     9540                .chained = true,
     9541                .chain_id = ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE,
     9542        },
     9543        [ALC285_FIXUP_LEGION_Y9000X_AUTOMUTE] = {
     9544                .type = HDA_FIXUP_FUNC,
     9545                .v.func = alc287_fixup_legion_15imhg05_speakers,
     9546                .chained = true,
     9547                .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
     9548        },
     9549#ifdef TARGET_OS2xxx
     9550        [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = {
     9551                .type = HDA_FIXUP_VERBS,
     9552                //.v.verbs = legion_15imhg05_coefs,
     9553                .v.verbs = (const struct hda_verb[]) {
     9554                         // set left speaker Legion 7i.
     9555                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
     9556                         { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
     9557
     9558                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9559                         { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
     9560                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9561                         { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
     9562                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9563
     9564                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9565                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
     9566                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9567                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9568                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9569
     9570                         // set right speaker Legion 7i.
     9571                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
     9572                         { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
     9573
     9574                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9575                         { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
     9576                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9577                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
     9578                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9579
     9580                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9581                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
     9582                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9583                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9584                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9585                         {}
     9586                },
     9587                .chained = true,
     9588                .chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
     9589        },
     9590#endif
     9591        [ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = {
     9592                .type = HDA_FIXUP_FUNC,
     9593                .v.func = alc287_fixup_legion_15imhg05_speakers,
     9594                .chained = true,
     9595                .chain_id = ALC269_FIXUP_HEADSET_MODE,
     9596        },
     9597#ifdef TARGET_OS2xxx
     9598        [ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = {
     9599                .type = HDA_FIXUP_VERBS,
     9600                .v.verbs = (const struct hda_verb[]) {
     9601                         // set left speaker Yoga 7i.
     9602                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
     9603                         { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
     9604
     9605                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9606                         { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
     9607                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9608                         { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
     9609                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9610
     9611                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9612                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
     9613                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9614                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9615                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9616
     9617                         // set right speaker Yoga 7i.
     9618                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
     9619                         { 0x20, AC_VERB_SET_PROC_COEF, 0x46 },
     9620
     9621                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9622                         { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
     9623                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9624                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
     9625                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9626
     9627                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9628                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
     9629                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9630                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9631                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9632                         {}
     9633                },
     9634                .chained = true,
     9635                .chain_id = ALC269_FIXUP_HEADSET_MODE,
     9636        },
     9637        [ALC298_FIXUP_LENOVO_C940_DUET7] = {
     9638                .type = HDA_FIXUP_FUNC,
     9639                .v.func = alc298_fixup_lenovo_c940_duet7,
     9640        },
     9641        [ALC287_FIXUP_13S_GEN2_SPEAKERS] = {
     9642                .type = HDA_FIXUP_VERBS,
     9643                .v.verbs = (const struct hda_verb[]) {
     9644                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
     9645                        { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
     9646                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9647                        { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
     9648                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9649                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9650                        { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9651                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
     9652                        { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
     9653                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
     9654                        { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
     9655                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9656                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
     9657                        { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
     9658                        {}
     9659                },
     9660                .chained = true,
     9661                .chain_id = ALC269_FIXUP_HEADSET_MODE,
     9662        },
     9663#endif
     9664        [ALC256_FIXUP_SET_COEF_DEFAULTS] = {
     9665                .type = HDA_FIXUP_FUNC,
     9666                .v.func = alc256_fixup_set_coef_defaults,
     9667        },
     9668#ifdef TARGET_OS2xxx
     9669        [ALC245_FIXUP_HP_GPIO_LED] = {
     9670                .type = HDA_FIXUP_FUNC,
     9671                .v.func = alc245_fixup_hp_gpio_led,
     9672        },
     9673        [ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
     9674                .type = HDA_FIXUP_PINS,
     9675                .v.pins = (const struct hda_pintbl[]) {
     9676                        { 0x19, 0x03a11120 }, /* use as headset mic, without its own jack detect */
     9677                        { }
     9678                },
     9679                .chained = true,
     9680                .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
     9681        },
     9682#endif
     9683        [ALC233_FIXUP_NO_AUDIO_JACK] = {
     9684                .type = HDA_FIXUP_FUNC,
     9685                .v.func = alc233_fixup_no_audio_jack,
     9686        },
     9687        [ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME] = {
     9688                .type = HDA_FIXUP_FUNC,
     9689                .v.func = alc256_fixup_mic_no_presence_and_resume,
     9690                .chained = true,
     9691                .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
    92579692        },
    92589693};
     
    92889723        SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
    92899724        SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC),
     9725        SND_PCI_QUIRK(0x1025, 0x129d, "Acer SWIFT SF313-51", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
    92909726        SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
    92919727        SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
    92929728        SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
    92939729        SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
     9730        SND_PCI_QUIRK(0x1025, 0x141f, "Acer Spin SP513-54N", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
    92949731        SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
    92959732        SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
    92969733        SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
    92979734        SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
     9735        SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X),
    92989736        SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
    92999737        SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
     
    93479785        SND_PCI_QUIRK(0x1028, 0x0a58, "Dell", ALC255_FIXUP_DELL_HEADSET_MIC),
    93489786        SND_PCI_QUIRK(0x1028, 0x0a61, "Dell XPS 15 9510", ALC289_FIXUP_DUAL_SPK),
     9787        SND_PCI_QUIRK(0x1028, 0x0a62, "Dell Precision 5560", ALC289_FIXUP_DUAL_SPK),
     9788        SND_PCI_QUIRK(0x1028, 0x0a9d, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
     9789        SND_PCI_QUIRK(0x1028, 0x0a9e, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
     9790        SND_PCI_QUIRK(0x1028, 0x0b19, "Dell XPS 15 9520", ALC289_FIXUP_DUAL_SPK),
    93499791        SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
    93509792        SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
     
    94069848        SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
    94079849        SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
     9850        SND_PCI_QUIRK(0x103c, 0x2b5e, "HP 288 Pro G2 MT", ALC221_FIXUP_HP_288PRO_MIC_NO_PRESENCE),
    94089851        SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
    94099852        SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
     
    94229865        SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
    94239866        SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
     9867        SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT),
    94249868        SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT),
    94259869        SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
     
    94289872        SND_PCI_QUIRK(0x103c, 0x8720, "HP EliteBook x360 1040 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
    94299873        SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED),
     9874        SND_PCI_QUIRK(0x103c, 0x8728, "HP EliteBook 840 G7", ALC285_FIXUP_HP_GPIO_LED),
    94309875        SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
    94319876        SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
     9877        SND_PCI_QUIRK(0x103c, 0x8735, "HP ProBook 435 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
    94329878        SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT),
    94339879        SND_PCI_QUIRK(0x103c, 0x8760, "HP", ALC285_FIXUP_HP_MUTE_LED),
     
    94389884        SND_PCI_QUIRK(0x103c, 0x8783, "HP ZBook Fury 15 G7 Mobile Workstation",
    94399885                      ALC285_FIXUP_HP_GPIO_AMP_INIT),
     9886        SND_PCI_QUIRK(0x103c, 0x8787, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
     9887        SND_PCI_QUIRK(0x103c, 0x8788, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED),
    94409888        SND_PCI_QUIRK(0x103c, 0x87c8, "HP", ALC287_FIXUP_HP_GPIO_LED),
    94419889        SND_PCI_QUIRK(0x103c, 0x87e5, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
     
    94499897        SND_PCI_QUIRK(0x103c, 0x8805, "HP ProBook 650 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
    94509898        SND_PCI_QUIRK(0x103c, 0x880d, "HP EliteBook 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
     9899        SND_PCI_QUIRK(0x103c, 0x8811, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
     9900        SND_PCI_QUIRK(0x103c, 0x8812, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
    94519901        SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
    94529902        SND_PCI_QUIRK(0x103c, 0x8847, "HP EliteBook x360 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
     
    94629912        SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
    94639913        SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED),
     9914        SND_PCI_QUIRK(0x103c, 0x89aa, "HP EliteBook 630 G9", ALC236_FIXUP_HP_GPIO_LED),
     9915        SND_PCI_QUIRK(0x103c, 0x89c3, "HP", ALC285_FIXUP_HP_GPIO_LED),
     9916        SND_PCI_QUIRK(0x103c, 0x89ca, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
     9917        SND_PCI_QUIRK(0x103c, 0x8a78, "HP Dev One", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
     9918        SND_PCI_QUIRK(0x103c, 0x8aa0, "HP ProBook 440 G9 (MB 8A9E)", ALC236_FIXUP_HP_GPIO_LED),
     9919        SND_PCI_QUIRK(0x103c, 0x8aa3, "HP ProBook 450 G9 (MB 8AA1)", ALC236_FIXUP_HP_GPIO_LED),
     9920        SND_PCI_QUIRK(0x103c, 0x8aa8, "HP EliteBook 640 G9 (MB 8AA6)", ALC236_FIXUP_HP_GPIO_LED),
     9921        SND_PCI_QUIRK(0x103c, 0x8aab, "HP EliteBook 650 G9 (MB 8AA9)", ALC236_FIXUP_HP_GPIO_LED),
    94649922        SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
    94659923        SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
     
    94879945        SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),
    94889946        SND_PCI_QUIRK(0x1043, 0x194e, "ASUS UX563FD", ALC294_FIXUP_ASUS_HPE),
     9947        SND_PCI_QUIRK(0x1043, 0x1970, "ASUS UX550VE", ALC289_FIXUP_ASUS_GA401),
    94899948        SND_PCI_QUIRK(0x1043, 0x1982, "ASUS B1400CEPE", ALC256_FIXUP_ASUS_HPE),
    94909949        SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
     
    95029961        SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401),
    95039962        SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
     9963        SND_PCI_QUIRK(0x1043, 0x1d42, "ASUS Zephyrus G14 2022", ALC289_FIXUP_ASUS_GA401),
     9964        SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
    95049965        SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
    95059966        SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
     
    95349995        SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
    95359996        SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
     9997        SND_PCI_QUIRK(0x144d, 0xc832, "Samsung Galaxy Book Flex Alpha (NP730QCJ)", ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
    95369998        SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
    95379999        SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
     
    955010012        SND_PCI_QUIRK(0x1558, 0x40c1, "Clevo NL40[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    955110013        SND_PCI_QUIRK(0x1558, 0x40d1, "Clevo NL41DU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10014        SND_PCI_QUIRK(0x1558, 0x5015, "Clevo NH5[58]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10015        SND_PCI_QUIRK(0x1558, 0x5017, "Clevo NH7[79]H[HJK]Q", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    955210016        SND_PCI_QUIRK(0x1558, 0x50a3, "Clevo NJ51GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    955310017        SND_PCI_QUIRK(0x1558, 0x50b3, "Clevo NK50S[BEZ]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     
    955510019        SND_PCI_QUIRK(0x1558, 0x50b8, "Clevo NK50SZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    955610020        SND_PCI_QUIRK(0x1558, 0x50d5, "Clevo NP50D5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10021        SND_PCI_QUIRK(0x1558, 0x50e1, "Clevo NH5[58]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10022        SND_PCI_QUIRK(0x1558, 0x50e2, "Clevo NH7[79]HPQ", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    955710023        SND_PCI_QUIRK(0x1558, 0x50f0, "Clevo NH50A[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    955810024        SND_PCI_QUIRK(0x1558, 0x50f2, "Clevo NH50E[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     
    956910035        SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    957010036        SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10037        SND_PCI_QUIRK(0x1558, 0x7716, "Clevo NS50PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10038        SND_PCI_QUIRK(0x1558, 0x7718, "Clevo L140PU", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    957110039        SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    957210040        SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     
    958010048        SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[57][0-9]RZ[Q]", ALC269_FIXUP_DMIC),
    958110049        SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10050        SND_PCI_QUIRK(0x1558, 0x866d, "Clevo NP5[05]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10051        SND_PCI_QUIRK(0x1558, 0x867c, "Clevo NP7[01]PNP", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10052        SND_PCI_QUIRK(0x1558, 0x867d, "Clevo NP7[01]PN[HJK]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    958210053        SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    9583         SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     10054        SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC256_FIXUP_MIC_NO_PRESENCE_AND_RESUME),
    958410055        SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
    958510056        SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
     
    964710118        SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
    964810119        SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
    9649         SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME),
     10120        SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo Yoga DuetITL 2021", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
     10121        SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
     10122        SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940 / Yoga Duet 7", ALC298_FIXUP_LENOVO_C940_DUET7),
     10123        SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
     10124        SND_PCI_QUIRK(0x17aa, 0x3820, "Yoga Duet 7 13ITL6", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
     10125        SND_PCI_QUIRK(0x17aa, 0x3824, "Legion Y9000X 2020", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
    965010126        SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
     10127        SND_PCI_QUIRK(0x17aa, 0x3834, "Lenovo IdeaPad Slim 9i 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
     10128        SND_PCI_QUIRK(0x17aa, 0x383d, "Legion Y9000X 2019", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
    965110129        SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP),
     10130        SND_PCI_QUIRK(0x17aa, 0x384a, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
     10131        SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
     10132        SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
    965210133        SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
    965310134        SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
     
    966910150        SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
    967010151        SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
     10152        SND_PCI_QUIRK(0x17aa, 0x508b, "Thinkpad X12 Gen 1", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
    967110153        SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
    967210154        SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
    967310155        SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
    967410156        SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
     10157        SND_PCI_QUIRK(0x1849, 0x1233, "ASRock NUC Box 1100", ALC233_FIXUP_NO_AUDIO_JACK),
    967510158        SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS),
    967610159        SND_PCI_QUIRK(0x1b35, 0x1235, "CZC B20", ALC269_FIXUP_CZC_B20),
     
    968010163        SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
    968110164        SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
     10165        SND_PCI_QUIRK(0x1d05, 0x1132, "TongFang PHxTxX1", ALC256_FIXUP_SET_COEF_DEFAULTS),
     10166        SND_PCI_QUIRK(0x1d05, 0x1096, "TongFang GMxMRxx", ALC269_FIXUP_NO_SHUTUP),
     10167        SND_PCI_QUIRK(0x1d05, 0x1100, "TongFang GKxNRxx", ALC269_FIXUP_NO_SHUTUP),
     10168        SND_PCI_QUIRK(0x1d05, 0x1111, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
     10169        SND_PCI_QUIRK(0x1d05, 0x1119, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
     10170        SND_PCI_QUIRK(0x1d05, 0x1129, "TongFang GMxZGxx", ALC269_FIXUP_NO_SHUTUP),
     10171        SND_PCI_QUIRK(0x1d05, 0x1147, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP),
     10172        SND_PCI_QUIRK(0x1d05, 0x115c, "TongFang GMxTGxx", ALC269_FIXUP_NO_SHUTUP),
     10173        SND_PCI_QUIRK(0x1d05, 0x121b, "TongFang GMxAGxx", ALC269_FIXUP_NO_SHUTUP),
    968210174        SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
    968310175        SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
    968410176        SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
     10177        SND_PCI_QUIRK(0x1d72, 0x1945, "Redmi G", ALC256_FIXUP_ASUS_HEADSET_MIC),
    968510178        SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
    968610179        SND_PCI_QUIRK(0x8086, 0x2074, "Intel NUC 8", ALC233_FIXUP_INTEL_NUC8_DMIC),
     
    986010353        {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
    986110354        {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"},
     10355        {.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"},
    986210356        {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
    986310357        {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},
     
    986510359        {.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"},
    986610360        {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"},
     10361        {.id = ALC285_FIXUP_HP_SPECTRE_X360_EB1, .name = "alc285-hp-spectre-x360-eb1"},
    986710362        {.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"},
    986810363        {.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"},
    986910364        {.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"},
     10365        {.id = ALC285_FIXUP_HP_GPIO_AMP_INIT, .name = "alc285-hp-amp-init"},
    987010366        {0}
    987110367};
     
    1046310959        case 0x10ec0236:
    1046410960        case 0x10ec0256:
     10961        case 0x19e58326:
    1046510962                spec->codec_variant = ALC269_TYPE_ALC256;
    1046610963                spec->shutup = alc256_shutup;
     
    1047810975        case 0x10ec0285:
    1047910976        case 0x10ec0289:
    10480                 spec->codec_variant = ALC269_TYPE_ALC215;
     10977                if (alc_get_coef0(codec) & 0x0010)
     10978                        spec->codec_variant = ALC269_TYPE_ALC245;
     10979                else
     10980                        spec->codec_variant = ALC269_TYPE_ALC215;
    1048110981                spec->shutup = alc225_shutup;
    1048210982                spec->init_hook = alc225_init;
     
    1102011520                alc_write_coef_idx(codec, 0x19, 0xa054);
    1102111521                break;
     11522        }
     11523}
     11524
     11525static void alc897_hp_automute_hook(struct hda_codec *codec,
     11526                                         struct hda_jack_callback *jack)
     11527{
     11528        struct alc_spec *spec = codec->spec;
     11529        int vref;
     11530
     11531        snd_hda_gen_hp_automute(codec, jack);
     11532        vref = spec->gen.hp_jack_present ? (PIN_HP | AC_PINCTL_VREF_100) : PIN_HP;
     11533        snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
     11534                            vref);
     11535}
     11536
     11537static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec,
     11538                                     const struct hda_fixup *fix, int action)
     11539{
     11540        struct alc_spec *spec = codec->spec;
     11541        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
     11542                spec->gen.hp_automute_hook = alc897_hp_automute_hook;
    1102211543        }
    1102311544}
     
    1110011621        ALC662_FIXUP_ACER_X2660G_HEADSET_MODE,
    1110111622        ALC662_FIXUP_ACER_NITRO_HEADSET_MODE,
     11623        ALC668_FIXUP_ASUS_NO_HEADSET_MIC,
     11624        ALC668_FIXUP_HEADSET_MIC,
     11625        ALC668_FIXUP_MIC_DET_COEF,
     11626        ALC897_FIXUP_LENOVO_HEADSET_MIC,
     11627        ALC897_FIXUP_HEADSET_MIC_PIN,
     11628        ALC897_FIXUP_HP_HSMIC_VERB,
    1110211629};
    1110311630
     
    1166612193                .chained = true,
    1166712194                .chain_id = ALC662_FIXUP_USI_FUNC
     12195        },
     12196        [ALC668_FIXUP_ASUS_NO_HEADSET_MIC] = {
     12197                .type = HDA_FIXUP_PINS,
     12198                .v.pins = (const struct hda_pintbl[]) {
     12199                        { 0x1b, 0x04a1112c },
     12200                        { }
     12201                },
     12202                .chained = true,
     12203                .chain_id = ALC668_FIXUP_HEADSET_MIC
     12204        },
     12205#endif
     12206        [ALC668_FIXUP_HEADSET_MIC] = {
     12207                .type = HDA_FIXUP_FUNC,
     12208                .v.func = alc269_fixup_headset_mic,
     12209                .chained = true,
     12210                .chain_id = ALC668_FIXUP_MIC_DET_COEF
     12211        },
     12212#ifdef TARGET_OS2xxx
     12213        [ALC668_FIXUP_MIC_DET_COEF] = {
     12214                .type = HDA_FIXUP_VERBS,
     12215                .v.verbs = (const struct hda_verb[]) {
     12216                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x15 },
     12217                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 },
     12218                        {}
     12219                },
     12220        },
     12221#endif
     12222        [ALC897_FIXUP_LENOVO_HEADSET_MIC] = {
     12223                .type = HDA_FIXUP_FUNC,
     12224                .v.func = alc897_fixup_lenovo_headset_mic,
     12225        },
     12226#ifdef TARGET_OS2xxx
     12227        [ALC897_FIXUP_HEADSET_MIC_PIN] = {
     12228                .type = HDA_FIXUP_PINS,
     12229                .v.pins = (const struct hda_pintbl[]) {
     12230                        { 0x1a, 0x03a11050 },
     12231                        { }
     12232                },
     12233                .chained = true,
     12234                .chain_id = ALC897_FIXUP_LENOVO_HEADSET_MIC
     12235        },
     12236        [ALC897_FIXUP_HP_HSMIC_VERB] = {
     12237                .type = HDA_FIXUP_PINS,
     12238                .v.pins = (const struct hda_pintbl[]) {
     12239                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
     12240                        { }
     12241                },
    1166812242        },
    1166912243#endif
     
    1169312267        SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
    1169412268        SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
     12269        SND_PCI_QUIRK(0x103c, 0x8719, "HP", ALC897_FIXUP_HP_HSMIC_VERB),
    1169512270        SND_PCI_QUIRK(0x103c, 0x873e, "HP", ALC671_FIXUP_HP_HEADSET_MIC2),
     12271        SND_PCI_QUIRK(0x103c, 0x877e, "HP 288 Pro G6", ALC671_FIXUP_HP_HEADSET_MIC2),
     12272        SND_PCI_QUIRK(0x103c, 0x885f, "HP 288 Pro G8", ALC671_FIXUP_HP_HEADSET_MIC2),
    1169612273        SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
    1169712274        SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
     
    1170312280        SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
    1170412281        SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
     12282        SND_PCI_QUIRK(0x1043, 0x185d, "ASUS G551JW", ALC668_FIXUP_ASUS_NO_HEADSET_MIC),
    1170512283        SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
    1170612284        SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
     
    1171112289        SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
    1171212290        SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
     12291        SND_PCI_QUIRK(0x17aa, 0x1057, "Lenovo P360", ALC897_FIXUP_HEADSET_MIC_PIN),
     12292        SND_PCI_QUIRK(0x17aa, 0x32ca, "Lenovo ThinkCentre M80", ALC897_FIXUP_HEADSET_MIC_PIN),
     12293        SND_PCI_QUIRK(0x17aa, 0x32cb, "Lenovo ThinkCentre M70", ALC897_FIXUP_HEADSET_MIC_PIN),
     12294        SND_PCI_QUIRK(0x17aa, 0x32cf, "Lenovo ThinkCentre M950", ALC897_FIXUP_HEADSET_MIC_PIN),
     12295        SND_PCI_QUIRK(0x17aa, 0x32f7, "Lenovo ThinkCentre M90", ALC897_FIXUP_HEADSET_MIC_PIN),
    1171312296        SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
    1171412297        SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
     
    1206912652        HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
    1207012653        HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
     12654        HDA_CODEC_ENTRY(0x19e58326, "HW8326", patch_alc269),
    1207112655        {0} /* terminator */
    1207212656};
  • GPL/trunk/alsa-kernel/pci/hda/patch_sigmatel.c

    r695 r717  
    44824482}
    44834483
    4484 static void stac_shutup(struct hda_codec *codec)
    4485 {
    4486         struct sigmatel_spec *spec = codec->spec;
    4487 
    4488         snd_hda_shutup_pins(codec);
    4489 
    4490         if (spec->eapd_mask)
    4491                 stac_gpio_set(codec, spec->gpio_mask,
    4492                                 spec->gpio_dir, spec->gpio_data &
    4493                                 ~spec->eapd_mask);
    4494 }
    4495 
    44964484#define stac_free       snd_hda_gen_free
    44974485
     
    45464534static int stac_suspend(struct hda_codec *codec)
    45474535{
    4548         stac_shutup(codec);
     4536        struct sigmatel_spec *spec = codec->spec;
     4537
     4538        snd_hda_shutup_pins(codec);
     4539
     4540        if (spec->eapd_mask)
     4541                stac_gpio_set(codec, spec->gpio_mask,
     4542                                spec->gpio_dir, spec->gpio_data &
     4543                                ~spec->eapd_mask);
     4544
    45494545        return 0;
    45504546}
     
    45624558        .suspend = stac_suspend,
    45634559#endif
    4564         .reboot_notify = stac_shutup,
    45654560};
    45664561
  • GPL/trunk/alsa-kernel/pci/hda/patch_via.c

    r703 r717  
    529529                return err;
    530530
     531        err = auto_parse_beep(codec);
     532        if (err < 0)
     533                return err;
     534
    531535        err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
    532         if (err < 0)
    533                 return err;
    534 
    535         err = auto_parse_beep(codec);
    536536        if (err < 0)
    537537                return err;
Note: See TracChangeset for help on using the changeset viewer.