linux/sound/pci/korg1212/korg1212.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *   Driver for the Korg 1212 IO PCI card
 *
 *	Copyright (c) 2001 Haroldo Gamal <[email protected]>
 */

#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 <linux/io.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>

// ----------------------------------------------------------------------------
// Debug Stuff
// ----------------------------------------------------------------------------
#define K1212_DEBUG_LEVEL
#if K1212_DEBUG_LEVEL > 0
#define K1212_DEBUG_PRINTK
#else
#define K1212_DEBUG_PRINTK(fmt,...)
#endif
#if K1212_DEBUG_LEVEL > 1
#define K1212_DEBUG_PRINTK_VERBOSE
#else
#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...)
#endif

// ----------------------------------------------------------------------------
// Record/Play Buffer Allocation Method. If K1212_LARGEALLOC is defined all 
// buffers are alocated as a large piece inside KorgSharedBuffer.
// ----------------------------------------------------------------------------
//#define K1212_LARGEALLOC		1

// ----------------------------------------------------------------------------
// Valid states of the Korg 1212 I/O card.
// ----------------------------------------------------------------------------
enum CardState {};

// ----------------------------------------------------------------------------
// The following enumeration defines the constants written to the card's
// host-to-card doorbell to initiate a command.
// ----------------------------------------------------------------------------
enum korg1212_dbcnst {};


// ----------------------------------------------------------------------------
// The following enumeration defines return codes 
// to the Korg 1212 I/O driver.
// ----------------------------------------------------------------------------
enum snd_korg1212rc {};

// ----------------------------------------------------------------------------
// The following enumeration defines the constants used to select the play
// mode for the card in the SelectPlayMode command.
// ----------------------------------------------------------------------------
enum PlayModeSelector {};

// ----------------------------------------------------------------------------
// The following enumeration defines the constants used to select the monitor
// mode for the card in the SetMonitorMode command.
// ----------------------------------------------------------------------------
enum MonitorModeSelector {};

#define MAILBOX0_OFFSET
#define MAILBOX1_OFFSET
#define MAILBOX2_OFFSET
#define MAILBOX3_OFFSET
#define OUT_DOORBELL_OFFSET
#define IN_DOORBELL_OFFSET
#define STATUS_REG_OFFSET
#define PCI_CONTROL_OFFSET
					//    register
#define SENS_CONTROL_OFFSET
					//    this is the upper word of the PCI control reg.
#define DEV_VEND_ID_OFFSET

#define MAX_COMMAND_RETRIES
                                       //    to send a command before giving up.
#define COMMAND_ACK_MASK
                                        //    the card.
#define DOORBELL_VAL_MASK

#define CARD_BOOT_DELAY_IN_MS
#define CARD_BOOT_TIMEOUT
#define DSP_BOOT_DELAY_IN_MS

#define kNumBuffers
#define k1212MaxCards
#define k1212NumWaveDevices
#define k16BitChannels
#define k32BitChannels
#define kAudioChannels
#define kPlayBufferFrames

#define K1212_ANALOG_CHANNELS
#define K1212_SPDIF_CHANNELS
#define K1212_ADAT_CHANNELS
#define K1212_CHANNELS
#define K1212_MIN_CHANNELS
#define K1212_MAX_CHANNELS
#define K1212_FRAME_SIZE
#define K1212_MAX_SAMPLES
#define K1212_PERIODS
#define K1212_PERIOD_BYTES
#define K1212_BUF_SIZE
#define K1212_ANALOG_BUF_SIZE
#define K1212_SPDIF_BUF_SIZE
#define K1212_ADAT_BUF_SIZE
#define K1212_MAX_BUF_SIZE

#define k1212MinADCSens
#define k1212MaxADCSens
#define k1212MaxVolume
#define k1212MaxWaveVolume
#define k1212MinVolume
#define k1212MaxVolInverted

// -----------------------------------------------------------------
// the following bits are used for controlling interrupts in the
// interrupt control/status reg
// -----------------------------------------------------------------
#define PCI_INT_ENABLE_BIT
#define PCI_DOORBELL_INT_ENABLE_BIT
#define LOCAL_INT_ENABLE_BIT
#define LOCAL_DOORBELL_INT_ENABLE_BIT
#define LOCAL_DMA1_INT_ENABLE_BIT

// -----------------------------------------------------------------
// the following bits are defined for the PCI command register
// -----------------------------------------------------------------
#define PCI_CMD_MEM_SPACE_ENABLE_BIT
#define PCI_CMD_IO_SPACE_ENABLE_BIT
#define PCI_CMD_BUS_MASTER_ENABLE_BIT

