All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector
@ 2011-07-29  1:11 Adrian Knoth
  2011-07-29  1:11 ` [PATCH 1/3] ALSA: hdspm - Provide MADI speed mode selector on RME MADI and MADIface Adrian Knoth
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Adrian Knoth @ 2011-07-29  1:11 UTC (permalink / raw)
  To: patch; +Cc: Adrian Knoth, alsa-devel

Hi!

Here's another small series of patches for the RME MADI cards. Most
prominently, we now provide a control element to the user to explicitly
select a frequency multiplier for the MADI link.

This way, one can run applications at 64kHz and above (up to 192kHz)
even when the card is not the clock master (read: is in slave mode).



Cheers

Adrian Knoth (3):
  ALSA: hdspm - Provide MADI speed mode selector on RME MADI and
    MADIface
  ALSA: hdspm - Fix reported external sample rate on RME MADI and
    MADIface
  ALSA: hdspm - Add firmware revision 0xcc for RME MADI

 sound/pci/rme9652/hdspm.c |  109 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 107 insertions(+), 2 deletions(-)

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] ALSA: hdspm - Provide MADI speed mode selector on RME MADI and MADIface
  2011-07-29  1:11 [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector Adrian Knoth
@ 2011-07-29  1:11 ` Adrian Knoth
  2011-07-29  1:11 ` [PATCH 2/3] ALSA: hdspm - Fix reported external sample rate " Adrian Knoth
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Adrian Knoth @ 2011-07-29  1:11 UTC (permalink / raw)
  To: patch; +Cc: Adrian Knoth, alsa-devel

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>

diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index af130ee..d219649 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,
 	return change;
 }
 
+#define HDSPM_MADI_SPEEDMODE(xname, xindex) \
+{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+	.name = xname, \
+	.index = xindex, \
+	.info = snd_hdspm_info_madi_speedmode, \
+	.get = snd_hdspm_get_madi_speedmode, \
+	.put = snd_hdspm_put_madi_speedmode \
+}
+
+static int hdspm_madi_speedmode(struct hdspm *hdspm)
+{
+	if (hdspm->control_register & HDSPM_QuadSpeed)
+		return 2;
+	if (hdspm->control_register & HDSPM_DoubleSpeed)
+		return 1;
+	return 0;
+}
+
+static int hdspm_set_madi_speedmode(struct hdspm *hdspm, int mode)
+{
+	hdspm->control_register &= ~(HDSPM_DoubleSpeed | HDSPM_QuadSpeed);
+	switch (mode) {
+	case 0:
+		break;
+	case 1:
+		hdspm->control_register |= HDSPM_DoubleSpeed;
+		break;
+	case 2:
+		hdspm->control_register |= HDSPM_QuadSpeed;
+		break;
+	}
+	hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
+
+	return 0;
+}
+
+static int snd_hdspm_info_madi_speedmode(struct snd_kcontrol *kcontrol,
+				       struct snd_ctl_elem_info *uinfo)
+{
+	static char *texts[] = { "Single", "Double", "Quad" };
+
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+	uinfo->count = 1;
+	uinfo->value.enumerated.items = 3;
+
+	if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+		uinfo->value.enumerated.item =
+		    uinfo->value.enumerated.items - 1;
+	strcpy(uinfo->value.enumerated.name,
+	       texts[uinfo->value.enumerated.item]);
+
+	return 0;
+}
+
+static int snd_hdspm_get_madi_speedmode(struct snd_kcontrol *kcontrol,
+				      struct snd_ctl_elem_value *ucontrol)
+{
+	struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+
+	spin_lock_irq(&hdspm->lock);
+	ucontrol->value.enumerated.item[0] = hdspm_madi_speedmode(hdspm);
+	spin_unlock_irq(&hdspm->lock);
+	return 0;
+}
+
+static int snd_hdspm_put_madi_speedmode(struct snd_kcontrol *kcontrol,
+				      struct snd_ctl_elem_value *ucontrol)
+{
+	struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+	int change;
+	int val;
+
+	if (!snd_hdspm_use_is_exclusive(hdspm))
+		return -EBUSY;
+	val = ucontrol->value.integer.value[0];
+	if (val < 0)
+		val = 0;
+	if (val > 2)
+		val = 2;
+	spin_lock_irq(&hdspm->lock);
+	change = val != hdspm_madi_speedmode(hdspm);
+	hdspm_set_madi_speedmode(hdspm, val);
+	spin_unlock_irq(&hdspm->lock);
+	return change;
+}
 
 #define HDSPM_MIXER(xname, xindex) \
 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
@@ -4289,7 +4374,8 @@ static struct snd_kcontrol_new snd_hdspm_controls_madi[] = {
 	HDSPM_TX_64("TX 64 channels mode", 0),
 	HDSPM_C_TMS("Clear Track Marker", 0),
 	HDSPM_SAFE_MODE("Safe Mode", 0),
-	HDSPM_INPUT_SELECT("Input Select", 0)
+	HDSPM_INPUT_SELECT("Input Select", 0),
+	HDSPM_MADI_SPEEDMODE("MADI Speed Mode", 0)
 };
 
 
@@ -4302,7 +4388,8 @@ static struct snd_kcontrol_new snd_hdspm_controls_madiface[] = {
 	HDSPM_SYNC_CHECK("MADI SyncCheck", 0),
 	HDSPM_TX_64("TX 64 channels mode", 0),
 	HDSPM_C_TMS("Clear Track Marker", 0),
-	HDSPM_SAFE_MODE("Safe Mode", 0)
+	HDSPM_SAFE_MODE("Safe Mode", 0),
+	HDSPM_MADI_SPEEDMODE("MADI Speed Mode", 0)
 };
 
 static struct snd_kcontrol_new snd_hdspm_controls_aio[] = {
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] ALSA: hdspm - Fix reported external sample rate on RME MADI and MADIface
  2011-07-29  1:11 [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector Adrian Knoth
  2011-07-29  1:11 ` [PATCH 1/3] ALSA: hdspm - Provide MADI speed mode selector on RME MADI and MADIface Adrian Knoth
