dsi.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright (c) 2015, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __DSI_CONNECTOR_H__
  14. #define __DSI_CONNECTOR_H__
  15. #include <linux/platform_device.h>
  16. #include "drm_crtc.h"
  17. #include "drm_mipi_dsi.h"
  18. #include "drm_panel.h"
  19. #include "msm_drv.h"
  20. #define DSI_0 0
  21. #define DSI_1 1
  22. #define DSI_MAX 2
  23. #define DSI_CLOCK_MASTER DSI_0
  24. #define DSI_CLOCK_SLAVE DSI_1
  25. #define DSI_LEFT DSI_0
  26. #define DSI_RIGHT DSI_1
  27. /* According to the current drm framework sequence, take the encoder of
  28. * DSI_1 as master encoder
  29. */
  30. #define DSI_ENCODER_MASTER DSI_1
  31. #define DSI_ENCODER_SLAVE DSI_0
  32. struct msm_dsi {
  33. struct drm_device *dev;
  34. struct platform_device *pdev;
  35. struct drm_connector *connector;
  36. struct drm_bridge *bridge;
  37. struct mipi_dsi_host *host;
  38. struct msm_dsi_phy *phy;
  39. struct drm_panel *panel;
  40. unsigned long panel_flags;
  41. bool phy_enabled;
  42. /* the encoders we are hooked to (outside of dsi block) */
  43. struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM];
  44. int id;
  45. };
  46. /* dsi manager */
  47. struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
  48. void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
  49. struct drm_connector *msm_dsi_manager_connector_init(u8 id);
  50. int msm_dsi_manager_phy_enable(int id,
  51. const unsigned long bit_rate, const unsigned long esc_rate,
  52. u32 *clk_pre, u32 *clk_post);
  53. void msm_dsi_manager_phy_disable(int id);
  54. int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
  55. bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 iova, u32 len);
  56. int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
  57. void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
  58. /* msm dsi */
  59. struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
  60. /* dsi host */
  61. int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
  62. const struct mipi_dsi_msg *msg);
  63. void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
  64. const struct mipi_dsi_msg *msg);
  65. int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
  66. const struct mipi_dsi_msg *msg);
  67. int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
  68. const struct mipi_dsi_msg *msg);
  69. void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
  70. u32 iova, u32 len);
  71. int msm_dsi_host_enable(struct mipi_dsi_host *host);
  72. int msm_dsi_host_disable(struct mipi_dsi_host *host);
  73. int msm_dsi_host_power_on(struct mipi_dsi_host *host);
  74. int msm_dsi_host_power_off(struct mipi_dsi_host *host);
  75. int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
  76. struct drm_display_mode *mode);
  77. struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
  78. unsigned long *panel_flags);
  79. int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
  80. void msm_dsi_host_unregister(struct mipi_dsi_host *host);
  81. void msm_dsi_host_destroy(struct mipi_dsi_host *host);
  82. int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
  83. struct drm_device *dev);
  84. int msm_dsi_host_init(struct msm_dsi *msm_dsi);
  85. /* dsi phy */
  86. struct msm_dsi_phy;
  87. enum msm_dsi_phy_type {
  88. MSM_DSI_PHY_UNKNOWN,
  89. MSM_DSI_PHY_28NM,
  90. MSM_DSI_PHY_MAX
  91. };
  92. struct msm_dsi_phy *msm_dsi_phy_init(struct platform_device *pdev,
  93. enum msm_dsi_phy_type type, int id);
  94. int msm_dsi_phy_enable(struct msm_dsi_phy *phy, bool is_dual_panel,
  95. const unsigned long bit_rate, const unsigned long esc_rate);
  96. int msm_dsi_phy_disable(struct msm_dsi_phy *phy);
  97. void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy,
  98. u32 *clk_pre, u32 *clk_post);
  99. #endif /* __DSI_CONNECTOR_H__ */