Re: CDROM: Hardware tray movement detection

Erik Andersen (andersee@debian.org)
Wed, 27 Aug 1997 00:30:52 -0600


On Tue, Aug 26, 1997 at 11:18:51AM -0500, Tim P. Gerla wrote:
> Erik and the rest of the linux-kernel peoples:
>
> Hi. I've been hacking the cdrom driver to make it detect disk changes a
> bit more reliably. For example, if I am playing an audio CD, and I exit
> the player, press the eject button on my drive, put a new CD in, and press
> the eject button once again to close the drive, there is no 'hdX: media
> changed' message. Thus, my player won't update the toc entries on the
> CD...
>
> Everything works fine as-is if you use software tray movement ioctls.
>
> My question:
>
> Is there any way to detect *hardware* tray movement, and afterward, detect
> a disk change?
>
> I've been looking in /usr/src/linux/drivers/cdrom/cdrom.c, but I can't
> find anything there. It could be a more model-specific thing, but ide-cd.c
> doesn't seem to have anything either. The closest routine I have seen in
> ide-cd.c is ide_cdrom_tray_move(). I added a
> ide_cdrom_check_media_change() call to that function, but ...tray_move is
> only called when software tray movement is detected. :(
>
> Please let me know if I'm going in the right direction. This is my first
> real kernel hack. :)
>
> Thanks!
>
> -Tim
> --
> Tim P. Gerla | timg@means.net | http://www.cjnetworks.com/~coryb/timg/
> OS: Linux 2.1.51. Machine: AMD 486/120, 36MB, 4.3gig.

This is a case where page 101 of the ATAPI version 2.6 spec could come in
handy. You will find on that page a bit that specifies whether the disc
in the currently loaded cdrom slot has been changed since the last time
the disc was loaded. Unfortunatly, most ATAPI cdrom drives will not
report this particular bit, since slot tables are only returned for cdrom
drives that support cd changer commands.

Since that approach is going to be fairly useless, your next best bet is to
re-reading the TOC on every ioctl call to see if it is still the same
as last time. I would be glad to receive any patches you might have that
improve the behavior of ide-cd.

I have a few things I am working on right now with the kernel cdrom support,
such as a /proc interface for cdrom info and tunables via the generic
cdrom driver and sysctl (almost done), moving all the cdrom header files
except cdrom.h to drivers/cdrom/ (done), merging ucdrom.h and cdrom.h (done),
making some updates to the generic cdrom interface to make it even more
generic (in progress), and porting all the proprietary cdrom drivers to use
the generic interface. When I am done, there will be one (and only one)
Linux cdrom user interface. Just in time for DVDs to take over... [GRIN]

-Erik

--
Erik B. Andersen   Web:    http://www.inconnect.com/~andersen/ 
                   email:  andersee@debian.org
--This message was written using 73% post-consumer electrons--