Skip to content

Commit 06c14f5

Browse files
committed
Merge tag 'mediatek-drm-next-5.10' of https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux into drm-next
Mediatek DRM Next for Linux 5.10 1. Move Mediatek HDMI PHY driver from DRM folder to PHY folder 2. Convert mtk-dpi to drm_bridge API 3. Disable tmds on mt2701 Signed-off-by: Dave Airlie <[email protected]> From: Chun-Kuang Hu <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 200a218 + 09e872d commit 06c14f5

File tree

20 files changed

+159
-59
lines changed

20 files changed

+159
-59
lines changed

Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Required properties (all function blocks):
4343
"mediatek,<chip>-dpi" - DPI controller, see mediatek,dpi.txt
4444
"mediatek,<chip>-disp-mutex" - display mutex
4545
"mediatek,<chip>-disp-od" - overdrive
46-
the supported chips are mt2701, mt2712 and mt8173.
46+
the supported chips are mt2701, mt7623, mt2712 and mt8173.
4747
- reg: Physical base address and length of the function block register space
4848
- interrupts: The interrupt signal from the function block (required, except for
4949
merge and split function blocks).

Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ output bus.
77

88
Required properties:
99
- compatible: "mediatek,<chip>-dpi"
10-
the supported chips are mt2701 , mt8173 and mt8183.
10+
the supported chips are mt2701, mt7623, mt8173 and mt8183.
1111
- reg: Physical base address and length of the controller's registers
1212
- interrupts: The interrupt signal from the function block.
1313
- clocks: device clocks

Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ channel output.
77

88
Required properties:
99
- compatible: "mediatek,<chip>-dsi"
10-
the supported chips are mt2701, mt8173 and mt8183.
10+
- the supported chips are mt2701, mt7623, mt8173 and mt8183.
1111
- reg: Physical base address and length of the controller's registers
1212
- interrupts: The interrupt signal from the function block.
1313
- clocks: device clocks
@@ -26,7 +26,7 @@ The MIPI TX configuration module controls the MIPI D-PHY.
2626

2727
Required properties:
2828
- compatible: "mediatek,<chip>-mipi-tx"
29-
the supported chips are mt2701, mt8173 and mt8183.
29+
- the supported chips are mt2701, 7623, mt8173 and mt8183.
3030
- reg: Physical base address and length of the controller's registers
3131
- clocks: PLL reference clock
3232
- clock-output-names: name of the output clock line to the DSI encoder

Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ its parallel input.
66

77
Required properties:
88
- compatible: Should be "mediatek,<chip>-hdmi".
9+
- the supported chips are mt2701, mt7623 and mt8173
910
- reg: Physical base address and length of the controller's registers
1011
- interrupts: The interrupt signal from the function block.
1112
- clocks: device clocks
@@ -32,6 +33,7 @@ The HDMI CEC controller handles hotplug detection and CEC communication.
3233

3334
Required properties:
3435
- compatible: Should be "mediatek,<chip>-cec"
36+
- the supported chips are mt7623 and mt8173
3537
- reg: Physical base address and length of the controller's registers
3638
- interrupts: The interrupt signal from the function block.
3739
- clocks: device clock
@@ -44,6 +46,7 @@ The Mediatek's I2C controller is used to interface with I2C devices.
4446

4547
Required properties:
4648
- compatible: Should be "mediatek,<chip>-hdmi-ddc"
49+
- the supported chips are mt7623 and mt8173
4750
- reg: Physical base address and length of the controller's registers
4851
- clocks: device clock
4952
- clock-names: Should be "ddc-i2c".
@@ -56,6 +59,7 @@ output and drives the HDMI pads.
5659

5760
Required properties:
5861
- compatible: "mediatek,<chip>-hdmi-phy"
62+
- the supported chips are mt2701, mt7623 and mt8173
5963
- reg: Physical base address and length of the module's registers
6064
- clocks: PLL reference clock
6165
- clock-names: must contain "pll_ref"

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5827,6 +5827,7 @@ L: [email protected]
58275827
S: Supported
58285828
F: Documentation/devicetree/bindings/display/mediatek/
58295829
F: drivers/gpu/drm/mediatek/
5830+
F: drivers/phy/mediatek/phy-mtk-hdmi*
58305831

58315832
DRM DRIVERS FOR NVIDIA TEGRA
58325833
M: Thierry Reding <[email protected]>

drivers/gpu/drm/mediatek/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ config DRM_MEDIATEK_HDMI
2424
tristate "DRM HDMI Support for Mediatek SoCs"
2525
depends on DRM_MEDIATEK
2626
select SND_SOC_HDMI_CODEC if SND_SOC
27-
select GENERIC_PHY
27+
select PHY_MTK_HDMI
2828
help
2929
DRM/KMS HDMI driver for Mediatek SoCs

drivers/gpu/drm/mediatek/Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o
1919

