1 /*
2 * Copyright (c) 2014 - 2020, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are permitted
5 * provided that the following conditions are met:
6 *    * Redistributions of source code must retain the above copyright notice, this list of
7 *      conditions and the following disclaimer.
8 *    * Redistributions in binary form must reproduce the above copyright notice, this list of
9 *      conditions and the following disclaimer in the documentation and/or other materials provided
10 *      with the distribution.
11 *    * Neither the name of The Linux Foundation nor the names of its contributors may be used to
12 *      endorse or promote products derived from this software without specific prior written
13 *      permission.
14 *
15 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24 
25 /*! @file display_interface.h
26   @brief Interface file for display device which represents a physical panel or an output buffer
27   where contents can be rendered.
28 
29   @details Display device is used to send layer buffers for composition and get them rendered onto
30   the target device. Each display device represents a unique display target which may be either a
31   physical panel or an output buffer..
32 */
33 #ifndef __DISPLAY_INTERFACE_H__
34 #define __DISPLAY_INTERFACE_H__
35 
36 #include <stdint.h>
37 #include <string>
38 #include <vector>
39 #include <utility>
40 
41 #include "layer_stack.h"
42 #include "sdm_types.h"
43 
44 namespace sdm {
45 
46 typedef std::vector<std::pair<std::string, std::string>> AttrVal;
47 
48 /*! @brief This enum represents display device types where contents can be rendered.
49 
50   @sa CoreInterface::CreateDisplay
51   @sa CoreInterface::IsDisplaySupported
52 */
53 enum DisplayType {
54   kPrimary,             //!< Main physical display which is attached to the handheld device.
55   kBuiltIn = kPrimary,  //!< Type name for all non-detachable physical displays. Use kBuiltIn
56                         //!< instead of kPrimary.
57   kHDMI,                //!< HDMI physical display which is generally detachable.
58   kPluggable = kHDMI,   //!< Type name for all pluggable physical displays. Use kPluggable
59                         //!< instead of kHDMI.
60   kVirtual,             //!< Contents would be rendered into the output buffer provided by the
61                         //!< client e.g. wireless display.
62   kDisplayMax,
63   kDisplayTypeMax = kDisplayMax
64 };
65 
66 /*! @brief This enum represents states of a display device.
67 
68   @sa DisplayInterface::GetDisplayState
69   @sa DisplayInterface::SetDisplayState
70 */
71 enum DisplayState {
72   kStateOff,        //!< Display is OFF. Contents are not rendered in this state. Client will not
73                     //!< receive VSync events in this state. This is default state as well.
74 
75   kStateOn,         //!< Display is ON. Contents are rendered in this state.
76 
77   kStateDoze,       //!< Display is ON and it is configured in a low power state.
78 
79   kStateDozeSuspend,
80                     //!< Display is ON in a low power state and continue showing its current
81                     //!< contents indefinitely until the mode changes.
82 
83   kStateStandby,    //!< Display is OFF. Client will continue to receive VSync events in this state
84                     //!< if VSync is enabled. Contents are not rendered in this state.
85 };
86 
87 /*! @brief This enum represents flags to override detail enhancer parameters.
88 
89   @sa DisplayInterface::SetDetailEnhancerData
90 */
91 enum DetailEnhancerOverrideFlags {
92   kOverrideDEEnable            = 0x1,     // Specifies to enable detail enhancer
93   kOverrideDESharpen1          = 0x2,     // Specifies user defined Sharpening/smooth for noise
94   kOverrideDESharpen2          = 0x4,     // Specifies user defined Sharpening/smooth for signal
95   kOverrideDEClip              = 0x8,     // Specifies user defined DE clip shift
96   kOverrideDELimit             = 0x10,    // Specifies user defined DE limit value
97   kOverrideDEThrQuiet          = 0x20,    // Specifies user defined DE quiet threshold
98   kOverrideDEThrDieout         = 0x40,    // Specifies user defined DE dieout threshold
99   kOverrideDEThrLow            = 0x80,    // Specifies user defined DE low threshold
100   kOverrideDEThrHigh           = 0x100,   // Specifies user defined DE high threshold
101   kOverrideDEFilterConfig      = 0x200,   // Specifies user defined scaling filter config
102   kOverrideDEBlend             = 0x400,   // Specifies user defined DE blend.
103   kOverrideDEMax               = 0xFFFFFFFF,
104 };
105 
106 /*! @brief This enum represents Y/RGB scaling filter configuration.
107 
108   @sa DisplayInterface::SetDetailEnhancerData
109 */
110 enum ScalingFilterConfig {
111   kFilterEdgeDirected,
112   kFilterCircular,
113   kFilterSeparable,
114   kFilterBilinear,
115   kFilterMax,
116 };
117 
118 /*! @brief This enum represents the quality level of the content.
119 
120   @sa DisplayInterface::SetDetailEnhancerData
121 */
122 enum ContentQuality {
123   kContentQualityUnknown,  // Default: high artifact and noise
124   kContentQualityLow,      // Low quality content, high artifact and noise,
125   kContentQualityMedium,   // Medium quality, medium artifact and noise,
126   kContentQualityHigh,     // High quality content, low artifact and noise
127   kContentQualityMax,
128 };
129 
130 /*! @brief This enum represents the display port.
131 
132   @sa DisplayInterface::GetDisplayPort
133 */
134 enum DisplayPort {
135   kPortDefault,
136   kPortDSI,        // Display is connected to DSI port.
137   kPortDTV,        // Display is connected to DTV port
138   kPortWriteBack,  // Display is connected to writeback port
139   kPortLVDS,       // Display is connected to LVDS port
140   kPortEDP,        // Display is connected to EDP port
141   kPortDP,         // Display is connected to DP port.
142 };
143 
144 /*! @brief This enum represents the events received by Display HAL. */
145 enum DisplayEvent {
146   kIdleTimeout,             // Event triggered by Idle Timer.
147   kThermalEvent,            // Event triggered by Thermal.
148   kIdlePowerCollapse,       // Event triggered by Idle Power Collapse.
149   kPanelDeadEvent,          // Event triggered by ESD.
150   kDisplayPowerResetEvent,  // Event triggered by Hardware Recovery.
151   kInvalidateDisplay,       // Event triggered by DrawCycle thread to Invalidate display.
152   kSyncInvalidateDisplay,   // Event triggered by Non-DrawCycle threads to Invalidate display.
153   kPostIdleTimeout,         // Event triggered after entering idle.
154 };
155 
156 /*! @brief This enum represents the secure events received by Display HAL. */
157 enum SecureEvent {
158   kSecureDisplayStart,  // Client sets it to notify secure display session start
159   kSecureDisplayEnd,    // Client sets it to notify secure display session end
160   kSecureEventMax,
161 };
162 
163 /*! @brief This enum represents the QSync modes supported by the hardware. */
164 enum QSyncMode {
165   kQSyncModeNone,               // This is set by the client to disable qsync
166   kQSyncModeContinuous,         // This is set by the client to enable qsync forever
167   kQsyncModeOneShot,            // This is set by client to enable qsync only for current frame.
168   kQsyncModeOneShotContinuous,  // This is set by client to enable qsync only for every commit.
169 };
170 
171 /*! @brief This structure defines configuration for display dpps ad4 region of interest. */
172 struct DisplayDppsAd4RoiCfg {
173   uint32_t h_start;     //!< start in hotizontal direction
174   uint32_t h_end;       //!< end in hotizontal direction
175   uint32_t v_start;     //!< start in vertical direction
176   uint32_t v_end;       //!< end in vertical direction
177   uint32_t factor_in;   //!< the strength factor of inside ROI region
178   uint32_t factor_out;  //!< the strength factor of outside ROI region
179 };
180 
181 /*! @brief This enum defines frame trigger modes. */
182 enum FrameTriggerMode {
183   kFrameTriggerDefault,      //!< Wait for pp_done of previous frame to trigger new frame
184   kFrameTriggerSerialize,    //!< Trigger new frame and wait for pp_done of this frame
185   kFrameTriggerPostedStart,  //!< Posted start mode, trigger new frame without pp_done
186   kFrameTriggerMax,
187 };
188 
189 /*! @brief This structure defines configuration for fixed properties of a display device.
190 
191   @sa DisplayInterface::GetConfig
192   @sa DisplayInterface::SetConfig
193 */
194 struct DisplayConfigFixedInfo {
195   bool underscan = false;              //!< If display support CE underscan.
196   bool secure = false;                 //!< If this display is capable of handling secure content.
197   bool is_cmdmode = false;             //!< If panel is command mode panel.
198   bool hdr_supported = false;          //!< If HDR10 is supported.
199   bool hdr_plus_supported = false;     //!< If HDR10+ is supported.
200   bool hdr_metadata_type_one = false;  //!< Metadata type one obtained from HDR sink
201   uint32_t hdr_eotf = 0;               //!< Electro optical transfer function
202   float max_luminance = 0.0f;          //!< From Panel's peak luminance
203   float average_luminance = 0.0f;      //!< From Panel's average luminance
204   float min_luminance = 0.0f;          //!< From Panel's blackness level
205   bool partial_update = false;         //!< If display supports Partial Update.
206   bool readback_supported = false;     //!< If display supports buffer readback.
207 };
208 
209 /*! @brief This structure defines configuration for variable properties of a display device.
210 
211   @sa DisplayInterface::GetConfig
212   @sa DisplayInterface::SetConfig
213 */
214 struct DisplayConfigGroupInfo {
215   uint32_t x_pixels = 0;          //!< Total number of pixels in X-direction on the display panel.
216   uint32_t y_pixels = 0;          //!< Total number of pixels in Y-direction on the display panel.
217   float x_dpi = 0.0f;             //!< Dots per inch in X-direction.
218   float y_dpi = 0.0f;             //!< Dots per inch in Y-direction.
219   bool is_yuv = false;            //!< If the display output is in YUV format.
220   bool smart_panel = false;       //!< If the display config has smart panel.
221 
222   bool operator==(const DisplayConfigGroupInfo& info) const {
223     return ((x_pixels == info.x_pixels) && (y_pixels == info.y_pixels) && (x_dpi == info.x_dpi) &&
224             (y_dpi == info.y_dpi) && (is_yuv == info.is_yuv) && (smart_panel == info.smart_panel));
225   }
226 };
227 
228 struct DisplayConfigVariableInfo : public DisplayConfigGroupInfo {
229   uint32_t fps = 0;               //!< Frame rate per second.
230   uint32_t vsync_period_ns = 0;   //!< VSync period in nanoseconds.
231 
232   bool operator==(const DisplayConfigVariableInfo& info) const {
233     return ((x_pixels == info.x_pixels) && (y_pixels == info.y_pixels) && (x_dpi == info.x_dpi) &&
234             (y_dpi == info.y_dpi) && (fps == info.fps) && (vsync_period_ns == info.vsync_period_ns)
235             && (is_yuv == info.is_yuv) && (smart_panel == info.smart_panel));
236   }
237 };
238 
239 /*! @brief Event data associated with VSync event.
240 
241   @sa DisplayEventHandler::VSync
242 */
243 struct DisplayEventVSync {
244   int64_t timestamp = 0;    //!< System monotonic clock timestamp in nanoseconds.
245 };
246 
247 /*! @brief The structure defines the user input for detail enhancer module.
248 
249   @sa DisplayInterface::SetDetailEnhancerData
250 */
251 struct DisplayDetailEnhancerData {
252   uint32_t override_flags = 0;        // flags to specify which data to be set.
253   uint16_t enable = 0;                // Detail enchancer enable
254   int16_t sharpen_level1 = 0;         // Sharpening/smooth strenght for noise
255   int16_t sharpen_level2 = 0;         // Sharpening/smooth strenght for signal
256   uint16_t clip = 0;                  // DE clip shift
257   uint16_t limit = 0;                 // DE limit value
258   uint16_t thr_quiet = 0;             // DE quiet threshold
259   uint16_t thr_dieout = 0;            // DE dieout threshold
260   uint16_t thr_low = 0;               // DE low threshold
261   uint16_t thr_high = 0;              // DE high threshold
262   int32_t sharp_factor = 50;          // sharp_factor specifies sharpness/smoothness level,
263                                       // range -100..100 positive for sharpness and negative for
264                                       // smoothness
265   ContentQuality quality_level = kContentQualityUnknown;
266                                       // Specifies context quality level
267   ScalingFilterConfig filter_config = kFilterEdgeDirected;
268                                       // Y/RGB filter configuration
269   uint32_t de_blend = 0;              // DE Unsharp Mask blend between High and Low frequencies
270 };
271 
272 /*! @brief Display device event handler implemented by the client.
273 
274   @details This class declares prototype for display device event handler methods which must be
275   implemented by the client. Display device will use these methods to notify events to the client.
276   Client must post heavy-weight event handling to a separate thread and unblock display manager
277   thread instantly.
278 
279   @sa CoreInterface::CreateDisplay
280 */
281 class DisplayEventHandler {
282  public:
283   /*! @brief Event handler for VSync event.
284 
285     @details This event is dispatched on every vertical synchronization. The event is disabled by
286     default.
287 
288     @param[in] vsync \link DisplayEventVSync \endlink
289 
290     @return \link DisplayError \endlink
291 
292     @sa DisplayInterface::GetDisplayState
293     @sa DisplayInterface::SetDisplayState
294   */
295   virtual DisplayError VSync(const DisplayEventVSync &vsync) = 0;
296 
297   /*! @brief Event handler for Refresh event.
298 
299     @details This event is dispatched to trigger a screen refresh. Client must call Prepare() and
300     Commit() in response to it from a separate thread. There is no data associated with this
301     event.
302 
303     @return \link DisplayError \endlink
304 
305     @sa DisplayInterface::Prepare
306     @sa DisplayInterface::Commit
307   */
308   virtual DisplayError Refresh() = 0;
309 
310   /*! @brief Event handler for CEC messages.
311 
312     @details This event is dispatched to send CEC messages to the CEC HAL.
313 
314     @param[in] message message to be sent
315 
316     @return \link DisplayError \endlink
317   */
318   virtual DisplayError CECMessage(char *message) = 0;
319 
320   /*! @brief Event handler for Histogram messages received by Display HAL. */
321   virtual DisplayError HistogramEvent(int source_fd, uint32_t blob_id) = 0;
322 
323   /*! @brief Event handler for events received by Display HAL. */
324   virtual DisplayError HandleEvent(DisplayEvent event) = 0;
325 
326  protected:
~DisplayEventHandler()327   virtual ~DisplayEventHandler() { }
328 };
329 
330 struct PPDisplayAPIPayload;
331 struct PPPendingParams;
332 
333 /*! @brief Display device interface.
334 
335   @details This class defines display device interface. It contains methods which client shall use
336   to configure or submit layers for composition on the display device. This interface is created
337   during display device creation and remains valid until destroyed.
338 
339   @sa CoreInterface::CreateDisplay
340   @sa CoreInterface::DestroyDisplay
341 */
342 class DisplayInterface {
343  public:
344   /*! @brief Method to determine hardware capability to compose layers associated with given frame.
345 
346     @details Client shall send all layers associated with a frame targeted for current display
347     using this method and check the layers which can be handled completely in display manager.
348 
349     Client shall mark composition type for one of the layer as kCompositionGPUTarget; the GPU
350     composed output would be rendered at the specified layer if some of the layers are not handled
351     by SDM.
352 
353     Display manager will set each layer as kCompositionGPU or kCompositionSDE upon return. Client
354     shall render all the layers marked as kCompositionGPU using GPU.
355 
356     This method can be called multiple times but only last call prevails. This method must be
357     followed by Commit().
358 
359     @param[inout] layer_stack \link LayerStack \endlink
360 
361     @return \link DisplayError \endlink
362 
363     @sa Commit
364   */
365   virtual DisplayError Prepare(LayerStack *layer_stack) = 0;
366 
367   /*! @brief Method to commit layers of a frame submitted in a former call to Prepare().
368 
369     @details Client shall call this method to submit layers for final composition. The composed
370     output would be displayed on the panel or written in output buffer.
371 
372     Client must ensure that layer stack is same as previous call to Prepare.
373 
374     This method shall be called only once for each frame.
375 
376     In the event of an error as well, this call will cause any fences returned in the previous call
377     to Commit() to eventually become signaled, so the client's wait on fences can be released to
378     prevent deadlocks.
379 
380     @param[in] layer_stack \link LayerStack \endlink
381 
382     @return \link DisplayError \endlink
383 
384     @sa Prepare
385   */
386   virtual DisplayError Commit(LayerStack *layer_stack) = 0;
387 
388   /*! @brief Method to flush any pending buffers/fences submitted previously via Commit() call.
389 
390     @details Client shall call this method to request the Display manager to release all buffers and
391     respective fences currently in use. This operation may result in a blank display on the panel
392     until a new frame is submitted for composition.
393 
394     For virtual displays this would result in output buffer getting cleared with border color.
395 
396     @param[in] layer_stack \link LayerStack \endlink
397 
398     @return \link DisplayError \endlink
399 
400     @sa Prepare
401     @sa Commit
402   */
403   virtual DisplayError Flush(LayerStack *layer_stack) = 0;
404 
405   /*! @brief Method to get current state of the display device.
406 
407     @param[out] state \link DisplayState \endlink
408 
409     @return \link DisplayError \endlink
410 
411     @sa SetDisplayState
412   */
413   virtual DisplayError GetDisplayState(DisplayState *state) = 0;
414 
415   /*! @brief Method to get number of configurations(variable properties) supported on the display
416     device.
417 
418     @param[out] count Number of modes supported; mode index starts with 0.
419 
420     @return \link DisplayError \endlink
421   */
422   virtual DisplayError GetNumVariableInfoConfigs(uint32_t *count) = 0;
423 
424   /*! @brief Method to get configuration for fixed properties of the display device.
425 
426     @param[out] fixed_info \link DisplayConfigFixedInfo \endlink
427 
428     @return \link DisplayError \endlink
429   */
430   virtual DisplayError GetConfig(DisplayConfigFixedInfo *fixed_info) = 0;
431 
432   /*! @brief Method to get configuration for variable properties of the display device.
433 
434     @param[in] index index of the mode
435     @param[out] variable_info \link DisplayConfigVariableInfo \endlink
436 
437     @return \link DisplayError \endlink
438   */
439   virtual DisplayError GetConfig(uint32_t index, DisplayConfigVariableInfo *variable_info) = 0;
440 
441   /*! @brief Method to get index of active configuration of the display device.
442 
443     @param[out] index index of the mode corresponding to variable properties.
444 
445     @return \link DisplayError \endlink
446   */
447   virtual DisplayError GetActiveConfig(uint32_t *index) = 0;
448 
449   /*! @brief Method to get VSync event state. Default event state is disabled.
450 
451     @param[out] enabled vsync state
452 
453     @return \link DisplayError \endlink
454   */
455   virtual DisplayError GetVSyncState(bool *enabled) = 0;
456 
457   /*! @brief Method to set current state of the display device.
458 
459     @param[in] state \link DisplayState \endlink
460     @param[in] flag to force full bridge teardown for pluggable displays, no-op for other displays,
461                if requested state is kStateOff
462     @param[in] pointer to release fence
463 
464     @return \link DisplayError \endlink
465 
466     @sa SetDisplayState
467   */
468   virtual DisplayError SetDisplayState(DisplayState state, bool teardown,
469                                        shared_ptr<Fence> *release_fence) = 0;
470 
471   /*! @brief Method to set active configuration for variable properties of the display device.
472 
473     @param[in] variable_info \link DisplayConfigVariableInfo \endlink
474 
475     @return \link DisplayError \endlink
476   */
477   virtual DisplayError SetActiveConfig(DisplayConfigVariableInfo *variable_info) = 0;
478 
479   /*! @brief Method to set active configuration for variable properties of the display device.
480 
481     @param[in] index index of the mode corresponding to variable properties.
482 
483     @return \link DisplayError \endlink
484   */
485   virtual DisplayError SetActiveConfig(uint32_t index) = 0;
486 
487   /*! @brief Method to set VSync event state. Default event state is disabled.
488 
489     @param[out] enabled vsync state
490 
491     @return \link DisplayError \endlink
492   */
493   virtual DisplayError SetVSyncState(bool enable) = 0;
494 
495   /*! @brief Method to set idle timeout value. Idle fallback is disabled with timeout value 0.
496 
497     @param[in] active_ms value in milliseconds.
498 
499     @return \link void \endlink
500   */
501   virtual void SetIdleTimeoutMs(uint32_t active_ms) = 0;
502 
503   /*! @brief Method to set maximum number of mixer stages for each display.
504 
505     @param[in] max_mixer_stages maximum number of mixer stages.
506 
507     @return \link DisplayError \endlink
508   */
509   virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages) = 0;
510 
511   /*! @brief Method to control partial update feature for each display.
512 
513     @param[in] enable partial update feature control flag
514     @param[out] pending whether the operation is completed or pending for completion
515 
516     @return \link DisplayError \endlink
517   */
518   virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending) = 0;
519 
520   /*! @brief Method to disable partial update for at least 1 frame.
521     @return \link DisplayError \endlink
522   */
523   virtual DisplayError DisablePartialUpdateOneFrame() = 0;
524 
525   /*! @brief Method to set the mode of the primary display.
526 
527     @param[in] mode the new display mode.
528 
529     @return \link DisplayError \endlink
530   */
531   virtual DisplayError SetDisplayMode(uint32_t mode) = 0;
532 
533   /*! @brief Method to get the min and max refresh rate of a display.
534 
535     @param[out] min and max refresh rate.
536 
537     @return \link DisplayError \endlink
538   */
539   virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate,
540                                            uint32_t *max_refresh_rate) = 0;
541 
542   /*! @brief Method to set the refresh rate of a display.
543 
544     @param[in] refresh_rate new refresh rate of the display.
545 
546     @param[in] final_rate indicates whether refresh rate is final rate or can be changed by sdm
547 
548     @param[in] idle_screen indicates whether screen is idle.
549 
550     @return \link DisplayError \endlink
551   */
552   virtual DisplayError SetRefreshRate(uint32_t refresh_rate, bool final_rate,
553                                       bool idle_screen = false) = 0;
554 
555   /*! @brief Method to get the refresh rate of a display.
556 
557     @param[in] refresh_rate refresh rate of the display.
558 
559     @return \link DisplayError \endlink
560   */
561   virtual DisplayError GetRefreshRate(uint32_t *refresh_rate) = 0;
562 
563   /*! @brief Method to query whether scanning is support for the HDMI display.
564 
565     @return \link DisplayError \endlink
566   */
567   virtual bool IsUnderscanSupported() = 0;
568 
569   /*! @brief Method to set brightness of the builtin display.
570 
571     @param[in] brightness the new backlight level 0.0f(min) to 1.0f(max) where -1.0f represents off.
572 
573     @return \link DisplayError \endlink
574   */
575   virtual DisplayError SetPanelBrightness(float brightness) = 0;
576 
577   /*! @brief Method to notify display about change in min HDCP encryption level.
578 
579     @param[in] min_enc_level minimum encryption level value.
580 
581     @return \link DisplayError \endlink
582   */
583   virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level) = 0;
584 
585   /*! @brief Method to route display API requests to color service.
586 
587     @param[in] in_payload \link PPDisplayAPIPayload \endlink
588     @param[out] out_payload \link PPDisplayPayload \endlink
589     @param[out] pending_action \link PPPendingParams \endlink
590 
591     @return \link DisplayError \endlink
592   */
593   virtual DisplayError ColorSVCRequestRoute(const PPDisplayAPIPayload &in_payload,
594                                             PPDisplayAPIPayload *out_payload,
595                                             PPPendingParams *pending_action) = 0;
596 
597   /*! @brief Method to request the number of color modes supported.
598 
599     @param[out] mode_count Number of modes
600 
601     @return \link DisplayError \endlink
602   */
603   virtual DisplayError GetColorModeCount(uint32_t *mode_count) = 0;
604 
605   /*! @brief Method to request the information of supported color modes.
606 
607     @param[inout] mode_count Number of updated modes
608     @param[out] vector of mode strings
609 
610     @return \link DisplayError \endlink
611   */
612   virtual DisplayError GetColorModes(uint32_t *mode_count,
613                                      std::vector<std::string> *color_modes) = 0;
614 
615   /*! @brief Method to request the attributes of color mode.
616 
617     @param[in] mode name
618     @param[out] vector of mode attributes
619 
620     @return \link DisplayError \endlink
621   */
622   virtual DisplayError GetColorModeAttr(const std::string &color_mode,
623                                         AttrVal *attr_map) = 0;
624 
625   /*! @brief Method to set the color mode
626 
627     @param[in] mode_name Mode name which needs to be set
628 
629     @return \link DisplayError \endlink
630   */
631   virtual DisplayError SetColorMode(const std::string &color_mode) = 0;
632 
633   /*! @brief Method to set the color mode by ID. This method is used for debugging only.
634 
635   @param[in] Mode ID which needs to be set
636 
637   @return \link DisplayError \endlink
638   */
639   virtual DisplayError SetColorModeById(int32_t color_mode_id) = 0;
640 
641   /*! @brief Method to get the color mode name.
642 
643   @param[in] Mode ID
644   @param[out] Mode name
645 
646   @return \link DisplayError \endlink
647   */
648   virtual DisplayError GetColorModeName(int32_t mode_id, std::string *mode_name) = 0;
649 
650   /*! @brief Method to set the color transform
651 
652     @param[in] length Mode name which needs to be set
653     @param[in] color_transform  4x4 Matrix for color transform
654 
655     @return \link DisplayError \endlink
656   */
657   virtual DisplayError SetColorTransform(const uint32_t length, const double *color_transform) = 0;
658 
659   /*! @brief Method to get the default color mode.
660 
661     @param[out] default mode name
662 
663     @return \link DisplayError \endlink
664   */
665   virtual DisplayError GetDefaultColorMode(std::string *color_mode) = 0;
666 
667   /*! @brief Method to request applying default display mode.
668 
669     @return \link DisplayError \endlink
670   */
671   virtual DisplayError ApplyDefaultDisplayMode() = 0;
672 
673   /*! @brief Method to set the position of the hw cursor.
674 
675     @param[in] x \link x position \endlink
676     @param[in] y \link y position \endlink
677 
678     @return \link DisplayError \endlink
679   */
680   virtual DisplayError SetCursorPosition(int x, int y) = 0;
681 
682   /*! @brief Method to get the brightness level of the display
683 
684     @param[out] brightness brightness percentage
685 
686     @return \link DisplayError \endlink
687   */
688   virtual DisplayError GetPanelBrightness(float *brightness) = 0;
689 
690   /*! @brief Method to get the max brightness level of the display
691 
692     @param[out] max_brightness level
693 
694     @return \link DisplayError \endlink
695   */
696   virtual DisplayError GetPanelMaxBrightness(uint32_t *max_brightness_level) = 0;
697 
698   /*! @brief Method to set layer mixer resolution.
699 
700     @param[in] width layer mixer width
701     @param[in] height layer mixer height
702 
703     @return \link DisplayError \endlink
704   */
705   virtual DisplayError SetMixerResolution(uint32_t width, uint32_t height) = 0;
706 
707   /*! @brief Method to get layer mixer resolution.
708 
709     @param[out] width layer mixer width
710     @param[out] height layer mixer height
711 
712     @return \link DisplayError \endlink
713   */
714   virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height) = 0;
715 
716   /*! @brief Method to set  frame buffer configuration.
717 
718     @param[in] variable_info \link DisplayConfigVariableInfo \endlink
719 
720     @return \link DisplayError \endlink
721   */
722   virtual DisplayError SetFrameBufferConfig(const DisplayConfigVariableInfo &variable_info) = 0;
723 
724   /*! @brief Method to get frame buffer configuration.
725 
726     @param[out] variable_info \link DisplayConfigVariableInfo \endlink
727 
728     @return \link DisplayError \endlink
729   */
730   virtual DisplayError GetFrameBufferConfig(DisplayConfigVariableInfo *variable_info) = 0;
731 
732   /*! @brief Method to set detail enhancement data.
733 
734     @param[in] de_data \link DisplayDetailEnhancerData \endlink
735 
736     @return \link DisplayError \endlink
737   */
738   virtual DisplayError SetDetailEnhancerData(const DisplayDetailEnhancerData &de_data) = 0;
739 
740   /*! @brief Method to get display port information.
741 
742     @param[out] port \link DisplayPort \endlink
743 
744     @return \link DisplayError \endlink
745   */
746   virtual DisplayError GetDisplayPort(DisplayPort *port) = 0;
747 
748   /*! @brief Method to get display ID information.
749 
750     @param[out] display_id Current display's ID as can be discovered using
751     CoreInterface::GetDisplaysStatus().
752 
753     @return \link DisplayError \endlink
754   */
755   virtual DisplayError GetDisplayId(int32_t *display_id) = 0;
756 
757   /*! @brief Method to get the display's type.
758 
759     @param[out] display_type Current display's type.
760 
761     @return \link DisplayError \endlink
762   */
763   virtual DisplayError GetDisplayType(DisplayType *display_type) = 0;
764 
765   /*! @brief Method to query whether it is Primrary device.
766 
767     @return true if this interface is primary.
768   */
769   virtual bool IsPrimaryDisplay() = 0;
770 
771   /*! @brief Method to toggle composition types handling by SDM.
772 
773     @details Client shall call this method to request SDM to enable/disable a specific type of
774     layer composition. If client disables a composition type, SDM will not handle any of the layer
775     composition using the disabled method in a draw cycle. On lack of resources to handle all
776     layers using other enabled composition methods, Prepare() will return an error.
777 
778     Request to toggle composition type is applied from subsequent draw cycles.
779 
780     Default state of all defined composition types is enabled.
781 
782     @param[in] composition_type \link LayerComposition \endlink
783     @param[in] enable \link enable composition type \endlink
784 
785     @return \link DisplayError \endlink
786 
787     @sa Prepare
788   */
789   virtual DisplayError SetCompositionState(LayerComposition composition_type, bool enable) = 0;
790 
791   /*! @brief Method to check whether a client target with the given properties
792       can be supported/handled by hardware.
793 
794     @param[in] width client target width
795     @param[in] height client target height
796     @param[in] format client target format
797     @param[in] colorMetaData client target colorMetaData
798 
799     @return \link DisplayError \endlink
800   */
801   virtual DisplayError GetClientTargetSupport(uint32_t width, uint32_t height,
802                                               LayerBufferFormat format,
803                                               const ColorMetaData &color_metadata) = 0;
804 
805   /*! @brief Method to handle secure events.
806 
807     @param[in] secure_event \link SecureEvent \endlink
808 
809     @param[inout] layer_stack \link LayerStack \endlink
810 
811     @return \link DisplayError \endlink
812   */
813   virtual DisplayError HandleSecureEvent(SecureEvent secure_event, LayerStack *layer_stack) = 0;
814 
815   /*! @brief Method to set dpps ad roi.
816 
817     @param[in] roi config parmas
818 
819     @return \link DisplayError \endlink
820   */
821 
822   virtual DisplayError SetDisplayDppsAdROI(void *payload) = 0;
823 
824   /*! @brief Method to set the Qsync mode.
825 
826   @param[in] qsync_mode: \link QSyncMode \endlink
827 
828   @return \link DisplayError \endlink
829   */
830   virtual DisplayError SetQSyncMode(QSyncMode qsync_mode) = 0;
831 
832   /*! @brief Method to control idle power collapse feature for primary display.
833 
834     @param[in] enable idle power collapse feature control flag
835     @param[in] synchronous commit flag
836 
837     @return \link DisplayError \endlink
838   */
839   virtual DisplayError ControlIdlePowerCollapse(bool enable, bool synchronous) = 0;
840 
841   /*! @brief Method to query whether it is supprt sspp tonemap.
842 
843     @return true if support sspp tonemap.
844   */
845   virtual bool IsSupportSsppTonemap() = 0;
846 
847   /*! @brief Method to free concurrent writeback resoures for primary display.
848     @return \link DisplayError \endlink
849   */
850   virtual DisplayError TeardownConcurrentWriteback(void) = 0;
851 
852   /*! @brief Method to set frame trigger mode for primary display.
853 
854     @param[in] frame trigger mode
855 
856     @return \link DisplayError \endlink
857   */
858   virtual DisplayError SetFrameTriggerMode(FrameTriggerMode mode) = 0;
859 
860   /*
861    * Returns a string consisting of a dump of SDM's display and layer related state
862    * as programmed to driver
863   */
864   virtual std::string Dump() = 0;
865 
866   /*! @brief Method to dynamically set DSI clock rate.
867 
868     @param[in] bit_clk_rate DSI bit clock rate in HZ.
869 
870     @return \link DisplayError \endlink
871   */
872   virtual DisplayError SetDynamicDSIClock(uint64_t bit_clk_rate) = 0;
873 
874   /*! @brief Method to get the current DSI clock rate
875 
876     @param[out] bit_clk_rate DSI bit clock rate in HZ
877 
878     @return \link DisplayError \endlink
879   */
880   virtual DisplayError GetDynamicDSIClock(uint64_t *bit_clk_rate) = 0;
881 
882   /*! @brief Method to get the supported DSI clock rates
883 
884       @param[out] bitclk DSI bit clock in HZ
885 
886       @return \link DisplayError \endlink
887   */
888   virtual DisplayError GetSupportedDSIClock(std::vector<uint64_t> *bitclk_rates) = 0;
889 
890   /*! @brief Method to retrieve the EDID information and HW port ID for display
891 
892     @param[out] HW port ID
893     @param[out] size of EDID blob data
894     @param[out] EDID blob
895 
896     @return \link DisplayError \endlink
897   */
898   virtual DisplayError GetDisplayIdentificationData(uint8_t *out_port, uint32_t *out_data_size,
899                                                     uint8_t *out_data) = 0;
900   /*! @brief Method to turn on histogram events. */
901   virtual DisplayError colorSamplingOn() = 0;
902 
903   /*! @brief Method to turn off histogram events. */
904   virtual DisplayError colorSamplingOff() = 0;
905 
906   /*! @brief Method to set min/max luminance for dynamic tonemapping of external device over WFD.
907 
908     @param[in] min_lum min luminance supported by external device.
909     @param[in] max_lum max luminance supported by external device.
910 
911     @return \link DisplayError \endlink
912   */
913   virtual DisplayError SetPanelLuminanceAttributes(float min_lum, float max_lum) = 0;
914 
915   /*! @brief Method to query if there is a need to validate.
916 
917       @return \link boolean \endlink
918   */
919   virtual bool CanSkipValidate() = 0;
920 
921   /*! @brief Method to set display backlight scale ratio.
922 
923     @param[in] backlight scale ratio.
924 
925     @return \link DisplayError \endlink
926   */
927   virtual DisplayError SetBLScale(uint32_t level) = 0;
928 
929   /*! @brief Method to check if the Default resources are freed for display
930 
931     @return \link bool \endlink
932   */
933   virtual bool CheckResourceState() = 0;
934 
935   /*! @brief Method to check if game enhance feature is supported for display
936 
937     @return \link bool \endlink
938   */
939   virtual bool GameEnhanceSupported() = 0;
940 
941   /*! @brief Method to get the current qsync mode used.
942 
943     @return \link DisplayError \endlink
944   */
945   virtual DisplayError GetQSyncMode(QSyncMode *qsync_mode) = 0;
946 
947   /*! @brief Method to clear scaler LUTs.
948 
949     @return \link DisplayError \endlink
950   */
951   virtual DisplayError ClearLUTs() = 0;
952 
953  protected:
~DisplayInterface()954   virtual ~DisplayInterface() { }
955 };
956 
957 }  // namespace sdm
958 
959 #endif  // __DISPLAY_INTERFACE_H__
960 
961