On Fri, Jul 25, 2025 at 10:33:59AM +0530, Suraj Kandpal wrote:
> Add connector helper function for atomic check which sets the
> mode_changed bit and checks if pixel format of fb is valid or not.
> 
> Signed-off-by: Suraj Kandpal <suraj.kand...@intel.com>
> ---
>  .../gpu/drm/i915/display/intel_writeback.c    | 49 +++++++++++++++++++
>  1 file changed, 49 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_writeback.c 
> b/drivers/gpu/drm/i915/display/intel_writeback.c
> index 9b2432d86d35..7fb30cc61991 100644
> --- a/drivers/gpu/drm/i915/display/intel_writeback.c
> +++ b/drivers/gpu/drm/i915/display/intel_writeback.c
> @@ -186,6 +186,54 @@ static void intel_writeback_connector_destroy(struct 
> drm_connector *connector)
>       kfree(connector);
>  }
>  
> +static int intel_writeback_check_format(u32 format)
> +{
> +     int i;
> +
> +     for (i = 0; i < ARRAY_SIZE(writeback_formats); i++) {
> +             if (writeback_formats[i] == format)
> +                     return 0;
> +     }
> +
> +     return -EINVAL;
> +}
> +
> +static int intel_writeback_atomic_check(struct drm_connector *connector,
> +                                     struct drm_atomic_state *state)
> +{
> +     struct drm_connector_state *conn_state =
> +             drm_atomic_get_new_connector_state(state, connector);
> +     struct drm_crtc_state *crtc_state;
> +     struct drm_framebuffer *fb;
> +     int ret;
> +
> +     /* We return 0 since this is called while disabling writeback encoder */
> +     if (!conn_state->crtc)
> +             return 0;
> +
> +     /* We do not allow a blank commit when using writeback connector */
> +     if (!conn_state->writeback_job)
> +             return -EINVAL;
> +
> +     fb = conn_state->writeback_job->fb;
> +     if (!fb)
> +             return -EINVAL;

Other atomic_check functions return 0 if there is no writeback_job or no
FB. Please elaborate.

> +
> +     crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> +     if (fb->width != crtc_state->mode.hdisplay ||
> +         fb->height != crtc_state->mode.vdisplay)
> +             return -EINVAL;
> +
> +     ret = intel_writeback_check_format(fb->format->format);
> +     if (ret) {
> +             drm_dbg_kms(connector->dev,
> +                         "Unsupported drm format sent in writeback job\n");
> +             return ret;
> +     }

Missing a call to drm_atomic_helper_check_wb_connector_state(). Please
use the framework where available.

> +
> +     return 0;
> +}
> +
>  static struct drm_writeback_connector *
>  intel_get_writeback_connector(struct drm_connector *connector)
>  {
> @@ -221,6 +269,7 @@ static const struct drm_connector_helper_funcs 
> conn_helper_funcs = {
>       .get_writeback_connector = intel_get_writeback_connector,
>       .get_modes = intel_writeback_get_modes,
>       .mode_valid = intel_writeback_mode_valid,
> +     .atomic_check = intel_writeback_atomic_check,
>       .prepare_writeback_job = intel_writeback_prepare_job,
>       .cleanup_writeback_job = intel_writeback_cleanup_job,
>  };
> -- 
> 2.34.1
> 

-- 
With best wishes
Dmitry

Reply via email to