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