hdmi.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. /*
  2. * Copyright (C) 2012 Avionic Design GmbH
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sub license,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the
  12. * next paragraph) shall be included in all copies or substantial portions
  13. * of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #ifndef __LINUX_HDMI_H_
  24. #define __LINUX_HDMI_H_
  25. #include <linux/types.h>
  26. #include <linux/device.h>
  27. enum hdmi_infoframe_type {
  28. HDMI_INFOFRAME_TYPE_VENDOR = 0x81,
  29. HDMI_INFOFRAME_TYPE_AVI = 0x82,
  30. HDMI_INFOFRAME_TYPE_SPD = 0x83,
  31. HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
  32. };
  33. #define HDMI_IEEE_OUI 0x000c03
  34. #define HDMI_INFOFRAME_HEADER_SIZE 4
  35. #define HDMI_AVI_INFOFRAME_SIZE 13
  36. #define HDMI_SPD_INFOFRAME_SIZE 25
  37. #define HDMI_AUDIO_INFOFRAME_SIZE 10
  38. #define HDMI_INFOFRAME_SIZE(type) \
  39. (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE)
  40. struct hdmi_any_infoframe {
  41. enum hdmi_infoframe_type type;
  42. unsigned char version;
  43. unsigned char length;
  44. };
  45. enum hdmi_colorspace {
  46. HDMI_COLORSPACE_RGB,
  47. HDMI_COLORSPACE_YUV422,
  48. HDMI_COLORSPACE_YUV444,
  49. HDMI_COLORSPACE_YUV420,
  50. HDMI_COLORSPACE_RESERVED4,
  51. HDMI_COLORSPACE_RESERVED5,
  52. HDMI_COLORSPACE_RESERVED6,
  53. HDMI_COLORSPACE_IDO_DEFINED,
  54. };
  55. enum hdmi_scan_mode {
  56. HDMI_SCAN_MODE_NONE,
  57. HDMI_SCAN_MODE_OVERSCAN,
  58. HDMI_SCAN_MODE_UNDERSCAN,
  59. HDMI_SCAN_MODE_RESERVED,
  60. };
  61. enum hdmi_colorimetry {
  62. HDMI_COLORIMETRY_NONE,
  63. HDMI_COLORIMETRY_ITU_601,
  64. HDMI_COLORIMETRY_ITU_709,
  65. HDMI_COLORIMETRY_EXTENDED,
  66. };
  67. enum hdmi_picture_aspect {
  68. HDMI_PICTURE_ASPECT_NONE,
  69. HDMI_PICTURE_ASPECT_4_3,
  70. HDMI_PICTURE_ASPECT_16_9,
  71. HDMI_PICTURE_ASPECT_RESERVED,
  72. };
  73. enum hdmi_active_aspect {
  74. HDMI_ACTIVE_ASPECT_16_9_TOP = 2,
  75. HDMI_ACTIVE_ASPECT_14_9_TOP = 3,
  76. HDMI_ACTIVE_ASPECT_16_9_CENTER = 4,
  77. HDMI_ACTIVE_ASPECT_PICTURE = 8,
  78. HDMI_ACTIVE_ASPECT_4_3 = 9,
  79. HDMI_ACTIVE_ASPECT_16_9 = 10,
  80. HDMI_ACTIVE_ASPECT_14_9 = 11,
  81. HDMI_ACTIVE_ASPECT_4_3_SP_14_9 = 13,
  82. HDMI_ACTIVE_ASPECT_16_9_SP_14_9 = 14,
  83. HDMI_ACTIVE_ASPECT_16_9_SP_4_3 = 15,
  84. };
  85. enum hdmi_extended_colorimetry {
  86. HDMI_EXTENDED_COLORIMETRY_XV_YCC_601,
  87. HDMI_EXTENDED_COLORIMETRY_XV_YCC_709,
  88. HDMI_EXTENDED_COLORIMETRY_S_YCC_601,
  89. HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601,
  90. HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB,
  91. /* The following EC values are only defined in CEA-861-F. */
  92. HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM,
  93. HDMI_EXTENDED_COLORIMETRY_BT2020,
  94. HDMI_EXTENDED_COLORIMETRY_RESERVED,
  95. };
  96. enum hdmi_quantization_range {
  97. HDMI_QUANTIZATION_RANGE_DEFAULT,
  98. HDMI_QUANTIZATION_RANGE_LIMITED,
  99. HDMI_QUANTIZATION_RANGE_FULL,
  100. HDMI_QUANTIZATION_RANGE_RESERVED,
  101. };
  102. /* non-uniform picture scaling */
  103. enum hdmi_nups {
  104. HDMI_NUPS_UNKNOWN,
  105. HDMI_NUPS_HORIZONTAL,
  106. HDMI_NUPS_VERTICAL,
  107. HDMI_NUPS_BOTH,
  108. };
  109. enum hdmi_ycc_quantization_range {
  110. HDMI_YCC_QUANTIZATION_RANGE_LIMITED,
  111. HDMI_YCC_QUANTIZATION_RANGE_FULL,
  112. };
  113. enum hdmi_content_type {
  114. HDMI_CONTENT_TYPE_GRAPHICS,
  115. HDMI_CONTENT_TYPE_PHOTO,
  116. HDMI_CONTENT_TYPE_CINEMA,
  117. HDMI_CONTENT_TYPE_GAME,
  118. };
  119. struct hdmi_avi_infoframe {
  120. enum hdmi_infoframe_type type;
  121. unsigned char version;
  122. unsigned char length;
  123. enum hdmi_colorspace colorspace;
  124. enum hdmi_scan_mode scan_mode;
  125. enum hdmi_colorimetry colorimetry;
  126. enum hdmi_picture_aspect picture_aspect;
  127. enum hdmi_active_aspect active_aspect;
  128. bool itc;
  129. enum hdmi_extended_colorimetry extended_colorimetry;
  130. enum hdmi_quantization_range quantization_range;
  131. enum hdmi_nups nups;
  132. unsigned char video_code;
  133. enum hdmi_ycc_quantization_range ycc_quantization_range;
  134. enum hdmi_content_type content_type;
  135. unsigned char pixel_repeat;
  136. unsigned short top_bar;
  137. unsigned short bottom_bar;
  138. unsigned short left_bar;
  139. unsigned short right_bar;
  140. };
  141. int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
  142. ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
  143. size_t size);
  144. enum hdmi_spd_sdi {
  145. HDMI_SPD_SDI_UNKNOWN,
  146. HDMI_SPD_SDI_DSTB,
  147. HDMI_SPD_SDI_DVDP,
  148. HDMI_SPD_SDI_DVHS,
  149. HDMI_SPD_SDI_HDDVR,
  150. HDMI_SPD_SDI_DVC,
  151. HDMI_SPD_SDI_DSC,
  152. HDMI_SPD_SDI_VCD,
  153. HDMI_SPD_SDI_GAME,
  154. HDMI_SPD_SDI_PC,
  155. HDMI_SPD_SDI_BD,
  156. HDMI_SPD_SDI_SACD,
  157. HDMI_SPD_SDI_HDDVD,
  158. HDMI_SPD_SDI_PMP,
  159. };
  160. struct hdmi_spd_infoframe {
  161. enum hdmi_infoframe_type type;
  162. unsigned char version;
  163. unsigned char length;
  164. char vendor[8];
  165. char product[16];
  166. enum hdmi_spd_sdi sdi;
  167. };
  168. int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame,
  169. const char *vendor, const char *product);
  170. ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer,
  171. size_t size);
  172. enum hdmi_audio_coding_type {
  173. HDMI_AUDIO_CODING_TYPE_STREAM,
  174. HDMI_AUDIO_CODING_TYPE_PCM,
  175. HDMI_AUDIO_CODING_TYPE_AC3,
  176. HDMI_AUDIO_CODING_TYPE_MPEG1,
  177. HDMI_AUDIO_CODING_TYPE_MP3,
  178. HDMI_AUDIO_CODING_TYPE_MPEG2,
  179. HDMI_AUDIO_CODING_TYPE_AAC_LC,
  180. HDMI_AUDIO_CODING_TYPE_DTS,
  181. HDMI_AUDIO_CODING_TYPE_ATRAC,
  182. HDMI_AUDIO_CODING_TYPE_DSD,
  183. HDMI_AUDIO_CODING_TYPE_EAC3,
  184. HDMI_AUDIO_CODING_TYPE_DTS_HD,
  185. HDMI_AUDIO_CODING_TYPE_MLP,
  186. HDMI_AUDIO_CODING_TYPE_DST,
  187. HDMI_AUDIO_CODING_TYPE_WMA_PRO,
  188. HDMI_AUDIO_CODING_TYPE_CXT,
  189. };
  190. enum hdmi_audio_sample_size {
  191. HDMI_AUDIO_SAMPLE_SIZE_STREAM,
  192. HDMI_AUDIO_SAMPLE_SIZE_16,
  193. HDMI_AUDIO_SAMPLE_SIZE_20,
  194. HDMI_AUDIO_SAMPLE_SIZE_24,
  195. };
  196. enum hdmi_audio_sample_frequency {
  197. HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM,
  198. HDMI_AUDIO_SAMPLE_FREQUENCY_32000,
  199. HDMI_AUDIO_SAMPLE_FREQUENCY_44100,
  200. HDMI_AUDIO_SAMPLE_FREQUENCY_48000,
  201. HDMI_AUDIO_SAMPLE_FREQUENCY_88200,
  202. HDMI_AUDIO_SAMPLE_FREQUENCY_96000,
  203. HDMI_AUDIO_SAMPLE_FREQUENCY_176400,
  204. HDMI_AUDIO_SAMPLE_FREQUENCY_192000,
  205. };
  206. enum hdmi_audio_coding_type_ext {
  207. /* Refer to Audio Coding Type (CT) field in Data Byte 1 */
  208. HDMI_AUDIO_CODING_TYPE_EXT_CT,
  209. /*
  210. * The next three CXT values are defined in CEA-861-E only.
  211. * They do not exist in older versions, and in CEA-861-F they are
  212. * defined as 'Not in use'.
  213. */
  214. HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC,
  215. HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2,
  216. HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND,
  217. /* The following CXT values are only defined in CEA-861-F. */
  218. HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC,
  219. HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_V2,
  220. HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC,
  221. HDMI_AUDIO_CODING_TYPE_EXT_DRA,
  222. HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_SURROUND,
  223. HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC_SURROUND = 10,
  224. };
  225. struct hdmi_audio_infoframe {
  226. enum hdmi_infoframe_type type;
  227. unsigned char version;
  228. unsigned char length;
  229. unsigned char channels;
  230. enum hdmi_audio_coding_type coding_type;
  231. enum hdmi_audio_sample_size sample_size;
  232. enum hdmi_audio_sample_frequency sample_frequency;
  233. enum hdmi_audio_coding_type_ext coding_type_ext;
  234. unsigned char channel_allocation;
  235. unsigned char level_shift_value;
  236. bool downmix_inhibit;
  237. };
  238. int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame);
  239. ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame,
  240. void *buffer, size_t size);
  241. enum hdmi_3d_structure {
  242. HDMI_3D_STRUCTURE_INVALID = -1,
  243. HDMI_3D_STRUCTURE_FRAME_PACKING = 0,
  244. HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE,
  245. HDMI_3D_STRUCTURE_LINE_ALTERNATIVE,
  246. HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL,
  247. HDMI_3D_STRUCTURE_L_DEPTH,
  248. HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH,
  249. HDMI_3D_STRUCTURE_TOP_AND_BOTTOM,
  250. HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF = 8,
  251. };
  252. struct hdmi_vendor_infoframe {
  253. enum hdmi_infoframe_type type;
  254. unsigned char version;
  255. unsigned char length;
  256. unsigned int oui;
  257. u8 vic;
  258. enum hdmi_3d_structure s3d_struct;
  259. unsigned int s3d_ext_data;
  260. };
  261. int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame);
  262. ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
  263. void *buffer, size_t size);
  264. union hdmi_vendor_any_infoframe {
  265. struct {
  266. enum hdmi_infoframe_type type;
  267. unsigned char version;
  268. unsigned char length;
  269. unsigned int oui;
  270. } any;
  271. struct hdmi_vendor_infoframe hdmi;
  272. };
  273. /**
  274. * union hdmi_infoframe - overall union of all abstract infoframe representations
  275. * @any: generic infoframe
  276. * @avi: avi infoframe
  277. * @spd: spd infoframe
  278. * @vendor: union of all vendor infoframes
  279. * @audio: audio infoframe
  280. *
  281. * This is used by the generic pack function. This works since all infoframes
  282. * have the same header which also indicates which type of infoframe should be
  283. * packed.
  284. */
  285. union hdmi_infoframe {
  286. struct hdmi_any_infoframe any;
  287. struct hdmi_avi_infoframe avi;
  288. struct hdmi_spd_infoframe spd;
  289. union hdmi_vendor_any_infoframe vendor;
  290. struct hdmi_audio_infoframe audio;
  291. };
  292. ssize_t
  293. hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size);
  294. int hdmi_infoframe_unpack(union hdmi_infoframe *frame, void *buffer);
  295. void hdmi_infoframe_log(const char *level, struct device *dev,
  296. union hdmi_infoframe *frame);
  297. #endif /* _DRM_HDMI_H */