| Message ID | 20260709134832.915809-1-kieran.bingham@ideasonboard.com |
|---|---|
| State | Accepted |
| Headers | show |
| Series |
|
| Related | show |
2026. 07. 09. 15:48 keltezéssel, Kieran Bingham írta: > Update the kernel headers to v7.1 using utils/update-kernel-headers.sh. > Preserve the libcamera local modifications manually. > > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > --- > > v2: > - Update commit message > - Bring in linux/bits.h which is now used by linux/drm_mode.h What about `linux/const.h` that is also included? > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > include/linux/README | 2 +- > include/linux/bits.h | 14 ++++++ > include/linux/drm_fourcc.h | 16 +++++++ > include/linux/drm_mode.h | 84 ++++++++++++++++++++++++++++++++++ > utils/update-kernel-headers.sh | 1 + > 5 files changed, 116 insertions(+), 1 deletion(-) > create mode 100644 include/linux/bits.h > > diff --git a/include/linux/README b/include/linux/README > index b02952bb28ca..9303e0f14ae6 100644 > --- a/include/linux/README > +++ b/include/linux/README > @@ -1,4 +1,4 @@ > # SPDX-License-Identifier: CC0-1.0 > > -Files in this directory are imported from v7.0 of the Linux kernel. Do not > +Files in this directory are imported from v7.1 of the Linux kernel. Do not > modify them manually. > diff --git a/include/linux/bits.h b/include/linux/bits.h > new file mode 100644 > index 000000000000..9243f3897518 > --- /dev/null > +++ b/include/linux/bits.h > @@ -0,0 +1,14 @@ > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > +/* bits.h: Macros for dealing with bitmasks. */ > + > +#ifndef _LINUX_BITS_H > +#define _LINUX_BITS_H > + > +#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h)))) > + > +#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h)))) > + > +#define __GENMASK_U128(h, l) \ > + ((_BIT128((h)) << 1) - (_BIT128(l))) > + > +#endif /* _LINUX_BITS_H */ > diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h > index e8a3d949032b..8e2a6abae62f 100644 > --- a/include/linux/drm_fourcc.h > +++ b/include/linux/drm_fourcc.h > @@ -1480,6 +1480,22 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) > #define DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED \ > DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 1ULL) > > +/* > + * ARM 64k interleaved modifier > + * > + * This is used by ARM Mali v10+ GPUs. With this modifier, the plane is divided > + * into 64k byte 1:1 or 2:1 -sided tiles. The 64k tiles are laid out linearly. > + * Each 64k tile is divided into blocks of 16x16 texel blocks, which are > + * themselves laid out linearly within a 64k tile. Then within each 16x16 > + * block, texel blocks are laid out according to U order, similar to > + * 16X16_BLOCK_U_INTERLEAVED. > + * > + * Note that unlike 16X16_BLOCK_U_INTERLEAVED, the layout does not change > + * depending on whether a format is compressed or not. > + */ > +#define DRM_FORMAT_MOD_ARM_INTERLEAVED_64K \ > + DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 2ULL) > + > /* > * Allwinner tiled modifier > * > diff --git a/include/linux/drm_mode.h b/include/linux/drm_mode.h > index 8894b7a80732..381a3e857d4e 100644 > --- a/include/linux/drm_mode.h > +++ b/include/linux/drm_mode.h > @@ -10,6 +10,9 @@ > #ifndef _DRM_MODE_H > #define _DRM_MODE_H > > +#include <linux/bits.h> > +#include <linux/const.h> > + > #include "drm.h" > > #if defined(__cplusplus) > @@ -149,6 +152,10 @@ extern "C" { > #define DRM_MODE_LINK_STATUS_GOOD 0 > #define DRM_MODE_LINK_STATUS_BAD 1 > > +/* Panel type property */ > +#define DRM_MODE_PANEL_TYPE_UNKNOWN 0 > +#define DRM_MODE_PANEL_TYPE_OLED 1 > + > /* > * DRM_MODE_ROTATE_<degrees> > * > @@ -1528,6 +1535,83 @@ struct drm_mode_closefb { > __u32 pad; > }; > > +/* > + * Put 16-bit ARGB values into a standard 64-bit representation that can be > + * used for ioctl parameters, inter-driver communication, etc. > + * > + * If the component values being provided contain less than 16 bits of > + * precision, use a conversion ratio to get a better color approximation. > + * The ratio is computed as (2^16 - 1) / (2^bpc - 1), where bpc and 16 are > + * the input and output precision, respectively. > + * Also note bpc must be greater than 0. > + */ > +#define __DRM_ARGB64_PREP(c, shift) \ > + (((__u64)(c) & __GENMASK(15, 0)) << (shift)) > + > +#define __DRM_ARGB64_PREP_BPC(c, shift, bpc) \ > +({ \ > + __u16 mask = __GENMASK((bpc) - 1, 0); \ > + __u16 conv = __KERNEL_DIV_ROUND_CLOSEST((mask & (c)) * \ > + __GENMASK(15, 0), mask);\ > + __DRM_ARGB64_PREP(conv, shift); \ > +}) > + > +#define DRM_ARGB64_PREP(alpha, red, green, blue) \ > +( \ > + __DRM_ARGB64_PREP(alpha, 48) | \ > + __DRM_ARGB64_PREP(red, 32) | \ > + __DRM_ARGB64_PREP(green, 16) | \ > + __DRM_ARGB64_PREP(blue, 0) \ > +) > + > +#define DRM_ARGB64_PREP_BPC(alpha, red, green, blue, bpc) \ > +({ \ > + __typeof__(bpc) __bpc = bpc; \ > + __DRM_ARGB64_PREP_BPC(alpha, 48, __bpc) | \ > + __DRM_ARGB64_PREP_BPC(red, 32, __bpc) | \ > + __DRM_ARGB64_PREP_BPC(green, 16, __bpc) | \ > + __DRM_ARGB64_PREP_BPC(blue, 0, __bpc); \ > +}) > + > +/* > + * Extract the specified color component from a standard 64-bit ARGB value. > + * > + * If the requested precision is less than 16 bits, make use of a conversion > + * ratio calculated as (2^bpc - 1) / (2^16 - 1), where bpc and 16 are the > + * output and input precision, respectively. > + * > + * If speed is more important than accuracy, use DRM_ARGB64_GET*_BPCS() > + * instead of DRM_ARGB64_GET*_BPC() in order to replace the expensive > + * division with a simple bit right-shift operation. > + */ > +#define __DRM_ARGB64_GET(c, shift) \ > + ((__u16)(((__u64)(c) >> (shift)) & __GENMASK(15, 0))) > + > +#define __DRM_ARGB64_GET_BPC(c, shift, bpc) \ > +({ \ > + __u16 comp = __DRM_ARGB64_GET(c, shift); \ > + __KERNEL_DIV_ROUND_CLOSEST(comp * __GENMASK((bpc) - 1, 0), \ > + __GENMASK(15, 0)); \ > +}) > + > +#define __DRM_ARGB64_GET_BPCS(c, shift, bpc) \ > + (__DRM_ARGB64_GET(c, shift) >> (16 - (bpc))) > + > +#define DRM_ARGB64_GETA(c) __DRM_ARGB64_GET(c, 48) > +#define DRM_ARGB64_GETR(c) __DRM_ARGB64_GET(c, 32) > +#define DRM_ARGB64_GETG(c) __DRM_ARGB64_GET(c, 16) > +#define DRM_ARGB64_GETB(c) __DRM_ARGB64_GET(c, 0) > + > +#define DRM_ARGB64_GETA_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 48, bpc) > +#define DRM_ARGB64_GETR_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 32, bpc) > +#define DRM_ARGB64_GETG_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 16, bpc) > +#define DRM_ARGB64_GETB_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 0, bpc) > + > +#define DRM_ARGB64_GETA_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 48, bpc) > +#define DRM_ARGB64_GETR_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 32, bpc) > +#define DRM_ARGB64_GETG_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 16, bpc) > +#define DRM_ARGB64_GETB_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 0, bpc) > + > #if defined(__cplusplus) > } > #endif > diff --git a/utils/update-kernel-headers.sh b/utils/update-kernel-headers.sh > index d97840ee0181..3fdea5f1eb5d 100755 > --- a/utils/update-kernel-headers.sh > +++ b/utils/update-kernel-headers.sh > @@ -49,6 +49,7 @@ headers=" > drm/drm.h > drm/drm_fourcc.h > drm/drm_mode.h > + linux/bits.h > linux/dma-buf.h > linux/dma-heap.h > linux/dw100.h
2026. 07. 15. 15:53 keltezéssel, Kieran Bingham írta: > Quoting Barnabás Pőcze (2026-07-15 09:35:38) >> 2026. 07. 09. 15:48 keltezéssel, Kieran Bingham írta: >>> Update the kernel headers to v7.1 using utils/update-kernel-headers.sh. >>> Preserve the libcamera local modifications manually. >>> >>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> >>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> >>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> >>> >>> --- >>> >>> v2: >>> - Update commit message >>> - Bring in linux/bits.h which is now used by linux/drm_mode.h >> >> What about `linux/const.h` that is also included? > > I only brought in linux/bits.h as it caused a compile error without it. > > Which makes me wonder why CI could get linux/const.h but not > linux/bits.h. Perhaps linux/bits.h is newer than the CI linux headers? > > I think as long as all the targets on CI compile correctly we should be > ok ? In my environment it picks up `const.h` from `/usr/include/linux/`. > > -- > Kieran > >>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> >>> --- >>> include/linux/README | 2 +- >>> include/linux/bits.h | 14 ++++++ >>> include/linux/drm_fourcc.h | 16 +++++++ >>> include/linux/drm_mode.h | 84 ++++++++++++++++++++++++++++++++++ >>> utils/update-kernel-headers.sh | 1 + >>> 5 files changed, 116 insertions(+), 1 deletion(-) >>> create mode 100644 include/linux/bits.h >>> >>> diff --git a/include/linux/README b/include/linux/README >>> index b02952bb28ca..9303e0f14ae6 100644 >>> --- a/include/linux/README >>> +++ b/include/linux/README >>> @@ -1,4 +1,4 @@ >>> # SPDX-License-Identifier: CC0-1.0 >>> >>> -Files in this directory are imported from v7.0 of the Linux kernel. Do not >>> +Files in this directory are imported from v7.1 of the Linux kernel. Do not >>> modify them manually. >>> diff --git a/include/linux/bits.h b/include/linux/bits.h >>> new file mode 100644 >>> index 000000000000..9243f3897518 >>> --- /dev/null >>> +++ b/include/linux/bits.h >>> @@ -0,0 +1,14 @@ >>> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ >>> +/* bits.h: Macros for dealing with bitmasks. */ >>> + >>> +#ifndef _LINUX_BITS_H >>> +#define _LINUX_BITS_H >>> + >>> +#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h)))) >>> + >>> +#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h)))) >>> + >>> +#define __GENMASK_U128(h, l) \ >>> + ((_BIT128((h)) << 1) - (_BIT128(l))) >>> + >>> +#endif /* _LINUX_BITS_H */ >>> diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h >>> index e8a3d949032b..8e2a6abae62f 100644 >>> --- a/include/linux/drm_fourcc.h >>> +++ b/include/linux/drm_fourcc.h >>> @@ -1480,6 +1480,22 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) >>> #define DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED \ >>> DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 1ULL) >>> >>> +/* >>> + * ARM 64k interleaved modifier >>> + * >>> + * This is used by ARM Mali v10+ GPUs. With this modifier, the plane is divided >>> + * into 64k byte 1:1 or 2:1 -sided tiles. The 64k tiles are laid out linearly. >>> + * Each 64k tile is divided into blocks of 16x16 texel blocks, which are >>> + * themselves laid out linearly within a 64k tile. Then within each 16x16 >>> + * block, texel blocks are laid out according to U order, similar to >>> + * 16X16_BLOCK_U_INTERLEAVED. >>> + * >>> + * Note that unlike 16X16_BLOCK_U_INTERLEAVED, the layout does not change >>> + * depending on whether a format is compressed or not. >>> + */ >>> +#define DRM_FORMAT_MOD_ARM_INTERLEAVED_64K \ >>> + DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 2ULL) >>> + >>> /* >>> * Allwinner tiled modifier >>> * >>> diff --git a/include/linux/drm_mode.h b/include/linux/drm_mode.h >>> index 8894b7a80732..381a3e857d4e 100644 >>> --- a/include/linux/drm_mode.h >>> +++ b/include/linux/drm_mode.h >>> @@ -10,6 +10,9 @@ >>> #ifndef _DRM_MODE_H >>> #define _DRM_MODE_H >>> >>> +#include <linux/bits.h> >>> +#include <linux/const.h> >>> + >>> #include "drm.h" >>> >>> #if defined(__cplusplus) >>> @@ -149,6 +152,10 @@ extern "C" { >>> #define DRM_MODE_LINK_STATUS_GOOD 0 >>> #define DRM_MODE_LINK_STATUS_BAD 1 >>> >>> +/* Panel type property */ >>> +#define DRM_MODE_PANEL_TYPE_UNKNOWN 0 >>> +#define DRM_MODE_PANEL_TYPE_OLED 1 >>> + >>> /* >>> * DRM_MODE_ROTATE_<degrees> >>> * >>> @@ -1528,6 +1535,83 @@ struct drm_mode_closefb { >>> __u32 pad; >>> }; >>> >>> +/* >>> + * Put 16-bit ARGB values into a standard 64-bit representation that can be >>> + * used for ioctl parameters, inter-driver communication, etc. >>> + * >>> + * If the component values being provided contain less than 16 bits of >>> + * precision, use a conversion ratio to get a better color approximation. >>> + * The ratio is computed as (2^16 - 1) / (2^bpc - 1), where bpc and 16 are >>> + * the input and output precision, respectively. >>> + * Also note bpc must be greater than 0. >>> + */ >>> +#define __DRM_ARGB64_PREP(c, shift) \ >>> + (((__u64)(c) & __GENMASK(15, 0)) << (shift)) >>> + >>> +#define __DRM_ARGB64_PREP_BPC(c, shift, bpc) \ >>> +({ \ >>> + __u16 mask = __GENMASK((bpc) - 1, 0); \ >>> + __u16 conv = __KERNEL_DIV_ROUND_CLOSEST((mask & (c)) * \ >>> + __GENMASK(15, 0), mask);\ >>> + __DRM_ARGB64_PREP(conv, shift); \ >>> +}) >>> + >>> +#define DRM_ARGB64_PREP(alpha, red, green, blue) \ >>> +( \ >>> + __DRM_ARGB64_PREP(alpha, 48) | \ >>> + __DRM_ARGB64_PREP(red, 32) | \ >>> + __DRM_ARGB64_PREP(green, 16) | \ >>> + __DRM_ARGB64_PREP(blue, 0) \ >>> +) >>> + >>> +#define DRM_ARGB64_PREP_BPC(alpha, red, green, blue, bpc) \ >>> +({ \ >>> + __typeof__(bpc) __bpc = bpc; \ >>> + __DRM_ARGB64_PREP_BPC(alpha, 48, __bpc) | \ >>> + __DRM_ARGB64_PREP_BPC(red, 32, __bpc) | \ >>> + __DRM_ARGB64_PREP_BPC(green, 16, __bpc) | \ >>> + __DRM_ARGB64_PREP_BPC(blue, 0, __bpc); \ >>> +}) >>> + >>> +/* >>> + * Extract the specified color component from a standard 64-bit ARGB value. >>> + * >>> + * If the requested precision is less than 16 bits, make use of a conversion >>> + * ratio calculated as (2^bpc - 1) / (2^16 - 1), where bpc and 16 are the >>> + * output and input precision, respectively. >>> + * >>> + * If speed is more important than accuracy, use DRM_ARGB64_GET*_BPCS() >>> + * instead of DRM_ARGB64_GET*_BPC() in order to replace the expensive >>> + * division with a simple bit right-shift operation. >>> + */ >>> +#define __DRM_ARGB64_GET(c, shift) \ >>> + ((__u16)(((__u64)(c) >> (shift)) & __GENMASK(15, 0))) >>> + >>> +#define __DRM_ARGB64_GET_BPC(c, shift, bpc) \ >>> +({ \ >>> + __u16 comp = __DRM_ARGB64_GET(c, shift); \ >>> + __KERNEL_DIV_ROUND_CLOSEST(comp * __GENMASK((bpc) - 1, 0), \ >>> + __GENMASK(15, 0)); \ >>> +}) >>> + >>> +#define __DRM_ARGB64_GET_BPCS(c, shift, bpc) \ >>> + (__DRM_ARGB64_GET(c, shift) >> (16 - (bpc))) >>> + >>> +#define DRM_ARGB64_GETA(c) __DRM_ARGB64_GET(c, 48) >>> +#define DRM_ARGB64_GETR(c) __DRM_ARGB64_GET(c, 32) >>> +#define DRM_ARGB64_GETG(c) __DRM_ARGB64_GET(c, 16) >>> +#define DRM_ARGB64_GETB(c) __DRM_ARGB64_GET(c, 0) >>> + >>> +#define DRM_ARGB64_GETA_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 48, bpc) >>> +#define DRM_ARGB64_GETR_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 32, bpc) >>> +#define DRM_ARGB64_GETG_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 16, bpc) >>> +#define DRM_ARGB64_GETB_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 0, bpc) >>> + >>> +#define DRM_ARGB64_GETA_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 48, bpc) >>> +#define DRM_ARGB64_GETR_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 32, bpc) >>> +#define DRM_ARGB64_GETG_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 16, bpc) >>> +#define DRM_ARGB64_GETB_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 0, bpc) >>> + >>> #if defined(__cplusplus) >>> } >>> #endif >>> diff --git a/utils/update-kernel-headers.sh b/utils/update-kernel-headers.sh >>> index d97840ee0181..3fdea5f1eb5d 100755 >>> --- a/utils/update-kernel-headers.sh >>> +++ b/utils/update-kernel-headers.sh >>> @@ -49,6 +49,7 @@ headers=" >>> drm/drm.h >>> drm/drm_fourcc.h >>> drm/drm_mode.h >>> + linux/bits.h >>> linux/dma-buf.h >>> linux/dma-heap.h >>> linux/dw100.h >>
On Wed, Jul 15, 2026 at 04:16:38PM +0200, Barnabás Pőcze wrote: > 2026. 07. 15. 15:53 keltezéssel, Kieran Bingham írta: > > Quoting Barnabás Pőcze (2026-07-15 09:35:38) > >> 2026. 07. 09. 15:48 keltezéssel, Kieran Bingham írta: > >>> Update the kernel headers to v7.1 using utils/update-kernel-headers.sh. > >>> Preserve the libcamera local modifications manually. > >>> > >>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > >>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > >>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > >>> > >>> --- > >>> > >>> v2: > >>> - Update commit message > >>> - Bring in linux/bits.h which is now used by linux/drm_mode.h > >> > >> What about `linux/const.h` that is also included? > > > > I only brought in linux/bits.h as it caused a compile error without it. > > > > Which makes me wonder why CI could get linux/const.h but not > > linux/bits.h. Perhaps linux/bits.h is newer than the CI linux headers? > > > > I think as long as all the targets on CI compile correctly we should be > > ok ? > > In my environment it picks up `const.h` from `/usr/include/linux/`. Bringing in const.h seems like a good idea. The risk of incompatibilities with /usr/include/linux/const.h is very low but it could cause annoying to debug issues (or just issues). > >>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > >>> --- > >>> include/linux/README | 2 +- > >>> include/linux/bits.h | 14 ++++++ > >>> include/linux/drm_fourcc.h | 16 +++++++ > >>> include/linux/drm_mode.h | 84 ++++++++++++++++++++++++++++++++++ > >>> utils/update-kernel-headers.sh | 1 + > >>> 5 files changed, 116 insertions(+), 1 deletion(-) > >>> create mode 100644 include/linux/bits.h > >>> > >>> diff --git a/include/linux/README b/include/linux/README > >>> index b02952bb28ca..9303e0f14ae6 100644 > >>> --- a/include/linux/README > >>> +++ b/include/linux/README > >>> @@ -1,4 +1,4 @@ > >>> # SPDX-License-Identifier: CC0-1.0 > >>> > >>> -Files in this directory are imported from v7.0 of the Linux kernel. Do not > >>> +Files in this directory are imported from v7.1 of the Linux kernel. Do not > >>> modify them manually. > >>> diff --git a/include/linux/bits.h b/include/linux/bits.h > >>> new file mode 100644 > >>> index 000000000000..9243f3897518 > >>> --- /dev/null > >>> +++ b/include/linux/bits.h > >>> @@ -0,0 +1,14 @@ > >>> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > >>> +/* bits.h: Macros for dealing with bitmasks. */ > >>> + > >>> +#ifndef _LINUX_BITS_H > >>> +#define _LINUX_BITS_H > >>> + > >>> +#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h)))) > >>> + > >>> +#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h)))) > >>> + > >>> +#define __GENMASK_U128(h, l) \ > >>> + ((_BIT128((h)) << 1) - (_BIT128(l))) > >>> + > >>> +#endif /* _LINUX_BITS_H */ > >>> diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h > >>> index e8a3d949032b..8e2a6abae62f 100644 > >>> --- a/include/linux/drm_fourcc.h > >>> +++ b/include/linux/drm_fourcc.h > >>> @@ -1480,6 +1480,22 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) > >>> #define DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED \ > >>> DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 1ULL) > >>> > >>> +/* > >>> + * ARM 64k interleaved modifier > >>> + * > >>> + * This is used by ARM Mali v10+ GPUs. With this modifier, the plane is divided > >>> + * into 64k byte 1:1 or 2:1 -sided tiles. The 64k tiles are laid out linearly. > >>> + * Each 64k tile is divided into blocks of 16x16 texel blocks, which are > >>> + * themselves laid out linearly within a 64k tile. Then within each 16x16 > >>> + * block, texel blocks are laid out according to U order, similar to > >>> + * 16X16_BLOCK_U_INTERLEAVED. > >>> + * > >>> + * Note that unlike 16X16_BLOCK_U_INTERLEAVED, the layout does not change > >>> + * depending on whether a format is compressed or not. > >>> + */ > >>> +#define DRM_FORMAT_MOD_ARM_INTERLEAVED_64K \ > >>> + DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 2ULL) > >>> + > >>> /* > >>> * Allwinner tiled modifier > >>> * > >>> diff --git a/include/linux/drm_mode.h b/include/linux/drm_mode.h > >>> index 8894b7a80732..381a3e857d4e 100644 > >>> --- a/include/linux/drm_mode.h > >>> +++ b/include/linux/drm_mode.h > >>> @@ -10,6 +10,9 @@ > >>> #ifndef _DRM_MODE_H > >>> #define _DRM_MODE_H > >>> > >>> +#include <linux/bits.h> > >>> +#include <linux/const.h> > >>> + > >>> #include "drm.h" > >>> > >>> #if defined(__cplusplus) > >>> @@ -149,6 +152,10 @@ extern "C" { > >>> #define DRM_MODE_LINK_STATUS_GOOD 0 > >>> #define DRM_MODE_LINK_STATUS_BAD 1 > >>> > >>> +/* Panel type property */ > >>> +#define DRM_MODE_PANEL_TYPE_UNKNOWN 0 > >>> +#define DRM_MODE_PANEL_TYPE_OLED 1 > >>> + > >>> /* > >>> * DRM_MODE_ROTATE_<degrees> > >>> * > >>> @@ -1528,6 +1535,83 @@ struct drm_mode_closefb { > >>> __u32 pad; > >>> }; > >>> > >>> +/* > >>> + * Put 16-bit ARGB values into a standard 64-bit representation that can be > >>> + * used for ioctl parameters, inter-driver communication, etc. > >>> + * > >>> + * If the component values being provided contain less than 16 bits of > >>> + * precision, use a conversion ratio to get a better color approximation. > >>> + * The ratio is computed as (2^16 - 1) / (2^bpc - 1), where bpc and 16 are > >>> + * the input and output precision, respectively. > >>> + * Also note bpc must be greater than 0. > >>> + */ > >>> +#define __DRM_ARGB64_PREP(c, shift) \ > >>> + (((__u64)(c) & __GENMASK(15, 0)) << (shift)) > >>> + > >>> +#define __DRM_ARGB64_PREP_BPC(c, shift, bpc) \ > >>> +({ \ > >>> + __u16 mask = __GENMASK((bpc) - 1, 0); \ > >>> + __u16 conv = __KERNEL_DIV_ROUND_CLOSEST((mask & (c)) * \ > >>> + __GENMASK(15, 0), mask);\ > >>> + __DRM_ARGB64_PREP(conv, shift); \ > >>> +}) > >>> + > >>> +#define DRM_ARGB64_PREP(alpha, red, green, blue) \ > >>> +( \ > >>> + __DRM_ARGB64_PREP(alpha, 48) | \ > >>> + __DRM_ARGB64_PREP(red, 32) | \ > >>> + __DRM_ARGB64_PREP(green, 16) | \ > >>> + __DRM_ARGB64_PREP(blue, 0) \ > >>> +) > >>> + > >>> +#define DRM_ARGB64_PREP_BPC(alpha, red, green, blue, bpc) \ > >>> +({ \ > >>> + __typeof__(bpc) __bpc = bpc; \ > >>> + __DRM_ARGB64_PREP_BPC(alpha, 48, __bpc) | \ > >>> + __DRM_ARGB64_PREP_BPC(red, 32, __bpc) | \ > >>> + __DRM_ARGB64_PREP_BPC(green, 16, __bpc) | \ > >>> + __DRM_ARGB64_PREP_BPC(blue, 0, __bpc); \ > >>> +}) > >>> + > >>> +/* > >>> + * Extract the specified color component from a standard 64-bit ARGB value. > >>> + * > >>> + * If the requested precision is less than 16 bits, make use of a conversion > >>> + * ratio calculated as (2^bpc - 1) / (2^16 - 1), where bpc and 16 are the > >>> + * output and input precision, respectively. > >>> + * > >>> + * If speed is more important than accuracy, use DRM_ARGB64_GET*_BPCS() > >>> + * instead of DRM_ARGB64_GET*_BPC() in order to replace the expensive > >>> + * division with a simple bit right-shift operation. > >>> + */ > >>> +#define __DRM_ARGB64_GET(c, shift) \ > >>> + ((__u16)(((__u64)(c) >> (shift)) & __GENMASK(15, 0))) > >>> + > >>> +#define __DRM_ARGB64_GET_BPC(c, shift, bpc) \ > >>> +({ \ > >>> + __u16 comp = __DRM_ARGB64_GET(c, shift); \ > >>> + __KERNEL_DIV_ROUND_CLOSEST(comp * __GENMASK((bpc) - 1, 0), \ > >>> + __GENMASK(15, 0)); \ > >>> +}) > >>> + > >>> +#define __DRM_ARGB64_GET_BPCS(c, shift, bpc) \ > >>> + (__DRM_ARGB64_GET(c, shift) >> (16 - (bpc))) > >>> + > >>> +#define DRM_ARGB64_GETA(c) __DRM_ARGB64_GET(c, 48) > >>> +#define DRM_ARGB64_GETR(c) __DRM_ARGB64_GET(c, 32) > >>> +#define DRM_ARGB64_GETG(c) __DRM_ARGB64_GET(c, 16) > >>> +#define DRM_ARGB64_GETB(c) __DRM_ARGB64_GET(c, 0) > >>> + > >>> +#define DRM_ARGB64_GETA_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 48, bpc) > >>> +#define DRM_ARGB64_GETR_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 32, bpc) > >>> +#define DRM_ARGB64_GETG_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 16, bpc) > >>> +#define DRM_ARGB64_GETB_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 0, bpc) > >>> + > >>> +#define DRM_ARGB64_GETA_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 48, bpc) > >>> +#define DRM_ARGB64_GETR_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 32, bpc) > >>> +#define DRM_ARGB64_GETG_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 16, bpc) > >>> +#define DRM_ARGB64_GETB_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 0, bpc) > >>> + > >>> #if defined(__cplusplus) > >>> } > >>> #endif > >>> diff --git a/utils/update-kernel-headers.sh b/utils/update-kernel-headers.sh > >>> index d97840ee0181..3fdea5f1eb5d 100755 > >>> --- a/utils/update-kernel-headers.sh > >>> +++ b/utils/update-kernel-headers.sh > >>> @@ -49,6 +49,7 @@ headers=" > >>> drm/drm.h > >>> drm/drm_fourcc.h > >>> drm/drm_mode.h > >>> + linux/bits.h > >>> linux/dma-buf.h > >>> linux/dma-heap.h > >>> linux/dw100.h
diff --git a/include/linux/README b/include/linux/README index b02952bb28ca..9303e0f14ae6 100644 --- a/include/linux/README +++ b/include/linux/README @@ -1,4 +1,4 @@ # SPDX-License-Identifier: CC0-1.0 -Files in this directory are imported from v7.0 of the Linux kernel. Do not +Files in this directory are imported from v7.1 of the Linux kernel. Do not modify them manually. diff --git a/include/linux/bits.h b/include/linux/bits.h new file mode 100644 index 000000000000..9243f3897518 --- /dev/null +++ b/include/linux/bits.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* bits.h: Macros for dealing with bitmasks. */ + +#ifndef _LINUX_BITS_H +#define _LINUX_BITS_H + +#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h)))) + +#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h)))) + +#define __GENMASK_U128(h, l) \ + ((_BIT128((h)) << 1) - (_BIT128(l))) + +#endif /* _LINUX_BITS_H */ diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h index e8a3d949032b..8e2a6abae62f 100644 --- a/include/linux/drm_fourcc.h +++ b/include/linux/drm_fourcc.h @@ -1480,6 +1480,22 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier) #define DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED \ DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 1ULL) +/* + * ARM 64k interleaved modifier + * + * This is used by ARM Mali v10+ GPUs. With this modifier, the plane is divided + * into 64k byte 1:1 or 2:1 -sided tiles. The 64k tiles are laid out linearly. + * Each 64k tile is divided into blocks of 16x16 texel blocks, which are + * themselves laid out linearly within a 64k tile. Then within each 16x16 + * block, texel blocks are laid out according to U order, similar to + * 16X16_BLOCK_U_INTERLEAVED. + * + * Note that unlike 16X16_BLOCK_U_INTERLEAVED, the layout does not change + * depending on whether a format is compressed or not. + */ +#define DRM_FORMAT_MOD_ARM_INTERLEAVED_64K \ + DRM_FORMAT_MOD_ARM_CODE(DRM_FORMAT_MOD_ARM_TYPE_MISC, 2ULL) + /* * Allwinner tiled modifier * diff --git a/include/linux/drm_mode.h b/include/linux/drm_mode.h index 8894b7a80732..381a3e857d4e 100644 --- a/include/linux/drm_mode.h +++ b/include/linux/drm_mode.h @@ -10,6 +10,9 @@ #ifndef _DRM_MODE_H #define _DRM_MODE_H +#include <linux/bits.h> +#include <linux/const.h> + #include "drm.h" #if defined(__cplusplus) @@ -149,6 +152,10 @@ extern "C" { #define DRM_MODE_LINK_STATUS_GOOD 0 #define DRM_MODE_LINK_STATUS_BAD 1 +/* Panel type property */ +#define DRM_MODE_PANEL_TYPE_UNKNOWN 0 +#define DRM_MODE_PANEL_TYPE_OLED 1 + /* * DRM_MODE_ROTATE_<degrees> * @@ -1528,6 +1535,83 @@ struct drm_mode_closefb { __u32 pad; }; +/* + * Put 16-bit ARGB values into a standard 64-bit representation that can be + * used for ioctl parameters, inter-driver communication, etc. + * + * If the component values being provided contain less than 16 bits of + * precision, use a conversion ratio to get a better color approximation. + * The ratio is computed as (2^16 - 1) / (2^bpc - 1), where bpc and 16 are + * the input and output precision, respectively. + * Also note bpc must be greater than 0. + */ +#define __DRM_ARGB64_PREP(c, shift) \ + (((__u64)(c) & __GENMASK(15, 0)) << (shift)) + +#define __DRM_ARGB64_PREP_BPC(c, shift, bpc) \ +({ \ + __u16 mask = __GENMASK((bpc) - 1, 0); \ + __u16 conv = __KERNEL_DIV_ROUND_CLOSEST((mask & (c)) * \ + __GENMASK(15, 0), mask);\ + __DRM_ARGB64_PREP(conv, shift); \ +}) + +#define DRM_ARGB64_PREP(alpha, red, green, blue) \ +( \ + __DRM_ARGB64_PREP(alpha, 48) | \ + __DRM_ARGB64_PREP(red, 32) | \ + __DRM_ARGB64_PREP(green, 16) | \ + __DRM_ARGB64_PREP(blue, 0) \ +) + +#define DRM_ARGB64_PREP_BPC(alpha, red, green, blue, bpc) \ +({ \ + __typeof__(bpc) __bpc = bpc; \ + __DRM_ARGB64_PREP_BPC(alpha, 48, __bpc) | \ + __DRM_ARGB64_PREP_BPC(red, 32, __bpc) | \ + __DRM_ARGB64_PREP_BPC(green, 16, __bpc) | \ + __DRM_ARGB64_PREP_BPC(blue, 0, __bpc); \ +}) + +/* + * Extract the specified color component from a standard 64-bit ARGB value. + * + * If the requested precision is less than 16 bits, make use of a conversion + * ratio calculated as (2^bpc - 1) / (2^16 - 1), where bpc and 16 are the + * output and input precision, respectively. + * + * If speed is more important than accuracy, use DRM_ARGB64_GET*_BPCS() + * instead of DRM_ARGB64_GET*_BPC() in order to replace the expensive + * division with a simple bit right-shift operation. + */ +#define __DRM_ARGB64_GET(c, shift) \ + ((__u16)(((__u64)(c) >> (shift)) & __GENMASK(15, 0))) + +#define __DRM_ARGB64_GET_BPC(c, shift, bpc) \ +({ \ + __u16 comp = __DRM_ARGB64_GET(c, shift); \ + __KERNEL_DIV_ROUND_CLOSEST(comp * __GENMASK((bpc) - 1, 0), \ + __GENMASK(15, 0)); \ +}) + +#define __DRM_ARGB64_GET_BPCS(c, shift, bpc) \ + (__DRM_ARGB64_GET(c, shift) >> (16 - (bpc))) + +#define DRM_ARGB64_GETA(c) __DRM_ARGB64_GET(c, 48) +#define DRM_ARGB64_GETR(c) __DRM_ARGB64_GET(c, 32) +#define DRM_ARGB64_GETG(c) __DRM_ARGB64_GET(c, 16) +#define DRM_ARGB64_GETB(c) __DRM_ARGB64_GET(c, 0) + +#define DRM_ARGB64_GETA_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 48, bpc) +#define DRM_ARGB64_GETR_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 32, bpc) +#define DRM_ARGB64_GETG_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 16, bpc) +#define DRM_ARGB64_GETB_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 0, bpc) + +#define DRM_ARGB64_GETA_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 48, bpc) +#define DRM_ARGB64_GETR_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 32, bpc) +#define DRM_ARGB64_GETG_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 16, bpc) +#define DRM_ARGB64_GETB_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 0, bpc) + #if defined(__cplusplus) } #endif diff --git a/utils/update-kernel-headers.sh b/utils/update-kernel-headers.sh index d97840ee0181..3fdea5f1eb5d 100755 --- a/utils/update-kernel-headers.sh +++ b/utils/update-kernel-headers.sh @@ -49,6 +49,7 @@ headers=" drm/drm.h drm/drm_fourcc.h drm/drm_mode.h + linux/bits.h linux/dma-buf.h linux/dma-heap.h linux/dw100.h