sound/soc/codecs/rt711.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt711.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt711.c- Extension
.c- Size
- 35808 bytes
- Lines
- 1336
- 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/pm.hlinux/soundwire/sdw.hlinux/regmap.hlinux/slab.hsound/core.hsound/pcm.hsound/pcm_params.hsound/sdw.hsound/soc.hsound/soc-dapm.hsound/initval.hsound/tlv.hsound/hda_verbs.hsound/jack.hrt711.h
Detected Declarations
function rt711_index_writefunction rt711_index_readfunction rt711_index_update_bitsfunction rt711_resetfunction rt711_calibrationfunction rt711_button_detectfunction rt711_headset_detectfunction rt711_jack_detect_handlerfunction rt711_btn_check_handlerfunction rt711_jack_initfunction rt711_set_jack_detectfunction rt711_get_gainfunction rt711_set_amp_gain_putfunction rt711_set_amp_gain_getfunction rt711_mux_getfunction rt711_mux_putfunction rt711_dac_surround_eventfunction rt711_adc_09_eventfunction rt711_adc_08_eventfunction rt711_set_bias_levelfunction rt711_parse_dtfunction rt711_probefunction rt711_set_sdw_streamfunction rt711_shutdownfunction rt711_pcm_hw_paramsfunction rt711_pcm_hw_freefunction rt711_clock_configfunction rt711_calibration_workfunction rt711_initfunction rt711_io_init
Annotated Snippet
if (loop >= 500) {
pr_err("%s, calibration time-out!\n",
__func__);
ret = -ETIMEDOUT;
break;
}
loop++;
usleep_range(10000, 11000);
rt711_index_read(regmap, RT711_VENDOR_CALI,
RT711_DAC_DC_CALI_CTL1, &val);
}
/* depop mode */
rt711_index_update_bits(regmap, RT711_VENDOR_REG,
RT711_FSM_CTL, 0xf, RT711_DEPOP_CTL);
regmap_write(rt711->regmap,
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
mutex_unlock(&rt711->calibrate_mutex);
dev_dbg(dev, "%s calibration complete, ret=%d\n", __func__, ret);
return ret;
}
static unsigned int rt711_button_detect(struct rt711_priv *rt711)
{
unsigned int btn_type = 0, val80, val81;
int ret;
ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG,
RT711_IRQ_FLAG_TABLE1, &val80);
if (ret < 0)
goto read_error;
ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG,
RT711_IRQ_FLAG_TABLE2, &val81);
if (ret < 0)
goto read_error;
val80 &= 0x0381;
val81 &= 0xff00;
switch (val80) {
case 0x0200:
case 0x0100:
case 0x0080:
btn_type |= SND_JACK_BTN_0;
break;
case 0x0001:
btn_type |= SND_JACK_BTN_3;
break;
}
switch (val81) {
case 0x8000:
case 0x4000:
case 0x2000:
btn_type |= SND_JACK_BTN_1;
break;
case 0x1000:
case 0x0800:
case 0x0400:
btn_type |= SND_JACK_BTN_2;
break;
case 0x0200:
case 0x0100:
btn_type |= SND_JACK_BTN_3;
break;
}
read_error:
return btn_type;
}
static int rt711_headset_detect(struct rt711_priv *rt711)
{
unsigned int buf, loop = 0;
int ret;
unsigned int jack_status = 0, reg;
ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG,
RT711_COMBO_JACK_AUTO_CTL2, &buf);
if (ret < 0)
goto io_error;
while (loop < 500 &&
(buf & RT711_COMBOJACK_AUTO_DET_STATUS) == 0) {
loop++;
usleep_range(9000, 10000);
ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG,
RT711_COMBO_JACK_AUTO_CTL2, &buf);
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/init.h`, `linux/delay.h`, `linux/pm_runtime.h`, `linux/pm.h`, `linux/soundwire/sdw.h`.
- Detected declarations: `function rt711_index_write`, `function rt711_index_read`, `function rt711_index_update_bits`, `function rt711_reset`, `function rt711_calibration`, `function rt711_button_detect`, `function rt711_headset_detect`, `function rt711_jack_detect_handler`, `function rt711_btn_check_handler`, `function rt711_jack_init`.
- 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.