Skip to content

Commit aa21c3d

Browse files
committed
Merge branch 'for-next' into for-linus
2 parents 476c02e + 652bb5d commit aa21c3d

Some content is hidden

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

52 files changed

+1160
-386
lines changed

Documentation/sound/alsa-configuration.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,19 @@ use_vmalloc
22342234
buffers. If mmap is used on such architectures, turn off this
22352235
option, so that the DMA-coherent buffers are allocated and used
22362236
instead.
2237+
delayed_register
2238+
The option is needed for devices that have multiple streams
2239+
defined in multiple USB interfaces. The driver may invoke
2240+
registrations multiple times (once per interface) and this may
2241+
lead to the insufficient device enumeration.
2242+
This option receives an array of strings, and you can pass
2243+
ID:INTERFACE like ``0123abcd:4`` for performing the delayed
2244+
registration to the given device. In this example, when a USB
2245+
device 0123:abcd is probed, the driver waits the registration
2246+
until the USB interface 4 gets probed.
2247+
The driver prints a message like "Found post-registration device
2248+
assignment: 1234abcd:04" for such a device, so that user can
2249+
notice the need.
22372250

22382251
This module supports multiple devices, autoprobe and hotplugging.
22392252

include/linux/usb/audio-v2.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ struct uac2_feature_unit_descriptor {
156156
__u8 bmaControls[0]; /* variable length */
157157
} __attribute__((packed));
158158

159+
/* 4.7.2.10 Effect Unit Descriptor */
160+
161+
struct uac2_effect_unit_descriptor {
162+
__u8 bLength;
163+
__u8 bDescriptorType;
164+
__u8 bDescriptorSubtype;
165+
__u8 bUnitID;
166+
__le16 wEffectType;
167+
__u8 bSourceID;
168+
__u8 bmaControls[]; /* variable length */
169+
} __attribute__((packed));
170+
159171
/* 4.9.2 Class-Specific AS Interface Descriptor */
160172

161173
struct uac2_as_header_descriptor {

include/sound/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ void snd_device_disconnect(struct snd_card *card, void *device_data);
266266
void snd_device_disconnect_all(struct snd_card *card);
267267
void snd_device_free(struct snd_card *card, void *device_data);
268268
void snd_device_free_all(struct snd_card *card);
269+
int snd_device_get_state(struct snd_card *card, void *device_data);
269270

270271
/* isadma.c */
271272

include/sound/pcm.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,15 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
14151415
return 1ULL << (__force int) pcm_format;
14161416
}
14171417

1418+
/**
1419+
* pcm_for_each_format - helper to iterate for each format type
1420+
* @f: the iterator variable in snd_pcm_format_t type
1421+
*/
1422+
#define pcm_for_each_format(f) \
1423+
for ((f) = SNDRV_PCM_FORMAT_FIRST; \
1424+
(__force int)(f) <= (__force int)SNDRV_PCM_FORMAT_LAST; \
1425+
(f) = (__force snd_pcm_format_t)((__force int)(f) + 1))
1426+
14181427
/* printk helpers */
14191428
#define pcm_err(pcm, fmt, args...) \
14201429
dev_err((pcm)->card->dev, fmt, ##args)

include/sound/pcm_params.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ static inline int snd_mask_test(const struct snd_mask *mask, unsigned int val)
133133
return mask->bits[MASK_OFS(val)] & MASK_BIT(val);
134134
}
135135

136+
/* Most of drivers need only this one */
137+
static inline int snd_mask_test_format(const struct snd_mask *mask,
138+
snd_pcm_format_t format)
139+
{
140+
return snd_mask_test(mask, (__force unsigned int)format);
141+
}
142+
136143
static inline int snd_mask_single(const struct snd_mask *mask)
137144
{
138145
int i, c = 0;

sound/core/device.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,24 @@ void snd_device_free_all(struct snd_card *card)
237237
list_for_each_entry_safe_reverse(dev, next, &card->devices, list)
238238
__snd_device_free(dev);
239239
}
240+
241+
/**
242+
* snd_device_get_state - Get the current state of the given device
243+
* @card: the card instance
244+
* @device_data: the data pointer to release
245+
*
246+
* Returns the current state of the given device object. For the valid
247+
* device, either @SNDRV_DEV_BUILD, @SNDRV_DEV_REGISTERED or
248+
* @SNDRV_DEV_DISCONNECTED is returned.
249+
* Or for a non-existing device, -1 is returned as an error.
250+
*/
251+
int snd_device_get_state(struct snd_card *card, void *device_data)
252+
{
253+
struct snd_device *dev;
254+
255+
dev = look_for_dev(card, device_data);
256+
if (dev)
257+
return dev->state;
258+
return -1;
259+
}
260+
EXPORT_SYMBOL_GPL(snd_device_get_state);

