summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata/atapi-cd.c
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2007-10-26 08:59:23 +0000
committersos <sos@FreeBSD.org>2007-10-26 08:59:23 +0000
commit8a3367a3b4185a08c824c8518d477fa3dd247168 (patch)
tree830bb38b7ebc3258d193aa4e7e95f95d4952d722 /sys/dev/ata/atapi-cd.c
parent07eb0a925e6d9c22f05c19f8bfc207fa6e7530fd (diff)
downloadFreeBSD-src-8a3367a3b4185a08c824c8518d477fa3dd247168.zip
FreeBSD-src-8a3367a3b4185a08c824c8518d477fa3dd247168.tar.gz
Update the way we get the mode pages on probe.
Diffstat (limited to 'sys/dev/ata/atapi-cd.c')
-rw-r--r--sys/dev/ata/atapi-cd.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c
index beb7667..4c6b55d 100644
--- a/sys/dev/ata/atapi-cd.c
+++ b/sys/dev/ata/atapi-cd.c
@@ -689,32 +689,25 @@ acd_geom_access(struct g_provider *pp, int dr, int dw, int de)
{
device_t dev = pp->geom->softc;
struct acd_softc *cdp = device_get_ivars(dev);
- struct ata_request *request;
- int8_t ccb[16] = { ATAPI_TEST_UNIT_READY, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int timeout = 60, track;
- if (!(request = ata_alloc_request()))
- return ENOMEM;
-
- /* wait if drive is not finished loading the medium */
+ /* check for media present, waiting for loading medium just in case */
while (timeout--) {
- bzero(request, sizeof(struct ata_request));
- request->dev = dev;
- bcopy(ccb, request->u.atapi.ccb, 16);
- request->flags = ATA_R_ATAPI;
- request->timeout = 5;
- ata_queue_request(request);
- if (!request->error &&
- (request->u.atapi.sense.key == 2 ||
- request->u.atapi.sense.key == 7) &&
- request->u.atapi.sense.asc == 4 &&
- request->u.atapi.sense.ascq == 1)
- pause("acdld", hz / 2);
- else
- break;
+ if (!acd_mode_sense(dev, ATAPI_CDROM_CAP_PAGE,
+ (caddr_t)&cdp->cap, sizeof(cdp->cap)) &&
+ cdp->cap.page_code == ATAPI_CDROM_CAP_PAGE) {
+ if ((cdp->cap.medium_type == MST_FMT_NONE) ||
+ (cdp->cap.medium_type == MST_NO_DISC) ||
+ (cdp->cap.medium_type == MST_DOOR_OPEN) ||
+ (cdp->cap.medium_type == MST_FMT_ERROR))
+ return EIO;
+ else
+ break;
+ }
+ pause("acdld", hz / 2);
}
- ata_free_request(request);
+ if (timeout <= 0)
+ return EIO;
if (pp->acr == 0) {
acd_prevent_allow(dev, 1);
@@ -1640,13 +1633,15 @@ static void
acd_get_cap(device_t dev)
{
struct acd_softc *cdp = device_get_ivars(dev);
+ int8_t ccb[16] = { ATAPI_MODE_SENSE_BIG, 0, ATAPI_CDROM_CAP_PAGE,
+ 0, 0, 0, 0, sizeof(cdp->cap)>>8, sizeof(cdp->cap),
+ 0, 0, 0, 0, 0, 0, 0 };
int count;
/* get drive capabilities, some bugridden drives needs this repeated */
for (count = 0 ; count < 5 ; count++) {
- if (!acd_mode_sense(dev, ATAPI_CDROM_CAP_PAGE,
- (caddr_t)&cdp->cap, sizeof(cdp->cap)) &&
- cdp->cap.page_code == ATAPI_CDROM_CAP_PAGE) {
+ if (!ata_atapicmd(dev, ccb, (caddr_t)&cdp->cap, sizeof(cdp->cap),
+ ATA_R_READ | ATA_R_QUIET, 5)) {
cdp->cap.max_read_speed = ntohs(cdp->cap.max_read_speed);
cdp->cap.cur_read_speed = ntohs(cdp->cap.cur_read_speed);
cdp->cap.max_write_speed = ntohs(cdp->cap.max_write_speed);
@@ -1825,6 +1820,8 @@ acd_describe(device_t dev)
printf("CD-R "); break;
case MST_CDRW:
printf("CD-RW "); break;
+ case MST_DVD:
+ printf("DVD "); break;
case MST_DOOR_OPEN:
printf("door open"); break;
case MST_NO_DISC:
OpenPOWER on IntegriCloud