2 * output.c - Display Output Switch driver
4 * Copyright (C) 2006 Luming Yu <luming.yu@intel.com>
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 #include <linux/module.h>
25 #include <linux/video_output.h>
26 #include <linux/slab.h>
27 #include <linux/err.h>
28 #include <linux/ctype.h>
31 MODULE_DESCRIPTION("Display Output Switcher Lowlevel Control Abstraction");
32 MODULE_LICENSE("GPL");
33 MODULE_AUTHOR("Luming Yu <luming.yu@intel.com>");
35 static ssize_t video_output_show_state(struct device *dev,
36 struct device_attribute *attr, char *buf)
39 struct output_device *od = to_output_device(dev);
41 ret_size = sprintf(buf,"%.8x\n",od->props->get_status(od));
45 static ssize_t video_output_store_state(struct device *dev,
46 struct device_attribute *attr,
47 const char *buf,size_t count)
50 struct output_device *od = to_output_device(dev);
51 int request_state = simple_strtoul(buf,&endp,0);
52 size_t size = endp - buf;
60 od->request_state = request_state;
61 od->props->set_state(od);
66 static void video_output_release(struct device *dev)
68 struct output_device *od = to_output_device(dev);
72 static struct device_attribute video_output_attributes[] = {
73 __ATTR(state, 0644, video_output_show_state, video_output_store_state),
78 static struct class video_output_class = {
79 .name = "video_output",
80 .dev_release = video_output_release,
81 .dev_attrs = video_output_attributes,
84 struct output_device *video_output_register(const char *name,
87 struct output_properties *op)
89 struct output_device *new_dev;
92 new_dev = kzalloc(sizeof(struct output_device),GFP_KERNEL);
98 new_dev->dev.class = &video_output_class;
99 new_dev->dev.parent = dev;
100 dev_set_name(&new_dev->dev, name);
101 dev_set_drvdata(&new_dev->dev, devdata);
102 ret_code = device_register(&new_dev->dev);
110 return ERR_PTR(ret_code);
112 EXPORT_SYMBOL(video_output_register);
114 void video_output_unregister(struct output_device *dev)
118 device_unregister(&dev->dev);
120 EXPORT_SYMBOL(video_output_unregister);
122 static void __exit video_output_class_exit(void)
124 class_unregister(&video_output_class);
127 static int __init video_output_class_init(void)
129 return class_register(&video_output_class);
132 postcore_initcall(video_output_class_init);
133 module_exit(video_output_class_exit);