ide-cd.h 3.4 KB

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