cam_compat.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _CAM_COMPAT_H_
  7. #define _CAM_COMPAT_H_
  8. #include <linux/version.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/component.h>
  11. #include <linux/iommu.h>
  12. #include <linux/qcom_scm.h>
  13. #include <linux/list_sort.h>
  14. #if KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE
  15. #include <linux/dma-iommu.h>
  16. #endif
  17. #include <soc/qcom/of_common.h>
  18. #include <linux/spi/spi.h>
  19. #include "cam_csiphy_dev.h"
  20. #include "cam_cpastop_hw.h"
  21. #include "cam_smmu_api.h"
  22. #if KERNEL_VERSION(6, 0, 0) <= LINUX_VERSION_CODE
  23. #include <smmu-proxy/linux/qti-smmu-proxy.h>
  24. #include <linux/qcom-dma-mapping.h>
  25. #endif
  26. #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0)
  27. #include <linux/ion.h>
  28. #include <linux/msm_ion.h>
  29. #define VFL_TYPE_VIDEO VFL_TYPE_GRABBER
  30. #endif
  31. #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) && \
  32. LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
  33. #include <soc/qcom/of_common.h>
  34. #include <linux/qcom-dma-mapping.h>
  35. #endif
  36. #if KERNEL_VERSION(5, 18, 0) <= LINUX_VERSION_CODE
  37. MODULE_IMPORT_NS(DMA_BUF);
  38. #endif
  39. #ifdef CONFIG_CSF_2_5_SECURE_CAMERA
  40. #include <linux/IClientEnv.h>
  41. #include <linux/ITrustedCameraDriver.h>
  42. #include <linux/CTrustedCameraDriver.h>
  43. #endif
  44. #define IS_CSF25(x, y) ((((x) == 2) && ((y) == 5)) ? 1 : 0)
  45. struct cam_fw_alloc_info {
  46. struct device *fw_dev;
  47. void *fw_kva;
  48. uint64_t fw_hdl;
  49. };
  50. int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length);
  51. void cam_unreserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length);
  52. void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa);
  53. int cam_update_camnoc_qos_settings(uint32_t use_case_id,
  54. uint32_t num_arg, struct qcom_scm_camera_qos *scm_buf);
  55. int cam_ife_notify_safe_lut_scm(bool safe_trigger);
  56. int camera_component_match_add_drivers(struct device *master_dev,
  57. struct component_match **match_list);
  58. int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
  59. bool protect, int32_t offset, bool is_shutdown);
  60. bool cam_is_mink_api_available(void);
  61. void cam_free_clear(const void *);
  62. void cam_check_iommu_faults(struct iommu_domain *domain,
  63. struct cam_smmu_pf_info *pf_info);
  64. static inline int cam_get_ddr_type(void) { return of_fdt_get_ddrtype(); }
  65. int cam_compat_util_get_dmabuf_va(struct dma_buf *dmabuf, uintptr_t *vaddr);
  66. void cam_compat_util_put_dmabuf_va(struct dma_buf *dmabuf, void *vaddr);
  67. void cam_smmu_util_iommu_custom(struct device *dev,
  68. dma_addr_t discard_start, size_t discard_length);
  69. const struct device *cam_cpas_get_rsc_dev_for_drv(uint32_t index);
  70. int cam_cpas_start_drv_for_dev(const struct device *dev);
  71. int cam_cpas_stop_drv_for_dev(const struct device *dev);
  72. int cam_cpas_drv_channel_switch_for_dev(const struct device *dev);
  73. #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)
  74. int cam_req_mgr_ordered_list_cmp(void *priv,
  75. const struct list_head *head_1, const struct list_head *head_2);
  76. void cam_i3c_driver_remove(struct i3c_device *client);
  77. #else
  78. int cam_req_mgr_ordered_list_cmp(void *priv,
  79. struct list_head *head_1, struct list_head *head_2);
  80. int cam_i3c_driver_remove(struct i3c_device *client);
  81. #endif
  82. long cam_dma_buf_set_name(struct dma_buf *dmabuf, const char *name);
  83. #if KERNEL_VERSION(5, 18, 0) <= LINUX_VERSION_CODE
  84. void cam_eeprom_spi_driver_remove(struct spi_device *sdev);
  85. #else
  86. int cam_eeprom_spi_driver_remove(struct spi_device *sdev);
  87. #endif
  88. int cam_compat_util_get_irq(struct cam_hw_soc_info *soc_info);
  89. bool cam_secure_get_vfe_fd_port_config(void);
  90. int cam_smmu_fetch_csf_version(struct cam_csf_version *csf_version);
  91. unsigned long cam_update_dma_map_attributes(unsigned long attr);
  92. size_t cam_align_dma_buf_size(size_t len);
  93. int cam_get_subpart_info(uint32_t *part_info, uint32_t max_num_cam);
  94. #endif /* _CAM_COMPAT_H_ */