[PATCH 1/2] drm: Add CRTC background color property
Cristian Ciocaltea
cristian.ciocaltea at collabora.com
Tue Sep 2 09:26:01 PDT 2025
On 9/2/25 4:36 PM, Ville Syrjälä wrote:
> On Tue, Sep 02, 2025 at 12:27:56PM +0300, Cristian Ciocaltea wrote:
>> Some display controllers can be hardware programmed to show non-black
>> colors for pixels that are either not covered by any plane or are
>> exposed through transparent regions of higher planes. This feature can
>> help reduce memory bandwidth usage, e.g. in compositors managing a UI
>> with a solid background color while using smaller planes to render the
>> remaining content.
>>
>> To support this capability, introduce the BACKGROUND_COLOR standard DRM
>> mode property, which can be attached to a CRTC through the
>> drm_crtc_attach_background_color_property() helper function.
>>
>> Additionally, define a 64-bit ARGB format value to be built with the
>> help of a dedicated drm_argb64() utility macro. Individual color
>> components can be extracted with desired precision using the
>> corresponding DRM_ARGB64_*() macros.
>>
>> Co-developed-by: Matt Roper <matthew.d.roper at intel.com>
>> Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
>> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea at collabora.com>
>> ---
>> drivers/gpu/drm/drm_atomic_state_helper.c | 1 +
>> drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++
>> drivers/gpu/drm/drm_blend.c | 37 +++++++++++++++++++++++++++----
>> drivers/gpu/drm/drm_mode_config.c | 6 +++++
>> include/drm/drm_blend.h | 4 +++-
>> include/drm/drm_crtc.h | 12 ++++++++++
>> include/drm/drm_mode_config.h | 5 +++++
>> include/uapi/drm/drm_mode.h | 30 +++++++++++++++++++++++++
>> 8 files changed, 94 insertions(+), 5 deletions(-)
[...]
>> +/*
>> + * Put 16-bit ARGB values into a standard 64-bit representation that
>> + * can be used for ioctl parameters, inter-driver communication, etc.
>> + */
>> +static inline __u64
>> +drm_argb64(__u16 alpha, __u16 red, __u16 green, __u16 blue)
>> +{
>> + return (__u64)alpha << 48 | (__u64)red << 32 | (__u64)green << 16 | blue;
>> +}
>> +
>> +/*
>> + * Extract the specified number of least-significant bits of a specific
>> + * color component from a standard 64-bit ARGB value.
>
> Why would you ever want the least significant bits?
Right, that's useless - will replace with proper helpers dealing with custom
precision.
Thanks,
Cristian
>> + */
>> +#define DRM_ARGB64_COMP(c, shift, numlsb) \
>> + ((__u16)(((c) >> (shift)) & ((1UL << (numlsb) % 17) - 1)))
>> +#define DRM_ARGB64_ALPHA_LSB(c, numlsb) DRM_ARGB64_COMP(c, 48, numlsb)
>> +#define DRM_ARGB64_RED_LSB(c, numlsb) DRM_ARGB64_COMP(c, 32, numlsb)
>> +#define DRM_ARGB64_GREEN_LSB(c, numlsb) DRM_ARGB64_COMP(c, 16, numlsb)
>> +#define DRM_ARGB64_BLUE_LSB(c, numlsb) DRM_ARGB64_COMP(c, 0, numlsb)
>> +
>> +/*
>> + * Convenience wrappers to extract all 16 bits of a specific color
>> + * component from a standard 64-bit ARGB value.
>> + */
>> +#define DRM_ARGB64_ALPHA(c) DRM_ARGB64_ALPHA_LSB(c, 16)
>> +#define DRM_ARGB64_RED(c) DRM_ARGB64_RED_LSB(c, 16)
>> +#define DRM_ARGB64_GREEN(c) DRM_ARGB64_GREEN_LSB(c, 16)
>> +#define DRM_ARGB64_BLUE(c) DRM_ARGB64_BLUE_LSB(c, 16)
>> +
>> #if defined(__cplusplus)
>> }
>> #endif
>>
>> --
>> 2.51.0
>
More information about the linux-arm-kernel
mailing list