From: BOSZORMENYI Zoltan <zbo...@mol.hu>
Subject: cdrom problem(s)
Date: 1999/09/03
Message-ID: <fa.hivb22v.112gnig@ifi.uio.no>#1/1
X-Deja-AN: 520643954
Original-Date: Fri, 3 Sep 1999 08:51:35 +0100
Sender: owner-lin...@vger.rutgers.edu
Content-Transfer-Encoding: 7bit
Original-Message-Id: <99Sep3.095551...@fw.mol.hu>
To: linux-...@vger.rutgers.edu
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Orcpt: rfc822;linux-kernel-outgoing-dig
Organization: Internet mailing list
MIME-Version: 1.0
Newsgroups: fa.linux.kernel
X-Loop: majo...@vger.rutgers.edu

Hi!

One of my friends complained about when he played MP3s
from a cd, the CD drive always spinned down. So when
the mp3 player wanted another chunk from the disc the
sound stopped until the drive spinned up again.
No, I do not want to start the "streaming IO" thread again.
:-)

First, we tried to disable the spindown with hdparm
but that did not worked, the command succeeded but
the drive spinned down even after that.

Next, we experimented with the drive capabilities
whether the drive supports setting its speed.
The program can be found here:
ftp://ftp.externet.hu/pub/people/zboszor/cdprobe.c

Here came the first problem: we tried several kernel
versions and some IDE drives: (a RedHat 6.0 shipped)
2.2.5-15, a 2.2.12, 2.3.15 and 2.3.16 and a 16x Toshiba
CD-ROM and a 8x <I do not know which vendor> one.

With 2.2.x the capability mask was 0xfff and with 2.3.15
it was 0x3ffff, which are definitely wrong.

The CDC_SELECT_DISC bit should appear only on CD
changers, right? And the CDC_SELECT_SPEED bit appears
on the 8x CD-ROM which fails to set its speed. :-(
(2.3.x was not tested on this drive, yet.)

And the drives are CD-ROMs, not CD-R, not CD-RW
and not DVD, so 2.3.15 is plain wrong in reporting
capabilities.

With 2.3.16, we got 0x1fef on my drive, which seems
to reflect the correct capabilities of the drive.

But with 2.3.16, we have another problem:
it does not play audio CDs. Starting CD player
applications fail with packet error on a vanilla
2.3.16 and other lines show up in dmesg or on the
console:

/dev/cdrom: Wrong medium type
cdrom: pid X is buggy!
cdrom: open failed.

After applying the posted cdrom fix, we do not get
the packet error but those lines do appear.

We tried to recompile cdp against 2.3.16.
At first the compilation failed because there is an
#include <linux/types.h> line in include/linux/cdrom.h.
One of the source files of cdp includes <linux/cdrom.h>
and <sys/types.h> and these conflict. Using

#ifdef __KERNEL__
#include <linux/types.h>
#endif

in cdrom.h solves the compilation error but the
audio CD playing problem remains.

Best regards,
Zoltan Boszormenyi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

From: Jens Axboe <ax...@image.dk>
Subject: Re: cdrom problem(s)
Date: 1999/09/03
Message-ID: <fa.dm5k9fv.mhqfbp@ifi.uio.no>#1/1
X-Deja-AN: 520643963
Original-Date: Fri, 03 Sep 1999 10:08:52 +0200
Sender: owner-lin...@vger.rutgers.edu
Content-Transfer-Encoding: 7bit
Original-Message-ID: <37CF8214...@image.dk>
References: <fa.hivb22v.112gnig@ifi.uio.no>
To: BOSZORMENYI Zoltan <zbo...@mol.hu>
Original-References: <99Sep3.095551...@fw.mol.hu>
Content-Type: text/plain; charset=us-ascii
X-Orcpt: rfc822;linux-kernel-outgoing-dig
Organization: Internet mailing list
MIME-Version: 1.0
Newsgroups: fa.linux.kernel
X-Loop: majo...@vger.rutgers.edu

BOSZORMENYI Zoltan wrote:
> Hi!
> 
> One of my friends complained about when he played MP3s
> from a cd, the CD drive always spinned down. So when
> the mp3 player wanted another chunk from the disc the
> sound stopped until the drive spinned up again.
> No, I do not want to start the "streaming IO" thread again.
> :-)
> 
> First, we tried to disable the spindown with hdparm
> but that did not worked, the command succeeded but
> the drive spinned down even after that.
> 
> Next, we experimented with the drive capabilities
> whether the drive supports setting its speed.
> The program can be found here:
> ftp://ftp.externet.hu/pub/people/zboszor/cdprobe.c

