X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fvideo%2Ffbsysfs.c;h=34e07399756b4ebd739792dff78abc1114dade2c;hb=9464c7cf61b9433057924c36e6e02f303a00e768;hp=c151dcf68786a1c5ca1987f209e83351db5159d7;hpb=41689045f6a3cbe0550e1d34e9cc20d2e8c432ba;p=linux-2.6.git diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c index c151dcf68..34e073997 100644 --- a/drivers/video/fbsysfs.c +++ b/drivers/video/fbsysfs.c @@ -18,7 +18,6 @@ #include #include #include -#include /** * framebuffer_alloc - creates a new frame buffer info structure @@ -56,10 +55,6 @@ struct fb_info *framebuffer_alloc(size_t size, struct device *dev) info->device = dev; -#ifdef CONFIG_FB_BACKLIGHT - mutex_init(&info->bl_mutex); -#endif - return info; #undef PADDING #undef BYTES_PER_LONG @@ -100,22 +95,13 @@ static int mode_string(char *buf, unsigned int offset, const struct fb_videomode *mode) { char m = 'U'; - char v = 'p'; - if (mode->flag & FB_MODE_IS_DETAILED) m = 'D'; if (mode->flag & FB_MODE_IS_VESA) m = 'V'; if (mode->flag & FB_MODE_IS_STANDARD) m = 'S'; - - if (mode->vmode & FB_VMODE_INTERLACED) - v = 'i'; - if (mode->vmode & FB_VMODE_DOUBLE) - v = 'd'; - - return snprintf(&buf[offset], PAGE_SIZE - offset, "%c:%dx%d%c-%d\n", - m, mode->xres, mode->yres, v, mode->refresh); + return snprintf(&buf[offset], PAGE_SIZE - offset, "%c:%dx%d-%d\n", m, mode->xres, mode->yres, mode->refresh); } static ssize_t store_mode(struct class_device *class_device, const char * buf, @@ -247,6 +233,45 @@ static ssize_t show_rotate(struct class_device *class_device, char *buf) return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate); } +static ssize_t store_con_rotate(struct class_device *class_device, + const char *buf, size_t count) +{ + struct fb_info *fb_info = class_get_devdata(class_device); + int rotate; + char **last = NULL; + + acquire_console_sem(); + rotate = simple_strtoul(buf, last, 0); + fb_con_duit(fb_info, FB_EVENT_SET_CON_ROTATE, &rotate); + release_console_sem(); + return count; +} + +static ssize_t store_con_rotate_all(struct class_device *class_device, + const char *buf, size_t count) +{ + struct fb_info *fb_info = class_get_devdata(class_device); + int rotate; + char **last = NULL; + + acquire_console_sem(); + rotate = simple_strtoul(buf, last, 0); + fb_con_duit(fb_info, FB_EVENT_SET_CON_ROTATE_ALL, &rotate); + release_console_sem(); + return count; +} + +static ssize_t show_con_rotate(struct class_device *class_device, char *buf) +{ + struct fb_info *fb_info = class_get_devdata(class_device); + int rotate; + + acquire_console_sem(); + rotate = fb_con_duit(fb_info, FB_EVENT_GET_CON_ROTATE, NULL); + release_console_sem(); + return snprintf(buf, PAGE_SIZE, "%d\n", rotate); +} + static ssize_t store_virtual(struct class_device *class_device, const char * buf, size_t count) { @@ -389,77 +414,6 @@ static ssize_t show_fbstate(struct class_device *class_device, char *buf) return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state); } -#ifdef CONFIG_FB_BACKLIGHT -static ssize_t store_bl_curve(struct class_device *class_device, - const char *buf, size_t count) -{ - struct fb_info *fb_info = class_get_devdata(class_device); - u8 tmp_curve[FB_BACKLIGHT_LEVELS]; - unsigned int i; - - /* Some drivers don't use framebuffer_alloc(), but those also - * don't have backlights. - */ - if (!fb_info || !fb_info->bl_dev) - return -ENODEV; - - if (count != (FB_BACKLIGHT_LEVELS / 8 * 24)) - return -EINVAL; - - for (i = 0; i < (FB_BACKLIGHT_LEVELS / 8); ++i) - if (sscanf(&buf[i * 24], - "%2hhx %2hhx %2hhx %2hhx %2hhx %2hhx %2hhx %2hhx\n", - &tmp_curve[i * 8 + 0], - &tmp_curve[i * 8 + 1], - &tmp_curve[i * 8 + 2], - &tmp_curve[i * 8 + 3], - &tmp_curve[i * 8 + 4], - &tmp_curve[i * 8 + 5], - &tmp_curve[i * 8 + 6], - &tmp_curve[i * 8 + 7]) != 8) - return -EINVAL; - - /* If there has been an error in the input data, we won't - * reach this loop. - */ - mutex_lock(&fb_info->bl_mutex); - for (i = 0; i < FB_BACKLIGHT_LEVELS; ++i) - fb_info->bl_curve[i] = tmp_curve[i]; - mutex_unlock(&fb_info->bl_mutex); - - return count; -} - -static ssize_t show_bl_curve(struct class_device *class_device, char *buf) -{ - struct fb_info *fb_info = class_get_devdata(class_device); - ssize_t len = 0; - unsigned int i; - - /* Some drivers don't use framebuffer_alloc(), but those also - * don't have backlights. - */ - if (!fb_info || !fb_info->bl_dev) - return -ENODEV; - - mutex_lock(&fb_info->bl_mutex); - for (i = 0; i < FB_BACKLIGHT_LEVELS; i += 8) - len += snprintf(&buf[len], PAGE_SIZE, - "%02x %02x %02x %02x %02x %02x %02x %02x\n", - fb_info->bl_curve[i + 0], - fb_info->bl_curve[i + 1], - fb_info->bl_curve[i + 2], - fb_info->bl_curve[i + 3], - fb_info->bl_curve[i + 4], - fb_info->bl_curve[i + 5], - fb_info->bl_curve[i + 6], - fb_info->bl_curve[i + 7]); - mutex_unlock(&fb_info->bl_mutex); - - return len; -} -#endif - /* When cmap is added back in it should be a binary attribute * not a text one. Consideration should also be given to converting * fbdev to use configfs instead of sysfs */ @@ -475,10 +429,9 @@ static struct class_device_attribute class_device_attrs[] = { __ATTR(name, S_IRUGO, show_name, NULL), __ATTR(stride, S_IRUGO, show_stride, NULL), __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate), + __ATTR(con_rotate, S_IRUGO|S_IWUSR, show_con_rotate, store_con_rotate), + __ATTR(con_rotate_all, S_IWUSR, NULL, store_con_rotate_all), __ATTR(state, S_IRUGO|S_IWUSR, show_fbstate, store_fbstate), -#ifdef CONFIG_FB_BACKLIGHT - __ATTR(bl_curve, S_IRUGO|S_IWUSR, show_bl_curve, store_bl_curve), -#endif }; int fb_init_class_device(struct fb_info *fb_info) @@ -501,25 +454,4 @@ void fb_cleanup_class_device(struct fb_info *fb_info) &class_device_attrs[i]); } -#ifdef CONFIG_FB_BACKLIGHT -/* This function generates a linear backlight curve - * - * 0: off - * 1-7: min - * 8-127: linear from min to max - */ -void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max) -{ - unsigned int i, flat, count, range = (max - min); - fb_info->bl_curve[0] = off; - - for (flat = 1; flat < (FB_BACKLIGHT_LEVELS / 16); ++flat) - fb_info->bl_curve[flat] = min; - - count = FB_BACKLIGHT_LEVELS * 15 / 16; - for (i = 0; i < count; ++i) - fb_info->bl_curve[flat + i] = min + (range * (i + 1) / count); -} -EXPORT_SYMBOL_GPL(fb_bl_default_curve); -#endif