Consolidated several local struct command to a new member of struct burn_drive
This commit is contained in:
parent
99af1501fc
commit
c96745af15
@ -1 +1 @@
|
||||
#define Cdrskin_timestamP "2011.06.07.084343"
|
||||
#define Cdrskin_timestamP "2011.06.07.143930"
|
||||
|
909
libburn/mmc.c
909
libburn/mmc.c
File diff suppressed because it is too large
Load Diff
@ -54,20 +54,21 @@ static unsigned char SBC_STOP_UNIT[] = { 0x1b, 0, 0, 0, 0, 0 };
|
||||
|
||||
void sbc_load(struct burn_drive *d)
|
||||
{
|
||||
struct command c;
|
||||
struct command *c;
|
||||
|
||||
c = &(d->casual_command);
|
||||
if (mmc_function_spy(d, "load") <= 0)
|
||||
return;
|
||||
|
||||
scsi_init_command(&c, SBC_LOAD, sizeof(SBC_LOAD));
|
||||
c.retry = 1;
|
||||
scsi_init_command(c, SBC_LOAD, sizeof(SBC_LOAD));
|
||||
c->retry = 1;
|
||||
|
||||
/* ts A70921 : Had to revoke Immed because of LG GSA-4082B */
|
||||
/* c.opcode[1] |= 1; / * ts A70918 : Immed */
|
||||
/* c->opcode[1] |= 1; / * ts A70918 : Immed */
|
||||
|
||||
c.dir = NO_TRANSFER;
|
||||
d->issue_command(d, &c);
|
||||
if (c.error)
|
||||
c->dir = NO_TRANSFER;
|
||||
d->issue_command(d, c);
|
||||
if (c->error)
|
||||
return;
|
||||
/* ts A70923 : Needed regardless of Immed bit. Was once 1 minute, now
|
||||
5 minutes for loading. If this does not suffice then other commands
|
||||
@ -77,20 +78,21 @@ void sbc_load(struct burn_drive *d)
|
||||
|
||||
void sbc_eject(struct burn_drive *d)
|
||||
{
|
||||
struct command c;
|
||||
struct command *c;
|
||||
|
||||
c = &(d->casual_command);
|
||||
if (mmc_function_spy(d, "eject") <= 0)
|
||||
return;
|
||||
|
||||
scsi_init_command(&c, SBC_UNLOAD, sizeof(SBC_UNLOAD));
|
||||
/* c.opcode[1] |= 1; / * ts A70918 : Immed , ts B00109 : revoked */
|
||||
c.page = NULL;
|
||||
c.dir = NO_TRANSFER;
|
||||
d->issue_command(d, &c);
|
||||
scsi_init_command(c, SBC_UNLOAD, sizeof(SBC_UNLOAD));
|
||||
/* c->opcode[1] |= 1; / * ts A70918 : Immed , ts B00109 : revoked */
|
||||
c->page = NULL;
|
||||
c->dir = NO_TRANSFER;
|
||||
d->issue_command(d, c);
|
||||
/* ts A70918 : Wait long. A late eject could surprise or hurt user.
|
||||
ts B00109 : Asynchronous eject revoked, as one cannot reliably
|
||||
distinguish out from unready.
|
||||
if (c.error)
|
||||
if (c->error)
|
||||
return;
|
||||
spc_wait_unit_attention(d, 1800, "STOP UNIT (+ EJECT)", 0);
|
||||
*/
|
||||
@ -102,18 +104,19 @@ void sbc_eject(struct burn_drive *d)
|
||||
*/
|
||||
int sbc_start_unit_flag(struct burn_drive *d, int flag)
|
||||
{
|
||||
struct command c;
|
||||
struct command *c;
|
||||
int ret;
|
||||
|
||||
c = &(d->casual_command);
|
||||
if (mmc_function_spy(d, "start_unit") <= 0)
|
||||
return 0;
|
||||
|
||||
scsi_init_command(&c, SBC_START_UNIT, sizeof(SBC_START_UNIT));
|
||||
c.retry = 1;
|
||||
c.opcode[1] |= (flag & 1); /* ts A70918 : Immed */
|
||||
c.dir = NO_TRANSFER;
|
||||
d->issue_command(d, &c);
|
||||
if (c.error)
|
||||
scsi_init_command(c, SBC_START_UNIT, sizeof(SBC_START_UNIT));
|
||||
c->retry = 1;
|
||||
c->opcode[1] |= (flag & 1); /* ts A70918 : Immed */
|
||||
c->dir = NO_TRANSFER;
|
||||
d->issue_command(d, c);
|
||||
if (c->error)
|
||||
return 0;
|
||||
if (!(flag & 1))
|
||||
return 1;
|
||||
@ -144,18 +147,19 @@ int sbc_start_unit(struct burn_drive *d)
|
||||
/* ts A90824 : Trying to reduce drive noise */
|
||||
int sbc_stop_unit(struct burn_drive *d)
|
||||
{
|
||||
struct command c;
|
||||
struct command *c;
|
||||
int ret;
|
||||
|
||||
c = &(d->casual_command);
|
||||
if (mmc_function_spy(d, "stop_unit") <= 0)
|
||||
return 0;
|
||||
|
||||
scsi_init_command(&c, SBC_STOP_UNIT, sizeof(SBC_STOP_UNIT));
|
||||
c.retry = 0;
|
||||
c.opcode[1] |= 1; /* Immed */
|
||||
c.dir = NO_TRANSFER;
|
||||
d->issue_command(d, &c);
|
||||
if (c.error)
|
||||
scsi_init_command(c, SBC_STOP_UNIT, sizeof(SBC_STOP_UNIT));
|
||||
c->retry = 0;
|
||||
c->opcode[1] |= 1; /* Immed */
|
||||
c->dir = NO_TRANSFER;
|
||||
d->issue_command(d, c);
|
||||
if (c->error)
|
||||
return 0;
|
||||
ret = spc_wait_unit_attention(d, 1800, "STOP UNIT", 0);
|
||||
d->is_stopped = 1;
|
||||
|
@ -64,6 +64,7 @@ int scsi_init_command(struct command *c, unsigned char *opcode, int oplen)
|
||||
{
|
||||
if (oplen > 16)
|
||||
return 0;
|
||||
memset(c, 0, sizeof(struct command));
|
||||
memcpy(c->opcode, opcode, oplen);
|
||||
c->oplen = oplen;
|
||||
c->dir = NO_TRANSFER;
|
||||
@ -102,25 +103,21 @@ int spc_decode_sense(unsigned char *sense, int senselen,
|
||||
|
||||
int spc_test_unit_ready_r(struct burn_drive *d, int *key, int *asc, int *ascq)
|
||||
{
|
||||
struct command *c = NULL;
|
||||
int ret;
|
||||
struct command *c;
|
||||
|
||||
c = &(d->casual_command);
|
||||
if (mmc_function_spy(d, "test_unit_ready") <= 0)
|
||||
{ret = 0; goto ex;}
|
||||
return 0;
|
||||
|
||||
BURN_ALLOC_MEM(c, struct command, 1);
|
||||
scsi_init_command(c, SPC_TEST_UNIT_READY,sizeof(SPC_TEST_UNIT_READY));
|
||||
c->retry = 0;
|
||||
c->dir = NO_TRANSFER;
|
||||
d->issue_command(d, c);
|
||||
if (c->error) {
|
||||
spc_decode_sense(c->sense, 0, key, asc, ascq);
|
||||
{ret = (key == 0); goto ex;}
|
||||
return (key == 0);
|
||||
}
|
||||
ret = 1;
|
||||
ex:;
|
||||
BURN_FREE_MEM(c);
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -233,13 +230,12 @@ ex:;
|
||||
|
||||
void spc_request_sense(struct burn_drive *d, struct buffer *buf)
|
||||
{
|
||||
struct command *c = NULL;
|
||||
int ret;
|
||||
struct command *c;
|
||||
|
||||
c = &(d->casual_command);
|
||||
if (mmc_function_spy(d, "request_sense") <= 0)
|
||||
goto ex;
|
||||
return;
|
||||
|
||||
BURN_ALLOC_MEM(c, struct command, 1);
|
||||
scsi_init_command(c, SPC_REQUEST_SENSE, sizeof(SPC_REQUEST_SENSE));
|
||||
c->retry = 0;
|
||||
c->dxfer_len= c->opcode[4];
|
||||
@ -249,8 +245,6 @@ void spc_request_sense(struct burn_drive *d, struct buffer *buf)
|
||||
c->page->bytes = 0;
|
||||
c->dir = FROM_DRIVE;
|
||||
d->issue_command(d, c);
|
||||
ex:;
|
||||
BURN_FREE_MEM(c);
|
||||
}
|
||||
|
||||
int spc_get_erase_progress(struct burn_drive *d)
|
||||
@ -309,42 +303,35 @@ ex:;
|
||||
|
||||
void spc_prevent(struct burn_drive *d)
|
||||
{
|
||||
struct command *c = NULL;
|
||||
int ret;
|
||||
struct command *c;
|
||||
|
||||
c = &(d->casual_command);
|
||||
if (mmc_function_spy(d, "prevent") <= 0)
|
||||
return;
|
||||
BURN_ALLOC_MEM(c, struct command, 1);
|
||||
|
||||
scsi_init_command(c, SPC_PREVENT, sizeof(SPC_PREVENT));
|
||||
c->retry = 1;
|
||||
c->dir = NO_TRANSFER;
|
||||
d->issue_command(d, c);
|
||||
|
||||
|
||||
#ifdef Libburn_pioneer_dvr_216d_get_evenT
|
||||
mmc_get_event(d);
|
||||
#endif
|
||||
|
||||
ex:;
|
||||
BURN_FREE_MEM(c);
|
||||
}
|
||||
|
||||
void spc_allow(struct burn_drive *d)
|
||||
{
|
||||
struct command *c = NULL;
|
||||
int ret;
|
||||
struct command *c;
|
||||
|
||||
c = &(d->casual_command);
|
||||
if (mmc_function_spy(d, "allow") <= 0)
|
||||
goto ex;
|
||||
return;
|
||||
|
||||
BURN_ALLOC_MEM(c, struct command, 1);
|
||||
scsi_init_command(c, SPC_ALLOW, sizeof(SPC_ALLOW));
|
||||
c->retry = 1;
|
||||
c->dir = NO_TRANSFER;
|
||||
d->issue_command(d, c);
|
||||
ex:;
|
||||
BURN_FREE_MEM(c);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -301,6 +301,16 @@ struct burn_drive
|
||||
struct buffer *buffer;
|
||||
struct burn_progress progress;
|
||||
|
||||
/* To be used by mmc.c, sbc.c, spc.c for SCSI commands where the struct
|
||||
content surely does not have to persist while another command gets
|
||||
composed and executed.
|
||||
(Inherently, sending SCSI commands to the same drive cannot be
|
||||
thread-safe. But there are functions which send SCSI commands
|
||||
and also call other such functions. These shall use own allocated
|
||||
command structs and not this struct here.)
|
||||
*/
|
||||
struct command casual_command;
|
||||
|
||||
/* ts A70711 : keeping an eye on the drive buffer */
|
||||
off_t pessimistic_buffer_free;
|
||||
int pbf_altered;
|
||||
|
Loading…
Reference in New Issue
Block a user