sound/soc/codecs/fs-amp-lib.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/fs-amp-lib.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/fs-amp-lib.c- Extension
.c- Size
- 6445 bytes
- Lines
- 266
- 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/crc16.hlinux/device.hlinux/firmware.hlinux/module.hlinux/slab.hfs-amp-lib.h
Detected Declarations
function fs_get_scene_countfunction fs_get_fwm_stringfunction fs_get_scene_regfunction fs_get_scene_modelfunction fs_get_scene_effectfunction fs_parse_scene_tablesfunction fs_parse_all_tablesfunction fs_verify_firmwarefunction fs_print_firmware_infofunction fs_amp_load_firmwareexport fs_amp_load_firmware
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
//
// fs-amp-lib.c --- Common library for FourSemi Audio Amplifiers
//
// Copyright (C) 2016-2025 Shanghai FourSemi Semiconductor Co.,Ltd.
#include <linux/crc16.h>
#include <linux/device.h>
#include <linux/firmware.h>
#include <linux/module.h>
#include <linux/slab.h>
#include "fs-amp-lib.h"
static int fs_get_scene_count(struct fs_amp_lib *amp_lib)
{
const struct fs_fwm_table *table;
int count;
if (!amp_lib || !amp_lib->dev)
return -EINVAL;
table = amp_lib->table[FS_INDEX_SCENE];
if (!table)
return -EFAULT;
count = table->size / sizeof(struct fs_scene_index);
if (count < 1 || count > FS_SCENE_COUNT_MAX) {
dev_err(amp_lib->dev, "Invalid scene count: %d\n", count);
return -ERANGE;
}
return count;
}
static void fs_get_fwm_string(struct fs_amp_lib *amp_lib,
int offset, const char **pstr)
{
const struct fs_fwm_table *table;
if (!amp_lib || !amp_lib->dev || !pstr)
return;
table = amp_lib->table[FS_INDEX_STRING];
if (table && offset > 0 && offset < table->size + sizeof(*table))
*pstr = (char *)table + offset;
else
*pstr = NULL;
}
static void fs_get_scene_reg(struct fs_amp_lib *amp_lib,
int offset, struct fs_amp_scene *scene)
{
const struct fs_fwm_table *table;
if (!amp_lib || !amp_lib->dev || !scene)
return;
table = amp_lib->table[FS_INDEX_REG];
if (table && offset > 0 && offset < table->size + sizeof(*table))
scene->reg = (struct fs_reg_table *)((char *)table + offset);
else
scene->reg = NULL;
}
static void fs_get_scene_model(struct fs_amp_lib *amp_lib,
int offset, struct fs_amp_scene *scene)
{
const struct fs_fwm_table *table;
const char *ptr;
if (!amp_lib || !amp_lib->dev || !scene)
return;
table = amp_lib->table[FS_INDEX_MODEL];
ptr = (char *)table;
if (table && offset > 0 && offset < table->size + sizeof(*table))
scene->model = (struct fs_file_table *)(ptr + offset);
else
scene->model = NULL;
}
static void fs_get_scene_effect(struct fs_amp_lib *amp_lib,
int offset, struct fs_amp_scene *scene)
{
const struct fs_fwm_table *table;
const char *ptr;
if (!amp_lib || !amp_lib->dev || !scene)
return;
Annotation
- Immediate include surface: `linux/crc16.h`, `linux/device.h`, `linux/firmware.h`, `linux/module.h`, `linux/slab.h`, `fs-amp-lib.h`.
- Detected declarations: `function fs_get_scene_count`, `function fs_get_fwm_string`, `function fs_get_scene_reg`, `function fs_get_scene_model`, `function fs_get_scene_effect`, `function fs_parse_scene_tables`, `function fs_parse_all_tables`, `function fs_verify_firmware`, `function fs_print_firmware_info`, `function fs_amp_load_firmware`.
- 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.