sound/soc/codecs/rt712-sdca.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt712-sdca.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt712-sdca.c- Extension
.c- Size
- 57595 bytes
- Lines
- 1927
- 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/bitops.hsound/core.hlinux/delay.hlinux/init.hsound/initval.hsound/jack.hlinux/kernel.hlinux/module.hlinux/moduleparam.hlinux/pm_runtime.hsound/pcm.hsound/pcm_params.hsound/sdca.hlinux/soundwire/sdw_registers.hlinux/slab.hsound/soc-dapm.hsound/tlv.hrt712-sdca.h
Detected Declarations
function rt712_sdca_index_writefunction rt712_sdca_index_readfunction rt712_sdca_index_update_bitsfunction rt712_sdca_calibrationfunction rt712_sdca_button_detectfunction rt712_sdca_headset_detectfunction rt712_sdca_jack_detect_handlerfunction rt712_sdca_btn_check_handlerfunction rt712_sdca_jack_initfunction rt712_sdca_set_jack_detectfunction rt712_sdca_set_gain_putfunction rt712_sdca_set_gain_getfunction rt712_sdca_set_fu0f_capture_ctlfunction rt712_sdca_fu0f_capture_getfunction rt712_sdca_fu0f_capture_putfunction rt712_sdca_set_fu05_playback_ctlfunction rt712_sdca_fu05_playback_getfunction rt712_sdca_fu05_playback_putfunction rt712_sdca_mux_getfunction rt712_sdca_mux_putfunction rt712_sdca_fu05_eventfunction rt712_sdca_fu0f_eventfunction rt712_sdca_pde40_eventfunction rt712_sdca_pde12_eventfunction rt712_sdca_pde23_eventfunction rt712_sdca_parse_dtfunction rt712_sdca_probefunction rt712_sdca_dmic_set_gain_getfunction rt712_sdca_dmic_set_gain_putfunction rt712_sdca_set_fu1e_capture_ctlfunction rt712_sdca_dmic_fu1e_capture_getfunction rt712_sdca_dmic_fu1e_capture_putfunction rt712_sdca_fu_infofunction rt712_sdca_dmic_mux_getfunction rt712_sdca_dmic_mux_putfunction rt712_sdca_dmic_fu1e_eventfunction rt712_sdca_dmic_pde11_eventfunction rt712_sdca_dmic_probefunction rt712_sdca_set_sdw_streamfunction rt712_sdca_shutdownfunction rt712_sdca_pcm_hw_paramsfunction rt712_sdca_pcm_hw_freefunction rt712_sdca_initfunction rt712_sdca_va_io_initfunction rt712_sdca_vb_io_initfunction rt712_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 */
if (rt712->version_id == RT712_VA)
regmap_write(rt712->regmap,
SDW_SDCA_CTL(FUNC_NUM_HID, RT712_SDCA_ENT_HID01,
RT712_SDCA_CTL_HIDTX_SET_OWNER_TO_DEVICE, 0), 0x01);
else
regmap_write(rt712->regmap,
SDW_SDCA_CTL(FUNC_NUM_HID, RT712_SDCA_ENT_HID01,
RT712_SDCA_CTL_HIDTX_CURRENT_OWNER, 0), 0x01);
}
return btn_type;
}
static int rt712_sdca_headset_detect(struct rt712_sdca_priv *rt712)
{
unsigned int det_mode;
int ret;
/* get detected_mode */
ret = regmap_read(rt712->regmap,
SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_GE49, RT712_SDCA_CTL_DETECTED_MODE, 0),
&det_mode);
if (ret < 0)
goto io_error;
switch (det_mode) {
case 0x00:
rt712->jack_type = 0;
break;
case 0x03:
rt712->jack_type = SND_JACK_HEADPHONE;
break;
case 0x05:
rt712->jack_type = SND_JACK_HEADSET;
break;
}
/* write selected_mode */
if (det_mode) {
ret = regmap_write(rt712->regmap,
SDW_SDCA_CTL(FUNC_NUM_JACK_CODEC, RT712_SDCA_ENT_GE49, RT712_SDCA_CTL_SELECTED_MODE, 0),
det_mode);
if (ret < 0)
goto io_error;
}
dev_dbg(&rt712->slave->dev,
"%s, detected_mode=0x%x\n", __func__, det_mode);
return 0;
io_error:
Annotation
- Immediate include surface: `linux/bitops.h`, `sound/core.h`, `linux/delay.h`, `linux/init.h`, `sound/initval.h`, `sound/jack.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `function rt712_sdca_index_write`, `function rt712_sdca_index_read`, `function rt712_sdca_index_update_bits`, `function rt712_sdca_calibration`, `function rt712_sdca_button_detect`, `function rt712_sdca_headset_detect`, `function rt712_sdca_jack_detect_handler`, `function rt712_sdca_btn_check_handler`, `function rt712_sdca_jack_init`, `function rt712_sdca_set_jack_detect`.
- 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.