Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-2-0]: src/sys/dev/scsipi Pull up revision 1.201 (requested by pk ...
details: https://anonhg.NetBSD.org/src/rev/5fa49ffb0fad
branches: netbsd-2-0
changeset: 560560:5fa49ffb0fad
user: jdc <jdc%NetBSD.org@localhost>
date: Tue Apr 27 18:50:21 2004 +0000
description:
Pull up revision 1.201 (requested by pk in ticket #186)
Some older devices do not understand the `disable block descriptor' bit in
the mode sense request. So fall back on mode sense data including a block
descriptor section.
See also sd.c rev. 1.214. Again: should we bother trying DBD at all?
diffstat:
sys/dev/scsipi/cd.c | 102 +++++++++++++++++++++++++++++++++++++++------------
1 files changed, 77 insertions(+), 25 deletions(-)
diffs (170 lines):
diff -r f81ce526e0b1 -r 5fa49ffb0fad sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c Tue Apr 27 18:00:25 2004 +0000
+++ b/sys/dev/scsipi/cd.c Tue Apr 27 18:50:21 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd.c,v 1.200 2004/02/22 00:26:43 enami Exp $ */
+/* $NetBSD: cd.c,v 1.200.2.1 2004/04/27 18:50:21 jdc Exp $ */
/*-
* Copyright (c) 1998, 2001, 2003 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.200 2004/02/22 00:26:43 enami Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.200.2.1 2004/04/27 18:50:21 jdc Exp $");
#include "rnd.h"
@@ -2268,17 +2268,29 @@
} data;
int error;
uint8_t oflags;
- int big;
+ int big, byte2;
struct cd_audio_page *page;
- if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data.page),
- AUDIO_PAGE, flags, &big)) != 0)
+ byte2 = SMS_DBD;
+try_again:
+ if ((error = cd_mode_sense(cd, byte2, &data, sizeof(data.page),
+ AUDIO_PAGE, flags, &big)) != 0) {
+ if (byte2 == SMS_DBD) {
+ /* Device may not understand DBD; retry without */
+ byte2 = 0;
+ goto try_again;
+ }
return (error);
+ }
if (big)
- page = (void *)(&data.header.big + 1);
+ page = (void *)((u_long)&data.header.big +
+ sizeof data.header.big +
+ _2btol(data.header.big.blk_desc_len));
else
- page = (void *)(&data.header.small + 1);
+ page = (void *)((u_long)&data.header.small +
+ sizeof data.header.small +
+ data.header.small.blk_desc_len);
oflags = page->flags;
page->flags &= ~CD_PA_SOTC;
@@ -2305,17 +2317,29 @@
struct cd_audio_page page;
} data;
int error;
- int big;
+ int big, byte2;
struct cd_audio_page *page;
- if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data.page),
- AUDIO_PAGE, flags, &big)) != 0)
+ byte2 = SMS_DBD;
+try_again:
+ if ((error = cd_mode_sense(cd, byte2, &data, sizeof(data.page),
+ AUDIO_PAGE, flags, &big)) != 0) {
+ if (byte2 == SMS_DBD) {
+ /* Device may not understand DBD; retry without */
+ byte2 = 0;
+ goto try_again;
+ }
return (error);
+ }
if (big)
- page = (void *)(&data.header.big + 1);
+ page = (void *)((u_long)&data.header.big +
+ sizeof data.header.big +
+ _2btol(data.header.big.blk_desc_len));
else
- page = (void *)(&data.header.small + 1);
+ page = (void *)((u_long)&data.header.small +
+ sizeof data.header.small +
+ data.header.small.blk_desc_len);
page->port[0].channels = p0;
page->port[1].channels = p1;
@@ -2341,17 +2365,29 @@
struct cd_audio_page page;
} data;
int error;
- int big;
+ int big, byte2;
struct cd_audio_page *page;
- if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data.page),
- AUDIO_PAGE, flags, &big)) != 0)
+ byte2 = SMS_DBD;
+try_again:
+ if ((error = cd_mode_sense(cd, byte2, &data, sizeof(data.page),
+ AUDIO_PAGE, flags, &big)) != 0) {
+ if (byte2 == SMS_DBD) {
+ /* Device may not understand DBD; retry without */
+ byte2 = 0;
+ goto try_again;
+ }
return (error);
+ }
if (big)
- page = (void *)(&data.header.big + 1);
+ page = (void *)((u_long)&data.header.big +
+ sizeof data.header.big +
+ _2btol(data.header.big.blk_desc_len));
else
- page = (void *)(&data.header.small + 1);
+ page = (void *)((u_long)&data.header.small +
+ sizeof data.header.small +
+ data.header.small.blk_desc_len);
arg->vol[0] = page->port[0].volume;
arg->vol[1] = page->port[1].volume;
@@ -2375,22 +2411,38 @@
struct cd_audio_page page;
} data, mask;
int error;
- int big;
+ int big, byte2;
struct cd_audio_page *page, *page2;
- if ((error = cd_mode_sense(cd, SMS_DBD, &data, sizeof(data.page),
- AUDIO_PAGE, flags, &big)) != 0)
+ byte2 = SMS_DBD;
+try_again:
+ if ((error = cd_mode_sense(cd, byte2, &data, sizeof(data.page),
+ AUDIO_PAGE, flags, &big)) != 0) {
+ if (byte2 == SMS_DBD) {
+ /* Device may not understand DBD; retry without */
+ byte2 = 0;
+ goto try_again;
+ }
return (error);
- if ((error = cd_mode_sense(cd, SMS_DBD, &mask, sizeof(mask.page),
+ }
+ if ((error = cd_mode_sense(cd, byte2, &mask, sizeof(mask.page),
AUDIO_PAGE|SMS_PAGE_CTRL_CHANGEABLE, flags, &big)) != 0)
return (error);
if (big) {
- page = (void *)(&data.header.big + 1);
- page2 = (void *)(&mask.header.big + 1);
+ page = (void *)((u_long)&data.header.big +
+ sizeof data.header.big +
+ _2btol(data.header.big.blk_desc_len));
+ page2 = (void *)((u_long)&mask.header.big +
+ sizeof mask.header.big +
+ _2btol(mask.header.big.blk_desc_len));
} else {
- page = (void *)(&data.header.small + 1);
- page2 = (void *)(&mask.header.small + 1);
+ page = (void *)((u_long)&data.header.small +
+ sizeof data.header.small +
+ data.header.small.blk_desc_len);
+ page2 = (void *)((u_long)&mask.header.small +
+ sizeof mask.header.small +
+ mask.header.small.blk_desc_len);
}
page->port[0].volume = arg->vol[0] & page2->port[0].volume;
Home |
Main Index |
Thread Index |
Old Index