dsi_defs.h 23 KB

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