Linux 6.7-rc7
[linux-modified.git] / sound / pci / hda / cs35l41_hda.h
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 <tanureal@opensource.cirrus.com>
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
20 #include <linux/firmware/cirrus/cs_dsp.h>
21 #include <linux/firmware/cirrus/wmfw.h>
22
23 struct cs35l41_amp_cal_data {
24         u32 calTarget[2];
25         u32 calTime[2];
26         s8 calAmbient;
27         u8 calStatus;
28         u16 calR;
29 } __packed;
30
31 struct cs35l41_amp_efi_data {
32         u32 size;
33         u32 count;
34         struct cs35l41_amp_cal_data data[];
35 } __packed;
36
37 enum cs35l41_hda_spk_pos {
38         CS35L41_LEFT,
39         CS35L41_RIGHT,
40 };
41
42 enum cs35l41_hda_gpio_function {
43         CS35L41_NOT_USED,
44         CS35l41_VSPK_SWITCH,
45         CS35L41_INTERRUPT,
46         CS35l41_SYNC,
47 };
48
49 struct cs35l41_hda {
50         struct device *dev;
51         struct regmap *regmap;
52         struct gpio_desc *reset_gpio;
53         struct gpio_desc *cs_gpio;
54         struct cs35l41_hw_cfg hw_cfg;
55         struct hda_codec *codec;
56
57         int irq;
58         int index;
59         int channel_index;
60         unsigned volatile long irq_errors;
61         const char *amp_name;
62         const char *acpi_subsystem_id;
63         int firmware_type;
64         int speaker_id;
65         struct mutex fw_mutex;
66         struct work_struct fw_load_work;
67
68         struct regmap_irq_chip_data *irq_data;
69         bool firmware_running;
70         bool request_fw_load;
71         bool fw_request_ongoing;
72         bool halo_initialized;
73         bool playback_started;
74         struct cs_dsp cs_dsp;
75         struct acpi_device *dacpi;
76         bool mute_override;
77 };
78
79 enum halo_state {
80         HALO_STATE_CODE_INIT_DOWNLOAD = 0,
81         HALO_STATE_CODE_START,
82         HALO_STATE_CODE_RUN
83 };
84
85 extern const struct dev_pm_ops cs35l41_hda_pm_ops;
86
87 int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq,
88                       struct regmap *regmap);
89 void cs35l41_hda_remove(struct device *dev);
90 int cs35l41_get_speaker_id(struct device *dev, int amp_index, int num_amps, int fixed_gpio_id);
91
92 #endif /*__CS35L41_HDA_H__*/