home *** CD-ROM | disk | FTP | other *** search
/ ftp.cdrom.com/pub/cdrom/ / cdrom.tar / cdrom / sun_toshiba / set_raw.c < prev   
C/C++ Source or Header  |  1993-07-05  |  1KB  |  75 lines

  1. /* set_raw.c  --  Set density to 0x82 to allow reading raw CD-DA frames.
  2.  *
  3.  * Send a Mode Select command via the USCSICMD facility of the CDROM driver
  4.  * in SunOS 4.1.3. Set the Density to 0x82 and the Block Length to 2352.
  5.  *
  6.  * Author: Adrie Koolen (adrie@ica.philips.nl)
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <sys/types.h>
  11. #include <scsi/scsi_types.h>
  12. #include <scsi/impl/uscsi.h>
  13.  
  14. u_char scsibuf[] = {
  15.     0x15,    /* MODE SELECT */
  16.     0x10,    /* LUN */
  17.     0x00,
  18.     0x00,
  19.     0x0c,
  20.     0x00
  21. };
  22.  
  23. u_char databuf[] = {
  24.     0x00, 0x00, 0x00, 0x08,  0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x30
  25. };
  26.  
  27. struct uscsi_cmd usc = {
  28.     (caddr_t) scsibuf,
  29.     sizeof(scsibuf),
  30.     (caddr_t) databuf,
  31.     sizeof(databuf),
  32.     0,
  33.     (USCSI_DIAGNOSE | USCSI_ISOLATE)
  34. };
  35.  
  36. char *program;
  37.  
  38.  
  39. main(argc, argv)
  40. int argc;
  41. char *argv[];
  42. {
  43.     int fd;
  44.     int len;
  45.     int i;
  46.  
  47.     program = argv[0];
  48.  
  49.     if ((fd = open("/dev/rsr0", 0)) < 0) 
  50.         pfatal("open");
  51.  
  52.     if (ioctl(fd, USCSICMD, usc) < 0)
  53.         pfatal("ioctl");
  54.  
  55. /****
  56.     printf("ret len:%d\n", usc.uscsi_buflen);
  57.  
  58.     for (i = 0; i < usc.uscsi_buflen; i++) {
  59.         if (!(i & 0xf))
  60.             printf("\n%04x: ", i); printf("%02x ", databuf[i]);
  61.     }
  62.  
  63.     printf("\n");
  64. ****/
  65. }
  66.  
  67. pfatal(s)
  68. char *s;
  69. {
  70.     fprintf(stderr, "%s: ", program);
  71.     perror(s);
  72.     fprintf(stderr, "\n");
  73.     exit(1);
  74. }
  75.