Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
korg1212.c File Reference
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/firmware.h>
#include <sound/core.h>
#include <sound/info.h>
#include <sound/control.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/initval.h>
#include <asm/io.h>

Go to the source code of this file.

Data Structures

struct  KorgAudioFrame
 
struct  KorgAudioBuffer
 
struct  KorgSharedBuffer
 
struct  SensBits
 
struct  snd_korg1212
 
union  swap_u32
 

Macros

#define K1212_DEBUG_LEVEL   0
 
#define K1212_DEBUG_PRINTK(fmt,...)
 
#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...)
 
#define MAILBOX0_OFFSET   0x40
 
#define MAILBOX1_OFFSET   0x44
 
#define MAILBOX2_OFFSET   0x48
 
#define MAILBOX3_OFFSET   0x4c
 
#define OUT_DOORBELL_OFFSET   0x60
 
#define IN_DOORBELL_OFFSET   0x64
 
#define STATUS_REG_OFFSET   0x68
 
#define PCI_CONTROL_OFFSET   0x6c
 
#define SENS_CONTROL_OFFSET   0x6e
 
#define DEV_VEND_ID_OFFSET   0x70
 
#define MAX_COMMAND_RETRIES   5
 
#define COMMAND_ACK_MASK   0x8000
 
#define DOORBELL_VAL_MASK   0x00FF
 
#define CARD_BOOT_DELAY_IN_MS   10
 
#define CARD_BOOT_TIMEOUT   10
 
#define DSP_BOOT_DELAY_IN_MS   200
 
#define kNumBuffers   8
 
#define k1212MaxCards   4
 
#define k1212NumWaveDevices   6
 
#define k16BitChannels   10
 
#define k32BitChannels   2
 
#define kAudioChannels   (k16BitChannels + k32BitChannels)
 
#define kPlayBufferFrames   1024
 
#define K1212_ANALOG_CHANNELS   2
 
#define K1212_SPDIF_CHANNELS   2
 
#define K1212_ADAT_CHANNELS   8
 
#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(struct KorgAudioFrame))
 
#define K1212_MAX_SAMPLES   (kPlayBufferFrames*kNumBuffers)
 
#define K1212_PERIODS   (kNumBuffers)
 
#define K1212_PERIOD_BYTES   (K1212_FRAME_SIZE*kPlayBufferFrames)
 
#define K1212_BUF_SIZE   (K1212_PERIOD_BYTES*kNumBuffers)
 
#define K1212_ANALOG_BUF_SIZE   (K1212_ANALOG_CHANNELS * 2 * kPlayBufferFrames * kNumBuffers)
 
#define K1212_SPDIF_BUF_SIZE   (K1212_SPDIF_CHANNELS * 3 * kPlayBufferFrames * kNumBuffers)
 
#define K1212_ADAT_BUF_SIZE   (K1212_ADAT_CHANNELS * 2 * kPlayBufferFrames * kNumBuffers)
 
#define K1212_MAX_BUF_SIZE   (K1212_ANALOG_BUF_SIZE + K1212_ADAT_BUF_SIZE)
 
#define k1212MinADCSens   0x00
 
#define k1212MaxADCSens   0x7f
 
#define k1212MaxVolume   0x7fff
 
#define k1212MaxWaveVolume   0xffff
 
#define k1212MinVolume   0x0000
 
#define k1212MaxVolInverted   0x8000
 
#define PCI_INT_ENABLE_BIT   0x00000100
 
#define PCI_DOORBELL_INT_ENABLE_BIT   0x00000200
 
#define LOCAL_INT_ENABLE_BIT   0x00010000
 
#define LOCAL_DOORBELL_INT_ENABLE_BIT   0x00020000
 
#define LOCAL_DMA1_INT_ENABLE_BIT   0x00080000
 
#define PCI_CMD_MEM_SPACE_ENABLE_BIT   0x0002
 
#define PCI_CMD_IO_SPACE_ENABLE_BIT   0x0001
 
#define PCI_CMD_BUS_MASTER_ENABLE_BIT   0x0004
 
#define PCI_STAT_PARITY_ERROR_BIT   0x8000
 
#define PCI_STAT_SYSTEM_ERROR_BIT   0x4000
 
#define PCI_STAT_MASTER_ABORT_RCVD_BIT   0x2000
 
#define PCI_STAT_TARGET_ABORT_RCVD_BIT   0x1000
 
#define PCI_STAT_TARGET_ABORT_SENT_BIT   0x0800
 
#define SET_SENS_LOCALINIT_BITPOS   15
 
