From nobody Wed Oct 8 23:11:10 2025 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F954271440 for ; Tue, 24 Jun 2025 09:24:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750757096; cv=none; b=ekK8chVi6HCR4Ht1wDIEeLnJimS4hETqnu9ClllMoGXcrEkX6IYWDq57WZu6Ccn507eoNoFMiyKvY0alU3cs8gq2K7EXgNLrMMTy+OzKqKcLwtegv4AWrB0q8qZQXQpM+FpzpS63P9VOhkpRLc+GVNQCrIKe1OU/aAJ990qmj/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750757096; c=relaxed/simple; bh=d8blF+pwGOzvN5a5pRJDPvXOWg+al/nOtmjJMwPEerE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=ezXOcFbHPIKHEgJzGtPJhkj98IphQJ5W3p8GscYSEYi6DtGeJsQ9Gx/cMs1MScilr2usMIbxVmfENX64aVPT1o7Z/Z+fsRSJgrUYOPwXlgp2Smi/dERXreEvkm9MJIG6qsLHBntTeaifpV/hzcZopM+gIu0eLGJtFuMZPCwIsj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=DNFSKPcV; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="DNFSKPcV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1750757094; x=1782293094; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=d8blF+pwGOzvN5a5pRJDPvXOWg+al/nOtmjJMwPEerE=; b=DNFSKPcVYmEAII6ocq4Qcyd4IvQsHkn8cRHiT6h+NOJYmypxZo2hh7wK 1YoG0jH+5kV2j5PjM/nGCb5ODe7X85e4BMD8kmpxJCxlmHhqVBWca666n CnEoqZQtifdW0x0n4uPcXUKHsc2TAUAS18t7aLkCSzOj1SSY19ASmazDb 8mwOjQNwX0gWpJeqEUl5WEUgilomc+YThLHHiYMrK0S1YZy5fpxyjTqcr rlQVRbNI7TKiDDwUTOTTVfVXbbR705ScsJkrQmwP5+Zef1LHMLSd2g4RQ 4bMaie2gfonz5MxxdnOcbfMoMcDS/BzwsthhrOF16jTPtgu6r6tFlbHlm Q==; X-CSE-ConnectionGUID: kAMBk0q5SXCuhoUD0ewa8g== X-CSE-MsgGUID: RTHlKML7TziMPnVq5VuWLg== X-IronPort-AV: E=Sophos;i="6.16,261,1744095600"; d="scan'208";a="42674601" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Jun 2025 02:24:54 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44; Tue, 24 Jun 2025 02:24:41 -0700 Received: from [127.0.0.1] (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.44 via Frontend Transport; Tue, 24 Jun 2025 02:24:35 -0700 From: Dharma Balasubiramani Date: Tue, 24 Jun 2025 14:54:16 +0530 Subject: [PATCH v4 3/3] drm/bridge: microchip-lvds: fix bus format mismatch with VESA displays Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20250624-microchip-lvds-v4-3-937d42a420e9@microchip.com> References: <20250624-microchip-lvds-v4-0-937d42a420e9@microchip.com> In-Reply-To: <20250624-microchip-lvds-v4-0-937d42a420e9@microchip.com> To: Manikandan Muralidharan , Andrzej Hajda , Neil Armstrong , "Robert Foss" , Laurent Pinchart , Jonas Karlman , "Jernej Skrabec" , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter CC: , , "Dharma Balasubiramani" , Sandeep Sheriker M X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1750757054; l=3511; i=dharma.b@microchip.com; s=20240209; h=from:subject:message-id; bh=d8blF+pwGOzvN5a5pRJDPvXOWg+al/nOtmjJMwPEerE=; b=Dx906w6ttNzYlzdGDxTMFtBAZo1nTR9KV989/dvE4oUmqvjsQdiIgK0o6pvINvIM0VgcCa8KA F8VtroDvcHbAlQXhLTyTPdbTINU/EvMnvUerHvC6/tCJxljj6xCQURw X-Developer-Key: i=dharma.b@microchip.com; a=ed25519; pk=kCq31LcpLAe9HDfIz9ZJ1U7T+osjOi7OZSbe0gqtyQ4= The 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. Signed-off-by: Sandeep Sheriker M Signed-off-by: Dharma Balasubiramani --- drivers/gpu/drm/bridge/microchip-lvds.c | 38 +++++++++++++++++++++++++++--= ---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/microchip-lvds.c b/drivers/gpu/drm/brid= ge/microchip-lvds.c index e4ff46b03d54..ce52b794a9c6 100644 --- a/drivers/gpu/drm/bridge/microchip-lvds.c +++ b/drivers/gpu/drm/bridge/microchip-lvds.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -40,9 +41,11 @@ =20 /* 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 =20 /*Bitfields in LVDSC_SR */ #define LVDSC_SR_CS BIT(0) @@ -74,9 +77,10 @@ static inline void lvds_writel(struct mchp_lvds *lvds, u= 32 offset, u32 val) writel_relaxed(val, lvds->regs + offset); } =20 -static void lvds_serialiser_on(struct mchp_lvds *lvds) +static void lvds_serialiser_on(struct mchp_lvds *lvds, u32 bus_format) { unsigned long timeout =3D jiffies + msecs_to_jiffies(LVDS_POLL_TIMEOUT_MS= ); + u8 map, pix_size; =20 /* 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); } =20 + switch (bus_format) { + case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG: + map =3D LVDSC_CFGR_MAPPING_JEIDA; + pix_size =3D LVDSC_CFGR_PIXSIZE_18BITS; + break; + case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG: + map =3D LVDSC_CFGR_MAPPING_VESA; + pix_size =3D LVDSC_CFGR_PIXSIZE_24BITS; + break; + default: + map =3D LVDSC_CFGR_MAPPING_JEIDA; + pix_size =3D 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); =20 /* Enable the LVDS serializer */ lvds_writel(lvds, LVDSC_CR, LVDSC_CR_SER_EN); @@ -134,7 +151,16 @@ static void mchp_lvds_atomic_enable(struct drm_bridge = *bridge, struct drm_atomic_state *state) { struct mchp_lvds *lvds =3D bridge_to_lvds(bridge); - lvds_serialiser_on(lvds); + struct drm_connector *connector; + + /* default to jeida-24 */ + u32 bus_format =3D MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA; + + connector =3D drm_atomic_get_new_connector_for_encoder(state, bridge->enc= oder); + if (connector && connector->display_info.num_bus_formats) + bus_format =3D connector->display_info.bus_formats[0]; + + lvds_serialiser_on(lvds, bus_format); } =20 static void mchp_lvds_atomic_disable(struct drm_bridge *bridge, --=20 2.43.0