blob: 855b12ce81508ead090599343bf166d6af59a764 [file] [log] [blame]
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -04001/*
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
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
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 */
31enum 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 */
56enum 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
Lloyd Atkinsond1709812016-08-31 10:04:02 -040068 * @hw_blks: array of lists of hardware resources present in the system, one
69 * list per type of hardware block
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040070 * @hw_mdp: hardware object for mdp_top
71 * @lm_max_width: cached layer mixer maximum width
72 * @rsvp_next_seq: sequence number for next reservation for debugging purposes
73 */
74struct sde_rm {
75 struct drm_device *dev;
76 struct list_head rsvps;
Lloyd Atkinsond1709812016-08-31 10:04:02 -040077 struct list_head hw_blks[SDE_HW_BLK_MAX];
Lloyd Atkinsonccc11c52016-08-10 18:54:30 -040078 struct sde_hw_mdp *hw_mdp;
79 uint32_t lm_max_width;
80 uint32_t rsvp_next_seq;
81};
82
83/**
84 * struct sde_rm_hw_blk - resource manager internal structure
85 * forward declaration for single iterator definition without void pointer
86 */
87struct sde_rm_hw_blk;
88
89/**
90 * struct sde_rm_hw_iter - iterator for use with sde_rm
91 * @hw: sde_hw object requested, or NULL on failure
92 * @blk: sde_rm internal block representation. Clients ignore. Used as iterator.
93 * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder
94 * @type: Hardware Block Type client wishes to search for.
95 */
96struct sde_rm_hw_iter {
97 void *hw;
98 struct sde_rm_hw_blk *blk;
99 uint32_t enc_id;
100 enum sde_hw_blk_type type;
101};
102
103/**
104 * sde_rm_init - Read hardware catalog and create reservation tracking objects
105 * for all HW blocks.
106 * @rm: SDE Resource Manager handle
107 * @cat: Pointer to hardware catalog
108 * @mmio: mapped register io address of MDP
109 * @dev: device handle for event logging purposes
110 * @Return: 0 on Success otherwise -ERROR
111 */
112int sde_rm_init(struct sde_rm *rm,
113 struct sde_mdss_cfg *cat,
114 void *mmio,
115 struct drm_device *dev);
116
117/**
118 * sde_rm_destroy - Free all memory allocated by sde_rm_init
119 * @rm: SDE Resource Manager handle
120 * @Return: 0 on Success otherwise -ERROR
121 */
122int sde_rm_destroy(struct sde_rm *rm);
123
124/**
125 * sde_rm_reserve - Given a CRTC->Encoder->Connector display chain, analyze
126 * the use connections and user requirements, specified through related
127 * topology control properties, and reserve hardware blocks to that
128 * display chain.
129 * HW blocks can then be accessed through sde_rm_get_* functions.
130 * HW Reservations should be released via sde_rm_release_hw.
131 * @rm: SDE Resource Manager handle
132 * @drm_enc: DRM Encoder handle
133 * @crtc_state: Proposed Atomic DRM CRTC State handle
134 * @conn_state: Proposed Atomic DRM Connector State handle
135 * @test_only: Atomic-Test phase, discard results (unless property overrides)
136 * @Return: 0 on Success otherwise -ERROR
137 */
138int sde_rm_reserve(struct sde_rm *rm,
139 struct drm_encoder *drm_enc,
140 struct drm_crtc_state *crtc_state,
141 struct drm_connector_state *conn_state,
142 bool test_only);
143
144/**
145 * sde_rm_reserve - Given the encoder for the display chain, release any
146 * HW blocks previously reserved for that use case.
147 * @rm: SDE Resource Manager handle
148 * @enc: DRM Encoder handle
149 * @Return: 0 on Success otherwise -ERROR
150 */
151void sde_rm_release(struct sde_rm *rm, struct drm_encoder *enc);
152
153/**
154 * sde_rm_get_mdp - Retrieve HW block for MDP TOP.
155 * This is never reserved, and is usable by any display.
156 * @rm: SDE Resource Manager handle
157 * @Return: Pointer to hw block or NULL
158 */
159struct sde_hw_mdp *sde_rm_get_mdp(struct sde_rm *rm);
160
161/**
162 * sde_rm_init_hw_iter - setup given iterator for new iteration over hw list
163 * using sde_rm_get_hw
164 * @iter: iter object to initialize
165 * @enc_id: DRM ID of Encoder client wishes to search for, or 0 for Any Encoder
166 * @type: Hardware Block Type client wishes to search for.
167 */
168void sde_rm_init_hw_iter(
169 struct sde_rm_hw_iter *iter,
170 uint32_t enc_id,
171 enum sde_hw_blk_type type);
172/**
173 * sde_rm_get_hw - retrieve reserved hw object given encoder and hw type
174 * Meant to do a single pass through the hardware list to iteratively
175 * retrieve hardware blocks of a given type for a given encoder.
176 * Initialize an iterator object.
177 * Set hw block type of interest. Set encoder id of interest, 0 for any.
178 * Function returns first hw of type for that encoder.
179 * Subsequent calls will return the next reserved hw of that type in-order.
180 * Iterator HW pointer will be null on failure to find hw.
181 * @rm: SDE Resource Manager handle
182 * @iter: iterator object
183 * @Return: true on match found, false on no match found
184 */
185bool sde_rm_get_hw(struct sde_rm *rm, struct sde_rm_hw_iter *iter);
186
187/**
188 * sde_rm_check_property_topctl - validate property bitmask before it is set
189 * @val: user's proposed topology control bitmask
190 * @Return: 0 on success or error
191 */
192int sde_rm_check_property_topctl(uint64_t val);
193
Lloyd Atkinson11f34442016-08-11 11:19:52 -0400194/**
195 * sde_rm_check_property_topctl - validate property bitmask before it is set
196 * @val: user's proposed topology control bitmask
197 * @Return: 0 on success or error
198 */
199int sde_rm_check_property_topctl(uint64_t val);
200
Lloyd Atkinson05ec9072016-09-12 15:44:46 -0400201#endif /* __SDE_RM_H__ */