From 3ffd17556b003cf38e28d8f553b3f01a96f400a1 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 17 Jul 2007 08:57:24 +0000 Subject: [PATCH] Implemented minimum speed in burn_drive_set_speed() --- libburn/trunk/cdrskin/cdrskin.c | 8 ++- libburn/trunk/cdrskin/cdrskin_timestamp.h | 2 +- libburn/trunk/libburn/drive.c | 16 +++-- libburn/trunk/libburn/libburn.h | 12 ++-- libburn/trunk/libburn/mmc.c | 73 +++++++++++++---------- 5 files changed, 65 insertions(+), 46 deletions(-) diff --git a/libburn/trunk/cdrskin/cdrskin.c b/libburn/trunk/cdrskin/cdrskin.c index 7eb372dd..1058a863 100644 --- a/libburn/trunk/cdrskin/cdrskin.c +++ b/libburn/trunk/cdrskin/cdrskin.c @@ -2962,9 +2962,13 @@ int Cdrskin_adjust_speed(struct CdrskiN *skin, int flag) if(skin->x_speed<0) k_speed= 0; /* libburn.h promises 0 to be max speed. */ - else if(skin->x_speed==0) /* cdrecord specifies 0 as minimum speed. */ + else if(skin->x_speed==0) { /* cdrecord specifies 0 as minimum speed. */ +#ifdef Cdrskin_libburn_has_get_best_speeD + k_speed= -1; +#else k_speed= Cdrskin_libburn_speed_factoR+Cdrskin_libburn_speed_addoN; - else +#endif + } else k_speed= skin->x_speed*Cdrskin_libburn_speed_factoR + Cdrskin_libburn_speed_addoN; diff --git a/libburn/trunk/cdrskin/cdrskin_timestamp.h b/libburn/trunk/cdrskin/cdrskin_timestamp.h index baade086..b52aeba9 100644 --- a/libburn/trunk/cdrskin/cdrskin_timestamp.h +++ b/libburn/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2007.07.14.112326" +#define Cdrskin_timestamP "2007.07.17.085823" diff --git a/libburn/trunk/libburn/drive.c b/libburn/trunk/libburn/drive.c index 0d6bcff7..d415f0a4 100644 --- a/libburn/trunk/libburn/drive.c +++ b/libburn/trunk/libburn/drive.c @@ -1623,17 +1623,23 @@ int burn_drive_get_best_speed(struct burn_drive *d, int speed_goal, if (flag & 2) source = -1; - + if (speed_goal < 0) + best_speed = 2000000000; *best_descr = NULL; for (sd = d->mdata->speed_descriptors; sd != NULL; sd = sd->next) { - if ((source >= 0 && sd->source != source) || - sd->write_speed <= 0) - continue; if (flag & 1) speed = sd->read_speed; else speed = sd->write_speed; - if (speed_goal <= 0) { + if ((source >= 0 && sd->source != source) || + speed <= 0) + continue; + if (speed_goal < 0) { + if (speed < best_speed) { + best_speed = speed; + *best_descr = sd; + } + } else if (speed_goal == 0) { if ((source == 2 && sd->end_lba > best_lba) || ((source !=2 || sd->end_lba == best_lba) && speed > best_speed)) { diff --git a/libburn/trunk/libburn/libburn.h b/libburn/trunk/libburn/libburn.h index a207cba8..8c2a70ff 100644 --- a/libburn/trunk/libburn/libburn.h +++ b/libburn/trunk/libburn/libburn.h @@ -1292,8 +1292,8 @@ int burn_track_get_counters(struct burn_track *t, Note: "k" is 1000, not 1024. 1xCD = 176.4 k/s, 1xDVD = 1385 k/s. Fractional speeds should be rounded up. Like 4xCD = 706. @param d The drive to set speed for - @param read Read speed in k/s (0 is max). - @param write Write speed in k/s (0 is max). + @param read Read speed in k/s (0 is max, -1 is min). + @param write Write speed in k/s (0 is max, -1 is min). */ void burn_drive_set_speed(struct burn_drive *d, int read, int write); @@ -1558,10 +1558,12 @@ int burn_drive_get_speedlist(struct burn_drive *d, /* ts A70713 */ /** Look up the fastest speed descriptor which is not faster than the given speed_goal. If it is 0, then the fastest one is chosen among the - descriptors with the highest end_lba. Parameter flag decides wether the - speed goal means write speed or read speed. + descriptors with the highest end_lba. If it is -1 then the slowest speed + descriptor is chosen regardless of end_lba. Parameter flag decides wether + the speed goal means write speed or read speed. @param d Drive to query - @param speed_goal Upper limit for speed, 0=search for maximum speed + @param speed_goal Upper limit for speed, + 0=search for maximum speed , -1 search for minimum speed @param best_descr Result of the search, NULL if no match @param flag Bitfield for control purposes bit0= look for best read speed rather than write speed diff --git a/libburn/trunk/libburn/mmc.c b/libburn/trunk/libburn/mmc.c index 89fcf83d..ee1d87c5 100644 --- a/libburn/trunk/libburn/mmc.c +++ b/libburn/trunk/libburn/mmc.c @@ -1631,36 +1631,17 @@ void mmc_perform_opc(struct burn_drive *d) ts A70712 : That leaner solution does not suffice for my LG GSA-4082B. Meanwhile there is a speed descriptor list anyway. */ -int mmc_set_streaming(struct burn_drive *d, int r_speed, int w_speed) +int mmc_set_streaming(struct burn_drive *d, + int r_speed, int w_speed, int end_lba) { struct buffer buf; struct command c; - int b, end_lba = 0; + int b, eff_end_lba; char msg[160]; unsigned char *pd; - struct burn_speed_descriptor *best_sd = NULL; mmc_function_spy("mmc_set_streaming"); - if (r_speed <= 0 || w_speed <= 0) { - /* ts A70712 : now searching for best speed descriptor */ - if (w_speed > 0 && r_speed <= 0) - burn_drive_get_best_speed(d, r_speed, &best_sd, 1); - else - burn_drive_get_best_speed(d, w_speed, &best_sd, 0); - if (best_sd != NULL) { - w_speed = best_sd->write_speed; - d->nominal_write_speed = w_speed; - r_speed = best_sd->read_speed; - end_lba = best_sd->end_lba; - } else { - if (w_speed <= 0) - w_speed = 0x10000000; /* ~ 2 TB/s */ - if (r_speed <= 0) - r_speed = 0x10000000; /* ~ 2 TB/s */ - } - } - scsi_init_command(&c, MMC_SET_STREAMING, sizeof(MMC_SET_STREAMING)); /* c.oplen = sizeof(MMC_SET_STREAMING); @@ -1676,17 +1657,23 @@ int mmc_set_streaming(struct burn_drive *d, int r_speed, int w_speed) memset(c.page->data, 0, c.page->bytes); pd = c.page->data; - /* Trying to avoid inquiry of available speed descriptors but rather - to allow the drive to use the liberties of Exact==0. - */ pd[0] = 0; /* WRC=0 (Default Rotation Control), RDD=Exact=RA=0 */ + if (w_speed == 0) + w_speed = 0x10000000; /* ~ 2 TB/s */ + else if (w_speed < 0) + w_speed = 177; /* 1x CD */ + if (r_speed == 0) + r_speed = 0x10000000; /* ~ 2 TB/s */ + else if (r_speed < 0) + r_speed = 177; /* 1x CD */ if (end_lba == 0) { /* Default computed from 4.7e9 */ - end_lba = 2294921 - 1; + eff_end_lba = 2294921 - 1; if (d->mdata->max_end_lba > 0) - end_lba = d->mdata->max_end_lba - 1; - } + eff_end_lba = d->mdata->max_end_lba - 1; + } else + eff_end_lba = end_lba; sprintf(msg, "mmc_set_streaming: end_lba=%d , r=%d , w=%d", end_lba, r_speed, w_speed); @@ -1732,26 +1719,46 @@ int mmc_set_streaming(struct burn_drive *d, int r_speed, int w_speed) void mmc_set_speed(struct burn_drive *d, int r, int w) { struct command c; - int ret; + int ret, end_lba = 0; + struct burn_speed_descriptor *best_sd = NULL; mmc_function_spy("mmc_set_speed"); + if (r <= 0 || w <= 0) { + /* ts A70712 : now searching for best speed descriptor */ + if (w > 0 && r <= 0) + burn_drive_get_best_speed(d, r, &best_sd, 1); + else + burn_drive_get_best_speed(d, w, &best_sd, 0); + if (best_sd != NULL) { + w = best_sd->write_speed; + d->nominal_write_speed = w; + r = best_sd->read_speed; + end_lba = best_sd->end_lba; + } + } + /* A70711 */ d->nominal_write_speed = w; /* ts A61221 : try to set DVD speed via command B6h */ if (strstr(d->current_profile_text, "DVD") == d->current_profile_text){ - ret = mmc_set_streaming(d, r, w); + ret = mmc_set_streaming(d, r, w, end_lba); if (ret != 0) return; /* success or really fatal failure */ } /* ts A61112 : MMC standards prescribe FFFFh as max speed. - But libburn.h prescribes 0. */ - if (r<=0 || r>0xffff) + But libburn.h prescribes 0. + ts A70715 : <0 now means minimum speed */ + if (r == 0 || r > 0xffff) r = 0xffff; - if (w<=0 || w>0xffff) + else if (r < 0) + r = 177; /* 1x CD */ + if (w == 0 || w > 0xffff) w = 0xffff; + else if (w < 0) + w = 177; /* 1x CD */ scsi_init_command(&c, MMC_SET_SPEED, sizeof(MMC_SET_SPEED)); /*