Changeset 4659a85f20c5e36b993ea5f1d55fab29672cedfc
- 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
| radcd116 |
r4659a85 |
|
| 1056 | 1056 | AC_EGREP_HEADER(cdrom_msf0,linux/cdrom.h,[ |
|---|
| 1057 | 1057 | 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) |
|---|
| 1058 | 1063 | ]) |
|---|
| 1059 | 1064 | |
|---|
| r63f553e |
r4659a85 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * 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 $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Johan Bilien <jobi@via.ecp.fr> |
|---|
| … | … | |
| 13 | 13 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 14 | 14 | * (at your option) any later version. |
|---|
| 15 | | * |
|---|
| | 15 | * |
|---|
| 16 | 16 | * This program is distributed in the hope that it will be useful, |
|---|
| 17 | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| … | … | |
| 54 | 54 | # include <IOKit/storage/IOCDMedia.h> |
|---|
| 55 | 55 | # 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> |
|---|
| 56 | 60 | #elif defined( HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H ) |
|---|
| 57 | 61 | # include <sys/cdio.h> |
|---|
| … | … | |
| 259 | 263 | continue; |
|---|
| 260 | 264 | |
|---|
| 261 | | (*pp_sectors)[i_tracks++] = |
|---|
| | 265 | (*pp_sectors)[i_tracks++] = |
|---|
| 262 | 266 | CDConvertMSFToLBA( pTrackDescriptors[i].p ); |
|---|
| 263 | 267 | } |
|---|
| … | … | |
| 272 | 276 | |
|---|
| 273 | 277 | /* set leadout sector */ |
|---|
| 274 | | (*pp_sectors)[i_tracks] = |
|---|
| | 278 | (*pp_sectors)[i_tracks] = |
|---|
| 275 | 279 | CDConvertMSFToLBA( pTrackDescriptors[i_leadout].p ); |
|---|
| 276 | 280 | } |
|---|
| … | … | |
| 430 | 434 | } |
|---|
| 431 | 435 | |
|---|
| 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 ) |
|---|
| 433 | 438 | struct ioc_toc_header tochdr; |
|---|
| 434 | 439 | struct ioc_read_toc_entry toc_entries; |
|---|
| … | … | |
| 457 | 462 | toc_entries.starting_track = 0; |
|---|
| 458 | 463 | toc_entries.data_len = ( i_tracks + 1 ) * |
|---|
| 459 | | sizeof( struct cd_toc_entry ); |
|---|
| | 464 | sizeof( struct cd_toc_entry ); |
|---|
| 460 | 465 | toc_entries.data = (struct cd_toc_entry *) |
|---|
| 461 | 466 | malloc( toc_entries.data_len ); |
|---|
| … | … | |
| 466 | 471 | return 0; |
|---|
| 467 | 472 | } |
|---|
| 468 | | |
|---|
| | 473 | |
|---|
| 469 | 474 | /* Read the TOC */ |
|---|
| 470 | 475 | if( ioctl( p_vcddev->i_device_handle, CDIOREADTOCENTRYS, |
|---|
| … | … | |
| 476 | 481 | return 0; |
|---|
| 477 | 482 | } |
|---|
| 478 | | |
|---|
| | 483 | |
|---|
| 479 | 484 | /* Fill the p_sectors structure with the track/sector matches */ |
|---|
| 480 | 485 | for( i = 0 ; i <= i_tracks ; i++ ) |
|---|
| 481 | 486 | { |
|---|
| | 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 |
|---|
| 482 | 491 | (*pp_sectors)[ i ] = ntohl( toc_entries.data[i].addr.lba ); |
|---|
| | 492 | #endif |
|---|
| 483 | 493 | } |
|---|
| 484 | 494 | } |
|---|
| … | … | |
| 676 | 686 | return -1; |
|---|
| 677 | 687 | } |
|---|
| 678 | | |
|---|
| | 688 | |
|---|
| 679 | 689 | /* We don't want to keep the header of the read sector */ |
|---|
| 680 | 690 | memcpy( p_buffer, p_block + VCD_DATA_START, VCD_DATA_SIZE ); |
|---|
| 681 | 691 | |
|---|
| 682 | 692 | 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; |
|---|
| 683 | 740 | } |
|---|
| 684 | 741 | |
|---|
| … | … | |
| 723 | 780 | #endif |
|---|
| 724 | 781 | |
|---|
| | 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 |
|---|
| 725 | 786 | /* We don't want to keep the header of the read sector */ |
|---|
| 726 | 787 | memcpy( p_buffer, p_block + VCD_DATA_START, VCD_DATA_SIZE ); |
|---|
| | 788 | #endif |
|---|
| 727 | 789 | |
|---|
| 728 | 790 | return( 0 ); |
|---|