sound/soc/codecs/wcd-common.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/wcd-common.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/wcd-common.c- Extension
.c- Size
- 3846 bytes
- Lines
- 145
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/module.hlinux/init.hlinux/device.hlinux/of.hlinux/printk.hlinux/component.hlinux/pm_runtime.hlinux/soundwire/sdw.hlinux/soundwire/sdw_type.hlinux/regmap.hwcd-common.h
Detected Declarations
function wcd_get_micb_vout_ctl_valfunction wcd_get_micbias_valfunction wcd_dt_parse_micbias_infofunction wcd_sdw_component_bindfunction wcd_sdw_component_unbindfunction wcd_update_statusfunction wcd_bus_configfunction wcd_interrupt_callbackexport wcd_get_micb_vout_ctl_valexport wcd_dt_parse_micbias_infoexport wcd_sdw_component_opsexport wcd_update_statusexport wcd_bus_configexport wcd_interrupt_callback
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2025, Qualcomm Technologies, Inc. and/or its subsidiaries.
#include <linux/export.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/of.h>
#include <linux/printk.h>
#include <linux/component.h>
#include <linux/pm_runtime.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_type.h>
#include <linux/regmap.h>
#include "wcd-common.h"
#define WCD_MIN_MICBIAS_MV 1000
#define WCD_DEF_MICBIAS_MV 1800
#define WCD_MAX_MICBIAS_MV 2850
#define SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(m) (0xE0 + 0x10 * (m))
int wcd_get_micb_vout_ctl_val(struct device *dev, u32 micb_mv)
{
/* min micbias voltage is 1V and maximum is 2.85V */
if (micb_mv < WCD_MIN_MICBIAS_MV || micb_mv > WCD_MAX_MICBIAS_MV) {
dev_err(dev, "Unsupported micbias voltage (%u mV)\n", micb_mv);
return -EINVAL;
}
return (micb_mv - WCD_MIN_MICBIAS_MV) / 50;
}
EXPORT_SYMBOL_GPL(wcd_get_micb_vout_ctl_val);
static int wcd_get_micbias_val(struct device *dev, int micb_num, u32 *micb_mv)
{
char micbias[64];
int mv;
sprintf(micbias, "qcom,micbias%d-microvolt", micb_num);
if (of_property_read_u32(dev->of_node, micbias, &mv)) {
dev_err(dev, "%s value not found, using default\n", micbias);
mv = WCD_DEF_MICBIAS_MV;
} else {
/* convert it to milli volts */
mv = mv/1000;
}
if (micb_mv)
*micb_mv = mv;
mv = wcd_get_micb_vout_ctl_val(dev, mv);
if (mv < 0) {
dev_err(dev, "Unsupported %s voltage (%d mV), falling back to default (%d mV)\n",
micbias, mv, WCD_DEF_MICBIAS_MV);
return wcd_get_micb_vout_ctl_val(dev, WCD_DEF_MICBIAS_MV);
}
return mv;
}
int wcd_dt_parse_micbias_info(struct wcd_common *common)
{
int ret, i;
for (i = 0; i < common->max_bias; i++) {
ret = wcd_get_micbias_val(common->dev, i + 1, &common->micb_mv[i]);
if (ret < 0)
return ret;
common->micb_vout[i] = ret;
}
return 0;
}
EXPORT_SYMBOL_GPL(wcd_dt_parse_micbias_info);
static int wcd_sdw_component_bind(struct device *dev, struct device *master, void *data)
{
pm_runtime_set_autosuspend_delay(dev, 3000);
pm_runtime_use_autosuspend(dev);
pm_runtime_mark_last_busy(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
return 0;
}
static void wcd_sdw_component_unbind(struct device *dev, struct device *master, void *data)
{
Annotation
- Immediate include surface: `linux/export.h`, `linux/module.h`, `linux/init.h`, `linux/device.h`, `linux/of.h`, `linux/printk.h`, `linux/component.h`, `linux/pm_runtime.h`.
- Detected declarations: `function wcd_get_micb_vout_ctl_val`, `function wcd_get_micbias_val`, `function wcd_dt_parse_micbias_info`, `function wcd_sdw_component_bind`, `function wcd_sdw_component_unbind`, `function wcd_update_status`, `function wcd_bus_config`, `function wcd_interrupt_callback`, `export wcd_get_micb_vout_ctl_val`, `export wcd_dt_parse_micbias_info`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration implementation candidate.
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.