Skip to content

Commit 0656ce1

Browse files
committed
drm/vc4: crtc: Make encoder lookup helper public
We'll need a function that looks up an encoder by its vc4_encoder_type. Such a function is already present in the CRTC code, so let's make it public so that we can reuse it in the unit tests. Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Maíra Canal <mcanal@igalia.com> Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-15-4615a663a84a@cerno.tech Signed-off-by: Maxime Ripard <maxime@cerno.tech>
1 parent ee33ac2 commit 0656ce1

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -486,21 +486,6 @@ static int vc4_crtc_disable(struct drm_crtc *crtc,
486486
return 0;
487487
}
488488

489-
static struct drm_encoder *vc4_crtc_get_encoder_by_type(struct drm_crtc *crtc,
490-
enum vc4_encoder_type type)
491-
{
492-
struct drm_encoder *encoder;
493-
494-
drm_for_each_encoder(encoder, crtc->dev) {
495-
struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
496-
497-
if (vc4_encoder->type == type)
498-
return encoder;
499-
}
500-
501-
return NULL;
502-
}
503-
504489
int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
505490
{
506491
struct drm_device *drm = crtc->dev;
@@ -536,7 +521,7 @@ int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
536521

537522
pv_data = vc4_crtc_to_vc4_pv_data(vc4_crtc);
538523
encoder_type = pv_data->encoder_types[encoder_sel];
539-
encoder = vc4_crtc_get_encoder_by_type(crtc, encoder_type);
524+
encoder = vc4_find_encoder_by_type(drm, encoder_type);
540525
if (WARN_ON(!encoder))
541526
return 0;
542527

drivers/gpu/drm/vc4/vc4_drv.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,22 @@ to_vc4_encoder(const struct drm_encoder *encoder)
495495
return container_of(encoder, struct vc4_encoder, base);
496496
}
497497

498+
static inline
499+
struct drm_encoder *vc4_find_encoder_by_type(struct drm_device *drm,
500+
enum vc4_encoder_type type)
501+
{
502+
struct drm_encoder *encoder;
503+
504+
drm_for_each_encoder(encoder, drm) {
505+
struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
506+
507+
if (vc4_encoder->type == type)
508+
return encoder;
509+
}
510+
511+
return NULL;
512+
}
513+
498514
struct vc4_crtc_data {
499515
const char *name;
500516

0 commit comments

Comments
 (0)