Skip to contentSkip to conversation

Add generic serial MIDI driver using serial bus API

PATCH Superseded Daniel Kaehn 2 participants 9 messages Apr 25, 2022 – Apr 28, 2022

Subsystems (3)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add generic serial MIDI driver using serial bus API

Generic serial MIDI driver adding support for using serial devices compatible with the serial bus as raw MIDI devices, allowing using additional serial devices not compatible with the existing serial-u16550 driver. Supports only setting standard serial baudrates on the underlying serial device; however, the underlying serial device can be configured so that a requested 38.4 kBaud is actually the standard MIDI 31.25 kBaud. Supports DeviceTree configuration.

Changes in v4:
- Fix regressed typo - Correct 3.84 kBaud -> 38.4 kBaud in DT & Kconfig (sorry about spam - noticed after sending v3 and didn't want to let the error sit around for too long)

Changes in v3:
- Replace use of snd_printk() with dev_* alternatives
- Removed unnecessary initialization of err variables
- Replaced instances of == SERIAL_MODE_NOT_OPENED with zero check
- Loop on output_write to completely fill output buffer if data available
- Depend on CONFIG_OF in Kconfig
- Replace use of devm_kzalloc() with extra_size allocation in snd_devm_card_new()
- Use module_serdev_device_driver() instead of module_init() and module_exit(0)

Changes in v2:
- Fix 'snd_serial_generic_write_wakeup' missing static keyword
- Correct 3.125 kBaud > 31.25 kBaud in documentation for MIDI

The need for this driver arose from a project using a Raspberry Pi4 which needed to receive and send raw MIDI with low latency. The pl011 UART used is not compatible with the existing serial MIDI driver made for u16550-style devices. Using a userspace program such as ttymidi to feed input from the TTY device to a virtual ALSA MIDI device was functional, but not ideal.

I am not sure if a MIDI driver needing the mentioned 'hack' to clock 38.4 kBaud down to the standard MIDI baud is permissible in the mainline kernel, but am submitting nevertheless in case it is useful. To my knowledge, it doesn't seem that there would be any way for this driver to manually configure a serial port to 31.25 kBaud using the serial bus API (please correct me f I'm wrong). In my use case, I am actually configuring one port to run at 115.2 kBaud for faster communication with a custom onboard MIDI controller.

Daniel Kaehn (2):
dt-bindings: sound: Add generic serial MIDI device Add generic serial MIDI driver using serial bus API

 .../devicetree/bindings/sound/serialmidi.yaml |  41 +++
 sound/drivers/Kconfig                         |  18 +
 sound/drivers/Makefile                        |   2 +
 sound/drivers/serial-generic.c                | 319 ++++++++++++++++++
 4 files changed, 380 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/serialmidi.yaml
 create mode 100644 sound/drivers/serial-generic.c

base-commit: d615b5416f8a1afeb82d13b238f8152c572d59c0

Signature · 1 line
2.33.0
#1 lore raw

PATCH v4 1/2 dt-bindings: sound: Add generic serial MIDI device

Adds dt-binding for snd-serial-generic serial MIDI driver

---
 .../devicetree/bindings/sound/serialmidi.yaml | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/serialmidi.yaml
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +41 -0
new file mode 100644
index 000000000000..38ef49a0c2f9
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/serialmidi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic Serial MIDI Device
+
+maintainers:
+  - Daniel Kaehn <[email protected]>
+
+description: |
+  Generic MIDI interface using a serial device. Can only be set to use standard speeds
+  corresponding to supported baud rates of the underlying serial device. If standard MIDI
+  speed of 31.25 kBaud is needed, configure the clocks of the underlying serial device
+  so that a requested speed of 38.4 kBaud resuts in the standard MIDI baud rate.
+
+properties:
+  compatible:
+    const: serialmidi
+
+  speed:
+    maxItems: 1
+    description: |
+      Speed to set the serial port to when the MIDI device is opened.
+      If not specified, the underlying serial device is allowed to use its configured default speed.
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    serial {
+        midi {
+            compatible = "serialmidi";
+            speed = <38400>;
+        };
+    };
Signature · 1 line
2.33.0
#8 lore raw

PATCH v4 2/2 Add generic serial MIDI driver using serial bus API

