~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kscd/libwm/plat_ultrix.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: plat_ultrix.c,v 1.9 2001/04/10 17:34:52 dfoerste Exp $
 
3
 *
 
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 
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 *
 
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
 
23
 *
 
24
 *
 
25
 * ULTRIX 4.2 drive control routines.
 
26
 */
 
27
 
 
28
static char plat_ultrix_id[] = "$Id: plat_ultrix.c,v 1.9 2001/04/10 17:34:52 dfoerste Exp $";
 
29
 
 
30
#if defined(ultrix) || defined(__ultrix)
 
31
 
 
32
 
 
33
#include <errno.h>
 
34
#include <stdio.h>
 
35
#include <sys/types.h>
 
36
#include <fcntl.h>
 
37
#include <sys/param.h>
 
38
#include <sys/stat.h>
 
39
#include <sys/time.h>
 
40
#include <ustat.h>
 
41
#include <string.h>
 
42
#include <sys/rzdisk.h>
 
43
#include <sys/cdrom.h>
 
44
 
 
45
#include "include/wm_config.h"
 
46
#include "include/wm_cdtext.h"
 
47
#include "include/wm_struct.h"
 
48
 
 
49
#define WM_MSG_CLASS WM_MSG_CLASS_PLATFORM
 
50
 
 
51
/*
 
52
 *   This structure will be filled with the TOC header and all entries.
 
53
 * Ultrix doesn't seem to allow getting single TOC entries.
 
54
 *                              - Chris Ross (cross@eng.umd.edu)
 
55
 */
 
56
struct cd_toc_header_and_entries 
 
57
{
 
58
  struct cd_toc_header  cdth;
 
59
  struct cd_toc_entry           cdte[CDROM_MAX_TRACK+1];
 
60
};
 
61
 
 
62
void *malloc();
 
63
char *strchr();
 
64
 
 
65
int     min_volume = 128;
 
66
int     max_volume = 255;
 
67
 
 
68
extern char     *cd_device;
 
69
 
 
70
/*
 
71
 * fgetline()
 
72
 *
 
73
 *   Simulate fgets, but joining continued lines in the output of uerf.
 
74
 */
 
75
 
 
76
#define BUF_SIZE        85              /* Max length of a (real) line */
 
77
 
 
78
char *
 
79
fgetline( FILE *fp )
 
80
{
 
81
  static char     *retval = NULL;
 
82
  static char     holdbuf[BUF_SIZE + 1];
 
83
  char            tmp[BUF_SIZE + 1];
 
84
  char            *stmp;
 
85
  
 
86
  if (!retval) 
 
87
    {
 
88
      retval = malloc(BUF_SIZE * 3);  /* 3 lines can be joined */
 
89
      if (!retval)
 
90
        return(NULL);
 
91
      else
 
92
        *retval = '\0';
 
93
    }
 
94
  
 
95
  if (*holdbuf) 
 
96
    {
 
97
      strcpy(retval, holdbuf);
 
98
      retval[strlen(retval)-1] = '\0';
 
99
      memset(holdbuf, 0, BUF_SIZE+1);
 
100
    }
 
101
 
 
102
  while (fgets(tmp, BUF_SIZE, fp)) 
 
103
    {
 
104
      stmp = tmp + strspn(tmp, " \t");
 
105
      if (*stmp == '_') 
 
106
        {                     /* Continuation line */
 
107
          retval[strlen(retval)-1] = '\0';   /* Trim off C/R */
 
108
          strcat(retval, stmp+1);
 
109
        } else {
 
110
          if (*retval) 
 
111
            {
 
112
              strcpy(holdbuf, tmp);
 
113
              holdbuf[strlen(holdbuf)-1] = -1;
 
114
              return retval;
 
115
            } else {             /* First line read, keep reading */
 
116
              strcat(retval, stmp);
 
117
              retval[strlen(retval)-1] = '\0';
 
118
            }
 
119
        }
 
120
    }
 
121
  return NULL;
 
122
} /* fgetline() */
 
123
 
 
124
/*
 
125
 * find_cdrom
 
126
 *
 
127
 * Determine the name of the CD-ROM device.
 
128
 *
 
129
 * Read through the boot records (via a call to uerf) and find the SCSI
 
130
 * address of the CD-ROM.  If the "CDROM" environment variable is set,
 
131
 * use that instead.
 
132
 */
 
