Hi,

On Fri, Nov 22, 2024 at 05:35:11PM +0100, Louis Chauvet wrote:
> specific allocation for the CRTC is not strictly necessary at this point,
> but in order to implement dynamic configuration of VKMS (configFS), it
> will be easier to have one allocation per CRTC.
> 
> Signed-off-by: Louis Chauvet <louis.chau...@bootlin.com>

This one should probably be split further, there's several things going
on right now.

> ---
>  drivers/gpu/drm/vkms/vkms_crtc.c      | 32 +++++++++++++++++---------------
>  drivers/gpu/drm/vkms/vkms_drv.h       |  9 +++++----
>  drivers/gpu/drm/vkms/vkms_output.c    | 26 +++++++++++++++-----------
>  drivers/gpu/drm/vkms/vkms_writeback.c | 17 +++++++++--------
>  4 files changed, 46 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c 
> b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 
> ace8d293f7da611110c1e117b6cf2f3c9e9b4381..d014dec117e7d4ec7e9e38037a4a4cb4bc6be4ca
>  100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -84,9 +84,7 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc,
>                                     int *max_error, ktime_t *vblank_time,
>                                     bool in_vblank_irq)
>  {
> -     struct drm_device *dev = crtc->dev;
> -     struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
> -     struct vkms_output *output = &vkmsdev->output;
> +     struct vkms_output *output = drm_crtc_to_vkms_output(crtc);
>       struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
>  
>       if (!READ_ONCE(vblank->enabled)) {
> @@ -279,25 +277,29 @@ static void vkms_crtc_destroy_workqueue(struct 
> drm_device *dev,
>       destroy_workqueue(vkms_out->composer_workq);
>  }
>  
> -int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> -                struct drm_plane *primary, struct drm_plane *cursor)
> +struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plane 
> *primary,
> +                                struct drm_plane *cursor)
>  {
> -     struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc);
> +     struct vkms_output *vkms_out;
> +     struct drm_crtc *crtc;
>       int ret;
>  
> -     ret = drmm_crtc_init_with_planes(dev, crtc, primary, cursor,
> -                                      &vkms_crtc_funcs, NULL);
> -     if (ret) {
> -             DRM_ERROR("Failed to init CRTC\n");
> -             return ret;
> +     vkms_out = drmm_crtc_alloc_with_planes(dev, struct vkms_output, crtc,
> +                                            primary, cursor,
> +                                            &vkms_crtc_funcs, NULL);
> +     if (IS_ERR(vkms_out)) {
> +             DRM_DEV_ERROR(dev->dev, "Failed to init CRTC\n");
> +             return vkms_out;
>       }
>  
> +     crtc = &vkms_out->crtc;
> +
>       drm_crtc_helper_add(crtc, &vkms_crtc_helper_funcs);
>  
>       ret = drm_mode_crtc_set_gamma_size(crtc, VKMS_LUT_SIZE);
>       if (ret) {
>               DRM_ERROR("Failed to set gamma size\n");
> -             return ret;
> +             return ERR_PTR(ret);
>       }
>  
>       drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE);
> @@ -307,12 +309,12 @@ int vkms_crtc_init(struct drm_device *dev, struct 
> drm_crtc *crtc,
>  
>       vkms_out->composer_workq = alloc_ordered_workqueue("vkms_composer", 0);
>       if (!vkms_out->composer_workq)
> -             return -ENOMEM;
> +             return ERR_PTR(-ENOMEM);
>  
>       ret = drmm_add_action_or_reset(dev, vkms_crtc_destroy_workqueue,
>                                      vkms_out);
>       if (ret)
> -             return ret;
> +             return ERR_PTR(ret);
>  
> -     return ret;
> +     return vkms_out;
>  }
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> index 
> 19fd99b8e506c4454d7878b67f692a0441c22665..fbe7de67fb9c6a6a6964d71b452b9a3ce573e0f8
>  100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.h
> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> @@ -214,7 +214,6 @@ struct vkms_config {
>  struct vkms_device {
>       struct drm_device drm;
>       struct platform_device *platform;
> -     struct vkms_output output;
>       const struct vkms_config *config;
>  };
>  
> @@ -241,8 +240,9 @@ struct vkms_device {
>   * @primary: primary plane to attach to the CRTC
>   * @cursor: plane to attach to the CRTC
>   */
> -int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> -                struct drm_plane *primary, struct drm_plane *cursor);
> +struct vkms_output *vkms_crtc_init(struct drm_device *dev,
> +                                struct drm_plane *primary,
> +                                struct drm_plane *cursor);

You also need to update the doc.

Maxime

Attachment: signature.asc
Description: PGP signature

Reply via email to