/*
 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
 * Copyright (c) 2011-2021, The Linux Foundation. All rights reserved.

 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of The Linux Foundation nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __GR_ADRENO_INFO_H__
#define __GR_ADRENO_INFO_H__

#include <display/media/mmm_color_fmt.h>

#include "gr_utils.h"

typedef enum {
  SURFACE_TILE_MODE_DISABLE    = 0x0,    // used for linear surface
  SURFACE_TILE_MODE_ENABLE     = 0x1     // used for tiled surface
} surface_tile_mode_t;

typedef enum {
  SURFACE_RASTER_MODE_UNKNOWN = 0x0,      // used when we don't know the raster mode to be used
  SURFACE_RASTER_MODE_TW      = 0x1,      // raster_mode = TypeWriter (TW)
  SURFACE_RASTER_MODE_CB      = 0x2,      // raster_mode = CheckerBoard (CB)
} surface_rastermode_t;

// Adreno Pixel Formats
typedef enum {
  ADRENO_PIXELFORMAT_UNKNOWN = 0,
  ADRENO_PIXELFORMAT_R16G16B16A16_FLOAT = 10,
  ADRENO_PIXELFORMAT_R10G10B10A2_UNORM = 24,  // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES
  ADRENO_PIXELFORMAT_R8G8B8A8 = 28,
  ADRENO_PIXELFORMAT_R8G8B8A8_SRGB = 29,
  ADRENO_PIXELFORMAT_D32_FLOAT = 40,
  ADRENO_PIXELFORMAT_D24_UNORM_S8_UINT = 45,
  ADRENO_PIXELFORMAT_R8G8_UNORM = 49,
  ADRENO_PIXELFORMAT_D16_UNORM = 55,
  ADRENO_PIXELFORMAT_R8_UNORM = 61,
  ADRENO_PIXELFORMAT_B5G6R5 = 85,
  ADRENO_PIXELFORMAT_B5G5R5A1 = 86,
  ADRENO_PIXELFORMAT_B8G8R8A8_UNORM = 87,
  ADRENO_PIXELFORMAT_B8G8R8A8 = 90,
  ADRENO_PIXELFORMAT_B8G8R8A8_SRGB = 91,
  ADRENO_PIXELFORMAT_B8G8R8X8_SRGB = 93,
  ADRENO_PIXELFORMAT_NV12 = 103,
  ADRENO_PIXELFORMAT_P010 = 104,
  ADRENO_PIXELFORMAT_YUY2 = 107,
  ADRENO_PIXELFORMAT_B4G4R4A4 = 115,
  ADRENO_PIXELFORMAT_NV12_EXT = 506,       // NV12 with non-std alignment and offsets
  ADRENO_PIXELFORMAT_R8G8B8X8 = 507,       //  GL_RGB8 (Internal)
  ADRENO_PIXELFORMAT_R8G8B8 = 508,         //  GL_RGB8
  ADRENO_PIXELFORMAT_A1B5G5R5 = 519,       //  GL_RGB5_A1
  ADRENO_PIXELFORMAT_R8G8B8X8_SRGB = 520,  //  GL_SRGB8
  ADRENO_PIXELFORMAT_R8G8B8_SRGB = 521,    //  GL_SRGB8
  ADRENO_PIXELFORMAT_A2B10G10R10_UNORM = 532,
  // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES
  ADRENO_PIXELFORMAT_R10G10B10X2_UNORM = 537,
  ADRENO_PIXELFORMAT_D24_UNORM_X8_UINT = 548,
  ADRENO_PIXELFORMAT_D24_UNORM = 549,
  ADRENO_PIXELFORMAT_D32_FLOAT_X24S8_UINT = 551,
  ADRENO_PIXELFORMAT_S8_UINT = 552,
  ADRENO_PIXELFORMAT_ASTC_4X4 = 568,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_5X4 = 569,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_5X5 = 570,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_6X5 = 571,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_6X6 = 572,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_8X5 = 573,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_8X6 = 574,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_8X8 = 575,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_10X5 = 576,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_10X6 = 577,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_10X8 = 578,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_10X10 = 579,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_12X10 = 580,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_12X12 = 581,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_4X4_SRGB = 582,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_5X4_SRGB = 583,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_5X5_SRGB = 584,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_6X5_SRGB = 585,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_6X6_SRGB = 586,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_8X5_SRGB = 587,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_8X6_SRGB = 588,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_8X8_SRGB = 589,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_10X5_SRGB = 590,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_10X6_SRGB = 591,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_10X8_SRGB = 592,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_10X10_SRGB = 593,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_12X10_SRGB = 594,  // ASTC Compressed
  ADRENO_PIXELFORMAT_ASTC_12X12_SRGB = 595,  // ASTC Compressed
  // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES
  ADRENO_PIXELFORMAT_R5G6B5 = 610,    //  RGBA version of B5G6R5
  ADRENO_PIXELFORMAT_R5G5B5A1 = 611,  //  RGBA version of B5G5R5A1
  ADRENO_PIXELFORMAT_R4G4B4A4 = 612,  //  RGBA version of B4G4R4A4
  ADRENO_PIXELFORMAT_UYVY = 614,      //  YUV 4:2:2 packed progressive (1 plane)
  ADRENO_PIXELFORMAT_NV21 = 619,
  ADRENO_PIXELFORMAT_Y8U8V8A8 = 620,  // YUV 4:4:4 packed (1 plane)
  ADRENO_PIXELFORMAT_Y8 = 625,        //  Single 8-bit luma only channel YUV format
  ADRENO_PIXELFORMAT_TP10 = 654,      // YUV 4:2:0 planar 10 bits/comp (2 planes)
} ADRENOPIXELFORMAT;



namespace gralloc {

class AdrenoMemInfo {
 public:
  /*
   * Function to compute aligned width and aligned height based on
   * width, height, format and usage flags.
   *
   * @return aligned width, aligned height
   */
  void GetAlignedWidthAndHeight(int width, int height, int format, int usage,
                                unsigned int *aligned_w, unsigned int *aligned_h, bool ubwc_enabled,
                                bool tile_enabled);

  /*
   * Function to compute the adreno aligned width and aligned height
   * based on the width and format.
   *
   * @return aligned width, aligned height
   */
  void AlignUnCompressedRGB(int width, int height, int format, int tileEnabled,
                            unsigned int *aligned_w, unsigned int *aligned_h);

  /*
   * Function to compute the adreno aligned width and aligned height
   * based on the width and format.
   *
   * @return aligned width, aligned height
   */
  void AlignCompressedRGB(int width, int height, int format, unsigned int *aligned_w,
                          unsigned int *aligned_h);

  /*
   * Function to compute the adreno aligned width and aligned height
   * based on the width and format.
   *
   * @return aligned width, aligned height
   */
  void AlignGpuDepthStencilFormat(int width, int height, int format, int tile_enabled,
                                  unsigned int *aligned_w, unsigned int *aligned_h);

  /*
   * Function to compute the pixel alignment requirement.
   *
   * @return alignment
   */
  uint32_t GetGpuPixelAlignment();

  /*
   * Function to query whether GPU supports UBWC for given HAL format
   * @return > 0 : supported
   *           0 : not supported
   */
  bool IsUBWCSupportedByGPU(int format);

  /*
  * Function to check if GPU supports PI or not
  */
  bool IsPISupportedByGPU(int format, uint64_t usage);
  /*
   * Function to get the corresponding Adreno format for given HAL format
   */
  ADRENOPIXELFORMAT GetGpuPixelFormat(int hal_format);

  /*
   * Function to get graphics metadata blob size
   * @return graphics metadata size
   */
  uint32_t AdrenoGetMetadataBlobSize();

  /*
   * Function to populate the graphics metadata blob
   * @return 1 : Successful
   *         2 : Unsuccessful
   */
  int AdrenoInitMemoryLayout(void *metadata_blob, int width, int height, int depth, int format,
                             int num_samples, int isUBWC, uint64_t usage, uint32_t num_planes);
  /*
   * Function to get buffer size for based on graphcis metadata
   * @return buffer size
   */
  uint32_t AdrenoGetAlignedGpuBufferSize(void *metadata_blob);

  /*
   * Function to check if adreno size calculation APIs are avaliable
   * @return true  : Avaliable
   *         false : Unavaliable
  */
  bool AdrenoSizeAPIAvaliable();

  void AdrenoSetProperties(gralloc::GrallocProperties props);

  static AdrenoMemInfo *GetInstance();

 private:
  AdrenoMemInfo();
  ~AdrenoMemInfo();
  // link(s)to adreno surface padding library.
  int (*LINK_adreno_compute_padding)(int width, int bpp, int surface_tile_height,
                                     surface_rastermode_t raster_mode,
                                     int padding_threshold) = NULL;
  void (*LINK_adreno_compute_aligned_width_and_height)(int width, int height, int bpp,
                                                       surface_tile_mode_t tile_mode,
                                                       surface_rastermode_t raster_mode,
                                                       int padding_threshold, int *aligned_w,
                                                       int *aligned_h) = NULL;
  void (*LINK_adreno_compute_fmt_aligned_width_and_height)(int width, int height, int plane_id,
                                                           ADRENOPIXELFORMAT format,
                                                           uint32_t num_samples,
                                                           surface_tile_mode_t tile_mode,
                                                           surface_rastermode_t raster_mode,
                                                           int padding_threshold, int *aligned_w,
                                                           int *aligned_h) = NULL;
  void (*LINK_adreno_compute_compressedfmt_aligned_width_and_height)(
      int width, int height, int format, surface_tile_mode_t tile_mode,
      surface_rastermode_t raster_mode, int padding_threshold,
      int *aligned_w, int *aligned_h, int *bpp) = NULL;
  int (*LINK_adreno_isUBWCSupportedByGpu)(ADRENOPIXELFORMAT format) = NULL;
  unsigned int (*LINK_adreno_get_gpu_pixel_alignment)(void) = NULL;

  uint32_t (*LINK_adreno_get_metadata_blob_size)(void) = NULL;
  int (*LINK_adreno_init_memory_layout)(void* metadata_blob, int width, int height, int depth,
       ADRENOPIXELFORMAT format, uint32_t num_samples, surface_tile_mode_t tile_mode,
       uint64_t usage, uint32_t num_planes) = NULL;
  uint64_t (*LINK_adreno_get_aligned_gpu_buffer_size)(void* metadata_blob) = NULL;
  int (*LINK_adreno_isPISupportedByGpu)(int format, uint64_t usage) = NULL;

  bool gfx_ubwc_disable_ = false;
  bool gfx_ahardware_buffer_disable_ = false;
  void *libadreno_utils_ = NULL;

  static AdrenoMemInfo *s_instance;
};

}  // namespace gralloc

#endif  // __GR_ADRENO_INFO_H__
