dsi_display.h 26 KB

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