Skip to contentSkip to conversation

Change spin_lock()/unlock() to spin_lock_irqsave()/restore() in azx_pcm_trigger(). This prevents deadlock when an interrupt occurs, caused by chip->reg_lock contention.

PATCH In review [email protected] 2 participants 21 messages Jul 13, 2012 – Aug 22, 2012 4 messages not in the archive Sound

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 Change spin_lock()/unlock() to spin_lock_irqsave()/restore() in azx_pcm_trigger(). This prevents deadlock when an interrupt occurs, caused by chip->reg_lock contention.

From: Ian Minett <[email protected]>

sound/pci/hda/hda_intel.c +4 -2
index 796472d..0ccffde 100644
@@ -551,6 +551,7 @@ enum {
 	(AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\
 	 AZX_DCAPS_ALIGN_BUFSIZE)
 
+/* quirks for Creative CTHDA */
 #define AZX_DCAPS_PRESET_CTHDA \
 	(AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY)
 
@@ -1930,6 +1931,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	struct snd_pcm_substream *s;
 	int rstart = 0, start, nsync = 0, sbits = 0;
 	int nwait, timeout;
+	unsigned long flags;
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
@@ -1956,7 +1958,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		snd_pcm_trigger_done(s, substream);
 	}
 
-	spin_lock(&chip->reg_lock);
+	spin_lock_irqsave(&chip->reg_lock, flags);
 	if (nsync > 1) {
 		/* first, set SYNC bits of corresponding streams */
 		if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
@@ -1980,7 +1982,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		}
 		azx_dev->running = start;
 	}
