^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright 10/16/2005 Tilman Kranz <tilde@tk-sls.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Creative Audio MIDI, for the CA0106 Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Version: 0.0.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Changelog:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * See ca_midi.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <sound/rawmidi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <sound/mpu401.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define CA_MIDI_MODE_INPUT MPU401_MODE_INPUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define CA_MIDI_MODE_OUTPUT MPU401_MODE_OUTPUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct snd_ca_midi {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct snd_rawmidi *rmidi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct snd_rawmidi_substream *substream_input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct snd_rawmidi_substream *substream_output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) void *dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) spinlock_t input_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) spinlock_t output_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) spinlock_t open_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned int channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) unsigned int midi_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int tx_enable, rx_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) int ipr_tx, ipr_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int input_avail, output_ready;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int ack, reset, enter_uart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) void (*interrupt)(struct snd_ca_midi *midi, unsigned int status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) void (*interrupt_enable)(struct snd_ca_midi *midi, int intr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) void (*interrupt_disable)(struct snd_ca_midi *midi, int intr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned char (*read)(struct snd_ca_midi *midi, int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) void (*write)(struct snd_ca_midi *midi, int data, int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* get info from dev_id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct snd_card *(*get_dev_id_card)(void *dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int (*get_dev_id_port)(void *dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int ca_midi_init(void *card, struct snd_ca_midi *midi, int device, char *name);