cd.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /* $OpenBSD: cd.h,v 1.25 2009/12/16 10:51:28 dlg Exp $ */
  2. /* $NetBSD: scsi_cd.h,v 1.6 1996/03/19 03:06:39 mycroft Exp $ */
  3. /*
  4. * Written by Julian Elischer (julian@tfs.com)
  5. * for TRW Financial Systems.
  6. *
  7. * TRW Financial Systems, in accordance with their agreement with Carnegie
  8. * Mellon University, makes this software available to CMU to distribute
  9. * or use in any manner that they see fit as long as this message is kept with
  10. * the software. For this reason TFS also grants any other persons or
  11. * organisations permission to use or modify this software.
  12. *
  13. * TFS supplies this software to be publicly redistributed
  14. * on the understanding that TFS is not responsible for the correct
  15. * functioning of this software in any circumstances.
  16. *
  17. * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
  18. */
  19. #ifndef _SCSI_CD_H
  20. #define _SCSI_CD_H 1
  21. /*
  22. * Define two bits always in the same place in byte 2 (flag byte)
  23. */
  24. #define CD_RELADDR 0x01
  25. #define CD_MSF 0x02
  26. /*
  27. * SCSI command format
  28. */
  29. struct scsi_blank {
  30. u_int8_t opcode;
  31. u_int8_t byte2;
  32. #define BLANK_DISC 0
  33. #define BLANK_MINIMAL 1
  34. u_int8_t addr[4];
  35. u_int8_t unused[5];
  36. u_int8_t control;
  37. };
  38. struct scsi_close_track {
  39. u_int8_t opcode;
  40. u_int8_t flags;
  41. #define CT_IMMED 1
  42. u_int8_t closefunc;
  43. #define CT_CLOSE_TRACK 1
  44. #define CT_CLOSE_SESS 2
  45. #define CT_CLOSE_BORDER 3
  46. u_int8_t unused;
  47. u_int8_t track[2];
  48. u_int8_t unused1[3];
  49. u_int8_t control;
  50. };
  51. struct scsi_pause {
  52. u_int8_t opcode;
  53. u_int8_t byte2;
  54. u_int8_t unused[6];
  55. u_int8_t resume;
  56. u_int8_t control;
  57. };
  58. #define PA_PAUSE 1
  59. #define PA_RESUME 0
  60. struct scsi_play_msf {
  61. u_int8_t opcode;
  62. u_int8_t byte2;
  63. u_int8_t unused;
  64. u_int8_t start_m;
  65. u_int8_t start_s;
  66. u_int8_t start_f;
  67. u_int8_t end_m;
  68. u_int8_t end_s;
  69. u_int8_t end_f;
  70. u_int8_t control;
  71. };
  72. struct scsi_play_track {
  73. u_int8_t opcode;
  74. u_int8_t byte2;
  75. u_int8_t unused[2];
  76. u_int8_t start_track;
  77. u_int8_t start_index;
  78. u_int8_t unused1;
  79. u_int8_t end_track;
  80. u_int8_t end_index;
  81. u_int8_t control;
  82. };
  83. struct scsi_play {
  84. u_int8_t opcode;
  85. u_int8_t byte2;
  86. u_int8_t blk_addr[4];
  87. u_int8_t unused;
  88. u_int8_t xfer_len[2];
  89. u_int8_t control;
  90. };
  91. struct scsi_play_big {
  92. u_int8_t opcode;
  93. u_int8_t byte2; /* same as above */
  94. u_int8_t blk_addr[4];
  95. u_int8_t xfer_len[4];
  96. u_int8_t unused;
  97. u_int8_t control;
  98. };
  99. struct scsi_play_rel_big {
  100. u_int8_t opcode;
  101. u_int8_t byte2; /* same as above */
  102. u_int8_t blk_addr[4];
  103. u_int8_t xfer_len[4];
  104. u_int8_t track;
  105. u_int8_t control;
  106. };
  107. struct scsi_read_header {
  108. u_int8_t opcode;
  109. u_int8_t byte2;
  110. u_int8_t blk_addr[4];
  111. u_int8_t unused;
  112. u_int8_t data_len[2];
  113. u_int8_t control;
  114. };
  115. struct scsi_read_subchannel {
  116. u_int8_t opcode;
  117. u_int8_t byte2;
  118. u_int8_t byte3;
  119. #define SRS_SUBQ 0x40
  120. u_int8_t subchan_format;
  121. u_int8_t unused[2];
  122. u_int8_t track;
  123. u_int8_t data_len[2];
  124. u_int8_t control;
  125. };
  126. struct scsi_read_toc {
  127. u_int8_t opcode;
  128. u_int8_t byte2;
  129. u_int8_t unused[4];
  130. u_int8_t from_track;
  131. u_int8_t data_len[2];
  132. u_int8_t control;
  133. };
  134. struct scsi_read_track_info {
  135. u_int8_t opcode;
  136. u_int8_t addrtype;
  137. #define RTI_LBA 0
  138. #define RTI_TRACK 1
  139. #define RTI_BORDER 2
  140. u_int8_t addr[4];
  141. u_int8_t unused;
  142. u_int8_t data_len[2];
  143. u_int8_t control;
  144. };
  145. struct scsi_load_unload {
  146. u_int8_t opcode;
  147. u_int8_t reserved;
  148. #define IMMED 0x1
  149. u_int8_t reserved2[2];
  150. u_int8_t options;
  151. #define START 0x1
  152. #define LOUNLO 0x2
  153. u_int8_t reserved4[3];
  154. u_int8_t slot;
  155. u_int8_t reserved5[2];
  156. u_int8_t control;
  157. };
  158. struct scsi_set_cd_speed {
  159. u_int8_t opcode;
  160. u_int8_t rotation;
  161. #define ROTATE_CLV 0
  162. #define ROTATE_CAV 1
  163. u_int8_t read[2];
  164. u_int8_t write[2];
  165. u_int8_t reserved[5];
  166. u_int8_t control;
  167. };
  168. /*
  169. * Opcodes
  170. */
  171. #define READ_SUBCHANNEL 0x42 /* cdrom read Subchannel */
  172. #define READ_TOC 0x43 /* cdrom read TOC */
  173. #define READ_HEADER 0x44 /* cdrom read header */
  174. #define PLAY 0x45 /* cdrom play 'play audio' mode */
  175. #define PLAY_MSF 0x47 /* cdrom play Min,Sec,Frames mode */
  176. #define PLAY_TRACK 0x48 /* cdrom play track/index mode */
  177. #define PLAY_TRACK_REL 0x49 /* cdrom play track/index mode */
  178. #define PAUSE 0x4b /* cdrom pause in 'play audio' mode */
  179. #define READ_TRACK_INFO 0x52 /* read track/rzone info */
  180. #define CLOSE_TRACK 0x5b /* close track/rzone/session/border */
  181. #define BLANK 0xa1 /* cdrom blank */
  182. #define PLAY_BIG 0xa5 /* cdrom pause in 'play audio' mode */
  183. #define LOAD_UNLOAD 0xa6 /* cdrom load/unload media */
  184. #define PLAY_TRACK_REL_BIG 0xa9 /* cdrom play track/index mode */
  185. #define SET_CD_SPEED 0xbb /* set cdrom read/write speed */
  186. /*
  187. * Mode pages
  188. */
  189. #define ERR_RECOVERY_PAGE 0x01
  190. #define WRITE_PARAM_PAGE 0x05
  191. #define CDVD_CAPABILITIES_PAGE 0x2a
  192. struct cd_audio_page {
  193. u_int8_t page_code;
  194. #define CD_PAGE_CODE 0x3F
  195. #define AUDIO_PAGE 0x0e
  196. #define CD_PAGE_PS 0x80
  197. u_int8_t param_len;
  198. u_int8_t flags;
  199. #define CD_PA_SOTC 0x02
  200. #define CD_PA_IMMED 0x04
  201. u_int8_t unused[2];
  202. u_int8_t format_lba;
  203. #define CD_PA_FORMAT_LBA 0x0F
  204. #define CD_PA_APR_VALID 0x80
  205. u_int8_t lb_per_sec[2];
  206. struct port_control {
  207. u_int8_t channels;
  208. #define CHANNEL 0x0F
  209. #define CHANNEL_0 1
  210. #define CHANNEL_1 2
  211. #define CHANNEL_2 4
  212. #define CHANNEL_3 8
  213. #define LEFT_CHANNEL CHANNEL_0
  214. #define RIGHT_CHANNEL CHANNEL_1
  215. #define MUTE_CHANNEL 0x0
  216. #define BOTH_CHANNEL LEFT_CHANNEL | RIGHT_CHANNEL
  217. u_int8_t volume;
  218. } port[4];
  219. #define LEFT_PORT 0
  220. #define RIGHT_PORT 1
  221. };
  222. /*
  223. * There are 2352 bytes in a CD digital audio frame. One frame is 1/75 of a
  224. * second, at 44.1kHz sample rate, 16 bits/sample, 2 channels.
  225. *
  226. * The frame data have the two channels interleaved, with the left
  227. * channel first. Samples are little endian 16-bit signed values.
  228. */
  229. #define CD_DA_BLKSIZ 2352 /* # bytes in CD-DA frame */
  230. #define CD_NORMAL_DENSITY_CODE 0x00 /* from Toshiba CD-ROM specs */
  231. #define CD_DA_DENSITY_CODE 0x82 /* from Toshiba CD-ROM specs */
  232. struct scsi_read_dvd_structure {
  233. u_int8_t opcode; /* GPCMD_READ_DVD_STRUCTURE */
  234. u_int8_t reserved;
  235. u_int8_t address[4];
  236. u_int8_t layer;
  237. u_int8_t format;
  238. u_int8_t length[2];
  239. u_int8_t agid; /* bottom 6 bits reserved */
  240. u_int8_t control;
  241. };
  242. struct scsi_read_dvd_structure_data {
  243. u_int8_t len[2]; /* Big-endian length of valid data. */
  244. u_int8_t reserved[2];
  245. u_int8_t data[2048];
  246. };
  247. #endif