-	spin_unlock(&chip->reg_lock);
+	spin_unlock_irqrestore(&chip->reg_lock, flags);
 	if (start) {
 		if (nsync == 1)
 			return 0;
Signature · 1 line
1.7.4.1
#2 lore raw

Re: [PATCH - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

In reply to a message not in the archive

At Fri, 13 Jul 2012 16:44:28 -0700,

Quoted 11 lines · [email protected] wrote:

From: Ian Minett <[email protected]>

Thanks very much for the feedback on the last submission, apologies for the delayed response. Please find attached the new set of patches for updating the CA0132 codec, which takes many of the suggestions into account.

- Ian

---

Quoted 8 lines

ALSA: Update Creative CA0132 HDA codec to introduce DSP features.

patch_ca0132.c:
- Add DSP support to codec.
- 3 capture subdevices supported: Analog Mic1/Digital Mic, Analog Mic2 and What U Hear.
- Add jack detection kcontrol
- Use request_firmware() for loading DSP binaries.

Ideally, these should be split to each patch. Though I see it's not so trivial in this case...

But please provide more technical details. I can only guess what's VNID and what's effect module ID. Give more descriptions.

Quoted 6 lines

hda_intel.c:
- in azx_pcm_trigger(), change spin_lock()/spin_unlock() pair to spin_lock_irqsave()/spin_unlock_irqrestore(). This still seems to be necessary - if an interrupt occurs after azx_stream_start() and before spin_unlock(), it will cause deadlock as azx_interrupt() also acquires chip->reg_lock.

Oh, this is basically because you are doing pretty bad things: calling PCM trigger callback from the codec driver. What's the reason behind it?

Since the whole patch lacks the big and small pictures, it's hard to judge...

Quoted 3 lines

ctefx.bin:
- DSP binary for firmware repository, for driver to load from /lib/firmware directory.

Please submit the patch for adding this, too. Or, at least, give a kernel config to build without the firmware.
Otherwise you'll break the driver.

Looking though the code, the biggest problem is that you are using float in the code. This is now allowed in the kernel at all. You have to rewrite without float type -- i.e. never use "float" in the code, for both fields/arguments and computations.

Also, some other review comments below:

Quoted 35 lines
sound/pci/hda/patch_ca0132.c +14 -2
index d0d3540..c7cdfe1 100644
@@ -1,5 +1,5 @@
 /*
- * HD audio interface patch for Creative CA0132 chip
+ * HD audio interface patch for Creative Sound Core3D chip
  *
  * Copyright (c) 2011, Creative Technology Ltd.
  *
@@ -25,18 +25,470 @@
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/pci.h>
-#include <linux/mutex.h>
 #include <linux/module.h>
+#include <linux/firmware.h>
 #include <sound/core.h>
+#include <sound/tlv.h>
 #include "hda_codec.h"
 #include "hda_local.h"
+#include "hda_jack.h"
 #include "hda_auto_parser.h"
 
+#include "ca0132_regs.h"
+
+/* Enable this to see more debug messages. */
+/*#define ENABLE_CA0132_DEBUG*/
+/* Enable this to see controls for tuning purpose. */
+/*#define ENABLE_TUNING_CONTROLS*/
+
+#define FLOAT_ZERO	0x00000000
+#define FLOAT_ONE	0x3f800000
+#define FLOAT_TWO	0x40000000

sound/pci/hda/patch_ca0132.c line 56

Quoted 10 lines
sound/pci/hda/patch_ca0132.c +10 -0
+#define FLOAT_MINUS_5	0xc0a00000
+
+#define UNSOL_TAG_HP	0x10
+#define UNSOL_TAG_AMIC1	0x12
+#define UNSOL_TAG_DSP	0x16
+
+#define SUCCEEDED(_x)         (((int)(_x)) >= 0)
+#define FAILED(_x)            (((int)(_x)) < 0)
+#define CT_OK                 (0)
+#define CT_FAIL               (-1)

Please avoid home-baked macros like this.
Usually a function returns zero for succcess and a negative error code. No need to define special CT_XX macros.

sound/pci/hda/patch_ca0132.c line 59

Quoted 3 lines
sound/pci/hda/patch_ca0132.c +3 -0
+
+#define MIN(x, y)             (((x) < (y)) ? (x) : (y))
+#define MAX(x, y)             (((x) > (y)) ? (x) : (y))

Use the standard min() and max() macros.

Quoted 21 lines
sound/pci/hda/patch_ca0132.c +16 -2
+#define DSP_DMA_WRITE_BUFLEN_INIT (1UL<<18)
+#define DSP_DMA_WRITE_BUFLEN_OVLY (1UL<<15)
+
+#define DMA_TRANSFER_FRAME_SIZE_NWORDS		8
+#define DMA_TRANSFER_MAX_FRAME_SIZE_NWORDS	32
+#define DMA_OVERLAY_FRAME_SIZE_NWORDS		2
+
+#define MASTERCONTROL				0x80
+#define MASTERCONTROL_ALLOC_DMA_CHAN		9
+#define MASTERCONTROL_QUERY_SPEAKER_EQ_ADDRESS	22
+
 #define WIDGET_CHIP_CTRL      0x15
 #define WIDGET_DSP_CTRL       0x16
 
-#define WUH_MEM_CONNID        10
-#define DSP_MEM_CONNID        16
+#define MEM_CONNID_MICIN1     3
+#define MEM_CONNID_MICIN2     5
+#define MEM_CONNID_MICOUT1    12
+#define MEM_CONNID_MICOUT2    14
+#define MEM_CONNID_WUH        10

sound/pci/hda/patch_ca0132.c line 88

Quoted 10 lines
sound/pci/hda/patch_ca0132.c +10 -0
+#define MEM_CONNID_DSP        16
+#define MEM_CONNID_DMIC       100
+
+#define SCP_SET    0
+#define SCP_GET    1
+
+#define SPEQ_FILE  "ctspeq.bin"
+#define SPEQ_SIZE  0x2040
+#define EFX_FILE   "ctefx.bin"
+#define EFX_SIZE   0xA003C

Don't forget to add MODULE_FIRMWARE() with these files, too.

I stop at this point... Too big to review...

thanks,

Takashi

author
#3 lore raw

PATCH v2 1/2 ALSA: Update Creative CA0132 codec to add DSP features.

From: Ian Minett <[email protected]>

Hi,
Thanks again for the feedback - we've reworked the patch accordingly, to remove floats, tidy the use of macros and add the MODULE_FIRMWARE() lines.

You are right - since it is a pretty big change introducing all the DSP functionality it isn't trivial to break it into multiple small patches. I've added more info on what has been changed below in the git commit message.

The reason we need to modify the trigger callback in hda_intel.c is that the DSP code is downloaded from the host (driver) to the CA0132 chip via the HD-link. This means that the trigger callback is called from the codec driver.

I will submit the DSP firmware blob (ctefx.bin) as a separate patch against the alsa-firmware repository, for intended upstreaming to linux-firmware package. The CA0132 codec uses request_firmware() loader to find the DSP binary in the /lib/firmware directory (the firmware isn't required for building the CA0132 module). If this isn't the correct way to submit firmware binaries, we'd appreciate any info on what the correct method for this is.

Thank you very much,
- Ian

---

ALSA: Update Creative CA0132 HDA codec to introduce DSP features.

patch_ca0132.c:

- Add DSP support to codec.
Playback Effects and controls:
- Play Enhancement On/Off
This is the master control for Surround, Crystalizer, Dialog Plus, Smart Volume, Equalizer and X-Bass.
- Surround On/Off
- Crystalizer On/Off
- Dialog Plus On/Off
- Smart Volume On/Off
- Equalizer On/Off
- X-Bass On/Off

Capture Effects and controls:
- Applied to Analog Mic-In1 / Stereo Digital-Mic.
- CrystalVoice On/Off
Master control for Acoustic Echo Cancellation, Voice Focus, Mic-Smart Volume, Voice FX.
- Acoustic Echo Cancellation On/Off
- Voice Focus (Beam Forming) On/Off
Apply to Stereo Digital Mic, not Analog Mic-In1.
- Smart Volume (Mic SVM) On/Off
- Voice FX (Voice Morphing)
Morph Effects preset selection include:
- Neutral,
- Male2Female,
- Female2Male,
- Scrappy Kid,
- Elderly,
- Orc,
- Elf,
- Dwarf,
- Alien Brute,
- Robot,
- Marine,
- Emo,
- Deep Voice,
- Munchkin
- Add VNIDs (Virtual Node IDs) to denote controls that are not in the physical codec node ID.
- Add effect module IDs to identify individual effect modules present in the DSP.
- Playback Device: One 2-ch device for:
* Built-in speaker/Headphone out
- Mutually exclusive, and independent volume/mute control.
- Only one will be active at any instance.
- Headphone Out will take precedence over Built-in speaker when it's plugged in or detected.
- Capture subdevices: 3 supported:
* Analog Mic1/Digital Mic
- Mutually exclusive, and independent volume/select control.
- Only one will be active at any instance.
- Analog Mic-In1 has +30dB Mic-Boost on/off control.
- Analog-Mic1 In will take precedence over Built-in Stereo Digital-Mic when it's plugged in or detected.
* Analog Mic2
* What U Hear.
- Add jack detection kcontrol
- Use request_firmware() for loading DSP binaries from /lib/firmware.
- Mixer controls:
- Volume level and Mute controls.
- Capture select controls.
- Mic-Boost control.
- Effects controls (as above).

hda_intel.c:
- in azx_pcm_trigger(), change spin_lock()/spin_unlock() pair to spin_lock_irqsave()/spin_unlock_irqrestore(). This is necessary for DSP code downloading via HD-link. If an interrupt occurs after azx_stream_start() and before spin_unlock(), it will cause deadlock as azx_interrupt() also acquires chip->reg_lock.

Developed and maintained by Creative Labs, Inc.

sound/pci/hda/ca0132_regs.h new file +409 -0
new file mode 100644
index 0000000..831ca9c
@@ -0,0 +1,409 @@
+/*
+ * HD audio interface patch for Creative CA0132 chip.
+ * CA0132 registers defines.
+ *
+ * Copyright (c) 2011, Creative Technology Ltd.
+ *
+ *  This driver is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This driver is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#ifndef __CA0132_REGS_H
+#define __CA0312_REGS_H
+
+#define DSP_CHIP_OFFSET                0x100000
+#define DSP_DBGCNTL_MODULE_OFFSET      0xE30
+#define DSP_DBGCNTL_INST_OFFSET \
+	(DSP_CHIP_OFFSET + DSP_DBGCNTL_MODULE_OFFSET)
+
+#define DSP_DBGCNTL_EXEC_LOBIT         0x0
+#define DSP_DBGCNTL_EXEC_HIBIT         0x3
+#define DSP_DBGCNTL_EXEC_MASK          0xF
+
+#define DSP_DBGCNTL_SS_LOBIT           0x4
+#define DSP_DBGCNTL_SS_HIBIT           0x7
+#define DSP_DBGCNTL_SS_MASK            0xF0
+
+#define DSP_DBGCNTL_STATE_LOBIT        0xA
+#define DSP_DBGCNTL_STATE_HIBIT        0xD
+#define DSP_DBGCNTL_STATE_MASK         0x3C00
+
+#define XRAM_CHIP_OFFSET               0x0
+#define XRAM_XRAM_CHANNEL_COUNT        0xE000
+#define XRAM_XRAM_MODULE_OFFSET        0x0
+#define XRAM_XRAM_CHAN_INCR            4
+#define XRAM_XRAM_INST_OFFSET(_chan) \
+	(XRAM_CHIP_OFFSET + XRAM_XRAM_MODULE_OFFSET + \
+	(_chan * XRAM_XRAM_CHAN_INCR))
+
+#define YRAM_CHIP_OFFSET               0x40000
+#define YRAM_YRAM_CHANNEL_COUNT        0x8000
+#define YRAM_YRAM_MODULE_OFFSET        0x0
+#define YRAM_YRAM_CHAN_INCR            4
+#define YRAM_YRAM_INST_OFFSET(_chan) \
+	(YRAM_CHIP_OFFSET + YRAM_YRAM_MODULE_OFFSET + \
+	(_chan * YRAM_YRAM_CHAN_INCR))
+
+#define UC_CHIP_OFFSET                 0x80000
+#define UC_UC_CHANNEL_COUNT            0x10000
+#define UC_UC_MODULE_OFFSET            0x0
+#define UC_UC_CHAN_INCR                4
+#define UC_UC_INST_OFFSET(_chan) \
+	(UC_CHIP_OFFSET + UC_UC_MODULE_OFFSET + \
+	(_chan * UC_UC_CHAN_INCR))
+
+#define AXRAM_CHIP_OFFSET              0x3C000
+#define AXRAM_AXRAM_CHANNEL_COUNT      0x1000
+#define AXRAM_AXRAM_MODULE_OFFSET      0x0
+#define AXRAM_AXRAM_CHAN_INCR          4
+#define AXRAM_AXRAM_INST_OFFSET(_chan) \
+	(AXRAM_CHIP_OFFSET + AXRAM_AXRAM_MODULE_OFFSET + \
+	(_chan * AXRAM_AXRAM_CHAN_INCR))
+
+#define AYRAM_CHIP_OFFSET              0x78000
+#define AYRAM_AYRAM_CHANNEL_COUNT      0x1000
+#define AYRAM_AYRAM_MODULE_OFFSET      0x0
+#define AYRAM_AYRAM_CHAN_INCR          4
+#define AYRAM_AYRAM_INST_OFFSET(_chan) \
+	(AYRAM_CHIP_OFFSET + AYRAM_AYRAM_MODULE_OFFSET + \
+	(_chan * AYRAM_AYRAM_CHAN_INCR))
+
+#define DSPDMAC_CHIP_OFFSET            0x110000
+#define DSPDMAC_DMA_CFG_CHANNEL_COUNT  12
+#define DSPDMAC_DMACFG_MODULE_OFFSET   0xF00
+#define DSPDMAC_DMACFG_CHAN_INCR       0x10
+#define DSPDMAC_DMACFG_INST_OFFSET(_chan) \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_DMACFG_MODULE_OFFSET + \
+	(_chan * DSPDMAC_DMACFG_CHAN_INCR))
+
+#define DSPDMAC_DMACFG_DBADR_LOBIT     0x0
+#define DSPDMAC_DMACFG_DBADR_HIBIT     0x10
+#define DSPDMAC_DMACFG_DBADR_MASK      0x1FFFF
+#define DSPDMAC_DMACFG_LP_LOBIT        0x11
+#define DSPDMAC_DMACFG_LP_HIBIT        0x11
+#define DSPDMAC_DMACFG_LP_MASK         0x20000
+
+#define DSPDMAC_DMACFG_AINCR_LOBIT     0x12
+#define DSPDMAC_DMACFG_AINCR_HIBIT     0x12
+#define DSPDMAC_DMACFG_AINCR_MASK      0x40000
+
+#define DSPDMAC_DMACFG_DWR_LOBIT       0x13
+#define DSPDMAC_DMACFG_DWR_HIBIT       0x13
+#define DSPDMAC_DMACFG_DWR_MASK        0x80000
+
+#define DSPDMAC_DMACFG_AJUMP_LOBIT     0x14
+#define DSPDMAC_DMACFG_AJUMP_HIBIT     0x17
+#define DSPDMAC_DMACFG_AJUMP_MASK      0xF00000
+
+#define DSPDMAC_DMACFG_AMODE_LOBIT     0x18
+#define DSPDMAC_DMACFG_AMODE_HIBIT     0x19
+#define DSPDMAC_DMACFG_AMODE_MASK      0x3000000
+
+#define DSPDMAC_DMACFG_LK_LOBIT        0x1A
+#define DSPDMAC_DMACFG_LK_HIBIT        0x1A
+#define DSPDMAC_DMACFG_LK_MASK         0x4000000
+
+#define DSPDMAC_DMACFG_AICS_LOBIT      0x1B
+#define DSPDMAC_DMACFG_AICS_HIBIT      0x1F
+#define DSPDMAC_DMACFG_AICS_MASK       0xF8000000
+
+#define DSPDMAC_DMACFG_LP_SINGLE                 0
+#define DSPDMAC_DMACFG_LP_LOOPING                1
+
+#define DSPDMAC_DMACFG_AINCR_XANDY               0
+#define DSPDMAC_DMACFG_AINCR_XORY                1
+
+#define DSPDMAC_DMACFG_DWR_DMA_RD                0
+#define DSPDMAC_DMACFG_DWR_DMA_WR                1
+
+#define DSPDMAC_DMACFG_AMODE_LINEAR              0
+#define DSPDMAC_DMACFG_AMODE_RSV1                1
+#define DSPDMAC_DMACFG_AMODE_WINTLV              2
+#define DSPDMAC_DMACFG_AMODE_GINTLV              3
+
+#define DSPDMAC_DSP_ADR_OFS_CHANNEL_COUNT 12
+#define DSPDMAC_DSPADROFS_MODULE_OFFSET 0xF04
+#define DSPDMAC_DSPADROFS_CHAN_INCR    0x10
+#define DSPDMAC_DSPADROFS_INST_OFFSET(_chan) \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_DSPADROFS_MODULE_OFFSET + \
+	(_chan * DSPDMAC_DSPADROFS_CHAN_INCR))
+
+#define DSPDMAC_DSPADROFS_COFS_LOBIT   0x0
+#define DSPDMAC_DSPADROFS_COFS_HIBIT   0xF
+#define DSPDMAC_DSPADROFS_COFS_MASK    0xFFFF
+
+#define DSPDMAC_DSPADROFS_BOFS_LOBIT   0x10
+#define DSPDMAC_DSPADROFS_BOFS_HIBIT   0x1F
+#define DSPDMAC_DSPADROFS_BOFS_MASK    0xFFFF0000
+
+#define DSPDMAC_DSP_ADR_WOFS_CHANNEL_COUNT 12
+#define DSPDMAC_DSPADRWOFS_MODULE_OFFSET 0xF04
+#define DSPDMAC_DSPADRWOFS_CHAN_INCR   0x10
+
+#define DSPDMAC_DSPADRWOFS_INST_OFFSET(_chan) \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_DSPADRWOFS_MODULE_OFFSET + \
+	(_chan * DSPDMAC_DSPADRWOFS_CHAN_INCR))
+
+#define DSPDMAC_DSPADRWOFS_WCOFS_LOBIT 0x0
+#define DSPDMAC_DSPADRWOFS_WCOFS_HIBIT 0xA
+#define DSPDMAC_DSPADRWOFS_WCOFS_MASK  0x7FF
+
+#define DSPDMAC_DSPADRWOFS_WCBFR_LOBIT 0xB
+#define DSPDMAC_DSPADRWOFS_WCBFR_HIBIT 0xF
+#define DSPDMAC_DSPADRWOFS_WCBFR_MASK  0xF800
+
+#define DSPDMAC_DSPADRWOFS_WBOFS_LOBIT 0x10
+#define DSPDMAC_DSPADRWOFS_WBOFS_HIBIT 0x1A
+#define DSPDMAC_DSPADRWOFS_WBOFS_MASK  0x7FF0000
+
+#define DSPDMAC_DSPADRWOFS_WBBFR_LOBIT 0x1B
+#define DSPDMAC_DSPADRWOFS_WBBFR_HIBIT 0x1F
+#define DSPDMAC_DSPADRWOFS_WBBFR_MASK  0xF8000000
+
+#define DSPDMAC_DSP_ADR_GOFS_CHANNEL_COUNT 12
+#define DSPDMAC_DSPADRGOFS_MODULE_OFFSET 0xF04
+#define DSPDMAC_DSPADRGOFS_CHAN_INCR   0x10
+#define DSPDMAC_DSPADRGOFS_INST_OFFSET(_chan) \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_DSPADRGOFS_MODULE_OFFSET + \
+	(_chan * DSPDMAC_DSPADRGOFS_CHAN_INCR))
+
+#define DSPDMAC_DSPADRGOFS_GCOFS_LOBIT 0x0
+#define DSPDMAC_DSPADRGOFS_GCOFS_HIBIT 0x9
+#define DSPDMAC_DSPADRGOFS_GCOFS_MASK  0x3FF
+
+#define DSPDMAC_DSPADRGOFS_GCS_LOBIT   0xA
+#define DSPDMAC_DSPADRGOFS_GCS_HIBIT   0xC
+#define DSPDMAC_DSPADRGOFS_GCS_MASK    0x1C00
+
+#define DSPDMAC_DSPADRGOFS_GCBFR_LOBIT 0xD
+#define DSPDMAC_DSPADRGOFS_GCBFR_HIBIT 0xF
+#define DSPDMAC_DSPADRGOFS_GCBFR_MASK  0xE000
+
+#define DSPDMAC_DSPADRGOFS_GBOFS_LOBIT 0x10
+#define DSPDMAC_DSPADRGOFS_GBOFS_HIBIT 0x19
+#define DSPDMAC_DSPADRGOFS_GBOFS_MASK  0x3FF0000
+
+#define DSPDMAC_DSPADRGOFS_GBS_LOBIT   0x1A
+#define DSPDMAC_DSPADRGOFS_GBS_HIBIT   0x1C
+#define DSPDMAC_DSPADRGOFS_GBS_MASK    0x1C000000
+
+#define DSPDMAC_DSPADRGOFS_GBBFR_LOBIT 0x1D
+#define DSPDMAC_DSPADRGOFS_GBBFR_HIBIT 0x1F
+#define DSPDMAC_DSPADRGOFS_GBBFR_MASK  0xE0000000
+
+#define DSPDMAC_XFR_CNT_CHANNEL_COUNT  12
+#define DSPDMAC_XFRCNT_MODULE_OFFSET   0xF08
+#define DSPDMAC_XFRCNT_CHAN_INCR       0x10
+
+#define DSPDMAC_XFRCNT_INST_OFFSET(_chan) \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_XFRCNT_MODULE_OFFSET + \
+	(_chan * DSPDMAC_XFRCNT_CHAN_INCR))
+
+#define DSPDMAC_XFRCNT_CCNT_LOBIT      0x0
+#define DSPDMAC_XFRCNT_CCNT_HIBIT      0xF
+#define DSPDMAC_XFRCNT_CCNT_MASK       0xFFFF
+
+#define DSPDMAC_XFRCNT_BCNT_LOBIT      0x10
+#define DSPDMAC_XFRCNT_BCNT_HIBIT      0x1F
+#define DSPDMAC_XFRCNT_BCNT_MASK       0xFFFF0000
+
+#define DSPDMAC_IRQ_CNT_CHANNEL_COUNT  12
+#define DSPDMAC_IRQCNT_MODULE_OFFSET   0xF0C
+#define DSPDMAC_IRQCNT_CHAN_INCR       0x10
+#define DSPDMAC_IRQCNT_INST_OFFSET(_chan) \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_IRQCNT_MODULE_OFFSET + \
+	(_chan * DSPDMAC_IRQCNT_CHAN_INCR))
+
+#define DSPDMAC_IRQCNT_CICNT_LOBIT     0x0
+#define DSPDMAC_IRQCNT_CICNT_HIBIT     0xF
+#define DSPDMAC_IRQCNT_CICNT_MASK      0xFFFF
+
+#define DSPDMAC_IRQCNT_BICNT_LOBIT     0x10
+#define DSPDMAC_IRQCNT_BICNT_HIBIT     0x1F
+#define DSPDMAC_IRQCNT_BICNT_MASK      0xFFFF0000
+
+#define DSPDMAC_AUD_CHSEL_CHANNEL_COUNT 12
+#define DSPDMAC_AUDCHSEL_MODULE_OFFSET 0xFC0
+#define DSPDMAC_AUDCHSEL_CHAN_INCR     0x4
+#define DSPDMAC_AUDCHSEL_INST_OFFSET(_chan) \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_AUDCHSEL_MODULE_OFFSET + \
+	(_chan * DSPDMAC_AUDCHSEL_CHAN_INCR))
+
+#define DSPDMAC_AUDCHSEL_ACS_LOBIT     0x0
+#define DSPDMAC_AUDCHSEL_ACS_HIBIT     0x1F
+#define DSPDMAC_AUDCHSEL_ACS_MASK      0xFFFFFFFF
+
+#define DSPDMAC_CHNLSTART_MODULE_OFFSET 0xFF0
+#define DSPDMAC_CHNLSTART_INST_OFFSET \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_CHNLSTART_MODULE_OFFSET)
+
+#define DSPDMAC_CHNLSTART_EN_LOBIT     0x0
+#define DSPDMAC_CHNLSTART_EN_HIBIT     0xB
+#define DSPDMAC_CHNLSTART_EN_MASK      0xFFF
+
+#define DSPDMAC_CHNLSTART_VAI1_LOBIT   0xC
+#define DSPDMAC_CHNLSTART_VAI1_HIBIT   0xF
+#define DSPDMAC_CHNLSTART_VAI1_MASK    0xF000
+
+#define DSPDMAC_CHNLSTART_DIS_LOBIT    0x10
+#define DSPDMAC_CHNLSTART_DIS_HIBIT    0x1B
+#define DSPDMAC_CHNLSTART_DIS_MASK     0xFFF0000
+
+#define DSPDMAC_CHNLSTART_VAI2_LOBIT   0x1C
+#define DSPDMAC_CHNLSTART_VAI2_HIBIT   0x1F
+#define DSPDMAC_CHNLSTART_VAI2_MASK    0xF0000000
+
+#define DSPDMAC_CHNLSTATUS_MODULE_OFFSET 0xFF4
+#define DSPDMAC_CHNLSTATUS_INST_OFFSET \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_CHNLSTATUS_MODULE_OFFSET)
+
+#define DSPDMAC_CHNLSTATUS_ISC_LOBIT   0x0
+#define DSPDMAC_CHNLSTATUS_ISC_HIBIT   0xB
+#define DSPDMAC_CHNLSTATUS_ISC_MASK    0xFFF
+
+#define DSPDMAC_CHNLSTATUS_AOO_LOBIT   0xC
+#define DSPDMAC_CHNLSTATUS_AOO_HIBIT   0xC
+#define DSPDMAC_CHNLSTATUS_AOO_MASK    0x1000
+
+#define DSPDMAC_CHNLSTATUS_AOU_LOBIT   0xD
+#define DSPDMAC_CHNLSTATUS_AOU_HIBIT   0xD
+#define DSPDMAC_CHNLSTATUS_AOU_MASK    0x2000
+
+#define DSPDMAC_CHNLSTATUS_AIO_LOBIT   0xE
+#define DSPDMAC_CHNLSTATUS_AIO_HIBIT   0xE
+#define DSPDMAC_CHNLSTATUS_AIO_MASK    0x4000
+
+#define DSPDMAC_CHNLSTATUS_AIU_LOBIT   0xF
+#define DSPDMAC_CHNLSTATUS_AIU_HIBIT   0xF
+#define DSPDMAC_CHNLSTATUS_AIU_MASK    0x8000
+
+#define DSPDMAC_CHNLSTATUS_IEN_LOBIT   0x10
+#define DSPDMAC_CHNLSTATUS_IEN_HIBIT   0x1B
+#define DSPDMAC_CHNLSTATUS_IEN_MASK    0xFFF0000
+
+#define DSPDMAC_CHNLSTATUS_VAI0_LOBIT  0x1C
+#define DSPDMAC_CHNLSTATUS_VAI0_HIBIT  0x1F
+#define DSPDMAC_CHNLSTATUS_VAI0_MASK   0xF0000000
+
+#define DSPDMAC_CHNLPROP_MODULE_OFFSET 0xFF8
+#define DSPDMAC_CHNLPROP_INST_OFFSET \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_CHNLPROP_MODULE_OFFSET)
+
+#define DSPDMAC_CHNLPROP_DCON_LOBIT    0x0
+#define DSPDMAC_CHNLPROP_DCON_HIBIT    0xB
+#define DSPDMAC_CHNLPROP_DCON_MASK     0xFFF
+
+#define DSPDMAC_CHNLPROP_FFS_LOBIT     0xC
+#define DSPDMAC_CHNLPROP_FFS_HIBIT     0xC
+#define DSPDMAC_CHNLPROP_FFS_MASK      0x1000
+
+#define DSPDMAC_CHNLPROP_NAJ_LOBIT     0xD
+#define DSPDMAC_CHNLPROP_NAJ_HIBIT     0xD
+#define DSPDMAC_CHNLPROP_NAJ_MASK      0x2000
+
+#define DSPDMAC_CHNLPROP_ENH_LOBIT     0xE
+#define DSPDMAC_CHNLPROP_ENH_HIBIT     0xE
+#define DSPDMAC_CHNLPROP_ENH_MASK      0x4000
+
+#define DSPDMAC_CHNLPROP_MSPCE_LOBIT   0x10
+#define DSPDMAC_CHNLPROP_MSPCE_HIBIT   0x1B
+#define DSPDMAC_CHNLPROP_MSPCE_MASK    0xFFF0000
+
+#define DSPDMAC_CHNLPROP_AC_LOBIT      0x1C
+#define DSPDMAC_CHNLPROP_AC_HIBIT      0x1F
+#define DSPDMAC_CHNLPROP_AC_MASK       0xF0000000
+
+#define DSPDMAC_ACTIVE_MODULE_OFFSET   0xFFC
+#define DSPDMAC_ACTIVE_INST_OFFSET \
+	(DSPDMAC_CHIP_OFFSET + DSPDMAC_ACTIVE_MODULE_OFFSET)
+
+#define DSPDMAC_ACTIVE_AAR_LOBIT       0x0
+#define DSPDMAC_ACTIVE_AAR_HIBIT       0xB
+#define DSPDMAC_ACTIVE_AAR_MASK        0xFFF
+
+#define DSPDMAC_ACTIVE_WFR_LOBIT       0xC
+#define DSPDMAC_ACTIVE_WFR_HIBIT       0x17
+#define DSPDMAC_ACTIVE_WFR_MASK        0xFFF000
+
+#define DSP_AUX_MEM_BASE            0xE000
+#define INVALID_CHIP_ADDRESS        (~0UL)
+
+#define X_SIZE  (XRAM_XRAM_CHANNEL_COUNT   * XRAM_XRAM_CHAN_INCR)
+#define Y_SIZE  (YRAM_YRAM_CHANNEL_COUNT   * YRAM_YRAM_CHAN_INCR)
+#define AX_SIZE (AXRAM_AXRAM_CHANNEL_COUNT * AXRAM_AXRAM_CHAN_INCR)
+#define AY_SIZE (AYRAM_AYRAM_CHANNEL_COUNT * AYRAM_AYRAM_CHAN_INCR)
+#define UC_SIZE (UC_UC_CHANNEL_COUNT       * UC_UC_CHAN_INCR)
+
+#define XEXT_SIZE (X_SIZE + AX_SIZE)
+#define YEXT_SIZE (Y_SIZE + AY_SIZE)
+
+#define U64K 0x10000UL
+
+#define X_END  (XRAM_CHIP_OFFSET  + X_SIZE)
+#define X_EXT  (XRAM_CHIP_OFFSET  + XEXT_SIZE)
+#define AX_END (XRAM_CHIP_OFFSET  + U64K*4)
+
+#define Y_END  (YRAM_CHIP_OFFSET  + Y_SIZE)
+#define Y_EXT  (YRAM_CHIP_OFFSET  + YEXT_SIZE)
+#define AY_END (YRAM_CHIP_OFFSET  + U64K*4)
+
+#define UC_END (UC_CHIP_OFFSET    + UC_SIZE)
+
+#define X_RANGE_MAIN(a, s) \
+	(((a)+((s)-1)*XRAM_XRAM_CHAN_INCR <  X_END))
+#define X_RANGE_AUX(a, s)  \
+	(((a) >= X_END) && ((a)+((s)-1)*XRAM_XRAM_CHAN_INCR < AX_END))
+#define X_RANGE_EXT(a, s)  \
+	(((a)+((s)-1)*XRAM_XRAM_CHAN_INCR <  X_EXT))
+#define X_RANGE_ALL(a, s)  \
+	(((a)+((s)-1)*XRAM_XRAM_CHAN_INCR < AX_END))
+
+#define Y_RANGE_MAIN(a, s) \
+	(((a) >= YRAM_CHIP_OFFSET) && \
+	((a)+((s)-1)*YRAM_YRAM_CHAN_INCR <  Y_END))
+#define Y_RANGE_AUX(a, s)  \
+	(((a) >= Y_END) && \
+	((a)+((s)-1)*YRAM_YRAM_CHAN_INCR < AY_END))
+#define Y_RANGE_EXT(a, s)  \
+	(((a) >= YRAM_CHIP_OFFSET) && \
+	((a)+((s)-1)*YRAM_YRAM_CHAN_INCR <  Y_EXT))
+#define Y_RANGE_ALL(a, s)  \
+	(((a) >= YRAM_CHIP_OFFSET) && \
+	((a)+((s)-1)*YRAM_YRAM_CHAN_INCR < AY_END))
+
+#define UC_RANGE(a, s) \
+	(((a) >= UC_CHIP_OFFSET) && \
+	((a)+((s)-1)*UC_UC_CHAN_INCR     < UC_END))
+
+#define X_OFF(a) \
+	(((a) - XRAM_CHIP_OFFSET) / XRAM_XRAM_CHAN_INCR)
+#define AX_OFF(a) \
+	(((a) % (AXRAM_AXRAM_CHANNEL_COUNT * \
+	AXRAM_AXRAM_CHAN_INCR)) / AXRAM_AXRAM_CHAN_INCR)
+
+#define Y_OFF(a) \
+	(((a) - YRAM_CHIP_OFFSET) / YRAM_YRAM_CHAN_INCR)
+#define AY_OFF(a) \
+	(((a) % (AYRAM_AYRAM_CHANNEL_COUNT * \
+	AYRAM_AYRAM_CHAN_INCR)) / AYRAM_AYRAM_CHAN_INCR)
+
+#define UC_OFF(a)  (((a) - UC_CHIP_OFFSET) / UC_UC_CHAN_INCR)
+
+#define X_EXT_MAIN_SIZE(a)  (XRAM_XRAM_CHANNEL_COUNT - X_OFF(a))
+#define X_EXT_AUX_SIZE(a, s) ((s) - X_EXT_MAIN_SIZE(a))
+
+#define Y_EXT_MAIN_SIZE(a)  (YRAM_YRAM_CHANNEL_COUNT - Y_OFF(a))
+#define Y_EXT_AUX_SIZE(a, s) ((s) - Y_EXT_MAIN_SIZE(a))
+
+#endif
sound/pci/hda/patch_ca0132.c +3974 -557

2,591 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.4.1

Part of the diff is not shown here. View the raw message.

author
#4 lore raw

PATCH v2 2/2 Change spin_lock()/unlock() to spin_lock_irqsave()/restore()

From: Ian Minett <[email protected]>

in azx_pcm_trigger().
This change is to prevent deadlock when an interrupt occurs, caused by chip->reg_lock contention.

sound/pci/hda/hda_intel.c +4 -2
index 796472d..0ccffde 100644
@@ -551,6 +551,7 @@ enum {
 	(AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\
 	 AZX_DCAPS_ALIGN_BUFSIZE)
 
+/* quirks for Creative CTHDA */
 #define AZX_DCAPS_PRESET_CTHDA \
 	(AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY)
 
@@ -1930,6 +1931,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	struct snd_pcm_substream *s;
 	int rstart = 0, start, nsync = 0, sbits = 0;
 	int nwait, timeout;
+	unsigned long flags;
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
@@ -1956,7 +1958,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		snd_pcm_trigger_done(s, substream);
 	}
 
-	spin_lock(&chip->reg_lock);
+	spin_lock_irqsave(&chip->reg_lock, flags);
 	if (nsync > 1) {
 		/* first, set SYNC bits of corresponding streams */
 		if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
@@ -1980,7 +1982,7 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		}
 		azx_dev->running = start;
 	}
-	spin_unlock(&chip->reg_lock);
+	spin_unlock_irqrestore(&chip->reg_lock, flags);
 	if (start) {
 		if (nsync == 1)
 			return 0;
Signature · 1 line
1.7.4.1
#5 lore raw

Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

In reply to Ian Minett

At Wed, 25 Jul 2012 11:01:19 -0700,

Quoted 7 lines · Ian Minett

From: Ian Minett <[email protected]>

Hi,
Thanks again for the feedback - we've reworked the patch accordingly, to remove floats, tidy the use of macros and add the MODULE_FIRMWARE() lines.

Quoted 7 lines

You are right - since it is a pretty big change introducing all the DSP functionality it isn't trivial to break it into multiple small patches. I've added more info on what has been changed below in the git commit message.

The reason we need to modify the trigger callback in hda_intel.c is that the DSP code is downloaded from the host (driver) to the CA0132 chip via the HD-link. This means that the trigger callback is called from the codec driver.

Well, this is the biggest problem. What the patch does is a layer violation. Such an operation must not be performed in the codec driver. I guess you know it very well when you look again how ugly hacks you need for setting up a fake PCM instance and so on.

One possible way would be to move these DSP loading code into hda_intel.c. But then it bloats up the generic controller driver.

Another possibility is to fork hda_intel.c and move the Creative's controller chip driver there (not meant the code in patch_ca0132.c). You can strip down many workarounds found in hda_intel.c (e.g. bdl_pos_adj, position_fix, probing errors, vga_switcheroo, etc) as a bonus. And the new controller driver can still use the same hda_codec.c and the rest as long as it uses the same structure.

Quoted 6 lines

I will submit the DSP firmware blob (ctefx.bin) as a separate patch against the alsa-firmware repository, for intended upstreaming to linux-firmware package. The CA0132 codec uses request_firmware() loader to find the DSP binary in the /lib/firmware directory (the firmware isn't required for building the CA0132 module). If this isn't the correct way to submit firmware binaries, we'd appreciate any info on what the correct method for this is.

Yes, this is the correct way.

But, still one concern is that people may very likely build the kernel without taking the firmware. Then suddenly it breaks just by the kernel update -- this shouldn't happen.

So, we'd need a kernel config, or at least a module parameter, to enable/disable the new DSP stuff. When it's off, the whole DSP isn't requested and it behaves just likes a standard HD-audio.

thanks,

Takashi

A message that is not in the archive (sent off-list or not yet received): OF0CFC3DA9.A9100453-ON88257A48.006BF087-88257A48.006FCB42@cli.creative.com

#7 lore raw

Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

At Fri, 27 Jul 2012 13:21:05 -0700,

Quoted 8 lines · Ian Minett
Quoted 7 lines

Another possibility is to fork hda_intel.c and move the Creative's controller chip driver there (not meant the code in patch_ca0132.c). You can strip down many workarounds found in hda_intel.c (e.g. bdl_pos_adj, position_fix, probing errors, vga_switcheroo, etc) as a bonus. And the new controller driver can still use the same hda_codec.c and the rest as long as it uses the same structure.

Quoted 4 lines

The CA0132 chip can be connected to and work with any other, non- Creative HDA controllers. So, forking hda_intel.c for a Creative- specific controller won't work in the case where our chip is using a different HDA controller.

So, the DSP part is specific to the codec and not the controller? OK, then forking the controller doesn't work.

Quoted 5 lines

Do you have any suggestions or thoughts on how we can add the spin_lock_irqxxx(), or an alternative approach, into non-specific controller code in order to facilitate the codec DSP download? Since the download isn't controller-specific, it doesn't sound right to move it into controller code such as hda_intel.c either.

No, no. The biggest problem is that the codec driver is calling what the controller driver should do -- prepare, trigger, whatever -- manually. This is the layer violation.

Quoted 8 lines

One thought we have is to handle the spin_lock_irqxxx() as a special case or quirk for the CA0132 codec. Using an approach similar to 'needs_damn_long_delay' in the CA0110 patch, we could define another flag e.g. 'needs_trigger_irqsave' in hda_codec.h struct hda_bus{}. In the CA0132 patch, we would set this flag, which would then be read in hda_intel.c,azx_pcm_trigger(). Either spin_lock_irqxxx() or the current spin_lock() would then be called depending on the flag condition. What is your opinion on an approach like this? Would this be acceptable?

No. The fact that you are calling the PCM functions is already wrong. The irqsave() is just a side-effect by that, and we can forget about it completely now.

The only question is where to implement the DSP loader stuff and how.

Quoted 11 lines
Quoted 6 lines

But, still one concern is that people may very likely build the kernel without taking the firmware. Then suddenly it breaks just by the kernel update -- this shouldn't happen.
So, we'd need a kernel config, or at least a module parameter, to enable/disable the new DSP stuff. When it's off, the whole DSP isn't requested and it behaves just likes a standard HD-audio.

The driver allows for audio playback to still function as normal in the absence of the DSP firmware image, the only effect will be that there will be no DSP processing applied to the stream. The DSP effect and volume controls and WUH recording capability won't be available.

Then we'd need some flag to enable/disable firmware loading, too.

Quoted 3 lines

Finally, can I send the binary firmware patch to the list? I sent it shortly after the previous patch submission but it didn't appear to get through. Is it ok to send directly to you?

It's up to you. If the file is too big, you can send it directly to me and I'll push it to git tree.

thanks,

Takashi

Quoted 84 lines

Thanks very much,
Ian

Takashi Iwai
<[email protected]>
To
07/26/2012 01:06 Ian Minett <[email protected]>
AM cc
[email protected]
Subject
Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

At Wed, 25 Jul 2012 11:01:19 -0700,

Quoted 7 lines · Ian Minett

From: Ian Minett <[email protected]>

Hi,
Thanks again for the feedback - we've reworked the patch accordingly, to remove floats, tidy the use of macros and add the MODULE_FIRMWARE() lines.

Quoted 7 lines

You are right - since it is a pretty big change introducing all the DSP functionality it isn't trivial to break it into multiple small patches. I've added more info on what has been changed below in the git commit message.

The reason we need to modify the trigger callback in hda_intel.c is that the DSP code is downloaded from the host (driver) to the CA0132 chip via the HD-link. This means that the trigger callback is called from the codec driver.

Well, this is the biggest problem. What the patch does is a layer violation. Such an operation must not be performed in the codec driver. I guess you know it very well when you look again how ugly hacks you need for setting up a fake PCM instance and so on.

One possible way would be to move these DSP loading code into hda_intel.c. But then it bloats up the generic controller driver.

Another possibility is to fork hda_intel.c and move the Creative's controller chip driver there (not meant the code in patch_ca0132.c). You can strip down many workarounds found in hda_intel.c (e.g. bdl_pos_adj, position_fix, probing errors, vga_switcheroo, etc) as a bonus. And the new controller driver can still use the same hda_codec.c and the rest as long as it uses the same structure.

Quoted 6 lines

I will submit the DSP firmware blob (ctefx.bin) as a separate patch against the alsa-firmware repository, for intended upstreaming to linux-firmware package. The CA0132 codec uses request_firmware() loader to find the DSP binary in the /lib/firmware directory (the firmware isn't required for building the CA0132 module). If this isn't the correct way to submit firmware binaries, we'd appreciate any info on what the correct method for this is.

Yes, this is the correct way.

But, still one concern is that people may very likely build the kernel without taking the firmware. Then suddenly it breaks just by the kernel update -- this shouldn't happen.

So, we'd need a kernel config, or at least a module parameter, to enable/disable the new DSP stuff. When it's off, the whole DSP isn't requested and it behaves just likes a standard HD-audio.

thanks,

Takashi

ForwardSourceID:NT0001C0EA
[1.2 <text/html; US-ASCII (quoted-printable)>]

A message that is not in the archive (sent off-list or not yet received): OF301523C9.1A0D8E05-ON88257A4B.0074BC06-88257A4B.007D5630@cli.creative.com

#9 lore raw

Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

At Mon, 30 Jul 2012 15:49:00 -0700,

Quoted 14 lines · Ian Minett
Quoted 13 lines
Quoted 9 lines

One thought we have is to handle the spin_lock_irqxxx() as a special case or quirk for the CA0132 codec. Using an approach similar to 'needs_damn_long_delay' in the CA0110 patch, we could define another flag e.g. 'needs_trigger_irqsave' in hda_codec.h struct hda_bus{}. In the CA0132 patch, we would set this flag, which would then be read in hda_intel.c,azx_pcm_trigger(). Either spin_lock_irqxxx() or the current spin_lock() would then be called depending on the flag condition. What is your opinion on an approach like this? Would this be acceptable?

No. The fact that you are calling the PCM functions is already wrong. The irqsave() is just a side-effect by that, and we can forget about it completely now.

Quoted 6 lines
Quoted 1 line

The only question is where to implement the DSP loader stuff and how.

Ok, we understand. Given that the codec cannot call into the controller's PCM interface to load the DSP image, is there an acceptable way you could recommend for us to add this functionality to the module, without breaking the architecture?

Well, as mentioned earlier, we need to push it up to the controller layer, i.e. hda_intel.c. For example, add a new op for firmware DMA transfer in hda_bus_ops.

Could you describe briefly the procedure for the DMA transfer of CA0132? The code looks too complex to follow.

thanks,

Takashi

author
#10 lore raw

Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

The only question is where to implement the DSP loader stuff and how.

Ok, we understand. Given that the codec cannot call into the controller's PCM interface to load the DSP image, is there an acceptable way you could recommend for us to add this functionality to the module, without breaking the architecture?

Quoted 6 lines

Well, as mentioned earlier, we need to push it up to the controller layer, i.e. hda_intel.c. For example, add a new op for firmware DMA transfer in hda_bus_ops.

Could you describe briefly the procedure for the DMA transfer of CA0132? The code looks too complex to follow.

Sure - the DSP code download procedure is:

1. The CA0132 driver extracts DSP data segments that need to download to the DSP chip.
2. Each of these data segments will be downloaded to the DSP chip via HDA-link, like audio data.
3. The HDA controller and CA0132 are programmed to transfer the DSP data segments.
4. The HDA controller FIFO must be flushed on every data segment to ensure that there is no previous residual data.

These are the controller ops that the CA0132 driver used for the DMA transfer:

#define azx_pcm_open(a)       (a->ops->open(a))
#define azx_pcm_close(a)      (a->ops->close(a))
#define azx_pcm_prepare(a)    (a->ops->prepare(a))

#define azx_pcm_trigger(a, b) (a->ops->trigger(a, b))
#define azx_pcm_hw_free(a) (a->ops->hw_free(a))

Thanks,
Ian

#11 lore raw

Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

At Tue, 31 Jul 2012 19:38:05 -0700,

Quoted 21 lines · Ian Minett
Quoted 14 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line

The only question is where to implement the DSP loader stuff and how.

Ok, we understand. Given that the codec cannot call into the controller's PCM interface to load the DSP image, is there an acceptable way you could recommend for us to add this functionality to the module, without breaking the architecture?

Quoted 6 lines

Well, as mentioned earlier, we need to push it up to the controller layer, i.e. hda_intel.c. For example, add a new op for firmware DMA transfer in hda_bus_ops.

Could you describe briefly the procedure for the DMA transfer of CA0132? The code looks too complex to follow.

Quoted 8 lines

Sure - the DSP code download procedure is:

1. The CA0132 driver extracts DSP data segments that need to download to the DSP chip.
2. Each of these data segments will be downloaded to the DSP chip via HDA-link, like audio data.
3. The HDA controller and CA0132 are programmed to transfer the DSP data segments.

So, the data transfer here is just like the normal PCM streaming? For example, if you have an op like

	int (*load_dsp)(struct hda_bus *bus, void *buffer, int size);

and calling this for each segment would work?
(In addition, we'd need to give some way to determine the stop
condition in the codec side.)

Quoted 2 lines

4. The HDA controller FIFO must be flushed on every data segment to ensure that there is no previous residual data.

Actually FIFO flush might be needed for the audio transfer as well.

thanks,

Takashi

Quoted 9 lines

These are the controller ops that the CA0132 driver used for the DMA transfer:

#define azx_pcm_open(a)       (a->ops->open(a))
#define azx_pcm_close(a)      (a->ops->close(a))
#define azx_pcm_prepare(a)    (a->ops->prepare(a))

#define azx_pcm_trigger(a, b) (a->ops->trigger(a, b))
#define azx_pcm_hw_free(a) (a->ops->hw_free(a))

Thanks,
Ian

author
#12 lore raw

Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

Quoted 5 lines
Quoted 9 lines

So, the data transfer here is just like the normal PCM streaming? For example, if you have an op like

           int (*load_dsp)(struct hda_bus *bus, void *buffer, int size);

and calling this for each segment would work?
(In addition, we'd need to give some way to determine the stop condition in the codec side.)

Hi,

Yes - this approach would work. We would also need to set the data format, and control the stop condition.

For example, by adding the following ops to handle the dsp download process:

/* format is 16-bit Stream Format Structure as defined in HDA spec.
pcm_prepare() callback in the codec will be called so that codec driver can obtain the stream tag and format to set up the codec.
*/

int (*load_dsp_prepare) \
      (struct hda_bus *bus, unsigned short format, void *buffer, int size);

/* start the transfer. */
int (*load_dsp_start)(struct hda_bus *bus);

/* stop the transfer and flush the FIFO. */
int (*load_dsp_stop)(struct hda_bus *bus);

Thanks,
Ian

#13 lore raw

Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

At Fri, 3 Aug 2012 20:29:44 -0700,

Quoted 23 lines · Ian Minett
Quoted 10 lines

So, the data transfer here is just like the normal PCM streaming? For example, if you have an op like

           int (*load_dsp)(struct hda_bus *bus, void *buffer, int size);

and calling this for each segment would work?
(In addition, we'd need to give some way to determine the stop condition in the codec side.)

Hi,

Yes - this approach would work. We would also need to set the data format, and control the stop condition.

For example, by adding the following ops to handle the dsp download process:

/* format is 16-bit Stream Format Structure as defined in HDA spec.
pcm_prepare() callback in the codec will be called so that codec driver can obtain the stream tag and format to set up the codec.
*/

Quoted 8 lines
int (*load_dsp_prepare) \
      (struct hda_bus *bus, unsigned short format, void *buffer, int size);

/* start the transfer. */
int (*load_dsp_start)(struct hda_bus *bus);

/* stop the transfer and flush the FIFO. */
int (*load_dsp_stop)(struct hda_bus *bus);

Looks good, but I think start and stop can be a single trigger like PCM op, something like:

  int (*load_dsp_trigger)(struct hda_bus *bus, bool start);

The second argument could be a generic int like PCM op, but I don't think we'd need pause or suspend/resume command for DSP loader :)

Takashi

author
#14 lore raw

Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

Quoted 5 lines
Quoted 7 lines

Looks good, but I think start and stop can be a single trigger like PCM op, something like:

int (*load_dsp_trigger)(struct hda_bus *bus, bool start);

The second argument could be a generic int like PCM op, but I don't think we'd need pause or suspend/resume command for DSP loader :)

Hi Takashi,

The proposed method for handling the DSP load process looks fine to us, and we can make a start on adding this to the CA0132 driver now.

We can update patch_ca0132.c, but would you be able to assist us with the modifications to the hda_intel.c side at all? We think it might result in a smoother process (and involving fewer submissions :) ) given your familiarity with the low-level architecture in that area.

If not, we'd appreciate any info or pointers you can provide on how and where the necessary modifications need to be made to hda_intel.c.

Thanks again for all your help with this.
Ian

#15 lore raw

Re: [PATCHv2 - CA0132 HDA Codec 1/2] ALSA: Update Creative CA0132 codec to add DSP features.

At Tue, 7 Aug 2012 17:27:59 -0700,

Quoted 11 lines · Ian Minett
Quoted 8 lines

Looks good, but I think start and stop can be a single trigger like PCM op, something like:

int (*load_dsp_trigger)(struct hda_bus *bus, bool start);

The second argument could be a generic int like PCM op, but I don't think we'd need pause or suspend/resume command for DSP loader :)

Hi Takashi,

Quoted 7 lines

The proposed method for handling the DSP load process looks fine to us, and we can make a start on adding this to the CA0132 driver now.

We can update patch_ca0132.c, but would you be able to assist us with the modifications to the hda_intel.c side at all? We think it might result in a smoother process (and involving fewer submissions :) ) given your familiarity with the low-level architecture in that area.

Sure, just send me a draft version of your patch, so that I can work on it.

Quoted 2 lines

If not, we'd appreciate any info or pointers you can provide on how and where the necessary modifications need to be made to hda_intel.c.

You had already some working code but it was calling PCM ops. When you see hda_intel.c, the necessary streaming operations can be much easier implemented there instead of indirect call of PCM ops, if you have a dedicated load_dsp_prepare and load_dsp_trigger. The current azx_pcm_trigger(), for example, looks fairly complex, but it's simply because of the support for linked PCM streams. If you can assume a single stream, it's just a call of azx_stream_start() and azx_stream_stop().

BTW, what would be the license of the firmware?
For upstreaming the firmware, you'd need to clarify its license. You can see the license texts in kernel-firmware tree / package about what other vendors give.

thanks,

Takashi

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#17 lore raw

PATCH 2/2 Add DSP loader code to CA0132 codec

From: Ian Minett <[email protected]>

Draft patch to add new DSP loader code, with calls to load_dsp_xxxx() functions.

sound/pci/hda/patch_ca0132.c +28 -157
index 825f5b4..45dce9c 100644
@@ -1952,22 +1952,13 @@ struct dma_engine {
 	unsigned short m_converter_format;
 	void         *m_buffer_addr;
 	unsigned int m_buffer_size;
-	unsigned int m_req_size;
-	struct snd_pcm_substream *substream;
 };
 
 enum dma_state {
-	DMA_STATE_RESET = 0,
-	DMA_STATE_STOP  = 1,
-	DMA_STATE_RUN   = 2
+	DMA_STATE_STOP  = 0,
+	DMA_STATE_RUN   = 1
 };
 
-#define azx_pcm_open(a)       (a->ops->open(a))
-#define azx_pcm_close(a)      (a->ops->close(a))
-#define azx_pcm_prepare(a)    (a->ops->prepare(a))
-#define azx_pcm_trigger(a, b) (a->ops->trigger(a, b))
-#define azx_pcm_hw_free(a)    (a->ops->hw_free(a))
-
 static int dma_convert_to_hda_format(
 		struct hda_stream_format *stream_format,
 		unsigned short *hda_format)
@@ -1986,113 +1977,6 @@ static int dma_convert_to_hda_format(
 	return 0;
 }
 
-static int dma_init(
-		struct hda_codec *codec,
-		struct dma_engine **pp_dma,
-		struct hda_stream_format *stream_format,
-		unsigned short *format,
-		unsigned int req_size)
-{
-	struct dma_engine *dma;
-	struct snd_pcm_substream *substream;
-	struct snd_pcm *pcm;
-	struct snd_pcm_runtime *runtime;
-	unsigned int bits;
-	snd_pcm_uframes_t frames;
-
-	*pp_dma = NULL;
-	dma = kzalloc(sizeof(*dma), GFP_KERNEL);
-	memset((void *)dma, 0, sizeof(*dma));
-
-	dma_convert_to_hda_format(stream_format, format);
-	dma->m_converter_format = *format;
-
-	dma->substream = NULL;
-	pcm = codec->pcm_info->pcm;
-	for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
-				substream; substream = substream->next) {
-		if (codec->pcm_info->pcm_type == HDA_PCM_TYPE_SPDIF)
-			continue;
-
-		if (!SUBSTREAM_BUSY(substream)) {
-			dma->substream = substream;
-			break;
-		}
-	}
-
-	if (NULL == dma->substream) {
-		kfree(dma);
-		return -1;
-	}
-
-	runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
-	memset((void *)runtime, 0, sizeof(*runtime));
-	dma->substream->runtime = runtime;
-	dma->substream->private_data = pcm->private_data;
-
-	azx_pcm_open(dma->substream);
-	req_size = req_size * 2;
-	snd_pcm_lib_malloc_pages(dma->substream, req_size);
-
-	runtime->rate = stream_format->sample_rate;
-	runtime->channels = stream_format->number_channels;
-	runtime->format = SNDRV_PCM_FORMAT_S32_LE;
-	runtime->no_period_wakeup = 1;
-
-	bits = snd_pcm_format_physical_width(runtime->format);
-	runtime->sample_bits = bits;
-	bits *= runtime->channels;
-	runtime->frame_bits = bits;
-	frames = 1;
-	while (bits % 8 != 0) {
-		bits *= 2;
-		frames *= 2;
-	}
-	runtime->byte_align = bits / 8;
-	runtime->min_align = frames;
-	runtime->buffer_size = bytes_to_frames(runtime, req_size);
-	runtime->period_size = runtime->buffer_size;
-	dma->m_req_size = req_size;
-	dma->codec = codec;
-
-	*pp_dma = dma;
-	CA0132_LOG("dma_init: succeeded.\n");
-	return 0;
-}
-
-static int dma_prepare(struct dma_engine *dma)
-{
-	struct snd_pcm_runtime *runtime;
-	int err;
-
-	CA0132_LOG("dma_prepare: begin\n");
-	runtime = dma->substream->runtime;
-
-	err = azx_pcm_prepare(dma->substream);
-	if (err < 0)
-		return -1;
-
-	dma->m_buffer_size = snd_pcm_lib_buffer_bytes(dma->substream);
-	dma->m_buffer_addr = runtime->dma_area;
-
-	return 0;
-}
-
-static int dma_reset(struct dma_engine *dma)
-{
-	struct snd_pcm_runtime *runtime = dma->substream->runtime;
-
-	CA0132_LOG("dma_reset: begin\n");
-	azx_pcm_hw_free(dma->substream);
-	snd_pcm_lib_malloc_pages(dma->substream, dma->m_req_size);
-
-	azx_pcm_prepare(dma->substream);
-	dma->m_buffer_size = snd_pcm_lib_buffer_bytes(dma->substream);
-	dma->m_buffer_addr = runtime->dma_area;
-
-	return 0;
-}
-
 static int dma_set_state(struct dma_engine *dma, enum dma_state state)
 {
 	int cmd;
@@ -2100,9 +1984,6 @@ static int dma_set_state(struct dma_engine *dma, enum dma_state state)
 	CA0132_LOG("dma_set_state state=%d\n", state);
 
 	switch (state) {
-	case DMA_STATE_RESET:
-		dma_reset(dma);
-		return 0;
 	case DMA_STATE_STOP:
 		cmd = SNDRV_PCM_TRIGGER_STOP;
 		break;
@@ -2113,9 +1994,7 @@ static int dma_set_state(struct dma_engine *dma, enum dma_state state)
 		return 0;
 	}
 
-	azx_pcm_trigger(dma->substream, cmd);
-
-	return 0;
+	return load_dsp_trigger(dma->codec->bus, cmd);
 }
 
 static unsigned int dma_get_buffer_size(struct dma_engine *dma)
