Skip to content

Commit c1a521f

Browse files
committed
Merge remote-tracking branch 'takashi/for-next' into sound/upstream-20250114
2 parents c3a4a69 + 3ab4a31 commit c1a521f

44 files changed

Lines changed: 418 additions & 263 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/sound/designs/midi-2.0.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,17 @@ Rawmidi API Extensions
293293
status 0x05). When UMP core receives such a message, it updates the
294294
UMP EP info and the corresponding sequencer clients as well.
295295

296+
* The legacy rawmidi device number is found in the new `tied_device`
297+
field of the rawmidi info.
298+
On the other hand, the UMP rawmidi device number is found in
299+
`tied_device` field of the legacy rawmidi info, too.
300+
301+
* Each substream of the legacy rawmidi may be enabled / disabled
302+
dynamically depending on the UMP FB state.
303+
When the selected substream is inactive, it's indicated by the bit
304+
0x10 (`SNDRV_RAWMIDI_INFO_STREAM_INACTIVE`) in the `flags` field of
305+
the legacy rawmidi info.
306+
296307

297308
Control API Extensions
298309
======================
@@ -377,6 +388,13 @@ Sequencer API Extensions
377388
announcement to the ALSA sequencer system port, similarly like the
378389
normal port change notification.
379390

391+
* There are two extended event types for notifying the UMP Endpoint and
392+
Function Block changes via the system announcement port:
393+
type 68 (`SNDRV_SEQ_EVENT_UMP_EP_CHANGE`) and type 69
394+
(`SNDRV_SEQ_EVENT_UMP_BLOCK_CHANGE`). They take the new type,
395+
`snd_seq_ev_ump_notify` in the payload, indicating the client number
396+
and the FB number that are changed.
397+
380398

381399
MIDI2 USB Gadget Function Driver
382400
================================

include/sound/hdaudio_ext.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#ifndef __SOUND_HDAUDIO_EXT_H
33
#define __SOUND_HDAUDIO_EXT_H
44

5-
#include <linux/io-64-nonatomic-lo-hi.h>
6-
#include <linux/iopoll.h>
75
#include <sound/hdaudio.h>
86

97
int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev,
@@ -119,49 +117,6 @@ int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *hlink)
119117

120118
void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable);
121119

122-
#define snd_hdac_adsp_writeb(chip, reg, value) \
123-
snd_hdac_reg_writeb(chip, (chip)->dsp_ba + (reg), value)
124-
#define snd_hdac_adsp_readb(chip, reg) \
125-
snd_hdac_reg_readb(chip, (chip)->dsp_ba + (reg))
126-
#define snd_hdac_adsp_writew(chip, reg, value) \
127-
snd_hdac_reg_writew(chip, (chip)->dsp_ba + (reg), value)
128-
#define snd_hdac_adsp_readw(chip, reg) \
129-
snd_hdac_reg_readw(chip, (chip)->dsp_ba + (reg))
130-
#define snd_hdac_adsp_writel(chip, reg, value) \
131-
snd_hdac_reg_writel(chip, (chip)->dsp_ba + (reg), value)
132-
#define snd_hdac_adsp_readl(chip, reg) \
133-
snd_hdac_reg_readl(chip, (chip)->dsp_ba + (reg))
134-
#define snd_hdac_adsp_writeq(chip, reg, value) \
135-
snd_hdac_reg_writeq(chip, (chip)->dsp_ba + (reg), value)
136-
#define snd_hdac_adsp_readq(chip, reg) \
137-
snd_hdac_reg_readq(chip, (chip)->dsp_ba + (reg))
138-
139-
#define snd_hdac_adsp_updateb(chip, reg, mask, val) \
140-
snd_hdac_adsp_writeb(chip, reg, \
141-
(snd_hdac_adsp_readb(chip, reg) & ~(mask)) | (val))
142-
#define snd_hdac_adsp_updatew(chip, reg, mask, val) \
143-
snd_hdac_adsp_writew(chip, reg, \
144-
(snd_hdac_adsp_readw(chip, reg) & ~(mask)) | (val))
145-
#define snd_hdac_adsp_updatel(chip, reg, mask, val) \
146-
snd_hdac_adsp_writel(chip, reg, \
147-
(snd_hdac_adsp_readl(chip, reg) & ~(mask)) | (val))
148-
#define snd_hdac_adsp_updateq(chip, reg, mask, val) \
149-
snd_hdac_adsp_writeq(chip, reg, \
150-
(snd_hdac_adsp_readq(chip, reg) & ~(mask)) | (val))
151-
152-
#define snd_hdac_adsp_readb_poll(chip, reg, val, cond, delay_us, timeout_us) \
153-
readb_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
154-
delay_us, timeout_us)
155-
#define snd_hdac_adsp_readw_poll(chip, reg, val, cond, delay_us, timeout_us) \
156-
readw_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
157-
delay_us, timeout_us)
158-
#define snd_hdac_adsp_readl_poll(chip, reg, val, cond, delay_us, timeout_us) \
159-
readl_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
160-
delay_us, timeout_us)
161-
#define snd_hdac_adsp_readq_poll(chip, reg, val, cond, delay_us, timeout_us) \
162-
readq_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
163-
delay_us, timeout_us)
164-
165120
struct hdac_ext_device;
166121

