/*
 * Copyright 1988, 1989, 1990, 1991 Massachusetts Institute of Technology
 */


/* pioneer.h */

/* header file for PIONEER LD-V4200 videodisc driver */

/* 
	Russell Sasnett
	GTE Laboratories / MIT Project Athena
	russ@athena.mit.edu
	4/2/90
*/

#ifndef	PIONEER_H
#define	PIONEER_H

/*
	for the pioneer, all commands taking arguments are
	preceded by the argument (postfix notation);
	like, 7000SE means to search to frame 7000

	most responses are simply the character 'R' followed
	by a carriage return

	upper/lower case is usually not significant
*/

/* following are ids which serve as an index into the command
	table declared static to pioneer.c */

#define PIONEER_CLEAR_CMD	0

#define PIONEER_DOOR_OPEN_CMD	1
#define PIONEER_REJECT_CMD	2
#define PIONEER_START_CMD	3

#define PIONEER_PLAY_CMD	4
#define PIONEER_PAUSE_CMD	5
#define PIONEER_STILL_CMD	6

#define PIONEER_STEP_FWD_CMD	7
#define PIONEER_STEP_REV_CMD	8

#define PIONEER_SCAN_FWD_CMD	9
#define PIONEER_SCAN_REV_CMD	10

#define PIONEER_MULTI_FWD_CMD	11
#define PIONEER_MULTI_REV_CMD	12

#define PIONEER_SPEED_CMD	13
#define PIONEER_SEARCH_CMD	14
#define PIONEER_STOP_MARKER_CMD	15

#define PIONEER_FRAME_MODE_CMD	16
#define PIONEER_TIME_MODE_CMD	17
#define PIONEER_CHAPTER_MODE_CMD 18

#define PIONEER_AUDIO_CONTROL_CMD 19
#define PIONEER_VIDEO_CONTROL_CMD 20

#define PIONEER_FRAME_NO_CMD 	21
#define PIONEER_TIME_NO_CMD	22
#define PIONEER_CHAPTER_NO_CMD	23

#define PIONEER_MODEL_CMD	24
#define PIONEER_PLAYER_STATUS_CMD 25
#define PIONEER_DISC_STATUS_CMD	26
#define PIONEER_COMM_STATUS_CMD 27

#define PIONEER_KEY_LOCK_CMD	28
#define PIONEER_COMM_MODE_CMD 	29

#define PIONEER_REG_A_CMD	30
#define PIONEER_REG_B_CMD	31
#define PIONEER_REG_C_CMD	32

#define PIONEER_DISPLAY_CONTROL_CMD 	33
#define PIONEER_CLEAR_SCREEN_CMD	34
#define PIONEER_PRINT_STRING_CMD	35

#define PIONEER_MULTI_FWD_NO_ADDR_CMD 36
#define PIONEER_MULTI_REV_NO_ADDR_CMD 37
#define PIONEER_PLAY_NO_ADDR_CMD 38

#define PIONEER_FIND_LAST_ADDR_CMD 39


/* ----------------------- */

/* speed argument macros */

#define PIONEER_fps_to_speed_arg(f) ( (f) * 2 )
#define PIONEER_speed_arg_to_fps(s) ( (s) / 2 )

/* args for audio control cmd */

#define PIONEER_NO_AUDIO	0
#define PIONEER_CH1_ON		1
#define PIONEER_CH2_ON		2
#define PIONEER_STEREO		3

/* masks (for driver) */

#define PIONEER_CH1_MASK	0x01
#define PIONEER_CH2_MASK	0x02

/* args for video control cmd */

#define PIONEER_VIDEO_SQUELCH	0
#define PIONEER_VIDEO_NOSQUELCH	1

/* args for comm_mode cmd */

#define PIONEER_CR_LF_MODE	0x02
#define PIONEER_CR_MODE		0x03	/* the default */

/* args for key lock cmd */

#define PIONEER_UNLOCK	0
#define PIONEER_LOCK	1

/* args for register A, which controls char gen */

/* masks (for driver) */

#define PIONEER_DPY_FRAME	0x01
#define PIONEER_DPY_CHAP	0x02
#define PIONEER_DPY_USER	0x04

