22 #define MODNAME "DVRMISC"
24 #define DPRINTF(x...) printf(MODNAME ": " x)
29 extern int module_start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi);
30 extern int module_stop(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi);
34 extern int dvrmisc_df_devctl(
iomanX_iop_file_t *a1,
const char *name,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
35 extern int dvrmisc_df_ioctl2(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
36 extern int dvrioctl2_nop(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
37 extern int dvrioctl2_version(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
38 extern int dvrioctl2_led_hdd_rec(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
39 extern int dvrioctl2_led_dvd_rec(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
40 extern int dvrioctl2_get_sircs(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
41 extern int dvrioctl2_get_time(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
42 extern int dvrioctl2_set_timezone(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
43 extern int dvrioctl2_save_preset_info(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
44 extern int dvrioctl2_load_preset_info(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
45 extern int dvrioctl2_test_dev_rst(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
46 extern int dvrioctl2_test_sdram_chk(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
47 extern int dvrioctl2_test_mpe_chk(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
48 extern int dvrioctl2_test_mpd_chk(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
49 extern int dvrioctl2_test_vdec_chk(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
50 extern int dvrioctl2_partition_free(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
51 extern int dvrioctl2_buzzer(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
52 extern int dvrioctl2_clr_preset_info(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
53 extern int dvrioctl2_get_vbi_err_rate(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
54 extern int dvrioctl2_update_dvrp_firmware(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
55 extern int dvrioctl2_flash_write_status(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
56 extern int dvrioctl2_set_device_key(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
57 extern int dvrioctl2_get_device_key(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
58 extern int dvrioctl2_set_dv_nodeid(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
59 extern int dvrioctl2_get_dv_nodeid(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
60 extern int dvrioctl2_diag_test(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
62 #ifdef DVRMISC_CFW_EXTENSIONS
63 extern int dvrioctl2_cfw_ping(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
64 extern int dvrioctl2_cfw_get_max_lba48(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
65 extern int dvrioctl2_cfw_mem_peek_poke(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
71 int (*fn)(
iomanX_iop_file_t *f,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen);
74 {0x5668, &dvrioctl2_get_sircs},
75 {0x5666, &dvrioctl2_led_hdd_rec},
76 {0x5667, &dvrioctl2_led_dvd_rec},
77 {0x5669, &dvrioctl2_get_time},
78 {0x566A, &dvrioctl2_set_timezone},
79 {0x566B, &dvrioctl2_save_preset_info},
80 {0x566C, &dvrioctl2_load_preset_info},
81 {0x5664, &dvrioctl2_nop},
82 {0x5665, &dvrioctl2_version},
83 {0x566D, &dvrioctl2_test_dev_rst},
84 {0x566E, &dvrioctl2_test_sdram_chk},
85 {0x566F, &dvrioctl2_test_mpe_chk},
86 {0x5670, &dvrioctl2_test_mpd_chk},
87 {0x5671, &dvrioctl2_test_vdec_chk},
88 {0x5672, &dvrioctl2_partition_free},
89 {0x5673, &dvrioctl2_buzzer},
90 {0x5674, &dvrioctl2_clr_preset_info},
91 {0x5675, &dvrioctl2_get_vbi_err_rate},
92 {0x5676, &dvrioctl2_update_dvrp_firmware},
93 {0x5677, &dvrioctl2_flash_write_status},
94 {0x5678, &dvrioctl2_set_device_key},
95 {0x5679, &dvrioctl2_get_device_key},
96 {0x567A, &dvrioctl2_set_dv_nodeid},
97 {0x567B, &dvrioctl2_get_dv_nodeid},
98 {0x5682, &dvrioctl2_diag_test},
99 #ifdef DVRMISC_CFW_EXTENSIONS
100 {0x5690, &dvrioctl2_cfw_ping},
101 {0x5691, &dvrioctl2_cfw_get_max_lba48},
102 {0x5692, &dvrioctl2_cfw_mem_peek_poke},
107 IOMANX_RETURN_VALUE_IMPL(
EUNSUP);
113 IOMANX_RETURN_VALUE(
EUNSUP),
114 IOMANX_RETURN_VALUE(
EUNSUP),
115 IOMANX_RETURN_VALUE(
EUNSUP),
116 IOMANX_RETURN_VALUE(
EUNSUP),
117 IOMANX_RETURN_VALUE(
EUNSUP),
118 IOMANX_RETURN_VALUE(
EUNSUP),
120 IOMANX_RETURN_VALUE(
EUNSUP),
121 IOMANX_RETURN_VALUE(
EUNSUP),
122 IOMANX_RETURN_VALUE(
EUNSUP),
123 IOMANX_RETURN_VALUE(
EUNSUP),
124 IOMANX_RETURN_VALUE(
EUNSUP),
125 IOMANX_RETURN_VALUE(
EUNSUP),
126 IOMANX_RETURN_VALUE(
EUNSUP),
127 IOMANX_RETURN_VALUE(
EUNSUP),
128 IOMANX_RETURN_VALUE(
EUNSUP),
129 IOMANX_RETURN_VALUE(
EUNSUP),
130 IOMANX_RETURN_VALUE(
EUNSUP),
131 IOMANX_RETURN_VALUE(
EUNSUP),
132 IOMANX_RETURN_VALUE(
EUNSUP),
133 IOMANX_RETURN_VALUE_S64(
EUNSUP),
135 IOMANX_RETURN_VALUE(
EUNSUP),
136 IOMANX_RETURN_VALUE(
EUNSUP),
141 .desc =
"Digital Video Recorder MISC task",
150 IRX_ID(MODNAME, 1, 1);
152 int _start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi)
155 return module_start(argc, argv, startaddr, mi);
157 return module_stop(argc, argv, startaddr, mi);
160 int module_start(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi)
168 for (i = 0; i < 30000; ++i) {
169 if (((*((vu32 *)0xB0004230)) & 4) != 0)
174 DPRINTF(
"MISC task of DVRP is not running...\n");
175 return MODULE_NO_RESIDENT_END;
177 if (iomanX_AddDrv(&DVRMISC) != 0)
178 return MODULE_NO_RESIDENT_END;
181 return MODULE_REMOVABLE_END;
183 if (mi && ((mi->
newflags & 2) != 0))
185 return MODULE_RESIDENT_END;
189 int module_stop(
int argc,
char *argv[],
void *startaddr,
ModuleInfo_t *mi)
196 if (iomanX_DelDrv(DVRMISC.name) != 0)
197 return MODULE_REMOVABLE_END;
198 return MODULE_NO_RESIDENT_END;
212 v1 = CreateSema(&v3);
223 if (DeleteSema(sema_id) != 0)
239 int dvrmisc_df_devctl(
258 while (DevctlCmdTbl[v12].cmd != cmd) {
260 if (v11 >=
sizeof(DevctlCmdTbl) /
sizeof(DevctlCmdTbl[0]))
263 v10 = DevctlCmdTbl[v12].fn(a1, cmd, arg, arglen, buf, buflen);
265 if (v11 ==
sizeof(DevctlCmdTbl) /
sizeof(DevctlCmdTbl[0]))
271 int dvrmisc_df_ioctl2(
292 int dvrioctl2_nop(
iomanX_iop_file_t *a1,
int cmd,
void *arg,
unsigned int arglen,
void *buf,
unsigned int buflen)
294 drvdrv_exec_cmd_ack cmdack;
303 cmdack.command = 0x5101;
304 cmdack.input_word_count = 0;
305 if (DvrdrvExecCmdAck(&cmdack)) {
306 DPRINTF(
"dvrioctl2_nop -> Handshake error!\n");
309 if (cmdack.ack_status_ack) {
310 DPRINTF(
"dvrioctl2_nop -> Status error!\n");
317 int dvrioctl2_version(
325 drvdrv_exec_cmd_ack cmdack;
333 cmdack.command = 0x5102;
334 cmdack.input_word_count = 0;
335 if (DvrdrvExecCmdAck(&cmdack)) {
336 DPRINTF(
"dvrioctl2_version -> Handshake error!\n");
338 }
else if (cmdack.ack_status_ack) {
339 DPRINTF(
"dvrioctl2_version -> Status error!\n");
342 *(u16 *)buf = cmdack.output_word[0];
343 *((u16 *)buf + 1) = cmdack.output_word[1];
348 int dvrioctl2_led_hdd_rec(
356 drvdrv_exec_cmd_ack cmdack;
364 cmdack.command = 0x5104;
365 cmdack.input_word_count = 1;
366 cmdack.input_word[0] = *(u16 *)arg;
367 if (DvrdrvExecCmdAck(&cmdack)) {
368 DPRINTF(
"dvrioctl2_led_hdd_rec -> Handshake error!\n");
371 if (cmdack.ack_status_ack) {
372 DPRINTF(
"dvrioctl2_led_hdd_rec -> Status error!\n");
379 int dvrioctl2_led_dvd_rec(
387 drvdrv_exec_cmd_ack cmdack;
395 cmdack.command = 0x5106;
396 cmdack.input_word_count = 1;
397 cmdack.input_word[0] = *(u16 *)arg;
398 if (DvrdrvExecCmdAck(&cmdack)) {
399 DPRINTF(
"dvrioctl2_led_dvd_rec -> Handshake error!\n");
402 if (cmdack.ack_status_ack) {
403 DPRINTF(
"dvrioctl2_led_dvd_rec -> Status error!\n");
410 int dvrioctl2_get_sircs(
418 drvdrv_exec_cmd_ack cmdack;
426 cmdack.command = 0x5107;
427 cmdack.input_word_count = 0;
428 if (DvrdrvExecCmdAck(&cmdack)) {
429 DPRINTF(
"dvrioctl2_get_sircs -> Handshake error!\n");
431 }
else if (cmdack.ack_status_ack) {
432 DPRINTF(
"dvrioctl2_get_sircs -> Status error!\n");
435 *(u16 *)buf = cmdack.output_word[0];
436 *((u16 *)buf + 1) = cmdack.output_word[1];
437 *((u16 *)buf + 2) = cmdack.output_word[2];
438 *((u16 *)buf + 3) = cmdack.output_word[3];
439 *((u16 *)buf + 4) = cmdack.output_word[4];
444 int dvrioctl2_get_time(
452 drvdrv_exec_cmd_ack cmdack;
460 cmdack.command = 0x5108;
461 cmdack.input_word_count = 0;
462 if (DvrdrvExecCmdAck(&cmdack)) {
463 DPRINTF(
"dvrioctl2_get_time -> Handshake error!\n");
465 }
else if (cmdack.ack_status_ack) {
466 DPRINTF(
"dvrioctl2_get_time -> Status error!\n");
469 *(u8 *)buf = cmdack.output_word[0];
470 *((u8 *)buf + 1) = cmdack.output_word[1];
471 *((u8 *)buf + 2) = cmdack.output_word[2];
472 *((u8 *)buf + 3) = cmdack.output_word[3];
473 *((u8 *)buf + 5) = cmdack.output_word[5];
474 *((u8 *)buf + 6) = cmdack.output_word[6];
475 *((u8 *)buf + 7) = cmdack.output_word[7];
480 int dvrioctl2_set_timezone(
488 drvdrv_exec_cmd_ack cmdack;
496 cmdack.command = 0x5109;
497 cmdack.input_word[0] = *(u16 *)arg;
498 cmdack.input_word_count = 2;
499 cmdack.input_word[1] = *((u16 *)arg + 1);
500 if (DvrdrvExecCmdAck(&cmdack)) {
501 DPRINTF(
"dvrioctl2_set_timezone -> Handshake error!\n");
504 if (cmdack.ack_status_ack) {
505 DPRINTF(
"dvrioctl2_set_timezone -> Status error!\n");
512 int dvrioctl2_save_preset_info(
520 drvdrv_exec_cmd_ack cmdack;
529 cmdack.command = 0x510A;
530 cmdack.input_word_count = 0;
531 cmdack.timeout = 15000000;
532 if (DvrdrvExecCmdAckComp(&cmdack)) {
533 DPRINTF(
"dvrioctl2_save_preset_info -> Handshake error!\n");
535 }
else if (cmdack.ack_status_ack || cmdack.comp_status) {
536 DPRINTF(
"dvrioctl2_save_preset_info -> Status error!\n");
542 int dvrioctl2_load_preset_info(
550 drvdrv_exec_cmd_ack cmdack;
559 cmdack.command = 0x510B;
560 cmdack.input_word_count = 0;
561 cmdack.timeout = 15000000;
562 if (DvrdrvExecCmdAckComp(&cmdack)) {
563 DPRINTF(
"dvrioctl2_load_preset_info -> Handshake error!\n");
565 }
else if (cmdack.ack_status_ack || cmdack.comp_status) {
566 DPRINTF(
"dvrioctl2_load_preset_info -> Status error!\n");
572 int dvrioctl2_test_dev_rst(
580 drvdrv_exec_cmd_ack cmdack;
589 cmdack.command = 0x510C;
590 cmdack.input_word_count = 0;
591 cmdack.timeout = 15000000;
592 if (DvrdrvExecCmdAckComp(&cmdack)) {
593 DPRINTF(
"dvrioctl2_test_dev_rst -> Handshake error!\n");
595 }
else if (cmdack.ack_status_ack || cmdack.comp_status) {
596 DPRINTF(
"dvrioctl2_test_dev_rst -> Status error!\n");
602 int dvrioctl2_test_sdram_chk(
610 drvdrv_exec_cmd_ack cmdack;
618 cmdack.command = 0x510D;
619 cmdack.input_word_count = 0;
620 cmdack.timeout = 20000000;
621 if (DvrdrvExecCmdAckComp(&cmdack)) {
622 DPRINTF(
"dvrioctl2_test_sdram_chk -> Handshake error!\n");
624 }
else if (cmdack.ack_status_ack || cmdack.comp_status) {
625 DPRINTF(
"dvrioctl2_test_sdram_chk -> Status error!\n");
628 *(u32 *)buf = (cmdack.return_result_word[0] << 16) + cmdack.return_result_word[1];
629 *((u32 *)buf + 1) = (cmdack.return_result_word[2] << 16) + cmdack.return_result_word[3];
630 *((u32 *)buf + 2) = (cmdack.return_result_word[4] << 16) + cmdack.return_result_word[5];
635 int dvrioctl2_test_mpe_chk(
643 drvdrv_exec_cmd_ack cmdack;
651 cmdack.command = 0x510E;
652 cmdack.input_word_count = 0;
653 cmdack.timeout = 15000000;
654 if (DvrdrvExecCmdAckComp(&cmdack)) {
655 DPRINTF(
"dvrioctl2_test_mpe_chk -> Handshake error!\n");
657 }
else if (cmdack.ack_status_ack || cmdack.comp_status) {
658 DPRINTF(
"dvrioctl2_test_mpe_chk -> Status error!\n");
661 *(u16 *)buf = cmdack.return_result_word[0];
666 int dvrioctl2_test_mpd_chk(
674 drvdrv_exec_cmd_ack cmdack;
682 cmdack.command = 0x510F;
683 cmdack.input_word_count = 0;
684 cmdack.timeout = 15000000;
685 if (DvrdrvExecCmdAckComp(&cmdack)) {
686 DPRINTF(
"dvrioctl2_test_mpd_chk -> Handshake error!\n");
688 }
else if (cmdack.ack_status_ack || cmdack.comp_status) {
689 DPRINTF(
"dvrioctl2_test_mpd_chk -> Status error!\n");
692 *(u16 *)buf = cmdack.return_result_word[0];
697 int dvrioctl2_test_vdec_chk(
705 drvdrv_exec_cmd_ack cmdack;
714 cmdack.command = 0x5110;
715 cmdack.input_word_count = 0;
716 cmdack.timeout = 15000000;
717 if (DvrdrvExecCmdAckComp(&cmdack)) {
718 DPRINTF(
"dvrioctl2_test_vdec_chk -> Handshake error!\n");
720 }
else if (cmdack.ack_status_ack || cmdack.comp_status) {
721 DPRINTF(
"dvrioctl2_test_vdec_chk -> Status error!\n");
727 int dvrioctl2_partition_free(
745 v7 = iomanX_devctl((
const char *)arg, 0x5002, 0, 0, 0, 0);
748 DPRINTF(
"dvrioctl2_partition_free : Cannot execute PDIOC_ZONEFREE.,%d\n", v7);
751 v9 = iomanX_devctl((
const char *)arg, 0x5001, 0, 0, 0, 0);
754 DPRINTF(
"dvrioctl2_partition_free : Cannot execute PDIOC_ZONESZ.,%d\n", v9);
758 if (*(s64 *)buf <= 0x7FFFFFF) {
760 *((u32 *)buf + 1) = 0;
762 *(u32 *)buf = v10 - 0x8000000;
763 *((u32 *)buf + 1) = (v10 >> 32) - 1 + ((
unsigned int)(v10 - 0x8000000) < 0xF8000000);
768 int dvrioctl2_buzzer(
776 drvdrv_exec_cmd_ack cmdack;
785 cmdack.command = 0x5111;
786 cmdack.input_word_count = 0;
787 if (DvrdrvExecCmdAck(&cmdack)) {
788 DPRINTF(
"dvrioctl2_buzzer -> Handshake error!\n");
791 if (cmdack.ack_status_ack) {
792 DPRINTF(
"dvrioctl2_buzzer -> Status error!\n");
799 int dvrioctl2_clr_preset_info(
807 drvdrv_exec_cmd_ack cmdack;
816 cmdack.command = 0x5112;
817 cmdack.input_word_count = 0;
818 cmdack.timeout = 20000000;
819 if (DvrdrvExecCmdAckComp(&cmdack)) {
820 DPRINTF(
"dvrioctl2_clr_preset_info -> Handshake error!\n");
823 if (cmdack.ack_status_ack) {
824 DPRINTF(
"dvrioctl2_clr_preset_info -> Status error!\n");
831 int dvrioctl2_get_vbi_err_rate(
839 drvdrv_exec_cmd_ack cmdack;
847 cmdack.command = 0x5113;
848 cmdack.input_word_count = 0;
849 if (DvrdrvExecCmdAck(&cmdack)) {
850 DPRINTF(
"dvrioctl2_get_vbi_err_rate -> Handshake error!\n");
853 if (cmdack.ack_status_ack) {
854 DPRINTF(
"dvrioctl2_get_vbi_err_rate -> Status error!\n");
857 *(u32 *)buf = (cmdack.output_word[0] << 16) + cmdack.output_word[1];
858 *((u32 *)buf + 1) = (cmdack.output_word[2] << 16) + cmdack.output_word[3];
864 int dvrioctl2_update_dvrp_firmware(
878 drvdrv_exec_cmd_ack cmdack;
888 update_fd = iomanX_open((
const char *)arg, 1, 0x49, arglen);
893 update_size = iomanX_lseek(update_fd, 0, 2);
894 if (iomanX_lseek(update_fd, 0, 0) < 0)
896 cmdack.command = 0x5114;
897 cmdack.input_word[0] = update_size >> 16;
898 cmdack.input_word[1] = update_size;
899 cmdack.input_word_count = 2;
900 cmdack.timeout = 10000000;
901 if (DvrdrvExecCmdAckComp(&cmdack)) {
902 DPRINTF(
"FLASH_DATA_TOTALSIZE -> Handshake error!\n");
907 if (cmdack.ack_status_ack) {
908 DPRINTF(
"FLASH_DATA_TOTALSIZE -> Status error!\n");
911 if (cmdack.comp_status) {
912 DPRINTF(
"FLASH_DATA_TOTALSIZE -> Status error!\n");
915 if (update_size != (cmdack.return_result_word[0] << 16) + cmdack.return_result_word[1])
916 DPRINTF(
"Size of firmware is not equal to Size of buffer on DVRP memory.\n");
917 for (i = 0x3FFF;; i = 0x3FFF) {
927 read_size = iomanX_read(update_fd, SBUF, 0x4000);
930 cmdack.command = 0x5115;
931 cmdack.input_word[0] = read_offset >> 16;
932 cmdack.input_word[1] = read_offset;
933 cmdack.input_word_count = 2;
934 cmdack.input_buffer = SBUF;
935 cmdack.input_buffer_length = read_size;
936 cmdack.timeout = 10000000;
937 if (DvrdrvExecCmdAckDmaSendComp(&cmdack)) {
938 DPRINTF(
"MISCCMD_FLASH_DATA_DOWNLOAD -> Handshake error!\n");
941 if (cmdack.ack_status_ack || (read_offset += read_size, cmdack.comp_status)) {
942 DPRINTF(
"MISCCMD_FLASH_DATA_DOWNLOAD -> Status error!\n");
945 for (j = 0; j < read_size; ++j) {
946 checksum += (u8)SBUF[j];
949 cmdack.command = 0x5116;
950 cmdack.input_word[0] = update_size >> 16;
951 cmdack.input_word[2] = checksum >> 16;
952 cmdack.input_word[1] = update_size;
953 cmdack.input_word[3] = checksum;
954 cmdack.input_word[4] = 0;
955 cmdack.input_word[5] = 0;
956 cmdack.input_word_count = 6;
957 cmdack.timeout = 10000000;
958 if (DvrdrvExecCmdAckComp(&cmdack)) {
959 DPRINTF(
"MISCCMD_FLASH_DATA_CHECKSUM -> Handshake error!\n");
962 if (cmdack.ack_status_ack) {
963 DPRINTF(
"MISCCMD_FLASH_DATA_CHECKSUM -> ACK Status error!\n");
965 if (cmdack.comp_status) {
967 DPRINTF(
"MISCCMD_FLASH_DATA_CHECKSUM -> COMP Status error!\n");
969 "Check sum error! IOP:%08X,DVRP:%08X\n",
971 (cmdack.return_result_word[0] << 16) | cmdack.return_result_word[1]);
974 cmdack.command = 0x5117;
975 cmdack.input_word_count = 0;
976 cmdack.timeout = 10000000;
977 if (DvrdrvExecCmdAckComp(&cmdack)) {
978 DPRINTF(
"MISCCMD_FLASH_DATA_WRITE -> Handshake error!\n");
981 if (cmdack.ack_status_ack) {
982 DPRINTF(
"MISCCMD_FLASH_DATA_WRITE -> ACK Status error!\n");
985 if (!cmdack.comp_status)
987 DPRINTF(
"MISCCMD_FLASH_DATA_WRITE -> COMP Status error!\n");
992 iomanX_close(update_fd);
996 int dvrioctl2_flash_write_status(
1000 unsigned int arglen,
1002 unsigned int buflen)
1004 drvdrv_exec_cmd_ack cmdack;
1012 cmdack.command = 0x5118;
1013 cmdack.input_word_count = 0;
1014 if (DvrdrvExecCmdAck(&cmdack)) {
1015 DPRINTF(
"dvrioctl2_flash_write_status -> Handshake error!\n");
1017 }
else if (cmdack.ack_status_ack) {
1018 DPRINTF(
"dvrioctl2_flash_write_status -> Status error!\n");
1021 *(u16 *)buf = cmdack.output_word[0];
1022 *((u16 *)buf + 1) = cmdack.output_word[1];
1027 int dvrioctl2_set_device_key(
1031 unsigned int arglen,
1033 unsigned int buflen)
1039 int *byteswap_tmp_end;
1042 drvdrv_exec_cmd_ack cmdack;
1045 "dvrioctl2_set_device_key (io=%p,cmd=%08X,argp=%p,arglen=%u,bufp=%p,buflen=%u)\n",
1052 cmdack.command = 0x511B;
1053 cmdack.input_word[0] = 0;
1054 cmdack.input_word[1] = 456;
1055 cmdack.input_word_count = 2;
1056 cmdack.timeout = 10000000;
1057 DPRINTF(
"dvrcmd.cmd_p[0]:%x\n", 0);
1058 DPRINTF(
"dvrcmd.cmd_p[1]:%x\n", 456);
1059 cmdack_err = DvrdrvExecCmdAckComp(&cmdack);
1060 DPRINTF(
"dvrcmd.ack_p[0]:%x\n", cmdack.ack_status_ack);
1062 DPRINTF(
"DEVKEY_TOTALSIZE -> Handshake error!\n");
1065 if (cmdack.ack_status_ack || cmdack.comp_status) {
1066 DPRINTF(
"DEVKEY_TOTALSIZE -> Status error!\n");
1069 bsize = (cmdack.return_result_word[0] << 16) + cmdack.return_result_word[1];
1071 DPRINTF(
"Size of firmware is not equal to Size of buffer on DVRP memory.\n");
1072 DPRINTF(
"FSIZE:%08X\n", 456);
1073 DPRINTF(
"BSIZE:%08X\n", bsize);
1074 cmdack.command = 0x511C;
1075 ((u32 *)SBUF)[0] = *(u32 *)
"XESD";
1076 byteswap_tmp2 = (
int *)&SBUF[4];
1077 byteswap_tmp = (
int *)arg;
1078 byteswap_tmp_end = (
int *)((
char *)arg + 448);
1080 byteswap_tmp2[0] = byteswap_tmp[0];
1081 byteswap_tmp2[1] = byteswap_tmp[1];
1082 byteswap_tmp2[2] = byteswap_tmp[2];
1083 byteswap_tmp2[3] = byteswap_tmp[3];
1086 }
while (byteswap_tmp != byteswap_tmp_end);
1087 *byteswap_tmp2 = *byteswap_tmp;
1088 cmdack.input_word_count = 2;
1089 cmdack.input_word[0] = 0;
1090 cmdack.input_word[1] = 0;
1091 cmdack.input_buffer = &SBUF;
1092 cmdack.input_buffer_length = 456;
1093 cmdack.timeout = 10000000;
1094 cmdack_err3 = DvrdrvExecCmdAckDmaSendComp(&cmdack);
1095 DPRINTF(
"dvrcmd.ack_p[0]:%x\n", cmdack.ack_status_ack);
1097 DPRINTF(
"MISCCMD_DEVKEY_DOWNLOAD -> Handshake error!\n");
1100 if (cmdack.ack_status_ack) {
1101 DPRINTF(
"MISCCMD_DEVKEY_DOWNLOAD -> Status error!\n");
1104 if (cmdack.comp_status) {
1105 DPRINTF(
"MISCCMD_DEVKEY_DOWNLOAD -> Status error!\n");
1108 cmdack.command = 0x5119;
1109 cmdack.input_word_count = 0;
1110 cmdack.timeout = 10000000;
1111 cmdack_err2 = DvrdrvExecCmdAckComp(&cmdack);
1112 DPRINTF(
"dvrcmd.ack_p[0]:%x\n", cmdack.ack_status_ack);
1114 DPRINTF(
"MISCCMD_SAVE_DEVKEY_INFO -> Handshake error!\n");
1117 if (cmdack.ack_status_ack) {
1118 DPRINTF(
"MISCCMD_SAVE_DEVKEY_INFO -> Status error!\n");
1121 if (cmdack.comp_status) {
1122 DPRINTF(
"MISCCMD_SAVE_DEVKEY_INFO -> Status error!\n");
1128 int dvrioctl2_get_device_key(
1132 unsigned int arglen,
1134 unsigned int buflen)
1137 u16 *return_result_word;
1139 drvdrv_exec_cmd_ack cmdack;
1148 cmdack.command = 0x511A;
1149 cmdack.input_word[0] = 0;
1150 cmdack.input_word[1] = 4;
1151 cmdack.input_word_count = 2;
1152 cmdack.timeout = 15000000;
1153 if (DvrdrvExecCmdAckComp(&cmdack)) {
1154 DPRINTF(
"MISCCMD_GET_DEVKEY_INFO -> Handshake error!\n");
1157 if (cmdack.ack_status_ack) {
1158 DPRINTF(
"MISCCMD_GET_DEVKEY_INFO -> Status error!\n");
1161 if (cmdack.comp_status) {
1162 DPRINTF(
"MISCCMD_GET_DEVKEY_INFO -> Status error!\n");
1166 return_result_word = cmdack.return_result_word;
1171 v8[0] = (*return_result_word & 0xFF00) >> 8;
1172 v8[1] = (*return_result_word & 0x00FF);
1173 return_result_word += 1;
1177 }
while (busywait-- >= 0);
1178 if (memcmp(v27,
"XESD", 4) == 0) {
1186 in_word_tmp = &cmdack.return_result_word[2];
1189 v15 = (u8 *)buf + v13;
1191 v15[0] = (*in_word_tmp & 0xFF00) >> 8;
1192 v15[1] = (*in_word_tmp & 0x00FF);
1205 cmdack.command = 0x511A;
1206 cmdack.input_word[0] = v17;
1207 cmdack.input_word[1] = v21;
1208 cmdack.input_word_count = 2;
1209 cmdack.timeout = 30000000;
1210 if (DvrdrvExecCmdAckComp(&cmdack)) {
1211 DPRINTF(
"MISCCMD_GET_DEVKEY_INFO -> Handshake error!\n");
1214 if (cmdack.ack_status_ack) {
1215 DPRINTF(
"MISCCMD_GET_DEVKEY_INFO -> Status error!\n");
1219 if (cmdack.comp_status) {
1220 DPRINTF(
"MISCCMD_GET_DEVKEY_INFO -> Status error!\n");
1223 if ((u16)v21 + 1 > 1) {
1225 in_word_tmp2 = cmdack.return_result_word;
1228 v24 = (u8 *)buf + v19;
1231 v24[4] = (*in_word_tmp2 & 0xFF00) >> 8;
1232 v24[5] = (*in_word_tmp2 & 0x00FF);
1234 }
while (v22 < (u16)v21 + 1);
1246 int dvrioctl2_set_dv_nodeid(
1250 unsigned int arglen,
1252 unsigned int buflen)
1254 unsigned int argwalked;
1255 drvdrv_exec_cmd_ack cmdack;
1263 cmdack.command = 0x511D;
1266 inword_tmp = ((u8 *)&cmdack.input_word[0]);
1269 inword_tmp2 = ((u8 *)arg + argwalked);
1270 inword_tmp[0] = inword_tmp2[1];
1271 inword_tmp[1] = inword_tmp2[0];
1274 }
while (argwalked < arglen);
1276 cmdack.input_word_count = 4;
1277 cmdack.timeout = 10000000;
1278 if (DvrdrvExecCmdAckComp(&cmdack)) {
1279 DPRINTF(
"MISCCMD_SAVE_DV_NODEID -> Handshake error!\n");
1282 if (cmdack.ack_status_ack) {
1283 DPRINTF(
"MISCCMD_SAVE_DV_NODEID -> Status error!\n");
1286 if (cmdack.comp_status) {
1287 DPRINTF(
"MISCCMD_SAVE_DV_NODEID -> Status error!\n");
1293 int dvrioctl2_get_dv_nodeid(
1297 unsigned int arglen,
1299 unsigned int buflen)
1301 unsigned int bufwalked;
1302 drvdrv_exec_cmd_ack cmdack;
1309 cmdack.command = 0x511E;
1310 cmdack.input_word_count = 0;
1311 cmdack.timeout = 15000000;
1312 if (DvrdrvExecCmdAckComp(&cmdack)) {
1313 DPRINTF(
"MISCCMD_GET_DV_NODEID -> Handshake error!\n");
1316 if (cmdack.ack_status_ack) {
1317 DPRINTF(
"MISCCMD_GET_DV_NODEID -> Status error!\n");
1320 if (cmdack.comp_status) {
1321 DPRINTF(
"MISCCMD_GET_DV_NODEID -> Status error!\n");
1326 u16 *return_result_word;
1329 return_result_word = cmdack.return_result_word;
1332 buftmp = (
char *)buf + bufwalked;
1334 buftmp[0] = (*return_result_word & 0xFF00) >> 8;
1335 buftmp[1] = (*return_result_word & 0x00FF);
1336 return_result_word += 1;
1337 }
while (bufwalked < buflen);
1340 while ((
unsigned int)(bufbusyloop++) < buflen)
1348 int dvrioctl2_diag_test(
1352 unsigned int arglen,
1354 unsigned int buflen)
1362 drvdrv_exec_cmd_ack cmdack;
1369 cmdack.command = 0x511F;
1370 cmdack.input_word[0] = *(u16 *)arg;
1371 cmdack.input_word[1] = *((u16 *)arg + 1);
1372 cmdack.input_word[2] = *((u16 *)arg + 2);
1373 cmdack.input_word[3] = *((u16 *)arg + 3);
1374 cmdack.input_word[4] = *((u16 *)arg + 4);
1375 cmdack.input_word_count = 5;
1376 cmdack.timeout = 120000000;
1377 if (cmdack.input_word[2]) {
1378 DPRINTF(
"------------------- > SetTO:%d msec\n", 120000);
1379 cmdack.timeout = 10000000 * cmdack.input_word[2];
1381 DPRINTF(
"arg : %4x", cmdack.input_word[0]);
1382 DPRINTF(
" %4x", cmdack.input_word[1]);
1383 DPRINTF(
" %4x ", cmdack.input_word[2]);
1384 DPRINTF(
" SetTimeOutTo : %d usec\n", cmdack.timeout);
1385 cmdack_err = DvrdrvExecCmdAckComp(&cmdack);
1387 testcnt_tmp = test_count++;
1390 "cmd ID : %d -------------------- TEST VERSION - diag test -------------------- r %d -- c %d\n",
1394 DPRINTF(
"diag_test dvrcmd.ack_p[0]:%x\n", cmdack.ack_status_ack);
1395 DPRINTF(
"diag_test dvrcmd.phase:%x\n", cmdack.phase);
1397 DPRINTF(
"dvrioctl2_diag_test -> Handshake error!\n");
1400 if (cmdack.ack_status_ack) {
1401 DPRINTF(
"dvrioctl2_diag_test -> Status error in ACK! param:%04x\n", cmdack.ack_status_ack);
1404 if (cmdack.comp_status) {
1405 DPRINTF(
"dvrioctl2_diag_test -> Status error in COMP! param:%04x\n", cmdack.comp_status);
1409 DPRINTF(
"---------------------------- return buffer\n");
1410 outbuf_tmp = (u16 *)&cmdack.return_result_word[0];
1413 DPRINTF(
" %4x", *outbuf_tmp);
1414 *(u16 *)buf = *outbuf_tmp;
1416 buf = (
char *)buf + 2;
1417 }
while (outbuf_cnt < 16);
1422 #ifdef DVRMISC_CFW_EXTENSIONS
1423 int dvrioctl2_cfw_ping(
1427 unsigned int arglen,
1429 unsigned int buflen)
1431 drvdrv_exec_cmd_ack cmdack;
1433 cmdack.command = 0x5130;
1434 cmdack.input_word_count = 0;
1435 if (DvrdrvExecCmdAck(&cmdack)) {
1436 DPRINTF(
"dvrioctl2_cfw_ping -> Handshake error!\n");
1439 if (cmdack.ack_status_ack) {
1440 DPRINTF(
"dvrioctl2_cfw_ping -> Status error!\n");
1441 return (
int)(s16)cmdack.ack_status_ack;
1447 int dvrioctl2_cfw_get_max_lba48(
1451 unsigned int arglen,
1453 unsigned int buflen)
1455 drvdrv_exec_cmd_ack cmdack;
1457 if ((arglen < 2) || (buflen < 10)) {
1458 DPRINTF(
"dvrioctl2_cfw_get_max_lba48 -> invalid buffer length!\n");
1462 cmdack.command = 0x5131;
1463 cmdack.input_word[0] = *(u16 *)arg;
1464 cmdack.input_word_count = 1;
1465 if (DvrdrvExecCmdAck(&cmdack)) {
1466 DPRINTF(
"dvrioctl2_cfw_get_max_lba48 -> Handshake error!\n");
1468 }
else if (cmdack.ack_status_ack) {
1469 return (
int)(s16)cmdack.ack_status_ack;
1471 *(u16 *)buf = cmdack.output_word[0];
1472 *((u16 *)buf + 1) = cmdack.output_word[1];
1473 *((u16 *)buf + 2) = cmdack.output_word[2];
1474 *((u16 *)buf + 3) = cmdack.output_word[3];
1479 int dvrioctl2_cfw_mem_peek_poke(
1483 unsigned int arglen,
1485 unsigned int buflen)
1487 drvdrv_exec_cmd_ack cmdack;
1489 if ((arglen < 14) || (buflen < 10)) {
1490 DPRINTF(
"dvrioctl2_cfw_mem_peek_poke -> invalid buffer length!\n");
1494 cmdack.command = 0x5132;
1495 cmdack.input_word[0] = *(u16 *)arg;
1496 cmdack.input_word[1] = *((u16 *)arg + 1);
1497 cmdack.input_word[2] = *((u16 *)arg + 2);
1498 cmdack.input_word[3] = *((u16 *)arg + 3);
1499 cmdack.input_word[4] = *((u16 *)arg + 4);
1500 cmdack.input_word[5] = *((u16 *)arg + 5);
1501 cmdack.input_word[6] = *((u16 *)arg + 6);
1502 cmdack.input_word_count = 7;
1503 if (DvrdrvExecCmdAck(&cmdack)) {
1504 DPRINTF(
"dvrioctl2_cfw_mem_peek_poke -> Handshake error!\n");
1506 }
else if (cmdack.ack_status_ack) {
1507 DPRINTF(
"dvrioctl2_cfw_mem_peek_poke -> Status error!\n");
1508 return (
int)(s16)cmdack.ack_status_ack;
1510 *(u16 *)buf = cmdack.output_word[0];
1511 *((u16 *)buf + 1) = cmdack.output_word[1];
1512 *((u16 *)buf + 2) = cmdack.output_word[2];
1513 *((u16 *)buf + 3) = cmdack.output_word[3];