linux/include/sound/rawmidi.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef __SOUND_RAWMIDI_H
#define __SOUND_RAWMIDI_H

/*
 *  Abstract layer for MIDI v1.0 stream
 *  Copyright (c) by Jaroslav Kysela <[email protected]>
 */

#include <sound/asound.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/workqueue.h>
#include <linux/device.h>

#if IS_ENABLED(CONFIG_SND_SEQUENCER)
#include <sound/seq_device.h>
#endif
#include <sound/info.h>

/*
 *  Raw MIDI interface
 */

#define SNDRV_RAWMIDI_DEVICES

#define SNDRV_RAWMIDI_LFLG_OUTPUT
#define SNDRV_RAWMIDI_LFLG_INPUT
#define SNDRV_RAWMIDI_LFLG_OPEN
#define SNDRV_RAWMIDI_LFLG_APPEND

struct snd_rawmidi;
struct snd_rawmidi_substream;
struct snd_seq_port_info;
struct pid;

struct snd_rawmidi_ops {};

struct snd_rawmidi_global_ops {};

struct snd_rawmidi_runtime {};

struct snd_rawmidi_substream {};

struct snd_rawmidi_file {};

struct snd_rawmidi_str {};

struct snd_rawmidi {};

/* main rawmidi functions */

int snd_rawmidi_new(struct snd_card *card, char *id, int device,
		    int output_count, int input_count,
		    struct snd_rawmidi **rmidi);
void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream,
			 const struct snd_rawmidi_ops *ops);

/* internal */
int snd_rawmidi_init(struct snd_rawmidi *rmidi,
		     struct snd_card *card, char *id, int device,
		     int output_count, int input_count,
		     unsigned int info_flags);
int snd_rawmidi_free(struct snd_rawmidi *rmidi);

/* callbacks */

int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
			const unsigned char *buffer, int count);
int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream);
int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream,
			      unsigned char *buffer, int count);
int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count);
int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream,
			 unsigned char *buffer, int count);
int snd_rawmidi_proceed(struct snd_rawmidi_substream *substream);

/* main midi functions */

int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info);
int snd_rawmidi_kernel_open(struct snd_rawmidi *rmidi, int subdevice,
			    int mode, struct snd_rawmidi_file *rfile);
int snd_rawmidi_kernel_release(struct snd_rawmidi_file *rfile);
int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
			      struct snd_rawmidi_params *params);
int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
			     struct snd_rawmidi_params *params);
int snd_rawmidi_drop_output(struct snd_rawmidi_substream *substream);
int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream);
int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream);
long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream,
			     unsigned char *buf, long count);
long snd_rawmidi_kernel_write(struct snd_rawmidi_substream *substream,
			      const unsigned char *buf, long count);

#endif /* __SOUND_RAWMIDI_H */