2006-10-30 05:32:33 +00:00
|
|
|
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
|
|
|
|
|
|
|
|
/* scsi block commands */
|
|
|
|
|
|
|
|
#include <string.h>
|
2007-03-15 19:50:57 +00:00
|
|
|
#include <unistd.h>
|
2006-10-30 05:32:33 +00:00
|
|
|
|
|
|
|
#include "transport.h"
|
|
|
|
#include "sbc.h"
|
2007-03-15 19:50:57 +00:00
|
|
|
#include "spc.h"
|
2006-10-30 05:32:33 +00:00
|
|
|
#include "options.h"
|
|
|
|
|
2007-09-12 10:45:34 +00:00
|
|
|
|
|
|
|
/* ts A70910
|
|
|
|
debug: for tracing calls which might use open drive fds
|
|
|
|
or for catching SCSI usage of emulated drives. */
|
|
|
|
int mmc_function_spy(struct burn_drive *d, char * text);
|
|
|
|
|
|
|
|
|
2006-10-30 05:32:33 +00:00
|
|
|
/* spc command set */
|
2007-05-21 18:57:09 +00:00
|
|
|
static unsigned char SBC_LOAD[] = { 0x1b, 0, 0, 0, 3, 0 };
|
|
|
|
static unsigned char SBC_UNLOAD[] = { 0x1b, 0, 0, 0, 2, 0 };
|
|
|
|
static unsigned char SBC_START_UNIT[] = { 0x1b, 0, 0, 0, 1, 0 };
|
2006-10-30 05:32:33 +00:00
|
|
|
|
|
|
|
void sbc_load(struct burn_drive *d)
|
|
|
|
{
|
|
|
|
struct command c;
|
|
|
|
|
2007-09-12 10:45:34 +00:00
|
|
|
if (mmc_function_spy(d, "load") <= 0)
|
|
|
|
return;
|
|
|
|
|
2007-05-21 18:57:09 +00:00
|
|
|
scsi_init_command(&c, SBC_LOAD, sizeof(SBC_LOAD));
|
|
|
|
/*
|
2006-10-30 05:32:33 +00:00
|
|
|
memcpy(c.opcode, SBC_LOAD, sizeof(SBC_LOAD));
|
|
|
|
c.oplen = sizeof(SBC_LOAD);
|
|
|
|
c.page = NULL;
|
2007-05-21 18:57:09 +00:00
|
|
|
*/
|
|
|
|
c.retry = 1;
|
2007-09-18 20:03:20 +00:00
|
|
|
|
2007-09-21 12:04:27 +00:00
|
|
|
/* ts A70921 : Had to revoke Immed because of LG GSA-4082B */
|
2007-09-22 19:30:45 +00:00
|
|
|
/* c.opcode[1] |= 1; / * ts A70918 : Immed */
|
2007-09-18 20:03:20 +00:00
|
|
|
|
2007-05-21 18:57:09 +00:00
|
|
|
c.dir = NO_TRANSFER;
|
2006-10-30 05:32:33 +00:00
|
|
|
d->issue_command(d, &c);
|
2007-09-18 20:03:20 +00:00
|
|
|
if (c.error)
|
|
|
|
return;
|
2007-09-23 16:35:44 +00:00
|
|
|
/* ts A70923 : Needed regardless of Immed bit. Was once 1 minute, now
|
2007-09-18 20:15:25 +00:00
|
|
|
5 minutes for loading. If this does not suffice then other commands
|
2007-09-18 20:03:20 +00:00
|
|
|
shall fail righteously. */
|
2007-09-23 16:35:44 +00:00
|
|
|
spc_wait_unit_attention(d, 300, "waiting after START UNIT (+ LOAD)",0);
|
2006-10-30 05:32:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void sbc_eject(struct burn_drive *d)
|
|
|
|
{
|
|
|
|
struct command c;
|
|
|
|
|
2007-09-12 10:45:34 +00:00
|
|
|
if (mmc_function_spy(d, "eject") <= 0)
|
|
|
|
return;
|
|
|
|
|
2007-05-21 18:57:09 +00:00
|
|
|
scsi_init_command(&c, SBC_UNLOAD, sizeof(SBC_UNLOAD));
|
|
|
|
/*
|
2006-10-30 05:32:33 +00:00
|
|
|
memcpy(c.opcode, SBC_UNLOAD, sizeof(SBC_UNLOAD));
|
|
|
|
c.oplen = sizeof(SBC_UNLOAD);
|
|
|
|
c.page = NULL;
|
2007-05-21 18:57:09 +00:00
|
|
|
*/
|
2007-09-18 20:03:20 +00:00
|
|
|
|
|
|
|
c.opcode[1] |= 1; /* ts A70918 : Immed */
|
|
|
|
|
2007-05-21 18:57:09 +00:00
|
|
|
c.page = NULL;
|
2006-10-30 05:32:33 +00:00
|
|
|
c.dir = NO_TRANSFER;
|
|
|
|
d->issue_command(d, &c);
|
2007-09-18 20:03:20 +00:00
|
|
|
if (c.error)
|
|
|
|
return;
|
2007-09-18 20:15:25 +00:00
|
|
|
/* ts A70918 : Wait long. A late eject could surprise or hurt user. */
|
2007-09-18 20:03:20 +00:00
|
|
|
spc_wait_unit_attention(d, 1800, "STOP UNIT (+ EJECT)", 0);
|
2006-10-30 05:32:33 +00:00
|
|
|
}
|
|
|
|
|
2006-11-18 19:49:18 +00:00
|
|
|
/* ts A61118 : is it necessary to tell the drive to get ready for use ? */
|
|
|
|
int sbc_start_unit(struct burn_drive *d)
|
|
|
|
{
|
|
|
|
struct command c;
|
|
|
|
|
2007-09-12 10:45:34 +00:00
|
|
|
if (mmc_function_spy(d, "start_unit") <= 0)
|
|
|
|
return 0;
|
|
|
|
|
2007-05-21 18:57:09 +00:00
|
|
|
scsi_init_command(&c, SBC_START_UNIT, sizeof(SBC_START_UNIT));
|
|
|
|
/*
|
2006-11-18 19:49:18 +00:00
|
|
|
memcpy(c.opcode, SBC_START_UNIT, sizeof(SBC_START_UNIT));
|
|
|
|
c.oplen = sizeof(SBC_START_UNIT);
|
|
|
|
c.page = NULL;
|
2007-05-21 18:57:09 +00:00
|
|
|
*/
|
|
|
|
c.retry = 1;
|
2007-09-18 20:03:20 +00:00
|
|
|
|
|
|
|
c.opcode[1] |= 1; /* ts A70918 : Immed */
|
|
|
|
|
2007-05-21 18:57:09 +00:00
|
|
|
c.dir = NO_TRANSFER;
|
2006-11-18 19:49:18 +00:00
|
|
|
d->issue_command(d, &c);
|
2007-09-18 20:03:20 +00:00
|
|
|
if (c.error)
|
|
|
|
return 0;
|
2007-09-18 20:15:25 +00:00
|
|
|
/* ts A70918 : now asynchronous */
|
2007-09-18 20:03:20 +00:00
|
|
|
return spc_wait_unit_attention(d, 1800, "START UNIT", 0);
|
2006-11-18 19:49:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-30 05:32:33 +00:00
|
|
|
/* ts A61021 : the sbc specific part of sg.c:enumerate_common()
|
|
|
|
*/
|
|
|
|
int sbc_setup_drive(struct burn_drive *d)
|
|
|
|
{
|
|
|
|
d->eject = sbc_eject;
|
|
|
|
d->load = sbc_load;
|
2006-11-18 19:49:18 +00:00
|
|
|
d->start_unit = sbc_start_unit;
|
2006-10-30 05:32:33 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|