diff options
author | Alex Deucher <alex@botch2.com> | 2007-03-04 02:45:55 -0500 |
---|---|---|
committer | Alex Deucher <alex@botch2.com> | 2007-03-13 00:17:29 -0400 |
commit | 3030e5a6afda5d05ddee5b586295a9e608b7a0de (patch) | |
tree | 6bfa950179dd258492b1d64a8a24970af0054d0e /src/smi_video.c | |
parent | 606971fc8a323b0b33bb43524941b4bae6a0c334 (diff) |
Whitespace and formatting changes
Diffstat (limited to 'src/smi_video.c')
-rw-r--r-- | src/smi_video.c | 1974 |
1 files changed, 898 insertions, 1076 deletions
diff --git a/src/smi_video.c b/src/smi_video.c index 1166c03..db19ffd 100644 --- a/src/smi_video.c +++ b/src/smi_video.c @@ -237,9 +237,9 @@ static VideoNormDataRec VideoNorms[] = static XF86VideoFormatRec SMI_VideoFormats[] = { - { 15, TrueColor }, /* depth, class */ - { 16, TrueColor }, /* depth, class */ - { 24, TrueColor }, /* depth, class */ + { 15, TrueColor }, /* depth, class */ + { 16, TrueColor }, /* depth, class */ + { 24, TrueColor }, /* depth, class */ }; @@ -280,85 +280,85 @@ static XF86AttributeRec SMI_VideoAttributes[2] = { /**************************************************************************/ static XF86ImageRec SMI_VideoImages[] = { - XVIMAGE_YUY2, - XVIMAGE_YV12, - XVIMAGE_I420, - { - FOURCC_RV15, /* id */ - XvRGB, /* type */ - LSBFirst, /* byte_order */ - { 'R', 'V' ,'1', '5', - 0x00, '5', 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }, /* guid */ - 16, /* bits_per_pixel */ - XvPacked, /* format */ - 1, /* num_planes */ - 15, /* depth */ - 0x001F, 0x03E0, 0x7C00, /* red_mask, green, blue */ - 0, 0, 0, /* y_sample_bits, u, v */ - 0, 0, 0, /* horz_y_period, u, v */ - 0, 0, 0, /* vert_y_period, u, v */ - { 'R', 'V', 'B' }, /* component_order */ - XvTopToBottom /* scaline_order */ - }, - { - FOURCC_RV16, /* id */ - XvRGB, /* type */ - LSBFirst, /* byte_order */ - { 'R', 'V' ,'1', '6', - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }, /* guid */ - 16, /* bits_per_pixel */ - XvPacked, /* format */ - 1, /* num_planes */ - 16, /* depth */ - 0x001F, 0x07E0, 0xF800, /* red_mask, green, blue */ - 0, 0, 0, /* y_sample_bits, u, v */ - 0, 0, 0, /* horz_y_period, u, v */ - 0, 0, 0, /* vert_y_period, u, v */ - { 'R', 'V', 'B' }, /* component_order */ - XvTopToBottom /* scaline_order */ - }, - { - FOURCC_RV24, /* id */ - XvRGB, /* type */ - LSBFirst, /* byte_order */ - { 'R', 'V' ,'2', '4', - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }, /* guid */ - 24, /* bits_per_pixel */ - XvPacked, /* format */ - 1, /* num_planes */ - 24, /* depth */ - 0x0000FF, 0x00FF00, 0xFF0000, /* red_mask, green, blue */ - 0, 0, 0, /* y_sample_bits, u, v */ - 0, 0, 0, /* horz_y_period, u, v */ - 0, 0, 0, /* vert_y_period, u, v */ - { 'R', 'V', 'B' }, /* component_order */ - XvTopToBottom /* scaline_order */ - }, - { - FOURCC_RV32, /* id */ - XvRGB, /* type */ - LSBFirst, /* byte_order */ - { 'R', 'V' ,'3', '2', - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }, /* guid */ - 32, /* bits_per_pixel */ - XvPacked, /* format */ - 1, /* num_planes */ - 24, /* depth */ - 0x0000FF, 0x00FF00, 0xFF0000, /* red_mask, green, blue */ - 0, 0, 0, /* y_sample_bits, u, v */ - 0, 0, 0, /* horz_y_period, u, v */ - 0, 0, 0, /* vert_y_period, u, v */ - { 'R', 'V', 'B' }, /* component_order */ - XvTopToBottom /* scaline_order */ - }, + XVIMAGE_YUY2, + XVIMAGE_YV12, + XVIMAGE_I420, + { + FOURCC_RV15, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'1', '5', + 0x00, '5', 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 16, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 15, /* depth */ + 0x001F, 0x03E0, 0x7C00, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, + { + FOURCC_RV16, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'1', '6', + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 16, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 16, /* depth */ + 0x001F, 0x07E0, 0xF800, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, + { + FOURCC_RV24, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'2', '4', + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 24, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 24, /* depth */ + 0x0000FF, 0x00FF00, 0xFF0000, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, + { + FOURCC_RV32, /* id */ + XvRGB, /* type */ + LSBFirst, /* byte_order */ + { 'R', 'V' ,'3', '2', + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, /* guid */ + 32, /* bits_per_pixel */ + XvPacked, /* format */ + 1, /* num_planes */ + 24, /* depth */ + 0x0000FF, 0x00FF00, 0xFF0000, /* red_mask, green, blue */ + 0, 0, 0, /* y_sample_bits, u, v */ + 0, 0, 0, /* horz_y_period, u, v */ + 0, 0, 0, /* vert_y_period, u, v */ + { 'R', 'V', 'B' }, /* component_order */ + XvTopToBottom /* scaline_order */ + }, }; @@ -645,19 +645,14 @@ SMI_InitVideo(ScreenPtr pScreen) SMI_InitOffscreenImages(pScreen); } - if (newAdaptor != NULL) - { - if (numAdaptors == 0) - { + if (newAdaptor != NULL) { + if (numAdaptors == 0) { numAdaptors = 1; ptrAdaptors = &newAdaptor; - } - else - { + } else { newAdaptors = xalloc((numAdaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); - if (newAdaptors != NULL) - { + if (newAdaptors != NULL) { memcpy(newAdaptors, ptrAdaptors, numAdaptors * sizeof(XF86VideoAdaptorPtr)); newAdaptors[numAdaptors++] = newAdaptor; @@ -666,14 +661,12 @@ SMI_InitVideo(ScreenPtr pScreen) } } - if (numAdaptors != 0) - { - DEBUG((VERBLEV, "ScreenInit %i\n",numAdaptors)); + if (numAdaptors != 0) { + DEBUG((VERBLEV, "ScreenInit %i\n",numAdaptors)); xf86XVScreenInit(pScreen, ptrAdaptors, numAdaptors); } - if (newAdaptors != NULL) - { + if (newAdaptors != NULL) { xfree(newAdaptors); } @@ -719,8 +712,7 @@ SetAttr(ScrnInfoPtr pScrn, int i, int value) SetKeyReg(pSmi, 0x5C, 0xEDEDED | (my_value << 24)); } else if (pPort->I2CDev.SlaveAddr == SAA7110) { return SetAttrSAA7110(pScrn, i, value); - } - else if (pPort->I2CDev.SlaveAddr == SAA7111) { + } else if (pPort->I2CDev.SlaveAddr == SAA7111) { return SetAttrSAA7111(pScrn, i, value); } #if 0 @@ -777,16 +769,14 @@ SetAttrSAA7111(ScrnInfoPtr pScrn, int i, int value) ENTRIES(SAA7111CompositeChannelSelect[channel]) / 2)) { return XvBadAlloc; } - } - else { + } else { if (!xf86I2CWriteVec(&(pPort->I2CDev), SAA7111SVideoChannelSelect[channel], ENTRIES(SAA7111SVideoChannelSelect[channel]) / 2)) { return XvBadAlloc; } } - } - else if (i >= XV_CAPTURE_BRIGHTNESS && i <= XV_HUE) { + } else if (i >= XV_CAPTURE_BRIGHTNESS && i <= XV_HUE) { int slave_adr = 0; switch (i) { @@ -816,8 +806,7 @@ SetAttrSAA7111(ScrnInfoPtr pScrn, int i, int value) } if (!xf86I2CWriteByte(&(pPort->I2CDev), slave_adr, (value & 0xff))) return XvBadAlloc; - } - else { + } else { return BadMatch; } @@ -838,45 +827,42 @@ SetAttrSAA7111(ScrnInfoPtr pScrn, int i, int value) /******************************************************************************\ -** ** -** V I D E O M A N A G E M E N T ** -** ** +** ** +** V I D E O M A N A G E M E N T ** +** ** \******************************************************************************/ static XF86VideoAdaptorPtr -SMI_SetupVideo( - ScreenPtr pScreen -) +SMI_SetupVideo(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - SMIPtr pSmi = SMIPTR(pScrn); - SMI_PortPtr smiPortPtr; - XF86VideoAdaptorPtr ptrAdaptor; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr smiPortPtr; + XF86VideoAdaptorPtr ptrAdaptor; - ENTER_PROC("SMI_SetupVideo"); + ENTER_PROC("SMI_SetupVideo"); - ptrAdaptor = xcalloc(1, sizeof(XF86VideoAdaptorRec) + - sizeof(DevUnion) + sizeof(SMI_PortRec)); - if (ptrAdaptor == NULL) - { - LEAVE_PROC("SMI_SetupVideo"); - return(NULL); - } + ptrAdaptor = xcalloc(1, sizeof(XF86VideoAdaptorRec) + + sizeof(DevUnion) + sizeof(SMI_PortRec)); + if (ptrAdaptor == NULL) { + LEAVE_PROC("SMI_SetupVideo"); + return NULL; + } - ptrAdaptor->type = XvInputMask + ptrAdaptor->type = XvInputMask #if SMI_USE_CAPTURE - | XvOutputMask - | XvVideoMask + | XvOutputMask + | XvVideoMask #endif - | XvImageMask - | XvWindowMask - ; + | XvImageMask + | XvWindowMask + ; - ptrAdaptor->flags = VIDEO_OVERLAID_IMAGES - | VIDEO_CLIP_TO_VIEWPORT - ; + ptrAdaptor->flags = VIDEO_OVERLAID_IMAGES + | VIDEO_CLIP_TO_VIEWPORT + ; - ptrAdaptor->name = "Silicon Motion Lynx Series Video Engine"; + ptrAdaptor->name = "Silicon Motion Lynx Series Video Engine"; ptrAdaptor->nPorts = 1; ptrAdaptor->pPortPrivates = (DevUnion*) &ptrAdaptor[1]; @@ -896,39 +882,39 @@ SMI_SetupVideo( } #endif - ptrAdaptor->nFormats = nElems(SMI_VideoFormats); - ptrAdaptor->pFormats = SMI_VideoFormats; + ptrAdaptor->nFormats = nElems(SMI_VideoFormats); + ptrAdaptor->pFormats = SMI_VideoFormats; - ptrAdaptor->nAttributes = nElems(SMI_VideoAttributes); - ptrAdaptor->pAttributes = SMI_VideoAttributes; + ptrAdaptor->nAttributes = nElems(SMI_VideoAttributes); + ptrAdaptor->pAttributes = SMI_VideoAttributes; - ptrAdaptor->nImages = nElems(SMI_VideoImages); - ptrAdaptor->pImages = SMI_VideoImages; + ptrAdaptor->nImages = nElems(SMI_VideoImages); + ptrAdaptor->pImages = SMI_VideoImages; #if SMI_USE_CAPTURE - if (pSmi->Chipset == SMI_COUGAR3DR) - ptrAdaptor->PutVideo = NULL; - else - ptrAdaptor->PutVideo = SMI_PutVideo; - ptrAdaptor->PutStill = NULL; + if (pSmi->Chipset == SMI_COUGAR3DR) + ptrAdaptor->PutVideo = NULL; + else + ptrAdaptor->PutVideo = SMI_PutVideo; + ptrAdaptor->PutStill = NULL; ptrAdaptor->GetVideo = NULL; - ptrAdaptor->GetStill = NULL; + ptrAdaptor->GetStill = NULL; #else - ptrAdaptor->PutVideo = NULL; - ptrAdaptor->PutStill = NULL; - ptrAdaptor->GetVideo = NULL; - ptrAdaptor->GetStill = NULL; + ptrAdaptor->PutVideo = NULL; + ptrAdaptor->PutStill = NULL; + ptrAdaptor->GetVideo = NULL; + ptrAdaptor->GetStill = NULL; #endif - ptrAdaptor->StopVideo = SMI_StopVideo; - ptrAdaptor->SetPortAttribute = SMI_SetPortAttribute; - ptrAdaptor->GetPortAttribute = SMI_GetPortAttribute; - ptrAdaptor->QueryBestSize = SMI_QueryBestSize; - ptrAdaptor->PutImage = SMI_PutImage; - ptrAdaptor->QueryImageAttributes = SMI_QueryImageAttributes; + ptrAdaptor->StopVideo = SMI_StopVideo; + ptrAdaptor->SetPortAttribute = SMI_SetPortAttribute; + ptrAdaptor->GetPortAttribute = SMI_GetPortAttribute; + ptrAdaptor->QueryBestSize = SMI_QueryBestSize; + ptrAdaptor->PutImage = SMI_PutImage; + ptrAdaptor->QueryImageAttributes = SMI_QueryImageAttributes; smiPortPtr->Attribute[XV_COLORKEY] = pSmi->videoKey; smiPortPtr->Attribute[XV_INTERLACED] = pSmi->interlaced; - smiPortPtr->videoStatus = 0; + smiPortPtr->videoStatus = 0; #if 0 /* aaa does not work ? */ @@ -945,11 +931,9 @@ SMI_SetupVideo( smiPortPtr->I2CDev.pI2CBus = pSmi->I2C; - if (xf86I2CDevInit(&(smiPortPtr->I2CDev))) - { + if (xf86I2CDevInit(&(smiPortPtr->I2CDev))) { - if (xf86I2CWriteVec(&(smiPortPtr->I2CDev), SAA7111InitData, - ENTRIES(SAA7111InitData) / 2)) { + if (xf86I2CWriteVec(&(smiPortPtr->I2CDev), SAA7111InitData, ENTRIES(SAA7111InitData) / 2)) { xvEncoding = MAKE_ATOM(XV_ENCODING_NAME); xvHue = MAKE_ATOM(XV_HUE_NAME); xvSaturation = MAKE_ATOM(XV_SATURATION_NAME); @@ -981,20 +965,18 @@ SMI_SetupVideo( SMI_ResetVideo(pScrn); LEAVE_PROC("SMI_SetupVideo"); - return(ptrAdaptor); + return ptrAdaptor; } static void -SMI_ResetVideo( - ScrnInfoPtr pScrn -) +SMI_ResetVideo(ScrnInfoPtr pScrn) { - SMIPtr pSmi = SMIPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; - int r, g, b; + int r, g, b; - ENTER_PROC("SMI_ResetVideo"); + ENTER_PROC("SMI_ResetVideo"); SetAttr(pScrn, XV_ENCODING, 0); /* Encoding = pal-composite-0 */ SetAttr(pScrn, XV_BRIGHTNESS, 128); /* Brightness = 128 (CCIR level) */ @@ -1003,31 +985,28 @@ SMI_ResetVideo( SetAttr(pScrn, XV_SATURATION, 64); /* Color saturation = 64 (CCIR level) */ SetAttr(pScrn, XV_HUE, 0); /* Hue = 0 */ - switch (pScrn->depth) - { - case 8: - SetKeyReg(pSmi, FPR04, pPort->Attribute[XV_COLORKEY] & 0x00FF); - SetKeyReg(pSmi, FPR08, 0); - break; - - case 15: - case 16: - SetKeyReg(pSmi, FPR04, pPort->Attribute[XV_COLORKEY] & 0xFFFF); - SetKeyReg(pSmi, FPR08, 0); - break; - - default: - r = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.red) >> pScrn->offset.red; - g = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.green) >> pScrn->offset.green; - b = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.blue) >> pScrn->offset.blue; - SetKeyReg(pSmi, FPR04, ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); - SetKeyReg(pSmi, FPR08, 0); - break; - } + switch (pScrn->depth) { + case 8: + SetKeyReg(pSmi, FPR04, pPort->Attribute[XV_COLORKEY] & 0x00FF); + SetKeyReg(pSmi, FPR08, 0); + break; + case 15: + case 16: + SetKeyReg(pSmi, FPR04, pPort->Attribute[XV_COLORKEY] & 0xFFFF); + SetKeyReg(pSmi, FPR08, 0); + break; + default: + r = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.red) >> pScrn->offset.red; + g = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.green) >> pScrn->offset.green; + b = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.blue) >> pScrn->offset.blue; + SetKeyReg(pSmi, FPR04, ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); + SetKeyReg(pSmi, FPR08, 0); + break; + } - SetKeyReg(pSmi, FPR5C, 0xEDEDED | (pPort->Attribute[XV_BRIGHTNESS] << 24)); + SetKeyReg(pSmi, FPR5C, 0xEDEDED | (pPort->Attribute[XV_BRIGHTNESS] << 24)); - LEAVE_PROC("SMI_ResetVideo"); + LEAVE_PROC("SMI_ResetVideo"); } @@ -1049,15 +1028,15 @@ SMI_PutVideo( ) { SMI_PortPtr pPort = (SMI_PortPtr) data; - SMIPtr pSmi = SMIPTR(pScrn); - CARD32 vid_pitch, vid_address; - CARD32 vpr00, cpr00; - int xscale, yscale; - BoxRec dstBox; - INT32 x1, y1, x2, y2; + SMIPtr pSmi = SMIPTR(pScrn); + CARD32 vid_pitch, vid_address; + CARD32 vpr00, cpr00; + int xscale, yscale; + BoxRec dstBox; + INT32 x1, y1, x2, y2; int norm; - int areaHeight, width, height, fbPitch; - int top, left; + int areaHeight, width, height, fbPitch; + int top, left; ENTER_PROC("SMI_PutVideo"); @@ -1079,42 +1058,39 @@ SMI_PutVideo( "vid_w=%d vid_h=%d drw_w=%d drw_h=%d\n", vid_x, vid_y, drw_x, drw_y, vid_w, vid_h, drw_w, drw_h)); - x1 = vid_x; - y1 = vid_y; - x2 = vid_x + vid_w; - y2 = vid_y + vid_h; + x1 = vid_x; + y1 = vid_y; + x2 = vid_x + vid_w; + y2 = vid_y + vid_h; - width = vid_w; - height = vid_h; + width = vid_w; + height = vid_h; - dstBox.x1 = drw_x; - dstBox.y1 = drw_y; - dstBox.x2 = drw_x + drw_w; - dstBox.y2 = drw_y + drw_h; + dstBox.x1 = drw_x; + dstBox.y1 = drw_y; + dstBox.x2 = drw_x + drw_w; + dstBox.y2 = drw_y + drw_h; #if 1 - if (!SMI_ClipVideo(pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, - height)) + if (!SMI_ClipVideo(pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, height)) { #else - if (!xf86XVClipVideoHelper(&dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, - height)) + if (!xf86XVClipVideoHelper(&dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, height)) { #endif - { LEAVE_PROC("SMI_PutVideo"); - return(Success); - } + return Success; + } DEBUG((VERBLEV, "Clip: x1=%d y1=%d x2=%d y2=%d\n", x1 >> 16, y1 >> 16, x2 >> 16, y2 >> 16)); - dstBox.x1 -= pScrn->frameX0; - dstBox.y1 -= pScrn->frameY0; - dstBox.x2 -= pScrn->frameX0; - dstBox.y2 -= pScrn->frameY0; + dstBox.x1 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y2 -= pScrn->frameY0; - vid_pitch = (vid_w * 2 + 7) & ~7; + vid_pitch = (vid_w * 2 + 7) & ~7; - vpr00 = READ_VPR(pSmi, 0x00) & ~0x0FF000FF; - cpr00 = READ_CPR(pSmi, 0x00) & ~0x000FFF00; + vpr00 = READ_VPR(pSmi, 0x00) & ~0x0FF000FF; + cpr00 = READ_CPR(pSmi, 0x00) & ~0x000FFF00; /* vpr00: Bit 2..0 = 6: Video Window I Format = YUV4:2:2 @@ -1141,8 +1117,7 @@ SMI_PutVideo( Bit 24 = 0: Select Video Window I Source Addr = 0 */ vpr00 |= 0x0010000E; - } - else { + } else { /* Bit 21 = 10: Vertical Interpolation = enabled Bit 24 = 1: Select Video Window I Source Addr = 1 @@ -1172,8 +1147,7 @@ SMI_PutVideo( Bit 13..11 = 0: Frame Skip Enable = no skip */ cpr00 |= 0x01000601; - } - else { + } else { /* Bit 9 = 0: Double Buffer Enable = disabled Bit 10 = 0: Interlace Data Capture = disabled @@ -1182,113 +1156,85 @@ SMI_PutVideo( cpr00 |= 0x01000801; } - if (pSmi->ByteSwap) - cpr00 |= 0x00004000; + if (pSmi->ByteSwap) + cpr00 |= 0x00004000; - fbPitch = pSmi->Stride; - if (pSmi->Bpp != 3) - { - fbPitch *= pSmi->Bpp; - } + fbPitch = pSmi->Stride; + if (pSmi->Bpp != 3) { + fbPitch *= pSmi->Bpp; + } - if (vid_w <= drw_w) - { - xscale = (256 * vid_w / drw_w) & 0xFF; - } - else if (vid_w / 2 <= drw_w) - { - xscale = (128 * vid_w / drw_w) & 0xFF; - width /= 2; - vid_pitch /= 2; - cpr00 |= 0x00010000; - } - else if (vid_w / 4 <= drw_w) - { - xscale = (64 * vid_w / drw_w) & 0xFF; - width /= 4; - vid_pitch /= 4; - cpr00 |= 0x00020000; - } - else - { - xscale = 0; - width /= 4; - vid_pitch /= 4; - cpr00 |= 0x00020000; - } + if (vid_w <= drw_w) { + xscale = (256 * vid_w / drw_w) & 0xFF; + } else if (vid_w / 2 <= drw_w) { + xscale = (128 * vid_w / drw_w) & 0xFF; + width /= 2; + vid_pitch /= 2; + cpr00 |= 0x00010000; + } else if (vid_w / 4 <= drw_w) { + xscale = (64 * vid_w / drw_w) & 0xFF; + width /= 4; + vid_pitch /= 4; + cpr00 |= 0x00020000; + } else { + xscale = 0; + width /= 4; + vid_pitch /= 4; + cpr00 |= 0x00020000; + } - if (vid_h <= drw_h) - { - yscale = (256 * vid_h / drw_h) & 0xFF; - } - else if (vid_h / 2 <= drw_h) - { - yscale = (128 * vid_h / drw_h) & 0xFF; - height /= 2; - cpr00 |= 0x00040000; - } - else if (vid_h / 4 <= drw_h) - { - yscale = (64 * vid_h / drw_h) & 0xFF; - height /= 4; - cpr00 |= 0x00080000; - } - else - { - yscale = 0; - height /= 4; - cpr00 |= 0x00080000; - } + if (vid_h <= drw_h) { + yscale = (256 * vid_h / drw_h) & 0xFF; + } else if (vid_h / 2 <= drw_h) { + yscale = (128 * vid_h / drw_h) & 0xFF; + height /= 2; + cpr00 |= 0x00040000; + } else if (vid_h / 4 <= drw_h) { + yscale = (64 * vid_h / drw_h) & 0xFF; + height /= 4; + cpr00 |= 0x00080000; + } else { + yscale = 0; + height /= 4; + cpr00 |= 0x00080000; + } - do - { - areaHeight = (vid_pitch * height + fbPitch - 1) / fbPitch; + do { + areaHeight = (vid_pitch * height + fbPitch - 1) / fbPitch; DEBUG((VERBLEV, "SMI_AllocateMemory: vid_pitch=%d height=%d fbPitch=%d areaHeight=%d\n", vid_pitch, height, fbPitch, areaHeight)); pPort->area = SMI_AllocateMemory(pScrn, pPort->area, areaHeight); - if (pPort->area == NULL) - { - if ((cpr00 & 0x000C0000) == 0) - { - /* height -> 1/2 height */ - yscale = (128 * vid_h / drw_h) & 0xFF; - height = vid_h / 2; - cpr00 |= 0x00040000; - } - else if (cpr00 & 0x00040000) - { - /* 1/2 height -> 1/4 height */ - yscale = (64 * vid_h / drw_h) & 0xFF; - height = vid_h / 4; - cpr00 ^= 0x000C0000; - } - else - { - /* 1/4 height */ - if ((cpr00 & 0x00030000) == 0) - { - /* width -> 1/2 width */ - xscale = (128 * vid_w / drw_w) & 0xFF; - width = vid_w / 2; - cpr00 |= 0x00010000; - } - else if (cpr00 & 0x00010000) - { - /* 1/2 width -> 1/4 width */ - xscale = (64 * vid_w / drw_w) & 0xFF; - width = vid_w / 4; - cpr00 ^= 0x00030000; - } - else - { + if (pPort->area == NULL) { + if ((cpr00 & 0x000C0000) == 0) { + /* height -> 1/2 height */ + yscale = (128 * vid_h / drw_h) & 0xFF; + height = vid_h / 2; + cpr00 |= 0x00040000; + } else if (cpr00 & 0x00040000) { + /* 1/2 height -> 1/4 height */ + yscale = (64 * vid_h / drw_h) & 0xFF; + height = vid_h / 4; + cpr00 ^= 0x000C0000; + } else { + /* 1/4 height */ + if ((cpr00 & 0x00030000) == 0) { + /* width -> 1/2 width */ + xscale = (128 * vid_w / drw_w) & 0xFF; + width = vid_w / 2; + cpr00 |= 0x00010000; + } else if (cpr00 & 0x00010000) { + /* 1/2 width -> 1/4 width */ + xscale = (64 * vid_w / drw_w) & 0xFF; + width = vid_w / 4; + cpr00 ^= 0x00030000; + } else { DEBUG((VERBLEV, "allocate error\n")); LEAVE_PROC("SMI_PutVideo"); - return(BadAlloc); - } - } + return BadAlloc; } + } } - while (pPort->area == NULL); + } while (pPort->area == NULL); DEBUG((VERBLEV, "xscale==%d yscale=%d width=%d height=%d\n", xscale, yscale, width, height)); @@ -1309,26 +1255,26 @@ SMI_PutVideo( DEBUG((VERBLEV, "FillKey\n")); xf86XVFillKeyHelper(pScrn->pScreen, pPort->Attribute[XV_COLORKEY], clipBoxes); - } + } - left = x1 >> 16; - top = y1 >> 16; - width = (x2 - x1) >> 16; - height = (y2 - y1) >> 16; + left = x1 >> 16; + top = y1 >> 16; + width = (x2 - x1) >> 16; + height = (y2 - y1) >> 16; - OUT_SEQ(pSmi, 0x21, IN_SEQ(pSmi, 0x21) & ~0x04); - WRITE_VPR(pSmi, 0x54, READ_VPR(pSmi, 0x54) | 0x00200000); + OUT_SEQ(pSmi, 0x21, IN_SEQ(pSmi, 0x21) & ~0x04); + WRITE_VPR(pSmi, 0x54, READ_VPR(pSmi, 0x54) | 0x00200000); #if 0 SMI_WaitForSync(pScrn); #endif /* Video Window I Left and Top Boundaries */ - WRITE_VPR(pSmi, 0x14, dstBox.x1 + (dstBox.y1 << 16)); + WRITE_VPR(pSmi, 0x14, dstBox.x1 + (dstBox.y1 << 16)); /* Video Window I Right and Bottom Boundaries */ - WRITE_VPR(pSmi, 0x18, dstBox.x2 + (dstBox.y2 << 16)); + WRITE_VPR(pSmi, 0x18, dstBox.x2 + (dstBox.y2 << 16)); /* Video Window I Source Width and Offset */ - WRITE_VPR(pSmi, 0x20, (vid_pitch / 8) + ((vid_pitch / 8) << 16)); + WRITE_VPR(pSmi, 0x20, (vid_pitch / 8) + ((vid_pitch / 8) << 16)); /* Video Window I Stretch Factor */ - WRITE_VPR(pSmi, 0x24, (xscale << 8) + yscale); + WRITE_VPR(pSmi, 0x24, (xscale << 8) + yscale); if (pPort->Attribute[XV_INTERLACED]) { /* Video Window II Left and Top Boundaries */ @@ -1360,8 +1306,7 @@ SMI_PutVideo( WRITE_CPR(pSmi, 0x10, vid_address / 8 + vid_pitch / 8); /* Capture Port Source Offset Address */ WRITE_CPR(pSmi, 0x14, 2*(vid_pitch / 8) + ((2*(vid_pitch / 8)) << 16)); - } - else { + } else { /* Video Source Clipping Control */ WRITE_CPR(pSmi, 0x04, left + (top << 16)); /* Video Source Capture Size Control */ @@ -1374,13 +1319,13 @@ SMI_PutVideo( WRITE_CPR(pSmi, 0x14, (vid_pitch / 8) + ((vid_pitch / 8) << 16)); } - WRITE_CPR(pSmi, 0x00, cpr00); - WRITE_VPR(pSmi, 0x00, vpr00); + WRITE_CPR(pSmi, 0x00, cpr00); + WRITE_VPR(pSmi, 0x00, vpr00); pPort->videoStatus = CLIENT_VIDEO_ON; DEBUG((VERBLEV, "SMI_PutVideo success\n")); LEAVE_PROC("SMI_PutVideo"); - return(Success); + return Success; } #endif @@ -1392,50 +1337,40 @@ SMI_StopVideo( Bool shutdown ) { - SMI_PortPtr pPort = (SMI_PortPtr) data; - SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr pPort = (SMI_PortPtr) data; + SMIPtr pSmi = SMIPTR(pScrn); - ENTER_PROC("SMI_StopVideo"); + ENTER_PROC("SMI_StopVideo"); - REGION_EMPTY(pScrn->pScreen, &pPort->clip); + REGION_EMPTY(pScrn->pScreen, &pPort->clip); - if (shutdown) - { - if (pPort->videoStatus & CLIENT_VIDEO_ON) - { - if (pSmi->Chipset == SMI_COUGAR3DR) - { - WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); - } - else - { - WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x01000008); - } + if (shutdown) { + if (pPort->videoStatus & CLIENT_VIDEO_ON) { + if (pSmi->Chipset == SMI_COUGAR3DR) { + WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); + } else { + WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x01000008); + } #if SMI_USE_CAPTURE - if (pSmi->Chipset != SMI_COUGAR3DR) - { - WRITE_CPR(pSmi, 0x00, READ_CPR(pSmi, 0x00) & ~0x00000001); - WRITE_VPR(pSmi, 0x54, READ_VPR(pSmi, 0x54) & ~0x00F00000); - } - /* #864 OUT_SEQ(pSmi, 0x21, IN_SEQ(pSmi, 0x21) | 0x04); */ + if (pSmi->Chipset != SMI_COUGAR3DR) { + WRITE_CPR(pSmi, 0x00, READ_CPR(pSmi, 0x00) & ~0x00000001); + WRITE_VPR(pSmi, 0x54, READ_VPR(pSmi, 0x54) & ~0x00F00000); + } +/* #864 OUT_SEQ(pSmi, 0x21, IN_SEQ(pSmi, 0x21) | 0x04); */ #endif - } - if (pPort->area != NULL) - { + } + if (pPort->area != NULL) { xf86FreeOffscreenArea(pPort->area); pPort->area = NULL; - } + } pPort->videoStatus = 0; /* pPort->i2cDevice = 0;aaa*/ - } - else - { - if (pPort->videoStatus & CLIENT_VIDEO_ON) - { + } else { + if (pPort->videoStatus & CLIENT_VIDEO_ON) { pPort->videoStatus |= OFF_TIMER; pPort->offTime = currentTime.milliseconds + OFF_DELAY; - } } + } LEAVE_PROC("SMI_StopVideo"); } @@ -1451,63 +1386,51 @@ SMI_SetPortAttribute( { int res; SMI_PortPtr pPort = (SMI_PortPtr) data; - SMIPtr pSmi = SMIPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); - ENTER_PROC("SMI_SetPortAttribute"); + ENTER_PROC("SMI_SetPortAttribute"); if (attribute == xvColorKey) { - int r, g, b; + int r, g, b; pPort->Attribute[XV_COLORKEY] = value; - switch (pScrn->depth) - { - case 8: - SetKeyReg(pSmi, FPR04, value & 0x00FF); - break; - - case 15: - case 16: - SetKeyReg(pSmi, FPR04, value & 0xFFFF); - break; - - default: - r = (value & pScrn->mask.red) >> pScrn->offset.red; - g = (value & pScrn->mask.green) >> pScrn->offset.green; - b = (value & pScrn->mask.blue) >> pScrn->offset.blue; - SetKeyReg(pSmi, FPR04, - ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); - break; - } - res = Success; + switch (pScrn->depth) { + case 8: + SetKeyReg(pSmi, FPR04, value & 0x00FF); + break; + case 15: + case 16: + SetKeyReg(pSmi, FPR04, value & 0xFFFF); + break; + default: + r = (value & pScrn->mask.red) >> pScrn->offset.red; + g = (value & pScrn->mask.green) >> pScrn->offset.green; + b = (value & pScrn->mask.blue) >> pScrn->offset.blue; + SetKeyReg(pSmi, FPR04, ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); + break; } - else if (attribute == xvInterlaced) { + res = Success; + } else if (attribute == xvInterlaced) { pPort->Attribute[XV_INTERLACED] = (value != 0); res = Success; - } - else if (attribute == xvEncoding) { + } else if (attribute == xvEncoding) { res = SetAttr(pScrn, XV_ENCODING, value); - } - else if (attribute == xvBrightness) { + } else if (attribute == xvBrightness) { res = SetAttr(pScrn, XV_BRIGHTNESS, value); - } - else if (attribute == xvCapBrightness) { + } else if (attribute == xvCapBrightness) { res = SetAttr(pScrn, XV_CAPTURE_BRIGHTNESS, value); - } - else if (attribute == xvContrast) { + } else if (attribute == xvContrast) { res = SetAttr(pScrn, XV_CONTRAST, value); - } - else if (attribute == xvSaturation) { + } else if (attribute == xvSaturation) { res = SetAttr(pScrn, XV_SATURATION, value); - } - else if (attribute == xvHue) { + } else if (attribute == xvHue) { res = SetAttr(pScrn, XV_HUE, value); - } - else { + } else { res = BadMatch; - } + } - LEAVE_PROC("SMI_SetPortAttribute"); - return(res); + LEAVE_PROC("SMI_SetPortAttribute"); + return res; } @@ -1521,7 +1444,7 @@ SMI_GetPortAttribute( { SMI_PortPtr pPort = (SMI_PortPtr) data; - ENTER_PROC("SMI_GetPortAttribute"); + ENTER_PROC("SMI_GetPortAttribute"); if (attribute == xvEncoding) *value = pPort->Attribute[XV_ENCODING]; else if (attribute == xvBrightness) @@ -1536,15 +1459,13 @@ SMI_GetPortAttribute( *value = pPort->Attribute[XV_HUE]; else if (attribute == xvColorKey) *value = pPort->Attribute[XV_COLORKEY]; - - else - { - LEAVE_PROC("SMI_GetPortAttribute"); - return(BadMatch); - } - + else { LEAVE_PROC("SMI_GetPortAttribute"); - return(Success); + return BadMatch; + } + + LEAVE_PROC("SMI_GetPortAttribute"); + return Success; } @@ -1561,14 +1482,14 @@ SMI_QueryBestSize( pointer data ) { - SMIPtr pSmi = SMIPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); - ENTER_PROC("SMI_QueryBestSize"); + ENTER_PROC("SMI_QueryBestSize"); - *p_w = min(drw_w, pSmi->lcdWidth); - *p_h = min(drw_h, pSmi->lcdHeight); + *p_w = min(drw_w, pSmi->lcdWidth); + *p_h = min(drw_h, pSmi->lcdHeight); - LEAVE_PROC("SMI_QueryBestSize"); + LEAVE_PROC("SMI_QueryBestSize"); } @@ -1593,113 +1514,102 @@ SMI_PutImage( DrawablePtr pDraw ) { - SMIPtr pSmi = SMIPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; - INT32 x1, y1, x2, y2; - int bpp = 0; - int fbPitch, srcPitch, srcPitch2 = 0, dstPitch, areaHeight; - BoxRec dstBox; - CARD32 offset, offset2 = 0, offset3 = 0, tmp; - int left, top, nPixels, nLines; - unsigned char *dstStart; - - ENTER_PROC("SMI_PutImage"); - - x1 = src_x; - y1 = src_y; - x2 = src_x + src_w; - y2 = src_y + src_h; - - dstBox.x1 = drw_x; - dstBox.y1 = drw_y; - dstBox.x2 = drw_x + drw_w; - dstBox.y2 = drw_y + drw_h; - - if (!SMI_ClipVideo(pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, - height)) - { - LEAVE_PROC("SMI_PutImage"); - return(Success); - } + INT32 x1, y1, x2, y2; + int bpp = 0; + int fbPitch, srcPitch, srcPitch2 = 0, dstPitch, areaHeight; + BoxRec dstBox; + CARD32 offset, offset2 = 0, offset3 = 0, tmp; + int left, top, nPixels, nLines; + unsigned char *dstStart; + + ENTER_PROC("SMI_PutImage"); + + x1 = src_x; + y1 = src_y; + x2 = src_x + src_w; + y2 = src_y + src_h; + + dstBox.x1 = drw_x; + dstBox.y1 = drw_y; + dstBox.x2 = drw_x + drw_w; + dstBox.y2 = drw_y + drw_h; + + if (!SMI_ClipVideo(pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, width, height)) { + LEAVE_PROC("SMI_PutImage"); + return Success; + } - dstBox.x1 -= pScrn->frameX0; - dstBox.y1 -= pScrn->frameY0; - dstBox.x2 -= pScrn->frameX0; - dstBox.y2 -= pScrn->frameY0; + dstBox.x1 -= pScrn->frameX0; + dstBox.y1 -= pScrn->frameY0; + dstBox.x2 -= pScrn->frameX0; + dstBox.y2 -= pScrn->frameY0; - if (pSmi->Bpp == 3) - { - fbPitch = pSmi->Stride; - } - else - { - fbPitch = pSmi->Stride * pSmi->Bpp; - } + if (pSmi->Bpp == 3) { + fbPitch = pSmi->Stride; + } else { + fbPitch = pSmi->Stride * pSmi->Bpp; + } - switch (id) - { - case FOURCC_YV12: - srcPitch = (width + 3) & ~3; - offset2 = srcPitch * height; - srcPitch2 = ((width >> 1) + 3) & ~3; - offset3 = offset2 + (srcPitch2 * (height >> 1)); - dstPitch = ((width << 1) + 15) & ~15; - break; - - case FOURCC_I420: - srcPitch = (width + 3) & ~3; - offset3 = srcPitch * height; - srcPitch2 = ((width >> 1) + 3) & ~3; - offset2 = offset3 + (srcPitch2 * (height >> 1)); - dstPitch = ((width << 1) + 15) & ~15; - break; - - case FOURCC_RV24: - bpp = 3; - srcPitch = width * bpp; - dstPitch = (srcPitch + 15) & ~15; - break; - - case FOURCC_RV32: - bpp = 4; - srcPitch = width * bpp; - dstPitch = (srcPitch + 15) & ~15; - break; - - case FOURCC_YUY2: - case FOURCC_RV15: - case FOURCC_RV16: - default: - bpp = 2; - srcPitch = width * bpp; - dstPitch = (srcPitch + 15) & ~15; - break; - } + switch (id) { + case FOURCC_YV12: + srcPitch = (width + 3) & ~3; + offset2 = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + offset3 = offset2 + (srcPitch2 * (height >> 1)); + dstPitch = ((width << 1) + 15) & ~15; + break; + case FOURCC_I420: + srcPitch = (width + 3) & ~3; + offset3 = srcPitch * height; + srcPitch2 = ((width >> 1) + 3) & ~3; + offset2 = offset3 + (srcPitch2 * (height >> 1)); + dstPitch = ((width << 1) + 15) & ~15; + break; + case FOURCC_RV24: + bpp = 3; + srcPitch = width * bpp; + dstPitch = (srcPitch + 15) & ~15; + break; + case FOURCC_RV32: + bpp = 4; + srcPitch = width * bpp; + dstPitch = (srcPitch + 15) & ~15; + break; + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + default: + bpp = 2; + srcPitch = width * bpp; + dstPitch = (srcPitch + 15) & ~15; + break; + } - areaHeight = ((dstPitch * height) + fbPitch - 1) / fbPitch; + areaHeight = ((dstPitch * height) + fbPitch - 1) / fbPitch; pPort->area = SMI_AllocateMemory(pScrn, pPort->area, areaHeight); - if (pPort->area == NULL) - { - LEAVE_PROC("SMI_PutImage"); - return(BadAlloc); - } + if (pPort->area == NULL) { + LEAVE_PROC("SMI_PutImage"); + return BadAlloc; + } - top = y1 >> 16; - left = (x1 >> 16) & ~1; - nPixels = ((((x2 + 0xFFFF) >> 16) + 1) & ~1) - left; - left *= bpp; + top = y1 >> 16; + left = (x1 >> 16) & ~1; + nPixels = ((((x2 + 0xFFFF) >> 16) + 1) & ~1) - left; + left *= bpp; offset = (pPort->area->box.y1 * fbPitch) + (top * dstPitch); - dstStart = pSmi->FBBase + offset + left; + dstStart = pSmi->FBBase + offset + left; - switch(id) { + switch(id) { case FOURCC_YV12: case FOURCC_I420: top &= ~1; tmp = ((top >> 1) * srcPitch2) + (left >> 2); offset2 += tmp; offset3 += tmp; - if(id == FOURCC_I420) { + if (id == FOURCC_I420) { tmp = offset2; offset2 = offset3; offset3 = tmp; @@ -1723,125 +1633,111 @@ SMI_PutImage( #else if (!REGION_EQUAL(pScrn->pScreen, &pPort->clip, clipBoxes)) #endif - { + { REGION_COPY(pScrn->pScreen, &pPort->clip, clipBoxes); xf86XVFillKeyHelper(pScrn->pScreen, pPort->Attribute[XV_COLORKEY], clipBoxes); - } + } - if (pSmi->Chipset != SMI_COUGAR3DR) - SMI_DisplayVideo(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, - &dstBox, src_w, src_h, drw_w, drw_h); - else - SMI_DisplayVideo0730(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, - &dstBox, src_w, src_h, drw_w, drw_h); + if (pSmi->Chipset != SMI_COUGAR3DR) + SMI_DisplayVideo(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, + &dstBox, src_w, src_h, drw_w, drw_h); + else + SMI_DisplayVideo0730(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, + &dstBox, src_w, src_h, drw_w, drw_h); pPort->videoStatus = CLIENT_VIDEO_ON; - LEAVE_PROC("SMI_PutImage"); - return(Success); + LEAVE_PROC("SMI_PutImage"); + return Success; } static int SMI_QueryImageAttributes( - ScrnInfoPtr pScrn, - int id, + ScrnInfoPtr pScrn, + int id, unsigned short *width, unsigned short *height, - int *pitches, - int *offsets + int *pitches, + int *offsets ) { - SMIPtr pSmi = SMIPTR(pScrn); - int size, tmp; + SMIPtr pSmi = SMIPTR(pScrn); + int size, tmp; - ENTER_PROC("SMI_QueryImageAttributes"); + ENTER_PROC("SMI_QueryImageAttributes"); - if (*width > pSmi->lcdWidth) - { - *width = pSmi->lcdWidth; + if (*width > pSmi->lcdWidth) { + *width = pSmi->lcdWidth; + } + if (*height > pSmi->lcdHeight) { + *height = pSmi->lcdHeight; + } + + *width = (*width + 1) & ~1; + if (offsets != NULL) { + offsets[0] = 0; + } + + switch (id) { + case FOURCC_YV12: + case FOURCC_I420: + *height = (*height + 1) & ~1; + size = (*width + 3) & ~3; + if (pitches != NULL) { + pitches[0] = size; } - if (*height > pSmi->lcdHeight) - { - *height = pSmi->lcdHeight; + size *= *height; + if (offsets != NULL) { + offsets[1] = size; } - - *width = (*width + 1) & ~1; - if (offsets != NULL) - { - offsets[0] = 0; + tmp = ((*width >> 1) + 3) & ~3; + if (pitches != NULL) { + pitches[1] = pitches[2] = tmp; } - - switch (id) - { - case FOURCC_YV12: - case FOURCC_I420: - *height = (*height + 1) & ~1; - size = (*width + 3) & ~3; - if (pitches != NULL) - { - pitches[0] = size; - } - size *= *height; - if (offsets != NULL) - { - offsets[1] = size; - } - tmp = ((*width >> 1) + 3) & ~3; - if (pitches != NULL) - { - pitches[1] = pitches[2] = tmp; - } - tmp *= (*height >> 1); - size += tmp; - if (offsets != NULL) - { - offsets[2] = size; - } - size += tmp; - break; - - case FOURCC_YUY2: - case FOURCC_RV15: - case FOURCC_RV16: - default: - size = *width * 2; - if (pitches != NULL) - { - pitches[0] = size; - } - size *= *height; - break; - - case FOURCC_RV24: - size = *width * 3; - if (pitches != NULL) - { - pitches[0] = size; - } - size *= *height; - break; - - case FOURCC_RV32: - size = *width * 4; - if (pitches != NULL) - { - pitches[0] = size; - } - size *= *height; - break; + tmp *= (*height >> 1); + size += tmp; + if (offsets != NULL) { + offsets[2] = size; + } + size += tmp; + break; + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + default: + size = *width * 2; + if (pitches != NULL) { + pitches[0] = size; } + size *= *height; + break; + case FOURCC_RV24: + size = *width * 3; + if (pitches != NULL) { + pitches[0] = size; + } + size *= *height; + break; + case FOURCC_RV32: + size = *width * 4; + if (pitches != NULL) { + pitches[0] = size; + } + size *= *height; + break; + } - LEAVE_PROC("SMI_QueryImageAttributes"); - return(size); + LEAVE_PROC("SMI_QueryImageAttributes"); + return size; } /******************************************************************************\ -** ** -** S U P P O R T F U N C T I O N S ** -** ** +** ** +** S U P P O R T F U N C T I O N S ** +** ** \******************************************************************************/ #if 0 static void @@ -1874,67 +1770,61 @@ SMI_ClipVideo( { ScreenPtr pScreen = pScrn->pScreen; INT32 vscale, hscale; - BoxPtr extents = REGION_EXTENTS(pScreen, reg); - int diff; + BoxPtr extents = REGION_EXTENTS(pScreen, reg); + int diff; - ENTER_PROC("SMI_ClipVideo"); + ENTER_PROC("SMI_ClipVideo"); DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); - /* PDR#941 */ - extents->x1 = max(extents->x1, pScrn->frameX0); - extents->y1 = max(extents->y1, pScrn->frameY0); + /* PDR#941 */ + extents->x1 = max(extents->x1, pScrn->frameX0); + extents->y1 = max(extents->y1, pScrn->frameY0); - hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); - vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); + hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1); + vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1); - *x1 <<= 16; *y1 <<= 16; - *x2 <<= 16; *y2 <<= 16; + *x1 <<= 16; *y1 <<= 16; + *x2 <<= 16; *y2 <<= 16; DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); - diff = extents->x1 - dst->x1; - if (diff > 0) - { - dst->x1 = extents->x1; - *x1 += diff * hscale; - } + diff = extents->x1 - dst->x1; + if (diff > 0) { + dst->x1 = extents->x1; + *x1 += diff * hscale; + } - diff = extents->y1 - dst->y1; - if (diff > 0) - { - dst->y1 = extents->y1; - *y1 += diff * vscale; - } + diff = extents->y1 - dst->y1; + if (diff > 0) { + dst->y1 = extents->y1; + *y1 += diff * vscale; + } - diff = dst->x2 - extents->x2; - if (diff > 0) - { - dst->x2 = extents->x2; /* PDR#687 */ - *x2 -= diff * hscale; - } + diff = dst->x2 - extents->x2; + if (diff > 0) { + dst->x2 = extents->x2; /* PDR#687 */ + *x2 -= diff * hscale; + } - diff = dst->y2 - extents->y2; - if (diff > 0) - { - dst->y2 = extents->y2; - *y2 -= diff * vscale; - } + diff = dst->y2 - extents->y2; + if (diff > 0) { + dst->y2 = extents->y2; + *y2 -= diff * vscale; + } DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); - if (*x1 < 0) - { - diff = (-*x1 + hscale - 1) / hscale; - dst->x1 += diff; - *x1 += diff * hscale; - } + if (*x1 < 0) { + diff = (-*x1 + hscale - 1) / hscale; + dst->x1 += diff; + *x1 += diff * hscale; + } - if (*y1 < 0) - { - diff = (-*y1 + vscale - 1) / vscale; - dst->y1 += diff; - *y1 += diff * vscale; - } + if (*y1 < 0) { + diff = (-*y1 + vscale - 1) / vscale; + dst->y1 += diff; + *y1 += diff * vscale; + } DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); @@ -1958,40 +1848,37 @@ SMI_ClipVideo( DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); - if ((*x1 >= *x2) || (*y1 >= *y2)) - { - LEAVE_PROC("SMI_ClipVideo"); - return(FALSE); - } + if ((*x1 >= *x2) || (*y1 >= *y2)) { + LEAVE_PROC("SMI_ClipVideo"); + return FALSE; + } - if ( (dst->x1 != extents->x1) || (dst->y1 != extents->y1) - || (dst->x2 != extents->x2) || (dst->y2 != extents->y2) - ) - { - RegionRec clipReg; - REGION_INIT(pScreen, &clipReg, dst, 1); - REGION_INTERSECT(pScreen, reg, reg, &clipReg); - REGION_UNINIT(pScreen, &clipReg); - } + if ((dst->x1 != extents->x1) || (dst->y1 != extents->y1) || + (dst->x2 != extents->x2) || (dst->y2 != extents->y2)) { + RegionRec clipReg; + REGION_INIT(pScreen, &clipReg, dst, 1); + REGION_INTERSECT(pScreen, reg, reg, &clipReg); + REGION_UNINIT(pScreen, &clipReg); + } DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); - LEAVE_PROC("SMI_ClipVideo"); - return(TRUE); + LEAVE_PROC("SMI_ClipVideo"); + return TRUE; } static void SMI_DisplayVideo( ScrnInfoPtr pScrn, - int id, - int offset, + int id, + int offset, short width, short height, - int pitch, - int x1, - int y1, - int x2, - int y2, + int pitch, + int x1, + int y1, + int x2, + int y2, BoxPtr dstBox, short vid_w, short vid_h, @@ -1999,83 +1886,71 @@ SMI_DisplayVideo( short drw_h ) { - SMIPtr pSmi = SMIPTR(pScrn); - CARD32 vpr00; - int hstretch, vstretch; + SMIPtr pSmi = SMIPTR(pScrn); + CARD32 vpr00; + int hstretch, vstretch; - ENTER_PROC("SMI_DisplayVideo"); + ENTER_PROC("SMI_DisplayVideo"); - vpr00 = READ_VPR(pSmi, 0x00) & ~0x0CB800FF; + vpr00 = READ_VPR(pSmi, 0x00) & ~0x0CB800FF; - switch (id) - { - case FOURCC_YV12: - case FOURCC_I420: - case FOURCC_YUY2: - vpr00 |= 0x6; - break; - - case FOURCC_RV15: - vpr00 |= 0x1; - break; - - case FOURCC_RV16: - vpr00 |= 0x2; - break; - - case FOURCC_RV24: - vpr00 |= 0x4; - break; - - case FOURCC_RV32: - vpr00 |= 0x3; - break; - } + switch (id) { + case FOURCC_YV12: + case FOURCC_I420: + case FOURCC_YUY2: + vpr00 |= 0x6; + break; + case FOURCC_RV15: + vpr00 |= 0x1; + break; + case FOURCC_RV16: + vpr00 |= 0x2; + break; + case FOURCC_RV24: + vpr00 |= 0x4; + break; + case FOURCC_RV32: + vpr00 |= 0x3; + break; + } - - if (drw_w > vid_w) - { - hstretch = (2560 * vid_w / drw_w + 5) / 10; - } - else - { - hstretch = 0; - } + if (drw_w > vid_w) { + hstretch = (2560 * vid_w / drw_w + 5) / 10; + } else { + hstretch = 0; + } - if (drw_h > vid_h) - { - vstretch = (2560 * vid_h / drw_h + 5) / 10; - vpr00 |= 1 << 21; - } - else - { - vstretch = 0; - } + if (drw_h > vid_h) { + vstretch = (2560 * vid_h / drw_h + 5) / 10; + vpr00 |= 1 << 21; + } else { + vstretch = 0; + } #if 0 - SMI_WaitForSync(pScrn); + SMI_WaitForSync(pScrn); #endif - WRITE_VPR(pSmi, 0x00, vpr00 | (1 << 3) | (1 << 20)); - WRITE_VPR(pSmi, 0x14, (dstBox->x1) | (dstBox->y1 << 16)); - WRITE_VPR(pSmi, 0x18, (dstBox->x2) | (dstBox->y2 << 16)); - WRITE_VPR(pSmi, 0x1C, offset >> 3); - WRITE_VPR(pSmi, 0x20, (pitch >> 3) | ((pitch >> 3) << 16)); - WRITE_VPR(pSmi, 0x24, (hstretch << 8) | vstretch); - - LEAVE_PROC("SMI_DisplayVideo"); + WRITE_VPR(pSmi, 0x00, vpr00 | (1 << 3) | (1 << 20)); + WRITE_VPR(pSmi, 0x14, (dstBox->x1) | (dstBox->y1 << 16)); + WRITE_VPR(pSmi, 0x18, (dstBox->x2) | (dstBox->y2 << 16)); + WRITE_VPR(pSmi, 0x1C, offset >> 3); + WRITE_VPR(pSmi, 0x20, (pitch >> 3) | ((pitch >> 3) << 16)); + WRITE_VPR(pSmi, 0x24, (hstretch << 8) | vstretch); + + LEAVE_PROC("SMI_DisplayVideo"); } static void SMI_DisplayVideo0730( ScrnInfoPtr pScrn, - int id, - int offset, + int id, + int offset, short width, short height, - int pitch, - int x1, - int y1, - int x2, - int y2, + int pitch, + int x1, + int y1, + int x2, + int y2, BoxPtr dstBox, short vid_w, short vid_h, @@ -2083,117 +1958,96 @@ SMI_DisplayVideo0730( short drw_h ) { - SMIPtr pSmi = SMIPTR(pScrn); - CARD32 fpr00; - int hstretch, vstretch; + SMIPtr pSmi = SMIPTR(pScrn); + CARD32 fpr00; + int hstretch, vstretch; - ENTER_PROC("SMI_DisplayVideo0730"); + ENTER_PROC("SMI_DisplayVideo0730"); - fpr00 = READ_FPR(pSmi, 0x00) & ~(FPR00_MASKBITS); + fpr00 = READ_FPR(pSmi, 0x00) & ~(FPR00_MASKBITS); - switch (id) - { - case FOURCC_YV12: - case FOURCC_I420: - case FOURCC_YUY2: - fpr00 |= FPR00_FMT_YUV422; - break; - - case FOURCC_RV15: - fpr00 |= FPR00_FMT_15P; - break; - - case FOURCC_RV16: - fpr00 |= FPR00_FMT_16P; - break; - - case FOURCC_RV24: - fpr00 |= FPR00_FMT_24P; - break; - - case FOURCC_RV32: - fpr00 |= FPR00_FMT_32P; - break; - } + switch (id) { + case FOURCC_YV12: + case FOURCC_I420: + case FOURCC_YUY2: + fpr00 |= FPR00_FMT_YUV422; + break; + case FOURCC_RV15: + fpr00 |= FPR00_FMT_15P; + break; + case FOURCC_RV16: + fpr00 |= FPR00_FMT_16P; + break; + case FOURCC_RV24: + fpr00 |= FPR00_FMT_24P; + break; + case FOURCC_RV32: + fpr00 |= FPR00_FMT_32P; + break; + } - /* the formulas for calculating the stretch values do not match the - documentation, but they're the same as the ddraw driver and they work */ - if (drw_w > vid_w) - { - hstretch = (8192 * vid_w / drw_w); - } - else - { - hstretch = 0; - } + /* the formulas for calculating the stretch values do not match the + documentation, but they're the same as the ddraw driver and they work */ + if (drw_w > vid_w) { + hstretch = (8192 * vid_w / drw_w); + } else { + hstretch = 0; + } - if (drw_h > vid_h) - { - vstretch = (8192 * vid_h / drw_h); - } - else - { - vstretch = 0; - } - + if (drw_h > vid_h) { + vstretch = (8192 * vid_h / drw_h); + } else { + vstretch = 0; + } - WRITE_FPR(pSmi, FPR00, fpr00 | FPR00_VWIENABLE | FPR00_VWIKEYENABLE); - WRITE_FPR(pSmi, FPR14, (dstBox->x1) | (dstBox->y1 << 16)); - WRITE_FPR(pSmi, FPR18, (dstBox->x2) | (dstBox->y2 << 16)); - WRITE_FPR(pSmi, FPR1C, offset >> 3); - WRITE_FPR(pSmi, FPR20, (pitch >> 3) | ((pitch >> 3) << 16)); - WRITE_FPR(pSmi, FPR24, (hstretch & 0xFF00) | ((vstretch & 0xFF00)>>8)); - WRITE_FPR(pSmi, FPR68, ((hstretch & 0x00FF)<<8) | (vstretch & 0x00FF)); + WRITE_FPR(pSmi, FPR00, fpr00 | FPR00_VWIENABLE | FPR00_VWIKEYENABLE); + WRITE_FPR(pSmi, FPR14, (dstBox->x1) | (dstBox->y1 << 16)); + WRITE_FPR(pSmi, FPR18, (dstBox->x2) | (dstBox->y2 << 16)); + WRITE_FPR(pSmi, FPR1C, offset >> 3); + WRITE_FPR(pSmi, FPR20, (pitch >> 3) | ((pitch >> 3) << 16)); + WRITE_FPR(pSmi, FPR24, (hstretch & 0xFF00) | ((vstretch & 0xFF00)>>8)); + WRITE_FPR(pSmi, FPR68, ((hstretch & 0x00FF)<<8) | (vstretch & 0x00FF)); - LEAVE_PROC("SMI_DisplayVideo0730"); + LEAVE_PROC("SMI_DisplayVideo0730"); } static void SMI_BlockHandler( - int i, + int i, pointer blockData, pointer pTimeout, pointer pReadMask ) { - ScreenPtr pScreen = screenInfo.screens[i]; - ScrnInfoPtr pScrn = xf86Screens[i]; - SMIPtr pSmi = SMIPTR(pScrn); + ScreenPtr pScreen = screenInfo.screens[i]; + ScrnInfoPtr pScrn = xf86Screens[i]; + SMIPtr pSmi = SMIPTR(pScrn); SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; - pScreen->BlockHandler = pSmi->BlockHandler; - (*pScreen->BlockHandler)(i, blockData, pTimeout, pReadMask); - pScreen->BlockHandler = SMI_BlockHandler; + pScreen->BlockHandler = pSmi->BlockHandler; + (*pScreen->BlockHandler)(i, blockData, pTimeout, pReadMask); + pScreen->BlockHandler = SMI_BlockHandler; - if (pPort->videoStatus & TIMER_MASK) - { - UpdateCurrentTime(); - if (pPort->videoStatus & OFF_TIMER) - { - if (pPort->offTime < currentTime.milliseconds) - { - if (pSmi->Chipset == SMI_COUGAR3DR) - { - WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); - } - else - { - WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); - } + if (pPort->videoStatus & TIMER_MASK) { + UpdateCurrentTime(); + if (pPort->videoStatus & OFF_TIMER) { + if (pPort->offTime < currentTime.milliseconds) { + if (pSmi->Chipset == SMI_COUGAR3DR) { + WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); + } else { + WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); + } pPort->videoStatus = FREE_TIMER; pPort->freeTime = currentTime.milliseconds + FREE_DELAY; - } - } - else - { - if (pPort->freeTime < currentTime.milliseconds) - { + } + } else { + if (pPort->freeTime < currentTime.milliseconds) { xf86FreeOffscreenArea(pPort->area); pPort->area = NULL; - } + } pPort->videoStatus = 0; - } } + } } #if 0 @@ -2251,9 +2105,9 @@ SMI_SendI2C( #endif /******************************************************************************\ -** ** -** O F F S C R E E N M E M O R Y M A N A G E R ** -** ** +** ** +** O F F S C R E E N M E M O R Y M A N A G E R ** +** ** \******************************************************************************/ static void @@ -2261,204 +2115,185 @@ SMI_InitOffscreenImages( ScreenPtr pScreen ) { - XF86OffscreenImagePtr offscreenImages; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - SMIPtr pSmi = SMIPTR(pScrn); - SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; + XF86OffscreenImagePtr offscreenImages; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SMIPtr pSmi = SMIPTR(pScrn); + SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; - ENTER_PROC("SMI_InitOffscreenImages"); + ENTER_PROC("SMI_InitOffscreenImages"); - offscreenImages = xalloc(sizeof(XF86OffscreenImageRec)); - if (offscreenImages == NULL) - { - LEAVE_PROC("SMI_InitOffscreenImages"); - return; - } + offscreenImages = xalloc(sizeof(XF86OffscreenImageRec)); + if (offscreenImages == NULL) { + LEAVE_PROC("SMI_InitOffscreenImages"); + return; + } - offscreenImages->image = SMI_VideoImages; - offscreenImages->flags = VIDEO_OVERLAID_IMAGES - | VIDEO_CLIP_TO_VIEWPORT; - offscreenImages->alloc_surface = SMI_AllocSurface; - offscreenImages->free_surface = SMI_FreeSurface; - offscreenImages->display = SMI_DisplaySurface; - offscreenImages->stop = SMI_StopSurface; - offscreenImages->getAttribute = SMI_GetSurfaceAttribute; - offscreenImages->setAttribute = SMI_SetSurfaceAttribute; - offscreenImages->max_width = pSmi->lcdWidth; - offscreenImages->max_height = pSmi->lcdHeight; - if (!pPort->I2CDev.SlaveAddr) { - offscreenImages->num_attributes = nElems(SMI_VideoAttributes); - offscreenImages->attributes = SMI_VideoAttributes; - } else { - offscreenImages->num_attributes = - nElems(SMI_VideoAttributesSAA711x); - offscreenImages->attributes = SMI_VideoAttributesSAA711x; - } - xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); + offscreenImages->image = SMI_VideoImages; + offscreenImages->flags = VIDEO_OVERLAID_IMAGES + | VIDEO_CLIP_TO_VIEWPORT; + offscreenImages->alloc_surface = SMI_AllocSurface; + offscreenImages->free_surface = SMI_FreeSurface; + offscreenImages->display = SMI_DisplaySurface; + offscreenImages->stop = SMI_StopSurface; + offscreenImages->getAttribute = SMI_GetSurfaceAttribute; + offscreenImages->setAttribute = SMI_SetSurfaceAttribute; + offscreenImages->max_width = pSmi->lcdWidth; + offscreenImages->max_height = pSmi->lcdHeight; + if (!pPort->I2CDev.SlaveAddr) { + offscreenImages->num_attributes = nElems(SMI_VideoAttributes); + offscreenImages->attributes = SMI_VideoAttributes; + } else { + offscreenImages->num_attributes = nElems(SMI_VideoAttributesSAA711x); + offscreenImages->attributes = SMI_VideoAttributesSAA711x; + } + xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); - LEAVE_PROC("SMI_InitOffscreenImages"); + LEAVE_PROC("SMI_InitOffscreenImages"); } static FBAreaPtr SMI_AllocateMemory( ScrnInfoPtr pScrn, FBAreaPtr area, - int numLines + int numLines ) { - ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; + ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; - ENTER_PROC("SMI_AllocateMemory"); + ENTER_PROC("SMI_AllocateMemory"); - if (area != NULL) - { - if ((area->box.y2 - area->box.y1) >= numLines) - { + if (area != NULL) { + if ((area->box.y2 - area->box.y1) >= numLines) { LEAVE_PROC("SMI_AllocateMemory (area->box.y2 - area->box.y1) >= numLines ok"); - return(area); - } + return area; + } - if (xf86ResizeOffscreenArea(area, pScrn->displayWidth, numLines)) - { + if (xf86ResizeOffscreenArea(area, pScrn->displayWidth, numLines)) { LEAVE_PROC("SMI_AllocateMemory xf86ResizeOffscreenArea ok"); - return(area); - } - - xf86FreeOffscreenArea(area); + return area; } - area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, numLines, 0, - NULL, NULL, NULL); + xf86FreeOffscreenArea(area); + } + + area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, numLines, 0, + NULL, NULL, NULL); - if (area == NULL) - { - int maxW, maxH; + if (area == NULL) { + int maxW, maxH; - xf86QueryLargestOffscreenArea(pScreen, &maxW, &maxH, 0, + xf86QueryLargestOffscreenArea(pScreen, &maxW, &maxH, 0, FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); DEBUG((VERBLEV, "QueryLargestOffscreenArea maxW=%d maxH=%d displayWidth=%d numlines=%d\n", maxW, maxH, pScrn->displayWidth, numLines)); - if ((maxW < pScrn->displayWidth) || (maxH < numLines)) - { + if ((maxW < pScrn->displayWidth) || (maxH < numLines)) { LEAVE_PROC("SMI_AllocateMemory (maxW < pScrn->displayWidth) || (maxH < numLines)"); - return(NULL); - } + return NULL; + } - xf86PurgeUnlockedOffscreenAreas(pScreen); - area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, numLines, + xf86PurgeUnlockedOffscreenAreas(pScreen); + area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, numLines, 0, NULL, NULL, NULL); - } + } DEBUG((VERBLEV, "area = %p\n", area)); - LEAVE_PROC("SMI_AllocateMemory"); - return(area); + LEAVE_PROC("SMI_AllocateMemory"); + return area; } static int SMI_AllocSurface( - ScrnInfoPtr pScrn, - int id, + ScrnInfoPtr pScrn, + int id, unsigned short width, unsigned short height, XF86SurfacePtr surface ) { - SMIPtr pSmi = SMIPTR(pScrn); - int numLines, pitch, fbPitch, bpp; - SMI_OffscreenPtr ptrOffscreen; - FBAreaPtr area; + SMIPtr pSmi = SMIPTR(pScrn); + int numLines, pitch, fbPitch, bpp; + SMI_OffscreenPtr ptrOffscreen; + FBAreaPtr area; - ENTER_PROC("SMI_AllocSurface"); + ENTER_PROC("SMI_AllocSurface"); - if ((width > pSmi->lcdWidth) || (height > pSmi->lcdHeight)) - { - LEAVE_PROC("SMI_AllocSurface"); - return(BadAlloc); - } + if ((width > pSmi->lcdWidth) || (height > pSmi->lcdHeight)) { + LEAVE_PROC("SMI_AllocSurface"); + return BadAlloc; + } - if (pSmi->Bpp == 3) - { - fbPitch = pSmi->Stride; - } - else - { - fbPitch = pSmi->Stride * pSmi->Bpp; - } + if (pSmi->Bpp == 3) { + fbPitch = pSmi->Stride; + } else { + fbPitch = pSmi->Stride * pSmi->Bpp; + } - width = (width + 1) & ~1; - switch (id) - { - case FOURCC_YV12: - case FOURCC_I420: - case FOURCC_YUY2: - case FOURCC_RV15: - case FOURCC_RV16: - bpp = 2; - break; - - case FOURCC_RV24: - bpp = 3; - break; - - case FOURCC_RV32: - bpp = 4; - break; - - default: - LEAVE_PROC("SMI_AllocSurface"); - return(BadAlloc); - } - pitch = (width * bpp + 15) & ~15; + width = (width + 1) & ~1; + switch (id) { + case FOURCC_YV12: + case FOURCC_I420: + case FOURCC_YUY2: + case FOURCC_RV15: + case FOURCC_RV16: + bpp = 2; + break; + case FOURCC_RV24: + bpp = 3; + break; + case FOURCC_RV32: + bpp = 4; + break; + default: + LEAVE_PROC("SMI_AllocSurface"); + return BadAlloc; + } + pitch = (width * bpp + 15) & ~15; - numLines = ((height * pitch) + fbPitch - 1) / fbPitch; + numLines = ((height * pitch) + fbPitch - 1) / fbPitch; - area = SMI_AllocateMemory(pScrn, NULL, numLines); - if (area == NULL) - { - LEAVE_PROC("SMI_AllocSurface"); - return(BadAlloc); - } + area = SMI_AllocateMemory(pScrn, NULL, numLines); + if (area == NULL) { + LEAVE_PROC("SMI_AllocSurface"); + return BadAlloc; + } - surface->pitches = xalloc(sizeof(int)); - if (surface->pitches == NULL) - { - xf86FreeOffscreenArea(area); - LEAVE_PROC("SMI_AllocSurface"); - return(BadAlloc); - } - surface->offsets = xalloc(sizeof(int)); - if (surface->offsets == NULL) - { - xfree(surface->pitches); - xf86FreeOffscreenArea(area); - LEAVE_PROC("SMI_AllocSurface"); - return(BadAlloc); - } + surface->pitches = xalloc(sizeof(int)); + if (surface->pitches == NULL) { + xf86FreeOffscreenArea(area); + LEAVE_PROC("SMI_AllocSurface"); + return BadAlloc; + } + surface->offsets = xalloc(sizeof(int)); + if (surface->offsets == NULL) { + xfree(surface->pitches); + xf86FreeOffscreenArea(area); + LEAVE_PROC("SMI_AllocSurface"); + return BadAlloc; + } - ptrOffscreen = xalloc(sizeof(SMI_OffscreenRec)); - if (ptrOffscreen == NULL) - { - xfree(surface->offsets); - xfree(surface->pitches); - xf86FreeOffscreenArea(area); - LEAVE_PROC("SMI_AllocSurface"); - return(BadAlloc); - } + ptrOffscreen = xalloc(sizeof(SMI_OffscreenRec)); + if (ptrOffscreen == NULL) { + xfree(surface->offsets); + xfree(surface->pitches); + xf86FreeOffscreenArea(area); + LEAVE_PROC("SMI_AllocSurface"); + return BadAlloc; + } - surface->pScrn = pScrn; - surface->id = id; - surface->width = width; - surface->height = height; - surface->pitches[0] = pitch; - surface->offsets[0] = area->box.y1 * fbPitch; - surface->devPrivate.ptr = (pointer) ptrOffscreen; + surface->pScrn = pScrn; + surface->id = id; + surface->width = width; + surface->height = height; + surface->pitches[0] = pitch; + surface->offsets[0] = area->box.y1 * fbPitch; + surface->devPrivate.ptr = (pointer) ptrOffscreen; - ptrOffscreen->area = area; - ptrOffscreen->isOn = FALSE; + ptrOffscreen->area = area; + ptrOffscreen->isOn = FALSE; - LEAVE_PROC("SMI_AllocSurface"); - return(Success); + LEAVE_PROC("SMI_AllocSurface"); + return Success; } static int @@ -2466,97 +2301,91 @@ SMI_FreeSurface( XF86SurfacePtr surface ) { - SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; + SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; - ENTER_PROC("SMI_FreeSurface"); + ENTER_PROC("SMI_FreeSurface"); - if (ptrOffscreen->isOn) - { - SMI_StopSurface(surface); - } + if (ptrOffscreen->isOn) { + SMI_StopSurface(surface); + } - xf86FreeOffscreenArea(ptrOffscreen->area); - xfree(surface->pitches); - xfree(surface->offsets); - xfree(surface->devPrivate.ptr); + xf86FreeOffscreenArea(ptrOffscreen->area); + xfree(surface->pitches); + xfree(surface->offsets); + xfree(surface->devPrivate.ptr); - LEAVE_PROC("SMI_FreeSurface"); - return(Success); + LEAVE_PROC("SMI_FreeSurface"); + return Success; } static int SMI_DisplaySurface( XF86SurfacePtr surface, - short vid_x, - short vid_y, - short drw_x, - short drw_y, - short vid_w, - short vid_h, - short drw_w, - short drw_h, - RegionPtr clipBoxes + short vid_x, + short vid_y, + short drw_x, + short drw_y, + short vid_w, + short vid_h, + short drw_w, + short drw_h, + RegionPtr clipBoxes ) { - SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; - SMIPtr pSmi = SMIPTR(surface->pScrn); + SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; + SMIPtr pSmi = SMIPTR(surface->pScrn); SMI_PortPtr pPort = pSmi->ptrAdaptor->pPortPrivates[0].ptr; - INT32 x1, y1, x2, y2; - BoxRec dstBox; + INT32 x1, y1, x2, y2; + BoxRec dstBox; - ENTER_PROC("SMI_DisplaySurface"); + ENTER_PROC("SMI_DisplaySurface"); - x1 = vid_x; - x2 = vid_x + vid_w; - y1 = vid_y; - y2 = vid_y + vid_h; + x1 = vid_x; + x2 = vid_x + vid_w; + y1 = vid_y; + y2 = vid_y + vid_h; - dstBox.x1 = drw_x; - dstBox.x2 = drw_x + drw_w; - dstBox.y1 = drw_y; - dstBox.y2 = drw_y + drw_h; + dstBox.x1 = drw_x; + dstBox.x2 = drw_x + drw_w; + dstBox.y1 = drw_y; + dstBox.y2 = drw_y + drw_h; - if (!SMI_ClipVideo(surface->pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, - surface->width, surface->height)) - { - LEAVE_PROC("SMI_DisplaySurface"); - return(Success); - } - - dstBox.x1 -= surface->pScrn->frameX0; - dstBox.y1 -= surface->pScrn->frameY0; - dstBox.x2 -= surface->pScrn->frameX0; - dstBox.y2 -= surface->pScrn->frameY0; - - xf86XVFillKeyHelper(surface->pScrn->pScreen, - pPort->Attribute[XV_COLORKEY], clipBoxes); + if (!SMI_ClipVideo(surface->pScrn, &dstBox, &x1, &y1, &x2, &y2, clipBoxes, + surface->width, surface->height)) { + LEAVE_PROC("SMI_DisplaySurface"); + return Success; + } - if (pSmi->Chipset != SMI_COUGAR3DR) - { - SMI_ResetVideo(surface->pScrn); - SMI_DisplayVideo(surface->pScrn, surface->id, surface->offsets[0], - surface->width, surface->height, surface->pitches[0], x1, y1, x2, - y2, &dstBox, vid_w, vid_h, drw_w, drw_h); - } - else - { - SMI_ResetVideo(surface->pScrn); - SMI_DisplayVideo0730(surface->pScrn, surface->id, surface->offsets[0], - surface->width, surface->height, surface->pitches[0], x1, y1, x2, - y2, &dstBox, vid_w, vid_h, drw_w, drw_h); - } + dstBox.x1 -= surface->pScrn->frameX0; + dstBox.y1 -= surface->pScrn->frameY0; + dstBox.x2 -= surface->pScrn->frameX0; + dstBox.y2 -= surface->pScrn->frameY0; + + xf86XVFillKeyHelper(surface->pScrn->pScreen, + pPort->Attribute[XV_COLORKEY], clipBoxes); + + if (pSmi->Chipset != SMI_COUGAR3DR) { + SMI_ResetVideo(surface->pScrn); + SMI_DisplayVideo(surface->pScrn, surface->id, surface->offsets[0], + surface->width, surface->height, surface->pitches[0], x1, y1, x2, + y2, &dstBox, vid_w, vid_h, drw_w, drw_h); + } else { + SMI_ResetVideo(surface->pScrn); + SMI_DisplayVideo0730(surface->pScrn, surface->id, surface->offsets[0], + surface->width, surface->height, surface->pitches[0], x1, y1, x2, + y2, &dstBox, vid_w, vid_h, drw_w, drw_h); + } - ptrOffscreen->isOn = TRUE; - if (pPort->videoStatus & CLIENT_VIDEO_ON) - { + ptrOffscreen->isOn = TRUE; + if (pPort->videoStatus & CLIENT_VIDEO_ON) { REGION_EMPTY(surface->pScrn->pScreen, &pPort->clip); - UpdateCurrentTime(); + UpdateCurrentTime(); pPort->videoStatus = FREE_TIMER; pPort->freeTime = currentTime.milliseconds + FREE_DELAY; - } + } - LEAVE_PROC("SMI_DisplaySurface"); - return(Success); + LEAVE_PROC("SMI_DisplaySurface"); + return Success; } static int @@ -2564,27 +2393,23 @@ SMI_StopSurface( XF86SurfacePtr surface ) { - SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; + SMI_OffscreenPtr ptrOffscreen = (SMI_OffscreenPtr) surface->devPrivate.ptr; - ENTER_PROC("SMI_StopSurface"); + ENTER_PROC("SMI_StopSurface"); - if (ptrOffscreen->isOn) - { - SMIPtr pSmi = SMIPTR(surface->pScrn); - if (pSmi->Chipset == SMI_COUGAR3DR) - { - WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); - } - else - { - WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); - } - - ptrOffscreen->isOn = FALSE; + if (ptrOffscreen->isOn) { + SMIPtr pSmi = SMIPTR(surface->pScrn); + if (pSmi->Chipset == SMI_COUGAR3DR) { + WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); + } else { + WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); } - LEAVE_PROC("SMI_StopSurface"); - return(Success); + ptrOffscreen->isOn = FALSE; + } + + LEAVE_PROC("SMI_StopSurface"); + return Success; } static int @@ -2594,10 +2419,10 @@ SMI_GetSurfaceAttribute( INT32 *value ) { - SMIPtr pSmi = SMIPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); - return(SMI_GetPortAttribute(pScrn, attr, value, - (pointer) pSmi->ptrAdaptor->pPortPrivates[0].ptr)); + return SMI_GetPortAttribute(pScrn, attr, value, + (pointer) pSmi->ptrAdaptor->pPortPrivates[0].ptr); } static int @@ -2607,23 +2432,20 @@ SMI_SetSurfaceAttribute( INT32 value ) { - SMIPtr pSmi = SMIPTR(pScrn); + SMIPtr pSmi = SMIPTR(pScrn); - return(SMI_SetPortAttribute(pScrn, attr, value, - (pointer) pSmi->ptrAdaptor->pPortPrivates[0].ptr)); + return SMI_SetPortAttribute(pScrn, attr, value, + (pointer) pSmi->ptrAdaptor->pPortPrivates[0].ptr); } static void SetKeyReg(SMIPtr pSmi, int reg, int value) { - if (pSmi->Chipset == SMI_COUGAR3DR) - { - WRITE_FPR(pSmi, reg, value); - } - else - { - WRITE_VPR(pSmi, reg, value); - } + if (pSmi->Chipset == SMI_COUGAR3DR) { + WRITE_FPR(pSmi, reg, value); + } else { + WRITE_VPR(pSmi, reg, value); + } } #else /* SMI_USE_VIDEO */ |