dsi_display.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _DSI_DISPLAY_H_
  7. #define _DSI_DISPLAY_H_
  8. #include <linux/types.h>
  9. #include <linux/bitops.h>
  10. #include <linux/debugfs.h>
  11. #include <linux/of_device.h>
  12. #include <linux/firmware.h>
  13. #include <linux/ktime.h>
  14. #include <drm/drm_crtc.h>
  15. #include <drm/drm_bridge.h>
  16. #include "msm_drv.h"
  17. #include "dsi_defs.h"
  18. #include "dsi_ctrl.h"
  19. #include "dsi_phy.h"
  20. #include "dsi_panel.h"
  21. #define MAX_DSI_CTRLS_PER_DISPLAY 2
  22. #define DSI_CLIENT_NAME_SIZE 20
  23. #define MAX_CMDLINE_PARAM_LEN 512
  24. #define MAX_CMD_PAYLOAD_SIZE 256
  25. #define DSI_MODE_MATCH_ACTIVE_TIMINGS (1 << 0)
  26. #define DSI_MODE_MATCH_PORCH_TIMINGS (1 << 1)
  27. #define DSI_MODE_MATCH_FULL_TIMINGS (DSI_MODE_MATCH_ACTIVE_TIMINGS | DSI_MODE_MATCH_PORCH_TIMINGS)
  28. #define DSI_MODE_MATCH_DSC_CONFIG (1 << 2)
  29. #define DSI_MODE_MATCH_NONDSC_BPP_CONFIG (1 << 3)
  30. /*
  31. * DSI Validate Mode modifiers
  32. * @DSI_VALIDATE_FLAG_ALLOW_ADJUST: Allow mode validation to also do fixup
  33. */
  34. #define DSI_VALIDATE_FLAG_ALLOW_ADJUST 0x1
  35. /**
  36. * enum dsi_display_selection_type - enumerates DSI display selection types
  37. * @DSI_PRIMARY: primary DSI display selected from module parameter
  38. * @DSI_SECONDARY: Secondary DSI display selected from module parameter
  39. * @MAX_DSI_ACTIVE_DISPLAY: Maximum acive displays that can be selected
  40. */
  41. enum dsi_display_selection_type {
  42. DSI_PRIMARY = 0,
  43. DSI_SECONDARY,
  44. MAX_DSI_ACTIVE_DISPLAY,
  45. };
  46. /**
  47. * enum dsi_display_type - enumerates DSI display types
  48. * @DSI_DISPLAY_SINGLE: A panel connected on a single DSI interface.
  49. * @DSI_DISPLAY_EXT_BRIDGE: A bridge is connected between panel and DSI host.
  50. * It utilizes a single DSI interface.
  51. * @DSI_DISPLAY_SPLIT: A panel that utilizes more than one DSI
  52. * interfaces.
  53. * @DSI_DISPLAY_SPLIT_EXT_BRIDGE: A bridge is present between panel and DSI
  54. * host. It utilizes more than one DSI interface.
  55. */
  56. enum dsi_display_type {
  57. DSI_DISPLAY_SINGLE = 0,
  58. DSI_DISPLAY_EXT_BRIDGE,
  59. DSI_DISPLAY_SPLIT,
  60. DSI_DISPLAY_SPLIT_EXT_BRIDGE,
  61. DSI_DISPLAY_MAX,
  62. };
  63. /**
  64. * struct dsi_display_ctrl - dsi ctrl/phy information for the display
  65. * @ctrl: Handle to the DSI controller device.
  66. * @ctrl_of_node: pHandle to the DSI controller device.
  67. * @dsi_ctrl_idx: DSI controller instance id.
  68. * @power_state: Current power state of the DSI controller.
  69. * @phy: Handle to the DSI PHY device.
  70. * @phy_of_node: pHandle to the DSI PHY device.
  71. * @phy_enabled: PHY power status.
  72. */
  73. struct dsi_display_ctrl {
  74. /* controller info */
  75. struct dsi_ctrl *ctrl;
  76. struct device_node *ctrl_of_node;
  77. u32 dsi_ctrl_idx;
  78. enum dsi_power_state power_state;
  79. /* phy info */
  80. struct msm_dsi_phy *phy;
  81. struct device_node *phy_of_node;
  82. bool phy_enabled;
  83. };
  84. /**
  85. * struct dsi_display_boot_param - defines DSI boot display selection
  86. * @name:Name of DSI display selected as a boot param.
  87. * @boot_disp_en:bool to indicate dtsi availability of display node
  88. * @is_primary:bool to indicate whether current display is primary display
  89. * @length:length of DSI display.
  90. * @cmdline_topology: Display topology shared from kernel command line.
  91. */
  92. struct dsi_display_boot_param {
  93. char name[MAX_CMDLINE_PARAM_LEN];
  94. char *boot_param;
  95. bool boot_disp_en;
  96. int length;
  97. struct device_node *node;
  98. int cmdline_topology;
  99. void *disp;
  100. };
  101. /**
  102. * struct dsi_display_clk_info - dsi display clock source information
  103. * @pll_clks: PLL clocks for DSI.
  104. */
  105. struct dsi_display_clk_info {
  106. struct dsi_clk_link_set pll_clks;
  107. };
  108. /**
  109. * struct dsi_display_ext_bridge - dsi display external bridge information
  110. * @display: Pointer of DSI display.
  111. * @node_of: Bridge node created from bridge driver.
  112. * @bridge: Bridge created from bridge driver
  113. * @orig_funcs: Bridge function from bridge driver (split mode only)
  114. * @bridge_funcs: Overridden function from bridge driver (split mode only)
  115. */
  116. struct dsi_display_ext_bridge {
  117. void *display;
  118. struct device_node *node_of;
  119. struct drm_bridge *bridge;
  120. const struct drm_bridge_funcs *orig_funcs;
  121. struct drm_bridge_funcs bridge_funcs;
  122. };
  123. /**
  124. * struct dsi_display - dsi display information
  125. * @pdev: Pointer to platform device.
  126. * @drm_dev: DRM device associated with the display.
  127. * @drm_conn: Pointer to DRM connector associated with the display
  128. * @ext_conn: Pointer to external connector attached to DSI connector
  129. * @name: Name of the display.
  130. * @display_type: Display type as defined in device tree.
  131. * @list: List pointer.
  132. * @is_active: Is display active.
  133. * @is_cont_splash_enabled: Is continuous splash enabled
  134. * @sw_te_using_wd: Is software te enabled
  135. * @display_lock: Mutex for dsi_display interface.
  136. * @disp_te_gpio: GPIO for panel TE interrupt.
  137. * @is_spurious_interrupt: bool to specify spurious interrupt.
  138. * @is_te_irq_enabled:bool to specify whether TE interrupt is enabled.
  139. * @esd_te_gate: completion gate to signal TE interrupt.
  140. * @ctrl_count: Number of DSI interfaces required by panel.
  141. * @ctrl: Controller information for DSI display.
  142. * @panel: Handle to DSI panel.
  143. * @panel_node: pHandle to DSI panel actually in use.
  144. * @ext_bridge: External bridge information for DSI display.
  145. * @ext_bridge_cnt: Number of external bridges
  146. * @modes: Array of probed DSI modes
  147. * @type: DSI display type.
  148. * @clk_master_idx: The master controller for controlling clocks. This is an
  149. * index into the ctrl[MAX_DSI_CTRLS_PER_DISPLAY] array.
  150. * @cmd_master_idx: The master controller for sending DSI commands to panel.
  151. * @video_master_idx: The master controller for enabling video engine.
  152. * @dyn_bit_clk: The DSI bit clock rate dynamically set by user mode client.
  153. * @dyn_bit_clk_pending: Flag indicating the pending DSI dynamic bit clock rate change.
  154. * @cached_clk_rate: The cached DSI clock rate set dynamically by sysfs.
  155. * @clkrate_change_pending: Flag indicating the pending DSI clock re-enabling.
  156. * @clock_info: Clock sourcing for DSI display.
  157. * @config: DSI host configuration information.
  158. * @lane_map: Lane mapping between DSI host and Panel.
  159. * @cmdline_topology: Display topology shared from kernel command line.
  160. * @cmdline_timing: Display timing shared from kernel command line.
  161. * @is_tpg_enabled: TPG state.
  162. * @poms_pending; Flag indicating the pending panel operating mode switch.
  163. * @ulps_enabled: ulps state.
  164. * @clamp_enabled: clamp state.
  165. * @phy_idle_power_off: PHY power state.
  166. * @host: DRM MIPI DSI Host.
  167. * @bridge: Pointer to DRM bridge object.
  168. * @cmd_engine_refcount: Reference count enforcing single instance of cmd eng
  169. * @clk_mngr: DSI clock manager.
  170. * @dsi_clk_handle: DSI clock handle.
  171. * @mdp_clk_handle: MDP clock handle.
  172. * @root: Debugfs root directory
  173. * @misr_enable Frame MISR enable/disable
  174. * @misr_frame_count Number of frames to accumulate the MISR value
  175. * @esd_trigger field indicating ESD trigger through debugfs
  176. * @poms_te_work POMS delayed work for disabling panel TE
  177. * @te_source vsync source pin information
  178. * @clk_gating_config Clocks for which clock gating needs to be enabled
  179. * @queue_cmd_waits Indicates if wait for dma commands done has to be queued.
  180. * @post_cmd_tx_workq: Pointer to the workqueue of post command transfer work.
  181. * @is_active: status of the display
  182. * @trusted_vm_env: Set to true, it the executing VM is Trusted VM.
  183. * Set to false, otherwise.
  184. * @hw_ownership: Indicates if VM owns the hardware resources.
  185. * @tx_cmd_buf_ndx: Index to the DSI debugfs TX CMD buffer.
  186. * @cmd_set: Debugfs TX cmd set.
  187. * @enabled: Boolean to indicate display enabled.
  188. */
  189. struct dsi_display {
  190. struct platform_device *pdev;
  191. struct drm_device *drm_dev;
  192. struct drm_connector *drm_conn;
  193. struct drm_connector *ext_conn;
  194. const char *name;
  195. const char *display_type;
  196. struct list_head list;
  197. bool is_cont_splash_enabled;
  198. bool sw_te_using_wd;
  199. struct mutex display_lock;
  200. int disp_te_gpio;
  201. bool is_te_irq_enabled;
  202. struct completion esd_te_gate;
  203. bool is_spurious_interrupt;
  204. u32 ctrl_count;
  205. struct dsi_display_ctrl ctrl[MAX_DSI_CTRLS_PER_DISPLAY];
  206. /* panel info */
  207. struct dsi_panel *panel;
  208. struct device_node *panel_node;
  209. struct device_node *parser_node;
  210. /* external bridge */
  211. struct dsi_display_ext_bridge ext_bridge[MAX_DSI_CTRLS_PER_DISPLAY];
  212. u32 ext_bridge_cnt;
  213. struct dsi_display_mode *modes;
  214. enum dsi_display_type type;
  215. u32 clk_master_idx;
  216. u32 cmd_master_idx;
  217. u32 video_master_idx;
  218. /* dynamic DSI clock info*/
  219. u32 dyn_bit_clk;
  220. bool dyn_bit_clk_pending;
  221. u32 cached_clk_rate;
  222. atomic_t clkrate_change_pending;
  223. struct dsi_display_clk_info clock_info;
  224. struct dsi_host_config config;
  225. struct dsi_lane_map lane_map;
  226. int cmdline_topology;
  227. int cmdline_timing;
  228. bool is_tpg_enabled;
  229. bool poms_pending;
  230. bool ulps_enabled;
  231. bool clamp_enabled;
  232. bool phy_idle_power_off;
  233. struct drm_gem_object *tx_cmd_buf;
  234. u32 cmd_buffer_size;
  235. u64 cmd_buffer_iova;
  236. void *vaddr;
  237. struct msm_gem_address_space *aspace;
  238. struct mipi_dsi_host host;
  239. struct dsi_bridge *bridge;
  240. u32 cmd_engine_refcount;
  241. void *clk_mngr;
  242. void *dsi_clk_handle;
  243. void *mdp_clk_handle;
  244. /* DEBUG FS */
  245. struct dentry *root;
  246. bool misr_enable;
  247. u32 misr_frame_count;
  248. u32 esd_trigger;
  249. /* multiple dsi error handlers */
  250. struct workqueue_struct *err_workq;
  251. struct work_struct fifo_underflow_work;
  252. struct work_struct fifo_overflow_work;
  253. struct work_struct lp_rx_timeout_work;
  254. /* panel te delayed work */
  255. struct delayed_work poms_te_work;
  256. /* firmware panel data */
  257. const struct firmware *fw;
  258. void *parser;
  259. struct dsi_display_boot_param *boot_disp;
  260. u32 te_source;
  261. u32 clk_gating_config;
  262. bool queue_cmd_waits;
  263. struct workqueue_struct *post_cmd_tx_workq;
  264. /* panel id of the display */
  265. u64 panel_id;
  266. bool is_active;
  267. bool trusted_vm_env;
  268. bool hw_ownership;
  269. int tx_cmd_buf_ndx;
  270. struct dsi_panel_cmd_set cmd_set;
  271. bool enabled;
  272. };
  273. int dsi_display_dev_probe(struct platform_device *pdev);
  274. int dsi_display_dev_remove(struct platform_device *pdev);
  275. /**
  276. * dsi_display_get_num_of_displays() - returns number of display devices
  277. * supported.
  278. *
  279. * Return: number of displays.
  280. */
  281. int dsi_display_get_num_of_displays(void);
  282. /**
  283. * dsi_display_get_active_displays - returns pointers for active display devices
  284. * @display_array: Pointer to display array to be filled
  285. * @max_display_count: Size of display_array
  286. * @Returns: Number of display entries filled
  287. */
  288. int dsi_display_get_active_displays(void **display_array,
  289. u32 max_display_count);
  290. /**
  291. * dsi_display_get_display_by_name()- finds display by name
  292. * @name: name of the display.
  293. *
  294. * Return: handle to the display or error code.
  295. */
  296. struct dsi_display *dsi_display_get_display_by_name(const char *name);
  297. /**
  298. * dsi_display_set_active_state() - sets the state of the display
  299. * @display: Handle to display.
  300. * @is_active: state
  301. */
  302. void dsi_display_set_active_state(struct dsi_display *display, bool is_active);
  303. /**
  304. * dsi_display_drm_bridge_init() - initializes DRM bridge object for DSI
  305. * @display: Handle to the display.
  306. * @encoder: Pointer to the encoder object which is connected to the
  307. * display.
  308. *
  309. * Return: error code.
  310. */
  311. int dsi_display_drm_bridge_init(struct dsi_display *display,
  312. struct drm_encoder *enc);
  313. /**
  314. * dsi_display_drm_bridge_deinit() - destroys DRM bridge for the display
  315. * @display: Handle to the display.
  316. *
  317. * Return: error code.
  318. */
  319. int dsi_display_drm_bridge_deinit(struct dsi_display *display);
  320. /**
  321. * dsi_display_drm_ext_bridge_init() - initializes DRM bridge for ext bridge
  322. * @display: Handle to the display.
  323. * @enc: Pointer to the encoder object which is connected to the
  324. * display.
  325. * @connector: Pointer to the connector object which is connected to
  326. * the display.
  327. *
  328. * Return: error code.
  329. */
  330. int dsi_display_drm_ext_bridge_init(struct dsi_display *display,
  331. struct drm_encoder *enc, struct drm_connector *connector);
  332. /**
  333. * dsi_display_get_info() - returns the display properties
  334. * @connector: Pointer to drm connector structure
  335. * @info: Pointer to the structure where info is stored.
  336. * @disp: Handle to the display.
  337. *
  338. * Return: error code.
  339. */
  340. int dsi_display_get_info(struct drm_connector *connector,
  341. struct msm_display_info *info, void *disp);
  342. /**
  343. * dsi_display_get_mode_count() - get number of modes supported by the display
  344. * @display: Handle to display.
  345. * @count: Number of modes supported
  346. *
  347. * Return: error code.
  348. */
  349. int dsi_display_get_mode_count(struct dsi_display *display, u32 *count);
  350. /**
  351. * dsi_display_get_modes() - get modes supported by display
  352. * @display: Handle to display.
  353. * @modes; Output param, list of DSI modes. Number of modes matches
  354. * count got from display->panel->num_display_modes;
  355. *
  356. * Return: error code.
  357. */
  358. int dsi_display_get_modes(struct dsi_display *display,
  359. struct dsi_display_mode **modes);
  360. /**
  361. * dsi_display_put_mode() - free up mode created for the display
  362. * @display: Handle to display.
  363. * @mode: Display mode to be freed up
  364. *
  365. * Return: error code.
  366. */
  367. void dsi_display_put_mode(struct dsi_display *display,
  368. struct dsi_display_mode *mode);
  369. /**
  370. * dsi_display_get_default_lms() - retrieve max number of lms used
  371. * for dsi display by traversing through all topologies
  372. * @display: Handle to display.
  373. * @num_lm: Number of LMs used
  374. *
  375. * Return: error code.
  376. */
  377. int dsi_display_get_default_lms(void *dsi_display, u32 *num_lm);
  378. /*
  379. * dsi_conn_get_lm_from_mode() - retrieves LM count from dsi mode priv info
  380. * @display: Handle to display.
  381. * @mode: Pointer to DRM mode structure
  382. *
  383. * Return: LM count from dsi panel topology
  384. */
  385. int dsi_conn_get_lm_from_mode(void *dsi_display, const struct drm_display_mode *mode);
  386. /**
  387. * dsi_display_find_mode() - retrieve cached DSI mode given relevant params
  388. * @display: Handle to display.
  389. * @cmp: Mode to use as comparison to find original
  390. * @sub_mode: Additional mode info to drm display mode
  391. * @out_mode: Output parameter, pointer to retrieved mode
  392. *
  393. * Return: error code.
  394. */
  395. int dsi_display_find_mode(struct dsi_display *display,
  396. struct dsi_display_mode *cmp,
  397. struct msm_sub_mode *sub_mode,
  398. struct dsi_display_mode **out_mode);
  399. /**
  400. * dsi_display_validate_mode() - validates if mode is supported by display
  401. * @display: Handle to display.
  402. * @mode: Mode to be validated.
  403. * @flags: Modifier flags.
  404. *
  405. * Return: 0 if supported or error code.
  406. */
  407. int dsi_display_validate_mode(struct dsi_display *display,
  408. struct dsi_display_mode *mode,
  409. u32 flags);
  410. /**
  411. * dsi_display_validate_mode_change() - validates mode if variable refresh case
  412. * or dynamic clk change case
  413. * @display: Handle to display.
  414. * @mode: Mode to be validated..
  415. *
  416. * Return: 0 if error code.
  417. */
  418. int dsi_display_validate_mode_change(struct dsi_display *display,
  419. struct dsi_display_mode *cur_dsi_mode,
  420. struct dsi_display_mode *mode);
  421. /**
  422. * dsi_display_set_mode() - Set mode on the display.
  423. * @display: Handle to display.
  424. * @mode: mode to be set.
  425. * @flags: Modifier flags.
  426. *
  427. * Return: error code.
  428. */
  429. int dsi_display_set_mode(struct dsi_display *display,
  430. struct dsi_display_mode *mode,
  431. u32 flags);
  432. /**
  433. * dsi_display_prepare() - prepare display
  434. * @display: Handle to display.
  435. *
  436. * Prepare will perform power up sequences for the host and panel hardware.
  437. * Power and clock resources might be turned on (depending on the panel mode).
  438. * The video engine is not enabled.
  439. *
  440. * Return: error code.
  441. */
  442. int dsi_display_prepare(struct dsi_display *display);
  443. /**
  444. * dsi_display_splash_res_cleanup() - cleanup for continuous splash
  445. * @display: Pointer to dsi display
  446. * Returns: Zero on success
  447. */
  448. int dsi_display_splash_res_cleanup(struct dsi_display *display);
  449. /**
  450. * dsi_display_config_ctrl_for_cont_splash()- Enable engine modes for DSI
  451. * controller during continuous splash
  452. * @display: Handle to DSI display
  453. *
  454. * Return: returns error code
  455. */
  456. int dsi_display_config_ctrl_for_cont_splash(struct dsi_display *display);
  457. /**
  458. * dsi_display_enable() - enable display
  459. * @display: Handle to display.
  460. *
  461. * Enable will turn on the host engine and the panel. At the end of the enable
  462. * function, Host and panel hardware are ready to accept pixel data from
  463. * upstream.
  464. *
  465. * Return: error code.
  466. */
  467. int dsi_display_enable(struct dsi_display *display);
  468. /**
  469. * dsi_display_post_enable() - perform post enable operations.
  470. * @display: Handle to display.
  471. *
  472. * Some panels might require some commands to be sent after pixel data
  473. * transmission has started. Such commands are sent as part of the post_enable
  474. * function.
  475. *
  476. * Return: error code.
  477. */
  478. int dsi_display_post_enable(struct dsi_display *display);
  479. /**
  480. * dsi_display_pre_disable() - perform pre disable operations.
  481. * @display: Handle to display.
  482. *
  483. * If a panel requires commands to be sent before pixel data transmission is
  484. * stopped, those can be sent as part of pre_disable.
  485. *
  486. * Return: error code.
  487. */
  488. int dsi_display_pre_disable(struct dsi_display *display);
  489. /**
  490. * dsi_display_disable() - disable panel and host hardware.
  491. * @display: Handle to display.
  492. *
  493. * Disable host and panel hardware and pixel data transmission can not continue.
  494. *
  495. * Return: error code.
  496. */
  497. int dsi_display_disable(struct dsi_display *display);
  498. /**
  499. * dsi_pre_clkoff_cb() - Callback before clock is turned off
  500. * @priv: private data pointer.
  501. * @clk_type: clock which is being turned on.
  502. * @l_type: specifies if the clock is HS or LP type. Valid only for link clocks.
  503. * @new_state: next state for the clock.
  504. *
  505. * @return: error code.
  506. */
  507. int dsi_pre_clkoff_cb(void *priv, enum dsi_clk_type clk_type,
  508. enum dsi_lclk_type l_type,
  509. enum dsi_clk_state new_state);
  510. /**
  511. * dsi_display_update_pps() - update PPS buffer.
  512. * @pps_cmd: PPS buffer.
  513. * @display: Handle to display.
  514. *
  515. * Copies new PPS buffer into display structure.
  516. *
  517. * Return: error code.
  518. */
  519. int dsi_display_update_pps(char *pps_cmd, void *display);
  520. /**
  521. * dsi_post_clkoff_cb() - Callback after clock is turned off
  522. * @priv: private data pointer.
  523. * @clk_type: clock which is being turned on.
  524. * @l_type: specifies if the clock is HS or LP type. Valid only for link clocks.
  525. * @curr_state: current state for the clock.
  526. *
  527. * @return: error code.
  528. */
  529. int dsi_post_clkoff_cb(void *priv, enum dsi_clk_type clk_type,
  530. enum dsi_lclk_type l_type,
  531. enum dsi_clk_state curr_state);
  532. /**
  533. * dsi_post_clkon_cb() - Callback after clock is turned on
  534. * @priv: private data pointer.
  535. * @clk_type: clock which is being turned on.
  536. * @l_type: specifies if the clock is HS or LP type. Valid only for link clocks.
  537. * @curr_state: current state for the clock.
  538. *
  539. * @return: error code.
  540. */
  541. int dsi_post_clkon_cb(void *priv, enum dsi_clk_type clk_type,
  542. enum dsi_lclk_type l_type,
  543. enum dsi_clk_state curr_state);
  544. /**
  545. * dsi_pre_clkon_cb() - Callback before clock is turned on
  546. * @priv: private data pointer.
  547. * @clk_type: clock which is being turned on.
  548. * @l_type: specifies if the clock is HS or LP type. Valid only for link clocks.
  549. * @new_state: next state for the clock.
  550. *
  551. * @return: error code.
  552. */
  553. int dsi_pre_clkon_cb(void *priv, enum dsi_clk_type clk_type,
  554. enum dsi_lclk_type l_type,
  555. enum dsi_clk_state new_state);
  556. /**
  557. * dsi_display_unprepare() - power off display hardware.
  558. * @display: Handle to display.
  559. *
  560. * Host and panel hardware is turned off. Panel will be in reset state at the
  561. * end of the function.
  562. *
  563. * Return: error code.
  564. */
  565. int dsi_display_unprepare(struct dsi_display *display);
  566. int dsi_display_set_tpg_state(struct dsi_display *display, bool enable,
  567. enum dsi_test_pattern type,
  568. u32 init_val,
  569. enum dsi_ctrl_tpg_pattern pattern);
  570. int dsi_display_clock_gate(struct dsi_display *display, bool enable);
  571. int dsi_dispaly_static_frame(struct dsi_display *display, bool enable);
  572. /**
  573. * dsi_display_get_drm_panel() - get drm_panel from display.
  574. * @display: Handle to display.
  575. * Get drm_panel which was inclued in dsi_display's dsi_panel.
  576. *
  577. * Return: drm_panel/NULL.
  578. */
  579. struct drm_panel *dsi_display_get_drm_panel(struct dsi_display *display);
  580. /**
  581. * dsi_display_has_dsc_switch_support() - check if dsc switch is supported.
  582. * @display: Handle to display.
  583. *
  584. * Return: True of panel supports both dsc and non-dsc modes.
  585. */
  586. bool dsi_display_has_dsc_switch_support(struct dsi_display *display);
  587. /**
  588. * dsi_display_enable_event() - enable interrupt based connector event
  589. * @connector: Pointer to drm connector structure
  590. * @display: Handle to display.
  591. * @event_idx: Event index.
  592. * @event_info: Event callback definition.
  593. * @enable: Whether to enable/disable the event interrupt.
  594. */
  595. void dsi_display_enable_event(struct drm_connector *connector,
  596. struct dsi_display *display,
  597. uint32_t event_idx, struct dsi_event_cb_info *event_info,
  598. bool enable);
  599. /**
  600. * dsi_display_set_backlight() - set backlight
  601. * @connector: Pointer to drm connector structure
  602. * @display: Handle to display.
  603. * @bl_lvl: Backlight level.
  604. * @event_info: Event callback definition.
  605. * @enable: Whether to enable/disable the event interrupt.
  606. */
  607. int dsi_display_set_backlight(struct drm_connector *connector,
  608. void *display, u32 bl_lvl);
  609. /**
  610. * dsi_display_check_status() - check if panel is dead or alive
  611. * @connector: Pointer to drm connector structure
  612. * @display: Handle to display.
  613. * @te_check_override: Whether check for TE from panel or default check
  614. */
  615. int dsi_display_check_status(struct drm_connector *connector, void *display,
  616. bool te_check_override);
  617. /**
  618. * dsi_display_cmd_transfer() - transfer command to the panel
  619. * @connector: Pointer to drm connector structure
  620. * @display: Handle to display.
  621. * @cmd_buf: Command buffer
  622. * @cmd_buf_len: Command buffer length in bytes
  623. */
  624. int dsi_display_cmd_transfer(struct drm_connector *connector,
  625. void *display, const char *cmd_buffer,
  626. u32 cmd_buf_len);
  627. /**
  628. * dsi_display_cmd_receive() - receive response from the panel
  629. * @display: Handle to display.
  630. * @cmd_buf: Command buffer
  631. * @cmd_buf_len: Command buffer length in bytes
  632. * @recv_buf: Receive buffer
  633. * @recv_buf_len: Receive buffer length in bytes
  634. * @ts: Command time stamp in nano-seconds.
  635. */
  636. int dsi_display_cmd_receive(void *display, const char *cmd_buf,
  637. u32 cmd_buf_len, u8 *recv_buf, u32 recv_buf_len, ktime_t *ts);
  638. /**
  639. * dsi_display_soft_reset() - perform a soft reset on DSI controller
  640. * @display: Handle to display
  641. *
  642. * The video, command and controller engines will be disabled before the
  643. * reset is triggered. After, the engines will be re-enabled to the same state
  644. * as before the reset.
  645. *
  646. * If the reset is done while MDP timing engine is turned on, the video
  647. * engine should be re-enabled only during the vertical blanking time.
  648. *
  649. * Return: error code
  650. */
  651. int dsi_display_soft_reset(void *display);
  652. /**
  653. * dsi_display_set_power - update power/dpms setting
  654. * @connector: Pointer to drm connector structure
  655. * @power_mode: One of the following,
  656. * SDE_MODE_DPMS_ON
  657. * SDE_MODE_DPMS_LP1
  658. * SDE_MODE_DPMS_LP2
  659. * SDE_MODE_DPMS_STANDBY
  660. * SDE_MODE_DPMS_SUSPEND
  661. * SDE_MODE_DPMS_OFF
  662. * @display: Pointer to private display structure
  663. * Returns: Zero on success
  664. */
  665. int dsi_display_set_power(struct drm_connector *connector,
  666. int power_mode, void *display);
  667. /*
  668. * dsi_display_pre_kickoff - program kickoff-time features
  669. * @connector: Pointer to drm connector structure
  670. * @display: Pointer to private display structure
  671. * @params: Parameters for kickoff-time programming
  672. * Returns: Zero on success
  673. */
  674. int dsi_display_pre_kickoff(struct drm_connector *connector,
  675. struct dsi_display *display,
  676. struct msm_display_kickoff_params *params);
  677. /*
  678. * dsi_display_pre_commit - program pre commit features
  679. * @display: Pointer to private display structure
  680. * @params: Parameters for pre commit time programming
  681. * Returns: Zero on success
  682. */
  683. int dsi_display_pre_commit(void *display,
  684. struct msm_display_conn_params *params);
  685. /**
  686. * dsi_display_get_dst_format() - get dst_format from DSI display
  687. * @connector: Pointer to drm connector structure
  688. * @display: Handle to display
  689. *
  690. * Return: enum dsi_pixel_format type
  691. */
  692. enum dsi_pixel_format dsi_display_get_dst_format(
  693. struct drm_connector *connector,
  694. void *display);
  695. /**
  696. * dsi_display_cont_splash_config() - initialize splash resources
  697. * @display: Handle to display
  698. *
  699. * Return: Zero on Success
  700. */
  701. int dsi_display_cont_splash_config(void *display);
  702. /**
  703. * dsi_display_cont_splash_res_disable() - Disable resource votes added in probe
  704. * @display: Pointer to dsi display
  705. * Returns: Zero on success
  706. */
  707. int dsi_display_cont_splash_res_disable(void *display);
  708. /*
  709. * dsi_display_get_panel_vfp - get panel vsync
  710. * @display: Pointer to private display structure
  711. * @h_active: width
  712. * @v_active: height
  713. * Returns: v_front_porch on success error code on failure
  714. */
  715. int dsi_display_get_panel_vfp(void *display,
  716. int h_active, int v_active);
  717. /**
  718. * dsi_display_dump_clks_state() - dump clocks state to console
  719. * @display: Handle to display
  720. *
  721. * Return: Zero on Success
  722. */
  723. int dsi_display_dump_clks_state(struct dsi_display *display);
  724. /**
  725. * dsi_display_update_dyn_bit_clk() - update mode timing to compensate for dynamic bit clock
  726. * @display: Handle to display
  727. * @mode: Mode to be updated
  728. * Return: Zero on Success
  729. */
  730. int dsi_display_update_dyn_bit_clk(struct dsi_display *display, struct dsi_display_mode *mode);
  731. /**
  732. * dsi_display_restore_bit_clk() - restore mode bit clock rate value from dynamic bit clock
  733. * @display: Handle to display
  734. * @mode: Mode to be updated
  735. * Return: Zero on Success
  736. */
  737. int dsi_display_restore_bit_clk(struct dsi_display *display, struct dsi_display_mode *mode);
  738. /**
  739. * dsi_display_mode_match() - compares two dsi mode structures
  740. * @mode1: dsi_display_mode to be compared
  741. * @mode2: dsi_display_mode to be compared
  742. * @match_flags: Values to compare
  743. * Return: True if mode matches
  744. */
  745. bool dsi_display_mode_match(const struct dsi_display_mode *mode1,
  746. struct dsi_display_mode *mode2, unsigned int match_flags);
  747. /**
  748. * dsi_display_update_transfer_time() - update DSI transfer time and clocks
  749. * @display: handle to display
  750. * @transfer_time: transfer time value to be updated
  751. *
  752. * Return: error code
  753. */
  754. int dsi_display_update_transfer_time(void *display, u32 transfer_time);
  755. /**
  756. * dsi_display_get_panel_scan_line() - get panel scan line
  757. * @display: handle to display
  758. * @scan_line: scan line buffer value
  759. * @scan_line_ts: scan line time stamp value in nano-seconds
  760. *
  761. * Return: error code
  762. */
  763. int dsi_display_get_panel_scan_line(void *display, u16 *scan_line, ktime_t *scan_line_ts);
  764. /**
  765. * dsi_display_report_dead() - report panel dead and cancel work queue
  766. * @display: handle to display
  767. *
  768. */
  769. void dsi_display_report_dead(struct dsi_display *display);
  770. #endif /* _DSI_DISPLAY_H_ */