sound/soc/tegra/tegra186_dspk.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/tegra/tegra186_dspk.c
Extension
.c
Size
15418 bytes
Lines
552
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) 2020-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// tegra186_dspk.c - Tegra186 DSPK driver

#include <linux/clk.h>
#include <linux/device.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <sound/core.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include "tegra186_dspk.h"
#include "tegra_cif.h"

static const struct reg_default tegra186_dspk_reg_defaults[] = {
	{ TEGRA186_DSPK_RX_INT_MASK, 0x00000007 },
	{ TEGRA186_DSPK_RX_CIF_CTRL, 0x00007700 },
	{ TEGRA186_DSPK_CG,	     0x00000001 },
	{ TEGRA186_DSPK_CORE_CTRL,   0x00000310 },
	{ TEGRA186_DSPK_CODEC_CTRL,  0x03000000 },
};

static int tegra186_dspk_get_fifo_th(struct snd_kcontrol *kcontrol,
				     struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol);
	struct tegra186_dspk *dspk = snd_soc_component_get_drvdata(codec);

	ucontrol->value.integer.value[0] = dspk->rx_fifo_th;

	return 0;
}

static int tegra186_dspk_put_fifo_th(struct snd_kcontrol *kcontrol,
				     struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol);
	struct tegra186_dspk *dspk = snd_soc_component_get_drvdata(codec);
	int value = ucontrol->value.integer.value[0];

	if (value == dspk->rx_fifo_th)
		return 0;

	dspk->rx_fifo_th = value;

	return 1;
}

static int tegra186_dspk_get_osr_val(struct snd_kcontrol *kcontrol,
				     struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol);
	struct tegra186_dspk *dspk = snd_soc_component_get_drvdata(codec);

	ucontrol->value.enumerated.item[0] = dspk->osr_val;

	return 0;
}

static int tegra186_dspk_put_osr_val(struct snd_kcontrol *kcontrol,
				     struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol);
	struct tegra186_dspk *dspk = snd_soc_component_get_drvdata(codec);
	unsigned int value = ucontrol->value.enumerated.item[0];

	if (value == dspk->osr_val)
		return 0;

	dspk->osr_val = value;

	return 1;
}

static int tegra186_dspk_get_pol_sel(struct snd_kcontrol *kcontrol,
				     struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol);
	struct tegra186_dspk *dspk = snd_soc_component_get_drvdata(codec);

	ucontrol->value.enumerated.item[0] = dspk->lrsel;

	return 0;
}

Annotation

Implementation Notes