refinements/compat fixes to fisrt-stage cache/timing tests
[xiph/unicode.git] / cdparanoia / interface / low_interface.h
blob76981fe7a516f5388bd717f08b9019afdb25b10f
1 /******************************************************************
2 * CopyPolicy: GNU Lesser General Public License 2.1 applies
3 * Copyright (C) 1998-2008 Monty xiphmont@mit.edu
4 *
5 * internal include file for cdda interface kit for Linux
7 ******************************************************************/
9 #ifndef _cdda_low_interface_
10 #define _cdda_low_interface_
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <unistd.h>
16 #include <string.h>
17 #include <errno.h>
18 #include <fcntl.h>
19 #include <time.h>
21 #include <sys/ioctl.h>
22 #include <sys/stat.h>
23 #include <sys/ipc.h>
24 #include <sys/sem.h>
25 #include <sys/shm.h>
26 #include <sys/time.h>
27 #include <sys/types.h>
29 #include <linux/major.h>
30 #include <linux/version.h>
32 /* some include file locations have changed with newer kernels */
34 #ifdef SBPCD_H
35 #include <linux/sbpcd.h>
36 #endif
38 #ifdef UCDROM_H
39 #include <linux/ucdrom.h>
40 #endif
42 #ifndef CDROMAUDIOBUFSIZ
43 #define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
44 #endif
46 #ifndef CDROM_GET_CAPABILITY
47 #define CDROM_GET_CAPABILITY 0x5331 /* get CDROM capabilites if CDROM */
48 #endif
51 #include <scsi/sg.h>
52 #include <scsi/scsi.h>
54 #include <linux/cdrom.h>
55 #include <linux/major.h>
57 #include "cdda_interface.h"
59 #ifndef SG_EMULATED_HOST
60 /* old kernel version; the check for the ioctl is still runtime, this
61 is just to build */
62 #define SG_EMULATED_HOST 0x2203
63 #define SG_SET_TRANSFORM 0x2204
64 #define SG_GET_TRANSFORM 0x2205
65 #endif
67 #ifndef SG_IO
68 /* old kernel version; the usage is all runtime-safe, this is just to
69 build */
70 typedef struct sg_io_hdr
72 int interface_id; /* [i] 'S' for SCSI generic (required) */
73 int dxfer_direction; /* [i] data transfer direction */
74 unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
75 unsigned char mx_sb_len; /* [i] max length to write to sbp */
76 unsigned short int iovec_count; /* [i] 0 implies no scatter gather */
77 unsigned int dxfer_len; /* [i] byte count of data transfer */
78 void * dxferp; /* [i], [*io] points to data transfer memory
79 or scatter gather list */
80 unsigned char * cmdp; /* [i], [*i] points to command to perform */
81 unsigned char * sbp; /* [i], [*o] points to sense_buffer memory */
82 unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
83 unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */
84 int pack_id; /* [i->o] unused internally (normally) */
85 void * usr_ptr; /* [i->o] unused internally */
86 unsigned char status; /* [o] scsi status */
87 unsigned char masked_status;/* [o] shifted, masked scsi status */
88 unsigned char msg_status; /* [o] messaging level data (optional) */
89 unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
90 unsigned short int host_status; /* [o] errors from host adapter */
91 unsigned short int driver_status;/* [o] errors from software driver */
92 int resid; /* [o] dxfer_len - actual_transferred */
93 unsigned int duration; /* [o] time taken by cmd (unit: millisec) */
94 unsigned int info; /* [o] auxiliary information */
95 } sg_io_hdr_t;
98 #endif
100 struct cdda_private_data {
101 struct sg_header *sg_hd;
102 unsigned char *sg_buffer; /* points into sg_hd */
103 clockid_t clock;
104 int last_milliseconds;
106 int (*cache_clear) (struct cdrom_drive *d, int lba, int sectors);
109 #define MAX_RETRIES 8
110 #define MAX_BIG_BUFF_SIZE 65536
111 #define MIN_BIG_BUFF_SIZE 4096
112 #define SG_OFF sizeof(struct sg_header)
114 extern int cooked_init_drive (cdrom_drive *d);
115 extern unsigned char *scsi_inquiry (cdrom_drive *d);
116 extern int scsi_init_drive (cdrom_drive *d);
117 #ifdef CDDA_TEST
118 extern int test_init_drive (cdrom_drive *d);
119 #endif
120 #endif