2020
mediatek-drm-hdmi-objs := mtk_cec.o \
2121
mtk_hdmi.o \
22-
mtk_hdmi_ddc.o \
23-
mtk_mt2701_hdmi_phy.o \
24-
mtk_mt8173_hdmi_phy.o \
25-
mtk_hdmi_phy.o
22+
mtk_hdmi_ddc.o
2623

2724
obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o

drivers/gpu/drm/mediatek/mtk_dpi.c

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ enum mtk_dpi_out_color_format {
6464
struct mtk_dpi {
6565
struct mtk_ddp_comp ddp_comp;
6666
struct drm_encoder encoder;
67-
struct drm_bridge *bridge;
67+
struct drm_bridge bridge;
68+
struct drm_bridge *next_bridge;
6869
void __iomem *regs;
6970
struct device *dev;
7071
struct clk *engine_clk;
@@ -83,9 +84,9 @@ struct mtk_dpi {
8384
int refcount;
8485
};
8586

86-
static inline struct mtk_dpi *mtk_dpi_from_encoder(struct drm_encoder *e)
87+
static inline struct mtk_dpi *bridge_to_dpi(struct drm_bridge *b)
8788
{
88-
return container_of(e, struct mtk_dpi, encoder);
89+
return container_of(b, struct mtk_dpi, bridge);
8990
}
9091

9192
enum mtk_dpi_polarity {
@@ -521,50 +522,53 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
521522
return 0;
522523
}
523524

524-
static bool mtk_dpi_encoder_mode_fixup(struct drm_encoder *encoder,
525-
const struct drm_display_mode *mode,
526-
struct drm_display_mode *adjusted_mode)
525+
static void mtk_dpi_encoder_destroy(struct drm_encoder *encoder)
527526
{
528-
return true;
527+
drm_encoder_cleanup(encoder);
529528
}
530529

531-
static void mtk_dpi_encoder_mode_set(struct drm_encoder *encoder,
532-
struct drm_display_mode *mode,
533-
struct drm_display_mode *adjusted_mode)
530+
static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
531+
.destroy = mtk_dpi_encoder_destroy,
532+
};
533+
534+
static int mtk_dpi_bridge_attach(struct drm_bridge *bridge,
535+
enum drm_bridge_attach_flags flags)
534536
{
535-
struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
537+
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
538+
539+
return drm_bridge_attach(bridge->encoder, dpi->next_bridge,
540+
&dpi->bridge, flags);
541+
}
542+
543+
static void mtk_dpi_bridge_mode_set(struct drm_bridge *bridge,
544+
const struct drm_display_mode *mode,
545+
const struct drm_display_mode *adjusted_mode)
546+
{
547+
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
536548

537549
drm_mode_copy(&dpi->mode, adjusted_mode);
538550
}
539551

540-
static void mtk_dpi_encoder_disable(struct drm_encoder *encoder)
552+
static void mtk_dpi_bridge_disable(struct drm_bridge *bridge)
541553
{
542-
struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
554+
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
543555

544556
mtk_dpi_power_off(dpi);
545557
}
546558

547-
static void mtk_dpi_encoder_enable(struct drm_encoder *encoder)
559+
static void mtk_dpi_bridge_enable(struct drm_bridge *bridge)
548560
{
549-
struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
561+
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
550562

551563
mtk_dpi_power_on(dpi);
552564
mtk_dpi_set_display_mode(dpi, &dpi->mode);
553565
}
554566

555-
static int mtk_dpi_atomic_check(struct drm_encoder *encoder,
556-
struct drm_crtc_state *crtc_state,
557-
struct drm_connector_state *conn_state)
558-
{
559-
return 0;
560-
}
561-
562-
static const struct drm_encoder_helper_funcs mtk_dpi_encoder_helper_funcs = {
563-
.mode_fixup = mtk_dpi_encoder_mode_fixup,
564-
.mode_set = mtk_dpi_encoder_mode_set,
565-
.disable = mtk_dpi_encoder_disable,
566-
.enable = mtk_dpi_encoder_enable,
567-
.atomic_check = mtk_dpi_atomic_check,
567+
static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
568+
.attach = mtk_dpi_bridge_attach,
569+
.mode_set = mtk_dpi_bridge_mode_set,
570+
.disable = mtk_dpi_bridge_disable,
571+
.enable = mtk_dpi_bridge_enable,
568572
};
569573

570574
static void mtk_dpi_start(struct mtk_ddp_comp *comp)
@@ -605,12 +609,10 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
605609
dev_err(dev, "Failed to initialize decoder: %d\n", ret);
606610
goto err_unregister;
607611
}
608-
drm_encoder_helper_add(&dpi->encoder, &mtk_dpi_encoder_helper_funcs);
609612

610-
/* Currently DPI0 is fixed to be driven by OVL1 */
611-
dpi->encoder.possible_crtcs = BIT(1);
613+
dpi->encoder.possible_crtcs = mtk_drm_find_possible_crtc_by_comp(drm_dev, dpi->ddp_comp);
612614

