dsi_display.h 27 KB

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