sde_hdcp.h 3.1 KB

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