Esempio n. 1
0
struct NepClassUPS * SetupUPS(void)
{
    struct NepClassUPS *nch;
    struct PsdDevice *pd = NULL;
    struct PsdAppBinding *pab;
    ULONG unit;

    if(ArgsArray[ARGS_UNIT])
    {
        unit = *((ULONG *) ArgsArray[ARGS_UNIT]);
    } else {
        unit = 0;
    }
    do
    {
        do
        {
            pd = psdFindDevice(pd,
                               DA_VendorID, 0x04b4,
                               DA_ProductID, 0xfd11,
                               TAG_END);

        } while(pd && (unit--));

        if(!pd)
        {
            PutStr("No GemBird PowerManager found!\n");
            return(NULL);
        }
        if((nch = psdAllocVec(sizeof(struct NepClassUPS))))
        {
            nch->nch_Device = pd;
            nch->nch_ReleaseHook.h_Entry = (APTR) releasehook;

            pab = psdClaimAppBinding(ABA_Device, pd,
                                     ABA_ReleaseHook, &nch->nch_ReleaseHook,
                                     ABA_UserData, nch,
                                     ABA_ForceRelease, TRUE,
                                     TAG_END);
            if(pab)
            {
                if(AllocUPS(nch))
                {
                    return(nch);
                } else {
                    PutStr("Couldn't allocate PowerManager...\n");
                }
                psdReleaseAppBinding(pab);
            } else {
                PutStr("Couldn't claim binding!\n");
            }
            psdFreeVec(nch);
        }
        PutStr("Hohum...\n");
    } while(TRUE);
    return(NULL);
}
Esempio n. 2
0
struct NepClassDRadio * SetupDRadio(void)
{
    struct NepClassDRadio *nch;
    struct PsdDevice *pd = NULL;
    struct PsdAppBinding *pab;
    ULONG unit;

