Skip to content

Commit 7fed7fa

Browse files
drm/crtc-helper: Add a drm_crtc_helper_atomic_check() helper
Provides a default CRTC state check handler for CRTCs that only have one primary plane attached. There are some drivers that duplicate this logic in their helpers, such as simpledrm and ssd130x. Factor out this common code into a CRTC helper and make drivers use it. Signed-off-by: Javier Martinez Canillas <[email protected]> Reviewed-by: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 6c3d9cf commit 7fed7fa

File tree

5 files changed

+35
-25
lines changed

5 files changed

+35
-25
lines changed

drivers/gpu/drm/drm_crtc_helper.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,32 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
421421
}
422422
EXPORT_SYMBOL(drm_crtc_helper_set_mode);
423423

424+
/**
425+
* drm_crtc_helper_atomic_check() - Helper to check CRTC atomic-state
426+
* @crtc: CRTC to check
427+
* @state: atomic state object
428+
*
429+
* Provides a default CRTC-state check handler for CRTCs that only have
430+
* one primary plane attached to it.
431+
*
432+
* This is often the case for the CRTC of simple framebuffers. See also
433+
* drm_plane_helper_atomic_check() for the respective plane-state check
434+
* helper function.
435+
*
436+
* RETURNS:
437+
* Zero on success, or an errno code otherwise.
438+
*/
439+
int drm_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
440+
{
441+
struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
442+
443+
if (!new_crtc_state->enable)
444+
return 0;
445+
446+
return drm_atomic_helper_check_crtc_primary_plane(new_crtc_state);
447+
}
448+
EXPORT_SYMBOL(drm_crtc_helper_atomic_check);
449+
424450
static void
425451
drm_crtc_helper_disable(struct drm_crtc *crtc)
426452
{

drivers/gpu/drm/drm_plane_helper.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ EXPORT_SYMBOL(drm_plane_helper_destroy);
298298
* scale and positioning are not expected to change since the plane is always
299299
* a fullscreen scanout buffer.
300300
*
301-
* This is often the case for the primary plane of simple framebuffers.
301+
* This is often the case for the primary plane of simple framebuffers. See
302+
* also drm_crtc_helper_atomic_check() for the respective CRTC-state check
303+
* helper function.
302304
*
303305
* RETURNS:
304306
* Zero on success, or an errno code otherwise.

drivers/gpu/drm/solomon/ssd130x.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <drm/drm_atomic.h>
2222
#include <drm/drm_atomic_helper.h>
23+
#include <drm/drm_crtc_helper.h>
2324
#include <drm/drm_damage_helper.h>
2425
#include <drm/drm_edid.h>
2526
#include <drm/drm_fb_helper.h>
@@ -645,25 +646,14 @@ static enum drm_mode_status ssd130x_crtc_helper_mode_valid(struct drm_crtc *crtc
645646
return MODE_OK;
646647
}
647648

648-
static int ssd130x_crtc_helper_atomic_check(struct drm_crtc *crtc,
649-
struct drm_atomic_state *new_state)
650-
{
651-
struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(new_state, crtc);
652-
653-
if (!new_crtc_state->enable)
654-
return 0;
655-
656-
return drm_atomic_helper_check_crtc_primary_plane(new_crtc_state);
657-
}
658-
659649
/*
660650
* The CRTC is always enabled. Screen updates are performed by
661651
* the primary plane's atomic_update function. Disabling clears
662652
* the screen in the primary plane's atomic_disable function.
663653
*/
664654
static const struct drm_crtc_helper_funcs ssd130x_crtc_helper_funcs = {
665655
.mode_valid = ssd130x_crtc_helper_mode_valid,
666-
.atomic_check = ssd130x_crtc_helper_atomic_check,
656+
.atomic_check = drm_crtc_helper_atomic_check,
667657
};
668658

669659
static void ssd130x_crtc_reset(struct drm_crtc *crtc)

drivers/gpu/drm/tiny/simpledrm.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <drm/drm_atomic.h>
1212
#include <drm/drm_atomic_state_helper.h>
1313
#include <drm/drm_connector.h>
14+
#include <drm/drm_crtc_helper.h>
1415
#include <drm/drm_damage_helper.h>
1516
#include <drm/drm_device.h>
1617
#include <drm/drm_drv.h>
@@ -545,25 +546,14 @@ static enum drm_mode_status simpledrm_crtc_helper_mode_valid(struct drm_crtc *cr
545546
return drm_crtc_helper_mode_valid_fixed(crtc, mode, &sdev->mode);
546547
}
547548

548-
static int simpledrm_crtc_helper_atomic_check(struct drm_crtc *crtc,
549-
struct drm_atomic_state *new_state)
550-
{
551-
struct drm_crtc_state *new_crtc_state = drm_atomic_get_new_crtc_state(new_state, crtc);
552-
553-
if (!new_crtc_state->enable)
554-
return 0;
555-
556-
return drm_atomic_helper_check_crtc_primary_plane(new_crtc_state);
557-
}
558-
559549
/*
560550
* The CRTC is always enabled. Screen updates are performed by
561551
* the primary plane's atomic_update function. Disabling clears
562552
* the screen in the primary plane's atomic_disable function.
563553
*/
564554
static const struct drm_crtc_helper_funcs simpledrm_crtc_helper_funcs = {
565555
.mode_valid = simpledrm_crtc_helper_mode_valid,
566-
.atomic_check = simpledrm_crtc_helper_atomic_check,
556+
.atomic_check = drm_crtc_helper_atomic_check,
567557
};
568558

569559
static const struct drm_crtc_funcs simpledrm_crtc_funcs = {

include/drm/drm_crtc_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
5050
struct drm_display_mode *mode,
5151
int x, int y,
5252
struct drm_framebuffer *old_fb);
53+
int drm_crtc_helper_atomic_check(struct drm_crtc *crtc,
54+
struct drm_atomic_state *state);
5355
bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
5456
bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
5557

0 commit comments

Comments
 (0)