Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) OSS Sequencer Emulation on ALSA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) Copyright (c) 1998,1999 by Takashi Iwai
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) ver.0.1.8; Nov. 16, 1999
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) This directory contains the OSS sequencer emulation driver on ALSA. Note
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) that this program is still in the development state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) What this does - it provides the emulation of the OSS sequencer, access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) via ``/dev/sequencer`` and ``/dev/music`` devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) The most of applications using OSS can run if the appropriate ALSA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) sequencer is prepared.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) The following features are emulated by this driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) * Normal sequencer and MIDI events:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)     They are converted to the ALSA sequencer events, and sent to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)     corresponding port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) * Timer events:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)     The timer is not selectable by ioctl. The control rate is fixed to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)     100 regardless of HZ. That is, even on Alpha system, a tick is always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)     1/100 second. The base rate and tempo can be changed in ``/dev/music``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) * Patch loading:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)     It purely depends on the synth drivers whether it's supported since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)     the patch loading is realized by callback to the synth driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) * I/O controls:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)     Most of controls are accepted. Some controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)     are dependent on the synth driver, as well as even on original OSS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) Furthermore, you can find the following advanced features:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) * Better queue mechanism:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)     The events are queued before processing them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) * Multiple applications:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)     You can run two or more applications simultaneously (even for OSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)     sequencer)!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)     However, each MIDI device is exclusive - that is, if a MIDI device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)     is opened once by some application, other applications can't use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)     it. No such a restriction in synth devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) * Real-time event processing:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)     The events can be processed in real time without using out of bound
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)     ioctl. To switch to real-time mode, send ABSTIME 0 event. The followed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)     events will be processed in real-time without queued. To switch off the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)     real-time mode, send RELTIME 0 event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) * ``/proc`` interface:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)     The status of applications and devices can be shown via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)     ``/proc/asound/seq/oss`` at any time. In the later version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)     configuration will be changed via ``/proc`` interface, too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) Installation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) Run configure script with both sequencer support (``--with-sequencer=yes``)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) and OSS emulation (``--with-oss=yes``) options. A module ``snd-seq-oss.o``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) will be created. If the synth module of your sound card supports for OSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) emulation (so far, only Emu8000 driver), this module will be loaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) automatically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) Otherwise, you need to load this module manually.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) At beginning, this module probes all the MIDI ports which have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) already connected to the sequencer. Once after that, the creation and deletion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) of ports are watched by announcement mechanism of ALSA sequencer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) The available synth and MIDI devices can be found in proc interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) Run ``cat /proc/asound/seq/oss``, and check the devices. For example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) if you use an AWE64 card, you'll see like the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)     OSS sequencer emulation version 0.1.8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)     ALSA client number 63
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)     ALSA receiver port 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)     Number of applications: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)     Number of synth devices: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)     synth 0: [EMU8000]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)       type 0x1 : subtype 0x20 : voices 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)       capabilties : ioctl enabled / load_patch enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)     Number of MIDI devices: 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)     midi 0: [Emu8000 Port-0] ALSA port 65:0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)       capability write / opened none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)     midi 1: [Emu8000 Port-1] ALSA port 65:1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)       capability write / opened none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)     midi 2: [0: MPU-401 (UART)] ALSA port 64:0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)       capability read/write / opened none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) Note that the device number may be different from the information of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) ``/proc/asound/oss-devices`` or ones of the original OSS driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) Use the device number listed in ``/proc/asound/seq/oss``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) to play via OSS sequencer emulation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) Using Synthesizer Devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) =========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) Run your favorite program. I've tested playmidi-2.4, awemidi-0.4.3, gmod-3.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) and xmp-1.1.5. You can load samples via ``/dev/sequencer`` like sfxload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) If the lowlevel driver supports multiple access to synth devices (like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) Emu8000 driver), two or more applications are allowed to run at the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) Using MIDI Devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) So far, only MIDI output was tested. MIDI input was not checked at all,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) but hopefully it will work. Use the device number listed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) ``/proc/asound/seq/oss``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) Be aware that these numbers are mostly different from the list in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) ``/proc/asound/oss-devices``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) Module Options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) ==============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) The following module options are available:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) maxqlen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)   specifies the maximum read/write queue length. This queue is private
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)   for OSS sequencer, so that it is independent from the queue length of ALSA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)   sequencer. Default value is 1024.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) seq_oss_debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)   specifies the debug level and accepts zero (= no debug message) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)   positive integer. Default value is 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) Queue Mechanism
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) OSS sequencer emulation uses an ALSA priority queue. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) events from ``/dev/sequencer`` are processed and put onto the queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) specified by module option.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) All the events from ``/dev/sequencer`` are parsed at beginning.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) The timing events are also parsed at this moment, so that the events may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) be processed in real-time. Sending an event ABSTIME 0 switches the operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) mode to real-time mode, and sending an event RELTIME 0 switches it off.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) In the real-time mode, all events are dispatched immediately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) The queued events are dispatched to the corresponding ALSA sequencer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) ports after scheduled time by ALSA sequencer dispatcher.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) If the write-queue is full, the application sleeps until a certain amount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) (as default one half) becomes empty in blocking mode. The synchronization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) to write timing was implemented, too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) The input from MIDI devices or echo-back events are stored on read FIFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) queue. If application reads ``/dev/sequencer`` in blocking mode, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) process will be awaked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) Interface to Synthesizer Device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) Registration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) To register an OSS synthesizer device, use snd_seq_oss_synth_register()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) function:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)   int snd_seq_oss_synth_register(char *name, int type, int subtype, int nvoices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)           snd_seq_oss_callback_t *oper, void *private_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) The arguments ``name``, ``type``, ``subtype`` and ``nvoices``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) are used for making the appropriate synth_info structure for ioctl. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return value is an index number of this device. This index must be remembered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) for unregister. If registration is failed, -errno will be returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) To release this device, call snd_seq_oss_synth_unregister() function:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)   int snd_seq_oss_synth_unregister(int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) where the ``index`` is the index number returned by register function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) Callbacks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ---------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) OSS synthesizer devices have capability for sample downloading and ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) like sample reset. In OSS emulation, these special features are realized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) by using callbacks. The registration argument oper is used to specify these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) callbacks. The following callback functions must be defined:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)   snd_seq_oss_callback_t:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)    int (*open)(snd_seq_oss_arg_t *p, void *closure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)    int (*close)(snd_seq_oss_arg_t *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)    int (*ioctl)(snd_seq_oss_arg_t *p, unsigned int cmd, unsigned long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)    int (*load_patch)(snd_seq_oss_arg_t *p, int format, const char *buf, int offs, int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)    int (*reset)(snd_seq_oss_arg_t *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) Except for ``open`` and ``close`` callbacks, they are allowed to be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) Each callback function takes the argument type ``snd_seq_oss_arg_t`` as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) first argument.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)   struct snd_seq_oss_arg_t {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)       int app_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)       int file_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)       int seq_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)       snd_seq_addr_t addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)       void *private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)       int event_passing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)   };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) The first three fields, ``app_index``, ``file_mode`` and ``seq_mode``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) are initialized by OSS sequencer. The ``app_index`` is the application
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) index which is unique to each application opening OSS sequencer. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) ``file_mode`` is bit-flags indicating the file operation mode. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) ``seq_oss.h`` for its meaning. The ``seq_mode`` is sequencer operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) mode. In the current version, only ``SND_OSSSEQ_MODE_SYNTH`` is used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) The next two fields, ``addr`` and ``private_data``, must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) filled by the synth driver at open callback. The ``addr`` contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) the address of ALSA sequencer port which is assigned to this device. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) the driver allocates memory for ``private_data``, it must be released
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) in close callback by itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) The last field, ``event_passing``, indicates how to translate note-on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) / off events. In ``PROCESS_EVENTS`` mode, the note 255 is regarded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) as velocity change, and key pressure event is passed to the port. In
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) ``PASS_EVENTS`` mode, all note on/off events are passed to the port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) without modified. ``PROCESS_KEYPRESS`` mode checks the note above 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) and regards it as key pressure event (mainly for Emu8000 driver).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) Open Callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) -------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) The ``open`` is called at each time this device is opened by an application
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) using OSS sequencer. This must not be NULL. Typically, the open callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) does the following procedure:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) #. Allocate private data record.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #. Create an ALSA sequencer port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) #. Set the new port address on ``arg->addr``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) #. Set the private data record pointer on ``arg->private_data``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) Note that the type bit-flags in port_info of this synth port must NOT contain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) ``TYPE_MIDI_GENERIC``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) bit. Instead, ``TYPE_SPECIFIC`` should be used. Also, ``CAP_SUBSCRIPTION``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) bit should NOT be included, too. This is necessary to tell it from other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) normal MIDI devices. If the open procedure succeeded, return zero. Otherwise,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) return -errno.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) Ioctl Callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) The ``ioctl`` callback is called when the sequencer receives device-specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) ioctls. The following two ioctls should be processed by this callback:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) IOCTL_SEQ_RESET_SAMPLES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)     reset all samples on memory -- return 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) IOCTL_SYNTH_MEMAVL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)     return the available memory size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) FM_4OP_ENABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)     can be ignored usually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) The other ioctls are processed inside the sequencer without passing to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) the lowlevel driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) Load_Patch Callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) The ``load_patch`` callback is used for sample-downloading. This callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) must read the data on user-space and transfer to each device. Return 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) if succeeded, and -errno if failed. The format argument is the patch key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) in patch_info record. The buf is user-space pointer where patch_info record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) is stored. The offs can be ignored. The count is total data size of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) sample data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) Close Callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) The ``close`` callback is called when this device is closed by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) application. If any private data was allocated in open callback, it must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) be released in the close callback. The deletion of ALSA port should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) done here, too. This callback must not be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) Reset Callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) The ``reset`` callback is called when sequencer device is reset or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) closed by applications. The callback should turn off the sounds on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) relevant port immediately, and initialize the status of the port. If this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) callback is undefined, OSS seq sends a ``HEARTBEAT`` event to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) port.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) Events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) ======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) Most of the events are processed by sequencer and translated to the adequate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) ALSA sequencer events, so that each synth device can receive by input_event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) callback of ALSA sequencer port. The following ALSA events should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) implemented by the driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) =============	===================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) ALSA event	Original OSS events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) =============	===================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) NOTEON		SEQ_NOTEON, MIDI_NOTEON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) NOTE		SEQ_NOTEOFF, MIDI_NOTEOFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) KEYPRESS	MIDI_KEY_PRESSURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) CHANPRESS	SEQ_AFTERTOUCH, MIDI_CHN_PRESSURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) PGMCHANGE	SEQ_PGMCHANGE, MIDI_PGM_CHANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) PITCHBEND	SEQ_CONTROLLER(CTRL_PITCH_BENDER),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		MIDI_PITCH_BEND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) CONTROLLER	MIDI_CTL_CHANGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		SEQ_BALANCE (with CTL_PAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) CONTROL14	SEQ_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) REGPARAM	SEQ_CONTROLLER(CTRL_PITCH_BENDER_RANGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) SYSEX		SEQ_SYSEX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) =============	===================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) The most of these behavior can be realized by MIDI emulation driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) included in the Emu8000 lowlevel driver. In the future release, this module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) will be independent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) Some OSS events (``SEQ_PRIVATE`` and ``SEQ_VOLUME`` events) are passed as event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) type SND_SEQ_OSS_PRIVATE.  The OSS sequencer passes these event 8 byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) packets without any modification. The lowlevel driver should process these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) events appropriately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) Interface to MIDI Device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) ========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) Since the OSS emulation probes the creation and deletion of ALSA MIDI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) sequencer ports automatically by receiving announcement from ALSA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) sequencer, the MIDI devices don't need to be registered explicitly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) like synth devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) However, the MIDI port_info registered to ALSA sequencer must include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) a group name ``SND_SEQ_GROUP_DEVICE`` and a capability-bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) ``CAP_READ`` or ``CAP_WRITE``. Also, subscription capabilities,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) ``CAP_SUBS_READ`` or ``CAP_SUBS_WRITE``, must be defined, too. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) these conditions are not satisfied, the port is not registered as OSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) sequencer MIDI device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) The events via MIDI devices are parsed in OSS sequencer and converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) to the corresponding ALSA sequencer events. The input from MIDI sequencer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) is also converted to MIDI byte events by OSS sequencer. This works just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) a reverse way of seq_midi module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) Known Problems / TODO's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * Patch loading via ALSA instrument layer is not implemented yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)