#define SET_SENS_DATA_BITPOS   10
 
#define SET_SENS_CLOCK_BITPOS   8
 
#define SET_SENS_LOADSHIFT_BITPOS   0
 
#define SET_SENS_LEFTCHANID   0x00
 
#define SET_SENS_RIGHTCHANID   0x01
 
#define K1212SENSUPDATE_DELAY_IN_MS   50
 
#define ONE_RTC_TICK   1
 
#define SENSCLKPULSE_WIDTH   4
 
#define LOADSHIFT_DELAY   4
 
#define INTERCOMMAND_DELAY   40
 
#define STOPCARD_DELAY   300
 
#define COMMAND_ACK_DELAY   13
 
#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)
 
#define MON_MIXER(ord, c_name)
 

Enumerations

enum  CardState {
  K1212_STATE_NONEXISTENT, K1212_STATE_UNINITIALIZED, K1212_STATE_DSP_IN_PROCESS, K1212_STATE_DSP_COMPLETE,
  K1212_STATE_READY, K1212_STATE_OPEN, K1212_STATE_SETUP, K1212_STATE_PLAYING,
  K1212_STATE_MONITOR, K1212_STATE_CALIBRATING, K1212_STATE_ERRORSTOP, K1212_STATE_MAX_STATE
}
 
enum  korg1212_dbcnst {
  K1212_DB_RequestForData = 0, K1212_DB_TriggerPlay = 1, K1212_DB_SelectPlayMode = 2, K1212_DB_ConfigureBufferMemory = 3,
  K1212_DB_RequestAdatTimecode = 4, K1212_DB_SetClockSourceRate = 5, K1212_DB_ConfigureMiscMemory = 6, K1212_DB_TriggerFromAdat = 7,
  K1212_DB_DMAERROR = 0x80, K1212_DB_CARDSTOPPED = 0x81, K1212_DB_RebootCard = 0xA0, K1212_DB_BootFromDSPPage4 = 0xA4,
  K1212_DB_DSPDownloadDone = 0xAE, K1212_DB_StartDSPDownload = 0xAF
}
 
enum  snd_korg1212rc {
  K1212_CMDRET_Success = 0, K1212_CMDRET_DIOCFailure, K1212_CMDRET_PMFailure, K1212_CMDRET_FailUnspecified,
  K1212_CMDRET_FailBadState, K1212_CMDRET_CardUninitialized, K1212_CMDRET_BadIndex, K1212_CMDRET_BadHandle,
  K1212_CMDRET_NoFillRoutine, K1212_CMDRET_FillRoutineInUse, K1212_CMDRET_NoAckFromCard, K1212_CMDRET_BadParams,
  K1212_CMDRET_BadDevice, K1212_CMDRET_BadFormat
}
 
enum  PlayModeSelector { K1212_MODE_SetupPlay = 0x00000001, K1212_MODE_MonitorOn = 0x00000002, K1212_MODE_MonitorOff = 0x00000004, K1212_MODE_StopPlay = 0x00000008 }
 
enum  MonitorModeSelector { K1212_MONMODE_Off = 0, K1212_MONMODE_On }
 
enum  ClockSourceIndex {
  K1212_CLKIDX_AdatAt44_1K = 0, K1212_CLKIDX_AdatAt48K, K1212_CLKIDX_WordAt44_1K, K1212_CLKIDX_WordAt48K,
  K1212_CLKIDX_LocalAt44_1K, K1212_CLKIDX_LocalAt48K, K1212_CLKIDX_Invalid
}
 
enum  ClockSourceType { K1212_CLKIDX_Adat = 0, K1212_CLKIDX_Word, K1212_CLKIDX_Local }
 

Functions

 MODULE_DESCRIPTION ("korg1212")
 
 MODULE_LICENSE ("GPL")
 
 MODULE_SUPPORTED_DEVICE ("{{KORG,korg1212}}")
 
 MODULE_FIRMWARE ("korg/k1212.dsp")
 
 module_param_array (index, int, NULL, 0444)
 
 MODULE_PARM_DESC (index,"Index value for Korg 1212 soundcard.")
 
 module_param_array (id, charp, NULL, 0444)
 
 MODULE_PARM_DESC (id,"ID string for Korg 1212 soundcard.")
 
 module_param_array (enable, bool, NULL, 0444)
 
 MODULE_PARM_DESC (enable,"Enable Korg 1212 soundcard.")
 
 MODULE_AUTHOR ("Haroldo Gamal <[email protected]>")
 
 MODULE_DEVICE_TABLE (pci, snd_korg1212_ids)
 
 module_pci_driver (korg1212_driver)
 

