ide-cd.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #define IDECD_DEBUG_LOG 0
  10. #if IDECD_DEBUG_LOG
  11. #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args)
  12. #else
  13. #define ide_debug_log(lvl, fmt, args...) do {} while (0)
  14. #endif
  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. /* Structure of a MSF cdrom address. */
  27. struct atapi_msf {
  28. u8 reserved;
  29. u8 minute;
  30. u8 second;
  31. u8 frame;
  32. };
  33. /* Space to hold the disk TOC. */
  34. #define MAX_TRACKS 99
  35. struct atapi_toc_header {
  36. unsigned short toc_length;
  37. u8 first_track;
  38. u8 last_track;
  39. };
  40. struct atapi_toc_entry {
  41. u8 reserved1;
  42. #if defined(__BIG_ENDIAN_BITFIELD)
  43. u8 adr : 4;
  44. u8 control : 4;
  45. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  46. u8 control : 4;
  47. u8 adr : 4;
  48. #else
  49. #error "Please fix <asm/byteorder.h>"
  50. #endif
  51. u8 track;
  52. u8 reserved2;
  53. union {
  54. unsigned lba;
  55. struct atapi_msf msf;
  56. } addr;
  57. };
  58. struct atapi_toc {
  59. int last_session_lba;
  60. int xa_flag;
  61. unsigned long capacity;
  62. struct atapi_toc_header hdr;
  63. struct atapi_toc_entry ent[MAX_TRACKS+1];
  64. /* One extra for the leadout. */
  65. };
  66. /* Extra per-device info for cdrom drives. */
  67. struct cdrom_info {
  68. ide_drive_t *drive;
  69. struct ide_driver *driver;
  70. struct gendisk *disk;
  71. struct device dev;
  72. /* Buffer for table of contents. NULL if we haven't allocated
  73. a TOC buffer for this device yet. */
  74. struct atapi_toc *toc;
  75. u8 max_speed; /* Max speed of the drive. */
  76. u8 current_speed; /* Current speed of the drive. */
  77. /* Per-device info needed by cdrom.c generic driver. */
  78. struct cdrom_device_info devinfo;
  79. unsigned long write_timeout;
  80. };
  81. /* ide-cd_verbose.c */
  82. void ide_cd_log_error(const char *, struct request *, struct request_sense *);
  83. /* ide-cd.c functions used by ide-cd_ioctl.c */
  84. int ide_cd_queue_pc(ide_drive_t *, const unsigned char *, int, void *,
  85. unsigned *, struct request_sense *, int, unsigned int);
  86. int ide_cd_read_toc(ide_drive_t *, struct request_sense *);
  87. int ide_cdrom_get_capabilities(ide_drive_t *, u8 *);
  88. void ide_cdrom_update_speed(ide_drive_t *, u8 *);
  89. int cdrom_check_status(ide_drive_t *, struct request_sense *);
  90. /* ide-cd_ioctl.c */
  91. int ide_cdrom_open_real(struct cdrom_device_info *, int);
  92. void ide_cdrom_release_real(struct cdrom_device_info *);
  93. int ide_cdrom_drive_status(struct cdrom_device_info *, int);
  94. unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *,
  95. unsigned int clearing, int slot_nr);
  96. int ide_cdrom_tray_move(struct cdrom_device_info *, int);
  97. int ide_cdrom_lock_door(struct cdrom_device_info *, int);
  98. int ide_cdrom_select_speed(struct cdrom_device_info *, int);
  99. int ide_cdrom_get_last_session(struct cdrom_device_info *,
  100. struct cdrom_multisession *);
  101. int ide_cdrom_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
  102. int ide_cdrom_reset(struct cdrom_device_info *cdi);
  103. int ide_cdrom_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
  104. int ide_cdrom_packet(struct cdrom_device_info *, struct packet_command *);
  105. #endif /* _IDE_CD_H */