dsi_defs.h 25 KB

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