Mike Frysinger | e359dc2 | 2011-03-22 16:34:40 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Load firmware files from Analog Devices SigmaStudio |
| 3 | * |
| 4 | * Copyright 2009-2011 Analog Devices Inc. |
| 5 | * |
| 6 | * Licensed under the GPL-2 or later. |
| 7 | */ |
| 8 | |
| 9 | #ifndef __SIGMA_FIRMWARE_H__ |
| 10 | #define __SIGMA_FIRMWARE_H__ |
| 11 | |
Lars-Peter Clausen | 38fd54e | 2011-11-28 09:44:20 +0100 | [diff] [blame] | 12 | #include <linux/device.h> |
| 13 | #include <linux/regmap.h> |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 14 | #include <linux/list.h> |
Lars-Peter Clausen | 38fd54e | 2011-11-28 09:44:20 +0100 | [diff] [blame] | 15 | |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 16 | #include <sound/pcm.h> |
Lars-Peter Clausen | 6b10998 | 2014-06-06 14:09:17 +0200 | [diff] [blame] | 17 | |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 18 | struct sigmadsp; |
| 19 | struct snd_soc_component; |
| 20 | struct snd_pcm_substream; |
Lars-Peter Clausen | 6b10998 | 2014-06-06 14:09:17 +0200 | [diff] [blame] | 21 | |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 22 | struct sigmadsp_ops { |
| 23 | int (*safeload)(struct sigmadsp *sigmadsp, unsigned int addr, |
| 24 | const uint8_t *data, size_t len); |
Lars-Peter Clausen | 6b10998 | 2014-06-06 14:09:17 +0200 | [diff] [blame] | 25 | }; |
| 26 | |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 27 | struct sigmadsp { |
| 28 | const struct sigmadsp_ops *ops; |
| 29 | |
Lars-Peter Clausen | a35daac | 2014-11-19 18:29:06 +0100 | [diff] [blame] | 30 | struct list_head ctrl_list; |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 31 | struct list_head data_list; |
| 32 | |
Lars-Peter Clausen | a35daac | 2014-11-19 18:29:06 +0100 | [diff] [blame] | 33 | struct snd_pcm_hw_constraint_list rate_constraints; |
| 34 | |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 35 | unsigned int current_samplerate; |
| 36 | struct snd_soc_component *component; |
| 37 | struct device *dev; |
| 38 | |
Lars-Peter Clausen | a35daac | 2014-11-19 18:29:06 +0100 | [diff] [blame] | 39 | struct mutex lock; |
| 40 | |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 41 | void *control_data; |
| 42 | int (*write)(void *, unsigned int, const uint8_t *, size_t); |
Lars-Peter Clausen | a35daac | 2014-11-19 18:29:06 +0100 | [diff] [blame] | 43 | int (*read)(void *, unsigned int, uint8_t *, size_t); |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct sigmadsp *devm_sigmadsp_init(struct device *dev, |
| 47 | const struct sigmadsp_ops *ops, const char *firmware_name); |
| 48 | void sigmadsp_reset(struct sigmadsp *sigmadsp); |
| 49 | |
| 50 | int sigmadsp_restrict_params(struct sigmadsp *sigmadsp, |
| 51 | struct snd_pcm_substream *substream); |
Lars-Peter Clausen | 6b10998 | 2014-06-06 14:09:17 +0200 | [diff] [blame] | 52 | |
Mike Frysinger | e359dc2 | 2011-03-22 16:34:40 -0700 | [diff] [blame] | 53 | struct i2c_client; |
| 54 | |
Lars-Peter Clausen | d48b088 | 2014-11-19 18:29:05 +0100 | [diff] [blame] | 55 | struct sigmadsp *devm_sigmadsp_init_regmap(struct device *dev, |
| 56 | struct regmap *regmap, const struct sigmadsp_ops *ops, |
| 57 | const char *firmware_name); |
| 58 | struct sigmadsp *devm_sigmadsp_init_i2c(struct i2c_client *client, |
| 59 | const struct sigmadsp_ops *ops, const char *firmware_name); |
| 60 | |
| 61 | int sigmadsp_attach(struct sigmadsp *sigmadsp, |
| 62 | struct snd_soc_component *component); |
| 63 | int sigmadsp_setup(struct sigmadsp *sigmadsp, unsigned int rate); |
| 64 | void sigmadsp_reset(struct sigmadsp *sigmadsp); |
Mike Frysinger | e359dc2 | 2011-03-22 16:34:40 -0700 | [diff] [blame] | 65 | |
| 66 | #endif |