Пример #1
0
/*
 * copy a device to a FILE*.
 */
static int raw_copy(char *dev_name, int dev_unit, FILE *dst)
{
    struct MsgPort  *port   = NULL;
    struct IOStdReq *ioreq  = NULL;
    int tracklen            = 512*11;
    int retstatus           = 1;
    int inhibited           = 0;
    char *buffer            = NULL;
    static char name[]      = {'D','F','0','\0'};

    if(!strcmp(dev_name, "trackdisk.device")) {
	inhibited = 1;
	name[2] = '0'+dev_unit;
    }

    /* allocate system stuff */
    if((port   = CreatePort(0, 0)))            {
    if((ioreq  = CreateStdIO(port)))           {
    if((buffer = AllocMem(tracklen, MEMF_CHIP))) {

    /* gain access to the device */
    if(!OpenDevice(dev_name, dev_unit, (struct IORequest*)ioreq, 0)) {

    /* check if a disk is present */
    myDoIO(ioreq, TD_CHANGESTATE, 0, -1, -1, -1);
    if(!ioreq->io_Error && ioreq->io_Actual) {
	fprintf(stderr,"No disk in %s unit %d !\n", dev_name, dev_unit);
	retstatus = 0;
    } else {
	int tr = 0;
	int write_protected = 0;
	/* check if disk is write-protected:
	myDoIO(ioreq, TD_PROTSTATUS, 0, -1, -1, -1);
	if(!ioreq->io_Error && ioreq->io_Actual) write_protected = 1;
	*/

	/* inhibit device */
	if(inhibited) inhibited = dev_inhibit(name,1);

	/* read tracks */
	for(tr = 0; tr < 160; ++tr) {
	    printf("Reading track %2d side %d of %s unit %d  \r",
		   tr/2, tr%2, dev_name, dev_unit);
	    fflush(stdout);
	    myDoIO(ioreq, CMD_READ, -1, tracklen*tr, tracklen, (LONG)buffer);
	    if(ioreq->io_Error) printf("Err. on\n");
	    if(fwrite(buffer, 1, tracklen, dst) != (unsigned int)tracklen) {
	       retstatus = 0;
	       break;
	    }
	}

	/* ok everything done! */
	printf("                                                                        \r");
	fflush(stdout);

	/* stop motor */
	myDoIO(ioreq, TD_MOTOR, 0, -1, 0, -1);

	/* uninhibit */
	if(inhibited) dev_inhibit(name,0);
    }
    CloseDevice((struct IORequest*)ioreq);   } else retstatus = 0;
    FreeMem(buffer,tracklen);                } else retstatus = 0;
    DeleteStdIO(ioreq);                      } else retstatus = 0;
    DeletePort(port);                        } else retstatus = 0;
    return retstatus;
}
OMX_ERRORTYPE IpulibRender::RenderSetConfig(
    OMX_INDEXTYPE nParamIndex,
    OMX_PTR pStructure)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;

	switch (nParamIndex)
	{
	case OMX_IndexOutputMode:
	{
		OMX_CONFIG_OUTPUTMODE *pOutputMode;
		pOutputMode = (OMX_CONFIG_OUTPUTMODE*)pStructure;
		CHECK_STRUCT(pOutputMode, OMX_CONFIG_OUTPUTMODE, ret);
		fsl_osal_memcpy(&sOutputMode, pOutputMode, sizeof(OMX_CONFIG_OUTPUTMODE));
		fsl_osal_memcpy(&sRectIn, &pOutputMode->sRectIn, sizeof(OMX_CONFIG_RECTTYPE));
		fsl_osal_memcpy(&sRectOut, &pOutputMode->sRectOut, sizeof(OMX_CONFIG_RECTTYPE));
		eRotation = pOutputMode->eRotation;
		ResetDevice();
	}
	break;
	case OMX_IndexConfigCaptureFrame:
	{
		OMX_CONFIG_CAPTUREFRAME *pCapture;
		pCapture = (OMX_CONFIG_CAPTUREFRAME*)pStructure;
		CHECK_STRUCT(pCapture, OMX_CONFIG_CAPTUREFRAME, ret);
		sCapture.eType = pCapture->eType;
		sCapture.pBuffer = pCapture->pBuffer;
		bCaptureFrameDone = OMX_FALSE;
		if (sCapture.eType == CAP_SNAPSHOT)
		{
			if(pShowFrame == NULL)
			{
				ret = OMX_ErrorUndefined;
				break;
			}
			fsl_osal_memcpy(sCapture.pBuffer, pShowFrame, nFrameLen);
			sCapture.nFilledLen = nFrameLen;
			bCaptureFrameDone = OMX_TRUE;
		}
	}
	break;
	case OMX_IndexSysSleep:
		OMX_CONFIG_SYSSLEEP *pSysSleep;
		pSysSleep = (OMX_CONFIG_SYSSLEEP *)pStructure;
		bSuspend = pSysSleep->bSleep;
		fsl_osal_mutex_lock(lock);
		if(OMX_TRUE == bSuspend)
		{
			CloseDevice();
		}
		else
		{
			OMX_STATETYPE eState = OMX_StateInvalid;
			GetState(&eState);
			if(eState == OMX_StatePause)
				StartDeviceInPause();
		}
		fsl_osal_mutex_unlock(lock);
		break;
	default:
		ret = OMX_ErrorUnsupportedIndex;
		break;
	}

	return ret;
}
Пример #3
0
void closeDevice(struct AFSBase *afsbase, struct IOExtTD *ioreq) {
	if (ioreq->iotd_Req.io_Device != NULL)
		CloseDevice((struct IORequest *)&ioreq->iotd_Req);
	DeleteIORequest((APTR)ioreq);
}
Пример #4
0
static void unload_capslib (void)
{
    CloseDevice (CAPS_IOReq);
    DeleteIORequest (CAPS_IOReq);
    DeleteMsgPort (CAPS_MsgPort);
}
Пример #5
0
DWORD CSTDevice::SelectCurrentConfiguration(UINT ConfigIdx, UINT InterfaceIdx, UINT AltSetIdx)
{
	DWORD nRet;
	BYTE TheConfig[3];
	DWORD ByteCount;
	USB_INTERFACE_DESCRIPTOR Desc;
	PUSB_CONFIGURATION_DESCRIPTOR pConfDesc;

	// Put the InterfaceIdx to -1 if it should not be a search criterion.
	// Put the AltSetIdx to -1 if it should not be a search criterion.

	if (!m_bDeviceIsOpen)
		return STDEVICE_DRIVERISCLOSED;
	if (m_pPipeHandles)
		return STDEVICE_PIPESAREOPEN;

	pConfDesc=(PUSB_CONFIGURATION_DESCRIPTOR)(m_pConfigs[ConfigIdx]);
	nRet=GetInterfaceDescriptor(ConfigIdx,
								InterfaceIdx,
								AltSetIdx,
								&Desc);
	if (nRet!=STDEVICE_NOERROR)
		return nRet;
	m_bDeviceIsOpen=FALSE;
	// 1- Release the descriptors
	ReleaseDescriptors();
	// 2- Set the config
	m_CurrentConfig=ConfigIdx;
	m_CurrentInterf=InterfaceIdx;
	m_CurrentAltSet=AltSetIdx;
	// 3- Get the descriptors
	nRet=AllocDescriptors();
	// 4- Change the current config in the driver
	if (nRet==STDEVICE_NOERROR)
	{
		TheConfig[0]=pConfDesc->bConfigurationValue-1;
		TheConfig[1]=Desc.bInterfaceNumber;
		TheConfig[2]=Desc.bAlternateSetting;
		if (DeviceIoControl(m_DeviceHandle,
							PU_CONFIG,
							TheConfig,
							3,
							NULL,
							0,
							&ByteCount,
							NULL))
			nRet=STDEVICE_NOERROR;
		else
			nRet=STDEVICE_BADPARAMETER;
	}
	if (nRet==STDEVICE_NOERROR)
		m_bDeviceIsOpen=TRUE;
	else
	{
		ClosePipes();
		// 2- Release the descriptors
		ReleaseDescriptors();
		// 3- Close the device
		CloseDevice();
		m_bDeviceIsOpen=FALSE;
	}
	return nRet;
}