1 /* @(#)interface.h	1.27 13/12/26 Copyright 1998-2001 Heiko Eissfeldt, Copyright 2005-2013 J. Schilling */
2 
3 /*
4  * Copyright (C) by Heiko Eissfeldt
5  * Copyright (c) 2005-2013 J. Schilling
6  *
7  * header file interface.h for cdda2wav
8  */
9 /*
10  * The contents of this file are subject to the terms of the
11  * Common Development and Distribution License, Version 1.0 only
12  * (the "License").  You may not use this file except in compliance
13  * with the License.
14  *
15  * See the file CDDL.Schily.txt in this distribution for details.
16  * A copy of the CDDL is also available via the Internet at
17  * http://www.opensource.org/licenses/cddl1.txt
18  *
19  * When distributing Covered Code, include this CDDL HEADER in each
20  * file and include the License file CDDL.Schily.txt from this distribution.
21  */
22 
23 #ifndef	DEF_BUFSIZE
24 #define	DEF_BUFSIZE		(3*1024*1024)	/* Max def. SCSI Buf size 3M */
25 #endif
26 
27 #ifndef	CD_FRAMESIZE
28 #define	CD_FRAMESIZE		2048
29 #endif
30 
31 #ifndef	CD_FRAMESIZE_RAW
32 #define	CD_FRAMESIZE_RAW	2352
33 #endif
34 
35 #define	CD_FRAMESAMPLES		(CD_FRAMESIZE_RAW / 4)
36 
37 /*
38  * NOTE: windows.h defines interface as an alias for struct, this
39  *	 is used by COM/OLE2, I guess it is class on C++
40  *	 We man need to #undef 'interface'
41  */
42 #undef interface
43 
44 extern unsigned interface;
45 
46 extern int trackindex_disp;
47 #ifndef	NSECTORS
48 #define	NSECTORS		75
49 #endif
50 
51 /* interface types */
52 #define	GENERIC_SCSI		0
53 #define	COOKED_IOCTL		1
54 
55 /* constants for sub-q-channel info */
56 #define	GET_ALL			0
57 #define	GET_POSITIONDATA	1
58 #define	GET_CATALOGNUMBER	2
59 #define	GET_TRACK_ISRC		3
60 
61 typedef struct subq_chnl {
62     unsigned char reserved;
63     unsigned char audio_status;
64     unsigned short subq_length;
65     unsigned char format;
66     unsigned char control_adr;
67     unsigned char track;
68     unsigned char index;
69     unsigned char data[40];	/* this has subq_all, subq_position,	  */
70 				/* subq_catalog or subq_track_isrc format */
71 } subq_chnl;
72 
73 typedef struct subq_all {
74     unsigned char abs_min;
75     unsigned char abs_sec;
76     unsigned char abs_frame;
77     unsigned char abs_reserved;
78     unsigned char trel_min;
79     unsigned char trel_sec;
80     unsigned char trel_frame;
81     unsigned char trel_reserved;
82     unsigned char mc_valid;	/* MSB */
83     unsigned char media_catalog_number[13];
84     unsigned char zero;
85     unsigned char aframe;
86     unsigned char tc_valid;	/* MSB */
87     unsigned char track_ISRC[15];
88 } subq_all;
89 
90 typedef struct subq_position {
91     unsigned char abs_reserved;
92     unsigned char abs_min;
93     unsigned char abs_sec;
94     unsigned char abs_frame;
95     unsigned char trel_reserved;
96     unsigned char trel_min;
97     unsigned char trel_sec;
98     unsigned char trel_frame;
99 } subq_position;
100 
101 typedef struct subq_catalog {
102     unsigned char mc_valid;	/* MSB */
103     unsigned char media_catalog_number[13];
104     unsigned char zero;
105     unsigned char aframe;
106 } subq_catalog;
107 
108 typedef struct subq_track_isrc {
109     unsigned char tc_valid;	/* MSB */
110     unsigned char track_isrc[15];
111 } subq_track_isrc;
112 
113 #if	!defined	NO_SCSI_STUFF
114 
115 /* cdrom access function pointer */
116 extern	void	(*EnableCdda)	__PR((SCSI *scgp, int Switch,
117 						unsigned uSectorsize));
118 extern	unsigned (*doReadToc)	__PR((SCSI *scgp));
119 extern	void	(*ReadTocText)	__PR((SCSI *scgp));
120 extern	unsigned (*ReadLastAudio) __PR((SCSI *scgp));
121 extern	int	(*ReadCdRom)	__PR((SCSI *scgp, UINT4 *p, unsigned lSector,
122 						unsigned SectorBurstVal));
123 extern	int	(*ReadCdRom_C2)	__PR((SCSI *scgp, UINT4 *p, unsigned lSector,
124 						unsigned SectorBurstVal));
125 extern	int	(*ReadCdRomSub)	__PR((SCSI *scgp, UINT4 *p, unsigned lSector,
126 						unsigned SectorBurstVal));
127 extern	int	(*ReadCdRomData) __PR((SCSI *scgp, unsigned char *p,
128 						unsigned lSector,
129 						unsigned SectorBurstVal));
130 extern	subq_chnl *(*ReadSubQ)	__PR((SCSI *scgp, unsigned char sq_format,
131 						unsigned char track));
132 extern	subq_chnl *(*ReadSubChannels) __PR((SCSI *scgp, unsigned lSector));
133 extern	void	(*SelectSpeed)	__PR((SCSI *scgp, unsigned speed));
134 extern	int	(*Play_at)	__PR((SCSI *scgp, unsigned from_sector,
135 						unsigned sectors));
136 extern	int	(*StopPlay)	__PR((SCSI *scgp));
137 extern	void	(*trash_cache)	__PR((UINT4 *p, unsigned lSector,
138 						unsigned SectorBurstVal));
139 
140 extern	SCSI	*get_scsi_p	__PR((void));
141 #endif
142 
143 extern	unsigned char	*bufferTOC;
144 extern	int		bufTOCsize;
145 extern	subq_chnl	*SubQbuffer;
146 
147 
148 extern	void	SetupInterface	__PR((void));
149 extern	int	Toshiba3401	__PR((void));
150 
151 extern int	poll_in			__PR((void));
152 
153 /*
154  * The callback interface for libparanoia to the CD-ROM interface
155  *
156  * cdda_read() is in interface.c the other functions are in toc.c
157  */
158 extern long	cdda_disc_firstsector	__PR((void *d));		/* -> long sector */
159 extern long	cdda_disc_lastsector	__PR((void *d));		/* -> long sector */
160 extern long	cdda_read		__PR((void *d, void *buffer, long beginsector, long sectors));	/* -> long sectors */
161 extern long	cdda_read_c2		__PR((void *d, void *buffer, long beginsector, long sectors));	/* -> long sectors */
162 extern int	cdda_sector_gettrack	__PR((void *d, long sector));	/* -> int trackno */
163 extern int	cdda_track_audiop	__PR((void *d, int track));	/* -> int Is audiotrack */
164 extern long	cdda_track_firstsector	__PR((void *d, int track));	/* -> long sector */
165 extern long	cdda_track_lastsector	__PR((void *d, int track));	/* -> long sector */
166 extern int	cdda_tracks		__PR((void *d));		/* -> int tracks */
167