// -----------------------------------------------------------------
// the following bits are defined for the PCI status register
// -----------------------------------------------------------------
#define PCI_STAT_PARITY_ERROR_BIT
#define PCI_STAT_SYSTEM_ERROR_BIT
#define PCI_STAT_MASTER_ABORT_RCVD_BIT
#define PCI_STAT_TARGET_ABORT_RCVD_BIT
#define PCI_STAT_TARGET_ABORT_SENT_BIT

// ------------------------------------------------------------------------
// the following constants are used in setting the 1212 I/O card's input
// sensitivity.
// ------------------------------------------------------------------------
#define SET_SENS_LOCALINIT_BITPOS
#define SET_SENS_DATA_BITPOS
#define SET_SENS_CLOCK_BITPOS
#define SET_SENS_LOADSHIFT_BITPOS

#define SET_SENS_LEFTCHANID
#define SET_SENS_RIGHTCHANID

#define K1212SENSUPDATE_DELAY_IN_MS

// --------------------------------------------------------------------------
// WaitRTCTicks
//
//    This function waits the specified number of real time clock ticks.
//    According to the DDK, each tick is ~0.8 microseconds.
//    The defines following the function declaration can be used for the
//    numTicksToWait parameter.
// --------------------------------------------------------------------------
#define ONE_RTC_TICK
#define SENSCLKPULSE_WIDTH
#define LOADSHIFT_DELAY
#define INTERCOMMAND_DELAY
#define STOPCARD_DELAY
                                       //    the command register.  (could be up to 180 us)
#define COMMAND_ACK_DELAY
                                       //    from the card after sending a command.

enum ClockSourceIndex {};

enum ClockSourceType {};

struct KorgAudioFrame {};

struct KorgAudioBuffer {};

struct KorgSharedBuffer {};

struct SensBits {};

struct snd_korg1212 {};

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_FIRMWARE();

static int index[SNDRV_CARDS] =;     /* Index 0-MAX */
static char *id[SNDRV_CARDS] =;	   /* ID for this card */
static bool enable[SNDRV_CARDS] =; /* Enable this card */

module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
MODULE_AUTHOR();

static const struct pci_device_id snd_korg1212_ids[] =;

MODULE_DEVICE_TABLE(pci, snd_korg1212_ids);

static const char * const stateName[] =;

static const char * const clockSourceTypeName[] =;

static const char * const clockSourceName[] =;

static const char * const channelName[] =;

static const u16 ClockSourceSelector[] =;

swap_u32;

#ifdef SNDRV_BIG_ENDIAN
static u32 LowerWordSwap(u32 swappee)
#else
static u32 UpperWordSwap(u32 swappee)
#endif
{}

#ifdef SNDRV_BIG_ENDIAN
static u32 UpperWordSwap(u32 swappee)
#else
static u32 LowerWordSwap(u32 swappee)
#endif
{}

#define SetBitInWord(theWord,bitPosition)
#define SetBitInDWord(theWord,bitPosition)
#define ClearBitInWord(theWord,bitPosition)
#define ClearBitInDWord(theWord,bitPosition)

static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212,
					enum korg1212_dbcnst doorbellVal,
					u32 mailBox0Val, u32 mailBox1Val,
					u32 mailBox2Val, u32 mailBox3Val)
{}

/* spinlock already held */
static void snd_korg1212_SendStop(struct snd_korg1212 *korg1212)
{}

static void snd_korg1212_SendStopAndWait(struct snd_korg1212 *korg1212)
{}

/* timer callback for checking the ack of stop request */
static void snd_korg1212_timer_func(struct timer_list *t)
{}

static int snd_korg1212_TurnOnIdleMonitor(struct snd_korg1212 *korg1212)
{}

static void snd_korg1212_TurnOffIdleMonitor(struct snd_korg1212 *korg1212)
{}

static inline void snd_korg1212_setCardState(struct snd_korg1212 * korg1212, enum CardState csState)
{}

static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212)
{}

static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
{}

/* spinlock already held */
static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212)
{}

/* spinlock already held */
static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212)
{}

/* spinlock already held */
static int snd_korg1212_StopPlay(struct snd_korg1212 * korg1212)
{}

static void snd_korg1212_EnableCardInterrupts(struct snd_korg1212 * korg1212)
{}

#if 0 /* not used */

static int snd_korg1212_SetMonitorMode(struct snd_korg1212 *korg1212,
				       enum MonitorModeSelector mode)
{
	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 {
			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;
        }

        return 1;
}

#endif /* not used */

static inline int snd_korg1212_use_is_exclusive(struct snd_korg1212 *korg1212)
{}

static int snd_korg1212_SetRate(struct snd_korg1212 *korg1212, int rate)
{}

static int snd_korg1212_SetClockSource(struct snd_korg1212 *korg1212, int source)
{}

static void snd_korg1212_DisableCardInterrupts(struct snd_korg1212 *korg1212)
{}

static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212)
{}

static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212)
{}

