Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/intel: add pick.h for the various "picker" helpers

Add a shared header that's used by i915, xe, and i915 display.

This allows us to drop the compat-i915-headers/i915_reg_defs.h include
from xe_reg_defs.h. All the register macro helpers were subtly pulled in
from i915 to all of xe through this.

Reviewed-by: Michał Grzelak <michal.grzelak@intel.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patch.msgid.link/fcd70f3317755bf98a6e7ae88974aa8ba06efd1e.1772042022.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

+56 -46
+1 -44
drivers/gpu/drm/i915/i915_reg_defs.h
··· 6 6 #ifndef __I915_REG_DEFS__ 7 7 #define __I915_REG_DEFS__ 8 8 9 + #include <drm/intel/pick.h> 9 10 #include <drm/intel/reg_bits.h> 10 - 11 - /* 12 - * Given the first two numbers __a and __b of arbitrarily many evenly spaced 13 - * numbers, pick the 0-based __index'th value. 14 - * 15 - * Always prefer this over _PICK() if the numbers are evenly spaced. 16 - */ 17 - #define _PICK_EVEN(__index, __a, __b) ((__a) + (__index) * ((__b) - (__a))) 18 - 19 - /* 20 - * Like _PICK_EVEN(), but supports 2 ranges of evenly spaced address offsets. 21 - * @__c_index corresponds to the index in which the second range starts to be 22 - * used. Using math interval notation, the first range is used for indexes [ 0, 23 - * @__c_index), while the second range is used for [ @__c_index, ... ). Example: 24 - * 25 - * #define _FOO_A 0xf000 26 - * #define _FOO_B 0xf004 27 - * #define _FOO_C 0xf008 28 - * #define _SUPER_FOO_A 0xa000 29 - * #define _SUPER_FOO_B 0xa100 30 - * #define FOO(x) _MMIO(_PICK_EVEN_2RANGES(x, 3, \ 31 - * _FOO_A, _FOO_B, \ 32 - * _SUPER_FOO_A, _SUPER_FOO_B)) 33 - * 34 - * This expands to: 35 - * 0: 0xf000, 36 - * 1: 0xf004, 37 - * 2: 0xf008, 38 - * 3: 0xa000, 39 - * 4: 0xa100, 40 - * 5: 0xa200, 41 - * ... 42 - */ 43 - #define _PICK_EVEN_2RANGES(__index, __c_index, __a, __b, __c, __d) \ 44 - (BUILD_BUG_ON_ZERO(!__is_constexpr(__c_index)) + \ 45 - ((__index) < (__c_index) ? _PICK_EVEN(__index, __a, __b) : \ 46 - _PICK_EVEN((__index) - (__c_index), __c, __d))) 47 - 48 - /* 49 - * Given the arbitrary numbers in varargs, pick the 0-based __index'th number. 50 - * 51 - * Always prefer _PICK_EVEN() over this if the numbers are evenly spaced. 52 - */ 53 - #define _PICK(__index, ...) (((const u32 []){ __VA_ARGS__ })[__index]) 54 11 55 12 typedef struct { 56 13 u32 reg;
+1
drivers/gpu/drm/xe/compat-i915-headers/intel_uncore.h
··· 6 6 #ifndef __INTEL_UNCORE_H__ 7 7 #define __INTEL_UNCORE_H__ 8 8 9 + #include "i915_reg_defs.h" 9 10 #include "xe_device.h" 10 11 #include "xe_device_types.h" 11 12 #include "xe_mmio.h"
+3 -2
drivers/gpu/drm/xe/regs/xe_reg_defs.h
··· 6 6 #ifndef _XE_REG_DEFS_H_ 7 7 #define _XE_REG_DEFS_H_ 8 8 9 + #include <drm/intel/pick.h> 10 + #include <drm/intel/reg_bits.h> 11 + 9 12 #include <linux/build_bug.h> 10 13 #include <linux/log2.h> 11 14 #include <linux/sizes.h> 12 - 13 - #include "compat-i915-headers/i915_reg_defs.h" 14 15 15 16 /** 16 17 * XE_REG_ADDR_MAX - The upper limit on MMIO register address
+51
include/drm/intel/pick.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* Copyright © 2026 Intel Corporation */ 3 + 4 + #ifndef _PICK_H_ 5 + #define _PICK_H_ 6 + 7 + /* 8 + * Given the first two numbers __a and __b of arbitrarily many evenly spaced 9 + * numbers, pick the 0-based __index'th value. 10 + * 11 + * Always prefer this over _PICK() if the numbers are evenly spaced. 12 + */ 13 + #define _PICK_EVEN(__index, __a, __b) ((__a) + (__index) * ((__b) - (__a))) 14 + 15 + /* 16 + * Like _PICK_EVEN(), but supports 2 ranges of evenly spaced address offsets. 17 + * @__c_index corresponds to the index in which the second range starts to be 18 + * used. Using math interval notation, the first range is used for indexes [ 0, 19 + * @__c_index), while the second range is used for [ @__c_index, ... ). Example: 20 + * 21 + * #define _FOO_A 0xf000 22 + * #define _FOO_B 0xf004 23 + * #define _FOO_C 0xf008 24 + * #define _SUPER_FOO_A 0xa000 25 + * #define _SUPER_FOO_B 0xa100 26 + * #define FOO(x) _MMIO(_PICK_EVEN_2RANGES(x, 3, \ 27 + * _FOO_A, _FOO_B, \ 28 + * _SUPER_FOO_A, _SUPER_FOO_B)) 29 + * 30 + * This expands to: 31 + * 0: 0xf000, 32 + * 1: 0xf004, 33 + * 2: 0xf008, 34 + * 3: 0xa000, 35 + * 4: 0xa100, 36 + * 5: 0xa200, 37 + * ... 38 + */ 39 + #define _PICK_EVEN_2RANGES(__index, __c_index, __a, __b, __c, __d) \ 40 + (BUILD_BUG_ON_ZERO(!__is_constexpr(__c_index)) + \ 41 + ((__index) < (__c_index) ? _PICK_EVEN(__index, __a, __b) : \ 42 + _PICK_EVEN((__index) - (__c_index), __c, __d))) 43 + 44 + /* 45 + * Given the arbitrary numbers in varargs, pick the 0-based __index'th number. 46 + * 47 + * Always prefer _PICK_EVEN() over this if the numbers are evenly spaced. 48 + */ 49 + #define _PICK(__index, ...) (((const u32 []){ __VA_ARGS__ })[__index]) 50 + 51 + #endif