    if(ArgsArray[ARGS_UNIT])
    {
        unit = *((ULONG *) ArgsArray[ARGS_UNIT]);
    } else {
        unit = 0;
    }
    do
    {
        do
        {
            pd = psdFindDevice(pd,
                               DA_VendorID, 0x04b4,
                               DA_ProductID, 0x1002,
                               TAG_END);
        } while(pd && (unit--));

        if(!pd)
        {
            PutStr("No D-Link/GemTek Radio found!\n");
            return(NULL);
        }
        if((nch = psdAllocVec(sizeof(struct NepClassDRadio))))
        {
            nch->nch_Device = pd;
            nch->nch_ReleaseHook.h_Entry = (APTR) releasehook;

            pab = psdClaimAppBinding(ABA_Device, pd,
                                     ABA_ReleaseHook, &nch->nch_ReleaseHook,
                                     ABA_UserData, nch,
                                     TAG_END);
            if(pab)
            {
                if(AllocDRadio(nch))
                {
                    return(nch);
                } else {
                    PutStr("Couldn't allocate DRadio...\n");
                }
                psdReleaseAppBinding(pab);
            } else {
                PutStr("Couldn't claim binding!\n");
            }
            psdFreeVec(nch);
        }
        PutStr("Hohum...\n");
    } while(TRUE);
    return(NULL);
}
Esempio n. 3
0
void FreeRocket(struct NepClassRocket *nch)
{
    APTR pab;

    psdGetAttrs(PGA_DEVICE, nch->nch_Device,
                DA_Binding, &pab,
                TAG_END);
    psdReleaseAppBinding(pab);
    psdFreePipe(nch->nch_EP0Pipe);
    DeleteMsgPort(nch->nch_TaskMsgPort);
    psdFreeVec(nch);
}
Esempio n. 4
0
void freedevice(struct InstData *data) {

    if(data->ps3eye_ep0pipe) {
        psdFreePipe(data->ps3eye_ep0pipe); // Allowed to be NULL
        data->ps3eye_ep0pipe = NULL;
        mybug(-1, ("releasehook freed endpoint 0 pipe\n"));
    }

    if(data->ps3eye_ep1pipe) {
        psdFreePipe(data->ps3eye_ep1pipe); // Allowed to be NULL
        data->ps3eye_ep1pipe = NULL;
        mybug(-1, ("releasehook freed endpoint 1 pipe\n"));
    }

    if(data->pab) {
        /* CHECKME: Calls releasehook? */
        psdReleaseAppBinding(data->pab); // Allowed to be NULL
        data->pab = NULL;
        data->pd = NULL;
        mybug(-1, ("freedevice released PS3Eye camera binding\n"));
    }
}
Esempio n. 5
0
void allocdevice(struct InstData *data) {

    UBYTE regval, tmp;

    /*
        Try to find FREE PS3Eye camera (DA_Binding = FALSE)
    */
    data->pd = psdFindDevice(NULL, DA_VendorID, 0x1415, DA_ProductID, 0x2000, DA_Binding, FALSE, TAG_END);
    if(data->pd) {
        mybug(-1, ("allocdevice found PS3Eye camera\n"));

        data->releasehook.h_Entry = (APTR) releasehook;

        data->pab = psdClaimAppBinding(ABA_Device, data->pd,
                                       ABA_ReleaseHook, &data->releasehook,
                                       ABA_UserData, data,
                                       ABA_ForceRelease, FALSE,
                                       TAG_END);

        if(data->pab) {
            mybug(-1, ("allocdevice claimed PS3Eye camera\n"));

            if((data->ps3eye_interface = psdFindInterface(data->pd, NULL, IFA_InterfaceNum, 0, TAG_END))){
                mybug(-1, ("allocdevice found interface 0\n"));

                if((data->ps3eye_ep0pipe = psdAllocPipe(data->pd, data->ps3eye_epmsgport, NULL))) {
                    mybug(-1, ("allocdevice allocated endpoint 0 pipe (CONTROL)\n"));

                    if((data->ps3eye_ep1in = psdFindEndpoint(data->ps3eye_interface, NULL, EA_IsIn, TRUE, EA_EndpointNum, 1, EA_TransferType, USEAF_BULK, TAG_END))) {
                        mybug(-1, ("allocdevice found endpoint 1 (BULK) from interface 0\n"));

                        if((data->ps3eye_ep1pipe = psdAllocPipe(data->pd, data->ps3eye_epmsgport, data->ps3eye_ep1in))) {
                            mybug(-1, ("allocdevice allocated endpoint 1 pipe (BULK)\n"));

                            /*
                                We need to call our set method in order for the led to luminate or not depending on the tick box (may have been pressed before usb connection)
                                Well, it seems to work...
                            */
                            SetAttrs(data->self, MUIA_Resolution, data->resolutionvga, TAG_DONE);

                            /* Turn the camera on */
                            regval = 0x3a;
                            ov534_reg_write(data, OV534_REG_SYS_CTRL, &regval);

                            regval = OV772X_SLAVE_ADDRESS_WRITE;
                            ov534_reg_write(data, OV534_REG_MS_ID, &regval);

                            /* probe the sensor */
                        	mybug(-1, ("Sensor ID: %02x%02x\n", ov772x_reg_read(data, OV772X_REG_PID), ov772x_reg_read(data, OV772X_REG_VER)));

                            return;

                        } else {
                            mybug(-1, ("allocdevice failed to allocate endpoint 1 pipe (BULK)\n"));
                        }
                    } else {
                        mybug(-1, ("allocdevice could not find endpoint 1 (BULK) from interface 0\n"));
                    }

                } else {
                    mybug(-1, ("allocdevice failed to allocate endpoint 0 pipe (CONTROL)\n"));   
                }

            }

            psdReleaseAppBinding(data->pab);
            mybug(-1, ("allocdevice released PS3Eye camera binding\n"));

        } else {
            mybug(-1, ("allocdevice unable to claim PS3Eye camera\n"));
        }
    }
}