平台驱动中 backlight 相关部分

static int ls3a_get_intensity(struct backlight_device * bd)
{
	// 从 EC 获取 backlight 数据

	return ???;
}

static int ls3a_set_intensity(struct backlight_device * bd)
{
	int brightness = bd->props.brightness;

	// 调用 EC 设置 brightness

	return 0;
}

static struct backlight_ops ls3a_backlight_ops =
{
	.get_brightness = ls3a_get_intensity,
	.update_status = ls3a_set_intensity,
};

static int __init ls3a_init(void)
{
	// 注册平台驱动和设备
	platform_driver_register(...);
	platform_device_register(...);

	...

	// 通过 EC 查询 backlight 属性
	...

	// 注册 backlight 设备
	ls3a_backlight_device = backlight_device_register(...);
	...
	// 设置 backlight 设备属性
	ls3a_backlight_device->props.max_brightness = ????; // from EC
	ls3a_backlight_device->props.brightness = ????; // default value
	backlight_update_status(ls3a_backlight_device);	// update

	...

	return 0;
}

static void __exit ls3a_exit(void)
{
	// 注册 backlight 设备
	backlight_device_unregister(ls3a_backlight_device);

	...

	platform_device_unregister(ls3a_device);
	platform_driver_unregister(ls3a_driver);
}

module_init(ls3a_init);
module_exit(ls3a_exit);

Over!

Leave a Reply

Your email address will not be published. Required fields are marked *