Ignore:
Timestamp:
Apr 19, 2025, 8:08:37 PM (6 months ago)
Author:
David Azarewicz
Message:

Merge in changes from 6.6-LTS branch.
Fixed additional 25+ problems.

Location:
GPL/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci.c

    r717 r772  
    103103                case 0x205: legacy_ctrl2 |= 3 << 6; break;
    104104                default:
    105                         dev_err(chip->card->dev,
    106                                 "invalid joystick port %#x", io_port);
     105                        if (io_port > 0)
     106                                dev_err(chip->card->dev,
     107                                        "The %s does not support arbitrary IO ports for the game port (requested 0x%x)\n",
     108                                        chip->card->shortname, (unsigned int)io_port);
    107109                        return -EINVAL;
    108110                }
     
    155157#endif /* SUPPORT_JOYSTICK */
    156158
    157 static int snd_card_ymfpci_probe(struct pci_dev *pci,
    158                                  const struct pci_device_id *pci_id)
     159static int __snd_card_ymfpci_probe(struct pci_dev *pci,
     160                                   const struct pci_device_id *pci_id)
    159161{
    160162        static int dev;
     
    175177        }
    176178
    177         err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
     179        err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
    178180                           sizeof(*chip), &card);
    179181        if (err < 0)
     
    191193        }
    192194
     195        strcpy(card->driver, str);
     196        sprintf(card->shortname, "Yamaha %s (%s)", model, str);
     197        sprintf(card->longname, "%s at 0x%lx, irq %i",
     198                card->shortname,
     199                chip->reg_area_phys,
     200                chip->irq);
     201
    193202        legacy_ctrl = 0;
    194203        legacy_ctrl2 = 0x0800;  /* SBEN = 0, SMOD = 01, LAD = 0 */
     
    223232                case 0x3a0: legacy_ctrl2 |= 2; break;
    224233                case 0x3a8: legacy_ctrl2 |= 3; break;
    225                 default: fm_port[dev] = 0; break;
     234                default:
     235                        if (fm_port[dev] > 0)
     236                                dev_err(card->dev,
     237                                        "The %s does not support arbitrary IO ports for FM (requested 0x%x)\n",
     238                                        card->shortname, (unsigned int)fm_port[dev]);
     239                        fm_port[dev] = 0;
     240                        break;
    226241                }
    227242                if (fm_port[dev] > 0)
     
    239254                case 0x332: legacy_ctrl2 |= 2 << 4; break;
    240255                case 0x334: legacy_ctrl2 |= 3 << 4; break;
    241                 default: mpu_port[dev] = 0; break;
     256                default:
     257                        if (mpu_port[dev] > 0)
     258                                dev_err(card->dev,
     259                                        "The %s does not support arbitrary IO ports for MPU-401 (requested 0x%x)\n",
     260                                        card->shortname, (unsigned int)mpu_port[dev]);
     261                        mpu_port[dev] = 0;
     262                        break;
    242263                }
    243264                if (mpu_port[dev] > 0)
     
    262283                return err;
    263284
    264         strcpy(card->driver, str);
    265         sprintf(card->shortname, "Yamaha %s (%s)", model, str);
    266         sprintf(card->longname, "%s at 0x%lx, irq %i",
    267                 card->shortname,
    268                 chip->reg_area_phys,
    269                 chip->irq);
    270285        err = snd_ymfpci_pcm(chip, 0);
    271286        if (err < 0)
     
    338353}
    339354
     355static int snd_card_ymfpci_probe(struct pci_dev *pci,
     356                                 const struct pci_device_id *pci_id)
     357{
     358        return snd_card_free_on_error(&pci->dev, __snd_card_ymfpci_probe(pci, pci_id));
     359}
     360
    340361static struct pci_driver ymfpci_driver = {
    341362        .name = KBUILD_MODNAME,
    342363        .id_table = snd_ymfpci_ids,
    343364        .probe = snd_card_ymfpci_probe,
    344 #ifdef CONFIG_PM_SLEEP
    345365        .driver = {
    346                 .pm = &snd_ymfpci_pm,
     366                .pm = pm_sleep_ptr(&snd_ymfpci_pm),
    347367        },
    348 #endif
    349368};
    350369
  • GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci.h

    r717 r772  
    269269};
    270270
     271static const int saved_regs_index[] = {
     272        /* spdif */
     273        YDSXGR_SPDIFOUTCTRL,
     274        YDSXGR_SPDIFOUTSTATUS,
     275        YDSXGR_SPDIFINCTRL,
     276        /* volumes */
     277        YDSXGR_PRIADCLOOPVOL,
     278        YDSXGR_NATIVEDACINVOL,
     279        YDSXGR_NATIVEDACOUTVOL,
     280        YDSXGR_BUF441OUTVOL,
     281        YDSXGR_NATIVEADCINVOL,
     282        YDSXGR_SPDIFLOOPVOL,
     283        YDSXGR_SPDIFOUTVOL,
     284        YDSXGR_ZVOUTVOL,
     285        YDSXGR_LEGACYOUTVOL,
     286        /* address bases */
     287        YDSXGR_PLAYCTRLBASE,
     288        YDSXGR_RECCTRLBASE,
     289        YDSXGR_EFFCTRLBASE,
     290        YDSXGR_WORKBASE,
     291        /* capture set up */
     292        YDSXGR_MAPOFREC,
     293        YDSXGR_RECFORMAT,
     294        YDSXGR_RECSLOTSR,
     295        YDSXGR_ADCFORMAT,
     296        YDSXGR_ADCSLOTSR,
     297};
     298#define YDSXGR_NUM_SAVED_REGS   ARRAY_SIZE(saved_regs_index)
     299
     300static const int pci_saved_regs_index[] = {
     301        /* All Chips */
     302        PCIR_DSXG_LEGACY,
     303        PCIR_DSXG_ELEGACY,
     304        /* YMF 744/754 */
     305        PCIR_DSXG_FMBASE,
     306        PCIR_DSXG_SBBASE,
     307        PCIR_DSXG_MPU401BASE,
     308        PCIR_DSXG_JOYBASE,
     309};
     310#define DSXG_PCI_NUM_SAVED_REGS ARRAY_SIZE(pci_saved_regs_index)
     311#define DSXG_PCI_NUM_SAVED_LEGACY_REGS  2
     312#ifndef TARGET_OS2
     313static_assert(DSXG_PCI_NUM_SAVED_LEGACY_REGS <= DSXG_PCI_NUM_SAVED_REGS);
     314#endif
     315
    271316struct snd_ymfpci {
    272317        int irq;
     
    277322        void __iomem *reg_area_virt;
    278323
    279         unsigned short old_legacy_ctrl;
     324        u16 old_legacy_ctrl;
    280325#ifdef SUPPORT_JOYSTICK
    281326        struct gameport *gameport;
     
    346391        const struct firmware *controller_microcode;
    347392
    348 #ifdef CONFIG_PM_SLEEP
    349         u32 *saved_regs;
     393        u32 saved_regs[YDSXGR_NUM_SAVED_REGS];
    350394        u32 saved_ydsxgr_mode;
    351         u16 saved_dsxg_legacy;
    352         u16 saved_dsxg_elegacy;
    353 #endif
     395        u16 saved_dsxg_pci_regs[DSXG_PCI_NUM_SAVED_REGS];
    354396};
    355397
    356398int snd_ymfpci_create(struct snd_card *card,
    357399                      struct pci_dev *pci,
    358                       unsigned short old_legacy_ctrl);
     400                      u16 old_legacy_ctrl);
    359401void snd_ymfpci_free_gameport(struct snd_ymfpci *chip);
    360402
  • GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci_main.c

    r717 r772  
    3535
    3636static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip);
    37 
    38 static inline u8 snd_ymfpci_readb(struct snd_ymfpci *chip, u32 offset)
    39 {
    40         return readb(chip->reg_area_virt + offset);
    41 }
    4237
    4338static inline void snd_ymfpci_writeb(struct snd_ymfpci *chip, u32 offset, u8 val)
     
    18321827                return -ENXIO;
    18331828        kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip);
     1829        kctl->id.device = chip->pcm_spdif->device;
    18341830        err = snd_ctl_add(chip->card, kctl);
    18351831        if (err < 0)
    18361832                return err;
     1833        kctl = snd_ctl_new1(&snd_ymfpci_spdif_mask, chip);
    18371834        kctl->id.device = chip->pcm_spdif->device;
    1838         kctl = snd_ctl_new1(&snd_ymfpci_spdif_mask, chip);
    18391835        err = snd_ctl_add(chip->card, kctl);
    18401836        if (err < 0)
    18411837                return err;
     1838        kctl = snd_ctl_new1(&snd_ymfpci_spdif_stream, chip);
    18421839        kctl->id.device = chip->pcm_spdif->device;
    1843         kctl = snd_ctl_new1(&snd_ymfpci_spdif_stream, chip);
    18441840        err = snd_ctl_add(chip->card, kctl);
    18451841        if (err < 0)
    18461842                return err;
    1847         kctl->id.device = chip->pcm_spdif->device;
    18481843        chip->spdif_pcm_ctl = kctl;
    18491844
     
    21702165        chip->work_base_addr = ptr_addr;
    21712166       
    2172         snd_BUG_ON(ptr + chip->work_size !=
     2167        snd_BUG_ON(ptr + PAGE_ALIGN(chip->work_size) !=
    21732168                   chip->work_ptr->area + chip->work_ptr->bytes);
    21742169
     
    22242219        snd_ymfpci_free_gameport(chip);
    22252220       
    2226         pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
     2221        pci_write_config_word(chip->pci, PCIR_DSXG_LEGACY, chip->old_legacy_ctrl);
    22272222       
    22282223        release_firmware(chip->dsp_microcode);
     
    22302225}
    22312226
    2232 #ifdef CONFIG_PM_SLEEP
    2233 static const int saved_regs_index[] = {
    2234         /* spdif */
    2235         YDSXGR_SPDIFOUTCTRL,
    2236         YDSXGR_SPDIFOUTSTATUS,
    2237         YDSXGR_SPDIFINCTRL,
    2238         /* volumes */
    2239         YDSXGR_PRIADCLOOPVOL,
    2240         YDSXGR_NATIVEDACINVOL,
    2241         YDSXGR_NATIVEDACOUTVOL,
    2242         YDSXGR_BUF441OUTVOL,
    2243         YDSXGR_NATIVEADCINVOL,
    2244         YDSXGR_SPDIFLOOPVOL,
    2245         YDSXGR_SPDIFOUTVOL,
    2246         YDSXGR_ZVOUTVOL,
    2247         YDSXGR_LEGACYOUTVOL,
    2248         /* address bases */
    2249         YDSXGR_PLAYCTRLBASE,
    2250         YDSXGR_RECCTRLBASE,
    2251         YDSXGR_EFFCTRLBASE,
    2252         YDSXGR_WORKBASE,
    2253         /* capture set up */
    2254         YDSXGR_MAPOFREC,
    2255         YDSXGR_RECFORMAT,
    2256         YDSXGR_RECSLOTSR,
    2257         YDSXGR_ADCFORMAT,
    2258         YDSXGR_ADCSLOTSR,
    2259 };
    2260 #define YDSXGR_NUM_SAVED_REGS   ARRAY_SIZE(saved_regs_index)
    2261 
    22622227static int snd_ymfpci_suspend(struct device *dev)
    22632228{
    22642229        struct snd_card *card = dev_get_drvdata(dev);
    22652230        struct snd_ymfpci *chip = card->private_data;
    2266         unsigned int i;
    2267        
     2231        unsigned int i, legacy_reg_count = DSXG_PCI_NUM_SAVED_LEGACY_REGS;
     2232
     2233        if (chip->pci->device >= 0x0010) /* YMF 744/754 */
     2234                legacy_reg_count = DSXG_PCI_NUM_SAVED_REGS;
     2235
    22682236        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    22692237        snd_ac97_suspend(chip->ac97);
     2238
    22702239        for (i = 0; i < YDSXGR_NUM_SAVED_REGS; i++)
    22712240                chip->saved_regs[i] = snd_ymfpci_readl(chip, saved_regs_index[i]);
     2241
    22722242        chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE);
    2273         pci_read_config_word(chip->pci, PCIR_DSXG_LEGACY,
    2274                              &chip->saved_dsxg_legacy);
    2275         pci_read_config_word(chip->pci, PCIR_DSXG_ELEGACY,
    2276                              &chip->saved_dsxg_elegacy);
     2243
     2244        for (i = 0; i < legacy_reg_count; i++)
     2245                pci_read_config_word(chip->pci, pci_saved_regs_index[i],
     2246                                      chip->saved_dsxg_pci_regs + i);
     2247
    22772248        snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0);
    22782249        snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0);
     
    22862257        struct snd_card *card = dev_get_drvdata(dev);
    22872258        struct snd_ymfpci *chip = card->private_data;
    2288         unsigned int i;
     2259        unsigned int i, legacy_reg_count = DSXG_PCI_NUM_SAVED_LEGACY_REGS;
     2260
     2261        if (chip->pci->device >= 0x0010) /* YMF 744/754 */
     2262                legacy_reg_count = DSXG_PCI_NUM_SAVED_REGS;
    22892263
    22902264        snd_ymfpci_aclink_reset(pci);
     
    22982272        snd_ac97_resume(chip->ac97);
    22992273
    2300         pci_write_config_word(chip->pci, PCIR_DSXG_LEGACY,
    2301                               chip->saved_dsxg_legacy);
    2302         pci_write_config_word(chip->pci, PCIR_DSXG_ELEGACY,
    2303                               chip->saved_dsxg_elegacy);
     2274        for (i = 0; i < legacy_reg_count; i++)
     2275                pci_write_config_word(chip->pci, pci_saved_regs_index[i],
     2276                                      chip->saved_dsxg_pci_regs[i]);
    23042277
    23052278        /* start hw again */
     
    23142287}
    23152288
    2316 SIMPLE_DEV_PM_OPS(snd_ymfpci_pm, snd_ymfpci_suspend, snd_ymfpci_resume);
    2317 #endif /* CONFIG_PM_SLEEP */
     2289DEFINE_SIMPLE_DEV_PM_OPS(snd_ymfpci_pm, snd_ymfpci_suspend, snd_ymfpci_resume);
    23182290
    23192291int snd_ymfpci_create(struct snd_card *card,
    23202292                      struct pci_dev *pci,
    2321                       unsigned short old_legacy_ctrl)
     2293                      u16 old_legacy_ctrl)
    23222294{
    23232295        struct snd_ymfpci *chip = card->private_data;
     
    23842356                return err;
    23852357
    2386 #ifdef CONFIG_PM_SLEEP
    2387         chip->saved_regs = devm_kmalloc_array(&pci->dev, YDSXGR_NUM_SAVED_REGS,
    2388                                               sizeof(u32), GFP_KERNEL);
    2389         if (!chip->saved_regs)
    2390                 return -ENOMEM;
    2391 #endif
    2392 
    23932358        snd_ymfpci_proc_init(card, chip);
    23942359
Note: See TracChangeset for help on using the changeset viewer.