treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157
[sfrench/cifs-2.6.git] / drivers / media / pci / cx18 / cx18-mailbox.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *  cx18 mailbox functions
4  *
5  *  Copyright (C) 2007  Hans Verkuil <hverkuil@xs4all.nl>
6  *  Copyright (C) 2008  Andy Walls <awalls@md.metrocast.net>
7  */
8
9 #ifndef _CX18_MAILBOX_H_
10 #define _CX18_MAILBOX_H_
11
12 /* mailbox max args */
13 #define MAX_MB_ARGUMENTS 6
14 /* compatibility, should be same as the define in cx2341x.h */
15 #define CX2341X_MBOX_MAX_DATA 16
16
17 #define MB_RESERVED_HANDLE_0 0
18 #define MB_RESERVED_HANDLE_1 0xFFFFFFFF
19
20 #define APU 0
21 #define CPU 1
22 #define EPU 2
23 #define HPU 3
24
25 struct cx18;
26
27 /*
28  * This structure is used by CPU to provide completed MDL & buffers information.
29  * Its structure is dictated by the layout of the SCB, required by the
30  * firmware, but its definition needs to be here, instead of in cx18-scb.h,
31  * for mailbox work order scheduling
32  */
33 struct cx18_mdl_ack {
34     u32 id;        /* ID of a completed MDL */
35     u32 data_used; /* Total data filled in the MDL with 'id' */
36 };
37
38 /* The cx18_mailbox struct is the mailbox structure which is used for passing
39    messages between processors */
40 struct cx18_mailbox {
41     /* The sender sets a handle in 'request' after he fills the command. The
42        'request' should be different than 'ack'. The sender, also, generates
43        an interrupt on XPU2YPU_irq where XPU is the sender and YPU is the
44        receiver. */
45     u32       request;
46     /* The receiver detects a new command when 'req' is different than 'ack'.
47        He sets 'ack' to the same value as 'req' to clear the command. He, also,
48        generates an interrupt on YPU2XPU_irq where XPU is the sender and YPU
49        is the receiver. */
50     u32       ack;
51     u32       reserved[6];
52     /* 'cmd' identifies the command. The list of these commands are in
53        cx23418.h */
54     u32       cmd;
55     /* Each command can have up to 6 arguments */
56     u32       args[MAX_MB_ARGUMENTS];
57     /* The return code can be one of the codes in the file cx23418.h. If the
58        command is completed successfully, the error will be ERR_SYS_SUCCESS.
59        If it is pending, the code is ERR_SYS_PENDING. If it failed, the error
60        code would indicate the task from which the error originated and will
61        be one of the errors in cx23418.h. In that case, the following
62        applies ((error & 0xff) != 0).
63        If the command is pending, the return will be passed in a MB from the
64        receiver to the sender. 'req' will be returned in args[0] */
65     u32       error;
66 };
67
68 struct cx18_stream;
69
70 int cx18_api(struct cx18 *cx, u32 cmd, int args, u32 data[]);
71 int cx18_vapi_result(struct cx18 *cx, u32 data[MAX_MB_ARGUMENTS], u32 cmd,
72                 int args, ...);
73 int cx18_vapi(struct cx18 *cx, u32 cmd, int args, ...);
74 int cx18_api_func(void *priv, u32 cmd, int in, int out,
75                 u32 data[CX2341X_MBOX_MAX_DATA]);
76
77 void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu);
78
79 void cx18_in_work_handler(struct work_struct *work);
80
81 #endif