blob: f9bd8f473737f6b8086dd6a04572cb3758e0f0d7 [file] [log] [blame]
Saurabh Shah66c941b2016-07-06 17:34:05 -07001/*
Rohit Kulkarni21649ef2018-02-08 14:39:40 -08002* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
Saurabh Shah66c941b2016-07-06 17:34:05 -07003*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are
6* met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above
10* copyright notice, this list of conditions and the following
11* disclaimer in the documentation and/or other materials provided
12* with the distribution.
13* * Neither the name of The Linux Foundation nor the names of its
14* contributors may be used to endorse or promote products derived
15* from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30#ifndef __DRM_INTERFACE_H__
31#define __DRM_INTERFACE_H__
32
33#include <map>
34#include <string>
35#include <utility>
36#include <vector>
37
38#include "xf86drm.h"
39#include "xf86drmMode.h"
Sushil Chauhan80e58432017-07-06 11:39:17 -070040#include <drm/msm_drm.h>
Saurabh Shah66c941b2016-07-06 17:34:05 -070041
42namespace sde_drm {
Ramkumar Radhakrishnan9ed1fd82017-03-09 18:46:41 -080043
44typedef std::map<std::pair<uint32_t, uint64_t>, float> CompRatioMap;
45
Saurabh Shah66c941b2016-07-06 17:34:05 -070046/*
47 * Drm Atomic Operation Codes
48 */
49enum struct DRMOps {
50 /*
51 * Op: Sets plane source crop
52 * Arg: uint32_t - Plane ID
53 * DRMRect - Source Rectangle
54 */
55 PLANE_SET_SRC_RECT,
56 /*
57 * Op: Sets plane destination rect
58 * Arg: uint32_t - Plane ID
59 * DRMRect - Dst Rectangle
60 */
61 PLANE_SET_DST_RECT,
62 /*
Namit Solanki6d0d8062017-11-30 17:29:48 +053063 * Op: Sets plane exclusion rect
64 * Arg: uint32_t - Plane ID
65 * drm_clip_rect - Exclusion Rectangle
66 */
67 PLANE_SET_EXCL_RECT,
68 /*
Saurabh Shah66c941b2016-07-06 17:34:05 -070069 * Op: Sets plane zorder
70 * Arg: uint32_t - Plane ID
71 * uint32_t - zorder
72 */
73 PLANE_SET_ZORDER,
74 /*
75 * Op: Sets plane rotation flags
76 * Arg: uint32_t - Plane ID
77 * uint32_t - bit mask of rotation flags (See drm_mode.h for enums)
78 */
79 PLANE_SET_ROTATION,
80 /*
81 * Op: Sets plane alpha
82 * Arg: uint32_t - Plane ID
83 * uint32_t - alpha value
84 */
85 PLANE_SET_ALPHA,
86 /*
87 * Op: Sets the blend type
88 * Arg: uint32_t - Plane ID
89 * uint32_t - blend type (see DRMBlendType)
90 */
91 PLANE_SET_BLEND_TYPE,
92 /*
93 * Op: Sets horizontal decimation
94 * Arg: uint32_t - Plane ID
95 * uint32_t - decimation factor
96 */
97 PLANE_SET_H_DECIMATION,
98 /*
99 * Op: Sets vertical decimation
100 * Arg: uint32_t - Plane ID
101 * uint32_t - decimation factor
102 */
103 PLANE_SET_V_DECIMATION,
104 /*
Prabhanjan Kandula585aa652017-01-26 18:39:11 -0800105 * Op: Sets source config flags
106 * Arg: uint32_t - Plane ID
107 * uint32_t - flags to enable or disable a specific op. E.g. deinterlacing
108 */
109 PLANE_SET_SRC_CONFIG,
110 /*
Saurabh Shah66c941b2016-07-06 17:34:05 -0700111 * Op: Sets frame buffer ID for plane. Set together with CRTC.
112 * Arg: uint32_t - Plane ID
113 * uint32_t - Framebuffer ID
114 */
115 PLANE_SET_FB_ID,
116 /*
117 * Op: Sets the crtc for this plane. Set together with FB_ID.
118 * Arg: uint32_t - Plane ID
119 * uint32_t - CRTC ID
120 */
121 PLANE_SET_CRTC,
122 /*
123 * Op: Sets acquire fence for this plane's buffer. Set together with FB_ID, CRTC.
124 * Arg: uint32_t - Plane ID
125 * uint32_t - Input fence
126 */
127 PLANE_SET_INPUT_FENCE,
128 /*
Saurabh Shah0ffee302016-11-22 10:42:11 -0800129 * Op: Sets scaler config on this plane.
130 * Arg: uint32_t - Plane ID
131 * uint64_t - Address of the scaler config object (version based)
132 */
133 PLANE_SET_SCALER_CONFIG,
134 /*
Rohit Kulkarni8622e362017-01-30 18:14:10 -0800135 * Op: Sets plane rotation destination rect
136 * Arg: uint32_t - Plane ID
137 * DRMRect - rotator dst Rectangle
138 */
139 PLANE_SET_ROTATION_DST_RECT,
140 /*
Sushil Chauhan1021cc02017-05-03 15:11:43 -0700141 * Op: Sets FB Secure mode for this plane.
142 * Arg: uint32_t - Plane ID
143 * uint32_t - Value of the FB Secure mode.
144 */
145 PLANE_SET_FB_SECURE_MODE,
146 /*
Ping Li8d6dd622017-07-03 12:05:15 -0700147 * Op: Sets csc config on this plane.
148 * Arg: uint32_t - Plane ID
149 * uint32_t* - pointer to csc type
150 */
151 PLANE_SET_CSC_CONFIG,
152 /*
Ramkumar Radhakrishnan07254302017-11-13 16:18:22 -0800153 * Op: Sets multirect mode on this plane.
154 * Arg: uint32_t - Plane ID
155 * uint32_t - multirect mode
156 */
157 PLANE_SET_MULTIRECT_MODE,
158 /*
Rohit Kulkarni2d7151c2017-12-14 22:17:49 -0800159 * Op: Sets rotator output frame buffer ID for plane.
160 * Arg: uint32_t - Plane ID
161 * uint32_t - Framebuffer ID
162 */
163 PLANE_SET_ROT_FB_ID,
164 /*
Arun Kumar K.R5d30ab52017-12-28 09:05:36 +0530165 * Op: Sets inverse pma mode on this plane.
166 * Arg: uint32_t - Plane ID
167 * uint32_t - enable/disable inverse pma.
168 */
169 PLANE_SET_INVERSE_PMA,
170 /*
171 * Op: Sets csc config on this plane.
172 * Arg: uint32_t - Plane ID
173 * uint64_t - Address of the csc config object(version based)
174 */
175 PLANE_SET_DGM_CSC_CONFIG,
176 /*
177 * Op: Sets SSPP Feature
178 * Arg: uint32_t - Plane ID
179 * DRMPPFeatureInfo * - PP feature data pointer
180 */
181 PLANE_SET_POST_PROC,
182 /*
Saurabh Shah66c941b2016-07-06 17:34:05 -0700183 * Op: Activate or deactivate a CRTC
184 * Arg: uint32_t - CRTC ID
185 * uint32_t - 1 to enable, 0 to disable
186 */
187 CRTC_SET_ACTIVE,
188 /*
189 * Op: Sets display mode
190 * Arg: uint32_t - CRTC ID
191 * drmModeModeInfo* - Pointer to display mode
192 */
193 CRTC_SET_MODE,
194 /*
195 * Op: Sets an offset indicating when a release fence should be signalled.
196 * Arg: uint32_t - offset
197 * 0: non-speculative, default
198 * 1: speculative
199 */
200 CRTC_SET_OUTPUT_FENCE_OFFSET,
201 /*
Ramkumar Radhakrishnan9ed1fd82017-03-09 18:46:41 -0800202 * Op: Sets overall SDE core clock
203 * Arg: uint32_t - CRTC ID
204 * uint32_t - core_clk
205 */
206 CRTC_SET_CORE_CLK,
Ramkumar Radhakrishnan3c4de112017-05-24 22:38:30 -0700207 /*
208 * Op: Sets MNOC bus average bandwidth
Ramkumar Radhakrishnan9ed1fd82017-03-09 18:46:41 -0800209 * Arg: uint32_t - CRTC ID
210 * uint32_t - core_ab
211 */
212 CRTC_SET_CORE_AB,
213 /*
Ramkumar Radhakrishnan3c4de112017-05-24 22:38:30 -0700214 * Op: Sets MNOC bus instantaneous bandwidth
Ramkumar Radhakrishnan9ed1fd82017-03-09 18:46:41 -0800215 * Arg: uint32_t - CRTC ID
216 * uint32_t - core_ib
217 */
218 CRTC_SET_CORE_IB,
219 /*
Ramkumar Radhakrishnan3c4de112017-05-24 22:38:30 -0700220 * Op: Sets LLCC Bus average bandwidth
221 * Arg: uint32_t - CRTC ID
222 * uint32_t - llcc_ab
223 */
224 CRTC_SET_LLCC_AB,
225 /*
226 * Op: Sets LLCC Bus instantaneous bandwidth
227 * Arg: uint32_t - CRTC ID
228 * uint32_t - llcc_ib
229 */
230 CRTC_SET_LLCC_IB,
231 /*
232 * Op: Sets DRAM bus average bandwidth
233 * Arg: uint32_t - CRTC ID
234 * uint32_t - dram_ab
235 */
236 CRTC_SET_DRAM_AB,
237 /*
238 * Op: Sets DRAM bus instantaneous bandwidth
239 * Arg: uint32_t - CRTC ID
240 * uint32_t - dram_ib
241 */
242 CRTC_SET_DRAM_IB,
243 /*
Ramkumar Radhakrishnanb7910442017-12-11 13:32:47 -0800244 * Op: Sets Rotator BW for inline rotation
245 * Arg: uint32_t - CRTC ID
246 * uint32_t - rot_bw
247 */
248 CRTC_SET_ROT_PREFILL_BW,
249 /*
Ramkumar Radhakrishnan3c4de112017-05-24 22:38:30 -0700250 * Op: Sets rotator clock for inline rotation
251 * Arg: uint32_t - CRTC ID
252 * uint32_t - rot_clk
253 */
Namit Solanki24921ab2017-05-23 20:16:25 +0530254 CRTC_SET_ROT_CLK,
255 /*
256 * Op: Sets destination scalar data
257 * Arg: uint32_t - CRTC ID
258 * uint64_t - Pointer to destination scalar data
259 */
260 CRTC_SET_DEST_SCALER_CONFIG,
261 /*
Saurabh Shah66c941b2016-07-06 17:34:05 -0700262 * Op: Returns release fence for this frame. Should be called after Commit() on
263 * DRMAtomicReqInterface.
264 * Arg: uint32_t - CRTC ID
265 * int * - Pointer to an integer that will hold the returned fence
266 */
267 CRTC_GET_RELEASE_FENCE,
268 /*
Ping Li281f48d2017-01-16 12:45:40 -0800269 * Op: Sets PP feature
270 * Arg: uint32_t - CRTC ID
271 * DRMPPFeatureInfo * - PP feature data pointer
272 */
273 CRTC_SET_POST_PROC,
274 /*
Saurabh Shahe9f55d72017-03-03 15:14:13 -0800275 * Op: Sets CRTC ROIs.
276 * Arg: uint32_t - CRTC ID
277 * uint32_t - number of ROIs
278 * DRMRect * - Array of CRTC ROIs
279 */
280 CRTC_SET_ROI,
281 /*
Sushil Chauhan1021cc02017-05-03 15:11:43 -0700282 * Op: Sets Security level for CRTC.
283 * Arg: uint32_t - CRTC ID
284 * uint32_t - Security level
285 */
286 CRTC_SET_SECURITY_LEVEL,
287 /*
Prabhanjan Kanduladbc8aed2017-03-24 14:43:16 -0700288 * Op: sets solid fill stages
289 * Arg: uint32_t - CRTC ID
290 * Vector of DRMSolidfillStage
291 */
292 CRTC_SET_SOLIDFILL_STAGES,
293 /*
Anjaneya Prasad Musunurie8c67f22017-07-01 16:16:13 +0530294 * Op: Sets idle timeout.
295 * Arg: uint32_t - CRTC ID
296 * uint32_t - idle timeout in ms
297 */
298 CRTC_SET_IDLE_TIMEOUT,
299 /*
Sushil Chauhan741ac312018-04-02 12:22:16 -0700300 * Op: Sets Capture mode for Concurrent Writeback feature.
301 * Arg: uint32_t - CRTC ID
302 * uint32_t - Capture mode
303 */
304 CRTC_SET_CAPTURE_MODE,
305 /*
Saurabh Shah66c941b2016-07-06 17:34:05 -0700306 * Op: Returns retire fence for this commit. Should be called after Commit() on
307 * DRMAtomicReqInterface.
308 * Arg: uint32_t - Connector ID
309 * int * - Pointer to an integer that will hold the returned fence
310 */
311 CONNECTOR_GET_RETIRE_FENCE,
312 /*
313 * Op: Sets writeback connector destination rect
314 * Arg: uint32_t - Connector ID
315 * DRMRect - Dst Rectangle
316 */
317 CONNECTOR_SET_OUTPUT_RECT,
318 /*
319 * Op: Sets frame buffer ID for writeback connector.
320 * Arg: uint32_t - Connector ID
321 * uint32_t - Framebuffer ID
322 */
323 CONNECTOR_SET_OUTPUT_FB_ID,
Sushil Chauhan3396e202017-04-14 18:34:22 -0700324 /*
325 * Op: Sets power mode for connector.
326 * Arg: uint32_t - Connector ID
327 * uint32_t - Power Mode
328 */
329 CONNECTOR_SET_POWER_MODE,
Saurabh Shahe9f55d72017-03-03 15:14:13 -0800330 /*
331 * Op: Sets panel ROIs.
332 * Arg: uint32_t - Connector ID
333 * uint32_t - number of ROIs
334 * DRMRect * - Array of Connector ROIs
335 */
336 CONNECTOR_SET_ROI,
Sushil Chauhane2f89c92017-08-23 11:30:34 -0700337 /*
Saurabh Shahf3635952017-10-16 17:08:18 -0700338 * Op: Sets the connector to autorefresh mode.
339 * Arg: uint32_t - Connector ID
340 * uint32_t - Enable-1, Disable-0
341 */
342 CONNECTOR_SET_AUTOREFRESH,
343 /*
Sushil Chauhane2f89c92017-08-23 11:30:34 -0700344 * Op: Set FB secure mode for Writeback connector.
345 * Arg: uint32_t - Connector ID
346 * uint32_t - FB Secure mode
347 */
348 CONNECTOR_SET_FB_SECURE_MODE,
Saurabh Shah82b06f42017-09-06 16:43:49 -0700349 /*
350 * Op: Sets a crtc id to this connector
351 * Arg: uint32_t - Connector ID
352 * uint32_t - CRTC ID
353 */
354 CONNECTOR_SET_CRTC,
Srikanth Rajagopalan7a09b2e2017-06-19 18:41:03 -0700355 /*
Gopikrishnaiah Anandan739faf92017-07-21 12:32:00 -0700356 * Op: Sets PP feature
357 * Arg: uint32_t - Connector ID
358 * DRMPPFeatureInfo * - PP feature data pointer
359 */
Xu Yang32e58c22017-11-20 09:58:11 +0800360 CONNECTOR_SET_POST_PROC,
Gopikrishnaiah Anandan739faf92017-07-21 12:32:00 -0700361 /*
Srikanth Rajagopalan7a09b2e2017-06-19 18:41:03 -0700362 * Op: Sets connector hdr metadata
363 * Arg: uint32_t - Connector ID
364 * drm_msm_ext_hdr_metadata - hdr_metadata
365 */
366 CONNECTOR_SET_HDR_METADATA,
Xu Yang32e58c22017-11-20 09:58:11 +0800367 /*
368 * Op: Cache Dpps features.
369 * Arg: uint32_t - Object ID
370 uint32_t - Feature ID
371 * uint64_t - Pointer to feature config data
372 */
373 DPPS_CACHE_FEATURE,
Xu Yangda642222018-06-12 10:32:33 +0800374 /*
375 * Op: Commit Dpps features.
376 * Arg: drmModeAtomicReq - Atomic request
377 */
378 DPPS_COMMIT_FEATURE,
Sushil Chauhan8f514a52018-02-27 17:35:44 -0800379 /*
380 * Op: Sets qsync mode on connector
381 * Arg: uint32_t - Connector ID
382 * uint32_t - qsync mode
383 */
384 CONNECTOR_SET_QSYNC_MODE,
Saurabh Shah66c941b2016-07-06 17:34:05 -0700385};
386
Saurabh Shahf9266ee2017-04-19 15:25:46 -0700387enum struct DRMRotation {
388 FLIP_H = 0x1,
389 FLIP_V = 0x2,
Prabhanjan Kandula5bc7f8b2017-05-23 12:24:57 -0700390 ROT_180 = FLIP_H | FLIP_V,
Saurabh Shahf9266ee2017-04-19 15:25:46 -0700391 ROT_90 = 0x4,
392};
393
Sushil Chauhan3396e202017-04-14 18:34:22 -0700394enum struct DRMPowerMode {
395 ON,
396 DOZE,
397 DOZE_SUSPEND,
398 OFF,
399};
400
Saurabh Shah66c941b2016-07-06 17:34:05 -0700401enum struct DRMBlendType {
402 UNDEFINED = 0,
403 OPAQUE = 1,
404 PREMULTIPLIED = 2,
405 COVERAGE = 3,
406};
407
Prabhanjan Kandula585aa652017-01-26 18:39:11 -0800408enum struct DRMSrcConfig {
409 DEINTERLACE = 0,
410};
411
Saurabh Shah66c941b2016-07-06 17:34:05 -0700412/* Display type to identify a suitable connector */
413enum struct DRMDisplayType {
414 PERIPHERAL,
415 TV,
416 VIRTUAL,
417};
418
419struct DRMRect {
420 uint32_t left; // Left-most pixel coordinate.
421 uint32_t top; // Top-most pixel coordinate.
422 uint32_t right; // Right-most pixel coordinate.
423 uint32_t bottom; // Bottom-most pixel coordinate.
424};
425
426//------------------------------------------------------------------------
427// DRM Info Query Types
428//------------------------------------------------------------------------
429
430enum struct QSEEDVersion {
431 V1,
432 V2,
433 V3,
434};
435
Rohit Kulkarnibfa855c2017-06-29 17:52:10 -0700436/* QSEED3 Step version */
437enum struct QSEEDStepVersion {
438 V2,
439 V3,
440 V4,
441};
442
Prabhanjan Kandulae6dfab92017-03-14 11:02:49 -0700443enum struct SmartDMARevision {
444 V1,
445 V2,
Mathew Joseph Karimpanal1f8a21c2017-10-20 20:47:42 +0530446 V2p5
Prabhanjan Kandulae6dfab92017-03-14 11:02:49 -0700447};
448
Rohit Kulkarni2d7151c2017-12-14 22:17:49 -0800449/* Inline Rotation version */
450enum struct InlineRotationVersion {
451 UNKNOWN,
452 V1,
453 V1p1, // Rotator FB ID needs to be set
454};
455
Saurabh Shah66c941b2016-07-06 17:34:05 -0700456/* Per CRTC Resource Info*/
457struct DRMCrtcInfo {
458 bool has_src_split;
Srikanth Rajagopalan49380782017-07-06 15:23:12 -0700459 bool has_hdr;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700460 uint32_t max_blend_stages;
Prabhanjan Kanduladbc8aed2017-03-24 14:43:16 -0700461 uint32_t max_solidfill_stages;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700462 QSEEDVersion qseed_version;
Prabhanjan Kandulae6dfab92017-03-14 11:02:49 -0700463 SmartDMARevision smart_dma_rev;
Ramkumar Radhakrishnan9ed1fd82017-03-09 18:46:41 -0800464 float ib_fudge_factor;
465 float clk_fudge_factor;
466 uint32_t dest_scale_prefill_lines;
467 uint32_t undersized_prefill_lines;
468 uint32_t macrotile_prefill_lines;
469 uint32_t nv12_prefill_lines;
470 uint32_t linear_prefill_lines;
471 uint32_t downscale_prefill_lines;
472 uint32_t extra_prefill_lines;
473 uint32_t amortized_threshold;
474 uint64_t max_bandwidth_low;
475 uint64_t max_bandwidth_high;
476 uint32_t max_sde_clk;
477 CompRatioMap comp_ratio_rt_map;
478 CompRatioMap comp_ratio_nrt_map;
Gopikrishnaiah Anandan76815522017-06-27 15:18:04 -0700479 uint32_t hw_version;
Namit Solanki24921ab2017-05-23 20:16:25 +0530480 uint32_t dest_scaler_count = 0;
481 uint32_t max_dest_scaler_input_width = 0;
482 uint32_t max_dest_scaler_output_width = 0;
483 uint32_t max_dest_scale_up = 1;
Pullakavi Srinivas3e2c0402017-12-05 17:50:15 +0530484 uint32_t min_prefill_lines = 0;
Ramkumar Radhakrishnana38b7602018-03-15 14:49:52 -0700485 int secure_disp_blend_stage = -1;
Sushil Chauhanc75358e2018-04-24 14:36:38 -0700486 bool concurrent_writeback = false;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700487};
488
489enum struct DRMPlaneType {
490 // Has CSC and scaling capability
491 VIG = 0,
492 // Has scaling capability but no CSC
493 RGB,
494 // No scaling support
495 DMA,
496 // Supports a small dimension and doesn't use a CRTC stage
497 CURSOR,
498 MAX,
499};
500
Arun Kumar K.R5d30ab52017-12-28 09:05:36 +0530501enum struct DRMTonemapLutType {
502 DMA_1D_GC,
503 DMA_1D_IGC,
504 VIG_1D_IGC,
505 VIG_3D_GAMUT,
506};
507
Saurabh Shah66c941b2016-07-06 17:34:05 -0700508struct DRMPlaneTypeInfo {
Prabhanjan Kandulae6dfab92017-03-14 11:02:49 -0700509 DRMPlaneType type;
510 uint32_t master_plane_id;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700511 // FourCC format enum and modifier
512 std::vector<std::pair<uint32_t, uint64_t>> formats_supported;
513 uint32_t max_linewidth;
Mathew Joseph Karimpanal1f8a21c2017-10-20 20:47:42 +0530514 uint32_t max_scaler_linewidth;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700515 uint32_t max_upscale;
516 uint32_t max_downscale;
517 uint32_t max_horizontal_deci;
518 uint32_t max_vertical_deci;
Ramkumar Radhakrishnan9ed1fd82017-03-09 18:46:41 -0800519 uint64_t max_pipe_bandwidth;
Rohit Kulkarni8622e362017-01-30 18:14:10 -0800520 uint32_t cache_size; // cache size in bytes for inline rotation support.
Namit Solanki6d0d8062017-11-30 17:29:48 +0530521 bool has_excl_rect = false;
Rohit Kulkarnibfa855c2017-06-29 17:52:10 -0700522 QSEEDStepVersion qseed3_version;
Ramkumar Radhakrishnan07254302017-11-13 16:18:22 -0800523 bool multirect_prop_present = false;
Rohit Kulkarni2d7151c2017-12-14 22:17:49 -0800524 InlineRotationVersion inrot_version; // inline rotation version
Arun Kumar K.R5d30ab52017-12-28 09:05:36 +0530525 bool inverse_pma = false;
526 uint32_t dgm_csc_version = 0; // csc used with DMA
527 std::map<DRMTonemapLutType, uint32_t> tonemap_lut_version_map = {};
Ramkumar Radhakrishnan4a269752018-03-08 14:53:15 -0800528 bool block_sec_ui = false;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700529};
530
Prabhanjan Kandulae6dfab92017-03-14 11:02:49 -0700531// All DRM Planes as map<Plane_id , plane_type_info> listed from highest to lowest priority
532typedef std::vector<std::pair<uint32_t, DRMPlaneTypeInfo>> DRMPlanesInfo;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700533
534enum struct DRMTopology {
Rohit Kulkarni2faa91c2017-06-05 15:43:48 -0700535 UNKNOWN, // To be compat with driver defs in sde_rm.h
Saurabh Shah66c941b2016-07-06 17:34:05 -0700536 SINGLE_LM,
Rohit Kulkarni2faa91c2017-06-05 15:43:48 -0700537 SINGLE_LM_DSC,
Saurabh Shah66c941b2016-07-06 17:34:05 -0700538 DUAL_LM,
Rohit Kulkarni2faa91c2017-06-05 15:43:48 -0700539 DUAL_LM_DSC,
Saurabh Shah66c941b2016-07-06 17:34:05 -0700540 DUAL_LM_MERGE,
Rohit Kulkarni2faa91c2017-06-05 15:43:48 -0700541 DUAL_LM_MERGE_DSC,
542 DUAL_LM_DSCMERGE,
543 PPSPLIT,
Saurabh Shah66c941b2016-07-06 17:34:05 -0700544};
545
546enum struct DRMPanelMode {
547 VIDEO,
548 COMMAND,
549};
550
Saurabh Shah7e16c932017-11-03 17:55:36 -0700551/* Per mode info */
552struct DRMModeInfo {
553 drmModeModeInfo mode;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700554 DRMTopology topology;
Saurabh Shahe9f55d72017-03-03 15:14:13 -0800555 // Valid only if mode is command
556 int num_roi;
557 int xstart;
558 int ystart;
559 int walign;
560 int halign;
561 int wmin;
562 int hmin;
563 bool roi_merge;
Saurabh Shah7e16c932017-11-03 17:55:36 -0700564};
565
566/* Per Connector Info*/
567struct DRMConnectorInfo {
568 uint32_t mmWidth;
569 uint32_t mmHeight;
570 uint32_t type;
571 std::vector<DRMModeInfo> modes;
572 std::string panel_name;
573 DRMPanelMode panel_mode;
574 bool is_primary;
575 // Valid only if DRMPanelMode is VIDEO
576 bool dynamic_fps;
577 // FourCC format enum and modifier
578 std::vector<std::pair<uint32_t, uint64_t>> formats_supported;
579 // Valid only if type is DRM_MODE_CONNECTOR_VIRTUAL
580 uint32_t max_linewidth;
Prabhanjan Kandula5bc7f8b2017-05-23 12:24:57 -0700581 DRMRotation panel_orientation;
Sushil Chauhan80e58432017-07-06 11:39:17 -0700582 drm_panel_hdr_properties panel_hdr_prop;
Ramkumar Radhakrishnan5c94f052017-07-06 11:59:14 -0700583 uint32_t transfer_time_us;
Srikanth Rajagopalance0f7cb2017-06-12 15:14:26 -0700584 drm_msm_ext_hdr_properties ext_hdr_prop;
Sushil Chauhan8f514a52018-02-27 17:35:44 -0800585 bool qsync_support;
Mathew Joseph Karimpanal731bc932017-11-22 10:04:56 +0530586 // Connection status of this connector
587 bool is_connected;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700588};
589
Mathew Joseph Karimpanal731bc932017-11-22 10:04:56 +0530590// All DRM Connectors as map<Connector_id , connector_info>
591typedef std::map<uint32_t, DRMConnectorInfo> DRMConnectorsInfo;
592
593/* Per Encoder Info */
594struct DRMEncoderInfo {
595 uint32_t type;
596};
597
598// All DRM Encoders as map<Encoder_id , encoder_info>
599typedef std::map<uint32_t, DRMEncoderInfo> DRMEncodersInfo;
600
Saurabh Shah66c941b2016-07-06 17:34:05 -0700601/* Identifier token for a display */
602struct DRMDisplayToken {
603 uint32_t conn_id;
604 uint32_t crtc_id;
Saurabh Shahf8226712018-02-05 15:51:53 -0800605 uint32_t crtc_index;
Mathew Joseph Karimpanal731bc932017-11-22 10:04:56 +0530606 uint32_t encoder_id;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700607};
608
Ping Li281f48d2017-01-16 12:45:40 -0800609enum DRMPPFeatureID {
610 kFeaturePcc,
611 kFeatureIgc,
612 kFeaturePgc,
613 kFeatureMixerGc,
614 kFeaturePaV2,
615 kFeatureDither,
616 kFeatureGamut,
617 kFeaturePADither,
Rajesh Yadavd30b0cc2017-09-22 00:26:54 +0530618 kFeaturePAHsic,
619 kFeaturePASixZone,
Rajesh Yadav99535ac2017-08-28 16:33:04 +0530620 kFeaturePAMemColSkin,
621 kFeaturePAMemColSky,
622 kFeaturePAMemColFoliage,
623 kFeaturePAMemColProt,
Rajesh Yadavc4f67b82017-11-15 20:37:13 +0530624 kFeatureDgmIgc,
625 kFeatureDgmGc,
626 kFeatureVigIgc,
627 kFeatureVigGamut,
Ping Li281f48d2017-01-16 12:45:40 -0800628 kPPFeaturesMax,
629};
630
631enum DRMPPPropType {
632 kPropEnum,
633 kPropRange,
634 kPropBlob,
635 kPropTypeMax,
636};
637
638struct DRMPPFeatureInfo {
639 DRMPPFeatureID id;
640 DRMPPPropType type;
641 uint32_t version;
642 uint32_t payload_size;
643 void *payload;
Gopikrishnaiah Anandan739faf92017-07-21 12:32:00 -0700644 uint32_t object_type;
Ping Li281f48d2017-01-16 12:45:40 -0800645};
646
Xu Yang32e58c22017-11-20 09:58:11 +0800647enum DRMDPPSFeatureID {
648 // Ad4 properties
649 kFeatureAd4Mode,
650 kFeatureAd4Init,
651 kFeatureAd4Cfg,
652 kFeatureAd4Input,
653 kFeatureAd4Backlight,
654 kFeatureAd4Assertiveness,
655 kFeatureAd4ManualStrength,
656 // ABA properties
657 kFeatureAbaHistCtrl,
658 kFeatureAbaHistIRQ,
659 kFeatureAbaLut,
660 // BL scale properties
661 kFeatureAd4BlScale,
662 kFeatureBacklightScale,
663 // Events
664 kFeaturePowerEvent,
665 kFeatureAbaHistEvent,
666 kFeatureBackLightEvent,
667 kFeatureAdAttBlEvent,
668 // Insert features above
669 kDppsFeaturesMax,
670};
671
Ping Li6a74d892018-05-02 15:54:58 -0700672struct DppsFeaturePayload {
673 uint32_t object_type;
674 uint32_t feature_id;
675 uint64_t value;
676};
677
Xu Yang32e58c22017-11-20 09:58:11 +0800678struct DRMDppsFeatureInfo {
679 DRMDPPSFeatureID id;
680 uint32_t version;
681};
682
683enum AD4Modes {
684 kAd4Off,
685 kAd4AutoStrength,
686 kAd4Calibration,
687 kAd4Manual,
688 kAd4ModeMax,
689};
690
691enum HistModes {
692 kHistDisabled,
693 kHistEnabled,
694};
695
696struct DRMDppsEventInfo {
697 uint32_t object_type;
698 uint32_t event_type;
699 int drm_fd;
700 bool enable;
701};
702
Ping Li8d6dd622017-07-03 12:05:15 -0700703enum DRMCscType {
704 kCscYuv2Rgb601L,
705 kCscYuv2Rgb601FR,
706 kCscYuv2Rgb709L,
707 kCscYuv2Rgb2020L,
708 kCscYuv2Rgb2020FR,
709 kCscTypeMax,
710};
711
Saurabh Shah0ffee302016-11-22 10:42:11 -0800712struct DRMScalerLUTInfo {
713 uint32_t dir_lut_size = 0;
714 uint32_t cir_lut_size = 0;
715 uint32_t sep_lut_size = 0;
716 uint64_t dir_lut = 0;
717 uint64_t cir_lut = 0;
718 uint64_t sep_lut = 0;
719};
720
Sushil Chauhan1021cc02017-05-03 15:11:43 -0700721enum struct DRMSecureMode {
722 NON_SECURE,
723 SECURE,
724 NON_SECURE_DIR_TRANSLATION,
725 SECURE_DIR_TRANSLATION,
726};
727
728enum struct DRMSecurityLevel {
729 SECURE_NON_SECURE,
730 SECURE_ONLY,
731};
732
Ramkumar Radhakrishnan07254302017-11-13 16:18:22 -0800733enum struct DRMMultiRectMode {
734 NONE = 0,
735 PARALLEL = 1,
736 SERIAL = 2,
737};
738
Sushil Chauhan741ac312018-04-02 12:22:16 -0700739enum struct DRMCWbCaptureMode {
740 MIXER_OUT = 0,
741 DSPP_OUT = 1,
742};
743
Sushil Chauhan8f514a52018-02-27 17:35:44 -0800744enum struct DRMQsyncMode {
745 NONE = 0,
746 CONTINUOUS,
747};
748
Prabhanjan Kanduladbc8aed2017-03-24 14:43:16 -0700749struct DRMSolidfillStage {
Xu Yang32e58c22017-11-20 09:58:11 +0800750 DRMRect bounding_rect {};
751 bool is_exclusion_rect = false;
752 uint32_t color = 0xff000000; // in 8bit argb
753 uint32_t red = 0;
754 uint32_t blue = 0;
755 uint32_t green = 0;
756 uint32_t alpha = 0xff;
757 uint32_t color_bit_depth = 0;
758 uint32_t z_order = 0;
759 uint32_t plane_alpha = 0xff;
Prabhanjan Kanduladbc8aed2017-03-24 14:43:16 -0700760};
761
Saurabh Shah66c941b2016-07-06 17:34:05 -0700762/* DRM Atomic Request Property Set.
763 *
764 * Helper class to create and populate atomic properties of DRM components
765 * when rendered in DRM atomic mode */
766class DRMAtomicReqInterface {
767 public:
768 virtual ~DRMAtomicReqInterface() {}
769 /* Perform request operation.
770 *
771 * [input]: opcode: operation code from DRMOps list.
Saurabh Shah1abcdf62017-11-21 14:03:22 -0800772 * obj_id: Relevant crtc, connector, plane id
Saurabh Shah66c941b2016-07-06 17:34:05 -0700773 * var_arg: arguments for DRMOps's can differ in number and
774 * data type. Refer above DRMOps to details.
775 * [return]: Error code if the API fails, 0 on success.
776 */
Saurabh Shah1abcdf62017-11-21 14:03:22 -0800777 virtual int Perform(DRMOps opcode, uint32_t obj_id, ...) = 0;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700778
779 /*
780 * Commit the params set via Perform(). Also resets the properties after commit. Needs to be
781 * called every frame.
782 * [input]: synchronous: Determines if the call should block until a h/w flip
Saurabh Shaha917aa72017-09-15 13:27:24 -0700783 * [input]: retain_planes: Retains already staged planes. Useful when not explicitly programming
784 * planes but still need the previously staged ones to not be unstaged
Saurabh Shah66c941b2016-07-06 17:34:05 -0700785 * [return]: Error code if the API fails, 0 on success.
786 */
Saurabh Shaha917aa72017-09-15 13:27:24 -0700787 virtual int Commit(bool synchronous, bool retain_planes) = 0;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700788 /*
789 * Validate the params set via Perform().
790 * [return]: Error code if the API fails, 0 on success.
791 */
792 virtual int Validate() = 0;
793};
794
795class DRMManagerInterface;
796
797/* Populates a singleton instance of DRMManager */
798typedef int (*GetDRMManager)(int fd, DRMManagerInterface **intf);
799
800/* Destroy DRMManager instance */
Saurabh Shahab7807c2017-02-08 15:41:08 -0800801typedef int (*DestroyDRMManager)();
Saurabh Shah66c941b2016-07-06 17:34:05 -0700802
803/*
804 * DRM Manager Interface - Any class which plans to implement helper function for vendor
805 * specific DRM driver implementation must implement the below interface routines to work
806 * with SDM.
807 */
808
809class DRMManagerInterface {
810 public:
811 virtual ~DRMManagerInterface() {}
812
813 /*
814 * Since SDM completely manages the planes. GetPlanesInfo will provide all
815 * the plane information.
816 * [output]: DRMPlanesInfo: Resource Info for planes.
817 */
818 virtual void GetPlanesInfo(DRMPlanesInfo *info) = 0;
819
820 /*
821 * Will provide all the information of a selected crtc.
822 * [input]: Use crtc id 0 to obtain system wide info
823 * [output]: DRMCrtcInfo: Resource Info for the given CRTC id.
Mathew Joseph Karimpanal43c9d692018-06-14 13:45:27 +0530824 * [return]: 0 on success, a negative error value otherwise.
Saurabh Shah66c941b2016-07-06 17:34:05 -0700825 */
Mathew Joseph Karimpanal43c9d692018-06-14 13:45:27 +0530826 virtual int GetCrtcInfo(uint32_t crtc_id, DRMCrtcInfo *info) = 0;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700827
828 /*
829 * Will provide all the information of a selected connector.
830 * [output]: DRMConnectorInfo: Resource Info for the given connector id
Mathew Joseph Karimpanal43c9d692018-06-14 13:45:27 +0530831 * [return]: 0 on success, a negative error value otherwise.
Saurabh Shah66c941b2016-07-06 17:34:05 -0700832 */
Mathew Joseph Karimpanal43c9d692018-06-14 13:45:27 +0530833 virtual int GetConnectorInfo(uint32_t conn_id, DRMConnectorInfo *info) = 0;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700834
835 /*
Mathew Joseph Karimpanal731bc932017-11-22 10:04:56 +0530836 * Provides information on all connectors.
837 * [output]: DRMConnectorsInfo: Resource info for connectors.
838 * [return]: 0 on success, a negative error value otherwise.
839 */
840 virtual int GetConnectorsInfo(DRMConnectorsInfo *info) = 0;
841
842 /*
843 * Provides information on a selected encoder.
844 * [output]: DRMEncoderInfo: Resource info for the given encoder id.
845 * [return]: 0 on success, a negative error value otherwise.
846 */
847 virtual int GetEncoderInfo(uint32_t encoder_id, DRMEncoderInfo *info) = 0;
848
849 /*
850 * Provides information on all encoders.
851 * [output]: DRMEncodersInfo: Resource info for encoders.
852 * [return]: 0 on success, a negative error value otherwise.
853 */
854 virtual int GetEncodersInfo(DRMEncodersInfo *info) = 0;
855
856 /*
Ping Li281f48d2017-01-16 12:45:40 -0800857 * Will query post propcessing feature info of a CRTC.
858 * [output]: DRMPPFeatureInfo: CRTC post processing feature info
859 */
Namit Solanki24921ab2017-05-23 20:16:25 +0530860 virtual void GetCrtcPPInfo(uint32_t crtc_id, DRMPPFeatureInfo *info) = 0;
Mathew Joseph Karimpanal731bc932017-11-22 10:04:56 +0530861
Ping Li281f48d2017-01-16 12:45:40 -0800862 /*
Saurabh Shah66c941b2016-07-06 17:34:05 -0700863 * Register a logical display to receive a token.
Mathew Joseph Karimpanal731bc932017-11-22 10:04:56 +0530864 * Each display pipeline in DRM is identified by its CRTC and Connector(s). On display connect
865 * (bootup or hotplug), clients should invoke this interface to establish the pipeline for the
866 * display and should get a DisplayToken populated with crtc, encoder and connnector(s) id's. Here
867 * onwards, Client should use this token to represent the display for any Perform operations if
Saurabh Shah66c941b2016-07-06 17:34:05 -0700868 * needed.
869 *
870 * [input]: disp_type - Peripheral / TV / Virtual
Mathew Joseph Karimpanal731bc932017-11-22 10:04:56 +0530871 * [output]: DRMDisplayToken - CRTC and Connector IDs for the display.
872 * [return]: 0 on success, a negative error value otherwise.
Saurabh Shah66c941b2016-07-06 17:34:05 -0700873 */
874 virtual int RegisterDisplay(DRMDisplayType disp_type, DRMDisplayToken *tok) = 0;
875
Mathew Joseph Karimpanal731bc932017-11-22 10:04:56 +0530876 /*
877 * Register a logical display to receive a token.
878 * Each display pipeline in DRM is identified by its CRTC and Connector(s). On display connect
879 * (bootup or hotplug), clients should invoke this interface to establish the pipeline for the
880 * display and should get a DisplayToken populated with crtc, encoder and connnector(s) id's. Here
881 * onwards, Client should use this token to represent the display for any Perform operations if
882 * needed.
883 *
884 * [input]: display_id - Connector ID
885 * [output]: DRMDisplayToken - CRTC and Connector id's for the display.
886 * [return]: 0 on success, a negative error value otherwise.
887 */
888 virtual int RegisterDisplay(int32_t display_id, DRMDisplayToken *tok) = 0;
889
Saurabh Shah66c941b2016-07-06 17:34:05 -0700890 /* Client should invoke this interface on display disconnect.
891 * [input]: DRMDisplayToken - identifier for the display.
892 */
893 virtual void UnregisterDisplay(const DRMDisplayToken &token) = 0;
894
895 /*
896 * Creates and returns an instance of DRMAtomicReqInterface corresponding to a display token
897 * returned as part of RegisterDisplay API. Needs to be called per display.
898 * [input]: DRMDisplayToken that identifies a display pipeline
899 * [output]: Pointer to an instance of DRMAtomicReqInterface.
900 * [return]: Error code if the API fails, 0 on success.
901 */
902 virtual int CreateAtomicReq(const DRMDisplayToken &token, DRMAtomicReqInterface **intf) = 0;
903
904 /*
905 * Destroys the instance of DRMAtomicReqInterface
906 * [input]: Pointer to a DRMAtomicReqInterface
907 * [return]: Error code if the API fails, 0 on success.
908 */
909 virtual int DestroyAtomicReq(DRMAtomicReqInterface *intf) = 0;
Saurabh Shah0ffee302016-11-22 10:42:11 -0800910 /*
911 * Sets the global scaler LUT
912 * [input]: LUT Info
913 * [return]: Error code if the API fails, 0 on success.
914 */
915 virtual int SetScalerLUT(const DRMScalerLUTInfo &lut_info) = 0;
Xu Yang32e58c22017-11-20 09:58:11 +0800916
917 /*
918 * Get the DPPS feature info
919 * [input]: Dpps feature id, info->id
920 * [output]: Dpps feature version, info->version
921 */
922 virtual void GetDppsFeatureInfo(DRMDppsFeatureInfo *info) = 0;
Saurabh Shah66c941b2016-07-06 17:34:05 -0700923};
Saurabh Shah0ffee302016-11-22 10:42:11 -0800924
Saurabh Shah66c941b2016-07-06 17:34:05 -0700925} // namespace sde_drm
926#endif // __DRM_INTERFACE_H__