File Index
Files and directories
Sign in
FILE

axg-tdm.h

File preview with syntax highlighting.

linux-6.19.14/sound/soc/meson/axg-tdm.h C
 1/* SPDX-License-Identifier: (GPL-2.0 OR MIT)
 2 *
 3 * Copyright (c) 2018 Baylibre SAS.
 4 * Author: Jerome Brunet <jbrunet@baylibre.com>
 5 */
 6
 7#ifndef _MESON_AXG_TDM_H
 8#define _MESON_AXG_TDM_H
 9
10#include <linux/clk.h>
11#include <linux/regmap.h>
12#include <sound/pcm.h>
13#include <sound/soc.h>
14#include <sound/soc-dai.h>
15
16#define AXG_TDM_NUM_LANES	4
17#define AXG_TDM_CHANNEL_MAX	128
18#define AXG_TDM_FORMATS		(SNDRV_PCM_FMTBIT_S8 |		\
19				 SNDRV_PCM_FMTBIT_S16_LE |	\
20				 SNDRV_PCM_FMTBIT_S20_LE |	\
21				 SNDRV_PCM_FMTBIT_S24_LE |	\
22				 SNDRV_PCM_FMTBIT_S32_LE)
23
24struct axg_tdm_iface {
25	struct clk *sclk;
26	struct clk *lrclk;
27	struct clk *mclk;
28	unsigned long mclk_rate;
29
30	/* format is common to all the DAIs of the iface */
31	unsigned int fmt;
32	unsigned int slots;
33	unsigned int slot_width;
34
35	/* For component wide symmetry */
36	int rate;
37};
38
39static inline bool axg_tdm_lrclk_invert(unsigned int fmt)
40{
41	return ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S) ^
42		!!(fmt & (SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_NB_IF));
43}
44
45static inline bool axg_tdm_sclk_invert(unsigned int fmt)
46{
47	return fmt & (SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_IB_NF);
48}
49
50struct axg_tdm_stream {
51	struct axg_tdm_iface *iface;
52	struct list_head formatter_list;
53	struct mutex lock;
54	unsigned int channels;
55	unsigned int width;
56	unsigned int physical_width;
57	u32 *mask;
58	bool ready;
59
60	/* For continuous clock tracking */
61	bool clk_enabled;
62};
63
64struct axg_tdm_stream *axg_tdm_stream_alloc(struct axg_tdm_iface *iface);
65void axg_tdm_stream_free(struct axg_tdm_stream *ts);
66int axg_tdm_stream_start(struct axg_tdm_stream *ts);
67void axg_tdm_stream_stop(struct axg_tdm_stream *ts);
68int axg_tdm_stream_set_cont_clocks(struct axg_tdm_stream *ts,
69				   unsigned int fmt);
70
71static inline int axg_tdm_stream_reset(struct axg_tdm_stream *ts)
72{
73	axg_tdm_stream_stop(ts);
74	return axg_tdm_stream_start(ts);
75}
76
77int axg_tdm_set_tdm_slots(struct snd_soc_dai *dai, u32 *tx_mask,
78			  u32 *rx_mask, unsigned int slots,
79			  unsigned int slot_width);
80
81#endif /* _MESON_AXG_TDM_H */
~/ Read-only file preview.