From 4b02675abede8359d7c5f4c9b738ced02a7e7492 Mon Sep 17 00:00:00 2001 From: sos Date: Mon, 21 Feb 2000 18:41:05 +0000 Subject: Fix the changer code, dont wait for device ready on unload, it wont become ready as there is no media - doh. Update the command name reporting. --- sys/dev/ata/atapi-all.c | 12 ++++++++---- sys/dev/ata/atapi-all.h | 14 +++++++++++--- sys/dev/ata/atapi-cd.c | 32 +++++++++++++++++++------------- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/sys/dev/ata/atapi-all.c b/sys/dev/ata/atapi-all.c index 8f1e67a..ca9cbba 100644 --- a/sys/dev/ata/atapi-all.c +++ b/sys/dev/ata/atapi-all.c @@ -592,11 +592,17 @@ atapi_cmd2str(u_int8_t cmd) case 0x25: return ("READ_CAPACITY"); case 0x28: return ("READ_BIG"); case 0x2a: return ("WRITE_BIG"); + case 0x2b: return ("LOCATE"); case 0x34: return ("READ_POSITION"); case 0x35: return ("SYNCHRONIZE_CACHE"); + case 0x3b: return ("WRITE_BUFFER"); + case 0x3c: return ("READ_BUFFER"); case 0x42: return ("READ_SUBCHANNEL"); case 0x43: return ("READ_TOC"); - case 0x51: return ("READ_DISC_INFO"); + case 0x47: return ("PLAY_MSF"); + case 0x48: return ("PLAY_TRACK"); + case 0x4b: return ("PAUSE"); + case 0x51: return ("READ_DISK_INFO"); case 0x52: return ("READ_TRACK_INFO"); case 0x53: return ("RESERVE_TRACK"); case 0x54: return ("SEND_OPC_INFO"); @@ -607,13 +613,11 @@ atapi_cmd2str(u_int8_t cmd) case 0x5b: return ("CLOSE_TRACK/SESSION"); case 0x5c: return ("READ_BUFFER_CAPACITY"); case 0x5d: return ("SEND_CUE_SHEET"); - case 0x47: return ("PLAY_MSF"); - case 0x4b: return ("PAUSE"); - case 0x48: return ("PLAY_TRACK"); case 0xa1: return ("BLANK_CMD"); case 0xa3: return ("SEND_KEY"); case 0xa4: return ("REPORT_KEY"); case 0xa5: return ("PLAY_BIG"); + case 0xa6: return ("LOAD_UNLOAD"); case 0xad: return ("READ_DVD_STRUCTURE"); case 0xb4: return ("PLAY_CD"); case 0xbb: return ("SET_SPEED"); diff --git a/sys/dev/ata/atapi-all.h b/sys/dev/ata/atapi-all.h index ca7a55f..998bbc4 100644 --- a/sys/dev/ata/atapi-all.h +++ b/sys/dev/ata/atapi-all.h @@ -66,6 +66,7 @@ #define ATAPI_TEST_UNIT_READY 0x00 /* check if device is ready */ #define ATAPI_REWIND 0x01 /* rewind */ #define ATAPI_REQUEST_SENSE 0x03 /* get sense data */ +#define ATAPI_FORMAT 0x04 /* format unit */ #define ATAPI_READ 0x08 /* read data */ #define ATAPI_WRITE 0x0a /* write data */ #define ATAPI_WEOF 0x10 /* write filemark */ @@ -94,16 +95,23 @@ #define ATAPI_PLAY_MSF 0x47 /* play by MSF address */ #define ATAPI_PLAY_TRACK 0x48 /* play by track number */ #define ATAPI_PAUSE 0x4b /* pause audio operation */ +#define ATAPI_READ_DISK_INFO 0x51 /* get disk info structure */ #define ATAPI_READ_TRACK_INFO 0x52 /* get track info structure */ +#define ATAPI_RESERVE_TRACK 0x53 /* reserve track */ +#define ATAPI_SEND_OPC_INFO 0x54 /* send OPC structurek */ #define ATAPI_MODE_SELECT_BIG 0x55 /* set device parameters */ +#define ATAPI_REPAIR_TRACK 0x58 /* repair track */ +#define ATAPI_READ_MASTER_CUE 0x59 /* read master CUE info */ #define ATAPI_MODE_SENSE_BIG 0x5a /* get device parameters */ #define ATAPI_CLOSE_TRACK 0x5b /* close track/session */ +#define ATAPI_READ_BUFFER_CAPACITY 0x5c /* get buffer capicity */ +#define ATAPI_SEND_CUE_SHEET 0x5d /* send CUE sheet */ #define ATAPI_BLANK 0xa1 /* blank the media */ -#define ATAPI_SEND_KEY 0xa3 -#define ATAPI_REPORT_KEY 0xa4 +#define ATAPI_SEND_KEY 0xa3 /* send DVD key structure */ +#define ATAPI_REPORT_KEY 0xa4 /* get DVD key structure */ #define ATAPI_PLAY_BIG 0xa5 /* play by lba */ #define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */ -#define ATAPI_READ_STRUCTURE 0xad +#define ATAPI_READ_STRUCTURE 0xad /* get DVD structure */ #define ATAPI_PLAY_CD 0xb4 /* universal play command */ #define ATAPI_SET_SPEED 0xbb /* set drive speed */ #define ATAPI_MECH_STATUS 0xbd /* get changer status */ diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index f35f964..f67af2f 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -422,17 +422,23 @@ acd_describe(struct acd_softc *cdp) } else { char changer[32]; + char devnum[8]; bzero(changer, sizeof(changer)); - if (cdp->changer_info) + if (cdp->changer_info) { + sprintf(devnum, "%d-%d", + cdp->lun, cdp->lun + cdp->changer_info->slots - 1); sprintf(changer, " with %d CD changer", cdp->changer_info->slots); - - printf("acd%d: %s%s <%.40s> at ata%d-%s using %s\n", - cdp->lun, (cdp->cap.write_dvdr) ? "DVD-R" : - (cdp->cap.write_dvdram) ? "DVD-RAM" : - (cdp->cap.write_cdrw) ? "CD-RW" : - (cdp->cap.write_cdr) ? "CD-R" : - (cdp->cap.read_dvdrom) ? "DVD-ROM" : "CDROM", + } + else + sprintf(devnum, "%d", cdp->lun); + + printf("acd%s: %s%s <%.40s> at ata%d-%s using %s\n", + devnum, (cdp->cap.write_dvdr) ? "DVD-R" : + (cdp->cap.write_dvdram) ? "DVD-RAM" : + (cdp->cap.write_cdrw) ? "CD-RW" : + (cdp->cap.write_cdr) ? "CD-R" : + (cdp->cap.read_dvdrom) ? "DVD-ROM" : "CDROM", changer, ATA_PARAM(cdp->atp->controller, cdp->atp->unit)->model, device_get_unit(cdp->atp->controller->dev), (cdp->atp->unit == ATA_MASTER) ? "master" : "slave", @@ -1134,7 +1140,7 @@ acd_done(struct atapi_request *request) } else { bp->b_resid = request->bytecount; - if ((bp->b_flags & B_READ) == B_WRITE) + if (!(bp->b_flags & B_READ)) cdp->flags |= F_WRITTEN; } devstat_end_transaction_buf(cdp->stats, bp); @@ -1244,16 +1250,16 @@ acd_select_slot(struct acd_softc *cdp) /* unlock (might not be needed but its cheaper than asking) */ acd_prevent_allow(cdp, 0); - bzero(ccb, sizeof(ccb)); + /* unload the current media from player */ + bzero(ccb, sizeof(ccb)); ccb[0] = ATAPI_LOAD_UNLOAD; - ccb[1] = 0x01; ccb[4] = 2; ccb[8] = cdp->changer_info->current_slot; - atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL, NULL); - atapi_wait_ready(cdp->atp, 30); + atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL, NULL); /* load the wanted slot */ + bzero(ccb, sizeof(ccb)); ccb[0] = ATAPI_LOAD_UNLOAD; ccb[1] = 0x01; ccb[4] = 3; -- cgit v1.1