drm: drm_rect and clipping for intel sprite planes
Subsystems (4)
PATCH 1/1 drm: drm_rect and clipping for intel sprite planes
I'm re-sending this whole plane clipping series, as it has been a quite while since the last time I posted it.
Laurent went through patch 1 and I made the requested changes, and I also fixed a minor issue in patch 3 that I spotted myself.
The other patches are unchanged and looking for volunteers to review them...
PATCH v5 1/4 drm: Add struct drm_rect and assorted utility functions
From: Ville Syrjälä <[email protected]>
struct drm_rect represents a simple rectangle. The utility functions are there to help driver writers.
v2: Moved the region stuff into its own file, made the smaller funcs
static inline, used 64bit maths in the scaled clipping function to avoid overflows (instead it will saturate to INT_MIN or INT_MAX).
v3: Renamed drm_region to drm_rect, drm_region_clip to
drm_rect_intersect, and drm_region_subsample to drm_rect_downscale.
v4: Renamed some function parameters, improve kernel-doc comments a bit,
and actually generate documentation for drm_rect.[ch].
v5: s/RETUTRNS/RETURNS/
--- Documentation/DocBook/drm.tmpl | 2 + drivers/gpu/drm/Makefile | 3 +- drivers/gpu/drm/drm_rect.c | 96 ++++++++++++++++++++++++++++++ include/drm/drm_rect.h | 132 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/drm_rect.c create mode 100644 include/drm/drm_rect.h
Documentation/DocBook/drm.tmpl +2 -0
@@ -1653,6 +1653,8 @@ void intel_crt_init(struct drm_device *dev) <sect2> <title>KMS API Functions</title> !Edrivers/gpu/drm/drm_crtc.c +!Edrivers/gpu/drm/drm_rect.c +!Finclude/drm/drm_rect.h </sect2> </sect1>
drivers/gpu/drm/Makefile +2 -1
@@ -12,7 +12,8 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \ drm_crtc.o drm_modes.o drm_edid.o \ drm_info.o drm_debugfs.o drm_encoder_slave.o \ - drm_trace_points.o drm_global.o drm_prime.o + drm_trace_points.o drm_global.o drm_prime.o \ + drm_rect.o drm-$(CONFIG_COMPAT) += drm_ioc32.o drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
drivers/gpu/drm/drm_rect.c new file +96 -0
96 lines not on this page · raw message
include/drm/drm_rect.h new file +132 -0
132 lines not on this page · raw message
Signature · 6 lines
1.8.1.5 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 2/4 drm: Add drm_rect_calc_{hscale, vscale}() utility functions
In reply to [email protected]From: Ville Syrjälä <[email protected]>
These functions calculcate the scaling factor based on the source and destination rectangles.
There are two version of the functions, the strict ones that will return an error if the min/max scaling factor is exceeded, and the relaxed versions that will adjust the src/dst rectangles in order to keep the scaling factor withing the limits.
v2: Return error instead of adjusting regions, refactor common parts
into one function, and split into strict and relaxed versions.
v3: Renamed drm_region to drm_rect, add "_rect_" to the function
names.
--- drivers/gpu/drm/drm_rect.c | 177 +++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_rect.h | 12 +++ 2 files changed, 189 insertions(+)
drivers/gpu/drm/drm_rect.c +177 -0
@@ -94,3 +94,180 @@ bool drm_rect_clip_scaled(struct drm_rect *src, struct drm_rect *dst,return drm_rect_intersect (dst, clip); }EXPORT_SYMBOL (drm_rect_clip_scaled); + +static int drm_calc_scale (int src,int dst) +{ +int scale =0 ; + +if (src <0 || dst <0 ) +return -EINVAL ; + +if (dst ==0 ) +return 0 ; + + scale = src / dst; + +return scale; +} + +/** +* drm_rect_calc_hscale - calculate the horizontal scaling factor +* @src: source window rectangle +* @dst: destination window rectangle +* @min_hscale: minimum allowed horizontal scaling factor +* @max_hscale: maximum allowed horizontal scaling factor +* +* Calculate the horizontal scaling factor as +* (@src width) / (@dst width). +* +* RETURNS: +* The horizontal scaling factor, or errno of out of limits. +*/ +int drm_rect_calc_hscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_hscale,int max_hscale) +{ +int src_w =drm_rect_width (src); +int dst_w =drm_rect_width (dst); +int hscale =drm_calc_scale (src_w, dst_w); + +if (hscale <0 || dst_w ==0 ) +return hscale; + +if (hscale < min_hscale || hscale > max_hscale) +return -ERANGE ; + +return hscale; +} +EXPORT_SYMBOL (drm_rect_calc_hscale); + +/** +* drm_rect_calc_vscale - calculate the vertical scaling factor +* @src: source window rectangle +* @dst: destination window rectangle +* @min_vscale: minimum allowed vertical scaling factor +* @max_vscale: maximum allowed vertical scaling factor +* +* Calculate the vertical scaling factor as +* (@src height) / (@dst height). +* +* RETURNS: +* The vertical scaling factor, or errno of out of limits. +*/ +int drm_rect_calc_vscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_vscale,int max_vscale) +{ +int src_h =drm_rect_height (src); +int dst_h =drm_rect_height (dst); +int vscale =drm_calc_scale (src_h, dst_h); + +if (vscale <0 || dst_h ==0 ) +return vscale; + +if (vscale < min_vscale || vscale > max_vscale) +return -ERANGE ; + +return vscale; +} +EXPORT_SYMBOL (drm_rect_calc_vscale); + +/** +* drm_calc_hscale_relaxed - calculate the horizontal scaling factor +* @src: source window rectangle +* @dst: destination window rectangle +* @min_hscale: minimum allowed horizontal scaling factor +* @max_hscale: maximum allowed horizontal scaling factor +* +* Calculate the horizontal scaling factor as +* (@src width) / (@dst width). +* +* If the calculated scaling factor is below @min_vscale, +* decrease the height of rectangle @dst to compensate. +* +* If the calculcated scaling factor is above @max_vscale, +* decrease the height of rectangle @src to compensate. +* +* RETURNS: +* The horizontal scaling factor. +*/ +int drm_rect_calc_hscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_hscale,int max_hscale) +{ +int src_w =drm_rect_width (src); +int dst_w =drm_rect_width (dst); +int hscale =drm_calc_scale (src_w, dst_w); + +if (hscale <0 || dst_w ==0 ) +return hscale; + +if (hscale < min_hscale) { +int max_dst_w = src_w / min_hscale; + +drm_rect_adjust_size (dst, max_dst_w - dst_w,0 ); + +return min_hscale; + } + +if (hscale > max_hscale) { +int max_src_w = dst_w * max_hscale; + +drm_rect_adjust_size (src, max_src_w - src_w,0 ); + +return max_hscale; + } + +return hscale; +} +EXPORT_SYMBOL (drm_rect_calc_hscale_relaxed); + +/** +* drm_rect_calc_vscale_relaxed - calculate the vertical scaling factor +* @src: source window rectangle +* @dst: destination window rectangle +* @min_vscale: minimum allowed vertical scaling factor +* @max_vscale: maximum allowed vertical scaling factor +* +* Calculate the vertical scaling factor as +* (@src height) / (@dst height). +* +* If the calculated scaling factor is below @min_vscale, +* decrease the height of rectangle @dst to compensate. +* +* If the calculcated scaling factor is above @max_vscale, +* decrease the height of rectangle @src to compensate. +* +* RETURNS: +* The vertical scaling factor. +*/ +int drm_rect_calc_vscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_vscale,int max_vscale) +{ +int src_h =drm_rect_height (src); +int dst_h =drm_rect_height (dst); +int vscale =drm_calc_scale (src_h, dst_h); + +if (vscale <0 || dst_h ==0 ) +return vscale; + +if (vscale < min_vscale) { +int max_dst_h = src_h / min_vscale; + +drm_rect_adjust_size (dst,0 , max_dst_h - dst_h); + +return min_vscale; + } + +if (vscale > max_vscale) { +int max_src_h = dst_h * max_vscale; + +drm_rect_adjust_size (src,0 , max_src_h - src_h); + +return max_vscale; + } + +return vscale; +} +EXPORT_SYMBOL (drm_rect_calc_vscale_relaxed);
include/drm/drm_rect.h +12 -0
@@ -128,5 +128,17 @@ bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip);bool drm_rect_clip_scaled (struct drm_rect *src,struct drm_rect *dst,const struct drm_rect *clip,int hscale,int vscale); +int drm_rect_calc_hscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_hscale,int max_hscale); +int drm_rect_calc_vscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_vscale,int max_vscale); +int drm_rect_calc_hscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_hscale,int max_hscale); +int drm_rect_calc_vscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_vscale,int max_vscale);#endif
Signature · 6 lines
1.8.1.5 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 2/4] drm: Add drm_rect_calc_{hscale, vscale}() utility functions
Quoted 10 lines · On Tue, Apr 16, 2013 at 01:47:20PM +0300, [email protected] wrote:
include/drm/drm_rect.h +2
-0@@ -128,5 +128,17 @@ bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip);bool drm_rect_clip_scaled (struct drm_rect *src,struct drm_rect *dst,const struct drm_rect *clip,int hscale,int vscale); +int drm_rect_calc_hscale(const struct drm_rect *src, + const struct drm_rect *dst,
include/drm/drm_rect.h bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip); · line 142
Quoted 10 lines
include/drm/drm_rect.h +10
-0+ int min_hscale, int max_hscale); +int drm_rect_calc_vscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_vscale,int max_vscale); +int drm_rect_calc_hscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_hscale,int max_hscale); +int drm_rect_calc_vscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_vscale,int max_vscale);
These struct drm_rect *src should be const so it is clear that dst is being manipulated.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH v3 2/4] drm: Add drm_rect_calc_{hscale, vscale}() utility functions
Quoted 16 lines · Chris Wilson
Quoted 15 lines · On Tue, Apr 16, 2013 at 01:47:20PM +0300, [email protected] wrote:
include/drm/drm_rect.h +7
-0@@ -128,5 +128,17 @@ bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip);bool drm_rect_clip_scaled (struct drm_rect *src,struct drm_rect *dst,const struct drm_rect *clip,int hscale,int vscale); +int drm_rect_calc_hscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_hscale,int max_hscale); +int drm_rect_calc_vscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_vscale,int max_vscale); +int drm_rect_calc_hscale_relaxed(struct drm_rect *src,
Quoted 8 lines
include/drm/drm_rect.h bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip); · line 142
Quoted 5 lines
include/drm/drm_rect.h +5
-0+struct drm_rect *dst, + int min_hscale, int max_hscale); +int drm_rect_calc_vscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_vscale,int max_vscale);These struct
drm_rect*src should be const so it is clear that dst is being manipulated.
Actually they can manipulate either src or dst, depending on whether we're trying upscale or downscale too much. The idea being that we can only decrease the size of either rect, never increase.
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH v3 2/4] drm: Add drm_rect_calc_{hscale, vscale}() utility functions
Quoted 26 lines · Ville Syrjälä
Quoted 16 lines · Chris Wilson
Quoted 15 lines · On Tue, Apr 16, 2013 at 01:47:20PM +0300, [email protected] wrote:
include/drm/drm_rect.h +7
-0@@ -128,5 +128,17 @@ bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip);bool drm_rect_clip_scaled (struct drm_rect *src,struct drm_rect *dst,const struct drm_rect *clip,int hscale,int vscale); +int drm_rect_calc_hscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_hscale,int max_hscale); +int drm_rect_calc_vscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_vscale,int max_vscale); +int drm_rect_calc_hscale_relaxed(struct drm_rect *src,Quoted 8 lines
include/drm/drm_rect.h bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip); · line 142
Quoted 5 lines
include/drm/drm_rect.h +5
-0+struct drm_rect *dst, + int min_hscale, int max_hscale); +int drm_rect_calc_vscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_vscale,int max_vscale);These struct
drm_rect*src should be const so it is clear that dst is being manipulated.
Quoted 3 lines
Actually they can manipulate either src or dst, depending on whether we're trying upscale or downscale too much. The idea being that we can only decrease the size of either rect, never increase.
Hmm, ofc you are right. I guess I'm just not that comfortable with the concept of relaxed scaling. Dare I ask you to split patch 4 so that you can convince me with a solid changelog?
s/calculcated/calculated.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH v3 2/4] drm: Add drm_rect_calc_{hscale, vscale}() utility functions
Quoted 27 lines · Chris Wilson
Quoted 26 lines · Ville Syrjälä
Quoted 24 lines · Chris Wilson
Quoted 10 lines · On Tue, Apr 16, 2013 at 01:47:20PM +0300, [email protected] wrote:
include/drm/drm_rect.h +2
-0@@ -128,5 +128,17 @@ bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip);bool drm_rect_clip_scaled (struct drm_rect *src,struct drm_rect *dst,const struct drm_rect *clip,int hscale,int vscale); +int drm_rect_calc_hscale(const struct drm_rect *src, + const struct drm_rect *dst,include/drm/drm_rect.h bool drm_rect_intersect(struct drm_rect *r, const struct drm_rect *clip); · line 142
Quoted 10 lines
include/drm/drm_rect.h +10
-0+ int min_hscale, int max_hscale); +int drm_rect_calc_vscale (const struct drm_rect *src, +const struct drm_rect *dst, +int min_vscale,int max_vscale); +int drm_rect_calc_hscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_hscale,int max_hscale); +int drm_rect_calc_vscale_relaxed (struct drm_rect *src, +struct drm_rect *dst, +int min_vscale,int max_vscale);These struct
drm_rect*src should be const so it is clear that dst is being manipulated.
Quoted 6 lines
Quoted 3 lines
Actually they can manipulate either src or dst, depending on whether we're trying upscale or downscale too much. The idea being that we can only decrease the size of either rect, never increase.
Hmm, ofc you are right. I guess I'm just not that comfortable with the concept of relaxed scaling.
Yeah it's a bit of an open question how we should do things. The hardware constraints can be very complicated to describe, so I don't see any simple/sane way to report them to userspace. Which means writing simple hardware agnostic userspace code is pretty much impossible unless the kernel is very relaxed about what it accepts.
OTOH if you want to be sure that the final picture will look exactly as specified, then you'd probably want an error instead.
But I haven't really made up my mind on how we should handle those two cases. Some kind of control knob might be nice, but I've not yet figured out where the knob should live, and what kind of granularity it should have.
And then we also have the problem that our errno based error reporting isn't really adequate for figuring out why something failed. Usually you just have to enable drm debugs, try again, and read through the log.
Quoted 2 lines
Dare I ask you to split patch 4 so that you
can convince me with a solid changelog?
So you'd like me to implement strict checks first, and then relax them in a follow up patch?
Quoted 2 lines
s/calculcated/calculated.
Fixed. Thanks.
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH v3 2/4] drm: Add drm_rect_calc_{hscale, vscale}() utility functions
Quoted 1 line · Ville Syrjälä
On Tue, Apr 16, 2013 at 03:49:58PM +0100, Chris Wilson wrote:
[snip]
Quoted 5 lines
Quoted 2 lines
Dare I ask you to split patch 4 so that you
can convince me with a solid changelog?So you'd like me to implement strict checks first, and then relax them in a follow up patch?
Yes, please. The strict checking should give us an interface with the least surprises. Then we can discuss how to relax those checks in combination with atomic modesetting & flipping to make sure the interface remains consistent and unsurprising.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 1/3 drm: Add drm_rect_equals()
From: Ville Syrjälä <[email protected]>
drm_rect_equals() tells whether two drm_rects are equal.
--- include/drm/drm_rect.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/drm/drm_rect.h +15 -0
@@ -124,6 +124,21 @@ static inline bool drm_rect_visible(const struct drm_rect *r)return drm_rect_width (r) >0 &&drm_rect_height (r) >0 ; } +/** +* drm_rect_equals - determine if two rectangles are equal +* @r1: first rectangle +* @r2: second rectangle +* +* RETURNS: +* %true if the rectangles are equal, %false otherwise. +*/ +static inline bool drm_rect_equals (const struct drm_rect *r1, +const struct drm_rect *r2) +{ +return r1->x1 == r2->x1 && r1->x2 == r2->x2 && + r1->y1 == r2->y1 && r1->y2 == r2->y2; +} +bool drm_rect_intersect (struct drm_rect *r,const struct drm_rect *clip); bool drm_rect_clip_scaled(struct drm_rect *src, struct drm_rect *dst, const struct drm_rect *clip,
Signature · 6 lines
1.8.1.5 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 2/3 drm/i915: Implement proper clipping for video sprites
From: Ville Syrjälä <[email protected]>
Properly clip the source when the destination gets clipped by the pipe dimensions.
Sadly the video sprite hardware is rather limited so it can't do proper sub-pixel postitioning. Resort to truncating the source coordinates to (macro)pixel boundary.
The scaling checks are done using the strict drm_region functions. Which means that an error is returned when the min/max scaling ratios are exceeded.
Also do some additional checking against various hardware limits.
v2: Truncate src coords instead of rounding to avoid increasing src
viewport size, and adapt to changes in drm_calc_{h,v}scale().
v3: Adapt to drm_region->drm_rect rename. Fix misaligned crtc_w for
packed YUV formats when scaling isn't supported.
v4: Use stricter scaling checks, use drm_rect_equals()
--- drivers/gpu/drm/i915/intel_sprite.c | 202 ++++++++++++++++++++++++++---------- 1 file changed, 150 insertions(+), 52 deletions(-)
drivers/gpu/drm/i915/intel_sprite.c +150 -52
@@ -32,6 +32,7 @@#include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_fourcc.h> +#include <drm/drm_rect.h> #include "intel_drv.h" #include <drm/i915_drm.h> #include "i915_drv.h"
@@ -583,6 +584,20 @@ ilk_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) key->flags =I915_SET_COLORKEY_NONE ; } +static bool +format_is_yuv (uint32_t format) +{ +switch (format) { +case DRM_FORMAT_YUYV : +case DRM_FORMAT_UYVY : +case DRM_FORMAT_VYUY : +case DRM_FORMAT_YVYU : +return true; +default : +return false; + } +} + static int intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb, int crtc_x, int crtc_y,
@@ -600,9 +615,27 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,enum transcoder cpu_transcoder =intel_pipe_to_cpu_transcoder (dev_priv, pipe);int ret =0 ; -int x = src_x >>16 , y = src_y >>16 ; -int primary_w = crtc->mode.hdisplay, primary_h = crtc->mode.vdisplay;bool disable_primary = false; +bool visible; +int hscale, vscale; +int max_scale, min_scale; +int pixel_size =drm_format_plane_cpp (fb->pixel_format,0 ); +struct drm_rect src = { + .x1 = src_x, + .x2 = src_x + src_w, + .y1 = src_y, + .y2 = src_y + src_h, + }; +struct drm_rect dst = { + .x1 = crtc_x, + .x2 = crtc_x + crtc_w, + .y1 = crtc_y, + .y2 = crtc_y + crtc_h, + }; +const struct drm_rect clip = { + .x2 = crtc->mode.hdisplay, + .y2 = crtc->mode.vdisplay, + }; intel_fb =to_intel_framebuffer (fb); obj = intel_fb->obj;
@@ -618,19 +651,23 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, intel_plane->src_w = src_w; intel_plane->src_h = src_h; - src_w = src_w >>16 ; - src_h = src_h >>16 ; -/* Pipe must be running... */ -if (!(I915_READ (PIPECONF (cpu_transcoder)) &PIPECONF_ENABLE )) -return -EINVAL ; - -if (crtc_x >= primary_w || crtc_y >= primary_h) +if (!(I915_READ (PIPECONF (cpu_transcoder)) &PIPECONF_ENABLE )) { +DRM_DEBUG_KMS ("Pipe disabled\n" );return -EINVAL ; + }/* Don't modify another pipe's plane */ -if (intel_plane->pipe != intel_crtc->pipe) +if (intel_plane->pipe != intel_crtc->pipe) { +DRM_DEBUG_KMS ("Wrong plane <-> crtc mapping\n" );return -EINVAL ; + } + +/* FIXME check all gen limits */ +if (fb->width <3 || fb->height <3 || fb->pitches[0 ] >16384 ) { +DRM_DEBUG_KMS ("Unsuitable framebuffer for plane\n" ); +return -EINVAL ; + }/* Sprite planes can be linear or x-tiled surfaces */ switch (obj->tiling_mode) {
@@ -638,55 +675,113 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,case I915_TILING_X :break ;default : +DRM_DEBUG_KMS ("Unsupported tiling mode\n" );return -EINVAL ; } -/* -* Clamp the width & height into the visible area. Note we don't -* try to scale the source if part of the visible region is offscreen. -* The caller must handle that by adjusting source offset and size. -*/ -if ((crtc_x <0 ) && ((crtc_x + crtc_w) >0 )) { - crtc_w += crtc_x; - crtc_x =0 ; + max_scale = intel_plane->max_downscale <<16 ; + min_scale = intel_plane->can_scale ?1 : (1 <<16 ); + + hscale =drm_rect_calc_hscale (&src, &dst, min_scale, max_scale); +if (hscale <0 ) { +DRM_DEBUG_KMS ("Horizontal scaling factor out of limits\n" ); +drm_rect_debug_print (&src, true); +drm_rect_debug_print (&dst, false); + +return hscale; + } + + vscale =drm_rect_calc_vscale (&src, &dst, min_scale, max_scale); +if (vscale <0 ) { +DRM_DEBUG_KMS ("Vertical scaling factor out of limits\n" ); +drm_rect_debug_print (&src, true); +drm_rect_debug_print (&dst, false); + +return vscale; + } + + visible =drm_rect_clip_scaled (&src, &dst, &clip, hscale, vscale); + + crtc_x = dst.x1; + crtc_y = dst.y1; + crtc_w =drm_rect_width (&dst); + crtc_h =drm_rect_height (&dst); + +if (visible) { +/* Make the source viewport size an exact multiple of the scaling factors. */ +drm_rect_adjust_size (&src, +drm_rect_width (&dst) * hscale -drm_rect_width (&src), +drm_rect_height (&dst) * vscale -drm_rect_height (&src)); + +/* +* Hardware doesn't handle subpixel coordinates. +* Adjust to (macro)pixel boundary, but be careful not to +* increase the source viewport size, because that could +* push the downscaling factor out of bounds. +* +* FIXME Should we be really strict and reject the +* config if it results in non (macro)pixel aligned +* coords? +*/ + src_x = src.x1 >>16 ; + src_w =drm_rect_width (&src) >>16 ; + src_y = src.y1 >>16 ; + src_h =drm_rect_height (&src) >>16 ; + +if (format_is_yuv (fb->pixel_format)) { + src_x &= ~1 ; + src_w &= ~1 ; + +/* +* Must keep src and dst the +* same if we can't scale. +*/ +if (!intel_plane->can_scale) + crtc_w &= ~1 ; + +if (crtc_w ==0 ) + visible = false; + } } -if ((crtc_x + crtc_w) <=0 )/* Nothing to display */ - goto out; -if ((crtc_x + crtc_w) > primary_w) - crtc_w = primary_w - crtc_x; - -if ((crtc_y <0 ) && ((crtc_y + crtc_h) >0 )) { - crtc_h += crtc_y; - crtc_y =0 ; + +/* Check size restrictions when scaling */ +if (visible && (src_w != crtc_w || src_h != crtc_h)) { +unsigned int width_bytes; + +BUG_ON (!intel_plane->can_scale); + +/* FIXME interlacing min height is 6 */ + +if (crtc_w <3 || crtc_h <3 ) { +DRM_DEBUG_KMS ("Destination dimensions too small\n" ); +return -EINVAL ; + } + +if (src_w <3 || src_h <3 ) { +DRM_DEBUG_KMS ("Source dimensions too small\n" ); +return -EINVAL ; + } + + width_bytes = ((src_x * pixel_size) &63 ) + src_w * pixel_size; + +if (src_w >2048 || src_h >2048 || + width_bytes >4096 || fb->pitches[0 ] >4096 ) { +DRM_DEBUG_KMS ("Source dimensions exceed hardware limits\n" ); +return -EINVAL ; + } } -if ((crtc_y + crtc_h) <=0 )/* Nothing to display */ - goto out; -if (crtc_y + crtc_h > primary_h) - crtc_h = primary_h - crtc_y; - -if (!crtc_w || !crtc_h)/* Again, nothing to display */ - goto out; - -/* -* We may not have a scaler, eg. HSW does not have it any more -*/ -if (!intel_plane->can_scale && (crtc_w != src_w || crtc_h != src_h)) -return -EINVAL ; - -/* -* We can take a larger source and scale it down, but -* only so much... 16x is the max on SNB. -*/ -if (((src_w * src_h) / (crtc_w * crtc_h)) > intel_plane->max_downscale) -return -EINVAL ; + + dst.x1 = crtc_x; + dst.x2 = crtc_x + crtc_w; + dst.y1 = crtc_y; + dst.y2 = crtc_y + crtc_h;/* * If the sprite is completely covering the primary plane, * we can disable the primary and save power. */ -if ((crtc_x ==0 ) && (crtc_y ==0 ) && - (crtc_w == primary_w) && (crtc_h == primary_h)) - disable_primary = true; + disable_primary =drm_rect_equals (&dst, &clip); +BUG_ON (disable_primary && !visible);mutex_lock (&dev->struct_mutex);
@@ -708,8 +803,12 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,if (!disable_primary)intel_enable_primary (crtc); - intel_plane->update_plane (plane, fb, obj, crtc_x, crtc_y, - crtc_w, crtc_h, x, y, src_w, src_h); +if (visible) + intel_plane->update_plane (plane, fb, obj, + crtc_x, crtc_y, crtc_w, crtc_h, + src_x, src_y, src_w, src_h); +else + intel_plane->disable_plane (plane);if (disable_primary)intel_disable_primary (crtc);
@@ -732,7 +831,6 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, out_unlock:mutex_unlock (&dev->struct_mutex); -out:return ret; }
Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/3 drm/i915: Relax the sprite scaling limits checks
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Reduce the size of the the src/dst viewport to keep the scalign ratios in check.
Also treat sprites below the minimum size as invisble.
--- drivers/gpu/drm/i915/intel_sprite.c | 60 ++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/intel_sprite.c +32 -28
@@ -679,26 +679,19 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,return -EINVAL ; } +/* +* FIXME the following code does a bunch of fuzzy adjustments to the +* coordinates and sizes. We probably need some way to decide whether +* more strict checking should be done instead. +*/ max_scale = intel_plane->max_downscale <<16 ; min_scale = intel_plane->can_scale ?1 : (1 <<16 ); - hscale =drm_rect_calc_hscale (&src, &dst, min_scale, max_scale); -if (hscale <0 ) { -DRM_DEBUG_KMS ("Horizontal scaling factor out of limits\n" ); -drm_rect_debug_print (&src, true); -drm_rect_debug_print (&dst, false); + hscale =drm_rect_calc_hscale_relaxed (&src, &dst, min_scale, max_scale); +BUG_ON (hscale <0 ); -return hscale; - } - - vscale =drm_rect_calc_vscale (&src, &dst, min_scale, max_scale); -if (vscale <0 ) { -DRM_DEBUG_KMS ("Vertical scaling factor out of limits\n" ); -drm_rect_debug_print (&src, true); -drm_rect_debug_print (&dst, false); - -return vscale; - } + vscale =drm_rect_calc_vscale_relaxed (&src, &dst, min_scale, max_scale); +BUG_ON (vscale <0 ); visible =drm_rect_clip_scaled (&src, &dst, &clip, hscale, vscale);
@@ -708,6 +701,25 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, crtc_h =drm_rect_height (&dst);if (visible) { +/* check again in case clipping clamped the results */ + hscale =drm_rect_calc_hscale (&src, &dst, min_scale, max_scale); +if (hscale <0 ) { +DRM_DEBUG_KMS ("Horizontal scaling factor out of limits\n" ); +drm_rect_debug_print (&src, true); +drm_rect_debug_print (&dst, false); + +return hscale; + } + + vscale =drm_rect_calc_vscale (&src, &dst, min_scale, max_scale); +if (vscale <0 ) { +DRM_DEBUG_KMS ("Vertical scaling factor out of limits\n" ); +drm_rect_debug_print (&src, true); +drm_rect_debug_print (&dst, false); + +return vscale; + } +/* Make the source viewport size an exact multiple of the scaling factors. */ drm_rect_adjust_size(&src, drm_rect_width(&dst) * hscale - drm_rect_width(&src),
@@ -718,10 +730,6 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,* Adjust to (macro)pixel boundary, but be careful not to * increase the source viewport size, because that could * push the downscaling factor out of bounds. -* -* FIXME Should we be really strict and reject the -* config if it results in non (macro)pixel aligned -* coords? */ src_x = src.x1 >>16 ; src_w =drm_rect_width (&src) >>16 ;
@@ -752,15 +760,11 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,/* FIXME interlacing min height is 6 */ -if (crtc_w <3 || crtc_h <3 ) { -DRM_DEBUG_KMS ("Destination dimensions too small\n" ); -return -EINVAL ; - } +if (crtc_w <3 || crtc_h <3 ) + visible = false; -if (src_w <3 || src_h <3 ) { -DRM_DEBUG_KMS ("Source dimensions too small\n" ); -return -EINVAL ; - } +if (src_w <3 || src_h <3 ) + visible = false; width_bytes = ((src_x * pixel_size) &63 ) + src_w * pixel_size;
Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 3/4 drm: Add drm_rect_debug_print()
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Add a debug function to print the rectangle in a human readable format.
v2: Renamed drm_region to drm_rect, the function from drm_region_debug
to drm_rect_debug_print(), and use %+d instead of +%d in the format.
v3: Use %d format for width/height in the non fixed point case as well
--- drivers/gpu/drm/drm_rect.c | 22 ++++++++++++++++++++++ include/drm/drm_rect.h | 1 + 2 files changed, 23 insertions(+)
drivers/gpu/drm/drm_rect.c +22 -0
@@ -24,6 +24,7 @@#include <linux/errno.h> #include <linux/export.h> #include <linux/kernel.h> +#include <drm/drmP.h> #include <drm/drm_rect.h> /**
@@ -271,3 +272,24 @@ int drm_rect_calc_vscale_relaxed(struct drm_rect *src,return vscale; }EXPORT_SYMBOL (drm_rect_calc_vscale_relaxed); + +/** +* drm_rect_debug_print - print the rectangle information +* @r: rectangle to print +* @fixed_point: rectangle is in 16.16 fixed point format +*/ +void drm_rect_debug_print (const struct drm_rect *r,bool fixed_point) +{ +int w =drm_rect_width (r); +int h =drm_rect_height (r); + +if (fixed_point) +DRM_DEBUG_KMS ("%d.%06ux%d.%06u%+d.%06u%+d.%06u\n" , + w >>16 , ((w &0xffff ) *15625 ) >>10 , + h >>16 , ((h &0xffff ) *15625 ) >>10 , + r->x1 >>16 , ((r->x1 &0xffff ) *15625 ) >>10 , + r->y1 >>16 , ((r->y1 &0xffff ) *15625 ) >>10 ); +else +DRM_DEBUG_KMS ("%dx%d%+d%+d\n" , w, h, r->x1, r->y1); +} +EXPORT_SYMBOL (drm_rect_debug_print);
include/drm/drm_rect.h +1 -0
@@ -140,5 +140,6 @@ int drm_rect_calc_hscale_relaxed(struct drm_rect *src,int drm_rect_calc_vscale_relaxed (struct drm_rect *src,struct drm_rect *dst,int min_vscale,int max_vscale); +void drm_rect_debug_print (const struct drm_rect *r,bool fixed_point);#endif
Signature · 6 lines
1.8.1.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 4/4 drm/i915: Implement proper clipping for video sprites
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Properly clip the source when the destination gets clipped by the pipe dimensions.
Sadly the video sprite hardware is rather limited so it can't do proper sub-pixel postitioning. Resort to truncating the source coordinates to (macro)pixel boundary.
The scaling checks are done using the relaxed drm_region functions. That means that the src/dst regions are reduced in size in order to keep the scaling factor within the limits.
Also do some additional checking against various hardware limits.
v2: Truncate src coords instead of rounding to avoid increasing src
viewport size, and adapt to changes in drm_calc_{h,v}scale().
v3: Adapt to drm_region->drm_rect rename. Fix misaligned crtc_w for
packed YUV formats when scaling isn't supported.
--- drivers/gpu/drm/i915/intel_sprite.c | 191 +++++++++++++++++++++++++++--------- 1 file changed, 145 insertions(+), 46 deletions(-)
drivers/gpu/drm/i915/intel_sprite.c +145 -46
@@ -32,6 +32,7 @@#include <drm/drmP.h> #include <drm/drm_crtc.h> #include <drm/drm_fourcc.h> +#include <drm/drm_rect.h> #include "intel_drv.h" #include <drm/i915_drm.h> #include "i915_drv.h"
@@ -583,6 +584,20 @@ ilk_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) key->flags =I915_SET_COLORKEY_NONE ; } +static bool +format_is_yuv (uint32_t format) +{ +switch (format) { +case DRM_FORMAT_YUYV : +case DRM_FORMAT_UYVY : +case DRM_FORMAT_VYUY : +case DRM_FORMAT_YVYU : +return true; +default : +return false; + } +} + static int intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb, int crtc_x, int crtc_y,
@@ -600,9 +615,28 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,enum transcoder cpu_transcoder =intel_pipe_to_cpu_transcoder (dev_priv, pipe);int ret =0 ; -int x = src_x >>16 , y = src_y >>16 ;int primary_w = crtc->mode.hdisplay, primary_h = crtc->mode.vdisplay;bool disable_primary = false; +bool visible; +int hscale, vscale; +int max_scale, min_scale; +int pixel_size =drm_format_plane_cpp (fb->pixel_format,0 ); +struct drm_rect src = { + .x1 = src_x, + .x2 = src_x + src_w, + .y1 = src_y, + .y2 = src_y + src_h, + }; +struct drm_rect dst = { + .x1 = crtc_x, + .x2 = crtc_x + crtc_w, + .y1 = crtc_y, + .y2 = crtc_y + crtc_h, + }; +const struct drm_rect clip = { + .x2 = crtc->mode.hdisplay, + .y2 = crtc->mode.vdisplay, + }; intel_fb =to_intel_framebuffer (fb); obj = intel_fb->obj;
@@ -618,19 +652,23 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, intel_plane->src_w = src_w; intel_plane->src_h = src_h; - src_w = src_w >>16 ; - src_h = src_h >>16 ; -/* Pipe must be running... */ -if (!(I915_READ (PIPECONF (cpu_transcoder)) &PIPECONF_ENABLE )) -return -EINVAL ; - -if (crtc_x >= primary_w || crtc_y >= primary_h) +if (!(I915_READ (PIPECONF (cpu_transcoder)) &PIPECONF_ENABLE )) { +DRM_DEBUG_KMS ("Pipe disabled\n" );return -EINVAL ; + }/* Don't modify another pipe's plane */ -if (intel_plane->pipe != intel_crtc->pipe) +if (intel_plane->pipe != intel_crtc->pipe) { +DRM_DEBUG_KMS ("Wrong plane <-> crtc mapping\n" );return -EINVAL ; + } + +/* FIXME check all gen limits */ +if (fb->width <3 || fb->height <3 || fb->pitches[0 ] >16384 ) { +DRM_DEBUG_KMS ("Unsuitable framebuffer for plane\n" ); +return -EINVAL ; + }/* Sprite planes can be linear or x-tiled surfaces */ switch (obj->tiling_mode) {
@@ -638,53 +676,111 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,case I915_TILING_X :break ;default : +DRM_DEBUG_KMS ("Unsupported tiling mode\n" );return -EINVAL ; }/* -* Clamp the width & height into the visible area. Note we don't -* try to scale the source if part of the visible region is offscreen. -* The caller must handle that by adjusting source offset and size. +* FIXME the following code does a bunch of fuzzy adjustments to the +* coordinates and sizes. We probably need some way to decide whether +* more strict checking should be done instead. */ -if ((crtc_x <0 ) && ((crtc_x + crtc_w) >0 )) { - crtc_w += crtc_x; - crtc_x =0 ; + max_scale = intel_plane->max_downscale <<16 ; + min_scale = intel_plane->can_scale ?1 : (1 <<16 ); + + hscale =drm_rect_calc_hscale_relaxed (&src, &dst, min_scale, max_scale); +BUG_ON (hscale <0 ); + + vscale =drm_rect_calc_vscale_relaxed (&src, &dst, min_scale, max_scale); +BUG_ON (vscale <0 ); + + visible =drm_rect_clip_scaled (&src, &dst, &clip, hscale, vscale); + +if (visible) { +/* check again in case clipping clamped the results */ + hscale =drm_rect_calc_hscale (&src, &dst, min_scale, max_scale); +if (hscale <0 ) { +DRM_DEBUG_KMS ("Horizontal scaling factor out of limits\n" ); +drm_rect_debug_print (&src, true); +drm_rect_debug_print (&dst, false); +return hscale; + } + + vscale =drm_rect_calc_vscale (&src, &dst, min_scale, max_scale); +if (vscale <0 ) { +DRM_DEBUG_KMS ("Vertical scaling factor out of limits\n" ); +drm_rect_debug_print (&src, true); +drm_rect_debug_print (&dst, false); +return vscale; + } + +/* Make the source viewport size an exact multiple of the scaling factors. */ +drm_rect_adjust_size (&src, +drm_rect_width (&dst) * hscale -drm_rect_width (&src), +drm_rect_height (&dst) * vscale -drm_rect_height (&src)); + + crtc_x = dst.x1; + crtc_y = dst.y1; + crtc_w =drm_rect_width (&dst); + crtc_h =drm_rect_height (&dst); + +/* +* Hardware doesn't handle subpixel coordinates. +* Adjust to (macro)pixel boundary, but be careful not to +* increase the source viewport size, because that could +* push the downscaling factor out of bounds. +*/ + src_x = src.x1 >>16 ; + src_w =drm_rect_width (&src) >>16 ; + src_y = src.y1 >>16 ; + src_h =drm_rect_height (&src) >>16 ; + +if (format_is_yuv (fb->pixel_format)) { + src_x &= ~1 ; + src_w &= ~1 ; + +/* +* Must keep src and dst the +* same if we can't scale. +*/ +if (!intel_plane->can_scale) + crtc_w &= ~1 ; + } } -if ((crtc_x + crtc_w) <=0 )/* Nothing to display */ - goto out; -if ((crtc_x + crtc_w) > primary_w) - crtc_w = primary_w - crtc_x; - -if ((crtc_y <0 ) && ((crtc_y + crtc_h) >0 )) { - crtc_h += crtc_y; - crtc_y =0 ; + +/* Account for minimum size when scaling */ +if (visible && (src_w != crtc_w || src_h != crtc_h)) { +BUG_ON (!intel_plane->can_scale); + +/* FIXME interlacing min height is 6 */ +/* FIXME return an error instead? */ + +if (crtc_w <3 || crtc_h <3 ) + visible = false; + +if (src_w <3 || src_h <3 ) + visible = false; } -if ((crtc_y + crtc_h) <=0 )/* Nothing to display */ - goto out; -if (crtc_y + crtc_h > primary_h) - crtc_h = primary_h - crtc_y; -if (!crtc_w || !crtc_h)/* Again, nothing to display */ - goto out; +/* Check size restrictions when scaling */ +if (visible && (src_w != crtc_w || src_h != crtc_h)) { +unsigned int width_bytes = ((src_x * pixel_size) &63 ) + src_w * pixel_size; -/* -* We may not have a scaler, eg. HSW does not have it any more -*/ -if (!intel_plane->can_scale && (crtc_w != src_w || crtc_h != src_h)) -return -EINVAL ; +BUG_ON (!intel_plane->can_scale); -/* -* We can take a larger source and scale it down, but -* only so much... 16x is the max on SNB. -*/ -if (((src_w * src_h) / (crtc_w * crtc_h)) > intel_plane->max_downscale) -return -EINVAL ; +if (src_w >2048 || src_h >2048 || + width_bytes >4096 || fb->pitches[0 ] >4096 ) { +DRM_DEBUG_KMS ("Source dimensions exceed hardware limits\n" ); +return -EINVAL ; + } + }/* * If the sprite is completely covering the primary plane, * we can disable the primary and save power. */ -if ((crtc_x ==0 ) && (crtc_y ==0 ) && +if (visible && + (crtc_x ==0 ) && (crtc_y ==0 ) && (crtc_w == primary_w) && (crtc_h == primary_h)) disable_primary = true;
@@ -708,11 +804,15 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,if (!disable_primary)intel_enable_primary (crtc); - intel_plane->update_plane (plane, fb, obj, crtc_x, crtc_y, - crtc_w, crtc_h, x, y, src_w, src_h); +if (visible) { + intel_plane->update_plane (plane, fb, obj, + crtc_x, crtc_y, crtc_w, crtc_h, + src_x, src_y, src_w, src_h); -if (disable_primary) -intel_disable_primary (crtc); +if (disable_primary) +intel_disable_primary (crtc); + }else + intel_plane->disable_plane (plane);/* Unpin old obj after new one is active to avoid ugliness */ if (old_obj) {
@@ -732,7 +832,6 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, out_unlock:mutex_unlock (&dev->struct_mutex); -out:return ret; }
Signature · 6 lines
1.8.1.5 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/4] drm/i915: Implement proper clipping for video sprites
Quoted 13 lines · On Tue, Apr 16, 2013 at 01:47:22PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Properly clip the source when the destination gets clipped by the pipe dimensions.
Sadly the video sprite hardware is rather limited so it can't do proper sub-pixel postitioning. Resort to truncating the source coordinates to (macro)pixel boundary.
The scaling checks are done using the relaxed
drm_regionfunctions. That means that the src/dst regions are reduced in size in order to keep the scaling factor within the limits.
Quoted 8 lines
Also do some additional checking against various hardware limits.
v2: Truncate src coords instead of rounding to avoid increasing src
viewport size, and adapt to changes in drm_calc_{h,v}scale().
v3: Adapt todrm_region->drm_rectrename. Fix misalignedcrtc_wfor
packed YUV formats when scaling isn't supported.Signed-off-by Ville Syrjälä <[email protected]>
Skipping to the end, use of drm_rect looks good.
The one ugly that stood out is:
drivers/gpu/drm/i915/intel_sprite.c intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, · line 785
Quoted 9 lines
drivers/gpu/drm/i915/intel_sprite.c +2
-1/* * If the sprite is completely covering the primary plane, * we can disable the primary and save power. */ -if ((crtc_x ==0 ) && (crtc_y ==0 ) && +if (visible && + (crtc_x ==0 ) && (crtc_y ==0 ) && (crtc_w == primary_w) && (crtc_h == primary_h)) disable_primary = true;
which would be
disable_primary = drm_rect_equals(&dst, &clip);
BUG_ON(disable_primary && !visible);
with a little bit of massaging of crtc/dst.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH v3 4/4] drm/i915: Implement proper clipping for video sprites
Quoted 27 lines · Chris Wilson
Quoted 13 lines · On Tue, Apr 16, 2013 at 01:47:22PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Properly clip the source when the destination gets clipped by the pipe dimensions.
Sadly the video sprite hardware is rather limited so it can't do proper sub-pixel postitioning. Resort to truncating the source coordinates to (macro)pixel boundary.
The scaling checks are done using the relaxed
drm_regionfunctions. That means that the src/dst regions are reduced in size in order to keep the scaling factor within the limits.Quoted 8 lines
Also do some additional checking against various hardware limits.
v2: Truncate src coords instead of rounding to avoid increasing src
viewport size, and adapt to changes in drm_calc_{h,v}scale().
v3: Adapt todrm_region->drm_rectrename. Fix misalignedcrtc_wfor
packed YUV formats when scaling isn't supported.Signed-off-by Ville Syrjälä <[email protected]>Skipping to the end, use of
drm_rectlooks good.The one ugly that stood out is:
Quoted 14 lines
drivers/gpu/drm/i915/intel_sprite.c intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, · line 785
Quoted 9 lines
drivers/gpu/drm/i915/intel_sprite.c +2
-1/* * If the sprite is completely covering the primary plane, * we can disable the primary and save power. */ -if ((crtc_x ==0 ) && (crtc_y ==0 ) && +if (visible && + (crtc_x ==0 ) && (crtc_y ==0 ) && (crtc_w == primary_w) && (crtc_h == primary_h)) disable_primary = true;which would be
disable_primary=drm_rect_equals(&dst, &clip);
BUG_ON(disable_primary && !visible);
with a little bit of massaging of crtc/dst.
Yeah, looks nicer. I'll add drm_rect_equals() to our repertoire.
Signature · 2 lines
Ville Syrjälä Intel OTC