* [PATCH 1/2] drm: Add DRM_ROTATE_MASK and DRM_REFLECT_MASK
@ 2015-10-01 7:00 Joonas Lahtinen
2015-10-01 7:00 ` [PATCH 2/2] drm: Use " Joonas Lahtinen
0 siblings, 1 reply; 3+ messages in thread
From: Joonas Lahtinen @ 2015-10-01 7:00 UTC (permalink / raw)
To: Direct Rendering Infrastructure - Development
Makes it cleaner to separate the two from rotation variable.
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
include/drm/drm_crtc.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 683f142..33ddedd 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -86,10 +86,12 @@ static inline uint64_t I642U64(int64_t val)
}
/* rotation property bits */
+#define DRM_ROTATE_MASK 0x0f
#define DRM_ROTATE_0 0
#define DRM_ROTATE_90 1
#define DRM_ROTATE_180 2
#define DRM_ROTATE_270 3
+#define DRM_REFLECT_MASK (~DRM_ROTATE_MASK)
#define DRM_REFLECT_X 4
#define DRM_REFLECT_Y 5
--
2.4.3
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] drm: Use DRM_ROTATE_MASK and DRM_REFLECT_MASK
2015-10-01 7:00 [PATCH 1/2] drm: Add DRM_ROTATE_MASK and DRM_REFLECT_MASK Joonas Lahtinen
@ 2015-10-01 7:00 ` Joonas Lahtinen
2015-10-01 7:27 ` Ville Syrjälä
0 siblings, 1 reply; 3+ messages in thread
From: Joonas Lahtinen @ 2015-10-01 7:00 UTC (permalink / raw)
To: Direct Rendering Infrastructure - Development
Avoid magic numbers and use the introduced defines.
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 2 +-
drivers/gpu/drm/drm_crtc.c | 3 ++-
drivers/gpu/drm/drm_rect.c | 4 ++--
drivers/gpu/drm/omapdrm/omap_fb.c | 4 ++--
drivers/gpu/drm/omapdrm/omap_plane.c | 2 +-
5 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index 36fda86..d0299ae 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -633,7 +633,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
if (!state->bpp[i])
return -EINVAL;
- switch (state->base.rotation & 0xf) {
+ switch (state->base.rotation & DRM_ROTATE_MASK) {
case BIT(DRM_ROTATE_90):
offset = ((y_offset + state->src_y + patched_src_w - 1) /
ydiv) * fb->pitches[i];
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e600a5f..e7c8422 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -5629,7 +5629,8 @@ unsigned int drm_rotation_simplify(unsigned int rotation,
{
if (rotation & ~supported_rotations) {
rotation ^= BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y);
- rotation = (rotation & ~0xf) | BIT((ffs(rotation & 0xf) + 1) % 4);
+ rotation = (rotation & DRM_REFLECT_MASK) |
+ BIT((ffs(rotation & DRM_ROTATE_MASK) + 1) % 4);
}
return rotation;
diff --git a/drivers/gpu/drm/drm_rect.c b/drivers/gpu/drm/drm_rect.c
index 631f5af..531ac4c 100644
--- a/drivers/gpu/drm/drm_rect.c
+++ b/drivers/gpu/drm/drm_rect.c
@@ -330,7 +330,7 @@ void drm_rect_rotate(struct drm_rect *r,
}
}
- switch (rotation & 0xf) {
+ switch (rotation & DRM_ROTATE_MASK) {
case BIT(DRM_ROTATE_0):
break;
case BIT(DRM_ROTATE_90):
@@ -390,7 +390,7 @@ void drm_rect_rotate_inv(struct drm_rect *r,
{
struct drm_rect tmp;
- switch (rotation & 0xf) {
+ switch (rotation & DRM_ROTATE_MASK) {
case BIT(DRM_ROTATE_0):
break;
case BIT(DRM_ROTATE_90):
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 51b1219..636a1f9 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -171,7 +171,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
uint32_t w = win->src_w;
uint32_t h = win->src_h;
- switch (win->rotation & 0xf) {
+ switch (win->rotation & DRM_ROTATE_MASK) {
default:
dev_err(fb->dev->dev, "invalid rotation: %02x",
(uint32_t)win->rotation);
@@ -209,7 +209,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
info->rotation_type = OMAP_DSS_ROT_TILER;
info->screen_width = omap_gem_tiled_stride(plane->bo, orient);
} else {
- switch (win->rotation & 0xf) {
+ switch (win->rotation & DRM_ROTATE_MASK) {
case 0:
case BIT(DRM_ROTATE_0):
/* OK */
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
index 09e363b..3054bda 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -108,7 +108,7 @@ 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 & 0xf) {
+ switch (state->rotation & DRM_ROTATE_MASK) {
case BIT(DRM_ROTATE_90):
case BIT(DRM_ROTATE_270):
win.src_w = state->src_h >> 16;
--
2.4.3
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] drm: Use DRM_ROTATE_MASK and DRM_REFLECT_MASK
2015-10-01 7:00 ` [PATCH 2/2] drm: Use " Joonas Lahtinen
@ 2015-10-01 7:27 ` Ville Syrjälä
0 siblings, 0 replies; 3+ messages in thread
From: Ville Syrjälä @ 2015-10-01 7:27 UTC (permalink / raw)
To: Joonas Lahtinen; +Cc: Direct Rendering Infrastructure - Development
On Thu, Oct 01, 2015 at 10:00:58AM +0300, Joonas Lahtinen wrote:
> Avoid magic numbers and use the introduced defines.
>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
> drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 2 +-
> drivers/gpu/drm/drm_crtc.c | 3 ++-
> drivers/gpu/drm/drm_rect.c | 4 ++--
> drivers/gpu/drm/omapdrm/omap_fb.c | 4 ++--
> drivers/gpu/drm/omapdrm/omap_plane.c | 2 +-
> 5 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> index 36fda86..d0299ae 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> @@ -633,7 +633,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
> if (!state->bpp[i])
> return -EINVAL;
>
> - switch (state->base.rotation & 0xf) {
> + switch (state->base.rotation & DRM_ROTATE_MASK) {
> case BIT(DRM_ROTATE_90):
> offset = ((y_offset + state->src_y + patched_src_w - 1) /
> ydiv) * fb->pitches[i];
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index e600a5f..e7c8422 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -5629,7 +5629,8 @@ unsigned int drm_rotation_simplify(unsigned int rotation,
> {
> if (rotation & ~supported_rotations) {
> rotation ^= BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y);
> - rotation = (rotation & ~0xf) | BIT((ffs(rotation & 0xf) + 1) % 4);
> + rotation = (rotation & DRM_REFLECT_MASK) |
> + BIT((ffs(rotation & DRM_ROTATE_MASK) + 1) % 4);
> }
>
> return rotation;
> diff --git a/drivers/gpu/drm/drm_rect.c b/drivers/gpu/drm/drm_rect.c
> index 631f5af..531ac4c 100644
> --- a/drivers/gpu/drm/drm_rect.c
> +++ b/drivers/gpu/drm/drm_rect.c
> @@ -330,7 +330,7 @@ void drm_rect_rotate(struct drm_rect *r,
> }
> }
There's also a
'rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))' stuff in these
functions that could be changed to use the new reflect mask instead.
But anyway, the patches look fine, so for both
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
PS. I wouldn't be opposed to a patch that kills the BIT() stuff all
over (ie. changes the defines to be of the form 1<<n already). I
think the only complication is drm_property_create_bitmask() which
wants the bit number. So that would need changing to take them as
masks already, which I think would make sense anyway.
>
> - switch (rotation & 0xf) {
> + switch (rotation & DRM_ROTATE_MASK) {
> case BIT(DRM_ROTATE_0):
> break;
> case BIT(DRM_ROTATE_90):
> @@ -390,7 +390,7 @@ void drm_rect_rotate_inv(struct drm_rect *r,
> {
> struct drm_rect tmp;
>
> - switch (rotation & 0xf) {
> + switch (rotation & DRM_ROTATE_MASK) {
> case BIT(DRM_ROTATE_0):
> break;
> case BIT(DRM_ROTATE_90):
> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
> index 51b1219..636a1f9 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
> @@ -171,7 +171,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
> uint32_t w = win->src_w;
> uint32_t h = win->src_h;
>
> - switch (win->rotation & 0xf) {
> + switch (win->rotation & DRM_ROTATE_MASK) {
> default:
> dev_err(fb->dev->dev, "invalid rotation: %02x",
> (uint32_t)win->rotation);
> @@ -209,7 +209,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
> info->rotation_type = OMAP_DSS_ROT_TILER;
> info->screen_width = omap_gem_tiled_stride(plane->bo, orient);
> } else {
> - switch (win->rotation & 0xf) {
> + switch (win->rotation & DRM_ROTATE_MASK) {
> case 0:
> case BIT(DRM_ROTATE_0):
> /* OK */
> diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
> index 09e363b..3054bda 100644
> --- a/drivers/gpu/drm/omapdrm/omap_plane.c
> +++ b/drivers/gpu/drm/omapdrm/omap_plane.c
> @@ -108,7 +108,7 @@ 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 & 0xf) {
> + switch (state->rotation & DRM_ROTATE_MASK) {
> case BIT(DRM_ROTATE_90):
> case BIT(DRM_ROTATE_270):
> win.src_w = state->src_h >> 16;
> --
> 2.4.3
--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-01 7:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-01 7:00 [PATCH 1/2] drm: Add DRM_ROTATE_MASK and DRM_REFLECT_MASK Joonas Lahtinen
2015-10-01 7:00 ` [PATCH 2/2] drm: Use " Joonas Lahtinen
2015-10-01 7:27 ` Ville Syrjälä
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.