167122
/* ops common to all codec drivers */

include/sound/pcm.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,9 +1532,10 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
15321532
dev_dbg((pcm)->card->dev, fmt, ##args)
15331533

15341534
/* helpers for copying between iov_iter and iomem */
1535-
int copy_to_iter_fromio(struct iov_iter *itert, const void __iomem *src,
1536-
size_t count);
1537-
int copy_from_iter_toio(void __iomem *dst, struct iov_iter *iter, size_t count);
1535+
size_t copy_to_iter_fromio(const void __iomem *src, size_t bytes,
1536+
struct iov_iter *iter) __must_check;
1537+
size_t copy_from_iter_toio(void __iomem *dst, size_t bytes,
1538+
struct iov_iter *iter) __must_check;
15381539

15391540
struct snd_pcm_status64 {
15401541
snd_pcm_state_t state; /* stream state */

include/sound/rawmidi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct snd_rawmidi_substream {
8989
unsigned int framing; /* whether to frame input data */
9090
unsigned int clock_type; /* clock source to use for input framing */
9191
int use_count; /* use counter (for output) */
92+
bool inactive; /* inactive substream (for UMP legacy) */
9293
size_t bytes;
9394
spinlock_t lock;
9495
struct snd_rawmidi *rmidi;
@@ -118,6 +119,7 @@ struct snd_rawmidi {
118119
struct list_head list;
119120
unsigned int device; /* device number */
120121
unsigned int info_flags; /* SNDRV_RAWMIDI_INFO_XXXX */
122+
unsigned int tied_device;
121123
char id[64];
122124
char name[80];
123125

include/sound/ump.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct snd_ump_ops {
8383
struct snd_seq_ump_ops {
8484
void (*input_receive)(struct snd_ump_endpoint *ump,
8585
const u32 *data, int words);
86+
int (*notify_ep_change)(struct snd_ump_endpoint *ump);
8687
int (*notify_fb_change)(struct snd_ump_endpoint *ump,
8788
struct snd_ump_block *fb);
8889
int (*switch_protocol)(struct snd_ump_endpoint *ump);

include/uapi/sound/asequencer.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <sound/asound.h>
1111

1212
/** version of the sequencer */
13-
#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 4)
13+
#define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 5)
1414

1515
/**
1616
* definition of sequencer event types
@@ -92,6 +92,9 @@
9292
#define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED 66 /* ports connected */
9393
#define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67 /* ports disconnected */
9494

95+
#define SNDRV_SEQ_EVENT_UMP_EP_CHANGE 68 /* UMP EP info has changed */
96+
#define SNDRV_SEQ_EVENT_UMP_BLOCK_CHANGE 69 /* UMP block info has changed */
97+
9598
/* 70-89: synthesizer events - obsoleted */
9699

97100
/** user-defined events with fixed length
@@ -253,6 +256,12 @@ struct snd_seq_ev_quote {
253256
struct snd_seq_event *event; /* quoted event */
254257
} __packed;
255258

259+
/* UMP info change notify */
260+
struct snd_seq_ev_ump_notify {
261+
unsigned char client; /**< Client number */
262+
unsigned char block; /**< Block number (optional) */
263+
};
264+
256265
union snd_seq_event_data { /* event data... */
257266
struct snd_seq_ev_note note;
258267
struct snd_seq_ev_ctrl control;
@@ -265,6 +274,7 @@ union snd_seq_event_data { /* event data... */
265274
struct snd_seq_connect connect;
266275
struct snd_seq_result result;
267276
struct snd_seq_ev_quote quote;
277+
struct snd_seq_ev_ump_notify ump_notify;
268278
};
269279

270280
/* sequencer event */

include/uapi/sound/asound.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ enum {
716716
* Raw MIDI section - /dev/snd/midi??
717717
*/
718718

719-
#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 4)
719+
#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 5)
720720

721721
enum {
722722
SNDRV_RAWMIDI_STREAM_OUTPUT = 0,
@@ -728,6 +728,9 @@ enum {
728728
#define SNDRV_RAWMIDI_INFO_INPUT 0x00000002
729729
#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004
730730
#define SNDRV_RAWMIDI_INFO_UMP 0x00000008
731+
#define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010
732+
733+
#define SNDRV_RAWMIDI_DEVICE_UNKNOWN -1
731734

732735
struct snd_rawmidi_info {
733736
unsigned int device; /* RO/WR (control): device number */
@@ -740,7 +743,8 @@ struct snd_rawmidi_info {
740743
unsigned char subname[32]; /* name of active or selected subdevice */
741744
unsigned int subdevices_count;
742745
unsigned int subdevices_avail;
743-
unsigned char reserved[64]; /* reserved for future use */
746+
int tied_device; /* R: tied rawmidi device (UMP/legacy) */
747+
unsigned char reserved[60]; /* reserved for future use */
744748
};
745749

746750
#define SNDRV_RAWMIDI_MODE_FRAMING_MASK (7<<0)

sound/core/memory.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,43 @@ int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size
2727

2828
if (import_ubuf(ITER_DEST, dst, count, &iter))
2929
return -EFAULT;
30-
return copy_to_iter_fromio(&iter, (const void __iomem *)src, count);
30+
if (copy_to_iter_fromio((const void __iomem *)src, count, &iter) != count)
31+
return -EFAULT;
32+
return 0;
3133
}
3234
EXPORT_SYMBOL(copy_to_user_fromio);
3335

3436
/**
3537
* copy_to_iter_fromio - copy data from mmio-space to iov_iter
36-
* @dst: the destination iov_iter
3738
* @src: the source pointer on mmio
3839
* @count: the data size to copy in bytes
40+
* @dst: the destination iov_iter
3941
*
4042
* Copies the data from mmio-space to iov_iter.
4143
*
42-
* Return: Zero if successful, or non-zero on failure.
44+
* Return: number of bytes to be copied
4345
*/
44-
int copy_to_iter_fromio(struct iov_iter *dst, const void __iomem *src,
45-
size_t count)
46+
size_t copy_to_iter_fromio(const void __iomem *src, size_t count,
47+
struct iov_iter *dst)
4648
{
4749
#if defined(__i386__) || defined(CONFIG_SPARC32)
48-
return copy_to_iter((const void __force *)src, count, dst) == count ? 0 : -EFAULT;
50+
return copy_to_iter((const void __force *)src, count, dst);
4951
#else
5052
char buf[256];
53+
size_t res = 0;
54+
5155
while (count) {
5256
size_t c = count;
5357
if (c > sizeof(buf))
5458
c = sizeof(buf);
5559
memcpy_fromio(buf, (void __iomem *)src, c);
5660
if (copy_to_iter(buf, c, dst) != c)
57-
return -EFAULT;
61+
return res;
5862
count -= c;
5963
src += c;
64+
res += c;
6065
}
61-
return 0;
66+
return res;
6267
#endif
6368
}
6469
EXPORT_SYMBOL(copy_to_iter_fromio);
@@ -79,37 +84,43 @@ int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size
7984

8085
if (import_ubuf(ITER_SOURCE, (void __user *)src, count, &iter))
8186
return -EFAULT;
82-
return copy_from_iter_toio((void __iomem *)dst, &iter, count);
87+
if (copy_from_iter_toio((void __iomem *)dst, count, &iter) != count)
88+
return -EFAULT;
89+
return 0;
8390
}
8491
EXPORT_SYMBOL(copy_from_user_toio);
8592

8693
/**
8794
* copy_from_iter_toio - copy data from iov_iter to mmio-space
8895
* @dst: the destination pointer on mmio-space
89-
* @src: the source iov_iter
9096
* @count: the data size to copy in bytes
97+
* @src: the source iov_iter
9198
*
9299
* Copies the data from iov_iter to mmio-space.
93100
*
94-
* Return: Zero if successful, or non-zero on failure.
101+
* Return: number of bytes to be copied
95102
*/
96-
int copy_from_iter_toio(void __iomem *dst, struct iov_iter *src, size_t count)
103+
size_t copy_from_iter_toio(void __iomem *dst, size_t count,
104+
struct iov_iter *src)
97105
{
98106
#if defined(__i386__) || defined(CONFIG_SPARC32)
99-
return copy_from_iter((void __force *)dst, count, src) == count ? 0 : -EFAULT;
107+
return copy_from_iter((void __force *)dst, count, src);
100108
#else
101109
char buf[256];
110+
size_t res = 0;
111+
102112
while (count) {
103113
size_t c = count;
104114
if (c > sizeof(buf))
105115
c = sizeof(buf);
106116
if (copy_from_iter(buf, c, src) != c)
107-
return -EFAULT;
117+
return res;
108118
memcpy_toio(dst, buf, c);
109119
count -= c;
110120
dst += c;
121+
res += c;
111122
}
112-
return 0;
123+
return res;
113124
#endif
114125
}
115126
EXPORT_SYMBOL(copy_from_iter_toio);

sound/core/rawmidi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,12 +629,15 @@ static int snd_rawmidi_info(struct snd_rawmidi_substream *substream,
629629
info->subdevice = substream->number;
630630
info->stream = substream->stream;
631631
info->flags = rmidi->info_flags;
632+
if (substream->inactive)
633+
info->flags |= SNDRV_RAWMIDI_INFO_STREAM_INACTIVE;
632634
strcpy(info->id, rmidi->id);
633635
strcpy(info->name, rmidi->name);
634636
strcpy(info->subname, substream->name);
635637
info->subdevices_count = substream->pstr->substream_count;
636638
info->subdevices_avail = (substream->pstr->substream_count -
637639
substream->pstr->substream_opened);
640+
info->tied_device = rmidi->tied_device;
638641
return 0;
639642
}
640643

@@ -1834,6 +1837,7 @@ int snd_rawmidi_init(struct snd_rawmidi *rmidi,
18341837
INIT_LIST_HEAD(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams);
18351838
INIT_LIST_HEAD(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams);
18361839
rmidi->info_flags = info_flags;
1840+
rmidi->tied_device = SNDRV_RAWMIDI_DEVICE_UNKNOWN;
18371841

18381842
if (id != NULL)
18391843
strscpy(rmidi->id, id, sizeof(rmidi->id));

sound/core/seq/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ config SND_SEQ_VIRMIDI
6262

6363
config SND_SEQ_UMP
6464
bool "Support for UMP events"
65-
default y if SND_SEQ_UMP_CLIENT
65+
default SND_UMP
6666
help
6767
Say Y here to enable the support for handling UMP (Universal MIDI
6868
Packet) events via ALSA sequencer infrastructure, which is an
@@ -71,6 +71,6 @@ config SND_SEQ_UMP
7171
among legacy and UMP clients.
7272

7373
config SND_SEQ_UMP_CLIENT
74-
def_tristate SND_UMP
74+
def_tristate SND_UMP && SND_SEQ_UMP
7575

7676
endif # SND_SEQUENCER

0 commit comments

Comments
 (0)