drm/bridge: adv7533: Fix adv7533_mode_valid for adv7533 and adv7535
Subsystems (3)
PATCH 1/1 drm/bridge: adv7533: Fix adv7533_mode_valid for adv7533 and adv7535
When dynamically switching lanes was removed, the intent of the code was to check to make sure that higher speed items used 4 lanes, but it had the unintended consequence of removing the slower speeds for 4-lane users.
This attempts to remedy this by doing a check to see that the max frequency doesn't exceed the chip limit, and a second check to make sure that the max bit-rate doesn't exceed the number of lanes * max bit rate / lane.
drivers/gpu/drm/bridge/adv7511/adv7533.c +12 -8
@@ -103,13 +103,9 @@ void adv7533_dsi_power_off(struct adv7511 *adv)enum drm_mode_status adv7533_mode_valid (struct adv7511 *adv,const struct drm_display_mode *mode) { -int lanes; +unsigned long max_lane_freq;struct mipi_dsi_device *dsi = adv->dsi; - -if (mode->clock >80000 ) - lanes =4 ; -else - lanes =3 ; +u8 bpp =mipi_dsi_pixel_format_to_bpp (dsi->format);/* * TODO: add support for dynamic switching of lanes
@@ -117,8 +113,16 @@ enum drm_mode_status adv7533_mode_valid(struct adv7511 *adv,* out the modes which shall need different number of lanes * than what was configured in the device tree. */ -if (lanes != dsi->lanes) -return MODE_BAD ; + +/* Check max clock for either 7533 or 7535 */ +if (mode->clock > (adv->type ==ADV7533 ?80000 :148500 )) +return MODE_CLOCK_HIGH ; + +/* Check max clock for each lane */ + max_lane_freq = (adv->type ==ADV7533 ?800000 :891000 ); + +if (mode->clock * bpp > max_lane_freq * adv->num_dsi_lanes) +return MODE_CLOCK_HIGH ;return MODE_OK ; }
Signature · 1 line
2.37.2
Quoted 5 lines · Adam Ford
When dynamically switching lanes was removed, the intent of the code was to check to make sure that higher speed items used 4 lanes, but it had the unintended consequence of removing the slower speeds for 4-lane users.
Quoted 7 lines
This attempts to remedy this by doing a check to see that the max frequency doesn't exceed the chip limit, and a second check to make sure that the max bit-rate doesn't exceed the number of lanes * max bit rate / lane.
Fixes 9a0cdcd6649b ("drm/bridge: adv7533: remove dynamic lane switching from adv7533 bridge")
Please remove the empty line here. There should be no empty lines between the tags
Quoted 12 lines
Signed-off-by Adam Ford <[email protected]>drivers/gpu/drm/bridge/adv7511/adv7533.c +1
-1@@ -103,13 +103,9 @@ void adv7533_dsi_power_off(struct adv7511 *adv)enum drm_mode_status adv7533_mode_valid (struct adv7511 *adv,const struct drm_display_mode *mode) { -int lanes; +unsigned long max_lane_freq;
drivers/gpu/drm/bridge/adv7511/adv7533.c void adv7533_dsi_power_off(struct adv7511 *adv) · line 111
Quoted 10 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c +1
-5struct mipi_dsi_device *dsi = adv->dsi; - -if (mode->clock >80000 ) - lanes =4 ; -else - lanes =3 ; +u8 bpp =mipi_dsi_pixel_format_to_bpp (dsi->format);/* * TODO: add support for dynamic switching of lanes
Drop the comment please. It makes little sense with your new implementation.
Quoted 19 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c +10
-2@@ -117,8 +113,16 @@ enum drm_mode_status adv7533_mode_valid(struct adv7511 *adv,* out the modes which shall need different number of lanes * than what was configured in the device tree. */ -if (lanes != dsi->lanes) -return MODE_BAD ; + +/* Check max clock for either 7533 or 7535 */ +if (mode->clock > (adv->type ==ADV7533 ?80000 :148500 )) +return MODE_CLOCK_HIGH ; + +/* Check max clock for each lane */ + max_lane_freq = (adv->type ==ADV7533 ?800000 :891000 ); + +if (mode->clock * bpp > max_lane_freq * adv->num_dsi_lanes) +return MODE_CLOCK_HIGH ;return MODE_OK ; }
Signature · 2 lines
With best wishes Dmitry
Robert Foss
maintainerQuoted 61 lines · Dmitry Baryshkov
Quoted 5 lines · Adam Ford
When dynamically switching lanes was removed, the intent of the code was to check to make sure that higher speed items used 4 lanes, but it had the unintended consequence of removing the slower speeds for 4-lane users.
Quoted 7 lines
This attempts to remedy this by doing a check to see that the max frequency doesn't exceed the chip limit, and a second check to make sure that the max bit-rate doesn't exceed the number of lanes * max bit rate / lane.
Fixes 9a0cdcd6649b ("drm/bridge: adv7533: remove dynamic lane switching from adv7533 bridge")Please remove the empty line here. There should be no empty lines between the tags
Quoted 12 lines
Signed-off-by Adam Ford <[email protected]>drivers/gpu/drm/bridge/adv7511/adv7533.c +1
-1@@ -103,13 +103,9 @@ void adv7533_dsi_power_off(struct adv7511 *adv)enum drm_mode_status adv7533_mode_valid (struct adv7511 *adv,const struct drm_display_mode *mode) { -int lanes; +unsigned long max_lane_freq;drivers/gpu/drm/bridge/adv7511/adv7533.c void adv7533_dsi_power_off(struct adv7511 *adv) · line 111
Quoted 10 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c +1
-5struct mipi_dsi_device *dsi = adv->dsi; - -if (mode->clock >80000 ) - lanes =4 ; -else - lanes =3 ; +u8 bpp =mipi_dsi_pixel_format_to_bpp (dsi->format);/* * TODO: add support for dynamic switching of lanes Drop the comment please. It makes little sense with your new implementation.
Quoted 17 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c +10
-2@@ -117,8 +113,16 @@ enum drm_mode_status adv7533_mode_valid(struct adv7511 *adv,* out the modes which shall need different number of lanes * than what was configured in the device tree. */ -if (lanes != dsi->lanes) -return MODE_BAD ; + +/* Check max clock for either 7533 or 7535 */ +if (mode->clock > (adv->type ==ADV7533 ?80000 :148500 )) +return MODE_CLOCK_HIGH ; + +/* Check max clock for each lane */ + max_lane_freq = (adv->type ==ADV7533 ?800000 :891000 ); + +if (mode->clock * bpp > max_lane_freq * adv->num_dsi_lanes) +return MODE_CLOCK_HIGH ;
Quoted 7 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c enum drm_mode_status adv7533_mode_valid(struct adv7511 *adv, · line 128
Quoted 2 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c +0
-0return MODE_OK ; }--
With best wishes
Dmitry
With Dmitrys feedback, feel free to add my Reviewed-by.