1 /* $NetBSD: dvdio.h,v 1.5 2001/12/09 22:54:51 veego Exp $ */ 2 3 #include <sys/types.h> 4 #include <sys/ioccom.h> 5 6 /* DVD-ROM Specific ioctls */ 7 #define DVD_READ_STRUCT _IOWR('d', 0, dvd_struct) 8 #define DVD_WRITE_STRUCT _IOWR('d', 1, dvd_struct) 9 #define DVD_AUTH _IOWR('d', 2, dvd_authinfo) 10 11 #define GPCMD_READ_DVD_STRUCTURE 0xad 12 #define GPCMD_SEND_DVD_STRUCTURE 0xad 13 #define GPCMD_REPORT_KEY 0xa4 14 #define GPCMD_SEND_KEY 0xa3 15 16 /* DVD struct types */ 17 #define DVD_STRUCT_PHYSICAL 0x00 18 #define DVD_STRUCT_COPYRIGHT 0x01 19 #define DVD_STRUCT_DISCKEY 0x02 20 #define DVD_STRUCT_BCA 0x03 21 #define DVD_STRUCT_MANUFACT 0x04 22 23 struct dvd_layer { 24 u_int8_t book_version : 4; 25 u_int8_t book_type : 4; 26 u_int8_t min_rate : 4; 27 u_int8_t disc_size : 4; 28 u_int8_t layer_type : 4; 29 u_int8_t track_path : 1; 30 u_int8_t nlayers : 2; 31 u_int8_t track_density : 4; 32 u_int8_t linear_density : 4; 33 u_int8_t bca : 1; 34 u_int32_t start_sector; 35 u_int32_t end_sector; 36 u_int32_t end_sector_l0; 37 }; 38 39 struct dvd_physical { 40 u_int8_t type; 41 u_int8_t layer_num; 42 struct dvd_layer layer[4]; 43 }; 44 45 struct dvd_copyright { 46 u_int8_t type; 47 48 u_int8_t layer_num; 49 u_int8_t cpst; 50 u_int8_t rmi; 51 }; 52 53 struct dvd_disckey { 54 u_int8_t type; 55 56 unsigned agid : 2; 57 u_int8_t value[2048]; 58 }; 59 60 struct dvd_bca { 61 u_int8_t type; 62 63 int len; 64 u_int8_t value[188]; 65 }; 66 67 struct dvd_manufact { 68 u_int8_t type; 69 70 u_int8_t layer_num; 71 int len; 72 u_int8_t value[2048]; 73 }; 74 75 typedef union { 76 u_int8_t type; 77 78 struct dvd_physical physical; 79 struct dvd_copyright copyright; 80 struct dvd_disckey disckey; 81 struct dvd_bca bca; 82 struct dvd_manufact manufact; 83 } dvd_struct; 84 85 /* 86 * DVD authentication ioctl 87 */ 88 89 /* Authentication states */ 90 #define DVD_LU_SEND_AGID 0 91 #define DVD_HOST_SEND_CHALLENGE 1 92 #define DVD_LU_SEND_KEY1 2 93 #define DVD_LU_SEND_CHALLENGE 3 94 #define DVD_HOST_SEND_KEY2 4 95 96 /* Termination states */ 97 #define DVD_AUTH_ESTABLISHED 5 98 #define DVD_AUTH_FAILURE 6 99 100 /* Other functions */ 101 #define DVD_LU_SEND_TITLE_KEY 7 102 #define DVD_LU_SEND_ASF 8 103 #define DVD_INVALIDATE_AGID 9 104 #define DVD_LU_SEND_RPC_STATE 10 105 #define DVD_HOST_SEND_RPC_STATE 11 106 107 /* State data */ 108 typedef u_int8_t dvd_key[5]; /* 40-bit value, MSB is first elem. */ 109 typedef u_int8_t dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ 110 111 struct dvd_lu_send_agid { 112 u_int8_t type; 113 unsigned agid : 2; 114 }; 115 116 struct dvd_host_send_challenge { 117 u_int8_t type; 118 unsigned agid : 2; 119 120 dvd_challenge chal; 121 }; 122 123 struct dvd_send_key { 124 u_int8_t type; 125 unsigned agid : 2; 126 127 dvd_key key; 128 }; 129 130 struct dvd_lu_send_challenge { 131 u_int8_t type; 132 unsigned agid : 2; 133 134 dvd_challenge chal; 135 }; 136 137 #define DVD_CPM_NO_COPYRIGHT 0 138 #define DVD_CPM_COPYRIGHTED 1 139 140 #define DVD_CP_SEC_NONE 0 141 #define DVD_CP_SEC_EXIST 1 142 143 #define DVD_CGMS_UNRESTRICTED 0 144 #define DVD_CGMS_SINGLE 2 145 #define DVD_CGMS_RESTRICTED 3 146 147 struct dvd_lu_send_title_key { 148 u_int8_t type; 149 unsigned agid : 2; 150 151 dvd_key title_key; 152 int lba; 153 unsigned cpm : 1; 154 unsigned cp_sec : 1; 155 unsigned cgms : 2; 156 }; 157 158 struct dvd_lu_send_asf { 159 u_int8_t type; 160 unsigned agid : 2; 161 162 unsigned asf : 1; 163 }; 164 165 struct dvd_host_send_rpcstate { 166 u_int8_t type; 167 u_int8_t pdrc; 168 }; 169 170 struct dvd_lu_send_rpcstate { 171 u_int8_t type : 2; 172 u_int8_t vra : 3; 173 u_int8_t ucca : 3; 174 u_int8_t region_mask; 175 u_int8_t rpc_scheme; 176 }; 177 178 typedef union { 179 u_int8_t type; 180 181 struct dvd_lu_send_agid lsa; 182 struct dvd_host_send_challenge hsc; 183 struct dvd_send_key lsk; 184 struct dvd_lu_send_challenge lsc; 185 struct dvd_send_key hsk; 186 struct dvd_lu_send_title_key lstk; 187 struct dvd_lu_send_asf lsasf; 188 struct dvd_host_send_rpcstate hrpcs; 189 struct dvd_lu_send_rpcstate lrpcs; 190 } dvd_authinfo; 191 192 typedef struct { 193 u_int16_t report_key_length; 194 u_int8_t reserved1[2]; 195 u_int8_t ucca : 3; 196 u_int8_t vra : 3; 197 u_int8_t type_code : 2; 198 u_int8_t region_mask; 199 u_int8_t rpc_scheme; 200 u_int8_t reserved2; 201 } dvd_rpc_state_t; 202 203