Commit dfb9f5ca authored by Haneen Mohammed's avatar Haneen Mohammed Committed by Sean Paul

drm/vkms: subclass CRTC state

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: default avatarHaneen Mohammed <hamohammed.sa@gmail.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarSean Paul <seanpaul@chromium.org>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1f3564a5a0a6c4410c5d383c86a572ddda4818a8.1532446182.git.hamohammed.sa@gmail.com
parent d7734b74
......@@ -64,13 +64,60 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
return true;
}
static void vkms_atomic_crtc_reset(struct drm_crtc *crtc)
{
struct vkms_crtc_state *vkms_state = NULL;
if (crtc->state) {
vkms_state = to_vkms_crtc_state(crtc->state);
__drm_atomic_helper_crtc_destroy_state(crtc->state);
kfree(vkms_state);
crtc->state = NULL;
}
vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL);
if (!vkms_state)
return;
crtc->state = &vkms_state->base;
crtc->state->crtc = crtc;
}
static struct drm_crtc_state *
vkms_atomic_crtc_duplicate_state(struct drm_crtc *crtc)
{
struct vkms_crtc_state *vkms_state;
if (WARN_ON(!crtc->state))
return NULL;
vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL);
if (!vkms_state)
return NULL;
__drm_atomic_helper_crtc_duplicate_state(crtc, &vkms_state->base);
return &vkms_state->base;
}
static void vkms_atomic_crtc_destroy_state(struct drm_crtc *crtc,
struct drm_crtc_state *state)
{
struct vkms_crtc_state *vkms_state;
vkms_state = to_vkms_crtc_state(state);
__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_atomic_crtc_reset,
.atomic_duplicate_state = vkms_atomic_crtc_duplicate_state,
.atomic_destroy_state = vkms_atomic_crtc_destroy_state,
.enable_vblank = vkms_enable_vblank,
.disable_vblank = vkms_disable_vblank,
};
......
......@@ -20,6 +20,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;
......@@ -52,6 +60,9 @@ struct vkms_gem_object {
#define drm_gem_to_vkms_gem(target)\
container_of(target, struct vkms_gem_object, gem)
#define to_vkms_crtc_state(target)\
container_of(target, struct vkms_crtc_state, base)
/* CRTC */
int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
struct drm_plane *primary, struct drm_plane *cursor);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment