Skip to content

Commit ab8df60

Browse files
Boris Brezillonanholt
authored andcommitted
drm/vc4: Fix ->clock_select setting for the VEC encoder
PV_CONTROL_CLK_SELECT_VEC is actually 2 and not 0. Fix the definition and rework the vc4_set_crtc_possible_masks() to cover the full range of the PV_CONTROL_CLK_SELECT field. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Eric Anholt <eric@anholt.net>
1 parent 26fc78f commit ab8df60

3 files changed

Lines changed: 26 additions & 16 deletions

File tree

‎drivers/gpu/drm/vc4/vc4_crtc.c‎

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ struct vc4_crtc_data {
8383
/* Which channel of the HVS this pixelvalve sources from. */
8484
int hvs_channel;
8585

86-
enum vc4_encoder_type encoder0_type;
87-
enum vc4_encoder_type encoder1_type;
86+
enum vc4_encoder_type encoder_types[4];
8887
};
8988

9089
#define CRTC_WRITE(offset, val) writel(val, vc4_crtc->regs + (offset))
@@ -867,20 +866,26 @@ static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = {
867866

868867
static const struct vc4_crtc_data pv0_data = {
869868
.hvs_channel = 0,
870-
.encoder0_type = VC4_ENCODER_TYPE_DSI0,
871-
.encoder1_type = VC4_ENCODER_TYPE_DPI,
869+
.encoder_types = {
870+
[PV_CONTROL_CLK_SELECT_DSI] = VC4_ENCODER_TYPE_DSI0,
871+
[PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI] = VC4_ENCODER_TYPE_DPI,
872+
},
872873
};
873874

874875
static const struct vc4_crtc_data pv1_data = {
875876
.hvs_channel = 2,
876-
.encoder0_type = VC4_ENCODER_TYPE_DSI1,
877-
.encoder1_type = VC4_ENCODER_TYPE_SMI,
877+
.encoder_types = {
878+
[PV_CONTROL_CLK_SELECT_DSI] = VC4_ENCODER_TYPE_DSI1,
879+
[PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI] = VC4_ENCODER_TYPE_SMI,
880+
},
878881
};
879882

880883
static const struct vc4_crtc_data pv2_data = {
881884
.hvs_channel = 1,
882-
.encoder0_type = VC4_ENCODER_TYPE_VEC,
883-
.encoder1_type = VC4_ENCODER_TYPE_HDMI,
885+
.encoder_types = {
886+
[PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI] = VC4_ENCODER_TYPE_HDMI,
887+
[PV_CONTROL_CLK_SELECT_VEC] = VC4_ENCODER_TYPE_VEC,
888+
},
884889
};
885890

886891
static const struct of_device_id vc4_crtc_dt_match[] = {
@@ -894,17 +899,20 @@ static void vc4_set_crtc_possible_masks(struct drm_device *drm,
894899
struct drm_crtc *crtc)
895900
{
896901
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
902+
const struct vc4_crtc_data *crtc_data = vc4_crtc->data;
903+
const enum vc4_encoder_type *encoder_types = crtc_data->encoder_types;
897904
struct drm_encoder *encoder;
898905

899906
drm_for_each_encoder(encoder, drm) {
900907
struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
901-
902-
if (vc4_encoder->type == vc4_crtc->data->encoder0_type) {
903-
vc4_encoder->clock_select = 0;
904-
encoder->possible_crtcs |= drm_crtc_mask(crtc);
905-
} else if (vc4_encoder->type == vc4_crtc->data->encoder1_type) {
906-
vc4_encoder->clock_select = 1;
907-
encoder->possible_crtcs |= drm_crtc_mask(crtc);
908+
int i;
909+
910+
for (i = 0; i < ARRAY_SIZE(crtc_data->encoder_types); i++) {
911+
if (vc4_encoder->type == encoder_types[i]) {
912+
vc4_encoder->clock_select = i;
913+
encoder->possible_crtcs |= drm_crtc_mask(crtc);
914+
break;
915+
}
908916
}
909917
}
910918
}

‎drivers/gpu/drm/vc4/vc4_drv.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ to_vc4_plane(struct drm_plane *plane)
194194
}
195195

196196
enum vc4_encoder_type {
197+
VC4_ENCODER_TYPE_NONE,
197198
VC4_ENCODER_TYPE_HDMI,
198199
VC4_ENCODER_TYPE_VEC,
199200
VC4_ENCODER_TYPE_DSI0,

‎drivers/gpu/drm/vc4/vc4_regs.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@
177177
# define PV_CONTROL_WAIT_HSTART BIT(12)
178178
# define PV_CONTROL_PIXEL_REP_MASK VC4_MASK(5, 4)
179179
# define PV_CONTROL_PIXEL_REP_SHIFT 4
180-
# define PV_CONTROL_CLK_SELECT_DSI_VEC 0
180+
# define PV_CONTROL_CLK_SELECT_DSI 0
181181
# define PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI 1
182+
# define PV_CONTROL_CLK_SELECT_VEC 2
182183
# define PV_CONTROL_CLK_SELECT_MASK VC4_MASK(3, 2)
183184
# define PV_CONTROL_CLK_SELECT_SHIFT 2
184185
# define PV_CONTROL_FIFO_CLR BIT(1)

0 commit comments

Comments
 (0)