1 /*
2  *   libdi - CD Audio Device Interface Library
3  *
4  *   Copyright (C) 1993-2004  Ti Kan
5  *   E-mail: xmcd@amb.org
6  *
7  *   This program is free software; you can redistribute it and/or modify
8  *   it under the terms of the GNU General Public License as published by
9  *   the Free Software Foundation; either version 2 of the License, or
10  *   (at your option) any later version.
11  *
12  *   This program is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with this program; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 
22 /*
23  *   Hitachi SCSI-1 vendor-unique support
24  *
25  *   The name "Hitachi" is a trademark of Hitachi Corporation, and is
26  *   used here for identification purposes only.
27  */
28 #ifndef __VU_HITA_H__
29 #define __VU_HITA_H__
30 
31 #ifdef VENDOR_HITACHI
32 
33 #ifndef lint
34 static char *_vu_hita_h_ident_ = "@(#)vu_hita.h	6.20 03/12/12";
35 #endif
36 
37 
38 /* Hitachi vendor-unique commands */
39 #define OP_VH_AUDPLAY		0xe0	/* Hitachi play audio */
40 #define OP_VH_PAUSE		0xe1	/* Hitachi pause */
41 #define OP_VH_PLAYTRK		0xe2	/* Hitachi play audio track */
42 #define OP_VH_RDINFO		0xe3	/* Hitachi read disk info */
43 #define OP_VH_EJECT		0xe4	/* Hitachi eject */
44 #define OP_VH_RDSTAT		0xe5	/* Hitachi read audio status */
45 #define OP_VH_PWRSAVE		0xe6	/* Hitachi power save mode */
46 #define OP_VH_RDXINFO		0xe8	/* Hitachi read extended disk info */
47 
48 
49 /* Return data lengths */
50 #define SZ_VH_PAUSE		3	/* Hitachi pause data size */
51 #define SZ_VH_RDINFO		303	/* Hitachi disk info data size */
52 #define SZ_VH_TOCHDR		3	/* Hitachi disc info header size */
53 #define SZ_VH_TOCENT		3	/* Hitachi disc info per-track
54 					 * entry size
55 					 */
56 #define SZ_VH_RDSTAT		11	/* Hitachi audio status data size */
57 #define SZ_VH_RDXINFO		404	/* Hitachi ext disk info data size */
58 #define SZ_VH_XTOCHDR		4	/* Hitachi ext disc info header size */
59 #define SZ_VH_XTOCENT		4	/* Hitachi ext disc info per-track
60 					 * entry size
61 					 */
62 
63 /* Macros to compute the real offset of the data area in several
64  * data structures.  The pad byte in the beginning of some structures
65  * are there to prevent the compiler from inserting a pad byte in
66  * the middle of the structure.  The alternative is to use #pragma pack(1),
67  * but that's not very portable.
68  */
69 #define AD_VH_PAUSE(x)		(x)	/* Hitachi pause data addr */
70 #define AD_VH_RDINFO(x)		((x)+1)	/* Hitachi disk info data addr */
71 #define AD_VH_RDSTAT(x)		(x)	/* Hitachi audio status data addr */
72 #define AD_VH_RDXINFO(x)	(x)	/* Hitachi ext disk info data addr */
73 
74 
75 /* Hitachi MSF location */
76 typedef struct hmsf {
77 #if _BYTE_ORDER_ == _L_ENDIAN_
78 	unsigned int	min:7;			/* minute */
79 	unsigned int	data:1;			/* 0=audio 1=data */
80 #else	/* _BYTE_ORDER_ == _B_ENDIAN_ */
81 	unsigned int	data:1;			/* 0=audio 1=data */
82 	unsigned int	min:7;			/* minute */
83 #endif	/* _BYTE_ORDER_ */
84 	unsigned int	sec:8;			/* second */
85 	unsigned int	frame:8;		/* frame */
86 	unsigned int	res:8;			/* reserved */
87 } hmsf_t;
88 
89 
90 /* Hitachi extended MSF location */
91 typedef struct hxmsf {
92 #if _BYTE_ORDER_ == _L_ENDIAN_
93 	unsigned int	adr:4;			/* ADR code */
94         unsigned int	preemph:1;		/* preemphasis */
95 	unsigned int	copyallow:1;		/* digital copy allow */
96 	unsigned int	trktype:1;		/* 0=audio 1=data */
97 	unsigned int	audioch:1;		/* 0=2ch 1=4ch */
98 #else	/* _BYTE_ORDER_ == _B_ENDIAN_ */
99 	unsigned int	audioch:1;		/* 0=2ch 1=4ch */
100 	unsigned int	trktype:1;		/* 0=audio 1=data */
101 	unsigned int	copyallow:1;		/* digital copy allow */
102         unsigned int	preemph:1;		/* preemphasis */
103 	unsigned int	adr:4;			/* ADR code */
104 #endif	/* _BYTE_ORDER_ */
105 	unsigned int	min:8;			/* minute */
106 	unsigned int	sec:8;			/* second */
107 	unsigned int	frame:8;		/* frame */
108 } hxmsf_t;
109 
110 
111 /* Hitachi Disk Info data */
112 typedef struct hdiscinfo {
113 	unsigned int	pad0:8;			/* pad byte for alignment */
114 #if _BYTE_ORDER_ == _L_ENDIAN_
115 	unsigned int	audio:1;		/* disc has audio tracks */
116 	unsigned int	data:1;			/* disc has data tracks */
117 	unsigned int	res:6;			/* reserved */
118 #else	/* _BYTE_ORDER_ == _B_ENDIAN_ */
119 	unsigned int	res:6;			/* reserved */
120 	unsigned int	data:1;			/* disc has data tracks */
121 	unsigned int	audio:1;		/* disc has audio tracks */
122 #endif	/* _BYTE_ORDER_ */
123 	unsigned int	first_trk:8;		/* first track number */
124 	unsigned int	last_trk:8;		/* last track number */
125 
126 	byte_t		msfdata[300];		/* Track MSF address data */
127 } hdiscinfo_t;
128 
129 
130 /* Hitachi Audio Status data */
131 typedef struct haudstat {
132 #if _BYTE_ORDER_ == _L_ENDIAN_
133 	unsigned int	playing:1;		/* Audio playing */
134 	unsigned int	res1:7;			/* Reserved */
135 	unsigned int	adr:4;			/* ADR code */
136         unsigned int	preemph:1;		/* preemphasis */
137 	unsigned int	copyallow:1;		/* digital copy allow */
138 	unsigned int	trktype:1;		/* 0=audio 1=data */
139 	unsigned int	audioch:1;		/* 0=2ch 1=4ch */
140 #else	/* _BYTE_ORDER_ == _B_ENDIAN_ */
141 	unsigned int	res1:7;			/* Reserved */
142 	unsigned int	playing:1;		/* Audio playing */
143 	unsigned int	audioch:1;		/* 0=2ch 1=4ch */
144 	unsigned int	trktype:1;		/* 0=audio 1=data */
145 	unsigned int	copyallow:1;		/* digital copy allow */
146         unsigned int	preemph:1;		/* preemphasis */
147 	unsigned int	adr:4;			/* ADR code */
148 #endif	/* _BYTE_ORDER_ */
149 	unsigned int	trkno:8;		/* track number */
150 	unsigned int	res2:8;			/* reserved */
151 
152 	hmsf_t		rel_addr;		/* relative address */
153 	hmsf_t		abs_addr;		/* absolute address */
154 } haudstat_t;
155 
156 
157 /* Hitachi Extended Disk Info data */
158 typedef struct hxdiscinfo {
159 	byte_t		res[2];			/* reserved */
160 	byte_t		first_trk;		/* first track number */
161 	byte_t		last_trk;		/* last track number */
162 
163 	byte_t		xmsfdata[400];		/* track MSF address data */
164 } hxdiscinfo_t;
165 
166 
167 /* Public function prototypes */
168 extern bool_t	hita_playaudio(byte_t, sword32_t, sword32_t, msf_t *, msf_t *,
169 			byte_t, byte_t);
170 extern bool_t	hita_pause_resume(bool_t);
171 extern bool_t	hita_start_stop(bool_t, bool_t);
172 extern bool_t	hita_get_playstatus(cdstat_t *);
173 extern bool_t	hita_get_toc(curstat_t *);
174 extern bool_t	hita_mute(bool_t);
175 extern bool_t	hita_eject(void);
176 extern void	hita_init(void);
177 
178 #else
179 
180 #define hita_init	NULL
181 
182 #endif	/* VENDOR_HITACHI */
183 
184 #endif	/* __VU_HITA_H__ */
185 
186