2
* This file is part of WorkMan, the civilized CD player library
3
* Copyright (C) 1991-1997 by Steven Grimm <koreth@midwinter.com>
4
* Copyright (C) by Dirk Försterling <milliByte@DeathsDoor.com>
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public
17
* License along with this library; if not, write to the Free
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
* plat_aix - AIX 4.x IDE and SCSI support 16 Dec 1998
23
* AIX 4.x Port: Erik O'Shaughnessy
24
* Original AIX IDE Code: Cloyce Spradling (xmcd libdi_d/aixioc.c )
26
* Taken from the ascd distribution.
30
#if defined(AIXV3) || defined(__AIXV3)
36
#include <sys/types.h>
37
#include <sys/cdrom.h>
38
#include <sys/devinfo.h>
40
#include <sys/scdisk.h>
42
#include "include/wm_config.h"
43
#include "include/wm_struct.h"
44
#include "include/wm_cdtext.h"
46
#define WM_MSG_CLASS WM_MSG_CLASS_PLATFORM
62
gen_init(struct wm_drive *d)
75
gen_open(struct wm_drive *d)
85
if(d->fd > -1) /* device already open? */
87
wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "gen_open(): [device is open (fd=%d)]\n", d->fd);
91
if( (fd = openx(d->cd_device,O_RDONLY,NULL,SC_SINGLE)) < 0 )
110
gen_scsi(struct wm_drive *d,
111
uchar_t *cdb, int cdblen,
112
void *retbuf, int retbuflen,
119
gen_close( struct wm_drive *d )
122
wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "closing the device\n");
129
/* NAME: gen_get_drive_status
136
gen_get_drive_status(struct wm_drive *d,
143
struct cd_audio_cmd cmd;
145
*mode = WM_CDM_EJECTED;
148
switch(d->proto.open(d))
156
cmd.audio_cmds = CD_INFO_AUDIO;
158
if( ioctl(d->fd,DKAUDIO,&cmd) < 0)
164
*mode = WM_CDM_PLAYING;
165
*track = cmd.indexing.info_audio.current_track;
166
*index = cmd.indexing.info_audio.current_index;
167
*pos = cmd.indexing.info_audio.current_mins * 60 * 75 +
168
cmd.indexing.info_audio.current_secs * 75 +
169
cmd.indexing.info_audio.current_frames;
173
*mode = WM_CDM_PAUSED;
174
*track = cmd.indexing.info_audio.current_track;
175
*index = cmd.indexing.info_audio.current_index;
176
*pos = cmd.indexing.info_audio.current_mins * 60 * 75 +
177
cmd.indexing.info_audio.current_secs * 75 +
178
cmd.indexing.info_audio.current_frames;
181
case CD_NO_AUDIO: /* no play audio in progress */
182
case CD_COMPLETED: /* play operation completed successfully */
183
case CD_STATUS_ERROR: /* invalid status or play stopped due to err */
184
case CD_NOT_VALID: /* audio status is invalid or not supported */
185
*mode = WM_CDM_STOPPED;
188
*mode = WM_CDM_UNKNOWN;
193
} /* gen_get_drive_status() */
197
/* NAME: gen_get_trackcount
204
gen_get_trackcount(struct wm_drive *d,int *tracks)
206
struct cd_audio_cmd cmd;
208
cmd.audio_cmds = CD_TRK_INFO_AUDIO;
211
if( ioctl(d->fd,DKAUDIO,&cmd) < 0)
217
*tracks = cmd.indexing.track_index.last_track;
220
} /* gen_get_trackcount() */
222
/* NAME: gen_get_trackinfo
229
gen_get_trackinfo(struct wm_drive *d,int track,int *data,int *startframe)
231
struct cd_audio_cmd cmd;
233
cmd.audio_cmds = CD_GET_TRK_MSF;
236
cmd.indexing.track_msf.track = track;
238
if( ioctl(d->fd,DKAUDIO,&cmd) < 0)
241
*startframe = cmd.indexing.track_msf.mins * 60 * 75 +
242
cmd.indexing.track_msf.secs * 75 +
243
cmd.indexing.track_msf.frames;
248
} /* gen_get_trackinfo() */
250
/* NAME: gen_get_cdlen
257
gen_get_cdlen(struct wm_drive *d,int *frames)
261
return gen_get_trackinfo(d,LEADOUT,&tmp,frames);
262
} /* gen_get_cdlen() */
272
gen_play(struct wm_drive *d,int start,int end)
274
struct cd_audio_cmd cmd;
276
cmd.audio_cmds = CD_PLAY_AUDIO;
279
cmd.indexing.msf.first_mins = start / (60*75);
280
cmd.indexing.msf.first_secs = (start % (60*75)) / 75;
281
cmd.indexing.msf.first_frames = start % 75;
283
cmd.indexing.msf.last_mins = end / (60*75);
284
cmd.indexing.msf.last_secs = (end % (60*75)) / 75;
285
cmd.indexing.msf.last_frames = end % 75;
287
if( ioctl(d->fd,DKAUDIO,&cmd) < 0)
289
perror("DKAUDIO:CD_PLAY_AUDIO");
302
gen_pause(struct wm_drive *d)
304
struct cd_audio_cmd cmd;
306
cmd.audio_cmds = CD_PAUSE_AUDIO;
308
return ioctl(d->fd,DKAUDIO,&cmd);
319
gen_resume(struct wm_drive *d)
321
struct cd_audio_cmd cmd;
323
cmd.audio_cmds = CD_RESUME_AUDIO;
324
return ioctl(d->fd,DKAUDIO,&cmd);
334
gen_stop(struct wm_drive *d)
336
struct cd_audio_cmd cmd;
338
cmd.audio_cmds = CD_STOP_AUDIO;
339
return ioctl(d->fd,DKAUDIO,&cmd);
349
gen_eject(struct wm_drive *d)
351
return ioctl(d->fd,DKEJECT,NULL);
354
/*----------------------------------------*
356
*----------------------------------------*/
358
gen_closetray(struct wm_drive *d)
361
} /* gen_closetray() */
365
scale_volume(int vol,int max)
367
return ((vol * (max_volume - min_volume)) / max + min_volume);
371
unscale_volume(int vol,int max)
374
n = ( vol - min_volume ) * max_volume / (max - min_volume);
378
/* NAME: gen_set_volume
385
gen_set_volume(struct wm_drive *d,int left,int right)
387
struct cd_audio_cmd cmd;
389
cmd.audio_cmds = CD_SET_VOLUME;
390
cmd.volume_type = CD_VOLUME_CHNLS;
392
cmd.out_port_0_vol = scale_volume(left,100);
393
cmd.out_port_1_vol = scale_volume(right,100);
395
if( ioctl(d->fd,DKAUDIO,&cmd) < 0)
397
perror("CD_SET_VOLUME");
402
} /* gen_set_volume() */
404
/* NAME: gen_get_volume
411
gen_get_volume(struct wm_drive *d,int *left,int *right)
413
struct cd_audio_cmd cmd;
416
fprintf(stderr,"gen_get_volume\n");
418
cmd.audio_cmds = CD_INFO_AUDIO;
419
if( ioctl(d->fd,DKAUDIO,&cmd) < 0)
422
*left = unscale_volume(cmd.out_port_0_vol,100);
423
*right = unscale_volume(cmd.out_port_1_vol,100);
426
} /* gen_get_volume() */