133
int
 
134
find_cdrom()
 
135
{
 
136
  char  *data;
 
137
  FILE  *uerf;
 
138
  int   fds[2];
 
139
  int   pid;
 
140
  
 
141
  cd_device = getenv("CDROM");
 
142
  
 
143
  if (cd_device != NULL)
 
144
    {
 
145
      if(strncmp("/dev/", cd_device, 5) || strstr(cd_device, "/../"))
 
146
        return 0;
 
147
    }
 
148
  
 
149
  pipe(fds);
 
150
  
 
151
  if ((pid = fork()) == 0) 
 
152
    {
 
153
      close(fds[0]);
 
154
      dup2(fds[1], 1);
 
155
      execl("/etc/uerf", "uerf", "-R", "-r", "300", NULL);
 
156
      execl("/usr/sbin/uerf", "uerf", "-R", "-r", "300", NULL);
 
157
      return 0; /* _exit(1); */
 
158
    } else if (pid < 0) {
 
159
      perror("fork");
 
160
      return 0; /* exit(1); */
 
161
    }
 
162
  
 
163
  close(fds[1]);
 
164
  uerf = fdopen(fds[0], "r");
 
165
  
 
166
  while (data = fgetline(uerf))
 
167
    if (strstr(data, "RRD42")) 
 
168
      {
 
169
        char    *device;
 
170
        
 
171
        cd_device = (char *)malloc(sizeof("/dev/rrz##c"));
 
172
        strcpy(cd_device, "/dev/r");
 
173
        device = strstr(data, "rz");
 
174
        device[(int)(strchr(device, ' ') - device)] = '\0';
 
175
        strcat(cd_device, device);
 
176
        strcat(cd_device, "c");
 
177
        break;
 
178
      }
 
179
  
 
180
  fclose(uerf);
 
181
  
 
182
  if (cd_device == NULL) 
 
183
    {
 
184
      fprintf(stderr,
 
185
              "No cdrom (RRD42) is installed on this system\n");
 
186
      return 0; /* exit(1); */
 
187
    }
 
188
  
 
189
  kill(pid, 15);
 
190
  (void)wait((int *)NULL);
 
191
  return 1;
 
192
} /* find_cdrom() */
 
193
 
 
194
/*
 
195
 * initialize the drive.  a no-op for the generic driver.
 
196
 */
 
197
int
 
198
gen_init( struct wm_drive *d )
 
199
{
 
200
        return (0);
 
201
} /* gen_init() */
 
202
 
 
203
 
 
204
/*
 
205
 * Open the CD device and figure out what kind of drive is attached.
 
206
 */
 
207
int
 
208
wmcd_open( struct wm_drive *d )
 
209
{
 
210
  int           fd;
 
211
  static int    warned = 0;
 
212
  
 
213
  if (d->fd >= 0)               /* Device already open? */
 
214
    {
 
215
      wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "wmcd_open(): [device is open (fd=%d)]\n", d->fd);
 
216
      return (0);
 
217
    }
 
218
  
 
219
  if (cd_device == NULL)
 
220
    find_cdrom();
 
221
  
 
222
  d->fd = open(cd_device, 0);
 
223
  if (d->fd < 0)
 
224
    {
 
225
      if (errno == EACCES)
 
226
        {
 
227
          return -EACCES;
 
228
        }
 
229
      else if (errno != EINTR)
 
230
        {
 
231
          return( -6 );
 
232
        }
 
233
      
 
234
      /* No CD in drive. */
 
235
      return (1);
 
236
    }
 
237
  
 
238
  /* Now fill in the relevant parts of the wm_drive structure. */
 
239
  fd = d->fd;
 
240
  *d = *(find_drive_struct("", "", ""));
 
241
  d->fd = fd;
 
242
  
 
243
  (d->init)(d);
 
244
  
 
245
  return (0);
 
246
} /* wmcd_open() */
 
247
 
 
248
/*
 
249
 * Re-Open the device if it is open.
 
250
 */
 
251
int
 
252
wmcd_reopen( struct wm_drive *d )
 
