Panel orientation property should be set before drm_dev_register(). Mediatek drm driver calls drm_dev_register() in .bind(). However, most panels sets orientation property relatively late, mostly in .get_modes() callback, since this is when they are able to get the connector and binds the orientation property to it, though the value should be known when the panel is probed.
Let the drm driver check if the remote end point is a panel and if it contains the orientation property. If it does, set it before drm_dev_register() is called.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org --- This patch is to solve the same problem as [1] [1] https://patchwork.kernel.org/project/linux-mediatek/patch/20220530081910.394... --- drivers/gpu/drm/mediatek/mtk_dsi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index d9f10a33e6fa..091107f97ccc 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -198,6 +198,7 @@ struct mtk_dsi {
unsigned long mode_flags; enum mipi_dsi_pixel_format format; + enum drm_panel_orientation orientation; unsigned int lanes; struct videomode vm; struct mtk_phy_timing phy_timing; @@ -822,6 +823,10 @@ static int mtk_dsi_encoder_init(struct drm_device *drm, struct mtk_dsi *dsi) ret = PTR_ERR(dsi->connector); goto err_cleanup_encoder; } + + if (dsi->orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN) + drm_connector_set_panel_orientation(dsi->connector, dsi->orientation); + drm_connector_attach_encoder(dsi->connector, &dsi->encoder);
return 0; @@ -836,6 +841,14 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data) int ret; struct drm_device *drm = data; struct mtk_dsi *dsi = dev_get_drvdata(dev); + struct drm_panel *panel; + + /* Read panel orientation if existed */ + dsi->orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; + ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, &panel, NULL); + if (!ret && panel && panel->dev) { + of_drm_get_panel_orientation(panel->dev->of_node, &dsi->orientation); + }
ret = mtk_dsi_encoder_init(drm, dsi); if (ret)
krane, kakadu, and kodama boards have a default panel rotation.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Enric Balletbo i Serra enric.balletbo@collabora.com Tested-by: Enric Balletbo i Serra enric.balletbo@collabora.com --- arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi index 8d5bf73a9099..f0dd5a06629d 100644 --- a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi @@ -276,6 +276,7 @@ panel: panel@0 { avee-supply = <&ppvarp_lcd>; pp1800-supply = <&pp1800_lcd>; backlight = <&backlight_lcd0>; + rotation = <270>; port { panel_in: endpoint { remote-endpoint = <&dsi_out>;
On Mon, May 30, 2022 at 7:30 PM Hsin-Yi Wang hsinyi@chromium.org wrote:
krane, kakadu, and kodama boards have a default panel rotation.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Enric Balletbo i Serra enric.balletbo@collabora.com Tested-by: Enric Balletbo i Serra enric.balletbo@collabora.com
Hi Matthias,
The series ("Add a panel API to return panel orientation") might land in drm-misc. With this series applied, we can add this patch to give the correct default orientation for mt8183 kukui devices. I didn't send this patch again with the series, since they might land in different trees.
Thanks.
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi index 8d5bf73a9099..f0dd5a06629d 100644 --- a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi @@ -276,6 +276,7 @@ panel: panel@0 { avee-supply = <&ppvarp_lcd>; pp1800-supply = <&pp1800_lcd>; backlight = <&backlight_lcd0>;
rotation = <270>; port { panel_in: endpoint { remote-endpoint = <&dsi_out>;
-- 2.36.1.124.g0e6072fb45-goog
Hi Hsin-Yi Wang,
On 06/06/2022 17:29, Hsin-Yi Wang wrote:
On Mon, May 30, 2022 at 7:30 PM Hsin-Yi Wang hsinyi@chromium.org wrote:
krane, kakadu, and kodama boards have a default panel rotation.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Enric Balletbo i Serra enric.balletbo@collabora.com Tested-by: Enric Balletbo i Serra enric.balletbo@collabora.com
Hi Matthias,
The series ("Add a panel API to return panel orientation") might land in drm-misc. With this series applied, we can add this patch to give the correct default orientation for mt8183 kukui devices. I didn't send this patch again with the series, since they might land in different trees.
I had a look on Linux next (next-20220617) and wasn't able to find the mtk_dsi.c changes. What is the status of this?
Regards, Matthias
Thanks.
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi index 8d5bf73a9099..f0dd5a06629d 100644 --- a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi @@ -276,6 +276,7 @@ panel: panel@0 { avee-supply = <&ppvarp_lcd>; pp1800-supply = <&pp1800_lcd>; backlight = <&backlight_lcd0>;
rotation = <270>; port { panel_in: endpoint { remote-endpoint = <&dsi_out>;
-- 2.36.1.124.g0e6072fb45-goog
On Fri, Jun 17, 2022 at 10:10 PM Matthias Brugger matthias.bgg@gmail.com wrote:
Hi Hsin-Yi Wang,
On 06/06/2022 17:29, Hsin-Yi Wang wrote:
On Mon, May 30, 2022 at 7:30 PM Hsin-Yi Wang hsinyi@chromium.org wrote:
krane, kakadu, and kodama boards have a default panel rotation.
Signed-off-by: Hsin-Yi Wang hsinyi@chromium.org Reviewed-by: Enric Balletbo i Serra enric.balletbo@collabora.com Tested-by: Enric Balletbo i Serra enric.balletbo@collabora.com
Hi Matthias,
The series ("Add a panel API to return panel orientation") might land in drm-misc. With this series applied, we can add this patch to give the correct default orientation for mt8183 kukui devices. I didn't send this patch again with the series, since they might land in different trees.
I had a look on Linux next (next-20220617) and wasn't able to find the mtk_dsi.c changes. What is the status of this?
The mtk_dsi change got dropped. The latest is this series: https://lore.kernel.org/lkml/20220609072722.3488207-1-hsinyi@chromium.org/, still waiting to be picked or others' comments.
If the dts patch is picked without the drm series, there will be a WARN, but won't affect boot or display up.
Regards, Matthias
Thanks.
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi index 8d5bf73a9099..f0dd5a06629d 100644 --- a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi @@ -276,6 +276,7 @@ panel: panel@0 { avee-supply = <&ppvarp_lcd>; pp1800-supply = <&pp1800_lcd>; backlight = <&backlight_lcd0>;
rotation = <270>; port { panel_in: endpoint { remote-endpoint = <&dsi_out>;
-- 2.36.1.124.g0e6072fb45-goog
dri-devel@lists.freedesktop.org