blob: fd88cebb6adb339f489137178bd49e8ec0b0eafc [file] [log] [blame]
Rob Clarkdd2da6e2013-11-30 16:12:10 -05001/*
Jeykumar Sankaran25fdd592018-06-27 15:26:09 -04002 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
Rob Clarkdd2da6e2013-11-30 16:12:10 -05003 * Copyright (C) 2013 Red Hat
4 * 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/>.
17 */
18
19#ifndef __MSM_KMS_H__
20#define __MSM_KMS_H__
21
22#include <linux/clk.h>
23#include <linux/regulator/consumer.h>
24
25#include "msm_drv.h"
26
Stephane Viau7ca12712014-12-08 10:48:57 -050027#define MAX_PLANE 4
28
Rob Clarkdd2da6e2013-11-30 16:12:10 -050029/* 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.
33 */
34struct 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);
Rob Clark0b776d42015-01-30 17:04:45 -050044 /* modeset, bracketing atomic_commit(): */
45 void (*prepare_commit)(struct msm_kms *kms, struct drm_atomic_state *state);
Jeykumar Sankaran2b7ac1a2018-06-27 13:49:23 -040046 void (*commit)(struct msm_kms *kms, struct drm_atomic_state *state);
Rob Clark0b776d42015-01-30 17:04:45 -050047 void (*complete_commit)(struct msm_kms *kms, struct drm_atomic_state *state);
Hai Li0a5c9aa2015-04-28 19:35:37 -040048 /* 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);
Jeykumar Sankaran4e490232018-02-13 12:42:44 -050051 /* 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);
Jeykumar Sankaran25fdd592018-06-27 15:26:09 -040055 /* 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);
Rob Clarkdd2da6e2013-11-30 16:12:10 -050060 /* misc: */
Rob Clarkdd2da6e2013-11-30 16:12:10 -050061 long (*round_pixclk)(struct msm_kms *kms, unsigned long rate,
62 struct drm_encoder *encoder);
Hai Li7a6dc952015-03-26 19:25:15 -040063 int (*set_split_display)(struct msm_kms *kms,
64 struct drm_encoder *encoder,
65 struct drm_encoder *slave_encoder,
66 bool is_cmd_mode);
Archit Taneja9c9f6f82016-12-05 15:24:53 +053067 void (*set_encoder_mode)(struct msm_kms *kms,
68 struct drm_encoder *encoder,
69 bool cmd_mode);
Jeykumar Sankaran036bfeb2018-06-27 15:24:17 -040070 /* pm suspend/resume hooks */
71 int (*pm_suspend)(struct device *dev);
72 int (*pm_resume)(struct device *dev);
Rob Clarkdd2da6e2013-11-30 16:12:10 -050073 /* cleanup: */
Rob Clarkdd2da6e2013-11-30 16:12:10 -050074 void (*destroy)(struct msm_kms *kms);
Rob Clarkbc5289e2016-10-26 14:06:55 -040075#ifdef CONFIG_DEBUG_FS
76 /* debugfs: */
77 int (*debugfs_init)(struct msm_kms *kms, struct drm_minor *minor);
Rob Clarkbc5289e2016-10-26 14:06:55 -040078#endif
Rob Clarkdd2da6e2013-11-30 16:12:10 -050079};
80
81struct msm_kms {
82 const struct msm_kms_funcs *funcs;
Archit Tanejaa2b3a552016-05-18 15:06:03 +053083
84 /* irq number to be passed on to drm_irq_install */
85 int irq;
Rob Clarkf59f62d2017-06-13 10:22:37 -040086
87 /* mapper-id used to request GEM buffer mapped for scanout: */
Rob Clarkf59f62d2017-06-13 10:22:37 -040088 struct msm_gem_address_space *aspace;
Rob Clarkdd2da6e2013-11-30 16:12:10 -050089};
90
Rob Clark9e0efa62013-11-30 17:24:22 -050091static inline void msm_kms_init(struct msm_kms *kms,
92 const struct msm_kms_funcs *funcs)
93{
94 kms->funcs = funcs;
95}
96
Rob Clarkdd2da6e2013-11-30 16:12:10 -050097struct msm_kms *mdp4_kms_init(struct drm_device *dev);
Rob Clark06c0dd92013-11-30 17:51:47 -050098struct msm_kms *mdp5_kms_init(struct drm_device *dev);
Jeykumar Sankaran25fdd592018-06-27 15:26:09 -040099struct msm_kms *dpu_kms_init(struct drm_device *dev);
Rajesh Yadavbc3220b2018-06-21 16:06:10 -0400100
101struct msm_mdss_funcs {
102 int (*enable)(struct msm_mdss *mdss);
103 int (*disable)(struct msm_mdss *mdss);
104 void (*destroy)(struct drm_device *dev);
105};
106
107struct msm_mdss {
108 struct drm_device *dev;
109 const struct msm_mdss_funcs *funcs;
110};
111
112int mdp5_mdss_init(struct drm_device *dev);
Jeykumar Sankaran25fdd592018-06-27 15:26:09 -0400113int dpu_mdss_init(struct drm_device *dev);
Rob Clarkdd2da6e2013-11-30 16:12:10 -0500114
115#endif /* __MSM_KMS_H__ */