hda_codec.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Support for Intel High-Definition Audio codec
  4. *
  5. * Copyright 2018 Google LLC
  6. *
  7. * Taken from coreboot file of the same name
  8. */
  9. #ifndef __HDA_CODEC_H_
  10. #define __HDA_CODEC_H_
  11. struct hda_regs;
  12. /**
  13. * struct hda_codec_priv - Private data required by the HDA codec
  14. *
  15. * @regs: HDA registers
  16. * @beep_nid: Node ID of beep node (>0)
  17. */
  18. struct hda_codec_priv {
  19. struct hda_regs *regs;
  20. uint beep_nid;
  21. };
  22. /**
  23. * hda_wait_for_ready() - Wait for the codec to indicate it is ready
  24. *
  25. * @regs: HDA registers
  26. * @return 0 if OK -ETIMEDOUT if codec did not respond in time
  27. */
  28. int hda_wait_for_ready(struct hda_regs *regs);
  29. /**
  30. * hda_wait_for_valid() - Wait for the codec to accept the last command
  31. *
  32. * @regs: HDA registers
  33. * @return 0 if OK -ETIMEDOUT if codec did not respond in time
  34. */
  35. int hda_wait_for_valid(struct hda_regs *regs);
  36. /**
  37. * hda_codec_detect() - Detect which codecs are present
  38. *
  39. * @regs: HDA registers
  40. * @return bit mask of active codecs (0 if none)
  41. * @return 0 if OK, -ve on error
  42. */
  43. int hda_codec_detect(struct hda_regs *regs);
  44. /**
  45. * hda_codecs_init() - Init all codecs
  46. *
  47. * @dev: Sound device
  48. * @regs: HDA registers
  49. * @codec_mask: Mask of codecs to init (bits 3:0)
  50. * @return 0 if OK, -ve on error
  51. */
  52. int hda_codecs_init(struct udevice *dev, struct hda_regs *regs, u32 codec_mask);
  53. /**
  54. * hda_codec_start_beep() - Start beeping
  55. *
  56. * This tells the sound hardware to start a beep. It will continue until stopped
  57. * by sound_stop_beep().
  58. *
  59. * @dev: Sound device
  60. * @frequency_hz: Beep frequency in hertz
  61. * @return if OK, -ve on error
  62. */
  63. int hda_codec_start_beep(struct udevice *dev, int frequency_hz);
  64. /**
  65. * hda_codec_stop_beep() - Stop beeping
  66. *
  67. * This tells the sound hardware to stop a previously started beep.
  68. *
  69. * @dev: Sound device
  70. * @return if OK, -ve on error
  71. */
  72. int hda_codec_stop_beep(struct udevice *dev);
  73. /**
  74. * hda_codec_init() - Set up the HDA codec base address
  75. *
  76. * This should be called at the start of the probe() method.
  77. *
  78. * @dev: Sound device
  79. * @return 0 if OK, -ve on error
  80. */
  81. int hda_codec_init(struct udevice *dev);
  82. /**
  83. * hda_codec_finish_init() - Finish setting up the HDA codec base address
  84. *
  85. * This should be called at the end of the probe() method.
  86. *
  87. * @dev: Sound device
  88. * @return 0 if OK, -ve on error
  89. */
  90. int hda_codec_finish_init(struct udevice *dev);
  91. #endif /* __HDA_CODEC_H_ */