dp_panel.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DP_PANEL_H_
  6. #define _DP_PANEL_H_
  7. #include <drm/msm_drm.h>
  8. #include "dp_aux.h"
  9. #include "dp_link.h"
  10. struct edid;
  11. struct dp_display_mode {
  12. struct drm_display_mode drm_mode;
  13. u32 bpp;
  14. u32 h_active_low;
  15. u32 v_active_low;
  16. bool out_fmt_is_yuv_420;
  17. };
  18. struct dp_panel_in {
  19. struct device *dev;
  20. struct drm_dp_aux *aux;
  21. struct dp_link *link;
  22. struct dp_catalog *catalog;
  23. };
  24. struct dp_panel_psr {
  25. u8 version;
  26. u8 capabilities;
  27. };
  28. struct dp_panel {
  29. /* dpcd raw data */
  30. u8 dpcd[DP_RECEIVER_CAP_SIZE];
  31. u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  32. struct dp_link_info link_info;
  33. const struct drm_edid *drm_edid;
  34. struct drm_connector *connector;
  35. struct dp_display_mode dp_mode;
  36. struct dp_panel_psr psr_cap;
  37. bool video_test;
  38. bool vsc_sdp_supported;
  39. u32 max_dp_lanes;
  40. u32 max_dp_link_rate;
  41. u32 max_bw_code;
  42. };
  43. int dp_panel_init_panel_info(struct dp_panel *dp_panel);
  44. int dp_panel_deinit(struct dp_panel *dp_panel);
  45. int dp_panel_timing_cfg(struct dp_panel *dp_panel);
  46. void dp_panel_dump_regs(struct dp_panel *dp_panel);
  47. int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
  48. struct drm_connector *connector);
  49. u32 dp_panel_get_mode_bpp(struct dp_panel *dp_panel, u32 mode_max_bpp,
  50. u32 mode_pclk_khz);
  51. int dp_panel_get_modes(struct dp_panel *dp_panel,
  52. struct drm_connector *connector);
  53. void dp_panel_handle_sink_request(struct dp_panel *dp_panel);
  54. void dp_panel_tpg_config(struct dp_panel *dp_panel, bool enable);
  55. /**
  56. * is_link_rate_valid() - validates the link rate
  57. * @lane_rate: link rate requested by the sink
  58. *
  59. * Returns true if the requested link rate is supported.
  60. */
  61. static inline bool is_link_rate_valid(u32 bw_code)
  62. {
  63. return (bw_code == DP_LINK_BW_1_62 ||
  64. bw_code == DP_LINK_BW_2_7 ||
  65. bw_code == DP_LINK_BW_5_4 ||
  66. bw_code == DP_LINK_BW_8_1);
  67. }
  68. /**
  69. * dp_link_is_lane_count_valid() - validates the lane count
  70. * @lane_count: lane count requested by the sink
  71. *
  72. * Returns true if the requested lane count is supported.
  73. */
  74. static inline bool is_lane_count_valid(u32 lane_count)
  75. {
  76. return (lane_count == 1 ||
  77. lane_count == 2 ||
  78. lane_count == 4);
  79. }
  80. struct dp_panel *dp_panel_get(struct dp_panel_in *in);
  81. void dp_panel_put(struct dp_panel *dp_panel);
  82. #endif /* _DP_PANEL_H_ */