xref: /linux/sound/soc/meson/gx-formatter.h (revision e5c91aac491def6ab3f90c4cc246e3fcb0f8f058)
1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2 /*
3  * Copyright (c) 2026 Baylibre SAS.
4  * Author: Valerio Setti <vsetti@baylibre.com>
5  */
6 
7 #ifndef _MESON_GX_FORMATTER_H
8 #define _MESON_GX_FORMATTER_H
9 
10 #include "gx-interface.h"
11 
12 struct platform_device;
13 struct regmap;
14 struct snd_soc_dapm_widget;
15 struct snd_kcontrol;
16 
17 struct gx_formatter_hw {
18 	unsigned int skew_offset;
19 };
20 
21 struct gx_formatter_ops {
22 	struct gx_stream *(*get_stream)(struct snd_soc_dapm_widget *w);
23 	void (*enable)(struct regmap *map);
24 	void (*disable)(struct regmap *map);
25 	int (*prepare)(struct regmap *map,
26 		       const struct gx_formatter_hw *quirks,
27 		       struct gx_stream *ts);
28 };
29 
30 struct gx_formatter_driver {
31 	const struct snd_soc_component_driver *component_drv;
32 	const struct regmap_config *regmap_cfg;
33 	const struct gx_formatter_ops *ops;
34 	const struct gx_formatter_hw *quirks;
35 };
36 
37 int gx_formatter_event(struct snd_soc_dapm_widget *w,
38 		       struct snd_kcontrol *control,
39 		       int event);
40 int gx_formatter_probe(struct platform_device *pdev);
41 
42 int gx_formatter_create(struct device *dev,
43 			struct snd_soc_dapm_widget *w,
44 			const struct gx_formatter_driver *drv,
45 			struct regmap *regmap);
46 
47 /*
48  * Formatter data is already freed when the associated device is removed,
49  * so we just need to remove the pointer from the widget.
50  */
51 static inline void gx_formatter_free(struct snd_soc_dapm_widget *w)
52 {
53 	w->priv = NULL;
54 }
55 
56 #endif /* _MESON_GX_FORMATTER_H */
57