Message ID | 20240530092930.434026-2-j-choudhary@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add mode_valid and atomic_check hooks for sii902x bridge | expand |
On Thu, May 30, 2024 at 02:59:29PM +0530, Jayesh Choudhary wrote: > Currently, mode_valid hook returns all mode as valid and it is > defined only in drm_connector_helper_funcs. With the introduction of > 'DRM_BRIDGE_ATTACH_NO_CONNECTOR', connector is not initialized in > bridge_attach call for cases when the encoder has this flag enabled. > So move the mode_valid hook to drm_bridge_funcs with proper clock > checks for maximum and minimum pixel clock supported by the bridge. > > Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com> > --- > drivers/gpu/drm/bridge/sii902x.c | 32 +++++++++++++++++++++++--------- > 1 file changed, 23 insertions(+), 9 deletions(-) > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Chris, you might be interested in testing this series.
Hi, On 5/30/24 17:29, Jayesh Choudhary wrote: > Currently, mode_valid hook returns all mode as valid and it is > defined only in drm_connector_helper_funcs. With the introduction of > 'DRM_BRIDGE_ATTACH_NO_CONNECTOR', connector is not initialized in > bridge_attach call for cases when the encoder has this flag enabled. > So move the mode_valid hook to drm_bridge_funcs with proper clock > checks for maximum and minimum pixel clock supported by the bridge. > > Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com> Acked-by: Sui Jingfeng <sui.jingfeng@linux.dev> > --- > drivers/gpu/drm/bridge/sii902x.c | 32 +++++++++++++++++++++++--------- > 1 file changed, 23 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c > index 2fbeda9025bf..6a6055a4ccf9 100644 > --- a/drivers/gpu/drm/bridge/sii902x.c > +++ b/drivers/gpu/drm/bridge/sii902x.c > @@ -163,6 +163,14 @@ > > #define SII902X_AUDIO_PORT_INDEX 3 > > +/* > + * The maximum resolution supported by the HDMI bridge is 1080p@60Hz > + * and 1920x1200 requiring a pixel clock of 165MHz and the minimum > + * resolution supported is 480p@60Hz requiring a pixel clock of 25MHz > + */ > +#define SII902X_MIN_PIXEL_CLOCK_KHZ 25000 > +#define SII902X_MAX_PIXEL_CLOCK_KHZ 165000 > + This bridge can drive 2560x1080@75Hz monitor(LG 34BL650), the pixel clock can up to 181250 kHz. I remember that I have tested the native mode with LS2K1000 SoC, and it do works in practice. And there are also has 320x240 panels, maybe it's also usuable with this HDMI transmitter Well, the datasheet mentioned that it supports up to 165 MHz dual-edge and single-edge modes. So I'm not against your patch, just mention it to let you know. > struct sii902x { > struct i2c_client *i2c; > struct regmap *regmap; > @@ -310,17 +318,8 @@ static int sii902x_get_modes(struct drm_connector *connector) > return num; > } > > -static enum drm_mode_status sii902x_mode_valid(struct drm_connector *connector, > - struct drm_display_mode *mode) > -{ > - /* TODO: check mode */ > - > - return MODE_OK; > -} > - > static const struct drm_connector_helper_funcs sii902x_connector_helper_funcs = { > .get_modes = sii902x_get_modes, > - .mode_valid = sii902x_mode_valid, > }; > > static void sii902x_bridge_disable(struct drm_bridge *bridge) > @@ -504,6 +503,20 @@ static int sii902x_bridge_atomic_check(struct drm_bridge *bridge, > return 0; > } > > +static enum drm_mode_status > +sii902x_bridge_mode_valid(struct drm_bridge *bridge, > + const struct drm_display_info *info, > + const struct drm_display_mode *mode) > +{ > + if (mode->clock < SII902X_MIN_PIXEL_CLOCK_KHZ) > + return MODE_CLOCK_LOW; > + > + if (mode->clock > SII902X_MAX_PIXEL_CLOCK_KHZ) > + return MODE_CLOCK_HIGH; > + > + return MODE_OK; > +} > + > static const struct drm_bridge_funcs sii902x_bridge_funcs = { > .attach = sii902x_bridge_attach, > .mode_set = sii902x_bridge_mode_set, > @@ -516,6 +529,7 @@ static const struct drm_bridge_funcs sii902x_bridge_funcs = { > .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, > .atomic_get_input_bus_fmts = sii902x_bridge_atomic_get_input_bus_fmts, > .atomic_check = sii902x_bridge_atomic_check, > + .mode_valid = sii902x_bridge_mode_valid, > }; > > static int sii902x_mute(struct sii902x *sii902x, bool mute)
Hi Jayesh, > > + > > static const struct drm_bridge_funcs sii902x_bridge_funcs = { > > .attach = sii902x_bridge_attach, > > .mode_set = sii902x_bridge_mode_set, > > @@ -516,6 +529,7 @@ static const struct drm_bridge_funcs sii902x_bridge_funcs = { > > .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, > > .atomic_get_input_bus_fmts = sii902x_bridge_atomic_get_input_bus_fmts, > > .atomic_check = sii902x_bridge_atomic_check, > > + .mode_valid = sii902x_bridge_mode_valid, As you have the possibility to test the driver, it would be nice with a follow-up patch that replaces the use of enable() / disable() with the atomic counterparts. enable() / disable() are deprecated, so it is nice to reduce their use. Sam
Hi, Jayesh On 5/31/24 21:33, Sam Ravnborg wrote: > Hi Jayesh, > >>> + >>> static const struct drm_bridge_funcs sii902x_bridge_funcs = { >>> .attach = sii902x_bridge_attach, >>> .mode_set = sii902x_bridge_mode_set, >>> @@ -516,6 +529,7 @@ static const struct drm_bridge_funcs sii902x_bridge_funcs = { >>> .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, >>> .atomic_get_input_bus_fmts = sii902x_bridge_atomic_get_input_bus_fmts, >>> .atomic_check = sii902x_bridge_atomic_check, >>> + .mode_valid = sii902x_bridge_mode_valid, > > As you have the possibility to test the driver, it would be nice with a > follow-up patch that replaces the use of enable() / disable() with the > atomic counterparts. > > enable() / disable() are deprecated, so it is nice to reduce their use. I agree with Sam. Please using atomic uniformally with a follow-up patch, the mixed using of atomic API and non atomic API is a little bit confusing IMO. > Sam
Hello Sui, Sam! Thanks for the review. (Sorry for delayed response. I was OoO last week) On 31/05/24 19:34, Sui Jingfeng wrote: > Hi, Jayesh > > > On 5/31/24 21:33, Sam Ravnborg wrote: >> Hi Jayesh, >> >>>> + >>>> static const struct drm_bridge_funcs sii902x_bridge_funcs = { >>>> .attach = sii902x_bridge_attach, >>>> .mode_set = sii902x_bridge_mode_set, >>>> @@ -516,6 +529,7 @@ static const struct drm_bridge_funcs >>>> sii902x_bridge_funcs = { >>>> .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, >>>> .atomic_get_input_bus_fmts = >>>> sii902x_bridge_atomic_get_input_bus_fmts, >>>> .atomic_check = sii902x_bridge_atomic_check, >>>> + .mode_valid = sii902x_bridge_mode_valid, >> >> As you have the possibility to test the driver, it would be nice with a >> follow-up patch that replaces the use of enable() / disable() with the >> atomic counterparts. >> >> enable() / disable() are deprecated, so it is nice to reduce their use. > > I agree with Sam. > > Please using atomic uniformally with a follow-up patch, the mixed > using of atomic API and non atomic API is a little bit confusing IMO. > > I will change the enable and disable to their atomic counter parts in the next revision. Warm Regards, -Jayesh
diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c index 2fbeda9025bf..6a6055a4ccf9 100644 --- a/drivers/gpu/drm/bridge/sii902x.c +++ b/drivers/gpu/drm/bridge/sii902x.c @@ -163,6 +163,14 @@ #define SII902X_AUDIO_PORT_INDEX 3 +/* + * The maximum resolution supported by the HDMI bridge is 1080p@60Hz + * and 1920x1200 requiring a pixel clock of 165MHz and the minimum + * resolution supported is 480p@60Hz requiring a pixel clock of 25MHz + */ +#define SII902X_MIN_PIXEL_CLOCK_KHZ 25000 +#define SII902X_MAX_PIXEL_CLOCK_KHZ 165000 + struct sii902x { struct i2c_client *i2c; struct regmap *regmap; @@ -310,17 +318,8 @@ static int sii902x_get_modes(struct drm_connector *connector) return num; } -static enum drm_mode_status sii902x_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - /* TODO: check mode */ - - return MODE_OK; -} - static const struct drm_connector_helper_funcs sii902x_connector_helper_funcs = { .get_modes = sii902x_get_modes, - .mode_valid = sii902x_mode_valid, }; static void sii902x_bridge_disable(struct drm_bridge *bridge) @@ -504,6 +503,20 @@ static int sii902x_bridge_atomic_check(struct drm_bridge *bridge, return 0; } +static enum drm_mode_status +sii902x_bridge_mode_valid(struct drm_bridge *bridge, + const struct drm_display_info *info, + const struct drm_display_mode *mode) +{ + if (mode->clock < SII902X_MIN_PIXEL_CLOCK_KHZ) + return MODE_CLOCK_LOW; + + if (mode->clock > SII902X_MAX_PIXEL_CLOCK_KHZ) + return MODE_CLOCK_HIGH; + + return MODE_OK; +} + static const struct drm_bridge_funcs sii902x_bridge_funcs = { .attach = sii902x_bridge_attach, .mode_set = sii902x_bridge_mode_set, @@ -516,6 +529,7 @@ static const struct drm_bridge_funcs sii902x_bridge_funcs = { .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, .atomic_get_input_bus_fmts = sii902x_bridge_atomic_get_input_bus_fmts, .atomic_check = sii902x_bridge_atomic_check, + .mode_valid = sii902x_bridge_mode_valid, }; static int sii902x_mute(struct sii902x *sii902x, bool mute)
Currently, mode_valid hook returns all mode as valid and it is defined only in drm_connector_helper_funcs. With the introduction of 'DRM_BRIDGE_ATTACH_NO_CONNECTOR', connector is not initialized in bridge_attach call for cases when the encoder has this flag enabled. So move the mode_valid hook to drm_bridge_funcs with proper clock checks for maximum and minimum pixel clock supported by the bridge. Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com> --- drivers/gpu/drm/bridge/sii902x.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-)