[PATCH 4/4] drm/vkms: subclass CRTC state
Daniel Vetter
daniel at ffwll.ch
Tue Jul 10 08:10:46 UTC 2018
On Mon, Jul 09, 2018 at 06:48:36PM +0300, Haneen Mohammed wrote:
> Subclass CRTC state struct to enable storing driver's private
> state. This patch only adds the base drm_crtc_state struct and
> the atomic functions that handle it.
>
> Signed-off-by: Haneen Mohammed <hamohammed.sa at gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> ---
> drivers/gpu/drm/vkms/vkms_crtc.c | 55 ++++++++++++++++++++++++++++++--
> drivers/gpu/drm/vkms/vkms_drv.h | 8 +++++
> 2 files changed, 60 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 84cc05506b09..56206437647d 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -10,13 +10,62 @@
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_crtc_helper.h>
>
> +static void vkms_crtc_reset(struct drm_crtc *crtc)
> +{
> + struct vkms_crtc_state *state = NULL;
> +
> + if (crtc->state) {
> + state = container_of(crtc->state, struct vkms_crtc_state,
> + base);
> + __drm_atomic_helper_crtc_destroy_state(crtc->state);
> + kfree(state);
> + crtc->state = NULL;
> + }
> +
> + state = kzalloc(sizeof(*state), GFP_KERNEL);
Hm, using kzalloc here is a good idea instead of kmalloc like in the
default functions. Care to write a patch for drm_atomic_helper to replace
all the kmalloc with kzalloc?
Thanks, Daniel
> + if (!state)
> + return;
> +
> + crtc->state = &state->base;
> + crtc->state->crtc = crtc;
> +}
> +
> +static struct drm_crtc_state *
> +vkms_crtc_duplicate_state(struct drm_crtc *crtc)
> +{
> + struct vkms_crtc_state *state;
> +
> + if (WARN_ON(!crtc->state))
> + return NULL;
> +
> + state = kzalloc(sizeof(*state), GFP_KERNEL);
> + if (!state)
> + return NULL;
> +
> + __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
> +
> + return &state->base;
> +}
> +
> +static void vkms_crtc_destroy_state(struct drm_crtc *crtc,
> + struct drm_crtc_state *state)
> +{
> + struct vkms_crtc_state *vkms_state;
> +
> + vkms_state = container_of(state, struct vkms_crtc_state, base);
> +
> + __drm_atomic_helper_crtc_destroy_state(state);
> + kfree(vkms_state);
> +}
> +
> static const struct drm_crtc_funcs vkms_crtc_funcs = {
> .set_config = drm_atomic_helper_set_config,
> .destroy = drm_crtc_cleanup,
> .page_flip = drm_atomic_helper_page_flip,
> - .reset = drm_atomic_helper_crtc_reset,
> - .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
> - .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> +
> + .reset = vkms_crtc_reset,
> + .atomic_duplicate_state = vkms_crtc_duplicate_state,
> + .atomic_destroy_state = vkms_crtc_destroy_state,
> };
>
> static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> index d339a8108d85..61e367d32308 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.h
> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> @@ -19,6 +19,14 @@ static const u32 vkms_formats[] = {
> DRM_FORMAT_XRGB8888,
> };
>
> +/**
> + * vkms_crtc_state - Driver specific CRTC state
> + * @base: base CRTC state
> + */
> +struct vkms_crtc_state {
> + struct drm_crtc_state base;
> +};
> +
> struct vkms_output {
> struct drm_crtc crtc;
> struct drm_encoder encoder;
> --
> 2.17.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the dri-devel
mailing list