PebbleOS v4.48.0-75-g7416f78a1
Loading...
Searching...
No Matches
GH3X2X

Goodix GH3X2X optical front end. More...

Data Structures

struct  pbl_gh3x2x_reg
 Register write. More...
 
struct  pbl_gh3x2x_slot
 What a slot measures, a channel per photodiode it samples. More...
 
struct  pbl_gh3x2x_setup
 Setup of the optical stack. More...
 
struct  pbl_gh3x2x
 GH3X2X. More...
 

Macros

#define PBL_GH3X2X_MAX_SLOTS   8U
 Most slots of a setup.
 
#define PBL_GH3X2X_NUM_RX   2U
 Photodiodes.
 
#define PBL_GH3X2X_NO_LED   UINT8_MAX
 Slot lighting no LED.
 
#define PBL_GH3X2X_DEFINE(sym, _bus, _addr, ...)
 Define a GH3X2X.
 

Functions

int pbl_gh3x2x_load_setup (const struct pbl_sensor *sensor, const struct pbl_gh3x2x_setup *setup)
 Reset the part and load another setup.
 

Detailed Description

Goodix GH3X2X optical front end.

The driver sets the optical stack up with its own register table (slot timing, LED selection, initial currents and gains): green and infrared LEDs on LED driver 0, red on LED driver 1, two photodiodes. Each slot of the table is a channel per photodiode: green, red and infrared intensity, the infrared light measured for wear detection as proximity, and the ambient light. pbl_gh3x2x_load_setup() loads another table, as for factory tests.

PBL_GH3X2X_DEFINE(s_gh3x2x, &s_i2c4, 0x14,
.irq = PBL_IRQ_SPEC(SF32LB_GPIO1_INTC, 44, PBL_IRQ_TYPE_EDGE_FALLING),
.irq_input = PBL_GPIO(SF32LB_GPIO1, 44, 0),
.reset = PBL_GPIO(&s_npm1300_gpio, 3, PBL_GPIO_ACTIVE_LOW));
#define PBL_GPIO_ACTIVE_LOW
The pin is active when low.
Definition gpio.h:60
#define PBL_GPIO(_port, _pin, _flags)
Initializer for a struct pbl_gpio.
Definition gpio.h:126
#define PBL_IRQ_TYPE_EDGE_FALLING
Falling edge.
Definition intc.h:49
#define PBL_IRQ_SPEC(_intc, _hwirq, _type)
Initializer for a struct pbl_irq_spec.
Definition intc.h:80
#define PBL_GH3X2X_DEFINE(sym, _bus, _addr,...)
Define a GH3X2X.
Definition gh3x2x.h:131

Data Structure Documentation

◆ pbl_gh3x2x_reg

struct pbl_gh3x2x_reg

Register write.

Data Fields
uint16_t addr Address.
uint16_t val Value.

◆ pbl_gh3x2x_slot

struct pbl_gh3x2x_slot

What a slot measures, a channel per photodiode it samples.

Data Fields
uint8_t idx Index of the channel of the first photodiode; the next one has the next index.
uint8_t led LED driver fired, or PBL_GH3X2X_NO_LED.
uint8_t mod Channel modifier, an enum pbl_sensor_mod.
uint8_t rx_mask Photodiodes that can be sampled, as a bitmask.
uint8_t type Channel type, an enum pbl_sensor_type.

◆ pbl_gh3x2x_setup

struct pbl_gh3x2x_setup

Setup of the optical stack.

The table must keep the slot sequence in slot order.

Data Fields
uint16_t num_regs Number of registers in the table.
uint8_t num_slots Number of slots, at most PBL_GH3X2X_MAX_SLOTS.
const struct pbl_gh3x2x_reg * regs Register table, written after a reset.
const struct pbl_gh3x2x_slot * slots Slots set up by the table.

◆ pbl_gh3x2x

struct pbl_gh3x2x

GH3X2X.

Data Fields
struct pbl_i2c_dev i2c I2C device.
struct pbl_irq_spec irq Interrupt line.
struct pbl_gpio irq_input Interrupt line, as an input.
struct pbl_gpio reset Reset line, optional.
struct pbl_sensor sensor Sensor, child of the I2C bus.
struct pbl_gh3x2x_state * state Driver state.

Macro Definition Documentation

◆ PBL_GH3X2X_DEFINE

#define PBL_GH3X2X_DEFINE (   sym,
  _bus,
  _addr,
  ... 
)
Value:
PBL_SENSOR_STREAM_STATE_DEFINE(sym, PBL_GH3X2X_NUM_BUFS, PBL_GH3X2X_BUF_SIZE); \
static struct pbl_gh3x2x_state sym##_gh3x2x_state; \
PBL_DEVICE_INSTANCE(sym, struct pbl_gh3x2x, struct pbl_sensor, sensor) { \
.sensor = PBL_SENSOR_INIT(sym, "gh3x2x", &(_bus)->dev, &pbl_gh3x2x_ops, pbl_gh3x2x_chans, 0U, \
.state = &sym##_gh3x2x_state, .i2c = PBL_I2C_DEV(_bus, _addr), __VA_ARGS__, \
}
#define PBL_I2C_DEV(_bus, _addr)
Initializer for a struct pbl_i2c_dev.
Definition i2c.h:159
A sensor.
Definition driver.h:147
#define PBL_SENSOR_STREAM_STATE_DEFINE(sym, _num_bufs, _buf_size)
Define the class state of streaming sensor sym, with its batch buffers.
Definition driver.h:186
#define PBL_SENSOR_MOUNT_IDENTITY
Identity mounting, for sensors aligned with the device or without vector types.
Definition driver.h:72
#define PBL_SENSOR_INIT(sym, _name, _parent, _ops, _chans, _events,...)
Initializer for the struct pbl_sensor of sensor sym.
Definition driver.h:211
GH3X2X.
Definition gh3x2x.h:103

Define a GH3X2X.

Parameters
symSymbol of the instance, a struct pbl_sensor.
_busI2C bus.
_addr7-bit I2C address.
...Designated initializers of the remaining fields: irq, irq_input and reset.

◆ PBL_GH3X2X_MAX_SLOTS

#define PBL_GH3X2X_MAX_SLOTS   8U

Most slots of a setup.

◆ PBL_GH3X2X_NO_LED

#define PBL_GH3X2X_NO_LED   UINT8_MAX

Slot lighting no LED.

◆ PBL_GH3X2X_NUM_RX

#define PBL_GH3X2X_NUM_RX   2U

Photodiodes.

Function Documentation

◆ pbl_gh3x2x_load_setup()

int pbl_gh3x2x_load_setup ( const struct pbl_sensor *  sensor,
const struct pbl_gh3x2x_setup *  setup 
)

Reset the part and load another setup.

The sensor has to be stopped: no sampling frequency or report latency. Attributes set on the channels are lost, and batches carry the channels of the new setup, which the channel table of the sensor does not list.

Parameters
sensorGH3X2X sensor.
setupSetup, or nullptr for the driver's.
Return values
0On success.
-EBUSYThe sensor is sampling.
-EINVALThe setup has too many slots.
-errnoOther negative errno on failure.