cdio.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. /* $OpenBSD: cdio.h,v 1.16 2006/12/23 17:35:35 krw Exp $ */
  2. /* $NetBSD: cdio.h,v 1.11 1996/02/19 18:29:04 scottr Exp $ */
  3. #ifndef _SYS_CDIO_H_
  4. #define _SYS_CDIO_H_
  5. #include <sys/types.h>
  6. #include <sys/ioccom.h>
  7. /* Shared between kernel & process */
  8. union msf_lba {
  9. struct {
  10. u_char unused;
  11. u_char minute;
  12. u_char second;
  13. u_char frame;
  14. } msf;
  15. u_int32_t lba;
  16. u_char addr[4];
  17. };
  18. struct cd_toc_entry {
  19. u_char nothing1;
  20. #if _BYTE_ORDER == _LITTLE_ENDIAN
  21. u_int control:4;
  22. u_int addr_type:4;
  23. #endif
  24. #if _BYTE_ORDER == _BIG_ENDIAN
  25. u_int addr_type:4;
  26. u_int control:4;
  27. #endif
  28. u_char track;
  29. u_char nothing2;
  30. union msf_lba addr;
  31. };
  32. struct cd_sub_channel_header {
  33. u_char nothing1;
  34. u_char audio_status;
  35. #define CD_AS_AUDIO_INVALID 0x00
  36. #define CD_AS_PLAY_IN_PROGRESS 0x11
  37. #define CD_AS_PLAY_PAUSED 0x12
  38. #define CD_AS_PLAY_COMPLETED 0x13
  39. #define CD_AS_PLAY_ERROR 0x14
  40. #define CD_AS_NO_STATUS 0x15
  41. u_char data_len[2];
  42. };
  43. struct cd_sub_channel_q_data {
  44. u_char data_format;
  45. #if _BYTE_ORDER == _LITTLE_ENDIAN
  46. u_int control:4;
  47. u_int addr_type:4;
  48. #endif
  49. #if _BYTE_ORDER == _BIG_ENDIAN
  50. u_int addr_type:4;
  51. u_int control:4;
  52. #endif
  53. u_char track_number;
  54. u_char index_number;
  55. u_char absaddr[4];
  56. u_char reladdr[4];
  57. #if _BYTE_ORDER == _LITTLE_ENDIAN
  58. u_int :7;
  59. u_int mc_valid:1;
  60. #endif
  61. #if _BYTE_ORDER == _BIG_ENDIAN
  62. u_int mc_valid:1;
  63. u_int :7;
  64. #endif
  65. u_char mc_number[15];
  66. #if _BYTE_ORDER == _LITTLE_ENDIAN
  67. u_int :7;
  68. u_int ti_valid:1;
  69. #endif
  70. #if _BYTE_ORDER == _BIG_ENDIAN
  71. u_int ti_valid:1;
  72. u_int :7;
  73. #endif
  74. u_char ti_number[15];
  75. };
  76. struct cd_sub_channel_position_data {
  77. u_char data_format;
  78. #if _BYTE_ORDER == _LITTLE_ENDIAN
  79. u_int control:4;
  80. u_int addr_type:4;
  81. #endif
  82. #if _BYTE_ORDER == _BIG_ENDIAN
  83. u_int addr_type:4;
  84. u_int control:4;
  85. #endif
  86. u_char track_number;
  87. u_char index_number;
  88. union msf_lba absaddr;
  89. union msf_lba reladdr;
  90. };
  91. struct cd_sub_channel_media_catalog {
  92. u_char data_format;
  93. u_char nothing1;
  94. u_char nothing2;
  95. u_char nothing3;
  96. #if _BYTE_ORDER == _LITTLE_ENDIAN
  97. u_int :7;
  98. u_int mc_valid:1;
  99. #endif
  100. #if _BYTE_ORDER == _BIG_ENDIAN
  101. u_int mc_valid:1;
  102. u_int :7;
  103. #endif
  104. u_char mc_number[15];
  105. };
  106. struct cd_sub_channel_track_info {
  107. u_char data_format;
  108. u_char nothing1;
  109. u_char track_number;
  110. u_char nothing2;
  111. #if _BYTE_ORDER == _LITTLE_ENDIAN
  112. u_int :7;
  113. u_int ti_valid:1;
  114. #endif
  115. #if _BYTE_ORDER == _BIG_ENDIAN
  116. u_int ti_valid:1;
  117. u_int :7;
  118. #endif
  119. u_char ti_number[15];
  120. };
  121. struct cd_sub_channel_info {
  122. struct cd_sub_channel_header header;
  123. union {
  124. struct cd_sub_channel_q_data q_data;
  125. struct cd_sub_channel_position_data position;
  126. struct cd_sub_channel_media_catalog media_catalog;
  127. struct cd_sub_channel_track_info track_info;
  128. } what;
  129. };
  130. /*
  131. * Ioctls for the CD drive
  132. */
  133. struct ioc_play_track {
  134. u_char start_track;
  135. u_char start_index;
  136. u_char end_track;
  137. u_char end_index;
  138. };
  139. #define CDIOCPLAYTRACKS _IOW('c', 1, struct ioc_play_track)
  140. struct ioc_play_blocks {
  141. int blk;
  142. int len;
  143. };
  144. #define CDIOCPLAYBLOCKS _IOW('c', 2, struct ioc_play_blocks)
  145. struct ioc_read_subchannel {
  146. u_char address_format;
  147. #define CD_LBA_FORMAT 1
  148. #define CD_MSF_FORMAT 2
  149. u_char data_format;
  150. #define CD_SUBQ_DATA 0
  151. #define CD_CURRENT_POSITION 1
  152. #define CD_MEDIA_CATALOG 2
  153. #define CD_TRACK_INFO 3
  154. u_char track;
  155. int data_len;
  156. struct cd_sub_channel_info *data;
  157. };
  158. #define CDIOCREADSUBCHANNEL _IOWR('c', 3, struct ioc_read_subchannel)
  159. struct ioc_toc_header {
  160. u_short len;
  161. u_char starting_track;
  162. u_char ending_track;
  163. };
  164. #define CDIOREADTOCHEADER _IOR('c', 4, struct ioc_toc_header)
  165. struct ioc_read_toc_entry {
  166. u_char address_format;
  167. u_char starting_track;
  168. #define CD_TRACK_LEADOUT 0xaa
  169. u_short data_len;
  170. struct cd_toc_entry *data;
  171. };
  172. #define CDIOREADTOCENTRIES _IOWR('c', 5, struct ioc_read_toc_entry)
  173. #define CDIOREADTOCENTRYS CDIOREADTOCENTRIES
  174. /* read LBA start of a given session; 0=last, others not yet supported */
  175. #define CDIOREADMSADDR _IOWR('c', 6, int)
  176. struct ioc_patch {
  177. u_char patch[4]; /* one for each channel */
  178. };
  179. #define CDIOCSETPATCH _IOW('c', 9, struct ioc_patch)
  180. struct ioc_vol {
  181. u_char vol[4]; /* one for each channel */
  182. };
  183. #define CDIOCGETVOL _IOR('c', 10, struct ioc_vol)
  184. #define CDIOCSETVOL _IOW('c', 11, struct ioc_vol)
  185. #define CDIOCSETMONO _IO('c', 12)
  186. #define CDIOCSETSTEREO _IO('c', 13)
  187. #define CDIOCSETMUTE _IO('c', 14)
  188. #define CDIOCSETLEFT _IO('c', 15)
  189. #define CDIOCSETRIGHT _IO('c', 16)
  190. #define CDIOCSETDEBUG _IO('c', 17)
  191. #define CDIOCCLRDEBUG _IO('c', 18)
  192. #define CDIOCPAUSE _IO('c', 19)
  193. #define CDIOCRESUME _IO('c', 20)
  194. #define CDIOCRESET _IO('c', 21)
  195. #define CDIOCSTART _IO('c', 22)
  196. #define CDIOCSTOP _IO('c', 23)
  197. #define CDIOCEJECT _IO('c', 24)
  198. #define CDIOCALLOW _IO('c', 25)
  199. #define CDIOCPREVENT _IO('c', 26)
  200. #define CDIOCCLOSE _IO('c', 27)
  201. #define CDIOCSETCDDA _IOW('c', 28, int) /* (re)set CDDA reading mode */
  202. struct ioc_play_msf {
  203. u_char start_m;
  204. u_char start_s;
  205. u_char start_f;
  206. u_char end_m;
  207. u_char end_s;
  208. u_char end_f;
  209. };
  210. #define CDIOCPLAYMSF _IOW('c', 25, struct ioc_play_msf)
  211. struct ioc_load_unload {
  212. u_char options;
  213. #define CD_LU_ABORT 0x1 /* NOTE: These are the same as the ATAPI */
  214. #define CD_LU_UNLOAD 0x2 /* op values for the LOAD_UNLOAD command */
  215. #define CD_LU_LOAD 0x3
  216. u_char slot;
  217. };
  218. #define CDIOCLOADUNLOAD _IOW('c', 26, struct ioc_load_unload)
  219. /* DVD definitions */
  220. /* DVD-ROM Specific ioctls */
  221. #define DVD_READ_STRUCT _IOWR('d', 0, union dvd_struct)
  222. #define DVD_WRITE_STRUCT _IOWR('d', 1, union dvd_struct)
  223. #define DVD_AUTH _IOWR('d', 2, union dvd_authinfo)
  224. #define GPCMD_READ_DVD_STRUCTURE 0xad
  225. #define GPCMD_SEND_DVD_STRUCTURE 0xad
  226. #define GPCMD_REPORT_KEY 0xa4
  227. #define GPCMD_SEND_KEY 0xa3
  228. /* DVD struct types */
  229. #define DVD_STRUCT_PHYSICAL 0x00
  230. #define DVD_STRUCT_COPYRIGHT 0x01
  231. #define DVD_STRUCT_DISCKEY 0x02
  232. #define DVD_STRUCT_BCA 0x03
  233. #define DVD_STRUCT_MANUFACT 0x04
  234. struct dvd_layer {
  235. u_int8_t book_version;
  236. u_int8_t book_type;
  237. u_int8_t min_rate;
  238. u_int8_t disc_size;
  239. u_int8_t layer_type;
  240. u_int8_t track_path;
  241. u_int8_t nlayers;
  242. u_int8_t track_density;
  243. u_int8_t linear_density;
  244. u_int8_t bca;
  245. u_int32_t start_sector;
  246. u_int32_t end_sector;
  247. u_int32_t end_sector_l0;
  248. };
  249. struct dvd_physical {
  250. u_int8_t type;
  251. u_int8_t layer_num;
  252. struct dvd_layer layer[4];
  253. };
  254. struct dvd_copyright {
  255. u_int8_t type;
  256. u_int8_t layer_num;
  257. u_int8_t cpst;
  258. u_int8_t rmi;
  259. };
  260. struct dvd_disckey {
  261. u_int8_t type;
  262. u_int8_t agid;
  263. u_int8_t value[2048];
  264. };
  265. struct dvd_bca {
  266. u_int8_t type;
  267. int len;
  268. u_int8_t value[188];
  269. };
  270. struct dvd_manufact {
  271. u_int8_t type;
  272. u_int8_t layer_num;
  273. int len;
  274. u_int8_t value[2048];
  275. };
  276. union dvd_struct {
  277. u_int8_t type;
  278. struct dvd_physical physical;
  279. struct dvd_copyright copyright;
  280. struct dvd_disckey disckey;
  281. struct dvd_bca bca;
  282. struct dvd_manufact manufact;
  283. };
  284. /*
  285. * DVD authentication ioctl
  286. */
  287. /* Authentication states */
  288. #define DVD_LU_SEND_AGID 0
  289. #define DVD_HOST_SEND_CHALLENGE 1
  290. #define DVD_LU_SEND_KEY1 2
  291. #define DVD_LU_SEND_CHALLENGE 3
  292. #define DVD_HOST_SEND_KEY2 4
  293. /* Termination states */
  294. #define DVD_AUTH_ESTABLISHED 5
  295. #define DVD_AUTH_FAILURE 6
  296. /* Other functions */
  297. #define DVD_LU_SEND_TITLE_KEY 7
  298. #define DVD_LU_SEND_ASF 8
  299. #define DVD_INVALIDATE_AGID 9
  300. #define DVD_LU_SEND_RPC_STATE 10
  301. #define DVD_HOST_SEND_RPC_STATE 11
  302. #if 0
  303. /* State data */
  304. typedef u_int8_t dvd_key[5]; /* 40-bit value, MSB is first elem. */
  305. typedef u_int8_t dvd_challenge[10]; /* 80-bit value, MSB is first elem. */
  306. #endif
  307. #define DVD_KEY_SIZE 5
  308. #define DVD_CHALLENGE_SIZE 10
  309. struct dvd_lu_send_agid {
  310. u_int8_t type;
  311. u_int8_t agid;
  312. };
  313. struct dvd_host_send_challenge {
  314. u_int8_t type;
  315. u_int8_t agid;
  316. u_int8_t chal[DVD_CHALLENGE_SIZE];
  317. };
  318. struct dvd_send_key {
  319. u_int8_t type;
  320. u_int8_t agid;
  321. u_int8_t key[DVD_KEY_SIZE];
  322. };
  323. struct dvd_lu_send_challenge {
  324. u_int8_t type;
  325. u_int8_t agid;
  326. u_int8_t chal[DVD_CHALLENGE_SIZE];
  327. };
  328. #define DVD_CPM_NO_COPYRIGHT 0
  329. #define DVD_CPM_COPYRIGHTED 1
  330. #define DVD_CP_SEC_NONE 0
  331. #define DVD_CP_SEC_EXIST 1
  332. #define DVD_CGMS_UNRESTRICTED 0
  333. #define DVD_CGMS_SINGLE 2
  334. #define DVD_CGMS_RESTRICTED 3
  335. struct dvd_lu_send_title_key {
  336. u_int8_t type;
  337. u_int8_t agid;
  338. u_int8_t title_key[DVD_KEY_SIZE];
  339. int lba;
  340. u_int8_t cpm;
  341. u_int8_t cp_sec;
  342. u_int8_t cgms;
  343. };
  344. struct dvd_lu_send_asf {
  345. u_int8_t type;
  346. u_int8_t agid;
  347. u_int8_t asf;
  348. };
  349. struct dvd_host_send_rpcstate {
  350. u_int8_t type;
  351. u_int8_t pdrc;
  352. };
  353. struct dvd_lu_send_rpcstate {
  354. u_int8_t type;
  355. u_int8_t vra;
  356. u_int8_t ucca;
  357. u_int8_t region_mask;
  358. u_int8_t rpc_scheme;
  359. };
  360. union dvd_authinfo {
  361. u_int8_t type;
  362. struct dvd_lu_send_agid lsa;
  363. struct dvd_host_send_challenge hsc;
  364. struct dvd_send_key lsk;
  365. struct dvd_lu_send_challenge lsc;
  366. struct dvd_send_key hsk;
  367. struct dvd_lu_send_title_key lstk;
  368. struct dvd_lu_send_asf lsasf;
  369. struct dvd_host_send_rpcstate hrpcs;
  370. struct dvd_lu_send_rpcstate lrpcs;
  371. };
  372. #endif /* !_SYS_CDIO_H_ */