xref: /openbmc/linux/sound/soc/codecs/sigmadsp.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
180503b23SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
240216ce7SLars-Peter Clausen /*
340216ce7SLars-Peter Clausen  * Load firmware files from Analog Devices SigmaStudio
440216ce7SLars-Peter Clausen  *
540216ce7SLars-Peter Clausen  * Copyright 2009-2011 Analog Devices Inc.
640216ce7SLars-Peter Clausen  */
740216ce7SLars-Peter Clausen 
840216ce7SLars-Peter Clausen #ifndef __SIGMA_FIRMWARE_H__
940216ce7SLars-Peter Clausen #define __SIGMA_FIRMWARE_H__
1040216ce7SLars-Peter Clausen 
1138fd54eeSLars-Peter Clausen #include <linux/device.h>
1238fd54eeSLars-Peter Clausen #include <linux/regmap.h>
13d48b088eSLars-Peter Clausen #include <linux/list.h>
1438fd54eeSLars-Peter Clausen 
15d48b088eSLars-Peter Clausen #include <sound/pcm.h>
166b10998dSLars-Peter Clausen 
17d48b088eSLars-Peter Clausen struct sigmadsp;
18d48b088eSLars-Peter Clausen struct snd_soc_component;
19d48b088eSLars-Peter Clausen struct snd_pcm_substream;
206b10998dSLars-Peter Clausen 
21d48b088eSLars-Peter Clausen struct sigmadsp_ops {
22d48b088eSLars-Peter Clausen 	int (*safeload)(struct sigmadsp *sigmadsp, unsigned int addr,
23d48b088eSLars-Peter Clausen 			const uint8_t *data, size_t len);
246b10998dSLars-Peter Clausen };
256b10998dSLars-Peter Clausen 
26d48b088eSLars-Peter Clausen struct sigmadsp {
27d48b088eSLars-Peter Clausen 	const struct sigmadsp_ops *ops;
28d48b088eSLars-Peter Clausen 
29a35daac7SLars-Peter Clausen 	struct list_head ctrl_list;
30d48b088eSLars-Peter Clausen 	struct list_head data_list;
31d48b088eSLars-Peter Clausen 
32a35daac7SLars-Peter Clausen 	struct snd_pcm_hw_constraint_list rate_constraints;
33a35daac7SLars-Peter Clausen 
34d48b088eSLars-Peter Clausen 	unsigned int current_samplerate;
35d48b088eSLars-Peter Clausen 	struct snd_soc_component *component;
36d48b088eSLars-Peter Clausen 	struct device *dev;
37d48b088eSLars-Peter Clausen 
38a35daac7SLars-Peter Clausen 	struct mutex lock;
39a35daac7SLars-Peter Clausen 
40d48b088eSLars-Peter Clausen 	void *control_data;
41d48b088eSLars-Peter Clausen 	int (*write)(void *, unsigned int, const uint8_t *, size_t);
42a35daac7SLars-Peter Clausen 	int (*read)(void *, unsigned int, uint8_t *, size_t);
43d48b088eSLars-Peter Clausen };
44d48b088eSLars-Peter Clausen 
45d48b088eSLars-Peter Clausen struct sigmadsp *devm_sigmadsp_init(struct device *dev,
46d48b088eSLars-Peter Clausen 	const struct sigmadsp_ops *ops, const char *firmware_name);
47d48b088eSLars-Peter Clausen 
48d48b088eSLars-Peter Clausen int sigmadsp_restrict_params(struct sigmadsp *sigmadsp,
49d48b088eSLars-Peter Clausen 	struct snd_pcm_substream *substream);
506b10998dSLars-Peter Clausen 
5140216ce7SLars-Peter Clausen struct i2c_client;
5240216ce7SLars-Peter Clausen 
53d48b088eSLars-Peter Clausen struct sigmadsp *devm_sigmadsp_init_regmap(struct device *dev,
54d48b088eSLars-Peter Clausen 	struct regmap *regmap, const struct sigmadsp_ops *ops,
55d48b088eSLars-Peter Clausen 	const char *firmware_name);
56d48b088eSLars-Peter Clausen struct sigmadsp *devm_sigmadsp_init_i2c(struct i2c_client *client,
57d48b088eSLars-Peter Clausen 	const struct sigmadsp_ops *ops,	const char *firmware_name);
58d48b088eSLars-Peter Clausen 
59d48b088eSLars-Peter Clausen int sigmadsp_attach(struct sigmadsp *sigmadsp,
60d48b088eSLars-Peter Clausen 	struct snd_soc_component *component);
61*17d74e68SPierre-Louis Bossart int sigmadsp_setup(struct sigmadsp *sigmadsp, unsigned int samplerate);
62d48b088eSLars-Peter Clausen void sigmadsp_reset(struct sigmadsp *sigmadsp);
6340216ce7SLars-Peter Clausen 
6440216ce7SLars-Peter Clausen #endif
65