blob: a04d0b3a249c44be72e73473069343f4994385ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
/*
* Definitions for a Sony interface CDROM drive.
*
* Corey Minyard (minyard@wf-rch.cirr.com)
*
* Copyright (C) 1993 Corey Minyard
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/*
* General defines.
*/
#define SONY_XA_DISK_TYPE 0x20
/*
* Offsets (from the base address) and bits for the various write registers
* of the drive.
*/
#define SONY_CMD_REG_OFFSET 0
#define SONY_PARAM_REG_OFFSET 1
#define SONY_WRITE_REG_OFFSET 2
#define SONY_CONTROL_REG_OFFSET 3
# define SONY_ATTN_CLR_BIT 0x01
# define SONY_RES_RDY_CLR_BIT 0x02
# define SONY_DATA_RDY_CLR_BIT 0x04
# define SONY_ATTN_INT_EN_BIT 0x08
# define SONY_RES_RDY_INT_EN_BIT 0x10
# define SONY_DATA_RDY_INT_EN_BIT 0x20
# define SONY_PARAM_CLR_BIT 0x40
# define SONY_DRIVE_RESET_BIT 0x80
/*
* Offsets (from the base address) and bits for the various read registers
* of the drive.
*/
#define SONY_STATUS_REG_OFFSET 0
# define SONY_ATTN_BIT 0x01
# define SONY_RES_RDY_BIT 0x02
# define SONY_DATA_RDY_BIT 0x04
# define SONY_ATTN_INT_ST_BIT 0x08
# define SONY_RES_RDY_INT_ST_BIT 0x10
# define SONY_DATA_RDY_INT_ST_BIT 0x20
# define SONY_DATA_REQUEST_BIT 0x40
# define SONY_BUSY_BIT 0x80
#define SONY_RESULT_REG_OFFSET 1
#define SONY_READ_REG_OFFSET 2
#define SONY_FIFOST_REG_OFFSET 3
# define SONY_PARAM_WRITE_RDY_BIT 0x01
# define SONY_PARAM_REG_EMPTY_BIT 0x02
# define SONY_RES_REG_NOT_EMP_BIT 0x04
# define SONY_RES_REG_FULL_BIT 0x08
#define LOG_START_OFFSET 150 /* Offset of first logical sector */
#define SONY_DETECT_TIMEOUT (8*HZ/10) /* Maximum amount of time
that drive detection code
will wait for response
from drive (in 1/100th's
of seconds). */
#define SONY_JIFFIES_TIMEOUT 1000 /* Maximum number of times the
drive will wait/try for an
operation */
#define SONY_RESET_TIMEOUT 100 /* Maximum number of times the
drive will wait/try a reset
operation */
#define SONY_READY_RETRIES 20000 /* How many times to retry a
spin waiting for a register
to come ready */
#define MAX_CDU31A_RETRIES 3 /* How many times to retry an
operation */
/* Commands to request or set drive control parameters and disc information */
#define SONY_REQ_DRIVE_CONFIG_CMD 0x00 /* Returns s_sony_drive_config */
#define SONY_REQ_DRIVE_MODE_CMD 0x01
#define SONY_REQ_DRIVE_PARAM_CMD 0x02
#define SONY_REQ_MECH_STATUS_CMD 0x03
#define SONY_REQ_AUDIO_STATUS_CMD 0x04
#define SONY_SET_DRIVE_PARAM_CMD 0x10
#define SONY_REQ_TOC_DATA_CMD 0x20 /* Returns s_sony_toc */
#define SONY_REQ_SUBCODE_ADDRESS_CMD 0x21 /* Returns s_sony_subcode */
#define SONY_REQ_UPC_EAN_CMD 0x22
#define SONY_REQ_ISRC_CMD 0x23
#define SONY_REQ_TOC_DATA_SPEC_CMD 0x24 /* Returns s_sony_session_toc */
/* Commands to request information from the drive */
#define SONY_READ_TOC_CMD 0x30 /* let the drive firmware grab the TOC */
#define SONY_SEEK_CMD 0x31
#define SONY_READ_CMD 0x32
#define SONY_READ_BLKERR_STAT_CMD 0x34
#define SONY_ABORT_CMD 0x35
#define SONY_READ_TOC_SPEC_CMD 0x36
/* Commands to control audio */
#define SONY_AUDIO_PLAYBACK_CMD 0x40
#define SONY_AUDIO_STOP_CMD 0x41
#define SONY_AUDIO_SCAN_CMD 0x42
/* Miscellaneous control commands */
#define SONY_EJECT_CMD 0x50
#define SONY_SPIN_UP_CMD 0x51
#define SONY_SPIN_DOWN_CMD 0x52
/* Diagnostic commands */
#define SONY_WRITE_BUFFER_CMD 0x60
#define SONY_READ_BUFFER_CMD 0x61
#define SONY_DIAGNOSTICS_CMD 0x62
/*
* The following are command parameters for the set drive parameter command
*/
#define SONY_SD_DECODE_PARAM 0x00
#define SONY_SD_INTERFACE_PARAM 0x01
#define SONY_SD_BUFFERING_PARAM 0x02
#define SONY_SD_AUDIO_PARAM 0x03
#define SONY_SD_AUDIO_VOLUME 0x04
#define SONY_SD_MECH_CONTROL 0x05
#define SONY_SD_AUTO_SPIN_DOWN_TIME 0x06
/*
* The following are parameter bits for the mechanical control command
*/
#define SONY_AUTO_SPIN_UP_BIT 0x01
#define SONY_AUTO_EJECT_BIT 0x02
#define SONY_DOUBLE_SPEED_BIT 0x04
/*
* The following extract information from the drive configuration about
* the drive itself.
*/
#define SONY_HWC_GET_LOAD_MECH(c) (c.hw_config[0] & 0x03)
#define SONY_HWC_EJECT(c) (c.hw_config[0] & 0x04)
#define SONY_HWC_LED_SUPPORT(c) (c.hw_config[0] & 0x08)
#define SONY_HWC_DOUBLE_SPEED(c) (c.hw_config[0] & 0x10)
#define SONY_HWC_GET_BUF_MEM_SIZE(c) ((c.hw_config[0] & 0xc0) >> 6)
#define SONY_HWC_AUDIO_PLAYBACK(c) (c.hw_config[1] & 0x01)
#define SONY_HWC_ELECTRIC_VOLUME(c) (c.hw_config[1] & 0x02)
#define SONY_HWC_ELECTRIC_VOLUME_CTL(c) (c.hw_config[1] & 0x04)
#define SONY_HWC_CADDY_LOAD_MECH 0x00
#define SONY_HWC_TRAY_LOAD_MECH 0x01
#define SONY_HWC_POPUP_LOAD_MECH 0x02
#define SONY_HWC_UNKWN_LOAD_MECH 0x03
#define SONY_HWC_8KB_BUFFER 0x00
#define SONY_HWC_32KB_BUFFER 0x01
#define SONY_HWC_64KB_BUFFER 0x02
#define SONY_HWC_UNKWN_BUFFER 0x03
/*
* This is the complete status returned from the drive configuration request
* command.
*/
struct s_sony_drive_config
{
unsigned char exec_status[2];
char vendor_id[8];
char product_id[16];
char product_rev_level[8];
unsigned char hw_config[2];
};
/* The following is returned from the request subcode address command */
struct s_sony_subcode
{
unsigned char exec_status[2];
unsigned char address :4;
unsigned char control :4;
unsigned char track_num;
unsigned char index_num;
unsigned char rel_msf[3];
unsigned char reserved1;
unsigned char abs_msf[3];
};
#define MAX_TRACKS 100 /* The maximum tracks a disk may have. */
/*
* The following is returned from the request TOC (Table Of Contents) command.
* (last_track_num-first_track_num+1) values are valid in tracks.
*/
struct s_sony_toc
{
unsigned char exec_status[2];
unsigned char address0 :4;
unsigned char control0 :4;
unsigned char point0;
unsigned char first_track_num;
unsigned char disk_type;
unsigned char dummy0;
unsigned char address1 :4;
unsigned char control1 :4;
unsigned char point1;
unsigned char last_track_num;
unsigned char dummy1;
unsigned char dummy2;
unsigned char address2 :4;
unsigned char control2 :4;
unsigned char point2;
unsigned char lead_out_start_msf[3];
struct
{
unsigned char address :4;
unsigned char control :4;
unsigned char track;
unsigned char track_start_msf[3];
} tracks[MAX_TRACKS];
unsigned int lead_out_start_lba;
};
struct s_sony_session_toc
{
unsigned char exec_status[2];
unsigned char session_number;
unsigned char address0 :4;
unsigned char control0 :4;
unsigned char point0;
unsigned char first_track_num;
unsigned char disk_type;
unsigned char dummy0;
unsigned char address1 :4;
unsigned char control1 :4;
unsigned char point1;
unsigned char last_track_num;
unsigned char dummy1;
unsigned char dummy2;
unsigned char address2 :4;
unsigned char control2 :4;
unsigned char point2;
unsigned char lead_out_start_msf[3];
unsigned char addressb0 :4;
unsigned char controlb0 :4;
unsigned char pointb0;
unsigned char next_poss_prog_area_msf[3];
unsigned char num_mode_5_pointers;
unsigned char max_start_outer_leadout_msf[3];
unsigned char addressb1 :4;
unsigned char controlb1 :4;
unsigned char pointb1;
unsigned char dummyb0_1[4];
unsigned char num_skip_interval_pointers;
unsigned char num_skip_track_assignments;
unsigned char dummyb0_2;
unsigned char addressb2 :4;
unsigned char controlb2 :4;
unsigned char pointb2;
unsigned char tracksb2[7];
unsigned char addressb3 :4;
unsigned char controlb3 :4;
unsigned char pointb3;
unsigned char tracksb3[7];
unsigned char addressb4 :4;
unsigned char controlb4 :4;
unsigned char pointb4;
unsigned char tracksb4[7];
unsigned char addressc0 :4;
unsigned char controlc0 :4;
unsigned char pointc0;
unsigned char dummyc0[7];
struct
{
unsigned char address :4;
unsigned char control :4;
unsigned char track;
unsigned char track_start_msf[3];
} tracks[MAX_TRACKS];
unsigned int start_track_lba;
unsigned int lead_out_start_lba;
unsigned int mint;
unsigned int maxt;
};
struct s_all_sessions_toc
{
unsigned char sessions;
unsigned int track_entries;
unsigned char first_track_num;
unsigned char last_track_num;
unsigned char disk_type;
unsigned char lead_out_start_msf[3];
struct
{
unsigned char address :4;
unsigned char control :4;
unsigned char track;
unsigned char track_start_msf[3];
} tracks[MAX_TRACKS];
unsigned int start_track_lba;
unsigned int lead_out_start_lba;
};
/*
* The following are errors returned from the drive.
*/
/* Command error group */
#define SONY_ILL_CMD_ERR 0x10
#define SONY_ILL_PARAM_ERR 0x11
/* Mechanism group */
#define SONY_NOT_LOAD_ERR 0x20
#define SONY_NO_DISK_ERR 0x21
#define SONY_NOT_SPIN_ERR 0x22
#define SONY_SPIN_ERR 0x23
#define SONY_SPINDLE_SERVO_ERR 0x25
#define SONY_FOCUS_SERVO_ERR 0x26
#define SONY_EJECT_MECH_ERR 0x29
#define SONY_AUDIO_PLAYING_ERR 0x2a
#define SONY_EMERGENCY_EJECT_ERR 0x2c
/* Seek error group */
#define SONY_FOCUS_ERR 0x30
#define SONY_FRAME_SYNC_ERR 0x31
#define SONY_SUBCODE_ADDR_ERR 0x32
#define SONY_BLOCK_SYNC_ERR 0x33
#define SONY_HEADER_ADDR_ERR 0x34
/* Read error group */
#define SONY_ILL_TRACK_R_ERR 0x40
#define SONY_MODE_0_R_ERR 0x41
#define SONY_ILL_MODE_R_ERR 0x42
#define SONY_ILL_BLOCK_SIZE_R_ERR 0x43
#define SONY_MODE_R_ERR 0x44
#define SONY_FORM_R_ERR 0x45
#define SONY_LEAD_OUT_R_ERR 0x46
#define SONY_BUFFER_OVERRUN_R_ERR 0x47
/* Data error group */
#define SONY_UNREC_CIRC_ERR 0x53
#define SONY_UNREC_LECC_ERR 0x57
/* Subcode error group */
#define SONY_NO_TOC_ERR 0x60
#define SONY_SUBCODE_DATA_NVAL_ERR 0x61
#define SONY_FOCUS_ON_TOC_READ_ERR 0x63
#define SONY_FRAME_SYNC_ON_TOC_READ_ERR 0x64
#define SONY_TOC_DATA_ERR 0x65
/* Hardware failure group */
#define SONY_HW_FAILURE_ERR 0x70
#define SONY_LEAD_IN_A_ERR 0x91
#define SONY_LEAD_OUT_A_ERR 0x92
#define SONY_DATA_TRACK_A_ERR 0x93
/*
* The following are returned from the Read With Block Error Status command.
* They are not errors but information (Errors from the 0x5x group above may
* also be returned
*/
#define SONY_NO_CIRC_ERR_BLK_STAT 0x50
#define SONY_NO_LECC_ERR_BLK_STAT 0x54
#define SONY_RECOV_LECC_ERR_BLK_STAT 0x55
#define SONY_NO_ERR_DETECTION_STAT 0x59
/*
* The following is not an error returned by the drive, but by the code
* that talks to the drive. It is returned because of a timeout.
*/
#define SONY_TIMEOUT_OP_ERR 0x01
#define SONY_SIGNAL_OP_ERR 0x02
#define SONY_BAD_DATA_ERR 0x03
/*
* The following are attention code for asynchronous events from the drive.
*/
/* Standard attention group */
#define SONY_EMER_EJECT_ATTN 0x2c
#define SONY_HW_FAILURE_ATTN 0x70
#define SONY_MECH_LOADED_ATTN 0x80
#define SONY_EJECT_PUSHED_ATTN 0x81
/* Audio attention group */
#define SONY_AUDIO_PLAY_DONE_ATTN 0x90
#define SONY_LEAD_IN_ERR_ATTN 0x91
#define SONY_LEAD_OUT_ERR_ATTN 0x92
#define SONY_DATA_TRACK_ERR_ATTN 0x93
#define SONY_AUDIO_PLAYBACK_ERR_ATTN 0x94
/* Auto spin up group */
#define SONY_SPIN_UP_COMPLETE_ATTN 0x24
#define SONY_SPINDLE_SERVO_ERR_ATTN 0x25
#define SONY_FOCUS_SERVO_ERR_ATTN 0x26
#define SONY_TOC_READ_DONE_ATTN 0x62
#define SONY_FOCUS_ON_TOC_READ_ERR_ATTN 0x63
#define SONY_SYNC_ON_TOC_READ_ERR_ATTN 0x65
/* Auto eject group */
#define SONY_SPIN_DOWN_COMPLETE_ATTN 0x27
#define SONY_EJECT_COMPLETE_ATTN 0x28
#define SONY_EJECT_MECH_ERR_ATTN 0x29
|