linux/sound/drivers/serial-u16550.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *   serial.c
 *   Copyright (c) by Jaroslav Kysela <[email protected]>,
 *                    Isaku Yamahata <[email protected]>,
 *		      George Hansper <[email protected]>,
 *		      Hannu Savolainen
 *
 *   This code is based on the code from ALSA 0.5.9, but heavily rewritten.
 *
 * Sat Mar 31 17:27:57 PST 2001 [email protected] 
 *      Added support for the Midiator MS-124T and for the MS-124W in
 *      Single Addressed (S/A) or Multiple Burst (M/B) mode, with
 *      power derived either parasitically from the serial port or
 *      from a separate power supply.
 *
 *      More documentation can be found in serial-u16550.txt.
 */

#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/io.h>
#include <sound/core.h>
#include <sound/rawmidi.h>
#include <sound/initval.h>

#include <linux/serial_reg.h>
#include <linux/jiffies.h>

MODULE_DESCRIPTION();
MODULE_LICENSE();

#define SNDRV_SERIAL_SOUNDCANVAS
#define SNDRV_SERIAL_MS124T
#define SNDRV_SERIAL_MS124W_SA
#define SNDRV_SERIAL_MS124W_MB
#define SNDRV_SERIAL_GENERIC
#define SNDRV_SERIAL_MAX_ADAPTOR
static const char * const adaptor_names[] =;

#define SNDRV_SERIAL_NORMALBUFF
#define SNDRV_SERIAL_DROPBUFF

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 */
static long port[SNDRV_CARDS] =; /* 0x3f8,0x2f8,0x3e8,0x2e8 */
static int irq[SNDRV_CARDS] =; 	/* 3,4,5,7,9,10,11,14,15 */
static int speed[SNDRV_CARDS] =; /* 9600,19200,38400,57600,115200 */
static int base[SNDRV_CARDS] =; /* baud base */
static int outs[SNDRV_CARDS] =;	 /* 1 to 16 */
static int ins[SNDRV_CARDS] =;	/* 1 to 16 */
static int adaptor[SNDRV_CARDS] =;
static bool droponfull[SNDRV_CARDS] =;

module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_hw_array(port, long, ioport, NULL, 0444);
MODULE_PARM_DESC();
module_param_hw_array(irq, int, irq, NULL, 0444);
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();
module_param_array();
MODULE_PARM_DESC();

module_param_array();
MODULE_PARM_DESC();

/*#define SNDRV_SERIAL_MS124W_MB_NOCOMBO 1*/  /* Address outs as 0-3 instead of bitmap */

#define SNDRV_SERIAL_MAX_OUTS
#define SNDRV_SERIAL_MAX_INS

#define TX_BUFF_SIZE
#define TX_BUFF_MASK

#define SERIAL_MODE_NOT_OPENED
#define SERIAL_MODE_INPUT_OPEN
#define SERIAL_MODE_OUTPUT_OPEN
#define SERIAL_MODE_INPUT_TRIGGERED
#define SERIAL_MODE_OUTPUT_TRIGGERED

struct snd_uart16550 {};

static struct platform_device *devices[SNDRV_CARDS];

static inline void snd_uart16550_add_timer(struct snd_uart16550 *uart)
{}

static inline void snd_uart16550_del_timer(struct snd_uart16550 *uart)
{}

/* This macro is only used in snd_uart16550_io_loop */
static inline void snd_uart16550_buffer_output(struct snd_uart16550 *uart)
{}

/* This loop should be called with interrupts disabled
 * We don't want to interrupt this, 
 * as we're already handling an interrupt 
 */
static void snd_uart16550_io_loop(struct snd_uart16550 * uart)
{}

