int Vesa_Install(char **Arguments);\r
Uint64 Vesa_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);\r
Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);\r
- int Vesa_Ioctl(tVFS_Node *Node, int ID, void *Data);\r
+ int Vesa_IOCtl(tVFS_Node *Node, int ID, void *Data);\r
int Vesa_Int_SetMode(int Mode);\r
int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data);\r
int Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data);\r
{\r
.Read = Vesa_Read,\r
.Write = Vesa_Write,\r
- .IOCtl = Vesa_Ioctl\r
+ .IOCtl = Vesa_IOCtl\r
}\r
};\r
tMutex glVesa_Lock;\r
int giVesaDriverId = -1;\r
// --- Video Modes ---\r
int giVesaCurrentMode = 0;\r
- int giVesaCurrentFormat = VIDEO_BUFFMT_TEXT;\r
tVesa_Mode *gVesa_Modes;\r
tVesa_Mode *gpVesaCurMode;\r
int giVesaModeCount = 0;\r
Vesa_2D_Fill,\r
Vesa_2D_Blit\r
};\r
+tDrvUtil_Video_BufInfo gVesa_BufInfo;\r
\r
// === CODE ===\r
int Vesa_Install(char **Arguments)\r
*/\r
Uint64 Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)\r
{\r
- ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);\r
-\r
- if(Buffer == NULL) {\r
- LEAVE('i', 0);\r
- return 0;\r
- }\r
-\r
- // Default Text mode\r
- if( giVesaCurrentMode == 0 )\r
- {\r
- Uint16 *fb = (Uint16*)(KERNEL_BASE|0xB8000);\r
- tVT_Char *chars = Buffer;\r
- int rem;\r
- \r
- Length /= sizeof(tVT_Char);\r
- Offset /= sizeof(tVT_Char);\r
- \r
- if( giVesaCurrentFormat != VIDEO_BUFFMT_TEXT ) {\r
- Log_Warning("VESA", "Vesa_Write - Mode 0 is not framebuffer");\r
- LEAVE('i', -1);\r
- return -1;\r
- }\r
- \r
- if( Offset + Length > 25*80 ) {\r
- Log_Warning("VESA", "Vesa_Write - Framebuffer Overflow");\r
- LEAVE('i', 0);\r
- return 0;\r
- }\r
- \r
- fb += 2*Offset;\r
- LOG("fb = %p", fb);\r
- for(rem = Length; rem --; fb ++, chars++)\r
- {\r
- if( chars->Ch < 0x80 )\r
- *fb = chars->Ch & 0x7F;\r
- else\r
- *fb = 0x00;\r
- \r
- *fb |= (chars->FGCol & 0x888) == 0x888 ? 0x8 : 0;\r
- *fb |= (chars->FGCol & 0x700) > 0x300 ? 0x4 : 0;\r
- *fb |= (chars->FGCol & 0x070) > 0x030 ? 0x2 : 0;\r
- *fb |= (chars->FGCol & 0x007) > 0x003 ? 0x1 : 0;\r
- *fb |= (chars->BGCol & 0x888) == 0x888 ? 0x80 : 0;\r
- *fb |= (chars->BGCol & 0x700) > 0x300 ? 0x40 : 0;\r
- *fb |= (chars->BGCol & 0x070) > 0x030 ? 0x20 : 0;\r
- *fb |= (chars->BGCol & 0x007) > 0x003 ? 0x10 : 0;\r
- //LOG("%08x (%03x,%03x) = %04x",\r
- // chars->Ch, chars->BGCol, chars->FGCol, *fb);\r
- }\r
- Length *= sizeof(tVT_Char);\r
- LEAVE('X', Length);\r
- return Length;\r
- }\r
-\r
if( gVesa_Modes[giVesaCurrentMode].framebuffer == 0 ) {\r
Log_Warning("VESA", "Vesa_Write - Non-LFB Modes not yet supported.");\r
- LEAVE('i', 0);\r
return 0;\r
}\r
- \r
- // Text Mode\r
- switch( giVesaCurrentFormat )\r
- {\r
- case VIDEO_BUFFMT_TEXT:\r
- {\r
- tVT_Char *chars = Buffer;\r
- int pitch = gVesa_Modes[giVesaCurrentMode].pitch;\r
- int depth = gVesa_Modes[giVesaCurrentMode].bpp;\r
- int bytes_per_px = gVesa_Modes[giVesaCurrentMode].bpp / 8;\r
- int widthInChars = gVesa_Modes[giVesaCurrentMode].width/giVT_CharWidth;\r
- int heightInChars = gVesa_Modes[giVesaCurrentMode].height/giVT_CharHeight;\r
- int x, y;\r
- Uint8 *dest = (void*)gpVesa_Framebuffer;\r
- int i;\r
- \r
- Length /= sizeof(tVT_Char);\r
- Offset /= sizeof(tVT_Char);\r
- \r
- if( depth == 32 ) depth = 24; // Actually 24-colour bits\r
- \r
- LOG("gVesa_Modes[%i] = {height:%i, width:%i, pitch:%i}",\r
- giVesaCurrentMode,\r
- gVesa_Modes[giVesaCurrentMode].height,\r
- gVesa_Modes[giVesaCurrentMode].width,\r
- gVesa_Modes[giVesaCurrentMode].pitch\r
- );\r
- x = Offset % widthInChars;\r
- y = Offset / widthInChars;\r
- LOG("(x,y) = (%i,%i) = [%i,%i]",\r
- x,\r
- y,\r
- x * giVT_CharWidth * bytes_per_px,\r
- y * giVT_CharHeight * pitch\r
- );\r
- LOG("(w,h) = (%i,%i) = [%i,%i]",\r
- (int)(Length % widthInChars),\r
- (int)(Length / widthInChars),\r
- (int)((Length % widthInChars) * giVT_CharWidth * bytes_per_px),\r
- (int)((Length / widthInChars) * giVT_CharHeight * pitch)\r
- );\r
- \r
- // Sanity Check\r
- if( Offset > (Uint64)(heightInChars*widthInChars) ) {\r
- LEAVE('i', 0);\r
- return 0;\r
- }\r
- if(y >= heightInChars) {\r
- LEAVE('i', 0);\r
- return 0;\r
- }\r
- \r
- \r
- if( (int)Offset + (int)Length > heightInChars*widthInChars ) {\r
- Log_Debug("VESA", "%i + %i > %i*%i (%i)",\r
- (int)Offset, (int)Length, heightInChars, widthInChars, heightInChars*widthInChars);\r
- Length = heightInChars*widthInChars - Offset;\r
- Log_Notice("VESA", "Clipping write size to %i characters", (int)Length);\r
- }\r
- \r
- dest += y * giVT_CharHeight * pitch;\r
- \r
- LOG("dest = %p", dest);\r
- \r
- for( i = 0; i < (int)Length; i++ )\r
- {\r
- if(\r
- !MM_GetPhysAddr( (tVAddr)dest + x*giVT_CharWidth*bytes_per_px )\r
- // || !MM_GetPhysAddr( (tVAddr)dest + x*giVT_CharWidth*depth/8 + pitch*giVT_CharHeight-1)\r
- )\r
- {\r
- Log_Notice("VESA", "Stopped at %i, not mapped", i);\r
- break;\r
- }\r
- if( y >= heightInChars )\r
- {\r
- Log_Notice("VESA", "Stopped at %i", i);\r
- break;\r
- }\r
- \r
- VT_Font_Render(\r
- chars->Ch,\r
- dest + x*giVT_CharWidth*bytes_per_px, bytes_per_px*8, pitch,\r
- VT_Colour12toN(chars->BGCol, depth),\r
- VT_Colour12toN(chars->FGCol, depth)\r
- );\r
- \r
- chars ++;\r
- x ++;\r
- if( x >= widthInChars )\r
- {\r
- x = 0;\r
- y ++;\r
- dest += pitch*giVT_CharHeight;\r
- }\r
- }\r
- Length = i * sizeof(tVT_Char);\r
- }\r
- break;\r
- \r
- case VIDEO_BUFFMT_FRAMEBUFFER:\r
- {\r
- Uint8 *destBuf = (Uint8*) ((Uint)gpVesa_Framebuffer + (Uint)Offset);\r
- \r
- if(gVesa_Modes[giVesaCurrentMode].fbSize < Offset+Length)\r
- {\r
- Log_Warning("VESA", "Vesa_Write - Framebuffer Overflow");\r
- LEAVE('i', 0);\r
- return 0;\r
- }\r
- \r
- LOG("buffer = %p", Buffer);\r
- LOG("Updating Framebuffer (%p to %p)", destBuf, destBuf + (Uint)Length);\r
- \r
- //TODO: Handle non 32-bpp framebuffer modes\r
- \r
- // Copy to Frambuffer\r
- memcpy(destBuf, Buffer, Length);\r
- \r
- LOG("BGA Framebuffer updated");\r
- }\r
- break;\r
- \r
- case VIDEO_BUFFMT_2DSTREAM:\r
- Length = DrvUtil_Video_2DStream(\r
- NULL, // Single framebuffer, so Ent is unused\r
- Buffer, Length, &gVesa_2DFunctions, sizeof(gVesa_2DFunctions)\r
- );\r
- break;\r
- \r
- default:\r
- LEAVE('i', -1);\r
- return -1;\r
- }\r
- \r
- LEAVE('X', Length);\r
- return Length;\r
+\r
+ return DrvUtil_Video_WriteLFB(&gVesa_BufInfo, Offset, Length, Buffer);\r
}\r
\r
+const char *csaVESA_IOCtls[] = {DRV_IOCTLNAMES, DRV_VIDEO_IOCTLNAMES, NULL};\r
/**\r
- * \fn int Vesa_Ioctl(vfs_node *node, int id, void *data)\r
* \brief Handle messages to the device\r
*/\r
-int Vesa_Ioctl(tVFS_Node *Node, int ID, void *Data)\r
+int Vesa_IOCtl(tVFS_Node *Node, int ID, void *Data)\r
{\r
int ret;\r
//Log_Debug("VESA", "Vesa_Ioctl: (Node=%p, ID=%i, Data=%p)", Node, ID, Data);\r
switch(ID)\r
{\r
- case DRV_IOCTL_TYPE: return DRV_TYPE_VIDEO;\r
- case DRV_IOCTL_IDENT: memcpy("VESA", Data, 4); return 1;\r
- case DRV_IOCTL_VERSION: return VERSION;\r
- \r
+ BASE_IOCTLS(DRV_TYPE_VIDEO, "VESA", VERSION, csaVESA_IOCtls);\r
+\r
case VIDEO_IOCTL_GETSETMODE:\r
if( !Data ) return giVesaCurrentMode;\r
return Vesa_Int_SetMode( *(int*)Data );\r
return Vesa_Int_ModeInfo((tVideo_IOCtl_Mode*)Data);\r
\r
case VIDEO_IOCTL_SETBUFFORMAT:\r
- ret = giVesaCurrentFormat;\r
- if(Data) giVesaCurrentFormat = *(int*)Data;\r
+ ret = gVesa_BufInfo.BufferFormat;\r
+ if(Data) gVesa_BufInfo.BufferFormat = *(int*)Data;\r
return ret;\r
\r
case VIDEO_IOCTL_SETCURSOR: // Set cursor position\r
#if !BLINKING_CURSOR\r
- if(giVesaCursorX > 0)\r
+ if(giVesaCursorX >= 0)\r
Vesa_FlipCursor(Node);\r
#endif\r
giVesaCursorX = ((tVideo_IOCtl_Pos*)Data)->x;\r
}\r
//Log_Debug("VESA", "Cursor position (%i,%i) Timer %i", giVesaCursorX, giVesaCursorY, giVesaCursorTimer);\r
return 0;\r
- \r
-// case VIDEO_IOCTL_REQLFB: // Request Linear Framebuffer\r
-// return 0;\r
}\r
return 0;\r
}\r
gpVesaCurMode = &gVesa_Modes[giVesaCurrentMode];\r
\r
Mutex_Release( &glVesa_Lock );\r
- \r
+\r
+ gVesa_BufInfo.Framebuffer = gpVesa_Framebuffer;\r
+ gVesa_BufInfo.Pitch = gVesa_Modes[mode].pitch;\r
+ gVesa_BufInfo.Width = gVesa_Modes[mode].width;\r
+ gVesa_BufInfo.Height = gVesa_Modes[mode].height;\r
+ gVesa_BufInfo.Depth = gVesa_Modes[mode].bpp; \r
+\r
return 1;\r
}\r
\r