# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build/ohos.gni")

group("display_group") {
  deps = [
    ":def_display_device",
    ":def_display_gralloc",
  ]
}

ohos_shared_library("def_display_gralloc") {
  sources = [
    "src/display_gralloc/allocator.cpp",
    "src/display_gralloc/allocator_manager.cpp",
    "src/display_gralloc/display_gralloc.cpp",
    "src/display_gralloc/dmabufferheap_allocator.cpp",
    "src/display_gralloc/drm_allocator.cpp",
    "src/display_gralloc/framebuffer_allocator.cpp",
    "src/utils/display_adapter.cpp",
  ]
  include_dirs = [
    "include",
    "../../interfaces/include",
    "src/utils/",
  ]

  output_name = "display_gralloc"
  cflags = [ "-Wno-macro-redefined" ]
  deps = [ "//third_party/libdrm:libdrm" ]

  external_deps = [
    "c_utils:utils",
    "hdf_core:libhdf_utils",
    "hilog:libhilog",
    "memory_utils:libdmabufheap",
  ]

  install_enable = true
  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "drivers_peripheral_display"
}

config("def_display_device_pub_config") {
  visibility = [ ":*" ]

  include_dirs = [
    "//drivers/peripheral/display/interfaces/include",
    "./src/display_device",
    "./include",
  ]
}

ohos_shared_library("def_display_device") {
  sources = [
    "src/display_device/composer/hdi_composer.cpp",
    "src/display_device/composer/hdi_gfx_composition.cpp",
    "src/display_device/composer/hdi_video_composition.cpp",
    "src/display_device/core/hdi_device_interface.cpp",
    "src/display_device/core/hdi_display.cpp",
    "src/display_device/core/hdi_layer.cpp",
    "src/display_device/core/hdi_session.cpp",
    "src/display_device/drm/drm_connector.cpp",
    "src/display_device/drm/drm_crtc.cpp",
    "src/display_device/drm/drm_device.cpp",
    "src/display_device/drm/drm_display.cpp",
    "src/display_device/drm/drm_encoder.cpp",
    "src/display_device/drm/drm_plane.cpp",
    "src/display_device/drm/drm_vsync_worker.cpp",
    "src/display_device/drm/hdi_drm_composition.cpp",
    "src/display_device/drm/hdi_drm_layer.cpp",
    "src/display_device/fbdev/fb_composition.cpp",
    "src/display_device/fbdev/fb_device.cpp",
    "src/display_device/fbdev/fb_display.cpp",
    "src/display_device/vsync/sorft_vsync.cpp",
    "src/utils/display_adapter.cpp",
  ]
  public_configs = [ ":def_display_device_pub_config" ]

  output_name = "display_device"

  include_dirs = [
    "src/display_device",
    "include",
    "../../interfaces/include",
    "src/display_device/drm",
    "src/display_device/fbdev",
    "src/display_device/core",
    "src/display_device/composer",
    "src/utils",
  ]

  deps = [
    ":def_display_layer_video",
    "../:hdi_display_gralloc",
    "//third_party/libdrm:libdrm",
  ]

  cflags = [ "-Wno-unused-function" ]

  external_deps = [
    "c_utils:utils",
    "hdf_core:libhdf_utils",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
  ]

  symlink_target_name = [ "libdisplay_layer.z.so" ]

  install_enable = true
  install_images = [ system_base_dir ]
  relative_install_dir = "chipset-sdk"
  subsystem_name = "hdf"
  part_name = "drivers_peripheral_display"
}

ohos_shared_library("def_display_layer_video") {
  sources = [ "src/display_layer_video/display_layer_video.cpp" ]
  public_configs = [ ":def_display_device_pub_config" ]

  output_name = "display_layer_video"
  include_dirs = [
    "../../interfaces/include",
    "../../hdi_service/video_layer/client",
  ]

  external_deps = [
    "c_utils:utils",
    "hdf_core:libhdf_host",
    "hdf_core:libhdf_ipc_adapter",
    "hdf_core:libhdf_utils",
    "hdf_core:libhdi",
    "hilog:libhilog",
    "ipc:ipc_single",
  ]

  public_deps = [ "../../hdi_service/video_layer/client:video_layer_client" ]

  install_enable = true
  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "drivers_peripheral_display"
}