In reply to Daniel Kaehn

Generic serial MIDI driver adding support for using serial devices compatible with the serial bus as raw MIDI devices, allowing using additional serial devices not compatible with the existing serial-u16550 driver. Supports only setting standard serial baudrates on the underlying serial device; however, the underlying serial device can be configured so that a requested 38.4 kBaud is actually the standard MIDI 31.25 kBaud. Supports DeviceTree configuration.

---
 sound/drivers/Kconfig          |  18 ++
 sound/drivers/Makefile         |   2 +
 sound/drivers/serial-generic.c | 319 +++++++++++++++++++++++++++++++++
 3 files changed, 339 insertions(+)
 create mode 100644 sound/drivers/serial-generic.c
sound/drivers/Kconfig +18 -0
index ca4cdf666f82..060e7d3f2439 100644
@@ -165,6 +165,24 @@ config SND_SERIAL_U16550
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-serial-u16550.
 
+config SND_SERIAL_GENERIC
+	tristate "Generic serial MIDI driver"
+	depends on SERIAL_DEV_BUS
+	depends on OF
+	select SND_RAWMIDI
+	help
+	  To include support for mapping generic serial devices as raw
+	  ALSA MIDI devices, say Y here. The driver only supports setting
+	  the serial port to standard baudrates. To attain the standard MIDI
+	  baudrate of 31.25 kBaud, configure the clock of the underlying serial
+	  device so that a requested 38.4 kBaud will result in the standard speed.
+
+	  Use this devicetree binding to configure serial port mapping
+	  <file:Documentation/devicetree/bindings/sound/serialmidi.yaml>
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-serial-generic.
+
 config SND_MPU401
 	tristate "Generic MPU-401 UART driver"
 	select SND_MPU401_UART
sound/drivers/Makefile +2 -0
index c0fe4eccdaef..b60303180a1b 100644
@@ -10,6 +10,7 @@ snd-mtpav-objs := mtpav.o
 snd-mts64-objs := mts64.o
 snd-portman2x4-objs := portman2x4.o
 snd-serial-u16550-objs := serial-u16550.o
+snd-serial-generic-objs := serial-generic.o
 snd-virmidi-objs := virmidi.o
 
 # Toplevel Module Dependency
@@ -17,6 +18,7 @@ obj-$(CONFIG_SND_DUMMY) += snd-dummy.o
 obj-$(CONFIG_SND_ALOOP) += snd-aloop.o
 obj-$(CONFIG_SND_VIRMIDI) += snd-virmidi.o
 obj-$(CONFIG_SND_SERIAL_U16550) += snd-serial-u16550.o
+obj-$(CONFIG_SND_SERIAL_GENERIC) += snd-serial-generic.o
 obj-$(CONFIG_SND_MTPAV) += snd-mtpav.o
 obj-$(CONFIG_SND_MTS64) += snd-mts64.o
 obj-$(CONFIG_SND_PORTMAN2X4) += snd-portman2x4.o
sound/drivers/serial-generic.c new file +319 -0

319 lines not on this page · raw message

Signature · 1 line
2.33.0
maintainer
#2 lore raw

Re: [PATCH v4 1/2] dt-bindings: sound: Add generic serial MIDI device

In reply to Daniel Kaehn
Quoted 1 line · Daniel Kaehn

Adds dt-binding for snd-serial-generic serial MIDI driver

Bindings are for h/w and there's no such thing as generic h/w. There are some exceptions but you'll have to justify why this is special.

Quoted 15 lines
---
 .../devicetree/bindings/sound/serialmidi.yaml | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/serialmidi.yaml
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +3 -0
new file mode 100644
index 000000000000..38ef49a0c2f9
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+
+%YAML 1.2

Documentation/devicetree/bindings/sound/serialmidi.yaml line 13

Quoted 10 lines
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +10 -0
+---
+$id: http://devicetree.org/schemas/sound/serialmidi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic Serial MIDI Device
+
+maintainers:
+  - Daniel Kaehn <[email protected]>
+
+description: |

Don't need '|' unless there is formatting to preserve.

