📄 drv_jvc.c
字号:
status = set_subcode((u_char *)&sc, sizeof(sc)); if (status < 0) return (status);} return (status);}LOCAL char sector[3000];LOCAL intclose_track_teac(track, trackp) int track; track_t *trackp;{ int ret = 0; if (!last_done) { printf("WARNING: adding dummy block to close track.\n"); /* * need read sector size * XXX do we really need this ? * XXX if we need this can we set blocks to 0 ? */ ret = write_teac_xg1(sector, lba_addr, 2352, 1, FALSE); lba_addr++; } if (!is_audio(trackp)) lba_addr += 2; teac_wr_pma(); return (ret);}static const char *sd_teac50_error_str[] = { "\100\200diagnostic failure on component parts", /* 40 80 */ "\100\201diagnostic failure on memories", /* 40 81 */ "\100\202diagnostic failure on cd-rom ecc circuit", /* 40 82 */ "\100\203diagnostic failure on gate array", /* 40 83 */ "\100\204diagnostic failure on internal SCSI controller", /* 40 84 */ "\100\205diagnostic failure on servo processor", /* 40 85 */ "\100\206diagnostic failure on program rom", /* 40 86 */ "\100\220thermal sensor failure", /* 40 90 */ "\200\000controller prom error", /* 80 00 */ /* JVC */ "\201\000no disk present - couldn't get focus", /* 81 00 */ /* JVC */ "\202\000no cartridge present", /* 82 00 */ /* JVC */ "\203\000unable to spin up", /* 83 00 */ /* JVC */ "\204\000addr exceeded the last valid block addr", /* 84 00 */ /* JVC */ "\205\000sync error", /* 85 00 */ /* JVC */ "\206\000address can't find or not data track", /* 86 00 */ /* JVC */ "\207\000missing track", /* 87 00 */ /* JVC */ "\213\000cartridge could not be ejected", /* 8B 00 */ /* JVC */ "\215\000audio not playing", /* 8D 00 */ /* JVC */ "\216\000read toc error", /* 8E 00 */ /* JVC */ "\217\000a blank disk is detected by read toc", /* 8F 00 */ "\220\000pma less disk - not a recordable disk", /* 90 00 */ "\223\000mount error", /* 93 00 */ /* JVC */ "\224\000toc less disk", /* 94 00 */ "\225\000disc information less disk", /* 95 00 */ /* JVC */ "\226\000disc information read error", /* 96 00 */ /* JVC */ "\227\000linear velocity measurement error", /* 97 00 */ /* JVC */ "\230\000drive sequence stop", /* 98 00 */ /* JVC */ "\231\000actuator velocity control error", /* 99 00 */ /* JVC */ "\232\000slider velocity control error", /* 9A 00 */ /* JVC */ "\233\000opc initialize error", /* 9B 00 */ "\233\001power calibration not executed", /* 9B 01 */ "\234\000opc execution eror", /* 9C 00 */ "\234\001alpc error - opc execution", /* 9C 01 */ "\234\002opc execution timeout", /* 9C 02 */ "\245\000disk application code does not match host application code", /* A5 00 */ "\255\000completed preview write", /* AD 00 */ "\256\000invalid B0 value", /* AE 00 */ /* JVC */ "\257\000pca area full", /* AF 00 */ "\260\000efm isn't detected", /* B0 00 */ /* JVC */ "\263\000no logical sector", /* B3 00 */ /* JVC */ "\264\000full pma area", /* B4 00 */ "\265\000read address is atip area - blank", /* B5 00 */ "\266\000write address is efm area - aleady written", /* B6 00 */ "\271\000abnormal spinning - servo irq", /* B9 00 */ /* JVC */ "\272\000no write data - buffer empty", /* BA 00 */ "\273\000write emergency occurred", /* BB 00 */ "\274\000read timeout", /* BC 00 */ /* JVC */ "\277\000abnormal spin - nmi", /* BF 00 */ /* JVC */ "\301\0004th run-in block detected", /* C1 00 */ "\302\0003rd run-in block detected", /* C2 00 */ "\303\0002nd run-in block detected", /* C3 00 */ "\304\0001st run-in block detected", /* C4 00 */ "\305\000link block detected", /* C5 00 */ "\306\0001st run-out block detected", /* C6 00 */ "\307\0002nd run-out block detected", /* C7 00 */ "\314\000write request means mixed data mode", /* CC 00 */ "\315\000unable to ensure reliable writing with the inserted disk - unsupported disk", /* CD 00 */ "\316\000unable to ensure reliable writing as the inserted disk does not support speed",/* CE 00 */ "\317\000unable to ensure reliable writing as the inserted disk has no char id code", /* CF 00 */ NULL};LOCAL intteac_attach(dp) cdr_t *dp;{ scsi_setnonstderrs(sd_teac50_error_str); return (0);}LOCAL intteac_fixation(onp, dummy, toctype, tracks, trackp) int onp; int dummy; int toctype; int tracks; track_t *trackp;{ long lba; int status; u_char *sp; int i;extern char *buf; if (tracks < 1) { /* * We come here if cdrecord isonly called with the -fix option. * As long as we cannot read and interpret the PMA, we must * abort here. */ teac_rd_pma();/* errmsgno(EX_BAD, "Cannot fixate zero track disk.\n");;*/ errmsgno(EX_BAD, "Cannot fixate without track list (not yet implemented).\n");; return (-1); } sp = (u_char *)buf; sleep(1); status = clear_subcode(); sleep(1); if (status < 0) return (status); sp[0] = 0; /* reserved */ sp[1] = 0; /* reserved */ sp[2] = 0; /* Q TNO */ sp = &sp[3]; /* point past header */ /* * Set up TOC entries for all tracks */ for(i=1; i <= tracks; i++) { lba = trackp[i].trackstart+150; /* MSF=00:02:00 is LBA=0 */ sp = set_toc_subcode(sp, /* ctrl/adr for this track */ st2mode[trackp[i].sectype&ST_MASK], ADR_POS, trackp[i].trackno, lba); } /* * Set first track on disk * * XXX We set the track type for the lead-in to the track type * XXX of the first track. The TEAC manual states that we should use * XXX audio if the disk contains both, audio and data tracks. */ sp = set_lin_subcode(sp, /* ctrl/adr for first track */ st2mode[trackp[1].sectype&ST_MASK], ADR_POS, 0xA0, /* Point A0 */ trackp[1].trackno, /* first track # */ toc2sess[toctype & TOC_MASK], /* disk type */ 0); /* reserved */ /* * Set last track on disk */ sp = set_lin_subcode(sp, /* ctrl/adr for first track */ st2mode[trackp[1].sectype&ST_MASK], ADR_POS, 0xA1, /* Point A1 */ MSF_CONV(trackp[tracks].trackno),/* last track # */ 0, /* reserved */ 0); /* reserved */ /* * Set start of lead out area in MSF * MSF=00:02:00 is LBA=0 */ lba = lba_addr + 150; if (lverbose > 1) printf("lba: %ld lba_addr: %ld\n", lba, lba_addr); if (lverbose > 1) printf("Lead out start: (%02d:%02d/%02d)\n", minutes(lba*2352), seconds(lba*2352), frames(lba*2352)); sp = set_lin_subcode(sp, /* ctrl/adr for first track */ st2mode[trackp[1].sectype&ST_MASK], ADR_POS, 0xA2, /* Point A2 */ MSF_CONV(LBA_MIN(lba)), MSF_CONV(LBA_SEC(lba)), MSF_CONV(LBA_FRM(lba))); status = sp - ((u_char *)buf); if (lverbose > 1) { printf("Subcode len: %d\n", status); scsiprbytes("Subcode:", (u_char *)buf, status); } status = set_subcode((u_char *)buf, status); sleep(1); if (status < 0) return (status); /* * now write the toc */ status = teac_freeze(!onp); return (status);}LOCAL intteac_open_session(tracks, trackp, toctype, multi) int tracks; track_t *trackp; int toctype; int multi;{ int i; for (i = 1; i <= tracks; i++) { if (trackp[i].tracksize < 0) { /* * XXX How about setting the subcode range to infinity. * XXX and correct it in clode track before writing * XXX the PMA? */ errmsgno(EX_BAD, "Track %d has unknown length.\n", i); return (-1); } } return (teac_calibrate(toctype, multi));}LOCAL intteac_calibrate(toctype, multi) int toctype; int multi;{ int status; silent++; if (read_B0(TRUE, &lba_addr, NULL) < 0) lba_addr = -150; silent--; status = clear_subcode(); if (status < 0) return (status); if (lverbose) { fprintf(stdout, "Judging disk..."); flush(); } status = opt_power_judge(1); if (status < 0) { printf("\n"); return (status); } if (lverbose) { fprintf(stdout, "done.\nCalibrating laser..."); flush(); } status = opt_power_judge(0); if (lverbose) { fprintf(stdout, "done.\n"); } silent++; if (next_wr_addr_teac(-1, -1) < 0) { if (verbose == 0 && scsi_sense_key() != SC_ILLEGAL_REQUEST) scsiprinterr("next writable address"); } silent--; return (status);}/*--------------------------------------------------------------------------*/#define SC_SET_LIMITS 0xb3 /* teac 12 byte command */#define SC_SET_SUBCODE 0xc2 /* teac 10 byte command */#define SC_READ_PMA 0xc4 /* teac 10 byte command */#define SC_READ_DISK_INFO 0xc7 /* teac 10 byte command */#define SC_WRITE_PMA 0xe1 /* teac 12 byte command */#define SC_FREEZE 0xe3 /* teac 12 byte command */#define SC_OPC_EXECUTE 0xec /* teac 12 byte command */#define SC_CLEAR_SUBCODE 0xe4 /* teac 12 byte command */#define SC_NEXT_WR_ADDRESS 0xe6 /* teac 12 byte command *//* ----------------------------------------------------------------- * Optimum power calibration for Teac Drives.----------------------------------------------------------------- */LOCAL intopt_power_judge(judge) int judge;{ fillbytes((caddr_t)&scmd, sizeof(scmd), '\0'); scmd.addr = (caddr_t)0; scmd.size = 0; scmd.flags = SCG_RECV_DATA|SCG_DISRE_ENA; scmd.cdb_len = SC_G5_CDBLEN; scmd.sense_len = CCS_SENSE_LEN; scmd.target = target; scmd.timeout = 60; scmd.cdb.g5_cdb.cmd = SC_OPC_EXECUTE; scmd.cdb.g5_cdb.lun = lun; scmd.cdb.g5_cdb.reladr = judge; /* Judge the Disc */ return (scsicmd("opt_power_judge"));}/* ----------------------------------------------------------------- * Clear subcodes for Teac Drives.----------------------------------------------------------------- */LOCAL intclear_subcode(){ fillbytes((caddr_t)&scmd, sizeof(scmd), '\0'); scmd.addr = (caddr_t)0; scmd.size = 0; scmd.flags = SCG_DISRE_ENA; scmd.cdb_len = SC_G5_CDBLEN; scmd.sense_len = CCS_SENSE_LEN; scmd.target = target; scmd.cdb.g5_cdb.cmd = SC_CLEAR_SUBCODE; scmd.cdb.g5_cdb.lun = lun; scmd.cdb.g5_cdb.addr[3] = 0x80; return (scsicmd("clear subcode"));}/* ----------------------------------------------------------------- * Set limits for command linking for Teac Drives.----------------------------------------------------------------- */LOCAL intset_limits(lba, length) long lba; long length;{ fillbytes((caddr_t)&scmd, sizeof(scmd), '\0'); scmd.addr = (caddr_t)0; scmd.size = 0; scmd.flags = SCG_DISRE_ENA; scmd.cdb_len = SC_G5_CDBLEN; scmd.sense_len = CCS_SENSE_LEN; scmd.target = target; scmd.cdb.g5_cdb.cmd = SC_SET_LIMITS; scmd.cdb.g5_cdb.lun = lun; i_to_long(&scmd.cdb.g5_cdb.addr[0], lba); i_to_long(&scmd.cdb.g5_cdb.count[0], length); return (scsicmd("set limits"));}/* ----------------------------------------------------------------- * Set subcode for Teac Drives.----------------------------------------------------------------- */LOCAL intset_subcode(subcode_data, length) u_char *subcode_data; int length;{ fillbytes((caddr_t)&scmd, sizeof(scmd), '\0'); scmd.addr = (caddr_t)subcode_data; scmd.size = length; scmd.flags = SCG_DISRE_ENA; scmd.cdb_len = SC_G1_CDBLEN; scmd.sense_len = CCS_SENSE_LEN; scmd.target = target; scmd.cdb.g1_cdb.cmd = SC_SET_SUBCODE; scmd.cdb.g1_cdb.lun = lun; g1_cdblen(&scmd.cdb.g1_cdb, length); return (scsicmd("set subcode"));}LOCAL intread_disk_info_teac(data, length, type) u_char *data; int length; int type;{ fillbytes((caddr_t)&scmd, sizeof(scmd), '\0'); scmd.addr = (caddr_t)data; scmd.size = length; scmd.flags = SCG_RECV_DATA |SCG_DISRE_ENA; scmd.cdb_len = SC_G1_CDBLEN; scmd.sense_len = CCS_SENSE_LEN; scmd.target = target; scmd.cdb.g1_cdb.cmd = SC_READ_DISK_INFO; scmd.cdb.g1_cdb.lun = lun; return (scsicmd("read disk info teac"));}/* ----------------------------------------------------------------- * Perform the freeze command for Teac Drives.----------------------------------------------------------------- */LOCAL intteac_freeze(bp_flag) int bp_flag;{ fillbytes((caddr_t)&scmd, sizeof(scmd), '\0'); scmd.addr = (caddr_t)0; scmd.size = 0; scmd.flags = SCG_DISRE_ENA; scmd.cdb_len = SC_G5_CDBLEN; scmd.sense_len = CCS_SENSE_LEN; scmd.target = target; scmd.timeout = 8 * 60; /* Needs up to 4 minutes */ scmd.cdb.g5_cdb.cmd = SC_FREEZE; scmd.cdb.g5_cdb.lun = lun; scmd.cdb.g5_cdb.addr[3] = bp_flag ? 0x80 : 0; return (scsicmd("teac_freeze"));}LOCAL intteac_wr_pma(){ fillbytes((caddr_t)&scmd, sizeof(scmd), '\0'); scmd.addr = (caddr_t)0; scmd.size = 0; scmd.flags = SCG_DISRE_ENA; scmd.cdb_len = SC_G5_CDBLEN; scmd.sense_len = CCS_SENSE_LEN; scmd.target = target; scmd.cdb.g5_cdb.cmd = SC_WRITE_PMA; scmd.cdb.g5_cdb.lun = lun; return (scsicmd("teac_write_pma"));}/* ----------------------------------------------------------------- * Read PMA for Teac Drives.----------------------------------------------------------------- */LOCAL intteac_rd_pma(){ unsigned char xx[256]; fillbytes((caddr_t)xx, sizeof(xx), '\0'); fillbytes((caddr_t)&scmd, sizeof(scmd), '\0'); scmd.addr = (caddr_t)xx; scmd.size = sizeof(xx); scmd.flags = SCG_RECV_DATA |SCG_DISRE_ENA; scmd.cdb_len = SC_G1_CDBLEN; scmd.sense_len = CCS_SENSE_LEN; scmd.target = target; scmd.cdb.g1_cdb.cmd = SC_READ_PMA; scmd.cdb.g1_cdb.lun = lun; g1_cdblen(&scmd.cdb.g1_cdb, sizeof(xx));/* return (scsicmd("teac_read_pma"));*/ if (scsicmd("teac_read_pma") < 0) return (-1); if (verbose) { scsiprbytes("PMA Data", xx, sizeof(xx) - scsigetresid()); } if (lverbose) { int i; Uchar *p; scsiprbytes("PMA Header: ", xx, 4); i = xx[2]; p = &xx[4]; for (; i <= xx[3]; i++) { scsiprbytes("PMA: ", p, 10); p += 10; } } return (0);}/* ----------------------------------------------------------------- * Next writable address for Teac Drives.----------------------------------------------------------------- */LOCAL intnext_wr_addr_teac(start_lba, last_lba) long start_lba; long last_lba;{ unsigned char xx[256]; fillbytes((caddr_t)xx, sizeof(xx), '\0'); fillbytes((caddr_t)&scmd, sizeof(scmd), '\0'); scmd.addr = (caddr_t)xx; scmd.size = sizeof(xx); scmd.flags = SCG_RECV_DATA |SCG_DISRE_ENA; scmd.cdb_len = SC_G5_CDBLEN; scmd.sense_len = CCS_SENSE_LEN; scmd.target = target; scmd.cdb.g5_cdb.cmd = SC_NEXT_WR_ADDRESS; scmd.cdb.g5_cdb.lun = lun; i_to_long(&scmd.cdb.g5_cdb.addr[0], start_lba); i_to_long(&scmd.cdb.g5_cdb.count[0], last_lba); if (verbose) printf("start lba: %ld last lba: %ld\n", start_lba, last_lba);/* return (scsicmd("next writable address"));*/ if (scsicmd("next writable address") < 0) return (-1); if (verbose) { scsiprbytes("WRa Data", xx, sizeof(xx) - scsigetresid()); printf("NWA: %ld\n", a_to_u_long(xx)); } return (0);}LOCAL intblank_jvc(addr, blanktype) long addr; int blanktype;{ extern char *blank_types[]; if (lverbose) printf("Blanking %s\n", blank_types[blanktype & 0x07]); return (scsi_blank(addr, blanktype));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -