blob: 2783eff633a10272068278160ca1768d05587db7 [file] [log] [blame]
Thomas Gleixner80503b22019-05-24 12:04:09 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Mike Frysingere359dc22011-03-22 16:34:40 -07002/*
3 * Load firmware files from Analog Devices SigmaStudio
4 *
5 * Copyright 2009-2011 Analog Devices Inc.
Mike Frysingere359dc22011-03-22 16:34:40 -07006 */
7
8#ifndef __SIGMA_FIRMWARE_H__
9#define __SIGMA_FIRMWARE_H__
10
Lars-Peter Clausen38fd54e2011-11-28 09:44:20 +010011#include <linux/device.h>
12#include <linux/regmap.h>
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010013#include <linux/list.h>
Lars-Peter Clausen38fd54e2011-11-28 09:44:20 +010014
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010015#include <sound/pcm.h>
Lars-Peter Clausen6b109982014-06-06 14:09:17 +020016
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010017struct sigmadsp;
18struct snd_soc_component;
19struct snd_pcm_substream;
Lars-Peter Clausen6b109982014-06-06 14:09:17 +020020
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010021struct sigmadsp_ops {
22 int (*safeload)(struct sigmadsp *sigmadsp, unsigned int addr,
23 const uint8_t *data, size_t len);
Lars-Peter Clausen6b109982014-06-06 14:09:17 +020024};
25
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010026struct sigmadsp {
27 const struct sigmadsp_ops *ops;
28
Lars-Peter Clausena35daac2014-11-19 18:29:06 +010029 struct list_head ctrl_list;
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010030 struct list_head data_list;
31
Lars-Peter Clausena35daac2014-11-19 18:29:06 +010032 struct snd_pcm_hw_constraint_list rate_constraints;
33
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010034 unsigned int current_samplerate;
35 struct snd_soc_component *component;
36 struct device *dev;
37
Lars-Peter Clausena35daac2014-11-19 18:29:06 +010038 struct mutex lock;
39
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010040 void *control_data;
41 int (*write)(void *, unsigned int, const uint8_t *, size_t);
Lars-Peter Clausena35daac2014-11-19 18:29:06 +010042 int (*read)(void *, unsigned int, uint8_t *, size_t);
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010043};
44
45struct sigmadsp *devm_sigmadsp_init(struct device *dev,
46 const struct sigmadsp_ops *ops, const char *firmware_name);
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010047
48int sigmadsp_restrict_params(struct sigmadsp *sigmadsp,
49 struct snd_pcm_substream *substream);
Lars-Peter Clausen6b109982014-06-06 14:09:17 +020050
Mike Frysingere359dc22011-03-22 16:34:40 -070051struct i2c_client;
52
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010053struct sigmadsp *devm_sigmadsp_init_regmap(struct device *dev,
54 struct regmap *regmap, const struct sigmadsp_ops *ops,
55 const char *firmware_name);
56struct sigmadsp *devm_sigmadsp_init_i2c(struct i2c_client *client,
57 const struct sigmadsp_ops *ops, const char *firmware_name);
58
59int sigmadsp_attach(struct sigmadsp *sigmadsp,
60 struct snd_soc_component *component);
Pierre-Louis Bossart17d74e62021-03-12 12:22:40 -060061int sigmadsp_setup(struct sigmadsp *sigmadsp, unsigned int samplerate);
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010062void sigmadsp_reset(struct sigmadsp *sigmadsp);
Mike Frysingere359dc22011-03-22 16:34:40 -070063
64#endif