Macro Definition Documentation

#define CARD_BOOT_DELAY_IN_MS   10

Definition at line 171 of file korg1212.c.

#define CARD_BOOT_TIMEOUT   10

Definition at line 172 of file korg1212.c.

#define ClearBitInDWord (   theWord,
  bitPosition 
)    (*theWord) &= ~(0x00000001 << bitPosition)

Definition at line 521 of file korg1212.c.

#define ClearBitInWord (   theWord,
  bitPosition 
)    (*theWord) &= ~(0x0001 << bitPosition)

Definition at line 520 of file korg1212.c.

#define COMMAND_ACK_DELAY   13

Definition at line 260 of file korg1212.c.

#define COMMAND_ACK_MASK   0x8000

Definition at line 167 of file korg1212.c.

#define DEV_VEND_ID_OFFSET   0x70

Definition at line 163 of file korg1212.c.

#define DOORBELL_VAL_MASK   0x00FF

Definition at line 169 of file korg1212.c.

#define DSP_BOOT_DELAY_IN_MS   200

Definition at line 173 of file korg1212.c.

#define IN_DOORBELL_OFFSET   0x64

Definition at line 157 of file korg1212.c.

#define INTERCOMMAND_DELAY   40

Definition at line 257 of file korg1212.c.

#define K1212_ADAT_BUF_SIZE   (K1212_ADAT_CHANNELS * 2 * kPlayBufferFrames * kNumBuffers)

Definition at line 196 of file korg1212.c.

#define K1212_ADAT_CHANNELS   8

Definition at line 185 of file korg1212.c.

#define K1212_ANALOG_BUF_SIZE   (K1212_ANALOG_CHANNELS * 2 * kPlayBufferFrames * kNumBuffers)

Definition at line 194 of file korg1212.c.

#define K1212_ANALOG_CHANNELS   2

Definition at line 183 of file korg1212.c.

#define K1212_BUF_SIZE   (K1212_PERIOD_BYTES*kNumBuffers)

Definition at line 193 of file korg1212.c.

#define K1212_CHANNELS   (K1212_ADAT_CHANNELS + K1212_ANALOG_CHANNELS)

Definition at line 186 of file korg1212.c.

#define K1212_DEBUG_LEVEL   0

Definition at line 44 of file korg1212.c.

#define K1212_DEBUG_PRINTK (   fmt,
  ... 
)

Definition at line 48 of file korg1212.c.

#define K1212_DEBUG_PRINTK_VERBOSE (   fmt,
  ... 
)

Definition at line 53 of file korg1212.c.

#define K1212_FRAME_SIZE   (sizeof(struct KorgAudioFrame))

Definition at line 189 of file korg1212.c.

#define K1212_MAX_BUF_SIZE   (K1212_ANALOG_BUF_SIZE + K1212_ADAT_BUF_SIZE)

Definition at line 197 of file korg1212.c.

#define K1212_MAX_CHANNELS   K1212_CHANNELS

Definition at line 188 of file korg1212.c.

#define K1212_MAX_SAMPLES   (kPlayBufferFrames*kNumBuffers)

Definition at line 190 of file korg1212.c.

#define K1212_MIN_CHANNELS   1

Definition at line 187 of file korg1212.c.

#define K1212_PERIOD_BYTES   (K1212_FRAME_SIZE*kPlayBufferFrames)

Definition at line 192 of file korg1212.c.

#define K1212_PERIODS   (kNumBuffers)

Definition at line 191 of file korg1212.c.

#define K1212_SPDIF_BUF_SIZE   (K1212_SPDIF_CHANNELS * 3 * kPlayBufferFrames * kNumBuffers)

Definition at line 195 of file korg1212.c.

#define K1212_SPDIF_CHANNELS   2

Definition at line 184 of file korg1212.c.

#define k1212MaxADCSens   0x7f

Definition at line 200 of file korg1212.c.

#define k1212MaxCards   4

Definition at line 176 of file korg1212.c.

#define k1212MaxVolInverted   0x8000

Definition at line 204 of file korg1212.c.

#define k1212MaxVolume   0x7fff

Definition at line 201 of file korg1212.c.

#define k1212MaxWaveVolume   0xffff

Definition at line 202 of file korg1212.c.

#define k1212MinADCSens   0x00

Definition at line 199 of file korg1212.c.

#define k1212MinVolume   0x0000

Definition at line 203 of file korg1212.c.

#define k1212NumWaveDevices   6

Definition at line 177 of file korg1212.c.

#define K1212SENSUPDATE_DELAY_IN_MS   50

