diff options
Diffstat (limited to 'sound/pci/pcxhr/pcxhr.c')
-rw-r--r-- | sound/pci/pcxhr/pcxhr.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 27cf2c28d113..80e064a3efff 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c | |||
@@ -1334,6 +1334,40 @@ static void pcxhr_proc_sync(struct snd_info_entry *entry, | |||
1334 | snd_iprintf(buffer, "\n"); | 1334 | snd_iprintf(buffer, "\n"); |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | static void pcxhr_proc_gpio_read(struct snd_info_entry *entry, | ||
1338 | struct snd_info_buffer *buffer) | ||
1339 | { | ||
1340 | struct snd_pcxhr *chip = entry->private_data; | ||
1341 | struct pcxhr_mgr *mgr = chip->mgr; | ||
1342 | /* commands available when embedded DSP is running */ | ||
1343 | if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { | ||
1344 | /* gpio ports on stereo boards only available */ | ||
1345 | int value = 0; | ||
1346 | hr222_read_gpio(mgr, 1, &value); /* GPI */ | ||
1347 | snd_iprintf(buffer, "GPI: 0x%x\n", value); | ||
1348 | hr222_read_gpio(mgr, 0, &value); /* GP0 */ | ||
1349 | snd_iprintf(buffer, "GPO: 0x%x\n", value); | ||
1350 | } else | ||
1351 | snd_iprintf(buffer, "no firmware loaded\n"); | ||
1352 | snd_iprintf(buffer, "\n"); | ||
1353 | } | ||
1354 | static void pcxhr_proc_gpo_write(struct snd_info_entry *entry, | ||
1355 | struct snd_info_buffer *buffer) | ||
1356 | { | ||
1357 | struct snd_pcxhr *chip = entry->private_data; | ||
1358 | struct pcxhr_mgr *mgr = chip->mgr; | ||
1359 | char line[64]; | ||
1360 | int value; | ||
1361 | /* commands available when embedded DSP is running */ | ||
1362 | if (!(mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX))) | ||
1363 | return; | ||
1364 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | ||
1365 | if (sscanf(line, "GPO: 0x%x", &value) != 1) | ||
1366 | continue; | ||
1367 | hr222_write_gpo(mgr, value); /* GP0 */ | ||
1368 | } | ||
1369 | } | ||
1370 | |||
1337 | static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip) | 1371 | static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip) |
1338 | { | 1372 | { |
1339 | struct snd_info_entry *entry; | 1373 | struct snd_info_entry *entry; |
@@ -1342,6 +1376,13 @@ static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip) | |||
1342 | snd_info_set_text_ops(entry, chip, pcxhr_proc_info); | 1376 | snd_info_set_text_ops(entry, chip, pcxhr_proc_info); |
1343 | if (! snd_card_proc_new(chip->card, "sync", &entry)) | 1377 | if (! snd_card_proc_new(chip->card, "sync", &entry)) |
1344 | snd_info_set_text_ops(entry, chip, pcxhr_proc_sync); | 1378 | snd_info_set_text_ops(entry, chip, pcxhr_proc_sync); |
1379 | /* gpio available on stereo sound cards only */ | ||
1380 | if (chip->mgr->is_hr_stereo && | ||
1381 | !snd_card_proc_new(chip->card, "gpio", &entry)) { | ||
1382 | snd_info_set_text_ops(entry, chip, pcxhr_proc_gpio_read); | ||
1383 | entry->c.text.write = pcxhr_proc_gpo_write; | ||
1384 | entry->mode |= S_IWUSR; | ||
1385 | } | ||
1345 | } | 1386 | } |
1346 | /* end of proc interface */ | 1387 | /* end of proc interface */ |
1347 | 1388 | ||
@@ -1510,12 +1551,12 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, | |||
1510 | 1551 | ||
1511 | snprintf(tmpid, sizeof(tmpid), "%s-%d", | 1552 | snprintf(tmpid, sizeof(tmpid), "%s-%d", |
1512 | id[dev] ? id[dev] : card_name, i); | 1553 | id[dev] ? id[dev] : card_name, i); |
1513 | card = snd_card_new(idx, tmpid, THIS_MODULE, 0); | 1554 | err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card); |
1514 | 1555 | ||
1515 | if (! card) { | 1556 | if (err < 0) { |
1516 | snd_printk(KERN_ERR "cannot allocate the card %d\n", i); | 1557 | snd_printk(KERN_ERR "cannot allocate the card %d\n", i); |
1517 | pcxhr_free(mgr); | 1558 | pcxhr_free(mgr); |
1518 | return -ENOMEM; | 1559 | return err; |
1519 | } | 1560 | } |
1520 | 1561 | ||
1521 | strcpy(card->driver, DRIVER_NAME); | 1562 | strcpy(card->driver, DRIVER_NAME); |