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