Lines Matching +full:tlv +full:- +full:layout

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-2024 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.
58 * and talkback added in May-June 2021.
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 * \--------------/
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
159 #include <sound/tlv.h>
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)
196 * for dB in 0 .. 184: int(8192 * pow(10, ((dB - 160) / 2 / 20)))
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)
591 /* Input gain TLV dB ranges */
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
1096 /* the first input with a level control (0-based) */
1109 /* the first input with an air control (0-based) */
1121 /* number of pre-compressor filters */
1138 /* the first input with phantom power control (0-based) */
1144 /* the number of inputs with software-controllable gain */
1179 /* layout/order of the entries in the set_mux message */
1314 /*** Model-specific data ***/
2290 /* Gen 4 device firmware provides access to a base64-encoded
2291 * zlib-compressed JSON description of the device's capabilities and
2293 * /proc/asound/cardX/device-map.json.zz.b64
2296 #define SCARLETT2_DEVMAP_FILENAME "device-map.json.zz.b64"
2313 u16 seq = private->scarlett2_seq++; in scarlett2_fill_request_header()
2315 req->cmd = cpu_to_le32(cmd); in scarlett2_fill_request_header()
2316 req->size = cpu_to_le16(req_size); in scarlett2_fill_request_header()
2317 req->seq = cpu_to_le16(seq); in scarlett2_fill_request_header()
2318 req->error = 0; in scarlett2_fill_request_header()
2319 req->pad = 0; in scarlett2_fill_request_header()
2345 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb()
2346 struct usb_device *dev = mixer->chip->dev; in scarlett2_usb()
2354 err = -ENOMEM; in scarlett2_usb()
2360 err = -ENOMEM; in scarlett2_usb()
2364 mutex_lock(&private->usb_mutex); in scarlett2_usb()
2371 memcpy(req->data, req_data, req_size); in scarlett2_usb()
2373 err = scarlett2_usb_tx(dev, private->bInterfaceNumber, in scarlett2_usb()
2378 mixer->chip, in scarlett2_usb()
2380 private->series_name, cmd, err); in scarlett2_usb()
2381 err = -EINVAL; in scarlett2_usb()
2385 if (!wait_for_completion_timeout(&private->cmd_done, in scarlett2_usb()
2388 mixer->chip, in scarlett2_usb()
2390 private->series_name, cmd); in scarlett2_usb()
2392 err = -ETIMEDOUT; in scarlett2_usb()
2398 err = scarlett2_usb_rx(dev, private->bInterfaceNumber, in scarlett2_usb()
2410 (err == -ESHUTDOWN || err == -EPROTO)) { in scarlett2_usb()
2416 mixer->chip, in scarlett2_usb()
2418 private->series_name, cmd, err, resp_buf_size); in scarlett2_usb()
2419 err = -EINVAL; in scarlett2_usb()
2426 if (resp->cmd != req->cmd || in scarlett2_usb()
2427 (resp->seq != req->seq && in scarlett2_usb()
2428 (le16_to_cpu(req->seq) != 1 || resp->seq != 0)) || in scarlett2_usb()
2429 resp_size != le16_to_cpu(resp->size) || in scarlett2_usb()
2430 resp->error || in scarlett2_usb()
2431 resp->pad) { in scarlett2_usb()
2433 mixer->chip, in scarlett2_usb()
2437 private->series_name, in scarlett2_usb()
2438 le32_to_cpu(req->cmd), le32_to_cpu(resp->cmd), in scarlett2_usb()
2439 le16_to_cpu(req->seq), le16_to_cpu(resp->seq), in scarlett2_usb()
2440 resp_size, le16_to_cpu(resp->size), in scarlett2_usb()
2441 le32_to_cpu(resp->error), in scarlett2_usb()
2442 le32_to_cpu(resp->pad)); in scarlett2_usb()
2443 err = -EINVAL; in scarlett2_usb()
2448 memcpy(resp_data, resp->data, resp_size); in scarlett2_usb()
2451 mutex_unlock(&private->usb_mutex); in scarlett2_usb()
2480 return !!private->config_set->items[config_item_num].offset; in scarlett2_has_config_item()
2488 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_get_config()
2490 &private->config_set->items[config_item_num]; in scarlett2_usb_get_config()
2498 if (!config_item->offset) in scarlett2_usb_get_config()
2499 return -EFAULT; in scarlett2_usb_get_config()
2502 size = config_item->size ? config_item->size : 8; in scarlett2_usb_get_config()
2504 /* For byte-sized parameters, retrieve directly into buf */ in scarlett2_usb_get_config()
2507 err = scarlett2_usb_get(mixer, config_item->offset, buf, size); in scarlett2_usb_get_config()
2524 /* For bit-sized parameters, retrieve into value */ in scarlett2_usb_get_config()
2525 err = scarlett2_usb_get(mixer, config_item->offset, &value, 1); in scarlett2_usb_get_config()
2545 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_data()
2555 return scarlett2_usb(private->mixer, SCARLETT2_USB_SET_DATA, in scarlett2_usb_set_data()
2568 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_data_buf()
2580 return -ENOMEM; in scarlett2_usb_set_data_buf()
2582 req->offset = cpu_to_le32(offset); in scarlett2_usb_set_data_buf()
2583 req->size = cpu_to_le32(bytes); in scarlett2_usb_set_data_buf()
2585 memcpy(req->data, buf, count); in scarlett2_usb_set_data_buf()
2591 ((__le16 *)req->data)[i] = cpu_to_le16(buf_16[i]); in scarlett2_usb_set_data_buf()
2597 ((__le32 *)req->data)[i] = cpu_to_le32(buf_32[i]); in scarlett2_usb_set_data_buf()
2600 err = scarlett2_usb(private->mixer, SCARLETT2_USB_SET_DATA, in scarlett2_usb_set_data_buf()
2628 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_config()
2629 const struct scarlett2_config_set *config_set = private->config_set; in scarlett2_usb_set_config()
2631 &config_set->items[config_item_num]; in scarlett2_usb_set_config()
2638 if (!config_item->offset) in scarlett2_usb_set_config()
2639 return -EFAULT; in scarlett2_usb_set_config()
2642 if (config_item->pbuf) { in scarlett2_usb_set_config()
2643 if (!config_set->param_buf_addr) in scarlett2_usb_set_config()
2644 return -EFAULT; in scarlett2_usb_set_config()
2648 mixer, config_set->param_buf_addr + 1, 1, index); in scarlett2_usb_set_config()
2654 mixer, config_set->param_buf_addr, 1, value); in scarlett2_usb_set_config()
2660 mixer, config_item->activate); in scarlett2_usb_set_config()
2664 * save and support bit-modification in scarlett2_usb_set_config()
2668 cancel_delayed_work_sync(&private->work); in scarlett2_usb_set_config()
2670 /* Convert config_item->size in bits to size in bytes and in scarlett2_usb_set_config()
2673 if (config_item->size >= 8) { in scarlett2_usb_set_config()
2674 size = config_item->size / 8; in scarlett2_usb_set_config()
2675 offset = config_item->offset + index * size; in scarlett2_usb_set_config()
2684 offset = config_item->offset; in scarlett2_usb_set_config()
2704 err = scarlett2_usb_activate_config(mixer, config_item->activate); in scarlett2_usb_set_config()
2711 if (config_set->param_buf_addr) in scarlett2_usb_set_config()
2715 if (config_item->activate != SCARLETT2_USB_CONFIG_SAVE) in scarlett2_usb_set_config()
2716 schedule_delayed_work(&private->work, msecs_to_jiffies(2000)); in scarlett2_usb_set_config()
2728 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_config_buf()
2729 const struct scarlett2_config_set *config_set = private->config_set; in scarlett2_usb_set_config_buf()
2731 &config_set->items[config_item_num]; in scarlett2_usb_set_config_buf()
2738 if (!config_item->offset) in scarlett2_usb_set_config_buf()
2739 return -EFAULT; in scarlett2_usb_set_config_buf()
2741 /* Convert config_item->size in bits to size in bytes and in scarlett2_usb_set_config_buf()
2744 if (config_item->size >= 8) { in scarlett2_usb_set_config_buf()
2745 size = config_item->size / 8; in scarlett2_usb_set_config_buf()
2746 offset = config_item->offset + index * size; in scarlett2_usb_set_config_buf()
2750 return -EFAULT; in scarlett2_usb_set_config_buf()
2759 return scarlett2_usb_activate_config(mixer, config_item->activate); in scarlett2_usb_set_config_buf()
2769 usb_audio_err(mixer->chip, "config save failed: %d\n", err); in scarlett2_config_save()
2778 scarlett2_config_save(private->mixer); in scarlett2_config_save_work()
2801 return !!private->info->mux_assignment[0][0].count; in scarlett2_has_mixer()
2818 * and put the values into private->mix[]
2823 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_get_mix()
2825 int num_mixer_in = private->num_mix_in; in scarlett2_usb_get_mix()
2845 private->mix[j] = scarlett2_mixer_value_to_db( in scarlett2_usb_get_mix()
2852 * (values obtained from private->mix[])
2857 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_mix()
2865 int num_mixer_in = private->num_mix_in; in scarlett2_usb_set_mix()
2871 scarlett2_mixer_values[private->mix[j]] in scarlett2_usb_set_mix()
2879 /* Convert a port number index (per info->port_count) to a hardware ID */
2890 num -= port_count[port_type][SCARLETT2_PORT_IN]; in scarlett2_mux_src_num_to_id()
2911 return port_num + id - base; in scarlett2_mux_id_to_num()
2916 return -1; in scarlett2_mux_id_to_num()
2919 /* Convert one mux entry from the interface and load into private->mux[] */
2923 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_populate_mux()
2924 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_usb_populate_mux()
2933 if (dst_idx >= private->num_mux_dsts) { in scarlett2_usb_populate_mux()
2934 usb_audio_err(private->mixer->chip, in scarlett2_usb_populate_mux()
2936 mux_entry, dst_idx, private->num_mux_dsts); in scarlett2_usb_populate_mux()
2945 if (src_idx >= private->num_mux_srcs) { in scarlett2_usb_populate_mux()
2946 usb_audio_err(private->mixer->chip, in scarlett2_usb_populate_mux()
2948 mux_entry, src_idx, private->num_mux_srcs); in scarlett2_usb_populate_mux()
2952 private->mux[dst_idx] = src_idx; in scarlett2_usb_populate_mux()
2966 * - the source is "Off"; therefore we set those values to zero (map
2969 * - the source is assigned to a previous (with respect to the
2975 const struct scarlett2_device_info *info = private->info; in scarlett2_update_meter_level_map()
2990 for (entry = info->meter_map; in scarlett2_update_meter_level_map()
2991 entry->count; in scarlett2_update_meter_level_map()
2997 for (j = 0, mux_idx = entry->start; in scarlett2_update_meter_level_map()
2998 j < entry->count; in scarlett2_update_meter_level_map()
3003 info->line_out_remap_enable && in scarlett2_update_meter_level_map()
3004 mux_idx < private->num_line_out in scarlett2_update_meter_level_map()
3005 ) ? info->line_out_unmap[mux_idx] in scarlett2_update_meter_level_map()
3013 int mux_src = private->mux[mux_idx]; in scarlett2_update_meter_level_map()
3019 private->meter_level_map[map_mux_idx] = in scarlett2_update_meter_level_map()
3025 /* Send USB message to get mux inputs and then populate private->mux[] */
3028 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_get_mux()
3029 int count = private->num_mux_dsts; in scarlett2_usb_get_mux()
3039 private->mux_updated = 0; in scarlett2_usb_get_mux()
3061 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_mux()
3062 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_set_mux()
3063 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_usb_set_mux()
3084 for (entry = info->mux_assignment[table]; in scarlett2_usb_set_mux()
3085 entry->count; in scarlett2_usb_set_mux()
3088 int port_type = entry->port_type; in scarlett2_usb_set_mux()
3089 int port_idx = entry->start; in scarlett2_usb_set_mux()
3096 for (j = 0; j < entry->count; j++) in scarlett2_usb_set_mux()
3101 /* Non-empty mux slots use the lower 12 bits in scarlett2_usb_set_mux()
3105 for (j = 0; j < entry->count; j++) { in scarlett2_usb_set_mux()
3107 port_count, private->mux[mux_idx++]); in scarlett2_usb_set_mux()
3176 return -ENOMEM; in scarlett2_add_new_ctl()
3182 elem->head.mixer = mixer; in scarlett2_add_new_ctl()
3183 elem->control = index; in scarlett2_add_new_ctl()
3184 elem->head.id = 0; in scarlett2_add_new_ctl()
3185 elem->channels = channels; in scarlett2_add_new_ctl()
3186 elem->val_type = USB_MIXER_BESPOKEN; in scarlett2_add_new_ctl()
3191 return -ENOMEM; in scarlett2_add_new_ctl()
3193 kctl->private_free = snd_usb_mixer_elem_free; in scarlett2_add_new_ctl()
3195 strscpy(kctl->id.name, name, sizeof(kctl->id.name)); in scarlett2_add_new_ctl()
3197 err = snd_usb_mixer_add_control(&elem->head, kctl); in scarlett2_add_new_ctl()
3213 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_firmware_version_ctl_get()
3214 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_firmware_version_ctl_get()
3216 ucontrol->value.integer.value[0] = private->firmware_version; in scarlett2_firmware_version_ctl_get()
3225 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_firmware_version_ctl_info()
3226 uinfo->count = 1; in scarlett2_firmware_version_ctl_info()
3252 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_min_firmware_version_ctl_get()
3253 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_min_firmware_version_ctl_get()
3255 ucontrol->value.integer.value[0] = private->info->min_firmware_version; in scarlett2_min_firmware_version_ctl_get()
3264 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_min_firmware_version_ctl_info()
3265 uinfo->count = 1; in scarlett2_min_firmware_version_ctl_info()
3292 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_sync()
3294 private->sync_updated = 0; in scarlett2_update_sync()
3295 return scarlett2_usb_get_sync_status(mixer, &private->sync); in scarlett2_update_sync()
3310 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_sync_ctl_get()
3311 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_sync_ctl_get()
3312 struct scarlett2_data *private = mixer->private_data; in scarlett2_sync_ctl_get()
3315 mutex_lock(&private->data_mutex); in scarlett2_sync_ctl_get()
3317 if (private->hwdep_in_use) { in scarlett2_sync_ctl_get()
3318 err = -EBUSY; in scarlett2_sync_ctl_get()
3322 if (private->sync_updated) { in scarlett2_sync_ctl_get()
3327 ucontrol->value.enumerated.item[0] = private->sync; in scarlett2_sync_ctl_get()
3330 mutex_unlock(&private->data_mutex); in scarlett2_sync_ctl_get()
3344 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_sync_ctl()
3351 0, 1, "Sync Status", &private->sync_ctl); in scarlett2_add_sync_ctl()
3360 /* Set the access mode of a control to read-only (val = 0) or
3361 * read-write (val = 1).
3366 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_WRITE; in scarlett2_set_ctl_access()
3368 kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_WRITE; in scarlett2_set_ctl_access()
3377 for (i = 0; i < private->info->gain_input_count; i++) in scarlett2_autogain_is_running()
3378 if (!private->autogain_status[i]) in scarlett2_autogain_is_running()
3386 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_autogain()
3387 const struct scarlett2_device_info *info = private->info; in scarlett2_update_autogain()
3392 private->autogain_updated = 0; in scarlett2_update_autogain()
3394 if (!info->gain_input_count) in scarlett2_update_autogain()
3399 info->gain_input_count, private->autogain_switch); in scarlett2_update_autogain()
3404 info->gain_input_count, raw_autogain_status); in scarlett2_update_autogain()
3418 for (i = 0; i < info->gain_input_count; i++) in scarlett2_update_autogain()
3419 if (private->autogain_switch[i]) in scarlett2_update_autogain()
3420 private->autogain_status[i] = 0; in scarlett2_update_autogain()
3422 private->num_autogain_status_texts - 1) in scarlett2_update_autogain()
3423 private->autogain_status[i] = in scarlett2_update_autogain()
3426 private->autogain_status[i] = in scarlett2_update_autogain()
3427 private->num_autogain_status_texts - 1; in scarlett2_update_autogain()
3442 private->ag_targets[i] = -ag_target_values[i]; in scarlett2_update_autogain()
3450 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_update_access()
3451 const struct scarlett2_device_info *info = private->info; in scarlett2_autogain_update_access()
3457 scarlett2_set_ctl_access(private->input_select_ctl, val); in scarlett2_autogain_update_access()
3460 for (i = 0; i < info->gain_input_count; i++) in scarlett2_autogain_update_access()
3461 scarlett2_set_ctl_access(private->input_link_ctls[i], in scarlett2_autogain_update_access()
3463 for (i = 0; i < info->gain_input_count; i++) in scarlett2_autogain_update_access()
3464 scarlett2_set_ctl_access(private->input_gain_ctls[i], val); in scarlett2_autogain_update_access()
3465 for (i = 0; i < info->safe_input_count; i++) in scarlett2_autogain_update_access()
3466 scarlett2_set_ctl_access(private->safe_ctls[i], val); in scarlett2_autogain_update_access()
3467 for (i = 0; i < info->level_input_count; i++) in scarlett2_autogain_update_access()
3468 scarlett2_set_ctl_access(private->level_ctls[i], val); in scarlett2_autogain_update_access()
3469 for (i = 0; i < info->air_input_count; i++) in scarlett2_autogain_update_access()
3470 scarlett2_set_ctl_access(private->air_ctls[i], val); in scarlett2_autogain_update_access()
3471 for (i = 0; i < info->mute_input_count; i++) in scarlett2_autogain_update_access()
3472 scarlett2_set_ctl_access(private->input_mute_ctls[i], val); in scarlett2_autogain_update_access()
3473 for (i = 0; i < info->phantom_count; i++) in scarlett2_autogain_update_access()
3474 scarlett2_set_ctl_access(private->phantom_ctls[i], val); in scarlett2_autogain_update_access()
3475 for (i = 0; i < info->dsp_input_count; i++) in scarlett2_autogain_update_access()
3476 scarlett2_set_ctl_access(private->dsp_ctls[i], val); in scarlett2_autogain_update_access()
3482 private->ag_target_ctls[i], val); in scarlett2_autogain_update_access()
3485 /* Notify of access mode change for all controls read-only while
3490 struct snd_card *card = mixer->chip->card; in scarlett2_autogain_notify_access()
3491 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_notify_access()
3492 const struct scarlett2_device_info *info = private->info; in scarlett2_autogain_notify_access()
3498 &private->input_select_ctl->id); in scarlett2_autogain_notify_access()
3501 for (i = 0; i < info->gain_input_count; i++) in scarlett2_autogain_notify_access()
3503 &private->input_link_ctls[i]->id); in scarlett2_autogain_notify_access()
3504 for (i = 0; i < info->gain_input_count; i++) in scarlett2_autogain_notify_access()
3506 &private->input_gain_ctls[i]->id); in scarlett2_autogain_notify_access()
3507 for (i = 0; i < info->safe_input_count; i++) in scarlett2_autogain_notify_access()
3509 &private->safe_ctls[i]->id); in scarlett2_autogain_notify_access()
3510 for (i = 0; i < info->level_input_count; i++) in scarlett2_autogain_notify_access()
3512 &private->level_ctls[i]->id); in scarlett2_autogain_notify_access()
3513 for (i = 0; i < info->air_input_count; i++) in scarlett2_autogain_notify_access()
3515 &private->air_ctls[i]->id); in scarlett2_autogain_notify_access()
3516 for (i = 0; i < info->dsp_input_count; i++) in scarlett2_autogain_notify_access()
3518 &private->dsp_ctls[i]->id); in scarlett2_autogain_notify_access()
3519 for (i = 0; i < info->mute_input_count; i++) in scarlett2_autogain_notify_access()
3521 &private->input_mute_ctls[i]->id); in scarlett2_autogain_notify_access()
3522 for (i = 0; i < info->phantom_count; i++) in scarlett2_autogain_notify_access()
3524 &private->phantom_ctls[i]->id); in scarlett2_autogain_notify_access()
3530 &private->ag_target_ctls[i]->id); in scarlett2_autogain_notify_access()
3539 struct scarlett2_data *private = mixer->private_data; in scarlett2_check_autogain_updated()
3542 if (!private->autogain_updated) in scarlett2_check_autogain_updated()
3555 * control that is meant to be read-only while autogain is running,
3557 * Return -EPERM if autogain is running.
3567 if (scarlett2_autogain_is_running(mixer->private_data)) in scarlett2_check_put_during_autogain()
3568 return -EPERM; in scarlett2_check_put_during_autogain()
3576 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_switch_ctl_info()
3577 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_switch_ctl_info()
3578 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_switch_ctl_info()
3581 mutex_lock(&private->data_mutex); in scarlett2_autogain_switch_ctl_info()
3590 mutex_unlock(&private->data_mutex); in scarlett2_autogain_switch_ctl_info()
3597 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_switch_ctl_get()
3598 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_switch_ctl_get()
3599 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_switch_ctl_get()
3602 mutex_lock(&private->data_mutex); in scarlett2_autogain_switch_ctl_get()
3604 if (private->hwdep_in_use) { in scarlett2_autogain_switch_ctl_get()
3605 err = -EBUSY; in scarlett2_autogain_switch_ctl_get()
3613 ucontrol->value.enumerated.item[0] = in scarlett2_autogain_switch_ctl_get()
3614 private->autogain_switch[elem->control]; in scarlett2_autogain_switch_ctl_get()
3617 mutex_unlock(&private->data_mutex); in scarlett2_autogain_switch_ctl_get()
3624 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_status_ctl_get()
3625 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_status_ctl_get()
3626 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_status_ctl_get()
3629 mutex_lock(&private->data_mutex); in scarlett2_autogain_status_ctl_get()
3631 if (private->hwdep_in_use) { in scarlett2_autogain_status_ctl_get()
3632 err = -EBUSY; in scarlett2_autogain_status_ctl_get()
3640 ucontrol->value.enumerated.item[0] = in scarlett2_autogain_status_ctl_get()
3641 private->autogain_status[elem->control]; in scarlett2_autogain_status_ctl_get()
3644 mutex_unlock(&private->data_mutex); in scarlett2_autogain_status_ctl_get()
3651 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_switch_ctl_put()
3652 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_switch_ctl_put()
3653 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_switch_ctl_put()
3655 int index = elem->control; in scarlett2_autogain_switch_ctl_put()
3658 mutex_lock(&private->data_mutex); in scarlett2_autogain_switch_ctl_put()
3660 if (private->hwdep_in_use) { in scarlett2_autogain_switch_ctl_put()
3661 err = -EBUSY; in scarlett2_autogain_switch_ctl_put()
3670 err = -EPERM; in scarlett2_autogain_switch_ctl_put()
3674 oval = private->autogain_switch[index]; in scarlett2_autogain_switch_ctl_put()
3675 val = !!ucontrol->value.integer.value[0]; in scarlett2_autogain_switch_ctl_put()
3680 private->autogain_switch[index] = val; in scarlett2_autogain_switch_ctl_put()
3692 mutex_unlock(&private->data_mutex); in scarlett2_autogain_switch_ctl_put()
3699 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_status_ctl_info()
3700 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_autogain_status_ctl_info()
3704 private->num_autogain_status_texts, in scarlett2_autogain_status_ctl_info()
3705 private->config_set->autogain_status_texts); in scarlett2_autogain_status_ctl_info()
3729 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_ag_target_ctl_info()
3730 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_ag_target_ctl_info()
3731 struct scarlett2_data *private = mixer->private_data; in scarlett2_ag_target_ctl_info()
3734 mutex_lock(&private->data_mutex); in scarlett2_ag_target_ctl_info()
3736 if (private->hwdep_in_use) { in scarlett2_ag_target_ctl_info()
3737 err = -EBUSY; in scarlett2_ag_target_ctl_info()
3745 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_ag_target_ctl_info()
3746 uinfo->count = 1; in scarlett2_ag_target_ctl_info()
3747 uinfo->value.integer.min = SCARLETT2_AG_TARGET_MIN; in scarlett2_ag_target_ctl_info()
3748 uinfo->value.integer.max = 0; in scarlett2_ag_target_ctl_info()
3749 uinfo->value.integer.step = 1; in scarlett2_ag_target_ctl_info()
3752 mutex_unlock(&private->data_mutex); in scarlett2_ag_target_ctl_info()
3759 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_ag_target_ctl_get()
3760 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_ag_target_ctl_get()
3761 struct scarlett2_data *private = mixer->private_data; in scarlett2_ag_target_ctl_get()
3764 mutex_lock(&private->data_mutex); in scarlett2_ag_target_ctl_get()
3766 if (private->hwdep_in_use) { in scarlett2_ag_target_ctl_get()
3767 err = -EBUSY; in scarlett2_ag_target_ctl_get()
3771 if (private->autogain_updated) { in scarlett2_ag_target_ctl_get()
3777 ucontrol->value.integer.value[0] = private->ag_targets[elem->control]; in scarlett2_ag_target_ctl_get()
3780 mutex_unlock(&private->data_mutex); in scarlett2_ag_target_ctl_get()
3787 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_ag_target_ctl_put()
3788 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_ag_target_ctl_put()
3789 struct scarlett2_data *private = mixer->private_data; in scarlett2_ag_target_ctl_put()
3791 int index = elem->control; in scarlett2_ag_target_ctl_put()
3794 mutex_lock(&private->data_mutex); in scarlett2_ag_target_ctl_put()
3796 if (private->hwdep_in_use) { in scarlett2_ag_target_ctl_put()
3797 err = -EBUSY; in scarlett2_ag_target_ctl_put()
3805 oval = private->ag_targets[index]; in scarlett2_ag_target_ctl_put()
3806 val = clamp(ucontrol->value.integer.value[0], in scarlett2_ag_target_ctl_put()
3812 private->ag_targets[index] = val; in scarlett2_ag_target_ctl_put()
3816 mixer, scarlett2_ag_target_configs[index], 1, -val); in scarlett2_ag_target_ctl_put()
3821 mutex_unlock(&private->data_mutex); in scarlett2_ag_target_ctl_put()
3837 .tlv = { .p = db_scale_ag_target }
3844 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_select()
3845 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_select()
3846 int link_count = info->gain_input_count; in scarlett2_update_input_select()
3849 private->input_select_updated = 0; in scarlett2_update_input_select()
3858 1, &private->input_select_switch); in scarlett2_update_input_select()
3864 link_count, private->input_link_switch); in scarlett2_update_input_select()
3874 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_select_ctl_get()
3875 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_select_ctl_get()
3876 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_select_ctl_get()
3879 mutex_lock(&private->data_mutex); in scarlett2_input_select_ctl_get()
3881 if (private->hwdep_in_use) { in scarlett2_input_select_ctl_get()
3882 err = -EBUSY; in scarlett2_input_select_ctl_get()
3886 if (private->input_select_updated) { in scarlett2_input_select_ctl_get()
3891 ucontrol->value.enumerated.item[0] = private->input_select_switch; in scarlett2_input_select_ctl_get()
3894 mutex_unlock(&private->data_mutex); in scarlett2_input_select_ctl_get()
3901 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_select_ctl_put()
3902 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_select_ctl_put()
3903 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_select_ctl_put()
3904 const struct scarlett2_device_info *info = private->info; in scarlett2_input_select_ctl_put()
3908 mutex_lock(&private->data_mutex); in scarlett2_input_select_ctl_put()
3910 if (private->hwdep_in_use) { in scarlett2_input_select_ctl_put()
3911 err = -EBUSY; in scarlett2_input_select_ctl_put()
3919 oval = private->input_select_switch; in scarlett2_input_select_ctl_put()
3920 val = ucontrol->value.integer.value[0]; in scarlett2_input_select_ctl_put()
3924 else if (val >= info->gain_input_count) in scarlett2_input_select_ctl_put()
3925 val = info->gain_input_count - 1; in scarlett2_input_select_ctl_put()
3930 private->input_select_switch = val; in scarlett2_input_select_ctl_put()
3940 mutex_unlock(&private->data_mutex); in scarlett2_input_select_ctl_put()
3947 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_select_ctl_info()
3948 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_select_ctl_info()
3949 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_select_ctl_info()
3951 int inputs = private->info->gain_input_count; in scarlett2_input_select_ctl_info()
3956 return -ENOMEM; in scarlett2_input_select_ctl_info()
3958 mutex_lock(&private->data_mutex); in scarlett2_input_select_ctl_info()
3960 if (private->hwdep_in_use) { in scarlett2_input_select_ctl_info()
3961 err = -EBUSY; in scarlett2_input_select_ctl_info()
3977 mutex_unlock(&private->data_mutex); in scarlett2_input_select_ctl_info()
3996 /* snd_ctl_boolean_mono_info() with autogain-updated check
3997 * (for controls that are read-only while autogain is running)
4002 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_autogain_disables_ctl_info()
4003 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_autogain_disables_ctl_info()
4004 struct scarlett2_data *private = mixer->private_data; in scarlett2_autogain_disables_ctl_info()
4007 mutex_lock(&private->data_mutex); in scarlett2_autogain_disables_ctl_info()
4009 if (private->hwdep_in_use) { in scarlett2_autogain_disables_ctl_info()
4010 err = -EBUSY; in scarlett2_autogain_disables_ctl_info()
4021 mutex_unlock(&private->data_mutex); in scarlett2_autogain_disables_ctl_info()
4028 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_link_ctl_get()
4029 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_link_ctl_get()
4030 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_link_ctl_get()
4033 mutex_lock(&private->data_mutex); in scarlett2_input_link_ctl_get()
4035 if (private->hwdep_in_use) { in scarlett2_input_link_ctl_get()
4036 err = -EBUSY; in scarlett2_input_link_ctl_get()
4040 if (private->input_select_updated) { in scarlett2_input_link_ctl_get()
4045 ucontrol->value.enumerated.item[0] = in scarlett2_input_link_ctl_get()
4046 private->input_link_switch[elem->control]; in scarlett2_input_link_ctl_get()
4049 mutex_unlock(&private->data_mutex); in scarlett2_input_link_ctl_get()
4056 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_link_ctl_put()
4057 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_link_ctl_put()
4058 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_link_ctl_put()
4060 int index = elem->control; in scarlett2_input_link_ctl_put()
4063 mutex_lock(&private->data_mutex); in scarlett2_input_link_ctl_put()
4065 if (private->hwdep_in_use) { in scarlett2_input_link_ctl_put()
4066 err = -EBUSY; in scarlett2_input_link_ctl_put()
4074 oval = private->input_link_switch[index]; in scarlett2_input_link_ctl_put()
4075 val = !!ucontrol->value.integer.value[0]; in scarlett2_input_link_ctl_put()
4080 private->input_link_switch[index] = val; in scarlett2_input_link_ctl_put()
4088 mutex_unlock(&private->data_mutex); in scarlett2_input_link_ctl_put()
4104 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_gain()
4105 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_gain()
4107 private->input_gain_updated = 0; in scarlett2_update_input_gain()
4109 if (!info->gain_input_count) in scarlett2_update_input_gain()
4114 info->gain_input_count, private->gain); in scarlett2_update_input_gain()
4120 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_gain_ctl_info()
4121 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_gain_ctl_info()
4122 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_gain_ctl_info()
4125 mutex_lock(&private->data_mutex); in scarlett2_input_gain_ctl_info()
4127 if (private->hwdep_in_use) { in scarlett2_input_gain_ctl_info()
4128 err = -EBUSY; in scarlett2_input_gain_ctl_info()
4136 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_input_gain_ctl_info()
4137 uinfo->count = elem->channels; in scarlett2_input_gain_ctl_info()
4138 uinfo->value.integer.min = 0; in scarlett2_input_gain_ctl_info()
4139 uinfo->value.integer.max = SCARLETT2_MAX_GAIN_VALUE; in scarlett2_input_gain_ctl_info()
4140 uinfo->value.integer.step = 1; in scarlett2_input_gain_ctl_info()
4143 mutex_unlock(&private->data_mutex); in scarlett2_input_gain_ctl_info()
4150 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_gain_ctl_get()
4151 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_gain_ctl_get()
4152 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_gain_ctl_get()
4155 mutex_lock(&private->data_mutex); in scarlett2_input_gain_ctl_get()
4157 if (private->hwdep_in_use) { in scarlett2_input_gain_ctl_get()
4158 err = -EBUSY; in scarlett2_input_gain_ctl_get()
4162 if (private->input_gain_updated) { in scarlett2_input_gain_ctl_get()
4167 ucontrol->value.integer.value[0] = in scarlett2_input_gain_ctl_get()
4168 private->gain[elem->control]; in scarlett2_input_gain_ctl_get()
4171 mutex_unlock(&private->data_mutex); in scarlett2_input_gain_ctl_get()
4178 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_gain_ctl_put()
4179 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_gain_ctl_put()
4180 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_gain_ctl_put()
4182 int index = elem->control; in scarlett2_input_gain_ctl_put()
4185 mutex_lock(&private->data_mutex); in scarlett2_input_gain_ctl_put()
4187 if (private->hwdep_in_use) { in scarlett2_input_gain_ctl_put()
4188 err = -EBUSY; in scarlett2_input_gain_ctl_put()
4196 oval = private->gain[index]; in scarlett2_input_gain_ctl_put()
4197 val = ucontrol->value.integer.value[0]; in scarlett2_input_gain_ctl_put()
4202 private->gain[index] = val; in scarlett2_input_gain_ctl_put()
4211 mutex_unlock(&private->data_mutex); in scarlett2_input_gain_ctl_put()
4230 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_safe()
4231 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_safe()
4233 private->input_safe_updated = 0; in scarlett2_update_input_safe()
4235 if (!info->safe_input_count) in scarlett2_update_input_safe()
4240 info->safe_input_count, private->safe_switch); in scarlett2_update_input_safe()
4246 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_safe_ctl_get()
4247 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_safe_ctl_get()
4248 struct scarlett2_data *private = mixer->private_data; in scarlett2_safe_ctl_get()
4251 mutex_lock(&private->data_mutex); in scarlett2_safe_ctl_get()
4253 if (private->hwdep_in_use) { in scarlett2_safe_ctl_get()
4254 err = -EBUSY; in scarlett2_safe_ctl_get()
4258 if (private->input_safe_updated) { in scarlett2_safe_ctl_get()
4263 ucontrol->value.integer.value[0] = in scarlett2_safe_ctl_get()
4264 private->safe_switch[elem->control]; in scarlett2_safe_ctl_get()
4267 mutex_unlock(&private->data_mutex); in scarlett2_safe_ctl_get()
4274 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_safe_ctl_put()
4275 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_safe_ctl_put()
4276 struct scarlett2_data *private = mixer->private_data; in scarlett2_safe_ctl_put()
4278 int index = elem->control; in scarlett2_safe_ctl_put()
4281 mutex_lock(&private->data_mutex); in scarlett2_safe_ctl_put()
4283 if (private->hwdep_in_use) { in scarlett2_safe_ctl_put()
4284 err = -EBUSY; in scarlett2_safe_ctl_put()
4292 oval = private->safe_switch[index]; in scarlett2_safe_ctl_put()
4293 val = !!ucontrol->value.integer.value[0]; in scarlett2_safe_ctl_put()
4298 private->safe_switch[index] = val; in scarlett2_safe_ctl_put()
4307 mutex_unlock(&private->data_mutex); in scarlett2_safe_ctl_put()
4323 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_pcm_input_switch()
4326 private->pcm_input_switch_updated = 0; in scarlett2_update_pcm_input_switch()
4330 1, &private->pcm_input_switch); in scarlett2_update_pcm_input_switch()
4340 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pcm_input_switch_ctl_get()
4341 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pcm_input_switch_ctl_get()
4342 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_pcm_input_switch_ctl_get()
4345 mutex_lock(&private->data_mutex); in scarlett2_pcm_input_switch_ctl_get()
4347 if (private->pcm_input_switch_updated) { in scarlett2_pcm_input_switch_ctl_get()
4352 ucontrol->value.enumerated.item[0] = private->pcm_input_switch; in scarlett2_pcm_input_switch_ctl_get()
4355 mutex_unlock(&private->data_mutex); in scarlett2_pcm_input_switch_ctl_get()
4362 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pcm_input_switch_ctl_put()
4363 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pcm_input_switch_ctl_put()
4364 struct scarlett2_data *private = mixer->private_data; in scarlett2_pcm_input_switch_ctl_put()
4368 mutex_lock(&private->data_mutex); in scarlett2_pcm_input_switch_ctl_put()
4370 if (private->hwdep_in_use) { in scarlett2_pcm_input_switch_ctl_put()
4371 err = -EBUSY; in scarlett2_pcm_input_switch_ctl_put()
4375 oval = private->pcm_input_switch; in scarlett2_pcm_input_switch_ctl_put()
4376 val = !!ucontrol->value.integer.value[0]; in scarlett2_pcm_input_switch_ctl_put()
4381 private->pcm_input_switch = val; in scarlett2_pcm_input_switch_ctl_put()
4391 mutex_unlock(&private->data_mutex); in scarlett2_pcm_input_switch_ctl_put()
4421 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_volumes()
4425 private->vol_updated = 0; in scarlett2_update_volumes()
4435 private->master_vol = clamp(vol + SCARLETT2_VOLUME_BIAS, in scarlett2_update_volumes()
4440 for (i = 0; i < private->num_line_out; i++) in scarlett2_update_volumes()
4441 if (private->vol_sw_hw_switch[i]) in scarlett2_update_volumes()
4442 private->vol[i] = private->master_vol; in scarlett2_update_volumes()
4453 private->headphone_vol = clamp(vol + SCARLETT2_VOLUME_BIAS, in scarlett2_update_volumes()
4463 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_volume_ctl_info()
4465 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_volume_ctl_info()
4466 uinfo->count = elem->channels; in scarlett2_volume_ctl_info()
4467 uinfo->value.integer.min = 0; in scarlett2_volume_ctl_info()
4468 uinfo->value.integer.max = SCARLETT2_VOLUME_BIAS; in scarlett2_volume_ctl_info()
4469 uinfo->value.integer.step = 1; in scarlett2_volume_ctl_info()
4476 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_master_volume_ctl_get()
4477 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_master_volume_ctl_get()
4478 struct scarlett2_data *private = mixer->private_data; in scarlett2_master_volume_ctl_get()
4481 mutex_lock(&private->data_mutex); in scarlett2_master_volume_ctl_get()
4483 if (private->hwdep_in_use) { in scarlett2_master_volume_ctl_get()
4484 err = -EBUSY; in scarlett2_master_volume_ctl_get()
4488 if (private->vol_updated) { in scarlett2_master_volume_ctl_get()
4493 ucontrol->value.integer.value[0] = private->master_vol; in scarlett2_master_volume_ctl_get()
4496 mutex_unlock(&private->data_mutex); in scarlett2_master_volume_ctl_get()
4504 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_headphone_volume_ctl_get()
4505 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_headphone_volume_ctl_get()
4506 struct scarlett2_data *private = mixer->private_data; in scarlett2_headphone_volume_ctl_get()
4509 mutex_lock(&private->data_mutex); in scarlett2_headphone_volume_ctl_get()
4511 if (private->hwdep_in_use) { in scarlett2_headphone_volume_ctl_get()
4512 err = -EBUSY; in scarlett2_headphone_volume_ctl_get()
4516 if (private->vol_updated) { in scarlett2_headphone_volume_ctl_get()
4521 ucontrol->value.integer.value[0] = private->headphone_vol; in scarlett2_headphone_volume_ctl_get()
4524 mutex_unlock(&private->data_mutex); in scarlett2_headphone_volume_ctl_get()
4530 const struct scarlett2_device_info *info = private->info; in line_out_remap()
4532 if (!info->line_out_remap_enable) in line_out_remap()
4535 if (index >= private->num_line_out) in line_out_remap()
4538 return info->line_out_remap[index]; in line_out_remap()
4544 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_volume_ctl_get()
4545 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_volume_ctl_get()
4546 struct scarlett2_data *private = mixer->private_data; in scarlett2_volume_ctl_get()
4547 int index = line_out_remap(private, elem->control); in scarlett2_volume_ctl_get()
4550 mutex_lock(&private->data_mutex); in scarlett2_volume_ctl_get()
4552 if (private->hwdep_in_use) { in scarlett2_volume_ctl_get()
4553 err = -EBUSY; in scarlett2_volume_ctl_get()
4557 if (private->vol_updated) { in scarlett2_volume_ctl_get()
4562 ucontrol->value.integer.value[0] = private->vol[index]; in scarlett2_volume_ctl_get()
4565 mutex_unlock(&private->data_mutex); in scarlett2_volume_ctl_get()
4572 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_volume_ctl_put()
4573 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_volume_ctl_put()
4574 struct scarlett2_data *private = mixer->private_data; in scarlett2_volume_ctl_put()
4575 int index = line_out_remap(private, elem->control); in scarlett2_volume_ctl_put()
4578 mutex_lock(&private->data_mutex); in scarlett2_volume_ctl_put()
4580 if (private->hwdep_in_use) { in scarlett2_volume_ctl_put()
4581 err = -EBUSY; in scarlett2_volume_ctl_put()
4585 oval = private->vol[index]; in scarlett2_volume_ctl_put()
4586 val = ucontrol->value.integer.value[0]; in scarlett2_volume_ctl_put()
4591 private->vol[index] = val; in scarlett2_volume_ctl_put()
4593 index, val - SCARLETT2_VOLUME_BIAS); in scarlett2_volume_ctl_put()
4598 mutex_unlock(&private->data_mutex); in scarlett2_volume_ctl_put()
4603 db_scale_scarlett2_volume, -SCARLETT2_VOLUME_BIAS * 100, 0
4614 .tlv = { .p = db_scale_scarlett2_volume }
4625 .tlv = { .p = db_scale_scarlett2_volume }
4637 .tlv = { .p = db_scale_scarlett2_volume }
4644 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_dim_mute()
4648 private->dim_mute_updated = 0; in scarlett2_update_dim_mute()
4655 SCARLETT2_DIM_MUTE_COUNT, private->dim_mute); in scarlett2_update_dim_mute()
4660 private->dim_mute[i] = !!private->dim_mute[i]; in scarlett2_update_dim_mute()
4662 mute = private->dim_mute[SCARLETT2_BUTTON_MUTE]; in scarlett2_update_dim_mute()
4664 for (i = 0; i < private->num_line_out; i++) in scarlett2_update_dim_mute()
4665 if (private->vol_sw_hw_switch[i]) in scarlett2_update_dim_mute()
4666 private->mute_switch[i] = mute; in scarlett2_update_dim_mute()
4674 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mute_ctl_get()
4675 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mute_ctl_get()
4676 struct scarlett2_data *private = mixer->private_data; in scarlett2_mute_ctl_get()
4677 int index = line_out_remap(private, elem->control); in scarlett2_mute_ctl_get()
4680 mutex_lock(&private->data_mutex); in scarlett2_mute_ctl_get()
4682 if (private->hwdep_in_use) { in scarlett2_mute_ctl_get()
4683 err = -EBUSY; in scarlett2_mute_ctl_get()
4687 if (private->dim_mute_updated) { in scarlett2_mute_ctl_get()
4692 ucontrol->value.integer.value[0] = private->mute_switch[index]; in scarlett2_mute_ctl_get()
4695 mutex_unlock(&private->data_mutex); in scarlett2_mute_ctl_get()
4702 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mute_ctl_put()
4703 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mute_ctl_put()
4704 struct scarlett2_data *private = mixer->private_data; in scarlett2_mute_ctl_put()
4705 int index = line_out_remap(private, elem->control); in scarlett2_mute_ctl_put()
4708 mutex_lock(&private->data_mutex); in scarlett2_mute_ctl_put()
4710 if (private->hwdep_in_use) { in scarlett2_mute_ctl_put()
4711 err = -EBUSY; in scarlett2_mute_ctl_put()
4715 oval = private->mute_switch[index]; in scarlett2_mute_ctl_put()
4716 val = !!ucontrol->value.integer.value[0]; in scarlett2_mute_ctl_put()
4721 private->mute_switch[index] = val; in scarlett2_mute_ctl_put()
4730 mutex_unlock(&private->data_mutex); in scarlett2_mute_ctl_put()
4746 private->sw_hw_ctls[index]->vd[0].access &= in scarlett2_sw_hw_ctl_ro()
4752 private->sw_hw_ctls[index]->vd[0].access |= in scarlett2_sw_hw_ctl_rw()
4769 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_sw_hw_enum_ctl_get()
4770 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_sw_hw_enum_ctl_get()
4771 int index = line_out_remap(private, elem->control); in scarlett2_sw_hw_enum_ctl_get()
4773 ucontrol->value.enumerated.item[0] = private->vol_sw_hw_switch[index]; in scarlett2_sw_hw_enum_ctl_get()
4780 struct scarlett2_data *private = mixer->private_data; in scarlett2_vol_ctl_set_writable()
4781 struct snd_card *card = mixer->chip->card; in scarlett2_vol_ctl_set_writable()
4785 private->vol_ctls[index]->vd[0].access |= in scarlett2_vol_ctl_set_writable()
4787 private->mute_ctls[index]->vd[0].access |= in scarlett2_vol_ctl_set_writable()
4790 private->vol_ctls[index]->vd[0].access &= in scarlett2_vol_ctl_set_writable()
4792 private->mute_ctls[index]->vd[0].access &= in scarlett2_vol_ctl_set_writable()
4799 &private->vol_ctls[index]->id); in scarlett2_vol_ctl_set_writable()
4802 &private->mute_ctls[index]->id); in scarlett2_vol_ctl_set_writable()
4808 struct scarlett2_data *private = mixer->private_data; in scarlett2_sw_hw_change()
4812 private->vol_sw_hw_switch[index] = val; in scarlett2_sw_hw_change()
4820 private->vol[index] = private->master_vol; in scarlett2_sw_hw_change()
4821 private->mute_switch[index] = private->dim_mute[SCARLETT2_BUTTON_MUTE]; in scarlett2_sw_hw_change()
4826 index, private->master_vol - SCARLETT2_VOLUME_BIAS); in scarlett2_sw_hw_change()
4833 index, private->dim_mute[SCARLETT2_BUTTON_MUTE]); in scarlett2_sw_hw_change()
4845 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_sw_hw_enum_ctl_put()
4846 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_sw_hw_enum_ctl_put()
4847 struct scarlett2_data *private = mixer->private_data; in scarlett2_sw_hw_enum_ctl_put()
4848 int ctl_index = elem->control; in scarlett2_sw_hw_enum_ctl_put()
4852 mutex_lock(&private->data_mutex); in scarlett2_sw_hw_enum_ctl_put()
4854 if (private->hwdep_in_use) { in scarlett2_sw_hw_enum_ctl_put()
4855 err = -EBUSY; in scarlett2_sw_hw_enum_ctl_put()
4859 oval = private->vol_sw_hw_switch[index]; in scarlett2_sw_hw_enum_ctl_put()
4860 val = !!ucontrol->value.enumerated.item[0]; in scarlett2_sw_hw_enum_ctl_put()
4870 mutex_unlock(&private->data_mutex); in scarlett2_sw_hw_enum_ctl_put()
4886 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_level()
4887 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_level()
4889 private->input_level_updated = 0; in scarlett2_update_input_level()
4891 if (!info->level_input_count) in scarlett2_update_input_level()
4896 info->level_input_count + info->level_input_first, in scarlett2_update_input_level()
4897 private->level_switch); in scarlett2_update_input_level()
4906 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_level_enum_ctl_info()
4907 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_level_enum_ctl_info()
4908 struct scarlett2_data *private = mixer->private_data; in scarlett2_level_enum_ctl_info()
4911 mutex_lock(&private->data_mutex); in scarlett2_level_enum_ctl_info()
4913 if (private->hwdep_in_use) { in scarlett2_level_enum_ctl_info()
4914 err = -EBUSY; in scarlett2_level_enum_ctl_info()
4925 mutex_unlock(&private->data_mutex); in scarlett2_level_enum_ctl_info()
4932 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_level_enum_ctl_get()
4933 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_level_enum_ctl_get()
4934 struct scarlett2_data *private = mixer->private_data; in scarlett2_level_enum_ctl_get()
4935 const struct scarlett2_device_info *info = private->info; in scarlett2_level_enum_ctl_get()
4937 int index = elem->control + info->level_input_first; in scarlett2_level_enum_ctl_get()
4940 mutex_lock(&private->data_mutex); in scarlett2_level_enum_ctl_get()
4942 if (private->hwdep_in_use) { in scarlett2_level_enum_ctl_get()
4943 err = -EBUSY; in scarlett2_level_enum_ctl_get()
4947 if (private->input_level_updated) { in scarlett2_level_enum_ctl_get()
4952 ucontrol->value.enumerated.item[0] = scarlett2_decode_muteable( in scarlett2_level_enum_ctl_get()
4953 private->level_switch[index]); in scarlett2_level_enum_ctl_get()
4956 mutex_unlock(&private->data_mutex); in scarlett2_level_enum_ctl_get()
4963 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_level_enum_ctl_put()
4964 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_level_enum_ctl_put()
4965 struct scarlett2_data *private = mixer->private_data; in scarlett2_level_enum_ctl_put()
4966 const struct scarlett2_device_info *info = private->info; in scarlett2_level_enum_ctl_put()
4968 int index = elem->control + info->level_input_first; in scarlett2_level_enum_ctl_put()
4971 mutex_lock(&private->data_mutex); in scarlett2_level_enum_ctl_put()
4973 if (private->hwdep_in_use) { in scarlett2_level_enum_ctl_put()
4974 err = -EBUSY; in scarlett2_level_enum_ctl_put()
4982 oval = private->level_switch[index]; in scarlett2_level_enum_ctl_put()
4983 val = !!ucontrol->value.enumerated.item[0]; in scarlett2_level_enum_ctl_put()
4988 private->level_switch[index] = val; in scarlett2_level_enum_ctl_put()
4991 if (private->config_set->items[SCARLETT2_CONFIG_LEVEL_SWITCH].mute) in scarlett2_level_enum_ctl_put()
5001 mutex_unlock(&private->data_mutex); in scarlett2_level_enum_ctl_put()
5017 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_pad()
5018 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_pad()
5020 private->input_pad_updated = 0; in scarlett2_update_input_pad()
5022 if (!info->pad_input_count) in scarlett2_update_input_pad()
5027 info->pad_input_count, private->pad_switch); in scarlett2_update_input_pad()
5033 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pad_ctl_get()
5034 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pad_ctl_get()
5035 struct scarlett2_data *private = mixer->private_data; in scarlett2_pad_ctl_get()
5038 mutex_lock(&private->data_mutex); in scarlett2_pad_ctl_get()
5040 if (private->hwdep_in_use) { in scarlett2_pad_ctl_get()
5041 err = -EBUSY; in scarlett2_pad_ctl_get()
5045 if (private->input_pad_updated) { in scarlett2_pad_ctl_get()
5050 ucontrol->value.integer.value[0] = in scarlett2_pad_ctl_get()
5051 private->pad_switch[elem->control]; in scarlett2_pad_ctl_get()
5054 mutex_unlock(&private->data_mutex); in scarlett2_pad_ctl_get()
5061 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pad_ctl_put()
5062 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pad_ctl_put()
5063 struct scarlett2_data *private = mixer->private_data; in scarlett2_pad_ctl_put()
5065 int index = elem->control; in scarlett2_pad_ctl_put()
5068 mutex_lock(&private->data_mutex); in scarlett2_pad_ctl_put()
5070 if (private->hwdep_in_use) { in scarlett2_pad_ctl_put()
5071 err = -EBUSY; in scarlett2_pad_ctl_put()
5075 oval = private->pad_switch[index]; in scarlett2_pad_ctl_put()
5076 val = !!ucontrol->value.integer.value[0]; in scarlett2_pad_ctl_put()
5081 private->pad_switch[index] = val; in scarlett2_pad_ctl_put()
5090 mutex_unlock(&private->data_mutex); in scarlett2_pad_ctl_put()
5106 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_air()
5107 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_air()
5109 private->input_air_updated = 0; in scarlett2_update_input_air()
5111 if (!info->air_input_count) in scarlett2_update_input_air()
5116 info->air_input_count, private->air_switch); in scarlett2_update_input_air()
5122 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_air_ctl_get()
5123 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_air_ctl_get()
5124 struct scarlett2_data *private = mixer->private_data; in scarlett2_air_ctl_get()
5127 mutex_lock(&private->data_mutex); in scarlett2_air_ctl_get()
5129 if (private->hwdep_in_use) { in scarlett2_air_ctl_get()
5130 err = -EBUSY; in scarlett2_air_ctl_get()
5134 if (private->input_air_updated) { in scarlett2_air_ctl_get()
5139 ucontrol->value.integer.value[0] = private->air_switch[elem->control]; in scarlett2_air_ctl_get()
5142 mutex_unlock(&private->data_mutex); in scarlett2_air_ctl_get()
5149 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_air_ctl_put()
5150 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_air_ctl_put()
5151 struct scarlett2_data *private = mixer->private_data; in scarlett2_air_ctl_put()
5153 int index = elem->control; in scarlett2_air_ctl_put()
5156 mutex_lock(&private->data_mutex); in scarlett2_air_ctl_put()
5158 if (private->hwdep_in_use) { in scarlett2_air_ctl_put()
5159 err = -EBUSY; in scarlett2_air_ctl_put()
5167 oval = private->air_switch[index]; in scarlett2_air_ctl_put()
5168 val = ucontrol->value.integer.value[0]; in scarlett2_air_ctl_put()
5173 private->air_switch[index] = val; in scarlett2_air_ctl_put()
5182 mutex_unlock(&private->data_mutex); in scarlett2_air_ctl_put()
5192 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_air_with_drive_ctl_info()
5193 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_air_with_drive_ctl_info()
5194 struct scarlett2_data *private = mixer->private_data; in scarlett2_air_with_drive_ctl_info()
5197 mutex_lock(&private->data_mutex); in scarlett2_air_with_drive_ctl_info()
5199 if (private->hwdep_in_use) { in scarlett2_air_with_drive_ctl_info()
5200 err = -EBUSY; in scarlett2_air_with_drive_ctl_info()
5211 mutex_unlock(&private->data_mutex); in scarlett2_air_with_drive_ctl_info()
5236 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_dsp()
5237 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_dsp()
5239 private->input_dsp_updated = 0; in scarlett2_update_input_dsp()
5241 if (!info->dsp_input_count) in scarlett2_update_input_dsp()
5246 info->dsp_input_count, private->dsp_switch); in scarlett2_update_input_dsp()
5252 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dsp_ctl_get()
5253 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dsp_ctl_get()
5254 struct scarlett2_data *private = mixer->private_data; in scarlett2_dsp_ctl_get()
5257 mutex_lock(&private->data_mutex); in scarlett2_dsp_ctl_get()
5259 if (private->hwdep_in_use) { in scarlett2_dsp_ctl_get()
5260 err = -EBUSY; in scarlett2_dsp_ctl_get()
5264 if (private->input_dsp_updated) { in scarlett2_dsp_ctl_get()
5269 ucontrol->value.integer.value[0] = private->dsp_switch[elem->control]; in scarlett2_dsp_ctl_get()
5272 mutex_unlock(&private->data_mutex); in scarlett2_dsp_ctl_get()
5279 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dsp_ctl_put()
5280 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dsp_ctl_put()
5281 struct scarlett2_data *private = mixer->private_data; in scarlett2_dsp_ctl_put()
5283 int index = elem->control; in scarlett2_dsp_ctl_put()
5286 mutex_lock(&private->data_mutex); in scarlett2_dsp_ctl_put()
5288 if (private->hwdep_in_use) { in scarlett2_dsp_ctl_put()
5289 err = -EBUSY; in scarlett2_dsp_ctl_put()
5297 oval = private->dsp_switch[index]; in scarlett2_dsp_ctl_put()
5298 val = ucontrol->value.integer.value[0]; in scarlett2_dsp_ctl_put()
5303 private->dsp_switch[index] = val; in scarlett2_dsp_ctl_put()
5312 mutex_unlock(&private->data_mutex); in scarlett2_dsp_ctl_put()
5328 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_compressor_values()
5329 const struct scarlett2_device_info *info = private->info; in scarlett2_update_compressor_values()
5332 if (!info->dsp_input_count) in scarlett2_update_compressor_values()
5337 SCARLETT2_COMPRESSOR_PARAM_COUNT * info->dsp_input_count, in scarlett2_update_compressor_values()
5338 private->compressor_values); in scarlett2_update_compressor_values()
5346 for (j = 0; j < info->dsp_input_count; j++) { in scarlett2_update_compressor_values()
5348 int val = private->compressor_values[idx]; in scarlett2_update_compressor_values()
5350 val >>= param->scale_bits; in scarlett2_update_compressor_values()
5351 val = clamp(val, param->min, param->max); in scarlett2_update_compressor_values()
5352 private->compressor_values[idx] = val; in scarlett2_update_compressor_values()
5362 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_compressor_ctl_get()
5363 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_compressor_ctl_get()
5365 ucontrol->value.integer.value[0] = in scarlett2_compressor_ctl_get()
5366 private->compressor_values[elem->control]; in scarlett2_compressor_ctl_get()
5373 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_compressor_ctl_put()
5374 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_compressor_ctl_put()
5375 struct scarlett2_data *private = mixer->private_data; in scarlett2_compressor_ctl_put()
5377 int index = elem->control; in scarlett2_compressor_ctl_put()
5385 mutex_lock(&private->data_mutex); in scarlett2_compressor_ctl_put()
5387 if (private->hwdep_in_use) { in scarlett2_compressor_ctl_put()
5388 err = -EBUSY; in scarlett2_compressor_ctl_put()
5396 oval = private->compressor_values[index]; in scarlett2_compressor_ctl_put()
5397 val = ucontrol->value.integer.value[0]; in scarlett2_compressor_ctl_put()
5401 private->compressor_values[index] = val; in scarlett2_compressor_ctl_put()
5403 scaled_val = val << param->scale_bits; in scarlett2_compressor_ctl_put()
5412 mixer, private->config_set->param_buf_addr + 1, 1, channel); in scarlett2_compressor_ctl_put()
5425 mutex_unlock(&private->data_mutex); in scarlett2_compressor_ctl_put()
5432 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_compressor_ctl_info()
5433 int control = elem->control % SCARLETT2_COMPRESSOR_PARAM_COUNT; in scarlett2_compressor_ctl_info()
5435 uinfo->type = compressor_params[control].type; in scarlett2_compressor_ctl_info()
5436 uinfo->count = 1; in scarlett2_compressor_ctl_info()
5437 uinfo->value.integer.min = compressor_params[control].min; in scarlett2_compressor_ctl_info()
5438 uinfo->value.integer.max = compressor_params[control].max; in scarlett2_compressor_ctl_info()
5439 uinfo->value.integer.step = 1; in scarlett2_compressor_ctl_info()
5451 /*** DSP Pre-Compressor and PEQ Filter Controls ***/
5456 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_precomp_flt_switch_ctl_get()
5457 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_precomp_flt_switch_ctl_get()
5459 ucontrol->value.integer.value[0] = private->precomp_flt_switch[elem->control]; in scarlett2_precomp_flt_switch_ctl_get()
5467 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_peq_flt_switch_ctl_get()
5468 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_peq_flt_switch_ctl_get()
5470 ucontrol->value.integer.value[0] = in scarlett2_peq_flt_switch_ctl_get()
5471 private->peq_flt_switch[elem->control]; in scarlett2_peq_flt_switch_ctl_get()
5479 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_precomp_flt_switch_ctl_put()
5480 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_precomp_flt_switch_ctl_put()
5481 struct scarlett2_data *private = mixer->private_data; in scarlett2_precomp_flt_switch_ctl_put()
5484 mutex_lock(&private->data_mutex); in scarlett2_precomp_flt_switch_ctl_put()
5486 if (private->hwdep_in_use) { in scarlett2_precomp_flt_switch_ctl_put()
5487 err = -EBUSY; in scarlett2_precomp_flt_switch_ctl_put()
5491 oval = private->precomp_flt_switch[elem->control]; in scarlett2_precomp_flt_switch_ctl_put()
5492 val = ucontrol->value.integer.value[0]; in scarlett2_precomp_flt_switch_ctl_put()
5497 private->precomp_flt_switch[elem->control] = val; in scarlett2_precomp_flt_switch_ctl_put()
5502 elem->control, val); in scarlett2_precomp_flt_switch_ctl_put()
5507 mutex_unlock(&private->data_mutex); in scarlett2_precomp_flt_switch_ctl_put()
5514 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_peq_flt_switch_ctl_put()
5515 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_peq_flt_switch_ctl_put()
5516 struct scarlett2_data *private = mixer->private_data; in scarlett2_peq_flt_switch_ctl_put()
5519 mutex_lock(&private->data_mutex); in scarlett2_peq_flt_switch_ctl_put()
5521 if (private->hwdep_in_use) { in scarlett2_peq_flt_switch_ctl_put()
5522 err = -EBUSY; in scarlett2_peq_flt_switch_ctl_put()
5526 oval = private->peq_flt_switch[elem->control]; in scarlett2_peq_flt_switch_ctl_put()
5527 val = ucontrol->value.integer.value[0]; in scarlett2_peq_flt_switch_ctl_put()
5532 private->peq_flt_switch[elem->control] = val; in scarlett2_peq_flt_switch_ctl_put()
5537 elem->control, val); in scarlett2_peq_flt_switch_ctl_put()
5542 mutex_unlock(&private->data_mutex); in scarlett2_peq_flt_switch_ctl_put()
5564 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_filter_values()
5565 const struct scarlett2_device_info *info = private->info; in scarlett2_update_filter_values()
5571 if (!info->dsp_input_count) in scarlett2_update_filter_values()
5577 info->dsp_input_count, private->precomp_flt_switch); in scarlett2_update_filter_values()
5583 info->dsp_input_count * info->peq_flt_count, in scarlett2_update_filter_values()
5584 private->peq_flt_switch); in scarlett2_update_filter_values()
5588 /* Get pre-compressor filter values directly */ in scarlett2_update_filter_values()
5591 info->dsp_input_count * in scarlett2_update_filter_values()
5592 info->precomp_flt_count * in scarlett2_update_filter_values()
5594 private->precomp_flt_values); in scarlett2_update_filter_values()
5604 info->dsp_input_count * in scarlett2_update_filter_values()
5605 info->peq_flt_total_count * in scarlett2_update_filter_values()
5611 for (i = 0, dst_idx = 0; i < info->dsp_input_count; i++) { in scarlett2_update_filter_values()
5613 info->peq_flt_total_count * in scarlett2_update_filter_values()
5615 for (j = 0; j < info->peq_flt_count; j++) in scarlett2_update_filter_values()
5619 private->peq_flt_values[dst_idx] = in scarlett2_update_filter_values()
5629 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_precomp_flt_ctl_get()
5630 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_precomp_flt_ctl_get()
5633 for (i = 0, idx = elem->control * SCARLETT2_BIQUAD_COEFFS; in scarlett2_precomp_flt_ctl_get()
5636 ucontrol->value.integer.value[i] = in scarlett2_precomp_flt_ctl_get()
5637 private->precomp_flt_values[idx]; in scarlett2_precomp_flt_ctl_get()
5645 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_peq_flt_ctl_get()
5646 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_peq_flt_ctl_get()
5649 for (i = 0, idx = elem->control * SCARLETT2_BIQUAD_COEFFS; in scarlett2_peq_flt_ctl_get()
5652 ucontrol->value.integer.value[i] = in scarlett2_peq_flt_ctl_get()
5653 private->peq_flt_values[idx]; in scarlett2_peq_flt_ctl_get()
5661 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_precomp_flt_ctl_put()
5662 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_precomp_flt_ctl_put()
5663 struct scarlett2_data *private = mixer->private_data; in scarlett2_precomp_flt_ctl_put()
5665 int index = elem->control * SCARLETT2_BIQUAD_COEFFS; in scarlett2_precomp_flt_ctl_put()
5668 mutex_lock(&private->data_mutex); in scarlett2_precomp_flt_ctl_put()
5670 if (private->hwdep_in_use) { in scarlett2_precomp_flt_ctl_put()
5671 err = -EBUSY; in scarlett2_precomp_flt_ctl_put()
5681 oval = private->precomp_flt_values[index + i]; in scarlett2_precomp_flt_ctl_put()
5682 val = ucontrol->value.integer.value[i]; in scarlett2_precomp_flt_ctl_put()
5692 private->precomp_flt_values[index + i] = in scarlett2_precomp_flt_ctl_put()
5693 ucontrol->value.integer.value[i]; in scarlett2_precomp_flt_ctl_put()
5697 mixer, private->config_set->param_buf_addr, 1, index); in scarlett2_precomp_flt_ctl_put()
5704 &private->precomp_flt_values[index]); in scarlett2_precomp_flt_ctl_put()
5710 mutex_unlock(&private->data_mutex); in scarlett2_precomp_flt_ctl_put()
5717 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_peq_flt_ctl_put()
5718 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_peq_flt_ctl_put()
5719 struct scarlett2_data *private = mixer->private_data; in scarlett2_peq_flt_ctl_put()
5720 const struct scarlett2_device_info *info = private->info; in scarlett2_peq_flt_ctl_put()
5722 int src_index = elem->control * SCARLETT2_BIQUAD_COEFFS; in scarlett2_peq_flt_ctl_put()
5724 elem->control / in scarlett2_peq_flt_ctl_put()
5725 info->peq_flt_count * in scarlett2_peq_flt_ctl_put()
5726 info->peq_flt_total_count + in scarlett2_peq_flt_ctl_put()
5727 elem->control % info->peq_flt_count in scarlett2_peq_flt_ctl_put()
5731 mutex_lock(&private->data_mutex); in scarlett2_peq_flt_ctl_put()
5733 if (private->hwdep_in_use) { in scarlett2_peq_flt_ctl_put()
5734 err = -EBUSY; in scarlett2_peq_flt_ctl_put()
5744 oval = private->peq_flt_values[src_index + i]; in scarlett2_peq_flt_ctl_put()
5745 val = ucontrol->value.integer.value[i]; in scarlett2_peq_flt_ctl_put()
5755 private->peq_flt_values[src_index + i] = in scarlett2_peq_flt_ctl_put()
5756 ucontrol->value.integer.value[i]; in scarlett2_peq_flt_ctl_put()
5760 mixer, private->config_set->param_buf_addr, 1, dst_index); in scarlett2_peq_flt_ctl_put()
5767 &private->peq_flt_values[src_index]); in scarlett2_peq_flt_ctl_put()
5773 mutex_unlock(&private->data_mutex); in scarlett2_peq_flt_ctl_put()
5780 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_flt_ctl_info()
5781 uinfo->count = SCARLETT2_BIQUAD_COEFFS; in scarlett2_flt_ctl_info()
5782 uinfo->value.integer.min = INT_MIN; in scarlett2_flt_ctl_info()
5783 uinfo->value.integer.max = INT_MAX; in scarlett2_flt_ctl_info()
5784 uinfo->value.integer.step = 1; in scarlett2_flt_ctl_info()
5808 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_mute()
5809 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_mute()
5811 private->input_mute_updated = 0; in scarlett2_update_input_mute()
5813 if (!info->mute_input_count) in scarlett2_update_input_mute()
5818 info->mute_input_count, private->input_mute_switch); in scarlett2_update_input_mute()
5824 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_mute_ctl_get()
5825 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_mute_ctl_get()
5826 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_mute_ctl_get()
5829 mutex_lock(&private->data_mutex); in scarlett2_input_mute_ctl_get()
5831 if (private->hwdep_in_use) { in scarlett2_input_mute_ctl_get()
5832 err = -EBUSY; in scarlett2_input_mute_ctl_get()
5836 if (private->input_mute_updated) { in scarlett2_input_mute_ctl_get()
5841 ucontrol->value.integer.value[0] = in scarlett2_input_mute_ctl_get()
5842 private->input_mute_switch[elem->control]; in scarlett2_input_mute_ctl_get()
5845 mutex_unlock(&private->data_mutex); in scarlett2_input_mute_ctl_get()
5852 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_input_mute_ctl_put()
5853 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_input_mute_ctl_put()
5854 struct scarlett2_data *private = mixer->private_data; in scarlett2_input_mute_ctl_put()
5856 int index = elem->control; in scarlett2_input_mute_ctl_put()
5859 mutex_lock(&private->data_mutex); in scarlett2_input_mute_ctl_put()
5861 if (private->hwdep_in_use) { in scarlett2_input_mute_ctl_put()
5862 err = -EBUSY; in scarlett2_input_mute_ctl_put()
5870 oval = private->input_mute_switch[index]; in scarlett2_input_mute_ctl_put()
5871 val = ucontrol->value.integer.value[0]; in scarlett2_input_mute_ctl_put()
5876 private->input_mute_switch[index] = val; in scarlett2_input_mute_ctl_put()
5886 mutex_unlock(&private->data_mutex); in scarlett2_input_mute_ctl_put()
5902 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_phantom()
5903 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_phantom()
5906 private->input_phantom_updated = 0; in scarlett2_update_input_phantom()
5908 if (!info->phantom_count) in scarlett2_update_input_phantom()
5913 info->phantom_count, private->phantom_switch); in scarlett2_update_input_phantom()
5921 1, &private->phantom_persistence); in scarlett2_update_input_phantom()
5933 const struct scarlett2_device_info *info = private->info; in scarlett2_phantom_is_switching()
5934 int index = line_num / info->inputs_per_phantom; in scarlett2_phantom_is_switching()
5936 return !!(private->phantom_switch[index] & 0x02); in scarlett2_phantom_is_switching()
5942 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_update_access()
5943 const struct scarlett2_device_info *info = private->info; in scarlett2_phantom_update_access()
5947 for (i = 0; i < info->gain_input_count; i++) { in scarlett2_phantom_update_access()
5950 scarlett2_set_ctl_access(private->autogain_ctls[i], val); in scarlett2_phantom_update_access()
5959 struct snd_card *card = mixer->chip->card; in scarlett2_phantom_notify_access()
5960 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_notify_access()
5961 const struct scarlett2_device_info *info = private->info; in scarlett2_phantom_notify_access()
5964 for (i = 0; i < info->gain_input_count; i++) in scarlett2_phantom_notify_access()
5966 &private->autogain_ctls[i]->id); in scarlett2_phantom_notify_access()
5975 struct scarlett2_data *private = mixer->private_data; in scarlett2_check_input_phantom_updated()
5978 if (!private->input_phantom_updated) in scarlett2_check_input_phantom_updated()
5993 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_ctl_get()
5994 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_phantom_ctl_get()
5995 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_ctl_get()
5998 mutex_lock(&private->data_mutex); in scarlett2_phantom_ctl_get()
6000 if (private->hwdep_in_use) { in scarlett2_phantom_ctl_get()
6001 err = -EBUSY; in scarlett2_phantom_ctl_get()
6009 ucontrol->value.integer.value[0] = scarlett2_decode_muteable( in scarlett2_phantom_ctl_get()
6010 private->phantom_switch[elem->control]); in scarlett2_phantom_ctl_get()
6013 mutex_unlock(&private->data_mutex); in scarlett2_phantom_ctl_get()
6020 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_ctl_put()
6021 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_phantom_ctl_put()
6022 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_ctl_put()
6023 const struct scarlett2_device_info *info = private->info; in scarlett2_phantom_ctl_put()
6025 int index = elem->control; in scarlett2_phantom_ctl_put()
6028 mutex_lock(&private->data_mutex); in scarlett2_phantom_ctl_put()
6030 if (private->hwdep_in_use) { in scarlett2_phantom_ctl_put()
6031 err = -EBUSY; in scarlett2_phantom_ctl_put()
6039 oval = private->phantom_switch[index]; in scarlett2_phantom_ctl_put()
6040 val = !!ucontrol->value.integer.value[0]; in scarlett2_phantom_ctl_put()
6045 private->phantom_switch[index] = val; in scarlett2_phantom_ctl_put()
6048 if (private->config_set->items[SCARLETT2_CONFIG_PHANTOM_SWITCH].mute) in scarlett2_phantom_ctl_put()
6053 index + info->phantom_first, val); in scarlett2_phantom_ctl_put()
6061 mutex_unlock(&private->data_mutex); in scarlett2_phantom_ctl_put()
6078 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_persistence_ctl_get()
6079 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_phantom_persistence_ctl_get()
6081 ucontrol->value.integer.value[0] = private->phantom_persistence; in scarlett2_phantom_persistence_ctl_get()
6088 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_persistence_ctl_put()
6089 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_phantom_persistence_ctl_put()
6090 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_persistence_ctl_put()
6092 int index = elem->control; in scarlett2_phantom_persistence_ctl_put()
6095 mutex_lock(&private->data_mutex); in scarlett2_phantom_persistence_ctl_put()
6097 if (private->hwdep_in_use) { in scarlett2_phantom_persistence_ctl_put()
6098 err = -EBUSY; in scarlett2_phantom_persistence_ctl_put()
6102 oval = private->phantom_persistence; in scarlett2_phantom_persistence_ctl_put()
6103 val = !!ucontrol->value.integer.value[0]; in scarlett2_phantom_persistence_ctl_put()
6108 private->phantom_persistence = val; in scarlett2_phantom_persistence_ctl_put()
6117 mutex_unlock(&private->data_mutex); in scarlett2_phantom_persistence_ctl_put()
6133 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_monitor_other()
6134 const struct scarlett2_device_info *info = private->info; in scarlett2_update_monitor_other()
6147 private->monitor_other_updated = 0; in scarlett2_update_monitor_other()
6152 if (!info->has_speaker_switching) in scarlett2_update_monitor_other()
6168 private->speaker_switching_switch = 0; in scarlett2_update_monitor_other()
6170 private->speaker_switching_switch = monitor_other_switch[0] + 1; in scarlett2_update_monitor_other()
6172 if (info->has_talkback) { in scarlett2_update_monitor_other()
6177 private->talkback_switch = 0; in scarlett2_update_monitor_other()
6179 private->talkback_switch = monitor_other_switch[1] + 1; in scarlett2_update_monitor_other()
6186 for (i = 0; i < private->num_mix_out; i++, bitmap >>= 1) in scarlett2_update_monitor_other()
6187 private->talkback_map[i] = bitmap & 1; in scarlett2_update_monitor_other()
6206 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_speaker_switch_enum_ctl_get()
6207 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_speaker_switch_enum_ctl_get()
6208 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_enum_ctl_get()
6211 mutex_lock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_get()
6213 if (private->hwdep_in_use) { in scarlett2_speaker_switch_enum_ctl_get()
6214 err = -EBUSY; in scarlett2_speaker_switch_enum_ctl_get()
6218 if (private->monitor_other_updated) { in scarlett2_speaker_switch_enum_ctl_get()
6223 ucontrol->value.enumerated.item[0] = private->speaker_switching_switch; in scarlett2_speaker_switch_enum_ctl_get()
6226 mutex_unlock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_get()
6235 struct snd_card *card = mixer->chip->card; in scarlett2_speaker_switch_enable()
6236 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_enable()
6243 if (!private->vol_sw_hw_switch[index]) { in scarlett2_speaker_switch_enable()
6244 err = scarlett2_sw_hw_change(private->mixer, i, 1); in scarlett2_speaker_switch_enable()
6254 &private->sw_hw_ctls[i]->id); in scarlett2_speaker_switch_enable()
6257 /* when the next monitor-other notify comes in, update the mux in scarlett2_speaker_switch_enable()
6260 private->speaker_switching_switched = 1; in scarlett2_speaker_switch_enable()
6270 struct snd_card *card = mixer->chip->card; in scarlett2_speaker_switch_disable()
6271 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_disable()
6278 &private->sw_hw_ctls[i]->id); in scarlett2_speaker_switch_disable()
6281 /* when the next monitor-other notify comes in, update the mux in scarlett2_speaker_switch_disable()
6284 private->speaker_switching_switched = 1; in scarlett2_speaker_switch_disable()
6290 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_speaker_switch_enum_ctl_put()
6291 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_speaker_switch_enum_ctl_put()
6292 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_enum_ctl_put()
6296 mutex_lock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_put()
6298 if (private->hwdep_in_use) { in scarlett2_speaker_switch_enum_ctl_put()
6299 err = -EBUSY; in scarlett2_speaker_switch_enum_ctl_put()
6303 oval = private->speaker_switching_switch; in scarlett2_speaker_switch_enum_ctl_put()
6304 val = min(ucontrol->value.enumerated.item[0], 2U); in scarlett2_speaker_switch_enum_ctl_put()
6309 private->speaker_switching_switch = val; in scarlett2_speaker_switch_enum_ctl_put()
6335 mutex_unlock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_put()
6349 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_speaker_switch_ctl()
6350 const struct scarlett2_device_info *info = private->info; in scarlett2_add_speaker_switch_ctl()
6352 if (!info->has_speaker_switching) in scarlett2_add_speaker_switch_ctl()
6358 &private->speaker_switching_ctl); in scarlett2_add_speaker_switch_ctl()
6376 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_enum_ctl_get()
6377 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_enum_ctl_get()
6378 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_enum_ctl_get()
6381 mutex_lock(&private->data_mutex); in scarlett2_talkback_enum_ctl_get()
6383 if (private->hwdep_in_use) { in scarlett2_talkback_enum_ctl_get()
6384 err = -EBUSY; in scarlett2_talkback_enum_ctl_get()
6388 if (private->monitor_other_updated) { in scarlett2_talkback_enum_ctl_get()
6393 ucontrol->value.enumerated.item[0] = private->talkback_switch; in scarlett2_talkback_enum_ctl_get()
6396 mutex_unlock(&private->data_mutex); in scarlett2_talkback_enum_ctl_get()
6403 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_enum_ctl_put()
6404 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_enum_ctl_put()
6405 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_enum_ctl_put()
6409 mutex_lock(&private->data_mutex); in scarlett2_talkback_enum_ctl_put()
6411 if (private->hwdep_in_use) { in scarlett2_talkback_enum_ctl_put()
6412 err = -EBUSY; in scarlett2_talkback_enum_ctl_put()
6416 oval = private->talkback_switch; in scarlett2_talkback_enum_ctl_put()
6417 val = min(ucontrol->value.enumerated.item[0], 2U); in scarlett2_talkback_enum_ctl_put()
6422 private->talkback_switch = val; in scarlett2_talkback_enum_ctl_put()
6439 mutex_unlock(&private->data_mutex); in scarlett2_talkback_enum_ctl_put()
6454 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_map_ctl_get()
6455 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_map_ctl_get()
6456 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_map_ctl_get()
6457 int index = elem->control; in scarlett2_talkback_map_ctl_get()
6459 ucontrol->value.integer.value[0] = private->talkback_map[index]; in scarlett2_talkback_map_ctl_get()
6467 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_map_ctl_put()
6468 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_map_ctl_put()
6469 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_map_ctl_put()
6470 int index = elem->control; in scarlett2_talkback_map_ctl_put()
6474 mutex_lock(&private->data_mutex); in scarlett2_talkback_map_ctl_put()
6476 if (private->hwdep_in_use) { in scarlett2_talkback_map_ctl_put()
6477 err = -EBUSY; in scarlett2_talkback_map_ctl_put()
6481 oval = private->talkback_map[index]; in scarlett2_talkback_map_ctl_put()
6482 val = !!ucontrol->value.integer.value[0]; in scarlett2_talkback_map_ctl_put()
6487 private->talkback_map[index] = val; in scarlett2_talkback_map_ctl_put()
6489 for (i = 0; i < private->num_mix_out; i++) in scarlett2_talkback_map_ctl_put()
6490 bitmap |= private->talkback_map[i] << i; in scarlett2_talkback_map_ctl_put()
6499 mutex_unlock(&private->data_mutex); in scarlett2_talkback_map_ctl_put()
6513 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_talkback_ctls()
6514 const struct scarlett2_device_info *info = private->info; in scarlett2_add_talkback_ctls()
6518 if (!info->has_talkback) in scarlett2_add_talkback_ctls()
6524 &private->talkback_ctl); in scarlett2_add_talkback_ctls()
6528 for (i = 0; i < private->num_mix_out; i++) { in scarlett2_add_talkback_ctls()
6545 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dim_mute_ctl_get()
6546 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dim_mute_ctl_get()
6547 struct scarlett2_data *private = mixer->private_data; in scarlett2_dim_mute_ctl_get()
6550 mutex_lock(&private->data_mutex); in scarlett2_dim_mute_ctl_get()
6552 if (private->hwdep_in_use) { in scarlett2_dim_mute_ctl_get()
6553 err = -EBUSY; in scarlett2_dim_mute_ctl_get()
6557 if (private->dim_mute_updated) { in scarlett2_dim_mute_ctl_get()
6562 ucontrol->value.integer.value[0] = private->dim_mute[elem->control]; in scarlett2_dim_mute_ctl_get()
6565 mutex_unlock(&private->data_mutex); in scarlett2_dim_mute_ctl_get()
6572 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dim_mute_ctl_put()
6573 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dim_mute_ctl_put()
6574 struct scarlett2_data *private = mixer->private_data; in scarlett2_dim_mute_ctl_put()
6575 int index = elem->control; in scarlett2_dim_mute_ctl_put()
6578 mutex_lock(&private->data_mutex); in scarlett2_dim_mute_ctl_put()
6580 if (private->hwdep_in_use) { in scarlett2_dim_mute_ctl_put()
6581 err = -EBUSY; in scarlett2_dim_mute_ctl_put()
6585 oval = private->dim_mute[index]; in scarlett2_dim_mute_ctl_put()
6586 val = !!ucontrol->value.integer.value[0]; in scarlett2_dim_mute_ctl_put()
6591 private->dim_mute[index] = val; in scarlett2_dim_mute_ctl_put()
6600 for (i = 0; i < private->num_line_out; i++) { in scarlett2_dim_mute_ctl_put()
6603 if (private->vol_sw_hw_switch[line_index]) { in scarlett2_dim_mute_ctl_put()
6604 private->mute_switch[line_index] = val; in scarlett2_dim_mute_ctl_put()
6605 snd_ctl_notify(mixer->chip->card, in scarlett2_dim_mute_ctl_put()
6607 &private->mute_ctls[i]->id); in scarlett2_dim_mute_ctl_put()
6612 mutex_unlock(&private->data_mutex); in scarlett2_dim_mute_ctl_put()
6628 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_line_out_ctls()
6629 const struct scarlett2_device_info *info = private->info; in scarlett2_add_line_out_ctls()
6639 0, 1, s, &private->master_vol_ctl); in scarlett2_add_line_out_ctls()
6651 &private->headphone_vol_ctl); in scarlett2_add_line_out_ctls()
6657 * has per-channel line-out volume controls. in scarlett2_add_line_out_ctls()
6664 for (i = 0; i < private->num_line_out; i++) { in scarlett2_add_line_out_ctls()
6668 if (info->line_out_descrs[i]) in scarlett2_add_line_out_ctls()
6671 i + 1, info->line_out_descrs[i]); in scarlett2_add_line_out_ctls()
6678 i, 1, s, &private->vol_ctls[i]); in scarlett2_add_line_out_ctls()
6689 &private->mute_ctls[i]); in scarlett2_add_line_out_ctls()
6697 /* Make the fader and mute controls read-only if the in scarlett2_add_line_out_ctls()
6700 if (private->vol_sw_hw_switch[index]) in scarlett2_add_line_out_ctls()
6709 &private->sw_hw_ctls[i]); in scarlett2_add_line_out_ctls()
6713 /* Make the switch read-only if the line is in scarlett2_add_line_out_ctls()
6716 if (private->speaker_switching_switch && i < 4) in scarlett2_add_line_out_ctls()
6727 &private->dim_mute_ctls[i]); in scarlett2_add_line_out_ctls()
6739 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_dsp_ctls()
6740 const struct scarlett2_device_info *info = private->info; in scarlett2_add_dsp_ctls()
6752 scnprintf(s, sizeof(s), compr_fmt, i + 1, param->name); in scarlett2_add_dsp_ctls()
6756 1, s, &private->compressor_ctls[idx]); in scarlett2_add_dsp_ctls()
6762 scnprintf(s, sizeof(s), flt_switch_fmt, i + 1, "Pre-Comp"); in scarlett2_add_dsp_ctls()
6765 i, 1, s, &private->precomp_flt_switch_ctls[i]); in scarlett2_add_dsp_ctls()
6772 i, 1, s, &private->peq_flt_switch_ctls[i]); in scarlett2_add_dsp_ctls()
6777 for (j = 0; j < info->precomp_flt_count; j++) { in scarlett2_add_dsp_ctls()
6778 scnprintf(s, sizeof(s), flt_fmt, i + 1, "Pre-Comp", j + 1); in scarlett2_add_dsp_ctls()
6781 i * info->precomp_flt_count + j, in scarlett2_add_dsp_ctls()
6782 1, s, &private->precomp_flt_switch_ctls[j]); in scarlett2_add_dsp_ctls()
6787 for (j = 0; j < info->peq_flt_count; j++) { in scarlett2_add_dsp_ctls()
6791 i * info->peq_flt_count + j, in scarlett2_add_dsp_ctls()
6792 1, s, &private->peq_flt_switch_ctls[j]); in scarlett2_add_dsp_ctls()
6802 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_line_in_ctls()
6803 const struct scarlett2_device_info *info = private->info; in scarlett2_add_line_in_ctls()
6807 const char *fmt2 = "Line In %d-%d %s Capture %s"; in scarlett2_add_line_in_ctls()
6810 for (i = 0; i < info->level_input_count; i++) { in scarlett2_add_line_in_ctls()
6811 scnprintf(s, sizeof(s), fmt, i + 1 + info->level_input_first, in scarlett2_add_line_in_ctls()
6814 i, 1, s, &private->level_ctls[i]); in scarlett2_add_line_in_ctls()
6820 for (i = 0; i < info->pad_input_count; i++) { in scarlett2_add_line_in_ctls()
6823 i, 1, s, &private->pad_ctls[i]); in scarlett2_add_line_in_ctls()
6829 for (i = 0; i < info->air_input_count; i++) { in scarlett2_add_line_in_ctls()
6830 scnprintf(s, sizeof(s), fmt, i + 1 + info->air_input_first, in scarlett2_add_line_in_ctls()
6831 "Air", info->air_option ? "Enum" : "Switch"); in scarlett2_add_line_in_ctls()
6833 mixer, &scarlett2_air_ctl[info->air_option], in scarlett2_add_line_in_ctls()
6834 i, 1, s, &private->air_ctls[i]); in scarlett2_add_line_in_ctls()
6840 for (i = 0; i < info->dsp_input_count; i++) { in scarlett2_add_line_in_ctls()
6843 i, 1, s, &private->dsp_ctls[i]); in scarlett2_add_line_in_ctls()
6853 for (i = 0; i < info->mute_input_count; i++) { in scarlett2_add_line_in_ctls()
6857 i, 1, s, &private->input_mute_ctls[i]); in scarlett2_add_line_in_ctls()
6863 if (info->inputs_per_phantom == 1) { in scarlett2_add_line_in_ctls()
6864 for (i = 0; i < info->phantom_count; i++) { in scarlett2_add_line_in_ctls()
6866 i + 1 + info->phantom_first, in scarlett2_add_line_in_ctls()
6870 i, 1, s, &private->phantom_ctls[i]); in scarlett2_add_line_in_ctls()
6874 } else if (info->inputs_per_phantom > 1) { in scarlett2_add_line_in_ctls()
6875 for (i = 0; i < info->phantom_count; i++) { in scarlett2_add_line_in_ctls()
6876 int from = i * info->inputs_per_phantom + 1; in scarlett2_add_line_in_ctls()
6877 int to = (i + 1) * info->inputs_per_phantom; in scarlett2_add_line_in_ctls()
6883 i, 1, s, &private->phantom_ctls[i]); in scarlett2_add_line_in_ctls()
6888 if (info->phantom_count && in scarlett2_add_line_in_ctls()
6904 &private->input_select_ctl); in scarlett2_add_line_in_ctls()
6911 for (i = 0; i < info->gain_input_count; i++) { in scarlett2_add_line_in_ctls()
6916 i, 1, s, &private->input_link_ctls[i]); in scarlett2_add_line_in_ctls()
6922 /* Add software-controllable input gain controls */ in scarlett2_add_line_in_ctls()
6923 for (i = 0; i < info->gain_input_count; i++) { in scarlett2_add_line_in_ctls()
6928 i, 1, s, &private->input_gain_ctls[i]); in scarlett2_add_line_in_ctls()
6931 private->input_gain_ctls[i]->tlv.p = in scarlett2_add_line_in_ctls()
6932 private->config_set->input_gain_tlv; in scarlett2_add_line_in_ctls()
6938 i, 1, s, &private->autogain_ctls[i]); in scarlett2_add_line_in_ctls()
6946 i, 1, s, &private->autogain_status_ctls[i]); in scarlett2_add_line_in_ctls()
6958 i, 1, s, &private->ag_target_ctls[i]); in scarlett2_add_line_in_ctls()
6963 /* Add safe-mode input switch controls */ in scarlett2_add_line_in_ctls()
6964 for (i = 0; i < info->safe_input_count; i++) { in scarlett2_add_line_in_ctls()
6969 i, 1, s, &private->safe_ctls[i]); in scarlett2_add_line_in_ctls()
6980 &private->pcm_input_switch_ctl); in scarlett2_add_line_in_ctls()
6992 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_mix()
6995 private->mix_updated = 0; in scarlett2_update_mix()
6997 for (i = 0; i < private->num_mix_out; i++) { in scarlett2_update_mix()
7009 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mixer_ctl_info()
7011 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_mixer_ctl_info()
7012 uinfo->count = elem->channels; in scarlett2_mixer_ctl_info()
7013 uinfo->value.integer.min = 0; in scarlett2_mixer_ctl_info()
7014 uinfo->value.integer.max = SCARLETT2_MIXER_MAX_VALUE; in scarlett2_mixer_ctl_info()
7015 uinfo->value.integer.step = 1; in scarlett2_mixer_ctl_info()
7022 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mixer_ctl_get()
7023 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mixer_ctl_get()
7024 struct scarlett2_data *private = mixer->private_data; in scarlett2_mixer_ctl_get()
7027 mutex_lock(&private->data_mutex); in scarlett2_mixer_ctl_get()
7029 if (private->hwdep_in_use) { in scarlett2_mixer_ctl_get()
7030 err = -EBUSY; in scarlett2_mixer_ctl_get()
7034 if (private->mix_updated) { in scarlett2_mixer_ctl_get()
7039 ucontrol->value.integer.value[0] = private->mix[elem->control]; in scarlett2_mixer_ctl_get()
7042 mutex_unlock(&private->data_mutex); in scarlett2_mixer_ctl_get()
7049 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mixer_ctl_put()
7050 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mixer_ctl_put()
7051 struct scarlett2_data *private = mixer->private_data; in scarlett2_mixer_ctl_put()
7053 int index = elem->control; in scarlett2_mixer_ctl_put()
7055 mutex_lock(&private->data_mutex); in scarlett2_mixer_ctl_put()
7057 if (private->hwdep_in_use) { in scarlett2_mixer_ctl_put()
7058 err = -EBUSY; in scarlett2_mixer_ctl_put()
7062 oval = private->mix[index]; in scarlett2_mixer_ctl_put()
7063 val = clamp(ucontrol->value.integer.value[0], in scarlett2_mixer_ctl_put()
7065 mix_num = index / private->num_mix_in; in scarlett2_mixer_ctl_put()
7070 private->mix[index] = val; in scarlett2_mixer_ctl_put()
7076 mutex_unlock(&private->data_mutex); in scarlett2_mixer_ctl_put()
7095 .tlv = { .p = db_scale_scarlett2_mixer }
7100 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_mixer_ctls()
7105 for (i = 0, index = 0; i < private->num_mix_out; i++) in scarlett2_add_mixer_ctls()
7106 for (j = 0; j < private->num_mix_in; j++, index++) { in scarlett2_add_mixer_ctls()
7112 &private->mix_ctls[index]); in scarlett2_add_mixer_ctls()
7124 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_direct_monitor()
7126 private->direct_monitor_updated = 0; in scarlett2_update_direct_monitor()
7128 if (!private->info->direct_monitor) in scarlett2_update_direct_monitor()
7133 1, &private->direct_monitor_switch); in scarlett2_update_direct_monitor()
7138 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_monitor_mix()
7142 if (!private->num_monitor_mix_ctls) in scarlett2_update_monitor_mix()
7147 private->num_monitor_mix_ctls, mix_values); in scarlett2_update_monitor_mix()
7151 for (i = 0; i < private->num_monitor_mix_ctls; i++) in scarlett2_update_monitor_mix()
7152 private->monitor_mix[i] = scarlett2_mixer_value_to_db( in scarlett2_update_monitor_mix()
7161 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_direct_monitor_ctl_get()
7162 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_direct_monitor_ctl_get()
7163 struct scarlett2_data *private = mixer->private_data; in scarlett2_direct_monitor_ctl_get()
7166 mutex_lock(&private->data_mutex); in scarlett2_direct_monitor_ctl_get()
7168 if (private->hwdep_in_use) { in scarlett2_direct_monitor_ctl_get()
7169 err = -EBUSY; in scarlett2_direct_monitor_ctl_get()
7173 if (private->direct_monitor_updated) { in scarlett2_direct_monitor_ctl_get()
7178 ucontrol->value.enumerated.item[0] = private->direct_monitor_switch; in scarlett2_direct_monitor_ctl_get()
7181 mutex_unlock(&private->data_mutex); in scarlett2_direct_monitor_ctl_get()
7188 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_direct_monitor_ctl_put()
7189 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_direct_monitor_ctl_put()
7190 struct scarlett2_data *private = mixer->private_data; in scarlett2_direct_monitor_ctl_put()
7192 int index = elem->control; in scarlett2_direct_monitor_ctl_put()
7195 mutex_lock(&private->data_mutex); in scarlett2_direct_monitor_ctl_put()
7197 if (private->hwdep_in_use) { in scarlett2_direct_monitor_ctl_put()
7198 err = -EBUSY; in scarlett2_direct_monitor_ctl_put()
7202 oval = private->direct_monitor_switch; in scarlett2_direct_monitor_ctl_put()
7203 val = min(ucontrol->value.enumerated.item[0], 2U); in scarlett2_direct_monitor_ctl_put()
7208 private->direct_monitor_switch = val; in scarlett2_direct_monitor_ctl_put()
7217 mutex_unlock(&private->data_mutex); in scarlett2_direct_monitor_ctl_put()
7231 /* Direct Monitor for Solo is mono-only and only needs a boolean control
7254 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_monitor_mix_ctl_get()
7255 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_monitor_mix_ctl_get()
7257 ucontrol->value.integer.value[0] = private->monitor_mix[elem->control]; in scarlett2_monitor_mix_ctl_get()
7265 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_monitor_mix_ctl_put()
7266 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_monitor_mix_ctl_put()
7267 struct scarlett2_data *private = mixer->private_data; in scarlett2_monitor_mix_ctl_put()
7269 int index = elem->control; in scarlett2_monitor_mix_ctl_put()
7271 mutex_lock(&private->data_mutex); in scarlett2_monitor_mix_ctl_put()
7273 if (private->hwdep_in_use) { in scarlett2_monitor_mix_ctl_put()
7274 err = -EBUSY; in scarlett2_monitor_mix_ctl_put()
7278 oval = private->monitor_mix[index]; in scarlett2_monitor_mix_ctl_put()
7279 val = clamp(ucontrol->value.integer.value[0], in scarlett2_monitor_mix_ctl_put()
7285 private->monitor_mix[index] = val; in scarlett2_monitor_mix_ctl_put()
7293 mutex_unlock(&private->data_mutex); in scarlett2_monitor_mix_ctl_put()
7306 .tlv = { .p = db_scale_scarlett2_mixer }
7311 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_direct_monitor_ctls()
7312 const struct scarlett2_device_info *info = private->info; in scarlett2_add_direct_monitor_ctls()
7316 if (!info->direct_monitor) in scarlett2_add_direct_monitor_ctls()
7319 s = info->direct_monitor == 1 in scarlett2_add_direct_monitor_ctls()
7324 mixer, &scarlett2_direct_monitor_ctl[info->direct_monitor - 1], in scarlett2_add_direct_monitor_ctls()
7325 0, 1, s, &private->direct_monitor_ctl); in scarlett2_add_direct_monitor_ctls()
7329 if (!private->num_monitor_mix_ctls) in scarlett2_add_direct_monitor_ctls()
7333 for (i = 0, index = 0; i < info->direct_monitor; i++) { in scarlett2_add_direct_monitor_ctls()
7338 if (info->direct_monitor == 1) in scarlett2_add_direct_monitor_ctls()
7349 for (k = 0; k < private->num_mix_in; k++, index++) { in scarlett2_add_direct_monitor_ctls()
7371 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mux_src_enum_ctl_info()
7372 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_mux_src_enum_ctl_info()
7373 const struct scarlett2_device_info *info = private->info; in scarlett2_mux_src_enum_ctl_info()
7374 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_mux_src_enum_ctl_info()
7375 unsigned int item = uinfo->value.enumerated.item; in scarlett2_mux_src_enum_ctl_info()
7376 int items = private->num_mux_srcs; in scarlett2_mux_src_enum_ctl_info()
7379 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in scarlett2_mux_src_enum_ctl_info()
7380 uinfo->count = elem->channels; in scarlett2_mux_src_enum_ctl_info()
7381 uinfo->value.enumerated.items = items; in scarlett2_mux_src_enum_ctl_info()
7384 item = uinfo->value.enumerated.item = items - 1; in scarlett2_mux_src_enum_ctl_info()
7394 item >= private->num_mix_out) in scarlett2_mux_src_enum_ctl_info()
7395 sprintf(uinfo->value.enumerated.name, in scarlett2_mux_src_enum_ctl_info()
7396 port->dsp_src_descr, in scarlett2_mux_src_enum_ctl_info()
7397 item - private->num_mix_out + 1); in scarlett2_mux_src_enum_ctl_info()
7399 sprintf(uinfo->value.enumerated.name, in scarlett2_mux_src_enum_ctl_info()
7400 port->src_descr, in scarlett2_mux_src_enum_ctl_info()
7401 item + port->src_num_offset); in scarlett2_mux_src_enum_ctl_info()
7405 item -= port_count[port_type][SCARLETT2_PORT_IN]; in scarlett2_mux_src_enum_ctl_info()
7408 return -EINVAL; in scarlett2_mux_src_enum_ctl_info()
7414 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mux_src_enum_ctl_get()
7415 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mux_src_enum_ctl_get()
7416 struct scarlett2_data *private = mixer->private_data; in scarlett2_mux_src_enum_ctl_get()
7417 int index = line_out_remap(private, elem->control); in scarlett2_mux_src_enum_ctl_get()
7420 mutex_lock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_get()
7422 if (private->hwdep_in_use) { in scarlett2_mux_src_enum_ctl_get()
7423 err = -EBUSY; in scarlett2_mux_src_enum_ctl_get()
7427 if (private->mux_updated) { in scarlett2_mux_src_enum_ctl_get()
7432 ucontrol->value.enumerated.item[0] = private->mux[index]; in scarlett2_mux_src_enum_ctl_get()
7435 mutex_unlock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_get()
7442 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mux_src_enum_ctl_put()
7443 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mux_src_enum_ctl_put()
7444 struct scarlett2_data *private = mixer->private_data; in scarlett2_mux_src_enum_ctl_put()
7445 int index = line_out_remap(private, elem->control); in scarlett2_mux_src_enum_ctl_put()
7448 mutex_lock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_put()
7450 if (private->hwdep_in_use) { in scarlett2_mux_src_enum_ctl_put()
7451 err = -EBUSY; in scarlett2_mux_src_enum_ctl_put()
7455 oval = private->mux[index]; in scarlett2_mux_src_enum_ctl_put()
7456 val = min(ucontrol->value.enumerated.item[0], in scarlett2_mux_src_enum_ctl_put()
7457 private->num_mux_srcs - 1U); in scarlett2_mux_src_enum_ctl_put()
7462 private->mux[index] = val; in scarlett2_mux_src_enum_ctl_put()
7468 mutex_unlock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_put()
7482 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_mux_enums()
7483 const struct scarlett2_device_info *info = private->info; in scarlett2_add_mux_enums()
7484 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_add_mux_enums()
7498 const char *descr = port->dst_descr; in scarlett2_add_mux_enums()
7501 channel >= private->num_mix_in) { in scarlett2_add_mux_enums()
7502 channel_num -= private->num_mix_in; in scarlett2_add_mux_enums()
7503 descr = port->dsp_dst_descr; in scarlett2_add_mux_enums()
7506 snprintf(s, sizeof(s) - 5, descr, channel_num); in scarlett2_add_mux_enums()
7512 &private->mux_ctls[i]); in scarlett2_add_mux_enums()
7526 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_meter_ctl_info()
7528 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_meter_ctl_info()
7529 uinfo->count = elem->channels; in scarlett2_meter_ctl_info()
7530 uinfo->value.integer.min = 0; in scarlett2_meter_ctl_info()
7531 uinfo->value.integer.max = 4095; in scarlett2_meter_ctl_info()
7532 uinfo->value.integer.step = 1; in scarlett2_meter_ctl_info()
7539 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_meter_ctl_get()
7540 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_meter_ctl_get()
7541 struct scarlett2_data *private = mixer->private_data; in scarlett2_meter_ctl_get()
7542 u8 *meter_level_map = private->meter_level_map; in scarlett2_meter_ctl_get()
7546 mutex_lock(&private->data_mutex); in scarlett2_meter_ctl_get()
7548 if (private->hwdep_in_use) { in scarlett2_meter_ctl_get()
7549 err = -EBUSY; in scarlett2_meter_ctl_get()
7553 err = scarlett2_usb_get_meter_levels(mixer, elem->channels, in scarlett2_meter_ctl_get()
7559 for (i = 0; i < elem->channels; i++) { in scarlett2_meter_ctl_get()
7568 ucontrol->value.integer.value[i] = value; in scarlett2_meter_ctl_get()
7572 mutex_unlock(&private->data_mutex); in scarlett2_meter_ctl_get()
7587 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_meter_ctl()
7594 0, private->num_mux_dsts, in scarlett2_add_meter_ctl()
7603 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_msd_ctl_get()
7604 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_msd_ctl_get()
7606 ucontrol->value.integer.value[0] = private->msd_switch; in scarlett2_msd_ctl_get()
7613 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_msd_ctl_put()
7614 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_msd_ctl_put()
7615 struct scarlett2_data *private = mixer->private_data; in scarlett2_msd_ctl_put()
7619 mutex_lock(&private->data_mutex); in scarlett2_msd_ctl_put()
7621 if (private->hwdep_in_use) { in scarlett2_msd_ctl_put()
7622 err = -EBUSY; in scarlett2_msd_ctl_put()
7626 oval = private->msd_switch; in scarlett2_msd_ctl_put()
7627 val = !!ucontrol->value.integer.value[0]; in scarlett2_msd_ctl_put()
7632 private->msd_switch = val; in scarlett2_msd_ctl_put()
7641 mutex_unlock(&private->data_mutex); in scarlett2_msd_ctl_put()
7655 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_msd_ctl()
7661 if (!private->msd_switch && !(mixer->chip->setup & SCARLETT2_MSD_ENABLE)) in scarlett2_add_msd_ctl()
7674 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_standalone_ctl_get()
7675 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_standalone_ctl_get()
7677 ucontrol->value.integer.value[0] = private->standalone_switch; in scarlett2_standalone_ctl_get()
7684 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_standalone_ctl_put()
7685 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_standalone_ctl_put()
7686 struct scarlett2_data *private = mixer->private_data; in scarlett2_standalone_ctl_put()
7690 mutex_lock(&private->data_mutex); in scarlett2_standalone_ctl_put()
7692 if (private->hwdep_in_use) { in scarlett2_standalone_ctl_put()
7693 err = -EBUSY; in scarlett2_standalone_ctl_put()
7697 oval = private->standalone_switch; in scarlett2_standalone_ctl_put()
7698 val = !!ucontrol->value.integer.value[0]; in scarlett2_standalone_ctl_put()
7703 private->standalone_switch = val; in scarlett2_standalone_ctl_put()
7713 mutex_unlock(&private->data_mutex); in scarlett2_standalone_ctl_put()
7727 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_standalone_ctl()
7742 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_power_status()
7746 private->power_status_updated = 0; in scarlett2_update_power_status()
7759 private->power_status = SCARLETT2_POWER_STATUS_FAIL; in scarlett2_update_power_status()
7761 private->power_status = SCARLETT2_POWER_STATUS_EXT; in scarlett2_update_power_status()
7763 private->power_status = SCARLETT2_POWER_STATUS_BUS; in scarlett2_update_power_status()
7771 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_power_status_ctl_get()
7772 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_power_status_ctl_get()
7773 struct scarlett2_data *private = mixer->private_data; in scarlett2_power_status_ctl_get()
7776 mutex_lock(&private->data_mutex); in scarlett2_power_status_ctl_get()
7778 if (private->power_status_updated) { in scarlett2_power_status_ctl_get()
7783 ucontrol->value.integer.value[0] = private->power_status; in scarlett2_power_status_ctl_get()
7786 mutex_unlock(&private->data_mutex); in scarlett2_power_status_ctl_get()
7810 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_power_status_ctl()
7819 &private->power_status_ctl); in scarlett2_add_power_status_ctl()
7826 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_bluetooth_volume()
7829 private->bluetooth_updated = 0; in scarlett2_update_bluetooth_volume()
7831 if (!private->info->has_bluetooth) in scarlett2_update_bluetooth_volume()
7836 1, &private->bluetooth_volume); in scarlett2_update_bluetooth_volume()
7846 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_bluetooth_volume_ctl_get()
7847 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_bluetooth_volume_ctl_get()
7848 struct scarlett2_data *private = mixer->private_data; in scarlett2_bluetooth_volume_ctl_get()
7851 mutex_lock(&private->data_mutex); in scarlett2_bluetooth_volume_ctl_get()
7853 if (private->hwdep_in_use) { in scarlett2_bluetooth_volume_ctl_get()
7854 err = -EBUSY; in scarlett2_bluetooth_volume_ctl_get()
7858 if (private->bluetooth_updated) { in scarlett2_bluetooth_volume_ctl_get()
7863 ucontrol->value.integer.value[0] = private->bluetooth_volume; in scarlett2_bluetooth_volume_ctl_get()
7866 mutex_unlock(&private->data_mutex); in scarlett2_bluetooth_volume_ctl_get()
7873 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_bluetooth_volume_ctl_put()
7874 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_bluetooth_volume_ctl_put()
7875 struct scarlett2_data *private = mixer->private_data; in scarlett2_bluetooth_volume_ctl_put()
7878 mutex_lock(&private->data_mutex); in scarlett2_bluetooth_volume_ctl_put()
7880 if (private->hwdep_in_use) { in scarlett2_bluetooth_volume_ctl_put()
7881 err = -EBUSY; in scarlett2_bluetooth_volume_ctl_put()
7885 oval = private->bluetooth_volume; in scarlett2_bluetooth_volume_ctl_put()
7886 val = clamp(ucontrol->value.integer.value[0], in scarlett2_bluetooth_volume_ctl_put()
7892 private->bluetooth_volume = val; in scarlett2_bluetooth_volume_ctl_put()
7900 mutex_unlock(&private->data_mutex); in scarlett2_bluetooth_volume_ctl_put()
7907 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_bluetooth_volume_ctl_info()
7908 uinfo->count = 1; in scarlett2_bluetooth_volume_ctl_info()
7909 uinfo->value.integer.min = 0; in scarlett2_bluetooth_volume_ctl_info()
7910 uinfo->value.integer.max = SCARLETT2_MAX_BLUETOOTH_VOLUME; in scarlett2_bluetooth_volume_ctl_info()
7911 uinfo->value.integer.step = 1; in scarlett2_bluetooth_volume_ctl_info()
7926 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_bluetooth_volume_ctl()
7928 if (!private->info->has_bluetooth) in scarlett2_add_bluetooth_volume_ctl()
7934 &private->bluetooth_volume_ctl); in scarlett2_add_bluetooth_volume_ctl()
7941 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_spdif_mode()
7944 const u8 *mode_values = private->info->spdif_mode_values; in scarlett2_update_spdif_mode()
7946 if (!private->info->spdif_mode_control_name) in scarlett2_update_spdif_mode()
7954 private->spdif_mode = 0; in scarlett2_update_spdif_mode()
7958 private->spdif_mode = i; in scarlett2_update_spdif_mode()
7968 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_spdif_mode_ctl_info()
7969 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_spdif_mode_ctl_info()
7970 const char * const *mode_texts = private->info->spdif_mode_texts; in scarlett2_spdif_mode_ctl_info()
7977 private->info->spdif_mode_texts); in scarlett2_spdif_mode_ctl_info()
7983 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_spdif_mode_ctl_get()
7984 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_spdif_mode_ctl_get()
7986 ucontrol->value.enumerated.item[0] = private->spdif_mode; in scarlett2_spdif_mode_ctl_get()
7993 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_spdif_mode_ctl_put()
7994 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_spdif_mode_ctl_put()
7995 struct scarlett2_data *private = mixer->private_data; in scarlett2_spdif_mode_ctl_put()
7999 mutex_lock(&private->data_mutex); in scarlett2_spdif_mode_ctl_put()
8001 oval = private->spdif_mode; in scarlett2_spdif_mode_ctl_put()
8002 val = ucontrol->value.enumerated.item[0]; in scarlett2_spdif_mode_ctl_put()
8005 err = -EINVAL; in scarlett2_spdif_mode_ctl_put()
8010 if (private->info->spdif_mode_values[i] == 0xff) { in scarlett2_spdif_mode_ctl_put()
8011 err = -EINVAL; in scarlett2_spdif_mode_ctl_put()
8018 private->spdif_mode = val; in scarlett2_spdif_mode_ctl_put()
8022 private->info->spdif_mode_values[val]); in scarlett2_spdif_mode_ctl_put()
8027 mutex_unlock(&private->data_mutex); in scarlett2_spdif_mode_ctl_put()
8041 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_spdif_mode_ctl()
8043 if (!private->info->spdif_mode_control_name) in scarlett2_add_spdif_mode_ctl()
8048 private->info->spdif_mode_control_name, in scarlett2_add_spdif_mode_ctl()
8057 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_sync()
8059 private->sync_updated = 1; in scarlett2_notify_sync()
8061 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_sync()
8062 &private->sync_ctl->id); in scarlett2_notify_sync()
8068 struct snd_card *card = mixer->chip->card; in scarlett2_notify_monitor()
8069 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_monitor()
8075 private->vol_updated = 1; in scarlett2_notify_monitor()
8077 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_monitor()
8078 &private->master_vol_ctl->id); in scarlett2_notify_monitor()
8080 for (i = 0; i < private->num_line_out; i++) in scarlett2_notify_monitor()
8081 if (private->vol_sw_hw_switch[line_out_remap(private, i)]) in scarlett2_notify_monitor()
8083 &private->vol_ctls[i]->id); in scarlett2_notify_monitor()
8089 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_volume()
8091 private->vol_updated = 1; in scarlett2_notify_volume()
8093 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_volume()
8094 &private->master_vol_ctl->id); in scarlett2_notify_volume()
8095 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_volume()
8096 &private->headphone_vol_ctl->id); in scarlett2_notify_volume()
8102 struct snd_card *card = mixer->chip->card; in scarlett2_notify_dim_mute()
8103 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_dim_mute()
8109 private->dim_mute_updated = 1; in scarlett2_notify_dim_mute()
8113 &private->dim_mute_ctls[i]->id); in scarlett2_notify_dim_mute()
8115 for (i = 0; i < private->num_line_out; i++) in scarlett2_notify_dim_mute()
8116 if (private->vol_sw_hw_switch[line_out_remap(private, i)]) in scarlett2_notify_dim_mute()
8118 &private->mute_ctls[i]->id); in scarlett2_notify_dim_mute()
8124 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_level()
8125 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_level()
8126 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_level()
8129 private->input_level_updated = 1; in scarlett2_notify_input_level()
8131 for (i = 0; i < info->level_input_count; i++) in scarlett2_notify_input_level()
8133 &private->level_ctls[i]->id); in scarlett2_notify_input_level()
8139 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_pad()
8140 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_pad()
8141 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_pad()
8144 private->input_pad_updated = 1; in scarlett2_notify_input_pad()
8146 for (i = 0; i < info->pad_input_count; i++) in scarlett2_notify_input_pad()
8148 &private->pad_ctls[i]->id); in scarlett2_notify_input_pad()
8154 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_air()
8155 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_air()
8156 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_air()
8159 private->input_air_updated = 1; in scarlett2_notify_input_air()
8161 for (i = 0; i < info->air_input_count; i++) in scarlett2_notify_input_air()
8163 &private->air_ctls[i]->id); in scarlett2_notify_input_air()
8169 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_dsp()
8170 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_dsp()
8171 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_dsp()
8174 private->input_dsp_updated = 1; in scarlett2_notify_input_dsp()
8176 for (i = 0; i < info->dsp_input_count; i++) in scarlett2_notify_input_dsp()
8178 &private->dsp_ctls[i]->id); in scarlett2_notify_input_dsp()
8184 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_mute()
8185 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_mute()
8186 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_mute()
8189 private->input_mute_updated = 1; in scarlett2_notify_input_mute()
8191 for (i = 0; i < info->mute_input_count; i++) in scarlett2_notify_input_mute()
8193 &private->input_mute_ctls[i]->id); in scarlett2_notify_input_mute()
8199 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_phantom()
8200 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_phantom()
8201 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_phantom()
8204 private->input_phantom_updated = 1; in scarlett2_notify_input_phantom()
8206 for (i = 0; i < info->phantom_count; i++) in scarlett2_notify_input_phantom()
8208 &private->phantom_ctls[i]->id); in scarlett2_notify_input_phantom()
8225 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_select()
8226 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_select()
8227 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_select()
8234 private->input_select_updated = 1; in scarlett2_notify_input_select()
8238 &private->input_select_ctl->id); in scarlett2_notify_input_select()
8240 for (i = 0; i < info->gain_input_count; i++) in scarlett2_notify_input_select()
8242 &private->input_link_ctls[i]->id); in scarlett2_notify_input_select()
8248 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_gain()
8249 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_gain()
8250 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_gain()
8253 if (!info->gain_input_count) in scarlett2_notify_input_gain()
8256 private->input_gain_updated = 1; in scarlett2_notify_input_gain()
8258 for (i = 0; i < info->gain_input_count; i++) in scarlett2_notify_input_gain()
8260 &private->input_gain_ctls[i]->id); in scarlett2_notify_input_gain()
8266 struct snd_card *card = mixer->chip->card; in scarlett2_notify_autogain()
8267 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_autogain()
8268 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_autogain()
8271 if (!info->gain_input_count) in scarlett2_notify_autogain()
8274 private->autogain_updated = 1; in scarlett2_notify_autogain()
8276 for (i = 0; i < info->gain_input_count; i++) { in scarlett2_notify_autogain()
8278 &private->autogain_ctls[i]->id); in scarlett2_notify_autogain()
8280 &private->autogain_status_ctls[i]->id); in scarlett2_notify_autogain()
8287 &private->ag_target_ctls[i]->id); in scarlett2_notify_autogain()
8295 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_safe()
8296 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_safe()
8297 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_safe()
8300 if (!info->safe_input_count) in scarlett2_notify_input_safe()
8303 private->input_safe_updated = 1; in scarlett2_notify_input_safe()
8305 for (i = 0; i < info->safe_input_count; i++) in scarlett2_notify_input_safe()
8307 &private->safe_ctls[i]->id); in scarlett2_notify_input_safe()
8313 struct snd_card *card = mixer->chip->card; in scarlett2_notify_monitor_other()
8314 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_monitor_other()
8315 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_monitor_other()
8317 private->monitor_other_updated = 1; in scarlett2_notify_monitor_other()
8319 if (info->has_speaker_switching) in scarlett2_notify_monitor_other()
8321 &private->speaker_switching_ctl->id); in scarlett2_notify_monitor_other()
8323 if (info->has_talkback) in scarlett2_notify_monitor_other()
8325 &private->talkback_ctl->id); in scarlett2_notify_monitor_other()
8330 if (private->speaker_switching_switched) { in scarlett2_notify_monitor_other()
8335 private->speaker_switching_switched = 0; in scarlett2_notify_monitor_other()
8336 private->mux_updated = 1; in scarlett2_notify_monitor_other()
8338 for (i = 0; i < private->num_mux_dsts; i++) in scarlett2_notify_monitor_other()
8340 &private->mux_ctls[i]->id); in scarlett2_notify_monitor_other()
8347 struct snd_card *card = mixer->chip->card; in scarlett2_notify_direct_monitor()
8348 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_direct_monitor()
8349 int count = private->num_mix_in * private->num_mix_out; in scarlett2_notify_direct_monitor()
8352 private->direct_monitor_updated = 1; in scarlett2_notify_direct_monitor()
8355 &private->direct_monitor_ctl->id); in scarlett2_notify_direct_monitor()
8360 private->mix_updated = 1; in scarlett2_notify_direct_monitor()
8365 &private->mix_ctls[i]->id); in scarlett2_notify_direct_monitor()
8371 struct snd_card *card = mixer->chip->card; in scarlett2_notify_power_status()
8372 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_power_status()
8374 private->power_status_updated = 1; in scarlett2_notify_power_status()
8377 &private->power_status_ctl->id); in scarlett2_notify_power_status()
8383 struct snd_card *card = mixer->chip->card; in scarlett2_notify_mux()
8384 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_mux()
8387 private->mux_updated = 1; in scarlett2_notify_mux()
8389 for (i = 0; i < private->num_mux_dsts; i++) in scarlett2_notify_mux()
8391 &private->mux_ctls[i]->id); in scarlett2_notify_mux()
8397 struct snd_card *card = mixer->chip->card; in scarlett2_notify_pcm_input_switch()
8398 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_pcm_input_switch()
8400 private->pcm_input_switch_updated = 1; in scarlett2_notify_pcm_input_switch()
8403 &private->pcm_input_switch_ctl->id); in scarlett2_notify_pcm_input_switch()
8411 struct snd_card *card = mixer->chip->card; in scarlett2_notify_bluetooth()
8412 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_bluetooth()
8414 if (!private->info->has_bluetooth) in scarlett2_notify_bluetooth()
8417 private->bluetooth_updated = 1; in scarlett2_notify_bluetooth()
8420 &private->bluetooth_volume_ctl->id); in scarlett2_notify_bluetooth()
8428 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_ack()
8431 if (private->running) in scarlett2_notify_ack()
8432 complete(&private->cmd_done); in scarlett2_notify_ack()
8438 struct usb_mixer_interface *mixer = urb->context; in scarlett2_notify()
8439 int len = urb->actual_length; in scarlett2_notify()
8440 int ustatus = urb->status; in scarlett2_notify()
8442 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify()
8444 private->config_set->notifications; in scarlett2_notify()
8449 data = le32_to_cpu(*(__le32 *)urb->transfer_buffer); in scarlett2_notify()
8454 if (private->running < 2) in scarlett2_notify()
8457 while (data && notifications->mask) { in scarlett2_notify()
8458 if (data & notifications->mask) { in scarlett2_notify()
8459 data &= ~notifications->mask; in scarlett2_notify()
8460 if (notifications->func) in scarlett2_notify()
8461 notifications->func(mixer); in scarlett2_notify()
8467 usb_audio_warn(mixer->chip, in scarlett2_notify()
8472 if (ustatus != -ENOENT && in scarlett2_notify()
8473 ustatus != -ECONNRESET && in scarlett2_notify()
8474 ustatus != -ESHUTDOWN) { in scarlett2_notify()
8475 urb->dev = mixer->chip->dev; in scarlett2_notify()
8478 complete(&private->cmd_done); in scarlett2_notify()
8486 struct scarlett2_data *private = mixer->private_data; in scarlett2_private_free()
8488 cancel_delayed_work_sync(&private->work); in scarlett2_private_free()
8490 mixer->private_data = NULL; in scarlett2_private_free()
8495 struct scarlett2_data *private = mixer->private_data; in scarlett2_private_suspend()
8497 if (cancel_delayed_work_sync(&private->work)) in scarlett2_private_suspend()
8498 scarlett2_config_save(private->mixer); in scarlett2_private_suspend()
8505 const struct scarlett2_device_info *info = private->info; in scarlett2_count_io()
8506 const struct scarlett2_config_set *config_set = info->config_set; in scarlett2_count_io()
8507 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_count_io()
8518 private->num_mux_srcs = srcs; in scarlett2_count_io()
8519 private->num_mux_dsts = dsts; in scarlett2_count_io()
8525 private->num_mix_in = in scarlett2_count_io()
8526 port_count[SCARLETT2_PORT_TYPE_MIX][SCARLETT2_PORT_OUT] - in scarlett2_count_io()
8527 info->dsp_count; in scarlett2_count_io()
8529 private->num_mix_out = in scarlett2_count_io()
8530 port_count[SCARLETT2_PORT_TYPE_MIX][SCARLETT2_PORT_IN] - in scarlett2_count_io()
8531 info->dsp_count; in scarlett2_count_io()
8534 private->num_line_out = in scarlett2_count_io()
8538 private->num_monitor_mix_ctls = in scarlett2_count_io()
8539 info->direct_monitor * 2 * private->num_mix_in; in scarlett2_count_io()
8542 if (config_set->autogain_status_texts) { in scarlett2_count_io()
8543 const char * const *texts = config_set->autogain_status_texts; in scarlett2_count_io()
8547 private->num_autogain_status_texts = i; in scarlett2_count_io()
8559 struct usb_host_config *config = dev->actconfig; in scarlett2_find_fc_interface()
8562 for (i = 0; i < config->desc.bNumInterfaces; i++) { in scarlett2_find_fc_interface()
8563 struct usb_interface *intf = config->interface[i]; in scarlett2_find_fc_interface()
8565 &intf->altsetting[0].desc; in scarlett2_find_fc_interface()
8568 if (desc->bInterfaceClass != 255) in scarlett2_find_fc_interface()
8571 epd = get_endpoint(intf->altsetting, 0); in scarlett2_find_fc_interface()
8572 private->bInterfaceNumber = desc->bInterfaceNumber; in scarlett2_find_fc_interface()
8573 private->bEndpointAddress = epd->bEndpointAddress & in scarlett2_find_fc_interface()
8575 private->wMaxPacketSize = le16_to_cpu(epd->wMaxPacketSize); in scarlett2_find_fc_interface()
8576 private->bInterval = epd->bInterval; in scarlett2_find_fc_interface()
8580 return -EINVAL; in scarlett2_find_fc_interface()
8591 return -ENOMEM; in scarlett2_init_private()
8593 mutex_init(&private->usb_mutex); in scarlett2_init_private()
8594 mutex_init(&private->data_mutex); in scarlett2_init_private()
8595 INIT_DELAYED_WORK(&private->work, scarlett2_config_save_work); in scarlett2_init_private()
8597 mixer->private_data = private; in scarlett2_init_private()
8598 mixer->private_free = scarlett2_private_free; in scarlett2_init_private()
8599 mixer->private_suspend = scarlett2_private_suspend; in scarlett2_init_private()
8601 private->info = entry->info; in scarlett2_init_private()
8602 private->config_set = entry->info->config_set; in scarlett2_init_private()
8603 private->series_name = entry->series_name; in scarlett2_init_private()
8605 private->scarlett2_seq = 0; in scarlett2_init_private()
8606 private->mixer = mixer; in scarlett2_init_private()
8608 return scarlett2_find_fc_interface(mixer->chip->dev, private); in scarlett2_init_private()
8614 struct usb_device *dev = mixer->chip->dev; in scarlett2_init_notify()
8615 struct scarlett2_data *private = mixer->private_data; in scarlett2_init_notify()
8616 unsigned int pipe = usb_rcvintpipe(dev, private->bEndpointAddress); in scarlett2_init_notify()
8619 if (mixer->urb) { in scarlett2_init_notify()
8620 usb_audio_err(mixer->chip, in scarlett2_init_notify()
8626 return -EINVAL; in scarlett2_init_notify()
8628 mixer->urb = usb_alloc_urb(0, GFP_KERNEL); in scarlett2_init_notify()
8629 if (!mixer->urb) in scarlett2_init_notify()
8630 return -ENOMEM; in scarlett2_init_notify()
8632 transfer_buffer = kmalloc(private->wMaxPacketSize, GFP_KERNEL); in scarlett2_init_notify()
8634 return -ENOMEM; in scarlett2_init_notify()
8636 usb_fill_int_urb(mixer->urb, dev, pipe, in scarlett2_init_notify()
8637 transfer_buffer, private->wMaxPacketSize, in scarlett2_init_notify()
8638 scarlett2_notify, mixer, private->bInterval); in scarlett2_init_notify()
8640 init_completion(&private->cmd_done); in scarlett2_init_notify()
8642 return usb_submit_urb(mixer->urb, GFP_KERNEL); in scarlett2_init_notify()
8648 struct usb_device *dev = mixer->chip->dev; in scarlett2_usb_init()
8649 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_init()
8655 return -EINVAL; in scarlett2_usb_init()
8658 err = scarlett2_usb_rx(dev, private->bInterfaceNumber, in scarlett2_usb_init()
8680 private->running = 1; in scarlett2_usb_init()
8683 private->scarlett2_seq = 1; in scarlett2_usb_init()
8689 private->scarlett2_seq = 1; in scarlett2_usb_init()
8696 /* extract 4-byte firmware version from step2_buf[8] */ in scarlett2_usb_init()
8697 private->firmware_version = le32_to_cpu(*(__le32 *)(step2_buf + 8)); in scarlett2_usb_init()
8698 usb_audio_info(mixer->chip, in scarlett2_usb_init()
8700 private->firmware_version); in scarlett2_usb_init()
8710 struct scarlett2_data *private = mixer->private_data; in scarlett2_get_flash_segment_nums()
8736 usb_audio_err(mixer->chip, in scarlett2_get_flash_segment_nums()
8738 return -EINVAL; in scarlett2_get_flash_segment_nums()
8749 usb_audio_err(mixer->chip, in scarlett2_get_flash_segment_nums()
8764 private->flash_segment_nums[flash_segment_id] = i; in scarlett2_get_flash_segment_nums()
8765 private->flash_segment_blocks[flash_segment_id] = in scarlett2_get_flash_segment_nums()
8771 * use 0 as the "not-found" value in scarlett2_get_flash_segment_nums()
8773 if (!private->flash_segment_nums[SCARLETT2_SEGMENT_ID_SETTINGS]) { in scarlett2_get_flash_segment_nums()
8774 usb_audio_err(mixer->chip, in scarlett2_get_flash_segment_nums()
8777 return -EINVAL; in scarlett2_get_flash_segment_nums()
8779 if (!private->flash_segment_nums[SCARLETT2_SEGMENT_ID_FIRMWARE]) { in scarlett2_get_flash_segment_nums()
8780 usb_audio_err(mixer->chip, in scarlett2_get_flash_segment_nums()
8783 return -EINVAL; in scarlett2_get_flash_segment_nums()
8792 struct scarlett2_data *private = mixer->private_data; in scarlett2_read_configs()
8793 const struct scarlett2_device_info *info = private->info; in scarlett2_read_configs()
8799 1, &private->msd_switch); in scarlett2_read_configs()
8804 if (private->firmware_version < info->min_firmware_version) { in scarlett2_read_configs()
8805 usb_audio_err(mixer->chip, in scarlett2_read_configs()
8808 private->series_name, in scarlett2_read_configs()
8809 private->firmware_version, in scarlett2_read_configs()
8810 info->min_firmware_version); in scarlett2_read_configs()
8815 if (private->msd_switch) in scarlett2_read_configs()
8870 1, &private->standalone_switch); in scarlett2_read_configs()
8893 private->num_line_out, &sw_vol); in scarlett2_read_configs()
8897 for (i = 0; i < private->num_line_out; i++) in scarlett2_read_configs()
8898 private->vol[i] = clamp( in scarlett2_read_configs()
8905 private->num_line_out, &private->mute_switch); in scarlett2_read_configs()
8909 for (i = 0; i < private->num_line_out; i++) in scarlett2_read_configs()
8910 private->mute_switch[i] = in scarlett2_read_configs()
8911 !!private->mute_switch[i]; in scarlett2_read_configs()
8918 private->num_line_out, in scarlett2_read_configs()
8919 &private->vol_sw_hw_switch); in scarlett2_read_configs()
8923 for (i = 0; i < private->num_line_out; i++) in scarlett2_read_configs()
8924 private->vol_sw_hw_switch[i] = in scarlett2_read_configs()
8925 !!private->vol_sw_hw_switch[i]; in scarlett2_read_configs()
8981 while (entry->usb_id && entry->usb_id != mixer->chip->usb_id) in get_scarlett2_device_entry()
8983 if (!entry->usb_id) in get_scarlett2_device_entry()
9001 private = mixer->private_data; in snd_scarlett2_controls_create()
9036 if (private->msd_switch || in snd_scarlett2_controls_create()
9037 private->firmware_version < private->info->min_firmware_version) in snd_scarlett2_controls_create()
9108 if (private->info->gain_input_count) { in snd_scarlett2_controls_create()
9114 private->running = 2; in snd_scarlett2_controls_create()
9121 /* Set private->hwdep_in_use; prevents access to the ALSA controls
9126 mutex_lock(&private->data_mutex); in scarlett2_lock()
9127 private->hwdep_in_use = 1; in scarlett2_lock()
9128 mutex_unlock(&private->data_mutex); in scarlett2_lock()
9134 struct scarlett2_data *private = mixer->private_data; in scarlett2_get_erase_progress()
9143 segment_id = private->selected_flash_segment_id; in scarlett2_get_erase_progress()
9144 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_get_erase_progress()
9148 return -EFAULT; in scarlett2_get_erase_progress()
9182 return -ETIMEDOUT; in scarlett2_wait_for_erase()
9190 struct scarlett2_data *private = mixer->private_data; in scarlett2_reboot()
9192 if (private->flash_write_state == in scarlett2_reboot()
9208 struct scarlett2_data *private = mixer->private_data; in scarlett2_ioctl_select_flash_segment()
9212 return -EFAULT; in scarlett2_ioctl_select_flash_segment()
9216 return -EINVAL; in scarlett2_ioctl_select_flash_segment()
9218 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_ioctl_select_flash_segment()
9221 usb_audio_err(mixer->chip, in scarlett2_ioctl_select_flash_segment()
9224 return -EFAULT; in scarlett2_ioctl_select_flash_segment()
9228 if (private->flash_write_state == SCARLETT2_FLASH_WRITE_STATE_ERASING) { in scarlett2_ioctl_select_flash_segment()
9236 private->selected_flash_segment_id = segment_id; in scarlett2_ioctl_select_flash_segment()
9237 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_SELECTED; in scarlett2_ioctl_select_flash_segment()
9242 /* Erase the previously-selected flash segment */
9246 struct scarlett2_data *private = mixer->private_data; in scarlett2_ioctl_erase_flash_segment()
9254 if (private->flash_write_state != SCARLETT2_FLASH_WRITE_STATE_SELECTED) in scarlett2_ioctl_erase_flash_segment()
9255 return -EINVAL; in scarlett2_ioctl_erase_flash_segment()
9257 segment_id = private->selected_flash_segment_id; in scarlett2_ioctl_erase_flash_segment()
9258 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_ioctl_erase_flash_segment()
9262 return -EFAULT; in scarlett2_ioctl_erase_flash_segment()
9280 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_ERASING; in scarlett2_ioctl_erase_flash_segment()
9290 struct scarlett2_data *private = mixer->private_data; in scarlett2_ioctl_get_erase_progress()
9301 if (private->flash_write_state != SCARLETT2_FLASH_WRITE_STATE_ERASING) in scarlett2_ioctl_get_erase_progress()
9302 return -EINVAL; in scarlett2_ioctl_get_erase_progress()
9304 segment_id = private->selected_flash_segment_id; in scarlett2_ioctl_get_erase_progress()
9305 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_ioctl_get_erase_progress()
9309 return -EFAULT; in scarlett2_ioctl_get_erase_progress()
9322 progress.num_blocks = private->flash_segment_blocks[segment_id]; in scarlett2_ioctl_get_erase_progress()
9325 return -EFAULT; in scarlett2_ioctl_get_erase_progress()
9331 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_WRITE; in scarlett2_ioctl_get_erase_progress()
9338 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_open()
9339 struct scarlett2_data *private = mixer->private_data; in scarlett2_hwdep_open()
9342 if (private->flash_write_state == in scarlett2_hwdep_open()
9351 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_IDLE; in scarlett2_hwdep_open()
9359 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_ioctl()
9365 (int __user *)arg) ? -EFAULT : 0; in scarlett2_hwdep_ioctl()
9380 return -ENOIOCTLCMD; in scarlett2_hwdep_ioctl()
9388 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_read()
9389 struct scarlett2_data *private = mixer->private_data; in scarlett2_hwdep_read()
9403 if (private->flash_write_state != SCARLETT2_FLASH_WRITE_STATE_SELECTED) in scarlett2_hwdep_read()
9404 return -EINVAL; in scarlett2_hwdep_read()
9407 segment_id = private->selected_flash_segment_id; in scarlett2_hwdep_read()
9409 return -EINVAL; in scarlett2_hwdep_read()
9411 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_hwdep_read()
9414 return -EFAULT; in scarlett2_hwdep_read()
9418 return -EINVAL; in scarlett2_hwdep_read()
9421 flash_size = private->flash_segment_blocks[segment_id] * in scarlett2_hwdep_read()
9432 count = flash_size - *offset; in scarlett2_hwdep_read()
9441 return -ENOMEM; in scarlett2_hwdep_read()
9450 err = -EFAULT; in scarlett2_hwdep_read()
9466 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_write()
9467 struct scarlett2_data *private = mixer->private_data; in scarlett2_hwdep_write()
9480 const size_t max_data_size = SCARLETT2_FLASH_RW_MAX - in scarlett2_hwdep_write()
9484 if (private->flash_write_state == in scarlett2_hwdep_write()
9489 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_WRITE; in scarlett2_hwdep_write()
9492 } else if (private->flash_write_state != in scarlett2_hwdep_write()
9494 return -EINVAL; in scarlett2_hwdep_write()
9498 segment_id = private->selected_flash_segment_id; in scarlett2_hwdep_write()
9500 return -EINVAL; in scarlett2_hwdep_write()
9502 segment_num = private->flash_segment_nums[segment_id]; in scarlett2_hwdep_write()
9505 return -EFAULT; in scarlett2_hwdep_write()
9508 flash_size = private->flash_segment_blocks[segment_id] * in scarlett2_hwdep_write()
9512 return -ENOSPC; in scarlett2_hwdep_write()
9525 return -ENOMEM; in scarlett2_hwdep_write()
9527 req->segment_num = cpu_to_le32(segment_num); in scarlett2_hwdep_write()
9528 req->offset = cpu_to_le32(*offset); in scarlett2_hwdep_write()
9529 req->pad = 0; in scarlett2_hwdep_write()
9531 if (copy_from_user(req->data, buf, count)) { in scarlett2_hwdep_write()
9532 err = -EFAULT; in scarlett2_hwdep_write()
9551 struct usb_mixer_interface *mixer = hw->private_data; in scarlett2_hwdep_release()
9552 struct scarlett2_data *private = mixer->private_data; in scarlett2_hwdep_release()
9555 * The ERASING state is left as-is, and checked on next open. in scarlett2_hwdep_release()
9558 private->hwdep_in_use && in scarlett2_hwdep_release()
9559 private->flash_write_state != SCARLETT2_FLASH_WRITE_STATE_ERASING) in scarlett2_hwdep_release()
9560 private->flash_write_state = SCARLETT2_FLASH_WRITE_STATE_IDLE; in scarlett2_hwdep_release()
9570 err = snd_hwdep_new(mixer->chip->card, "Focusrite Control", 0, &hw); in scarlett2_hwdep_init()
9574 hw->private_data = mixer; in scarlett2_hwdep_init()
9575 hw->exclusive = 1; in scarlett2_hwdep_init()
9576 hw->ops.open = scarlett2_hwdep_open; in scarlett2_hwdep_init()
9577 hw->ops.ioctl = scarlett2_hwdep_ioctl; in scarlett2_hwdep_init()
9578 hw->ops.read = scarlett2_hwdep_read; in scarlett2_hwdep_init()
9579 hw->ops.write = scarlett2_hwdep_write; in scarlett2_hwdep_init()
9580 hw->ops.release = scarlett2_hwdep_release; in scarlett2_hwdep_init()
9585 /*** device-map file ***/
9595 struct usb_mixer_interface *mixer = entry->private_data; in scarlett2_devmap_read()
9600 if (pos >= entry->size) in scarlett2_devmap_read()
9603 if (pos + count > entry->size) in scarlett2_devmap_read()
9604 count = entry->size - pos; in scarlett2_devmap_read()
9608 return -ENOMEM; in scarlett2_devmap_read()
9623 size_t block_start = pos - offset; in scarlett2_devmap_read()
9626 entry->size - block_start); in scarlett2_devmap_read()
9629 size_t copy_size = min_t(size_t, count, read_size - offset); in scarlett2_devmap_read()
9642 return -EFAULT; in scarlett2_devmap_read()
9648 count -= copy_size; in scarlett2_devmap_read()
9661 struct snd_card *card = mixer->chip->card; in scarlett2_devmap_init()
9662 struct scarlett2_data *private = mixer->private_data; in scarlett2_devmap_init()
9663 const struct scarlett2_device_info *info = private->info; in scarlett2_devmap_init()
9672 if (!info->has_devmap) in scarlett2_devmap_init()
9686 entry->content = SNDRV_INFO_CONTENT_DATA; in scarlett2_devmap_init()
9687 entry->private_data = mixer; in scarlett2_devmap_init()
9688 entry->c.ops = &scarlett2_devmap_ops; in scarlett2_devmap_init()
9689 entry->size = config_len; in scarlett2_devmap_init()
9690 entry->mode = S_IFREG | 0444; in scarlett2_devmap_init()
9697 struct snd_usb_audio *chip = mixer->chip; in snd_scarlett2_init()
9702 if (!mixer->protocol) in snd_scarlett2_init()
9708 usb_audio_err(mixer->chip, in snd_scarlett2_init()
9711 USB_ID_VENDOR(chip->usb_id), in snd_scarlett2_init()
9712 USB_ID_PRODUCT(chip->usb_id)); in snd_scarlett2_init()
9716 if (chip->setup & SCARLETT2_DISABLE) { in snd_scarlett2_init()
9721 entry->series_name, in snd_scarlett2_init()
9722 USB_ID_VENDOR(chip->usb_id), in snd_scarlett2_init()
9723 USB_ID_PRODUCT(chip->usb_id), in snd_scarlett2_init()
9731 "https://github.com/geoffreybennett/scarlett-gen2/issues", in snd_scarlett2_init()
9732 entry->series_name, in snd_scarlett2_init()
9733 USB_ID_PRODUCT(chip->usb_id)); in snd_scarlett2_init()
9737 usb_audio_err(mixer->chip, in snd_scarlett2_init()
9739 entry->series_name, in snd_scarlett2_init()
9746 usb_audio_err(mixer->chip, in snd_scarlett2_init()
9748 entry->series_name, in snd_scarlett2_init()
9755 usb_audio_err(mixer->chip, in snd_scarlett2_init()
9757 entry->series_name, in snd_scarlett2_init()