From: James S. <jsi...@ac...> - 2000-05-31 14:33:04
|
Sorry for the late response. Been busy with the code. I had teh smae question when I first looked at it. > static u_long get_line_length(int xres_virtual, int bpp) > { > u_long length; > > length = (xres_virtual+bpp-1)/bpp; This returns the number of bytes wide the screen is. For 640 at 8 bpp that would be 640/8 = 80 bytes wide. If we where at 16 bpp we have 640/16 = 40 words wide. Why the above formula? It rounds up the number of we bytes/words/longs we have. It also handles things like 24 bpp very well. Consider so results: 640x480@8 (640+7)/8 = 80 (Stuff after decimal goes away) (640+15)/16 = 40 (640+23)/24 = 27 (640+31)/32 = 20 Take for example if a user tried to set a mode with the x resolution of 643. We have: (643+7)/8 = 81. See it rounded up the number of bytes fo those strange 3 pixels (643+31)/32 = 21 > length = (length+31)&-32; This translates it into the number of 32 bit words. > length >>= 3; Then we translate into bytes. > return(length); > } > -------------------------------- > > What is/should be the return value? 32 bit aligned bytes? Yes. > I thought: > > length = (xres + bpp-1) * bpp; > > would be right. But, as I mentioned, I'm a bit confused ;-) Length is the value that placed in fb_fix-screeninfo line_length which is the number of bytes wide the way th card sees a scanline. Take a voodoo card for example. No matter what mode you set the card in line_length is 1024. So take for example 800x600. We have video memory layed out like this: 0 800 1024 ------------------------------- | | | 0 | | | | | | | | | .... | | | -------------------------------- 600 So the area between 800 and 1024 you can't see. But if you want to draw a rectangle you you draw from say 300 to 500 on the first first line. You of course trnaslate the postion to the byte position in video memory. When you want to go to the next line you have to add the 1024 to 300 translated to a byte position to get to the next line to draw on. You keep adding this 1024 to get to the next line. P.S By the way the CVS is very active even if the mailing list is not. The code is in flux so expect some breakage from time to time. In fact I have to go fix something right now. I will post info later tonight on how to use this kernel. This should go on our web page next. Q: Why did they deprecate a.out support in linux? A: Because a nasty coff is bad for your elf. James Simmons [jsi...@li...] ____/| fbdev/console/gfx developer \ o.O| http://www.linux-fbdev.org =(_)= http://linuxgfx.sourceforge.net U http://linuxconsole.sourceforge.net |