Zephyr API Documentation 4.2.99
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
45
51 const char *name;
53 size_t n_blocks;
56};
57
61typedef void (*ump_send_func)(const void *, const struct midi_ump);
62
69#define UMP_STREAM_RESPONDER(_dev, _send, _ep_spec) \
70 { \
71 .dev = _dev, \
72 .send = (ump_send_func) _send, \
73 .ep_spec = _ep_spec, \
74 }
75
87
93#define UMP_BLOCK_DT_SPEC_GET(_node) \
94{ \
95 .name = DT_PROP_OR(_node, label, NULL), \
96 .first_group = DT_REG_ADDR(_node), \
97 .groups_spanned = DT_REG_SIZE(_node), \
98 .is_input = !DT_ENUM_HAS_VALUE(_node, terminal_type, output_only), \
99 .is_output = !DT_ENUM_HAS_VALUE(_node, terminal_type, input_only), \
100 .is_midi1 = !DT_ENUM_HAS_VALUE(_node, protocol, midi2), \
101 .is_31250bps = DT_PROP(_node, serial_31250bps), \
102}
103
104#define UMP_BLOCK_SEP_IF_OKAY(_node) \
105 COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(_node), \
106 (UMP_BLOCK_DT_SPEC_GET(_node),), \
107 ())
108
114#define UMP_ENDPOINT_DT_SPEC_GET(_node) \
115{ \
116 .name = DT_PROP_OR(_node, label, NULL), \
117 .n_blocks = DT_FOREACH_CHILD_SEP(_node, DT_NODE_HAS_STATUS_OKAY, (+)), \
118 .blocks = {DT_FOREACH_CHILD(_node, UMP_BLOCK_SEP_IF_OKAY)}, \
119}
120
128int ump_stream_respond(const struct ump_stream_responder_cfg *cfg,
129 const struct midi_ump pkt);
130
135const char *ump_product_instance_id(void);
136
138
139#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:61
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.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Universal MIDI Packet container.
Definition midi.h:41
UMP Function Block specification.
Definition ump_stream_responder.h:26
const char * name
Name of this function block, or NULL if unnamed.
Definition ump_stream_responder.h:28
bool is_midi1
True if this function block carries MIDI1 data only.
Definition ump_stream_responder.h:38
bool is_input
True if this function block is an input.
Definition ump_stream_responder.h:34
uint8_t first_group
Number of the first UMP group in this block.
Definition ump_stream_responder.h:30
bool is_output
True if this function block is an output.
Definition ump_stream_responder.h:36
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:43
uint8_t groups_spanned
Number of (contiguous) UMP groups spanned by this block.
Definition ump_stream_responder.h:32
UMP endpoint specification.
Definition ump_stream_responder.h:49
size_t n_blocks
Number of function blocks in this endpoint.
Definition ump_stream_responder.h:53
struct ump_block_dt_spec blocks[]
Function blocks in this endpoint.
Definition ump_stream_responder.h:55
const char * name
Name of this endpoint, or NULL if unnamed.
Definition ump_stream_responder.h:51
Configuration for the UMP Stream responder.
Definition ump_stream_responder.h:79
const void * dev
The device to send reply packets.
Definition ump_stream_responder.h:81
ump_send_func send
The function to call to send a reply packet.
Definition ump_stream_responder.h:83
const struct ump_endpoint_dt_spec * ep_spec
The UMP endpoint specification.
Definition ump_stream_responder.h:85