hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/gpu/drm/msm/hdmi/hdmi.c
....@@ -8,6 +8,8 @@
88 #include <linux/of_irq.h>
99 #include <linux/of_gpio.h>
1010
11
+#include <drm/drm_bridge_connector.h>
12
+
1113 #include <sound/hdmi-codec.h>
1214 #include "hdmi.h"
1315
....@@ -41,7 +43,7 @@
4143 struct hdmi *hdmi = dev_id;
4244
4345 /* Process HPD: */
44
- msm_hdmi_connector_irq(hdmi->connector);
46
+ msm_hdmi_hpd_irq(hdmi->bridge);
4547
4648 /* Process DDC: */
4749 msm_hdmi_i2c_irq(hdmi->i2c);
....@@ -245,9 +247,27 @@
245247 hdmi->pwr_clks[i] = clk;
246248 }
247249
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
+
248264 pm_runtime_enable(&pdev->dev);
249265
250266 hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0);
267
+ if (!hdmi->workq) {
268
+ ret = -ENOMEM;
269
+ goto fail;
270
+ }
251271
252272 hdmi->i2c = msm_hdmi_i2c_init(hdmi);
253273 if (IS_ERR(hdmi->i2c)) {
....@@ -311,13 +331,15 @@
311331 goto fail;
312332 }
313333
314
- hdmi->connector = msm_hdmi_connector_init(hdmi);
334
+ hdmi->connector = drm_bridge_connector_init(hdmi->dev, encoder);
315335 if (IS_ERR(hdmi->connector)) {
316336 ret = PTR_ERR(hdmi->connector);
317337 DRM_DEV_ERROR(dev->dev, "failed to create HDMI connector: %d\n", ret);
318338 hdmi->connector = NULL;
319339 goto fail;
320340 }
341
+
342
+ drm_connector_attach_encoder(hdmi->connector, hdmi->encoder);
321343
322344 hdmi->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
323345 if (!hdmi->irq) {
....@@ -335,7 +357,9 @@
335357 goto fail;
336358 }
337359
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);
339363 if (ret < 0) {
340364 DRM_DEV_ERROR(&hdmi->pdev->dev, "failed to enable HPD: %d\n", ret);
341365 goto fail;
....@@ -421,20 +445,6 @@
421445 HDMI_CFG(pwr_clk, 8x74),
422446 HDMI_CFG(hpd_clk, 8x74),
423447 .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" },
438448 };
439449
440450 /*
....@@ -549,7 +559,7 @@
549559 struct hdmi_platform_config *hdmi_cfg;
550560 struct hdmi *hdmi;
551561 struct device_node *of_node = dev->of_node;
552
- int i, err;
562
+ int err;
553563
554564 hdmi_cfg = (struct hdmi_platform_config *)
555565 of_device_get_match_data(dev);
....@@ -560,42 +570,6 @@
560570
561571 hdmi_cfg->mmio_name = "core_physical";
562572 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
- }
599573
600574 dev->platform_data = hdmi_cfg;
601575