ide-cd.h 4.5 KB

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