Lines Matching +full:activate +full:- +full:to +full:- +full:activate
1 // SPDX-License-Identifier: GPL-2.0
8 * - 6i6/18i8/18i20 Gen 2
9 * - Solo/2i2/4i4/8i6/18i8/18i20 Gen 3
10 * - Solo/2i2/4i4 Gen 4
11 * - Clarett 2Pre/4Pre/8Pre USB
12 * - Clarett+ 2Pre/4Pre/8Pre
14 * Copyright (c) 2018-2023 by Geoffrey D. Bennett <g at b4.vu>
15 * Copyright (c) 2020-2021 by Vladimir Sadovnikov <sadko4u@gmail.com>
35 * (firmware 1083) using usbmon in July-August 2018.
39 * Scarlett 6i6 support added in June 2019 (thanks to Martin Wittmann
42 * Scarlett 4i4/8i6 Gen 3 support added in May 2020 (thanks to Laurent
43 * Debricon for donating a 4i4 and to Fredrik Unger for providing 8i6
46 * Scarlett 18i8/18i20 Gen 3 support added in June 2020 (thanks to
51 * interface during driver initialisation added in May 2021 (thanks to
54 * Support for Solo/2i2 Gen 3 added in May 2021 (thanks to Alexander
58 * and talkback added in May-June 2021.
63 * Support for Clarett 8Pre USB added in Sep 2023 (thanks to Philippe
66 * Support for Clarett+ 4Pre and 2Pre added in Sep 2023 (thanks to
75 * to many LinuxMusicians people and to Focusrite for hardware
78 * This ALSA mixer gives access to (model-dependent):
79 * - input, output, mixer-matrix muxes
80 * - mixer-matrix gain stages
81 * - gain/volume/mute controls
82 * - level meters
83 * - line/inst level, pad, and air controls
84 * - phantom power, direct monitor, speaker switching, and talkback
86 * - disable/enable MSD mode
87 * - disable/enable standalone mode
88 * - input mute, gain, autogain, safe mode
89 * - direct monitor mixes
90 * - compressor and EQ
91 * - Bluetooth volume
94 * /--------------\ 18chn 20chn /--------------\
95 * | Hardware in +--+------\ /-------------+--+ ALSA PCM out |
96 * \--------------/ | | | | \--------------/
97 * | | | /-----\ |
100 * | +---------------+ | |
102 * | +-----+-----+ | |
108 * | +------------+ | |
114 * | +-----+------+ | |
118 * | +----------/ |
122 * +---------------+ +--—------------+
124 * +---+---+---+ +-----+-----+
128 * /--------------\ | | | /--------------\
129 * | S/PDIF, ADAT |<--/ |10chn \-->| ALSA PCM in |
130 * | Hardware out | | \--------------/
131 * \--------------/ |
133 * +-------------+ Software gain per channel.
134 * | Master Gain |<-- 18i20 only: Switch per channel
135 * +------+------+ to select HW or SW gain control.
138 * /--------------\ |
139 * | Analogue |<------/
141 * \--------------/
146 * to the host. To access the full functionality of the device without
148 * - holding down the 48V button for five seconds while powering on
150 * - using this driver and alsamixer to change the "MSD Mode" setting
151 * to Off and power-cycling the device
170 /* device_setup value to allow turning MSD mode back on */
173 /* device_setup value to disable this mixer driver */
180 * (the corresponding value in dB is per-device)
187 /* mixer range from -80dB to +12dB in 0.5dB steps */
188 #define SCARLETT2_MIXER_MIN_DB -80
189 #define SCARLETT2_MIXER_BIAS (-SCARLETT2_MIXER_MIN_DB * 2)
192 ((SCARLETT2_MIXER_MAX_DB - SCARLETT2_MIXER_MIN_DB) * 2)
195 /* map from (dB + 80) * 2 to mixer value
196 * for dB in 0 .. 184: int(8192 * pow(10, ((dB - 160) / 2 / 20)))
228 /* Maximum number of inputs to the mixer */
257 * The compressor parameters are 32-bit fixed point values with 24
270 * - Enable: Off, On
271 * - Threshold: -40dB to 0dB
272 * - Ratio: 1:1 to 50:1 in 0.5:1 steps
273 * - Knee Width: 0dB to 10dB
274 * - Attack: 30ms to 127ms
275 * - Release: 30ms to 127ms
276 * - Makeup Gain: 0dB to 24dB
280 { "Threshold", SNDRV_CTL_ELEM_TYPE_INTEGER, -40, 0, 24 },
309 * - None (no input to mux)
310 * - Analogue I/O
311 * - S/PDIF I/O
312 * - ADAT I/O
313 * - Mixer I/O
314 * - PCM I/O
342 #define SCARLETT2_AG_TARGET_MIN (-30)
366 * If autogain_switch is set, autogain_status is set to 0 (Running).
564 * Vocaster and 4th Gen devices have a parameter buffer to set certain
565 * configuration parameters. When pbuf is set, rather than writing to
566 * the given offset, the channel and value are written to the
567 * parameter buffer and the activate command is sent to the device.
571 * mute set to 1. 0x02 and 0x03 are temporary values while the device
578 u8 activate; member
607 .offset = 0x34, .size = 16, .activate = 1 },
610 .offset = 0x5c, .size = 8, .activate = 1 },
613 .offset = 0x7c, .size = 8, .activate = 7 },
616 .offset = 0x84, .size = 8, .activate = 8 },
619 .offset = 0x8d, .size = 8, .activate = 6 },
629 .offset = 0x31, .size = 8, .activate = 2 },
632 .offset = 0x34, .size = 16, .activate = 1 },
635 .offset = 0x5c, .size = 8, .activate = 1 },
638 .offset = 0x66, .size = 8, .activate = 3 },
644 .offset = 0x7c, .size = 8, .activate = 7 },
647 .offset = 0x84, .size = 8, .activate = 8 },
650 .offset = 0x8d, .size = 8, .activate = 6 },
659 .offset = 0x04, .size = 8, .activate = 6 },
662 .offset = 0x05, .size = 8, .activate = 6 },
665 .offset = 0x06, .size = 8, .activate = 3 },
668 .offset = 0x07, .size = 8, .activate = 4 },
671 .offset = 0x08, .size = 1, .activate = 7 },
674 .offset = 0x09, .size = 1, .activate = 8 },
683 .offset = 0x34, .size = 16, .activate = 1 },
686 .offset = 0x5c, .size = 8, .activate = 1 },
689 .offset = 0x7c, .size = 8, .activate = 7 },
692 .offset = 0x84, .size = 8, .activate = 8 },
695 .offset = 0x8c, .size = 8, .activate = 8 },
698 .offset = 0x95, .size = 8, .activate = 6 },
701 .offset = 0x9c, .size = 1, .activate = 8 },
704 .offset = 0x9d, .size = 8, .activate = 6 },
707 .offset = 0x9e, .size = 8, .activate = 6 },
716 .offset = 0x31, .size = 8, .activate = 2 },
719 .offset = 0x34, .size = 16, .activate = 1 },
722 .offset = 0x5c, .size = 8, .activate = 1 },
725 .offset = 0x66, .size = 8, .activate = 3 },
731 .offset = 0x7c, .size = 8, .activate = 7 },
734 .offset = 0x84, .size = 8, .activate = 8 },
737 .offset = 0x8c, .size = 8, .activate = 8 },
740 .offset = 0x95, .size = 8, .activate = 6 },
743 .offset = 0x9c, .size = 1, .activate = 8 },
746 .offset = 0x9d, .size = 8, .activate = 6 },
749 .offset = 0x9e, .size = 8, .activate = 6 },
752 .offset = 0x9f, .size = 1, .activate = 10 },
755 .offset = 0xa0, .size = 1, .activate = 10 },
758 .offset = 0xb0, .size = 16, .activate = 10 },
761 .offset = 0x94, .size = 8, .activate = 6 },
773 .offset = 0x9d, .size = 8, .activate = 6 },
776 .offset = 0x1c0, .size = 8, .activate = 19, .pbuf = 1 },
782 .offset = 0xc1, .size = 8, .activate = 29, .pbuf = 1 },
785 .offset = 0x9f, .size = 8, .activate = 21, .pbuf = 1 },
788 .offset = 0x9c, .size = 1, .activate = 20, .pbuf = 1 },
791 .offset = 0x1c4, .size = 8, .activate = 22, .pbuf = 1 },
794 .offset = 0x1c8, .size = 32, .activate = 23 },
797 .offset = 0x7c, .size = 32, .activate = 27 },
800 .offset = 0x200, .size = 32, .activate = 27 },
803 .offset = 0x84, .size = 32, .activate = 27 },
806 .offset = 0x250, .size = 32, .activate = 27 },
809 .offset = 0x1be, .size = 8, .activate = 17, .pbuf = 1 },
812 .offset = 0xbf, .size = 8, .activate = 28 },
822 .offset = 0x47, .size = 8, .activate = 4 },
825 .offset = 0x108, .size = 8, .activate = 12, .pbuf = 1 },
828 .offset = 0x46, .size = 8, .activate = 9, .pbuf = 1,
832 .offset = 0x3d, .size = 8, .activate = 10, .pbuf = 1,
836 .offset = 0x3e, .size = 8, .activate = 11, .pbuf = 1 },
839 .offset = 0x206, .size = 8, .activate = 25, .pbuf = 1 },
842 .offset = 0x232, .size = 16, .activate = 26 }
854 .offset = 0x49, .size = 8, .activate = 4 },
857 .offset = 0x14a, .size = 8, .activate = 16, .pbuf = 1 },
860 .offset = 0x135, .size = 8, .activate = 10, .pbuf = 1 },
866 .offset = 0x131, .size = 8, .activate = 29, .pbuf = 1 },
869 .offset = 0x132, .size = 8, .activate = 30, .pbuf = 1 },
872 .offset = 0x48, .size = 8, .activate = 11, .pbuf = 1,
876 .offset = 0x4b, .size = 8, .activate = 12, .pbuf = 1 },
879 .offset = 0x3c, .size = 8, .activate = 13, .pbuf = 1,
883 .offset = 0x147, .size = 8, .activate = 14, .pbuf = 1 },
886 .offset = 0x3e, .size = 8, .activate = 15, .pbuf = 1 },
889 .offset = 0x14b, .size = 8, .activate = 17, .pbuf = 1 },
892 .offset = 0x14e, .size = 8, .activate = 18, .pbuf = 1 },
895 .offset = 0x2a0, .size = 16, .activate = 36 }
907 .offset = 0x5c, .size = 8, .activate = 4 },
910 .offset = 0x13e, .size = 8, .activate = 10, .pbuf = 1 },
916 .offset = 0x13a, .size = 8, .activate = 23, .pbuf = 1 },
919 .offset = 0x13b, .size = 8, .activate = 24, .pbuf = 1 },
922 .offset = 0x5a, .size = 8, .activate = 11, .pbuf = 1,
926 .offset = 0x5e, .size = 8, .activate = 12, .pbuf = 1 },
929 .offset = 0x4e, .size = 8, .activate = 13, .pbuf = 1,
933 .offset = 0x150, .size = 8, .activate = 14, .pbuf = 1 },
936 .offset = 0x50, .size = 8, .activate = 15, .pbuf = 1 },
939 .offset = 0x153, .size = 8, .activate = 16, .pbuf = 1 },
942 .offset = 0x156, .size = 8, .activate = 17, .pbuf = 1 },
963 .offset = 0x31, .size = 8, .activate = 2 },
966 .offset = 0x34, .size = 16, .activate = 1 },
969 .offset = 0x5c, .size = 8, .activate = 1 },
972 .offset = 0x66, .size = 8, .activate = 3 },
978 .offset = 0x7c, .size = 8, .activate = 7 },
981 .offset = 0x95, .size = 8, .activate = 8 },
984 .offset = 0x8d, .size = 8, .activate = 6 },
987 .offset = 0x9e, .size = 8, .activate = 4 },
992 * - id: hardware ID of this port type
993 * - src_descr: printf format string for mux input selections
994 * - src_num_offset: added to channel number for the fprintf
995 * - dst_descr: printf format string for mixer controls
1054 * ports to add to the set_mux message. The end of the list is marked
1067 * that consecutive meter entries are mapped to. The end of the list
1089 * level control that can be set to line or instrument
1093 /* the first input with a level control (0-based) */
1106 /* the first input with an air control (0-based) */
1118 /* number of pre-compressor filters */
1135 /* the first input with phantom power control (0-based) */
1141 /* the number of inputs with software-controllable gain */
1164 * internally to the analogue 7/8 outputs
1181 * SCARLETT2_USB_GET_METER to index into mux[] entries (same
1191 struct mutex data_mutex; /* lock access to this data */
1311 /*** Model-specific data ***/
2295 u16 seq = private->scarlett2_seq++; in scarlett2_fill_request_header()
2297 req->cmd = cpu_to_le32(cmd); in scarlett2_fill_request_header()
2298 req->size = cpu_to_le16(req_size); in scarlett2_fill_request_header()
2299 req->seq = cpu_to_le16(seq); in scarlett2_fill_request_header()
2300 req->error = 0; in scarlett2_fill_request_header()
2301 req->pad = 0; in scarlett2_fill_request_header()
2322 /* Send a proprietary format request to the Scarlett interface */
2327 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb()
2328 struct usb_device *dev = mixer->chip->dev; in scarlett2_usb()
2336 err = -ENOMEM; in scarlett2_usb()
2342 err = -ENOMEM; in scarlett2_usb()
2346 mutex_lock(&private->usb_mutex); in scarlett2_usb()
2353 memcpy(req->data, req_data, req_size); in scarlett2_usb()
2355 err = scarlett2_usb_tx(dev, private->bInterfaceNumber, in scarlett2_usb()
2360 mixer->chip, in scarlett2_usb()
2362 private->series_name, cmd, err); in scarlett2_usb()
2363 err = -EINVAL; in scarlett2_usb()
2367 if (!wait_for_completion_timeout(&private->cmd_done, in scarlett2_usb()
2370 mixer->chip, in scarlett2_usb()
2372 private->series_name, cmd); in scarlett2_usb()
2374 err = -ETIMEDOUT; in scarlett2_usb()
2378 /* send a second message to get the response */ in scarlett2_usb()
2380 err = scarlett2_usb_rx(dev, private->bInterfaceNumber, in scarlett2_usb()
2388 /* ESHUTDOWN and EPROTO are valid responses to a in scarlett2_usb()
2392 (err == -ESHUTDOWN || err == -EPROTO)) { in scarlett2_usb()
2398 mixer->chip, in scarlett2_usb()
2400 private->series_name, cmd, err, resp_buf_size); in scarlett2_usb()
2401 err = -EINVAL; in scarlett2_usb()
2408 if (resp->cmd != req->cmd || in scarlett2_usb()
2409 (resp->seq != req->seq && in scarlett2_usb()
2410 (le16_to_cpu(req->seq) != 1 || resp->seq != 0)) || in scarlett2_usb()
2411 resp_size != le16_to_cpu(resp->size) || in scarlett2_usb()
2412 resp->error || in scarlett2_usb()
2413 resp->pad) { in scarlett2_usb()
2415 mixer->chip, in scarlett2_usb()
2419 private->series_name, in scarlett2_usb()
2420 le32_to_cpu(req->cmd), le32_to_cpu(resp->cmd), in scarlett2_usb()
2421 le16_to_cpu(req->seq), le16_to_cpu(resp->seq), in scarlett2_usb()
2422 resp_size, le16_to_cpu(resp->size), in scarlett2_usb()
2423 le32_to_cpu(resp->error), in scarlett2_usb()
2424 le32_to_cpu(resp->pad)); in scarlett2_usb()
2425 err = -EINVAL; in scarlett2_usb()
2430 memcpy(resp_data, resp->data, resp_size); in scarlett2_usb()
2433 mutex_unlock(&private->usb_mutex); in scarlett2_usb()
2440 /* Send a USB message to get data; result placed in *buf */
2462 return !!private->config_set->items[config_item_num].offset; in scarlett2_has_config_item()
2465 /* Send a USB message to get configuration parameters; result placed in *buf */
2470 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_get_config()
2472 &private->config_set->items[config_item_num]; in scarlett2_usb_get_config()
2480 if (!config_item->offset) in scarlett2_usb_get_config()
2481 return -EFAULT; in scarlett2_usb_get_config()
2483 /* Writes to the parameter buffer are always 1 byte */ in scarlett2_usb_get_config()
2484 size = config_item->size ? config_item->size : 8; in scarlett2_usb_get_config()
2486 /* For byte-sized parameters, retrieve directly into buf */ in scarlett2_usb_get_config()
2489 err = scarlett2_usb_get(mixer, config_item->offset, buf, size); in scarlett2_usb_get_config()
2506 /* For bit-sized parameters, retrieve into value */ in scarlett2_usb_get_config()
2507 err = scarlett2_usb_get(mixer, config_item->offset, &value, 1); in scarlett2_usb_get_config()
2527 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_data()
2537 return scarlett2_usb(private->mixer, SCARLETT2_USB_SET_DATA, in scarlett2_usb_set_data()
2550 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_data_buf()
2562 return -ENOMEM; in scarlett2_usb_set_data_buf()
2564 req->offset = cpu_to_le32(offset); in scarlett2_usb_set_data_buf()
2565 req->size = cpu_to_le32(bytes); in scarlett2_usb_set_data_buf()
2567 memcpy(req->data, buf, count); in scarlett2_usb_set_data_buf()
2573 ((__le16 *)req->data)[i] = cpu_to_le16(buf_16[i]); in scarlett2_usb_set_data_buf()
2579 ((__le32 *)req->data)[i] = cpu_to_le32(buf_32[i]); in scarlett2_usb_set_data_buf()
2582 err = scarlett2_usb(private->mixer, SCARLETT2_USB_SET_DATA, in scarlett2_usb_set_data_buf()
2592 * The value for activate needed is determined by the configuration
2596 struct usb_mixer_interface *mixer, int activate) in scarlett2_usb_activate_config() argument
2600 req = cpu_to_le32(activate); in scarlett2_usb_activate_config()
2605 /* Send USB messages to set a SCARLETT2_CONFIG_* parameter */
2610 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_config()
2611 const struct scarlett2_config_set *config_set = private->config_set; in scarlett2_usb_set_config()
2613 &config_set->items[config_item_num]; in scarlett2_usb_set_config()
2620 if (!config_item->offset) in scarlett2_usb_set_config()
2621 return -EFAULT; in scarlett2_usb_set_config()
2624 if (config_item->pbuf) { in scarlett2_usb_set_config()
2625 if (!config_set->param_buf_addr) in scarlett2_usb_set_config()
2626 return -EFAULT; in scarlett2_usb_set_config()
2630 mixer, config_set->param_buf_addr + 1, 1, index); in scarlett2_usb_set_config()
2636 mixer, config_set->param_buf_addr, 1, value); in scarlett2_usb_set_config()
2640 /* Activate the write through the parameter buffer */ in scarlett2_usb_set_config()
2642 mixer, config_item->activate); in scarlett2_usb_set_config()
2646 * save and support bit-modification in scarlett2_usb_set_config()
2650 cancel_delayed_work_sync(&private->work); in scarlett2_usb_set_config()
2652 /* Convert config_item->size in bits to size in bytes and in scarlett2_usb_set_config()
2655 if (config_item->size >= 8) { in scarlett2_usb_set_config()
2656 size = config_item->size / 8; in scarlett2_usb_set_config()
2657 offset = config_item->offset + index * size; in scarlett2_usb_set_config()
2666 offset = config_item->offset; in scarlett2_usb_set_config()
2685 /* Activate the change */ in scarlett2_usb_set_config()
2686 err = scarlett2_usb_activate_config(mixer, config_item->activate); in scarlett2_usb_set_config()
2693 if (config_set->param_buf_addr) in scarlett2_usb_set_config()
2696 /* Schedule the change to be written to NVRAM */ in scarlett2_usb_set_config()
2697 if (config_item->activate != SCARLETT2_USB_CONFIG_SAVE) in scarlett2_usb_set_config()
2698 schedule_delayed_work(&private->work, msecs_to_jiffies(2000)); in scarlett2_usb_set_config()
2703 /* Send USB messages to set a SCARLETT2_CONFIG_* parameter with
2710 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_config_buf()
2711 const struct scarlett2_config_set *config_set = private->config_set; in scarlett2_usb_set_config_buf()
2713 &config_set->items[config_item_num]; in scarlett2_usb_set_config_buf()
2720 if (!config_item->offset) in scarlett2_usb_set_config_buf()
2721 return -EFAULT; in scarlett2_usb_set_config_buf()
2723 /* Convert config_item->size in bits to size in bytes and in scarlett2_usb_set_config_buf()
2726 if (config_item->size >= 8) { in scarlett2_usb_set_config_buf()
2727 size = config_item->size / 8; in scarlett2_usb_set_config_buf()
2728 offset = config_item->offset + index * size; in scarlett2_usb_set_config_buf()
2732 return -EFAULT; in scarlett2_usb_set_config_buf()
2740 /* Activate the change */ in scarlett2_usb_set_config_buf()
2741 return scarlett2_usb_activate_config(mixer, config_item->activate); in scarlett2_usb_set_config_buf()
2751 usb_audio_err(mixer->chip, "config save failed: %d\n", err); in scarlett2_config_save()
2754 /* Delayed work to save config */
2760 scarlett2_config_save(private->mixer); in scarlett2_config_save_work()
2763 /* Send a USB message to get sync status; result placed in *sync */
2783 return !!private->info->mux_assignment[0][0].count; in scarlett2_has_mixer()
2786 /* Map from mixer value to (db + 80) * 2
2799 /* Send a USB message to get the volumes for all inputs of one mix
2800 * and put the values into private->mix[]
2805 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_get_mix()
2807 int num_mixer_in = private->num_mix_in; in scarlett2_usb_get_mix()
2827 private->mix[j] = scarlett2_mixer_value_to_db( in scarlett2_usb_get_mix()
2833 /* Send a USB message to set the volumes for all inputs of one mix
2834 * (values obtained from private->mix[])
2839 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_mix()
2847 int num_mixer_in = private->num_mix_in; in scarlett2_usb_set_mix()
2853 scarlett2_mixer_values[private->mix[j]] in scarlett2_usb_set_mix()
2861 /* Convert a port number index (per info->port_count) to a hardware ID */
2872 num -= port_count[port_type][SCARLETT2_PORT_IN]; in scarlett2_mux_src_num_to_id()
2879 /* Convert a hardware ID to a port number index */
2893 return port_num + id - base; in scarlett2_mux_id_to_num()
2898 return -1; in scarlett2_mux_id_to_num()
2901 /* Convert one mux entry from the interface and load into private->mux[] */
2905 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_populate_mux()
2906 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_usb_populate_mux()
2915 if (dst_idx >= private->num_mux_dsts) { in scarlett2_usb_populate_mux()
2916 usb_audio_err(private->mixer->chip, in scarlett2_usb_populate_mux()
2918 mux_entry, dst_idx, private->num_mux_dsts); in scarlett2_usb_populate_mux()
2927 if (src_idx >= private->num_mux_srcs) { in scarlett2_usb_populate_mux()
2928 usb_audio_err(private->mixer->chip, in scarlett2_usb_populate_mux()
2930 mux_entry, src_idx, private->num_mux_srcs); in scarlett2_usb_populate_mux()
2934 private->mux[dst_idx] = src_idx; in scarlett2_usb_populate_mux()
2940 * request) is returned in mux_assignment order, but to avoid exposing
2941 * that to userspace, scarlett2_meter_ctl_get() rearranges the data
2948 * - the source is "Off"; therefore we set those values to zero (map
2951 * - the source is assigned to a previous (with respect to the
2953 * to the value previously reported for that source
2957 const struct scarlett2_device_info *info = private->info; in scarlett2_update_meter_level_map()
2960 /* sources already assigned to a destination in scarlett2_update_meter_level_map()
2972 for (entry = info->meter_map; in scarlett2_update_meter_level_map()
2973 entry->count; in scarlett2_update_meter_level_map()
2979 for (j = 0, mux_idx = entry->start; in scarlett2_update_meter_level_map()
2980 j < entry->count; in scarlett2_update_meter_level_map()
2985 info->line_out_remap_enable && in scarlett2_update_meter_level_map()
2986 mux_idx < private->num_line_out in scarlett2_update_meter_level_map()
2987 ) ? info->line_out_unmap[mux_idx] in scarlett2_update_meter_level_map()
2995 int mux_src = private->mux[mux_idx]; in scarlett2_update_meter_level_map()
3001 private->meter_level_map[map_mux_idx] = in scarlett2_update_meter_level_map()
3007 /* Send USB message to get mux inputs and then populate private->mux[] */
3010 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_get_mux()
3011 int count = private->num_mux_dsts; in scarlett2_usb_get_mux()
3021 private->mux_updated = 0; in scarlett2_usb_get_mux()
3040 /* Send USB messages to set mux inputs */
3043 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_mux()
3044 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_set_mux()
3045 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_usb_set_mux()
3066 for (entry = info->mux_assignment[table]; in scarlett2_usb_set_mux()
3067 entry->count; in scarlett2_usb_set_mux()
3070 int port_type = entry->port_type; in scarlett2_usb_set_mux()
3071 int port_idx = entry->start; in scarlett2_usb_set_mux()
3078 for (j = 0; j < entry->count; j++) in scarlett2_usb_set_mux()
3083 /* Non-empty mux slots use the lower 12 bits in scarlett2_usb_set_mux()
3087 for (j = 0; j < entry->count; j++) { in scarlett2_usb_set_mux()
3089 port_count, private->mux[mux_idx++]); in scarlett2_usb_set_mux()
3108 /* Send USB message to get meter levels */
3128 /* copy, convert to u16 */ in scarlett2_usb_get_meter_levels()
3135 /* For config items with mute=1, xor bits 0 & 1 together to get the
3146 /* helper function to create a new control */
3158 return -ENOMEM; in scarlett2_add_new_ctl()
3162 * Also, the head.id field is set to 0, as we don't use this field. in scarlett2_add_new_ctl()
3164 elem->head.mixer = mixer; in scarlett2_add_new_ctl()
3165 elem->control = index; in scarlett2_add_new_ctl()
3166 elem->head.id = 0; in scarlett2_add_new_ctl()
3167 elem->channels = channels; in scarlett2_add_new_ctl()
3168 elem->val_type = USB_MIXER_BESPOKEN; in scarlett2_add_new_ctl()
3173 return -ENOMEM; in scarlett2_add_new_ctl()
3175 kctl->private_free = snd_usb_mixer_elem_free; in scarlett2_add_new_ctl()
3177 strscpy(kctl->id.name, name, sizeof(kctl->id.name)); in scarlett2_add_new_ctl()
3179 err = snd_usb_mixer_add_control(&elem->head, kctl); in scarlett2_add_new_ctl()
3195 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_firmware_version_ctl_get()
3196 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_firmware_version_ctl_get()
3198 ucontrol->value.integer.value[0] = private->firmware_version; in scarlett2_firmware_version_ctl_get()
3207 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_firmware_version_ctl_info()
3208 uinfo->count = 1; in scarlett2_firmware_version_ctl_info()
3234 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_min_firmware_version_ctl_get()
3235 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_min_firmware_version_ctl_get()
3237 ucontrol->value.integer.value[0] = private->info->min_firmware_version; in scarlett2_min_firmware_version_ctl_get()
3246 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_min_firmware_version_ctl_info()
3247 uinfo->count = 1; in scarlett2_min_firmware_version_ctl_info()
3274 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_sync()
3276 private->sync_updated = 0; in scarlett2_update_sync()
3277 return scarlett2_usb_get_sync_status(mixer, &private->sync); in scarlett2_update_sync()
3292 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_sync_ctl_get()
3293 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_sync_ctl_get()
3294 struct scarlett2_data *private = mixer->private_data; in scarlett2_sync_ctl_get()
3297 mutex_lock(&private->data_mutex); in scarlett2_sync_ctl_get()
3299 if (private->hwdep_in_use) { in scarlett2_sync_ctl_get()
3300 err = -EBUSY; in scarlett2_sync_ctl_get()
3304 if (private->sync_updated) { in scarlett2_sync_ctl_get()
3309 ucontrol->value.enumerated.item[0] = private->sync; in scarlett2_sync_ctl_get()
3312 mutex_unlock(&private->data_mutex); in scarlett2_sync_ctl_get()
3326 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_sync_ctl()
3333 0, 1, "Sync Status", &private->sync_ctl); in scarlett2_add_sync_ctl()
3342 /* Set the access mode of a control to read-only (val = 0) or
3343 * read-write (val = 1).
3348 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_WRITE; in scarlett2_set_ctl_access()
3350 kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_WRITE; in scarlett2_set_ctl_access()
3359 for (i = 0; i < private->info->gain_input_count; i++) in scarlett2_autogain_is_running()
3360 if (!private->autogain_status[i]) in scarlett2_autogain_is_running()
3368 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_autogain()
3369 const struct scarlett2_device_info *info = private->info; in scarlett2_update_autogain()
3374 private->autogain_updated = 0; in scarlett2_update_autogain()
3376 if (!info->gain_input_count) in scarlett2_update_autogain()
3381 info->gain_input_count, private->autogain_switch); in scarlett2_update_autogain()
3386 info->gain_input_count, raw_autogain_status); in scarlett2_update_autogain()
3395 * subsequent elements correspond to the status value from the in scarlett2_update_autogain()
3400 for (i = 0; i < info->gain_input_count; i++) in scarlett2_update_autogain()
3401 if (private->autogain_switch[i]) in scarlett2_update_autogain()
3402 private->autogain_status[i] = 0; in scarlett2_update_autogain()
3404 private->num_autogain_status_texts - 1) in scarlett2_update_autogain()
3405 private->autogain_status[i] = in scarlett2_update_autogain()
3408 private->autogain_status[i] = in scarlett2_update_autogain()
3409 private->num_autogain_status_texts - 1; in scarlett2_update_autogain()
3424 private->ag_targets[i] = -ag_target_values[i]; in scarlett2_update_autogain()
3432 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_update_access()
3433 const struct scarlett2_device_info *info = private->info; in scarlett2_autogain_update_access()
3439 scarlett2_set_ctl_access(private->input_select_ctl, val); in scarlett2_autogain_update_access()
3442 for (i = 0; i < info->gain_input_count / 2; i++) in scarlett2_autogain_update_access()
3443 scarlett2_set_ctl_access(private->input_link_ctls[i], in scarlett2_autogain_update_access()
3445 for (i = 0; i < info->gain_input_count; i++) in scarlett2_autogain_update_access()
3446 scarlett2_set_ctl_access(private->input_gain_ctls[i], val); in scarlett2_autogain_update_access()
3447 for (i = 0; i < info->safe_input_count; i++) in scarlett2_autogain_update_access()
3448 scarlett2_set_ctl_access(private->safe_ctls[i], val); in scarlett2_autogain_update_access()
3449 for (i = 0; i < info->level_input_count; i++) in scarlett2_autogain_update_access()
3450 scarlett2_set_ctl_access(private->level_ctls[i], val); in scarlett2_autogain_update_access()
3451 for (i = 0; i < info->air_input_count; i++) in scarlett2_autogain_update_access()
3452 scarlett2_set_ctl_access(private->air_ctls[i], val); in scarlett2_autogain_update_access()
3453 for (i = 0; i < info->mute_input_count; i++) in scarlett2_autogain_update_access()
3454 scarlett2_set_ctl_access(private->input_mute_ctls[i], val); in scarlett2_autogain_update_access()
3455 for (i = 0; i < info->phantom_count; i++) in scarlett2_autogain_update_access()
3456 scarlett2_set_ctl_access(private->phantom_ctls[i], val); in scarlett2_autogain_update_access()
3457 for (i = 0; i < info->dsp_input_count; i++) in scarlett2_autogain_update_access()
3458 scarlett2_set_ctl_access(private->dsp_ctls[i], val); in scarlett2_autogain_update_access()
3464 private->ag_target_ctls[i], val); in scarlett2_autogain_update_access()
3467 /* Notify of access mode change for all controls read-only while
3472 struct snd_card *card = mixer->chip->card; in scarlett2_autogain_notify_access()
3473 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_notify_access()
3474 const struct scarlett2_device_info *info = private->info; in scarlett2_autogain_notify_access()
3480 &private->input_select_ctl->id); in scarlett2_autogain_notify_access()
3483 for (i = 0; i < info->gain_input_count / 2; i++) in scarlett2_autogain_notify_access()
3485 &private->input_link_ctls[i]->id); in scarlett2_autogain_notify_access()
3486 for (i = 0; i < info->gain_input_count; i++) in scarlett2_autogain_notify_access()
3488 &private->input_gain_ctls[i]->id); in scarlett2_autogain_notify_access()
3489 for (i = 0; i < info->safe_input_count; i++) in scarlett2_autogain_notify_access()
3491 &private->safe_ctls[i]->id); in scarlett2_autogain_notify_access()
3492 for (i = 0; i < info->level_input_count; i++) in scarlett2_autogain_notify_access()
3494 &private->level_ctls[i]->id); in scarlett2_autogain_notify_access()
3495 for (i = 0; i < info->air_input_count; i++) in scarlett2_autogain_notify_access()
3497 &private->air_ctls[i]->id); in scarlett2_autogain_notify_access()
3498 for (i = 0; i < info->dsp_input_count; i++) in scarlett2_autogain_notify_access()
3500 &private->dsp_ctls[i]->id); in scarlett2_autogain_notify_access()
3501 for (i = 0; i < info->mute_input_count; i++) in scarlett2_autogain_notify_access()
3503 &private->input_mute_ctls[i]->id); in scarlett2_autogain_notify_access()
3504 for (i = 0; i < info->phantom_count; i++) in scarlett2_autogain_notify_access()
3506 &private->phantom_ctls[i]->id); in scarlett2_autogain_notify_access()
3512 &private->ag_target_ctls[i]->id); in scarlett2_autogain_notify_access()
3521 struct scarlett2_data *private = mixer->private_data; in scarlett2_check_autogain_updated()
3524 if (!private->autogain_updated) in scarlett2_check_autogain_updated()
3537 * control that is meant to be read-only while autogain is running,
3539 * Return -EPERM if autogain is running.
3549 if (scarlett2_autogain_is_running(mixer->private_data)) in scarlett2_check_put_during_autogain()
3550 return -EPERM; in scarlett2_check_put_during_autogain()
3558 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_switch_ctl_info()
3559 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_switch_ctl_info()
3560 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_switch_ctl_info()
3563 mutex_lock(&private->data_mutex); in scarlett2_autogain_switch_ctl_info()
3572 mutex_unlock(&private->data_mutex); in scarlett2_autogain_switch_ctl_info()
3579 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_switch_ctl_get()
3580 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_switch_ctl_get()
3581 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_switch_ctl_get()
3584 mutex_lock(&private->data_mutex); in scarlett2_autogain_switch_ctl_get()
3586 if (private->hwdep_in_use) { in scarlett2_autogain_switch_ctl_get()
3587 err = -EBUSY; in scarlett2_autogain_switch_ctl_get()
3595 ucontrol->value.enumerated.item[0] = in scarlett2_autogain_switch_ctl_get()
3596 private->autogain_switch[elem->control]; in scarlett2_autogain_switch_ctl_get()
3599 mutex_unlock(&private->data_mutex); in scarlett2_autogain_switch_ctl_get()
3606 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_status_ctl_get()
3607 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_status_ctl_get()
3608 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_status_ctl_get()
3611 mutex_lock(&private->data_mutex); in scarlett2_autogain_status_ctl_get()
3613 if (private->hwdep_in_use) { in scarlett2_autogain_status_ctl_get()
3614 err = -EBUSY; in scarlett2_autogain_status_ctl_get()
3622 ucontrol->value.enumerated.item[0] = in scarlett2_autogain_status_ctl_get()
3623 private->autogain_status[elem->control]; in scarlett2_autogain_status_ctl_get()
3626 mutex_unlock(&private->data_mutex); in scarlett2_autogain_status_ctl_get()
3633 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_switch_ctl_put()
3634 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_switch_ctl_put()
3635 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_switch_ctl_put()
3637 int index = elem->control; in scarlett2_autogain_switch_ctl_put()
3640 mutex_lock(&private->data_mutex); in scarlett2_autogain_switch_ctl_put()
3642 if (private->hwdep_in_use) { in scarlett2_autogain_switch_ctl_put()
3643 err = -EBUSY; in scarlett2_autogain_switch_ctl_put()
3652 err = -EPERM; in scarlett2_autogain_switch_ctl_put()
3656 oval = private->autogain_switch[index]; in scarlett2_autogain_switch_ctl_put()
3657 val = !!ucontrol->value.integer.value[0]; in scarlett2_autogain_switch_ctl_put()
3662 private->autogain_switch[index] = val; in scarlett2_autogain_switch_ctl_put()
3664 /* Send switch change to the device */ in scarlett2_autogain_switch_ctl_put()
3674 mutex_unlock(&private->data_mutex); in scarlett2_autogain_switch_ctl_put()
3681 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_status_ctl_info()
3682 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_autogain_status_ctl_info()
3686 private->num_autogain_status_texts, in scarlett2_autogain_status_ctl_info()
3687 private->config_set->autogain_status_texts); in scarlett2_autogain_status_ctl_info()
3711 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_ag_target_ctl_info()
3712 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_ag_target_ctl_info()
3713 struct scarlett2_data *private = mixer->private_data; in scarlett2_ag_target_ctl_info()
3716 mutex_lock(&private->data_mutex); in scarlett2_ag_target_ctl_info()
3718 if (private->hwdep_in_use) { in scarlett2_ag_target_ctl_info()
3719 err = -EBUSY; in scarlett2_ag_target_ctl_info()
3727 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_ag_target_ctl_info()
3728 uinfo->count = 1; in scarlett2_ag_target_ctl_info()
3729 uinfo->value.integer.min = SCARLETT2_AG_TARGET_MIN; in scarlett2_ag_target_ctl_info()
3730 uinfo->value.integer.max = 0; in scarlett2_ag_target_ctl_info()
3731 uinfo->value.integer.step = 1; in scarlett2_ag_target_ctl_info()
3734 mutex_unlock(&private->data_mutex); in scarlett2_ag_target_ctl_info()
3741 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_ag_target_ctl_get()
3742 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_ag_target_ctl_get()
3743 struct scarlett2_data *private = mixer->private_data; in scarlett2_ag_target_ctl_get()
3746 mutex_lock(&private->data_mutex); in scarlett2_ag_target_ctl_get()
3748 if (private->hwdep_in_use) { in scarlett2_ag_target_ctl_get()
3749 err = -EBUSY; in scarlett2_ag_target_ctl_get()
3753 if (private->autogain_updated) { in scarlett2_ag_target_ctl_get()
3759 ucontrol->value.integer.value[0] = private->ag_targets[elem->control]; in scarlett2_ag_target_ctl_get()
3762 mutex_unlock(&private->data_mutex); in scarlett2_ag_target_ctl_get()
3769 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_ag_target_ctl_put()
3770 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_ag_target_ctl_put()
3771 struct scarlett2_data *private = mixer->private_data; in scarlett2_ag_target_ctl_put()
3773 int index = elem->control; in scarlett2_ag_target_ctl_put()
3776 mutex_lock(&private->data_mutex); in scarlett2_ag_target_ctl_put()
3778 if (private->hwdep_in_use) { in scarlett2_ag_target_ctl_put()
3779 err = -EBUSY; in scarlett2_ag_target_ctl_put()
3787 oval = private->ag_targets[index]; in scarlett2_ag_target_ctl_put()
3788 val = clamp(ucontrol->value.integer.value[0], in scarlett2_ag_target_ctl_put()
3794 private->ag_targets[index] = val; in scarlett2_ag_target_ctl_put()
3796 /* Send new value to the device */ in scarlett2_ag_target_ctl_put()
3798 mixer, scarlett2_ag_target_configs[index], 1, -val); in scarlett2_ag_target_ctl_put()
3803 mutex_unlock(&private->data_mutex); in scarlett2_ag_target_ctl_put()
3826 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_select()
3827 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_select()
3828 int link_count = info->gain_input_count / 2; in scarlett2_update_input_select()
3831 private->input_select_updated = 0; in scarlett2_update_input_select()
3840 1, &private->input_select_switch); in scarlett2_update_input_select()
3846 link_count, private->input_link_switch); in scarlett2_update_input_select()
3851 if (private->input_link_switch[0]) in scarlett2_update_input_select()
3852 private->input_select_switch = 0; in scarlett2_update_input_select()
3860 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_select_ctl_get()
3861 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_select_ctl_get()
3862 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_select_ctl_get()
3865 mutex_lock(&private->data_mutex); in scarlett2_input_select_ctl_get()
3867 if (private->hwdep_in_use) { in scarlett2_input_select_ctl_get()
3868 err = -EBUSY; in scarlett2_input_select_ctl_get()
3872 if (private->input_select_updated) { in scarlett2_input_select_ctl_get()
3877 ucontrol->value.enumerated.item[0] = private->input_select_switch; in scarlett2_input_select_ctl_get()
3880 mutex_unlock(&private->data_mutex); in scarlett2_input_select_ctl_get()
3887 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_select_ctl_put()
3888 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_select_ctl_put()
3889 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_select_ctl_put()
3892 int max_val = private->input_link_switch[0] ? 0 : 1; in scarlett2_input_select_ctl_put()
3894 mutex_lock(&private->data_mutex); in scarlett2_input_select_ctl_put()
3896 if (private->hwdep_in_use) { in scarlett2_input_select_ctl_put()
3897 err = -EBUSY; in scarlett2_input_select_ctl_put()
3905 oval = private->input_select_switch; in scarlett2_input_select_ctl_put()
3906 val = ucontrol->value.integer.value[0]; in scarlett2_input_select_ctl_put()
3916 private->input_select_switch = val; in scarlett2_input_select_ctl_put()
3918 /* Send switch change to the device if inputs not linked */ in scarlett2_input_select_ctl_put()
3919 if (!private->input_link_switch[0]) in scarlett2_input_select_ctl_put()
3927 mutex_unlock(&private->data_mutex); in scarlett2_input_select_ctl_put()
3934 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_select_ctl_info()
3935 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_select_ctl_info()
3936 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_select_ctl_info()
3938 int inputs = private->info->gain_input_count; in scarlett2_input_select_ctl_info()
3944 return -ENOMEM; in scarlett2_input_select_ctl_info()
3946 mutex_lock(&private->data_mutex); in scarlett2_input_select_ctl_info()
3948 if (private->hwdep_in_use) { in scarlett2_input_select_ctl_info()
3949 err = -EBUSY; in scarlett2_input_select_ctl_info()
3961 if (private->input_link_switch[i / 2]) { in scarlett2_input_select_ctl_info()
3963 GFP_KERNEL, "Input %d-%d", i + 1, i + 2); in scarlett2_input_select_ctl_info()
3975 mutex_unlock(&private->data_mutex); in scarlett2_input_select_ctl_info()
3994 /* snd_ctl_boolean_mono_info() with autogain-updated check
3995 * (for controls that are read-only while autogain is running)
4000 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_disables_ctl_info()
4001 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_disables_ctl_info()
4002 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_disables_ctl_info()
4005 mutex_lock(&private->data_mutex); in scarlett2_autogain_disables_ctl_info()
4007 if (private->hwdep_in_use) { in scarlett2_autogain_disables_ctl_info()
4008 err = -EBUSY; in scarlett2_autogain_disables_ctl_info()
4019 mutex_unlock(&private->data_mutex); in scarlett2_autogain_disables_ctl_info()
4026 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_link_ctl_get()
4027 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_link_ctl_get()
4028 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_link_ctl_get()
4031 mutex_lock(&private->data_mutex); in scarlett2_input_link_ctl_get()
4033 if (private->hwdep_in_use) { in scarlett2_input_link_ctl_get()
4034 err = -EBUSY; in scarlett2_input_link_ctl_get()
4038 if (private->input_select_updated) { in scarlett2_input_link_ctl_get()
4043 ucontrol->value.enumerated.item[0] = in scarlett2_input_link_ctl_get()
4044 private->input_link_switch[elem->control]; in scarlett2_input_link_ctl_get()
4047 mutex_unlock(&private->data_mutex); in scarlett2_input_link_ctl_get()
4054 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_link_ctl_put()
4055 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_link_ctl_put()
4056 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_link_ctl_put()
4058 int index = elem->control; in scarlett2_input_link_ctl_put()
4061 mutex_lock(&private->data_mutex); in scarlett2_input_link_ctl_put()
4063 if (private->hwdep_in_use) { in scarlett2_input_link_ctl_put()
4064 err = -EBUSY; in scarlett2_input_link_ctl_put()
4072 oval = private->input_link_switch[index]; in scarlett2_input_link_ctl_put()
4073 val = !!ucontrol->value.integer.value[0]; in scarlett2_input_link_ctl_put()
4078 private->input_link_switch[index] = val; in scarlett2_input_link_ctl_put()
4081 snd_ctl_notify(mixer->chip->card, in scarlett2_input_link_ctl_put()
4083 &private->input_select_ctl->id); in scarlett2_input_link_ctl_put()
4084 private->input_select_updated = 1; in scarlett2_input_link_ctl_put()
4086 /* Send switch change to the device in scarlett2_input_link_ctl_put()
4087 * Link for channels 1-2 is at index 1 in scarlett2_input_link_ctl_put()
4096 mutex_unlock(&private->data_mutex); in scarlett2_input_link_ctl_put()
4112 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_gain()
4113 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_gain()
4115 private->input_gain_updated = 0; in scarlett2_update_input_gain()
4117 if (!info->gain_input_count) in scarlett2_update_input_gain()
4122 info->gain_input_count, private->gain); in scarlett2_update_input_gain()
4128 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_gain_ctl_info()
4129 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_gain_ctl_info()
4130 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_gain_ctl_info()
4133 mutex_lock(&private->data_mutex); in scarlett2_input_gain_ctl_info()
4135 if (private->hwdep_in_use) { in scarlett2_input_gain_ctl_info()
4136 err = -EBUSY; in scarlett2_input_gain_ctl_info()
4144 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_input_gain_ctl_info()
4145 uinfo->count = elem->channels; in scarlett2_input_gain_ctl_info()
4146 uinfo->value.integer.min = 0; in scarlett2_input_gain_ctl_info()
4147 uinfo->value.integer.max = SCARLETT2_MAX_GAIN_VALUE; in scarlett2_input_gain_ctl_info()
4148 uinfo->value.integer.step = 1; in scarlett2_input_gain_ctl_info()
4151 mutex_unlock(&private->data_mutex); in scarlett2_input_gain_ctl_info()
4158 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_gain_ctl_get()
4159 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_gain_ctl_get()
4160 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_gain_ctl_get()
4163 mutex_lock(&private->data_mutex); in scarlett2_input_gain_ctl_get()
4165 if (private->hwdep_in_use) { in scarlett2_input_gain_ctl_get()
4166 err = -EBUSY; in scarlett2_input_gain_ctl_get()
4170 if (private->input_gain_updated) { in scarlett2_input_gain_ctl_get()
4175 ucontrol->value.integer.value[0] = in scarlett2_input_gain_ctl_get()
4176 private->gain[elem->control]; in scarlett2_input_gain_ctl_get()
4179 mutex_unlock(&private->data_mutex); in scarlett2_input_gain_ctl_get()
4186 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_gain_ctl_put()
4187 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_gain_ctl_put()
4188 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_gain_ctl_put()
4190 int index = elem->control; in scarlett2_input_gain_ctl_put()
4193 mutex_lock(&private->data_mutex); in scarlett2_input_gain_ctl_put()
4195 if (private->hwdep_in_use) { in scarlett2_input_gain_ctl_put()
4196 err = -EBUSY; in scarlett2_input_gain_ctl_put()
4204 oval = private->gain[index]; in scarlett2_input_gain_ctl_put()
4205 val = ucontrol->value.integer.value[0]; in scarlett2_input_gain_ctl_put()
4210 private->gain[index] = val; in scarlett2_input_gain_ctl_put()
4212 /* Send gain change to the device */ in scarlett2_input_gain_ctl_put()
4219 mutex_unlock(&private->data_mutex); in scarlett2_input_gain_ctl_put()
4238 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_safe()
4239 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_safe()
4241 private->input_safe_updated = 0; in scarlett2_update_input_safe()
4243 if (!info->safe_input_count) in scarlett2_update_input_safe()
4248 info->safe_input_count, private->safe_switch); in scarlett2_update_input_safe()
4254 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_safe_ctl_get()
4255 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_safe_ctl_get()
4256 struct scarlett2_data *private = mixer->private_data; in scarlett2_safe_ctl_get()
4259 mutex_lock(&private->data_mutex); in scarlett2_safe_ctl_get()
4261 if (private->hwdep_in_use) { in scarlett2_safe_ctl_get()
4262 err = -EBUSY; in scarlett2_safe_ctl_get()
4266 if (private->input_safe_updated) { in scarlett2_safe_ctl_get()
4271 ucontrol->value.integer.value[0] = in scarlett2_safe_ctl_get()
4272 private->safe_switch[elem->control]; in scarlett2_safe_ctl_get()
4275 mutex_unlock(&private->data_mutex); in scarlett2_safe_ctl_get()
4282 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_safe_ctl_put()
4283 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_safe_ctl_put()
4284 struct scarlett2_data *private = mixer->private_data; in scarlett2_safe_ctl_put()
4286 int index = elem->control; in scarlett2_safe_ctl_put()
4289 mutex_lock(&private->data_mutex); in scarlett2_safe_ctl_put()
4291 if (private->hwdep_in_use) { in scarlett2_safe_ctl_put()
4292 err = -EBUSY; in scarlett2_safe_ctl_put()
4300 oval = private->safe_switch[index]; in scarlett2_safe_ctl_put()
4301 val = !!ucontrol->value.integer.value[0]; in scarlett2_safe_ctl_put()
4306 private->safe_switch[index] = val; in scarlett2_safe_ctl_put()
4308 /* Send switch change to the device */ in scarlett2_safe_ctl_put()
4315 mutex_unlock(&private->data_mutex); in scarlett2_safe_ctl_put()
4331 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_pcm_input_switch()
4334 private->pcm_input_switch_updated = 0; in scarlett2_update_pcm_input_switch()
4338 1, &private->pcm_input_switch); in scarlett2_update_pcm_input_switch()
4348 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pcm_input_switch_ctl_get()
4349 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pcm_input_switch_ctl_get()
4350 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_pcm_input_switch_ctl_get()
4353 mutex_lock(&private->data_mutex); in scarlett2_pcm_input_switch_ctl_get()
4355 if (private->pcm_input_switch_updated) { in scarlett2_pcm_input_switch_ctl_get()
4360 ucontrol->value.enumerated.item[0] = private->pcm_input_switch; in scarlett2_pcm_input_switch_ctl_get()
4363 mutex_unlock(&private->data_mutex); in scarlett2_pcm_input_switch_ctl_get()
4370 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pcm_input_switch_ctl_put()
4371 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pcm_input_switch_ctl_put()
4372 struct scarlett2_data *private = mixer->private_data; in scarlett2_pcm_input_switch_ctl_put()
4376 mutex_lock(&private->data_mutex); in scarlett2_pcm_input_switch_ctl_put()
4378 if (private->hwdep_in_use) { in scarlett2_pcm_input_switch_ctl_put()
4379 err = -EBUSY; in scarlett2_pcm_input_switch_ctl_put()
4383 oval = private->pcm_input_switch; in scarlett2_pcm_input_switch_ctl_put()
4384 val = !!ucontrol->value.integer.value[0]; in scarlett2_pcm_input_switch_ctl_put()
4389 private->pcm_input_switch = val; in scarlett2_pcm_input_switch_ctl_put()
4391 /* Send switch change to the device */ in scarlett2_pcm_input_switch_ctl_put()
4399 mutex_unlock(&private->data_mutex); in scarlett2_pcm_input_switch_ctl_put()
4429 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_volumes()
4433 private->vol_updated = 0; in scarlett2_update_volumes()
4443 private->master_vol = clamp(vol + SCARLETT2_VOLUME_BIAS, in scarlett2_update_volumes()
4448 for (i = 0; i < private->num_line_out; i++) in scarlett2_update_volumes()
4449 if (private->vol_sw_hw_switch[i]) in scarlett2_update_volumes()
4450 private->vol[i] = private->master_vol; in scarlett2_update_volumes()
4461 private->headphone_vol = clamp(vol + SCARLETT2_VOLUME_BIAS, in scarlett2_update_volumes()
4471 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_volume_ctl_info()
4473 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_volume_ctl_info()
4474 uinfo->count = elem->channels; in scarlett2_volume_ctl_info()
4475 uinfo->value.integer.min = 0; in scarlett2_volume_ctl_info()
4476 uinfo->value.integer.max = SCARLETT2_VOLUME_BIAS; in scarlett2_volume_ctl_info()
4477 uinfo->value.integer.step = 1; in scarlett2_volume_ctl_info()
4484 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_master_volume_ctl_get()
4485 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_master_volume_ctl_get()
4486 struct scarlett2_data *private = mixer->private_data; in scarlett2_master_volume_ctl_get()
4489 mutex_lock(&private->data_mutex); in scarlett2_master_volume_ctl_get()
4491 if (private->hwdep_in_use) { in scarlett2_master_volume_ctl_get()
4492 err = -EBUSY; in scarlett2_master_volume_ctl_get()
4496 if (private->vol_updated) { in scarlett2_master_volume_ctl_get()
4501 ucontrol->value.integer.value[0] = private->master_vol; in scarlett2_master_volume_ctl_get()
4504 mutex_unlock(&private->data_mutex); in scarlett2_master_volume_ctl_get()
4512 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_headphone_volume_ctl_get()
4513 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_headphone_volume_ctl_get()
4514 struct scarlett2_data *private = mixer->private_data; in scarlett2_headphone_volume_ctl_get()
4517 mutex_lock(&private->data_mutex); in scarlett2_headphone_volume_ctl_get()
4519 if (private->hwdep_in_use) { in scarlett2_headphone_volume_ctl_get()
4520 err = -EBUSY; in scarlett2_headphone_volume_ctl_get()
4524 if (private->vol_updated) { in scarlett2_headphone_volume_ctl_get()
4529 ucontrol->value.integer.value[0] = private->headphone_vol; in scarlett2_headphone_volume_ctl_get()
4532 mutex_unlock(&private->data_mutex); in scarlett2_headphone_volume_ctl_get()
4538 const struct scarlett2_device_info *info = private->info; in line_out_remap()
4540 if (!info->line_out_remap_enable) in line_out_remap()
4543 if (index >= private->num_line_out) in line_out_remap()
4546 return info->line_out_remap[index]; in line_out_remap()
4552 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_volume_ctl_get()
4553 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_volume_ctl_get()
4554 struct scarlett2_data *private = mixer->private_data; in scarlett2_volume_ctl_get()
4555 int index = line_out_remap(private, elem->control); in scarlett2_volume_ctl_get()
4558 mutex_lock(&private->data_mutex); in scarlett2_volume_ctl_get()
4560 if (private->hwdep_in_use) { in scarlett2_volume_ctl_get()
4561 err = -EBUSY; in scarlett2_volume_ctl_get()
4565 if (private->vol_updated) { in scarlett2_volume_ctl_get()
4570 ucontrol->value.integer.value[0] = private->vol[index]; in scarlett2_volume_ctl_get()
4573 mutex_unlock(&private->data_mutex); in scarlett2_volume_ctl_get()
4580 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_volume_ctl_put()
4581 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_volume_ctl_put()
4582 struct scarlett2_data *private = mixer->private_data; in scarlett2_volume_ctl_put()
4583 int index = line_out_remap(private, elem->control); in scarlett2_volume_ctl_put()
4586 mutex_lock(&private->data_mutex); in scarlett2_volume_ctl_put()
4588 if (private->hwdep_in_use) { in scarlett2_volume_ctl_put()
4589 err = -EBUSY; in scarlett2_volume_ctl_put()
4593 oval = private->vol[index]; in scarlett2_volume_ctl_put()
4594 val = ucontrol->value.integer.value[0]; in scarlett2_volume_ctl_put()
4599 private->vol[index] = val; in scarlett2_volume_ctl_put()
4601 index, val - SCARLETT2_VOLUME_BIAS); in scarlett2_volume_ctl_put()
4606 mutex_unlock(&private->data_mutex); in scarlett2_volume_ctl_put()
4611 db_scale_scarlett2_volume, -SCARLETT2_VOLUME_BIAS * 100, 0
4652 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_dim_mute()
4656 private->dim_mute_updated = 0; in scarlett2_update_dim_mute()
4663 SCARLETT2_DIM_MUTE_COUNT, private->dim_mute); in scarlett2_update_dim_mute()
4668 private->dim_mute[i] = !!private->dim_mute[i]; in scarlett2_update_dim_mute()
4670 mute = private->dim_mute[SCARLETT2_BUTTON_MUTE]; in scarlett2_update_dim_mute()
4672 for (i = 0; i < private->num_line_out; i++) in scarlett2_update_dim_mute()
4673 if (private->vol_sw_hw_switch[i]) in scarlett2_update_dim_mute()
4674 private->mute_switch[i] = mute; in scarlett2_update_dim_mute()
4682 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mute_ctl_get()
4683 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mute_ctl_get()
4684 struct scarlett2_data *private = mixer->private_data; in scarlett2_mute_ctl_get()
4685 int index = line_out_remap(private, elem->control); in scarlett2_mute_ctl_get()
4688 mutex_lock(&private->data_mutex); in scarlett2_mute_ctl_get()
4690 if (private->hwdep_in_use) { in scarlett2_mute_ctl_get()
4691 err = -EBUSY; in scarlett2_mute_ctl_get()
4695 if (private->dim_mute_updated) { in scarlett2_mute_ctl_get()
4700 ucontrol->value.integer.value[0] = private->mute_switch[index]; in scarlett2_mute_ctl_get()
4703 mutex_unlock(&private->data_mutex); in scarlett2_mute_ctl_get()
4710 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mute_ctl_put()
4711 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mute_ctl_put()
4712 struct scarlett2_data *private = mixer->private_data; in scarlett2_mute_ctl_put()
4713 int index = line_out_remap(private, elem->control); in scarlett2_mute_ctl_put()
4716 mutex_lock(&private->data_mutex); in scarlett2_mute_ctl_put()
4718 if (private->hwdep_in_use) { in scarlett2_mute_ctl_put()
4719 err = -EBUSY; in scarlett2_mute_ctl_put()
4723 oval = private->mute_switch[index]; in scarlett2_mute_ctl_put()
4724 val = !!ucontrol->value.integer.value[0]; in scarlett2_mute_ctl_put()
4729 private->mute_switch[index] = val; in scarlett2_mute_ctl_put()
4731 /* Send mute change to the device */ in scarlett2_mute_ctl_put()
4738 mutex_unlock(&private->data_mutex); in scarlett2_mute_ctl_put()
4754 private->sw_hw_ctls[index]->vd[0].access &= in scarlett2_sw_hw_ctl_ro()
4760 private->sw_hw_ctls[index]->vd[0].access |= in scarlett2_sw_hw_ctl_rw()
4777 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_sw_hw_enum_ctl_get()
4778 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_sw_hw_enum_ctl_get()
4779 int index = line_out_remap(private, elem->control); in scarlett2_sw_hw_enum_ctl_get()
4781 ucontrol->value.enumerated.item[0] = private->vol_sw_hw_switch[index]; in scarlett2_sw_hw_enum_ctl_get()
4788 struct scarlett2_data *private = mixer->private_data; in scarlett2_vol_ctl_set_writable()
4789 struct snd_card *card = mixer->chip->card; in scarlett2_vol_ctl_set_writable()
4793 private->vol_ctls[index]->vd[0].access |= in scarlett2_vol_ctl_set_writable()
4795 private->mute_ctls[index]->vd[0].access |= in scarlett2_vol_ctl_set_writable()
4798 private->vol_ctls[index]->vd[0].access &= in scarlett2_vol_ctl_set_writable()
4800 private->mute_ctls[index]->vd[0].access &= in scarlett2_vol_ctl_set_writable()
4807 &private->vol_ctls[index]->id); in scarlett2_vol_ctl_set_writable()
4810 &private->mute_ctls[index]->id); in scarlett2_vol_ctl_set_writable()
4816 struct scarlett2_data *private = mixer->private_data; in scarlett2_sw_hw_change()
4820 private->vol_sw_hw_switch[index] = val; in scarlett2_sw_hw_change()
4822 /* Change access mode to RO (hardware controlled volume) in scarlett2_sw_hw_change()
4827 /* Reset volume/mute to master volume/mute */ in scarlett2_sw_hw_change()
4828 private->vol[index] = private->master_vol; in scarlett2_sw_hw_change()
4829 private->mute_switch[index] = private->dim_mute[SCARLETT2_BUTTON_MUTE]; in scarlett2_sw_hw_change()
4831 /* Set SW volume to current HW volume */ in scarlett2_sw_hw_change()
4834 index, private->master_vol - SCARLETT2_VOLUME_BIAS); in scarlett2_sw_hw_change()
4838 /* Set SW mute to current HW mute */ in scarlett2_sw_hw_change()
4841 index, private->dim_mute[SCARLETT2_BUTTON_MUTE]); in scarlett2_sw_hw_change()
4845 /* Send SW/HW switch change to the device */ in scarlett2_sw_hw_change()
4853 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_sw_hw_enum_ctl_put()
4854 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_sw_hw_enum_ctl_put()
4855 struct scarlett2_data *private = mixer->private_data; in scarlett2_sw_hw_enum_ctl_put()
4856 int ctl_index = elem->control; in scarlett2_sw_hw_enum_ctl_put()
4860 mutex_lock(&private->data_mutex); in scarlett2_sw_hw_enum_ctl_put()
4862 if (private->hwdep_in_use) { in scarlett2_sw_hw_enum_ctl_put()
4863 err = -EBUSY; in scarlett2_sw_hw_enum_ctl_put()
4867 oval = private->vol_sw_hw_switch[index]; in scarlett2_sw_hw_enum_ctl_put()
4868 val = !!ucontrol->value.enumerated.item[0]; in scarlett2_sw_hw_enum_ctl_put()
4878 mutex_unlock(&private->data_mutex); in scarlett2_sw_hw_enum_ctl_put()
4894 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_level()
4895 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_level()
4897 private->input_level_updated = 0; in scarlett2_update_input_level()
4899 if (!info->level_input_count) in scarlett2_update_input_level()
4904 info->level_input_count + info->level_input_first, in scarlett2_update_input_level()
4905 private->level_switch); in scarlett2_update_input_level()
4914 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_level_enum_ctl_info()
4915 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_level_enum_ctl_info()
4916 struct scarlett2_data *private = mixer->private_data; in scarlett2_level_enum_ctl_info()
4919 mutex_lock(&private->data_mutex); in scarlett2_level_enum_ctl_info()
4921 if (private->hwdep_in_use) { in scarlett2_level_enum_ctl_info()
4922 err = -EBUSY; in scarlett2_level_enum_ctl_info()
4933 mutex_unlock(&private->data_mutex); in scarlett2_level_enum_ctl_info()
4940 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_level_enum_ctl_get()
4941 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_level_enum_ctl_get()
4942 struct scarlett2_data *private = mixer->private_data; in scarlett2_level_enum_ctl_get()
4943 const struct scarlett2_device_info *info = private->info; in scarlett2_level_enum_ctl_get()
4945 int index = elem->control + info->level_input_first; in scarlett2_level_enum_ctl_get()
4948 mutex_lock(&private->data_mutex); in scarlett2_level_enum_ctl_get()
4950 if (private->hwdep_in_use) { in scarlett2_level_enum_ctl_get()
4951 err = -EBUSY; in scarlett2_level_enum_ctl_get()
4955 if (private->input_level_updated) { in scarlett2_level_enum_ctl_get()
4960 ucontrol->value.enumerated.item[0] = scarlett2_decode_muteable( in scarlett2_level_enum_ctl_get()
4961 private->level_switch[index]); in scarlett2_level_enum_ctl_get()
4964 mutex_unlock(&private->data_mutex); in scarlett2_level_enum_ctl_get()
4971 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_level_enum_ctl_put()
4972 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_level_enum_ctl_put()
4973 struct scarlett2_data *private = mixer->private_data; in scarlett2_level_enum_ctl_put()
4974 const struct scarlett2_device_info *info = private->info; in scarlett2_level_enum_ctl_put()
4976 int index = elem->control + info->level_input_first; in scarlett2_level_enum_ctl_put()
4979 mutex_lock(&private->data_mutex); in scarlett2_level_enum_ctl_put()
4981 if (private->hwdep_in_use) { in scarlett2_level_enum_ctl_put()
4982 err = -EBUSY; in scarlett2_level_enum_ctl_put()
4990 oval = private->level_switch[index]; in scarlett2_level_enum_ctl_put()
4991 val = !!ucontrol->value.enumerated.item[0]; in scarlett2_level_enum_ctl_put()
4996 private->level_switch[index] = val; in scarlett2_level_enum_ctl_put()
4998 /* To set the Gen 4 muteable controls, bit 1 gets set instead */ in scarlett2_level_enum_ctl_put()
4999 if (private->config_set->items[SCARLETT2_CONFIG_LEVEL_SWITCH].mute) in scarlett2_level_enum_ctl_put()
5002 /* Send switch change to the device */ in scarlett2_level_enum_ctl_put()
5009 mutex_unlock(&private->data_mutex); in scarlett2_level_enum_ctl_put()
5025 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_pad()
5026 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_pad()
5028 private->input_pad_updated = 0; in scarlett2_update_input_pad()
5030 if (!info->pad_input_count) in scarlett2_update_input_pad()
5035 info->pad_input_count, private->pad_switch); in scarlett2_update_input_pad()
5041 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pad_ctl_get()
5042 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pad_ctl_get()
5043 struct scarlett2_data *private = mixer->private_data; in scarlett2_pad_ctl_get()
5046 mutex_lock(&private->data_mutex); in scarlett2_pad_ctl_get()
5048 if (private->hwdep_in_use) { in scarlett2_pad_ctl_get()
5049 err = -EBUSY; in scarlett2_pad_ctl_get()
5053 if (private->input_pad_updated) { in scarlett2_pad_ctl_get()
5058 ucontrol->value.integer.value[0] = in scarlett2_pad_ctl_get()
5059 private->pad_switch[elem->control]; in scarlett2_pad_ctl_get()
5062 mutex_unlock(&private->data_mutex); in scarlett2_pad_ctl_get()
5069 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pad_ctl_put()
5070 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pad_ctl_put()
5071 struct scarlett2_data *private = mixer->private_data; in scarlett2_pad_ctl_put()
5073 int index = elem->control; in scarlett2_pad_ctl_put()
5076 mutex_lock(&private->data_mutex); in scarlett2_pad_ctl_put()
5078 if (private->hwdep_in_use) { in scarlett2_pad_ctl_put()
5079 err = -EBUSY; in scarlett2_pad_ctl_put()
5083 oval = private->pad_switch[index]; in scarlett2_pad_ctl_put()
5084 val = !!ucontrol->value.integer.value[0]; in scarlett2_pad_ctl_put()
5089 private->pad_switch[index] = val; in scarlett2_pad_ctl_put()
5091 /* Send switch change to the device */ in scarlett2_pad_ctl_put()
5098 mutex_unlock(&private->data_mutex); in scarlett2_pad_ctl_put()
5114 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_air()
5115 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_air()
5117 private->input_air_updated = 0; in scarlett2_update_input_air()
5119 if (!info->air_input_count) in scarlett2_update_input_air()
5124 info->air_input_count, private->air_switch); in scarlett2_update_input_air()
5130 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_air_ctl_get()
5131 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_air_ctl_get()
5132 struct scarlett2_data *private = mixer->private_data; in scarlett2_air_ctl_get()
5135 mutex_lock(&private->data_mutex); in scarlett2_air_ctl_get()
5137 if (private->hwdep_in_use) { in scarlett2_air_ctl_get()
5138 err = -EBUSY; in scarlett2_air_ctl_get()
5142 if (private->input_air_updated) { in scarlett2_air_ctl_get()
5147 ucontrol->value.integer.value[0] = private->air_switch[elem->control]; in scarlett2_air_ctl_get()
5150 mutex_unlock(&private->data_mutex); in scarlett2_air_ctl_get()
5157 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_air_ctl_put()
5158 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_air_ctl_put()
5159 struct scarlett2_data *private = mixer->private_data; in scarlett2_air_ctl_put()
5161 int index = elem->control; in scarlett2_air_ctl_put()
5164 mutex_lock(&private->data_mutex); in scarlett2_air_ctl_put()
5166 if (private->hwdep_in_use) { in scarlett2_air_ctl_put()
5167 err = -EBUSY; in scarlett2_air_ctl_put()
5175 oval = private->air_switch[index]; in scarlett2_air_ctl_put()
5176 val = ucontrol->value.integer.value[0]; in scarlett2_air_ctl_put()
5181 private->air_switch[index] = val; in scarlett2_air_ctl_put()
5183 /* Send switch change to the device */ in scarlett2_air_ctl_put()
5190 mutex_unlock(&private->data_mutex); in scarlett2_air_ctl_put()
5200 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_air_with_drive_ctl_info()
5201 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_air_with_drive_ctl_info()
5202 struct scarlett2_data *private = mixer->private_data; in scarlett2_air_with_drive_ctl_info()
5205 mutex_lock(&private->data_mutex); in scarlett2_air_with_drive_ctl_info()
5207 if (private->hwdep_in_use) { in scarlett2_air_with_drive_ctl_info()
5208 err = -EBUSY; in scarlett2_air_with_drive_ctl_info()
5219 mutex_unlock(&private->data_mutex); in scarlett2_air_with_drive_ctl_info()
5244 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_dsp()
5245 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_dsp()
5247 private->input_dsp_updated = 0; in scarlett2_update_input_dsp()
5249 if (!info->dsp_input_count) in scarlett2_update_input_dsp()
5254 info->dsp_input_count, private->dsp_switch); in scarlett2_update_input_dsp()
5260 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dsp_ctl_get()
5261 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dsp_ctl_get()
5262 struct scarlett2_data *private = mixer->private_data; in scarlett2_dsp_ctl_get()
5265 mutex_lock(&private->data_mutex); in scarlett2_dsp_ctl_get()
5267 if (private->hwdep_in_use) { in scarlett2_dsp_ctl_get()
5268 err = -EBUSY; in scarlett2_dsp_ctl_get()
5272 if (private->input_dsp_updated) { in scarlett2_dsp_ctl_get()
5277 ucontrol->value.integer.value[0] = private->dsp_switch[elem->control]; in scarlett2_dsp_ctl_get()
5280 mutex_unlock(&private->data_mutex); in scarlett2_dsp_ctl_get()
5287 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dsp_ctl_put()
5288 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dsp_ctl_put()
5289 struct scarlett2_data *private = mixer->private_data; in scarlett2_dsp_ctl_put()
5291 int index = elem->control; in scarlett2_dsp_ctl_put()
5294 mutex_lock(&private->data_mutex); in scarlett2_dsp_ctl_put()
5296 if (private->hwdep_in_use) { in scarlett2_dsp_ctl_put()
5297 err = -EBUSY; in scarlett2_dsp_ctl_put()
5305 oval = private->dsp_switch[index]; in scarlett2_dsp_ctl_put()
5306 val = ucontrol->value.integer.value[0]; in scarlett2_dsp_ctl_put()
5311 private->dsp_switch[index] = val; in scarlett2_dsp_ctl_put()
5313 /* Send switch change to the device */ in scarlett2_dsp_ctl_put()
5320 mutex_unlock(&private->data_mutex); in scarlett2_dsp_ctl_put()
5336 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_compressor_values()
5337 const struct scarlett2_device_info *info = private->info; in scarlett2_update_compressor_values()
5340 if (!info->dsp_input_count) in scarlett2_update_compressor_values()
5345 SCARLETT2_COMPRESSOR_PARAM_COUNT * info->dsp_input_count, in scarlett2_update_compressor_values()
5346 private->compressor_values); in scarlett2_update_compressor_values()
5354 for (j = 0; j < info->dsp_input_count; j++) { in scarlett2_update_compressor_values()
5356 int val = private->compressor_values[idx]; in scarlett2_update_compressor_values()
5358 val >>= param->scale_bits; in scarlett2_update_compressor_values()
5359 val = clamp(val, param->min, param->max); in scarlett2_update_compressor_values()
5360 private->compressor_values[idx] = val; in scarlett2_update_compressor_values()
5370 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_compressor_ctl_get()
5371 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_compressor_ctl_get()
5373 ucontrol->value.integer.value[0] = in scarlett2_compressor_ctl_get()
5374 private->compressor_values[elem->control]; in scarlett2_compressor_ctl_get()
5381 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_compressor_ctl_put()
5382 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_compressor_ctl_put()
5383 struct scarlett2_data *private = mixer->private_data; in scarlett2_compressor_ctl_put()
5385 int index = elem->control; in scarlett2_compressor_ctl_put()
5391 mutex_lock(&private->data_mutex); in scarlett2_compressor_ctl_put()
5393 if (private->hwdep_in_use) { in scarlett2_compressor_ctl_put()
5394 err = -EBUSY; in scarlett2_compressor_ctl_put()
5402 oval = private->compressor_values[index]; in scarlett2_compressor_ctl_put()
5403 val = ucontrol->value.integer.value[0]; in scarlett2_compressor_ctl_put()
5407 private->compressor_values[index] = val; in scarlett2_compressor_ctl_put()
5411 scaled_val = val << param->scale_bits; in scarlett2_compressor_ctl_put()
5413 /* Send change to the device */ in scarlett2_compressor_ctl_put()
5415 /* The channel needs to be put in the parameter buffer index in scarlett2_compressor_ctl_put()
5420 mixer, private->config_set->param_buf_addr + 1, 1, channel); in scarlett2_compressor_ctl_put()
5433 mutex_unlock(&private->data_mutex); in scarlett2_compressor_ctl_put()
5440 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_compressor_ctl_info()
5441 int control = elem->control % SCARLETT2_COMPRESSOR_PARAM_COUNT; in scarlett2_compressor_ctl_info()
5443 uinfo->type = compressor_params[control].type; in scarlett2_compressor_ctl_info()
5444 uinfo->count = 1; in scarlett2_compressor_ctl_info()
5445 uinfo->value.integer.min = compressor_params[control].min; in scarlett2_compressor_ctl_info()
5446 uinfo->value.integer.max = compressor_params[control].max; in scarlett2_compressor_ctl_info()
5447 uinfo->value.integer.step = 1; in scarlett2_compressor_ctl_info()
5459 /*** DSP Pre-Compressor and PEQ Filter Controls ***/
5464 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_precomp_flt_switch_ctl_get()
5465 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_precomp_flt_switch_ctl_get()
5467 ucontrol->value.integer.value[0] = private->precomp_flt_switch[elem->control]; in scarlett2_precomp_flt_switch_ctl_get()
5475 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_peq_flt_switch_ctl_get()
5476 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_peq_flt_switch_ctl_get()
5478 ucontrol->value.integer.value[0] = in scarlett2_peq_flt_switch_ctl_get()
5479 private->peq_flt_switch[elem->control]; in scarlett2_peq_flt_switch_ctl_get()
5487 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_precomp_flt_switch_ctl_put()
5488 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_precomp_flt_switch_ctl_put()
5489 struct scarlett2_data *private = mixer->private_data; in scarlett2_precomp_flt_switch_ctl_put()
5492 mutex_lock(&private->data_mutex); in scarlett2_precomp_flt_switch_ctl_put()
5494 if (private->hwdep_in_use) { in scarlett2_precomp_flt_switch_ctl_put()
5495 err = -EBUSY; in scarlett2_precomp_flt_switch_ctl_put()
5499 oval = private->precomp_flt_switch[elem->control]; in scarlett2_precomp_flt_switch_ctl_put()
5500 val = ucontrol->value.integer.value[0]; in scarlett2_precomp_flt_switch_ctl_put()
5505 private->precomp_flt_switch[elem->control] = val; in scarlett2_precomp_flt_switch_ctl_put()
5507 /* Send change to the device */ in scarlett2_precomp_flt_switch_ctl_put()
5510 elem->control, val); in scarlett2_precomp_flt_switch_ctl_put()
5515 mutex_unlock(&private->data_mutex); in scarlett2_precomp_flt_switch_ctl_put()
5522 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_peq_flt_switch_ctl_put()
5523 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_peq_flt_switch_ctl_put()
5524 struct scarlett2_data *private = mixer->private_data; in scarlett2_peq_flt_switch_ctl_put()
5527 mutex_lock(&private->data_mutex); in scarlett2_peq_flt_switch_ctl_put()
5529 if (private->hwdep_in_use) { in scarlett2_peq_flt_switch_ctl_put()
5530 err = -EBUSY; in scarlett2_peq_flt_switch_ctl_put()
5534 oval = private->peq_flt_switch[elem->control]; in scarlett2_peq_flt_switch_ctl_put()
5535 val = ucontrol->value.integer.value[0]; in scarlett2_peq_flt_switch_ctl_put()
5540 private->peq_flt_switch[elem->control] = val; in scarlett2_peq_flt_switch_ctl_put()
5542 /* Send change to the device */ in scarlett2_peq_flt_switch_ctl_put()
5545 elem->control, val); in scarlett2_peq_flt_switch_ctl_put()
5550 mutex_unlock(&private->data_mutex); in scarlett2_peq_flt_switch_ctl_put()
5572 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_filter_values()
5573 const struct scarlett2_device_info *info = private->info; in scarlett2_update_filter_values()
5579 if (!info->dsp_input_count) in scarlett2_update_filter_values()
5585 info->dsp_input_count, private->precomp_flt_switch); in scarlett2_update_filter_values()
5591 info->dsp_input_count * info->peq_flt_count, in scarlett2_update_filter_values()
5592 private->peq_flt_switch); in scarlett2_update_filter_values()
5596 /* Get pre-compressor filter values directly */ in scarlett2_update_filter_values()
5599 info->dsp_input_count * in scarlett2_update_filter_values()
5600 info->precomp_flt_count * in scarlett2_update_filter_values()
5602 private->precomp_flt_values); in scarlett2_update_filter_values()
5607 /* PEQ filter values need to be copied via buffer because of in scarlett2_update_filter_values()
5608 * padding after peq_flt_count up to peq_flt_total_count in scarlett2_update_filter_values()
5612 info->dsp_input_count * in scarlett2_update_filter_values()
5613 info->peq_flt_total_count * in scarlett2_update_filter_values()
5619 for (i = 0, dst_idx = 0; i < info->dsp_input_count; i++) { in scarlett2_update_filter_values()
5621 info->peq_flt_total_count * in scarlett2_update_filter_values()
5623 for (j = 0; j < info->peq_flt_count; j++) in scarlett2_update_filter_values()
5627 private->peq_flt_values[dst_idx] = in scarlett2_update_filter_values()
5637 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_precomp_flt_ctl_get()
5638 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_precomp_flt_ctl_get()
5641 for (i = 0, idx = elem->control * SCARLETT2_BIQUAD_COEFFS; in scarlett2_precomp_flt_ctl_get()
5644 ucontrol->value.integer.value[i] = in scarlett2_precomp_flt_ctl_get()
5645 private->precomp_flt_values[idx]; in scarlett2_precomp_flt_ctl_get()
5653 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_peq_flt_ctl_get()
5654 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_peq_flt_ctl_get()
5657 for (i = 0, idx = elem->control * SCARLETT2_BIQUAD_COEFFS; in scarlett2_peq_flt_ctl_get()
5660 ucontrol->value.integer.value[i] = in scarlett2_peq_flt_ctl_get()
5661 private->peq_flt_values[idx]; in scarlett2_peq_flt_ctl_get()
5669 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_precomp_flt_ctl_put()
5670 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_precomp_flt_ctl_put()
5671 struct scarlett2_data *private = mixer->private_data; in scarlett2_precomp_flt_ctl_put()
5673 int index = elem->control * SCARLETT2_BIQUAD_COEFFS; in scarlett2_precomp_flt_ctl_put()
5676 mutex_lock(&private->data_mutex); in scarlett2_precomp_flt_ctl_put()
5678 if (private->hwdep_in_use) { in scarlett2_precomp_flt_ctl_put()
5679 err = -EBUSY; in scarlett2_precomp_flt_ctl_put()
5689 oval = private->precomp_flt_values[index + i]; in scarlett2_precomp_flt_ctl_put()
5690 val = ucontrol->value.integer.value[i]; in scarlett2_precomp_flt_ctl_put()
5700 private->precomp_flt_values[index + i] = in scarlett2_precomp_flt_ctl_put()
5701 ucontrol->value.integer.value[i]; in scarlett2_precomp_flt_ctl_put()
5703 /* Send change to the device */ in scarlett2_precomp_flt_ctl_put()
5705 mixer, private->config_set->param_buf_addr, 1, index); in scarlett2_precomp_flt_ctl_put()
5712 &private->precomp_flt_values[index]); in scarlett2_precomp_flt_ctl_put()
5718 mutex_unlock(&private->data_mutex); in scarlett2_precomp_flt_ctl_put()
5725 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_peq_flt_ctl_put()
5726 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_peq_flt_ctl_put()
5727 struct scarlett2_data *private = mixer->private_data; in scarlett2_peq_flt_ctl_put()
5728 const struct scarlett2_device_info *info = private->info; in scarlett2_peq_flt_ctl_put()
5730 int src_index = elem->control * SCARLETT2_BIQUAD_COEFFS; in scarlett2_peq_flt_ctl_put()
5732 elem->control / in scarlett2_peq_flt_ctl_put()
5733 info->peq_flt_count * in scarlett2_peq_flt_ctl_put()
5734 info->peq_flt_total_count + in scarlett2_peq_flt_ctl_put()
5735 elem->control % info->peq_flt_count in scarlett2_peq_flt_ctl_put()
5739 mutex_lock(&private->data_mutex); in scarlett2_peq_flt_ctl_put()
5741 if (private->hwdep_in_use) { in scarlett2_peq_flt_ctl_put()
5742 err = -EBUSY; in scarlett2_peq_flt_ctl_put()
5752 oval = private->peq_flt_values[src_index + i]; in scarlett2_peq_flt_ctl_put()
5753 val = ucontrol->value.integer.value[i]; in scarlett2_peq_flt_ctl_put()
5763 private->peq_flt_values[src_index + i] = in scarlett2_peq_flt_ctl_put()
5764 ucontrol->value.integer.value[i]; in scarlett2_peq_flt_ctl_put()
5766 /* Send change to the device */ in scarlett2_peq_flt_ctl_put()
5768 mixer, private->config_set->param_buf_addr, 1, dst_index); in scarlett2_peq_flt_ctl_put()
5775 &private->peq_flt_values[src_index]); in scarlett2_peq_flt_ctl_put()
5781 mutex_unlock(&private->data_mutex); in scarlett2_peq_flt_ctl_put()
5788 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_flt_ctl_info()
5789 uinfo->count = SCARLETT2_BIQUAD_COEFFS; in scarlett2_flt_ctl_info()
5790 uinfo->value.integer.min = INT_MIN; in scarlett2_flt_ctl_info()
5791 uinfo->value.integer.max = INT_MAX; in scarlett2_flt_ctl_info()
5792 uinfo->value.integer.step = 1; in scarlett2_flt_ctl_info()
5816 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_mute()
5817 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_mute()
5819 private->input_mute_updated = 0; in scarlett2_update_input_mute()
5821 if (!info->mute_input_count) in scarlett2_update_input_mute()
5826 info->mute_input_count, private->input_mute_switch); in scarlett2_update_input_mute()
5832 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_mute_ctl_get()
5833 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_mute_ctl_get()
5834 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_mute_ctl_get()
5837 mutex_lock(&private->data_mutex); in scarlett2_input_mute_ctl_get()
5839 if (private->hwdep_in_use) { in scarlett2_input_mute_ctl_get()
5840 err = -EBUSY; in scarlett2_input_mute_ctl_get()
5844 if (private->input_mute_updated) { in scarlett2_input_mute_ctl_get()
5849 ucontrol->value.integer.value[0] = in scarlett2_input_mute_ctl_get()
5850 private->input_mute_switch[elem->control]; in scarlett2_input_mute_ctl_get()
5853 mutex_unlock(&private->data_mutex); in scarlett2_input_mute_ctl_get()
5860 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_mute_ctl_put()
5861 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_mute_ctl_put()
5862 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_mute_ctl_put()
5864 int index = elem->control; in scarlett2_input_mute_ctl_put()
5867 mutex_lock(&private->data_mutex); in scarlett2_input_mute_ctl_put()
5869 if (private->hwdep_in_use) { in scarlett2_input_mute_ctl_put()
5870 err = -EBUSY; in scarlett2_input_mute_ctl_put()
5878 oval = private->input_mute_switch[index]; in scarlett2_input_mute_ctl_put()
5879 val = ucontrol->value.integer.value[0]; in scarlett2_input_mute_ctl_put()
5884 private->input_mute_switch[index] = val; in scarlett2_input_mute_ctl_put()
5886 /* Send switch change to the device */ in scarlett2_input_mute_ctl_put()
5894 mutex_unlock(&private->data_mutex); in scarlett2_input_mute_ctl_put()
5910 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_phantom()
5911 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_phantom()
5914 private->input_phantom_updated = 0; in scarlett2_update_input_phantom()
5916 if (!info->phantom_count) in scarlett2_update_input_phantom()
5921 info->phantom_count, private->phantom_switch); in scarlett2_update_input_phantom()
5929 1, &private->phantom_persistence); in scarlett2_update_input_phantom()
5941 const struct scarlett2_device_info *info = private->info; in scarlett2_phantom_is_switching()
5942 int index = line_num / info->inputs_per_phantom; in scarlett2_phantom_is_switching()
5944 return !!(private->phantom_switch[index] & 0x02); in scarlett2_phantom_is_switching()
5950 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_update_access()
5951 const struct scarlett2_device_info *info = private->info; in scarlett2_phantom_update_access()
5955 for (i = 0; i < info->gain_input_count; i++) { in scarlett2_phantom_update_access()
5958 scarlett2_set_ctl_access(private->autogain_ctls[i], val); in scarlett2_phantom_update_access()
5967 struct snd_card *card = mixer->chip->card; in scarlett2_phantom_notify_access()
5968 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_notify_access()
5969 const struct scarlett2_device_info *info = private->info; in scarlett2_phantom_notify_access()
5972 for (i = 0; i < info->gain_input_count; i++) in scarlett2_phantom_notify_access()
5974 &private->autogain_ctls[i]->id); in scarlett2_phantom_notify_access()
5983 struct scarlett2_data *private = mixer->private_data; in scarlett2_check_input_phantom_updated()
5986 if (!private->input_phantom_updated) in scarlett2_check_input_phantom_updated()
6001 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_ctl_get()
6002 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_phantom_ctl_get()
6003 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_ctl_get()
6006 mutex_lock(&private->data_mutex); in scarlett2_phantom_ctl_get()
6008 if (private->hwdep_in_use) { in scarlett2_phantom_ctl_get()
6009 err = -EBUSY; in scarlett2_phantom_ctl_get()
6017 ucontrol->value.integer.value[0] = scarlett2_decode_muteable( in scarlett2_phantom_ctl_get()
6018 private->phantom_switch[elem->control]); in scarlett2_phantom_ctl_get()
6021 mutex_unlock(&private->data_mutex); in scarlett2_phantom_ctl_get()
6028 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_ctl_put()
6029 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_phantom_ctl_put()
6030 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_ctl_put()
6031 const struct scarlett2_device_info *info = private->info; in scarlett2_phantom_ctl_put()
6033 int index = elem->control; in scarlett2_phantom_ctl_put()
6036 mutex_lock(&private->data_mutex); in scarlett2_phantom_ctl_put()
6038 if (private->hwdep_in_use) { in scarlett2_phantom_ctl_put()
6039 err = -EBUSY; in scarlett2_phantom_ctl_put()
6047 oval = private->phantom_switch[index]; in scarlett2_phantom_ctl_put()
6048 val = !!ucontrol->value.integer.value[0]; in scarlett2_phantom_ctl_put()
6053 private->phantom_switch[index] = val; in scarlett2_phantom_ctl_put()
6055 /* To set the Gen 4 muteable controls, bit 1 gets set */ in scarlett2_phantom_ctl_put()
6056 if (private->config_set->items[SCARLETT2_CONFIG_PHANTOM_SWITCH].mute) in scarlett2_phantom_ctl_put()
6059 /* Send switch change to the device */ in scarlett2_phantom_ctl_put()
6061 index + info->phantom_first, val); in scarlett2_phantom_ctl_put()
6069 mutex_unlock(&private->data_mutex); in scarlett2_phantom_ctl_put()
6086 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_persistence_ctl_get()
6087 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_phantom_persistence_ctl_get()
6089 ucontrol->value.integer.value[0] = private->phantom_persistence; in scarlett2_phantom_persistence_ctl_get()
6096 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_persistence_ctl_put()
6097 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_phantom_persistence_ctl_put()
6098 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_persistence_ctl_put()
6100 int index = elem->control; in scarlett2_phantom_persistence_ctl_put()
6103 mutex_lock(&private->data_mutex); in scarlett2_phantom_persistence_ctl_put()
6105 if (private->hwdep_in_use) { in scarlett2_phantom_persistence_ctl_put()
6106 err = -EBUSY; in scarlett2_phantom_persistence_ctl_put()
6110 oval = private->phantom_persistence; in scarlett2_phantom_persistence_ctl_put()
6111 val = !!ucontrol->value.integer.value[0]; in scarlett2_phantom_persistence_ctl_put()
6116 private->phantom_persistence = val; in scarlett2_phantom_persistence_ctl_put()
6118 /* Send switch change to the device */ in scarlett2_phantom_persistence_ctl_put()
6125 mutex_unlock(&private->data_mutex); in scarlett2_phantom_persistence_ctl_put()
6141 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_monitor_other()
6142 const struct scarlett2_device_info *info = private->info; in scarlett2_update_monitor_other()
6155 private->monitor_other_updated = 0; in scarlett2_update_monitor_other()
6160 if (!info->has_speaker_switching) in scarlett2_update_monitor_other()
6176 private->speaker_switching_switch = 0; in scarlett2_update_monitor_other()
6178 private->speaker_switching_switch = monitor_other_switch[0] + 1; in scarlett2_update_monitor_other()
6180 if (info->has_talkback) { in scarlett2_update_monitor_other()
6185 private->talkback_switch = 0; in scarlett2_update_monitor_other()
6187 private->talkback_switch = monitor_other_switch[1] + 1; in scarlett2_update_monitor_other()
6194 for (i = 0; i < private->num_mix_out; i++, bitmap >>= 1) in scarlett2_update_monitor_other()
6195 private->talkback_map[i] = bitmap & 1; in scarlett2_update_monitor_other()
6214 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_speaker_switch_enum_ctl_get()
6215 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_speaker_switch_enum_ctl_get()
6216 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_enum_ctl_get()
6219 mutex_lock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_get()
6221 if (private->hwdep_in_use) { in scarlett2_speaker_switch_enum_ctl_get()
6222 err = -EBUSY; in scarlett2_speaker_switch_enum_ctl_get()
6226 if (private->monitor_other_updated) { in scarlett2_speaker_switch_enum_ctl_get()
6231 ucontrol->value.enumerated.item[0] = private->speaker_switching_switch; in scarlett2_speaker_switch_enum_ctl_get()
6234 mutex_unlock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_get()
6239 * to HW volume and disable those controls
6243 struct snd_card *card = mixer->chip->card; in scarlett2_speaker_switch_enable()
6244 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_enable()
6250 /* switch the main/alt speakers to HW volume */ in scarlett2_speaker_switch_enable()
6251 if (!private->vol_sw_hw_switch[index]) { in scarlett2_speaker_switch_enable()
6252 err = scarlett2_sw_hw_change(private->mixer, i, 1); in scarlett2_speaker_switch_enable()
6262 &private->sw_hw_ctls[i]->id); in scarlett2_speaker_switch_enable()
6265 /* when the next monitor-other notify comes in, update the mux in scarlett2_speaker_switch_enable()
6268 private->speaker_switching_switched = 1; in scarlett2_speaker_switch_enable()
6278 struct snd_card *card = mixer->chip->card; in scarlett2_speaker_switch_disable()
6279 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_disable()
6286 &private->sw_hw_ctls[i]->id); in scarlett2_speaker_switch_disable()
6289 /* when the next monitor-other notify comes in, update the mux in scarlett2_speaker_switch_disable()
6292 private->speaker_switching_switched = 1; in scarlett2_speaker_switch_disable()
6298 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_speaker_switch_enum_ctl_put()
6299 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_speaker_switch_enum_ctl_put()
6300 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_enum_ctl_put()
6304 mutex_lock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_put()
6306 if (private->hwdep_in_use) { in scarlett2_speaker_switch_enum_ctl_put()
6307 err = -EBUSY; in scarlett2_speaker_switch_enum_ctl_put()
6311 oval = private->speaker_switching_switch; in scarlett2_speaker_switch_enum_ctl_put()
6312 val = min(ucontrol->value.enumerated.item[0], 2U); in scarlett2_speaker_switch_enum_ctl_put()
6317 private->speaker_switching_switch = val; in scarlett2_speaker_switch_enum_ctl_put()
6343 mutex_unlock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_put()
6357 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_speaker_switch_ctl()
6358 const struct scarlett2_device_info *info = private->info; in scarlett2_add_speaker_switch_ctl()
6360 if (!info->has_speaker_switching) in scarlett2_add_speaker_switch_ctl()
6366 &private->speaker_switching_ctl); in scarlett2_add_speaker_switch_ctl()
6384 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_enum_ctl_get()
6385 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_enum_ctl_get()
6386 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_enum_ctl_get()
6389 mutex_lock(&private->data_mutex); in scarlett2_talkback_enum_ctl_get()
6391 if (private->hwdep_in_use) { in scarlett2_talkback_enum_ctl_get()
6392 err = -EBUSY; in scarlett2_talkback_enum_ctl_get()
6396 if (private->monitor_other_updated) { in scarlett2_talkback_enum_ctl_get()
6401 ucontrol->value.enumerated.item[0] = private->talkback_switch; in scarlett2_talkback_enum_ctl_get()
6404 mutex_unlock(&private->data_mutex); in scarlett2_talkback_enum_ctl_get()
6411 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_enum_ctl_put()
6412 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_enum_ctl_put()
6413 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_enum_ctl_put()
6417 mutex_lock(&private->data_mutex); in scarlett2_talkback_enum_ctl_put()
6419 if (private->hwdep_in_use) { in scarlett2_talkback_enum_ctl_put()
6420 err = -EBUSY; in scarlett2_talkback_enum_ctl_put()
6424 oval = private->talkback_switch; in scarlett2_talkback_enum_ctl_put()
6425 val = min(ucontrol->value.enumerated.item[0], 2U); in scarlett2_talkback_enum_ctl_put()
6430 private->talkback_switch = val; in scarlett2_talkback_enum_ctl_put()
6447 mutex_unlock(&private->data_mutex); in scarlett2_talkback_enum_ctl_put()
6462 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_map_ctl_get()
6463 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_map_ctl_get()
6464 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_map_ctl_get()
6465 int index = elem->control; in scarlett2_talkback_map_ctl_get()
6467 ucontrol->value.integer.value[0] = private->talkback_map[index]; in scarlett2_talkback_map_ctl_get()
6475 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_map_ctl_put()
6476 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_map_ctl_put()
6477 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_map_ctl_put()
6478 int index = elem->control; in scarlett2_talkback_map_ctl_put()
6482 mutex_lock(&private->data_mutex); in scarlett2_talkback_map_ctl_put()
6484 if (private->hwdep_in_use) { in scarlett2_talkback_map_ctl_put()
6485 err = -EBUSY; in scarlett2_talkback_map_ctl_put()
6489 oval = private->talkback_map[index]; in scarlett2_talkback_map_ctl_put()
6490 val = !!ucontrol->value.integer.value[0]; in scarlett2_talkback_map_ctl_put()
6495 private->talkback_map[index] = val; in scarlett2_talkback_map_ctl_put()
6497 for (i = 0; i < private->num_mix_out; i++) in scarlett2_talkback_map_ctl_put()
6498 bitmap |= private->talkback_map[i] << i; in scarlett2_talkback_map_ctl_put()
6500 /* Send updated bitmap to the device */ in scarlett2_talkback_map_ctl_put()
6507 mutex_unlock(&private->data_mutex); in scarlett2_talkback_map_ctl_put()
6521 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_talkback_ctls()
6522 const struct scarlett2_device_info *info = private->info; in scarlett2_add_talkback_ctls()
6526 if (!info->has_talkback) in scarlett2_add_talkback_ctls()
6532 &private->talkback_ctl); in scarlett2_add_talkback_ctls()
6536 for (i = 0; i < private->num_mix_out; i++) { in scarlett2_add_talkback_ctls()
6553 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dim_mute_ctl_get()
6554 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dim_mute_ctl_get()
6555 struct scarlett2_data *private = mixer->private_data; in scarlett2_dim_mute_ctl_get()
6558 mutex_lock(&private->data_mutex); in scarlett2_dim_mute_ctl_get()
6560 if (private->hwdep_in_use) { in scarlett2_dim_mute_ctl_get()
6561 err = -EBUSY; in scarlett2_dim_mute_ctl_get()
6565 if (private->dim_mute_updated) { in scarlett2_dim_mute_ctl_get()
6570 ucontrol->value.integer.value[0] = private->dim_mute[elem->control]; in scarlett2_dim_mute_ctl_get()
6573 mutex_unlock(&private->data_mutex); in scarlett2_dim_mute_ctl_get()
6580 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dim_mute_ctl_put()
6581 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dim_mute_ctl_put()
6582 struct scarlett2_data *private = mixer->private_data; in scarlett2_dim_mute_ctl_put()
6583 int index = elem->control; in scarlett2_dim_mute_ctl_put()
6586 mutex_lock(&private->data_mutex); in scarlett2_dim_mute_ctl_put()
6588 if (private->hwdep_in_use) { in scarlett2_dim_mute_ctl_put()
6589 err = -EBUSY; in scarlett2_dim_mute_ctl_put()
6593 oval = private->dim_mute[index]; in scarlett2_dim_mute_ctl_put()
6594 val = !!ucontrol->value.integer.value[0]; in scarlett2_dim_mute_ctl_put()
6599 private->dim_mute[index] = val; in scarlett2_dim_mute_ctl_put()
6601 /* Send switch change to the device */ in scarlett2_dim_mute_ctl_put()
6608 for (i = 0; i < private->num_line_out; i++) { in scarlett2_dim_mute_ctl_put()
6611 if (private->vol_sw_hw_switch[line_index]) { in scarlett2_dim_mute_ctl_put()
6612 private->mute_switch[line_index] = val; in scarlett2_dim_mute_ctl_put()
6613 snd_ctl_notify(mixer->chip->card, in scarlett2_dim_mute_ctl_put()
6615 &private->mute_ctls[i]->id); in scarlett2_dim_mute_ctl_put()
6620 mutex_unlock(&private->data_mutex); in scarlett2_dim_mute_ctl_put()
6636 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_line_out_ctls()
6637 const struct scarlett2_device_info *info = private->info; in scarlett2_add_line_out_ctls()
6647 0, 1, s, &private->master_vol_ctl); in scarlett2_add_line_out_ctls()
6659 &private->headphone_vol_ctl); in scarlett2_add_line_out_ctls()
6665 * has per-channel line-out volume controls. in scarlett2_add_line_out_ctls()
6672 for (i = 0; i < private->num_line_out; i++) { in scarlett2_add_line_out_ctls()
6676 if (info->line_out_descrs[i]) in scarlett2_add_line_out_ctls()
6679 i + 1, info->line_out_descrs[i]); in scarlett2_add_line_out_ctls()
6686 i, 1, s, &private->vol_ctls[i]); in scarlett2_add_line_out_ctls()
6697 &private->mute_ctls[i]); in scarlett2_add_line_out_ctls()
6705 /* Make the fader and mute controls read-only if the in scarlett2_add_line_out_ctls()
6706 * SW/HW switch is set to HW in scarlett2_add_line_out_ctls()
6708 if (private->vol_sw_hw_switch[index]) in scarlett2_add_line_out_ctls()
6717 &private->sw_hw_ctls[i]); in scarlett2_add_line_out_ctls()
6721 /* Make the switch read-only if the line is in scarlett2_add_line_out_ctls()
6724 if (private->speaker_switching_switch && i < 4) in scarlett2_add_line_out_ctls()
6735 &private->dim_mute_ctls[i]); in scarlett2_add_line_out_ctls()
6747 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_dsp_ctls()
6748 const struct scarlett2_device_info *info = private->info; in scarlett2_add_dsp_ctls()
6760 scnprintf(s, sizeof(s), compr_fmt, i + 1, param->name); in scarlett2_add_dsp_ctls()
6764 1, s, &private->compressor_ctls[idx]); in scarlett2_add_dsp_ctls()
6770 scnprintf(s, sizeof(s), flt_switch_fmt, i + 1, "Pre-Comp"); in scarlett2_add_dsp_ctls()
6773 i, 1, s, &private->precomp_flt_switch_ctls[i]); in scarlett2_add_dsp_ctls()
6780 i, 1, s, &private->peq_flt_switch_ctls[i]); in scarlett2_add_dsp_ctls()
6785 for (j = 0; j < info->precomp_flt_count; j++) { in scarlett2_add_dsp_ctls()
6786 scnprintf(s, sizeof(s), flt_fmt, i + 1, "Pre-Comp", j + 1); in scarlett2_add_dsp_ctls()
6789 i * info->precomp_flt_count + j, in scarlett2_add_dsp_ctls()
6790 1, s, &private->precomp_flt_switch_ctls[j]); in scarlett2_add_dsp_ctls()
6795 for (j = 0; j < info->peq_flt_count; j++) { in scarlett2_add_dsp_ctls()
6799 i * info->peq_flt_count + j, in scarlett2_add_dsp_ctls()
6800 1, s, &private->peq_flt_switch_ctls[j]); in scarlett2_add_dsp_ctls()
6810 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_line_in_ctls()
6811 const struct scarlett2_device_info *info = private->info; in scarlett2_add_line_in_ctls()
6815 const char *fmt2 = "Line In %d-%d %s Capture %s"; in scarlett2_add_line_in_ctls()
6818 for (i = 0; i < info->level_input_count; i++) { in scarlett2_add_line_in_ctls()
6819 scnprintf(s, sizeof(s), fmt, i + 1 + info->level_input_first, in scarlett2_add_line_in_ctls()
6822 i, 1, s, &private->level_ctls[i]); in scarlett2_add_line_in_ctls()
6828 for (i = 0; i < info->pad_input_count; i++) { in scarlett2_add_line_in_ctls()
6831 i, 1, s, &private->pad_ctls[i]); in scarlett2_add_line_in_ctls()
6837 for (i = 0; i < info->air_input_count; i++) { in scarlett2_add_line_in_ctls()
6838 scnprintf(s, sizeof(s), fmt, i + 1 + info->air_input_first, in scarlett2_add_line_in_ctls()
6839 "Air", info->air_option ? "Enum" : "Switch"); in scarlett2_add_line_in_ctls()
6841 mixer, &scarlett2_air_ctl[info->air_option], in scarlett2_add_line_in_ctls()
6842 i, 1, s, &private->air_ctls[i]); in scarlett2_add_line_in_ctls()
6848 for (i = 0; i < info->dsp_input_count; i++) { in scarlett2_add_line_in_ctls()
6851 i, 1, s, &private->dsp_ctls[i]); in scarlett2_add_line_in_ctls()
6861 for (i = 0; i < info->mute_input_count; i++) { in scarlett2_add_line_in_ctls()
6865 i, 1, s, &private->input_mute_ctls[i]); in scarlett2_add_line_in_ctls()
6871 if (info->inputs_per_phantom == 1) { in scarlett2_add_line_in_ctls()
6872 for (i = 0; i < info->phantom_count; i++) { in scarlett2_add_line_in_ctls()
6874 i + 1 + info->phantom_first, in scarlett2_add_line_in_ctls()
6878 i, 1, s, &private->phantom_ctls[i]); in scarlett2_add_line_in_ctls()
6882 } else if (info->inputs_per_phantom > 1) { in scarlett2_add_line_in_ctls()
6883 for (i = 0; i < info->phantom_count; i++) { in scarlett2_add_line_in_ctls()
6884 int from = i * info->inputs_per_phantom + 1; in scarlett2_add_line_in_ctls()
6885 int to = (i + 1) * info->inputs_per_phantom; in scarlett2_add_line_in_ctls() local
6887 scnprintf(s, sizeof(s), fmt2, from, to, in scarlett2_add_line_in_ctls()
6891 i, 1, s, &private->phantom_ctls[i]); in scarlett2_add_line_in_ctls()
6896 if (info->phantom_count && in scarlett2_add_line_in_ctls()
6912 &private->input_select_ctl); in scarlett2_add_line_in_ctls()
6919 for (i = 0; i < info->gain_input_count / 2; i++) { in scarlett2_add_line_in_ctls()
6921 "Line In %d-%d Link Capture Switch", in scarlett2_add_line_in_ctls()
6925 i, 1, s, &private->input_link_ctls[i]); in scarlett2_add_line_in_ctls()
6931 /* Add software-controllable input gain controls */ in scarlett2_add_line_in_ctls()
6932 for (i = 0; i < info->gain_input_count; i++) { in scarlett2_add_line_in_ctls()
6937 i, 1, s, &private->input_gain_ctls[i]); in scarlett2_add_line_in_ctls()
6940 private->input_gain_ctls[i]->tlv.p = in scarlett2_add_line_in_ctls()
6941 private->config_set->input_gain_tlv; in scarlett2_add_line_in_ctls()
6947 i, 1, s, &private->autogain_ctls[i]); in scarlett2_add_line_in_ctls()
6955 i, 1, s, &private->autogain_status_ctls[i]); in scarlett2_add_line_in_ctls()
6967 i, 1, s, &private->ag_target_ctls[i]); in scarlett2_add_line_in_ctls()
6972 /* Add safe-mode input switch controls */ in scarlett2_add_line_in_ctls()
6973 for (i = 0; i < info->safe_input_count; i++) { in scarlett2_add_line_in_ctls()
6978 i, 1, s, &private->safe_ctls[i]); in scarlett2_add_line_in_ctls()
6989 &private->pcm_input_switch_ctl); in scarlett2_add_line_in_ctls()
7001 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_mix()
7004 private->mix_updated = 0; in scarlett2_update_mix()
7006 for (i = 0; i < private->num_mix_out; i++) { in scarlett2_update_mix()
7018 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mixer_ctl_info()
7020 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_mixer_ctl_info()
7021 uinfo->count = elem->channels; in scarlett2_mixer_ctl_info()
7022 uinfo->value.integer.min = 0; in scarlett2_mixer_ctl_info()
7023 uinfo->value.integer.max = SCARLETT2_MIXER_MAX_VALUE; in scarlett2_mixer_ctl_info()
7024 uinfo->value.integer.step = 1; in scarlett2_mixer_ctl_info()
7031 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mixer_ctl_get()
7032 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mixer_ctl_get()
7033 struct scarlett2_data *private = mixer->private_data; in scarlett2_mixer_ctl_get()
7036 mutex_lock(&private->data_mutex); in scarlett2_mixer_ctl_get()
7038 if (private->hwdep_in_use) { in scarlett2_mixer_ctl_get()
7039 err = -EBUSY; in scarlett2_mixer_ctl_get()
7043 if (private->mix_updated) { in scarlett2_mixer_ctl_get()
7048 ucontrol->value.integer.value[0] = private->mix[elem->control]; in scarlett2_mixer_ctl_get()
7051 mutex_unlock(&private->data_mutex); in scarlett2_mixer_ctl_get()
7058 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mixer_ctl_put()
7059 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mixer_ctl_put()
7060 struct scarlett2_data *private = mixer->private_data; in scarlett2_mixer_ctl_put()
7062 int index = elem->control; in scarlett2_mixer_ctl_put()
7064 mutex_lock(&private->data_mutex); in scarlett2_mixer_ctl_put()
7066 if (private->hwdep_in_use) { in scarlett2_mixer_ctl_put()
7067 err = -EBUSY; in scarlett2_mixer_ctl_put()
7071 oval = private->mix[index]; in scarlett2_mixer_ctl_put()
7072 val = clamp(ucontrol->value.integer.value[0], in scarlett2_mixer_ctl_put()
7074 mix_num = index / private->num_mix_in; in scarlett2_mixer_ctl_put()
7079 private->mix[index] = val; in scarlett2_mixer_ctl_put()
7085 mutex_unlock(&private->data_mutex); in scarlett2_mixer_ctl_put()
7109 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_mixer_ctls()
7114 for (i = 0, index = 0; i < private->num_mix_out; i++) in scarlett2_add_mixer_ctls()
7115 for (j = 0; j < private->num_mix_in; j++, index++) { in scarlett2_add_mixer_ctls()
7121 &private->mix_ctls[index]); in scarlett2_add_mixer_ctls()
7133 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_direct_monitor()
7135 private->direct_monitor_updated = 0; in scarlett2_update_direct_monitor()
7137 if (!private->info->direct_monitor) in scarlett2_update_direct_monitor()
7142 1, &private->direct_monitor_switch); in scarlett2_update_direct_monitor()
7147 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_monitor_mix()
7151 if (!private->num_monitor_mix_ctls) in scarlett2_update_monitor_mix()
7156 private->num_monitor_mix_ctls, mix_values); in scarlett2_update_monitor_mix()
7160 for (i = 0; i < private->num_monitor_mix_ctls; i++) in scarlett2_update_monitor_mix()
7161 private->monitor_mix[i] = scarlett2_mixer_value_to_db( in scarlett2_update_monitor_mix()
7170 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_direct_monitor_ctl_get()
7171 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_direct_monitor_ctl_get()
7172 struct scarlett2_data *private = mixer->private_data; in scarlett2_direct_monitor_ctl_get()
7175 mutex_lock(&private->data_mutex); in scarlett2_direct_monitor_ctl_get()
7177 if (private->hwdep_in_use) { in scarlett2_direct_monitor_ctl_get()
7178 err = -EBUSY; in scarlett2_direct_monitor_ctl_get()
7182 if (private->direct_monitor_updated) { in scarlett2_direct_monitor_ctl_get()
7187 ucontrol->value.enumerated.item[0] = private->direct_monitor_switch; in scarlett2_direct_monitor_ctl_get()
7190 mutex_unlock(&private->data_mutex); in scarlett2_direct_monitor_ctl_get()
7197 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_direct_monitor_ctl_put()
7198 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_direct_monitor_ctl_put()
7199 struct scarlett2_data *private = mixer->private_data; in scarlett2_direct_monitor_ctl_put()
7201 int index = elem->control; in scarlett2_direct_monitor_ctl_put()
7204 mutex_lock(&private->data_mutex); in scarlett2_direct_monitor_ctl_put()
7206 if (private->hwdep_in_use) { in scarlett2_direct_monitor_ctl_put()
7207 err = -EBUSY; in scarlett2_direct_monitor_ctl_put()
7211 oval = private->direct_monitor_switch; in scarlett2_direct_monitor_ctl_put()
7212 val = min(ucontrol->value.enumerated.item[0], 2U); in scarlett2_direct_monitor_ctl_put()
7217 private->direct_monitor_switch = val; in scarlett2_direct_monitor_ctl_put()
7219 /* Send switch change to the device */ in scarlett2_direct_monitor_ctl_put()
7226 mutex_unlock(&private->data_mutex); in scarlett2_direct_monitor_ctl_put()
7240 /* Direct Monitor for Solo is mono-only and only needs a boolean control
7263 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_monitor_mix_ctl_get()
7264 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_monitor_mix_ctl_get()
7266 ucontrol->value.integer.value[0] = private->monitor_mix[elem->control]; in scarlett2_monitor_mix_ctl_get()
7274 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_monitor_mix_ctl_put()
7275 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_monitor_mix_ctl_put()
7276 struct scarlett2_data *private = mixer->private_data; in scarlett2_monitor_mix_ctl_put()
7278 int index = elem->control; in scarlett2_monitor_mix_ctl_put()
7280 mutex_lock(&private->data_mutex); in scarlett2_monitor_mix_ctl_put()
7282 if (private->hwdep_in_use) { in scarlett2_monitor_mix_ctl_put()
7283 err = -EBUSY; in scarlett2_monitor_mix_ctl_put()
7287 oval = private->monitor_mix[index]; in scarlett2_monitor_mix_ctl_put()
7288 val = clamp(ucontrol->value.integer.value[0], in scarlett2_monitor_mix_ctl_put()
7294 private->monitor_mix[index] = val; in scarlett2_monitor_mix_ctl_put()
7302 mutex_unlock(&private->data_mutex); in scarlett2_monitor_mix_ctl_put()
7320 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_direct_monitor_ctls()
7321 const struct scarlett2_device_info *info = private->info; in scarlett2_add_direct_monitor_ctls()
7325 if (!info->direct_monitor) in scarlett2_add_direct_monitor_ctls()
7328 s = info->direct_monitor == 1 in scarlett2_add_direct_monitor_ctls()
7333 mixer, &scarlett2_direct_monitor_ctl[info->direct_monitor - 1], in scarlett2_add_direct_monitor_ctls()
7334 0, 1, s, &private->direct_monitor_ctl); in scarlett2_add_direct_monitor_ctls()
7338 if (!private->num_monitor_mix_ctls) in scarlett2_add_direct_monitor_ctls()
7342 for (i = 0, index = 0; i < info->direct_monitor; i++) { in scarlett2_add_direct_monitor_ctls()
7347 if (info->direct_monitor == 1) in scarlett2_add_direct_monitor_ctls()
7358 for (k = 0; k < private->num_mix_in; k++, index++) { in scarlett2_add_direct_monitor_ctls()
7380 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mux_src_enum_ctl_info()
7381 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_mux_src_enum_ctl_info()
7382 const struct scarlett2_device_info *info = private->info; in scarlett2_mux_src_enum_ctl_info()
7383 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_mux_src_enum_ctl_info()
7384 unsigned int item = uinfo->value.enumerated.item; in scarlett2_mux_src_enum_ctl_info()
7385 int items = private->num_mux_srcs; in scarlett2_mux_src_enum_ctl_info()
7388 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in scarlett2_mux_src_enum_ctl_info()
7389 uinfo->count = elem->channels; in scarlett2_mux_src_enum_ctl_info()
7390 uinfo->value.enumerated.items = items; in scarlett2_mux_src_enum_ctl_info()
7393 item = uinfo->value.enumerated.item = items - 1; in scarlett2_mux_src_enum_ctl_info()
7403 item >= private->num_mix_out) in scarlett2_mux_src_enum_ctl_info()
7404 sprintf(uinfo->value.enumerated.name, in scarlett2_mux_src_enum_ctl_info()
7405 port->dsp_src_descr, in scarlett2_mux_src_enum_ctl_info()
7406 item - private->num_mix_out + 1); in scarlett2_mux_src_enum_ctl_info()
7408 sprintf(uinfo->value.enumerated.name, in scarlett2_mux_src_enum_ctl_info()
7409 port->src_descr, in scarlett2_mux_src_enum_ctl_info()
7410 item + port->src_num_offset); in scarlett2_mux_src_enum_ctl_info()
7414 item -= port_count[port_type][SCARLETT2_PORT_IN]; in scarlett2_mux_src_enum_ctl_info()
7417 return -EINVAL; in scarlett2_mux_src_enum_ctl_info()
7423 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mux_src_enum_ctl_get()
7424 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mux_src_enum_ctl_get()
7425 struct scarlett2_data *private = mixer->private_data; in scarlett2_mux_src_enum_ctl_get()
7426 int index = line_out_remap(private, elem->control); in scarlett2_mux_src_enum_ctl_get()
7429 mutex_lock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_get()
7431 if (private->hwdep_in_use) { in scarlett2_mux_src_enum_ctl_get()
7432 err = -EBUSY; in scarlett2_mux_src_enum_ctl_get()
7436 if (private->mux_updated) { in scarlett2_mux_src_enum_ctl_get()
7441 ucontrol->value.enumerated.item[0] = private->mux[index]; in scarlett2_mux_src_enum_ctl_get()
7444 mutex_unlock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_get()
7451 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mux_src_enum_ctl_put()
7452 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mux_src_enum_ctl_put()
7453 struct scarlett2_data *private = mixer->private_data; in scarlett2_mux_src_enum_ctl_put()
7454 int index = line_out_remap(private, elem->control); in scarlett2_mux_src_enum_ctl_put()
7457 mutex_lock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_put()
7459 if (private->hwdep_in_use) { in scarlett2_mux_src_enum_ctl_put()
7460 err = -EBUSY; in scarlett2_mux_src_enum_ctl_put()
7464 oval = private->mux[index]; in scarlett2_mux_src_enum_ctl_put()
7465 val = min(ucontrol->value.enumerated.item[0], in scarlett2_mux_src_enum_ctl_put()
7466 private->num_mux_srcs - 1U); in scarlett2_mux_src_enum_ctl_put()
7471 private->mux[index] = val; in scarlett2_mux_src_enum_ctl_put()
7477 mutex_unlock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_put()
7491 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_mux_enums()
7492 const struct scarlett2_device_info *info = private->info; in scarlett2_add_mux_enums()
7493 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_add_mux_enums()
7507 const char *descr = port->dst_descr; in scarlett2_add_mux_enums()
7510 channel >= private->num_mix_in) { in scarlett2_add_mux_enums()
7511 channel_num -= private->num_mix_in; in scarlett2_add_mux_enums()
7512 descr = port->dsp_dst_descr; in scarlett2_add_mux_enums()
7515 snprintf(s, sizeof(s) - 5, descr, channel_num); in scarlett2_add_mux_enums()
7521 &private->mux_ctls[i]); in scarlett2_add_mux_enums()
7535 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_meter_ctl_info()
7537 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_meter_ctl_info()
7538 uinfo->count = elem->channels; in scarlett2_meter_ctl_info()
7539 uinfo->value.integer.min = 0; in scarlett2_meter_ctl_info()
7540 uinfo->value.integer.max = 4095; in scarlett2_meter_ctl_info()
7541 uinfo->value.integer.step = 1; in scarlett2_meter_ctl_info()
7548 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_meter_ctl_get()
7549 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_meter_ctl_get()
7550 struct scarlett2_data *private = mixer->private_data; in scarlett2_meter_ctl_get()
7551 u8 *meter_level_map = private->meter_level_map; in scarlett2_meter_ctl_get()
7555 mutex_lock(&private->data_mutex); in scarlett2_meter_ctl_get()
7557 if (private->hwdep_in_use) { in scarlett2_meter_ctl_get()
7558 err = -EBUSY; in scarlett2_meter_ctl_get()
7562 err = scarlett2_usb_get_meter_levels(mixer, elem->channels, in scarlett2_meter_ctl_get()
7568 for (i = 0; i < elem->channels; i++) { in scarlett2_meter_ctl_get()
7577 ucontrol->value.integer.value[i] = value; in scarlett2_meter_ctl_get()
7581 mutex_unlock(&private->data_mutex); in scarlett2_meter_ctl_get()
7596 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_meter_ctl()
7603 0, private->num_mux_dsts, in scarlett2_add_meter_ctl()
7612 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_msd_ctl_get()
7613 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_msd_ctl_get()
7615 ucontrol->value.integer.value[0] = private->msd_switch; in scarlett2_msd_ctl_get()
7622 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_msd_ctl_put()
7623 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_msd_ctl_put()
7624 struct scarlett2_data *private = mixer->private_data; in scarlett2_msd_ctl_put()
7628 mutex_lock(&private->data_mutex); in scarlett2_msd_ctl_put()
7630 if (private->hwdep_in_use) { in scarlett2_msd_ctl_put()
7631 err = -EBUSY; in scarlett2_msd_ctl_put()
7635 oval = private->msd_switch; in scarlett2_msd_ctl_put()
7636 val = !!ucontrol->value.integer.value[0]; in scarlett2_msd_ctl_put()
7641 private->msd_switch = val; in scarlett2_msd_ctl_put()
7643 /* Send switch change to the device */ in scarlett2_msd_ctl_put()
7650 mutex_unlock(&private->data_mutex); in scarlett2_msd_ctl_put()
7664 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_msd_ctl()
7670 if (!private->msd_switch && !(mixer->chip->setup & SCARLETT2_MSD_ENABLE)) in scarlett2_add_msd_ctl()
7683 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_standalone_ctl_get()
7684 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_standalone_ctl_get()
7686 ucontrol->value.integer.value[0] = private->standalone_switch; in scarlett2_standalone_ctl_get()
7693 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_standalone_ctl_put()
7694 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_standalone_ctl_put()
7695 struct scarlett2_data *private = mixer->private_data; in scarlett2_standalone_ctl_put()
7699 mutex_lock(&private->data_mutex); in scarlett2_standalone_ctl_put()
7701 if (private->hwdep_in_use) { in scarlett2_standalone_ctl_put()
7702 err = -EBUSY; in scarlett2_standalone_ctl_put()
7706 oval = private->standalone_switch; in scarlett2_standalone_ctl_put()
7707 val = !!ucontrol->value.integer.value[0]; in scarlett2_standalone_ctl_put()
7712 private->standalone_switch = val; in scarlett2_standalone_ctl_put()
7714 /* Send switch change to the device */ in scarlett2_standalone_ctl_put()
7722 mutex_unlock(&private->data_mutex); in scarlett2_standalone_ctl_put()
7736 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_standalone_ctl()
7751 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_power_status()
7755 private->power_status_updated = 0; in scarlett2_update_power_status()
7768 private->power_status = SCARLETT2_POWER_STATUS_FAIL; in scarlett2_update_power_status()
7770 private->power_status = SCARLETT2_POWER_STATUS_EXT; in scarlett2_update_power_status()
7772 private->power_status = SCARLETT2_POWER_STATUS_BUS; in scarlett2_update_power_status()
7780 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_power_status_ctl_get()
7781 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_power_status_ctl_get()
7782 struct scarlett2_data *private = mixer->private_data; in scarlett2_power_status_ctl_get()
7785 mutex_lock(&private->data_mutex); in scarlett2_power_status_ctl_get()
7787 if (private->power_status_updated) { in scarlett2_power_status_ctl_get()
7792 ucontrol->value.integer.value[0] = private->power_status; in scarlett2_power_status_ctl_get()
7795 mutex_unlock(&private->data_mutex); in scarlett2_power_status_ctl_get()
7819 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_power_status_ctl()
7828 &private->power_status_ctl); in scarlett2_add_power_status_ctl()
7835 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_bluetooth_volume()
7838 private->bluetooth_updated = 0; in scarlett2_update_bluetooth_volume()
7840 if (!private->info->has_bluetooth) in scarlett2_update_bluetooth_volume()
7845 1, &private->bluetooth_volume); in scarlett2_update_bluetooth_volume()
7855 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_bluetooth_volume_ctl_get()
7856 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_bluetooth_volume_ctl_get()
7857 struct scarlett2_data *private = mixer->private_data; in scarlett2_bluetooth_volume_ctl_get()
7860 mutex_lock(&private->data_mutex); in scarlett2_bluetooth_volume_ctl_get()
7862 if (private->hwdep_in_use) { in scarlett2_bluetooth_volume_ctl_get()
7863 err = -EBUSY; in scarlett2_bluetooth_volume_ctl_get()
7867 if (private->bluetooth_updated) { in scarlett2_bluetooth_volume_ctl_get()
7872 ucontrol->value.integer.value[0] = private->bluetooth_volume; in scarlett2_bluetooth_volume_ctl_get()
7875 mutex_unlock(&private->data_mutex); in scarlett2_bluetooth_volume_ctl_get()
7882 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_bluetooth_volume_ctl_put()
7883 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_bluetooth_volume_ctl_put()
7884 struct scarlett2_data *private = mixer->private_data; in scarlett2_bluetooth_volume_ctl_put()
7887 mutex_lock(&private->data_mutex); in scarlett2_bluetooth_volume_ctl_put()
7889 if (private->hwdep_in_use) { in scarlett2_bluetooth_volume_ctl_put()
7890 err = -EBUSY; in scarlett2_bluetooth_volume_ctl_put()
7894 oval = private->bluetooth_volume; in scarlett2_bluetooth_volume_ctl_put()
7895 val = clamp(ucontrol->value.integer.value[0], in scarlett2_bluetooth_volume_ctl_put()
7901 private->bluetooth_volume = val; in scarlett2_bluetooth_volume_ctl_put()
7909 mutex_unlock(&private->data_mutex); in scarlett2_bluetooth_volume_ctl_put()
7916 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_bluetooth_volume_ctl_info()
7917 uinfo->count = 1; in scarlett2_bluetooth_volume_ctl_info()
7918 uinfo->value.integer.min = 0; in scarlett2_bluetooth_volume_ctl_info()
7919 uinfo->value.integer.max = SCARLETT2_MAX_BLUETOOTH_VOLUME; in scarlett2_bluetooth_volume_ctl_info()
7920 uinfo->value.integer.step = 1; in scarlett2_bluetooth_volume_ctl_info()
7935 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_bluetooth_volume_ctl()
7937 if (!private->info->has_bluetooth) in scarlett2_add_bluetooth_volume_ctl()
7943 &private->bluetooth_volume_ctl); in scarlett2_add_bluetooth_volume_ctl()
7950 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_spdif_mode()
7953 const u8 *mode_values = private->info->spdif_mode_values; in scarlett2_update_spdif_mode()
7955 if (!private->info->spdif_mode_control_name) in scarlett2_update_spdif_mode()
7963 private->spdif_mode = 0; in scarlett2_update_spdif_mode()
7967 private->spdif_mode = i; in scarlett2_update_spdif_mode()
7977 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_spdif_mode_ctl_info()
7978 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_spdif_mode_ctl_info()
7979 const char * const *mode_texts = private->info->spdif_mode_texts; in scarlett2_spdif_mode_ctl_info()
7986 private->info->spdif_mode_texts); in scarlett2_spdif_mode_ctl_info()
7992 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_spdif_mode_ctl_get()
7993 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_spdif_mode_ctl_get()
7995 ucontrol->value.enumerated.item[0] = private->spdif_mode; in scarlett2_spdif_mode_ctl_get()
8002 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_spdif_mode_ctl_put()
8003 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_spdif_mode_ctl_put()
8004 struct scarlett2_data *private = mixer->private_data; in scarlett2_spdif_mode_ctl_put()
8008 mutex_lock(&private->data_mutex); in scarlett2_spdif_mode_ctl_put()
8010 oval = private->spdif_mode; in scarlett2_spdif_mode_ctl_put()
8011 val = ucontrol->value.enumerated.item[0]; in scarlett2_spdif_mode_ctl_put()
8014 err = -EINVAL; in scarlett2_spdif_mode_ctl_put()
8019 if (private->info->spdif_mode_values[i] == 0xff) { in scarlett2_spdif_mode_ctl_put()
8020 err = -EINVAL; in scarlett2_spdif_mode_ctl_put()
8027 private->spdif_mode = val; in scarlett2_spdif_mode_ctl_put()
8031 private->info->spdif_mode_values[val]); in scarlett2_spdif_mode_ctl_put()
8036 mutex_unlock(&private->data_mutex); in scarlett2_spdif_mode_ctl_put()
8050 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_spdif_mode_ctl()
8052 if (!private->info->spdif_mode_control_name) in scarlett2_add_spdif_mode_ctl()
8057 private->info->spdif_mode_control_name, in scarlett2_add_spdif_mode_ctl()
8066 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_sync()
8068 private->sync_updated = 1; in scarlett2_notify_sync()
8070 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_sync()
8071 &private->sync_ctl->id); in scarlett2_notify_sync()
8077 struct snd_card *card = mixer->chip->card; in scarlett2_notify_monitor()
8078 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_monitor()
8084 private->vol_updated = 1; in scarlett2_notify_monitor()
8086 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_monitor()
8087 &private->master_vol_ctl->id); in scarlett2_notify_monitor()
8089 for (i = 0; i < private->num_line_out; i++) in scarlett2_notify_monitor()
8090 if (private->vol_sw_hw_switch[line_out_remap(private, i)]) in scarlett2_notify_monitor()
8092 &private->vol_ctls[i]->id); in scarlett2_notify_monitor()
8098 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_volume()
8100 private->vol_updated = 1; in scarlett2_notify_volume()
8102 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_volume()
8103 &private->master_vol_ctl->id); in scarlett2_notify_volume()
8104 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_volume()
8105 &private->headphone_vol_ctl->id); in scarlett2_notify_volume()
8111 struct snd_card *card = mixer->chip->card; in scarlett2_notify_dim_mute()
8112 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_dim_mute()
8118 private->dim_mute_updated = 1; in scarlett2_notify_dim_mute()
8122 &private->dim_mute_ctls[i]->id); in scarlett2_notify_dim_mute()
8124 for (i = 0; i < private->num_line_out; i++) in scarlett2_notify_dim_mute()
8125 if (private->vol_sw_hw_switch[line_out_remap(private, i)]) in scarlett2_notify_dim_mute()
8127 &private->mute_ctls[i]->id); in scarlett2_notify_dim_mute()
8133 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_level()
8134 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_level()
8135 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_level()
8138 private->input_level_updated = 1; in scarlett2_notify_input_level()
8140 for (i = 0; i < info->level_input_count; i++) in scarlett2_notify_input_level()
8142 &private->level_ctls[i]->id); in scarlett2_notify_input_level()
8148 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_pad()
8149 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_pad()
8150 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_pad()
8153 private->input_pad_updated = 1; in scarlett2_notify_input_pad()
8155 for (i = 0; i < info->pad_input_count; i++) in scarlett2_notify_input_pad()
8157 &private->pad_ctls[i]->id); in scarlett2_notify_input_pad()
8163 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_air()
8164 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_air()
8165 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_air()
8168 private->input_air_updated = 1; in scarlett2_notify_input_air()
8170 for (i = 0; i < info->air_input_count; i++) in scarlett2_notify_input_air()
8172 &private->air_ctls[i]->id); in scarlett2_notify_input_air()
8178 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_dsp()
8179 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_dsp()
8180 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_dsp()
8183 private->input_dsp_updated = 1; in scarlett2_notify_input_dsp()
8185 for (i = 0; i < info->dsp_input_count; i++) in scarlett2_notify_input_dsp()
8187 &private->dsp_ctls[i]->id); in scarlett2_notify_input_dsp()
8193 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_mute()
8194 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_mute()
8195 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_mute()
8198 private->input_mute_updated = 1; in scarlett2_notify_input_mute()
8200 for (i = 0; i < info->mute_input_count; i++) in scarlett2_notify_input_mute()
8202 &private->input_mute_ctls[i]->id); in scarlett2_notify_input_mute()
8208 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_phantom()
8209 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_phantom()
8210 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_phantom()
8213 private->input_phantom_updated = 1; in scarlett2_notify_input_phantom()
8215 for (i = 0; i < info->phantom_count; i++) in scarlett2_notify_input_phantom()
8217 &private->phantom_ctls[i]->id); in scarlett2_notify_input_phantom()
8234 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_select()
8235 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_select()
8236 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_select()
8243 private->input_select_updated = 1; in scarlett2_notify_input_select()
8247 &private->input_select_ctl->id); in scarlett2_notify_input_select()
8249 for (i = 0; i < info->gain_input_count / 2; i++) in scarlett2_notify_input_select()
8251 &private->input_link_ctls[i]->id); in scarlett2_notify_input_select()
8257 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_gain()
8258 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_gain()
8259 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_gain()
8262 if (!info->gain_input_count) in scarlett2_notify_input_gain()
8265 private->input_gain_updated = 1; in scarlett2_notify_input_gain()
8267 for (i = 0; i < info->gain_input_count; i++) in scarlett2_notify_input_gain()
8269 &private->input_gain_ctls[i]->id); in scarlett2_notify_input_gain()
8275 struct snd_card *card = mixer->chip->card; in scarlett2_notify_autogain()
8276 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_autogain()
8277 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_autogain()
8280 if (!info->gain_input_count) in scarlett2_notify_autogain()
8283 private->autogain_updated = 1; in scarlett2_notify_autogain()
8285 for (i = 0; i < info->gain_input_count; i++) { in scarlett2_notify_autogain()
8287 &private->autogain_ctls[i]->id); in scarlett2_notify_autogain()
8289 &private->autogain_status_ctls[i]->id); in scarlett2_notify_autogain()
8296 &private->ag_target_ctls[i]->id); in scarlett2_notify_autogain()
8304 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_safe()
8305 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_safe()
8306 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_safe()
8309 if (!info->safe_input_count) in scarlett2_notify_input_safe()
8312 private->input_safe_updated = 1; in scarlett2_notify_input_safe()
8314 for (i = 0; i < info->safe_input_count; i++) in scarlett2_notify_input_safe()
8316 &private->safe_ctls[i]->id); in scarlett2_notify_input_safe()
8322 struct snd_card *card = mixer->chip->card; in scarlett2_notify_monitor_other()
8323 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_monitor_other()
8324 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_monitor_other()
8326 private->monitor_other_updated = 1; in scarlett2_notify_monitor_other()
8328 if (info->has_speaker_switching) in scarlett2_notify_monitor_other()
8330 &private->speaker_switching_ctl->id); in scarlett2_notify_monitor_other()
8332 if (info->has_talkback) in scarlett2_notify_monitor_other()
8334 &private->talkback_ctl->id); in scarlett2_notify_monitor_other()
8339 if (private->speaker_switching_switched) { in scarlett2_notify_monitor_other()
8344 private->speaker_switching_switched = 0; in scarlett2_notify_monitor_other()
8345 private->mux_updated = 1; in scarlett2_notify_monitor_other()
8347 for (i = 0; i < private->num_mux_dsts; i++) in scarlett2_notify_monitor_other()
8349 &private->mux_ctls[i]->id); in scarlett2_notify_monitor_other()
8356 struct snd_card *card = mixer->chip->card; in scarlett2_notify_direct_monitor()
8357 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_direct_monitor()
8358 int count = private->num_mix_in * private->num_mix_out; in scarlett2_notify_direct_monitor()
8361 private->direct_monitor_updated = 1; in scarlett2_notify_direct_monitor()
8364 &private->direct_monitor_ctl->id); in scarlett2_notify_direct_monitor()
8369 private->mix_updated = 1; in scarlett2_notify_direct_monitor()
8371 /* Notify of change to the mix controls */ in scarlett2_notify_direct_monitor()
8374 &private->mix_ctls[i]->id); in scarlett2_notify_direct_monitor()
8380 struct snd_card *card = mixer->chip->card; in scarlett2_notify_power_status()
8381 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_power_status()
8383 private->power_status_updated = 1; in scarlett2_notify_power_status()
8386 &private->power_status_ctl->id); in scarlett2_notify_power_status()
8392 struct snd_card *card = mixer->chip->card; in scarlett2_notify_mux()
8393 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_mux()
8396 private->mux_updated = 1; in scarlett2_notify_mux()
8398 for (i = 0; i < private->num_mux_dsts; i++) in scarlett2_notify_mux()
8400 &private->mux_ctls[i]->id); in scarlett2_notify_mux()
8406 struct snd_card *card = mixer->chip->card; in scarlett2_notify_pcm_input_switch()
8407 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_pcm_input_switch()
8409 private->pcm_input_switch_updated = 1; in scarlett2_notify_pcm_input_switch()
8412 &private->pcm_input_switch_ctl->id); in scarlett2_notify_pcm_input_switch()
8420 struct snd_card *card = mixer->chip->card; in scarlett2_notify_bluetooth()
8421 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_bluetooth()
8423 if (!private->info->has_bluetooth) in scarlett2_notify_bluetooth()
8426 private->bluetooth_updated = 1; in scarlett2_notify_bluetooth()
8429 &private->bluetooth_volume_ctl->id); in scarlett2_notify_bluetooth()
8437 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_ack()
8440 if (private->running) in scarlett2_notify_ack()
8441 complete(&private->cmd_done); in scarlett2_notify_ack()
8447 struct usb_mixer_interface *mixer = urb->context; in scarlett2_notify()
8448 int len = urb->actual_length; in scarlett2_notify()
8449 int ustatus = urb->status; in scarlett2_notify()
8451 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify()
8453 private->config_set->notifications; in scarlett2_notify()
8458 data = le32_to_cpu(*(__le32 *)urb->transfer_buffer); in scarlett2_notify()
8463 if (private->running < 2) in scarlett2_notify()
8466 while (data && notifications->mask) { in scarlett2_notify()
8467 if (data & notifications->mask) { in scarlett2_notify()
8468 data &= ~notifications->mask; in scarlett2_notify()
8469 if (notifications->func) in scarlett2_notify()
8470 notifications->func(mixer); in scarlett2_notify()
8476 usb_audio_warn(mixer->chip, in scarlett2_notify()
8481 if (ustatus != -ENOENT && in scarlett2_notify()
8482 ustatus != -ECONNRESET && in scarlett2_notify()
8483 ustatus != -ESHUTDOWN) { in scarlett2_notify()
8484 urb->dev = mixer->chip->dev; in scarlett2_notify()
8487 complete(&private->cmd_done); in scarlett2_notify()
8495 struct scarlett2_data *private = mixer->private_data; in scarlett2_private_free()
8497 cancel_delayed_work_sync(&private->work); in scarlett2_private_free()
8499 mixer->private_data = NULL; in scarlett2_private_free()
8504 struct scarlett2_data *private = mixer->private_data; in scarlett2_private_suspend()
8506 if (cancel_delayed_work_sync(&private->work)) in scarlett2_private_suspend()
8507 scarlett2_config_save(private->mixer); in scarlett2_private_suspend()
8514 const struct scarlett2_device_info *info = private->info; in scarlett2_count_io()
8515 const struct scarlett2_config_set *config_set = info->config_set; in scarlett2_count_io()
8516 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_count_io()
8527 private->num_mux_srcs = srcs; in scarlett2_count_io()
8528 private->num_mux_dsts = dsts; in scarlett2_count_io()
8534 private->num_mix_in = in scarlett2_count_io()
8535 port_count[SCARLETT2_PORT_TYPE_MIX][SCARLETT2_PORT_OUT] - in scarlett2_count_io()
8536 info->dsp_count; in scarlett2_count_io()
8538 private->num_mix_out = in scarlett2_count_io()
8539 port_count[SCARLETT2_PORT_TYPE_MIX][SCARLETT2_PORT_IN] - in scarlett2_count_io()
8540 info->dsp_count; in scarlett2_count_io()
8543 private->num_line_out = in scarlett2_count_io()
8547 private->num_monitor_mix_ctls = in scarlett2_count_io()
8548 info->direct_monitor * 2 * private->num_mix_in; in scarlett2_count_io()
8551 if (config_set->autogain_status_texts) { in scarlett2_count_io()
8552 const char * const *texts = config_set->autogain_status_texts; in scarlett2_count_io()
8556 private->num_autogain_status_texts = i; in scarlett2_count_io()
8568 struct usb_host_config *config = dev->actconfig; in scarlett2_find_fc_interface()
8571 for (i = 0; i < config->desc.bNumInterfaces; i++) { in scarlett2_find_fc_interface()
8572 struct usb_interface *intf = config->interface[i]; in scarlett2_find_fc_interface()
8574 &intf->altsetting[0].desc; in scarlett2_find_fc_interface()
8577 if (desc->bInterfaceClass != 255) in scarlett2_find_fc_interface()
8580 epd = get_endpoint(intf->altsetting, 0); in scarlett2_find_fc_interface()
8581 private->bInterfaceNumber = desc->bInterfaceNumber; in scarlett2_find_fc_interface()
8582 private->bEndpointAddress = epd->bEndpointAddress & in scarlett2_find_fc_interface()
8584 private->wMaxPacketSize = le16_to_cpu(epd->wMaxPacketSize); in scarlett2_find_fc_interface()
8585 private->bInterval = epd->bInterval; in scarlett2_find_fc_interface()
8589 return -EINVAL; in scarlett2_find_fc_interface()
8600 return -ENOMEM; in scarlett2_init_private()
8602 mutex_init(&private->usb_mutex); in scarlett2_init_private()
8603 mutex_init(&private->data_mutex); in scarlett2_init_private()
8604 INIT_DELAYED_WORK(&private->work, scarlett2_config_save_work); in scarlett2_init_private()
8606 mixer->private_data = private; in scarlett2_init_private()
8607 mixer->private_free = scarlett2_private_free; in scarlett2_init_private()
8608 mixer->private_suspend = scarlett2_private_suspend; in scarlett2_init_private()
8610 private->info = entry->info; in scarlett2_init_private()
8611 private->config_set = entry->info->config_set; in scarlett2_init_private()
8612 private->series_name = entry->series_name; in scarlett2_init_private()
8614 private->scarlett2_seq = 0; in scarlett2_init_private()
8615 private->mixer = mixer; in scarlett2_init_private()
8617 return scarlett2_find_fc_interface(mixer->chip->dev, private); in scarlett2_init_private()
8620 /* Submit a URB to receive notifications from the device */
8623 struct usb_device *dev = mixer->chip->dev; in scarlett2_init_notify()
8624 struct scarlett2_data *private = mixer->private_data; in scarlett2_init_notify()
8625 unsigned int pipe = usb_rcvintpipe(dev, private->bEndpointAddress); in scarlett2_init_notify()
8628 if (mixer->urb) { in scarlett2_init_notify()
8629 usb_audio_err(mixer->chip, in scarlett2_init_notify()
8635 return -EINVAL; in scarlett2_init_notify()
8637 mixer->urb = usb_alloc_urb(0, GFP_KERNEL); in scarlett2_init_notify()
8638 if (!mixer->urb) in scarlett2_init_notify()
8639 return -ENOMEM; in scarlett2_init_notify()
8641 transfer_buffer = kmalloc(private->wMaxPacketSize, GFP_KERNEL); in scarlett2_init_notify()
8643 return -ENOMEM; in scarlett2_init_notify()
8645 usb_fill_int_urb(mixer->urb, dev, pipe, in scarlett2_init_notify()
8646 transfer_buffer, private->wMaxPacketSize, in scarlett2_init_notify()
8647 scarlett2_notify, mixer, private->bInterval); in scarlett2_init_notify()
8649 init_completion(&private->cmd_done); in scarlett2_init_notify()
8651 return usb_submit_urb(mixer->urb, GFP_KERNEL); in scarlett2_init_notify()
8657 struct usb_device *dev = mixer->chip->dev; in scarlett2_usb_init()
8658 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_init()
8664 return -EINVAL; in scarlett2_usb_init()
8667 err = scarlett2_usb_rx(dev, private->bInterfaceNumber, in scarlett2_usb_init()
8689 private->running = 1; in scarlett2_usb_init()
8692 private->scarlett2_seq = 1; in scarlett2_usb_init()
8698 private->scarlett2_seq = 1; in scarlett2_usb_init()
8705 /* extract 4-byte firmware version from step2_buf[8] */ in scarlett2_usb_init()
8706 private->firmware_version = le32_to_cpu(*(__le32 *)(step2_buf + 8)); in scarlett2_usb_init()
8707 usb_audio_info(mixer->chip, in scarlett2_usb_init()
8709 private->firmware_version); in scarlett2_usb_init()
8719 struct scarlett2_data *private = mixer->private_data; in scarlett2_get_flash_segment_nums()
8745 usb_audio_err(mixer->chip, in scarlett2_get_flash_segment_nums()
8747 return -EINVAL; in scarlett2_get_flash_segment_nums()
8758 usb_audio_err(mixer->chip, in scarlett2_get_flash_segment_nums()
8759 "failed to get flash segment info %d: %d\n", in scarlett2_get_flash_segment_nums()
8773 private->flash_segment_nums[flash_segment_id] = i; in scarlett2_get_flash_segment_nums()
8774 private->flash_segment_blocks[flash_segment_id] = in scarlett2_get_flash_segment_nums()
8779 /* segment 0 is App_Gold and we never want to touch that, so in scarlett2_get_flash_segment_nums()
8780 * use 0 as the "not-found" value in scarlett2_get_flash_segment_nums()
8782 if (!private->flash_segment_nums[SCARLETT2_SEGMENT_ID_SETTINGS]) { in scarlett2_get_flash_segment_nums()
8783 usb_audio_err(mixer->chip, in scarlett2_get_flash_segment_nums()
8784 "failed to find flash segment %s\n", in scarlett2_get_flash_segment_nums()
8786 return -EINVAL; in scarlett2_get_flash_segment_nums()
8788 if (!private->flash_segment_nums[SCARLETT2_SEGMENT_ID_FIRMWARE]) { in scarlett2_get_flash_segment_nums()
8789 usb_audio_err(mixer->chip, in scarlett2_get_flash_segment_nums()
8790 "failed to find flash segment %s\n", in scarlett2_get_flash_segment_nums()
8792 return -EINVAL; in scarlett2_get_flash_segment_nums()
8801 struct scarlett2_data *private = mixer->private_data; in scarlett2_read_configs()
8802 const struct scarlett2_device_info *info = private->info; in scarlett2_read_configs()
8808 1, &private->msd_switch); in scarlett2_read_configs()
8813 if (private->firmware_version < info->min_firmware_version) { in scarlett2_read_configs()
8814 usb_audio_err(mixer->chip, in scarlett2_read_configs()
8817 private->series_name, in scarlett2_read_configs()
8818 private->firmware_version, in scarlett2_read_configs()
8819 info->min_firmware_version); in scarlett2_read_configs()
8824 if (private->msd_switch) in scarlett2_read_configs()
8879 1, &private->standalone_switch); in scarlett2_read_configs()
8902 private->num_line_out, &sw_vol); in scarlett2_read_configs()
8906 for (i = 0; i < private->num_line_out; i++) in scarlett2_read_configs()
8907 private->vol[i] = clamp( in scarlett2_read_configs()
8914 private->num_line_out, &private->mute_switch); in scarlett2_read_configs()
8918 for (i = 0; i < private->num_line_out; i++) in scarlett2_read_configs()
8919 private->mute_switch[i] = in scarlett2_read_configs()
8920 !!private->mute_switch[i]; in scarlett2_read_configs()
8927 private->num_line_out, in scarlett2_read_configs()
8928 &private->vol_sw_hw_switch); in scarlett2_read_configs()
8932 for (i = 0; i < private->num_line_out; i++) in scarlett2_read_configs()
8933 private->vol_sw_hw_switch[i] = in scarlett2_read_configs()
8934 !!private->vol_sw_hw_switch[i]; in scarlett2_read_configs()
8990 while (entry->usb_id && entry->usb_id != mixer->chip->usb_id) in get_scarlett2_device_entry()
8992 if (!entry->usb_id) in get_scarlett2_device_entry()
9010 private = mixer->private_data; in snd_scarlett2_controls_create()
9045 if (private->msd_switch || in snd_scarlett2_controls_create()
9046 private->firmware_version < private->info->min_firmware_version) in snd_scarlett2_controls_create()
9117 if (private->info->gain_input_count) { in snd_scarlett2_controls_create()
9123 private->running = 2; in snd_scarlett2_controls_create()
9130 /* Set private->hwdep_in_use; prevents access to the ALSA controls
9135 mutex_lock(&private->data_mutex); in scarlett2_lock()
9136 private->hwdep_in_use = 1; in scarlett2_lock()
9137 mutex_unlock(&private->data_mutex); in scarlett2_lock()
9140 /* Call SCARLETT2_USB_GET_ERASE to get the erase progress */
9143 struct scarlett2_data *private = mixer->private_data; in scarlett2_get_erase_progress()
9152 segment_id = private->selected_flash_segment_id; in scarlett2_get_erase_progress()
9153 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_get_erase_progress()
9157 return -EFAULT; in scarlett2_get_erase_progress()
9191 return -ETIMEDOUT; in scarlett2_wait_for_erase()
9194 /* Reboot the device; wait for the erase to complete if one is in
9199 struct scarlett2_data *private = mixer->private_data; in scarlett2_reboot()
9201 if (private->flash_write_state == in scarlett2_reboot()
9217 struct scarlett2_data *private = mixer->private_data; in scarlett2_ioctl_select_flash_segment()
9221 return -EFAULT; in scarlett2_ioctl_select_flash_segment()
9225 return -EINVAL; in scarlett2_ioctl_select_flash_segment()
9227 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_ioctl_select_flash_segment()
9230 usb_audio_err(mixer->chip, in scarlett2_ioctl_select_flash_segment()
9233 return -EFAULT; in scarlett2_ioctl_select_flash_segment()
9236 /* If erasing, wait for it to complete */ in scarlett2_ioctl_select_flash_segment()
9237 if (private->flash_write_state == SCARLETT2_FLASH_WRITE_STATE_ERASING) { in scarlett2_ioctl_select_flash_segment()
9244 /* Save the selected segment ID and set the state to SELECTED */ in scarlett2_ioctl_select_flash_segment()
9245 private->selected_flash_segment_id = segment_id; in scarlett2_ioctl_select_flash_segment()
9246 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_SELECTED; in scarlett2_ioctl_select_flash_segment()
9251 /* Erase the previously-selected flash segment */
9255 struct scarlett2_data *private = mixer->private_data; in scarlett2_ioctl_erase_flash_segment()
9263 if (private->flash_write_state != SCARLETT2_FLASH_WRITE_STATE_SELECTED) in scarlett2_ioctl_erase_flash_segment()
9264 return -EINVAL; in scarlett2_ioctl_erase_flash_segment()
9266 segment_id = private->selected_flash_segment_id; in scarlett2_ioctl_erase_flash_segment()
9267 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_ioctl_erase_flash_segment()
9271 return -EFAULT; in scarlett2_ioctl_erase_flash_segment()
9273 /* Prevent access to ALSA controls that access the device from in scarlett2_ioctl_erase_flash_segment()
9288 /* On success, change the state from SELECTED to ERASING */ in scarlett2_ioctl_erase_flash_segment()
9289 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_ERASING; in scarlett2_ioctl_erase_flash_segment()
9299 struct scarlett2_data *private = mixer->private_data; in scarlett2_ioctl_get_erase_progress()
9310 if (private->flash_write_state != SCARLETT2_FLASH_WRITE_STATE_ERASING) in scarlett2_ioctl_get_erase_progress()
9311 return -EINVAL; in scarlett2_ioctl_get_erase_progress()
9313 segment_id = private->selected_flash_segment_id; in scarlett2_ioctl_get_erase_progress()
9314 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_ioctl_get_erase_progress()
9318 return -EFAULT; in scarlett2_ioctl_get_erase_progress()
9331 progress.num_blocks = private->flash_segment_blocks[segment_id]; in scarlett2_ioctl_get_erase_progress()
9334 return -EFAULT; in scarlett2_ioctl_get_erase_progress()
9336 /* If the erase is complete, change the state from ERASING to in scarlett2_ioctl_get_erase_progress()
9340 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_WRITE; in scarlett2_ioctl_get_erase_progress()
9347 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_open()
9348 struct scarlett2_data *private = mixer->private_data; in scarlett2_hwdep_open()
9350 /* If erasing, wait for it to complete */ in scarlett2_hwdep_open()
9351 if (private->flash_write_state == in scarlett2_hwdep_open()
9359 /* Set the state to IDLE */ in scarlett2_hwdep_open()
9360 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_IDLE; in scarlett2_hwdep_open()
9368 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_ioctl()
9374 (int __user *)arg) ? -EFAULT : 0; in scarlett2_hwdep_ioctl()
9389 return -ENOIOCTLCMD; in scarlett2_hwdep_ioctl()
9397 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_read()
9398 struct scarlett2_data *private = mixer->private_data; in scarlett2_hwdep_read()
9412 if (private->flash_write_state != SCARLETT2_FLASH_WRITE_STATE_SELECTED) in scarlett2_hwdep_read()
9413 return -EINVAL; in scarlett2_hwdep_read()
9416 segment_id = private->selected_flash_segment_id; in scarlett2_hwdep_read()
9418 return -EINVAL; in scarlett2_hwdep_read()
9420 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_hwdep_read()
9423 return -EFAULT; in scarlett2_hwdep_read()
9427 return -EINVAL; in scarlett2_hwdep_read()
9430 flash_size = private->flash_segment_blocks[segment_id] * in scarlett2_hwdep_read()
9435 /* Limit the numbers of bytes read to SCARLETT2_FLASH_RW_MAX */ in scarlett2_hwdep_read()
9439 /* Limit read to EOF */ in scarlett2_hwdep_read()
9441 count = flash_size - *offset; in scarlett2_hwdep_read()
9450 return -ENOMEM; in scarlett2_hwdep_read()
9457 /* Copy the response to userspace */ in scarlett2_hwdep_read()
9459 err = -EFAULT; in scarlett2_hwdep_read()
9475 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_write()
9476 struct scarlett2_data *private = mixer->private_data; in scarlett2_hwdep_write()
9489 const size_t max_data_size = SCARLETT2_FLASH_RW_MAX - in scarlett2_hwdep_write()
9492 /* If erasing, wait for it to complete */ in scarlett2_hwdep_write()
9493 if (private->flash_write_state == in scarlett2_hwdep_write()
9498 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_WRITE; in scarlett2_hwdep_write()
9501 } else if (private->flash_write_state != in scarlett2_hwdep_write()
9503 return -EINVAL; in scarlett2_hwdep_write()
9506 /* Check that we're writing to the upgrade firmware */ in scarlett2_hwdep_write()
9507 segment_id = private->selected_flash_segment_id; in scarlett2_hwdep_write()
9509 return -EINVAL; in scarlett2_hwdep_write()
9511 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_hwdep_write()
9514 return -EFAULT; in scarlett2_hwdep_write()
9517 flash_size = private->flash_segment_blocks[segment_id] * in scarlett2_hwdep_write()
9521 return -EINVAL; in scarlett2_hwdep_write()
9526 /* Limit the *req size to SCARLETT2_FLASH_RW_MAX */ in scarlett2_hwdep_write()
9534 return -ENOMEM; in scarlett2_hwdep_write()
9536 req->segment_num = cpu_to_le32(segment_num); in scarlett2_hwdep_write()
9537 req->offset = cpu_to_le32(*offset); in scarlett2_hwdep_write()
9538 req->pad = 0; in scarlett2_hwdep_write()
9540 if (copy_from_user(req->data, buf, count)) { in scarlett2_hwdep_write()
9541 err = -EFAULT; in scarlett2_hwdep_write()
9560 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_release()
9561 struct scarlett2_data *private = mixer->private_data; in scarlett2_hwdep_release()
9563 /* Return from the SELECTED or WRITE state to IDLE. in scarlett2_hwdep_release()
9564 * The ERASING state is left as-is, and checked on next open. in scarlett2_hwdep_release()
9567 private->hwdep_in_use && in scarlett2_hwdep_release()
9568 private->flash_write_state != SCARLETT2_FLASH_WRITE_STATE_ERASING) in scarlett2_hwdep_release()
9569 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_IDLE; in scarlett2_hwdep_release()
9579 err = snd_hwdep_new(mixer->chip->card, "Focusrite Control", 0, &hw); in scarlett2_hwdep_init()
9583 hw->private_data = mixer; in scarlett2_hwdep_init()
9584 hw->exclusive = 1; in scarlett2_hwdep_init()
9585 hw->ops.open = scarlett2_hwdep_open; in scarlett2_hwdep_init()
9586 hw->ops.ioctl = scarlett2_hwdep_ioctl; in scarlett2_hwdep_init()
9587 hw->ops.read = scarlett2_hwdep_read; in scarlett2_hwdep_init()
9588 hw->ops.write = scarlett2_hwdep_write; in scarlett2_hwdep_init()
9589 hw->ops.release = scarlett2_hwdep_release; in scarlett2_hwdep_init()
9596 struct snd_usb_audio *chip = mixer->chip; in snd_scarlett2_init()
9601 if (!mixer->protocol) in snd_scarlett2_init()
9607 usb_audio_err(mixer->chip, in snd_scarlett2_init()
9610 USB_ID_VENDOR(chip->usb_id), in snd_scarlett2_init()
9611 USB_ID_PRODUCT(chip->usb_id)); in snd_scarlett2_init()
9615 if (chip->setup & SCARLETT2_DISABLE) { in snd_scarlett2_init()
9620 entry->series_name, in snd_scarlett2_init()
9621 USB_ID_VENDOR(chip->usb_id), in snd_scarlett2_init()
9622 USB_ID_PRODUCT(chip->usb_id), in snd_scarlett2_init()
9629 "report any issues to " in snd_scarlett2_init()
9630 "https://github.com/geoffreybennett/scarlett-gen2/issues", in snd_scarlett2_init()
9631 entry->series_name, in snd_scarlett2_init()
9632 USB_ID_PRODUCT(chip->usb_id)); in snd_scarlett2_init()
9636 usb_audio_err(mixer->chip, in snd_scarlett2_init()
9638 entry->series_name, in snd_scarlett2_init()
9645 usb_audio_err(mixer->chip, in snd_scarlett2_init()
9647 entry->series_name, in snd_scarlett2_init()