sjcd.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Definitions for a Sanyo CD-ROM interface.
  3. *
  4. * Copyright (C) 1995 Vadim V. Model
  5. * model@cecmow.enet.dec.com
  6. * vadim@rbrf.msk.su
  7. * vadim@ipsun.ras.ru
  8. * Eric van der Maarel
  9. * H.T.M.v.d.Maarel@marin.nl
  10. *
  11. * This information is based on mcd.c from M. Harriss and sjcd102.lst from
  12. * E. Moenkeberg.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */
  28. #ifndef __SJCD_H__
  29. #define __SJCD_H__
  30. /*
  31. * Change this to set the I/O port address as default. More flexibility
  32. * come with setup implementation.
  33. */
  34. #define SJCD_BASE_ADDR 0x340
  35. /*
  36. * Change this to set the irq as default. Really SANYO do not use interrupts
  37. * at all.
  38. */
  39. #define SJCD_INTR_NR 0
  40. /*
  41. * Change this to set the dma as default value. really SANYO does not use
  42. * direct memory access at all.
  43. */
  44. #define SJCD_DMA_NR 0
  45. /*
  46. * Macros which allow us to find out the status of the drive.
  47. */
  48. #define SJCD_STATUS_AVAILABLE( x ) (((x)&0x02)==0)
  49. #define SJCD_DATA_AVAILABLE( x ) (((x)&0x01)==0)
  50. /*
  51. * Port access macro. Three ports are available: S-data port (command port),
  52. * status port (read only) and D-data port (read only).
  53. */
  54. #define SJCDPORT( x ) ( sjcd_base + ( x ) )
  55. #define SJCD_STATUS_PORT SJCDPORT( 1 )
  56. #define SJCD_S_DATA_PORT SJCDPORT( 0 )
  57. #define SJCD_COMMAND_PORT SJCDPORT( 0 )
  58. #define SJCD_D_DATA_PORT SJCDPORT( 2 )
  59. /*
  60. * Drive info bits. Drive info available as first (mandatory) byte of
  61. * command completion status.
  62. */
  63. #define SST_NOT_READY 0x10 /* no disk in the drive (???) */
  64. #define SST_MEDIA_CHANGED 0x20 /* disk is changed */
  65. #define SST_DOOR_OPENED 0x40 /* door is open */
  66. /* commands */
  67. #define SCMD_EJECT_TRAY 0xD0 /* eject tray if not locked */
  68. #define SCMD_LOCK_TRAY 0xD2 /* lock tray when in */
  69. #define SCMD_UNLOCK_TRAY 0xD4 /* unlock tray when in */
  70. #define SCMD_CLOSE_TRAY 0xD6 /* load tray in */
  71. #define SCMD_RESET 0xFA /* soft reset */
  72. #define SCMD_GET_STATUS 0x80
  73. #define SCMD_GET_VERSION 0xCC
  74. #define SCMD_DATA_READ 0xA0 /* are the same, depend on mode&args */
  75. #define SCMD_SEEK 0xA0
  76. #define SCMD_PLAY 0xA0
  77. #define SCMD_GET_QINFO 0xA8
  78. #define SCMD_SET_MODE 0xC4
  79. #define SCMD_MODE_PLAY 0xE0
  80. #define SCMD_MODE_COOKED (0xF8 & ~0x20)
  81. #define SCMD_MODE_RAW 0xF9
  82. #define SCMD_MODE_x20_BIT 0x20 /* What is it for ? */
  83. #define SCMD_SET_VOLUME 0xAE
  84. #define SCMD_PAUSE 0xE0
  85. #define SCMD_STOP 0xE0
  86. #define SCMD_GET_DISK_INFO 0xAA
  87. /*
  88. * Some standard arguments for SCMD_GET_DISK_INFO.
  89. */
  90. #define SCMD_GET_1_TRACK 0xA0 /* get the first track information */
  91. #define SCMD_GET_L_TRACK 0xA1 /* get the last track information */
  92. #define SCMD_GET_D_SIZE 0xA2 /* get the whole disk information */
  93. /*
  94. * Borrowed from hd.c. Allows to optimize multiple port read commands.
  95. */
  96. #define S_READ_DATA( port, buf, nr ) insb( port, buf, nr )
  97. /*
  98. * We assume that there are no audio disks with TOC length more than this
  99. * number (I personally have never seen disks with more than 20 fragments).
  100. */
  101. #define SJCD_MAX_TRACKS 100
  102. struct msf {
  103. unsigned char min;
  104. unsigned char sec;
  105. unsigned char frame;
  106. };
  107. struct sjcd_hw_disk_info {
  108. unsigned char track_control;
  109. unsigned char track_no;
  110. unsigned char x, y, z;
  111. union {
  112. unsigned char track_no;
  113. struct msf track_msf;
  114. } un;
  115. };
  116. struct sjcd_hw_qinfo {
  117. unsigned char track_control;
  118. unsigned char track_no;
  119. unsigned char x;
  120. struct msf rel;
  121. struct msf abs;
  122. };
  123. struct sjcd_play_msf {
  124. struct msf start;
  125. struct msf end;
  126. };
  127. struct sjcd_disk_info {
  128. unsigned char first;
  129. unsigned char last;
  130. struct msf disk_length;
  131. struct msf first_track;
  132. };
  133. struct sjcd_toc {
  134. unsigned char ctrl_addr;
  135. unsigned char track;
  136. unsigned char point_index;
  137. struct msf track_time;
  138. struct msf disk_time;
  139. };
  140. #if defined( SJCD_GATHER_STAT )
  141. struct sjcd_stat {
  142. int ticks;
  143. int tticks[ 8 ];
  144. int idle_ticks;
  145. int start_ticks;
  146. int mode_ticks;
  147. int read_ticks;
  148. int data_ticks;
  149. int stop_ticks;
  150. int stopping_ticks;
  151. };
  152. #endif
  153. #endif