wmail: use automake.
[dockapps.git] / ascd / libworkman / plat_template.c
blob956b98b491c8ba03ee599f987593087d52bc75ba
1 /*
2 * $Id$
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
28 #if [TEMPLATESYSTEM]
30 static char plat_template_id[] = "$Id$"
33 #include "include/wm_config.h"
34 #include "include/wm_struct.h"
36 #define WM_MSG_CLASS WM_MSG_CLASS_PLATFORM
39 * gen_init();
43 int gen_init(struct wm_drive *d)
45 return (0);
49 * gen_get_trackcount()
53 int gen_get_trackcount(struct wm_drive *d,int *tracks)
55 return (0);
60 * gen_get_cdlen()
64 int gen_get_cdlen(struct wm_drive *d,int *frames)
66 return (0);
70 * gen_get_trackinfo()
74 int
75 gen_get_trackinfo(struct wm_drive *d,int track,int *data,int *startframe)
77 return (0);
81 * gen_get_drive_status()
85 int gen_get_drive_status(struct wm_drive *d,
86 enum wm_cd_modes oldmode,
87 enum wm_cd_modes *mode,
88 int *pos,
89 int *track,
90 int *index)
92 return (0);
96 int scale_volume(int vol,int max)
98 return ((vol * (max_volume - min_volume)) / max + min_volume);
101 int unscale_volume(int vol,int max)
103 int n;
104 n = ( vol - min_volume ) * max_volume / (max - min_volume);
105 return (n <0)?0:n;
109 * gen_get_volume()
113 int gen_get_volume(struct wm_drive *d,int *left,int *right)
115 return (0);
119 * gen_set_volume()
123 int gen_set_volume(struct wm_drive *d,int left,int right)
125 return (0);
129 * gen_pause()
133 int gen_pause(struct wm_drive *d)
135 return ioctl( 0 );
139 * gen_resume
143 int gen_resume(struct wm_drive *d)
145 return (0);
149 * gen_stop()
153 int gen_stop(struct wm_drive *d){
154 return (0);
158 * gen_play()
162 int gen_play(struct wm_drive *d,int start,int end)
164 return (0);
168 * gen_eject()
172 int gen_eject(struct wm_drive *d)
174 return (0);
178 /*----------------------------------------*
179 * Close the CD tray
180 *----------------------------------------*/
181 int gen_closetray(struct wm_drive *d)
183 #ifdef CAN_CLOSE
184 if(!close(d->fd))
186 d->fd=-1;
187 return(wmcd_reopen(d));
188 } else {
189 return(-1);
191 #else
192 /* Always succeed if the drive can't close */
193 return(0);
194 #endif /* CAN_CLOSE */
195 } /* gen_closetray() */
199 * wm_scsi()
202 int wm_scsi(struct wm_drive *d,
203 uchar_t *cdb, int cdblen,void *retbuf,int retbuflen,int getreply)
205 return (0);
210 * wmcd_open()
214 int wmcd_open(struct wm_drive *d)
216 char vendor[32] = WM_STR_GENVENDOR;
217 char model[32] = WM_STR_GENMODEL;
218 char rev[32] = WM_STR_GENREV;
220 int fd;
222 if( ! d ){
223 errno = EFAULT;
224 return -1;
227 if(d->fd > -1) /* device already open? */
228 return 0;
230 if( cd_device == (char *)NULL )
231 cd_device = DEFAULT_CD_DEVICE;
233 /* open() goes here */
235 *d = *(find_drive_struct(vendor, model, rev));
236 wm_drive_settype(vendor, model, rev);
238 d->fd = fd;
239 d->init(d);
241 return (0);
242 } /* wmcd_open() */
245 * Re-Open the device if it is open.
248 wmcd_reopen( struct wm_drive *d )
250 int status;
252 do {
253 wm_lib_message(WM_MSG_LEVEL_DEBUG, "wmcd_reopen ");
254 if (d->fd >= 0) /* Device really open? */
256 wm_lib_message(WM_MSG_LEVEL_DEBUG, "closes the device and ");
257 status = close( d->fd ); /* close it! */
258 /* we know, that the file is closed, do we? */
259 d->fd = -1;
261 wm_susleep( 1000 );
262 wm_lib_message(WM_MSG_LEVEL_DEBUG, "calls wmcd_open()\n");
263 status = wmcd_open( d ); /* open it as usual */
264 wm_susleep( 1000 );
265 } while ( status != 0 );
266 return status;
267 } /* wmcd_reopen() */
269 #endif /* TEMPLATESYSTEM */