/* cm206.h Header file for cm206.c.
   Copyright (c) 1995 David van Leeuwen 
*/

/* First, the cm260 stuff */
/* The ports and irq used. If it is not defined, make it variable, 
   and initialize them at some reasonable value */

#define CM206_BASE 0x340
#define CM206_IRQ 11

#define r_data_status (CM206_BASE)
#define r_uart_receive (CM206_BASE+0x2)
#define r_fifo_output_buffer (CM206_BASE+0x4)
#define r_line_status (CM206_BASE+0x6)
#define r_data_control (CM206_BASE+0x8)
#define r_uart_transmit (CM206_BASE+0xa)
#define r_test_clock (CM206_BASE+0xc)
#define r_test_control (CM206_BASE+0xe)

/* the data_status flags */
#define ds_ram_size 0x4000
#define ds_toc_ready 0x2000
#define ds_fifo_empty 0x1000
#define ds_sync_error 0x800
#define ds_crc_error 0x400
#define ds_data_error 0x200
#define ds_fifo_overflow 0x100
#define ds_data_ready 0x80

/* the line_status flags */
#define ls_attention 0x10
#define ls_parity_error 0x8
#define ls_overrun 0x4
#define ls_receive_buffer_full 0x2
#define ls_transmitter_buffer_empty 0x1

/* the data control register flags */
#define dc_read_q_channel 0x4000
#define dc_mask_sync_error 0x2000
#define dc_toc_enable 0x1000
#define dc_no_stop_on_error 0x800
#define dc_break 0x400
#define dc_initialize 0x200
#define dc_mask_transmit_ready 0x100
#define dc_flag_enable 0x80

#define dc_normal (dc_mask_sync_error | dc_no_stop_on_error | \
		   dc_mask_transmit_ready)

/* now some constants related to the cm206 */
/* another drive status byte, echoed by the cm206 on most commmands */

#define dsb_error_condition 0x1
#define dsb_play_in_progress 0x4
#define dsb_possible_media_change 0x8
#define dsb_disc_present 0x10
#define dsb_drive_not_ready 0x20
#define dsb_tray_locked 0x40
#define dsb_tray_not_closed 0x80

#define dsb_not_useful (dsb_drive_not_ready | dsb_tray_not_closed)

/* the cm206 command set */

#define c_close_tray 0
#define c_lock_tray 0x01
#define c_unlock_tray 0x04
#define c_open_tray 0x05
#define c_seek 0x10
#define c_read_data 0x20
#define c_force_1x 0x21
#define c_force_2x 0x22
#define c_auto_mode 0x23
#define c_play 0x30
#define c_set_audio_mode 0x31
#define c_read_current_q 0x41
#define c_stream_q 0x42
#define c_drive_status 0x50
#define c_disc_status 0x51
#define c_audio_status 0x52
#define c_drive_configuration 0x53
#define c_read_upc 0x60
#define c_stop 0x70
#define c_calc_checksum 0xe5

#define c_gimme 0xf8

/* finally, the (error) condition that the drive can be in      *
 * OK, this is not always an error, but let's prefix it with e_ */

#define e_none 0
#define e_illegal_command 0x01
#define e_sync 0x02
#define e_seek 0x03
#define e_parity 0x04
#define e_focus 0x05
#define e_header_sync 0x06
#define e_code_incompatibility 0x07
#define e_reset_done 0x08
#define e_bad_parameter 0x09
#define e_radial 0x0a
#define e_sub_code 0x0b
#define e_no_data_track 0x0c
#define e_scan 0x0d
#define e_tray_open 0x0f
#define e_no_disc 0x10
#define e_tray stalled 0x11

/* drive configuration masks */

#define dcf_revision_code 0x7
#define dcf_transfer_rate 0x60
#define dcf_motorized_tray 0x80

/* disc status byte */

#define cds_multi_session 0x2
#define cds_all_audio 0x8
#define cds_xa_mode 0xf0

/* finally some ioctls for the driver */

#define CM206CTL_GET_STAT 0x2000
#define CM206CTL_GET_LAST_STAT 0x2001
#define CM206_RESET_DRIVE 0x2002 /* use with care */
