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