1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 1996-98 Erik Andersen 4 * Copyright (C) 1998-2000 Jens Axboe 5 */ 6 #ifndef _IDE_CD_H 7 #define _IDE_CD_H 8 9 #include <linux/cdrom.h> 10 #include <asm/byteorder.h> 11 12 #define IDECD_DEBUG_LOG 0 13 14 #if IDECD_DEBUG_LOG 15 #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 16 #else 17 #define ide_debug_log(lvl, fmt, args...) do {} while (0) 18 #endif 19 20 #define ATAPI_WAIT_WRITE_BUSY (10 * HZ) 21 22 /************************************************************************/ 23 24 #define SECTOR_BITS 9 25 #ifndef SECTOR_SIZE 26 #define SECTOR_SIZE (1 << SECTOR_BITS) 27 #endif 28 #define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS) 29 #define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32) 30 31 /* Capabilities Page size including 8 bytes of Mode Page Header */ 32 #define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20) 33 #define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4 34 35 /* Structure of a MSF cdrom address. */ 36 struct atapi_msf { 37 u8 reserved; 38 u8 minute; 39 u8 second; 40 u8 frame; 41 }; 42 43 /* Space to hold the disk TOC. */ 44 #define MAX_TRACKS 99 45 struct atapi_toc_header { 46 unsigned short toc_length; 47 u8 first_track; 48 u8 last_track; 49 }; 50 51 struct atapi_toc_entry { 52 u8 reserved1; 53 #if defined(__BIG_ENDIAN_BITFIELD) 54 u8 adr : 4; 55 u8 control : 4; 56 #elif defined(__LITTLE_ENDIAN_BITFIELD) 57 u8 control : 4; 58 u8 adr : 4; 59 #else 60 #error "Please fix <asm/byteorder.h>" 61 #endif 62 u8 track; 63 u8 reserved2; 64 union { 65 unsigned lba; 66 struct atapi_msf msf; 67 } addr; 68 }; 69 70 struct atapi_toc { 71 int last_session_lba; 72 int xa_flag; 73 unsigned long capacity; 74 struct atapi_toc_header hdr; 75 struct atapi_toc_entry ent[MAX_TRACKS+1]; 76 /* One extra for the leadout. */ 77 }; 78 79 /* Extra per-device info for cdrom drives. */ 80 struct cdrom_info { 81 ide_drive_t *drive; 82 struct ide_driver *driver; 83 struct gendisk *disk; 84 struct device dev; 85 86 /* Buffer for table of contents. NULL if we haven't allocated 87 a TOC buffer for this device yet. */ 88 89 struct atapi_toc *toc; 90 91 u8 max_speed; /* Max speed of the drive. */ 92 u8 current_speed; /* Current speed of the drive. */ 93 94 /* Per-device info needed by cdrom.c generic driver. */ 95 struct cdrom_device_info devinfo; 96 97 unsigned long write_timeout; 98 }; 99 100 /* ide-cd_verbose.c */ 101 void ide_cd_log_error(const char *, struct request *, struct request_sense *); 102 103 /* ide-cd.c functions used by ide-cd_ioctl.c */ 104 int ide_cd_queue_pc(ide_drive_t *, const unsigned char *, int, void *, 105 unsigned *, struct request_sense *, int, req_flags_t); 106 int ide_cd_read_toc(ide_drive_t *, struct request_sense *); 107 int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); 108 void ide_cdrom_update_speed(ide_drive_t *, u8 *); 109 int cdrom_check_status(ide_drive_t *, struct request_sense *); 110 111 /* ide-cd_ioctl.c */ 112 int ide_cdrom_open_real(struct cdrom_device_info *, int); 113 void ide_cdrom_release_real(struct cdrom_device_info *); 114 int ide_cdrom_drive_status(struct cdrom_device_info *, int); 115 unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *, 116 unsigned int clearing, int slot_nr); 117 int ide_cdrom_tray_move(struct cdrom_device_info *, int); 118 int ide_cdrom_lock_door(struct cdrom_device_info *, int); 119 int ide_cdrom_select_speed(struct cdrom_device_info *, int); 120 int ide_cdrom_get_last_session(struct cdrom_device_info *, 121 struct cdrom_multisession *); 122 int ide_cdrom_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *); 123 int ide_cdrom_reset(struct cdrom_device_info *cdi); 124 int ide_cdrom_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); 125 int ide_cdrom_packet(struct cdrom_device_info *, struct packet_command *); 126 127 #endif /* _IDE_CD_H */ 128