1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /*
3  * Libbrasero-media
4  * Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
5  *
6  * Libbrasero-media is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * The Libbrasero-media authors hereby grant permission for non-GPL compatible
12  * GStreamer plugins to be used and distributed together with GStreamer
13  * and Libbrasero-media. This permission is above and beyond the permissions granted
14  * by the GPL license by which Libbrasero-media is covered. If you modify this code
15  * you may extend this exception to your version of the code, but you are not
16  * obligated to do so. If you do not wish to do so, delete this exception
17  * statement from your version.
18  *
19  * Libbrasero-media is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU Library General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to:
26  * 	The Free Software Foundation, Inc.,
27  * 	51 Franklin Street, Fifth Floor
28  * 	Boston, MA  02110-1301, USA.
29  */
30 
31 #include <glib.h>
32 
33 #include "scsi-base.h"
34 
35 #ifndef _SCSI_READ_TOC_PMA_ATIP_H
36 #define _SCSI_READ_TOC_PMA_ATIP_H
37 
38 G_BEGIN_DECLS
39 
40 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
41 
42 struct _BraseroScsiTocPmaAtipHdr {
43 	uchar len			[2];
44 
45 	uchar first_track_session;
46 	uchar last_track_session;
47 };
48 
49 struct _BraseroScsiTocDesc {
50 	uchar reserved0;
51 
52 	uchar control			:4; /* BraseroScsiTrackMode 		*/
53 	uchar adr			:4; /* BraseroScsiQSubChannelProgAreaMode 	*/
54 
55 	uchar track_num;
56 	uchar reserved1;
57 
58 	uchar track_start		[4];
59 };
60 
61 struct _BraseroScsiRawTocDesc {
62 	uchar session_num;
63 
64 	uchar control			:4; /* BraseroScsiTrackMode 		*/
65 	uchar adr			:4; /* BraseroScsiQSubChannelLeadinMode	*/
66 
67 	/* Q sub-channel data */
68 	uchar track_num;
69 
70 	uchar point;			/* BraseroScsiQSubChannelLeadinMode5 or BraseroScsiQSubChannelLeadinMode1 */
71 	uchar min;
72 	uchar sec;
73 	uchar frame;
74 
75 	uchar zero;
76 	uchar p_min;
77 	uchar p_sec;
78 	uchar p_frame;
79 };
80 
81 struct _BraseroScsiPmaDesc {
82 	uchar reserved0;
83 
84 	uchar control			:4; /* BraseroScsiTrackMode 		*/
85 	uchar adr			:4; /* BraseroScsiQSubChannelPmaMode 	*/
86 
87 	uchar track_num;			/* always 0 */
88 
89 	uchar point;				/* see BraseroScsiQSubChannelPmaMode */
90 	uchar min;
91 	uchar sec;
92 	uchar frame;
93 
94 	uchar zero;
95 	uchar p_min;
96 	uchar p_sec;
97 	uchar p_frame;
98 };
99 
100 struct _BraseroScsiAtipDesc {
101 	uchar reference_speed		:3;	/* 1 */
102 	uchar reserved0			:1;
103 	uchar indicative_target_wrt_pwr	:4;
104 
105 	uchar reserved1			:6;	/* 2 */
106 	uchar unrestricted_use		:1;
107 	uchar bit0			:1;
108 
109 	uchar A3_valid			:1;	/* 3 */
110 	uchar A2_valid			:1;
111 	uchar A1_valid			:1;
112 	uchar disc_sub_type		:3;
113 	uchar erasable			:1;
114 	uchar bit1			:1;
115 
116 	uchar reserved2;			/* 4 */
117 
118 	uchar leadin_mn;
119 	uchar leadin_sec;
120 	uchar leadin_frame;
121 	uchar reserved3;			/* 8 */
122 
123 	/* Additional capacity for high capacity CD-R,
124 	 * otherwise last possible leadout */
125 	uchar leadout_mn;
126 	uchar leadout_sec;
127 	uchar leadout_frame;
128 	uchar reserved4;			/* 12 */
129 
130 	/* Write strategy recording parameters.
131 	 * See MMC1 and MMC2 for a description. */
132 	uchar A1_data			[3];
133 	uchar reserved5;
134 
135 	uchar A2_data			[3];
136 	uchar reserved6;
137 
138 	uchar A3_data			[3];
139 	uchar reserved7;
140 
141 	/* Be careful here since the following is only true for MMC3. That means
142 	 * if we use this size with a MMC1/2 drives it returns an error (invalid
143 	 * field). The following value is not really useful anyway. */
144 	uchar S4_data			[3];
145 	uchar reserved8;
146 };
147 
148 #else
149 
150 struct _BraseroScsiTocPmaAtipHdr {
151 	uchar len			[2];
152 
153 	uchar first_track_session;
154 	uchar last_track_session;
155 };
156 
157 struct _BraseroScsiTocDesc {
158 	uchar reserved0;
159 
160 	uchar adr			:4;
161 	uchar control			:4;
162 
163 	uchar track_num;
164 	uchar reserved1;
165 
166 	uchar track_start		[4];
167 };
168 
169 struct _BraseroScsiRawTocDesc {
170 	uchar session_num;
171 
172 	uchar adr			:4;
173 	uchar control			:4;
174 
175 	uchar track_num;
176 
177 	uchar point;
178 	uchar min;
179 	uchar sec;
180 	uchar frame;
181 
182 	uchar zero;
183 	uchar p_min;
184 	uchar p_sec;
185 	uchar p_frame;
186 };
187 
188 struct _BraseroScsiPmaDesc {
189 	uchar reserved0;
190 
191 	uchar adr			:4;
192 	uchar control			:4;
193 
194 	uchar track_num;
195 
196 	uchar point;
197 	uchar min;
198 	uchar sec;
199 	uchar frame;
200 
201 	uchar zero;
202 	uchar p_min;
203 	uchar p_sec;
204 	uchar p_frame;
205 };
206 
207 struct _BraseroScsiAtipDesc {
208 	uchar indicative_target_wrt_pwr	:4;
209 	uchar reserved0			:1;
210 	uchar reference_speed		:3;
211 
212 	uchar bit0			:1;
213 	uchar unrestricted_use		:1;
214 	uchar reserved1			:6;
215 
216 	uchar bit1			:1;
217 	uchar erasable			:1;
218 	uchar disc_sub_type		:3;
219 	uchar A1_valid			:1;
220 	uchar A2_valid			:1;
221 	uchar A3_valid			:1;
222 
223 	uchar reserved2;
224 
225 	uchar leadin_start_time_mn;
226 	uchar leadin_start_time_sec;
227 	uchar leadin_start_time_frame;
228 	uchar reserved3;
229 
230 	/* Additional capacity for high capacity CD-R,
231 	 * otherwise last possible leadout */
232 	uchar leadout_mn;
233 	uchar leadout_sec;
234 	uchar leadout_frame;
235 	uchar reserved4;
236 
237 	/* write strategy recording parameters */
238 	uchar A1_data			[3];
239 	uchar reserved5;
240 
241 	uchar A2_data			[3];
242 	uchar reserved6;
243 
244 	uchar A3_data			[3];
245 	uchar reserved7;
246 
247 	uchar S4_data			[3];
248 	uchar reserved8;
249 };
250 
251 #endif
252 
253 typedef struct _BraseroScsiTocDesc BraseroScsiTocDesc;
254 typedef struct _BraseroScsiRawTocDesc BraseroScsiRawTocDesc;
255 typedef struct _BraseroScsiPmaDesc BraseroScsiPmaDesc;
256 typedef struct _BraseroScsiAtipDesc BraseroScsiAtipDesc;
257 
258 typedef struct _BraseroScsiTocPmaAtipHdr BraseroScsiTocPmaAtipHdr;
259 
260 /* multiple toc descriptors may be returned */
261 struct _BraseroScsiFormattedTocData {
262 	BraseroScsiTocPmaAtipHdr hdr	[1];
263 	BraseroScsiTocDesc desc		[0];
264 };
265 typedef struct _BraseroScsiFormattedTocData BraseroScsiFormattedTocData;
266 
267 /* multiple toc descriptors may be returned */
268 struct _BraseroScsiRawTocData {
269 	BraseroScsiTocPmaAtipHdr hdr	[1];
270 	BraseroScsiRawTocDesc desc	[0];
271 };
272 typedef struct _BraseroScsiRawTocData BraseroScsiRawTocData;
273 
274 /* multiple pma descriptors may be returned */
275 struct _BraseroScsiPmaData {
276 	BraseroScsiTocPmaAtipHdr hdr	[1];
277 	BraseroScsiPmaDesc desc		[0];
278 };
279 typedef struct _BraseroScsiPmaData BraseroScsiPmaData;
280 
281 struct _BraseroScsiAtipData {
282 	BraseroScsiTocPmaAtipHdr hdr	[1];
283 	BraseroScsiAtipDesc desc	[1];
284 };
285 typedef struct _BraseroScsiAtipData BraseroScsiAtipData;
286 
287 struct _BraseroScsiMultisessionData {
288 	BraseroScsiTocPmaAtipHdr hdr	[1];
289 	BraseroScsiTocDesc desc		[1];
290 };
291 typedef struct _BraseroScsiMultisessionData BraseroScsiMultisessionData;
292 
293 /* Inside a language block, packs must be recorded in that order */
294 typedef enum {
295 BRASERO_SCSI_CD_TEXT_ALBUM_TITLE	= 0x80,
296 BRASERO_SCSI_CD_TEXT_PERFORMER_NAME	= 0x81,
297 BRASERO_SCSI_CD_TEXT_SONGWRITER_NAME	= 0x82,
298 BRASERO_SCSI_CD_TEXT_COMPOSER_NAME	= 0x83,
299 BRASERO_SCSI_CD_TEXT_ARRANGER_NAME	= 0x84,
300 BRASERO_SCSI_CD_TEXT_ARTIST_NAME	= 0x85,
301 BRASERO_SCSI_CD_TEXT_DISC_ID_INFO	= 0x86,
302 BRASERO_SCSI_CD_TEXT_GENRE_ID_INFO	= 0x87,
303 BRASERO_SCSI_CD_TEXT_TOC_1		= 0x88,
304 BRASERO_SCSI_CD_TEXT_TOC_2		= 0x89,
305 BRASERO_SCSI_CD_TEXT_RESERVED_1		= 0x8A,
306 BRASERO_SCSI_CD_TEXT_RESERVED_2		= 0x8B,
307 BRASERO_SCSI_CD_TEXT_RESERVED_3		= 0x8C,
308 BRASERO_SCSI_CD_TEXT_RESERVED_CONTENT	= 0x8D,
309 BRASERO_SCSI_CD_TEXT_UPC_EAN_ISRC	= 0x8E,
310 BRASERO_SCSI_CD_TEXT_BLOCK_SIZE		= 0x8F,
311 } BraseroScsiCDTextPackType;
312 
313 typedef enum {
314 	BRASERO_CD_TEXT_8859_1		= 0x00,
315 	BRASERO_CD_TEXT_ASCII		= 0x01,	/* (7 bit)	*/
316 
317 	/* Reserved */
318 
319 	BRASERO_CD_TEXT_KANJI		= 0x80,
320 	BRASERO_CD_TEXT_KOREAN		= 0x81,
321 	BRASERO_CD_TEXT_CHINESE		= 0x82	/* Mandarin */
322 } BraseroScsiCDTextCharset;
323 
324 struct _BraseroScsiCDTextPackData {
325 	uchar type;
326 	uchar track_num;
327 	uchar pack_num;
328 
329 	uchar char_pos			:4;	/* byte not used for type 0x8F */
330 	uchar block_num			:3;
331 	uchar double_byte		:1;
332 
333 	uchar text			[12];
334 	uchar crc			[2];
335 };
336 typedef struct _BraseroScsiCDTextPackData BraseroScsiCDTextPackData;
337 
338 /* Takes two BraseroScsiCDTextPackData (18 bytes) 3 x 12 = 36 bytes */
339 struct _BraseroScsiCDTextPackCharset {
340 	char charset;
341 	char first_track;
342 	char last_track;
343 	char copyr_flags;
344 	char pack_count [16];
345 	char last_seqnum [8];
346 	char language_code [8];
347 };
348 typedef struct _BraseroScsiCDTextPackCharset BraseroScsiCDTextPackCharset;
349 
350 struct _BraseroScsiCDTextData {
351 	BraseroScsiTocPmaAtipHdr hdr	[1];
352 	BraseroScsiCDTextPackData pack	[0];
353 };
354 typedef struct _BraseroScsiCDTextData BraseroScsiCDTextData;
355 
356 #define BRASERO_SCSI_TRACK_LEADOUT_START	0xAA
357 
358 G_END_DECLS
359 
360 #endif /* _SCSI_READ_TOC_PMA_ATIP_H */
361