linux/drivers/ide/ide-cd.h
<<
>>
Prefs
   1/*
   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
  11/*
  12 * typical timeout for packet command
  13 */
  14#define ATAPI_WAIT_PC           (60 * HZ)
  15#define ATAPI_WAIT_WRITE_BUSY   (10 * HZ)
  16
  17/************************************************************************/
  18
  19#define SECTOR_BITS             9
  20#ifndef SECTOR_SIZE
  21#define SECTOR_SIZE             (1 << SECTOR_BITS)
  22#endif
  23#define SECTORS_PER_FRAME       (CD_FRAMESIZE >> SECTOR_BITS)
  24#define SECTOR_BUFFER_SIZE      (CD_FRAMESIZE * 32)
  25
  26/* Capabilities Page size including 8 bytes of Mode Page Header */
  27#define ATAPI_CAPABILITIES_PAGE_SIZE            (8 + 20)
  28#define ATAPI_CAPABILITIES_PAGE_PAD_SIZE        4
  29
  30enum {
  31        /* Device sends an interrupt when ready for a packet command. */
  32        IDE_CD_FLAG_DRQ_INTERRUPT       = (1 << 0),
  33        /* Drive cannot lock the door. */
  34        IDE_CD_FLAG_NO_DOORLOCK         = (1 << 1),
  35        /* Drive cannot eject the disc. */
  36        IDE_CD_FLAG_NO_EJECT            = (1 << 2),
  37        /* Drive is a pre ATAPI 1.2 drive. */
  38        IDE_CD_FLAG_PRE_ATAPI12         = (1 << 3),
  39        /* TOC addresses are in BCD. */
  40        IDE_CD_FLAG_TOCADDR_AS_BCD      = (1 << 4),
  41        /* TOC track numbers are in BCD. */
  42        IDE_CD_FLAG_TOCTRACKS_AS_BCD    = (1 << 5),
  43        /*
  44         * Drive does not provide data in multiples of SECTOR_SIZE
  45         * when more than one interrupt is needed.
  46         */
  47        IDE_CD_FLAG_LIMIT_NFRAMES       = (1 << 6),
  48        /* Seeking in progress. */
  49        IDE_CD_FLAG_SEEKING             = (1 << 7),
  50        /* Driver has noticed a media change. */
  51        IDE_CD_FLAG_MEDIA_CHANGED       = (1 << 8),
  52        /* Saved TOC information is current. */
  53        IDE_CD_FLAG_TOC_VALID           = (1 << 9),
  54        /* We think that the drive door is locked. */
  55        IDE_CD_FLAG_DOOR_LOCKED         = (1 << 10),
  56        /* SET_CD_SPEED command is unsupported. */
  57        IDE_CD_FLAG_NO_SPEED_SELECT     = (1 << 11),
  58        IDE_CD_FLAG_VERTOS_300_SSD      = (1 << 12),
  59        IDE_CD_FLAG_VERTOS_600_ESD      = (1 << 13),
  60        IDE_CD_FLAG_SANYO_3CD           = (1 << 14),
  61        IDE_CD_FLAG_FULL_CAPS_PAGE      = (1 << 15),
  62        IDE_CD_FLAG_PLAY_AUDIO_OK       = (1 << 16),
  63        IDE_CD_FLAG_LE_SPEED_FIELDS     = (1 << 17),
  64};
  65
  66/* Structure of a MSF cdrom address. */
  67struct atapi_msf {
  68        byte reserved;
  69        byte minute;
  70        byte second;
  71        byte frame;
  72};
  73
  74/* Space to hold the disk TOC. */
  75#define MAX_TRACKS 99
  76struct atapi_toc_header {
  77        unsigned short toc_length;
  78        byte first_track;
  79        byte last_track;
  80};
  81
  82struct atapi_toc_entry {
  83        byte reserved1;
  84#if defined(__BIG_ENDIAN_BITFIELD)
  85        __u8 adr     : 4;
  86        __u8 control : 4;
  87#elif defined(__LITTLE_ENDIAN_BITFIELD)
  88        __u8 control : 4;
  89        __u8 adr     : 4;
  90#else
  91#error "Please fix <asm/byteorder.h>"
  92#endif
  93        byte track;
  94        byte reserved2;
  95        union {
  96                unsigned lba;
  97                struct atapi_msf msf;
  98        } addr;
  99};
 100
 101struct atapi_toc {
 102        int    last_session_lba;
 103        int    xa_flag;
 104        unsigned long capacity;
 105        struct atapi_toc_header hdr;
 106        struct atapi_toc_entry  ent[MAX_TRACKS+1];
 107          /* One extra for the leadout. */
 108};
 109
 110/* Extra per-device info for cdrom drives. */
 111struct cdrom_info {
 112        ide_drive_t     *drive;
 113        ide_driver_t    *driver;
 114        struct gendisk  *disk;
 115        struct kref     kref;
 116
 117        /* Buffer for table of contents.  NULL if we haven't allocated
 118           a TOC buffer for this device yet. */
 119
 120        struct atapi_toc *toc;
 121
 122        unsigned long   sector_buffered;
 123        unsigned long   nsectors_buffered;
 124        unsigned char   *buffer;
 125
 126        /* The result of the last successful request sense command
 127           on this device. */
 128        struct request_sense sense_data;
 129
 130        struct request request_sense_request;
 131        int dma;
 132        unsigned long last_block;
 133        unsigned long start_seek;
 134
 135        unsigned int cd_flags;
 136
 137        u8 max_speed;           /* Max speed of the drive. */
 138        u8 current_speed;       /* Current speed of the drive. */
 139
 140        /* Per-device info needed by cdrom.c generic driver. */
 141        struct cdrom_device_info devinfo;
 142
 143        unsigned long write_timeout;
 144};
 145
 146/* ide-cd_verbose.c */
 147void ide_cd_log_error(const char *, struct request *, struct request_sense *);
 148
 149/* ide-cd.c functions used by ide-cd_ioctl.c */
 150void ide_cd_init_rq(ide_drive_t *, struct request *);
 151int ide_cd_queue_pc(ide_drive_t *, struct request *);
 152int ide_cd_read_toc(ide_drive_t *, struct request_sense *);
 153int ide_cdrom_get_capabilities(ide_drive_t *, u8 *);
 154void ide_cdrom_update_speed(ide_drive_t *, u8 *);
 155int cdrom_check_status(ide_drive_t *, struct request_sense *);
 156
 157/* ide-cd_ioctl.c */
 158int ide_cdrom_open_real(struct cdrom_device_info *, int);
 159void ide_cdrom_release_real(struct cdrom_device_info *);
 160int ide_cdrom_drive_status(struct cdrom_device_info *, int);
 161int ide_cdrom_check_media_change_real(struct cdrom_device_info *, int);
 162int ide_cdrom_tray_move(struct cdrom_device_info *, int);
 163int ide_cdrom_lock_door(struct cdrom_device_info *, int);
 164int ide_cdrom_select_speed(struct cdrom_device_info *, int);
 165int ide_cdrom_get_last_session(struct cdrom_device_info *,
 166                               struct cdrom_multisession *);
 167int ide_cdrom_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
 168int ide_cdrom_reset(struct cdrom_device_info *cdi);
 169int ide_cdrom_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
 170int ide_cdrom_packet(struct cdrom_device_info *, struct packet_command *);
 171
 172#endif /* _IDE_CD_H */
 173
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.