@@ -272,6 +272,51 @@ struct backlight_properties {
enum backlight_scale scale;
};
+#define BACKLIGHT_PROPS(_brightness, _max_brightness, _type) \
+ .brightness = _brightness, \
+ .max_brightness = _max_brightness, \
+ .power = FB_BLANK_POWERDOWN, \
+ .type = _type, \
+ .fb_blank = 0, \
+ .state = 0, \
+ .scale = BACKLIGHT_SCALE_UNKNOWN,
+
+/**
+ * DECLARE_BACKLIGHT_INIT_RAW - backlight_properties to init a raw
+ * backlight device
+ *
+ * This macro is used to initialize backlight_properties that is used when
+ * registering a raw backlight device.
+ */
+#define DECLARE_BACKLIGHT_INIT_RAW(name, _brightness, _max_brightness) \
+ const struct backlight_properties name = { \
+ BACKLIGHT_PROPS(_brightness, _max_brightness, BACKLIGHT_RAW) \
+ }
+
+/**
+ * DECLARE_BACKLIGHT_INIT_PLATFORM - backlight_properties to init a platform
+ * backlight device
+ *
+ * This macro is used to initialize backlight_properties that is used when
+ * registering a platform backlight device.
+ */
+#define DECLARE_BACKLIGHT_INIT_PLATFORM(name, _brightness, _max_brightness) \
+ const struct backlight_properties name = { \
+ BACKLIGHT_PROPS(_brightness, _max_brightness, BACKLIGHT_PLATFORM) \
+ }
+
+/**
+ * DECLARE_BACKLIGHT_INIT_FIRMWARE - backlight_properties to init a firmware
+ * backlight device
+ *
+ * This macro is used to initialize backlight_properties that is used when
+ * registering a firmware backlight device.
+ */
+#define DECLARE_BACKLIGHT_INIT_FIRMWARE(name, _brightness, _max_brightness) \
+ const struct backlight_properties name = { \
+ BACKLIGHT_PROPS(_brightness, _max_brightness, BACKLIGHT_FIRMWARE) \
+ }
+
/**
* struct backlight_device - backlight device data
*
Device registration almost always uses a struct backlight_properties variable to pass config info. Make it simpler and less error prone by the introduction of a number of macros. There is one macro for each type of backlight {firmware, platform, raw}. All members in struct backlight_properties are initialized. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Cc: Lee Jones <lee.jones@linaro.org> Cc: Daniel Thompson <daniel.thompson@linaro.org> Cc: Jingoo Han <jingoohan1@gmail.com> --- include/linux/backlight.h | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)