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