hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
....@@ -1,37 +1,28 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
34 * Copyright (C) 2013 Red Hat
45 * Author: Rob Clark <robdclark@gmail.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published by
8
- * the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
15
- * You should have received a copy of the GNU General Public License along with
16
- * this program. If not, see <http://www.gnu.org/licenses/>.
176 */
187
198 #ifndef __DPU_KMS_H__
209 #define __DPU_KMS_H__
2110
11
+#include <linux/interconnect.h>
12
+
13
+#include <drm/drm_drv.h>
14
+
2215 #include "msm_drv.h"
2316 #include "msm_kms.h"
2417 #include "msm_mmu.h"
2518 #include "msm_gem.h"
26
-#include "dpu_dbg.h"
2719 #include "dpu_hw_catalog.h"
2820 #include "dpu_hw_ctl.h"
2921 #include "dpu_hw_lm.h"
3022 #include "dpu_hw_interrupts.h"
3123 #include "dpu_hw_top.h"
24
+#include "dpu_io_util.h"
3225 #include "dpu_rm.h"
33
-#include "dpu_power_handle.h"
34
-#include "dpu_irq.h"
3526 #include "dpu_core_perf.h"
3627
3728 #define DRMID(x) ((x) ? (x)->base.id : -1)
....@@ -42,7 +33,7 @@
4233 */
4334 #define DPU_DEBUG(fmt, ...) \
4435 do { \
45
- if (unlikely(drm_debug & DRM_UT_KMS)) \
36
+ if (drm_debug_enabled(DRM_UT_KMS)) \
4637 DRM_DEBUG(fmt, ##__VA_ARGS__); \
4738 else \
4839 pr_debug(fmt, ##__VA_ARGS__); \
....@@ -54,7 +45,7 @@
5445 */
5546 #define DPU_DEBUG_DRIVER(fmt, ...) \
5647 do { \
57
- if (unlikely(drm_debug & DRM_UT_DRIVER)) \
48
+ if (drm_debug_enabled(DRM_UT_DRIVER)) \
5849 DRM_ERROR(fmt, ##__VA_ARGS__); \
5950 else \
6051 pr_debug(fmt, ##__VA_ARGS__); \
....@@ -74,9 +65,6 @@
7465 ktime_compare(ktime_sub((A), (B)), ktime_set(0, 0))
7566
7667 #define DPU_NAME_SIZE 12
77
-
78
-/* timeout in frames waiting for frame done */
79
-#define DPU_FRAME_DONE_TIMEOUT 60
8068
8169 /*
8270 * struct dpu_irq_callback - IRQ callback handlers
....@@ -104,7 +92,6 @@
10492 atomic_t *enable_counts;
10593 atomic_t *irq_counts;
10694 spinlock_t cb_lock;
107
- struct dentry *debugfs_file;
10895 };
10996
11097 struct dpu_kms {
....@@ -113,18 +100,8 @@
113100 int core_rev;
114101 struct dpu_mdss_cfg *catalog;
115102
116
- struct dpu_power_handle phandle;
117
- struct dpu_power_client *core_client;
118
- struct dpu_power_event *power_event;
119
-
120
- /* directory entry for debugfs */
121
- struct dentry *debugfs_root;
122
- struct dentry *debugfs_danger;
123
- struct dentry *debugfs_vbif;
124
-
125103 /* io/register spaces: */
126104 void __iomem *mmio, *vbif[VBIF_MAX], *reg_dma;
127
- unsigned long mmio_len, vbif_len[VBIF_MAX], reg_dma_len;
128105
129106 struct regulator *vdd;
130107 struct regulator *mmagic;
....@@ -135,9 +112,12 @@
135112
136113 struct dpu_core_perf perf;
137114
138
- /* saved atomic state during system suspend */
139
- struct drm_atomic_state *suspend_state;
140
- bool suspend_block;
115
+ /*
116
+ * Global private object state, Do not access directly, use
117
+ * dpu_kms_global_get_state()
118
+ */
119
+ struct drm_modeset_lock global_state_lock;
120
+ struct drm_private_obj global_state;
141121
142122 struct dpu_rm rm;
143123 bool rm_init;
....@@ -149,7 +129,21 @@
149129
150130 struct platform_device *pdev;
151131 bool rpm_enabled;
132
+
133
+ struct opp_table *opp_table;
134
+ bool has_opp_table;
135
+
152136 struct dss_module_power mp;
137
+
138
+ /* reference count bandwidth requests, so we know when we can
139
+ * release bandwidth. Each atomic update increments, and frame-
140
+ * done event decrements. Additionally, for video mode, the
141
+ * reference is incremented when crtc is enabled, and decremented
142
+ * when disabled.
143
+ */
144
+ atomic_t bandwidth_ref;
145
+ struct icc_path *path[2];
146
+ u32 num_paths;
153147 };
154148
155149 struct vsync_info {
....@@ -159,43 +153,32 @@
159153
160154 #define to_dpu_kms(x) container_of(x, struct dpu_kms, base)
161155
162
-/* get struct msm_kms * from drm_device * */
163
-#define ddev_to_msm_kms(D) ((D) && (D)->dev_private ? \
164
- ((struct msm_drm_private *)((D)->dev_private))->kms : NULL)
156
+#define to_dpu_global_state(x) container_of(x, struct dpu_global_state, base)
165157
166
-/**
167
- * dpu_kms_is_suspend_state - whether or not the system is pm suspended
168
- * @dev: Pointer to drm device
169
- * Return: Suspend status
158
+/* Global private object state for tracking resources that are shared across
159
+ * multiple kms objects (planes/crtcs/etc).
170160 */
171
-static inline bool dpu_kms_is_suspend_state(struct drm_device *dev)
172
-{
173
- if (!ddev_to_msm_kms(dev))
174
- return false;
161
+struct dpu_global_state {
162
+ struct drm_private_state base;
175163
176
- return to_dpu_kms(ddev_to_msm_kms(dev))->suspend_state != NULL;
177
-}
164
+ uint32_t pingpong_to_enc_id[PINGPONG_MAX - PINGPONG_0];
165
+ uint32_t mixer_to_enc_id[LM_MAX - LM_0];
166
+ uint32_t ctl_to_enc_id[CTL_MAX - CTL_0];
167
+ uint32_t intf_to_enc_id[INTF_MAX - INTF_0];
168
+ uint32_t dspp_to_enc_id[DSPP_MAX - DSPP_0];
169
+};
178170
179
-/**
180
- * dpu_kms_is_suspend_blocked - whether or not commits are blocked due to pm
181
- * suspend status
182
- * @dev: Pointer to drm device
183
- * Return: True if commits should be rejected due to pm suspend
184
- */
185
-static inline bool dpu_kms_is_suspend_blocked(struct drm_device *dev)
186
-{
187
- if (!dpu_kms_is_suspend_state(dev))
188
- return false;
189
-
190
- return to_dpu_kms(ddev_to_msm_kms(dev))->suspend_block;
191
-}
171
+struct dpu_global_state
172
+ *dpu_kms_get_existing_global_state(struct dpu_kms *dpu_kms);
173
+struct dpu_global_state
174
+ *__must_check dpu_kms_get_global_state(struct drm_atomic_state *s);
192175
193176 /**
194177 * Debugfs functions - extra helper functions for debugfs support
195178 *
196179 * Main debugfs documentation is located at,
197180 *
198
- * Documentation/filesystems/debugfs.txt
181
+ * Documentation/filesystems/debugfs.rst
199182 *
200183 * @dpu_debugfs_setup_regset32: Initialize data for dpu_debugfs_create_regset32
201184 * @dpu_debugfs_create_regset32: Create 32-bit register dump file
....@@ -243,12 +226,8 @@
243226 * @mode: File mode within debugfs
244227 * @parent: Parent directory entry within debugfs, can be NULL
245228 * @regset: Pointer to persistent register block definition
246
- *
247
- * Return: dentry pointer for newly created file, use either debugfs_remove()
248
- * or debugfs_remove_recursive() (on a parent directory) to remove the
249
- * file
250229 */
251
-void *dpu_debugfs_create_regset32(const char *name, umode_t mode,
230
+void dpu_debugfs_create_regset32(const char *name, umode_t mode,
252231 void *parent, struct dpu_debugfs_regset32 *regset);
253232
254233 /**