summaryrefslogtreecommitdiff
path: root/lib/igt_fb.c
AgeCommit message (Collapse)Author
2017-09-22lib/igt_fb: Add igt_cairo_image_surface_create_from_png()Ville Syrjälä
Raw usage of cairo_image_surface_create_from_png() doesn't work since it doesn't know about IGT_DATADIR and IGT_SRCDIR. Let's extract the helper from igt_paint_image() that uses igt_fopen_data() + cairo_image_surface_create_from_png_stream() and call it igt_cairo_image_surface_create_from_png(). Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2017-09-08build: remove _GNU_SOURCE from source filesDaniel Vetter
We are, the build system takes care of that. Reviewed-by: Eric Anholt <eric@anholt.net> Acked-by: Jani Nikula <jani.nikula@intel.com> Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Acked-by: Petri Latvala <petri.latvala@intel.com> Acked-by: Daniel Stone <daniels@collabora.com> Acked-by: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2017-07-25lib/igt_fb: Add helper function for tile_to_modPraveen Paneri
igt_get_fb_tile_size function takes modifer as an argument This helper function will let users to convert tiling to modifier and use igt_get_fb_tile_size() v2: Improved code comment (Paulo) v3 (from Paulo): Simple rebase. Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Praveen Paneri <praveen.paneri@intel.com> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2017-07-25lib/igt_fb: Let others use igt_get_fb_tile_sizePraveen Paneri
This function can be used by igt_draw to get accurate tile dimensions for all tile formats. v2: Added comments to function igt_get_fb_tile_size (Daniel) v3: Fixed errors in comments and coding style (Paulo) Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Praveen Paneri <praveen.paneri@intel.com>
2017-07-19lib/igt_fb: Export the cairo surface instead of writing to a pngPaul Kocialkowski
This removes the igt_write_fb_to_png function (that was unused thus far) and exports the igt_get_cairo_surface function to grab the matching cairo surface. Writing to a png is now handled by the common frame handling code in lib/igt_frame. This also fixes how the surface is retreived in chamelium code, which avoids destroying it too early. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@linux.intel.com> Reviewed-by: Lyude <lyude@redhat.com>
2017-02-27lib: Add basic support for valgrind annotations.Maarten Lankhorst
SIGRTMAX appears to be used by valgrind now for its internal tracking, so avoid it in the helpers. Also add some valgrind annotations in gem_mmap, to make sure that its accesses are tracked correctly. I've also added gem_munmap, but there are a lot of places that don't use it yet in tests/. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2016-11-10lib: Pass tiling constant where that's expectedTomeu Vizoso
We were passing in two places a framebuffer modifier constant instead of a tiling constant. Also adds igt_fb_mod_to_tiling so tests can do that by themselves. Cc: Tvrtko Ursulin <tursulin@ursulin.net> Fixes: 8a1a38661f56 ("lib: Add igt_create_bo_with_dimensions") Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-08-18lib: Preallocate framebuffersChris Wilson
So for reasons unfathomable CRC appear to be miscalculated when the plane is not in the mappable aperture. Worrisome, but for now preallocate space in the mappable region for the new framebuffer and design some specific tests to explore the issue further. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-05-31lib: Actually use provided size when creating BOTomeu Vizoso
When reworking igt_create_fb_with_bo_size to use igt_create_bo_with_dimensions, we mistakenly stopped acknowledging non-zero size parameters. To fix this, we move the core of the code to create_bo_for_fb and teach it to use the GEM APIs when a size is passed. igt_create_bo_with_dimensions ends up calling just create_bo_for_fb with a zero size because now the later is more generic than the former. Also, create_bo_for_fb now returns the handle of the BO that was created, as there's no point anymore in having it be a parameter passed by reference. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-04-21lib: Pass format instead of bpp to create_bo_for_fb()Ville Syrjälä
create_bo_for_fb() expects the drm format as a parameter since commit 8a1a38661f56 ("lib: Add igt_create_bo_with_dimensions") but not all callers were updated. Fix that up. Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com> Fixes: 8a1a38661f56 ("lib: Add igt_create_bo_with_dimensions") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93328 Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-04-14lib: Add igt_create_bo_with_dimensionsTomeu Vizoso
igt_create_bo_with_dimensions() is intended to abstract differences between drivers in buffer object creation. The driver-specific ioctls will be called if the driver that is being tested can satisfy the needs of the calling subtest, or it will be skipped otherwise. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14lib: Map dumb buffersTomeu Vizoso
If a buffer object is dumb, call DRM_IOCTL_MODE_MAP_DUMB when mapping it. Also, don't call DRM_IOCTL_I915_GEM_SET_DOMAIN on dumb buffers. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14lib: Add igt_dirty_fbTomeu Vizoso
Just wraps drmModeDirtyFB and for now invalidates the whole FB. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14lib: Call intel_get_drm_devid only from intel codeTomeu Vizoso
It only makes sense when testing the i915 driver, so don't call it otherwise. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-03-21lib: fb: add igt_paint_color_gradient_rangeLionel Landwerlin
This is a helper to draw a gradient between 2 colors. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
2016-03-03lib/igt_fb: Fix gen2 and 915 Y tile sizesVille Syrjälä
gen2 tile dimensions are 128x32 for both X and Y tiling 915 tile dimensions are 512x8 for both X and Y tiling Fix igt_get_fb_tile_size() to return the correct Y tile dimensions for these platforms. X tile was fine already. Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2016-03-02lib/igt_fb: Fix domain tracking for GTT cairo surfacesChris Wilson
If we create a cairo surface using a GTT mmaping, then we need to use the GTT access domain. cairo surfaces created with a blit temporary (for unfenced surfaces) still use the CPU domain. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-01-29tests/igt_fb: rename igt_get_all_formats to igt_get_all_cairo_formatsPaulo Zanoni
I recently had this discussion with Daniel where I didn't want to use igt_drm_format_to_bpp() because it uses the format_desc array, and igt_fb currently assumes that all the format_desc formats have a matching valid Cairo format, so I wouldn't be able to easily add formats such as ARGB2101010. The function that has the assumption mentioned above is igt_get_all_formats: its current users call igt_get_all_formats, and then call cairo-dependent functions, such as igt_get_cairo_ctx on the returned formats. In order to document the current behavior and prevent any problems in case we start adding new formats without matching Cairo versions to format_desc, rename igt_get_all_formats to igt_get_all_cairo_formats and make it explicitly check for CAIRO_FORMAT_INVALID. Requested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2016-01-29lib/igt_fb: fix igt_get_all_formats documentationPaulo Zanoni
We give the callers a const pointer to a static variable that we reuse between multiple calls: they're not supposed to free it, and they don't free it today. Fix the documentation and leave the still reachable pointer instead of reworking the function and its callers. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2016-01-29lib/igt_fb: make the automatic buffer sizes/strides smallerPaulo Zanoni
The big motivation behind this patch is that the current power-of-two granularity from igt_fb is way too big. There was more than one occasion where I had to work around this problem on kms_frontbuffer_tracking, and during my last workaround I was requested to just make igt_fb use more minimal buffers. I also need to export the size computation function so I won't need to reimplement it inside kms_frontbuffer_tracking. v2: - Fix the Yf sizes (Ville). - Don't change the Gen 2/3 behavior for both tiled and non-tiled. v3: - Edit the commit message, clarify that v1 was wrongly treating gen 2/3 non-tiled as tiled (Chris). Requested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2016-01-08lib: Extract some common fb create+fill methods into helpersVille Syrjälä
Several tests do one or more of the following: * igt_create_fb() + igt_paint_test_pattern() * igt_create_color_fb() + igt_paint_test_pattern() * igt_create_fb() + igt_paint_image() Extract them into new helpers: igt_create_pattern_fb(), igt_create_color_pattern_fb(), igt_create_image_fb(). v2: Fix typos, and improve API docs (Thomas) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2015-11-27lib/igt_fb: also pass the stride to igt_create_fb_with_bo_size()Paulo Zanoni
If the caller is going to specify a custom size, it's likely that he will also specify a custom stride. The automatic stride picked by create_bo_for_fb() is too huge for tiled buffers, so if the caller wants smaller buffers, then he'll need a smaller stride too, otherwise the Kernel will reject the addfb IOCTL due to stride * height being bigger than the size. I want to make tests/kms_frontbuffer_tracking use igt_create_fb_with_bo_size() so I can provide smaller buffers that will fit into the CFB. I'm also planning to make all frontbuffers with the same width/height/format have the same stride and size regardless of tiling method so I can exercise specific code paths. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2015-11-27lib/igt_fb: fix open-coded ALIGN()Paulo Zanoni
Maybe this will help someone's life in the future. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2015-11-27lib/igt_fb: fix igt_create_fb_with_bo_size() documentationPaulo Zanoni
If we pass zero as the bo_size we won't get the minimum needed size, we'll just get a size that works. The size is decided by create_bo_for_fb(). The selected size is really not minimal for tiled objects. We'll implement support for minimum size later. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2015-11-27lib/igt_fb: fix fb->size when provided by the userPaulo Zanoni
I want to have a little more control over the size of the buffers in kms_frontbuffer_tracking, so I decided to start calling igt_create_fb_with_bo_size() instead of igt_create_fb(). The problem is that create_bo_for_fb() returns its own calculated size as size_ret instead of the actual used size. So we fix this by returning the actual size, the one used in gem_create instead of the calculated size that's not used anywhere. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2015-10-12Replace __gem_mmap__{cpu,gtt,wc}() + igt_assert() with gem_mmap__{cpu,gtt,wc}()Ville Syrjälä
gem_mmap__{cpu,gtt,wc}() already has the assert built in, so replace __gem_mmap__{cpu,gtt,wc}() + igt_assert() with it. Mostly done with coccinelle, with some manual help: @@ identifier I; expression E1, E2, E3, E4, E5, E6; @@ ( - I = __gem_mmap__gtt(E1, E2, E3, E4); + I = gem_mmap__gtt(E1, E2, E3, E4); ... - igt_assert(I); | - I = __gem_mmap__cpu(E1, E2, E3, E4, E5); + I = gem_mmap__cpu(E1, E2, E3, E4, E5); ... - igt_assert(I); | - I = __gem_mmap__wc(E1, E2, E3, E4, E5); + I = gem_mmap__wc(E1, E2, E3, E4, E5); ... - igt_assert(I); ) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-09Make gem_mmap__{cpu,gtt,wc}() assert on failureVille Syrjälä
Rename the current gem_mmap__{cpu,gtt,wc}() functions into __gem_mmap__{cpu,gtt,wc}(), and add back wrappers with the original name that assert that the pointer is valid. Most callers will expect a valid pointer and shouldn't have to bother with failures. To avoid changing anything (yet), sed 's/gem_mmap__/__gem_mmap__/g' over the entire codebase. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-09lib: Die if framebuffer GTT mapping failsVille Syrjälä
Cairo helpfully allocates a new buffer for us when cairo_image_surface_create_for_data() is called with a NULL ptr. That means if gem_mmap__gtt() fails, we get a totally silent failure and nothing ever drawn into the framebuffer. Very confusing. Put in an igt_assert() to make sure we managed to mmap something. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-09s/gem_mmap/gem_mmap__gtt/Ville Syrjälä
Get rid of the gem_mmap() alias of gem_mmap__gtt(). I don't see any point in having it. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-08lib/igt_fb: don't forget to close parens on message printedPaulo Zanoni
Restore the anxiety levels back to the normal values. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2015-09-08lib: various documentation fixesThomas Wood
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-07-02docs: various documentation fixesThomas Wood
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-06-27doc: Remove i-g-t/intel prefixes and capitalize section titlesDamien Lespiau
Looks better! Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-05-01igt_fb: Close the image file when we are done with itTvrtko Ursulin
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-04-29igt_fb: Transfer existing content to Cairo surface for Y/Yf frame buffersTvrtko Ursulin
Rendering into Y and Yf tiled frame buffers with Cairo was losing the previous content ie. was starting from black. This is different than the behaviour with linear and X tiled so make it the same by blitting the initial content when creating the rendering context. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Damien Lespiau <damien.lespiau@intel.com> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-04-14lib: load images from the data directory in igt_paint_imageThomas Wood
Update igt_paint_image so that it can read images from the package data directory. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-03-12lib/fb: Use PRIx64 for uint64_t in format stringDamien Lespiau
Fix the following warning: igt_fb.c: In function 'igt_create_fb_with_bo_size': igt_fb.c:414:2: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 9 has type 'uint64_t' [-Wformat=] igt_debug("%s(width=%d, height=%d, format=0x%x [bpp=%d], tiling=%llx, size=%d\n", introduced by commit: commit e36091d1c7010e825897dc4487f9985ab353973b Author: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Date: Tue Mar 3 14:11:01 2015 +0000 tiling: Convert framebuffer helpers to use fb modifiers Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-03-12lib: Allow the creation of Ys/Yf tiled FBsDamien Lespiau
There's no fencing for those tiling layouts, so we create a linear bo for cairo to play with, and when cairo is finished with it, we do a fast copy blit to the fb BO with its final tiling. v2: Move to correct domain after CPU is done with the object (-EINVAL). (Tvrtko Ursulin) Correct arguments passed in to framebuffer creation (segfault). (Tvrtko Ursulin) Pass zero stride to kernel as it expects for Yf&Ys. (Tvrtko Ursulin) v3: Rebase for gem_mmap__cpu changes. (Tvrtko Ursulin) v4: Rebase for addfb2.5. (Tvrtko Ursulin) Signed-off-by: Damien Lespiau <damien.lespiau@intel.com> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2015-03-12lib/igt_fb: Use new ADDFB2 extension for new tiling modesTvrtko Ursulin
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2015-03-12tiling: Convert framebuffer helpers to use fb modifiersTvrtko Ursulin
This converts the IGT API only, underneath legacy set_tiling is still used. v2: One got away in kms_flip. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-09-06lib/igt_fb: Ignore RGB888Chris Wilson
None of our display hardware supports the packed 24-bit format, so stop trying to use it and causing test failures. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78873&list_id=465068 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-09-06lib/igt_fb: Add debug output for creating fbChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-09-05lib/igt_fb: ensure igt_create_fb parameters are consistentThomas Wood
Make sure the parameters in the prototype and implementation of igt_create_fb match and are complete so that the documentation is correct. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-09-05lib: move create_stereo_fb from testdisplay to igt_fbThomas Wood
Move create_stereo_fb from testdisplay to igt_create_stereo_fb in igt_fb so that it can be used in other tests. v2: update for new igt_create_fb API add parameters for format and tiling remove some old debug code Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-08-26lib/intel_* Use igt checks and macrosDaniel Vetter
Various stuff all over. Most done with the igt.cocci spatch, but with a few fixups by hand. And add igt_core.h includes where needed. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-08-21lib/fb: Assert, instead of silently failing, when creating fbsDamien Lespiau
We were either returning 0, or a negative value cast to an unsigned int for errors and the clients of that API weren't exactly checking anything. We're in luck, we can take shortcuts in a testing library to just assert when an expected error occurs. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-08-21lib/fb: Replace straight igt_fail() by asserts with debug messagesDamien Lespiau
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-08-21lib: Change the fb creation functions to take fully qualified tiling formatsDamien Lespiau
In the future, we'll need more than X tiling here. So give a full enum instead of bool meaning X-tiled. It's fine to do this change without updating the users just yet as 'true' happens to be I915_TILING_X. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-07-29lib: Don't take a reference to the surface in get_cairo_surface()Damien Lespiau
We don't need to keep a reference to the surface, the cairo context will keep a reference to it until we destroy it. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2014-07-29lib: NULLify ->cairo_surface once unmappedDamien Lespiau
Just a matter of not leaving dangling pointers around. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>