soc-acpi.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (C) 2013-15, Intel Corporation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License version
  6. * 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. #ifndef __LINUX_SND_SOC_ACPI_H
  15. #define __LINUX_SND_SOC_ACPI_H
  16. #include <linux/stddef.h>
  17. #include <linux/acpi.h>
  18. struct snd_soc_acpi_package_context {
  19. char *name; /* package name */
  20. int length; /* number of elements */
  21. struct acpi_buffer *format;
  22. struct acpi_buffer *state;
  23. bool data_valid;
  24. };
  25. #if IS_ENABLED(CONFIG_ACPI)
  26. /* translation fron HID to I2C name, needed for DAI codec_name */
  27. const char *snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]);
  28. bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
  29. struct snd_soc_acpi_package_context *ctx);
  30. #else
  31. static inline const char *
  32. snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN])
  33. {
  34. return NULL;
  35. }
  36. static inline bool
  37. snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
  38. struct snd_soc_acpi_package_context *ctx)
  39. {
  40. return false;
  41. }
  42. #endif
  43. /* acpi match */
  44. struct snd_soc_acpi_mach *
  45. snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
  46. /* acpi check hid */
  47. bool snd_soc_acpi_check_hid(const u8 hid[ACPI_ID_LEN]);
  48. /**
  49. * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
  50. * related to the hardware, except for the firmware and topology file names.
  51. * A platform supported by legacy and Sound Open Firmware (SOF) would expose
  52. * all firmware/topology related fields.
  53. *
  54. * @id: ACPI ID (usually the codec's) used to find a matching machine driver.
  55. * @drv_name: machine driver name
  56. * @fw_filename: firmware file name. Used when SOF is not enabled.
  57. * @board: board name
  58. * @machine_quirk: pointer to quirk, usually based on DMI information when
  59. * ACPI ID alone is not sufficient, wrong or misleading
  60. * @quirk_data: data used to uniquely identify a machine, usually a list of
  61. * audio codecs whose presence if checked with ACPI
  62. * @pdata: intended for platform data or machine specific-ops. This structure
  63. * is not constant since this field may be updated at run-time
  64. * @sof_fw_filename: Sound Open Firmware file name, if enabled
  65. * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled
  66. * @asoc_plat_name: ASoC platform name, used for binding machine drivers
  67. * if non NULL
  68. * @new_mach_data: machine driver private data fixup
  69. */
  70. /* Descriptor for SST ASoC machine driver */
  71. struct snd_soc_acpi_mach {
  72. const u8 id[ACPI_ID_LEN];
  73. const char *drv_name;
  74. const char *fw_filename;
  75. const char *board;
  76. struct snd_soc_acpi_mach * (*machine_quirk)(void *arg);
  77. const void *quirk_data;
  78. void *pdata;
  79. const char *sof_fw_filename;
  80. const char *sof_tplg_filename;
  81. const char *asoc_plat_name;
  82. struct platform_device * (*new_mach_data)(void *pdata);
  83. };
  84. #define SND_SOC_ACPI_MAX_CODECS 3
  85. /**
  86. * struct snd_soc_acpi_codecs: Structure to hold secondary codec information
  87. * apart from the matched one, this data will be passed to the quirk function
  88. * to match with the ACPI detected devices
  89. *
  90. * @num_codecs: number of secondary codecs used in the platform
  91. * @codecs: holds the codec IDs
  92. *
  93. */
  94. struct snd_soc_acpi_codecs {
  95. int num_codecs;
  96. u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN];
  97. };
  98. /* check all codecs */
  99. struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg);
  100. #endif