Introduced size parameter to DVD-RW formatting plus writing of zeros.

This commit is contained in:
Thomas Schmitt 2007-01-08 10:42:54 +00:00
parent 6a69cfcf07
commit fdd40d4492
5 changed files with 89 additions and 11 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2007.01.06.120551"
#define Cdrskin_timestamP "2007.01.08.104222"

View File

@ -26,6 +26,9 @@
#include "sg.h"
#include "structure.h"
/* ts A70107 : to get BE_CANCELLED */
#include "error.h"
#include "libdax_msgs.h"
extern struct libdax_msgs *libdax_messenger;
@ -198,7 +201,6 @@ int burn_drive_inquire_media(struct burn_drive *d)
if (d->current_profile == -1 || d->current_is_cd_profile)
d->read_toc(d);
}
d->busy = BURN_DRIVE_IDLE;
return 1;
}
@ -237,6 +239,7 @@ int burn_drive_grab(struct burn_drive *d, int le)
/* ts A61125 : outsourced media state inquiry aspects */
ret = burn_drive_inquire_media(d);
d->silent_on_scsi_error = sose;
d->busy = BURN_DRIVE_IDLE;
return ret;
}
@ -467,16 +470,31 @@ void burn_disc_erase_sync(struct burn_drive *d, int fast)
/* ts A61125 : update media state records */
burn_drive_mark_unready(d);
burn_drive_inquire_media(d);
d->busy = BURN_DRIVE_IDLE;
}
/*
@param flag: bit0 = fill formatted size with zeros
*/
void burn_disc_format_sync(struct burn_drive *d, off_t size, int flag)
{
int ret;
int ret, buf_secs, err, i, stages = 1, pbase, pfill, pseudo_sector;
off_t num_bufs;
char msg[80];
struct buffer buf;
/*
#define Libburn_format_ignore_sizE 1
*/
#ifdef Libburn_format_ignore_sizE
size = 0;
#else
stages = 2 * (flag & 1);
#endif
d->cancel = 0;
d->busy = BURN_DRIVE_FORMATTING;
ret = d->format_unit(d, (off_t) 0, 0);
ret = d->format_unit(d, size, 0);
if (ret <= 0)
d->cancel = 1;
/* reset the progress */
@ -492,16 +510,67 @@ void burn_disc_format_sync(struct burn_drive *d, off_t size, int flag)
while (!d->test_unit_ready(d) && d->get_erase_progress(d) == 0)
sleep(1);
while ((d->progress.sector = d->get_erase_progress(d)) > 0 ||
!d->test_unit_ready(d))
while ((pseudo_sector = d->get_erase_progress(d)) > 0 ||
!d->test_unit_ready(d)) {
d->progress.sector = pseudo_sector / stages;
sleep(1);
}
d->sync_cache(d);
d->progress.sector = 0x10000;
if (size <= 0)
goto ex;
/* ts A61125 : update media state records */
/* update media state records */
burn_drive_mark_unready(d);
burn_drive_inquire_media(d);
if (flag & 1) {
/* write size in zeros */;
pbase = 0x8000;
pfill = 0xffff - pbase;
buf_secs = 16; /* Must not be more than 16 */
num_bufs = size / buf_secs / 2048;
if (num_bufs <= 0 || num_bufs > 0x7fffffff) {
d->cancel = 1;
goto ex;
}
/* <<< */
sprintf(msg,
"Writing %.f sectors of zeros to formatted media\n",
(double) num_bufs * (double) buf_secs);
libdax_msgs_submit(libdax_messenger, d->global_index,
0x00000002,
LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO,
msg, 0, 0);
d->buffer = &buf;
memset(d->buffer, 0, sizeof(struct buffer));
d->buffer->bytes = buf_secs * 2048;
d->buffer->sectors = buf_secs;
d->busy = BURN_DRIVE_WRITING;
for (i = 0; i < num_bufs; i++) {
d->nwa = i * buf_secs;
err = d->write(d, d->nwa, d->buffer);
if (err == BE_CANCELLED || d->cancel) {
d->cancel = 1;
break;
}
d->progress.sector = pbase
+ pfill * ((double) i / (double) num_bufs);
}
d->sync_cache(d);
if (d->current_profile == 0x13 || d->current_profile == 0x1a) {
/* DVD-RW or DVD+RW */
d->busy = BURN_DRIVE_CLOSING_SESSION;
/* CLOSE SESSION, 010b */
d->close_track_session(d, 1, 0);
d->busy = BURN_DRIVE_WRITING;
}
}
ex:;
d->progress.sector = 0x10000;
d->busy = BURN_DRIVE_IDLE;
d->buffer = NULL;
}
enum burn_disc_status burn_disc_get_status(struct burn_drive *d)

View File

@ -847,8 +847,12 @@ void burn_disc_erase(struct burn_drive *drive, int fast);
in state "Sequential Recording" (profile 0014h) which get formatted to
state "Restricted Overwrite" (profile 0013h).
@param drive The drive with the disc to format.
@param size Unused yet. Submit: (off_t) 0.
@param flag Unused yet. Submit: 0.
@param size The size in bytes to be used with the format command. It should
be divisible by 32*1024. The effect of this parameter may
depend on the media profile.
@param flag Bitfield for control purposes:
bit0= after formatting, write the given number of zero-bytes
to the media and eventually perform preliminary closing.
*/
void burn_disc_format(struct burn_drive *drive, off_t size, int flag);

View File

@ -1167,6 +1167,7 @@ int mmc_read_buffer_capacity(struct burn_drive *d)
>>> formatting are answered. Currently it is a very use case specific
>>> all-in-one automat.
@param size The size (in bytes) to be sent with the FORMAT comand
@param flag unused yet, submit 0
*/
int mmc_format_unit(struct burn_drive *d, off_t size, int flag)
@ -1198,8 +1199,10 @@ int mmc_format_unit(struct burn_drive *d, off_t size, int flag)
/* mmc5r03c.pdf , 6.5.4.2.14, DVD+RW Basic Format */
c.page->data[8] = 0x26 << 2; /* Format type */
/* Note: parameter "size" is ignored here */
memset(c.page->data + 4, 0xff, 4); /* maximum blocksize */
if (d->bg_format_status == 1) /* is partly formatted */
c.page->data[11] = 1; /* Restart bit */
else if(d->bg_format_status == 2) { /* format in progress */

View File

@ -1149,6 +1149,7 @@ ex:;
burn_drive_mark_unready(d);
burn_drive_inquire_media(d);
d->busy = BURN_DRIVE_IDLE;
return ret;
early_failure:;
return 0;
@ -1316,6 +1317,7 @@ return crap. so we send the command, then ignore the result.
burn_drive_inquire_media(d);
burn_print(1, "done\n");
d->busy = BURN_DRIVE_IDLE;
/* ts A61012 : This return was traditionally missing. I suspect this
to have caused Cdrskin_eject() failures */