sound/soc/tegra/tegra210_ope.c

Source file repositories/reference/linux-study-clean/sound/soc/tegra/tegra210_ope.c

File Facts

System
Linux kernel
Corpus path
sound/soc/tegra/tegra210_ope.c
Extension
.c
Size
11023 bytes
Lines
416
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
// SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES.
// All rights reserved.
//
// tegra210_ope.c - Tegra210 OPE driver

#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>

#include "tegra210_mbdrc.h"
#include "tegra210_ope.h"
#include "tegra210_peq.h"
#include "tegra_cif.h"

static const struct reg_default tegra210_ope_reg_defaults[] = {
	{ TEGRA210_OPE_RX_INT_MASK, 0x00000001},
	{ TEGRA210_OPE_RX_CIF_CTRL, 0x00007700},
	{ TEGRA210_OPE_TX_INT_MASK, 0x00000001},
	{ TEGRA210_OPE_TX_CIF_CTRL, 0x00007700},
	{ TEGRA210_OPE_CG, 0x1},
};

static int tegra210_ope_set_audio_cif(struct tegra210_ope *ope,
				      struct snd_pcm_hw_params *params,
				      unsigned int reg)
{
	int channels, audio_bits;
	struct tegra_cif_conf cif_conf;

	memset(&cif_conf, 0, sizeof(struct tegra_cif_conf));

	channels = params_channels(params);
	if (channels < 2)
		return -EINVAL;

	switch (params_format(params)) {
	case SNDRV_PCM_FORMAT_S16_LE:
		audio_bits = TEGRA_ACIF_BITS_16;
		break;
	case SNDRV_PCM_FORMAT_S24_LE:
	case SNDRV_PCM_FORMAT_S32_LE:
		audio_bits = TEGRA_ACIF_BITS_32;
		break;
	default:
		return -EINVAL;
	}

	cif_conf.audio_ch = channels;
	cif_conf.client_ch = channels;
	cif_conf.audio_bits = audio_bits;
	cif_conf.client_bits = audio_bits;

	tegra_set_cif(ope->regmap, reg, &cif_conf);

	return 0;
}

static int tegra210_ope_hw_params(struct snd_pcm_substream *substream,
				 struct snd_pcm_hw_params *params,
				 struct snd_soc_dai *dai)
{
	struct device *dev = dai->dev;
	struct tegra210_ope *ope = snd_soc_dai_get_drvdata(dai);
	int err;

	/* Set RX and TX CIF */
	err = tegra210_ope_set_audio_cif(ope, params,
					 TEGRA210_OPE_RX_CIF_CTRL);
	if (err) {
		dev_err(dev, "Can't set OPE RX CIF: %d\n", err);
		return err;
	}

	err = tegra210_ope_set_audio_cif(ope, params,
					 TEGRA210_OPE_TX_CIF_CTRL);
	if (err) {
		dev_err(dev, "Can't set OPE TX CIF: %d\n", err);
		return err;
	}

Annotation

Implementation Notes