dsi_defs.h 26 KB

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