sound/core/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ int snd_info_card_free(struct snd_card *card)
604604
*/
605605
int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len)
606606
{
607-
int c = -1;
607+
int c;
608608

609609
if (snd_BUG_ON(!buffer || !buffer->buffer))
610610
return 1;

sound/core/oss/pcm_oss.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -884,20 +884,17 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
884884
sformat = snd_pcm_plug_slave_format(format, sformat_mask);
885885

886886
if ((__force int)sformat < 0 ||
887-
!snd_mask_test(sformat_mask, (__force int)sformat)) {
888-
for (sformat = (__force snd_pcm_format_t)0;
889-
(__force int)sformat <= (__force int)SNDRV_PCM_FORMAT_LAST;
890-
sformat = (__force snd_pcm_format_t)((__force int)sformat + 1)) {
891-
if (snd_mask_test(sformat_mask, (__force int)sformat) &&
887+
!snd_mask_test_format(sformat_mask, sformat)) {
888+
pcm_for_each_format(sformat) {
889+
if (snd_mask_test_format(sformat_mask, sformat) &&
892890
snd_pcm_oss_format_to(sformat) >= 0)
893-
break;
894-
}
895-
if ((__force int)sformat > (__force int)SNDRV_PCM_FORMAT_LAST) {
896-
pcm_dbg(substream->pcm, "Cannot find a format!!!\n");
897-
err = -EINVAL;
898-
goto failure;
891+
goto format_found;
899892
}
893+
pcm_dbg(substream->pcm, "Cannot find a format!!!\n");
894+
err = -EINVAL;
895+
goto failure;
900896
}
897+
format_found:
901898
err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, (__force int)sformat, 0);
902899
if (err < 0)
903900
goto failure;
@@ -1220,8 +1217,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
12201217
if (ret < 0)
12211218
break;
12221219
}
1220+
mutex_unlock(&runtime->oss.params_lock);
12231221
ret = __snd_pcm_lib_xfer(substream, (void *)ptr, true,
12241222
frames, in_kernel);
1223+
mutex_lock(&runtime->oss.params_lock);
12251224
if (ret != -EPIPE && ret != -ESTRPIPE)
12261225
break;
12271226
/* test, if we can't store new data, because the stream */
@@ -1257,8 +1256,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
12571256
ret = snd_pcm_oss_capture_position_fixup(substream, &delay);
12581257
if (ret < 0)
12591258
break;
1259+
mutex_unlock(&runtime->oss.params_lock);
12601260
ret = __snd_pcm_lib_xfer(substream, (void *)ptr, true,
12611261
frames, in_kernel);
1262+
mutex_lock(&runtime->oss.params_lock);
12621263
if (ret == -EPIPE) {
12631264
if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
12641265
ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);

sound/core/oss/pcm_plugin.c

Lines changed: 56 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -196,82 +196,74 @@ int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin)
196196
return 0;
197197
}
198198