Documentation/devicetree/bindings/sound/serialmidi.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +10 -0
+  Generic MIDI interface using a serial device. Can only be set to use standard speeds
+  corresponding to supported baud rates of the underlying serial device. If standard MIDI
+  speed of 31.25 kBaud is needed, configure the clocks of the underlying serial device
+  so that a requested speed of 38.4 kBaud resuts in the standard MIDI baud rate.
+
+properties:
+  compatible:
+    const: serialmidi
+
+  speed:

Not a standard property and we already have 2 of them concerning baud rate.

Quoted 22 lines
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +18 -0
+    maxItems: 1
+    description: |
+      Speed to set the serial port to when the MIDI device is opened.
+      If not specified, the underlying serial device is allowed to use its configured default speed.
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    serial {
+        midi {
+            compatible = "serialmidi";
+            speed = <38400>;
+        };
+    };
Signature · 1 line
2.33.0
author
#3 lore raw

Re: [PATCH v4 1/2] dt-bindings: sound: Add generic serial MIDI device

Quoted 7 lines · Rob Herring
Quoted 1 line · Daniel Kaehn

Adds dt-binding for snd-serial-generic serial MIDI driver

Bindings are for h/w and there's no such thing as generic h/w. There are some exceptions but you'll have to justify why this is special.

Thanks for taking the time to look at this!

Not entirely sure if you mean that I'll need to justify the existence / need for this binding,
or the use of the term 'generic' -- just in case, I'll make sure to respond to both. Note that
I'm justifying my reasoning for submitting the binding - but I'm uncertain myself if my reasoning
is valid, as someone new to kernel development.

The intent of this binding is to signify that a serial port (namely a UART) is connected
in hardware to a MIDI decoupling circuit, which then connects to some (any) sort of MIDI device,
either directly to an on-board device, or via a jack/connector. In a sense, the MIDI device that this
connects to is 'generic', as the identity of the device does not need to be known to interface with it
over MIDI for most use cases.

I see how this is a bit of an oddball, since it's not specifically describing a particular hardware
device attached to a UART (like some of the bluetooth modules are), but thought this sort of
binding might be permissible because of things like the gpio-matrix-keypad binding, which doesn't
describe specific switches, just how thoise switches are wired, and what GPIO they use, which is all
that is needed to interface with them. Some MIDI devices implement extra low-level features like device
multiplexing, but these aren't (to my knowledge) common, and are beyond what this supports.

The reason that the corresponding driver written has the name 'generic' is for an entirely
different reason. A "serial MIDI" driver already exists in the kernel, however, it interfaces only with
u16550-compatible UARTs. This driver uses the serial bus, making it work with 'generic' serial devices.

If this comment was directed toward the use of 'generic' in the commit message and binding
descriptions: I can reword them to be more specific and to avoid the term.

Quoted 20 lines
Quoted 20 lines
---
 .../devicetree/bindings/sound/serialmidi.yaml | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/serialmidi.yaml
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +7 -0
new file mode 100644
index 000000000000..38ef49a0c2f9
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/serialmidi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
Quoted 9 lines

Documentation/devicetree/bindings/sound/serialmidi.yaml line 13

Quoted 6 lines
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +6 -0
+title: Generic Serial MIDI Device
+
+maintainers:
+  - Daniel Kaehn <[email protected]>
+
+description: |

Don't need '|' unless there is formatting to preserve.

Will fix.

Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +5 -0
+  Generic MIDI interface using a serial device. Can only be set to use standard speeds
+  corresponding to supported baud rates of the underlying serial device. If standard MIDI
+  speed of 31.25 kBaud is needed, configure the clocks of the underlying serial device
+  so that a requested speed of 38.4 kBaud resuts in the standard MIDI baud rate.
+
Quoted 9 lines

Documentation/devicetree/bindings/sound/serialmidi.yaml line 23

Quoted 5 lines
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +5 -0
+properties:
+  compatible:
+    const: serialmidi
+
+  speed:

Not a standard property and we already have 2 of them concerning baud rate.

Thanks for the correction - I'll switch this to the existing "baud" property.

I somehow missed that there was a fixed list of standard properties to be used, and just chose 'speed' as opposed to 'current-speed' which I saw on serial bindings,
since this speed is fixed and can't (and shouldn't need to be) changed. "baud" describes
this well enough.

Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +14 -0
+    maxItems: 1
+    description: |
+      Speed to set the serial port to when the MIDI device is opened.
+      If not specified, the underlying serial device is allowed to use its configured default speed.
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    serial {
+        midi {
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/sound/serialmidi.yaml new file +4 -1
+            compatible = "serialmidi";
+            speed = <38400>;
+        };
+    };
--

