4
* Copyright (C) 2011 Texas Instruments.
6
* This file is licensed under the terms of the GNU General Public License
7
* version 2. This program is licensed "as is" without any warranty of any
8
* kind, whether express or implied.
10
* Author: Gustavo Diaz (gusdp@ti.com)
14
#include <linux/version.h>
15
#include <linux/module.h>
16
#include <linux/sysfs.h>
17
#include <linux/platform_device.h>
18
#include <linux/device.h>
19
#include <linux/uaccess.h>
22
#include "servicesext.h"
23
#include "kerneldisplay.h"
26
static ssize_t show_ignore_sync(OMAPLFB_DEVINFO *display_info, char *buf)
28
return snprintf(buf, PAGE_SIZE, "%d\n", display_info->ignore_sync);
31
static ssize_t store_ignore_sync(OMAPLFB_DEVINFO *display_info,
32
const char *buf, size_t count)
34
unsigned long new_value;
36
if (strict_strtoul(buf, 10, &new_value))
39
if (new_value == 0 || new_value == 1) {
40
display_info->ignore_sync = new_value;
47
struct omaplfb_attribute {
48
struct attribute attr;
49
ssize_t (*show)(OMAPLFB_DEVINFO *, char *);
50
ssize_t (*store)(OMAPLFB_DEVINFO *, const char *, size_t);
53
static ssize_t omaplfb_attr_show(struct kobject *kobj, struct attribute *attr,
56
OMAPLFB_DEVINFO *display_info;
57
struct omaplfb_attribute *omaplfb_attr;
59
display_info = container_of(kobj, OMAPLFB_DEVINFO, kobj);
60
omaplfb_attr = container_of(attr, struct omaplfb_attribute, attr);
62
if (!omaplfb_attr->show)
65
return omaplfb_attr->show(display_info, buf);
68
static ssize_t omaplfb_attr_store(struct kobject *kobj, struct attribute *attr,
69
const char *buf, size_t size)
71
OMAPLFB_DEVINFO *display_info;
72
struct omaplfb_attribute *omaplfb_attr;
74
display_info = container_of(kobj, OMAPLFB_DEVINFO, kobj);
75
omaplfb_attr = container_of(attr, struct omaplfb_attribute, attr);
77
if (!omaplfb_attr->store)
80
return omaplfb_attr->store(display_info, buf, size);
83
#define OMAPLFB_ATTR(_name, _mode, _show, _store) \
84
struct omaplfb_attribute omaplfb_attr_##_name = \
85
__ATTR(_name, _mode, _show, _store)
87
static OMAPLFB_ATTR(ignore_sync, S_IRUGO|S_IWUSR, show_ignore_sync,
92
static struct attribute *omaplfb_sysfs_attrs[] = {
93
&omaplfb_attr_ignore_sync.attr,
97
static const struct sysfs_ops omaplfb_sysfs_ops = {
98
.show = omaplfb_attr_show,
99
.store = omaplfb_attr_store,
102
static struct kobj_type omaplfb_ktype = {
103
.sysfs_ops = &omaplfb_sysfs_ops,
104
.default_attrs = omaplfb_sysfs_attrs,
107
void omaplfb_create_sysfs(struct omaplfb_device *odev)
111
/* Create a sysfs entry for every display */
112
for (i = 0; i < odev->display_count; i++) {
113
OMAPLFB_DEVINFO *display_info = &odev->display_info_list[i];
114
r = kobject_init_and_add(&display_info->kobj, &omaplfb_ktype,
115
&odev->dev->kobj, "display%d",
116
display_info->uDeviceID);
118
ERROR_PRINTK("failed to create sysfs file\n");
122
void omaplfb_remove_sysfs(struct omaplfb_device *odev)
125
for (i = 0; i < odev->display_count; i++) {
126
OMAPLFB_DEVINFO *display_info = &odev->display_info_list[i];
127
kobject_del(&display_info->kobj);
128
kobject_put(&display_info->kobj);