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);
70unsigned int INTR_DVRRDY_TO_HANDLER(
void *a1);
71void INTR_CMD_ACK_HANDLER(
int a1,
void *a2);
72unsigned int INTR_CMD_ACK_TO_HANDLER(
void *arg);
73void INTR_CMD_COMP_HANDLER(
int a1,
void *a2);
74unsigned int INTR_CMD_COMP_TO_HANDLER(
void *arg);
75void INTR_DMAACK_HANDLER(
int a1,
void *a2);
76unsigned int INTR_DMAACK_TO_HANDLER(
void *arg);
77void INTR_DMAEND_HANDLER(
int a1,
void *a2);
83struct_itr_sema *AllocItrSema();
84int ReleaseItrSema(
const struct_itr_sema *itrsema);
90void (*intrhandler_callbacks[32])(
int intrnr,
void *arg);
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, INTR_DVRRDY_TO_HANDLER, &DVRDRV);
205 CancelAlarm(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)
240 if ((SPD_REG16(0x4230) & 2) != 0)
246 printf(
"DvrdrvSendCmdAck -> Command is running... (Time out)\n");
250 v14 = SetItrSidTbl(0, command, itrsema->sema);
253 printf(
"DvrdrvSendCmdAck() -> SetItrSidTbl Error\n");
256 SPD_REG16(0x4218) |= 0x80u;
257 while ((SPD_REG16(0x4218) & 0x80) != 0)
260 if (input_word_count > 0) {
265 SPD_REG16(0x4214) = v17;
266 }
while (v15 < input_word_count);
268 USec2SysClock(0x1C9C380u, &v28);
269 v18 = (u16)(command & 0xF00) >> 8;
271 SetAlarm(&v28, INTR_CMD_ACK_TO_HANDLER, v14);
274 if (v18 && (u16)(command & 0xF00) >> 8 < 4u) {
275 SetAlarm(&v28, INTR_DMAACK_TO_HANDLER, v14);
280 SPD_REG16(0x4210) = command;
282 v21 = (u16)(command & 0xF00) >> 8;
284 CancelAlarm(INTR_CMD_ACK_TO_HANDLER, v14);
286 if (!v21 || (u16)(command & 0xF00) >> 8 >= 4u) {
287 printf(
"DvrdrvSendCmdAck() -> Error!\n");
290 CancelAlarm(INTR_DMAACK_TO_HANDLER, v14);
293 if (!v14->timed_out || v14->error) {
295 v24 = command & 0xF00;
296 if ((v23 & 0x8000) == 0) {
299 if ((v23 & 2) == 0) {
301 printf(
"DvrdrvSendCmdAck -> Interrupt Flag Error!,%04X\n", (u16)v14->error);
304 }
else if (v24 >> 8) {
307 if ((v14->error & 8) == 0) {
314 if ((SPD_REG16(0x4228) & 1) == 0)
315 v25 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
317 for (i = 0; (u32)i < *status_4228; ++ack_status) {
319 *ack_status = SPD_REG16(0x4224);
321 *status_4220 = SPD_REG16(0x4220);
327 printf(
"DvrdrvSendCmdAck() -> TO!\n");
335int DvrdrvSetDmaDirection(u32 arg)
338 if (arg < 2 && (SPD_REG16(0x4100) & 2) != 0) {
339 while ((SPD_REG16(0x4100) & 2) != 0)
342 if ((SPD_REG8(0x4004) & 7) == arg)
344 SPD_REG8(0x4004) = arg | (SPD_REG8(0x4004) & 0xF8);
345 SPD_REG16(0x4100) |= 1u;
346 while ((SPD_REG16(0x4100) & 1) != 0)
351int DvrdrvTransferDma(u8 *output_buffer,
int a2)
361 if (((u32)output_buffer & 3) != 0)
366 SPD_REG16(0x4108) = a2 / 128;
367 SPD_REG16(0x410C) = 32;
368 v8 = (u32 *)&output_buffer[128 * (u16)(a2 / 128)];
369 switch (SPD_REG8(0x4004) & 7) {
386 SpdDmaTransfer(2, output_buffer, (v6 << 16) | 0x20, v4);
390 SPD_REG16(0x4120) = ((*((u32 *)v8)) & 0x0000FFFF);
391 SPD_REG16(0x4122) = ((*((u32 *)v8)) & 0xFFFF0000) >> 16;
402void DvrPreDmaHandler(
int bcr,
int dir)
409 SPD_REG16(0x4100) |= 2u;
412void DvrPostDmaHandler(
int bcr,
int dir)
419 while ((SPD_REG16(0x4100) & 2) != 0)
423int DvrdrvPrepareWaitDmaEnd(struct_itr_sema *itrsema, u16 command)
430 SetItrSidTbl(1, command, itrsema->sema);
433 printf(
"DvrdrvPrepareWaitDmaEnd : itrsema==NULL\n");
439int DvrdrvCancelWaitDmaEnd(u16 command)
445 v2 = GetItrSidTbl(1, command);
451 printf(
"DvrdrvCancelWaitDmaEnd -> Cannot found Sid!!\n");
457int DvrdrvWaitDmaEnd(struct_itr_sema *itrsema, u16 command)
466 WaitSema(itrsema->sema);
467 v3 = GetItrSidTbl(1, command);
470 if ((v4 & 0x8000) == 0) {
471 if ((v4 & 0x10) != 0) {
475 if ((SPD_REG16(0x4228) & 1) != 0)
478 v6 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
486 *(u16 *)v8 = SPD_REG16(0x4224);
492 printf(
"DvrdrvWaitDmaEnd -> Interrupt Flag Error!,%04X\n", (u16)v3->error);
499int DvrdrvPrepareWaitCmdComp(struct_itr_sema *itrsema, u16 command, u32 timeout)
510 v8 = SetItrSidTbl(2, command, v7);
511 USec2SysClock(timeout, &v10);
512 SetAlarm(&v10, INTR_CMD_COMP_TO_HANDLER, v8);
515 printf(
"DvrdrvPrepareWaitCmdComp : itrsema==NULL\n");
521int DvrdrvCancelWaitCmdComp(u16 command)
528 v2 = GetItrSidTbl(2, command);
531 CancelAlarm(INTR_CMD_COMP_TO_HANDLER, v2);
536 printf(
"DvrdrvCancelWaitCmdComp -> Cannot found Sid!!\n");
542int DvrdrvWaitCmdComp(struct_itr_sema *itrsema, u16 command, u16 *status_4220, u16 *comp_status, u32 *status_4228)
549 WaitSema(itrsema->sema);
550 v8 = GetItrSidTbl(2, command);
551 CancelAlarm(INTR_CMD_COMP_TO_HANDLER, v8);
553 if (!v8->timed_out) {
557 if ((v10 & 0x8000) == 0) {
558 if ((v10 & 4) != 0) {
561 if ((SPD_REG16(0x4228) & 1) != 0)
564 v11 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
567 if (*status_4228 > 0) {
573 *v13++ = SPD_REG16(0x4224);
574 }
while ((u32)v12 < *status_4228);
576 *status_4220 = SPD_REG16(0x4220);
579 printf(
"DvrdrvWaitCmdComp -> Interrupt Flag Error!,%04X\n", (u16)v8->error);
587s32 DvrdrvBlockPhase()
589 return WaitSema(phase_sema_id);
592s32 DvrdrvUnblockPhase()
594 return SignalSema(phase_sema_id);
597int DvrdrvEnableIntr(u16 a1)
603 SPD_REG16(0x4208) |= a1;
604 SpdIntrEnable(0x200);
609int DvrdrvDisableIntr(s16 a1)
615 SPD_REG16(0x4208) &= ~a1;
616 SPD_REG16(0x4204) = a1;
617 if (!SPD_REG16(0x4208))
618 SpdIntrDisable(0x200);
623int DvrdrvRegisterIntrHandler(
int a1,
void *arg,
void (*a3)(
int intrnr,
void *arg))
628 for (i = 0; i < 32; i += 1)
630 if (intrhandler_callbacks[i] == NULL)
632 intrhandler_callbacks[i] = a3;
633 intrhandler_intrnum[i] = a1;
634 intrhandler_callbacksarg[i] = arg;
643int DvrdrvUnregisterIntrHandler(
void (*a1)(
int intrnr,
void *arg))
648 for (i = 0; i < 32; i += 1)
650 if (intrhandler_callbacks[i] == a1)
652 intrhandler_callbacks[i] = NULL;
653 intrhandler_intrnum[i] = 0;
654 intrhandler_callbacksarg[i] = 0;
671 if (phase_sema_id < 0)
673 DvrdrvDisableIntr(0x801F);
674 DvrdrvUnregisterIntrHandler((
void *)INTR_DVRRDY_HANDLER);
675 DvrdrvUnregisterIntrHandler((
void *)INTR_CMD_ACK_HANDLER);
676 DvrdrvUnregisterIntrHandler((
void *)INTR_CMD_COMP_HANDLER);
677 DvrdrvUnregisterIntrHandler((
void *)INTR_DMAACK_HANDLER);
678 DvrdrvUnregisterIntrHandler((
void *)INTR_DMAEND_HANDLER);
679 DeleteSema(api_sema_id);
680 DeleteSema(phase_sema_id);
684 for (
int i = 0; i < 32; i += 1) {
685 DeleteSema(itr_sema_table[i].sema);
691int DVR_INTR_HANDLER(
int flag)
701 v4 = SPD_REG16(0x4200);
702 for (i = 0; i < 32; i += 1)
704 if ((intrhandler_intrnum[i] & v4) != 0)
706 if (intrhandler_callbacks[i])
708 intrhandler_callbacks[i](v4, intrhandler_callbacksarg[i]);
709 v1 |= intrhandler_intrnum[i];
713 SPD_REG16(0x4204) = v1;
717void INTR_DVRRDY_HANDLER(
int a1,
void *a2v)
724 if (a2->mainthread_id >= 0)
725 iWakeupThread(a2->mainthread_id);
728unsigned int INTR_DVRRDY_TO_HANDLER(
void *a1)
734 iReleaseWaitThread(v1);
738void INTR_CMD_ACK_HANDLER(
int a1,
void *a2)
748 v2 = GetItrSidTbl(0, SPD_REG16(0x4220));
753 Kprintf(
"Illegal Sema ID : %d\n", v6);
760 Kprintf(
"ACK:GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220));
761 Kprintf(
"Clear \"Reply FIFO\"\n");
763 if ((SPD_REG16(0x4228) & 1) == 0)
764 v3 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
772 *(u16 *)v5 = SPD_REG16(0x4224);
779unsigned int INTR_CMD_ACK_TO_HANDLER(
void *arg)
787 GetSystemTime(&clock);
789 Kprintf(
"CMDACK_TO:[%u]\n", v1);
796void INTR_CMD_COMP_HANDLER(
int a1,
void *a2)
806 v2 = GetItrSidTbl(2, SPD_REG16(0x4220));
811 Kprintf(
"Illegal thread ID : %d\n", v6);
818 Kprintf(
"COMP:GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220));
819 Kprintf(
"Clear \"Reply FIFO\"\n");
821 if ((SPD_REG16(0x4228) & 1) == 0)
822 v3 = (u8)(SPD_REG16(0x4228) & 0xFC) >> 2;
830 *(u16 *)v5 = SPD_REG16(0x4224);
837unsigned int INTR_CMD_COMP_TO_HANDLER(
void *arg)
845 GetSystemTime(&clock);
847 Kprintf(
"COMP TO:[%u]\n", v1);
854void INTR_DMAACK_HANDLER(
int a1,
void *a2)
863 v2 = GetItrSidTbl(0, SPD_REG16(0x4220));
868 Kprintf(
"Illegal thread ID : %d\n", v3);
872 Kprintf(
"GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220));
876unsigned int INTR_DMAACK_TO_HANDLER(
void *arg)
883 GetSystemTime(&clock);
885 Kprintf(
"DMAACK_TO:[%u]\n", v1);
886 GetItrSidTbl(0, a1->command)->timed_out = 1;
887 iSignalSema(a1->sema);
891void INTR_DMAEND_HANDLER(
int a1,
void *a2)
900 v2 = GetItrSidTbl(1, SPD_REG16(0x4220));
905 Kprintf(
"Illegal thread ID : %d\n", v3);
909 Kprintf(
"GetItrSidTbl(%04Xh) error\n", SPD_REG16(0x4220));
915 WaitSema(api_sema_id);
921 SignalSema(api_sema_id);
931 for (i = 0; i < 32; i += 1) {
932 if (itrsid_table[itrsid_index][i].sema == -1 || itrsid_table[itrsid_index][i].command == command) {
933 itrsid_table[itrsid_index][i].command = command;
934 itrsid_table[itrsid_index][i].sema = sema;
935 itrsid_table[itrsid_index][i].error = 0;
941 return &itrsid_table[itrsid_index][i];
942 Kprintf(
"SetItrSidTbl : Error!\n");
952 for (i = 0; i < 32; i += 1) {
953 if (itrsid_table[itrsid_index][i].command == command) {
959 return &itrsid_table[itrsid_index][i];
960 Kprintf(
"GetItrSidTbl : Error!\n");
978struct_itr_sema *AllocItrSema()
981 struct_itr_sema *result;
986 for (i = 0; i < 32; i += 1)
988 if (!itr_sema_table[i].used)
990 itr_sema_table[i].used = 1;
991 result = &itr_sema_table[i];
998 printf(
"AllocItrSema : empty\n");
1002int ReleaseItrSema(
const struct_itr_sema *itrsema)
1009 for (i = 0; i < 32; i += 1)
1011 if (&itr_sema_table[i] == itrsema)
1013 itr_sema_table[i].used = 0;
1021 printf(
"ReleaseItrSema : full\n");
1025int DvrdrvExecCmdAck(drvdrv_exec_cmd_ack *a1)
1027 struct_itr_sema *v2;
1031 v2 = AllocItrSema();
1038 v4 = DvrdrvSendCmdAck(
1042 a1->input_word_count,
1043 &a1->status_4220_ack,
1044 &a1->ack_status_ack,
1045 &a1->status_4228_ack);
1046 DvrdrvUnblockPhase();
1050 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1056int DvrdrvExecCmdAckComp(drvdrv_exec_cmd_ack *a1)
1058 struct_itr_sema *v2;
1059 struct_itr_sema *v3;
1064 v2 = AllocItrSema();
1069 DvrdrvPrepareWaitCmdComp(v2, a1->command, a1->timeout);
1073 v6 = DvrdrvSendCmdAck(
1077 a1->input_word_count,
1078 &a1->status_4220_ack,
1079 &a1->ack_status_ack,
1080 &a1->status_4228_ack);
1082 DvrdrvCancelWaitCmdComp(a1->command);
1083 DvrdrvUnblockPhase();
1085 DvrdrvUnblockPhase();
1088 v6 = DvrdrvWaitCmdComp(v3, v7, &a1->status_4220_comp, &a1->comp_status, &a1->status_4228_comp);
1093 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1099int DvrdrvExecCmdAckDmaSendComp(drvdrv_exec_cmd_ack *a1)
1101 struct_itr_sema *v2;
1102 struct_itr_sema *v3;
1108 struct_itr_sema *v10;
1112 s32 input_word_count;
1118 v2 = AllocItrSema();
1121 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1124 DvrdrvPrepareWaitCmdComp(v2, a1->command, a1->timeout);
1127 v5 = DvrdrvSendCmdAck(
1131 a1->input_word_count,
1132 &a1->status_4220_ack,
1133 &a1->ack_status_ack,
1134 &a1->status_4228_ack);
1137 printf(
"Phase1 error -> %d\n", v5);
1140 DvrdrvUnblockPhase();
1143 DvrdrvSetDmaDirection(1u);
1144 v8 = a1->input_buffer_length;
1145 if ((v8 & 0x7F) != 0)
1146 v18 = (v8 / 128 + 1) << 7;
1148 v18 = a1->input_buffer_length;
1150 input_word_count = 2;
1151 v12 = (v9 & 0xF0FF) | 0x200;
1152 v13[0] = (v18 & 0xFFFF0000) >> 16;
1154 v10 = AllocItrSema();
1155 DvrdrvPrepareWaitDmaEnd(v10, v12);
1156 v6 = DvrdrvSendCmdAck(v3, v12, v13, input_word_count, &v15, ack_status, v17);
1161 if (!ack_status[0]) {
1163 DvrdrvCancelWaitDmaEnd(v12);
1165 DvrdrvTransferDma(a1->input_buffer, v18);
1166 DvrdrvWaitDmaEnd(v10, v12);
1168 ReleaseItrSema(v10);
1169 DvrdrvUnblockPhase();
1172 v6 = DvrdrvWaitCmdComp(v3, v11, &a1->status_4220_comp, &a1->comp_status, &a1->status_4228_comp);
1178 DvrdrvCancelWaitCmdComp(v7);
1179 DvrdrvUnblockPhase();
1185int DvrdrvExecCmdAckDmaRecvComp(drvdrv_exec_cmd_ack *a1)
1187 struct_itr_sema *v2;
1188 struct_itr_sema *v3;
1192 struct_itr_sema *v8;
1197 s32 input_word_count;
1202 v2 = AllocItrSema();
1205 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1208 DvrdrvPrepareWaitCmdComp(v2, a1->command, a1->timeout);
1211 v5 = DvrdrvSendCmdAck(
1215 a1->input_word_count,
1216 &a1->status_4220_ack,
1217 &a1->ack_status_ack,
1218 &a1->status_4228_ack);
1222 DvrdrvUnblockPhase();
1225 DvrdrvSetDmaDirection(0);
1227 input_word_count = 0;
1228 v11 = (v7 & 0xF0FF) | 0x300;
1229 v8 = AllocItrSema();
1230 DvrdrvPrepareWaitDmaEnd(v8, v11);
1231 v5 = DvrdrvSendCmdAck(v3, v11, v12, input_word_count, &v14, ack_status, v16);
1236 if (!ack_status[0]) {
1237 v9 = (ack_status[1] << 16) + ack_status[2];
1238 a1->ack_status_ack2 = v9;
1240 DvrdrvCancelWaitDmaEnd(v11);
1242 DvrdrvTransferDma((u8 *)a1->output_buffer, v9);
1243 DvrdrvWaitDmaEnd(v8, v11);
1246 DvrdrvUnblockPhase();
1249 v5 = DvrdrvWaitCmdComp(v3, v10, &a1->status_4220_comp, &a1->comp_status, &a1->status_4228_comp);
1255 DvrdrvCancelWaitCmdComp(v6);
1256 DvrdrvUnblockPhase();
1262int DvrdrvExecCmdAckDma2Comp(drvdrv_exec_cmd_ack *a1)
1264 struct_itr_sema *v2;
1265 struct_itr_sema *v3;
1269 struct_itr_sema *v8;
1272 struct_itr_sema *v11;
1277 s32 input_word_count;
1289 v2 = AllocItrSema();
1292 printf(
"DvrdrvExecCmdAck : Cannot alloc sema\n");
1295 DvrdrvPrepareWaitCmdComp(v2, a1->command, a1->timeout);
1298 v5 = DvrdrvSendCmdAck(
1302 a1->input_word_count,
1303 &a1->status_4220_ack,
1304 &a1->ack_status_ack,
1305 &a1->status_4228_ack);
1308 DvrdrvUnblockPhase();
1311 DvrdrvSetDmaDirection(1u);
1312 v6 = a1->input_buffer_length;
1313 v20 = (v6 & 0x7F) != 0 ? (u32)((v6 / 128 + 1) << 7) : a1->input_buffer_length;
1315 input_word_count = 2;
1316 v14 = (v7 & 0xF0FF) | 0x200;
1317 v15[0] = (v20 & 0xFFFF0000) >> 16;
1319 v8 = AllocItrSema();
1320 DvrdrvPrepareWaitDmaEnd(v8, v14);
1321 v5 = DvrdrvSendCmdAck(v3, v14, v15, input_word_count, &v17, ack_status, v19);
1328 if (!ack_status[0]) {
1330 DvrdrvCancelWaitDmaEnd(v14);
1332 DvrdrvTransferDma(a1->input_buffer, v20);
1333 DvrdrvWaitDmaEnd(v8, v14);
1336 DvrdrvUnblockPhase();
1339 DvrdrvSetDmaDirection(0);
1342 v21 = (v10 & 0xF0FF) | 0x300;
1343 v11 = AllocItrSema();
1344 DvrdrvPrepareWaitDmaEnd(v11, v21);
1345 v5 = DvrdrvSendCmdAck(v3, v21, v22, v23, &v24, v25, v26);
1346 if (!v5 && !v25[0]) {
1347 v12 = (v25[1] << 16) + v25[2];
1348 a1->ack_status_ack2 = v12;
1350 DvrdrvCancelWaitDmaEnd(v21);
1352 DvrdrvTransferDma((u8 *)a1->output_buffer, v12);
1353 DvrdrvWaitDmaEnd(v11, v21);
1355 ReleaseItrSema(v11);
1356 DvrdrvUnblockPhase();
1359 v5 = DvrdrvWaitCmdComp(v3, v13, &a1->status_4220_comp, &a1->comp_status, &a1->status_4228_comp);
1366 DvrdrvCancelWaitCmdComp(v9);
1367 DvrdrvUnblockPhase();
int CpuResumeIntr(int state)
int CpuSuspendIntr(int *state)