xref: /openbmc/linux/sound/soc/codecs/sigmadsp.h (revision a35daac77a0397d4f23b642d3dc0684682e56cc5)
140216ce7SLars-Peter Clausen /*
240216ce7SLars-Peter Clausen  * Load firmware files from Analog Devices SigmaStudio
340216ce7SLars-Peter Clausen  *
440216ce7SLars-Peter Clausen  * Copyright 2009-2011 Analog Devices Inc.
540216ce7SLars-Peter Clausen  *
640216ce7SLars-Peter Clausen  * Licensed under the GPL-2 or later.
740216ce7SLars-Peter Clausen  */
840216ce7SLars-Peter Clausen 
940216ce7SLars-Peter Clausen #ifndef __SIGMA_FIRMWARE_H__
1040216ce7SLars-Peter Clausen #define __SIGMA_FIRMWARE_H__
1140216ce7SLars-Peter Clausen 
1238fd54eeSLars-Peter Clausen #include <linux/device.h>
1338fd54eeSLars-Peter Clausen #include <linux/regmap.h>
14d48b088eSLars-Peter Clausen #include <linux/list.h>
1538fd54eeSLars-Peter Clausen 
16d48b088eSLars-Peter Clausen #include <sound/pcm.h>
176b10998dSLars-Peter Clausen 
18d48b088eSLars-Peter Clausen struct sigmadsp;
19d48b088eSLars-Peter Clausen struct snd_soc_component;
20d48b088eSLars-Peter Clausen struct snd_pcm_substream;
216b10998dSLars-Peter Clausen 
22d48b088eSLars-Peter Clausen struct sigmadsp_ops {
23d48b088eSLars-Peter Clausen 	int (*safeload)(struct sigmadsp *sigmadsp, unsigned int addr,
24d48b088eSLars-Peter Clausen 			const uint8_t *data, size_t len);
256b10998dSLars-Peter Clausen };
266b10998dSLars-Peter Clausen 
27d48b088eSLars-Peter Clausen struct sigmadsp {
28d48b088eSLars-Peter Clausen 	const struct sigmadsp_ops *ops;
29d48b088eSLars-Peter Clausen 
30*a35daac7SLars-Peter Clausen 	struct list_head ctrl_list;
31d48b088eSLars-Peter Clausen 	struct list_head data_list;
32d48b088eSLars-Peter Clausen 
33*a35daac7SLars-Peter Clausen 	struct snd_pcm_hw_constraint_list rate_constraints;
34*a35daac7SLars-Peter Clausen 
35d48b088eSLars-Peter Clausen 	unsigned int current_samplerate;
36d48b088eSLars-Peter Clausen 	struct snd_soc_component *component;
37d48b088eSLars-Peter Clausen 	struct device *dev;
38d48b088eSLars-Peter Clausen 
39*a35daac7SLars-Peter Clausen 	struct mutex lock;
40*a35daac7SLars-Peter Clausen 
41d48b088eSLars-Peter Clausen 	void *control_data;
42d48b088eSLars-Peter Clausen 	int (*write)(void *, unsigned int, const uint8_t *, size_t);
43*a35daac7SLars-Peter Clausen 	int (*read)(void *, unsigned int, uint8_t *, size_t);
44d48b088eSLars-Peter Clausen };
45d48b088eSLars-Peter Clausen 
46d48b088eSLars-Peter Clausen struct sigmadsp *devm_sigmadsp_init(struct device *dev,
47d48b088eSLars-Peter Clausen 	const struct sigmadsp_ops *ops, const char *firmware_name);
48d48b088eSLars-Peter Clausen void sigmadsp_reset(struct sigmadsp *sigmadsp);
49d48b088eSLars-Peter Clausen 
50d48b088eSLars-Peter Clausen int sigmadsp_restrict_params(struct sigmadsp *sigmadsp,
51d48b088eSLars-Peter Clausen 	struct snd_pcm_substream *substream);
526b10998dSLars-Peter Clausen 
5340216ce7SLars-Peter Clausen struct i2c_client;
5440216ce7SLars-Peter Clausen 
55d48b088eSLars-Peter Clausen struct sigmadsp *devm_sigmadsp_init_regmap(struct device *dev,
56d48b088eSLars-Peter Clausen 	struct regmap *regmap, const struct sigmadsp_ops *ops,
57d48b088eSLars-Peter Clausen 	const char *firmware_name);
58d48b088eSLars-Peter Clausen struct sigmadsp *devm_sigmadsp_init_i2c(struct i2c_client *client,
59d48b088eSLars-Peter Clausen 	const struct sigmadsp_ops *ops,	const char *firmware_name);
60d48b088eSLars-Peter Clausen 
61d48b088eSLars-Peter Clausen int sigmadsp_attach(struct sigmadsp *sigmadsp,
62d48b088eSLars-Peter Clausen 	struct snd_soc_component *component);
63d48b088eSLars-Peter Clausen int sigmadsp_setup(struct sigmadsp *sigmadsp, unsigned int rate);
64d48b088eSLars-Peter Clausen void sigmadsp_reset(struct sigmadsp *sigmadsp);
6540216ce7SLars-Peter Clausen 
6640216ce7SLars-Peter Clausen #endif
67