18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 1996-98 Erik Andersen 48c2ecf20Sopenharmony_ci * Copyright (C) 1998-2000 Jens Axboe 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef _IDE_CD_H 78c2ecf20Sopenharmony_ci#define _IDE_CD_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/cdrom.h> 108c2ecf20Sopenharmony_ci#include <asm/byteorder.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define IDECD_DEBUG_LOG 0 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#if IDECD_DEBUG_LOG 158c2ecf20Sopenharmony_ci#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args) 168c2ecf20Sopenharmony_ci#else 178c2ecf20Sopenharmony_ci#define ide_debug_log(lvl, fmt, args...) do {} while (0) 188c2ecf20Sopenharmony_ci#endif 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define ATAPI_WAIT_WRITE_BUSY (10 * HZ) 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/************************************************************************/ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_SHIFT) 258c2ecf20Sopenharmony_ci#define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32) 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* Capabilities Page size including 8 bytes of Mode Page Header */ 288c2ecf20Sopenharmony_ci#define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20) 298c2ecf20Sopenharmony_ci#define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* Structure of a MSF cdrom address. */ 328c2ecf20Sopenharmony_cistruct atapi_msf { 338c2ecf20Sopenharmony_ci u8 reserved; 348c2ecf20Sopenharmony_ci u8 minute; 358c2ecf20Sopenharmony_ci u8 second; 368c2ecf20Sopenharmony_ci u8 frame; 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* Space to hold the disk TOC. */ 408c2ecf20Sopenharmony_ci#define MAX_TRACKS 99 418c2ecf20Sopenharmony_cistruct atapi_toc_header { 428c2ecf20Sopenharmony_ci unsigned short toc_length; 438c2ecf20Sopenharmony_ci u8 first_track; 448c2ecf20Sopenharmony_ci u8 last_track; 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistruct atapi_toc_entry { 488c2ecf20Sopenharmony_ci u8 reserved1; 498c2ecf20Sopenharmony_ci#if defined(__BIG_ENDIAN_BITFIELD) 508c2ecf20Sopenharmony_ci u8 adr : 4; 518c2ecf20Sopenharmony_ci u8 control : 4; 528c2ecf20Sopenharmony_ci#elif defined(__LITTLE_ENDIAN_BITFIELD) 538c2ecf20Sopenharmony_ci u8 control : 4; 548c2ecf20Sopenharmony_ci u8 adr : 4; 558c2ecf20Sopenharmony_ci#else 568c2ecf20Sopenharmony_ci#error "Please fix <asm/byteorder.h>" 578c2ecf20Sopenharmony_ci#endif 588c2ecf20Sopenharmony_ci u8 track; 598c2ecf20Sopenharmony_ci u8 reserved2; 608c2ecf20Sopenharmony_ci union { 618c2ecf20Sopenharmony_ci unsigned lba; 628c2ecf20Sopenharmony_ci struct atapi_msf msf; 638c2ecf20Sopenharmony_ci } addr; 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistruct atapi_toc { 678c2ecf20Sopenharmony_ci int last_session_lba; 688c2ecf20Sopenharmony_ci int xa_flag; 698c2ecf20Sopenharmony_ci unsigned long capacity; 708c2ecf20Sopenharmony_ci struct atapi_toc_header hdr; 718c2ecf20Sopenharmony_ci struct atapi_toc_entry ent[MAX_TRACKS+1]; 728c2ecf20Sopenharmony_ci /* One extra for the leadout. */ 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* Extra per-device info for cdrom drives. */ 768c2ecf20Sopenharmony_cistruct cdrom_info { 778c2ecf20Sopenharmony_ci ide_drive_t *drive; 788c2ecf20Sopenharmony_ci struct ide_driver *driver; 798c2ecf20Sopenharmony_ci struct gendisk *disk; 808c2ecf20Sopenharmony_ci struct device dev; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci /* Buffer for table of contents. NULL if we haven't allocated 838c2ecf20Sopenharmony_ci a TOC buffer for this device yet. */ 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci struct atapi_toc *toc; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci u8 max_speed; /* Max speed of the drive. */ 888c2ecf20Sopenharmony_ci u8 current_speed; /* Current speed of the drive. */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci /* Per-device info needed by cdrom.c generic driver. */ 918c2ecf20Sopenharmony_ci struct cdrom_device_info devinfo; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci unsigned long write_timeout; 948c2ecf20Sopenharmony_ci}; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci/* ide-cd_verbose.c */ 978c2ecf20Sopenharmony_civoid ide_cd_log_error(const char *, struct request *, struct request_sense *); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* ide-cd.c functions used by ide-cd_ioctl.c */ 1008c2ecf20Sopenharmony_ciint ide_cd_queue_pc(ide_drive_t *, const unsigned char *, int, void *, 1018c2ecf20Sopenharmony_ci unsigned *, struct scsi_sense_hdr *, int, req_flags_t); 1028c2ecf20Sopenharmony_ciint ide_cd_read_toc(ide_drive_t *); 1038c2ecf20Sopenharmony_ciint ide_cdrom_get_capabilities(ide_drive_t *, u8 *); 1048c2ecf20Sopenharmony_civoid ide_cdrom_update_speed(ide_drive_t *, u8 *); 1058c2ecf20Sopenharmony_ciint cdrom_check_status(ide_drive_t *, struct scsi_sense_hdr *); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci/* ide-cd_ioctl.c */ 1088c2ecf20Sopenharmony_ciint ide_cdrom_open_real(struct cdrom_device_info *, int); 1098c2ecf20Sopenharmony_civoid ide_cdrom_release_real(struct cdrom_device_info *); 1108c2ecf20Sopenharmony_ciint ide_cdrom_drive_status(struct cdrom_device_info *, int); 1118c2ecf20Sopenharmony_ciunsigned int ide_cdrom_check_events_real(struct cdrom_device_info *, 1128c2ecf20Sopenharmony_ci unsigned int clearing, int slot_nr); 1138c2ecf20Sopenharmony_ciint ide_cdrom_tray_move(struct cdrom_device_info *, int); 1148c2ecf20Sopenharmony_ciint ide_cdrom_lock_door(struct cdrom_device_info *, int); 1158c2ecf20Sopenharmony_ciint ide_cdrom_select_speed(struct cdrom_device_info *, int); 1168c2ecf20Sopenharmony_ciint ide_cdrom_get_last_session(struct cdrom_device_info *, 1178c2ecf20Sopenharmony_ci struct cdrom_multisession *); 1188c2ecf20Sopenharmony_ciint ide_cdrom_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *); 1198c2ecf20Sopenharmony_ciint ide_cdrom_reset(struct cdrom_device_info *cdi); 1208c2ecf20Sopenharmony_ciint ide_cdrom_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); 1218c2ecf20Sopenharmony_ciint ide_cdrom_packet(struct cdrom_device_info *, struct packet_command *); 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci#endif /* _IDE_CD_H */ 124