dsi_display.h 26 KB

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