@@ -2128,15 +2007,6 @@ static unsigned int *dma_get_buffer_addr(struct dma_engine *dma)
 	return dma->m_buffer_addr;
 }
 
-static int dma_free_buffer(struct dma_engine *dma)
-{
-	azx_pcm_hw_free(dma->substream);
-	azx_pcm_close(dma->substream);
-	kfree(dma->substream->runtime);
-	dma->substream->runtime = NULL;
-	return 0;
-}
-
 static int dma_xfer(struct dma_engine *dma,
 		const unsigned int *data,
 		unsigned int count)
@@ -2160,13 +2030,6 @@ static unsigned int dma_get_stream_id(struct dma_engine *dma)
 	return spec->dsp_stream_id;
 }
 
-static int dma_exit(struct dma_engine *dma)
-{
-	CA0132_LOG("dma_exit\n");
-	kfree(dma);
-	return 0;
-}
-
 /*
  * CA0132 chip DSP image segment stuffs
  */
@@ -2384,7 +2247,6 @@ static int dspxfr_one_seg(struct hda_codec *codec,
 			}
 			CA0132_DSP_LOG("+++++ DMA complete");
 			dma_set_state(dma_engine, DMA_STATE_STOP);
-			dma_set_state(dma_engine, DMA_STATE_RESET);
 		}
 
 		CTASSERT(run_size_words <= words_to_write);
