@@ -261,6 +261,8 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
261
261
int ret , i , cur , err , pins , clock_id ;
262
262
const u8 * sources ;
263
263
int proto = fmt -> protocol ;
264
+ bool readable , writeable ;
265
+ u32 bmControls ;
264
266
265
267
entity_id &= 0xff ;
266
268
@@ -292,11 +294,27 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
292
294
sources = GET_VAL (selector , proto , baCSourceID );
293
295
cur = 0 ;
294
296
297
+ if (proto == UAC_VERSION_3 )
298
+ bmControls = le32_to_cpu (* (__le32 * )(& selector -> v3 .baCSourceID [0 ] + pins ));
299
+ else
300
+ bmControls = * (__u8 * )(& selector -> v2 .baCSourceID [0 ] + pins );
301
+
302
+ readable = uac_v2v3_control_is_readable (bmControls ,
303
+ UAC2_CX_CLOCK_SELECTOR );
304
+ writeable = uac_v2v3_control_is_writeable (bmControls ,
305
+ UAC2_CX_CLOCK_SELECTOR );
306
+
295
307
if (pins == 1 ) {
296
308
ret = 1 ;
297
309
goto find_source ;
298
310
}
299
311
312
+ /* for now just warn about buggy device */
313
+ if (!readable )
314
+ usb_audio_warn (chip ,
315
+ "%s(): clock selector control is not readable, id %d\n" ,
316
+ __func__ , clock_id );
317
+
300
318
/* the entity ID we are looking at is a selector.
301
319
* find out what it currently selects */
302
320
ret = uac_clock_selector_get_val (chip , clock_id );
@@ -326,7 +344,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
326
344
if (ret > 0 ) {
327
345
/* Skip setting clock selector again for some devices */
328
346
if (chip -> quirk_flags & QUIRK_FLAG_SKIP_CLOCK_SELECTOR ||
329
- pins == 1 )
347
+ pins == 1 || ! writeable )
330
348
return ret ;
331
349
err = uac_clock_selector_set_val (chip , entity_id , cur );
332
350
if (err < 0 )
@@ -337,6 +355,9 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
337
355
return ret ;
338
356
339
357
find_others :
358
+ if (!writeable )
359
+ return - ENXIO ;
360
+
340
361
/* The current clock source is invalid, try others. */
341
362
for (i = 1 ; i <= pins ; i ++ ) {
342
363
if (i == cur )
0 commit comments