dsi_defs.h 21 KB

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