Lines Matching +full:hdmi +full:- +full:connector
1 // SPDX-License-Identifier: GPL-2.0-only
12 #include "hdmi.h"
16 struct hdmi *hdmi; member
21 static void msm_hdmi_phy_reset(struct hdmi *hdmi) in msm_hdmi_phy_reset() argument
25 val = hdmi_read(hdmi, REG_HDMI_PHY_CTRL); in msm_hdmi_phy_reset()
29 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
33 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
39 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
43 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
51 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
55 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
61 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
65 hdmi_write(hdmi, REG_HDMI_PHY_CTRL, in msm_hdmi_phy_reset()
70 static int gpio_config(struct hdmi *hdmi, bool on) in gpio_config() argument
72 const struct hdmi_platform_config *config = hdmi->config; in gpio_config()
77 struct hdmi_gpio_data gpio = config->gpios[i]; in gpio_config()
94 struct hdmi_gpio_data gpio = config->gpios[i]; in gpio_config()
112 static void enable_hpd_clocks(struct hdmi *hdmi, bool enable) in enable_hpd_clocks() argument
114 const struct hdmi_platform_config *config = hdmi->config; in enable_hpd_clocks()
115 struct device *dev = &hdmi->pdev->dev; in enable_hpd_clocks()
119 for (i = 0; i < config->hpd_clk_cnt; i++) { in enable_hpd_clocks()
120 if (config->hpd_freq && config->hpd_freq[i]) { in enable_hpd_clocks()
121 ret = clk_set_rate(hdmi->hpd_clks[i], in enable_hpd_clocks()
122 config->hpd_freq[i]); in enable_hpd_clocks()
126 config->hpd_clk_names[i], ret); in enable_hpd_clocks()
129 ret = clk_prepare_enable(hdmi->hpd_clks[i]); in enable_hpd_clocks()
133 config->hpd_clk_names[i], ret); in enable_hpd_clocks()
137 for (i = config->hpd_clk_cnt - 1; i >= 0; i--) in enable_hpd_clocks()
138 clk_disable_unprepare(hdmi->hpd_clks[i]); in enable_hpd_clocks()
142 int msm_hdmi_hpd_enable(struct drm_connector *connector) in msm_hdmi_hpd_enable() argument
144 struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector); in msm_hdmi_hpd_enable()
145 struct hdmi *hdmi = hdmi_connector->hdmi; in msm_hdmi_hpd_enable() local
146 const struct hdmi_platform_config *config = hdmi->config; in msm_hdmi_hpd_enable()
147 struct device *dev = &hdmi->pdev->dev; in msm_hdmi_hpd_enable()
152 for (i = 0; i < config->hpd_reg_cnt; i++) { in msm_hdmi_hpd_enable()
153 ret = regulator_enable(hdmi->hpd_regs[i]); in msm_hdmi_hpd_enable()
156 config->hpd_reg_names[i], ret); in msm_hdmi_hpd_enable()
167 ret = gpio_config(hdmi, true); in msm_hdmi_hpd_enable()
174 enable_hpd_clocks(hdmi, true); in msm_hdmi_hpd_enable()
176 msm_hdmi_set_mode(hdmi, false); in msm_hdmi_hpd_enable()
177 msm_hdmi_phy_reset(hdmi); in msm_hdmi_hpd_enable()
178 msm_hdmi_set_mode(hdmi, true); in msm_hdmi_hpd_enable()
180 hdmi_write(hdmi, REG_HDMI_USEC_REFTIMER, 0x0001001b); in msm_hdmi_hpd_enable()
183 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, in msm_hdmi_hpd_enable()
188 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hpd_enable()
189 hpd_ctrl = hdmi_read(hdmi, REG_HDMI_HPD_CTRL); in msm_hdmi_hpd_enable()
193 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, in msm_hdmi_hpd_enable()
195 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, in msm_hdmi_hpd_enable()
197 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hpd_enable()
207 struct hdmi *hdmi = hdmi_connector->hdmi; in hdp_disable() local
208 const struct hdmi_platform_config *config = hdmi->config; in hdp_disable()
209 struct device *dev = &hdmi->pdev->dev; in hdp_disable()
213 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, 0); in hdp_disable()
215 msm_hdmi_set_mode(hdmi, false); in hdp_disable()
217 enable_hpd_clocks(hdmi, false); in hdp_disable()
220 ret = gpio_config(hdmi, false); in hdp_disable()
228 for (i = 0; i < config->hpd_reg_cnt; i++) { in hdp_disable()
229 ret = regulator_disable(hdmi->hpd_regs[i]); in hdp_disable()
232 config->hpd_reg_names[i], ret); in hdp_disable()
241 struct drm_connector *connector = &hdmi_connector->base; in msm_hdmi_hotplug_work() local
242 drm_helper_hpd_irq_event(connector->dev); in msm_hdmi_hotplug_work()
245 void msm_hdmi_connector_irq(struct drm_connector *connector) in msm_hdmi_connector_irq() argument
247 struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector); in msm_hdmi_connector_irq()
248 struct hdmi *hdmi = hdmi_connector->hdmi; in msm_hdmi_connector_irq() local
252 hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS); in msm_hdmi_connector_irq()
253 hpd_int_ctrl = hdmi_read(hdmi, REG_HDMI_HPD_INT_CTRL); in msm_hdmi_connector_irq()
260 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, in msm_hdmi_connector_irq()
269 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, hpd_int_ctrl); in msm_hdmi_connector_irq()
271 queue_work(hdmi->workq, &hdmi_connector->hpd_work); in msm_hdmi_connector_irq()
275 static enum drm_connector_status detect_reg(struct hdmi *hdmi) in detect_reg() argument
279 pm_runtime_get_sync(&hdmi->pdev->dev); in detect_reg()
280 enable_hpd_clocks(hdmi, true); in detect_reg()
282 hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS); in detect_reg()
284 enable_hpd_clocks(hdmi, false); in detect_reg()
285 pm_runtime_put_autosuspend(&hdmi->pdev->dev); in detect_reg()
292 static enum drm_connector_status detect_gpio(struct hdmi *hdmi) in detect_gpio() argument
294 const struct hdmi_platform_config *config = hdmi->config; in detect_gpio()
295 struct hdmi_gpio_data hpd_gpio = config->gpios[HPD_GPIO_INDEX]; in detect_gpio()
303 struct drm_connector *connector, bool force) in hdmi_connector_detect() argument
305 struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector); in hdmi_connector_detect()
306 struct hdmi *hdmi = hdmi_connector->hdmi; in hdmi_connector_detect() local
307 const struct hdmi_platform_config *config = hdmi->config; in hdmi_connector_detect()
308 struct hdmi_gpio_data hpd_gpio = config->gpios[HPD_GPIO_INDEX]; in hdmi_connector_detect()
317 return detect_reg(hdmi); in hdmi_connector_detect()
320 stat_gpio = detect_gpio(hdmi); in hdmi_connector_detect()
321 stat_reg = detect_reg(hdmi); in hdmi_connector_detect()
327 } while (--retry); in hdmi_connector_detect()
330 * so trust that one the most if we didn't manage to get hdmi and in hdmi_connector_detect()
341 static void hdmi_connector_destroy(struct drm_connector *connector) in hdmi_connector_destroy() argument
343 struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector); in hdmi_connector_destroy()
347 drm_connector_cleanup(connector); in hdmi_connector_destroy()
352 static int msm_hdmi_connector_get_modes(struct drm_connector *connector) in msm_hdmi_connector_get_modes() argument
354 struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector); in msm_hdmi_connector_get_modes()
355 struct hdmi *hdmi = hdmi_connector->hdmi; in msm_hdmi_connector_get_modes() local
360 hdmi_ctrl = hdmi_read(hdmi, REG_HDMI_CTRL); in msm_hdmi_connector_get_modes()
361 hdmi_write(hdmi, REG_HDMI_CTRL, hdmi_ctrl | HDMI_CTRL_ENABLE); in msm_hdmi_connector_get_modes()
363 edid = drm_get_edid(connector, hdmi->i2c); in msm_hdmi_connector_get_modes()
365 hdmi_write(hdmi, REG_HDMI_CTRL, hdmi_ctrl); in msm_hdmi_connector_get_modes()
367 hdmi->hdmi_mode = drm_detect_hdmi_monitor(edid); in msm_hdmi_connector_get_modes()
368 drm_connector_update_edid_property(connector, edid); in msm_hdmi_connector_get_modes()
371 ret = drm_add_edid_modes(connector, edid); in msm_hdmi_connector_get_modes()
378 static int msm_hdmi_connector_mode_valid(struct drm_connector *connector, in msm_hdmi_connector_mode_valid() argument
381 struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector); in msm_hdmi_connector_mode_valid()
382 struct hdmi *hdmi = hdmi_connector->hdmi; in msm_hdmi_connector_mode_valid() local
383 const struct hdmi_platform_config *config = hdmi->config; in msm_hdmi_connector_mode_valid()
384 struct msm_drm_private *priv = connector->dev->dev_private; in msm_hdmi_connector_mode_valid()
385 struct msm_kms *kms = priv->kms; in msm_hdmi_connector_mode_valid()
388 requested = 1000 * mode->clock; in msm_hdmi_connector_mode_valid()
389 actual = kms->funcs->round_pixclk(kms, in msm_hdmi_connector_mode_valid()
390 requested, hdmi_connector->hdmi->encoder); in msm_hdmi_connector_mode_valid()
396 if (config->pwr_clk_cnt > 0) in msm_hdmi_connector_mode_valid()
397 actual = clk_round_rate(hdmi->pwr_clks[0], actual); in msm_hdmi_connector_mode_valid()
421 /* initialize connector */
422 struct drm_connector *msm_hdmi_connector_init(struct hdmi *hdmi) in msm_hdmi_connector_init() argument
424 struct drm_connector *connector = NULL; in msm_hdmi_connector_init() local
429 return ERR_PTR(-ENOMEM); in msm_hdmi_connector_init()
431 hdmi_connector->hdmi = hdmi; in msm_hdmi_connector_init()
432 INIT_WORK(&hdmi_connector->hpd_work, msm_hdmi_hotplug_work); in msm_hdmi_connector_init()
434 connector = &hdmi_connector->base; in msm_hdmi_connector_init()
436 drm_connector_init_with_ddc(hdmi->dev, connector, in msm_hdmi_connector_init()
439 hdmi->i2c); in msm_hdmi_connector_init()
440 drm_connector_helper_add(connector, &msm_hdmi_connector_helper_funcs); in msm_hdmi_connector_init()
442 connector->polled = DRM_CONNECTOR_POLL_CONNECT | in msm_hdmi_connector_init()
445 connector->interlace_allowed = 0; in msm_hdmi_connector_init()
446 connector->doublescan_allowed = 0; in msm_hdmi_connector_init()
448 drm_connector_attach_encoder(connector, hdmi->encoder); in msm_hdmi_connector_init()
450 return connector; in msm_hdmi_connector_init()