drm/bridge: microchip-lvds: clean up and fix bus formats
Subsystems (4)
Dharma Balasubiramani
maintainerPATCH v6 3/3 drm/bridge: microchip-lvds: fix bus format mismatch with VESA displays
In reply to Dharma BalasubiramaniThe LVDS controller was hardcoded to JEIDA mapping, which leads to distorted output on panels expecting VESA mapping.
Update the driver to dynamically select the appropriate mapping and pixel size based on the panel's advertised media bus format. This ensures compatibility with both JEIDA and VESA displays.
--- drivers/gpu/drm/bridge/microchip-lvds.c | 37 +++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/microchip-lvds.c +31 -6
@@ -11,6 +11,7 @@#include <linux/component.h> #include <linux/delay.h> #include <linux/jiffies.h> +#include <linux/media-bus-format.h> #include <linux/mfd/syscon.h> #include <linux/of_graph.h> #include <linux/pinctrl/devinfo.h>
@@ -40,9 +41,11 @@/* Bitfields in LVDSC_CFGR (Configuration Register) */ #define LVDSC_CFGR_PIXSIZE_24BITS 0 +#define LVDSC_CFGR_PIXSIZE_18BITS BIT(0)#define LVDSC_CFGR_DEN_POL_HIGH 0#define LVDSC_CFGR_DC_UNBALANCED 0#define LVDSC_CFGR_MAPPING_JEIDA BIT(6) +#define LVDSC_CFGR_MAPPING_VESA 0/*Bitfields in LVDSC_SR */ #define LVDSC_SR_CS BIT(0)
@@ -74,9 +77,10 @@ static inline void lvds_writel(struct mchp_lvds *lvds, u32 offset, u32 val)writel_relaxed (val, lvds->regs + offset); } -static void lvds_serialiser_on (struct mchp_lvds *lvds) +static void lvds_serialiser_on (struct mchp_lvds *lvds,u32 bus_format) {unsigned long timeout = jiffies +msecs_to_jiffies (LVDS_POLL_TIMEOUT_MS ); +u8 map, pix_size;/* The LVDSC registers can only be written if WPEN is cleared */ lvds_writel(lvds, LVDSC_WPMR, (LVDSC_WPMR_WPKEY_PSSWD &
@@ -91,11 +95,24 @@ static void lvds_serialiser_on(struct mchp_lvds *lvds)usleep_range (1000 ,2000 ); } +switch (bus_format) { +case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG : + map =LVDSC_CFGR_MAPPING_JEIDA ; + pix_size =LVDSC_CFGR_PIXSIZE_18BITS ; +break ; +case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG : + map =LVDSC_CFGR_MAPPING_VESA ; + pix_size =LVDSC_CFGR_PIXSIZE_24BITS ; +break ; +default : + map =LVDSC_CFGR_MAPPING_JEIDA ; + pix_size =LVDSC_CFGR_PIXSIZE_24BITS ; +break ; + } +/* Configure the LVDSC */ -lvds_writel (lvds,LVDSC_CFGR , (LVDSC_CFGR_MAPPING_JEIDA | -LVDSC_CFGR_DC_UNBALANCED | -LVDSC_CFGR_DEN_POL_HIGH | -LVDSC_CFGR_PIXSIZE_24BITS )); +lvds_writel (lvds,LVDSC_CFGR , map |LVDSC_CFGR_DC_UNBALANCED | +LVDSC_CFGR_DEN_POL_HIGH | pix_size);/* Enable the LVDS serializer */ lvds_writel (lvds,LVDSC_CR ,LVDSC_CR_SER_EN );
@@ -115,6 +132,7 @@ static void mchp_lvds_atomic_enable(struct drm_bridge *bridge, struct drm_atomic_state *state) {struct mchp_lvds *lvds =bridge_to_lvds (bridge); +struct drm_connector *connector;int ret; ret =clk_prepare_enable (lvds->pclk);
@@ -129,7 +147,14 @@ static void mchp_lvds_atomic_enable(struct drm_bridge *bridge,return ; } -lvds_serialiser_on (lvds); +/* default to jeida-24 */ +u32 bus_format =MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA ; + + connector =drm_atomic_get_new_connector_for_encoder (state, bridge->encoder); +if (connector && connector->display_info.num_bus_formats) + bus_format = connector->display_info.bus_formats[0 ]; + +lvds_serialiser_on (lvds, bus_format); } static void mchp_lvds_atomic_disable(struct drm_bridge *bridge,
Signature · 1 line
2.43.0
Dharma Balasubiramani
maintainerv6 cover drm/bridge: microchip-lvds: clean up and fix bus formats
This patch series drops the unsed panel field, switches to atomic variants and adds support to select between the two supported formats (JEIDA and VESA) by the LVDSC.
---
Changes in v6:
- Drop pre and post hooks as they are not neccessary now.
- Drop turning off the serialiser.
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Drop the redundant port node lookup.
- Split the commits adding atomic bridge ops into 2.
- Update commit messages accordingly.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Split the commits into 3.
- Drop <drm/drm_panel.h>
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Use BIT(0) instead of 1.
- Drop the panel field of the mchp_lvds structure.
- Drop the inner parentheses in write in serialiser_on().
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Switch to atomic bridge functions
- Drop custom connector creation
- Use drm_atomic_get_new_connector_for_encoder()
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Dharma Balasubiramani (3):
drm/bridge: microchip-lvds: Remove unused drm_panel and redundant port node lookup drm/bridge: microchip-lvds: migrate to atomic bridge ops
drm/bridge: microchip-lvds: fix bus format mismatch with VESA displays
drivers/gpu/drm/bridge/microchip-lvds.c | 63 +++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 26 deletions(-)
---
base-commit: 4325743c7e209ae7845293679a4de94b969f2bef
change-id: 20250618-microchip-lvds-b7151d96094a
Best regards,
Signature · 1 line
Dharma Balasubiramani <[email protected]>
Dharma Balasubiramani
maintainerPATCH v6 1/3 drm/bridge: microchip-lvds: Remove unused drm_panel and redundant port node lookup
Drop the unused drm_panel field from the mchp_lvds structure, and remove the unnecessary port device node lookup, as devm_drm_of_get_bridge() already performs the required checks internally.
--- drivers/gpu/drm/bridge/microchip-lvds.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/gpu/drm/bridge/microchip-lvds.c +0 -16
@@ -23,7 +23,6 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_bridge.h> #include <drm/drm_of.h> -#include <drm/drm_panel.h> #include <drm/drm_print.h> #include <drm/drm_probe_helper.h> #include <drm/drm_simple_kms_helper.h>
@@ -56,7 +55,6 @@ struct mchp_lvds {struct device *dev;void __iomem *regs;struct clk *pclk; -struct drm_panel *panel;struct drm_bridge bridge;struct drm_bridge *panel_bridge; };
@@ -151,7 +149,6 @@ static int mchp_lvds_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct mchp_lvds *lvds; -struct device_node *port;int ret;if (!dev->of_node)
@@ -173,19 +170,6 @@ static int mchp_lvds_probe(struct platform_device *pdev)return dev_err_probe (lvds->dev,PTR_ERR (lvds->pclk),"could not get pclk_lvds\n" ); - port =of_graph_get_remote_node (dev->of_node,1 ,0 ); -if (!port) { -dev_err (dev, -"can't find port point, please init lvds panel port!\n" ); -return -ENODEV ; - } - - lvds->panel =of_drm_find_panel (port); -of_node_put (port); - -if (IS_ERR (lvds->panel)) -return -EPROBE_DEFER ; - lvds->panel_bridge =devm_drm_of_get_bridge (dev, dev->of_node,1 ,0 );if (IS_ERR (lvds->panel_bridge))
Signature · 1 line
2.43.0
Dharma Balasubiramani
maintainerPATCH v6 2/3 drm/bridge: microchip-lvds: migrate to atomic bridge ops
In reply to Dharma BalasubiramaniReplace legacy .enable and .disable callbacks with their atomic counterparts .atomic_enable and .atomic_disable.
--- drivers/gpu/drm/bridge/microchip-lvds.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/microchip-lvds.c +6 -4
@@ -111,7 +111,8 @@ static int mchp_lvds_attach(struct drm_bridge *bridge, bridge, flags); } -static void mchp_lvds_enable (struct drm_bridge *bridge) +static void mchp_lvds_atomic_enable (struct drm_bridge *bridge, +struct drm_atomic_state *state) {struct mchp_lvds *lvds =bridge_to_lvds (bridge);int ret;
@@ -131,7 +132,8 @@ static void mchp_lvds_enable(struct drm_bridge *bridge)lvds_serialiser_on (lvds); } -static void mchp_lvds_disable (struct drm_bridge *bridge) +static void mchp_lvds_atomic_disable (struct drm_bridge *bridge, +struct drm_atomic_state *state) {struct mchp_lvds *lvds =bridge_to_lvds (bridge);
@@ -141,8 +143,8 @@ static void mchp_lvds_disable(struct drm_bridge *bridge)static const struct drm_bridge_funcs mchp_lvds_bridge_funcs = { .attach = mchp_lvds_attach, - .enable = mchp_lvds_enable, - .disable = mchp_lvds_disable, + .atomic_enable = mchp_lvds_atomic_enable, + .atomic_disable = mchp_lvds_atomic_disable, };static int mchp_lvds_probe (struct platform_device *pdev)
Signature · 1 line
2.43.0
Re: [PATCH v6 2/3] drm/bridge: microchip-lvds: migrate to atomic bridge ops
Quoted 4 lines · Dharma Balasubiramani
Replace legacy .enable and .disable callbacks with their atomic counterparts .atomic_enable and .atomic_disable.
Signed-off-by Dharma Balasubiramani <[email protected]>
Thanks!
Maxime
Quoted 5 lines · Dharma Balasubiramani
This patch series drops the unsed panel field, switches to atomic variants and adds support to select between the two supported formats (JEIDA and VESA) by the LVDSC.
Signed-off-by Dharma Balasubiramani <[email protected]>
Applied to drm-misc-next, Thanks.
Quoted 42 lines
---
Changes in v6:
- Drop pre and post hooks as they are not neccessary now.
- Drop turning off the serialiser.
- Link to v5: https://lore.kernel.org/r/[email protected]Changes in v5:
- Drop the redundant port node lookup.
- Split the commits adding atomic bridge ops into 2.
- Update commit messages accordingly.
- Link to v4: https://lore.kernel.org/r/[email protected]Changes in v4:
- Split the commits into 3.
- Drop <drm/drm_panel.h>
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- Use BIT(0) instead of 1.
- Drop the panel field of themchp_lvdsstructure.
- Drop the inner parentheses in write inserialiser_on().
- Link to v2: https://lore.kernel.org/r/[email protected]Changes in v2:
- Switch to atomic bridge functions
- Drop custom connector creation
- Usedrm_atomic_get_new_connector_for_encoder()
- Link to v1: https://lore.kernel.org/r/[email protected]---
Dharma Balasubiramani (3):
drm/bridge: microchip-lvds: Remove unuseddrm_paneland redundant port node lookup drm/bridge: microchip-lvds: migrate to atomic bridge ops
drm/bridge: microchip-lvds: fix bus format mismatch with VESA displaysdrivers/gpu/drm/bridge/microchip-lvds.c | 63 +++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 26 deletions(-)---
base-commit:4325743c7e209ae7845293679a4de94b969f2bef
change-id: 20250618-microchip-lvds-b7151d96094aBest regards,
Signature · 2 lines
Thanks and Regards, Manikandan M.