drivers/video/backlight/bd6107.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/bd6107.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/bd6107.c- Extension
.c- Size
- 5616 bytes
- Lines
- 201
- 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/backlight.hlinux/delay.hlinux/err.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/platform_data/bd6107.hlinux/slab.h
Detected Declarations
struct bd6107function bd6107_writefunction bd6107_backlight_update_statusfunction bd6107_backlight_controls_devicefunction bd6107_probefunction bd6107_remove
Annotated Snippet
struct bd6107 {
struct i2c_client *client;
struct backlight_device *backlight;
struct bd6107_platform_data *pdata;
struct gpio_desc *reset;
};
static int bd6107_write(struct bd6107 *bd, u8 reg, u8 data)
{
return i2c_smbus_write_byte_data(bd->client, reg, data);
}
static int bd6107_backlight_update_status(struct backlight_device *backlight)
{
struct bd6107 *bd = bl_get_data(backlight);
int brightness = backlight_get_brightness(backlight);
if (brightness) {
bd6107_write(bd, BD6107_PORTSEL, BD6107_PORTSEL_LEDM(2) |
BD6107_PORTSEL_LEDM(1) | BD6107_PORTSEL_LEDM(0));
bd6107_write(bd, BD6107_MAINCNT1, brightness);
bd6107_write(bd, BD6107_LEDCNT1, BD6107_LEDCNT1_LEDONOFF1);
} else {
/* Assert the reset line (gpiolib will handle active low) */
gpiod_set_value(bd->reset, 1);
msleep(24);
gpiod_set_value(bd->reset, 0);
}
return 0;
}
static bool bd6107_backlight_controls_device(struct backlight_device *backlight,
struct device *display_dev)
{
struct bd6107 *bd = bl_get_data(backlight);
return !bd->pdata->dev || bd->pdata->dev == display_dev;
}
static const struct backlight_ops bd6107_backlight_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = bd6107_backlight_update_status,
.controls_device = bd6107_backlight_controls_device,
};
static int bd6107_probe(struct i2c_client *client)
{
struct bd6107_platform_data *pdata = dev_get_platdata(&client->dev);
struct backlight_device *backlight;
struct backlight_properties props;
struct bd6107 *bd;
if (pdata == NULL) {
dev_err(&client->dev, "No platform data\n");
return -EINVAL;
}
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_BYTE_DATA)) {
dev_warn(&client->dev,
"I2C adapter doesn't support I2C_FUNC_SMBUS_BYTE\n");
return -EIO;
}
bd = devm_kzalloc(&client->dev, sizeof(*bd), GFP_KERNEL);
if (!bd)
return -ENOMEM;
bd->client = client;
bd->pdata = pdata;
/*
* Request the reset GPIO line with GPIOD_OUT_HIGH meaning asserted,
* so in the machine descriptor table (or other hardware description),
* the line should be flagged as active low so this will assert
* the reset.
*/
bd->reset = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(bd->reset))
return dev_err_probe(&client->dev, PTR_ERR(bd->reset),
"unable to request reset GPIO\n");
memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_RAW;
props.max_brightness = 128;
props.brightness = clamp_t(unsigned int, pdata->def_value, 0,
props.max_brightness);
backlight = devm_backlight_device_register(&client->dev,
Annotation
- Immediate include surface: `linux/backlight.h`, `linux/delay.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/platform_data/bd6107.h`, `linux/slab.h`.
- Detected declarations: `struct bd6107`, `function bd6107_write`, `function bd6107_backlight_update_status`, `function bd6107_backlight_controls_device`, `function bd6107_probe`, `function bd6107_remove`.
- 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.