2.33.0

Thanks,

Daneil Kaehn

maintainer
#4 lore raw

Re: [PATCH v4 1/2] dt-bindings: sound: Add generic serial MIDI device

Quoted 11 lines · Dan K
Quoted 7 lines · Rob Herring
Quoted 1 line · Daniel Kaehn

Adds dt-binding for snd-serial-generic serial MIDI driver

Bindings are for h/w and there's no such thing as generic h/w. There are some exceptions but you'll have to justify why this is special.

Thanks for taking the time to look at this!

Quoted 7 lines

Not entirely sure if you mean that I'll need to justify the existence / need for this binding,
or the use of the term 'generic' -- just in case, I'll make sure to respond to both. Note that
I'm justifying my reasoning for submitting the binding - but I'm uncertain myself if my reasoning
is valid, as someone new to kernel development.

'Generic' is really just a red flag.

We've had generic or simple bindings before. The result tends to be a never ending stream of new properties to deal with every new variation in devices. These can be quirks for device behavior, timing for power control, etc.

Quoted 9 lines

The intent of this binding is to signify that a serial port (namely a UART) is connected
in hardware to a MIDI decoupling circuit, which then connects to some (any) sort of MIDI device,
either directly to an on-board device, or via a jack/connector. In a sense, the MIDI device that this
connects to is 'generic', as the identity of the device does not need to be known to interface with it
over MIDI for most use cases.

Okay, maybe it is appropriate. The key part is 'most use cases'. What about ones that don't fit into 'most'? It's possible to do both (generic binding and device specific bindings), but we need to define when generic bindings are appropriate or not.

Do devices ever need power controls or other sideband interfaces? Regulators, resets, clocks? If so, you need to describe the specific device.

Is a jack/connector in any way standard and have signals other than UART (or whatever is the other side of the MIDI decoupling circuit)? We have bindings for standard connectors.

I don't really know anything about what this h/w looks like, so any pointers or examples would help.

Quoted 3 lines

I see how this is a bit of an oddball, since it's not specifically describing a particular hardware
device attached to a UART (like some of the bluetooth modules are),

To follow that comparison, all/most BT modules use a standard/generic protocol over the serial port. But we don't have compatibles aligned to the protocol because the devices are more than just a serial protocol. They have GPIOs, regulators, clocks, etc. Furthermore, the serial protocols themselves can have extensions and/or quirks.

Quoted 9 lines

but thought this sort of
binding might be permissible because of things like the gpio-matrix-keypad binding, which doesn't
describe specific switches, just how thoise switches are wired, and what GPIO they use, which is all
that is needed to interface with them. Some MIDI devices implement extra low-level features like device
multiplexing, but these aren't (to my knowledge) common, and are beyond what this supports.

At some point devices become simple enough to model generically.

Quoted 6 lines

The reason that the corresponding driver written has the name 'generic' is for an entirely
different reason. A "serial MIDI" driver already exists in the kernel, however, it interfaces only with
u16550-compatible UARTs. This driver uses the serial bus, making it work with 'generic' serial devices.

Bindings are separate from the kernel (though they live in the same repository for convenience). A 'generic' binding often appears with a 'generic' driver. You can have specific bindings with a generic driver. The difference with doing that is the OS can evolve without changing the binding (an ABI). Maybe initially you use a generic driver until there's extra/custom features of the device you want to support with a custom driver.

Rob

author
#5 lore raw

Re: [PATCH v4 1/2] dt-bindings: sound: Add generic serial MIDI device

Thanks for taking the time for a thorough reply!

Quoted 8 lines · Rob Herring

'Generic' is really just a red flag.

We've had generic or simple bindings before. The result tends to be a never ending stream of new properties to deal with every new variation in devices. These can be quirks for device behavior, timing for power control, etc.

Makes sense, I see why that's a concern. I think it's probably unlikely that would happen here (for reasons described below).

Quoted 6 lines

