Implemented minimum speed in burn_drive_set_speed()

This commit is contained in:
Thomas Schmitt 2007-07-17 08:57:24 +00:00
parent 1087d402f2
commit bdadae6ba5
5 changed files with 65 additions and 46 deletions

View File

@ -2962,9 +2962,13 @@ int Cdrskin_adjust_speed(struct CdrskiN *skin, int flag)
if(skin->x_speed<0) if(skin->x_speed<0)
k_speed= 0; /* libburn.h promises 0 to be max speed. */ 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; k_speed= Cdrskin_libburn_speed_factoR+Cdrskin_libburn_speed_addoN;
else #endif
} else
k_speed= skin->x_speed*Cdrskin_libburn_speed_factoR + k_speed= skin->x_speed*Cdrskin_libburn_speed_factoR +
Cdrskin_libburn_speed_addoN; Cdrskin_libburn_speed_addoN;

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2007.07.14.112326" #define Cdrskin_timestamP "2007.07.17.085823"

View File

@ -1623,17 +1623,23 @@ int burn_drive_get_best_speed(struct burn_drive *d, int speed_goal,
if (flag & 2) if (flag & 2)
source = -1; source = -1;
if (speed_goal < 0)
best_speed = 2000000000;
*best_descr = NULL; *best_descr = NULL;
for (sd = d->mdata->speed_descriptors; sd != NULL; sd = sd->next) { 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) if (flag & 1)
speed = sd->read_speed; speed = sd->read_speed;
else else
speed = sd->write_speed; 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) || if ((source == 2 && sd->end_lba > best_lba) ||
((source !=2 || sd->end_lba == best_lba) && ((source !=2 || sd->end_lba == best_lba) &&
speed > best_speed)) { speed > best_speed)) {

View File

@ -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. Note: "k" is 1000, not 1024. 1xCD = 176.4 k/s, 1xDVD = 1385 k/s.
Fractional speeds should be rounded up. Like 4xCD = 706. Fractional speeds should be rounded up. Like 4xCD = 706.
@param d The drive to set speed for @param d The drive to set speed for
@param read Read 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). @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); 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 */ /* ts A70713 */
/** Look up the fastest speed descriptor which is not faster than the given /** 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 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 descriptors with the highest end_lba. If it is -1 then the slowest speed
speed goal means write speed or read 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 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 best_descr Result of the search, NULL if no match
@param flag Bitfield for control purposes @param flag Bitfield for control purposes
bit0= look for best read speed rather than write speed bit0= look for best read speed rather than write speed

View File

@ -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. ts A70712 : That leaner solution does not suffice for my LG GSA-4082B.
Meanwhile there is a speed descriptor list anyway. 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 buffer buf;
struct command c; struct command c;
int b, end_lba = 0; int b, eff_end_lba;
char msg[160]; char msg[160];
unsigned char *pd; unsigned char *pd;
struct burn_speed_descriptor *best_sd = NULL;
mmc_function_spy("mmc_set_streaming"); 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)); scsi_init_command(&c, MMC_SET_STREAMING, sizeof(MMC_SET_STREAMING));
/* /*
c.oplen = 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); memset(c.page->data, 0, c.page->bytes);
pd = c.page->data; 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 */ 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) { if (end_lba == 0) {
/* Default computed from 4.7e9 */ /* Default computed from 4.7e9 */
end_lba = 2294921 - 1; eff_end_lba = 2294921 - 1;
if (d->mdata->max_end_lba > 0) 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", sprintf(msg, "mmc_set_streaming: end_lba=%d , r=%d , w=%d",
end_lba, r_speed, w_speed); 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) void mmc_set_speed(struct burn_drive *d, int r, int w)
{ {
struct command c; struct command c;
int ret; int ret, end_lba = 0;
struct burn_speed_descriptor *best_sd = NULL;
mmc_function_spy("mmc_set_speed"); 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 */ /* A70711 */
d->nominal_write_speed = w; d->nominal_write_speed = w;
/* ts A61221 : try to set DVD speed via command B6h */ /* ts A61221 : try to set DVD speed via command B6h */
if (strstr(d->current_profile_text, "DVD") == d->current_profile_text){ 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) if (ret != 0)
return; /* success or really fatal failure */ return; /* success or really fatal failure */
} }
/* ts A61112 : MMC standards prescribe FFFFh as max speed. /* ts A61112 : MMC standards prescribe FFFFh as max speed.
But libburn.h prescribes 0. */ But libburn.h prescribes 0.
if (r<=0 || r>0xffff) ts A70715 : <0 now means minimum speed */
if (r == 0 || r > 0xffff)
r = 0xffff; r = 0xffff;
if (w<=0 || w>0xffff) else if (r < 0)
r = 177; /* 1x CD */
if (w == 0 || w > 0xffff)
w = 0xffff; w = 0xffff;
else if (w < 0)
w = 177; /* 1x CD */
scsi_init_command(&c, MMC_SET_SPEED, sizeof(MMC_SET_SPEED)); scsi_init_command(&c, MMC_SET_SPEED, sizeof(MMC_SET_SPEED));
/* /*