sound/soc/codecs/rt711-sdca.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt711-sdca.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt711-sdca.c- Extension
.c- Size
- 47860 bytes
- Lines
- 1670
- Domain
- Driver Families
- Bucket
- sound/soc
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/moduleparam.hlinux/kernel.hlinux/init.hlinux/delay.hlinux/pm_runtime.hlinux/soundwire/sdw_registers.hlinux/slab.hlinux/bitops.hsound/core.hsound/pcm.hsound/pcm_params.hsound/sdw.hsound/soc-dapm.hsound/initval.hsound/tlv.hsound/jack.hrt711-sdca.h
Detected Declarations
function rt711_sdca_index_writefunction rt711_sdca_index_readfunction rt711_sdca_index_update_bitsfunction rt711_sdca_resetfunction rt711_sdca_ge_force_jack_typefunction rt711_sdca_calibrationfunction rt711_sdca_button_detectfunction rt711_sdca_headset_detectfunction rt711_sdca_jack_detect_handlerfunction rt711_sdca_btn_check_handlerfunction rt711_sdca_jack_initfunction rt711_sdca_set_jack_detectfunction rt711_sdca_set_gain_putfunction rt711_sdca_set_gain_getfunction rt711_sdca_set_fu0f_capture_ctlfunction rt711_sdca_set_fu1e_capture_ctlfunction rt711_sdca_fu1e_capture_getfunction rt711_sdca_fu1e_capture_putfunction rt711_sdca_fu0f_capture_getfunction rt711_sdca_fu0f_capture_putfunction rt711_sdca_ge_select_getfunction rt711_sdca_ge_select_putfunction rt711_sdca_mux_getfunction rt711_sdca_mux_putfunction rt711_sdca_fu05_eventfunction rt711_sdca_fu0f_eventfunction rt711_sdca_fu1e_eventfunction rt711_sdca_pde28_eventfunction rt711_sdca_pde29_eventfunction rt711_sdca_pde2a_eventfunction rt711_sdca_line1_power_eventfunction rt711_sdca_line2_power_eventfunction rt711_sdca_parse_dtfunction rt711_sdca_probefunction rt711_sdca_set_sdw_streamfunction rt711_sdca_shutdownfunction rt711_sdca_pcm_hw_paramsfunction rt711_sdca_pcm_hw_freefunction rt711_sdca_initfunction rt711_sdca_vd0_io_initfunction rt711_sdca_vd1_io_initfunction rt711_sdca_io_init
Annotated Snippet
switch (buf[1] & 0xf0) {
case 0x10:
btn_type |= SND_JACK_BTN_2;
break;
case 0x20:
btn_type |= SND_JACK_BTN_3;
break;
case 0x40:
btn_type |= SND_JACK_BTN_0;
break;
case 0x80:
btn_type |= SND_JACK_BTN_1;
break;
}
switch (buf[2]) {
case 0x01:
case 0x10:
btn_type |= SND_JACK_BTN_2;
break;
case 0x02:
case 0x20:
btn_type |= SND_JACK_BTN_3;
break;
case 0x04:
case 0x40:
btn_type |= SND_JACK_BTN_0;
break;
case 0x08:
case 0x80:
btn_type |= SND_JACK_BTN_1;
break;
}
}
_end_btn_det_:
/* Host is owner, so set back to device */
if (owner == 0)
/* set owner to device */
regmap_write(rt711->regmap,
SDW_SDCA_CTL(FUNC_NUM_HID, RT711_SDCA_ENT_HID01,
RT711_SDCA_CTL_HIDTX_SET_OWNER_TO_DEVICE, 0), 0x01);
return btn_type;
}
static int rt711_sdca_headset_detect(struct rt711_sdca_priv *rt711)
{
unsigned int det_mode;
int ret;
rt711_sdca_ge_force_jack_type(rt711, rt711->ge_mode_override);
/* get detected_mode */
ret = regmap_read(rt711->regmap,
SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT711_SDCA_ENT_GE49, RT711_SDCA_CTL_DETECTED_MODE, 0),
&det_mode);
if (ret < 0)
goto io_error;
switch (det_mode) {
case 0x00:
rt711->jack_type = 0;
break;
case 0x03:
rt711->jack_type = SND_JACK_HEADPHONE;
break;
case 0x05:
rt711->jack_type = SND_JACK_HEADSET;
break;
}
/* write selected_mode */
if (det_mode) {
ret = regmap_write(rt711->regmap,
SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT711_SDCA_ENT_GE49, RT711_SDCA_CTL_SELECTED_MODE, 0),
det_mode);
if (ret < 0)
goto io_error;
}
dev_dbg(&rt711->slave->dev,
"%s, detected_mode=0x%x\n", __func__, det_mode);
return 0;
io_error:
pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret);
return ret;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/init.h`, `linux/delay.h`, `linux/pm_runtime.h`, `linux/soundwire/sdw_registers.h`, `linux/slab.h`.
- Detected declarations: `function rt711_sdca_index_write`, `function rt711_sdca_index_read`, `function rt711_sdca_index_update_bits`, `function rt711_sdca_reset`, `function rt711_sdca_ge_force_jack_type`, `function rt711_sdca_calibration`, `function rt711_sdca_button_detect`, `function rt711_sdca_headset_detect`, `function rt711_sdca_jack_detect_handler`, `function rt711_sdca_btn_check_handler`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.