1 /* @(#)drv_philips.c	1.82 10/12/19 Copyright 1997-2010 J. Schilling */
2 #include <schily/mconfig.h>
3 #ifndef lint
4 static	UConst char sccsid[] =
5 	"@(#)drv_philips.c	1.82 10/12/19 Copyright 1997-2010 J. Schilling";
6 #endif
7 /*
8  *	CDR device implementation for
9  *	Philips/Yamaha/Ricoh/Plasmon
10  *
11  *	Copyright (c) 1997-2010 J. Schilling
12  */
13 /*
14  * The contents of this file are subject to the terms of the
15  * Common Development and Distribution License, Version 1.0 only
16  * (the "License").  You may not use this file except in compliance
17  * with the License.
18  *
19  * See the file CDDL.Schily.txt in this distribution for details.
20  * A copy of the CDDL is also available via the Internet at
21  * http://www.opensource.org/licenses/cddl1.txt
22  *
23  * When distributing Covered Code, include this CDDL HEADER in each
24  * file and include the License file CDDL.Schily.txt from this distribution.
25  */
26 
27 #include <schily/mconfig.h>
28 
29 #include <schily/stdio.h>
30 #include <schily/unistd.h>	/* Include sys/types.h to make off_t available */
31 #include <schily/standard.h>
32 #include <schily/intcvt.h>
33 #include <schily/schily.h>
34 #include <schily/nlsdefs.h>
35 
36 #include <scg/scsireg.h>
37 #include <scg/scsitransp.h>
38 #include <scg/scgcmd.h>
39 #include <scg/scsidefs.h>	/* XXX Only for DEV_RICOH_RO_1060C */
40 
41 #include "cdrecord.h"
42 
43 extern	int	debug;
44 extern	int	lverbose;
45 
46 LOCAL	int	load_unload_philips		__PR((SCSI *scgp, int));
47 LOCAL	int	philips_load			__PR((SCSI *scgp, cdr_t *dp));
48 LOCAL	int	philips_unload			__PR((SCSI *scgp, cdr_t *dp));
49 LOCAL	int	philips_dumbload		__PR((SCSI *scgp, cdr_t *dp));
50 LOCAL	int	philips_dumbunload		__PR((SCSI *scgp, cdr_t *dp));
51 LOCAL	int	plasmon_buf			__PR((SCSI *, long *, long *));
52 LOCAL	int	recover_philips			__PR((SCSI *scgp, cdr_t *dp, int));
53 LOCAL	int	speed_select_yamaha		__PR((SCSI *scgp, cdr_t *dp, int *speedp));
54 LOCAL	int	speed_select_philips		__PR((SCSI *scgp, cdr_t *dp, int *speedp));
55 LOCAL	int	speed_select_oldphilips		__PR((SCSI *scgp, cdr_t *dp, int *speedp));
56 LOCAL	int	speed_select_dumbphilips	__PR((SCSI *scgp, cdr_t *dp, int *speedp));
57 LOCAL	int	speed_select_pioneer		__PR((SCSI *scgp, cdr_t *dp, int *speedp));
58 LOCAL	int	philips_init			__PR((SCSI *scgp, cdr_t *dp));
59 LOCAL	int	philips_getdisktype		__PR((SCSI *scgp, cdr_t *dp));
60 LOCAL	BOOL	capacity_philips		__PR((SCSI *scgp, long *lp));
61 LOCAL	int	first_writable_addr_philips	__PR((SCSI *scgp, long *, int, int, int, int));
62 LOCAL	int	next_wr_addr_philips		__PR((SCSI *scgp, track_t *trackp, long *ap));
63 LOCAL	int	reserve_track_philips		__PR((SCSI *scgp, unsigned long));
64 LOCAL	int	scsi_cdr_write_philips		__PR((SCSI *scgp, caddr_t bp, long sectaddr, long size, int blocks, BOOL islast));
65 LOCAL	int	write_track_info_philips	__PR((SCSI *scgp, int));
66 LOCAL	int	write_track_philips		__PR((SCSI *scgp, long, int));
67 LOCAL	int	open_track_philips		__PR((SCSI *scgp, cdr_t *dp, track_t *trackp));
68 LOCAL	int	open_track_plasmon		__PR((SCSI *scgp, cdr_t *dp, track_t *trackp));
69 LOCAL	int	open_track_oldphilips		__PR((SCSI *scgp, cdr_t *dp, track_t *trackp));
70 LOCAL	int	open_track_yamaha		__PR((SCSI *scgp, cdr_t *dp, track_t *trackp));
71 LOCAL	int	close_track_philips		__PR((SCSI *scgp, cdr_t *dp, track_t *trackp));
72 LOCAL	int	fixation_philips		__PR((SCSI *scgp, cdr_t *dp, track_t *trackp));
73 
74 LOCAL	int	philips_attach			__PR((SCSI *scgp, cdr_t *));
75 LOCAL	int	plasmon_attach			__PR((SCSI *scgp, cdr_t *));
76 LOCAL	int	ricoh_attach			__PR((SCSI *scgp, cdr_t *));
77 LOCAL	int	philips_getlilo			__PR((SCSI *scgp, long *lilenp, long *lolenp));
78 
79 
80 struct cdd_52x_mode_page_21 {	/* write track information */
81 		MP_P_CODE;		/* parsave & pagecode */
82 	Uchar	p_len;			/* 0x0E = 14 Bytes */
83 	Uchar	res_2;
84 	Uchar	sectype;
85 	Uchar	track;
86 	Uchar	ISRC[9];
87 	Uchar	res[2];
88 };
89 
90 struct cdd_52x_mode_page_23 {	/* speed selection */
91 		MP_P_CODE;		/* parsave & pagecode */
92 	Uchar	p_len;			/* 0x06 = 6 Bytes */
93 	Uchar	speed;
94 	Uchar	dummy;
95 	Uchar	res[4];
96 
97 };
98 
99 #if defined(_BIT_FIELDS_LTOH)	/* Intel byteorder */
100 
101 struct yamaha_mode_page_31 {	/* drive configuration */
102 		MP_P_CODE;		/* parsave & pagecode */
103 	Uchar	p_len;			/* 0x02 = 2 Bytes */
104 	Uchar	res;
105 	Ucbit	dummy		: 4;
106 	Ucbit	speed		: 4;
107 };
108 
109 #else				/* Motorola byteorder */
110 
111 struct yamaha_mode_page_31 {	/* drive configuration */
112 		MP_P_CODE;		/* parsave & pagecode */
113 	Uchar	p_len;			/* 0x02 = 2 Bytes */
114 	Uchar	res;
115 	Ucbit	speed		: 4;
116 	Ucbit	dummy		: 4;
117 };
118 #endif
119 
120 struct cdd_52x_mode_data {
121 	struct scsi_mode_header	header;
122 	union cdd_pagex	{
123 		struct cdd_52x_mode_page_21	page21;
124 		struct cdd_52x_mode_page_23	page23;
125 		struct yamaha_mode_page_31	page31;
126 	} pagex;
127 };
128 
129 
130 cdr_t	cdr_philips_cdd521O = {
131 	0, 0, 0,
132 	CDR_TAO|CDR_TRAYLOAD,
133 	0,
134 	CDR_CDRW_NONE,
135 	WM_TAO,
136 	2, 2,
137 	"philips_cdd521_old",
138 	"driver for Philips old CDD-521",
139 	0,
140 	(dstat_t *)0,
141 	drive_identify,
142 	philips_attach,
143 	philips_init,
144 	philips_getdisktype,
145 	no_diskstatus,
146 	philips_load,
147 	philips_unload,
148 	buf_dummy,
149 	recovery_needed,
150 	recover_philips,
151 	speed_select_oldphilips,
152 	select_secsize,
153 	next_wr_addr_philips,
154 	reserve_track_philips,
155 	scsi_cdr_write_philips,
156 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
157 	no_sendcue,
158 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
159 	open_track_oldphilips,
160 	close_track_philips,
161 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
162 	cmd_dummy,
163 	cmd_dummy,					/* abort	*/
164 	read_session_offset_philips,
165 	fixation_philips,
166 	cmd_dummy,					/* stats	*/
167 	blank_dummy,
168 	format_dummy,
169 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
170 	cmd_dummy,					/* opt1		*/
171 	cmd_dummy,					/* opt2		*/
172 };
173 
174 cdr_t	cdr_philips_dumb = {
175 	0, 0, 0,
176 	CDR_TAO|CDR_TRAYLOAD,
177 	0,
178 	CDR_CDRW_NONE,
179 	WM_TAO,
180 	2, 2,
181 	"philips_dumb",
182 	"driver for Philips CDD-521 with pessimistic assumptions",
183 	0,
184 	(dstat_t *)0,
185 	drive_identify,
186 	philips_attach,
187 	philips_init,
188 	philips_getdisktype,
189 	no_diskstatus,
190 	philips_dumbload,
191 	philips_dumbunload,
192 	buf_dummy,
193 	recovery_needed,
194 	recover_philips,
195 	speed_select_dumbphilips,
196 	select_secsize,
197 	next_wr_addr_philips,
198 	reserve_track_philips,
199 	scsi_cdr_write_philips,
200 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
201 	no_sendcue,
202 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
203 	open_track_oldphilips,
204 	close_track_philips,
205 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
206 	cmd_dummy,
207 	cmd_dummy,					/* abort	*/
208 	read_session_offset_philips,
209 	fixation_philips,
210 	cmd_dummy,					/* stats	*/
211 	blank_dummy,
212 	format_dummy,
213 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
214 	cmd_dummy,					/* opt1		*/
215 	cmd_dummy,					/* opt2		*/
216 };
217 
218 cdr_t	cdr_philips_cdd521 = {
219 	0, 0, 0,
220 	CDR_TAO|CDR_TRAYLOAD,
221 	0,
222 	CDR_CDRW_NONE,
223 	WM_TAO,
224 	2, 2,
225 	"philips_cdd521",
226 	"driver for Philips CDD-521",
227 	0,
228 	(dstat_t *)0,
229 	drive_identify,
230 	philips_attach,
231 	philips_init,
232 	philips_getdisktype,
233 	no_diskstatus,
234 	philips_load,
235 	philips_unload,
236 	buf_dummy,
237 	recovery_needed,
238 	recover_philips,
239 	speed_select_philips,
240 	select_secsize,
241 	next_wr_addr_philips,
242 	reserve_track_philips,
243 	scsi_cdr_write_philips,
244 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
245 	no_sendcue,
246 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
247 	open_track_philips,
248 	close_track_philips,
249 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
250 	cmd_dummy,
251 	cmd_dummy,					/* abort	*/
252 	read_session_offset_philips,
253 	fixation_philips,
254 	cmd_dummy,					/* stats	*/
255 	blank_dummy,
256 	format_dummy,
257 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
258 	cmd_dummy,					/* opt1		*/
259 	cmd_dummy,					/* opt2		*/
260 };
261 
262 cdr_t	cdr_philips_cdd522 = {
263 	0, 0, 0,
264 /*	CDR_TAO|CDR_SAO|CDR_TRAYLOAD,*/
265 	CDR_TAO|CDR_TRAYLOAD,
266 	0,
267 	CDR_CDRW_NONE,
268 	WM_TAO,
269 	2, 2,
270 	"philips_cdd522",
271 	"driver for Philips CDD-522",
272 	0,
273 	(dstat_t *)0,
274 	drive_identify,
275 	philips_attach,
276 	philips_init,
277 	philips_getdisktype,
278 	no_diskstatus,
279 	philips_load,
280 	philips_unload,
281 	buf_dummy,
282 	recovery_needed,
283 	recover_philips,
284 	speed_select_philips,
285 	select_secsize,
286 	next_wr_addr_philips,
287 	reserve_track_philips,
288 	scsi_cdr_write_philips,
289 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
290 	no_sendcue,
291 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
292 	open_track_philips,
293 	close_track_philips,
294 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
295 	cmd_dummy,
296 	cmd_dummy,					/* abort	*/
297 	read_session_offset_philips,
298 	fixation_philips,
299 	cmd_dummy,					/* stats	*/
300 	blank_dummy,
301 	format_dummy,
302 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
303 	cmd_dummy,					/* opt1		*/
304 	cmd_dummy,					/* opt2		*/
305 };
306 
307 cdr_t	cdr_tyuden_ew50 = {
308 	0, 0, 0,
309 	CDR_TAO|CDR_TRAYLOAD|CDR_SWABAUDIO,
310 	0,
311 	CDR_CDRW_NONE,
312 	WM_TAO,
313 	2, 2,
314 	"tyuden_ew50",
315 	"driver for Taiyo Yuden EW-50",
316 	0,
317 	(dstat_t *)0,
318 	drive_identify,
319 	philips_attach,
320 	philips_init,
321 	philips_getdisktype,
322 	no_diskstatus,
323 	philips_load,
324 	philips_unload,
325 	buf_dummy,
326 	recovery_needed,
327 	recover_philips,
328 	speed_select_philips,
329 	select_secsize,
330 	next_wr_addr_philips,
331 	reserve_track_philips,
332 	scsi_cdr_write_philips,
333 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
334 	no_sendcue,
335 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
336 	open_track_philips,
337 	close_track_philips,
338 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
339 	cmd_dummy,
340 	cmd_dummy,					/* abort	*/
341 	read_session_offset_philips,
342 	fixation_philips,
343 	cmd_dummy,					/* stats	*/
344 	blank_dummy,
345 	format_dummy,
346 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
347 	cmd_dummy,					/* opt1		*/
348 	cmd_dummy,					/* opt2		*/
349 };
350 
351 cdr_t	cdr_kodak_pcd600 = {
352 	0, 0, 0,
353 	CDR_TAO|CDR_TRAYLOAD,
354 	0,
355 	CDR_CDRW_NONE,
356 	WM_TAO,
357 	6, 6,
358 	"kodak_pcd_600",
359 	"driver for Kodak PCD-600",
360 	0,
361 	(dstat_t *)0,
362 	drive_identify,
363 	philips_attach,
364 	philips_init,
365 	philips_getdisktype,
366 	no_diskstatus,
367 	philips_load,
368 	philips_unload,
369 	buf_dummy,
370 	recovery_needed,
371 	recover_philips,
372 	speed_select_philips,
373 	select_secsize,
374 	next_wr_addr_philips,
375 	reserve_track_philips,
376 	scsi_cdr_write_philips,
377 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
378 	no_sendcue,
379 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
380 	open_track_oldphilips,
381 	close_track_philips,
382 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
383 	cmd_dummy,
384 	cmd_dummy,					/* abort	*/
385 	read_session_offset_philips,
386 	fixation_philips,
387 	cmd_dummy,					/* stats	*/
388 	blank_dummy,
389 	format_dummy,
390 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
391 	cmd_dummy,					/* opt1		*/
392 	cmd_dummy,					/* opt2		*/
393 };
394 
395 cdr_t	cdr_plasmon_rf4100 = {
396 	0, 0, 0,
397 	CDR_TAO|CDR_TRAYLOAD,
398 	0,
399 	CDR_CDRW_NONE,
400 	WM_TAO,
401 	2, 4,
402 	"plasmon_rf4100",
403 	"driver for Plasmon RF 4100",
404 	0,
405 	(dstat_t *)0,
406 	drive_identify,
407 	plasmon_attach,
408 	philips_init,
409 	philips_getdisktype,
410 	no_diskstatus,
411 	philips_load,
412 	philips_unload,
413 	plasmon_buf,
414 	recovery_needed,
415 	recover_philips,
416 	speed_select_philips,
417 	select_secsize,
418 	next_wr_addr_philips,
419 	reserve_track_philips,
420 	scsi_cdr_write_philips,
421 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
422 	no_sendcue,
423 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
424 	open_track_plasmon,
425 	close_track_philips,
426 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
427 	cmd_dummy,
428 	cmd_dummy,					/* abort	*/
429 	read_session_offset_philips,
430 	fixation_philips,
431 	cmd_dummy,					/* stats	*/
432 	blank_dummy,
433 	format_dummy,
434 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
435 	cmd_dummy,					/* opt1		*/
436 	cmd_dummy,					/* opt2		*/
437 };
438 
439 cdr_t	cdr_pioneer_dw_s114x = {
440 	0, 0, 0,
441 	CDR_TAO|CDR_TRAYLOAD|CDR_SWABAUDIO,
442 	0,
443 	CDR_CDRW_NONE,
444 	WM_TAO,
445 	2, 4,
446 	"pioneer_dws114x",
447 	"driver for Pioneer DW-S114X",
448 	0,
449 	(dstat_t *)0,
450 	drive_identify,
451 	philips_attach,
452 	philips_init,
453 	philips_getdisktype,
454 	no_diskstatus,
455 	scsi_load,
456 	scsi_unload,
457 	buf_dummy,
458 	recovery_needed,
459 	recover_philips,
460 	speed_select_pioneer,
461 	select_secsize,
462 	next_wr_addr_philips,
463 	reserve_track_philips,
464 	scsi_cdr_write_philips,
465 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
466 	no_sendcue,
467 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
468 /*	open_track_yamaha,*/
469 /*???*/	open_track_oldphilips,
470 	close_track_philips,
471 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
472 	cmd_dummy,
473 	cmd_dummy,					/* abort	*/
474 	read_session_offset_philips,
475 	fixation_philips,
476 	cmd_dummy,					/* stats	*/
477 	blank_dummy,
478 	format_dummy,
479 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
480 	cmd_dummy,					/* opt1		*/
481 	cmd_dummy,					/* opt2		*/
482 };
483 
484 cdr_t	cdr_yamaha_cdr100 = {
485 	0, 0, 0,
486 /*	CDR_TAO|CDR_SAO|CDR_CADDYLOAD|CDR_SWABAUDIO,*/
487 	CDR_TAO|CDR_CADDYLOAD|CDR_SWABAUDIO,
488 	0,
489 	CDR_CDRW_NONE,
490 	WM_TAO,
491 	2, 4,
492 	"yamaha_cdr100",
493 	"driver for Yamaha CDR-100 / CDR-102",
494 	0,
495 	(dstat_t *)0,
496 	drive_identify,
497 	philips_attach,
498 	philips_init,
499 	drive_getdisktype,
500 	no_diskstatus,
501 	scsi_load,
502 	philips_unload,
503 	buf_dummy,
504 	recovery_needed,
505 	recover_philips,
506 	speed_select_yamaha,
507 	select_secsize,
508 	next_wr_addr_philips,
509 	reserve_track_philips,
510 	scsi_cdr_write_philips,
511 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
512 	no_sendcue,
513 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
514 	open_track_yamaha,
515 	close_track_philips,
516 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
517 	cmd_dummy,
518 	cmd_dummy,					/* abort	*/
519 	read_session_offset_philips,
520 	fixation_philips,
521 	cmd_dummy,					/* stats	*/
522 	blank_dummy,
523 	format_dummy,
524 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
525 	cmd_dummy,					/* opt1		*/
526 	cmd_dummy,					/* opt2		*/
527 };
528 
529 cdr_t	cdr_ricoh_ro1060 = {
530 	0, 0, 0,
531 /*	CDR_TAO|CDR_SAO|CDR_CADDYLOAD,*/
532 	CDR_TAO|CDR_CADDYLOAD,
533 	0,
534 	CDR_CDRW_NONE,
535 	WM_TAO,
536 	2, 2,
537 	"ricoh_ro1060c",
538 	"driver for Ricoh RO-1060C",
539 	0,
540 	(dstat_t *)0,
541 	drive_identify,
542 	ricoh_attach,
543 	philips_init,
544 	philips_getdisktype,
545 	no_diskstatus,
546 	scsi_load,
547 	scsi_unload,
548 	buf_dummy,
549 	recovery_needed,
550 	recover_philips,
551 	speed_select_yamaha,
552 	select_secsize,
553 	next_wr_addr_philips,
554 	reserve_track_philips,
555 	scsi_cdr_write_philips,
556 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
557 	no_sendcue,
558 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
559 	open_track_philips,
560 	close_track_philips,
561 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
562 	cmd_dummy,
563 	cmd_dummy,					/* abort	*/
564 	read_session_offset_philips,
565 	fixation_philips,
566 	cmd_dummy,					/* stats	*/
567 	blank_dummy,
568 	format_dummy,
569 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
570 	cmd_dummy,					/* opt1		*/
571 	cmd_dummy,					/* opt2		*/
572 };
573 
574 cdr_t	cdr_ricoh_ro1420 = {
575 	0, 0, 0,
576 /*	CDR_TAO|CDR_SAO|CDR_CADDYLOAD,*/
577 	CDR_TAO|CDR_CADDYLOAD,
578 	0,
579 	CDR_CDRW_NONE,
580 	WM_TAO,
581 	2, 2,
582 	"ricoh_ro1420c",
583 	"driver for Ricoh RO-1420C",
584 	0,
585 	(dstat_t *)0,
586 	drive_identify,
587 	ricoh_attach,
588 	philips_init,
589 	philips_getdisktype,
590 	no_diskstatus,
591 	scsi_load,
592 	scsi_unload,
593 	buf_dummy,
594 	recovery_needed,
595 	recover_philips,
596 	speed_select_yamaha,
597 	select_secsize,
598 	next_wr_addr_philips,
599 	reserve_track_philips,
600 	scsi_cdr_write_philips,
601 	(int(*)__PR((track_t *, void *, BOOL)))cmd_dummy,	/* gen_cue */
602 	no_sendcue,
603 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy, /* leadin */
604 	open_track_philips,
605 	close_track_philips,
606 	(int(*)__PR((SCSI *, cdr_t *, track_t *)))cmd_dummy,
607 	cmd_dummy,
608 	cmd_dummy,					/* abort	*/
609 	read_session_offset_philips,
610 	fixation_philips,
611 	cmd_dummy,					/* stats	*/
612 	blank_dummy,
613 	format_dummy,
614 	(int(*)__PR((SCSI *, caddr_t, int, int)))NULL,	/* no OPC	*/
615 	cmd_dummy,					/* opt1		*/
616 	cmd_dummy,					/* opt2		*/
617 };
618 
619 
620 LOCAL int
load_unload_philips(scgp,load)621 load_unload_philips(scgp, load)
622 	SCSI	*scgp;
623 	int	load;
624 {
625 	register struct	scg_cmd	*scmd = scgp->scmd;
626 
627 	fillbytes((caddr_t)scmd, sizeof (*scmd), '\0');
628 	scmd->flags = SCG_DISRE_ENA;
629 	scmd->cdb_len = SC_G1_CDBLEN;
630 	scmd->sense_len = CCS_SENSE_LEN;
631 	scmd->cdb.g1_cdb.cmd = 0xE7;
632 	scmd->cdb.g1_cdb.lun = scg_lun(scgp);
633 	scmd->cdb.g1_cdb.count[1] = !load;
634 
635 	scgp->cmdname = "philips medium load/unload";
636 
637 	if (scg_cmd(scgp) < 0)
638 		return (-1);
639 	return (0);
640 }
641 
642 LOCAL int
philips_load(scgp,dp)643 philips_load(scgp, dp)
644 	SCSI	*scgp;
645 	cdr_t	*dp;
646 {
647 	return (load_unload_philips(scgp, 1));
648 }
649 
650 LOCAL int
philips_unload(scgp,dp)651 philips_unload(scgp, dp)
652 	SCSI	*scgp;
653 	cdr_t	*dp;
654 {
655 	return (load_unload_philips(scgp, 0));
656 }
657 
658 LOCAL int
philips_dumbload(scgp,dp)659 philips_dumbload(scgp, dp)
660 	SCSI	*scgp;
661 	cdr_t	*dp;
662 {
663 	int	ret;
664 
665 	scgp->silent++;
666 	ret = load_unload_philips(scgp, 1);
667 	scgp->silent--;
668 	if (ret < 0)
669 		return (scsi_load(scgp, dp));
670 	return (0);
671 }
672 
673 LOCAL int
philips_dumbunload(scgp,dp)674 philips_dumbunload(scgp, dp)
675 	SCSI	*scgp;
676 	cdr_t	*dp;
677 {
678 	int	ret;
679 
680 	scgp->silent++;
681 	ret = load_unload_philips(scgp, 0);
682 	scgp->silent--;
683 	if (ret < 0)
684 		return (scsi_unload(scgp, dp));
685 	return (0);
686 }
687 
688 LOCAL int
plasmon_buf(scgp,sp,fp)689 plasmon_buf(scgp, sp, fp)
690 	SCSI	*scgp;
691 	long	*sp;	/* Size pointer */
692 	long	*fp;	/* Free space pointer */
693 {
694 	/*
695 	 * There's no way to obtain these values from the
696 	 * Plasmon RF41xx devices.  This function stub is only
697 	 * present to prevent cdrecord.c from calling the READ BUFFER
698 	 * SCSI cmd which is implemented non standard compliant in
699 	 * the Plasmon drive. Calling READ BUFFER would only jam the Plasmon
700 	 * as the non standard implementation in the Plasmon firmware
701 	 * expects different parameters.
702 	 */
703 
704 	if (sp)
705 		*sp = 0L;
706 	if (fp)
707 		*fp = 0L;
708 
709 	return (100);	/* 100 % */
710 }
711 
712 LOCAL int
recover_philips(scgp,dp,track)713 recover_philips(scgp, dp, track)
714 	SCSI	*scgp;
715 	cdr_t	*dp;
716 	int	track;
717 {
718 	register struct	scg_cmd	*scmd = scgp->scmd;
719 
720 	fillbytes((caddr_t)scmd, sizeof (*scmd), '\0');
721 	scmd->flags = SCG_DISRE_ENA;
722 	scmd->cdb_len = SC_G1_CDBLEN;
723 	scmd->sense_len = CCS_SENSE_LEN;
724 	scmd->cdb.g1_cdb.cmd = 0xEC;
725 	scmd->cdb.g1_cdb.lun = scg_lun(scgp);
726 
727 	scgp->cmdname = "philips recover";
728 
729 	if (scg_cmd(scgp) < 0)
730 		return (-1);
731 	return (0);
732 }
733 
734 LOCAL int
speed_select_yamaha(scgp,dp,speedp)735 speed_select_yamaha(scgp, dp, speedp)
736 	SCSI	*scgp;
737 	cdr_t	*dp;
738 	int	*speedp;
739 {
740 	struct	scsi_mode_page_header	*mp;
741 	char				mode[256];
742 	int				len = 16;
743 	int				page = 0x31;
744 	struct yamaha_mode_page_31	*xp;
745 	struct cdd_52x_mode_data md;
746 	int	count;
747 	int	speed = 1;
748 	BOOL	dummy = (dp->cdr_cmdflags & F_DUMMY) != 0;
749 
750 	if (speedp) {
751 		speed = *speedp;
752 	} else {
753 		fillbytes((caddr_t)mode, sizeof (mode), '\0');
754 
755 		if (!get_mode_params(scgp, page, _("Speed/Dummy information"),
756 			(Uchar *)mode, (Uchar *)0, (Uchar *)0, (Uchar *)0, &len)) {
757 			return (-1);
758 		}
759 		if (len == 0)
760 			return (-1);
761 
762 		mp = (struct scsi_mode_page_header *)
763 			(mode + sizeof (struct scsi_mode_header) +
764 			((struct scsi_mode_header *)mode)->blockdesc_len);
765 
766 		xp = (struct yamaha_mode_page_31 *)mp;
767 		speed = xp->speed;
768 	}
769 
770 	fillbytes((caddr_t)&md, sizeof (md), '\0');
771 
772 	count  = sizeof (struct scsi_mode_header) +
773 		sizeof (struct yamaha_mode_page_31);
774 
775 	speed >>= 1;
776 	md.pagex.page31.p_code = 0x31;
777 	md.pagex.page31.p_len =  0x02;
778 	md.pagex.page31.speed = speed;
779 	md.pagex.page31.dummy = dummy?1:0;
780 
781 	return (mode_select(scgp, (Uchar *)&md, count, 0, scgp->inq->data_format >= 2));
782 }
783 
784 LOCAL int
speed_select_philips(scgp,dp,speedp)785 speed_select_philips(scgp, dp, speedp)
786 	SCSI	*scgp;
787 	cdr_t	*dp;
788 	int	*speedp;
789 {
790 	struct	scsi_mode_page_header	*mp;
791 	char				mode[256];
792 	int				len = 20;
793 	int				page = 0x23;
794 	struct cdd_52x_mode_page_23	*xp;
795 	struct cdd_52x_mode_data	md;
796 	int				count;
797 	int				speed = 1;
798 	BOOL				dummy = (dp->cdr_cmdflags & F_DUMMY) != 0;
799 
800 	if (speedp) {
801 		speed = *speedp;
802 	} else {
803 		fillbytes((caddr_t)mode, sizeof (mode), '\0');
804 
805 		if (!get_mode_params(scgp, page, _("Speed/Dummy information"),
806 			(Uchar *)mode, (Uchar *)0, (Uchar *)0, (Uchar *)0, &len)) {
807 			return (-1);
808 		}
809 		if (len == 0)
810 			return (-1);
811 
812 		mp = (struct scsi_mode_page_header *)
813 			(mode + sizeof (struct scsi_mode_header) +
814 			((struct scsi_mode_header *)mode)->blockdesc_len);
815 
816 		xp = (struct cdd_52x_mode_page_23 *)mp;
817 		speed = xp->speed;
818 	}
819 
820 	fillbytes((caddr_t)&md, sizeof (md), '\0');
821 
822 	count  = sizeof (struct scsi_mode_header) +
823 		sizeof (struct cdd_52x_mode_page_23);
824 
825 	md.pagex.page23.p_code = 0x23;
826 	md.pagex.page23.p_len =  0x06;
827 	md.pagex.page23.speed = speed;
828 	md.pagex.page23.dummy = dummy?1:0;
829 
830 	return (mode_select(scgp, (Uchar *)&md, count, 0, scgp->inq->data_format >= 2));
831 }
832 
833 LOCAL int
speed_select_pioneer(scgp,dp,speedp)834 speed_select_pioneer(scgp, dp, speedp)
835 	SCSI	*scgp;
836 	cdr_t	*dp;
837 	int	*speedp;
838 {
839 	if (speedp != 0 && *speedp < 2) {
840 		*speedp = 2;
841 		if (lverbose)
842 			printf(_("WARNING: setting to minimum speed (2).\n"));
843 	}
844 	return (speed_select_philips(scgp, dp, speedp));
845 }
846 
847 LOCAL int
speed_select_oldphilips(scgp,dp,speedp)848 speed_select_oldphilips(scgp, dp, speedp)
849 	SCSI	*scgp;
850 	cdr_t	*dp;
851 	int	*speedp;
852 {
853 	BOOL	dummy = (dp->cdr_cmdflags & F_DUMMY) != 0;
854 
855 	if (lverbose)
856 		printf(_("WARNING: ignoring selected speed.\n"));
857 	if (dummy) {
858 		errmsgno(EX_BAD, _("Cannot set dummy writing for this device.\n"));
859 		return (-1);
860 	}
861 	return (0);
862 }
863 
864 LOCAL int
speed_select_dumbphilips(scgp,dp,speedp)865 speed_select_dumbphilips(scgp, dp, speedp)
866 	SCSI	*scgp;
867 	cdr_t	*dp;
868 	int	*speedp;
869 {
870 	if (speed_select_philips(scgp, dp, speedp) < 0)
871 		return (speed_select_oldphilips(scgp, dp, speedp));
872 	return (0);
873 }
874 
875 LOCAL int
philips_init(scgp,dp)876 philips_init(scgp, dp)
877 	SCSI	*scgp;
878 	cdr_t	*dp;
879 {
880 	return ((*dp->cdr_set_speed_dummy)(scgp, dp, NULL));
881 }
882 
883 
884 #define	IS(what, flag)	printf(_("  Is %s%s\n"), flag?"":_("not "), what);
885 
886 LOCAL int
philips_getdisktype(scgp,dp)887 philips_getdisktype(scgp, dp)
888 	SCSI	*scgp;
889 	cdr_t	*dp;
890 {
891 	dstat_t	*dsp = dp->cdr_dstat;
892 	char	sbuf[16];
893 	long	dummy;
894 	long	lilen;
895 	long	lolen;
896 	msf_t	msf;
897 	int	audio = -1;
898 
899 	scgp->silent++;
900 	dummy = (*dp->cdr_next_wr_address)(scgp, (track_t *)0, &lilen);
901 	scgp->silent--;
902 
903 	/*
904 	 * Check for "Command sequence error" first.
905 	 */
906 	if ((dsp->ds_cdrflags & RF_WRITE) != 0 &&
907 	    dummy < 0 &&
908 	    (scg_sense_key(scgp) != SC_ILLEGAL_REQUEST ||
909 						scg_sense_code(scgp) != 0x2C)) {
910 		reload_media(scgp, dp);
911 	}
912 
913 	scgp->silent++;
914 	if (read_subchannel(scgp, sbuf, 0, 12, 0, 1, 0xf0) >= 0) {
915 		if (sbuf[2] == 0 && sbuf[3] == 8)
916 			audio = (sbuf[7] & 0x40) != 0;
917 	}
918 	scgp->silent--;
919 
920 	if ((dp->cdr_dstat->ds_cdrflags & RF_PRATIP) != 0 &&
921 						dummy >= 0 && lilen == 0) {
922 		scgp->silent++;
923 		dummy = philips_getlilo(scgp, &lilen, &lolen);
924 		scgp->silent--;
925 
926 		if (dummy >= 0) {
927 /*			printf("lead-in len: %d lead-out len: %d\n", lilen, lolen);*/
928 			lba_to_msf(-150 - lilen, &msf);
929 
930 			printf(_("ATIP info from disk:\n"));
931 			if (audio >= 0)
932 				IS(_("unrestricted"), audio);
933 			if (audio == 1 || (audio == 0 && (sbuf[7] & 0x3F) != 0x3F))
934 				printf(_("  Disk application code: %d\n"), sbuf[7] & 0x3F);
935 			printf(_("  ATIP start of lead in:  %ld (%02d:%02d/%02d)\n"),
936 				-150 - lilen, msf.msf_min, msf.msf_sec, msf.msf_frame);
937 
938 			if (capacity_philips(scgp, &lolen)) {
939 				lba_to_msf(lolen, &msf);
940 				printf(
941 				_("  ATIP start of lead out: %ld (%02d:%02d/%02d)\n"),
942 				lolen, msf.msf_min, msf.msf_sec, msf.msf_frame);
943 			}
944 			lba_to_msf(-150 - lilen, &msf);
945 			pr_manufacturer(&msf,
946 					FALSE,		/* Always not erasable */
947 					audio > 0);	/* Audio from read subcode */
948 		}
949 	}
950 
951 	if (capacity_philips(scgp, &lolen)) {
952 		dsp->ds_maxblocks = lolen;
953 		dsp->ds_maxrblocks = disk_rcap(&msf, dsp->ds_maxblocks,
954 					FALSE,		/* Always not erasable */
955 					audio > 0);	/* Audio from read subcode */
956 	}
957 	scgp->silent++;
958 	/*read_subchannel(scgp, bp, track, cnt, msf, subq, fmt); */
959 
960 	if (read_subchannel(scgp, sbuf, 0, 14, 0, 0, 0xf1) >= 0)
961 		scg_prbytes(_("Disk bar code:"), (Uchar *)sbuf, 14 - scg_getresid(scgp));
962 	scgp->silent--;
963 
964 	return (drive_getdisktype(scgp, dp));
965 }
966 
967 LOCAL BOOL
capacity_philips(scgp,lp)968 capacity_philips(scgp, lp)
969 	SCSI	*scgp;
970 	long	*lp;
971 {
972 	long	l = 0L;
973 	BOOL	succeed = TRUE;
974 
975 	scgp->silent++;
976 	if (read_B0(scgp, FALSE, NULL, &l) >= 0) {
977 		if (debug)
978 			printf(_("lead out B0: %ld\n"), l);
979 		*lp = l;
980 	} else if (read_trackinfo(scgp, 0xAA, &l, NULL, NULL, NULL, NULL) >= 0) {
981 		if (debug)
982 			printf(_("lead out AA: %ld\n"), l);
983 		*lp = l;
984 	} if (read_capacity(scgp) >= 0) {
985 		l = scgp->cap->c_baddr + 1;
986 		if (debug)
987 			printf(_("lead out capacity: %ld\n"), l);
988 	} else {
989 		succeed = FALSE;
990 	}
991 	*lp = l;
992 	scgp->silent--;
993 	return (succeed);
994 }
995 
996 struct	fwa {
997 	char	len;
998 	char	addr[4];
999 	char	res;
1000 };
1001 
1002 LOCAL int
first_writable_addr_philips(scgp,ap,track,isaudio,preemp,npa)1003 first_writable_addr_philips(scgp, ap, track, isaudio, preemp, npa)
1004 	SCSI	*scgp;
1005 	long	*ap;
1006 	int	track;
1007 	int	isaudio;
1008 	int	preemp;
1009 	int	npa;
1010 {
1011 		struct	fwa	fwa;
1012 	register struct	scg_cmd	*scmd = scgp->scmd;
1013 
1014 	fillbytes((caddr_t)&fwa, sizeof (fwa), '\0');
1015 	fillbytes((caddr_t)scmd, sizeof (*scmd), '\0');
1016 	scmd->addr = (caddr_t)&fwa;
1017 	scmd->size = sizeof (fwa);
1018 	scmd->flags = SCG_RECV_DATA|SCG_DISRE_ENA;
1019 	scmd->cdb_len = SC_G1_CDBLEN;
1020 	scmd->sense_len = CCS_SENSE_LEN;
1021 	scmd->cdb.g1_cdb.cmd = 0xE2;
1022 	scmd->cdb.g1_cdb.lun = scg_lun(scgp);
1023 	scmd->cdb.g1_cdb.addr[0] = track;
1024 	scmd->cdb.g1_cdb.addr[1] = isaudio ? (preemp ? 5 : 4) : 1;
1025 
1026 	scmd->cdb.g1_cdb.count[0] = npa?1:0;
1027 	scmd->cdb.g1_cdb.count[1] = sizeof (fwa);
1028 
1029 	scgp->cmdname = "first writeable address philips";
1030 
1031 	if (scg_cmd(scgp) < 0)
1032 		return (-1);
1033 
1034 	if (ap)
1035 		*ap = a_to_4_byte(fwa.addr);
1036 	return (0);
1037 }
1038 
1039 LOCAL int
next_wr_addr_philips(scgp,trackp,ap)1040 next_wr_addr_philips(scgp, trackp, ap)
1041 	SCSI	*scgp;
1042 	track_t	*trackp;
1043 	long	*ap;
1044 {
1045 
1046 /*	if (first_writable_addr_philips(scgp, ap, 0, 0, 0, 1) < 0)*/
1047 	if (first_writable_addr_philips(scgp, ap, 0, 0, 0, 0) < 0)
1048 		return (-1);
1049 	return (0);
1050 }
1051 
1052 LOCAL int
reserve_track_philips(scgp,len)1053 reserve_track_philips(scgp, len)
1054 	SCSI	*scgp;
1055 	unsigned long len;
1056 {
1057 	register struct	scg_cmd	*scmd = scgp->scmd;
1058 
1059 	fillbytes((caddr_t)scmd, sizeof (*scmd), '\0');
1060 	scmd->flags = SCG_DISRE_ENA;
1061 	scmd->cdb_len = SC_G1_CDBLEN;
1062 	scmd->sense_len = CCS_SENSE_LEN;
1063 	scmd->cdb.g1_cdb.cmd = 0xE4;
1064 	scmd->cdb.g1_cdb.lun = scg_lun(scgp);
1065 	i_to_4_byte(&scmd->cdb.cmd_cdb[5], len);
1066 
1067 	scgp->cmdname = "philips reserve_track";
1068 
1069 	if (scg_cmd(scgp) < 0)
1070 		return (-1);
1071 	return (0);
1072 }
1073 
1074 LOCAL int
scsi_cdr_write_philips(scgp,bp,sectaddr,size,blocks,islast)1075 scsi_cdr_write_philips(scgp, bp, sectaddr, size, blocks, islast)
1076 	SCSI	*scgp;
1077 	caddr_t	bp;		/* address of buffer */
1078 	long	sectaddr;	/* disk address (sector) to put */
1079 	long	size;		/* number of bytes to transfer */
1080 	int	blocks;		/* sector count */
1081 	BOOL	islast;		/* last write for track */
1082 {
1083 	return (write_xg0(scgp, bp, 0, size, blocks));
1084 }
1085 
1086 LOCAL int
write_track_info_philips(scgp,sectype)1087 write_track_info_philips(scgp, sectype)
1088 	SCSI	*scgp;
1089 	int	sectype;
1090 {
1091 	struct cdd_52x_mode_data md;
1092 	int	count = sizeof (struct scsi_mode_header) +
1093 			sizeof (struct cdd_52x_mode_page_21);
1094 
1095 	fillbytes((caddr_t)&md, sizeof (md), '\0');
1096 	md.pagex.page21.p_code = 0x21;
1097 	md.pagex.page21.p_len =  0x0E;
1098 				/* is sectype ok ??? */
1099 	md.pagex.page21.sectype = sectype & ST_MASK;
1100 	md.pagex.page21.track = 0;	/* 0 : create new track */
1101 
1102 	return (mode_select(scgp, (Uchar *)&md, count, 0, scgp->inq->data_format >= 2));
1103 }
1104 
1105 LOCAL int
write_track_philips(scgp,track,sectype)1106 write_track_philips(scgp, track, sectype)
1107 	SCSI	*scgp;
1108 	long	track;		/* track number 0 == new track */
1109 	int	sectype;
1110 {
1111 	register struct	scg_cmd	*scmd = scgp->scmd;
1112 
1113 	fillbytes((caddr_t)scmd, sizeof (*scmd), '\0');
1114 	scmd->flags = SCG_DISRE_ENA|SCG_CMD_RETRY;
1115 /*	scmd->flags = SCG_DISRE_ENA;*/
1116 	scmd->cdb_len = SC_G1_CDBLEN;
1117 	scmd->sense_len = CCS_SENSE_LEN;
1118 	scmd->cdb.g1_cdb.cmd = 0xE6;
1119 	scmd->cdb.g1_cdb.lun = scg_lun(scgp);
1120 	g1_cdbaddr(&scmd->cdb.g1_cdb, track);
1121 	scmd->cdb.g1_cdb.res6 = sectype & ST_MASK;
1122 
1123 	scgp->cmdname = "philips write_track";
1124 
1125 	if (scg_cmd(scgp) < 0)
1126 		return (-1);
1127 	return (0);
1128 }
1129 
1130 LOCAL int
open_track_philips(scgp,dp,trackp)1131 open_track_philips(scgp, dp, trackp)
1132 	SCSI	*scgp;
1133 	cdr_t	*dp;
1134 	track_t *trackp;
1135 {
1136 	if (select_secsize(scgp, trackp->secsize) < 0)
1137 		return (-1);
1138 
1139 	if (write_track_info_philips(scgp, trackp->sectype) < 0)
1140 		return (-1);
1141 
1142 	if (write_track_philips(scgp, 0, trackp->sectype) < 0)
1143 		return (-1);
1144 
1145 	return (0);
1146 }
1147 
1148 LOCAL int
open_track_plasmon(scgp,dp,trackp)1149 open_track_plasmon(scgp, dp, trackp)
1150 	SCSI	*scgp;
1151 	cdr_t	*dp;
1152 	track_t *trackp;
1153 {
1154 	if (select_secsize(scgp, trackp->secsize) < 0)
1155 		return (-1);
1156 
1157 	if (write_track_info_philips(scgp, trackp->sectype) < 0)
1158 		return (-1);
1159 
1160 	return (0);
1161 }
1162 
1163 LOCAL int
open_track_oldphilips(scgp,dp,trackp)1164 open_track_oldphilips(scgp, dp, trackp)
1165 	SCSI	*scgp;
1166 	cdr_t	*dp;
1167 	track_t	*trackp;
1168 {
1169 	if (write_track_philips(scgp, 0, trackp->sectype) < 0)
1170 		return (-1);
1171 
1172 	return (0);
1173 }
1174 
1175 LOCAL int
open_track_yamaha(scgp,dp,trackp)1176 open_track_yamaha(scgp, dp, trackp)
1177 	SCSI	*scgp;
1178 	cdr_t	*dp;
1179 	track_t	*trackp;
1180 {
1181 	if (select_secsize(scgp, trackp->secsize) < 0)
1182 		return (-1);
1183 
1184 	if (write_track_philips(scgp, 0, trackp->sectype) < 0)
1185 		return (-1);
1186 
1187 	return (0);
1188 }
1189 
1190 LOCAL int
close_track_philips(scgp,dp,trackp)1191 close_track_philips(scgp, dp, trackp)
1192 	SCSI	*scgp;
1193 	cdr_t	*dp;
1194 	track_t	*trackp;
1195 {
1196 	return (scsi_flush_cache(scgp, FALSE));
1197 }
1198 
1199 LOCAL int
fixation_philips(scgp,dp,trackp)1200 fixation_philips(scgp, dp, trackp)
1201 	SCSI	*scgp;
1202 	cdr_t	*dp;
1203 	track_t	*trackp;
1204 {
1205 	register struct	scg_cmd	*scmd = scgp->scmd;
1206 
1207 	fillbytes((caddr_t)scmd, sizeof (*scmd), '\0');
1208 	scmd->flags = SCG_DISRE_ENA;
1209 	scmd->cdb_len = SC_G1_CDBLEN;
1210 	scmd->sense_len = CCS_SENSE_LEN;
1211 	scmd->timeout = 8 * 60;		/* Needs up to 4 minutes */
1212 	scmd->cdb.g1_cdb.cmd = 0xE9;
1213 	scmd->cdb.g1_cdb.lun = scg_lun(scgp);
1214 	scmd->cdb.g1_cdb.count[1] =
1215 			((track_base(trackp)->tracktype & TOCF_MULTI) ? 8 : 0) |
1216 			(track_base(trackp)->tracktype & TOC_MASK);
1217 
1218 	scgp->cmdname = "philips fixation";
1219 
1220 	if (scg_cmd(scgp) < 0)
1221 		return (-1);
1222 	return (0);
1223 }
1224 
1225 static const char *sd_cdd_521_error_str[] = {
1226 	"\003\000tray out",				/* 0x03 */
1227 	"\062\000write data error with CU",		/* 0x32 */	/* Yamaha */
1228 	"\063\000monitor atip error",			/* 0x33 */
1229 	"\064\000absorbtion control error",		/* 0x34 */
1230 #ifdef	YAMAHA_CDR_100
1231 	/* Is this the same ??? */
1232 	"\120\000write operation in progress",		/* 0x50 */
1233 #endif
1234 	"\127\000unable to read TOC/PMA/Subcode/ATIP",	/* 0x57 */
1235 	"\132\000operator medium removal request",	/* 0x5a */
1236 	"\145\000verify failed",			/* 0x65 */
1237 	"\201\000illegal track number",			/* 0x81 */
1238 	"\202\000command now not valid",		/* 0x82 */
1239 	"\203\000medium removal is prevented",		/* 0x83 */
1240 	"\204\000tray out",				/* 0x84 */
1241 	"\205\000track at one not in PMA",		/* 0x85 */
1242 	"\240\000stopped on non data block",		/* 0xa0 */
1243 	"\241\000invalid start address",		/* 0xa1 */
1244 	"\242\000attampt to cross track-boundary",	/* 0xa2 */
1245 	"\243\000illegal medium",			/* 0xa3 */
1246 	"\244\000disk write protected",			/* 0xa4 */
1247 	"\245\000application code conflict",		/* 0xa5 */
1248 	"\246\000illegal blocksize for command",	/* 0xa6 */
1249 	"\247\000blocksize conflict",			/* 0xa7 */
1250 	"\250\000illegal transfer length",		/* 0xa8 */
1251 	"\251\000request for fixation failed",		/* 0xa9 */
1252 	"\252\000end of medium reached",		/* 0xaa */
1253 #ifdef	REAL_CDD_521
1254 	"\253\000non reserved reserved track",		/* 0xab */
1255 #else
1256 	"\253\000illegal track number",			/* 0xab */
1257 #endif
1258 	"\254\000data track length error",		/* 0xac */
1259 	"\255\000buffer under run",			/* 0xad */
1260 	"\256\000illegal track mode",			/* 0xae */
1261 	"\257\000optical power calibration error",	/* 0xaf */
1262 	"\260\000calibration area almost full",		/* 0xb0 */
1263 	"\261\000current program area empty",		/* 0xb1 */
1264 	"\262\000no efm at search address",		/* 0xb2 */
1265 	"\263\000link area encountered",		/* 0xb3 */
1266 	"\264\000calibration area full",		/* 0xb4 */
1267 	"\265\000dummy data blocks added",		/* 0xb5 */
1268 	"\266\000block size format conflict",		/* 0xb6 */
1269 	"\267\000current command aborted",		/* 0xb7 */
1270 	"\270\000program area not empty",		/* 0xb8 */
1271 #ifdef	YAMAHA_CDR_100
1272 	/* Used while writing lead in in DAO */
1273 	"\270\000write leadin in progress",		/* 0xb8 */
1274 #endif
1275 	"\271\000parameter list too large",		/* 0xb9 */
1276 	"\277\000buffer overflow",			/* 0xbf */	/* Yamaha */
1277 	"\300\000no barcode available",			/* 0xc0 */
1278 	"\301\000barcode reading error",		/* 0xc1 */
1279 	"\320\000recovery needed",			/* 0xd0 */
1280 	"\321\000cannot recover track",			/* 0xd1 */
1281 	"\322\000cannot recover pma",			/* 0xd2 */
1282 	"\323\000cannot recover leadin",		/* 0xd3 */
1283 	"\324\000cannot recover leadout",		/* 0xd4 */
1284 	"\325\000cannot recover opc",			/* 0xd5 */
1285 	"\326\000eeprom failure",			/* 0xd6 */
1286 	"\340\000laser current over",			/* 0xe0 */	/* Yamaha */
1287 	"\341\000servo adjustment over",		/* 0xe0 */	/* Yamaha */
1288 	NULL
1289 };
1290 
1291 static const char *sd_ro1420_error_str[] = {
1292 	"\004\000logical unit is in process of becoming ready", /* 04 00 */
1293 	"\011\200radial skating error",				/* 09 80 */
1294 	"\011\201sledge servo failure",				/* 09 81 */
1295 	"\011\202pll no lock",					/* 09 82 */
1296 	"\011\203servo off track",				/* 09 83 */
1297 	"\011\204atip sync error",				/* 09 84 */
1298 	"\011\205atip/subcode jumped error",			/* 09 85 */
1299 	"\127\300subcode not found",				/* 57 C0 */
1300 	"\127\301atip not found",				/* 57 C1 */
1301 	"\127\302no atip or subcode",				/* 57 C2 */
1302 	"\127\303pma error",					/* 57 C3 */
1303 	"\127\304toc read error",				/* 57 C4 */
1304 	"\127\305disk informatoion error",			/* 57 C5 */
1305 	"\144\200read in leadin",				/* 64 80 */
1306 	"\144\201read in leadout",				/* 64 81 */
1307 	"\201\000illegal track",				/* 81 00 */
1308 	"\202\000command not now valid",			/* 82 00 */
1309 	"\220\000reserve track check error",			/* 90 00 */
1310 	"\220\001verify blank error",				/* 90 01 */
1311 	"\221\001mode of last track error",			/* 91 01 */
1312 	"\222\000header search error",				/* 92 00 */
1313 	"\230\001header monitor error",				/* 98 01 */
1314 	"\230\002edc error",					/* 98 02 */
1315 	"\230\003read link, run-in run-out",			/* 98 03 */
1316 	"\230\004last one block error",				/* 98 04 */
1317 	"\230\005illegal blocksize",				/* 98 05 */
1318 	"\230\006not all data transferred",			/* 98 06 */
1319 	"\230\007cdbd over run error",				/* 98 07 */
1320 	"\240\000stopped on non_data block",			/* A0 00 */
1321 	"\241\000invalid start address",			/* A1 00 */
1322 	"\243\000illegal medium",				/* A3 00 */
1323 	"\246\000illegal blocksize for command",		/* A6 00 */
1324 	"\251\000request for fixation failed",			/* A9 00 */
1325 	"\252\000end of medium reached",			/* AA 00 */
1326 	"\253\000illegal track number",				/* AB 00 */
1327 	"\255\000buffer underrun",				/* AD 00 */
1328 	"\256\000illegal track mode",				/* AE 00 */
1329 	"\257\200power range error",				/* AF 80 */
1330 	"\257\201moderation error",				/* AF 81 */
1331 	"\257\202beta upper range error",			/* AF 82 */
1332 	"\257\203beta lower range error",			/* AF 83 */
1333 	"\257\204alpha upper range error",			/* AF 84 */
1334 	"\257\205alpha lower range error",			/* AF 85 */
1335 	"\257\206alpha and power range error",			/* AF 86 */
1336 	"\260\000calibration area almost full",			/* B0 00 */
1337 	"\261\000current program area empty",			/* B1 00 */
1338 	"\262\000no efm at search address",			/* B2 00 */
1339 	"\264\000calibration area full",			/* B4 00 */
1340 	"\265\000dummy blocks added",				/* B5 00 */
1341 	"\272\000write audio on reserved track",		/* BA 00 */
1342 	"\302\200syscon rom error",				/* C2 80 */
1343 	"\302\201syscon ram error",				/* C2 81 */
1344 	"\302\220efm encoder error",				/* C2 90 */
1345 	"\302\221efm decoder error",				/* C2 91 */
1346 	"\302\222servo ic error",				/* C2 92 */
1347 	"\302\223motor controller error",			/* C2 93 */
1348 	"\302\224dac error",					/* C2 94 */
1349 	"\302\225syscon eeprom error",				/* C2 95 */
1350 	"\302\240block decoder communication error",		/* C2 A0 */
1351 	"\302\241block encoder communication error",		/* C2 A1 */
1352 	"\302\242block encoder/decoder path error",		/* C2 A2 */
1353 	"\303\000CD-R engine selftest error",			/* C3 xx */
1354 	"\304\000buffer parity error",				/* C4 00 */
1355 	"\305\000data transfer error",				/* C5 00 */
1356 	"\340\00012V failure",					/* E0 00 */
1357 	"\341\000undefined syscon error",			/* E1 00 */
1358 	"\341\001syscon communication error",			/* E1 01 */
1359 	"\341\002unknown syscon error",				/* E1 02 */
1360 	"\342\000syscon not ready",				/* E2 00 */
1361 	"\343\000command rejected",				/* E3 00 */
1362 	"\344\000command not accepted",				/* E4 00 */
1363 	"\345\000verify error at beginning of track",		/* E5 00 */
1364 	"\345\001verify error at ending of track",		/* E5 01 */
1365 	"\345\002verify error at beginning of lead-in",		/* E5 02 */
1366 	"\345\003verify error at ending of lead-in",		/* E5 03 */
1367 	"\345\004verify error at beginning of lead-out",	/* E5 04 */
1368 	"\345\005verify error at ending of lead-out",		/* E5 05 */
1369 	"\377\000command phase timeout error",			/* FF 00 */
1370 	"\377\001data in phase timeout error",			/* FF 01 */
1371 	"\377\002data out phase timeout error",			/* FF 02 */
1372 	"\377\003status phase timeout error",			/* FF 03 */
1373 	"\377\004message in phase timeout error",		/* FF 04 */
1374 	"\377\005message out phase timeout error",		/* FF 05 */
1375 	NULL
1376 };
1377 
1378 LOCAL int
philips_attach(scgp,dp)1379 philips_attach(scgp, dp)
1380 	SCSI	*scgp;
1381 	cdr_t	*dp;
1382 {
1383 	scg_setnonstderrs(scgp, sd_cdd_521_error_str);
1384 	return (0);
1385 }
1386 
1387 LOCAL int
plasmon_attach(scgp,dp)1388 plasmon_attach(scgp, dp)
1389 	SCSI	*scgp;
1390 	cdr_t	*dp;
1391 {
1392 	scgp->inq->data_format = 1;	/* Correct the ly */
1393 
1394 	scg_setnonstderrs(scgp, sd_cdd_521_error_str);
1395 	return (0);
1396 }
1397 
1398 LOCAL int
ricoh_attach(scgp,dp)1399 ricoh_attach(scgp, dp)
1400 	SCSI	*scgp;
1401 	cdr_t	*dp;
1402 {
1403 	if (dp == &cdr_ricoh_ro1060) {
1404 		errmsgno(EX_BAD, _("No support for Ricoh RO-1060C\n"));
1405 		return (-1);
1406 	}
1407 	scg_setnonstderrs(scgp, sd_ro1420_error_str);
1408 	return (0);
1409 }
1410 
1411 LOCAL int
philips_getlilo(scgp,lilenp,lolenp)1412 philips_getlilo(scgp, lilenp, lolenp)
1413 	SCSI	*scgp;
1414 	long	*lilenp;
1415 	long	*lolenp;
1416 {
1417 		char	buf[4];
1418 		long	li, lo;
1419 	register struct	scg_cmd	*scmd = scgp->scmd;
1420 
1421 	fillbytes((caddr_t)scmd, sizeof (*scmd), '\0');
1422 	scmd->addr = buf;
1423 	scmd->size = sizeof (buf);
1424 	scmd->flags = SCG_RECV_DATA|SCG_DISRE_ENA;
1425 	scmd->cdb_len = SC_G1_CDBLEN;
1426 	scmd->sense_len = CCS_SENSE_LEN;
1427 	scmd->cdb.g1_cdb.cmd = 0xEE;	/* Read session info */
1428 	scmd->cdb.g1_cdb.lun = scg_lun(scgp);
1429 	g1_cdblen(&scmd->cdb.g1_cdb, sizeof (buf));
1430 
1431 	scgp->cmdname = "philips read session info";
1432 
1433 	if (scg_cmd(scgp) < 0)
1434 		return (-1);
1435 
1436 	if (scgp->verbose)
1437 		scg_prbytes(_("Session info data: "), (Uchar *)buf, sizeof (buf) - scg_getresid(scgp));
1438 
1439 	li = a_to_u_2_byte(buf);
1440 	lo = a_to_u_2_byte(&buf[2]);
1441 
1442 	if (lilenp)
1443 		*lilenp = li;
1444 	if (lolenp)
1445 		*lolenp = lo;
1446 
1447 	return (0);
1448 }
1449