.. | .. |
---|
8 | 8 | #include <linux/of_irq.h> |
---|
9 | 9 | #include <linux/of_gpio.h> |
---|
10 | 10 | |
---|
| 11 | +#include <drm/drm_bridge_connector.h> |
---|
| 12 | + |
---|
11 | 13 | #include <sound/hdmi-codec.h> |
---|
12 | 14 | #include "hdmi.h" |
---|
13 | 15 | |
---|
.. | .. |
---|
41 | 43 | struct hdmi *hdmi = dev_id; |
---|
42 | 44 | |
---|
43 | 45 | /* Process HPD: */ |
---|
44 | | - msm_hdmi_connector_irq(hdmi->connector); |
---|
| 46 | + msm_hdmi_hpd_irq(hdmi->bridge); |
---|
45 | 47 | |
---|
46 | 48 | /* Process DDC: */ |
---|
47 | 49 | msm_hdmi_i2c_irq(hdmi->i2c); |
---|
.. | .. |
---|
245 | 247 | hdmi->pwr_clks[i] = clk; |
---|
246 | 248 | } |
---|
247 | 249 | |
---|
| 250 | + hdmi->hpd_gpiod = devm_gpiod_get_optional(&pdev->dev, "hpd", GPIOD_IN); |
---|
| 251 | + /* This will catch e.g. -EPROBE_DEFER */ |
---|
| 252 | + if (IS_ERR(hdmi->hpd_gpiod)) { |
---|
| 253 | + ret = PTR_ERR(hdmi->hpd_gpiod); |
---|
| 254 | + DRM_DEV_ERROR(&pdev->dev, "failed to get hpd gpio: (%d)\n", ret); |
---|
| 255 | + goto fail; |
---|
| 256 | + } |
---|
| 257 | + |
---|
| 258 | + if (!hdmi->hpd_gpiod) |
---|
| 259 | + DBG("failed to get HPD gpio"); |
---|
| 260 | + |
---|
| 261 | + if (hdmi->hpd_gpiod) |
---|
| 262 | + gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); |
---|
| 263 | + |
---|
248 | 264 | pm_runtime_enable(&pdev->dev); |
---|
249 | 265 | |
---|
250 | 266 | hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0); |
---|
| 267 | + if (!hdmi->workq) { |
---|
| 268 | + ret = -ENOMEM; |
---|
| 269 | + goto fail; |
---|
| 270 | + } |
---|
251 | 271 | |
---|
252 | 272 | hdmi->i2c = msm_hdmi_i2c_init(hdmi); |
---|
253 | 273 | if (IS_ERR(hdmi->i2c)) { |
---|
.. | .. |
---|
311 | 331 | goto fail; |
---|
312 | 332 | } |
---|
313 | 333 | |
---|
314 | | - hdmi->connector = msm_hdmi_connector_init(hdmi); |
---|
| 334 | + hdmi->connector = drm_bridge_connector_init(hdmi->dev, encoder); |
---|
315 | 335 | if (IS_ERR(hdmi->connector)) { |
---|
316 | 336 | ret = PTR_ERR(hdmi->connector); |
---|
317 | 337 | DRM_DEV_ERROR(dev->dev, "failed to create HDMI connector: %d\n", ret); |
---|
318 | 338 | hdmi->connector = NULL; |
---|
319 | 339 | goto fail; |
---|
320 | 340 | } |
---|
| 341 | + |
---|
| 342 | + drm_connector_attach_encoder(hdmi->connector, hdmi->encoder); |
---|
321 | 343 | |
---|
322 | 344 | hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); |
---|
323 | 345 | if (!hdmi->irq) { |
---|
.. | .. |
---|
335 | 357 | goto fail; |
---|
336 | 358 | } |
---|
337 | 359 | |
---|
338 | | - ret = msm_hdmi_hpd_enable(hdmi->connector); |
---|
| 360 | + drm_bridge_connector_enable_hpd(hdmi->connector); |
---|
| 361 | + |
---|
| 362 | + ret = msm_hdmi_hpd_enable(hdmi->bridge); |
---|
339 | 363 | if (ret < 0) { |
---|
340 | 364 | DRM_DEV_ERROR(&hdmi->pdev->dev, "failed to enable HPD: %d\n", ret); |
---|
341 | 365 | goto fail; |
---|
.. | .. |
---|
421 | 445 | HDMI_CFG(pwr_clk, 8x74), |
---|
422 | 446 | HDMI_CFG(hpd_clk, 8x74), |
---|
423 | 447 | .hpd_freq = hpd_clk_freq_8x74, |
---|
424 | | -}; |
---|
425 | | - |
---|
426 | | -static const struct { |
---|
427 | | - const char *name; |
---|
428 | | - const bool output; |
---|
429 | | - const int value; |
---|
430 | | - const char *label; |
---|
431 | | -} msm_hdmi_gpio_pdata[] = { |
---|
432 | | - { "qcom,hdmi-tx-ddc-clk", true, 1, "HDMI_DDC_CLK" }, |
---|
433 | | - { "qcom,hdmi-tx-ddc-data", true, 1, "HDMI_DDC_DATA" }, |
---|
434 | | - { "qcom,hdmi-tx-hpd", false, 1, "HDMI_HPD" }, |
---|
435 | | - { "qcom,hdmi-tx-mux-en", true, 1, "HDMI_MUX_EN" }, |
---|
436 | | - { "qcom,hdmi-tx-mux-sel", true, 0, "HDMI_MUX_SEL" }, |
---|
437 | | - { "qcom,hdmi-tx-mux-lpm", true, 1, "HDMI_MUX_LPM" }, |
---|
438 | 448 | }; |
---|
439 | 449 | |
---|
440 | 450 | /* |
---|
.. | .. |
---|
549 | 559 | struct hdmi_platform_config *hdmi_cfg; |
---|
550 | 560 | struct hdmi *hdmi; |
---|
551 | 561 | struct device_node *of_node = dev->of_node; |
---|
552 | | - int i, err; |
---|
| 562 | + int err; |
---|
553 | 563 | |
---|
554 | 564 | hdmi_cfg = (struct hdmi_platform_config *) |
---|
555 | 565 | of_device_get_match_data(dev); |
---|
.. | .. |
---|
560 | 570 | |
---|
561 | 571 | hdmi_cfg->mmio_name = "core_physical"; |
---|
562 | 572 | hdmi_cfg->qfprom_mmio_name = "qfprom_physical"; |
---|
563 | | - |
---|
564 | | - for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) { |
---|
565 | | - const char *name = msm_hdmi_gpio_pdata[i].name; |
---|
566 | | - struct gpio_desc *gpiod; |
---|
567 | | - |
---|
568 | | - /* |
---|
569 | | - * We are fetching the GPIO lines "as is" since the connector |
---|
570 | | - * code is enabling and disabling the lines. Until that point |
---|
571 | | - * the power-on default value will be kept. |
---|
572 | | - */ |
---|
573 | | - gpiod = devm_gpiod_get_optional(dev, name, GPIOD_ASIS); |
---|
574 | | - /* This will catch e.g. -PROBE_DEFER */ |
---|
575 | | - if (IS_ERR(gpiod)) |
---|
576 | | - return PTR_ERR(gpiod); |
---|
577 | | - if (!gpiod) { |
---|
578 | | - /* Try a second time, stripping down the name */ |
---|
579 | | - char name3[32]; |
---|
580 | | - |
---|
581 | | - /* |
---|
582 | | - * Try again after stripping out the "qcom,hdmi-tx" |
---|
583 | | - * prefix. This is mainly to match "hpd-gpios" used |
---|
584 | | - * in the upstream bindings. |
---|
585 | | - */ |
---|
586 | | - if (sscanf(name, "qcom,hdmi-tx-%s", name3)) |
---|
587 | | - gpiod = devm_gpiod_get_optional(dev, name3, GPIOD_ASIS); |
---|
588 | | - if (IS_ERR(gpiod)) |
---|
589 | | - return PTR_ERR(gpiod); |
---|
590 | | - if (!gpiod) |
---|
591 | | - DBG("failed to get gpio: %s", name); |
---|
592 | | - } |
---|
593 | | - hdmi_cfg->gpios[i].gpiod = gpiod; |
---|
594 | | - if (gpiod) |
---|
595 | | - gpiod_set_consumer_name(gpiod, msm_hdmi_gpio_pdata[i].label); |
---|
596 | | - hdmi_cfg->gpios[i].output = msm_hdmi_gpio_pdata[i].output; |
---|
597 | | - hdmi_cfg->gpios[i].value = msm_hdmi_gpio_pdata[i].value; |
---|
598 | | - } |
---|
599 | 573 | |
---|
600 | 574 | dev->platform_data = hdmi_cfg; |
---|
601 | 575 | |
---|