File Index
Files and directories
Sign in
FILE

dpu_kms.h

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h OBJECTIVE-C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  4 * Copyright (C) 2013 Red Hat
  5 * Author: Rob Clark <robdclark@gmail.com>
  6 */
  7
  8#ifndef __DPU_KMS_H__
  9#define __DPU_KMS_H__
 10
 11#include <linux/interconnect.h>
 12
 13#include <drm/drm_drv.h>
 14
 15#include "msm_drv.h"
 16#include "msm_kms.h"
 17#include "msm_mmu.h"
 18#include "msm_gem.h"
 19#include "dpu_hw_catalog.h"
 20#include "dpu_hw_ctl.h"
 21#include "dpu_hw_lm.h"
 22#include "dpu_hw_interrupts.h"
 23#include "dpu_hw_top.h"
 24#include "dpu_rm.h"
 25#include "dpu_core_perf.h"
 26
 27#define DRMID(x) ((x) ? (x)->base.id : -1)
 28
 29/**
 30 * DPU_DEBUG - macro for kms/plane/crtc/encoder/connector logs
 31 * @fmt: Pointer to format string
 32 */
 33#define DPU_DEBUG(fmt, ...)                                                \
 34	DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__)
 35
 36/**
 37 * DPU_DEBUG_DRIVER - macro for hardware driver logging
 38 * @fmt: Pointer to format string
 39 */
 40#define DPU_DEBUG_DRIVER(fmt, ...)                                         \
 41	DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__)
 42
 43#define DPU_ERROR(fmt, ...) pr_err("[dpu error]" fmt, ##__VA_ARGS__)
 44#define DPU_ERROR_RATELIMITED(fmt, ...) pr_err_ratelimited("[dpu error]" fmt, ##__VA_ARGS__)
 45
 46/**
 47 * ktime_compare_safe - compare two ktime structures
 48 *	This macro is similar to the standard ktime_compare() function, but
 49 *	attempts to also handle ktime overflows.
 50 * @A: First ktime value
 51 * @B: Second ktime value
 52 * Returns: -1 if A < B, 0 if A == B, 1 if A > B
 53 */
 54#define ktime_compare_safe(A, B) \
 55	ktime_compare(ktime_sub((A), (B)), ktime_set(0, 0))
 56
 57extern bool dpu_use_virtual_planes;
 58
 59struct dpu_kms {
 60	struct msm_kms base;
 61	struct drm_device *dev;
 62	const struct dpu_mdss_cfg *catalog;
 63	const struct qcom_ubwc_cfg_data *mdss;
 64
 65	/* io/register spaces: */
 66	void __iomem *mmio, *vbif[VBIF_MAX];
 67
 68	struct regulator *vdd;
 69	struct regulator *mmagic;
 70	struct regulator *venus;
 71
 72	struct dpu_hw_intr *hw_intr;
 73
 74	struct dpu_core_perf perf;
 75
 76	/*
 77	 * Global private object state, Do not access directly, use
 78	 * dpu_kms_global_get_state()
 79	 */
 80	struct drm_private_obj global_state;
 81
 82	struct dpu_rm rm;
 83
 84	struct dpu_hw_vbif *hw_vbif[VBIF_MAX];
 85	struct dpu_hw_mdp *hw_mdp;
 86
 87	bool has_danger_ctrl;
 88
 89	struct platform_device *pdev;
 90	bool rpm_enabled;
 91
 92	struct clk_bulk_data *clocks;
 93	size_t num_clocks;
 94
 95	/* reference count bandwidth requests, so we know when we can
 96	 * release bandwidth.  Each atomic update increments, and frame-
 97	 * done event decrements.  Additionally, for video mode, the
 98	 * reference is incremented when crtc is enabled, and decremented
 99	 * when disabled.
100	 */
101	atomic_t bandwidth_ref;
102	struct icc_path *path[2];
103	u32 num_paths;
104};
105
106struct vsync_info {
107	u32 frame_count;
108	u32 line_count;
109};
110
111#define DPU_ENC_WR_PTR_START_TIMEOUT_US 20000
112
113#define DPU_ENC_MAX_POLL_TIMEOUT_US	2000
114
115#define to_dpu_kms(x) container_of(x, struct dpu_kms, base)
116
117#define to_dpu_global_state(x) container_of(x, struct dpu_global_state, base)
118
119/* Global private object state for tracking resources that are shared across
120 * multiple kms objects (planes/crtcs/etc).
121 */
122struct dpu_global_state {
123	struct drm_private_state base;
124
125	struct dpu_rm *rm;
126
127	uint32_t pingpong_to_crtc_id[PINGPONG_MAX - PINGPONG_0];
128	uint32_t mixer_to_crtc_id[LM_MAX - LM_0];
129	uint32_t ctl_to_crtc_id[CTL_MAX - CTL_0];
130	uint32_t dspp_to_crtc_id[DSPP_MAX - DSPP_0];
131	uint32_t dsc_to_crtc_id[DSC_MAX - DSC_0];
132	uint32_t cdm_to_crtc_id;
133
134	uint32_t sspp_to_crtc_id[SSPP_MAX - SSPP_NONE];
135	uint32_t cwb_to_crtc_id[CWB_MAX - CWB_0];
136};
137
138struct dpu_global_state
139	*dpu_kms_get_existing_global_state(struct dpu_kms *dpu_kms);
140struct dpu_global_state
141	*__must_check dpu_kms_get_global_state(struct drm_atomic_state *s);
142
143/**
144 * Debugfs functions - extra helper functions for debugfs support
145 *
146 * Main debugfs documentation is located at,
147 *
148 * Documentation/filesystems/debugfs.rst
149 *
150 * @dpu_debugfs_create_regset32: Create 32-bit register dump file
151 */
152
153void dpu_debugfs_create_regset32(const char *name, umode_t mode,
154		void *parent,
155		uint32_t offset, uint32_t length, struct dpu_kms *dpu_kms);
156
157/**
158 * DPU info management functions
159 * These functions/definitions allow for building up a 'dpu_info' structure
160 * containing one or more "key=value\n" entries.
161 */
162#define DPU_KMS_INFO_MAX_SIZE	4096
163
164/**
165 * Vblank enable/disable functions
166 */
167int dpu_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
168void dpu_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
169
170unsigned long dpu_kms_get_clk_rate(struct dpu_kms *dpu_kms, char *clock_name);
171
172#endif /* __dpu_kms_H__ */
~/ Read-only file preview.