dsi_defs.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _DSI_DEFS_H_
  7. #define _DSI_DEFS_H_
  8. #include <linux/types.h>
  9. #include <drm/drm_mipi_dsi.h>
  10. #include "msm_drv.h"
  11. #define DSI_H_TOTAL(t) (((t)->h_active) + ((t)->h_back_porch) + \
  12. ((t)->h_sync_width) + ((t)->h_front_porch))
  13. #define DSI_V_TOTAL(t) (((t)->v_active) + ((t)->v_back_porch) + \
  14. ((t)->v_sync_width) + ((t)->v_front_porch))
  15. #define DSI_H_SCALE(h, s) (DIV_ROUND_UP((h) * (s)->numer, (s)->denom))
  16. #define DSI_DEBUG_NAME_LEN 32
  17. #define display_for_each_ctrl(index, display) \
  18. for (index = 0; (index < (display)->ctrl_count) &&\
  19. (index < MAX_DSI_CTRLS_PER_DISPLAY); index++)
  20. #define DSI_WARN(fmt, ...) DRM_WARN("[msm-dsi-warn]: "fmt, ##__VA_ARGS__)
  21. #define DSI_ERR(fmt, ...) DRM_DEV_ERROR(NULL, "[msm-dsi-error]: " fmt, \
  22. ##__VA_ARGS__)
  23. #define DSI_INFO(fmt, ...) DRM_DEV_INFO(NULL, "[msm-dsi-info]: "fmt, \
  24. ##__VA_ARGS__)
  25. #define DSI_DEBUG(fmt, ...) DRM_DEV_DEBUG(NULL, "[msm-dsi-debug]: "fmt, \
  26. ##__VA_ARGS__)
  27. /**
  28. * enum dsi_pixel_format - DSI pixel formats
  29. * @DSI_PIXEL_FORMAT_RGB565:
  30. * @DSI_PIXEL_FORMAT_RGB666:
  31. * @DSI_PIXEL_FORMAT_RGB666_LOOSE:
  32. * @DSI_PIXEL_FORMAT_RGB888:
  33. * @DSI_PIXEL_FORMAT_RGB111:
  34. * @DSI_PIXEL_FORMAT_RGB332:
  35. * @DSI_PIXEL_FORMAT_RGB444:
  36. * @DSI_PIXEL_FORMAT_RGB101010:
  37. * @DSI_PIXEL_FORMAT_MAX:
  38. */
  39. enum dsi_pixel_format {
  40. DSI_PIXEL_FORMAT_RGB565 = 0,
  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_RGB101010,
  48. DSI_PIXEL_FORMAT_MAX
  49. };
  50. /**
  51. * enum dsi_op_mode - dsi operation mode
  52. * @DSI_OP_VIDEO_MODE: DSI video mode operation
  53. * @DSI_OP_CMD_MODE: DSI Command mode operation
  54. * @DSI_OP_MODE_MAX:
  55. */
  56. enum dsi_op_mode {
  57. DSI_OP_VIDEO_MODE = BIT(0),
  58. DSI_OP_CMD_MODE = BIT(1),
  59. DSI_OP_MODE_MAX = BIT(2),
  60. };
  61. /**
  62. * enum dsi_mode_flags - flags to signal other drm components via private flags
  63. * @DSI_MODE_FLAG_SEAMLESS: Seamless transition requested by user
  64. * @DSI_MODE_FLAG_DFPS: Seamless transition is DynamicFPS
  65. * @DSI_MODE_FLAG_VBLANK_PRE_MODESET: Transition needs VBLANK before Modeset
  66. * @DSI_MODE_FLAG_DMS: Seamless transition is dynamic mode switch
  67. * @DSI_MODE_FLAG_VRR: Seamless transition is DynamicFPS.
  68. * New timing values are sent from DAL.
  69. * @DSI_MODE_FLAG_DYN_CLK: Seamless transition is dynamic clock change
  70. * @DSI_MODE_FLAG_DMS_FPS: Seamless fps only transition in Dynamic Mode Switch
  71. * @DSI_MODE_FLAG_POMS_TO_VID:
  72. * Seamless transition is dynamic panel operating mode switch to video
  73. * @DSI_MODE_FLAG_POMS_TO_CMD:
  74. * Seamless transition is dynamic panel operating mode switch to cmd
  75. * @DSI_MODE_FLAG_NONDSC_BPP_SWITCH: Transition is bpp mode switch without DSC.
  76. */
  77. enum dsi_mode_flags {
  78. DSI_MODE_FLAG_SEAMLESS = BIT(0),
  79. DSI_MODE_FLAG_DFPS = BIT(1),
  80. DSI_MODE_FLAG_VBLANK_PRE_MODESET = BIT(2),
  81. DSI_MODE_FLAG_DMS = BIT(3),
  82. DSI_MODE_FLAG_VRR = BIT(4),
  83. DSI_MODE_FLAG_DYN_CLK = BIT(5),
  84. DSI_MODE_FLAG_DMS_FPS = BIT(6),
  85. DSI_MODE_FLAG_POMS_TO_VID = BIT(7),
  86. DSI_MODE_FLAG_POMS_TO_CMD = BIT(8),
  87. DSI_MODE_FLAG_NONDSC_BPP_SWITCH = BIT(9)
  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_dyn_clk_feature_type - Dynamic clock feature support type
  214. * @DSI_DYN_CLK_TYPE_LEGACY: Constant FPS is not supported
  215. * @DSI_DYN_CLK_TYPE_CONST_FPS_ADJUST_HFP: Constant FPS supported with
  216. * change in hfp
  217. * @DSI_DYN_CLK_TYPE_CONST_FPS_ADJUST_VFP: Constant FPS supported with
  218. * change in vfp
  219. * @DSI_DYN_CLK_TYPE_MAX:
  220. */
  221. enum dsi_dyn_clk_feature_type {
  222. DSI_DYN_CLK_TYPE_LEGACY = 0,
  223. DSI_DYN_CLK_TYPE_CONST_FPS_ADJUST_HFP,
  224. DSI_DYN_CLK_TYPE_CONST_FPS_ADJUST_VFP,
  225. DSI_DYN_CLK_TYPE_MAX
  226. };
  227. /**
  228. * enum dsi_cmd_set_type - DSI command set type
  229. * @DSI_CMD_SET_PRE_ON: Panel pre on
  230. * @DSI_CMD_SET_ON: Panel on
  231. * @DSI_CMD_SET_VID_ON: Video mode panel on
  232. * @DSI_CMD_SET_CMD_ON: Command mode panel on
  233. * @DSI_CMD_SET_POST_ON: Panel post on
  234. * @DSI_CMD_SET_PRE_OFF: Panel pre off
  235. * @DSI_CMD_SET_OFF: Panel off
  236. * @DSI_CMD_SET_POST_OFF: Panel post off
  237. * @DSI_CMD_SET_PRE_RES_SWITCH: Pre resolution switch
  238. * @DSI_CMD_SET_RES_SWITCH: Resolution switch
  239. * @DSI_CMD_SET_POST_RES_SWITCH: Post resolution switch
  240. * @DSI_CMD_SET_VID_SWITCH_IN: Video mode switch in
  241. * @DSI_CMD_SET_VID_SWITCH_OUT: Video mode switch out
  242. * @DSI_CMD_SET_CMD_SWITCH_IN: Cmd mode switch in
  243. * @DSI_CMD_SET_CMD_SWITCH_OUT: Cmd mode switch out
  244. * @DSI_CMD_SET_PANEL_STATUS: Panel status
  245. * @DSI_CMD_SET_LP1: Low power mode 1
  246. * @DSI_CMD_SET_LP2: Low power mode 2
  247. * @DSI_CMD_SET_NOLP: Low power mode disable
  248. * @DSI_CMD_SET_PPS: DSC PPS command
  249. * @DSI_CMD_SET_ROI: Panel ROI update
  250. * @DSI_CMD_SET_TIMING_SWITCH: Timing switch
  251. * @DSI_CMD_SET_POST_TIMING_SWITCH: Post timing switch
  252. * @DSI_CMD_SET_QSYNC_ON Enable qsync mode
  253. * @DSI_CMD_SET_QSYNC_OFF Disable qsync mode
  254. * @DSI_CMD_SET_MAX
  255. */
  256. enum dsi_cmd_set_type {
  257. DSI_CMD_SET_PRE_ON = 0,
  258. DSI_CMD_SET_ON,
  259. DSI_CMD_SET_VID_ON,
  260. DSI_CMD_SET_CMD_ON,
  261. DSI_CMD_SET_POST_ON,
  262. DSI_CMD_SET_PRE_OFF,
  263. DSI_CMD_SET_OFF,
  264. DSI_CMD_SET_POST_OFF,
  265. DSI_CMD_SET_PRE_RES_SWITCH,
  266. DSI_CMD_SET_RES_SWITCH,
  267. DSI_CMD_SET_POST_RES_SWITCH,
  268. DSI_CMD_SET_VID_SWITCH_IN,
  269. DSI_CMD_SET_VID_SWITCH_OUT,
  270. DSI_CMD_SET_CMD_SWITCH_IN,
  271. DSI_CMD_SET_CMD_SWITCH_OUT,
  272. DSI_CMD_SET_PANEL_STATUS,
  273. DSI_CMD_SET_LP1,
  274. DSI_CMD_SET_LP2,
  275. DSI_CMD_SET_NOLP,
  276. DSI_CMD_SET_PPS,
  277. DSI_CMD_SET_ROI,
  278. DSI_CMD_SET_TIMING_SWITCH,
  279. DSI_CMD_SET_POST_TIMING_SWITCH,
  280. DSI_CMD_SET_QSYNC_ON,
  281. DSI_CMD_SET_QSYNC_OFF,
  282. DSI_CMD_SET_MAX
  283. };
  284. /**
  285. * enum dsi_cmd_set_state - command set state
  286. * @DSI_CMD_SET_STATE_LP: dsi low power mode
  287. * @DSI_CMD_SET_STATE_HS: dsi high speed mode
  288. * @DSI_CMD_SET_STATE_MAX
  289. */
  290. enum dsi_cmd_set_state {
  291. DSI_CMD_SET_STATE_LP = 0,
  292. DSI_CMD_SET_STATE_HS,
  293. DSI_CMD_SET_STATE_MAX
  294. };
  295. /**
  296. * enum dsi_clk_gate_type - Type of clock to be gated.
  297. * @PIXEL_CLK: DSI pixel clock.
  298. * @BYTE_CLK: DSI byte clock.
  299. * @DSI_PHY: DSI PHY.
  300. * @DSI_CLK_ALL: All available DSI clocks
  301. * @DSI_CLK_NONE: None of the clocks should be gated
  302. */
  303. enum dsi_clk_gate_type {
  304. PIXEL_CLK = 1,
  305. BYTE_CLK = 2,
  306. DSI_PHY = 4,
  307. DSI_CLK_ALL = (PIXEL_CLK | BYTE_CLK | DSI_PHY),
  308. DSI_CLK_NONE = 8,
  309. };
  310. /**
  311. * enum dsi_phy_type - DSI phy types
  312. * @DSI_PHY_TYPE_DPHY:
  313. * @DSI_PHY_TYPE_CPHY:
  314. */
  315. enum dsi_phy_type {
  316. DSI_PHY_TYPE_DPHY,
  317. DSI_PHY_TYPE_CPHY
  318. };
  319. /**
  320. * enum dsi_te_mode - dsi te source
  321. * @DSI_TE_ON_DATA_LINK: TE read from DSI link
  322. * @DSI_TE_ON_EXT_PIN: TE signal on an external GPIO
  323. */
  324. enum dsi_te_mode {
  325. DSI_TE_ON_DATA_LINK = 0,
  326. DSI_TE_ON_EXT_PIN,
  327. };
  328. /**
  329. * enum dsi_video_traffic_mode - video mode pixel transmission type
  330. * @DSI_VIDEO_TRAFFIC_SYNC_PULSES: Non-burst mode with sync pulses.
  331. * @DSI_VIDEO_TRAFFIC_SYNC_START_EVENTS: Non-burst mode with sync start events.
  332. * @DSI_VIDEO_TRAFFIC_BURST_MODE: Burst mode using sync start events.
  333. */
  334. enum dsi_video_traffic_mode {
  335. DSI_VIDEO_TRAFFIC_SYNC_PULSES = 0,
  336. DSI_VIDEO_TRAFFIC_SYNC_START_EVENTS,
  337. DSI_VIDEO_TRAFFIC_BURST_MODE,
  338. };
  339. /**
  340. * struct dsi_cmd_desc - description of a dsi command
  341. * @msg: dsi mipi msg packet
  342. * @last_command: indicates whether the cmd is the last one to send
  343. * @post_wait_ms: post wait duration
  344. * @ctrl: index of DSI controller
  345. * @ctrl_flags: controller flags
  346. * @ts: dsi command time stamp in nano-seconds.
  347. */
  348. struct dsi_cmd_desc {
  349. struct mipi_dsi_msg msg;
  350. bool last_command;
  351. u32 post_wait_ms;
  352. u32 ctrl;
  353. u32 ctrl_flags;
  354. ktime_t ts;
  355. };
  356. /**
  357. * struct dsi_panel_cmd_set - command set of the panel
  358. * @type: type of the command
  359. * @state: state of the command
  360. * @count: number of cmds
  361. * @ctrl_idx: index of the dsi control
  362. * @cmds: arry of cmds
  363. */
  364. struct dsi_panel_cmd_set {
  365. enum dsi_cmd_set_type type;
  366. enum dsi_cmd_set_state state;
  367. u32 count;
  368. u32 ctrl_idx;
  369. struct dsi_cmd_desc *cmds;
  370. };
  371. /**
  372. * struct dsi_mode_info - video mode information dsi frame
  373. * @h_active: Active width of one frame in pixels.
  374. * @h_back_porch: Horizontal back porch in pixels.
  375. * @h_sync_width: HSYNC width in pixels.
  376. * @h_front_porch: Horizontal fron porch in pixels.
  377. * @h_skew:
  378. * @h_sync_polarity: Polarity of HSYNC (false is active low).
  379. * @v_active: Active height of one frame in lines.
  380. * @v_back_porch: Vertical back porch in lines.
  381. * @v_sync_width: VSYNC width in lines.
  382. * @v_front_porch: Vertical front porch in lines.
  383. * @v_sync_polarity: Polarity of VSYNC (false is active low).
  384. * @refresh_rate: Refresh rate in Hz.
  385. * @clk_rate_hz: DSI bit clock rate per lane in Hz.
  386. * @min_dsi_clk_hz: Min DSI bit clock to transfer in vsync time.
  387. * @mdp_transfer_time_us: Specifies the mdp transfer time for command mode
  388. * panels in microseconds.
  389. * @dsi_transfer_time_us: Specifies dsi transfer time for command mode.
  390. * @dsc_enabled: DSC compression enabled.
  391. * @vdc_enabled: VDC compression enabled.
  392. * @dsc: DSC compression configuration.
  393. * @vdc: VDC compression configuration.
  394. * @pclk_scale: pclk scale factor, target bpp to source bpp
  395. * @roi_caps: Panel ROI capabilities.
  396. * @qsync_min_fps: Qsync min fps rate
  397. * @avr_step_fps: AVR step fps rate
  398. */
  399. struct dsi_mode_info {
  400. u32 h_active;
  401. u32 h_back_porch;
  402. u32 h_sync_width;
  403. u32 h_front_porch;
  404. u32 h_skew;
  405. bool h_sync_polarity;
  406. u32 v_active;
  407. u32 v_back_porch;
  408. u32 v_sync_width;
  409. u32 v_front_porch;
  410. bool v_sync_polarity;
  411. u32 refresh_rate;
  412. u64 clk_rate_hz;
  413. u64 min_dsi_clk_hz;
  414. u32 mdp_transfer_time_us;
  415. u32 dsi_transfer_time_us;
  416. bool dsc_enabled;
  417. bool vdc_enabled;
  418. struct msm_display_dsc_info *dsc;
  419. struct msm_display_vdc_info *vdc;
  420. struct msm_ratio pclk_scale;
  421. struct msm_roi_caps roi_caps;
  422. u32 qsync_min_fps;
  423. u32 avr_step_fps;
  424. };
  425. /**
  426. * struct dsi_split_link_config - Split Link Configuration
  427. * @enabled: Split Link Enabled.
  428. * @sublink_swap: Split link left right sublinks swap.
  429. * @num_sublinks: Number of sublinks.
  430. * @lanes_per_sublink: Number of lanes per sublink.
  431. * @panel_mode: Specifies cmd or video mode.
  432. * @lanes_enabled: Specifies what all lanes are enabled.
  433. */
  434. struct dsi_split_link_config {
  435. bool enabled;
  436. bool sublink_swap;
  437. u32 num_sublinks;
  438. u32 lanes_per_sublink;
  439. u8 lanes_enabled;
  440. enum dsi_op_mode panel_mode;
  441. };
  442. /**
  443. * struct dsi_host_common_cfg - Host configuration common to video and cmd mode
  444. * @dst_format: Destination pixel format.
  445. * @data_lanes: Physical data lanes to be enabled.
  446. * @num_data_lanes: Number of physical data lanes.
  447. * @bpp: Number of bits per pixel.
  448. * @bpp_switch_enabled: Check if bpp switch is enabled without DSC.
  449. * @en_crc_check: Enable CRC checks.
  450. * @en_ecc_check: Enable ECC checks.
  451. * @te_mode: Source for TE signalling.
  452. * @mdp_cmd_trigger: MDP frame update trigger for command mode.
  453. * @dma_cmd_trigger: Command DMA trigger.
  454. * @cmd_trigger_stream: Command mode stream to trigger.
  455. * @swap_mode: DSI color swap mode.
  456. * @bit_swap_read: Is red color bit swapped.
  457. * @bit_swap_green: Is green color bit swapped.
  458. * @bit_swap_blue: Is blue color bit swapped.
  459. * @t_clk_post: Number of byte clock cycles that the transmitter shall
  460. * continue sending after last data lane has transitioned
  461. * to LP mode.
  462. * @t_clk_pre: Number of byte clock cycles that the high spped clock
  463. * shall be driven prior to data lane transitions from LP
  464. * to HS mode.
  465. * @ignore_rx_eot: Ignore Rx EOT packets if set to true.
  466. * @append_tx_eot: Append EOT packets for forward transmissions if set to
  467. * true.
  468. * @ext_bridge_mode: External bridge is connected.
  469. * @force_hs_clk_lane: Send continuous clock to the panel.
  470. * @phy_type: DPHY/CPHY is enabled for this panel.
  471. * @dsi_split_link_config: Split Link Configuration.
  472. * @byte_intf_clk_div: Determines the factor for calculating byte intf clock.
  473. * @dma_sched_line: Line at which dma command gets triggered. In case of
  474. * video mode it is the line number after vactive and for
  475. * cmd it points to the line after TE.
  476. * @dma_sched_window: Determines the width of the window during the
  477. * DSI command will be sent by the HW.
  478. * @vpadding: panel stacking height.
  479. * @line_insertion_enable: line insertion support enable.
  480. */
  481. struct dsi_host_common_cfg {
  482. enum dsi_pixel_format dst_format;
  483. enum dsi_data_lanes data_lanes;
  484. u8 num_data_lanes;
  485. u8 bpp;
  486. bool bpp_switch_enabled;
  487. bool en_crc_check;
  488. bool en_ecc_check;
  489. enum dsi_te_mode te_mode;
  490. enum dsi_trigger_type mdp_cmd_trigger;
  491. enum dsi_trigger_type dma_cmd_trigger;
  492. u32 cmd_trigger_stream;
  493. enum dsi_color_swap_mode swap_mode;
  494. bool bit_swap_red;
  495. bool bit_swap_green;
  496. bool bit_swap_blue;
  497. u32 t_clk_post;
  498. u32 t_clk_pre;
  499. bool ignore_rx_eot;
  500. bool append_tx_eot;
  501. bool ext_bridge_mode;
  502. bool force_hs_clk_lane;
  503. enum dsi_phy_type phy_type;
  504. struct dsi_split_link_config split_link;
  505. u32 byte_intf_clk_div;
  506. u32 dma_sched_line;
  507. u32 dma_sched_window;
  508. u32 vpadding;
  509. bool line_insertion_enable;
  510. };
  511. /**
  512. * struct dsi_video_engine_cfg - DSI video engine configuration
  513. * @last_line_interleave_en: Allow command mode op interleaved on last line of
  514. * video stream.
  515. * @pulse_mode_hsa_he: Send HSA and HE following VS/VE packet if set to
  516. * true.
  517. * @hfp_lp11_en: Enter low power stop mode (LP-11) during HFP.
  518. * @hbp_lp11_en: Enter low power stop mode (LP-11) during HBP.
  519. * @hsa_lp11_en: Enter low power stop mode (LP-11) during HSA.
  520. * @eof_bllp_lp11_en: Enter low power stop mode (LP-11) during BLLP of
  521. * last line of a frame.
  522. * @bllp_lp11_en: Enter low power stop mode (LP-11) during BLLP.
  523. * @traffic_mode: Traffic mode for video stream.
  524. * @vc_id: Virtual channel identifier.
  525. */
  526. struct dsi_video_engine_cfg {
  527. bool last_line_interleave_en;
  528. bool pulse_mode_hsa_he;
  529. bool hfp_lp11_en;
  530. bool hbp_lp11_en;
  531. bool hsa_lp11_en;
  532. bool eof_bllp_lp11_en;
  533. bool bllp_lp11_en;
  534. enum dsi_video_traffic_mode traffic_mode;
  535. u32 vc_id;
  536. };
  537. /**
  538. * struct dsi_cmd_engine_cfg - DSI command engine configuration
  539. * @max_cmd_packets_interleave Maximum number of command mode RGB packets to
  540. * send with in one horizontal blanking period
  541. * of the video mode frame.
  542. * @wr_mem_start: DCS command for write_memory_start.
  543. * @wr_mem_continue: DCS command for write_memory_continue.
  544. * @insert_dcs_command: Insert DCS command as first byte of payload
  545. * of the pixel data.
  546. * @mdp_idle_ctrl_en: Enable idle insertion between command mode mdp packets.
  547. * @mdp_idle_ctrl_len: No. of dsi pclk cycles of idle time to insert between
  548. * command mode mdp packets.
  549. */
  550. struct dsi_cmd_engine_cfg {
  551. u32 max_cmd_packets_interleave;
  552. u32 wr_mem_start;
  553. u32 wr_mem_continue;
  554. bool insert_dcs_command;
  555. bool mdp_idle_ctrl_en;
  556. u32 mdp_idle_ctrl_len;
  557. };
  558. /**
  559. * struct dsi_host_config - DSI host configuration parameters.
  560. * @panel_mode: Operation mode for panel (video or cmd mode).
  561. * @common_config: Host configuration common to both Video and Cmd mode.
  562. * @video_engine: Video engine configuration if panel is in video mode.
  563. * @cmd_engine: Cmd engine configuration if panel is in cmd mode.
  564. * @esc_clk_rate_hz: Esc clock frequency in Hz.
  565. * @bit_clk_rate_hz: Bit clock frequency in Hz.
  566. * @bit_clk_rate_hz_override: DSI bit clk rate override from dt/sysfs.
  567. * @video_timing: Video timing information of a frame.
  568. * @lane_map: Mapping between logical and physical lanes.
  569. */
  570. struct dsi_host_config {
  571. enum dsi_op_mode panel_mode;
  572. struct dsi_host_common_cfg common_config;
  573. union {
  574. struct dsi_video_engine_cfg video_engine;
  575. struct dsi_cmd_engine_cfg cmd_engine;
  576. } u;
  577. u64 esc_clk_rate_hz;
  578. u64 bit_clk_rate_hz;
  579. u64 bit_clk_rate_hz_override;
  580. struct dsi_mode_info video_timing;
  581. struct dsi_lane_map lane_map;
  582. };
  583. /**
  584. * struct dsi_display_mode_priv_info - private mode info that will be attached
  585. * with each drm mode
  586. * @cmd_sets: Command sets of the mode
  587. * @phy_timing_val: Phy timing values
  588. * @phy_timing_len: Phy timing array length
  589. * @panel_jitter: Panel jitter for RSC backoff
  590. * @panel_prefill_lines: Panel prefill lines for RSC
  591. * @mdp_transfer_time_us: Specifies the mdp transfer time for command mode
  592. * panels in microseconds.
  593. * @mdp_transfer_time_us_min: Specifies the minimum possible mdp transfer time
  594. * for command mode panels in microseconds.
  595. * @mdp_transfer_time_us_max: Specifies the maximum possible mdp transfer time
  596. * for command mode panels in microseconds.
  597. * @dsi_transfer_time_us: Specifies the dsi transfer time for cmd panels.
  598. * @qsync_min_fps: Qsync min fps value for the mode
  599. * @avr_step_fps: AVR step fps value for the mode
  600. * @clk_rate_hz: DSI bit clock per lane in hz.
  601. * @min_dsi_clk_hz: Min dsi clk per lane to transfer frame in vsync time.
  602. * @bit_clk_list: List of dynamic bit clock rates supported.
  603. * @topology: Topology selected for the panel
  604. * @dsc: DSC compression info
  605. * @vdc: VDC compression info
  606. * @wd_jitter: WD Jitter config.
  607. * @dsc_enabled: DSC compression enabled
  608. * @vdc_enabled: VDC compression enabled
  609. * @pclk_scale: pclk scale factor, target bpp to source bpp
  610. * @roi_caps: Panel ROI capabilities
  611. * @widebus_support 48 bit wide data bus is supported by hw
  612. * @allowed_mode_switch: BIT mask to mark allowed mode switches
  613. * @disable_rsc_solver: Dynamically disable RSC solver for the timing mode.
  614. */
  615. struct dsi_display_mode_priv_info {
  616. struct dsi_panel_cmd_set cmd_sets[DSI_CMD_SET_MAX];
  617. u32 *phy_timing_val;
  618. u32 phy_timing_len;
  619. u32 panel_jitter_numer;
  620. u32 panel_jitter_denom;
  621. u32 panel_prefill_lines;
  622. u32 mdp_transfer_time_us;
  623. u32 mdp_transfer_time_us_min;
  624. u32 mdp_transfer_time_us_max;
  625. u32 dsi_transfer_time_us;
  626. u32 qsync_min_fps;
  627. u32 avr_step_fps;
  628. u64 clk_rate_hz;
  629. u64 min_dsi_clk_hz;
  630. struct msm_dyn_clk_list bit_clk_list;
  631. struct msm_display_topology topology;
  632. struct msm_display_dsc_info dsc;
  633. struct msm_display_vdc_info vdc;
  634. struct msm_display_wd_jitter_config wd_jitter;
  635. bool dsc_enabled;
  636. bool vdc_enabled;
  637. struct msm_ratio pclk_scale;
  638. struct msm_roi_caps roi_caps;
  639. bool widebus_support;
  640. u32 allowed_mode_switch;
  641. bool disable_rsc_solver;
  642. };
  643. /**
  644. * struct dsi_display_mode - specifies mode for dsi display
  645. * @timing: Timing parameters for the panel.
  646. * @pixel_clk_khz: Pixel clock in Khz.
  647. * @dsi_mode_flags: Flags to signal other drm components via private flags
  648. * @panel_mode_caps: panel mode capabilities.
  649. * @pixel_format_caps: pixel format capabilities.
  650. * @bpp: bits per pixel.
  651. * @is_preferred: Is mode preferred
  652. * @mode_idx: Mode index as defined by devicetree.
  653. * @priv_info: Mode private info
  654. */
  655. struct dsi_display_mode {
  656. struct dsi_mode_info timing;
  657. u32 pixel_clk_khz;
  658. u32 dsi_mode_flags;
  659. u32 panel_mode_caps;
  660. u32 pixel_format_caps;
  661. u32 bpp;
  662. bool is_preferred;
  663. u32 mode_idx;
  664. struct dsi_display_mode_priv_info *priv_info;
  665. };
  666. /**
  667. * struct dsi_rect - dsi rectangle representation
  668. * Note: sde_rect is also using u16, this must be maintained for memcpy
  669. */
  670. struct dsi_rect {
  671. u16 x;
  672. u16 y;
  673. u16 w;
  674. u16 h;
  675. };
  676. /**
  677. * dsi_rect_intersect - intersect two rectangles
  678. * @r1: first rectangle
  679. * @r2: scissor rectangle
  680. * @result: result rectangle, all 0's on no intersection found
  681. */
  682. void dsi_rect_intersect(const struct dsi_rect *r1,
  683. const struct dsi_rect *r2,
  684. struct dsi_rect *result);
  685. /**
  686. * dsi_rect_is_equal - compares two rects
  687. * @r1: rect value to compare
  688. * @r2: rect value to compare
  689. *
  690. * Returns true if the rects are same
  691. */
  692. static inline bool dsi_rect_is_equal(struct dsi_rect *r1,
  693. struct dsi_rect *r2)
  694. {
  695. return r1->x == r2->x && r1->y == r2->y && r1->w == r2->w &&
  696. r1->h == r2->h;
  697. }
  698. struct dsi_event_cb_info {
  699. uint32_t event_idx;
  700. void *event_usr_ptr;
  701. int (*event_cb)(void *event_usr_ptr,
  702. uint32_t event_idx, uint32_t instance_idx,
  703. uint32_t data0, uint32_t data1,
  704. uint32_t data2, uint32_t data3);
  705. };
  706. /**
  707. * enum dsi_error_status - various dsi errors
  708. * @DSI_FIFO_OVERFLOW: DSI FIFO Overflow error
  709. * @DSI_FIFO_UNDERFLOW: DSI FIFO Underflow error
  710. * @DSI_LP_Rx_TIMEOUT: DSI LP/RX Timeout error
  711. * @DSI_PLL_UNLOCK_ERR: DSI PLL unlock error
  712. */
  713. enum dsi_error_status {
  714. DSI_FIFO_OVERFLOW = 1,
  715. DSI_FIFO_UNDERFLOW,
  716. DSI_LP_Rx_TIMEOUT,
  717. DSI_PLL_UNLOCK_ERR,
  718. DSI_ERR_INTR_ALL,
  719. };
  720. /* structure containing the delays required for dynamic clk */
  721. struct dsi_dyn_clk_delay {
  722. u32 pipe_delay;
  723. u32 pipe_delay2;
  724. u32 pll_delay;
  725. };
  726. /* dynamic refresh control bits */
  727. enum dsi_dyn_clk_control_bits {
  728. DYN_REFRESH_INTF_SEL = 1,
  729. DYN_REFRESH_SYNC_MODE,
  730. DYN_REFRESH_SW_TRIGGER,
  731. DYN_REFRESH_SWI_CTRL,
  732. };
  733. /* convert dsi pixel format into bits per pixel */
  734. static inline int dsi_pixel_format_to_bpp(enum dsi_pixel_format fmt)
  735. {
  736. switch (fmt) {
  737. case DSI_PIXEL_FORMAT_RGB888:
  738. case DSI_PIXEL_FORMAT_MAX:
  739. return 24;
  740. case DSI_PIXEL_FORMAT_RGB666:
  741. case DSI_PIXEL_FORMAT_RGB666_LOOSE:
  742. return 18;
  743. case DSI_PIXEL_FORMAT_RGB565:
  744. return 16;
  745. case DSI_PIXEL_FORMAT_RGB111:
  746. return 3;
  747. case DSI_PIXEL_FORMAT_RGB332:
  748. return 8;
  749. case DSI_PIXEL_FORMAT_RGB444:
  750. return 12;
  751. case DSI_PIXEL_FORMAT_RGB101010:
  752. return 30;
  753. }
  754. return 24;
  755. }
  756. static inline u64 dsi_h_active_dce(struct dsi_mode_info *mode)
  757. {
  758. u64 h_active = 0;
  759. if (mode->dsc_enabled && mode->dsc)
  760. h_active = mode->dsc->pclk_per_line;
  761. else if (mode->vdc_enabled && mode->vdc)
  762. h_active = mode->vdc->pclk_per_line;
  763. else
  764. h_active = mode->h_active;
  765. return h_active;
  766. }
  767. static inline u64 dsi_h_total_dce(struct dsi_mode_info *mode)
  768. {
  769. u64 h_total = dsi_h_active_dce(mode);
  770. h_total += mode->h_back_porch + mode->h_front_porch +
  771. mode->h_sync_width;
  772. return h_total;
  773. }
  774. /*
  775. * dsi_is_type_cphy - check if panel type is cphy
  776. * @cfg: Pointer to dsi host common cfg
  777. * Returns: True if panel type is cphy
  778. */
  779. static inline bool dsi_is_type_cphy(struct dsi_host_common_cfg *cfg)
  780. {
  781. return (cfg->phy_type == DSI_PHY_TYPE_CPHY) ? true : false;
  782. }
  783. /**
  784. * dsi_host_transfer_sub() - transfers DSI commands from host to panel
  785. * @host: pointer to the DSI mipi host device
  786. * @cmd: DSI command to be transferred
  787. *
  788. * Return: error code.
  789. */
  790. int dsi_host_transfer_sub(struct mipi_dsi_host *host, struct dsi_cmd_desc *cmd);
  791. #endif /* _DSI_DEFS_H_ */