Commit 38c5af44 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/simple-kms: Support custom CRTC state

Simple KMS helpers already support custom state for planes. Extend the
helpers to support custom CRTC state as well. Drivers can set the reset,
duplicate and destroy callbacks for the display pipeline's CRTC state
and inherit from struct drm_crtc_state by embedding an instance.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714142240.21979-12-tzimmermann@suse.de
parent 2545ac96
...@@ -145,6 +145,39 @@ static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = { ...@@ -145,6 +145,39 @@ static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = {
.atomic_disable = drm_simple_kms_crtc_disable, .atomic_disable = drm_simple_kms_crtc_disable,
}; };
static void drm_simple_kms_crtc_reset(struct drm_crtc *crtc)
{
struct drm_simple_display_pipe *pipe;
pipe = container_of(crtc, struct drm_simple_display_pipe, crtc);
if (!pipe->funcs || !pipe->funcs->reset_crtc)
return drm_atomic_helper_crtc_reset(crtc);
return pipe->funcs->reset_crtc(pipe);
}
static struct drm_crtc_state *drm_simple_kms_crtc_duplicate_state(struct drm_crtc *crtc)
{
struct drm_simple_display_pipe *pipe;
pipe = container_of(crtc, struct drm_simple_display_pipe, crtc);
if (!pipe->funcs || !pipe->funcs->duplicate_crtc_state)
return drm_atomic_helper_crtc_duplicate_state(crtc);
return pipe->funcs->duplicate_crtc_state(pipe);
}
static void drm_simple_kms_crtc_destroy_state(struct drm_crtc *crtc, struct drm_crtc_state *state)
{
struct drm_simple_display_pipe *pipe;
pipe = container_of(crtc, struct drm_simple_display_pipe, crtc);
if (!pipe->funcs || !pipe->funcs->destroy_crtc_state)
drm_atomic_helper_crtc_destroy_state(crtc, state);
else
pipe->funcs->destroy_crtc_state(pipe, state);
}
static int drm_simple_kms_crtc_enable_vblank(struct drm_crtc *crtc) static int drm_simple_kms_crtc_enable_vblank(struct drm_crtc *crtc)
{ {
struct drm_simple_display_pipe *pipe; struct drm_simple_display_pipe *pipe;
...@@ -168,12 +201,12 @@ static void drm_simple_kms_crtc_disable_vblank(struct drm_crtc *crtc) ...@@ -168,12 +201,12 @@ static void drm_simple_kms_crtc_disable_vblank(struct drm_crtc *crtc)
} }
static const struct drm_crtc_funcs drm_simple_kms_crtc_funcs = { static const struct drm_crtc_funcs drm_simple_kms_crtc_funcs = {
.reset = drm_atomic_helper_crtc_reset, .reset = drm_simple_kms_crtc_reset,
.destroy = drm_crtc_cleanup, .destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config, .set_config = drm_atomic_helper_set_config,
.page_flip = drm_atomic_helper_page_flip, .page_flip = drm_atomic_helper_page_flip,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, .atomic_duplicate_state = drm_simple_kms_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, .atomic_destroy_state = drm_simple_kms_crtc_destroy_state,
.enable_vblank = drm_simple_kms_crtc_enable_vblank, .enable_vblank = drm_simple_kms_crtc_enable_vblank,
.disable_vblank = drm_simple_kms_crtc_disable_vblank, .disable_vblank = drm_simple_kms_crtc_disable_vblank,
}; };
......
...@@ -153,6 +153,33 @@ struct drm_simple_display_pipe_funcs { ...@@ -153,6 +153,33 @@ struct drm_simple_display_pipe_funcs {
*/ */
void (*disable_vblank)(struct drm_simple_display_pipe *pipe); void (*disable_vblank)(struct drm_simple_display_pipe *pipe);
/**
* @reset_crtc:
*
* Optional, called by &drm_crtc_funcs.reset. Please read the
* documentation for the &drm_crtc_funcs.reset hook for more details.
*/
void (*reset_crtc)(struct drm_simple_display_pipe *pipe);
/**
* @duplicate_crtc_state:
*
* Optional, called by &drm_crtc_funcs.atomic_duplicate_state. Please
* read the documentation for the &drm_crtc_funcs.atomic_duplicate_state
* hook for more details.
*/
struct drm_crtc_state * (*duplicate_crtc_state)(struct drm_simple_display_pipe *pipe);
/**
* @destroy_crtc_state:
*
* Optional, called by &drm_crtc_funcs.atomic_destroy_state. Please
* read the documentation for the &drm_crtc_funcs.atomic_destroy_state
* hook for more details.
*/
void (*destroy_crtc_state)(struct drm_simple_display_pipe *pipe,
struct drm_crtc_state *crtc_state);
/** /**
* @reset_plane: * @reset_plane:
* *
......
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