From 1ccedd55722209fdcd5c4702bcd737c121a06d84 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 3 Jun 2009 18:53:57 +0000 Subject: [PATCH] Bug fix: No usable media was detected with old MMC-1 drives --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/drive.c | 2 +- libburn/mmc.c | 152 +++++++++++++++++++++++++----------- libburn/spc.c | 2 +- libburn/transport.h | 2 + 5 files changed, 112 insertions(+), 48 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index a5e083a..e03b60e 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2009.06.03.085637" +#define Cdrskin_timestamP "2009.06.03.185118" diff --git a/libburn/drive.c b/libburn/drive.c index 87f91e3..5327aea 100644 --- a/libburn/drive.c +++ b/libburn/drive.c @@ -232,7 +232,7 @@ int burn_drive_inquire_media(struct burn_drive *d) /* ts A61020 : d->status was set to BURN_DISC_BLANK as pure guess */ /* ts A71128 : run read_disc_info() for any recognizeable profile */ - if (d->current_profile > 0 || + if (d->current_profile > 0 || d->current_is_guessed_profile || d->mdata->cdr_write || d->mdata->cdrw_write || d->mdata->dvdr_write || d->mdata->dvdram_write) { diff --git a/libburn/mmc.c b/libburn/mmc.c index e8dc44b..28a52b7 100644 --- a/libburn/mmc.c +++ b/libburn/mmc.c @@ -77,6 +77,12 @@ extern struct libdax_msgs *libdax_messenger; # define Libburn_do_not_format_dvd_ram_or_bd_rE 1 */ + +/* ts A90603 : Simulate the command restrictions of an old MMC-1 drive + # define Libisofs_simulate_old_mmc1_drivE 1 +*/ + + /* DVD/BD progress report: ts A61219 : It seems to work with a used (i.e. thoroughly formatted) DVD+RW. Error messages of class DEBUG appear because of inability to @@ -1460,6 +1466,75 @@ inquire_drive:; } +/* ts A61201 */ +static char *mmc_obtain_profile_name(int profile_number) +{ + static char *texts[0x53] = {NULL}; + int i, max_pno = 0x53; + + if (texts[0] == NULL) { + for (i = 0; i=max_pno) + return ""; + return texts[profile_number]; +} + + +/* ts A90603 : to be used if the drive knows no GET CONFIGURATION +*/ +static int mmc_guess_profile(struct burn_drive *d, int flag) +{ + int cp; + + cp = 0; + if (d->status == BURN_DISC_BLANK || + d->status == BURN_DISC_APPENDABLE) { + cp = 0x09; + } else if (d->status == BURN_DISC_FULL) { + cp = 0x08; + } + if (cp) + if (d->erasable) + cp = 0x0a; + d->current_profile = cp; + if (cp == 0) + return 0; + d->current_is_cd_profile = 1; + d->current_is_supported_profile = 1; + strcpy(d->current_profile_text, mmc_obtain_profile_name(cp)); + return 1; +} + + static int mmc_read_disc_info_al(struct burn_drive *d, int *alloc_len) { struct buffer buf; @@ -1610,6 +1685,10 @@ regard_as_blank:; break; } + /* ts A90603 : An MMC-1 drive might not know the media type yet */ + if (d->current_is_guessed_profile && d->current_profile == 0) + mmc_guess_profile(d, 0); + if ((d->current_profile != 0 || d->status != BURN_DISC_UNREADY) && ! d->current_is_supported_profile) { if (!d->silent_on_scsi_error) { @@ -1625,7 +1704,7 @@ regard_as_blank:; return 0; } - /* >>> ts A61217 : Note for future + /* ts A61217 : Note for future growisofs performs OPC if (data[0]<<8)|data[1]<=32 which indicates no OPC entries are attached to the reply from the drive. @@ -2165,49 +2244,6 @@ void mmc_set_speed(struct burn_drive *d, int r, int w) } -/* ts A61201 */ -static char *mmc_obtain_profile_name(int profile_number) -{ - static char *texts[0x53] = {NULL}; - int i, max_pno = 0x53; - - if (texts[0] == NULL) { - for (i = 0; i=max_pno) - return ""; - return texts[profile_number]; -} - - /* ts A61201 : found in unfunctional state */ static int mmc_get_configuration_al(struct burn_drive *d, int *alloc_len) @@ -2227,6 +2263,7 @@ static int mmc_get_configuration_al(struct burn_drive *d, int *alloc_len) d->current_profile_text[0] = 0; d->current_is_cd_profile = 0; d->current_is_supported_profile = 0; + d->current_is_guessed_profile = 0; d->current_has_feat21h = 0; d->current_feat21h_link_size = -1; d->current_feat23h_byte4 = 0; @@ -2249,8 +2286,24 @@ static int mmc_get_configuration_al(struct burn_drive *d, int *alloc_len) c.dir = FROM_DRIVE; d->issue_command(d, &c); - if (c.error) +#ifdef Libisofs_simulate_old_mmc1_drivE + c.error = 1; + c.sense[2] = 0x5; + c.sense[12] = 0x20; + c.sense[13] = 0x0; +#endif /* Libisofs_simulate_old_mmc1_drivE */ + + if (c.error) { + /* ts A90603 : MMC-1 drive do not know 46h GET CONFIGURATION */ + if (c.sense[2] == 0x5 && c.sense[12] == 0x20 && + c.sense[13] == 0x0) { + d->current_is_guessed_profile = 1; + /* Will yield a non-zero profile only after + mmc_read_disc_info_al() was called */ + mmc_guess_profile(d, 0); + } return 0; + } old_alloc_len = *alloc_len; *alloc_len = len = mmc_four_char_to_int(c.page->data); if (len > old_alloc_len) @@ -3475,6 +3528,14 @@ static int mmc_get_write_performance_al(struct burn_drive *d, c.page->bytes = 0; c.dir = FROM_DRIVE; d->issue_command(d, &c); + +#ifdef Libisofs_simulate_old_mmc1_drivE + c.error = 1; + c.sense[2] = 0x5; + c.sense[12] = 0x20; + c.sense[13] = 0x0; +#endif /* Libisofs_simulate_old_mmc1_drivE */ + if (c.error) return 0; len = mmc_four_char_to_int(c.page->data); @@ -3810,6 +3871,7 @@ int mmc_setup_drive(struct burn_drive *d) d->current_profile_text[0] = 0; d->current_is_cd_profile = 0; d->current_is_supported_profile = 0; + d->current_is_guessed_profile = 0; d->current_has_feat21h = 0; d->current_feat21h_link_size = -1; d->current_feat23h_byte4 = 0; diff --git a/libburn/spc.c b/libburn/spc.c index 6e5aa53..eb55093 100644 --- a/libburn/spc.c +++ b/libburn/spc.c @@ -359,7 +359,7 @@ static int spc_sense_caps_al(struct burn_drive *d, int *alloc_len, int flag) if (page_length + 10 > old_alloc_len) page_length = old_alloc_len - 10; - /* ts A90602 : 20 to asserts page[21]. (see SPC-1 8.3.3) */ + /* ts A90602 : 20 asserts page[21]. (see SPC-1 8.3.3) */ if (page_length < 20) { m->valid = -1; sprintf(msg, "MODE SENSE page 2A too short: %s : %d", diff --git a/libburn/transport.h b/libburn/transport.h index c0ef4df..4f9718b 100644 --- a/libburn/transport.h +++ b/libburn/transport.h @@ -161,6 +161,8 @@ struct burn_drive char current_profile_text[80]; int current_is_cd_profile; int current_is_supported_profile; + /* ts A90603 */ + int current_is_guessed_profile; /* ts A70128 : MMC-to-MMC feature info from 46h for DVD-RW. Quite internal. Regard as opaque :)