Currently, most callers of intel_panel_mode_valid() also call
intel_panel_fixed_mode(). This is done either to check for the presence of
a fixed mode for the connector or to get the clock of the fixed mode, which
is then compared against the max dotclock for the pipe.
Since intel_panel_mode_valid() already calls intel_panel_fixed_mode()
internally, we can avoid yet another call to intel_panel_fixed_mode() from
the caller.
Remove the redundant call to intel_panel_fixed_mode() in mode_valid paths.
To get the clock for the fixed mode, extend the helper
intel_panel_mode_valid() to accept 'target_clock' as an out param.
The 'target_clock' can then be used by the callers to check against the
max dotclock.
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
Link: https://patch.msgid.link/20260430131220.3891497-3-ankit.k.nautiyal@intel.com
struct intel_connector *connector = to_intel_connector(_connector);
const struct drm_display_info *info = &connector->base.display_info;
struct intel_dp *intel_dp = intel_attached_dp(connector);
- const struct drm_display_mode *fixed_mode;
int target_clock = mode->clock;
enum drm_mode_status status;
if (intel_dp_hdisplay_bad(display, mode->hdisplay))
return MODE_H_ILLEGAL;
- fixed_mode = intel_panel_fixed_mode(connector, mode);
- if (intel_dp_is_edp(intel_dp) && fixed_mode) {
- status = intel_panel_mode_valid(connector, mode);
+ if (intel_dp_is_edp(intel_dp)) {
+ status = intel_panel_mode_valid(connector, mode, &target_clock);
if (status != MODE_OK)
return status;
-
- target_clock = fixed_mode->clock;
}
/*
{
struct intel_display *display = to_intel_display(connector->dev);
struct intel_connector *intel_connector = to_intel_connector(connector);
- const struct drm_display_mode *fixed_mode =
- intel_panel_fixed_mode(intel_connector, mode);
int max_dotclk = display->cdclk.max_dotclk_freq;
enum drm_mode_status status;
+ int target_clock;
drm_dbg_kms(display->drm, "\n");
- status = intel_panel_mode_valid(intel_connector, mode);
+ status = intel_panel_mode_valid(intel_connector, mode, &target_clock);
if (status != MODE_OK)
return status;
- if (fixed_mode->clock > max_dotclk)
+ if (target_clock > max_dotclk)
return MODE_CLOCK_HIGH;
return intel_mode_valid_max_plane_size(display, mode, 1);
struct intel_display *display = to_intel_display(_connector->dev);
struct intel_connector *connector = to_intel_connector(_connector);
struct intel_dvo *intel_dvo = intel_attached_dvo(connector);
- const struct drm_display_mode *fixed_mode =
- intel_panel_fixed_mode(connector, mode);
int max_dotclk = display->cdclk.max_dotclk_freq;
int target_clock = mode->clock;
enum drm_mode_status status;
return status;
/* XXX: Validate clock range */
-
- if (fixed_mode) {
- enum drm_mode_status status;
-
- status = intel_panel_mode_valid(connector, mode);
- if (status != MODE_OK)
- return status;
-
- target_clock = fixed_mode->clock;
- }
+ status = intel_panel_mode_valid(connector, mode, &target_clock);
+ if (status != MODE_OK)
+ return status;
if (target_clock > max_dotclk)
return MODE_CLOCK_HIGH;
{
struct intel_display *display = to_intel_display(_connector->dev);
struct intel_connector *connector = to_intel_connector(_connector);
- const struct drm_display_mode *fixed_mode =
- intel_panel_fixed_mode(connector, mode);
int max_pixclk = display->cdclk.max_dotclk_freq;
enum drm_mode_status status;
+ int target_clock;
status = intel_cpu_transcoder_mode_valid(display, mode);
if (status != MODE_OK)
return status;
- status = intel_panel_mode_valid(connector, mode);
+ status = intel_panel_mode_valid(connector, mode, &target_clock);
if (status != MODE_OK)
return status;
- if (fixed_mode->clock > max_pixclk)
+ if (target_clock > max_pixclk)
return MODE_CLOCK_HIGH;
return MODE_OK;
enum drm_mode_status
intel_panel_mode_valid(struct intel_connector *connector,
- const struct drm_display_mode *mode)
+ const struct drm_display_mode *mode,
+ int *target_clock)
{
const struct drm_display_mode *fixed_mode =
intel_panel_fixed_mode(connector, mode);
+ if (target_clock)
+ *target_clock = mode->clock;
+
if (!fixed_mode)
return MODE_OK;
if (drm_mode_vrefresh(mode) != drm_mode_vrefresh(fixed_mode))
return MODE_PANEL;
+ if (target_clock)
+ *target_clock = fixed_mode->clock;
+
return MODE_OK;
}
enum drrs_type intel_panel_drrs_type(struct intel_connector *connector);
enum drm_mode_status
intel_panel_mode_valid(struct intel_connector *connector,
- const struct drm_display_mode *mode);
+ const struct drm_display_mode *mode,
+ int *target_clock);
int intel_panel_compute_config(struct intel_connector *connector,
struct drm_display_mode *adjusted_mode);
void intel_panel_add_edid_fixed_modes(struct intel_connector *connector,
if (IS_LVDS(intel_sdvo_connector)) {
enum drm_mode_status status;
- const struct drm_display_mode *fixed_mode;
+ int target_clock;
- status = intel_panel_mode_valid(&intel_sdvo_connector->base, mode);
+ status = intel_panel_mode_valid(&intel_sdvo_connector->base, mode, &target_clock);
if (status != MODE_OK)
return status;
- fixed_mode = intel_panel_fixed_mode(&intel_sdvo_connector->base, mode);
-
- if (fixed_mode && fixed_mode->clock > max_dotclk)
+ if (target_clock > max_dotclk)
return MODE_CLOCK_HIGH;
}