From: Kronos <kronos@people.it>
To: linux-fbdev-devel@lists.sourceforge.net
Subject: Re: [PATCH][RFC][2/3] mode attribute in sysfs tree
Date: Wed, 16 Jun 2004 11:30:32 +0200 [thread overview]
Message-ID: <20040616093032.GC3556@dreamland.darkstar.lan> (raw)
In-Reply-To: <20040615172138.GA8823@dreamland.darkstar.lan>
fb_show_mode function and FB_MODE_ATTR macro.
diff -Nru -X dontdiff linux-2.6-vanilla/drivers/video/fbsysfs.c linux-2.6/drivers/video/fbsysfs.c
--- linux-2.6-vanilla/drivers/video/fbsysfs.c 2004-02-28 13:32:58.000000000 +0100
+++ linux-2.6/drivers/video/fbsysfs.c 2004-06-14 17:34:15.000000000 +0200
@@ -70,5 +70,32 @@
kfree(info);
}
+ssize_t fb_show_mode(struct class_device *class_dev, char * buf) {
+ struct fb_info *info = class_get_devdata(class_dev);
+ struct fb_var_screeninfo *var = &info->var;
+
+ u32 htotal = var->xres + var->upper_margin + var->lower_margin + var->hsync_len;
+ u32 vtotal = var->yres + var->left_margin + var->right_margin + var->vsync_len;
+
+ if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
+ vtotal = vtotal << 2;
+ else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED)
+ vtotal = vtotal << 1;
+
+ /*
+ * This should be:
+ * 1000000000000
+ * ------------------------------- * 2
+ * var->pixclock * htotal * vtotal
+ *
+ * we divide numerator and pixclock by 1000 so the expression does not overflow.
+ */
+ u32 refresh = 1000000000UL / ((var->pixclock / 1000) * htotal * vtotal) * 2;
+
+ return snprintf(buf, PAGE_SIZE, "%ux%u-%u@%u\n", var->xres, var->yres,
+ var->bits_per_pixel, refresh);
+}
+
+EXPORT_SYMBOL(fb_show_mode);
EXPORT_SYMBOL(framebuffer_release);
EXPORT_SYMBOL(framebuffer_alloc);
diff -Nru -X dontdiff linux-2.6-vanilla/include/linux/fb.h linux-2.6/include/linux/fb.h
--- linux-2.6-vanilla/include/linux/fb.h 2004-06-15 15:38:40.000000000 +0200
+++ linux-2.6/include/linux/fb.h 2004-06-14 17:34:28.000000000 +0200
@@ -611,6 +611,15 @@
/* drivers/video/fbsysfs.c */
extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
extern void framebuffer_release(struct fb_info *info);
+extern ssize_t fb_show_mode(struct class_device *class_dev, char * buf);
+
+#define FB_MODE_ATTR(_name) \
+struct class_device_attribute _name = { \
+ .attr = {.name = "mode", .mode = 0444, .owner = THIS_MODULE }, \
+ .show = fb_show_mode, \
+ .store = NULL, \
+};
+
/* drivers/video/fbmon.c */
#define FB_MAXTIMINGS 0
Luca
--
Home: http://kronoz.cjb.net
Not an editor command: Wq
-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
next prev parent reply other threads:[~2004-06-16 9:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-15 17:21 [PATCH][RFC][0/3] mode attribute in sysfs tree Kronos
2004-06-16 2:43 ` Antonino A. Daplas
2004-06-16 9:28 ` [PATCH][RFC][1/3] " Kronos
2004-06-16 9:30 ` Kronos [this message]
2004-06-16 9:32 ` [PATCH][RFC][3/3] " Kronos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040616093032.GC3556@dreamland.darkstar.lan \
--to=kronos@people.it \
--cc=linux-fbdev-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).