sound/soc/codecs/rt-sdw-common.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt-sdw-common.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt-sdw-common.c- Extension
.c- Size
- 5628 bytes
- Lines
- 239
- 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/module.hlinux/regmap.hlinux/bitops.hlinux/soundwire/sdw_registers.hsound/jack.hrt-sdw-common.h
Detected Declarations
function rt_sdca_index_writefunction rt_sdca_index_readfunction rt_sdca_index_update_bitsfunction rt_sdca_btn_typefunction rt_sdca_headset_detectfunction rt_sdca_button_detectexport rt_sdca_index_writeexport rt_sdca_index_readexport rt_sdca_index_update_bitsexport rt_sdca_btn_typeexport rt_sdca_headset_detectexport rt_sdca_button_detect
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
//
// rt-sdw-common.c
//
// Copyright(c) 2024 Realtek Semiconductor Corp.
//
/*
* This file defines common functions used with Realtek soundwire codecs.
*/
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/bitops.h>
#include <linux/soundwire/sdw_registers.h>
#include <sound/jack.h>
#include "rt-sdw-common.h"
/**
* rt_sdca_index_write - Write a value to Realtek defined register.
*
* @map: map for setting.
* @nid: Realtek-defined ID.
* @reg: register.
* @value: value.
*
* A value of zero will be returned on success, a negative errno will
* be returned in error cases.
*/
int rt_sdca_index_write(struct regmap *map, unsigned int nid,
unsigned int reg, unsigned int value)
{
unsigned int addr = (nid << 20) | reg;
int ret;
ret = regmap_write(map, addr, value);
if (ret < 0)
pr_err("Failed to set value: %06x <= %04x ret=%d\n",
addr, value, ret);
return ret;
}
EXPORT_SYMBOL_GPL(rt_sdca_index_write);
/**
* rt_sdca_index_read - Read value from Realtek defined register.
*
* @map: map for setting.
* @nid: Realtek-defined ID.
* @reg: register.
* @value: value.
*
* A value of zero will be returned on success, a negative errno will
* be returned in error cases.
*/
int rt_sdca_index_read(struct regmap *map, unsigned int nid,
unsigned int reg, unsigned int *value)
{
unsigned int addr = (nid << 20) | reg;
int ret;
ret = regmap_read(map, addr, value);
if (ret < 0)
pr_err("Failed to get value: %06x => %04x ret=%d\n",
addr, *value, ret);
return ret;
}
EXPORT_SYMBOL_GPL(rt_sdca_index_read);
/**
* rt_sdca_index_update_bits - Update value on Realtek defined register.
*
* @map: map for setting.
* @nid: Realtek-defined ID.
* @reg: register.
* @mask: Bitmask to change
* @val: New value for bitmask
*
* A value of zero will be returned on success, a negative errno will
* be returned in error cases.
*/
int rt_sdca_index_update_bits(struct regmap *map,
unsigned int nid, unsigned int reg, unsigned int mask, unsigned int val)
{
unsigned int tmp;
int ret;
Annotation
- Immediate include surface: `linux/module.h`, `linux/regmap.h`, `linux/bitops.h`, `linux/soundwire/sdw_registers.h`, `sound/jack.h`, `rt-sdw-common.h`.
- Detected declarations: `function rt_sdca_index_write`, `function rt_sdca_index_read`, `function rt_sdca_index_update_bits`, `function rt_sdca_btn_type`, `function rt_sdca_headset_detect`, `function rt_sdca_button_detect`, `export rt_sdca_index_write`, `export rt_sdca_index_read`, `export rt_sdca_index_update_bits`, `export rt_sdca_btn_type`.
- 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.