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, hwc_procs_t const **hwc_procs, 38 qService::QService *qservice, uint32_t panel_bpp, uint32_t pattern_type, 39 HWCDisplay **hwc_display); 40 static void Destroy(HWCDisplay *hwc_display); 41 virtual int Prepare(hwc_display_contents_1_t *content_list); 42 virtual int Commit(hwc_display_contents_1_t *content_list); 43 virtual void SetSecureDisplay(bool secure_display_active, bool force_flush); 44 virtual int Perform(uint32_t operation, ...); 45 46 protected: 47 HWCBufferAllocator *buffer_allocator_ = NULL; 48 BufferInfo buffer_info_ = {}; 49 uint32_t panel_bpp_ = 0; 50 uint32_t pattern_type_ = 0; 51 52 enum ColorPatternType { 53 kPatternNone = 0, 54 kPatternColorRamp, 55 kPatternBWVertical, 56 kPatternColorSquare, 57 }; 58 59 enum DisplayBpp { 60 kDisplayBpp18 = 18, 61 kDisplayBpp24 = 24, 62 kDisplayBpp30 = 30, 63 }; 64 65 enum ColorRamp { 66 kColorRedRamp = 0, 67 kColorGreenRamp = 1, 68 kColorBlueRamp = 2, 69 kColorWhiteRamp = 3, 70 }; 71 72 enum Colors { 73 kColorBlack = 0, 74 kColorWhite = 1, 75 }; 76 77 private: 78 HWCDisplayExternalTest(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, 79 qService::QService *qservice, 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 int PostCommit(hwc_display_contents_1_t *content_list); 95 96 static const uint32_t kTestLayerCnt = 1; 97 }; 98 99 } // namespace sdm 100 101 #endif // __HWC_DISPLAY_EXTERNAL_TEST_H__ 102 103