Definition at line 244 of file korg1212.c.

#define k16BitChannels   10

Definition at line 178 of file korg1212.c.

#define k32BitChannels   2

Definition at line 179 of file korg1212.c.

#define kAudioChannels   (k16BitChannels + k32BitChannels)

Definition at line 180 of file korg1212.c.

#define kNumBuffers   8

Definition at line 175 of file korg1212.c.

#define kPlayBufferFrames   1024

Definition at line 181 of file korg1212.c.

#define LOADSHIFT_DELAY   4

Definition at line 256 of file korg1212.c.

#define LOCAL_DMA1_INT_ENABLE_BIT   0x00080000

Definition at line 214 of file korg1212.c.

#define LOCAL_DOORBELL_INT_ENABLE_BIT   0x00020000

Definition at line 213 of file korg1212.c.

#define LOCAL_INT_ENABLE_BIT   0x00010000

Definition at line 212 of file korg1212.c.

#define MAILBOX0_OFFSET   0x40

Definition at line 152 of file korg1212.c.

#define MAILBOX1_OFFSET   0x44

Definition at line 153 of file korg1212.c.

#define MAILBOX2_OFFSET   0x48

Definition at line 154 of file korg1212.c.

#define MAILBOX3_OFFSET   0x4c

Definition at line 155 of file korg1212.c.

#define MAX_COMMAND_RETRIES   5

Definition at line 165 of file korg1212.c.

#define MON_MIXER (   ord,
  c_name 
)
Value:
{ \
.name = c_name " Monitor Volume", \
.info = snd_korg1212_control_volume_info, \
.get = snd_korg1212_control_volume_get, \
.put = snd_korg1212_control_volume_put, \
.private_value = ord, \
}, \
{ \
.name = c_name " Monitor Route", \
.info = snd_korg1212_control_route_info, \
.get = snd_korg1212_control_route_get, \
.put = snd_korg1212_control_route_put, \
.private_value = ord, \
}, \
{ \
.name = c_name " Monitor Phase Invert", \
.info = snd_korg1212_control_phase_info, \
.get = snd_korg1212_control_phase_get, \
.put = snd_korg1212_control_phase_put, \
.private_value = ord, \
}

Definition at line 2002 of file korg1212.c.

#define ONE_RTC_TICK   1

Definition at line 254 of file korg1212.c.

#define OUT_DOORBELL_OFFSET   0x60

Definition at line 156 of file korg1212.c.

#define PCI_CMD_BUS_MASTER_ENABLE_BIT   0x0004

Definition at line 221 of file korg1212.c.

#define PCI_CMD_IO_SPACE_ENABLE_BIT   0x0001

Definition at line 220 of file korg1212.c.

#define PCI_CMD_MEM_SPACE_ENABLE_BIT   0x0002

Definition at line 219 of file korg1212.c.

#define PCI_CONTROL_OFFSET   0x6c

Definition at line 159 of file korg1212.c.

#define PCI_DOORBELL_INT_ENABLE_BIT   0x00000200

Definition at line 211 of file korg1212.c.

#define PCI_INT_ENABLE_BIT   0x00000100

Definition at line 210 of file korg1212.c.

#define PCI_STAT_MASTER_ABORT_RCVD_BIT   0x2000

Definition at line 228 of file korg1212.c.

#define PCI_STAT_PARITY_ERROR_BIT   0x8000

Definition at line 226 of file korg1212.c.

#define PCI_STAT_SYSTEM_ERROR_BIT   0x4000

Definition at line 227 of file korg1212.c.

#define PCI_STAT_TARGET_ABORT_RCVD_BIT   0x1000

Definition at line 229 of file korg1212.c.

#define PCI_STAT_TARGET_ABORT_SENT_BIT   0x0800

Definition at line 230 of file korg1212.c.

#define SENS_CONTROL_OFFSET   0x6e

Definition at line 161 of file korg1212.c.

#define SENSCLKPULSE_WIDTH   4

Definition at line 255 of file korg1212.c.

#define SET_SENS_CLOCK_BITPOS   8

Definition at line 238 of file korg1212.c.

#define SET_SENS_DATA_BITPOS   10

Definition at line 237 of file korg1212.c.

#define SET_SENS_LEFTCHANID   0x00

Definition at line 241 of file korg1212.c.

#define SET_SENS_LOADSHIFT_BITPOS   0

Definition at line 239 of file korg1212.c.

#define SET_SENS_LOCALINIT_BITPOS   15

Definition at line 236 of file korg1212.c.

#define SET_SENS_RIGHTCHANID   0x01

