diff --git a/configure.ac b/configure.ac index 4c0726e8..5890352a 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,7 @@ define(RELEASE_NUM, 72) define(CDIO_VERSION_STR, 0.$1cvs) AC_PREREQ(2.52) -AC_REVISION([$Id: configure.ac,v 1.125 2005/01/07 22:15:24 rocky Exp $])dnl +AC_REVISION([$Id: configure.ac,v 1.126 2005/01/08 20:39:40 rocky Exp $])dnl AC_INIT(libcdio, CDIO_VERSION_STR(RELEASE_NUM)) AC_CONFIG_SRCDIR(src/cd-info.c) AM_INIT_AUTOMAKE @@ -331,7 +331,7 @@ case $host_os in fi ;; linux*) - AC_CHECK_HEADERS(linux/version.h) + AC_CHECK_HEADERS(linux/version.h linux/major.h) AC_CHECK_HEADERS(linux/cdrom.h, [have_linux_cdrom_h="yes"]) if test "x$have_linux_cdrom_h" = "xyes" ; then AC_TRY_COMPILE(,[ diff --git a/include/cdio/cdda.h b/include/cdio/cdda.h index 7499ea15..e3c55f9d 100644 --- a/include/cdio/cdda.h +++ b/include/cdio/cdda.h @@ -1,5 +1,5 @@ /* - $Id: cdda.h,v 1.2 2005/01/06 23:34:13 rocky Exp $ + $Id: cdda.h,v 1.3 2005/01/08 20:39:40 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein Copyright (C) 2001 Xiph.org @@ -63,13 +63,17 @@ typedef struct TOC { /* structure of table of contents */ struct cdrom_drive_s { CdIo_t *p_cdio; - int opened; /* This struct may just represent a candidate for opening */ + int opened; /**< This struct may just represent a candidate for opening */ char *cdda_device_name; char *drive_model; + int drive_type; int interface; - int bigendianp; + int bigendianp; /**< Whether data returned on the CDDA is bigendian or + not. 1 if big endian, 0 if little endian and -1 if + we don't know. + */ int nsectors; int cd_extra; @@ -83,7 +87,7 @@ struct cdrom_drive_s { char *errorbuf; char *messagebuf; - /* functions specific to particular drives/interrfaces */ + /* functions specific to particular drives/interfaces */ int (*enable_cdda) (cdrom_drive_t *d, int onoff); int (*read_toc) (cdrom_drive_t *d); @@ -96,23 +100,12 @@ struct cdrom_drive_s { int is_atapi; int is_mmc; - /* SCSI command buffer and offset pointers */ - unsigned char *sg; - unsigned char *sg_buffer; - unsigned char inqbytes[4]; - /* Scsi parameters and state */ unsigned char density; unsigned char orgdens; unsigned int orgsize; long bigbuff; int adjust_ssize; - - int fua; - int lun; - - sigset_t sigset; - }; /** autosense functions */ diff --git a/lib/cdda_interface/cooked_interface.c b/lib/cdda_interface/cooked_interface.c index e4b0f0d3..3ccf9886 100644 --- a/lib/cdda_interface/cooked_interface.c +++ b/lib/cdda_interface/cooked_interface.c @@ -1,5 +1,5 @@ /* - $Id: cooked_interface.c,v 1.6 2005/01/06 03:38:58 rocky Exp $ + $Id: cooked_interface.c,v 1.7 2005/01/08 20:39:40 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein Original interface.c Copyright (C) 1994-1997 @@ -171,7 +171,7 @@ verify_read_command(cdrom_drive_t *d) #include "drive_exceptions.h" -#if CHECK_EXCEPTIONS_FIXED +#ifdef HAVE_LINUX_MAJOR_H static void check_exceptions(cdrom_drive_t *d, const exception_t *list) { @@ -185,14 +185,14 @@ check_exceptions(cdrom_drive_t *d, const exception_t *list) i++; } } -#endif +#endif /* HAVE_LINUX_MAJOR_H */ /* set function pointers to use the ioctl routines */ int cooked_init_drive (cdrom_drive_t *d){ int ret; -#if BUFSIZE_DETERMINATION_FIXED +#if HAVE_LINUX_MAJOR_H switch(d->drive_type){ case MATSUSHITA_CDROM_MAJOR: /* sbpcd 1 */ case MATSUSHITA_CDROM2_MAJOR: /* sbpcd 2 */ @@ -203,6 +203,8 @@ cooked_init_drive (cdrom_drive_t *d){ cdmessage(d,"Attempting to set sbpcd buffer size...\n"); d->nsectors=8; + +#if BUFSIZE_DETERMINATION_FIXED while(1){ /* this ioctl returns zero on error; exactly wrong, but that's @@ -226,6 +228,7 @@ cooked_init_drive (cdrom_drive_t *d){ break; } } +#endif /* BUFSIZE_DETERMINATION_FIXED */ break; case IDE0_MAJOR: @@ -241,18 +244,9 @@ cooked_init_drive (cdrom_drive_t *d){ break; default: - d->nsectors=40; + d->nsectors=25; /* The max for SCSI MMC2 */ } -#else - { - char buffer[256]; - d->nsectors = 8; - sprintf(buffer,"\tSetting read block size at %d sectors (%ld bytes).\n", - d->nsectors,(long)d->nsectors*CDIO_CD_FRAMESIZE_RAW); - cdmessage(d,buffer); - } - -#endif +#endif /*HAVE_LINUX_MAJOR_H*/ d->enable_cdda = Dummy; d->read_audio = cooked_read; diff --git a/lib/cdda_interface/drive_exceptions.h b/lib/cdda_interface/drive_exceptions.h index 1e5aac4f..85ff2e1d 100644 --- a/lib/cdda_interface/drive_exceptions.h +++ b/lib/cdda_interface/drive_exceptions.h @@ -1,5 +1,5 @@ /* - $Id: drive_exceptions.h,v 1.2 2005/01/05 04:16:11 rocky Exp $ + $Id: drive_exceptions.h,v 1.3 2005/01/08 20:39:40 rocky Exp $ Copyright (C) 2004 Rocky Bernstein Copyright (C) 1998 Monty xiphmont@mit.edu @@ -21,7 +21,6 @@ extern int scsi_enable_cdda(cdrom_drive_t *d, int); extern long scsi_read_mmc(cdrom_drive_t *d, void *,long,long); -extern long scsi_read_mmc2(cdrom_drive_t *d, void *,long,long); extern long scsi_read_D4_10(cdrom_drive_t *, void *,long,long); extern long scsi_read_D4_12(cdrom_drive_t *, void *,long,long); extern long scsi_read_D8(cdrom_drive_t *, void *,long,long); @@ -40,6 +39,11 @@ typedef struct exception { /* specific to general */ #ifdef FINISHED_DRIVE_EXCEPTIONS +extern long scsi_read_mmc2(cdrom_drive_t *d, void *,long,long); +#else +#define scsi_read_mmc2 NULL +#endif + /* list of drives that affect autosensing in ATAPI specific portions of code (force drives to detect as ATAPI or SCSI, force ATAPI read command */ @@ -49,7 +53,6 @@ static exception_t atapi_list[]={ {"SONY CD-ROM CDU-561", 0, 0, Dummy, NULL,0}, {"Chinon CD-ROM CDS-525", 0, 0, Dummy, NULL,0}, {NULL,0,0,NULL,NULL,0}}; -#endif /*FINISHED_DRIVE_EXCEPTIONS*/ /* list of drives that affect MMC default settings */ diff --git a/lib/cdda_interface/interface.c b/lib/cdda_interface/interface.c index d4748675..2ae0b385 100644 --- a/lib/cdda_interface/interface.c +++ b/lib/cdda_interface/interface.c @@ -1,5 +1,5 @@ /* - $Id: interface.c,v 1.7 2005/01/06 03:38:58 rocky Exp $ + $Id: interface.c,v 1.8 2005/01/08 20:39:40 rocky Exp $ Copyright (C) 2005 Rocky Bernstein Copyright (C) 1998 Monty xiphmont@mit.edu @@ -53,7 +53,6 @@ cdda_close(cdrom_drive_t *d) _clean_messages(d); if (d->cdda_device_name) free(d->cdda_device_name); if (d->drive_model) free(d->drive_model); - if (d->sg) free(d->sg); free(d); } diff --git a/lib/cdda_interface/scan_devices.c b/lib/cdda_interface/scan_devices.c index 1a702885..328f0fd2 100644 --- a/lib/cdda_interface/scan_devices.c +++ b/lib/cdda_interface/scan_devices.c @@ -1,5 +1,5 @@ /* - $Id: scan_devices.c,v 1.6 2005/01/08 00:56:09 rocky Exp $ + $Id: scan_devices.c,v 1.7 2005/01/08 20:39:40 rocky Exp $ Copyright (C) 2004 Rocky Bernstein Copyright (C) 1998 Monty xiphmont@mit.edu @@ -156,6 +156,11 @@ cdda_identify_cooked(const char *dev, int messagedest, char **messages) { cdrom_drive_t *d=NULL; + struct stat st; +#ifdef HAVE_LINUX_MAJOR_H + int drive_type = 0; +#endif + char *description=NULL; char *device = NULL; CdIo_t *p_cdio = NULL; @@ -172,11 +177,78 @@ cdda_identify_cooked(const char *dev, int messagedest, char **messages) return NULL; } +#ifdef HAVE_LINUX_MAJOR_H + if ( 0 == stat(device, &st) ) { + if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { + drive_type=(int)(st.st_rdev>>8); + switch (drive_type) { + case IDE0_MAJOR: + case IDE1_MAJOR: + case IDE2_MAJOR: + case IDE3_MAJOR: + /* Yay, ATAPI... */ + description=strdup("ATAPI compatible "); + break; + case CDU31A_CDROM_MAJOR: + /* major indicates this is a cdrom; no ping necessary. */ + description=strdup("Sony CDU31A or compatible"); + break; + case CDU535_CDROM_MAJOR: + /* major indicates this is a cdrom; no ping necessary. */ + description=strdup("Sony CDU535 or compatible"); + break; + + case MATSUSHITA_CDROM_MAJOR: + case MATSUSHITA_CDROM2_MAJOR: + case MATSUSHITA_CDROM3_MAJOR: + case MATSUSHITA_CDROM4_MAJOR: + /* major indicates this is a cdrom; no ping necessary. */ + description=strdup("non-ATAPI IDE-style Matsushita/Panasonic CR-5xx or compatible"); + break; + case SANYO_CDROM_MAJOR: + description=strdup("Sanyo proprietary or compatible: NOT CDDA CAPABLE"); + break; + case MITSUMI_CDROM_MAJOR: + case MITSUMI_X_CDROM_MAJOR: + description=strdup("Mitsumi proprietary or compatible: NOT CDDA CAPABLE"); + break; + case OPTICS_CDROM_MAJOR: + description=strdup("Optics Dolphin or compatible: NOT CDDA CAPABLE"); + break; + case AZTECH_CDROM_MAJOR: + description=strdup("Aztech proprietary or compatible: NOT CDDA CAPABLE"); + break; + case GOLDSTAR_CDROM_MAJOR: + description=strdup("Goldstar proprietary: NOT CDDA CAPABLE"); + break; + case CM206_CDROM_MAJOR: + description=strdup("Philips/LMS CM206 proprietary: NOT CDDA CAPABLE"); + break; + + case SCSI_CDROM_MAJOR: + case SCSI_GENERIC_MAJOR: + /* Nope nope nope */ + idmessage(messagedest,messages,"\t\t%s is not a cooked ioctl CDROM.", + device); + free(device); + return(NULL); + default: + /* What the hell is this? */ + idmessage(messagedest,messages,"\t\t%s is not a cooked ioctl CDROM.", + device); + free(device); + return(NULL); + } + } + } +#endif /* HAVE_LINUX_MAJOR_H */ + /* Minimum init */ d=calloc(1,sizeof(cdrom_drive_t)); - d->p_cdio = p_cdio; + d->p_cdio = p_cdio; d->cdda_device_name = device; + d->drive_type = drive_type; d->interface = COOKED_IOCTL; d->bigendianp = -1; /* We don't know yet... */ d->nsectors = -1; @@ -185,28 +257,19 @@ cdda_identify_cooked(const char *dev, int messagedest, char **messages) cdio_hwinfo_t hw_info; if ( scsi_mmc_get_hwinfo( p_cdio, &hw_info ) ) { - d->drive_model=calloc(38,1); - snprintf(d->drive_model, 38, "%s %s %s", + d->drive_model=calloc(36,1); + snprintf(d->drive_model, 36, "%s%s%s ", hw_info.psz_vendor, hw_info.psz_model, hw_info.psz_revision ); + catstring(d->drive_model, description); idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n", d->drive_model); + if (description) free(description); } } return(d); } -struct sg_id { - long l1; /* target | lun << 8 | channel << 16 | low_ino << 24 */ - long l2; /* Unique id */ -} sg_id; - -typedef struct scsiid{ - int bus; - int id; - int lun; -} scsiid; - #ifdef CDDA_TEST cdrom_drive_t *cdda_identify_test(const char *filename, int messagedest,