Okay, maybe it is appropriate. The key part is 'most use cases'. What about ones that don't fit into 'most'? It's possible to do both (generic binding and device specific bindings), but we need to define when generic bindings are appropriate or not.

Sorry about the vague language.

In many/most cases, a raw/serial MIDI device is an independent external device, and its connection to another MIDI device would be transient and through an external cable. Usually, this is a device that a user plugs in at runtime, such as a MIDI keyboard (/piano) that simply sends and receives bytes using the MIDI protocol, and its identity isn't known at the time of devicetree compilation (and doesn't need to be known).

This binding is only describing that a serial port is dedicated to MIDI, and the only hardware it describes is the circuitry and electrical connections needed to connect to a MIDI device (likely through a jack). This covers almost all of the use cases for (serial) MIDI (MIDI is now also often done over USB / network, in case you aren't familiar). As you can probably imagine from its use of DT in general - this is targeted toward embedded devices, allowing an off-the-shelf SOC in an audio product to interface with an external raw MIDI device.

The only exceptions to 'most use cases' I'm aware of are with some antiquated MIDI interface devices that connect to an RS232 port and have multiple output ports (selectable via a special MIDI message), enabling someone to connect multiple MIDI devices to a PC simultaneously. I only discovered that these exist because of the existing serial MIDI driver in the kernel, and some research reveals that few devices like these (with multiplexed I/O) exist. This is also probably well outside of the use case for an embedded device.

Quoted 8 lines

Do devices ever need power controls or other sideband interfaces? Regulators, resets, clocks? If so, you need to describe the specific device.

Is a jack/connector in any way standard and have signals other than UART (or whatever is the other side of the MIDI decoupling circuit)? We have bindings for standard connectors.

The standard connector is a DIN5 connector, but only two signal pins are used, for RX and TX. No sideband interfaces are used - the MIDI device connected is typically a completely independent system. Neither device for MIDI will power the other (except for USB MIDI). Really the only parameter possible for just the serial MIDI interface itself is the baudrate - which is fixed to 31.25k in the standard, but a device could feasibly be connected to an onboard / non-transient custom MIDI controller with a different baudrate (my use case contains this, as well as the earlier use case for an external MIDI device).

Quoted 3 lines

I don't really know anything about what this h/w looks like, so any pointers or examples would help.

I hope the above helps to clarify.

Quoted 10 lines
Quoted 3 lines

I see how this is a bit of an oddball, since it's not specifically describing a particular hardware
device attached to a UART (like some of the bluetooth modules are),

To follow that comparison, all/most BT modules use a standard/generic protocol over the serial port. But we don't have compatibles aligned to the protocol because the devices are more than just a serial protocol. They have GPIOs, regulators, clocks, etc. Furthermore, the serial protocols themselves can have extensions and/or quirks.

I think I would contend that for MIDI, the 'device' this binding describes more or less is just the serial protocol (and hardware to support the transmission). Any specific handling of special functions of a device would be done in userspace.

Quoted 10 lines

At some point devices become simple enough to model generically.

Quoted 6 lines

The reason that the corresponding driver written has the name 'generic' is for an entirely
different reason. A "serial MIDI" driver already exists in the kernel, however, it interfaces only with
u16550-compatible UARTs. This driver uses the serial bus, making it work with 'generic' serial devices.

Quoted 8 lines

Bindings are separate from the kernel (though they live in the same repository for convenience). A 'generic' binding often appears with a 'generic' driver. You can have specific bindings with a generic driver. The difference with doing that is the OS can evolve without changing the binding (an ABI). Maybe initially you use a generic driver until there's extra/custom features of the device you want to support with a custom driver.

I've seen that sort of 'specific binding - > generic driver' model before - but I think you'll agree that since the nature of the external device is typically transient, the generic binding -> generic driver is probably what would make sense here.

Thanks,
Daniel Kaehn

maintainer
#6 lore raw

Re: [PATCH v4 1/2] dt-bindings: sound: Add generic serial MIDI device

Quoted 111 lines · Dan K

Thanks for taking the time for a thorough reply!

Quoted 8 lines · Rob Herring

'Generic' is really just a red flag.

We've had generic or simple bindings before. The result tends to be a never ending stream of new properties to deal with every new variation in devices. These can be quirks for device behavior, timing for power control, etc.

Makes sense, I see why that's a concern. I think it's probably unlikely that would happen here (for reasons described below).

Quoted 6 lines

Okay, maybe it is appropriate. The key part is 'most use cases'. What about ones that don't fit into 'most'? It's possible to do both (generic binding and device specific bindings), but we need to define when generic bindings are appropriate or not.

Sorry about the vague language.

In many/most cases, a raw/serial MIDI device is an independent external device, and its connection to another MIDI device would be transient and through an external cable. Usually, this is a device that a user plugs in at runtime, such as a MIDI keyboard (/piano) that simply sends and receives bytes using the MIDI protocol, and its identity isn't known at the time of devicetree compilation (and doesn't need to be known).

