sde_hdcp.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012, 2014-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __SDE_HDCP_H__
  6. #define __SDE_HDCP_H__
  7. #include <linux/types.h>
  8. #include <linux/bitops.h>
  9. #include <linux/debugfs.h>
  10. #include <linux/of_device.h>
  11. #include <linux/i2c.h>
  12. #include <linux/list.h>
  13. #include <drm/drm_crtc.h>
  14. #include <drm/drm_edid.h>
  15. #include <linux/hdcp_qseecom.h>
  16. #include "sde_kms.h"
  17. #define MAX_STREAM_COUNT 2
  18. enum sde_hdcp_client_id {
  19. HDCP_CLIENT_HDMI,
  20. HDCP_CLIENT_DP,
  21. };
  22. enum sde_hdcp_state {
  23. HDCP_STATE_INACTIVE,
  24. HDCP_STATE_AUTHENTICATING,
  25. HDCP_STATE_AUTHENTICATED,
  26. HDCP_STATE_AUTH_FAIL,
  27. };
  28. enum sde_hdcp_version {
  29. HDCP_VERSION_NONE,
  30. HDCP_VERSION_1X = BIT(0),
  31. HDCP_VERSION_2P2 = BIT(1),
  32. HDCP_VERSION_MAX = BIT(2),
  33. };
  34. struct stream_info {
  35. u8 stream_id;
  36. u8 virtual_channel;
  37. };
  38. struct sde_hdcp_stream {
  39. struct list_head list;
  40. u8 stream_id;
  41. u8 virtual_channel;
  42. u32 stream_handle;
  43. bool active;
  44. };
  45. struct sde_hdcp_init_data {
  46. struct device *msm_hdcp_dev;
  47. struct dss_io_data *core_io;
  48. struct dss_io_data *dp_ahb;
  49. struct dss_io_data *dp_aux;
  50. struct dss_io_data *dp_link;
  51. struct dss_io_data *dp_p0;
  52. struct dss_io_data *qfprom_io;
  53. struct dss_io_data *hdcp_io;
  54. struct drm_dp_aux *drm_aux;
  55. struct mutex *mutex;
  56. struct workqueue_struct *workq;
  57. void *cb_data;
  58. void (*notify_status)(void *cb_data, enum sde_hdcp_state state);
  59. u8 sink_rx_status;
  60. unsigned char *revision;
  61. u32 phy_addr;
  62. bool sec_access;
  63. enum sde_hdcp_client_id client_id;
  64. };
  65. struct sde_hdcp_ops {
  66. int (*isr)(void *ptr);
  67. int (*cp_irq)(void *ptr);
  68. int (*reauthenticate)(void *input);
  69. int (*authenticate)(void *hdcp_ctrl);
  70. bool (*feature_supported)(void *input);
  71. void (*force_encryption)(void *input, bool enable);
  72. bool (*sink_support)(void *input);
  73. void (*abort)(void *input, bool abort);
  74. int (*set_mode)(void *input, bool mst_enabled);
  75. int (*on)(void *input);
  76. void (*off)(void *hdcp_ctrl);
  77. int (*register_streams)(void *input, u8 num_streams,
  78. struct stream_info *streams);
  79. int (*deregister_streams)(void *input, u8 num_streams,
  80. struct stream_info *streams);
  81. };
  82. static inline const char *sde_hdcp_state_name(enum sde_hdcp_state hdcp_state)
  83. {
  84. switch (hdcp_state) {
  85. case HDCP_STATE_INACTIVE: return "HDCP_STATE_INACTIVE";
  86. case HDCP_STATE_AUTHENTICATING: return "HDCP_STATE_AUTHENTICATING";
  87. case HDCP_STATE_AUTHENTICATED: return "HDCP_STATE_AUTHENTICATED";
  88. case HDCP_STATE_AUTH_FAIL: return "HDCP_STATE_AUTH_FAIL";
  89. default: return "???";
  90. }
  91. }
  92. static inline const char *sde_hdcp_version(enum sde_hdcp_version hdcp_version)
  93. {
  94. switch (hdcp_version) {
  95. case HDCP_VERSION_NONE: return "HDCP_VERSION_NONE";
  96. case HDCP_VERSION_1X: return "HDCP_VERSION_1X";
  97. case HDCP_VERSION_2P2: return "HDCP_VERSION_2P2";
  98. default: return "???";
  99. }
  100. }
  101. void *sde_hdcp_1x_init(struct sde_hdcp_init_data *init_data);
  102. void sde_hdcp_1x_deinit(void *input);
  103. struct sde_hdcp_ops *sde_hdcp_1x_get(void *input);
  104. void *sde_dp_hdcp2p2_init(struct sde_hdcp_init_data *init_data);
  105. void sde_dp_hdcp2p2_deinit(void *input);
  106. struct sde_hdcp_ops *sde_dp_hdcp2p2_get(void *input);
  107. #endif /* __SDE_HDCP_H__ */