soc-acpi.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * Copyright (C) 2013-15, Intel Corporation. All rights reserved.
  4. */
  5. #ifndef __LINUX_SND_SOC_ACPI_H
  6. #define __LINUX_SND_SOC_ACPI_H
  7. #include <linux/stddef.h>
  8. #include <linux/acpi.h>
  9. #include <linux/mod_devicetable.h>
  10. struct snd_soc_acpi_package_context {
  11. char *name; /* package name */
  12. int length; /* number of elements */
  13. struct acpi_buffer *format;
  14. struct acpi_buffer *state;
  15. bool data_valid;
  16. };
  17. /* codec name is used in DAIs is i2c-<HID>:00 with HID being 8 chars */
  18. #define SND_ACPI_I2C_ID_LEN (4 + ACPI_ID_LEN + 3 + 1)
  19. #if IS_ENABLED(CONFIG_ACPI)
  20. bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
  21. struct snd_soc_acpi_package_context *ctx);
  22. #else
  23. static inline bool
  24. snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
  25. struct snd_soc_acpi_package_context *ctx)
  26. {
  27. return false;
  28. }
  29. #endif
  30. /* acpi match */
  31. struct snd_soc_acpi_mach *
  32. snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
  33. /**
  34. * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
  35. * related to the hardware, except for the firmware and topology file names.
  36. * A platform supported by legacy and Sound Open Firmware (SOF) would expose
  37. * all firmware/topology related fields.
  38. *
  39. * @id: ACPI ID (usually the codec's) used to find a matching machine driver.
  40. * @drv_name: machine driver name
  41. * @fw_filename: firmware file name. Used when SOF is not enabled.
  42. * @board: board name
  43. * @machine_quirk: pointer to quirk, usually based on DMI information when
  44. * ACPI ID alone is not sufficient, wrong or misleading
  45. * @quirk_data: data used to uniquely identify a machine, usually a list of
  46. * audio codecs whose presence if checked with ACPI
  47. * @pdata: intended for platform data or machine specific-ops. This structure
  48. * is not constant since this field may be updated at run-time
  49. * @sof_fw_filename: Sound Open Firmware file name, if enabled
  50. * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled
  51. * @asoc_plat_name: ASoC platform name, used for binding machine drivers
  52. * if non NULL
  53. * @new_mach_data: machine driver private data fixup
  54. */
  55. /* Descriptor for SST ASoC machine driver */
  56. struct snd_soc_acpi_mach {
  57. const u8 id[ACPI_ID_LEN];
  58. const char *drv_name;
  59. const char *fw_filename;
  60. const char *board;
  61. struct snd_soc_acpi_mach * (*machine_quirk)(void *arg);
  62. const void *quirk_data;
  63. void *pdata;
  64. const char *sof_fw_filename;
  65. const char *sof_tplg_filename;
  66. const char *asoc_plat_name;
  67. struct platform_device * (*new_mach_data)(void *pdata);
  68. };
  69. #define SND_SOC_ACPI_MAX_CODECS 3
  70. /**
  71. * struct snd_soc_acpi_codecs: Structure to hold secondary codec information
  72. * apart from the matched one, this data will be passed to the quirk function
  73. * to match with the ACPI detected devices
  74. *
  75. * @num_codecs: number of secondary codecs used in the platform
  76. * @codecs: holds the codec IDs
  77. *
  78. */
  79. struct snd_soc_acpi_codecs {
  80. int num_codecs;
  81. u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN];
  82. };
  83. /* check all codecs */
  84. struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg);
  85. #endif