aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/console/fbcon.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/console/fbcon.c')
-rw-r--r--drivers/video/console/fbcon.c113
1 files changed, 105 insertions, 8 deletions
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 47ba1a79adcd..746225bf8c44 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -195,6 +195,8 @@ static void fbcon_redraw_move(struct vc_data *vc, struct display *p,
195static void fbcon_modechanged(struct fb_info *info); 195static void fbcon_modechanged(struct fb_info *info);
196static void fbcon_set_all_vcs(struct fb_info *info); 196static void fbcon_set_all_vcs(struct fb_info *info);
197 197
198static struct class_device *fbcon_class_device;
199
198#ifdef CONFIG_MAC 200#ifdef CONFIG_MAC
199/* 201/*
200 * On the Macintoy, there may or may not be a working VBL int. We need to probe 202 * On the Macintoy, there may or may not be a working VBL int. We need to probe
@@ -2945,14 +2947,6 @@ static int fbcon_event_notify(struct notifier_block *self,
2945 case FB_EVENT_NEW_MODELIST: 2947 case FB_EVENT_NEW_MODELIST:
2946 fbcon_new_modelist(info); 2948 fbcon_new_modelist(info);
2947 break; 2949 break;
2948 case FB_EVENT_SET_CON_ROTATE:
2949 fbcon_rotate(info, *(int *)event->data);
2950 break;
2951 case FB_EVENT_GET_CON_ROTATE:
2952 ret = fbcon_get_rotate(info);
2953 break;
2954 case FB_EVENT_SET_CON_ROTATE_ALL:
2955 fbcon_rotate_all(info, *(int *)event->data);
2956 } 2950 }
2957 2951
2958 return ret; 2952 return ret;
@@ -2992,6 +2986,81 @@ static struct notifier_block fbcon_event_notifier = {
2992 .notifier_call = fbcon_event_notify, 2986 .notifier_call = fbcon_event_notify,
2993}; 2987};
2994 2988
2989static ssize_t store_rotate(struct class_device *class_device,
2990 const char *buf, size_t count)
2991{
2992 struct fb_info *info;
2993 int rotate, idx;
2994 char **last = NULL;
2995
2996 acquire_console_sem();
2997 idx = con2fb_map[fg_console];
2998
2999 if (idx == -1 || registered_fb[idx] == NULL)
3000 goto err;
3001
3002 info = registered_fb[idx];
3003 rotate = simple_strtoul(buf, last, 0);
3004 fbcon_rotate(info, rotate);
3005err:
3006 release_console_sem();
3007 return count;
3008}
3009
3010static ssize_t store_rotate_all(struct class_device *class_device,
3011 const char *buf, size_t count)
3012{
3013 struct fb_info *info;
3014 int rotate, idx;
3015 char **last = NULL;
3016
3017 acquire_console_sem();
3018 idx = con2fb_map[fg_console];
3019
3020 if (idx == -1 || registered_fb[idx] == NULL)
3021 goto err;
3022
3023 info = registered_fb[idx];
3024 rotate = simple_strtoul(buf, last, 0);
3025 fbcon_rotate_all(info, rotate);
3026err:
3027 release_console_sem();
3028 return count;
3029}
3030
3031static ssize_t show_rotate(struct class_device *class_device, char *buf)
3032{
3033 struct fb_info *info;
3034 int rotate = 0, idx;
3035
3036 acquire_console_sem();
3037 idx = con2fb_map[fg_console];
3038
3039 if (idx == -1 || registered_fb[idx] == NULL)
3040 goto err;
3041
3042 info = registered_fb[idx];
3043 rotate = fbcon_get_rotate(info);
3044err:
3045 release_console_sem();
3046 return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
3047}
3048
3049static struct class_device_attribute class_device_attrs[] = {
3050 __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate),
3051 __ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all),
3052};
3053
3054static int fbcon_init_class_device(void)
3055{
3056 int i;
3057
3058 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
3059 class_device_create_file(fbcon_class_device,
3060 &class_device_attrs[i]);
3061 return 0;
3062}
3063
2995static int __init fb_console_init(void) 3064static int __init fb_console_init(void)
2996{ 3065{
2997 int i; 3066 int i;
@@ -3000,6 +3069,18 @@ static int __init fb_console_init(void)
3000 fb_register_client(&fbcon_event_notifier); 3069 fb_register_client(&fbcon_event_notifier);
3001 release_console_sem(); 3070 release_console_sem();
3002 3071
3072 fbcon_class_device =
3073 class_device_create(fb_class, NULL,
3074 MKDEV(FB_MAJOR, FB_MAX), NULL,
3075 "fbcon");
3076 if (IS_ERR(fbcon_class_device)) {
3077 printk(KERN_WARNING "Unable to create class_device "
3078 "for fbcon; errno = %ld\n",
3079 PTR_ERR(fbcon_class_device));
3080 fbcon_class_device = NULL;
3081 } else
3082 fbcon_init_class_device();
3083
3003 for (i = 0; i < MAX_NR_CONSOLES; i++) 3084 for (i = 0; i < MAX_NR_CONSOLES; i++)
3004 con2fb_map[i] = -1; 3085 con2fb_map[i] = -1;
3005 3086
@@ -3020,10 +3101,26 @@ module_init(fb_console_init);
3020 3101
3021#ifdef MODULE 3102#ifdef MODULE
3022 3103
3104static void __exit fbcon_deinit_class_device(void)
3105{
3106 int i;
3107
3108 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
3109 class_device_remove_file(fbcon_class_device,
3110 &class_device_attrs[i]);
3111}
3112
3113static void __exit fbcon_exit(void)
3114{
3115 fbcon_deinit_class_device();
3116 class_device_destroy(fb_class, MKDEV(FB_MAJOR, FB_MAX));
3117}
3118
3023static void __exit fb_console_exit(void) 3119static void __exit fb_console_exit(void)
3024{ 3120{
3025 acquire_console_sem(); 3121 acquire_console_sem();
3026 fb_unregister_client(&fbcon_event_notifier); 3122 fb_unregister_client(&fbcon_event_notifier);
3123 fbcon_exit();
3027 release_console_sem(); 3124 release_console_sem();
3028 give_up_console(&fb_con); 3125 give_up_console(&fb_con);
3029} 3126}