Changeset 679 for GPL/trunk/alsa-kernel/pci/ens1370.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/ens1370.c
r607 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * Driver for Ensoniq ES1370/ES1371 AudioPCI soundcard 3 4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>, 4 5 * Thomas Sailer <sailer@ife.ee.ethz.ch> 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 6 */ 21 7 … … 23 9 * for ens1371 only ( FIXME ) 24 10 * derived from cs4281.c, atiixp.c and via82xx.c 25 * using http://www.alsa-project.org/~tiwai/writing-an-alsa-driver/ 11 * using http://www.alsa-project.org/~tiwai/writing-an-alsa-driver/ 26 12 * by Kurt J. Bosch 27 13 */ 28 14 29 #include < asm/io.h>15 #include <linux/io.h> 30 16 #include <linux/delay.h> 31 17 #include <linux/interrupt.h> … … 34 20 #include <linux/slab.h> 35 21 #include <linux/gameport.h> 36 #include <linux/module param.h>22 #include <linux/module.h> 37 23 #include <linux/mutex.h> 38 24 … … 56 42 #ifdef CHIP1370 57 43 #define DRIVER_NAME "ENS1370" 44 #define CHIP_NAME "ES1370" /* it can be ENS but just to keep compatibility... */ 58 45 #else 59 46 #define DRIVER_NAME "ENS1371" 60 #endif 61 62 47 #define CHIP_NAME "ES1371" 48 #endif 49 50 51 #ifdef TARGET_OS2 52 #define KBUILD_MODNAME "ens137x" 53 #endif 63 54 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Thomas Sailer <sailer@ife.ee.ethz.ch>"); 64 55 MODULE_LICENSE("GPL"); … … 78 69 #endif 79 70 80 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))71 #if IS_REACHABLE(CONFIG_GAMEPORT) 81 72 #define SUPPORT_JOYSTICK 82 73 #endif … … 84 75 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 85 76 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 86 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */77 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ 87 78 #ifdef SUPPORT_JOYSTICK 88 79 #ifdef CHIP1371 89 80 static int joystick_port[SNDRV_CARDS]; 90 81 #else 91 static intjoystick[SNDRV_CARDS];82 static bool joystick[SNDRV_CARDS]; 92 83 #endif 93 84 #endif … … 105 96 #ifdef SUPPORT_JOYSTICK 106 97 #ifdef CHIP1371 107 module_param_ array(joystick_port, int, NULL, 0444);98 module_param_hw_array(joystick_port, int, ioport, NULL, 0444); 108 99 MODULE_PARM_DESC(joystick_port, "Joystick port address."); 109 100 #else … … 230 221 #define ES_1371_CODEC_RDY (1<<31) /* codec ready */ 231 222 #define ES_1371_CODEC_WIP (1<<30) /* codec register access in progress */ 223 #define EV_1938_CODEC_MAGIC (1<<26) 232 224 #define ES_1371_CODEC_PIRD (1<<23) /* codec read/write select register */ 233 225 #define ES_1371_CODEC_WRITE(a,d) ((((a)&0x7f)<<16)|(((d)&0xffff)<<0)) … … 444 436 static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id); 445 437 446 static DEFINE_PCI_DEVICE_TABLE(snd_audiopci_ids)= {438 static const struct pci_device_id snd_audiopci_ids[] = { 447 439 #ifdef CHIP1370 448 440 { PCI_VDEVICE(ENSONIQ, 0x5000), 0, }, /* ES1370 */ … … 465 457 466 458 #ifdef CHIP1370 467 static unsigned int snd_es1370_fixed_rates[] =459 static const unsigned int snd_es1370_fixed_rates[] = 468 460 {5512, 11025, 22050, 44100}; 469 static struct snd_pcm_hw_constraint_list snd_es1370_hw_constraints_rates = {470 .count = 4, 461 static const struct snd_pcm_hw_constraint_list snd_es1370_hw_constraints_rates = { 462 .count = 4, 471 463 .list = snd_es1370_fixed_rates, 472 464 .mask = 0, 473 465 }; 474 static struct snd_ratnum es1370_clock = {466 static const struct snd_ratnum es1370_clock = { 475 467 .num = ES_1370_SRCLOCK, 476 .den_min = 29, 468 .den_min = 29, 477 469 .den_max = 353, 478 470 .den_step = 1, 479 471 }; 480 static struct snd_pcm_hw_constraint_ratnums snd_es1370_hw_constraints_clock = {472 static const struct snd_pcm_hw_constraint_ratnums snd_es1370_hw_constraints_clock = { 481 473 .nrats = 1, 482 474 .rats = &es1370_clock, 483 475 }; 484 476 #else 485 static struct snd_ratden es1371_dac_clock = {477 static const struct snd_ratden es1371_dac_clock = { 486 478 .num_min = 3000 * (1 << 15), 487 479 .num_max = 48000 * (1 << 15), … … 489 481 .den = 1 << 15, 490 482 }; 491 static struct snd_pcm_hw_constraint_ratdens snd_es1371_hw_constraints_dac_clock = {483 static const struct snd_pcm_hw_constraint_ratdens snd_es1371_hw_constraints_dac_clock = { 492 484 .nrats = 1, 493 485 .rats = &es1371_dac_clock, 494 486 }; 495 static struct snd_ratnum es1371_adc_clock = {487 static const struct snd_ratnum es1371_adc_clock = { 496 488 .num = 48000 << 15, 497 .den_min = 32768, 489 .den_min = 32768, 498 490 .den_max = 393216, 499 491 .den_step = 1, 500 492 }; 501 static struct snd_pcm_hw_constraint_ratnums snd_es1371_hw_constraints_adc_clock = {493 static const struct snd_pcm_hw_constraint_ratnums snd_es1371_hw_constraints_adc_clock = { 502 494 .nrats = 1, 503 495 .rats = &es1371_adc_clock, … … 523 515 cond_resched(); 524 516 } 525 snd_printk(KERN_ERR"wait src ready timeout 0x%lx [0x%x]\n",517 dev_err(ensoniq->card->dev, "wait src ready timeout 0x%lx [0x%x]\n", 526 518 ES_REG(ensoniq, 1371_SMPRATE), r); 527 519 return 0; … … 585 577 586 578 #if 0 587 printk(KERN_DEBUG579 dev_dbg(ensoniq->card->dev, 588 580 "CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", 589 581 reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); … … 596 588 schedule_timeout_uninterruptible(1); 597 589 } while (time_after(end_time, jiffies)); 598 snd_printk(KERN_ERR"codec write timeout, status = 0x%x\n",590 dev_err(ensoniq->card->dev, "codec write timeout, status = 0x%x\n", 599 591 inl(ES_REG(ensoniq, STATUS))); 600 592 } … … 603 595 604 596 #ifdef CHIP1371 597 598 static inline bool is_ev1938(struct ensoniq *ensoniq) 599 { 600 return ensoniq->pci->device == 0x8938; 601 } 605 602 606 603 static void snd_es1371_codec_write(struct snd_ac97 *ac97, … … 608 605 { 609 606 struct ensoniq *ensoniq = ac97->private_data; 610 unsigned int t, x; 611 607 unsigned int t, x, flag; 608 609 flag = is_ev1938(ensoniq) ? EV_1938_CODEC_MAGIC : 0; 612 610 mutex_lock(&ensoniq->src_mutex); 613 611 for (t = 0; t < POLL_COUNT; t++) { … … 631 629 break; 632 630 } 633 outl(ES_1371_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1371_CODEC)); 631 outl(ES_1371_CODEC_WRITE(reg, val) | flag, 632 ES_REG(ensoniq, 1371_CODEC)); 634 633 /* restore SRC reg */ 635 634 snd_es1371_wait_src_ready(ensoniq); … … 640 639 } 641 640 mutex_unlock(&ensoniq->src_mutex); 642 snd_printk(KERN_ERR"codec write timeout at 0x%lx [0x%x]\n",641 dev_err(ensoniq->card->dev, "codec write timeout at 0x%lx [0x%x]\n", 643 642 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); 644 643 } … … 648 647 { 649 648 struct ensoniq *ensoniq = ac97->private_data; 650 unsigned int t, x, fail = 0; 651 649 unsigned int t, x, flag, fail = 0; 650 651 flag = is_ev1938(ensoniq) ? EV_1938_CODEC_MAGIC : 0; 652 652 __again: 653 653 mutex_lock(&ensoniq->src_mutex); … … 672 672 break; 673 673 } 674 outl(ES_1371_CODEC_READS(reg), ES_REG(ensoniq, 1371_CODEC)); 674 outl(ES_1371_CODEC_READS(reg) | flag, 675 ES_REG(ensoniq, 1371_CODEC)); 675 676 /* restore SRC reg */ 676 677 snd_es1371_wait_src_ready(ensoniq); … … 684 685 for (t = 0; t < POLL_COUNT; t++) { 685 686 if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & ES_1371_CODEC_RDY) { 687 if (is_ev1938(ensoniq)) { 688 for (t = 0; t < 100; t++) 689 inl(ES_REG(ensoniq, CONTROL)); 690 x = inl(ES_REG(ensoniq, 1371_CODEC)); 691 } 686 692 mutex_unlock(&ensoniq->src_mutex); 687 693 return ES_1371_CODEC_READ(x); … … 690 696 mutex_unlock(&ensoniq->src_mutex); 691 697 if (++fail > 10) { 692 snd_printk(KERN_ERR "codec read timeout (final) "693 "at 0x%lx, reg = 0x%x [0x%x]\n",698 dev_err(ensoniq->card->dev, 699 "codec read timeout (final) at 0x%lx, reg = 0x%x [0x%x]\n", 694 700 ES_REG(ensoniq, 1371_CODEC), reg, 695 701 inl(ES_REG(ensoniq, 1371_CODEC))); … … 700 706 } 701 707 mutex_unlock(&ensoniq->src_mutex); 702 snd_printk(KERN_ERR "es1371:codec read timeout at 0x%lx [0x%x]\n",708 dev_err(ensoniq->card->dev, "codec read timeout at 0x%lx [0x%x]\n", 703 709 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); 704 710 return 0; … … 716 722 static void snd_es1371_adc_rate(struct ensoniq * ensoniq, unsigned int rate) 717 723 { 718 unsigned int n, truncm, freq , result;724 unsigned int n, truncm, freq; 719 725 720 726 mutex_lock(&ensoniq->src_mutex); … … 724 730 truncm = (21 * n - 1) | 1; 725 731 freq = ((48000UL << 15) / rate) * n; 726 result = (48000UL << 15) / (freq / n);727 732 if (rate >= 24000) { 728 733 if (truncm > 239) … … 855 860 */ 856 861 857 static int snd_ensoniq_hw_params(struct snd_pcm_substream *substream,858 struct snd_pcm_hw_params *hw_params)859 {860 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));861 }862 863 static int snd_ensoniq_hw_free(struct snd_pcm_substream *substream)864 {865 return snd_pcm_lib_free_pages(substream);866 }867 868 862 static int snd_ensoniq_playback1_prepare(struct snd_pcm_substream *substream) 869 863 { … … 1043 1037 } 1044 1038 1045 static struct snd_pcm_hardware snd_ensoniq_playback1 =1039 static const struct snd_pcm_hardware snd_ensoniq_playback1 = 1046 1040 { 1047 1041 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1055 1049 #else 1056 1050 (SNDRV_PCM_RATE_KNOT | /* 5512Hz rate */ 1057 SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_22050 | 1051 SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_22050 | 1058 1052 SNDRV_PCM_RATE_44100), 1059 1053 #endif … … 1070 1064 }; 1071 1065 1072 static struct snd_pcm_hardware snd_ensoniq_playback2 =1066 static const struct snd_pcm_hardware snd_ensoniq_playback2 = 1073 1067 { 1074 1068 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1075 1069 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1076 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE | 1070 SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE | 1077 1071 SNDRV_PCM_INFO_SYNC_START), 1078 1072 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, … … 1090 1084 }; 1091 1085 1092 static struct snd_pcm_hardware snd_ensoniq_capture =1086 static const struct snd_pcm_hardware snd_ensoniq_capture = 1093 1087 { 1094 1088 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | … … 1211 1205 } 1212 1206 1213 static struct snd_pcm_ops snd_ensoniq_playback1_ops = {1207 static const struct snd_pcm_ops snd_ensoniq_playback1_ops = { 1214 1208 .open = snd_ensoniq_playback1_open, 1215 1209 .close = snd_ensoniq_playback1_close, 1216 .ioctl = snd_pcm_lib_ioctl,1217 .hw_params = snd_ensoniq_hw_params,1218 .hw_free = snd_ensoniq_hw_free,1219 1210 .prepare = snd_ensoniq_playback1_prepare, 1220 1211 .trigger = snd_ensoniq_trigger, … … 1222 1213 }; 1223 1214 1224 static struct snd_pcm_ops snd_ensoniq_playback2_ops = {1215 static const struct snd_pcm_ops snd_ensoniq_playback2_ops = { 1225 1216 .open = snd_ensoniq_playback2_open, 1226 1217 .close = snd_ensoniq_playback2_close, 1227 .ioctl = snd_pcm_lib_ioctl,1228 .hw_params = snd_ensoniq_hw_params,1229 .hw_free = snd_ensoniq_hw_free,1230 1218 .prepare = snd_ensoniq_playback2_prepare, 1231 1219 .trigger = snd_ensoniq_trigger, … … 1233 1221 }; 1234 1222 1235 static struct snd_pcm_ops snd_ensoniq_capture_ops = {1223 static const struct snd_pcm_ops snd_ensoniq_capture_ops = { 1236 1224 .open = snd_ensoniq_capture_open, 1237 1225 .close = snd_ensoniq_capture_close, 1238 .ioctl = snd_pcm_lib_ioctl,1239 .hw_params = snd_ensoniq_hw_params,1240 .hw_free = snd_ensoniq_hw_free,1241 1226 .prepare = snd_ensoniq_capture_prepare, 1242 1227 .trigger = snd_ensoniq_trigger, … … 1244 1229 }; 1245 1230 1246 static int __devinit snd_ensoniq_pcm(struct ensoniq * ensoniq, int device, 1247 struct snd_pcm ** rpcm) 1231 static const struct snd_pcm_chmap_elem surround_map[] = { 1232 { .channels = 1, 1233 .map = { SNDRV_CHMAP_MONO } }, 1234 { .channels = 2, 1235 .map = { SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, 1236 {0} 1237 }; 1238 1239 static int snd_ensoniq_pcm(struct ensoniq *ensoniq, int device) 1248 1240 { 1249 1241 struct snd_pcm *pcm; 1250 1242 int err; 1251 1243 1252 if (rpcm) 1253 *rpcm = NULL; 1254 #ifdef CHIP1370 1255 err = snd_pcm_new(ensoniq->card, "ES1370/1", device, 1, 1, &pcm); 1256 #else 1257 err = snd_pcm_new(ensoniq->card, "ES1371/1", device, 1, 1, &pcm); 1258 #endif 1244 err = snd_pcm_new(ensoniq->card, CHIP_NAME "/1", device, 1, 1, &pcm); 1259 1245 if (err < 0) 1260 1246 return err; … … 1269 1255 pcm->private_data = ensoniq; 1270 1256 pcm->info_flags = 0; 1271 #ifdef CHIP1370 1272 strcpy(pcm->name, "ES1370 DAC2/ADC"); 1257 strcpy(pcm->name, CHIP_NAME " DAC2/ADC"); 1258 ensoniq->pcm1 = pcm; 1259 1260 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 1261 &ensoniq->pci->dev, 64*1024, 128*1024); 1262 1263 #ifdef CHIP1370 1264 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1265 surround_map, 2, 0, NULL); 1273 1266 #else 1274 strcpy(pcm->name, "ES1371 DAC2/ADC"); 1275 #endif 1276 ensoniq->pcm1 = pcm; 1277 1278 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1279 snd_dma_pci_data(ensoniq->pci), 64*1024, 128*1024); 1280 1281 if (rpcm) 1282 *rpcm = pcm; 1283 return 0; 1284 } 1285 1286 static int __devinit snd_ensoniq_pcm2(struct ensoniq * ensoniq, int device, 1287 struct snd_pcm ** rpcm) 1267 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1268 snd_pcm_std_chmaps, 2, 0, NULL); 1269 #endif 1270 return err; 1271 } 1272 1273 static int snd_ensoniq_pcm2(struct ensoniq *ensoniq, int device) 1288 1274 { 1289 1275 struct snd_pcm *pcm; 1290 1276 int err; 1291 1277 1292 if (rpcm) 1293 *rpcm = NULL; 1294 #ifdef CHIP1370 1295 err = snd_pcm_new(ensoniq->card, "ES1370/2", device, 1, 0, &pcm); 1296 #else 1297 err = snd_pcm_new(ensoniq->card, "ES1371/2", device, 1, 0, &pcm); 1298 #endif 1278 err = snd_pcm_new(ensoniq->card, CHIP_NAME "/2", device, 1, 0, &pcm); 1299 1279 if (err < 0) 1300 1280 return err; … … 1307 1287 pcm->private_data = ensoniq; 1308 1288 pcm->info_flags = 0; 1309 #ifdef CHIP1370 1310 strcpy(pcm->name, "ES1370 DAC1"); 1289 strcpy(pcm->name, CHIP_NAME " DAC1"); 1290 ensoniq->pcm2 = pcm; 1291 1292 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, 1293 &ensoniq->pci->dev, 64*1024, 128*1024); 1294 1295 #ifdef CHIP1370 1296 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1297 snd_pcm_std_chmaps, 2, 0, NULL); 1311 1298 #else 1312 strcpy(pcm->name, "ES1371 DAC1"); 1313 #endif 1314 ensoniq->pcm2 = pcm; 1315 1316 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1317 snd_dma_pci_data(ensoniq->pci), 64*1024, 128*1024); 1318 1319 if (rpcm) 1320 *rpcm = pcm; 1321 return 0; 1299 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1300 surround_map, 2, 0, NULL); 1301 #endif 1302 return err; 1322 1303 } 1323 1304 … … 1456 1437 1457 1438 /* spdif controls */ 1458 static struct snd_kcontrol_new snd_es1371_mixer_spdif[] __devinitdata= {1439 static const struct snd_kcontrol_new snd_es1371_mixer_spdif[] = { 1459 1440 ES1371_SPDIF(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH)), 1460 1441 { … … 1518 1499 } 1519 1500 1520 static struct snd_kcontrol_new snd_ens1373_rear __devinitdata=1501 static const struct snd_kcontrol_new snd_ens1373_rear = 1521 1502 { 1522 1503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 1536 1517 1537 1518 spin_lock_irq(&ensoniq->reg_lock); 1538 if ( (ensoniq->ctrl & ES_1371_GPIO_OUTM) >= 4)1519 if (ensoniq->ctrl & ES_1371_GPIO_OUT(4)) 1539 1520 val = 1; 1540 1521 ucontrol->value.integer.value[0] = val; … … 1563 1544 } 1564 1545 1565 static struct snd_kcontrol_new snd_ens1373_line __devinitdata=1546 static const struct snd_kcontrol_new snd_ens1373_line = 1566 1547 { 1567 1548 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, … … 1585 1566 1586 1567 static int es1371_quirk_lookup(struct ensoniq *ensoniq, 1587 1568 const struct es1371_quirk *list) 1588 1569 { 1589 1570 while (list->vid != (unsigned short)PCI_ANY_ID) { … … 1597 1578 } 1598 1579 1599 static struct es1371_quirk es1371_spdif_present[] __devinitdata= {1580 static const struct es1371_quirk es1371_spdif_present[] = { 1600 1581 { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C }, 1601 1582 { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D }, … … 1606 1587 }; 1607 1588 1608 static struct snd_pci_quirk ens1373_line_quirk[] __devinitdata= {1589 static const struct snd_pci_quirk ens1373_line_quirk[] = { 1609 1590 SND_PCI_QUIRK_ID(0x1274, 0x2000), /* GA-7DXR */ 1610 1591 SND_PCI_QUIRK_ID(0x1458, 0xa000), /* GA-8IEXP */ … … 1612 1593 }; 1613 1594 1614 static int __devinitsnd_ensoniq_1371_mixer(struct ensoniq *ensoniq,1615 1595 static int snd_ensoniq_1371_mixer(struct ensoniq *ensoniq, 1596 int has_spdif, int has_line) 1616 1597 { 1617 1598 struct snd_card *card = ensoniq->card; … … 1619 1600 struct snd_ac97_template ac97; 1620 1601 int err; 1621 static struct snd_ac97_bus_ops ops = {1602 static const struct snd_ac97_bus_ops ops = { 1622 1603 .write = snd_es1371_codec_write, 1623 1604 .read = snd_es1371_codec_read, … … 1721 1702 */ 1722 1703 1723 static struct snd_kcontrol_new snd_es1370_controls[2] __devinitdata= {1704 static const struct snd_kcontrol_new snd_es1370_controls[2] = { 1724 1705 ENSONIQ_CONTROL("PCM 0 Output also on Line-In Jack", ES_1370_XCTL0), 1725 1706 ENSONIQ_CONTROL("Mic +5V bias", ES_1370_XCTL1) … … 1734 1715 } 1735 1716 1736 static int __devinit snd_ensoniq_1370_mixer(struct ensoniq *ensoniq)1717 static int snd_ensoniq_1370_mixer(struct ensoniq *ensoniq) 1737 1718 { 1738 1719 struct snd_card *card = ensoniq->card; … … 1768 1749 1769 1750 #ifdef CHIP1371 1770 static int __devinit snd_ensoniq_get_joystick_port(int dev)1751 static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev) 1771 1752 { 1772 1753 switch (joystick_port[dev]) { … … 1780 1761 1781 1762 default: 1782 printk(KERN_ERR "ens1371: invalid joystick port %#x", joystick_port[dev]); 1763 dev_err(ensoniq->card->dev, 1764 "invalid joystick port %#x", joystick_port[dev]); 1783 1765 return 0; 1784 1766 } 1785 1767 } 1786 1768 #else 1787 static in line int snd_ensoniq_get_joystick_port(int dev)1769 static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev) 1788 1770 { 1789 1771 return joystick[dev] ? 0x200 : 0; … … 1791 1773 #endif 1792 1774 1793 static int __devinitsnd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev)1775 static int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev) 1794 1776 { 1795 1777 struct gameport *gp; 1796 1778 int io_port; 1797 1779 1798 io_port = snd_ensoniq_get_joystick_port( dev);1780 io_port = snd_ensoniq_get_joystick_port(ensoniq, dev); 1799 1781 1800 1782 switch (io_port) { … … 1807 1789 break; 1808 1790 if (io_port > 0x218) { 1809 printk(KERN_WARNING "ens137x: no gameport ports available\n"); 1791 dev_warn(ensoniq->card->dev, 1792 "no gameport ports available\n"); 1810 1793 return -EBUSY; 1811 1794 } … … 1814 1797 default: 1815 1798 if (!request_region(io_port, 8, "ens137x: gameport")) { 1816 printk(KERN_WARNING "ens137x: gameport io port 0x%#x in use\n", 1799 dev_warn(ensoniq->card->dev, 1800 "gameport io port %#x in use\n", 1817 1801 io_port); 1818 1802 return -EBUSY; … … 1823 1807 ensoniq->gameport = gp = gameport_allocate_port(); 1824 1808 if (!gp) { 1825 printk(KERN_ERR "ens137x: cannot allocate memory for gameport\n"); 1809 dev_err(ensoniq->card->dev, 1810 "cannot allocate memory for gameport\n"); 1826 1811 release_region(io_port, 8); 1827 1812 return -ENOMEM; … … 1866 1851 */ 1867 1852 1868 static void snd_ensoniq_proc_read(struct snd_info_entry *entry, 1853 static void snd_ensoniq_proc_read(struct snd_info_entry *entry, 1869 1854 struct snd_info_buffer *buffer) 1870 1855 { 1871 1856 struct ensoniq *ensoniq = entry->private_data; 1872 1857 1873 #ifdef CHIP1370 1874 snd_iprintf(buffer, "Ensoniq AudioPCI ES1370\n\n"); 1875 #else 1876 snd_iprintf(buffer, "Ensoniq AudioPCI ES1371\n\n"); 1877 #endif 1858 snd_iprintf(buffer, "Ensoniq AudioPCI " CHIP_NAME "\n\n"); 1878 1859 snd_iprintf(buffer, "Joystick enable : %s\n", 1879 1860 ensoniq->ctrl & ES_JYSTK_EN ? "on" : "off"); … … 1889 1870 } 1890 1871 1891 static void __devinit snd_ensoniq_proc_init(struct ensoniq * ensoniq) 1892 { 1893 struct snd_info_entry *entry; 1894 1895 if (! snd_card_proc_new(ensoniq->card, "audiopci", &entry)) 1896 snd_info_set_text_ops(entry, ensoniq, snd_ensoniq_proc_read); 1872 static void snd_ensoniq_proc_init(struct ensoniq *ensoniq) 1873 { 1874 snd_card_ro_proc_new(ensoniq->card, "audiopci", ensoniq, 1875 snd_ensoniq_proc_read); 1897 1876 } 1898 1877 … … 1913 1892 outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */ 1914 1893 #endif 1915 if (ensoniq->irq >= 0) 1916 synchronize_irq(ensoniq->irq); 1917 pci_set_power_state(ensoniq->pci, 3); 1894 pci_set_power_state(ensoniq->pci, PCI_D3hot); 1918 1895 __hw_end: 1919 1896 #ifdef CHIP1370 … … 1936 1913 1937 1914 #ifdef CHIP1371 1938 static struct snd_pci_quirk es1371_amplifier_hack[] __devinitdata= {1915 static const struct snd_pci_quirk es1371_amplifier_hack[] = { 1939 1916 SND_PCI_QUIRK_ID(0x107b, 0x2150), /* Gateway Solo 2150 */ 1940 1917 SND_PCI_QUIRK_ID(0x13bd, 0x100c), /* EV1938 on Mebius PC-MJ100V */ … … 1944 1921 }; 1945 1922 1946 static struct es1371_quirk es1371_ac97_reset_hack[] = {1923 static const struct es1371_quirk es1371_ac97_reset_hack[] = { 1947 1924 { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C }, 1948 1925 { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D }, … … 2015 1992 outb(0x00, ES_REG(ensoniq, UART_RES)); 2016 1993 outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); 2017 synchronize_irq(ensoniq->irq); 2018 } 2019 2020 #ifdef CONFIG_PM 2021 static int snd_ensoniq_suspend(struct pci_dev *pci, pm_message_t state) 2022 { 2023 struct snd_card *card = pci_get_drvdata(pci); 1994 } 1995 1996 #ifdef CONFIG_PM_SLEEP 1997 static int snd_ensoniq_suspend(struct device *dev) 1998 { 1999 struct snd_card *card = dev_get_drvdata(dev); 2024 2000 struct ensoniq *ensoniq = card->private_data; 2025 2001 2026 2002 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2027 2003 2028 snd_pcm_suspend_all(ensoniq->pcm1);2029 snd_pcm_suspend_all(ensoniq->pcm2);2030 2031 2004 #ifdef CHIP1371 2032 2005 snd_ac97_suspend(ensoniq->u.es1371.ac97); … … 2041 2014 snd_ak4531_suspend(ensoniq->u.es1370.ak4531); 2042 2015 #endif 2043 2044 pci_disable_device(pci); 2045 pci_save_state(pci); 2046 pci_set_power_state(pci, pci_choose_state(pci, state)); 2047 return 0; 2048 } 2049 2050 static int snd_ensoniq_resume(struct pci_dev *pci) 2051 { 2052 struct snd_card *card = pci_get_drvdata(pci); 2016 return 0; 2017 } 2018 2019 static int snd_ensoniq_resume(struct device *dev) 2020 { 2021 struct snd_card *card = dev_get_drvdata(dev); 2053 2022 struct ensoniq *ensoniq = card->private_data; 2054 2055 pci_set_power_state(pci, PCI_D0);2056 pci_restore_state(pci);2057 if (pci_enable_device(pci) < 0) {2058 printk(KERN_ERR DRIVER_NAME ": pci_enable_device failed, "2059 "disabling device\n");2060 snd_card_disconnect(card);2061 return -EIO;2062 }2063 pci_set_master(pci);2064 2023 2065 2024 snd_ensoniq_chip_init(ensoniq); … … 2073 2032 return 0; 2074 2033 } 2075 #endif /* CONFIG_PM */ 2076 2077 2078 static int __devinit snd_ensoniq_create(struct snd_card *card, 2079 struct pci_dev *pci, 2080 struct ensoniq ** rensoniq) 2034 2035 static SIMPLE_DEV_PM_OPS(snd_ensoniq_pm, snd_ensoniq_suspend, snd_ensoniq_resume); 2036 #define SND_ENSONIQ_PM_OPS &snd_ensoniq_pm 2037 #else 2038 #define SND_ENSONIQ_PM_OPS NULL 2039 #endif /* CONFIG_PM_SLEEP */ 2040 2041 static int snd_ensoniq_create(struct snd_card *card, 2042 struct pci_dev *pci, 2043 struct ensoniq **rensoniq) 2081 2044 { 2082 2045 struct ensoniq *ensoniq; 2083 2046 int err; 2084 static struct snd_device_ops ops = {2047 static const struct snd_device_ops ops = { 2085 2048 .dev_free = snd_ensoniq_dev_free, 2086 2049 }; … … 2106 2069 ensoniq->port = pci_resource_start(pci, 0); 2107 2070 if (request_irq(pci->irq, snd_audiopci_interrupt, IRQF_SHARED, 2108 "Ensoniq AudioPCI", ensoniq)) {2109 snd_printk(KERN_ERR"unable to grab IRQ %d\n", pci->irq);2071 KBUILD_MODNAME, ensoniq)) { 2072 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 2110 2073 snd_ensoniq_free(ensoniq); 2111 2074 return -EBUSY; 2112 2075 } 2113 2076 ensoniq->irq = pci->irq; 2114 #ifdef CHIP1370 2115 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 2077 card->sync_irq = ensoniq->irq; 2078 #ifdef CHIP1370 2079 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 2116 2080 16, &ensoniq->dma_bug) < 0) { 2117 snd_printk(KERN_ERR"unable to allocate space for phantom area - dma_bug\n");2081 dev_err(card->dev, "unable to allocate space for phantom area - dma_bug\n"); 2118 2082 snd_ensoniq_free(ensoniq); 2119 2083 return -EBUSY; … … 2153 2117 2154 2118 snd_ensoniq_proc_init(ensoniq); 2155 2156 snd_card_set_dev(card, &pci->dev);2157 2119 2158 2120 *rensoniq = ensoniq; … … 2321 2283 } 2322 2284 2323 static struct snd_rawmidi_ops snd_ensoniq_midi_output =2285 static const struct snd_rawmidi_ops snd_ensoniq_midi_output = 2324 2286 { 2325 2287 .open = snd_ensoniq_midi_output_open, … … 2328 2290 }; 2329 2291 2330 static struct snd_rawmidi_ops snd_ensoniq_midi_input =2292 static const struct snd_rawmidi_ops snd_ensoniq_midi_input = 2331 2293 { 2332 2294 .open = snd_ensoniq_midi_input_open, … … 2335 2297 }; 2336 2298 2337 static int __devinit snd_ensoniq_midi(struct ensoniq * ensoniq, int device, 2338 struct snd_rawmidi **rrawmidi) 2299 static int snd_ensoniq_midi(struct ensoniq *ensoniq, int device) 2339 2300 { 2340 2301 struct snd_rawmidi *rmidi; 2341 2302 int err; 2342 2303 2343 if (rrawmidi)2344 *rrawmidi = NULL;2345 2304 if ((err = snd_rawmidi_new(ensoniq->card, "ES1370/1", device, 1, 1, &rmidi)) < 0) 2346 2305 return err; 2347 #ifdef CHIP1370 2348 strcpy(rmidi->name, "ES1370"); 2349 #else 2350 strcpy(rmidi->name, "ES1371"); 2351 #endif 2306 strcpy(rmidi->name, CHIP_NAME); 2352 2307 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_ensoniq_midi_output); 2353 2308 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_ensoniq_midi_input); … … 2356 2311 rmidi->private_data = ensoniq; 2357 2312 ensoniq->rmidi = rmidi; 2358 if (rrawmidi)2359 *rrawmidi = rmidi;2360 2313 return 0; 2361 2314 } … … 2400 2353 } 2401 2354 2402 static int __devinitsnd_audiopci_probe(struct pci_dev *pci,2403 2355 static int snd_audiopci_probe(struct pci_dev *pci, 2356 const struct pci_device_id *pci_id) 2404 2357 { 2405 2358 static int dev; 2406 2359 struct snd_card *card; 2407 2360 struct ensoniq *ensoniq; 2408 int err , pcm_devs[2];2361 int err; 2409 2362 2410 2363 if (dev >= SNDRV_CARDS) … … 2415 2368 } 2416 2369 2417 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2370 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 2371 0, &card); 2418 2372 if (err < 0) 2419 2373 return err; … … 2425 2379 card->private_data = ensoniq; 2426 2380 2427 pcm_devs[0] = 0; pcm_devs[1] = 1;2428 2381 #ifdef CHIP1370 2429 2382 if ((err = snd_ensoniq_1370_mixer(ensoniq)) < 0) { … … 2438 2391 } 2439 2392 #endif 2440 if ((err = snd_ensoniq_pcm(ensoniq, 0 , NULL)) < 0) {2393 if ((err = snd_ensoniq_pcm(ensoniq, 0)) < 0) { 2441 2394 snd_card_free(card); 2442 2395 return err; 2443 2396 } 2444 if ((err = snd_ensoniq_pcm2(ensoniq, 1 , NULL)) < 0) {2397 if ((err = snd_ensoniq_pcm2(ensoniq, 1)) < 0) { 2445 2398 snd_card_free(card); 2446 2399 return err; 2447 2400 } 2448 if ((err = snd_ensoniq_midi(ensoniq, 0 , NULL)) < 0) {2401 if ((err = snd_ensoniq_midi(ensoniq, 0)) < 0) { 2449 2402 snd_card_free(card); 2450 2403 return err; … … 2472 2425 } 2473 2426 2474 static void __devexitsnd_audiopci_remove(struct pci_dev *pci)2427 static void snd_audiopci_remove(struct pci_dev *pci) 2475 2428 { 2476 2429 snd_card_free(pci_get_drvdata(pci)); 2477 pci_set_drvdata(pci, NULL); 2478 } 2479 2480 static struct pci_driver driver = { 2481 .name = DRIVER_NAME, 2430 } 2431 2432 static struct pci_driver ens137x_driver = { 2433 .name = KBUILD_MODNAME, 2482 2434 .id_table = snd_audiopci_ids, 2483 2435 .probe = snd_audiopci_probe, 2484 .remove = __devexit_p(snd_audiopci_remove), 2485 #ifdef CONFIG_PM 2486 .suspend = snd_ensoniq_suspend, 2487 .resume = snd_ensoniq_resume, 2488 #endif 2436 .remove = snd_audiopci_remove, 2437 .driver = { 2438 .pm = SND_ENSONIQ_PM_OPS, 2439 }, 2489 2440 }; 2490 2441 2491 #ifdef CHIP1370 2492 static int __init alsa_card_ens1370_init(void) 2493 { 2494 return pci_register_driver(&driver); 2495 } 2496 2497 static void __exit alsa_card_ens1370_exit(void) 2498 { 2499 pci_unregister_driver(&driver); 2500 } 2501 module_init(alsa_card_ens1370_init) 2502 module_exit(alsa_card_ens1370_exit) 2503 #endif 2504 2505 #ifdef CHIP1371 2506 static int __init alsa_card_ens1371_init(void) 2507 { 2508 return pci_register_driver(&driver); 2509 } 2510 2511 static void __exit alsa_card_ens1371_exit(void) 2512 { 2513 pci_unregister_driver(&driver); 2514 } 2515 module_init(alsa_card_ens1371_init) 2516 module_exit(alsa_card_ens1371_exit) 2517 #endif 2518 2519 2442 module_pci_driver(ens137x_driver);
Note:
See TracChangeset
for help on using the changeset viewer.