sound/soc/codecs/pcm6240.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/pcm6240.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/pcm6240.c- Extension
.c- Size
- 51735 bytes
- Lines
- 2161
- 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/unaligned.hlinux/firmware.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/of_irq.hlinux/of_address.hlinux/regmap.hsound/pcm_params.hsound/soc.hsound/tlv.hpcm6240.h
Detected Declarations
function pcmdev_change_devfunction pcmdev_dev_readfunction pcmdev_dev_update_bitsfunction pcmdev_get_volswfunction pcmdevice_get_volswfunction pcm1690_get_volswfunction pcm1690_get_finevolswfunction pcmdev_put_volswfunction pcmdevice_put_volswfunction pcm1690_put_volswfunction pcm1690_put_finevolswfunction pcmdev_dev_bulk_writefunction pcmdev_dev_writefunction pcmdevice_info_profilefunction pcmdevice_get_profile_idfunction pcmdevice_set_profile_idfunction pcmdevice_info_volswfunction pcm9211_sw_rstfunction pcmdevice_sw_rstfunction pcmdev_gain_ctrl_addfunction pcmdev_profile_ctrl_addfunction pcmdevice_config_info_removefunction pcmdev_regbin_readyfunction pcmdevice_comp_probefunction pcmdevice_comp_removefunction pcmdev_single_byte_wrfunction pcmdev_burst_wrfunction pcmdev_delayfunction pcmdev_bits_wrfunction pcmdevice_process_blockfunction pcmdevice_select_cfg_blkfunction pcmdevice_mutefunction pcmdevice_hw_paramsfunction pcmdevice_removefunction pcmdevice_i2c_probefunction pcmdevice_i2c_remove
Annotated Snippet
if (ret) {
dev_err(pcm_dev->dev, "%s: read mode err=%d\n",
__func__, ret);
goto out;
}
val &= PCM1690_REG_MODE_CTRL_DAMS_MSK;
/* Set to wide-range mode, before using vol ctrl. */
if (!val && vol_ctrl_type == PCMDEV_PCM1690_VOL_CTRL) {
ucontrol->value.integer.value[0] = -25500;
goto out;
}
/* Set to fine mode, before using fine vol ctrl. */
if (val && vol_ctrl_type == PCMDEV_PCM1690_FINE_VOL_CTRL) {
ucontrol->value.integer.value[0] = -12750;
goto out;
}
}
ret = pcmdev_dev_read(pcm_dev, dev_no, reg, &val);
if (ret) {
dev_err(pcm_dev->dev, "%s: read err=%d\n",
__func__, ret);
goto out;
}
val = (val >> shift) & mask;
val = (val > max) ? max : val;
val = mc->invert ? max - val : val;
ucontrol->value.integer.value[0] = val;
out:
mutex_unlock(&pcm_dev->codec_lock);
return ret;
}
static int pcmdevice_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return pcmdev_get_volsw(kcontrol, ucontrol, PCMDEV_GENERIC_VOL_CTRL);
}
static int pcm1690_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return pcmdev_get_volsw(kcontrol, ucontrol, PCMDEV_PCM1690_VOL_CTRL);
}
static int pcm1690_get_finevolsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return pcmdev_get_volsw(kcontrol, ucontrol,
PCMDEV_PCM1690_FINE_VOL_CTRL);
}
static int pcmdev_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol, int vol_ctrl_type)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct pcmdevice_priv *pcm_dev =
snd_soc_component_get_drvdata(component);
struct pcmdevice_mixer_control *mc =
(struct pcmdevice_mixer_control *)kcontrol->private_value;
int max = mc->max, rc;
unsigned int mask = BIT(fls(max)) - 1;
unsigned int dev_no = mc->dev_no;
unsigned int shift = mc->shift;
unsigned int val, val_mask;
unsigned int reg = mc->reg;
mutex_lock(&pcm_dev->codec_lock);
val = ucontrol->value.integer.value[0] & mask;
val = (val > max) ? max : val;
val = mc->invert ? max - val : val;
val_mask = mask << shift;
val = val << shift;
switch (vol_ctrl_type) {
case PCMDEV_PCM1690_VOL_CTRL:
val_mask |= PCM1690_REG_MODE_CTRL_DAMS_MSK;
val |= PCM1690_REG_MODE_CTRL_DAMS_WIDE_RANGE;
break;
case PCMDEV_PCM1690_FINE_VOL_CTRL:
val_mask |= PCM1690_REG_MODE_CTRL_DAMS_MSK;
val |= PCM1690_REG_MODE_CTRL_DAMS_FINE_STEP;
break;
}
rc = pcmdev_dev_update_bits(pcm_dev, dev_no, reg, val_mask, val);
if (rc < 0)
dev_err(pcm_dev->dev, "%s: update_bits err = %d\n",
__func__, rc);
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/firmware.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/of_irq.h`, `linux/of_address.h`, `linux/regmap.h`.
- Detected declarations: `function pcmdev_change_dev`, `function pcmdev_dev_read`, `function pcmdev_dev_update_bits`, `function pcmdev_get_volsw`, `function pcmdevice_get_volsw`, `function pcm1690_get_volsw`, `function pcm1690_get_finevolsw`, `function pcmdev_put_volsw`, `function pcmdevice_put_volsw`, `function pcm1690_put_volsw`.
- 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.