1*1a0afcdeSderaadt /* $OpenBSD: extern.h,v 1.17 2021/11/28 19:28:42 deraadt Exp $ */ 29ed7639aSespie /* 39ed7639aSespie * Copyright (c) 2002 Marc Espie. 49ed7639aSespie * 59ed7639aSespie * Redistribution and use in source and binary forms, with or without 69ed7639aSespie * modification, are permitted provided that the following conditions 79ed7639aSespie * are met: 89ed7639aSespie * 1. Redistributions of source code must retain the above copyright 99ed7639aSespie * notice, this list of conditions and the following disclaimer. 109ed7639aSespie * 2. Redistributions in binary form must reproduce the above copyright 119ed7639aSespie * notice, this list of conditions and the following disclaimer in the 129ed7639aSespie * documentation and/or other materials provided with the distribution. 139ed7639aSespie * 149ed7639aSespie * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 159ed7639aSespie * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 169ed7639aSespie * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 179ed7639aSespie * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 189ed7639aSespie * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 199ed7639aSespie * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 209ed7639aSespie * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 219ed7639aSespie * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 229ed7639aSespie * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 239ed7639aSespie * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 249ed7639aSespie * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 259ed7639aSespie */ 269ed7639aSespie 27cf22b6b5Smjc #include <sys/queue.h> 28cf22b6b5Smjc 29*1a0afcdeSderaadt #define cdio_isset(a,i) ((a)[(i)>>3] & (1<<((i)&(NBBY-1)))) 30*1a0afcdeSderaadt #define cdio_setbit(a,i) ((a)[(i)>>3] |= 1<<((i)&(NBBY-1))) 31*1a0afcdeSderaadt 329ed7639aSespie struct cd_toc_entry; 33cf22b6b5Smjc struct track_info { 34cf22b6b5Smjc off_t sz; 35f7dfecd4Sav off_t off; 36cf22b6b5Smjc u_int blklen; 37e6deffc0Smjc int fd; 38cf22b6b5Smjc char *file; 39cf22b6b5Smjc SLIST_ENTRY(track_info) track_list; 40cf22b6b5Smjc char type; 417b34dc5fSav int speed; 42cf22b6b5Smjc }; 43c52ec6b0Smortimer SLIST_HEAD(track_head, track_info); 44c52ec6b0Smortimer extern struct track_head tracks; 459ed7639aSespie 467b34dc5fSav /* Read/Write speed */ 477b34dc5fSav #define DRIVE_SPEED_MAX 0xfffe 487b34dc5fSav #define DRIVE_SPEED_OPTIMAL 0xffff /* automatically adjusted by drive */ 497b34dc5fSav 507b34dc5fSav /* Convert writing speed into Kbytes/sec (1x - 75 frames per second) */ 517b34dc5fSav #define CD_SPEED_TO_KBPS(x, blksz) ((x) * 75 * (blksz) / 1024) 527b34dc5fSav 537b34dc5fSav /* 547b34dc5fSav * It's maximum possible speed for CD (audio track). 557b34dc5fSav * Data tracks theoretically can be written at 436x but in practice I 567b34dc5fSav * believe, 380x will be never reached. 577b34dc5fSav * NOTE: this value must never be changed to a bigger value, it can cause 587b34dc5fSav * DRIVE_SPEED_MAX overrun. 597b34dc5fSav */ 607b34dc5fSav #define CD_MAX_SPEED 380 61c7402b7cSav 627299f7a2Sfgsch /* MMC feature codes */ 637299f7a2Sfgsch #define MMC_FEATURE_CDRW_CAV 0x27 /* Constant Angular Velocity */ 647299f7a2Sfgsch #define MMC_FEATURE_CD_TAO 0x2d /* Track-At-Once writing mode */ 657299f7a2Sfgsch #define MMC_FEATURE_CDRW_WRITE 0x37 /* media is CD-RW and can be written */ 667299f7a2Sfgsch 677299f7a2Sfgsch #define MMC_FEATURE_MAX 0x0110 687299f7a2Sfgsch 697299f7a2Sfgsch /* Media types */ 70f560e737Sav #define MEDIATYPE_UNKNOWN 0 71f560e737Sav #define MEDIATYPE_CDR 1 72f560e737Sav #define MEDIATYPE_CDRW 2 73f560e737Sav 749ed7639aSespie extern unsigned long entry2time(struct cd_toc_entry *); 759ed7639aSespie extern unsigned long entry2frames(struct cd_toc_entry *); 76cf22b6b5Smjc extern int open_cd(char *, int); 779ed7639aSespie extern char ** cddb(const char *, int, struct cd_toc_entry *, char *); 78ae359c1cSespie extern unsigned long cddb_discid(int, struct cd_toc_entry *); 799ed7639aSespie extern void free_names(char **); 80f560e737Sav extern int get_media_type(void); 81dc4cd921Skrw extern int get_media_capabilities(u_int8_t *, int); 827993cdedSmjc extern int blank(void); 837993cdedSmjc extern int unit_ready(void); 847993cdedSmjc extern int synchronize_cache(void); 857993cdedSmjc extern int close_session(void); 86dca2c108Smjc extern int get_disc_size(off_t *); 877993cdedSmjc extern int get_nwa(int *); 88cf22b6b5Smjc extern int writetao(struct track_head *); 89618f50a1Sderaadt extern int writetrack(struct track_info *, int); 907993cdedSmjc extern int mode_sense_write(unsigned char []); 917993cdedSmjc extern int mode_select_write(unsigned char []); 924ab9ef17Sfgsch extern int cdrip(char *); 934ab9ef17Sfgsch extern int cdplay(char *); 949ed7639aSespie 959ed7639aSespie #define VERSION "2.1" 96dca2c108Smjc #define WAVHDRLEN 44 97