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
* Sony NEWS-specific drive control routines.
24
#if defined( __sony_news) || defined(sony_news)
31
#include <sys/types.h>
32
#include <sys/param.h>
36
#include "include/wm_config.h"
37
#include "include/wm_struct.h"
38
#include "include/wm_cdtext.h"
40
#define WM_MSG_CLASS WM_MSG_CLASS_PLATFORM
45
extern int intermittent_dev;
51
* Initialize the drive. A no-op for the generic driver.
54
gen_init( struct wm_drive *d )
60
* Open the CD device and figure out what kind of drive is attached.
63
gen_open( struct wm_drive *d )
65
if (d->fd > -1) { /* Device already open? */
66
wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "gen_open(): [device is open (fd=%d)]\n", d->fd);
72
if ((d->fd = CD_Open(d->cd_device, 0)) < 0) {
73
/* Solaris 2.2 volume manager moves links around */
74
if (errno == ENOENT && intermittent_dev)
79
else if (errno != EIO) /* defined at top */
90
* Pass SCSI commands to the device.
93
gen_scsi(struct wm_drive *d, unsigned char *cdb, int cdblen,
94
unsigned char *buf, int buflen, int getreply)
96
/* NEWS can't do SCSI passthrough... or can it? */
101
gen_close( struct wm_drive *d )
105
wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "closing the device.\n");
106
ret = CD_Close(d->fd);
114
* Get the current status of the drive: the current play mode, the absolute
115
* position from start of disc (in frames), and the current track and index
116
* numbers if the CD is playing or paused.
119
gen_get_drive_status( struct wm_drive *d, int oldmode,
120
int *mode, int *pos, int *track, int *index)
124
/* If we can't get status, the CD is ejected, so default to that. */
125
*mode = WM_CDM_EJECTED;
127
/* Is the device open? */
129
switch (d->proto.open(d)) {
138
/* Disc is ejected. Close the device. */
139
if (CD_GetStatus(d->fd, &sc)) {
146
*mode = WM_CDM_PLAYING;
150
if (oldmode == WM_CDM_PLAYING || oldmode == WM_CDM_PAUSED)
151
*mode = WM_CDM_PAUSED;
153
*mode = WM_CDM_STOPPED;
157
if (oldmode == WM_CDM_PLAYING) {
158
*mode = WM_CDM_TRACK_DONE; /* waiting for next track. */
164
*mode = WM_CDM_STOPPED;
178
} /* gen_get_drive_status() */
181
* Get the number of tracks on the CD.
184
gen_get_trackcount(struct wm_drive *d, int *tracks)
186
struct CD_Capacity cc;
188
if (CD_GetCapacity(d->fd, &cc))
191
*tracks = cc.etrack - 1;
193
} /* gen_get_trackcount() */
196
* Get the start time and mode (data or audio) of a track.
199
gen_get_trackinfo( struct wm_drive *d, int track, int *data, int *startframe )
201
struct CD_TOCinfo hdr;
202
struct CD_TOCdata ent;
207
if (CD_ReadTOC(d->fd, &hdr))
210
*data = (ent.control & 4) ? 1 : 0;
211
*startframe = ent.baddr;
214
} /* gen_get_trackinfo */
217
* Get the number of frames on the CD.
220
gen_get_cdlen( struct wm_drive *d, int *frames )
224
if ((d->get_trackcount)(d, &tmp))
227
return gen_get_trackinfo(d, tmp + 1, &tmp, frames);
228
} /* gen_get_cdlen() */
232
* Play the CD from one position to another (both in frames.)
235
gen_play( struct wm_drive *d, int start, int end )
237
struct CD_PlayAddr msf;
239
msf.addrmode = CD_MSF;
240
msf.addr.msf.startmsf.min = start / (60*75);
241
msf.addr.msf.startmsf.sec = (start % (60*75)) / 75;
242
msf.addr.msf.startmsf.frame = start % 75;
243
msf.addr.msf.endmsf.min = end / (60*75);
244
msf.addr.msf.endmsf.sec = (end % (60*75)) / 75;
245
msf.addr.msf.endmsf.frame = end % 75;
247
if (CD_Play(d->fd, &msf)) {
248
wm_lib_message(WM_MSG_LEVEL_ERROR|WM_MSG_CLASS,
249
"wm_cd_play_chunk(%d,%d)\n",start,end);
250
wm_lib_message(WM_MSG_LEVEL_ERROR|WM_MSG_CLASS,
251
"msf = %d:%d:%d %d:%d:%d\n",
252
msf.addr.msf.startmsf.min,
253
msf.addr.msf.startmsf.sec,
254
msf.addr.msf.startmsf.frame,
255
msf.addr.msf.endmsf.min,
256
msf.addr.msf.endmsf.sec,
257
msf.addr.msf.endmsf.frame);
258
wm_lib_message(WM_MSG_LEVEL_ERROR|WM_MSG_CLASS,
270
gen_pause( struct wm_drive *d )
277
* Resume playing the CD (assuming it was paused.)
280
gen_resume( struct wm_drive *d )
290
gen_stop( struct wm_drive *d )
297
* Eject the current CD, if there is one.
300
gen_eject( struct wm_drive *d )
305
if (fstat(d->fd, &stbuf) != 0)
308
/* Is this a mounted filesystem? */
309
if (ustat(stbuf.st_rdev, &ust) == 0)
312
if (CD_AutoEject(d->fd))
315
/* Close the device if it needs to vanish. */
316
if (intermittent_dev)
322
/*----------------------------------------*
325
* Please edit and send changes to
326
* milliByte@DeathsDoor.com
327
*----------------------------------------*/
329
gen_closetray(struct wm_drive *d)
332
} /* gen_closetray() */
336
* Set the volume level for the left and right channels. Their values
337
* range from 0 to 100.
340
gen_set_volume( struct wm_drive *d, int left, int right)
342
/* NEWS can't adjust volume! */
347
* Read the initial volume from the drive, if available. Each channel
348
* ranges from 0 to 100, with -1 indicating data not available.
351
gen_get_volume( struct wm_drive *d, omt *left, int *right)
353
/* Suns, HPs, Linux, NEWS can't read the volume; oh well */
356
} /* gen_get_volume() */