Lines Matching +full:hdmi +full:- +full:tx +full:- +full:8996
1 // SPDX-License-Identifier: GPL-2.0-only
14 #include <sound/hdmi-codec.h>
15 #include "hdmi.h"
17 void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on) in msm_hdmi_set_mode() argument
22 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_set_mode()
25 if (!hdmi->hdmi_mode) { in msm_hdmi_set_mode()
27 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl); in msm_hdmi_set_mode()
36 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl); in msm_hdmi_set_mode()
37 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_set_mode()
38 DBG("HDMI Core: %s, HDMI_CTRL=0x%08x", in msm_hdmi_set_mode()
44 struct hdmi *hdmi = dev_id; in msm_hdmi_irq() local
47 msm_hdmi_hpd_irq(hdmi->bridge); in msm_hdmi_irq()
50 msm_hdmi_i2c_irq(hdmi->i2c); in msm_hdmi_irq()
53 if (hdmi->hdcp_ctrl) in msm_hdmi_irq()
54 msm_hdmi_hdcp_irq(hdmi->hdcp_ctrl); in msm_hdmi_irq()
61 static void msm_hdmi_destroy(struct hdmi *hdmi) in msm_hdmi_destroy() argument
67 if (hdmi->workq) in msm_hdmi_destroy()
68 destroy_workqueue(hdmi->workq); in msm_hdmi_destroy()
69 msm_hdmi_hdcp_destroy(hdmi); in msm_hdmi_destroy()
71 if (hdmi->phy_dev) { in msm_hdmi_destroy()
72 put_device(hdmi->phy_dev); in msm_hdmi_destroy()
73 hdmi->phy = NULL; in msm_hdmi_destroy()
74 hdmi->phy_dev = NULL; in msm_hdmi_destroy()
77 if (hdmi->i2c) in msm_hdmi_destroy()
78 msm_hdmi_i2c_destroy(hdmi->i2c); in msm_hdmi_destroy()
80 platform_set_drvdata(hdmi->pdev, NULL); in msm_hdmi_destroy()
83 static int msm_hdmi_get_phy(struct hdmi *hdmi) in msm_hdmi_get_phy() argument
85 struct platform_device *pdev = hdmi->pdev; in msm_hdmi_get_phy()
89 phy_node = of_parse_phandle(pdev->dev.of_node, "phys", 0); in msm_hdmi_get_phy()
91 DRM_DEV_ERROR(&pdev->dev, "cannot find phy device\n"); in msm_hdmi_get_phy()
92 return -ENXIO; in msm_hdmi_get_phy()
97 hdmi->phy = platform_get_drvdata(phy_pdev); in msm_hdmi_get_phy()
102 DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n"); in msm_hdmi_get_phy()
103 return -EPROBE_DEFER; in msm_hdmi_get_phy()
105 if (!hdmi->phy) { in msm_hdmi_get_phy()
106 DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n"); in msm_hdmi_get_phy()
107 put_device(&phy_pdev->dev); in msm_hdmi_get_phy()
108 return -EPROBE_DEFER; in msm_hdmi_get_phy()
111 hdmi->phy_dev = get_device(&phy_pdev->dev); in msm_hdmi_get_phy()
116 /* construct hdmi at bind/probe time, grab all the resources. If
120 static struct hdmi *msm_hdmi_init(struct platform_device *pdev) in msm_hdmi_init()
122 struct hdmi_platform_config *config = pdev->dev.platform_data; in msm_hdmi_init()
123 struct hdmi *hdmi = NULL; in msm_hdmi_init() local
127 hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); in msm_hdmi_init()
128 if (!hdmi) { in msm_hdmi_init()
129 ret = -ENOMEM; in msm_hdmi_init()
133 hdmi->pdev = pdev; in msm_hdmi_init()
134 hdmi->config = config; in msm_hdmi_init()
135 spin_lock_init(&hdmi->reg_lock); in msm_hdmi_init()
137 ret = drm_of_find_panel_or_bridge(pdev->dev.of_node, 1, 0, NULL, &hdmi->next_bridge); in msm_hdmi_init()
138 if (ret && ret != -ENODEV) in msm_hdmi_init()
141 hdmi->mmio = msm_ioremap(pdev, config->mmio_name); in msm_hdmi_init()
142 if (IS_ERR(hdmi->mmio)) { in msm_hdmi_init()
143 ret = PTR_ERR(hdmi->mmio); in msm_hdmi_init()
147 /* HDCP needs physical address of hdmi register */ in msm_hdmi_init()
149 config->mmio_name); in msm_hdmi_init()
151 ret = -EINVAL; in msm_hdmi_init()
154 hdmi->mmio_phy_addr = res->start; in msm_hdmi_init()
156 hdmi->qfprom_mmio = msm_ioremap(pdev, config->qfprom_mmio_name); in msm_hdmi_init()
157 if (IS_ERR(hdmi->qfprom_mmio)) { in msm_hdmi_init()
158 DRM_DEV_INFO(&pdev->dev, "can't find qfprom resource\n"); in msm_hdmi_init()
159 hdmi->qfprom_mmio = NULL; in msm_hdmi_init()
162 hdmi->hpd_regs = devm_kcalloc(&pdev->dev, in msm_hdmi_init()
163 config->hpd_reg_cnt, in msm_hdmi_init()
164 sizeof(hdmi->hpd_regs[0]), in msm_hdmi_init()
166 if (!hdmi->hpd_regs) { in msm_hdmi_init()
167 ret = -ENOMEM; in msm_hdmi_init()
170 for (i = 0; i < config->hpd_reg_cnt; i++) in msm_hdmi_init()
171 hdmi->hpd_regs[i].supply = config->hpd_reg_names[i]; in msm_hdmi_init()
173 ret = devm_regulator_bulk_get(&pdev->dev, config->hpd_reg_cnt, hdmi->hpd_regs); in msm_hdmi_init()
175 DRM_DEV_ERROR(&pdev->dev, "failed to get hpd regulator: %d\n", ret); in msm_hdmi_init()
179 hdmi->pwr_regs = devm_kcalloc(&pdev->dev, in msm_hdmi_init()
180 config->pwr_reg_cnt, in msm_hdmi_init()
181 sizeof(hdmi->pwr_regs[0]), in msm_hdmi_init()
183 if (!hdmi->pwr_regs) { in msm_hdmi_init()
184 ret = -ENOMEM; in msm_hdmi_init()
188 for (i = 0; i < config->pwr_reg_cnt; i++) in msm_hdmi_init()
189 hdmi->pwr_regs[i].supply = config->pwr_reg_names[i]; in msm_hdmi_init()
191 ret = devm_regulator_bulk_get(&pdev->dev, config->pwr_reg_cnt, hdmi->pwr_regs); in msm_hdmi_init()
193 DRM_DEV_ERROR(&pdev->dev, "failed to get pwr regulator: %d\n", ret); in msm_hdmi_init()
197 hdmi->hpd_clks = devm_kcalloc(&pdev->dev, in msm_hdmi_init()
198 config->hpd_clk_cnt, in msm_hdmi_init()
199 sizeof(hdmi->hpd_clks[0]), in msm_hdmi_init()
201 if (!hdmi->hpd_clks) { in msm_hdmi_init()
202 ret = -ENOMEM; in msm_hdmi_init()
205 for (i = 0; i < config->hpd_clk_cnt; i++) { in msm_hdmi_init()
208 clk = msm_clk_get(pdev, config->hpd_clk_names[i]); in msm_hdmi_init()
211 DRM_DEV_ERROR(&pdev->dev, "failed to get hpd clk: %s (%d)\n", in msm_hdmi_init()
212 config->hpd_clk_names[i], ret); in msm_hdmi_init()
216 hdmi->hpd_clks[i] = clk; in msm_hdmi_init()
219 hdmi->pwr_clks = devm_kcalloc(&pdev->dev, in msm_hdmi_init()
220 config->pwr_clk_cnt, in msm_hdmi_init()
221 sizeof(hdmi->pwr_clks[0]), in msm_hdmi_init()
223 if (!hdmi->pwr_clks) { in msm_hdmi_init()
224 ret = -ENOMEM; in msm_hdmi_init()
227 for (i = 0; i < config->pwr_clk_cnt; i++) { in msm_hdmi_init()
230 clk = msm_clk_get(pdev, config->pwr_clk_names[i]); in msm_hdmi_init()
233 DRM_DEV_ERROR(&pdev->dev, "failed to get pwr clk: %s (%d)\n", in msm_hdmi_init()
234 config->pwr_clk_names[i], ret); in msm_hdmi_init()
238 hdmi->pwr_clks[i] = clk; in msm_hdmi_init()
241 hdmi->hpd_gpiod = devm_gpiod_get_optional(&pdev->dev, "hpd", GPIOD_IN); in msm_hdmi_init()
242 /* This will catch e.g. -EPROBE_DEFER */ in msm_hdmi_init()
243 if (IS_ERR(hdmi->hpd_gpiod)) { in msm_hdmi_init()
244 ret = PTR_ERR(hdmi->hpd_gpiod); in msm_hdmi_init()
245 DRM_DEV_ERROR(&pdev->dev, "failed to get hpd gpio: (%d)\n", ret); in msm_hdmi_init()
249 if (!hdmi->hpd_gpiod) in msm_hdmi_init()
252 if (hdmi->hpd_gpiod) in msm_hdmi_init()
253 gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); in msm_hdmi_init()
255 pm_runtime_enable(&pdev->dev); in msm_hdmi_init()
257 hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0); in msm_hdmi_init()
259 hdmi->i2c = msm_hdmi_i2c_init(hdmi); in msm_hdmi_init()
260 if (IS_ERR(hdmi->i2c)) { in msm_hdmi_init()
261 ret = PTR_ERR(hdmi->i2c); in msm_hdmi_init()
262 DRM_DEV_ERROR(&pdev->dev, "failed to get i2c: %d\n", ret); in msm_hdmi_init()
263 hdmi->i2c = NULL; in msm_hdmi_init()
267 ret = msm_hdmi_get_phy(hdmi); in msm_hdmi_init()
269 DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n"); in msm_hdmi_init()
273 hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi); in msm_hdmi_init()
274 if (IS_ERR(hdmi->hdcp_ctrl)) { in msm_hdmi_init()
275 dev_warn(&pdev->dev, "failed to init hdcp: disabled\n"); in msm_hdmi_init()
276 hdmi->hdcp_ctrl = NULL; in msm_hdmi_init()
279 return hdmi; in msm_hdmi_init()
282 if (hdmi) in msm_hdmi_init()
283 msm_hdmi_destroy(hdmi); in msm_hdmi_init()
290 * driver (not hdmi sub-device's probe/bind!)
294 * hdmi sub-device's probe.
296 int msm_hdmi_modeset_init(struct hdmi *hdmi, in msm_hdmi_modeset_init() argument
299 struct msm_drm_private *priv = dev->dev_private; in msm_hdmi_modeset_init()
300 struct platform_device *pdev = hdmi->pdev; in msm_hdmi_modeset_init()
303 if (priv->num_bridges == ARRAY_SIZE(priv->bridges)) { in msm_hdmi_modeset_init()
304 DRM_DEV_ERROR(dev->dev, "too many bridges\n"); in msm_hdmi_modeset_init()
305 return -ENOSPC; in msm_hdmi_modeset_init()
308 hdmi->dev = dev; in msm_hdmi_modeset_init()
309 hdmi->encoder = encoder; in msm_hdmi_modeset_init()
311 hdmi_audio_infoframe_init(&hdmi->audio.infoframe); in msm_hdmi_modeset_init()
313 hdmi->bridge = msm_hdmi_bridge_init(hdmi); in msm_hdmi_modeset_init()
314 if (IS_ERR(hdmi->bridge)) { in msm_hdmi_modeset_init()
315 ret = PTR_ERR(hdmi->bridge); in msm_hdmi_modeset_init()
316 DRM_DEV_ERROR(dev->dev, "failed to create HDMI bridge: %d\n", ret); in msm_hdmi_modeset_init()
317 hdmi->bridge = NULL; in msm_hdmi_modeset_init()
321 if (hdmi->next_bridge) { in msm_hdmi_modeset_init()
322 ret = drm_bridge_attach(hdmi->encoder, hdmi->next_bridge, hdmi->bridge, in msm_hdmi_modeset_init()
325 DRM_DEV_ERROR(dev->dev, "failed to attach next HDMI bridge: %d\n", ret); in msm_hdmi_modeset_init()
330 hdmi->connector = drm_bridge_connector_init(hdmi->dev, encoder); in msm_hdmi_modeset_init()
331 if (IS_ERR(hdmi->connector)) { in msm_hdmi_modeset_init()
332 ret = PTR_ERR(hdmi->connector); in msm_hdmi_modeset_init()
333 DRM_DEV_ERROR(dev->dev, "failed to create HDMI connector: %d\n", ret); in msm_hdmi_modeset_init()
334 hdmi->connector = NULL; in msm_hdmi_modeset_init()
338 drm_connector_attach_encoder(hdmi->connector, hdmi->encoder); in msm_hdmi_modeset_init()
340 hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); in msm_hdmi_modeset_init()
341 if (!hdmi->irq) { in msm_hdmi_modeset_init()
342 ret = -EINVAL; in msm_hdmi_modeset_init()
343 DRM_DEV_ERROR(dev->dev, "failed to get irq\n"); in msm_hdmi_modeset_init()
347 ret = devm_request_irq(dev->dev, hdmi->irq, in msm_hdmi_modeset_init()
349 "hdmi_isr", hdmi); in msm_hdmi_modeset_init()
351 DRM_DEV_ERROR(dev->dev, "failed to request IRQ%u: %d\n", in msm_hdmi_modeset_init()
352 hdmi->irq, ret); in msm_hdmi_modeset_init()
356 drm_bridge_connector_enable_hpd(hdmi->connector); in msm_hdmi_modeset_init()
358 ret = msm_hdmi_hpd_enable(hdmi->bridge); in msm_hdmi_modeset_init()
360 DRM_DEV_ERROR(&hdmi->pdev->dev, "failed to enable HPD: %d\n", ret); in msm_hdmi_modeset_init()
364 priv->bridges[priv->num_bridges++] = hdmi->bridge; in msm_hdmi_modeset_init()
366 platform_set_drvdata(pdev, hdmi); in msm_hdmi_modeset_init()
372 if (hdmi->bridge) { in msm_hdmi_modeset_init()
373 msm_hdmi_bridge_destroy(hdmi->bridge); in msm_hdmi_modeset_init()
374 hdmi->bridge = NULL; in msm_hdmi_modeset_init()
376 if (hdmi->connector) { in msm_hdmi_modeset_init()
377 hdmi->connector->funcs->destroy(hdmi->connector); in msm_hdmi_modeset_init()
378 hdmi->connector = NULL; in msm_hdmi_modeset_init()
385 * The hdmi device:
392 static const char *hpd_reg_names_8960[] = {"core-vdda"};
400 static const char *pwr_reg_names_8x74[] = {"core-vdda", "core-vcc"};
413 * HDMI audio codec callbacks
419 struct hdmi *hdmi = dev_get_drvdata(dev); in msm_hdmi_audio_hw_params() local
426 DRM_DEV_DEBUG(dev, "%u Hz, %d bit, %d channels\n", params->sample_rate, in msm_hdmi_audio_hw_params()
427 params->sample_width, params->cea.channels); in msm_hdmi_audio_hw_params()
429 switch (params->cea.channels) { in msm_hdmi_audio_hw_params()
451 return -EINVAL; in msm_hdmi_audio_hw_params()
454 switch (params->sample_rate) { in msm_hdmi_audio_hw_params()
478 params->sample_rate); in msm_hdmi_audio_hw_params()
479 return -EINVAL; in msm_hdmi_audio_hw_params()
482 msm_hdmi_audio_set_sample_rate(hdmi, rate); in msm_hdmi_audio_hw_params()
483 msm_hdmi_audio_info_setup(hdmi, 1, chan, channel_allocation, in msm_hdmi_audio_hw_params()
491 struct hdmi *hdmi = dev_get_drvdata(dev); in msm_hdmi_audio_shutdown() local
493 msm_hdmi_audio_info_setup(hdmi, 0, 0, 0, 0, 0); in msm_hdmi_audio_shutdown()
507 static int msm_hdmi_register_audio_driver(struct hdmi *hdmi, struct device *dev) in msm_hdmi_register_audio_driver() argument
509 hdmi->audio_pdev = platform_device_register_data(dev, in msm_hdmi_register_audio_driver()
514 return PTR_ERR_OR_ZERO(hdmi->audio_pdev); in msm_hdmi_register_audio_driver()
521 struct hdmi *hdmi; in msm_hdmi_bind() local
522 struct device_node *of_node = dev->of_node; in msm_hdmi_bind()
529 return -ENXIO; in msm_hdmi_bind()
532 hdmi_cfg->mmio_name = "core_physical"; in msm_hdmi_bind()
533 hdmi_cfg->qfprom_mmio_name = "qfprom_physical"; in msm_hdmi_bind()
535 dev->platform_data = hdmi_cfg; in msm_hdmi_bind()
537 hdmi = msm_hdmi_init(to_platform_device(dev)); in msm_hdmi_bind()
538 if (IS_ERR(hdmi)) in msm_hdmi_bind()
539 return PTR_ERR(hdmi); in msm_hdmi_bind()
540 priv->hdmi = hdmi; in msm_hdmi_bind()
542 err = msm_hdmi_register_audio_driver(hdmi, dev); in msm_hdmi_bind()
545 hdmi->audio_pdev = NULL; in msm_hdmi_bind()
556 if (priv->hdmi) { in msm_hdmi_unbind()
557 if (priv->hdmi->audio_pdev) in msm_hdmi_unbind()
558 platform_device_unregister(priv->hdmi->audio_pdev); in msm_hdmi_unbind()
560 msm_hdmi_destroy(priv->hdmi); in msm_hdmi_unbind()
561 priv->hdmi = NULL; in msm_hdmi_unbind()
572 return component_add(&pdev->dev, &msm_hdmi_ops); in msm_hdmi_dev_probe()
577 component_del(&pdev->dev, &msm_hdmi_ops); in msm_hdmi_dev_remove()
582 { .compatible = "qcom,hdmi-tx-8996", .data = &hdmi_tx_8974_config },
583 { .compatible = "qcom,hdmi-tx-8994", .data = &hdmi_tx_8974_config },
584 { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8974_config },
585 { .compatible = "qcom,hdmi-tx-8974", .data = &hdmi_tx_8974_config },
586 { .compatible = "qcom,hdmi-tx-8960", .data = &hdmi_tx_8960_config },
587 { .compatible = "qcom,hdmi-tx-8660", .data = &hdmi_tx_8960_config },