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

Commit bd2ef25d authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Daniel Vetter
Browse files

drm: Add drm_rotation_90_or_270()



We have intel_rotation_90_or_270() in i915 to check if the rotation is
90 or 270 degrees. Similar checks are elsewhere in drm, so let's move
the helper into a central place and use it everwhere.

v2: Drop the BIT()
    Convert all new intel_rotation_90_or_270() calls
    Deal with superfluous code shuffling

Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> (v1)
Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1474907460-10717-2-git-send-email-ville.syrjala@linux.intel.com
parent 30cd85dd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -393,7 +393,7 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,

	if ((state->base.fb->pixel_format == DRM_FORMAT_YUV422 ||
	     state->base.fb->pixel_format == DRM_FORMAT_NV61) &&
	    (state->base.rotation & (DRM_ROTATE_90 | DRM_ROTATE_270)))
	    drm_rotation_90_or_270(state->base.rotation))
		cfg |= ATMEL_HLCDC_YUV422ROT;

	atmel_hlcdc_layer_update_cfg(&plane->layer,
@@ -628,7 +628,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
	/*
	 * Swap width and size in case of 90 or 270 degrees rotation
	 */
	if (state->base.rotation & (DRM_ROTATE_90 | DRM_ROTATE_270)) {
	if (drm_rotation_90_or_270(state->base.rotation)) {
		tmp = state->crtc_w;
		state->crtc_w = state->crtc_h;
		state->crtc_h = tmp;
+1 −1
Original line number Diff line number Diff line
@@ -2399,7 +2399,7 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
	primary_state->crtc_h = vdisplay;
	primary_state->src_x = set->x << 16;
	primary_state->src_y = set->y << 16;
	if (primary_state->rotation & (DRM_ROTATE_90 | DRM_ROTATE_270)) {
	if (drm_rotation_90_or_270(primary_state->rotation)) {
		primary_state->src_w = vdisplay << 16;
		primary_state->src_h = hdisplay << 16;
	} else {
+1 −2
Original line number Diff line number Diff line
@@ -727,8 +727,7 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
	drm_crtc_get_hv_timing(mode, &hdisplay, &vdisplay);

	if (crtc->state &&
	    crtc->primary->state->rotation & (DRM_ROTATE_90 |
					      DRM_ROTATE_270))
	    drm_rotation_90_or_270(crtc->primary->state->rotation))
		swap(hdisplay, vdisplay);

	return drm_framebuffer_check_src_coords(x << 16, y << 16,
+2 −1
Original line number Diff line number Diff line
@@ -142,8 +142,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
	intel_state->clip.y2 =
		crtc_state->base.enable ? crtc_state->pipe_src_h : 0;

	if (state->fb && intel_rotation_90_or_270(state->rotation)) {
	if (state->fb && drm_rotation_90_or_270(state->rotation)) {
		char *format_name;

		if (!(state->fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
			state->fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED)) {
			DRM_DEBUG_KMS("Y/Yf tiling required for 90/270!\n");
+8 −8
Original line number Diff line number Diff line
@@ -2139,7 +2139,7 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view,
			const struct drm_framebuffer *fb,
			unsigned int rotation)
{
	if (intel_rotation_90_or_270(rotation)) {
	if (drm_rotation_90_or_270(rotation)) {
		*view = i915_ggtt_view_rotated;
		view->params.rotated = to_intel_framebuffer(fb)->rot_info;
	} else {
@@ -2260,7 +2260,7 @@ void intel_unpin_fb_obj(struct drm_framebuffer *fb, unsigned int rotation)
static int intel_fb_pitch(const struct drm_framebuffer *fb, int plane,
			  unsigned int rotation)
{
	if (intel_rotation_90_or_270(rotation))
	if (drm_rotation_90_or_270(rotation))
		return to_intel_framebuffer(fb)->rotated[plane].pitch;
	else
		return fb->pitches[plane];
@@ -2296,7 +2296,7 @@ void intel_add_fb_offsets(int *x, int *y,
	const struct intel_framebuffer *intel_fb = to_intel_framebuffer(state->base.fb);
	unsigned int rotation = state->base.rotation;

	if (intel_rotation_90_or_270(rotation)) {
	if (drm_rotation_90_or_270(rotation)) {
		*x += intel_fb->rotated[plane].x;
		*y += intel_fb->rotated[plane].y;
	} else {
@@ -2360,7 +2360,7 @@ static u32 intel_adjust_tile_offset(int *x, int *y,
		intel_tile_dims(dev_priv, &tile_width, &tile_height,
				fb->modifier[plane], cpp);

		if (intel_rotation_90_or_270(rotation)) {
		if (drm_rotation_90_or_270(rotation)) {
			pitch_tiles = pitch / tile_height;
			swap(tile_width, tile_height);
		} else {
@@ -2416,7 +2416,7 @@ static u32 _intel_compute_tile_offset(const struct drm_i915_private *dev_priv,
		intel_tile_dims(dev_priv, &tile_width, &tile_height,
				fb_modifier, cpp);

		if (intel_rotation_90_or_270(rotation)) {
		if (drm_rotation_90_or_270(rotation)) {
			pitch_tiles = pitch / tile_height;
			swap(tile_width, tile_height);
		} else {
@@ -2976,7 +2976,7 @@ int skl_check_plane_surface(struct intel_plane_state *plane_state)
	int ret;

	/* Rotate src coordinates to match rotated GTT view */
	if (intel_rotation_90_or_270(rotation))
	if (drm_rotation_90_or_270(rotation))
		drm_rect_rotate(&plane_state->base.src,
				fb->width, fb->height, DRM_ROTATE_270);

@@ -3276,7 +3276,7 @@ u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane,
	 * The stride is either expressed as a multiple of 64 bytes chunks for
	 * linear buffers or in number of tiles for tiled buffers.
	 */
	if (intel_rotation_90_or_270(rotation)) {
	if (drm_rotation_90_or_270(rotation)) {
		int cpp = drm_format_plane_cpp(fb->pixel_format, plane);

		stride /= intel_tile_height(dev_priv, fb->modifier[0], cpp);
@@ -4666,7 +4666,7 @@ skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
		to_intel_crtc(crtc_state->base.crtc);
	int need_scaling;

	need_scaling = intel_rotation_90_or_270(rotation) ?
	need_scaling = drm_rotation_90_or_270(rotation) ?
		(src_h != dst_w || src_w != dst_h):
		(src_w != dst_w || src_h != dst_h);

Loading