@@ -2413,17 +2275,29 @@ static int dspxfr_image(struct hda_codec *codec,
 	struct dma_engine *dma_engine;
 	unsigned int dma_chan;
 	unsigned int port_map_mask;
-	unsigned int buf_size;
 
 	CTASSERT(fls_data != NULL);
 	if (fls_data == NULL)
 		return -1;
 
-	buf_size = ovly ? DSP_DMA_WRITE_BUFLEN_OVLY : DSP_DMA_WRITE_BUFLEN_INIT;
-	status = dma_init(codec, &dma_engine, format, &hda_format, buf_size);
-
-	if (FAILED(status))
-		return -1;
+	dma_engine = kzalloc(sizeof(*dma_engine), GFP_KERNEL);
+	if (!dma_engine) {
+		status = -ENOMEM;
+		goto exit;
+	}
+	memset((void*)dma_engine, 0, sizeof(*dma_engine));
+	
+	dma_engine->codec = codec;
+	dma_convert_to_hda_format(format, &hda_format);
+	dma_engine->m_converter_format = hda_format;
+	dma_engine->m_buffer_size =
+	      ovly ? DSP_DMA_WRITE_BUFLEN_OVLY : DSP_DMA_WRITE_BUFLEN_INIT;
+	dma_engine->m_buffer_addr = kzalloc(dma_engine->m_buffer_size,
+					    GFP_KERNEL);
+	if (!dma_engine->m_buffer_addr) {
+		status = -ENOMEM;
+		goto exit;
+	}
 
 	dma_chan = 0;
 	do {
@@ -2434,7 +2308,10 @@ static int dspxfr_image(struct hda_codec *codec,
 			break;
 		}
 
-		status = dma_prepare(dma_engine);
+		status = load_dsp_prepare(codec->bus, 
+					 dma_engine->m_converter_format,
+					 dma_engine->m_buffer_addr,
+					 dma_engine->m_buffer_size);
 		if (FAILED(status))
 			break;
 
@@ -2495,15 +2372,9 @@ static int dspxfr_image(struct hda_codec *codec,
 	if (ovly && (dma_chan != INVALID_DMA_CHANNEL))
 		status = dspio_free_dma_chan(codec, dma_chan);
 
-	status = dma_set_state(dma_engine, DMA_STATE_RESET);
-	if (FAILED(status))
-		status = FAIL_MSG(status, "dma set state Reset fail");
-
-	status = dma_free_buffer(dma_engine);
-	if (FAILED(status))
-		status = FAIL_MSG(status, "dma free buffer fail");
-
-	dma_exit(dma_engine);
+exit:
+	kfree(dma_engine->m_buffer_addr);
+	kfree(dma_engine);
 
 	return status;
 }
Signature · 1 line
1.7.4.1
#18 lore raw

Re: [PATCHv2.1-CA0132 HDA Codec 2/2] Add DSP loader code to CA0132 codec

At Fri, 10 Aug 2012 23:17:52 -0700,

Quoted 7 lines · Ian Minett

From: Ian Minett <[email protected]>

Draft patch to add new DSP loader code, with calls to load_dsp_xxxx() functions.

(snip)

sound/pci/hda/patch_ca0132.c static int dma_set_state(struct dma_engine *dma, enum dma_state state) · line 1997

Quoted 8 lines
sound/pci/hda/patch_ca0132.c +1 -3
@@ -2113,9 +1994,7 @@ static int dma_set_state(struct dma_engine *dma, enum dma_state state)
 		return 0;
 	}
 
-	azx_pcm_trigger(dma->substream, cmd);
-
-	return 0;
+	return load_dsp_trigger(dma->codec->bus, cmd);

Maybe we just need to pass a boolean to start/stop.

sound/pci/hda/patch_ca0132.c static unsigned int *dma_get_buffer_addr(struct dma_engine *dma) · line 2137

Quoted 12 lines
sound/pci/hda/patch_ca0132.c +0 -7
 static unsigned int dma_get_buffer_size(struct dma_engine *dma)
@@ -2128,15 +2007,6 @@ static unsigned int *dma_get_buffer_addr(struct dma_engine *dma)
 	return dma->m_buffer_addr;
 }
 
