2 * $Id: drv_toshiba.c,v 1.3 1999/02/14 09:50:42 dirk Exp $
4 * This file is part of WorkMan, the civilized CD player library
5 * (c) 1991-1997 by Steven Grimm (original author)
6 * (c) by Dirk Försterling (current 'author' = maintainer)
7 * The maintainer can be contacted by his e-mail address:
8 * milliByte@DeathsDoor.com
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the Free
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * Vendor-specific drive control routines for Toshiba XM-3401 series.
28 static char drv_toshiba_id
[] = "$Id: drv_toshiba.c,v 1.3 1999/02/14 09:50:42 dirk Exp $";
32 #include "include/wm_config.h"
33 #include "include/wm_struct.h"
34 #include "include/wm_scsi.h"
36 #define SCMD_TOSH_EJECT 0xc4
38 /* local prototypes */
39 static int tosh_init( struct wm_drive
*d
);
40 static int tosh_eject( struct wm_drive
*d
);
41 static int tosh_set_volume( struct wm_drive
*d
, int left
, int right
);
42 static int tosh_get_volume( struct wm_drive
*d
, int *left
, int *right
);
44 struct wm_drive toshiba_proto
= {
46 "Toshiba", /* vendor */
52 tosh_init
, /* functions... */
68 * Initialize the driver.
71 tosh_init( struct wm_drive
*d
)
73 extern int min_volume
;
75 /* Sun use Toshiba drives as well */
76 #if defined(SYSV) && defined(CODEC)
84 * Send the Toshiba code to eject the CD.
87 tosh_eject( struct wm_drive
*d
)
89 return (sendscsi(d
, NULL
, 0, 0, SCMD_TOSH_EJECT
, 1, 0,0,0,0,0,0,0,0,0,0));
93 * Set the volume. The low end of the scale is more sensitive than the high
94 * end, so make up for that by transforming the volume parameters to a square
98 tosh_set_volume( struct wm_drive
*d
, int left
, int right
)
100 left
= (left
* left
* left
) / 10000;
101 right
= (right
* right
* right
) / 10000;
102 return (gen_set_volume(d
, left
, right
));
106 * Undo the transformation above using a binary search (so no floating-point
110 unscale_volume(cd_vol
, max
)
113 int vol
= 0, top
= max
, bot
= 0, scaled
= 0;
115 /*cd_vol = (cd_vol * 100 + (max_volume - 1)) / max_volume;*/
119 vol
= (top
+ bot
) / 2;
120 scaled
= (vol
* vol
) / max
;
121 if (cd_vol
<= scaled
)
127 /* Might have looked down too far for repeated scaled values */
143 tosh_get_volume( struct wm_drive
*d
, int *left
, int *right
)
147 status
= gen_get_volume(d
, left
, right
);
150 *left
= unscale_volume(*left
, 100);
151 *right
= unscale_volume(*right
, 100);