drm/atomic: Add for_each_{connector,crtc,plane}_in_state helper macros
This saves some typing whenever a iteration over all the connector, crtc or plane states in the atomic state is written, which happens quite often. Cc: dri-devel@lists.freedesktop.org Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:

committed by
Daniel Vetter

parent
0578be680c
commit
df63b9994e
@@ -909,14 +909,13 @@ int
|
||||
drm_atomic_connectors_for_crtc(struct drm_atomic_state *state,
|
||||
struct drm_crtc *crtc)
|
||||
{
|
||||
struct drm_connector *connector;
|
||||
struct drm_connector_state *conn_state;
|
||||
|
||||
int i, num_connected_connectors = 0;
|
||||
|
||||
for (i = 0; i < state->num_connector; i++) {
|
||||
struct drm_connector_state *conn_state;
|
||||
|
||||
conn_state = state->connector_states[i];
|
||||
|
||||
if (conn_state && conn_state->crtc == crtc)
|
||||
for_each_connector_in_state(state, connector, conn_state, i) {
|
||||
if (conn_state->crtc == crtc)
|
||||
num_connected_connectors++;
|
||||
}
|
||||
|
||||
@@ -968,19 +967,16 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
|
||||
{
|
||||
struct drm_device *dev = state->dev;
|
||||
struct drm_mode_config *config = &dev->mode_config;
|
||||
int nplanes = config->num_total_plane;
|
||||
int ncrtcs = config->num_crtc;
|
||||
struct drm_plane *plane;
|
||||
struct drm_plane_state *plane_state;
|
||||
struct drm_crtc *crtc;
|
||||
struct drm_crtc_state *crtc_state;
|
||||
int i, ret = 0;
|
||||
|
||||
DRM_DEBUG_ATOMIC("checking %p\n", state);
|
||||
|
||||
for (i = 0; i < nplanes; i++) {
|
||||
struct drm_plane *plane = state->planes[i];
|
||||
|
||||
if (!plane)
|
||||
continue;
|
||||
|
||||
ret = drm_atomic_plane_check(plane, state->plane_states[i]);
|
||||
for_each_plane_in_state(state, plane, plane_state, i) {
|
||||
ret = drm_atomic_plane_check(plane, plane_state);
|
||||
if (ret) {
|
||||
DRM_DEBUG_ATOMIC("[PLANE:%d] atomic core check failed\n",
|
||||
plane->base.id);
|
||||
@@ -988,13 +984,8 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ncrtcs; i++) {
|
||||
struct drm_crtc *crtc = state->crtcs[i];
|
||||
|
||||
if (!crtc)
|
||||
continue;
|
||||
|
||||
ret = drm_atomic_crtc_check(crtc, state->crtc_states[i]);
|
||||
for_each_crtc_in_state(state, crtc, crtc_state, i) {
|
||||
ret = drm_atomic_crtc_check(crtc, crtc_state);
|
||||
if (ret) {
|
||||
DRM_DEBUG_ATOMIC("[CRTC:%d] atomic core check failed\n",
|
||||
crtc->base.id);
|
||||
@@ -1006,13 +997,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
|
||||
ret = config->funcs->atomic_check(state->dev, state);
|
||||
|
||||
if (!state->allow_modeset) {
|
||||
for (i = 0; i < ncrtcs; i++) {
|
||||
struct drm_crtc *crtc = state->crtcs[i];
|
||||
struct drm_crtc_state *crtc_state = state->crtc_states[i];
|
||||
|
||||
if (!crtc)
|
||||
continue;
|
||||
|
||||
for_each_crtc_in_state(state, crtc, crtc_state, i) {
|
||||
if (crtc_state->mode_changed ||
|
||||
crtc_state->active_changed) {
|
||||
DRM_DEBUG_ATOMIC("[CRTC:%d] requires full modeset\n",
|
||||
@@ -1210,6 +1195,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
|
||||
struct drm_atomic_state *state;
|
||||
struct drm_modeset_acquire_ctx ctx;
|
||||
struct drm_plane *plane;
|
||||
struct drm_crtc *crtc;
|
||||
struct drm_crtc_state *crtc_state;
|
||||
unsigned plane_mask = 0;
|
||||
int ret = 0;
|
||||
unsigned int i, j;
|
||||
@@ -1313,15 +1300,9 @@ retry:
|
||||
}
|
||||
|
||||
if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
|
||||
int ncrtcs = dev->mode_config.num_crtc;
|
||||
|
||||
for (i = 0; i < ncrtcs; i++) {
|
||||
struct drm_crtc_state *crtc_state = state->crtc_states[i];
|
||||
for_each_crtc_in_state(state, crtc, crtc_state, i) {
|
||||
struct drm_pending_vblank_event *e;
|
||||
|
||||
if (!crtc_state)
|
||||
continue;
|
||||
|
||||
e = create_vblank_event(dev, file_priv, arg->user_data);
|
||||
if (!e) {
|
||||
ret = -ENOMEM;
|
||||
@@ -1373,14 +1354,7 @@ fail:
|
||||
goto backoff;
|
||||
|
||||
if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
|
||||
int ncrtcs = dev->mode_config.num_crtc;
|
||||
|
||||
for (i = 0; i < ncrtcs; i++) {
|
||||
struct drm_crtc_state *crtc_state = state->crtc_states[i];
|
||||
|
||||
if (!crtc_state)
|
||||
continue;
|
||||
|
||||
for_each_crtc_in_state(state, crtc, crtc_state, i) {
|
||||
destroy_vblank_event(dev, file_priv, crtc_state->event);
|
||||
crtc_state->event = NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user