| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2016-2018, 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 | 4 | */ |
|---|
| 14 | 5 | |
|---|
| 15 | 6 | #ifndef __DPU_RM_H__ |
|---|
| .. | .. |
|---|
| 20 | 11 | #include "msm_kms.h" |
|---|
| 21 | 12 | #include "dpu_hw_top.h" |
|---|
| 22 | 13 | |
|---|
| 23 | | -/** |
|---|
| 24 | | - * enum dpu_rm_topology_name - HW resource use case in use by connector |
|---|
| 25 | | - * @DPU_RM_TOPOLOGY_NONE: No topology in use currently |
|---|
| 26 | | - * @DPU_RM_TOPOLOGY_SINGLEPIPE: 1 LM, 1 PP, 1 INTF/WB |
|---|
| 27 | | - * @DPU_RM_TOPOLOGY_DUALPIPE: 2 LM, 2 PP, 2 INTF/WB |
|---|
| 28 | | - * @DPU_RM_TOPOLOGY_DUALPIPE_3DMERGE: 2 LM, 2 PP, 3DMux, 1 INTF/WB |
|---|
| 29 | | - */ |
|---|
| 30 | | -enum dpu_rm_topology_name { |
|---|
| 31 | | - DPU_RM_TOPOLOGY_NONE = 0, |
|---|
| 32 | | - DPU_RM_TOPOLOGY_SINGLEPIPE, |
|---|
| 33 | | - DPU_RM_TOPOLOGY_DUALPIPE, |
|---|
| 34 | | - DPU_RM_TOPOLOGY_DUALPIPE_3DMERGE, |
|---|
| 35 | | - DPU_RM_TOPOLOGY_MAX, |
|---|
| 36 | | -}; |
|---|
| 37 | | - |
|---|
| 38 | | -/** |
|---|
| 39 | | - * enum dpu_rm_topology_control - HW resource use case in use by connector |
|---|
| 40 | | - * @DPU_RM_TOPCTL_RESERVE_LOCK: If set, in AtomicTest phase, after a successful |
|---|
| 41 | | - * test, reserve the resources for this display. |
|---|
| 42 | | - * Normal behavior would not impact the reservation |
|---|
| 43 | | - * list during the AtomicTest phase. |
|---|
| 44 | | - * @DPU_RM_TOPCTL_RESERVE_CLEAR: If set, in AtomicTest phase, before testing, |
|---|
| 45 | | - * release any reservation held by this display. |
|---|
| 46 | | - * Normal behavior would not impact the |
|---|
| 47 | | - * reservation list during the AtomicTest phase. |
|---|
| 48 | | - * @DPU_RM_TOPCTL_DS : Require layer mixers with DS capabilities |
|---|
| 49 | | - */ |
|---|
| 50 | | -enum dpu_rm_topology_control { |
|---|
| 51 | | - DPU_RM_TOPCTL_RESERVE_LOCK, |
|---|
| 52 | | - DPU_RM_TOPCTL_RESERVE_CLEAR, |
|---|
| 53 | | - DPU_RM_TOPCTL_DS, |
|---|
| 54 | | -}; |
|---|
| 14 | +struct dpu_global_state; |
|---|
| 55 | 15 | |
|---|
| 56 | 16 | /** |
|---|
| 57 | 17 | * struct dpu_rm - DPU dynamic hardware resource manager |
|---|
| 58 | | - * @dev: device handle for event logging purposes |
|---|
| 59 | | - * @rsvps: list of hardware reservations by each crtc->encoder->connector |
|---|
| 60 | | - * @hw_blks: array of lists of hardware resources present in the system, one |
|---|
| 61 | | - * list per type of hardware block |
|---|
| 62 | | - * @hw_mdp: hardware object for mdp_top |
|---|
| 18 | + * @pingpong_blks: array of pingpong hardware resources |
|---|
| 19 | + * @mixer_blks: array of layer mixer hardware resources |
|---|
| 20 | + * @ctl_blks: array of ctl hardware resources |
|---|
| 21 | + * @intf_blks: array of intf hardware resources |
|---|
| 22 | + * @dspp_blks: array of dspp hardware resources |
|---|
| 63 | 23 | * @lm_max_width: cached layer mixer maximum width |
|---|
| 64 | | - * @rsvp_next_seq: sequence number for next reservation for debugging purposes |
|---|
| 65 | 24 | * @rm_lock: resource manager mutex |
|---|
| 66 | 25 | */ |
|---|
| 67 | 26 | struct dpu_rm { |
|---|
| 68 | | - struct drm_device *dev; |
|---|
| 69 | | - struct list_head rsvps; |
|---|
| 70 | | - struct list_head hw_blks[DPU_HW_BLK_MAX]; |
|---|
| 71 | | - struct dpu_hw_mdp *hw_mdp; |
|---|
| 27 | + struct dpu_hw_blk *pingpong_blks[PINGPONG_MAX - PINGPONG_0]; |
|---|
| 28 | + struct dpu_hw_blk *mixer_blks[LM_MAX - LM_0]; |
|---|
| 29 | + struct dpu_hw_blk *ctl_blks[CTL_MAX - CTL_0]; |
|---|
| 30 | + struct dpu_hw_blk *intf_blks[INTF_MAX - INTF_0]; |
|---|
| 31 | + struct dpu_hw_blk *dspp_blks[DSPP_MAX - DSPP_0]; |
|---|
| 32 | + |
|---|
| 72 | 33 | uint32_t lm_max_width; |
|---|
| 73 | | - uint32_t rsvp_next_seq; |
|---|
| 74 | | - struct mutex rm_lock; |
|---|
| 75 | | -}; |
|---|
| 76 | | - |
|---|
| 77 | | -/** |
|---|
| 78 | | - * struct dpu_rm_hw_blk - resource manager internal structure |
|---|
| 79 | | - * forward declaration for single iterator definition without void pointer |
|---|
| 80 | | - */ |
|---|
| 81 | | -struct dpu_rm_hw_blk; |
|---|
| 82 | | - |
|---|
| 83 | | -/** |
|---|
| 84 | | - * struct dpu_rm_hw_iter - iterator for use with dpu_rm |
|---|
| 85 | | - * @hw: dpu_hw object requested, or NULL on failure |
|---|
| 86 | | - * @blk: dpu_rm internal block representation. Clients ignore. Used as iterator. |
|---|
| 87 | | - * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder |
|---|
| 88 | | - * @type: Hardware Block Type client wishes to search for. |
|---|
| 89 | | - */ |
|---|
| 90 | | -struct dpu_rm_hw_iter { |
|---|
| 91 | | - void *hw; |
|---|
| 92 | | - struct dpu_rm_hw_blk *blk; |
|---|
| 93 | | - uint32_t enc_id; |
|---|
| 94 | | - enum dpu_hw_blk_type type; |
|---|
| 95 | 34 | }; |
|---|
| 96 | 35 | |
|---|
| 97 | 36 | /** |
|---|
| .. | .. |
|---|
| 100 | 39 | * @rm: DPU Resource Manager handle |
|---|
| 101 | 40 | * @cat: Pointer to hardware catalog |
|---|
| 102 | 41 | * @mmio: mapped register io address of MDP |
|---|
| 103 | | - * @dev: device handle for event logging purposes |
|---|
| 104 | 42 | * @Return: 0 on Success otherwise -ERROR |
|---|
| 105 | 43 | */ |
|---|
| 106 | 44 | int dpu_rm_init(struct dpu_rm *rm, |
|---|
| 107 | 45 | struct dpu_mdss_cfg *cat, |
|---|
| 108 | | - void __iomem *mmio, |
|---|
| 109 | | - struct drm_device *dev); |
|---|
| 46 | + void __iomem *mmio); |
|---|
| 110 | 47 | |
|---|
| 111 | 48 | /** |
|---|
| 112 | 49 | * dpu_rm_destroy - Free all memory allocated by dpu_rm_init |
|---|
| .. | .. |
|---|
| 125 | 62 | * @rm: DPU Resource Manager handle |
|---|
| 126 | 63 | * @drm_enc: DRM Encoder handle |
|---|
| 127 | 64 | * @crtc_state: Proposed Atomic DRM CRTC State handle |
|---|
| 128 | | - * @conn_state: Proposed Atomic DRM Connector State handle |
|---|
| 129 | 65 | * @topology: Pointer to topology info for the display |
|---|
| 130 | | - * @test_only: Atomic-Test phase, discard results (unless property overrides) |
|---|
| 131 | 66 | * @Return: 0 on Success otherwise -ERROR |
|---|
| 132 | 67 | */ |
|---|
| 133 | 68 | int dpu_rm_reserve(struct dpu_rm *rm, |
|---|
| 69 | + struct dpu_global_state *global_state, |
|---|
| 134 | 70 | struct drm_encoder *drm_enc, |
|---|
| 135 | 71 | struct drm_crtc_state *crtc_state, |
|---|
| 136 | | - struct drm_connector_state *conn_state, |
|---|
| 137 | | - struct msm_display_topology topology, |
|---|
| 138 | | - bool test_only); |
|---|
| 72 | + struct msm_display_topology topology); |
|---|
| 139 | 73 | |
|---|
| 140 | 74 | /** |
|---|
| 141 | 75 | * dpu_rm_reserve - Given the encoder for the display chain, release any |
|---|
| .. | .. |
|---|
| 144 | 78 | * @enc: DRM Encoder handle |
|---|
| 145 | 79 | * @Return: 0 on Success otherwise -ERROR |
|---|
| 146 | 80 | */ |
|---|
| 147 | | -void dpu_rm_release(struct dpu_rm *rm, struct drm_encoder *enc); |
|---|
| 81 | +void dpu_rm_release(struct dpu_global_state *global_state, |
|---|
| 82 | + struct drm_encoder *enc); |
|---|
| 148 | 83 | |
|---|
| 149 | 84 | /** |
|---|
| 150 | | - * dpu_rm_get_mdp - Retrieve HW block for MDP TOP. |
|---|
| 151 | | - * This is never reserved, and is usable by any display. |
|---|
| 152 | | - * @rm: DPU Resource Manager handle |
|---|
| 153 | | - * @Return: Pointer to hw block or NULL |
|---|
| 85 | + * Get hw resources of the given type that are assigned to this encoder. |
|---|
| 154 | 86 | */ |
|---|
| 155 | | -struct dpu_hw_mdp *dpu_rm_get_mdp(struct dpu_rm *rm); |
|---|
| 156 | | - |
|---|
| 157 | | -/** |
|---|
| 158 | | - * dpu_rm_init_hw_iter - setup given iterator for new iteration over hw list |
|---|
| 159 | | - * using dpu_rm_get_hw |
|---|
| 160 | | - * @iter: iter object to initialize |
|---|
| 161 | | - * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder |
|---|
| 162 | | - * @type: Hardware Block Type client wishes to search for. |
|---|
| 163 | | - */ |
|---|
| 164 | | -void dpu_rm_init_hw_iter( |
|---|
| 165 | | - struct dpu_rm_hw_iter *iter, |
|---|
| 166 | | - uint32_t enc_id, |
|---|
| 167 | | - enum dpu_hw_blk_type type); |
|---|
| 168 | | -/** |
|---|
| 169 | | - * dpu_rm_get_hw - retrieve reserved hw object given encoder and hw type |
|---|
| 170 | | - * Meant to do a single pass through the hardware list to iteratively |
|---|
| 171 | | - * retrieve hardware blocks of a given type for a given encoder. |
|---|
| 172 | | - * Initialize an iterator object. |
|---|
| 173 | | - * Set hw block type of interest. Set encoder id of interest, 0 for any. |
|---|
| 174 | | - * Function returns first hw of type for that encoder. |
|---|
| 175 | | - * Subsequent calls will return the next reserved hw of that type in-order. |
|---|
| 176 | | - * Iterator HW pointer will be null on failure to find hw. |
|---|
| 177 | | - * @rm: DPU Resource Manager handle |
|---|
| 178 | | - * @iter: iterator object |
|---|
| 179 | | - * @Return: true on match found, false on no match found |
|---|
| 180 | | - */ |
|---|
| 181 | | -bool dpu_rm_get_hw(struct dpu_rm *rm, struct dpu_rm_hw_iter *iter); |
|---|
| 182 | | - |
|---|
| 183 | | -/** |
|---|
| 184 | | - * dpu_rm_check_property_topctl - validate property bitmask before it is set |
|---|
| 185 | | - * @val: user's proposed topology control bitmask |
|---|
| 186 | | - * @Return: 0 on success or error |
|---|
| 187 | | - */ |
|---|
| 188 | | -int dpu_rm_check_property_topctl(uint64_t val); |
|---|
| 189 | | - |
|---|
| 190 | | -/** |
|---|
| 191 | | - * dpu_rm_get_topology_name - returns the name of the the given topology |
|---|
| 192 | | - * definition |
|---|
| 193 | | - * @topology: topology definition |
|---|
| 194 | | - * @Return: name of the topology |
|---|
| 195 | | - */ |
|---|
| 196 | | -enum dpu_rm_topology_name |
|---|
| 197 | | -dpu_rm_get_topology_name(struct msm_display_topology topology); |
|---|
| 198 | | - |
|---|
| 87 | +int dpu_rm_get_assigned_resources(struct dpu_rm *rm, |
|---|
| 88 | + struct dpu_global_state *global_state, uint32_t enc_id, |
|---|
| 89 | + enum dpu_hw_blk_type type, struct dpu_hw_blk **blks, int blks_size); |
|---|
| 199 | 90 | #endif /* __DPU_RM_H__ */ |
|---|
| 91 | + |
|---|