static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id)
{}

static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212)
{}

static const struct snd_pcm_hardware snd_korg1212_playback_info =;

static const struct snd_pcm_hardware snd_korg1212_capture_info =;

static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int count, int offset, int size)
{}

static int snd_korg1212_copy_to(struct snd_pcm_substream *substream,
				struct iov_iter *dst, int pos, int count)
{}

static int snd_korg1212_copy_from(struct snd_pcm_substream *substream,
				  struct iov_iter *src, int pos, int count)
{}

static void snd_korg1212_free_pcm(struct snd_pcm *pcm)
{}

static int snd_korg1212_playback_open(struct snd_pcm_substream *substream)
{}


static int snd_korg1212_capture_open(struct snd_pcm_substream *substream)
{}

static int snd_korg1212_playback_close(struct snd_pcm_substream *substream)
{}

static int snd_korg1212_capture_close(struct snd_pcm_substream *substream)
{}

static int snd_korg1212_ioctl(struct snd_pcm_substream *substream,
			     unsigned int cmd, void *arg)
{}

static int snd_korg1212_hw_params(struct snd_pcm_substream *substream,
                             struct snd_pcm_hw_params *params)
{}

static int snd_korg1212_prepare(struct snd_pcm_substream *substream)
{}

static int snd_korg1212_trigger(struct snd_pcm_substream *substream,
                           int cmd)
{}

static snd_pcm_uframes_t snd_korg1212_playback_pointer(struct snd_pcm_substream *substream)
{}

static snd_pcm_uframes_t snd_korg1212_capture_pointer(struct snd_pcm_substream *substream)
{}

static int snd_korg1212_playback_copy(struct snd_pcm_substream *substream,
				      int channel, unsigned long pos,
				      struct iov_iter *src, unsigned long count)
{}

static int snd_korg1212_playback_silence(struct snd_pcm_substream *substream,
                           int channel, /* not used (interleaved data) */
                           unsigned long pos,
                           unsigned long count)
{}

static int snd_korg1212_capture_copy(struct snd_pcm_substream *substream,
				     int channel, unsigned long pos,
				     struct iov_iter *dst, unsigned long count)
{}

static const struct snd_pcm_ops snd_korg1212_playback_ops =;

static const struct snd_pcm_ops snd_korg1212_capture_ops =;

/*
 * Control Interface
 */

static int snd_korg1212_control_phase_info(struct snd_kcontrol *kcontrol,
					   struct snd_ctl_elem_info *uinfo)
{}

static int snd_korg1212_control_phase_get(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *u)
{}

static int snd_korg1212_control_phase_put(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *u)
{}

static int snd_korg1212_control_volume_info(struct snd_kcontrol *kcontrol,
					    struct snd_ctl_elem_info *uinfo)
{}

static int snd_korg1212_control_volume_get(struct snd_kcontrol *kcontrol,
					   struct snd_ctl_elem_value *u)
{}

static int snd_korg1212_control_volume_put(struct snd_kcontrol *kcontrol,
					   struct snd_ctl_elem_value *u)
{}

static int snd_korg1212_control_route_info(struct snd_kcontrol *kcontrol,
					   struct snd_ctl_elem_info *uinfo)
{}

static int snd_korg1212_control_route_get(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *u)
{}

static int snd_korg1212_control_route_put(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *u)
{}

static int snd_korg1212_control_info(struct snd_kcontrol *kcontrol,
				     struct snd_ctl_elem_info *uinfo)
{}

static int snd_korg1212_control_get(struct snd_kcontrol *kcontrol,
				    struct snd_ctl_elem_value *u)
{}

static int snd_korg1212_control_put(struct snd_kcontrol *kcontrol,
				    struct snd_ctl_elem_value *u)
{}

static int snd_korg1212_control_sync_info(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_info *uinfo)
{}

static int snd_korg1212_control_sync_get(struct snd_kcontrol *kcontrol,
					 struct snd_ctl_elem_value *ucontrol)
{}

static int snd_korg1212_control_sync_put(struct snd_kcontrol *kcontrol,
					 struct snd_ctl_elem_value *ucontrol)
{}

#define MON_MIXER(ord,c_name)

static const struct snd_kcontrol_new snd_korg1212_controls[] =;

/*
 * proc interface
 */

static void snd_korg1212_proc_read(struct snd_info_entry *entry,
				   struct snd_info_buffer *buffer)
{}

static void snd_korg1212_proc_init(struct snd_korg1212 *korg1212)
{}

static void
snd_korg1212_free(struct snd_card *card)
{}

static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci)

{}

/*
 * Card initialisation
 */

static int
snd_korg1212_probe(struct pci_dev *pci,
		const struct pci_device_id *pci_id)
{}

static struct pci_driver korg1212_driver =;

module_pci_driver();