Changeset 679 for GPL/trunk/alsa-kernel/pci/ymfpci
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (5 years ago)
- Location:
- GPL/trunk
- Files:
-
- 3 edited
- 1 copied
-
. (modified) (1 prop)
-
alsa-kernel/pci/ymfpci/ymfpci.c (modified) (17 diffs)
-
alsa-kernel/pci/ymfpci/ymfpci.h (copied) (copied from GPL/branches/uniaud32-next/alsa-kernel/pci/ymfpci/ymfpci.h )
-
alsa-kernel/pci/ymfpci/ymfpci_main.c (modified) (62 diffs)
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/ymfpci/ymfpci.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * The driver for the Yamaha's DS1/DS1E cards 3 4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 4 *5 *6 * This program is free software; you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation; either version 2 of the License, or9 * (at your option) any later version.10 *11 * This program is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 *16 * You should have received a copy of the GNU General Public License17 * along with this program; if not, write to the Free Software18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19 *20 5 */ 21 6 … … 23 8 #include <linux/pci.h> 24 9 #include <linux/time.h> 25 #include <linux/module param.h>10 #include <linux/module.h> 26 11 #include <sound/core.h> 27 #include <sound/ymfpci.h>12 #include "ymfpci.h" 28 13 #include <sound/mpu401.h> 29 14 #include <sound/opl3.h> 30 15 #include <sound/initval.h> 16 17 #ifdef TARGET_OS2 18 #define KBUILD_MODNAME "ymfpci" 19 #endif 31 20 32 21 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); … … 42 31 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 43 32 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 44 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */33 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 45 34 static long fm_port[SNDRV_CARDS]; 46 35 static long mpu_port[SNDRV_CARDS]; … … 48 37 static long joystick_port[SNDRV_CARDS]; 49 38 #endif 50 static intrear_switch[SNDRV_CARDS];39 static bool rear_switch[SNDRV_CARDS]; 51 40 52 41 module_param_array(index, int, NULL, 0444); … … 56 45 module_param_array(enable, bool, NULL, 0444); 57 46 MODULE_PARM_DESC(enable, "Enable Yamaha DS-1 soundcard."); 58 module_param_ array(mpu_port, long, NULL, 0444);47 module_param_hw_array(mpu_port, long, ioport, NULL, 0444); 59 48 MODULE_PARM_DESC(mpu_port, "MPU-401 Port."); 60 module_param_ array(fm_port, long, NULL, 0444);49 module_param_hw_array(fm_port, long, ioport, NULL, 0444); 61 50 MODULE_PARM_DESC(fm_port, "FM OPL-3 Port."); 62 51 #ifdef SUPPORT_JOYSTICK 63 module_param_ array(joystick_port, long, NULL, 0444);52 module_param_hw_array(joystick_port, long, ioport, NULL, 0444); 64 53 MODULE_PARM_DESC(joystick_port, "Joystick port address"); 65 54 #endif … … 67 56 MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch"); 68 57 69 static DEFINE_PCI_DEVICE_TABLE(snd_ymfpci_ids)= {58 static const struct pci_device_id snd_ymfpci_ids[] = { 70 59 { PCI_VDEVICE(YAMAHA, 0x0004), 0, }, /* YMF724 */ 71 60 { PCI_VDEVICE(YAMAHA, 0x000d), 0, }, /* YMF724F */ … … 80 69 81 70 #ifdef SUPPORT_JOYSTICK 82 static int __devinitsnd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,83 int legacy_ctrl, int legacy_ctrl2)71 static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev, 72 int legacy_ctrl, int legacy_ctrl2) 84 73 { 85 74 struct gameport *gp; … … 107 96 } 108 97 if (!r) { 109 printk(KERN_ERR "ymfpci: no gameport ports available\n"); 98 dev_err(chip->card->dev, 99 "no gameport ports available\n"); 110 100 return -EBUSY; 111 101 } … … 117 107 case 0x205: legacy_ctrl2 |= 3 << 6; break; 118 108 default: 119 printk(KERN_ERR "ymfpci: invalid joystick port %#x", io_port); 109 dev_err(chip->card->dev, 110 "invalid joystick port %#x", io_port); 120 111 return -EINVAL; 121 112 } … … 123 114 124 115 if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) { 125 printk(KERN_ERR "ymfpci: joystick port %#x is in use.\n", io_port); 116 dev_err(chip->card->dev, 117 "joystick port %#x is in use.\n", io_port); 126 118 return -EBUSY; 127 119 } … … 129 121 chip->gameport = gp = gameport_allocate_port(); 130 122 if (!gp) { 131 printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n"); 123 dev_err(chip->card->dev, 124 "cannot allocate memory for gameport\n"); 132 125 release_and_free_resource(r); 133 126 return -ENOMEM; … … 168 161 #endif /* SUPPORT_JOYSTICK */ 169 162 170 static int __devinitsnd_card_ymfpci_probe(struct pci_dev *pci,171 const struct pci_device_id *pci_id)163 static int snd_card_ymfpci_probe(struct pci_dev *pci, 164 const struct pci_device_id *pci_id) 172 165 { 173 166 static int dev; … … 188 181 } 189 182 190 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 183 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 184 0, &card); 191 185 if (err < 0) 192 186 return err; … … 264 258 old_legacy_ctrl, 265 259 &chip)) < 0) { 266 snd_card_free(card);267 260 release_and_free_resource(mpu_res); 268 261 release_and_free_resource(fm_res); 269 return err;262 goto free_card; 270 263 } 271 264 chip->fm_res = fm_res; … … 279 272 chip->reg_area_phys, 280 273 chip->irq); 281 if ((err = snd_ymfpci_pcm(chip, 0, NULL)) < 0) { 282 snd_card_free(card); 283 return err; 284 } 285 if ((err = snd_ymfpci_pcm_spdif(chip, 1, NULL)) < 0) { 286 snd_card_free(card); 287 return err; 288 } 289 if ((err = snd_ymfpci_pcm_4ch(chip, 2, NULL)) < 0) { 290 snd_card_free(card); 291 return err; 292 } 293 if ((err = snd_ymfpci_pcm2(chip, 3, NULL)) < 0) { 294 snd_card_free(card); 295 return err; 296 } 297 if ((err = snd_ymfpci_mixer(chip, rear_switch[dev])) < 0) { 298 snd_card_free(card); 299 return err; 300 } 301 if ((err = snd_ymfpci_timer(chip, 0)) < 0) { 302 snd_card_free(card); 303 return err; 304 } 274 err = snd_ymfpci_pcm(chip, 0); 275 if (err < 0) 276 goto free_card; 277 278 err = snd_ymfpci_pcm_spdif(chip, 1); 279 if (err < 0) 280 goto free_card; 281 282 err = snd_ymfpci_mixer(chip, rear_switch[dev]); 283 if (err < 0) 284 goto free_card; 285 286 if (chip->ac97->ext_id & AC97_EI_SDAC) { 287 err = snd_ymfpci_pcm_4ch(chip, 2); 288 if (err < 0) 289 goto free_card; 290 291 err = snd_ymfpci_pcm2(chip, 3); 292 if (err < 0) 293 goto free_card; 294 } 295 err = snd_ymfpci_timer(chip, 0); 296 if (err < 0) 297 goto free_card; 298 305 299 if (chip->mpu_res) { 306 300 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI, 307 301 mpu_port[dev], 308 MPU401_INFO_INTEGRATED, 309 pci->irq, 0, &chip->rawmidi)) < 0) { 310 printk(KERN_WARNING "ymfpci: cannot initialize MPU401 at 0x%lx, skipping...\n", mpu_port[dev]); 302 MPU401_INFO_INTEGRATED | 303 MPU401_INFO_IRQ_HOOK, 304 -1, &chip->rawmidi)) < 0) { 305 dev_warn(card->dev, 306 "cannot initialize MPU401 at 0x%lx, skipping...\n", 307 mpu_port[dev]); 311 308 legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */ 312 309 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); … … 318 315 fm_port[dev] + 2, 319 316 OPL3_HW_OPL3, 1, &opl3)) < 0) { 320 printk(KERN_WARNING "ymfpci: cannot initialize FM OPL3 at 0x%lx, skipping...\n", fm_port[dev]); 317 dev_warn(card->dev, 318 "cannot initialize FM OPL3 at 0x%lx, skipping...\n", 319 fm_port[dev]); 321 320 legacy_ctrl &= ~YMFPCI_LEGACY_FMEN; 322 321 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); 323 322 } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 324 snd_card_free(card); 325 snd_printk(KERN_ERR "cannot create opl3 hwdep\n"); 326 return err; 323 dev_err(card->dev, "cannot create opl3 hwdep\n"); 324 goto free_card; 327 325 } 328 326 } … … 330 328 snd_ymfpci_create_gameport(chip, dev, legacy_ctrl, legacy_ctrl2); 331 329 332 if ((err = snd_card_register(card)) < 0) {333 snd_card_free(card);334 return err;335 } 330 err = snd_card_register(card); 331 if (err < 0) 332 goto free_card; 333 336 334 pci_set_drvdata(pci, card); 337 335 dev++; 338 336 return 0; 337 338 free_card: 339 snd_card_free(card); 340 return err; 339 341 } 340 342 341 static void __devexitsnd_card_ymfpci_remove(struct pci_dev *pci)343 static void snd_card_ymfpci_remove(struct pci_dev *pci) 342 344 { 343 345 snd_card_free(pci_get_drvdata(pci)); 344 pci_set_drvdata(pci, NULL);345 346 } 346 347 347 static struct pci_driver driver = {348 .name = "Yamaha DS-1 PCI",348 static struct pci_driver ymfpci_driver = { 349 .name = KBUILD_MODNAME, 349 350 .id_table = snd_ymfpci_ids, 350 351 .probe = snd_card_ymfpci_probe, 351 .remove = __devexit_p(snd_card_ymfpci_remove), 352 #ifdef CONFIG_PM 353 .suspend = snd_ymfpci_suspend, 354 .resume = snd_ymfpci_resume, 352 .remove = snd_card_ymfpci_remove, 353 #ifdef CONFIG_PM_SLEEP 354 .driver = { 355 .pm = &snd_ymfpci_pm, 356 }, 355 357 #endif 356 358 }; 357 359 358 static int __init alsa_card_ymfpci_init(void) 359 { 360 return pci_register_driver(&driver); 361 } 362 363 static void __exit alsa_card_ymfpci_exit(void) 364 { 365 pci_unregister_driver(&driver); 366 } 367 368 module_init(alsa_card_ymfpci_init) 369 module_exit(alsa_card_ymfpci_exit) 360 module_pci_driver(ymfpci_driver); -
GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci_main.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 3 4 * Routines for control of YMF724/740/744/754 chips 4 *5 * This program is free software; you can redistribute it and/or modify6 * it under the terms of the GNU General Public License as published by7 * the Free Software Foundation; either version 2 of the License, or8 * (at your option) any later version.9 *10 * This program is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU General Public License16 * along with this program; if not, write to the Free Software17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18 *19 5 */ 6 7 #ifdef TARGET_OS2 8 #define KBUILD_MODNAME "ymfpci" 9 #endif 20 10 21 11 #include <linux/delay.h> … … 26 16 #include <linux/sched.h> 27 17 #include <linux/slab.h> 28 #include <linux/vmalloc.h>29 18 #include <linux/mutex.h> 19 #include <linux/module.h> 20 #include <linux/io.h> 30 21 31 22 #include <sound/core.h> … … 33 24 #include <sound/info.h> 34 25 #include <sound/tlv.h> 35 #include <sound/ymfpci.h>26 #include "ymfpci.h" 36 27 #include <sound/asoundef.h> 37 28 #include <sound/mpu401.h> 38 29 39 #include <asm/io.h>40 30 #include <asm/byteorder.h> 41 31 … … 87 77 schedule_timeout_uninterruptible(1); 88 78 } while (time_before(jiffies, end_time)); 89 snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg)); 79 dev_err(chip->card->dev, 80 "codec_ready: codec %i is not ready [0x%x]\n", 81 secondary, snd_ymfpci_readw(chip, reg)); 90 82 return -EBUSY; 91 83 } … … 135 127 } 136 128 137 static u32 def_rate[8] = {129 static const u32 def_rate[8] = { 138 130 100, 2000, 8000, 11025, 16000, 22050, 32000, 48000 139 131 }; … … 142 134 { 143 135 u32 i; 144 static u32 val[8] = {136 static const u32 val[8] = { 145 137 0x00570000, 0x06AA0000, 0x18B20000, 0x20930000, 146 138 0x2B9A0000, 0x35A10000, 0x3EAA0000, 0x40000000 … … 158 150 { 159 151 u32 i; 160 static u32 val[8] = {152 static const u32 val[8] = { 161 153 0x35280000, 0x34A70000, 0x32020000, 0x31770000, 162 154 0x31390000, 0x31C90000, 0x33D00000, 0x40000000 … … 320 312 if (ypcm->period_pos >= ypcm->period_size) { 321 313 /* 322 printk(KERN_DEBUG314 dev_dbg(chip->card->dev, 323 315 "done - active_bank = 0x%x, start = 0x%x\n", 324 316 chip->active_bank, … … 335 327 unsigned int next_bank = 1 - chip->active_bank; 336 328 struct snd_ymfpci_playback_bank *bank; 337 u32 volume;329 __le32 volume; 338 330 339 331 bank = &voice->bank[next_bank]; … … 373 365 ypcm->period_pos %= ypcm->period_size; 374 366 /* 375 printk(KERN_DEBUG367 dev_dbg(chip->card->dev, 376 368 "done - active_bank = 0x%x, start = 0x%x\n", 377 369 chip->active_bank, … … 413 405 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; 414 406 } 415 /* fall through */407 fallthrough; 416 408 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 417 409 case SNDRV_PCM_TRIGGER_SUSPEND: … … 504 496 struct snd_ymfpci_playback_bank *bank; 505 497 unsigned int nbank; 506 u32 vol_left, vol_right;498 __le32 vol_left, vol_right; 507 499 u8 use_left, use_right; 508 500 unsigned long flags; … … 598 590 } 599 591 600 static int __devinitsnd_ymfpci_ac3_init(struct snd_ymfpci *chip)601 { 602 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),592 static int snd_ymfpci_ac3_init(struct snd_ymfpci *chip) 593 { 594 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, 603 595 4096, &chip->ac3_tmp_base) < 0) 604 596 return -ENOMEM; … … 641 633 int err; 642 634 643 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)644 return err;645 635 if ((err = snd_ymfpci_pcm_voice_alloc(ypcm, params_channels(hw_params))) < 0) 646 636 return err; … … 660 650 /* wait, until the PCI operations are not finished */ 661 651 snd_ymfpci_irq_wait(chip); 662 snd_pcm_lib_free_pages(substream);663 652 if (ypcm->voices[1]) { 664 653 snd_ymfpci_voice_free(chip, ypcm->voices[1]); … … 696 685 } 697 686 698 static int snd_ymfpci_capture_hw_params(struct snd_pcm_substream *substream,699 struct snd_pcm_hw_params *hw_params)700 {701 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));702 }703 704 687 static int snd_ymfpci_capture_hw_free(struct snd_pcm_substream *substream) 705 688 { … … 708 691 /* wait, until the PCI operations are not finished */ 709 692 snd_ymfpci_irq_wait(chip); 710 return snd_pcm_lib_free_pages(substream);693 return 0; 711 694 } 712 695 … … 780 763 static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip) 781 764 { 782 wait_queue_ t wait;765 wait_queue_entry_t wait; 783 766 int loops = 4; 784 767 … … 844 827 } 845 828 846 static struct snd_pcm_hardware snd_ymfpci_playback =829 static const struct snd_pcm_hardware snd_ymfpci_playback = 847 830 { 848 831 .info = (SNDRV_PCM_INFO_MMAP | … … 866 849 }; 867 850 868 static struct snd_pcm_hardware snd_ymfpci_capture =851 static const struct snd_pcm_hardware snd_ymfpci_capture = 869 852 { 870 853 .info = (SNDRV_PCM_INFO_MMAP | … … 898 881 struct snd_pcm_runtime *runtime = substream->runtime; 899 882 struct snd_ymfpci_pcm *ypcm; 883 int err; 884 885 runtime->hw = snd_ymfpci_playback; 886 /* FIXME? True value is 256/48 = 5.33333 ms */ 887 err = snd_pcm_hw_constraint_minmax(runtime, 888 SNDRV_PCM_HW_PARAM_PERIOD_TIME, 889 5334, UINT_MAX); 890 if (err < 0) 891 return err; 892 err = snd_pcm_hw_rule_noresample(runtime, 48000); 893 if (err < 0) 894 return err; 900 895 901 896 ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); … … 905 900 ypcm->type = PLAYBACK_VOICE; 906 901 ypcm->substream = substream; 907 runtime->hw = snd_ymfpci_playback;908 902 runtime->private_data = ypcm; 909 903 runtime->private_free = snd_ymfpci_pcm_free_substream; 910 /* FIXME? True value is 256/48 = 5.33333 ms */911 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 5333, UINT_MAX);912 904 return 0; 913 905 } … … 1014 1006 struct snd_pcm_runtime *runtime = substream->runtime; 1015 1007 struct snd_ymfpci_pcm *ypcm; 1008 int err; 1009 1010 runtime->hw = snd_ymfpci_capture; 1011 /* FIXME? True value is 256/48 = 5.33333 ms */ 1012 err = snd_pcm_hw_constraint_minmax(runtime, 1013 SNDRV_PCM_HW_PARAM_PERIOD_TIME, 1014 5334, UINT_MAX); 1015 if (err < 0) 1016 return err; 1017 err = snd_pcm_hw_rule_noresample(runtime, 48000); 1018 if (err < 0) 1019 return err; 1016 1020 1017 1021 ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); … … 1023 1027 ypcm->capture_bank_number = capture_bank_number; 1024 1028 chip->capture_substream[capture_bank_number] = substream; 1025 runtime->hw = snd_ymfpci_capture;1026 /* FIXME? True value is 256/48 = 5.33333 ms */1027 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 5333, UINT_MAX);1028 1029 runtime->private_data = ypcm; 1029 1030 runtime->private_free = snd_ymfpci_pcm_free_substream; … … 1104 1105 } 1105 1106 1106 static struct snd_pcm_ops snd_ymfpci_playback_ops = {1107 static const struct snd_pcm_ops snd_ymfpci_playback_ops = { 1107 1108 .open = snd_ymfpci_playback_open, 1108 1109 .close = snd_ymfpci_playback_close, 1109 .ioctl = snd_pcm_lib_ioctl,1110 1110 .hw_params = snd_ymfpci_playback_hw_params, 1111 1111 .hw_free = snd_ymfpci_playback_hw_free, … … 1115 1115 }; 1116 1116 1117 static struct snd_pcm_ops snd_ymfpci_capture_rec_ops = {1117 static const struct snd_pcm_ops snd_ymfpci_capture_rec_ops = { 1118 1118 .open = snd_ymfpci_capture_rec_open, 1119 1119 .close = snd_ymfpci_capture_close, 1120 .ioctl = snd_pcm_lib_ioctl,1121 .hw_params = snd_ymfpci_capture_hw_params,1122 1120 .hw_free = snd_ymfpci_capture_hw_free, 1123 1121 .prepare = snd_ymfpci_capture_prepare, … … 1126 1124 }; 1127 1125 1128 int __devinit snd_ymfpci_pcm(struct snd_ymfpci *chip, int device, struct snd_pcm ** rpcm)1126 int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device) 1129 1127 { 1130 1128 struct snd_pcm *pcm; 1131 1129 int err; 1132 1130 1133 if (rpcm)1134 *rpcm = NULL;1135 1131 if ((err = snd_pcm_new(chip->card, "YMFPCI", device, 32, 1, &pcm)) < 0) 1136 1132 return err; … … 1145 1141 chip->pcm = pcm; 1146 1142 1147 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1148 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); 1149 1150 if (rpcm) 1151 *rpcm = pcm; 1152 return 0; 1153 } 1154 1155 static struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { 1143 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 1144 &chip->pci->dev, 64*1024, 256*1024); 1145 1146 return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1147 snd_pcm_std_chmaps, 2, 0, NULL); 1148 } 1149 1150 static const struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { 1156 1151 .open = snd_ymfpci_capture_ac97_open, 1157 1152 .close = snd_ymfpci_capture_close, 1158 .ioctl = snd_pcm_lib_ioctl,1159 .hw_params = snd_ymfpci_capture_hw_params,1160 1153 .hw_free = snd_ymfpci_capture_hw_free, 1161 1154 .prepare = snd_ymfpci_capture_prepare, … … 1164 1157 }; 1165 1158 1166 int __devinit snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device, struct snd_pcm ** rpcm)1159 int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device) 1167 1160 { 1168 1161 struct snd_pcm *pcm; 1169 1162 int err; 1170 1163 1171 if (rpcm)1172 *rpcm = NULL;1173 1164 if ((err = snd_pcm_new(chip->card, "YMFPCI - PCM2", device, 0, 1, &pcm)) < 0) 1174 1165 return err; … … 1183 1174 chip->pcm2 = pcm; 1184 1175 1185 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1186 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); 1187 1188 if (rpcm) 1189 *rpcm = pcm; 1190 return 0; 1191 } 1192 1193 static struct snd_pcm_ops snd_ymfpci_playback_spdif_ops = { 1176 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 1177 &chip->pci->dev, 64*1024, 256*1024); 1178 1179 return 0; 1180 } 1181 1182 static const struct snd_pcm_ops snd_ymfpci_playback_spdif_ops = { 1194 1183 .open = snd_ymfpci_playback_spdif_open, 1195 1184 .close = snd_ymfpci_playback_spdif_close, 1196 .ioctl = snd_pcm_lib_ioctl,1197 1185 .hw_params = snd_ymfpci_playback_hw_params, 1198 1186 .hw_free = snd_ymfpci_playback_hw_free, … … 1202 1190 }; 1203 1191 1204 int __devinit snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device, struct snd_pcm ** rpcm)1192 int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device) 1205 1193 { 1206 1194 struct snd_pcm *pcm; 1207 1195 int err; 1208 1196 1209 if (rpcm)1210 *rpcm = NULL;1211 1197 if ((err = snd_pcm_new(chip->card, "YMFPCI - IEC958", device, 1, 0, &pcm)) < 0) 1212 1198 return err; … … 1220 1206 chip->pcm_spdif = pcm; 1221 1207 1222 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1223 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); 1224 1225 if (rpcm) 1226 *rpcm = pcm; 1227 return 0; 1228 } 1229 1230 static struct snd_pcm_ops snd_ymfpci_playback_4ch_ops = { 1208 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 1209 &chip->pci->dev, 64*1024, 256*1024); 1210 1211 return 0; 1212 } 1213 1214 static const struct snd_pcm_ops snd_ymfpci_playback_4ch_ops = { 1231 1215 .open = snd_ymfpci_playback_4ch_open, 1232 1216 .close = snd_ymfpci_playback_4ch_close, 1233 .ioctl = snd_pcm_lib_ioctl,1234 1217 .hw_params = snd_ymfpci_playback_hw_params, 1235 1218 .hw_free = snd_ymfpci_playback_hw_free, … … 1239 1222 }; 1240 1223 1241 int __devinit snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, struct snd_pcm ** rpcm) 1224 static const struct snd_pcm_chmap_elem surround_map[] = { 1225 { .channels = 1, 1226 .map = { SNDRV_CHMAP_MONO } }, 1227 { .channels = 2, 1228 .map = { SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, 1229 {0} 1230 }; 1231 1232 int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device) 1242 1233 { 1243 1234 struct snd_pcm *pcm; 1244 1235 int err; 1245 1236 1246 if (rpcm)1247 *rpcm = NULL;1248 1237 if ((err = snd_pcm_new(chip->card, "YMFPCI - Rear", device, 1, 0, &pcm)) < 0) 1249 1238 return err; … … 1257 1246 chip->pcm_4ch = pcm; 1258 1247 1259 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1260 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); 1261 1262 if (rpcm) 1263 *rpcm = pcm; 1264 return 0; 1248 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 1249 &chip->pci->dev, 64*1024, 256*1024); 1250 1251 return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1252 surround_map, 2, 0, NULL); 1265 1253 } 1266 1254 … … 1303 1291 } 1304 1292 1305 static struct snd_kcontrol_new snd_ymfpci_spdif_default __devinitdata=1293 static const struct snd_kcontrol_new snd_ymfpci_spdif_default = 1306 1294 { 1307 1295 .iface = SNDRV_CTL_ELEM_IFACE_PCM, … … 1331 1319 } 1332 1320 1333 static struct snd_kcontrol_new snd_ymfpci_spdif_mask __devinitdata=1321 static const struct snd_kcontrol_new snd_ymfpci_spdif_mask = 1334 1322 { 1335 1323 .access = SNDRV_CTL_ELEM_ACCESS_READ, … … 1378 1366 } 1379 1367 1380 static struct snd_kcontrol_new snd_ymfpci_spdif_stream __devinitdata=1368 static const struct snd_kcontrol_new snd_ymfpci_spdif_stream = 1381 1369 { 1382 1370 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, … … 1426 1414 } 1427 1415 1428 static struct snd_kcontrol_new snd_ymfpci_drec_source __devinitdata= {1416 static const struct snd_kcontrol_new snd_ymfpci_drec_source = { 1429 1417 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 1430 1418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 1596 1584 } 1597 1585 1598 1599 static struct snd_kcontrol_new snd_ymfpci_controls[] __devinitdata = { 1586 static const struct snd_kcontrol_new snd_ymfpci_dup4ch = { 1587 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1588 .name = "4ch Duplication", 1589 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 1590 .info = snd_ymfpci_info_dup4ch, 1591 .get = snd_ymfpci_get_dup4ch, 1592 .put = snd_ymfpci_put_dup4ch, 1593 }; 1594 1595 static const struct snd_kcontrol_new snd_ymfpci_controls[] = { 1600 1596 { 1601 1597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 1616 1612 YMFPCI_DOUBLE("ADC Playback Volume", 1, YDSXGR_SECADCOUTVOL), 1617 1613 YMFPCI_DOUBLE("ADC Capture Volume", 1, YDSXGR_SECADCLOOPVOL), 1618 YMFPCI_DOUBLE("FM Legacy Volume", 0, YDSXGR_LEGACYOUTVOL),1614 YMFPCI_DOUBLE("FM Legacy Playback Volume", 0, YDSXGR_LEGACYOUTVOL), 1619 1615 YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("AC97 ", PLAYBACK,VOLUME), 0, YDSXGR_ZVOUTVOL), 1620 1616 YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("", CAPTURE,VOLUME), 0, YDSXGR_ZVLOOPVOL), … … 1624 1620 YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, YDSXGR_SPDIFINCTRL, 0), 1625 1621 YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("Loop",NONE,NONE), 0, YDSXGR_SPDIFINCTRL, 4), 1626 {1627 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,1628 .name = "4ch Duplication",1629 .info = snd_ymfpci_info_dup4ch,1630 .get = snd_ymfpci_get_dup4ch,1631 .put = snd_ymfpci_put_dup4ch,1632 },1633 1622 }; 1634 1623 … … 1698 1687 } 1699 1688 1700 static struct snd_kcontrol_new snd_ymfpci_rear_shared __devinitdata= {1689 static const struct snd_kcontrol_new snd_ymfpci_rear_shared = { 1701 1690 .name = "Shared Rear/Line-In Switch", 1702 1691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 1762 1751 } 1763 1752 1764 static struct snd_kcontrol_new snd_ymfpci_pcm_volume __devinitdata= {1753 static const struct snd_kcontrol_new snd_ymfpci_pcm_volume = { 1765 1754 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1766 1755 .name = "PCM Playback Volume", … … 1789 1778 } 1790 1779 1791 int __devinitsnd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch)1780 int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) 1792 1781 { 1793 1782 struct snd_ac97_template ac97; … … 1796 1785 unsigned int idx; 1797 1786 int err; 1798 static struct snd_ac97_bus_ops ops = {1787 static const struct snd_ac97_bus_ops ops = { 1799 1788 .write = snd_ymfpci_codec_write, 1800 1789 .read = snd_ymfpci_codec_read, … … 1818 1807 for (idx = 0; idx < ARRAY_SIZE(snd_ymfpci_controls); idx++) { 1819 1808 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_controls[idx], chip))) < 0) 1809 return err; 1810 } 1811 if (chip->ac97->ext_id & AC97_EI_SDAC) { 1812 kctl = snd_ctl_new1(&snd_ymfpci_dup4ch, chip); 1813 err = snd_ctl_add(chip->card, kctl); 1814 if (err < 0) 1820 1815 return err; 1821 1816 } … … 1918 1913 } 1919 1914 1920 static struct snd_timer_hardware snd_ymfpci_timer_hw = {1915 static const struct snd_timer_hardware snd_ymfpci_timer_hw = { 1921 1916 .flags = SNDRV_TIMER_HW_AUTO, 1922 1917 .resolution = 10417, /* 1 / 96 kHz = 10.41666...us */ … … 1927 1922 }; 1928 1923 1929 int __devinitsnd_ymfpci_timer(struct snd_ymfpci *chip, int device)1924 int snd_ymfpci_timer(struct snd_ymfpci *chip, int device) 1930 1925 { 1931 1926 struct snd_timer *timer = NULL; … … 1963 1958 } 1964 1959 1965 static int __devinit snd_ymfpci_proc_init(struct snd_card *card, struct snd_ymfpci *chip) 1966 { 1967 struct snd_info_entry *entry; 1968 1969 if (! snd_card_proc_new(card, "ymfpci", &entry)) 1970 snd_info_set_text_ops(entry, chip, snd_ymfpci_proc_read); 1971 return 0; 1960 static int snd_ymfpci_proc_init(struct snd_card *card, struct snd_ymfpci *chip) 1961 { 1962 return snd_card_ro_proc_new(card, "ymfpci", chip, snd_ymfpci_proc_read); 1972 1963 } 1973 1964 … … 2023 2014 if (err >= 0) { 2024 2015 if (chip->dsp_microcode->size != YDSXG_DSPLENGTH) { 2025 snd_printk(KERN_ERR "DSP microcode has wrong size\n"); 2016 dev_err(chip->card->dev, 2017 "DSP microcode has wrong size\n"); 2026 2018 err = -EINVAL; 2027 2019 } … … 2038 2030 if (err >= 0) { 2039 2031 if (chip->controller_microcode->size != YDSXG_CTRLLENGTH) { 2040 snd_printk(KERN_ERR "controller microcode"2041 "has wrong size\n");2032 dev_err(chip->card->dev, 2033 "controller microcode has wrong size\n"); 2042 2034 err = -EINVAL; 2043 2035 } … … 2085 2077 } 2086 2078 2087 static int __devinitsnd_ymfpci_memalloc(struct snd_ymfpci *chip)2079 static int snd_ymfpci_memalloc(struct snd_ymfpci *chip) 2088 2080 { 2089 2081 long size, playback_ctrl_size; … … 2105 2097 /* work_ptr must be aligned to 256 bytes, but it's already 2106 2098 covered with the kernel page allocation mechanism */ 2107 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),2099 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, 2108 2100 size, &chip->work_ptr) < 0) 2109 2101 return -ENOMEM; … … 2114 2106 chip->bank_base_playback = ptr; 2115 2107 chip->bank_base_playback_addr = ptr_addr; 2116 chip->ctrl_playback = ( u32 *)ptr;2108 chip->ctrl_playback = (__le32 *)ptr; 2117 2109 chip->ctrl_playback[0] = cpu_to_le32(YDSXG_PLAYBACK_VOICES); 2118 2110 ptr += ALIGN(playback_ctrl_size, 0x100); … … 2214 2206 * the chip again unless reboot. ACPI bug? 2215 2207 */ 2216 pci_set_power_state(chip->pci, 3);2208 pci_set_power_state(chip->pci, PCI_D3hot); 2217 2209 #endif 2218 2210 2219 #ifdef CONFIG_PM 2220 vfree(chip->saved_regs);2211 #ifdef CONFIG_PM_SLEEP 2212 kfree(chip->saved_regs); 2221 2213 #endif 2222 2214 if (chip->irq >= 0) … … 2225 2217 release_and_free_resource(chip->fm_res); 2226 2218 snd_ymfpci_free_gameport(chip); 2227 if (chip->reg_area_virt) 2228 iounmap(chip->reg_area_virt); 2219 iounmap(chip->reg_area_virt); 2229 2220 if (chip->work_ptr.area) 2230 2221 snd_dma_free_pages(&chip->work_ptr); … … 2247 2238 } 2248 2239 2249 #ifdef CONFIG_PM 2250 static int saved_regs_index[] = {2240 #ifdef CONFIG_PM_SLEEP 2241 static const int saved_regs_index[] = { 2251 2242 /* spdif */ 2252 2243 YDSXGR_SPDIFOUTCTRL, … … 2277 2268 #define YDSXGR_NUM_SAVED_REGS ARRAY_SIZE(saved_regs_index) 2278 2269 2279 int snd_ymfpci_suspend(struct pci_dev *pci, pm_message_t state)2280 { 2281 struct snd_card *card = pci_get_drvdata(pci);2270 static int snd_ymfpci_suspend(struct device *dev) 2271 { 2272 struct snd_card *card = dev_get_drvdata(dev); 2282 2273 struct snd_ymfpci *chip = card->private_data; 2283 2274 unsigned int i; 2284 2275 2285 2276 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2286 snd_pcm_suspend_all(chip->pcm);2287 snd_pcm_suspend_all(chip->pcm2);2288 snd_pcm_suspend_all(chip->pcm_spdif);2289 snd_pcm_suspend_all(chip->pcm_4ch);2290 2277 snd_ac97_suspend(chip->ac97); 2291 2278 for (i = 0; i < YDSXGR_NUM_SAVED_REGS; i++) 2292 2279 chip->saved_regs[i] = snd_ymfpci_readl(chip, saved_regs_index[i]); 2293 2280 chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE); 2281 pci_read_config_word(chip->pci, PCIR_DSXG_LEGACY, 2282 &chip->saved_dsxg_legacy); 2283 pci_read_config_word(chip->pci, PCIR_DSXG_ELEGACY, 2284 &chip->saved_dsxg_elegacy); 2294 2285 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); 2295 2286 snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0); 2296 2287 snd_ymfpci_disable_dsp(chip); 2297 pci_disable_device(pci); 2298 pci_save_state(pci); 2299 pci_set_power_state(pci, pci_choose_state(pci, state)); 2300 return 0; 2301 } 2302 2303 int snd_ymfpci_resume(struct pci_dev *pci) 2304 { 2305 struct snd_card *card = pci_get_drvdata(pci); 2288 return 0; 2289 } 2290 2291 static int snd_ymfpci_resume(struct device *dev) 2292 { 2293 struct pci_dev *pci = to_pci_dev(dev); 2294 struct snd_card *card = dev_get_drvdata(dev); 2306 2295 struct snd_ymfpci *chip = card->private_data; 2307 2296 unsigned int i; 2308 2297 2309 pci_set_power_state(pci, PCI_D0);2310 pci_restore_state(pci);2311 if (pci_enable_device(pci) < 0) {2312 printk(KERN_ERR "ymfpci: pci_enable_device failed, "2313 "disabling device\n");2314 snd_card_disconnect(card);2315 return -EIO;2316 }2317 pci_set_master(pci);2318 2298 snd_ymfpci_aclink_reset(pci); 2319 2299 snd_ymfpci_codec_ready(chip, 0); … … 2325 2305 2326 2306 snd_ac97_resume(chip->ac97); 2307 2308 pci_write_config_word(chip->pci, PCIR_DSXG_LEGACY, 2309 chip->saved_dsxg_legacy); 2310 pci_write_config_word(chip->pci, PCIR_DSXG_ELEGACY, 2311 chip->saved_dsxg_elegacy); 2327 2312 2328 2313 /* start hw again */ … … 2336 2321 return 0; 2337 2322 } 2338 #endif /* CONFIG_PM */ 2339 2340 int __devinit snd_ymfpci_create(struct snd_card *card, 2341 struct pci_dev * pci, 2342 unsigned short old_legacy_ctrl, 2343 struct snd_ymfpci ** rchip) 2323 2324 SIMPLE_DEV_PM_OPS(snd_ymfpci_pm, snd_ymfpci_suspend, snd_ymfpci_resume); 2325 #endif /* CONFIG_PM_SLEEP */ 2326 2327 int snd_ymfpci_create(struct snd_card *card, 2328 struct pci_dev *pci, 2329 unsigned short old_legacy_ctrl, 2330 struct snd_ymfpci **rchip) 2344 2331 { 2345 2332 struct snd_ymfpci *chip; 2346 2333 int err; 2347 static struct snd_device_ops ops = {2334 static const struct snd_device_ops ops = { 2348 2335 .dev_free = snd_ymfpci_dev_free, 2349 2336 }; … … 2369 2356 chip->irq = -1; 2370 2357 chip->device_id = pci->device; 2371 #ifndef TARGET_OS22372 2358 chip->rev = pci->revision; 2373 #else2374 chip->rev = snd_pci_revision(pci);2375 #endif2376 2359 chip->reg_area_phys = pci_resource_start(pci, 0); 2377 chip->reg_area_virt = ioremap _nocache(chip->reg_area_phys, 0x8000);2360 chip->reg_area_virt = ioremap(chip->reg_area_phys, 0x8000); 2378 2361 pci_set_master(pci); 2379 2362 chip->src441_used = -1; 2380 2363 2381 2364 if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) { 2382 snd_printk(KERN_ERR "unable to grab memory region 0x%lx-0x%lx\n", chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); 2383 snd_ymfpci_free(chip); 2384 return -EBUSY; 2365 dev_err(chip->card->dev, 2366 "unable to grab memory region 0x%lx-0x%lx\n", 2367 chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); 2368 err = -EBUSY; 2369 goto free_chip; 2385 2370 } 2386 2371 if (request_irq(pci->irq, snd_ymfpci_interrupt, IRQF_SHARED, 2387 "YMFPCI", chip)) {2388 snd_printk(KERN_ERR"unable to grab IRQ %d\n", pci->irq);2389 snd_ymfpci_free(chip);2390 return -EBUSY;2372 KBUILD_MODNAME, chip)) { 2373 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq); 2374 err = -EBUSY; 2375 goto free_chip; 2391 2376 } 2392 2377 chip->irq = pci->irq; 2378 card->sync_irq = chip->irq; 2393 2379 2394 2380 snd_ymfpci_aclink_reset(pci); 2395 2381 if (snd_ymfpci_codec_ready(chip, 0) < 0) { 2396 snd_ymfpci_free(chip);2397 return -EIO;2382 err = -EIO; 2383 goto free_chip; 2398 2384 } 2399 2385 2400 2386 err = snd_ymfpci_request_firmware(chip); 2401 2387 if (err < 0) { 2402 snd_printk(KERN_ERR "firmware request failed: %d\n", err); 2403 snd_ymfpci_free(chip); 2404 return err; 2388 dev_err(chip->card->dev, "firmware request failed: %d\n", err); 2389 goto free_chip; 2405 2390 } 2406 2391 snd_ymfpci_download_image(chip); … … 2409 2394 2410 2395 if (snd_ymfpci_memalloc(chip) < 0) { 2411 snd_ymfpci_free(chip);2412 return -EIO;2413 } 2414 2415 if ((err = snd_ymfpci_ac3_init(chip)) < 0) {2416 snd_ymfpci_free(chip);2417 return err;2418 } 2419 2420 #ifdef CONFIG_PM 2421 chip->saved_regs = vmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32));2396 err = -EIO; 2397 goto free_chip; 2398 } 2399 2400 err = snd_ymfpci_ac3_init(chip); 2401 if (err < 0) 2402 goto free_chip; 2403 2404 #ifdef CONFIG_PM_SLEEP 2405 chip->saved_regs = kmalloc_array(YDSXGR_NUM_SAVED_REGS, sizeof(u32), 2406 GFP_KERNEL); 2422 2407 if (chip->saved_regs == NULL) { 2423 snd_ymfpci_free(chip);2424 return -ENOMEM;2408 err = -ENOMEM; 2409 goto free_chip; 2425 2410 } 2426 2411 #endif 2427 2412 2428 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 2429 snd_ymfpci_free(chip); 2430 return err; 2431 } 2413 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 2414 if (err < 0) 2415 goto free_chip; 2432 2416 2433 2417 snd_ymfpci_proc_init(card, chip); 2434 2418 2435 snd_card_set_dev(card, &pci->dev);2436 2437 2419 *rchip = chip; 2438 2420 return 0; 2439 } 2421 2422 free_chip: 2423 snd_ymfpci_free(chip); 2424 return err; 2425 }
Note:
See TracChangeset
for help on using the changeset viewer.
