1 /* 2 * Copyright (c) 2016, 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 __HW_SCALE_H__ 26 #define __HW_SCALE_H__ 27 28 #include <linux/msm_mdp_ext.h> 29 #include <private/hw_info_types.h> 30 31 #include <cstring> 32 #include <array> 33 #include <map> 34 35 namespace sdm { 36 37 class HWScale { 38 public: 39 static DisplayError Create(HWScale **intf, bool has_qseed3); 40 static DisplayError Destroy(HWScale *intf); 41 42 virtual void SetHWScaleData(const HWScaleData &scale, uint32_t index, 43 mdp_layer_commit_v1 *mdp_commit, HWSubBlockType sub_block_type) = 0; 44 virtual void* GetScaleDataRef(uint32_t index, HWSubBlockType sub_block_type) = 0; 45 virtual void DumpScaleData(void *mdp_scale) = 0; 46 virtual void ResetScaleParams() = 0; 47 protected: ~HWScale()48 virtual ~HWScale() { } 49 }; 50 51 class HWScaleV1 : public HWScale { 52 public: 53 virtual void SetHWScaleData(const HWScaleData &scale, uint32_t index, 54 mdp_layer_commit_v1 *mdp_commit, HWSubBlockType sub_block_type); 55 virtual void* GetScaleDataRef(uint32_t index, HWSubBlockType sub_block_type); 56 virtual void DumpScaleData(void *mdp_scale); ResetScaleParams()57 virtual void ResetScaleParams() { scale_data_v1_ = {}; } 58 59 protected: ~HWScaleV1()60 ~HWScaleV1() {} 61 std::array<mdp_scale_data, (kMaxSDELayers * 2)> scale_data_v1_ = {}; 62 }; 63 64 class HWScaleV2 : public HWScale { 65 public: 66 virtual void SetHWScaleData(const HWScaleData &scale, uint32_t index, 67 mdp_layer_commit_v1 *mdp_commit, HWSubBlockType sub_block_type); 68 virtual void* GetScaleDataRef(uint32_t index, HWSubBlockType sub_block_type); 69 virtual void DumpScaleData(void *mdp_scale); ResetScaleParams()70 virtual void ResetScaleParams() { scale_data_v2_ = {}; dest_scale_data_v2_ = {}; } 71 72 protected: ~HWScaleV2()73 ~HWScaleV2() {} 74 std::array<mdp_scale_data_v2, (kMaxSDELayers * 2)> scale_data_v2_ = {}; 75 std::map<uint32_t, mdp_scale_data_v2> dest_scale_data_v2_ = {}; 76 77 private: 78 uint32_t GetMDPAlphaInterpolation(HWAlphaInterpolation alpha_filter_cfg); 79 uint32_t GetMDPScalingFilter(ScalingFilterConfig filter_cfg); 80 }; 81 82 } // namespace sdm 83 84 #endif // __HW_SCALE_H__ 85 86