1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
9 - sometimes the sound is metallic and sibilant, unloading and
10 reloading the module may solve this.
13 #include <linux/pci.h>
14 #include <linux/time.h>
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <sound/core.h>
19 #include <sound/initval.h>
21 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
22 MODULE_DESCRIPTION("Cirrus Logic Sound Fusion CS46XX");
23 MODULE_LICENSE("GPL");
24 MODULE_SUPPORTED_DEVICE("{{Cirrus Logic,Sound Fusion (CS4280)},"
25 "{Cirrus Logic,Sound Fusion (CS4610)},"
26 "{Cirrus Logic,Sound Fusion (CS4612)},"
27 "{Cirrus Logic,Sound Fusion (CS4615)},"
28 "{Cirrus Logic,Sound Fusion (CS4622)},"
29 "{Cirrus Logic,Sound Fusion (CS4624)},"
30 "{Cirrus Logic,Sound Fusion (CS4630)}}");
32 static int index
[SNDRV_CARDS
] = SNDRV_DEFAULT_IDX
; /* Index 0-MAX */
33 static char *id
[SNDRV_CARDS
] = SNDRV_DEFAULT_STR
; /* ID for this card */
34 static bool enable
[SNDRV_CARDS
] = SNDRV_DEFAULT_ENABLE_PNP
; /* Enable this card */
35 static bool external_amp
[SNDRV_CARDS
];
36 static bool thinkpad
[SNDRV_CARDS
];
37 static bool mmap_valid
[SNDRV_CARDS
] = {[0 ... (SNDRV_CARDS
- 1)] = 1};
39 module_param_array(index
, int, NULL
, 0444);
40 MODULE_PARM_DESC(index
, "Index value for the CS46xx soundcard.");
41 module_param_array(id
, charp
, NULL
, 0444);
42 MODULE_PARM_DESC(id
, "ID string for the CS46xx soundcard.");
43 module_param_array(enable
, bool, NULL
, 0444);
44 MODULE_PARM_DESC(enable
, "Enable CS46xx soundcard.");
45 module_param_array(external_amp
, bool, NULL
, 0444);
46 MODULE_PARM_DESC(external_amp
, "Force to enable external amplifier.");
47 module_param_array(thinkpad
, bool, NULL
, 0444);
48 MODULE_PARM_DESC(thinkpad
, "Force to enable Thinkpad's CLKRUN control.");
49 module_param_array(mmap_valid
, bool, NULL
, 0444);
50 MODULE_PARM_DESC(mmap_valid
, "Support OSS mmap.");
52 static const struct pci_device_id snd_cs46xx_ids
[] = {
53 { PCI_VDEVICE(CIRRUS
, 0x6001), 0, }, /* CS4280 */
54 { PCI_VDEVICE(CIRRUS
, 0x6003), 0, }, /* CS4612 */
55 { PCI_VDEVICE(CIRRUS
, 0x6004), 0, }, /* CS4615 */
59 MODULE_DEVICE_TABLE(pci
, snd_cs46xx_ids
);
61 static int snd_card_cs46xx_probe(struct pci_dev
*pci
,
62 const struct pci_device_id
*pci_id
)
65 struct snd_card
*card
;
66 struct snd_cs46xx
*chip
;
69 if (dev
>= SNDRV_CARDS
)
76 err
= snd_card_new(&pci
->dev
, index
[dev
], id
[dev
], THIS_MODULE
,
80 if ((err
= snd_cs46xx_create(card
, pci
,
81 external_amp
[dev
], thinkpad
[dev
],
86 card
->private_data
= chip
;
87 chip
->accept_valid
= mmap_valid
[dev
];
88 if ((err
= snd_cs46xx_pcm(chip
, 0)) < 0) {
92 #ifdef CONFIG_SND_CS46XX_NEW_DSP
93 if ((err
= snd_cs46xx_pcm_rear(chip
, 1)) < 0) {
97 if ((err
= snd_cs46xx_pcm_iec958(chip
, 2)) < 0) {
102 if ((err
= snd_cs46xx_mixer(chip
, 2)) < 0) {
106 #ifdef CONFIG_SND_CS46XX_NEW_DSP
107 if (chip
->nr_ac97_codecs
==2) {
108 if ((err
= snd_cs46xx_pcm_center_lfe(chip
, 3)) < 0) {
114 if ((err
= snd_cs46xx_midi(chip
, 0)) < 0) {
118 if ((err
= snd_cs46xx_start_dsp(chip
)) < 0) {
124 snd_cs46xx_gameport(chip
);
126 strcpy(card
->driver
, "CS46xx");
127 strcpy(card
->shortname
, "Sound Fusion CS46xx");
128 sprintf(card
->longname
, "%s at 0x%lx/0x%lx, irq %i",
134 if ((err
= snd_card_register(card
)) < 0) {
139 pci_set_drvdata(pci
, card
);
144 static void snd_card_cs46xx_remove(struct pci_dev
*pci
)
146 snd_card_free(pci_get_drvdata(pci
));
149 static struct pci_driver cs46xx_driver
= {
150 .name
= KBUILD_MODNAME
,
151 .id_table
= snd_cs46xx_ids
,
152 .probe
= snd_card_cs46xx_probe
,
153 .remove
= snd_card_cs46xx_remove
,
154 #ifdef CONFIG_PM_SLEEP
156 .pm
= &snd_cs46xx_pm
,
161 module_pci_driver(cs46xx_driver
);