Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / rom / usb / classes / felsunxi / class_DeviceBinding.c
blobda974034763c5d9884a8262819d999196aeaed54
1 /*
2 Copyright © 2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #ifdef DEBUG
10 #undef DEBUG
11 #endif
12 #define DEBUG 0
14 #include "felsunxi_intern.h"
16 struct FELSunxiDevice * AttemptDeviceBinding(LIBBASETYPEPTR LIBBASE, struct PsdDevice *pd) {
17 mybug(-1,("FELSunxi AttemptDeviceBinding\n"));
19 struct Library *ps;
21 IPTR prodid;
22 IPTR vendid;
24 if((ps = OpenLibrary("poseidon.library", 4))) {
25 psdGetAttrs(PGA_DEVICE, pd, DA_VendorID, &vendid, DA_ProductID, &prodid, TAG_END);
26 CloseLibrary(ps);
27 if((vendid == 0x1f3a) && (prodid == 0xefe8)) {
28 return ForceDeviceBinding(LIBBASE, pd);
32 return NULL;
35 struct FELSunxiDevice * ForceDeviceBinding(LIBBASETYPEPTR LIBBASE, struct PsdDevice *pd) {
36 mybug(-1,("FELSunxi ForceDeviceBinding\n"));
38 struct FELSunxiDevice *FELSunxiDevice;
39 struct Library *ps;
41 if((ps = OpenLibrary("poseidon.library", 4))) {
42 FELSunxiDevice = psdAllocVec(sizeof(struct FELSunxiDevice));
43 if(FELSunxiDevice) {
44 FELSunxiDevice->ps = ps;
45 FELSunxiDevice->pd = pd;
46 /* Open MUI for FELSunxiTask, don't bother to continue if it fails */
47 FELSunxiDevice->MUIMasterBase = OpenLibrary("muimaster.library", 0);
48 if(FELSunxiDevice->MUIMasterBase) {
49 mybug(-1,("Creating FELSunxiTask\n"));
50 FELSunxiDevice->readysignal = SIGB_SINGLE;
51 FELSunxiDevice->readysigtask = FindTask(NULL);
52 SetSignal(0, SIGF_SINGLE);
54 FELSunxiDevice->felsunxitask = psdSpawnSubTask("FELSunxi task", FELSunxiTask, FELSunxiDevice);
55 if(FELSunxiDevice->felsunxitask) {
56 /* Wait for FELSunxiTask to be ready */
57 psdBorrowLocksWait(FELSunxiDevice->felsunxitask, 1UL<<FELSunxiDevice->readysignal);
58 return FELSunxiDevice;
59 } else {
60 mybug(-1,("Failed to spawn the task\n"));
62 CloseLibrary(FELSunxiDevice->MUIMasterBase);
64 psdFreeVec(FELSunxiDevice);
66 CloseLibrary(ps);
69 return NULL;
72 void ReleaseDeviceBinding(LIBBASETYPEPTR LIBBASE, struct FELSunxiDevice *FELSunxiDevice) {
73 mybug(-1,("FELSunxi ReleaseDeviceBinding(%p)\n",FELSunxiDevice->pd));
76 We need to support user closing the app window and user pulling the plug
78 Signal(FELSunxiDevice->felsunxitask, SIGBREAKF_CTRL_C);