-static int dma_free_buffer(struct dma_engine *dma)
-{
-	azx_pcm_hw_free(dma->substream);
-	azx_pcm_close(dma->substream);
-	kfree(dma->substream->runtime);
-	dma->substream->runtime = NULL;
-	return 0;

OK, I forgot that a cleanup callback is also required...

sound/pci/hda/patch_ca0132.c static int dspxfr_image(struct hda_codec *codec, · line 2296

Quoted 7 lines
sound/pci/hda/patch_ca0132.c +7 -0
+	dma_engine->codec = codec;
+	dma_convert_to_hda_format(format, &hda_format);
+	dma_engine->m_converter_format = hda_format;
+	dma_engine->m_buffer_size =
+	      ovly ? DSP_DMA_WRITE_BUFLEN_OVLY : DSP_DMA_WRITE_BUFLEN_INIT;
+	dma_engine->m_buffer_addr = kzalloc(dma_engine->m_buffer_size,
+					    GFP_KERNEL);

Allocating the DMA transfer buffer via kmalloc doesn't work. The buffer must be aligned and coherent. Thus it's better to let the buffer management in hda_intel.c.

In the end, what we need in hda_intel.c are:
- a function to allocate buffer, setup BDL and DMA, return the pointer
- a function to start/stop transfer
- a function to clean up DMA, release the buffer

Thus the hda_bus_ops will gain the following ops:

/* bus operators */
struct hda_bus_ops {
...

#ifdef CONFIG_SND_HDA_LOAD_DSP
	/* prepare DSP transfer */
	void *(*load_dsp_prepare)(struct hda_codec *codec, unsigned int format,
				  unsigned int byte_size);
	/* start/stop DSP transfer */
	void (*load_dsp_trigger)(struct hda_codec *codec, bool start);
	/* clean up DSP transfer */
	void (*load_dsp_cleanup)(struct hda_codec *codec, void *buf,
				 unsigned int byte_size);

#endif
};

Then define the function like

static inline void *
snd_hda_codec_load_dsp_prepare(struct hda_codec *codec, unsigned int format,
unsigned int size)

{
	return codec->bus->ops.load_dsp_prepare(codec, format, size);
}

and so on.

A remaining question is:
- what is the condition to operate DSP transfer? Must all PCM streams be closed and streams are released?

Takashi

author
#19 lore raw

Re: [PATCHv2.1-CA0132 HDA Codec 2/2] Add DSP loader code to CA0132 codec

Quoted 7 lines

So the point is to concentrate only on DMA transfer stuff at first. Once after confirmed it's working, continue to the new DSP features.,

Ok, that makes sense.

Quoted 3 lines

A remaining question is:
- what is the condition to operate DSP transfer? Must all PCM streams be closed and streams are released?

Yes, all PCM streams need to be closed and released for the DSP transfer. Since the driver loads the DSP during the init phase, there shouldn't be any active streams at that time.

- Ian

Notice
The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying or distribution of the message, or any action taken by you in reliance on it, is prohibited and may be unlawful. This email is for communication purposes only. It is not intended to constitute an offer or form a binding agreement. Our company accepts no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided. If you have received this message in error, please delete it and contact the sender immediately. Thank you.

             Takashi Iwai                                              
             <[email protected]>                                           
                                                                                                 To
             08/11/2012 12:12 AM                 Ian Minett <[email protected]>
                                                                                                 cc
                                                 [email protected]
                                                                                            Subject
                                                 Re: [PATCHv2.1-CA0132 HDA Codec 2/2] Add DSP
                                                 loader code to CA0132 codec

At Fri, 10 Aug 2012 23:17:52 -0700,

Quoted 7 lines · Ian Minett

From: Ian Minett <[email protected]>

Draft patch to add new DSP loader code, with calls to load_dsp_xxxx() functions.

(snip)

sound/pci/hda/patch_ca0132.c static int dma_set_state(struct dma_engine *dma, enum dma_state state) · line 1997

Quoted 8 lines
sound/pci/hda/patch_ca0132.c +1 -3
@@ -2113,9 +1994,7 @@ static int dma_set_state(struct dma_engine *dma, enum dma_state state)
                       return 0;
           }
 
-          azx_pcm_trigger(dma->substream, cmd);
-
-          return 0;
+          return load_dsp_trigger(dma->codec->bus, cmd);

Maybe we just need to pass a boolean to start/stop.

sound/pci/hda/patch_ca0132.c static unsigned int *dma_get_buffer_addr(struct dma_engine *dma) · line 2137

Quoted 12 lines
sound/pci/hda/patch_ca0132.c +0 -7
 static unsigned int dma_get_buffer_size(struct dma_engine *dma)
@@ -2128,15 +2007,6 @@ static unsigned int *dma_get_buffer_addr(struct dma_engine *dma)
           return dma->m_buffer_addr;
 }
 
-static int dma_free_buffer(struct dma_engine *dma)
-{
-          azx_pcm_hw_free(dma->substream);
-          azx_pcm_close(dma->substream);
-          kfree(dma->substream->runtime);
-          dma->substream->runtime = NULL;
-          return 0;

OK, I forgot that a cleanup callback is also required...

sound/pci/hda/patch_ca0132.c static int dspxfr_image(struct hda_codec *codec, · line 2296

Quoted 7 lines
sound/pci/hda/patch_ca0132.c +7 -0
+          dma_engine->codec = codec;
+          dma_convert_to_hda_format(format, &hda_format);
+          dma_engine->m_converter_format = hda_format;
+          dma_engine->m_buffer_size =
+                ovly ? DSP_DMA_WRITE_BUFLEN_OVLY : DSP_DMA_WRITE_BUFLEN_INIT;
+          dma_engine->m_buffer_addr = kzalloc(dma_engine->m_buffer_size,
+                                                              GFP_KERNEL);

Allocating the DMA transfer buffer via kmalloc doesn't work. The buffer must be aligned and coherent. Thus it's better to let the buffer management in hda_intel.c.

In the end, what we need in hda_intel.c are:
- a function to allocate buffer, setup BDL and DMA, return the pointer
- a function to start/stop transfer
- a function to clean up DMA, release the buffer

Thus the hda_bus_ops will gain the following ops:

/* bus operators */
struct hda_bus_ops {
...

#ifdef CONFIG_SND_HDA_LOAD_DSP
             /* prepare DSP transfer */
             void *(*load_dsp_prepare)(struct hda_codec *codec, unsigned int format,
                                                   unsigned int byte_size);
             /* start/stop DSP transfer */
             void (*load_dsp_trigger)(struct hda_codec *codec, bool start);
             /* clean up DSP transfer */
             void (*load_dsp_cleanup)(struct hda_codec *codec, void *buf,
                                                  unsigned int byte_size);

#endif
};

Then define the function like

static inline void *
snd_hda_codec_load_dsp_prepare(struct hda_codec *codec, unsigned int format,
unsigned int size)

{
             return codec->bus->ops.load_dsp_prepare(codec, format, size);
}

and so on.

A remaining question is:
- what is the condition to operate DSP transfer? Must all PCM streams be closed and streams are released?

Takashi

ForwardSourceID:NT0001D94A

author
#20 lore raw

PATCH 1/1 Draft DSP loader update #2

In reply to Takashi Iwai

From: Ian Minett <[email protected]>

Thanks for the recent feedback - based on that we've updated the recent draft patch for adding the DSP loader to patch_ca0132.c :

- move DMA buffer management out (to be handled in hda_intel)
- add call to cleanup DMA
- change start/stop flag to boolean

If the changes look acceptable, do we have enough for us to get started on adding the DSP loader updates to patch_ca0132 (working with the 'from scratch' CA0132 as you suggested)?

Please let us know if you can think of anything else that needs to be worked out, or anything we need to provide for the bus op mods.

Thanks very much,
Ian

sound/pci/hda/patch_ca0132.c +14 -21
index 45dce9c..0d07445 100644
@@ -1979,22 +1979,22 @@ static int dma_convert_to_hda_format(
 
 static int dma_set_state(struct dma_engine *dma, enum dma_state state)
 {
-	int cmd;
+	bool cmd;
 
 	CA0132_LOG("dma_set_state state=%d\n", state);
 
 	switch (state) {
 	case DMA_STATE_STOP:
-		cmd = SNDRV_PCM_TRIGGER_STOP;
+		cmd = false;
 		break;
 	case DMA_STATE_RUN:
-		cmd = SNDRV_PCM_TRIGGER_START;
+		cmd = true;
 		break;
 	default:
 		return 0;
 	}
 
-	return load_dsp_trigger(dma->codec->bus, cmd);
+	return snd_hda_codec_load_dsp_trigger(dma->codec, cmd);
 }
 
 static unsigned int dma_get_buffer_size(struct dma_engine *dma)
@@ -2281,10 +2281,8 @@ static int dspxfr_image(struct hda_codec *codec,
 		return -1;
 
 	dma_engine = kzalloc(sizeof(*dma_engine), GFP_KERNEL);
-	if (!dma_engine) {
-		status = -ENOMEM;
-		goto exit;
-	}
+	if (!dma_engine)
+		return -ENOMEM;
 	memset((void*)dma_engine, 0, sizeof(*dma_engine));
 	
 	dma_engine->codec = codec;
@@ -2292,12 +2290,6 @@ static int dspxfr_image(struct hda_codec *codec,
 	dma_engine->m_converter_format = hda_format;
 	dma_engine->m_buffer_size =
 	      ovly ? DSP_DMA_WRITE_BUFLEN_OVLY : DSP_DMA_WRITE_BUFLEN_INIT;
-	dma_engine->m_buffer_addr = kzalloc(dma_engine->m_buffer_size,
-					    GFP_KERNEL);
-	if (!dma_engine->m_buffer_addr) {
-		status = -ENOMEM;
-		goto exit;
-	}
 
 	dma_chan = 0;
 	do {
@@ -2308,11 +2300,11 @@ static int dspxfr_image(struct hda_codec *codec,
 			break;
 		}
 
-		status = load_dsp_prepare(codec->bus, 
-					 dma_engine->m_converter_format,
-					 dma_engine->m_buffer_addr,
-					 dma_engine->m_buffer_size);
-		if (FAILED(status))
+		dma_engine->m_buffer_addr =
+		snd_hda_codec_load_dsp_prepare(codec,
+						dma_engine->m_converter_format,
+						dma_engine->m_buffer_size);
+		if (!dma_engine->m_buffer_addr)
 			break;
 
 		if (ovly) {
@@ -2372,8 +2364,9 @@ static int dspxfr_image(struct hda_codec *codec,
 	if (ovly && (dma_chan != INVALID_DMA_CHANNEL))
 		status = dspio_free_dma_chan(codec, dma_chan);
 
-exit:
-	kfree(dma_engine->m_buffer_addr);
+	snd_hda_codec_load_dsp_cleanup(codec,
+				       dma_engine->m_buffer_addr,
+				       dma_engine->m_buffer_size);
 	kfree(dma_engine);
 
 	return status;
Signature · 1 line
1.7.4.1
#21 lore raw

Re: [PATCHv2.1-CA0132 HDA Codec 1/1] Draft DSP loader update #2

At Tue, 14 Aug 2012 22:50:06 -0700,

Quoted 10 lines · Ian Minett

From: Ian Minett <[email protected]>

Thanks for the recent feedback - based on that we've updated the recent draft patch for adding the DSP loader to patch_ca0132.c :

- move DMA buffer management out (to be handled in hda_intel)
- add call to cleanup DMA
- change start/stop flag to boolean

Quoted 6 lines

If the changes look acceptable, do we have enough for us to get started on adding the DSP loader updates to patch_ca0132 (working with the 'from scratch' CA0132 as you suggested)?

Please let us know if you can think of anything else that needs to be worked out, or anything we need to provide for the bus op mods.

Any missing thing will be revealed later once when you start coding the DSP loader part in hda_intel.c :)

So now, as I suggested, start writing a code just loading the firmware DSP code based on the _bare_ upstream tree. That is, don't base on the already modified patch_ca0132.c or hda_intel.c. Write a patch that can be applied on the top of the current Linus tree, for example.

There shouldn't be any addition of controls, etc, at this point. Just do load the firmware. This is the very first start.

I can help debugging or give review / advise. But obviously you are at the better position start writing it since you have the test hardware and the firmware data, both of which are missing for other developers (including me).

Once when a draft patch is ready or you face to a problem, let me know.

thanks,

Takashi

Quoted 95 lines

Thanks very much,
Ian

sound/pci/hda/patch_ca0132.c +14 -21
index 45dce9c..0d07445 100644
@@ -1979,22 +1979,22 @@ static int dma_convert_to_hda_format(
 
 static int dma_set_state(struct dma_engine *dma, enum dma_state state)
 {
-	int cmd;
+	bool cmd;
 
 	CA0132_LOG("dma_set_state state=%d\n", state);
 
 	switch (state) {
 	case DMA_STATE_STOP:
-		cmd = SNDRV_PCM_TRIGGER_STOP;
+		cmd = false;
 		break;
 	case DMA_STATE_RUN:
-		cmd = SNDRV_PCM_TRIGGER_START;
+		cmd = true;
 		break;
 	default:
 		return 0;
 	}
 
-	return load_dsp_trigger(dma->codec->bus, cmd);
+	return snd_hda_codec_load_dsp_trigger(dma->codec, cmd);
 }
 
 static unsigned int dma_get_buffer_size(struct dma_engine *dma)
@@ -2281,10 +2281,8 @@ static int dspxfr_image(struct hda_codec *codec,
 		return -1;
 
 	dma_engine = kzalloc(sizeof(*dma_engine), GFP_KERNEL);
-	if (!dma_engine) {
-		status = -ENOMEM;
-		goto exit;
-	}
+	if (!dma_engine)
+		return -ENOMEM;
 	memset((void*)dma_engine, 0, sizeof(*dma_engine));
 
 	dma_engine->codec = codec;
@@ -2292,12 +2290,6 @@ static int dspxfr_image(struct hda_codec *codec,
 	dma_engine->m_converter_format = hda_format;
 	dma_engine->m_buffer_size =
 	      ovly ? DSP_DMA_WRITE_BUFLEN_OVLY : DSP_DMA_WRITE_BUFLEN_INIT;
-	dma_engine->m_buffer_addr = kzalloc(dma_engine->m_buffer_size,
-					    GFP_KERNEL);
-	if (!dma_engine->m_buffer_addr) {
-		status = -ENOMEM;
-		goto exit;
-	}
 
 	dma_chan = 0;
 	do {
@@ -2308,11 +2300,11 @@ static int dspxfr_image(struct hda_codec *codec,
 			break;
 		}
 
-		status = load_dsp_prepare(codec->bus, 
-					 dma_engine->m_converter_format,
-					 dma_engine->m_buffer_addr,
-					 dma_engine->m_buffer_size);
-		if (FAILED(status))
+		dma_engine->m_buffer_addr =
+		snd_hda_codec_load_dsp_prepare(codec,
+						dma_engine->m_converter_format,
+						dma_engine->m_buffer_size);
+		if (!dma_engine->m_buffer_addr)
 			break;
 
 		if (ovly) {
@@ -2372,8 +2364,9 @@ static int dspxfr_image(struct hda_codec *codec,
 	if (ovly && (dma_chan != INVALID_DMA_CHANNEL))
 		status = dspio_free_dma_chan(codec, dma_chan);
 
-exit:
-	kfree(dma_engine->m_buffer_addr);
+	snd_hda_codec_load_dsp_cleanup(codec,
+				       dma_engine->m_buffer_addr,
+				       dma_engine->m_buffer_size);
 	kfree(dma_engine);
 
 	return status;
Signature · 1 line
1.7.4.1
author
#22 lore raw

Re: [PATCHv2.1-CA0132 HDA Codec 1/1] Draft DSP loader update #2

Quoted 8 lines

There shouldn't be any addition of controls, etc, at this point. Just do load the firmware. This is the very first start.

Quoted 7 lines

I can help debugging or give review / advise. But obviously you are at the better position start writing it since you have the test hardware and the firmware data, both of which are missing for other developers (including me).

Once when a draft patch is ready or you face to a problem, let me know.

Ok, thanks.
We do seem to be having problems in the DSP load prepare function:

void *(*load_dsp_prepare)(struct hda_codec *codec, unsigned int format,

                          unsigned int byte_size);

This is the place where the buffer gets allocated, and BDL and DMA set up, and the pointer returned.
Is there any sample code or other info you could provide, to give us a better idea of how the function and these actions should be implemented?

Thanks very much,
- Ian

#23 lore raw

Re: [PATCHv2.1-CA0132 HDA Codec 1/1] Draft DSP loader update #2

At Tue, 21 Aug 2012 18:36:01 -0700,

Quoted 16 lines · Ian Minett
Quoted 5 lines

There shouldn't be any addition of controls, etc, at this point. Just do load the firmware. This is the very first start.

Quoted 7 lines

I can help debugging or give review / advise. But obviously you are at the better position start writing it since you have the test hardware and the firmware data, both of which are missing for other developers (including me).

Once when a draft patch is ready or you face to a problem, let me know.

Ok, thanks.
We do seem to be having problems in the DSP load prepare function:

Quoted 7 lines

void *(*load_dsp_prepare)(struct hda_codec *codec, unsigned int format,

                          unsigned int byte_size);

This is the place where the buffer gets allocated, and BDL and DMA set up, and the pointer returned.
Is there any sample code or other info you could provide, to give us a better idea of how the function and these actions should be implemented?

Maybe better to start from a bit clean up of SG buffer handling code in general. The first patch below makes the sg-buffer helpers more generic so that they can be called even without sg-buffer support.

Then, setup_bdle() in hda_intel.c can be changed cleanly by passing struct snd_dma_buffer pointer, as found in the second patch.

The rest of the second patch is the additions of callbacks supposedly needed for your case.

load_dsp_prepare() callback takes parameters of the format value (encoded by snd_hda_calc_stream_format()), the byte size of the buffer to allocate, and a pointer to struct snd_dma_buffer. It'll return the stream tag in success, or a negative error code. The allocated buffer is stored in snd_dma_buffer.area pointer. It'll be an SG-buffer, but can be accessed linearly by that pointer.

Then, the caller should set up the codec by itself. Unlike PCM prepare, it doesn't set up the codec, as the DSP loading might need more special setups.

After setting up these and the buffer is filled, call load_dsp_trigger() callback. It's a simple start/stop of the controller.

Then call load_dsp_clean() callback. The buffer will be released there, too.

Takashi

Quoted 1 line

From c7b5d707a25f57c8bc38a9d7b7a61b8db45d37e1 Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Wed, 22 Aug 2012 14:36:32 +0200
Subject: [PATCH] ALSA: Make snd_sgbuf_get_{ptr|addr}() available for non-SG
cases

Passing struct snd_dma_buffer pointer instead, so that they work no matter whether real SG buffer is used or not.

This is a preliminary work for the HD-audio DSP loader code.

---
 include/sound/memalloc.h | 27 +++++++++++++++++++++++++--
 include/sound/pcm.h      | 39 ++++++++++++++-------------------------
 sound/core/pcm_memory.c  | 26 --------------------------
 sound/core/sgbuf.c       | 28 ++++++++++++++++++++++++++++
 4 files changed, 67 insertions(+), 53 deletions(-)
include/sound/memalloc.h +25 -2
index c425062..9201520 100644
@@ -98,8 +98,10 @@ static inline unsigned int snd_sgbuf_aligned_pages(size_t size)
 /*
  * return the physical address at the corresponding offset
  */
-static inline dma_addr_t snd_sgbuf_get_addr(struct snd_sg_buf *sgbuf, size_t offset)
+static inline dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab,
+					    size_t offset)
 {
+	struct snd_sg_buf *sgbuf = dmab->private_data;
 	dma_addr_t addr = sgbuf->table[offset >> PAGE_SHIFT].addr;
 	addr &= PAGE_MASK;
 	return addr + offset % PAGE_SIZE;
@@ -108,10 +110,31 @@ static inline dma_addr_t snd_sgbuf_get_addr(struct snd_sg_buf *sgbuf, size_t off
 /*
  * return the virtual address at the corresponding offset
  */
-static inline void *snd_sgbuf_get_ptr(struct snd_sg_buf *sgbuf, size_t offset)
+static inline void *snd_sgbuf_get_ptr(struct snd_dma_buffer *dmab,
+				      size_t offset)
 {
+	struct snd_sg_buf *sgbuf = dmab->private_data;
 	return sgbuf->table[offset >> PAGE_SHIFT].buf + offset % PAGE_SIZE;
 }
+
+unsigned int snd_sgbuf_get_chunk_size(struct snd_dma_buffer *dmab,
+				      unsigned int ofs, unsigned int size);
+#else
+/* non-SG versions */
+static inline dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab,
+					    size_t offset)
+{
+	return dmab->addr + offset;
+}
+
+static inline void *snd_sgbuf_get_ptr(struct snd_dma_buffer *dmab,
+				      size_t offset)
+{
+	return dmab->area + offset;
+}
+
+#define snd_sgbuf_get_chunk_size(dmab, ofs, size)	(size)
+
 #endif /* CONFIG_SND_DMA_SGBUF */
 
 /* allocate/release a buffer */
include/sound/pcm.h +14 -25
index cdca2ab..0c054b9 100644
@@ -982,53 +982,42 @@ static int snd_pcm_lib_alloc_vmalloc_32_buffer
 	_snd_pcm_lib_alloc_vmalloc_buffer \
 			(subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO)
 
+#define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p)
+
 #ifdef CONFIG_SND_DMA_SGBUF
 /*
  * SG-buffer handling
  */
 #define snd_pcm_substream_sgbuf(substream) \
-	((substream)->runtime->dma_buffer_p->private_data)
-
-static inline dma_addr_t
-snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs)
-{
-	struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream);
-	return snd_sgbuf_get_addr(sg, ofs);
-}
-
-static inline void *
-snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs)
-{
-	struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream);
-	return snd_sgbuf_get_ptr(sg, ofs);
-}
+	snd_pcm_get_dma_buf(substream)->private_data
 
 struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream,
 				    unsigned long offset);
-unsigned int snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream,
-					  unsigned int ofs, unsigned int size);
-
 #else /* !SND_DMA_SGBUF */
 /*
  * fake using a continuous buffer
  */
+#define snd_pcm_sgbuf_ops_page	NULL
+#endif /* SND_DMA_SGBUF */
+
 static inline dma_addr_t
 snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs)
 {
-	return substream->runtime->dma_addr + ofs;
+	return snd_sgbuf_get_addr(snd_pcm_get_dma_buf(substream), ofs);
 }
 
 static inline void *
 snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs)
 {
-	return substream->runtime->dma_area + ofs;
+	return snd_sgbuf_get_ptr(snd_pcm_get_dma_buf(substream), ofs);
 }
 
-#define snd_pcm_sgbuf_ops_page	NULL
-
-#define snd_pcm_sgbuf_get_chunk_size(subs, ofs, size)	(size)
-
-#endif /* SND_DMA_SGBUF */
+static inline unsigned int
+snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream,
+			     unsigned int ofs, unsigned int size)
+{
+	return snd_sgbuf_get_chunk_size(snd_pcm_get_dma_buf(substream), ofs, size);
+}
 
 /* handle mmap counter - PCM mmap callback should handle this counter properly */
 static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area)
sound/core/pcm_memory.c +0 -26
index 9571313..69e01c4 100644
@@ -327,32 +327,6 @@ struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigne
 }
 
 EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page);
-
-/*
- * compute the max chunk size with continuous pages on sg-buffer
- */
-unsigned int snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream,
-					  unsigned int ofs, unsigned int size)
-{
-	struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream);
-	unsigned int start, end, pg;
-
-	start = ofs >> PAGE_SHIFT;
-	end = (ofs + size - 1) >> PAGE_SHIFT;
-	/* check page continuity */
-	pg = sg->table[start].addr >> PAGE_SHIFT;
-	for (;;) {
-		start++;
-		if (start > end)
-			break;
-		pg++;
-		if ((sg->table[start].addr >> PAGE_SHIFT) != pg)
-			return (start << PAGE_SHIFT) - ofs;
-	}
-	/* ok, all on continuous pages */
-	return size;
-}
-EXPORT_SYMBOL(snd_pcm_sgbuf_get_chunk_size);
 #endif /* CONFIG_SND_DMA_SGBUF */
 
 /**
sound/core/sgbuf.c +28 -0
index d0f0035..da3c619 100644
@@ -22,6 +22,7 @@
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
+#include <linux/export.h>
 #include <sound/memalloc.h>
 
 
@@ -136,3 +137,30 @@ void *snd_malloc_sgbuf_pages(struct device *device,
 	snd_free_sgbuf_pages(dmab); /* free the table */
 	return NULL;
 }
