Changeset 4659a85f20c5e36b993ea5f1d55fab29672cedfc

Show
Ignore:
Timestamp:
02/12/02 19:19:43 (6 years ago)
Author:
Sam Hocevar <sam@videolan.org>
git-committer:
Sam Hocevar <sam@videolan.org> 1038853183 +0000
git-parent:

[adcd116073483c0a2671a8483e0c259dee9bf307]

git-author:
Sam Hocevar <sam@videolan.org> 1038853183 +0000
Message:
  • ./modules/access/vcd/cdrom.c: NetBSD VCD input fixes, courtesy of
    Olaf 'Rhialto' Seibert.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac.in

    radcd116 r4659a85  
    10561056  AC_EGREP_HEADER(cdrom_msf0,linux/cdrom.h,[ 
    10571057    PLUGINS="${PLUGINS} vcd" 
     1058  ]) 
     1059 
     1060  AC_EGREP_HEADER(scsireq,sys/scsiio.h,[ 
     1061    PLUGINS="${PLUGINS} vcd" 
     1062    AC_DEFINE(HAVE_SCSIREQ_IN_SYS_SCSIIO_H, 1, For NetBSD VCD support) 
    10581063  ]) 
    10591064 
  • modules/access/vcd/cdrom.c

    r63f553e r4659a85  
    33 ***************************************************************************** 
    44 * Copyright (C) 1998-2001 VideoLAN 
    5  * $Id: cdrom.c,v 1.5 2002/10/16 23:12:46 massiot Exp $ 
     5 * $Id: cdrom.c,v 1.6 2002/12/02 18:19:43 sam Exp $ 
    66 * 
    77 * Authors: Johan Bilien <jobi@via.ecp.fr> 
     
    1313 * the Free Software Foundation; either version 2 of the License, or 
    1414 * (at your option) any later version. 
    15  *  
     15 * 
    1616 * This program is distributed in the hope that it will be useful, 
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     
    5454#   include <IOKit/storage/IOCDMedia.h> 
    5555#   include <IOKit/storage/IOCDMediaBSDClient.h> 
     56#elif defined( HAVE_SCSIREQ_IN_SYS_SCSIIO_H ) 
     57#   include <sys/inttypes.h> 
     58#   include <sys/cdio.h> 
     59#   include <sys/scsiio.h> 
    5660#elif defined( HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H ) 
    5761#   include <sys/cdio.h> 
     
    259263                    continue; 
    260264 
    261                 (*pp_sectors)[i_tracks++] =  
     265                (*pp_sectors)[i_tracks++] = 
    262266                    CDConvertMSFToLBA( pTrackDescriptors[i].p ); 
    263267            } 
     
    272276 
    273277            /* set leadout sector */ 
    274             (*pp_sectors)[i_tracks] =  
     278            (*pp_sectors)[i_tracks] = 
    275279                CDConvertMSFToLBA( pTrackDescriptors[i_leadout].p ); 
    276280        } 
     
    430434        } 
    431435 
    432 #elif defined( HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H ) 
     436#elif defined( HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H ) \ 
     437       || defined( HAVE_SCSIREQ_IN_SYS_SCSIIO_H ) 
    433438        struct ioc_toc_header tochdr; 
    434439        struct ioc_read_toc_entry toc_entries; 
     
    457462             toc_entries.starting_track = 0; 
    458463             toc_entries.data_len = ( i_tracks + 1 ) * 
    459                                         sizeof( struct cd_toc_entry );  
     464                                        sizeof( struct cd_toc_entry ); 
    460465             toc_entries.data = (struct cd_toc_entry *) 
    461466                                    malloc( toc_entries.data_len ); 
     
    466471                 return 0; 
    467472             } 
    468   
     473 
    469474             /* Read the TOC */ 
    470475             if( ioctl( p_vcddev->i_device_handle, CDIOREADTOCENTRYS, 
     
    476481                 return 0; 
    477482             } 
    478      
     483 
    479484             /* Fill the p_sectors structure with the track/sector matches */ 
    480485             for( i = 0 ; i <= i_tracks ; i++ ) 
    481486             { 
     487#if defined( HAVE_SCSIREQ_IN_SYS_SCSIIO_H ) 
     488                 /* FIXME: is this ok? */ 
     489                 (*pp_sectors)[ i ] = toc_entries.data[i].addr.lba; 
     490#else 
    482491                 (*pp_sectors)[ i ] = ntohl( toc_entries.data[i].addr.lba ); 
     492#endif 
    483493             } 
    484494        } 
     
    676686                return -1; 
    677687            } 
    678   
     688 
    679689            /* We don't want to keep the header of the read sector */ 
    680690            memcpy( p_buffer, p_block + VCD_DATA_START, VCD_DATA_SIZE ); 
    681691 
    682692            return 0; 
     693        } 
     694 
     695#elif defined( HAVE_SCSIREQ_IN_SYS_SCSIIO_H ) 
     696        struct scsireq  sc; 
     697 
     698        int i_blocks = 1; 
     699        int i_ret; 
     700 
     701        int sector_type = 5; /* mode2/form2 */ 
     702        int sync = 0, 
     703            header_code = 0, 
     704            user_data = 1, 
     705            edc_ecc = 0, 
     706            error_field = 0; 
     707        int sub_channel = 0; 
     708 
     709        memset( &sc, 0, sizeof(sc) ); 
     710        sc.cmd[0] = 0xBE; 
     711        sc.cmd[1] = (sector_type) << 2; 
     712        sc.cmd[2] = (i_sector >> 24) & 0xff; 
     713        sc.cmd[3] = (i_sector >> 16) & 0xff; 
     714        sc.cmd[4] = (i_sector >>  8) & 0xff; 
     715        sc.cmd[5] = (i_sector >>  0) & 0xff; 
     716        sc.cmd[6] = (i_blocks >> 16) & 0xff; 
     717        sc.cmd[7] = (i_blocks >>  8) & 0xff; 
     718        sc.cmd[8] = (i_blocks >>  0) & 0xff; 
     719        sc.cmd[9] = (sync << 7) | (header_code << 5) | (user_data << 4) | 
     720                    (edc_ecc << 3) | (error_field << 1); 
     721        sc.cmd[10] = sub_channel; 
     722        sc.cmdlen = 12; 
     723        sc.databuf = (caddr_t)p_block; 
     724        sc.datalen = VCD_SECTOR_SIZE;      // was 2328 == VCD_DATA_SIZE + 4; 
     725        sc.senselen = sizeof( sc.sense ); 
     726        sc.flags = SCCMD_READ; 
     727        sc.timeout = 10000; 
     728 
     729        i_ret = ioctl( i_fd, SCIOCCOMMAND, &sc ); 
     730        if( i_ret == -1 ) 
     731        { 
     732            msg_Err( p_this, "SCIOCCOMMAND failed" ); 
     733            return -1; 
     734        } 
     735        if( sc.retsts || sc.error ) 
     736        { 
     737            msg_Err( p_this, "SCSI command failed: status %d error %d\n", 
     738                             sc.retsts, sc.error ); 
     739           return -1; 
    683740        } 
    684741 
     
    723780#endif 
    724781 
     782#if defined( HAVE_SCSIREQ_IN_SYS_SCSIIO_H ) 
     783        /* FIXME: is this ok? */ 
     784        memcpy( p_buffer, p_block, VCD_DATA_SIZE ); 
     785#else 
    725786        /* We don't want to keep the header of the read sector */ 
    726787        memcpy( p_buffer, p_block + VCD_DATA_START, VCD_DATA_SIZE ); 
     788#endif 
    727789 
    728790        return( 0 );