It's not the speed setting you should be after, but
rather CDROMSETSPINDOWN (and the equivalent GETSPINDOWN).

> Here came the first problem: we tried several kernel
> versions and some IDE drives: (a RedHat 6.0 shipped)
> 2.2.5-15, a 2.2.12, 2.3.15 and 2.3.16 and a 16x Toshiba
> CD-ROM and a 8x <I do not know which vendor> one.
> 
> With 2.2.x the capability mask was 0xfff and with 2.3.15
> it was 0x3ffff, which are definitely wrong.

What do you mean? I assume you just mean the capability
bits minus the mask.

> The CDC_SELECT_DISC bit should appear only on CD
> changers, right? And the CDC_SELECT_SPEED bit appears
> on the 8x CD-ROM which fails to set its speed. :-(
> (2.3.x was not tested on this drive, yet.)

I have fixed these up in 2.3.x mostly, 2.2 was awful
when it came to this. Basically just set all capabilities.

> And the drives are CD-ROMs, not CD-R, not CD-RW
> and not DVD, so 2.3.15 is plain wrong in reporting
> capabilities.

2.3.15 is not plain wrong in reporting capabilities,
but many drives are!

> With 2.3.16, we got 0x1fef on my drive, which seems
> to reflect the correct capabilities of the drive.

It is getting better.

> But with 2.3.16, we have another problem:
> it does not play audio CDs. Starting CD player
> applications fail with packet error on a vanilla
> 2.3.16 and other lines show up in dmesg or on the
> console:
> 
> /dev/cdrom: Wrong medium type
> cdrom: pid X is buggy!
> cdrom: open failed.
> 
> After applying the posted cdrom fix, we do not get
> the packet error but those lines do appear.

The second patch that followed had a correction to
that error message - it just wasn't very telling what
exactly was wrong. Basically, fix the cd playing
application to open the device O_NONBLOCK.

> We tried to recompile cdp against 2.3.16.
> At first the compilation failed because there is an
> #include <linux/types.h> line in include/linux/cdrom.h.
> One of the source files of cdp includes <linux/cdrom.h>
> and <sys/types.h> and these conflict. Using
> 
> #ifdef __KERNEL__
> #include <linux/types.h>
> #endif
> 
> in cdrom.h solves the compilation error but the
> audio CD playing problem remains.

That's a mistake, thanks! Add the O_NONBLOCK and you
should be fine.

-- 
*  Jens Axboe <ax...@image.dk>
*  Linux CD-ROM Maintainer
*  http://www.kernel.dk

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

From: BOSZORMENYI Zoltan <zbo...@mol.hu>
Subject: Re: cdrom problem(s)
Date: 1999/09/03
Message-ID: <fa.hhfh0iv.16iumih@ifi.uio.no>#1/1
X-Deja-AN: 520640660
Original-Date: Fri, 3 Sep 1999 09:46:40 +0100
Sender: owner-lin...@vger.rutgers.edu
Content-Transfer-Encoding: 7bit
Original-Message-Id: <99Sep3.105057...@fw.mol.hu>
References: <fa.dm5k9fv.mhqfbp@ifi.uio.no>
To: Jens Axboe <ax...@image.dk>
Original-References: <99Sep3.095551...@fw.mol.hu> <37CF8214...@image.dk>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Orcpt: rfc822;linux-kernel-outgoing-dig
Organization: Internet mailing list
MIME-Version: 1.0
Newsgroups: fa.linux.kernel
X-Loop: majo...@vger.rutgers.edu

Jens Axboe wrote:
> It's not the speed setting you should be after, but
> rather CDROMSETSPINDOWN (and the equivalent GETSPINDOWN).

Thanks, but doesn't hdparm do the same thing?
As I wrote, hdparm -S 0 succeeded but the drive
spinned down after that. :-(

BTW, is is right what the hdparm manpage writes
about the spindown settings?

> > Here came the first problem: we tried several kernel
> > versions and some IDE drives: (a RedHat 6.0 shipped)
> > 2.2.5-15, a 2.2.12, 2.3.15 and 2.3.16 and a 16x Toshiba
> > CD-ROM and a 8x <I do not know which vendor> one.
> >
> > With 2.2.x the capability mask was 0xfff and with 2.3.15
> > it was 0x3ffff, which are definitely wrong.
> 
> What do you mean? I assume you just mean the capability
> bits minus the mask.

I should have been written capability "value" not "mask".
My program writes this value it gets from the kernel in hex
and in a human readable way.

The value it wrote was 0xfff on 2.2.x, 0x3ffff on 2.3.15
and 0x1fef on 2.3.16 on the same drive. (The Toshiba one.)

> > And the drives are CD-ROMs, not CD-R, not CD-RW
> > and not DVD, so 2.3.15 is plain wrong in reporting
> > capabilities.
> 
> 2.3.15 is not plain wrong in reporting capabilities,
> but many drives are!

You may be right. I did not read ide-cd.c et.al.,
would you please enlighten me which techniques you use
to find out the correct capabilities of a drive
if it misreports them?

> > But with 2.3.16, we have another problem:
> > it does not play audio CDs. Starting CD player
> > applications fail with packet error on a vanilla
> > 2.3.16 and other lines show up in dmesg or on the
> > console:
> >
> > /dev/cdrom: Wrong medium type
> > cdrom: pid X is buggy!
> > cdrom: open failed.
> >
> > After applying the posted cdrom fix, we do not get
> > the packet error but those lines do appear.
> 
> The second patch that followed had a correction to
> that error message - it just wasn't very telling what
> exactly was wrong. Basically, fix the cd playing
> application to open the device O_NONBLOCK.

Hmm, the comments in cdrom.h tell that this change
was in 2.1.x, the cd player application in question (cdp)
works in 2.2.x. But I will look at its code deeper.
Thanks for the quick answer.

Best regards,
Zoltan Boszormenyi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

From: Jens Axboe <ax...@image.dk>
Subject: Re: cdrom problem(s)
Date: 1999/09/03
Message-ID: <fa.dkocgfv.i6ifbl@ifi.uio.no>#1/1
X-Deja-AN: 520640657
Original-Date: Fri, 03 Sep 1999 10:54:01 +0200
Sender: owner-lin...@vger.rutgers.edu
Content-Transfer-Encoding: 7bit
Original-Message-ID: <37CF8CA9...@image.dk>
References: <fa.hhfh0iv.16iumih@ifi.uio.no>
To: BOSZORMENYI Zoltan <zbo...@mol.hu>
Original-References: <99Sep3.095551...@fw.mol.hu> 
<37CF8214...@image.dk> <99Sep3.105057...@fw.mol.hu>
Content-Type: text/plain; charset=us-ascii
X-Orcpt: rfc822;linux-kernel-outgoing-dig
Organization: Internet mailing list
MIME-Version: 1.0
Newsgroups: fa.linux.kernel
X-Loop: majo...@vger.rutgers.edu

BOSZORMENYI Zoltan wrote:
> > It's not the speed setting you should be after, but
> > rather CDROMSETSPINDOWN (and the equivalent GETSPINDOWN).
> 
> Thanks, but doesn't hdparm do the same thing?
> As I wrote, hdparm -S 0 succeeded but the drive
> spinned down after that. :-(

I have no idea and I don't have hdparm sources handy here.
You could probably with an strace of hdparm.

> BTW, is is right what the hdparm manpage writes
> about the spindown settings?

I'm on a redhat 4.2 box right now and that man page
is probably not up to date. I'll check my own system
tonight.

> The value it wrote was 0xfff on 2.2.x, 0x3ffff on 2.3.15
> and 0x1fef on 2.3.16 on the same drive. (The Toshiba one.)

You must have 2.3.16 to get the capabilitites right.

> > > And the drives are CD-ROMs, not CD-R, not CD-RW
> > > and not DVD, so 2.3.15 is plain wrong in reporting
> > > capabilities.
> >
> > 2.3.15 is not plain wrong in reporting capabilities,
> > but many drives are!
> 
> You may be right. I did not read ide-cd.c et.al.,
> would you please enlighten me which techniques you use
> to find out the correct capabilities of a drive
> if it misreports them?

Sorry, there was a fix in 2.3.16 to correctly report
the capabilities with the ioctl - I forgot about that.
2.3.16 gets them right, ioctl included.
 
> > The second patch that followed had a correction to
> > that error message - it just wasn't very telling what
> > exactly was wrong. Basically, fix the cd playing
> > application to open the device O_NONBLOCK.
> 
> Hmm, the comments in cdrom.h tell that this change
> was in 2.1.x, the cd player application in question (cdp)
> works in 2.2.x. But I will look at its code deeper.
> Thanks for the quick answer.

Yes, it has been like this for a very long time. But now
cdrom.c also defaults to checking the media type which
makes it fail hard. That's the significant change.

> Best regards,
> Zoltan Boszormenyi

-- 
*  Jens Axboe <ax...@image.dk>
*  Linux CD-ROM Maintainer
*  http://www.kernel.dk

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/