PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
Backlight

Backlight class. More...

Modules

 AW9364E
 Awinic AW9364E LED driver Backlight driver.
 
 LED backlight
 Backlight on an LED, its color mixed by multicolor LEDs.
 
 POSIX
 Backlight of a native build, which does nothing.
 
 PWM backlight
 Backlight driver driving the LED with a PWM output.
 
 QEMU
 QEMU backlight, driving the brightness (or RGB, with CONFIG_BACKLIGHT_QEMU_COLOR) registers of the QEMU display.
 

Data Structures

struct  pbl_backlight_ops
 Backlight driver operations, called with the device lock held. More...
 
struct  pbl_backlight_state
 Backlight runtime state. More...
 
struct  pbl_backlight
 Backlight. More...
 

Macros

#define PBL_BACKLIGHT_BRIGHTNESS_MAX   100U
 Maximum brightness.
 
#define PBL_BACKLIGHT_STATE_DEFINE(sym)
 Define the class state of a backlight.
 
#define PBL_BACKLIGHT_INIT(sym, _name, _parent, _ops)
 Initialize a struct pbl_backlight.
 

Functions

int pbl_backlight_set_brightness (const struct pbl_backlight *bl, uint8_t brightness)
 Set the brightness.
 
uint8_t pbl_backlight_get_level (const struct pbl_backlight *bl, uint8_t brightness)
 Map a brightness to an opaque hardware level identifier.
 
int pbl_backlight_refresh (const struct pbl_backlight *bl)
 Re-apply the brightness and color to the hardware.
 
int pbl_backlight_set_color (const struct pbl_backlight *bl, uint32_t rgb_color)
 Set the color.
 
uint32_t pbl_backlight_get_color (const struct pbl_backlight *bl)
 Get the color.
 

Variables

const struct pbl_backlight *const BACKLIGHT
 The board's backlight.
 

Backlight colors

Colors for pbl_backlight_set_color(), as 0xRRGGBB.

Not gamma-corrected.

#define BACKLIGHT_COLOR_RED   0xFF0000
 Red.
 
#define BACKLIGHT_COLOR_GREEN   0x00FF00
 Green.
 
#define BACKLIGHT_COLOR_BLUE   0x0000FF
 Blue.
 
#define BACKLIGHT_COLOR_BLACK   0x000000
 Black (off).
 
#define BACKLIGHT_COLOR_WHITE   0xFFFFFF
 White.
 
#define BACKLIGHT_COLOR_WARM_WHITE   0xFFBFA2
 Warm white.
 

Detailed Description

Backlight class.

A backlight is a struct pbl_backlight device. The class keeps the brightness and color last applied, which drivers read from the state. Every call into the driver runs with the device lock held, a recursive mutex.

...
pbl_backlight_set_brightness(BACKLIGHT, 0);
const struct pbl_backlight *const BACKLIGHT
The board's backlight.
int pbl_backlight_set_brightness(const struct pbl_backlight *bl, uint8_t brightness)
Set the brightness.

Data Structure Documentation

◆ pbl_backlight_state

struct pbl_backlight_state

Backlight runtime state.

Data Fields
uint8_t brightness Brightness, 0 (off) to PBL_BACKLIGHT_BRIGHTNESS_MAX.
uint32_t color Color as 0xRRGGBB, on backlights with color.
struct pbl_mutex lock Device lock.

◆ pbl_backlight

struct pbl_backlight

Backlight.

Data Fields
struct pbl_device dev Device.
const struct pbl_backlight_ops * ops Driver operations.
struct pbl_backlight_state * state Runtime state.

Macro Definition Documentation

◆ BACKLIGHT_COLOR_BLACK

#define BACKLIGHT_COLOR_BLACK   0x000000

Black (off).

◆ BACKLIGHT_COLOR_BLUE

#define BACKLIGHT_COLOR_BLUE   0x0000FF

Blue.

◆ BACKLIGHT_COLOR_GREEN

