dsi_defs.h 20 KB

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