drivers/video/backlight/omap1_bl.c

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

File Facts

System
Linux kernel
Corpus path
drivers/video/backlight/omap1_bl.c
Extension
.c
Size
3695 bytes
Lines
165
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct omap_backlight {
	bool enabled;
	int current_intensity;

	struct device *dev;
	struct omap_backlight_config *pdata;
};

static inline void omapbl_send_intensity(int intensity)
{
	omap_writeb(intensity, OMAP_PWL_ENABLE);
}

static inline void omapbl_send_enable(int enable)
{
	omap_writeb(enable, OMAP_PWL_CLK_ENABLE);
}

static void omapbl_enable(struct omap_backlight *bl, bool enable)
{
	if (enable) {
		omapbl_send_intensity(bl->current_intensity);
		omapbl_send_enable(1);
	} else {
		omapbl_send_intensity(0);
		omapbl_send_enable(0);
	}
}

#ifdef CONFIG_PM_SLEEP
static int omapbl_suspend(struct device *dev)
{
	struct backlight_device *bl_dev = dev_get_drvdata(dev);
	struct omap_backlight *bl = bl_get_data(bl_dev);

	omapbl_enable(bl, false);
	return 0;
}

static int omapbl_resume(struct device *dev)
{
	struct backlight_device *bl_dev = dev_get_drvdata(dev);
	struct omap_backlight *bl = bl_get_data(bl_dev);

	omapbl_enable(bl, bl->enabled);
	return 0;
}
#endif

static void omapbl_set_enabled(struct backlight_device *dev, bool enable)
{
	struct omap_backlight *bl = bl_get_data(dev);

	omapbl_enable(bl, enable);
	bl->enabled = enable;
}

static int omapbl_update_status(struct backlight_device *dev)
{
	struct omap_backlight *bl = bl_get_data(dev);
	bool enable;

	if (bl->current_intensity != dev->props.brightness) {
		if (bl->enabled)
			omapbl_send_intensity(dev->props.brightness);
		bl->current_intensity = dev->props.brightness;
	}

	enable = !backlight_is_blank(dev);

	if (enable != bl->enabled)
		omapbl_set_enabled(dev, enable);

	return 0;
}

static int omapbl_get_intensity(struct backlight_device *dev)
{
	struct omap_backlight *bl = bl_get_data(dev);

	return bl->current_intensity;
}

static const struct backlight_ops omapbl_ops = {
	.get_brightness = omapbl_get_intensity,
	.update_status  = omapbl_update_status,
};

static int omapbl_probe(struct platform_device *pdev)
{

Annotation

Implementation Notes