drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c

Source file repositories/reference/linux-study-clean/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c

File Facts

System
Linux kernel
Corpus path
drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
Extension
.c
Size
7753 bytes
Lines
348
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 display_attribute {
	struct attribute attr;
	ssize_t (*show)(struct omap_dss_device *, char *);
	ssize_t	(*store)(struct omap_dss_device *, const char *, size_t);
};

#define DISPLAY_ATTR(_name, _mode, _show, _store) \
	struct display_attribute display_attr_##_name = \
	__ATTR(_name, _mode, _show, _store)

static DISPLAY_ATTR(name, S_IRUGO, display_name_show, NULL);
static DISPLAY_ATTR(display_name, S_IRUGO, display_name_show, NULL);
static DISPLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
		display_enabled_show, display_enabled_store);
static DISPLAY_ATTR(tear_elim, S_IRUGO|S_IWUSR,
		display_tear_show, display_tear_store);
static DISPLAY_ATTR(timings, S_IRUGO|S_IWUSR,
		display_timings_show, display_timings_store);
static DISPLAY_ATTR(rotate, S_IRUGO|S_IWUSR,
		display_rotate_show, display_rotate_store);
static DISPLAY_ATTR(mirror, S_IRUGO|S_IWUSR,
		display_mirror_show, display_mirror_store);
static DISPLAY_ATTR(wss, S_IRUGO|S_IWUSR,
		display_wss_show, display_wss_store);

static struct attribute *display_sysfs_attrs[] = {
	&display_attr_name.attr,
	&display_attr_display_name.attr,
	&display_attr_enabled.attr,
	&display_attr_tear_elim.attr,
	&display_attr_timings.attr,
	&display_attr_rotate.attr,
	&display_attr_mirror.attr,
	&display_attr_wss.attr,
	NULL
};
ATTRIBUTE_GROUPS(display_sysfs);

static ssize_t display_attr_show(struct kobject *kobj, struct attribute *attr,
		char *buf)
{
	struct omap_dss_device *dssdev;
	struct display_attribute *display_attr;

	dssdev = container_of(kobj, struct omap_dss_device, kobj);
	display_attr = container_of(attr, struct display_attribute, attr);

	if (!display_attr->show)
		return -ENOENT;

	return display_attr->show(dssdev, buf);
}

static ssize_t display_attr_store(struct kobject *kobj, struct attribute *attr,
		const char *buf, size_t size)
{
	struct omap_dss_device *dssdev;
	struct display_attribute *display_attr;

	dssdev = container_of(kobj, struct omap_dss_device, kobj);
	display_attr = container_of(attr, struct display_attribute, attr);

	if (!display_attr->store)
		return -ENOENT;

	return display_attr->store(dssdev, buf, size);
}

static const struct sysfs_ops display_sysfs_ops = {
	.show = display_attr_show,
	.store = display_attr_store,
};

static struct kobj_type display_ktype = {
	.sysfs_ops = &display_sysfs_ops,
	.default_groups = display_sysfs_groups,
};

int display_init_sysfs(struct platform_device *pdev)
{
	struct omap_dss_device *dssdev = NULL;
	int r;

	for_each_dss_dev(dssdev) {
		r = kobject_init_and_add(&dssdev->kobj, &display_ktype,
			&pdev->dev.kobj, "%s", dssdev->alias);
		if (r) {
			DSSERR("failed to create sysfs files\n");
			omap_dss_put_device(dssdev);
			goto err;

Annotation

Implementation Notes