+
+
+/*
+ * compute the max chunk size with continuous pages on sg-buffer
+ */
+unsigned int snd_sgbuf_get_chunk_size(struct snd_dma_buffer *dmab,
+				      unsigned int ofs, unsigned int size)
+{
+	struct snd_sg_buf *sg = dmab->private_data;
+	unsigned int start, end, pg;
+
+	start = ofs >> PAGE_SHIFT;
+	end = (ofs + size - 1) >> PAGE_SHIFT;
+	/* check page continuity */
+	pg = sg->table[start].addr >> PAGE_SHIFT;
+	for (;;) {
+		start++;
+		if (start > end)
+			break;
+		pg++;
+		if ((sg->table[start].addr >> PAGE_SHIFT) != pg)
+			return (start << PAGE_SHIFT) - ofs;
+	}
+	/* ok, all on continuous pages */
+	return size;
+}
+EXPORT_SYMBOL(snd_sgbuf_get_chunk_size);
Signature · 1 line
1.7.11.4
sound/pci/hda/hda_intel.c +96 -6

138 lines not on this page · raw message

#24 lore raw

Re: [PATCHv2.1-CA0132 HDA Codec 1/2] Add DSP loader code to CA0132 codec

In reply to a message not in the archive

At Fri, 10 Aug 2012 23:17:51 -0700,

