diff options
Diffstat (limited to 'sound/pci/asihpi/asihpi.c')
-rw-r--r-- | sound/pci/asihpi/asihpi.c | 87 |
1 files changed, 58 insertions, 29 deletions
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 2ca6f4f85b4..eae62ebbd29 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "hpioctl.h" | 27 | #include "hpioctl.h" |
28 | 28 | ||
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/version.h> | ||
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/jiffies.h> | 31 | #include <linux/jiffies.h> |
33 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
@@ -42,29 +41,10 @@ | |||
42 | #include <sound/tlv.h> | 41 | #include <sound/tlv.h> |
43 | #include <sound/hwdep.h> | 42 | #include <sound/hwdep.h> |
44 | 43 | ||
45 | |||
46 | MODULE_LICENSE("GPL"); | 44 | MODULE_LICENSE("GPL"); |
47 | MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>"); | 45 | MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>"); |
48 | MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); | 46 | MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); |
49 | 47 | ||
50 | #if defined CONFIG_SND_DEBUG | ||
51 | /* copied from pcm_lib.c, hope later patch will make that version public | ||
52 | and this copy can be removed */ | ||
53 | static void pcm_debug_name(struct snd_pcm_substream *substream, | ||
54 | char *name, size_t len) | ||
55 | { | ||
56 | snprintf(name, len, "pcmC%dD%d%c:%d", | ||
57 | substream->pcm->card->number, | ||
58 | substream->pcm->device, | ||
59 | substream->stream ? 'c' : 'p', | ||
60 | substream->number); | ||
61 | } | ||
62 | #define DEBUG_NAME(substream, name) char name[16]; pcm_debug_name(substream, name, sizeof(name)) | ||
63 | #else | ||
64 | #define pcm_debug_name(s, n, l) do { } while (0) | ||
65 | #define DEBUG_NAME(name, substream) do { } while (0) | ||
66 | #endif | ||
67 | |||
68 | #if defined CONFIG_SND_DEBUG_VERBOSE | 48 | #if defined CONFIG_SND_DEBUG_VERBOSE |
69 | /** | 49 | /** |
70 | * snd_printddd - very verbose debug printk | 50 | * snd_printddd - very verbose debug printk |
@@ -305,7 +285,8 @@ static u16 handle_error(u16 err, int line, char *filename) | |||
305 | static void print_hwparams(struct snd_pcm_substream *substream, | 285 | static void print_hwparams(struct snd_pcm_substream *substream, |
306 | struct snd_pcm_hw_params *p) | 286 | struct snd_pcm_hw_params *p) |
307 | { | 287 | { |
308 | DEBUG_NAME(substream, name); | 288 | char name[16]; |
289 | snd_pcm_debug_name(substream, name, sizeof(name)); | ||
309 | snd_printd("%s HWPARAMS\n", name); | 290 | snd_printd("%s HWPARAMS\n", name); |
310 | snd_printd(" samplerate %d Hz\n", params_rate(p)); | 291 | snd_printd(" samplerate %d Hz\n", params_rate(p)); |
311 | snd_printd(" channels %d\n", params_channels(p)); | 292 | snd_printd(" channels %d\n", params_channels(p)); |
@@ -577,8 +558,9 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
577 | struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); | 558 | struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); |
578 | struct snd_pcm_substream *s; | 559 | struct snd_pcm_substream *s; |
579 | u16 e; | 560 | u16 e; |
580 | DEBUG_NAME(substream, name); | 561 | char name[16]; |
581 | 562 | ||
563 | snd_pcm_debug_name(substream, name, sizeof(name)); | ||
582 | snd_printdd("%s trigger\n", name); | 564 | snd_printdd("%s trigger\n", name); |
583 | 565 | ||
584 | switch (cmd) { | 566 | switch (cmd) { |
@@ -742,7 +724,9 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
742 | int loops = 0; | 724 | int loops = 0; |
743 | u16 state; | 725 | u16 state; |
744 | u32 buffer_size, bytes_avail, samples_played, on_card_bytes; | 726 | u32 buffer_size, bytes_avail, samples_played, on_card_bytes; |
745 | DEBUG_NAME(substream, name); | 727 | char name[16]; |
728 | |||
729 | snd_pcm_debug_name(substream, name, sizeof(name)); | ||
746 | 730 | ||
747 | snd_printdd("%s snd_card_asihpi_timer_function\n", name); | 731 | snd_printdd("%s snd_card_asihpi_timer_function\n", name); |
748 | 732 | ||
@@ -1324,10 +1308,12 @@ static const char * const asihpi_src_names[] = { | |||
1324 | "RF", | 1308 | "RF", |
1325 | "Clock", | 1309 | "Clock", |
1326 | "Bitstream", | 1310 | "Bitstream", |
1327 | "Microphone", | 1311 | "Mic", |
1328 | "Cobranet", | 1312 | "Net", |
1329 | "Analog", | 1313 | "Analog", |
1330 | "Adapter", | 1314 | "Adapter", |
1315 | "RTP", | ||
1316 | "GPI", | ||
1331 | }; | 1317 | }; |
1332 | 1318 | ||
1333 | compile_time_assert( | 1319 | compile_time_assert( |
@@ -1342,8 +1328,10 @@ static const char * const asihpi_dst_names[] = { | |||
1342 | "Digital", | 1328 | "Digital", |
1343 | "RF", | 1329 | "RF", |
1344 | "Speaker", | 1330 | "Speaker", |
1345 | "Cobranet Out", | 1331 | "Net", |
1346 | "Analog" | 1332 | "Analog", |
1333 | "RTP", | ||
1334 | "GPO", | ||
1347 | }; | 1335 | }; |
1348 | 1336 | ||
1349 | compile_time_assert( | 1337 | compile_time_assert( |
@@ -1477,11 +1465,40 @@ static int snd_asihpi_volume_put(struct snd_kcontrol *kcontrol, | |||
1477 | 1465 | ||
1478 | static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0); | 1466 | static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0); |
1479 | 1467 | ||
1468 | #define snd_asihpi_volume_mute_info snd_ctl_boolean_mono_info | ||
1469 | |||
1470 | static int snd_asihpi_volume_mute_get(struct snd_kcontrol *kcontrol, | ||
1471 | struct snd_ctl_elem_value *ucontrol) | ||
1472 | { | ||
1473 | u32 h_control = kcontrol->private_value; | ||
1474 | u32 mute; | ||
1475 | |||
1476 | hpi_handle_error(hpi_volume_get_mute(h_control, &mute)); | ||
1477 | ucontrol->value.integer.value[0] = mute ? 0 : 1; | ||
1478 | |||
1479 | return 0; | ||
1480 | } | ||
1481 | |||
1482 | static int snd_asihpi_volume_mute_put(struct snd_kcontrol *kcontrol, | ||
1483 | struct snd_ctl_elem_value *ucontrol) | ||
1484 | { | ||
1485 | u32 h_control = kcontrol->private_value; | ||
1486 | int change = 1; | ||
1487 | /* HPI currently only supports all or none muting of multichannel volume | ||
1488 | ALSA Switch element has opposite sense to HPI mute: on==unmuted, off=muted | ||
1489 | */ | ||
1490 | int mute = ucontrol->value.integer.value[0] ? 0 : HPI_BITMASK_ALL_CHANNELS; | ||
1491 | hpi_handle_error(hpi_volume_set_mute(h_control, mute)); | ||
1492 | return change; | ||
1493 | } | ||
1494 | |||
1480 | static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, | 1495 | static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, |
1481 | struct hpi_control *hpi_ctl) | 1496 | struct hpi_control *hpi_ctl) |
1482 | { | 1497 | { |
1483 | struct snd_card *card = asihpi->card; | 1498 | struct snd_card *card = asihpi->card; |
1484 | struct snd_kcontrol_new snd_control; | 1499 | struct snd_kcontrol_new snd_control; |
1500 | int err; | ||
1501 | u32 mute; | ||
1485 | 1502 | ||
1486 | asihpi_ctl_init(&snd_control, hpi_ctl, "Volume"); | 1503 | asihpi_ctl_init(&snd_control, hpi_ctl, "Volume"); |
1487 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 1504 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
@@ -1491,7 +1508,19 @@ static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, | |||
1491 | snd_control.put = snd_asihpi_volume_put; | 1508 | snd_control.put = snd_asihpi_volume_put; |
1492 | snd_control.tlv.p = db_scale_100; | 1509 | snd_control.tlv.p = db_scale_100; |
1493 | 1510 | ||
1494 | return ctl_add(card, &snd_control, asihpi); | 1511 | err = ctl_add(card, &snd_control, asihpi); |
1512 | if (err) | ||
1513 | return err; | ||
1514 | |||
1515 | if (hpi_volume_get_mute(hpi_ctl->h_control, &mute) == 0) { | ||
1516 | asihpi_ctl_init(&snd_control, hpi_ctl, "Switch"); | ||
1517 | snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE; | ||
1518 | snd_control.info = snd_asihpi_volume_mute_info; | ||
1519 | snd_control.get = snd_asihpi_volume_mute_get; | ||
1520 | snd_control.put = snd_asihpi_volume_mute_put; | ||
1521 | err = ctl_add(card, &snd_control, asihpi); | ||
1522 | } | ||
1523 | return err; | ||
1495 | } | 1524 | } |
1496 | 1525 | ||
1497 | /*------------------------------------------------------------ | 1526 | /*------------------------------------------------------------ |
@@ -2924,7 +2953,7 @@ static DEFINE_PCI_DEVICE_TABLE(asihpi_pci_tbl) = { | |||
2924 | MODULE_DEVICE_TABLE(pci, asihpi_pci_tbl); | 2953 | MODULE_DEVICE_TABLE(pci, asihpi_pci_tbl); |
2925 | 2954 | ||
2926 | static struct pci_driver driver = { | 2955 | static struct pci_driver driver = { |
2927 | .name = "asihpi", | 2956 | .name = KBUILD_MODNAME, |
2928 | .id_table = asihpi_pci_tbl, | 2957 | .id_table = asihpi_pci_tbl, |
2929 | .probe = snd_asihpi_probe, | 2958 | .probe = snd_asihpi_probe, |
2930 | .remove = __devexit_p(snd_asihpi_remove), | 2959 | .remove = __devexit_p(snd_asihpi_remove), |