sound/soc/img/img-spdif-out.c

Source file repositories/reference/linux-study-clean/sound/soc/img/img-spdif-out.c

File Facts

System
Linux kernel
Corpus path
sound/soc/img/img-spdif-out.c
Extension
.c
Size
12242 bytes
Lines
468
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

struct img_spdif_out {
	spinlock_t lock;
	void __iomem *base;
	struct clk *clk_sys;
	struct clk *clk_ref;
	struct snd_dmaengine_dai_dma_data dma_data;
	struct device *dev;
	struct reset_control *rst;
	u32 suspend_ctl;
	u32 suspend_csl;
	u32 suspend_csh;
};

static int img_spdif_out_runtime_suspend(struct device *dev)
{
	struct img_spdif_out *spdif = dev_get_drvdata(dev);

	clk_disable_unprepare(spdif->clk_ref);
	clk_disable_unprepare(spdif->clk_sys);

	return 0;
}

static int img_spdif_out_runtime_resume(struct device *dev)
{
	struct img_spdif_out *spdif = dev_get_drvdata(dev);
	int ret;

	ret = clk_prepare_enable(spdif->clk_sys);
	if (ret) {
		dev_err(dev, "clk_enable failed: %d\n", ret);
		return ret;
	}

	ret = clk_prepare_enable(spdif->clk_ref);
	if (ret) {
		dev_err(dev, "clk_enable failed: %d\n", ret);
		clk_disable_unprepare(spdif->clk_sys);
		return ret;
	}

	return 0;
}

static inline void img_spdif_out_writel(struct img_spdif_out *spdif, u32 val,
				u32 reg)
{
	writel(val, spdif->base + reg);
}

static inline u32 img_spdif_out_readl(struct img_spdif_out *spdif, u32 reg)
{
	return readl(spdif->base + reg);
}

static void img_spdif_out_reset(struct img_spdif_out *spdif)
{
	u32 ctl, status_low, status_high;

	ctl = img_spdif_out_readl(spdif, IMG_SPDIF_OUT_CTL) &
			~IMG_SPDIF_OUT_CTL_SRT_MASK;
	status_low = img_spdif_out_readl(spdif, IMG_SPDIF_OUT_CSL);
	status_high = img_spdif_out_readl(spdif, IMG_SPDIF_OUT_CSH_UV);

	reset_control_assert(spdif->rst);
	reset_control_deassert(spdif->rst);

	img_spdif_out_writel(spdif, ctl, IMG_SPDIF_OUT_CTL);
	img_spdif_out_writel(spdif, status_low, IMG_SPDIF_OUT_CSL);
	img_spdif_out_writel(spdif, status_high, IMG_SPDIF_OUT_CSH_UV);
}

static int img_spdif_out_info(struct snd_kcontrol *kcontrol,
					struct snd_ctl_elem_info *uinfo)
{
	uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
	uinfo->count = 1;

	return 0;
}

static int img_spdif_out_get_status_mask(struct snd_kcontrol *kcontrol,
				       struct snd_ctl_elem_value *ucontrol)
{
	ucontrol->value.iec958.status[0] = 0xff;
	ucontrol->value.iec958.status[1] = 0xff;
	ucontrol->value.iec958.status[2] = 0xff;
	ucontrol->value.iec958.status[3] = 0xff;
	ucontrol->value.iec958.status[4] = 0xff;

Annotation

Implementation Notes