Linux 4.19.133
[linux/fpc-iii.git] / drivers / gpu / drm / msm / msm_kms.h
blobfd88cebb6adb339f489137178bd49e8ec0b0eafc
1 /*
2 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
3 * Copyright (C) 2013 Red Hat
4 * Author: Rob Clark <robdclark@gmail.com>
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.
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.
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/>.
19 #ifndef __MSM_KMS_H__
20 #define __MSM_KMS_H__
22 #include <linux/clk.h>
23 #include <linux/regulator/consumer.h>
25 #include "msm_drv.h"
27 #define MAX_PLANE 4
29 /* As there are different display controller blocks depending on the
30 * snapdragon version, the kms support is split out and the appropriate
31 * implementation is loaded at runtime. The kms module is responsible
32 * for constructing the appropriate planes/crtcs/encoders/connectors.
34 struct msm_kms_funcs {
35 /* hw initialization: */
36 int (*hw_init)(struct msm_kms *kms);
37 /* irq handling: */
38 void (*irq_preinstall)(struct msm_kms *kms);
39 int (*irq_postinstall)(struct msm_kms *kms);
40 void (*irq_uninstall)(struct msm_kms *kms);
41 irqreturn_t (*irq)(struct msm_kms *kms);
42 int (*enable_vblank)(struct msm_kms *kms, struct drm_crtc *crtc);
43 void (*disable_vblank)(struct msm_kms *kms, struct drm_crtc *crtc);
44 /* modeset, bracketing atomic_commit(): */
45 void (*prepare_commit)(struct msm_kms *kms, struct drm_atomic_state *state);
46 void (*commit)(struct msm_kms *kms, struct drm_atomic_state *state);
47 void (*complete_commit)(struct msm_kms *kms, struct drm_atomic_state *state);
48 /* functions to wait for atomic commit completed on each CRTC */
49 void (*wait_for_crtc_commit_done)(struct msm_kms *kms,
50 struct drm_crtc *crtc);
51 /* get msm_format w/ optional format modifiers from drm_mode_fb_cmd2 */
52 const struct msm_format *(*get_format)(struct msm_kms *kms,
53 const uint32_t format,
54 const uint64_t modifiers);
55 /* do format checking on format modified through fb_cmd2 modifiers */
56 int (*check_modified_format)(const struct msm_kms *kms,
57 const struct msm_format *msm_fmt,
58 const struct drm_mode_fb_cmd2 *cmd,
59 struct drm_gem_object **bos);
60 /* misc: */
61 long (*round_pixclk)(struct msm_kms *kms, unsigned long rate,
62 struct drm_encoder *encoder);
63 int (*set_split_display)(struct msm_kms *kms,
64 struct drm_encoder *encoder,
65 struct drm_encoder *slave_encoder,
66 bool is_cmd_mode);
67 void (*set_encoder_mode)(struct msm_kms *kms,
68 struct drm_encoder *encoder,
69 bool cmd_mode);
70 /* pm suspend/resume hooks */
71 int (*pm_suspend)(struct device *dev);
72 int (*pm_resume)(struct device *dev);
73 /* cleanup: */
74 void (*destroy)(struct msm_kms *kms);
75 #ifdef CONFIG_DEBUG_FS
76 /* debugfs: */
77 int (*debugfs_init)(struct msm_kms *kms, struct drm_minor *minor);
78 #endif
81 struct msm_kms {
82 const struct msm_kms_funcs *funcs;
84 /* irq number to be passed on to drm_irq_install */
85 int irq;
87 /* mapper-id used to request GEM buffer mapped for scanout: */
88 struct msm_gem_address_space *aspace;
91 static inline void msm_kms_init(struct msm_kms *kms,
92 const struct msm_kms_funcs *funcs)
94 kms->funcs = funcs;
97 struct msm_kms *mdp4_kms_init(struct drm_device *dev);
98 struct msm_kms *mdp5_kms_init(struct drm_device *dev);
99 struct msm_kms *dpu_kms_init(struct drm_device *dev);
101 struct msm_mdss_funcs {
102 int (*enable)(struct msm_mdss *mdss);
103 int (*disable)(struct msm_mdss *mdss);
104 void (*destroy)(struct drm_device *dev);
107 struct msm_mdss {
108 struct drm_device *dev;
109 const struct msm_mdss_funcs *funcs;
112 int mdp5_mdss_init(struct drm_device *dev);
113 int dpu_mdss_init(struct drm_device *dev);
115 #endif /* __MSM_KMS_H__ */