hdmi.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __HDMI_CONNECTOR_H__
  18. #define __HDMI_CONNECTOR_H__
  19. #include <linux/i2c.h>
  20. #include <linux/clk.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/regulator/consumer.h>
  23. #include <linux/hdmi.h>
  24. #include "msm_drv.h"
  25. #include "hdmi.xml.h"
  26. struct hdmi_phy;
  27. struct hdmi_platform_config;
  28. struct hdmi_audio {
  29. bool enabled;
  30. struct hdmi_audio_infoframe infoframe;
  31. int rate;
  32. };
  33. struct hdmi_hdcp_ctrl;
  34. struct hdmi {
  35. struct drm_device *dev;
  36. struct platform_device *pdev;
  37. const struct hdmi_platform_config *config;
  38. /* audio state: */
  39. struct hdmi_audio audio;
  40. /* video state: */
  41. bool power_on;
  42. unsigned long int pixclock;
  43. void __iomem *mmio;
  44. void __iomem *qfprom_mmio;
  45. phys_addr_t mmio_phy_addr;
  46. struct regulator **hpd_regs;
  47. struct regulator **pwr_regs;
  48. struct clk **hpd_clks;
  49. struct clk **pwr_clks;
  50. struct hdmi_phy *phy;
  51. struct i2c_adapter *i2c;
  52. struct drm_connector *connector;
  53. struct drm_bridge *bridge;
  54. /* the encoder we are hooked to (outside of hdmi block) */
  55. struct drm_encoder *encoder;
  56. bool hdmi_mode; /* are we in hdmi mode? */
  57. int irq;
  58. struct workqueue_struct *workq;
  59. struct hdmi_hdcp_ctrl *hdcp_ctrl;
  60. /*
  61. * spinlock to protect registers shared by different execution
  62. * REG_HDMI_CTRL
  63. * REG_HDMI_DDC_ARBITRATION
  64. * REG_HDMI_HDCP_INT_CTRL
  65. * REG_HDMI_HPD_CTRL
  66. */
  67. spinlock_t reg_lock;
  68. };
  69. /* platform config data (ie. from DT, or pdata) */
  70. struct hdmi_platform_config {
  71. struct hdmi_phy *(*phy_init)(struct hdmi *hdmi);
  72. const char *mmio_name;
  73. const char *qfprom_mmio_name;
  74. /* regulators that need to be on for hpd: */
  75. const char **hpd_reg_names;
  76. int hpd_reg_cnt;
  77. /* regulators that need to be on for screen pwr: */
  78. const char **pwr_reg_names;
  79. int pwr_reg_cnt;
  80. /* clks that need to be on for hpd: */
  81. const char **hpd_clk_names;
  82. const long unsigned *hpd_freq;
  83. int hpd_clk_cnt;
  84. /* clks that need to be on for screen pwr (ie pixel clk): */
  85. const char **pwr_clk_names;
  86. int pwr_clk_cnt;
  87. /* gpio's: */
  88. int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, mux_en_gpio, mux_sel_gpio;
  89. int mux_lpm_gpio;
  90. };
  91. void hdmi_set_mode(struct hdmi *hdmi, bool power_on);
  92. static inline void hdmi_write(struct hdmi *hdmi, u32 reg, u32 data)
  93. {
  94. msm_writel(data, hdmi->mmio + reg);
  95. }
  96. static inline u32 hdmi_read(struct hdmi *hdmi, u32 reg)
  97. {
  98. return msm_readl(hdmi->mmio + reg);
  99. }
  100. static inline u32 hdmi_qfprom_read(struct hdmi *hdmi, u32 reg)
  101. {
  102. return msm_readl(hdmi->qfprom_mmio + reg);
  103. }
  104. /*
  105. * The phy appears to be different, for example between 8960 and 8x60,
  106. * so split the phy related functions out and load the correct one at
  107. * runtime:
  108. */
  109. struct hdmi_phy_funcs {
  110. void (*destroy)(struct hdmi_phy *phy);
  111. void (*powerup)(struct hdmi_phy *phy, unsigned long int pixclock);
  112. void (*powerdown)(struct hdmi_phy *phy);
  113. };
  114. struct hdmi_phy {
  115. const struct hdmi_phy_funcs *funcs;
  116. };
  117. struct hdmi_phy *hdmi_phy_8960_init(struct hdmi *hdmi);
  118. struct hdmi_phy *hdmi_phy_8x60_init(struct hdmi *hdmi);
  119. struct hdmi_phy *hdmi_phy_8x74_init(struct hdmi *hdmi);
  120. /*
  121. * audio:
  122. */
  123. int hdmi_audio_update(struct hdmi *hdmi);
  124. int hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled,
  125. uint32_t num_of_channels, uint32_t channel_allocation,
  126. uint32_t level_shift, bool down_mix);
  127. void hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate);
  128. /*
  129. * hdmi bridge:
  130. */
  131. struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi);
  132. void hdmi_bridge_destroy(struct drm_bridge *bridge);
  133. /*
  134. * hdmi connector:
  135. */
  136. void hdmi_connector_irq(struct drm_connector *connector);
  137. struct drm_connector *hdmi_connector_init(struct hdmi *hdmi);
  138. /*
  139. * i2c adapter for ddc:
  140. */
  141. void hdmi_i2c_irq(struct i2c_adapter *i2c);
  142. void hdmi_i2c_destroy(struct i2c_adapter *i2c);
  143. struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi);
  144. /*
  145. * hdcp
  146. */
  147. struct hdmi_hdcp_ctrl *hdmi_hdcp_init(struct hdmi *hdmi);
  148. void hdmi_hdcp_destroy(struct hdmi *hdmi);
  149. void hdmi_hdcp_on(struct hdmi_hdcp_ctrl *hdcp_ctrl);
  150. void hdmi_hdcp_off(struct hdmi_hdcp_ctrl *hdcp_ctrl);
  151. void hdmi_hdcp_irq(struct hdmi_hdcp_ctrl *hdcp_ctrl);
  152. #endif /* __HDMI_CONNECTOR_H__ */