home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / cbm / os-include.lha / os-include / devices / cd.h < prev    next >
C/C++ Source or Header  |  1993-10-15  |  12KB  |  319 lines

  1.  
  2. #ifndef DEVICES_CD_H
  3. #define DEVICES_CD_H
  4. /*
  5. **    $VER: cd.h 1.11 (12.8.93)
  6. **    Includes Release 40.15
  7. **
  8. **    cd.device include file
  9. **
  10. **    (C) Copyright 1992-1993 Commodore-Amiga, Inc.
  11. **        All Rights Reserved
  12. */
  13.  
  14. #include <exec/types.h>
  15. #include <exec/nodes.h>
  16.  
  17.  
  18. /**************************************************************************
  19.  *                                      *
  20.  *   CD Commands                              *
  21.  *                                      *
  22.  **************************************************************************/
  23.  
  24. #define CD_RESET         1
  25. #define CD_READ         2
  26. #define CD_WRITE         3
  27. #define CD_UPDATE         4
  28. #define CD_CLEAR         5
  29. #define CD_STOP         6
  30. #define CD_START         7
  31. #define CD_FLUSH         8
  32. #define CD_MOTOR         9
  33. #define CD_SEEK        10
  34. #define CD_FORMAT        11
  35. #define CD_REMOVE        12
  36. #define CD_CHANGENUM        13
  37. #define CD_CHANGESTATE        14
  38. #define CD_PROTSTATUS        15
  39.  
  40. #define CD_GETDRIVETYPE     18
  41. #define CD_GETNUMTRACKS     19
  42. #define CD_ADDCHANGEINT     20
  43. #define CD_REMCHANGEINT     21
  44. #define CD_GETGEOMETRY        22
  45. #define CD_EJECT        23
  46.  
  47.  
  48. #define CD_INFO        32
  49. #define CD_CONFIG        33
  50. #define CD_TOCMSF        34
  51. #define CD_TOCLSN        35
  52.  
  53. #define CD_READXL        36
  54.  
  55. #define CD_PLAYTRACK        37
  56. #define CD_PLAYMSF        38
  57. #define CD_PLAYLSN        39
  58. #define CD_PAUSE        40
  59. #define CD_SEARCH        41
  60.  
  61. #define CD_QCODEMSF        42
  62. #define CD_QCODELSN        43
  63. #define CD_ATTENUATE        44
  64.  
  65. #define CD_ADDFRAMEINT        45
  66. #define CD_REMFRAMEINT        46
  67.  
  68.  
  69. /**************************************************************************
  70.  *                                      *
  71.  *   Device Driver Error Codes                          *
  72.  *                                      *
  73.  **************************************************************************/
  74.  
  75. #define CDERR_OPENFAIL         (-1) /* device/unit failed to open      */
  76. #define CDERR_ABORTED         (-2) /* request terminated early          */
  77. #define CDERR_NOCMD         (-3) /* command not supported by device      */
  78. #define CDERR_BADLENGTH      (-4) /* invalid length (IO_LENGTH/IO_OFFSET) */
  79. #define CDERR_BADADDRESS     (-5) /* invalid address (IO_DATA misaligned) */
  80. #define CDERR_UNITBUSY         (-6) /* device opens ok, but unit is busy      */
  81. #define CDERR_SELFTEST         (-7) /* hardware failed self-test          */
  82.  
  83. #define CDERR_NotSpecified   20   /* general catchall              */
  84. #define CDERR_NoSecHdr         21   /* couldn't even find a sector      */
  85. #define CDERR_BadSecPreamble 22   /* sector looked wrong          */
  86. #define CDERR_BadSecID         23   /* ditto                  */
  87. #define CDERR_BadHdrSum      24   /* header had incorrect checksum      */
  88. #define CDERR_BadSecSum      25   /* data had incorrect checksum      */
  89. #define CDERR_TooFewSecs     26   /* couldn't find enough sectors      */
  90. #define CDERR_BadSecHdr      27   /* another "sector looked wrong"      */
  91. #define CDERR_WriteProt      28   /* can't write to a protected disk      */
  92. #define CDERR_NoDisk         29   /* no disk in the drive          */
  93. #define CDERR_SeekError      30   /* couldn't find track 0          */
  94. #define CDERR_NoMem         31   /* ran out of memory              */
  95. #define CDERR_BadUnitNum     32   /* asked for a unit > NUMUNITS      */
  96. #define CDERR_BadDriveType   33   /* not a drive cd.device understands      */
  97. #define CDERR_DriveInUse     34   /* someone else allocated the drive      */
  98. #define CDERR_PostReset      35   /* user hit reset; awaiting doom      */
  99. #define CDERR_BadDataType    36   /* data on disk is wrong type      */
  100. #define CDERR_InvalidState   37   /* invalid cmd under current conditions */
  101.  
  102. #define CDERR_Phase         42   /* illegal or unexpected SCSI phase      */
  103. #define CDERR_NoBoard         50   /* open failed for non-existant board   */
  104.  
  105.  
  106.  
  107. /**************************************************************************
  108.  *                                      *
  109.  * Configuration                              *
  110.  *                                      *
  111.  *     The drive is configured by TagList items defined as follows:      *
  112.  *                                      *
  113.  **************************************************************************/
  114.  
  115. #define TAGCD_PLAYSPEED    0x0001
  116. #define TAGCD_READSPEED    0x0002
  117. #define TAGCD_READXLSPEED    0x0003
  118. #define TAGCD_SECTORSIZE    0x0004
  119. #define TAGCD_XLECC        0x0005
  120. #define TAGCD_EJECTRESET    0x0006
  121.  
  122.  
  123. /**************************************************************************
  124.  *                                      *
  125.  * Information                                  *
  126.  *                                      *
  127.  *    Information/Status structure describes current speed settings      *
  128.  *    for read and play commands, sector size, audio attenuation      *
  129.  *    precision, and drive status.                      *
  130.  *                                      *
  131.  **************************************************************************/
  132.  
  133. struct CDInfo {
  134.                 /*                      Default      */
  135.     UWORD   PlaySpeed;        /* Audio play speed          (75)      */
  136.     UWORD   ReadSpeed;        /* Data-rate of CD_READ command   (Max)      */
  137.     UWORD   ReadXLSpeed;    /* Data-rate of CD_READXL command (75)      */
  138.     UWORD   SectorSize;     /* Number of bytes per sector     (2048)      */
  139.     UWORD   XLECC;        /* CDXL ECC enabled/disabled          */
  140.     UWORD   EjectReset;     /* Reset on eject enabled/disabled          */
  141.     UWORD   Reserved1[4];   /* Reserved for future expansion          */
  142.  
  143.     UWORD   MaxSpeed;        /* Maximum speed drive can handle (75, 150)   */
  144.     UWORD   AudioPrecision; /* 0 = no attenuator, 1 = mute only,      */
  145.                 /* other = (# levels - 1)              */
  146.     UWORD   Status;        /* See flags below                  */
  147.     UWORD   Reserved2[4];   /* Reserved for future expansion          */
  148.     };
  149.  
  150.  
  151. /* Flags for Status */
  152.  
  153. #define CDSTSB_CLOSED     0 /* Drive door is closed              */
  154. #define CDSTSB_DISK     1 /* A disk has been detected              */
  155. #define CDSTSB_SPIN     2 /* Disk is spinning (motor is on)          */
  156. #define CDSTSB_TOC     3 /* Table of contents read.  Disk is valid.      */
  157. #define CDSTSB_CDROM     4 /* Track 1 contains CD-ROM data          */
  158. #define CDSTSB_PLAYING     5 /* Audio is playing                  */
  159. #define CDSTSB_PAUSED     6 /* Pause mode (pauses on play command)      */
  160. #define CDSTSB_SEARCH     7 /* Search mode (Fast Forward/Fast Reverse)      */
  161. #define CDSTSB_DIRECTION 8 /* Search direction (0 = Forward, 1 = Reverse) */
  162.  
  163. #define CDSTSF_CLOSED     0x0001
  164. #define CDSTSF_DISK     0x0002
  165. #define CDSTSF_SPIN     0x0004
  166. #define CDSTSF_TOC     0x0008
  167. #define CDSTSF_CDROM     0x0010
  168. #define CDSTSF_PLAYING     0x0020
  169. #define CDSTSF_PAUSED     0x0040
  170. #define CDSTSF_SEARCH     0x0080
  171. #define CDSTSF_DIRECTION 0x0100
  172.  
  173.  
  174. /* Modes for CD_SEARCH */
  175.  
  176. #define CDMODE_NORMAL    0      /* Normal play at current play speed      */
  177. #define CDMODE_FFWD    1      /* Fast forward play (skip-play forward)*/
  178. #define CDMODE_FREV    2      /* Fast reverse play (skip-play reverse)*/
  179.  
  180.  
  181. /**************************************************************************
  182.  *                                      *
  183.  * Position Information                          *
  184.  *                                      *
  185.  *    Position information can be described in two forms: MSF and LSN   *
  186.  *    form.  MSF (Minutes, Seconds, Frames) form is a time encoding.      *
  187.  *    LSN (Logical Sector Number) form is frame (sector) count.      *
  188.  *    The desired form is selected using the io_Flags field of the      *
  189.  *    IOStdReq structure.  The flags and the union are described      *
  190.  *    below.                                  *
  191.  *                                      *
  192.  **************************************************************************/
  193.  
  194. struct RMSF {
  195.  
  196.     UBYTE   Reserved;        /* Reserved (always zero) */
  197.     UBYTE   Minute;        /* Minutes (0-72ish)      */
  198.     UBYTE   Second;        /* Seconds (0-59)          */
  199.     UBYTE   Frame;        /* Frame   (0-74)          */
  200.     };
  201.  
  202. union LSNMSF {
  203.  
  204.     struct  RMSF MSF;        /* Minute, Second, Frame  */
  205.     ULONG   LSN;        /* Logical Sector Number  */
  206.     };
  207.  
  208.  
  209. /**************************************************************************
  210.  *                                      *
  211.  * CD Transfer Lists                              *
  212.  *                                      *
  213.  *    A CDXL node is a double link node; however only single linkage      *
  214.  *    is used by the device driver.  If you wish to construct a      *
  215.  *    transfer list manually, it is only neccessary to define the      *
  216.  *    mln_Succ pointer of the MinNode.  You may also use the Exec      *
  217.  *    list functions by defining a List or MinList structure and by      *
  218.  *    using the AddHead/AddTail functions to create the list.  This      *
  219.  *    will create a double-linked list.  Although a double-linked      *
  220.  *    list is not required by the device driver, you may wish use it      *
  221.  *    for your own purposes.    Don't forget to initialize the          *
  222.  *    the List/MinList before using it!                  *
  223.  *                                      *
  224.  **************************************************************************/
  225.  
  226. struct    CDXL {
  227.  
  228.     struct MinNode    Node;           /* double linkage          */
  229.     char         *Buffer;           /* data destination (word aligned) */
  230.     LONG          Length;           /* must be even # bytes          */
  231.     LONG          Actual;           /* bytes transferred          */
  232.     APTR          IntData;           /* interrupt server data segment   */
  233.     VOID          (*IntCode)();    /* interrupt server code entry      */
  234.     };
  235.  
  236.  
  237. /**************************************************************************
  238.  *                                      *
  239.  * CD Table of Contents                          *
  240.  *                                      *
  241.  *    The CD_TOC command returns an array of CDTOC entries.          *
  242.  *    Entry zero contains summary information describing how many      *
  243.  *    tracks the disk has and the play-time of the disk.          *
  244.  *    Entries 1 through N (N = Number of tracks on disk) contain      *
  245.  *    information about the track.                      *
  246.  *                                      *
  247.  **************************************************************************/
  248.  
  249. struct TOCSummary {
  250.  
  251.     UBYTE     FirstTrack; /* First track on disk (always 1)          */
  252.     UBYTE     LastTrack;  /* Last track on disk              */
  253.     union LSNMSF LeadOut;    /* Beginning of lead-out track (end of disk) */
  254.     };
  255.  
  256.  
  257. struct TOCEntry {
  258.  
  259.     UBYTE     CtlAdr;     /* Q-Code info             */
  260.     UBYTE     Track;      /* Track number             */
  261.     union LSNMSF Position;   /* Start position of this track */
  262.     };
  263.  
  264.  
  265. union CDTOC {
  266.  
  267.     struct TOCSummary Summary;    /* First entry (0) is summary information */
  268.     struct TOCEntry   Entry;    /* Entries 1-N are track entries      */
  269.     };
  270.  
  271.  
  272.  
  273. /**************************************************************************
  274.  *                                      *
  275.  * Q-Code Packets                              *
  276.  *                                      *
  277.  *    Q-Code packets are only returned when audio is playing.      *
  278.  *    Currently, only position packets are returned (ADR_POSITION)      *
  279.  *    The other ADR_ types are almost never encoded on the disk      *
  280.  *    and are of little use anyway.  To avoid making the QCode      *
  281.  *    structure a union, these other ADR_ structures are not defined.   *
  282.  *                                      *
  283.  **************************************************************************/
  284.  
  285. struct QCode {
  286.  
  287.     UBYTE     CtlAdr;    /* Data type / QCode type        */
  288.     UBYTE     Track;    /* Track number            */
  289.     UBYTE     Index;    /* Track subindex number        */
  290.     UBYTE     Zero;        /* The "Zero" byte of Q-Code packet */
  291.     union LSNMSF TrackPosition; /* Position from start of track     */
  292.     union LSNMSF DiskPosition;    /* Position from start of disk        */
  293.     };
  294.  
  295.  
  296. #define CTLADR_CTLMASK 0xF0   /* Control field */
  297.  
  298. #define CTL_CTLMASK    0xD0   /* To be ANDed with CtlAdr before compared  */
  299.  
  300. #define CTL_2AUD       0x00   /* 2 audio channels without preemphasis      */
  301. #define CTL_2AUDEMPH   0x10   /* 2 audio channels with preemphasis      */
  302. #define CTL_4AUD       0x80   /* 4 audio channels without preemphasis      */
  303. #define CTL_4AUDEMPH   0x90   /* 4 audio channels with preemphasis      */
  304. #define CTL_DATA       0x40   /* CD-ROM Data                  */
  305.  
  306. #define CTL_COPYMASK   0x20   /* To be ANDed with CtlAdr before compared  */
  307.  
  308. #define CTL_COPY       0x20   /* When true, this audio/data can be copied */
  309.  
  310. #define CTLADR_ADRMASK 0x0F   /* Address field                  */
  311.  
  312. #define ADR_POSITION   0x01   /* Q-Code is position information      */
  313. #define ADR_UPC        0x02   /* Q-Code is UPC information (not used)      */
  314. #define ADR_ISRC       0x03   /* Q-Code is ISRC (not used)          */
  315. #define ADR_HYBRID     0x05   /* This disk is a hybrid disk          */
  316.  
  317.  
  318. #endif
  319.