dsi_defs.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DSI_DEFS_H_
  6. #define _DSI_DEFS_H_
  7. #include <linux/types.h>
  8. #include <drm/drm_mipi_dsi.h>
  9. #include "msm_drv.h"
  10. #define DSI_H_TOTAL(t) (((t)->h_active) + ((t)->h_back_porch) + \
  11. ((t)->h_sync_width) + ((t)->h_front_porch))
  12. #define DSI_V_TOTAL(t) (((t)->v_active) + ((t)->v_back_porch) + \
  13. ((t)->v_sync_width) + ((t)->v_front_porch))
  14. #define DSI_H_TOTAL_DSC(t) \
  15. ({\
  16. u64 value;\
  17. if ((t)->dsc_enabled && (t)->dsc)\
  18. value = (t)->dsc->pclk_per_line;\
  19. else\
  20. value = (t)->h_active;\
  21. value = value + (t)->h_back_porch + (t)->h_sync_width +\
  22. (t)->h_front_porch;\
  23. value;\
  24. })
  25. #define DSI_H_ACTIVE_DSC(t) \
  26. ({\
  27. u64 value;\
  28. if ((t)->dsc_enabled && (t)->dsc)\
  29. value = (t)->dsc->pclk_per_line;\
  30. else\
  31. value = (t)->h_active;\
  32. value;\
  33. })
  34. #define DSI_DEBUG_NAME_LEN 32
  35. #define display_for_each_ctrl(index, display) \
  36. for (index = 0; (index < (display)->ctrl_count) &&\
  37. (index < MAX_DSI_CTRLS_PER_DISPLAY); index++)
  38. #define DSI_WARN(fmt, ...) DRM_WARN("[msm-dsi-warn]: "fmt, ##__VA_ARGS__)
  39. #define DSI_ERR(fmt, ...) DRM_DEV_ERROR(NULL, "[msm-dsi-error]: " fmt, \
  40. ##__VA_ARGS__)
  41. #define DSI_INFO(fmt, ...) DRM_DEV_INFO(NULL, "[msm-dsi-info]: "fmt, \
  42. ##__VA_ARGS__)
  43. #define DSI_DEBUG(fmt, ...) DRM_DEV_DEBUG(NULL, "[msm-dsi-debug]: "fmt, \
  44. ##__VA_ARGS__)
  45. /**
  46. * enum dsi_pixel_format - DSI pixel formats
  47. * @DSI_PIXEL_FORMAT_RGB565:
  48. * @DSI_PIXEL_FORMAT_RGB666:
  49. * @DSI_PIXEL_FORMAT_RGB666_LOOSE:
  50. * @DSI_PIXEL_FORMAT_RGB888:
  51. * @DSI_PIXEL_FORMAT_RGB111:
  52. * @DSI_PIXEL_FORMAT_RGB332:
  53. * @DSI_PIXEL_FORMAT_RGB444:
  54. * @DSI_PIXEL_FORMAT_MAX:
  55. */
  56. enum dsi_pixel_format {
  57. DSI_PIXEL_FORMAT_RGB565 = 0,
  58. DSI_PIXEL_FORMAT_RGB666,
  59. DSI_PIXEL_FORMAT_RGB666_LOOSE,
  60. DSI_PIXEL_FORMAT_RGB888,
  61. DSI_PIXEL_FORMAT_RGB111,
  62. DSI_PIXEL_FORMAT_RGB332,
  63. DSI_PIXEL_FORMAT_RGB444,
  64. DSI_PIXEL_FORMAT_MAX
  65. };
  66. /**
  67. * enum dsi_op_mode - dsi operation mode
  68. * @DSI_OP_VIDEO_MODE: DSI video mode operation
  69. * @DSI_OP_CMD_MODE: DSI Command mode operation
  70. * @DSI_OP_MODE_MAX:
  71. */
  72. enum dsi_op_mode {
  73. DSI_OP_VIDEO_MODE = 0,
  74. DSI_OP_CMD_MODE,
  75. DSI_OP_MODE_MAX
  76. };
  77. /**
  78. * enum dsi_mode_flags - flags to signal other drm components via private flags
  79. * @DSI_MODE_FLAG_SEAMLESS: Seamless transition requested by user
  80. * @DSI_MODE_FLAG_DFPS: Seamless transition is DynamicFPS
  81. * @DSI_MODE_FLAG_VBLANK_PRE_MODESET: Transition needs VBLANK before Modeset
  82. * @DSI_MODE_FLAG_DMS: Seamless transition is dynamic mode switch
  83. * @DSI_MODE_FLAG_VRR: Seamless transition is DynamicFPS.
  84. * New timing values are sent from DAL.
  85. * @DSI_MODE_FLAG_POMS:
  86. * Seamless transition is dynamic panel operating mode switch
  87. * @DSI_MODE_FLAG_DYN_CLK: Seamless transition is dynamic clock change
  88. * @DSI_MODE_FLAG_DMS_FPS: Seamless fps only transition in Dynamic Mode Switch
  89. */
  90. enum dsi_mode_flags {
  91. DSI_MODE_FLAG_SEAMLESS = BIT(0),
  92. DSI_MODE_FLAG_DFPS = BIT(1),
  93. DSI_MODE_FLAG_VBLANK_PRE_MODESET = BIT(2),
  94. DSI_MODE_FLAG_DMS = BIT(3),
  95. DSI_MODE_FLAG_VRR = BIT(4),
  96. DSI_MODE_FLAG_POMS = BIT(5),
  97. DSI_MODE_FLAG_DYN_CLK = BIT(6),
  98. DSI_MODE_FLAG_DMS_FPS = BIT(7),
  99. };
  100. /**
  101. * enum dsi_logical_lane - dsi logical lanes
  102. * @DSI_LOGICAL_LANE_0: Logical lane 0
  103. * @DSI_LOGICAL_LANE_1: Logical lane 1
  104. * @DSI_LOGICAL_LANE_2: Logical lane 2
  105. * @DSI_LOGICAL_LANE_3: Logical lane 3
  106. * @DSI_LOGICAL_CLOCK_LANE: Clock lane
  107. * @DSI_LANE_MAX: Maximum lanes supported
  108. */
  109. enum dsi_logical_lane {
  110. DSI_LOGICAL_LANE_0 = 0,
  111. DSI_LOGICAL_LANE_1,
  112. DSI_LOGICAL_LANE_2,
  113. DSI_LOGICAL_LANE_3,
  114. DSI_LOGICAL_CLOCK_LANE,
  115. DSI_LANE_MAX
  116. };
  117. /**
  118. * enum dsi_data_lanes - BIT map for DSI data lanes
  119. * This is used to identify the active DSI data lanes for
  120. * various operations like DSI data lane enable/ULPS/clamp
  121. * configurations.
  122. * @DSI_DATA_LANE_0: BIT(DSI_LOGICAL_LANE_0)
  123. * @DSI_DATA_LANE_1: BIT(DSI_LOGICAL_LANE_1)
  124. * @DSI_DATA_LANE_2: BIT(DSI_LOGICAL_LANE_2)
  125. * @DSI_DATA_LANE_3: BIT(DSI_LOGICAL_LANE_3)
  126. * @DSI_CLOCK_LANE: BIT(DSI_LOGICAL_CLOCK_LANE)
  127. */
  128. enum dsi_data_lanes {
  129. DSI_DATA_LANE_0 = BIT(DSI_LOGICAL_LANE_0),
  130. DSI_DATA_LANE_1 = BIT(DSI_LOGICAL_LANE_1),
  131. DSI_DATA_LANE_2 = BIT(DSI_LOGICAL_LANE_2),
  132. DSI_DATA_LANE_3 = BIT(DSI_LOGICAL_LANE_3),
  133. DSI_CLOCK_LANE = BIT(DSI_LOGICAL_CLOCK_LANE)
  134. };
  135. /**
  136. * enum dsi_phy_data_lanes - dsi physical lanes
  137. * used for DSI logical to physical lane mapping
  138. * @DSI_PHYSICAL_LANE_INVALID: Physical lane valid/invalid
  139. * @DSI_PHYSICAL_LANE_0: Physical lane 0
  140. * @DSI_PHYSICAL_LANE_1: Physical lane 1
  141. * @DSI_PHYSICAL_LANE_2: Physical lane 2
  142. * @DSI_PHYSICAL_LANE_3: Physical lane 3
  143. */
  144. enum dsi_phy_data_lanes {
  145. DSI_PHYSICAL_LANE_INVALID = 0,
  146. DSI_PHYSICAL_LANE_0 = BIT(0),
  147. DSI_PHYSICAL_LANE_1 = BIT(1),
  148. DSI_PHYSICAL_LANE_2 = BIT(2),
  149. DSI_PHYSICAL_LANE_3 = BIT(3)
  150. };
  151. enum dsi_lane_map_type_v1 {
  152. DSI_LANE_MAP_0123,
  153. DSI_LANE_MAP_3012,
  154. DSI_LANE_MAP_2301,
  155. DSI_LANE_MAP_1230,
  156. DSI_LANE_MAP_0321,
  157. DSI_LANE_MAP_1032,
  158. DSI_LANE_MAP_2103,
  159. DSI_LANE_MAP_3210,
  160. };
  161. /**
  162. * lane_map: DSI logical <-> physical lane mapping
  163. * lane_map_v1: Lane mapping for DSI controllers < v2.0
  164. * lane_map_v2: Lane mapping for DSI controllers >= 2.0
  165. */
  166. struct dsi_lane_map {
  167. enum dsi_lane_map_type_v1 lane_map_v1;
  168. u8 lane_map_v2[DSI_LANE_MAX - 1];
  169. };
  170. /**
  171. * enum dsi_trigger_type - dsi trigger type
  172. * @DSI_TRIGGER_NONE: No trigger.
  173. * @DSI_TRIGGER_TE: TE trigger.
  174. * @DSI_TRIGGER_SEOF: Start or End of frame.
  175. * @DSI_TRIGGER_SW: Software trigger.
  176. * @DSI_TRIGGER_SW_SEOF: Software trigger and start/end of frame.
  177. * @DSI_TRIGGER_SW_TE: Software and TE triggers.
  178. * @DSI_TRIGGER_MAX: Max trigger values.
  179. */
  180. enum dsi_trigger_type {
  181. DSI_TRIGGER_NONE = 0,
  182. DSI_TRIGGER_TE,
  183. DSI_TRIGGER_SEOF,
  184. DSI_TRIGGER_SW,
  185. DSI_TRIGGER_SW_SEOF,
  186. DSI_TRIGGER_SW_TE,
  187. DSI_TRIGGER_MAX
  188. };
  189. /**
  190. * enum dsi_color_swap_mode - color swap mode
  191. * @DSI_COLOR_SWAP_RGB:
  192. * @DSI_COLOR_SWAP_RBG:
  193. * @DSI_COLOR_SWAP_BGR:
  194. * @DSI_COLOR_SWAP_BRG:
  195. * @DSI_COLOR_SWAP_GRB:
  196. * @DSI_COLOR_SWAP_GBR:
  197. */
  198. enum dsi_color_swap_mode {
  199. DSI_COLOR_SWAP_RGB = 0,
  200. DSI_COLOR_SWAP_RBG,
  201. DSI_COLOR_SWAP_BGR,
  202. DSI_COLOR_SWAP_BRG,
  203. DSI_COLOR_SWAP_GRB,
  204. DSI_COLOR_SWAP_GBR
  205. };
  206. /**
  207. * enum dsi_dfps_type - Dynamic FPS support type
  208. * @DSI_DFPS_NONE: Dynamic FPS is not supported.
  209. * @DSI_DFPS_SUSPEND_RESUME:
  210. * @DSI_DFPS_IMMEDIATE_CLK:
  211. * @DSI_DFPS_IMMEDIATE_HFP:
  212. * @DSI_DFPS_IMMEDIATE_VFP:
  213. * @DSI_DPFS_MAX:
  214. */
  215. enum dsi_dfps_type {
  216. DSI_DFPS_NONE = 0,
  217. DSI_DFPS_SUSPEND_RESUME,
  218. DSI_DFPS_IMMEDIATE_CLK,
  219. DSI_DFPS_IMMEDIATE_HFP,
  220. DSI_DFPS_IMMEDIATE_VFP,
  221. DSI_DFPS_MAX
  222. };
  223. /**
  224. * enum dsi_cmd_set_type - DSI command set type
  225. * @DSI_CMD_SET_PRE_ON: Panel pre on
  226. * @DSI_CMD_SET_ON: Panel on
  227. * @DSI_CMD_SET_POST_ON: Panel post on
  228. * @DSI_CMD_SET_PRE_OFF: Panel pre off
  229. * @DSI_CMD_SET_OFF: Panel off
  230. * @DSI_CMD_SET_POST_OFF: Panel post off
  231. * @DSI_CMD_SET_PRE_RES_SWITCH: Pre resolution switch
  232. * @DSI_CMD_SET_RES_SWITCH: Resolution switch
  233. * @DSI_CMD_SET_POST_RES_SWITCH: Post resolution switch
  234. * @DSI_CMD_SET_CMD_TO_VID_SWITCH: Cmd to video mode switch
  235. * @DSI_CMD_SET_POST_CMD_TO_VID_SWITCH: Post cmd to vid switch
  236. * @DSI_CMD_SET_VID_TO_CMD_SWITCH: Video to cmd mode switch
  237. * @DSI_CMD_SET_POST_VID_TO_CMD_SWITCH: Post vid to cmd switch
  238. * @DSI_CMD_SET_PANEL_STATUS: Panel status
  239. * @DSI_CMD_SET_LP1: Low power mode 1
  240. * @DSI_CMD_SET_LP2: Low power mode 2
  241. * @DSI_CMD_SET_NOLP: Low power mode disable
  242. * @DSI_CMD_SET_PPS: DSC PPS command
  243. * @DSI_CMD_SET_ROI: Panel ROI update
  244. * @DSI_CMD_SET_TIMING_SWITCH: Timing switch
  245. * @DSI_CMD_SET_POST_TIMING_SWITCH: Post timing switch
  246. * @DSI_CMD_SET_QSYNC_ON Enable qsync mode
  247. * @DSI_CMD_SET_QSYNC_OFF Disable qsync mode
  248. * @DSI_CMD_SET_MAX
  249. */
  250. enum dsi_cmd_set_type {
  251. DSI_CMD_SET_PRE_ON = 0,
  252. DSI_CMD_SET_ON,
  253. DSI_CMD_SET_POST_ON,
  254. DSI_CMD_SET_PRE_OFF,
  255. DSI_CMD_SET_OFF,
  256. DSI_CMD_SET_POST_OFF,
  257. DSI_CMD_SET_PRE_RES_SWITCH,
  258. DSI_CMD_SET_RES_SWITCH,
  259. DSI_CMD_SET_POST_RES_SWITCH,
  260. DSI_CMD_SET_CMD_TO_VID_SWITCH,
  261. DSI_CMD_SET_POST_CMD_TO_VID_SWITCH,
  262. DSI_CMD_SET_VID_TO_CMD_SWITCH,
  263. DSI_CMD_SET_POST_VID_TO_CMD_SWITCH,
  264. DSI_CMD_SET_PANEL_STATUS,
  265. DSI_CMD_SET_LP1,
  266. DSI_CMD_SET_LP2,
  267. DSI_CMD_SET_NOLP,
  268. DSI_CMD_SET_PPS,
  269. DSI_CMD_SET_ROI,
  270. DSI_CMD_SET_TIMING_SWITCH,
  271. DSI_CMD_SET_POST_TIMING_SWITCH,
  272. DSI_CMD_SET_QSYNC_ON,
  273. DSI_CMD_SET_QSYNC_OFF,
  274. DSI_CMD_SET_MAX
  275. };
  276. /**
  277. * enum dsi_cmd_set_state - command set state
  278. * @DSI_CMD_SET_STATE_LP: dsi low power mode
  279. * @DSI_CMD_SET_STATE_HS: dsi high speed mode
  280. * @DSI_CMD_SET_STATE_MAX
  281. */
  282. enum dsi_cmd_set_state {
  283. DSI_CMD_SET_STATE_LP = 0,
  284. DSI_CMD_SET_STATE_HS,
  285. DSI_CMD_SET_STATE_MAX
  286. };
  287. /**
  288. * enum dsi_clk_gate_type - Type of clock to be gated.
  289. * @PIXEL_CLK: DSI pixel clock.
  290. * @BYTE_CLK: DSI byte clock.
  291. * @DSI_PHY: DSI PHY.
  292. * @DSI_CLK_ALL: All available DSI clocks
  293. * @DSI_CLK_NONE: None of the clocks should be gated
  294. */
  295. enum dsi_clk_gate_type {
  296. PIXEL_CLK = 1,
  297. BYTE_CLK = 2,
  298. DSI_PHY = 4,
  299. DSI_CLK_ALL = (PIXEL_CLK | BYTE_CLK | DSI_PHY),
  300. DSI_CLK_NONE = 8,
  301. };
  302. /**
  303. * enum dsi_phy_type - DSI phy types
  304. * @DSI_PHY_TYPE_DPHY:
  305. * @DSI_PHY_TYPE_CPHY:
  306. */
  307. enum dsi_phy_type {
  308. DSI_PHY_TYPE_DPHY,
  309. DSI_PHY_TYPE_CPHY
  310. };
  311. /**
  312. * enum dsi_te_mode - dsi te source
  313. * @DSI_TE_ON_DATA_LINK: TE read from DSI link
  314. * @DSI_TE_ON_EXT_PIN: TE signal on an external GPIO
  315. */
  316. enum dsi_te_mode {
  317. DSI_TE_ON_DATA_LINK = 0,
  318. DSI_TE_ON_EXT_PIN,
  319. };
  320. /**
  321. * enum dsi_video_traffic_mode - video mode pixel transmission type
  322. * @DSI_VIDEO_TRAFFIC_SYNC_PULSES: Non-burst mode with sync pulses.
  323. * @DSI_VIDEO_TRAFFIC_SYNC_START_EVENTS: Non-burst mode with sync start events.
  324. * @DSI_VIDEO_TRAFFIC_BURST_MODE: Burst mode using sync start events.
  325. */
  326. enum dsi_video_traffic_mode {
  327. DSI_VIDEO_TRAFFIC_SYNC_PULSES = 0,
  328. DSI_VIDEO_TRAFFIC_SYNC_START_EVENTS,
  329. DSI_VIDEO_TRAFFIC_BURST_MODE,
  330. };
  331. /**
  332. * struct dsi_cmd_desc - description of a dsi command
  333. * @msg: dsi mipi msg packet
  334. * @last_command: indicates whether the cmd is the last one to send
  335. * @post_wait_ms: post wait duration
  336. */
  337. struct dsi_cmd_desc {
  338. struct mipi_dsi_msg msg;
  339. bool last_command;
  340. u32 post_wait_ms;
  341. };
  342. /**
  343. * struct dsi_panel_cmd_set - command set of the panel
  344. * @type: type of the command
  345. * @state: state of the command
  346. * @count: number of cmds
  347. * @ctrl_idx: index of the dsi control
  348. * @cmds: arry of cmds
  349. */
  350. struct dsi_panel_cmd_set {
  351. enum dsi_cmd_set_type type;
  352. enum dsi_cmd_set_state state;
  353. u32 count;
  354. u32 ctrl_idx;
  355. struct dsi_cmd_desc *cmds;
  356. };
  357. /**
  358. * struct dsi_mode_info - video mode information dsi frame
  359. * @h_active: Active width of one frame in pixels.
  360. * @h_back_porch: Horizontal back porch in pixels.
  361. * @h_sync_width: HSYNC width in pixels.
  362. * @h_front_porch: Horizontal fron porch in pixels.
  363. * @h_skew:
  364. * @h_sync_polarity: Polarity of HSYNC (false is active low).
  365. * @v_active: Active height of one frame in lines.
  366. * @v_back_porch: Vertical back porch in lines.
  367. * @v_sync_width: VSYNC width in lines.
  368. * @v_front_porch: Vertical front porch in lines.
  369. * @v_sync_polarity: Polarity of VSYNC (false is active low).
  370. * @refresh_rate: Refresh rate in Hz.
  371. * @clk_rate_hz: DSI bit clock rate per lane in Hz.
  372. * @min_dsi_clk_hz: Min DSI bit clock to transfer in vsync time.
  373. * @mdp_transfer_time_us: Specifies the mdp transfer time for command mode
  374. * panels in microseconds.
  375. * @dsi_transfer_time_us: Specifies dsi transfer time for command mode.
  376. * @dsc_enabled: DSC compression enabled.
  377. * @dsc: DSC compression configuration.
  378. * @roi_caps: Panel ROI capabilities.
  379. */
  380. struct dsi_mode_info {
  381. u32 h_active;
  382. u32 h_back_porch;
  383. u32 h_sync_width;
  384. u32 h_front_porch;
  385. u32 h_skew;
  386. bool h_sync_polarity;
  387. u32 v_active;
  388. u32 v_back_porch;
  389. u32 v_sync_width;
  390. u32 v_front_porch;
  391. bool v_sync_polarity;
  392. u32 refresh_rate;
  393. u64 clk_rate_hz;
  394. u64 min_dsi_clk_hz;
  395. u32 mdp_transfer_time_us;
  396. u32 dsi_transfer_time_us;
  397. bool dsc_enabled;
  398. struct msm_display_dsc_info *dsc;
  399. struct msm_roi_caps roi_caps;
  400. };
  401. /**
  402. * struct dsi_split_link_config - Split Link Configuration
  403. * @split_link_enabled: Split Link Enabled.
  404. * @num_sublinks: Number of sublinks.
  405. * @lanes_per_sublink: Number of lanes per sublink.
  406. */
  407. struct dsi_split_link_config {
  408. bool split_link_enabled;
  409. u32 num_sublinks;
  410. u32 lanes_per_sublink;
  411. };
  412. /**
  413. * struct dsi_host_common_cfg - Host configuration common to video and cmd mode
  414. * @dst_format: Destination pixel format.
  415. * @data_lanes: Physical data lanes to be enabled.
  416. * @num_data_lanes: Number of physical data lanes.
  417. * @bpp: Number of bits per pixel.
  418. * @en_crc_check: Enable CRC checks.
  419. * @en_ecc_check: Enable ECC checks.
  420. * @te_mode: Source for TE signalling.
  421. * @mdp_cmd_trigger: MDP frame update trigger for command mode.
  422. * @dma_cmd_trigger: Command DMA trigger.
  423. * @cmd_trigger_stream: Command mode stream to trigger.
  424. * @swap_mode: DSI color swap mode.
  425. * @bit_swap_read: Is red color bit swapped.
  426. * @bit_swap_green: Is green color bit swapped.
  427. * @bit_swap_blue: Is blue color bit swapped.
  428. * @t_clk_post: Number of byte clock cycles that the transmitter shall
  429. * continue sending after last data lane has transitioned
  430. * to LP mode.
  431. * @t_clk_pre: Number of byte clock cycles that the high spped clock
  432. * shall be driven prior to data lane transitions from LP
  433. * to HS mode.
  434. * @ignore_rx_eot: Ignore Rx EOT packets if set to true.
  435. * @append_tx_eot: Append EOT packets for forward transmissions if set to
  436. * true.
  437. * @ext_bridge_mode: External bridge is connected.
  438. * @force_hs_clk_lane: Send continuous clock to the panel.
  439. * @dsi_split_link_config: Split Link Configuration.
  440. */
  441. struct dsi_host_common_cfg {
  442. enum dsi_pixel_format dst_format;
  443. enum dsi_data_lanes data_lanes;
  444. u8 num_data_lanes;
  445. u8 bpp;
  446. bool en_crc_check;
  447. bool en_ecc_check;
  448. enum dsi_te_mode te_mode;
  449. enum dsi_trigger_type mdp_cmd_trigger;
  450. enum dsi_trigger_type dma_cmd_trigger;
  451. u32 cmd_trigger_stream;
  452. enum dsi_color_swap_mode swap_mode;
  453. bool bit_swap_red;
  454. bool bit_swap_green;
  455. bool bit_swap_blue;
  456. u32 t_clk_post;
  457. u32 t_clk_pre;
  458. bool ignore_rx_eot;
  459. bool append_tx_eot;
  460. bool ext_bridge_mode;
  461. bool force_hs_clk_lane;
  462. struct dsi_split_link_config split_link;
  463. };
  464. /**
  465. * struct dsi_video_engine_cfg - DSI video engine configuration
  466. * @last_line_interleave_en: Allow command mode op interleaved on last line of
  467. * video stream.
  468. * @pulse_mode_hsa_he: Send HSA and HE following VS/VE packet if set to
  469. * true.
  470. * @hfp_lp11_en: Enter low power stop mode (LP-11) during HFP.
  471. * @hbp_lp11_en: Enter low power stop mode (LP-11) during HBP.
  472. * @hsa_lp11_en: Enter low power stop mode (LP-11) during HSA.
  473. * @eof_bllp_lp11_en: Enter low power stop mode (LP-11) during BLLP of
  474. * last line of a frame.
  475. * @bllp_lp11_en: Enter low power stop mode (LP-11) during BLLP.
  476. * @traffic_mode: Traffic mode for video stream.
  477. * @vc_id: Virtual channel identifier.
  478. * @dma_sched_line: Line number, after vactive end, at which command dma
  479. * needs to be triggered.
  480. */
  481. struct dsi_video_engine_cfg {
  482. bool last_line_interleave_en;
  483. bool pulse_mode_hsa_he;
  484. bool hfp_lp11_en;
  485. bool hbp_lp11_en;
  486. bool hsa_lp11_en;
  487. bool eof_bllp_lp11_en;
  488. bool bllp_lp11_en;
  489. bool force_clk_lane_hs;
  490. enum dsi_video_traffic_mode traffic_mode;
  491. u32 vc_id;
  492. u32 dma_sched_line;
  493. };
  494. /**
  495. * struct dsi_cmd_engine_cfg - DSI command engine configuration
  496. * @max_cmd_packets_interleave Maximum number of command mode RGB packets to
  497. * send with in one horizontal blanking period
  498. * of the video mode frame.
  499. * @wr_mem_start: DCS command for write_memory_start.
  500. * @wr_mem_continue: DCS command for write_memory_continue.
  501. * @insert_dcs_command: Insert DCS command as first byte of payload
  502. * of the pixel data.
  503. */
  504. struct dsi_cmd_engine_cfg {
  505. u32 max_cmd_packets_interleave;
  506. u32 wr_mem_start;
  507. u32 wr_mem_continue;
  508. bool insert_dcs_command;
  509. };
  510. /**
  511. * struct dsi_host_config - DSI host configuration parameters.
  512. * @panel_mode: Operation mode for panel (video or cmd mode).
  513. * @common_config: Host configuration common to both Video and Cmd mode.
  514. * @video_engine: Video engine configuration if panel is in video mode.
  515. * @cmd_engine: Cmd engine configuration if panel is in cmd mode.
  516. * @esc_clk_rate_khz: Esc clock frequency in Hz.
  517. * @bit_clk_rate_hz: Bit clock frequency in Hz.
  518. * @bit_clk_rate_hz_override: DSI bit clk rate override from dt/sysfs.
  519. * @video_timing: Video timing information of a frame.
  520. * @lane_map: Mapping between logical and physical lanes.
  521. */
  522. struct dsi_host_config {
  523. enum dsi_op_mode panel_mode;
  524. struct dsi_host_common_cfg common_config;
  525. union {
  526. struct dsi_video_engine_cfg video_engine;
  527. struct dsi_cmd_engine_cfg cmd_engine;
  528. } u;
  529. u64 esc_clk_rate_hz;
  530. u64 bit_clk_rate_hz;
  531. u64 bit_clk_rate_hz_override;
  532. struct dsi_mode_info video_timing;
  533. struct dsi_lane_map lane_map;
  534. };
  535. /**
  536. * struct dsi_display_mode_priv_info - private mode info that will be attached
  537. * with each drm mode
  538. * @cmd_sets: Command sets of the mode
  539. * @phy_timing_val: Phy timing values
  540. * @phy_timing_len: Phy timing array length
  541. * @panel_jitter: Panel jitter for RSC backoff
  542. * @panel_prefill_lines: Panel prefill lines for RSC
  543. * @mdp_transfer_time_us: Specifies the mdp transfer time for command mode
  544. * panels in microseconds.
  545. * @dsi_transfer_time_us: Specifies the dsi transfer time for cmd panels.
  546. * @clk_rate_hz: DSI bit clock per lane in hz.
  547. * @min_dsi_clk_hz: Min dsi clk per lane to transfer frame in vsync time.
  548. * @topology: Topology selected for the panel
  549. * @dsc: DSC compression info
  550. * @dsc_enabled: DSC compression enabled
  551. * @roi_caps: Panel ROI capabilities
  552. */
  553. struct dsi_display_mode_priv_info {
  554. struct dsi_panel_cmd_set cmd_sets[DSI_CMD_SET_MAX];
  555. u32 *phy_timing_val;
  556. u32 phy_timing_len;
  557. u32 panel_jitter_numer;
  558. u32 panel_jitter_denom;
  559. u32 panel_prefill_lines;
  560. u32 mdp_transfer_time_us;
  561. u32 dsi_transfer_time_us;
  562. u64 clk_rate_hz;
  563. u64 min_dsi_clk_hz;
  564. struct msm_display_topology topology;
  565. struct msm_display_dsc_info dsc;
  566. bool dsc_enabled;
  567. struct msm_roi_caps roi_caps;
  568. };
  569. /**
  570. * struct dsi_display_mode - specifies mode for dsi display
  571. * @timing: Timing parameters for the panel.
  572. * @pixel_clk_khz: Pixel clock in Khz.
  573. * @dsi_mode_flags: Flags to signal other drm components via private flags
  574. * @panel_mode: Panel mode
  575. * @priv_info: Mode private info
  576. */
  577. struct dsi_display_mode {
  578. struct dsi_mode_info timing;
  579. u32 pixel_clk_khz;
  580. u32 dsi_mode_flags;
  581. enum dsi_op_mode panel_mode;
  582. struct dsi_display_mode_priv_info *priv_info;
  583. };
  584. /**
  585. * struct dsi_rect - dsi rectangle representation
  586. * Note: sde_rect is also using u16, this must be maintained for memcpy
  587. */
  588. struct dsi_rect {
  589. u16 x;
  590. u16 y;
  591. u16 w;
  592. u16 h;
  593. };
  594. /**
  595. * dsi_rect_intersect - intersect two rectangles
  596. * @r1: first rectangle
  597. * @r2: scissor rectangle
  598. * @result: result rectangle, all 0's on no intersection found
  599. */
  600. void dsi_rect_intersect(const struct dsi_rect *r1,
  601. const struct dsi_rect *r2,
  602. struct dsi_rect *result);
  603. /**
  604. * dsi_rect_is_equal - compares two rects
  605. * @r1: rect value to compare
  606. * @r2: rect value to compare
  607. *
  608. * Returns true if the rects are same
  609. */
  610. static inline bool dsi_rect_is_equal(struct dsi_rect *r1,
  611. struct dsi_rect *r2)
  612. {
  613. return r1->x == r2->x && r1->y == r2->y && r1->w == r2->w &&
  614. r1->h == r2->h;
  615. }
  616. struct dsi_event_cb_info {
  617. uint32_t event_idx;
  618. void *event_usr_ptr;
  619. int (*event_cb)(void *event_usr_ptr,
  620. uint32_t event_idx, uint32_t instance_idx,
  621. uint32_t data0, uint32_t data1,
  622. uint32_t data2, uint32_t data3);
  623. };
  624. /**
  625. * enum dsi_error_status - various dsi errors
  626. * @DSI_FIFO_OVERFLOW: DSI FIFO Overflow error
  627. * @DSI_FIFO_UNDERFLOW: DSI FIFO Underflow error
  628. * @DSI_LP_Rx_TIMEOUT: DSI LP/RX Timeout error
  629. * @DSI_PLL_UNLOCK_ERR: DSI PLL unlock error
  630. */
  631. enum dsi_error_status {
  632. DSI_FIFO_OVERFLOW = 1,
  633. DSI_FIFO_UNDERFLOW,
  634. DSI_LP_Rx_TIMEOUT,
  635. DSI_PLL_UNLOCK_ERR,
  636. DSI_ERR_INTR_ALL,
  637. };
  638. /* structure containing the delays required for dynamic clk */
  639. struct dsi_dyn_clk_delay {
  640. u32 pipe_delay;
  641. u32 pipe_delay2;
  642. u32 pll_delay;
  643. };
  644. /* dynamic refresh control bits */
  645. enum dsi_dyn_clk_control_bits {
  646. DYN_REFRESH_INTF_SEL = 1,
  647. DYN_REFRESH_SYNC_MODE,
  648. DYN_REFRESH_SW_TRIGGER,
  649. DYN_REFRESH_SWI_CTRL,
  650. };
  651. /* convert dsi pixel format into bits per pixel */
  652. static inline int dsi_pixel_format_to_bpp(enum dsi_pixel_format fmt)
  653. {
  654. switch (fmt) {
  655. case DSI_PIXEL_FORMAT_RGB888:
  656. case DSI_PIXEL_FORMAT_MAX:
  657. return 24;
  658. case DSI_PIXEL_FORMAT_RGB666:
  659. case DSI_PIXEL_FORMAT_RGB666_LOOSE:
  660. return 18;
  661. case DSI_PIXEL_FORMAT_RGB565:
  662. return 16;
  663. case DSI_PIXEL_FORMAT_RGB111:
  664. return 3;
  665. case DSI_PIXEL_FORMAT_RGB332:
  666. return 8;
  667. case DSI_PIXEL_FORMAT_RGB444:
  668. return 12;
  669. }
  670. return 24;
  671. }
  672. #endif /* _DSI_DEFS_H_ */