dsi_display.h 25 KB

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