2 Copyright © 2014, The AROS Development Team. All rights reserved.
14 #include "felsunxi_intern.h"
16 struct FELSunxiDevice
* AttemptDeviceBinding(LIBBASETYPEPTR LIBBASE
, struct PsdDevice
*pd
) {
17 mybug(-1,("FELSunxi AttemptDeviceBinding\n"));
24 if((ps
= OpenLibrary("poseidon.library", 4))) {
25 psdGetAttrs(PGA_DEVICE
, pd
, DA_VendorID
, &vendid
, DA_ProductID
, &prodid
, TAG_END
);
27 if((vendid
== 0x1f3a) && (prodid
== 0xefe8)) {
28 return ForceDeviceBinding(LIBBASE
, pd
);
35 struct FELSunxiDevice
* ForceDeviceBinding(LIBBASETYPEPTR LIBBASE
, struct PsdDevice
*pd
) {
36 mybug(-1,("FELSunxi ForceDeviceBinding\n"));
38 struct FELSunxiDevice
*FELSunxiDevice
;
41 if((ps
= OpenLibrary("poseidon.library", 4))) {
42 FELSunxiDevice
= psdAllocVec(sizeof(struct 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
;
60 mybug(-1,("Failed to spawn the task\n"));
62 CloseLibrary(FELSunxiDevice
->MUIMasterBase
);
64 psdFreeVec(FELSunxiDevice
);
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
);