root/include/linux/sbpcd.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * sbpcd.h   Specify interface address and interface type here.
   3  */
   4 
   5 /*
   6  * these definitions can get overridden by the kernel command line
   7  * ("lilo boot option"). Examples:
   8  *                                 sbpcd=0x230,SoundBlaster
   9  *                             or
  10  *                                 sbpcd=0x300,LaserMate
  11  * these strings are case sensitive !!!
  12  */
  13 
  14 /* 
  15  * change this to select the type of your interface board:
  16  *
  17  * set SBPRO to 1 for "true" SoundBlaster card
  18  * set SBPRO to 0 for "poor" (no sound) interface cards
  19  *                and for "compatible" soundcards.
  20  *
  21  * most "compatible" sound boards like Galaxy need to set SBPRO to 0 !!!
  22  * if SBPRO gets set wrong, the drive will get found - but any
  23  * data access will give errors (audio access will work).
  24  * The OmniCD interface card from CreativeLabs needs SBPRO 1.
  25  *
  26  * mail to emoenke@gwdg.de if your "compatible" card needs SBPRO 1
  27  * (currently I do not know any "compatible" with SBPRO 1)
  28  * then I can include better information with the next release.
  29  */
  30 #define SBPRO     1
  31 
  32 /*
  33  * put your CDROM port base address here:
  34  * SBPRO addresses typically are 0x0230 (=0x220+0x10), 0x0250, ...
  35  * LASERMATE (CI-101P) adresses typically are 0x0300, 0x0310, ...
  36  * there are some soundcards on the market with 0x0630, 0x0650, ...
  37  *
  38  * obey! changed against v0.4 !!!
  39  * for SBPRO cards, specify the CDROM address - no longer the audio address! 
  40  * example: if your SBPRO audio address is 0x220, specify 0x230.
  41  *
  42  * a fill-in is not always necessary - the driver does auto-probing now,
  43  * with the here specified address first...
  44  */
  45 #define CDROM_PORT 0x0230
  46 
  47 
  48 /*==========================================================================*/
  49 /*==========================================================================*/
  50 /*
  51  * nothing to change below here if you are not experimenting
  52  */
  53 /*==========================================================================*/
  54 /*==========================================================================*/
  55 /*
  56  * Debug output levels
  57  */
  58 #define DBG_INF         1       /* necessary information */
  59 #define DBG_IRQ         2       /* interrupt trace */
  60 #define DBG_REA         3       /* "read" status trace */
  61 #define DBG_CHK         4       /* "media check" trace */
  62 #define DBG_TIM         5       /* datarate timer test */
  63 #define DBG_INI         6       /* initialization trace */
  64 #define DBG_TOC         7       /* tell TocEntry values */
  65 #define DBG_IOC         8       /* ioctl trace */
  66 #define DBG_STA         9       /* "ResponseStatus" trace */
  67 #define DBG_ERR         10      /* "xx_ReadError" trace */
  68 #define DBG_CMD         11      /* "cmd_out" trace */
  69 #define DBG_WRN         12      /* give explanation before auto-probing */
  70 #define DBG_MUL         13      /* multi session code test */
  71 #define DBG_ID          14      /* "drive_id !=0" test code */
  72 #define DBG_IOX         15      /* some special information */
  73 #define DBG_DID         16      /* drive ID test */
  74 #define DBG_RES         17      /* drive reset info */
  75 #define DBG_SPI         18      /* SpinUp test */
  76 #define DBG_000         19      /* unnecessary information */
  77 
  78 /*==========================================================================*/
  79 /*==========================================================================*/
  80 
  81 /*
  82  * bits of flags_cmd_out:
  83  */
  84 #define f_respo3 0x100
  85 #define f_putcmd 0x80
  86 #define f_respo2 0x40
  87 #define f_lopsta 0x20
  88 #define f_getsta 0x10
  89 #define f_ResponseStatus 0x08
  90 #define f_obey_p_check 0x04
  91 #define f_bit1 0x02
  92 #define f_wait_if_busy 0x01
  93 
  94 /*
  95  * diskstate_flags:
  96  */
  97 #define upc_bit 0x40
  98 #define volume_bit 0x20
  99 #define toc_bit 0x10
 100 #define multisession_bit 0x08
 101 #define cd_size_bit 0x04
 102 #define subq_bit 0x02
 103 #define frame_size_bit 0x01
 104 
 105 /*
 106  * disk states (bits of diskstate_flags):
 107  */
 108 #define upc_valid (DS[d].diskstate_flags&upc_bit)
 109 #define volume_valid (DS[d].diskstate_flags&volume_bit)
 110 #define toc_valid (DS[d].diskstate_flags&toc_bit)
 111 #define multisession_valid (DS[d].diskstate_flags&multisession_bit)
 112 #define cd_size_valid (DS[d].diskstate_flags&cd_size_bit)
 113 #define subq_valid (DS[d].diskstate_flags&subq_bit)
 114 #define frame_size_valid (DS[d].diskstate_flags&frame_size_bit)
 115 
 116 
 117 /*
 118  * bits of the status_byte (result of xx_ReadStatus):
 119  */
 120 #define p_door_closed 0x80
 121 #define p_caddy_in 0x40
 122 #define p_spinning 0x20
 123 #define p_check 0x10
 124 #define p_busy_new 0x08
 125 #define p_door_locked 0x04
 126 #define p_bit_1 0x02
 127 #define p_disk_ok 0x01
 128 /*
 129  * "old" drives status result bits:
 130  */
 131 #define p_caddin_old 0x40
 132 #define p_success_old 0x08
 133 #define p_busy_old 0x04
 134 
 135 /*
 136  * used drive states:
 137  */
 138 #define st_door_closed (DS[d].status_byte&p_door_closed)
 139 #define st_caddy_in (DS[d].status_byte&p_caddy_in)
 140 #define st_spinning (DS[d].status_byte&p_spinning)
 141 #define st_check (DS[d].status_byte&p_check)
 142 #define st_busy (DS[d].status_byte&p_busy_new)
 143 #define st_door_locked (DS[d].status_byte&p_door_locked)
 144 #define st_diskok (DS[d].status_byte&p_disk_ok)
 145 
 146 /*
 147  * bits of the CDi_status register:
 148  */
 149 #define s_not_result_ready 0x04  /* 0: "result ready" */
 150 #define s_not_data_ready 0x02    /* 0: "data ready"   */
 151 #define s_attention 0x01         /* 1: "attention required" */
 152 /*
 153  * usable as:
 154  */
 155 #define DRV_ATTN               ((inb(CDi_status)&s_attention)!=0)
 156 #define DATA_READY             ((inb(CDi_status)&s_not_data_ready)==0)
 157 #define RESULT_READY           ((inb(CDi_status)&s_not_result_ready)==0)
 158 
 159 /*
 160  * drive types (firmware versions):
 161  */
 162 #define drv_199 0       /* <200 */
 163 #define drv_200 1       /* <201 */
 164 #define drv_201 2       /* <210 */
 165 #define drv_210 3       /* <211 */
 166 #define drv_211 4       /* <300 */
 167 #define drv_300 5       /* else */
 168 #define drv_099 0x10    /* new,  <100 */
 169 #define drv_100 0x11    /* new, >=100 */
 170 #define drv_new 0x10    /* all new drives have that bit set */
 171 #define drv_old 0x00    /*  */
 172 
 173 /*
 174  * drv_099 and drv_100 are the "new" drives
 175  */
 176 #define new_drive (DS[d].drv_type&0x10)
 177 
 178 /*
 179  * audio states:
 180  */
 181 #define audio_playing 2
 182 #define audio_pausing 1
 183 
 184 /*
 185  * drv_pattern, drv_options:
 186  */
 187 #define speed_auto 0x80
 188 #define speed_300 0x40
 189 #define speed_150 0x20
 190 #define sax_a 0x04
 191 #define sax_xn2 0x02
 192 #define sax_xn1 0x01
 193 
 194 /*
 195  * values of cmd_type (0 else):
 196  */
 197 #define cmd_type_READ_M1  0x01 /* "data mode 1": 2048 bytes per frame */
 198 #define cmd_type_READ_M2  0x02 /* "data mode 2": 12+2048+280 bytes per frame */
 199 #define cmd_type_READ_SC  0x04 /* "subchannel info": 96 bytes per frame */
 200 
 201 /*
 202  * sense byte: used only if new_drive
 203  *                  only during cmd 09 00 xx ah al 00 00
 204  *
 205  *          values: 00
 206  *                  82
 207  *                  xx from infobuf[0] after 85 00 00 00 00 00 00
 208  */
 209 
 210 
 211 #define CD_MINS                   75  /* minutes per CD                  */
 212 #define CD_SECS                   60  /* seconds per minutes             */
 213 #define CD_FRAMES                 75  /* frames per second               */
 214 #define CD_FRAMESIZE            2048  /* bytes per frame, data mode      */
 215 #define CD_FRAMESIZE_XA         2340  /* bytes per frame, "xa" mode      */
 216 #define CD_FRAMESIZE_RAW        2352  /* bytes per frame, "raw" mode     */
 217 #define CD_BLOCK_OFFSET          150  /* offset of first logical frame   */
 218 
 219 
 220 /* audio status (bin) */
 221 #define aud_00 0x00 /* Audio status byte not supported or not valid */
 222 #define audx11 0x0b /* Audio play operation in progress             */
 223 #define audx12 0x0c /* Audio play operation paused                  */
 224 #define audx13 0x0d /* Audio play operation successfully completed  */
 225 #define audx14 0x0e /* Audio play operation stopped due to error    */
 226 #define audx15 0x0f /* No current audio status to return            */
 227 
 228 /* audio status (bcd) */
 229 #define aud_11 0x11 /* Audio play operation in progress             */
 230 #define aud_12 0x12 /* Audio play operation paused                  */
 231 #define aud_13 0x13 /* Audio play operation successfully completed  */
 232 #define aud_14 0x14 /* Audio play operation stopped due to error    */
 233 #define aud_15 0x15 /* No current audio status to return            */
 234 
 235 /*============================================================================
 236 ==============================================================================
 237 
 238 COMMAND SET of "old" drives like CR-521, CR-522
 239                (the CR-562 family is different):
 240 
 241 No.     Command                        Code
 242 --------------------------------------------
 243 
 244 Drive Commands:
 245  1      Seek                            01      
 246  2      Read Data                       02
 247  3      Read XA-Data                    03
 248  4      Read Header                     04
 249  5      Spin Up                         05
 250  6      Spin Down                       06
 251  7      Diagnostic                      07
 252  8      Read UPC                        08
 253  9      Read ISRC                       09
 254 10      Play Audio                      0A
 255 11      Play Audio MSF                  0B
 256 12      Play Audio Track/Index          0C
 257 
 258 Status Commands:
 259 13      Read Status                     81      
 260 14      Read Error                      82
 261 15      Read Drive Version              83
 262 16      Mode Select                     84
 263 17      Mode Sense                      85
 264 18      Set XA Parameter                86
 265 19      Read XA Parameter               87
 266 20      Read Capacity                   88
 267 21      Read SUB_Q                      89
 268 22      Read Disc Code                  8A
 269 23      Read Disc Information           8B
 270 24      Read TOC                        8C
 271 25      Pause/Resume                    8D
 272 26      Read Packet                     8E
 273 27      Read Path Check                 00
 274  
 275  
 276 all numbers (lba, msf-bin, msf-bcd, counts) to transfer high byte first
 277 
 278 mnemo     7-byte command        #bytes response (r0...rn)
 279 ________ ____________________  ____ 
 280 
 281 Read Status:
 282 status:  81.                    (1)  one-byte command, gives the main
 283                                                           status byte
 284 Read Error:
 285 check1:  82 00 00 00 00 00 00.  (6)  r1: audio status
 286 
 287 Read Packet:
 288 check2:  8e xx 00 00 00 00 00. (xx)  gets xx bytes response, relating
 289                                         to commands 01 04 05 07 08 09
 290 
 291 Play Audio:
 292 play:    0a ll-bb-aa nn-nn-nn.  (0)  play audio, ll-bb-aa: starting block (lba),
 293                                                  nn-nn-nn: #blocks
 294 Play Audio MSF:
 295          0b mm-ss-ff mm-ss-ff   (0)  play audio from/to
 296 
 297 Play Audio Track/Index:
 298          0c ...
 299 
 300 Pause/Resume:
 301 pause:   8d pr 00 00 00 00 00.  (0)  pause (pr=00) 
 302                                      resume (pr=80) audio playing
 303 
 304 Mode Select:
 305          84 00 nn-nn ??-?? 00   (0)  nn-nn: 2048 or 2340
 306                                      possibly defines transfer size
 307 
 308 set_vol: 84 83 00 00 sw le 00.  (0)  sw(itch): lrxxxxxx (off=1)
 309                                      le(vel): min=0, max=FF, else half
 310                                      (firmware 2.11)
 311 
 312 Mode Sense:
 313 get_vol: 85 03 00 00 00 00 00.  (2)  tell current audio volume setting
 314 
 315 Read Disc Information:
 316 tocdesc: 8b 00 00 00 00 00 00.  (6)  read the toc descriptor ("msf-bin"-format)
 317 
 318 Read TOC:
 319 tocent:  8c fl nn 00 00 00 00.  (8)  read toc entry #nn
 320                                        (fl=0:"lba"-, =2:"msf-bin"-format)
 321 
 322 Read Capacity:
 323 capacit: 88 00 00 00 00 00 00.  (5)  "read CD-ROM capacity"
 324 
 325 
 326 Read Path Check:
 327 ping:    00 00 00 00 00 00 00.  (2)  r0=AA, r1=55
 328                                      ("ping" if the drive is connected)
 329 
 330 Read Drive Version:
 331 ident:   83 00 00 00 00 00 00. (12)  gives "MATSHITAn.nn" 
 332                                      (n.nn = 2.01, 2.11., 3.00, ...)
 333 
 334 Seek:
 335 seek:    01 00 ll-bb-aa 00 00.  (0)  
 336 seek:    01 02 mm-ss-ff 00 00.  (0)  
 337 
 338 Read Data:
 339 read:    02 xx-xx-xx nn-nn fl. (??)  read nn-nn blocks of 2048 bytes,
 340                                      starting at block xx-xx-xx  
 341                                      fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx
 342 
 343 Read XA-Data:
 344 read:    03 xx-xx-xx nn-nn fl. (??)  read nn-nn blocks of 2340 bytes, 
 345                                      starting at block xx-xx-xx  
 346                                      fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx
 347 
 348 Read SUB_Q:
 349          89 fl 00 00 00 00 00. (13)  r0: audio status, r4-r7: lba/msf, 
 350                                        fl=0: "lba", fl=2: "msf"
 351 
 352 Read Disc Code:
 353          8a 00 00 00 00 00 00. (14)  possibly extended "check condition"-info
 354 
 355 Read Header:
 356          04 00 ll-bb-aa 00 00.  (0)   4 bytes response with "check2"
 357          04 02 mm-ss-ff 00 00.  (0)   4 bytes response with "check2"
 358 
 359 Spin Up:
 360          05 00 ll-bb-aa 00 00.  (0)  possibly implies a "seek"
 361 
 362 Spin Down:
 363          06 ...
 364 
 365 Diagnostic:
 366          07 00 ll-bb-aa 00 00.  (2)   2 bytes response with "check2"
 367          07 02 mm-ss-ff 00 00.  (2)   2 bytes response with "check2"
 368 
 369 Read UPC:
 370          08 00 ll-bb-aa 00 00. (16)  
 371          08 02 mm-ss-ff 00 00. (16)  
 372 
 373 Read ISRC:
 374          09 00 ll-bb-aa 00 00. (15)  15 bytes response with "check2"
 375          09 02 mm-ss-ff 00 00. (15)  15 bytes response with "check2"
 376 
 377 Set XA Parameter:
 378          86 ...
 379 
 380 Read XA Parameter:
 381          87 ...
 382 
 383 ==============================================================================
 384 ============================================================================*/
 385 
 386 /*==========================================================================*/
 387 /*==========================================================================*/
 388 
 389 /*
 390  * highest allowed drive number (MINOR+1)
 391  * currently only one controller, maybe later up to 4
 392  */
 393 #define NR_SBPCD 4
 394 
 395 /*
 396  * we try to never disable interrupts - seems to work
 397  */
 398 #define SBPCD_DIS_IRQ 0
 399 
 400 /*
 401  * we don't use the IRQ line - leave it free for the sound driver
 402  */
 403 #define SBPCD_USE_IRQ   0
 404 
 405 /*
 406  * you can set the interrupt number of your interface board here:
 407  * It is not used at this time. No need to set it correctly.
 408  */
 409 #define SBPCD_INTR_NR   7            
 410 
 411 /*
 412  * "write byte to port"
 413  */
 414 #define OUT(x,y) outb(y,x)
 415 
 416 
 417 #define MIXER_CD_Volume 0x28
 418 
 419 /*==========================================================================*/
 420 /*
 421  * use "REP INSB" for strobing the data in:
 422  */
 423 #if PATCHLEVEL<15
 424 #define READ_DATA(port, buf, nr) \
 425 __asm__("cld;rep;insb": :"d" (port),"D" (buf),"c" (nr):"cx","dx","di")
 426 #else
 427 #define READ_DATA(port, buf, nr) insb(port, buf, nr)
 428 #endif
 429 
 430 /*==========================================================================*/
 431 /*
 432  * to fork and execute a function after some elapsed time:
 433  * one "jifs" unit is 10 msec.
 434  */
 435 #define SET_TIMER(func, jifs) \
 436         ((timer_table[SBPCD_TIMER].expires = jiffies + jifs), \
 437         (timer_table[SBPCD_TIMER].fn = func), \
 438         (timer_active |= 1<<SBPCD_TIMER))
 439 
 440 #define CLEAR_TIMER     timer_active &= ~(1<<SBPCD_TIMER)
 441 
 442 /*==========================================================================*/
 443 /*
 444  * Creative Labs Programmers did this:
 445  */
 446 #define MAX_TRACKS      120 /* why more than 99? */
 447 
 448 
 449 /*==========================================================================*/
 450 /*
 451  * To make conversions easier (machine dependent!)
 452  */
 453 typedef union _msf
 454 {
 455   u_int n;
 456   u_char c[4];
 457 }
 458 MSF;
 459 
 460 typedef union _blk
 461 {
 462   u_int n;
 463   u_char c[4];
 464 }
 465 BLK;
 466 
 467 /*==========================================================================*/
 468 
 469 
 470 
 471 
 472 
 473 

/* [previous][next][first][last][top][bottom][index][help] */