From dbec2d53a3a89bda776fe9b23eaa21c52a0ffb15 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 18 Apr 2008 09:27:16 +0000 Subject: [PATCH] Began to implement formatting of DVD-RAM and experimentally of BD-RE --- libburn/trunk/cdrskin/cdrskin_timestamp.h | 2 +- libburn/trunk/libburn/async.c | 4 ++ libburn/trunk/libburn/drive.c | 4 +- libburn/trunk/libburn/libburn.h | 13 +++- libburn/trunk/libburn/mmc.c | 76 ++++++++++++++++++----- 5 files changed, 78 insertions(+), 21 deletions(-) diff --git a/libburn/trunk/cdrskin/cdrskin_timestamp.h b/libburn/trunk/cdrskin/cdrskin_timestamp.h index 204b4e5a..9cb1180c 100644 --- a/libburn/trunk/cdrskin/cdrskin_timestamp.h +++ b/libburn/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2008.04.16.082208" +#define Cdrskin_timestamP "2008.04.18.092715" diff --git a/libburn/trunk/libburn/async.c b/libburn/trunk/libburn/async.c index ff801afd..4881d644 100644 --- a/libburn/trunk/libburn/async.c +++ b/libburn/trunk/libburn/async.c @@ -392,6 +392,10 @@ void burn_disc_format(struct burn_drive *drive, off_t size, int flag) size = 0; flag &= ~(2|8); /* no insisting in size 0, no expansion */ flag |= 4; /* format up to maximum size */ + } else if (drive->current_profile == 0x12) { + ok = 1; /* DVD-RAM */ + } else if (drive->current_profile == 0x43) { + ok = 1; /* BD-RE */ } if (!ok) { diff --git a/libburn/trunk/libburn/drive.c b/libburn/trunk/libburn/drive.c index 9baffe80..d5e7fa00 100644 --- a/libburn/trunk/libburn/drive.c +++ b/libburn/trunk/libburn/drive.c @@ -592,7 +592,7 @@ void burn_disc_erase_sync(struct burn_drive *d, int fast) /* @param flag: bit0 = fill formatted size with zeros - bit1, bit2 , bit4, bit7 - bit15 are for d->format_unit() + bit1, bit2 , bit4, bit5, bit7 - bit15 are for d->format_unit() */ void burn_disc_format_sync(struct burn_drive *d, off_t size, int flag) { @@ -615,7 +615,7 @@ void burn_disc_format_sync(struct burn_drive *d, off_t size, int flag) d->cancel = 0; d->busy = BURN_DRIVE_FORMATTING; - ret = d->format_unit(d, size, flag & 0xff96); /* forward bits */ + ret = d->format_unit(d, size, flag & 0xffb6); /* forward bits */ if (ret <= 0) d->cancel = 1; diff --git a/libburn/trunk/libburn/libburn.h b/libburn/trunk/libburn/libburn.h index 8547fb28..31c383ac 100644 --- a/libburn/trunk/libburn/libburn.h +++ b/libburn/trunk/libburn/libburn.h @@ -1166,11 +1166,15 @@ void burn_read_opts_free(struct burn_read_opts *opts); void burn_disc_erase(struct burn_drive *drive, int fast); -/* ts A70101 - A70112 */ +/* ts A70101 - A70417 */ /** Format media for use with libburn. This currently applies to DVD-RW in state "Sequential Recording" (profile 0014h) which get formatted to state "Restricted Overwrite" (profile 0013h). DVD+RW can be "de-iced" by setting bit2 of flag. Other media cannot be formatted yet. + This function usually returns while the drive is still in the process + of formatting. The formatting is done, when burn_drive_get_status() + returns BURN_DRIVE_IDLE. This may be immediately after return or may + need several thousand seconds to occur. @param drive The drive with the disc to format. @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 @@ -1179,14 +1183,17 @@ void burn_disc_erase(struct burn_drive *drive, int fast); bit0= after formatting, write the given number of zero-bytes to the media and eventually perform preliminary closing. bit1= insist in size 0 even if there is a better default known - bit2= format to maximum available size + bit2= without bit7: format to maximum available size + with bit7 : take size from indexed format descriptor bit3= -reserved- bit4= enforce re-format of (partly) formatted media + bit5= try to disable eventual defect management bit7= MMC expert application mode (else libburn tries to choose a suitable format type): bit8 to bit15 contain the index of the format to use. See burn_disc_get_formats(), burn_disc_get_format_descr(). - Acceptable types are: 0x00, 0x10, 0x11, 0x13, 0x15, 0x26. + Acceptable types are: 0x00, 0x01, 0x10, 0x11, 0x13, + 0x15, 0x26, 0x30, 0x31. If bit7 is set, bit4 is set automatically. */ void burn_disc_format(struct burn_drive *drive, off_t size, int flag); diff --git a/libburn/trunk/libburn/mmc.c b/libburn/trunk/libburn/mmc.c index 58778eb3..6fde1bda 100644 --- a/libburn/trunk/libburn/mmc.c +++ b/libburn/trunk/libburn/mmc.c @@ -2564,6 +2564,7 @@ int mmc_read_buffer_capacity(struct burn_drive *d) bit2= format to maximum available size bit3= expand format up to at least size bit4= enforce re-format of (partly) formatted media + bit5= try to disable eventual defect management bit7= bit8 to bit15 contain the index of the format to use bit8-bit15 = see bit7 */ @@ -2572,8 +2573,8 @@ int mmc_format_unit(struct burn_drive *d, off_t size, int flag) struct buffer buf; struct command c; int ret, tolerate_failure = 0, return_immediately = 0, i, format_type; - int index; - off_t num_of_blocks = 0, diff; + int index, format_sub_type = 0; + off_t num_of_blocks = 0, diff, format_size; char msg[160],descr[80]; int full_format_type = 0x00; /* Full Format (or 0x10 for DVD-RW ?) */ @@ -2605,7 +2606,7 @@ int mmc_format_unit(struct burn_drive *d, off_t size, int flag) if (ret <= 0) goto selected_not_suitable; index = (flag >> 8) & 0xff; - if(index < 0 || index > d->num_format_descr) { + if(index < 0 || index >= d->num_format_descr) { selected_not_suitable:; libdax_msgs_submit(libdax_messenger, d->global_index, 0x00020132, @@ -2617,14 +2618,16 @@ selected_not_suitable:; if (!(d->current_profile == 0x13 || d->current_profile == 0x14 || d->current_profile == 0x1a || - (0 && d->current_profile == 0x12) || + d->current_profile == 0x12 || (0 && d->current_profile == 0x43))) /* >>> */ goto unsuitable_media; format_type = d->format_descriptors[index].type; - if (!(format_type == 0x00 || format_type == 0x10 || + if (!(format_type == 0x00 || format_type == 0x01 || + format_type == 0x10 || format_type == 0x11 || format_type == 0x13 || - format_type == 0x15 || format_type == 0x26)) + format_type == 0x15 || format_type == 0x26 || + format_type == 0x30 || format_type == 0x31 )) goto selected_not_suitable; if (flag & 4) { num_of_blocks = @@ -2734,6 +2737,7 @@ selected_not_suitable:; } } else { +no_suitable_formatting_type:; libdax_msgs_submit(libdax_messenger, d->global_index, 0x00020131, LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, @@ -2747,15 +2751,46 @@ selected_not_suitable:; format_type == 0x15 ? "quick" : "full"); return_immediately = 1; /* caller must do the waiting */ - } else if (0 && d->current_profile == 0x12) { - /* DVD-RAM */ - format_type = 0x00; - if(flag & 4) { - /* >>> search for largest 0x00 format descriptor */; - } else { - /* >>> search for smallest 0x00 descriptor >= size */; + } else if (d->current_profile == 0x12) { + /* ts A80417 : DVD-RAM */ + index = -1; + format_size = -1; + for (i = 0; i < d->num_format_descr; i++) { + format_type = d->format_descriptors[i].type; + if (format_type!=0x00 && format_type!=0x01) + continue; + if(flag & (4 | 32)) { /* Max size or no defect mgt */ + /* Search for largest 0x00 or 0x01 + format descriptor */; + if (d->format_descriptors[i].size>format_size){ + format_size = + d->format_descriptors[i].size; + index = i; + } + } else { + /* Search for smallest 0x0 or 0x01 + descriptor >= size */; + if (d->format_descriptors[i].size >= size && + (format_size < 0 || + d->format_descriptors[i].sizeformat_descriptors[i].size; + index = i; + } + } } - /* >>> */; + if(index < 0) + goto no_suitable_formatting_type; + format_type = d->format_descriptors[index].type; + num_of_blocks = d->format_descriptors[index].size / 2048; + mmc_int_to_four_char(c.page->data + 4, num_of_blocks); + for (i = 0; i < 3; i++) + c.page->data[9 + i] = + ( d->format_descriptors[index].tdp >> + (16 - 8 * i)) & 0xff; + sprintf(descr, "%s", d->current_profile_text); + return_immediately = 1; /* caller must do the waiting */ } else if (0 && d->current_profile == 0x43 && burn_support_untested_profiles) { @@ -2784,7 +2819,7 @@ unsuitable_media:; msg, 0, 0); return 0; } - c.page->data[8] = format_type << 2; + c.page->data[8] = (format_type << 2) | (format_sub_type & 3); sprintf(msg, "Format type %2.2Xh \"%s\", blocks = %.f\n", format_type, descr, (double) num_of_blocks); @@ -2792,6 +2827,17 @@ unsuitable_media:; LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO, msg, 0, 0); + /* <<< + */ + if(d->current_profile == 0x12 || d->current_profile == 0x43) { + libdax_msgs_submit(libdax_messenger, d->global_index, + 0x00000002, + LIBDAX_MSGS_SEV_NOTE, LIBDAX_MSGS_PRIO_ZERO, + "Formatting of DVD-RAM or BD-RE not implemented yet", + 0, 0); + return 1; + } + d->issue_command(d, &c); if (c.error && !tolerate_failure) { if (c.sense[2]!=0) {