1*9f988b79SJean-Baptiste Boric /* $NetBSD: cdio_mmc_structs.h,v 1.1 2013/08/05 18:44:16 reinoud Exp $ */ 2*9f988b79SJean-Baptiste Boric 3*9f988b79SJean-Baptiste Boric /* 4*9f988b79SJean-Baptiste Boric * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk 5*9f988b79SJean-Baptiste Boric * All rights reserved. 6*9f988b79SJean-Baptiste Boric * 7*9f988b79SJean-Baptiste Boric * Redistribution and use in source and binary forms, with or without 8*9f988b79SJean-Baptiste Boric * modification, are permitted provided that the following conditions 9*9f988b79SJean-Baptiste Boric * are met: 10*9f988b79SJean-Baptiste Boric * 1. Redistributions of source code must retain the above copyright 11*9f988b79SJean-Baptiste Boric * notice, this list of conditions and the following disclaimer. 12*9f988b79SJean-Baptiste Boric * 2. Redistributions in binary form must reproduce the above copyright 13*9f988b79SJean-Baptiste Boric * notice, this list of conditions and the following disclaimer in the 14*9f988b79SJean-Baptiste Boric * documentation and/or other materials provided with the distribution. 15*9f988b79SJean-Baptiste Boric * 16*9f988b79SJean-Baptiste Boric * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17*9f988b79SJean-Baptiste Boric * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18*9f988b79SJean-Baptiste Boric * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19*9f988b79SJean-Baptiste Boric * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20*9f988b79SJean-Baptiste Boric * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21*9f988b79SJean-Baptiste Boric * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22*9f988b79SJean-Baptiste Boric * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23*9f988b79SJean-Baptiste Boric * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24*9f988b79SJean-Baptiste Boric * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25*9f988b79SJean-Baptiste Boric * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26*9f988b79SJean-Baptiste Boric * 27*9f988b79SJean-Baptiste Boric */ 28*9f988b79SJean-Baptiste Boric 29*9f988b79SJean-Baptiste Boric #ifndef _CDIO_MMC_EMU_H_ 30*9f988b79SJean-Baptiste Boric #define _CDIO_MMC_EMU_H_ 31*9f988b79SJean-Baptiste Boric 32*9f988b79SJean-Baptiste Boric #include <sys/types.h> 33*9f988b79SJean-Baptiste Boric 34*9f988b79SJean-Baptiste Boric /* 35*9f988b79SJean-Baptiste Boric * MMC device abstraction interface. 36*9f988b79SJean-Baptiste Boric * 37*9f988b79SJean-Baptiste Boric * It gathers information from GET_CONFIGURATION, READ_DISCINFO, 38*9f988b79SJean-Baptiste Boric * READ_TRACKINFO, READ_TOC2, READ_CD_CAPACITY and GET_CONFIGURATION 39*9f988b79SJean-Baptiste Boric * SCSI/ATAPI calls regardless if its a legacy CD-ROM/DVD-ROM device or a MMC 40*9f988b79SJean-Baptiste Boric * standard recordable device. 41*9f988b79SJean-Baptiste Boric */ 42*9f988b79SJean-Baptiste Boric struct mmc_discinfo { 43*9f988b79SJean-Baptiste Boric uint16_t mmc_profile; 44*9f988b79SJean-Baptiste Boric uint16_t mmc_class; 45*9f988b79SJean-Baptiste Boric 46*9f988b79SJean-Baptiste Boric uint8_t disc_state; 47*9f988b79SJean-Baptiste Boric uint8_t last_session_state; 48*9f988b79SJean-Baptiste Boric uint8_t bg_format_state; 49*9f988b79SJean-Baptiste Boric uint8_t link_block_penalty; /* in sectors */ 50*9f988b79SJean-Baptiste Boric 51*9f988b79SJean-Baptiste Boric uint64_t mmc_cur; /* current MMC_CAPs */ 52*9f988b79SJean-Baptiste Boric uint64_t mmc_cap; /* possible MMC_CAPs */ 53*9f988b79SJean-Baptiste Boric 54*9f988b79SJean-Baptiste Boric uint32_t disc_flags; /* misc flags */ 55*9f988b79SJean-Baptiste Boric 56*9f988b79SJean-Baptiste Boric uint32_t disc_id; 57*9f988b79SJean-Baptiste Boric uint64_t disc_barcode; 58*9f988b79SJean-Baptiste Boric uint8_t application_code; /* 8 bit really */ 59*9f988b79SJean-Baptiste Boric 60*9f988b79SJean-Baptiste Boric uint8_t unused1[3]; /* padding */ 61*9f988b79SJean-Baptiste Boric 62*9f988b79SJean-Baptiste Boric uint32_t last_possible_lba; /* last leadout start adr. */ 63*9f988b79SJean-Baptiste Boric uint32_t sector_size; 64*9f988b79SJean-Baptiste Boric 65*9f988b79SJean-Baptiste Boric uint16_t num_sessions; 66*9f988b79SJean-Baptiste Boric uint16_t num_tracks; /* derived */ 67*9f988b79SJean-Baptiste Boric 68*9f988b79SJean-Baptiste Boric uint16_t first_track; 69*9f988b79SJean-Baptiste Boric uint16_t first_track_last_session; 70*9f988b79SJean-Baptiste Boric uint16_t last_track_last_session; 71*9f988b79SJean-Baptiste Boric 72*9f988b79SJean-Baptiste Boric uint16_t unused2; /* padding/misc info resv. */ 73*9f988b79SJean-Baptiste Boric 74*9f988b79SJean-Baptiste Boric uint16_t reserved1[4]; /* MMC-5 track resources */ 75*9f988b79SJean-Baptiste Boric uint32_t reserved2[3]; /* MMC-5 POW resources */ 76*9f988b79SJean-Baptiste Boric 77*9f988b79SJean-Baptiste Boric uint32_t reserved3[8]; /* MMC-5+ */ 78*9f988b79SJean-Baptiste Boric }; 79*9f988b79SJean-Baptiste Boric #define MMCGETDISCINFO _IOR('c', 28, struct mmc_discinfo) 80*9f988b79SJean-Baptiste Boric 81*9f988b79SJean-Baptiste Boric #define MMC_CLASS_UNKN 0 82*9f988b79SJean-Baptiste Boric #define MMC_CLASS_DISC 1 83*9f988b79SJean-Baptiste Boric #define MMC_CLASS_CD 2 84*9f988b79SJean-Baptiste Boric #define MMC_CLASS_DVD 3 85*9f988b79SJean-Baptiste Boric #define MMC_CLASS_MO 4 86*9f988b79SJean-Baptiste Boric #define MMC_CLASS_BD 5 87*9f988b79SJean-Baptiste Boric #define MMC_CLASS_FILE 0xffff /* emulation mode */ 88*9f988b79SJean-Baptiste Boric 89*9f988b79SJean-Baptiste Boric #define MMC_DFLAGS_BARCODEVALID (1 << 0) /* barcode is present and valid */ 90*9f988b79SJean-Baptiste Boric #define MMC_DFLAGS_DISCIDVALID (1 << 1) /* discid is present and valid */ 91*9f988b79SJean-Baptiste Boric #define MMC_DFLAGS_APPCODEVALID (1 << 2) /* application code valid */ 92*9f988b79SJean-Baptiste Boric #define MMC_DFLAGS_UNRESTRICTED (1 << 3) /* restricted, then set app. code */ 93*9f988b79SJean-Baptiste Boric 94*9f988b79SJean-Baptiste Boric #define MMC_DFLAGS_FLAGBITS \ 95*9f988b79SJean-Baptiste Boric "\10\1BARCODEVALID\2DISCIDVALID\3APPCODEVALID\4UNRESTRICTED" 96*9f988b79SJean-Baptiste Boric 97*9f988b79SJean-Baptiste Boric #define MMC_CAP_SEQUENTIAL (1 << 0) /* sequential writable only */ 98*9f988b79SJean-Baptiste Boric #define MMC_CAP_RECORDABLE (1 << 1) /* record-able; i.e. not static */ 99*9f988b79SJean-Baptiste Boric #define MMC_CAP_ERASABLE (1 << 2) /* drive can erase sectors */ 100*9f988b79SJean-Baptiste Boric #define MMC_CAP_BLANKABLE (1 << 3) /* media can be blanked */ 101*9f988b79SJean-Baptiste Boric #define MMC_CAP_FORMATTABLE (1 << 4) /* media can be formatted */ 102*9f988b79SJean-Baptiste Boric #define MMC_CAP_REWRITABLE (1 << 5) /* media can be rewritten */ 103*9f988b79SJean-Baptiste Boric #define MMC_CAP_MRW (1 << 6) /* Mount Rainier formatted */ 104*9f988b79SJean-Baptiste Boric #define MMC_CAP_PACKET (1 << 7) /* using packet recording */ 105*9f988b79SJean-Baptiste Boric #define MMC_CAP_STRICTOVERWRITE (1 << 8) /* only writes a packet at a time */ 106*9f988b79SJean-Baptiste Boric #define MMC_CAP_PSEUDOOVERWRITE (1 << 9) /* overwrite through replacement */ 107*9f988b79SJean-Baptiste Boric #define MMC_CAP_ZEROLINKBLK (1 << 10) /* zero link block length capable */ 108*9f988b79SJean-Baptiste Boric #define MMC_CAP_HW_DEFECTFREE (1 << 11) /* hardware defect management */ 109*9f988b79SJean-Baptiste Boric 110*9f988b79SJean-Baptiste Boric #define MMC_CAP_FLAGBITS \ 111*9f988b79SJean-Baptiste Boric "\10\1SEQUENTIAL\2RECORDABLE\3ERASABLE\4BLANKABLE\5FORMATTABLE" \ 112*9f988b79SJean-Baptiste Boric "\6REWRITABLE\7MRW\10PACKET\11STRICTOVERWRITE\12PSEUDOOVERWRITE" \ 113*9f988b79SJean-Baptiste Boric "\13ZEROLINKBLK\14HW_DEFECTFREE" 114*9f988b79SJean-Baptiste Boric 115*9f988b79SJean-Baptiste Boric #define MMC_STATE_EMPTY 0 116*9f988b79SJean-Baptiste Boric #define MMC_STATE_INCOMPLETE 1 117*9f988b79SJean-Baptiste Boric #define MMC_STATE_FULL 2 118*9f988b79SJean-Baptiste Boric #define MMC_STATE_CLOSED 3 119*9f988b79SJean-Baptiste Boric 120*9f988b79SJean-Baptiste Boric #define MMC_BGFSTATE_UNFORM 0 121*9f988b79SJean-Baptiste Boric #define MMC_BGFSTATE_STOPPED 1 122*9f988b79SJean-Baptiste Boric #define MMC_BGFSTATE_RUNNING 2 123*9f988b79SJean-Baptiste Boric #define MMC_BGFSTATE_COMPLETED 3 124*9f988b79SJean-Baptiste Boric 125*9f988b79SJean-Baptiste Boric 126*9f988b79SJean-Baptiste Boric struct mmc_trackinfo { 127*9f988b79SJean-Baptiste Boric uint16_t tracknr; /* IN/OUT */ 128*9f988b79SJean-Baptiste Boric uint16_t sessionnr; 129*9f988b79SJean-Baptiste Boric 130*9f988b79SJean-Baptiste Boric uint8_t track_mode; 131*9f988b79SJean-Baptiste Boric uint8_t data_mode; 132*9f988b79SJean-Baptiste Boric 133*9f988b79SJean-Baptiste Boric uint16_t flags; 134*9f988b79SJean-Baptiste Boric 135*9f988b79SJean-Baptiste Boric uint32_t track_start; 136*9f988b79SJean-Baptiste Boric uint32_t next_writable; 137*9f988b79SJean-Baptiste Boric uint32_t free_blocks; 138*9f988b79SJean-Baptiste Boric uint32_t packet_size; 139*9f988b79SJean-Baptiste Boric uint32_t track_size; 140*9f988b79SJean-Baptiste Boric uint32_t last_recorded; 141*9f988b79SJean-Baptiste Boric }; 142*9f988b79SJean-Baptiste Boric #define MMCGETTRACKINFO _IOWR('c', 29, struct mmc_trackinfo) 143*9f988b79SJean-Baptiste Boric 144*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_COPY (1 << 0) 145*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_DAMAGED (1 << 1) 146*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_FIXED_PACKET (1 << 2) 147*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_INCREMENTAL (1 << 3) 148*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_BLANK (1 << 4) 149*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_RESERVED (1 << 5) 150*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_NWA_VALID (1 << 6) 151*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_LRA_VALID (1 << 7) 152*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_DATA (1 << 8) 153*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_AUDIO (1 << 9) 154*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_AUDIO_4CHAN (1 << 10) 155*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_PRE_EMPH (1 << 11) 156*9f988b79SJean-Baptiste Boric 157*9f988b79SJean-Baptiste Boric #define MMC_TRACKINFO_FLAGBITS \ 158*9f988b79SJean-Baptiste Boric "\10\1COPY\2DAMAGED\3FIXEDPACKET\4INCREMENTAL\5BLANK" \ 159*9f988b79SJean-Baptiste Boric "\6RESERVED\7NWA_VALID\10LRA_VALID\11DATA\12AUDIO" \ 160*9f988b79SJean-Baptiste Boric "\13AUDIO_4CHAN\14PRE_EMPH" 161*9f988b79SJean-Baptiste Boric 162*9f988b79SJean-Baptiste Boric #endif /* _CDIO_MMC_EMU_H_ */ 163*9f988b79SJean-Baptiste Boric 164