dsi_defs.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  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_split_link_config - Split Link Configuration
  394. * @split_link_enabled: Split Link Enabled.
  395. * @num_sublinks: Number of sublinks.
  396. * @lanes_per_sublink: Number of lanes per sublink.
  397. */
  398. struct dsi_split_link_config {
  399. bool split_link_enabled;
  400. u32 num_sublinks;
  401. u32 lanes_per_sublink;
  402. };
  403. /**
  404. * struct dsi_host_common_cfg - Host configuration common to video and cmd mode
  405. * @dst_format: Destination pixel format.
  406. * @data_lanes: Physical data lanes to be enabled.
  407. * @num_data_lanes: Number of physical data lanes.
  408. * @bpp: Number of bits per pixel.
  409. * @en_crc_check: Enable CRC checks.
  410. * @en_ecc_check: Enable ECC checks.
  411. * @te_mode: Source for TE signalling.
  412. * @mdp_cmd_trigger: MDP frame update trigger for command mode.
  413. * @dma_cmd_trigger: Command DMA trigger.
  414. * @cmd_trigger_stream: Command mode stream to trigger.
  415. * @swap_mode: DSI color swap mode.
  416. * @bit_swap_read: Is red color bit swapped.
  417. * @bit_swap_green: Is green color bit swapped.
  418. * @bit_swap_blue: Is blue color bit swapped.
  419. * @t_clk_post: Number of byte clock cycles that the transmitter shall
  420. * continue sending after last data lane has transitioned
  421. * to LP mode.
  422. * @t_clk_pre: Number of byte clock cycles that the high spped clock
  423. * shall be driven prior to data lane transitions from LP
  424. * to HS mode.
  425. * @ignore_rx_eot: Ignore Rx EOT packets if set to true.
  426. * @append_tx_eot: Append EOT packets for forward transmissions if set to
  427. * true.
  428. * @ext_bridge_mode: External bridge is connected.
  429. * @force_hs_clk_lane: Send continuous clock to the panel.
  430. * @dsi_split_link_config: Split Link Configuration.
  431. */
  432. struct dsi_host_common_cfg {
  433. enum dsi_pixel_format dst_format;
  434. enum dsi_data_lanes data_lanes;
  435. u8 num_data_lanes;
  436. u8 bpp;
  437. bool en_crc_check;
  438. bool en_ecc_check;
  439. enum dsi_te_mode te_mode;
  440. enum dsi_trigger_type mdp_cmd_trigger;
  441. enum dsi_trigger_type dma_cmd_trigger;
  442. u32 cmd_trigger_stream;
  443. enum dsi_color_swap_mode swap_mode;
  444. bool bit_swap_red;
  445. bool bit_swap_green;
  446. bool bit_swap_blue;
  447. u32 t_clk_post;
  448. u32 t_clk_pre;
  449. bool ignore_rx_eot;
  450. bool append_tx_eot;
  451. bool ext_bridge_mode;
  452. bool force_hs_clk_lane;
  453. struct dsi_split_link_config split_link;
  454. };
  455. /**
  456. * struct dsi_video_engine_cfg - DSI video engine configuration
  457. * @last_line_interleave_en: Allow command mode op interleaved on last line of
  458. * video stream.
  459. * @pulse_mode_hsa_he: Send HSA and HE following VS/VE packet if set to
  460. * true.
  461. * @hfp_lp11_en: Enter low power stop mode (LP-11) during HFP.
  462. * @hbp_lp11_en: Enter low power stop mode (LP-11) during HBP.
  463. * @hsa_lp11_en: Enter low power stop mode (LP-11) during HSA.
  464. * @eof_bllp_lp11_en: Enter low power stop mode (LP-11) during BLLP of
  465. * last line of a frame.
  466. * @bllp_lp11_en: Enter low power stop mode (LP-11) during BLLP.
  467. * @traffic_mode: Traffic mode for video stream.
  468. * @vc_id: Virtual channel identifier.
  469. * @dma_sched_line: Line number, after vactive end, at which command dma
  470. * needs to be triggered.
  471. */
  472. struct dsi_video_engine_cfg {
  473. bool last_line_interleave_en;
  474. bool pulse_mode_hsa_he;
  475. bool hfp_lp11_en;
  476. bool hbp_lp11_en;
  477. bool hsa_lp11_en;
  478. bool eof_bllp_lp11_en;
  479. bool bllp_lp11_en;
  480. bool force_clk_lane_hs;
  481. enum dsi_video_traffic_mode traffic_mode;
  482. u32 vc_id;
  483. u32 dma_sched_line;
  484. };
  485. /**
  486. * struct dsi_cmd_engine_cfg - DSI command engine configuration
  487. * @max_cmd_packets_interleave Maximum number of command mode RGB packets to
  488. * send with in one horizontal blanking period
  489. * of the video mode frame.
  490. * @wr_mem_start: DCS command for write_memory_start.
  491. * @wr_mem_continue: DCS command for write_memory_continue.
  492. * @insert_dcs_command: Insert DCS command as first byte of payload
  493. * of the pixel data.
  494. */
  495. struct dsi_cmd_engine_cfg {
  496. u32 max_cmd_packets_interleave;
  497. u32 wr_mem_start;
  498. u32 wr_mem_continue;
  499. bool insert_dcs_command;
  500. };
  501. /**
  502. * struct dsi_host_config - DSI host configuration parameters.
  503. * @panel_mode: Operation mode for panel (video or cmd mode).
  504. * @common_config: Host configuration common to both Video and Cmd mode.
  505. * @video_engine: Video engine configuration if panel is in video mode.
  506. * @cmd_engine: Cmd engine configuration if panel is in cmd mode.
  507. * @esc_clk_rate_khz: Esc clock frequency in Hz.
  508. * @bit_clk_rate_hz: Bit clock frequency in Hz.
  509. * @bit_clk_rate_hz_override: DSI bit clk rate override from dt/sysfs.
  510. * @video_timing: Video timing information of a frame.
  511. * @lane_map: Mapping between logical and physical lanes.
  512. */
  513. struct dsi_host_config {
  514. enum dsi_op_mode panel_mode;
  515. struct dsi_host_common_cfg common_config;
  516. union {
  517. struct dsi_video_engine_cfg video_engine;
  518. struct dsi_cmd_engine_cfg cmd_engine;
  519. } u;
  520. u64 esc_clk_rate_hz;
  521. u64 bit_clk_rate_hz;
  522. u64 bit_clk_rate_hz_override;
  523. struct dsi_mode_info video_timing;
  524. struct dsi_lane_map lane_map;
  525. };
  526. /**
  527. * struct dsi_display_mode_priv_info - private mode info that will be attached
  528. * with each drm mode
  529. * @cmd_sets: Command sets of the mode
  530. * @phy_timing_val: Phy timing values
  531. * @phy_timing_len: Phy timing array length
  532. * @panel_jitter: Panel jitter for RSC backoff
  533. * @panel_prefill_lines: Panel prefill lines for RSC
  534. * @mdp_transfer_time_us: Specifies the mdp transfer time for command mode
  535. * panels in microseconds.
  536. * @dsi_transfer_time_us: Specifies the dsi transfer time for cmd panels.
  537. * @clk_rate_hz: DSI bit clock per lane in hz.
  538. * @min_dsi_clk_hz: Min dsi clk per lane to transfer frame in vsync time.
  539. * @topology: Topology selected for the panel
  540. * @dsc: DSC compression info
  541. * @dsc_enabled: DSC compression enabled
  542. * @roi_caps: Panel ROI capabilities
  543. */
  544. struct dsi_display_mode_priv_info {
  545. struct dsi_panel_cmd_set cmd_sets[DSI_CMD_SET_MAX];
  546. u32 *phy_timing_val;
  547. u32 phy_timing_len;
  548. u32 panel_jitter_numer;
  549. u32 panel_jitter_denom;
  550. u32 panel_prefill_lines;
  551. u32 mdp_transfer_time_us;
  552. u32 dsi_transfer_time_us;
  553. u64 clk_rate_hz;
  554. u64 min_dsi_clk_hz;
  555. struct msm_display_topology topology;
  556. struct msm_display_dsc_info dsc;
  557. bool dsc_enabled;
  558. struct msm_roi_caps roi_caps;
  559. };
  560. /**
  561. * struct dsi_display_mode - specifies mode for dsi display
  562. * @timing: Timing parameters for the panel.
  563. * @pixel_clk_khz: Pixel clock in Khz.
  564. * @dsi_mode_flags: Flags to signal other drm components via private flags
  565. * @panel_mode: Panel mode
  566. * @priv_info: Mode private info
  567. */
  568. struct dsi_display_mode {
  569. struct dsi_mode_info timing;
  570. u32 pixel_clk_khz;
  571. u32 dsi_mode_flags;
  572. enum dsi_op_mode panel_mode;
  573. struct dsi_display_mode_priv_info *priv_info;
  574. };
  575. /**
  576. * struct dsi_rect - dsi rectangle representation
  577. * Note: sde_rect is also using u16, this must be maintained for memcpy
  578. */
  579. struct dsi_rect {
  580. u16 x;
  581. u16 y;
  582. u16 w;
  583. u16 h;
  584. };
  585. /**
  586. * dsi_rect_intersect - intersect two rectangles
  587. * @r1: first rectangle
  588. * @r2: scissor rectangle
  589. * @result: result rectangle, all 0's on no intersection found
  590. */
  591. void dsi_rect_intersect(const struct dsi_rect *r1,
  592. const struct dsi_rect *r2,
  593. struct dsi_rect *result);
  594. /**
  595. * dsi_rect_is_equal - compares two rects
  596. * @r1: rect value to compare
  597. * @r2: rect value to compare
  598. *
  599. * Returns true if the rects are same
  600. */
  601. static inline bool dsi_rect_is_equal(struct dsi_rect *r1,
  602. struct dsi_rect *r2)
  603. {
  604. return r1->x == r2->x && r1->y == r2->y && r1->w == r2->w &&
  605. r1->h == r2->h;
  606. }
  607. struct dsi_event_cb_info {
  608. uint32_t event_idx;
  609. void *event_usr_ptr;
  610. int (*event_cb)(void *event_usr_ptr,
  611. uint32_t event_idx, uint32_t instance_idx,
  612. uint32_t data0, uint32_t data1,
  613. uint32_t data2, uint32_t data3);
  614. };
  615. /**
  616. * enum dsi_error_status - various dsi errors
  617. * @DSI_FIFO_OVERFLOW: DSI FIFO Overflow error
  618. * @DSI_FIFO_UNDERFLOW: DSI FIFO Underflow error
  619. * @DSI_LP_Rx_TIMEOUT: DSI LP/RX Timeout error
  620. * @DSI_PLL_UNLOCK_ERR: DSI PLL unlock error
  621. */
  622. enum dsi_error_status {
  623. DSI_FIFO_OVERFLOW = 1,
  624. DSI_FIFO_UNDERFLOW,
  625. DSI_LP_Rx_TIMEOUT,
  626. DSI_PLL_UNLOCK_ERR,
  627. DSI_ERR_INTR_ALL,
  628. };
  629. /* structure containing the delays required for dynamic clk */
  630. struct dsi_dyn_clk_delay {
  631. u32 pipe_delay;
  632. u32 pipe_delay2;
  633. u32 pll_delay;
  634. };
  635. /* dynamic refresh control bits */
  636. enum dsi_dyn_clk_control_bits {
  637. DYN_REFRESH_INTF_SEL = 1,
  638. DYN_REFRESH_SYNC_MODE,
  639. DYN_REFRESH_SW_TRIGGER,
  640. DYN_REFRESH_SWI_CTRL,
  641. };
  642. /* convert dsi pixel format into bits per pixel */
  643. static inline int dsi_pixel_format_to_bpp(enum dsi_pixel_format fmt)
  644. {
  645. switch (fmt) {
  646. case DSI_PIXEL_FORMAT_RGB888:
  647. case DSI_PIXEL_FORMAT_MAX:
  648. return 24;
  649. case DSI_PIXEL_FORMAT_RGB666:
  650. case DSI_PIXEL_FORMAT_RGB666_LOOSE:
  651. return 18;
  652. case DSI_PIXEL_FORMAT_RGB565:
  653. return 16;
  654. case DSI_PIXEL_FORMAT_RGB111:
  655. return 3;
  656. case DSI_PIXEL_FORMAT_RGB332:
  657. return 8;
  658. case DSI_PIXEL_FORMAT_RGB444:
  659. return 12;
  660. }
  661. return 24;
  662. }
  663. #endif /* _DSI_DEFS_H_ */