18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Driver for Digigram VX soundcards
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Definitions of DSP commands
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef __VX_CMD_H
118c2ecf20Sopenharmony_ci#define __VX_CMD_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cienum {
148c2ecf20Sopenharmony_ci	CMD_VERSION,
158c2ecf20Sopenharmony_ci	CMD_SUPPORTED,
168c2ecf20Sopenharmony_ci	CMD_TEST_IT,
178c2ecf20Sopenharmony_ci	CMD_SEND_IRQA,
188c2ecf20Sopenharmony_ci	CMD_IBL,
198c2ecf20Sopenharmony_ci	CMD_ASYNC,
208c2ecf20Sopenharmony_ci	CMD_RES_PIPE,
218c2ecf20Sopenharmony_ci	CMD_FREE_PIPE,
228c2ecf20Sopenharmony_ci	CMD_CONF_PIPE,
238c2ecf20Sopenharmony_ci	CMD_ABORT_CONF_PIPE,
248c2ecf20Sopenharmony_ci	CMD_PARAM_OUTPUT_PIPE,
258c2ecf20Sopenharmony_ci	CMD_STOP_PIPE,
268c2ecf20Sopenharmony_ci	CMD_PIPE_STATE,
278c2ecf20Sopenharmony_ci	CMD_PIPE_SPL_COUNT,
288c2ecf20Sopenharmony_ci	CMD_CAN_START_PIPE,
298c2ecf20Sopenharmony_ci	CMD_SIZE_HBUFFER,
308c2ecf20Sopenharmony_ci	CMD_START_STREAM,
318c2ecf20Sopenharmony_ci	CMD_START_ONE_STREAM,
328c2ecf20Sopenharmony_ci	CMD_PAUSE_STREAM,
338c2ecf20Sopenharmony_ci	CMD_PAUSE_ONE_STREAM,
348c2ecf20Sopenharmony_ci	CMD_STREAM_OUT_LEVEL_ADJUST,
358c2ecf20Sopenharmony_ci	CMD_STOP_STREAM,
368c2ecf20Sopenharmony_ci	CMD_FORMAT_STREAM_OUT,
378c2ecf20Sopenharmony_ci	CMD_FORMAT_STREAM_IN,
388c2ecf20Sopenharmony_ci	CMD_GET_STREAM_STATE,
398c2ecf20Sopenharmony_ci	CMD_DROP_BYTES_AWAY,
408c2ecf20Sopenharmony_ci	CMD_GET_REMAINING_BYTES,
418c2ecf20Sopenharmony_ci	CMD_CONNECT_AUDIO,
428c2ecf20Sopenharmony_ci	CMD_AUDIO_LEVEL_ADJUST,
438c2ecf20Sopenharmony_ci	CMD_AUDIO_VU_PIC_METER,
448c2ecf20Sopenharmony_ci	CMD_GET_AUDIO_LEVELS,
458c2ecf20Sopenharmony_ci	CMD_GET_NOTIFY_EVENT,
468c2ecf20Sopenharmony_ci	CMD_INFO_NOTIFIED,
478c2ecf20Sopenharmony_ci	CMD_ACCESS_IO_FCT,
488c2ecf20Sopenharmony_ci	CMD_STATUS_R_BUFFERS,
498c2ecf20Sopenharmony_ci	CMD_UPDATE_R_BUFFERS,
508c2ecf20Sopenharmony_ci	CMD_LOAD_EFFECT_CONTEXT,
518c2ecf20Sopenharmony_ci	CMD_EFFECT_ONE_PIPE,
528c2ecf20Sopenharmony_ci	CMD_MODIFY_CLOCK,
538c2ecf20Sopenharmony_ci	CMD_STREAM1_OUT_SET_N_LEVELS,
548c2ecf20Sopenharmony_ci	CMD_PURGE_STREAM_DCMDS,
558c2ecf20Sopenharmony_ci	CMD_NOTIFY_PIPE_TIME,
568c2ecf20Sopenharmony_ci	CMD_LOAD_EFFECT_CONTEXT_PACKET,
578c2ecf20Sopenharmony_ci	CMD_RELIC_R_BUFFER,
588c2ecf20Sopenharmony_ci	CMD_RESYNC_AUDIO_INPUTS,
598c2ecf20Sopenharmony_ci	CMD_NOTIFY_STREAM_TIME,
608c2ecf20Sopenharmony_ci	CMD_STREAM_SAMPLE_COUNT,
618c2ecf20Sopenharmony_ci	CMD_CONFIG_TIME_CODE,
628c2ecf20Sopenharmony_ci	CMD_GET_TIME_CODE,
638c2ecf20Sopenharmony_ci	CMD_MANAGE_SIGNAL,
648c2ecf20Sopenharmony_ci	CMD_PARAMETER_STREAM_OUT,
658c2ecf20Sopenharmony_ci	CMD_READ_BOARD_FREQ,
668c2ecf20Sopenharmony_ci	CMD_GET_STREAM_LEVELS,
678c2ecf20Sopenharmony_ci	CMD_PURGE_PIPE_DCMDS,
688c2ecf20Sopenharmony_ci	// CMD_SET_STREAM_OUT_EFFECTS,
698c2ecf20Sopenharmony_ci	// CMD_GET_STREAM_OUT_EFFECTS,
708c2ecf20Sopenharmony_ci	CMD_CONNECT_MONITORING,
718c2ecf20Sopenharmony_ci	CMD_STREAM2_OUT_SET_N_LEVELS,
728c2ecf20Sopenharmony_ci	CMD_CANCEL_R_BUFFERS,
738c2ecf20Sopenharmony_ci	CMD_NOTIFY_END_OF_BUFFER,
748c2ecf20Sopenharmony_ci	CMD_GET_STREAM_VU_METER,
758c2ecf20Sopenharmony_ci	CMD_LAST_INDEX
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistruct vx_cmd_info {
798c2ecf20Sopenharmony_ci	unsigned int opcode;	/* command word */
808c2ecf20Sopenharmony_ci	int length;		/* command length (in words) */
818c2ecf20Sopenharmony_ci	int st_type;		/* status type (RMH_SSIZE_XXX) */
828c2ecf20Sopenharmony_ci	int st_length;		/* fixed length */
838c2ecf20Sopenharmony_ci};
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci/* Family and code op of some DSP requests. */
868c2ecf20Sopenharmony_ci#define CODE_OP_PIPE_TIME                       0x004e0000
878c2ecf20Sopenharmony_ci#define CODE_OP_START_STREAM                    0x00800000
888c2ecf20Sopenharmony_ci#define CODE_OP_PAUSE_STREAM                    0x00810000
898c2ecf20Sopenharmony_ci#define CODE_OP_OUT_STREAM_LEVEL                0x00820000
908c2ecf20Sopenharmony_ci#define CODE_OP_UPDATE_R_BUFFERS                0x00840000
918c2ecf20Sopenharmony_ci#define CODE_OP_OUT_STREAM1_LEVEL_CURVE         0x00850000
928c2ecf20Sopenharmony_ci#define CODE_OP_OUT_STREAM2_LEVEL_CURVE         0x00930000
938c2ecf20Sopenharmony_ci#define CODE_OP_OUT_STREAM_FORMAT               0x00860000
948c2ecf20Sopenharmony_ci#define CODE_OP_STREAM_TIME                     0x008f0000
958c2ecf20Sopenharmony_ci#define CODE_OP_OUT_STREAM_EXTRAPARAMETER       0x00910000
968c2ecf20Sopenharmony_ci#define CODE_OP_OUT_AUDIO_LEVEL                 0x00c20000
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define NOTIFY_LAST_COMMAND     0x00400000
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/* Values for a user delay */
1018c2ecf20Sopenharmony_ci#define DC_DIFFERED_DELAY       (1<<BIT_DIFFERED_COMMAND)
1028c2ecf20Sopenharmony_ci#define DC_NOTIFY_DELAY         (1<<BIT_NOTIFIED_COMMAND)
1038c2ecf20Sopenharmony_ci#define DC_HBUFFER_DELAY        (1<<BIT_TIME_RELATIVE_TO_BUFFER)
1048c2ecf20Sopenharmony_ci#define DC_MULTIPLE_DELAY       (1<<BIT_RESERVED)
1058c2ecf20Sopenharmony_ci#define DC_STREAM_TIME_DELAY    (1<<BIT_STREAM_TIME)
1068c2ecf20Sopenharmony_ci#define DC_CANCELLED_DELAY      (1<<BIT_CANCELLED_COMMAND)
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/* Values for tiDelayed field in TIME_INFO structure,
1098c2ecf20Sopenharmony_ci * and for pbPause field in PLAY_BUFFER_INFO structure
1108c2ecf20Sopenharmony_ci */
1118c2ecf20Sopenharmony_ci#define BIT_DIFFERED_COMMAND                0
1128c2ecf20Sopenharmony_ci#define BIT_NOTIFIED_COMMAND                1
1138c2ecf20Sopenharmony_ci#define BIT_TIME_RELATIVE_TO_BUFFER         2
1148c2ecf20Sopenharmony_ci#define BIT_RESERVED                        3
1158c2ecf20Sopenharmony_ci#define BIT_STREAM_TIME                     4
1168c2ecf20Sopenharmony_ci#define BIT_CANCELLED_COMMAND               5
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci/* Access to the "Size" field of the response of the CMD_GET_NOTIFY_EVENT request. */
1198c2ecf20Sopenharmony_ci#define GET_NOTIFY_EVENT_SIZE_FIELD_MASK    0x000000ff
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/* DSP commands general masks */
1228c2ecf20Sopenharmony_ci#define OPCODE_MASK                 0x00ff0000
1238c2ecf20Sopenharmony_ci#define DSP_DIFFERED_COMMAND_MASK   0x0000C000
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/* Notifications (NOTIFY_INFO) */
1268c2ecf20Sopenharmony_ci#define ALL_CMDS_NOTIFIED                   0x0000  // reserved
1278c2ecf20Sopenharmony_ci#define START_STREAM_NOTIFIED               0x0001
1288c2ecf20Sopenharmony_ci#define PAUSE_STREAM_NOTIFIED               0x0002
1298c2ecf20Sopenharmony_ci#define OUT_STREAM_LEVEL_NOTIFIED           0x0003
1308c2ecf20Sopenharmony_ci#define OUT_STREAM_PARAMETER_NOTIFIED       0x0004  // left for backward compatibility
1318c2ecf20Sopenharmony_ci#define OUT_STREAM_FORMAT_NOTIFIED          0x0004
1328c2ecf20Sopenharmony_ci#define PIPE_TIME_NOTIFIED                  0x0005
1338c2ecf20Sopenharmony_ci#define OUT_AUDIO_LEVEL_NOTIFIED            0x0006
1348c2ecf20Sopenharmony_ci#define OUT_STREAM_LEVEL_CURVE_NOTIFIED     0x0007
1358c2ecf20Sopenharmony_ci#define STREAM_TIME_NOTIFIED                0x0008
1368c2ecf20Sopenharmony_ci#define OUT_STREAM_EXTRAPARAMETER_NOTIFIED  0x0009
1378c2ecf20Sopenharmony_ci#define UNKNOWN_COMMAND_NOTIFIED            0xffff
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/* Output pipe parameters setting */
1408c2ecf20Sopenharmony_ci#define MASK_VALID_PIPE_MPEG_PARAM      0x000040
1418c2ecf20Sopenharmony_ci#define MASK_VALID_PIPE_BACKWARD_PARAM  0x000020
1428c2ecf20Sopenharmony_ci#define MASK_SET_PIPE_MPEG_PARAM        0x000002
1438c2ecf20Sopenharmony_ci#define MASK_SET_PIPE_BACKWARD_PARAM    0x000001
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci#define MASK_DSP_WORD           0x00FFFFFF
1468c2ecf20Sopenharmony_ci#define MASK_ALL_STREAM         0x00FFFFFF
1478c2ecf20Sopenharmony_ci#define MASK_DSP_WORD_LEVEL     0x000001FF
1488c2ecf20Sopenharmony_ci#define MASK_FIRST_FIELD        0x0000001F
1498c2ecf20Sopenharmony_ci#define FIELD_SIZE              5
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci#define COMMAND_RECORD_MASK     0x000800
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci/* PipeManagement definition bits (PIPE_DECL_INFO) */
1548c2ecf20Sopenharmony_ci#define P_UNDERRUN_SKIP_SOUND_MASK				0x01
1558c2ecf20Sopenharmony_ci#define P_PREPARE_FOR_MPEG3_MASK				0x02
1568c2ecf20Sopenharmony_ci#define P_DO_NOT_RESET_ANALOG_LEVELS			0x04
1578c2ecf20Sopenharmony_ci#define P_ALLOW_UNDER_ALLOCATION_MASK			0x08
1588c2ecf20Sopenharmony_ci#define P_DATA_MODE_MASK				0x10
1598c2ecf20Sopenharmony_ci#define P_ASIO_BUFFER_MANAGEMENT_MASK			0x20
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci#define BIT_SKIP_SOUND					0x08	// bit 3
1628c2ecf20Sopenharmony_ci#define BIT_DATA_MODE					0x10	// bit 4
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci/* Bits in the CMD_MODIFY_CLOCK request. */
1658c2ecf20Sopenharmony_ci#define CMD_MODIFY_CLOCK_FD_BIT     0x00000001
1668c2ecf20Sopenharmony_ci#define CMD_MODIFY_CLOCK_T_BIT      0x00000002
1678c2ecf20Sopenharmony_ci#define CMD_MODIFY_CLOCK_S_BIT      0x00000004
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci/* Access to the results of the CMD_GET_TIME_CODE RMH. */
1708c2ecf20Sopenharmony_ci#define TIME_CODE_V_MASK            0x00800000
1718c2ecf20Sopenharmony_ci#define TIME_CODE_N_MASK            0x00400000
1728c2ecf20Sopenharmony_ci#define TIME_CODE_B_MASK            0x00200000
1738c2ecf20Sopenharmony_ci#define TIME_CODE_W_MASK            0x00100000
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/* Values for the CMD_MANAGE_SIGNAL RMH. */
1768c2ecf20Sopenharmony_ci#define MANAGE_SIGNAL_TIME_CODE     0x01
1778c2ecf20Sopenharmony_ci#define MANAGE_SIGNAL_MIDI          0x02
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/* Values for the CMD_CONFIG_TIME_CODE RMH. */
1808c2ecf20Sopenharmony_ci#define CONFIG_TIME_CODE_CANCEL     0x00001000
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/* Mask to get only the effective time from the
1838c2ecf20Sopenharmony_ci * high word out of the 2 returned by the DSP
1848c2ecf20Sopenharmony_ci */
1858c2ecf20Sopenharmony_ci#define PCX_TIME_HI_MASK        0x000fffff
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci/* Values for setting a H-Buffer time */
1888c2ecf20Sopenharmony_ci#define HBUFFER_TIME_HIGH       0x00200000
1898c2ecf20Sopenharmony_ci#define HBUFFER_TIME_LOW        0x00000000
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci#define NOTIFY_MASK_TIME_HIGH   0x00400000
1928c2ecf20Sopenharmony_ci#define MULTIPLE_MASK_TIME_HIGH 0x00100000
1938c2ecf20Sopenharmony_ci#define STREAM_MASK_TIME_HIGH   0x00800000
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci/*
1978c2ecf20Sopenharmony_ci *
1988c2ecf20Sopenharmony_ci */
1998c2ecf20Sopenharmony_civoid vx_init_rmh(struct vx_rmh *rmh, unsigned int cmd);
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci/**
2028c2ecf20Sopenharmony_ci * vx_send_pipe_cmd_params - fill first command word for pipe commands
2038c2ecf20Sopenharmony_ci * @rmh: the rmh to be modified
2048c2ecf20Sopenharmony_ci * @is_capture: 0 = playback, 1 = capture operation
2058c2ecf20Sopenharmony_ci * @param1: first pipe-parameter
2068c2ecf20Sopenharmony_ci * @param2: second pipe-parameter
2078c2ecf20Sopenharmony_ci */
2088c2ecf20Sopenharmony_cistatic inline void vx_set_pipe_cmd_params(struct vx_rmh *rmh, int is_capture,
2098c2ecf20Sopenharmony_ci					  int param1, int param2)
2108c2ecf20Sopenharmony_ci{
2118c2ecf20Sopenharmony_ci	if (is_capture)
2128c2ecf20Sopenharmony_ci		rmh->Cmd[0] |= COMMAND_RECORD_MASK;
2138c2ecf20Sopenharmony_ci	rmh->Cmd[0] |= (((u32)param1 & MASK_FIRST_FIELD) << FIELD_SIZE) & MASK_DSP_WORD;
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci	if (param2)
2168c2ecf20Sopenharmony_ci		rmh->Cmd[0] |= ((u32)param2 & MASK_FIRST_FIELD) & MASK_DSP_WORD;
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci}
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci/**
2218c2ecf20Sopenharmony_ci * vx_set_stream_cmd_params - fill first command word for stream commands
2228c2ecf20Sopenharmony_ci * @rmh: the rmh to be modified
2238c2ecf20Sopenharmony_ci * @is_capture: 0 = playback, 1 = capture operation
2248c2ecf20Sopenharmony_ci * @pipe: the pipe index (zero-based)
2258c2ecf20Sopenharmony_ci */
2268c2ecf20Sopenharmony_cistatic inline void vx_set_stream_cmd_params(struct vx_rmh *rmh, int is_capture, int pipe)
2278c2ecf20Sopenharmony_ci{
2288c2ecf20Sopenharmony_ci	if (is_capture)
2298c2ecf20Sopenharmony_ci		rmh->Cmd[0] |= COMMAND_RECORD_MASK;
2308c2ecf20Sopenharmony_ci	rmh->Cmd[0] |= (((u32)pipe & MASK_FIRST_FIELD) << FIELD_SIZE) & MASK_DSP_WORD;
2318c2ecf20Sopenharmony_ci}
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#endif /* __VX_CMD_H */
234