blob: 614475cbb823f282c857b60fd9a5160c190b192d [file] [log] [blame]
Mike Frysingere359dc22011-03-22 16:34:40 -07001/*
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 Clausen38fd54e2011-11-28 09:44:20 +010012#include <linux/device.h>
13#include <linux/regmap.h>
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010014#include <linux/list.h>
Lars-Peter Clausen38fd54e2011-11-28 09:44:20 +010015
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010016#include <sound/pcm.h>
Lars-Peter Clausen6b109982014-06-06 14:09:17 +020017
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010018struct sigmadsp;
19struct snd_soc_component;
20struct snd_pcm_substream;
Lars-Peter Clausen6b109982014-06-06 14:09:17 +020021
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010022struct sigmadsp_ops {
23 int (*safeload)(struct sigmadsp *sigmadsp, unsigned int addr,
24 const uint8_t *data, size_t len);
Lars-Peter Clausen6b109982014-06-06 14:09:17 +020025};
26
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010027struct sigmadsp {
28 const struct sigmadsp_ops *ops;
29
Lars-Peter Clausena35daac2014-11-19 18:29:06 +010030 struct list_head ctrl_list;
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010031 struct list_head data_list;
32
Lars-Peter Clausena35daac2014-11-19 18:29:06 +010033 struct snd_pcm_hw_constraint_list rate_constraints;
34
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010035 unsigned int current_samplerate;
36 struct snd_soc_component *component;
37 struct device *dev;
38
Lars-Peter Clausena35daac2014-11-19 18:29:06 +010039 struct mutex lock;
40
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010041 void *control_data;
42 int (*write)(void *, unsigned int, const uint8_t *, size_t);
Lars-Peter Clausena35daac2014-11-19 18:29:06 +010043 int (*read)(void *, unsigned int, uint8_t *, size_t);
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010044};
45
46struct sigmadsp *devm_sigmadsp_init(struct device *dev,
47 const struct sigmadsp_ops *ops, const char *firmware_name);
48void sigmadsp_reset(struct sigmadsp *sigmadsp);
49
50int sigmadsp_restrict_params(struct sigmadsp *sigmadsp,
51 struct snd_pcm_substream *substream);
Lars-Peter Clausen6b109982014-06-06 14:09:17 +020052
Mike Frysingere359dc22011-03-22 16:34:40 -070053struct i2c_client;
54
Lars-Peter Clausend48b0882014-11-19 18:29:05 +010055struct sigmadsp *devm_sigmadsp_init_regmap(struct device *dev,
56 struct regmap *regmap, const struct sigmadsp_ops *ops,
57 const char *firmware_name);
58struct sigmadsp *devm_sigmadsp_init_i2c(struct i2c_client *client,
59 const struct sigmadsp_ops *ops, const char *firmware_name);
60
61int sigmadsp_attach(struct sigmadsp *sigmadsp,
62 struct snd_soc_component *component);
63int sigmadsp_setup(struct sigmadsp *sigmadsp, unsigned int rate);
64void sigmadsp_reset(struct sigmadsp *sigmadsp);
Mike Frysingere359dc22011-03-22 16:34:40 -070065
66#endif