blob: b2dd87d09f5a6f91bdf1f52bc793cd986bfa9b05 [file] [log] [blame]
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001/*
Lloyd Atkinsonb6b99172017-01-17 10:23:06 -05002 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04003 *
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
Lloyd Atkinson05ec9072016-09-12 15:44:46 -040015#ifndef __SDE_RM_H__
16#define __SDE_RM_H__
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040017
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
Jeykumar Sankaran2b098072017-03-16 17:25:59 -070025 * @SDE_RM_TOPOLOGY_NONE: No topology in use currently
26 * @SDE_RM_TOPOLOGY_SINGLEPIPE: 1 LM, 1 PP, 1 INTF/WB
27 * @SDE_RM_TOPOLOGY_SINGLEPIPE_DSC: 1 LM, 1 DSC, 1 PP, 1 INTF/WB
28 * @SDE_RM_TOPOLOGY_DUALPIPE: 2 LM, 2 PP, 2 INTF/WB
29 * @SDE_RM_TOPOLOGY_DUALPIPE_DSC: 2 LM, 2 DSC, 2 PP, 2 INTF/WB
30 * @SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE: 2 LM, 2 PP, 3DMux, 1 INTF/WB
31 * @SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_DSC: 2 LM, 2 PP, 3DMux, 1 DSC, 1 INTF/WB
32 * @SDE_RM_TOPOLOGY_DUALPIPE_DSCMERGE: 2 LM, 2 PP, 2 DSC Merge, 1 INTF/WB
33 * @SDE_RM_TOPOLOGY_PPSPLIT: 1 LM, 2 PPs, 2 INTF/WB
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040034 */
35enum sde_rm_topology_name {
Jeykumar Sankaran2b098072017-03-16 17:25:59 -070036 SDE_RM_TOPOLOGY_NONE = 0,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040037 SDE_RM_TOPOLOGY_SINGLEPIPE,
Jeykumar Sankaran2b098072017-03-16 17:25:59 -070038 SDE_RM_TOPOLOGY_SINGLEPIPE_DSC,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040039 SDE_RM_TOPOLOGY_DUALPIPE,
Jeykumar Sankaran2b098072017-03-16 17:25:59 -070040 SDE_RM_TOPOLOGY_DUALPIPE_DSC,
41 SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE,
42 SDE_RM_TOPOLOGY_DUALPIPE_3DMERGE_DSC,
43 SDE_RM_TOPOLOGY_DUALPIPE_DSCMERGE,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040044 SDE_RM_TOPOLOGY_PPSPLIT,
Jeykumar Sankaran2b098072017-03-16 17:25:59 -070045 SDE_RM_TOPOLOGY_MAX,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040046};
47
48/**
49 * enum sde_rm_topology_control - HW resource use case in use by connector
50 * @SDE_RM_TOPCTL_RESERVE_LOCK: If set, in AtomicTest phase, after a successful
51 * test, reserve the resources for this display.
52 * Normal behavior would not impact the reservation
53 * list during the AtomicTest phase.
54 * @SDE_RM_TOPCTL_RESERVE_CLEAR: If set, in AtomicTest phase, before testing,
55 * release any reservation held by this display.
56 * Normal behavior would not impact the
57 * reservation list during the AtomicTest phase.
58 * @SDE_RM_TOPCTL_DSPP: Require layer mixers with DSPP capabilities
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +053059 * @SDE_RM_TOPCTL_DS : Require layer mixers with DS capabilities
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040060 */
61enum sde_rm_topology_control {
62 SDE_RM_TOPCTL_RESERVE_LOCK,
63 SDE_RM_TOPCTL_RESERVE_CLEAR,
64 SDE_RM_TOPCTL_DSPP,
Sravanthi Kollukuduruc7bcde92017-06-16 12:44:39 +053065 SDE_RM_TOPCTL_DS,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040066};
67
68/**
69 * struct sde_rm - SDE dynamic hardware resource manager
70 * @dev: device handle for event logging purposes
71 * @rsvps: list of hardware reservations by each crtc->encoder->connector
Lloyd Atkinsond1709812016-08-31 10:04:02 -040072 * @hw_blks: array of lists of hardware resources present in the system, one
73 * list per type of hardware block
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040074 * @hw_mdp: hardware object for mdp_top
75 * @lm_max_width: cached layer mixer maximum width
76 * @rsvp_next_seq: sequence number for next reservation for debugging purposes
Lloyd Atkinsond3b14572017-04-26 08:33:55 -070077 * @rm_lock: resource manager mutex
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040078 */
79struct sde_rm {
80 struct drm_device *dev;
81 struct list_head rsvps;
Lloyd Atkinsond1709812016-08-31 10:04:02 -040082 struct list_head hw_blks[SDE_HW_BLK_MAX];
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040083 struct sde_hw_mdp *hw_mdp;
84 uint32_t lm_max_width;
85 uint32_t rsvp_next_seq;
Lloyd Atkinsond3b14572017-04-26 08:33:55 -070086 struct mutex rm_lock;
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040087};
88
89/**
90 * struct sde_rm_hw_blk - resource manager internal structure
91 * forward declaration for single iterator definition without void pointer
92 */
93struct sde_rm_hw_blk;
94
95/**
96 * struct sde_rm_hw_iter - iterator for use with sde_rm
97 * @hw: sde_hw object requested, or NULL on failure
98 * @blk: sde_rm internal block representation. Clients ignore. Used as iterator.
99 * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder
100 * @type: Hardware Block Type client wishes to search for.
101 */
102struct sde_rm_hw_iter {
103 void *hw;
104 struct sde_rm_hw_blk *blk;
105 uint32_t enc_id;
106 enum sde_hw_blk_type type;
107};
108
109/**
Jeykumar Sankaran83ddcb02017-10-27 11:34:50 -0700110 * sde_rm_get_topology_name - get the name of the given topology config
111 * @topology: msm_display_topology topology config
112 * @Return: name of the given topology
113 */
114enum sde_rm_topology_name sde_rm_get_topology_name(
115 struct msm_display_topology topology);
116
117
118/**
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400119 * sde_rm_init - Read hardware catalog and create reservation tracking objects
120 * for all HW blocks.
121 * @rm: SDE Resource Manager handle
122 * @cat: Pointer to hardware catalog
123 * @mmio: mapped register io address of MDP
124 * @dev: device handle for event logging purposes
125 * @Return: 0 on Success otherwise -ERROR
126 */
127int sde_rm_init(struct sde_rm *rm,
128 struct sde_mdss_cfg *cat,
Chandan Uddaraju9efbbe32017-11-09 23:57:05 -0800129 void __iomem *mmio,
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -0400130 struct drm_device *dev);
131
132/**
133 * sde_rm_destroy - Free all memory allocated by sde_rm_init
134 * @rm: SDE Resource Manager handle
135 * @Return: 0 on Success otherwise -ERROR
136 */
137int sde_rm_destroy(struct sde_rm *rm);
138
139/**
140 * sde_rm_reserve - Given a CRTC->Encoder->Connector display chain, analyze
141 * the use connections and user requirements, specified through related
142 * topology control properties, and reserve hardware blocks to that
143 * display chain.
144 * HW blocks can then be accessed through sde_rm_get_* functions.
145 * HW Reservations should be released via sde_rm_release_hw.
146 * @rm: SDE Resource Manager handle
147 * @drm_enc: DRM Encoder handle
148 * @crtc_state: Proposed Atomic DRM CRTC State handle
149 * @conn_state: Proposed Atomic DRM Connector State handle
150 * @test_only: Atomic-Test phase, discard results (unless property overrides)
151 * @Return: 0 on Success otherwise -ERROR
152 */
153int sde_rm_reserve(struct sde_rm *rm,
154 struct drm_encoder *drm_enc,
155 struct drm_crtc_state *crtc_state,
156 struct drm_connector_state *conn_state,
157 bool test_only);
158
159/**
160 * sde_rm_reserve - Given the encoder for the display chain, release any
161 * HW blocks previously reserved for that use case.
162 * @rm: SDE Resource Manager handle
163 * @enc: DRM Encoder handle
164 * @Return: 0 on Success otherwise -ERROR
165 */
166void sde_rm_release(struct sde_rm *rm, struct drm_encoder *enc);
167
168/**
169 * sde_rm_get_mdp - Retrieve HW block for MDP TOP.
170 * This is never reserved, and is usable by any display.
171 * @rm: SDE Resource Manager handle
172 * @Return: Pointer to hw block or NULL
173 */
174struct sde_hw_mdp *sde_rm_get_mdp(struct sde_rm *rm);
175
176/**
177 * sde_rm_init_hw_iter - setup given iterator for new iteration over hw list
178 * using sde_rm_get_hw
179 * @iter: iter object to initialize
180 * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder
181 * @type: Hardware Block Type client wishes to search for.
182 */
183void sde_rm_init_hw_iter(
184 struct sde_rm_hw_iter *iter,
185 uint32_t enc_id,
186 enum sde_hw_blk_type type);
187/**
188 * sde_rm_get_hw - retrieve reserved hw object given encoder and hw type
189 * Meant to do a single pass through the hardware list to iteratively
190 * retrieve hardware blocks of a given type for a given encoder.
191 * Initialize an iterator object.
192 * Set hw block type of interest. Set encoder id of interest, 0 for any.
193 * Function returns first hw of type for that encoder.
194 * Subsequent calls will return the next reserved hw of that type in-order.
195 * Iterator HW pointer will be null on failure to find hw.
196 * @rm: SDE Resource Manager handle
197 * @iter: iterator object
198 * @Return: true on match found, false on no match found
199 */
200bool sde_rm_get_hw(struct sde_rm *rm, struct sde_rm_hw_iter *iter);
201
202/**
203 * sde_rm_check_property_topctl - validate property bitmask before it is set
204 * @val: user's proposed topology control bitmask
205 * @Return: 0 on success or error
206 */
207int sde_rm_check_property_topctl(uint64_t val);
208
Jeykumar Sankaran586d0922017-09-18 15:01:33 -0700209/**
Chandan Uddaraju9efbbe32017-11-09 23:57:05 -0800210 * sde_rm_cont_splash_res_init - Read the current MDSS configuration
211 * to update the splash data structure with the topology
212 * configured by the bootloader.
213 * @rm: SDE Resource Manager handle
214 * @splash_data: Pointer to the splash_data structure to be updated.
215 * @cat: Pointer to the SDE catalog
216 * @Return: 0 on success or error
217 */
218int sde_rm_cont_splash_res_init(struct sde_rm *rm,
219 struct sde_splash_data *splash_data,
220 struct sde_mdss_cfg *cat);
221
222/**
Jeykumar Sankaran586d0922017-09-18 15:01:33 -0700223 * sde_rm_update_topology - sets topology property of the connector
224 * @conn_state: drm state of the connector
225 * @topology: topology selected for the display
226 * @return: 0 on success or error
227 */
228int sde_rm_update_topology(struct drm_connector_state *conn_state,
229 struct msm_display_topology *topology);
230
Lloyd Atkinson05ec9072016-09-12 15:44:46 -0400231#endif /* __SDE_RM_H__ */