613-
ret = drm_bridge_attach(&dpi->encoder, dpi->bridge, NULL, 0);
615+
ret = drm_bridge_attach(&dpi->encoder, &dpi->bridge, NULL, 0);
614616
if (ret) {
615617
dev_err(dev, "Failed to attach bridge: %d\n", ret);
616618
goto err_cleanup;
@@ -770,11 +772,11 @@ static int mtk_dpi_probe(struct platform_device *pdev)
770772
}
771773

772774
ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
773-
NULL, &dpi->bridge);
775+
NULL, &dpi->next_bridge);
774776
if (ret)
775777
return ret;
776778

777-
dev_info(dev, "Found bridge node: %pOF\n", dpi->bridge->of_node);
779+
dev_info(dev, "Found bridge node: %pOF\n", dpi->next_bridge->of_node);
778780

779781
comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DPI);
780782
if (comp_id < 0) {
@@ -791,8 +793,15 @@ static int mtk_dpi_probe(struct platform_device *pdev)
791793

792794
platform_set_drvdata(pdev, dpi);
793795

796+
dpi->bridge.funcs = &mtk_dpi_bridge_funcs;
797+
dpi->bridge.of_node = dev->of_node;
798+
dpi->bridge.type = DRM_MODE_CONNECTOR_DPI;
799+
800+
drm_bridge_add(&dpi->bridge);
801+
794802
ret = component_add(dev, &mtk_dpi_component_ops);
795803
if (ret) {
804+
drm_bridge_remove(&dpi->bridge);
796805
dev_err(dev, "Failed to add component: %d\n", ret);
797806
return ret;
798807
}
@@ -802,7 +811,10 @@ static int mtk_dpi_probe(struct platform_device *pdev)
802811

803812
static int mtk_dpi_remove(struct platform_device *pdev)
804813
{
814+
struct mtk_dpi *dpi = platform_get_drvdata(pdev);
815+
805816
component_del(&pdev->dev, &mtk_dpi_component_ops);
817+
drm_bridge_remove(&dpi->bridge);
806818

807819
return 0;
808820
}

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <linux/of_platform.h>
1414
#include <linux/platform_device.h>
1515
#include <linux/soc/mediatek/mtk-cmdq.h>
16+
#include <drm/drm_print.h>
17+
1618
#include "mtk_drm_drv.h"
1719
#include "mtk_drm_plane.h"
1820
#include "mtk_drm_ddp_comp.h"
@@ -412,6 +414,22 @@ static const struct mtk_ddp_comp_match mtk_ddp_matches[DDP_COMPONENT_ID_MAX] = {
412414
[DDP_COMPONENT_WDMA1] = { MTK_DISP_WDMA, 1, NULL },
413415
};
414416

417+
static bool mtk_drm_find_comp_in_ddp(struct mtk_ddp_comp ddp_comp,
418+
const enum mtk_ddp_comp_id *path,
419+
unsigned int path_len)
420+
{
421+
unsigned int i;
422+
423+
if (path == NULL)
424+
return false;
425+
426+
for (i = 0U; i < path_len; i++)
427+
if (ddp_comp.id == path[i])
428+
return true;
429+
430+
return false;
431+
}
432+
415433
int mtk_ddp_comp_get_id(struct device_node *node,
416434
enum mtk_ddp_comp_type comp_type)
417435
{
@@ -427,6 +445,26 @@ int mtk_ddp_comp_get_id(struct device_node *node,
427445
return -EINVAL;
428446
}
429447

448+
unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
449+
struct mtk_ddp_comp ddp_comp)
450+
{
451+
struct mtk_drm_private *private = drm->dev_private;
452+
unsigned int ret = 0;
453+
454+
if (mtk_drm_find_comp_in_ddp(ddp_comp, private->data->main_path, private->data->main_len))
455+
ret = BIT(0);
456+
else if (mtk_drm_find_comp_in_ddp(ddp_comp, private->data->ext_path,
457+
private->data->ext_len))
458+
ret = BIT(1);
459+
else if (mtk_drm_find_comp_in_ddp(ddp_comp, private->data->third_path,
460+
private->data->third_len))
461+
ret = BIT(2);
462+
else
463+
DRM_INFO("Failed to find comp in ddp table\n");
464+
465+
return ret;
466+
}
467+
430468
int mtk_ddp_comp_init(struct device *dev, struct device_node *node,
431469
struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id,
432470
const struct mtk_ddp_comp_funcs *funcs)

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ static inline void mtk_ddp_ctm_set(struct mtk_ddp_comp *comp,
202202

203203
int mtk_ddp_comp_get_id(struct device_node *node,
204204
enum mtk_ddp_comp_type comp_type);
205+
unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
206+
struct mtk_ddp_comp ddp_comp);
205207
int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node,
206208
struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id,
207209
const struct mtk_ddp_comp_funcs *funcs);

0 commit comments

Comments
 (0)