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