summaryrefslogtreecommitdiff
path: root/lib/igt_fb.c
AgeCommit message (Collapse)Author
2018-11-05lib/igt_fb: Assert converted formats harderVille Syrjälä
Add more asserts to make sure the converted formats are correct. Cc: Maxime Ripard <maxime.ripard@bootlin.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-11-05lib/igt_fb: Fix the pixman converterVille Syrjälä
Cairo doesn't do RGB888. The shadow buffer must be in XRGB888 (which is what our YUV converters also assume). We did calculate the shadow stride/size with four bytes per pixel, but we just put the wrong format in the fb metadata. Cc: Maxime Ripard <maxime.ripard@bootlin.com> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-11-02lib/igt_fb: Fix unused variable buf.Stanislav Lisovskiy
Despite the comment temporary buf is not used anywhere in convert_nv12_to_rgb24, so it has to be either removed or used instead of cvt->src.ptr. v2: Put it in use instead of removing as other functions seem to use it. Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2018-10-17lib: Don't call igt_require_fb_modifiers() when no modifierDeepak Rawat
vmwgfx and amdgpu doesn't support fb modifiers, yet kms_addfb() requires modifier support. Since many tests don't need this to run, the requirement can be made less broad. Therefore, tighten the requirement to cases where modifiers are actually needed. v2: * In create_fb() calls to kms_addfb(), remove the modifier flag iff the driver doesn't support modifiers and the modifer is 0 * Don't modify the flag in kms_addfb(). Signed-off-by: Deepak Rawat <drawat@vmware.com> Signed-off-by: Leo Li <sunpeng.li@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2018-10-17lib/igt_fb: Check for cairo surface successDeepak Rawat
For vmwgfx cairo surface creation fails due to stride mismatch, add a igt_require_f() for surface. v2: Check for surface creation failure. Signed-off-by: Deepak Rawat <drawat@vmware.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2018-10-17lib/igt_fb: Call dumb_destroy ioctl in case of dumb buffersDeepak Rawat
vmwgfx does not support GEM interface so calling gem_close on vmwgfx results in error. v2: Use drmIoctl with error when ioctl() failed. v3: Seperate ioctl wrapper. Signed-off-by: Deepak Rawat <drawat@vmware.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2018-10-08fb: Add more formatsMaxime Ripard
We're going to need some DRM formats, and we're going to need the igt_fb code to handle them. Since it relies on the format_desc structure to map the DRM fourcc to the pixman and cairo formats, we need to add these new formats to that structure. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2018-10-08fb: Add support for conversions through pixmanMaxime Ripard
Pixman allows for much more conversions than cairo, and we don't want to open code conversions routine for the common formats. Let's plug pixman in our conversion function so that we can benefit from it when possible. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-10-08fb: Add format conversion routineMaxime Ripard
The chamelium format subtests will need to convert the reference pattern to the format to be tested on the DRM device. However, Cairo is very limited when it comes to format, and while pixman has much more support for formats, it's still falling short compared to what DRM exposes, especially on the YUV side. Plus, since we want to run CRC checks on the frame, we can't afford having conversions back and forth between RGB24, as the current API is doing. In order to abstract this away, let's create a function that will convert a igt_fb structure to another DRM format and return the converted igt_fb. For now, we will use only cairo to do the conversion, but we will use other libraries or roll our own routines to convert to more exotic formats and abstract it away from the users. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-10-08fb: Create common function to convert frame formatsMaxime Ripard
The current code to convert between two buffer formats is quite tied to the cairo surface infrastructure. Since we'll want to reuse it, make that function more generic by introducing a common structure that passes all the arguments and a common function that will call the right functions we needed. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-10-08fb: convert: Remove swizzle from the argumentsMaxime Ripard
Since it can be inferred from the framebuffer that is already given as an argument, it is redundant and can be removed. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-10-08fb: Use an igt_fb for the cairo shadow bufferMaxime Ripard
In the case where an igt_fb user wants to get a cairo surface out of that framebuffer, if the format of that framebuffer cannot be imported as-is in Cairo, the current code will do an anonymous mapping to create a shadow buffer where an RGB24 copy of that buffer will be created. However, making that shadow buffer into an igt_fb itself will help us do further improvements on the conversion code. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2018-10-08fb: Add RGB888 formatMaxime Ripard
The RGB888 format is the one used as the shadow buffer used when a cairo surface is requested for a format that Cairo cannot handle. Since we're going to move that buffer representation to a struct igt_fb, let's add the RGB888 format to the list of formats that igt_fb knows about. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2018-10-08fb: Only set the GEM domain on intel platformsMaxime Ripard
The gem_set_domain call uses an i915 specific ioctl that will fail on anything else. Let's move that call under a check for whether or not we're running on an intel platform. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2018-10-08fb: Add buffer map/unmap functionsMaxime Ripard
The current code to manipulate the buffer has the assumption that we can create an underlying cairo instance. However, when it comes to supporting various formats, cairo is very limited so we would need to decouple the buffer access from cairo surfaces. Let's create a function that allows to map the underlying GEM buffer from an igt_fb structure, which will then allow use to manipulate as we wish. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
2018-09-27lib/igt_fb: Refactor blitter usageVille Syrjälä
Deduplicate the blitter code. Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-27lib/igt_fb: Pass around igt_fb internallyVille Syrjälä
Instead of passing around a boatload of integers everywhere let's just pass around the igt_fb struct. That obviously means we have to populate it first sufficiently, to which end we'll add a small helper. Later on the stride/size calculations will consult the already pre-populated igt_fb and fill in the rest as needed. This makes the whole thing a lot less error prone as it's impossible to accidentally pass the arguments in the wrong order when there's just the one of them, and it's a pointer. v2: Rebase due to uint64_t size Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-27lib/igt_fb: Constify format_desc_structVille Syrjälä
We don't want anyone to modify the format description structures. Make them const. Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-27lib/igt_fb: Consolidate fb size calculation to one functionVille Syrjälä
Eliminate the planar vs. packed size calculation differences and just use one function for the entire thing. v2: Rebase due to uint64_t size Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-27lib/igt_fb: Extract calc_plane_stride()Ville Syrjälä
Extract the stride calculation from calc_fb_size_packed() to its own thing so that we can use it to calculate just the stride. v2: Rebase due to overflow fixes and roundup_power_of_two() Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/igt_fb: Remove the hand rolled addfb2Ville Syrjälä
Just use __kms_addfb() always instead of hand rolling another drmModeAddFB2() usage. __kms_addfb() demands support for modifiers but we've had that for a long time now so it's not a problem. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/kms: Pass the number of planes explicitly to __kms_addfb()Ville Syrjälä
Currently __kms_addfb() assumes that only the first plane can be at offset 0. I don't particularly like such assumptions so let's just pass in the number of planes explicitly. We'll also require offsets[] to be passed in always. Nothing really to gain by making it optional. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/kms: Pass strides[] to __kms_addfbVille Syrjälä
Make __kms_addfb() usable with planar formats by passing in the stride for each plane. v2: Handle strides[1] for planar formats in kms_available_modes_crc Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/igt_fb: Add fb_num_planes()Ville Syrjälä
Add a helper to return the number of color planes. We'll need this for ccs support later. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/igt_fb: Add fb_plane_bpp()Ville Syrjälä
Add another helper to get the bpp for a specific color plane. We'll need this for ccs support later. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/igt_fb: s/planar_foo/fb_plane_foo/Ville Syrjälä
Rename the planar_foo() functions to fb_plane_foo(). Makes it clear they're perfectly usable with non-planar formats too. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/igt_fb: Pass fb_blit_upload to free_linear_mapping()Ville Syrjälä
With fb_blit_upload now being the base class of fb_convert_blit_upload we can pass the entire structure down to free_linear_mapping(). Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/igt_fb: Use fb_blit_upload as the base class for fb_convert_blit_uploadVille Syrjälä
fb_blit_upload already has everything we need, so let's use it as the base class for fb_convert_blit_upload. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib: Add DIV_ROUND_UP()Ville Syrjälä
Add DIV_ROUND_UP() and replace some hand rolled versions with it. v2: Drop the duplicate from gem_render_copy() (Paulo) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-25lib/igt_fb: Respect the users choice of strideVille Syrjälä
We prented to allow the caller to specify the stride explicitly for the fb. But we don't actually use that user specified stride when we calculate the require bo size. Fix that oversight. v2: Rebased due to uint64_t size Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2018-09-11lib: Add roundup_power_of_two()Ville Syrjälä
Add a helper to round a value to the next power of two size. And since we need fls() to implement that, reuse that elsewhere as well. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-09-11lib/igt_fb: Make fb size 64bitVille Syrjälä
Switch all fb size handling to 64bits to accomodate >4GiB framebuffers. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-09-07lib/igt_fb: Add missing set_domain callsVille Syrjälä
We're missing some set_domain calls around the ggtt mmap paths. This means we never tell the kernel that we've dirtied the object. And then at some point down the line the kernel throws the pages into /dev/null instead of hanging on to them/swapping them out because they were never marked as dirty. Throw in the missing set_domains(GTT,GTT) calls and rip out the old bogus set_domain(CPU,CPU). Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-06-08lib/fb: Add color_encoding/color_range to igt_fbVille Syrjälä
Make igt_fb be aware of the color encoding/range. For now we still hardcore everything to BT.709 limited range though. v2: Default to BT.709 Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2018-06-08lib: Add support for rendering into packed YCbCr framebuffersVille Syrjälä
Reuse the __convert() cairo stuff to support packed YCbCr framebuffers. v2: Allow odd fb width since some tests want it v3: Use igt_memcpy_from_wc() v4: Rebase due to color_encoding/range enums v5: Follow the fixed nv12 code v6: Use igt_format_is_yuv() Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2018-06-08lib: Use igt_matrix for ycbcr<->rgb conversionVille Syrjälä
Probably horribly inefficient (not that the original code tried to be particularly efficient), but at least this is now pretty generic so it'll be super easy to add other color encodings and whatnot. v2: Rebase v3: Deal with the new color_encoding/range enums v4: Fix the code to actually work, and do things in 2x2 blocks Keep the chroma siting comment and pimp it up a bit Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2018-06-08lib: Clean up format_descVille Syrjälä
Always populate the plane_bpp[] stuff, and use named initializers so that we can actually see what's being set to what. v2: Fix depth for xrgb8888 Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2018-06-08lib: Don't use dumb buffers for YCbCrVille Syrjälä
We don't do the "black != zero" clearing for dumb buffers, so let's not use them for YCbCr framebuffers. v2: Use igt_format_is_yuv() Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2018-06-08lib: Clear packed YUV formats to blackVille Syrjälä
As we do for NV12, let's also clear packed YUV formats to black instead of zero. Avoids unexpected green screens. v2: Nuke the debug messages v3: Use wmemset(Maarten) Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2018-06-07lib/igt_fb: Round to nearest when clamping rgbVille Syrjälä
I think round to nearest is maybe more correct here. Also do the clamp with integers as it actually makes the resulting code measurably faster. Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
2018-05-23lib: Add clamp() to igt_aux and use it for ycbcr<->rgb conversionVille Syrjälä
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-05-23tests/kms_plane_scaling: Allow clip test to fail with YUVVille Syrjälä
YUV formats require the clipped src coordinates to be suitably aligned. We'd need to very carefully compute the unclipped dst coordinates to guarantee that. That's too much hassle so let's just accept failure in case YUV formats are used. v2: Actually remove the original igt_display_commit2() (Maarten) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> #irc
2018-05-07lib: drop drmtest dependency on intel_batchbufferLionel Landwerlin
It doesn't look like there should be a dependency there. v2: s/intel_batchbuffer/intel_reg/ v3: One more s/intel_batchbuffer/intel_reg/ in benchmarks Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
2018-03-01lib: Provide an accelerated routine for readback from WCChris Wilson
Reading from WC is awfully slow as each access is uncached and so performed synchronously, stalling for the memory load. x86 did introduce some new instructions in SSE 4.1 to provide a small internal buffer to accelerate reading back a cacheline at a time from uncached memory, for this purpose. v2: Don't be lazy and handle misalignment. v3: Switch out of sse41 before emitting the generic memcpy routine v4: Replace opencoded memcpy_from_wc v5: Always flush the internal buffer before use (Eric) v6: Assume bulk moves, so check for dst alignment. v7: Use _mm_fence for _buitlin_ia32_mfence for consistency, remove superfluous defines (Ville) Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Eric Anholt <eric@anholt.net> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2018-02-12lib/igt_fb: Remove igt_get_all_cairo_formats()Maarten Lankhorst
All users have been converted to igt_fb_supported_format(), I don't think there's a valid use left for this. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> Tested-by: Vidya Srinivas <vidya.srinivas@intel.com>
2018-02-12lib/igt_fb: Add igt_fb_supported_format()Maarten Lankhorst
This makes it possible to iterate whether a format is supported or not, without each driver having to open code it. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> Tested-by: Vidya Srinivas <vidya.srinivas@intel.com>
2018-02-12lib/igt_fb: Make igt_remove_fb more robustMaarten Lankhorst
This will make it easier for tests to unconditionally call igt_remove_fb, without first checking whether the FB is allocated. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> Tested-by: Vidya Srinivas <vidya.srinivas@intel.com>
2018-02-01lib/igt_fb: Add support for NV12 format through conversion, v2.Maarten Lankhorst
For NV12 a format conversion is needed. Because YUV formats are not fully defined with just a fourcc, I've chosen BT.601 limited range. This puts the pixel center of the CbCr components between the top left Y and bottom left Y: Y Y Y Y UV UV Y Y Y Y Some work is put into optimising the conversion routines in order to make it fast enough. Before converting nv12 to rgb24, it is copied to a temporary buffer to take advantage of memory caching. This is approximately 20x faster than directly reading the BO. When testing on my KBL with a 1080p buffer, it takes approximately .1s to convert either way, this is fast enough not to bother optimising even further for me. Changes since v1: - Use BT.601 instead of BT.709 coefficients. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com>
2018-02-01lib/fb: Add support for creating planar framebuffers, v3.Maarten Lankhorst
Add support to create planar framebuffers, but don't add formats that support them yet. This first requires conversion to the RGB24 format. Changes since v1: - Don't crash in igt_create_bo_with_dimensions(). Changes since v2: - Zero offsets for dumb fb too. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> [mlankhorst: Change memset(4 * ..) to memset(ARRAY_SIZE(format->plane_bpp) * ..)]
2018-02-01lib/intel_batchbuffer: Add delta argument to igt_blitter_fast_copy__raw, v2.Maarten Lankhorst
Adding a delta offset will allow us to copy planar framebuffers with this function. Changes since v1: - Set src and destination addresses to the delta, in case BO is mapped at offset 0. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Mika Kahola <mika.kahola@intel.com> #v1