drm/vkms: Reimplement line-per-line pixel conversion for plane reading
Louis Chauvet
maintainerv4 cover drm/vkms: Reimplement line-per-line pixel conversion for plane reading
This patchset is the second version of [1]. It is almost a complete rewrite to use a line-by-line algorithm for the composition. It can be divided in three parts:
- PATCH 1 to 4: no functional change is intended, only some formatting and documenting (PATCH 2 is taken from [2])
- PATCH 5 to 8: Some preparation work not directly related to the line-by-line algorithm
- PATCH 9: main patch for this series, it reintroduce the line-by-line algorithm
- PATCH 10 to 13: taken from Arthur's series [2], with sometimes adaptation to use the pixel-by-pixel algorithm.
The PATCH 9 aims to restore the line-by-line pixel reading algorithm. It was introduced in 8ba1648567e2 ("drm: vkms: Refactor the plane composer to accept new formats") but removed in 8ba1648567e2 ("drm: vkms: Refactor the plane composer to accept new formats") in a over-simplification effort. At this time, nobody noticed the performance impact of this commit. After the first iteration of my series, poeple notice performance impact, and it was the case. Pekka suggested to reimplement the line-by-line algorithm.
Expiriments on my side shown great improvement for the line-by-line algorithm, and the performances are the same as the original line-by-line algorithm. I targeted my effort to make the code working for all the rotations and translations. The usage of helpers from drm_rect_* avoid reimplementing existing logic.
The only "complex" part remaining is the clipping of the coordinate to avoid reading/writing outside of src/dst. Thus I added a lot of comments to help when someone will want to add some features (framebuffer resizing for example).
The YUV part is not mandatory for this series, but as my first effort was to help the integration of YUV, I decided to rebase Arthur's series on mine to help. I took [3], [4], [5] and [6] and adapted them to use the line-by-line reading. They were also updated to use 32.32 fixed point values for yuv conversion instead of 8.8 fixed points.
My series was mainly tested with:
- kms_plane (for color conversions)
- kms_rotation_crc (for rotations of planes)
- kms_cursor_crc (for translations)
The benchmark used to measure the improvment was done with:
- kms_fb_stress
[1]: https://lore.kernel.org/r/[email protected]
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://lore.kernel.org/all/[email protected]/
[4]: https://lore.kernel.org/all/[email protected]/
[5]: https://lore.kernel.org/all/[email protected]/
[6]: https://lore.kernel.org/all/[email protected]/
To: Rodrigo Siqueira <[email protected]>
To: Melissa Wen <[email protected]>
To: Maíra Canal <[email protected]>
To: Haneen Mohammed <[email protected]>
To: Daniel Vetter <[email protected]>
To: Maarten Lankhorst <[email protected]>
To: Maxime Ripard <[email protected]>
To: Thomas Zimmermann <[email protected]>
To: David Airlie <[email protected]>
To: [email protected]
To: Jonathan Corbet <[email protected]>
To: [email protected]
Note: after my changes, those tests seems to pass, so [7] may need updating (I did not check, it was maybe already the case):
- kms_cursor_legacy@flip-vs-cursor-atomic
- kms_pipe_crc_basic@nonblocking-crc
- kms_pipe_crc_basic@nonblocking-crc-frame-sequence
- kms_writeback@writeback-pixel-formats
- kms_writeback@writeback-invalid-parameters
- kms_flip@flip-vs-absolute-wf_vblank-interruptible
And those tests pass, I did not investigate why the runners fails:
- kms_flip@flip-vs-expired-vblank-interruptible
- kms_flip@flip-vs-expired-vblank
- kms_flip@plain-flip-fb-recreate
- kms_flip@plain-flip-fb-recreate-interruptible
- kms_flip@plain-flip-ts-check-interruptible
- kms_cursor_legacy@cursorA-vs-flipA-toggle
- kms_pipe_crc_basic@nonblocking-crc
- kms_prop_blob@invalid-get-prop
- kms_flip@flip-vs-absolute-wf_vblank-interruptible
- kms_invalid_mode@zero-hdisplay
- kms_invalid_mode@bad-vtotal
- kms_cursor_crc.* (everything is SUCCEED or SKIP, but no fails)
[7]: https://lore.kernel.org/all/[email protected]/
Changes in v4:
- PATCH 3/14: Update comments for get_pixel_* functions
- PATCH 4/14: Add WARN when trying to get unsupported pixel_* functions
- PATCH 5/14: Create dummy pixel reader/writer to avoid NULL
function pointers and kernel OOPS
- PATCH 6/14: Added the usage of const pointers when needed
- PATCH 7/14: Extraction of pixel accessors modification
- PATCH 8/14: Extraction of the blending function modification
- PATCH 9/14: Extraction of the pixel_read_direction enum
- PATCH 10/14: Update direction_for_rotation documentation
- PATCH 10/14: Rename conversion functions to be explicit
- PATCH 10/14: Replace while(count) by while(out_pixel<end) in read_line callbacks. It avoid a new variable+addition in the composition hot path.
- PATCH 11/14: Rename conversion functions to be explicit
- PATCH 11/14: Update the documentation for get_subsampling_offset
- PATCH 11/14: Add the matrix_conversion structure to remove a test from the hot path.
- PATCH 11/14: Upadate matrix values to use 32.32 fixed floats for conversion
- PATCH 12/14: Update commit message
- PATCH 14/14: Change kunit expected value
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Correction of remaining git-rebase artefacts
- Added Pekka in copy of this patch
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Rebased the series on top of drm-misc/drm-misc-net
- Extract the typedef for pixel_read/pixel_write
- Introduce the line-by-line algorithm per pixel format
- Add some documentation for existing and new code
- Port the series [1] to use line-by-line algorithm
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Arthur Grillo (5):
drm/vkms: Use drm_frame directly
drm/vkms: Add YUV support
drm/vkms: Add range and encoding properties to the plane drm/vkms: Drop YUV formats TODO
drm/vkms: Create KUnit tests for YUV conversions
Louis Chauvet (9):
drm/vkms: Code formatting
drm/vkms: write/update the documentation for pixel conversion and pixel write functions drm/vkms: Add typedef and documentation for pixel_read and pixel_write functions drm/vkms: Add dummy pixel_read/pixel_write callbacks to avoid NULL pointers drm/vkms: Use const for input pointers in pixel_read an pixel_write functions drm/vkms: Update pixels accessor to support packed and multi-plane formats. drm/vkms: Avoid computing blending limits inside pre_mul_alpha_blend drm/vkms: Introduce pixel_read_direction enum
drm/vkms: Re-introduce line-per-line composition algorithm
Documentation/gpu/vkms.rst | 3 +- drivers/gpu/drm/vkms/Kconfig | 15 + drivers/gpu/drm/vkms/Makefile | 1 + drivers/gpu/drm/vkms/tests/.kunitconfig | 4 + drivers/gpu/drm/vkms/tests/Makefile | 3 + drivers/gpu/drm/vkms/tests/vkms_format_test.c | 158 ++++++ drivers/gpu/drm/vkms/vkms_composer.c | 251 ++++++-- drivers/gpu/drm/vkms/vkms_crtc.c | 6 +- drivers/gpu/drm/vkms/vkms_drv.c | 3 +- drivers/gpu/drm/vkms/vkms_drv.h | 86 ++- drivers/gpu/drm/vkms/vkms_formats.c | 790 ++++++++++++++++++++++---- drivers/gpu/drm/vkms/vkms_formats.h | 12 +- drivers/gpu/drm/vkms/vkms_plane.c | 45 +- drivers/gpu/drm/vkms/vkms_writeback.c | 5 - 14 files changed, 1167 insertions(+), 215 deletions(-)
---
base-commit: c079e2e113f2ec2803ba859bbb442a6ab82c96bd
change-id: 20240201-yuv-1337d90d9576
Best regards,
Signature · 1 line
Louis Chauvet <[email protected]>
Louis Chauvet
maintainerPATCH v4 1/14 drm/vkms: Code formatting
Few no-op changes to remove double spaces and fix wrong alignments.
--- drivers/gpu/drm/vkms/vkms_composer.c | 10 +++++----- drivers/gpu/drm/vkms/vkms_crtc.c | 6 ++---- drivers/gpu/drm/vkms/vkms_drv.c | 3 +-- drivers/gpu/drm/vkms/vkms_plane.c | 8 ++++---- 4 files changed, 12 insertions(+), 15 deletions(-)
drivers/gpu/drm/vkms/vkms_composer.c +5 -5
@@ -96,7 +96,7 @@ static u16 lerp_u16(u16 a, u16 b, s64 t)s64 a_fp =drm_int2fixp (a);s64 b_fp =drm_int2fixp (b); -s64 delta =drm_fixp_mul (b_fp - a_fp, t); +s64 delta =drm_fixp_mul (b_fp - a_fp, t);return drm_fixp2int (a_fp + delta); }
@@ -302,8 +302,8 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb,void vkms_composer_worker (struct work_struct *work) {struct vkms_crtc_state *crtc_state =container_of (work, - struct vkms_crtc_state, - composer_work); + struct vkms_crtc_state, + composer_work);struct drm_crtc *crtc = crtc_state->base.crtc;struct vkms_writeback_job *active_wb = crtc_state->active_writeback;struct vkms_output *out =drm_crtc_to_vkms_output (crtc);
@@ -328,7 +328,7 @@ void vkms_composer_worker(struct work_struct *work) crtc_state->gamma_lut.base = (struct drm_color_lut *)crtc->state->gamma_lut->data; crtc_state->gamma_lut.lut_length = crtc->state->gamma_lut->length /sizeof (struct drm_color_lut ); - max_lut_index_fp =drm_int2fixp (crtc_state->gamma_lut.lut_length -1 ); + max_lut_index_fp =drm_int2fixp (crtc_state->gamma_lut.lut_length -1 ); crtc_state->gamma_lut.channel_value2index_ratio =drm_fixp_div (max_lut_index_fp, u16_max_fp);
@@ -367,7 +367,7 @@ void vkms_composer_worker(struct work_struct *work)drm_crtc_add_crc_entry (crtc, true, frame_start++, &crc32); } -static const char *const pipe_crc_sources[] = {"auto" }; +static const char *const pipe_crc_sources[] = {"auto" };const char *const *vkms_get_crc_sources (struct drm_crtc *crtc,size_t *count)
drivers/gpu/drm/vkms/vkms_crtc.c +2 -4
@@ -191,8 +191,7 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,return ret;drm_for_each_plane_mask (plane, crtc->dev, crtc_state->plane_mask) { - plane_state =drm_atomic_get_existing_plane_state (crtc_state->state, - plane); + plane_state =drm_atomic_get_existing_plane_state (crtc_state->state, plane);WARN_ON (!plane_state);if (!plane_state->visible)
@@ -208,8 +207,7 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc, i =0 ;drm_for_each_plane_mask (plane, crtc->dev, crtc_state->plane_mask) { - plane_state =drm_atomic_get_existing_plane_state (crtc_state->state, - plane); + plane_state =drm_atomic_get_existing_plane_state (crtc_state->state, plane);if (!plane_state->visible)continue ;
drivers/gpu/drm/vkms/vkms_drv.c +1 -2
@@ -81,8 +81,7 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state)drm_atomic_helper_wait_for_flip_done (dev, old_state);for_each_old_crtc_in_state (old_state, crtc, old_crtc_state, i) { -struct vkms_crtc_state *vkms_state = -to_vkms_crtc_state (old_crtc_state); +struct vkms_crtc_state *vkms_state =to_vkms_crtc_state (old_crtc_state);flush_work (&vkms_state->composer_work); }
drivers/gpu/drm/vkms/vkms_plane.c +4 -4
@@ -117,10 +117,10 @@ static void vkms_plane_atomic_update(struct drm_plane *plane,memcpy (&frame_info->map, &shadow_plane_state->data,sizeof (frame_info->map));drm_framebuffer_get (frame_info->fb); frame_info->rotation =drm_rotation_simplify (new_state->rotation,DRM_MODE_ROTATE_0 | -DRM_MODE_ROTATE_90 | -DRM_MODE_ROTATE_270 | -DRM_MODE_REFLECT_X | -DRM_MODE_REFLECT_Y ); +DRM_MODE_ROTATE_90 | +DRM_MODE_ROTATE_270 | +DRM_MODE_REFLECT_X | +DRM_MODE_REFLECT_Y );drm_rect_rotate (&frame_info->rotated,drm_rect_width (&frame_info->rotated),drm_rect_height (&frame_info->rotated), frame_info->rotation);
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 2/14 drm/vkms: Use drm_frame directly
In reply to Louis ChauvetFrom: Arthur Grillo <[email protected]>
Remove intermidiary variables and access the variables directly from drm_frame. These changes should be noop.
--- drivers/gpu/drm/vkms/vkms_drv.h | 3 --- drivers/gpu/drm/vkms/vkms_formats.c | 12 +++++++----- drivers/gpu/drm/vkms/vkms_plane.c | 3 --- drivers/gpu/drm/vkms/vkms_writeback.c | 5 ----- 4 files changed, 7 insertions(+), 16 deletions(-)
drivers/gpu/drm/vkms/vkms_drv.h +0 -3
@@ -31,9 +31,6 @@ struct vkms_frame_info {struct drm_rect rotated;struct iosys_map map[DRM_FORMAT_MAX_PLANES ];unsigned int rotation; -unsigned int offset; -unsigned int pitch; -unsigned int cpp; };struct pixel_argb_u16 {
drivers/gpu/drm/vkms/vkms_formats.c +7 -5
@@ -11,8 +11,10 @@static size_t pixel_offset (const struct vkms_frame_info *frame_info,int x,int y) { -return frame_info->offset + (y * frame_info->pitch) - + (x * frame_info->cpp); +struct drm_framebuffer *fb = frame_info->fb; + +return fb->offsets[0 ] + (y * fb->pitches[0 ]) + + (x * fb->format->cpp[0 ]); }/*
@@ -131,12 +133,12 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_stateu8 *src_pixels =get_packed_src_addr (frame_info, y);int limit =min_t (size_t,drm_rect_width (&frame_info->dst), stage_buffer->n_pixels); -for (size_t x =0 ; x < limit; x++, src_pixels += frame_info->cpp) { +for (size_t x =0 ; x < limit; x++, src_pixels += frame_info->fb->format->cpp[0 ]) {int x_pos =get_x_position (frame_info, limit, x);if (drm_rotation_90_or_270 (frame_info->rotation)) src_pixels =get_packed_src_addr (frame_info, x + frame_info->rotated.y1) - + frame_info->cpp * y; + + frame_info->fb->format->cpp[0 ] * y; plane->pixel_read (src_pixels, &out_pixels[x_pos]); }
@@ -223,7 +225,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb,struct pixel_argb_u16 *in_pixels = src_buffer->pixels;int x_limit =min_t (size_t,drm_rect_width (&frame_info->dst), src_buffer->n_pixels); -for (size_t x =0 ; x < x_limit; x++, dst_pixels += frame_info->cpp) +for (size_t x =0 ; x < x_limit; x++, dst_pixels += frame_info->fb->format->cpp[0 ]) wb->pixel_write (dst_pixels, &in_pixels[x]); }
drivers/gpu/drm/vkms/vkms_plane.c +0 -3
@@ -125,9 +125,6 @@ static void vkms_plane_atomic_update(struct drm_plane *plane,drm_rect_rotate (&frame_info->rotated,drm_rect_width (&frame_info->rotated),drm_rect_height (&frame_info->rotated), frame_info->rotation); - frame_info->offset = fb->offsets[0 ]; - frame_info->pitch = fb->pitches[0 ]; - frame_info->cpp = fb->format->cpp[0 ]; vkms_plane_state->pixel_read =get_pixel_conversion_function (fmt); }
drivers/gpu/drm/vkms/vkms_writeback.c +0 -5
@@ -149,11 +149,6 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, crtc_state->active_writeback = active_wb; crtc_state->wb_pending = true;spin_unlock_irq (&output->composer_lock); - - wb_frame_info->offset = fb->offsets[0 ]; - wb_frame_info->pitch = fb->pitches[0 ]; - wb_frame_info->cpp = fb->format->cpp[0 ]; -drm_writeback_queue_job (wb_conn, connector_state); active_wb->pixel_write =get_pixel_write_function (wb_format);drm_rect_init (&wb_frame_info->src,0 ,0 , crtc_width, crtc_height);
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 3/14 drm/vkms: write/update the documentation for pixel conversion and pixel write functions
In reply to Louis ChauvetAdd some documentation on pixel conversion functions. Update of outdated comments for pixel_write functions.
--- drivers/gpu/drm/vkms/vkms_composer.c | 7 ++++ drivers/gpu/drm/vkms/vkms_drv.h | 13 ++++++++ drivers/gpu/drm/vkms/vkms_formats.c | 62 ++++++++++++++++++++++++++++++------ 3 files changed, 73 insertions(+), 9 deletions(-)
drivers/gpu/drm/vkms/vkms_composer.c +7 -0
@@ -189,6 +189,13 @@ static void blend(struct vkms_writeback_job *wb,size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay; +/* +* The planes are composed line-by-line to avoid heavy memory usage. It is a necessary +* complexity to avoid poor blending performance. +* +* The function vkms_compose_row is used to read a line, pixel-by-pixel, into the staging +* buffer. +*/ for (size_t y =0 ; y < crtc_y_limit; y++) {fill_background (&background_color, output_buffer);
drivers/gpu/drm/vkms/vkms_drv.h +13 -0
@@ -25,6 +25,17 @@#define VKMS_LUT_SIZE 256 +/** +* struct vkms_frame_info - structure to store the state of a frame +* +* @fb: backing drm framebuffer +* @src: source rectangle of this frame in the source framebuffer +* @dst: destination rectangle in the crtc buffer +* @map: see drm_shadow_plane_state@data +* @rotation: rotation applied to the source. +* +* @src and @dst should have the same size modulo the rotation. +*/ struct vkms_frame_info {struct drm_framebuffer *fb;struct drm_rect src, dst;
@@ -52,6 +63,8 @@ struct vkms_writeback_job {* vkms_plane_state - Driver specific plane state * @base: base plane state * @frame_info: data required for composing computation +* @pixel_read: function to read a pixel in this plane. The creator of a vkms_plane_state must +* ensure that this pointer is valid */ struct vkms_plane_state {struct drm_shadow_plane_state base;
drivers/gpu/drm/vkms/vkms_formats.c +53 -9
113 lines not on this page · raw message
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 4/14 drm/vkms: Add typedef and documentation for pixel_read and pixel_write functions
In reply to Louis ChauvetIntroduce two typedefs: pixel_read_t and pixel_write_t. It allows the compiler to check if the passed functions take the correct arguments. Such typedefs will help ensuring consistency across the code base in case of update of these prototypes.
Rename input/output variable in a consistent way between read_line and write_line.
A warn has been added in get_pixel_*_function to alert when an unsupported pixel format is requested. As those formats are checked before atomic_update callbacks, it should never append.
Document for those typedefs.
--- drivers/gpu/drm/vkms/vkms_drv.h | 23 ++++++- drivers/gpu/drm/vkms/vkms_formats.c | 122 ++++++++++++++++++++---------------- drivers/gpu/drm/vkms/vkms_formats.h | 4 +- drivers/gpu/drm/vkms/vkms_plane.c | 2 +- 4 files changed, 93 insertions(+), 58 deletions(-)
drivers/gpu/drm/vkms/vkms_drv.h +21 -2
@@ -53,12 +53,31 @@ struct line_buffer {struct pixel_argb_u16 *pixels; }; +/** +* typedef pixel_write_t - These functions are used to read a pixel from a +* `struct pixel_argb_u16*`, convert it in a specific format and write it in the @dst_pixels +* buffer. +* +* @out_pixel: destination address to write the pixel +* @in_pixel: pixel to write +*/ +typedef void (*pixel_write_t )(u8 *out_pixel,struct pixel_argb_u16 *in_pixel); +struct vkms_writeback_job {struct iosys_map data[DRM_FORMAT_MAX_PLANES ];struct vkms_frame_info wb_frame_info; -void (*pixel_write)(u8 *dst_pixels,struct pixel_argb_u16 *in_pixel); +pixel_write_t pixel_write; }; +/** +* typedef pixel_read_t - These functions are used to read a pixel in the source frame, +* convert it to `struct pixel_argb_u16` and write it to @out_pixel. +* +* @in_pixel: Pointer to the pixel to read +* @out_pixel: Pointer to write the converted pixel +*/ +typedef void (*pixel_read_t )(u8 *in_pixel,struct pixel_argb_u16 *out_pixel); +/** * vkms_plane_state - Driver specific plane state * @base: base plane state
@@ -69,7 +88,7 @@ struct vkms_writeback_job {struct vkms_plane_state {struct drm_shadow_plane_state base;struct vkms_frame_info *frame_info; -void (*pixel_read)(u8 *src_buffer,struct pixel_argb_u16 *out_pixel); +pixel_read_t pixel_read; };struct vkms_plane {
drivers/gpu/drm/vkms/vkms_formats.c +69 -53
213 lines not on this page · raw message
drivers/gpu/drm/vkms/vkms_formats.h +2 -2
@@ -5,8 +5,8 @@#include "vkms_drv.h" -void *get_pixel_conversion_function (u32 format); +pixel_read_t get_pixel_read_function (u32 format); -void *get_pixel_write_function (u32 format); +pixel_write_t get_pixel_write_function (u32 format);#endif /* _VKMS_FORMATS_H_ */
drivers/gpu/drm/vkms/vkms_plane.c +1 -1
@@ -125,7 +125,7 @@ static void vkms_plane_atomic_update(struct drm_plane *plane,drm_rect_rotate (&frame_info->rotated,drm_rect_width (&frame_info->rotated),drm_rect_height (&frame_info->rotated), frame_info->rotation); - vkms_plane_state->pixel_read =get_pixel_conversion_function (fmt); + vkms_plane_state->pixel_read =get_pixel_read_function (fmt); } static int vkms_plane_atomic_check(struct drm_plane *plane,
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 5/14 drm/vkms: Add dummy pixel_read/pixel_write callbacks to avoid NULL pointers
In reply to Louis ChauvetIntroduce two callbacks which does nothing. They are used in replacement of NULL and it avoid kernel OOPS if this NULL is called.
If those callback are used, it means that there is a mismatch between what formats are announced by atomic_check and what is realy supported by atomic_update.
--- drivers/gpu/drm/vkms/vkms_formats.c | 42 +++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-)
drivers/gpu/drm/vkms/vkms_formats.c +36 -6
@@ -136,6 +136,21 @@ static void RGB565_to_argb_u16(u8 *in_pixel, struct pixel_argb_u16 *out_pixel) out_pixel->b =drm_fixp2int_round (drm_fixp_mul (fp_b, fp_rb_ratio)); } +/** +* black_to_argb_u16() - pixel_read callback which always read black +* +* This callback is used when an invalid format is requested for plane reading. +* It is used to avoid null pointer to be used as a function. In theory, this function should +* never be called, except if you found a bug in the driver/DRM core. +*/ +static void black_to_argb_u16 (u8 *in_pixel,struct pixel_argb_u16 *out_pixel) +{ + out_pixel->a = (u16 )0xFFFF ; + out_pixel->r =0 ; + out_pixel->g =0 ; + out_pixel->b =0 ; +} +/** * vkms_compose_row - compose a single row of a plane * @stage_buffer: output line with the composed pixels
@@ -238,6 +253,15 @@ static void argb_u16_to_RGB565(u8 *out_pixel, struct pixel_argb_u16 *in_pixel) *pixel =cpu_to_le16 (r <<11 | g <<5 | b); } +/** +* argb_u16_to_nothing() - pixel_write callback with no effect +* +* This callback is used when an invalid format is requested for writeback. +* It is used to avoid null pointer to be used as a function. In theory, this should never +* happen, except if there is a bug in the driver +*/ +static void argb_u16_to_nothing (u8 *out_pixel,struct pixel_argb_u16 *in_pixel) {} +/** * Generic loop for all supported writeback format. It is executed just after the blending to * write a line in the writeback buffer.
@@ -261,8 +285,8 @@ void vkms_writeback_row(struct vkms_writeback_job *wb,/** * Retrieve the correct read_pixel function for a specific format. -* The returned pointer is NULL for unsupported pixel formats. The caller must ensure that the -* pointer is valid before using it in a vkms_plane_state. +* If the format is not supported by VKMS a warn is emitted and a dummy "always read black" +* function is returned. * * @format: DRM_FORMAT_* value for which to obtain a conversion function (see [drm_fourcc.h]) */
@@ -285,17 +309,20 @@ pixel_read_t get_pixel_read_function(u32 format)* format must: * - Be listed in vkms_formats in vkms_plane.c * - Have a pixel_read callback defined here +* +* To avoid kernel crash, a dummy "always read black" function is used. It means +* that during the composition, this plane will always be black. */ WARN (true,"Pixel format %4cc is not supported by VKMS planes. This is a kernel bug, atomic check must forbid this configuration.\n" , format); -return (pixel_read_t )NULL ; +return &black_to_argb_u16; } }/** * Retrieve the correct write_pixel function for a specific format. -* The returned pointer is NULL for unsupported pixel formats. The caller must ensure that the -* pointer is valid before using it in a vkms_writeback_job. +* If the format is not supported by VKMS a warn is emitted and a dummy "don't do anything" +* function is returned. * * @format: DRM_FORMAT_* value for which to obtain a conversion function (see [drm_fourcc.h]) */
@@ -318,9 +345,12 @@ pixel_write_t get_pixel_write_function(u32 format)* format must: * - Be listed in vkms_wb_formats in vkms_writeback.c * - Have a pixel_write callback defined here +* +* To avoid kernel crash, a dummy "don't do anything" function is used. It means +* that the resulting writeback buffer is not composed and can contains any values. */ WARN (true,"Pixel format %4cc is not supported by VKMS writeback. This is a kernel bug, atomic check must forbid this configuration.\n" , format); -return (pixel_write_t )NULL ; +return &argb_u16_to_nothing; } }
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 6/14 drm/vkms: Use const for input pointers in pixel_read an pixel_write functions
In reply to Louis ChauvetAs the pixel_read and pixel_write function should never modify the input buffer, mark those pointers const.
--- drivers/gpu/drm/vkms/vkms_drv.h | 4 ++-- drivers/gpu/drm/vkms/vkms_formats.c | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/vkms/vkms_drv.h +2 -2
@@ -61,7 +61,7 @@ struct line_buffer {* @out_pixel: destination address to write the pixel * @in_pixel: pixel to write */ -typedef void (*pixel_write_t )(u8 *out_pixel,struct pixel_argb_u16 *in_pixel); +typedef void (*pixel_write_t )(u8 *out_pixel,const struct pixel_argb_u16 *in_pixel);struct vkms_writeback_job {struct iosys_map data[DRM_FORMAT_MAX_PLANES ];
@@ -76,7 +76,7 @@ struct vkms_writeback_job {* @in_pixel: Pointer to the pixel to read * @out_pixel: Pointer to write the converted pixel */ -typedef void (*pixel_read_t )(u8 *in_pixel,struct pixel_argb_u16 *out_pixel); +typedef void (*pixel_read_t )(const u8 *in_pixel,struct pixel_argb_u16 *out_pixel);/** * vkms_plane_state - Driver specific plane state
drivers/gpu/drm/vkms/vkms_formats.c +12 -12
@@ -76,7 +76,7 @@ static int get_x_position(const struct vkms_frame_info *frame_info, int limit, i* They are used in the `vkms_compose_row` function to handle multiple formats. */ -static void ARGB8888_to_argb_u16 (u8 *in_pixel,struct pixel_argb_u16 *out_pixel) +static void ARGB8888_to_argb_u16 (const u8 *in_pixel,struct pixel_argb_u16 *out_pixel) {/* * The 257 is the "conversion ratio". This number is obtained by the
@@ -90,7 +90,7 @@ static void ARGB8888_to_argb_u16(u8 *in_pixel, struct pixel_argb_u16 *out_pixel) out_pixel->b = (u16 )in_pixel[0 ] *257 ; } -static void XRGB8888_to_argb_u16 (u8 *in_pixel,struct pixel_argb_u16 *out_pixel) +static void XRGB8888_to_argb_u16 (const u8 *in_pixel,struct pixel_argb_u16 *out_pixel) { out_pixel->a = (u16 )0xffff ; out_pixel->r = (u16 )in_pixel[2 ] *257 ;
@@ -98,7 +98,7 @@ static void XRGB8888_to_argb_u16(u8 *in_pixel, struct pixel_argb_u16 *out_pixel) out_pixel->b = (u16 )in_pixel[0 ] *257 ; } -static void ARGB16161616_to_argb_u16 (u8 *in_pixel,struct pixel_argb_u16 *out_pixel) +static void ARGB16161616_to_argb_u16 (const u8 *in_pixel,struct pixel_argb_u16 *out_pixel) {u16 *pixel = (u16 *)in_pixel;
@@ -108,7 +108,7 @@ static void ARGB16161616_to_argb_u16(u8 *in_pixel, struct pixel_argb_u16 *out_pi out_pixel->b =le16_to_cpu (pixel[0 ]); } -static void XRGB16161616_to_argb_u16 (u8 *in_pixel,struct pixel_argb_u16 *out_pixel) +static void XRGB16161616_to_argb_u16 (const u8 *in_pixel,struct pixel_argb_u16 *out_pixel) {u16 *pixel = (u16 *)in_pixel;
@@ -118,7 +118,7 @@ static void XRGB16161616_to_argb_u16(u8 *in_pixel, struct pixel_argb_u16 *out_pi out_pixel->b =le16_to_cpu (pixel[0 ]); } -static void RGB565_to_argb_u16 (u8 *in_pixel,struct pixel_argb_u16 *out_pixel) +static void RGB565_to_argb_u16 (const u8 *in_pixel,struct pixel_argb_u16 *out_pixel) {u16 *pixel = (u16 *)in_pixel;
@@ -143,7 +143,7 @@ static void RGB565_to_argb_u16(u8 *in_pixel, struct pixel_argb_u16 *out_pixel)* It is used to avoid null pointer to be used as a function. In theory, this function should * never be called, except if you found a bug in the driver/DRM core. */ -static void black_to_argb_u16 (u8 *in_pixel,struct pixel_argb_u16 *out_pixel) +static void black_to_argb_u16 (const u8 *in_pixel,struct pixel_argb_u16 *out_pixel) { out_pixel->a = (u16 )0xFFFF ; out_pixel->r =0 ;
@@ -189,7 +189,7 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state* They are used in the `vkms_writeback_row` to convert and store a pixel from the src_buffer to * the writeback buffer. */ -static void argb_u16_to_ARGB8888 (u8 *out_pixel,struct pixel_argb_u16 *in_pixel) +static void argb_u16_to_ARGB8888 (u8 *out_pixel,const struct pixel_argb_u16 *in_pixel) {/* * This sequence below is important because the format's byte order is
@@ -207,7 +207,7 @@ static void argb_u16_to_ARGB8888(u8 *out_pixel, struct pixel_argb_u16 *in_pixel) out_pixel[0 ] =DIV_ROUND_CLOSEST (in_pixel->b,257 ); } -static void argb_u16_to_XRGB8888 (u8 *out_pixel,struct pixel_argb_u16 *in_pixel) +static void argb_u16_to_XRGB8888 (u8 *out_pixel,const struct pixel_argb_u16 *in_pixel) { out_pixel[3 ] =0xff ; out_pixel[2 ] =DIV_ROUND_CLOSEST (in_pixel->r,257 );
@@ -215,7 +215,7 @@ static void argb_u16_to_XRGB8888(u8 *out_pixel, struct pixel_argb_u16 *in_pixel) out_pixel[0 ] =DIV_ROUND_CLOSEST (in_pixel->b,257 ); } -static void argb_u16_to_ARGB16161616 (u8 *out_pixel,struct pixel_argb_u16 *in_pixel) +static void argb_u16_to_ARGB16161616 (u8 *out_pixel,const struct pixel_argb_u16 *in_pixel) {u16 *pixel = (u16 *)out_pixel;
@@ -225,7 +225,7 @@ static void argb_u16_to_ARGB16161616(u8 *out_pixel, struct pixel_argb_u16 *in_pi pixel[0 ] =cpu_to_le16 (in_pixel->b); } -static void argb_u16_to_XRGB16161616 (u8 *out_pixel,struct pixel_argb_u16 *in_pixel) +static void argb_u16_to_XRGB16161616 (u8 *out_pixel,const struct pixel_argb_u16 *in_pixel) {u16 *pixel = (u16 *)out_pixel;
@@ -235,7 +235,7 @@ static void argb_u16_to_XRGB16161616(u8 *out_pixel, struct pixel_argb_u16 *in_pi pixel[0 ] =cpu_to_le16 (in_pixel->b); } -static void argb_u16_to_RGB565 (u8 *out_pixel,struct pixel_argb_u16 *in_pixel) +static void argb_u16_to_RGB565 (u8 *out_pixel,const struct pixel_argb_u16 *in_pixel) {u16 *pixel = (u16 *)out_pixel;
@@ -260,7 +260,7 @@ static void argb_u16_to_RGB565(u8 *out_pixel, struct pixel_argb_u16 *in_pixel)* It is used to avoid null pointer to be used as a function. In theory, this should never * happen, except if there is a bug in the driver */ -static void argb_u16_to_nothing (u8 *out_pixel,struct pixel_argb_u16 *in_pixel) {} +static void argb_u16_to_nothing (u8 *out_pixel,const struct pixel_argb_u16 *in_pixel) {}/** * Generic loop for all supported writeback format. It is executed just after the blending to
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 7/14 drm/vkms: Update pixels accessor to support packed and multi-plane formats.
In reply to Louis ChauvetIntroduce the usage of block_h/block_w to compute the offset and the pointer of a pixel. The previous implementation was specialized for planes with block_h == block_w == 1. To avoid confusion and allow easier implementation of tiled formats. It also remove the usage of the deprecated format field cpp.
Introduce the plane_index parameter to get an offset/pointer on a different plane.
--- drivers/gpu/drm/vkms/vkms_formats.c | 59 +++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 25 deletions(-)
drivers/gpu/drm/vkms/vkms_formats.c +34 -25
@@ -10,23 +10,33 @@#include "vkms_formats.h" /** -* pixel_offset() - Get the offset of the pixel at coordinates x/y in the first plane +* packed_pixels_offset() - Get the offset of the block containing the pixel at coordinates x/y * * @frame_info: Buffer metadata * @x: The x coordinate of the wanted pixel in the buffer * @y: The y coordinate of the wanted pixel in the buffer +* @plane_index: The index of the plane to use * -* The caller must ensure that the framebuffer associated with this request uses a pixel format -* where block_h == block_w == 1. -* If this requirement is not fulfilled, the resulting offset can point to an other pixel or -* outside of the buffer. +* The returned offset correspond to the offset of the block containing the pixel at coordinates +* x/y. +* The caller must use this offset with care, as for formats with block_h != 1 or block_w != 1 +* the requested pixel value may have to be extracted from the block, even if they are +* individually addressable. */ -static size_t pixel_offset (const struct vkms_frame_info *frame_info,int x,int y) +static size_t packed_pixels_offset (const struct vkms_frame_info *frame_info,int x,int y, +size_t plane_index) {struct drm_framebuffer *fb = frame_info->fb; - -return fb->offsets[0 ] + (y * fb->pitches[0 ]) - + (x * fb->format->cpp[0 ]); +const struct drm_format_info *format = frame_info->fb->format; +/* Directly using x and y to multiply pitches and format->ccp is not sufficient because +* in some formats a block can represent multiple pixels. +* +* Dividing x and y by the block size allows to extract the correct offset of the block +* containing the pixel. +*/ +return fb->offsets[plane_index] + + (y /drm_format_info_block_width (format, plane_index)) * fb->pitches[plane_index] + + (x /drm_format_info_block_height (format, plane_index)) * format->char_per_block[plane_index]; }/**
@@ -36,30 +46,29 @@ static size_t pixel_offset(const struct vkms_frame_info *frame_info, int x, int* @frame_info: Buffer metadata * @x: The x(width) coordinate inside the plane * @y: The y(height) coordinate inside the plane +* @plane_index: The index of the plane * -* Takes the information stored in the frame_info, a pair of coordinates, and -* returns the address of the first color channel. -* This function assumes the channels are packed together, i.e. a color channel -* comes immediately after another in the memory. And therefore, this function -* doesn't work for YUV with chroma subsampling (e.g. YUV420 and NV21). +* Takes the information stored in the frame_info, a pair of coordinates, and returns the address +* of the block containing this pixel. * -* The caller must ensure that the framebuffer associated with this request uses a pixel format -* where block_h == block_w == 1, otherwise the returned pointer can be outside the buffer. +* The returned pointer points to the block containing the pixel at coordinates x/y. +* The caller must use this pointer with care, as for formats with block_h != 1 or block_w != 1 +* the requested pixel may have to be extracted from the block, even if they are +* individually addressable. */ static void *packed_pixels_addr (const struct vkms_frame_info *frame_info, -int x,int y) +int x,int y,size_t plane_index) { -size_t offset =pixel_offset (frame_info, x, y); - -return (u8 *)frame_info->map[0 ].vaddr + offset; +return (u8 *)frame_info->map[0 ].vaddr +packed_pixels_offset (frame_info, x, y, plane_index); } -static void *get_packed_src_addr (const struct vkms_frame_info *frame_info,int y) +static void *get_packed_src_addr (const struct vkms_frame_info *frame_info,int y, +size_t plane_index) {int x_src = frame_info->src.x1 >>16 ;int y_src = y - frame_info->rotated.y1 + (frame_info->src.y1 >>16 ); -return packed_pixels_addr (frame_info, x_src, y_src); +return packed_pixels_addr (frame_info, x_src, y_src, plane_index); }static int get_x_position (const struct vkms_frame_info *frame_info,int limit,int x)
@@ -168,14 +177,14 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state {struct pixel_argb_u16 *out_pixels = stage_buffer->pixels;struct vkms_frame_info *frame_info = plane->frame_info; -u8 *src_pixels =get_packed_src_addr (frame_info, y); +u8 *src_pixels =get_packed_src_addr (frame_info, y,0 );int limit =min_t (size_t,drm_rect_width (&frame_info->dst), stage_buffer->n_pixels);for (size_t x =0 ; x < limit; x++, src_pixels += frame_info->fb->format->cpp[0 ]) {int x_pos =get_x_position (frame_info, limit, x);if (drm_rotation_90_or_270 (frame_info->rotation)) - src_pixels =get_packed_src_addr (frame_info, x + frame_info->rotated.y1) + src_pixels =get_packed_src_addr (frame_info, x + frame_info->rotated.y1,0 ) + frame_info->fb->format->cpp[0 ] * y; plane->pixel_read (src_pixels, &out_pixels[x_pos]);
@@ -275,7 +284,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, {struct vkms_frame_info *frame_info = &wb->wb_frame_info;int x_dst = frame_info->dst.x1; -u8 *dst_pixels =packed_pixels_addr (frame_info, x_dst, y); +u8 *dst_pixels =packed_pixels_addr (frame_info, x_dst, y,0 );struct pixel_argb_u16 *in_pixels = src_buffer->pixels;int x_limit =min_t (size_t,drm_rect_width (&frame_info->dst), src_buffer->n_pixels);
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 8/14 drm/vkms: Avoid computing blending limits inside pre_mul_alpha_blend
In reply to Louis ChauvetThe pre_mul_alpha_blend is dedicated to blending, so to avoid mixing different concepts (coordinate calculation and color management), extract the x_limit and x_dst computation outside of this helper.
It also increases the maintainability by grouping the computation related to coordinates in the same place: the loop in blend.
--- drivers/gpu/drm/vkms/vkms_composer.c | 43 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 21 deletions(-)
drivers/gpu/drm/vkms/vkms_composer.c +22 -21
@@ -24,34 +24,33 @@ static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha)/** * pre_mul_alpha_blend - alpha blending equation -* @frame_info: Source framebuffer's metadata * @stage_buffer: The line with the pixels from src_plane * @output_buffer: A line buffer that receives all the blends output +* @x_start: The start offset to avoid useless copy +* @count: The number of byte to copy * -* Using the information from the `frame_info`, this blends only the -* necessary pixels from the `stage_buffer` to the `output_buffer` -* using premultiplied blend formula. +* Using @x_start and @count information, only few pixel can be blended instead of the whole line +* each time. * * The current DRM assumption is that pixel color values have been already * pre-multiplied with the alpha channel values. See more * drm_plane_create_blend_mode_property(). Also, this formula assumes a * completely opaque background. */ -static void pre_mul_alpha_blend (struct vkms_frame_info *frame_info, -struct line_buffer *stage_buffer, -struct line_buffer *output_buffer) +static void pre_mul_alpha_blend ( +const struct line_buffer *stage_buffer, +struct line_buffer *output_buffer, +int x_start, +int pixel_count) { -int x_dst = frame_info->dst.x1; -struct pixel_argb_u16 *out = output_buffer->pixels + x_dst; -struct pixel_argb_u16 *in = stage_buffer->pixels; -int x_limit =min_t (size_t,drm_rect_width (&frame_info->dst), - stage_buffer->n_pixels); - -for (int x =0 ; x < x_limit; x++) { - out[x].a = (u16 )0xffff ; - out[x].r =pre_mul_blend_channel (in[x].r, out[x].r, in[x].a); - out[x].g =pre_mul_blend_channel (in[x].g, out[x].g, in[x].a); - out[x].b =pre_mul_blend_channel (in[x].b, out[x].b, in[x].a); +struct pixel_argb_u16 *out = &output_buffer->pixels[x_start]; +const struct pixel_argb_u16 *in = &stage_buffer->pixels[x_start]; + +for (int i =0 ; i < pixel_count; i++) { + out[i].a = (u16 )0xffff ; + out[i].r =pre_mul_blend_channel (in[i].r, out[i].r, in[i].a); + out[i].g =pre_mul_blend_channel (in[i].g, out[i].g, in[i].a); + out[i].b =pre_mul_blend_channel (in[i].b, out[i].b, in[i].a); } }
@@ -183,7 +182,7 @@ static void blend(struct vkms_writeback_job *wb, {struct vkms_plane_state **plane = crtc_state->active_planes;u32 n_active_planes = crtc_state->num_active_planes; -int y_pos; +int y_pos, x_dst, x_limit;const struct pixel_argb_u16 background_color = { .a =0xffff };
@@ -201,14 +200,16 @@ static void blend(struct vkms_writeback_job *wb,/* The active planes are composed associatively in z-order. */ for (size_t i =0 ; i < n_active_planes; i++) { + x_dst = plane[i]->frame_info->dst.x1; + x_limit =min_t (size_t,drm_rect_width (&plane[i]->frame_info->dst), + stage_buffer->n_pixels); y_pos =get_y_pos (plane[i]->frame_info, y);if (!check_limit (plane[i]->frame_info, y_pos))continue ;vkms_compose_row (stage_buffer, plane[i], y_pos); -pre_mul_alpha_blend (plane[i]->frame_info, stage_buffer, - output_buffer); +pre_mul_alpha_blend (stage_buffer, output_buffer, x_dst, x_limit); }apply_lut (crtc_state, output_buffer);
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 9/14 drm/vkms: Introduce pixel_read_direction enum
In reply to Louis ChauvetThe pixel_read_direction enum is useful to describe the reading direction in a plane. It avoids using the rotation property of DRM, which not practical to know the direction of reading.
This patch also introduce two helpers, one to compute the pixel_read_direction from the DRM rotation property, and one to compute the step, in byte, between two successive pixel in a specific direction.
--- drivers/gpu/drm/vkms/vkms_composer.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_drv.h | 11 +++++++++++ drivers/gpu/drm/vkms/vkms_formats.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+)
drivers/gpu/drm/vkms/vkms_composer.c +36 -0
@@ -162,6 +162,42 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } +/** +* direction_for_rotation() - Get the correct reading direction for a given rotation +* +* This function will use the @rotation setting of a source plane to compute the reading +* direction in this plane which correspond to a "left to right writing" in the CRTC. +* For example, if the buffer is reflected on X axis, the pixel must be read from right to left +* to be written from left to right on the CRTC. +* +* @rotation: Rotation to analyze. It correspond the field @frame_info.rotation. +*/ +static enum pixel_read_direction direction_for_rotation (unsigned int rotation) +{ +if (rotation &DRM_MODE_ROTATE_0 ) { +if (rotation &DRM_MODE_REFLECT_X ) +return READ_RIGHT_TO_LEFT ; +else +return READ_LEFT_TO_RIGHT ; + }else if (rotation &DRM_MODE_ROTATE_90 ) { +if (rotation &DRM_MODE_REFLECT_Y ) +return READ_BOTTOM_TO_TOP ; +else +return READ_TOP_TO_BOTTOM ; + }else if (rotation &DRM_MODE_ROTATE_180 ) { +if (rotation &DRM_MODE_REFLECT_X ) +return READ_LEFT_TO_RIGHT ; +else +return READ_RIGHT_TO_LEFT ; + }else if (rotation &DRM_MODE_ROTATE_270 ) { +if (rotation &DRM_MODE_REFLECT_Y ) +return READ_TOP_TO_BOTTOM ; +else +return READ_BOTTOM_TO_TOP ; + } +return READ_LEFT_TO_RIGHT ; +} +/** * blend - blend the pixels from all planes and compute crc * @wb: The writeback frame buffer metadata
drivers/gpu/drm/vkms/vkms_drv.h +11 -0
@@ -69,6 +69,17 @@ struct vkms_writeback_job {pixel_write_t pixel_write; }; +/** +* enum pixel_read_direction - Enum used internaly by VKMS to represent a reading direction in a +* plane. +*/ +enum pixel_read_direction { +READ_BOTTOM_TO_TOP , +READ_TOP_TO_BOTTOM , +READ_RIGHT_TO_LEFT , +READ_LEFT_TO_RIGHT +}; +/** * typedef pixel_read_t - These functions are used to read a pixel in the source frame, * convert it to `struct pixel_argb_u16` and write it to @out_pixel.
drivers/gpu/drm/vkms/vkms_formats.c +28 -0
@@ -62,6 +62,34 @@ static void *packed_pixels_addr(const struct vkms_frame_info *frame_info,return (u8 *)frame_info->map[0 ].vaddr +packed_pixels_offset (frame_info, x, y, plane_index); } +/** +* get_step_1x1() - Common helper to compute the correct step value between each pixel to read in a +* certain direction. +* This must be used only with format where blockh == blockw == 1. +* In the case when direction is not a valid pixel_read_direction, the returned step is 0, so you +* must not rely on this result to create a loop variant if the direction can be invalid. +* +* @fb: Framebuffer to iter on +* @direction: Direction of the reading +* @plane_index: Plane to get the step from +*/ +static int get_step_1x1 (struct drm_framebuffer *fb,enum pixel_read_direction direction, +int plane_index) +{ +switch (direction) { +case READ_LEFT_TO_RIGHT : +return fb->format->char_per_block[plane_index]; +case READ_RIGHT_TO_LEFT : +return -fb->format->char_per_block[plane_index]; +case READ_TOP_TO_BOTTOM : +return (int )fb->pitches[plane_index]; +case READ_BOTTOM_TO_TOP : +return -(int )fb->pitches[plane_index]; + } + +return 0 ; +} +static void *get_packed_src_addr (const struct vkms_frame_info *frame_info,int y,size_t plane_index) {
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 10/14 drm/vkms: Re-introduce line-per-line composition algorithm
In reply to Louis ChauvetRe-introduce a line-by-line composition algorithm for each pixel format. This allows more performance by not requiring an indirection per pixel read. This patch is focused on readability of the code.
Line-by-line composition was introduced by [1] but rewritten back to pixel-by-pixel algorithm in [2]. At this time, nobody noticed the impact on performance, and it was merged.
This patch is almost a revert of [2], but in addition efforts have been made to increase readability and maintainability of the rotation handling. The blend function is now divided in two parts:
- Transformation of coordinates from the output referential to the source referential
- Line conversion and blending
Most of the complexity of the rotation management is avoided by using drm_rect_* helpers. The remaining complexity is around the clipping, to avoid reading/writing outside source/destination buffers.
The pixel conversion is now done line-by-line, so the read_pixel_t was replaced with read_pixel_line_t callback. This way the indirection is only required once per line and per plane, instead of once per pixel and per plane.
The read_line_t callbacks are very similar for most pixel format, but it is required to avoid performance impact. Some helpers were created to avoid code repetition:
- get_step_1x1: get the step in byte to reach next pixel block in a certain direction
- *_to_argb_u16: helpers to perform colors conversion. They should be inlined by the compiler, and they are used to avoid repetition between multiple variants of the same format (argb/xrgb and maybe in the future for formats like bgr formats).
This new algorithm was tested with:
- kms_plane (for color conversions)
- kms_rotation_crc (for rotations of planes)
- kms_cursor_crc (for translations of planes)
The performance gain was mesured with:
- kms_fb_stress
[1]: commit 8ba1648567e2 ("drm: vkms: Refactor the plane composer to accept
new formats")
https://lore.kernel.org/all/[email protected]/
[2]: commit 322d716a3e8a ("drm/vkms: isolate pixel conversion
functionality")
https://lore.kernel.org/all/[email protected]/--- drivers/gpu/drm/vkms/vkms_composer.c | 169 ++++++++++++++++++++------- drivers/gpu/drm/vkms/vkms_drv.h | 27 +++-- drivers/gpu/drm/vkms/vkms_formats.c | 218 +++++++++++++++++++++-------------- drivers/gpu/drm/vkms/vkms_formats.h | 2 +- drivers/gpu/drm/vkms/vkms_plane.c | 5 +- 5 files changed, 280 insertions(+), 141 deletions(-)
drivers/gpu/drm/vkms/vkms_composer.c +129 -40
@@ -54,33 +54,6 @@ static void pre_mul_alpha_blend( } } -static int get_y_pos (struct vkms_frame_info *frame_info,int y) -{ -if (frame_info->rotation &DRM_MODE_REFLECT_Y ) -return drm_rect_height (&frame_info->rotated) - y -1 ; - -switch (frame_info->rotation &DRM_MODE_ROTATE_MASK ) { -case DRM_MODE_ROTATE_90 : -return frame_info->rotated.x2 - y -1 ; -case DRM_MODE_ROTATE_270 : -return y + frame_info->rotated.x1; -default : -return y; - } -} - -static bool check_limit (struct vkms_frame_info *frame_info,int pos) -{ -if (drm_rotation_90_or_270 (frame_info->rotation)) { -if (pos >=0 && pos <drm_rect_width (&frame_info->rotated)) -return true; - }else { -if (pos >= frame_info->rotated.y1 && pos < frame_info->rotated.y2) -return true; - } - -return false; -}static void fill_background (const struct pixel_argb_u16 *background_color,struct line_buffer *output_buffer)
@@ -218,34 +191,150 @@ static void blend(struct vkms_writeback_job *wb, {struct vkms_plane_state **plane = crtc_state->active_planes;u32 n_active_planes = crtc_state->num_active_planes; -int y_pos, x_dst, x_limit;const struct pixel_argb_u16 background_color = { .a =0xffff }; -size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay; +int crtc_y_limit = crtc_state->base.crtc->mode.vdisplay; +int crtc_x_limit = crtc_state->base.crtc->mode.hdisplay;/* * The planes are composed line-by-line to avoid heavy memory usage. It is a necessary * complexity to avoid poor blending performance. * -* The function vkms_compose_row is used to read a line, pixel-by-pixel, into the staging -* buffer. +* The function pixel_read_line callback is used to read a line, using an efficient +* algorithm for a specific format, into the staging buffer. */ for (size_t y =0 ; y < crtc_y_limit; y++) {fill_background (&background_color, output_buffer);/* The active planes are composed associatively in z-order. */ for (size_t i =0 ; i < n_active_planes; i++) { - x_dst = plane[i]->frame_info->dst.x1; - x_limit =min_t (size_t,drm_rect_width (&plane[i]->frame_info->dst), - stage_buffer->n_pixels); - y_pos =get_y_pos (plane[i]->frame_info, y); +struct vkms_plane_state *current_plane = plane[i]; -if (!check_limit (plane[i]->frame_info, y_pos)) +/* Avoid rendering useless lines */ +if (y < current_plane->frame_info->dst.y1 || + y >= current_plane->frame_info->dst.y2)continue ; -vkms_compose_row (stage_buffer, plane[i], y_pos); -pre_mul_alpha_blend (stage_buffer, output_buffer, x_dst, x_limit); +/* +* dst_line is the line to copy. The initial coordinates are inside the +* destination framebuffer, and then drm_rect_* helpers are used to +* compute the correct position into the source framebuffer. +*/ +struct drm_rect dst_line =DRM_RECT_INIT ( + current_plane->frame_info->dst.x1, y, +drm_rect_width (¤t_plane->frame_info->dst),1 ); +struct drm_rect tmp_src; + +drm_rect_fp_to_int (&tmp_src, ¤t_plane->frame_info->src); + +/* +* [1]: Clamping src_line to the crtc_x_limit to avoid writing outside of +* the destination buffer +*/ + dst_line.x1 =max_t (int, dst_line.x1,0 ); + dst_line.x2 =min_t (int, dst_line.x2, crtc_x_limit); +/* The destination is completely outside of the crtc. */ +if (dst_line.x2 <= dst_line.x1) +continue ; + +struct drm_rect src_line = dst_line; + +/* +* Transform the coordinate x/y from the crtc to coordinates into +* coordinates for the src buffer. +* +* - Cancel the offset of the dst buffer. +* - Invert the rotation. This assumes that +* dst = drm_rect_rotate(src, rotation) (dst and src have the +* same size, but can be rotated). +* - Apply the offset of the source rectangle to the coordinate. +*/ +drm_rect_translate (&src_line, -current_plane->frame_info->dst.x1, + -current_plane->frame_info->dst.y1); +drm_rect_rotate_inv (&src_line, +drm_rect_width (&tmp_src), +drm_rect_height (&tmp_src), + current_plane->frame_info->rotation); +drm_rect_translate (&src_line, tmp_src.x1, tmp_src.y1); + +/* Get the correct reading direction in the source buffer. */ + +enum pixel_read_direction direction = +direction_for_rotation (current_plane->frame_info->rotation); + +int x_start = src_line.x1; +int y_start = src_line.y1; +int pixel_count; +/* [2]: Compute and clamp the number of pixel to read */ +if (direction ==READ_LEFT_TO_RIGHT || direction ==READ_RIGHT_TO_LEFT ) { +/* +* In horizontal reading, the src_line width is the number of pixel +* to read +*/ + pixel_count =drm_rect_width (&src_line); +if (x_start <0 ) { + pixel_count += x_start; + x_start =0 ; + } +if (x_start + pixel_count > current_plane->frame_info->fb->width) { + pixel_count = + (int )current_plane->frame_info->fb->width - x_start; + } + }else { +/* +* In vertical reading, the src_line height is the number of pixel +* to read +*/ + pixel_count =drm_rect_height (&src_line); +if (y_start <0 ) { + pixel_count += y_start; + y_start =0 ; + } +if (y_start + pixel_count > current_plane->frame_info->fb->height) { + pixel_count = + (int )current_plane->frame_info->fb->width - y_start; + } + } + +if (pixel_count <=0 ) { +/* Nothing to read, so avoid multiple function calls for nothing */ +continue ; + } + +/* +* Modify the starting point to take in account the rotation +* +* src_line is the top-left corner, so when reading READ_RIGHT_TO_LEFT or +* READ_BOTTOM_TO_TOP, it must be changed to the top-right/bottom-left +* corner. +*/ +if (direction ==READ_RIGHT_TO_LEFT ) { +// x_start is now the right point + x_start += pixel_count -1 ; + }else if (direction ==READ_BOTTOM_TO_TOP ) { +// y_start is now the bottom point + y_start += pixel_count -1 ; + } + +/* +* Perform the conversion and the blending +* +* Here we know that the read line (x_start, y_start, pixel_count) is +* inside the source buffer [2] and we don't write outside the stage +* buffer [1] +*/ + current_plane->pixel_read_line ( + current_plane, + x_start, + y_start, + direction, + pixel_count, + &stage_buffer->pixels[current_plane->frame_info->dst.x1]); + +pre_mul_alpha_blend (stage_buffer, output_buffer, + current_plane->frame_info->dst.x1, + pixel_count); }apply_lut (crtc_state, output_buffer);
@@ -253,7 +342,7 @@ static void blend(struct vkms_writeback_job *wb, *crc32 =crc32_le (*crc32, (void *)output_buffer->pixels, row_size);if (wb) -vkms_writeback_row (wb, output_buffer, y_pos); +vkms_writeback_row (wb, output_buffer, y); } }
@@ -264,7 +353,7 @@ static int check_format_funcs(struct vkms_crtc_state *crtc_state,u32 n_active_planes = crtc_state->num_active_planes;for (size_t i =0 ; i < n_active_planes; i++) -if (!planes[i]->pixel_read) +if (!planes[i]->pixel_read_line)return -1 ;if (active_wb && !active_wb->pixel_write)
drivers/gpu/drm/vkms/vkms_drv.h +18 -9
@@ -39,7 +39,6 @@struct vkms_frame_info {struct drm_framebuffer *fb;struct drm_rect src, dst; -struct drm_rect rotated;struct iosys_map map[DRM_FORMAT_MAX_PLANES ];unsigned int rotation; };
@@ -80,26 +79,37 @@ enum pixel_read_direction {READ_LEFT_TO_RIGHT }; +struct vkms_plane_state ; +/** -* typedef pixel_read_t - These functions are used to read a pixel in the source frame, +* typedef pixel_read_line_t - These functions are used to read a pixel line in the source frame, * convert it to `struct pixel_argb_u16` and write it to @out_pixel. * -* @in_pixel: Pointer to the pixel to read -* @out_pixel: Pointer to write the converted pixel +* @plane: Plane used as source for the pixel value +* @x_start: X (width) coordinate of the first pixel to copy. The caller must ensure that x_start +* is positive and smaller than @plane->frame_info->fb->width. +* @y_start: Y (width) coordinate of the first pixel to copy. The caller must ensure that y_start +* is positive and smaller than @plane->frame_info->fb->height. +* @direction: Direction to use for the copy, starting at @x_start/@y_start +* @count: Number of pixels to copy +* @out_pixel: Pointer where to write the pixel values. They will be written from @out_pixel[0] +* to @out_pixel[@count]. The caller must ensure that out_pixel have a length of at least @count. */ -typedef void (*pixel_read_t )(const u8 *in_pixel,struct pixel_argb_u16 *out_pixel); +typedef void (*pixel_read_line_t )(const struct vkms_plane_state *plane,int x_start, +int y_start,enum pixel_read_direction direction,int count, +struct pixel_argb_u16 out_pixel[]);/** * vkms_plane_state - Driver specific plane state * @base: base plane state * @frame_info: data required for composing computation -* @pixel_read: function to read a pixel in this plane. The creator of a vkms_plane_state must -* ensure that this pointer is valid +* @pixel_read_line: function to read a pixel line in this plane. The creator of a vkms_plane_state +* must ensure that this pointer is valid */ struct vkms_plane_state {struct drm_shadow_plane_state base;struct vkms_frame_info *frame_info; -pixel_read_t pixel_read; +pixel_read_line_t pixel_read_line; };struct vkms_plane {
@@ -204,7 +214,6 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,/* Composer Support */ void vkms_composer_worker (struct work_struct *work);void vkms_set_composer (struct vkms_output *out,bool enabled); -void vkms_compose_row (struct line_buffer *stage_buffer,struct vkms_plane_state *plane,int y);void vkms_writeback_row (struct vkms_writeback_job *wb,const struct line_buffer *src_buffer,int y);/* Writeback */
drivers/gpu/drm/vkms/vkms_formats.c +131 -87
284 lines not on this page · raw message
drivers/gpu/drm/vkms/vkms_formats.h +1 -1
@@ -5,7 +5,7 @@#include "vkms_drv.h" -pixel_read_t get_pixel_read_function (u32 format); +pixel_read_line_t get_pixel_read_line_function (u32 format);pixel_write_t get_pixel_write_function (u32 format);
drivers/gpu/drm/vkms/vkms_plane.c +1 -4
@@ -112,7 +112,6 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, frame_info = vkms_plane_state->frame_info;memcpy (&frame_info->src, &new_state->src,sizeof (struct drm_rect ));memcpy (&frame_info->dst, &new_state->dst,sizeof (struct drm_rect )); -memcpy (&frame_info->rotated, &new_state->dst,sizeof (struct drm_rect )); frame_info->fb = fb;memcpy (&frame_info->map, &shadow_plane_state->data,sizeof (frame_info->map));drm_framebuffer_get (frame_info->fb);
@@ -122,10 +121,8 @@ static void vkms_plane_atomic_update(struct drm_plane *plane,DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y); -drm_rect_rotate (&frame_info->rotated,drm_rect_width (&frame_info->rotated), -drm_rect_height (&frame_info->rotated), frame_info->rotation); - vkms_plane_state->pixel_read =get_pixel_read_function (fmt); + vkms_plane_state->pixel_read_line =get_pixel_read_line_function (fmt); } static int vkms_plane_atomic_check(struct drm_plane *plane,
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 11/14 drm/vkms: Add YUV support
In reply to Louis ChauvetFrom: Arthur Grillo <[email protected]>
Add support to the YUV formats bellow:
- NV12/NV16/NV24
- NV21/NV61/NV42
- YUV420/YUV422/YUV444
- YVU420/YVU422/YVU444
The conversion from yuv to rgb is done with fixed-point arithmetic, using 32.32 floats.
To do the conversion, a specific matrix must be used for each color range (DRM_COLOR_*_RANGE) and encoding (DRM_COLOR_*). This matrix is stored in the conversion_matrix struct, along with the specific y_offset needed. This matrix is queried only once, in vkms_plane_atomic_update and stored in a vkms_plane_state. Those conversion matrices of each encoding and range were obtained by rounding the values of the original conversion matrices multiplied by 2^32. This is done to avoid the use of fixed point operations.
The same reading function is used for YUV and YVU formats. As the only difference between those two category of formats is the order of field, a simple swap in conversion matrix columns allows using the same function.
[Louis Chauvet:
- Adapted Arthur's work
- Implemented the read_line_t callbacks for yuv
- add struct conversion_matrix
- remove struct pixel_yuv_u8
- update the commit message]
--- drivers/gpu/drm/vkms/vkms_drv.h | 23 +++ drivers/gpu/drm/vkms/vkms_formats.c | 374 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_formats.h | 4 + drivers/gpu/drm/vkms/vkms_plane.c | 16 +- 4 files changed, 416 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/vkms_drv.h +23 -0
@@ -99,6 +99,28 @@ typedef void (*pixel_read_line_t)(const struct vkms_plane_state *plane, int x_st int y_start, enum pixel_read_direction direction, int count, struct pixel_argb_u16 out_pixel[]); + +/** +* CONVERSION_MATRIX_FLOAT_DEPTH - Number of digits after the point for conversion matrix values +*/ +#define CONVERSION_MATRIX_FLOAT_DEPTH 32 + +/** +* struct conversion_matrix - Matrix to use for a specific encoding and range +* +* @matrix: Conversion matrix from yuv to rgb. The matrix is stored in a row-major manner and is +* used to compute rgb values from yuv values: +* [[r],[g],[b]] = @matrix * [[y],[u],[v]] +* OR for yvu formats: +* [[r],[g],[b]] = @matrix * [[y],[v],[u]] +* The values of the matrix are fixed floats, 32.CONVERSION_MATRIX_FLOAT_DEPTH +* @y_offest: Offset to apply on the y value. +*/ +struct conversion_matrix { +s64 matrix[3 ][3 ]; +s64 y_offset; +}; +/** * vkms_plane_state - Driver specific plane state * @base: base plane state
@@ -110,6 +132,7 @@ struct vkms_plane_state {struct drm_shadow_plane_state base;struct vkms_frame_info *frame_info;pixel_read_line_t pixel_read_line; +struct conversion_matrix *conversion_matrix; };struct vkms_plane {
drivers/gpu/drm/vkms/vkms_formats.c +374 -0
404 lines not on this page · raw message
drivers/gpu/drm/vkms/vkms_formats.h +4 -0
@@ -9,4 +9,8 @@ pixel_read_line_t get_pixel_read_line_function(u32 format);pixel_write_t get_pixel_write_function (u32 format); +struct conversion_matrix * +get_conversion_matrix_to_argb_u16 (u32 format,enum drm_color_encoding encoding, +enum drm_color_range range); +#endif /* _VKMS_FORMATS_H_ */
drivers/gpu/drm/vkms/vkms_plane.c +15 -1
@@ -17,7 +17,19 @@ static const u32 vkms_formats[] = {DRM_FORMAT_XRGB8888 ,DRM_FORMAT_XRGB16161616 ,DRM_FORMAT_ARGB16161616 , -DRM_FORMAT_RGB565 +DRM_FORMAT_RGB565 , +DRM_FORMAT_NV12 , +DRM_FORMAT_NV16 , +DRM_FORMAT_NV24 , +DRM_FORMAT_NV21 , +DRM_FORMAT_NV61 , +DRM_FORMAT_NV42 , +DRM_FORMAT_YUV420 , +DRM_FORMAT_YUV422 , +DRM_FORMAT_YUV444 , +DRM_FORMAT_YVU420 , +DRM_FORMAT_YVU422 , +DRM_FORMAT_YVU444 }; static struct drm_plane_state *
@@ -123,6 +135,8 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, vkms_plane_state->pixel_read_line =get_pixel_read_line_function (fmt); + vkms_plane_state->conversion_matrix =get_conversion_matrix_to_argb_u16 + (fmt, new_state->color_encoding, new_state->color_range); } static int vkms_plane_atomic_check(struct drm_plane *plane,
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 12/14 drm/vkms: Add range and encoding properties to the plane
In reply to Louis ChauvetFrom: Arthur Grillo <[email protected]>
Now that the driver internally handles these quantization ranges and YUV encoding matrices, expose the UAPI for setting them.
--- drivers/gpu/drm/vkms/vkms_plane.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/vkms/vkms_plane.c +9 -0
@@ -223,5 +223,14 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,drm_plane_create_rotation_property (&plane->base,DRM_MODE_ROTATE_0 ,DRM_MODE_ROTATE_MASK |DRM_MODE_REFLECT_MASK ); +drm_plane_create_color_properties (&plane->base, +BIT (DRM_COLOR_YCBCR_BT601 ) | +BIT (DRM_COLOR_YCBCR_BT709 ) | +BIT (DRM_COLOR_YCBCR_BT2020 ), +BIT (DRM_COLOR_YCBCR_LIMITED_RANGE ) | +BIT (DRM_COLOR_YCBCR_FULL_RANGE ), +DRM_COLOR_YCBCR_BT601 , +DRM_COLOR_YCBCR_FULL_RANGE ); +return plane; }
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 13/14 drm/vkms: Drop YUV formats TODO
In reply to Louis ChauvetFrom: Arthur Grillo <[email protected]>
VKMS has support for YUV formats now. Remove the task from the TODO list.
--- Documentation/gpu/vkms.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Documentation/gpu/vkms.rst +1 -2
@@ -122,8 +122,7 @@ There's lots of plane features we could add support for: - Scaling. -- Additional buffer formats, especially YUV formats for video like NV12. - Low/high bpp RGB formats would also be interesting. +- Additional buffer formats. Low/high bpp RGB formats would be interesting. - Async updates (currently only possible on cursor plane using the legacy cursor api).
Signature · 1 line
2.43.0
Louis Chauvet
maintainerPATCH v4 14/14 drm/vkms: Create KUnit tests for YUV conversions
In reply to Louis ChauvetFrom: Arthur Grillo <[email protected]>
Create KUnit tests to test the conversion between YUV and RGB. Test each conversion and range combination with some common colors.
--- drivers/gpu/drm/vkms/Kconfig | 15 +++ drivers/gpu/drm/vkms/Makefile | 1 + drivers/gpu/drm/vkms/tests/.kunitconfig | 4 + drivers/gpu/drm/vkms/tests/Makefile | 3 + drivers/gpu/drm/vkms/tests/vkms_format_test.c | 158 ++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_formats.c | 5 +- drivers/gpu/drm/vkms/vkms_formats.h | 4 + 7 files changed, 189 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/Kconfig +15 -0
@@ -13,3 +13,18 @@ config DRM_VKMS a VKMS. If M is selected the module will be called vkms. + +config DRM_VKMS_KUNIT_TESTS + tristate "Tests for VKMS" if !KUNIT_ALL_TESTS + depends on DRM_VKMS && KUNIT + default KUNIT_ALL_TESTS + help + This builds unit tests for VKMS. This option is not useful for + distributions or general kernels, but only for kernel + developers working on VKMS. + + For more information on KUnit and unit tests in general, + please refer to the KUnit documentation in + Documentation/dev-tools/kunit/. + + If in doubt, say "N".
drivers/gpu/drm/vkms/Makefile +1 -0
@@ -9,3 +9,4 @@ vkms-y := \ vkms_writeback.o obj-$(CONFIG_DRM_VKMS) += vkms.o +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += tests/
drivers/gpu/drm/vkms/tests/.kunitconfig new file +4 -0
@@ -0,0 +1,4 @@ +CONFIG_KUNIT=y +CONFIG_DRM=y +CONFIG_DRM_VKMS=y +CONFIG_DRM_VKMS_KUNIT_TESTS=y
drivers/gpu/drm/vkms/tests/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += vkms_format_test.o
drivers/gpu/drm/vkms/tests/vkms_format_test.c new file +158 -0
158 lines not on this page · raw message
drivers/gpu/drm/vkms/vkms_formats.c +4 -1
@@ -7,6 +7,8 @@#include <drm/drm_rect.h> #include <drm/drm_fixed.h> +#include <kunit/visibility.h> +#include "vkms_formats.h" /**
@@ -185,7 +187,7 @@ static struct pixel_argb_u16 argb_u16_from_RGB565(const u16 *pixel)return out_pixel; } -static struct pixel_argb_u16 argb_u16_from_yuv888 (u8 y,u8 cb,u8 cr, +VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 cb, u8 cr,struct conversion_matrix *matrix) {u8 r, g, b;
@@ -218,6 +220,7 @@ static struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 cb, u8 cr,return argb_u16_from_u8888 (255 , r, g, b); } +EXPORT_SYMBOL_IF_KUNIT (argb_u16_from_yuv888);/* * The following functions are read_line function for each pixel format supported by VKMS.
drivers/gpu/drm/vkms/vkms_formats.h +4 -0
@@ -13,4 +13,8 @@ struct conversion_matrix * get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encoding, enum drm_color_range range); +#if IS_ENABLED (CONFIG_KUNIT ) +struct pixel_argb_u16 argb_u16_from_yuv888 (u8 y,u8 cb,u8 cr,struct conversion_matrix *matrix); +#endif +#endif /* _VKMS_FORMATS_H_ */
Signature · 1 line
2.43.0