summaryrefslogtreecommitdiffstats
path: root/sound/soc/meson/gx-formatter.h
blob: b90b1814d79b49e3e6e5f4470161bc1e8bba6ebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
/*
 * Copyright (c) 2026 Baylibre SAS.
 * Author: Valerio Setti <vsetti@baylibre.com>
 */

#ifndef _MESON_GX_FORMATTER_H
#define _MESON_GX_FORMATTER_H

#include "gx-interface.h"

struct platform_device;
struct regmap;
struct snd_soc_dapm_widget;
struct snd_kcontrol;

struct gx_formatter_hw {
	unsigned int skew_offset;
};

struct gx_formatter_ops {
	struct gx_stream *(*get_stream)(struct snd_soc_dapm_widget *w);
	void (*enable)(struct regmap *map);
	void (*disable)(struct regmap *map);
	int (*prepare)(struct regmap *map,
		       const struct gx_formatter_hw *quirks,
		       struct gx_stream *ts);
};

struct gx_formatter_driver {
	const struct snd_soc_component_driver *component_drv;
	const struct regmap_config *regmap_cfg;
	const struct gx_formatter_ops *ops;
	const struct gx_formatter_hw *quirks;
};

int gx_formatter_event(struct snd_soc_dapm_widget *w,
		       struct snd_kcontrol *control,
		       int event);
int gx_formatter_probe(struct platform_device *pdev);

int gx_formatter_create(struct device *dev,
			struct snd_soc_dapm_widget *w,
			const struct gx_formatter_driver *drv,
			struct regmap *regmap);

/*
 * Formatter data is already freed when the associated device is removed,
 * so we just need to remove the pointer from the widget.
 */
static inline void gx_formatter_free(struct snd_soc_dapm_widget *w)
{
	w->priv = NULL;
}

#endif /* _MESON_GX_FORMATTER_H */