You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1520 lines
71 KiB

  1. -------------------------------------------------------------------------------
  2. Note: This is about how libburn operates optical drives. Not about how to
  3. operate libburn. The libburn API is described in libburn/libburn.h
  4. -------------------------------------------------------------------------------
  5. libburnia-project.org Optical Media Rotisserie Recipes as of December 2011
  6. Content:
  7. - TAO Multi-Session CD Cookbook (CD-R, CD-RW)
  8. - SAO CD Cookbook (CD-R, CD-RW, pure audio or pure data only)
  9. - Overwriteable DVD Cookbook (DVD-RAM, DVD+RW, DVD-RW, BD-RE)
  10. - Sequential DVD-R[W] Cookbook
  11. - DVD+R[/DL] Cookbook
  12. - BD-R Cookbook
  13. -------------------------------------------------------------------------------
  14. TAO Multi-Session CD Cookbook
  15. -------------------------------------------------------------------------------
  16. Guided by reading mmc-r10a.pdf , O.8 "Write a Track"
  17. from http://www.t10.org/ftp/t10/drafts/mmc/
  18. backed by reading mmc5r03c.pdf from http://www.t10.org/ftp/t10/drafts/mmc5/
  19. by reading spc3r23.pdf from http://www.t10.org/ftp/t10/drafts/spc3/
  20. by reading libburn/* from http://icculus.org/burn
  21. and by experiments with drives NEC ND-4570A, LG GSA-4082B, LITE-ON LTR48125S
  22. which used in part code from http://icculus.org/burn.
  23. For libburnia-project.org by Thomas Schmitt <scdbackup@gmx.net>
  24. -------------------------------------------------------------------------------
  25. Media type can be recognized by Current Profile from 46h GET CONFIGURATION.
  26. (mmc5r03c.pdf 6.6.2.1)
  27. CD-R 0009h
  28. CD-RW 000ah
  29. The following topics are covered in this text:
  30. - About blank, appendable and finalized CD media
  31. - Writing a session to CD in TAO mode
  32. - Obtaining CD multi-session info for extending ISO-9660 filesystems
  33. - Obtaining a Table Of Content from CD
  34. -------------------------------------------------------------------------------
  35. About blank, appendable and finalized CD media :
  36. CD media have to be blank or appendable in order to be writeable in TAO mode.
  37. The according status may be inquired by 51h READ DISC INFORMATION requesting
  38. Data Type 000b Standard Disc Information, where reply value Disc Status
  39. indicates:
  40. 00b blank
  41. 01b appendable
  42. 10b finalized
  43. 11b others (unsuitable for this recipe)
  44. (mmc5r03c.pdf 6.22.3.1.4)
  45. CD-RW which are finalized or appendable may be blanked by command A1h BLANK
  46. with blanking types 000b "Blank the disc" or 001b "Minimally blank the disc".
  47. The Start Address/Track Number will be ignored so it may well be 0.
  48. Because the operation is long running it is advised to set the Immed bit and to
  49. watch the progress by commands 00h TEST UNIT READY and 03h REQUEST SENSE
  50. with DESC bit set to 0 for fixed format reply.
  51. It is done when 00h succeeds and 03h reports 0 in PROGRESS INDICATION
  52. (byte 1+2 in Table 22 = byte 16+17 SENSE KEY SPECIFIC in table 26).
  53. (mmc5r03c.pdf 6.2 BLANK)
  54. (spc3r23.pdf 4.5.2.4.4 table 22, 4.5.3 table 26,
  55. 6.27 REQUEST SENSE, 6.33 TEST UNIT READY)
  56. -------------------------------------------------------------------------------
  57. Writing a session to CD in TAO mode :
  58. The writing method for blank or appendable media is the same. A new session
  59. will get created automatically by the first track when it is written. If the
  60. media is blank then the new session will be the first and only one in the
  61. table of content. If the media is appendable then a new session will be
  62. appended to the existing sessions. In any case the new track will be the
  63. first one in the new session.
  64. Speed may be set by BBh SET CD SPEED parameter Drive Write Speed. Note that
  65. kbytes/sec means 1000 bytes/sec and not 1024/sec. Rotational control should
  66. be set to 00b. 1x CD speed is 176.4 kbytes/sec. Speed is usually set to the
  67. next lower possible value by the drive. So it is helpful to add a few
  68. kbytes/sec just in case the drive has rounding problems.
  69. (mmc5r03c.pdf 6.37)
  70. Before writing can occur, a Write Parameters mode page 05h has to be composed
  71. and transmitted via 55h MODE SELECT. Mode page 05h describes several burn
  72. parameters:
  73. BUFE Buffer Underrun protection 0=off, 1=on
  74. Test Write -dummy mode for writing 0=off, 1=on
  75. Write Type Packet/TAO/SAO/RAW 01h = TAO
  76. Multi-session Whether to keep appendable 00b = finalize
  77. 11b = keep appendable
  78. Copy Whether to deny copying 1 = deny by SCMS , 0 = allow
  79. Track Mode Describes frame type 4 for data , 0 for audio
  80. Data Block Type Layout of payload blocks 8 for 2048 byte data blocks
  81. 0 for 2352 byte audio blocks
  82. Audio Pause Length 150 = 2 seconds
  83. Media Catalog Number A property of the disc 0x80 if valid
  84. 13 decimal digits as ASCII
  85. ISRC A property of the track 0x80 if valid
  86. 12 letters and digits, ASCII
  87. Any other parameters may be set to 0.
  88. Mode page data as of MMC-5 table 644 are preceded by a Mode Parameter Header
  89. as of SPC-3 table 240. This 8-byte header may be filled with zeros.
  90. (mmc5r03c.pdf 7.5.4 The Mode Page, 4.2.3.4 Table 17 CONTROL = Track Mode)
  91. (spc3r23.pdf 6.8 MODE SELECT, 7.4.3 Mode parameter header formats)
  92. Writing has to begin at the address returned by 52h READ TRACK INFORMATION
  93. with Address/Number Type set to 01b and Logical Block Address/Track/Session
  94. Number set to FFh. The Next Writeable Address as of table 500 is the number
  95. to start writing with.
  96. (mmc5r03c.pdf 6.27 )
  97. Writing is performed by one or more 2Ah WRITE transactions with the Logical
  98. Block Address counted up from the initial number in sync with the number of
  99. blocks written. I.e the Transfer Length of the previous 2Ah WRITE has to be
  100. added to the Logical Block Address for the next 2Ah WRITE. Only full blocks
  101. can be written.
  102. (mmc5r03c.pdf, 6.44)
  103. When writing is done, it is mandatory to force the drive's buffer to media by
  104. 35h SYNCHRONIZE CACHE.
  105. (mmc5r03c.pdf, 6.41)
  106. A track must at least contain 300 payload blocks: 4 seconds of audio or
  107. 600 KiB of data.
  108. (mmc5r03c.pdf 6.3.3.1.2)
  109. Up to december 2009 the track was closed by 5Bh CLOSE TRACK SESSION Close
  110. Function 001b. Older MMC specifies a valid Logical Track Number FFh to depict
  111. the open track. MMC-5 is quite silent about this. FFh worked for my drives.
  112. (mmc5r03c.pdf 6.3.3.1.2)
  113. This is omitted since libburn-0.7.4, relying entirely on 35h SYNCHRONIZE CACHE.
  114. First appeared a drive where CLOSE TRACK fails in simulation mode, later
  115. another one produced error replies even with real burning.
  116. After that, a new track may be written beginning with sending the mode page 05h
  117. again. It is not tested whether 05h can be omitted if Track Mode and Data Block
  118. Type are the same as with the previous track.
  119. The new track will be added to the session which was opened by the first track.
  120. After the last track of a session, 5Bh CLOSE TRACK SESSION Close Function 010b
  121. with Logical Track Number 0 closes the session. It depends on the Multi-Session
  122. value in mode page 05h whether the disc is finalized or stays appendable.
  123. (mmc5r03c.pdf 6.3.3.1.3)
  124. -------------------------------------------------------------------------------
  125. Obtaining CD multi-session info for extending ISO-9660 filesystems :
  126. Program mkisofs expects two numbers with its option -C which describe the
  127. situation on an appendable CD which already contains a ISO-9660 filesystem
  128. in the first track of the last session.
  129. The first number is the Logical Block Address of that track containing the
  130. existing ISO-9660 filesystem image. This number is needed for mkisofs option
  131. -M to connect to the existing image. The new image will refer to files in
  132. the previously existing image. mkisofs option -M needs read access to the
  133. CD or a blockwise copy of it on hard disk.
  134. The number is gained by 43h READ TOC/PMA/ATIP.
  135. (mmc5r03c.pdf 6.26)
  136. Untested is Format 0001b which in table 478 promises quick access via
  137. Start Address Of First Track In Last Session.
  138. (mmc5r03c.pdf 6.26.2.5 table 478, 6.26.3.3.1)
  139. libburn gets the number from its Table Of Content model which is obtained
  140. by 43h READ TOC/PMA/ATIP, Format 0010b. See below.
  141. The second number is an exact prediction of the Logical Block Address of the
  142. new track which will contain the newly generated ISO-9660 image.
  143. Even without mkisofs option -M this second number is still needed to make the
  144. inner block address pointers of the image match the Logical Block Addresses
  145. on CD. For that one may inquire 52h READ TRACK INFORMATION with
  146. Address/Number Type set to 01b and Logical Block Address/Track/Session
  147. Number set to FFh. The Next Writeable Address as of table 500 is the number
  148. to use.
  149. (mmc5r03c.pdf 6.27 )
  150. -------------------------------------------------------------------------------
  151. Obtaining a Table Of Content from CD :
  152. The structure of a CD is comprised of sessions. Each session contains one or
  153. more tracks and is followed by a lead-out. A track has an address and a length.
  154. Table of content information is gained by 43h READ TOC/PMA/ATIP, Format 0010b.
  155. (mmc5r03c.pdf 6.26.2.5 table 478)
  156. The number of sessions is given by Last Complete Session Number.
  157. The number of TOC Track descriptors is: (TOC Data Length - 2)/11 .
  158. Each TOC Track Descriptor contains a Session Number.
  159. If POINT is >= 1 and <= 99 (63h) then the descriptor is about the track of
  160. which POINT tells the number.
  161. The start address of this track can be read from PMIN, PSEC, PFRAME where
  162. it is encoded in MSF format:
  163. If M is smaller than 90: LBA = (M * 60 + S) * 75 + F - 150
  164. Else : LBA = (M * 60 + S) * 75 + F - 450150
  165. The length of the track is given by MIN,SEC,FRAME in the same format.
  166. If POINT = A0h then the descriptor tells in PMIN the first track number of its
  167. session.
  168. POINT = A1h tells in PMIN the last track number of its session.
  169. POINT = A2h describes in PMIN, PSEC, PFRAME the lead-out of a session, i.e the
  170. first address after the session's end. (Next writeable address typically is
  171. lead-out + 11400 after the first session, lead-out + 6900 after further
  172. sessions.)
  173. POINT = B0h tells in MIN,SEC,FRAME this next writeable address or FFh,FFh,FFh
  174. for finalized disc.
  175. (mmc5r03c.pdf 6.26.3.4 table 489, 4.2.3.7 Mode-1 Q, Mode-5 Q)
  176. In libburn the address of the first track in the last session is obtained from
  177. the last session's POINT = A0h and from the track descriptor with the POINT
  178. value matching the PMIN value of the A0h descriptor.
  179. Untested is whether POINT = B0h and 52h READ TRACK INFORMATION are always in
  180. sync. libburn uses the info provided by 52h READ TRACK INFORMATION.
  181. -------------------------------------------------------------------------------
  182. -------------------------------------------------------------------------------
  183. SAO CD Cookbook
  184. -------------------------------------------------------------------------------
  185. Guided by reading libburn/* from http://icculus.org/burn
  186. backed by reading mmc5r03c.pdf from http://www.t10.org/ftp/t10/drafts/mmc5/
  187. backed by reading scms.html from
  188. http://www.barrel-of-monkeys.com/graphics/prod/dvdplayers/
  189. and by experiments with drives NEC ND-4570A, LG GSA-4082B, LITE-ON LTR48125S,
  190. Optiarc BD RW BD-5300S, LG BDDVDRW GGC-H20L
  191. For libburnia-project.org by Thomas Schmitt <scdbackup@gmx.net>
  192. -------------------------------------------------------------------------------
  193. Recognition of media type and state (blank, appendable, finalized) is as
  194. described in the TAO Multi-Session CD Cookbook. See there.
  195. The MMC specs do not give much hint about the combination of SAO and
  196. multi-session. My drives refused not only on a few experiments which i did
  197. in libburn but also failed with cdrecord -sao on an appendable CD.
  198. So for now only blank CD seem to be suitable for SAO writing.
  199. Different from TAO mode, the whole session layout is announced to the drive by
  200. sending a Cue Sheet. This implies that the sizes of the tracks have to be known
  201. in advance, which is a heavy drawback when dealing with track data sources like
  202. stdin, named pipes or sockets.
  203. Nevertheless, SAO seems to be best writing mode for audio purposes, as our
  204. audio expert Lorenzo Taylor found out.
  205. A SAO session in libburn may either consist entirely of audio tracks or
  206. entirely of data tracks. For mixed sessions, only TAO is usable yet.
  207. - Composing a SAO CD Cue Sheet (either audio or data, but not mixed)
  208. - Writing the prepared SAO CD session
  209. - What is known about mixed mode sessions
  210. -------------------------------------------------------------------------------
  211. Composing a Cue Sheet (either audio or data, but not mixed) :
  212. The Cue Sheet will get submitted to the drive by 5Dh SEND CUE SHEET.
  213. Each entry of the sheet is of 8 bytes size. Its fields are named
  214. CTL|ADR, TNO, INDEX, DATA FORM, SCMS, MIN, SEC, FRAME .
  215. (mmc5r03c.pdf 6.33)
  216. CTL is comprised of four bits:
  217. bit4 = Pre-emphasis (audio only)
  218. bit5 = Digital copy permission:
  219. 0 = prohibited (one-time copy is permitted if SCMS is 00h)
  220. 1 = permitted (unlimited)
  221. bit6 = Data track indicator (bit4 and bit7 shall be 0)
  222. bit7 = 4-channel audio
  223. Usually CTL is 40h for data and 00h for audio.
  224. (mmc5r03c.pdf 6.33.3.4)
  225. ADR is 01h for entries which define time points. It is 02h for media catalog
  226. entries and it is 03h for track ISRC entries.
  227. The bits of CTL and ADR are combined in the CTL|ADR byte.
  228. TNO is the track number. The TNO of the first track may be chosen in the range
  229. of 1 to 99. The TNO of following tracks must be the TNO of their predecessor
  230. plus 1. The last track must not have a TNO larger than 99.
  231. INDEX is a subaddress within tracks. INDEX 1 is mandatory and marks the start
  232. of the payload area of a track. The range between INDEX 0 and 1 is called
  233. pre-gap. It should contain zeros if it exists. Further cue sheet entries with
  234. consecutive INDEX numbers mark ranges within the track. The range of the last
  235. index may contain a post-gap with zeros.
  236. (mmc5r03c.pdf 4.2.3.5.2)
  237. A pre-gap of 2 seconds is mandatory only for the first track. Pre-gap and
  238. post-gap may be needed with further tracks if they have neighbors with
  239. different DATA FORM values. (Such mixing is not yet supported by libburn.)
  240. DATA FORM is 00h for audio payload, 01h for audio pause (Lead-in and Lead-out),
  241. 10h for data, 14h for data pause (Lead-in and Lead-out).
  242. This shall be ored with 40h for CD-TEXT in Lead-in.
  243. (mmc5r03c.pdf 6.33.3.11 CD-DA Data Form, 6.33.3.12 CD-ROM mode 1 Form)
  244. SCMS value 80h in conjunction with bit5 of CTL is an indicator for exhausted
  245. one-time-copy permission. If this permission is still intact, then SCMS is 00h.
  246. MIN, SEC, FRAME give the MSF address where the described data entity starts.
  247. LBA = frames - 150, 75 frames = 1 sec , 60 sec = 1 min.
  248. This address must increase from entry to entry (or at least stay equal).
  249. The first two entries in a Cue Sheet may describe the Media Catalog Number,
  250. a string of 13 characters, also known with CD-TEXT as "UPC/EAN".
  251. (02h, catalog characters 1 to 7)
  252. (02h, catalog characters 8 to 13, 00h)
  253. These two entries shall be omitted if no catalog number is given.
  254. The next entry (eventually being the first one) describes the Lead-in.
  255. Its content is
  256. (CTL|ADR ,00h,00h, DATA FORM ,00h,00h,00h,00h)
  257. With the CTL|ADR for the first track: 41h for data, 01h for audio.
  258. DATA FORM is pause (audio=01h, data=14h). Ored with 40h if CD-TEXT shall
  259. be stored in Lean-in.
  260. The LBA for the first write is negative: -150. This corresponds to MSF address
  261. 00h:00h:00h. All addresses are to be given in MSF format.
  262. Each track may be preceded by two entries describing an ISRC string of 12
  263. characters.
  264. (CTL | 03h, TNO, characters 1 to 6)
  265. (CTL | 03h, TNO, characters 7 to 12)
  266. These entries shall be omitted if no ISRC is given for the track.
  267. CTL shall be the same as with the track.
  268. The first information track on disc is preceded by a pause encoding or pre-gap
  269. of at least 2 seconds:
  270. (CTL|ADR,01h,00h, DATA FORM ,00h,00h,00h,00h)
  271. with DATA FORM = 00h for audio and 10h for data. By those 2 seconds the MSF
  272. address increases to 00h:02h:00h = LBA 0. Optional further sectors may occupy
  273. addresses larger than 0. This entry has to come after ISRC, if ISRC is given
  274. for the track. INDEX has to be 0.
  275. Each track is represented by one or more entries, with increasing index number.
  276. At least the entry for INDEX 1 has to exist:
  277. (CTL|ADR, TNO ,01h,DATA FORM,00h, MIN , SEC , FRAME)
  278. TNO gives the track number. MIN, SEC, FRAME give the MSF address which becomes
  279. the start address of the track. The MSF address is then increased by the size
  280. of the track (to be used with next track or with lead-out).
  281. There may be more entries with INDEX 2 to 99. Their MSF address tells the
  282. sector where their range starts. This range ends at the MSF of the next entry
  283. in the cue sheet. INDEX information is stored in the sub-channel of the sectors
  284. but not in the Table-of-Content of the disc.
  285. A track must at least contain 300 payload blocks: 4 seconds of audio or
  286. 600 KiB of data.
  287. (mmc5r03c.pdf 6.33.3.6)
  288. At the end of the session there is a lead-out entry
  289. (CTL|ADR,AAh,01h,DATA FORM,00h,MIN,SEC,FRAME)
  290. marking the end of the last track. (With libburn CTL is as of the last track.)
  291. DATA FORM is 01h for audio, 14h for data.
  292. -------------------------------------------------------------------------------
  293. Writing the prepared session :
  294. Speed may be set by BBh SET CD SPEED parameter Drive Write Speed. Note that
  295. kbytes/sec means 1000 bytes/sec and not 1024/sec. Rotational control should
  296. be set to 00b. 1x CD speed is 176.4 kbytes/sec. Speed is usually set to the
  297. next lower possible value by the drive. So it is helpful to add a few
  298. kbytes/sec just in case the drive has rounding problems.
  299. (mmc5r03c.pdf 6.37)
  300. If CD-TEXT shall be written into Lead-in, then it is necessary to obtain the
  301. Start Time of Lead-in by 43h READ TOC/PMA/ATIP Format 0100b. It is an MFS
  302. address which varies from media manufacturer to media manufacturer.
  303. Minute will be >= 90. Therefore this conversion applies:
  304. LBA = (M * 60 + S) * 75 + F - 450150
  305. A Write Parameters mode page 05h has to be composed and transmitted via
  306. 55h MODE SELECT. This page describes the following parameters:
  307. BUFE Buffer Underrun protection 0=off, 1=on
  308. Test Write -dummy mode for writing 0=off, 1=on
  309. Write Type Packet/TAO/SAO/RAW 02h = SAO
  310. Multi-session Whether to keep appendable 00b = finalize
  311. 11b = keep appendable
  312. Track Mode Describes frame type 0 (is ignored)
  313. Data Block Type Layout of payload blocks 0 (is ignored)
  314. Audio Pause Length 150 = 2 seconds (ignored ?)
  315. Media Catalog Number 0x80 if valid
  316. See also Cue Sheet ADR 02h 13 decimal digits as ASCII
  317. (With SAO, ISRC is transmitted only by the Cue Sheet.)
  318. Any other parameters may be set to 0.
  319. Mode page data as of MMC-5 table 644 are preceded by a Mode Parameter Header
  320. as of SPC-3 table 240. This 8-byte header may be filled with zeros.
  321. (mmc5r03c.pdf 7.5.4 The Mode Page, 4.2.3.4 Table 17 CONTROL = Track Mode)
  322. (spc3r23.pdf 6.8 MODE SELECT, 7.4.3 Mode parameter header formats)
  323. The Cue Sheet is submitted to the drive by 5Dh SEND CUE SHEET. Cue Sheet Size
  324. is 8 times the number of entries.
  325. (mmc5r03c.pdf 6.33)
  326. Writing is performed by multiple 2Ah WRITE transactions with the Logical
  327. Block Address counted up from the initial number in sync with the number of
  328. blocks written. I.e the Transfer Length of the previous 2Ah WRITE has to be
  329. added to the Logical Block Address for the next 2Ah WRITE. Only full blocks
  330. can be written.
  331. (mmc5r03c.pdf, 6.44)
  332. Block addresses may be negative for areas before the normally readable
  333. data. Data representation of addresses is 4-byte, big-endian, two's-complement.
  334. E.g: -150 = FFh FFh FFh 6Ah.
  335. This is the natural form found with about any 32-bit processor, so only
  336. the endianness has to be taken into respect when converting a 32-bit
  337. integer into a LBA for command 2Ah WRITE.
  338. If CD-TEXT shall be written into Lead-in, then writing begins at the start
  339. address of Lead-in, which was obtained above.
  340. The 18 bytes of each text pack have to be split up to 24 bytes with only the
  341. lowest six bits used in each byte. E.g. text pack
  342. 8F 00 2A 00 01 01 03 00 06 05 04 05 07 06 01 02 48 65
  343. becomes
  344. 23 30 00 2A 00 00 04 01 00 30 00 06 01 10 10 05 01 30 18 01 00 24 21 25
  345. 4 of these 24 byte packs form a block of DATA FORM 41h. I.e. only 96 bytes
  346. payload per block. The whole range from Lead-in start to LBA -150 has to be
  347. filled with blocks of this form. Therefore it is necessary to write the
  348. list of given packs in repeated cycles.
  349. A typical Lead-in start address is -11635 = FFh FFh D2h 8Dh.
  350. A description of the CD-TEXT pack format is given in file doc/cdtext.txt .
  351. Writing without CD-TEXT begins at LBA -150 = FFh FFh FFh 6Ah.
  352. In both cases, the mandatory pause preceding the first track has to be
  353. written as 150 blocks of the matching sector size: 2048 for data,
  354. 2352 for audio. By this, the LBA increases from -150 to 0.
  355. Next the tracks' payload is sent. For each track exactly the number of blocks
  356. has to be transmitted as is announced in the Cue Sheet by the difference
  357. of the track's own start address and the start address of the next entry in
  358. the Cue Sheet. After each write the LBA for the next write has to be increased
  359. by the number of blocks transmitted. Just like with TAO writing.
  360. There is no separator between the tracks of a pure mode SAO session.
  361. (If the session was mixed mode, there would be extended Pre-gaps and Post-gaps
  362. between data mode tracks and audio mode tracks.)
  363. (libburn sends its own buffer to the drive at the end of each track but does
  364. not sync the drive's chache. It is unclear whether this separation of tracks
  365. on the level of 2Ah WRITE is necessary with a pure mode session. It does not
  366. harm in any case and would probably be unavoidable if audio and data tracks
  367. were mixed.)
  368. When writing of all tracks is done, it is mandatory to force the drive's buffer
  369. to media by 35h SYNCHRONIZE CACHE.
  370. (mmc5r03c.pdf, 6.41)
  371. No further finalization is necessary. (I.e. no 5Bh CLOSE TRACK SESSION.)
  372. -------------------------------------------------------------------------------
  373. Obtaining CD-TEXT from Lead-in :
  374. Audio CDs may contain CD-TEXT information in their Lead-in. It is gained by
  375. 43h READ TOC/PMA/ATIP, Format 0101b. The reply consists of 4 bytes header,
  376. of which the first two bytes give the number of following bytes as big-endian
  377. 16 bit number. The other two bytes are 0.
  378. Following are text packs of 18 bytes each.
  379. (mmc5r03c.pdf 6.26.3.7.1 table 495)
  380. A description of CD-TEXT packs and of the applicable libburn API calls is
  381. given in file doc/cdtext.txt .
  382. ----------------------------------------------------------------------------
  383. What is known about mixed mode sessions :
  384. For now, SAO sessions with a mix of data and audio are not supported in
  385. libburn. Here are the reasons why.
  386. Obviously the code of http://icculus.org/burn is incomplete in this aspect.
  387. In mmc5r03c.pdf comparison of table 555 and 6.33.3.18 seems self-contradicting.
  388. (The second Pre-gap in table 555 does not match any of the criteria of
  389. 6.33.3.18. Also, there is no Post-gap shown in table 555 although 6.33.3.19
  390. would prescribe some.)
  391. If a data track follows an audio track then the data track gets a preceding
  392. extended Pre-gap:
  393. (CTL|ADR, TNO ,01h,DATA FORM,00h, MIN , SEC , FRAME)
  394. with TNO already the number of the data track. The MSF address is to be
  395. increased by 3 seconds. The first second of the extended Pre-gap needs to be
  396. written in the audio track's mode and the other 2 seconds are to be written
  397. in the data track's mode.
  398. (libburn compares DATA FORM rather than burn_track.mode . Wrong ?)
  399. (libburn currently does only 2 seconds and the second part of Pre-gap. There is
  400. an issue with burn_track.pregap1 about this. Seems libburn mistakes the pause
  401. preceding track 1 for a part 2 of an extended Pre-gap.)
  402. If a data track is followed by an audio track then it gets a Post-gap of at
  403. least two seconds.
  404. No example of Post-gap is given for Cue Sheet. Maybe it is to be added to the
  405. track, or maybe it gets an own Cue Sheet entry ... who knows ?
  406. (libburn contains write code for pregap1, pregap2 and postgap. But only
  407. pregap2 ever gets activated. Once hackingly for the first 2 second pause, once
  408. incompletely for a change of DATA FORM.)
  409. Seems nobody ever tested this. Libburnia simply knows no use case where the
  410. correctness of Pre-gap and Post-gap would become evident.
  411. -------------------------------------------------------------------------------
  412. -------------------------------------------------------------------------------
  413. Overwriteable DVD Cookbook
  414. -------------------------------------------------------------------------------
  415. Inspired by Andy Polyakov's http://fy.chalmers.se/~appro/linux/DVD+RW/tools ,
  416. backed by reading mmc5r03c.pdf from http://www.t10.org/ftp/t10/drafts/mmc5/
  417. by own experiments with drives NEC ND-4570A, LG GSA-4082B, PHILIPS SPD3300L,
  418. LG GGW H20L, and by BD-RE experiments done by Giulio Orsero on LG BE06LU10.
  419. For libburnia-project.org by Thomas Schmitt <scdbackup@gmx.net>
  420. -------------------------------------------------------------------------------
  421. Media type can be recognized by Current Profile from 46h GET CONFIGURATION.
  422. (mmc5r03c.pdf 6.6.2.1)
  423. DVD-RAM 0012h
  424. DVD-RW Restricted Overwrite 0013h
  425. DVD-RW Sequential Recording 0014h (i.e. unformatted)
  426. DVD+RW 001Ah
  427. BD-RE 0043h
  428. A short compilation of the write model:
  429. - Overwriting in general
  430. The recipes described here are depending on formatting state:
  431. - DVD-RAM, fully formatted DVD+RW, DVD-RW, BD-RE
  432. - Unformatted DVD+RW
  433. - Partly formatted DVD+RW
  434. - Unformatted DVD-RW
  435. - Partly formatted DVD-RW
  436. - Intermediate state DVD-RW
  437. - DVD-RAM and BD-RE formatting
  438. - DVD-RAM and BD-RE speed tuning
  439. Slightly off topic are
  440. - ISO 9660 multi-session emulation on overwriteable media
  441. - ISO 9660 based TOC emulation on overwriteable media
  442. -------------------------------------------------------------------------------
  443. Overwriting in general :
  444. Depending on media type, some kind of formatting has to have happened before
  445. data can be written. Formatting may happen separately from writing or
  446. simultaneously. See the particular recipes below.
  447. No Write Parameters mode page 05h is to be sent. Speed can be influenced by
  448. B6h SET STREAMING , speed capabilities can be inquired by ACh GET PERFORMANCE.
  449. It is advised to set only speeds and sizes which are returned by ACh.
  450. (mmc5r03c.pdf 6.39 SET STREAMING, 6.8 GET PERFORMANCE)
  451. Optimal performance is promised without any speed setting. But my experiments
  452. showed that SET STREAMING values persist after media change.
  453. In the formatted area of the media, coarse random access is possible.
  454. For DVD-RAM, DVD+RW, BD-RE write addresses and data size need to be aligned
  455. to 2 KiB. For DVD-RW alignment has to be 32 KiB. Within these limitations
  456. the write address is at the discretion of the sending program.
  457. Just use 2Ah WRITE to send data.
  458. (mmc5r03c.pdf, 6.44)
  459. When writing is done, it is mandatory to force the drive's buffer to media by
  460. 35h SYNCHRONIZE CACHE.
  461. (mmc5r03c.pdf, 6.41)
  462. The size of the formatted area can be inquired by 23h READ FORMAT CAPACITIES.
  463. The Number Of Blocks value in the Current/Maximum Capacity Descriptor gives
  464. this size in 2 KiB blocks. But this is true only if Descriptor Type is 10b
  465. ("Formatted Media").
  466. (mmc5r03c.pdf, 6.24.3.2.1, 6.24.3.2.3)
  467. Not yet formatted areas may be completely forbidden or they may be allowed for
  468. sequential writing (DVD-RW Intermediate state) or they may be allowed for
  469. random access only after the necessary waiting time for formatting to reach
  470. the desired address (DVD+RW with background formatting active).
  471. Already written areas can be overwritten without special precaution.
  472. Blanking a DVD-RW actually destroys its formatting.
  473. Most of the concepts usually expressed in Write Parameters mode page 05h do not
  474. apply to the recipes here: Test-Write, Buffer Underrun protection,
  475. Multi-session, Write Type, Block Type, Track Mode, ...
  476. There are hints for multi-session formats with DVD-RW but both of my drives
  477. do not offer "Add Session" Format Types 12h or 14h.
  478. (mmc5r03c.pdf 6.5.4.2.7 , 6.5.4.2.9)
  479. Caution: Drive and media compatibility seems still to be quite an adventure.
  480. If you experience problems, especially problems with readability, then try
  481. different drives and media brands. Failure does not necessarily mean that the
  482. software did anything wrong.
  483. -------------------------------------------------------------------------------
  484. DVD-RAM, fully formatted DVD+RW, DVD-RW, BD-RE :
  485. Full format is the natural state of DVD-RAM.
  486. BD-RE are sold unformatted and need to be fully formatted first.
  487. See paragraph about DVD-RAM and BD-RE formatting below.
  488. DVD+RW reaches this state if Background Formatting is allowed to finish without
  489. being stopped by 5Bh CLOSE TRACK SESSION.
  490. (mmc5r03c.pdf, 6.5 FORMAT UNIT, 6.5.4.2.14 Format Type = 26h)
  491. The formatting state of a DVD+RW may be inquired by 51h READ DISC INFORMATION
  492. requesting Data Type 000b "Standard Disc Information". In the reply,
  493. BG Format 3 indicates fully formatted media.
  494. (mmc5r03c.pdf 6.22.3.1.13)
  495. DVD-RW reaches this state either by Format Type 00h (or 10h) with maximum
  496. size given as Number Of Blocks, or by writing sequentially until the disc is
  497. completely full into an intermediate session opened by format 15h or 13h.
  498. (mmc5r03c.pdf, 6.5 FORMAT UNIT, 6.5.4.2.1, 6.5.4.2.10, 6.5.4.2.8)
  499. A fully formatted DVD-RW can be recognized by 23h READ FORMAT CAPACITIES. The
  500. Descriptor Type of the Current/Maximum Capacity Descriptor is 10b ("Formatted
  501. Media") and 0 blocks are offered with Format Types 13h or 11h.
  502. (mmc5r03c.pdf, 6.24.3.2.1, 6.24.3.3)
  503. See also discussion of unformatted or partially formatted DVD-RW below.
  504. In fully formatted state there is no need for any formatting before writing nor
  505. for any finalizing other than forcing the drive's buffer to media by
  506. 35h SYNCHRONIZE CACHE (which is mandatory for writing, anyway).
  507. (mmc5r03c.pdf, 6.41)
  508. (It seems to do no harm to send to DVD+RW or DVD-RW a 5Bh CLOSE TRACK SESSION
  509. with Close Function 010b despite there is no session open in this scenario.)
  510. -------------------------------------------------------------------------------
  511. Unformatted DVD+RW :
  512. This is the state of previously unused DVD+RW media.
  513. The formatting state of a DVD+RW may be inquired by 51h READ DISC INFORMATION
  514. requiring Data Type 000b "Standard Disc Information".
  515. In the reply, BG Format 0 indicates unformatted media (or unsuitable media).
  516. (mmc5r03c.pdf 6.22.3.1.13)
  517. Formatting has to be started by command 04h FORMAT UNIT, Format Type 26h.
  518. Different from other format types, 26h is allowed to send a fantasy size of
  519. 0xffffffff blocks and does not require the caller to know the exact maximum
  520. size offered with that format.
  521. (mmc5r03c.pdf, 6.5 FORMAT UNIT, 6.5.4.2.14 Format Type = 26h)
  522. As its name suggests, one has not to wait for background formatting to end
  523. but may very soon start writing as on formatted media. Random access to
  524. yet unformatted areas can last long, though.
  525. If backup formatting has been started at the beginning of the session, then
  526. it may get stopped after the final cache sync by 5Bh CLOSE TRACK SESSION
  527. with Close Function 010b.
  528. (mmc5r03c.pdf 6.3.3.6)
  529. Formatting of DVD+RW is called "de-icing" because unformatted areas offer
  530. no hold for random access addressing and are thus slippery like ice. One can
  531. also see a color change from shiny unformatted to more dull formatted media.
  532. -------------------------------------------------------------------------------
  533. Partly formatted DVD+RW :
  534. This state is achieved by stopping background formatting before the media
  535. was completely formmatted.
  536. The formatting state of a DVD+RW is obtained by 51h READ DISC INFORMATION
  537. requiring Data Type 000b "Standard Disc Information".
  538. In the reply, BG Format 1 indicates partly formatted media.
  539. (mmc5r03c.pdf 6.22.3.1.13)
  540. If the data of the session surely fit into the formatted area, then it would
  541. be unnecessary to restart background formatting.
  542. But in order to make the DVD+RW surely accept its maximum number of bytes,
  543. formatting may be restarted by command 04h FORMAT UNIT, Format Type 26h,
  544. with the Restart bit set and Number of Blocks set to 0xffffffff.
  545. (mmc5r03c.pdf, 6.5 FORMAT UNIT, 6.5.4.2.14 Format Type = 26h)
  546. From then on, the same rules apply as for previously unformatted DVD+RW.
  547. -------------------------------------------------------------------------------
  548. Unformatted DVD-RW (media profile is 0014h) :
  549. This state is present with previously unused media. It is also present with
  550. media blanked by programs cdrecord, wodim or dvd+rw-format and with media which
  551. were sequentially written from blank state.
  552. Profile transition from formatted 0013h to unformatted 0014h is done by
  553. A1h BLANK.
  554. (mmc5r03c.pdf, 6.2)
  555. Experiments on my drives indicate that only Blanking Type 000b "Blank the disc"
  556. achieves neat media. Media blanked via type 001b offer no feature 0021h and
  557. stall cdrecord or libburn already when those media get examined. growisofs can
  558. burn them - but only via DAO (feature 002Fh which prescribes Write Type 2).
  559. (mmc5r03c.pdf 5.3.11, 5.3.25)
  560. For becoming overwriteable such media need to be treated by command 04h FORMAT
  561. UNIT.
  562. (mmc5r03c.pdf, 6.5)
  563. The Format Type has to be chosen from the list replied by 23h READ FORMAT
  564. CAPACITIES. Suitable are Format Types 00h, 10h, 15h.
  565. (mmc5r03c.pdf 6.24)
  566. Format Types 00h and 10h provide a writeable area of a size given by Number of
  567. Blocks. Type 00h seems to be the most traditional and complete one. It needs
  568. no closing of a session at the end of writing.
  569. The Number Of Blocks may be at most the value reported by 23h READ FORMAT
  570. CAPACITIES in the entry for the desired format type. Full format is achieved
  571. by sending exactly the reported value.
  572. (mmc5r03c.pdf, 6.5.4.2.1 Format Type = 00h, 6.5.4.2.5 Format Type = 10h)
  573. Format Type 15h provides a writeable area of given size too, but this area can
  574. be expanded by sequential writing and afterwards marked as overwriteable by
  575. closing the session. It is even allowed to format with size 0 and to leave
  576. the size claim entirely to a sequential write process beginning at LBA 0.
  577. (mmc5r03c.pdf, 6.5.4.2.10 Format Type = 15h)
  578. When writing is done and cache is synced, one should send 5Bh CLOSE TRACK
  579. SESSION with Close Function 010b in order to bring the session out of
  580. Intermediate state.
  581. (mmc5r03c.pdf 6.3.3.2.3)
  582. If not written up to the last 32 KiB block, the DVD-RW is only partly formatted
  583. after that.
  584. -------------------------------------------------------------------------------
  585. Partly formatted DVD-RW (media profile is 0013h) :
  586. This state is achieved by formatting a DVD-RW with a number of blocks which
  587. is less than offered for the Format Type by the drive's reply to 23h READ
  588. FORMAT CAPACITIES. If the media was most recently formatted by Format Types
  589. 015h or 013h then it must have got written some bytes and afterwards treated
  590. by 5Bh CLOSE TRACK SESSION, 010b in order to be partly formatted.
  591. (mmc5r03c.pdf 6.3.3.2.3 CLOSE TRACK SESSION 010b, 6.24 READ FORMAT CAPACITIES)
  592. Elsewise the media is in Intermediate state. See below.
  593. A partly formatted DVD-RW can be recognized by 23h READ FORMAT CAPACITIES. The
  594. Descriptor Type of the Current/Maximum Capacity Descriptor is 10b ("Formatted
  595. Media") and the Number Of Blocks with formats 00h, 10h or 15h is larger than the
  596. currently formatted size, or more than 0 blocks are offered with Format
  597. Types 13h or 11h.
  598. (mmc5r03c.pdf, 6.24.3.2.1, 6.24.3.3)
  599. If the data of the session surely fit into the formatted area, then it would
  600. be unnecessary to do any further formatting.
  601. But in order to make the DVD-RW surely accept its maximum number of bytes,
  602. partial formatting may be expanded by command 04h FORMAT UNIT, Format Type 13h,
  603. which is supposed to be offered by the drive in this state. This brings the
  604. session again into Intermediate state and thus enables expansion by sequential
  605. writing. As with Format Type 15h it is ok to set Number Of Blocks to 0, so that
  606. no fixed size formatting work is done and writing can begin soon after.
  607. (mmc5r03c.pdf, 6.5.4.2.8 Format Type = 13h)
  608. When writing is done and cache is synced, one should send 5Bh CLOSE TRACK
  609. SESSION with Close Function 010b in order to bring the session out of
  610. Intermediate state.
  611. (mmc5r03c.pdf 6.3.3.2.3)
  612. If not written up to the last 32 KiB block, the DVD-RW is only partly formatted
  613. after that.
  614. Format Type 13h has been tested only with expanding sessions formatted by 15h.
  615. Nevertheless it is offered with sessions from 00h and 10h, too.
  616. According to the specs, Format Type 11h would expand a session by a fixed
  617. size. This has not been tested yet because it is less appealing than 13h.
  618. (mmc5r03c.pdf, 6.5.4.2.6 Format Type = 11h)
  619. -------------------------------------------------------------------------------
  620. Intermediate state DVD-RW (media profile is 0013h) :
  621. This state is achieved by formatting a DVD-RW with Format Type 15h or 13h
  622. without subsequentially writing data and sending 5Bh CLOSE TRACK SESSION
  623. with Close Function 010b.
  624. Such media behave very unpleasing with my DVD-ROM drive under Linux 2.4 ide-cd.
  625. One should therefore better avoid to release media in this state.
  626. This state can be recognized by 23h READ FORMAT CAPACITIES. The Descriptor Type
  627. of the Current/Maximum Capacity Descriptor is 11b ("Unknown Capacity") and
  628. no formats 13h or 11h are offered.
  629. (mmc5r03c.pdf, 6.24.3.2.1, 6.24.3.3)
  630. One may treat such media as if Format Type 15h or 13h had been freshly applied.
  631. I.e. sequential writing from LBA 0. After cache sync bring the session out
  632. of Intermediate state by 5Bh CLOSE TRACK SESSION with Close Function 010b.
  633. (mmc5r03c.pdf 6.3.3.2.3)
  634. -------------------------------------------------------------------------------
  635. DVD-RAM and BD-RE formatting :
  636. Although DVD-RAM usually are sold formatted, there may still arise the wish
  637. to adjust formatting.
  638. BD-RE are sold unformatted and need to be formatted prior to usage.
  639. Two format types are relevant for DVD-RAM : 00h and 01h.
  640. 00h offers the default size format and usually a maximum payload size format.
  641. Even with that maximum size payload there is hardware defect management.
  642. (mmc5r03c.pdf 6.5.4.2.1.2)
  643. 01h can convert payload capacity into spare blocks for defect management.
  644. There is no way to increase payload capacity by format 01h.
  645. (mmc5r03c.pdf 6.5.4.2.2.1)
  646. With BD-RE there are three format types : 00h, 30h and 31h.
  647. 00h offers the default size format. This may be the only fast formatting
  648. mode that is offered by the drive.
  649. Feature 0023h tells whether format 31h and certain 30h subtypes are available.
  650. (mmc5r03c.pdf 5.3.13)
  651. 30h offers several sizes with defect management. Usually there are three
  652. sizes given: #1: default size, #2: maximum spare area, #3: minimal spare.
  653. One may demand any spare size between maximum and minimum. There may be quick
  654. certification and full certification. See feature 0023h.
  655. 31h offers a single size and disables defect management. This has the side
  656. effect to speed up writing to nominal speed.
  657. (mmc5r03c.pdf 6.5.4.2.15, 6.24.3.3, Table 472)
  658. Only format sizes from the list of format descriptors are permissible
  659. for DVD-RAM. The format list can be obtained by 23h READ FORMAT CAPACITIES.
  660. It also includes a description of the current formatting state.
  661. (mmc5r03c.pdf 6.24, 6.24.3.2, 6.24.3.3)
  662. Formatting is done by command 04h FORMAT UNIT. Its data payload consists
  663. of a Format List Header and a Format Descriptor. It is advisable to set
  664. the Immed bit and the FOV bit in header byte number 1. The descriptor should
  665. be a copy of a descriptor from 23h READ FORMAT CAPACITIES.
  666. (mmc5r03c.pdf 6.5, 6.5.3.2, 6.5.3.3)
  667. With nearly all formats Sub-type should be set to 0. But with BD-RE formats
  668. 30h and 31h the Sub-type selects the certification mode.
  669. Usable with 30h seem 10b Full Certification and 11b Quick Certification.
  670. Usable with 31h seem also 00b Quick Reformat and 01b No Certification.
  671. (mmc5r03c.pdf 6.5.4.2.15.1)
  672. Other format types have their certification intensity controlled by
  673. a pair of bits: CmpList and DCRT.
  674. CmpList resides in CDB byte 1 as bit 3. DCRT resides in the payload byte 1
  675. as bit 5. Both together should request a quick size change without lengthy
  676. certification but maintaining the list of known defects.
  677. (mmc5r03c.pdf 6.5, table 249, 6.5.3.2)
  678. With DVD-RAM on my PHILIPS SPD3300L drive they prevent any format size
  679. change though. The TSSTcorp SH-S203B works properly.
  680. With BD-RE format 00h, the default is specified to be Quick Reformat,
  681. and with 00h in general certification can only be disabled not enabled.
  682. (mmc5r03c.pdf 6.5.4.2.1.7)
  683. -------------------------------------------------------------------------------
  684. DVD-RAM and BD-RE tuning :
  685. A special aspect of DVD-RAM and BD-RE is their low speed with write operations,
  686. which usually is only half than the nominal speed of media and drive.
  687. This is blamed to the automatic checkreading which happens for managing
  688. eventual defects.
  689. Defect management of BD-RE can be disabled by format type 31h. See above.
  690. There is no drive known yet which would apply command 2Ah WRITE10 to DVD-RAM
  691. with full speed.
  692. The only known way to get full speed from DVD-RAM or BD-RE with enabled defect
  693. management is the use of AAh WRITE12 with Streaming Bit set to 1.
  694. (mmc5r03c.pdf 6.45)
  695. With some DVD-RAM drives this fails if a write buffer is not full 32 kB.
  696. With the tested BD-RE one must write full 64 kB buffers, or else writing
  697. might not get into effect at all.
  698. Although it seems not optimal, this is specified not only to disable the
  699. cumbersome checkread but also to ignore known defects and to write data
  700. to these defective addresses.
  701. (mmc5r03c.pdf 4.8.5)
  702. So the speed-up is only advisable as long as the media are free of
  703. incorrectable errors.
  704. Caveat:
  705. MMC-5 does not guarantee AAh WRITE12 to work on DVD-RAM or BD-RE at all.
  706. None of the features of profiles 0012h and 0043h promises the existence of
  707. AAh WRITE12.
  708. (mmc5r03c.pdf 5.4.13, 6.45)
  709. Nevertheless it worked on all tested drives if proper alignment and block
  710. size was observed.
  711. -------------------------------------------------------------------------------
  712. ISO 9660 multi-session emulation on overwriteable media :
  713. Overwriteable media provide a single overwriteable track which may grow up to
  714. the full media capacity. There is no builtin table-of-content which records
  715. the history of write sessions.
  716. mount -t iso9660 will use sbsector=0 as default.
  717. The term "superblock" shall depict the first 64 KiB after the sbsector address.
  718. ISO 9660 multi-session depends on typical TOC information in two ways:
  719. It needs the superblock address MSC1 of the most recently recorded session and
  720. it needs the Next Writeable Address NWA for which to prepare the address
  721. offset.
  722. The following is learned from growisofs and from ECMA-119:
  723. http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-119.pdf
  724. ISO 9660 filesystems provide information about the number of sectors which
  725. is also the lowest unused block address and thus a suitable NWA.
  726. This block address is stored in the Primary Volume Descriptor which is supposed
  727. to be stored in block 16 (eventually relative to MSC1).
  728. The bytes 0 to 5 of a PVD block are
  729. 0x01 'C' 'D' '0' '0' '1'
  730. The sector count can then be read from byte 80 to 83
  731. sectors= pvd[80] | (pvd[81] << 8) | (pvd[82] << 16) | (pvd[83] << 24);
  732. (Ecma-119.pdf 8.4)
  733. To support CD, DVD and BD media alike, it is advisable to round the NWA
  734. to the next multiple of 32 (= 64 KiB).
  735. So one can use 0 as MSC1 and prepare a new ISO session for the computed NWA.
  736. After writing the session it is necessary to copy the PVD from session start
  737. plus 16 to LBA 16 and to adjust it to its new location.
  738. The minimal change would be to update the number of image sectors.
  739. It is stored in both notations LSB and MSB:
  740. for(i= 0; i < 4; i++)
  741. pvd[87 - i]= pvd[80 + i]= (sectors >> (8 * i)) & 0xff;
  742. cdrskin --grow_overwriteable_iso not only patches the sector fields of the
  743. PVD block but also the blocks up to LBA 31 which begin with
  744. 0xff 'C' 'D' '0' '0' '1'
  745. libisoburn submits 64 KiB data buffer to libisofs before image generation and
  746. afterwards writes these 64 KiB as new superblock to LBA 0.
  747. -------------------------------------------------------------------------------
  748. ISO 9660 based TOC emulation on overwriteable media :
  749. Above method of multi-session emulation yields a single session image after
  750. each add-on session. No reliable session history can be read because the
  751. sector size of the existing session gets overwritten by the new one.
  752. A TOC with session history is nevertheless desirable with incremental backups
  753. in order to access older backup states by mounting older superblocks at the
  754. start addresses of older sessions.
  755. All usual ISO 9660 formatter programs write a complete superblock to the
  756. start of each session.
  757. With a uniform NWA rounding rule it is possible to compute the address of
  758. superblock N+1 as the NWA after session N. The only problem is N=1
  759. because it gets overwritten by later sessions.
  760. libisoburn preserves the information of session 1 by writing the first session
  761. to LBA 32 rather than LBA 0. Afterwards it writes the overall superblock to
  762. LBA 0 (up to 31).
  763. So with all further add-on sessions the superblock at LBA 0 will enclose the
  764. overall image, while the superblocks of the sessions form a chain beginning
  765. at LBA 32. Each session superblock points to the next one by its sector count
  766. rounded up to 32. The chain end is marked by the overall image size.
  767. This chain gives the start addresses of sessions. The sector count minus start
  768. address gives the size of a particular session. ECMA-119 explains how to
  769. retrieve more info from the PVD (e.g. the volume id).
  770. See also the multi-session example in libisofs/doc/checksums.txt.
  771. -------------------------------------------------------------------------------
  772. -------------------------------------------------------------------------------
  773. Sequential DVD-R[W] Cookbook
  774. -------------------------------------------------------------------------------
  775. Inspired by Andy Polyakov's http://fy.chalmers.se/~appro/linux/DVD+RW/tools ,
  776. backed by reading mmc5r03c.pdf from http://www.t10.org/ftp/t10/drafts/mmc5/
  777. and by experiments with drives NEC ND-4570A and LG GSA-4082B.
  778. For libburnia-project.org by Thomas Schmitt <scdbackup@gmx.net>
  779. -------------------------------------------------------------------------------
  780. Media type can be recognized by Current Profile from 46h GET CONFIGURATION.
  781. (mmc5r03c.pdf 6.6.2.1)
  782. DVD-R 0011h
  783. DVD-RW Restricted Overwrite 0013h
  784. DVD-RW Sequential Recording 0014h
  785. DVD-R/DL Sequential Recording 0015h (can only do single-session)
  786. There are two approaches for writing to sequential DVD-R[W]: DAO and
  787. Incremental. Not all media and drives offer Incremental which can do
  788. multi-session as with CD media and does not demand a predicted track size.
  789. DAO seems to be the older method. It can only write one single session and
  790. track, and it demands an exactly predicted track size.
  791. - About overwriteable, blank, appendable and finalized DVD-R[W] media
  792. - Incremental writing
  793. - DAO writing
  794. - Obtaining DVD-R[W] multi-session info for extending ISO-9660 filesystems
  795. - Obtaining a Table Of Content from DVD-R[W]
  796. - Hearsay about DVD-R/DL (Dual Layer)
  797. -------------------------------------------------------------------------------
  798. About overwriteable, blank, appendable and finalized DVD-R[W] media :
  799. DVD-RW can be either in formatted state Restricted Overwrite or in unformatted
  800. state Sequential Recording. Sequential media can be either blank, appendable
  801. or finalized.
  802. Only blank and appendable media are sequentially writeable. For overwriteable
  803. DVD-RW see the Overwriteable DVD Cookbook.
  804. Overwriteable DVD-RW can be detected by their profile number 0013h in contrast
  805. to profile number 0014h for sequential DVD-RW.
  806. The status of sequential media can be inquired like with CD by 51h READ DISC
  807. INFORMATION requesting Data Type 000b Standard Disc Information, where reply
  808. value Disc Status indicates:
  809. 00b blank
  810. 01b appendable
  811. 10b finalized
  812. 11b others (unsuitable for this recipe)
  813. (mmc5r03c.pdf 6.22.3.1.4)
  814. Finalized, appendable or overwriteable DVD-RW can be brought into blank
  815. sequential state by command A1h BLANK with blanking type 000b "Blank the disc".
  816. See TAO Multi-Session CD Cookbook for details about blanking.
  817. After minimal blanking (type 001b) DVD-RW my two drives do not offer the
  818. Incremental Streaming feature 0021h the media any more. Full blanking (000b)
  819. brings back this feature.
  820. (mmc5r03c.pdf 6.2)
  821. -------------------------------------------------------------------------------
  822. Incremental writing :
  823. Incremental writing can produce multi-session DVDs. It is indicated
  824. by feature 0021h being marked current in the reply of 46h GET CONFIGURATION.
  825. growisofs inquires 0021h by setting Starting Feature Number to 0x21 and
  826. Allocation Length to 16 in order to get only this one. The feature descriptor
  827. begins at byte 8 of the reply. Its availability is indicated by the Current
  828. Bit. libburn obtains the full feature list for this and other info.
  829. (mmc5r03c.pdf 5.2.2. Feature Descriptor format, 5.3.11 Feature 0021h,
  830. 6.2 46h GET CONFIGURATION, )
  831. In mode page 05h this method is selected by Write Type 00h.
  832. Speed can be influenced by B6h SET STREAMING , speed capabilities can be
  833. inquired by ACh GET PERFORMANCE. It is advised to set only speeds and sizes
  834. which are returned by ACh.
  835. (mmc5r03c.pdf 6.39 SET STREAMING, 6.8 GET PERFORMANCE)
  836. growisofs fetches a mode page 05h template by MODE SENSE and inserts its own
  837. parameters. It sets Multi-session to 11b, unless dvd_compat is nonzero.
  838. libburn composes its mode page 05h from zero and enables the application
  839. to control Multi-Session.
  840. BUFE Buffer Underrun protection 0=off, 1=on
  841. LS_V Link size valid 1=true
  842. Test Write -dummy mode for writing 0=off, 1=on
  843. Write Type Packet/TAO/SAO/RAW 00h = Incremental (Packet)
  844. Multi-session Whether to keep appendable 00b = finalize
  845. 11b = keep appendable
  846. Track Mode Describes frame type 5 [*1]
  847. Data Block Type Layout of payload blocks 8 [*2]
  848. Link Size ??? 16 [*3]
  849. FP Fixed Packet Size Bit 1
  850. Packet Size 16 [*4]
  851. (mmc5r03c.pdf 7.5.4 The Mode Page, 4.2.3.4 Table 17 CONTROL = Track Mode)
  852. (spc3r23.pdf 6.8 MODE SELECT, 7.4.3 Mode parameter header formats)
  853. [*1:]
  854. growisofs takes the Track Mode from 52h READ TRACK INFORMATION, Address/Number
  855. Type 1, Track 1, Track Information Block byte 5 & 0xf.
  856. (mmc5r03.pdf 6.27)
  857. The specs predict that this will be Track Mode 4 (6.27.3.8) and also state that
  858. default is 5 (7.5.4.12). 4 means: uninterrupted, do not copy. 5 means
  859. increment, do not copy.
  860. [*2:]
  861. 8 means: 2048 byte data blocks. growisofs sets this value if Data Mode from
  862. above 52h READ TRACK INFORMATION is 1 or Fh, which is predicted by the specs
  863. to be always true.
  864. (mmc5r03.pdf 6.27.3.10)
  865. [*3:]
  866. growisofs (transport.hxx) sets Link Size to 16 for profiles 0011h and 0014h.
  867. libburn now records the first link size from feature 0021h in its burn_drive
  868. structure. If another link size item is 16, then 16 is used.
  869. [*4:]
  870. growisofs takes Packet Size from 52h. Specs predict it will be 16 (= 32 kiB).
  871. (mmc5r03.pdf 7.5.4.16)
  872. The writing process is much like in "Writing a session to CD in TAO mode" :
  873. Next Writeable Address is fetched from the reply of 52h READ TRACK INFORMATION.
  874. libburn writes full 32 kiB buffers via 2Ah WRITE.
  875. (mmc5r03c.pdf, 6.27 READ TRACK INFORMATION, 6.44 WRITE)
  876. When writing is done, it is mandatory to force the drive's buffer to media by
  877. 35h SYNCHRONIZE CACHE.
  878. (mmc5r03c.pdf, 6.41)
  879. The track has to be closed by 5Bh CLOSE TRACK SESSION Close Function 001b.
  880. growisofs uses the logical track number for that and not FFh like libburn
  881. does with TAO CD. So libburn obtains the Last Track Number in Last Session
  882. from the reply of 51h READ DISC INFORMATION requesting Data Type 000b
  883. "Standard Disc Information".
  884. (mmc5r03c.pdf 6.3.3.2.2 CLOSE TRACK, 6.22.3.1.)
  885. Multiple tracks are permissible in a single session. After all of them have
  886. been written, 5Bh CLOSE TRACK SESSION Close Function 010b with Logical Track
  887. Number 0 closes the session. It depends on the Multi-Session value in mode
  888. page 05h whether the disc is finalized or stays appendable.
  889. (mmc5r03c.pdf 6.3.3.2.3)
  890. -------------------------------------------------------------------------------
  891. DAO writing :
  892. DAO is the mode described by feature 002Fh. This feature also gives information
  893. about capabilities for Burnfree (BUF), Test Write and DVD-RW.
  894. (mmc5r03c.pdf 5.3.25)
  895. Experiments with growisofs showed that the track size needs to be predicted
  896. and may not be exceeded during the write process. (growisofs ran into SCSI
  897. errors with piped non-ISO-9660 images and with piped ISO-9660 which have
  898. trailing data.)
  899. Speed can be influenced by B6h SET STREAMING , speed capabilities can be
  900. inquired by ACh GET PERFORMANCE. It is advised to set only speeds and sizes
  901. which are returned by ACh.
  902. (mmc5r03c.pdf 6.39 SET STREAMING, 6.8 GET PERFORMANCE)
  903. The mode page 05h to be sent :
  904. BUFE Buffer Underrun protection 0=off, 1=on
  905. LS_V Link size valid 0=false [*3]
  906. Test Write -dummy mode for writing 0=off, 1=on
  907. Write Type Packet/TAO/SAO/RAW 02h = DAO (same code as SAO)
  908. Multi-session Whether to keep appendable 00b = finalize
  909. Track Mode Describes frame type 5 [*1]
  910. Data Block Type Layout of payload blocks 8 [*2]
  911. Link Size ??? 0 [*3]
  912. FP Fixed Packet Size Bit 0 [*3]
  913. Packet Size 0 [*3]
  914. (mmc5r03c.pdf 7.5.4 The Mode Page, 4.2.3.4 Table 17 CONTROL = Track Mode)
  915. (spc3r23.pdf 6.8 MODE SELECT, 7.4.3 Mode parameter header formats)
  916. [*1:]
  917. growisofs takes the Track Mode from 52h READ TRACK INFORMATION, Address/Number
  918. Type 1, Track 1, Track Information Block byte 5 & 0xf.
  919. (mmc5r03.pdf 6.27)
  920. [*2:]
  921. 8 means: 2048 byte data blocks. growisofs sets this value if Data Mode from
  922. above 52h READ TRACK INFORMATION is 1 or Fh, which is predicted by the specs
  923. to be always true. (If not: growisofs aborts.)
  924. (mmc5r03.pdf 6.27.3.10)
  925. [*3:]
  926. Link Size, Packet Size and their companions only apply to Write Type 00h.
  927. The session layout must be described by 53h RESERVE TRACK, RMZ=ARSV=0.
  928. Reservation size should better already be aligned to 32 KiB. It has not been
  929. tested yet, what happens if not enough data get written.
  930. (mmc5r03c.pdf 6.31)
  931. Next Writeable Address is fetched from the reply of 52h READ TRACK INFORMATION.
  932. The reply is supposed to be 0. libburn writes full 32 kiB buffers via
  933. 2Ah WRITE.
  934. (mmc5r03c.pdf, 6.27 READ TRACK INFORMATION, 6.44 WRITE)
  935. If the track source delivers less than the announced size then libburn pads up
  936. by zeros.
  937. When writing is done, it is mandatory to force the drive's buffer to media by
  938. 35h SYNCHRONIZE CACHE.
  939. (mmc5r03c.pdf, 6.41)
  940. No further finalization is necessary. (I.e. no 5Bh CLOSE TRACK SESSION.)
  941. -------------------------------------------------------------------------------
  942. Obtaining DVD-R[W] multi-session info for extending ISO-9660 filesystems :
  943. (valid for DVD+R too)
  944. Like with CD it is necessary to obtain the two numbers for mkisofs option -C
  945. in order to prepare a ISO-9660 filesystem image which by its inner pointers
  946. matches the block addresses of the future location on media.
  947. These are the start address of the first track in the last complete session
  948. and the predicted start address of the track which will host the new image.
  949. See TAO Multi-Session CD Cookbook for some more info about mkisofs aspects.
  950. The first number may be gained by 43h READ TOC/PMA/ATIP Format 0001b which in
  951. table 478 promises quick access via Start Address Of First Track In Last
  952. Session.
  953. (mmc5r03c.pdf 6.26.2.5 table 478, 6.26.3.3.1)
  954. Regrettably the MMC-5 specs still define a useless reply for non-CD media
  955. which obviously stems from MMC-3 times when no multi-session was possible
  956. with non-CD.
  957. (mmc5r03c.pdf 6.26.3.3.3)
  958. Both my drives do give a useful reply with the correct number for appendable
  959. DVD-RW. But not being backed by the specs this method appears unappealing .
  960. Another approach would be a formatted Table of Content, obtained by 43h READ
  961. TOC/PMA/ATIP Format 0000b. The specs do not totally outrule that this returns
  962. useful data with non-CD but they define a crippled TOC for multi-session.
  963. (mmc5r03c.pdf 6.26.3.2.4)
  964. My LG drive returns a more detailed TOC, my NEC drive stays with the rather
  965. suboptimal specs. So one would get different TOCs on different drives.
  966. Nevertheless, the MMC-5 compliant TOC would return the desired number in
  967. the Track Start address of the track with the highest number before AAh.
  968. Most stable seems the approach to obtain the desired number from the reply
  969. of 52h READ TRACK INFORMATION, Address/Number Type 01b. The field Logical Block
  970. Address/Track/Session has to bear the track number of the first track in the
  971. last complete session. To determine this number one has to determine the
  972. number of the last session and the number of the last track from 51h READ DISC
  973. INFORMATION and to iterate over the tracknumber by 52h READ TRACK INFORMATION
  974. until the first track with the desired session number appears and reveils
  975. its start address.
  976. (mmc5r03c.pdf 6.22 51h DISC, 6.27 52h TRACK)
  977. This method is very near to fabricating an own TOC. So libburn does this
  978. when inspecting the media. If the first number for -C is needed, libburn
  979. inquires its TOC model for the address of the first track in the last
  980. complete session. See below for a detailed description of TOC fabrication.
  981. The second -C number is the exact prediction of future track start address. It
  982. is gained like with CD by 52h READ TRACK INFORMATION Type 01b. Different from
  983. CD one may not use track number FFh but has to use the Last Track in Last
  984. Session from 51h READ DISC INFORMATION.
  985. (mmc5r03c.pdf 6.22 51h DISC, 6.27 52h TRACK)
  986. -------------------------------------------------------------------------------
  987. Obtaining a Table Of Content from DVD-R[W]:
  988. (valid for DVD+R too)
  989. The raw TOC entries from 43h READ TOC/PMA/ATIP Format 0010b as described with
  990. CD media are not available with non-CD.
  991. There is a Format 0000b "Formatted TOC" but this is with non-CD a fictional
  992. information much at the discretion of the drive. Two drives with the same disc
  993. may well return different Formatted TOC. They are supposed to be consistent
  994. only about the last complete session and even there the MMC-5 specification
  995. 6.26.3.2.5 seems to prescribe a structure which does not match the true
  996. structure of incremental writing to sequential DVD-R[W].
  997. (mmc5r03c.pdf 6.26.3.2)
  998. So i prefer not to use this method of getting a TOC.
  999. The alternative is to produce an own TOC from information gained by 51h READ
  1000. DISC INFORMATION and by 52h READ TRACK INFORMATION which reveil a CD-like
  1001. structure of sessions and 1:n related tracks.
  1002. 51h READ DISC INFORMATION Data Type 000b, fields Number of Sessions (Least
  1003. Significant Byte) and Number of Sessions (Most Significant Byte) give the
  1004. number of sessions. The last complete session number of an appendable disc
  1005. is one less because there is an incomplete session at its end. libburn only
  1006. records complete sessions in its TOC model.
  1007. libburn uses Last Track in Last Session as a hint for the range of track
  1008. numbers.
  1009. (mmc5r03c.pdf 6.22)
  1010. Next step is to iterate from 1 up to the last track number and to obtain
  1011. the according track info by 52h READ TRACK INFORMATION. Each track tells its
  1012. Session Number (LSB at byte 2, MSB at 33), its Logical Track Start Address,
  1013. its Logical Track Size, and much more which is not needed for a fake CD TOC.
  1014. One may analyze the track info more finely but for this special purpose
  1015. it is enough to discard the tracks which do not belong to complete sessions.
  1016. (mmc5r03c.pdf 6.27)
  1017. At the end of each session libburn inserts fake leadout entries into its TOC
  1018. model. Their start address is computed from the start and size of the last
  1019. track of the session.
  1020. -------------------------------------------------------------------------------
  1021. Hearsay about DVD-R/DL (Dual Layer) :
  1022. Meanwhile confirmed by one user:
  1023. DVD-R/DL can assume profile 0015h DVD-R Dual Layer Sequential which is supposed
  1024. to behave like DVD-R or 0016h DVD-R Dual Layer Jump which has no counterpart
  1025. with DVD-R.
  1026. A half-sentence in mmc5r03c.pdf 6.3.3.3.3 indicates that closing a session
  1027. by 5Bh CLOSE TRACK SESSION Close Function 010b overrides the multi-session bits
  1028. in mode page 05h.
  1029. growisofs applies this function in case of not DAO, though. A comment in
  1030. growisofs_mmc.cpp states: "// DVD-R DL Seq has no notion of multi-session".
  1031. I am not reading this from the specs - but not explicitely the contrary either.
  1032. For now libburn will close the session but there is a macro prepared in
  1033. libburn/write.c Libburn_dvd_r_dl_multi_no_close_sessioN which will suppress
  1034. close session if multi-session is demanded.
  1035. -------------------------------------------------------------------------------
  1036. -------------------------------------------------------------------------------
  1037. DVD+R[/DL] Cookbook
  1038. -------------------------------------------------------------------------------
  1039. Inspired by reading mmc5r03c.pdf from http://www.t10.org/ftp/t10/drafts/mmc5/
  1040. backed by Andy Polyakov's http://fy.chalmers.se/~appro/linux/DVD+RW/tools ,
  1041. For libburnia-project.org by Thomas Schmitt <scdbackup@gmx.net>
  1042. -------------------------------------------------------------------------------
  1043. Media type can be recognized by Current Profile from 46h GET CONFIGURATION.
  1044. (mmc5r03c.pdf 6.6.2.1)
  1045. DVD+R 001bh
  1046. DVD+R/DL 002bh
  1047. - About empty, appendable and finalized DVD+R
  1048. - Writing a Pseudo Session to DVD+R
  1049. - DVD+R/DL (Dual Layer
  1050. The following two chapters of the Sequential DVD-R[W] Cookbook are valid for
  1051. DVD+R media too:
  1052. - Obtaining DVD-R[W] multi-session info for extending ISO-9660 filesystems
  1053. - Obtaining a Table Of Content from DVD-R[W]
  1054. -------------------------------------------------------------------------------
  1055. About blank, appendable and finalized DVD+R :
  1056. In the beginning a DVD+R holds an empty session and the Incomplete Fragment.
  1057. From these one may spawn reserved fragments or one may write directly to
  1058. the incomplete fragment. As soon as this is done the empty session becomes the
  1059. open session which finally needs to get closed. By closing fragments and
  1060. session a new empty session with empty Incomplete Fragment gets spawned.
  1061. So the disc stays appendable.
  1062. A DVD+R may hold 153 closed sessions with a single track each.
  1063. The open session may hold up to 15 open fragments. But on closure of the
  1064. session those fragments together form a single logical track. So one will
  1065. usually only use a single fragment for sequential writing.
  1066. (mmc5r03c.pdf 4.3.6.2)
  1067. The disc may get finalized by another close command so that no more data can
  1068. be written.
  1069. (mmc5r03c.pdf 6.3.3.4.4)
  1070. -------------------------------------------------------------------------------
  1071. Writing a Pseudo Session to DVD+R :
  1072. Session writing has to be pseudo because only one logical track per session
  1073. can be distinguished. So actually there have to be written multiple sessions
  1074. to mark multiple tracks. The pseudo session cannot get marked on disc and thus
  1075. the tracks of a pseudo session cannot be grouped accordingly in a TOC.
  1076. Speed can be influenced by B6h SET STREAMING , speed capabilities can be
  1077. inquired by ACh GET PERFORMANCE. It is advised to set only speeds and sizes
  1078. which are returned by ACh.
  1079. (mmc5r03c.pdf 6.39 SET STREAMING, 6.8 GET PERFORMANCE)
  1080. No mode page 05h is to be sent.
  1081. growisofs sends a page but the specs clearly state that one shall not do.
  1082. (mmc5r03c.pdf 7.5.3)
  1083. It is optional whether a track size is reserved in advance or not. Eventually
  1084. this is done by 53h RESERVE TRACK, RMZ=ARSV=0. Reservation size should better
  1085. already be aligned to 32 KiB.
  1086. (mmc5r03c.pdf 6.31)
  1087. The specs promise to pad up the track if not enough data get written.
  1088. (mmc5r03c.pdf 6.3.3.4.2)
  1089. Next Writeable Address is fetched from the reply of 52h READ TRACK INFORMATION
  1090. with track number FFh.
  1091. (mmc5r03c.pdf 6.27)
  1092. Since the fixely set write type is 16-block packet, full 32 kiB buffers have
  1093. to be transmitted via 2Ah WRITE.
  1094. (mmc5r03c.pdf 4.3.6.2.2)
  1095. When writing is done, it is mandatory to force the drive's buffer to media by
  1096. 35h SYNCHRONIZE CACHE.
  1097. (mmc5r03c.pdf 6.41)
  1098. The written fragment (i.e. track-to-be) has to be closed by 5Bh CLOSE TRACK
  1099. SESSION Close Function 001b.
  1100. (mmc5r03c.pdf 6.3.3.4.2)
  1101. libburn obtains the necessary logical track number from Last Track Number in
  1102. Last Session from the reply of 51h READ DISC INFORMATION requesting
  1103. Data Type 000b.
  1104. (mmc5r03c.pdf 6.22)
  1105. After each track 5Bh CLOSE TRACK SESSION Close Function 010b with Logical Track
  1106. Number 0 closes the DVD+R session but keeps the media appendable.
  1107. (mmc5r03c.pdf 6.3.3.4.3)
  1108. If the media shall not stay appendable then the last DVD+R session is to be
  1109. closed by Close Function 101b rather than 010b. This finalizes the media
  1110. "with minimal radius".
  1111. (mmc5r03c.pdf 6.3.3.4.4)
  1112. Note: growisofs has code for that gesture but explicitly avoids to use it, if
  1113. the media was appendable before writing began. Instead it recommends to fill
  1114. up the media with zeros. This gesture nevertheless caused error replies from
  1115. the drives in my own experiments.
  1116. The reason given by Andy Polyakov is that some DVD-ROM drives get mislead by
  1117. the lead-out information of (formerly) appendable media unless the media is
  1118. fully written.
  1119. (http://fy.chalmers.se/~appro/linux/DVD+RW/ , "Compatibility: caveat lector")
  1120. Own experiments showed no such problems with PC attached PATA DVD-ROM drives.
  1121. For best DVD-ROM compatibility one should avoid appendable media at all
  1122. by closing them already after the first session.
  1123. -------------------------------------------------------------------------------
  1124. DVD+R/DL (Dual Layer) :
  1125. libburn treats DL media just like their single layer equivalents.
  1126. This seems to work fine for DVD+R/DL, according to a report by nightmorph
  1127. in http://libburnia-project.org/ticket/13 .
  1128. -------------------------------------------------------------------------------
  1129. -------------------------------------------------------------------------------
  1130. BD-R Cookbook
  1131. -------------------------------------------------------------------------------
  1132. Inspired by reading mmc5r03c.pdf from http://www.t10.org/ftp/t10/drafts/mmc5/
  1133. backed by experiments iwith drive LG GGW H20L.
  1134. For libburnia-project.org by Thomas Schmitt <scdbackup@gmx.net>
  1135. -------------------------------------------------------------------------------
  1136. Media type can be recognized by Current Profile from 46h GET CONFIGURATION.
  1137. (mmc5r03c.pdf 6.6.2.1)
  1138. BD-R 0042h
  1139. There are two basic recording modes defined: Sequential Recording Mode SRM and
  1140. Random Recording Mode RRM. The latter is optional and for now not topic of this
  1141. text.
  1142. (mmc5r03c.pdf 4.5.3.5)
  1143. - SRM Formatting
  1144. - Writing a session in SRM-POW
  1145. (- Pseudo-OverWrite SRM+POW)
  1146. -------------------------------------------------------------------------------
  1147. SRM Formatting:
  1148. Despite being write-once media BD-R can optionally carry some formatting.
  1149. SRM has a disc structure model with tracks and sessions.
  1150. Several tracks may be open at the same time, each having its own NWA.
  1151. (mmc5r03c.pdf 4.5.3.5.2.2)
  1152. This structure is formatted onto blank media automatically as soon as the
  1153. first serious write attempt occurs.
  1154. (mmc5r03c.pdf 4.5.3.5)
  1155. Before such a write attempt, blank media may be explicitely formatted with
  1156. spares, which provide defect management.
  1157. (mmc5r03c.pdf 4.5.3.5.3)
  1158. Tracks get created from other tracks via RESERVE TRACK splitting.
  1159. (mmc5r03c.pdf 4.5.3.5.2.5)
  1160. On top of defect management there may be Pseudo-OverWrite SRM+POW, a costly
  1161. way to write several times to the same LBA. See below.
  1162. Fully sequential states are called SRM-POW.
  1163. (mmc5r03c.pdf 4.5.3.5.4)
  1164. Explicite formatting is done by 04h FORMAT UNIT. Its data payload consists
  1165. of a Format List Header and a Format Descriptor. It is advisable to set
  1166. the Immed bit and the FOV bit in header byte number 1. The descriptor should
  1167. be a copy of a descriptor from 23h READ FORMAT CAPACITIES but the size may be
  1168. adjusted within a certain range.
  1169. (mmc5r03c.pdf 6.5, 6.5.3.2, 6.5.3.3)
  1170. Format type 00h creates SRM layouts with a default number of spares (or
  1171. eventually RRM) chosen by the format sub-type:
  1172. 00b = SRM with support for POW
  1173. 01b = SRM without POW (but with some spares for defect management)
  1174. 10b = (RRM)
  1175. (mmc5r03c.pdf 6.5.4.2.1.6)
  1176. Format type 32h uses the same sub-types but can allocate non-default
  1177. amounts of spares. Similar to BD-RE format 31h, three format descriptors are
  1178. offered: #1: default size, #2: maximum spare area, #3: minimal spare.
  1179. The size may be chosen within that range.
  1180. The sense behind the Type Dependent Parameters is obscure
  1181. to me. Best will be to set ISA_V and TDMA_V to 0.
  1182. (mmc5r03c.pdf 6.5.4.2.1.17)
  1183. -------------------------------------------------------------------------------
  1184. Writing a session in SRM:
  1185. The procedure and constraints for writing BD-R SRM-POW are very similar to
  1186. DVD+R. libburn flatly re-uses its DVD+R code except the Close Function for
  1187. finalizing a disc.
  1188. In short:
  1189. If all written sessions are closed, then there is exactly one NWA.
  1190. In the beginning there is an empty session and track. A new track can be
  1191. written either with pre-announced size (by RESERVE TRACK) or open-end by
  1192. simply starting to write to the NWA. When done the track gets closed by
  1193. close function 001b. Then either session or disc gets closed depending on
  1194. the Close Function used:
  1195. - Close Function 010b closes the session and keeps the media appendable
  1196. (same as with DVD+R)
  1197. - Close Function 110b finalizes the media and makes it read-only.
  1198. (differs from libburn DVD+R procedure which uses 101b)
  1199. -------------------------------------------------------------------------------
  1200. Pseudo-OverWrite POW: (no used yet by libburn)
  1201. This enhancement of SRM emulates overwriting of existing data blocks.
  1202. (mmc5r03c.pdf 4.5.3.5.4)
  1203. POW establishes a virtual vLBA space on top of the real address space rLBA.
  1204. All read and write commands deal with vLBA. It seems that track NWAs are
  1205. assumed to be identical in vLBA space and in rLBA space.
  1206. It is not clear whether one may write to vLBA blocks which are neither written
  1207. yet nor at one of the track NWAs. Probably not, or else one could make NWAs run
  1208. into vLBAs which are associated with older rLBAs.
  1209. Replacing invalidated blocks consumes addresses in rLBA space at the NWA of
  1210. some track. I.e. no spares are consumed by POW. Nevertheless it is costly by
  1211. a special map called Orphanage. It covers rLBA which have been consumed
  1212. by differing vLBAs. It never shrinks and can grow with each write to remapped
  1213. addresses.
  1214. To avoid heavy Orphanage growth it is advised to write mostly to vLBA which
  1215. still coincide with their rLBA. E.g. those addresses which have neither been
  1216. written as rLBA nor as vLBA yet. So one should begin the vLBA of new sessions
  1217. at the NWA of a sufficiently sized track.
  1218. (mmc5r03c.pdf 4.5.3.5.4.2 , 4.5.3.6.9)
  1219. -------------------------------------------------------------------------------
  1220. This text is copyright 2011 - 2012 Thomas Schmitt <scdbackup@gmx.net>.
  1221. Permission is granted to copy, modify, and distribute it, as long as the
  1222. references to the original information sources are maintained.
  1223. There is NO WARRANTY, to the extent permitted by law.
  1224. -------------------------------------------------------------------------------