Lines Matching +full:hdmi +full:- +full:bridge
1 // SPDX-License-Identifier: GPL-2.0-only
9 #include "hdmi.h"
13 struct hdmi *hdmi; member
17 void msm_hdmi_bridge_destroy(struct drm_bridge *bridge) in msm_hdmi_bridge_destroy() argument
21 static void msm_hdmi_power_on(struct drm_bridge *bridge) in msm_hdmi_power_on() argument
23 struct drm_device *dev = bridge->dev; in msm_hdmi_power_on()
24 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); in msm_hdmi_power_on()
25 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_power_on() local
26 const struct hdmi_platform_config *config = hdmi->config; in msm_hdmi_power_on()
29 pm_runtime_get_sync(&hdmi->pdev->dev); in msm_hdmi_power_on()
31 for (i = 0; i < config->pwr_reg_cnt; i++) { in msm_hdmi_power_on()
32 ret = regulator_enable(hdmi->pwr_regs[i]); in msm_hdmi_power_on()
34 DRM_DEV_ERROR(dev->dev, "failed to enable pwr regulator: %s (%d)\n", in msm_hdmi_power_on()
35 config->pwr_reg_names[i], ret); in msm_hdmi_power_on()
39 if (config->pwr_clk_cnt > 0) { in msm_hdmi_power_on()
40 DBG("pixclock: %lu", hdmi->pixclock); in msm_hdmi_power_on()
41 ret = clk_set_rate(hdmi->pwr_clks[0], hdmi->pixclock); in msm_hdmi_power_on()
43 DRM_DEV_ERROR(dev->dev, "failed to set pixel clk: %s (%d)\n", in msm_hdmi_power_on()
44 config->pwr_clk_names[0], ret); in msm_hdmi_power_on()
48 for (i = 0; i < config->pwr_clk_cnt; i++) { in msm_hdmi_power_on()
49 ret = clk_prepare_enable(hdmi->pwr_clks[i]); in msm_hdmi_power_on()
51 DRM_DEV_ERROR(dev->dev, "failed to enable pwr clk: %s (%d)\n", in msm_hdmi_power_on()
52 config->pwr_clk_names[i], ret); in msm_hdmi_power_on()
57 static void power_off(struct drm_bridge *bridge) in power_off() argument
59 struct drm_device *dev = bridge->dev; in power_off()
60 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); in power_off()
61 struct hdmi *hdmi = hdmi_bridge->hdmi; in power_off() local
62 const struct hdmi_platform_config *config = hdmi->config; in power_off()
70 for (i = 0; i < config->pwr_clk_cnt; i++) in power_off()
71 clk_disable_unprepare(hdmi->pwr_clks[i]); in power_off()
73 for (i = 0; i < config->pwr_reg_cnt; i++) { in power_off()
74 ret = regulator_disable(hdmi->pwr_regs[i]); in power_off()
76 DRM_DEV_ERROR(dev->dev, "failed to disable pwr regulator: %s (%d)\n", in power_off()
77 config->pwr_reg_names[i], ret); in power_off()
81 pm_runtime_put_autosuspend(&hdmi->pdev->dev); in power_off()
86 static void msm_hdmi_config_avi_infoframe(struct hdmi *hdmi) in msm_hdmi_config_avi_infoframe() argument
88 struct drm_crtc *crtc = hdmi->encoder->crtc; in msm_hdmi_config_avi_infoframe()
89 const struct drm_display_mode *mode = &crtc->state->adjusted_mode; in msm_hdmi_config_avi_infoframe()
96 hdmi->connector, mode); in msm_hdmi_config_avi_infoframe()
100 DRM_DEV_ERROR(&hdmi->pdev->dev, in msm_hdmi_config_avi_infoframe()
111 hdmi_write(hdmi, REG_HDMI_AVI_INFO(0), in msm_hdmi_config_avi_infoframe()
117 hdmi_write(hdmi, REG_HDMI_AVI_INFO(1), in msm_hdmi_config_avi_infoframe()
123 hdmi_write(hdmi, REG_HDMI_AVI_INFO(2), in msm_hdmi_config_avi_infoframe()
129 hdmi_write(hdmi, REG_HDMI_AVI_INFO(3), in msm_hdmi_config_avi_infoframe()
134 hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, in msm_hdmi_config_avi_infoframe()
138 val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); in msm_hdmi_config_avi_infoframe()
141 hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); in msm_hdmi_config_avi_infoframe()
144 static void msm_hdmi_bridge_pre_enable(struct drm_bridge *bridge) in msm_hdmi_bridge_pre_enable() argument
146 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); in msm_hdmi_bridge_pre_enable()
147 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_pre_enable() local
148 struct hdmi_phy *phy = hdmi->phy; in msm_hdmi_bridge_pre_enable()
152 if (!hdmi->power_on) { in msm_hdmi_bridge_pre_enable()
154 msm_hdmi_power_on(bridge); in msm_hdmi_bridge_pre_enable()
155 hdmi->power_on = true; in msm_hdmi_bridge_pre_enable()
156 if (hdmi->hdmi_mode) { in msm_hdmi_bridge_pre_enable()
157 msm_hdmi_config_avi_infoframe(hdmi); in msm_hdmi_bridge_pre_enable()
158 msm_hdmi_audio_update(hdmi); in msm_hdmi_bridge_pre_enable()
162 msm_hdmi_phy_powerup(phy, hdmi->pixclock); in msm_hdmi_bridge_pre_enable()
164 msm_hdmi_set_mode(hdmi, true); in msm_hdmi_bridge_pre_enable()
166 if (hdmi->hdcp_ctrl) in msm_hdmi_bridge_pre_enable()
167 msm_hdmi_hdcp_on(hdmi->hdcp_ctrl); in msm_hdmi_bridge_pre_enable()
170 static void msm_hdmi_bridge_enable(struct drm_bridge *bridge) in msm_hdmi_bridge_enable() argument
174 static void msm_hdmi_bridge_disable(struct drm_bridge *bridge) in msm_hdmi_bridge_disable() argument
178 static void msm_hdmi_bridge_post_disable(struct drm_bridge *bridge) in msm_hdmi_bridge_post_disable() argument
180 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); in msm_hdmi_bridge_post_disable()
181 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_post_disable() local
182 struct hdmi_phy *phy = hdmi->phy; in msm_hdmi_bridge_post_disable()
184 if (hdmi->hdcp_ctrl) in msm_hdmi_bridge_post_disable()
185 msm_hdmi_hdcp_off(hdmi->hdcp_ctrl); in msm_hdmi_bridge_post_disable()
188 msm_hdmi_set_mode(hdmi, false); in msm_hdmi_bridge_post_disable()
192 if (hdmi->power_on) { in msm_hdmi_bridge_post_disable()
193 power_off(bridge); in msm_hdmi_bridge_post_disable()
194 hdmi->power_on = false; in msm_hdmi_bridge_post_disable()
195 if (hdmi->hdmi_mode) in msm_hdmi_bridge_post_disable()
196 msm_hdmi_audio_update(hdmi); in msm_hdmi_bridge_post_disable()
201 static void msm_hdmi_bridge_mode_set(struct drm_bridge *bridge, in msm_hdmi_bridge_mode_set() argument
205 struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); in msm_hdmi_bridge_mode_set()
206 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_mode_set() local
212 hdmi->pixclock = mode->clock * 1000; in msm_hdmi_bridge_mode_set()
214 hstart = mode->htotal - mode->hsync_start; in msm_hdmi_bridge_mode_set()
215 hend = mode->htotal - mode->hsync_start + mode->hdisplay; in msm_hdmi_bridge_mode_set()
217 vstart = mode->vtotal - mode->vsync_start - 1; in msm_hdmi_bridge_mode_set()
218 vend = mode->vtotal - mode->vsync_start + mode->vdisplay - 1; in msm_hdmi_bridge_mode_set()
221 mode->htotal, mode->vtotal, hstart, hend, vstart, vend); in msm_hdmi_bridge_mode_set()
223 hdmi_write(hdmi, REG_HDMI_TOTAL, in msm_hdmi_bridge_mode_set()
224 HDMI_TOTAL_H_TOTAL(mode->htotal - 1) | in msm_hdmi_bridge_mode_set()
225 HDMI_TOTAL_V_TOTAL(mode->vtotal - 1)); in msm_hdmi_bridge_mode_set()
227 hdmi_write(hdmi, REG_HDMI_ACTIVE_HSYNC, in msm_hdmi_bridge_mode_set()
230 hdmi_write(hdmi, REG_HDMI_ACTIVE_VSYNC, in msm_hdmi_bridge_mode_set()
234 if (mode->flags & DRM_MODE_FLAG_INTERLACE) { in msm_hdmi_bridge_mode_set()
235 hdmi_write(hdmi, REG_HDMI_VSYNC_TOTAL_F2, in msm_hdmi_bridge_mode_set()
236 HDMI_VSYNC_TOTAL_F2_V_TOTAL(mode->vtotal)); in msm_hdmi_bridge_mode_set()
237 hdmi_write(hdmi, REG_HDMI_VSYNC_ACTIVE_F2, in msm_hdmi_bridge_mode_set()
241 hdmi_write(hdmi, REG_HDMI_VSYNC_TOTAL_F2, in msm_hdmi_bridge_mode_set()
243 hdmi_write(hdmi, REG_HDMI_VSYNC_ACTIVE_F2, in msm_hdmi_bridge_mode_set()
249 if (mode->flags & DRM_MODE_FLAG_NHSYNC) in msm_hdmi_bridge_mode_set()
251 if (mode->flags & DRM_MODE_FLAG_NVSYNC) in msm_hdmi_bridge_mode_set()
253 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in msm_hdmi_bridge_mode_set()
256 hdmi_write(hdmi, REG_HDMI_FRAME_CTRL, frame_ctrl); in msm_hdmi_bridge_mode_set()
258 if (hdmi->hdmi_mode) in msm_hdmi_bridge_mode_set()
259 msm_hdmi_audio_update(hdmi); in msm_hdmi_bridge_mode_set()
271 /* initialize bridge */
272 struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi) in msm_hdmi_bridge_init() argument
274 struct drm_bridge *bridge = NULL; in msm_hdmi_bridge_init() local
278 hdmi_bridge = devm_kzalloc(hdmi->dev->dev, in msm_hdmi_bridge_init()
281 ret = -ENOMEM; in msm_hdmi_bridge_init()
285 hdmi_bridge->hdmi = hdmi; in msm_hdmi_bridge_init()
287 bridge = &hdmi_bridge->base; in msm_hdmi_bridge_init()
288 bridge->funcs = &msm_hdmi_bridge_funcs; in msm_hdmi_bridge_init()
290 ret = drm_bridge_attach(hdmi->encoder, bridge, NULL, 0); in msm_hdmi_bridge_init()
294 return bridge; in msm_hdmi_bridge_init()
297 if (bridge) in msm_hdmi_bridge_init()
298 msm_hdmi_bridge_destroy(bridge); in msm_hdmi_bridge_init()