ITrustedCameraDriver.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #include "smcinvoke_object.h"
  6. /**
  7. * Struct containing values for programming of domain ID
  8. *
  9. * @version: Version info
  10. * @protect: To protect or reset the lanes
  11. * @csid_hw_idx_mask: Bit position denoting CSID in use
  12. * @cdm_hw_idx_mask: Bit position denoting CDM in use
  13. * @vc_mask: VC mask for identifying domain
  14. * @phy_lane_sel_mask: PHY lane info - contains CPHY, DPHY and PHY ID values
  15. * 0-15 bits -- PHY index
  16. * 16-23 bits -- CPHY lanes
  17. * 24-31 bits -- DPHY lanes
  18. * @reserved: Reserved bit
  19. */
  20. typedef struct {
  21. uint32_t version;
  22. uint32_t protect;
  23. uint32_t csid_hw_idx_mask;
  24. uint32_t cdm_hw_idx_mask;
  25. uint64_t vc_mask;
  26. uint64_t phy_lane_sel_mask;
  27. uint64_t reserved;
  28. } ITCDriverSensorInfo;
  29. #define ITrustedCameraDriver_ERROR_NOT_ALLOWED 10
  30. #define ITrustedCameraDriver_OP_dynamicProtectSensor 0
  31. #define ITrustedCameraDriver_OP_getVersion 1
  32. #define ITrustedCameraDriver_OP_dynamicConfigureFDPort 3
  33. static inline int32_t
  34. ITrustedCameraDriver_release(struct Object self)
  35. {
  36. return Object_invoke(self, Object_OP_release, 0, 0);
  37. }
  38. static inline int32_t
  39. ITrustedCameraDriver_retain(struct Object self)
  40. {
  41. return Object_invoke(self, Object_OP_retain, 0, 0);
  42. }
  43. /*
  44. * Description: This method allows protecting a camera sensor based on the sensor
  45. * information provided.
  46. *
  47. * In: this - ITrustedCameraDriver object
  48. * In: phy_info_ptr - Camera HW settings required for securing the usecase
  49. * Out: void
  50. * Return: Object_OK on success
  51. * secure camera error codes from seccam_def on failure
  52. */
  53. static inline int32_t
  54. ITrustedCameraDriver_dynamicProtectSensor(struct Object self,
  55. const ITCDriverSensorInfo *phy_info_ptr)
  56. {
  57. union ObjectArg a[1] = {{{0, 0}}};
  58. a[0].bi = (struct ObjectBufIn) { phy_info_ptr, sizeof(ITCDriverSensorInfo) };
  59. return Object_invoke(self, ITrustedCameraDriver_OP_dynamicProtectSensor, a,
  60. ObjectCounts_pack(1, 0, 0, 0));
  61. }
  62. /*
  63. * Description: Get the current version info
  64. *
  65. * In: this - ITrustedCameraDriver object
  66. * Out: arch_ver_ptr - the pointer of arch version number.
  67. * Out: max_ver_ptr - the pointer of the second part of the version number
  68. * Out: min_ver_ptr - the pointer of the third part of the version number
  69. * Return: Object_OK on success
  70. */
  71. static inline int32_t
  72. ITrustedCameraDriver_getVersion(struct Object self, uint32_t *arch_ver_ptr,
  73. uint32_t *max_ver_ptr, uint32_t *min_ver_ptr)
  74. {
  75. union ObjectArg a[1] = {{{0, 0}}};
  76. int32_t result;
  77. struct {
  78. uint32_t m_arch_ver;
  79. uint32_t m_max_ver;
  80. uint32_t m_min_ver;
  81. } o = {0};
  82. a[0].b = (struct ObjectBuf) { &o, 12 };
  83. result = Object_invoke(self, ITrustedCameraDriver_OP_getVersion, a,
  84. ObjectCounts_pack(0, 1, 0, 0));
  85. *arch_ver_ptr = o.m_arch_ver;
  86. *max_ver_ptr = o.m_max_ver;
  87. *min_ver_ptr = o.m_min_ver;
  88. return result;
  89. }
  90. /*
  91. * Description: Dynamic configuration to allow secure/non-secure FD port
  92. * on all the CSIDs
  93. *
  94. * In: this - ITrustedCameraDriver object
  95. * In: protect - to secure or non-secure the port
  96. * Out: void
  97. * Return: Object_OK on success
  98. * Object_ERROR on failure
  99. * ITrustedCameraDriver_ERROR_NOT_ALLOWED on request to
  100. * configure FD port even when disabled by OEM
  101. */
  102. static inline int32_t
  103. ITrustedCameraDriver_dynamicConfigureFDPort(struct Object self, uint32_t protect)
  104. {
  105. union ObjectArg a[1] = {{{0, 0}}};
  106. a[0].b = (struct ObjectBuf) { &protect, sizeof(uint32_t) };
  107. return Object_invoke(self, ITrustedCameraDriver_OP_dynamicConfigureFDPort, a,
  108. ObjectCounts_pack(1, 0, 0, 0));
  109. }