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

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
165 hdmi->dev = dev; in msm_hdmi_modeset_init()
166 hdmi->encoder = encoder; in msm_hdmi_modeset_init()
168 hdmi_audio_infoframe_init(&hdmi->audio.infoframe); in msm_hdmi_modeset_init()
170 ret = msm_hdmi_bridge_init(hdmi); in msm_hdmi_modeset_init()
172 DRM_DEV_ERROR(dev->dev, "failed to create HDMI bridge: %d\n", ret); in msm_hdmi_modeset_init()
176 if (hdmi->next_bridge) { in msm_hdmi_modeset_init()
177 ret = drm_bridge_attach(hdmi->encoder, hdmi->next_bridge, hdmi->bridge, in msm_hdmi_modeset_init()
180 DRM_DEV_ERROR(dev->dev, "failed to attach next HDMI bridge: %d\n", ret); in msm_hdmi_modeset_init()
185 hdmi->connector = drm_bridge_connector_init(hdmi->dev, encoder); in msm_hdmi_modeset_init()
186 if (IS_ERR(hdmi->connector)) { in msm_hdmi_modeset_init()
187 ret = PTR_ERR(hdmi->connector); in msm_hdmi_modeset_init()
188 DRM_DEV_ERROR(dev->dev, "failed to create HDMI connector: %d\n", ret); in msm_hdmi_modeset_init()
189 hdmi->connector = NULL; in msm_hdmi_modeset_init()
193 drm_connector_attach_encoder(hdmi->connector, hdmi->encoder); in msm_hdmi_modeset_init()
195 ret = devm_request_irq(dev->dev, hdmi->irq, in msm_hdmi_modeset_init()
197 "hdmi_isr", hdmi); in msm_hdmi_modeset_init()
199 DRM_DEV_ERROR(dev->dev, "failed to request IRQ%u: %d\n", in msm_hdmi_modeset_init()
200 hdmi->irq, ret); in msm_hdmi_modeset_init()
204 ret = msm_hdmi_hpd_enable(hdmi->bridge); in msm_hdmi_modeset_init()
206 DRM_DEV_ERROR(&hdmi->pdev->dev, "failed to enable HPD: %d\n", ret); in msm_hdmi_modeset_init()
213 if (hdmi->connector) { in msm_hdmi_modeset_init()
214 hdmi->connector->funcs->destroy(hdmi->connector); in msm_hdmi_modeset_init()
215 hdmi->connector = NULL; in msm_hdmi_modeset_init()
222 * The hdmi device:
229 static const char *hpd_reg_names_8960[] = {"core-vdda"};
233 HDMI_CFG(hpd_reg, 8960),
234 HDMI_CFG(hpd_clk, 8960),
237 static const char *pwr_reg_names_8x74[] = {"core-vdda", "core-vcc"};
250 * HDMI audio codec callbacks
256 struct hdmi *hdmi = dev_get_drvdata(dev); in msm_hdmi_audio_hw_params() local
263 DRM_DEV_DEBUG(dev, "%u Hz, %d bit, %d channels\n", params->sample_rate, in msm_hdmi_audio_hw_params()
264 params->sample_width, params->cea.channels); in msm_hdmi_audio_hw_params()
266 switch (params->cea.channels) { in msm_hdmi_audio_hw_params()
288 return -EINVAL; in msm_hdmi_audio_hw_params()
291 switch (params->sample_rate) { in msm_hdmi_audio_hw_params()
315 params->sample_rate); in msm_hdmi_audio_hw_params()
316 return -EINVAL; in msm_hdmi_audio_hw_params()
319 msm_hdmi_audio_set_sample_rate(hdmi, rate); in msm_hdmi_audio_hw_params()
320 msm_hdmi_audio_info_setup(hdmi, 1, chan, channel_allocation, in msm_hdmi_audio_hw_params()
328 struct hdmi *hdmi = dev_get_drvdata(dev); in msm_hdmi_audio_shutdown() local
330 msm_hdmi_audio_info_setup(hdmi, 0, 0, 0, 0, 0); in msm_hdmi_audio_shutdown()
344 static int msm_hdmi_register_audio_driver(struct hdmi *hdmi, struct device *dev) in msm_hdmi_register_audio_driver() argument
346 hdmi->audio_pdev = platform_device_register_data(dev, in msm_hdmi_register_audio_driver()
351 return PTR_ERR_OR_ZERO(hdmi->audio_pdev); in msm_hdmi_register_audio_driver()
357 struct hdmi *hdmi = dev_get_drvdata(dev); in msm_hdmi_bind() local
360 err = msm_hdmi_init(hdmi); in msm_hdmi_bind()
363 priv->hdmi = hdmi; in msm_hdmi_bind()
365 err = msm_hdmi_register_audio_driver(hdmi, dev); in msm_hdmi_bind()
368 hdmi->audio_pdev = NULL; in msm_hdmi_bind()
379 if (priv->hdmi) { in msm_hdmi_unbind()
380 if (priv->hdmi->audio_pdev) in msm_hdmi_unbind()
381 platform_device_unregister(priv->hdmi->audio_pdev); in msm_hdmi_unbind()
383 if (priv->hdmi->bridge) in msm_hdmi_unbind()
384 msm_hdmi_hpd_disable(priv->hdmi); in msm_hdmi_unbind()
386 msm_hdmi_destroy(priv->hdmi); in msm_hdmi_unbind()
387 priv->hdmi = NULL; in msm_hdmi_unbind()
399 struct device *dev = &pdev->dev; in msm_hdmi_dev_probe()
400 struct hdmi *hdmi; in msm_hdmi_dev_probe() local
406 return -EINVAL; in msm_hdmi_dev_probe()
408 hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); in msm_hdmi_dev_probe()
409 if (!hdmi) in msm_hdmi_dev_probe()
410 return -ENOMEM; in msm_hdmi_dev_probe()
412 hdmi->pdev = pdev; in msm_hdmi_dev_probe()
413 hdmi->config = config; in msm_hdmi_dev_probe()
414 spin_lock_init(&hdmi->reg_lock); in msm_hdmi_dev_probe()
416 ret = drm_of_find_panel_or_bridge(pdev->dev.of_node, 1, 0, NULL, &hdmi->next_bridge); in msm_hdmi_dev_probe()
417 if (ret && ret != -ENODEV) in msm_hdmi_dev_probe()
420 hdmi->mmio = msm_ioremap(pdev, "core_physical"); in msm_hdmi_dev_probe()
421 if (IS_ERR(hdmi->mmio)) in msm_hdmi_dev_probe()
422 return PTR_ERR(hdmi->mmio); in msm_hdmi_dev_probe()
424 /* HDCP needs physical address of hdmi register */ in msm_hdmi_dev_probe()
428 return -EINVAL; in msm_hdmi_dev_probe()
429 hdmi->mmio_phy_addr = res->start; in msm_hdmi_dev_probe()
431 hdmi->qfprom_mmio = msm_ioremap(pdev, "qfprom_physical"); in msm_hdmi_dev_probe()
432 if (IS_ERR(hdmi->qfprom_mmio)) { in msm_hdmi_dev_probe()
433 DRM_DEV_INFO(&pdev->dev, "can't find qfprom resource\n"); in msm_hdmi_dev_probe()
434 hdmi->qfprom_mmio = NULL; in msm_hdmi_dev_probe()
437 hdmi->irq = platform_get_irq(pdev, 0); in msm_hdmi_dev_probe()
438 if (hdmi->irq < 0) in msm_hdmi_dev_probe()
439 return hdmi->irq; in msm_hdmi_dev_probe()
441 hdmi->hpd_regs = devm_kcalloc(&pdev->dev, in msm_hdmi_dev_probe()
442 config->hpd_reg_cnt, in msm_hdmi_dev_probe()
443 sizeof(hdmi->hpd_regs[0]), in msm_hdmi_dev_probe()
445 if (!hdmi->hpd_regs) in msm_hdmi_dev_probe()
446 return -ENOMEM; in msm_hdmi_dev_probe()
448 for (i = 0; i < config->hpd_reg_cnt; i++) in msm_hdmi_dev_probe()
449 hdmi->hpd_regs[i].supply = config->hpd_reg_names[i]; in msm_hdmi_dev_probe()
451 ret = devm_regulator_bulk_get(&pdev->dev, config->hpd_reg_cnt, hdmi->hpd_regs); in msm_hdmi_dev_probe()
455 hdmi->pwr_regs = devm_kcalloc(&pdev->dev, in msm_hdmi_dev_probe()
456 config->pwr_reg_cnt, in msm_hdmi_dev_probe()
457 sizeof(hdmi->pwr_regs[0]), in msm_hdmi_dev_probe()
459 if (!hdmi->pwr_regs) in msm_hdmi_dev_probe()
460 return -ENOMEM; in msm_hdmi_dev_probe()
462 for (i = 0; i < config->pwr_reg_cnt; i++) in msm_hdmi_dev_probe()
463 hdmi->pwr_regs[i].supply = config->pwr_reg_names[i]; in msm_hdmi_dev_probe()
465 ret = devm_regulator_bulk_get(&pdev->dev, config->pwr_reg_cnt, hdmi->pwr_regs); in msm_hdmi_dev_probe()
469 hdmi->hpd_clks = devm_kcalloc(&pdev->dev, in msm_hdmi_dev_probe()
470 config->hpd_clk_cnt, in msm_hdmi_dev_probe()
471 sizeof(hdmi->hpd_clks[0]), in msm_hdmi_dev_probe()
473 if (!hdmi->hpd_clks) in msm_hdmi_dev_probe()
474 return -ENOMEM; in msm_hdmi_dev_probe()
476 for (i = 0; i < config->hpd_clk_cnt; i++) { in msm_hdmi_dev_probe()
479 clk = msm_clk_get(pdev, config->hpd_clk_names[i]); in msm_hdmi_dev_probe()
483 config->hpd_clk_names[i]); in msm_hdmi_dev_probe()
485 hdmi->hpd_clks[i] = clk; in msm_hdmi_dev_probe()
488 hdmi->pwr_clks = devm_kcalloc(&pdev->dev, in msm_hdmi_dev_probe()
489 config->pwr_clk_cnt, in msm_hdmi_dev_probe()
490 sizeof(hdmi->pwr_clks[0]), in msm_hdmi_dev_probe()
492 if (!hdmi->pwr_clks) in msm_hdmi_dev_probe()
493 return -ENOMEM; in msm_hdmi_dev_probe()
495 for (i = 0; i < config->pwr_clk_cnt; i++) { in msm_hdmi_dev_probe()
498 clk = msm_clk_get(pdev, config->pwr_clk_names[i]); in msm_hdmi_dev_probe()
502 config->pwr_clk_names[i]); in msm_hdmi_dev_probe()
504 hdmi->pwr_clks[i] = clk; in msm_hdmi_dev_probe()
507 hdmi->hpd_gpiod = devm_gpiod_get_optional(&pdev->dev, "hpd", GPIOD_IN); in msm_hdmi_dev_probe()
508 /* This will catch e.g. -EPROBE_DEFER */ in msm_hdmi_dev_probe()
509 if (IS_ERR(hdmi->hpd_gpiod)) in msm_hdmi_dev_probe()
510 return dev_err_probe(dev, PTR_ERR(hdmi->hpd_gpiod), in msm_hdmi_dev_probe()
513 if (!hdmi->hpd_gpiod) in msm_hdmi_dev_probe()
516 if (hdmi->hpd_gpiod) in msm_hdmi_dev_probe()
517 gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); in msm_hdmi_dev_probe()
519 ret = msm_hdmi_get_phy(hdmi); in msm_hdmi_dev_probe()
521 DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n"); in msm_hdmi_dev_probe()
525 ret = devm_pm_runtime_enable(&pdev->dev); in msm_hdmi_dev_probe()
529 platform_set_drvdata(pdev, hdmi); in msm_hdmi_dev_probe()
531 ret = component_add(&pdev->dev, &msm_hdmi_ops); in msm_hdmi_dev_probe()
538 msm_hdmi_put_phy(hdmi); in msm_hdmi_dev_probe()
544 struct hdmi *hdmi = dev_get_drvdata(&pdev->dev); in msm_hdmi_dev_remove() local
546 component_del(&pdev->dev, &msm_hdmi_ops); in msm_hdmi_dev_remove()
548 msm_hdmi_put_phy(hdmi); in msm_hdmi_dev_remove()
552 { .compatible = "qcom,hdmi-tx-8998", .data = &hdmi_tx_8974_config },
553 { .compatible = "qcom,hdmi-tx-8996", .data = &hdmi_tx_8974_config },
554 { .compatible = "qcom,hdmi-tx-8994", .data = &hdmi_tx_8974_config },
555 { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8974_config },
556 { .compatible = "qcom,hdmi-tx-8974", .data = &hdmi_tx_8974_config },
557 { .compatible = "qcom,hdmi-tx-8960", .data = &hdmi_tx_8960_config },
558 { .compatible = "qcom,hdmi-tx-8660", .data = &hdmi_tx_8960_config },