linux/sound/core/seq/seq_midi_emul.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  GM/GS/XG midi module.
 *
 *  Copyright (C) 1999 Steve Ratcliffe
 *
 *  Based on awe_wave.c by Takashi Iwai
 */
/*
 * This module is used to keep track of the current midi state.
 * It can be used for drivers that are required to emulate midi when
 * the hardware doesn't.
 *
 * It was written for a AWE64 driver, but there should be no AWE specific
 * code in here.  If there is it should be reported as a bug.
 */

#include <linux/init.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/module.h>
#include <sound/core.h>
#include <sound/seq_kernel.h>
#include <sound/seq_midi_emul.h>
#include <sound/initval.h>
#include <sound/asoundef.h>

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

/* Prototypes for static functions */
static void note_off(const struct snd_midi_op *ops, void *drv,
		     struct snd_midi_channel *chan,
		     int note, int vel);
static void do_control(const struct snd_midi_op *ops, void *private,
		       struct snd_midi_channel_set *chset,
		       struct snd_midi_channel *chan,
		       int control, int value);
static void rpn(const struct snd_midi_op *ops, void *drv,
		struct snd_midi_channel *chan,
		struct snd_midi_channel_set *chset);
static void nrpn(const struct snd_midi_op *ops, void *drv,
		 struct snd_midi_channel *chan,
		 struct snd_midi_channel_set *chset);
static void sysex(const struct snd_midi_op *ops, void *private,
		  unsigned char *sysex,
		  int len, struct snd_midi_channel_set *chset);
static void all_sounds_off(const struct snd_midi_op *ops, void *private,
			   struct snd_midi_channel *chan);
static void all_notes_off(const struct snd_midi_op *ops, void *private,
			  struct snd_midi_channel *chan);
static void snd_midi_reset_controllers(struct snd_midi_channel *chan);
static void reset_all_channels(struct snd_midi_channel_set *chset);


/*
 * Process an event in a driver independent way.  This means dealing
 * with RPN, NRPN, SysEx etc that are defined for common midi applications
 * such as GM, GS and XG.
 * There modes that this module will run in are:
 *   Generic MIDI - no interpretation at all, it will just save current values
 *                  of controllers etc.
 *   GM - You can use all gm_ prefixed elements of chan.  Controls, RPN, NRPN,
 *        SysEx will be interpreded as defined in General Midi.
 *   GS - You can use all gs_ prefixed elements of chan. Codes for GS will be
 *        interpreted.
 *   XG - You can use all xg_ prefixed elements of chan.  Codes for XG will
 *        be interpreted.
 */
void
snd_midi_process_event(const struct snd_midi_op *ops,
		       struct snd_seq_event *ev,
		       struct snd_midi_channel_set *chanset)
{}
EXPORT_SYMBOL();


/*
 * release note
 */
static void
note_off(const struct snd_midi_op *ops, void *drv,
	 struct snd_midi_channel *chan,
	 int note, int vel)
{}

/*
 * Do all driver independent operations for this controller and pass
 * events that need to take place immediately to the driver.
 */
static void
do_control(const struct snd_midi_op *ops, void *drv,
	   struct snd_midi_channel_set *chset,
	   struct snd_midi_channel *chan, int control, int value)
{}


/*
 * initialize the MIDI status
 */
void
snd_midi_channel_set_clear(struct snd_midi_channel_set *chset)
{}
EXPORT_SYMBOL();

/*
 * Process a rpn message.
 */
static void
rpn(const struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
    struct snd_midi_channel_set *chset)
{}

/*
 * Process an nrpn message.
 */
static void
nrpn(const struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
     struct snd_midi_channel_set *chset)
{}


/*
 * convert channel parameter in GS sysex
 */
static int
get_channel(unsigned char cmd)
{}


/*
 * Process a sysex message.
 */
static void
sysex(const struct snd_midi_op *ops, void *private, unsigned char *buf, int len,
      struct snd_midi_channel_set *chset)
{}

/*
 * all sound off
 */
static void
all_sounds_off(const struct snd_midi_op *ops, void *drv,
	       struct snd_midi_channel *chan)
{}

/*
 * all notes off
 */
static void
all_notes_off(const struct snd_midi_op *ops, void *drv,
	      struct snd_midi_channel *chan)
{}

/*
 * Initialise a single midi channel control block.
 */
static void snd_midi_channel_init(struct snd_midi_channel *p, int n)
{}

/*
 * Allocate and initialise a set of midi channel control blocks.
 */
static struct snd_midi_channel *snd_midi_channel_init_set(int n)
{}

/*
 * reset all midi channels
 */
static void
reset_all_channels(struct snd_midi_channel_set *chset)
{}


/*
 * Allocate and initialise a midi channel set.
 */
struct snd_midi_channel_set *snd_midi_channel_alloc_set(int n)
{}
EXPORT_SYMBOL();

/*
 * Reset the midi controllers on a particular channel to default values.
 */
static void snd_midi_reset_controllers(struct snd_midi_channel *chan)
{}


/*
 * Free a midi channel set.
 */
void snd_midi_channel_free_set(struct snd_midi_channel_set *chset)
{}
EXPORT_SYMBOL();