Definition at line 242 of file korg1212.c.

#define SetBitInDWord (   theWord,
  bitPosition 
)    (*theWord) |= (0x00000001 << bitPosition)

Definition at line 519 of file korg1212.c.

#define SetBitInWord (   theWord,
  bitPosition 
)    (*theWord) |= (0x0001 << bitPosition)

Definition at line 518 of file korg1212.c.

#define STATUS_REG_OFFSET   0x68

Definition at line 158 of file korg1212.c.

#define STOPCARD_DELAY   300

Definition at line 258 of file korg1212.c.

Enumeration Type Documentation

enum CardState
Enumerator:
K1212_STATE_NONEXISTENT 
K1212_STATE_UNINITIALIZED 
K1212_STATE_DSP_IN_PROCESS 
K1212_STATE_DSP_COMPLETE 
K1212_STATE_READY 
K1212_STATE_OPEN 
K1212_STATE_SETUP 
K1212_STATE_PLAYING 
K1212_STATE_MONITOR 
K1212_STATE_CALIBRATING 
K1212_STATE_ERRORSTOP 
K1212_STATE_MAX_STATE 

Definition at line 65 of file korg1212.c.

Enumerator:
K1212_CLKIDX_AdatAt44_1K 
K1212_CLKIDX_AdatAt48K 
K1212_CLKIDX_WordAt44_1K 
K1212_CLKIDX_WordAt48K 
K1212_CLKIDX_LocalAt44_1K 
K1212_CLKIDX_LocalAt48K 
K1212_CLKIDX_Invalid 

Definition at line 263 of file korg1212.c.

Enumerator:
K1212_CLKIDX_Adat 
K1212_CLKIDX_Word 
K1212_CLKIDX_Local 

Definition at line 273 of file korg1212.c.

Enumerator:
K1212_DB_RequestForData 
K1212_DB_TriggerPlay 
K1212_DB_SelectPlayMode 
K1212_DB_ConfigureBufferMemory 
K1212_DB_RequestAdatTimecode 
K1212_DB_SetClockSourceRate 
K1212_DB_ConfigureMiscMemory 
K1212_DB_TriggerFromAdat 
K1212_DB_DMAERROR 
K1212_DB_CARDSTOPPED 
K1212_DB_RebootCard 
K1212_DB_BootFromDSPPage4 
K1212_DB_DSPDownloadDone 
K1212_DB_StartDSPDownload 

Definition at line 87 of file korg1212.c.

Enumerator:
K1212_MONMODE_Off 
K1212_MONMODE_On 

Definition at line 147 of file korg1212.c.

Enumerator:
K1212_MODE_SetupPlay 
K1212_MODE_MonitorOn 
K1212_MODE_MonitorOff 
K1212_MODE_StopPlay 

Definition at line 136 of file korg1212.c.

Enumerator:
K1212_CMDRET_Success 
K1212_CMDRET_DIOCFailure 
K1212_CMDRET_PMFailure 
K1212_CMDRET_FailUnspecified 
K1212_CMDRET_FailBadState 
K1212_CMDRET_CardUninitialized 
K1212_CMDRET_BadIndex 
K1212_CMDRET_BadHandle 
K1212_CMDRET_NoFillRoutine 
K1212_CMDRET_FillRoutineInUse 
K1212_CMDRET_NoAckFromCard 
K1212_CMDRET_BadParams 
K1212_CMDRET_BadDevice 
K1212_CMDRET_BadFormat 

Definition at line 112 of file korg1212.c.

Function Documentation

MODULE_AUTHOR ( "Haroldo Gamal <[email protected]>"  )
MODULE_DESCRIPTION ( "korg1212"  )
MODULE_DEVICE_TABLE ( pci  ,
snd_korg1212_ids   
)
MODULE_FIRMWARE ( "korg/k1212.dsp )
MODULE_LICENSE ( "GPL"  )
module_param_array ( index  ,
int  ,
NULL  ,
0444   
)
module_param_array ( id  ,
charp  ,
NULL  ,
0444   
)
module_param_array ( enable  ,
bool  ,
NULL  ,
0444   
)
MODULE_PARM_DESC ( index  ,
"Index value for Korg 1212 soundcard."   
)
MODULE_PARM_DESC ( id  ,
"ID string for Korg 1212 soundcard."   
)
MODULE_PARM_DESC ( enable  ,
"Enable Korg 1212 soundcard."   
)
module_pci_driver ( korg1212_driver  )
MODULE_SUPPORTED_DEVICE ( "{{KORG,korg1212}}"  )