drivers/video/backlight/ili922x.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/ili922x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/ili922x.c- Extension
.c- Size
- 14725 bytes
- Lines
- 552
- Domain
- Driver Families
- Bucket
- drivers/video
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/errno.hlinux/init.hlinux/kernel.hlinux/lcd.hlinux/module.hlinux/of.hlinux/slab.hlinux/spi/spi.hlinux/string.h
Detected Declarations
struct ili922xfunction ili922x_read_statusfunction ili922x_readfunction ili922x_writefunction ili922x_reg_dumpfunction ili922x_reg_dumpfunction ili922x_poweronfunction ili922x_powerofffunction ili922x_display_initfunction ili922x_lcd_powerfunction ili922x_set_powerfunction ili922x_get_powerfunction ili922x_probefunction ili922x_remove
Annotated Snippet
struct ili922x {
struct spi_device *spi;
struct lcd_device *ld;
int power;
};
/**
* ili922x_read_status - read status register from display
* @spi: spi device
* @rs: output value
*/
static int ili922x_read_status(struct spi_device *spi, u16 *rs)
{
struct spi_message msg;
struct spi_transfer xfer;
unsigned char tbuf[CMD_BUFSIZE];
unsigned char rbuf[CMD_BUFSIZE];
int ret, i;
memset(&xfer, 0, sizeof(struct spi_transfer));
spi_message_init(&msg);
xfer.tx_buf = tbuf;
xfer.rx_buf = rbuf;
xfer.cs_change = 1;
CHECK_FREQ_REG(spi, &xfer);
tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_INDEX,
START_RW_READ));
/*
* we need 4-byte xfer here due to invalid dummy byte
* received after start byte
*/
for (i = 1; i < 4; i++)
tbuf[i] = set_tx_byte(0); /* dummy */
xfer.bits_per_word = 8;
xfer.len = 4;
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(spi, &msg);
if (ret < 0) {
dev_dbg(&spi->dev, "Error sending SPI message 0x%x", ret);
return ret;
}
*rs = (rbuf[2] << 8) + rbuf[3];
return 0;
}
/**
* ili922x_read - read register from display
* @spi: spi device
* @reg: offset of the register to be read
* @rx: output value
*/
static int ili922x_read(struct spi_device *spi, u8 reg, u16 *rx)
{
struct spi_message msg;
struct spi_transfer xfer_regindex, xfer_regvalue;
unsigned char tbuf[CMD_BUFSIZE];
unsigned char rbuf[CMD_BUFSIZE];
int ret, len = 0, send_bytes;
memset(&xfer_regindex, 0, sizeof(struct spi_transfer));
memset(&xfer_regvalue, 0, sizeof(struct spi_transfer));
spi_message_init(&msg);
xfer_regindex.tx_buf = tbuf;
xfer_regindex.rx_buf = rbuf;
xfer_regindex.cs_change = 1;
CHECK_FREQ_REG(spi, &xfer_regindex);
tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_INDEX,
START_RW_WRITE));
tbuf[1] = set_tx_byte(0);
tbuf[2] = set_tx_byte(reg);
xfer_regindex.bits_per_word = 8;
len = xfer_regindex.len = 3;
spi_message_add_tail(&xfer_regindex, &msg);
send_bytes = len;
tbuf[len++] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG,
START_RW_READ));
tbuf[len++] = set_tx_byte(0);
tbuf[len] = set_tx_byte(0);
xfer_regvalue.cs_change = 1;
xfer_regvalue.len = 3;
xfer_regvalue.tx_buf = &tbuf[send_bytes];
xfer_regvalue.rx_buf = &rbuf[send_bytes];
CHECK_FREQ_REG(spi, &xfer_regvalue);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/errno.h`, `linux/init.h`, `linux/kernel.h`, `linux/lcd.h`, `linux/module.h`, `linux/of.h`, `linux/slab.h`.
- Detected declarations: `struct ili922x`, `function ili922x_read_status`, `function ili922x_read`, `function ili922x_write`, `function ili922x_reg_dump`, `function ili922x_reg_dump`, `function ili922x_poweron`, `function ili922x_poweroff`, `function ili922x_display_init`, `function ili922x_lcd_power`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.