Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 1 | /* |
Jeykumar Sankaran | 25fdd59 | 2018-06-27 15:26:09 -0400 | [diff] [blame^] | 2 | * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 3 | * 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 Viau | 7ca1271 | 2014-12-08 10:48:57 -0500 | [diff] [blame] | 27 | #define MAX_PLANE 4 |
| 28 | |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 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. |
| 33 | */ |
| 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); |
Rob Clark | 0b776d4 | 2015-01-30 17:04:45 -0500 | [diff] [blame] | 44 | /* modeset, bracketing atomic_commit(): */ |
| 45 | void (*prepare_commit)(struct msm_kms *kms, struct drm_atomic_state *state); |
Jeykumar Sankaran | 2b7ac1a | 2018-06-27 13:49:23 -0400 | [diff] [blame] | 46 | void (*commit)(struct msm_kms *kms, struct drm_atomic_state *state); |
Rob Clark | 0b776d4 | 2015-01-30 17:04:45 -0500 | [diff] [blame] | 47 | void (*complete_commit)(struct msm_kms *kms, struct drm_atomic_state *state); |
Hai Li | 0a5c9aa | 2015-04-28 19:35:37 -0400 | [diff] [blame] | 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); |
Jeykumar Sankaran | 4e49023 | 2018-02-13 12:42:44 -0500 | [diff] [blame] | 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); |
Jeykumar Sankaran | 25fdd59 | 2018-06-27 15:26:09 -0400 | [diff] [blame^] | 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); |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 60 | /* misc: */ |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 61 | long (*round_pixclk)(struct msm_kms *kms, unsigned long rate, |
| 62 | struct drm_encoder *encoder); |
Hai Li | 7a6dc95 | 2015-03-26 19:25:15 -0400 | [diff] [blame] | 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); |
Archit Taneja | 9c9f6f8 | 2016-12-05 15:24:53 +0530 | [diff] [blame] | 67 | void (*set_encoder_mode)(struct msm_kms *kms, |
| 68 | struct drm_encoder *encoder, |
| 69 | bool cmd_mode); |
Jeykumar Sankaran | 036bfeb | 2018-06-27 15:24:17 -0400 | [diff] [blame] | 70 | /* pm suspend/resume hooks */ |
| 71 | int (*pm_suspend)(struct device *dev); |
| 72 | int (*pm_resume)(struct device *dev); |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 73 | /* cleanup: */ |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 74 | void (*destroy)(struct msm_kms *kms); |
Rob Clark | bc5289e | 2016-10-26 14:06:55 -0400 | [diff] [blame] | 75 | #ifdef CONFIG_DEBUG_FS |
| 76 | /* debugfs: */ |
| 77 | int (*debugfs_init)(struct msm_kms *kms, struct drm_minor *minor); |
Rob Clark | bc5289e | 2016-10-26 14:06:55 -0400 | [diff] [blame] | 78 | #endif |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | struct msm_kms { |
| 82 | const struct msm_kms_funcs *funcs; |
Archit Taneja | a2b3a55 | 2016-05-18 15:06:03 +0530 | [diff] [blame] | 83 | |
| 84 | /* irq number to be passed on to drm_irq_install */ |
| 85 | int irq; |
Rob Clark | f59f62d | 2017-06-13 10:22:37 -0400 | [diff] [blame] | 86 | |
| 87 | /* mapper-id used to request GEM buffer mapped for scanout: */ |
Rob Clark | f59f62d | 2017-06-13 10:22:37 -0400 | [diff] [blame] | 88 | struct msm_gem_address_space *aspace; |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 89 | }; |
| 90 | |
Rob Clark | 9e0efa6 | 2013-11-30 17:24:22 -0500 | [diff] [blame] | 91 | static inline void msm_kms_init(struct msm_kms *kms, |
| 92 | const struct msm_kms_funcs *funcs) |
| 93 | { |
| 94 | kms->funcs = funcs; |
| 95 | } |
| 96 | |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 97 | struct msm_kms *mdp4_kms_init(struct drm_device *dev); |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 98 | struct msm_kms *mdp5_kms_init(struct drm_device *dev); |
Jeykumar Sankaran | 25fdd59 | 2018-06-27 15:26:09 -0400 | [diff] [blame^] | 99 | struct msm_kms *dpu_kms_init(struct drm_device *dev); |
Rajesh Yadav | bc3220b | 2018-06-21 16:06:10 -0400 | [diff] [blame] | 100 | |
| 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); |
| 105 | }; |
| 106 | |
| 107 | struct msm_mdss { |
| 108 | struct drm_device *dev; |
| 109 | const struct msm_mdss_funcs *funcs; |
| 110 | }; |
| 111 | |
| 112 | int mdp5_mdss_init(struct drm_device *dev); |
Jeykumar Sankaran | 25fdd59 | 2018-06-27 15:26:09 -0400 | [diff] [blame^] | 113 | int dpu_mdss_init(struct drm_device *dev); |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 114 | |
| 115 | #endif /* __MSM_KMS_H__ */ |