linux/sound/drivers/opl3/opl3_synth.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  Copyright (c) by Uros Bizjak <[email protected]>
 *                   
 *  Routines for OPL2/OPL3/OPL4 control
 */

#include <linux/slab.h>
#include <linux/export.h>
#include <linux/nospec.h>
#include <sound/opl3.h>
#include <sound/asound_fm.h>
#include "opl3_voice.h"

#if IS_ENABLED(CONFIG_SND_SEQUENCER)
#define OPL3_SUPPORT_SYNTH
#endif

/*
 *    There is 18 possible 2 OP voices
 *      (9 in the left and 9 in the right).
 *      The first OP is the modulator and 2nd is the carrier.
 *
 *      The first three voices in the both sides may be connected
 *      with another voice to a 4 OP voice. For example voice 0
 *      can be connected with voice 3. The operators of voice 3 are
 *      used as operators 3 and 4 of the new 4 OP voice.
 *      In this case the 2 OP voice number 0 is the 'first half' and
 *      voice 3 is the second.
 */


/*
 *    Register offset table for OPL2/3 voices,
 *    OPL2 / one OPL3 register array side only
 */

char snd_opl3_regmap[MAX_OPL2_VOICES][4] =;

EXPORT_SYMBOL();

/*
 * prototypes
 */
static int snd_opl3_play_note(struct snd_opl3 * opl3, struct snd_dm_fm_note * note);
static int snd_opl3_set_voice(struct snd_opl3 * opl3, struct snd_dm_fm_voice * voice);
static int snd_opl3_set_params(struct snd_opl3 * opl3, struct snd_dm_fm_params * params);
static int snd_opl3_set_mode(struct snd_opl3 * opl3, int mode);
static int snd_opl3_set_connection(struct snd_opl3 * opl3, int connection);

/* ------------------------------ */

/*
 * open the device exclusively
 */
int snd_opl3_open(struct snd_hwdep * hw, struct file *file)
{}

/*
 * ioctl for hwdep device:
 */
int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file,
		   unsigned int cmd, unsigned long arg)
{}

/*
 * close the device
 */
int snd_opl3_release(struct snd_hwdep * hw, struct file *file)
{}

#ifdef OPL3_SUPPORT_SYNTH
/*
 * write the device - load patches
 */
long snd_opl3_write(struct snd_hwdep *hw, const char __user *buf, long count,
		    loff_t *offset)
{}


/*
 * Patch management
 */

/* offsets for SBI params */
#define AM_VIB
#define KSL_LEVEL
#define ATTACK_DECAY
#define SUSTAIN_RELEASE
#define WAVE_SELECT

/* offset for SBI instrument */
#define CONNECTION
#define OFFSET_4OP

/*
 * load a patch, obviously.
 *
 * loaded on the given program and bank numbers with the given type
 * (FM_PATCH_OPLx).
 * data is the pointer of SBI record _without_ header (key and name).
 * name is the name string of the patch.
 * ext is the extension data of 7 bytes long (stored in name of SBI
 * data up to offset 25), or NULL to skip.
 * return 0 if successful or a negative error code.
 */
int snd_opl3_load_patch(struct snd_opl3 *opl3,
			int prog, int bank, int type,
			const char *name,
			const unsigned char *ext,
			const unsigned char *data)
{}
EXPORT_SYMBOL();

/*
 * find a patch with the given program and bank numbers, returns its pointer
 * if no matching patch is found and create_patch is set, it creates a
 * new patch object.
 */
struct fm_patch *snd_opl3_find_patch(struct snd_opl3 *opl3, int prog, int bank,
				     int create_patch)
{}
EXPORT_SYMBOL();

/*
 * Clear all patches of the given OPL3 instance
 */
void snd_opl3_clear_patches(struct snd_opl3 *opl3)
{}
#endif /* OPL3_SUPPORT_SYNTH */

/* ------------------------------ */

void snd_opl3_reset(struct snd_opl3 * opl3)
{}

EXPORT_SYMBOL();

static int snd_opl3_play_note(struct snd_opl3 * opl3, struct snd_dm_fm_note * note)
{}


static int snd_opl3_set_voice(struct snd_opl3 * opl3, struct snd_dm_fm_voice * voice)
{}

static int snd_opl3_set_params(struct snd_opl3 * opl3, struct snd_dm_fm_params * params)
{}

static int snd_opl3_set_mode(struct snd_opl3 * opl3, int mode)
{}

static int snd_opl3_set_connection(struct snd_opl3 * opl3, int connection)
{}