sound/soc/intel/catpt/device.c

Source file repositories/reference/linux-study-clean/sound/soc/intel/catpt/device.c

File Facts

System
Linux kernel
Corpus path
sound/soc/intel/catpt/device.c
Extension
.c
Size
9961 bytes
Lines
404
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source 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
//
// Copyright(c) 2020 Intel Corporation
//
// Author: Cezary Rojewski <cezary.rojewski@intel.com>
//
// Special thanks to:
//    Marcin Barlik <marcin.barlik@intel.com>
//    Piotr Papierkowski <piotr.papierkowski@intel.com>
//
// for sharing LPT-LP and WTP-LP AudioDSP architecture expertise and
// helping backtrack its historical background
//

#include <linux/acpi.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <sound/intel-dsp-config.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include "core.h"
#include "registers.h"

static int catpt_do_suspend(struct device *dev)
{
	struct catpt_dev *cdev = dev_get_drvdata(dev);
	struct dma_chan *chan;
	int ret;

	chan = catpt_dma_request_config_chan(cdev);
	if (IS_ERR(chan))
		return PTR_ERR(chan);

	memset(&cdev->dx_ctx, 0, sizeof(cdev->dx_ctx));
	ret = catpt_ipc_enter_dxstate(cdev, CATPT_DX_STATE_D3, &cdev->dx_ctx);
	if (ret) {
		ret = CATPT_IPC_RET(ret);
		goto release_dma_chan;
	}

	ret = catpt_dsp_stall(cdev, true);
	if (ret)
		goto release_dma_chan;

	ret = catpt_store_memdumps(cdev, chan);
	if (ret) {
		dev_err(cdev->dev, "store memdumps failed: %d\n", ret);
		goto release_dma_chan;
	}

	ret = catpt_store_module_states(cdev, chan);
	if (ret) {
		dev_err(cdev->dev, "store module states failed: %d\n", ret);
		goto release_dma_chan;
	}

	ret = catpt_store_streams_context(cdev, chan);
	if (ret)
		dev_err(cdev->dev, "store streams ctx failed: %d\n", ret);

release_dma_chan:
	dma_release_channel(chan);
	if (ret)
		return ret;
	return catpt_dsp_power_down(cdev);
}

/* Do not block the system from suspending, recover on resume() if needed. */
static int catpt_suspend(struct device *dev)
{
	catpt_do_suspend(dev);
	return 0;
}

static int catpt_resume(struct device *dev)
{
	struct catpt_dev *cdev = dev_get_drvdata(dev);
	int ret, i;

	ret = catpt_dsp_power_up(cdev);
	if (ret)
		return ret;

	if (!try_module_get(dev->driver->owner)) {
		dev_info(dev, "module unloading, skipping fw boot\n");
		return 0;

Annotation

Implementation Notes