hdcp_main.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __HDCP_MAIN_H__
  6. #define __HDCP_MAIN_H__
  7. #include <linux/cdev.h>
  8. #include <linux/completion.h>
  9. #include <linux/delay.h>
  10. #include <linux/device.h>
  11. #include <linux/errno.h>
  12. #include <linux/fs.h>
  13. #include <linux/hdcp_qseecom.h>
  14. #include <linux/io.h>
  15. #include <linux/kernel.h>
  16. #include <linux/kthread.h>
  17. #include <linux/list.h>
  18. #include <linux/module.h>
  19. #include <linux/mutex.h>
  20. #include <linux/sched.h>
  21. #include <linux/sched.h>
  22. #include <linux/slab.h>
  23. #include <linux/types.h>
  24. #include <linux/of.h>
  25. #include <linux/of_device.h>
  26. #include <misc/qseecom_kernel.h>
  27. #define HDCP2P2_APP_NAME "hdcp2p2"
  28. #define HDCP1_APP_NAME "hdcp1"
  29. #define HDCP1OPS_APP_NAME "ops"
  30. #define HDCPSRM_APP_NAME "hdcpsrm"
  31. #define QSEECOM_SBUFF_SIZE 0x1000
  32. #define MAX_REC_ID_LIST_SIZE 160
  33. #define MAX_TX_MESSAGE_SIZE 129
  34. #define MAX_RX_MESSAGE_SIZE 534
  35. #define MAX_TOPOLOGY_ELEMS 32
  36. #define HDCP1_NOTIFY_TOPOLOGY 1
  37. #define HDCP1_AKSV_SIZE 8
  38. #define HDCP_CLIENT_MAKE_VERSION(maj, min, patch) \
  39. ((((maj)&0xFF) << 16) | (((min)&0xFF) << 8) | ((patch)&0xFF))
  40. #define HCDP_TXMTR_GET_MAJOR_VERSION(v) (((v) >> 16) & 0xFF)
  41. #define HCDP_TXMTR_GET_MINOR_VERSION(v) (((v) >> 8) & 0xFF)
  42. #define HCDP_TXMTR_GET_PATCH_VERSION(v) ((v)&0xFF)
  43. #define HDCP_CLIENT_MAJOR_VERSION 2
  44. #define HDCP_CLIENT_MINOR_VERSION 1
  45. #define HDCP_CLIENT_PATCH_VERSION 0
  46. #define HDCP_SUCCESS 0
  47. /* Wait 200ms after authentication */
  48. #define SLEEP_FORCE_ENCRYPTION_MS 200
  49. /* Error code when Qseecomd is not up at boot time */
  50. #define QSEECOMD_ERROR -4103
  51. /* Wait for 100ms on every retry to check if Qseecomd is up */
  52. #define SLEEP_QSEECOMD_WAIT_MS 100
  53. #define SLEEP_SET_HW_KEY_MS 300
  54. /* flags set by tz in response message */
  55. #define HDCP_TXMTR_SUBSTATE_INIT 0
  56. #define HDCP_TXMTR_SUBSTATE_WAITING_FOR_RECIEVERID_LIST 1
  57. #define HDCP_TXMTR_SUBSTATE_PROCESSED_RECIEVERID_LIST 2
  58. #define HDCP_TXMTR_SUBSTATE_WAITING_FOR_STREAM_READY_MESSAGE 3
  59. #define HDCP_TXMTR_SUBSTATE_REPEATER_AUTH_COMPLETE 4
  60. enum hdcp_state {
  61. HDCP_STATE_INIT = 0x00,
  62. HDCP_STATE_APP_LOADED = 0x01,
  63. HDCP_STATE_SESSION_INIT = 0x02,
  64. HDCP_STATE_TXMTR_INIT = 0x04,
  65. HDCP_STATE_AUTHENTICATED = 0x08,
  66. HDCP_STATE_ERROR = 0x10
  67. };
  68. struct hdcp_ta_interface
  69. {
  70. void *(*trusted_app_hdcp1_init)(void);
  71. bool (*trusted_app_hdcp1_feature_supported)(void *data);
  72. int (*trusted_app_hdcp1_set_enc)(void *data,bool enable);
  73. int (*trusted_app_hdcp1_ops_notify)(void *data, void *topo,
  74. bool is_authenticated);
  75. int (*trusted_app_hdcp1_start)(void *data, u32 *aksv_msb,
  76. u32 *aksv_lsb);
  77. void (*trusted_app_hdcp1_stop)(void *data);
  78. void *(*trusted_app_hdcp2_init)(u32 device_type);
  79. void (*trusted_app_hdcp2_deinit)(void *ctx);
  80. int (*trusted_app_hdcp2_app_start)(void *ctx, uint32_t req_len);
  81. int (*trusted_app_hdcp2_app_start_auth)(void *ctx, uint32_t req_len);
  82. int (*trusted_app_hdcp2_app_process_msg)(void *ctx, uint32_t req_len);
  83. int (*trusted_app_hdcp2_app_timeout)(void *ctx, uint32_t req_len);
  84. int (*trusted_app_hdcp2_app_enable_encryption)(void *ctx, uint32_t req_len);
  85. int (*trusted_app_hdcp2_app_query_stream)(void *ctx, uint32_t req_len);
  86. int (*trusted_app_hdcp2_app_stop)(void *ctx);
  87. bool (*trusted_app_hdcp2_feature_supported)(void *ctx);
  88. int (*trusted_app_hdcp2_force_encryption)(void *ctx, uint32_t enable);
  89. int (*trusted_app_hdcp2_open_stream)(void *ctx, uint8_t vc_payload_id,
  90. uint8_t stream_number, uint32_t *stream_id);
  91. int (*trusted_app_hdcp2_close_stream)(void *ctx, uint32_t stream_id);
  92. int (*trusted_app_hdcp2_update_app_data)(void *ctx,
  93. struct hdcp2_app_data *app_data);
  94. };
  95. int hdcp1_validate_aksv(u32 aksv_msb, u32 aksv_lsb);
  96. #endif /* __HDCP_MAIN_H__ */