Lines Matching +full:hdmi +full:- +full:phy
1 // SPDX-License-Identifier: GPL-2.0-only
12 #include "hdmi.h"
16 struct drm_device *dev = bridge->dev; in msm_hdmi_power_on()
18 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_power_on() local
19 const struct hdmi_platform_config *config = hdmi->config; in msm_hdmi_power_on()
22 pm_runtime_get_sync(&hdmi->pdev->dev); in msm_hdmi_power_on()
24 ret = regulator_bulk_enable(config->pwr_reg_cnt, hdmi->pwr_regs); in msm_hdmi_power_on()
26 DRM_DEV_ERROR(dev->dev, "failed to enable pwr regulator: %d\n", ret); in msm_hdmi_power_on()
28 if (config->pwr_clk_cnt > 0) { in msm_hdmi_power_on()
29 DBG("pixclock: %lu", hdmi->pixclock); in msm_hdmi_power_on()
30 ret = clk_set_rate(hdmi->pwr_clks[0], hdmi->pixclock); in msm_hdmi_power_on()
32 DRM_DEV_ERROR(dev->dev, "failed to set pixel clk: %s (%d)\n", in msm_hdmi_power_on()
33 config->pwr_clk_names[0], ret); in msm_hdmi_power_on()
37 for (i = 0; i < config->pwr_clk_cnt; i++) { in msm_hdmi_power_on()
38 ret = clk_prepare_enable(hdmi->pwr_clks[i]); in msm_hdmi_power_on()
40 DRM_DEV_ERROR(dev->dev, "failed to enable pwr clk: %s (%d)\n", in msm_hdmi_power_on()
41 config->pwr_clk_names[i], ret); in msm_hdmi_power_on()
48 struct drm_device *dev = bridge->dev; in power_off()
50 struct hdmi *hdmi = hdmi_bridge->hdmi; in power_off() local
51 const struct hdmi_platform_config *config = hdmi->config; in power_off()
59 for (i = 0; i < config->pwr_clk_cnt; i++) in power_off()
60 clk_disable_unprepare(hdmi->pwr_clks[i]); in power_off()
62 ret = regulator_bulk_disable(config->pwr_reg_cnt, hdmi->pwr_regs); in power_off()
64 DRM_DEV_ERROR(dev->dev, "failed to disable pwr regulator: %d\n", ret); in power_off()
66 pm_runtime_put(&hdmi->pdev->dev); in power_off()
71 static void msm_hdmi_config_avi_infoframe(struct hdmi *hdmi) in msm_hdmi_config_avi_infoframe() argument
73 struct drm_crtc *crtc = hdmi->encoder->crtc; in msm_hdmi_config_avi_infoframe()
74 const struct drm_display_mode *mode = &crtc->state->adjusted_mode; in msm_hdmi_config_avi_infoframe()
81 hdmi->connector, mode); in msm_hdmi_config_avi_infoframe()
85 DRM_DEV_ERROR(&hdmi->pdev->dev, in msm_hdmi_config_avi_infoframe()
96 hdmi_write(hdmi, REG_HDMI_AVI_INFO(0), in msm_hdmi_config_avi_infoframe()
102 hdmi_write(hdmi, REG_HDMI_AVI_INFO(1), in msm_hdmi_config_avi_infoframe()
108 hdmi_write(hdmi, REG_HDMI_AVI_INFO(2), in msm_hdmi_config_avi_infoframe()
114 hdmi_write(hdmi, REG_HDMI_AVI_INFO(3), in msm_hdmi_config_avi_infoframe()
119 hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, in msm_hdmi_config_avi_infoframe()
123 val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); in msm_hdmi_config_avi_infoframe()
126 hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); in msm_hdmi_config_avi_infoframe()
132 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_pre_enable() local
133 struct hdmi_phy *phy = hdmi->phy; in msm_hdmi_bridge_pre_enable() local
137 if (!hdmi->power_on) { in msm_hdmi_bridge_pre_enable()
138 msm_hdmi_phy_resource_enable(phy); in msm_hdmi_bridge_pre_enable()
140 hdmi->power_on = true; in msm_hdmi_bridge_pre_enable()
141 if (hdmi->hdmi_mode) { in msm_hdmi_bridge_pre_enable()
142 msm_hdmi_config_avi_infoframe(hdmi); in msm_hdmi_bridge_pre_enable()
143 msm_hdmi_audio_update(hdmi); in msm_hdmi_bridge_pre_enable()
147 msm_hdmi_phy_powerup(phy, hdmi->pixclock); in msm_hdmi_bridge_pre_enable()
149 msm_hdmi_set_mode(hdmi, true); in msm_hdmi_bridge_pre_enable()
151 if (hdmi->hdcp_ctrl) in msm_hdmi_bridge_pre_enable()
152 msm_hdmi_hdcp_on(hdmi->hdcp_ctrl); in msm_hdmi_bridge_pre_enable()
158 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_post_disable() local
159 struct hdmi_phy *phy = hdmi->phy; in msm_hdmi_bridge_post_disable() local
161 if (hdmi->hdcp_ctrl) in msm_hdmi_bridge_post_disable()
162 msm_hdmi_hdcp_off(hdmi->hdcp_ctrl); in msm_hdmi_bridge_post_disable()
165 msm_hdmi_set_mode(hdmi, false); in msm_hdmi_bridge_post_disable()
167 msm_hdmi_phy_powerdown(phy); in msm_hdmi_bridge_post_disable()
169 if (hdmi->power_on) { in msm_hdmi_bridge_post_disable()
171 hdmi->power_on = false; in msm_hdmi_bridge_post_disable()
172 if (hdmi->hdmi_mode) in msm_hdmi_bridge_post_disable()
173 msm_hdmi_audio_update(hdmi); in msm_hdmi_bridge_post_disable()
174 msm_hdmi_phy_resource_disable(phy); in msm_hdmi_bridge_post_disable()
183 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_mode_set() local
189 hdmi->pixclock = mode->clock * 1000; in msm_hdmi_bridge_mode_set()
191 hstart = mode->htotal - mode->hsync_start; in msm_hdmi_bridge_mode_set()
192 hend = mode->htotal - mode->hsync_start + mode->hdisplay; in msm_hdmi_bridge_mode_set()
194 vstart = mode->vtotal - mode->vsync_start - 1; in msm_hdmi_bridge_mode_set()
195 vend = mode->vtotal - mode->vsync_start + mode->vdisplay - 1; in msm_hdmi_bridge_mode_set()
198 mode->htotal, mode->vtotal, hstart, hend, vstart, vend); in msm_hdmi_bridge_mode_set()
200 hdmi_write(hdmi, REG_HDMI_TOTAL, in msm_hdmi_bridge_mode_set()
201 HDMI_TOTAL_H_TOTAL(mode->htotal - 1) | in msm_hdmi_bridge_mode_set()
202 HDMI_TOTAL_V_TOTAL(mode->vtotal - 1)); in msm_hdmi_bridge_mode_set()
204 hdmi_write(hdmi, REG_HDMI_ACTIVE_HSYNC, in msm_hdmi_bridge_mode_set()
207 hdmi_write(hdmi, REG_HDMI_ACTIVE_VSYNC, in msm_hdmi_bridge_mode_set()
211 if (mode->flags & DRM_MODE_FLAG_INTERLACE) { in msm_hdmi_bridge_mode_set()
212 hdmi_write(hdmi, REG_HDMI_VSYNC_TOTAL_F2, in msm_hdmi_bridge_mode_set()
213 HDMI_VSYNC_TOTAL_F2_V_TOTAL(mode->vtotal)); in msm_hdmi_bridge_mode_set()
214 hdmi_write(hdmi, REG_HDMI_VSYNC_ACTIVE_F2, in msm_hdmi_bridge_mode_set()
218 hdmi_write(hdmi, REG_HDMI_VSYNC_TOTAL_F2, in msm_hdmi_bridge_mode_set()
220 hdmi_write(hdmi, REG_HDMI_VSYNC_ACTIVE_F2, in msm_hdmi_bridge_mode_set()
226 if (mode->flags & DRM_MODE_FLAG_NHSYNC) in msm_hdmi_bridge_mode_set()
228 if (mode->flags & DRM_MODE_FLAG_NVSYNC) in msm_hdmi_bridge_mode_set()
230 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in msm_hdmi_bridge_mode_set()
233 hdmi_write(hdmi, REG_HDMI_FRAME_CTRL, frame_ctrl); in msm_hdmi_bridge_mode_set()
235 if (hdmi->hdmi_mode) in msm_hdmi_bridge_mode_set()
236 msm_hdmi_audio_update(hdmi); in msm_hdmi_bridge_mode_set()
243 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_edid_read() local
247 hdmi_ctrl = hdmi_read(hdmi, REG_HDMI_CTRL); in msm_hdmi_bridge_edid_read()
248 hdmi_write(hdmi, REG_HDMI_CTRL, hdmi_ctrl | HDMI_CTRL_ENABLE); in msm_hdmi_bridge_edid_read()
250 drm_edid = drm_edid_read_ddc(connector, hdmi->i2c); in msm_hdmi_bridge_edid_read()
252 hdmi_write(hdmi, REG_HDMI_CTRL, hdmi_ctrl); in msm_hdmi_bridge_edid_read()
256 * FIXME: This should use connector->display_info.is_hdmi from a in msm_hdmi_bridge_edid_read()
262 hdmi->hdmi_mode = drm_detect_hdmi_monitor(edid); in msm_hdmi_bridge_edid_read()
273 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_mode_valid() local
274 const struct hdmi_platform_config *config = hdmi->config; in msm_hdmi_bridge_mode_valid()
275 struct msm_drm_private *priv = bridge->dev->dev_private; in msm_hdmi_bridge_mode_valid()
276 struct msm_kms *kms = priv->kms; in msm_hdmi_bridge_mode_valid()
279 requested = 1000 * mode->clock; in msm_hdmi_bridge_mode_valid()
285 if (kms->funcs->round_pixclk) in msm_hdmi_bridge_mode_valid()
286 actual = kms->funcs->round_pixclk(kms, in msm_hdmi_bridge_mode_valid()
287 requested, hdmi_bridge->hdmi->encoder); in msm_hdmi_bridge_mode_valid()
288 else if (config->pwr_clk_cnt > 0) in msm_hdmi_bridge_mode_valid()
289 actual = clk_round_rate(hdmi->pwr_clks[0], requested); in msm_hdmi_bridge_mode_valid()
315 struct drm_bridge *bridge = &hdmi_bridge->base; in msm_hdmi_hotplug_work()
321 int msm_hdmi_bridge_init(struct hdmi *hdmi) in msm_hdmi_bridge_init() argument
327 hdmi_bridge = devm_kzalloc(hdmi->dev->dev, in msm_hdmi_bridge_init()
330 return -ENOMEM; in msm_hdmi_bridge_init()
332 hdmi_bridge->hdmi = hdmi; in msm_hdmi_bridge_init()
333 INIT_WORK(&hdmi_bridge->hpd_work, msm_hdmi_hotplug_work); in msm_hdmi_bridge_init()
335 bridge = &hdmi_bridge->base; in msm_hdmi_bridge_init()
336 bridge->funcs = &msm_hdmi_bridge_funcs; in msm_hdmi_bridge_init()
337 bridge->ddc = hdmi->i2c; in msm_hdmi_bridge_init()
338 bridge->type = DRM_MODE_CONNECTOR_HDMIA; in msm_hdmi_bridge_init()
339 bridge->ops = DRM_BRIDGE_OP_HPD | in msm_hdmi_bridge_init()
343 ret = devm_drm_bridge_add(hdmi->dev->dev, bridge); in msm_hdmi_bridge_init()
347 ret = drm_bridge_attach(hdmi->encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR); in msm_hdmi_bridge_init()
351 hdmi->bridge = bridge; in msm_hdmi_bridge_init()