sound/soc/sof/amd/acp-probes.c

Source file repositories/reference/linux-study-clean/sound/soc/sof/amd/acp-probes.c

File Facts

System
Linux kernel
Corpus path
sound/soc/sof/amd/acp-probes.c
Extension
.c
Size
4079 bytes
Lines
148
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.

Dependency Surface

Detected Declarations

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) 2023 Advanced Micro Devices, Inc.
//
// Authors: V Sujith Kumar Reddy <Vsujithkumar.Reddy@amd.com>

/*
 * Probe interface for generic AMD audio ACP DSP block
 */

#include <linux/module.h>
#include <sound/soc.h>
#include "../sof-priv.h"
#include "../sof-client-probes.h"
#include "../sof-client.h"
#include "../ops.h"
#include "acp.h"
#include "acp-dsp-offset.h"

static int acp_probes_compr_startup(struct sof_client_dev *cdev,
				    struct snd_compr_stream *cstream,
				    struct snd_soc_dai *dai, u32 *stream_id)
{
	struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
	struct acp_dsp_stream *stream;
	struct acp_dev_data *adata;

	adata = sdev->pdata->hw_pdata;
	stream = acp_dsp_stream_get(sdev, 0);
	if (!stream)
		return -ENODEV;

	stream->cstream = cstream;
	cstream->runtime->private_data = stream;

	adata->probe_stream = stream;
	*stream_id = stream->stream_tag;

	return 0;
}

static int acp_probes_compr_shutdown(struct sof_client_dev *cdev,
				     struct snd_compr_stream *cstream,
				     struct snd_soc_dai *dai)
{
	struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
	struct acp_dsp_stream *stream = cstream->runtime->private_data;
	struct acp_dev_data *adata;
	int ret;

	ret = acp_dsp_stream_put(sdev, stream);
	if (ret < 0) {
		dev_err(sdev->dev, "Failed to release probe compress stream\n");
		return ret;
	}

	adata = sdev->pdata->hw_pdata;
	stream->cstream = NULL;
	cstream->runtime->private_data = NULL;
	adata->probe_stream = NULL;

	return 0;
}

static int acp_probes_compr_set_params(struct sof_client_dev *cdev,
				       struct snd_compr_stream *cstream,
				       struct snd_compr_params *params,
				       struct snd_soc_dai *dai)
{
	struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
	struct acp_dsp_stream *stream = cstream->runtime->private_data;
	unsigned int buf_offset, index;
	u32 size;
	int ret;

	stream->dmab = cstream->runtime->dma_buffer_p;
	stream->num_pages = PFN_UP(cstream->runtime->dma_bytes);
	size = cstream->runtime->buffer_size;

	ret = acp_dsp_stream_config(sdev, stream);
	if (ret < 0) {
		acp_dsp_stream_put(sdev, stream);
		return ret;
	}

	/* write buffer size of stream in scratch memory */

Annotation

Implementation Notes