hdmi.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 {
  34. struct kref refcount;
  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. struct regulator *hpd_regs[2];
  45. struct regulator *pwr_regs[2];
  46. struct clk *hpd_clks[3];
  47. struct clk *pwr_clks[2];
  48. struct hdmi_phy *phy;
  49. struct i2c_adapter *i2c;
  50. struct drm_connector *connector;
  51. struct drm_bridge *bridge;
  52. /* the encoder we are hooked to (outside of hdmi block) */
  53. struct drm_encoder *encoder;
  54. bool hdmi_mode; /* are we in hdmi mode? */
  55. int irq;
  56. };
  57. /* platform config data (ie. from DT, or pdata) */
  58. struct hdmi_platform_config {
  59. struct hdmi_phy *(*phy_init)(struct hdmi *hdmi);
  60. const char *mmio_name;
  61. /* regulators that need to be on for hpd: */
  62. const char **hpd_reg_names;
  63. int hpd_reg_cnt;
  64. /* regulators that need to be on for screen pwr: */
  65. const char **pwr_reg_names;
  66. int pwr_reg_cnt;
  67. /* clks that need to be on for hpd: */
  68. const char **hpd_clk_names;
  69. const long unsigned *hpd_freq;
  70. int hpd_clk_cnt;
  71. /* clks that need to be on for screen pwr (ie pixel clk): */
  72. const char **pwr_clk_names;
  73. int pwr_clk_cnt;
  74. /* gpio's: */
  75. int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, mux_en_gpio, mux_sel_gpio;
  76. int mux_lpm_gpio;
  77. /* older devices had their own irq, mdp5+ it is shared w/ mdp: */
  78. bool shared_irq;
  79. };
  80. void hdmi_set_mode(struct hdmi *hdmi, bool power_on);
  81. void hdmi_destroy(struct kref *kref);
  82. static inline void hdmi_write(struct hdmi *hdmi, u32 reg, u32 data)
  83. {
  84. msm_writel(data, hdmi->mmio + reg);
  85. }
  86. static inline u32 hdmi_read(struct hdmi *hdmi, u32 reg)
  87. {
  88. return msm_readl(hdmi->mmio + reg);
  89. }
  90. static inline struct hdmi * hdmi_reference(struct hdmi *hdmi)
  91. {
  92. kref_get(&hdmi->refcount);
  93. return hdmi;
  94. }
  95. static inline void hdmi_unreference(struct hdmi *hdmi)
  96. {
  97. kref_put(&hdmi->refcount, hdmi_destroy);
  98. }
  99. /*
  100. * The phy appears to be different, for example between 8960 and 8x60,
  101. * so split the phy related functions out and load the correct one at
  102. * runtime:
  103. */
  104. struct hdmi_phy_funcs {
  105. void (*destroy)(struct hdmi_phy *phy);
  106. void (*reset)(struct hdmi_phy *phy);
  107. void (*powerup)(struct hdmi_phy *phy, unsigned long int pixclock);
  108. void (*powerdown)(struct hdmi_phy *phy);
  109. };
  110. struct hdmi_phy {
  111. const struct hdmi_phy_funcs *funcs;
  112. };
  113. struct hdmi_phy *hdmi_phy_8960_init(struct hdmi *hdmi);
  114. struct hdmi_phy *hdmi_phy_8x60_init(struct hdmi *hdmi);
  115. struct hdmi_phy *hdmi_phy_8x74_init(struct hdmi *hdmi);
  116. /*
  117. * audio:
  118. */
  119. int hdmi_audio_update(struct hdmi *hdmi);
  120. int hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled,
  121. uint32_t num_of_channels, uint32_t channel_allocation,
  122. uint32_t level_shift, bool down_mix);
  123. void hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate);
  124. /*
  125. * hdmi bridge:
  126. */
  127. struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi);
  128. /*
  129. * hdmi connector:
  130. */
  131. void hdmi_connector_irq(struct drm_connector *connector);
  132. struct drm_connector *hdmi_connector_init(struct hdmi *hdmi);
  133. /*
  134. * i2c adapter for ddc:
  135. */
  136. void hdmi_i2c_irq(struct i2c_adapter *i2c);
  137. void hdmi_i2c_destroy(struct i2c_adapter *i2c);
  138. struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi);
  139. #endif /* __HDMI_CONNECTOR_H__ */