Ignore:
Timestamp:
Aug 21, 2021, 3:35:34 AM (4 years ago)
Author:
David Azarewicz
Message:

Merge changes from next branch.

Location:
GPL/trunk
Files:
64 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/pci/Makefile

    r679 r695  
    1313#
    1414#===================================================================
    15 FILES = pci_iomap_compat.obj ens1370.obj ens1371.obj cs4281.obj  es1938.obj &
     15FILES = pci_iomap_compat.obj ens1370.obj cs4281.obj  es1938.obj &
    1616  es1968.obj intel8x0.obj maestro3.obj via82xx.obj &
    1717  fm801.obj atiixp.obj cmipci.obj als4000.obj bt87x.obj &
    1818  ak4531_codec.obj cs5530.obj
    1919
     20#ens1371.obj  unused code.
    2021#pci_iomap_compat.obj
    2122
  • GPL/trunk/alsa-kernel/pci/ad1889.c

    r679 r695  
    4444MODULE_DESCRIPTION("Analog Devices AD1889 ALSA sound driver");
    4545MODULE_LICENSE("GPL");
    46 MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1889}}");
    4746
    4847static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
     
    858857
    859858        /* check PCI availability (32bit DMA) */
    860         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
    861             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
     859        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
    862860                dev_err(card->dev, "error setting 32-bit DMA mask.\n");
    863861                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/ali5451/ali5451.c

    r679 r695  
    3333MODULE_DESCRIPTION("ALI M5451");
    3434MODULE_LICENSE("GPL");
    35 MODULE_SUPPORTED_DEVICE("{{ALI,M5451,pci},{ALI,M5451}}");
    3635
    3736static int index = SNDRV_DEFAULT_IDX1;  /* Index */
     
    20612060                return err;
    20622061        /* check, if we can restrict PCI DMA transfers to 31 bits */
    2063         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(31)) < 0 ||
    2064             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(31)) < 0) {
     2062        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(31))) {
    20652063                dev_err(card->dev,
    20662064                        "architecture does not support 31bit PCI busmaster DMA\n");
  • GPL/trunk/alsa-kernel/pci/als300.c

    r679 r695  
    8787MODULE_DESCRIPTION("Avance Logic ALS300");
    8888MODULE_LICENSE("GPL");
    89 MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS300},{Avance Logic,ALS300+}}");
    9089
    9190static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
     
    626625                return err;
    627626
    628         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
    629                 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
     627        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
    630628                dev_err(card->dev, "error setting 28bit DMA mask\n");
    631629                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/als4000.c

    r679 r695  
    7272MODULE_DESCRIPTION("Avance Logic ALS4000");
    7373MODULE_LICENSE("GPL");
    74 MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS4000}}");
    7574
    7675#if IS_REACHABLE(CONFIG_GAMEPORT)
     
    841840        }
    842841        /* check, if we can restrict PCI DMA transfers to 24 bits */
    843         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
    844             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
     842        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
    845843                dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n");
    846844                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/atiixp.c

    r679 r695  
    2828MODULE_DESCRIPTION("ATI IXP AC97 controller");
    2929MODULE_LICENSE("GPL");
    30 MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250/300/400/600}}");
    3130
    3231static int index = SNDRV_DEFAULT_IDX1;  /* Index 0-MAX */
  • GPL/trunk/alsa-kernel/pci/atiixp_modem.c

    r679 r695  
    2424MODULE_DESCRIPTION("ATI IXP MC97 controller");
    2525MODULE_LICENSE("GPL");
    26 MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250}}");
    2726
    2827static int index = -2; /* Exclude the first card */
  • GPL/trunk/alsa-kernel/pci/au88x0/au88x0.c

    r679 r695  
    4242MODULE_DESCRIPTION("Aureal vortex");
    4343MODULE_LICENSE("GPL");
    44 MODULE_SUPPORTED_DEVICE("{{Aureal Semiconductor Inc., Aureal Vortex Sound Processor}}");
    45 
    4644MODULE_DEVICE_TABLE(pci, snd_vortex_ids);
    4745
     
    152150        if ((err = pci_enable_device(pci)) < 0)
    153151                return err;
    154         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
    155             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
     152        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
    156153                dev_err(card->dev, "error to set DMA mask\n");
    157154                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/azt3328.c

    r679 r695  
    197197MODULE_DESCRIPTION("Aztech AZF3328 (PCI168)");
    198198MODULE_LICENSE("GPL");
    199 MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}");
    200199
    201200#if IS_REACHABLE(CONFIG_GAMEPORT)
     
    23802379
    23812380        /* check if we can restrict PCI DMA transfers to 24 bits */
    2382         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
    2383             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
     2381        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
    23842382                dev_err(card->dev,
    23852383                        "architecture does not support 24bit PCI busmaster DMA\n"
     
    24492447                /* shutdown codecs to reduce power / noise */
    24502448                        /* have ...ctrl_codec_activity() act properly */
    2451                 codec->running = 1;
     2449                codec->running = true;
    24522450                snd_azf3328_ctrl_codec_activity(chip, codec_type, 0);
    24532451
  • GPL/trunk/alsa-kernel/pci/bt87x.c

    r679 r695  
    2828MODULE_DESCRIPTION("Brooktree Bt87x audio driver");
    2929MODULE_LICENSE("GPL");
    30 MODULE_SUPPORTED_DEVICE("{{Brooktree,Bt878},"
    31                 "{Brooktree,Bt879}}");
    3230
    3331#ifndef TARGET_OS2
     
    337335                irq_block = status >> INT_RISCS_SHIFT;
    338336                if (current_block != irq_block)
    339                         chip->current_line = (irq_block * chip->lines + 15) / 16;
     337                        chip->current_line = DIV_ROUND_UP(irq_block * chip->lines,
     338                                                          16);
    340339
    341340                snd_pcm_period_elapsed(chip->substream);
  • GPL/trunk/alsa-kernel/pci/ca0106/ca0106_main.c

    r679 r695  
    142142MODULE_DESCRIPTION("CA0106");
    143143MODULE_LICENSE("GPL");
    144 MODULE_SUPPORTED_DEVICE("{{Creative,SB CA0106 chip}}");
    145144
    146145// module parameters (see "Module Parameters")
     
    16101609        if (err < 0)
    16111610                return err;
    1612         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
    1613             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
     1611        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
    16141612                dev_err(card->dev, "error to set 32bit mask DMA\n");
    16151613                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/cmipci.c

    r679 r695  
    3434MODULE_DESCRIPTION("C-Media CMI8x38 PCI");
    3535MODULE_LICENSE("GPL");
    36 MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8738},"
    37                 "{C-Media,CMI8738B},"
    38                 "{C-Media,CMI8338A},"
    39                 "{C-Media,CMI8338B}}");
    4036
    4137#if IS_REACHABLE(CONFIG_GAMEPORT)
  • GPL/trunk/alsa-kernel/pci/cs4281.c

    r679 r695  
    2929MODULE_DESCRIPTION("Cirrus Logic CS4281");
    3030MODULE_LICENSE("GPL");
    31 MODULE_SUPPORTED_DEVICE("{{Cirrus Logic,CS4281}}");
    3231
    3332static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
  • GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx.c

    r679 r695  
    2525MODULE_DESCRIPTION("Cirrus Logic Sound Fusion CS46XX");
    2626MODULE_LICENSE("GPL");
    27 MODULE_SUPPORTED_DEVICE("{{Cirrus Logic,Sound Fusion (CS4280)},"
    28                 "{Cirrus Logic,Sound Fusion (CS4610)},"
    29                 "{Cirrus Logic,Sound Fusion (CS4612)},"
    30                 "{Cirrus Logic,Sound Fusion (CS4615)},"
    31                 "{Cirrus Logic,Sound Fusion (CS4622)},"
    32                 "{Cirrus Logic,Sound Fusion (CS4624)},"
    33                 "{Cirrus Logic,Sound Fusion (CS4630)}}");
    3427
    3528static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
  • GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.c

    r679 r695  
    818818        tmp1 -= correctionPerGOF * GOF_PER_SEC;
    819819        correctionPerSec = tmp1;
    820         initialDelay = ((48000 * 24) + rate - 1) / rate;
     820        initialDelay = DIV_ROUND_UP(48000 * 24, rate);
    821821
    822822        /*
  • GPL/trunk/alsa-kernel/pci/cs5535audio/cs5535audio.c

    r679 r695  
    274274                return err;
    275275
    276         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
    277             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
     276        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
    278277                dev_warn(card->dev, "unable to get 32bit dma\n");
    279278                err = -ENXIO;
     
    399398MODULE_LICENSE("GPL");
    400399MODULE_DESCRIPTION("CS5535 Audio");
    401 MODULE_SUPPORTED_DEVICE("CS5535 Audio");
  • GPL/trunk/alsa-kernel/pci/cs5535audio/cs5535audio_olpc.c

    r679 r695  
    159159        memset(&elem, 0, sizeof(elem));
    160160        elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    161         strlcpy(elem.name, "High Pass Filter Enable", sizeof(elem.name));
     161        strscpy(elem.name, "High Pass Filter Enable", sizeof(elem.name));
    162162        snd_ctl_remove_id(card, &elem);
    163163
     
    165165        memset(&elem, 0, sizeof(elem));
    166166        elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
    167         strlcpy(elem.name, "V_REFOUT Enable", sizeof(elem.name));
     167        strscpy(elem.name, "V_REFOUT Enable", sizeof(elem.name));
    168168        snd_ctl_remove_id(card, &elem);
    169169
  • GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1.c

    r679 r695  
    2323MODULE_DESCRIPTION("EMU10K1");
    2424MODULE_LICENSE("GPL");
    25 MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB Live!/PCI512/E-mu APS},"
    26                "{Creative Labs,SB Audigy}}");
    2725
    2826#if IS_ENABLED(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER)
     
    183181#endif
    184182 
    185         strlcpy(card->driver, emu->card_capabilities->driver,
     183        strscpy(card->driver, emu->card_capabilities->driver,
    186184                sizeof(card->driver));
    187         strlcpy(card->shortname, emu->card_capabilities->name,
     185        strscpy(card->shortname, emu->card_capabilities->name,
    188186                sizeof(card->shortname));
    189187        snprintf(card->longname, sizeof(card->longname),
  • GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1_main.c

    r679 r695  
    18831883
    18841884        if (!*card->id && c->id)
    1885                 strlcpy(card->id, c->id, sizeof(card->id));
     1885                strscpy(card->id, c->id, sizeof(card->id));
    18861886
    18871887        is_audigy = emu->audigy = c->emu10k2_chip;
  • GPL/trunk/alsa-kernel/pci/emu10k1/emu10k1x.c

    r679 r695  
    3535MODULE_DESCRIPTION("EMU10K1X");
    3636MODULE_LICENSE("GPL");
    37 MODULE_SUPPORTED_DEVICE("{{Dell Creative Labs,SB Live!}");
    3837
    3938// module parameters (see "Module Parameters")
     
    898897        if ((err = pci_enable_device(pci)) < 0)
    899898                return err;
    900         if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
    901             pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
     899
     900        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28)) < 0) {
    902901                dev_err(card->dev, "error to set 28bit mask DMA\n");
    903902                pci_disable_device(pci);
  • GPL/trunk/alsa-kernel/pci/emu10k1/emufx.c

    r679 r695  
    942942                        id = &ctl->kcontrol->id;
    943943                        gctl->id.iface = (__force int)id->iface;
    944                         strlcpy(gctl->id.name, id->name, sizeof(gctl->id.name));
     944                        strscpy(gctl->id.name, id->name, sizeof(gctl->id.name));
    945945                        gctl->id.index = id->index;
    946946                        gctl->id.device = id->device;
     
    978978        if (err < 0)
    979979                goto __error;
    980         strlcpy(emu->fx8010.name, icode->name, sizeof(emu->fx8010.name));
     980        strscpy(emu->fx8010.name, icode->name, sizeof(emu->fx8010.name));
    981981        /* stop FX processor - this may be dangerous, but it's better to miss
    982982           some samples than generate wrong ones - [jk] */
     
    10171017
    10181018        mutex_lock(&emu->fx8010.lock);
    1019         strlcpy(icode->name, emu->fx8010.name, sizeof(icode->name));
     1019        strscpy(icode->name, emu->fx8010.name, sizeof(icode->name));
    10201020        /* ok, do the main job */
    10211021        err = snd_emu10k1_gpr_peek(emu, icode);
  • GPL/trunk/alsa-kernel/pci/emu10k1/memory.c

    r679 r695  
    376376{
    377377        if (emu->iommu_workaround) {
    378                 size_t npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
     378                size_t npages = DIV_ROUND_UP(size, PAGE_SIZE);
    379379                size_t size_real = npages * PAGE_SIZE;
    380380
  • GPL/trunk/alsa-kernel/pci/ens1370.c

    r679 r695  
    5656#ifdef CHIP1370
    5757MODULE_DESCRIPTION("Ensoniq AudioPCI ES1370");
    58 MODULE_SUPPORTED_DEVICE("{{Ensoniq,AudioPCI-97 ES1370},"
    59                 "{Creative Labs,SB PCI64/128 (ES1370)}}");
    6058#endif
    6159#ifdef CHIP1371
    6260MODULE_DESCRIPTION("Ensoniq/Creative AudioPCI ES1371+");
    63 MODULE_SUPPORTED_DEVICE("{{Ensoniq,AudioPCI ES1371/73},"
    64                 "{Ensoniq,AudioPCI ES1373},"
    65                 "{Creative Labs,Ectiva EV1938},"
    66                 "{Creative Labs,SB PCI64/128 (ES1371/73)},"
    67                 "{Creative Labs,Vibra PCI128},"
    68                 "{Ectiva,EV1938}}");
    6961#endif
    7062
     
    756748
    757749        mutex_lock(&ensoniq->src_mutex);
    758         freq = ((rate << 15) + 1500) / 3000;
     750        freq = DIV_ROUND_CLOSEST(rate << 15, 3000);
    759751        r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE |
    760752                                                   ES_1371_DIS_P2 | ES_1371_DIS_R1)) |
     
    777769
    778770        mutex_lock(&ensoniq->src_mutex);
    779         freq = ((rate << 15) + 1500) / 3000;
     771        freq = DIV_ROUND_CLOSEST(rate << 15, 3000);
    780772        r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE |
    781773                                                   ES_1371_DIS_P1 | ES_1371_DIS_R1)) |
  • GPL/trunk/alsa-kernel/pci/es1938.c

    r679 r695  
    5656MODULE_DESCRIPTION("ESS Solo-1");
    5757MODULE_LICENSE("GPL");
    58 MODULE_SUPPORTED_DEVICE("{{ESS,ES1938},"
    59                 "{ESS,ES1946},"
    60                 "{ESS,ES1969},"
    61                 "{TerraTec,128i PCI}}");
    6258
    6359#if IS_REACHABLE(CONFIG_GAMEPORT)
     
    15961592                return err;
    15971593        /* check, if we can restrict PCI DMA transfers to 24 bits */
    1598         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
    1599             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
     1594        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
    16001595                dev_err(card->dev,
    16011596                        "architecture does not support 24bit PCI busmaster DMA\n");
  • GPL/trunk/alsa-kernel/pci/es1968.c

    r679 r695  
    111111MODULE_DESCRIPTION("ESS Maestro");
    112112MODULE_LICENSE("GPL");
    113 MODULE_SUPPORTED_DEVICE("{{ESS,Maestro 2e},"
    114                 "{ESS,Maestro 2},"
    115                 "{ESS,Maestro 1},"
    116                 "{TerraTec,DMX}}");
    117113
    118114#if IS_REACHABLE(CONFIG_GAMEPORT)
     
    27052701                return err;
    27062702        /* check, if we can restrict PCI DMA transfers to 28 bits */
    2707         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
    2708             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
     2703        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
    27092704                dev_err(card->dev,
    27102705                        "architecture does not support 28bit PCI busmaster DMA\n");
     
    28052800                        dev_info(card->dev, "detected TEA575x radio type %s\n",
    28062801                                   get_tea575x_gpio(chip)->name);
    2807                         strlcpy(chip->tea.card, get_tea575x_gpio(chip)->name,
     2802                        strscpy(chip->tea.card, get_tea575x_gpio(chip)->name,
    28082803                                sizeof(chip->tea.card));
    28092804                        break;
  • GPL/trunk/alsa-kernel/pci/fm801.c

    r679 r695  
    3131MODULE_DESCRIPTION("ForteMedia FM801");
    3232MODULE_LICENSE("GPL");
    33 MODULE_SUPPORTED_DEVICE("{{ForteMedia,FM801},"
    34                 "{Genius,SoundMaker Live 5.1}}");
    3533
    3634static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
     
    13241322        }
    13251323        if (!(chip->tea575x_tuner & TUNER_DISABLED)) {
    1326                 strlcpy(chip->tea.card, get_tea575x_gpio(chip)->name,
     1324                strscpy(chip->tea.card, get_tea575x_gpio(chip)->name,
    13271325                        sizeof(chip->tea.card));
    13281326        }
  • GPL/trunk/alsa-kernel/pci/hda/hda_auto_parser.c

    r679 r695  
    769769        if (!name)
    770770                return 0;
    771         strlcpy(label, name, maxlen);
     771        strscpy(label, name, maxlen);
    772772        return 1;
    773773}
  • GPL/trunk/alsa-kernel/pci/hda/hda_auto_parser.h

    r679 r695  
    2828
    2929#define AUTO_CFG_MAX_OUTS       HDA_MAX_OUTS
    30 #define AUTO_CFG_MAX_INS        8
     30#define AUTO_CFG_MAX_INS        18
    3131
    3232struct auto_pin_cfg_item {
  • GPL/trunk/alsa-kernel/pci/hda/hda_codec.c

    r689 r695  
    19501950 * @suffix: suffix string to each follower name (optional)
    19511951 * @init_follower_vol: initialize followers to unmute/0dB
     1952 * @access: kcontrol access rights
    19521953 * @ctl_ret: store the vmaster kcontrol in return
    19531954 *
     
    19641965                          unsigned int *tlv, const char * const *followers,
    19651966                          const char *suffix, bool init_follower_vol,
    1966                           struct snd_kcontrol **ctl_ret)
     1967                          unsigned int access, struct snd_kcontrol **ctl_ret)
    19671968{
    19681969        struct snd_kcontrol *kctl;
     
    19801981        if (!kctl)
    19811982                return -ENOMEM;
     1983        kctl->vd[0].access |= access;
    19821984        err = snd_hda_ctl_add(codec, 0, kctl);
    19831985        if (err < 0)
     
    20112013EXPORT_SYMBOL_GPL(__snd_hda_add_vmaster);
    20122014
    2013 /*
    2014  * mute-LED control using vmaster
    2015  */
    2016 static int vmaster_mute_mode_info(struct snd_kcontrol *kcontrol,
    2017                                   struct snd_ctl_elem_info *uinfo)
    2018 {
    2019         static const char * const texts[] = {
    2020                 "On", "Off", "Follow Master"
    2021         };
    2022 
    2023         return snd_ctl_enum_info(uinfo, 1, 3, texts);
    2024 }
    2025 
    2026 static int vmaster_mute_mode_get(struct snd_kcontrol *kcontrol,
    2027                                  struct snd_ctl_elem_value *ucontrol)
    2028 {
    2029         struct hda_vmaster_mute_hook *hook = snd_kcontrol_chip(kcontrol);
    2030         ucontrol->value.enumerated.item[0] = hook->mute_mode;
    2031         return 0;
    2032 }
    2033 
    2034 static int vmaster_mute_mode_put(struct snd_kcontrol *kcontrol,
    2035                                  struct snd_ctl_elem_value *ucontrol)
    2036 {
    2037         struct hda_vmaster_mute_hook *hook = snd_kcontrol_chip(kcontrol);
    2038         unsigned int old_mode = hook->mute_mode;
    2039 
    2040         hook->mute_mode = ucontrol->value.enumerated.item[0];
    2041         if (hook->mute_mode > HDA_VMUTE_FOLLOW_MASTER)
    2042                 hook->mute_mode = HDA_VMUTE_FOLLOW_MASTER;
    2043         if (old_mode == hook->mute_mode)
    2044                 return 0;
    2045         snd_hda_sync_vmaster_hook(hook);
    2046         return 1;
    2047 }
    2048 
    2049 static const struct snd_kcontrol_new vmaster_mute_mode = {
    2050         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    2051         .name = "Mute-LED Mode",
    2052         .info = vmaster_mute_mode_info,
    2053         .get = vmaster_mute_mode_get,
    2054         .put = vmaster_mute_mode_put,
    2055 };
    2056 
    20572015/* meta hook to call each driver's vmaster hook */
    20582016static void vmaster_hook(void *private_data, int enabled)
     
    20602018        struct hda_vmaster_mute_hook *hook = private_data;
    20612019
    2062         if (hook->mute_mode != HDA_VMUTE_FOLLOW_MASTER)
    2063                 enabled = hook->mute_mode;
    20642020        hook->hook(hook->codec, enabled);
    20652021}
    20662022
    20672023/**
    2068  * snd_hda_add_vmaster_hook - Add a vmaster hook for mute-LED
     2024 * snd_hda_add_vmaster_hook - Add a vmaster hw specific hook
    20692025 * @codec: the HDA codec
    20702026 * @hook: the vmaster hook object
    2071  * @expose_enum_ctl: flag to create an enum ctl
    2072  *
    2073  * Add a mute-LED hook with the given vmaster switch kctl.
    2074  * When @expose_enum_ctl is set, "Mute-LED Mode" control is automatically
    2075  * created and associated with the given hook.
     2027 *
     2028 * Add a hw specific hook (like EAPD) with the given vmaster switch kctl.
    20762029 */
    20772030int snd_hda_add_vmaster_hook(struct hda_codec *codec,
    2078                              struct hda_vmaster_mute_hook *hook,
    2079                              bool expose_enum_ctl)
    2080 {
    2081         struct snd_kcontrol *kctl;
    2082 
     2031                             struct hda_vmaster_mute_hook *hook)
     2032{
    20832033        if (!hook->hook || !hook->sw_kctl)
    20842034                return 0;
    20852035        hook->codec = codec;
    2086         hook->mute_mode = HDA_VMUTE_FOLLOW_MASTER;
    20872036        snd_ctl_add_vmaster_hook(hook->sw_kctl, vmaster_hook, hook);
    2088         if (!expose_enum_ctl)
    2089                 return 0;
    2090         kctl = snd_ctl_new1(&vmaster_mute_mode, hook);
    2091         if (!kctl)
    2092                 return -ENOMEM;
    2093         return snd_hda_ctl_add(codec, 0, kctl);
     2037        return 0;
    20942038}
    20952039EXPORT_SYMBOL_GPL(snd_hda_add_vmaster_hook);
     
    30022946                dev->power.power_state = PMSG_RESUME;
    30032947#endif
     2948
    30042949        if (pm_runtime_suspended(dev) && (codec->jackpoll_interval ||
    30052950            hda_codec_need_resume(codec) || codec->forced_resume))
     
    35053450
    35063451/**
    3507  * snd_hda_input_mux_info_info - Info callback helper for the input-mux enum
     3452 * snd_hda_input_mux_info - Info callback helper for the input-mux enum
    35083453 * @imux: imux helper object
    35093454 * @uinfo: pointer to get/store the data
     
    35283473
    35293474/**
    3530  * snd_hda_input_mux_info_put - Put callback helper for the input-mux enum
     3475 * snd_hda_input_mux_put - Put callback helper for the input-mux enum
    35313476 * @codec: the HDA codec
    35323477 * @imux: imux helper object
     
    39633908
    39643909/**
    3965  * _snd_hda_pin_ctl - Helper to set pin ctl value
     3910 * _snd_hda_set_pin_ctl - Helper to set pin ctl value
    39663911 * @codec: the HDA codec
    39673912 * @pin: referred pin NID
     
    40213966                         "%s %d", label, label_idx);
    40223967        else
    4023                 strlcpy(imux->items[imux->num_items].label, label,
     3968                strscpy(imux->items[imux->num_items].label, label,
    40243969                        sizeof(imux->items[imux->num_items].label));
    40253970        imux->items[imux->num_items].index = index;
  • GPL/trunk/alsa-kernel/pci/hda/hda_controller.c

    r689 r695  
    753753        if (err < 0)
    754754                return err;
    755         strlcpy(pcm->name, cpcm->name, sizeof(pcm->name));
     755        strscpy(pcm->name, cpcm->name, sizeof(pcm->name));
    756756        apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
    757757        if (apcm == NULL) {
  • GPL/trunk/alsa-kernel/pci/hda/hda_eld.c

    r679 r695  
    261261                goto out_fail;
    262262        } else
    263                 strlcpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl + 1);
     263                strscpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl + 1);
    264264
    265265        for (i = 0; i < e->sad_count; i++) {
  • GPL/trunk/alsa-kernel/pci/hda/hda_generic.c

    r689 r695  
    985985        if (get_amp_nid_(val))
    986986                knew->subdevice = HDA_SUBDEV_AMP_FLAG;
     987        if (knew->access == 0)
     988                knew->access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
    987989        knew->private_value = val;
    988990        return knew;
     
    35303532        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    35313533        .name = "Capture Switch",
     3534        .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
    35323535        .info = cap_sw_info,
    35333536        .get = cap_sw_get,
     
    36363639        if (!knew)
    36373640                return -ENOMEM;
    3638         if (is_switch)
     3641        if (is_switch) {
    36393642                knew->put = cap_single_sw_put;
     3643                if (spec->mic_mute_led)
     3644                        knew->access |= SNDRV_CTL_ELEM_ACCESS_MIC_LED;
     3645        }
    36403646        if (!inv_dmic)
    36413647                return 0;
     
    36523658        if (!knew)
    36533659                return -ENOMEM;
    3654         if (is_switch)
     3660        if (is_switch) {
    36553661                knew->put = cap_single_sw_put;
     3662                if (spec->mic_mute_led)
     3663                        knew->access |= SNDRV_CTL_ELEM_ACCESS_MIC_LED;
     3664        }
    36563665        return 0;
    36573666}
     
    36943703                knew->private_value = sw_ctl;
    36953704                knew->subdevice = HDA_SUBDEV_AMP_FLAG;
     3705                if (spec->mic_mute_led)
     3706                        knew->access |= SNDRV_CTL_ELEM_ACCESS_MIC_LED;
    36963707        }
    36973708        return 0;
     
    39353946}
    39363947
    3937 static void vmaster_update_mute_led(void *private_data, int enabled)
    3938 {
    3939         ledtrig_audio_set(LED_AUDIO_MUTE, enabled ? LED_OFF : LED_ON);
    3940 }
    3941 
    39423948/**
    3943  * snd_dha_gen_add_mute_led_cdev - Create a LED classdev and enable as vmaster mute LED
     3949 * snd_hda_gen_add_mute_led_cdev - Create a LED classdev and enable as vmaster mute LED
    39443950 * @codec: the HDA codec
    39453951 * @callback: the callback for LED classdev brightness_set_blocking
     
    39633969                codec_err(codec, "vmaster hook already present before cdev!\n");
    39643970
    3965         spec->vmaster_mute.hook = vmaster_update_mute_led;
    3966         spec->vmaster_mute_enum = 1;
     3971        spec->vmaster_mute_led = 1;
    39673972        return 0;
    39683973}
    39693974EXPORT_SYMBOL_GPL(snd_hda_gen_add_mute_led_cdev);
    39703975
    3971 /*
    3972  * mic mute LED hook helpers
    3973  */
    3974 enum {
    3975         MICMUTE_LED_ON,
    3976         MICMUTE_LED_OFF,
    3977         MICMUTE_LED_FOLLOW_CAPTURE,
    3978         MICMUTE_LED_FOLLOW_MUTE,
    3979 };
    3980 
    3981 static void call_micmute_led_update(struct hda_codec *codec)
    3982 {
    3983         struct hda_gen_spec *spec = codec->spec;
    3984         unsigned int val;
    3985 
    3986         switch (spec->micmute_led.led_mode) {
    3987         case MICMUTE_LED_ON:
    3988                 val = 1;
    3989                 break;
    3990         case MICMUTE_LED_OFF:
    3991                 val = 0;
    3992                 break;
    3993         case MICMUTE_LED_FOLLOW_CAPTURE:
    3994                 val = !!spec->micmute_led.capture;
    3995                 break;
    3996         case MICMUTE_LED_FOLLOW_MUTE:
    3997         default:
    3998                 val = !spec->micmute_led.capture;
    3999                 break;
    4000         }
    4001 
    4002         if (val == spec->micmute_led.led_value)
    4003                 return;
    4004         spec->micmute_led.led_value = val;
    4005         ledtrig_audio_set(LED_AUDIO_MICMUTE,
    4006                           spec->micmute_led.led_value ? LED_ON : LED_OFF);
    4007 }
    4008 
    4009 static void update_micmute_led(struct hda_codec *codec,
    4010                                struct snd_kcontrol *kcontrol,
    4011                                struct snd_ctl_elem_value *ucontrol)
    4012 {
    4013         struct hda_gen_spec *spec = codec->spec;
    4014         unsigned int mask;
    4015 
    4016         if (spec->micmute_led.old_hook)
    4017                 spec->micmute_led.old_hook(codec, kcontrol, ucontrol);
    4018 
    4019         if (!ucontrol)
    4020                 return;
    4021         mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
    4022         if (!strcmp("Capture Switch", ucontrol->id.name)) {
    4023                 /* TODO: How do I verify if it's a mono or stereo here? */
    4024                 if (ucontrol->value.integer.value[0] ||
    4025                     ucontrol->value.integer.value[1])
    4026                         spec->micmute_led.capture |= mask;
    4027                 else
    4028                         spec->micmute_led.capture &= ~mask;
    4029                 call_micmute_led_update(codec);
    4030         }
    4031 }
    4032 
    4033 static int micmute_led_mode_info(struct snd_kcontrol *kcontrol,
    4034                                  struct snd_ctl_elem_info *uinfo)
    4035 {
    4036         static const char * const texts[] = {
    4037                 "On", "Off", "Follow Capture", "Follow Mute",
    4038         };
    4039 
    4040         return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts);
    4041 }
    4042 
    4043 static int micmute_led_mode_get(struct snd_kcontrol *kcontrol,
    4044                                 struct snd_ctl_elem_value *ucontrol)
    4045 {
    4046         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    4047         struct hda_gen_spec *spec = codec->spec;
    4048 
    4049         ucontrol->value.enumerated.item[0] = spec->micmute_led.led_mode;
    4050         return 0;
    4051 }
    4052 
    4053 static int micmute_led_mode_put(struct snd_kcontrol *kcontrol,
    4054                                 struct snd_ctl_elem_value *ucontrol)
    4055 {
    4056         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
    4057         struct hda_gen_spec *spec = codec->spec;
    4058         unsigned int mode;
    4059 
    4060         mode = ucontrol->value.enumerated.item[0];
    4061         if (mode > MICMUTE_LED_FOLLOW_MUTE)
    4062                 mode = MICMUTE_LED_FOLLOW_MUTE;
    4063         if (mode == spec->micmute_led.led_mode)
    4064                 return 0;
    4065         spec->micmute_led.led_mode = mode;
    4066         call_micmute_led_update(codec);
    4067         return 1;
    4068 }
    4069 
    4070 static const struct snd_kcontrol_new micmute_led_mode_ctl = {
    4071         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    4072         .name = "Mic Mute-LED Mode",
    4073         .info = micmute_led_mode_info,
    4074         .get = micmute_led_mode_get,
    4075         .put = micmute_led_mode_put,
    4076 };
    4077 
    4078 /* Set up the capture sync hook for controlling the mic-mute LED */
    4079 static int add_micmute_led_hook(struct hda_codec *codec)
    4080 {
    4081         struct hda_gen_spec *spec = codec->spec;
    4082 
    4083         spec->micmute_led.led_mode = MICMUTE_LED_FOLLOW_MUTE;
    4084         spec->micmute_led.capture = 0;
    4085         spec->micmute_led.led_value = -1;
    4086         spec->micmute_led.old_hook = spec->cap_sync_hook;
    4087         spec->cap_sync_hook = update_micmute_led;
    4088         if (!snd_hda_gen_add_kctl(spec, NULL, &micmute_led_mode_ctl))
    4089                 return -ENOMEM;
    4090         return 0;
    4091 }
    4092 
    40933976/**
    4094  * snd_dha_gen_add_micmute_led_cdev - Create a LED classdev and enable as mic-mute LED
     3977 * snd_hda_gen_add_micmute_led_cdev - Create a LED classdev and enable as mic-mute LED
    40953978 * @codec: the HDA codec
    40963979 * @callback: the callback for LED classdev brightness_set_blocking
     
    41093992                                                     enum led_brightness))
    41103993{
     3994        struct hda_gen_spec *spec = codec->spec;
    41113995        int err;
    41123996
     
    41194003        }
    41204004
    4121         return add_micmute_led_hook(codec);
     4005        spec->mic_mute_led = 1;
     4006        return 0;
    41224007}
    41234008EXPORT_SYMBOL_GPL(snd_hda_gen_add_micmute_led_cdev);
     
    50784963        parse_user_hints(codec);
    50794964
     4965        if (spec->vmaster_mute_led || spec->mic_mute_led)
     4966                snd_ctl_led_request();
     4967
    50804968        if (spec->mixer_nid && !spec->mixer_merge_nid)
    50814969                spec->mixer_merge_nid = spec->mixer_nid;
     
    53095197                err = snd_hda_add_vmaster(codec, "Master Playback Volume",
    53105198                                          spec->vmaster_tlv, follower_pfxs,
    5311                                           "Playback Volume");
     5199                                          "Playback Volume", 0);
    53125200                if (err < 0)
    53135201                        return err;
     
    53175205                err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
    53185206                                            NULL, follower_pfxs,
    5319                                             "Playback Switch",
    5320                                             true, &spec->vmaster_mute.sw_kctl);
     5207                                            "Playback Switch", true,
     5208                                            spec->vmaster_mute_led ?
     5209                                                SNDRV_CTL_ELEM_ACCESS_SPK_LED : 0,
     5210                                            &spec->vmaster_mute.sw_kctl);
    53215211                if (err < 0)
    53225212                        return err;
    53235213                if (spec->vmaster_mute.hook) {
    5324                         snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute,
    5325                                                  spec->vmaster_mute_enum);
     5214                        snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute);
    53265215                        snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
    53275216                }
     
    57395628        if (*str)
    57405629                return;
    5741         strlcpy(str, chip_name, len);
     5630        strscpy(str, chip_name, len);
    57425631
    57435632        /* drop non-alnum chars after a space */
  • GPL/trunk/alsa-kernel/pci/hda/hda_generic.h

    r679 r695  
    8484extern const struct badness_table hda_main_out_badness;
    8585extern const struct badness_table hda_extra_out_badness;
    86 
    87 struct hda_micmute_hook {
    88         unsigned int led_mode;
    89         unsigned int capture;
    90         unsigned int led_value;
    91         void (*old_hook)(struct hda_codec *codec,
    92                          struct snd_kcontrol *kcontrol,
    93                          struct snd_ctl_elem_value *ucontrol);
    94 };
    9586
    9687struct hda_gen_spec {
     
    230221        unsigned int own_eapd_ctl:1; /* set EAPD by own function */
    231222        unsigned int keep_eapd_on:1; /* don't turn off EAPD automatically */
    232         unsigned int vmaster_mute_enum:1; /* add vmaster mute mode enum */
     223        unsigned int vmaster_mute_led:1; /* add SPK-LED flag to vmaster mute switch */
     224        unsigned int mic_mute_led:1; /* add MIC-LED flag to capture mute switch */
    233225        unsigned int indep_hp:1; /* independent HP supported */
    234226        unsigned int prefer_hp_amp:1; /* enable HP amp for speaker if any */
     
    285277                              struct snd_kcontrol *kcontrol,
    286278                              struct snd_ctl_elem_value *ucontrol);
    287 
    288         /* mic mute LED hook; called via cap_sync_hook */
    289         struct hda_micmute_hook micmute_led;
    290279
    291280        /* PCM hooks */
  • GPL/trunk/alsa-kernel/pci/hda/hda_intel.c

    r689 r695  
    227227
    228228MODULE_LICENSE("GPL");
    229 MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
    230                          "{Intel, ICH6M},"
    231                          "{Intel, ICH7},"
    232                          "{Intel, ESB2},"
    233                          "{Intel, ICH8},"
    234                          "{Intel, ICH9},"
    235                          "{Intel, ICH10},"
    236                          "{Intel, PCH},"
    237                          "{Intel, CPT},"
    238                          "{Intel, PPT},"
    239                          "{Intel, LPT},"
    240                          "{Intel, LPT_LP},"
    241                          "{Intel, WPT_LP},"
    242                          "{Intel, SPT},"
    243                          "{Intel, SPT_LP},"
    244                          "{Intel, HPT},"
    245                          "{Intel, PBG},"
    246                          "{Intel, SCH},"
    247                          "{ATI, SB450},"
    248                          "{ATI, SB600},"
    249                          "{ATI, RS600},"
    250                          "{ATI, RS690},"
    251                          "{ATI, RS780},"
    252                          "{ATI, R600},"
    253                          "{ATI, RV630},"
    254                          "{ATI, RV610},"
    255                          "{ATI, RV670},"
    256                          "{ATI, RV635},"
    257                          "{ATI, RV620},"
    258                          "{ATI, RV770},"
    259                          "{VIA, VT8251},"
    260                          "{VIA, VT8237A},"
    261                          "{SiS, SIS966},"
    262                          "{ULI, M5461}}");
    263229MODULE_DESCRIPTION("Intel HDA driver");
    264230
     
    14921458                if (dhandle) {
    14931459                        status = acpi_get_handle(dhandle, "ATPX", &atpx_handle);
    1494                         if (!ACPI_FAILURE(status)) {
     1460                        if (ACPI_SUCCESS(status)) {
    14951461                                pci_dev_put(pdev);
    14961462                                return true;
     
    15021468                if (dhandle) {
    15031469                        status = acpi_get_handle(dhandle, "ATPX", &atpx_handle);
    1504                         if (!ACPI_FAILURE(status)) {
     1470                        if (ACPI_SUCCESS(status)) {
    15051471                                pci_dev_put(pdev);
    15061472                                return true;
     
    20191985        if (!(gcap & AZX_GCAP_64OK))
    20201986                dma_bits = 32;
    2021         if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
    2022                 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
    2023         } else {
    2024                 dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
    2025                 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
    2026         }
     1987        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
     1988                dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
    20271989
    20281990        /* read number of streams from GCAP register instead of using
     
    20892051
    20902052        strcpy(card->driver, "HDA-Intel");
    2091         strlcpy(card->shortname, driver_short_names[chip->driver_type],
     2053        strscpy(card->shortname, driver_short_names[chip->driver_type],
    20922054                sizeof(card->shortname));
    20932055        snprintf(card->longname, sizeof(card->longname),
     
    22802242        /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */
    22812243        SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0),
    2282         /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */
    2283         SND_PCI_QUIRK(0x1558, 0x6504, "Clevo W65_67SB", 0),
    22842244        /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */
    22852245        SND_PCI_QUIRK(0x1028, 0x0497, "Dell Precision T3600", 0),
     
    23642324                /* HSW/BDW controllers need this power */
    23652325                if (CONTROLLER_IN_GPU(pci))
    2366                         hda->need_i915_power = 1;
     2326                        hda->need_i915_power = true;
    23672327        }
    23682328
     
    25752535        { PCI_DEVICE(0x8086, 0x51c8),
    25762536          .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
     2537        /* Alderlake-M */
     2538        { PCI_DEVICE(0x8086, 0x51cc),
     2539          .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
    25772540        /* Elkhart Lake */
    25782541        { PCI_DEVICE(0x8086, 0x4b55),
     
    26662629        /* ATI HDMI */
    26672630        { PCI_DEVICE(0x1002, 0x0002),
    2668           .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
     2631          .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
     2632          AZX_DCAPS_PM_RUNTIME },
    26692633        { PCI_DEVICE(0x1002, 0x1308),
    26702634          .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
     
    27282692          .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
    27292693        { PCI_DEVICE(0x1002, 0xaac0),
    2730           .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
     2694          .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
     2695          AZX_DCAPS_PM_RUNTIME },
    27312696        { PCI_DEVICE(0x1002, 0xaac8),
    2732           .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
     2697          .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
     2698          AZX_DCAPS_PM_RUNTIME },
    27332699        { PCI_DEVICE(0x1002, 0xaad8),
    27342700          .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
  • GPL/trunk/alsa-kernel/pci/hda/hda_jack.c

    r679 r695  
    214214
    215215/**
    216  * snd_hda_set_dirty_all - Mark all the cached as dirty
     216 * snd_hda_jack_set_dirty_all - Mark all the cached as dirty
    217217 * @codec: the HDA codec
    218218 *
     
    294294
    295295/**
    296  * snd_hda_jack_detect_enable_mst - enable the jack-detection
     296 * snd_hda_jack_detect_enable_callback_mst - enable the jack-detection
    297297 * @codec: the HDA codec
    298298 * @nid: pin NID to enable
     
    388388}
    389389EXPORT_SYMBOL_GPL(snd_hda_jack_set_gating_jack);
     390
     391/**
     392 * snd_hda_jack_bind_keymap - bind keys generated from one NID to another jack.
     393 * @codec: the HDA codec
     394 * @key_nid: key event is generated by this pin NID
     395 * @keymap: map of key type and key code
     396 * @jack_nid: key reports to the jack of this pin NID
     397 *
     398 * This function is used in the case of key is generated from one NID while is
     399 * reported to the jack of another NID.
     400 */
     401int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid,
     402                             const struct hda_jack_keymap *keymap,
     403                             hda_nid_t jack_nid)
     404{
     405        const struct hda_jack_keymap *map;
     406        struct hda_jack_tbl *key_gen = snd_hda_jack_tbl_get(codec, key_nid);
     407        struct hda_jack_tbl *report_to = snd_hda_jack_tbl_get(codec, jack_nid);
     408
     409        WARN_ON(codec->dp_mst);
     410
     411        if (!key_gen || !report_to || !report_to->jack)
     412                return -EINVAL;
     413
     414        key_gen->key_report_jack = jack_nid;
     415
     416        if (keymap)
     417                for (map = keymap; map->type; map++)
     418                        snd_jack_set_key(report_to->jack, map->type, map->key);
     419
     420        return 0;
     421}
     422EXPORT_SYMBOL_GPL(snd_hda_jack_bind_keymap);
     423
     424/**
     425 * snd_hda_jack_set_button_state - report button event to the hda_jack_tbl button_state.
     426 * @codec: the HDA codec
     427 * @jack_nid: the button event reports to the jack_tbl of this NID
     428 * @button_state: the button event captured by codec
     429 *
     430 * Codec driver calls this function to report the button event.
     431 */
     432void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid,
     433                                   int button_state)
     434{
     435        struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, jack_nid);
     436
     437        if (!jack)
     438                return;
     439
     440        if (jack->key_report_jack) {
     441                struct hda_jack_tbl *report_to =
     442                        snd_hda_jack_tbl_get(codec, jack->key_report_jack);
     443
     444                if (report_to) {
     445                        report_to->button_state = button_state;
     446                        return;
     447                }
     448        }
     449
     450        jack->button_state = button_state;
     451}
     452EXPORT_SYMBOL_GPL(snd_hda_jack_set_button_state);
    390453
    391454/**
     
    531594
    532595        if (base_name)
    533                 strlcpy(name, base_name, sizeof(name));
     596                strscpy(name, base_name, sizeof(name));
    534597        else
    535598                snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), NULL);
     
    652715        if (!event)
    653716                return;
    654         event->jack_dirty = 1;
     717
     718        if (event->key_report_jack) {
     719                struct hda_jack_tbl *report_to =
     720                        snd_hda_jack_tbl_get_mst(codec, event->key_report_jack,
     721                                                 event->dev_id);
     722                if (report_to)
     723                        report_to->jack_dirty = 1;
     724        } else
     725                event->jack_dirty = 1;
    655726
    656727        call_jack_callback(codec, res, event);
  • GPL/trunk/alsa-kernel/pci/hda/hda_jack.h

    r679 r695  
    4141        hda_nid_t gating_jack;          /* valid when gating jack plugged */
    4242        hda_nid_t gated_jack;           /* gated is dependent on this jack */
     43        hda_nid_t key_report_jack;      /* key reports to this jack */
    4344        int type;
    4445        int button_state;
     
    99100int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid,
    100101                                 hda_nid_t gating_nid);
     102
     103int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid,
     104                             const struct hda_jack_keymap *keymap,
     105                             hda_nid_t jack_nid);
     106
     107void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid,
     108                                   int button_state);
    101109
    102110u32 snd_hda_jack_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id);
  • GPL/trunk/alsa-kernel/pci/hda/hda_local.h

    r679 r695  
    132132                          unsigned int *tlv, const char * const *followers,
    133133                          const char *suffix, bool init_follower_vol,
    134                           struct snd_kcontrol **ctl_ret);
    135 #define snd_hda_add_vmaster(codec, name, tlv, followers, suffix) \
    136         __snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, NULL)
     134                          unsigned int access, struct snd_kcontrol **ctl_ret);
     135#define snd_hda_add_vmaster(codec, name, tlv, followers, suffix, access) \
     136        __snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, access, NULL)
    137137int snd_hda_codec_reset(struct hda_codec *codec);
    138138void snd_hda_codec_register(struct hda_codec *codec);
     
    140140
    141141#define snd_hda_regmap_sync(codec)      snd_hdac_regmap_sync(&(codec)->core)
    142 
    143 enum {
    144         HDA_VMUTE_OFF,
    145         HDA_VMUTE_ON,
    146         HDA_VMUTE_FOLLOW_MASTER,
    147 };
    148142
    149143struct hda_vmaster_mute_hook {
     
    154148        void (*hook)(void *, int);
    155149        /* below are initialized automatically */
    156         unsigned int mute_mode; /* HDA_VMUTE_XXX */
    157150        struct hda_codec *codec;
    158151};
    159152
    160153int snd_hda_add_vmaster_hook(struct hda_codec *codec,
    161                              struct hda_vmaster_mute_hook *hook,
    162                              bool expose_enum_ctl);
     154                             struct hda_vmaster_mute_hook *hook);
    163155void snd_hda_sync_vmaster_hook(struct hda_vmaster_mute_hook *hook);
    164156
     
    181173 * input MUX helper
    182174 */
    183 #define HDA_MAX_NUM_INPUTS      16
     175#define HDA_MAX_NUM_INPUTS      36
    184176struct hda_input_mux_item {
    185177        char label[32];
  • GPL/trunk/alsa-kernel/pci/hda/hda_proc.c

    r679 r695  
    683683}
    684684
     685static void print_dpmst_connections(struct snd_info_buffer *buffer, struct hda_codec *codec,
     686                                    hda_nid_t nid, int dev_num)
     687{
     688        int c, conn_len, curr, dev_id_saved;
     689        hda_nid_t *conn;
     690
     691        conn_len = snd_hda_get_num_raw_conns(codec, nid);
     692        if (conn_len <= 0)
     693                return;
     694
     695        conn = kmalloc_array(conn_len, sizeof(hda_nid_t), GFP_KERNEL);
     696        if (!conn)
     697                return;
     698
     699        dev_id_saved = snd_hda_get_dev_select(codec, nid);
     700
     701        snd_hda_set_dev_select(codec, nid, dev_num);
     702        curr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
     703        if (snd_hda_get_raw_connections(codec, nid, conn, conn_len) < 0)
     704                goto out;
     705
     706        for (c = 0; c < conn_len; c++) {
     707                snd_iprintf(buffer, " 0x%02x", conn[c]);
     708                if (c == curr)
     709                        snd_iprintf(buffer, "*");
     710        }
     711
     712out:
     713        kfree(conn);
     714        snd_hda_set_dev_select(codec, nid, dev_id_saved);
     715}
     716
    685717static void print_device_list(struct snd_info_buffer *buffer,
    686718                            struct hda_codec *codec, hda_nid_t nid)
     
    706738
    707739                snd_iprintf(buffer,
    708                         "Dev %02d: PD = %d, ELDV = %d, IA = %d\n", i,
     740                        "Dev %02d: PD = %d, ELDV = %d, IA = %d, Connections [", i,
    709741                        !!(dev_list[i] & AC_DE_PD),
    710742                        !!(dev_list[i] & AC_DE_ELDV),
    711743                        !!(dev_list[i] & AC_DE_IA));
     744
     745                print_dpmst_connections(buffer, codec, nid, i);
     746
     747                snd_iprintf(buffer, " ]\n");
    712748        }
    713749}
  • GPL/trunk/alsa-kernel/pci/hda/hda_tegra.c

    r679 r695  
    1818#include <linux/mutex.h>
    1919#include <linux/of_device.h>
     20#include <linux/reset.h>
    2021#include <linux/slab.h>
    2122#include <linux/time.h>
     
    7172        struct azx chip;
    7273        struct device *dev;
    73         struct clk *hda_clk;
    74         struct clk *hda2codec_2x_clk;
    75         struct clk *hda2hdmi_clk;
     74        struct reset_control *reset;
     75        struct clk_bulk_data clocks[3];
     76        unsigned int nclocks;
    7677        void __iomem *regs;
    7778        struct work_struct probe_work;
     
    114115}
    115116
    116 static int hda_tegra_enable_clocks(struct hda_tegra *data)
    117 {
    118         int rc;
    119 
    120         rc = clk_prepare_enable(data->hda_clk);
    121         if (rc)
    122                 return rc;
    123         rc = clk_prepare_enable(data->hda2codec_2x_clk);
    124         if (rc)
    125                 goto disable_hda;
    126         rc = clk_prepare_enable(data->hda2hdmi_clk);
    127         if (rc)
    128                 goto disable_codec_2x;
    129 
    130         return 0;
    131 
    132 disable_codec_2x:
    133         clk_disable_unprepare(data->hda2codec_2x_clk);
    134 disable_hda:
    135         clk_disable_unprepare(data->hda_clk);
    136         return rc;
    137 }
    138 
    139 static void hda_tegra_disable_clocks(struct hda_tegra *data)
    140 {
    141         clk_disable_unprepare(data->hda2hdmi_clk);
    142         clk_disable_unprepare(data->hda2codec_2x_clk);
    143         clk_disable_unprepare(data->hda_clk);
    144 }
    145 
    146117/*
    147118 * power management
     
    187158                azx_enter_link_reset(chip);
    188159        }
    189         hda_tegra_disable_clocks(hda);
     160        clk_bulk_disable_unprepare(hda->nclocks, hda->clocks);
    190161
    191162        return 0;
     
    199170        int rc;
    200171
    201         rc = hda_tegra_enable_clocks(hda);
     172        if (!chip->running) {
     173                rc = reset_control_assert(hda->reset);
     174                if (rc)
     175                        return rc;
     176        }
     177
     178        rc = clk_bulk_prepare_enable(hda->nclocks, hda->clocks);
    202179        if (rc != 0)
    203180                return rc;
    204         if (chip && chip->running) {
     181        if (chip->running) {
    205182                hda_tegra_init(hda);
    206183                azx_init_chip(chip, 1);
     
    208185                azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
    209186                           ~STATESTS_INT_MASK);
     187        } else {
     188                usleep_range(10, 100);
     189
     190                rc = reset_control_deassert(hda->reset);
     191                if (rc)
     192                        return rc;
    210193        }
    211194
     
    265248
    266249        hda_tegra_init(hda);
    267 
    268         return 0;
    269 }
    270 
    271 static int hda_tegra_init_clk(struct hda_tegra *hda)
    272 {
    273         struct device *dev = hda->dev;
    274 
    275         hda->hda_clk = devm_clk_get(dev, "hda");
    276         if (IS_ERR(hda->hda_clk)) {
    277                 dev_err(dev, "failed to get hda clock\n");
    278                 return PTR_ERR(hda->hda_clk);
    279         }
    280         hda->hda2codec_2x_clk = devm_clk_get(dev, "hda2codec_2x");
    281         if (IS_ERR(hda->hda2codec_2x_clk)) {
    282                 dev_err(dev, "failed to get hda2codec_2x clock\n");
    283                 return PTR_ERR(hda->hda2codec_2x_clk);
    284         }
    285         hda->hda2hdmi_clk = devm_clk_get(dev, "hda2hdmi");
    286         if (IS_ERR(hda->hda2hdmi_clk)) {
    287                 dev_err(dev, "failed to get hda2hdmi clock\n");
    288                 return PTR_ERR(hda->hda2hdmi_clk);
    289         }
    290250
    291251        return 0;
     
    302262        const char *sname, *drv_name = "tegra-hda";
    303263        struct device_node *np = pdev->dev.of_node;
     264
     265        if (irq_id < 0)
     266                return irq_id;
    304267
    305268        err = hda_tegra_init_chip(chip, pdev);
     
    496459        }
    497460
    498         err = hda_tegra_init_clk(hda);
     461        hda->reset = devm_reset_control_array_get_exclusive(&pdev->dev);
     462        if (IS_ERR(hda->reset)) {
     463                err = PTR_ERR(hda->reset);
     464                goto out_free;
     465        }
     466
     467        hda->clocks[hda->nclocks++].id = "hda";
     468        hda->clocks[hda->nclocks++].id = "hda2hdmi";
     469        hda->clocks[hda->nclocks++].id = "hda2codec_2x";
     470
     471        err = devm_clk_bulk_get(&pdev->dev, hda->nclocks, hda->clocks);
    499472        if (err < 0)
    500473                goto out_free;
  • GPL/trunk/alsa-kernel/pci/hda/patch_ca0132.c

    r689 r695  
    791791        { .name = "Fast Roll Off",
    792792          .val = 0x80
     793        }
     794};
     795
     796/*
     797 * Data structures for storing audio router remapping data. These are used to
     798 * remap a currently active streams ports.
     799 */
     800struct chipio_stream_remap_data {
     801        unsigned int stream_id;
     802        unsigned int count;
     803
     804        unsigned int offset[16];
     805        unsigned int value[16];
     806};
     807
     808static const struct chipio_stream_remap_data stream_remap_data[] = {
     809        { .stream_id = 0x14,
     810          .count     = 0x04,
     811          .offset    = { 0x00, 0x04, 0x08, 0x0c },
     812          .value     = { 0x0001f8c0, 0x0001f9c1, 0x0001fac6, 0x0001fbc7 },
     813        },
     814        { .stream_id = 0x0c,
     815          .count     = 0x0c,
     816          .offset    = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
     817                         0x20, 0x24, 0x28, 0x2c },
     818          .value     = { 0x0001e0c0, 0x0001e1c1, 0x0001e4c2, 0x0001e5c3,
     819                         0x0001e2c4, 0x0001e3c5, 0x0001e8c6, 0x0001e9c7,
     820                         0x0001ecc8, 0x0001edc9, 0x0001eaca, 0x0001ebcb },
     821        },
     822        { .stream_id = 0x0c,
     823          .count     = 0x08,
     824          .offset    = { 0x08, 0x0c, 0x10, 0x14, 0x20, 0x24, 0x28, 0x2c },
     825          .value     = { 0x000140c2, 0x000141c3, 0x000150c4, 0x000151c5,
     826                         0x000142c8, 0x000143c9, 0x000152ca, 0x000153cb },
    793827        }
    794828};
     
    18361870}
    18371871
     1872/*
     1873 * Get ChipIO audio stream's status.
     1874 */
     1875static void chipio_get_stream_control(struct hda_codec *codec,
     1876                                int streamid, unsigned int *enable)
     1877{
     1878        chipio_set_control_param_no_mutex(codec,
     1879                        CONTROL_PARAM_STREAM_ID, streamid);
     1880        *enable = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0,
     1881                           VENDOR_CHIPIO_PARAM_GET,
     1882                           CONTROL_PARAM_STREAM_CONTROL);
     1883}
    18381884
    18391885/*
     
    18751921
    18761922/*
     1923 * Writes to the 8051's exram, which has 16-bits of address space.
     1924 * Data at addresses 0x2000-0x7fff is mirrored to 0x8000-0xdfff.
     1925 * Data at 0x8000-0xdfff can also be used as program memory for the 8051 by
     1926 * setting the pmem bank selection SFR.
     1927 * 0xe000-0xffff is always mapped as program memory, with only 0xf000-0xffff
     1928 * being writable.
     1929 */
     1930static void chipio_8051_set_address(struct hda_codec *codec, unsigned int addr)
     1931{
     1932        unsigned int tmp;
     1933
     1934        /* Lower 8-bits. */
     1935        tmp = addr & 0xff;
     1936        snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
     1937                            VENDOR_CHIPIO_8051_ADDRESS_LOW, tmp);
     1938
     1939        /* Upper 8-bits. */
     1940        tmp = (addr >> 8) & 0xff;
     1941        snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
     1942                            VENDOR_CHIPIO_8051_ADDRESS_HIGH, tmp);
     1943}
     1944
     1945static void chipio_8051_set_data(struct hda_codec *codec, unsigned int data)
     1946{
     1947        /* 8-bits of data. */
     1948        snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
     1949                            VENDOR_CHIPIO_8051_DATA_WRITE, data & 0xff);
     1950}
     1951
     1952static unsigned int chipio_8051_get_data(struct hda_codec *codec)
     1953{
     1954        return snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0,
     1955                                   VENDOR_CHIPIO_8051_DATA_READ, 0);
     1956}
     1957
     1958/* PLL_PMU writes share the lower address register of the 8051 exram writes. */
     1959static void chipio_8051_set_data_pll(struct hda_codec *codec, unsigned int data)
     1960{
     1961        /* 8-bits of data. */
     1962        snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
     1963                            VENDOR_CHIPIO_PLL_PMU_WRITE, data & 0xff);
     1964}
     1965
     1966static void chipio_8051_write_exram(struct hda_codec *codec,
     1967                unsigned int addr, unsigned int data)
     1968{
     1969        struct ca0132_spec *spec = codec->spec;
     1970
     1971        mutex_lock(&spec->chipio_mutex);
     1972
     1973        chipio_8051_set_address(codec, addr);
     1974        chipio_8051_set_data(codec, data);
     1975
     1976        mutex_unlock(&spec->chipio_mutex);
     1977}
     1978
     1979static void chipio_8051_write_exram_no_mutex(struct hda_codec *codec,
     1980                unsigned int addr, unsigned int data)
     1981{
     1982        chipio_8051_set_address(codec, addr);
     1983        chipio_8051_set_data(codec, data);
     1984}
     1985
     1986/* Readback data from the 8051's exram. No mutex. */
     1987static void chipio_8051_read_exram(struct hda_codec *codec,
     1988                unsigned int addr, unsigned int *data)
     1989{
     1990        chipio_8051_set_address(codec, addr);
     1991        *data = chipio_8051_get_data(codec);
     1992}
     1993
     1994static void chipio_8051_write_pll_pmu(struct hda_codec *codec,
     1995                unsigned int addr, unsigned int data)
     1996{
     1997        struct ca0132_spec *spec = codec->spec;
     1998
     1999        mutex_lock(&spec->chipio_mutex);
     2000
     2001        chipio_8051_set_address(codec, addr & 0xff);
     2002        chipio_8051_set_data_pll(codec, data);
     2003
     2004        mutex_unlock(&spec->chipio_mutex);
     2005}
     2006
     2007static void chipio_8051_write_pll_pmu_no_mutex(struct hda_codec *codec,
     2008                unsigned int addr, unsigned int data)
     2009{
     2010        chipio_8051_set_address(codec, addr & 0xff);
     2011        chipio_8051_set_data_pll(codec, data);
     2012}
     2013
     2014/*
    18772015 * Enable clocks.
    18782016 */
     
    18822020
    18832021        mutex_lock(&spec->chipio_mutex);
    1884         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    1885                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0);
    1886         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    1887                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xff);
    1888         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    1889                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 5);
    1890         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    1891                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0x0b);
    1892         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    1893                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 6);
    1894         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    1895                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xff);
     2022
     2023        chipio_8051_write_pll_pmu_no_mutex(codec, 0x00, 0xff);
     2024        chipio_8051_write_pll_pmu_no_mutex(codec, 0x05, 0x0b);
     2025        chipio_8051_write_pll_pmu_no_mutex(codec, 0x06, 0xff);
     2026
    18962027        mutex_unlock(&spec->chipio_mutex);
    18972028}
     
    22142345
    22152346/**
    2216  * Prepare and send the SCP message to DSP
     2347 * dspio_scp - Prepare and send the SCP message to DSP
    22172348 * @codec: the HDA codec
    22182349 * @mod_id: ID of the DSP module to send the command
     
    23232454}
    23242455
    2325 static int dspio_set_uint_param_no_source(struct hda_codec *codec, int mod_id,
    2326                         int req, const unsigned int data)
    2327 {
    2328         return dspio_set_param(codec, mod_id, 0x00, req, &data,
    2329                         sizeof(unsigned int));
    2330 }
    2331 
    23322456/*
    23332457 * Allocate a DSP DMA channel via an SCP message
     
    27482872
    27492873/**
    2750  * Allocate router ports
     2874 * dsp_allocate_router_ports - Allocate router ports
    27512875 *
    27522876 * @codec: the HDA codec
     
    30653189
    30663190/**
    3067  * Write a block of data into DSP code or data RAM using pre-allocated
    3068  * DMA engine.
     3191 * dspxfr_one_seg - Write a block of data into DSP code or data RAM using pre-allocated DMA engine.
    30693192 *
    30703193 * @codec: the HDA codec
     
    32633386
    32643387/**
    3265  * Write the entire DSP image of a DSP code/data overlay to DSP memories
     3388 * dspxfr_image - Write the entire DSP image of a DSP code/data overlay to DSP memories
    32663389 *
    32673390 * @codec: the HDA codec
     
    70177140                snd_hda_add_vmaster(codec, "Master Playback Volume",
    70187141                                        spec->tlv, ca0132_alt_follower_pfxs,
    7019                                         "Playback Volume");
     7142                                        "Playback Volume", 0);
    70207143                err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
    70217144                                            NULL, ca0132_alt_follower_pfxs,
    70227145                                            "Playback Switch",
    7023                                             true, &spec->vmaster_mute.sw_kctl);
     7146                                            true, 0, &spec->vmaster_mute.sw_kctl);
    70247147                if (err < 0)
    70257148                        return err;
     
    74887611
    74897612        mutex_lock(&spec->chipio_mutex);
    7490         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7491                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x20);
    7492         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7493                             VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19);
    7494         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7495                             VENDOR_CHIPIO_8051_DATA_WRITE, 0x00);
    7496         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7497                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x2D);
    7498         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7499                             VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19);
    7500         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7501                             VENDOR_CHIPIO_8051_DATA_WRITE, 0x00);
     7613
     7614        chipio_8051_write_exram_no_mutex(codec, 0x1920, 0x00);
     7615        chipio_8051_write_exram_no_mutex(codec, 0x192d, 0x00);
     7616
    75027617        mutex_unlock(&spec->chipio_mutex);
    75037618}
     
    75217636                refresh_amp_caps(codec, spec->input_pins[i], HDA_INPUT);
    75227637        }
     7638}
     7639
     7640
     7641/* If there is an active channel for some reason, find it and free it. */
     7642static void ca0132_alt_free_active_dma_channels(struct hda_codec *codec)
     7643{
     7644        unsigned int i, tmp;
     7645        int status;
     7646
     7647        /* Read active DSPDMAC channel register. */
     7648        status = chipio_read(codec, DSPDMAC_CHNLSTART_MODULE_OFFSET, &tmp);
     7649        if (status >= 0) {
     7650                /* AND against 0xfff to get the active channel bits. */
     7651                tmp = tmp & 0xfff;
     7652
     7653                /* If there are no active channels, nothing to free. */
     7654                if (!tmp)
     7655                        return;
     7656        } else {
     7657                codec_dbg(codec, "%s: Failed to read active DSP DMA channel register.\n",
     7658                                __func__);
     7659                return;
     7660        }
     7661
     7662        /*
     7663         * Check each DSP DMA channel for activity, and if the channel is
     7664         * active, free it.
     7665         */
     7666        for (i = 0; i < DSPDMAC_DMA_CFG_CHANNEL_COUNT; i++) {
     7667                if (dsp_is_dma_active(codec, i)) {
     7668                        status = dspio_free_dma_chan(codec, i);
     7669                        if (status < 0)
     7670                                codec_dbg(codec, "%s: Failed to free active DSP DMA channel %d.\n",
     7671                                                __func__, i);
     7672                }
     7673        }
     7674}
     7675
     7676/*
     7677 * In the case of CT_EXTENSIONS_ENABLE being set to 1, and the DSP being in
     7678 * use, audio is no longer routed directly to the DAC/ADC from the HDA stream.
     7679 * Instead, audio is now routed through the DSP's DMA controllers, which
     7680 * the DSP is tasked with setting up itself. Through debugging, it seems the
     7681 * cause of most of the no-audio on startup issues were due to improperly
     7682 * configured DSP DMA channels.
     7683 *
     7684 * Normally, the DSP configures these the first time an HDA audio stream is
     7685 * started post DSP firmware download. That is why creating a 'dummy' stream
     7686 * worked in fixing the audio in some cases. This works most of the time, but
     7687 * sometimes if a stream is started/stopped before the DSP can setup the DMA
     7688 * configuration registers, it ends up in a broken state. Issues can also
     7689 * arise if streams are started in an unusual order, i.e the audio output dma
     7690 * channel being sandwiched between the mic1 and mic2 dma channels.
     7691 *
     7692 * The solution to this is to make sure that the DSP has no DMA channels
     7693 * in use post DSP firmware download, and then to manually start each default
     7694 * DSP stream that uses the DMA channels. These are 0x0c, the audio output
     7695 * stream, 0x03, analog mic 1, and 0x04, analog mic 2.
     7696 */
     7697static void ca0132_alt_start_dsp_audio_streams(struct hda_codec *codec)
     7698{
     7699        const unsigned int dsp_dma_stream_ids[] = { 0x0c, 0x03, 0x04 };
     7700        struct ca0132_spec *spec = codec->spec;
     7701        unsigned int i, tmp;
     7702
     7703        /*
     7704         * Check if any of the default streams are active, and if they are,
     7705         * stop them.
     7706         */
     7707        mutex_lock(&spec->chipio_mutex);
     7708
     7709        for (i = 0; i < ARRAY_SIZE(dsp_dma_stream_ids); i++) {
     7710                chipio_get_stream_control(codec, dsp_dma_stream_ids[i], &tmp);
     7711
     7712                if (tmp) {
     7713                        chipio_set_stream_control(codec,
     7714                                        dsp_dma_stream_ids[i], 0);
     7715                }
     7716        }
     7717
     7718        mutex_unlock(&spec->chipio_mutex);
     7719
     7720        /*
     7721         * If all DSP streams are inactive, there should be no active DSP DMA
     7722         * channels. Check and make sure this is the case, and if it isn't,
     7723         * free any active channels.
     7724         */
     7725        ca0132_alt_free_active_dma_channels(codec);
     7726
     7727        mutex_lock(&spec->chipio_mutex);
     7728
     7729        /* Make sure stream 0x0c is six channels. */
     7730        chipio_set_stream_channels(codec, 0x0c, 6);
     7731
     7732        for (i = 0; i < ARRAY_SIZE(dsp_dma_stream_ids); i++) {
     7733                chipio_set_stream_control(codec,
     7734                                dsp_dma_stream_ids[i], 1);
     7735
     7736                /* Give the DSP some time to setup the DMA channel. */
     7737                msleep(75);
     7738        }
     7739
     7740        mutex_unlock(&spec->chipio_mutex);
     7741}
     7742
     7743/*
     7744 * The region of ChipIO memory from 0x190000-0x1903fc is a sort of 'audio
     7745 * router', where each entry represents a 48khz audio channel, with a format
     7746 * of an 8-bit destination, an 8-bit source, and an unknown 2-bit number
     7747 * value. The 2-bit number value is seemingly 0 if inactive, 1 if active,
     7748 * and 3 if it's using Sample Rate Converter ports.
     7749 * An example is:
     7750 * 0x0001f8c0
     7751 * In this case, f8 is the destination, and c0 is the source. The number value
     7752 * is 1.
     7753 * This region of memory is normally managed internally by the 8051, where
     7754 * the region of exram memory from 0x1477-0x1575 has each byte represent an
     7755 * entry within the 0x190000 range, and when a range of entries is in use, the
     7756 * ending value is overwritten with 0xff.
     7757 * 0x1578 in exram is a table of 0x25 entries, corresponding to the ChipIO
     7758 * streamID's, where each entry is a starting 0x190000 port offset.
     7759 * 0x159d in exram is the same as 0x1578, except it contains the ending port
     7760 * offset for the corresponding streamID.
     7761 *
     7762 * On certain cards, such as the SBZ/ZxR/AE7, these are originally setup by
     7763 * the 8051, then manually overwritten to remap the ports to work with the
     7764 * new DACs.
     7765 *
     7766 * Currently known portID's:
     7767 * 0x00-0x1f: HDA audio stream input/output ports.
     7768 * 0x80-0xbf: Sample rate converter input/outputs. Only valid ports seem to
     7769 *            have the lower-nibble set to 0x1, 0x2, and 0x9.
     7770 * 0xc0-0xdf: DSP DMA input/output ports. Dynamically assigned.
     7771 * 0xe0-0xff: DAC/ADC audio input/output ports.
     7772 *
     7773 * Currently known streamID's:
     7774 * 0x03: Mic1 ADC to DSP.
     7775 * 0x04: Mic2 ADC to DSP.
     7776 * 0x05: HDA node 0x02 audio stream to DSP.
     7777 * 0x0f: DSP Mic exit to HDA node 0x07.
     7778 * 0x0c: DSP processed audio to DACs.
     7779 * 0x14: DAC0, front L/R.
     7780 *
     7781 * It is possible to route the HDA audio streams directly to the DAC and
     7782 * bypass the DSP entirely, with the only downside being that since the DSP
     7783 * does volume control, the only volume control you'll get is through PCM on
     7784 * the PC side, in the same way volume is handled for optical out. This may be
     7785 * useful for debugging.
     7786 */
     7787static void chipio_remap_stream(struct hda_codec *codec,
     7788                const struct chipio_stream_remap_data *remap_data)
     7789{
     7790        unsigned int i, stream_offset;
     7791
     7792        /* Get the starting port for the stream to be remapped. */
     7793        chipio_8051_read_exram(codec, 0x1578 + remap_data->stream_id,
     7794                        &stream_offset);
     7795
     7796        /*
     7797         * Check if the stream's port value is 0xff, because the 8051 may not
     7798         * have gotten around to setting up the stream yet. Wait until it's
     7799         * setup to remap it's ports.
     7800         */
     7801        if (stream_offset == 0xff) {
     7802                for (i = 0; i < 5; i++) {
     7803                        msleep(25);
     7804
     7805                        chipio_8051_read_exram(codec, 0x1578 + remap_data->stream_id,
     7806                                        &stream_offset);
     7807
     7808                        if (stream_offset != 0xff)
     7809                                break;
     7810                }
     7811        }
     7812
     7813        if (stream_offset == 0xff) {
     7814                codec_info(codec, "%s: Stream 0x%02x ports aren't allocated, remap failed!\n",
     7815                                __func__, remap_data->stream_id);
     7816                return;
     7817        }
     7818
     7819        /* Offset isn't in bytes, its in 32-bit words, so multiply it by 4. */
     7820        stream_offset *= 0x04;
     7821        stream_offset += 0x190000;
     7822
     7823        for (i = 0; i < remap_data->count; i++) {
     7824                chipio_write_no_mutex(codec,
     7825                                stream_offset + remap_data->offset[i],
     7826                                remap_data->value[i]);
     7827        }
     7828
     7829        /* Update stream map configuration. */
     7830        chipio_write_no_mutex(codec, 0x19042c, 0x00000001);
    75237831}
    75247832
     
    75837891                dspio_set_uint_param(codec, 0x96,
    75847892                                SPEAKER_TUNING_FRONT_LEFT_DELAY + i, values[i]);
    7585 }
    7586 
    7587 /*
    7588  * Creates a dummy stream to bind the output to. This seems to have to be done
    7589  * after changing the main outputs source and destination streams.
    7590  */
    7591 static void ca0132_alt_create_dummy_stream(struct hda_codec *codec)
    7592 {
    7593         struct ca0132_spec *spec = codec->spec;
    7594         unsigned int stream_format;
    7595 
    7596         stream_format = snd_hdac_calc_stream_format(48000, 2,
    7597                         SNDRV_PCM_FORMAT_S32_LE, 32, 0);
    7598 
    7599         snd_hda_codec_setup_stream(codec, spec->dacs[0], spec->dsp_stream_id,
    7600                                         0, stream_format);
    7601 
    7602         snd_hda_codec_cleanup_stream(codec, spec->dacs[0]);
    76037893}
    76047894
     
    76447934        codec_dbg(codec, "Connect Streams entered, mutex locked and loaded.\n");
    76457935
    7646         chipio_set_stream_channels(codec, 0x0C, 6);
    7647         chipio_set_stream_control(codec, 0x0C, 1);
    7648 
    76497936        /* This value is 0x43 for 96khz, and 0x83 for 192khz. */
    76507937        chipio_write_no_mutex(codec, 0x18a020, 0x00000043);
     
    76707957static void sbz_chipio_startup_data(struct hda_codec *codec)
    76717958{
     7959        const struct chipio_stream_remap_data *dsp_out_remap_data;
    76727960        struct ca0132_spec *spec = codec->spec;
    76737961
     
    76757963        codec_dbg(codec, "Startup Data entered, mutex locked and loaded.\n");
    76767964
    7677         /* These control audio output */
    7678         chipio_write_no_mutex(codec, 0x190060, 0x0001f8c0);
    7679         chipio_write_no_mutex(codec, 0x190064, 0x0001f9c1);
    7680         chipio_write_no_mutex(codec, 0x190068, 0x0001fac6);
    7681         chipio_write_no_mutex(codec, 0x19006c, 0x0001fbc7);
    7682         /* Signal to update I think */
    7683         chipio_write_no_mutex(codec, 0x19042c, 0x00000001);
    7684 
    7685         chipio_set_stream_channels(codec, 0x0C, 6);
    7686         chipio_set_stream_control(codec, 0x0C, 1);
    7687         /* No clue what these control */
    7688         if (ca0132_quirk(spec) == QUIRK_SBZ) {
    7689                 chipio_write_no_mutex(codec, 0x190030, 0x0001e0c0);
    7690                 chipio_write_no_mutex(codec, 0x190034, 0x0001e1c1);
    7691                 chipio_write_no_mutex(codec, 0x190038, 0x0001e4c2);
    7692                 chipio_write_no_mutex(codec, 0x19003c, 0x0001e5c3);
    7693                 chipio_write_no_mutex(codec, 0x190040, 0x0001e2c4);
    7694                 chipio_write_no_mutex(codec, 0x190044, 0x0001e3c5);
    7695                 chipio_write_no_mutex(codec, 0x190048, 0x0001e8c6);
    7696                 chipio_write_no_mutex(codec, 0x19004c, 0x0001e9c7);
    7697                 chipio_write_no_mutex(codec, 0x190050, 0x0001ecc8);
    7698                 chipio_write_no_mutex(codec, 0x190054, 0x0001edc9);
    7699                 chipio_write_no_mutex(codec, 0x190058, 0x0001eaca);
    7700                 chipio_write_no_mutex(codec, 0x19005c, 0x0001ebcb);
    7701         } else if (ca0132_quirk(spec) == QUIRK_ZXR) {
    7702                 chipio_write_no_mutex(codec, 0x190038, 0x000140c2);
    7703                 chipio_write_no_mutex(codec, 0x19003c, 0x000141c3);
    7704                 chipio_write_no_mutex(codec, 0x190040, 0x000150c4);
    7705                 chipio_write_no_mutex(codec, 0x190044, 0x000151c5);
    7706                 chipio_write_no_mutex(codec, 0x190050, 0x000142c8);
    7707                 chipio_write_no_mutex(codec, 0x190054, 0x000143c9);
    7708                 chipio_write_no_mutex(codec, 0x190058, 0x000152ca);
    7709                 chipio_write_no_mutex(codec, 0x19005c, 0x000153cb);
    7710         }
    7711         chipio_write_no_mutex(codec, 0x19042c, 0x00000001);
     7965        /* Remap DAC0's output ports. */
     7966        chipio_remap_stream(codec, &stream_remap_data[0]);
     7967
     7968        /* Remap DSP audio output stream ports. */
     7969        switch (ca0132_quirk(spec)) {
     7970        case QUIRK_SBZ:
     7971                dsp_out_remap_data = &stream_remap_data[1];
     7972                break;
     7973
     7974        case QUIRK_ZXR:
     7975                dsp_out_remap_data = &stream_remap_data[2];
     7976                break;
     7977
     7978        default:
     7979                dsp_out_remap_data = NULL;
     7980                break;
     7981        }
     7982
     7983        if (dsp_out_remap_data)
     7984                chipio_remap_stream(codec, dsp_out_remap_data);
    77127985
    77137986        codec_dbg(codec, "Startup Data exited, mutex released.\n");
    77147987        mutex_unlock(&spec->chipio_mutex);
    7715 }
    7716 
    7717 /*
    7718  * Custom DSP SCP commands where the src value is 0x00 instead of 0x20. This is
    7719  * done after the DSP is loaded.
    7720  */
    7721 static void ca0132_alt_dsp_scp_startup(struct hda_codec *codec)
    7722 {
    7723         struct ca0132_spec *spec = codec->spec;
    7724         unsigned int tmp, i;
    7725 
    7726         /*
    7727          * Gotta run these twice, or else mic works inconsistently. Not clear
    7728          * why this is, but multiple tests have confirmed it.
    7729          */
    7730         for (i = 0; i < 2; i++) {
    7731                 switch (ca0132_quirk(spec)) {
    7732                 case QUIRK_SBZ:
    7733                 case QUIRK_AE5:
    7734                 case QUIRK_AE7:
    7735                         tmp = 0x00000003;
    7736                         dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
    7737                         tmp = 0x00000000;
    7738                         dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp);
    7739                         tmp = 0x00000001;
    7740                         dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp);
    7741                         tmp = 0x00000004;
    7742                         dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
    7743                         tmp = 0x00000005;
    7744                         dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
    7745                         tmp = 0x00000000;
    7746                         dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
    7747                         break;
    7748                 case QUIRK_R3D:
    7749                 case QUIRK_R3DI:
    7750                         tmp = 0x00000000;
    7751                         dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp);
    7752                         tmp = 0x00000001;
    7753                         dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp);
    7754                         tmp = 0x00000004;
    7755                         dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
    7756                         tmp = 0x00000005;
    7757                         dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
    7758                         tmp = 0x00000000;
    7759                         dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);
    7760                         break;
    7761                 default:
    7762                         break;
    7763                 }
    7764                 msleep(100);
    7765         }
    77667988}
    77677989
     
    78028024
    78038025        chipio_8051_write_direct(codec, 0x93, 0x10);
    7804         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7805                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x44);
    7806         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7807                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc2);
     8026        chipio_8051_write_pll_pmu(codec, 0x44, 0xc2);
    78088027
    78098028        writeb(0xff, spec->mem_base + 0x304);
     
    78428061        chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0);
    78438062
    7844         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7845                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x92);
    7846         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7847                             VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0xfa);
    7848         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7849                             VENDOR_CHIPIO_8051_DATA_WRITE, 0x22);
     8063        chipio_8051_write_exram(codec, 0xfa92, 0x22);
    78508064}
    78518065
    78528066static void ae5_post_dsp_pll_setup(struct hda_codec *codec)
    78538067{
    7854         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7855                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x41);
    7856         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7857                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc8);
    7858 
    7859         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7860                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x45);
    7861         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7862                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xcc);
    7863 
    7864         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7865                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x40);
    7866         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7867                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xcb);
    7868 
    7869         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7870                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x43);
    7871         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7872                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc7);
    7873 
    7874         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7875                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x51);
    7876         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7877                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0x8d);
     8068        chipio_8051_write_pll_pmu(codec, 0x41, 0xc8);
     8069        chipio_8051_write_pll_pmu(codec, 0x45, 0xcc);
     8070        chipio_8051_write_pll_pmu(codec, 0x40, 0xcb);
     8071        chipio_8051_write_pll_pmu(codec, 0x43, 0xc7);
     8072        chipio_8051_write_pll_pmu(codec, 0x51, 0x8d);
    78788073}
    78798074
     
    78878082
    78888083        chipio_set_conn_rate_no_mutex(codec, 0x70, SR_96_000);
    7889 
    7890         chipio_set_stream_channels(codec, 0x0C, 6);
    7891         chipio_set_stream_control(codec, 0x0C, 1);
    78928084
    78938085        chipio_set_stream_source_dest(codec, 0x5, 0x43, 0x0);
     
    79008092        chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 4);
    79018093
    7902         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7903                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x43);
    7904         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    7905                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc7);
     8094        chipio_8051_write_pll_pmu_no_mutex(codec, 0x43, 0xc7);
    79068095
    79078096        ca0113_mmio_command_set(codec, 0x48, 0x01, 0x80);
     
    79428131}
    79438132
    7944 static const unsigned int ae7_port_set_data[] = {
    7945         0x0001e0c0, 0x0001e1c1, 0x0001e4c2, 0x0001e5c3, 0x0001e2c4, 0x0001e3c5,
    7946         0x0001e8c6, 0x0001e9c7, 0x0001ecc8, 0x0001edc9, 0x0001eaca, 0x0001ebcb
    7947 };
    7948 
    79498133static void ae7_post_dsp_setup_ports(struct hda_codec *codec)
    79508134{
    79518135        struct ca0132_spec *spec = codec->spec;
    7952         unsigned int i, count, addr;
    79538136
    79548137        mutex_lock(&spec->chipio_mutex);
    79558138
    7956         chipio_set_stream_channels(codec, 0x0c, 6);
    7957         chipio_set_stream_control(codec, 0x0c, 1);
    7958 
    7959         count = ARRAY_SIZE(ae7_port_set_data);
    7960         addr = 0x190030;
    7961         for (i = 0; i < count; i++) {
    7962                 chipio_write_no_mutex(codec, addr, ae7_port_set_data[i]);
    7963 
    7964                 /* Addresses are incremented by 4-bytes. */
    7965                 addr += 0x04;
    7966         }
    7967 
    7968         /*
    7969          * Port setting always ends with a write of 0x1 to address 0x19042c.
    7970          */
    7971         chipio_write_no_mutex(codec, 0x19042c, 0x00000001);
     8139        /* Seems to share the same port remapping as the SBZ. */
     8140        chipio_remap_stream(codec, &stream_remap_data[1]);
    79728141
    79738142        ca0113_mmio_command_set(codec, 0x30, 0x30, 0x00);
     
    79938162
    79948163        chipio_set_conn_rate_no_mutex(codec, 0x70, SR_96_000);
    7995         chipio_set_stream_channels(codec, 0x0c, 6);
    7996         chipio_set_stream_control(codec, 0x0c, 1);
    79978164
    79988165        chipio_set_stream_source_dest(codec, 0x05, 0x43, 0x00);
     
    80188185        unsigned int i;
    80198186
    8020         for (i = 0; i < ARRAY_SIZE(addr); i++) {
    8021                 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8022                                     VENDOR_CHIPIO_8051_ADDRESS_LOW, addr[i]);
    8023                 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8024                                     VENDOR_CHIPIO_PLL_PMU_WRITE, data[i]);
    8025         }
     8187        for (i = 0; i < ARRAY_SIZE(addr); i++)
     8188                chipio_8051_write_pll_pmu_no_mutex(codec, addr[i], data[i]);
    80268189}
    80278190
     
    80398202        mutex_lock(&spec->chipio_mutex);
    80408203
    8041         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8042                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x43);
    8043         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8044                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc7);
     8204        chipio_8051_write_pll_pmu_no_mutex(codec, 0x43, 0xc7);
    80458205
    80468206        chipio_write_no_mutex(codec, 0x189000, 0x0001f101);
     
    81158275        chipio_8051_write_direct(codec, 0x93, 0x10);
    81168276
    8117         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8118                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x44);
    8119         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8120                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc2);
     8277        chipio_8051_write_pll_pmu(codec, 0x44, 0xc2);
    81218278
    81228279        ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83);
     
    81308287        snd_hda_codec_write(codec, 0x17, 0, 0x794, 0x00);
    81318288
    8132         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8133                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x92);
    8134         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8135                             VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0xfa);
    8136         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8137                             VENDOR_CHIPIO_8051_DATA_WRITE, 0x22);
     8289        chipio_8051_write_exram(codec, 0xfa92, 0x22);
    81388290
    81398291        ae7_post_dsp_pll_setup(codec);
    81408292        ae7_post_dsp_asi_stream_setup(codec);
    81418293
    8142         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8143                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x43);
    8144         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    8145                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc7);
     8294        chipio_8051_write_pll_pmu(codec, 0x43, 0xc7);
    81468295
    81478296        ae7_post_dsp_asi_setup_ports(codec);
     
    82068355                return;
    82078356
    8208         ca0132_alt_dsp_scp_startup(codec);
    82098357        ca0132_alt_init_analog_mics(codec);
     8358        ca0132_alt_start_dsp_audio_streams(codec);
    82108359
    82118360        /*remove DSP headroom*/
     
    82568405                return;
    82578406
    8258         ca0132_alt_dsp_scp_startup(codec);
    82598407        ca0132_alt_init_analog_mics(codec);
     8408        ca0132_alt_start_dsp_audio_streams(codec);
    82608409        sbz_connect_streams(codec);
    82618410        sbz_chipio_startup_data(codec);
    8262 
    8263         chipio_set_stream_control(codec, 0x03, 1);
    8264         chipio_set_stream_control(codec, 0x04, 1);
    82658411
    82668412        /*
     
    82988444
    82998445        ca0132_alt_init_speaker_tuning(codec);
    8300 
    8301         ca0132_alt_create_dummy_stream(codec);
    83028446}
    83038447
     
    83158459                return;
    83168460
    8317         ca0132_alt_dsp_scp_startup(codec);
    83188461        ca0132_alt_init_analog_mics(codec);
    8319         chipio_set_stream_control(codec, 0x03, 1);
    8320         chipio_set_stream_control(codec, 0x04, 1);
     8462        ca0132_alt_start_dsp_audio_streams(codec);
    83218463
    83228464        /* New, unknown SCP req's */
     
    83678509
    83688510        ca0132_alt_init_speaker_tuning(codec);
    8369 
    8370         ca0132_alt_create_dummy_stream(codec);
    83718511}
    83728512
     
    83848524                return;
    83858525
    8386         ca0132_alt_dsp_scp_startup(codec);
    83878526        ca0132_alt_init_analog_mics(codec);
     8527        ca0132_alt_start_dsp_audio_streams(codec);
    83888528        ae7_post_dsp_setup_ports(codec);
    83898529
     
    84528592
    84538593        ca0132_alt_init_speaker_tuning(codec);
    8454 
    8455         ca0132_alt_create_dummy_stream(codec);
    84568594}
    84578595
     
    86448782}
    86458783
    8646 static void ca0132_init_unsol(struct hda_codec *codec)
     8784static void ca0132_setup_unsol(struct hda_codec *codec)
    86478785{
    86488786        struct ca0132_spec *spec = codec->spec;
     
    87428880        mutex_init(&spec->chipio_mutex);
    87438881
     8882        /*
     8883         * The Windows driver always does this upon startup, which seems to
     8884         * clear out any previous configuration. This should help issues where
     8885         * a boot into Windows prior to a boot into Linux breaks things. Also,
     8886         * Windows always sends the reset twice.
     8887         */
     8888        if (ca0132_use_alt_functions(spec)) {
     8889                chipio_set_control_flag(codec, CONTROL_FLAG_IDLE_ENABLE, 0);
     8890                chipio_write_no_mutex(codec, 0x18b0a4, 0x000000c2);
     8891
     8892                snd_hda_codec_write(codec, codec->core.afg, 0,
     8893                            AC_VERB_SET_CODEC_RESET, 0);
     8894                snd_hda_codec_write(codec, codec->core.afg, 0,
     8895                            AC_VERB_SET_CODEC_RESET, 0);
     8896        }
     8897
    87448898        spec->cur_out_type = SPEAKER_OUT;
    87458899        if (!ca0132_use_alt_functions(spec))
     
    91149268        chipio_write(codec, 0x18b0a4, 0x000000c2);
    91159269
    9116         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9117                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x1E);
    9118         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9119                             VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x1C);
    9120         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9121                             VENDOR_CHIPIO_8051_DATA_WRITE, 0x5B);
     9270        chipio_8051_write_exram(codec, 0x1c1e, 0x5b);
    91229271
    91239272        snd_hda_codec_write(codec, 0x11, 0,
     
    91299278        chipio_write(codec, 0x18b0a4, 0x000000c2);
    91309279
    9131         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9132                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x1E);
    9133         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9134                             VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x1C);
    9135         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9136                             VENDOR_CHIPIO_8051_DATA_WRITE, 0x5B);
    9137 
    9138         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9139                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x20);
    9140         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9141                             VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19);
    9142         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9143                             VENDOR_CHIPIO_8051_DATA_WRITE, 0x00);
    9144         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9145                             VENDOR_CHIPIO_8051_DATA_WRITE, 0x40);
     9280        chipio_8051_write_exram(codec, 0x1c1e, 0x5b);
     9281        chipio_8051_write_exram(codec, 0x1920, 0x00);
     9282        chipio_8051_write_exram(codec, 0x1921, 0x40);
    91469283
    91479284        snd_hda_codec_write(codec, 0x11, 0,
    91489285                        AC_VERB_SET_PIN_WIDGET_CONTROL, 0x04);
     9286}
     9287
     9288/*
     9289 * The ZxR seems to use alternative DAC's for the surround channels, which
     9290 * require PLL PMU setup for the clock rate, I'm guessing. Without setting
     9291 * this up, we get no audio out of the surround jacks.
     9292 */
     9293static void zxr_pre_dsp_setup(struct hda_codec *codec)
     9294{
     9295        static const unsigned int addr[] = { 0x43, 0x40, 0x41, 0x42, 0x45 };
     9296        static const unsigned int data[] = { 0x08, 0x0c, 0x0b, 0x07, 0x0d };
     9297        unsigned int i;
     9298
     9299        chipio_write(codec, 0x189000, 0x0001f100);
     9300        msleep(50);
     9301        chipio_write(codec, 0x18900c, 0x0001f100);
     9302        msleep(50);
     9303
     9304        /*
     9305         * This writes a RET instruction at the entry point of the function at
     9306         * 0xfa92 in exram. This function seems to have something to do with
     9307         * ASI. Might be some way to prevent the card from reconfiguring the
     9308         * ASI stuff itself.
     9309         */
     9310        chipio_8051_write_exram(codec, 0xfa92, 0x22);
     9311
     9312        chipio_8051_write_pll_pmu(codec, 0x51, 0x98);
     9313
     9314        snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x725, 0x82);
     9315        chipio_set_control_param(codec, CONTROL_PARAM_ASI, 3);
     9316
     9317        chipio_write(codec, 0x18902c, 0x00000000);
     9318        msleep(50);
     9319        chipio_write(codec, 0x18902c, 0x00000003);
     9320        msleep(50);
     9321
     9322        for (i = 0; i < ARRAY_SIZE(addr); i++)
     9323                chipio_8051_write_pll_pmu(codec, addr[i], data[i]);
    91499324}
    91509325
     
    93139488        unsigned char tmp[3];
    93149489
    9315         if (ca0132_quirk(spec) == QUIRK_AE7) {
    9316                 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9317                                     VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x41);
    9318                 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9319                                     VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc8);
    9320         }
     9490        if (ca0132_quirk(spec) == QUIRK_AE7)
     9491                chipio_8051_write_pll_pmu(codec, 0x41, 0xc8);
    93219492
    93229493        chipio_8051_write_direct(codec, 0x93, 0x10);
    9323         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9324                             VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x44);
    9325         snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9326                             VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc2);
     9494        chipio_8051_write_pll_pmu(codec, 0x44, 0xc2);
    93279495
    93289496        if (ca0132_quirk(spec) == QUIRK_AE7) {
     
    93639531        if (ca0132_quirk(spec) == QUIRK_AE5)
    93649532                ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83);
    9365 
    9366         chipio_write(codec, 0x18b0a4, 0x000000c2);
    9367 
    9368         snd_hda_codec_write(codec, 0x01, 0, 0x7ff, 0x00);
    9369         snd_hda_codec_write(codec, 0x01, 0, 0x7ff, 0x00);
    93709533}
    93719534
     
    94059568        case QUIRK_AE5:
    94069569                ca0132_gpio_init(codec);
    9407                 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9408                                 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x49);
    9409                 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9410                                 VENDOR_CHIPIO_PLL_PMU_WRITE, 0x88);
     9570                chipio_8051_write_pll_pmu(codec, 0x49, 0x88);
    94119571                chipio_write(codec, 0x18b030, 0x00000020);
    94129572                snd_hda_sequence_write(codec, spec->chip_init_verbs);
     
    94169576        case QUIRK_AE7:
    94179577                ca0132_gpio_init(codec);
    9418                 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9419                                 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x49);
    9420                 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0,
    9421                                 VENDOR_CHIPIO_PLL_PMU_WRITE, 0x88);
     9578                chipio_8051_write_pll_pmu(codec, 0x49, 0x88);
    94229579                snd_hda_sequence_write(codec, spec->chip_init_verbs);
    94239580                snd_hda_sequence_write(codec, spec->desktop_init_verbs);
     
    94289585                break;
    94299586        case QUIRK_ZXR:
     9587                chipio_8051_write_pll_pmu(codec, 0x49, 0x88);
    94309588                snd_hda_sequence_write(codec, spec->chip_init_verbs);
    94319589                snd_hda_sequence_write(codec, spec->desktop_init_verbs);
     9590                zxr_pre_dsp_setup(codec);
    94329591                break;
    94339592        default:
     
    94779636                ae5_register_set(codec);
    94789637
    9479         ca0132_init_unsol(codec);
    94809638        ca0132_init_params(codec);
    94819639        ca0132_init_flags(codec);
     
    1004210200                goto error;
    1004310201
     10202        ca0132_setup_unsol(codec);
     10203
    1004410204        return 0;
    1004510205
  • GPL/trunk/alsa-kernel/pci/hda/patch_cirrus.c

    r679 r695  
    1010#include <linux/module.h>
    1111#include <sound/core.h>
     12#include <linux/mutex.h>
     13#include <linux/pci.h>
    1214#include <sound/tlv.h>
    1315#include <sound/hda_codec.h>
     
    2426 */
    2527
     28#define CS42L42_HP_CH     (2U)
     29#define CS42L42_HS_MIC_CH (1U)
     30
    2631struct cs_spec {
    2732        struct hda_gen_spec gen;
     
    4247        int (*spdif_sw_put)(struct snd_kcontrol *kcontrol,
    4348                            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);
    4461};
    4562
     
    115132 * 1 ADC <= LineIn(sense) / MicIn / DMicIn,
    116133 * 1 SPDIF OUT => SPDIF Trasmitter(sense)
    117 */
     134 */
    118135#define CS4210_DAC_NID          0x02
    119136#define CS4210_ADC_NID          0x03
     
    134151{
    135152        struct cs_spec *spec = codec->spec;
     153
    136154        snd_hda_codec_write(codec, spec->vendor_nid, 0,
    137155                            AC_VERB_SET_COEF_INDEX, idx);
     
    144162{
    145163        struct cs_spec *spec = codec->spec;
     164
    146165        snd_hda_codec_write(codec, spec->vendor_nid, 0,
    147166                            AC_VERB_SET_COEF_INDEX, idx);
     
    180199{
    181200        unsigned int val;
     201
    182202        val = snd_hda_codec_get_pincfg(codec, nid);
    183203        return (get_defcfg_connect(val) != AC_JACK_PORT_NONE);
     
    198218                                         * No effect if SPDIF_OUT2 is
    199219                                         * selected in IDX_SPDIF_CTL.
    200                                         */
     220                                         */
    201221
    202222                cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef);
     
    272292        {0x11, AC_VERB_SET_PROC_COEF, 0x0008},
    273293        {0x11, AC_VERB_SET_PROC_STATE, 0x00},
    274 
    275 #if 0 /* Don't to set to D3 as we are in power-up sequence */
    276         {0x07, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Rx: D3 */
    277         {0x08, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Tx: D3 */
    278         /*{0x01, AC_VERB_SET_POWER_STATE, 0x03},*/ /* AFG: D3 This is already handled */
    279 #endif
    280 
    281294        {0} /* terminator */
    282295};
     
    366379        if (spec->gen.dyn_adc_switch) {
    367380                unsigned int done = 0;
     381
    368382                for (i = 0; i < spec->gen.input_mux.num_items; i++) {
    369383                        int idx = spec->gen.dyn_adc_idx[i];
     384
    370385                        if (done & (1 << idx))
    371386                                continue;
     
    501516        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
    502517                struct cs_spec *spec = codec->spec;
     518
    503519                spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */
    504520                spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */
     
    513529        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
    514530                struct cs_spec *spec = codec->spec;
     531
    515532                spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */
    516533                spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */
     
    659676        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
    660677                struct cs_spec *spec = codec->spec;
     678
    661679                spec->gpio_eapd_hp = 0;
    662680                spec->gpio_eapd_speaker = 1;
     
    813831 * 1 ADC <= LineIn(sense) / MicIn / DMicIn,
    814832 * 1 SPDIF OUT => SPDIF Trasmitter(sense)
    815 */
     833 */
    816834
    817835/* CS4210 board names */
     
    856874{
    857875        struct cs_spec *spec = codec->spec;
     876
    858877        if (action == HDA_FIXUP_ACT_PRE_PROBE)
    859878                spec->sense_b = 1;
     
    881900        {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_DEV_CFG},
    882901        /*
    883             Disable Coefficient Index Auto-Increment(DAI)=1,
    884             PDREF=0
    885         */
     902         *  Disable Coefficient Index Auto-Increment(DAI)=1,
     903         *  PDREF=0
     904         */
    886905        {0x0B, AC_VERB_SET_PROC_COEF, 0x0001 },
    887906
     
    970989        coef &= ~0x0003;
    971990        coef |= (vol & 0x0003);
    972         if (original_coef == coef)
    973                 return 0;
    974         else {
     991        if (original_coef != coef) {
    975992                cs_vendor_coef_set(codec, CS421X_IDX_SPK_CTL, coef);
    976993                return 1;
    977994        }
     995
     996        return 0;
    978997}
    979998
     
    10141033
    10151034                /*
    1016                     GPIO or SENSE_B forced - disconnect the DMIC pin.
    1017                 */
     1035                 *  GPIO or SENSE_B forced - disconnect the DMIC pin.
     1036                 */
    10181037                def_conf = snd_hda_codec_get_pincfg(codec, CS421X_DMIC_PIN_NID);
    10191038                def_conf &= ~AC_DEFCFG_PORT_CONN;
     
    10541073        for (i = 0; i < cfg->dig_outs; i++) {
    10551074                hda_nid_t nid = cfg->dig_out_pins[i];
     1075
    10561076                if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
    10571077                        spec->spdif_detect = 1;
     
    11321152#ifdef CONFIG_PM
    11331153/*
    1134         Manage PDREF, when transitioning to D3hot
    1135         (DAC,ADC) -> D3, PDREF=1, AFG->D3
    1136 */
     1154 *      Manage PDREF, when transitioning to D3hot
     1155 *      (DAC,ADC) -> D3, PDREF=1, AFG->D3
     1156 */
    11371157static int cs421x_suspend(struct hda_codec *codec)
    11381158{
     
    11851205
    11861206        /*
    1187             Update the GPIO/DMIC/SENSE_B pinmux before the configuration
    1188             is auto-parsed. If GPIO or SENSE_B is forced, DMIC input
    1189             is disabled.
    1190         */
     1207         *  Update the GPIO/DMIC/SENSE_B pinmux before the configuration
     1208         *   is auto-parsed. If GPIO or SENSE_B is forced, DMIC input
     1209         *   is disabled.
     1210         */
    11911211        cs4210_pinmux_init(codec);
    11921212
     
    12261246}
    12271247
     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
     1286struct cs8409_i2c_param {
     1287        unsigned int addr;
     1288        unsigned int reg;
     1289};
     1290
     1291struct cs8409_cir_param {
     1292        unsigned int nid;
     1293        unsigned int cir;
     1294        unsigned int coeff;
     1295};
     1296
     1297enum {
     1298        CS8409_BULLSEYE,
     1299        CS8409_WARLOCK,
     1300        CS8409_CYBORG,
     1301        CS8409_FIXUPS,
     1302};
     1303
     1304static void cs8409_cs42l42_fixups(struct hda_codec *codec,
     1305                                    const struct hda_fixup *fix, int action);
     1306static 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 */
     1310static 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 */
     1320static 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
     1364static 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
     1374static 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
     1382static 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 */
     1408static 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 */
     1462static 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
     1490static 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 */
     1525static 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 */
     1542static 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 */
     1570static 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 */
     1618static 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
     1652static 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
     1679static 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
     1707static 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
     1738static 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
     1784static const DECLARE_TLV_DB_SCALE(
     1785        cs8409_cs42l42_hp_db_scale,
     1786        CS8409_CS42L42_HP_VOL_REAL_MIN * 100, 100, 1);
     1787
     1788static const DECLARE_TLV_DB_SCALE(
     1789        cs8409_cs42l42_amic_db_scale,
     1790        CS8409_CS42L42_AMIC_VOL_REAL_MIN * 100, 100, 1);
     1791
     1792static 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
     1808static 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 */
     1825static 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 */
     1853static 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 */
     1878static 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
     1904static 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 */
     1925static 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 */
     2028static 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 */
     2047static 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 */
     2063static 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
     2130static 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
     2140static 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
     2151static 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
     2242static 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
     2278static 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}
    12282304
    12292305/*
     
    12362312        HDA_CODEC_ENTRY(0x10134210, "CS4210", patch_cs4210),
    12372313        HDA_CODEC_ENTRY(0x10134213, "CS4213", patch_cs4213),
     2314        HDA_CODEC_ENTRY(0x10138409, "CS8409", patch_cs8409),
    12382315        {0} /* terminator */
    12392316};
  • GPL/trunk/alsa-kernel/pci/hda/patch_conexant.c

    r689 r695  
    591591        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
    592592                spec->mute_led_eapd = 0x1b;
    593                 spec->dynamic_eapd = 1;
     593                spec->dynamic_eapd = true;
    594594#ifdef CONFIG_SND_HDA_GENERIC_LEDS
    595595                snd_hda_gen_add_mute_led_cdev(codec, cx_auto_vmaster_mute_led);
  • GPL/trunk/alsa-kernel/pci/hda/patch_hdmi.c

    r689 r695  
    165165        bool dyn_pin_out;
    166166        bool dyn_pcm_assign;
     167        bool dyn_pcm_no_legacy;
    167168        bool intel_hsw_fixup;   /* apply Intel platform-specific fixups */
    168169        /*
     
    261262        }
    262263
    263         codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid);
     264        codec_warn(codec, "HDMI: pin NID 0x%x not registered\n", pin_nid);
    264265        return -EINVAL;
    265266}
     
    321322                        return cvt_idx;
    322323
    323         codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid);
     324        codec_warn(codec, "HDMI: cvt NID 0x%x not registered\n", cvt_nid);
    324325        return -EINVAL;
    325326}
     
    646647        int i;
    647648
     649        hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
    648650        if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0)
    649651                                                            != AC_DIPXMIT_BEST)
    650652                return false;
    651653
    652         hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
    653654        for (i = 0; i < size; i++) {
    654655                val = snd_hda_codec_read(codec, pin_nid, 0,
     
    695696                dp_ai->CA               = ca;
    696697        } else {
    697                 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n",
    698                             pin_nid);
     698                codec_dbg(codec, "HDMI: unknown connection type at pin NID 0x%x\n", pin_nid);
    699699                return;
    700700        }
     
    709709        if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes,
    710710                                        sizeof(ai))) {
    711                 codec_dbg(codec,
    712                           "hdmi_pin_setup_infoframe: pin=%d channels=%d ca=0x%02x\n",
    713                             pin_nid,
    714                             active_channels, ca);
     711                codec_dbg(codec, "%s: pin NID=0x%x channels=%d ca=0x%02x\n",
     712                          __func__, pin_nid, active_channels, ca);
    715713                hdmi_stop_infoframe_trans(codec, pin_nid);
    716714                hdmi_fill_audio_infoframe(codec, pin_nid,
     
    804802
    805803        codec_dbg(codec,
    806                 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n",
     804                "HDMI hot plug event: Codec=%d NID=0x%x Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n",
    807805                codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA),
    808806                !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV));
     
    882880                pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0);
    883881                pwr = (pwr & AC_PWRST_ACTUAL) >> AC_PWRST_ACTUAL_SHIFT;
    884                 codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr);
     882                codec_dbg(codec, "Haswell HDMI audio: Power for NID 0x%x is now D%d\n", nid, pwr);
    885883        }
    886884}
     
    11291127                        if (!per_cvt->assigned) {
    11301128                                codec_dbg(codec,
    1131                                           "choose cvt %d for pin nid %d\n",
    1132                                         cvt_idx, nid);
     1129                                          "choose cvt %d for pin NID 0x%x\n",
     1130                                          cvt_idx, nid);
    11331131                                snd_hda_codec_write_cache(codec, nid, 0,
    11341132                                            AC_VERB_SET_CONNECT_SEL,
     
    13281326        if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
    13291327                codec_warn(codec,
    1330                            "HDMI: pin %d wcaps %#x does not support connection list\n",
     1328                           "HDMI: pin NID 0x%x wcaps %#x does not support connection list\n",
    13311329                           pin_nid, get_wcaps(codec, pin_nid));
    13321330                return -EINVAL;
     
    13551353{
    13561354        int i;
     1355
     1356        /* on the new machines, try to assign the pcm slot dynamically,
     1357         * not use the preferred fixed map (legacy way) anymore.
     1358         */
     1359        if (spec->dyn_pcm_no_legacy)
     1360                goto last_try;
    13571361
    13581362        /*
     
    13851389        }
    13861390
     1391 last_try:
    13871392        /* the last try; check the empty slots in pins */
    13881393        for (i = 0; i < spec->num_nids; i++) {
     
    16431648
    16441649        codec_dbg(codec,
    1645                 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
     1650                "HDMI status: Codec=%d NID=0x%x Presence_Detect=%d ELD_Valid=%d\n",
    16461651                codec->addr, pin_nid, eld->monitor_present, eld->eld_valid);
    16471652
     
    18511856        if (spec->intel_hsw_fixup) {
    18521857                /*
    1853                  * On Intel platforms, device entries number is
    1854                  * changed dynamically. If there is a DP MST
    1855                  * hub connected, the device entries number is 3.
    1856                  * Otherwise, it is 1.
    1857                  * Here we manually set dev_num to 3, so that
    1858                  * we can initialize all the device entries when
    1859                  * bootup statically.
     1858                 * On Intel platforms, device entries count returned
     1859                 * by AC_PAR_DEVLIST_LEN is dynamic, and depends on
     1860                 * the type of receiver that is connected. Allocate pin
     1861                 * structures based on worst case.
    18601862                 */
    1861                 dev_num = 3;
    1862                 spec->dev_num = 3;
     1863                dev_num = spec->dev_num;
    18631864        } else if (spec->dyn_pcm_assign && codec->dp_mst) {
    18641865                dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1;
     
    19471948        SND_PCI_QUIRK(0x103c, 0x870f, "HP", 1),
    19481949        SND_PCI_QUIRK(0x103c, 0x871a, "HP", 1),
     1950        SND_PCI_QUIRK(0x1462, 0xec94, "MS-7C94", 1),
    19491951        {}
    19501952};
     
    28152817        }
    28162818
    2817         codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid);
     2819        codec_info(codec, "Can't find the HDMI/DP port for pin NID 0x%x\n", pin_nid);
    28182820        return -1;
    28192821}
     
    29452947/* Intel Haswell and onwards; audio component with eld notifier */
    29462948static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid,
    2947                                  const int *port_map, int port_num)
     2949                                 const int *port_map, int port_num, int dev_num)
    29482950{
    29492951        struct hdmi_spec *spec;
     
    29602962        spec->port_num = port_num;
    29612963        spec->intel_hsw_fixup = true;
     2964        spec->dev_num = dev_num;
    29622965
    29632966        intel_haswell_enable_all_pins(codec, true);
     
    29852988static int patch_i915_hsw_hdmi(struct hda_codec *codec)
    29862989{
    2987         return intel_hsw_common_init(codec, 0x08, NULL, 0);
     2990        return intel_hsw_common_init(codec, 0x08, NULL, 0, 3);
    29882991}
    29892992
    29902993static int patch_i915_glk_hdmi(struct hda_codec *codec)
    29912994{
    2992         return intel_hsw_common_init(codec, 0x0b, NULL, 0);
     2995        return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3);
    29932996}
    29942997
     
    30013004        static const int map[] = {0x0, 0x4, 0x6, 0x8, 0xa, 0xb};
    30023005
    3003         return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
     3006        return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3);
    30043007}
    30053008
     
    30113014         */
    30123015        static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
    3013 
    3014         return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
     3016        int ret;
     3017
     3018        ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4);
     3019        if (!ret) {
     3020                struct hdmi_spec *spec = codec->spec;
     3021
     3022                spec->dyn_pcm_no_legacy = true;
     3023        }
     3024
     3025        return ret;
    30153026}
    30163027
  • GPL/trunk/alsa-kernel/pci/hda/patch_realtek.c

    r689 r695  
    299299{
    300300#ifdef CONFIG_SND_HDA_GENERIC_LEDS
    301         if (action == HDA_FIXUP_ACT_PROBE)
     301        if (action == HDA_FIXUP_ACT_PRE_PROBE)
    302302                snd_hda_gen_add_micmute_led_cdev(codec, NULL);
    303303#endif
     
    37763776                report |= SND_JACK_BTN_3;
    37773777
    3778         jack->jack->button_state = report;
     3778        snd_hda_jack_set_button_state(codec, jack->nid, report);
    37793779}
    37803780
     
    38393839{
    38403840        struct alc_spec *spec = codec->spec;
     3841        hda_nid_t hp_pin;
    38413842
    38423843        switch (action) {
     
    38453846                snd_hda_jack_detect_enable_callback(codec, 0x55,
    38463847                                                    alc_headset_btn_callback);
    3847                 snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack", false,
    3848                                       SND_JACK_HEADSET, alc_headset_btn_keymap);
    3849                 break;
    3850         case HDA_FIXUP_ACT_INIT:
     3848                break;
     3849        case HDA_FIXUP_ACT_BUILD:
     3850                hp_pin = alc_get_hp_pin(spec);
     3851                if (!hp_pin || snd_hda_jack_bind_keymap(codec, 0x55,
     3852                                                        alc_headset_btn_keymap,
     3853                                                        hp_pin))
     3854                        snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack",
     3855                                              false, SND_JACK_HEADSET,
     3856                                              alc_headset_btn_keymap);
     3857
    38513858                alc_enable_headset_jack_key(codec);
    38523859                break;
     
    70367043        }
    70377044}
     7045#endif /* NOT_USED */
    70387046
    70397047static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
     
    70547062        }
    70557063}
    7056 #endif /* NOT_USED */
    70577064
    70587065/* for hda_fixup_thinkpad_acpi() */
     
    72757282        ALC256_FIXUP_ACER_HEADSET_MIC,
    72767283        ALC285_FIXUP_IDEAPAD_S740_COEF,
     7284        ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST,
    72777285        ALC295_FIXUP_ASUS_DACS,
    72787286        ALC295_FIXUP_HP_OMEN,
     
    84578465                        {0}
    84588466                },
    8459                 .chained = true,
    8460                 .chain_id = ALC289_FIXUP_ASUS_GA401,
    84618467        },
    84628468        [ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
     
    88448850                        { }
    88458851                },
     8852                .chained = true,
     8853                .chain_id = ALC289_FIXUP_ASUS_GA401,
    88468854        },
    88478855#endif
     
    91179125                .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
    91189126        },
     9127        [ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST] = {
     9128                .type = HDA_FIXUP_FUNC,
     9129                .v.func = alc269_fixup_limit_int_mic_boost,
     9130                .chained = true,
     9131                .chain_id = ALC285_FIXUP_HP_MUTE_LED,
     9132        },
    91199133        [ALC295_FIXUP_ASUS_DACS] = {
    91209134                .type = HDA_FIXUP_FUNC,
     
    91379151                        { 0x1e, 0x411111f0 },
    91389152                        { 0x21, 0x03211020 },
    9139                         {0}
     9153                        {}
    91409154                },
    91419155                .chained = true,
    91429156                .chain_id = ALC269_FIXUP_HP_LINE1_MIC1_LED,
    91439157        },
     9158#endif
    91449159        [ALC285_FIXUP_HP_SPECTRE_X360] = {
    91459160                .type = HDA_FIXUP_FUNC,
    91469161                .v.func = alc285_fixup_hp_spectre_x360,
    91479162        },
    9148 #endif
    91499163        [ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = {
    91509164                .type = HDA_FIXUP_FUNC,
     
    92029216        SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
    92039217        SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC),
     9218        SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
    92049219        SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
    92059220        SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
    92069221        SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
     9222        SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
    92079223        SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
    92089224        SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
     
    93699385        SND_PCI_QUIRK(0x103c, 0x888d, "HP ZBook Power 15.6 inch G8 Mobile Workstation PC", ALC236_FIXUP_HP_GPIO_LED),
    93709386        SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED),
     9387        SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
     9388        SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED),
    93719389        SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
    93729390        SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
     
    95529570        SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
    95539571        SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
     9572        SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
    95549573        SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME),
    95559574        SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
  • GPL/trunk/alsa-kernel/pci/hda/patch_sigmatel.c

    r679 r695  
    43794379        spec->gen.automute_hook = stac_update_outputs;
    43804380
     4381#ifndef TARGET_OS2
     4382        if (spec->gpio_led)
     4383                snd_hda_gen_add_mute_led_cdev(codec, stac_vmaster_hook);
     4384#endif
    43814385        err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
    43824386        if (err < 0)
     
    44204424#endif
    44214425
    4422 #ifdef CONFIG_SND_HDA_GENERIC_LEDS
    4423         if (spec->gpio_led)
    4424                 snd_hda_gen_add_mute_led_cdev(codec, stac_vmaster_hook);
    4425 #endif
    44264426        if (spec->aloopback_ctl &&
    44274427            snd_hda_get_bool_hint(codec, "loopback") == 1) {
  • GPL/trunk/alsa-kernel/pci/hda/thinkpad_helper.c

    r679 r695  
    1919                                    const struct hda_fixup *fix, int action)
    2020{
    21         if (action == HDA_FIXUP_ACT_PROBE) {
     21        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
    2222                if (!is_thinkpad(codec))
    2323                        return;
  • GPL/trunk/alsa-kernel/pci/intel8x0.c

    r689 r695  
    3131MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; SiS 7012; Ali 5455");
    3232MODULE_LICENSE("GPL");
    33 MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
    34                 "{Intel,82901AB-ICH0},"
    35                 "{Intel,82801BA-ICH2},"
    36                 "{Intel,82801CA-ICH3},"
    37                 "{Intel,82801DB-ICH4},"
    38                 "{Intel,ICH5},"
    39                 "{Intel,ICH6},"
    40                 "{Intel,ICH7},"
    41                 "{Intel,6300ESB},"
    42                 "{Intel,ESB2},"
    43                 "{Intel,MX440},"
    44                 "{SiS,SI7012},"
    45                 "{NVidia,nForce Audio},"
    46                 "{NVidia,nForce2 Audio},"
    47                 "{NVidia,nForce3 Audio},"
    48                 "{NVidia,MCP04},"
    49                 "{NVidia,MCP501},"
    50                 "{NVidia,CK804},"
    51                 "{NVidia,CK8},"
    52                 "{NVidia,CK8S},"
    53                 "{AMD,AMD768},"
    54                 "{AMD,AMD8111},"
    55                 "{ALI,M5455}}");
    5633
    5734static int index = SNDRV_DEFAULT_IDX1;  /* Index 0-MAX */
  • GPL/trunk/alsa-kernel/pci/intel8x0m.c

    r679 r695  
    2626                   "SiS 7013; NVidia MCP/2/2S/3 modems");
    2727MODULE_LICENSE("GPL");
    28 MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
    29                 "{Intel,82901AB-ICH0},"
    30                 "{Intel,82801BA-ICH2},"
    31                 "{Intel,82801CA-ICH3},"
    32                 "{Intel,82801DB-ICH4},"
    33                 "{Intel,ICH5},"
    34                 "{Intel,ICH6},"
    35                 "{Intel,ICH7},"
    36                 "{Intel,MX440},"
    37                 "{SiS,7013},"
    38                 "{NVidia,NForce Modem},"
    39                 "{NVidia,NForce2 Modem},"
    40                 "{NVidia,NForce2s Modem},"
    41                 "{NVidia,NForce3 Modem},"
    42                 "{AMD,AMD768}}");
    4328
    4429static int index = -2; /* Exclude the first card */
     
    11301115        else
    11311116                chip->bmaddr = pci_iomap(pci, 1, 0);
     1117
     1118port_inited:
    11321119        if (!chip->bmaddr) {
    11331120                dev_err(card->dev, "Controller space ioremap problem\n");
     
    11361123        }
    11371124
    1138  port_inited:
    11391125        /* initialize offsets */
    11401126        chip->bdbars_count = 2;
  • GPL/trunk/alsa-kernel/pci/korg1212/korg1212.c

    r679 r695  
    389389MODULE_DESCRIPTION("korg1212");
    390390MODULE_LICENSE("GPL");
    391 MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}");
    392391MODULE_FIRMWARE("korg/k1212.dsp");
    393392
  • GPL/trunk/alsa-kernel/pci/maestro3.c

    r679 r695  
    4343MODULE_DESCRIPTION("ESS Maestro3 PCI");
    4444MODULE_LICENSE("GPL");
    45 MODULE_SUPPORTED_DEVICE("{{ESS,Maestro3 PCI},"
    46                 "{ESS,ES1988},"
    47                 "{ESS,Allegro PCI},"
    48                 "{ESS,Allegro-1 PCI},"
    49                 "{ESS,Canyon3D-2/LE PCI}}");
    5045MODULE_FIRMWARE("ess/maestro3_assp_kernel.fw");
    5146MODULE_FIRMWARE("ess/maestro3_assp_minisrc.fw");
     
    12531248
    12541249        /* set up dac/adc rate */
     1250#ifndef TARGET_OS2
     1251        freq = DIV_ROUND_CLOSEST(runtime->rate << 15, 48000);
     1252#else
    12551253        freq = ((runtime->rate << 15) + 24000 ) / 48000;
     1254#endif
    12561255        if (freq)
    12571256                freq--;
     
    25402539
    25412540        /* check, if we can restrict PCI DMA transfers to 28 bits */
    2542         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
    2543             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
     2541        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
    25442542                dev_err(card->dev,
    25452543                        "architecture does not support 28bit PCI busmaster DMA\n");
  • GPL/trunk/alsa-kernel/pci/nm256/nm256.c

    r679 r695  
    3737MODULE_DESCRIPTION("NeoMagic NM256AV/ZX");
    3838MODULE_LICENSE("GPL");
    39 MODULE_SUPPORTED_DEVICE("{{NeoMagic,NM256AV},"
    40                 "{NeoMagic,NM256ZX}}");
    4139
    4240/*
  • GPL/trunk/alsa-kernel/pci/rme32.c

    r679 r695  
    8989MODULE_DESCRIPTION("RME Digi32, Digi32/8, Digi32 PRO");
    9090MODULE_LICENSE("GPL");
    91 MODULE_SUPPORTED_DEVICE("{{RME,Digi32}," "{RME,Digi32/8}," "{RME,Digi32 PRO}}");
    9291
    9392/* Defines for RME Digi32 series */
     
    469468                default:
    470469                        return -1;
    471                         break;
    472470                }
    473471        else
  • GPL/trunk/alsa-kernel/pci/rme96.c

    r679 r695  
    3232                   "Digi96/8 PAD");
    3333MODULE_LICENSE("GPL");
    34 MODULE_SUPPORTED_DEVICE("{{RME,Digi96},"
    35                 "{RME,Digi96/8},"
    36                 "{RME,Digi96/8 PRO},"
    37                 "{RME,Digi96/8 PST},"
    38                 "{RME,Digi96/8 PAD}}");
    3934
    4035static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
  • GPL/trunk/alsa-kernel/pci/rme9652/hdsp.c

    r689 r695  
    4545MODULE_DESCRIPTION("RME Hammerfall DSP");
    4646MODULE_LICENSE("GPL");
    47 MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
    48                 "{RME HDSP-9652},"
    49                 "{RME HDSP-9632}}");
    5047MODULE_FIRMWARE("rpm_firmware.bin");
    5148MODULE_FIRMWARE("multiface_firmware.bin");
     
    470467        unsigned char         ds_out_channels;
    471468        unsigned char         ss_out_channels;
     469        u32                   io_loopback;          /* output loopback channel states*/
    472470
    473471        struct snd_dma_buffer capture_dma_buf;
     
    32543252static struct snd_kcontrol_new snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK;
    32553253
     3254
     3255static bool hdsp_loopback_get(struct hdsp *const hdsp, const u8 channel)
     3256{
     3257        return hdsp->io_loopback & (1 << channel);
     3258}
     3259
     3260static int hdsp_loopback_set(struct hdsp *const hdsp, const u8 channel, const bool enable)
     3261{
     3262        if (hdsp_loopback_get(hdsp, channel) == enable)
     3263                return 0;
     3264
     3265        hdsp->io_loopback ^= (1 << channel);
     3266
     3267        hdsp_write(hdsp, HDSP_inputEnable + (4 * (hdsp->max_channels + channel)), enable);
     3268
     3269        return 1;
     3270}
     3271
     3272static int snd_hdsp_loopback_get(struct snd_kcontrol *const kcontrol,
     3273                                 struct snd_ctl_elem_value *const ucontrol)
     3274{
     3275        struct hdsp *const hdsp = snd_kcontrol_chip(kcontrol);
     3276        const u8 channel = snd_ctl_get_ioff(kcontrol, &ucontrol->id);
     3277
     3278        if (channel >= hdsp->max_channels)
     3279                return -ENOENT;
     3280
     3281        ucontrol->value.integer.value[0] = hdsp_loopback_get(hdsp, channel);
     3282
     3283        return 0;
     3284}
     3285
     3286static int snd_hdsp_loopback_put(struct snd_kcontrol *const kcontrol,
     3287                                 struct snd_ctl_elem_value *const ucontrol)
     3288{
     3289        struct hdsp *const hdsp = snd_kcontrol_chip(kcontrol);
     3290        const u8 channel = snd_ctl_get_ioff(kcontrol, &ucontrol->id);
     3291        const bool enable = ucontrol->value.integer.value[0] & 1;
     3292
     3293        if (channel >= hdsp->max_channels)
     3294                return -ENOENT;
     3295
     3296        return hdsp_loopback_set(hdsp, channel, enable);
     3297}
     3298
     3299static struct snd_kcontrol_new snd_hdsp_loopback_control = {
     3300        .iface = SNDRV_CTL_ELEM_IFACE_HWDEP,
     3301        .name = "Output Loopback",
     3302        .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
     3303        .info = snd_ctl_boolean_mono_info,
     3304        .get = snd_hdsp_loopback_get,
     3305        .put = snd_hdsp_loopback_put
     3306};
     3307
    32563308static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)
    32573309{
     
    32963348                                return err;
    32973349                }
     3350        }
     3351
     3352        /* Output loopback controls for H9632 cards */
     3353        if (hdsp->io_type == H9632) {
     3354                snd_hdsp_loopback_control.count = hdsp->max_channels;
     3355                kctl = snd_ctl_new1(&snd_hdsp_loopback_control, hdsp);
     3356                if (kctl == NULL)
     3357                        return -ENOMEM;
     3358                err = snd_ctl_add(card, kctl);
     3359                if (err < 0)
     3360                        return err;
    32983361        }
    32993362
     
    49575020static void snd_hdsp_initialize_channels(struct hdsp *hdsp)
    49585021{
    4959         int status, aebi_channels, aebo_channels;
     5022        int status, aebi_channels, aebo_channels, i;
    49605023
    49615024        switch (hdsp->io_type) {
     
    49845047                hdsp->ds_out_channels = H9632_DS_CHANNELS+aebo_channels;
    49855048                hdsp->qs_out_channels = H9632_QS_CHANNELS+aebo_channels;
     5049                /* Disable loopback of output channels, as the set function
     5050                 * only sets on a change we fake all bits (channels) as enabled.
     5051                 */
     5052                hdsp->io_loopback = 0xffffffff;
     5053                for (i = 0; i < hdsp->max_channels; ++i)
     5054                        hdsp_loopback_set(hdsp, i, false);
    49865055                break;
    49875056
  • GPL/trunk/alsa-kernel/pci/rme9652/hdspm.c

    r689 r695  
    166166MODULE_DESCRIPTION("RME HDSPM");
    167167MODULE_LICENSE("GPL");
    168 MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
    169168
    170169/* --- Write registers. ---
     
    22872286                status = hdspm_read(hdspm, HDSPM_RD_STATUS_1);
    22882287                return (status >> 16) & 0xF;
    2289                 break;
    22902288        case AES32:
    22912289                status = hdspm_read(hdspm, HDSPM_statusRegister);
     
    23132311                        status = hdspm_read(hdspm, HDSPM_RD_STATUS_1);
    23142312                        return (status >> 20) & 0xF;
    2315                         break;
    23162313                case AES32:
    23172314                        status = hdspm_read(hdspm, HDSPM_statusRegister);
     
    23392336                        status = hdspm_read(hdspm, HDSPM_RD_STATUS_2);
    23402337                        return (status >> 12) & 0xF;
    2341                         break;
    23422338                default:
    23432339                        break;
     
    23592355                timecode = hdspm_read(hdspm, HDSPM_timecodeRegister);
    23602356                return (timecode >> (4*index)) & 0xF;
    2361                 break;
    23622357        default:
    23632358                break;
     
    38463841                }
    38473842                return 0;
    3848                 break;
    38493843
    38503844        case MADI:
     
    38573851                }
    38583852                return 0;
    3859                 break;
    38603853
    38613854        case RayDAT:
     
    38683861                        return 1;
    38693862                return 0;
    3870 
    3871                 break;
    38723863
    38733864        case MADIface:
     
    63226313                        /* TODO: Mac driver sets it when f_s>48kHz */
    63236314                        status.card_specific.madi.frame_format = 0;
     6315                        break;
    63246316
    63256317                default:
     
    63376329
    63386330                hdspm_version.card_type = hdspm->io_type;
    6339                 strlcpy(hdspm_version.cardname, hdspm->card_name,
     6331                strscpy(hdspm_version.cardname, hdspm->card_name,
    63406332                                sizeof(hdspm_version.cardname));
    63416333                hdspm_version.serial = hdspm->serial;
  • GPL/trunk/alsa-kernel/pci/rme9652/rme9652.c

    r689 r695  
    4040MODULE_DESCRIPTION("RME Digi9652/Digi9636");
    4141MODULE_LICENSE("GPL");
    42 MODULE_SUPPORTED_DEVICE("{{RME,Hammerfall},"
    43                 "{RME,Hammerfall-Light}}");
    4442
    4543/* The Hammerfall has two sets of 24 ADAT + 2 S/PDIF channels, one for
     
    733731        case 0x7:
    734732                return 32000;
    735                 break;
    736733
    737734        case 0x6:
    738735                return 44100;
    739                 break;
    740736
    741737        case 0x5:
    742738                return 48000;
    743                 break;
    744739
    745740        case 0x4:
    746741                return 88200;
    747                 break;
    748742
    749743        case 0x3:
    750744                return 96000;
    751                 break;
    752745
    753746        case 0x0:
    754747                return 64000;
    755                 break;
    756748
    757749        default:
     
    760752                           s->card_name, rate_bits);
    761753                return 0;
    762                 break;
    763754        }
    764755}
  • GPL/trunk/alsa-kernel/pci/sis7019.c

    r679 r695  
    2525MODULE_DESCRIPTION("SiS7019");
    2626MODULE_LICENSE("GPL");
    27 MODULE_SUPPORTED_DEVICE("{{SiS,SiS7019 Audio Accelerator}}");
    2827
    2928static int index = SNDRV_DEFAULT_IDX1;  /* Index 0-MAX */
     
    364363                delta = 0x1000;
    365364        else
    366                 delta = (((rate << 12) + 24000) / 48000) & 0x0000ffff;
     365                delta = DIV_ROUND_CLOSEST(rate << 12, 48000) & 0x0000ffff;
    367366        return delta;
    368367}
  • GPL/trunk/alsa-kernel/pci/sonicvibes.c

    r679 r695  
    3030MODULE_DESCRIPTION("S3 SonicVibes PCI");
    3131MODULE_LICENSE("GPL");
    32 MODULE_SUPPORTED_DEVICE("{{S3,SonicVibes PCI}}");
    3332
    3433#if IS_REACHABLE(CONFIG_GAMEPORT)
     
    571570        unsigned long flags;
    572571
    573         div = (rate * 65536 + SV_FULLRATE / 2) / SV_FULLRATE;
     572        div = DIV_ROUND_CLOSEST(rate * 65536, SV_FULLRATE);
    574573        if (div > 65535)
    575574                div = 65535;
     
    12311230                return err;
    12321231        /* check, if we can restrict PCI DMA transfers to 24 bits */
    1233         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
    1234             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
     1232        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
    12351233                dev_err(card->dev,
    12361234                        "architecture does not support 24bit PCI busmaster DMA\n");
  • GPL/trunk/alsa-kernel/pci/trident/trident.c

    r679 r695  
    2222MODULE_DESCRIPTION("Trident 4D-WaveDX/NX & SiS SI7018");
    2323MODULE_LICENSE("GPL");
    24 MODULE_SUPPORTED_DEVICE("{{Trident,4DWave DX},"
    25                 "{Trident,4DWave NX},"
    26                 "{SiS,SI7018 PCI Audio},"
    27                 "{Best Union,Miss Melody 4DWave PCI},"
    28                 "{HIS,4DWave PCI},"
    29                 "{Warpspeed,ONSpeed 4DWave PCI},"
    30                 "{Aztech Systems,PCI 64-Q3D},"
    31                 "{Addonics,SV 750},"
    32                 "{CHIC,True Sound 4Dwave},"
    33                 "{Shark,Predator4D-PCI},"
    34                 "{Jaton,SonicWave 4D},"
    35                 "{Hoontech,SoundTrack Digital 4DWave NX}}");
    3624
    3725static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
  • GPL/trunk/alsa-kernel/pci/trident/trident_main.c

    r679 r695  
    683683                delta = 0x1000;
    684684        else
     685#ifndef TARGET_OS2
     686                delta = DIV_ROUND_CLOSEST(rate << 12, 48000) & 0x0000ffff;
     687#else
    685688                delta = (((rate << 12) + 24000) / 48000) & 0x0000ffff;
     689#endif
    686690        return delta;
    687691}
     
    10391043
    10401044        // Set channel sample rate, 4.12 format
     1045#ifndef TARGET_OS2
     1046        val = DIV_ROUND_CLOSEST(48000U << 12, runtime->rate);
     1047#else
    10411048        val = (((unsigned int) 48000L << 12) + (runtime->rate/2)) / runtime->rate;
     1049#endif
    10421050        outw(val, TRID_REG(trident, T4D_SBDELTA_DELTA_R));
    10431051
     
    35023510                return err;
    35033511        /* check, if we can restrict PCI DMA transfers to 30 bits */
    3504         if (dma_set_mask(&pci->dev, DMA_BIT_MASK(30)) < 0 ||
    3505             dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(30)) < 0) {
     3512        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(30))) {
    35063513                dev_err(card->dev,
    35073514                        "architecture does not support 30bit PCI busmaster DMA\n");
  • GPL/trunk/alsa-kernel/pci/via82xx.c

    r679 r695  
    6161MODULE_DESCRIPTION("VIA VT82xx audio");
    6262MODULE_LICENSE("GPL");
    63 MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C,pci},{VIA,VT8233A/C,8235}}");
    6463
    6564#if IS_REACHABLE(CONFIG_GAMEPORT)
  • GPL/trunk/alsa-kernel/pci/via82xx_modem.c

    r679 r695  
    3939MODULE_DESCRIPTION("VIA VT82xx modem");
    4040MODULE_LICENSE("GPL");
    41 MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C modem,pci}}");
    4241
    4342static int index = -2; /* Exclude the first card */
  • GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci.c

    r679 r695  
    2222MODULE_DESCRIPTION("Yamaha DS-1 PCI");
    2323MODULE_LICENSE("GPL");
    24 MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF724},"
    25                 "{Yamaha,YMF724F},"
    26                 "{Yamaha,YMF740},"
    27                 "{Yamaha,YMF740C},"
    28                 "{Yamaha,YMF744},"
    29                 "{Yamaha,YMF754}}");
    3024
    3125static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
Note: See TracChangeset for help on using the changeset viewer.