annotate libmpdemux/vcd_read.h @ 7428:29cce5d75dca

updated version (from ftp/incoming)
author arpi
date Tue, 17 Sep 2002 16:11:50 +0000
parents 1394aebaa838
children d862231858d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 //=================== VideoCD ==========================
2089
d7920c8257e2 BSD/OS support
arpi
parents: 1973
diff changeset
2 #if defined(linux) || defined(sun) || defined(__bsdi__)
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
3
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
4 #if defined(linux)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
5 #include <linux/cdrom.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
6 #elif defined(sun)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
7 #include <sys/cdio.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
8 static int sun_vcd_read(int, int*);
2089
d7920c8257e2 BSD/OS support
arpi
parents: 1973
diff changeset
9 #elif defined(__bsdi__)
d7920c8257e2 BSD/OS support
arpi
parents: 1973
diff changeset
10 #include <dvd.h>
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
11 #endif
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
12
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
13
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 static struct cdrom_tocentry vcd_entry;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
16 static inline void vcd_set_msf(unsigned int sect){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 vcd_entry.cdte_addr.msf.frame=sect%75;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 sect=sect/75;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 vcd_entry.cdte_addr.msf.second=sect%60;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 sect=sect/60;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 vcd_entry.cdte_addr.msf.minute=sect;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
24 static inline unsigned int vcd_get_msf(){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 return vcd_entry.cdte_addr.msf.frame +
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 (vcd_entry.cdte_addr.msf.second+
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 vcd_entry.cdte_addr.msf.minute*60)*75;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 int vcd_seek_to_track(int fd,int track){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 vcd_entry.cdte_format = CDROM_MSF;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 vcd_entry.cdte_track = track;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 if (ioctl(fd, CDROMREADTOCENTRY, &vcd_entry)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 perror("ioctl dif1");
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
35 return -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 }
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
37 return VCD_SECTOR_DATA*vcd_get_msf();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39
598
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
40 int vcd_get_track_end(int fd,int track){
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
41 struct cdrom_tochdr tochdr;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
42 if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1)
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
43 { perror("read CDROM toc header: "); return -1; }
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
44 vcd_entry.cdte_format = CDROM_MSF;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
45 vcd_entry.cdte_track = track<tochdr.cdth_trk1?(track+1):CDROM_LEADOUT;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
46 if (ioctl(fd, CDROMREADTOCENTRY, &vcd_entry)) {
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
47 perror("ioctl dif2");
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
48 return -1;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
49 }
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
50 return VCD_SECTOR_DATA*vcd_get_msf();
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
51 }
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
52
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 void vcd_read_toc(int fd){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 struct cdrom_tochdr tochdr;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 { perror("read CDROM toc header: "); return; }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 for (i=tochdr.cdth_trk0 ; i<=tochdr.cdth_trk1 ; i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 struct cdrom_tocentry tocentry;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 tocentry.cdte_track = i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 tocentry.cdte_format = CDROM_MSF;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 if (ioctl(fd,CDROMREADTOCENTRY,&tocentry)==-1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 { perror("read CDROM toc entry: "); return; }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1105
diff changeset
67 mp_msg(MSGT_OPEN,MSGL_INFO,"track %02d: adr=%d ctrl=%d format=%d %02d:%02d:%02d mode: %d\n",
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 (int)tocentry.cdte_track,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 (int)tocentry.cdte_adr,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 (int)tocentry.cdte_ctrl,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 (int)tocentry.cdte_format,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 (int)tocentry.cdte_addr.msf.minute,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 (int)tocentry.cdte_addr.msf.second,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 (int)tocentry.cdte_addr.msf.frame,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 (int)tocentry.cdte_datamode
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
80
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 static char vcd_buf[VCD_SECTOR_SIZE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 1
diff changeset
83 static int vcd_read(int fd,char *mem){
2089
d7920c8257e2 BSD/OS support
arpi
parents: 1973
diff changeset
84 #if defined(linux) || defined(__bsdi__)
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
85 memcpy(vcd_buf,&vcd_entry.cdte_addr.msf,sizeof(struct cdrom_msf));
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
86 if(ioctl(fd,CDROMREADRAW,vcd_buf)==-1) return 0; // EOF?
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
87 memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
88 #elif defined(sun)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
89 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
90 int offset;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
91 if (sun_vcd_read(fd, &offset) <= 0) return 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
92 memcpy(mem,&vcd_buf[offset],VCD_SECTOR_DATA);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
93 }
1020
72cacd3b8f30 Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents: 598
diff changeset
94 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
96 vcd_entry.cdte_addr.msf.frame++;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
97 if (vcd_entry.cdte_addr.msf.frame==75){
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
98 vcd_entry.cdte_addr.msf.frame=0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
99 vcd_entry.cdte_addr.msf.second++;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
100 if (vcd_entry.cdte_addr.msf.second==60){
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
101 vcd_entry.cdte_addr.msf.second=0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
102 vcd_entry.cdte_addr.msf.minute++;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
103 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
104 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
105
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
106 return VCD_SECTOR_DATA;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
107 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
108
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
109
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
110 #ifdef sun
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
111 #include <sys/scsi/generic/commands.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
112 #include <sys/scsi/impl/uscsi.h>
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
113
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
114 #define SUN_XAREAD 1 /*fails on atapi drives*/
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
115 #define SUN_MODE2READ 2 /*fails on atapi drives*/
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
116 #define SUN_SCSIREAD 3
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
117 #define SUN_VCDREAD SUN_SCSIREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
118
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
119 static int sun_vcd_read(int fd, int *offset)
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
120 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
121 #if SUN_VCDREAD == SUN_XAREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
122 struct cdrom_cdxa cdxa;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
123 cdxa.cdxa_addr = vcd_get_msf();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
124 cdxa.cdxa_length = 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
125 cdxa.cdxa_data = vcd_buf;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
126 cdxa.cdxa_format = CDROM_XA_SECTOR_DATA;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
127
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
128 if(ioctl(fd,CDROMCDXA,&cdxa)==-1) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
129 perror("CDROMCDXA");
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
130 return 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
131 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
132 *offset = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
133 #elif SUN_VCDREAD == SUN_MODE2READ
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
134 struct cdrom_read cdread;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
135 cdread.cdread_lba = 4*vcd_get_msf();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
136 cdread.cdread_bufaddr = vcd_buf;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
137 cdread.cdread_buflen = 2336;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
139 if(ioctl(fd,CDROMREADMODE2,&cdread)==-1) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
140 perror("CDROMREADMODE2");
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
141 return 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
142 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
143 *offset = 8;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
144 #elif SUN_VCDREAD == SUN_SCSIREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
145 struct uscsi_cmd sc;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
146 union scsi_cdb cdb;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
147 int lba = vcd_get_msf();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
148 int blocks = 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
149 int sector_type;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
150 int sync, header_code, user_data, edc_ecc, error_field;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
151 int sub_channel;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
152
1105
6121410e667f Remove compiler warning.
atmosfear
parents: 1061
diff changeset
153 /* sector_type = 3; *//* mode2 */
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
154 sector_type = 5; /* mode2/form2 */
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
155 sync = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
156 header_code = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
157 user_data = 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
158 edc_ecc = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
159 error_field = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
160 sub_channel = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
161
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
162 memset(&cdb, 0, sizeof(cdb));
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
163 memset(&sc, 0, sizeof(sc));
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
164 cdb.scc_cmd = 0xBE;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
165 cdb.cdb_opaque[1] = (sector_type) << 2;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
166 cdb.cdb_opaque[2] = (lba >> 24) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
167 cdb.cdb_opaque[3] = (lba >> 16) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
168 cdb.cdb_opaque[4] = (lba >> 8) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
169 cdb.cdb_opaque[5] = lba & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
170 cdb.cdb_opaque[6] = (blocks >> 16) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
171 cdb.cdb_opaque[7] = (blocks >> 8) & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
172 cdb.cdb_opaque[8] = blocks & 0xff;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
173 cdb.cdb_opaque[9] = (sync << 7) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
174 (header_code << 5) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
175 (user_data << 4) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
176 (edc_ecc << 3) |
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
177 (error_field << 1);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
178 cdb.cdb_opaque[10] = sub_channel;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
179
1061
0f7be115a4db patch by J¸«ärgen Keil
arpi_esp
parents: 1038
diff changeset
180 sc.uscsi_cdb = (caddr_t)&cdb;
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
181 sc.uscsi_cdblen = 12;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
182 sc.uscsi_bufaddr = vcd_buf;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
183 sc.uscsi_buflen = 2336;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
184 sc.uscsi_flags = USCSI_ISOLATE | USCSI_READ;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
185 sc.uscsi_timeout = 20;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
186 if (ioctl(fd, USCSICMD, &sc)) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
187 perror("USCSICMD: READ CD");
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
188 return -1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
189 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
190 if (sc.uscsi_status) {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
191 fprintf(stderr, "scsi command failed with status %d\n", sc.uscsi_status);
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
192 return -1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
193 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
194 *offset = 0;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
195 return 1;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
196 #else
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
197 #error SUN_VCDREAD
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
198 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 }
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
200 #endif /*sun*/
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
201
3261
caac174877b7 using #ifdef HAVE_VCD
arpi
parents: 2450
diff changeset
202 #else /* linux || sun || __bsdi__ */
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
203
3261
caac174877b7 using #ifdef HAVE_VCD
arpi
parents: 2450
diff changeset
204 #error vcd is not yet supported on this arch...
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
205
3261
caac174877b7 using #ifdef HAVE_VCD
arpi
parents: 2450
diff changeset
206 #endif