Commit bcc2c6b7 authored by Stas Sergeev's avatar Stas Sergeev Committed by Takashi Iwai

ALSA: snd-pcsp: add nopcm mode

Currently, if the high-res timers are unavailable, snd-pcsp does not
initialize. People who choose it over pcspkr, loose their console beeps
in that case and get annoyed.
With this patch, the console beeps remain regardless of the high-res
timers. Additionally, the "nopcm" modparam is added to forcibly
disable the PCM capabilities of the driver.
Signed-off-by: default avatarStas Sergeev <stsp@aknet.ru>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent e87a3dd3
...@@ -1454,6 +1454,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. ...@@ -1454,6 +1454,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
Module for internal PC-Speaker. Module for internal PC-Speaker.
nopcm - Disable PC-Speaker PCM sound. Only beeps remain.
nforce_wa - enable NForce chipset workaround. Expect bad sound. nforce_wa - enable NForce chipset workaround. Expect bad sound.
This module supports system beeps, some kind of PCM playback and This module supports system beeps, some kind of PCM playback and
......
...@@ -26,6 +26,7 @@ MODULE_ALIAS("platform:pcspkr"); ...@@ -26,6 +26,7 @@ MODULE_ALIAS("platform:pcspkr");
static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */ static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */
static int nopcm; /* Disable PCM capability of the driver */
module_param(index, int, 0444); module_param(index, int, 0444);
MODULE_PARM_DESC(index, "Index value for pcsp soundcard."); MODULE_PARM_DESC(index, "Index value for pcsp soundcard.");
...@@ -33,6 +34,8 @@ module_param(id, charp, 0444); ...@@ -33,6 +34,8 @@ module_param(id, charp, 0444);
MODULE_PARM_DESC(id, "ID string for pcsp soundcard."); MODULE_PARM_DESC(id, "ID string for pcsp soundcard.");
module_param(enable, bool, 0444); module_param(enable, bool, 0444);
MODULE_PARM_DESC(enable, "Enable PC-Speaker sound."); MODULE_PARM_DESC(enable, "Enable PC-Speaker sound.");
module_param(nopcm, bool, 0444);
MODULE_PARM_DESC(nopcm, "Disable PC-Speaker PCM sound. Only beeps remain.");
struct snd_pcsp pcsp_chip; struct snd_pcsp pcsp_chip;
...@@ -43,13 +46,16 @@ static int __devinit snd_pcsp_create(struct snd_card *card) ...@@ -43,13 +46,16 @@ static int __devinit snd_pcsp_create(struct snd_card *card)
int err; int err;
int div, min_div, order; int div, min_div, order;
if (!nopcm) {
hrtimer_get_res(CLOCK_MONOTONIC, &tp); hrtimer_get_res(CLOCK_MONOTONIC, &tp);
if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) { if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) {
printk(KERN_ERR "PCSP: Timer resolution is not sufficient " printk(KERN_ERR "PCSP: Timer resolution is not sufficient "
"(%linS)\n", tp.tv_nsec); "(%linS)\n", tp.tv_nsec);
printk(KERN_ERR "PCSP: Make sure you have HPET and ACPI " printk(KERN_ERR "PCSP: Make sure you have HPET and ACPI "
"enabled.\n"); "enabled.\n");
return -EIO; printk(KERN_ERR "PCSP: Turned into nopcm mode.\n");
nopcm = 1;
}
} }
if (loops_per_jiffy >= PCSP_MIN_LPJ && tp.tv_nsec <= PCSP_MIN_PERIOD_NS) if (loops_per_jiffy >= PCSP_MIN_LPJ && tp.tv_nsec <= PCSP_MIN_PERIOD_NS)
...@@ -107,12 +113,14 @@ static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev) ...@@ -107,12 +113,14 @@ static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev)
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
if (!nopcm) {
err = snd_pcsp_new_pcm(&pcsp_chip); err = snd_pcsp_new_pcm(&pcsp_chip);
if (err < 0) { if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
err = snd_pcsp_new_mixer(&pcsp_chip); }
err = snd_pcsp_new_mixer(&pcsp_chip, nopcm);
if (err < 0) { if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
......
...@@ -83,6 +83,6 @@ extern enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle); ...@@ -83,6 +83,6 @@ extern enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle);
extern void pcsp_sync_stop(struct snd_pcsp *chip); extern void pcsp_sync_stop(struct snd_pcsp *chip);
extern int snd_pcsp_new_pcm(struct snd_pcsp *chip); extern int snd_pcsp_new_pcm(struct snd_pcsp *chip);
extern int snd_pcsp_new_mixer(struct snd_pcsp *chip); extern int snd_pcsp_new_mixer(struct snd_pcsp *chip, int nopcm);
#endif #endif
...@@ -119,24 +119,43 @@ static int pcsp_pcspkr_put(struct snd_kcontrol *kcontrol, ...@@ -119,24 +119,43 @@ static int pcsp_pcspkr_put(struct snd_kcontrol *kcontrol,
.put = pcsp_##ctl_type##_put, \ .put = pcsp_##ctl_type##_put, \
} }
static struct snd_kcontrol_new __devinitdata snd_pcsp_controls[] = { static struct snd_kcontrol_new __devinitdata snd_pcsp_controls_pcm[] = {
PCSP_MIXER_CONTROL(enable, "Master Playback Switch"), PCSP_MIXER_CONTROL(enable, "Master Playback Switch"),
PCSP_MIXER_CONTROL(treble, "BaseFRQ Playback Volume"), PCSP_MIXER_CONTROL(treble, "BaseFRQ Playback Volume"),
};
static struct snd_kcontrol_new __devinitdata snd_pcsp_controls_spkr[] = {
PCSP_MIXER_CONTROL(pcspkr, "PC Speaker Playback Switch"), PCSP_MIXER_CONTROL(pcspkr, "PC Speaker Playback Switch"),
}; };
int __devinit snd_pcsp_new_mixer(struct snd_pcsp *chip) static int __devinit snd_pcsp_ctls_add(struct snd_pcsp *chip,
struct snd_kcontrol_new *ctls, int num)
{ {
struct snd_card *card = chip->card;
int i, err; int i, err;
struct snd_card *card = chip->card;
for (i = 0; i < num; i++) {
err = snd_ctl_add(card, snd_ctl_new1(ctls + i, chip));
if (err < 0)
return err;
}
return 0;
}
for (i = 0; i < ARRAY_SIZE(snd_pcsp_controls); i++) { int __devinit snd_pcsp_new_mixer(struct snd_pcsp *chip, int nopcm)
err = snd_ctl_add(card, {
snd_ctl_new1(snd_pcsp_controls + i, int err;
chip)); struct snd_card *card = chip->card;
if (!nopcm) {
err = snd_pcsp_ctls_add(chip, snd_pcsp_controls_pcm,
ARRAY_SIZE(snd_pcsp_controls_pcm));
if (err < 0) if (err < 0)
return err; return err;
} }
err = snd_pcsp_ctls_add(chip, snd_pcsp_controls_spkr,
ARRAY_SIZE(snd_pcsp_controls_spkr));
if (err < 0)
return err;
strcpy(card->mixername, "PC-Speaker"); strcpy(card->mixername, "PC-Speaker");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment