18 #include <linux/kernel.h>
19 #include <linux/slab.h>
22 #include <linux/module.h>
24 #define FB_SYSFS_FLAG_ATTR 1
41 #define BYTES_PER_LONG (BITS_PER_LONG/8)
42 #define PADDING (BYTES_PER_LONG - (sizeof(struct fb_info) % BYTES_PER_LONG))
43 int fb_info_size =
sizeof(
struct fb_info);
58 info->
par = p + fb_info_size;
62 #ifdef CONFIG_FB_BACKLIGHT
105 static int mode_string(
char *
buf,
unsigned int offset,
128 const char *buf,
size_t count)
139 memset(&var, 0,
sizeof(var));
143 mode = &modelist->
mode;
144 i = mode_string(mstr, 0, mode);
149 if ((err = activate(fb_info, &var)))
166 return mode_string(buf, 0, fb_info->
mode);
169 static ssize_t store_modes(
struct device *device,
171 const char *buf,
size_t count)
181 list_splice(&fb_info->
modelist, &old_list);
186 list_splice(&old_list, &fb_info->
modelist);
207 mode = &modelist->
mode;
208 i += mode_string(buf, i, mode);
214 const char *buf,
size_t count)
223 if ((err =
activate(fb_info, &var)))
235 static ssize_t store_rotate(
struct device *device,
237 const char *buf,
size_t count)
247 if ((err =
activate(fb_info, &var)))
254 static ssize_t show_rotate(
struct device *device,
262 static ssize_t store_virtual(
struct device *device,
264 const char *buf,
size_t count)
274 if (last - buf >= count)
278 if ((err =
activate(fb_info, &var)))
283 static ssize_t show_virtual(
struct device *device,
288 fb_info->
var.yres_virtual);
291 static ssize_t show_stride(
struct device *device,
298 static ssize_t store_blank(
struct device *device,
300 const char *buf,
size_t count)
316 static ssize_t show_blank(
struct device *device,
323 static ssize_t store_console(
struct device *device,
325 const char *buf,
size_t count)
331 static ssize_t show_console(
struct device *device,
338 static ssize_t store_cursor(
struct device *device,
340 const char *buf,
size_t count)
346 static ssize_t show_cursor(
struct device *device,
353 static ssize_t store_pan(
struct device *device,
355 const char *buf,
size_t count)
365 if (last - buf >= count)
378 static ssize_t show_pan(
struct device *device,
383 fb_info->
var.yoffset);
386 static ssize_t show_name(
struct device *device,
394 static ssize_t store_fbstate(
struct device *device,
396 const char *buf,
size_t count)
409 unlock_fb_info(fb_info);
414 static ssize_t show_fbstate(
struct device *device,
421 #ifdef CONFIG_FB_BACKLIGHT
422 static ssize_t store_bl_curve(
struct device *device,
424 const char *buf,
size_t count)
427 u8 tmp_curve[FB_BACKLIGHT_LEVELS];
433 if (!fb_info || !fb_info->bl_dev)
436 if (count != (FB_BACKLIGHT_LEVELS / 8 * 24))
439 for (i = 0; i < (FB_BACKLIGHT_LEVELS / 8); ++
i)
441 "%2hhx %2hhx %2hhx %2hhx %2hhx %2hhx %2hhx %2hhx\n",
442 &tmp_curve[i * 8 + 0],
443 &tmp_curve[i * 8 + 1],
444 &tmp_curve[i * 8 + 2],
445 &tmp_curve[i * 8 + 3],
446 &tmp_curve[i * 8 + 4],
447 &tmp_curve[i * 8 + 5],
448 &tmp_curve[i * 8 + 6],
449 &tmp_curve[i * 8 + 7]) != 8)
456 for (i = 0; i < FB_BACKLIGHT_LEVELS; ++
i)
457 fb_info->bl_curve[i] = tmp_curve[i];
463 static ssize_t show_bl_curve(
struct device *device,
473 if (!fb_info || !fb_info->bl_dev)
477 for (i = 0; i < FB_BACKLIGHT_LEVELS; i += 8)
479 "%02x %02x %02x %02x %02x %02x %02x %02x\n",
480 fb_info->bl_curve[i + 0],
481 fb_info->bl_curve[i + 1],
482 fb_info->bl_curve[i + 2],
483 fb_info->bl_curve[i + 3],
484 fb_info->bl_curve[i + 4],
485 fb_info->bl_curve[i + 5],
486 fb_info->bl_curve[i + 6],
487 fb_info->bl_curve[i + 7]);
510 #ifdef CONFIG_FB_BACKLIGHT
523 for (i = 0; i <
ARRAY_SIZE(device_attrs); i++) {
544 for (i = 0; i <
ARRAY_SIZE(device_attrs); i++)
551 #ifdef CONFIG_FB_BACKLIGHT
564 fb_info->bl_curve[0] = off;
566 for (flat = 1; flat < (FB_BACKLIGHT_LEVELS / 16); ++flat)
567 fb_info->bl_curve[flat] = min;
569 count = FB_BACKLIGHT_LEVELS * 15 / 16;
571 fb_info->bl_curve[flat + i] = min + (range * (i + 1) /
count);