Lines Matching +full:hdmi +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-only
12 #include "hdmi.h"
24 struct drm_device *dev = bridge->dev; in msm_hdmi_power_on()
26 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_power_on() local
27 const struct hdmi_platform_config *config = hdmi->config; in msm_hdmi_power_on()
30 pm_runtime_get_sync(&hdmi->pdev->dev); in msm_hdmi_power_on()
32 ret = regulator_bulk_enable(config->pwr_reg_cnt, hdmi->pwr_regs); in msm_hdmi_power_on()
34 DRM_DEV_ERROR(dev->dev, "failed to enable pwr regulator: %d\n", ret); in msm_hdmi_power_on()
36 if (config->pwr_clk_cnt > 0) { in msm_hdmi_power_on()
37 DBG("pixclock: %lu", hdmi->pixclock); in msm_hdmi_power_on()
38 ret = clk_set_rate(hdmi->pwr_clks[0], hdmi->pixclock); in msm_hdmi_power_on()
40 DRM_DEV_ERROR(dev->dev, "failed to set pixel clk: %s (%d)\n", in msm_hdmi_power_on()
41 config->pwr_clk_names[0], ret); in msm_hdmi_power_on()
45 for (i = 0; i < config->pwr_clk_cnt; i++) { in msm_hdmi_power_on()
46 ret = clk_prepare_enable(hdmi->pwr_clks[i]); in msm_hdmi_power_on()
48 DRM_DEV_ERROR(dev->dev, "failed to enable pwr clk: %s (%d)\n", in msm_hdmi_power_on()
49 config->pwr_clk_names[i], ret); in msm_hdmi_power_on()
56 struct drm_device *dev = bridge->dev; in power_off()
58 struct hdmi *hdmi = hdmi_bridge->hdmi; in power_off() local
59 const struct hdmi_platform_config *config = hdmi->config; in power_off()
67 for (i = 0; i < config->pwr_clk_cnt; i++) in power_off()
68 clk_disable_unprepare(hdmi->pwr_clks[i]); in power_off()
70 ret = regulator_bulk_disable(config->pwr_reg_cnt, hdmi->pwr_regs); in power_off()
72 DRM_DEV_ERROR(dev->dev, "failed to disable pwr regulator: %d\n", ret); in power_off()
74 pm_runtime_put(&hdmi->pdev->dev); in power_off()
79 static void msm_hdmi_config_avi_infoframe(struct hdmi *hdmi) in msm_hdmi_config_avi_infoframe() argument
81 struct drm_crtc *crtc = hdmi->encoder->crtc; in msm_hdmi_config_avi_infoframe()
82 const struct drm_display_mode *mode = &crtc->state->adjusted_mode; in msm_hdmi_config_avi_infoframe()
89 hdmi->connector, mode); in msm_hdmi_config_avi_infoframe()
93 DRM_DEV_ERROR(&hdmi->pdev->dev, in msm_hdmi_config_avi_infoframe()
104 hdmi_write(hdmi, REG_HDMI_AVI_INFO(0), in msm_hdmi_config_avi_infoframe()
110 hdmi_write(hdmi, REG_HDMI_AVI_INFO(1), in msm_hdmi_config_avi_infoframe()
116 hdmi_write(hdmi, REG_HDMI_AVI_INFO(2), in msm_hdmi_config_avi_infoframe()
122 hdmi_write(hdmi, REG_HDMI_AVI_INFO(3), in msm_hdmi_config_avi_infoframe()
127 hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, in msm_hdmi_config_avi_infoframe()
131 val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); in msm_hdmi_config_avi_infoframe()
134 hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); in msm_hdmi_config_avi_infoframe()
140 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_pre_enable() local
141 struct hdmi_phy *phy = hdmi->phy; in msm_hdmi_bridge_pre_enable() local
145 if (!hdmi->power_on) { in msm_hdmi_bridge_pre_enable()
146 msm_hdmi_phy_resource_enable(phy); in msm_hdmi_bridge_pre_enable()
148 hdmi->power_on = true; in msm_hdmi_bridge_pre_enable()
149 if (hdmi->hdmi_mode) { in msm_hdmi_bridge_pre_enable()
150 msm_hdmi_config_avi_infoframe(hdmi); in msm_hdmi_bridge_pre_enable()
151 msm_hdmi_audio_update(hdmi); in msm_hdmi_bridge_pre_enable()
155 msm_hdmi_phy_powerup(phy, hdmi->pixclock); in msm_hdmi_bridge_pre_enable()
157 msm_hdmi_set_mode(hdmi, true); in msm_hdmi_bridge_pre_enable()
159 if (hdmi->hdcp_ctrl) in msm_hdmi_bridge_pre_enable()
160 msm_hdmi_hdcp_on(hdmi->hdcp_ctrl); in msm_hdmi_bridge_pre_enable()
166 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_post_disable() local
167 struct hdmi_phy *phy = hdmi->phy; in msm_hdmi_bridge_post_disable() local
169 if (hdmi->hdcp_ctrl) in msm_hdmi_bridge_post_disable()
170 msm_hdmi_hdcp_off(hdmi->hdcp_ctrl); in msm_hdmi_bridge_post_disable()
173 msm_hdmi_set_mode(hdmi, false); in msm_hdmi_bridge_post_disable()
175 msm_hdmi_phy_powerdown(phy); in msm_hdmi_bridge_post_disable()
177 if (hdmi->power_on) { in msm_hdmi_bridge_post_disable()
179 hdmi->power_on = false; in msm_hdmi_bridge_post_disable()
180 if (hdmi->hdmi_mode) in msm_hdmi_bridge_post_disable()
181 msm_hdmi_audio_update(hdmi); in msm_hdmi_bridge_post_disable()
182 msm_hdmi_phy_resource_disable(phy); in msm_hdmi_bridge_post_disable()
191 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_mode_set() local
197 hdmi->pixclock = mode->clock * 1000; in msm_hdmi_bridge_mode_set()
199 hstart = mode->htotal - mode->hsync_start; in msm_hdmi_bridge_mode_set()
200 hend = mode->htotal - mode->hsync_start + mode->hdisplay; in msm_hdmi_bridge_mode_set()
202 vstart = mode->vtotal - mode->vsync_start - 1; in msm_hdmi_bridge_mode_set()
203 vend = mode->vtotal - mode->vsync_start + mode->vdisplay - 1; in msm_hdmi_bridge_mode_set()
206 mode->htotal, mode->vtotal, hstart, hend, vstart, vend); in msm_hdmi_bridge_mode_set()
208 hdmi_write(hdmi, REG_HDMI_TOTAL, in msm_hdmi_bridge_mode_set()
209 HDMI_TOTAL_H_TOTAL(mode->htotal - 1) | in msm_hdmi_bridge_mode_set()
210 HDMI_TOTAL_V_TOTAL(mode->vtotal - 1)); in msm_hdmi_bridge_mode_set()
212 hdmi_write(hdmi, REG_HDMI_ACTIVE_HSYNC, in msm_hdmi_bridge_mode_set()
215 hdmi_write(hdmi, REG_HDMI_ACTIVE_VSYNC, in msm_hdmi_bridge_mode_set()
219 if (mode->flags & DRM_MODE_FLAG_INTERLACE) { in msm_hdmi_bridge_mode_set()
220 hdmi_write(hdmi, REG_HDMI_VSYNC_TOTAL_F2, in msm_hdmi_bridge_mode_set()
221 HDMI_VSYNC_TOTAL_F2_V_TOTAL(mode->vtotal)); in msm_hdmi_bridge_mode_set()
222 hdmi_write(hdmi, REG_HDMI_VSYNC_ACTIVE_F2, in msm_hdmi_bridge_mode_set()
226 hdmi_write(hdmi, REG_HDMI_VSYNC_TOTAL_F2, in msm_hdmi_bridge_mode_set()
228 hdmi_write(hdmi, REG_HDMI_VSYNC_ACTIVE_F2, in msm_hdmi_bridge_mode_set()
234 if (mode->flags & DRM_MODE_FLAG_NHSYNC) in msm_hdmi_bridge_mode_set()
236 if (mode->flags & DRM_MODE_FLAG_NVSYNC) in msm_hdmi_bridge_mode_set()
238 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in msm_hdmi_bridge_mode_set()
241 hdmi_write(hdmi, REG_HDMI_FRAME_CTRL, frame_ctrl); in msm_hdmi_bridge_mode_set()
243 if (hdmi->hdmi_mode) in msm_hdmi_bridge_mode_set()
244 msm_hdmi_audio_update(hdmi); in msm_hdmi_bridge_mode_set()
251 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_get_edid() local
255 hdmi_ctrl = hdmi_read(hdmi, REG_HDMI_CTRL); in msm_hdmi_bridge_get_edid()
256 hdmi_write(hdmi, REG_HDMI_CTRL, hdmi_ctrl | HDMI_CTRL_ENABLE); in msm_hdmi_bridge_get_edid()
258 edid = drm_get_edid(connector, hdmi->i2c); in msm_hdmi_bridge_get_edid()
260 hdmi_write(hdmi, REG_HDMI_CTRL, hdmi_ctrl); in msm_hdmi_bridge_get_edid()
262 hdmi->hdmi_mode = drm_detect_hdmi_monitor(edid); in msm_hdmi_bridge_get_edid()
272 struct hdmi *hdmi = hdmi_bridge->hdmi; in msm_hdmi_bridge_mode_valid() local
273 const struct hdmi_platform_config *config = hdmi->config; in msm_hdmi_bridge_mode_valid()
274 struct msm_drm_private *priv = bridge->dev->dev_private; in msm_hdmi_bridge_mode_valid()
275 struct msm_kms *kms = priv->kms; in msm_hdmi_bridge_mode_valid()
278 requested = 1000 * mode->clock; in msm_hdmi_bridge_mode_valid()
284 if (kms->funcs->round_pixclk) in msm_hdmi_bridge_mode_valid()
285 actual = kms->funcs->round_pixclk(kms, in msm_hdmi_bridge_mode_valid()
286 requested, hdmi_bridge->hdmi->encoder); in msm_hdmi_bridge_mode_valid()
287 else if (config->pwr_clk_cnt > 0) in msm_hdmi_bridge_mode_valid()
288 actual = clk_round_rate(hdmi->pwr_clks[0], requested); in msm_hdmi_bridge_mode_valid()
314 struct drm_bridge *bridge = &hdmi_bridge->base; in msm_hdmi_hotplug_work()
320 struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi) in msm_hdmi_bridge_init() argument
326 hdmi_bridge = devm_kzalloc(hdmi->dev->dev, in msm_hdmi_bridge_init()
329 ret = -ENOMEM; in msm_hdmi_bridge_init()
333 hdmi_bridge->hdmi = hdmi; in msm_hdmi_bridge_init()
334 INIT_WORK(&hdmi_bridge->hpd_work, msm_hdmi_hotplug_work); in msm_hdmi_bridge_init()
336 bridge = &hdmi_bridge->base; in msm_hdmi_bridge_init()
337 bridge->funcs = &msm_hdmi_bridge_funcs; in msm_hdmi_bridge_init()
338 bridge->ddc = hdmi->i2c; in msm_hdmi_bridge_init()
339 bridge->type = DRM_MODE_CONNECTOR_HDMIA; in msm_hdmi_bridge_init()
340 bridge->ops = DRM_BRIDGE_OP_HPD | in msm_hdmi_bridge_init()
346 ret = drm_bridge_attach(hdmi->encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR); in msm_hdmi_bridge_init()