summaryrefslogtreecommitdiffstats
path: root/sound/pci/korg1212/korg1212.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/korg1212/korg1212.c')
-rw-r--r--sound/pci/korg1212/korg1212.c935
1 files changed, 432 insertions, 503 deletions
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index a110d664f626..4eddb512c12f 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -41,8 +41,16 @@
// Debug Stuff
// ----------------------------------------------------------------------------
#define K1212_DEBUG_LEVEL 0
-#define K1212_DEBUG_PRINTK printk
-//#define K1212_DEBUG_PRINTK(x...) printk("<0>" x)
+#if K1212_DEBUG_LEVEL > 0
+#define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args)
+#else
+#define K1212_DEBUG_PRINTK(fmt,...)
+#endif
+#if K1212_DEBUG_LEVEL > 1
+#define K1212_DEBUG_PRINTK_VERBOSE(fmt,args...) printk(KERN_DEBUG fmt,##args)
+#else
+#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...)
+#endif
// ----------------------------------------------------------------------------
// Record/Play Buffer Allocation Method. If K1212_LARGEALLOC is defined all
@@ -53,7 +61,7 @@
// ----------------------------------------------------------------------------
// Valid states of the Korg 1212 I/O card.
// ----------------------------------------------------------------------------
-typedef enum {
+enum CardState {
K1212_STATE_NONEXISTENT, // there is no card here
K1212_STATE_UNINITIALIZED, // the card is awaiting DSP download
K1212_STATE_DSP_IN_PROCESS, // the card is currently downloading its DSP code
@@ -69,13 +77,13 @@ typedef enum {
K1212_STATE_ERRORSTOP, // the card has stopped itself because of an error and we
// are in the process of cleaning things up.
K1212_STATE_MAX_STATE // state values of this and beyond are invalid
-} CardState;
+};
// ----------------------------------------------------------------------------
// The following enumeration defines the constants written to the card's
// host-to-card doorbell to initiate a command.
// ----------------------------------------------------------------------------
-typedef enum {
+enum korg1212_dbcnst {
K1212_DB_RequestForData = 0, // sent by the card to request a buffer fill.
K1212_DB_TriggerPlay = 1, // starts playback/record on the card.
K1212_DB_SelectPlayMode = 2, // select monitor, playback setup, or stop.
@@ -93,14 +101,14 @@ typedef enum {
K1212_DB_DSPDownloadDone = 0xAE, // sent by the card to indicate the download has
// completed.
K1212_DB_StartDSPDownload = 0xAF // tells the card to download its DSP firmware.
-} korg1212_dbcnst_t;
+};
// ----------------------------------------------------------------------------
// The following enumeration defines return codes
// to the Korg 1212 I/O driver.
// ----------------------------------------------------------------------------
-typedef enum {
+enum snd_korg1212rc {
K1212_CMDRET_Success = 0, // command was successfully placed
K1212_CMDRET_DIOCFailure, // the DeviceIoControl call failed
K1212_CMDRET_PMFailure, // the protected mode call failed
@@ -118,27 +126,27 @@ typedef enum {
K1212_CMDRET_BadDevice, // the specified wave device was out of range
K1212_CMDRET_BadFormat // the specified wave format is unsupported
-} snd_korg1212rc;
+};
// ----------------------------------------------------------------------------
// The following enumeration defines the constants used to select the play
// mode for the card in the SelectPlayMode command.
// ----------------------------------------------------------------------------
-typedef enum {
+enum PlayModeSelector {
K1212_MODE_SetupPlay = 0x00000001, // provides card with pre-play information
K1212_MODE_MonitorOn = 0x00000002, // tells card to turn on monitor mode
K1212_MODE_MonitorOff = 0x00000004, // tells card to turn off monitor mode
K1212_MODE_StopPlay = 0x00000008 // stops playback on the card
-} PlayModeSelector;
+};
// ----------------------------------------------------------------------------
// The following enumeration defines the constants used to select the monitor
// mode for the card in the SetMonitorMode command.
// ----------------------------------------------------------------------------
-typedef enum {
+enum MonitorModeSelector {
K1212_MONMODE_Off = 0, // tells card to turn off monitor mode
K1212_MONMODE_On // tells card to turn on monitor mode
-} MonitorModeSelector;
+};
#define MAILBOX0_OFFSET 0x40 // location of mailbox 0 relative to base address
#define MAILBOX1_OFFSET 0x44 // location of mailbox 1 relative to base address
@@ -180,7 +188,7 @@ typedef enum {
#define K1212_CHANNELS (K1212_ADAT_CHANNELS + K1212_ANALOG_CHANNELS)
#define K1212_MIN_CHANNELS 1
#define K1212_MAX_CHANNELS K1212_CHANNELS
-#define K1212_FRAME_SIZE (sizeof(KorgAudioFrame))
+#define K1212_FRAME_SIZE (sizeof(struct KorgAudioFrame))
#define K1212_MAX_SAMPLES (kPlayBufferFrames*kNumBuffers)
#define K1212_PERIODS (kNumBuffers)
#define K1212_PERIOD_BYTES (K1212_FRAME_SIZE*kPlayBufferFrames)
@@ -256,14 +264,7 @@ typedef enum {
#include "korg1212-firmware.h"
-typedef struct _snd_korg1212 korg1212_t;
-
-typedef u16 K1212Sample; // channels 0-9 use 16 bit samples
-typedef u32 K1212SpdifSample; // channels 10-11 use 32 bits - only 20 are sent
- // across S/PDIF.
-typedef u32 K1212TimeCodeSample; // holds the ADAT timecode value
-
-typedef enum {
+enum ClockSourceIndex {
K1212_CLKIDX_AdatAt44_1K = 0, // selects source as ADAT at 44.1 kHz
K1212_CLKIDX_AdatAt48K, // selects source as ADAT at 48 kHz
K1212_CLKIDX_WordAt44_1K, // selects source as S/PDIF at 44.1 kHz
@@ -271,36 +272,36 @@ typedef enum {
K1212_CLKIDX_LocalAt44_1K, // selects source as local clock at 44.1 kHz
K1212_CLKIDX_LocalAt48K, // selects source as local clock at 48 kHz
K1212_CLKIDX_Invalid // used to check validity of the index
-} ClockSourceIndex;
+};
-typedef enum {
+enum ClockSourceType {
K1212_CLKIDX_Adat = 0, // selects source as ADAT
K1212_CLKIDX_Word, // selects source as S/PDIF
K1212_CLKIDX_Local // selects source as local clock
-} ClockSourceType;
+};
-typedef struct KorgAudioFrame {
- K1212Sample frameData16[k16BitChannels];
- K1212SpdifSample frameData32[k32BitChannels];
- K1212TimeCodeSample timeCodeVal;
-} KorgAudioFrame;
+struct KorgAudioFrame {
+ u16 frameData16[k16BitChannels]; /* channels 0-9 use 16 bit samples */
+ u32 frameData32[k32BitChannels]; /* channels 10-11 use 32 bits - only 20 are sent across S/PDIF */
+ u32 timeCodeVal; /* holds the ADAT timecode value */
+};
-typedef struct KorgAudioBuffer {
- KorgAudioFrame bufferData[kPlayBufferFrames]; /* buffer definition */
-} KorgAudioBuffer;
+struct KorgAudioBuffer {
+ struct KorgAudioFrame bufferData[kPlayBufferFrames]; /* buffer definition */
+};
-typedef struct KorgSharedBuffer {
+struct KorgSharedBuffer {
#ifdef K1212_LARGEALLOC
- KorgAudioBuffer playDataBufs[kNumBuffers];
- KorgAudioBuffer recordDataBufs[kNumBuffers];
+ struct KorgAudioBuffer playDataBufs[kNumBuffers];
+ struct KorgAudioBuffer recordDataBufs[kNumBuffers];
#endif
short volumeData[kAudioChannels];
u32 cardCommand;
u16 routeData [kAudioChannels];
u32 AdatTimeCode; // ADAT timecode value
-} KorgSharedBuffer;
+};
-typedef struct SensBits {
+struct SensBits {
union {
struct {
unsigned int leftChanVal:8;
@@ -315,12 +316,12 @@ typedef struct SensBits {
} v;
u16 rightSensBits;
} r;
-} SensBits;
+};
-struct _snd_korg1212 {
- snd_card_t *card;
+struct snd_korg1212 {
+ struct snd_card *card;
struct pci_dev *pci;
- snd_pcm_t *pcm;
+ struct snd_pcm *pcm;
int irq;
spinlock_t lock;
@@ -347,10 +348,10 @@ struct _snd_korg1212 {
u32 DataBufsSize;
- KorgAudioBuffer * playDataBufsPtr;
- KorgAudioBuffer * recordDataBufsPtr;
+ struct KorgAudioBuffer * playDataBufsPtr;
+ struct KorgAudioBuffer * recordDataBufsPtr;
- KorgSharedBuffer * sharedBufferPtr;
+ struct KorgSharedBuffer * sharedBufferPtr;
u32 RecDataPhy;
u32 PlayDataPhy;
@@ -374,20 +375,20 @@ struct _snd_korg1212 {
int channels;
int currentBuffer;
- snd_pcm_substream_t *playback_substream;
- snd_pcm_substream_t *capture_substream;
+ struct snd_pcm_substream *playback_substream;
+ struct snd_pcm_substream *capture_substream;
pid_t capture_pid;
pid_t playback_pid;
- CardState cardState;
+ enum CardState cardState;
int running;
int idleMonitorOn; // indicates whether the card is in idle monitor mode.
u32 cmdRetryCount; // tracks how many times we have retried sending to the card.
- ClockSourceIndex clkSrcRate; // sample rate and clock source
+ enum ClockSourceIndex clkSrcRate; // sample rate and clock source
- ClockSourceType clkSource; // clock source
+ enum ClockSourceType clkSource; // clock source
int clkRate; // clock rate
int volumePhase[kAudioChannels];
@@ -432,60 +433,58 @@ static struct pci_device_id snd_korg1212_ids[] = {
{ 0, },
};
-static char* stateName[] = {
- "Non-existent",
- "Uninitialized",
- "DSP download in process",
- "DSP download complete",
- "Ready",
- "Open",
- "Setup for play",
- "Playing",
- "Monitor mode on",
- "Calibrating",
- "Invalid"
+MODULE_DEVICE_TABLE(pci, snd_korg1212_ids);
+
+static char *stateName[] = {
+ "Non-existent",
+ "Uninitialized",
+ "DSP download in process",
+ "DSP download complete",
+ "Ready",
+ "Open",
+ "Setup for play",
+ "Playing",
+ "Monitor mode on",
+ "Calibrating",
+ "Invalid"
};
-static char* clockSourceTypeName[] = { "ADAT", "S/PDIF", "local" };
+static char *clockSourceTypeName[] = { "ADAT", "S/PDIF", "local" };
-static char* clockSourceName[] = {
- "ADAT at 44.1 kHz",
- "ADAT at 48 kHz",
- "S/PDIF at 44.1 kHz",
- "S/PDIF at 48 kHz",
- "local clock at 44.1 kHz",
- "local clock at 48 kHz"
+static char *clockSourceName[] = {
+ "ADAT at 44.1 kHz",
+ "ADAT at 48 kHz",
+ "S/PDIF at 44.1 kHz",
+ "S/PDIF at 48 kHz",
+ "local clock at 44.1 kHz",
+ "local clock at 48 kHz"
};
-static char* channelName[] = {
- "ADAT-1",
- "ADAT-2",
- "ADAT-3",
- "ADAT-4",
- "ADAT-5",
- "ADAT-6",
- "ADAT-7",
- "ADAT-8",
- "Analog-L",
- "Analog-R",
- "SPDIF-L",
- "SPDIF-R",
+static char *channelName[] = {
+ "ADAT-1",
+ "ADAT-2",
+ "ADAT-3",
+ "ADAT-4",
+ "ADAT-5",
+ "ADAT-6",
+ "ADAT-7",
+ "ADAT-8",
+ "Analog-L",
+ "Analog-R",
+ "SPDIF-L",
+ "SPDIF-R",
};
-static u16 ClockSourceSelector[] =
- {0x8000, // selects source as ADAT at 44.1 kHz
- 0x0000, // selects source as ADAT at 48 kHz
- 0x8001, // selects source as S/PDIF at 44.1 kHz
- 0x0001, // selects source as S/PDIF at 48 kHz
- 0x8002, // selects source as local clock at 44.1 kHz
- 0x0002 // selects source as local clock at 48 kHz
- };
-
-static snd_korg1212rc rc;
-
-MODULE_DEVICE_TABLE(pci, snd_korg1212_ids);
+static u16 ClockSourceSelector[] = {
+ 0x8000, // selects source as ADAT at 44.1 kHz
+ 0x0000, // selects source as ADAT at 48 kHz
+ 0x8001, // selects source as S/PDIF at 44.1 kHz
+ 0x0001, // selects source as S/PDIF at 48 kHz
+ 0x8002, // selects source as local clock at 44.1 kHz
+ 0x0002 // selects source as local clock at 48 kHz
+};
-typedef union swap_u32 { unsigned char c[4]; u32 i; } swap_u32;
+union swap_u32 { unsigned char c[4]; u32 i; };
#ifdef SNDRV_BIG_ENDIAN
static u32 LowerWordSwap(u32 swappee)
@@ -493,7 +492,7 @@ static u32 LowerWordSwap(u32 swappee)
static u32 UpperWordSwap(u32 swappee)
#endif
{
- swap_u32 retVal, swapper;
+ union swap_u32 retVal, swapper;
swapper.i = swappee;
retVal.c[2] = swapper.c[3];
@@ -510,7 +509,7 @@ static u32 UpperWordSwap(u32 swappee)
static u32 LowerWordSwap(u32 swappee)
#endif
{
- swap_u32 retVal, swapper;
+ union swap_u32 retVal, swapper;
swapper.i = swappee;
retVal.c[2] = swapper.c[2];
@@ -521,45 +520,27 @@ static u32 LowerWordSwap(u32 swappee)
return retVal.i;
}
-#if 0 /* not used */
-
-static u32 EndianSwap(u32 swappee)
-{
- swap_u32 retVal, swapper;
-
- swapper.i = swappee;
- retVal.c[0] = swapper.c[3];
- retVal.c[1] = swapper.c[2];
- retVal.c[2] = swapper.c[1];
- retVal.c[3] = swapper.c[0];
-
- return retVal.i;
-}
-
-#endif /* not used */
-
#define SetBitInWord(theWord,bitPosition) (*theWord) |= (0x0001 << bitPosition)
#define SetBitInDWord(theWord,bitPosition) (*theWord) |= (0x00000001 << bitPosition)
#define ClearBitInWord(theWord,bitPosition) (*theWord) &= ~(0x0001 << bitPosition)
#define ClearBitInDWord(theWord,bitPosition) (*theWord) &= ~(0x00000001 << bitPosition)
-static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg1212_dbcnst_t doorbellVal,
- u32 mailBox0Val, u32 mailBox1Val, u32 mailBox2Val, u32 mailBox3Val)
+static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212,
+ enum korg1212_dbcnst doorbellVal,
+ u32 mailBox0Val, u32 mailBox1Val,
+ u32 mailBox2Val, u32 mailBox3Val)
{
u32 retryCount;
u16 mailBox3Lo;
- snd_korg1212rc rc = K1212_CMDRET_Success;
+ int rc = K1212_CMDRET_Success;
if (!korg1212->outDoorbellPtr) {
-#if K1212_DEBUG_LEVEL > 1
- K1212_DEBUG_PRINTK("K1212_DEBUG: CardUninitialized\n");
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: CardUninitialized\n");
return K1212_CMDRET_CardUninitialized;
}
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- 0x%08x 0x%08x [%s]\n", doorbellVal, mailBox0Val, stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- 0x%08x 0x%08x [%s]\n",
+ doorbellVal, mailBox0Val, stateName[korg1212->cardState]);
for (retryCount = 0; retryCount < MAX_COMMAND_RETRIES; retryCount++) {
writel(mailBox3Val, korg1212->mailbox3Ptr);
writel(mailBox2Val, korg1212->mailbox2Ptr);
@@ -586,9 +567,7 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121
mailBox3Lo = readl(korg1212->mailbox3Ptr);
if (mailBox3Lo & COMMAND_ACK_MASK) {
if ((mailBox3Lo & DOORBELL_VAL_MASK) == (doorbellVal & DOORBELL_VAL_MASK)) {
-#if K1212_DEBUG_LEVEL > 1
- K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- Success\n");
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- Success\n");
rc = K1212_CMDRET_Success;
break;
}
@@ -597,9 +576,7 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121
korg1212->cmdRetryCount += retryCount;
if (retryCount >= MAX_COMMAND_RETRIES) {
-#if K1212_DEBUG_LEVEL > 1
- K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- NoAckFromCard\n");
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- NoAckFromCard\n");
rc = K1212_CMDRET_NoAckFromCard;
}
@@ -607,7 +584,7 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121
}
/* spinlock already held */
-static void snd_korg1212_SendStop(korg1212_t *korg1212)
+static void snd_korg1212_SendStop(struct snd_korg1212 *korg1212)
{
if (! korg1212->stop_pending_cnt) {
korg1212->sharedBufferPtr->cardCommand = 0xffffffff;
@@ -618,7 +595,7 @@ static void snd_korg1212_SendStop(korg1212_t *korg1212)
}
}
-static void snd_korg1212_SendStopAndWait(korg1212_t *korg1212)
+static void snd_korg1212_SendStopAndWait(struct snd_korg1212 *korg1212)
{
unsigned long flags;
spin_lock_irqsave(&korg1212->lock, flags);
@@ -631,17 +608,17 @@ static void snd_korg1212_SendStopAndWait(korg1212_t *korg1212)
/* timer callback for checking the ack of stop request */
static void snd_korg1212_timer_func(unsigned long data)
{
- korg1212_t *korg1212 = (korg1212_t *) data;
+ struct snd_korg1212 *korg1212 = (struct snd_korg1212 *) data;
+ unsigned long flags;
- spin_lock(&korg1212->lock);
+ spin_lock_irqsave(&korg1212->lock, flags);
if (korg1212->sharedBufferPtr->cardCommand == 0) {
/* ack'ed */
korg1212->stop_pending_cnt = 0;
korg1212->dsp_stop_is_processed = 1;
wake_up(&korg1212->wait);
-#if K1212_DEBUG_LEVEL > 1
- K1212_DEBUG_PRINTK("K1212_DEBUG: Stop ack'ed [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Stop ack'ed [%s]\n",
+ stateName[korg1212->cardState]);
} else {
if (--korg1212->stop_pending_cnt > 0) {
/* reprogram timer */
@@ -652,17 +629,17 @@ static void snd_korg1212_timer_func(unsigned long data)
korg1212->sharedBufferPtr->cardCommand = 0;
korg1212->dsp_stop_is_processed = 1;
wake_up(&korg1212->wait);
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n",
+ stateName[korg1212->cardState]);
}
}
- spin_unlock(&korg1212->lock);
+ spin_unlock_irqrestore(&korg1212->lock, flags);
}
-static void snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212)
+static int snd_korg1212_TurnOnIdleMonitor(struct snd_korg1212 *korg1212)
{
unsigned long flags;
+ int rc;
udelay(INTERCOMMAND_DELAY);
spin_lock_irqsave(&korg1212->lock, flags);
@@ -670,9 +647,10 @@ static void snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212)
rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
K1212_MODE_MonitorOn, 0, 0, 0);
spin_unlock_irqrestore(&korg1212->lock, flags);
+ return rc;
}
-static void snd_korg1212_TurnOffIdleMonitor(korg1212_t *korg1212)
+static void snd_korg1212_TurnOffIdleMonitor(struct snd_korg1212 *korg1212)
{
if (korg1212->idleMonitorOn) {
snd_korg1212_SendStopAndWait(korg1212);
@@ -680,16 +658,15 @@ static void snd_korg1212_TurnOffIdleMonitor(korg1212_t *korg1212)
}
}
-static inline void snd_korg1212_setCardState(korg1212_t * korg1212, CardState csState)
+static inline void snd_korg1212_setCardState(struct snd_korg1212 * korg1212, enum CardState csState)
{
korg1212->cardState = csState;
}
-static int snd_korg1212_OpenCard(korg1212_t * korg1212)
+static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212)
{
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", stateName[korg1212->cardState], korg1212->opencnt);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n",
+ stateName[korg1212->cardState], korg1212->opencnt);
down(&korg1212->open_mutex);
if (korg1212->opencnt++ == 0) {
snd_korg1212_TurnOffIdleMonitor(korg1212);
@@ -700,11 +677,10 @@ static int snd_korg1212_OpenCard(korg1212_t * korg1212)
return 1;
}
-static int snd_korg1212_CloseCard(korg1212_t * korg1212)
+static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
{
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", stateName[korg1212->cardState], korg1212->opencnt);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n",
+ stateName[korg1212->cardState], korg1212->opencnt);
down(&korg1212->open_mutex);
if (--(korg1212->opencnt)) {
@@ -713,12 +689,11 @@ static int snd_korg1212_CloseCard(korg1212_t * korg1212)
}
if (korg1212->cardState == K1212_STATE_SETUP) {
- rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
+ int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
K1212_MODE_StopPlay, 0, 0, 0);
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
-
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
if (rc != K1212_CMDRET_Success) {
up(&korg1212->open_mutex);
return 0;
@@ -737,11 +712,12 @@ static int snd_korg1212_CloseCard(korg1212_t * korg1212)
}
/* spinlock already held */
-static int snd_korg1212_SetupForPlay(korg1212_t * korg1212)
+static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212)
{
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->setcnt);
-#endif
+ int rc;
+
+ K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay [%s] %d\n",
+ stateName[korg1212->cardState], korg1212->setcnt);
if (korg1212->setcnt++)
return 0;
@@ -749,10 +725,9 @@ static int snd_korg1212_SetupForPlay(korg1212_t * korg1212)
snd_korg1212_setCardState(korg1212, K1212_STATE_SETUP);
rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
K1212_MODE_SetupPlay, 0, 0, 0);
-
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
if (rc != K1212_CMDRET_Success) {
return 1;
}
@@ -760,22 +735,21 @@ static int snd_korg1212_SetupForPlay(korg1212_t * korg1212)
}
/* spinlock already held */
-static int snd_korg1212_TriggerPlay(korg1212_t * korg1212)
+static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212)
{
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->playcnt);
-#endif
+ int rc;
+
+ K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay [%s] %d\n",
+ stateName[korg1212->cardState], korg1212->playcnt);
if (korg1212->playcnt++)
return 0;
snd_korg1212_setCardState(korg1212, K1212_STATE_PLAYING);
rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_TriggerPlay, 0, 0, 0, 0);
-
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
-
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
if (rc != K1212_CMDRET_Success) {
return 1;
}
@@ -783,11 +757,10 @@ static int snd_korg1212_TriggerPlay(korg1212_t * korg1212)
}
/* spinlock already held */
-static int snd_korg1212_StopPlay(korg1212_t * korg1212)
+static int snd_korg1212_StopPlay(struct snd_korg1212 * korg1212)
{
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->playcnt);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n",
+ stateName[korg1212->cardState], korg1212->playcnt);
if (--(korg1212->playcnt))
return 0;
@@ -801,7 +774,7 @@ static int snd_korg1212_StopPlay(korg1212_t * korg1212)
return 0;
}
-static void snd_korg1212_EnableCardInterrupts(korg1212_t * korg1212)
+static void snd_korg1212_EnableCardInterrupts(struct snd_korg1212 * korg1212)
{
writel(PCI_INT_ENABLE_BIT |
PCI_DOORBELL_INT_ENABLE_BIT |
@@ -813,37 +786,37 @@ static void snd_korg1212_EnableCardInterrupts(korg1212_t * korg1212)
#if 0 /* not used */
-static int snd_korg1212_SetMonitorMode(korg1212_t *korg1212, MonitorModeSelector mode)
+static int snd_korg1212_SetMonitorMode(struct snd_korg1212 *korg1212,
+ enum MonitorModeSelector mode)
{
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: SetMonitorMode [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: SetMonitorMode [%s]\n",
+ stateName[korg1212->cardState]);
switch (mode) {
- case K1212_MONMODE_Off:
- if (korg1212->cardState != K1212_STATE_MONITOR) {
- return 0;
- } else {
- snd_korg1212_SendStopAndWait(korg1212);
- snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN);
- }
- break;
-
- case K1212_MONMODE_On:
- if (korg1212->cardState != K1212_STATE_OPEN) {
- return 0;
- } else {
- snd_korg1212_setCardState(korg1212, K1212_STATE_MONITOR);
- rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
- K1212_MODE_MonitorOn, 0, 0, 0);
- if (rc != K1212_CMDRET_Success) {
- return 0;
- }
- }
- break;
+ case K1212_MONMODE_Off:
+ if (korg1212->cardState != K1212_STATE_MONITOR)
+ return 0;
+ else {
+ snd_korg1212_SendStopAndWait(korg1212);
+ snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN);
+ }
+ break;
+
+ case K1212_MONMODE_On:
+ if (korg1212->cardState != K1212_STATE_OPEN)
+ return 0;
+ else {
+ int rc;
+ snd_korg1212_setCardState(korg1212, K1212_STATE_MONITOR);
+ rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
+ K1212_MODE_MonitorOn, 0, 0, 0);
+ if (rc != K1212_CMDRET_Success)
+ return 0;
+ }
+ break;
- default:
- return 0;
+ default:
+ return 0;
}
return 1;
@@ -851,44 +824,44 @@ static int snd_korg1212_SetMonitorMode(korg1212_t *korg1212, MonitorModeSelector
#endif /* not used */
-static inline int snd_korg1212_use_is_exclusive(korg1212_t *korg1212)
+static inline int snd_korg1212_use_is_exclusive(struct snd_korg1212 *korg1212)
{
- int ret = 1;
+ if (korg1212->playback_pid != korg1212->capture_pid &&
+ korg1212->playback_pid >= 0 && korg1212->capture_pid >= 0)
+ return 0;
- if ((korg1212->playback_pid != korg1212->capture_pid) &&
- (korg1212->playback_pid >= 0) && (korg1212->capture_pid >= 0)) {
- ret = 0;
- }
- return ret;
+ return 1;
}
-static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate)
+static int snd_korg1212_SetRate(struct snd_korg1212 *korg1212, int rate)
{
- static ClockSourceIndex s44[] = { K1212_CLKIDX_AdatAt44_1K,
- K1212_CLKIDX_WordAt44_1K,
- K1212_CLKIDX_LocalAt44_1K };
- static ClockSourceIndex s48[] = {
- K1212_CLKIDX_AdatAt48K,
- K1212_CLKIDX_WordAt48K,
- K1212_CLKIDX_LocalAt48K };
- int parm;
+ static enum ClockSourceIndex s44[] = {
+ K1212_CLKIDX_AdatAt44_1K,
+ K1212_CLKIDX_WordAt44_1K,
+ K1212_CLKIDX_LocalAt44_1K
+ };
+ static enum ClockSourceIndex s48[] = {
+ K1212_CLKIDX_AdatAt48K,
+ K1212_CLKIDX_WordAt48K,
+ K1212_CLKIDX_LocalAt48K
+ };
+ int parm, rc;
- if (!snd_korg1212_use_is_exclusive (korg1212)) {
- return -EBUSY;
- }
+ if (!snd_korg1212_use_is_exclusive (korg1212))
+ return -EBUSY;
- switch(rate) {
- case 44100:
- parm = s44[korg1212->clkSource];
- break;
+ switch (rate) {
+ case 44100:
+ parm = s44[korg1212->clkSource];
+ break;
- case 48000:
- parm = s48[korg1212->clkSource];
- break;
+ case 48000:
+ parm = s48[korg1212->clkSource];
+ break;
- default:
- return -EINVAL;
- }
+ default:
+ return -EINVAL;
+ }
korg1212->clkSrcRate = parm;
korg1212->clkRate = rate;
@@ -897,19 +870,18 @@ static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate)
rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate,
ClockSourceSelector[korg1212->clkSrcRate],
0, 0, 0);
-
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
return 0;
}
-static int snd_korg1212_SetClockSource(korg1212_t *korg1212, int source)
+static int snd_korg1212_SetClockSource(struct snd_korg1212 *korg1212, int source)
{
- if (source<0 || source >2)
- return -EINVAL;
+ if (source < 0 || source > 2)
+ return -EINVAL;
korg1212->clkSource = source;
@@ -918,14 +890,14 @@ static int snd_korg1212_SetClockSource(korg1212_t *korg1212, int source)
return 0;
}
-static void snd_korg1212_DisableCardInterrupts(korg1212_t *korg1212)
+static void snd_korg1212_DisableCardInterrupts(struct snd_korg1212 *korg1212)
{
writel(0, korg1212->statusRegPtr);
}
-static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212)
+static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212)
{
- SensBits sensVals;
+ struct SensBits sensVals;
int bitPosition;
int channel;
int clkIs48K;
@@ -935,9 +907,8 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212)
u16 count;
unsigned long flags;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity [%s]\n",
+ stateName[korg1212->cardState]);
// ----------------------------------------------------------------------------
// initialize things. The local init bit is always set when writing to the
@@ -1006,19 +977,17 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212)
udelay(LOADSHIFT_DELAY);
for (bitPosition = 15; bitPosition >= 0; bitPosition--) { // for all the bits
- if (channel == 0) {
- if (sensVals.l.leftSensBits & (0x0001 << bitPosition)) {
+ if (channel == 0) {
+ if (sensVals.l.leftSensBits & (0x0001 << bitPosition))
SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high
- } else {
- ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low
- }
- } else {
- if (sensVals.r.rightSensBits & (0x0001 << bitPosition)) {
- SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high
- } else {
- ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low
- }
- }
+ else
+ ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low
+ } else {
+ if (sensVals.r.rightSensBits & (0x0001 << bitPosition))
+ SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high
+ else
+ ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low
+ }
ClearBitInWord(&controlValue, SET_SENS_CLOCK_BITPOS);
writew(controlValue, korg1212->sensRegPtr); // clock goes low
@@ -1059,12 +1028,11 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212)
udelay(SENSCLKPULSE_WIDTH);
if (monModeSet) {
- rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
+ int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
K1212_MODE_MonitorOn, 0, 0, 0);
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
-
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
}
spin_unlock_irqrestore(&korg1212->lock, flags);
@@ -1072,23 +1040,22 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212)
return 1;
}
-static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212)
+static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212)
{
- int channel;
+ int channel, rc;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n",
+ stateName[korg1212->cardState]);
// ----------------------------------------------------
// tell the card to boot
// ----------------------------------------------------
rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_BootFromDSPPage4, 0, 0, 0, 0);
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Boot from Page 4 - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
- mdelay(DSP_BOOT_DELAY_IN_MS);
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Boot from Page 4 - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
+ msleep(DSP_BOOT_DELAY_IN_MS);
// --------------------------------------------------------------------------------
// Let the card know where all the buffers are.
@@ -1102,9 +1069,9 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212)
0
);
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Buffer Memory - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Buffer Memory - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
udelay(INTERCOMMAND_DELAY);
@@ -1116,10 +1083,9 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212)
0
);
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Misc Memory - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
-
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Misc Memory - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
// --------------------------------------------------------------------------------
// Initialize the routing and volume tables, then update the card's state.
@@ -1138,16 +1104,16 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212)
rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate,
ClockSourceSelector[korg1212->clkSrcRate],
0, 0, 0);
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
- snd_korg1212_TurnOnIdleMonitor(korg1212);
+ rc = snd_korg1212_TurnOnIdleMonitor(korg1212);
snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Monitor On - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Set Monitor On - RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE);
}
@@ -1155,7 +1121,7 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212)
static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
u32 doorbellValue;
- korg1212_t *korg1212 = dev_id;
+ struct snd_korg1212 *korg1212 = dev_id;
if(irq != korg1212->irq)
return IRQ_NONE;
@@ -1176,9 +1142,9 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs
switch (doorbellValue) {
case K1212_DB_DSPDownloadDone:
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n",
+ korg1212->irqcount, doorbellValue,
+ stateName[korg1212->cardState]);
if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) {
korg1212->dsp_is_loaded = 1;
wake_up(&korg1212->wait);
@@ -1189,10 +1155,10 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs
// an error occurred - stop the card
// ------------------------------------------------------------------------
case K1212_DB_DMAERROR:
-#if K1212_DEBUG_LEVEL > 1
- K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DMAE count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]);
-#endif
- snd_printk(KERN_ERR "korg1212: DMA Error\n");
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DMAE count - %ld, %x, [%s].\n",
+ korg1212->irqcount, doorbellValue,
+ stateName[korg1212->cardState]);
+ snd_printk(KERN_ERR "korg1212: DMA Error\n");
korg1212->errorcnt++;
korg1212->totalerrorcnt++;
korg1212->sharedBufferPtr->cardCommand = 0;
@@ -1204,17 +1170,16 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs
// the semaphore in case someone is waiting for this.
// ------------------------------------------------------------------------
case K1212_DB_CARDSTOPPED:
-#if K1212_DEBUG_LEVEL > 1
- K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n",
+ korg1212->irqcount, doorbellValue,
+ stateName[korg1212->cardState]);
korg1212->sharedBufferPtr->cardCommand = 0;
break;
default:
-#if K1212_DEBUG_LEVEL > 3
- K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n", korg1212->irqcount, doorbellValue,
- korg1212->currentBuffer, stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n",
+ korg1212->irqcount, doorbellValue,
+ korg1212->currentBuffer, stateName[korg1212->cardState]);
if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) {
korg1212->currentBuffer++;
@@ -1246,19 +1211,18 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs
return IRQ_HANDLED;
}
-static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212)
+static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212)
{
+ int rc;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n",
+ stateName[korg1212->cardState]);
// ---------------------------------------------------------------
// verify the state of the card before proceeding.
// ---------------------------------------------------------------
- if (korg1212->cardState >= K1212_STATE_DSP_IN_PROCESS) {
+ if (korg1212->cardState >= K1212_STATE_DSP_IN_PROCESS)
return 1;
- }
snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS);
@@ -1267,10 +1231,9 @@ static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212)
rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload,
UpperWordSwap(korg1212->dma_dsp.addr),
0, 0, 0);
-
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n",
+ rc, stateName[korg1212->cardState]);
korg1212->dsp_is_loaded = 0;
wait_event_timeout(korg1212->wait, korg1212->dsp_is_loaded, HZ * CARD_BOOT_TIMEOUT);
@@ -1282,7 +1245,7 @@ static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212)
return 0;
}
-static snd_pcm_hardware_t snd_korg1212_playback_info =
+static struct snd_pcm_hardware snd_korg1212_playback_info =
{
.info = (SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
@@ -1302,7 +1265,7 @@ static snd_pcm_hardware_t snd_korg1212_playback_info =
.fifo_size = 0,
};
-static snd_pcm_hardware_t snd_korg1212_capture_info =
+static struct snd_pcm_hardware snd_korg1212_capture_info =
{
.info = (SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
@@ -1322,21 +1285,21 @@ static snd_pcm_hardware_t snd_korg1212_capture_info =
.fifo_size = 0,
};
-static int snd_korg1212_silence(korg1212_t *korg1212, int pos, int count, int offset, int size)
+static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int count, int offset, int size)
{
- KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos;
+ struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos;
int i;
-#if K1212_DEBUG_LEVEL > 2
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", pos, offset, size, count);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n",
+ pos, offset, size, count);
snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL);
for (i=0; i < count; i++) {
#if K1212_DEBUG_LEVEL > 0
if ( (void *) dst < (void *) korg1212->playDataBufsPtr ||
(void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) {
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", dst, i);
+ printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n",
+ dst, i);
return -EFAULT;
}
#endif
@@ -1347,29 +1310,26 @@ static int snd_korg1212_silence(korg1212_t *korg1212, int pos, int count, int of
return 0;
}
-static int snd_korg1212_copy_to(korg1212_t *korg1212, void __user *dst, int pos, int count, int offset, int size)
+static int snd_korg1212_copy_to(struct snd_korg1212 *korg1212, void __user *dst, int pos, int count, int offset, int size)
{
- KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos;
+ struct KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos;
int i, rc;
-#if K1212_DEBUG_LEVEL > 2
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", pos, offset, size);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n",
+ pos, offset, size);
snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL);
for (i=0; i < count; i++) {
#if K1212_DEBUG_LEVEL > 0
if ( (void *) src < (void *) korg1212->recordDataBufsPtr ||
(void *) src > (void *) korg1212->recordDataBufsPtr[8].bufferData ) {
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i);
+ printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i);
return -EFAULT;
}
#endif
rc = copy_to_user(dst + offset, src, size);
if (rc) {
-#if K1212_DEBUG_LEVEL > 0
K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i);
-#endif
return -EFAULT;
}
src++;
@@ -1379,14 +1339,13 @@ static int snd_korg1212_copy_to(korg1212_t *korg1212, void __user *dst, int pos,
return 0;
}
-static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int pos, int count, int offset, int size)
+static int snd_korg1212_copy_from(struct snd_korg1212 *korg1212, void __user *src, int pos, int count, int offset, int size)
{
- KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos;
+ struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos;
int i, rc;
-#if K1212_DEBUG_LEVEL > 2
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", pos, offset, size, count);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n",
+ pos, offset, size, count);
snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL);
@@ -1394,15 +1353,13 @@ static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int po
#if K1212_DEBUG_LEVEL > 0
if ( (void *) dst < (void *) korg1212->playDataBufsPtr ||
(void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) {
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i);
+ printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i);
return -EFAULT;
}
#endif
rc = copy_from_user((void*) dst + offset, src, size);
if (rc) {
-#if K1212_DEBUG_LEVEL > 0
K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i);
-#endif
return -EFAULT;
}
dst++;
@@ -1412,26 +1369,24 @@ static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int po
return 0;
}
-static void snd_korg1212_free_pcm(snd_pcm_t *pcm)
+static void snd_korg1212_free_pcm(struct snd_pcm *pcm)
{
- korg1212_t *korg1212 = (korg1212_t *) pcm->private_data;
+ struct snd_korg1212 *korg1212 = pcm->private_data;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n",
+ stateName[korg1212->cardState]);
korg1212->pcm = NULL;
}
-static int snd_korg1212_playback_open(snd_pcm_substream_t *substream)
+static int snd_korg1212_playback_open(struct snd_pcm_substream *substream)
{
unsigned long flags;
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
- snd_pcm_runtime_t *runtime = substream->runtime;
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_pcm_runtime *runtime = substream->runtime;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n",
+ stateName[korg1212->cardState]);
snd_pcm_set_sync(substream); // ???
@@ -1455,15 +1410,14 @@ static int snd_korg1212_playback_open(snd_pcm_substream_t *substream)
}
-static int snd_korg1212_capture_open(snd_pcm_substream_t *substream)
+static int snd_korg1212_capture_open(struct snd_pcm_substream *substream)
{
unsigned long flags;
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
- snd_pcm_runtime_t *runtime = substream->runtime;
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_pcm_runtime *runtime = substream->runtime;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n",
+ stateName[korg1212->cardState]);
snd_pcm_set_sync(substream);
@@ -1481,18 +1435,18 @@ static int snd_korg1212_capture_open(snd_pcm_substream_t *substream)
spin_unlock_irqrestore(&korg1212->lock, flags);
- snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, kPlayBufferFrames, kPlayBufferFrames);
+ snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
+ kPlayBufferFrames, kPlayBufferFrames);
return 0;
}
-static int snd_korg1212_playback_close(snd_pcm_substream_t *substream)
+static int snd_korg1212_playback_close(struct snd_pcm_substream *substream)
{
unsigned long flags;
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n",
+ stateName[korg1212->cardState]);
snd_korg1212_silence(korg1212, 0, K1212_MAX_SAMPLES, 0, korg1212->channels * 2);
@@ -1508,14 +1462,13 @@ static int snd_korg1212_playback_close(snd_pcm_substream_t *substream)
return 0;
}
-static int snd_korg1212_capture_close(snd_pcm_substream_t *substream)
+static int snd_korg1212_capture_close(struct snd_pcm_substream *substream)
{
unsigned long flags;
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n",
+ stateName[korg1212->cardState]);
spin_lock_irqsave(&korg1212->lock, flags);
@@ -1529,39 +1482,34 @@ static int snd_korg1212_capture_close(snd_pcm_substream_t *substream)
return 0;
}
-static int snd_korg1212_ioctl(snd_pcm_substream_t *substream,
+static int snd_korg1212_ioctl(struct snd_pcm_substream *substream,
unsigned int cmd, void *arg)
{
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd);
if (cmd == SNDRV_PCM_IOCTL1_CHANNEL_INFO ) {
- snd_pcm_channel_info_t *info = arg;
+ struct snd_pcm_channel_info *info = arg;
info->offset = 0;
info->first = info->channel * 16;
info->step = 256;
-#if K1212_DEBUG_LEVEL > 0
K1212_DEBUG_PRINTK("K1212_DEBUG: channel_info %d:, offset=%ld, first=%d, step=%d\n", info->channel, info->offset, info->first, info->step);
-#endif
return 0;
}
return snd_pcm_lib_ioctl(substream, cmd, arg);
}
-static int snd_korg1212_hw_params(snd_pcm_substream_t *substream,
- snd_pcm_hw_params_t *params)
+static int snd_korg1212_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
{
unsigned long flags;
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
int err;
pid_t this_pid;
pid_t other_pid;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n",
+ stateName[korg1212->cardState]);
spin_lock_irqsave(&korg1212->lock, flags);
@@ -1603,22 +1551,20 @@ static int snd_korg1212_hw_params(snd_pcm_substream_t *substream,
return 0;
}
-static int snd_korg1212_prepare(snd_pcm_substream_t *substream)
+static int snd_korg1212_prepare(struct snd_pcm_substream *substream)
{
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
int rc;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n",
+ stateName[korg1212->cardState]);
spin_lock_irq(&korg1212->lock);
/* FIXME: we should wait for ack! */
if (korg1212->stop_pending_cnt > 0) {
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n",
+ stateName[korg1212->cardState]);
spin_unlock_irq(&korg1212->lock);
return -EAGAIN;
/*
@@ -1637,24 +1583,21 @@ static int snd_korg1212_prepare(snd_pcm_substream_t *substream)
return rc ? -EINVAL : 0;
}
-static int snd_korg1212_trigger(snd_pcm_substream_t *substream,
+static int snd_korg1212_trigger(struct snd_pcm_substream *substream,
int cmd)
{
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
int rc;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n", stateName[korg1212->cardState], cmd);
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n",
+ stateName[korg1212->cardState], cmd);
spin_lock(&korg1212->lock);
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
/*
if (korg1212->running) {
-#if K1212_DEBUG_LEVEL > 1
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger: Already running?\n");
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already running?\n");
break;
}
*/
@@ -1665,9 +1608,7 @@ static int snd_korg1212_trigger(snd_pcm_substream_t *substream,
case SNDRV_PCM_TRIGGER_STOP:
/*
if (!korg1212->running) {
-#if K1212_DEBUG_LEVEL > 1
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger: Already stopped?\n");
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already stopped?\n");
break;
}
*/
@@ -1683,82 +1624,75 @@ static int snd_korg1212_trigger(snd_pcm_substream_t *substream,
return rc ? -EINVAL : 0;
}
-static snd_pcm_uframes_t snd_korg1212_playback_pointer(snd_pcm_substream_t *substream)
+static snd_pcm_uframes_t snd_korg1212_playback_pointer(struct snd_pcm_substream *substream)
{
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
snd_pcm_uframes_t pos;
pos = korg1212->currentBuffer * kPlayBufferFrames;
-#if K1212_DEBUG_LEVEL > 2
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_pointer [%s] %ld\n",
- stateName[korg1212->cardState], pos);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_pointer [%s] %ld\n",
+ stateName[korg1212->cardState], pos);
return pos;
}
-static snd_pcm_uframes_t snd_korg1212_capture_pointer(snd_pcm_substream_t *substream)
+static snd_pcm_uframes_t snd_korg1212_capture_pointer(struct snd_pcm_substream *substream)
{
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
snd_pcm_uframes_t pos;
pos = korg1212->currentBuffer * kPlayBufferFrames;
-#if K1212_DEBUG_LEVEL > 2
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_pointer [%s] %ld\n",
- stateName[korg1212->cardState], pos);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_pointer [%s] %ld\n",
+ stateName[korg1212->cardState], pos);
return pos;
}
-static int snd_korg1212_playback_copy(snd_pcm_substream_t *substream,
+static int snd_korg1212_playback_copy(struct snd_pcm_substream *substream,
int channel, /* not used (interleaved data) */
snd_pcm_uframes_t pos,
void __user *src,
snd_pcm_uframes_t count)
{
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
-#if K1212_DEBUG_LEVEL > 2
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n",
+ stateName[korg1212->cardState], pos, count);
return snd_korg1212_copy_from(korg1212, src, pos, count, 0, korg1212->channels * 2);
}
-static int snd_korg1212_playback_silence(snd_pcm_substream_t *substream,
+static int snd_korg1212_playback_silence(struct snd_pcm_substream *substream,
int channel, /* not used (interleaved data) */
snd_pcm_uframes_t pos,
snd_pcm_uframes_t count)
{
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n", stateName[korg1212->cardState]);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n",
+ stateName[korg1212->cardState]);
return snd_korg1212_silence(korg1212, pos, count, 0, korg1212->channels * 2);
}
-static int snd_korg1212_capture_copy(snd_pcm_substream_t *substream,
+static int snd_korg1212_capture_copy(struct snd_pcm_substream *substream,
int channel, /* not used (interleaved data) */
snd_pcm_uframes_t pos,
void __user *dst,
snd_pcm_uframes_t count)
{
- korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
+ struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
-#if K1212_DEBUG_LEVEL > 2
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count);
-#endif
+ K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n",
+ stateName[korg1212->cardState], pos, count);
return snd_korg1212_copy_to(korg1212, dst, pos, count, 0, korg1212->channels * 2);
}
-static snd_pcm_ops_t snd_korg1212_playback_ops = {
+static struct snd_pcm_ops snd_korg1212_playback_ops = {
.open = snd_korg1212_playback_open,
.close = snd_korg1212_playback_close,
.ioctl = snd_korg1212_ioctl,
@@ -1770,7 +1704,7 @@ static snd_pcm_ops_t snd_korg1212_playback_ops = {
.silence = snd_korg1212_playback_silence,
};
-static snd_pcm_ops_t snd_korg1212_capture_ops = {
+static struct snd_pcm_ops snd_korg1212_capture_ops = {
.open = snd_korg1212_capture_open,
.close = snd_korg1212_capture_close,
.ioctl = snd_korg1212_ioctl,
@@ -1785,16 +1719,18 @@ static snd_pcm_ops_t snd_korg1212_capture_ops = {
* Control Interface
*/
-static int snd_korg1212_control_phase_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_korg1212_control_phase_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = (kcontrol->private_value >= 8) ? 2 : 1;
return 0;
}
-static int snd_korg1212_control_phase_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+static int snd_korg1212_control_phase_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *u)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
int i = kcontrol->private_value;
spin_lock_irq(&korg1212->lock);
@@ -1809,9 +1745,10 @@ static int snd_korg1212_control_phase_get(snd_kcontrol_t *kcontrol, snd_ctl_elem
return 0;
}
-static int snd_korg1212_control_phase_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+static int snd_korg1212_control_phase_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *u)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
int change = 0;
int i, val;
@@ -1846,7 +1783,8 @@ static int snd_korg1212_control_phase_put(snd_kcontrol_t *kcontrol, snd_ctl_elem
return change;
}
-static int snd_korg1212_control_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_korg1212_control_volume_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = (kcontrol->private_value >= 8) ? 2 : 1;
@@ -1855,9 +1793,10 @@ static int snd_korg1212_control_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_el
return 0;
}
-static int snd_korg1212_control_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+static int snd_korg1212_control_volume_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *u)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
int i;
spin_lock_irq(&korg1212->lock);
@@ -1873,9 +1812,10 @@ static int snd_korg1212_control_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_ele
return 0;
}
-static int snd_korg1212_control_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+static int snd_korg1212_control_volume_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *u)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
int change = 0;
int i;
int val;
@@ -1905,7 +1845,8 @@ static int snd_korg1212_control_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_ele
return change;
}
-static int snd_korg1212_control_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_korg1212_control_route_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = (kcontrol->private_value >= 8) ? 2 : 1;
@@ -1917,9 +1858,10 @@ static int snd_korg1212_control_route_info(snd_kcontrol_t *kcontrol, snd_ctl_ele
return 0;
}
-static int snd_korg1212_control_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+static int snd_korg1212_control_route_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *u)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
int i;
spin_lock_irq(&korg1212->lock);
@@ -1935,9 +1877,10 @@ static int snd_korg1212_control_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem
return 0;
}
-static int snd_korg1212_control_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+static int snd_korg1212_control_route_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *u)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
int change = 0, i;
spin_lock_irq(&korg1212->lock);
@@ -1961,7 +1904,8 @@ static int snd_korg1212_control_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem
return change;
}
-static int snd_korg1212_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_korg1212_control_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 2;
@@ -1970,9 +1914,10 @@ static int snd_korg1212_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info
return 0;
}
-static int snd_korg1212_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+static int snd_korg1212_control_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *u)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
spin_lock_irq(&korg1212->lock);
@@ -1984,9 +1929,10 @@ static int snd_korg1212_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value
return 0;
}
-static int snd_korg1212_control_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
+static int snd_korg1212_control_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *u)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
int change = 0;
spin_lock_irq(&korg1212->lock);
@@ -2008,7 +1954,8 @@ static int snd_korg1212_control_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value
return change;
}
-static int snd_korg1212_control_sync_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
+static int snd_korg1212_control_sync_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
@@ -2020,9 +1967,10 @@ static int snd_korg1212_control_sync_info(snd_kcontrol_t *kcontrol, snd_ctl_elem
return 0;
}
-static int snd_korg1212_control_sync_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_korg1212_control_sync_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
spin_lock_irq(&korg1212->lock);
@@ -2032,9 +1980,10 @@ static int snd_korg1212_control_sync_get(snd_kcontrol_t * kcontrol, snd_ctl_elem
return 0;
}
-static int snd_korg1212_control_sync_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
+static int snd_korg1212_control_sync_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
- korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
+ struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
unsigned int val;
int change;
@@ -2075,7 +2024,7 @@ static int snd_korg1212_control_sync_put(snd_kcontrol_t * kcontrol, snd_ctl_elem
.private_value = ord, \
}
-static snd_kcontrol_new_t snd_korg1212_controls[] = {
+static struct snd_kcontrol_new snd_korg1212_controls[] = {
MON_MIXER(8, "Analog"),
MON_MIXER(10, "SPDIF"),
MON_MIXER(0, "ADAT-1"), MON_MIXER(1, "ADAT-2"), MON_MIXER(2, "ADAT-3"), MON_MIXER(3, "ADAT-4"),
@@ -2102,10 +2051,11 @@ static snd_kcontrol_new_t snd_korg1212_controls[] = {
* proc interface
*/
-static void snd_korg1212_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
+static void snd_korg1212_proc_read(struct snd_info_entry *entry,
+ struct snd_info_buffer *buffer)
{
int n;
- korg1212_t *korg1212 = (korg1212_t *)entry->private_data;
+ struct snd_korg1212 *korg1212 = entry->private_data;
snd_iprintf(buffer, korg1212->card->longname);
snd_iprintf(buffer, " (index #%d)\n", korg1212->card->number + 1);
@@ -2129,23 +2079,23 @@ static void snd_korg1212_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *b
snd_iprintf(buffer, " Error count: %ld\n", korg1212->totalerrorcnt);
}
-static void __devinit snd_korg1212_proc_init(korg1212_t *korg1212)
+static void __devinit snd_korg1212_proc_init(struct snd_korg1212 *korg1212)
{
- snd_info_entry_t *entry;
+ struct snd_info_entry *entry;
if (! snd_card_proc_new(korg1212->card, "korg1212", &entry))
snd_info_set_text_ops(entry, korg1212, 1024, snd_korg1212_proc_read);
}
static int
-snd_korg1212_free(korg1212_t *korg1212)
+snd_korg1212_free(struct snd_korg1212 *korg1212)
{
snd_korg1212_TurnOffIdleMonitor(korg1212);
if (korg1212->irq >= 0) {
synchronize_irq(korg1212->irq);
snd_korg1212_DisableCardInterrupts(korg1212);
- free_irq(korg1212->irq, (void *)korg1212);
+ free_irq(korg1212->irq, korg1212);
korg1212->irq = -1;
}
@@ -2194,25 +2144,23 @@ snd_korg1212_free(korg1212_t *korg1212)
return 0;
}
-static int snd_korg1212_dev_free(snd_device_t *device)
+static int snd_korg1212_dev_free(struct snd_device *device)
{
- korg1212_t *korg1212 = device->device_data;
-#if K1212_DEBUG_LEVEL > 0
+ struct snd_korg1212 *korg1212 = device->device_data;
K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n");
-#endif
return snd_korg1212_free(korg1212);
}
-static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
- korg1212_t ** rchip)
+static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
+ struct snd_korg1212 ** rchip)
{
- int err;
+ int err, rc;
unsigned int i;
unsigned ioport_size, iomem_size, iomem2_size;
- korg1212_t * korg1212;
+ struct snd_korg1212 * korg1212;
- static snd_device_ops_t ops = {
+ static struct snd_device_ops ops = {
.dev_free = snd_korg1212_dev_free,
};
@@ -2270,7 +2218,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
ioport_size = pci_resource_len(korg1212->pci, 1);
iomem2_size = pci_resource_len(korg1212->pci, 2);
-#if K1212_DEBUG_LEVEL > 0
K1212_DEBUG_PRINTK("K1212_DEBUG: resources:\n"
" iomem = 0x%lx (%d)\n"
" ioport = 0x%lx (%d)\n"
@@ -2280,7 +2227,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
korg1212->ioport, ioport_size,
korg1212->iomem2, iomem2_size,
stateName[korg1212->cardState]);
-#endif
if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) {
snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
@@ -2291,7 +2237,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
err = request_irq(pci->irq, snd_korg1212_interrupt,
SA_INTERRUPT|SA_SHIRQ,
- "korg1212", (void *) korg1212);
+ "korg1212", korg1212);
if (err) {
snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq);
@@ -2314,7 +2260,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET);
korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET);
-#if K1212_DEBUG_LEVEL > 0
K1212_DEBUG_PRINTK("K1212_DEBUG: card registers:\n"
" Status register = 0x%p\n"
" OutDoorbell = 0x%p\n"
@@ -2338,24 +2283,21 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
korg1212->sensRegPtr,
korg1212->idRegPtr,
stateName[korg1212->cardState]);
-#endif
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
- sizeof(KorgSharedBuffer), &korg1212->dma_shared) < 0) {
- snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%Zd bytes)\n", sizeof(KorgSharedBuffer));
+ sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) {
+ snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%Zd bytes)\n", sizeof(struct KorgSharedBuffer));
snd_korg1212_free(korg1212);
return -ENOMEM;
}
- korg1212->sharedBufferPtr = (KorgSharedBuffer *)korg1212->dma_shared.area;
+ korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area;
korg1212->sharedBufferPhy = korg1212->dma_shared.addr;
-#if K1212_DEBUG_LEVEL > 0
- K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(KorgSharedBuffer));
-#endif
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(struct KorgSharedBuffer));
#ifndef K1212_LARGEALLOC
- korg1212->DataBufsSize = sizeof(KorgAudioBuffer) * kNumBuffers;
+ korg1212->DataBufsSize = sizeof(struct KorgAudioBuffer) * kNumBuffers;
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
korg1212->DataBufsSize, &korg1212->dma_play) < 0) {
@@ -2363,13 +2305,11 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
snd_korg1212_free(korg1212);
return -ENOMEM;
}
- korg1212->playDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_play.area;
+ korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area;
korg1212->PlayDataPhy = korg1212->dma_play.addr;
-#if K1212_DEBUG_LEVEL > 0
K1212_DEBUG_PRINTK("K1212_DEBUG: Play Data Area = 0x%p (0x%08x), %d bytes\n",
korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize);
-#endif
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
@@ -2377,31 +2317,29 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
snd_korg1212_free(korg1212);
return -ENOMEM;
}
- korg1212->recordDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_rec.area;
+ korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area;
korg1212->RecDataPhy = korg1212->dma_rec.addr;
-#if K1212_DEBUG_LEVEL > 0
K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n",
korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize);
-#endif
#else // K1212_LARGEALLOC
korg1212->recordDataBufsPtr = korg1212->sharedBufferPtr->recordDataBufs;
korg1212->playDataBufsPtr = korg1212->sharedBufferPtr->playDataBufs;
- korg1212->PlayDataPhy = (u32) &((KorgSharedBuffer *) korg1212->sharedBufferPhy)->playDataBufs;
- korg1212->RecDataPhy = (u32) &((KorgSharedBuffer *) korg1212->sharedBufferPhy)->recordDataBufs;
+ korg1212->PlayDataPhy = (u32) &((struct KorgSharedBuffer *) korg1212->sharedBufferPhy)->playDataBufs;
+ korg1212->RecDataPhy = (u32) &((struct KorgSharedBuffer *) korg1212->sharedBufferPhy)->recordDataBufs;
#endif // K1212_LARGEALLOC
korg1212->dspCodeSize = sizeof (dspCode);
korg1212->VolumeTablePhy = korg1212->sharedBufferPhy +
- offsetof(KorgSharedBuffer, volumeData);
+ offsetof(struct KorgSharedBuffer, volumeData);
korg1212->RoutingTablePhy = korg1212->sharedBufferPhy +
- offsetof(KorgSharedBuffer, routeData);
+ offsetof(struct KorgSharedBuffer, routeData);
korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
- offsetof(KorgSharedBuffer, AdatTimeCode);
+ offsetof(struct KorgSharedBuffer, AdatTimeCode);
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) {
@@ -2410,17 +2348,14 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
return -ENOMEM;
}
-#if K1212_DEBUG_LEVEL > 0
K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n",
korg1212->dma_dsp.area, korg1212->dma_dsp.addr, korg1212->dspCodeSize,
stateName[korg1212->cardState]);
-#endif
rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
-#if K1212_DEBUG_LEVEL > 0
- if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
-#endif
+ if (rc)
+ K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) {
snd_korg1212_free(korg1212);
@@ -2434,8 +2369,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
if (snd_korg1212_downloadDSPCode(korg1212))
return -EBUSY;
- snd_printk(KERN_ERR
- "korg1212: dspMemPhy = %08x U[%08x], "
+ K1212_DEBUG_PRINTK("korg1212: dspMemPhy = %08x U[%08x], "
"PlayDataPhy = %08x L[%08x]\n"
"korg1212: RecDataPhy = %08x L[%08x], "
"VolumeTablePhy = %08x L[%08x]\n"
@@ -2461,9 +2395,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
korg1212->pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
- //snd_pcm_lib_preallocate_pages_for_all(korg1212->pcm,
- // K1212_MAX_BUF_SIZE, K1212_MAX_BUF_SIZE, GFP_KERNEL);
-
for (i = 0; i < ARRAY_SIZE(snd_korg1212_controls); i++) {
err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212));
if (err < 0)
@@ -2488,8 +2419,8 @@ snd_korg1212_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{
static int dev;
- korg1212_t *korg1212;
- snd_card_t *card;
+ struct snd_korg1212 *korg1212;
+ struct snd_card *card;
int err;
if (dev >= SNDRV_CARDS) {
@@ -2513,9 +2444,7 @@ snd_korg1212_probe(struct pci_dev *pci,
sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname,
korg1212->iomem, korg1212->irq);
-#if K1212_DEBUG_LEVEL > 0
K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname);
-#endif
if ((err = snd_card_register(card)) < 0) {
snd_card_free(card);
OpenPOWER on IntegriCloud