@ 2011-07-29  1:11 ` Adrian Knoth
  2011-07-29  1:11 ` [PATCH 3/3] ALSA: hdspm - Add firmware revision 0xcc for RME MADI Adrian Knoth
  2011-07-29  5:49 ` [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector Takashi Iwai
  3 siblings, 0 replies; 5+ messages in thread
From: Adrian Knoth @ 2011-07-29  1:11 UTC (permalink / raw)
  To: patch; +Cc: Adrian Knoth, alsa-devel

In slave mode, the card can only detect the base frequency (32..48kHz)
on the MADI link (exception: 96k frames), so the real external sample
rate is this base frequency multiplied by 1, 2 or 4 depending on the
speed mode.

This patch enables 64..192kHz sample rates in clock slave mode, which
failed before due to an alleged sample rate mismatch between the MADI
link (e.g., 48kHz) and the application in DS/QS mode (e.g., 96kHz,
192kHz).

Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de>

diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index d219649..88ae274 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -1217,6 +1217,22 @@ static int hdspm_external_sample_rate(struct hdspm *hdspm)
 				rate = 0;
 				break;
 			}
+
+			/* QS and DS rates normally can not be detected
+			 * automatically by the card. Only exception is MADI
+			 * in 96k frame mode.
+			 *
+			 * So if we read SS values (32 .. 48k), check for
+			 * user-provided DS/QS bits in the control register
+			 * and multiply the base frequency accordingly.
+			 */
+			if (rate <= 48000) {
+				if (hdspm->control_register & HDSPM_QuadSpeed)
+					rate *= 4;
+				else if (hdspm->control_register &
+						HDSPM_DoubleSpeed)
+					rate *= 2;
+			}
 		}
 		break;
 	}
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] ALSA: hdspm - Add firmware revision 0xcc for RME MADI
  2011-07-29  1:11 [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector Adrian Knoth
  2011-07-29  1:11 ` [PATCH 1/3] ALSA: hdspm - Provide MADI speed mode selector on RME MADI and MADIface Adrian Knoth
  2011-07-29  1:11 ` [PATCH 2/3] ALSA: hdspm - Fix reported external sample rate " Adrian Knoth
@ 2011-07-29  1:11 ` Adrian Knoth
  2011-07-29  5:49 ` [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector Takashi Iwai
  3 siblings, 0 replies; 5+ messages in thread
From: Adrian Knoth @ 2011-07-29  1:11 UTC (permalink / raw)
  To: patch; +Cc: Adrian Knoth, alsa-devel

Apparently, there are multiple old firmware revisions in the wild for
the PCI RME MADI cards. Just add them to the list of supported devices
and treat them like their modern counterparts.

Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de>

diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 88ae274..6edc67c 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -521,6 +521,7 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
 #define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024)
 
 /* revisions >= 230 indicate AES32 card */
+#define HDSPM_MADI_ANCIENT_REV	204
 #define HDSPM_MADI_OLD_REV	207
 #define HDSPM_MADI_REV		210
 #define HDSPM_RAYDAT_REV	211
@@ -6484,6 +6485,7 @@ static int __devinit snd_hdspm_create(struct snd_card *card,
 	switch (hdspm->firmware_rev) {
 	case HDSPM_MADI_REV:
 	case HDSPM_MADI_OLD_REV:
+	case HDSPM_MADI_ANCIENT_REV:
 		hdspm->io_type = MADI;
 		hdspm->card_name = "RME MADI";
 		hdspm->midiPorts = 3;
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector
  2011-07-29  1:11 [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector Adrian Knoth
                   ` (2 preceding siblings ...)
  2011-07-29  1:11 ` [PATCH 3/3] ALSA: hdspm - Add firmware revision 0xcc for RME MADI Adrian Knoth
@ 2011-07-29  5:49 ` Takashi Iwai
  3 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2011-07-29  5:49 UTC (permalink / raw)
  To: Adrian Knoth; +Cc: alsa-devel

