linux/sound/soc/codecs/tas5720.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * tas5720.c - ALSA SoC Texas Instruments TAS5720 Mono Audio Amplifier
 *
 * Copyright (C)2015-2016 Texas Instruments Incorporated -  https://www.ti.com
 *
 * Author: Andreas Dannenberg <[email protected]>
 */

#include <linux/module.h>
#include <linux/errno.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/regulator/consumer.h>
#include <linux/delay.h>

#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/tlv.h>

#include "tas5720.h"

/* Define how often to check (and clear) the fault status register (in ms) */
#define TAS5720_FAULT_CHECK_INTERVAL

enum tas572x_type {};

static const char * const tas5720_supply_names[] =;

#define TAS5720_NUM_SUPPLIES

struct tas5720_data {};

static int tas5720_hw_params(struct snd_pcm_substream *substream,
			     struct snd_pcm_hw_params *params,
			     struct snd_soc_dai *dai)
{}

static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{}

static int tas5720_set_dai_tdm_slot(struct snd_soc_dai *dai,
				    unsigned int tx_mask, unsigned int rx_mask,
				    int slots, int slot_width)
{}

static int tas5720_mute_soc_component(struct snd_soc_component *component, int mute)
{}

static int tas5720_mute(struct snd_soc_dai *dai, int mute, int direction)
{}

static void tas5720_fault_check_work(struct work_struct *work)
{}

static int tas5720_codec_probe(struct snd_soc_component *component)
{}

static void tas5720_codec_remove(struct snd_soc_component *component)
{
	struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
	int ret;

	cancel_delayed_work_sync(&tas5720->fault_check_work);

	ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
				     tas5720->supplies);
	if (ret < 0)
		dev_err(component->dev, "failed to disable supplies: %d\n", ret);
};

static int tas5720_dac_event(struct snd_soc_dapm_widget *w,
			     struct snd_kcontrol *kcontrol, int event)
{}

#ifdef CONFIG_PM
static int tas5720_suspend(struct snd_soc_component *component)
{}

static int tas5720_resume(struct snd_soc_component *component)
{}
#else
#define tas5720_suspend
#define tas5720_resume
#endif

static bool tas5720_is_volatile_reg(struct device *dev, unsigned int reg)
{}

static const struct regmap_config tas5720_regmap_config =;

static const struct regmap_config tas5720a_q1_regmap_config =;

static const struct regmap_config tas5722_regmap_config =;

/*
 * DAC analog gain. There are four discrete values to select from, ranging
 * from 19.2 dB to 26.3dB.
 */
static const DECLARE_TLV_DB_RANGE(dac_analog_tlv,
	0x0, 0x0, TLV_DB_SCALE_ITEM(1920, 0, 0),
	0x1, 0x1, TLV_DB_SCALE_ITEM(2070, 0, 0),
	0x2, 0x2, TLV_DB_SCALE_ITEM(2350, 0, 0),
	0x3, 0x3, TLV_DB_SCALE_ITEM(2630, 0, 0),
);

/*
 * DAC analog gain for TAS5720A-Q1. There are three discrete values to select from, ranging
 * from 19.2 dB to 25.0dB.
 */
static const DECLARE_TLV_DB_RANGE(dac_analog_tlv_a_q1,
	0x0, 0x0, TLV_DB_SCALE_ITEM(1920, 0, 0),
	0x1, 0x1, TLV_DB_SCALE_ITEM(2260, 0, 0),
	0x2, 0x2, TLV_DB_SCALE_ITEM(2500, 0, 0),
);

/*
 * DAC digital volumes. From -103.5 to 24 dB in 0.5 dB or 0.25 dB steps
 * depending on the device. Note that setting the gain below -100 dB
 * (register value <0x7) is effectively a MUTE as per device datasheet.
 *
 * Note that for the TAS5722 the digital volume controls are actually split
 * over two registers, so we need custom getters/setters for access.
 */
static DECLARE_TLV_DB_SCALE(tas5720_dac_tlv, -10350, 50, 0);
static DECLARE_TLV_DB_SCALE(tas5722_dac_tlv, -10350, 25, 0);

static int tas5722_volume_get(struct snd_kcontrol *kcontrol,
			      struct snd_ctl_elem_value *ucontrol)
{}

static int tas5722_volume_set(struct snd_kcontrol *kcontrol,
			      struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new tas5720_snd_controls[] =;

static const struct snd_kcontrol_new tas5720a_q1_snd_controls[] =;

static const struct snd_kcontrol_new tas5722_snd_controls[] =;

static const struct snd_soc_dapm_widget tas5720_dapm_widgets[] =;

static const struct snd_soc_dapm_route tas5720_audio_map[] =;

static const struct snd_soc_component_driver soc_component_dev_tas5720 =;

static const struct snd_soc_component_driver soc_component_dev_tas5720_a_q1 =;

static const struct snd_soc_component_driver soc_component_dev_tas5722 =;

/* PCM rates supported by the TAS5720 driver */
#define TAS5720_RATES

/* Formats supported by TAS5720 driver */
#define TAS5720_FORMATS

static const struct snd_soc_dai_ops tas5720_speaker_dai_ops =;

/*
 * TAS5720 DAI structure
 *
 * Note that were are advertising .playback.channels_max = 2 despite this being
 * a mono amplifier. The reason for that is that some serial ports such as TI's
 * McASP module have a minimum number of channels (2) that they can output.
 * Advertising more channels than we have will allow us to interface with such
 * a serial port without really any negative side effects as the TAS5720 will
 * simply ignore any extra channel(s) asides from the one channel that is
 * configured to be played back.
 */
static struct snd_soc_dai_driver tas5720_dai[] =;

static const struct i2c_device_id tas5720_id[] =;
MODULE_DEVICE_TABLE(i2c, tas5720_id);

static int tas5720_probe(struct i2c_client *client)
{}

#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id tas5720_of_match[] =;
MODULE_DEVICE_TABLE(of, tas5720_of_match);
#endif

static struct i2c_driver tas5720_i2c_driver =;

module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();