intel_hdmi_lpe_audio.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /*
  2. * intel_hdmi_lpe_audio.h - Intel HDMI LPE audio driver
  3. *
  4. * Copyright (C) 2016 Intel Corp
  5. * Authors: Sailaja Bandarupalli <sailaja.bandarupalli@intel.com>
  6. * Ramesh Babu K V <ramesh.babu@intel.com>
  7. * Vaibhav Agarwal <vaibhav.agarwal@intel.com>
  8. * Jerome Anand <jerome.anand@intel.com>
  9. * Aravind Siddappaji <aravindx.siddappaji@intel.com>
  10. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; version 2 of the License.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. */
  23. #ifndef __INTEL_HDMI_LPE_AUDIO_H
  24. #define __INTEL_HDMI_LPE_AUDIO_H
  25. #define HAD_MIN_CHANNEL 2
  26. #define HAD_MAX_CHANNEL 8
  27. #define HAD_NUM_OF_RING_BUFS 4
  28. /* max 20bit address, aligned to 64 */
  29. #define HAD_MAX_BUFFER ((1024 * 1024 - 1) & ~0x3f)
  30. #define HAD_DEFAULT_BUFFER (600 * 1024) /* default prealloc size */
  31. #define HAD_MAX_PERIODS 256 /* arbitrary, but should suffice */
  32. #define HAD_MIN_PERIODS 1
  33. #define HAD_MAX_PERIOD_BYTES ((HAD_MAX_BUFFER / HAD_MIN_PERIODS) & ~0x3f)
  34. #define HAD_MIN_PERIOD_BYTES 1024 /* might be smaller */
  35. #define HAD_FIFO_SIZE 0 /* fifo not being used */
  36. #define MAX_SPEAKERS 8
  37. #define AUD_SAMPLE_RATE_32 32000
  38. #define AUD_SAMPLE_RATE_44_1 44100
  39. #define AUD_SAMPLE_RATE_48 48000
  40. #define AUD_SAMPLE_RATE_88_2 88200
  41. #define AUD_SAMPLE_RATE_96 96000
  42. #define AUD_SAMPLE_RATE_176_4 176400
  43. #define AUD_SAMPLE_RATE_192 192000
  44. #define HAD_MIN_RATE AUD_SAMPLE_RATE_32
  45. #define HAD_MAX_RATE AUD_SAMPLE_RATE_192
  46. #define DIS_SAMPLE_RATE_25_2 25200
  47. #define DIS_SAMPLE_RATE_27 27000
  48. #define DIS_SAMPLE_RATE_54 54000
  49. #define DIS_SAMPLE_RATE_74_25 74250
  50. #define DIS_SAMPLE_RATE_148_5 148500
  51. #define HAD_REG_WIDTH 0x08
  52. #define HAD_MAX_DIP_WORDS 16
  53. /* DP Link Rates */
  54. #define DP_2_7_GHZ 270000
  55. #define DP_1_62_GHZ 162000
  56. /* Maud Values */
  57. #define AUD_SAMPLE_RATE_32_DP_2_7_MAUD_VAL 1988
  58. #define AUD_SAMPLE_RATE_44_1_DP_2_7_MAUD_VAL 2740
  59. #define AUD_SAMPLE_RATE_48_DP_2_7_MAUD_VAL 2982
  60. #define AUD_SAMPLE_RATE_88_2_DP_2_7_MAUD_VAL 5480
  61. #define AUD_SAMPLE_RATE_96_DP_2_7_MAUD_VAL 5965
  62. #define AUD_SAMPLE_RATE_176_4_DP_2_7_MAUD_VAL 10961
  63. #define HAD_MAX_RATE_DP_2_7_MAUD_VAL 11930
  64. #define AUD_SAMPLE_RATE_32_DP_1_62_MAUD_VAL 3314
  65. #define AUD_SAMPLE_RATE_44_1_DP_1_62_MAUD_VAL 4567
  66. #define AUD_SAMPLE_RATE_48_DP_1_62_MAUD_VAL 4971
  67. #define AUD_SAMPLE_RATE_88_2_DP_1_62_MAUD_VAL 9134
  68. #define AUD_SAMPLE_RATE_96_DP_1_62_MAUD_VAL 9942
  69. #define AUD_SAMPLE_RATE_176_4_DP_1_62_MAUD_VAL 18268
  70. #define HAD_MAX_RATE_DP_1_62_MAUD_VAL 19884
  71. /* Naud Value */
  72. #define DP_NAUD_VAL 32768
  73. /* HDMI Controller register offsets - audio domain common */
  74. /* Base address for below regs = 0x65000 */
  75. enum hdmi_ctrl_reg_offset_common {
  76. AUDIO_HDMI_CONFIG_A = 0x000,
  77. AUDIO_HDMI_CONFIG_B = 0x800,
  78. AUDIO_HDMI_CONFIG_C = 0x900,
  79. };
  80. /* HDMI controller register offsets */
  81. enum hdmi_ctrl_reg_offset {
  82. AUD_CONFIG = 0x0,
  83. AUD_CH_STATUS_0 = 0x08,
  84. AUD_CH_STATUS_1 = 0x0C,
  85. AUD_HDMI_CTS = 0x10,
  86. AUD_N_ENABLE = 0x14,
  87. AUD_SAMPLE_RATE = 0x18,
  88. AUD_BUF_CONFIG = 0x20,
  89. AUD_BUF_CH_SWAP = 0x24,
  90. AUD_BUF_A_ADDR = 0x40,
  91. AUD_BUF_A_LENGTH = 0x44,
  92. AUD_BUF_B_ADDR = 0x48,
  93. AUD_BUF_B_LENGTH = 0x4c,
  94. AUD_BUF_C_ADDR = 0x50,
  95. AUD_BUF_C_LENGTH = 0x54,
  96. AUD_BUF_D_ADDR = 0x58,
  97. AUD_BUF_D_LENGTH = 0x5c,
  98. AUD_CNTL_ST = 0x60,
  99. AUD_HDMI_STATUS = 0x64, /* v2 */
  100. AUD_HDMIW_INFOFR = 0x68, /* v2 */
  101. };
  102. /* Audio configuration */
  103. union aud_cfg {
  104. struct {
  105. u32 aud_en:1;
  106. u32 layout:1; /* LAYOUT[01], see below */
  107. u32 fmt:2;
  108. u32 num_ch:3;
  109. u32 set:1;
  110. u32 flat:1;
  111. u32 val_bit:1;
  112. u32 user_bit:1;
  113. u32 underrun:1; /* 0: send null packets,
  114. * 1: send silence stream
  115. */
  116. u32 packet_mode:1; /* 0: 32bit container, 1: 16bit */
  117. u32 left_align:1; /* 0: MSB bits 0-23, 1: bits 8-31 */
  118. u32 bogus_sample:1; /* bogus sample for odd channels */
  119. u32 dp_modei:1; /* 0: HDMI, 1: DP */
  120. u32 rsvd:16;
  121. } regx;
  122. u32 regval;
  123. };
  124. #define AUD_CONFIG_VALID_BIT (1 << 9)
  125. #define AUD_CONFIG_DP_MODE (1 << 15)
  126. #define AUD_CONFIG_CH_MASK 0x70
  127. #define LAYOUT0 0 /* interleaved stereo */
  128. #define LAYOUT1 1 /* for channels > 2 */
  129. /* Audio Channel Status 0 Attributes */
  130. union aud_ch_status_0 {
  131. struct {
  132. u32 ch_status:1;
  133. u32 lpcm_id:1;
  134. u32 cp_info:1;
  135. u32 format:3;
  136. u32 mode:2;
  137. u32 ctg_code:8;
  138. u32 src_num:4;
  139. u32 ch_num:4;
  140. u32 samp_freq:4; /* CH_STATUS_MAP_XXX */
  141. u32 clk_acc:2;
  142. u32 rsvd:2;
  143. } regx;
  144. u32 regval;
  145. };
  146. /* samp_freq values - Sampling rate as per IEC60958 Ver 3 */
  147. #define CH_STATUS_MAP_32KHZ 0x3
  148. #define CH_STATUS_MAP_44KHZ 0x0
  149. #define CH_STATUS_MAP_48KHZ 0x2
  150. #define CH_STATUS_MAP_88KHZ 0x8
  151. #define CH_STATUS_MAP_96KHZ 0xA
  152. #define CH_STATUS_MAP_176KHZ 0xC
  153. #define CH_STATUS_MAP_192KHZ 0xE
  154. /* Audio Channel Status 1 Attributes */
  155. union aud_ch_status_1 {
  156. struct {
  157. u32 max_wrd_len:1;
  158. u32 wrd_len:3;
  159. u32 rsvd:28;
  160. } regx;
  161. u32 regval;
  162. };
  163. #define MAX_SMPL_WIDTH_20 0x0
  164. #define MAX_SMPL_WIDTH_24 0x1
  165. #define SMPL_WIDTH_16BITS 0x1
  166. #define SMPL_WIDTH_24BITS 0x5
  167. /* CTS register */
  168. union aud_hdmi_cts {
  169. struct {
  170. u32 cts_val:24;
  171. u32 en_cts_prog:1;
  172. u32 rsvd:7;
  173. } regx;
  174. u32 regval;
  175. };
  176. /* N register */
  177. union aud_hdmi_n_enable {
  178. struct {
  179. u32 n_val:24;
  180. u32 en_n_prog:1;
  181. u32 rsvd:7;
  182. } regx;
  183. u32 regval;
  184. };
  185. /* Audio Buffer configurations */
  186. union aud_buf_config {
  187. struct {
  188. u32 audio_fifo_watermark:8;
  189. u32 dma_fifo_watermark:3;
  190. u32 rsvd0:5;
  191. u32 aud_delay:8;
  192. u32 rsvd1:8;
  193. } regx;
  194. u32 regval;
  195. };
  196. #define FIFO_THRESHOLD 0xFE
  197. #define DMA_FIFO_THRESHOLD 0x7
  198. /* Audio Sample Swapping offset */
  199. union aud_buf_ch_swap {
  200. struct {
  201. u32 first_0:3;
  202. u32 second_0:3;
  203. u32 first_1:3;
  204. u32 second_1:3;
  205. u32 first_2:3;
  206. u32 second_2:3;
  207. u32 first_3:3;
  208. u32 second_3:3;
  209. u32 rsvd:8;
  210. } regx;
  211. u32 regval;
  212. };
  213. #define SWAP_LFE_CENTER 0x00fac4c8 /* octal 76543210 */
  214. /* Address for Audio Buffer */
  215. union aud_buf_addr {
  216. struct {
  217. u32 valid:1;
  218. u32 intr_en:1;
  219. u32 rsvd:4;
  220. u32 addr:26;
  221. } regx;
  222. u32 regval;
  223. };
  224. #define AUD_BUF_VALID (1U << 0)
  225. #define AUD_BUF_INTR_EN (1U << 1)
  226. /* Length of Audio Buffer */
  227. union aud_buf_len {
  228. struct {
  229. u32 buf_len:20;
  230. u32 rsvd:12;
  231. } regx;
  232. u32 regval;
  233. };
  234. /* Audio Control State Register offset */
  235. union aud_ctrl_st {
  236. struct {
  237. u32 ram_addr:4;
  238. u32 eld_ack:1;
  239. u32 eld_addr:4;
  240. u32 eld_buf_size:5;
  241. u32 eld_valid:1;
  242. u32 cp_ready:1;
  243. u32 dip_freq:2;
  244. u32 dip_idx:3;
  245. u32 dip_en_sta:4;
  246. u32 rsvd:7;
  247. } regx;
  248. u32 regval;
  249. };
  250. /* Audio HDMI Widget Data Island Packet offset */
  251. union aud_info_frame1 {
  252. struct {
  253. u32 pkt_type:8;
  254. u32 ver_num:8;
  255. u32 len:5;
  256. u32 rsvd:11;
  257. } regx;
  258. u32 regval;
  259. };
  260. #define HDMI_INFO_FRAME_WORD1 0x000a0184
  261. #define DP_INFO_FRAME_WORD1 0x00441b84
  262. /* DIP frame 2 */
  263. union aud_info_frame2 {
  264. struct {
  265. u32 chksum:8;
  266. u32 chnl_cnt:3;
  267. u32 rsvd0:1;
  268. u32 coding_type:4;
  269. u32 smpl_size:2;
  270. u32 smpl_freq:3;
  271. u32 rsvd1:3;
  272. u32 format:8;
  273. } regx;
  274. u32 regval;
  275. };
  276. /* DIP frame 3 */
  277. union aud_info_frame3 {
  278. struct {
  279. u32 chnl_alloc:8;
  280. u32 rsvd0:3;
  281. u32 lsv:4;
  282. u32 dm_inh:1;
  283. u32 rsvd1:16;
  284. } regx;
  285. u32 regval;
  286. };
  287. #define VALID_DIP_WORDS 3
  288. /* AUD_HDMI_STATUS bits */
  289. #define HDMI_AUDIO_UNDERRUN (1U << 31)
  290. #define HDMI_AUDIO_BUFFER_DONE (1U << 29)
  291. /* AUD_HDMI_STATUS register mask */
  292. #define AUD_HDMI_STATUS_MASK_UNDERRUN 0xC0000000
  293. #define AUD_HDMI_STATUS_MASK_SRDBG 0x00000002
  294. #define AUD_HDMI_STATUSG_MASK_FUNCRST 0x00000001
  295. #endif