Goodix GH3X2X optical front end.
More...
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.
.irq_input =
PBL_GPIO(SF32LB_GPIO1, 44, 0),
#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
◆ pbl_gh3x2x_reg
| Data Fields |
|
uint16_t |
addr |
Address. |
|
uint16_t |
val |
Value. |
◆ 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
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
| 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. |
◆ PBL_GH3X2X_DEFINE
| #define PBL_GH3X2X_DEFINE |
( |
|
sym, |
|
|
|
_bus, |
|
|
|
_addr, |
|
|
|
... |
|
) |
| |
Value:
static struct pbl_gh3x2x_state sym##_gh3x2x_state; \
.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
-
| sym | Symbol of the instance, a struct pbl_sensor. |
| _bus | I2C bus. |
| _addr | 7-bit I2C address. |
| ... | Designated initializers of the remaining fields: irq, irq_input and reset. |
◆ PBL_GH3X2X_MAX_SLOTS
| #define PBL_GH3X2X_MAX_SLOTS 8U |
◆ PBL_GH3X2X_NO_LED
| #define PBL_GH3X2X_NO_LED UINT8_MAX |
◆ PBL_GH3X2X_NUM_RX
| #define PBL_GH3X2X_NUM_RX 2U |
◆ pbl_gh3x2x_load_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
-
| sensor | GH3X2X sensor. |
| setup | Setup, or nullptr for the driver's. |
- Return values
-
| 0 | On success. |
| -EBUSY | The sensor is sampling. |
| -EINVAL | The setup has too many slots. |
| -errno | Other negative errno on failure. |