Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/atomic-helper: Add an analog TV atomic_check implementation

The analog TV connector drivers share some atomic_check logic, and the new
TV standard property have created some boilerplate that can be shared
across drivers too.

Let's create an atomic_check helper for those use cases.

Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Tested-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
Acked-in-principle-or-something-like-that-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v10-14-256dad125326@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>

+52
+49
drivers/gpu/drm/drm_atomic_state_helper.c
··· 557 557 EXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset); 558 558 559 559 /** 560 + * @drm_atomic_helper_connector_tv_check: Validate an analog TV connector state 561 + * @connector: DRM Connector 562 + * @state: the DRM State object 563 + * 564 + * Checks the state object to see if the requested state is valid for an 565 + * analog TV connector. 566 + * 567 + * Returns: 568 + * Zero for success, a negative error code on error. 569 + */ 570 + int drm_atomic_helper_connector_tv_check(struct drm_connector *connector, 571 + struct drm_atomic_state *state) 572 + { 573 + struct drm_connector_state *old_conn_state = 574 + drm_atomic_get_old_connector_state(state, connector); 575 + struct drm_connector_state *new_conn_state = 576 + drm_atomic_get_new_connector_state(state, connector); 577 + struct drm_crtc_state *crtc_state; 578 + struct drm_crtc *crtc; 579 + 580 + crtc = new_conn_state->crtc; 581 + if (!crtc) 582 + return 0; 583 + 584 + crtc_state = drm_atomic_get_new_crtc_state(state, crtc); 585 + if (!crtc_state) 586 + return -EINVAL; 587 + 588 + if (old_conn_state->tv.mode != new_conn_state->tv.mode) 589 + crtc_state->mode_changed = true; 590 + 591 + if (old_conn_state->tv.margins.left != new_conn_state->tv.margins.left || 592 + old_conn_state->tv.margins.right != new_conn_state->tv.margins.right || 593 + old_conn_state->tv.margins.top != new_conn_state->tv.margins.top || 594 + old_conn_state->tv.margins.bottom != new_conn_state->tv.margins.bottom || 595 + old_conn_state->tv.mode != new_conn_state->tv.mode || 596 + old_conn_state->tv.brightness != new_conn_state->tv.brightness || 597 + old_conn_state->tv.contrast != new_conn_state->tv.contrast || 598 + old_conn_state->tv.flicker_reduction != new_conn_state->tv.flicker_reduction || 599 + old_conn_state->tv.overscan != new_conn_state->tv.overscan || 600 + old_conn_state->tv.saturation != new_conn_state->tv.saturation || 601 + old_conn_state->tv.hue != new_conn_state->tv.hue) 602 + crtc_state->connectors_changed = true; 603 + 604 + return 0; 605 + } 606 + EXPORT_SYMBOL(drm_atomic_helper_connector_tv_check); 607 + 608 + /** 560 609 * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state 561 610 * @connector: connector object 562 611 * @state: atomic connector state
+3
include/drm/drm_atomic_state_helper.h
··· 26 26 27 27 #include <linux/types.h> 28 28 29 + struct drm_atomic_state; 29 30 struct drm_bridge; 30 31 struct drm_bridge_state; 31 32 struct drm_crtc; ··· 72 71 struct drm_connector_state *conn_state); 73 72 void drm_atomic_helper_connector_reset(struct drm_connector *connector); 74 73 void drm_atomic_helper_connector_tv_reset(struct drm_connector *connector); 74 + int drm_atomic_helper_connector_tv_check(struct drm_connector *connector, 75 + struct drm_atomic_state *state); 75 76 void drm_atomic_helper_connector_tv_margins_reset(struct drm_connector *connector); 76 77 void 77 78 __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,