xref: /linux/include/sound/cs-amp-lib.h (revision c297aa7d3fb6755890b78b483e82c9cf07370d50)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2024 Cirrus Logic, Inc. and
4  *                    Cirrus Logic International Semiconductor Ltd.
5  */
6 
7 #ifndef CS_AMP_LIB_H
8 #define CS_AMP_LIB_H
9 
10 #include <linux/efi.h>
11 #include <linux/types.h>
12 
13 struct cs_dsp;
14 
15 struct cirrus_amp_cal_data {
16 	u32 calTarget[2];
17 	u32 calTime[2];
18 	s8  calAmbient;
19 	u8  calStatus;
20 	u16 calR;
21 } __packed;
22 
23 struct cirrus_amp_efi_data {
24 	u32 size;
25 	u32 count;
26 	struct cirrus_amp_cal_data data[];
27 } __packed;
28 
29 /**
30  * struct cirrus_amp_cal_controls - definition of firmware calibration controls
31  * @alg_id:	ID of algorithm containing the controls.
32  * @mem_region:	DSP memory region containing the controls.
33  * @ambient:	Name of control for calAmbient value.
34  * @calr:	Name of control for calR value.
35  * @status:	Name of control for calStatus value.
36  * @checksum:	Name of control for checksum value.
37  */
38 struct cirrus_amp_cal_controls {
39 	unsigned int alg_id;
40 	int mem_region;
41 	const char *ambient;
42 	const char *calr;
43 	const char *status;
44 	const char *checksum;
45 };
46 
47 int cs_amp_write_cal_coeffs(struct cs_dsp *dsp,
48 			    const struct cirrus_amp_cal_controls *controls,
49 			    const struct cirrus_amp_cal_data *data);
50 int cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_index,
51 				    struct cirrus_amp_cal_data *out_data);
52 
53 struct cs_amp_test_hooks {
54 	efi_status_t (*get_efi_variable)(efi_char16_t *name,
55 					 efi_guid_t *guid,
56 					 unsigned long *size,
57 					 void *buf);
58 
59 	int (*write_cal_coeff)(struct cs_dsp *dsp,
60 			       const struct cirrus_amp_cal_controls *controls,
61 			       const char *ctl_name, u32 val);
62 };
63 
64 extern const struct cs_amp_test_hooks * const cs_amp_test_hooks;
65 
66 #endif /* CS_AMP_LIB_H */
67