hdcp_main.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #define SLEEP_SET_HW_KEY_MS 300
  50. /* flags set by tz in response message */
  51. #define HDCP_TXMTR_SUBSTATE_INIT 0
  52. #define HDCP_TXMTR_SUBSTATE_WAITING_FOR_RECIEVERID_LIST 1
  53. #define HDCP_TXMTR_SUBSTATE_PROCESSED_RECIEVERID_LIST 2
  54. #define HDCP_TXMTR_SUBSTATE_WAITING_FOR_STREAM_READY_MESSAGE 3
  55. #define HDCP_TXMTR_SUBSTATE_REPEATER_AUTH_COMPLETE 4
  56. enum hdcp_state {
  57. HDCP_STATE_INIT = 0x00,
  58. HDCP_STATE_APP_LOADED = 0x01,
  59. HDCP_STATE_SESSION_INIT = 0x02,
  60. HDCP_STATE_TXMTR_INIT = 0x04,
  61. HDCP_STATE_AUTHENTICATED = 0x08,
  62. HDCP_STATE_ERROR = 0x10
  63. };
  64. struct hdcp_ta_interface
  65. {
  66. void *(*trusted_app_hdcp1_init)(void);
  67. bool (*trusted_app_hdcp1_feature_supported)(void *data);
  68. int (*trusted_app_hdcp1_set_enc)(void *data,bool enable);
  69. int (*trusted_app_hdcp1_ops_notify)(void *data, void *topo,
  70. bool is_authenticated);
  71. int (*trusted_app_hdcp1_start)(void *data, u32 *aksv_msb,
  72. u32 *aksv_lsb);
  73. void (*trusted_app_hdcp1_stop)(void *data);
  74. void *(*trusted_app_hdcp2_init)(u32 device_type);
  75. void (*trusted_app_hdcp2_deinit)(void *ctx);
  76. int (*trusted_app_hdcp2_app_start)(void *ctx, uint32_t req_len);
  77. int (*trusted_app_hdcp2_app_start_auth)(void *ctx, uint32_t req_len);
  78. int (*trusted_app_hdcp2_app_process_msg)(void *ctx, uint32_t req_len);
  79. int (*trusted_app_hdcp2_app_timeout)(void *ctx, uint32_t req_len);
  80. int (*trusted_app_hdcp2_app_enable_encryption)(void *ctx, uint32_t req_len);
  81. int (*trusted_app_hdcp2_app_query_stream)(void *ctx, uint32_t req_len);
  82. int (*trusted_app_hdcp2_app_stop)(void *ctx);
  83. bool (*trusted_app_hdcp2_feature_supported)(void *ctx);
  84. int (*trusted_app_hdcp2_force_encryption)(void *ctx, uint32_t enable);
  85. int (*trusted_app_hdcp2_open_stream)(void *ctx, uint8_t vc_payload_id,
  86. uint8_t stream_number, uint32_t *stream_id);
  87. int (*trusted_app_hdcp2_close_stream)(void *ctx, uint32_t stream_id);
  88. int (*trusted_app_hdcp2_update_app_data)(void *ctx,
  89. struct hdcp2_app_data *app_data);
  90. };
  91. int hdcp1_validate_aksv(u32 aksv_msb, u32 aksv_lsb);
  92. #endif /* __HDCP_MAIN_H__ */