Message ID | 20240524071348.106210-1-j-choudhary@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm: bridge: cdns-mhdp8546: Add mode_valid hook for the drm_bridge_funcs | expand |
On Fri, May 24, 2024 at 12:43:48PM +0530, Jayesh Choudhary wrote: > With the support for the 'DRM_BRIDGE_ATTACH_NO_CONNECTOR' case, > the connector_helper funcs are not initialized if the encoder has this > flag in its bridge_attach call. Till now we had mode_valid hook only in > the drm_connector_helper_funcs. Add this hook in drm_bridge_funcs to > validate the modes in this case as well. > > Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com> > --- > .../drm/bridge/cadence/cdns-mhdp8546-core.c | 31 +++++++++++++++---- > 1 file changed, 25 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c > index 8a91ef0ae065..0aee038f5db7 100644 > --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c > +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c > @@ -1617,12 +1617,10 @@ bool cdns_mhdp_bandwidth_ok(struct cdns_mhdp_device *mhdp, > return true; > } > > -static > -enum drm_mode_status cdns_mhdp_mode_valid(struct drm_connector *conn, > - struct drm_display_mode *mode) > +static enum > +drm_mode_status cdns_mhdp_mode_valid(struct cdns_mhdp_device *mhdp, > + const struct drm_display_mode *mode) > { > - struct cdns_mhdp_device *mhdp = connector_to_mhdp(conn); > - > mutex_lock(&mhdp->link_mutex); > > if (!cdns_mhdp_bandwidth_ok(mhdp, mode, mhdp->link.num_lanes, > @@ -1635,6 +1633,16 @@ enum drm_mode_status cdns_mhdp_mode_valid(struct drm_connector *conn, > return MODE_OK; > } > > +static enum drm_mode_status > +cdns_mhdp_connector_mode_valid(struct drm_connector *conn, > + struct drm_display_mode *mode) > +{ > + struct cdns_mhdp_device *mhdp = connector_to_mhdp(conn); > + const struct drm_display_mode *mod = mode; > + > + return cdns_mhdp_mode_valid(mhdp, mod); > +} > + > static int cdns_mhdp_connector_atomic_check(struct drm_connector *conn, > struct drm_atomic_state *state) > { > @@ -1678,7 +1686,7 @@ static int cdns_mhdp_connector_atomic_check(struct drm_connector *conn, > static const struct drm_connector_helper_funcs cdns_mhdp_conn_helper_funcs = { > .detect_ctx = cdns_mhdp_connector_detect, > .get_modes = cdns_mhdp_get_modes, > - .mode_valid = cdns_mhdp_mode_valid, > + .mode_valid = cdns_mhdp_connector_mode_valid, Just move it to bridge_funcs and drop it from connector_helper_funcs. It should be enough. > .atomic_check = cdns_mhdp_connector_atomic_check, > }; > > @@ -2233,6 +2241,16 @@ static const struct drm_edid *cdns_mhdp_bridge_edid_read(struct drm_bridge *brid > return cdns_mhdp_edid_read(mhdp, connector); > } > > +static enum drm_mode_status > +cdns_mhdp_bridge_mode_valid(struct drm_bridge *bridge, > + const struct drm_display_info *info, > + const struct drm_display_mode *mode) > +{ > + struct cdns_mhdp_device *mhdp = bridge_to_mhdp(bridge); > + > + return cdns_mhdp_mode_valid(mhdp, mode); > +} > + > static const struct drm_bridge_funcs cdns_mhdp_bridge_funcs = { > .atomic_enable = cdns_mhdp_atomic_enable, > .atomic_disable = cdns_mhdp_atomic_disable, > @@ -2247,6 +2265,7 @@ static const struct drm_bridge_funcs cdns_mhdp_bridge_funcs = { > .edid_read = cdns_mhdp_bridge_edid_read, > .hpd_enable = cdns_mhdp_bridge_hpd_enable, > .hpd_disable = cdns_mhdp_bridge_hpd_disable, > + .mode_valid = cdns_mhdp_bridge_mode_valid, > }; > > static bool cdns_mhdp_detect_hpd(struct cdns_mhdp_device *mhdp, bool *hpd_pulse) > -- > 2.25.1 >
On 24/05/24 15:13, Dmitry Baryshkov wrote: > On Fri, May 24, 2024 at 12:43:48PM +0530, Jayesh Choudhary wrote: >> With the support for the 'DRM_BRIDGE_ATTACH_NO_CONNECTOR' case, >> the connector_helper funcs are not initialized if the encoder has this >> flag in its bridge_attach call. Till now we had mode_valid hook only in >> the drm_connector_helper_funcs. Add this hook in drm_bridge_funcs to >> validate the modes in this case as well. >> >> Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com> >> --- >> .../drm/bridge/cadence/cdns-mhdp8546-core.c | 31 +++++++++++++++---- >> 1 file changed, 25 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c >> index 8a91ef0ae065..0aee038f5db7 100644 >> --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c >> +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c >> @@ -1617,12 +1617,10 @@ bool cdns_mhdp_bandwidth_ok(struct cdns_mhdp_device *mhdp, >> return true; >> } >> >> -static >> -enum drm_mode_status cdns_mhdp_mode_valid(struct drm_connector *conn, >> - struct drm_display_mode *mode) >> +static enum >> +drm_mode_status cdns_mhdp_mode_valid(struct cdns_mhdp_device *mhdp, >> + const struct drm_display_mode *mode) >> { >> - struct cdns_mhdp_device *mhdp = connector_to_mhdp(conn); >> - >> mutex_lock(&mhdp->link_mutex); >> >> if (!cdns_mhdp_bandwidth_ok(mhdp, mode, mhdp->link.num_lanes, >> @@ -1635,6 +1633,16 @@ enum drm_mode_status cdns_mhdp_mode_valid(struct drm_connector *conn, >> return MODE_OK; >> } >> >> +static enum drm_mode_status >> +cdns_mhdp_connector_mode_valid(struct drm_connector *conn, >> + struct drm_display_mode *mode) >> +{ >> + struct cdns_mhdp_device *mhdp = connector_to_mhdp(conn); >> + const struct drm_display_mode *mod = mode; >> + >> + return cdns_mhdp_mode_valid(mhdp, mod); >> +} >> + >> static int cdns_mhdp_connector_atomic_check(struct drm_connector *conn, >> struct drm_atomic_state *state) >> { >> @@ -1678,7 +1686,7 @@ static int cdns_mhdp_connector_atomic_check(struct drm_connector *conn, >> static const struct drm_connector_helper_funcs cdns_mhdp_conn_helper_funcs = { >> .detect_ctx = cdns_mhdp_connector_detect, >> .get_modes = cdns_mhdp_get_modes, >> - .mode_valid = cdns_mhdp_mode_valid, >> + .mode_valid = cdns_mhdp_connector_mode_valid, > > Just move it to bridge_funcs and drop it from connector_helper_funcs. It > should be enough. Okay. Will change in v2. Thanks, Jayesh > >> .atomic_check = cdns_mhdp_connector_atomic_check, >> }; >> >> @@ -2233,6 +2241,16 @@ static const struct drm_edid *cdns_mhdp_bridge_edid_read(struct drm_bridge *brid >> return cdns_mhdp_edid_read(mhdp, connector); >> } >> >> +static enum drm_mode_status >> +cdns_mhdp_bridge_mode_valid(struct drm_bridge *bridge, >> + const struct drm_display_info *info, >> + const struct drm_display_mode *mode) >> +{ >> + struct cdns_mhdp_device *mhdp = bridge_to_mhdp(bridge); >> + >> + return cdns_mhdp_mode_valid(mhdp, mode); >> +} >> + >> static const struct drm_bridge_funcs cdns_mhdp_bridge_funcs = { >> .atomic_enable = cdns_mhdp_atomic_enable, >> .atomic_disable = cdns_mhdp_atomic_disable, >> @@ -2247,6 +2265,7 @@ static const struct drm_bridge_funcs cdns_mhdp_bridge_funcs = { >> .edid_read = cdns_mhdp_bridge_edid_read, >> .hpd_enable = cdns_mhdp_bridge_hpd_enable, >> .hpd_disable = cdns_mhdp_bridge_hpd_disable, >> + .mode_valid = cdns_mhdp_bridge_mode_valid, >> }; >> >> static bool cdns_mhdp_detect_hpd(struct cdns_mhdp_device *mhdp, bool *hpd_pulse) >> -- >> 2.25.1 >> >
diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c index 8a91ef0ae065..0aee038f5db7 100644 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c @@ -1617,12 +1617,10 @@ bool cdns_mhdp_bandwidth_ok(struct cdns_mhdp_device *mhdp, return true; } -static -enum drm_mode_status cdns_mhdp_mode_valid(struct drm_connector *conn, - struct drm_display_mode *mode) +static enum +drm_mode_status cdns_mhdp_mode_valid(struct cdns_mhdp_device *mhdp, + const struct drm_display_mode *mode) { - struct cdns_mhdp_device *mhdp = connector_to_mhdp(conn); - mutex_lock(&mhdp->link_mutex); if (!cdns_mhdp_bandwidth_ok(mhdp, mode, mhdp->link.num_lanes, @@ -1635,6 +1633,16 @@ enum drm_mode_status cdns_mhdp_mode_valid(struct drm_connector *conn, return MODE_OK; } +static enum drm_mode_status +cdns_mhdp_connector_mode_valid(struct drm_connector *conn, + struct drm_display_mode *mode) +{ + struct cdns_mhdp_device *mhdp = connector_to_mhdp(conn); + const struct drm_display_mode *mod = mode; + + return cdns_mhdp_mode_valid(mhdp, mod); +} + static int cdns_mhdp_connector_atomic_check(struct drm_connector *conn, struct drm_atomic_state *state) { @@ -1678,7 +1686,7 @@ static int cdns_mhdp_connector_atomic_check(struct drm_connector *conn, static const struct drm_connector_helper_funcs cdns_mhdp_conn_helper_funcs = { .detect_ctx = cdns_mhdp_connector_detect, .get_modes = cdns_mhdp_get_modes, - .mode_valid = cdns_mhdp_mode_valid, + .mode_valid = cdns_mhdp_connector_mode_valid, .atomic_check = cdns_mhdp_connector_atomic_check, }; @@ -2233,6 +2241,16 @@ static const struct drm_edid *cdns_mhdp_bridge_edid_read(struct drm_bridge *brid return cdns_mhdp_edid_read(mhdp, connector); } +static enum drm_mode_status +cdns_mhdp_bridge_mode_valid(struct drm_bridge *bridge, + const struct drm_display_info *info, + const struct drm_display_mode *mode) +{ + struct cdns_mhdp_device *mhdp = bridge_to_mhdp(bridge); + + return cdns_mhdp_mode_valid(mhdp, mode); +} + static const struct drm_bridge_funcs cdns_mhdp_bridge_funcs = { .atomic_enable = cdns_mhdp_atomic_enable, .atomic_disable = cdns_mhdp_atomic_disable, @@ -2247,6 +2265,7 @@ static const struct drm_bridge_funcs cdns_mhdp_bridge_funcs = { .edid_read = cdns_mhdp_bridge_edid_read, .hpd_enable = cdns_mhdp_bridge_hpd_enable, .hpd_disable = cdns_mhdp_bridge_hpd_disable, + .mode_valid = cdns_mhdp_bridge_mode_valid, }; static bool cdns_mhdp_detect_hpd(struct cdns_mhdp_device *mhdp, bool *hpd_pulse)
With the support for the 'DRM_BRIDGE_ATTACH_NO_CONNECTOR' case, the connector_helper funcs are not initialized if the encoder has this flag in its bridge_attach call. Till now we had mode_valid hook only in the drm_connector_helper_funcs. Add this hook in drm_bridge_funcs to validate the modes in this case as well. Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com> --- .../drm/bridge/cadence/cdns-mhdp8546-core.c | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-)