4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/types.h>
35 #include "transport.h"
38 #include "misc_scsi.h"
44 static int speed_tbl
[4] = { 1, 2, 12, 4 };
45 static uchar_t rev_speed_tbl
[16] = { 0, 0, 1, 0, 3, 0, 0, 0, 0,
46 0, 0, 0, 2, 0, 0, 0 };
49 * These are commands for using older Sun Toshiba drives. These
50 * commands are needed for reading CD TOC and audio extraction
51 * and changing speeds (used for audio extraction).
55 read_toc_as_per_8020(int fd
, int format
, int trackno
, int buflen
, uchar_t
*buf
)
57 struct uscsi_cmd
*scmd
;
59 scmd
= get_uscsi_cmd();
60 scmd
->uscsi_flags
= USCSI_READ
|USCSI_SILENT
;
61 scmd
->uscsi_timeout
= 60;
62 scmd
->uscsi_cdb
[0] = READ_TOC_CMD
;
63 scmd
->uscsi_cdb
[6] = trackno
;
64 scmd
->uscsi_cdb
[8] = buflen
& 0xff;
65 scmd
->uscsi_cdb
[7] = (buflen
>> 8) & 0xff;
66 scmd
->uscsi_cdb
[9] = (format
<< 6) & 0xc0;
67 scmd
->uscsi_cdblen
= 10;
68 scmd
->uscsi_bufaddr
= (char *)buf
;
69 scmd
->uscsi_buflen
= buflen
;
70 if (uscsi(fd
, scmd
) < 0)
76 toshiba_read_audio(cd_device
*target
, uint_t start_blk
, uint_t nblk
,
79 struct uscsi_cmd
*scmd
;
82 scmd
= get_uscsi_cmd();
83 scmd
->uscsi_flags
= USCSI_READ
|USCSI_SILENT
;
84 scmd
->uscsi_timeout
= 60;
85 ((uchar_t
*)scmd
->uscsi_cdb
)[0] = READ_AUDIO_CMD
;
86 scmd
->uscsi_cdb
[5] = start_blk
& 0xff;
87 scmd
->uscsi_cdb
[4] = (start_blk
>> 8) & 0xff;
88 scmd
->uscsi_cdb
[3] = (start_blk
>> 16) & 0xff;
89 scmd
->uscsi_cdb
[2] = (start_blk
>> 24) & 0xff;
90 scmd
->uscsi_cdb
[9] = nblk
& 0xff;
91 scmd
->uscsi_cdb
[8] = (nblk
>> 8) & 0xff;
92 scmd
->uscsi_cdb
[7] = (nblk
>> 16) & 0xff;
93 scmd
->uscsi_cdb
[6] = (nblk
>> 24) & 0xff;
94 scmd
->uscsi_cdblen
= 12;
95 scmd
->uscsi_bufaddr
= (char *)buf
;
96 scmd
->uscsi_buflen
= nblk
*2352;
98 for (retry
= 0; retry
< 3; retry
++) {
99 ret
= uscsi(target
->d_fd
, scmd
);
110 toshiba_speed_ctrl(cd_device
*dev
, int cmd
, int speed
)
113 struct uscsi_cmd
*scmd
;
116 if ((cmd
== GET_WRITE_SPEED
) || (cmd
== SET_WRITE_SPEED
)) {
118 (void) printf("toshiba_speed_ctrl: WRONG CMD %d\n",
124 if (cmd
== SET_READ_SPEED
) {
125 if (dev
->d_cap
& DEV_CAP_SETTING_SPEED_NOT_ALLOWED
) {
128 "Cannot set speed on this device.\n"));
132 if (strncmp("SUN32XCD",
133 (const char *)&dev
->d_inq
[24], 8) == 0)
136 if ((speed
!= 1) && (speed
!= 2) && (speed
!= 4) &&
140 "%dx speed is not supported by the device.\n"));
146 mpage
= (uchar_t
*)my_zalloc(16);
147 scmd
= get_uscsi_cmd();
148 scmd
->uscsi_flags
= USCSI_READ
|USCSI_SILENT
;
149 scmd
->uscsi_timeout
= 60;
150 scmd
->uscsi_cdblen
= 6;
151 scmd
->uscsi_bufaddr
= (char *)mpage
;
152 scmd
->uscsi_buflen
= 16;
153 /* 6 byte mode sense for older drives */
154 scmd
->uscsi_cdb
[0] = MODE_SENSE_6_CMD
;
155 scmd
->uscsi_cdb
[2] = 0x31;
156 scmd
->uscsi_cdb
[4] = 16;
157 if (uscsi(dev
->d_fd
, scmd
) < 0)
159 if (cmd
== GET_READ_SPEED
) {
160 ret
= speed_tbl
[mpage
[14] & 0x3];
163 if (cmd
== SET_READ_SPEED
) {
164 (void) memset(mpage
, 0, 9);
168 mpage
[14] = rev_speed_tbl
[speed
];
169 scmd
= get_uscsi_cmd();
170 scmd
->uscsi_flags
= USCSI_WRITE
|USCSI_SILENT
;
171 scmd
->uscsi_timeout
= 60;
172 scmd
->uscsi_cdblen
= 6;
173 scmd
->uscsi_bufaddr
= (char *)mpage
;
174 scmd
->uscsi_buflen
= 16;
175 /* 6 byte mode sense command for older drives */
176 scmd
->uscsi_cdb
[0] = MODE_SELECT_6_CMD
;
177 scmd
->uscsi_cdb
[1] = 0x10;
178 scmd
->uscsi_cdb
[4] = 16;
179 if (uscsi(dev
->d_fd
, scmd
) < 0)