/* Memory callback functions, these are used by the skin to provide memory allocation */ static void *RIPCALL SysAllocFnCallback(size_t cbSize) { #ifdef PMS_OIL_MERGE_DISABLE_MEM return (OIL_malloc(OILMemoryPoolJob, OIL_MemNonBlock, cbSize)); #else return (malloc(cbSize)); #endif }
/** * \brief OIL system initialization function. * * Calling this function initializes the OIL and starts the RIP. The function * first checks to ensure that the OIL is not in the \c OIL_Sys_JobActive or * \c OIL_Sys_Uninitialised states. This function: * \arg sets up the callback functions used by the Skin to allocate and free memory. * \n In addition, if the system is currently in the \c OIL_Sys_Inactive state and the next state * requested is the \c OIL_Sys_Active state, this function: * \arg allocates and initializes RIP memory; * \arg provides a list of embedded devices to the RIP; * \arg provides exit and reboot callback functions to the RIP; * \arg starts the RIP; * \arg registers resources, RIP modules and streams as required, and * \arg places the system into the \c OIL_Sys_Active state. * \n If the system is currently in the \c OIL_Sys_Suspended state, and the next state * requested is the \c OIL_Sys_Active state, this function: * \arg places the system into the \c OIL_Sys_Active state. * * During this call the RIP is started and claims * \c g_SystemState.cbRIPMemory bytes of memory. * * \param[in] eNextState The system state that is required by the end of the call; * expected to be \c OIL_Sys_Active. * \return Returns TRUE if the system is successfully initialized (as necessary) * and placed in the requested state, FALSE otherwise. */ int SysInit(OIL_eTySystemState eNextState) { struct SysMemFns tSkinMemoryFns; HQASSERT((OIL_Sys_JobActive != g_SystemState.eCurrentState), ("sys_init entered in state: OIL_Sys_JobActive")); HQASSERT((OIL_Sys_Uninitialised != g_SystemState.eCurrentState), ("sys_init entered in state: OIL_Sys_Uninitialised")); /* Initialise the memory helper functions */ /* - these are the memory allocation functions to be used by skin */ tSkinMemoryFns.pAllocFn = SysAllocFnCallback; tSkinMemoryFns.pFreeFn = SysFreeFnCallback; GG_SHOW(GG_SHOW_OIL, "SysInit:\n"); if ( g_profile_scope != NULL && !SwLeProfileOption(NULL, g_profile_scope) ) { oil_printf("sys_init: Invalid profile scope %s\n", g_profile_scope); return 0; } /* log the job start time */ GGglobal_timing(SW_TRACE_OIL_SYSSTART, 0); if ((g_SystemState.eCurrentState == OIL_Sys_Inactive) && (eNextState == OIL_Sys_Active)) { uint8 *reasonText ; /* allocate memory for the RIP, all systems ready for a job */ g_SystemState.pRIPMemory = NULL; #ifdef PMS_OIL_MERGE_DISABLE_MEM g_SystemState.pRIPMemory = OIL_malloc(OILMemoryPoolSys, OIL_MemBlock, g_SystemState.cbRIPMemory); #else g_SystemState.pRIPMemory = mmalloc(g_SystemState.cbRIPMemory); #endif if(g_SystemState.pRIPMemory == NULL) /*Bad Pointer*/ { oil_printf("sys_init: Failed to allocate RIP Memory\n"); return 0; } (void)SwLeInitRuntime(NULL) ; MemLogInit(g_mps_log, g_mps_telemetry) ; /* It is assumed that pthreads has been initialised. This is done earlier in the OIL boot process. */ /* initialize the SDK support libraries */ g_SystemState.cbmaxAddressSpace = g_SystemState.cbRIPMemory; if ( !SwLeSDKStart(&g_SystemState.cbmaxAddressSpace, &g_SystemState.cbRIPMemory, g_SystemState.pRIPMemory, &tSkinMemoryFns, &reasonText) ) { GG_SHOW(GG_SHOW_OIL, "sys_init: %s.\n", (char *)reasonText) ; return FALSE ; } /* Set number of RIP renderer threads */ SwLeSetRipRendererThreads( g_ConfigurableFeatures.nRendererThreads ); SwLeMemInit(g_SystemState.cbmaxAddressSpace, g_SystemState.cbRIPMemory, 0, g_SystemState.pRIPMemory); /* set MultipleCopies pgbdev param to true so that we get just 1 copy in rastercallback */ SwLePgbSetMultipleCopies(TRUE); SwLeSetRasterCallbacks(OIL_RasterStride, OIL_RasterRequirements, OIL_RasterDestination, OIL_RasterCallback); /* Add embedded devices to list passed to RIP */ SwLeAddCustomDevices( sizeof(ppEmbeddedDevices) / sizeof(ppEmbeddedDevices[0]), ppEmbeddedDevices ); /* set RIP exit callback */ SwLeSetRipExitFunction( OIL_RipExitCallback ); /* set RIP reboot callback */ SwLeSetRipRebootFunction( OIL_RipRebootCallback ); if (!oil_progress_init()) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to start progress timeline \n"); return FALSE; } /* Start RIP */ if ( SwLeStart( g_SystemState.cbmaxAddressSpace, g_SystemState.cbRIPMemory, 0, g_SystemState.pRIPMemory, (SwLeMONITORCALLBACK *)OIL_MonitorCallback ) ) { g_SystemState.eCurrentState = eNextState; } else { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to start RIP \n"); return FALSE; } /* Report job processing times */ progevts_enable_times(); oil_events_initialise(); if(!RegisterResources()) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to register resources\n"); return FALSE; } if(!RegisterRIPModules()) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to register RIP modules\n"); return FALSE; } if(!Stream_Register()) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to register Stream\n"); return FALSE; } } if ( !libjpeg_register() || !libjpegturbo_register() ) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to register libjpeg\n"); return FALSE; } if ((g_SystemState.eCurrentState == OIL_Sys_Suspended) && (eNextState == OIL_Sys_Active)) { GG_SHOW(GG_SHOW_OIL, "**RIP awakes\n"); g_SystemState.eCurrentState = eNextState; return TRUE; } /* Reset the job error status */ g_JobErrorData.Code = 0; g_JobErrorData.bErrorPageComplete = FALSE; /* return TRUE if now in requested state */ return (g_SystemState.eCurrentState == eNextState); }
/** * \brief Get the media source and media size from the PMS. * * This routine copies the media attributes being requested by the job into a PMS_TyMedia * structure and passes it to the PMS. This gives the PMS the opportunity to * compare the requested media attributes with those that are actually available, and * to update the job attributes accordingly. * \param[in, out] stEBDDeviceParams A pointer to an OIL_TyEBDDeviceParameters structure holding the * media details from the current job. It will be updated if the PMS * changes the media size or input tray. */ void GetMediaFromPMS(OIL_TyEBDDeviceParameters *stEBDDeviceParams) { PMS_TyTrayInfo *ptTrayInfo; PMS_TyPaperInfo *pPaperInfo; #ifdef PMS_OIL_MERGE_DISABLE PMS_TyJob *pCurrentJob; PMS_TyMedia *pstPMSMedia; #else OIL_TyMedia *pstPMSMedia; #endif int rotate; float ClipLeft, ClipTop, ClipWidth, ClipHeight; OIL_ProbeLog(SW_TRACE_OIL_GETMEDIAFROMPMS, SW_TRACETYPE_ENTER, (intptr_t)0); #ifdef PMS_OIL_MERGE_DISABLE pstPMSMedia = OIL_malloc(OILMemoryPoolJob, OIL_MemNonBlock, sizeof(PMS_TyMedia)); HQASSERTV(pstPMSMedia!=NULL, ("GetMediaFromPMS: Failed to allocate %lu bytes", (unsigned long) sizeof(PMS_TyMedia))); /* Clear the structure to avoid confusion when debugging */ memset(pstPMSMedia, 0x00, sizeof(PMS_TyMedia)); #else pstPMSMedia = OIL_malloc(OILMemoryPoolJob, OIL_MemNonBlock, sizeof(OIL_TyMedia)); HQASSERTV(pstPMSMedia!=NULL, ("GetMediaFromPMS: Failed to allocate %lu bytes", (unsigned long) sizeof(OIL_TyMedia))); /* Clear the structure to avoid confusion when debugging */ memset(pstPMSMedia, 0x00, sizeof(OIL_TyMedia)); #endif /* The parameters in stEBDDeviceParams configured in the (%embedded%) device. see \HqnEbd_SensePageDevice in SW\procsets\HqnEmbedded. see ebd_devparams_array in src\oil_ebddev.c */ strcpy((char*)pstPMSMedia->szMediaType, (char*)stEBDDeviceParams->MediaTypeFromJob); strcpy((char*)pstPMSMedia->szMediaColor, (char*)stEBDDeviceParams->MediaColorFromJob); pstPMSMedia->uMediaWeight = stEBDDeviceParams->MediaWeightFromJob; pstPMSMedia->uInputTray = stEBDDeviceParams->MediaSourceFromJob; pstPMSMedia->dWidth = stEBDDeviceParams->PageWidthFromJob; pstPMSMedia->dHeight = stEBDDeviceParams->PageHeightFromJob; /* Access default job settings */ #ifdef PMS_OIL_MERGE_DISABLE PMS_GetJobSettings(&pCurrentJob); HQASSERT(pCurrentJob, "GetMediaFromPMS, pCurrentJob is NULL"); pstPMSMedia->ePaperSize = pCurrentJob->tDefaultJobMedia.ePaperSize; #else pstPMSMedia->ePaperSize = g_tJob.tCurrentJobMedia.ePaperSize; #endif /* \todo Populate pstPMSMedia with other parameters that influence tray selection */ /* call PMS function to allow PMS to select a tray/media. */ if(PMS_MediaSelect(pstPMSMedia, &ptTrayInfo, &rotate)) { HQASSERT(ptTrayInfo, "GetMediaFromPMS, tray/media selected, but ptTrayInfo is NULL"); if(PMS_GetPaperInfo(ptTrayInfo->ePaperSize, &pPaperInfo)) { HQASSERT(pPaperInfo, "GetMediaFromPMS, pPaperInfo is NULL"); stEBDDeviceParams->PageWidthFromPMS = (float)pPaperInfo->dWidth; stEBDDeviceParams->PageHeightFromPMS = (float)pPaperInfo->dHeight; stEBDDeviceParams->PCL5PageSizeFromPMS = pPaperInfo->ePCL5size; stEBDDeviceParams->PCLXLPageSizeFromPMS = pPaperInfo->ePCLXLsize; ClipLeft = (float)(pPaperInfo->nLeftUnprintable * 0.000072); ClipTop = (float)(pPaperInfo->nTopUnprintable * 0.000072); ClipWidth = (float)(pPaperInfo->dWidth - ClipLeft - (pPaperInfo->nRightUnprintable * 0.000072)); ClipHeight = (float)(pPaperInfo->dHeight - ClipTop - (pPaperInfo->nBottomUnprintable * 0.000072)); if(rotate) { stEBDDeviceParams->MediaClipTopFromPMS = ClipLeft; stEBDDeviceParams->MediaClipLeftFromPMS = ClipTop; stEBDDeviceParams->MediaClipHeightFromPMS = ClipWidth; stEBDDeviceParams->MediaClipWidthFromPMS = ClipHeight; } else { stEBDDeviceParams->MediaClipLeftFromPMS = ClipLeft; stEBDDeviceParams->MediaClipTopFromPMS = ClipTop; stEBDDeviceParams->MediaClipWidthFromPMS = ClipWidth; stEBDDeviceParams->MediaClipHeightFromPMS = ClipHeight; } if(g_ConfigurableFeatures.ePrintableMode == OIL_RIPRemovesUnprintableArea) { /* calculate the logical page or get engine raster dimensions if defined */ stEBDDeviceParams->ImagingBoxLeftFromPMS = ClipLeft; stEBDDeviceParams->ImagingBoxTopFromPMS = ClipTop; stEBDDeviceParams->ImagingBoxRightFromPMS = ClipLeft + PADDED_ALIGNEMENT(ClipWidth, g_pstCurrentJob->uRIPDepth, g_pstCurrentJob->uXResolution); stEBDDeviceParams->ImagingBoxBottomFromPMS = ClipTop + ClipHeight; } else { stEBDDeviceParams->ImagingBoxLeftFromPMS = 0; stEBDDeviceParams->ImagingBoxTopFromPMS = 0; stEBDDeviceParams->ImagingBoxRightFromPMS = PADDED_ALIGNEMENT(pPaperInfo->dWidth, g_pstCurrentJob->uRIPDepth, g_pstCurrentJob->uXResolution); stEBDDeviceParams->ImagingBoxBottomFromPMS = (float)pPaperInfo->dHeight; } stEBDDeviceParams->MediaSourceFromPMS = ptTrayInfo->eMediaSource; } else { HQFAIL("GetMediaFromPMS, Call to PMS_GetPaperInfo failed."); } } OIL_free(OILMemoryPoolJob, pstPMSMedia); OIL_ProbeLog(SW_TRACE_OIL_GETMEDIAFROMPMS, SW_TRACETYPE_EXIT, (intptr_t)0); }
/** * \brief Create a PMS page structure from an OIL page. * * An OIL page structure is passed in and a PMS page strucutre is returned. * * This function allocates memory for the PMS page and populates the PMS * page structure with data from the OIL page structure.\n * The PMS page points to plane and band data stored in the OIL page so * the OIL page structure must not be destroyed until the entire page has been output * (as notified by OIL_PageDone()). * \param[in] ptOILPage A pointer to an OIL_TyPage structure. * \return A pointer to a PMS page, built from the OIL page supplied. */ PMS_TyPage* CreatePMSPage(OIL_TyPage *ptOILPage) { unsigned int i, j; PMS_TyPage *ptPMSPage; OIL_ProbeLog(SW_TRACE_OIL_CREATEPMSPAGE, SW_TRACETYPE_ENTER, (intptr_t)0); /* assert if no of bands is greater than pms max limit */ HQASSERTV(ptOILPage->atPlane[3].uBandTotal < PMS_BAND_LIMIT, ("CreatePMSPage: Exceeded the limit of maximum bands (%d)", PMS_BAND_LIMIT)); /* allocate the memory */ ptPMSPage = (PMS_TyPage *)OIL_malloc(OILMemoryPoolJob, OIL_MemBlock, sizeof(PMS_TyPage)); HQASSERTV(ptPMSPage!=NULL, ("CreatePMSPage: Failed to allocate %lu bytes", (unsigned long) sizeof(PMS_TyPage))); /* fill in the PMS page data */ ptPMSPage->JobId = ptOILPage->pstJob->uJobId; ptPMSPage->pJobPMSData = (PMS_TyJob *)(ptOILPage->pstJob->pJobPMSData); strcpy(ptPMSPage->szJobName, ptOILPage->pstJob->szJobName); ptPMSPage->PageId = ptOILPage->uPageNo; ptPMSPage->nPageWidthPixels = ptOILPage->nPageWidthPixels; ptPMSPage->nPageHeightPixels = ptOILPage->nPageHeightPixels; ptPMSPage->nRasterWidthBits = ptOILPage->nRasterWidthData; if(ptOILPage->pstJob->eColorMode == OIL_RGB_PixelInterleaved) { ptPMSPage->nRasterWidthPixels = (ptOILPage->nRasterWidthData / ptOILPage->uOutputDepth) / 3; } else { ptPMSPage->nRasterWidthPixels = (ptOILPage->nRasterWidthData / ptOILPage->uOutputDepth); } ptPMSPage->dXResolution = ptOILPage->dXRes; ptPMSPage->dYResolution = ptOILPage->dYRes; ptPMSPage->uRIPDepth = ptOILPage->uRIPDepth; ptPMSPage->uOutputDepth = ptOILPage->uOutputDepth; ptPMSPage->nTopMargin = ptOILPage->nTopMargin; ptPMSPage->nBottomMargin = ptOILPage->nBottomMargin; ptPMSPage->nLeftMargin = ptOILPage->nLeftMargin; ptPMSPage->nRightMargin = ptOILPage->nRightMargin; ptPMSPage->eColorantFamily = ptOILPage->eColorantFamily; ptPMSPage->bForceMonoIfCMYblank = ptOILPage->pstJob->bForceMonoIfCMYblank; ptPMSPage->uTotalPlanes = ptOILPage->nColorants; for(i=0; i < PMS_MAX_PLANES_COUNT; i++) { ptPMSPage->atPlane[i].uBandTotal = ptOILPage->atPlane[i].uBandTotal; switch(ptOILPage->atPlane[i].ePlaneColorant) { case OIL_Cyan: ptPMSPage->atPlane[i].ePlaneColorant = PMS_CYAN; break; case OIL_Magenta: ptPMSPage->atPlane[i].ePlaneColorant = PMS_MAGENTA; break; case OIL_Yellow: ptPMSPage->atPlane[i].ePlaneColorant = PMS_YELLOW; break; case OIL_Black: ptPMSPage->atPlane[i].ePlaneColorant = PMS_BLACK; break; case OIL_Red: ptPMSPage->atPlane[i].ePlaneColorant = PMS_RED; break; case OIL_Green: ptPMSPage->atPlane[i].ePlaneColorant = PMS_GREEN; break; case OIL_Blue: ptPMSPage->atPlane[i].ePlaneColorant = PMS_BLUE; break; case OIL_InvalidColor: default: ptPMSPage->atPlane[i].ePlaneColorant = PMS_INVALID_COLOURANT; break; } /* Don't pass values of bBlankPlane from OIL page to the PMS one, since they're all TRUE in the case of PUSH_BAND and PUSH_BAND_DIRECT because the page is passed early to the PMS, before any bands have arrived. Instead, default it to FALSE here and let CreatePMSBlankPlane set it to TRUE when necessary. */ ptPMSPage->atPlane[i].bBlankPlane = FALSE; for(j=0; j < ptOILPage->atPlane[i].uBandTotal; j++) { ptPMSPage->atPlane[i].atBand[j].uBandHeight = ptOILPage->atPlane[i].atBand[j].uBandHeight; ptPMSPage->atPlane[i].atBand[j].uBandNumber = ptOILPage->atPlane[i].atBand[j].uBandNumber; ptPMSPage->atPlane[i].atBand[j].pBandRaster = ptOILPage->atPlane[i].atBand[j].pBandRaster; ptPMSPage->atPlane[i].atBand[j].cbBandSize = ptOILPage->atPlane[i].atBand[j].cbBandSize; } for(; j < PMS_BAND_LIMIT; j++) { ptPMSPage->atPlane[i].atBand[j].uBandHeight = 0; ptPMSPage->atPlane[i].atBand[j].uBandNumber = 0; ptPMSPage->atPlane[i].atBand[j].pBandRaster = NULL; ptPMSPage->atPlane[i].atBand[j].cbBandSize = 0; } } ptPMSPage->nCopies = ptOILPage->uCopies; ptPMSPage->stMedia.uInputTray = ptOILPage->stMedia.uInputTray; ptPMSPage->stMedia.eOutputTray = ptOILPage->stMedia.uOutputTray; ptPMSPage->bIsRLE = ptOILPage->bIsRLE; ptPMSPage->bDuplex = ptOILPage->bDuplex; ptPMSPage->bCollate = ptOILPage->bCollate; ptPMSPage->bTumble = ptOILPage->bTumble; ptPMSPage->uOrientation = ptOILPage->uOrientation; ptPMSPage->bFaceUp = ptOILPage->bFaceUp; ptPMSPage->eColorMode = ptOILPage->pstJob->eColorMode; /* being used only in tiff comment field */ ptPMSPage->eScreenMode = ptOILPage->pstJob->eScreenMode; /* being used only in tiff comment field */ ptPMSPage->ulPickupTime = 0; ptPMSPage->ulOutputTime = 0; ptPMSPage->eState = PMS_CREATED; ptPMSPage->nBlankPage = ptOILPage->nBlankPage; ptPMSPage->stMedia.dWidth = ptOILPage->stMedia.dWidth; ptPMSPage->stMedia.dHeight = ptOILPage->stMedia.dHeight; strcpy((char*)ptPMSPage->stMedia.szMediaType, (char*)ptOILPage->stMedia.szMediaType); strcpy((char*)ptPMSPage->stMedia.szMediaColor, (char*)ptOILPage->stMedia.szMediaColor); ptPMSPage->stMedia.uMediaWeight = ptOILPage->stMedia.uMediaWeight; { /* discover paper size by asking PMS for trays and checking for the tray number that matches the tray enum value, as this is used to set the InputAttributes value ** Note this does not relate directly to the tray number ** needs fixing?? TODO**/ PMS_TyTrayInfo *pstPMSTrays = NULL; unsigned int nTrays = PMS_GetTrayInfo(&pstPMSTrays); ptPMSPage->stMedia.ePaperSize = pstPMSTrays[0].ePaperSize; for(j = 0; j < nTrays; j++) { if(pstPMSTrays[j].eMediaSource == (int)(ptPMSPage->stMedia.uInputTray)) { ptPMSPage->stMedia.ePaperSize = pstPMSTrays[j].ePaperSize; break; } } } OIL_ProbeLog(SW_TRACE_OIL_CREATEPMSPAGE, SW_TRACETYPE_EXIT, (intptr_t)0); return ptPMSPage; }