2006-08-15 20:37:04 +00:00
|
|
|
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
|
|
|
|
|
|
|
|
#ifndef __TRANSPORT
|
|
|
|
#define __TRANSPORT
|
|
|
|
|
|
|
|
#include "libburn.h"
|
2006-11-16 11:17:55 +00:00
|
|
|
#include "os.h"
|
2006-08-15 20:37:04 +00:00
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
/* sg data structures */
|
|
|
|
#include <sys/types.h>
|
2006-10-13 10:22:21 +00:00
|
|
|
|
|
|
|
|
2006-11-16 11:17:55 +00:00
|
|
|
/* see os.h for name of particular os-*.h where this is defined */
|
|
|
|
#define BUFFER_SIZE BURN_OS_TRANSPORT_BUFFER_SIZE
|
2006-10-13 10:22:21 +00:00
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
|
|
|
|
enum transfer_direction
|
|
|
|
{ TO_DRIVE, FROM_DRIVE, NO_TRANSFER };
|
|
|
|
|
|
|
|
/* end of sg data structures */
|
|
|
|
|
|
|
|
/* generic 'drive' data structures */
|
|
|
|
|
|
|
|
struct cue_sheet
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
unsigned char *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct params
|
|
|
|
{
|
|
|
|
int speed;
|
|
|
|
int retries;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct buffer
|
|
|
|
{
|
2006-12-20 11:20:08 +00:00
|
|
|
/* ts A61219:
|
|
|
|
Added 4096 bytes reserve against possible buffer overflows.
|
|
|
|
(Changed in sector.c buffer flush test from >= to > BUFFER_SIZE .
|
|
|
|
This can at most cause a 1 sector overlap. Sometimes an offset
|
|
|
|
of 16 byte is applied to the output data (in some RAW mode). ) */
|
|
|
|
unsigned char data[BUFFER_SIZE + 4096];
|
2006-08-15 20:37:04 +00:00
|
|
|
int sectors;
|
|
|
|
int bytes;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct command
|
|
|
|
{
|
|
|
|
unsigned char opcode[16];
|
|
|
|
int oplen;
|
|
|
|
int dir;
|
2007-05-21 18:57:09 +00:00
|
|
|
int dxfer_len;
|
2006-08-15 20:37:04 +00:00
|
|
|
unsigned char sense[128];
|
|
|
|
int error;
|
|
|
|
int retry;
|
|
|
|
struct buffer *page;
|
|
|
|
};
|
|
|
|
|
2006-10-12 17:35:06 +00:00
|
|
|
struct burn_scsi_inquiry_data
|
2006-08-15 20:37:04 +00:00
|
|
|
{
|
|
|
|
char vendor[9];
|
|
|
|
char product[17];
|
|
|
|
char revision[5];
|
|
|
|
int valid;
|
|
|
|
};
|
|
|
|
|
2006-12-26 17:07:53 +00:00
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
struct scsi_mode_data
|
|
|
|
{
|
|
|
|
int buffer_size;
|
|
|
|
int dvdram_read;
|
|
|
|
int dvdram_write;
|
|
|
|
int dvdr_read;
|
|
|
|
int dvdr_write;
|
|
|
|
int dvdrom_read;
|
|
|
|
int cdrw_read;
|
|
|
|
int cdrw_write;
|
|
|
|
int cdr_read;
|
|
|
|
int cdr_write;
|
|
|
|
int simulate;
|
|
|
|
int max_read_speed;
|
|
|
|
int max_write_speed;
|
2006-10-21 10:34:15 +00:00
|
|
|
|
|
|
|
/* ts A61021 */
|
|
|
|
int min_write_speed;
|
|
|
|
|
2006-12-25 19:07:43 +00:00
|
|
|
/* ts A61225 : Results from ACh GET PERFORMANCE, Type 03h
|
|
|
|
Speed values go into *_*_speed */
|
|
|
|
int min_end_lba;
|
|
|
|
int max_end_lba;
|
2006-12-26 17:07:53 +00:00
|
|
|
struct burn_speed_descriptor *speed_descriptors;
|
2006-12-25 19:07:43 +00:00
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
int cur_read_speed;
|
|
|
|
int cur_write_speed;
|
|
|
|
int retry_page_length;
|
|
|
|
int retry_page_valid;
|
|
|
|
int write_page_length;
|
|
|
|
int write_page_valid;
|
|
|
|
int c2_pointers;
|
|
|
|
int valid;
|
|
|
|
int underrun_proof;
|
|
|
|
};
|
|
|
|
|
2006-09-04 19:11:04 +00:00
|
|
|
|
2007-01-13 21:16:04 +00:00
|
|
|
/* ts A70112 : represents a single Formattable Capacity Descriptor as of
|
|
|
|
mmc5r03c.pdf 6.24.3.3 . There can at most be 32 of them. */
|
|
|
|
struct burn_format_descr {
|
|
|
|
/* format type: e.g 0x00 is "Full", 0x15 is "Quick" */
|
|
|
|
int type;
|
|
|
|
|
|
|
|
/* the size in bytes derived from Number of Blocks */
|
|
|
|
off_t size;
|
|
|
|
|
|
|
|
/* the Type Dependent Parameter (usually the write alignment size) */
|
2007-08-17 08:19:30 +00:00
|
|
|
unsigned int tdp;
|
2007-01-13 21:16:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-09-04 19:11:04 +00:00
|
|
|
/** Gets initialized in enumerate_common() and burn_drive_register() */
|
2006-08-15 20:37:04 +00:00
|
|
|
struct burn_drive
|
|
|
|
{
|
2007-09-24 13:54:52 +00:00
|
|
|
/* ts A70902:
|
|
|
|
0=null-emulation
|
|
|
|
1=MMC drive ,
|
|
|
|
2=stdio random read-write
|
|
|
|
3=stdio sequential write-only
|
|
|
|
*/
|
2007-09-04 22:50:04 +00:00
|
|
|
int drive_role;
|
|
|
|
|
2006-10-05 14:21:34 +00:00
|
|
|
int bus_no;
|
2006-08-15 20:37:04 +00:00
|
|
|
int host;
|
|
|
|
int id;
|
|
|
|
int channel;
|
|
|
|
int lun;
|
|
|
|
char *devname;
|
2006-10-13 10:22:21 +00:00
|
|
|
|
2007-03-03 14:09:46 +00:00
|
|
|
/* ts A70302: mmc5r03c.pdf 5.3.2 Physical Interface Standard */
|
|
|
|
int phys_if_std; /* 1=SCSI, 2=ATAPI, 3,4,6=FireWire, 7=SATA, 8=USB */
|
|
|
|
char phys_if_name[80]; /* MMC-5 5.3.2 table 91 , e.g. "SCSI Family" */
|
2006-08-15 20:37:04 +00:00
|
|
|
|
2006-11-16 11:17:55 +00:00
|
|
|
/* see os.h for name of particular os-*.h where this is defined */
|
|
|
|
BURN_OS_TRANSPORT_DRIVE_ELEMENTS
|
|
|
|
|
2006-09-27 12:04:53 +00:00
|
|
|
|
2006-09-04 19:11:04 +00:00
|
|
|
/* ts A60904 : ticket 62, contribution by elmom */
|
|
|
|
/**
|
|
|
|
Tells the index in scanned burn_drive_info array.
|
|
|
|
-1 if fallen victim to burn_drive_info_forget()
|
|
|
|
*/
|
|
|
|
int global_index;
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
pthread_mutex_t access_lock;
|
|
|
|
|
|
|
|
enum burn_disc_status status;
|
|
|
|
int erasable;
|
2006-12-01 21:38:34 +00:00
|
|
|
|
|
|
|
/* ts A61201 from 46h GET CONFIGURATION */
|
|
|
|
int current_profile;
|
|
|
|
char current_profile_text[80];
|
|
|
|
int current_is_cd_profile;
|
2006-12-20 11:20:08 +00:00
|
|
|
int current_is_supported_profile;
|
|
|
|
|
2007-01-29 17:57:31 +00:00
|
|
|
/* ts A70128 : MMC-to-MMC feature info from 46h for DVD-RW.
|
|
|
|
Quite internal. Regard as opaque :)
|
|
|
|
*/
|
|
|
|
/* 1 = incremental recording available, 0 = not available */
|
|
|
|
int current_has_feat21h;
|
|
|
|
|
|
|
|
/* Link Size item number 0 from feature 0021h descriptor */
|
|
|
|
int current_feat21h_link_size;
|
|
|
|
|
|
|
|
/* Flags from feature 002Fh feature descriptor mmc5r03c.pdf 5.3.25 :
|
2007-02-05 13:28:57 +00:00
|
|
|
bit1= DVD-RW supported
|
|
|
|
bit2= Test Write available
|
|
|
|
bit3= DVD-R DL supported
|
|
|
|
bit6= Buffer Under-run Free recording available (page 05h BUFE)
|
|
|
|
Value -1 indicates that no 002Fh was current in the features list.
|
2007-01-29 17:57:31 +00:00
|
|
|
*/
|
|
|
|
int current_feat2fh_byte4;
|
|
|
|
|
2007-10-03 11:24:41 +00:00
|
|
|
/* ts A70114 : whether a DVD-RW media holds an incomplete session
|
2007-01-14 13:41:19 +00:00
|
|
|
(which could need closing after write) */
|
2007-01-18 21:18:03 +00:00
|
|
|
int needs_close_session;
|
2007-10-03 11:24:41 +00:00
|
|
|
/* ts A71003 : whether a random write operation was done and no
|
|
|
|
synchronize chache has happened yet */
|
|
|
|
int needs_sync_cache;
|
2007-01-14 13:41:19 +00:00
|
|
|
|
2008-04-12 16:42:45 +00:00
|
|
|
/* ts A80412 : whether to use WRITE12 with Streaming bit set
|
|
|
|
rather than WRITE10. Speeds up DVD-RAM. Might help
|
|
|
|
with BD-RE */
|
|
|
|
int do_stream_recording;
|
|
|
|
|
2007-01-29 17:57:31 +00:00
|
|
|
/* ts A61218 from 51h READ DISC INFORMATION */
|
2006-12-20 11:20:08 +00:00
|
|
|
int bg_format_status; /* 0=needs format start, 1=needs format restart*/
|
|
|
|
|
2007-01-09 21:06:55 +00:00
|
|
|
/* ts A70108 from 23h READ FORMAT CAPACITY mmc5r03c.pdf 6.24 */
|
|
|
|
int format_descr_type; /* 1=unformatted, 2=formatted, 3=unclear */
|
|
|
|
off_t format_curr_max_size; /* meaning depends on format_descr_type */
|
2007-08-09 13:30:52 +00:00
|
|
|
unsigned int format_curr_blsas; /* dito */
|
2007-01-09 21:06:55 +00:00
|
|
|
int best_format_type;
|
|
|
|
off_t best_format_size;
|
2006-12-01 21:38:34 +00:00
|
|
|
|
2007-01-13 21:16:04 +00:00
|
|
|
/* The complete list of format descriptors as read with 23h */
|
|
|
|
int num_format_descr;
|
|
|
|
struct burn_format_descr format_descriptors[32];
|
|
|
|
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
volatile int released;
|
2006-11-06 19:58:24 +00:00
|
|
|
|
|
|
|
/* ts A61106 */
|
|
|
|
int silent_on_scsi_error;
|
|
|
|
|
2007-09-12 10:45:34 +00:00
|
|
|
int stdio_fd;
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
int nwa; /* next writeable address */
|
|
|
|
int alba; /* absolute lba */
|
|
|
|
int rlba; /* relative lba in section */
|
|
|
|
int start_lba;
|
|
|
|
int end_lba;
|
2007-01-29 17:57:31 +00:00
|
|
|
|
2007-02-01 16:15:09 +00:00
|
|
|
|
|
|
|
/* ts A70131 : from 51h READ DISC INFORMATION Number of Sessions (-1)*/
|
|
|
|
int complete_sessions;
|
2007-01-29 17:57:31 +00:00
|
|
|
/* ts A70129 :
|
|
|
|
from 51h READ DISC INFORMATION Last Track Number in Last Session */
|
|
|
|
int last_track_no;
|
2007-02-13 14:37:25 +00:00
|
|
|
/* ts A70212 : from various sources : free space on media (in bytes)
|
|
|
|
With CD this might change after particular write
|
|
|
|
parameters have been set and nwa has been inquired.
|
|
|
|
(e.g. by d->send_write_parameters() ; d->get_nwa()).
|
|
|
|
*/
|
|
|
|
off_t media_capacity_remaining;
|
2007-02-15 20:18:07 +00:00
|
|
|
/* ts A70215 : if > 0 : first lba on media that is too high for write*/
|
|
|
|
int media_lba_limit;
|
2007-01-29 17:57:31 +00:00
|
|
|
|
2007-02-01 16:15:09 +00:00
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
int toc_temp;
|
|
|
|
struct burn_disc *disc; /* disc structure */
|
|
|
|
int block_types[4];
|
|
|
|
struct buffer *buffer;
|
|
|
|
struct burn_progress progress;
|
|
|
|
|
2007-07-12 16:29:29 +00:00
|
|
|
/* ts A70711 : keeping an eye on the drive buffer */
|
|
|
|
off_t pessimistic_buffer_free;
|
|
|
|
int pbf_altered;
|
|
|
|
int wait_for_buffer_free;
|
|
|
|
int nominal_write_speed;
|
2007-08-17 08:19:30 +00:00
|
|
|
unsigned int wfb_min_usec;
|
|
|
|
unsigned int wfb_max_usec;
|
|
|
|
unsigned int wfb_timeout_sec;
|
|
|
|
unsigned int wfb_min_percent;
|
|
|
|
unsigned int wfb_max_percent;
|
|
|
|
unsigned int pessimistic_writes;
|
|
|
|
unsigned int waited_writes;
|
|
|
|
unsigned int waited_tries;
|
|
|
|
unsigned int waited_usec;
|
2007-07-12 16:29:29 +00:00
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
volatile int cancel;
|
|
|
|
volatile enum burn_drive_status busy;
|
2007-09-29 18:50:19 +00:00
|
|
|
|
|
|
|
/* ts A70929 */
|
|
|
|
pid_t thread_pid;
|
|
|
|
int thread_pid_valid;
|
|
|
|
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
/* transport functions */
|
|
|
|
int (*grab) (struct burn_drive *);
|
|
|
|
int (*release) (struct burn_drive *);
|
2006-10-21 18:51:35 +00:00
|
|
|
|
|
|
|
/* ts A61021 */
|
|
|
|
int (*drive_is_open) (struct burn_drive *);
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
int (*issue_command) (struct burn_drive *, struct command *);
|
|
|
|
|
|
|
|
/* lower level functions */
|
|
|
|
void (*erase) (struct burn_drive *, int);
|
|
|
|
void (*getcaps) (struct burn_drive *);
|
2006-10-21 10:34:15 +00:00
|
|
|
|
|
|
|
/* ts A61021 */
|
|
|
|
void (*read_atip) (struct burn_drive *);
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
int (*write) (struct burn_drive *, int, struct buffer *);
|
|
|
|
void (*read_toc) (struct burn_drive *);
|
|
|
|
void (*lock) (struct burn_drive *);
|
|
|
|
void (*unlock) (struct burn_drive *);
|
|
|
|
void (*eject) (struct burn_drive *);
|
|
|
|
void (*load) (struct burn_drive *);
|
2006-11-18 19:49:18 +00:00
|
|
|
int (*start_unit) (struct burn_drive *);
|
2006-08-15 20:37:04 +00:00
|
|
|
void (*read_disc_info) (struct burn_drive *);
|
|
|
|
void (*read_sectors) (struct burn_drive *,
|
|
|
|
int start,
|
|
|
|
int len,
|
|
|
|
const struct burn_read_opts *, struct buffer *);
|
|
|
|
void (*perform_opc) (struct burn_drive *);
|
|
|
|
void (*set_speed) (struct burn_drive *, int, int);
|
|
|
|
void (*send_parameters) (struct burn_drive *,
|
|
|
|
const struct burn_read_opts *);
|
|
|
|
void (*send_write_parameters) (struct burn_drive *,
|
|
|
|
const struct burn_write_opts *);
|
|
|
|
void (*send_cue_sheet) (struct burn_drive *, struct cue_sheet *);
|
2007-02-05 13:28:57 +00:00
|
|
|
|
|
|
|
/* ts A70205 : Announce size of a DVD-R[W] DAO session. */
|
|
|
|
int (*reserve_track) (struct burn_drive *d, off_t size);
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
void (*sync_cache) (struct burn_drive *);
|
|
|
|
int (*get_erase_progress) (struct burn_drive *);
|
2006-11-11 12:22:53 +00:00
|
|
|
int (*get_nwa) (struct burn_drive *, int trackno, int *lba, int *nwa);
|
2006-10-09 12:49:08 +00:00
|
|
|
|
2007-01-31 17:34:49 +00:00
|
|
|
/* ts A70131 : obtain (possibly fake) TOC number and start lba of
|
|
|
|
first track in last complete session */
|
|
|
|
int (*read_multi_session_c1)(struct burn_drive *d,
|
|
|
|
int *trackno, int *start);
|
|
|
|
|
2006-10-09 12:49:08 +00:00
|
|
|
/* ts A61009 : removed d in favor of o->drive */
|
|
|
|
/* void (*close_disc) (struct burn_drive * d,
|
|
|
|
struct burn_write_opts * o);
|
|
|
|
void (*close_session) (struct burn_drive * d,
|
2006-08-15 20:37:04 +00:00
|
|
|
struct burn_write_opts * o);
|
2006-10-09 12:49:08 +00:00
|
|
|
*/
|
|
|
|
void (*close_disc) (struct burn_write_opts * o);
|
|
|
|
void (*close_session) ( struct burn_write_opts * o);
|
|
|
|
|
2006-10-30 11:18:36 +00:00
|
|
|
/* ts A61029 */
|
2006-10-31 11:55:51 +00:00
|
|
|
void (*close_track_session) ( struct burn_drive *d,
|
2006-10-30 11:18:36 +00:00
|
|
|
int session, int track);
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
int (*test_unit_ready) (struct burn_drive * d);
|
|
|
|
void (*probe_write_modes) (struct burn_drive * d);
|
|
|
|
struct params params;
|
2006-10-12 17:35:06 +00:00
|
|
|
struct burn_scsi_inquiry_data *idata;
|
2006-08-15 20:37:04 +00:00
|
|
|
struct scsi_mode_data *mdata;
|
|
|
|
int toc_entries;
|
|
|
|
struct burn_toc_entry *toc_entry;
|
2006-10-23 11:31:37 +00:00
|
|
|
|
|
|
|
/* ts A61023 : get size and free space of drive buffer */
|
|
|
|
int (*read_buffer_capacity) (struct burn_drive *d);
|
|
|
|
|
2006-12-20 11:20:08 +00:00
|
|
|
/* ts A61220 : format media (e.g. DVD+RW) */
|
2007-01-06 12:08:57 +00:00
|
|
|
int (*format_unit) (struct burn_drive *d, off_t size, int flag);
|
2006-12-20 11:20:08 +00:00
|
|
|
|
2007-01-13 21:16:04 +00:00
|
|
|
/* ts A70108 */
|
|
|
|
/* mmc5r03c.pdf 6.24 : get list of available formats */
|
|
|
|
int (*read_format_capacities) (struct burn_drive *d, int top_wanted);
|
|
|
|
|
2007-08-12 15:25:56 +00:00
|
|
|
/* ts A70812 */
|
|
|
|
/* mmc5r03c.pdf 6.15 : read data sectors (start and amount in LBA) */
|
|
|
|
int (*read_10) (struct burn_drive *d, int start, int amount,
|
|
|
|
struct buffer *buf);
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* end of generic 'drive' data structures */
|
|
|
|
|
2008-04-22 16:13:05 +00:00
|
|
|
/* ts A80422 : centralizing this setting for debugging purposes
|
|
|
|
*/
|
|
|
|
int burn_drive_set_media_capacity_remaining(struct burn_drive *d, off_t value);
|
|
|
|
|
|
|
|
|
2006-08-15 20:37:04 +00:00
|
|
|
#endif /* __TRANSPORT */
|