Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c93546a5 authored by Dave Airlie's avatar Dave Airlie
Browse files

Merge tag 'topic/atomic-core-2015-01-05' of git://anongit.freedesktop.org/drm-intel into drm-next

Next batch of atomic work. Most important is the propertification from Rob
and the nth iteration of the actual atomic ioctl originally from Ville.
Big differences compared to earlier revisions:
- Core properties are now fully handled by the core, drivers can only
  handle driver-specific properties.
- Atomic props&ioctl are opt-in per file_priv, userspace needs to
  explicitly ask for it (like universal plane support).
- For now all hidden behind the atomic module option until this has
  settled a bit.
- Atomic modesets are currently not possible since the exact abi for how
  to handle the mode property is still under discussion.

Besides this some cleanup patches from me and the addition of per-object
state to global state backpointers to simplify drivers.

* tag 'topic/atomic-core-2015-01-05' of git://anongit.freedesktop.org/drm-intel:
  drm: Ensure universal_planes is set for atomic
  drm/atomic: Hide drm.ko internal interfaces
  drm: Atomic modeset ioctl
  drm/atomic: atomic connector properties
  drm/atomic: atomic plane properties
  drm: small property creation cleanup
  drm/atomic: atomic_check functions
  drm: add atomic properties
  drm: refactor getproperties/getconnector
  drm: tweak getconnector locking
  drm: add atomic_get_property
  drm: add atomic_set_property wrappers
  drm: get rid of direct property value access
  drm: store property instead of id in obj attachment
  drm: allow property validation for refcnted props
  drm/atomic: Introduce state->obj backpointers
  drm/atomic-helper: Again check modeset *before* plane states
  drm/atomic-helper: Export both plane and modeset check helpers
parents e5202a22 179f158c
Loading
Loading
Loading
Loading
+88 −3
Original line number Diff line number Diff line
@@ -239,6 +239,14 @@
              Driver supports dedicated render nodes.
            </para></listitem>
          </varlistentry>
          <varlistentry>
            <term>DRIVER_ATOMIC</term>
            <listitem><para>
              Driver supports atomic properties.  In this case the driver
              must implement appropriate obj->atomic_get_property() vfuncs
              for any modeset objects with driver specific properties.
            </para></listitem>
          </varlistentry>
        </variablelist>
      </sect3>
      <sect3>
@@ -2565,8 +2573,8 @@ void intel_crt_init(struct drm_device *dev)
	<td valign="top" >Description/Restrictions</td>
	</tr>
	<tr>
	<td rowspan="25" valign="top" >DRM</td>
	<td rowspan="4" valign="top" >Generic</td>
	<td rowspan="36" valign="top" >DRM</td>
	<td rowspan="5" valign="top" >Connector</td>
	<td valign="top" >“EDID”</td>
	<td valign="top" >BLOB | IMMUTABLE</td>
	<td valign="top" >0</td>
@@ -2595,7 +2603,14 @@ void intel_crt_init(struct drm_device *dev)
	<td valign="top" >Contains tiling information for a connector.</td>
	</tr>
	<tr>
	<td rowspan="1" valign="top" >Plane</td>
	<td valign="top" >“CRTC_ID”</td>
	<td valign="top" >OBJECT</td>
	<td valign="top" >DRM_MODE_OBJECT_CRTC</td>
	<td valign="top" >Connector</td>
	<td valign="top" >CRTC that connector is attached to (atomic)</td>
	</tr>
	<tr>
	<td rowspan="11" valign="top" >Plane</td>
	<td valign="top" >“type”</td>
	<td valign="top" >ENUM | IMMUTABLE</td>
	<td valign="top" >{ "Overlay", "Primary", "Cursor" }</td>
