mhl.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. /*
  2. * Defines for Mobile High-Definition Link (MHL) interface
  3. *
  4. * Copyright (C) 2015, Samsung Electronics, Co., Ltd.
  5. * Andrzej Hajda <a.hajda@samsung.com>
  6. *
  7. * Based on MHL driver for Android devices.
  8. * Copyright (C) 2013-2014 Silicon Image, Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef __MHL_H__
  15. #define __MHL_H__
  16. #include <linux/types.h>
  17. /* Device Capabilities Registers */
  18. enum {
  19. MHL_DCAP_DEV_STATE,
  20. MHL_DCAP_MHL_VERSION,
  21. MHL_DCAP_CAT,
  22. MHL_DCAP_ADOPTER_ID_H,
  23. MHL_DCAP_ADOPTER_ID_L,
  24. MHL_DCAP_VID_LINK_MODE,
  25. MHL_DCAP_AUD_LINK_MODE,
  26. MHL_DCAP_VIDEO_TYPE,
  27. MHL_DCAP_LOG_DEV_MAP,
  28. MHL_DCAP_BANDWIDTH,
  29. MHL_DCAP_FEATURE_FLAG,
  30. MHL_DCAP_DEVICE_ID_H,
  31. MHL_DCAP_DEVICE_ID_L,
  32. MHL_DCAP_SCRATCHPAD_SIZE,
  33. MHL_DCAP_INT_STAT_SIZE,
  34. MHL_DCAP_RESERVED,
  35. MHL_DCAP_SIZE
  36. };
  37. #define MHL_DCAP_CAT_SINK 0x01
  38. #define MHL_DCAP_CAT_SOURCE 0x02
  39. #define MHL_DCAP_CAT_POWER 0x10
  40. #define MHL_DCAP_CAT_PLIM(x) ((x) << 5)
  41. #define MHL_DCAP_VID_LINK_RGB444 0x01
  42. #define MHL_DCAP_VID_LINK_YCBCR444 0x02
  43. #define MHL_DCAP_VID_LINK_YCBCR422 0x04
  44. #define MHL_DCAP_VID_LINK_PPIXEL 0x08
  45. #define MHL_DCAP_VID_LINK_ISLANDS 0x10
  46. #define MHL_DCAP_VID_LINK_VGA 0x20
  47. #define MHL_DCAP_VID_LINK_16BPP 0x40
  48. #define MHL_DCAP_AUD_LINK_2CH 0x01
  49. #define MHL_DCAP_AUD_LINK_8CH 0x02
  50. #define MHL_DCAP_VT_GRAPHICS 0x00
  51. #define MHL_DCAP_VT_PHOTO 0x02
  52. #define MHL_DCAP_VT_CINEMA 0x04
  53. #define MHL_DCAP_VT_GAMES 0x08
  54. #define MHL_DCAP_SUPP_VT 0x80
  55. #define MHL_DCAP_LD_DISPLAY 0x01
  56. #define MHL_DCAP_LD_VIDEO 0x02
  57. #define MHL_DCAP_LD_AUDIO 0x04
  58. #define MHL_DCAP_LD_MEDIA 0x08
  59. #define MHL_DCAP_LD_TUNER 0x10
  60. #define MHL_DCAP_LD_RECORD 0x20
  61. #define MHL_DCAP_LD_SPEAKER 0x40
  62. #define MHL_DCAP_LD_GUI 0x80
  63. #define MHL_DCAP_LD_ALL 0xFF
  64. #define MHL_DCAP_FEATURE_RCP_SUPPORT 0x01
  65. #define MHL_DCAP_FEATURE_RAP_SUPPORT 0x02
  66. #define MHL_DCAP_FEATURE_SP_SUPPORT 0x04
  67. #define MHL_DCAP_FEATURE_UCP_SEND_SUPPOR 0x08
  68. #define MHL_DCAP_FEATURE_UCP_RECV_SUPPORT 0x10
  69. #define MHL_DCAP_FEATURE_RBP_SUPPORT 0x40
  70. /* Extended Device Capabilities Registers */
  71. enum {
  72. MHL_XDC_ECBUS_SPEEDS,
  73. MHL_XDC_TMDS_SPEEDS,
  74. MHL_XDC_ECBUS_ROLES,
  75. MHL_XDC_LOG_DEV_MAPX,
  76. MHL_XDC_SIZE
  77. };
  78. #define MHL_XDC_ECBUS_S_075 0x01
  79. #define MHL_XDC_ECBUS_S_8BIT 0x02
  80. #define MHL_XDC_ECBUS_S_12BIT 0x04
  81. #define MHL_XDC_ECBUS_D_150 0x10
  82. #define MHL_XDC_ECBUS_D_8BIT 0x20
  83. #define MHL_XDC_TMDS_000 0x00
  84. #define MHL_XDC_TMDS_150 0x01
  85. #define MHL_XDC_TMDS_300 0x02
  86. #define MHL_XDC_TMDS_600 0x04
  87. /* MHL_XDC_ECBUS_ROLES flags */
  88. #define MHL_XDC_DEV_HOST 0x01
  89. #define MHL_XDC_DEV_DEVICE 0x02
  90. #define MHL_XDC_DEV_CHARGER 0x04
  91. #define MHL_XDC_HID_HOST 0x08
  92. #define MHL_XDC_HID_DEVICE 0x10
  93. /* MHL_XDC_LOG_DEV_MAPX flags */
  94. #define MHL_XDC_LD_PHONE 0x01
  95. /* Device Status Registers */
  96. enum {
  97. MHL_DST_CONNECTED_RDY,
  98. MHL_DST_LINK_MODE,
  99. MHL_DST_VERSION,
  100. MHL_DST_SIZE
  101. };
  102. /* Offset of DEVSTAT registers */
  103. #define MHL_DST_OFFSET 0x30
  104. #define MHL_DST_REG(name) (MHL_DST_OFFSET + MHL_DST_##name)
  105. #define MHL_DST_CONN_DCAP_RDY 0x01
  106. #define MHL_DST_CONN_XDEVCAPP_SUPP 0x02
  107. #define MHL_DST_CONN_POW_STAT 0x04
  108. #define MHL_DST_CONN_PLIM_STAT_MASK 0x38
  109. #define MHL_DST_LM_CLK_MODE_MASK 0x07
  110. #define MHL_DST_LM_CLK_MODE_PACKED_PIXEL 0x02
  111. #define MHL_DST_LM_CLK_MODE_NORMAL 0x03
  112. #define MHL_DST_LM_PATH_EN_MASK 0x08
  113. #define MHL_DST_LM_PATH_ENABLED 0x08
  114. #define MHL_DST_LM_PATH_DISABLED 0x00
  115. #define MHL_DST_LM_MUTED_MASK 0x10
  116. /* Extended Device Status Registers */
  117. enum {
  118. MHL_XDS_CURR_ECBUS_MODE,
  119. MHL_XDS_AVLINK_MODE_STATUS,
  120. MHL_XDS_AVLINK_MODE_CONTROL,
  121. MHL_XDS_MULTI_SINK_STATUS,
  122. MHL_XDS_SIZE
  123. };
  124. /* Offset of XDEVSTAT registers */
  125. #define MHL_XDS_OFFSET 0x90
  126. #define MHL_XDS_REG(name) (MHL_XDS_OFFSET + MHL_XDS_##name)
  127. /* MHL_XDS_REG_CURR_ECBUS_MODE flags */
  128. #define MHL_XDS_SLOT_MODE_8BIT 0x00
  129. #define MHL_XDS_SLOT_MODE_6BIT 0x01
  130. #define MHL_XDS_ECBUS_S 0x04
  131. #define MHL_XDS_ECBUS_D 0x08
  132. #define MHL_XDS_LINK_CLOCK_75MHZ 0x00
  133. #define MHL_XDS_LINK_CLOCK_150MHZ 0x10
  134. #define MHL_XDS_LINK_CLOCK_300MHZ 0x20
  135. #define MHL_XDS_LINK_CLOCK_600MHZ 0x30
  136. #define MHL_XDS_LINK_STATUS_NO_SIGNAL 0x00
  137. #define MHL_XDS_LINK_STATUS_CRU_LOCKED 0x01
  138. #define MHL_XDS_LINK_STATUS_TMDS_NORMAL 0x02
  139. #define MHL_XDS_LINK_STATUS_TMDS_RESERVED 0x03
  140. #define MHL_XDS_LINK_RATE_1_5_GBPS 0x00
  141. #define MHL_XDS_LINK_RATE_3_0_GBPS 0x01
  142. #define MHL_XDS_LINK_RATE_6_0_GBPS 0x02
  143. #define MHL_XDS_ATT_CAPABLE 0x08
  144. #define MHL_XDS_SINK_STATUS_1_HPD_LOW 0x00
  145. #define MHL_XDS_SINK_STATUS_1_HPD_HIGH 0x01
  146. #define MHL_XDS_SINK_STATUS_2_HPD_LOW 0x00
  147. #define MHL_XDS_SINK_STATUS_2_HPD_HIGH 0x04
  148. #define MHL_XDS_SINK_STATUS_3_HPD_LOW 0x00
  149. #define MHL_XDS_SINK_STATUS_3_HPD_HIGH 0x10
  150. #define MHL_XDS_SINK_STATUS_4_HPD_LOW 0x00
  151. #define MHL_XDS_SINK_STATUS_4_HPD_HIGH 0x40
  152. /* Interrupt Registers */
  153. enum {
  154. MHL_INT_RCHANGE,
  155. MHL_INT_DCHANGE,
  156. MHL_INT_SIZE
  157. };
  158. /* Offset of DEVSTAT registers */
  159. #define MHL_INT_OFFSET 0x20
  160. #define MHL_INT_REG(name) (MHL_INT_OFFSET + MHL_INT_##name)
  161. #define MHL_INT_RC_DCAP_CHG 0x01
  162. #define MHL_INT_RC_DSCR_CHG 0x02
  163. #define MHL_INT_RC_REQ_WRT 0x04
  164. #define MHL_INT_RC_GRT_WRT 0x08
  165. #define MHL_INT_RC_3D_REQ 0x10
  166. #define MHL_INT_RC_FEAT_REQ 0x20
  167. #define MHL_INT_RC_FEAT_COMPLETE 0x40
  168. #define MHL_INT_DC_EDID_CHG 0x02
  169. enum {
  170. MHL_ACK = 0x33, /* Command or Data byte acknowledge */
  171. MHL_NACK = 0x34, /* Command or Data byte not acknowledge */
  172. MHL_ABORT = 0x35, /* Transaction abort */
  173. MHL_WRITE_STAT = 0xe0, /* Write one status register */
  174. MHL_SET_INT = 0x60, /* Write one interrupt register */
  175. MHL_READ_DEVCAP_REG = 0x61, /* Read one register */
  176. MHL_GET_STATE = 0x62, /* Read CBUS revision level from follower */
  177. MHL_GET_VENDOR_ID = 0x63, /* Read vendor ID value from follower */
  178. MHL_SET_HPD = 0x64, /* Set Hot Plug Detect in follower */
  179. MHL_CLR_HPD = 0x65, /* Clear Hot Plug Detect in follower */
  180. MHL_SET_CAP_ID = 0x66, /* Set Capture ID for downstream device */
  181. MHL_GET_CAP_ID = 0x67, /* Get Capture ID from downstream device */
  182. MHL_MSC_MSG = 0x68, /* VS command to send RCP sub-commands */
  183. MHL_GET_SC1_ERRORCODE = 0x69, /* Get Vendor-Specific error code */
  184. MHL_GET_DDC_ERRORCODE = 0x6A, /* Get DDC channel command error code */
  185. MHL_GET_MSC_ERRORCODE = 0x6B, /* Get MSC command error code */
  186. MHL_WRITE_BURST = 0x6C, /* Write 1-16 bytes to responder's scratchpad */
  187. MHL_GET_SC3_ERRORCODE = 0x6D, /* Get channel 3 command error code */
  188. MHL_WRITE_XSTAT = 0x70, /* Write one extended status register */
  189. MHL_READ_XDEVCAP_REG = 0x71, /* Read one extended devcap register */
  190. /* let the rest of these float, they are software specific */
  191. MHL_READ_EDID_BLOCK,
  192. MHL_SEND_3D_REQ_OR_FEAT_REQ,
  193. MHL_READ_DEVCAP,
  194. MHL_READ_XDEVCAP
  195. };
  196. /* MSC message types */
  197. enum {
  198. MHL_MSC_MSG_RCP = 0x10, /* RCP sub-command */
  199. MHL_MSC_MSG_RCPK = 0x11, /* RCP Acknowledge sub-command */
  200. MHL_MSC_MSG_RCPE = 0x12, /* RCP Error sub-command */
  201. MHL_MSC_MSG_RAP = 0x20, /* Mode Change Warning sub-command */
  202. MHL_MSC_MSG_RAPK = 0x21, /* MCW Acknowledge sub-command */
  203. MHL_MSC_MSG_RBP = 0x22, /* Remote Button Protocol sub-command */
  204. MHL_MSC_MSG_RBPK = 0x23, /* RBP Acknowledge sub-command */
  205. MHL_MSC_MSG_RBPE = 0x24, /* RBP Error sub-command */
  206. MHL_MSC_MSG_UCP = 0x30, /* UCP sub-command */
  207. MHL_MSC_MSG_UCPK = 0x31, /* UCP Acknowledge sub-command */
  208. MHL_MSC_MSG_UCPE = 0x32, /* UCP Error sub-command */
  209. MHL_MSC_MSG_RUSB = 0x40, /* Request USB host role */
  210. MHL_MSC_MSG_RUSBK = 0x41, /* Acknowledge request for USB host role */
  211. MHL_MSC_MSG_RHID = 0x42, /* Request HID host role */
  212. MHL_MSC_MSG_RHIDK = 0x43, /* Acknowledge request for HID host role */
  213. MHL_MSC_MSG_ATT = 0x50, /* Request attention sub-command */
  214. MHL_MSC_MSG_ATTK = 0x51, /* ATT Acknowledge sub-command */
  215. MHL_MSC_MSG_BIST_TRIGGER = 0x60,
  216. MHL_MSC_MSG_BIST_REQUEST_STAT = 0x61,
  217. MHL_MSC_MSG_BIST_READY = 0x62,
  218. MHL_MSC_MSG_BIST_STOP = 0x63,
  219. };
  220. /* RAP action codes */
  221. #define MHL_RAP_POLL 0x00 /* Just do an ack */
  222. #define MHL_RAP_CONTENT_ON 0x10 /* Turn content stream ON */
  223. #define MHL_RAP_CONTENT_OFF 0x11 /* Turn content stream OFF */
  224. #define MHL_RAP_CBUS_MODE_DOWN 0x20
  225. #define MHL_RAP_CBUS_MODE_UP 0x21
  226. /* RAPK status codes */
  227. #define MHL_RAPK_NO_ERR 0x00 /* RAP action recognized & supported */
  228. #define MHL_RAPK_UNRECOGNIZED 0x01 /* Unknown RAP action code received */
  229. #define MHL_RAPK_UNSUPPORTED 0x02 /* Rcvd RAP action code not supported */
  230. #define MHL_RAPK_BUSY 0x03 /* Responder too busy to respond */
  231. /* Bit masks for RCP messages */
  232. #define MHL_RCP_KEY_RELEASED_MASK 0x80
  233. #define MHL_RCP_KEY_ID_MASK 0x7F
  234. /*
  235. * Error status codes for RCPE messages
  236. */
  237. /* No error. (Not allowed in RCPE messages) */
  238. #define MHL_RCPE_STATUS_NO_ERROR 0x00
  239. /* Unsupported/unrecognized key code */
  240. #define MHL_RCPE_STATUS_INEFFECTIVE_KEY_CODE 0x01
  241. /* Responder busy. Initiator may retry message */
  242. #define MHL_RCPE_STATUS_BUSY 0x02
  243. /*
  244. * Error status codes for RBPE messages
  245. */
  246. /* No error. (Not allowed in RBPE messages) */
  247. #define MHL_RBPE_STATUS_NO_ERROR 0x00
  248. /* Unsupported/unrecognized button code */
  249. #define MHL_RBPE_STATUS_INEFFECTIVE_BUTTON_CODE 0x01
  250. /* Responder busy. Initiator may retry message */
  251. #define MHL_RBPE_STATUS_BUSY 0x02
  252. /*
  253. * Error status codes for UCPE messages
  254. */
  255. /* No error. (Not allowed in UCPE messages) */
  256. #define MHL_UCPE_STATUS_NO_ERROR 0x00
  257. /* Unsupported/unrecognized key code */
  258. #define MHL_UCPE_STATUS_INEFFECTIVE_KEY_CODE 0x01
  259. enum mhl_burst_id {
  260. MHL_BURST_ID_3D_VIC = 0x10,
  261. MHL_BURST_ID_3D_DTD = 0x11,
  262. MHL_BURST_ID_HEV_VIC = 0x20,
  263. MHL_BURST_ID_HEV_DTDA = 0x21,
  264. MHL_BURST_ID_HEV_DTDB = 0x22,
  265. MHL_BURST_ID_VC_ASSIGN = 0x38,
  266. MHL_BURST_ID_VC_CONFIRM = 0x39,
  267. MHL_BURST_ID_AUD_DELAY = 0x40,
  268. MHL_BURST_ID_ADT_BURSTID = 0x41,
  269. MHL_BURST_ID_BIST_SETUP = 0x51,
  270. MHL_BURST_ID_BIST_RETURN_STAT = 0x52,
  271. MHL_BURST_ID_EMSC_SUPPORT = 0x61,
  272. MHL_BURST_ID_HID_PAYLOAD = 0x62,
  273. MHL_BURST_ID_BLK_RCV_BUFFER_INFO = 0x63,
  274. MHL_BURST_ID_BITS_PER_PIXEL_FMT = 0x64,
  275. };
  276. struct mhl_burst_blk_rcv_buffer_info {
  277. __be16 id;
  278. __le16 size;
  279. } __packed;
  280. struct mhl3_burst_header {
  281. __be16 id;
  282. u8 checksum;
  283. u8 total_entries;
  284. u8 sequence_index;
  285. } __packed;
  286. struct mhl_burst_bits_per_pixel_fmt {
  287. struct mhl3_burst_header hdr;
  288. u8 num_entries;
  289. struct {
  290. u8 stream_id;
  291. u8 pixel_format;
  292. } __packed desc[0];
  293. } __packed;
  294. struct mhl_burst_emsc_support {
  295. struct mhl3_burst_header hdr;
  296. u8 num_entries;
  297. __be16 burst_id[0];
  298. } __packed;
  299. struct mhl_burst_audio_descr {
  300. struct mhl3_burst_header hdr;
  301. u8 flags;
  302. u8 short_desc[9];
  303. } __packed;
  304. /*
  305. * MHL3 infoframe related definitions
  306. */
  307. #define MHL3_IEEE_OUI 0x7ca61d
  308. #define MHL3_INFOFRAME_SIZE 15
  309. enum mhl3_video_format {
  310. MHL3_VIDEO_FORMAT_NONE,
  311. MHL3_VIDEO_FORMAT_3D,
  312. MHL3_VIDEO_FORMAT_MULTI_VIEW,
  313. MHL3_VIDEO_FORMAT_DUAL_3D
  314. };
  315. enum mhl3_3d_format_type {
  316. MHL3_3D_FORMAT_TYPE_FS, /* frame sequential */
  317. MHL3_3D_FORMAT_TYPE_TB, /* top-bottom */
  318. MHL3_3D_FORMAT_TYPE_LR, /* left-right */
  319. MHL3_3D_FORMAT_TYPE_FS_TB, /* frame sequential, top-bottom */
  320. MHL3_3D_FORMAT_TYPE_FS_LR, /* frame sequential, left-right */
  321. MHL3_3D_FORMAT_TYPE_TB_LR /* top-bottom, left-right */
  322. };
  323. struct mhl3_infoframe {
  324. unsigned char version;
  325. enum mhl3_video_format video_format;
  326. enum mhl3_3d_format_type format_type;
  327. bool sep_audio;
  328. int hev_format;
  329. int av_delay;
  330. };
  331. #endif /* __MHL_H__ */