18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci#ifndef __SOUND_SEQ_MIDI_EVENT_H
38c2ecf20Sopenharmony_ci#define __SOUND_SEQ_MIDI_EVENT_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci *  MIDI byte <-> sequencer event coder
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci *  Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>,
98c2ecf20Sopenharmony_ci *                        Jaroslav Kysela <perex@perex.cz>
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <sound/asequencer.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define MAX_MIDI_EVENT_BUF	256
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/* midi status */
178c2ecf20Sopenharmony_cistruct snd_midi_event {
188c2ecf20Sopenharmony_ci	int qlen;		/* queue length */
198c2ecf20Sopenharmony_ci	int read;		/* chars read */
208c2ecf20Sopenharmony_ci	int type;		/* current event type */
218c2ecf20Sopenharmony_ci	unsigned char lastcmd;	/* last command (for MIDI state handling) */
228c2ecf20Sopenharmony_ci	unsigned char nostat;	/* no state flag */
238c2ecf20Sopenharmony_ci	int bufsize;		/* allocated buffer size */
248c2ecf20Sopenharmony_ci	unsigned char *buf;	/* input buffer */
258c2ecf20Sopenharmony_ci	spinlock_t lock;
268c2ecf20Sopenharmony_ci};
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciint snd_midi_event_new(int bufsize, struct snd_midi_event **rdev);
298c2ecf20Sopenharmony_civoid snd_midi_event_free(struct snd_midi_event *dev);
308c2ecf20Sopenharmony_civoid snd_midi_event_reset_encode(struct snd_midi_event *dev);
318c2ecf20Sopenharmony_civoid snd_midi_event_reset_decode(struct snd_midi_event *dev);
328c2ecf20Sopenharmony_civoid snd_midi_event_no_status(struct snd_midi_event *dev, int on);
338c2ecf20Sopenharmony_cibool snd_midi_event_encode_byte(struct snd_midi_event *dev, unsigned char c,
348c2ecf20Sopenharmony_ci				struct snd_seq_event *ev);
358c2ecf20Sopenharmony_ci/* decode from event to bytes - return number of written bytes if success */
368c2ecf20Sopenharmony_cilong snd_midi_event_decode(struct snd_midi_event *dev, unsigned char *buf, long count,
378c2ecf20Sopenharmony_ci			   struct snd_seq_event *ev);
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#endif /* __SOUND_SEQ_MIDI_EVENT_H */
40