/* NOTES ON SERVICING INTERUPTS
 * ---------------------------
 * After receiving a interrupt, it is important to indicate to the UART that
 * this has been done. 
 * For a Rx interrupt, this is done by reading the received byte.
 * For a Tx interrupt this is done by either:
 * a) Writing a byte
 * b) Reading the IIR
 * It is particularly important to read the IIR if a Tx interrupt is received
 * when there is no data in tx_buff[], as in this case there no other
 * indication that the interrupt has been serviced, and it remains outstanding
 * indefinitely. This has the curious side effect that and no further interrupts
 * will be generated from this device AT ALL!!.
 * It is also desirable to clear outstanding interrupts when the device is
 * opened/closed.
 *
 *
 * Note that some devices need OUT2 to be set before they will generate
 * interrupts at all. (Possibly tied to an internal pull-up on CTS?)
 */
static irqreturn_t snd_uart16550_interrupt(int irq, void *dev_id)
{}

/* When the polling mode, this function calls snd_uart16550_io_loop. */
static void snd_uart16550_buffer_timer(struct timer_list *t)
{}

/*
 *  this method probes, if an uart sits on given port
 *  return 0 if found
 *  return negative error if not found
 */
static int snd_uart16550_detect(struct snd_uart16550 *uart)
{}

static void snd_uart16550_do_open(struct snd_uart16550 * uart)
{}

static void snd_uart16550_do_close(struct snd_uart16550 * uart)
{}

static int snd_uart16550_input_open(struct snd_rawmidi_substream *substream)
{}

static int snd_uart16550_input_close(struct snd_rawmidi_substream *substream)
{}

static void snd_uart16550_input_trigger(struct snd_rawmidi_substream *substream,
					int up)
{}

static int snd_uart16550_output_open(struct snd_rawmidi_substream *substream)
{
	unsigned long flags;
	struct snd_uart16550 *uart = substream->rmidi->private_data;

	spin_lock_irqsave(&uart->open_lock, flags);
	if (uart->filemode == SERIAL_MODE_NOT_OPENED)
		snd_uart16550_do_open(uart);
	uart->filemode |= SERIAL_MODE_OUTPUT_OPEN;
	uart->midi_output[substream->number] = substream;
	spin_unlock_irqrestore(&uart->open_lock, flags);
	return 0;
};

static int snd_uart16550_output_close(struct snd_rawmidi_substream *substream)
{
	unsigned long flags;
	struct snd_uart16550 *uart = substream->rmidi->private_data;

	spin_lock_irqsave(&uart->open_lock, flags);
	uart->filemode &= ~SERIAL_MODE_OUTPUT_OPEN;
	uart->midi_output[substream->number] = NULL;
	if (uart->filemode == SERIAL_MODE_NOT_OPENED)
		snd_uart16550_do_close(uart);
	spin_unlock_irqrestore(&uart->open_lock, flags);
	return 0;
};

static inline int snd_uart16550_buffer_can_write(struct snd_uart16550 *uart,
						 int Num)
{}

static inline int snd_uart16550_write_buffer(struct snd_uart16550 *uart,
					     unsigned char byte)
{}

static int snd_uart16550_output_byte(struct snd_uart16550 *uart,
				     struct snd_rawmidi_substream *substream,
				     unsigned char midi_byte)
{}

static void snd_uart16550_output_write(struct snd_rawmidi_substream *substream)
{}

static void snd_uart16550_output_trigger(struct snd_rawmidi_substream *substream,
					 int up)
{}

static const struct snd_rawmidi_ops snd_uart16550_output =;

static const struct snd_rawmidi_ops snd_uart16550_input =;

static int snd_uart16550_create(struct snd_card *card,
				unsigned long iobase,
				int irq,
				unsigned int speed,
				unsigned int base,
				int adaptor,
				int droponfull,
				struct snd_uart16550 **ruart)
{}

static void snd_uart16550_substreams(struct snd_rawmidi_str *stream)
{}

static int snd_uart16550_rmidi(struct snd_uart16550 *uart, int device,
			       int outs, int ins,
			       struct snd_rawmidi **rmidi)
{}

static int snd_serial_probe(struct platform_device *devptr)
{}

#define SND_SERIAL_DRIVER

static struct platform_driver snd_serial_driver =;

static void snd_serial_unregister_all(void)
{}

static int __init alsa_card_serial_init(void)
{}

static void __exit alsa_card_serial_exit(void)
{}

module_init()
module_exit()