intel_hdmi_audio.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (C) 2016 Intel Corporation
  3. * Authors: Sailaja Bandarupalli <sailaja.bandarupalli@intel.com>
  4. * Ramesh Babu K V <ramesh.babu@intel.com>
  5. * Vaibhav Agarwal <vaibhav.agarwal@intel.com>
  6. * Jerome Anand <jerome.anand@intel.com>
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining
  9. * a copy of this software and associated documentation files
  10. * (the "Software"), to deal in the Software without restriction,
  11. * including without limitation the rights to use, copy, modify, merge,
  12. * publish, distribute, sublicense, and/or sell copies of the Software,
  13. * and to permit persons to whom the Software is furnished to do so,
  14. * subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice (including the
  17. * next paragraph) shall be included in all copies or substantial
  18. * portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  24. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  25. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  26. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  27. * SOFTWARE.
  28. */
  29. #ifndef _INTEL_HDMI_AUDIO_H_
  30. #define _INTEL_HDMI_AUDIO_H_
  31. #include "intel_hdmi_lpe_audio.h"
  32. #define MAX_PB_STREAMS 1
  33. #define MAX_CAP_STREAMS 0
  34. #define BYTES_PER_WORD 0x4
  35. #define INTEL_HAD "HdmiLpeAudio"
  36. /*
  37. * CEA speaker placement:
  38. *
  39. * FL FLC FC FRC FR
  40. *
  41. * LFE
  42. *
  43. * RL RLC RC RRC RR
  44. *
  45. * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M
  46. * corresponds to CEA RL/RR; The SMPTE channel _assignment_ C/LFE is
  47. * swapped to CEA LFE/FC.
  48. */
  49. enum cea_speaker_placement {
  50. FL = (1 << 0), /* Front Left */
  51. FC = (1 << 1), /* Front Center */
  52. FR = (1 << 2), /* Front Right */
  53. FLC = (1 << 3), /* Front Left Center */
  54. FRC = (1 << 4), /* Front Right Center */
  55. RL = (1 << 5), /* Rear Left */
  56. RC = (1 << 6), /* Rear Center */
  57. RR = (1 << 7), /* Rear Right */
  58. RLC = (1 << 8), /* Rear Left Center */
  59. RRC = (1 << 9), /* Rear Right Center */
  60. LFE = (1 << 10), /* Low Frequency Effect */
  61. };
  62. struct cea_channel_speaker_allocation {
  63. int ca_index;
  64. int speakers[8];
  65. /* derived values, just for convenience */
  66. int channels;
  67. int spk_mask;
  68. };
  69. struct channel_map_table {
  70. unsigned char map; /* ALSA API channel map position */
  71. unsigned char cea_slot; /* CEA slot value */
  72. int spk_mask; /* speaker position bit mask */
  73. };
  74. struct pcm_stream_info {
  75. struct snd_pcm_substream *substream;
  76. int substream_refcount;
  77. };
  78. /*
  79. * struct snd_intelhad - intelhad driver structure
  80. *
  81. * @card: ptr to hold card details
  82. * @connected: the monitor connection status
  83. * @stream_info: stream information
  84. * @eld: holds ELD info
  85. * @curr_buf: pointer to hold current active ring buf
  86. * @valid_buf_cnt: ring buffer count for stream
  87. * @had_spinlock: driver lock
  88. * @aes_bits: IEC958 status bits
  89. * @buff_done: id of current buffer done intr
  90. * @dev: platoform device handle
  91. * @chmap: holds channel map info
  92. */
  93. struct snd_intelhad {
  94. struct snd_intelhad_card *card_ctx;
  95. bool connected;
  96. struct pcm_stream_info stream_info;
  97. unsigned char eld[HDMI_MAX_ELD_BYTES];
  98. bool dp_output;
  99. unsigned int aes_bits;
  100. spinlock_t had_spinlock;
  101. struct device *dev;
  102. struct snd_pcm_chmap *chmap;
  103. int tmds_clock_speed;
  104. int link_rate;
  105. int port; /* fixed */
  106. int pipe; /* can change dynamically */
  107. /* ring buffer (BD) position index */
  108. unsigned int bd_head;
  109. /* PCM buffer position indices */
  110. unsigned int pcmbuf_head; /* being processed */
  111. unsigned int pcmbuf_filled; /* to be filled */
  112. unsigned int num_bds; /* number of BDs */
  113. unsigned int period_bytes; /* PCM period size in bytes */
  114. /* internal stuff */
  115. union aud_cfg aud_config; /* AUD_CONFIG reg value cache */
  116. struct work_struct hdmi_audio_wq;
  117. struct mutex mutex; /* for protecting chmap and eld */
  118. bool need_reset;
  119. struct snd_jack *jack;
  120. };
  121. struct snd_intelhad_card {
  122. struct snd_card *card;
  123. struct device *dev;
  124. /* internal stuff */
  125. int irq;
  126. void __iomem *mmio_start;
  127. int num_pipes;
  128. int num_ports;
  129. struct snd_intelhad pcm_ctx[3]; /* one for each port */
  130. };
  131. #endif /* _INTEL_HDMI_AUDIO_ */