Lloyd Atkinson | ccc11c5 | 2016-08-10 18:54:30 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef __SDE_KMS_RM_H__ |
| 16 | #define __SDE_KMS_RM_H__ |
| 17 | |
| 18 | #include <linux/list.h> |
| 19 | |
| 20 | #include "msm_kms.h" |
| 21 | #include "sde_hw_top.h" |
| 22 | |
| 23 | /** |
| 24 | * enum sde_rm_topology_name - HW resource use case in use by connector |
| 25 | * @SDE_RM_TOPOLOGY_UNKNOWN: No topology in use currently |
| 26 | * @SDE_RM_TOPOLOGY_SINGLEPIPE: 1 LM, 1 PP, 1 INTF/WB |
| 27 | * @SDE_RM_TOPOLOGY_DUALPIPE: 2 LM, 2 PP, 2 INTF/WB |
| 28 | * @SDE_RM_TOPOLOGY_PPSPLIT: 1 LM, 2 PPs, 2 INTF/WB |
| 29 | * @SDE_RM_TOPOLOGY_DUALPIPEMERGE: 2 LM, 2 PP, 3DMux, 1 INTF/WB |
| 30 | */ |
| 31 | enum sde_rm_topology_name { |
| 32 | SDE_RM_TOPOLOGY_UNKNOWN = 0, |
| 33 | SDE_RM_TOPOLOGY_SINGLEPIPE, |
| 34 | SDE_RM_TOPOLOGY_DUALPIPE, |
| 35 | SDE_RM_TOPOLOGY_PPSPLIT, |
| 36 | SDE_RM_TOPOLOGY_DUALPIPEMERGE, |
| 37 | }; |
| 38 | |
| 39 | /** |
| 40 | * enum sde_rm_topology_control - HW resource use case in use by connector |
| 41 | * @SDE_RM_TOPCTL_RESERVE_LOCK: If set, in AtomicTest phase, after a successful |
| 42 | * test, reserve the resources for this display. |
| 43 | * Normal behavior would not impact the reservation |
| 44 | * list during the AtomicTest phase. |
| 45 | * @SDE_RM_TOPCTL_RESERVE_CLEAR: If set, in AtomicTest phase, before testing, |
| 46 | * release any reservation held by this display. |
| 47 | * Normal behavior would not impact the |
| 48 | * reservation list during the AtomicTest phase. |
| 49 | * @SDE_RM_TOPCTL_DSPP: Require layer mixers with DSPP capabilities |
| 50 | * @SDE_RM_TOPCTL_FORCE_TILING: Require kernel to split across multiple layer |
| 51 | * mixers, despite width fitting within capability |
| 52 | * of a single layer mixer. |
| 53 | * @SDE_RM_TOPCTL_PPSPLIT: Require kernel to use pingpong split pipe |
| 54 | * configuration instead of dual pipe. |
| 55 | */ |
| 56 | enum sde_rm_topology_control { |
| 57 | SDE_RM_TOPCTL_RESERVE_LOCK, |
| 58 | SDE_RM_TOPCTL_RESERVE_CLEAR, |
| 59 | SDE_RM_TOPCTL_DSPP, |
| 60 | SDE_RM_TOPCTL_FORCE_TILING, |
| 61 | SDE_RM_TOPCTL_PPSPLIT, |
| 62 | }; |
| 63 | |
| 64 | /** |
| 65 | * struct sde_rm - SDE dynamic hardware resource manager |
| 66 | * @dev: device handle for event logging purposes |
| 67 | * @rsvps: list of hardware reservations by each crtc->encoder->connector |
| 68 | * @hw_blks: list of hardware resources present in the system |
| 69 | * @hw_mdp: hardware object for mdp_top |
| 70 | * @lm_max_width: cached layer mixer maximum width |
| 71 | * @rsvp_next_seq: sequence number for next reservation for debugging purposes |
| 72 | */ |
| 73 | struct sde_rm { |
| 74 | struct drm_device *dev; |
| 75 | struct list_head rsvps; |
| 76 | struct list_head hw_blks; |
| 77 | struct sde_hw_mdp *hw_mdp; |
| 78 | uint32_t lm_max_width; |
| 79 | uint32_t rsvp_next_seq; |
| 80 | }; |
| 81 | |
| 82 | /** |
| 83 | * struct sde_rm_hw_blk - resource manager internal structure |
| 84 | * forward declaration for single iterator definition without void pointer |
| 85 | */ |
| 86 | struct sde_rm_hw_blk; |
| 87 | |
| 88 | /** |
| 89 | * struct sde_rm_hw_iter - iterator for use with sde_rm |
| 90 | * @hw: sde_hw object requested, or NULL on failure |
| 91 | * @blk: sde_rm internal block representation. Clients ignore. Used as iterator. |
| 92 | * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder |
| 93 | * @type: Hardware Block Type client wishes to search for. |
| 94 | */ |
| 95 | struct sde_rm_hw_iter { |
| 96 | void *hw; |
| 97 | struct sde_rm_hw_blk *blk; |
| 98 | uint32_t enc_id; |
| 99 | enum sde_hw_blk_type type; |
| 100 | }; |
| 101 | |
| 102 | /** |
| 103 | * sde_rm_init - Read hardware catalog and create reservation tracking objects |
| 104 | * for all HW blocks. |
| 105 | * @rm: SDE Resource Manager handle |
| 106 | * @cat: Pointer to hardware catalog |
| 107 | * @mmio: mapped register io address of MDP |
| 108 | * @dev: device handle for event logging purposes |
| 109 | * @Return: 0 on Success otherwise -ERROR |
| 110 | */ |
| 111 | int sde_rm_init(struct sde_rm *rm, |
| 112 | struct sde_mdss_cfg *cat, |
| 113 | void *mmio, |
| 114 | struct drm_device *dev); |
| 115 | |
| 116 | /** |
| 117 | * sde_rm_destroy - Free all memory allocated by sde_rm_init |
| 118 | * @rm: SDE Resource Manager handle |
| 119 | * @Return: 0 on Success otherwise -ERROR |
| 120 | */ |
| 121 | int sde_rm_destroy(struct sde_rm *rm); |
| 122 | |
| 123 | /** |
| 124 | * sde_rm_reserve - Given a CRTC->Encoder->Connector display chain, analyze |
| 125 | * the use connections and user requirements, specified through related |
| 126 | * topology control properties, and reserve hardware blocks to that |
| 127 | * display chain. |
| 128 | * HW blocks can then be accessed through sde_rm_get_* functions. |
| 129 | * HW Reservations should be released via sde_rm_release_hw. |
| 130 | * @rm: SDE Resource Manager handle |
| 131 | * @drm_enc: DRM Encoder handle |
| 132 | * @crtc_state: Proposed Atomic DRM CRTC State handle |
| 133 | * @conn_state: Proposed Atomic DRM Connector State handle |
| 134 | * @test_only: Atomic-Test phase, discard results (unless property overrides) |
| 135 | * @Return: 0 on Success otherwise -ERROR |
| 136 | */ |
| 137 | int sde_rm_reserve(struct sde_rm *rm, |
| 138 | struct drm_encoder *drm_enc, |
| 139 | struct drm_crtc_state *crtc_state, |
| 140 | struct drm_connector_state *conn_state, |
| 141 | bool test_only); |
| 142 | |
| 143 | /** |
| 144 | * sde_rm_reserve - Given the encoder for the display chain, release any |
| 145 | * HW blocks previously reserved for that use case. |
| 146 | * @rm: SDE Resource Manager handle |
| 147 | * @enc: DRM Encoder handle |
| 148 | * @Return: 0 on Success otherwise -ERROR |
| 149 | */ |
| 150 | void sde_rm_release(struct sde_rm *rm, struct drm_encoder *enc); |
| 151 | |
| 152 | /** |
| 153 | * sde_rm_get_mdp - Retrieve HW block for MDP TOP. |
| 154 | * This is never reserved, and is usable by any display. |
| 155 | * @rm: SDE Resource Manager handle |
| 156 | * @Return: Pointer to hw block or NULL |
| 157 | */ |
| 158 | struct sde_hw_mdp *sde_rm_get_mdp(struct sde_rm *rm); |
| 159 | |
| 160 | /** |
| 161 | * sde_rm_init_hw_iter - setup given iterator for new iteration over hw list |
| 162 | * using sde_rm_get_hw |
| 163 | * @iter: iter object to initialize |
| 164 | * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder |
| 165 | * @type: Hardware Block Type client wishes to search for. |
| 166 | */ |
| 167 | void sde_rm_init_hw_iter( |
| 168 | struct sde_rm_hw_iter *iter, |
| 169 | uint32_t enc_id, |
| 170 | enum sde_hw_blk_type type); |
| 171 | /** |
| 172 | * sde_rm_get_hw - retrieve reserved hw object given encoder and hw type |
| 173 | * Meant to do a single pass through the hardware list to iteratively |
| 174 | * retrieve hardware blocks of a given type for a given encoder. |
| 175 | * Initialize an iterator object. |
| 176 | * Set hw block type of interest. Set encoder id of interest, 0 for any. |
| 177 | * Function returns first hw of type for that encoder. |
| 178 | * Subsequent calls will return the next reserved hw of that type in-order. |
| 179 | * Iterator HW pointer will be null on failure to find hw. |
| 180 | * @rm: SDE Resource Manager handle |
| 181 | * @iter: iterator object |
| 182 | * @Return: true on match found, false on no match found |
| 183 | */ |
| 184 | bool sde_rm_get_hw(struct sde_rm *rm, struct sde_rm_hw_iter *iter); |
| 185 | |
| 186 | /** |
| 187 | * sde_rm_check_property_topctl - validate property bitmask before it is set |
| 188 | * @val: user's proposed topology control bitmask |
| 189 | * @Return: 0 on success or error |
| 190 | */ |
| 191 | int sde_rm_check_property_topctl(uint64_t val); |
| 192 | |
Lloyd Atkinson | 11f3444 | 2016-08-11 11:19:52 -0400 | [diff] [blame] | 193 | /** |
| 194 | * sde_rm_check_property_topctl - validate property bitmask before it is set |
| 195 | * @val: user's proposed topology control bitmask |
| 196 | * @Return: 0 on success or error |
| 197 | */ |
| 198 | int sde_rm_check_property_topctl(uint64_t val); |
| 199 | |
Lloyd Atkinson | ccc11c5 | 2016-08-10 18:54:30 -0400 | [diff] [blame] | 200 | #endif /* __sde_kms_rm_H__ */ |