Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/sound/hda/codecs/side-codecs/cs35l41_hda.h
26481 views
1
/* SPDX-License-Identifier: GPL-2.0
2
*
3
* CS35L41 ALSA HDA audio driver
4
*
5
* Copyright 2021 Cirrus Logic, Inc.
6
*
7
* Author: Lucas Tanure <[email protected]>
8
*/
9
10
#ifndef __CS35L41_HDA_H__
11
#define __CS35L41_HDA_H__
12
13
#include <linux/acpi.h>
14
#include <linux/efi.h>
15
#include <linux/regulator/consumer.h>
16
#include <linux/gpio/consumer.h>
17
#include <linux/device.h>
18
#include <sound/cs35l41.h>
19
#include <sound/cs-amp-lib.h>
20
21
#include <linux/firmware/cirrus/cs_dsp.h>
22
#include <linux/firmware/cirrus/wmfw.h>
23
24
#define CS35L41_MAX_ACCEPTABLE_SPI_SPEED_HZ 1000000
25
#define DEFAULT_AMP_GAIN_PCM 17 /* 17.5dB Gain */
26
#define DEFAULT_AMP_GAIN_PDM 19 /* 19.5dB Gain */
27
28
struct cs35l41_amp_cal_data {
29
u32 calTarget[2];
30
u32 calTime[2];
31
s8 calAmbient;
32
u8 calStatus;
33
u16 calR;
34
} __packed;
35
36
struct cs35l41_amp_efi_data {
37
u32 size;
38
u32 count;
39
struct cs35l41_amp_cal_data data[];
40
} __packed;
41
42
enum cs35l41_hda_spk_pos {
43
CS35L41_LEFT,
44
CS35L41_RIGHT,
45
CS35L41_CENTER,
46
};
47
48
enum cs35l41_hda_gpio_function {
49
CS35L41_NOT_USED,
50
CS35l41_VSPK_SWITCH,
51
CS35L41_INTERRUPT,
52
CS35l41_SYNC,
53
};
54
55
enum control_bus {
56
I2C,
57
SPI
58
};
59
60
struct cs35l41_hda {
61
struct device *dev;
62
struct regmap *regmap;
63
struct gpio_desc *reset_gpio;
64
struct gpio_desc *cs_gpio;
65
struct cs35l41_hw_cfg hw_cfg;
66
struct hda_codec *codec;
67
68
int irq;
69
int index;
70
int channel_index;
71
unsigned volatile long irq_errors;
72
const char *amp_name;
73
const char *acpi_subsystem_id;
74
int firmware_type;
75
int speaker_id;
76
struct mutex fw_mutex;
77
struct work_struct fw_load_work;
78
79
struct regmap_irq_chip_data *irq_data;
80
bool firmware_running;
81
bool request_fw_load;
82
bool fw_request_ongoing;
83
bool halo_initialized;
84
bool playback_started;
85
struct cs_dsp cs_dsp;
86
struct acpi_device *dacpi;
87
bool mute_override;
88
enum control_bus control_bus;
89
bool bypass_fw;
90
unsigned int tuning_gain;
91
struct cirrus_amp_cal_data cal_data;
92
bool cal_data_valid;
93
94
};
95
96
enum halo_state {
97
HALO_STATE_CODE_INIT_DOWNLOAD = 0,
98
HALO_STATE_CODE_START,
99
HALO_STATE_CODE_RUN
100
};
101
102
extern const struct dev_pm_ops cs35l41_hda_pm_ops;
103
104
int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq,
105
struct regmap *regmap, enum control_bus control_bus);
106
void cs35l41_hda_remove(struct device *dev);
107
int cs35l41_get_speaker_id(struct device *dev, int amp_index, int num_amps, int fixed_gpio_id);
108
int cs35l41_hda_parse_acpi(struct cs35l41_hda *cs35l41, struct device *physdev, int id);
109
110
#endif /*__CS35L41_HDA_H__*/
111
112