drm/vkms: add module parameter to set background color
PATCH 1/1 drm/vkms: add module parameter to set background color
After commit 8ba1648567e2 ("drm: vkms: Refactor the plane composer to accept new formats") the composition is no longer performed on top of the primary plane, but instead on top of the CRTC, which means that now we have a background.
This opens to the possibility of coloring the background with a personalized color. Therefore, create a module parameter that takes a unsigned long number as an XRGB16161616 color and set the background color to it. That said, the composition will be performed on top of this background color. By default, the background color is black.
---
This patch intends to add a background color property to vkms through a module parameter. Another option would be to implement this property by adding a new KMS property that would indicate the background color. It would be nice to hear other opinions on what would be the best approach.
Moreover, I wrote some IGT tests to ensure that the functionality is working correctly [1]. The tests take the CRC of a colored primary plane, offset the primary plane out of the screen, and take the CRC of the colored background. The two CRC must be equal.
[1] https://gitlab.freedesktop.org/mairacanal/igt-gpu-tools/-/tree/vkms/background-color
Best Regards,
- Maíra Canal
--- Documentation/gpu/vkms.rst | 2 -- drivers/gpu/drm/vkms/vkms_composer.c | 20 ++++++++++++++------ drivers/gpu/drm/vkms/vkms_drv.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_drv.h | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-)
Documentation/gpu/vkms.rst +0 -2
@@ -121,8 +121,6 @@ There's lots of plane features we could add support for: - ARGB format on primary plane: blend the primary plane into background with translucent alpha. -- Add background color KMS property[Good to get started]. - - Full alpha blending on all planes. - Rotation, scaling.
drivers/gpu/drm/vkms/vkms_composer.c +14 -6
@@ -79,7 +79,8 @@ static void fill_background(const struct pixel_argb_u16 *background_color,* from all planes, calculates the crc32 of the output from the former step, * and, if necessary, convert and store the output to the writeback buffer. */ -static void blend (struct vkms_writeback_job *wb, +static void blend (struct vkms_device *vkms_dev, +struct vkms_writeback_job *wb,struct vkms_crtc_state *crtc_state,u32 *crc32,struct line_buffer *stage_buffer,struct line_buffer *output_buffer,size_t row_size)
@@ -87,7 +88,12 @@ 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; -const struct pixel_argb_u16 background_color = { .a =0xffff }; +const struct pixel_argb_u16 background_color = { + .a =0xffff , + .r = (*vkms_dev->config->background_color >>32 ) &0xffff , + .g = (*vkms_dev->config->background_color >>16 ) &0xffff , + .b = *vkms_dev->config->background_color &0xffff , + };size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;
@@ -139,7 +145,8 @@ static int check_iosys_map(struct vkms_crtc_state *crtc_state)return 0 ; } -static int compose_active_planes (struct vkms_writeback_job *active_wb, +static int compose_active_planes (struct vkms_device *vkms_dev, +struct vkms_writeback_job *active_wb,struct vkms_crtc_state *crtc_state,u32 *crc32) {
@@ -178,7 +185,7 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb, goto free_stage_buffer; } -blend (active_wb, crtc_state, crc32, &stage_buffer, +blend (vkms_dev, active_wb, crtc_state, crc32, &stage_buffer, &output_buffer, line_width * pixel_size);kvfree (output_buffer.pixels);
@@ -205,6 +212,7 @@ void vkms_composer_worker(struct work_struct *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); +struct vkms_device *vkms_dev =vkms_output_to_vkms_device (out);bool crc_pending, wb_pending;u64 frame_start, frame_end;u32 crc32 =0 ;
@@ -228,9 +236,9 @@ void vkms_composer_worker(struct work_struct *work)return ;if (wb_pending) - ret =compose_active_planes (active_wb, crtc_state, &crc32); + ret =compose_active_planes (vkms_dev, active_wb, crtc_state, &crc32);else - ret =compose_active_planes (NULL , crtc_state, &crc32); + ret =compose_active_planes (vkms_dev,NULL , crtc_state, &crc32);if (ret)return ;
drivers/gpu/drm/vkms/vkms_drv.c +6 -0
@@ -51,6 +51,10 @@ static bool enable_overlay;module_param_named (enable_overlay, enable_overlay, bool,0444 );MODULE_PARM_DESC (enable_overlay,"Enable/Disable overlay support" ); +static unsigned long background_color =0x000000000000 ; +module_param_named (background_color, background_color, ulong,0644 ); +MODULE_PARM_DESC (background_color,"Background color (0xRRRRGGGGBBBB)" ); +DEFINE_DRM_GEM_FOPS (vkms_driver_fops);static void vkms_release (struct drm_device *dev)
@@ -99,6 +103,7 @@ static int vkms_config_show(struct seq_file *m, void *data)seq_printf (m,"writeback=%d\n" , vkmsdev->config->writeback);seq_printf (m,"cursor=%d\n" , vkmsdev->config->cursor);seq_printf (m,"overlay=%d\n" , vkmsdev->config->overlay); +seq_printf (m,"background_color=0x%lx\n" , *vkmsdev->config->background_color);return 0 ; }
@@ -226,6 +231,7 @@ static int __init vkms_init(void) config->cursor = enable_cursor; config->writeback = enable_writeback; config->overlay = enable_overlay; + config->background_color = &background_color; ret =vkms_create (config);if (ret)
drivers/gpu/drm/vkms/vkms_drv.h +4 -0
@@ -113,6 +113,7 @@ struct vkms_config {bool writeback;bool cursor;bool overlay; +unsigned long *background_color;/* only set when instantiated */ struct vkms_device *dev; };
@@ -127,6 +128,9 @@ struct vkms_device {#define drm_crtc_to_vkms_output (target) \ container_of(target, struct vkms_output, crtc) +#define vkms_output_to_vkms_device (target) \ + container_of(target, struct vkms_device, output) +#define drm_device_to_vkms_device (target) \ container_of(target, struct vkms_device, drm)
Signature · 1 line
2.39.2
Quoted 12 lines · Maíra Canal
After commit
8ba1648567e2("drm: vkms: Refactor the plane composer to accept new formats") the composition is no longer performed on top of the primary plane, but instead on top of the CRTC, which means that now we have a background.This opens to the possibility of coloring the background with a personalized color. Therefore, create a module parameter that takes a unsigned long number as an XRGB16161616 color and set the background color to it. That said, the composition will be performed on top of this background color. By default, the background color is black.
Quoted 8 lines
Signed-off-by Maíra Canal <[email protected]>---
This patch intends to add a background color property to vkms through a module parameter. Another option would be to implement this property by adding a new KMS property that would indicate the background color. It would be nice to hear other opinions on what would be the best approach.
These patches (and I think even igts for them) have been floating around for years. The hang-up is the userspace. Turns out all compositors want for background is black, thus far no one has figured out a real use-case for anything else.
Maybe some time ...
Quoted 6 lines
Moreover, I wrote some IGT tests to ensure that the functionality is working correctly [1]. The tests take the CRC of a colored primary plane, offset the primary plane out of the screen, and take the CRC of the colored background. The two CRC must be equal.
[1] https://gitlab.freedesktop.org/mairacanal/igt-gpu-tools/-/tree/vkms/background-color
I wonder whether it would be more useful to have this as a Kunit validation test to very that the vkms composing code works correctly? Still with the modparam and vkms_config to handle it all cleanly. -Daniel
Quoted 147 lines
Best Regards,
- Maíra Canal--- Documentation/gpu/vkms.rst | 2 -- drivers/gpu/drm/vkms/vkms_composer.c | 20 ++++++++++++++------ drivers/gpu/drm/vkms/vkms_drv.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_drv.h | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-)Documentation/gpu/vkms.rst +0
-2@@ -121,8 +121,6 @@ There's lots of plane features we could add support for: - ARGB format on primary plane: blend the primary plane into background with translucent alpha. -- Add background color KMS property[Good to get started]. - - Full alpha blending on all planes. - Rotation, scaling.drivers/gpu/drm/vkms/vkms_composer.c +14
-6@@ -79,7 +79,8 @@ static void fill_background(const struct pixel_argb_u16 *background_color,* from all planes, calculates the crc32 of the output from the former step, * and, if necessary, convert and store the output to the writeback buffer. */ -static void blend (struct vkms_writeback_job *wb, +static void blend (struct vkms_device *vkms_dev, +struct vkms_writeback_job *wb,struct vkms_crtc_state *crtc_state,u32 *crc32,struct line_buffer *stage_buffer,struct line_buffer *output_buffer,size_t row_size)@@ -87,7 +88,12 @@ 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; -const struct pixel_argb_u16 background_color = { .a =0xffff }; +const struct pixel_argb_u16 background_color = { + .a =0xffff , + .r = (*vkms_dev->config->background_color >>32 ) &0xffff , + .g = (*vkms_dev->config->background_color >>16 ) &0xffff , + .b = *vkms_dev->config->background_color &0xffff , + };size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;@@ -139,7 +145,8 @@ static int check_iosys_map(struct vkms_crtc_state *crtc_state)return 0 ; } -static int compose_active_planes (struct vkms_writeback_job *active_wb, +static int compose_active_planes (struct vkms_device *vkms_dev, +struct vkms_writeback_job *active_wb,struct vkms_crtc_state *crtc_state,u32 *crc32) {@@ -178,7 +185,7 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb, goto free_stage_buffer; } -blend (active_wb, crtc_state, crc32, &stage_buffer, +blend (vkms_dev, active_wb, crtc_state, crc32, &stage_buffer, &output_buffer, line_width * pixel_size);kvfree (output_buffer.pixels);@@ -205,6 +212,7 @@ void vkms_composer_worker(struct work_struct *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); +struct vkms_device *vkms_dev =vkms_output_to_vkms_device (out);bool crc_pending, wb_pending;u64 frame_start, frame_end;u32 crc32 =0 ;@@ -228,9 +236,9 @@ void vkms_composer_worker(struct work_struct *work)return ;if (wb_pending) - ret =compose_active_planes (active_wb, crtc_state, &crc32); + ret =compose_active_planes (vkms_dev, active_wb, crtc_state, &crc32);else - ret =compose_active_planes (NULL , crtc_state, &crc32); + ret =compose_active_planes (vkms_dev,NULL , crtc_state, &crc32);if (ret)return ;drivers/gpu/drm/vkms/vkms_drv.c +6
-0@@ -51,6 +51,10 @@ static bool enable_overlay;module_param_named (enable_overlay, enable_overlay, bool,0444 );MODULE_PARM_DESC (enable_overlay,"Enable/Disable overlay support" ); +static unsigned long background_color =0x000000000000 ; +module_param_named (background_color, background_color, ulong,0644 ); +MODULE_PARM_DESC (background_color,"Background color (0xRRRRGGGGBBBB)" ); +DEFINE_DRM_GEM_FOPS (vkms_driver_fops);static void vkms_release (struct drm_device *dev)@@ -99,6 +103,7 @@ static int vkms_config_show(struct seq_file *m, void *data)seq_printf (m,"writeback=%d\n" , vkmsdev->config->writeback);seq_printf (m,"cursor=%d\n" , vkmsdev->config->cursor);seq_printf (m,"overlay=%d\n" , vkmsdev->config->overlay); +seq_printf (m,"background_color=0x%lx\n" , *vkmsdev->config->background_color);return 0 ; }@@ -226,6 +231,7 @@ static int __init vkms_init(void) config->cursor = enable_cursor; config->writeback = enable_writeback; config->overlay = enable_overlay; + config->background_color = &background_color; ret =vkms_create (config);if (ret)drivers/gpu/drm/vkms/vkms_drv.h +4
-1@@ -113,6 +113,7 @@ struct vkms_config {bool writeback;bool cursor;bool overlay; +unsigned long *background_color;/* only set when instantiated */ struct vkms_device *dev; };@@ -127,6 +128,9 @@ struct vkms_device {#define drm_crtc_to_vkms_output (target) \ container_of(target, struct vkms_output, crtc) +#define vkms_output_to_vkms_device (target) \ + container_of(target, struct vkms_device, output) +#define drm_device_to_vkms_device (target) \ container_of(target, struct vkms_device, drm) --2.39.2
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 22 lines · Daniel Vetter
Quoted 12 lines · Maíra Canal
After commit
8ba1648567e2("drm: vkms: Refactor the plane composer to accept new formats") the composition is no longer performed on top of the primary plane, but instead on top of the CRTC, which means that now we have a background.This opens to the possibility of coloring the background with a personalized color. Therefore, create a module parameter that takes a unsigned long number as an XRGB16161616 color and set the background color to it. That said, the composition will be performed on top of this background color. By default, the background color is black.
Quoted 8 lines
Signed-off-by Maíra Canal <[email protected]>---
This patch intends to add a background color property to vkms through a module parameter. Another option would be to implement this property by adding a new KMS property that would indicate the background color. It would be nice to hear other opinions on what would be the best approach.
Quoted 7 lines
These patches (and I think even igts for them) have been floating around for years. The hang-up is the userspace. Turns out all compositors want for background is black, thus far no one has figured out a real use-case for anything else.
Maybe some time ...
But, would it be okay to add this feature as a vkms' module parameter?
Quoted 10 lines
Quoted 6 lines
Moreover, I wrote some IGT tests to ensure that the functionality is working correctly [1]. The tests take the CRC of a colored primary plane, offset the primary plane out of the screen, and take the CRC of the colored background. The two CRC must be equal.
[1] https://gitlab.freedesktop.org/mairacanal/igt-gpu-tools/-/tree/vkms/background-color
I wonder whether it would be more useful to have this as a Kunit validation test to very that the vkms composing code works correctly? Still with the modparam and
vkms_configto handle it all cleanly.
Not sure if this would fit as a unit test, as the vkms composing code basically outputs a CRC, which can be better verified by the userspace. The output_buffer and stage_buffer are internal variables, so it would be difficult to evaluate them with a KUnit test.
With the IGT test, we can assure that the background composition is being performed properly using the CRC in a negative test and also some positive tests.
Best Regards,
- Maíra Canal
Quoted 151 lines
-Daniel
Quoted 147 lines
Best Regards,
- Maíra Canal--- Documentation/gpu/vkms.rst | 2 -- drivers/gpu/drm/vkms/vkms_composer.c | 20 ++++++++++++++------ drivers/gpu/drm/vkms/vkms_drv.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_drv.h | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-)Documentation/gpu/vkms.rst +0
-2@@ -121,8 +121,6 @@ There's lots of plane features we could add support for: - ARGB format on primary plane: blend the primary plane into background with translucent alpha. -- Add background color KMS property[Good to get started]. - - Full alpha blending on all planes. - Rotation, scaling.drivers/gpu/drm/vkms/vkms_composer.c +14
-6@@ -79,7 +79,8 @@ static void fill_background(const struct pixel_argb_u16 *background_color,* from all planes, calculates the crc32 of the output from the former step, * and, if necessary, convert and store the output to the writeback buffer. */ -static void blend (struct vkms_writeback_job *wb, +static void blend (struct vkms_device *vkms_dev, +struct vkms_writeback_job *wb,struct vkms_crtc_state *crtc_state,u32 *crc32,struct line_buffer *stage_buffer,struct line_buffer *output_buffer,size_t row_size)@@ -87,7 +88,12 @@ 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; -const struct pixel_argb_u16 background_color = { .a =0xffff }; +const struct pixel_argb_u16 background_color = { + .a =0xffff , + .r = (*vkms_dev->config->background_color >>32 ) &0xffff , + .g = (*vkms_dev->config->background_color >>16 ) &0xffff , + .b = *vkms_dev->config->background_color &0xffff , + };size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;@@ -139,7 +145,8 @@ static int check_iosys_map(struct vkms_crtc_state *crtc_state)return 0 ; } -static int compose_active_planes (struct vkms_writeback_job *active_wb, +static int compose_active_planes (struct vkms_device *vkms_dev, +struct vkms_writeback_job *active_wb,struct vkms_crtc_state *crtc_state,u32 *crc32) {@@ -178,7 +185,7 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb, goto free_stage_buffer; } -blend (active_wb, crtc_state, crc32, &stage_buffer, +blend (vkms_dev, active_wb, crtc_state, crc32, &stage_buffer, &output_buffer, line_width * pixel_size);kvfree (output_buffer.pixels);@@ -205,6 +212,7 @@ void vkms_composer_worker(struct work_struct *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); +struct vkms_device *vkms_dev =vkms_output_to_vkms_device (out);bool crc_pending, wb_pending;u64 frame_start, frame_end;u32 crc32 =0 ;@@ -228,9 +236,9 @@ void vkms_composer_worker(struct work_struct *work)return ;if (wb_pending) - ret =compose_active_planes (active_wb, crtc_state, &crc32); + ret =compose_active_planes (vkms_dev, active_wb, crtc_state, &crc32);else - ret =compose_active_planes (NULL , crtc_state, &crc32); + ret =compose_active_planes (vkms_dev,NULL , crtc_state, &crc32);if (ret)return ;drivers/gpu/drm/vkms/vkms_drv.c +6
-0@@ -51,6 +51,10 @@ static bool enable_overlay;module_param_named (enable_overlay, enable_overlay, bool,0444 );MODULE_PARM_DESC (enable_overlay,"Enable/Disable overlay support" ); +static unsigned long background_color =0x000000000000 ; +module_param_named (background_color, background_color, ulong,0644 ); +MODULE_PARM_DESC (background_color,"Background color (0xRRRRGGGGBBBB)" ); +DEFINE_DRM_GEM_FOPS (vkms_driver_fops);static void vkms_release (struct drm_device *dev)@@ -99,6 +103,7 @@ static int vkms_config_show(struct seq_file *m, void *data)seq_printf (m,"writeback=%d\n" , vkmsdev->config->writeback);seq_printf (m,"cursor=%d\n" , vkmsdev->config->cursor);seq_printf (m,"overlay=%d\n" , vkmsdev->config->overlay); +seq_printf (m,"background_color=0x%lx\n" , *vkmsdev->config->background_color);return 0 ; }@@ -226,6 +231,7 @@ static int __init vkms_init(void) config->cursor = enable_cursor; config->writeback = enable_writeback; config->overlay = enable_overlay; + config->background_color = &background_color; ret =vkms_create (config);if (ret)drivers/gpu/drm/vkms/vkms_drv.h +4
-1@@ -113,6 +113,7 @@ struct vkms_config {bool writeback;bool cursor;bool overlay; +unsigned long *background_color;/* only set when instantiated */ struct vkms_device *dev; };@@ -127,6 +128,9 @@ struct vkms_device {#define drm_crtc_to_vkms_output (target) \ container_of(target, struct vkms_output, crtc) +#define vkms_output_to_vkms_device (target) \ + container_of(target, struct vkms_device, output) +#define drm_device_to_vkms_device (target) \ container_of(target, struct vkms_device, drm) --2.39.2
Quoted 28 lines · Maíra Canal
Quoted 27 lines · Daniel Vetter
Quoted 12 lines · Maíra Canal
After commit
8ba1648567e2("drm: vkms: Refactor the plane composer to accept new formats") the composition is no longer performed on top of the primary plane, but instead on top of the CRTC, which means that now we have a background.This opens to the possibility of coloring the background with a personalized color. Therefore, create a module parameter that takes a unsigned long number as an XRGB16161616 color and set the background color to it. That said, the composition will be performed on top of this background color. By default, the background color is black.
Quoted 8 lines
Signed-off-by Maíra Canal <[email protected]>---
This patch intends to add a background color property to vkms through a module parameter. Another option would be to implement this property by adding a new KMS property that would indicate the background color. It would be nice to hear other opinions on what would be the best approach.
These patches (and I think even igts for them) have been floating around for years. The hang-up is the userspace. Turns out all compositors want for background is black, thus far no one has figured out a real use-case for anything else.
Quoted 4 lines
Quoted 2 lines
Maybe some time ...
But, would it be okay to add this feature as a vkms' module parameter?
Yeah I think that's ok.
Quoted 17 lines
Quoted 10 lines
Quoted 6 lines
Moreover, I wrote some IGT tests to ensure that the functionality is working correctly [1]. The tests take the CRC of a colored primary plane, offset the primary plane out of the screen, and take the CRC of the colored background. The two CRC must be equal.
[1] https://gitlab.freedesktop.org/mairacanal/igt-gpu-tools/-/tree/vkms/background-color
I wonder whether it would be more useful to have this as a Kunit validation test to very that the vkms composing code works correctly? Still with the modparam and
vkms_configto handle it all cleanly.Not sure if this would fit as a unit test, as the vkms composing code basically outputs a CRC, which can be better verified by the userspace. The
output_bufferandstage_bufferare internal variables, so it would be difficult to evaluate them with a KUnit test.
Quoted 3 lines
With the IGT test, we can assure that the background composition is being performed properly using the CRC in a negative test and also some positive tests.
I was just thinking of how you could keep the test, because igt is for uapi in general. So doesn't fit all that well, validating internals is more what kunit is supposed to do.
-Daniel
Quoted 155 lines
Best Regards,
- Maíra CanalQuoted 151 lines
-Daniel
Quoted 147 lines
Best Regards,
- Maíra Canal--- Documentation/gpu/vkms.rst | 2 -- drivers/gpu/drm/vkms/vkms_composer.c | 20 ++++++++++++++------ drivers/gpu/drm/vkms/vkms_drv.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_drv.h | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-)Documentation/gpu/vkms.rst +0
-2@@ -121,8 +121,6 @@ There's lots of plane features we could add support for: - ARGB format on primary plane: blend the primary plane into background with translucent alpha. -- Add background color KMS property[Good to get started]. - - Full alpha blending on all planes. - Rotation, scaling.drivers/gpu/drm/vkms/vkms_composer.c +14
-6@@ -79,7 +79,8 @@ static void fill_background(const struct pixel_argb_u16 *background_color,* from all planes, calculates the crc32 of the output from the former step, * and, if necessary, convert and store the output to the writeback buffer. */ -static void blend (struct vkms_writeback_job *wb, +static void blend (struct vkms_device *vkms_dev, +struct vkms_writeback_job *wb,struct vkms_crtc_state *crtc_state,u32 *crc32,struct line_buffer *stage_buffer,struct line_buffer *output_buffer,size_t row_size)@@ -87,7 +88,12 @@ 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; -const struct pixel_argb_u16 background_color = { .a =0xffff }; +const struct pixel_argb_u16 background_color = { + .a =0xffff , + .r = (*vkms_dev->config->background_color >>32 ) &0xffff , + .g = (*vkms_dev->config->background_color >>16 ) &0xffff , + .b = *vkms_dev->config->background_color &0xffff , + };size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;@@ -139,7 +145,8 @@ static int check_iosys_map(struct vkms_crtc_state *crtc_state)return 0 ; } -static int compose_active_planes (struct vkms_writeback_job *active_wb, +static int compose_active_planes (struct vkms_device *vkms_dev, +struct vkms_writeback_job *active_wb,struct vkms_crtc_state *crtc_state,u32 *crc32) {@@ -178,7 +185,7 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb, goto free_stage_buffer; } -blend (active_wb, crtc_state, crc32, &stage_buffer, +blend (vkms_dev, active_wb, crtc_state, crc32, &stage_buffer, &output_buffer, line_width * pixel_size);kvfree (output_buffer.pixels);@@ -205,6 +212,7 @@ void vkms_composer_worker(struct work_struct *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); +struct vkms_device *vkms_dev =vkms_output_to_vkms_device (out);bool crc_pending, wb_pending;u64 frame_start, frame_end;u32 crc32 =0 ;@@ -228,9 +236,9 @@ void vkms_composer_worker(struct work_struct *work)return ;if (wb_pending) - ret =compose_active_planes (active_wb, crtc_state, &crc32); + ret =compose_active_planes (vkms_dev, active_wb, crtc_state, &crc32);else - ret =compose_active_planes (NULL , crtc_state, &crc32); + ret =compose_active_planes (vkms_dev,NULL , crtc_state, &crc32);if (ret)return ;drivers/gpu/drm/vkms/vkms_drv.c +6
-0@@ -51,6 +51,10 @@ static bool enable_overlay;module_param_named (enable_overlay, enable_overlay, bool,0444 );MODULE_PARM_DESC (enable_overlay,"Enable/Disable overlay support" ); +static unsigned long background_color =0x000000000000 ; +module_param_named (background_color, background_color, ulong,0644 ); +MODULE_PARM_DESC (background_color,"Background color (0xRRRRGGGGBBBB)" ); +DEFINE_DRM_GEM_FOPS (vkms_driver_fops);static void vkms_release (struct drm_device *dev)@@ -99,6 +103,7 @@ static int vkms_config_show(struct seq_file *m, void *data)seq_printf (m,"writeback=%d\n" , vkmsdev->config->writeback);seq_printf (m,"cursor=%d\n" , vkmsdev->config->cursor);seq_printf (m,"overlay=%d\n" , vkmsdev->config->overlay); +seq_printf (m,"background_color=0x%lx\n" , *vkmsdev->config->background_color);return 0 ; }@@ -226,6 +231,7 @@ static int __init vkms_init(void) config->cursor = enable_cursor; config->writeback = enable_writeback; config->overlay = enable_overlay; + config->background_color = &background_color; ret =vkms_create (config);if (ret)drivers/gpu/drm/vkms/vkms_drv.h +4
-1@@ -113,6 +113,7 @@ struct vkms_config {bool writeback;bool cursor;bool overlay; +unsigned long *background_color;/* only set when instantiated */ struct vkms_device *dev; };@@ -127,6 +128,9 @@ struct vkms_device {#define drm_crtc_to_vkms_output (target) \ container_of(target, struct vkms_output, crtc) +#define vkms_output_to_vkms_device (target) \ + container_of(target, struct vkms_device, output) +#define drm_device_to_vkms_device (target) \ container_of(target, struct vkms_device, drm) --2.39.2
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 53 lines · Daniel Vetter
Quoted 28 lines · Maíra Canal
Quoted 27 lines · Daniel Vetter
Quoted 12 lines · Maíra Canal
After commit
8ba1648567e2("drm: vkms: Refactor the plane composer to accept new formats") the composition is no longer performed on top of the primary plane, but instead on top of the CRTC, which means that now we have a background.This opens to the possibility of coloring the background with a personalized color. Therefore, create a module parameter that takes a unsigned long number as an XRGB16161616 color and set the background color to it. That said, the composition will be performed on top of this background color. By default, the background color is black.
Quoted 8 lines
Signed-off-by Maíra Canal <[email protected]>---
This patch intends to add a background color property to vkms through a module parameter. Another option would be to implement this property by adding a new KMS property that would indicate the background color. It would be nice to hear other opinions on what would be the best approach.
These patches (and I think even igts for them) have been floating around for years. The hang-up is the userspace. Turns out all compositors want for background is black, thus far no one has figured out a real use-case for anything else.
Quoted 4 lines
Quoted 2 lines
Maybe some time ...
But, would it be okay to add this feature as a vkms' module parameter?
Yeah I think that's ok.
Quoted 17 lines
Quoted 10 lines
Quoted 6 lines
Moreover, I wrote some IGT tests to ensure that the functionality is working correctly [1]. The tests take the CRC of a colored primary plane, offset the primary plane out of the screen, and take the CRC of the colored background. The two CRC must be equal.
[1] https://gitlab.freedesktop.org/mairacanal/igt-gpu-tools/-/tree/vkms/background-color
I wonder whether it would be more useful to have this as a Kunit validation test to very that the vkms composing code works correctly? Still with the modparam and
vkms_configto handle it all cleanly.Not sure if this would fit as a unit test, as the vkms composing code basically outputs a CRC, which can be better verified by the userspace. The
output_bufferandstage_bufferare internal variables, so it would be difficult to evaluate them with a KUnit test.
Quoted 7 lines
Quoted 3 lines
With the IGT test, we can assure that the background composition is being performed properly using the CRC in a negative test and also some positive tests.
I was just thinking of how you could keep the test, because igt is for uapi in general. So doesn't fit all that well, validating internals is more what kunit is supposed to do.
I'm not sure if testing the composition is an internal behavior, because the output of the composition is a CRC that is exposed to the userspace.
Moreover, we need some sort of variable output to create a KUnit test, which is not the case for vkms. The output_buffer and stage_buffer are internal variables and they are overwritten on each iteration of the blend loop.
As this property would be exclusive to vkms, I believe it would be okay to add a vkms-specific IGT test to verify the correct behavior of the background.
Best Regards,
- Maíra Canal
Quoted 158 lines
-Daniel
Quoted 155 lines
Best Regards,
- Maíra CanalQuoted 151 lines
-Daniel
Quoted 147 lines
Best Regards,
- Maíra Canal--- Documentation/gpu/vkms.rst | 2 -- drivers/gpu/drm/vkms/vkms_composer.c | 20 ++++++++++++++------ drivers/gpu/drm/vkms/vkms_drv.c | 6 ++++++ drivers/gpu/drm/vkms/vkms_drv.h | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-)Documentation/gpu/vkms.rst +0
-2@@ -121,8 +121,6 @@ There's lots of plane features we could add support for: - ARGB format on primary plane: blend the primary plane into background with translucent alpha. -- Add background color KMS property[Good to get started]. - - Full alpha blending on all planes. - Rotation, scaling.drivers/gpu/drm/vkms/vkms_composer.c +14
-6@@ -79,7 +79,8 @@ static void fill_background(const struct pixel_argb_u16 *background_color,* from all planes, calculates the crc32 of the output from the former step, * and, if necessary, convert and store the output to the writeback buffer. */ -static void blend (struct vkms_writeback_job *wb, +static void blend (struct vkms_device *vkms_dev, +struct vkms_writeback_job *wb,struct vkms_crtc_state *crtc_state,u32 *crc32,struct line_buffer *stage_buffer,struct line_buffer *output_buffer,size_t row_size)@@ -87,7 +88,12 @@ 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; -const struct pixel_argb_u16 background_color = { .a =0xffff }; +const struct pixel_argb_u16 background_color = { + .a =0xffff , + .r = (*vkms_dev->config->background_color >>32 ) &0xffff , + .g = (*vkms_dev->config->background_color >>16 ) &0xffff , + .b = *vkms_dev->config->background_color &0xffff , + };size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;@@ -139,7 +145,8 @@ static int check_iosys_map(struct vkms_crtc_state *crtc_state)return 0 ; } -static int compose_active_planes (struct vkms_writeback_job *active_wb, +static int compose_active_planes (struct vkms_device *vkms_dev, +struct vkms_writeback_job *active_wb,struct vkms_crtc_state *crtc_state,u32 *crc32) {@@ -178,7 +185,7 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb, goto free_stage_buffer; } -blend (active_wb, crtc_state, crc32, &stage_buffer, +blend (vkms_dev, active_wb, crtc_state, crc32, &stage_buffer, &output_buffer, line_width * pixel_size);kvfree (output_buffer.pixels);@@ -205,6 +212,7 @@ void vkms_composer_worker(struct work_struct *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); +struct vkms_device *vkms_dev =vkms_output_to_vkms_device (out);bool crc_pending, wb_pending;u64 frame_start, frame_end;u32 crc32 =0 ;@@ -228,9 +236,9 @@ void vkms_composer_worker(struct work_struct *work)return ;if (wb_pending) - ret =compose_active_planes (active_wb, crtc_state, &crc32); + ret =compose_active_planes (vkms_dev, active_wb, crtc_state, &crc32);else - ret =compose_active_planes (NULL , crtc_state, &crc32); + ret =compose_active_planes (vkms_dev,NULL , crtc_state, &crc32);if (ret)return ;drivers/gpu/drm/vkms/vkms_drv.c +6
-0@@ -51,6 +51,10 @@ static bool enable_overlay;module_param_named (enable_overlay, enable_overlay, bool,0444 );MODULE_PARM_DESC (enable_overlay,"Enable/Disable overlay support" ); +static unsigned long background_color =0x000000000000 ; +module_param_named (background_color, background_color, ulong,0644 ); +MODULE_PARM_DESC (background_color,"Background color (0xRRRRGGGGBBBB)" ); +DEFINE_DRM_GEM_FOPS (vkms_driver_fops);static void vkms_release (struct drm_device *dev)@@ -99,6 +103,7 @@ static int vkms_config_show(struct seq_file *m, void *data)seq_printf (m,"writeback=%d\n" , vkmsdev->config->writeback);seq_printf (m,"cursor=%d\n" , vkmsdev->config->cursor);seq_printf (m,"overlay=%d\n" , vkmsdev->config->overlay); +seq_printf (m,"background_color=0x%lx\n" , *vkmsdev->config->background_color);return 0 ; }@@ -226,6 +231,7 @@ static int __init vkms_init(void) config->cursor = enable_cursor; config->writeback = enable_writeback; config->overlay = enable_overlay; + config->background_color = &background_color; ret =vkms_create (config);if (ret)drivers/gpu/drm/vkms/vkms_drv.h +4
-1@@ -113,6 +113,7 @@ struct vkms_config {bool writeback;bool cursor;bool overlay; +unsigned long *background_color;/* only set when instantiated */ struct vkms_device *dev; };@@ -127,6 +128,9 @@ struct vkms_device {#define drm_crtc_to_vkms_output (target) \ container_of(target, struct vkms_output, crtc) +#define vkms_output_to_vkms_device (target) \ + container_of(target, struct vkms_device, output) +#define drm_device_to_vkms_device (target) \ container_of(target, struct vkms_device, drm) --2.39.2
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Maíra,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.3-rc5 next-20230406] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ma-ra-Canal/drm-vkms-add-module-parameter-to-set-background-color/20230407-012233 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230406172002.124456-1-mcanal%40igalia.com patch subject: [PATCH] drm/vkms: add module parameter to set background color config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20230407/[email protected]/config) compiler: powerpc-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/d725068207852d3b6a0dd795bf224422804101e1
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Ma-ra-Canal/drm-vkms-add-module-parameter-to-set-background-color/20230407-012233 git checkout d725068207852d3b6a0dd795bf224422804101e1
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/gpu/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/gpu/drm/vkms/vkms_composer.c: In function 'blend':
>> drivers/gpu/drm/vkms/vkms_composer.c:93:59: warning: right shift count >= width of type [-Wshift-count-overflow]
93 | .r = (*vkms_dev->config->background_color >> 32) & 0xffff,
| ^~vim +93 drivers/gpu/drm/vkms/vkms_composer.c
70
71 /**
72 * @wb_frame_info: The writeback frame buffer metadata
73 * @crtc_state: The crtc state
74 * @crc32: The crc output of the final frame
75 * @output_buffer: A buffer of a row that will receive the result of the blend(s)
76 * @stage_buffer: The line with the pixels from plane being blend to the output
77 *
78 * This function blends the pixels (Using the pre_mul_alpha_blend)
79 * from all planes, calculates the crc32 of the output from the former step,
80 * and, if necessary, convert and store the output to the writeback buffer.
81 */
82 static void blend(struct vkms_device *vkms_dev,
83 struct vkms_writeback_job *wb,
84 struct vkms_crtc_state *crtc_state,
85 u32 *crc32, struct line_buffer *stage_buffer,
86 struct line_buffer *output_buffer, size_t row_size)
87 {
88 struct vkms_plane_state **plane = crtc_state->active_planes;
89 u32 n_active_planes = crtc_state->num_active_planes;
90
91 const struct pixel_argb_u16 background_color = {
92 .a = 0xffff,
> 93 .r = (*vkms_dev->config->background_color >> 32) & 0xffff,
94 .g = (*vkms_dev->config->background_color >> 16) & 0xffff,
95 .b = *vkms_dev->config->background_color & 0xffff,
96 };
97
98 size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;
99 100 for (size_t y = 0; y < crtc_y_limit; y++) {
101 fill_background(&background_color, output_buffer);
102
103 /* The active planes are composed associatively in z-order. */
104 for (size_t i = 0; i < n_active_planes; i++) {
105 if (!check_y_limit(plane[i]->frame_info, y))
106 continue;
107
108 plane[i]->plane_read(stage_buffer, plane[i]->frame_info, y);
109 pre_mul_alpha_blend(plane[i]->frame_info, stage_buffer,
110 output_buffer);
111 }
112
113 *crc32 = crc32_le(*crc32, (void *)output_buffer->pixels, row_size);
114
115 if (wb)
116 wb->wb_write(&wb->wb_frame_info, output_buffer, y);
117 }
118 }
119
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Hi Maíra,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ma-ra-Canal/drm-vkms-add-module-parameter-to-set-background-color/20230407-012233 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230406172002.124456-1-mcanal%40igalia.com patch subject: [PATCH] drm/vkms: add module parameter to set background color config: i386-randconfig-m031-20230403 (https://download.01.org/0day-ci/archive/20230408/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Link: https://lore.kernel.org/r/[email protected]/
smatch warnings:drivers/gpu/drm/vkms/vkms_composer.c:93 blend() warn: right shifting more than type allows 32 vs 32
vim +93 drivers/gpu/drm/vkms/vkms_composer.c
d725068207852d drivers/gpu/drm/vkms/vkms_composer.c Maíra Canal 2023-04-06 82 static void blend(struct vkms_device *vkms_dev,
d725068207852d drivers/gpu/drm/vkms/vkms_composer.c Maíra Canal 2023-04-06 83 struct vkms_writeback_job *wb,
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 84 struct vkms_crtc_state *crtc_state,
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 85 u32 *crc32, struct line_buffer *stage_buffer,
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 86 struct line_buffer *output_buffer, size_t row_size)
39cba5cf8c2c23 drivers/gpu/drm/vkms/vkms_composer.c Melissa Wen 2020-08-25 87 {
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 88 struct vkms_plane_state **plane = crtc_state->active_planes;
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 89 u32 n_active_planes = crtc_state->num_active_planes;
39cba5cf8c2c23 drivers/gpu/drm/vkms/vkms_composer.c Melissa Wen 2020-08-25 90
d725068207852d drivers/gpu/drm/vkms/vkms_composer.c Maíra Canal 2023-04-06 91 const struct pixel_argb_u16 background_color = {
d725068207852d drivers/gpu/drm/vkms/vkms_composer.c Maíra Canal 2023-04-06 92 .a = 0xffff,
d725068207852d drivers/gpu/drm/vkms/vkms_composer.c Maíra Canal 2023-04-06 @93 .r = (*vkms_dev->config->background_color >> 32) & 0xffff,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This shift always results in zero.
d725068207852d drivers/gpu/drm/vkms/vkms_composer.c Maíra Canal 2023-04-06 94 .g = (*vkms_dev->config->background_color >> 16) & 0xffff,
d725068207852d drivers/gpu/drm/vkms/vkms_composer.c Maíra Canal 2023-04-06 95 .b = *vkms_dev->config->background_color & 0xffff,
d725068207852d drivers/gpu/drm/vkms/vkms_composer.c Maíra Canal 2023-04-06 96 };
32a1648aca4409 drivers/gpu/drm/vkms/vkms_composer.c Melissa Wen 2021-04-24 97
bc0d7fdefec62e drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 98 size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;
39cba5cf8c2c23 drivers/gpu/drm/vkms/vkms_composer.c Melissa Wen 2020-08-25 99
bc0d7fdefec62e drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 100 for (size_t y = 0; y < crtc_y_limit; y++) {
bc0d7fdefec62e drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 101 fill_background(&background_color, output_buffer);
bc0d7fdefec62e drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 102
bc0d7fdefec62e drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 103 /* The active planes are composed associatively in z-order. */
bc0d7fdefec62e drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 104 for (size_t i = 0; i < n_active_planes; i++) {
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 105 if (!check_y_limit(plane[i]->frame_info, y))
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 106 continue;
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 107
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 108 plane[i]->plane_read(stage_buffer, plane[i]->frame_info, y);
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 109 pre_mul_alpha_blend(plane[i]->frame_info, stage_buffer,
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 110 output_buffer);
db7f419c06d7cc drivers/gpu/drm/vkms/vkms_crc.c Haneen Mohammed 2018-09-06 111 }
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 112
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 113 *crc32 = crc32_le(*crc32, (void *)output_buffer->pixels, row_size);
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 114
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 115 if (wb)
8ba1648567e289 drivers/gpu/drm/vkms/vkms_composer.c Igor Torrente 2022-09-05 116 wb->wb_write(&wb->wb_frame_info, output_buffer, y);
db7f419c06d7cc drivers/gpu/drm/vkms/vkms_crc.c Haneen Mohammed 2018-09-06 117 }
db7f419c06d7cc drivers/gpu/drm/vkms/vkms_crc.c Haneen Mohammed 2018-09-06 118 }Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests