17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*98584592Sarutz * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _MISC_SCSI_H 287c478bd9Sstevel@tonic-gate #define _MISC_SCSI_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include "device.h" 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate struct track_info { 397c478bd9Sstevel@tonic-gate uint32_t ti_flags; /* flags, see below */ 407c478bd9Sstevel@tonic-gate int ti_track_no; /* Track number */ 417c478bd9Sstevel@tonic-gate int ti_session_no; /* session no. 0 if cannot find that */ 427c478bd9Sstevel@tonic-gate uchar_t ti_track_mode; /* track ctrl nibble, see READ TOC */ 437c478bd9Sstevel@tonic-gate uchar_t ti_data_mode; /* Mode 0,1,2 or FF */ 447c478bd9Sstevel@tonic-gate uint32_t ti_start_address; /* Start LBA */ 457c478bd9Sstevel@tonic-gate uint32_t ti_track_size; /* Size in blocks */ 467c478bd9Sstevel@tonic-gate uint32_t ti_packet_size; /* If a packet written track */ 477c478bd9Sstevel@tonic-gate uint32_t ti_free_blocks; /* For an incomplete track */ 487c478bd9Sstevel@tonic-gate uint32_t ti_lra; /* LBA of Last written user datablock */ 497c478bd9Sstevel@tonic-gate uint32_t ti_nwa; /* Next writable address */ 507c478bd9Sstevel@tonic-gate }; 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* 537c478bd9Sstevel@tonic-gate * track_info_flags 547c478bd9Sstevel@tonic-gate */ 557c478bd9Sstevel@tonic-gate #define TI_FIXED_PACKET 1 567c478bd9Sstevel@tonic-gate #define TI_PACKET_MODE 2 577c478bd9Sstevel@tonic-gate #define TI_BLANK_TRACK 4 587c478bd9Sstevel@tonic-gate #define TI_RESERVED_TRACK 8 597c478bd9Sstevel@tonic-gate #define TI_COPY 0x10 607c478bd9Sstevel@tonic-gate #define TI_DAMAGED_TRACK 0x20 617c478bd9Sstevel@tonic-gate #define TI_NWA_VALID 0x100 627c478bd9Sstevel@tonic-gate #define TI_LRA_VALID 0x200 637c478bd9Sstevel@tonic-gate #define TI_SESSION_NO_VALID 0x1000 647c478bd9Sstevel@tonic-gate #define TI_FREE_BLOCKS_VALID 0x2000 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * Track mode nibble 687c478bd9Sstevel@tonic-gate */ 697c478bd9Sstevel@tonic-gate #define TRACK_MODE_DATA 0x06 707c478bd9Sstevel@tonic-gate #define TRACK_MODE_AUDIO 0x02 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 74 minutes, each second is 75 blocks */ 737c478bd9Sstevel@tonic-gate #define MAX_CD_BLKS (74*60*75) 747c478bd9Sstevel@tonic-gate #define MAX_DVD_BLKS 2295100 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* 77*98584592Sarutz * Macros to translate between a bandwidth ("RATE") and a Speed ("X") 78*98584592Sarutz * for CDs. Eg, "1X == 176,400 bytes/second". 79*98584592Sarutz * 807c478bd9Sstevel@tonic-gate * Some devices just multiply speed by 176. But more accurate ones 817c478bd9Sstevel@tonic-gate * multiply speed by 176.4. 827c478bd9Sstevel@tonic-gate */ 83*98584592Sarutz #define CD_RATE_TO_X(r) ((r) % 176 ? ((((r)*10)+5)/1764) : (r) / 176) 84*98584592Sarutz #define CD_X_TO_RATE(s) ((((s)*1764)+5)/10) 85*98584592Sarutz 86*98584592Sarutz /* 87*98584592Sarutz * Macros to translate between a bandwidth ("RATE") and a Speed ("X") 88*98584592Sarutz * for DVDs. Eg, "1X == 1,385,000 bytes/second". 89*98584592Sarutz */ 90*98584592Sarutz #define DVD_RATE_TO_X(r) (((ulong_t)(r)*1000)/1385000) 91*98584592Sarutz #define DVD_X_TO_RATE(s) (((s)*1385000)/1000) 92*98584592Sarutz 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #define FINALIZE_TIMEOUT (6 * 12) /* Six minutes */ 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate uint32_t read_scsi32(void *addr); 977c478bd9Sstevel@tonic-gate uint16_t read_scsi16(void *addr); 987c478bd9Sstevel@tonic-gate void load_scsi32(void *addr, uint32_t val); 997c478bd9Sstevel@tonic-gate void load_scsi16(void *addr, uint16_t val); 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate int get_mode_page(int fd, int page_no, int pc, int buf_len, uchar_t *buffer); 1027c478bd9Sstevel@tonic-gate int set_mode_page(int fd, uchar_t *buffer); 1037c478bd9Sstevel@tonic-gate int build_track_info(cd_device *dev, int trackno, struct track_info *t_info); 1047c478bd9Sstevel@tonic-gate uchar_t get_data_mode(int fd, uint32_t lba); 1057c478bd9Sstevel@tonic-gate int prepare_for_write(cd_device *dev, int track_mode, int test_write, 1067c478bd9Sstevel@tonic-gate int keep_disc_open); 1077c478bd9Sstevel@tonic-gate int finalize(cd_device *dev); 1087c478bd9Sstevel@tonic-gate int get_last_possible_lba(cd_device *dev); 1097c478bd9Sstevel@tonic-gate int read_audio_through_read_cd(cd_device *dev, uint_t start_lba, uint_t nblks, 1107c478bd9Sstevel@tonic-gate uchar_t *buf); 1117c478bd9Sstevel@tonic-gate int eject_media(cd_device *dev); 1127c478bd9Sstevel@tonic-gate int cd_speed_ctrl(cd_device *dev, int cmd, int speed); 1137c478bd9Sstevel@tonic-gate int rt_streaming_ctrl(cd_device *dev, int cmd, int speed); 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate void tao_init(int mode); 1167c478bd9Sstevel@tonic-gate void tao_fini(void); 1177c478bd9Sstevel@tonic-gate void write_init(int mode); 1187c478bd9Sstevel@tonic-gate void write_fini(void); 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate #endif 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate #endif /* _MISC_SCSI_H */ 125