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  *   Sony vendor-unique support
24  *
25  *   The name "Sony" is a trademark of Sony Corporation, and is used
26  *   here for identification purposes only.
27  */
28 #ifndef __VU_SONY_H__
29 #define __VU_SONY_H__
30 
31 #ifdef VENDOR_SONY
32 
33 #ifndef lint
34 static char *_vu_sony_h_ident_ = "@(#)vu_sony.h	6.21 03/12/12";
35 #endif
36 
37 
38 /* Sony vendor-unique commands */
39 #define OP_VS_SETADDRFMT	0xc0	/* Sony set address format */
40 #define OP_VS_RDTOC		0xc1	/* Sony read TOC */
41 #define OP_VS_RDSUBQ		0xc2	/* Sony read subchannel */
42 #define OP_VS_RDHDR		0xc3	/* Sony read header */
43 #define OP_VS_PLAYSTAT		0xc4	/* Sony playback status */
44 #define OP_VS_PAUSE		0xc5	/* Sony pause */
45 #define OP_VS_PLAYTRK		0xc6	/* Sony play track */
46 #define OP_VS_PLAYMSF		0xc7	/* Sony play MSF */
47 #define OP_VS_PLAYAUD		0xc8	/* Sony play audio */
48 #define OP_VS_PLAYCTL		0xc9	/* Sony playback control */
49 #define OP_VS_READCDDA		0xd8	/* Sony read CD-DA (12) */
50 #define OP_VS_READCDDAMSF	0xd9	/* Sony read CD-DA (12) */
51 
52 
53 /* Sony audio status codes */
54 #define SAUD_PLAYING		0x00	/* audio play in progress */
55 #define SAUD_PAUSED		0x01	/* audio pause in progress */
56 #define SAUD_MUTED		0x02	/* audio muting on */
57 #define SAUD_COMPLETED		0x03	/* audio play successfully completed */
58 #define SAUD_ERROR		0x04	/* error occurred during audio play */
59 #define SAUD_NOTREQ		0x05	/* audio play not requested */
60 
61 
62 /* Return data lengths */
63 #define SZ_VS_RDTOC		604	/* Sony read TOC data size */
64 #define SZ_VS_TOCHDR		4	/* Sony read TOC header data size */
65 #define SZ_VS_TOCENT		6	/* Sony read TOC header entry size */
66 #define SZ_VS_RDSUBQ		9	/* Sony read sub-code Q data size */
67 #define SZ_VS_PLAYSTAT		18	/* Sony read disc info data size */
68 #define SZ_VS_CDPARM		4	/* CD-ROM parameters data size */
69 
70 /* Mode Sense/Mode Select page code */
71 #define PG_VS_CDPARM		0x8	/* CD-ROM parameters page */
72 
73 
74 /* Sony read subchannel command data */
75 typedef struct ssubq_data {
76 #if _BYTE_ORDER_ == _L_ENDIAN_
77 	unsigned int	preemph:1;	/* preemphasis */
78 	unsigned int	copyallow:1;	/* digital copy allow */
79 	unsigned int	trktype:1;	/* 0=audio 1=data */
80 	unsigned int	audioch:1;	/* 0=2ch 1=4ch */
81 	unsigned int	reserved:4;	/* reserved */
82 #else	/* _BYTE_ORDER_ == _B_ENDIAN_ */
83 	unsigned int	reserved:4;	/* reserved */
84 	unsigned int	audioch:1;	/* 0=2ch 1=4ch */
85 	unsigned int	trktype:1;	/* 0=audio 1=data */
86 	unsigned int	copyallow:1;	/* digital copy allow */
87 	unsigned int	preemph:1;	/* preemphasis */
88 #endif	/* _BYTE_ORDER_ */
89 	unsigned int	trkno:8;	/* track number */
90 	unsigned int	idxno:8;	/* index number */
91 	unsigned int	rel_min:8;	/* trk relative minutes */
92 
93 	unsigned int	rel_sec:8;	/* trk relative seconds */
94 	unsigned int	rel_frame:8;	/* trk relative frame */
95 	unsigned int	abs_min:8;	/* absolute minutes */
96 	unsigned int	abs_sec:8;	/* absolute seconds */
97 
98 	unsigned int	abs_frame:8;	/* absolute frame */
99 	unsigned int	pad1:24;	/* pad for alignment */
100 } ssubq_data_t;
101 
102 
103 /* Sony read TOC command data */
104 typedef struct stoc_data {
105 	unsigned int	data_len:16;	/* data length */
106 	unsigned int	first_trk:8;	/* first track */
107 	unsigned int	last_trk:8;	/* last track */
108 
109 	byte_t		trkdata[600];	/* track info */
110 } stoc_data_t;
111 
112 typedef struct stoc_ent {
113 	unsigned int	trkno:8;	/* track number */
114 #if _BYTE_ORDER_ == _L_ENDIAN_
115 	unsigned int	preemph:1;	/* preemphasis */
116 	unsigned int	copyallow:1;	/* digital copy allow */
117 	unsigned int	trktype:1;	/* 0=audio 1=data */
118 	unsigned int	audioch:1;	/* 0=2ch 1=4ch */
119 	unsigned int	res1:4;		/* reserved */
120 #else	/* _BYTE_ORDER_ == _B_ENDIAN_ */
121 	unsigned int	res1:4;		/* reserved */
122 	unsigned int	audioch:1;	/* 0=2ch 1=4ch */
123 	unsigned int	trktype:1;	/* 0=audio 1=data */
124 	unsigned int	copyallow:1;	/* digital copy allow */
125 	unsigned int	preemph:1;	/* preemphasis */
126 #endif	/* _BYTE_ORDER_ */
127 	unsigned int	res2:8;		/* reserved */
128 	unsigned int	min:8;		/* minutes */
129 
130 	unsigned int	sec:8;		/* seconds */
131 	unsigned int	frame:8;	/* frame */
132 	unsigned int	pad1:16;	/* pad bytes for alignment */
133 } stoc_ent_t;
134 
135 
136 /* Sony play status command data */
137 typedef struct sstat_data {
138 	unsigned int	res1:8;		/* reserved */
139 #if _BYTE_ORDER_ == _L_ENDIAN_
140 	unsigned int	lbamsf:1;	/* address format bit */
141 	unsigned int	res2:7;		/* reserved */
142 	unsigned int	data_len:16;	/* audio status data length */
143 
144 	unsigned int	audio_status:8;	/* audio status */
145 	unsigned int	preemph:1;	/* preemphasis */
146 	unsigned int	copyallow:1;	/* digital copy allow */
147 	unsigned int	trktype:1;	/* 0=audio 1=data */
148 	unsigned int	audioch:1;	/* 0=2ch 1=4ch */
149 	unsigned int	res3:4;		/* reserved */
150 	unsigned int	res4:8;		/* reserved */
151 	unsigned int	min:8;		/* CD address: minute */
152 
153 	unsigned int	sec:8;		/* CD address: second */
154 	unsigned int	frame:8;	/* CD address: frame */
155 	unsigned int	sel0:4;		/* output select for channel 0 */
156 	unsigned int	res5:4;		/* reserved */
157 	unsigned int	vol0:8;		/* channel 0 volume */
158 
159 	unsigned int	sel1:4;		/* output select for channel 1 */
160 	unsigned int	res6:4;		/* reserved */
161 	unsigned int	vol1:8;		/* channel 1 volume */
162 	unsigned int	sel2:4;		/* output select for channel 2 */
163 	unsigned int	res7:4;		/* reserved */
164 	unsigned int	vol2:8;		/* channel 2 volume */
165 
166 	unsigned int	sel3:4;		/* output select for channel 3 */
167 	unsigned int	res8:4;		/* reserved */
168 	unsigned int	vol3:8;		/* channel 3 volume */
169 #else	/* _BYTE_ORDER_ == _B_ENDIAN_ */
170 	unsigned int	res2:7;		/* reserved */
171 	unsigned int	lbamsf:1;	/* address format bit */
172 	unsigned int	data_len:16;	/* audio status data length */
173 
174 	unsigned int	audio_status:8;	/* audio status */
175 	unsigned int	res3:4;		/* reserved */
176 	unsigned int	audioch:1;	/* 0=2ch 1=4ch */
177 	unsigned int	trktype:1;	/* 0=audio 1=data */
178 	unsigned int	copyallow:1;	/* digital copy allow */
179 	unsigned int	preemph:1;	/* preemphasis */
180 	unsigned int	res4:8;		/* reserved */
181 	unsigned int	min:8;		/* CD address: minute */
182 
183 	unsigned int	sec:8;		/* CD address: second */
184 	unsigned int	frame:8;	/* CD address: frame */
185 	unsigned int	res5:4;		/* reserved */
186 	unsigned int	sel0:4;		/* output select for channel 0 */
187 	unsigned int	vol0:8;		/* channel 0 volume */
188 
189 	unsigned int	res6:4;		/* reserved */
190 	unsigned int	sel1:4;		/* output select for channel 1 */
191 	unsigned int	vol1:8;		/* channel 1 volume */
192 	unsigned int	res7:4;		/* reserved */
193 	unsigned int	sel2:4;		/* output select for channel 2 */
194 	unsigned int	vol2:8;		/* channel 2 volume */
195 
196 	unsigned int	res8:4;		/* reserved */
197 	unsigned int	sel3:4;		/* output select for channel 3 */
198 	unsigned int	vol3:8;		/* channel 3 volume */
199 #endif	/* _BYTE_ORDER_ */
200 	unsigned int	pad1:16;	/* pad for alignment */
201 } sstat_data_t;
202 
203 
204 /* Mode Sense/Mode Select CD-ROM parameters page data structure */
205 typedef struct cdparm_pg {
206 #if _BYTE_ORDER_ == _L_ENDIAN_
207 	unsigned int	pg_code:6;	/* page code */
208 	unsigned int	res0:2;		/* reserved */
209 	unsigned int	pg_len:8;	/* page length */
210 	unsigned int	lbamsf:1;	/* LBA/MSF addr format ctrl bit */
211 	unsigned int	res1:7;		/* reserved */
212 	unsigned int	inact_mult:4;	/* inactivity timer multiplier */
213 	unsigned int	res2:4;		/* reserved */
214 #else	/* _BYTE_ORDER_ == _B_ENDIAN_ */
215 	unsigned int	res0:2;		/* reserved */
216 	unsigned int	pg_code:6;	/* page code */
217 	unsigned int	pg_len:8;	/* page length */
218 	unsigned int	res1:7;		/* reserved */
219 	unsigned int	lbamsf:1;	/* LBA/MSF addr format ctrl bit */
220 	unsigned int	res2:4;		/* reserved */
221 	unsigned int	inact_mult:4;	/* inactivity timer multiplier */
222 #endif	/* _BYTE_ORDER_ */
223 } cdparm_pg_t;
224 
225 
226 /* Public function prototypes */
227 extern bool_t	sony_playaudio(byte_t, sword32_t, sword32_t, msf_t *, msf_t *,
228 			byte_t, byte_t);
229 extern bool_t	sony_pause_resume(bool_t);
230 extern bool_t	sony_get_playstatus(cdstat_t *);
231 extern bool_t	sony_get_toc(curstat_t *);
232 extern int	sony_volume(int, curstat_t *, bool_t);
233 extern bool_t	sony_route(curstat_t *);
234 extern void	sony_init(void);
235 extern void	sony_start(void);
236 
237 #else
238 
239 #define sony_init	NULL
240 
241 #endif	/* VENDOR_SONY */
242 
243 #endif	/* __VU_SONY_H__ */
244 
245