2024-05-24 09:35:42

by Jayesh Choudhary

[permalink] [raw]
Subject: [PATCH v3 0/2] Add mode_valid hook for sii902x bridge

Currently, there are no check to validate the modes in the bridge.
Add pixel clock check to validate the modes that the bridge can support.

Also add the mode_valid hook in drm_bridge_funcs structure to take care
of the case when the encoder attaches the bridge chain with the
DRM_BRIDGE_ATTACH_NO_CONNECTOR flag in which case, the connector is not
initialized in the bridge's attach call.

Also add this check to the atomic_check call as suggested by Maxime in
v1 patch.

Changelog v2->v3:
- Remove newline that was introduced in [1/2] and later deleted in [2/2]
in v2

v2 patch:
<https://lore.kernel.org/all/[email protected]/>

Changelog v1->v2:
- Add KHZ suffix in the macros to be more clear
- Add the hook for drm_bridge_funcs as well
- Add check in atomic_check dunction call (in a separate patch)

v1 patch:
<https://lore.kernel.org/all/[email protected]/>

Jayesh Choudhary (2):
drm/bridge: sii902x: Fix mode_valid hook
drm/bridge: Add pixel clock check in atomic_check

drivers/gpu/drm/bridge/sii902x.c | 43 ++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)

--
2.25.1



2024-05-24 09:36:09

by Jayesh Choudhary

[permalink] [raw]
Subject: [PATCH v3 2/2] drm/bridge: Add pixel clock check in atomic_check

Check the pixel clock for the mode in atomic_check and ensure that
it is within the range supported by the bridge.

Signed-off-by: Jayesh Choudhary <[email protected]>
---
drivers/gpu/drm/bridge/sii902x.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index bae551e107f9..a5b7ee1e3bbe 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -517,6 +517,12 @@ static int sii902x_bridge_atomic_check(struct drm_bridge *bridge,
struct drm_crtc_state *crtc_state,
struct drm_connector_state *conn_state)
{
+ if (crtc_state->mode.clock < SII902X_MIN_PIXEL_CLOCK_KHZ)
+ return MODE_CLOCK_LOW;
+
+ if (crtc_state->mode.clock > SII902X_MAX_PIXEL_CLOCK_KHZ)
+ return MODE_CLOCK_HIGH;
+
/*
* There might be flags negotiation supported in future but
* set the bus flags in atomic_check statically for now.
--
2.25.1