File Index
Files and directories
Sign in
FILE

cs-amp-lib.h

File preview with syntax highlighting.

linux-6.19.14/include/sound/cs-amp-lib.h C
 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
13struct cs_dsp;
14
15struct cirrus_amp_cal_data {
16	u32 calTarget[2];
17	u32 calTime[2];
18	s8  calAmbient;
19	u8  calStatus;
20	u16 calR;
21} __packed;
22
23struct cirrus_amp_efi_data {
24	u32 size;
25	u32 count;
26	struct cirrus_amp_cal_data data[] __counted_by(count);
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 */
38struct 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
47int 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);
50int cs_amp_read_cal_coeffs(struct cs_dsp *dsp,
51			   const struct cirrus_amp_cal_controls *controls,
52			   struct cirrus_amp_cal_data *data);
53int cs_amp_write_ambient_temp(struct cs_dsp *dsp,
54			      const struct cirrus_amp_cal_controls *controls,
55			      u32 temp);
56int cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_index,
57				    struct cirrus_amp_cal_data *out_data);
58int cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, int num_amps,
59				    const struct cirrus_amp_cal_data *in_data);
60int cs_amp_get_vendor_spkid(struct device *dev);
61struct dentry *cs_amp_create_debugfs(struct device *dev);
62
63static inline u64 cs_amp_cal_target_u64(const struct cirrus_amp_cal_data *data)
64{
65	return ((u64)data->calTarget[1] << 32) | data->calTarget[0];
66}
67
68struct cs_amp_test_hooks {
69	efi_status_t (*get_efi_variable)(efi_char16_t *name,
70					 efi_guid_t *guid,
71					 u32 *returned_attr,
72					 unsigned long *size,
73					 void *buf);
74	efi_status_t (*set_efi_variable)(efi_char16_t *name,
75					 efi_guid_t *guid,
76					 u32 attr,
77					 unsigned long size,
78					 void *buf);
79
80	int (*write_cal_coeff)(struct cs_dsp *dsp,
81			       const struct cirrus_amp_cal_controls *controls,
82			       const char *ctl_name, u32 val);
83
84	int (*read_cal_coeff)(struct cs_dsp *dsp,
85			      const struct cirrus_amp_cal_controls *controls,
86			      const char *ctl_name, u32 *val);
87};
88extern const struct cs_amp_test_hooks * const cs_amp_test_hooks;
89
90#endif /* CS_AMP_LIB_H */
~/ Read-only file preview.