drivers/video/backlight/jornada720_bl.c

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

File Facts

System
Linux kernel
Corpus path
drivers/video/backlight/jornada720_bl.c
Extension
.c
Size
3577 bytes
Lines
151
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

if (ret != TXDUMMY) {
			dev_info(&bd->dev, "brightness off timeout\n");
			/* turn off backlight */
			PPSR &= ~PPC_LDD1;
			PPDR |= PPC_LDD1;
			ret = -ETIMEDOUT;
		}
	} else  /* turn on backlight */
		PPSR |= PPC_LDD1;

	/* send command to our mcu */
	if (jornada_ssp_byte(SETBRIGHTNESS) != TXDUMMY) {
		dev_info(&bd->dev, "failed to set brightness\n");
		ret = -ETIMEDOUT;
		goto out;
	}

	/*
	 * at this point we expect that the mcu has accepted
	 * our command and is waiting for our new value
	 * please note that maximum brightness is 255,
	 * but due to physical layout it is equal to 0, so we simply
	 * invert the value (MAX VALUE - NEW VALUE).
	 */
	if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness)
		!= TXDUMMY) {
		dev_err(&bd->dev, "set brightness failed\n");
		ret = -ETIMEDOUT;
	}

	/*
	 * If infact we get an TXDUMMY as output we are happy and dont
	 * make any further comments about it
	 */
out:
	jornada_ssp_end();

	return ret;
}

static const struct backlight_ops jornada_bl_ops = {
	.get_brightness = jornada_bl_get_brightness,
	.update_status = jornada_bl_update_status,
	.options = BL_CORE_SUSPENDRESUME,
};

static int jornada_bl_probe(struct platform_device *pdev)
{
	struct backlight_properties props;
	int ret;
	struct backlight_device *bd;

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = BL_MAX_BRIGHT;

	bd = devm_backlight_device_register(&pdev->dev, S1D_DEVICENAME,
					&pdev->dev, NULL, &jornada_bl_ops,
					&props);
	if (IS_ERR(bd)) {
		ret = PTR_ERR(bd);
		dev_err(&pdev->dev, "failed to register device, err=%x\n", ret);
		return ret;
	}

	bd->props.power = BACKLIGHT_POWER_ON;
	bd->props.brightness = BL_DEF_BRIGHT;
	/*
	 * note. make sure max brightness is set otherwise
	 * you will get seemingly non-related errors when
	 * trying to change brightness
	 */
	jornada_bl_update_status(bd);

	platform_set_drvdata(pdev, bd);
	dev_info(&pdev->dev, "HP Jornada 700 series backlight driver\n");

	return 0;
}

static struct platform_driver jornada_bl_driver = {
	.probe		= jornada_bl_probe,
	.driver	= {
		.name	= "jornada_bl",
	},
};

module_platform_driver(jornada_bl_driver);

MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson>");

Annotation

Implementation Notes