All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/kms/atomic: Used existing func for checking fb geometry
       [not found] <CGME20180727083812epcas5p39f97180e85def2b4b4c1b68af2e83b41@epcas5p3.samsung.com>
@ 2018-07-27  8:38 ` Satendra Singh Thakur
  2018-07-27  9:51     ` Maarten Lankhorst
  0 siblings, 1 reply; 5+ messages in thread
From: Satendra Singh Thakur @ 2018-07-27  8:38 UTC (permalink / raw)
  To: Gustavo Padovan, Maarten Lankhorst, Sean Paul, David Airlie,
	dri-devel, linux-kernel
  Cc: vineet.j, hemanshu.s, sst2005, Satendra Singh Thakur

1.In the func drm_atomic_plane_check, the fb geometry checking code
can be replaced by func drm_framebuffer_check_src_coords, this will
remove several redundant lines of code.
2. Currently, in the func drm_atomic_plane_check;
there are 3 if statements in the beginning with total 5 conditions.
these conditions are
crtc is NULL but fb is non-NULL
if (state->crtc && !state->fb)
crtc is non-NULL but fb is NULL
if (state->fb && !state->crtc)
crtc is NULL (and fb is also NULL)
if (!state->crtc)

The same code can be re-written using 2 if statements and 4 conditions.
first we check whether crtc and fb both are NULL
if (!state->crtc && !state->fb)
then we check either crtc or fb is NULL
if (!state->crtc || !state->fb)

