sound/soc/sof/mediatek/mtk-adsp-common.c
Source file repositories/reference/linux-study-clean/sound/soc/sof/mediatek/mtk-adsp-common.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sof/mediatek/mtk-adsp-common.c- Extension
.c- Size
- 6366 bytes
- Lines
- 214
- 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.hsound/asound.hsound/sof/xtensa.h../ops.h../sof-audio.hadsp_helper.hmtk-adsp-common.h
Detected Declarations
function mtk_adsp_get_registersfunction mtk_adsp_dumpfunction mtk_adsp_send_msgfunction mtk_adsp_handle_replyfunction mtk_adsp_handle_requestfunction mtk_adsp_get_bar_indexfunction mtk_adsp_stream_pcm_hw_paramsfunction mtk_adsp_stream_pcm_pointerexport mtk_adsp_dumpexport mtk_adsp_send_msgexport mtk_adsp_handle_replyexport mtk_adsp_handle_requestexport mtk_adsp_get_bar_indexexport mtk_adsp_stream_pcm_hw_paramsexport mtk_adsp_stream_pcm_pointer
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
//
// This file is provided under a dual BSD/GPLv2 license. When using or
// redistributing this file, you may do so under either license.
//
// Copyright(c) 2022 MediaTek Inc. All rights reserved.
//
// Author: YC Hung <yc.hung@mediatek.com>
/*
* Common helpers for the audio DSP on MediaTek platforms
*/
#include <linux/module.h>
#include <sound/asound.h>
#include <sound/sof/xtensa.h>
#include "../ops.h"
#include "../sof-audio.h"
#include "adsp_helper.h"
#include "mtk-adsp-common.h"
/**
* mtk_adsp_get_registers() - This function is called in case of DSP oops
* in order to gather information about the registers, filename and
* linenumber and stack.
* @sdev: SOF device
* @xoops: Stores information about registers.
* @panic_info: Stores information about filename and line number.
* @stack: Stores the stack dump.
* @stack_words: Size of the stack dump.
*/
static void mtk_adsp_get_registers(struct snd_sof_dev *sdev,
struct sof_ipc_dsp_oops_xtensa *xoops,
struct sof_ipc_panic_info *panic_info,
u32 *stack, size_t stack_words)
{
u32 offset = sdev->dsp_oops_offset;
/* first read registers */
sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops));
/* then get panic info */
if (xoops->arch_hdr.totalsize > EXCEPT_MAX_HDR_SIZE) {
dev_err(sdev->dev, "invalid header size 0x%x\n",
xoops->arch_hdr.totalsize);
return;
}
offset += xoops->arch_hdr.totalsize;
sof_mailbox_read(sdev, offset, panic_info, sizeof(*panic_info));
/* then get the stack */
offset += sizeof(*panic_info);
sof_mailbox_read(sdev, offset, stack, stack_words * sizeof(u32));
}
/**
* mtk_adsp_dump() - This function is called when a panic message is
* received from the firmware.
* @sdev: SOF device
* @flags: parameter not used but required by ops prototype
*/
void mtk_adsp_dump(struct snd_sof_dev *sdev, u32 flags)
{
char *level = (flags & SOF_DBG_DUMP_OPTIONAL) ? KERN_DEBUG : KERN_ERR;
struct sof_ipc_dsp_oops_xtensa xoops;
struct sof_ipc_panic_info panic_info = {};
u32 stack[MTK_ADSP_STACK_DUMP_SIZE];
u32 status;
/* Get information about the panic status from the debug box area.
* Compute the trace point based on the status.
*/
sof_mailbox_read(sdev, sdev->debug_box.offset + 0x4, &status, 4);
/* Get information about the registers, the filename and line
* number and the stack.
*/
mtk_adsp_get_registers(sdev, &xoops, &panic_info, stack,
MTK_ADSP_STACK_DUMP_SIZE);
/* Print the information to the console */
sof_print_oops_and_stack(sdev, level, status, status, &xoops, &panic_info,
stack, MTK_ADSP_STACK_DUMP_SIZE);
}
EXPORT_SYMBOL(mtk_adsp_dump);
/**
* mtk_adsp_send_msg - Send message to Audio DSP
* @sdev: SOF device
* @msg: SOF IPC Message to send
Annotation
- Immediate include surface: `linux/module.h`, `sound/asound.h`, `sound/sof/xtensa.h`, `../ops.h`, `../sof-audio.h`, `adsp_helper.h`, `mtk-adsp-common.h`.
- Detected declarations: `function mtk_adsp_get_registers`, `function mtk_adsp_dump`, `function mtk_adsp_send_msg`, `function mtk_adsp_handle_reply`, `function mtk_adsp_handle_request`, `function mtk_adsp_get_bar_index`, `function mtk_adsp_stream_pcm_hw_params`, `function mtk_adsp_stream_pcm_pointer`, `export mtk_adsp_dump`, `export mtk_adsp_send_msg`.
- 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.