/* absolute args (not masks) */

#define PIONEER_DPY_NONE	0x00
#define PIONEER_DPY_ALL		0x07

/* args for register B, which controls default A/V squelch */

/* masks (for driver) */

#define PIONEER_AUDIO_SQUELCH_OFF	0x40
#define PIONEER_VIDEO_SQUELCH_OFF	0x80

/* absolute args */

#define PIONEER_AV_SQUELCH_ON		0x00
#define PIONEER_AV_SQUELCH_OFF		0xc0

/* args for register C, which overrides general setup parameters
	set by the front-panel DIP switches */

/* masks (for driver) */

#define PIONEER_SIDE_REPEAT	0x01
#define PIONEER_LOAD_START	0x02
#define PIONEER_POWER_START	0x04
#define PIONEER_RESERVED	0x08
#define PIONEER_BACKGROUND	0x10
#define PIONEER_TERMINATOR	0x20
#define PIONEER_BAUD_RATE	0x40
#define PIONEER_TEST_MODE	0x80

/* absolute arg (not a mask) */

#define PIONEER_DEFAULT_REG_C	0x00

/* args for display command */

#define PIONEER_DISPLAY_OFF	0x00
#define PIONEER_DISPLAY_ON	0x01

/* ----------------- */

/* enhanced LD-V4200 commands (not used in this driver) */

#define PIONEER_REG_A_STATUS	"$A"	/* RETURNS contents of register A */
#define PIONEER_REG_B_STATUS	"$B"	/* RETURNS contents of register B */
#define PIONEER_REG_C_STATUS	"$C"	/* RETURNS contents of register C */
#define PIONEER_USER_CODE	"?U"	/* RETURNS user code string (if any) */

/* ----------------- */

/* type of response from player */

#define PIONEER_ACK_RESP		0	/* typical "R\r" response */
#define PIONEER_ADDR_RESP		1	/* "00000\r" response */
#define PIONEER_PLAYER_STATUS_RESP	2	/* "P00\r" response */
#define PIONEER_DISC_STATUS_RESP	3	/* "XXXXX\r" response */
#define PIONEER_COMM_STATUS_RESP	4	/* "CM3\r" response */
#define PIONEER_MODEL_RESP		5	/* "P1502XX\r" response */
#define PIONEER_PRINT_RESP		6	/* "R\rR\r" response */
#define PIONEER_ERR_RESP		7	/* "E00\r" response */

/* ----------------- */

/* ERROR messages (returned) */

#define PIONEER_COMM_ERR	"E00\r"	/* basic communications error */
#define PIONEER_FUNC_ERR	"E04\r"	/* illegal or impossible request */
#define PIONEER_ARG_ERR		"E06\r"	/* missing argument */
#define PIONEER_NODISC_ERR	"E11\r"	/* disc is not loaded */
#define PIONEER_SEARCH_ERR	"E12\r"	/* search address not found */
#define PIONEER_FOCUS_ERR	"E13\r"	/* player can't focus on disc */
#define PIONEER_PICSTOP_ERR	"E15\r"	/* hit picture stop code on disc */
#define PIONEER_PANIC_ERR	"E99\r"	/* unrecoverable error */

/* ----------------- */

/* length of timeouts, in milliseconds */

#define PIONEER_STD_TIMEOUT		 1000
#define PIONEER_SEARCH_TIMEOUT		10000
#define PIONEER_LOAD_TIMEOUT		30000
#define PIONEER_UNLOAD_TIMEOUT		15000
#define PIONEER_OPEN_TIMEOUT		10000
#define PIONEER_SPECIAL_TIMEOUT		    0  /* means to wait indefinitely */

/* ----------------- */

/* macro to convert framecount to h,m,s and back */

#define FRAMES_TO_HMS(f,h,m,s) \
  (h) = (f) / 108000; \
  (m) = ((f) % 108000) / 1800; \
  (s) = (((f) % 108000) % 1800) / 30;

#define HMS_TO_FRAMES(h,m,s) \
  (s) * 30 + (m) * 1800 + (h) * 108000

#endif	/* !PIONEER_H */

