26#define MODNAME "DVR_Basic_driver"
51int module_start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi);
52int module_stop(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi);
54int DvrdrvSendCmdAck(struct_itr_sema *itrsema, u16 command, u16 *input_word, s32 input_word_count, u16 *status_4220, u16 *ack_status, u32 *status_4228);
55int DvrdrvSetDmaDirection(u32 arg);
56int DvrdrvTransferDma(u8 *output_buffer,
int a2);
57void DvrPreDmaHandler(
int bcr,
int dir);
58void DvrPostDmaHandler(
int bcr,
int dir);
59int DvrdrvPrepareWaitDmaEnd(struct_itr_sema *itrsema, u16 command);
60int DvrdrvCancelWaitDmaEnd(u16 command);
61int DvrdrvWaitDmaEnd(struct_itr_sema *itrsema, u16 command);
62int DvrdrvPrepareWaitCmdComp(struct_itr_sema *itrsema, u16 command, u32 timeout);
63int DvrdrvCancelWaitCmdComp(u16 command);
64int DvrdrvWaitCmdComp(struct_itr_sema *itrsema, u16 command, u16 *status_4220, u16 *comp_status, u32 *status_4228);
65s32 DvrdrvBlockPhase();
66s32 DvrdrvUnblockPhase();
68int DVR_INTR_HANDLER(
int flag);
69void INTR_DVRRDY_HANDLER(
int a1,
void *a2v);
70int INTR_DVRRDY_TO_HANDLER(
void *a1);
71void INTR_CMD_ACK_HANDLER(
int,
void *);
73void INTR_CMD_COMP_HANDLER(
int,
void *);
75void INTR_DMAACK_HANDLER(
int,
void *);
77void INTR_DMAEND_HANDLER(
int,
void *);
83struct_itr_sema *AllocItrSema();
84int ReleaseItrSema(
const struct_itr_sema *itrsema);
90void (*intrhandler_callbacks[32])(int,
void *);
91int intrhandler_intrnum[32];
92void *intrhandler_callbacksarg[32];
94struct_itr_sema itr_sema_table[32];
96int _start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi)
99 return module_start(argc, argv, startaddr, mi);
101 return module_stop(argc, argv, startaddr, mi);
104int module_start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi)
109 if (DvrdrvInit() != -1) {
110 if (RegisterLibraryEntries(&_exp_pvrdrv) == 0) {
112 return MODULE_REMOVABLE_END;
114 if (mi && ((mi->
newflags & 2) != 0))
116 return MODULE_RESIDENT_END;
120 return MODULE_NO_RESIDENT_END;
123int module_stop(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi)
130 ReleaseLibraryEntries(&_exp_pvrdrv);
131 if (DvrdrvEnd() != 0)
132 return MODULE_REMOVABLE_END;
133 return MODULE_NO_RESIDENT_END;
143 DVRDRV.mainthread_id = -1;
148 v0 = CreateSema(&v12);
156 v1 = CreateSema(&v13);
164 for (
int i = 0; i < 32; i += 1) {
165 itr_sema_table[i].sema = CreateSema(&v13);
166 itr_sema_table[i].used = 0;
168 for (
int i = 0; i < 32; i += 1) {
169 intrhandler_callbacks[i] = 0;
170 intrhandler_intrnum[i] = 0;
172 for (
int i = 0; i < 3; i += 1) {
173 for (
int j = 0; j < 32; j += 1) {
174 ClearItrSidTbl(&itrsid_table[i][j]);
177 SpdRegisterIntrHandler(9, DVR_INTR_HANDLER);
178 DvrdrvRegisterIntrHandler(1, &DVRDRV, INTR_DVRRDY_HANDLER);
179 DvrdrvRegisterIntrHandler(2, &DVRDRV, INTR_CMD_ACK_HANDLER);
180 DvrdrvRegisterIntrHandler(4, &DVRDRV, INTR_CMD_COMP_HANDLER);
181 DvrdrvRegisterIntrHandler(8, &DVRDRV, INTR_DMAACK_HANDLER);
182 DvrdrvRegisterIntrHandler(16, &DVRDRV, INTR_DMAEND_HANDLER);
183 DvrdrvEnableIntr(0x1Fu);
184 dev9RegisterPreDmaCb(2, DvrPreDmaHandler);
185 dev9RegisterPostDmaCb(2, DvrPostDmaHandler);
189int DvrdrvResetSystem()
198 SPD_REG8(0x4008) &= 0xFEu;
200 SPD_REG8(0x4008) |= 1u;
201 DVRDRV.mainthread_id = GetThreadId();
202 USec2SysClock(0x1C9C380u, &v4);
203 SetAlarm(&v4, (
unsigned int (*)(
void *))INTR_DVRRDY_TO_HANDLER, &DVRDRV);
205 CancelAlarm((
unsigned int (*)(
void *))INTR_DVRRDY_TO_HANDLER, &DVRDRV);
210 if ((DVRDRV.dvr_ready & 1) != 0)
212 DVRDRV.dvr_ready = 0;
214 DvrdrvDisableIntr(1);
219int DvrdrvSendCmdAck(struct_itr_sema *itrsema, u16 command, u16 *input_word, s32 input_word_count, u16 *status_4220, u16 *ack_status, u32 *status_4228)
228 unsigned int (*v19)(
void *);
231 unsigned int (*v22)(
void *);
242 if ((SPD_REG16(0x4230) & 2) != 0)
248 printf(
"DvrdrvSendCmdAck -> Command is running... (Time out)\n");
252 v14 = SetItrSidTbl(0, command, itrsema->sema);
255 printf(
"DvrdrvSendCmdAck() -> SetItrSidTbl Error\n");
258 SPD_REG16(0x4218) |= 0x80u;
259 while ((SPD_REG16(0x4218) & 0x80) != 0)
262 if (input_word_count > 0) {
267 SPD_REG16(0x4214) = v17;
268 }
while (v15 < input_word_count);
270 USec2SysClock(0x1C9C380u, &v28);
271 v18 = (u16)(command & 0xF00) >> 8;
273 v19 = (
unsigned int (*)(
void *))INTR_CMD_ACK_TO_HANDLER;
275 SetAlarm(&v28, v19, v14);
278 if (v18 && (u16)(command & 0xF00) >> 8 < 4u) {
279 v19 = (
unsigned int (*)(
void *))INTR_DMAACK_TO_HANDLER;
284 SPD_REG16(0x4210) = command;
286 v21 = (u16)(command & 0xF00) >> 8;
288 v22 = (
unsigned int (*)(
void *))INTR_CMD_ACK_TO_HANDLER;
290 if (!v21 || (u16)(command & 0xF00) >> 8 >= 4u) {
291 printf(
"DvrdrvSendCmdAck() -> Error!\n");
294 v22 = (
unsigned int (*)(
void *))INTR_DMAACK_TO_HANDLER;
296 CancelAlarm(v22, v14);
298 if (!v14->timed_out || v14->error) {
300 v24 = command & 0xF00;
301 if ((v23 & 0x8000) == 0) {
304 if ((v23 & 2) == 0) {
306 printf(
"DvrdrvSendCmdAck -> Interrupt Flag Error!,%04X\n", (u16)v14->error);
309 }
else if (v24 >> 8) {
312 if ((v14->error & 8) == 0) {
319 if ((SPD_REG16(0x4228) & 1) == 0)
320 v25 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
322 for (i = 0; (u32)i < *status_4228; ++ack_status) {
324 *ack_status = SPD_REG16(0x4224);
326 *status_4220 = SPD_REG16(0x4220);
332 printf(
"DvrdrvSendCmdAck() -> TO!\n");
340int DvrdrvSetDmaDirection(u32 arg)
343 if (arg < 2 && (SPD_REG16(0x4100) & 2) != 0) {
344 while ((SPD_REG16(0x4100) & 2) != 0)
347 if ((SPD_REG8(0x4004) & 7) == arg)
349 SPD_REG8(0x4004) = arg | (SPD_REG8(0x4004) & 0xF8);
350 SPD_REG16(0x4100) |= 1u;
351 while ((SPD_REG16(0x4100) & 1) != 0)
356int DvrdrvTransferDma(u8 *output_buffer,
int a2)
366 if (((u32)output_buffer & 3) != 0)
371 SPD_REG16(0x4108) = a2 / 128;
372 SPD_REG16(0x410C) = 32;
373 v8 = (u32 *)&output_buffer[128 * (u16)(a2 / 128)];
374 switch (SPD_REG8(0x4004) & 7) {
391 SpdDmaTransfer(2, output_buffer, (v6 << 16) | 0x20, v4);
395 SPD_REG16(0x4120) = ((*((u32 *)v8)) & 0x0000FFFF);
396 SPD_REG16(0x4122) = ((*((u32 *)v8)) & 0xFFFF0000) >> 16;
407void DvrPreDmaHandler(
int bcr,
int dir)
414 SPD_REG16(0x4100) |= 2u;
417void DvrPostDmaHandler(
int bcr,
int dir)
424 while ((SPD_REG16(0x4100) & 2) != 0)
428int DvrdrvPrepareWaitDmaEnd(struct_itr_sema *itrsema, u16 command)
435 SetItrSidTbl(1, command, itrsema->sema);
438 printf(
"DvrdrvPrepareWaitDmaEnd : itrsema==NULL\n");
444int DvrdrvCancelWaitDmaEnd(u16 command)
450 v2 = GetItrSidTbl(1, command);
456 printf(
"DvrdrvCancelWaitDmaEnd -> Cannot found Sid!!\n");
462int DvrdrvWaitDmaEnd(struct_itr_sema *itrsema, u16 command)
471 WaitSema(itrsema->sema);
472 v3 = GetItrSidTbl(1, command);
475 if ((v4 & 0x8000) == 0) {
476 if ((v4 & 0x10) != 0) {
480 if ((SPD_REG16(0x4228) & 1) != 0)
483 v6 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
491 *(u16 *)v8 = SPD_REG16(0x4224);
497 printf(
"DvrdrvWaitDmaEnd -> Interrupt Flag Error!,%04X\n", (u16)v3->error);
504int DvrdrvPrepareWaitCmdComp(struct_itr_sema *itrsema, u16 command, u32 timeout)
515 v8 = SetItrSidTbl(2, command, v7);
516 USec2SysClock(timeout, &v10);
517 SetAlarm(&v10, (
unsigned int (*)(
void *))INTR_CMD_COMP_TO_HANDLER, v8);
520 printf(
"DvrdrvPrepareWaitCmdComp : itrsema==NULL\n");
526int DvrdrvCancelWaitCmdComp(u16 command)
533 v2 = GetItrSidTbl(2, command);
536 CancelAlarm((
unsigned int (*)(
void *))INTR_CMD_COMP_TO_HANDLER, v2);
541 printf(
"DvrdrvCancelWaitCmdComp -> Cannot found Sid!!\n");
547int DvrdrvWaitCmdComp(struct_itr_sema *itrsema, u16 command, u16 *status_4220, u16 *comp_status, u32 *status_4228)
554 WaitSema(itrsema->sema);
555 v8 = GetItrSidTbl(2, command);
556 CancelAlarm((
unsigned int (*)(
void *))INTR_CMD_COMP_TO_HANDLER, v8);
558 if (!v8->timed_out) {
562 if ((v10 & 0x8000) == 0) {
563 if ((v10 & 4) != 0) {
566 if ((SPD_REG16(0x4228) & 1) != 0)
569 v11 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
572 if (*status_4228 > 0) {
578 *v13++ = SPD_REG16(0x4224);
579 }
while ((u32)v12 < *status_4228);
581 *status_4220 = SPD_REG16(0x4220);
584 printf(
"DvrdrvWaitCmdComp -> Interrupt Flag Error!,%04X\n", (u16)v8->error);
592s32 DvrdrvBlockPhase()
594 return WaitSema(phase_sema_id);
597s32 DvrdrvUnblockPhase()
599 return SignalSema(phase_sema_id);
602int DvrdrvEnableIntr(u16 a1)
608 SPD_REG16(0x4208) |= a1;
609 SpdIntrEnable(0x200);
614int DvrdrvDisableIntr(s16 a1)
620 SPD_REG16(0x4208) &= ~a1;
621 SPD_REG16(0x4204) = a1;
622 if (!SPD_REG16(0x4208))
623 SpdIntrDisable(0x200);
628int DvrdrvRegisterIntrHandler(
int a1,
void *arg,
void (*a3)(
int,
void *))
633 for (i = 0; i < 32; i += 1)
635 if (intrhandler_callbacks[i] == NULL)
637 intrhandler_callbacks[i] = a3;
638 intrhandler_intrnum[i] = a1;
639 intrhandler_callbacksarg[i] = arg;
648int DvrdrvUnregisterIntrHandler(
void (*a1)(
int,
void *))
653 for (i = 0; i < 32; i += 1)
655 if (intrhandler_callbacks[i] == a1)
657 intrhandler_callbacks[i] = NULL;
658 intrhandler_intrnum[i] = 0;
659 intrhandler_callbacksarg[i] = 0;
676 if (phase_sema_id < 0)
678 DvrdrvDisableIntr(0x801F);
679 DvrdrvUnregisterIntrHandler((
void *)INTR_DVRRDY_HANDLER);
680 DvrdrvUnregisterIntrHandler((
void *)INTR_CMD_ACK_HANDLER);
681 DvrdrvUnregisterIntrHandler((
void *)INTR_CMD_COMP_HANDLER);
682 DvrdrvUnregisterIntrHandler((
void *)INTR_DMAACK_HANDLER);
683 DvrdrvUnregisterIntrHandler((
void *)INTR_DMAEND_HANDLER);
684 DeleteSema(api_sema_id);
685 DeleteSema(phase_sema_id);
689 for (
int i = 0; i < 32; i += 1) {
690 DeleteSema(itr_sema_table[i].sema);
696int DVR_INTR_HANDLER(
int flag)
706 v4 = SPD_REG16(0x4200);
707 for (i = 0; i < 32; i += 1)
709 if ((intrhandler_intrnum[i] & v4) != 0)
711 if (intrhandler_callbacks[i])
713 intrhandler_callbacks[i](v4, intrhandler_callbacksarg[i]);
714 v1 |= intrhandler_intrnum[i];
718 SPD_REG16(0x4204) = v1;
722void INTR_DVRRDY_HANDLER(
int a1,
void *a2v)
729 if (a2->mainthread_id >= 0)
730 iWakeupThread(a2->mainthread_id);
733int INTR_DVRRDY_TO_HANDLER(
void *a1)
739 iReleaseWaitThread(v1);
743void INTR_CMD_ACK_HANDLER(
int a1,
void *a2)
753 v2 = GetItrSidTbl(0, SPD_REG16(0x4220));
758 Kprintf(
"Illegal Sema ID : %d\n", v6);
765 Kprintf(
"ACK:GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220));
766 Kprintf(
"Clear \"Reply FIFO\"\n");
768 if ((SPD_REG16(0x4228) & 1) == 0)
769 v3 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
777 *(u16 *)v5 = SPD_REG16(0x4224);
790 GetSystemTime(&clock);
792 Kprintf(
"CMDACK_TO:[%u]\n", v1);
799void INTR_CMD_COMP_HANDLER(
int a1,
void *a2)
809 v2 = GetItrSidTbl(2, SPD_REG16(0x4220));
814 Kprintf(
"Illegal thread ID : %d\n", v6);
821 Kprintf(
"COMP:GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220));
822 Kprintf(
"Clear \"Reply FIFO\"\n");
824 if ((SPD_REG16(0x4228) & 1) == 0)
825 v3 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
833 *(u16 *)v5 = SPD_REG16(0x4224);
846 GetSystemTime(&clock);
848 Kprintf(
"COMP TO:[%u]\n", v1);
855void INTR_DMAACK_HANDLER(
int a1,
void *a2)
864 v2 = GetItrSidTbl(0, SPD_REG16(0x4220));
869 Kprintf(
"Illegal thread ID : %d\n", v3);
873 Kprintf(
"GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220));
882 GetSystemTime(&clock);
884 Kprintf(
"DMAACK_TO:[%u]\n", v1);
885 GetItrSidTbl(0, a1->command)->timed_out = 1;
886 iSignalSema(a1->sema);
890void INTR_DMAEND_HANDLER(
int a1,
void *a2)
899 v2 = GetItrSidTbl(1, SPD_REG16(0x4220));
904 Kprintf(
"Illegal thread ID : %d\n", v3);
908 Kprintf(
"GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220));
914 WaitSema(api_sema_id);
920 SignalSema(api_sema_id);
930 for (i = 0; i < 32; i += 1) {
931 if (itrsid_table[itrsid_index][i].sema == -1 || itrsid_table[itrsid_index][i].command == command) {
932 itrsid_table[itrsid_index][i].command = command;
933 itrsid_table[itrsid_index][i].sema = sema;
934 itrsid_table[itrsid_index][i].error = 0;
940 return &itrsid_table[itrsid_index][i];
941 Kprintf(
"SetItrSidTbl : Error!\n");
951 for (i = 0; i < 32; i += 1) {
952 if (itrsid_table[itrsid_index][i].command == command) {
958 return &itrsid_table[itrsid_index][i];
959 Kprintf(
"GetItrSidTbl : Error!\n");
977struct_itr_sema *AllocItrSema()
980 struct_itr_sema *result;
985 for (i = 0; i < 32; i += 1)
987 if (!itr_sema_table[i].used)
989 itr_sema_table[i].used = 1;
990 result = &itr_sema_table[i];
997 printf(
"AllocItrSema : empty\n");
1001int ReleaseItrSema(
const struct_itr_sema *itrsema)
1008 for (i = 0; i < 32; i += 1)
1010 if (&itr_sema_table[i] == itrsema)
1012 itr_sema_table[i].used = 0;
1020 printf(
"ReleaseItrSema : full\n");
1024int DvrdrvExecCmdAck(drvdrv_exec_cmd_ack *a1)
1026 struct_itr_sema *v2;
1030 v2 = AllocItrSema();
1037 v4 = DvrdrvSendCmdAck(
1041 a1->input_word_count,
1042 &a1->status_4220_ack,
1043 &a1->ack_status_ack,
1044 &a1->status_4228_ack);
1045 DvrdrvUnblockPhase();
1049 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1055int DvrdrvExecCmdAckComp(drvdrv_exec_cmd_ack *a1)
1057 struct_itr_sema *v2;
1058 struct_itr_sema *v3;
1063 v2 = AllocItrSema();
1068 DvrdrvPrepareWaitCmdComp(v2, a1->command, a1->timeout);
1072 v6 = DvrdrvSendCmdAck(
1076 a1->input_word_count,
1077 &a1->status_4220_ack,
1078 &a1->ack_status_ack,
1079 &a1->status_4228_ack);
1081 DvrdrvCancelWaitCmdComp(a1->command);
1082 DvrdrvUnblockPhase();
1084 DvrdrvUnblockPhase();
1087 v6 = DvrdrvWaitCmdComp(v3, v7, &a1->status_4220_comp, &a1->comp_status, &a1->status_4228_comp);
1092 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1098int DvrdrvExecCmdAckDmaSendComp(drvdrv_exec_cmd_ack *a1)
1100 struct_itr_sema *v2;
1101 struct_itr_sema *v3;
1107 struct_itr_sema *v10;
1111 s32 input_word_count;
1117 v2 = AllocItrSema();
1120 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1123 DvrdrvPrepareWaitCmdComp(v2, a1->command, a1->timeout);
1126 v5 = DvrdrvSendCmdAck(
1130 a1->input_word_count,
1131 &a1->status_4220_ack,
1132 &a1->ack_status_ack,
1133 &a1->status_4228_ack);
1136 printf(
"Phase1 error -> %d\n", v5);
1139 DvrdrvUnblockPhase();
1142 DvrdrvSetDmaDirection(1u);
1143 v8 = a1->input_buffer_length;
1144 if ((v8 & 0x7F) != 0)
1145 v18 = (v8 / 128 + 1) << 7;
1147 v18 = a1->input_buffer_length;
1149 input_word_count = 2;
1150 v12 = (v9 & 0xF0FF) | 0x200;
1151 v13[0] = (v18 & 0xFFFF0000) >> 16;
1153 v10 = AllocItrSema();
1154 DvrdrvPrepareWaitDmaEnd(v10, v12);
1155 v6 = DvrdrvSendCmdAck(v3, v12, v13, input_word_count, &v15, ack_status, v17);
1160 if (!ack_status[0]) {
1162 DvrdrvCancelWaitDmaEnd(v12);
1164 DvrdrvTransferDma(a1->input_buffer, v18);
1165 DvrdrvWaitDmaEnd(v10, v12);
1167 ReleaseItrSema(v10);
1168 DvrdrvUnblockPhase();
1171 v6 = DvrdrvWaitCmdComp(v3, v11, &a1->status_4220_comp, &a1->comp_status, &a1->status_4228_comp);
1177 DvrdrvCancelWaitCmdComp(v7);
1178 DvrdrvUnblockPhase();
1184int DvrdrvExecCmdAckDmaRecvComp(drvdrv_exec_cmd_ack *a1)
1186 struct_itr_sema *v2;
1187 struct_itr_sema *v3;
1191 struct_itr_sema *v8;
1196 s32 input_word_count;
1201 v2 = AllocItrSema();
1204 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1207 DvrdrvPrepareWaitCmdComp(v2, a1->command, a1->timeout);
1210 v5 = DvrdrvSendCmdAck(
1214 a1->input_word_count,
1215 &a1->status_4220_ack,
1216 &a1->ack_status_ack,
1217 &a1->status_4228_ack);
1221 DvrdrvUnblockPhase();
1224 DvrdrvSetDmaDirection(0);
1226 input_word_count = 0;
1227 v11 = (v7 & 0xF0FF) | 0x300;
1228 v8 = AllocItrSema();
1229 DvrdrvPrepareWaitDmaEnd(v8, v11);
1230 v5 = DvrdrvSendCmdAck(v3, v11, v12, input_word_count, &v14, ack_status, v16);
1235 if (!ack_status[0]) {
1236 v9 = (ack_status[1] << 16) + ack_status[2];
1237 a1->ack_status_ack2 = v9;
1239 DvrdrvCancelWaitDmaEnd(v11);
1241 DvrdrvTransferDma((u8 *)a1->output_buffer, v9);
1242 DvrdrvWaitDmaEnd(v8, v11);
1245 DvrdrvUnblockPhase();
1248 v5 = DvrdrvWaitCmdComp(v3, v10, &a1->status_4220_comp, &a1->comp_status, &a1->status_4228_comp);
1254 DvrdrvCancelWaitCmdComp(v6);
1255 DvrdrvUnblockPhase();
1261int DvrdrvExecCmdAckDma2Comp(drvdrv_exec_cmd_ack *a1)
1263 struct_itr_sema *v2;
1264 struct_itr_sema *v3;
1268 struct_itr_sema *v8;
1271 struct_itr_sema *v11;
1276 s32 input_word_count;
1288 v2 = AllocItrSema();
1291 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1294 DvrdrvPrepareWaitCmdComp(v2, a1->command, a1->timeout);
1297 v5 = DvrdrvSendCmdAck(
1301 a1->input_word_count,
1302 &a1->status_4220_ack,
1303 &a1->ack_status_ack,
1304 &a1->status_4228_ack);
1307 DvrdrvUnblockPhase();
1310 DvrdrvSetDmaDirection(1u);
1311 v6 = a1->input_buffer_length;
1312 v20 = (v6 & 0x7F) != 0 ? (u32)((v6 / 128 + 1) << 7) : a1->input_buffer_length;
1314 input_word_count = 2;
1315 v14 = (v7 & 0xF0FF) | 0x200;
1316 v15[0] = (v20 & 0xFFFF0000) >> 16;
1318 v8 = AllocItrSema();
1319 DvrdrvPrepareWaitDmaEnd(v8, v14);
1320 v5 = DvrdrvSendCmdAck(v3, v14, v15, input_word_count, &v17, ack_status, v19);
1327 if (!ack_status[0]) {
1329 DvrdrvCancelWaitDmaEnd(v14);
1331 DvrdrvTransferDma(a1->input_buffer, v20);
1332 DvrdrvWaitDmaEnd(v8, v14);
1335 DvrdrvUnblockPhase();
1338 DvrdrvSetDmaDirection(0);
1341 v21 = (v10 & 0xF0FF) | 0x300;
1342 v11 = AllocItrSema();
1343 DvrdrvPrepareWaitDmaEnd(v11, v21);
1344 v5 = DvrdrvSendCmdAck(v3, v21, v22, v23, &v24, v25, v26);
1345 if (!v5 && !v25[0]) {
1346 v12 = (v25[1] << 16) + v25[2];
1347 a1->ack_status_ack2 = v12;
1349 DvrdrvCancelWaitDmaEnd(v21);
1351 DvrdrvTransferDma((u8 *)a1->output_buffer, v12);
1352 DvrdrvWaitDmaEnd(v11, v21);
1354 ReleaseItrSema(v11);
1355 DvrdrvUnblockPhase();
1358 v5 = DvrdrvWaitCmdComp(v3, v13, &a1->status_4220_comp, &a1->comp_status, &a1->status_4228_comp);
1365 DvrdrvCancelWaitCmdComp(v9);
1366 DvrdrvUnblockPhase();
int CpuResumeIntr(int state)
int CpuSuspendIntr(int *state)