Skip to content

Commit 06ba288

Browse files
Mateusz Kwiatkowskipelwell
authored andcommitted
drm/vc4: Refactor mode checking logic
Replace drm_encoder_helper_funcs::atomic_check with drm_connector_helper_funcs::atomic_check - the former is not called during drm_mode_obj_set_property_ioctl(). Set crtc_state->mode_changed if TV norm changes even without explicit mode change. This makes things like "xrandr --output Composite-1 --set mode PAL-M" work properly. Signed-off-by: Mateusz Kwiatkowski <[email protected]>
1 parent 43e2374 commit 06ba288

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

drivers/gpu/drm/vc4/vc4_vec.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,31 @@ static void vc4_vec_connector_reset(struct drm_connector *connector)
421421
connector->state->tv.mode = vc4_vec_get_default_mode(connector);
422422
}
423423

424+
static int vc4_vec_connector_atomic_check(struct drm_connector *conn,
425+
struct drm_atomic_state *state)
426+
{
427+
struct drm_connector_state *old_state =
428+
drm_atomic_get_old_connector_state(state, conn);
429+
struct drm_connector_state *new_state =
430+
drm_atomic_get_new_connector_state(state, conn);
431+
432+
const struct vc4_vec_tv_mode *vec_mode =
433+
&vc4_vec_tv_modes[new_state->tv.mode];
434+
435+
if (new_state->crtc) {
436+
struct drm_crtc_state *crtc_state =
437+
drm_atomic_get_new_crtc_state(state, new_state->crtc);
438+
439+
if (!drm_mode_equal(vec_mode->mode, &crtc_state->mode))
440+
return -EINVAL;
441+
442+
if (old_state->tv.mode != new_state->tv.mode)
443+
crtc_state->mode_changed = true;
444+
}
445+
446+
return 0;
447+
}
448+
424449
static const struct drm_connector_funcs vc4_vec_connector_funcs = {
425450
.detect = vc4_vec_connector_detect,
426451
.fill_modes = drm_helper_probe_single_connector_modes,
@@ -432,6 +457,7 @@ static const struct drm_connector_funcs vc4_vec_connector_funcs = {
432457

433458
static const struct drm_connector_helper_funcs vc4_vec_connector_helper_funcs = {
434459
.get_modes = vc4_vec_connector_get_modes,
460+
.atomic_check = vc4_vec_connector_atomic_check,
435461
};
436462

437463
static struct drm_connector *vc4_vec_connector_init(struct drm_device *dev,
@@ -569,26 +595,10 @@ static bool vc4_vec_encoder_mode_fixup(struct drm_encoder *encoder,
569595
return true;
570596
}
571597

572-
static int vc4_vec_encoder_atomic_check(struct drm_encoder *encoder,
573-
struct drm_crtc_state *crtc_state,
574-
struct drm_connector_state *conn_state)
575-
{
576-
const struct vc4_vec_tv_mode *vec_mode;
577-
578-
vec_mode = &vc4_vec_tv_modes[conn_state->tv.mode];
579-
580-
if (conn_state->crtc &&
581-
!drm_mode_equal(vec_mode->mode, &crtc_state->adjusted_mode))
582-
return -EINVAL;
583-
584-
return 0;
585-
}
586-
587598
static const struct drm_encoder_helper_funcs vc4_vec_encoder_helper_funcs = {
588599
.disable = vc4_vec_encoder_disable,
589600
.enable = vc4_vec_encoder_enable,
590601
.mode_fixup = vc4_vec_encoder_mode_fixup,
591-
.atomic_check = vc4_vec_encoder_atomic_check,
592602
};
593603

594604
static const struct vc4_vec_variant bcm2835_vec_variant = {

0 commit comments

Comments
 (0)