aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorAdrian Knoth <adi@drcomp.erfurt.thur.de>2011-07-28 21:11:02 -0400
committerTakashi Iwai <tiwai@suse.de>2011-07-29 01:40:51 -0400
commit700d1ef33ff1d9a582b4a1dc23a130049f239942 (patch)
treead28b62d6241574a50c4eae8579f8ed468249435 /sound/pci
parentca9380fd68514c7bc952282c1b4fc70607e9fe43 (diff)
ALSA: hdspm - Provide MADI speed mode selector on RME MADI and MADIface
When running in slave mode (no clock master), there is no way to determine the real wirespeed on the MADI link (single/double/quad speed). Like physical gear, simply provide the user with a tristate switch to select the appropriate format. Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/rme9652/hdspm.c91
1 files changed, 89 insertions, 2 deletions
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index af130ee0c45d..d21964994168 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -3415,6 +3415,91 @@ static int snd_hdspm_put_qs_wire(struct snd_kcontrol *kcontrol,
3415 return change; 3415 return change;
3416} 3416}
3417 3417
3418#define HDSPM_MADI_SPEEDMODE(xname, xindex) \
3419{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3420 .name = xname, \
3421 .index = xindex, \
3422 .info = snd_hdspm_info_madi_speedmode, \
3423 .get = snd_hdspm_get_madi_speedmode, \
3424 .put = snd_hdspm_put_madi_speedmode \
3425}
3426
3427static int hdspm_madi_speedmode(struct hdspm *hdspm)
3428{
3429 if (hdspm->control_register & HDSPM_QuadSpeed)
3430 return 2;
3431 if (hdspm->control_register & HDSPM_DoubleSpeed)
3432 return 1;
3433 return 0;
3434}
3435
3436static int hdspm_set_madi_speedmode(struct hdspm *hdspm, int mode)
3437{
3438 hdspm->control_register &= ~(HDSPM_DoubleSpeed | HDSPM_QuadSpeed);
3439 switch (mode) {
3440 case 0:
3441 break;
3442 case 1:
3443 hdspm->control_register |= HDSPM_DoubleSpeed;
3444 break;
3445 case 2:
3446 hdspm->control_register |= HDSPM_QuadSpeed;
3447 break;
3448 }
3449 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
3450
3451 return 0;
3452}
3453
3454static int snd_hdspm_info_madi_speedmode(struct snd_kcontrol *kcontrol,
3455 struct snd_ctl_elem_info *uinfo)
3456{
3457 static char *texts[] = { "Single", "Double", "Quad" };
3458
3459 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3460 uinfo->count = 1;
3461 uinfo->value.enumerated.items = 3;
3462
3463 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
3464 uinfo->value.enumerated.item =
3465 uinfo->value.enumerated.items - 1;
3466 strcpy(uinfo->value.enumerated.name,
3467 texts[uinfo->value.enumerated.item]);
3468
3469 return 0;
3470}
3471
3472static int snd_hdspm_get_madi_speedmode(struct snd_kcontrol *kcontrol,
3473 struct snd_ctl_elem_value *ucontrol)
3474{
3475 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
3476
3477 spin_lock_irq(&hdspm->lock);
3478 ucontrol->value.enumerated.item[0] = hdspm_madi_speedmode(hdspm);
3479 spin_unlock_irq(&hdspm->lock);
3480 return 0;
3481}
3482
3483static int snd_hdspm_put_madi_speedmode(struct snd_kcontrol *kcontrol,
3484 struct snd_ctl_elem_value *ucontrol)
3485{
3486 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
3487 int change;
3488 int val;
3489
3490 if (!snd_hdspm_use_is_exclusive(hdspm))
3491 return -EBUSY;
3492 val = ucontrol->value.integer.value[0];
3493 if (val < 0)
3494 val = 0;
3495 if (val > 2)
3496 val = 2;
3497 spin_lock_irq(&hdspm->lock);
3498 change = val != hdspm_madi_speedmode(hdspm);
3499 hdspm_set_madi_speedmode(hdspm, val);
3500 spin_unlock_irq(&hdspm->lock);
3501 return change;
3502}
3418 3503
3419#define HDSPM_MIXER(xname, xindex) \ 3504#define HDSPM_MIXER(xname, xindex) \
3420{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 3505{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
@@ -4289,7 +4374,8 @@ static struct snd_kcontrol_new snd_hdspm_controls_madi[] = {
4289 HDSPM_TX_64("TX 64 channels mode", 0), 4374 HDSPM_TX_64("TX 64 channels mode", 0),
4290 HDSPM_C_TMS("Clear Track Marker", 0), 4375 HDSPM_C_TMS("Clear Track Marker", 0),
4291 HDSPM_SAFE_MODE("Safe Mode", 0), 4376 HDSPM_SAFE_MODE("Safe Mode", 0),
4292 HDSPM_INPUT_SELECT("Input Select", 0) 4377 HDSPM_INPUT_SELECT("Input Select", 0),
4378 HDSPM_MADI_SPEEDMODE("MADI Speed Mode", 0)
4293}; 4379};
4294 4380
4295 4381
@@ -4302,7 +4388,8 @@ static struct snd_kcontrol_new snd_hdspm_controls_madiface[] = {
4302 HDSPM_SYNC_CHECK("MADI SyncCheck", 0), 4388 HDSPM_SYNC_CHECK("MADI SyncCheck", 0),
4303 HDSPM_TX_64("TX 64 channels mode", 0), 4389 HDSPM_TX_64("TX 64 channels mode", 0),
4304 HDSPM_C_TMS("Clear Track Marker", 0), 4390 HDSPM_C_TMS("Clear Track Marker", 0),
4305 HDSPM_SAFE_MODE("Safe Mode", 0) 4391 HDSPM_SAFE_MODE("Safe Mode", 0),
4392 HDSPM_MADI_SPEEDMODE("MADI Speed Mode", 0)
4306}; 4393};
4307 4394
4308static struct snd_kcontrol_new snd_hdspm_controls_aio[] = { 4395static struct snd_kcontrol_new snd_hdspm_controls_aio[] = {