Quoted 11 lines · Ian Minett

From: Ian Minett <[email protected]>

Hi Takashi,
Great, it's good to hear that you are able to assist with adding the DSP loader modifications to hda_intel.c.

I've attached a draft patch as you requested. Please let us know if you have any questions concerning it. The first patch is the previous update to add DSP features to patch_ca0132, then the second is the draft patch, to add the new DMA loader calls.

Well, for cleanness, I think we should start rather from scratch:

- The first patch to add a new hda_bus_ops for DSP transfer; it won't touch patch_ca0132.c but only the core part (hda_intel.c, hda_codec.[ch])

- Add the DSP transfer to patch_ca0132.c;
at this point, just do DMA transfer but no new mixers etc won't be added

- Add new features to patch_ca0132.c

At the early development stage, the first two items can be a single patch. We can split to two when applied to the upstream. But, mixing all changes in a single patch is pretty bad.
So the point is to concentrate only on DMA transfer stuff at first. Once after confirmed it's working, continue to the new DSP features.

Quoted 2 lines

We're also currently ascertaining the license information to go along with the firmware binary release.

Good. This is really mandatory for upstreaming.

Quoted 7 lines

The project team would like to know, beyond the outstanding items mentioned above, do you see any other potential issues with the updates to the codec that could possibly slow the submission process? We're starting to get rather close to our target date.
Also, once the codec has made it into the ALSA tree, how long do you estimate it would take before it is upstreamed to the Linux kernel? If you could provide any info on the timeframe for this process, we'd greatly appreciate it.

Heh, this depends on how hard we work :)
If it can be quickly done, it'll be merged even in 3.7 kernel.

Takashi