@@ -2603,6 +2618,76 @@ void intel_crt_init(struct drm_device *dev)
	<td valign="top" >Plane type</td>
	</tr>
	<tr>
	<td valign="top" >“SRC_X”</td>
	<td valign="top" >RANGE</td>
	<td valign="top" >Min=0, Max=UINT_MAX</td>
	<td valign="top" >Plane</td>
	<td valign="top" >Scanout source x coordinate in 16.16 fixed point (atomic)</td>
	</tr>
	<tr>
	<td valign="top" >“SRC_Y”</td>
	<td valign="top" >RANGE</td>
	<td valign="top" >Min=0, Max=UINT_MAX</td>
	<td valign="top" >Plane</td>
	<td valign="top" >Scanout source y coordinate in 16.16 fixed point (atomic)</td>
	</tr>
	<tr>
	<td valign="top" >“SRC_W”</td>
	<td valign="top" >RANGE</td>
	<td valign="top" >Min=0, Max=UINT_MAX</td>
	<td valign="top" >Plane</td>
	<td valign="top" >Scanout source width in 16.16 fixed point (atomic)</td>
	</tr>
	<tr>
	<td valign="top" >“SRC_H”</td>
	<td valign="top" >RANGE</td>
	<td valign="top" >Min=0, Max=UINT_MAX</td>
	<td valign="top" >Plane</td>
	<td valign="top" >Scanout source height in 16.16 fixed point (atomic)</td>
	</tr>
	<tr>
	<td valign="top" >“CRTC_X”</td>
	<td valign="top" >SIGNED_RANGE</td>
	<td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
	<td valign="top" >Plane</td>
	<td valign="top" >Scanout CRTC (destination) x coordinate (atomic)</td>
	</tr>
	<tr>
	<td valign="top" >“CRTC_Y”</td>
	<td valign="top" >SIGNED_RANGE</td>
	<td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
	<td valign="top" >Plane</td>
	<td valign="top" >Scanout CRTC (destination) y coordinate (atomic)</td>
	</tr>
	<tr>
	<td valign="top" >“CRTC_W”</td>
	<td valign="top" >RANGE</td>
	<td valign="top" >Min=0, Max=UINT_MAX</td>
	<td valign="top" >Plane</td>
	<td valign="top" >Scanout CRTC (destination) width (atomic)</td>
	</tr>
	<tr>
	<td valign="top" >“CRTC_H”</td>
	<td valign="top" >RANGE</td>
	<td valign="top" >Min=0, Max=UINT_MAX</td>
	<td valign="top" >Plane</td>
	<td valign="top" >Scanout CRTC (destination) height (atomic)</td>
	</tr>
	<tr>
	<td valign="top" >“FB_ID”</td>
	<td valign="top" >OBJECT</td>
	<td valign="top" >DRM_MODE_OBJECT_FB</td>
	<td valign="top" >Plane</td>
	<td valign="top" >Scanout framebuffer (atomic)</td>
	</tr>
	<tr>
	<td valign="top" >“CRTC_ID”</td>
	<td valign="top" >OBJECT</td>
	<td valign="top" >DRM_MODE_OBJECT_CRTC</td>
	<td valign="top" >Plane</td>
	<td valign="top" >CRTC that plane is attached to (atomic)</td>
	</tr>
	<tr>
	<td rowspan="2" valign="top" >DVI-I</td>
	<td valign="top" >“subconnector”</td>
	<td valign="top" >ENUM</td>
+717 −13

File changed.

Preview size limit exceeded, changes collapsed.

+85 −21
Original line number Diff line number Diff line
@@ -330,7 +330,29 @@ mode_fixup(struct drm_atomic_state *state)
	return 0;
}

static int
/**
 * drm_atomic_helper_check - validate state object for modeset changes
 * @dev: DRM device
 * @state: the driver state object
 *
 * Check the state object to see if the requested state is physically possible.
 * This does all the crtc and connector related computations for an atomic
 * update. It computes and updates crtc_state->mode_changed, adds any additional
 * connectors needed for full modesets and calls down into ->mode_fixup
 * functions of the driver backend.
 *
 * IMPORTANT:
 *
 * Drivers which update ->mode_changed (e.g. in their ->atomic_check hooks if a
 * plane update can't be done without a full modeset) _must_ call this function
 * afterwards after that change. It is permitted to call this function multiple
 * times for the same update, e.g. when the ->atomic_check functions depend upon
 * the adjusted dotclock for fifo space allocation and watermark computation.
 *
 * RETURNS
 * Zero for success or -errno
 */
int
drm_atomic_helper_check_modeset(struct drm_device *dev,
				struct drm_atomic_state *state)
{
@@ -406,22 +428,22 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,

	return mode_fixup(state);
}
EXPORT_SYMBOL(drm_atomic_helper_check_modeset);

/**
 * drm_atomic_helper_check - validate state object
 * drm_atomic_helper_check - validate state object for modeset changes
 * @dev: DRM device
 * @state: the driver state object
 *
 * Check the state object to see if the requested state is physically possible.
 * Only crtcs and planes have check callbacks, so for any additional (global)
 * checking that a driver needs it can simply wrap that around this function.
 * Drivers without such needs can directly use this as their ->atomic_check()
 * callback.
 * This does all the plane update related checks using by calling into the
 * ->atomic_check hooks provided by the driver.
 *
 * RETURNS
 * Zero for success or -errno
 */
int drm_atomic_helper_check(struct drm_device *dev,
int
drm_atomic_helper_check_planes(struct drm_device *dev,
			       struct drm_atomic_state *state)
{
	int nplanes = dev->mode_config.num_total_plane;
@@ -445,7 +467,7 @@ int drm_atomic_helper_check(struct drm_device *dev,

		ret = funcs->atomic_check(plane, plane_state);
		if (ret) {
			DRM_DEBUG_KMS("[PLANE:%d] atomic check failed\n",
			DRM_DEBUG_KMS("[PLANE:%d] atomic driver check failed\n",
				      plane->base.id);
			return ret;
		}
@@ -465,16 +487,49 @@ int drm_atomic_helper_check(struct drm_device *dev,

		ret = funcs->atomic_check(crtc, state->crtc_states[i]);
		if (ret) {
			DRM_DEBUG_KMS("[CRTC:%d] atomic check failed\n",
			DRM_DEBUG_KMS("[CRTC:%d] atomic driver check failed\n",
				      crtc->base.id);
			return ret;
		}
	}

	return ret;
}
EXPORT_SYMBOL(drm_atomic_helper_check_planes);

/**
 * drm_atomic_helper_check - validate state object
 * @dev: DRM device
 * @state: the driver state object
 *
 * Check the state object to see if the requested state is physically possible.
 * Only crtcs and planes have check callbacks, so for any additional (global)
 * checking that a driver needs it can simply wrap that around this function.
 * Drivers without such needs can directly use this as their ->atomic_check()
 * callback.
 *
 * This just wraps the two parts of the state checking for planes and modeset
 * state in the default order: First it calls drm_atomic_helper_check_modeset()
 * and then drm_atomic_helper_check_planes(). The assumption is that the
 * ->atomic_check functions depend upon an updated adjusted_mode.clock to
 * e.g. properly compute watermarks.
 *
 * RETURNS
 * Zero for success or -errno
 */
int drm_atomic_helper_check(struct drm_device *dev,
			    struct drm_atomic_state *state)
{
	int ret;

	ret = drm_atomic_helper_check_modeset(dev, state);
	if (ret)
		return ret;

	ret = drm_atomic_helper_check_planes(dev, state);
	if (ret)
		return ret;

	return ret;
}
EXPORT_SYMBOL(drm_atomic_helper_check);
@@ -1222,7 +1277,7 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane,
		goto fail;
	}

	ret = drm_atomic_set_crtc_for_plane(state, plane, crtc);
	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
	if (ret != 0)
		goto fail;
	drm_atomic_set_fb_for_plane(plane_state, fb);
@@ -1301,7 +1356,7 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane)
		goto fail;
	}

	ret = drm_atomic_set_crtc_for_plane(state, plane, NULL);
	ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
	if (ret != 0)
		goto fail;
	drm_atomic_set_fb_for_plane(plane_state, NULL);
@@ -1464,7 +1519,7 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set)

		crtc_state->enable = false;

		ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, NULL);
		ret = drm_atomic_set_crtc_for_plane(primary_state, NULL);
		if (ret != 0)
			goto fail;

@@ -1479,7 +1534,7 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set)
	crtc_state->enable = true;
	drm_mode_copy(&crtc_state->mode, set->mode);

	ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, crtc);
	ret = drm_atomic_set_crtc_for_plane(primary_state, crtc);
	if (ret != 0)
		goto fail;
	drm_atomic_set_fb_for_plane(primary_state, set->fb);
@@ -1558,7 +1613,7 @@ drm_atomic_helper_crtc_set_property(struct drm_crtc *crtc,
		goto fail;
	}

	ret = crtc->funcs->atomic_set_property(crtc, crtc_state,
	ret = drm_atomic_crtc_set_property(crtc, crtc_state,
			property, val);
	if (ret)
		goto fail;
@@ -1617,7 +1672,7 @@ drm_atomic_helper_plane_set_property(struct drm_plane *plane,
		goto fail;
	}

	ret = plane->funcs->atomic_set_property(plane, plane_state,
	ret = drm_atomic_plane_set_property(plane, plane_state,
			property, val);
	if (ret)
		goto fail;
@@ -1676,7 +1731,7 @@ drm_atomic_helper_connector_set_property(struct drm_connector *connector,
		goto fail;
	}

	ret = connector->funcs->atomic_set_property(connector, connector_state,
	ret = drm_atomic_connector_set_property(connector, connector_state,
			property, val);
	if (ret)
		goto fail;
@@ -1751,7 +1806,7 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
		goto fail;
	}

	ret = drm_atomic_set_crtc_for_plane(state, plane, crtc);
	ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
	if (ret != 0)
		goto fail;
	drm_atomic_set_fb_for_plane(plane_state, fb);
@@ -1814,6 +1869,9 @@ void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc)
{
	kfree(crtc->state);
	crtc->state = kzalloc(sizeof(*crtc->state), GFP_KERNEL);

	if (crtc->state)
		crtc->state->crtc = crtc;
}
EXPORT_SYMBOL(drm_atomic_helper_crtc_reset);

@@ -1873,6 +1931,9 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane)

	kfree(plane->state);
	plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL);

	if (plane->state)
		plane->state->plane = plane;
}
EXPORT_SYMBOL(drm_atomic_helper_plane_reset);

@@ -1930,6 +1991,9 @@ void drm_atomic_helper_connector_reset(struct drm_connector *connector)
{
	kfree(connector->state);
	connector->state = kzalloc(sizeof(*connector->state), GFP_KERNEL);

	if (connector->state)
		connector->state->connector = connector;
}
EXPORT_SYMBOL(drm_atomic_helper_connector_reset);

+230 −115

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Diff line number Diff line
@@ -946,6 +946,7 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
		crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
	if (!crtc_state)
		return -ENOMEM;
	crtc_state->crtc = crtc;

	crtc_state->enable = true;
	crtc_state->planes_changed = true;
@@ -1005,6 +1006,7 @@ int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
		plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
	if (!plane_state)
		return -ENOMEM;
	plane_state->plane = plane;

	plane_state->crtc = crtc;
	drm_atomic_set_fb_for_plane(plane_state, crtc->primary->fb);
Loading