Ticket 93: write speeds from mode page 2Ah descriptors

This commit is contained in:
Thomas Schmitt 2006-12-25 11:34:43 +00:00
parent e460bfac24
commit 15ab12493c
4 changed files with 61 additions and 17 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2006.12.24.182410" #define Cdrskin_timestamP "2006.12.25.113534"

View File

@ -226,6 +226,9 @@ int burn_drive_grab(struct burn_drive *d, int le)
/* ts A61118 */ /* ts A61118 */
d->start_unit(d); d->start_unit(d);
/* ts A61225 : after loading the tray, mode page 2Ah can change */
d->getcaps(d);
/* ts A61202 : gave bit1 of le a meaning */ /* ts A61202 : gave bit1 of le a meaning */
sose = d->silent_on_scsi_error; sose = d->silent_on_scsi_error;
if (!le) if (!le)

View File

@ -1152,7 +1152,9 @@ void burn_read_opts_transfer_damaged_blocks(struct burn_read_opts *opts,
void burn_read_opts_set_hardware_error_retries(struct burn_read_opts *opts, void burn_read_opts_set_hardware_error_retries(struct burn_read_opts *opts,
unsigned char hardware_error_retries); unsigned char hardware_error_retries);
/** Gets the maximum write speed for a drive /** Gets the maximum write speed for a drive and eventually loaded media.
The return value might change by the media type of already loaded media,
again by call burn_drive_grab() and again by call burn_disc_read_atip().
@param d Drive to query @param d Drive to query
@return Maximum write speed in K/s @return Maximum write speed in K/s
*/ */
@ -1160,8 +1162,9 @@ int burn_drive_get_write_speed(struct burn_drive *d);
/* ts A61021 */ /* ts A61021 */
/** Gets the minimum write speed for a drive. This might differ from /** Gets the minimum write speed for a drive and eventually loaded media.
burn_drive_get_write_speed() only after burn_disc_read_atip() The return value might change by the media type of already loaded media,
again by call burn_drive_grab() and again by call burn_disc_read_atip().
@param d Drive to query @param d Drive to query
@return Minimum write speed in K/s @return Minimum write speed in K/s
*/ */

View File

@ -132,10 +132,13 @@ void spc_sense_caps(struct burn_drive *d)
{ {
struct buffer buf; struct buffer buf;
struct scsi_mode_data *m; struct scsi_mode_data *m;
int size; int size, page_length, num_write_speeds = 0, i, speed;
unsigned char *page; unsigned char *page;
struct command c; struct command c;
/* ts A61225 : 1 = report about post-MMC-1 speed descriptors */
static int speed_debug = 0;
memcpy(c.opcode, SPC_MODE_SENSE, sizeof(SPC_MODE_SENSE)); memcpy(c.opcode, SPC_MODE_SENSE, sizeof(SPC_MODE_SENSE));
c.retry = 1; c.retry = 1;
c.oplen = sizeof(SPC_MODE_SENSE); c.oplen = sizeof(SPC_MODE_SENSE);
@ -150,6 +153,14 @@ void spc_sense_caps(struct burn_drive *d)
m = d->mdata; m = d->mdata;
page = c.page->data + 8; page = c.page->data + 8;
/* ts A61225 :
Although MODE SENSE indeed belongs to SPC, the returned code page
2Ah is part of MMC-1 to MMC-3. In MMC-1 5.2.3.4. it has 22 bytes,
in MMC-3 6.3.11 there are at least 28 bytes plus a variable length
set of speed descriptors. In MMC-5 E.11 it is declared "legacy".
*/
page_length = page[1];
m->buffer_size = page[12] * 256 + page[13]; m->buffer_size = page[12] * 256 + page[13];
m->dvdram_read = page[2] & 32; m->dvdram_read = page[2] & 32;
m->dvdram_write = page[3] & 32; m->dvdram_write = page[3] & 32;
@ -162,28 +173,55 @@ void spc_sense_caps(struct burn_drive *d)
m->cdr_read = page[2] & 1; m->cdr_read = page[2] & 1;
m->cdr_write = page[3] & 1; m->cdr_write = page[3] & 1;
m->c2_pointers = page[5] & 16;
m->valid = 1;
m->underrun_proof = page[4] & 128;
/* ts A61021 : these fields are marked obsolete in MMC 3 */ /* ts A61021 : these fields are marked obsolete in MMC 3 */
m->max_read_speed = page[8] * 256 + page[9]; m->max_read_speed = page[8] * 256 + page[9];
m->cur_read_speed = page[14] * 256 + page[15]; m->cur_read_speed = page[14] * 256 + page[15];
/* in MMC-3 : see [30-31] and blocks beginning at [32] */
m->max_write_speed = page[18] * 256 + page[19]; m->max_write_speed = page[18] * 256 + page[19];
/* New field to be set by atip */
m->min_write_speed = m->max_write_speed;
/* in MMC-3 : [28-29] */
m->cur_write_speed = page[20] * 256 + page[21]; m->cur_write_speed = page[20] * 256 + page[21];
/* >>> ts A61021 : iterate over all speeds : /* ts A61021 : New field to be set by atip (or following MMC-3 info) */
data[30-31]: number of speed performance descriptor blocks m->min_write_speed = m->max_write_speed;
data[32-35]: block 0 : [+2-3] speed in kbytes/sec
*/
/* ts A61225 : end of MMC-1 , begin of MMC-3 */
if (page_length < 32) /* no write speed descriptors ? */
return;
m->cur_write_speed = page[28] * 256 + page[29];
if (speed_debug)
fprintf(stderr, "LIBBURN_DEBUG: cur_write_speed = %d\n",
m->cur_write_speed);
num_write_speeds = page[30] * 256 + page[31];
m->max_write_speed = m->min_write_speed = m->cur_write_speed;
for (i = 0; i < num_write_speeds; i++) {
speed = page[32 + 4*i + 2] * 256 + page[32 + 4*i + 3];
if (speed_debug)
fprintf(stderr,
"LIBBURN_DEBUG: write speed #%d = %d kB/s (rc %d)\n",
i, speed, page[32 + 4*i +1] & 7);
if (speed > m->max_write_speed)
m->max_write_speed = speed;
if (speed < m->min_write_speed)
m->min_write_speed = speed;
}
if (speed_debug)
fprintf(stderr,
"LIBBURN_DEBUG: min_write_speed = %d , max_write_speed = %d\n",
m->min_write_speed, m->max_write_speed);
m->c2_pointers = page[5] & 16;
m->valid = 1;
m->underrun_proof = page[4] & 128;
} }
void spc_sense_error_params(struct burn_drive *d) void spc_sense_error_params(struct burn_drive *d)
{ {
struct buffer buf; struct buffer buf;