Date: Mon, 21 Feb 2005 11:50:57 -0300 From: Ivo Roumenov Tonev <ivo@tonev.pro.br> To: marius@FreeBSD.org Cc: ports@FreeBSD.org Subject: cdrtools-2.01 Message-ID: <20050221115057.43c7iqxq8w8g8gkg@mail.ebfoto.com.br>
next in thread | raw e-mail | index | archive | help
This message is in MIME format. --=_5wlk2xwi3j0g Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 7bit Patch for DVD writing can include it in the port? patch -p1 < cdrtools-2.01a32-dvd-2.patch patch -p0 < cdrtools-2.01a27-dvd-fix.patch -- Ivo Roumenov Tonev ICQ: 14854601 +55 61 8409-2642 "One OS to rule them all, One OS to find them, One OS to bring them all and in the darkness bind them In the Land of Redmond, where the Shadows lie." -- adapted from J.R.R. Tolkien --=_5wlk2xwi3j0g Content-Type: text/x-patch; charset=ISO-8859-1; name="cdrtools-2.01a27-dvd-fix.patch" Content-Disposition: attachment; filename="cdrtools-2.01a27-dvd-fix.patch" Content-Transfer-Encoding: 7bit --- cdrecord/cdrecord.c +++ cdrecord/cdrecord.c @@ -359,7 +359,7 @@ HOST_CPU, HOST_VENDOR, HOST_OS); printf("Note: This version is an unofficial (modified) version with DVD support\n"); printf("Note: and therefore may have bugs that are not present in the original.\n"); - printf("Note: Please send bug reports or support requests to <warly@mandrakesoft.com>.\n"); + printf("Note: Please send bug reports or support requests to http://bugzilla.redhat.com/bugzilla\n"); printf("Note: The author of cdrecord should not be bothered with problems in this version.\n"); #if defined(SOURCE_MODIFIED) || !defined(IS_SCHILY_XCONFIG) --- cdrecord/drv_mmc.c +++ cdrecord/drv_mmc.c @@ -1491,7 +1491,7 @@ dsp->ds_disktype&= ~DT_CD; dsp->ds_disktype|= DT_DVD; - return (ret); + return (0); } @@ -2663,13 +2663,14 @@ The BIG timeout is needed in case there was a very short rzone to write at the beginning of the disk, because lead-out needs to be at some distance. */ + int ret; scg_settimeout(scgp, 1000); if(is_packet(trackp)){ scsi_close_tr_session(scgp, 2, 0, FALSE); } - fixate_mmc(scgp, dp, trackp); + ret = fixate_mmc(scgp, dp, trackp); scg_settimeout(scgp, 200); - + return ret; } char *blank_types[] = { --=_5wlk2xwi3j0g Content-Type: text/x-patch; charset=ISO-8859-1; name="cdrtools-2.01a32-dvd-2.patch" Content-Disposition: attachment; filename="cdrtools-2.01a32-dvd-2.patch" Content-Transfer-Encoding: quoted-printable --- cdrtools-2.01/cdrecord/drv_mmc.c.dvd=092004-05-25 00:36:01.000000000 +0= 200 +++ cdrtools-2.01/cdrecord/drv_mmc.c=092004-10-18 14:40:10.329455353 +0200 @@ -84,8 +84,11 @@ EXPORT=09char=09*hasdrvopt=09=09__PR((char *optstr, char *optname)); LOCAL=09cdr_t=09*identify_mmc=09=09__PR((SCSI *scgp, cdr_t *, struct scsi_= inquiry *)); LOCAL=09int=09attach_mmc=09=09__PR((SCSI *scgp, cdr_t *)); +LOCAL int attach_mdvd __PR((SCSI *scgp, cdr_t *)); EXPORT=09int=09check_writemodes_mmc=09__PR((SCSI *scgp, cdr_t *dp)); +EXPORT int check_writemodes_mdvd __PR((SCSI *scgp, cdr_t *dp)); LOCAL=09int=09deflt_writemodes_mmc=09__PR((SCSI *scgp, BOOL reset_dummy)); +LOCAL int deflt_writemodes_mdvd __PR((SCSI *scgp, BOOL reset_dummy= )); LOCAL=09int=09get_diskinfo=09=09__PR((SCSI *scgp, struct disk_info *dip)); LOCAL=09void=09di_to_dstat=09=09__PR((struct disk_info *dip, dstat_t *dsp)= ); LOCAL=09int=09get_atip=09=09__PR((SCSI *scgp, struct atipinfo *atp)); @@ -94,18 +97,27 @@ #endif LOCAL=09int=09init_mmc=09=09__PR((SCSI *scgp, cdr_t *dp)); LOCAL=09int=09getdisktype_mmc=09=09__PR((SCSI *scgp, cdr_t *dp)); +LOCAL int getdisktype_mdvd __PR((SCSI *scgp, cdr_t *dp)); LOCAL=09int=09speed_select_mmc=09__PR((SCSI *scgp, cdr_t *dp, int *speedp)= ); +LOCAL int speed_select_mdvd __PR((SCSI *scgp, cdr_t *dp, int *= speedp)); LOCAL=09int=09mmc_set_speed=09=09__PR((SCSI *scgp, int readspeed, int writ= espeed, int rotctl)); LOCAL=09int=09next_wr_addr_mmc=09__PR((SCSI *scgp, track_t *trackp, long *= ap)); +LOCAL int next_wr_addr_mdvd __PR((SCSI *scgp, track_t *trackp,= long *ap)); LOCAL=09int=09write_leadin_mmc=09__PR((SCSI *scgp, cdr_t *dp, track_t *tra= ckp)); LOCAL=09int=09open_track_mmc=09=09__PR((SCSI *scgp, cdr_t *dp, track_t *tr= ackp)); +LOCAL int open_track_mdvd __PR((SCSI *scgp, cdr_t *dp, track= _t *trackp)); LOCAL=09int=09close_track_mmc=09=09__PR((SCSI *scgp, cdr_t *dp, track_t *t= rackp)); +LOCAL int close_track_mdvd __PR((SCSI *scgp, cdr_t *dp, track= _t *trackp)); LOCAL=09int=09open_session_mmc=09__PR((SCSI *scgp, cdr_t *dp, track_t *tra= ckp)); +LOCAL int open_session_mdvd __PR((SCSI *scgp, cdr_t *dp, track= _t *trackp)); LOCAL=09int=09waitfix_mmc=09=09__PR((SCSI *scgp, int secs)); LOCAL=09int=09fixate_mmc=09=09__PR((SCSI *scgp, cdr_t *dp, track_t *trackp= )); +LOCAL int fixate_mdvd __PR((SCSI *scgp, cdr_t *dp, track= _t *trackp)); LOCAL=09int=09blank_mmc=09=09__PR((SCSI *scgp, cdr_t *dp, long addr, int b= lanktype)); +LOCAL=09int=09format_mdvd=09=09__PR((SCSI *scgp, cdr_t *dp, int formattype= )); LOCAL=09int=09send_opc_mmc=09=09__PR((SCSI *scgp, caddr_t, int cnt, int do= opc)); LOCAL=09int=09opt1_mmc=09=09__PR((SCSI *scgp, cdr_t *dp)); +LOCAL=09int=09opt1_mdvd=09=09__PR((SCSI *scgp, cdr_t *dp)); LOCAL=09int=09opt2_mmc=09=09__PR((SCSI *scgp, cdr_t *dp)); LOCAL=09int=09scsi_sony_write=09=09__PR((SCSI *scgp, caddr_t bp, long sect= addr, long size, int blocks, BOOL islast)); LOCAL=09int=09gen_cue_mmc=09=09__PR((track_t *trackp, void *vcuep, BOOL ne= edgap)); @@ -197,6 +209,46 @@ =09opt2_mmc, }; +cdr_t cdr_mdvd =3D { + 0, 0, + CDR_SWABAUDIO, + =09 370,370, + "mmc_mdvd", + "generic SCSI-3/mmc DVD-R(W) driver", + 0, + =09 (dstat_t *)0, + identify_mmc, + attach_mdvd, +=09 init_mmc, + getdisktype_mdvd, + scsi_load, + scsi_unload, + read_buff_cap, + cmd_dummy, /* recovery_needed *= / + (int(*)__PR((SCSI *, int)))cmd_dummy, /* recover *= / + speed_select_mdvd, + select_secsize, + next_wr_addr_mdvd, + (int(*)__PR((SCSI *, Ulong)))cmd_ill, /* reserve_track *= / + scsi_cdr_write, + (int(*)__PR((SCSI *scgp, int, track_t *)))cmd_dummy, /* gen_cue *= / +=09 (int(*)__PR((SCSI *scgp, cdr_t *, track_t *)))cmd_dummy, /* send_cue *= / + =09 write_leadin_mmc, + open_track_mdvd, + close_track_mdvd, + open_session_mdvd, + cmd_dummy, +=09 cmd_dummy,=09=09=09=09=09/* abort=09*/ + read_session_offset, + fixate_mdvd, + =09 stats_mmc, + blank_mmc, +=09 format_mdvd, + send_opc_mmc, + =09 opt1_mdvd, + =09 opt2_mmc, +}; + /* * Sony MMC CD-writer */ @@ -556,7 +608,21 @@ =09if (profile >=3D 0) { =09=09if (lverbose) =09=09=09print_profiles(scgp); -=09=09if (profile =3D=3D 0 || profile =3D=3D 0x12 || profile > 0x19) { +=09=09if (profile =3D=3D 0 || profile >=3D 0x10 && profile <=3D 0x15 || pr= ofile > 0x19) { +=09=09 /* +=09=09 * 10h DVD-ROM +=09=09 * 11h DVD-R +=09=09 * 12h DVD-RAM +=09=09 * 13h DVD-RW (Restricted overwrite) +=09=09 * 14h DVD-RW (Sequential recording) +=09=09 * 1Ah DVD+RW +=09=09 * 1Bh DVD+R +=09=09 * +=09=09 */ +=09=09 if (profile =3D=3D 0x11 || profile =3D=3D 0x13 || profile =3D=3D= 0x14 || profile =3D=3D 0x1A || profile =3D=3D 0x1B) { +=09=09=09is_dvd =3D TRUE; +=09=09=09dp =3D &cdr_mdvd; +=09=09 } else { =09=09=09is_dvd =3D FALSE; =09=09=09dp =3D &cdr_cd; @@ -578,23 +644,8 @@ =09=09=09=09errmsgno(EX_BAD, =09=09=09=09"Found unsupported DVD-RAM media.\n"); =09=09=09=09return (dp); -=09=09=09} else {=09=09=09/* DVD+RW DVD+R */ -=09=09=09=09errmsgno(EX_BAD, -=09=09=09=09"Found DVD+ media but DVD+R/DVD+RW support code is missing.\n"= ); -=09=09=09=09errmsgno(EX_BAD, -=09=09=09=09"If you need DVD+R/DVD+RW support, ask the Author for cdrecord= -ProDVD.\n"); -=09=09=09=09errmsgno(EX_BAD, -=09=09=09=09"Free test versions and free keys for personal use are at ftp:= //ftp.berlios.de/pub/cdrecord/ProDVD/\n"); -=09=09=09=09return (dp); =09=09=09} -=09=09} else if (profile >=3D 0x10 && profile < 0x18) { -=09=09=09errmsgno(EX_BAD, -=09=09=09"Found DVD media but DVD-R/DVD-RW support code is missing.\n"); -=09=09=09errmsgno(EX_BAD, -=09=09=09"If you need DVD-R/DVD-RW support, ask the Author for cdrecord-Pr= oDVD.\n"); -=09=09=09errmsgno(EX_BAD, -=09=09=09"Free test versions and free keys for personal use are at ftp://f= tp.berlios.de/pub/cdrecord/ProDVD/\n"); -=09=09=09return (dp); +=09=09 } =09=09} =09} else { =09=09if (xdebug) @@ -661,13 +712,12 @@ #endif =09} =09if (is_dvd) { -=09=09errmsgno(EX_BAD, -=09=09"Found DVD media but DVD-R/DVD-RW support code is missing.\n"); -=09=09errmsgno(EX_BAD, -=09=09"If you need DVD-R/DVD-RW support, ask the Author for cdrecord-ProDV= D.\n"); -=09=09errmsgno(EX_BAD, -=09=09"Free test versions and free keys for personal use are at ftp://ftp.= berlios.de/pub/cdrecord/ProDVD/\n"); + =09 errmsgno(EX_BAD, + "Found DVD media: using cdr_mdvd.\n"); + dp =3D &cdr_mdvd; =09} +=09dp->profile =3D profile; +=09dp->is_dvd =3D is_dvd; =09return (dp); } @@ -856,6 +906,42 @@ =09return (0); } +LOCAL int +attach_mdvd(scgp, dp) + SCSI *scgp; + cdr_t *dp; +{ + struct cd_mode_page_2A *mp; +=09 + + allow_atapi(scgp, TRUE);/* Try to switch to 10 byte mode cmds */ + + scgp->silent++; + mp =3D mmc_cap(scgp, NULL);/* Get MMC capabilities in allocated mp= */ + scgp->silent--; + if (mp =3D=3D NULL) + return (-1); /* Pre SCSI-3/mmc drive */ + + dp->cdr_cdcap =3D mp; /* Store MMC cap pointer */ + + if (mp->loading_type =3D=3D LT_TRAY) + dp->cdr_flags |=3D CDR_TRAYLOAD; + else if (mp->loading_type =3D=3D LT_CADDY) + dp->cdr_flags |=3D CDR_CADDYLOAD; + + if (mp->BUF !=3D 0) + dp->cdr_flags |=3D CDR_BURNFREE; + + check_writemodes_mdvd(scgp, dp); + + if (driveropts !=3D NULL) { + if (strcmp(driveropts, "help") =3D=3D 0) { + mmc_opthelp(dp, 0); + } + } + + return (0); +} EXPORT int check_writemodes_mmc(scgp, dp) @@ -1007,6 +1093,77 @@ } LOCAL int +check_writemodes_mdvd(scgp, dp) +=09SCSI=09*scgp; +=09cdr_t=09*dp; +{ +=09Uchar=09mode[0x100]; +=09int=09len; +=09struct=09cd_mode_page_05 *mp; + +=09if (xdebug) +=09=09printf("Checking possible write modes: "); + +=09deflt_writemodes_mdvd(scgp, FALSE); + +=09fillbytes((caddr_t)mode, sizeof(mode), '\0'); + +=09scgp->silent++; +=09if (!get_mode_params(scgp, 0x05, "CD write parameter", +=09=09=09mode, (Uchar *)0, (Uchar *)0, (Uchar *)0, &len)) { +=09=09scgp->silent--; +=09=09return (-1); +=09} +=09if (len =3D=3D 0) { +=09=09scgp->silent--; +=09=09return (-1); +=09} + +=09mp =3D (struct cd_mode_page_05 *) +=09=09(mode + sizeof(struct scsi_mode_header) + +=09=09((struct scsi_mode_header *)mode)->blockdesc_len); + +=09mp->test_write =3D 0; + +=09/*We only check for PACKET and SAO since these are the only supported m= odes for DVD */ +=09/*XXX these checks are irrelevant because they are not medium sensitive= . ie the device returns +=09 error only when it does not support a given mode for ALL mediums. It = should check using +=09 GET CONFIGURATION command.*/ + +=09mp->write_type =3D WT_PACKET; +=09mp->fp =3D 0; +=09i_to_4_byte(mp->packet_size, 0); + +=09if (set_mode_params(scgp, "CD write parameter", mode, len, 0, -1)) { +=09=09dp->cdr_flags |=3D CDR_PACKET; +=09=09if (xdebug) +=09=09 printf("PACKET "); +=09} else +=09 dp->cdr_flags &=3D ~CDR_PACKET; +=09mp->fp =3D 0; +=09i_to_4_byte(mp->packet_size, 0); +=09mp->track_mode =3D TM_DATA; + + +=09mp->write_type =3D WT_SAO; + +=09if (set_mode_params(scgp, "CD write parameter", mode, len, 0, -1)) { +=09=09dp->cdr_flags |=3D CDR_SAO; +=09=09if (xdebug) +=09=09=09printf("SAO "); +=09} else +=09=09dp->cdr_flags &=3D ~CDR_SAO; + + +=09if (xdebug) +=09=09printf("\n"); + +=09deflt_writemodes_mdvd(scgp, TRUE); +=09scgp->silent--; +=09return (0); +} + +LOCAL int deflt_writemodes_mmc(scgp, reset_dummy) =09SCSI=09*scgp; =09BOOL=09reset_dummy; @@ -1080,6 +1237,61 @@ =09return (0); } +LOCAL int +deflt_writemodes_mdvd(scgp, reset_dummy) +=09SCSI=09*scgp; +=09BOOL=09reset_dummy; +{ +=09Uchar=09mode[0x100]; +=09int=09len; +=09struct=09cd_mode_page_05 *mp; + +=09fillbytes((caddr_t)mode, sizeof(mode), '\0'); + +=09scgp->silent++; +=09if (!get_mode_params(scgp, 0x05, "DVD write parameter", +=09=09=09mode, (Uchar *)0, (Uchar *)0, (Uchar *)0, &len)) { +=09=09scgp->silent--; +=09=09return (-1); +=09} +=09if (len =3D=3D 0) { +=09=09scgp->silent--; +=09=09return (-1); +=09} + +=09mp =3D (struct cd_mode_page_05 *) +=09=09(mode + sizeof(struct scsi_mode_header) + +=09=09((struct scsi_mode_header *)mode)->blockdesc_len); + +=09mp->test_write =3D 0; +=09/* +=09 * This is the only place where we reset mp->test_write (-dummy) +=09 */ +=09if (reset_dummy) +=09=09mp->test_write =3D 0; + + +=09/* +=09 * Set default values: +=09 * Write type =3D 02 (session at once) +=09 * +=09 * XXX Note:=09the same code appears in check_writemodes_mmc() and +=09 * XXX=09=09in speed_select_mmc(). +=09 */ +=09mp->write_type =3D WT_SAO; +=09mp->track_mode =3D TM_DATA; +=09mp->dbtype =3D DB_ROM_MODE1; +=09mp->session_format =3D SES_DA_ROM; + + +=09if (set_mode_params(scgp, "DVD write parameter", mode, len, 0, -1) < 0)= { +=09=09scgp->silent--; +=09=09return (-1); +=09} +=09scgp->silent--; +=09return (0); +} + #ifdef=09PRINT_ATIP LOCAL=09void=09print_di=09=09__PR((struct disk_info *dip)); LOCAL=09void=09atip_printspeed=09=09__PR((char *fmt, int speedindex, char = speedtab[])); @@ -1149,6 +1361,9 @@ =09if (dsp->ds_last_leadout =3D=3D 0 && dsp->ds_maxblocks >=3D 0) =09=09dsp->ds_last_leadout =3D dsp->ds_maxblocks; +=09dsp->ds_trfirst=3Ddip->first_track; +=09dsp->ds_trlast=3Ddip->last_track_ls; +=09dsp->ds_trfirst_ls=3Ddip->first_track_ls; } LOCAL int @@ -1259,6 +1474,30 @@ } LOCAL int +getdisktype_mdvd(scgp, dp) +=09SCSI=09*scgp; +=09cdr_t=09*dp; +{ + int ret=3D0; + dstat_t=09*dsp =3D dp->cdr_dstat; + + struct track_info track_info; + if(getdisktype_mmc(scgp, dp)<0) +=09 return -1; + + /* read rzone info to get the space left on disk */ + /*ds_trlast is the last rzone on disk, can be invisible */ + if(read_rzone_info(scgp, (caddr_t)&track_info, sizeof(track_info))>= =3D0) +=09 dsp->ds_maxblocks=3Da_to_u_4_byte(track_info.free_blocks)+a_to_4_byte= (track_info.next_writable_addr); + + dsp->ds_disktype&=3D ~DT_CD; + dsp->ds_disktype|=3D DT_DVD; +=09 + return (ret); + +} + +LOCAL int getdisktype_mmc(scgp, dp) =09SCSI=09*scgp; =09cdr_t=09*dp; @@ -1688,6 +1927,7 @@ =09 * But the standard is rounding the wrong way. =09 * Furtunately rounding down is guaranteed. =09 */ +=09//val =3D curspeed*177; =09val =3D curspeed*177; =09if (val > 0xFFFF) =09=09val =3D 0xFFFF; @@ -1700,6 +1940,7 @@ =09if (scsi_get_speed(scgp, 0, &val) >=3D 0) { =09=09if (val > 0) { +=09=09 printf("Speed set to %d KB/s\n", val); =09=09=09curspeed =3D val / 176; =09=09=09*speedp =3D curspeed; =09=09} @@ -1762,6 +2003,68 @@ } LOCAL int +speed_select_mdvd(scgp, dp, speedp) +=09SCSI=09*scgp; +=09cdr_t *dp; +=09int=09*speedp; +{ + int retcode; + unsigned char perf_desc[28]; + int write_speed =3D *speedp * 1385; + int val =3D 0, val2 =3D 0; + int i; + + /* For the moment we just divide the CD speed by 7*/ + + if(speedp!=3DNULL) + (*speedp)=3D(*speedp)*8; + + memset(perf_desc, 0, sizeof(perf_desc)); + + /* Write Rotation Control =3D ROTCTL_CLV + * | Restore Logical Unit Defaults =3D 0 + * | Exact =3D 0 + * | Random Access =3D 0) + */ + perf_desc[0]=3D ROTCTL_CLV << 3 | 0 << 2 | 0 << 1 | 0; + /* Start LBA to 0 */ + perf_desc[4] =3D 0; + perf_desc[5] =3D 0; + perf_desc[6] =3D 0; + perf_desc[7] =3D 0; + /* End LBA set to 0 (setting to 0xffffffff failed on my LG burner + */ + perf_desc[8] =3D 0; + perf_desc[9] =3D 0; + perf_desc[10] =3D 0; + perf_desc[11] =3D 0; + /* Read Speed =3D 0xFFFF */ + perf_desc[12] =3D 0; + perf_desc[13] =3D 0; + perf_desc[14] =3D 0xFF; + perf_desc[15] =3D 0xFF; + /* Read Time =3D 1s */ + perf_desc[18] =3D 1000 >> 8; + perf_desc[19] =3D 1000 & 0xFF; + /* Write Speed */ + perf_desc[20] =3D write_speed >> 24; + perf_desc[21] =3D write_speed >> 16 & 0xFF; + perf_desc[22] =3D write_speed >> 8 & 0xFF; + perf_desc[23] =3D write_speed & 0xFF; + /* Write Time =3D 1s */ + perf_desc[26] =3D 1000 >> 8; + perf_desc[27] =3D 1000 & 0xFF; + + //retcode =3D scsi_set_streaming(scgp, NULL, 0); + retcode =3D scsi_set_streaming(scgp, &perf_desc, sizeof(perf_desc)); + if (retcode =3D=3D -1) return retcode; + retcode =3D speed_select_mmc(scgp, dp, speedp); + if(speedp!=3DNULL) + (*speedp)=3D(*speedp)/7; + return retcode; +} + +LOCAL int next_wr_addr_mmc(scgp, trackp, ap) =09SCSI=09*scgp; =09track_t=09*trackp; @@ -1898,6 +2201,48 @@ }; LOCAL int +next_wr_addr_mdvd(scgp, trackp, ap) +=09SCSI=09*scgp; +=09track_t=09*trackp; +=09long=09*ap; +{ +=09int track; +=09struct=09track_info=09track_info; +=09long=09next_addr; +=09int=09result =3D -1; +=09struct disk_info disk_info; +=09if (trackp){ +=09 track =3D trackp->trackno; +=09} + +=09if (trackp !=3D 0 && track > 0 && is_packet(trackp)) { +=09=09scgp->silent++; +=09=09result =3D read_rzone_info(scgp, (caddr_t)&track_info, sizeof(track_= info)); +=09=09scgp->silent--; +=09=09if (scsi_in_progress(scgp)){ +=09=09 return -1; +=09=09} +=09=09 +=09} + +=09if (result < 0) { +=09 /* Get the last rzone*/ +=09 if(read_disk_info(scgp,(caddr_t)&disk_info,8)<0) +=09=09 return (-1); +=09 +=09=09if (read_rzone_info(scgp, (caddr_t)&track_info, sizeof(track_info)) = < 0) +=09=09return (-1); +=09} +=09if (scgp->verbose) +=09=09scg_prbytes("track info:", (Uchar *)&track_info, +=09=09=09=09sizeof(track_info)-scg_getresid(scgp)); +=09next_addr =3D a_to_4_byte(track_info.next_writable_addr); +=09if (ap) +=09=09*ap =3D next_addr; +=09return (0); +} + +LOCAL int open_track_mmc(scgp, dp, trackp) =09SCSI=09*scgp; =09cdr_t=09*dp; @@ -1978,6 +2323,45 @@ } LOCAL int +open_track_mdvd(scgp, dp, trackp) +=09SCSI=09*scgp; +=09cdr_t=09*dp; +=09track_t *trackp; +{ +=09Uchar=09mode[0x100]; +=09int=09len; +=09struct=09cd_mode_page_05 *mp; + +=09if (is_packet(trackp)) { +=09 fillbytes((caddr_t)mode, sizeof(mode), '\0'); +=09 +=09 if (!get_mode_params(scgp, 0x05, "DVD write parameter", +=09=09=09mode, (Uchar *)0, (Uchar *)0, (Uchar *)0, &len)) +=09 return (-1); +=09 if (len =3D=3D 0) +=09=09 return (-1); + +=09 mp =3D (struct cd_mode_page_05 *) +=09 (mode + sizeof(struct scsi_mode_header) + +=09=09 ((struct scsi_mode_header *)mode)->blockdesc_len); + +=09=09mp->write_type =3D WT_PACKET; +=09=09mp->LS_V =3D 1; +=09=09/*For now we set the link size to 0x10(32k) because Pioneer-A03 only= support this */ +=09=09mp->link_size=3D0x10; +=09=09mp->fp =3D 1; +=09=09i_to_4_byte(mp->packet_size, trackp->pktsize); +=09} else { +=09 return 0; +=09} + +=09if (!set_mode_params(scgp, "CD write parameter", mode, len, 0, trackp->= secsize)) +=09=09return (-1); + +=09return (0); +} + +LOCAL int close_track_mmc(scgp, dp, trackp) =09SCSI=09*scgp; =09cdr_t=09*dp; @@ -2003,6 +2387,30 @@ =09return (0); } +LOCAL int +close_track_mdvd(scgp, dp, trackp) +=09SCSI=09*scgp; +=09cdr_t=09*dp; +=09track_t=09*trackp; +{ +=09int=09ret; +=09if (!is_packet(trackp)) +=09 return (0); + +=09if (scsi_flush_cache(scgp, (dp->cdr_cmdflags&F_IMMED) !=3D 0) < 0) { +=09=09printf("Trouble flushing the cache\n"); +=09=09return -1; +=09} +=09wait_unit_ready(scgp, 300);=09=09/* XXX Wait for ATAPI */ +=09if (is_packet(trackp) && !is_noclose(trackp)) { +=09=09=09/* close the incomplete track */ +=09=09ret =3D scsi_close_tr_session(scgp, 1, 0xFF, (dp->cdr_cmdflags&F_IMM= ED) !=3D 0); +=09=09wait_unit_ready(scgp, 300);=09/* XXX Wait for ATAPI */ +=09=09return (ret); +=09} +=09return (0); +} + int=09toc2sess[] =3D { =09SES_DA_ROM,=09/* CD-DA=09=09 */ =09SES_DA_ROM,=09/* CD-ROM=09=09 */ @@ -2086,6 +2494,82 @@ } LOCAL int +open_session_mdvd(scgp, dp, trackp) +=09SCSI=09*scgp; +=09cdr_t=09*dp; +=09track_t=09*trackp; +{ +=09Uchar=09mode[0x100]; +=09int=09tracks =3D trackp->tracks; + +=09int=09len; +=09struct=09cd_mode_page_05 *mp; +=09Ulong totalsize; +=09int i; +=09struct=09track_info=09track_info; +=09int profile; + +=09fillbytes((caddr_t)mode, sizeof(mode), '\0'); + +=09if (!get_mode_params(scgp, 0x05, "DVD write parameter", +=09=09=09mode, (Uchar *)0, (Uchar *)0, (Uchar *)0, &len)) +=09=09return (-1); +=09if (len =3D=3D 0) +=09=09return (-1); + +=09mp =3D (struct cd_mode_page_05 *) +=09=09(mode + sizeof(struct scsi_mode_header) + +=09=09((struct scsi_mode_header *)mode)->blockdesc_len); +=09if(is_packet(trackp)){ +=09 mp->write_type=3DWT_PACKET; +=09 mp->multi_session =3D (track_base(trackp)->tracktype & TOCF_MULTI) ? = MS_MULTI : MS_NONE; +=09 mp->fp=3D0; +=09 mp->BUFE=3D1; +=09 mp->track_mode=3D1; +=09}else{ +=09 mp->write_type =3D WT_SAO; +=09} + +=09 +=09if (lverbose && dp->cdr_cdcap->BUF !=3D 0) +=09=09printf("BURN-Free is %s.\n", mp->BUFE?"ON":"OFF"); +=09if (driveropts !=3D NULL) { +=09=09if ((strcmp(driveropts, "burnproof") =3D=3D 0 || +=09=09 strcmp(driveropts, "burnfree") =3D=3D 0) && dp->cdr_cdcap->BUF != =3D 0) { +=09=09=09errmsgno(EX_BAD, "Turning BURN-Free on\n"); +=09=09=09mp->BUFE =3D 1; +=09=09} else if ((strcmp(driveropts, "noburnproof") =3D=3D 0 || +=09=09=09 strcmp(driveropts, "noburnfree") =3D=3D 0)) { +=09=09=09errmsgno(EX_BAD, "Turning BURN-Free off\n"); +=09=09=09mp->BUFE =3D 0; +=09=09} else if (strcmp(driveropts, "help") =3D=3D 0) { +=09=09=09mmc_opthelp(dp, 0); +=09=09} else { +=09=09=09errmsgno(EX_BAD, "Bad driver opts '%s'.\n", driveropts); +=09=09=09mmc_opthelp(dp, EX_BAD); +=09=09} +=09} + + +=09if (!set_mode_params(scgp, "DVD write parameter", mode, len, 0, -1)) +=09=09return (-1); + +=09=09 +=09totalsize=3D0; +=09for(i=3D1;i<=3Dtracks;i++) { +=09 totalsize+=3Dtrackp[i].tracksecs; +=09} + +=09profile =3D get_curprofile(scgp); +=09if(!is_packet(trackp) && profile !=3D 0x1A){ +=09 /* in DAO mode we need to reserve space for the track*/ +=09 if(reserve_track(scgp, totalsize)<0) +=09 return (-1); +=09 } +=09return (0); +} + +LOCAL int waitfix_mmc(scgp, secs) =09SCSI=09*scgp; =09int=09secs; @@ -2215,6 +2699,25 @@ =09return (ret); } +LOCAL int +fixate_mdvd(scgp, dp, trackp) +=09SCSI=09*scgp; +=09cdr_t *dp; +=09track_t=09*trackp; +{ + /*set a really BIG timeout and call fixate_mmc +=09 The BIG timeout is needed in case there was a very short rzone to writ= e at the +=09 beginning of the disk, because lead-out needs to be at some distance. + */ + scg_settimeout(scgp, 1000); + if(is_packet(trackp)){ +=09 scsi_close_tr_session(scgp, 2, 0, FALSE); + } + fixate_mmc(scgp, dp, trackp); + scg_settimeout(scgp, 200); + +} + char=09*blank_types[] =3D { =09"entire disk", =09"PMA, TOC, pregap", @@ -2226,6 +2729,12 @@ =09"reserved blanking type", }; +char=09*format_types[] =3D { +=09"full format", +=09"background format", +=09"forced format", +}; + LOCAL int blank_mmc(scgp, dp, addr, blanktype) =09SCSI=09*scgp; @@ -2238,11 +2747,17 @@ =09BOOL=09cdrrw=09 =3D FALSE;=09/* Read CD-RW=09*/ =09BOOL=09cdwrw=09 =3D FALSE;=09/* Write CD-RW=09*/ =09int=09ret; +=09int =09profile; =09mmc_check(scgp, &cdrr, &cdwr, &cdrrw, &cdwrw, NULL, NULL); =09if (!cdwrw) =09=09return (blank_dummy(scgp, dp, addr, blanktype)); +=09profile =3D get_curprofile(scgp); +=09if (profile =3D=3D 0x1A) { +=09=09printf("Error: this media does not support blanking, ignoring.\n"); +=09=09return (blank_dummy(scgp, dp, addr, blanktype)); +=09} =09if (lverbose) { =09=09printf("Blanking %s\n", blank_types[blanktype & 0x07]); =09=09flush(); @@ -2258,6 +2773,80 @@ } LOCAL int +format_mdvd(scgp, dp, formattype) +=09SCSI=09*scgp; +=09cdr_t=09*dp; +=09int=09formattype; +{ +extern=09char=09*buf; +=09BOOL=09dvdwr=09 =3D FALSE;=09/* Write DVD=09*/ +=09int=09ret; +=09int =09profile; +=09char=09addr[12]; +=09struct disk_info *dip; + +=09printf("format_mdvd\n"); +=09mmc_check(scgp, NULL, NULL, NULL, NULL, NULL, &dvdwr); +=09if (!dvdwr) +=09=09return (format_dummy(scgp, dp, formattype)); + +=09printf("format_mdvd: drive is a dvd burner.\n"); +=09profile =3D get_curprofile(scgp); +=09if (profile !=3D 0x1A) { +=09=09printf("Error: only support DVD+RW formating, ignoring.\n"); +=09 return (format_dummy(scgp, dp, formattype)); +=09} +=09printf("format_mdvd: media is a DVD+RW.\n"); +=09dip =3D (struct disk_info *)buf; +=09if (get_diskinfo(scgp, dip) < 0) +=09=09return ret; +=09 +=09if (dip->disk_status & 3 && formattype !=3D FORCE_FORMAT) { +=09=09printf("Error: disk already formated, ignoring.\n"); +=09 return ret; + } +=09addr[0] =3D 0; // "Reserved" +=09addr[1] =3D 2; // "IMMED" flag +=09addr[2] =3D 0; // "Descriptor Length" (MSB) +=09addr[3] =3D 8; // "Descriptor Length" (LSB) +=09addr[4+0] =3D 0xff; +=09addr[4+1] =3D 0xff; +=09addr[4+2] =3D 0xff; +=09addr[4+3] =3D 0xff; +=09addr[4+4] =3D 0x26<<2; +=09addr[4+5] =3D 0; +=09addr[4+6] =3D 0; +=09addr[4+7] =3D 0; +=09if (formattype =3D=3D FORCE_FORMAT) { +=09 printf("format_mdvd: forcing reformat.\n"); +=09 formattype =3D FULL_FORMAT; +=09 addr[4+0] =3D 0; +=09 addr[4+1] =3D 0; +=09 addr[4+2] =3D 0; +=09 addr[4+3] =3D 0; +=09 addr[4+7] =3D 1; +=09} else { +=09 printf("format_mdvd: media is unformated.\n"); +=09} + +=09if (lverbose) { +=09=09printf("Formating %s\n", format_types[formattype & 0x07]); +=09=09flush(); +=09} +=09if (formattype =3D=3D FULL_FORMAT) { +=09 ret =3D scsi_format(scgp, &addr, sizeof(addr), FALSE); +=09} else { +=09 ret =3D scsi_format(scgp, &addr, sizeof(addr), TRUE); +=09} +=09if (ret < 0) +=09=09return (ret); + +=09wait_unit_ready(scgp, 90*60/curspeed);=09/* XXX Wait for ATAPI */ +=09waitfix_mmc(scgp, 90*60/curspeed);=09/* XXX Wait for ATAPI */ +=09return (ret); +} + +LOCAL int send_opc_mmc(scgp, bp, cnt, doopc) =09SCSI=09*scgp; =09caddr_t=09bp; @@ -2453,6 +3042,42 @@ } LOCAL int +opt1_mdvd(scgp, dp) +=09SCSI=09*scgp; +=09cdr_t=09*dp; +{ +=09int=09oflags =3D dp->cdr_dstat->ds_cdrflags; + +=09if ((dp->cdr_dstat->ds_cdrflags & RF_AUDIOMASTER) !=3D 0) { +=09=09printf("Turning Audio Master Q. R. on\n"); +=09=09if (set_audiomaster_yamaha(scgp, dp, TRUE) < 0) +=09=09=09return (-1); +=09=09if (!debug && lverbose <=3D 1) +=09=09=09dp->cdr_dstat->ds_cdrflags &=3D ~RF_PRATIP; +=09=09if (getdisktype_mdvd(scgp, dp) < 0) { +=09=09=09dp->cdr_dstat->ds_cdrflags =3D oflags; +=09=09=09return (-1); +=09=09} +=09=09dp->cdr_dstat->ds_cdrflags =3D oflags; +=09=09if (oflags & RF_PRATIP) { +=09=09=09msf_t msf; +=09=09=09lba_to_msf(dp->cdr_dstat->ds_first_leadin, &msf); +=09=09=09printf("New start of lead in: %ld (%02d:%02d/%02d)\n", +=09=09=09=09(long)dp->cdr_dstat->ds_first_leadin, +=09=09 msf.msf_min, + =09=09 msf.msf_sec, + =09=09msf.msf_frame); +=09=09=09lba_to_msf(dp->cdr_dstat->ds_maxblocks, &msf); +=09=09=09printf("New start of lead out: %ld (%02d:%02d/%02d)\n", +=09=09=09=09(long)dp->cdr_dstat->ds_maxblocks, +=09=09 msf.msf_min, + =09=09 msf.msf_sec, + =09=09msf.msf_frame); +=09=09} +=09} +=09return (0); +} +LOCAL int scsi_sony_write(scgp, bp, sectaddr, size, blocks, islast) =09SCSI=09*scgp; =09caddr_t=09bp;=09=09/* address of buffer */ --- cdrtools-2.01/cdrecord/cdr_drv.c.dvd=092004-03-02 02:06:26.000000000 +0= 100 +++ cdrtools-2.01/cdrecord/cdr_drv.c=092004-10-18 14:37:32.427251472 +0200 @@ -42,6 +42,7 @@ extern=09cdr_t=09cdr_oldcd; extern=09cdr_t=09cdr_cd; extern=09cdr_t=09cdr_mmc; +extern cdr_t cdr_mdvd; extern=09cdr_t=09cdr_mmc_sony; extern=09cdr_t=09cdr_cd_dvd; extern=09cdr_t=09cdr_philips_cdd521O; @@ -80,6 +81,7 @@ cdr_t=09*drivers[] =3D { =09&cdr_cd_dvd, =09&cdr_mmc, + &cdr_mdvd, =09&cdr_mmc_sony, =09&cdr_cd, =09&cdr_oldcd, --- cdrtools-2.01/cdrecord/cdrecord.h.dvd=092004-05-25 00:36:01.000000000 += 0200 +++ cdrtools-2.01/cdrecord/cdrecord.h=092004-10-18 14:37:32.428251328 +0200 @@ -96,7 +96,7 @@ #define=09CDR_MAX_BUF_SIZE=09(256*1024) #ifndef=09MIN_GRACE_TIME -#define=09MIN_GRACE_TIME=092=09=09/* 2 seconds */ +#define=09MIN_GRACE_TIME=090=09=09/* 2 seconds */ #endif #ifndef=09GRACE_TIME #define=09GRACE_TIME=099=09=09/* 9 seconds */ @@ -460,6 +460,13 @@ #define=09BLANK_SESSION=090x06=09/* Erase the last session=09=09 */ /* + * Defines for formating DVD (custom values) + */ +#define=09FULL_FORMAT 0x00 /* Interactive format */ +#define=09BACKGROUND_FORMAT 0x01 /* Background format */ +#define=09FORCE_FORMAT 0x02 /* Force reformat */ + +/* * Useful definitions for audio tracks */ #define=09msample=09=09(44100 * 2)=09=09/* one 16bit audio sample */ @@ -570,6 +577,12 @@ #define=09DSF_NEED_FORMAT=090x0800=09/* Disk needs to be formatted=09=09*/ /* + * Definitions for disktype flags + */ +#define DT_CD 0x001 /*is a CD */ +#define DT_DVD 0x002 /*is a DVD */ + +/* * Definitions for disk_status disk type * used in "ds_type". */ @@ -709,6 +722,8 @@ =09int=09(*cdr_opc)=09=09__PR((SCSI *scgp, caddr_t bp, int cnt, int doopc)= );=09/* Do OPC */ =09int=09(*cdr_opt1)=09=09__PR((SCSI *scgp, cdr_t *));=09=09=09/* do early= option processing*/ =09int=09(*cdr_opt2)=09=09__PR((SCSI *scgp, cdr_t *));=09=09=09/* do late = option processing */ +=09int=09profile; +=09BOOL=09is_dvd; }; #endif --- cdrtools-2.01/cdrecord/cdrecord.c.dvd=092004-09-08 19:26:35.000000000 += 0200 +++ cdrtools-2.01/cdrecord/cdrecord.c=092004-10-18 14:37:32.436250174 +0200 @@ -180,6 +180,7 @@ LOCAL=09void=09susage=09=09__PR((int)); LOCAL=09void=09usage=09=09__PR((int)); LOCAL=09void=09blusage=09=09__PR((int)); +LOCAL=09void=09formattypeusage=09__PR((int)); LOCAL=09void=09intr=09=09__PR((int sig)); LOCAL=09void=09catchsig=09__PR((int sig)); LOCAL=09int=09scsi_cb=09=09__PR((void *arg)); @@ -216,9 +217,9 @@ LOCAL=09BOOL=09checkdsize=09__PR((SCSI *scgp, cdr_t *dp, =09=09=09=09=09long tsize, int flags)); LOCAL=09void=09raise_fdlim=09__PR((void)); -LOCAL=09void=09gargs=09=09__PR((int, char **, int *, track_t *, char **, +LOCAL=09int=09gargs=09=09__PR((int, char **, int *, track_t *, char **, =09=09=09=09=09int *, cdr_t **, -=09=09=09=09=09int *, long *, int *)); +=09=09=09=09=09int *, long *, int *, int *)); LOCAL=09void=09set_trsizes=09__PR((cdr_t *, int, track_t *)); EXPORT=09void=09load_media=09__PR((SCSI *scgp, cdr_t *, BOOL)); EXPORT=09void=09unload_media=09__PR((SCSI *scgp, cdr_t *, int)); @@ -238,6 +239,7 @@ LOCAL=09void=09wait_input=09__PR((void)); LOCAL=09void=09checkgui=09__PR((void)); LOCAL=09int=09getbltype=09__PR((char *optstr, long *typep)); +LOCAL=09int=09getformattype=09__PR((char *optstr, long *typep)); LOCAL=09void=09print_drflags=09__PR((cdr_t *dp)); LOCAL=09void=09print_wrmodes=09__PR((cdr_t *dp)); LOCAL=09BOOL=09check_wrmode=09__PR((cdr_t *dp, int wmode, int tflags)); @@ -262,6 +264,7 @@ =09int=09speed =3D -1; =09long=09flags =3D 0L; =09int=09blanktype =3D 0; +=09int=09formattype =3D 0; =09int=09i; =09int=09tracks =3D 0; =09int=09trackno; @@ -273,6 +276,9 @@ =09SCSI=09*scgp =3D NULL; =09char=09errstr[80]; =09BOOL=09gracedone =3D FALSE; +=09int ispacket; +=09BOOL=09is_cdwr =3D FALSE; +=09BOOL=09is_dvdwr =3D FALSE; #ifdef __EMX__ =09/* This gives wildcard expansion with Non-Posix shells with EMX */ @@ -287,8 +293,8 @@ =09=09track[i].track =3D track[i].trackno =3D i; =09track[0].tracktype =3D TOC_MASK; =09raise_fdlim(); -=09gargs(ac, av, &tracks, track, &dev, &timeout, &dp, &speed, &flags, -=09=09=09=09=09=09=09&blanktype); +=09ispacket =3D gargs(ac, av, &tracks, track, &dev, &timeout, &dp, &speed,= &flags, +=09=09=09=09=09=09=09&blanktype, &formattype); =09if ((track[0].tracktype & TOC_MASK) =3D=3D TOC_MASK) =09=09comerrno(EX_BAD, "Internal error: Bad TOC type.\n"); @@ -349,11 +355,15 @@ #=09define=09CLONE_TITLE=09"" #endif =09if ((flags & F_MSINFO) =3D=3D 0 || lverbose || flags & F_VERSION) { -=09=09printf("Cdrecord%s%s %s (%s-%s-%s) Copyright (C) 1995-2004 J=F6rg Sc= hilling\n", +=09=09printf("Cdrecord%s%s %s-dvd (%s-%s-%s) Copyright (C) 1995-2004 J=C3= =B6rg Schilling\n", =09=09=09=09=09=09=09=09PRODVD_TITLE, =09=09=09=09=09=09=09=09CLONE_TITLE, =09=09=09=09=09=09=09=09cdr_version, =09=09=09=09=09=09=09=09HOST_CPU, HOST_VENDOR, HOST_OS); + =09=09printf("Note: This version is an unofficial (modified) version wit= h DVD support\n"); + printf("Note: and therefore may have bugs that are not pre= sent in the original.\n"); + printf("Note: Please send bug reports or support requests = to <warly@mandrakesoft.com>.\n"); + printf("Note: The author of cdrecord should not be bothere= d with problems in this version.\n"); #if=09defined(SOURCE_MODIFIED) || !defined(IS_SCHILY_XCONFIG) #define=09INSERT_YOUR_EMAIL_ADDRESS_HERE @@ -483,11 +493,16 @@ =09 */ =09if ((scgp =3D scg_open(dev, errstr, sizeof (errstr), =09=09=09=09debug, (flags & F_MSINFO) =3D=3D 0 || lverbose)) =3D=3D (SCSI = *)0) { + =09 =09if (dev !=3D NULL || (flags & F_SCANBUS) =3D=3D 0 || (scgp =3D = scg_open("ATA", errstr, sizeof (errstr), + =09=09 =09 debug, (flags & F_MSINFO) =3D=3D 0 || lverbose)) = =3D=3D (SCSI *)0) { =09=09=09errmsg("%s%sCannot open SCSI driver.\n", errstr, errstr[0]?". ":"= "); =09=09=09errmsgno(EX_BAD, "For possible targets try 'cdrecord -scanbus'.%s= \n", =09=09=09=09=09=09geteuid() ? " Make sure you are root.":""); =09=09=09errmsgno(EX_BAD, "For possible transport specifiers try 'cdrecord= dev=3Dhelp'.\n"); =09=09=09exit(EX_BAD); + =09=09} else { + =09=09=09dev =3D "ATA"; + =09=09} =09} =09/* =09 * XXX Below this point we do not need root privilleges anymore. @@ -619,6 +634,17 @@ =09} else if (!is_unknown_dev(scgp) && dp !=3D get_cdrcmds(scgp)) { =09=09errmsgno(EX_BAD, "WARNING: Trying to use other driver on known devic= e.\n"); =09} + is_mmc(scgp, &is_cdwr, &is_dvdwr); + if (ispacket) { +=09 if (is_dvdwr) { +=09=09track[0].flags |=3D TI_PACKET; +=09=09/*XXX put here to only affect DVD writing, should be in gargs. +=09=09 * however if set in args for all mode, packet writing is then +=09=09 * broken for all disc as cdrecord assume that PACKET imply TAO whic= h +=09=09 * is not true at all???? */ +=09=09track[0].flags &=3D ~TI_TAO; +=09 } +=09} =09if (!is_cddrive(scgp)) =09=09comerrno(EX_BAD, "Sorry, no CD/DVD-Drive found on this target.\n"); @@ -649,8 +675,6 @@ =09 tracks > 0 || =09 cuefilename !=3D NULL) { -=09=09BOOL=09is_cdwr =3D FALSE; -=09=09BOOL=09is_dvdwr =3D FALSE; =09=09if ((dp->cdr_flags & CDR_ISREADER) !=3D 0) { =09=09=09errmsgno(EX_BAD, @@ -660,7 +684,7 @@ =09=09if (!is_mmc(scgp, &is_cdwr, &is_dvdwr)) =09=09=09is_cdwr =3D TRUE;=09=09=09/* If it is not MMC, it must be a CD wr= iter */ -=09=09if (is_dvdwr && !set_cdrcmds("mmc_dvd", (cdr_t **)NULL)) { +=09=09if (is_dvdwr && !set_cdrcmds("mmc_mdvd", (cdr_t **)NULL)) { =09=09=09errmsgno(EX_BAD, =09=09=09"This version of cdrecord does not include DVD-R/DVD-RW support c= ode.\n"); =09=09=09errmsgno(EX_BAD, @@ -965,11 +989,6 @@ =09=09print_toc(scgp, dp); =09=09comexit(0); =09} -=09if ((flags & F_FORMAT) !=3D 0) { -=09=09errmsgno(EX_BAD, "Format option not implemented in this version.\n")= ; -=09=09comexit(EX_BAD); -=09} - #ifdef=09XXX =09if ((*dp->cdr_check_session)() < 0) { =09=09comexit(EX_BAD); @@ -1181,7 +1200,39 @@ =09if (gettimeofday(&starttime, (struct timezone *)0) < 0) =09=09errmsg("Cannot get start time\n"); -=09/* +=09if (flags & F_FORMAT) { +=09 =09printf("cdrecord: media format asked\n"); +=09=09/* +=09=09 * Do not abort if OPC failes. Just give it a chance +=09=09 * for better laser power calibration than without OPC. +=09=09 * +=09=09 * Ricoh drives return with a vendor unique sense code. +=09=09 * This is most likely because they refuse to do OPC +=09=09 * on a non blank media. +=09=09 */ +=09=09scgp->silent++; +=09=09do_opc(scgp, dp, flags); +=09=09scgp->silent--; +=09=09wait_unit_ready(scgp, 120); +=09=09if (gettimeofday(&starttime, (struct timezone *)0) < 0) +=09=09=09errmsg("Cannot get start time\n"); + +=09=09if ((*dp->cdr_format)(scgp, dp, formattype) < 0) { +=09=09=09errmsgno(EX_BAD, "Cannot format disk, aborting.\n"); +=09=09=09comexit(EX_BAD); +=09=09} +=09=09if (gettimeofday(&fixtime, (struct timezone *)0) < 0) +=09=09=09errmsg("Cannot get format time\n"); +=09=09if (lverbose) +=09=09=09prtimediff("Formatting time: ", &starttime, &fixtime); + +=09=09if (!wait_unit_ready(scgp, 240) || tracks =3D=3D 0) { +=09=09=09comexit(0); +=09=09} +=09=09if (gettimeofday(&starttime, (struct timezone *)0) < 0) +=09=09=09errmsg("Cannot get start time\n"); +=09}=09 + /* =09 * Blank the media if we were requested to do so =09 */ =09if (flags & F_BLANK) { @@ -1238,6 +1289,14 @@ =09=09trackno =3D 0; =09} =09scgp->silent--; +=09 +=09/* If it is DVD, the information in TOC is fabricated :) +=09 The real information is from read disk info command*/ +=09if((dp->cdr_dstat->ds_disktype&DT_DVD) && (dp->cdr_dstat->ds_trlast>0))= { +=09 trackno=3Ddp->cdr_dstat->ds_trlast-1; +=09 printf("trackno=3D%d\n",trackno); +=09} + =09if ((tracks + trackno) > MAX_TRACK) { =09=09/* =09=09 * XXX How many tracks are allowed on a DVD? @@ -1422,8 +1481,8 @@ =09if (gracetime > 999) =09=09gracetime =3D 999; -=09printf("Starting to write CD/DVD at speed %d in %s%s %s mode for %s ses= sion.\n", -=09=09(int)dp->cdr_dstat->ds_wspeed, +=09printf("Starting to write CD/DVD at speed %5.1f in %s%s %s mode for %s = session.\n", +=09=09(float)dp->cdr_dstat->ds_wspeed, =09=09(dp->cdr_cmdflags & F_DUMMY) ? "dummy" : "real", =09=09(dp->cdr_cmdflags & F_FORCE) ? " force" : "", =09=09wm2name[dp->cdr_dstat->ds_wrmode], @@ -1539,6 +1598,7 @@ =09=09=09(tlast.tv_sec * 1.0 + tlast.tv_usec * 0.000001); =09=09if (fspeed > 999.0) =09=09=09fspeed =3D 999.0; +=09=09if (dp->is_dvd) fspeed /=3D 9; =09=09printf("Average write speed %5.1fx.\n", fspeed); =09} @@ -1593,7 +1653,7 @@ =09error("\t-checkdrive=09check if a driver for the drive is present\n"); =09error("\t-prcap=09=09print drive capabilities for MMC compliant drives\= n"); =09error("\t-inq=09=09do an inquiry for the drive and exit\n"); -=09error("\t-scanbus=09scan the SCSI bus and exit\n"); +=09error("\t-scanbus=09scan the SCSI and IDE buses and exit\n"); =09error("\t-reset=09=09reset the SCSI bus with the cdrecorder (if possibl= e)\n"); =09error("\t-abort=09=09send an abort sequence to the drive (may help if h= ung)\n"); =09error("\t-overburn=09allow to write more than the official size of a me= dium\n"); @@ -1601,7 +1661,8 @@ =09error("\t-useinfo=09use *.inf files to overwrite audio options.\n"); =09error("\tspeed=3D#=09=09set speed of drive\n"); =09error("\tblank=3Dtype=09blank a CD-RW disc (see blank=3Dhelp)\n"); -=09error("\t-format=09=09format a CD-RW/DVD-RW/DVD+RW disc\n"); +=09error("\tformat=09=09format a CD-RW/DVD-RW/DVD+RW disc\n"); +=09error("\tformattype=3D#=09select the format method for DVD+RW disc\n"); #ifdef=09FIFO =09error("\tfs=3D#=09=09Set fifo size to # (0 to disable, default is %ld M= B)\n", =09=09=09=09=09=09=09DEFAULT_FIFOSIZE/(1024L*1024L)); @@ -1687,6 +1748,18 @@ =09/* NOTREACHED */ } +LOCAL void +formattypeusage(ret) +=09int=09ret; +{ +=09error("Formating options:\n"); +=09error("\tfull\t\tstandard formating\n"); +=09error("\tbackground\t\tbackground formating\n"); +=09error("\tforce\t\tforce reformat\n"); + +=09exit(ret); +=09/* NOTREACHED */ +} /* ARGSUSED */ LOCAL void intr(sig) @@ -2156,6 +2229,7 @@ =09=09=09=09=09usleep(wt*1000); =09=09=09} #endif +=09=09=09if (dp->is_dvd) fspeed /=3D 9; =09=09=09printf(" %5.1fx", fspeed); =09=09=09printf("."); =09=09=09savbytes =3D (bytes >> 20) << 20; @@ -2969,10 +3043,13 @@ =09=09/* =09=09 * dsp->ds_maxblocks =3D=3D 0 (disk capacity is unknown). =09=09 */ -=09=09if (endsec >=3D (405000-300)) {=09=09=09/*<90 min disk*/ -=09=09=09errmsgno(EX_BAD, -=09=09=09=09"Data will not fit on any disk.\n"); -=09=09=09goto toolarge; +=09 if (endsec >=3D (2300000)) { +=09=09 errmsgno(EX_BAD, +=09=09=09"ERROR: Could not manage to find medium size, and more than 4.3 G= B of data.\n"); + =09=09 goto toolarge; +=09 } else if (endsec >=3D (405000-300)) { /*<90 min dis= k or DVD*/ +=09=09 errmsgno(EX_BAD, +=09=09=09"WARNING: Could not manage to find medium size, and more than 90 = mins of data.\n"); =09=09} else if (endsec >=3D (333000-150)) {=09=09/* 74 min disk*/ =09=09=09errmsgno(EX_BAD, =09=09=09"WARNING: Data may not fit on standard 74min disk.\n"); @@ -3046,7 +3123,7 @@ } char=09*opts =3D -"help,version,checkdrive,prcap,inq,scanbus,reset,abort,overburn,ignsize,us= einfo,dev*,timeout#,driver*,driveropts*,setdropts,tsize&,padsize&,pregap&,d= efpregap&,speed#,load,lock,eject,dummy,msinfo,toc,atip,multi,fix,nofix,wait= i,immed,debug#,d+,kdebug#,kd#,verbose+,v+,Verbose+,V+,x+,xd#,silent,s,audio= ,data,mode2,xa,xa1,xa2,xamix,cdi,isosize,nopreemp,preemp,nocopy,copy,nopad,= pad,swab,fs&,ts&,blank&,format,pktsize#,packet,noclose,force,tao,dao,sao,ra= w,raw96r,raw96p,raw16,clone,scms,isrc*,mcn*,index*,cuefile*,textfile*,text,= shorttrack,noshorttrack,gracetime#,minbuf#"; +"help,version,checkdrive,prcap,inq,scanbus,reset,abort,overburn,ignsize,us= einfo,dev*,timeout#,driver*,driveropts*,setdropts,tsize&,padsize&,pregap&,d= efpregap&,speed#,load,lock,eject,dummy,msinfo,toc,atip,multi,fix,nofix,wait= i,immed,debug#,d+,kdebug#,kd#,verbose+,v+,Verbose+,V+,x+,xd#,silent,s,audio= ,data,mode2,xa,xa1,xa2,xamix,cdi,isosize,nopreemp,preemp,nocopy,copy,nopad,= pad,swab,fs&,ts&,blank&,format,formattype&,pktsize#,packet,noclose,force,ta= o,dao,sao,raw,raw96r,raw96p,raw16,clone,scms,isrc*,mcn*,index*,cuefile*,tex= tfile*,text,shorttrack,noshorttrack,gracetime#,minbuf#"; /* * Defines used to find whether a write mode has been specified. @@ -3056,8 +3133,8 @@ #define=09M_RAW=09=094=09/* Raw mode */ #define=09M_PACKET=098=09/* Packed mode */ -LOCAL void -gargs(ac, av, tracksp, trackp, devp, timeoutp, dpp, speedp, flagsp, blankp= ) +LOCAL int +gargs(ac, av, tracksp, trackp, devp, timeoutp, dpp, speedp, flagsp, blankp= , formatp) =09int=09ac; =09char=09**av; =09int=09*tracksp; @@ -3068,6 +3145,7 @@ =09int=09*speedp; =09long=09*flagsp; =09int=09*blankp; +=09int=09*formatp; { =09int=09cac; =09char=09* const*cav; @@ -3080,6 +3158,7 @@ =09char=09*textfile =3D NULL; =09long=09bltype =3D -1; =09int=09doformat =3D 0; +=09int=09formattype =3D -1; =09Llong=09tracksize; =09Llong=09padsize; =09long=09pregapsize; @@ -3195,7 +3274,7 @@ =09=09=09=09&nopreemp, &preemp, =09=09=09=09&nocopy, ©, =09=09=09=09&nopad, &pad, &bswab, getnum, &fs, getnum, &bufsize, -=09=09=09=09getbltype, &bltype, &doformat, &pktsize, +=09=09=09=09getbltype, &bltype, &doformat, getformattype, &formattype, &pk= tsize, =09=09=09=09&ispacket, &noclose, &force, =09=09=09=09&tao, &dao, &dao, &raw, &raw96r, &raw96p, &raw16, =09=09=09=09&clone, @@ -3276,8 +3355,14 @@ =09=09=09=09*flagsp |=3D F_BLANK; =09=09=09=09*blankp =3D bltype; =09=09=09} -=09=09=09if (doformat) -=09=09=09=09*flagsp |=3D F_FORMAT; + =09=09=09if (doformat > 0) { + =09=09=09=09*flagsp |=3D F_FORMAT; + =09=09=09=09*formatp |=3D FULL_FORMAT; + =09=09=09} + =09=09=09if (formattype >=3D 0) { + =09=09=09=09*flagsp |=3D F_FORMAT; + =09=09=09=09*formatp |=3D formattype; + =09=09=09} =09=09=09if (ispacket) =09=09=09=09wm |=3D M_PACKET; =09=09=09if (tao) @@ -3724,14 +3809,14 @@ =09 ((strncmp(*devp, "HELP", 4) =3D=3D 0) || =09 (strncmp(*devp, "help", 4) =3D=3D 0))) { =09=09*flagsp |=3D F_CHECKDRIVE; /* Set this for not calling mlockall() */ -=09=09return; +=09=09return ispacket; =09} =09if (*flagsp & (F_LOAD|F_DLCK|F_SETDROPTS|F_MSINFO|F_TOC|F_PRATIP|F_FIX|= F_VERSION|F_CHECKDRIVE|F_PRCAP|F_INQUIRY|F_SCANBUS|F_RESET|F_ABORT)) { =09=09if (tracks !=3D 0) { =09=09=09errmsgno(EX_BAD, "No tracks allowed with this option\n"); =09=09=09susage(EX_BAD); =09=09} -=09=09return; +=09=09return ispacket; =09} =09*tracksp =3D tracks; =09if (*flagsp & F_SAO) { @@ -3760,12 +3845,13 @@ =09=09=09susage(EX_BAD); =09=09} =09=09cuefilename =3D cuefile; -=09=09return; +=09=09return ispacket; =09} =09if (tracks =3D=3D 0 && (*flagsp & (F_LOAD|F_DLCK|F_EJECT|F_BLANK|F_FORM= AT)) =3D=3D 0) { =09=09errmsgno(EX_BAD, "No tracks specified. Need at least one.\n"); =09=09susage(EX_BAD); =09} +=09return ispacket; } LOCAL void @@ -4437,6 +4523,26 @@ =09return (TRUE); } +LOCAL int +getformattype(optstr, typep) +=09char=09*optstr; +=09long=09*typep; +{ +=09if (streql(optstr, "full")) { +=09=09*typep =3D FULL_FORMAT; +=09} else if (streql(optstr, "background")) { +=09=09*typep =3D BACKGROUND_FORMAT; +=09} else if (streql(optstr, "force")) { +=09=09*typep =3D FORCE_FORMAT; +=09} else if (streql(optstr, "help")) { +=09=09formattypeusage(0); +=09} else { +=09=09error("Illegal blanking type '%s'.\n", optstr); +=09=09formattypeusage(EX_BAD); +=09=09return (-1); +=09} +=09return (TRUE); +} LOCAL void print_drflags(dp) =09cdr_t=09*dp; --- cdrtools-2.01/cdrecord/scsi_cdr.c.dvd=092004-05-25 00:36:01.000000000 += 0200 +++ cdrtools-2.01/cdrecord/scsi_cdr.c=092004-10-18 14:37:32.439249741 +0200 @@ -107,6 +107,8 @@ EXPORT=09int=09send_cue_sheet=09__PR((SCSI *scgp, caddr_t bp, long size)); EXPORT=09int=09read_buff_cap=09__PR((SCSI *scgp, long *, long *)); EXPORT=09int=09scsi_blank=09__PR((SCSI *scgp, long addr, int blanktype, BO= OL immed)); +EXPORT=09int=09scsi_format=09__PR((SCSI *scgp, caddr_t addr, int size, BOO= L background)); +EXPORT=09int=09scsi_set_streaming=09__PR((SCSI *scgp, caddr_t addr, int si= ze)); EXPORT=09BOOL=09allow_atapi=09__PR((SCSI *scgp, BOOL new)); EXPORT=09int=09mode_select=09__PR((SCSI *scgp, Uchar *, int, int, int)); EXPORT=09int=09mode_sense=09__PR((SCSI *scgp, Uchar *dp, int cnt, int page= , int pcf)); @@ -519,6 +521,32 @@ } EXPORT int +scsi_set_streaming(scgp, perf_desc, size) +=09SCSI=09*scgp; +=09caddr_t=09perf_desc; +=09int=09size; +{ +=09register struct=09scg_cmd=09*scmd =3D scgp->scmd; + +=09fillbytes((caddr_t)scmd, sizeof (*scmd), '\0'); +=09scmd->addr =3D perf_desc; +=09scmd->size =3D size; +=09scmd->flags =3D SCG_DISRE_ENA; +=09scmd->cdb_len =3D SC_G5_CDBLEN; +=09scmd->sense_len =3D CCS_SENSE_LEN; +=09scmd->cdb.g5_cdb.cmd =3D 0xB6; +=09scmd->cdb.cmd_cdb[11] =3D 0; +=09scmd->cdb.cmd_cdb[10] =3D size; + +=09scgp->cmdname =3D "set streaming"; + +=09printf("scsi_set_streaming\n"); +=09if (scg_cmd(scgp) < 0) +=09=09return (-1); +=09return (0); +} + +EXPORT int scsi_set_speed(scgp, readspeed, writespeed, rotctl) =09SCSI=09*scgp; =09int=09readspeed; @@ -1042,6 +1070,32 @@ =09return (0); } + +EXPORT int +reserve_track(scgp, size) +=09SCSI=09*scgp; +=09Ulong=09size; + +{ +=09register struct=09scg_cmd=09*scmd =3D scgp->scmd; + +=09fillbytes((caddr_t)scmd, sizeof(*scmd), '\0'); +=09scmd->flags =3D SCG_DISRE_ENA; +=09scmd->cdb_len =3D SC_G1_CDBLEN; +=09scmd->sense_len =3D CCS_SENSE_LEN; +=09scmd->cdb.g1_cdb.cmd =3D 0x53; +=09scmd->cdb.g1_cdb.lun =3D scg_lun(scgp); +=09i_to_4_byte(&scmd->cdb.g1_cdb.addr[3], size); + +=09scgp->cmdname =3D "reserve track"; + +=09if (scg_cmd(scgp) < 0) +=09=09return (-1); + +=09return (0); + +} + EXPORT int read_rzone_info(scgp, bp, cnt) =09SCSI=09*scgp; @@ -1323,6 +1377,69 @@ =09return (scg_cmd(scgp)); } +EXPORT int +scsi_format(scgp, addr, size, background) +=09SCSI=09*scgp; +=09caddr_t=09addr; +=09int =09size; +=09BOOL =09background; +{ +=09register struct=09scg_cmd=09*scmd =3D scgp->scmd; +=09int progress=3D0, ret=3D-1, pid=3D-1; +=09unsigned char sense_table[18]; +=09int i; +=09 +=09printf("scsi_format: preparing\n"); + +=09fillbytes((caddr_t)scmd, sizeof(*scmd), '\0'); +=09scmd->addr =3D addr; +=09scmd->size =3D size; +=09scmd->flags =3D SCG_DISRE_ENA; +=09scmd->cdb_len =3D SC_G5_CDBLEN; +=09scmd->sense_len =3D CCS_SENSE_LEN; +=09scmd->timeout =3D 160 * 60; /* Do not know what to set */ +=09scmd->cdb.g5_cdb.cmd =3D 0x04; /* Format Unit */ +=09scmd->cdb.cmd_cdb[1] =3D 0x11; /* "FmtData" and "Format Code" */ +=09scmd->cdb.cmd_cdb[5] =3D 0; + +=09scgp->cmdname =3D "format unit"; + +=09printf("scsi_format: running\n"); +=09ret =3D (scg_cmd(scgp)); +=09printf("scsi_format: post processing %d\n", ret); +=09if (ret =3D=3D -1) return ret; +=09if (background) { +=09=09if ((pid=3Dfork()) =3D=3D (pid_t)-1) +=09=09=09perror ("- [unable to fork()]"); +=09=09else { +=09=09=09if (!pid) { +=09=09=09 while (1) { +=09=09=09=09if (test_unit_ready(scgp) >=3D 0) +=09=09=09=09 break; +=09=09=09=09sleep(1); +=09=09=09 } +=09=09=09 return ret; +=09=09=09} +=09=09} +=09} +=09printf("Formating in progress: 0.00 %% done."); +=09sleep(20); +=09while (progress < 0xfff0) { +=09=09test_unit_ready(scgp); +=09=09request_sense_b(scgp, (caddr_t)sense_table, 18); +=09=09progress =3D sense_table[16]<<8|sense_table[17]; +=09=09printf("\rFormating in progress: %.2f %% done [%d]. = ", (float)(progress*100)/0x10000,progress); +=09=09usleep(10000); +=09=09/*for (i=3D0; i < 18; i++) { +=09=09 printf("%d ", sense_table[i]); +=09=09}*/ +=09} +=09sleep(10); +=09printf("\rFormating in progress: 100.00 %% done. \n"); +=09if (pid) exit (0); +=09return ret; +} + /* * XXX First try to handle ATAPI: * XXX ATAPI cannot handle SCSI 6 byte commands. --- cdrtools-2.01/libscg/scsitransp.c.dvd=092004-06-17 22:20:27.000000000 += 0200 +++ cdrtools-2.01/libscg/scsitransp.c=092004-10-18 14:37:32.424251905 +0200 @@ -108,6 +108,7 @@ EXPORT=09int=09scg_sense_key=09__PR((SCSI *scgp)); EXPORT=09int=09scg_sense_code=09__PR((SCSI *scgp)); EXPORT=09int=09scg_sense_qual=09__PR((SCSI *scgp)); +EXPORT=09unsigned char *scg_sense_table=09__PR((SCSI *scgp)); EXPORT=09void=09scg_fprintdev=09__PR((FILE *, struct scsi_inquiry *)); EXPORT=09void=09scg_printdev=09__PR((struct scsi_inquiry *)); EXPORT=09int=09scg_printf=09__PR((SCSI *scgp, const char *form, ...)); @@ -1240,6 +1241,23 @@ } /* + * Return all the SCSI sense table last command. + */ +EXPORT unsigned char * +scg_sense_table(scgp) +=09SCSI=09*scgp; +{ +=09register struct scg_cmd *cp =3D scgp->scmd; + +=09if(!scg_cmd_err(scgp)) +=09=09return (0); + +=09if (cp->sense.code >=3D 0x70) +=09=09return &(cp->sense); + =09return (0); +} + +/* * Return the SCSI sense code for last command. */ EXPORT int --=_5wlk2xwi3j0g--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050221115057.43c7iqxq8w8g8gkg>