sti_hdmi.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) STMicroelectronics SA 2014
  4. * Author: Vincent Abriou <vincent.abriou@st.com> for STMicroelectronics.
  5. */
  6. #ifndef _STI_HDMI_H_
  7. #define _STI_HDMI_H_
  8. #include <linux/hdmi.h>
  9. #include <linux/platform_device.h>
  10. #include <media/cec-notifier.h>
  11. #include <drm/drm_modes.h>
  12. #include <drm/drm_property.h>
  13. #define HDMI_STA 0x0010
  14. #define HDMI_STA_DLL_LCK BIT(5)
  15. #define HDMI_STA_HOT_PLUG BIT(4)
  16. struct sti_hdmi;
  17. struct hdmi_phy_ops {
  18. bool (*start)(struct sti_hdmi *hdmi);
  19. void (*stop)(struct sti_hdmi *hdmi);
  20. };
  21. struct hdmi_audio_params {
  22. bool enabled;
  23. unsigned int sample_width;
  24. unsigned int sample_rate;
  25. struct hdmi_audio_infoframe cea;
  26. };
  27. static const struct drm_prop_enum_list colorspace_mode_names[] = {
  28. { HDMI_COLORSPACE_RGB, "rgb" },
  29. { HDMI_COLORSPACE_YUV422, "yuv422" },
  30. { HDMI_COLORSPACE_YUV444, "yuv444" },
  31. };
  32. #define DEFAULT_COLORSPACE_MODE HDMI_COLORSPACE_RGB
  33. /**
  34. * STI hdmi structure
  35. *
  36. * @dev: driver device
  37. * @drm_dev: pointer to drm device
  38. * @mode: current display mode selected
  39. * @regs: hdmi register
  40. * @syscfg: syscfg register for pll rejection configuration
  41. * @clk_pix: hdmi pixel clock
  42. * @clk_tmds: hdmi tmds clock
  43. * @clk_phy: hdmi phy clock
  44. * @clk_audio: hdmi audio clock
  45. * @irq: hdmi interrupt number
  46. * @irq_status: interrupt status register
  47. * @phy_ops: phy start/stop operations
  48. * @enabled: true if hdmi is enabled else false
  49. * @hpd: hot plug detect status
  50. * @wait_event: wait event
  51. * @event_received: wait event status
  52. * @reset: reset control of the hdmi phy
  53. * @ddc_adapt: i2c ddc adapter
  54. * @colorspace: current colorspace selected
  55. * @hdmi_monitor: true if HDMI monitor detected else DVI monitor assumed
  56. * @audio_pdev: ASoC hdmi-codec platform device
  57. * @audio: hdmi audio parameters.
  58. * @drm_connector: hdmi connector
  59. * @notifier: hotplug detect notifier
  60. */
  61. struct sti_hdmi {
  62. struct device dev;
  63. struct drm_device *drm_dev;
  64. struct drm_display_mode mode;
  65. void __iomem *regs;
  66. void __iomem *syscfg;
  67. struct clk *clk_pix;
  68. struct clk *clk_tmds;
  69. struct clk *clk_phy;
  70. struct clk *clk_audio;
  71. int irq;
  72. u32 irq_status;
  73. struct hdmi_phy_ops *phy_ops;
  74. bool enabled;
  75. bool hpd;
  76. wait_queue_head_t wait_event;
  77. bool event_received;
  78. struct reset_control *reset;
  79. struct i2c_adapter *ddc_adapt;
  80. enum hdmi_colorspace colorspace;
  81. bool hdmi_monitor;
  82. struct platform_device *audio_pdev;
  83. struct hdmi_audio_params audio;
  84. struct drm_connector *drm_connector;
  85. struct cec_notifier *notifier;
  86. };
  87. u32 hdmi_read(struct sti_hdmi *hdmi, int offset);
  88. void hdmi_write(struct sti_hdmi *hdmi, u32 val, int offset);
  89. /**
  90. * hdmi phy config structure
  91. *
  92. * A pointer to an array of these structures is passed to a TMDS (HDMI) output
  93. * via the control interface to provide board and SoC specific
  94. * configurations of the HDMI PHY. Each entry in the array specifies a hardware
  95. * specific configuration for a given TMDS clock frequency range.
  96. *
  97. * @min_tmds_freq: Lower bound of TMDS clock frequency this entry applies to
  98. * @max_tmds_freq: Upper bound of TMDS clock frequency this entry applies to
  99. * @config: SoC specific register configuration
  100. */
  101. struct hdmi_phy_config {
  102. u32 min_tmds_freq;
  103. u32 max_tmds_freq;
  104. u32 config[4];
  105. };
  106. #endif