drive.h 4.63 KB
Newer Older
Mario Danic's avatar
Mario Danic committed
1 2
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */

3 4 5 6 7 8
/* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens
   Copyright (c) 2006 - 2010 Thomas Schmitt <scdbackup@gmx.net>
   Provided under GPL version 2 or later.
*/


Mario Danic's avatar
Mario Danic committed
9 10 11 12 13 14 15 16 17 18
#ifndef __DRIVE
#define __DRIVE

#include "libburn.h"
#include "toc.h"
#include "structure.h"

struct burn_drive;
struct command;
struct mempage;
19 20
struct scsi_mode_data;
struct burn_speed_descriptor;
Mario Danic's avatar
Mario Danic committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

#define LEAD_IN 1
#define GAP 2
#define USER_DATA 3
#define LEAD_OUT 4
#define SYNC 5

#define SESSION_LEADOUT_ENTRY(d,s) (d)->toc->session[(s)].leadout_entry

#define CURRENT_SESSION_START(d) \
	burn_msf_to_lba(d->toc->session[d->currsession].start_m, \
	                   d->toc->session[d->currsession].start_s, \
	                   d->toc->session[d->currsession].start_f)

#define SESSION_END(d,s) \
	TOC_ENTRY_PLBA((d)->toc, SESSION_LEADOUT_ENTRY((d), (s)))

#define PREVIOUS_SESSION_END(d) \
	TOC_ENTRY_PLBA((d)->toc, SESSION_LEADOUT_ENTRY((d), (d)->currsession-1))

#define LAST_SESSION_END(d) \
	TOC_ENTRY_PLBA((d)->toc, \
	               SESSION_LEADOUT_ENTRY((d), (d)->toc->sessions-1))

struct burn_drive *burn_drive_register(struct burn_drive *);
46
int burn_drive_unregister(struct burn_drive *d);
Mario Danic's avatar
Mario Danic committed
47 48

unsigned int burn_drive_count(void);
49 50 51

/* ts A61007 */
/* void burn_wait_all(void); */
52 53
/* @param flag  bit0= demand freed drives (else released drives) */
int burn_drives_are_clear(int flag);
54

Mario Danic's avatar
Mario Danic committed
55 56 57 58
int burn_sector_length_write(struct burn_drive *d);
int burn_track_control(struct burn_drive *d, int);
void burn_write_empty_sector(int fd);
void burn_write_empty_subcode(int fd);
59 60
void burn_drive_free(struct burn_drive *d);
void burn_drive_free_all(void);
Mario Danic's avatar
Mario Danic committed
61

62
/* @param flag bit0= reset global drive list */
Mario Danic's avatar
Mario Danic committed
63
int burn_drive_scan_sync(struct burn_drive_info *drives[],
64 65
			 unsigned int *n_drives, int flag);

Mario Danic's avatar
Mario Danic committed
66 67 68 69
void burn_disc_erase_sync(struct burn_drive *d, int fast);
int burn_drive_get_block_types(struct burn_drive *d,
			       enum burn_write_types write_type);

70
int burn_drive_is_open(struct burn_drive *d);
71 72 73
int burn_drive_is_occupied(struct burn_drive *d);
int burn_drive_forget(struct burn_drive *d, int force);
int burn_drive_convert_fs_adr_sub(char *path, char adr[], int *rec_count);
74

75 76 77 78 79 80 81 82
/* ts A61021 : the unspecific part of sg.c:enumerate_common()
*/
int burn_setup_drive(struct burn_drive *d, char *fname);

/* ts A61021 : after-setup activities from sg.c:enumerate_common()
*/
struct burn_drive *burn_drive_finish_enum(struct burn_drive *d);

83 84 85 86 87
/* ts A61125 : media status aspects of burn_drive_grab() */
int burn_drive_inquire_media(struct burn_drive *d);

/* ts A61125 : model aspects of burn_drive_release */
int burn_drive_mark_unready(struct burn_drive *d);
88

89 90 91 92 93 94 95 96 97 98 99 100 101 102

/* ts A61226 */
int burn_speed_descriptor_new(struct burn_speed_descriptor **s,
				struct burn_speed_descriptor *prev,
				struct burn_speed_descriptor *next, int flag);

/* ts A61226 */
/* @param flag bit0= destroy whole next-chain of descriptors */
int burn_speed_descriptor_destroy(struct burn_speed_descriptor **s, int flag);


/* ts A61226 : free dynamically allocated sub data of struct scsi_mode_data */
int burn_mdata_free_subs(struct scsi_mode_data *m);

103 104

/* ts A61230 */
105
void burn_disc_format_sync(struct burn_drive *d, off_t size, int flag);
106

107 108 109 110 111

/* ts A70207 : evaluate write mode related peculiarities of a disc */
struct burn_disc_mode_demands {
	int multi_session;
	int multi_track;
112
	int unknown_track_size; /* 0=known, 1=unknown, 2=unknown+defaulted */
113 114 115
	int mixed_mode;
	int audio;
	int exotic_track;
116 117
	int block_types;
	int will_append; /* because of media state or multi session disc */
118 119
};
int burn_disc_get_write_mode_demands(struct burn_disc *disc,
120 121
			struct burn_write_opts *opts,
			struct burn_disc_mode_demands *result, int flag);
122

123 124 125 126 127 128 129

/* ts A70924 : convert a special stdio address into fd number.
   @return >0 is a valid fd , -1 indicates unsuitable address string. 
*/
int burn_drive__fd_from_special_adr(char *adr);


130 131 132
/* ts A70929 : Find the drive which is being worked on by pid , tid */
int burn_drive_find_by_thread_pid(struct burn_drive **d, pid_t pid,
					pthread_t tid);
133 134


135 136 137 138 139 140
/* ts A51221 - A80731 : Whitelist inquiry functions */
int burn_drive_is_banned(char *device_address);
int burn_drive_whitelist_count(void);
char *burn_drive_whitelist_item(int idx, int flag);


141 142 143
/* ts A80801 */
int burn_drive_is_listed(char *path, struct burn_drive **found, int flag);

144 145 146 147 148 149 150 151

/* ts B00226 : Outsourced backend of burn_abort()
   @param elapsed  to be subtracted from start time
   @param flag     bit0= do not shutdown the library
*/ 
int burn_abort_5(int patience,
               int (*pacifier_func)(void *handle, int patience, int elapsed),
               void *handle, int elapsed, int flag);
152

Mario Danic's avatar
Mario Danic committed
153
#endif /* __DRIVE */