Skip to content

Commit c61b93f

Browse files
Boris Brezillondanvet
authored andcommitted
drm/atomic: Fix remaining places where !funcs->best_encoder is valid
Adapt drm_pick_crtcs() and update_connector_routing() to fallback to drm_atomic_helper_best_encoder() if funcs->best_encoder() is NULL so that DRM drivers can leave this hook unassigned if they know they want to use drm_atomic_helper_best_encoder(). Update the vtables documentation accordingly. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1465300095-16971-2-git-send-email-boris.brezillon@free-electrons.com
1 parent 7ea7728 commit c61b93f

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

drivers/gpu/drm/drm_atomic_helper.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,10 @@ update_connector_routing(struct drm_atomic_state *state,
300300
if (funcs->atomic_best_encoder)
301301
new_encoder = funcs->atomic_best_encoder(connector,
302302
connector_state);
303-
else
303+
else if (funcs->best_encoder)
304304
new_encoder = funcs->best_encoder(connector);
305+
else
306+
new_encoder = drm_atomic_helper_best_encoder(connector);
305307

306308
if (!new_encoder) {
307309
DRM_DEBUG_ATOMIC("No suitable encoder found for [CONNECTOR:%d:%s]\n",

drivers/gpu/drm/drm_fb_helper.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,18 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
19711971
my_score++;
19721972

19731973
connector_funcs = connector->helper_private;
1974-
encoder = connector_funcs->best_encoder(connector);
1974+
1975+
/*
1976+
* If the DRM device implements atomic hooks and ->best_encoder() is
1977+
* NULL we fallback to the default drm_atomic_helper_best_encoder()
1978+
* helper.
1979+
*/
1980+
if (fb_helper->dev->mode_config.funcs->atomic_commit &&
1981+
!connector_funcs->best_encoder)
1982+
encoder = drm_atomic_helper_best_encoder(connector);
1983+
else
1984+
encoder = connector_funcs->best_encoder(connector);
1985+
19751986
if (!encoder)
19761987
goto out;
19771988

include/drm/drm_modeset_helper_vtables.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,11 @@ struct drm_connector_helper_funcs {
736736
* inspect dynamic configuration state should instead use
737737
* @atomic_best_encoder.
738738
*
739+
* You can leave this function to NULL if the connector is only
740+
* attached to a single encoder and you are using the atomic helpers.
741+
* In this case, the core will call drm_atomic_helper_best_encoder()
742+
* for you.
743+
*
739744
* RETURNS:
740745
*
741746
* Encoder that should be used for the given connector and connector
@@ -752,8 +757,9 @@ struct drm_connector_helper_funcs {
752757
* need to select the best encoder depending upon the desired
753758
* configuration and can't select it statically.
754759
*
755-
* This function is used by drm_atomic_helper_check_modeset() and either
756-
* this or @best_encoder is required.
760+
* This function is used by drm_atomic_helper_check_modeset().
761+
* If it is not implemented, the core will fallback to @best_encoder
762+
* (or drm_atomic_helper_best_encoder() if @best_encoder is NULL).
757763
*
758764
* NOTE:
759765
*

0 commit comments

Comments
 (0)