253
{
 
254
  int status;
 
255
  
 
256
  do {
 
257
    wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "wmcd_reopen\n");
 
258
    if (d->fd >= 0)             /* Device really open? */
 
259
      {
 
260
        wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "closing the device\n");
 
261
        status = close( d->fd );   /* close it! */
 
262
        /* we know, that the file is closed, do we? */
 
263
        d->fd = -1;
 
264
      }
 
265
    wm_susleep( 1000 );
 
266
    wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "calling wmcd_open()\n");
 
267
    status = wmcd_open( d ); /* open it as usual */
 
268
    wm_susleep( 1000 );
 
269
  } while ( status != 0 );
 
270
  return status;
 
271
} /* wmcd_reopen() */
 
272
 
 
273
/*
 
274
 * Send an arbitrary SCSI command to a device.
 
275
 */
 
276
int
 
277
wm_scsi( struct wm_drive *d, unsigned char *cdb, int cdblen, 
 
278
         void *retbuf, int retbuflen, int getreply )
 
279
{
 
280
        /* ULTRIX doesn't have a SCSI passthrough interface, does it? */
 
281
        return (-1);
 
282
} /* wm_scsi() */
 
283
 
 
284
 
 
285
/*
 
286
 * Get the current status of the drive: the current play mode, the absolute
 
287
 * position from start of disc (in frames), and the current track and index
 
288
 * numbers if the CD is playing or paused.
 
289
 */
 
290
int
 
291
gen_get_drive_status( struct wm_drive *d, enum wm_cd_modes oldmode, 
 
292
                      enum wm_cd_modes *mode, int *pos, int *track, int *index)
 
293
{
 
294
  struct cd_sub_channel         sc;
 
295
  struct cd_subc_channel_data   scd;
 
296
  
 
297
  /* If we can't get status, the CD is ejected, so default to that. */
 
298
  *mode = WM_CDM_EJECTED;
 
299
  
 
300
  sc.sch_address_format = CDROM_MSF_FORMAT;
 
301
  sc.sch_data_format    = CDROM_CURRENT_POSITION;
 
302
  sc.sch_track_number   = 0;
 
303
  sc.sch_alloc_length   = sizeof(scd);
 
304
  sc.sch_buffer         = (caddr_t)&scd;
 
305
  
 
306
  /* Is the device open? */
 
307
  if (d->fd < 0)
 
308
    {
 
309
      switch (wmcd_open(d)) 
 
310
        {
 
311
        case -1:        /* error */
 
312
          return (-1);
 
313
          
 
314
        case 1:         /* retry */
 
315
          return (0);
 
316
        }
 
317
    }
 
318
  
 
319
  if (ioctl(d->fd, CDROM_READ_SUBCHANNEL, &sc))
 
320
    return (0); /* ejected */
 
321
  
 
322
  switch (scd.scd_header.sh_audio_status) 
 
323
    {
 
324
    case AS_PLAY_IN_PROGRESS:
 
325
      *mode = WM_CDM_PLAYING;
 
326
dopos:
 
327
      *pos = scd.scd_position_data.scp_absaddr.msf.m_units * 60 * 75 +
 
328
        scd.scd_position_data.scp_absaddr.msf.s_units * 75 +
 
329
        scd.scd_position_data.scp_absaddr.msf.f_units;
 
330
      *track = scd.scd_position_data.scp_track_number;
 
331
      *index = scd.scd_position_data.scp_index_number;
 
332
      break;
 
333
      
 
334
    case AS_PLAY_PAUSED:
 
335
      if (oldmode == WM_CDM_PLAYING || oldmode == WM_CDM_PAUSED)
 
336
        {
 
337
          *mode = WM_CDM_PAUSED;
 
338
          goto dopos;
 
339
        }
 
340
      else
 
341
        *mode = WM_CDM_STOPPED;
 
342
      break;
 
343
      
 
344
    case AS_PLAY_COMPLETED:
 
345
      *mode = WM_CDM_TRACK_DONE; /* waiting for next track. */
 
346
      break;
 
347
      
 
348
    case AS_NO_STATUS:
 
349
      *mode = WM_CDM_STOPPED;
 
350
      break;
 
351
    }
 
352
  return (0);
 
353
} /* gen_get_drive_status() */
 
