1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * cx18 header containing common defines.
5 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
11 #include <media/drv-intf/cx2341x.h>
13 #define MGR_CMD_MASK 0x40000000
14 /* The MSB of the command code indicates that this is the completion of a
16 #define MGR_CMD_MASK_ACK (MGR_CMD_MASK | 0x80000000)
18 /* Description: This command creates a new instance of a certain task
19 IN[0] - Task ID. This is one of the XPU_CMD_MASK_YYY where XPU is
20 the processor on which the task YYY will be created
21 OUT[0] - Task handle. This handle is passed along with commands to
22 dispatch to the right instance of the task
23 ReturnCode - One of the ERR_SYS_... */
24 #define CX18_CREATE_TASK (MGR_CMD_MASK | 0x0001)
26 /* Description: This command destroys an instance of a task
27 IN[0] - Task handle. Hanlde of the task to destroy
28 ReturnCode - One of the ERR_SYS_... */
29 #define CX18_DESTROY_TASK (MGR_CMD_MASK | 0x0002)
31 /* All commands for CPU have the following mask set */
32 #define CPU_CMD_MASK 0x20000000
33 #define CPU_CMD_MASK_DEBUG (CPU_CMD_MASK | 0x00000000)
34 #define CPU_CMD_MASK_ACK (CPU_CMD_MASK | 0x80000000)
35 #define CPU_CMD_MASK_CAPTURE (CPU_CMD_MASK | 0x00020000)
36 #define CPU_CMD_MASK_TS (CPU_CMD_MASK | 0x00040000)
38 #define EPU_CMD_MASK 0x02000000
39 #define EPU_CMD_MASK_DEBUG (EPU_CMD_MASK | 0x000000)
40 #define EPU_CMD_MASK_DE (EPU_CMD_MASK | 0x040000)
42 #define APU_CMD_MASK 0x10000000
43 #define APU_CMD_MASK_ACK (APU_CMD_MASK | 0x80000000)
45 #define CX18_APU_ENCODING_METHOD_MPEG (0 << 28)
46 #define CX18_APU_ENCODING_METHOD_AC3 (1 << 28)
48 /* Description: Command APU to start audio
49 IN[0] - audio parameters (same as CX18_CPU_SET_AUDIO_PARAMETERS?)
50 IN[1] - caller buffer address, or 0
52 #define CX18_APU_START (APU_CMD_MASK | 0x01)
54 /* Description: Command APU to stop audio
55 IN[0] - encoding method to stop
57 #define CX18_APU_STOP (APU_CMD_MASK | 0x02)
59 /* Description: Command APU to reset the AI
61 #define CX18_APU_RESETAI (APU_CMD_MASK | 0x05)
63 /* Description: This command indicates that a Memory Descriptor List has been
64 filled with the requested channel type
65 IN[0] - Task handle. Handle of the task
66 IN[1] - Offset of the MDL_ACK from the beginning of the local DDR.
67 IN[2] - Number of CNXT_MDL_ACK structures in the array pointed to by IN[1]
68 ReturnCode - One of the ERR_DE_... */
69 #define CX18_EPU_DMA_DONE (EPU_CMD_MASK_DE | 0x0001)
71 /* Something interesting happened
72 IN[0] - A value to log
73 IN[1] - An offset of a string in the MiniMe memory;
74 0/zero/NULL means "I have nothing to say" */
75 #define CX18_EPU_DEBUG (EPU_CMD_MASK_DEBUG | 0x0003)
77 /* Reads memory/registers (32-bit)
80 #define CX18_CPU_DEBUG_PEEK32 (CPU_CMD_MASK_DEBUG | 0x0003)
82 /* Description: This command starts streaming with the set channel type
83 IN[0] - Task handle. Handle of the task to start
84 ReturnCode - One of the ERR_CAPTURE_... */
85 #define CX18_CPU_CAPTURE_START (CPU_CMD_MASK_CAPTURE | 0x0002)
87 /* Description: This command stops streaming with the set channel type
88 IN[0] - Task handle. Handle of the task to stop
89 IN[1] - 0 = stop at end of GOP, 1 = stop at end of frame (MPEG only)
90 ReturnCode - One of the ERR_CAPTURE_... */
91 #define CX18_CPU_CAPTURE_STOP (CPU_CMD_MASK_CAPTURE | 0x0003)
93 /* Description: This command pauses streaming with the set channel type
94 IN[0] - Task handle. Handle of the task to pause
95 ReturnCode - One of the ERR_CAPTURE_... */
96 #define CX18_CPU_CAPTURE_PAUSE (CPU_CMD_MASK_CAPTURE | 0x0007)
98 /* Description: This command resumes streaming with the set channel type
99 IN[0] - Task handle. Handle of the task to resume
100 ReturnCode - One of the ERR_CAPTURE_... */
101 #define CX18_CPU_CAPTURE_RESUME (CPU_CMD_MASK_CAPTURE | 0x0008)
103 #define CAPTURE_CHANNEL_TYPE_NONE 0
104 #define CAPTURE_CHANNEL_TYPE_MPEG 1
105 #define CAPTURE_CHANNEL_TYPE_INDEX 2
106 #define CAPTURE_CHANNEL_TYPE_YUV 3
107 #define CAPTURE_CHANNEL_TYPE_PCM 4
108 #define CAPTURE_CHANNEL_TYPE_VBI 5
109 #define CAPTURE_CHANNEL_TYPE_SLICED_VBI 6
110 #define CAPTURE_CHANNEL_TYPE_TS 7
111 #define CAPTURE_CHANNEL_TYPE_MAX 15
113 /* Description: This command sets the channel type. This can only be done
115 IN[0] - Task handle. Handle of the task to start
116 IN[1] - Channel Type. See Below.
117 ReturnCode - One of the ERR_CAPTURE_... */
118 #define CX18_CPU_SET_CHANNEL_TYPE (CPU_CMD_MASK_CAPTURE + 1)
120 /* Description: Set stream output type
121 IN[0] - task handle. Handle of the task to start
123 ReturnCode - One of the ERR_CAPTURE_... */
124 #define CX18_CPU_SET_STREAM_OUTPUT_TYPE (CPU_CMD_MASK_CAPTURE | 0x0012)
126 /* Description: Set video input resolution and frame rate
132 IN[5] - frame rate, 0 - 29.97f/s, 1 - 25f/s
133 ReturnCode - One of the ERR_CAPTURE_... */
134 #define CX18_CPU_SET_VIDEO_IN (CPU_CMD_MASK_CAPTURE | 0x0004)
136 /* Description: Set video frame rate
137 IN[0] - task handle. Handle of the task to start
138 IN[1] - video bit rate mode
139 IN[2] - video average rate
140 IN[3] - video peak rate
141 IN[4] - system mux rate
142 ReturnCode - One of the ERR_CAPTURE_... */
143 #define CX18_CPU_SET_VIDEO_RATE (CPU_CMD_MASK_CAPTURE | 0x0005)
145 /* Description: Set video output resolution
147 IN[1] - horizontal size
148 IN[2] - vertical size
149 ReturnCode - One of the ERR_CAPTURE_... */
150 #define CX18_CPU_SET_VIDEO_RESOLUTION (CPU_CMD_MASK_CAPTURE | 0x0006)
152 /* Description: This command set filter parameters
153 IN[0] - Task handle. Handle of the task
154 IN[1] - type, 0 - temporal, 1 - spatial, 2 - median
155 IN[2] - mode, temporal/spatial: 0 - disable, 1 - static, 2 - dynamic
156 median: 0 = disable, 1 = horizontal, 2 = vertical,
157 3 = horizontal/vertical, 4 = diagonal
158 IN[3] - strength, temporal 0 - 31, spatial 0 - 15
159 ReturnCode - One of the ERR_CAPTURE_... */
160 #define CX18_CPU_SET_FILTER_PARAM (CPU_CMD_MASK_CAPTURE | 0x0009)
162 /* Description: This command set spatial filter type
164 IN[1] - luma type: 0 = disable, 1 = 1D horizontal only, 2 = 1D vertical only,
165 3 = 2D H/V separable, 4 = 2D symmetric non-separable
166 IN[2] - chroma type: 0 - disable, 1 = 1D horizontal
167 ReturnCode - One of the ERR_CAPTURE_... */
168 #define CX18_CPU_SET_SPATIAL_FILTER_TYPE (CPU_CMD_MASK_CAPTURE | 0x000C)
170 /* Description: This command set coring levels for median filter
176 ReturnCode - One of the ERR_CAPTURE_... */
177 #define CX18_CPU_SET_MEDIAN_CORING (CPU_CMD_MASK_CAPTURE | 0x000E)
179 /* Description: This command set the picture type mask for index file
180 IN[0] - Task handle (ignored by firmware)
181 IN[1] - 0 = disable index file output
186 #define CX18_CPU_SET_INDEXTABLE (CPU_CMD_MASK_CAPTURE | 0x0010)
188 /* Description: Set audio parameters
189 IN[0] - task handle. Handle of the task to start
190 IN[1] - audio parameter
191 ReturnCode - One of the ERR_CAPTURE_... */
192 #define CX18_CPU_SET_AUDIO_PARAMETERS (CPU_CMD_MASK_CAPTURE | 0x0011)
194 /* Description: Set video mute
195 IN[0] - task handle. Handle of the task to start
196 IN[1] - bit31-24: muteYvalue
199 bit0: 1:mute, 0: unmute
200 ReturnCode - One of the ERR_CAPTURE_... */
201 #define CX18_CPU_SET_VIDEO_MUTE (CPU_CMD_MASK_CAPTURE | 0x0013)
203 /* Description: Set audio mute
204 IN[0] - task handle. Handle of the task to start
206 ReturnCode - One of the ERR_CAPTURE_... */
207 #define CX18_CPU_SET_AUDIO_MUTE (CPU_CMD_MASK_CAPTURE | 0x0014)
209 /* Description: Set stream output type
210 IN[0] - task handle. Handle of the task to start
214 SET_VIM_PROTECT_MODE 3
217 SET_MERAQPAR_ENABLE 6
218 SET_NAV_PACK_INSERTION 7
219 SET_SCENE_CHANGE_ENABLE 8
222 ReturnCode - One of the ERR_CAPTURE_... */
223 #define CX18_CPU_SET_MISC_PARAMETERS (CPU_CMD_MASK_CAPTURE | 0x0015)
225 /* Description: Set raw VBI parameters
227 IN[1] - No. of input lines per field:
230 IN[2] - No. of input bytes per line
231 IN[3] - No. of output frames per transfer
235 #define CX18_CPU_SET_RAW_VBI_PARAM (CPU_CMD_MASK_CAPTURE | 0x0016)
237 /* Description: Set capture line No.
238 IN[0] - task handle. Handle of the task to start
241 ReturnCode - One of the ERR_CAPTURE_... */
242 #define CX18_CPU_SET_CAPTURE_LINE_NO (CPU_CMD_MASK_CAPTURE | 0x0017)
244 /* Description: Set copyright
245 IN[0] - task handle. Handle of the task to start
247 ReturnCode - One of the ERR_CAPTURE_... */
248 #define CX18_CPU_SET_COPYRIGHT (CPU_CMD_MASK_CAPTURE | 0x0018)
250 /* Description: Set audio PID
251 IN[0] - task handle. Handle of the task to start
253 ReturnCode - One of the ERR_CAPTURE_... */
254 #define CX18_CPU_SET_AUDIO_PID (CPU_CMD_MASK_CAPTURE | 0x0019)
256 /* Description: Set video PID
257 IN[0] - task handle. Handle of the task to start
259 ReturnCode - One of the ERR_CAPTURE_... */
260 #define CX18_CPU_SET_VIDEO_PID (CPU_CMD_MASK_CAPTURE | 0x001A)
262 /* Description: Set Vertical Crop Line
263 IN[0] - task handle. Handle of the task to start
265 ReturnCode - One of the ERR_CAPTURE_... */
266 #define CX18_CPU_SET_VER_CROP_LINE (CPU_CMD_MASK_CAPTURE | 0x001B)
268 /* Description: Set COP structure
269 IN[0] - task handle. Handle of the task to start
272 ReturnCode - One of the ERR_CAPTURE_... */
273 #define CX18_CPU_SET_GOP_STRUCTURE (CPU_CMD_MASK_CAPTURE | 0x001C)
275 /* Description: Set Scene Change Detection
276 IN[0] - task handle. Handle of the task to start
278 ReturnCode - One of the ERR_CAPTURE_... */
279 #define CX18_CPU_SET_SCENE_CHANGE_DETECTION (CPU_CMD_MASK_CAPTURE | 0x001D)
281 /* Description: Set Aspect Ratio
282 IN[0] - task handle. Handle of the task to start
284 ReturnCode - One of the ERR_CAPTURE_... */
285 #define CX18_CPU_SET_ASPECT_RATIO (CPU_CMD_MASK_CAPTURE | 0x001E)
287 /* Description: Set Skip Input Frame
288 IN[0] - task handle. Handle of the task to start
289 IN[1] - skip input frames
290 ReturnCode - One of the ERR_CAPTURE_... */
291 #define CX18_CPU_SET_SKIP_INPUT_FRAME (CPU_CMD_MASK_CAPTURE | 0x001F)
293 /* Description: Set sliced VBI parameters -
294 Note This API will only apply to MPEG and Sliced VBI Channels
296 IN[1] - output type, 0 - CC, 1 - Moji, 2 - Teletext
297 IN[2] - start / stop line
298 bit[15:0] start line number
299 bit[31:16] stop line number
300 IN[3] - number of output frames per interrupt
301 IN[4] - VBI insertion mode
302 bit 0: output user data, 1 - enable
303 bit 1: output private stream, 1 - enable
304 bit 2: mux option, 0 - in GOP, 1 - in picture
305 bit[7:0] private stream ID
306 IN[5] - insertion period while mux option is in picture
307 ReturnCode - VBI data offset */
308 #define CX18_CPU_SET_SLICED_VBI_PARAM (CPU_CMD_MASK_CAPTURE | 0x0020)
310 /* Description: Set the user data place holder
311 IN[0] - type of data (0 for user)
312 IN[1] - Stuffing period
313 IN[2] - ID data size in word (less than 10)
314 IN[3] - Pointer to ID buffer */
315 #define CX18_CPU_SET_USERDATA_PLACE_HOLDER (CPU_CMD_MASK_CAPTURE | 0x0021)
322 Out[1] Video PTS bit[32:2] of last output video frame.
323 Out[2] Video PTS bit[ 1:0] of last output video frame.
324 Out[3] Hardware Video PTS counter bit[31:0],
325 these bits get incremented on every 90kHz clock tick.
326 Out[4] Hardware Video PTS counter bit32,
327 these bits get incremented on every 90kHz clock tick.
329 #define CX18_CPU_GET_ENC_PTS (CPU_CMD_MASK_CAPTURE | 0x0022)
331 /* Description: Set VFC parameters
333 IN[1] - VFC enable flag, 1 - enable, 0 - disable
335 #define CX18_CPU_SET_VFC_PARAM (CPU_CMD_MASK_CAPTURE | 0x0023)
337 /* Below is the list of commands related to the data exchange */
338 #define CPU_CMD_MASK_DE (CPU_CMD_MASK | 0x040000)
340 /* Description: This command provides the physical base address of the local
342 IN[0] - Physical offset where EPU has the local DDR mapped
343 ReturnCode - One of the ERR_DE_... */
344 #define CPU_CMD_DE_SetBase (CPU_CMD_MASK_DE | 0x0001)
346 /* Description: This command provides the offsets in the device memory where
347 the 2 cx18_mdl_ack blocks reside
348 IN[0] - Task handle. Handle of the task to start
349 IN[1] - Offset of the first cx18_mdl_ack from the beginning of the
351 IN[2] - Offset of the second cx18_mdl_ack from the beginning of the
353 ReturnCode - One of the ERR_DE_... */
354 #define CX18_CPU_DE_SET_MDL_ACK (CPU_CMD_MASK_DE | 0x0002)
356 /* Description: This command provides the offset to a Memory Descriptor List
357 IN[0] - Task handle. Handle of the task to start
358 IN[1] - Offset of the MDL from the beginning of the local DDR.
359 IN[2] - Number of cx18_mdl_ent structures in the array pointed to by IN[1]
361 IN[4] - Total buffer length
362 ReturnCode - One of the ERR_DE_... */
363 #define CX18_CPU_DE_SET_MDL (CPU_CMD_MASK_DE | 0x0005)
365 /* Description: This command requests return of all current Memory
366 Descriptor Lists to the driver
367 IN[0] - Task handle. Handle of the task to start
368 ReturnCode - One of the ERR_DE_... */
369 #define CX18_CPU_DE_RELEASE_MDL (CPU_CMD_MASK_DE | 0x0006)
371 /* Description: This command signals the cpu that the dat buffer has been
372 consumed and ready for re-use.
373 IN[0] - Task handle. Handle of the task
374 IN[1] - Offset of the data block from the beginning of the local DDR.
375 IN[2] - Number of bytes in the data block
376 ReturnCode - One of the ERR_DE_... */
377 /* #define CX18_CPU_DE_RELEASE_BUFFER (CPU_CMD_MASK_DE | 0x0007) */
379 /* No Error / Success */
380 #define CNXT_OK 0x000000
382 /* Received unknown command */
383 #define CXERR_UNK_CMD 0x000001
385 /* First parameter in the command is invalid */
386 #define CXERR_INVALID_PARAM1 0x000002
388 /* Second parameter in the command is invalid */
389 #define CXERR_INVALID_PARAM2 0x000003
391 /* Device interface is not open/found */
392 #define CXERR_DEV_NOT_FOUND 0x000004
394 /* Requested function is not implemented/available */
395 #define CXERR_NOTSUPPORTED 0x000005
397 /* Invalid pointer is provided */
398 #define CXERR_BADPTR 0x000006
400 /* Unable to allocate memory */
401 #define CXERR_NOMEM 0x000007
403 /* Object/Link not found */
404 #define CXERR_LINK 0x000008
406 /* Device busy, command cannot be executed */
407 #define CXERR_BUSY 0x000009
409 /* File/device/handle is not open. */
410 #define CXERR_NOT_OPEN 0x00000A
412 /* Value is out of range */
413 #define CXERR_OUTOFRANGE 0x00000B
415 /* Buffer overflow */
416 #define CXERR_OVERFLOW 0x00000C
418 /* Version mismatch */
419 #define CXERR_BADVER 0x00000D
421 /* Operation timed out */
422 #define CXERR_TIMEOUT 0x00000E
424 /* Operation aborted */
425 #define CXERR_ABORT 0x00000F
427 /* Specified I2C device not found for read/write */
428 #define CXERR_I2CDEV_NOTFOUND 0x000010
430 /* Error in I2C data xfer (but I2C device is present) */
431 #define CXERR_I2CDEV_XFERERR 0x000011
433 /* Channel changing component not ready */
434 #define CXERR_CHANNELNOTREADY 0x000012
436 /* PPU (Presensation/Decoder) mail box is corrupted */
437 #define CXERR_PPU_MB_CORRUPT 0x000013
439 /* CPU (Capture/Encoder) mail box is corrupted */
440 #define CXERR_CPU_MB_CORRUPT 0x000014
442 /* APU (Audio) mail box is corrupted */
443 #define CXERR_APU_MB_CORRUPT 0x000015
445 /* Unable to open file for reading */
446 #define CXERR_FILE_OPEN_READ 0x000016
448 /* Unable to open file for writing */
449 #define CXERR_FILE_OPEN_WRITE 0x000017
451 /* Unable to find the I2C section specified */
452 #define CXERR_I2C_BADSECTION 0x000018
454 /* Error in I2C data xfer (but I2C device is present) */
455 #define CXERR_I2CDEV_DATALOW 0x000019
457 /* Error in I2C data xfer (but I2C device is present) */
458 #define CXERR_I2CDEV_CLOCKLOW 0x00001A
460 /* No Interrupt received from HW (for I2C access) */
461 #define CXERR_NO_HW_I2C_INTR 0x00001B
463 /* RPU is not ready to accept commands! */
464 #define CXERR_RPU_NOT_READY 0x00001C
466 /* RPU is not ready to accept commands! */
467 #define CXERR_RPU_NO_ACK 0x00001D
469 /* The are no buffers ready. Try again soon! */
470 #define CXERR_NODATA_AGAIN 0x00001E
472 /* The stream is stopping. Function not allowed now! */
473 #define CXERR_STOPPING_STATUS 0x00001F
475 /* Trying to access hardware when the power is turned OFF */
476 #define CXERR_DEVPOWER_OFF 0x000020
478 #endif /* CX23418_H */