Zephyr API Documentation 4.5.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ump_stream_responder.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Titouan Christophe
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#ifndef ZEPHYR_LIB_MIDI2_UMP_STREAM_RESPONDER_H_
7#define ZEPHYR_LIB_MIDI2_UMP_STREAM_RESPONDER_H_
8
18
19#include <zephyr/kernel.h>
20#include <zephyr/audio/midi.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
49
55 const char *name;
57 size_t n_blocks;
60};
61
65typedef void (*ump_send_func)(const void *, const struct midi_ump);
66
73#define UMP_STREAM_RESPONDER(_dev, _send, _ep_spec) \
74 { \
75 .dev = _dev, \
76 .send = (ump_send_func) _send, \
77 .ep_spec = _ep_spec, \
78 }
79
91
97#define UMP_BLOCK_DT_SPEC_GET(_node) \
98{ \
99 .name = DT_PROP_OR(_node, label, NULL), \
100 .first_group = DT_REG_ADDR(_node), \
101 .groups_spanned = DT_REG_SIZE(_node), \
102 .is_input = !DT_ENUM_HAS_VALUE(_node, terminal_type, output_only), \
103 .is_output = !DT_ENUM_HAS_VALUE(_node, terminal_type, input_only), \
104 .is_midi1 = !DT_ENUM_HAS_VALUE(_node, protocol, midi2), \
105 .is_31250bps = DT_PROP(_node, serial_31250bps), \
106}
107
108#define UMP_BLOCK_SEP_IF_OKAY(_node) \
109 COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(_node), \
110 (UMP_BLOCK_DT_SPEC_GET(_node),), \
111 ())
112
118#define UMP_ENDPOINT_DT_SPEC_GET(_node) \
119{ \
120 .name = DT_PROP_OR(_node, label, NULL), \
121 .n_blocks = DT_FOREACH_CHILD_SEP(_node, DT_NODE_HAS_STATUS_OKAY, (+)), \
122 .blocks = {DT_FOREACH_CHILD(_node, UMP_BLOCK_SEP_IF_OKAY)}, \
123}
124
132int ump_stream_respond(const struct ump_stream_responder_cfg *cfg,
133 const struct midi_ump pkt);
134
139const char *ump_product_instance_id(void);
140
142
143#ifdef __cplusplus
144}
145#endif
146
147#endif
const char * ump_product_instance_id(void)
Definition ump_stream_responder.c:235
void(* ump_send_func)(const void *, const struct midi_ump)
A function to send a UMP.
Definition ump_stream_responder.h:65
int ump_stream_respond(const struct ump_stream_responder_cfg *cfg, const struct midi_ump pkt)
Respond to an UMP Stream message.
Definition ump_stream_responder.c:265
Public kernel APIs.
Header file for MIDI 2.0 Universal MIDI Packet (UMP) definitions.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Universal MIDI Packet container.
Definition midi.h:47
UMP Function Block specification.
Definition ump_stream_responder.h:30
const char * name
Name of this function block, or NULL if unnamed.
Definition ump_stream_responder.h:32
bool is_midi1
True if this function block carries MIDI1 data only.
Definition ump_stream_responder.h:42
bool is_input
True if this function block is an input.
Definition ump_stream_responder.h:38
uint8_t first_group
Number of the first UMP group in this block.
Definition ump_stream_responder.h:34
bool is_output
True if this function block is an output.
Definition ump_stream_responder.h:40
bool is_31250bps
True if this function block is physically wired to a (MIDI1) serial interface, where data is transmit...
Definition ump_stream_responder.h:47
uint8_t groups_spanned
Number of (contiguous) UMP groups spanned by this block.
Definition ump_stream_responder.h:36
UMP endpoint specification.
Definition ump_stream_responder.h:53
size_t n_blocks
Number of function blocks in this endpoint.
Definition ump_stream_responder.h:57
struct ump_block_dt_spec blocks[]
Function blocks in this endpoint.
Definition ump_stream_responder.h:59
const char * name
Name of this endpoint, or NULL if unnamed.
Definition ump_stream_responder.h:55
Configuration for the UMP Stream responder.
Definition ump_stream_responder.h:83
const void * dev
The device to send reply packets.
Definition ump_stream_responder.h:85
ump_send_func send
The function to call to send a reply packet.
Definition ump_stream_responder.h:87
const struct ump_endpoint_dt_spec * ep_spec
The UMP endpoint specification.
Definition ump_stream_responder.h:89