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