354
 
 
355
/*
 
356
 * Get the number of tracks on the CD.
 
357
 */
 
358
int
 
359
gen_get_trackcount( struct wm_drive *d, int *tracks )
 
360
{
 
361
  struct cd_toc_header  hdr;
 
362
  
 
363
  if (ioctl(d->fd, CDROM_TOC_HEADER, &hdr))
 
364
    return (-1);
 
365
  
 
366
  *tracks = hdr.th_ending_track;
 
367
  
 
368
  return (0);
 
369
} /* gen_get_trackcount() */
 
370
 
 
371
/*
 
372
 * Get the start time and mode (data or audio) of a track.
 
373
 *
 
374
 * XXX - this should get cached, but that means keeping track of ejects.
 
375
 */
 
376
int
 
377
gen_get_trackinfo(struct wm_drive *d, int track, int *data, int *startframe)
 
378
{
 
379
  struct cd_toc                         toc;
 
380
  struct cd_toc_header                  hdr;
 
381
  struct cd_toc_header_and_entries      toc_buffer;
 
382
  
 
383
  if (ioctl(d->fd, CDROM_TOC_HEADER, &hdr))
 
384
    return (-1);
 
385
  
 
386
  bzero((char *)&toc_buffer, sizeof(toc_buffer));
 
387
  toc.toc_address_format = CDROM_MSF_FORMAT;
 
388
  toc.toc_starting_track = 0;
 
389
  toc.toc_alloc_length = (u_short)(((hdr.th_data_len1 << 8) +
 
390
                                    hdr.th_data_len0) & 0xfff) + 2;
 
391
  toc.toc_buffer = (caddr_t)&toc_buffer;
 
392
  
 
393
  if (ioctl(d->fd, CDROM_TOC_ENTRYS, &toc))
 
394
    return (-1);
 
395
  
 
396
  if (track == 0)
 
397
    track = hdr.th_ending_track + 1;
 
398
  
 
399
  *data = (toc_buffer.cdte[track-1].te_control & CDROM_DATA_TRACK) ? 1:0;
 
400
  *startframe = toc_buffer.cdte[track - 1].te_absaddr.msf.m_units*60*75 +
 
401
    toc_buffer.cdte[track - 1].te_absaddr.msf.s_units * 75 +
 
402
    toc_buffer.cdte[track - 1].te_absaddr.msf.f_units;
 
403
  
 
404
  return (0);
 
405
} /* gen_get_trackinfo() */
 
406
 
 
407
/*
 
408
 * Get the number of frames on the CD.
 
409
 */
 
410
int
 
411
gen_get_cdlen(struct wm_drive *d, int *frames)
 
412
{
 
413
  int           tmp;
 
414
  return (gen_get_trackinfo(d, 0, &tmp, frames));
 
415
} /* gen_get_cdlen() */
 
416
 
 
417
/*
 
418
 * Play the CD from one position to another (both in frames.)
 
419
 */
 
420
int
 
421
gen_play( struct wm_drive *d, int start, int end )
 
422
{
 
423
  struct cd_play_audio_msf      msf;
 
424
  
 
425
  msf.msf_starting_M_unit       = start / (60*75);
 
426
  msf.msf_starting_S_unit       = (start % (60*75)) / 75;
 
427
  msf.msf_starting_F_unit       = start % 75;
 
428
  msf.msf_ending_M_unit = end / (60*75);
 
429
  msf.msf_ending_S_unit = (end % (60*75)) / 75;
 
430
  msf.msf_ending_F_unit = end % 75;
 
431
  
 
432
  if (ioctl(d->fd, SCSI_START_UNIT))
 
433
    return (-1);
 
434
  if (ioctl(d->fd, CDROM_PLAY_MSF, &msf))
 
435
    return (-2);
 
436
  
 
437
  return (0);
 
438
} /* gen_play() */
 
439
 
 
440
/*
 
441
 * Pause the CD.
 
442
 */
 
443
int
 
444
gen_pause( struct wm_drive *d )
 
445
{
 
446
  return (ioctl(d->fd, CDROM_PAUSE_PLAY));
 
447
} /* gen_pause() */
 
448
 
 
449
/*
 
450
 * Resume playing the CD (assuming it was paused.)
 
451
 */
 
