sde_kms.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. /*
  2. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (C) 2013 Red Hat
  5. * Author: Rob Clark <[email protected]>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __SDE_KMS_H__
  20. #define __SDE_KMS_H__
  21. #include <linux/pm_domain.h>
  22. #include <linux/pm_qos.h>
  23. #include <drm/drm_framebuffer.h>
  24. #include "msm_drv.h"
  25. #include "msm_kms.h"
  26. #include "msm_mmu.h"
  27. #include "msm_gem.h"
  28. #include "sde_dbg.h"
  29. #include "sde_hw_catalog.h"
  30. #include "sde_hw_ctl.h"
  31. #include "sde_hw_lm.h"
  32. #include "sde_hw_pingpong.h"
  33. #include "sde_hw_interrupts.h"
  34. #include "sde_hw_wb.h"
  35. #include "sde_hw_top.h"
  36. #include "sde_hw_uidle.h"
  37. #include "sde_hw_vbif.h"
  38. #include "sde_rm.h"
  39. #include "sde_power_handle.h"
  40. #include "sde_irq.h"
  41. #include "sde_core_perf.h"
  42. #define DRMID(x) ((x) ? (x)->base.id : -1)
  43. /**
  44. * SDE_DEBUG - macro for kms/plane/crtc/encoder/connector logs
  45. * @fmt: Pointer to format string
  46. */
  47. #define SDE_DEBUG(fmt, ...) \
  48. do { \
  49. if (drm_debug_enabled(DRM_UT_KMS)) \
  50. DRM_DEBUG(fmt, ##__VA_ARGS__); \
  51. else \
  52. pr_debug(fmt, ##__VA_ARGS__); \
  53. } while (0)
  54. /**
  55. * SDE_INFO - macro for kms/plane/crtc/encoder/connector logs
  56. * @fmt: Pointer to format string
  57. */
  58. #define SDE_INFO(fmt, ...) \
  59. do { \
  60. if (drm_debug_enabled(DRM_UT_KMS)) \
  61. DRM_INFO(fmt, ##__VA_ARGS__); \
  62. else \
  63. pr_info(fmt, ##__VA_ARGS__); \
  64. } while (0)
  65. /**
  66. * SDE_DEBUG_DRIVER - macro for hardware driver logging
  67. * @fmt: Pointer to format string
  68. */
  69. #define SDE_DEBUG_DRIVER(fmt, ...) \
  70. do { \
  71. if (drm_debug_enabled(DRM_UT_DRIVER)) \
  72. DRM_ERROR(fmt, ##__VA_ARGS__); \
  73. else \
  74. pr_debug(fmt, ##__VA_ARGS__); \
  75. } while (0)
  76. #define SDE_ERROR(fmt, ...) pr_err("[sde error]" fmt, ##__VA_ARGS__)
  77. #define POPULATE_RECT(rect, a, b, c, d, Q16_flag) \
  78. do { \
  79. (rect)->x = (Q16_flag) ? (a) >> 16 : (a); \
  80. (rect)->y = (Q16_flag) ? (b) >> 16 : (b); \
  81. (rect)->w = (Q16_flag) ? (c) >> 16 : (c); \
  82. (rect)->h = (Q16_flag) ? (d) >> 16 : (d); \
  83. } while (0)
  84. #define CHECK_LAYER_BOUNDS(offset, size, max_size) \
  85. (((size) > (max_size)) || ((offset) > ((max_size) - (size))))
  86. /**
  87. * ktime_compare_safe - compare two ktime structures
  88. * This macro is similar to the standard ktime_compare() function, but
  89. * attempts to also handle ktime overflows.
  90. * @A: First ktime value
  91. * @B: Second ktime value
  92. * Returns: -1 if A < B, 0 if A == B, 1 if A > B
  93. */
  94. #define ktime_compare_safe(A, B) \
  95. ktime_compare(ktime_sub((A), (B)), ktime_set(0, 0))
  96. #define SDE_NAME_SIZE 12
  97. #define DEFAULT_FPS 60
  98. /* timeout in frames waiting for frame done */
  99. #if IS_ENABLED(CONFIG_DISPLAY_SAMSUNG)
  100. /* case 03134585
  101. * sometimes, it is delayed for hundreds miliseconds
  102. * to call sde_crtc_frame_event_work(), by scheduling.
  103. * Set enough time for frame done timeout.
  104. */
  105. #define SDE_FRAME_DONE_TIMEOUT 500
  106. #else
  107. #define SDE_FRAME_DONE_TIMEOUT 60
  108. #endif
  109. /* max active secure client counts allowed */
  110. #define MAX_ALLOWED_SECURE_CLIENT_CNT 1
  111. /* max active crtc when secure client is active */
  112. #define MAX_ALLOWED_CRTC_CNT_DURING_SECURE 1
  113. /* max virtual encoders per secure crtc */
  114. #define MAX_ALLOWED_ENCODER_CNT_PER_SECURE_CRTC 1
  115. /* defines the operations required for secure state transition */
  116. #define SDE_KMS_OPS_SECURE_STATE_CHANGE BIT(0)
  117. #define SDE_KMS_OPS_WAIT_FOR_TX_DONE BIT(1)
  118. #define SDE_KMS_OPS_CLEANUP_PLANE_FB BIT(2)
  119. #define SDE_KMS_OPS_PREPARE_PLANE_FB BIT(3)
  120. /* ESD status check interval in miliseconds */
  121. #define STATUS_CHECK_INTERVAL_MS 5000
  122. /**
  123. * enum sde_kms_smmu_state: smmu state
  124. * @ATTACHED: all the context banks are attached.
  125. * @DETACHED: all the context banks are detached.
  126. * @DETACHED_SEC: secure context bank is detached.
  127. * @ATTACH_ALL_REQ: transient state of attaching context banks.
  128. * @DETACH_ALL_REQ: transient state of detaching context banks.
  129. * @DETACH_SEC_REQ: tranisent state of secure context bank is detached
  130. * @ATTACH_SEC_REQ: transient state of attaching secure context bank.
  131. */
  132. enum sde_kms_smmu_state {
  133. ATTACHED = 0,
  134. DETACHED,
  135. DETACHED_SEC,
  136. ATTACH_ALL_REQ,
  137. DETACH_ALL_REQ,
  138. DETACH_SEC_REQ,
  139. ATTACH_SEC_REQ,
  140. };
  141. /**
  142. * enum sde_kms_smmu_state_transition_type: state transition type
  143. * @NONE: no pending state transitions
  144. * @PRE_COMMIT: state transitions should be done before processing the commit
  145. * @POST_COMMIT: state transitions to be done after processing the commit.
  146. */
  147. enum sde_kms_smmu_state_transition_type {
  148. NONE,
  149. PRE_COMMIT,
  150. POST_COMMIT
  151. };
  152. /**
  153. * enum sde_kms_sui_misr_state: state request for enabling/disabling MISR
  154. * @NONE: no request
  155. * @ENABLE_SUI_MISR_REQ: request to enable sui MISR
  156. * @DISABLE_SUI_MISR_REQ: request to disable sui MISR
  157. */
  158. enum sde_kms_sui_misr_state {
  159. SUI_MISR_NONE,
  160. SUI_MISR_ENABLE_REQ,
  161. SUI_MISR_DISABLE_REQ
  162. };
  163. /*
  164. * @FRAME_DONE_WAIT_DEFAULT: waits for frame N pp_done interrupt before
  165. * triggering frame N+1.
  166. * @FRAME_DONE_WAIT_SERIALIZE: serialize pp_done and ctl_start irq for frame
  167. * N without next frame trigger wait.
  168. * @FRAME_DONE_WAIT_POSTED_START: Do not wait for pp_done interrupt for any
  169. * frame. Wait will trigger only for error case.
  170. */
  171. enum frame_trigger_mode_type {
  172. FRAME_DONE_WAIT_DEFAULT,
  173. FRAME_DONE_WAIT_SERIALIZE,
  174. FRAME_DONE_WAIT_POSTED_START,
  175. };
  176. /**
  177. * struct sde_kms_smmu_state_data: stores the smmu state and transition type
  178. * @state: current state of smmu context banks
  179. * @prev_state: previous state of smmu context banks
  180. * @secure_level: secure level cached from crtc
  181. * @prev_secure_level: previous secure level
  182. * @transition_type: transition request type
  183. * @transition_error: whether there is error while transitioning the state
  184. */
  185. struct sde_kms_smmu_state_data {
  186. uint32_t state;
  187. uint32_t prev_state;
  188. uint32_t secure_level;
  189. uint32_t prev_secure_level;
  190. uint32_t transition_type;
  191. uint32_t transition_error;
  192. uint32_t sui_misr_state;
  193. };
  194. /*
  195. * struct sde_irq_callback - IRQ callback handlers
  196. * @list: list to callback
  197. * @func: intr handler
  198. * @arg: argument for the handler
  199. */
  200. struct sde_irq_callback {
  201. struct list_head list;
  202. void (*func)(void *arg, int irq_idx);
  203. void *arg;
  204. };
  205. /**
  206. * struct sde_irq: IRQ structure contains callback registration info
  207. * @total_irq: total number of irq_idx obtained from HW interrupts mapping
  208. * @irq_cb_tbl: array of IRQ callbacks setting
  209. * @enable_counts array of IRQ enable counts
  210. * @cb_lock: callback lock
  211. * @debugfs_file: debugfs file for irq statistics
  212. */
  213. struct sde_irq {
  214. u32 total_irqs;
  215. struct list_head *irq_cb_tbl;
  216. atomic_t *enable_counts;
  217. atomic_t *irq_counts;
  218. spinlock_t cb_lock;
  219. struct dentry *debugfs_file;
  220. };
  221. /**
  222. * struct sde_kms_frame_event_cb_data : info of drm objects of a frame event
  223. * @crtc: pointer to drm crtc object registered for frame event
  224. * @connector: pointer to drm connector which is source of frame event
  225. */
  226. struct sde_kms_frame_event_cb_data {
  227. struct drm_crtc *crtc;
  228. struct drm_connector *connector;
  229. };
  230. struct sde_kms {
  231. struct msm_kms base;
  232. struct drm_device *dev;
  233. uint32_t core_rev;
  234. struct sde_mdss_cfg *catalog;
  235. struct generic_pm_domain genpd;
  236. bool genpd_init;
  237. struct msm_gem_address_space *aspace[MSM_SMMU_DOMAIN_MAX];
  238. struct sde_power_event *power_event;
  239. /* directory entry for debugfs */
  240. struct dentry *debugfs_vbif;
  241. /* io/register spaces: */
  242. void __iomem *mmio, *vbif[VBIF_MAX], *reg_dma, *sid;
  243. unsigned long mmio_len, vbif_len[VBIF_MAX], reg_dma_len, sid_len;
  244. unsigned long reg_dma_off;
  245. struct regulator *vdd;
  246. struct regulator *mmagic;
  247. struct regulator *venus;
  248. struct sde_irq_controller irq_controller;
  249. struct sde_hw_intr *hw_intr;
  250. struct sde_irq irq_obj;
  251. int irq_num; /* mdss irq number */
  252. bool irq_enabled;
  253. struct sde_core_perf perf;
  254. /* saved atomic state during system suspend */
  255. struct drm_atomic_state *suspend_state;
  256. bool suspend_block;
  257. struct sde_rm rm;
  258. bool rm_init;
  259. struct sde_splash_data splash_data;
  260. struct sde_vbif_clk_client vbif_clk_clients[SDE_CLK_CTRL_MAX];
  261. struct sde_hw_vbif *hw_vbif[VBIF_MAX];
  262. struct sde_hw_mdp *hw_mdp;
  263. struct sde_hw_uidle *hw_uidle;
  264. struct sde_hw_sid *hw_sid;
  265. int dsi_display_count;
  266. void **dsi_displays;
  267. int wb_display_count;
  268. void **wb_displays;
  269. int dp_display_count;
  270. void **dp_displays;
  271. int dp_stream_count;
  272. bool dsc_switch_support;
  273. bool has_danger_ctrl;
  274. struct sde_kms_smmu_state_data smmu_state;
  275. atomic_t detach_sec_cb;
  276. atomic_t detach_all_cb;
  277. struct mutex secure_transition_lock;
  278. bool first_kickoff;
  279. bool qdss_enabled;
  280. bool pm_suspend_clk_dump;
  281. cpumask_t irq_cpu_mask;
  282. atomic_t irq_vote_count;
  283. struct dev_pm_qos_request pm_qos_irq_req[NR_CPUS];
  284. struct irq_affinity_notify affinity_notify;
  285. struct sde_vm *vm;
  286. unsigned long ipcc_base_addr;
  287. u32 debugfs_hw_fence;
  288. };
  289. struct vsync_info {
  290. u32 frame_count;
  291. u32 line_count;
  292. };
  293. #define to_sde_kms(x) container_of(x, struct sde_kms, base)
  294. /**
  295. * sde_is_custom_client - whether or not to enable non-standard customizations
  296. *
  297. * Return: Whether or not the 'sdeclient' module parameter was set on boot up
  298. */
  299. bool sde_is_custom_client(void);
  300. /**
  301. * sde_kms_get_hw_version - get the hw revision - client is expected to
  302. * enable the power resources before making this call
  303. * @dev: Pointer to drm device
  304. */
  305. static inline u32 sde_kms_get_hw_version(struct drm_device *dev)
  306. {
  307. struct sde_kms *sde_kms;
  308. if (!ddev_to_msm_kms(dev))
  309. return 0;
  310. sde_kms = to_sde_kms(ddev_to_msm_kms(dev));
  311. return readl_relaxed(sde_kms->mmio + 0x0);
  312. }
  313. /**
  314. * sde_kms_power_resource_is_enabled - whether or not power resource is enabled
  315. * @dev: Pointer to drm device
  316. * Return: true if power resource is enabled; false otherwise
  317. */
  318. static inline bool sde_kms_power_resource_is_enabled(struct drm_device *dev)
  319. {
  320. if (!dev)
  321. return false;
  322. return pm_runtime_enabled(dev->dev);
  323. }
  324. /**
  325. * sde_kms_is_suspend_state - whether or not the system is pm suspended
  326. * @dev: Pointer to drm device
  327. * Return: Suspend status
  328. */
  329. static inline bool sde_kms_is_suspend_state(struct drm_device *dev)
  330. {
  331. if (!ddev_to_msm_kms(dev))
  332. return false;
  333. return to_sde_kms(ddev_to_msm_kms(dev))->suspend_state != NULL;
  334. }
  335. /**
  336. * sde_kms_is_suspend_blocked - whether or not commits are blocked due to pm
  337. * suspend status
  338. * @dev: Pointer to drm device
  339. * Return: True if commits should be rejected due to pm suspend
  340. */
  341. static inline bool sde_kms_is_suspend_blocked(struct drm_device *dev)
  342. {
  343. if (!sde_kms_is_suspend_state(dev))
  344. return false;
  345. return to_sde_kms(ddev_to_msm_kms(dev))->suspend_block;
  346. }
  347. /**
  348. * sde_kms_is_secure_session_inprogress - to indicate if secure-session is in
  349. * currently in-progress based on the current smmu_state
  350. *
  351. * @sde_kms: Pointer to sde_kms
  352. *
  353. * return: true if secure-session is in progress; false otherwise
  354. */
  355. static inline bool sde_kms_is_secure_session_inprogress(struct sde_kms *sde_kms)
  356. {
  357. bool ret = false;
  358. if (!sde_kms || !sde_kms->catalog)
  359. return false;
  360. mutex_lock(&sde_kms->secure_transition_lock);
  361. if (((test_bit(SDE_FEATURE_SUI_NS_ALLOWED, sde_kms->catalog->features)) &&
  362. (sde_kms->smmu_state.secure_level == SDE_DRM_SEC_ONLY) &&
  363. ((sde_kms->smmu_state.state == DETACHED_SEC) ||
  364. (sde_kms->smmu_state.state == DETACH_SEC_REQ) ||
  365. (sde_kms->smmu_state.state == ATTACH_SEC_REQ))) ||
  366. (((sde_kms->smmu_state.state == DETACHED) ||
  367. (sde_kms->smmu_state.state == DETACH_ALL_REQ) ||
  368. (sde_kms->smmu_state.state == ATTACH_ALL_REQ))))
  369. ret = true;
  370. mutex_unlock(&sde_kms->secure_transition_lock);
  371. return ret;
  372. }
  373. /**
  374. * sde_kms_is_vbif_operation_allowed - resticts the VBIF programming
  375. * during secure-ui, if the sec_ui_misr feature is enabled
  376. *
  377. * @sde_kms: Pointer to sde_kms
  378. *
  379. * return: false if secure-session is in progress; true otherwise
  380. */
  381. static inline bool sde_kms_is_vbif_operation_allowed(struct sde_kms *sde_kms)
  382. {
  383. if (!sde_kms)
  384. return false;
  385. if (!test_bit(SDE_FEATURE_SUI_MISR, sde_kms->catalog->features))
  386. return true;
  387. return !sde_kms_is_secure_session_inprogress(sde_kms);
  388. }
  389. /**
  390. * sde_kms_is_cp_operation_allowed - resticts the CP programming
  391. * during secure-ui, if the non-secure context banks are detached
  392. *
  393. * @sde_kms: Pointer to sde_kms
  394. */
  395. static inline bool sde_kms_is_cp_operation_allowed(struct sde_kms *sde_kms)
  396. {
  397. if (!sde_kms || !sde_kms->catalog)
  398. return false;
  399. if (test_bit(SDE_FEATURE_SUI_NS_ALLOWED, sde_kms->catalog->features))
  400. return true;
  401. return !sde_kms_is_secure_session_inprogress(sde_kms);
  402. }
  403. /**
  404. * Debugfs functions - extra helper functions for debugfs support
  405. *
  406. * Main debugfs documentation is located at,
  407. *
  408. * Documentation/filesystems/debugfs.txt
  409. *
  410. * @sde_debugfs_get_root: Get root dentry for SDE_KMS's debugfs node
  411. */
  412. /**
  413. * sde_debugfs_get_root - Return root directory entry for KMS's debugfs
  414. *
  415. * The return value should be passed as the 'parent' argument to subsequent
  416. * debugfs create calls.
  417. *
  418. * @sde_kms: Pointer to SDE's KMS structure
  419. *
  420. * Return: dentry pointer for SDE's debugfs location
  421. */
  422. void *sde_debugfs_get_root(struct sde_kms *sde_kms);
  423. /**
  424. * SDE info management functions
  425. * These functions/definitions allow for building up a 'sde_info' structure
  426. * containing one or more "key=value\n" entries.
  427. */
  428. #if IS_ENABLED(CONFIG_DRM_LOW_MSM_MEM_FOOTPRINT)
  429. #define SDE_KMS_INFO_MAX_SIZE (1 << 12)
  430. #else
  431. #define SDE_KMS_INFO_MAX_SIZE (1 << 14)
  432. #endif
  433. /**
  434. * struct sde_kms_info - connector information structure container
  435. * @data: Array of information character data
  436. * @len: Current length of information data
  437. * @staged_len: Temporary data buffer length, commit to
  438. * len using sde_kms_info_stop
  439. * @start: Whether or not a partial data entry was just started
  440. */
  441. struct sde_kms_info {
  442. char data[SDE_KMS_INFO_MAX_SIZE];
  443. uint32_t len;
  444. uint32_t staged_len;
  445. bool start;
  446. };
  447. /**
  448. * SDE_KMS_INFO_DATA - Macro for accessing sde_kms_info data bytes
  449. * @S: Pointer to sde_kms_info structure
  450. * Returns: Pointer to byte data
  451. */
  452. #define SDE_KMS_INFO_DATA(S) ((S) ? ((struct sde_kms_info *)(S))->data \
  453. : NULL)
  454. /**
  455. * SDE_KMS_INFO_DATALEN - Macro for accessing sde_kms_info data length
  456. * it adds an extra character length to count null.
  457. * @S: Pointer to sde_kms_info structure
  458. * Returns: Size of available byte data
  459. */
  460. #define SDE_KMS_INFO_DATALEN(S) ((S) ? ((struct sde_kms_info *)(S))->len + 1 \
  461. : 0)
  462. /**
  463. * sde_kms_info_reset - reset sde_kms_info structure
  464. * @info: Pointer to sde_kms_info structure
  465. */
  466. void sde_kms_info_reset(struct sde_kms_info *info);
  467. /**
  468. * sde_kms_info_add_keyint - add integer value to 'sde_kms_info'
  469. * @info: Pointer to sde_kms_info structure
  470. * @key: Pointer to key string
  471. * @value: Signed 64-bit integer value
  472. */
  473. void sde_kms_info_add_keyint(struct sde_kms_info *info,
  474. const char *key,
  475. int64_t value);
  476. /**
  477. * sde_kms_info_add_keystr - add string value to 'sde_kms_info'
  478. * @info: Pointer to sde_kms_info structure
  479. * @key: Pointer to key string
  480. * @value: Pointer to string value
  481. */
  482. void sde_kms_info_add_keystr(struct sde_kms_info *info,
  483. const char *key,
  484. const char *value);
  485. /**
  486. * sde_kms_info_start - begin adding key to 'sde_kms_info'
  487. * Usage:
  488. * sde_kms_info_start(key)
  489. * sde_kms_info_append(val_1)
  490. * ...
  491. * sde_kms_info_append(val_n)
  492. * sde_kms_info_stop
  493. * @info: Pointer to sde_kms_info structure
  494. * @key: Pointer to key string
  495. */
  496. void sde_kms_info_start(struct sde_kms_info *info,
  497. const char *key);
  498. /**
  499. * sde_kms_info_append - append value string to 'sde_kms_info'
  500. * Usage:
  501. * sde_kms_info_start(key)
  502. * sde_kms_info_append(val_1)
  503. * ...
  504. * sde_kms_info_append(val_n)
  505. * sde_kms_info_stop
  506. * @info: Pointer to sde_kms_info structure
  507. * @str: Pointer to partial value string
  508. */
  509. void sde_kms_info_append(struct sde_kms_info *info,
  510. const char *str);
  511. /**
  512. * sde_kms_info_append_format - append format code string to 'sde_kms_info'
  513. * Usage:
  514. * sde_kms_info_start(key)
  515. * sde_kms_info_append_format(fourcc, modifier)
  516. * ...
  517. * sde_kms_info_stop
  518. * @info: Pointer to sde_kms_info structure
  519. * @pixel_format: FOURCC format code
  520. * @modifier: 64-bit drm format modifier
  521. */
  522. void sde_kms_info_append_format(struct sde_kms_info *info,
  523. uint32_t pixel_format,
  524. uint64_t modifier);
  525. /**
  526. * sde_kms_info_append_dnsc_blur_filter_info - append dnsc_blur filters code to 'sde_kms_info'
  527. * Usage:
  528. * sde_kms_info_start(key)
  529. * sde_kms_info_append_dnsc_blur_filter_info(info, ratio)
  530. * ...
  531. * sde_kms_info_stop
  532. * @info: Pointer to sde_kms_info structure
  533. * @filter: Pointer to dnsc_blur filter info
  534. */
  535. void sde_kms_info_append_dnsc_blur_filter_info(struct sde_kms_info *info,
  536. struct sde_dnsc_blur_filter_info *filter);
  537. /**
  538. * sde_kms_info_stop - finish adding key to 'sde_kms_info'
  539. * Usage:
  540. * sde_kms_info_start(key)
  541. * sde_kms_info_append(val_1)
  542. * ...
  543. * sde_kms_info_append(val_n)
  544. * sde_kms_info_stop
  545. * @info: Pointer to sde_kms_info structure
  546. */
  547. void sde_kms_info_stop(struct sde_kms_info *info);
  548. /**
  549. * sde_kms_info_add_list - add a space separated list to 'sde_kms_info'
  550. * @info: Pointer to sde_kms_info structure
  551. * @key: Pointer to key string
  552. * @item: Pointer to array of integer values
  553. * @size: Number of integers to parse
  554. */
  555. void sde_kms_info_add_list(struct sde_kms_info *info,
  556. const char *key, uint32_t *item, size_t size);
  557. /**
  558. * sde_kms_rect_intersect - intersect two rectangles
  559. * @r1: first rectangle
  560. * @r2: scissor rectangle
  561. * @result: result rectangle, all 0's on no intersection found
  562. */
  563. void sde_kms_rect_intersect(const struct sde_rect *r1,
  564. const struct sde_rect *r2,
  565. struct sde_rect *result);
  566. /**
  567. * sde_kms_rect_merge_rectangles - merge a rectangle list into one rect
  568. * @rois: pointer to the list of rois
  569. * @result: output rectangle, all 0 on error
  570. */
  571. void sde_kms_rect_merge_rectangles(const struct msm_roi_list *rois,
  572. struct sde_rect *result);
  573. /**
  574. * sde_kms_rect_is_equal - compares two rects
  575. * @r1: rect value to compare
  576. * @r2: rect value to compare
  577. *
  578. * Returns 1 if the rects are same, 0 otherwise.
  579. */
  580. static inline bool sde_kms_rect_is_equal(struct sde_rect *r1,
  581. struct sde_rect *r2)
  582. {
  583. if ((!r1 && r2) || (r1 && !r2))
  584. return false;
  585. if (!r1 && !r2)
  586. return true;
  587. return r1->x == r2->x && r1->y == r2->y && r1->w == r2->w &&
  588. r1->h == r2->h;
  589. }
  590. /**
  591. * sde_kms_rect_is_null - returns true if the width or height of a rect is 0
  592. * @rect: rectangle to check for zero size
  593. * @Return: True if width or height of rectangle is 0
  594. */
  595. static inline bool sde_kms_rect_is_null(const struct sde_rect *r)
  596. {
  597. if (!r)
  598. return true;
  599. return (!r->w || !r->h);
  600. }
  601. /*
  602. * sde_in_trusted_vm - checks the executing VM
  603. * return: true, if the device driver is executing in the trusted VM
  604. * false, if the device driver is executing in the primary VM
  605. */
  606. static inline bool sde_in_trusted_vm(const struct sde_kms *sde_kms)
  607. {
  608. if (sde_kms && sde_kms->catalog)
  609. return sde_kms->catalog->trusted_vm_env;
  610. return false;
  611. }
  612. /**
  613. * Vblank enable/disable functions
  614. */
  615. int sde_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
  616. void sde_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
  617. /**
  618. * smmu attach/detach functions
  619. * @sde_kms: poiner to sde_kms structure
  620. * @secure_only: if true only secure contexts are attached/detached, else
  621. * all contexts are attached/detached/
  622. */
  623. int sde_kms_mmu_attach(struct sde_kms *sde_kms, bool secure_only);
  624. int sde_kms_mmu_detach(struct sde_kms *sde_kms, bool secure_only);
  625. /**
  626. * sde_kms_timeline_status - provides current timeline status
  627. * @dev: Pointer to drm device
  628. */
  629. void sde_kms_timeline_status(struct drm_device *dev);
  630. /**
  631. * sde_kms_handle_recovery - handler function for FIFO overflow issue
  632. * @encoder: pointer to drm encoder structure
  633. * return: 0 on success; error code otherwise
  634. */
  635. int sde_kms_handle_recovery(struct drm_encoder *encoder);
  636. /**
  637. * sde_kms_cpu_vote_for_irq() - API to keep pm_qos latency vote on cpu
  638. * where mdss_irq is scheduled
  639. * @sde_kms: pointer to sde_kms structure
  640. * @enable: true if enable request, false otherwise.
  641. */
  642. void sde_kms_cpu_vote_for_irq(struct sde_kms *sde_kms, bool enable);
  643. /**
  644. * sde_kms_get_io_resources() - reads associated register range
  645. * @kms: pointer to sde_kms structure
  646. * @io_res: pointer to msm_io_res struct to populate the ranges
  647. * Return: error code.
  648. */
  649. int sde_kms_get_io_resources(struct sde_kms *kms, struct msm_io_res *io_res);
  650. /**
  651. * sde_kms_vm_trusted_resource_init - reserve/initialize the HW/SW resources
  652. * @sde_kms: poiner to sde_kms structure
  653. * @state: current update atomic commit state
  654. * return: 0 on success; error code otherwise
  655. */
  656. int sde_kms_vm_trusted_resource_init(struct sde_kms *sde_kms,
  657. struct drm_atomic_state *state);
  658. /**
  659. * sde_kms_vm_trusted_resource_deinit - release the HW/SW resources
  660. * @sde_kms: poiner to sde_kms structure
  661. */
  662. void sde_kms_vm_trusted_resource_deinit(struct sde_kms *sde_kms);
  663. /**
  664. * sde_kms_vm_trusted_post_commit - function to prepare the VM after the
  665. * last commit before releasing the HW
  666. * resources from trusted VM
  667. * @sde_kms: pointer to sde_kms
  668. * @state: current frames atomic commit state
  669. */
  670. int sde_kms_vm_trusted_post_commit(struct sde_kms *sde_kms,
  671. struct drm_atomic_state *state);
  672. /**
  673. * sde_kms_vm_primary_post_commit - function to prepare the VM after the
  674. * last commit before assign the HW
  675. * resources from primary VM
  676. * @sde_kms: pointer to sde_kms
  677. * @state: current frames atomic commit state
  678. */
  679. int sde_kms_vm_primary_post_commit(struct sde_kms *sde_kms,
  680. struct drm_atomic_state *state);
  681. /**
  682. * sde_kms_vm_trusted_prepare_commit - function to prepare the VM before the
  683. * the first commit after the accepting
  684. * the HW resources in trusted VM.
  685. * @sde_kms: pointer to sde_kms
  686. * @state: current frame's atomic commit state
  687. */
  688. int sde_kms_vm_trusted_prepare_commit(struct sde_kms *sde_kms,
  689. struct drm_atomic_state *state);
  690. /**
  691. * sde_kms_vm_primary_prepare_commit - function to prepare the VM before the
  692. * the first commit after the reclaming
  693. * the HW resources in trusted VM.
  694. * @sde_kms: pointer to sde_kms
  695. * @state: current frame's atomic commit state
  696. */
  697. int sde_kms_vm_primary_prepare_commit(struct sde_kms *sde_kms,
  698. struct drm_atomic_state *state);
  699. void sde_kms_add_data_to_minidump_va(struct sde_kms *sde_kms);
  700. #endif /* __sde_kms_H__ */