This binding is only describing that a serial port is dedicated to MIDI, and the only hardware it describes is the circuitry and electrical connections needed to connect to a MIDI device (likely through a jack). This covers almost all of the use cases for (serial) MIDI (MIDI is now also often done over USB / network, in case you aren't familiar). As you can probably imagine from its use of DT in general - this is targeted toward embedded devices, allowing an off-the-shelf SOC in an audio product to interface with an external raw MIDI device.

The only exceptions to 'most use cases' I'm aware of are with some antiquated MIDI interface devices that connect to an RS232 port and have multiple output ports (selectable via a special MIDI message), enabling someone to connect multiple MIDI devices to a PC simultaneously. I only discovered that these exist because of the existing serial MIDI driver in the kernel, and some research reveals that few devices like these (with multiplexed I/O) exist. This is also probably well outside of the use case for an embedded device.

Quoted 8 lines

Do devices ever need power controls or other sideband interfaces? Regulators, resets, clocks? If so, you need to describe the specific device.

Is a jack/connector in any way standard and have signals other than UART (or whatever is the other side of the MIDI decoupling circuit)? We have bindings for standard connectors.

The standard connector is a DIN5 connector, but only two signal pins are used, for RX and TX. No sideband interfaces are used - the MIDI device connected is typically a completely independent system. Neither device for MIDI will power the other (except for USB MIDI). Really the only parameter possible for just the serial MIDI interface itself is the baudrate - which is fixed to 31.25k in the standard, but a device could feasibly be connected to an onboard / non-transient custom MIDI controller with a different baudrate (my use case contains this, as well as the earlier use case for an external MIDI device).

Quoted 3 lines

I don't really know anything about what this h/w looks like, so any pointers or examples would help.

I hope the above helps to clarify.

Quoted 10 lines
Quoted 3 lines

I see how this is a bit of an oddball, since it's not specifically describing a particular hardware
device attached to a UART (like some of the bluetooth modules are),

To follow that comparison, all/most BT modules use a standard/generic protocol over the serial port. But we don't have compatibles aligned to the protocol because the devices are more than just a serial protocol. They have GPIOs, regulators, clocks, etc. Furthermore, the serial protocols themselves can have extensions and/or quirks.

I think I would contend that for MIDI, the 'device' this binding describes more or less is just the serial protocol (and hardware to support the transmission). Any specific handling of special functions of a device would be done in userspace.

Quoted 10 lines

At some point devices become simple enough to model generically.

Quoted 6 lines

The reason that the corresponding driver written has the name 'generic' is for an entirely
different reason. A "serial MIDI" driver already exists in the kernel, however, it interfaces only with
u16550-compatible UARTs. This driver uses the serial bus, making it work with 'generic' serial devices.

Quoted 8 lines

Bindings are separate from the kernel (though they live in the same repository for convenience). A 'generic' binding often appears with a 'generic' driver. You can have specific bindings with a generic driver. The difference with doing that is the OS can evolve without changing the binding (an ABI). Maybe initially you use a generic driver until there's extra/custom features of the device you want to support with a custom driver.

Quoted 4 lines

I've seen that sort of 'specific binding - > generic driver' model before - but I think you'll agree that since the nature of the external device is typically transient, the generic binding -> generic driver is probably what would make sense here.

Thanks for the all the details and I do agree. Can you add some description of the h/w from above into the binding description.

Rob

author
#7 lore raw

Re: [PATCH v4 1/2] dt-bindings: sound: Add generic serial MIDI device

Will do, thanks.

Daniel Kaehn