📄 cs4236.c
字号:
/* * Driver for generic CS4232/CS4235/CS4236/CS4236B/CS4237B/CS4238B/CS4239 chips * Copyright (c) by Jaroslav Kysela <perex@suse.cz> * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */#include <sound/driver.h>#include <linux/init.h>#include <linux/slab.h>#ifndef LINUX_ISAPNP_H#include <linux/isapnp.h>#define isapnp_card pci_bus#define isapnp_dev pci_dev#endif#include <sound/core.h>#include <sound/cs4231.h>#include <sound/mpu401.h>#include <sound/opl3.h>#define SNDRV_GET_ID#include <sound/initval.h>#define chip_t cs4231_tEXPORT_NO_SYMBOLS;MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");MODULE_LICENSE("GPL");MODULE_CLASSES("{sound}");#ifdef CS4232MODULE_DESCRIPTION("Cirrus Logic CS4232");MODULE_DEVICES("{{Turtle Beach,TBS-2000}," "{Turtle Beach,Tropez Plus}," "{SIC CrystalWave 32}," "{Hewlett Packard,Omnibook 5500}," "{TerraTec,Maestro 32/96}," "{Philips,PCA70PS}}");#elseMODULE_DESCRIPTION("Cirrus Logic CS4235-9");MODULE_DEVICES("{{Crystal Semiconductors,CS4235}," "{Crystal Semiconductors,CS4236}," "{Crystal Semiconductors,CS4237}," "{Crystal Semiconductors,CS4238}," "{Crystal Semiconductors,CS4239}," "{Acer,AW37}," "{Acer,AW35/Pro}," "{Crystal,3D}," "{Crystal Computer,TidalWave128}," "{Dell,Optiplex GX1}," "{Dell,Workstation 400 sound}," "{EliteGroup,P5TX-LA sound}," "{Gallant,SC-70P}," "{Gateway,E1000 Onboard CS4236B}," "{Genius,Sound Maker 3DJ}," "{Hewlett Packard,HP6330 sound}," "{IBM,PC 300PL sound}," "{IBM,Aptiva 2137 E24}," "{IBM,IntelliStation M Pro}," "{Intel,Marlin Spike Mobo CS4235}," "{Guillemot,MaxiSound 16 PnP}," "{NewClear,3D}," "{TerraTec,AudioSystem EWS64L/XL}," "{Typhoon Soundsystem,CS4236B}," "{Turtle Beach,Malibu}," "{Unknown,Digital PC 5000 Onboard}}");#endif#ifdef CS4232#define IDENT "CS4232"#else#define IDENT "CS4236+"#endifstatic int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */#ifdef __ISAPNP__static int snd_isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};#endifstatic long snd_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */static long snd_cport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */static long snd_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* PnP setup */static long snd_fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */static long snd_sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */static int snd_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */static int snd_mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 9,11,12,15 */static int snd_dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */static int snd_dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");MODULE_PARM_DESC(snd_index, "Index value for " IDENT " soundcard.");MODULE_PARM_SYNTAX(snd_index, SNDRV_INDEX_DESC);MODULE_PARM(snd_id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");MODULE_PARM_DESC(snd_id, "ID string for " IDENT " soundcard.");MODULE_PARM_SYNTAX(snd_id, SNDRV_ID_DESC);MODULE_PARM(snd_enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");MODULE_PARM_DESC(snd_enable, "Enable " IDENT " soundcard.");MODULE_PARM_SYNTAX(snd_enable, SNDRV_ENABLE_DESC);#ifdef __ISAPNP__MODULE_PARM(snd_isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");MODULE_PARM_DESC(snd_isapnp, "ISA PnP detection for specified soundcard.");MODULE_PARM_SYNTAX(snd_isapnp, SNDRV_ISAPNP_DESC);#endifMODULE_PARM(snd_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");MODULE_PARM_DESC(snd_port, "Port # for " IDENT " driver.");MODULE_PARM_SYNTAX(snd_port, SNDRV_PORT12_DESC);MODULE_PARM(snd_cport, "1-" __MODULE_STRING(SNDRV_CARDS) "l");MODULE_PARM_DESC(snd_cport, "Control port # for " IDENT " driver.");MODULE_PARM_SYNTAX(snd_cport, SNDRV_PORT12_DESC);MODULE_PARM(snd_mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");MODULE_PARM_DESC(snd_mpu_port, "MPU-401 port # for " IDENT " driver.");MODULE_PARM_SYNTAX(snd_mpu_port, SNDRV_PORT12_DESC);MODULE_PARM(snd_fm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");MODULE_PARM_DESC(snd_fm_port, "FM port # for " IDENT " driver.");MODULE_PARM_SYNTAX(snd_fm_port, SNDRV_PORT12_DESC);MODULE_PARM(snd_sb_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");MODULE_PARM_DESC(snd_sb_port, "SB port # for " IDENT " driver (optional).");MODULE_PARM_SYNTAX(snd_sb_port, SNDRV_PORT12_DESC);MODULE_PARM(snd_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");MODULE_PARM_DESC(snd_irq, "IRQ # for " IDENT " driver.");MODULE_PARM_SYNTAX(snd_irq, SNDRV_IRQ_DESC);MODULE_PARM(snd_mpu_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");MODULE_PARM_DESC(snd_mpu_irq, "MPU-401 IRQ # for " IDENT " driver.");MODULE_PARM_SYNTAX(snd_mpu_irq, SNDRV_IRQ_DESC);MODULE_PARM(snd_dma1, "1-" __MODULE_STRING(SNDRV_CARDS) "i");MODULE_PARM_DESC(snd_dma1, "DMA1 # for " IDENT " driver.");MODULE_PARM_SYNTAX(snd_dma1, SNDRV_DMA_DESC);MODULE_PARM(snd_dma2, "1-" __MODULE_STRING(SNDRV_CARDS) "i");MODULE_PARM_DESC(snd_dma2, "DMA2 # for " IDENT " driver.");MODULE_PARM_SYNTAX(snd_dma2, SNDRV_DMA_DESC);struct snd_card_cs4236 { struct resource *res_sb_port;#ifdef __ISAPNP__ struct isapnp_dev *wss; struct isapnp_dev *ctrl; struct isapnp_dev *mpu;#endif};static snd_card_t *snd_cs4236_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;#ifdef __ISAPNP__static struct isapnp_card *snd_cs4236_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR;static const struct isapnp_card_id *snd_cs4236_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR;#define ISAPNP_CS4232(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \ { \ ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ devs : { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \ ISAPNP_DEVICE_ID(_va, _vb, _vc, _mpu401) } \ }#define ISAPNP_CS4232_1(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \ { \ ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ devs : { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \ ISAPNP_DEVICE_ID('P', 'N', 'P', _mpu401) } \ }#define ISAPNP_CS4232_WOMPU(_va, _vb, _vc, _device, _wss, _ctrl) \ { \ ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ devs : { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl) } \ }#ifdef CS4232static struct isapnp_card_id snd_card_pnpids[] __devinitdata = { /* Philips PCA70PS */ ISAPNP_CS4232_1('C','S','C',0x0d32,0x0000,0x0010,0xb006), /* TerraTec Maestro 32/96 (CS4232) */ ISAPNP_CS4232('C','S','C',0x1a32,0x0000,0x0010,0x0003), /* HP Omnibook 5500 onboard */ ISAPNP_CS4232('C','S','C',0x4232,0x0000,0x0002,0x0003), /* Turtle Beach TBS-2000 (CS4232) */ ISAPNP_CS4232('C','S','C',0x7532,0x0000,0x0010,0xb006), /* Turtle Beach Tropez Plus (CS4232) */ ISAPNP_CS4232_1('C','S','C',0x7632,0x0000,0x0010,0xb006), /* SIC CrystalWave 32 (CS4232) */ ISAPNP_CS4232('C','S','C',0xf032,0x0000,0x0010,0x0003), /* --- */ { ISAPNP_CARD_END, } /* end */};#else /* CS4236 */static struct isapnp_card_id snd_card_pnpids[] __devinitdata = { /* Intel Marlin Spike Motherboard - CS4235 */ ISAPNP_CS4232('C','S','C',0x0225,0x0000,0x0010,0x0003), /* Intel Marlin Spike Motherboard (#2) - CS4235 */ ISAPNP_CS4232('C','S','C',0x0225,0x0100,0x0110,0x0103), /* Genius Sound Maker 3DJ - CS4237B */ ISAPNP_CS4232('C','S','C',0x0437,0x0000,0x0010,0x0003), /* Digital PC 5000 Onboard - CS4236B */ ISAPNP_CS4232_WOMPU('C','S','C',0x0735,0x0000,0x0010), /* some uknown CS4236B */ ISAPNP_CS4232('C','S','C',0x0b35,0x0000,0x0010,0x0003), /* CS4235 on mainboard without MPU */ ISAPNP_CS4232_WOMPU('C','S','C',0x1425,0x0100,0x0110), /* Gateway E1000 Onboard CS4236B */ ISAPNP_CS4232('C','S','C',0x1335,0x0000,0x0010,0x0003), /* HP 6330 Onboard sound */ ISAPNP_CS4232('C','S','C',0x1525,0x0100,0x0110,0x0103), /* Crystal Computer TidalWave128 */ ISAPNP_CS4232('C','S','C',0x1e37,0x0000,0x0010,0x0003), /* ACER AW37 - CS4235 */ ISAPNP_CS4232('C','S','C',0x4236,0x0000,0x0010,0x0003), /* build-in soundcard in EliteGroup P5TX-LA motherboard - CS4237B */ ISAPNP_CS4232('C','S','C',0x4237,0x0000,0x0010,0x0003), /* Crystal 3D - CS4237B */ ISAPNP_CS4232('C','S','C',0x4336,0x0000,0x0010,0x0003), /* Typhoon Soundsystem PnP - CS4236B */ ISAPNP_CS4232('C','S','C',0x4536,0x0000,0x0010,0x0003), /* TerraTec AudioSystem EWS64XL - CS4236B */ ISAPNP_CS4232('C','S','C',0xa836,0xa800,0xa810,0xa803), /* Crystal Semiconductors CS4237B */ ISAPNP_CS4232('C','S','C',0x4637,0x0000,0x0010,0x0003), /* NewClear 3D - CX4237B-XQ3 */ ISAPNP_CS4232('C','S','C',0x4837,0x0000,0x0010,0x0003), /* Dell Optiplex GX1 - CS4236B */ ISAPNP_CS4232('C','S','C',0x6835,0x0000,0x0010,0x0003), /* Dell P410 motherboard - CS4236B */ ISAPNP_CS4232_WOMPU('C','S','C',0x6835,0x0000,0x0010), /* Dell Workstation 400 Onboard - CS4236B */ ISAPNP_CS4232('C','S','C',0x6836,0x0000,0x0010,0x0003), /* Turtle Beach Malibu - CS4237B */ ISAPNP_CS4232('C','S','C',0x7537,0x0000,0x0010,0x0003), /* CS4235 - onboard */ ISAPNP_CS4232('C','S','C',0x8025,0x0100,0x0110,0x0103), /* IBM PC 300PL Onboard - CS4236B */ ISAPNP_CS4232_WOMPU('C','S','C',0xe836,0x0000,0x0010), /* IBM Aptiva 2137 E24 Onboard - CS4237B */ ISAPNP_CS4232('C','S','C',0x8037,0x0000,0x0010,0x0003), /* IBM IntelliStation M Pro motherboard */ ISAPNP_CS4232_WOMPU('C','S','C',0xc835,0x0000,0x0010), /* Guillemot MaxiSound 16 PnP - CS4236B */ ISAPNP_CS4232('C','S','C',0x9836,0x0000,0x0010,0x0003), /* Gallant SC-70P */ ISAPNP_CS4232('C','S','C',0x9837,0x0000,0x0010,0x0003), /* ACER AW37/Pro - CS4235 */ ISAPNP_CS4232('C','S','C',0xd925,0x0000,0x0010,0x0003), /* ACER AW35/Pro - CS4237B */ ISAPNP_CS4232('C','S','C',0xd937,0x0000,0x0010,0x0003), /* CS4235 without MPU401 */ ISAPNP_CS4232_WOMPU('C','S','C',0xe825,0x0100,0x0110), /* CS4236B */ ISAPNP_CS4232('C','S','C',0xf235,0x0000,0x0010,0x0003), /* CS4236B */ ISAPNP_CS4232('C','S','C',0xf238,0x0000,0x0010,0x0003), /* --- */ { ISAPNP_CARD_END, } /* end */};#endifISAPNP_CARD_TABLE(snd_card_pnpids);static int __init snd_card_cs4236_isapnp(int dev, struct snd_card_cs4236 *acard){ const struct isapnp_card_id *id = snd_cs4236_isapnp_id[dev]; struct isapnp_card *card = snd_cs4236_isapnp_cards[dev]; struct isapnp_dev *pdev; acard->wss = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); if (acard->wss->active) { acard->wss = NULL; return -EBUSY; } acard->ctrl = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL); if (acard->ctrl->active) { acard->wss = acard->ctrl = NULL; return -EBUSY; } if (id->devs[2].vendor && id->devs[2].function) { acard->mpu = isapnp_find_dev(card, id->devs[2].vendor, id->devs[2].function, NULL); if (acard->mpu->active) { acard->wss = acard->ctrl = acard->mpu = NULL; return -EBUSY; } } /* WSS initialization */ pdev = acard->wss; if (pdev->prepare(pdev) < 0) return -EAGAIN; if (snd_port[dev] != SNDRV_AUTO_PORT) isapnp_resource_change(&pdev->resource[0], snd_port[dev], 4); if (snd_fm_port[dev] != SNDRV_AUTO_PORT) isapnp_resource_change(&pdev->resource[1], snd_fm_port[dev], 4); if (snd_sb_port[dev] != SNDRV_AUTO_PORT) isapnp_resource_change(&pdev->resource[2], snd_sb_port[dev], 16); if (snd_irq[dev] != SNDRV_AUTO_IRQ) isapnp_resource_change(&pdev->irq_resource[0], snd_irq[dev], 1); if (snd_dma1[dev] != SNDRV_AUTO_DMA) isapnp_resource_change(&pdev->dma_resource[0], snd_dma1[dev], 1); if (snd_dma2[dev] != SNDRV_AUTO_DMA) isapnp_resource_change(&pdev->dma_resource[1], snd_dma2[dev] < 0 ? 4 : snd_dma2[dev], 1); if (pdev->activate(pdev)<0) { printk(KERN_ERR IDENT " isapnp configure failed for WSS (out of resources?)\n"); return -EBUSY; } snd_port[dev] = pdev->resource[0].start; snd_fm_port[dev] = pdev->resource[1].start; snd_sb_port[dev] = pdev->resource[2].start; snd_irq[dev] = pdev->irq_resource[0].start; snd_dma1[dev] = pdev->dma_resource[0].start; snd_dma2[dev] = pdev->dma_resource[1].start == 4 ? -1 : pdev->dma_resource[1].start; snd_printdd("isapnp WSS: wss port=0x%lx, fm port=0x%lx, sb port=0x%lx\n",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -