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: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> (v1) Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1474907460-10717-2-git-send-email-ville.syrjala@linux.intel.com
This commit is contained in:
parent
30cd85dd6e
commit
bd2ef25d92
10 changed files with 28 additions and 33 deletions
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -1284,12 +1284,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
|
|||
unsigned int intel_tile_height(const struct drm_i915_private *dev_priv,
|
||||
uint64_t fb_modifier, unsigned int cpp);
|
||||
|
||||
static inline bool
|
||||
intel_rotation_90_or_270(unsigned int rotation)
|
||||
{
|
||||
return rotation & (DRM_ROTATE_90 | DRM_ROTATE_270);
|
||||
}
|
||||
|
||||
void intel_create_rotation_property(struct drm_device *dev,
|
||||
struct intel_plane *plane);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ static void intel_fbc_get_plane_source_size(struct intel_fbc_state_cache *cache,
|
|||
{
|
||||
int w, h;
|
||||
|
||||
if (intel_rotation_90_or_270(cache->plane.rotation)) {
|
||||
if (drm_rotation_90_or_270(cache->plane.rotation)) {
|
||||
w = cache->plane.src_h;
|
||||
h = cache->plane.src_w;
|
||||
} else {
|
||||
|
|
|
@ -3151,7 +3151,7 @@ skl_plane_downscale_amount(const struct intel_plane_state *pstate)
|
|||
src_h = drm_rect_height(&pstate->base.src);
|
||||
dst_w = drm_rect_width(&pstate->base.dst);
|
||||
dst_h = drm_rect_height(&pstate->base.dst);
|
||||
if (intel_rotation_90_or_270(pstate->base.rotation))
|
||||
if (drm_rotation_90_or_270(pstate->base.rotation))
|
||||
swap(dst_w, dst_h);
|
||||
|
||||
downscale_h = max(src_h / dst_h, (uint32_t)DRM_PLANE_HELPER_NO_SCALING);
|
||||
|
@ -3182,7 +3182,7 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
|
|||
width = drm_rect_width(&intel_pstate->base.src) >> 16;
|
||||
height = drm_rect_height(&intel_pstate->base.src) >> 16;
|
||||
|
||||
if (intel_rotation_90_or_270(pstate->rotation))
|
||||
if (drm_rotation_90_or_270(pstate->rotation))
|
||||
swap(width, height);
|
||||
|
||||
/* for planar format */
|
||||
|
@ -3282,7 +3282,7 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,
|
|||
src_w = drm_rect_width(&intel_pstate->base.src) >> 16;
|
||||
src_h = drm_rect_height(&intel_pstate->base.src) >> 16;
|
||||
|
||||
if (intel_rotation_90_or_270(pstate->rotation))
|
||||
if (drm_rotation_90_or_270(pstate->rotation))
|
||||
swap(src_w, src_h);
|
||||
|
||||
/* Halve UV plane width and height for NV12 */
|
||||
|
@ -3296,7 +3296,7 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,
|
|||
else
|
||||
plane_bpp = drm_format_plane_cpp(fb->pixel_format, 0);
|
||||
|
||||
if (intel_rotation_90_or_270(pstate->rotation)) {
|
||||
if (drm_rotation_90_or_270(pstate->rotation)) {
|
||||
switch (plane_bpp) {
|
||||
case 1:
|
||||
min_scanlines = 32;
|
||||
|
@ -3554,7 +3554,7 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
|
|||
width = drm_rect_width(&intel_pstate->base.src) >> 16;
|
||||
height = drm_rect_height(&intel_pstate->base.src) >> 16;
|
||||
|
||||
if (intel_rotation_90_or_270(pstate->rotation))
|
||||
if (drm_rotation_90_or_270(pstate->rotation))
|
||||
swap(width, height);
|
||||
|
||||
cpp = drm_format_plane_cpp(fb->pixel_format, 0);
|
||||
|
@ -3575,7 +3575,7 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
|
|||
fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED) {
|
||||
uint32_t min_scanlines = 4;
|
||||
uint32_t y_tile_minimum;
|
||||
if (intel_rotation_90_or_270(pstate->rotation)) {
|
||||
if (drm_rotation_90_or_270(pstate->rotation)) {
|
||||
int cpp = (fb->pixel_format == DRM_FORMAT_NV12) ?
|
||||
drm_format_plane_cpp(fb->pixel_format, 1) :
|
||||
drm_format_plane_cpp(fb->pixel_format, 0);
|
||||
|
|
|
@ -108,16 +108,12 @@ static void omap_plane_atomic_update(struct drm_plane *plane,
|
|||
win.src_x = state->src_x >> 16;
|
||||
win.src_y = state->src_y >> 16;
|
||||
|
||||
switch (state->rotation & DRM_ROTATE_MASK) {
|
||||
case DRM_ROTATE_90:
|
||||
case DRM_ROTATE_270:
|
||||
if (drm_rotation_90_or_270(state->rotation)) {
|
||||
win.src_w = state->src_h >> 16;
|
||||
win.src_h = state->src_w >> 16;
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
win.src_w = state->src_w >> 16;
|
||||
win.src_h = state->src_h >> 16;
|
||||
break;
|
||||
}
|
||||
|
||||
/* update scanout: */
|
||||
|
|
|
@ -47,6 +47,11 @@ struct drm_atomic_state;
|
|||
#define DRM_REFLECT_Y BIT(5)
|
||||
#define DRM_REFLECT_MASK (DRM_REFLECT_X | DRM_REFLECT_Y)
|
||||
|
||||
static inline bool drm_rotation_90_or_270(unsigned int rotation)
|
||||
{
|
||||
return rotation & (DRM_ROTATE_90 | DRM_ROTATE_270);
|
||||
}
|
||||
|
||||
struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
|
||||
unsigned int supported_rotations);
|
||||
unsigned int drm_rotation_simplify(unsigned int rotation,
|
||||
|
|
Loading…
Reference in a new issue