cs-amp-lib.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef CS_AMP_LIB_H
  7. #define CS_AMP_LIB_H
  8. #include <linux/efi.h>
  9. #include <linux/types.h>
  10. struct cs_dsp;
  11. struct cirrus_amp_cal_data {
  12. u32 calTarget[2];
  13. u32 calTime[2];
  14. s8 calAmbient;
  15. u8 calStatus;
  16. u16 calR;
  17. } __packed;
  18. struct cirrus_amp_efi_data {
  19. u32 size;
  20. u32 count;
  21. struct cirrus_amp_cal_data data[];
  22. } __packed;
  23. /**
  24. * struct cirrus_amp_cal_controls - definition of firmware calibration controls
  25. * @alg_id: ID of algorithm containing the controls.
  26. * @mem_region: DSP memory region containing the controls.
  27. * @ambient: Name of control for calAmbient value.
  28. * @calr: Name of control for calR value.
  29. * @status: Name of control for calStatus value.
  30. * @checksum: Name of control for checksum value.
  31. */
  32. struct cirrus_amp_cal_controls {
  33. unsigned int alg_id;
  34. int mem_region;
  35. const char *ambient;
  36. const char *calr;
  37. const char *status;
  38. const char *checksum;
  39. };
  40. int cs_amp_write_cal_coeffs(struct cs_dsp *dsp,
  41. const struct cirrus_amp_cal_controls *controls,
  42. const struct cirrus_amp_cal_data *data);
  43. int cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_index,
  44. struct cirrus_amp_cal_data *out_data);
  45. struct cs_amp_test_hooks {
  46. efi_status_t (*get_efi_variable)(efi_char16_t *name,
  47. efi_guid_t *guid,
  48. unsigned long *size,
  49. void *buf);
  50. int (*write_cal_coeff)(struct cs_dsp *dsp,
  51. const struct cirrus_amp_cal_controls *controls,
  52. const char *ctl_name, u32 val);
  53. };
  54. extern const struct cs_amp_test_hooks * const cs_amp_test_hooks;
  55. #endif /* CS_AMP_LIB_H */