Signed-off-by: Satendra Singh Thakur <satendra.t@samsung.com>
---
 drivers/gpu/drm/drm_atomic.c | 37 +++++++++----------------------------
 1 file changed, 9 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 895741e..1cddab8 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -909,22 +909,16 @@ plane_switching_crtc(struct drm_atomic_state *state,
 static int drm_atomic_plane_check(struct drm_plane *plane,
 		struct drm_plane_state *state)
 {
-	unsigned int fb_width, fb_height;
 	int ret;
 
-	/* either *both* CRTC and FB must be set, or neither */
-	if (state->crtc && !state->fb) {
-		DRM_DEBUG_ATOMIC("CRTC set but no FB\n");
-		return -EINVAL;
-	} else if (state->fb && !state->crtc) {
-		DRM_DEBUG_ATOMIC("FB set but no CRTC\n");
-		return -EINVAL;
-	}
-
 	/* if disabled, we don't care about the rest of the state: */
-	if (!state->crtc)
+	if (!state->crtc && !state->fb)
 		return 0;
-
+	/* both CRTC and FB must be set*/
+	if (!state->crtc || !state->fb) {
+		DRM_DEBUG_ATOMIC("Either no CRTC or no FB\n");
+		return -EINVAL;
+	}
 	/* Check whether this plane is usable on this CRTC */
 	if (!(plane->possible_crtcs & drm_crtc_mask(state->crtc))) {
 		DRM_DEBUG_ATOMIC("Invalid crtc for plane\n");
@@ -954,24 +948,11 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 		return -ERANGE;
 	}
 
-	fb_width = state->fb->width << 16;
-	fb_height = state->fb->height << 16;
-
 	/* Make sure source coordinates are inside the fb. */
-	if (state->src_w > fb_width ||
-	    state->src_x > fb_width - state->src_w ||
-	    state->src_h > fb_height ||
-	    state->src_y > fb_height - state->src_h) {
-		DRM_DEBUG_ATOMIC("Invalid source coordinates "
-				 "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n",
-				 state->src_w >> 16, ((state->src_w & 0xffff) * 15625) >> 10,
-				 state->src_h >> 16, ((state->src_h & 0xffff) * 15625) >> 10,
-				 state->src_x >> 16, ((state->src_x & 0xffff) * 15625) >> 10,
-				 state->src_y >> 16, ((state->src_y & 0xffff) * 15625) >> 10,
-				 state->fb->width, state->fb->height);
+	ret = drm_framebuffer_check_src_coords(state->src_x, state->src_y,
+		state->src_w, state->src_h, state->fb);
+	if (ret)
 		return -ENOSPC;
-	}
-
 	if (plane_switching_crtc(state->state, plane, state)) {
 		DRM_DEBUG_ATOMIC("[PLANE:%d:%s] switching CRTC directly\n",
 				 plane->base.id, plane->name);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/kms/atomic: Used existing func for checking fb geometry
  2018-07-27  8:38 ` [PATCH] drm/kms/atomic: Used existing func for checking fb geometry Satendra Singh Thakur
@ 2018-07-27  9:51     ` Maarten Lankhorst
  0 siblings, 0 replies; 5+ messages in thread
From: Maarten Lankhorst @ 2018-07-27  9:51 UTC (permalink / raw)
  To: Satendra Singh Thakur, Gustavo Padovan, Sean Paul, David Airlie,
	dri-devel, linux-kernel
  Cc: vineet.j, hemanshu.s, sst2005

Op 27-07-18 om 10:38 schreef Satendra Singh Thakur:
> 1.In the func drm_atomic_plane_check, the fb geometry checking code
> can be replaced by func drm_framebuffer_check_src_coords, this will
> remove several redundant lines of code.
> 2. Currently, in the func drm_atomic_plane_check;
> there are 3 if statements in the beginning with total 5 conditions.
> these conditions are
> crtc is NULL but fb is non-NULL
> if (state->crtc && !state->fb)
> crtc is non-NULL but fb is NULL
> if (state->fb && !state->crtc)
> crtc is NULL (and fb is also NULL)
> if (!state->crtc)
>
> The same code can be re-written using 2 if statements and 4 conditions.
> first we check whether crtc and fb both are NULL
> if (!state->crtc && !state->fb)
> then we check either crtc or fb is NULL
> if (!state->crtc || !state->fb)
>
> Signed-off-by: Satendra Singh Thakur <satendra.t@samsung.com>
> ---
>  drivers/gpu/drm/drm_atomic.c | 37 +++++++++----------------------------
>  1 file changed, 9 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 895741e..1cddab8 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -909,22 +909,16 @@ plane_switching_crtc(struct drm_atomic_state *state,
>  static int drm_atomic_plane_check(struct drm_plane *plane,
>  		struct drm_plane_state *state)
>  {
> -	unsigned int fb_width, fb_height;
>  	int ret;
>  
> -	/* either *both* CRTC and FB must be set, or neither */
> -	if (state->crtc && !state->fb) {
> -		DRM_DEBUG_ATOMIC("CRTC set but no FB\n");
> -		return -EINVAL;
> -	} else if (state->fb && !state->crtc) {
> -		DRM_DEBUG_ATOMIC("FB set but no CRTC\n");
> -		return -EINVAL;
> -	}
> -
>  	/* if disabled, we don't care about the rest of the state: */
> -	if (!state->crtc)
> +	if (!state->crtc && !state->fb)
>  		return 0;
> -
> +	/* both CRTC and FB must be set*/
> +	if (!state->crtc || !state->fb) {
> +		DRM_DEBUG_ATOMIC("Either no CRTC or no FB\n");
> +		return -EINVAL;
> +	}
>  	/* Check whether this plane is usable on this CRTC */
>  	if (!(plane->possible_crtcs & drm_crtc_mask(state->crtc))) {
>  		DRM_DEBUG_ATOMIC("Invalid crtc for plane\n");
This should be a separate patch?
> @@ -954,24 +948,11 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
>  		return -ERANGE;
>  	}
>  
> -	fb_width = state->fb->width << 16;
> -	fb_height = state->fb->height << 16;
> -
>  	/* Make sure source coordinates are inside the fb. */
> -	if (state->src_w > fb_width ||
> -	    state->src_x > fb_width - state->src_w ||
> -	    state->src_h > fb_height ||
> -	    state->src_y > fb_height - state->src_h) {
> -		DRM_DEBUG_ATOMIC("Invalid source coordinates "
> -				 "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n",
> -				 state->src_w >> 16, ((state->src_w & 0xffff) * 15625) >> 10,
> -				 state->src_h >> 16, ((state->src_h & 0xffff) * 15625) >> 10,
> -				 state->src_x >> 16, ((state->src_x & 0xffff) * 15625) >> 10,
> -				 state->src_y >> 16, ((state->src_y & 0xffff) * 15625) >> 10,
> -				 state->fb->width, state->fb->height);
> +	ret = drm_framebuffer_check_src_coords(state->src_x, state->src_y,
> +		state->src_w, state->src_h, state->fb);
> +	if (ret)
>  		return -ENOSPC;
Change this to return ret, no need to swallow errors. :)
> -	}
> -
>  	if (plane_switching_crtc(state->state, plane, state)) {
>  		DRM_DEBUG_ATOMIC("[PLANE:%d:%s] switching CRTC directly\n",
>  				 plane->base.id, plane->name);



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/kms/atomic: Used existing func for checking fb geometry
@ 2018-07-27  9:51     ` Maarten Lankhorst
  0 siblings, 0 replies; 5+ messages in thread
From: Maarten Lankhorst @ 2018-07-27  9:51 UTC (permalink / raw)
  To: Satendra Singh Thakur, Gustavo Padovan, Sean Paul, David Airlie,
	dri-devel, linux-kernel
  Cc: hemanshu.s, vineet.j, sst2005

Op 27-07-18 om 10:38 schreef Satendra Singh Thakur:
> 1.In the func drm_atomic_plane_check, the fb geometry checking code
> can be replaced by func drm_framebuffer_check_src_coords, this will
> remove several redundant lines of code.
> 2. Currently, in the func drm_atomic_plane_check;
> there are 3 if statements in the beginning with total 5 conditions.
> these conditions are
> crtc is NULL but fb is non-NULL
> if (state->crtc && !state->fb)
> crtc is non-NULL but fb is NULL
> if (state->fb && !state->crtc)
> crtc is NULL (and fb is also NULL)
> if (!state->crtc)
>
> The same code can be re-written using 2 if statements and 4 conditions.
> first we check whether crtc and fb both are NULL
> if (!state->crtc && !state->fb)
> then we check either crtc or fb is NULL
> if (!state->crtc || !state->fb)
>
> Signed-off-by: Satendra Singh Thakur <satendra.t@samsung.com>
> ---
>  drivers/gpu/drm/drm_atomic.c | 37 +++++++++----------------------------
>  1 file changed, 9 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 895741e..1cddab8 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -909,22 +909,16 @@ plane_switching_crtc(struct drm_atomic_state *state,
>  static int drm_atomic_plane_check(struct drm_plane *plane,
>  		struct drm_plane_state *state)
>  {
> -	unsigned int fb_width, fb_height;
>  	int ret;
>  
> -	/* either *both* CRTC and FB must be set, or neither */
> -	if (state->crtc && !state->fb) {
> -		DRM_DEBUG_ATOMIC("CRTC set but no FB\n");
> -		return -EINVAL;
> -	} else if (state->fb && !state->crtc) {
> -		DRM_DEBUG_ATOMIC("FB set but no CRTC\n");
> -		return -EINVAL;
> -	}
> -
>  	/* if disabled, we don't care about the rest of the state: */
> -	if (!state->crtc)
> +	if (!state->crtc && !state->fb)
>  		return 0;
> -
> +	/* both CRTC and FB must be set*/
> +	if (!state->crtc || !state->fb) {
> +		DRM_DEBUG_ATOMIC("Either no CRTC or no FB\n");
> +		return -EINVAL;
> +	}
>  	/* Check whether this plane is usable on this CRTC */
>  	if (!(plane->possible_crtcs & drm_crtc_mask(state->crtc))) {
>  		DRM_DEBUG_ATOMIC("Invalid crtc for plane\n");
This should be a separate patch?
> @@ -954,24 +948,11 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
>  		return -ERANGE;
>  	}
>  
> -	fb_width = state->fb->width << 16;
> -	fb_height = state->fb->height << 16;
> -
>  	/* Make sure source coordinates are inside the fb. */
> -	if (state->src_w > fb_width ||
> -	    state->src_x > fb_width - state->src_w ||
> -	    state->src_h > fb_height ||
> -	    state->src_y > fb_height - state->src_h) {
> -		DRM_DEBUG_ATOMIC("Invalid source coordinates "
> -				 "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n",
> -				 state->src_w >> 16, ((state->src_w & 0xffff) * 15625) >> 10,
> -				 state->src_h >> 16, ((state->src_h & 0xffff) * 15625) >> 10,
> -				 state->src_x >> 16, ((state->src_x & 0xffff) * 15625) >> 10,
> -				 state->src_y >> 16, ((state->src_y & 0xffff) * 15625) >> 10,
> -				 state->fb->width, state->fb->height);
> +	ret = drm_framebuffer_check_src_coords(state->src_x, state->src_y,
> +		state->src_w, state->src_h, state->fb);
> +	if (ret)
>  		return -ENOSPC;
Change this to return ret, no need to swallow errors. :)
> -	}
> -
>  	if (plane_switching_crtc(state->state, plane, state)) {
>  		DRM_DEBUG_ATOMIC("[PLANE:%d:%s] switching CRTC directly\n",
>  				 plane->base.id, plane->name);


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1] drm/kms/atomic: Improving func drm_atomic_plane_check
       [not found]     ` <CGME20180727110534epcas5p1b5d48f9f92b7d6874bbe15c2f80dce1c@epcas5p1.samsung.com>
@ 2018-07-27 11:04       ` Satendra Singh Thakur
  0 siblings, 0 replies; 5+ messages in thread
From: Satendra Singh Thakur @ 2018-07-27 11:04 UTC (permalink / raw)
  To: Gustavo Padovan, Maarten Lankhorst, Sean Paul, David Airlie,
	dri-devel, linux-kernel
  Cc: vineet.j, hemanshu.s, sst2005, Satendra Singh Thakur

Currently, in the func drm_atomic_plane_check;
there are 3 if statements in the beginning with total 5 conditions.
these conditions are
crtc is NULL but fb is non-NULL
if (state->crtc && !state->fb)
crtc is non-NULL but fb is NULL
if (state->fb && !state->crtc)
crtc is NULL (and fb is also NULL)
if (!state->crtc)

The same code can be re-written using 2 if statements and 4 conditions.
first we check whether crtc and fb both are NULL
if (!state->crtc && !state->fb)
then we check either crtc or fb is NULL
if (!state->crtc || !state->fb)

Signed-off-by: Satendra Singh Thakur <satendra.t@samsung.com>
---
 v1: Hi Mr Maarten, Thanks for the comments.
     I have splitted them into two patches.  
 
 drivers/gpu/drm/drm_atomic.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 895741e..0415bbf 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -912,18 +912,15 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 	unsigned int fb_width, fb_height;
 	int ret;
 
-	/* either *both* CRTC and FB must be set, or neither */
-	if (state->crtc && !state->fb) {
-		DRM_DEBUG_ATOMIC("CRTC set but no FB\n");
-		return -EINVAL;
-	} else if (state->fb && !state->crtc) {
-		DRM_DEBUG_ATOMIC("FB set but no CRTC\n");
-		return -EINVAL;
-	}
-
 	/* if disabled, we don't care about the rest of the state: */
-	if (!state->crtc)
+	if (!state->crtc && !state->fb)
 		return 0;
+	/* both CRTC and FB must be set*/
+	if (!state->crtc || !state->fb) {
+		DRM_DEBUG_ATOMIC("Either invalid CRTC [%p] or invalid FB [%p]\n",
+		state->crtc, state->fb);
+		return -EINVAL;
+	}
 
 	/* Check whether this plane is usable on this CRTC */
 	if (!(plane->possible_crtcs & drm_crtc_mask(state->crtc))) {
-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1] drm/kms/atomic: Using existing func for checking framebuffer dimensions
       [not found]     ` <CGME20180727111112epcas5p35e49be90453d18c560207d6ab34661ec@epcas5p3.samsung.com>
@ 2018-07-27 11:11       ` Satendra Singh Thakur
  0 siblings, 0 replies; 5+ messages in thread
From: Satendra Singh Thakur @ 2018-07-27 11:11 UTC (permalink / raw)
  To: Gustavo Padovan, Maarten Lankhorst, Sean Paul, David Airlie,
	dri-devel, linux-kernel
  Cc: vineet.j, hemanshu.s, sst2005, Satendra Singh Thakur

In the func drm_atomic_plane_check, the fb geometry checking code
can be replaced by func drm_framebuffer_check_src_coords, this will
remove several redundant lines of code.

Signed-off-by: Satendra Singh Thakur <satendra.t@samsung.com>
---
 v1: Hi Mr Maarten, Thanks for the comments.
     I have splitted them into two patches.  

 drivers/gpu/drm/drm_atomic.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 895741e..953bd2a 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -909,7 +909,6 @@ plane_switching_crtc(struct drm_atomic_state *state,
 static int drm_atomic_plane_check(struct drm_plane *plane,
 		struct drm_plane_state *state)
 {
-	unsigned int fb_width, fb_height;
 	int ret;
 
 	/* either *both* CRTC and FB must be set, or neither */
@@ -954,24 +953,11 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
 		return -ERANGE;
 	}
 
-	fb_width = state->fb->width << 16;
-	fb_height = state->fb->height << 16;
-
 	/* Make sure source coordinates are inside the fb. */
-	if (state->src_w > fb_width ||
-	    state->src_x > fb_width - state->src_w ||
-	    state->src_h > fb_height ||
-	    state->src_y > fb_height - state->src_h) {
-		DRM_DEBUG_ATOMIC("Invalid source coordinates "
-				 "%u.%06ux%u.%06u+%u.%06u+%u.%06u (fb %ux%u)\n",
-				 state->src_w >> 16, ((state->src_w & 0xffff) * 15625) >> 10,
-				 state->src_h >> 16, ((state->src_h & 0xffff) * 15625) >> 10,
-				 state->src_x >> 16, ((state->src_x & 0xffff) * 15625) >> 10,
-				 state->src_y >> 16, ((state->src_y & 0xffff) * 15625) >> 10,
-				 state->fb->width, state->fb->height);
-		return -ENOSPC;
-	}
-
+	ret = drm_framebuffer_check_src_coords(state->src_x, state->src_y,
+		state->src_w, state->src_h, state->fb);
+	if (ret)
+		return ret;
 	if (plane_switching_crtc(state->state, plane, state)) {
 		DRM_DEBUG_ATOMIC("[PLANE:%d:%s] switching CRTC directly\n",
 				 plane->base.id, plane->name);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-07-27 11:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180727083812epcas5p39f97180e85def2b4b4c1b68af2e83b41@epcas5p3.samsung.com>
2018-07-27  8:38 ` [PATCH] drm/kms/atomic: Used existing func for checking fb geometry Satendra Singh Thakur
2018-07-27  9:51   ` Maarten Lankhorst
2018-07-27  9:51     ` Maarten Lankhorst
     [not found]     ` <CGME20180727110534epcas5p1b5d48f9f92b7d6874bbe15c2f80dce1c@epcas5p1.samsung.com>
2018-07-27 11:04       ` [PATCH v1] drm/kms/atomic: Improving func drm_atomic_plane_check Satendra Singh Thakur
     [not found]     ` <CGME20180727111112epcas5p35e49be90453d18c560207d6ab34661ec@epcas5p3.samsung.com>
2018-07-27 11:11       ` [PATCH v1] drm/kms/atomic: Using existing func for checking framebuffer dimensions Satendra Singh Thakur

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.