452
int
 
453
gen_resume( struct wm_drive *d )
 
454
{
 
455
  return (ioctl(d->fd, CDROM_RESUME_PLAY));
 
456
} /* gen_resume() */
 
457
 
 
458
/*
 
459
 * Stop the CD.
 
460
 */
 
461
int
 
462
gen_stop( struct wm_drive *d )
 
463
{
 
464
  return (ioctl(d->fd, SCSI_STOP_UNIT));
 
465
} /* gen_stop() */
 
466
 
 
467
/*
 
468
 * Eject the current CD, if there is one.
 
469
 */
 
470
int
 
471
gen_eject(struct wm_drive *d)
 
472
{
 
473
  /* On some systems, we can check to see if the CD is mounted. */
 
474
  struct stat   stbuf;
 
475
  struct ustat  ust;
 
476
  
 
477
  if (fstat(d->fd, &stbuf) != 0)
 
478
    return (-2);
 
479
  
 
480
  /* Is this a mounted filesystem? */
 
481
  if (ustat(stbuf.st_rdev, &ust) == 0)
 
482
    return (-3);
 
483
  
 
484
  return (ioctl(d->fd, CDROM_EJECT_CADDY));
 
485
} /* gen_eject() */
 
486
 
 
487
/*----------------------------------------*
 
488
 * Close the CD tray
 
489
 *
 
490
 * Please edit and send changes to
 
491
 * milliByte@DeathsDoor.com
 
492
 *----------------------------------------*/
 
493
 
 
494
int 
 
495
gen_closetray(struct wm_drive *d)
 
496
{
 
497
#ifdef CAN_CLOSE
 
498
  if(!close(d->fd))
 
499
    {
 
500
      d->fd=-1;
 
501
      return(wmcd_reopen(d));
 
502
    } else {
 
503
      return(-1);
 
504
    }
 
505
#else
 
506
  /* Always succeed if the drive can't close */
 
507
  return(0);
 
508
#endif /* CAN_CLOSE */
 
509
} /* gen_closetray() */
 
510
 
 
511
 
 
512
/*
 
513
 * scale_volume(vol, max)
 
514
 *
 
515
 * Return a volume value suitable for passing to the CD-ROM drive.  "vol"
 
516
 * is a volume slider setting; "max" is the slider's maximum value.
 
517
 *
 
518
 * On Sun and DEC CD-ROM drives, the amount of sound coming out the jack
 
519
 * increases much faster toward the top end of the volume scale than it
 
520
 * does at the bottom.  To make up for this, we make the volume scale look
 
521
 * sort of logarithmic (actually an upside-down inverse square curve) so
 
522
 * that the volume value passed to the drive changes less and less as you
 
523
 * approach the maximum slider setting.  The actual formula looks like
 
524
 *
 
525
 *     (max^2 - (max - vol)^2) * (max_volume - min_volume)
 
526
 * v = --------------------------------------------------- + min_volume
 
527
 *                           max^2
 
528
 *
 
529
 * If your system's volume settings aren't broken in this way, something
 
530
 * like the following should work:
 
531
 *
 
532
 *      return ((vol * (max_volume - min_volume)) / max + min_volume);
 
533
 */
 
534
scale_volume( int vol, int max )
 
535
{
 
536
  return ((max * max - (max - vol) * (max - vol)) *
 
537
          (max_volume - min_volume) / (max * max) + min_volume);
 
538
} /* scale_volume() */
 
539
 
 
540
 
 
541
/*
 
542
 * unscale_volume(cd_vol, max)
 
543
 *
 
544
 * Given a value between min_volume and max_volume, return the volume slider
 
545
 * value needed to achieve that value.
 
546
 *
 
547
 * Rather than perform floating-point calculations to reverse the above
 
548
 * formula, we simply do a binary search of scale_volume()'s return values.
 
549
 */
 
550
static int
 
551
unscale_volume( int cd_vol, int max )
 