#define BACKLIGHT_COLOR_GREEN   0x00FF00

Green.

◆ BACKLIGHT_COLOR_RED

#define BACKLIGHT_COLOR_RED   0xFF0000

Red.

◆ BACKLIGHT_COLOR_WARM_WHITE

#define BACKLIGHT_COLOR_WARM_WHITE   0xFFBFA2

Warm white.

◆ BACKLIGHT_COLOR_WHITE

#define BACKLIGHT_COLOR_WHITE   0xFFFFFF

White.

◆ PBL_BACKLIGHT_BRIGHTNESS_MAX

#define PBL_BACKLIGHT_BRIGHTNESS_MAX   100U

Maximum brightness.

◆ PBL_BACKLIGHT_INIT

#define PBL_BACKLIGHT_INIT (   sym,
  _name,
  _parent,
  _ops 
)
Value:
{ \
.dev = \
PBL_DEVICE_INIT_CLASS(sym, _name, pbl_backlight_dev_init, _parent, &pbl_backlight_class), \
.ops = (_ops), \
.state = &sym##_backlight_state, \
}

Initialize a struct pbl_backlight.

Parameters
symSymbol of the instance, as passed to PBL_BACKLIGHT_STATE_DEFINE().
_nameDevice name.
_parentParent device.
_opsDriver operations.

◆ PBL_BACKLIGHT_STATE_DEFINE

#define PBL_BACKLIGHT_STATE_DEFINE (   sym)
Value:
static struct pbl_backlight_state sym##_backlight_state = { \
}
struct pbl_mutex lock
Device lock.
Definition backlight.h:72
Backlight runtime state.
Definition backlight.h:70
#define BACKLIGHT_COLOR_WARM_WHITE
Warm white.
Definition backlight.h:44
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50

Define the class state of a backlight.

Parameters
symSymbol of the instance.

Function Documentation

◆ pbl_backlight_get_color()

uint32_t pbl_backlight_get_color ( const struct pbl_backlight *  bl)

Get the color.

Parameters
blBacklight.
Returns
Color as 0xRRGGBB.

◆ pbl_backlight_get_level()

uint8_t pbl_backlight_get_level ( const struct pbl_backlight *  bl,
uint8_t  brightness 
)

Map a brightness to an opaque hardware level identifier.

Two brightness values with the same identifier produce identical output, which lets callers collapse steps the hardware cannot distinguish. Backlights with continuous control return the brightness unchanged.

Parameters
blBacklight.
brightnessBrightness from 0 to PBL_BACKLIGHT_BRIGHTNESS_MAX.
Returns
Hardware level identifier.

◆ pbl_backlight_refresh()

int pbl_backlight_refresh ( const struct pbl_backlight *  bl)

Re-apply the brightness and color to the hardware.

A no-op while the backlight is off, or on drivers that cannot re-apply without a visible glitch.

Parameters
blBacklight.
Returns
0, -ENODEV if the backlight is not ready, or a negative errno.

◆ pbl_backlight_set_brightness()

int pbl_backlight_set_brightness ( const struct pbl_backlight *  bl,
uint8_t  brightness 
)

Set the brightness.

Parameters
blBacklight.
brightnessBrightness from 0 (off) to PBL_BACKLIGHT_BRIGHTNESS_MAX; larger values are clamped.
Returns
0, -ENODEV if the backlight is not ready, or a negative errno.

◆ pbl_backlight_set_color()

int pbl_backlight_set_color ( const struct pbl_backlight *  bl,
uint32_t  rgb_color 
)

Set the color.

Parameters
blBacklight.
rgb_colorColor as 0xRRGGBB, e.g. one of the BACKLIGHT_COLOR_* values.
Returns
0, -ENOTSUP if the backlight has no color, -ENODEV if it is not ready, or a negative errno.

Variable Documentation

◆ BACKLIGHT

const struct pbl_backlight* const BACKLIGHT
extern

The board's backlight.