Changeset 679 for GPL/trunk/alsa-kernel/pci/cs5535audio/cs5535audio.c
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/cs5535audio/cs5535audio.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Driver for audio on multifunction CS5535/6 companion device … … 5 6 * Based on Jaroslav Kysela and Takashi Iwai's examples. 6 7 * This work was sponsored by CIS(M) Sdn Bhd. 7 *8 * This program is free software; you can redistribute it and/or modify9 * it under the terms of the GNU General Public License as published by10 * the Free Software Foundation; either version 2 of the License, or11 * (at your option) any later version.12 *13 * This program is distributed in the hope that it will be useful,14 * but WITHOUT ANY WARRANTY; without even the implied warranty of15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 * GNU General Public License for more details.17 *18 * You should have received a copy of the GNU General Public License19 * along with this program; if not, write to the Free Software20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA21 *22 8 */ 23 9 … … 27 13 #include <linux/pci.h> 28 14 #include <linux/slab.h> 29 #include <linux/module param.h>30 #include < asm/io.h>15 #include <linux/module.h> 16 #include <linux/io.h> 31 17 #include <sound/core.h> 32 18 #include <sound/control.h> … … 39 25 40 26 #define DRIVER_NAME "cs5535audio" 27 #ifdef TARGET_OS2 28 #define KBUILD_MODNAME DRIVER_NAME 29 #include <linux/dma-mapping.h> 30 #endif 41 31 42 32 static char *ac97_quirk; … … 44 34 MODULE_PARM_DESC(ac97_quirk, "AC'97 board specific workarounds."); 45 35 46 static struct ac97_quirk ac97_quirks[] __devinitdata= {36 static const struct ac97_quirk ac97_quirks[] = { 47 37 #if 0 /* Not yet confirmed if all 5536 boards are HP only */ 48 38 { … … 58 48 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 59 49 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 60 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;50 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 61 51 62 52 module_param_array(index, int, NULL, 0444); … … 67 57 MODULE_PARM_DESC(enable, "Enable " DRIVER_NAME); 68 58 69 static DEFINE_PCI_DEVICE_TABLE(snd_cs5535audio_ids)= {59 static const struct pci_device_id snd_cs5535audio_ids[] = { 70 60 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) }, 71 61 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) }, … … 85 75 } while (--timeout); 86 76 if (!timeout) 87 snd_printk(KERN_ERR "Failure writing to cs5535 codec\n"); 77 dev_err(cs5535au->card->dev, 78 "Failure writing to cs5535 codec\n"); 88 79 } 89 80 … … 110 101 } while (--timeout); 111 102 if (!timeout) 112 snd_printk(KERN_ERR "Failure reading codec reg 0x%x," 113 "Last value=0x%x\n", reg, val); 103 dev_err(cs5535au->card->dev, 104 "Failure reading codec reg 0x%x, Last value=0x%x\n", 105 reg, val); 114 106 115 107 return (unsigned short) val; … … 145 137 } 146 138 147 static int __devinitsnd_cs5535audio_mixer(struct cs5535audio *cs5535au)139 static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au) 148 140 { 149 141 struct snd_card *card = cs5535au->card; … … 151 143 struct snd_ac97_template ac97; 152 144 int err; 153 static struct snd_ac97_bus_ops ops = {145 static const struct snd_ac97_bus_ops ops = { 154 146 .write = snd_cs5535audio_ac97_codec_write, 155 147 .read = snd_cs5535audio_ac97_codec_read, … … 169 161 170 162 if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) { 171 snd_printk(KERN_ERR"mixer failed\n");163 dev_err(card->dev, "mixer failed\n"); 172 164 return err; 173 165 } … … 177 169 err = olpc_quirks(card, cs5535au->ac97); 178 170 if (err < 0) { 179 snd_printk(KERN_ERR"olpc quirks failed\n");171 dev_err(card->dev, "olpc quirks failed\n"); 180 172 return err; 181 173 } … … 191 183 spin_unlock(&cs5535au->reg_lock); 192 184 if (bm_stat & EOP) { 193 struct cs5535audio_dma *dma;194 dma = cs5535au->playback_substream->runtime->private_data;195 185 snd_pcm_period_elapsed(cs5535au->playback_substream); 196 186 } else { 197 snd_printk(KERN_ERR "unexpected bm0 irq src, bm_stat=%x\n", 198 bm_stat); 187 dev_err(cs5535au->card->dev, 188 "unexpected bm0 irq src, bm_stat=%x\n", 189 bm_stat); 199 190 } 200 191 } … … 206 197 bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS); 207 198 spin_unlock(&cs5535au->reg_lock); 208 if (bm_stat & EOP) { 209 struct cs5535audio_dma *dma; 210 dma = cs5535au->capture_substream->runtime->private_data; 199 if (bm_stat & EOP) 211 200 snd_pcm_period_elapsed(cs5535au->capture_substream); 212 }213 201 } 214 202 … … 242 230 break; 243 231 default: 244 snd_printk(KERN_ERR "Unexpected irq src: " 245 "0x%x\n", acc_irq_stat); 232 dev_err(cs5535au->card->dev, 233 "Unexpected irq src: 0x%x\n", 234 acc_irq_stat); 246 235 break; 247 236 } … … 253 242 static int snd_cs5535audio_free(struct cs5535audio *cs5535au) 254 243 { 255 synchronize_irq(cs5535au->irq); 256 pci_set_power_state(cs5535au->pci, 3); 244 pci_set_power_state(cs5535au->pci, PCI_D3hot); 257 245 258 246 if (cs5535au->irq >= 0) … … 271 259 } 272 260 273 static int __devinitsnd_cs5535audio_create(struct snd_card *card,274 275 261 static int snd_cs5535audio_create(struct snd_card *card, 262 struct pci_dev *pci, 263 struct cs5535audio **rcs5535au) 276 264 { 277 265 struct cs5535audio *cs5535au; 278 266 279 267 int err; 280 static struct snd_device_ops ops = {268 static const struct snd_device_ops ops = { 281 269 .dev_free = snd_cs5535audio_dev_free, 282 270 }; … … 286 274 return err; 287 275 288 if ( pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||289 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {290 printk(KERN_WARNING"unable to get 32bit dma\n");276 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 || 277 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) { 278 dev_warn(card->dev, "unable to get 32bit dma\n"); 291 279 err = -ENXIO; 292 280 goto pcifail; … … 312 300 313 301 if (request_irq(pci->irq, snd_cs5535audio_interrupt, 314 IRQF_SHARED, "CS5535 Audio", cs5535au)) {315 snd_printk(KERN_ERR"unable to grab IRQ %d\n", pci->irq);302 IRQF_SHARED, KBUILD_MODNAME, cs5535au)) { 303 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 316 304 err = -EBUSY; 317 305 goto sndfail; … … 319 307 320 308 cs5535au->irq = pci->irq; 309 card->sync_irq = cs5535au->irq; 321 310 pci_set_master(pci); 322 311 … … 325 314 goto sndfail; 326 315 327 snd_card_set_dev(card, &pci->dev);328 329 316 *rcs5535au = cs5535au; 330 317 return 0; … … 339 326 } 340 327 341 static int __devinitsnd_cs5535audio_probe(struct pci_dev *pci,342 328 static int snd_cs5535audio_probe(struct pci_dev *pci, 329 const struct pci_device_id *pci_id) 343 330 { 344 331 static int dev; … … 354 341 } 355 342 356 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 343 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 344 0, &card); 357 345 if (err < 0) 358 346 return err; … … 388 376 } 389 377 390 static void __devexitsnd_cs5535audio_remove(struct pci_dev *pci)378 static void snd_cs5535audio_remove(struct pci_dev *pci) 391 379 { 392 380 olpc_quirks_cleanup(); 393 381 snd_card_free(pci_get_drvdata(pci)); 394 pci_set_drvdata(pci, NULL); 395 } 396 397 static struct pci_driver driver = { 398 .name = DRIVER_NAME, 382 } 383 384 static struct pci_driver cs5535audio_driver = { 385 .name = KBUILD_MODNAME, 399 386 .id_table = snd_cs5535audio_ids, 400 387 .probe = snd_cs5535audio_probe, 401 .remove = __devexit_p(snd_cs5535audio_remove), 402 #ifdef CONFIG_PM 403 .suspend = snd_cs5535audio_suspend, 404 .resume = snd_cs5535audio_resume, 388 .remove = snd_cs5535audio_remove, 389 #ifdef CONFIG_PM_SLEEP 390 .driver = { 391 .pm = &snd_cs5535audio_pm, 392 }, 405 393 #endif 406 394 }; 407 395 408 static int __init alsa_card_cs5535audio_init(void) 409 { 410 return pci_register_driver(&driver); 411 } 412 413 static void __exit alsa_card_cs5535audio_exit(void) 414 { 415 pci_unregister_driver(&driver); 416 } 417 418 module_init(alsa_card_cs5535audio_init) 419 module_exit(alsa_card_cs5535audio_exit) 396 module_pci_driver(cs5535audio_driver); 420 397 421 398 MODULE_AUTHOR("Jaya Kumar");
Note:
See TracChangeset
for help on using the changeset viewer.