xref: /openbmc/linux/sound/soc/codecs/sigmadsp.h (revision d48b088e3ec45eeccf0fce0b75378e41428f47e9)
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>
14*d48b088eSLars-Peter Clausen #include <linux/list.h>
1538fd54eeSLars-Peter Clausen 
16*d48b088eSLars-Peter Clausen #include <sound/pcm.h>
176b10998dSLars-Peter Clausen 
18*d48b088eSLars-Peter Clausen struct sigmadsp;
19*d48b088eSLars-Peter Clausen struct snd_soc_component;
20*d48b088eSLars-Peter Clausen struct snd_pcm_substream;
216b10998dSLars-Peter Clausen 
22*d48b088eSLars-Peter Clausen struct sigmadsp_ops {
23*d48b088eSLars-Peter Clausen 	int (*safeload)(struct sigmadsp *sigmadsp, unsigned int addr,
24*d48b088eSLars-Peter Clausen 			const uint8_t *data, size_t len);
256b10998dSLars-Peter Clausen };
266b10998dSLars-Peter Clausen 
27*d48b088eSLars-Peter Clausen struct sigmadsp {
28*d48b088eSLars-Peter Clausen 	const struct sigmadsp_ops *ops;
29*d48b088eSLars-Peter Clausen 
30*d48b088eSLars-Peter Clausen 	struct list_head data_list;
31*d48b088eSLars-Peter Clausen 
32*d48b088eSLars-Peter Clausen 	unsigned int current_samplerate;
33*d48b088eSLars-Peter Clausen 	struct snd_soc_component *component;
34*d48b088eSLars-Peter Clausen 	struct device *dev;
35*d48b088eSLars-Peter Clausen 
36*d48b088eSLars-Peter Clausen 	void *control_data;
37*d48b088eSLars-Peter Clausen 	int (*write)(void *, unsigned int, const uint8_t *, size_t);
38*d48b088eSLars-Peter Clausen };
39*d48b088eSLars-Peter Clausen 
40*d48b088eSLars-Peter Clausen struct sigmadsp *devm_sigmadsp_init(struct device *dev,
41*d48b088eSLars-Peter Clausen 	const struct sigmadsp_ops *ops, const char *firmware_name);
42*d48b088eSLars-Peter Clausen void sigmadsp_reset(struct sigmadsp *sigmadsp);
43*d48b088eSLars-Peter Clausen 
44*d48b088eSLars-Peter Clausen int sigmadsp_restrict_params(struct sigmadsp *sigmadsp,
45*d48b088eSLars-Peter Clausen 	struct snd_pcm_substream *substream);
466b10998dSLars-Peter Clausen 
4740216ce7SLars-Peter Clausen struct i2c_client;
4840216ce7SLars-Peter Clausen 
49*d48b088eSLars-Peter Clausen struct sigmadsp *devm_sigmadsp_init_regmap(struct device *dev,
50*d48b088eSLars-Peter Clausen 	struct regmap *regmap, const struct sigmadsp_ops *ops,
51*d48b088eSLars-Peter Clausen 	const char *firmware_name);
52*d48b088eSLars-Peter Clausen struct sigmadsp *devm_sigmadsp_init_i2c(struct i2c_client *client,
53*d48b088eSLars-Peter Clausen 	const struct sigmadsp_ops *ops,	const char *firmware_name);
54*d48b088eSLars-Peter Clausen 
55*d48b088eSLars-Peter Clausen int sigmadsp_attach(struct sigmadsp *sigmadsp,
56*d48b088eSLars-Peter Clausen 	struct snd_soc_component *component);
57*d48b088eSLars-Peter Clausen int sigmadsp_setup(struct sigmadsp *sigmadsp, unsigned int rate);
58*d48b088eSLars-Peter Clausen void sigmadsp_reset(struct sigmadsp *sigmadsp);
5940216ce7SLars-Peter Clausen 
6040216ce7SLars-Peter Clausen #endif
61