1 /*
2     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
3     SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #ifndef _K3B_DEVICE_TYPES_H_
7 #define _K3B_DEVICE_TYPES_H_
8 
9 #include <QFlags>
10 
11 namespace K3b {
12     namespace Device {
13         const unsigned short FEATURE_PROFILE_LIST = 0x000;
14         const unsigned short FEATURE_CORE = 0x001;
15         const unsigned short FEATURE_MORPHING = 0x002;
16         const unsigned short FEATURE_REMOVABLE_MEDIA = 0x003;
17         const unsigned short FEATURE_WRITE_PROTECT = 0x004;
18         const unsigned short FEATURE_RANDOM_READABLE = 0x010;
19         const unsigned short FEATURE_MULTI_READ = 0x01D;
20         const unsigned short FEATURE_CD_READ = 0x01E;
21         const unsigned short FEATURE_DVD_READ = 0x01F;
22         const unsigned short FEATURE_RANDOM_WRITABLE = 0x020;
23         const unsigned short FEATURE_INCREMENTAL_STREAMING_WRITABLE = 0x021;
24         const unsigned short FEATURE_SECTOR_ERASABLE = 0x022;
25         const unsigned short FEATURE_FORMATTABLE = 0x023;
26         const unsigned short FEATURE_DEFECT_MANAGEMENT = 0x024;
27         const unsigned short FEATURE_WRITE_ONCE = 0x025;
28         const unsigned short FEATURE_RESTRICTED_OVERWRITE = 0x026;
29         const unsigned short FEATURE_CD_RW_CAV_WRITE = 0x027;
30         const unsigned short FEATURE_MRW = 0x028;
31         const unsigned short FEATURE_ENHANCED_DEFECT_REPORTING = 0x029;
32         const unsigned short FEATURE_DVD_PLUS_RW = 0x02A;
33         const unsigned short FEATURE_DVD_PLUS_R = 0x02B;
34         const unsigned short FEATURE_RIGID_RESTRICTED_OVERWRITE = 0x02C;
35         const unsigned short FEATURE_CD_TRACK_AT_ONCE = 0x02D;
36         const unsigned short FEATURE_CD_MASTERING = 0x02E;
37         const unsigned short FEATURE_DVD_R_RW_WRITE = 0x02F;
38         const unsigned short FEATURE_DDCD_READ = 0x030;
39         const unsigned short FEATURE_DDCD_R_WRITE = 0x031;
40         const unsigned short FEATURE_DDCD_RW_WRITE = 0x032;
41         const unsigned short FEATURE_LAYER_JUMP_RECORDING = 0x033;
42         const unsigned short FEATURE_CD_RW_MEDIA_WRITE_SUPPORT = 0x037;
43         const unsigned short FEATURE_BD_PSEUDO_OVERWRITE = 0x038;
44         const unsigned short FEATURE_DVD_PLUS_RW_DUAL_LAYER = 0x03A;            /**< since MMC5 revision 3 */
45         const unsigned short FEATURE_DVD_PLUS_R_DUAL_LAYER = 0x03B;
46         const unsigned short FEATURE_BD_READ = 0x040;
47         const unsigned short FEATURE_BD_WRITE = 0x041;
48         const unsigned short FEATURE_HD_DVD_READ = 0x050;
49         const unsigned short FEATURE_HD_DVD_WRITE = 0x051;
50         const unsigned short FEATURE_POWER_MANAGEMENT = 0x100;
51         const unsigned short FEATURE_EMBEDDED_CHANGER = 0x102;
52         const unsigned short FEATURE_CD_AUDIO_ANALOG_PLAY = 0x103;
53         const unsigned short FEATURE_MICROCODE_UPGRADE = 0x104;
54         const unsigned short FEATURE_TIMEOUT = 0x105;
55         const unsigned short FEATURE_DVD_CSS = 0x106;
56         const unsigned short FEATURE_REAL_TIME_STREAMING = 0x107;
57         const unsigned short FEATURE_LOGICAL_UNIT_SERIAL_NUMBER = 0x108;
58         const unsigned short FEATURE_DISC_CONTROL_BLOCKS = 0x10A;
59         const unsigned short FEATURE_DVD_CPRM = 0x10B;
60         const unsigned short FEATURE_FIRMWARE_DATE = 0x10C;
61 
62         enum Interface {
63             SCSI,        /**< The device is accessed through the SCSI subsystem. */
64             IDE,         /**< The device is accessed through the IDE (ATAPI) interface. */
65             OTHER        /**< Unknown interface (this is not used as the DeviceManager does only handle SCSI and IDE anyway). */
66         };
67 
68         /**
69          * Specifies the device type. Device::type() returns a bitwise or
70          * of device types.
71          */
72         enum DeviceType {
73             DEVICE_CD_ROM = 0x1,          /**< Device reads CD-ROM media (every device in K3b supports this.) */
74             DEVICE_CD_R = 0x2,            /**< Device writes CD-R media */
75             DEVICE_CD_RW = 0x4,           /**< Device writes CD-RW media */
76             DEVICE_DVD_ROM = 0x8,         /**< Device reads DVD-ROM media */
77             DEVICE_DVD_RAM = 0x10,        /**< Device writes DVD-RAM media */
78             DEVICE_DVD_R = 0x20,          /**< Device writes DVD-R media */
79             DEVICE_DVD_RW = 0x40,         /**< Device writes DVD-RW media */
80             DEVICE_DVD_R_DL = 0x80,       /**< Device writes DVD-R Dual Layer media */
81             DEVICE_DVD_PLUS_R = 0x100,    /**< Device writes DVD+R media */
82             DEVICE_DVD_PLUS_RW = 0x200,   /**< Device writes DVD+RW media */
83             DEVICE_DVD_PLUS_R_DL = 0x400, /**< Device writes DVD+R Double Layer media */
84             DEVICE_HD_DVD_ROM = 0x800,    /**< Device reads HD DVD-ROM media */
85             DEVICE_HD_DVD_R = 0x1000,     /**< Device writes HD DVD-R media */
86             DEVICE_HD_DVD_RAM = 0x2000,   /**< Device writes HD DVD-RAM media */
87             DEVICE_BD_ROM = 0x4000,       /**< Device reads BD-ROM media */
88             DEVICE_BD_R = 0x8000,         /**< Device writes BD-R media */
89             DEVICE_BD_RE = 0x10000        /**< Device writes BD-RE media */
90         };
91         Q_DECLARE_FLAGS( DeviceTypes, DeviceType )
92 
93         /**
94          * The different writing modes. Device::writingModes() returns a bitwise or of writing modes.
95          */
96         enum WritingMode {
97             WRITINGMODE_SAO = 0x1,           /**< Device writes CD or DVD-R media in Session at once (also known as DAO) writing mode */
98             WRITINGMODE_SAO_R96P = 0x2,      /**< Device writes CD media with packed R-W subchannels Session at once writing mode */
99             WRITINGMODE_SAO_R96R = 0x4,      /**< Device writes CD media with raw R-W subchannels Session at once writing mode */
100             WRITINGMODE_TAO = 0x8,           /**< Device writes CD media in Track at once writing mode */
101             WRITINGMODE_RAW = 0x10,          /**< Device writes CD media in Raw writing mode */
102             WRITINGMODE_RAW_R16 = 0x20,      /**< Device writes CD media with P/Q subchannels in Raw writing mode */
103             WRITINGMODE_RAW_R96P = 0x40,     /**< Device writes CD media with packed R-W subchannels Raw writing mode */
104             WRITINGMODE_RAW_R96R = 0x80,     /**< Device writes CD media with raw R-W subchannels Raw writing mode */
105             WRITINGMODE_INCR_SEQ = 0x100,    /**< Device writes DVD-R(W) media in incremental sequential writing mode */
106             WRITINGMODE_RES_OVWR = 0x200,    /**< Device writes DVD-RW media in restricted overwrite mode */
107             WRITINGMODE_LAYER_JUMP = 0x400,  /**< Device writes DVD-R Dual layer media in Layer Jump writing mode */
108             WRITINGMODE_RRM = 0x800,         /**< Device writes BD-R media in Random Recording Mode */
109             WRITINGMODE_SRM = 0x1000,        /**< Device writes BD-R media in Sequential recording mode */
110             WRITINGMODE_SRM_POW = 0x2000     /**< Device writes BD-R media in Pseudo overwrite Sequential recording mode */
111         };
112         Q_DECLARE_FLAGS( WritingModes, WritingMode )
113 
114         enum MediaState {
115             STATE_UNKNOWN = 0x1,    /**< Media state is unknown (when an error occurred or the device is unable to determine the media state). */
116             STATE_NO_MEDIA = 0x2,   /**< No media inserted. */
117             STATE_COMPLETE = 0x4,   /**< The inserted media is complete. */
118             STATE_INCOMPLETE = 0x8, /**< The inserted media is incomplete/appendable. */
119             STATE_EMPTY = 0x10,     /**< The inserted media is empty. */
120             STATE_ALL = STATE_COMPLETE|STATE_INCOMPLETE|STATE_EMPTY
121         };
122         Q_DECLARE_FLAGS( MediaStates, MediaState )
123 
124         enum BackGroundFormattingState {
125             BG_FORMAT_INVALID = 0x0,
126             BG_FORMAT_NONE = 0x1,
127             BG_FORMAT_INCOMPLETE = 0x2,
128             BG_FORMAT_IN_PROGRESS = 0x4,
129             BG_FORMAT_COMPLETE = 0x8
130         };
131         Q_DECLARE_FLAGS( BackGroundFormattingStates, BackGroundFormattingState )
132 
133         /**
134          * Defines the media types used throughout K3b.
135          * For all groups of media a flag is defined like MEDIA_REWRITABLE_DVD.
136          *
137          * None of the flags is defines as 0 so we can actually include things like
138          * MEDIA_NONE in flag combinations. This is important when specifying sets
139          * of supported media or the like.
140          */
141         enum MediaType {
142             /** Represents an unknown media type (when an error occurred) */
143             MEDIA_UNKNOWN = 0x1,
144 
145             /** No medium is inserted. */
146             MEDIA_NONE = 0x2,
147 
148             /** DVD-ROM media */
149             MEDIA_DVD_ROM = 0x4,
150 
151             MEDIA_DVD_R = 0x8,
152 
153             MEDIA_DVD_R_SEQ = 0x10,
154 
155             /** Dual Layer DVD-R media. */
156             MEDIA_DVD_R_DL = 0x20,
157 
158             MEDIA_DVD_R_DL_SEQ = 0x40,
159 
160             MEDIA_DVD_R_DL_JUMP = 0x80,
161 
162             MEDIA_DVD_RAM = 0x100,
163 
164             MEDIA_DVD_RW = 0x200,
165 
166             /** DVD-RW media formatted in Restricted Overwrite mode. */
167             MEDIA_DVD_RW_OVWR = 0x400,
168 
169             /** DVD-RW media formatted in Incremental Sequential mode. */
170             MEDIA_DVD_RW_SEQ = 0x800,
171 
172             MEDIA_DVD_PLUS_RW = 0x1000,
173 
174             MEDIA_DVD_PLUS_R = 0x2000,
175 
176             /** Double Layer DVD+R media. */
177             MEDIA_DVD_PLUS_R_DL = 0x4000,
178 
179             /** Double Layer DVD+RW media. */
180             MEDIA_DVD_PLUS_RW_DL = 0x8000,
181 
182             MEDIA_CD_ROM = 0x10000,
183             MEDIA_CD_R = 0x20000,
184             MEDIA_CD_RW = 0x40000,
185             MEDIA_HD_DVD_ROM = 0x80000,
186             MEDIA_HD_DVD_R = 0x100000,
187             MEDIA_HD_DVD_RAM = 0x200000,
188 
189             /** Read-only Blu-ray Disc (BD) */
190             MEDIA_BD_ROM = 0x400000,
191 
192             /** Writable Blu-ray Disc (BD-R) */
193             MEDIA_BD_R = 0x800000,
194 
195             /** Writable Blu-ray Disc (BD-R) */
196             MEDIA_BD_R_SRM = 0x1000000,
197 
198             /** Writable Blu-ray Disc (BD-R) */
199             MEDIA_BD_R_SRM_POW = 0x2000000,
200 
201             /** Writable Blu-ray Disc (BD-R) */
202             MEDIA_BD_R_RRM = 0x4000000,
203 
204             /** Rewritable Blu-ray Disc (BD-RE) */
205             MEDIA_BD_RE = 0x8000000,
206 
207             /** This is a bitwise or of media types representing all writable CD media.*/
208             MEDIA_WRITABLE_CD = MEDIA_CD_R |
209             MEDIA_CD_RW,
210 
211             MEDIA_CD_ALL = MEDIA_WRITABLE_CD |
212             MEDIA_CD_ROM,
213 
214             MEDIA_REWRITABLE_DVD_SL = MEDIA_DVD_RW |
215             MEDIA_DVD_RW_OVWR |
216             MEDIA_DVD_RW_SEQ |
217             MEDIA_DVD_PLUS_RW,
218 
219             MEDIA_REWRITABLE_DVD_DL = MEDIA_DVD_PLUS_RW_DL,
220 
221             MEDIA_REWRITABLE_DVD = MEDIA_REWRITABLE_DVD_SL |
222             MEDIA_DVD_PLUS_RW_DL,
223 
224             /** This is a bitwise or of media types representing all writable single layer DVD media. */
225             MEDIA_WRITABLE_DVD_SL = MEDIA_REWRITABLE_DVD_SL |
226             MEDIA_DVD_R |
227             MEDIA_DVD_R_SEQ |
228             MEDIA_DVD_RW |
229             MEDIA_DVD_RW_OVWR |
230             MEDIA_DVD_RW_SEQ |
231             MEDIA_DVD_PLUS_RW |
232             MEDIA_DVD_PLUS_R,
233 
234             /** This is a bitwise or of media types representing all writable double layer DVD media. */
235             MEDIA_WRITABLE_DVD_DL = MEDIA_REWRITABLE_DVD_DL |
236             MEDIA_DVD_R_DL |
237             MEDIA_DVD_R_DL_SEQ |
238             MEDIA_DVD_R_DL_JUMP |
239             MEDIA_DVD_PLUS_R_DL |
240             MEDIA_DVD_PLUS_RW_DL,
241 
242             /** This is a bitwise or of media types representing all writable DVD media. */
243             MEDIA_WRITABLE_DVD = MEDIA_WRITABLE_DVD_SL |
244             MEDIA_WRITABLE_DVD_DL,
245 
246             MEDIA_REWRITABLE_BD = MEDIA_BD_RE,
247 
248             /** This is a bitwise or of media types representing all writable BD media. */
249             MEDIA_WRITABLE_BD = MEDIA_REWRITABLE_BD |
250             MEDIA_BD_R |
251             MEDIA_BD_R_SRM |
252             MEDIA_BD_R_SRM_POW |
253             MEDIA_BD_R_RRM,
254 
255             /** This is a bitwise or of media types representing all writable media. */
256             MEDIA_WRITABLE = MEDIA_WRITABLE_CD |
257             MEDIA_WRITABLE_DVD |
258             MEDIA_WRITABLE_BD,
259 
260             MEDIA_REWRITABLE = MEDIA_CD_RW |
261             MEDIA_REWRITABLE_DVD |
262             MEDIA_REWRITABLE_BD,
263 
264             /** This is a bitwise or of media types representing all DVD-R/W media. */
265             MEDIA_DVD_MINUS_ALL = MEDIA_DVD_R |
266             MEDIA_DVD_R_SEQ |
267             MEDIA_DVD_RW |
268             MEDIA_DVD_RW_OVWR |
269             MEDIA_DVD_RW_SEQ |
270             MEDIA_DVD_R_DL |
271             MEDIA_DVD_R_DL_SEQ |
272             MEDIA_DVD_R_DL_JUMP,
273 
274             /** This is a bitwise or of media types representing all DVD+R/W media. */
275             MEDIA_DVD_PLUS_ALL = MEDIA_DVD_PLUS_RW |
276             MEDIA_DVD_PLUS_R |
277             MEDIA_DVD_PLUS_R_DL |
278             MEDIA_DVD_PLUS_RW_DL,
279 
280             MEDIA_DVD_ALL = MEDIA_WRITABLE_DVD |
281             MEDIA_DVD_ROM,
282 
283             MEDIA_BD_ALL = MEDIA_WRITABLE_BD |
284             MEDIA_BD_ROM,
285 
286             MEDIA_ALL = MEDIA_CD_ALL |
287             MEDIA_DVD_ALL |
288             MEDIA_BD_ALL
289         };
290         Q_DECLARE_FLAGS( MediaTypes, MediaType )
291 
292         enum SpeedMultiplicator {
293             SPEED_FACTOR_CD = 175,
294             SPEED_FACTOR_CD_MODE1 = 150,
295             SPEED_FACTOR_DVD = 1385,
296             SPEED_FACTOR_BD = 4496 // 4495.5
297         };
298 
299         enum CopyrightProtectionSytemType {
300             COPYRIGHT_PROTECTION_NONE = 0x0,
301             COPYRIGHT_PROTECTION_CSS = 0x1,
302             COPYRIGHT_PROTECTION_CPRM = 0x2,
303             COPYRIGHT_PROTECTION_AACS_HD_DVD = 0x3,
304             COPYRIGHT_PROTECTION_AACS_BD = 0x10
305         };
306 
isDvdMedia(MediaTypes mediaType)307         inline bool isDvdMedia( MediaTypes mediaType ) {
308             return ( mediaType & MEDIA_DVD_ALL );
309         }
310 
isCdMedia(MediaTypes mediaType)311         inline bool isCdMedia( MediaTypes mediaType ) {
312             return ( mediaType & MEDIA_CD_ALL );
313         }
314 
isBdMedia(MediaTypes mediaType)315         inline bool isBdMedia( MediaTypes mediaType ) {
316             return ( mediaType & MEDIA_BD_ALL );
317         }
318 
isRewritableMedia(MediaTypes mediaType)319         inline bool isRewritableMedia( MediaTypes mediaType ) {
320             return ( mediaType & MEDIA_REWRITABLE );
321         }
322     }
323 }
324 
325 Q_DECLARE_OPERATORS_FOR_FLAGS(K3b::Device::DeviceTypes)
326 Q_DECLARE_OPERATORS_FOR_FLAGS(K3b::Device::WritingModes)
327 Q_DECLARE_OPERATORS_FOR_FLAGS(K3b::Device::MediaStates)
328 Q_DECLARE_OPERATORS_FOR_FLAGS(K3b::Device::BackGroundFormattingStates)
329 Q_DECLARE_OPERATORS_FOR_FLAGS(K3b::Device::MediaTypes)
330 
331 #endif
332