drivers/video/backlight/lcd.c

Source file repositories/reference/linux-study-clean/drivers/video/backlight/lcd.c

File Facts

System
Linux kernel
Corpus path
drivers/video/backlight/lcd.c
Extension
.c
Size
8363 bytes
Lines
348
Domain
Driver Families
Bucket
drivers/video
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-only
/*
 * LCD Lowlevel Control Abstraction
 *
 * Copyright (C) 2003,2004 Hewlett-Packard Company
 *
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/lcd.h>
#include <linux/notifier.h>
#include <linux/ctype.h>
#include <linux/err.h>
#include <linux/slab.h>

static DEFINE_MUTEX(lcd_dev_list_mutex);
static LIST_HEAD(lcd_dev_list);

static void lcd_notify_blank(struct lcd_device *ld, struct device *display_dev,
			     int power)
{
	guard(mutex)(&ld->ops_lock);

	if (!ld->ops || !ld->ops->set_power)
		return;
	if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev))
		return;

	ld->ops->set_power(ld, power);
}

void lcd_notify_blank_all(struct device *display_dev, int power)
{
	struct lcd_device *ld;

	guard(mutex)(&lcd_dev_list_mutex);

	list_for_each_entry(ld, &lcd_dev_list, entry)
		lcd_notify_blank(ld, display_dev, power);
}
EXPORT_SYMBOL(lcd_notify_blank_all);

static void lcd_notify_mode_change(struct lcd_device *ld, struct device *display_dev,
				   unsigned int width, unsigned int height)
{
	guard(mutex)(&ld->ops_lock);

	if (!ld->ops || !ld->ops->set_mode)
		return;
	if (ld->ops->controls_device && !ld->ops->controls_device(ld, display_dev))
		return;

	ld->ops->set_mode(ld, width, height);
}

void lcd_notify_mode_change_all(struct device *display_dev,
				unsigned int width, unsigned int height)
{
	struct lcd_device *ld;

	guard(mutex)(&lcd_dev_list_mutex);

	list_for_each_entry(ld, &lcd_dev_list, entry)
		lcd_notify_mode_change(ld, display_dev, width, height);
}
EXPORT_SYMBOL(lcd_notify_mode_change_all);

static ssize_t lcd_power_show(struct device *dev, struct device_attribute *attr,
		char *buf)
{
	int rc;
	struct lcd_device *ld = to_lcd_device(dev);

	mutex_lock(&ld->ops_lock);
	if (ld->ops && ld->ops->get_power)
		rc = sprintf(buf, "%d\n", ld->ops->get_power(ld));
	else
		rc = -ENXIO;
	mutex_unlock(&ld->ops_lock);

	return rc;
}

static ssize_t lcd_power_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{

Annotation

Implementation Notes