552
{
 
553
  int   vol = 0, top = max, bot = 0, scaled;
 
554
  
 
555
  while (bot <= top)
 
556
    {
 
557
      vol = (top + bot) / 2;
 
558
      scaled = scale_volume(vol, max);
 
559
      if (cd_vol == scaled)
 
560
        break;
 
561
      if (cd_vol < scaled)
 
562
        top = vol - 1;
 
563
      else
 
564
        bot = vol + 1;
 
565
    }
 
566
  
 
567
  if (vol < 0)
 
568
    vol = 0;
 
569
  else if (vol > max)
 
570
    vol = max;
 
571
  
 
572
  return (vol);
 
573
} /* unscale_volume() */
 
574
 
 
575
/*
 
576
 * Set the volume level for the left and right channels.  Their values
 
577
 * range from 0 to 100.
 
578
 */
 
579
int
 
580
gen_set_volume( struct wm_drive *d, int left, int right )
 
581
{
 
582
  struct cd_playback            pb;
 
583
  struct cd_playback_status     ps;
 
584
  struct cd_playback_control    pc;
 
585
  
 
586
  left = scale_volume(left, 100);
 
587
  right = scale_volume(right, 100);
 
588
  
 
589
  bzero((char *)&pb, sizeof(pb));
 
590
  bzero((char *)&ps, sizeof(ps));
 
591
  bzero((char *)&pc, sizeof(pc));
 
592
  
 
593
  pb.pb_alloc_length = sizeof(ps);
 
594
  pb.pb_buffer = (caddr_t)&ps;
 
595
  
 
596
  if (ioctl(d->fd, CDROM_PLAYBACK_STATUS, &pb))
 
597
    return (-1);
 
598
  
 
599
  pc.pc_chan0_select = ps.ps_chan0_select;
 
600
  pc.pc_chan0_volume = (left < CDROM_MIN_VOLUME) ?
 
601
    CDROM_MIN_VOLUME : (left > CDROM_MAX_VOLUME) ?
 
602
    CDROM_MAX_VOLUME : left;
 
603
  pc.pc_chan1_select = ps.ps_chan1_select;
 
604
  pc.pc_chan1_volume = (right < CDROM_MIN_VOLUME) ?
 
605
    CDROM_MIN_VOLUME : (right > CDROM_MAX_VOLUME) ?
 
606
    CDROM_MAX_VOLUME : right;
 
607
  
 
608
  pb.pb_alloc_length = sizeof(pc);
 
609
  pb.pb_buffer = (caddr_t)&pc;
 
610
  
 
611
  if (ioctl(d->fd, CDROM_PLAYBACK_CONTROL, &pb))
 
612
    return (-1);
 
613
  
 
614
  return (0);
 
615
} /* gen_set_volume() */
 
616
 
 
617
/*
 
618
 * Read the initial volume from the drive, if available.  Each channel
 
619
 * ranges from 0 to 100, with -1 indicating data not available.
 
620
 */
 
621
int
 
622
gen_get_volume(struct wm_drive *d, int *left, int *right)
 
623
{
 
624
  struct cd_playback            pb;
 
625
  struct cd_playback_status     ps;
 
626
  
 
627
  bzero((char *)&pb, sizeof(pb));
 
628
  bzero((char *)&ps, sizeof(ps));
 
629
  
 
630
  pb.pb_alloc_length = sizeof(ps);
 
631
  pb.pb_buffer = (caddr_t)&ps;
 
632
  
 
633
  if (d->fd >= 0)
 
634
    {
 
635
      if (ioctl(d->fd, CDROM_PLAYBACK_STATUS, &pb))
 
636
        *left = *right = -1;
 
637
      else
 
638
        {
 
639
          *left = unscale_volume(ps.ps_chan0_volume, 100);
 
640
          *right = unscale_volume(ps.ps_chan1_volume, 100);
 
641
        }
 
642
    }
 
643
  else
 
644
    *left = *right = -1;
 
645
  
 
646
  return (0);
 
647
} /* gen_get_volume() */
 
648
 
 
649
/*------------------------------------------------------------------------*
 
650
 * gen_get_cdtext(drive, buffer, lenght)
 
651
 *------------------------------------------------------------------------*/
 
652
 
 
653
int
 
654
gen_get_cdtext(struct wm_drive *d, unsigned char **pp_buffer, int *p_buffer_lenght)
 
655
{
 
656
  return -1; /* No SCSI, no CDTEXT */
 
657
} /* gen_get_cdtext() */
 
658
 
 
659
 
 
660
#endif