1 /* 2 * Copyright (c) 2017, 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 #ifndef __HWC_DISPLAY_EXTERNAL_TEST_H__ 26 #define __HWC_DISPLAY_EXTERNAL_TEST_H__ 27 28 #include<bitset> 29 30 #include "hwc_display.h" 31 #include "hwc_buffer_allocator.h" 32 33 namespace sdm { 34 35 class HWCDisplayExternalTest : public HWCDisplay { 36 public: 37 static int Create(CoreInterface *core_intf, HWCBufferAllocator *buffer_allocator, 38 HWCCallbacks *callbacks, qService::QService *qservice, 39 uint32_t panel_bpp, uint32_t pattern_type, HWCDisplay **hwc_display); 40 static void Destroy(HWCDisplay *hwc_display); 41 virtual HWC2::Error Validate(uint32_t *out_num_types, uint32_t *out_num_requests); 42 virtual HWC2::Error Present(int32_t *out_retire_fence); 43 virtual void SetSecureDisplay(bool secure_display_active); 44 virtual int Perform(uint32_t operation, ...); 45 46 protected: 47 BufferInfo buffer_info_ = {}; 48 uint32_t panel_bpp_ = 0; 49 uint32_t pattern_type_ = 0; 50 51 enum ColorPatternType { 52 kPatternNone = 0, 53 kPatternColorRamp, 54 kPatternBWVertical, 55 kPatternColorSquare, 56 }; 57 58 enum DisplayBpp { 59 kDisplayBpp18 = 18, 60 kDisplayBpp24 = 24, 61 kDisplayBpp30 = 30, 62 }; 63 64 enum ColorRamp { 65 kColorRedRamp = 0, 66 kColorGreenRamp = 1, 67 kColorBlueRamp = 2, 68 kColorWhiteRamp = 3, 69 }; 70 71 enum Colors { 72 kColorBlack = 0, 73 kColorWhite = 1, 74 }; 75 76 private: 77 HWCDisplayExternalTest(CoreInterface *core_intf, HWCBufferAllocator *buffer_allocator, 78 HWCCallbacks *callbacks, qService::QService *qservice, 79 uint32_t panel_bpp, uint32_t pattern_type); 80 int Init(); 81 int Deinit(); 82 void DumpInputBuffer(); 83 void CalcCRC(uint32_t color_value, std::bitset<16> *crc_data); 84 int FillBuffer(); 85 int GetStride(LayerBufferFormat format, uint32_t width, uint32_t *stride); 86 void PixelCopy(uint32_t red, uint32_t green, uint32_t blue, uint32_t alpha, uint8_t **buffer); 87 void GenerateColorRamp(uint8_t *buffer); 88 void GenerateBWVertical(uint8_t *buffer); 89 void GenerateColorSquare(uint8_t *buffer); 90 int InitLayer(Layer *layer); 91 int DeinitLayer(Layer *layer); 92 int CreateLayerStack(); 93 int DestroyLayerStack(); 94 HWC2::Error PostCommit(int32_t *out_retire_fence); 95 96 static const uint32_t kTestLayerCnt = 1; 97 }; 98 99 } // namespace sdm 100 101 #endif // __HWC_DISPLAY_EXTERNAL_TEST_H__ 102 103