ide-cd.h 4.8 KB

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