1 /*
2 * Copyright (c) 2014 - 2019, 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   kOverrideDEMax               = 0xFFFFFFFF,
103 };
104 
105 /*! @brief This enum represents Y/RGB scaling filter configuration.
106 
107   @sa DisplayInterface::SetDetailEnhancerData
108 */
109 enum ScalingFilterConfig {
110   kFilterEdgeDirected,
111   kFilterCircular,
112   kFilterSeparable,
113   kFilterBilinear,
114   kFilterMax,
115 };
116 
117 /*! @brief This enum represents the quality level of the content.
118 
119   @sa DisplayInterface::SetDetailEnhancerData
120 */
121 enum ContentQuality {
122   kContentQualityUnknown,  // Default: high artifact and noise
123   kContentQualityLow,      // Low quality content, high artifact and noise,
124   kContentQualityMedium,   // Medium quality, medium artifact and noise,
125   kContentQualityHigh,     // High quality content, low artifact and noise
126   kContentQualityMax,
127 };
128 
129 /*! @brief This enum represents the display port.
130 
131   @sa DisplayInterface::GetDisplayPort
132 */
133 enum DisplayPort {
134   kPortDefault,
135   kPortDSI,        // Display is connected to DSI port.
136   kPortDTV,        // Display is connected to DTV port
137   kPortWriteBack,  // Display is connected to writeback port
138   kPortLVDS,       // Display is connected to LVDS port
139   kPortEDP,        // Display is connected to EDP port
140   kPortDP,         // Display is connected to DP port.
141 };
142 
143 /*! @brief This enum represents the events received by Display HAL. */
144 enum DisplayEvent {
145   kIdleTimeout,             // Event triggered by Idle Timer.
146   kThermalEvent,            // Event triggered by Thermal.
147   kIdlePowerCollapse,       // Event triggered by Idle Power Collapse.
148   kPanelDeadEvent,          // Event triggered by ESD.
149   kDisplayPowerResetEvent,  // Event triggered by Hardware Recovery.
150   kInvalidateDisplay,       // Event triggered to Invalidate display.
151 };
152 
153 /*! @brief This enum represents the secure events received by Display HAL. */
154 enum SecureEvent {
155   kSecureDisplayStart,  // Client sets it to notify secure display session start
156   kSecureDisplayEnd,    // Client sets it to notify secure display session end
157   kSecureEventMax,
158 };
159 
160 /*! @brief This enum represents the QSync modes supported by the hardware. */
161 enum QSyncMode {
162   kQSyncModeNone,        // This is set by the client to disable qsync
163   kQSyncModeContinuous,  // This is set by the client to enable qsync forever
164   kQsyncModeOneShot,     // This is set by client to enable qsync only for current frame.
165 };
166 
167 /*! @brief This structure defines configuration for display dpps ad4 region of interest. */
168 struct DisplayDppsAd4RoiCfg {
169   uint32_t h_start;     //!< start in hotizontal direction
170   uint32_t h_end;       //!< end in hotizontal direction
171   uint32_t v_start;     //!< start in vertical direction
172   uint32_t v_end;       //!< end in vertical direction
173   uint32_t factor_in;   //!< the strength factor of inside ROI region
174   uint32_t factor_out;  //!< the strength factor of outside ROI region
175 };
176 
177 /*! @brief This structure defines configuration for fixed properties of a display device.
178 
179   @sa DisplayInterface::GetConfig
180   @sa DisplayInterface::SetConfig
181 */
182 struct DisplayConfigFixedInfo {
183   bool underscan = false;              //!< If display support CE underscan.
184   bool secure = false;                 //!< If this display is capable of handling secure content.
185   bool is_cmdmode = false;             //!< If panel is command mode panel.
186   bool hdr_supported = false;          //!< if HDR is enabled
187   bool hdr_metadata_type_one = false;  //!< Metadata type one obtained from HDR sink
188   uint32_t hdr_eotf = 0;               //!< Electro optical transfer function
189   float max_luminance = 0.0f;          //!< From Panel's peak luminance
190   float average_luminance = 0.0f;      //!< From Panel's average luminance
191   float min_luminance = 0.0f;          //!< From Panel's blackness level
192   bool partial_update = false;         //!< If display supports Partial Update.
193 };
194 
195 /*! @brief This structure defines configuration for variable properties of a display device.
196 
197   @sa DisplayInterface::GetConfig
198   @sa DisplayInterface::SetConfig
199 */
200 struct DisplayConfigVariableInfo {
201   uint32_t x_pixels = 0;          //!< Total number of pixels in X-direction on the display panel.
202   uint32_t y_pixels = 0;          //!< Total number of pixels in Y-direction on the display panel.
203   float x_dpi = 0.0f;             //!< Dots per inch in X-direction.
204   float y_dpi = 0.0f;             //!< Dots per inch in Y-direction.
205   uint32_t fps = 0;               //!< Frame rate per second.
206   uint32_t vsync_period_ns = 0;   //!< VSync period in nanoseconds.
207   bool is_yuv = false;            //!< If the display output is in YUV format.
208 
209   bool operator==(const DisplayConfigVariableInfo& info) const {
210     return ((x_pixels == info.x_pixels) && (y_pixels == info.y_pixels) && (x_dpi == info.x_dpi) &&
211             (y_dpi == info.y_dpi) && (fps == info.fps) && (vsync_period_ns == info.vsync_period_ns)
212             && (is_yuv == info.is_yuv));
213   }
214 };
215 
216 /*! @brief Event data associated with VSync event.
217 
218   @sa DisplayEventHandler::VSync
219 */
220 struct DisplayEventVSync {
221   int64_t timestamp = 0;    //!< System monotonic clock timestamp in nanoseconds.
222 };
223 
224 /*! @brief The structure defines the user input for detail enhancer module.
225 
226   @sa DisplayInterface::SetDetailEnhancerData
227 */
228 struct DisplayDetailEnhancerData {
229   uint32_t override_flags = 0;        // flags to specify which data to be set.
230   uint16_t enable = 0;                // Detail enchancer enable
231   int16_t sharpen_level1 = 0;         // Sharpening/smooth strenght for noise
232   int16_t sharpen_level2 = 0;         // Sharpening/smooth strenght for signal
233   uint16_t clip = 0;                  // DE clip shift
234   uint16_t limit = 0;                 // DE limit value
235   uint16_t thr_quiet = 0;             // DE quiet threshold
236   uint16_t thr_dieout = 0;            // DE dieout threshold
237   uint16_t thr_low = 0;               // DE low threshold
238   uint16_t thr_high = 0;              // DE high threshold
239   int32_t sharp_factor = 50;          // sharp_factor specifies sharpness/smoothness level,
240                                       // range -100..100 positive for sharpness and negative for
241                                       // smoothness
242   ContentQuality quality_level = kContentQualityUnknown;
243                                       // Specifies context quality level
244   ScalingFilterConfig filter_config = kFilterEdgeDirected;
245                                       // Y/RGB filter configuration
246 };
247 
248 /*! @brief Display device event handler implemented by the client.
249 
250   @details This class declares prototype for display device event handler methods which must be
251   implemented by the client. Display device will use these methods to notify events to the client.
252   Client must post heavy-weight event handling to a separate thread and unblock display manager
253   thread instantly.
254 
255   @sa CoreInterface::CreateDisplay
256 */
257 class DisplayEventHandler {
258  public:
259   /*! @brief Event handler for VSync event.
260 
261     @details This event is dispatched on every vertical synchronization. The event is disabled by
262     default.
263 
264     @param[in] vsync \link DisplayEventVSync \endlink
265 
266     @return \link DisplayError \endlink
267 
268     @sa DisplayInterface::GetDisplayState
269     @sa DisplayInterface::SetDisplayState
270   */
271   virtual DisplayError VSync(const DisplayEventVSync &vsync) = 0;
272 
273   /*! @brief Event handler for Refresh event.
274 
275     @details This event is dispatched to trigger a screen refresh. Client must call Prepare() and
276     Commit() in response to it from a separate thread. There is no data associated with this
277     event.
278 
279     @return \link DisplayError \endlink
280 
281     @sa DisplayInterface::Prepare
282     @sa DisplayInterface::Commit
283   */
284   virtual DisplayError Refresh() = 0;
285 
286   /*! @brief Event handler for CEC messages.
287 
288     @details This event is dispatched to send CEC messages to the CEC HAL.
289 
290     @param[in] message message to be sent
291 
292     @return \link DisplayError \endlink
293   */
294   virtual DisplayError CECMessage(char *message) = 0;
295 
296   /*! @brief Event handler for Histogram messages received by Display HAL. */
297   virtual DisplayError HistogramEvent(int source_fd, uint32_t blob_id) = 0;
298 
299   /*! @brief Event handler for events received by Display HAL. */
300   virtual DisplayError HandleEvent(DisplayEvent event) = 0;
301 
302  protected:
~DisplayEventHandler()303   virtual ~DisplayEventHandler() { }
304 };
305 
306 struct PPDisplayAPIPayload;
307 struct PPPendingParams;
308 
309 /*! @brief Display device interface.
310 
311   @details This class defines display device interface. It contains methods which client shall use
312   to configure or submit layers for composition on the display device. This interface is created
313   during display device creation and remains valid until destroyed.
314 
315   @sa CoreInterface::CreateDisplay
316   @sa CoreInterface::DestroyDisplay
317 */
318 class DisplayInterface {
319  public:
320   /*! @brief Method to determine hardware capability to compose layers associated with given frame.
321 
322     @details Client shall send all layers associated with a frame targeted for current display
323     using this method and check the layers which can be handled completely in display manager.
324 
325     Client shall mark composition type for one of the layer as kCompositionGPUTarget; the GPU
326     composed output would be rendered at the specified layer if some of the layers are not handled
327     by SDM.
328 
329     Display manager will set each layer as kCompositionGPU or kCompositionSDE upon return. Client
330     shall render all the layers marked as kCompositionGPU using GPU.
331 
332     This method can be called multiple times but only last call prevails. This method must be
333     followed by Commit().
334 
335     @param[inout] layer_stack \link LayerStack \endlink
336 
337     @return \link DisplayError \endlink
338 
339     @sa Commit
340   */
341   virtual DisplayError Prepare(LayerStack *layer_stack) = 0;
342 
343   /*! @brief Method to commit layers of a frame submitted in a former call to Prepare().
344 
345     @details Client shall call this method to submit layers for final composition. The composed
346     output would be displayed on the panel or written in output buffer.
347 
348     Client must ensure that layer stack is same as previous call to Prepare.
349 
350     This method shall be called only once for each frame.
351 
352     In the event of an error as well, this call will cause any fences returned in the previous call
353     to Commit() to eventually become signaled, so the client's wait on fences can be released to
354     prevent deadlocks.
355 
356     @param[in] layer_stack \link LayerStack \endlink
357 
358     @return \link DisplayError \endlink
359 
360     @sa Prepare
361   */
362   virtual DisplayError Commit(LayerStack *layer_stack) = 0;
363 
364   /*! @brief Method to flush any pending buffers/fences submitted previously via Commit() call.
365 
366     @details Client shall call this method to request the Display manager to release all buffers and
367     respective fences currently in use. This operation may result in a blank display on the panel
368     until a new frame is submitted for composition.
369 
370     For virtual displays this would result in output buffer getting cleared with border color.
371 
372     @param[in] layer_stack \link LayerStack \endlink
373 
374     @return \link DisplayError \endlink
375 
376     @sa Prepare
377     @sa Commit
378   */
379   virtual DisplayError Flush(LayerStack *layer_stack) = 0;
380 
381   /*! @brief Method to get current state of the display device.
382 
383     @param[out] state \link DisplayState \endlink
384 
385     @return \link DisplayError \endlink
386 
387     @sa SetDisplayState
388   */
389   virtual DisplayError GetDisplayState(DisplayState *state) = 0;
390 
391   /*! @brief Method to get number of configurations(variable properties) supported on the display
392     device.
393 
394     @param[out] count Number of modes supported; mode index starts with 0.
395 
396     @return \link DisplayError \endlink
397   */
398   virtual DisplayError GetNumVariableInfoConfigs(uint32_t *count) = 0;
399 
400   /*! @brief Method to get configuration for fixed properties of the display device.
401 
402     @param[out] fixed_info \link DisplayConfigFixedInfo \endlink
403 
404     @return \link DisplayError \endlink
405   */
406   virtual DisplayError GetConfig(DisplayConfigFixedInfo *fixed_info) = 0;
407 
408   /*! @brief Method to get configuration for variable properties of the display device.
409 
410     @param[in] index index of the mode
411     @param[out] variable_info \link DisplayConfigVariableInfo \endlink
412 
413     @return \link DisplayError \endlink
414   */
415   virtual DisplayError GetConfig(uint32_t index, DisplayConfigVariableInfo *variable_info) = 0;
416 
417   /*! @brief Method to get index of active configuration of the display device.
418 
419     @param[out] index index of the mode corresponding to variable properties.
420 
421     @return \link DisplayError \endlink
422   */
423   virtual DisplayError GetActiveConfig(uint32_t *index) = 0;
424 
425   /*! @brief Method to get VSync event state. Default event state is disabled.
426 
427     @param[out] enabled vsync state
428 
429     @return \link DisplayError \endlink
430   */
431   virtual DisplayError GetVSyncState(bool *enabled) = 0;
432 
433   /*! @brief Method to set current state of the display device.
434 
435     @param[in] state \link DisplayState \endlink
436     @param[in] flag to force full bridge teardown for pluggable displays, no-op for other displays,
437                if requested state is kStateOff
438     @param[in] pointer to release fence
439 
440     @return \link DisplayError \endlink
441 
442     @sa SetDisplayState
443   */
444   virtual DisplayError SetDisplayState(DisplayState state, bool teardown,
445                                        int *release_fence) = 0;
446 
447   /*! @brief Method to set active configuration for variable properties of the display device.
448 
449     @param[in] variable_info \link DisplayConfigVariableInfo \endlink
450 
451     @return \link DisplayError \endlink
452   */
453   virtual DisplayError SetActiveConfig(DisplayConfigVariableInfo *variable_info) = 0;
454 
455   /*! @brief Method to set active configuration for variable properties of the display device.
456 
457     @param[in] index index of the mode corresponding to variable properties.
458 
459     @return \link DisplayError \endlink
460   */
461   virtual DisplayError SetActiveConfig(uint32_t index) = 0;
462 
463   /*! @brief Method to set VSync event state. Default event state is disabled.
464 
465     @param[out] enabled vsync state
466 
467     @return \link DisplayError \endlink
468   */
469   virtual DisplayError SetVSyncState(bool enable) = 0;
470 
471   /*! @brief Method to set idle timeout value. Idle fallback is disabled with timeout value 0.
472 
473     @param[in] active_ms value in milliseconds.
474 
475     @return \link void \endlink
476   */
477   virtual void SetIdleTimeoutMs(uint32_t active_ms) = 0;
478 
479   /*! @brief Method to set maximum number of mixer stages for each display.
480 
481     @param[in] max_mixer_stages maximum number of mixer stages.
482 
483     @return \link DisplayError \endlink
484   */
485   virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages) = 0;
486 
487   /*! @brief Method to control partial update feature for each display.
488 
489     @param[in] enable partial update feature control flag
490     @param[out] pending whether the operation is completed or pending for completion
491 
492     @return \link DisplayError \endlink
493   */
494   virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending) = 0;
495 
496   /*! @brief Method to disable partial update for at least 1 frame.
497     @return \link DisplayError \endlink
498   */
499   virtual DisplayError DisablePartialUpdateOneFrame() = 0;
500 
501   /*! @brief Method to set the mode of the primary display.
502 
503     @param[in] mode the new display mode.
504 
505     @return \link DisplayError \endlink
506   */
507   virtual DisplayError SetDisplayMode(uint32_t mode) = 0;
508 
509   /*! @brief Method to get the min and max refresh rate of a display.
510 
511     @param[out] min and max refresh rate.
512 
513     @return \link DisplayError \endlink
514   */
515   virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate,
516                                            uint32_t *max_refresh_rate) = 0;
517 
518   /*! @brief Method to set the refresh rate of a display.
519 
520     @param[in] refresh_rate new refresh rate of the display.
521 
522     @param[in] final_rate indicates whether refresh rate is final rate or can be changed by sdm
523 
524     @return \link DisplayError \endlink
525   */
526   virtual DisplayError SetRefreshRate(uint32_t refresh_rate, bool final_rate) = 0;
527 
528   /*! @brief Method to query whether scanning is support for the HDMI display.
529 
530     @return \link DisplayError \endlink
531   */
532   virtual bool IsUnderscanSupported() = 0;
533 
534   /*! @brief Method to set brightness of the primary display.
535 
536     @param[in] level the new backlight level.
537 
538     @return \link DisplayError \endlink
539   */
540   virtual DisplayError SetPanelBrightness(int level) = 0;
541 
542   /*! @brief Method to notify display about change in min HDCP encryption level.
543 
544     @param[in] min_enc_level minimum encryption level value.
545 
546     @return \link DisplayError \endlink
547   */
548   virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level) = 0;
549 
550   /*! @brief Method to route display API requests to color service.
551 
552     @param[in] in_payload \link PPDisplayAPIPayload \endlink
553     @param[out] out_payload \link PPDisplayPayload \endlink
554     @param[out] pending_action \link PPPendingParams \endlink
555 
556     @return \link DisplayError \endlink
557   */
558   virtual DisplayError ColorSVCRequestRoute(const PPDisplayAPIPayload &in_payload,
559                                             PPDisplayAPIPayload *out_payload,
560                                             PPPendingParams *pending_action) = 0;
561 
562   /*! @brief Method to request the number of color modes supported.
563 
564     @param[out] mode_count Number of modes
565 
566     @return \link DisplayError \endlink
567   */
568   virtual DisplayError GetColorModeCount(uint32_t *mode_count) = 0;
569 
570   /*! @brief Method to request the information of supported color modes.
571 
572     @param[inout] mode_count Number of updated modes
573     @param[out] vector of mode strings
574 
575     @return \link DisplayError \endlink
576   */
577   virtual DisplayError GetColorModes(uint32_t *mode_count,
578                                      std::vector<std::string> *color_modes) = 0;
579 
580   /*! @brief Method to request the attributes of color mode.
581 
582     @param[in] mode name
583     @param[out] vector of mode attributes
584 
585     @return \link DisplayError \endlink
586   */
587   virtual DisplayError GetColorModeAttr(const std::string &color_mode,
588                                         AttrVal *attr_map) = 0;
589 
590   /*! @brief Method to set the color mode
591 
592     @param[in] mode_name Mode name which needs to be set
593 
594     @return \link DisplayError \endlink
595   */
596   virtual DisplayError SetColorMode(const std::string &color_mode) = 0;
597 
598   /*! @brief Method to set the color mode by ID. This method is used for debugging only.
599 
600   @param[in] Mode ID which needs to be set
601 
602   @return \link DisplayError \endlink
603   */
604   virtual DisplayError SetColorModeById(int32_t color_mode_id) = 0;
605 
606   /*! @brief Method to get the color mode name.
607 
608   @param[in] Mode ID
609   @param[out] Mode name
610 
611   @return \link DisplayError \endlink
612   */
613   virtual DisplayError GetColorModeName(int32_t mode_id, std::string *mode_name) = 0;
614 
615   /*! @brief Method to set the color transform
616 
617     @param[in] length Mode name which needs to be set
618     @param[in] color_transform  4x4 Matrix for color transform
619 
620     @return \link DisplayError \endlink
621   */
622   virtual DisplayError SetColorTransform(const uint32_t length, const double *color_transform) = 0;
623 
624   /*! @brief Method to get the default color mode.
625 
626     @param[out] default mode name
627 
628     @return \link DisplayError \endlink
629   */
630   virtual DisplayError GetDefaultColorMode(std::string *color_mode) = 0;
631 
632   /*! @brief Method to set the position of the hw cursor.
633 
634     @param[in] x \link x position \endlink
635     @param[in] y \link y position \endlink
636 
637     @return \link DisplayError \endlink
638   */
639   virtual DisplayError SetCursorPosition(int x, int y) = 0;
640 
641   /*! @brief Method to get the brightness level of the display
642 
643     @param[out] level brightness level
644 
645     @return \link DisplayError \endlink
646   */
647   virtual DisplayError GetPanelBrightness(int *level) = 0;
648 
649   /*! @brief Method to set layer mixer resolution.
650 
651     @param[in] width layer mixer width
652     @param[in] height layer mixer height
653 
654     @return \link DisplayError \endlink
655   */
656   virtual DisplayError SetMixerResolution(uint32_t width, uint32_t height) = 0;
657 
658   /*! @brief Method to get layer mixer resolution.
659 
660     @param[out] width layer mixer width
661     @param[out] height layer mixer height
662 
663     @return \link DisplayError \endlink
664   */
665   virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height) = 0;
666 
667   /*! @brief Method to set  frame buffer configuration.
668 
669     @param[in] variable_info \link DisplayConfigVariableInfo \endlink
670 
671     @return \link DisplayError \endlink
672   */
673   virtual DisplayError SetFrameBufferConfig(const DisplayConfigVariableInfo &variable_info) = 0;
674 
675   /*! @brief Method to get frame buffer configuration.
676 
677     @param[out] variable_info \link DisplayConfigVariableInfo \endlink
678 
679     @return \link DisplayError \endlink
680   */
681   virtual DisplayError GetFrameBufferConfig(DisplayConfigVariableInfo *variable_info) = 0;
682 
683   /*! @brief Method to set detail enhancement data.
684 
685     @param[in] de_data \link DisplayDetailEnhancerData \endlink
686 
687     @return \link DisplayError \endlink
688   */
689   virtual DisplayError SetDetailEnhancerData(const DisplayDetailEnhancerData &de_data) = 0;
690 
691   /*! @brief Method to get display port information.
692 
693     @param[out] port \link DisplayPort \endlink
694 
695     @return \link DisplayError \endlink
696   */
697   virtual DisplayError GetDisplayPort(DisplayPort *port) = 0;
698 
699   /*! @brief Method to get display ID information.
700 
701     @param[out] display_id Current display's ID as can be discovered using
702     CoreInterface::GetDisplaysStatus().
703 
704     @return \link DisplayError \endlink
705   */
706   virtual DisplayError GetDisplayId(int32_t *display_id) = 0;
707 
708   /*! @brief Method to get the display's type.
709 
710     @param[out] display_type Current display's type.
711 
712     @return \link DisplayError \endlink
713   */
714   virtual DisplayError GetDisplayType(DisplayType *display_type) = 0;
715 
716   /*! @brief Method to query whether it is Primrary device.
717 
718     @return true if this interface is primary.
719   */
720   virtual bool IsPrimaryDisplay() = 0;
721 
722   /*! @brief Method to toggle composition types handling by SDM.
723 
724     @details Client shall call this method to request SDM to enable/disable a specific type of
725     layer composition. If client disables a composition type, SDM will not handle any of the layer
726     composition using the disabled method in a draw cycle. On lack of resources to handle all
727     layers using other enabled composition methods, Prepare() will return an error.
728 
729     Request to toggle composition type is applied from subsequent draw cycles.
730 
731     Default state of all defined composition types is enabled.
732 
733     @param[in] composition_type \link LayerComposition \endlink
734     @param[in] enable \link enable composition type \endlink
735 
736     @return \link DisplayError \endlink
737 
738     @sa Prepare
739   */
740   virtual DisplayError SetCompositionState(LayerComposition composition_type, bool enable) = 0;
741 
742   /*! @brief Method to check whether a client target with the given properties
743       can be supported/handled by hardware.
744 
745     @param[in] width client target width
746     @param[in] height client target height
747     @param[in] format client target format
748     @param[in] colorMetaData client target colorMetaData
749 
750     @return \link DisplayError \endlink
751   */
752   virtual DisplayError GetClientTargetSupport(uint32_t width, uint32_t height,
753                                               LayerBufferFormat format,
754                                               const ColorMetaData &color_metadata) = 0;
755 
756   /*! @brief Method to handle secure events.
757 
758     @param[in] secure_event \link SecureEvent \endlink
759 
760     @param[inout] layer_stack \link LayerStack \endlink
761 
762     @return \link DisplayError \endlink
763   */
764   virtual DisplayError HandleSecureEvent(SecureEvent secure_event, LayerStack *layer_stack) = 0;
765 
766   /*! @brief Method to set dpps ad roi.
767 
768     @param[in] roi config parmas
769 
770     @return \link DisplayError \endlink
771   */
772 
773   virtual DisplayError SetDisplayDppsAdROI(void *payload) = 0;
774 
775   /*! @brief Method to set the Qsync mode.
776 
777   @param[in] qsync_mode: \link QSyncMode \endlink
778 
779   @return \link DisplayError \endlink
780   */
781   virtual DisplayError SetQSyncMode(QSyncMode qsync_mode) = 0;
782 
783   /*! @brief Method to control idle power collapse feature for primary display.
784 
785     @param[in] enable idle power collapse feature control flag
786     @param[in] synchronous commit flag
787 
788     @return \link DisplayError \endlink
789   */
790   virtual DisplayError ControlIdlePowerCollapse(bool enable, bool synchronous) = 0;
791 
792   /*! @brief Method to query whether it is supprt sspp tonemap.
793 
794     @return true if support sspp tonemap.
795   */
796   virtual bool IsSupportSsppTonemap() = 0;
797 
798   /*! @brief Method to free concurrent writeback resoures for primary display.
799     @return \link DisplayError \endlink
800   */
801   virtual DisplayError TeardownConcurrentWriteback(void) = 0;
802 
803   /*
804    * Returns a string consisting of a dump of SDM's display and layer related state
805    * as programmed to driver
806   */
807   virtual std::string Dump() = 0;
808 
809   /*! @brief Method to dynamically set DSI clock rate.
810 
811     @param[in] bit_clk_rate DSI bit clock rate in HZ.
812 
813     @return \link DisplayError \endlink
814   */
815   virtual DisplayError SetDynamicDSIClock(uint64_t bit_clk_rate) = 0;
816 
817   /*! @brief Method to get the current DSI clock rate
818 
819     @param[out] bit_clk_rate DSI bit clock rate in HZ
820 
821     @return \link DisplayError \endlink
822   */
823   virtual DisplayError GetDynamicDSIClock(uint64_t *bit_clk_rate) = 0;
824 
825   /*! @brief Method to get the supported DSI clock rates
826 
827       @param[out] bitclk DSI bit clock in HZ
828 
829       @return \link DisplayError \endlink
830   */
831   virtual DisplayError GetSupportedDSIClock(std::vector<uint64_t> *bitclk_rates) = 0;
832 
833   /*! @brief Method to retrieve the EDID information and HW port ID for display
834 
835     @param[out] HW port ID
836     @param[out] size of EDID blob data
837     @param[out] EDID blob
838 
839     @return \link DisplayError \endlink
840   */
841   virtual DisplayError GetDisplayIdentificationData(uint8_t *out_port, uint32_t *out_data_size,
842                                                     uint8_t *out_data) = 0;
843   /*! @brief Method to turn on histogram events. */
844   virtual DisplayError colorSamplingOn() = 0;
845 
846   /*! @brief Method to turn off histogram events. */
847   virtual DisplayError colorSamplingOff() = 0;
848 
849  protected:
~DisplayInterface()850   virtual ~DisplayInterface() { }
851 };
852 
853 }  // namespace sdm
854 
855 #endif  // __DISPLAY_INTERFACE_H__
856 
857