diff options
Diffstat (limited to 'sound/pci/asihpi/asihpi.c')
-rw-r--r-- | sound/pci/asihpi/asihpi.c | 81 |
1 files changed, 66 insertions, 15 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index e3569bdd3b64..b941d2541dda 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c | |||
@@ -49,19 +49,21 @@ MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); | |||
49 | #if defined CONFIG_SND_DEBUG | 49 | #if defined CONFIG_SND_DEBUG |
50 | /* copied from pcm_lib.c, hope later patch will make that version public | 50 | /* copied from pcm_lib.c, hope later patch will make that version public |
51 | and this copy can be removed */ | 51 | and this copy can be removed */ |
52 | static void pcm_debug_name(struct snd_pcm_substream *substream, | 52 | static inline void |
53 | char *name, size_t len) | 53 | snd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size) |
54 | { | 54 | { |
55 | snprintf(name, len, "pcmC%dD%d%c:%d", | 55 | snprintf(buf, size, "pcmC%dD%d%c:%d", |
56 | substream->pcm->card->number, | 56 | substream->pcm->card->number, |
57 | substream->pcm->device, | 57 | substream->pcm->device, |
58 | substream->stream ? 'c' : 'p', | 58 | substream->stream ? 'c' : 'p', |
59 | substream->number); | 59 | substream->number); |
60 | } | 60 | } |
61 | #define DEBUG_NAME(substream, name) char name[16]; pcm_debug_name(substream, name, sizeof(name)) | ||
62 | #else | 61 | #else |
63 | #define pcm_debug_name(s, n, l) do { } while (0) | 62 | static inline void |
64 | #define DEBUG_NAME(name, substream) do { } while (0) | 63 | snd_pcm_debug_name(struct snd_pcm_substream *substream, char *buf, size_t size) |
64 | { | ||
65 | *buf = 0; | ||
66 | } | ||
65 | #endif | 67 | #endif |
66 | 68 | ||
67 | #if defined CONFIG_SND_DEBUG_VERBOSE | 69 | #if defined CONFIG_SND_DEBUG_VERBOSE |
@@ -304,7 +306,8 @@ static u16 handle_error(u16 err, int line, char *filename) | |||
304 | static void print_hwparams(struct snd_pcm_substream *substream, | 306 | static void print_hwparams(struct snd_pcm_substream *substream, |
305 | struct snd_pcm_hw_params *p) | 307 | struct snd_pcm_hw_params *p) |
306 | { | 308 | { |
307 | DEBUG_NAME(substream, name); | 309 | char name[16]; |
310 | snd_pcm_debug_name(substream, name, sizeof(name)); | ||
308 | snd_printd("%s HWPARAMS\n", name); | 311 | snd_printd("%s HWPARAMS\n", name); |
309 | snd_printd(" samplerate %d Hz\n", params_rate(p)); | 312 | snd_printd(" samplerate %d Hz\n", params_rate(p)); |
310 | snd_printd(" channels %d\n", params_channels(p)); | 313 | snd_printd(" channels %d\n", params_channels(p)); |
@@ -576,8 +579,9 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
576 | struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); | 579 | struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); |
577 | struct snd_pcm_substream *s; | 580 | struct snd_pcm_substream *s; |
578 | u16 e; | 581 | u16 e; |
579 | DEBUG_NAME(substream, name); | 582 | char name[16]; |
580 | 583 | ||
584 | snd_pcm_debug_name(substream, name, sizeof(name)); | ||
581 | snd_printdd("%s trigger\n", name); | 585 | snd_printdd("%s trigger\n", name); |
582 | 586 | ||
583 | switch (cmd) { | 587 | switch (cmd) { |
@@ -741,7 +745,9 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
741 | int loops = 0; | 745 | int loops = 0; |
742 | u16 state; | 746 | u16 state; |
743 | u32 buffer_size, bytes_avail, samples_played, on_card_bytes; | 747 | u32 buffer_size, bytes_avail, samples_played, on_card_bytes; |
744 | DEBUG_NAME(substream, name); | 748 | char name[16]; |
749 | |||
750 | snd_pcm_debug_name(substream, name, sizeof(name)); | ||
745 | 751 | ||
746 | snd_printdd("%s snd_card_asihpi_timer_function\n", name); | 752 | snd_printdd("%s snd_card_asihpi_timer_function\n", name); |
747 | 753 | ||
@@ -1323,10 +1329,12 @@ static const char * const asihpi_src_names[] = { | |||
1323 | "RF", | 1329 | "RF", |
1324 | "Clock", | 1330 | "Clock", |
1325 | "Bitstream", | 1331 | "Bitstream", |
1326 | "Microphone", | 1332 | "Mic", |
1327 | "Cobranet", | 1333 | "Net", |
1328 | "Analog", | 1334 | "Analog", |
1329 | "Adapter", | 1335 | "Adapter", |
1336 | "RTP", | ||
1337 | "GPI", | ||
1330 | }; | 1338 | }; |
1331 | 1339 | ||
1332 | compile_time_assert( | 1340 | compile_time_assert( |
@@ -1341,8 +1349,10 @@ static const char * const asihpi_dst_names[] = { | |||
1341 | "Digital", | 1349 | "Digital", |
1342 | "RF", | 1350 | "RF", |
1343 | "Speaker", | 1351 | "Speaker", |
1344 | "Cobranet Out", | 1352 | "Net", |
1345 | "Analog" | 1353 | "Analog", |
1354 | "RTP", | ||
1355 | "GPO", | ||
1346 | }; | 1356 | }; |
1347 | 1357 | ||
1348 | compile_time_assert( | 1358 | compile_time_assert( |
@@ -1476,11 +1486,40 @@ static int snd_asihpi_volume_put(struct snd_kcontrol *kcontrol, | |||
1476 | 1486 | ||
1477 | static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0); | 1487 | static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0); |
1478 | 1488 | ||
1489 | #define snd_asihpi_volume_mute_info snd_ctl_boolean_mono_info | ||
1490 | |||
1491 | static int snd_asihpi_volume_mute_get(struct snd_kcontrol *kcontrol, | ||
1492 | struct snd_ctl_elem_value *ucontrol) | ||
1493 | { | ||
1494 | u32 h_control = kcontrol->private_value; | ||
1495 | u32 mute; | ||
1496 | |||
1497 | hpi_handle_error(hpi_volume_get_mute(h_control, &mute)); | ||
1498 | ucontrol->value.integer.value[0] = mute ? 0 : 1; | ||
1499 | |||
1500 | return 0; | ||
1501 | } | ||
1502 | |||
1503 | static int snd_asihpi_volume_mute_put(struct snd_kcontrol *kcontrol, | ||
1504 | struct snd_ctl_elem_value *ucontrol) | ||
1505 | { | ||
1506 | u32 h_control = kcontrol->private_value; | ||
1507 | int change = 1; | ||
1508 | /* HPI currently only supports all or none muting of multichannel volume | ||
1509 | ALSA Switch element has opposite sense to HPI mute: on==unmuted, off=muted | ||
1510 | */ | ||
1511 | int mute = ucontrol->value.integer.value[0] ? 0 : HPI_BITMASK_ALL_CHANNELS; | ||
1512 | hpi_handle_error(hpi_volume_set_mute(h_control, mute)); | ||
1513 | return change; | ||
1514 | } | ||
1515 | |||
1479 | static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, | 1516 | static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, |
1480 | struct hpi_control *hpi_ctl) | 1517 | struct hpi_control *hpi_ctl) |
1481 | { | 1518 | { |
1482 | struct snd_card *card = asihpi->card; | 1519 | struct snd_card *card = asihpi->card; |
1483 | struct snd_kcontrol_new snd_control; | 1520 | struct snd_kcontrol_new snd_control; |
1521 | int err; | ||
1522 | u32 mute; | ||
1484 | 1523 | ||
1485 | asihpi_ctl_init(&snd_control, hpi_ctl, "Volume"); | 1524 | asihpi_ctl_init(&snd_control, hpi_ctl, "Volume"); |
1486 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 1525 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
@@ -1490,7 +1529,19 @@ static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, | |||
1490 | snd_control.put = snd_asihpi_volume_put; | 1529 | snd_control.put = snd_asihpi_volume_put; |
1491 | snd_control.tlv.p = db_scale_100; | 1530 | snd_control.tlv.p = db_scale_100; |
1492 | 1531 | ||
1493 | return ctl_add(card, &snd_control, asihpi); | 1532 | err = ctl_add(card, &snd_control, asihpi); |
1533 | if (err) | ||
1534 | return err; | ||
1535 | |||
1536 | if (hpi_volume_get_mute(hpi_ctl->h_control, &mute) == 0) { | ||
1537 | asihpi_ctl_init(&snd_control, hpi_ctl, "Switch"); | ||
1538 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; | ||
1539 | snd_control.info = snd_asihpi_volume_mute_info; | ||
1540 | snd_control.get = snd_asihpi_volume_mute_get; | ||
1541 | snd_control.put = snd_asihpi_volume_mute_put; | ||
1542 | err = ctl_add(card, &snd_control, asihpi); | ||
1543 | } | ||
1544 | return err; | ||
1494 | } | 1545 | } |
1495 | 1546 | ||
1496 | /*------------------------------------------------------------ | 1547 | /*------------------------------------------------------------ |
@@ -2923,7 +2974,7 @@ static DEFINE_PCI_DEVICE_TABLE(asihpi_pci_tbl) = { | |||
2923 | MODULE_DEVICE_TABLE(pci, asihpi_pci_tbl); | 2974 | MODULE_DEVICE_TABLE(pci, asihpi_pci_tbl); |
2924 | 2975 | ||
2925 | static struct pci_driver driver = { | 2976 | static struct pci_driver driver = { |
2926 | .name = "asihpi", | 2977 | .name = KBUILD_MODNAME, |
2927 | .id_table = asihpi_pci_tbl, | 2978 | .id_table = asihpi_pci_tbl, |
2928 | .probe = snd_asihpi_probe, | 2979 | .probe = snd_asihpi_probe, |
2929 | .remove = __devexit_p(snd_asihpi_remove), | 2980 | .remove = __devexit_p(snd_asihpi_remove), |