hdcp_qseecom.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __HDCP_QSEECOM_H
  6. #define __HDCP_QSEECOM_H
  7. #include <linux/types.h>
  8. #define HDCP_QSEECOM_ENUM_STR(x) #x
  9. enum hdcp2_app_cmd {
  10. HDCP2_CMD_START,
  11. HDCP2_CMD_START_AUTH,
  12. HDCP2_CMD_STOP,
  13. HDCP2_CMD_PROCESS_MSG,
  14. HDCP2_CMD_TIMEOUT,
  15. HDCP2_CMD_EN_ENCRYPTION,
  16. HDCP2_CMD_QUERY_STREAM,
  17. };
  18. struct hdcp2_buffer {
  19. unsigned char *data;
  20. u32 length;
  21. };
  22. struct hdcp2_app_data {
  23. u32 timeout;
  24. bool repeater_flag;
  25. struct hdcp2_buffer request; // requests to TA, sent from sink
  26. struct hdcp2_buffer response; // responses from TA, sent to sink
  27. };
  28. struct hdcp1_topology {
  29. uint32_t depth;
  30. uint32_t device_count;
  31. uint32_t max_devices_exceeded;
  32. uint32_t max_cascade_exceeded;
  33. uint32_t hdcp2LegacyDeviceDownstream;
  34. uint32_t hdcp1DeviceDownstream;
  35. };
  36. static inline const char *hdcp2_app_cmd_str(enum hdcp2_app_cmd cmd)
  37. {
  38. switch (cmd) {
  39. case HDCP2_CMD_START:
  40. return HDCP_QSEECOM_ENUM_STR(HDCP2_CMD_START);
  41. case HDCP2_CMD_START_AUTH:
  42. return HDCP_QSEECOM_ENUM_STR(HDCP2_CMD_START_AUTH);
  43. case HDCP2_CMD_STOP:
  44. return HDCP_QSEECOM_ENUM_STR(HDCP2_CMD_STOP);
  45. case HDCP2_CMD_PROCESS_MSG:
  46. return HDCP_QSEECOM_ENUM_STR(HDCP2_CMD_PROCESS_MSG);
  47. case HDCP2_CMD_TIMEOUT:
  48. return HDCP_QSEECOM_ENUM_STR(HDCP2_CMD_TIMEOUT);
  49. case HDCP2_CMD_EN_ENCRYPTION:
  50. return HDCP_QSEECOM_ENUM_STR(HDCP2_CMD_EN_ENCRYPTION);
  51. case HDCP2_CMD_QUERY_STREAM:
  52. return HDCP_QSEECOM_ENUM_STR(HDCP2_CMD_QUERY_STREAM);
  53. default: return "???";
  54. }
  55. }
  56. #if IS_ENABLED(CONFIG_HDCP_QSEECOM)
  57. void *hdcp1_init(void);
  58. void hdcp1_deinit(void *data);
  59. bool hdcp1_feature_supported(void *data);
  60. int hdcp1_start(void *data, u32 *aksv_msb, u32 *aksv_lsb);
  61. int hdcp1_set_enc(void *data, bool enable);
  62. int hdcp1_ops_notify(void *data, void *topology, bool is_authenticated);
  63. void hdcp1_stop(void *data);
  64. void *hdcp2_init(u32 device_type);
  65. void hdcp2_deinit(void *ctx);
  66. bool hdcp2_feature_supported(void *ctx);
  67. int hdcp2_app_comm(void *ctx, enum hdcp2_app_cmd cmd,
  68. struct hdcp2_app_data *app_data);
  69. int hdcp2_open_stream(void *ctx, uint8_t vc_payload_id,
  70. uint8_t stream_number, uint32_t *stream_id);
  71. int hdcp2_close_stream(void *ctx, uint32_t stream_id);
  72. int hdcp2_force_encryption(void *ctx, uint32_t enable);
  73. void hdcp1_set_hdcp_key_verify_retries(void *ctx, u32 max_hdcp_key_verify_retries);
  74. void hdcp2_set_hdcp_key_verify_retries(void *ctx, u32 max_hdcp_key_verify_retries);
  75. #else
  76. static inline void *hdcp1_init(void)
  77. {
  78. return NULL;
  79. }
  80. static inline void hdcp1_deinit(void *data)
  81. {
  82. }
  83. static inline bool hdcp1_feature_supported(void *data)
  84. {
  85. return false;
  86. }
  87. static inline int hdcp1_start(void *data, u32 *aksv_msb, u32 *aksv_lsb)
  88. {
  89. return 0;
  90. }
  91. static inline int hdcp1_ops_notify(void *data, void *topology, bool is_authenticated)
  92. {
  93. return 0;
  94. }
  95. static inline int hdcp1_set_enc(void *data, bool enable)
  96. {
  97. return 0;
  98. }
  99. static inline void hdcp1_stop(void *data)
  100. {
  101. }
  102. static inline void *hdcp2_init(u32 device_type)
  103. {
  104. return NULL;
  105. }
  106. static inline void hdcp2_deinit(void *ctx)
  107. {
  108. }
  109. static inline bool hdcp2_feature_supported(void *ctx)
  110. {
  111. return false;
  112. }
  113. static inline int hdcp2_app_comm(void *ctx, enum hdcp2_app_cmd cmd,
  114. struct hdcp2_app_data *app_data)
  115. {
  116. return 0;
  117. }
  118. static inline int hdcp2_open_stream(void *ctx, uint8_t vc_payload_id,
  119. uint8_t stream_number, uint32_t *stream_id)
  120. {
  121. return 0;
  122. }
  123. static inline int hdcp2_close_stream(void *ctx, uint32_t stream_id)
  124. {
  125. return 0;
  126. }
  127. static inline int hdcp2_force_encryption(void *ctx, uint32_t enable)
  128. {
  129. return 0;
  130. }
  131. static inline void hdcp1_set_hdcp_key_verify_retries(void *ctx, u32 max_hdcp_key_verify_retries)
  132. {
  133. }
  134. static inline void hdcp2_set_hdcp_key_verify_retries(void *ctx, u32 max_hdcp_key_verify_retries)
  135. {
  136. }
  137. #endif /* CONFIG_HDCP_QSEECOM */
  138. #endif /* __HDCP_QSEECOM_H */