Lines Matching +full:- +full:chn +full:- +full:disabled
1 // SPDX-License-Identifier: GPL-2.0
8 * - 6i6/18i8/18i20 Gen 2
9 * - Solo/2i2/4i4/8i6/18i8/18i20 Gen 3
10 * - Clarett 2Pre/4Pre/8Pre USB
11 * - Clarett+ 2Pre/4Pre/8Pre
13 * Copyright (c) 2018-2023 by Geoffrey D. Bennett <g at b4.vu>
14 * Copyright (c) 2020-2021 by Vladimir Sadovnikov <sadko4u@gmail.com>
34 * (firmware 1083) using usbmon in July-August 2018.
57 * and talkback added in May-June 2021.
71 * This ALSA mixer gives access to (model-dependent):
72 * - input, output, mixer-matrix muxes
73 * - mixer-matrix gain stages
74 * - gain/volume/mute controls
75 * - level meters
76 * - line/inst level, pad, and air controls
77 * - phantom power, direct monitor, speaker switching, and talkback
79 * - disable/enable MSD mode
80 * - disable/enable standalone mode
83 * /--------------\ 18chn 20chn /--------------\
84 * | Hardware in +--+------\ /-------------+--+ ALSA PCM out |
85 * \--------------/ | | | | \--------------/
86 * | | | /-----\ |
89 * | +---------------+ | |
91 * | +-----+-----+ | |
93 * | |18chn | |
95 * | | 10chn| |
97 * | +------------+ | |
103 * | +-----+------+ | |
105 * |18chn |10chn | |20chn
107 * | +----------/ |
111 * +---------------+ +--—------------+
113 * +---+---+---+ +-----+-----+
115 * 10chn| | |18chn
117 * /--------------\ | | | /--------------\
118 * | S/PDIF, ADAT |<--/ |10chn \-->| ALSA PCM in |
119 * | Hardware out | | \--------------/
120 * \--------------/ |
122 * +-------------+ Software gain per channel.
123 * | Master Gain |<-- 18i20 only: Switch per channel
124 * +------+------+ to select HW or SW gain control.
126 * |10chn
127 * /--------------\ |
128 * | Analogue |<------/
130 * \--------------/
136 * proprietary software, MSD mode can be disabled by:
137 * - holding down the 48V button for five seconds while powering on
139 * - using this driver and alsamixer to change the "MSD Mode" setting
140 * to Off and power-cycling the device
165 /* mixer range from -80dB to +6dB in 0.5dB steps */
166 #define SCARLETT2_MIXER_MIN_DB -80
167 #define SCARLETT2_MIXER_BIAS (-SCARLETT2_MIXER_MIN_DB * 2)
170 ((SCARLETT2_MIXER_MAX_DB - SCARLETT2_MIXER_MIN_DB) * 2)
174 * for dB in 0 .. 172: int(8192 * pow(10, ((dB - 160) / 2 / 20)))
228 * - None (no input to mux)
229 * - Analogue I/O
230 * - S/PDIF I/O
231 * - ADAT I/O
232 * - Mixer I/O
233 * - PCM I/O
264 * - id: hardware ID of this port type
265 * - src_descr: printf format string for mux input selections
266 * - src_num_offset: added to channel number for the fprintf
267 * - dst_descr: printf format string for mixer controls
333 * to be disabled in order to access the full functionality of
355 /* the first input with a level control (0-based) */
451 /*** Model-specific data ***/
1071 /* actual volume of output inc. dim (-18dB) */
1245 u16 seq = private->scarlett2_seq++; in scarlett2_fill_request_header()
1247 req->cmd = cpu_to_le32(cmd); in scarlett2_fill_request_header()
1248 req->size = cpu_to_le16(req_size); in scarlett2_fill_request_header()
1249 req->seq = cpu_to_le16(seq); in scarlett2_fill_request_header()
1250 req->error = 0; in scarlett2_fill_request_header()
1251 req->pad = 0; in scarlett2_fill_request_header()
1277 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb()
1278 struct usb_device *dev = mixer->chip->dev; in scarlett2_usb()
1286 err = -ENOMEM; in scarlett2_usb()
1292 err = -ENOMEM; in scarlett2_usb()
1296 mutex_lock(&private->usb_mutex); in scarlett2_usb()
1303 memcpy(req->data, req_data, req_size); in scarlett2_usb()
1305 err = scarlett2_usb_tx(dev, private->bInterfaceNumber, in scarlett2_usb()
1310 mixer->chip, in scarlett2_usb()
1312 private->series_name, cmd, err); in scarlett2_usb()
1313 err = -EINVAL; in scarlett2_usb()
1319 err = scarlett2_usb_rx(dev, private->bInterfaceNumber, in scarlett2_usb()
1327 mixer->chip, in scarlett2_usb()
1329 private->series_name, cmd, err, resp_buf_size); in scarlett2_usb()
1330 err = -EINVAL; in scarlett2_usb()
1337 if (resp->cmd != req->cmd || in scarlett2_usb()
1338 (resp->seq != req->seq && in scarlett2_usb()
1339 (le16_to_cpu(req->seq) != 1 || resp->seq != 0)) || in scarlett2_usb()
1340 resp_size != le16_to_cpu(resp->size) || in scarlett2_usb()
1341 resp->error || in scarlett2_usb()
1342 resp->pad) { in scarlett2_usb()
1344 mixer->chip, in scarlett2_usb()
1348 private->series_name, in scarlett2_usb()
1349 le32_to_cpu(req->cmd), le32_to_cpu(resp->cmd), in scarlett2_usb()
1350 le16_to_cpu(req->seq), le16_to_cpu(resp->seq), in scarlett2_usb()
1351 resp_size, le16_to_cpu(resp->size), in scarlett2_usb()
1352 le32_to_cpu(resp->error), in scarlett2_usb()
1353 le32_to_cpu(resp->pad)); in scarlett2_usb()
1354 err = -EINVAL; in scarlett2_usb()
1359 memcpy(resp_data, resp->data, resp_size); in scarlett2_usb()
1362 mutex_unlock(&private->usb_mutex); in scarlett2_usb()
1390 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_get_config()
1391 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_get_config()
1393 &scarlett2_config_items[info->config_set][config_item_num]; in scarlett2_usb_get_config()
1398 /* For byte-sized parameters, retrieve directly into buf */ in scarlett2_usb_get_config()
1399 if (config_item->size >= 8) { in scarlett2_usb_get_config()
1400 size = config_item->size / 8 * count; in scarlett2_usb_get_config()
1401 err = scarlett2_usb_get(mixer, config_item->offset, buf, size); in scarlett2_usb_get_config()
1413 /* For bit-sized parameters, retrieve into value */ in scarlett2_usb_get_config()
1414 err = scarlett2_usb_get(mixer, config_item->offset, &value, 1); in scarlett2_usb_get_config()
1435 usb_audio_err(mixer->chip, "config save failed: %d\n", err); in scarlett2_config_save()
1444 scarlett2_config_save(private->mixer); in scarlett2_config_save_work()
1452 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_config()
1453 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_set_config()
1455 &scarlett2_config_items[info->config_set][config_item_num]; in scarlett2_usb_set_config()
1466 cancel_delayed_work_sync(&private->work); in scarlett2_usb_set_config()
1468 /* Convert config_item->size in bits to size in bytes and in scarlett2_usb_set_config()
1471 if (config_item->size >= 8) { in scarlett2_usb_set_config()
1472 size = config_item->size / 8; in scarlett2_usb_set_config()
1473 offset = config_item->offset + index * size; in scarlett2_usb_set_config()
1482 offset = config_item->offset; in scarlett2_usb_set_config()
1507 req2 = cpu_to_le32(config_item->activate); in scarlett2_usb_set_config()
1514 if (config_item->activate != SCARLETT2_USB_CONFIG_SAVE) in scarlett2_usb_set_config()
1515 schedule_delayed_work(&private->work, msecs_to_jiffies(2000)); in scarlett2_usb_set_config()
1547 * and put the values into private->mix[]
1552 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_get_mix()
1553 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_get_mix()
1556 info->port_count[SCARLETT2_PORT_TYPE_MIX][SCARLETT2_PORT_OUT]; in scarlett2_usb_get_mix()
1583 private->mix[j] = k; in scarlett2_usb_get_mix()
1590 * (values obtained from private->mix[])
1595 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_mix()
1596 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_set_mix()
1605 info->port_count[SCARLETT2_PORT_TYPE_MIX][SCARLETT2_PORT_OUT]; in scarlett2_usb_set_mix()
1611 scarlett2_mixer_values[private->mix[j]] in scarlett2_usb_set_mix()
1619 /* Convert a port number index (per info->port_count) to a hardware ID */
1630 num -= port_count[port_type][SCARLETT2_PORT_IN]; in scarlett2_mux_src_num_to_id()
1651 return port_num + id - base; in scarlett2_mux_id_to_num()
1656 return -1; in scarlett2_mux_id_to_num()
1659 /* Convert one mux entry from the interface and load into private->mux[] */
1663 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_populate_mux()
1664 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_usb_populate_mux()
1673 if (dst_idx >= private->num_mux_dsts) { in scarlett2_usb_populate_mux()
1674 usb_audio_err(private->mixer->chip, in scarlett2_usb_populate_mux()
1676 mux_entry, dst_idx, private->num_mux_dsts); in scarlett2_usb_populate_mux()
1685 if (src_idx >= private->num_mux_srcs) { in scarlett2_usb_populate_mux()
1686 usb_audio_err(private->mixer->chip, in scarlett2_usb_populate_mux()
1688 mux_entry, src_idx, private->num_mux_srcs); in scarlett2_usb_populate_mux()
1692 private->mux[dst_idx] = src_idx; in scarlett2_usb_populate_mux()
1695 /* Send USB message to get mux inputs and then populate private->mux[] */
1698 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_get_mux()
1699 int count = private->num_mux_dsts; in scarlett2_usb_get_mux()
1709 private->mux_updated = 0; in scarlett2_usb_get_mux()
1729 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_set_mux()
1730 const struct scarlett2_device_info *info = private->info; in scarlett2_usb_set_mux()
1731 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_usb_set_mux()
1752 for (entry = info->mux_assignment[table]; in scarlett2_usb_set_mux()
1753 entry->count; in scarlett2_usb_set_mux()
1756 int port_type = entry->port_type; in scarlett2_usb_set_mux()
1757 int port_idx = entry->start; in scarlett2_usb_set_mux()
1764 for (j = 0; j < entry->count; j++) in scarlett2_usb_set_mux()
1769 /* Non-empty mux slots use the lower 12 bits in scarlett2_usb_set_mux()
1773 for (j = 0; j < entry->count; j++) { in scarlett2_usb_set_mux()
1775 port_count, private->mux[mux_idx++]); in scarlett2_usb_set_mux()
1833 return -ENOMEM; in scarlett2_add_new_ctl()
1839 elem->head.mixer = mixer; in scarlett2_add_new_ctl()
1840 elem->control = index; in scarlett2_add_new_ctl()
1841 elem->head.id = 0; in scarlett2_add_new_ctl()
1842 elem->channels = channels; in scarlett2_add_new_ctl()
1843 elem->val_type = USB_MIXER_BESPOKEN; in scarlett2_add_new_ctl()
1848 return -ENOMEM; in scarlett2_add_new_ctl()
1850 kctl->private_free = snd_usb_mixer_elem_free; in scarlett2_add_new_ctl()
1852 strscpy(kctl->id.name, name, sizeof(kctl->id.name)); in scarlett2_add_new_ctl()
1854 err = snd_usb_mixer_add_control(&elem->head, kctl); in scarlett2_add_new_ctl()
1871 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_sync()
1873 private->sync_updated = 0; in scarlett2_update_sync()
1874 return scarlett2_usb_get_sync_status(mixer, &private->sync); in scarlett2_update_sync()
1889 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_sync_ctl_get()
1890 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_sync_ctl_get()
1891 struct scarlett2_data *private = mixer->private_data; in scarlett2_sync_ctl_get()
1894 mutex_lock(&private->data_mutex); in scarlett2_sync_ctl_get()
1896 if (private->sync_updated) { in scarlett2_sync_ctl_get()
1901 ucontrol->value.enumerated.item[0] = private->sync; in scarlett2_sync_ctl_get()
1904 mutex_unlock(&private->data_mutex); in scarlett2_sync_ctl_get()
1918 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_sync_ctl()
1921 if (private->info->config_set == SCARLETT2_CONFIG_SET_NO_MIXER) in scarlett2_add_sync_ctl()
1925 0, 1, "Sync Status", &private->sync_ctl); in scarlett2_add_sync_ctl()
1935 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_volumes()
1936 const struct scarlett2_device_info *info = private->info; in scarlett2_update_volumes()
1937 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_update_volumes()
1944 private->vol_updated = 0; in scarlett2_update_volumes()
1950 private->master_vol = clamp( in scarlett2_update_volumes()
1954 if (info->line_out_hw_vol) in scarlett2_update_volumes()
1956 private->dim_mute[i] = !!volume_status.dim_mute[i]; in scarlett2_update_volumes()
1958 mute = private->dim_mute[SCARLETT2_BUTTON_MUTE]; in scarlett2_update_volumes()
1961 if (private->vol_sw_hw_switch[i]) { in scarlett2_update_volumes()
1962 private->vol[i] = private->master_vol; in scarlett2_update_volumes()
1963 private->mute_switch[i] = mute; in scarlett2_update_volumes()
1972 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_volume_ctl_info()
1974 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_volume_ctl_info()
1975 uinfo->count = elem->channels; in scarlett2_volume_ctl_info()
1976 uinfo->value.integer.min = 0; in scarlett2_volume_ctl_info()
1977 uinfo->value.integer.max = SCARLETT2_VOLUME_BIAS; in scarlett2_volume_ctl_info()
1978 uinfo->value.integer.step = 1; in scarlett2_volume_ctl_info()
1985 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_master_volume_ctl_get()
1986 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_master_volume_ctl_get()
1987 struct scarlett2_data *private = mixer->private_data; in scarlett2_master_volume_ctl_get()
1990 mutex_lock(&private->data_mutex); in scarlett2_master_volume_ctl_get()
1992 if (private->vol_updated) { in scarlett2_master_volume_ctl_get()
1997 ucontrol->value.integer.value[0] = private->master_vol; in scarlett2_master_volume_ctl_get()
2000 mutex_unlock(&private->data_mutex); in scarlett2_master_volume_ctl_get()
2006 const struct scarlett2_device_info *info = private->info; in line_out_remap()
2007 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in line_out_remap()
2011 if (!info->line_out_remap_enable) in line_out_remap()
2017 return info->line_out_remap[index]; in line_out_remap()
2023 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_volume_ctl_get()
2024 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_volume_ctl_get()
2025 struct scarlett2_data *private = mixer->private_data; in scarlett2_volume_ctl_get()
2026 int index = line_out_remap(private, elem->control); in scarlett2_volume_ctl_get()
2029 mutex_lock(&private->data_mutex); in scarlett2_volume_ctl_get()
2031 if (private->vol_updated) { in scarlett2_volume_ctl_get()
2036 ucontrol->value.integer.value[0] = private->vol[index]; in scarlett2_volume_ctl_get()
2039 mutex_unlock(&private->data_mutex); in scarlett2_volume_ctl_get()
2046 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_volume_ctl_put()
2047 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_volume_ctl_put()
2048 struct scarlett2_data *private = mixer->private_data; in scarlett2_volume_ctl_put()
2049 int index = line_out_remap(private, elem->control); in scarlett2_volume_ctl_put()
2052 mutex_lock(&private->data_mutex); in scarlett2_volume_ctl_put()
2054 oval = private->vol[index]; in scarlett2_volume_ctl_put()
2055 val = ucontrol->value.integer.value[0]; in scarlett2_volume_ctl_put()
2060 private->vol[index] = val; in scarlett2_volume_ctl_put()
2062 index, val - SCARLETT2_VOLUME_BIAS); in scarlett2_volume_ctl_put()
2067 mutex_unlock(&private->data_mutex); in scarlett2_volume_ctl_put()
2072 db_scale_scarlett2_gain, -SCARLETT2_VOLUME_BIAS * 100, 0
2103 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mute_ctl_get()
2104 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mute_ctl_get()
2105 struct scarlett2_data *private = mixer->private_data; in scarlett2_mute_ctl_get()
2106 int index = line_out_remap(private, elem->control); in scarlett2_mute_ctl_get()
2109 mutex_lock(&private->data_mutex); in scarlett2_mute_ctl_get()
2111 if (private->vol_updated) { in scarlett2_mute_ctl_get()
2116 ucontrol->value.integer.value[0] = private->mute_switch[index]; in scarlett2_mute_ctl_get()
2119 mutex_unlock(&private->data_mutex); in scarlett2_mute_ctl_get()
2126 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mute_ctl_put()
2127 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mute_ctl_put()
2128 struct scarlett2_data *private = mixer->private_data; in scarlett2_mute_ctl_put()
2129 int index = line_out_remap(private, elem->control); in scarlett2_mute_ctl_put()
2132 mutex_lock(&private->data_mutex); in scarlett2_mute_ctl_put()
2134 oval = private->mute_switch[index]; in scarlett2_mute_ctl_put()
2135 val = !!ucontrol->value.integer.value[0]; in scarlett2_mute_ctl_put()
2140 private->mute_switch[index] = val; in scarlett2_mute_ctl_put()
2149 mutex_unlock(&private->data_mutex); in scarlett2_mute_ctl_put()
2165 private->sw_hw_ctls[index]->vd[0].access &= in scarlett2_sw_hw_ctl_ro()
2171 private->sw_hw_ctls[index]->vd[0].access |= in scarlett2_sw_hw_ctl_rw()
2188 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_sw_hw_enum_ctl_get()
2189 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_sw_hw_enum_ctl_get()
2190 int index = line_out_remap(private, elem->control); in scarlett2_sw_hw_enum_ctl_get()
2192 ucontrol->value.enumerated.item[0] = private->vol_sw_hw_switch[index]; in scarlett2_sw_hw_enum_ctl_get()
2199 struct scarlett2_data *private = mixer->private_data; in scarlett2_vol_ctl_set_writable()
2200 struct snd_card *card = mixer->chip->card; in scarlett2_vol_ctl_set_writable()
2204 private->vol_ctls[index]->vd[0].access |= in scarlett2_vol_ctl_set_writable()
2206 private->mute_ctls[index]->vd[0].access |= in scarlett2_vol_ctl_set_writable()
2209 private->vol_ctls[index]->vd[0].access &= in scarlett2_vol_ctl_set_writable()
2211 private->mute_ctls[index]->vd[0].access &= in scarlett2_vol_ctl_set_writable()
2218 &private->vol_ctls[index]->id); in scarlett2_vol_ctl_set_writable()
2221 &private->mute_ctls[index]->id); in scarlett2_vol_ctl_set_writable()
2227 struct scarlett2_data *private = mixer->private_data; in scarlett2_sw_hw_change()
2231 private->vol_sw_hw_switch[index] = val; in scarlett2_sw_hw_change()
2239 private->vol[index] = private->master_vol; in scarlett2_sw_hw_change()
2240 private->mute_switch[index] = private->dim_mute[SCARLETT2_BUTTON_MUTE]; in scarlett2_sw_hw_change()
2245 index, private->master_vol - SCARLETT2_VOLUME_BIAS); in scarlett2_sw_hw_change()
2252 index, private->dim_mute[SCARLETT2_BUTTON_MUTE]); in scarlett2_sw_hw_change()
2264 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_sw_hw_enum_ctl_put()
2265 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_sw_hw_enum_ctl_put()
2266 struct scarlett2_data *private = mixer->private_data; in scarlett2_sw_hw_enum_ctl_put()
2267 int ctl_index = elem->control; in scarlett2_sw_hw_enum_ctl_put()
2271 mutex_lock(&private->data_mutex); in scarlett2_sw_hw_enum_ctl_put()
2273 oval = private->vol_sw_hw_switch[index]; in scarlett2_sw_hw_enum_ctl_put()
2274 val = !!ucontrol->value.enumerated.item[0]; in scarlett2_sw_hw_enum_ctl_put()
2284 mutex_unlock(&private->data_mutex); in scarlett2_sw_hw_enum_ctl_put()
2300 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_input_other()
2301 const struct scarlett2_device_info *info = private->info; in scarlett2_update_input_other()
2303 private->input_other_updated = 0; in scarlett2_update_input_other()
2305 if (info->level_input_count) { in scarlett2_update_input_other()
2308 info->level_input_count + info->level_input_first, in scarlett2_update_input_other()
2309 private->level_switch); in scarlett2_update_input_other()
2314 if (info->pad_input_count) { in scarlett2_update_input_other()
2317 info->pad_input_count, private->pad_switch); in scarlett2_update_input_other()
2322 if (info->air_input_count) { in scarlett2_update_input_other()
2325 info->air_input_count, private->air_switch); in scarlett2_update_input_other()
2330 if (info->phantom_count) { in scarlett2_update_input_other()
2333 info->phantom_count, private->phantom_switch); in scarlett2_update_input_other()
2339 1, &private->phantom_persistence); in scarlett2_update_input_other()
2360 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_level_enum_ctl_get()
2361 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_level_enum_ctl_get()
2362 struct scarlett2_data *private = mixer->private_data; in scarlett2_level_enum_ctl_get()
2363 const struct scarlett2_device_info *info = private->info; in scarlett2_level_enum_ctl_get()
2365 int index = elem->control + info->level_input_first; in scarlett2_level_enum_ctl_get()
2368 mutex_lock(&private->data_mutex); in scarlett2_level_enum_ctl_get()
2370 if (private->input_other_updated) { in scarlett2_level_enum_ctl_get()
2375 ucontrol->value.enumerated.item[0] = private->level_switch[index]; in scarlett2_level_enum_ctl_get()
2378 mutex_unlock(&private->data_mutex); in scarlett2_level_enum_ctl_get()
2385 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_level_enum_ctl_put()
2386 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_level_enum_ctl_put()
2387 struct scarlett2_data *private = mixer->private_data; in scarlett2_level_enum_ctl_put()
2388 const struct scarlett2_device_info *info = private->info; in scarlett2_level_enum_ctl_put()
2390 int index = elem->control + info->level_input_first; in scarlett2_level_enum_ctl_put()
2393 mutex_lock(&private->data_mutex); in scarlett2_level_enum_ctl_put()
2395 oval = private->level_switch[index]; in scarlett2_level_enum_ctl_put()
2396 val = !!ucontrol->value.enumerated.item[0]; in scarlett2_level_enum_ctl_put()
2401 private->level_switch[index] = val; in scarlett2_level_enum_ctl_put()
2410 mutex_unlock(&private->data_mutex); in scarlett2_level_enum_ctl_put()
2427 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pad_ctl_get()
2428 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pad_ctl_get()
2429 struct scarlett2_data *private = mixer->private_data; in scarlett2_pad_ctl_get()
2432 mutex_lock(&private->data_mutex); in scarlett2_pad_ctl_get()
2434 if (private->input_other_updated) { in scarlett2_pad_ctl_get()
2439 ucontrol->value.integer.value[0] = in scarlett2_pad_ctl_get()
2440 private->pad_switch[elem->control]; in scarlett2_pad_ctl_get()
2443 mutex_unlock(&private->data_mutex); in scarlett2_pad_ctl_get()
2450 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_pad_ctl_put()
2451 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_pad_ctl_put()
2452 struct scarlett2_data *private = mixer->private_data; in scarlett2_pad_ctl_put()
2454 int index = elem->control; in scarlett2_pad_ctl_put()
2457 mutex_lock(&private->data_mutex); in scarlett2_pad_ctl_put()
2459 oval = private->pad_switch[index]; in scarlett2_pad_ctl_put()
2460 val = !!ucontrol->value.integer.value[0]; in scarlett2_pad_ctl_put()
2465 private->pad_switch[index] = val; in scarlett2_pad_ctl_put()
2474 mutex_unlock(&private->data_mutex); in scarlett2_pad_ctl_put()
2491 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_air_ctl_get()
2492 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_air_ctl_get()
2493 struct scarlett2_data *private = mixer->private_data; in scarlett2_air_ctl_get()
2496 mutex_lock(&private->data_mutex); in scarlett2_air_ctl_get()
2498 if (private->input_other_updated) { in scarlett2_air_ctl_get()
2503 ucontrol->value.integer.value[0] = private->air_switch[elem->control]; in scarlett2_air_ctl_get()
2506 mutex_unlock(&private->data_mutex); in scarlett2_air_ctl_get()
2513 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_air_ctl_put()
2514 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_air_ctl_put()
2515 struct scarlett2_data *private = mixer->private_data; in scarlett2_air_ctl_put()
2517 int index = elem->control; in scarlett2_air_ctl_put()
2520 mutex_lock(&private->data_mutex); in scarlett2_air_ctl_put()
2522 oval = private->air_switch[index]; in scarlett2_air_ctl_put()
2523 val = !!ucontrol->value.integer.value[0]; in scarlett2_air_ctl_put()
2528 private->air_switch[index] = val; in scarlett2_air_ctl_put()
2537 mutex_unlock(&private->data_mutex); in scarlett2_air_ctl_put()
2554 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_ctl_get()
2555 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_phantom_ctl_get()
2556 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_ctl_get()
2559 mutex_lock(&private->data_mutex); in scarlett2_phantom_ctl_get()
2561 if (private->input_other_updated) { in scarlett2_phantom_ctl_get()
2566 ucontrol->value.integer.value[0] = in scarlett2_phantom_ctl_get()
2567 private->phantom_switch[elem->control]; in scarlett2_phantom_ctl_get()
2570 mutex_unlock(&private->data_mutex); in scarlett2_phantom_ctl_get()
2577 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_ctl_put()
2578 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_phantom_ctl_put()
2579 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_ctl_put()
2581 int index = elem->control; in scarlett2_phantom_ctl_put()
2584 mutex_lock(&private->data_mutex); in scarlett2_phantom_ctl_put()
2586 oval = private->phantom_switch[index]; in scarlett2_phantom_ctl_put()
2587 val = !!ucontrol->value.integer.value[0]; in scarlett2_phantom_ctl_put()
2592 private->phantom_switch[index] = val; in scarlett2_phantom_ctl_put()
2601 mutex_unlock(&private->data_mutex); in scarlett2_phantom_ctl_put()
2618 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_persistence_ctl_get()
2619 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_phantom_persistence_ctl_get()
2621 ucontrol->value.integer.value[0] = private->phantom_persistence; in scarlett2_phantom_persistence_ctl_get()
2628 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_phantom_persistence_ctl_put()
2629 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_phantom_persistence_ctl_put()
2630 struct scarlett2_data *private = mixer->private_data; in scarlett2_phantom_persistence_ctl_put()
2632 int index = elem->control; in scarlett2_phantom_persistence_ctl_put()
2635 mutex_lock(&private->data_mutex); in scarlett2_phantom_persistence_ctl_put()
2637 oval = private->phantom_persistence; in scarlett2_phantom_persistence_ctl_put()
2638 val = !!ucontrol->value.integer.value[0]; in scarlett2_phantom_persistence_ctl_put()
2643 private->phantom_persistence = val; in scarlett2_phantom_persistence_ctl_put()
2652 mutex_unlock(&private->data_mutex); in scarlett2_phantom_persistence_ctl_put()
2668 struct scarlett2_data *private = mixer->private_data; in scarlett2_update_monitor_other()
2669 const struct scarlett2_device_info *info = private->info; in scarlett2_update_monitor_other()
2682 private->monitor_other_updated = 0; in scarlett2_update_monitor_other()
2684 if (info->direct_monitor) in scarlett2_update_monitor_other()
2687 1, &private->direct_monitor_switch); in scarlett2_update_monitor_other()
2692 if (!info->has_speaker_switching) in scarlett2_update_monitor_other()
2708 private->speaker_switching_switch = 0; in scarlett2_update_monitor_other()
2710 private->speaker_switching_switch = monitor_other_switch[0] + 1; in scarlett2_update_monitor_other()
2712 if (info->has_talkback) { in scarlett2_update_monitor_other()
2714 info->port_count; in scarlett2_update_monitor_other()
2721 private->talkback_switch = 0; in scarlett2_update_monitor_other()
2723 private->talkback_switch = monitor_other_switch[1] + 1; in scarlett2_update_monitor_other()
2731 private->talkback_map[i] = bitmap & 1; in scarlett2_update_monitor_other()
2740 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_direct_monitor_ctl_get()
2741 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_direct_monitor_ctl_get()
2742 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_direct_monitor_ctl_get()
2745 mutex_lock(&private->data_mutex); in scarlett2_direct_monitor_ctl_get()
2747 if (private->monitor_other_updated) { in scarlett2_direct_monitor_ctl_get()
2752 ucontrol->value.enumerated.item[0] = private->direct_monitor_switch; in scarlett2_direct_monitor_ctl_get()
2755 mutex_unlock(&private->data_mutex); in scarlett2_direct_monitor_ctl_get()
2762 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_direct_monitor_ctl_put()
2763 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_direct_monitor_ctl_put()
2764 struct scarlett2_data *private = mixer->private_data; in scarlett2_direct_monitor_ctl_put()
2766 int index = elem->control; in scarlett2_direct_monitor_ctl_put()
2769 mutex_lock(&private->data_mutex); in scarlett2_direct_monitor_ctl_put()
2771 oval = private->direct_monitor_switch; in scarlett2_direct_monitor_ctl_put()
2772 val = min(ucontrol->value.enumerated.item[0], 2U); in scarlett2_direct_monitor_ctl_put()
2777 private->direct_monitor_switch = val; in scarlett2_direct_monitor_ctl_put()
2786 mutex_unlock(&private->data_mutex); in scarlett2_direct_monitor_ctl_put()
2800 /* Direct Monitor for Solo is mono-only and only needs a boolean control
2822 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_direct_monitor_ctl()
2823 const struct scarlett2_device_info *info = private->info; in scarlett2_add_direct_monitor_ctl()
2826 if (!info->direct_monitor) in scarlett2_add_direct_monitor_ctl()
2829 s = info->direct_monitor == 1 in scarlett2_add_direct_monitor_ctl()
2834 mixer, &scarlett2_direct_monitor_ctl[info->direct_monitor - 1], in scarlett2_add_direct_monitor_ctl()
2835 0, 1, s, &private->direct_monitor_ctl); in scarlett2_add_direct_monitor_ctl()
2853 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_speaker_switch_enum_ctl_get()
2854 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_speaker_switch_enum_ctl_get()
2855 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_enum_ctl_get()
2858 mutex_lock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_get()
2860 if (private->monitor_other_updated) { in scarlett2_speaker_switch_enum_ctl_get()
2865 ucontrol->value.enumerated.item[0] = private->speaker_switching_switch; in scarlett2_speaker_switch_enum_ctl_get()
2868 mutex_unlock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_get()
2877 struct snd_card *card = mixer->chip->card; in scarlett2_speaker_switch_enable()
2878 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_enable()
2885 if (!private->vol_sw_hw_switch[index]) { in scarlett2_speaker_switch_enable()
2886 err = scarlett2_sw_hw_change(private->mixer, i, 1); in scarlett2_speaker_switch_enable()
2896 &private->sw_hw_ctls[i]->id); in scarlett2_speaker_switch_enable()
2899 /* when the next monitor-other notify comes in, update the mux in scarlett2_speaker_switch_enable()
2902 private->speaker_switching_switched = 1; in scarlett2_speaker_switch_enable()
2907 /* when speaker switching gets disabled, reenable the hw/sw controls
2912 struct snd_card *card = mixer->chip->card; in scarlett2_speaker_switch_disable()
2913 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_disable()
2920 &private->sw_hw_ctls[i]->id); in scarlett2_speaker_switch_disable()
2923 /* when the next monitor-other notify comes in, update the mux in scarlett2_speaker_switch_disable()
2926 private->speaker_switching_switched = 1; in scarlett2_speaker_switch_disable()
2932 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_speaker_switch_enum_ctl_put()
2933 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_speaker_switch_enum_ctl_put()
2934 struct scarlett2_data *private = mixer->private_data; in scarlett2_speaker_switch_enum_ctl_put()
2938 mutex_lock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_put()
2940 oval = private->speaker_switching_switch; in scarlett2_speaker_switch_enum_ctl_put()
2941 val = min(ucontrol->value.enumerated.item[0], 2U); in scarlett2_speaker_switch_enum_ctl_put()
2946 private->speaker_switching_switch = val; in scarlett2_speaker_switch_enum_ctl_put()
2962 /* update controls if speaker switching gets enabled or disabled */ in scarlett2_speaker_switch_enum_ctl_put()
2972 mutex_unlock(&private->data_mutex); in scarlett2_speaker_switch_enum_ctl_put()
2987 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_speaker_switch_ctl()
2988 const struct scarlett2_device_info *info = private->info; in scarlett2_add_speaker_switch_ctl()
2990 if (!info->has_speaker_switching) in scarlett2_add_speaker_switch_ctl()
2996 &private->speaker_switching_ctl); in scarlett2_add_speaker_switch_ctl()
3005 "Disabled", "Off", "On" in scarlett2_talkback_enum_ctl_info()
3014 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_enum_ctl_get()
3015 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_enum_ctl_get()
3016 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_enum_ctl_get()
3019 mutex_lock(&private->data_mutex); in scarlett2_talkback_enum_ctl_get()
3021 if (private->monitor_other_updated) { in scarlett2_talkback_enum_ctl_get()
3026 ucontrol->value.enumerated.item[0] = private->talkback_switch; in scarlett2_talkback_enum_ctl_get()
3029 mutex_unlock(&private->data_mutex); in scarlett2_talkback_enum_ctl_get()
3036 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_enum_ctl_put()
3037 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_enum_ctl_put()
3038 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_enum_ctl_put()
3042 mutex_lock(&private->data_mutex); in scarlett2_talkback_enum_ctl_put()
3044 oval = private->talkback_switch; in scarlett2_talkback_enum_ctl_put()
3045 val = min(ucontrol->value.enumerated.item[0], 2U); in scarlett2_talkback_enum_ctl_put()
3050 private->talkback_switch = val; in scarlett2_talkback_enum_ctl_put()
3067 mutex_unlock(&private->data_mutex); in scarlett2_talkback_enum_ctl_put()
3082 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_map_ctl_get()
3083 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_map_ctl_get()
3084 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_map_ctl_get()
3085 int index = elem->control; in scarlett2_talkback_map_ctl_get()
3087 ucontrol->value.integer.value[0] = private->talkback_map[index]; in scarlett2_talkback_map_ctl_get()
3095 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_talkback_map_ctl_put()
3096 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_talkback_map_ctl_put()
3097 struct scarlett2_data *private = mixer->private_data; in scarlett2_talkback_map_ctl_put()
3099 private->info->port_count; in scarlett2_talkback_map_ctl_put()
3102 int index = elem->control; in scarlett2_talkback_map_ctl_put()
3106 mutex_lock(&private->data_mutex); in scarlett2_talkback_map_ctl_put()
3108 oval = private->talkback_map[index]; in scarlett2_talkback_map_ctl_put()
3109 val = !!ucontrol->value.integer.value[0]; in scarlett2_talkback_map_ctl_put()
3114 private->talkback_map[index] = val; in scarlett2_talkback_map_ctl_put()
3117 bitmap |= private->talkback_map[i] << i; in scarlett2_talkback_map_ctl_put()
3126 mutex_unlock(&private->data_mutex); in scarlett2_talkback_map_ctl_put()
3141 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_talkback_ctls()
3142 const struct scarlett2_device_info *info = private->info; in scarlett2_add_talkback_ctls()
3143 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_add_talkback_ctls()
3148 if (!info->has_talkback) in scarlett2_add_talkback_ctls()
3154 &private->talkback_ctl); in scarlett2_add_talkback_ctls()
3175 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dim_mute_ctl_get()
3176 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dim_mute_ctl_get()
3177 struct scarlett2_data *private = mixer->private_data; in scarlett2_dim_mute_ctl_get()
3180 mutex_lock(&private->data_mutex); in scarlett2_dim_mute_ctl_get()
3182 if (private->vol_updated) { in scarlett2_dim_mute_ctl_get()
3187 ucontrol->value.integer.value[0] = private->dim_mute[elem->control]; in scarlett2_dim_mute_ctl_get()
3190 mutex_unlock(&private->data_mutex); in scarlett2_dim_mute_ctl_get()
3197 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_dim_mute_ctl_put()
3198 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_dim_mute_ctl_put()
3199 struct scarlett2_data *private = mixer->private_data; in scarlett2_dim_mute_ctl_put()
3200 const struct scarlett2_device_info *info = private->info; in scarlett2_dim_mute_ctl_put()
3201 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_dim_mute_ctl_put()
3205 int index = elem->control; in scarlett2_dim_mute_ctl_put()
3208 mutex_lock(&private->data_mutex); in scarlett2_dim_mute_ctl_put()
3210 oval = private->dim_mute[index]; in scarlett2_dim_mute_ctl_put()
3211 val = !!ucontrol->value.integer.value[0]; in scarlett2_dim_mute_ctl_put()
3216 private->dim_mute[index] = val; in scarlett2_dim_mute_ctl_put()
3228 if (private->vol_sw_hw_switch[line_index]) { in scarlett2_dim_mute_ctl_put()
3229 private->mute_switch[line_index] = val; in scarlett2_dim_mute_ctl_put()
3230 snd_ctl_notify(mixer->chip->card, in scarlett2_dim_mute_ctl_put()
3232 &private->mute_ctls[i]->id); in scarlett2_dim_mute_ctl_put()
3237 mutex_unlock(&private->data_mutex); in scarlett2_dim_mute_ctl_put()
3253 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_line_out_ctls()
3254 const struct scarlett2_device_info *info = private->info; in scarlett2_add_line_out_ctls()
3255 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_add_line_out_ctls()
3262 if (info->line_out_hw_vol) { in scarlett2_add_line_out_ctls()
3266 0, 1, s, &private->master_vol_ctl); in scarlett2_add_line_out_ctls()
3276 if (info->line_out_descrs[i]) in scarlett2_add_line_out_ctls()
3279 i + 1, info->line_out_descrs[i]); in scarlett2_add_line_out_ctls()
3286 i, 1, s, &private->vol_ctls[i]); in scarlett2_add_line_out_ctls()
3297 &private->mute_ctls[i]); in scarlett2_add_line_out_ctls()
3301 /* Make the fader and mute controls read-only if the in scarlett2_add_line_out_ctls()
3304 if (private->vol_sw_hw_switch[index]) in scarlett2_add_line_out_ctls()
3308 if (info->line_out_hw_vol) { in scarlett2_add_line_out_ctls()
3315 &private->sw_hw_ctls[i]); in scarlett2_add_line_out_ctls()
3319 /* Make the switch read-only if the line is in scarlett2_add_line_out_ctls()
3322 if (private->speaker_switching_switch && i < 4) in scarlett2_add_line_out_ctls()
3328 if (info->line_out_hw_vol) in scarlett2_add_line_out_ctls()
3333 &private->dim_mute_ctls[i]); in scarlett2_add_line_out_ctls()
3345 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_line_in_ctls()
3346 const struct scarlett2_device_info *info = private->info; in scarlett2_add_line_in_ctls()
3350 const char *fmt2 = "Line In %d-%d %s Capture %s"; in scarlett2_add_line_in_ctls()
3353 for (i = 0; i < info->level_input_count; i++) { in scarlett2_add_line_in_ctls()
3354 snprintf(s, sizeof(s), fmt, i + 1 + info->level_input_first, in scarlett2_add_line_in_ctls()
3357 i, 1, s, &private->level_ctls[i]); in scarlett2_add_line_in_ctls()
3363 for (i = 0; i < info->pad_input_count; i++) { in scarlett2_add_line_in_ctls()
3366 i, 1, s, &private->pad_ctls[i]); in scarlett2_add_line_in_ctls()
3372 for (i = 0; i < info->air_input_count; i++) { in scarlett2_add_line_in_ctls()
3375 i, 1, s, &private->air_ctls[i]); in scarlett2_add_line_in_ctls()
3381 if (info->inputs_per_phantom == 1) { in scarlett2_add_line_in_ctls()
3382 for (i = 0; i < info->phantom_count; i++) { in scarlett2_add_line_in_ctls()
3387 i, 1, s, &private->phantom_ctls[i]); in scarlett2_add_line_in_ctls()
3391 } else if (info->inputs_per_phantom > 1) { in scarlett2_add_line_in_ctls()
3392 for (i = 0; i < info->phantom_count; i++) { in scarlett2_add_line_in_ctls()
3393 int from = i * info->inputs_per_phantom + 1; in scarlett2_add_line_in_ctls()
3394 int to = (i + 1) * info->inputs_per_phantom; in scarlett2_add_line_in_ctls()
3400 i, 1, s, &private->phantom_ctls[i]); in scarlett2_add_line_in_ctls()
3405 if (info->phantom_count) { in scarlett2_add_line_in_ctls()
3421 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mixer_ctl_info()
3423 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_mixer_ctl_info()
3424 uinfo->count = elem->channels; in scarlett2_mixer_ctl_info()
3425 uinfo->value.integer.min = 0; in scarlett2_mixer_ctl_info()
3426 uinfo->value.integer.max = SCARLETT2_MIXER_MAX_VALUE; in scarlett2_mixer_ctl_info()
3427 uinfo->value.integer.step = 1; in scarlett2_mixer_ctl_info()
3434 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mixer_ctl_get()
3435 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_mixer_ctl_get()
3437 ucontrol->value.integer.value[0] = private->mix[elem->control]; in scarlett2_mixer_ctl_get()
3444 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mixer_ctl_put()
3445 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mixer_ctl_put()
3446 struct scarlett2_data *private = mixer->private_data; in scarlett2_mixer_ctl_put()
3447 const struct scarlett2_device_info *info = private->info; in scarlett2_mixer_ctl_put()
3448 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_mixer_ctl_put()
3450 int index = elem->control; in scarlett2_mixer_ctl_put()
3452 mutex_lock(&private->data_mutex); in scarlett2_mixer_ctl_put()
3454 oval = private->mix[index]; in scarlett2_mixer_ctl_put()
3455 val = clamp(ucontrol->value.integer.value[0], in scarlett2_mixer_ctl_put()
3463 private->mix[index] = val; in scarlett2_mixer_ctl_put()
3469 mutex_unlock(&private->data_mutex); in scarlett2_mixer_ctl_put()
3493 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_mixer_ctls()
3494 const struct scarlett2_device_info *info = private->info; in scarlett2_add_mixer_ctls()
3495 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_add_mixer_ctls()
3524 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mux_src_enum_ctl_info()
3525 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_mux_src_enum_ctl_info()
3526 const struct scarlett2_device_info *info = private->info; in scarlett2_mux_src_enum_ctl_info()
3527 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_mux_src_enum_ctl_info()
3528 unsigned int item = uinfo->value.enumerated.item; in scarlett2_mux_src_enum_ctl_info()
3529 int items = private->num_mux_srcs; in scarlett2_mux_src_enum_ctl_info()
3532 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in scarlett2_mux_src_enum_ctl_info()
3533 uinfo->count = elem->channels; in scarlett2_mux_src_enum_ctl_info()
3534 uinfo->value.enumerated.items = items; in scarlett2_mux_src_enum_ctl_info()
3537 item = uinfo->value.enumerated.item = items - 1; in scarlett2_mux_src_enum_ctl_info()
3546 sprintf(uinfo->value.enumerated.name, in scarlett2_mux_src_enum_ctl_info()
3547 port->src_descr, item + port->src_num_offset); in scarlett2_mux_src_enum_ctl_info()
3550 item -= port_count[port_type][SCARLETT2_PORT_IN]; in scarlett2_mux_src_enum_ctl_info()
3553 return -EINVAL; in scarlett2_mux_src_enum_ctl_info()
3559 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mux_src_enum_ctl_get()
3560 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mux_src_enum_ctl_get()
3561 struct scarlett2_data *private = mixer->private_data; in scarlett2_mux_src_enum_ctl_get()
3562 int index = line_out_remap(private, elem->control); in scarlett2_mux_src_enum_ctl_get()
3565 mutex_lock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_get()
3567 if (private->mux_updated) { in scarlett2_mux_src_enum_ctl_get()
3572 ucontrol->value.enumerated.item[0] = private->mux[index]; in scarlett2_mux_src_enum_ctl_get()
3575 mutex_unlock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_get()
3582 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_mux_src_enum_ctl_put()
3583 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_mux_src_enum_ctl_put()
3584 struct scarlett2_data *private = mixer->private_data; in scarlett2_mux_src_enum_ctl_put()
3585 int index = line_out_remap(private, elem->control); in scarlett2_mux_src_enum_ctl_put()
3588 mutex_lock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_put()
3590 oval = private->mux[index]; in scarlett2_mux_src_enum_ctl_put()
3591 val = min(ucontrol->value.enumerated.item[0], in scarlett2_mux_src_enum_ctl_put()
3592 private->num_mux_srcs - 1U); in scarlett2_mux_src_enum_ctl_put()
3597 private->mux[index] = val; in scarlett2_mux_src_enum_ctl_put()
3603 mutex_unlock(&private->data_mutex); in scarlett2_mux_src_enum_ctl_put()
3617 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_mux_enums()
3618 const struct scarlett2_device_info *info = private->info; in scarlett2_add_mux_enums()
3619 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_add_mux_enums()
3633 snprintf(s, sizeof(s) - 5, descr, channel + 1); in scarlett2_add_mux_enums()
3639 &private->mux_ctls[i]); in scarlett2_add_mux_enums()
3653 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_meter_ctl_info()
3655 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in scarlett2_meter_ctl_info()
3656 uinfo->count = elem->channels; in scarlett2_meter_ctl_info()
3657 uinfo->value.integer.min = 0; in scarlett2_meter_ctl_info()
3658 uinfo->value.integer.max = 4095; in scarlett2_meter_ctl_info()
3659 uinfo->value.integer.step = 1; in scarlett2_meter_ctl_info()
3666 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_meter_ctl_get()
3670 err = scarlett2_usb_get_meter_levels(elem->head.mixer, elem->channels, in scarlett2_meter_ctl_get()
3675 for (i = 0; i < elem->channels; i++) in scarlett2_meter_ctl_get()
3676 ucontrol->value.integer.value[i] = meter_levels[i]; in scarlett2_meter_ctl_get()
3691 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_meter_ctl()
3694 if (private->info->config_set == SCARLETT2_CONFIG_SET_NO_MIXER) in scarlett2_add_meter_ctl()
3698 0, private->num_mux_dsts, in scarlett2_add_meter_ctl()
3707 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_msd_ctl_get()
3708 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_msd_ctl_get()
3710 ucontrol->value.integer.value[0] = private->msd_switch; in scarlett2_msd_ctl_get()
3717 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_msd_ctl_put()
3718 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_msd_ctl_put()
3719 struct scarlett2_data *private = mixer->private_data; in scarlett2_msd_ctl_put()
3723 mutex_lock(&private->data_mutex); in scarlett2_msd_ctl_put()
3725 oval = private->msd_switch; in scarlett2_msd_ctl_put()
3726 val = !!ucontrol->value.integer.value[0]; in scarlett2_msd_ctl_put()
3731 private->msd_switch = val; in scarlett2_msd_ctl_put()
3740 mutex_unlock(&private->data_mutex); in scarlett2_msd_ctl_put()
3754 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_msd_ctl()
3755 const struct scarlett2_device_info *info = private->info; in scarlett2_add_msd_ctl()
3757 if (!info->has_msd_mode) in scarlett2_add_msd_ctl()
3761 if (!private->msd_switch && !(mixer->chip->setup & SCARLETT2_MSD_ENABLE)) in scarlett2_add_msd_ctl()
3774 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_standalone_ctl_get()
3775 struct scarlett2_data *private = elem->head.mixer->private_data; in scarlett2_standalone_ctl_get()
3777 ucontrol->value.integer.value[0] = private->standalone_switch; in scarlett2_standalone_ctl_get()
3784 struct usb_mixer_elem_info *elem = kctl->private_data; in scarlett2_standalone_ctl_put()
3785 struct usb_mixer_interface *mixer = elem->head.mixer; in scarlett2_standalone_ctl_put()
3786 struct scarlett2_data *private = mixer->private_data; in scarlett2_standalone_ctl_put()
3790 mutex_lock(&private->data_mutex); in scarlett2_standalone_ctl_put()
3792 oval = private->standalone_switch; in scarlett2_standalone_ctl_put()
3793 val = !!ucontrol->value.integer.value[0]; in scarlett2_standalone_ctl_put()
3798 private->standalone_switch = val; in scarlett2_standalone_ctl_put()
3808 mutex_unlock(&private->data_mutex); in scarlett2_standalone_ctl_put()
3822 struct scarlett2_data *private = mixer->private_data; in scarlett2_add_standalone_ctl()
3824 if (private->info->config_set == SCARLETT2_CONFIG_SET_NO_MIXER) in scarlett2_add_standalone_ctl()
3836 struct scarlett2_data *private = mixer->private_data; in scarlett2_private_free()
3838 cancel_delayed_work_sync(&private->work); in scarlett2_private_free()
3840 mixer->private_data = NULL; in scarlett2_private_free()
3845 struct scarlett2_data *private = mixer->private_data; in scarlett2_private_suspend()
3847 if (cancel_delayed_work_sync(&private->work)) in scarlett2_private_suspend()
3848 scarlett2_config_save(private->mixer); in scarlett2_private_suspend()
3855 const struct scarlett2_device_info *info = private->info; in scarlett2_count_mux_io()
3856 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_count_mux_io()
3866 private->num_mux_srcs = srcs; in scarlett2_count_mux_io()
3867 private->num_mux_dsts = dsts; in scarlett2_count_mux_io()
3878 struct usb_host_config *config = dev->actconfig; in scarlett2_find_fc_interface()
3881 for (i = 0; i < config->desc.bNumInterfaces; i++) { in scarlett2_find_fc_interface()
3882 struct usb_interface *intf = config->interface[i]; in scarlett2_find_fc_interface()
3884 &intf->altsetting[0].desc; in scarlett2_find_fc_interface()
3887 if (desc->bInterfaceClass != 255) in scarlett2_find_fc_interface()
3890 epd = get_endpoint(intf->altsetting, 0); in scarlett2_find_fc_interface()
3891 private->bInterfaceNumber = desc->bInterfaceNumber; in scarlett2_find_fc_interface()
3892 private->bEndpointAddress = epd->bEndpointAddress & in scarlett2_find_fc_interface()
3894 private->wMaxPacketSize = le16_to_cpu(epd->wMaxPacketSize); in scarlett2_find_fc_interface()
3895 private->bInterval = epd->bInterval; in scarlett2_find_fc_interface()
3899 return -EINVAL; in scarlett2_find_fc_interface()
3910 return -ENOMEM; in scarlett2_init_private()
3912 mutex_init(&private->usb_mutex); in scarlett2_init_private()
3913 mutex_init(&private->data_mutex); in scarlett2_init_private()
3914 INIT_DELAYED_WORK(&private->work, scarlett2_config_save_work); in scarlett2_init_private()
3916 mixer->private_data = private; in scarlett2_init_private()
3917 mixer->private_free = scarlett2_private_free; in scarlett2_init_private()
3918 mixer->private_suspend = scarlett2_private_suspend; in scarlett2_init_private()
3920 private->info = entry->info; in scarlett2_init_private()
3921 private->series_name = entry->series_name; in scarlett2_init_private()
3923 private->scarlett2_seq = 0; in scarlett2_init_private()
3924 private->mixer = mixer; in scarlett2_init_private()
3926 return scarlett2_find_fc_interface(mixer->chip->dev, private); in scarlett2_init_private()
3932 struct usb_device *dev = mixer->chip->dev; in scarlett2_usb_init()
3933 struct scarlett2_data *private = mixer->private_data; in scarlett2_usb_init()
3938 return -EINVAL; in scarlett2_usb_init()
3941 err = scarlett2_usb_rx(dev, private->bInterfaceNumber, in scarlett2_usb_init()
3947 private->scarlett2_seq = 1; in scarlett2_usb_init()
3953 private->scarlett2_seq = 1; in scarlett2_usb_init()
3960 struct scarlett2_data *private = mixer->private_data; in scarlett2_read_configs()
3961 const struct scarlett2_device_info *info = private->info; in scarlett2_read_configs()
3962 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_read_configs()
3970 if (info->has_msd_mode) { in scarlett2_read_configs()
3973 1, &private->msd_switch); in scarlett2_read_configs()
3978 if (private->msd_switch) in scarlett2_read_configs()
3991 if (info->config_set == SCARLETT2_CONFIG_SET_NO_MIXER) in scarlett2_read_configs()
3996 1, &private->standalone_switch); in scarlett2_read_configs()
4008 if (info->line_out_hw_vol) in scarlett2_read_configs()
4010 private->dim_mute[i] = !!volume_status.dim_mute[i]; in scarlett2_read_configs()
4012 private->master_vol = clamp( in scarlett2_read_configs()
4019 private->vol_sw_hw_switch[i] = in scarlett2_read_configs()
4020 info->line_out_hw_vol in scarlett2_read_configs()
4023 volume = private->vol_sw_hw_switch[i] in scarlett2_read_configs()
4028 private->vol[i] = volume; in scarlett2_read_configs()
4030 mute = private->vol_sw_hw_switch[i] in scarlett2_read_configs()
4031 ? private->dim_mute[SCARLETT2_BUTTON_MUTE] in scarlett2_read_configs()
4033 private->mute_switch[i] = mute; in scarlett2_read_configs()
4049 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_sync()
4051 private->sync_updated = 1; in scarlett2_notify_sync()
4053 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_sync()
4054 &private->sync_ctl->id); in scarlett2_notify_sync()
4061 struct snd_card *card = mixer->chip->card; in scarlett2_notify_monitor()
4062 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_monitor()
4063 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_monitor()
4064 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_notify_monitor()
4070 if (!info->line_out_hw_vol) in scarlett2_notify_monitor()
4073 private->vol_updated = 1; in scarlett2_notify_monitor()
4075 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in scarlett2_notify_monitor()
4076 &private->master_vol_ctl->id); in scarlett2_notify_monitor()
4079 if (private->vol_sw_hw_switch[line_out_remap(private, i)]) in scarlett2_notify_monitor()
4081 &private->vol_ctls[i]->id); in scarlett2_notify_monitor()
4088 struct snd_card *card = mixer->chip->card; in scarlett2_notify_dim_mute()
4089 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_dim_mute()
4090 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_dim_mute()
4091 const int (*port_count)[SCARLETT2_PORT_DIRNS] = info->port_count; in scarlett2_notify_dim_mute()
4096 private->vol_updated = 1; in scarlett2_notify_dim_mute()
4098 if (!info->line_out_hw_vol) in scarlett2_notify_dim_mute()
4103 &private->dim_mute_ctls[i]->id); in scarlett2_notify_dim_mute()
4106 if (private->vol_sw_hw_switch[line_out_remap(private, i)]) in scarlett2_notify_dim_mute()
4108 &private->mute_ctls[i]->id); in scarlett2_notify_dim_mute()
4115 struct snd_card *card = mixer->chip->card; in scarlett2_notify_input_other()
4116 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_input_other()
4117 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_input_other()
4120 private->input_other_updated = 1; in scarlett2_notify_input_other()
4122 for (i = 0; i < info->level_input_count; i++) in scarlett2_notify_input_other()
4124 &private->level_ctls[i]->id); in scarlett2_notify_input_other()
4125 for (i = 0; i < info->pad_input_count; i++) in scarlett2_notify_input_other()
4127 &private->pad_ctls[i]->id); in scarlett2_notify_input_other()
4128 for (i = 0; i < info->air_input_count; i++) in scarlett2_notify_input_other()
4130 &private->air_ctls[i]->id); in scarlett2_notify_input_other()
4131 for (i = 0; i < info->phantom_count; i++) in scarlett2_notify_input_other()
4133 &private->phantom_ctls[i]->id); in scarlett2_notify_input_other()
4142 struct snd_card *card = mixer->chip->card; in scarlett2_notify_monitor_other()
4143 struct scarlett2_data *private = mixer->private_data; in scarlett2_notify_monitor_other()
4144 const struct scarlett2_device_info *info = private->info; in scarlett2_notify_monitor_other()
4146 private->monitor_other_updated = 1; in scarlett2_notify_monitor_other()
4148 if (info->direct_monitor) { in scarlett2_notify_monitor_other()
4150 &private->direct_monitor_ctl->id); in scarlett2_notify_monitor_other()
4154 if (info->has_speaker_switching) in scarlett2_notify_monitor_other()
4156 &private->speaker_switching_ctl->id); in scarlett2_notify_monitor_other()
4158 if (info->has_talkback) in scarlett2_notify_monitor_other()
4160 &private->talkback_ctl->id); in scarlett2_notify_monitor_other()
4162 /* if speaker switching was recently enabled or disabled, in scarlett2_notify_monitor_other()
4165 if (private->speaker_switching_switched) { in scarlett2_notify_monitor_other()
4170 private->speaker_switching_switched = 0; in scarlett2_notify_monitor_other()
4171 private->mux_updated = 1; in scarlett2_notify_monitor_other()
4173 for (i = 0; i < private->num_mux_dsts; i++) in scarlett2_notify_monitor_other()
4175 &private->mux_ctls[i]->id); in scarlett2_notify_monitor_other()
4182 struct usb_mixer_interface *mixer = urb->context; in scarlett2_notify()
4183 int len = urb->actual_length; in scarlett2_notify()
4184 int ustatus = urb->status; in scarlett2_notify()
4190 data = le32_to_cpu(*(__le32 *)urb->transfer_buffer); in scarlett2_notify()
4203 if (ustatus != -ENOENT && in scarlett2_notify()
4204 ustatus != -ECONNRESET && in scarlett2_notify()
4205 ustatus != -ESHUTDOWN) { in scarlett2_notify()
4206 urb->dev = mixer->chip->dev; in scarlett2_notify()
4213 struct usb_device *dev = mixer->chip->dev; in scarlett2_init_notify()
4214 struct scarlett2_data *private = mixer->private_data; in scarlett2_init_notify()
4215 unsigned int pipe = usb_rcvintpipe(dev, private->bEndpointAddress); in scarlett2_init_notify()
4218 if (mixer->urb) { in scarlett2_init_notify()
4219 usb_audio_err(mixer->chip, in scarlett2_init_notify()
4225 return -EINVAL; in scarlett2_init_notify()
4227 mixer->urb = usb_alloc_urb(0, GFP_KERNEL); in scarlett2_init_notify()
4228 if (!mixer->urb) in scarlett2_init_notify()
4229 return -ENOMEM; in scarlett2_init_notify()
4231 transfer_buffer = kmalloc(private->wMaxPacketSize, GFP_KERNEL); in scarlett2_init_notify()
4233 return -ENOMEM; in scarlett2_init_notify()
4235 usb_fill_int_urb(mixer->urb, dev, pipe, in scarlett2_init_notify()
4236 transfer_buffer, private->wMaxPacketSize, in scarlett2_init_notify()
4237 scarlett2_notify, mixer, private->bInterval); in scarlett2_init_notify()
4239 return usb_submit_urb(mixer->urb, GFP_KERNEL); in scarlett2_init_notify()
4248 while (entry->usb_id && entry->usb_id != mixer->chip->usb_id) in get_scarlett2_device_entry()
4250 if (!entry->usb_id) in get_scarlett2_device_entry()
4283 if (((struct scarlett2_data *)mixer->private_data)->msd_switch) in snd_scarlett2_controls_create()
4346 struct snd_usb_audio *chip = mixer->chip; in snd_scarlett2_init()
4351 if (!mixer->protocol) in snd_scarlett2_init()
4357 usb_audio_err(mixer->chip, in snd_scarlett2_init()
4360 USB_ID_VENDOR(chip->usb_id), in snd_scarlett2_init()
4361 USB_ID_PRODUCT(chip->usb_id)); in snd_scarlett2_init()
4365 if (chip->setup & SCARLETT2_DISABLE) { in snd_scarlett2_init()
4367 "Focusrite %s Mixer Driver disabled " in snd_scarlett2_init()
4370 entry->series_name, in snd_scarlett2_init()
4371 USB_ID_VENDOR(chip->usb_id), in snd_scarlett2_init()
4372 USB_ID_PRODUCT(chip->usb_id), in snd_scarlett2_init()
4380 entry->series_name, in snd_scarlett2_init()
4381 USB_ID_PRODUCT(chip->usb_id)); in snd_scarlett2_init()
4385 usb_audio_err(mixer->chip, in snd_scarlett2_init()
4387 entry->series_name, in snd_scarlett2_init()