hdcp_main.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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/ion.h>
  16. #include <linux/kernel.h>
  17. #include <linux/kthread.h>
  18. #include <linux/list.h>
  19. #include <linux/module.h>
  20. #include <linux/mutex.h>
  21. #include <linux/sched.h>
  22. #include <linux/sched.h>
  23. #include <linux/slab.h>
  24. #include <linux/types.h>
  25. #include <linux/of.h>
  26. #include <linux/of_device.h>
  27. #include <misc/qseecom_kernel.h>
  28. #define HDCP2P2_APP_NAME "hdcp2p2"
  29. #define HDCP1_APP_NAME "hdcp1"
  30. #define HDCP1OPS_APP_NAME "ops"
  31. #define HDCPSRM_APP_NAME "hdcpsrm"
  32. #define QSEECOM_SBUFF_SIZE 0x1000
  33. #define MAX_REC_ID_LIST_SIZE 160
  34. #define MAX_TX_MESSAGE_SIZE 129
  35. #define MAX_RX_MESSAGE_SIZE 534
  36. #define MAX_TOPOLOGY_ELEMS 32
  37. #define HDCP1_NOTIFY_TOPOLOGY 1
  38. #define HDCP1_AKSV_SIZE 8
  39. #define HDCP_CLIENT_MAKE_VERSION(maj, min, patch) \
  40. ((((maj)&0xFF) << 16) | (((min)&0xFF) << 8) | ((patch)&0xFF))
  41. #define HCDP_TXMTR_GET_MAJOR_VERSION(v) (((v) >> 16) & 0xFF)
  42. #define HCDP_TXMTR_GET_MINOR_VERSION(v) (((v) >> 8) & 0xFF)
  43. #define HCDP_TXMTR_GET_PATCH_VERSION(v) ((v)&0xFF)
  44. #define HDCP_CLIENT_MAJOR_VERSION 2
  45. #define HDCP_CLIENT_MINOR_VERSION 1
  46. #define HDCP_CLIENT_PATCH_VERSION 0
  47. #define HDCP_SUCCESS 0
  48. /* Wait 200ms after authentication */
  49. #define SLEEP_FORCE_ENCRYPTION_MS 200
  50. #define SLEEP_SET_HW_KEY_MS 300
  51. /* flags set by tz in response message */
  52. #define HDCP_TXMTR_SUBSTATE_INIT 0
  53. #define HDCP_TXMTR_SUBSTATE_WAITING_FOR_RECIEVERID_LIST 1
  54. #define HDCP_TXMTR_SUBSTATE_PROCESSED_RECIEVERID_LIST 2
  55. #define HDCP_TXMTR_SUBSTATE_WAITING_FOR_STREAM_READY_MESSAGE 3
  56. #define HDCP_TXMTR_SUBSTATE_REPEATER_AUTH_COMPLETE 4
  57. enum hdcp_state {
  58. HDCP_STATE_INIT = 0x00,
  59. HDCP_STATE_APP_LOADED = 0x01,
  60. HDCP_STATE_SESSION_INIT = 0x02,
  61. HDCP_STATE_TXMTR_INIT = 0x04,
  62. HDCP_STATE_AUTHENTICATED = 0x08,
  63. HDCP_STATE_ERROR = 0x10
  64. };
  65. struct hdcp_ta_interface
  66. {
  67. void *(*trusted_app_hdcp1_init)(void);
  68. bool (*trusted_app_hdcp1_feature_supported)(void *data);
  69. int (*trusted_app_hdcp1_set_enc)(void *data,bool enable);
  70. int (*trusted_app_hdcp1_ops_notify)(void *data, void *topo,
  71. bool is_authenticated);
  72. int (*trusted_app_hdcp1_start)(void *data, u32 *aksv_msb,
  73. u32 *aksv_lsb);
  74. void (*trusted_app_hdcp1_stop)(void *data);
  75. void *(*trusted_app_hdcp2_init)(u32 device_type);
  76. void (*trusted_app_hdcp2_deinit)(void *ctx);
  77. int (*trusted_app_hdcp2_app_start)(void *ctx, uint32_t req_len);
  78. int (*trusted_app_hdcp2_app_start_auth)(void *ctx, uint32_t req_len);
  79. int (*trusted_app_hdcp2_app_process_msg)(void *ctx, uint32_t req_len);
  80. int (*trusted_app_hdcp2_app_timeout)(void *ctx, uint32_t req_len);
  81. int (*trusted_app_hdcp2_app_enable_encryption)(void *ctx, uint32_t req_len);
  82. int (*trusted_app_hdcp2_app_query_stream)(void *ctx, uint32_t req_len);
  83. int (*trusted_app_hdcp2_app_stop)(void *ctx);
  84. bool (*trusted_app_hdcp2_feature_supported)(void *ctx);
  85. int (*trusted_app_hdcp2_force_encryption)(void *ctx, uint32_t enable);
  86. int (*trusted_app_hdcp2_open_stream)(void *ctx, uint8_t vc_payload_id,
  87. uint8_t stream_number, uint32_t *stream_id);
  88. int (*trusted_app_hdcp2_close_stream)(void *ctx, uint32_t stream_id);
  89. int (*trusted_app_hdcp2_update_app_data)(void *ctx,
  90. struct hdcp2_app_data *app_data);
  91. };
  92. int hdcp1_validate_aksv(u32 aksv_msb, u32 aksv_lsb);
  93. #endif /* __HDCP_MAIN_H__ */