Lines Matching +full:hdmi +full:- +full:tx

1 // SPDX-License-Identifier: GPL-2.0-only
16 #include <sound/hdmi-codec.h>
17 #include "hdmi.h"
19 void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on) in msm_hdmi_set_mode() argument
24 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_set_mode()
27 if (!hdmi->hdmi_mode) { in msm_hdmi_set_mode()
29 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl); in msm_hdmi_set_mode()
38 hdmi_write(hdmi, REG_HDMI_CTRL, ctrl); in msm_hdmi_set_mode()
39 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_set_mode()
40 DBG("HDMI Core: %s, HDMI_CTRL=0x%08x", in msm_hdmi_set_mode()
46 struct hdmi *hdmi = dev_id; in msm_hdmi_irq() local
49 msm_hdmi_hpd_irq(hdmi->bridge); in msm_hdmi_irq()
52 msm_hdmi_i2c_irq(hdmi->i2c); in msm_hdmi_irq()
55 if (hdmi->hdcp_ctrl) in msm_hdmi_irq()
56 msm_hdmi_hdcp_irq(hdmi->hdcp_ctrl); in msm_hdmi_irq()
63 static void msm_hdmi_destroy(struct hdmi *hdmi) in msm_hdmi_destroy() argument
69 if (hdmi->workq) in msm_hdmi_destroy()
70 destroy_workqueue(hdmi->workq); in msm_hdmi_destroy()
71 msm_hdmi_hdcp_destroy(hdmi); in msm_hdmi_destroy()
73 if (hdmi->i2c) in msm_hdmi_destroy()
74 msm_hdmi_i2c_destroy(hdmi->i2c); in msm_hdmi_destroy()
77 static void msm_hdmi_put_phy(struct hdmi *hdmi) in msm_hdmi_put_phy() argument
79 if (hdmi->phy_dev) { in msm_hdmi_put_phy()
80 put_device(hdmi->phy_dev); in msm_hdmi_put_phy()
81 hdmi->phy = NULL; in msm_hdmi_put_phy()
82 hdmi->phy_dev = NULL; in msm_hdmi_put_phy()
86 static int msm_hdmi_get_phy(struct hdmi *hdmi) in msm_hdmi_get_phy() argument
88 struct platform_device *pdev = hdmi->pdev; in msm_hdmi_get_phy()
92 phy_node = of_parse_phandle(pdev->dev.of_node, "phys", 0); in msm_hdmi_get_phy()
94 DRM_DEV_ERROR(&pdev->dev, "cannot find phy device\n"); in msm_hdmi_get_phy()
95 return -ENXIO; in msm_hdmi_get_phy()
102 return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n"); in msm_hdmi_get_phy()
104 hdmi->phy = platform_get_drvdata(phy_pdev); in msm_hdmi_get_phy()
105 if (!hdmi->phy) { in msm_hdmi_get_phy()
106 put_device(&phy_pdev->dev); in msm_hdmi_get_phy()
107 return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n"); in msm_hdmi_get_phy()
110 hdmi->phy_dev = &phy_pdev->dev; in msm_hdmi_get_phy()
115 /* construct hdmi at bind/probe time, grab all the resources. If
119 static int msm_hdmi_init(struct hdmi *hdmi) in msm_hdmi_init() argument
121 struct platform_device *pdev = hdmi->pdev; in msm_hdmi_init()
124 hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0); in msm_hdmi_init()
125 if (!hdmi->workq) { in msm_hdmi_init()
126 ret = -ENOMEM; in msm_hdmi_init()
130 hdmi->i2c = msm_hdmi_i2c_init(hdmi); in msm_hdmi_init()
131 if (IS_ERR(hdmi->i2c)) { in msm_hdmi_init()
132 ret = PTR_ERR(hdmi->i2c); in msm_hdmi_init()
133 DRM_DEV_ERROR(&pdev->dev, "failed to get i2c: %d\n", ret); in msm_hdmi_init()
134 hdmi->i2c = NULL; in msm_hdmi_init()
138 hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi); in msm_hdmi_init()
139 if (IS_ERR(hdmi->hdcp_ctrl)) { in msm_hdmi_init()
140 dev_warn(&pdev->dev, "failed to init hdcp: disabled\n"); in msm_hdmi_init()
141 hdmi->hdcp_ctrl = NULL; in msm_hdmi_init()
147 msm_hdmi_destroy(hdmi); in msm_hdmi_init()
154 * driver (not hdmi sub-device's probe/bind!)
158 * hdmi sub-device's probe.
160 int msm_hdmi_modeset_init(struct hdmi *hdmi, in msm_hdmi_modeset_init() argument
163 struct msm_drm_private *priv = dev->dev_private; in msm_hdmi_modeset_init()
166 if (priv->num_bridges == ARRAY_SIZE(priv->bridges)) { in msm_hdmi_modeset_init()
167 DRM_DEV_ERROR(dev->dev, "too many bridges\n"); in msm_hdmi_modeset_init()
168 return -ENOSPC; in msm_hdmi_modeset_init()
171 hdmi->dev = dev; in msm_hdmi_modeset_init()
172 hdmi->encoder = encoder; in msm_hdmi_modeset_init()
174 hdmi_audio_infoframe_init(&hdmi->audio.infoframe); in msm_hdmi_modeset_init()
176 hdmi->bridge = msm_hdmi_bridge_init(hdmi); in msm_hdmi_modeset_init()
177 if (IS_ERR(hdmi->bridge)) { in msm_hdmi_modeset_init()
178 ret = PTR_ERR(hdmi->bridge); in msm_hdmi_modeset_init()
179 DRM_DEV_ERROR(dev->dev, "failed to create HDMI bridge: %d\n", ret); in msm_hdmi_modeset_init()
180 hdmi->bridge = NULL; in msm_hdmi_modeset_init()
184 if (hdmi->next_bridge) { in msm_hdmi_modeset_init()
185 ret = drm_bridge_attach(hdmi->encoder, hdmi->next_bridge, hdmi->bridge, in msm_hdmi_modeset_init()
188 DRM_DEV_ERROR(dev->dev, "failed to attach next HDMI bridge: %d\n", ret); in msm_hdmi_modeset_init()
193 hdmi->connector = drm_bridge_connector_init(hdmi->dev, encoder); in msm_hdmi_modeset_init()
194 if (IS_ERR(hdmi->connector)) { in msm_hdmi_modeset_init()
195 ret = PTR_ERR(hdmi->connector); in msm_hdmi_modeset_init()
196 DRM_DEV_ERROR(dev->dev, "failed to create HDMI connector: %d\n", ret); in msm_hdmi_modeset_init()
197 hdmi->connector = NULL; in msm_hdmi_modeset_init()
201 drm_connector_attach_encoder(hdmi->connector, hdmi->encoder); in msm_hdmi_modeset_init()
203 ret = devm_request_irq(dev->dev, hdmi->irq, in msm_hdmi_modeset_init()
205 "hdmi_isr", hdmi); in msm_hdmi_modeset_init()
207 DRM_DEV_ERROR(dev->dev, "failed to request IRQ%u: %d\n", in msm_hdmi_modeset_init()
208 hdmi->irq, ret); in msm_hdmi_modeset_init()
212 ret = msm_hdmi_hpd_enable(hdmi->bridge); in msm_hdmi_modeset_init()
214 DRM_DEV_ERROR(&hdmi->pdev->dev, "failed to enable HPD: %d\n", ret); in msm_hdmi_modeset_init()
218 priv->bridges[priv->num_bridges++] = hdmi->bridge; in msm_hdmi_modeset_init()
224 if (hdmi->bridge) { in msm_hdmi_modeset_init()
225 msm_hdmi_bridge_destroy(hdmi->bridge); in msm_hdmi_modeset_init()
226 hdmi->bridge = NULL; in msm_hdmi_modeset_init()
228 if (hdmi->connector) { in msm_hdmi_modeset_init()
229 hdmi->connector->funcs->destroy(hdmi->connector); in msm_hdmi_modeset_init()
230 hdmi->connector = NULL; in msm_hdmi_modeset_init()
237 * The hdmi device:
244 static const char *hpd_reg_names_8960[] = {"core-vdda"};
252 static const char *pwr_reg_names_8x74[] = {"core-vdda", "core-vcc"};
265 * HDMI audio codec callbacks
271 struct hdmi *hdmi = dev_get_drvdata(dev); in msm_hdmi_audio_hw_params() local
278 DRM_DEV_DEBUG(dev, "%u Hz, %d bit, %d channels\n", params->sample_rate, in msm_hdmi_audio_hw_params()
279 params->sample_width, params->cea.channels); in msm_hdmi_audio_hw_params()
281 switch (params->cea.channels) { in msm_hdmi_audio_hw_params()
303 return -EINVAL; in msm_hdmi_audio_hw_params()
306 switch (params->sample_rate) { in msm_hdmi_audio_hw_params()
330 params->sample_rate); in msm_hdmi_audio_hw_params()
331 return -EINVAL; in msm_hdmi_audio_hw_params()
334 msm_hdmi_audio_set_sample_rate(hdmi, rate); in msm_hdmi_audio_hw_params()
335 msm_hdmi_audio_info_setup(hdmi, 1, chan, channel_allocation, in msm_hdmi_audio_hw_params()
343 struct hdmi *hdmi = dev_get_drvdata(dev); in msm_hdmi_audio_shutdown() local
345 msm_hdmi_audio_info_setup(hdmi, 0, 0, 0, 0, 0); in msm_hdmi_audio_shutdown()
359 static int msm_hdmi_register_audio_driver(struct hdmi *hdmi, struct device *dev) in msm_hdmi_register_audio_driver() argument
361 hdmi->audio_pdev = platform_device_register_data(dev, in msm_hdmi_register_audio_driver()
366 return PTR_ERR_OR_ZERO(hdmi->audio_pdev); in msm_hdmi_register_audio_driver()
372 struct hdmi *hdmi = dev_get_drvdata(dev); in msm_hdmi_bind() local
375 err = msm_hdmi_init(hdmi); in msm_hdmi_bind()
378 priv->hdmi = hdmi; in msm_hdmi_bind()
380 err = msm_hdmi_register_audio_driver(hdmi, dev); in msm_hdmi_bind()
383 hdmi->audio_pdev = NULL; in msm_hdmi_bind()
394 if (priv->hdmi) { in msm_hdmi_unbind()
395 if (priv->hdmi->audio_pdev) in msm_hdmi_unbind()
396 platform_device_unregister(priv->hdmi->audio_pdev); in msm_hdmi_unbind()
398 msm_hdmi_destroy(priv->hdmi); in msm_hdmi_unbind()
399 priv->hdmi = NULL; in msm_hdmi_unbind()
411 struct device *dev = &pdev->dev; in msm_hdmi_dev_probe()
412 struct hdmi *hdmi; in msm_hdmi_dev_probe() local
418 return -EINVAL; in msm_hdmi_dev_probe()
420 hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); in msm_hdmi_dev_probe()
421 if (!hdmi) in msm_hdmi_dev_probe()
422 return -ENOMEM; in msm_hdmi_dev_probe()
424 hdmi->pdev = pdev; in msm_hdmi_dev_probe()
425 hdmi->config = config; in msm_hdmi_dev_probe()
426 spin_lock_init(&hdmi->reg_lock); in msm_hdmi_dev_probe()
428 ret = drm_of_find_panel_or_bridge(pdev->dev.of_node, 1, 0, NULL, &hdmi->next_bridge); in msm_hdmi_dev_probe()
429 if (ret && ret != -ENODEV) in msm_hdmi_dev_probe()
432 hdmi->mmio = msm_ioremap(pdev, "core_physical"); in msm_hdmi_dev_probe()
433 if (IS_ERR(hdmi->mmio)) in msm_hdmi_dev_probe()
434 return PTR_ERR(hdmi->mmio); in msm_hdmi_dev_probe()
436 /* HDCP needs physical address of hdmi register */ in msm_hdmi_dev_probe()
440 return -EINVAL; in msm_hdmi_dev_probe()
441 hdmi->mmio_phy_addr = res->start; in msm_hdmi_dev_probe()
443 hdmi->qfprom_mmio = msm_ioremap(pdev, "qfprom_physical"); in msm_hdmi_dev_probe()
444 if (IS_ERR(hdmi->qfprom_mmio)) { in msm_hdmi_dev_probe()
445 DRM_DEV_INFO(&pdev->dev, "can't find qfprom resource\n"); in msm_hdmi_dev_probe()
446 hdmi->qfprom_mmio = NULL; in msm_hdmi_dev_probe()
449 hdmi->irq = platform_get_irq(pdev, 0); in msm_hdmi_dev_probe()
450 if (hdmi->irq < 0) in msm_hdmi_dev_probe()
451 return hdmi->irq; in msm_hdmi_dev_probe()
453 hdmi->hpd_regs = devm_kcalloc(&pdev->dev, in msm_hdmi_dev_probe()
454 config->hpd_reg_cnt, in msm_hdmi_dev_probe()
455 sizeof(hdmi->hpd_regs[0]), in msm_hdmi_dev_probe()
457 if (!hdmi->hpd_regs) in msm_hdmi_dev_probe()
458 return -ENOMEM; in msm_hdmi_dev_probe()
460 for (i = 0; i < config->hpd_reg_cnt; i++) in msm_hdmi_dev_probe()
461 hdmi->hpd_regs[i].supply = config->hpd_reg_names[i]; in msm_hdmi_dev_probe()
463 ret = devm_regulator_bulk_get(&pdev->dev, config->hpd_reg_cnt, hdmi->hpd_regs); in msm_hdmi_dev_probe()
467 hdmi->pwr_regs = devm_kcalloc(&pdev->dev, in msm_hdmi_dev_probe()
468 config->pwr_reg_cnt, in msm_hdmi_dev_probe()
469 sizeof(hdmi->pwr_regs[0]), in msm_hdmi_dev_probe()
471 if (!hdmi->pwr_regs) in msm_hdmi_dev_probe()
472 return -ENOMEM; in msm_hdmi_dev_probe()
474 for (i = 0; i < config->pwr_reg_cnt; i++) in msm_hdmi_dev_probe()
475 hdmi->pwr_regs[i].supply = config->pwr_reg_names[i]; in msm_hdmi_dev_probe()
477 ret = devm_regulator_bulk_get(&pdev->dev, config->pwr_reg_cnt, hdmi->pwr_regs); in msm_hdmi_dev_probe()
481 hdmi->hpd_clks = devm_kcalloc(&pdev->dev, in msm_hdmi_dev_probe()
482 config->hpd_clk_cnt, in msm_hdmi_dev_probe()
483 sizeof(hdmi->hpd_clks[0]), in msm_hdmi_dev_probe()
485 if (!hdmi->hpd_clks) in msm_hdmi_dev_probe()
486 return -ENOMEM; in msm_hdmi_dev_probe()
488 for (i = 0; i < config->hpd_clk_cnt; i++) { in msm_hdmi_dev_probe()
491 clk = msm_clk_get(pdev, config->hpd_clk_names[i]); in msm_hdmi_dev_probe()
495 config->hpd_clk_names[i]); in msm_hdmi_dev_probe()
497 hdmi->hpd_clks[i] = clk; in msm_hdmi_dev_probe()
500 hdmi->pwr_clks = devm_kcalloc(&pdev->dev, in msm_hdmi_dev_probe()
501 config->pwr_clk_cnt, in msm_hdmi_dev_probe()
502 sizeof(hdmi->pwr_clks[0]), in msm_hdmi_dev_probe()
504 if (!hdmi->pwr_clks) in msm_hdmi_dev_probe()
505 return -ENOMEM; in msm_hdmi_dev_probe()
507 for (i = 0; i < config->pwr_clk_cnt; i++) { in msm_hdmi_dev_probe()
510 clk = msm_clk_get(pdev, config->pwr_clk_names[i]); in msm_hdmi_dev_probe()
514 config->pwr_clk_names[i]); in msm_hdmi_dev_probe()
516 hdmi->pwr_clks[i] = clk; in msm_hdmi_dev_probe()
519 hdmi->hpd_gpiod = devm_gpiod_get_optional(&pdev->dev, "hpd", GPIOD_IN); in msm_hdmi_dev_probe()
520 /* This will catch e.g. -EPROBE_DEFER */ in msm_hdmi_dev_probe()
521 if (IS_ERR(hdmi->hpd_gpiod)) in msm_hdmi_dev_probe()
522 return dev_err_probe(dev, PTR_ERR(hdmi->hpd_gpiod), in msm_hdmi_dev_probe()
525 if (!hdmi->hpd_gpiod) in msm_hdmi_dev_probe()
528 if (hdmi->hpd_gpiod) in msm_hdmi_dev_probe()
529 gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); in msm_hdmi_dev_probe()
531 ret = msm_hdmi_get_phy(hdmi); in msm_hdmi_dev_probe()
533 DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n"); in msm_hdmi_dev_probe()
537 ret = devm_pm_runtime_enable(&pdev->dev); in msm_hdmi_dev_probe()
541 platform_set_drvdata(pdev, hdmi); in msm_hdmi_dev_probe()
543 ret = component_add(&pdev->dev, &msm_hdmi_ops); in msm_hdmi_dev_probe()
550 msm_hdmi_put_phy(hdmi); in msm_hdmi_dev_probe()
556 struct hdmi *hdmi = dev_get_drvdata(&pdev->dev); in msm_hdmi_dev_remove() local
558 component_del(&pdev->dev, &msm_hdmi_ops); in msm_hdmi_dev_remove()
560 msm_hdmi_put_phy(hdmi); in msm_hdmi_dev_remove()
566 { .compatible = "qcom,hdmi-tx-8996", .data = &hdmi_tx_8974_config },
567 { .compatible = "qcom,hdmi-tx-8994", .data = &hdmi_tx_8974_config },
568 { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8974_config },
569 { .compatible = "qcom,hdmi-tx-8974", .data = &hdmi_tx_8974_config },
570 { .compatible = "qcom,hdmi-tx-8960", .data = &hdmi_tx_8960_config },
571 { .compatible = "qcom,hdmi-tx-8660", .data = &hdmi_tx_8960_config },