linux/sound/drivers/serial-generic.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *   serial-generic.c
 *   Copyright (c) by Daniel Kaehn <[email protected]
 *   Based on serial-u16550.c by Jaroslav Kysela <[email protected]>,
 *		                 Isaku Yamahata <[email protected]>,
 *		                 George Hansper <[email protected]>,
 *		                 Hannu Savolainen
 *
 * Generic serial MIDI driver using the serdev serial bus API for hardware interaction
 */

#include <linux/err.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/serdev.h>
#include <linux/serial_reg.h>
#include <linux/slab.h>
#include <linux/dev_printk.h>

#include <sound/core.h>
#include <sound/rawmidi.h>
#include <sound/initval.h>

MODULE_DESCRIPTION();
MODULE_LICENSE();

#define SERIAL_MODE_INPUT_OPEN
#define SERIAL_MODE_OUTPUT_OPEN
#define SERIAL_MODE_INPUT_TRIGGERED
#define SERIAL_MODE_OUTPUT_TRIGGERED

#define SERIAL_TX_STATE_ACTIVE
#define SERIAL_TX_STATE_WAKEUP

struct snd_serial_generic {};

static void snd_serial_generic_tx_wakeup(struct snd_serial_generic *drvdata)
{}

#define INTERNAL_BUF_SIZE

static void snd_serial_generic_tx_work(struct work_struct *work)
{}

static void snd_serial_generic_write_wakeup(struct serdev_device *serdev)
{}

static size_t snd_serial_generic_receive_buf(struct serdev_device *serdev,
					     const u8 *buf, size_t count)
{}

static const struct serdev_device_ops snd_serial_generic_serdev_device_ops =;

static int snd_serial_generic_ensure_serdev_open(struct snd_serial_generic *drvdata)
{}

static int snd_serial_generic_input_open(struct snd_rawmidi_substream *substream)
{}

static int snd_serial_generic_input_close(struct snd_rawmidi_substream *substream)
{}

static void snd_serial_generic_input_trigger(struct snd_rawmidi_substream *substream,
					int up)
{}

static int snd_serial_generic_output_open(struct snd_rawmidi_substream *substream)
{
	struct snd_serial_generic *drvdata = substream->rmidi->card->private_data;
	int err;

	dev_dbg(drvdata->card->dev, "Opening output for card %s\n",
		drvdata->card->shortname);

	err = snd_serial_generic_ensure_serdev_open(drvdata);
	if (err < 0)
		return err;

	set_bit(SERIAL_MODE_OUTPUT_OPEN, &drvdata->filemode);

	drvdata->midi_output = substream;
	return 0;
};

static int snd_serial_generic_output_close(struct snd_rawmidi_substream *substream)
{
	struct snd_serial_generic *drvdata = substream->rmidi->card->private_data;

	dev_dbg(drvdata->card->dev, "Closing output for card %s\n",
		drvdata->card->shortname);

	clear_bit(SERIAL_MODE_OUTPUT_OPEN, &drvdata->filemode);
	clear_bit(SERIAL_MODE_OUTPUT_TRIGGERED, &drvdata->filemode);

	if (!drvdata->filemode)
		serdev_device_close(drvdata->serdev);

	drvdata->midi_output = NULL;

	return 0;
};

static void snd_serial_generic_output_trigger(struct snd_rawmidi_substream *substream,
					 int up)
{}

static void snd_serial_generic_output_drain(struct snd_rawmidi_substream *substream)
{}

static const struct snd_rawmidi_ops snd_serial_generic_output =;

static const struct snd_rawmidi_ops snd_serial_generic_input =;

static void snd_serial_generic_parse_dt(struct serdev_device *serdev,
				struct snd_serial_generic *drvdata)
{}

static void snd_serial_generic_substreams(struct snd_rawmidi_str *stream, int dev_num)
{}

static int snd_serial_generic_rmidi(struct snd_serial_generic *drvdata,
				int outs, int ins, struct snd_rawmidi **rmidi)
{}

static int snd_serial_generic_probe(struct serdev_device *serdev)
{}

static const struct of_device_id snd_serial_generic_dt_ids[] =;

MODULE_DEVICE_TABLE(of, snd_serial_generic_dt_ids);

static struct serdev_device_driver snd_serial_generic_driver =;

module_serdev_device_driver();