At Fri, 29 Jul 2011 03:11:01 +0200,
Adrian Knoth wrote:
> 
> Hi!
> 
> Here's another small series of patches for the RME MADI cards. Most
> prominently, we now provide a control element to the user to explicitly
> select a frequency multiplier for the MADI link.
> 
> This way, one can run applications at 64kHz and above (up to 192kHz)
> even when the card is not the clock master (read: is in slave mode).

Applied now.  Thanks.


Takashi

> 
> 
> 
> Cheers
> 
> Adrian Knoth (3):
>   ALSA: hdspm - Provide MADI speed mode selector on RME MADI and
>     MADIface
>   ALSA: hdspm - Fix reported external sample rate on RME MADI and
>     MADIface
>   ALSA: hdspm - Add firmware revision 0xcc for RME MADI
> 
>  sound/pci/rme9652/hdspm.c |  109 ++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 107 insertions(+), 2 deletions(-)
> 
> -- 
> 1.7.5.4
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-29  5:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-29  1:11 [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector Adrian Knoth
2011-07-29  1:11 ` [PATCH 1/3] ALSA: hdspm - Provide MADI speed mode selector on RME MADI and MADIface Adrian Knoth
2011-07-29  1:11 ` [PATCH 2/3] ALSA: hdspm - Fix reported external sample rate " Adrian Knoth
2011-07-29  1:11 ` [PATCH 3/3] ALSA: hdspm - Add firmware revision 0xcc for RME MADI Adrian Knoth
2011-07-29  5:49 ` [PATCH 0/3] [RME - HDSPM/MADI] Speed mode selector Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.