xref: /kernel/linux/linux-6.6/include/sound/opl3.h (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci#ifndef __SOUND_OPL3_H
362306a36Sopenharmony_ci#define __SOUND_OPL3_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci/*
662306a36Sopenharmony_ci * Definitions of the OPL-3 registers.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
962306a36Sopenharmony_ci *                  Hannu Savolainen 1993-1996
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci *      The OPL-3 mode is switched on by writing 0x01, to the offset 5
1262306a36Sopenharmony_ci *      of the right side.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci *      Another special register at the right side is at offset 4. It contains
1562306a36Sopenharmony_ci *      a bit mask defining which voices are used as 4 OP voices.
1662306a36Sopenharmony_ci *
1762306a36Sopenharmony_ci *      The percussive mode is implemented in the left side only.
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci *      With the above exceptions the both sides can be operated independently.
2062306a36Sopenharmony_ci *
2162306a36Sopenharmony_ci *      A 4 OP voice can be created by setting the corresponding
2262306a36Sopenharmony_ci *      bit at offset 4 of the right side.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci *      For example setting the rightmost bit (0x01) changes the
2562306a36Sopenharmony_ci *      first voice on the right side to the 4 OP mode. The fourth
2662306a36Sopenharmony_ci *      voice is made inaccessible.
2762306a36Sopenharmony_ci *
2862306a36Sopenharmony_ci *      If a voice is set to the 2 OP mode, it works like 2 OP modes
2962306a36Sopenharmony_ci *      of the original YM3812 (AdLib). In addition the voice can
3062306a36Sopenharmony_ci *      be connected the left, right or both stereo channels. It can
3162306a36Sopenharmony_ci *      even be left unconnected. This works with 4 OP voices also.
3262306a36Sopenharmony_ci *
3362306a36Sopenharmony_ci *      The stereo connection bits are located in the FEEDBACK_CONNECTION
3462306a36Sopenharmony_ci *      register of the voice (0xC0-0xC8). In 4 OP voices these bits are
3562306a36Sopenharmony_ci *      in the second half of the voice.
3662306a36Sopenharmony_ci */
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#include <sound/core.h>
3962306a36Sopenharmony_ci#include <sound/hwdep.h>
4062306a36Sopenharmony_ci#include <sound/timer.h>
4162306a36Sopenharmony_ci#include <sound/seq_midi_emul.h>
4262306a36Sopenharmony_ci#include <sound/seq_oss.h>
4362306a36Sopenharmony_ci#include <sound/seq_oss_legacy.h>
4462306a36Sopenharmony_ci#include <sound/seq_device.h>
4562306a36Sopenharmony_ci#include <sound/asound_fm.h>
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci/*
4862306a36Sopenharmony_ci *    Register numbers for the global registers
4962306a36Sopenharmony_ci */
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#define OPL3_REG_TEST			0x01
5262306a36Sopenharmony_ci#define   OPL3_ENABLE_WAVE_SELECT	0x20
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define OPL3_REG_TIMER1			0x02
5562306a36Sopenharmony_ci#define OPL3_REG_TIMER2			0x03
5662306a36Sopenharmony_ci#define OPL3_REG_TIMER_CONTROL		0x04	/* Left side */
5762306a36Sopenharmony_ci#define   OPL3_IRQ_RESET		0x80
5862306a36Sopenharmony_ci#define   OPL3_TIMER1_MASK		0x40
5962306a36Sopenharmony_ci#define   OPL3_TIMER2_MASK		0x20
6062306a36Sopenharmony_ci#define   OPL3_TIMER1_START		0x01
6162306a36Sopenharmony_ci#define   OPL3_TIMER2_START		0x02
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define OPL3_REG_CONNECTION_SELECT	0x04	/* Right side */
6462306a36Sopenharmony_ci#define   OPL3_LEFT_4OP_0		0x01
6562306a36Sopenharmony_ci#define   OPL3_LEFT_4OP_1		0x02
6662306a36Sopenharmony_ci#define   OPL3_LEFT_4OP_2		0x04
6762306a36Sopenharmony_ci#define   OPL3_RIGHT_4OP_0		0x08
6862306a36Sopenharmony_ci#define   OPL3_RIGHT_4OP_1		0x10
6962306a36Sopenharmony_ci#define   OPL3_RIGHT_4OP_2		0x20
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci#define OPL3_REG_MODE			0x05	/* Right side */
7262306a36Sopenharmony_ci#define   OPL3_OPL3_ENABLE		0x01	/* OPL3 mode */
7362306a36Sopenharmony_ci#define   OPL3_OPL4_ENABLE		0x02	/* OPL4 mode */
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci#define OPL3_REG_KBD_SPLIT		0x08	/* Left side */
7662306a36Sopenharmony_ci#define   OPL3_COMPOSITE_SINE_WAVE_MODE	0x80	/* Don't use with OPL-3? */
7762306a36Sopenharmony_ci#define   OPL3_KEYBOARD_SPLIT		0x40
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#define OPL3_REG_PERCUSSION		0xbd	/* Left side only */
8062306a36Sopenharmony_ci#define   OPL3_TREMOLO_DEPTH		0x80
8162306a36Sopenharmony_ci#define   OPL3_VIBRATO_DEPTH		0x40
8262306a36Sopenharmony_ci#define	  OPL3_PERCUSSION_ENABLE	0x20
8362306a36Sopenharmony_ci#define   OPL3_BASSDRUM_ON		0x10
8462306a36Sopenharmony_ci#define   OPL3_SNAREDRUM_ON		0x08
8562306a36Sopenharmony_ci#define   OPL3_TOMTOM_ON		0x04
8662306a36Sopenharmony_ci#define   OPL3_CYMBAL_ON		0x02
8762306a36Sopenharmony_ci#define   OPL3_HIHAT_ON			0x01
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci/*
9062306a36Sopenharmony_ci *    Offsets to the register banks for operators. To get the
9162306a36Sopenharmony_ci *      register number just add the operator offset to the bank offset
9262306a36Sopenharmony_ci *
9362306a36Sopenharmony_ci *      AM/VIB/EG/KSR/Multiple (0x20 to 0x35)
9462306a36Sopenharmony_ci */
9562306a36Sopenharmony_ci#define OPL3_REG_AM_VIB			0x20
9662306a36Sopenharmony_ci#define   OPL3_TREMOLO_ON		0x80
9762306a36Sopenharmony_ci#define   OPL3_VIBRATO_ON		0x40
9862306a36Sopenharmony_ci#define   OPL3_SUSTAIN_ON		0x20
9962306a36Sopenharmony_ci#define   OPL3_KSR			0x10	/* Key scaling rate */
10062306a36Sopenharmony_ci#define   OPL3_MULTIPLE_MASK		0x0f	/* Frequency multiplier */
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci /*
10362306a36Sopenharmony_ci  *   KSL/Total level (0x40 to 0x55)
10462306a36Sopenharmony_ci  */
10562306a36Sopenharmony_ci#define OPL3_REG_KSL_LEVEL		0x40
10662306a36Sopenharmony_ci#define   OPL3_KSL_MASK			0xc0	/* Envelope scaling bits */
10762306a36Sopenharmony_ci#define   OPL3_TOTAL_LEVEL_MASK		0x3f	/* Strength (volume) of OP */
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci/*
11062306a36Sopenharmony_ci *    Attack / Decay rate (0x60 to 0x75)
11162306a36Sopenharmony_ci */
11262306a36Sopenharmony_ci#define OPL3_REG_ATTACK_DECAY		0x60
11362306a36Sopenharmony_ci#define   OPL3_ATTACK_MASK		0xf0
11462306a36Sopenharmony_ci#define   OPL3_DECAY_MASK		0x0f
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci/*
11762306a36Sopenharmony_ci * Sustain level / Release rate (0x80 to 0x95)
11862306a36Sopenharmony_ci */
11962306a36Sopenharmony_ci#define OPL3_REG_SUSTAIN_RELEASE	0x80
12062306a36Sopenharmony_ci#define   OPL3_SUSTAIN_MASK		0xf0
12162306a36Sopenharmony_ci#define   OPL3_RELEASE_MASK		0x0f
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci/*
12462306a36Sopenharmony_ci * Wave select (0xE0 to 0xF5)
12562306a36Sopenharmony_ci */
12662306a36Sopenharmony_ci#define OPL3_REG_WAVE_SELECT		0xe0
12762306a36Sopenharmony_ci#define   OPL3_WAVE_SELECT_MASK		0x07
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci/*
13062306a36Sopenharmony_ci *    Offsets to the register banks for voices. Just add to the
13162306a36Sopenharmony_ci *      voice number to get the register number.
13262306a36Sopenharmony_ci *
13362306a36Sopenharmony_ci *      F-Number low bits (0xA0 to 0xA8).
13462306a36Sopenharmony_ci */
13562306a36Sopenharmony_ci#define OPL3_REG_FNUM_LOW		0xa0
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci/*
13862306a36Sopenharmony_ci *    F-number high bits / Key on / Block (octave) (0xB0 to 0xB8)
13962306a36Sopenharmony_ci */
14062306a36Sopenharmony_ci#define OPL3_REG_KEYON_BLOCK		0xb0
14162306a36Sopenharmony_ci#define	  OPL3_KEYON_BIT		0x20
14262306a36Sopenharmony_ci#define	  OPL3_BLOCKNUM_MASK		0x1c
14362306a36Sopenharmony_ci#define   OPL3_FNUM_HIGH_MASK		0x03
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci/*
14662306a36Sopenharmony_ci *    Feedback / Connection (0xc0 to 0xc8)
14762306a36Sopenharmony_ci *
14862306a36Sopenharmony_ci *      These registers have two new bits when the OPL-3 mode
14962306a36Sopenharmony_ci *      is selected. These bits controls connecting the voice
15062306a36Sopenharmony_ci *      to the stereo channels. For 4 OP voices this bit is
15162306a36Sopenharmony_ci *      defined in the second half of the voice (add 3 to the
15262306a36Sopenharmony_ci *      register offset).
15362306a36Sopenharmony_ci *
15462306a36Sopenharmony_ci *      For 4 OP voices the connection bit is used in the
15562306a36Sopenharmony_ci *      both halves (gives 4 ways to connect the operators).
15662306a36Sopenharmony_ci */
15762306a36Sopenharmony_ci#define OPL3_REG_FEEDBACK_CONNECTION	0xc0
15862306a36Sopenharmony_ci#define   OPL3_FEEDBACK_MASK		0x0e	/* Valid just for 1st OP of a voice */
15962306a36Sopenharmony_ci#define   OPL3_CONNECTION_BIT		0x01
16062306a36Sopenharmony_ci/*
16162306a36Sopenharmony_ci *    In the 4 OP mode there is four possible configurations how the
16262306a36Sopenharmony_ci *      operators can be connected together (in 2 OP modes there is just
16362306a36Sopenharmony_ci *      AM or FM). The 4 OP connection mode is defined by the rightmost
16462306a36Sopenharmony_ci *      bit of the FEEDBACK_CONNECTION (0xC0-0xC8) on the both halves.
16562306a36Sopenharmony_ci *
16662306a36Sopenharmony_ci *      First half      Second half     Mode
16762306a36Sopenharmony_ci *
16862306a36Sopenharmony_ci *                                       +---+
16962306a36Sopenharmony_ci *                                       v   |
17062306a36Sopenharmony_ci *      0               0               >+-1-+--2--3--4-->
17162306a36Sopenharmony_ci *
17262306a36Sopenharmony_ci *
17362306a36Sopenharmony_ci *
17462306a36Sopenharmony_ci *                                       +---+
17562306a36Sopenharmony_ci *                                       |   |
17662306a36Sopenharmony_ci *      0               1               >+-1-+--2-+
17762306a36Sopenharmony_ci *                                                |->
17862306a36Sopenharmony_ci *                                      >--3----4-+
17962306a36Sopenharmony_ci *
18062306a36Sopenharmony_ci *                                       +---+
18162306a36Sopenharmony_ci *                                       |   |
18262306a36Sopenharmony_ci *      1               0               >+-1-+-----+
18362306a36Sopenharmony_ci *                                                 |->
18462306a36Sopenharmony_ci *                                      >--2--3--4-+
18562306a36Sopenharmony_ci *
18662306a36Sopenharmony_ci *                                       +---+
18762306a36Sopenharmony_ci *                                       |   |
18862306a36Sopenharmony_ci *      1               1               >+-1-+--+
18962306a36Sopenharmony_ci *                                              |
19062306a36Sopenharmony_ci *                                      >--2--3-+->
19162306a36Sopenharmony_ci *                                              |
19262306a36Sopenharmony_ci *                                      >--4----+
19362306a36Sopenharmony_ci */
19462306a36Sopenharmony_ci#define   OPL3_STEREO_BITS		0x30	/* OPL-3 only */
19562306a36Sopenharmony_ci#define     OPL3_VOICE_TO_LEFT		0x10
19662306a36Sopenharmony_ci#define     OPL3_VOICE_TO_RIGHT		0x20
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci/*
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci */
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci#define OPL3_LEFT		0x0000
20362306a36Sopenharmony_ci#define OPL3_RIGHT		0x0100
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci#define OPL3_HW_AUTO		0x0000
20662306a36Sopenharmony_ci#define OPL3_HW_OPL2		0x0200
20762306a36Sopenharmony_ci#define OPL3_HW_OPL3		0x0300
20862306a36Sopenharmony_ci#define OPL3_HW_OPL3_SV		0x0301	/* S3 SonicVibes */
20962306a36Sopenharmony_ci#define OPL3_HW_OPL3_CS		0x0302	/* CS4232/CS4236+ */
21062306a36Sopenharmony_ci#define OPL3_HW_OPL3_FM801	0x0303	/* FM801 */
21162306a36Sopenharmony_ci#define OPL3_HW_OPL3_CS4281	0x0304	/* CS4281 */
21262306a36Sopenharmony_ci#define OPL3_HW_OPL4		0x0400	/* YMF278B/YMF295 */
21362306a36Sopenharmony_ci#define OPL3_HW_OPL4_ML		0x0401	/* YMF704/YMF721 */
21462306a36Sopenharmony_ci#define OPL3_HW_MASK		0xff00
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci#define MAX_OPL2_VOICES		9
21762306a36Sopenharmony_ci#define MAX_OPL3_VOICES		18
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_cistruct snd_opl3;
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci/*
22262306a36Sopenharmony_ci * Instrument record, aka "Patch"
22362306a36Sopenharmony_ci */
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci/* FM operator */
22662306a36Sopenharmony_cistruct fm_operator {
22762306a36Sopenharmony_ci	unsigned char am_vib;
22862306a36Sopenharmony_ci	unsigned char ksl_level;
22962306a36Sopenharmony_ci	unsigned char attack_decay;
23062306a36Sopenharmony_ci	unsigned char sustain_release;
23162306a36Sopenharmony_ci	unsigned char wave_select;
23262306a36Sopenharmony_ci} __attribute__((packed));
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_ci/* Instrument data */
23562306a36Sopenharmony_cistruct fm_instrument {
23662306a36Sopenharmony_ci	struct fm_operator op[4];
23762306a36Sopenharmony_ci	unsigned char feedback_connection[2];
23862306a36Sopenharmony_ci	unsigned char echo_delay;
23962306a36Sopenharmony_ci	unsigned char echo_atten;
24062306a36Sopenharmony_ci	unsigned char chorus_spread;
24162306a36Sopenharmony_ci	unsigned char trnsps;
24262306a36Sopenharmony_ci	unsigned char fix_dur;
24362306a36Sopenharmony_ci	unsigned char modes;
24462306a36Sopenharmony_ci	unsigned char fix_key;
24562306a36Sopenharmony_ci};
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci/* type */
24862306a36Sopenharmony_ci#define FM_PATCH_OPL2	0x01		/* OPL2 2 operators FM instrument */
24962306a36Sopenharmony_ci#define FM_PATCH_OPL3	0x02		/* OPL3 4 operators FM instrument */
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci/* Instrument record */
25262306a36Sopenharmony_cistruct fm_patch {
25362306a36Sopenharmony_ci	unsigned char prog;
25462306a36Sopenharmony_ci	unsigned char bank;
25562306a36Sopenharmony_ci	unsigned char type;
25662306a36Sopenharmony_ci	struct fm_instrument inst;
25762306a36Sopenharmony_ci	char name[24];
25862306a36Sopenharmony_ci	struct fm_patch *next;
25962306a36Sopenharmony_ci};
26062306a36Sopenharmony_ci
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci/*
26362306a36Sopenharmony_ci * A structure to keep track of each hardware voice
26462306a36Sopenharmony_ci */
26562306a36Sopenharmony_cistruct snd_opl3_voice {
26662306a36Sopenharmony_ci	int  state;		/* status */
26762306a36Sopenharmony_ci#define SNDRV_OPL3_ST_OFF		0	/* Not playing */
26862306a36Sopenharmony_ci#define SNDRV_OPL3_ST_ON_2OP	1	/* 2op voice is allocated */
26962306a36Sopenharmony_ci#define SNDRV_OPL3_ST_ON_4OP	2	/* 4op voice is allocated */
27062306a36Sopenharmony_ci#define SNDRV_OPL3_ST_NOT_AVAIL	-1	/* voice is not available */
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ci	unsigned int time;	/* An allocation time */
27362306a36Sopenharmony_ci	unsigned char note;	/* Note currently assigned to this voice */
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci	unsigned long note_off;	/* note-off time */
27662306a36Sopenharmony_ci	int note_off_check;	/* check note-off time */
27762306a36Sopenharmony_ci
27862306a36Sopenharmony_ci	unsigned char keyon_reg;	/* KON register shadow */
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci	struct snd_midi_channel *chan;	/* Midi channel for this note */
28162306a36Sopenharmony_ci};
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_cistruct snd_opl3 {
28462306a36Sopenharmony_ci	unsigned long l_port;
28562306a36Sopenharmony_ci	unsigned long r_port;
28662306a36Sopenharmony_ci	struct resource *res_l_port;
28762306a36Sopenharmony_ci	struct resource *res_r_port;
28862306a36Sopenharmony_ci	unsigned short hardware;
28962306a36Sopenharmony_ci	/* hardware access */
29062306a36Sopenharmony_ci	void (*command) (struct snd_opl3 * opl3, unsigned short cmd, unsigned char val);
29162306a36Sopenharmony_ci	unsigned short timer_enable;
29262306a36Sopenharmony_ci	int seq_dev_num;	/* sequencer device number */
29362306a36Sopenharmony_ci	struct snd_timer *timer1;
29462306a36Sopenharmony_ci	struct snd_timer *timer2;
29562306a36Sopenharmony_ci	spinlock_t timer_lock;
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci	void *private_data;
29862306a36Sopenharmony_ci	void (*private_free)(struct snd_opl3 *);
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci	struct snd_hwdep *hwdep;
30162306a36Sopenharmony_ci	spinlock_t reg_lock;
30262306a36Sopenharmony_ci	struct snd_card *card;		/* The card that this belongs to */
30362306a36Sopenharmony_ci	unsigned char fm_mode;		/* OPL mode, see SNDRV_DM_FM_MODE_XXX */
30462306a36Sopenharmony_ci	unsigned char rhythm;		/* percussion mode flag */
30562306a36Sopenharmony_ci	unsigned char max_voices;	/* max number of voices */
30662306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SEQUENCER)
30762306a36Sopenharmony_ci#define SNDRV_OPL3_MODE_SYNTH 0		/* OSS - voices allocated by application */
30862306a36Sopenharmony_ci#define SNDRV_OPL3_MODE_SEQ 1		/* ALSA - driver handles voice allocation */
30962306a36Sopenharmony_ci	int synth_mode;			/* synth mode */
31062306a36Sopenharmony_ci	int seq_client;
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ci	struct snd_seq_device *seq_dev;	/* sequencer device */
31362306a36Sopenharmony_ci	struct snd_midi_channel_set * chset;
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
31662306a36Sopenharmony_ci	struct snd_seq_device *oss_seq_dev;	/* OSS sequencer device */
31762306a36Sopenharmony_ci	struct snd_midi_channel_set * oss_chset;
31862306a36Sopenharmony_ci#endif
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_ci#define OPL3_PATCH_HASH_SIZE	32
32162306a36Sopenharmony_ci	struct fm_patch *patch_table[OPL3_PATCH_HASH_SIZE];
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_ci	struct snd_opl3_voice voices[MAX_OPL3_VOICES]; /* Voices (OPL3 'channel') */
32462306a36Sopenharmony_ci	int use_time;			/* allocation counter */
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci	unsigned short connection_reg;	/* connection reg shadow */
32762306a36Sopenharmony_ci	unsigned char drum_reg;		/* percussion reg shadow */
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci	spinlock_t voice_lock;		/* Lock for voice access */
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ci	struct timer_list tlist;	/* timer for note-offs and effects */
33262306a36Sopenharmony_ci	int sys_timer_status;		/* system timer run status */
33362306a36Sopenharmony_ci	spinlock_t sys_timer_lock;	/* Lock for system timer access */
33462306a36Sopenharmony_ci#endif
33562306a36Sopenharmony_ci};
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_ci/* opl3.c */
33862306a36Sopenharmony_civoid snd_opl3_interrupt(struct snd_hwdep * hw);
33962306a36Sopenharmony_ciint snd_opl3_new(struct snd_card *card, unsigned short hardware,
34062306a36Sopenharmony_ci		 struct snd_opl3 **ropl3);
34162306a36Sopenharmony_ciint snd_opl3_init(struct snd_opl3 *opl3);
34262306a36Sopenharmony_ciint snd_opl3_create(struct snd_card *card,
34362306a36Sopenharmony_ci		    unsigned long l_port, unsigned long r_port,
34462306a36Sopenharmony_ci		    unsigned short hardware,
34562306a36Sopenharmony_ci		    int integrated,
34662306a36Sopenharmony_ci		    struct snd_opl3 ** opl3);
34762306a36Sopenharmony_ciint snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev);
34862306a36Sopenharmony_ciint snd_opl3_hwdep_new(struct snd_opl3 * opl3, int device, int seq_device,
34962306a36Sopenharmony_ci		       struct snd_hwdep ** rhwdep);
35062306a36Sopenharmony_ci
35162306a36Sopenharmony_ci/* opl3_synth */
35262306a36Sopenharmony_ciint snd_opl3_open(struct snd_hwdep * hw, struct file *file);
35362306a36Sopenharmony_ciint snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file,
35462306a36Sopenharmony_ci		   unsigned int cmd, unsigned long arg);
35562306a36Sopenharmony_ciint snd_opl3_release(struct snd_hwdep * hw, struct file *file);
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_civoid snd_opl3_reset(struct snd_opl3 * opl3);
35862306a36Sopenharmony_ci
35962306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SEQUENCER)
36062306a36Sopenharmony_cilong snd_opl3_write(struct snd_hwdep *hw, const char __user *buf, long count,
36162306a36Sopenharmony_ci		    loff_t *offset);
36262306a36Sopenharmony_ciint snd_opl3_load_patch(struct snd_opl3 *opl3,
36362306a36Sopenharmony_ci			int prog, int bank, int type,
36462306a36Sopenharmony_ci			const char *name,
36562306a36Sopenharmony_ci			const unsigned char *ext,
36662306a36Sopenharmony_ci			const unsigned char *data);
36762306a36Sopenharmony_cistruct fm_patch *snd_opl3_find_patch(struct snd_opl3 *opl3, int prog, int bank,
36862306a36Sopenharmony_ci				     int create_patch);
36962306a36Sopenharmony_civoid snd_opl3_clear_patches(struct snd_opl3 *opl3);
37062306a36Sopenharmony_ci#else
37162306a36Sopenharmony_ci#define snd_opl3_write	NULL
37262306a36Sopenharmony_cistatic inline void snd_opl3_clear_patches(struct snd_opl3 *opl3) {}
37362306a36Sopenharmony_ci#endif
37462306a36Sopenharmony_ci
37562306a36Sopenharmony_ci#endif /* __SOUND_OPL3_H */
376