sound/usb/mixer_scarlett2.c
Source file repositories/reference/linux-study-clean/sound/usb/mixer_scarlett2.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/mixer_scarlett2.c- Extension
.c- Size
- 271924 bytes
- Lines
- 9884
- Domain
- Driver Families
- Bucket
- sound/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/usb.hlinux/moduleparam.hsound/control.hsound/tlv.hsound/hwdep.huapi/sound/scarlett2.husbaudio.hmixer.hhelper.hmixer_scarlett2.hfcp.h
Detected Declarations
struct compressor_paramstruct scarlett2_notificationstruct scarlett2_configstruct scarlett2_config_setstruct scarlett2_config_set_entrystruct scarlett2_portstruct scarlett2_mux_entrystruct scarlett2_meter_entrystruct scarlett2_device_infostruct scarlett2_datastruct scarlett2_device_entrystruct scarlett2_usb_packetfunction scarlett2_get_port_start_numfunction scarlett2_fill_request_headerfunction scarlett2_usb_txfunction scarlett2_usb_rxfunction scarlett2_usbfunction scarlett2_usb_getfunction scarlett2_has_config_itemfunction scarlett2_usb_get_configfunction scarlett2_usb_set_datafunction scarlett2_usb_set_data_buffunction scarlett2_usb_activate_configfunction scarlett2_usb_set_configfunction scarlett2_usb_set_config_buffunction scarlett2_config_savefunction scarlett2_config_save_workfunction scarlett2_usb_get_sync_statusfunction scarlett2_has_mixerfunction scarlett2_mixer_value_to_dbfunction scarlett2_usb_get_mixfunction scarlett2_usb_set_mixfunction scarlett2_mux_src_num_to_idfunction scarlett2_mux_id_to_numfunction scarlett2_usb_populate_muxfunction scarlett2_update_meter_level_mapfunction scarlett2_usb_get_muxfunction scarlett2_usb_set_muxfunction scarlett2_usb_get_meter_levelsfunction scarlett2_decode_muteablefunction scarlett2_add_new_ctlfunction scarlett2_firmware_version_ctl_getfunction scarlett2_firmware_version_ctl_infofunction scarlett2_add_firmware_version_ctlfunction scarlett2_min_firmware_version_ctl_getfunction scarlett2_min_firmware_version_ctl_infofunction scarlett2_add_min_firmware_version_ctlfunction scarlett2_update_sync
Annotated Snippet
struct compressor_param {
const char *name;
snd_ctl_elem_type_t type;
s32 min;
s32 max;
int scale_bits;
};
/* The available compressor parameters on the Vocaster:
* - Enable: Off, On
* - Threshold: -40dB to 0dB
* - Ratio: 1:1 to 50:1 in 0.5:1 steps
* - Knee Width: 0dB to 10dB
* - Attack: 30ms to 127ms
* - Release: 30ms to 127ms
* - Makeup Gain: 0dB to 24dB
*/
static const struct compressor_param compressor_params[] = {
{ "Enable", SNDRV_CTL_ELEM_TYPE_BOOLEAN, 0, 1, 0 },
{ "Threshold", SNDRV_CTL_ELEM_TYPE_INTEGER, -40, 0, 24 },
{ "Ratio", SNDRV_CTL_ELEM_TYPE_INTEGER, 2, 100, 23 },
{ "Knee Width", SNDRV_CTL_ELEM_TYPE_INTEGER, 0, 10, 24 },
{ "Attack", SNDRV_CTL_ELEM_TYPE_INTEGER, 30, 127, 24 },
{ "Release", SNDRV_CTL_ELEM_TYPE_INTEGER, 30, 127, 24 },
{ "Makeup Gain", SNDRV_CTL_ELEM_TYPE_INTEGER, 0, 24, 24 },
};
#define SCARLETT2_COMPRESSOR_PARAM_COUNT ARRAY_SIZE(compressor_params)
#define SCARLETT2_COMPRESSOR_CTLS_MAX \
(SCARLETT2_COMPRESSOR_PARAM_COUNT * SCARLETT2_DSP_SWITCH_MAX)
/* Maximum number of filter controls */
#define SCARLETT2_PRECOMP_FLT_CTLS_MAX (2 * SCARLETT2_DSP_SWITCH_MAX)
#define SCARLETT2_PEQ_FLT_CTLS_MAX (3 * SCARLETT2_DSP_SWITCH_MAX)
/* Number of biquad filter coefficients */
#define SCARLETT2_BIQUAD_COEFFS 5
/* Maximum number of filter coefficient values */
#define SCARLETT2_PRECOMP_FLT_VALUES_MAX \
(SCARLETT2_PRECOMP_FLT_CTLS_MAX * SCARLETT2_BIQUAD_COEFFS)
#define SCARLETT2_PEQ_FLT_VALUES_MAX \
(SCARLETT2_PEQ_FLT_CTLS_MAX * SCARLETT2_BIQUAD_COEFFS)
/* Maximum number of PEQ filter slots */
#define SCARLETT2_PEQ_FLT_SLOTS_MAX 4
/* Hardware port types:
* - None (no input to mux)
* - Analogue I/O
* - S/PDIF I/O
* - ADAT I/O
* - Mixer I/O
* - PCM I/O
*/
enum {
SCARLETT2_PORT_TYPE_NONE,
SCARLETT2_PORT_TYPE_ANALOGUE,
SCARLETT2_PORT_TYPE_SPDIF,
SCARLETT2_PORT_TYPE_ADAT,
SCARLETT2_PORT_TYPE_MIX,
SCARLETT2_PORT_TYPE_PCM,
SCARLETT2_PORT_TYPE_COUNT
};
/* I/O count of each port type kept in struct scarlett2_ports */
enum {
SCARLETT2_PORT_IN,
SCARLETT2_PORT_OUT,
SCARLETT2_PORT_DIRNS
};
/* Dim/Mute buttons on the 18i20 */
enum {
SCARLETT2_BUTTON_MUTE,
SCARLETT2_BUTTON_DIM,
SCARLETT2_DIM_MUTE_COUNT
};
/* Autogain target values */
#define SCARLETT2_AG_TARGET_MIN (-30)
enum {
SCARLETT2_AG_HOT_TARGET,
SCARLETT2_AG_MEAN_TARGET,
SCARLETT2_AG_PEAK_TARGET,
SCARLETT2_AG_TARGET_COUNT
};
Annotation
- Immediate include surface: `linux/slab.h`, `linux/usb.h`, `linux/moduleparam.h`, `sound/control.h`, `sound/tlv.h`, `sound/hwdep.h`, `uapi/sound/scarlett2.h`, `usbaudio.h`.
- Detected declarations: `struct compressor_param`, `struct scarlett2_notification`, `struct scarlett2_config`, `struct scarlett2_config_set`, `struct scarlett2_config_set_entry`, `struct scarlett2_port`, `struct scarlett2_mux_entry`, `struct scarlett2_meter_entry`, `struct scarlett2_device_info`, `struct scarlett2_data`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.