hdmi.h 3.9 KB

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