199-
snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_pcm_uframes_t drv_frames)
199+
static snd_pcm_sframes_t calc_dst_frames(struct snd_pcm_substream *plug,
200+
snd_pcm_sframes_t frames)
200201
{
201-
struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;
202-
int stream;
202+
struct snd_pcm_plugin *plugin, *plugin_next;
203203

204-
if (snd_BUG_ON(!plug))
205-
return -ENXIO;
206-
if (drv_frames == 0)
207-
return 0;
208-
stream = snd_pcm_plug_stream(plug);
209-
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
210-
plugin = snd_pcm_plug_last(plug);
211-
while (plugin && drv_frames > 0) {
212-
if (drv_frames > plugin->buf_frames)
213-
drv_frames = plugin->buf_frames;
214-
plugin_prev = plugin->prev;
215-
if (plugin->src_frames)
216-
drv_frames = plugin->src_frames(plugin, drv_frames);
217-
plugin = plugin_prev;
204+
plugin = snd_pcm_plug_first(plug);
205+
while (plugin && frames > 0) {
206+
plugin_next = plugin->next;
207+
if (plugin->dst_frames) {
208+
frames = plugin->dst_frames(plugin, frames);
209+
if (frames < 0)
210+
return frames;
218211
}
219-
} else if (stream == SNDRV_PCM_STREAM_CAPTURE) {
220-
plugin = snd_pcm_plug_first(plug);
221-
while (plugin && drv_frames > 0) {
222-
plugin_next = plugin->next;
223-
if (plugin->dst_frames)
224-
drv_frames = plugin->dst_frames(plugin, drv_frames);
225-
if (drv_frames > plugin->buf_frames)
226-
drv_frames = plugin->buf_frames;
227-
plugin = plugin_next;
212+
if (frames > plugin->buf_frames)
213+
frames = plugin->buf_frames;
214+
plugin = plugin_next;
215+
}
216+
return frames;
217+
}
218+
219+
static snd_pcm_sframes_t calc_src_frames(struct snd_pcm_substream *plug,
220+
snd_pcm_sframes_t frames)
221+
{
222+
struct snd_pcm_plugin *plugin, *plugin_prev;
223+
224+
plugin = snd_pcm_plug_last(plug);
225+
while (plugin && frames > 0) {
226+
if (frames > plugin->buf_frames)
227+
frames = plugin->buf_frames;
228+
plugin_prev = plugin->prev;
229+
if (plugin->src_frames) {
230+
frames = plugin->src_frames(plugin, frames);
231+
if (frames < 0)
232+
return frames;
228233
}
229-
} else
234+
plugin = plugin_prev;
235+
}
236+
return frames;
237+
}
238+
239+
snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_pcm_uframes_t drv_frames)
240+
{
241+
if (snd_BUG_ON(!plug))
242+
return -ENXIO;
243+
switch (snd_pcm_plug_stream(plug)) {
244+
case SNDRV_PCM_STREAM_PLAYBACK:
245+
return calc_src_frames(plug, drv_frames);
246+
case SNDRV_PCM_STREAM_CAPTURE:
247+
return calc_dst_frames(plug, drv_frames);
248+
default:
230249
snd_BUG();
231-
return drv_frames;
250+
return -EINVAL;
251+
}
232252
}
233253

234254
snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pcm_uframes_t clt_frames)
235255
{
236-
struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;
237-
snd_pcm_sframes_t frames;
238-
int stream;
239-
240256
if (snd_BUG_ON(!plug))
241257
return -ENXIO;
242-
if (clt_frames == 0)
243-
return 0;
244-
frames = clt_frames;
245-
stream = snd_pcm_plug_stream(plug);
246-
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
247-
plugin = snd_pcm_plug_first(plug);
248-
while (plugin && frames > 0) {
249-
plugin_next = plugin->next;
250-
if (plugin->dst_frames) {
251-
frames = plugin->dst_frames(plugin, frames);
252-
if (frames < 0)
253-
return frames;
254-
}
255-
if (frames > plugin->buf_frames)
256-
frames = plugin->buf_frames;
257-
plugin = plugin_next;
258-
}
259-
} else if (stream == SNDRV_PCM_STREAM_CAPTURE) {
260-
plugin = snd_pcm_plug_last(plug);
261-
while (plugin) {
262-
if (frames > plugin->buf_frames)
263-
frames = plugin->buf_frames;
264-
plugin_prev = plugin->prev;
265-
if (plugin->src_frames) {
266-
frames = plugin->src_frames(plugin, frames);
267-
if (frames < 0)
268-
return frames;
269-
}
270-
plugin = plugin_prev;
271-
}
272-
} else
258+
switch (snd_pcm_plug_stream(plug)) {
259+
case SNDRV_PCM_STREAM_PLAYBACK:
260+
return calc_dst_frames(plug, clt_frames);
261+
case SNDRV_PCM_STREAM_CAPTURE:
262+
return calc_src_frames(plug, clt_frames);
263+
default:
273264
snd_BUG();
274-
return frames;
265+
return -EINVAL;
266+
}
275267
}
276268

277269
static int snd_pcm_plug_formats(const struct snd_mask *mask,

sound/core/oss/rate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct rate_priv {
4747
unsigned int pos;
4848
rate_f func;
4949
snd_pcm_sframes_t old_src_frames, old_dst_frames;
50-
struct rate_channel channels[0];
50+
struct rate_channel channels[];
5151
};
5252

5353
static void rate_init(struct snd_pcm_plugin *plugin)

0 commit comments

Comments
 (0)