cx18-mailbox.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  20. * 02111-1307 USA
  21. */
  22. #ifndef _CX18_MAILBOX_H_
  23. #define _CX18_MAILBOX_H_
  24. /* mailbox max args */
  25. #define MAX_MB_ARGUMENTS 6
  26. /* compatibility, should be same as the define in cx2341x.h */
  27. #define CX2341X_MBOX_MAX_DATA 16
  28. #define MB_RESERVED_HANDLE_0 0
  29. #define MB_RESERVED_HANDLE_1 0xFFFFFFFF
  30. #define APU 0
  31. #define CPU 1
  32. #define EPU 2
  33. #define HPU 3
  34. struct cx18;
  35. /*
  36. * This structure is used by CPU to provide completed MDL & buffers information.
  37. * Its structure is dictated by the layout of the SCB, required by the
  38. * firmware, but its definition needs to be here, instead of in cx18-scb.h,
  39. * for mailbox work order scheduling
  40. */
  41. struct cx18_mdl_ack {
  42. u32 id; /* ID of a completed MDL */
  43. u32 data_used; /* Total data filled in the MDL with 'id' */
  44. };
  45. /* The cx18_mailbox struct is the mailbox structure which is used for passing
  46. messages between processors */
  47. struct cx18_mailbox {
  48. /* The sender sets a handle in 'request' after he fills the command. The
  49. 'request' should be different than 'ack'. The sender, also, generates
  50. an interrupt on XPU2YPU_irq where XPU is the sender and YPU is the
  51. receiver. */
  52. u32 request;
  53. /* The receiver detects a new command when 'req' is different than 'ack'.
  54. He sets 'ack' to the same value as 'req' to clear the command. He, also,
  55. generates an interrupt on YPU2XPU_irq where XPU is the sender and YPU
  56. is the receiver. */
  57. u32 ack;
  58. u32 reserved[6];
  59. /* 'cmd' identifies the command. The list of these commands are in
  60. cx23418.h */
  61. u32 cmd;
  62. /* Each command can have up to 6 arguments */
  63. u32 args[MAX_MB_ARGUMENTS];
  64. /* The return code can be one of the codes in the file cx23418.h. If the
  65. command is completed successfully, the error will be ERR_SYS_SUCCESS.
  66. If it is pending, the code is ERR_SYS_PENDING. If it failed, the error
  67. code would indicate the task from which the error originated and will
  68. be one of the errors in cx23418.h. In that case, the following
  69. applies ((error & 0xff) != 0).
  70. If the command is pending, the return will be passed in a MB from the
  71. receiver to the sender. 'req' will be returned in args[0] */
  72. u32 error;
  73. };
  74. struct cx18_stream;
  75. int cx18_api(struct cx18 *cx, u32 cmd, int args, u32 data[]);
  76. int cx18_vapi_result(struct cx18 *cx, u32 data[MAX_MB_ARGUMENTS], u32 cmd,
  77. int args, ...);
  78. int cx18_vapi(struct cx18 *cx, u32 cmd, int args, ...);
  79. int cx18_api_func(void *priv, u32 cmd, int in, int out,
  80. u32 data[CX2341X_MBOX_MAX_DATA]);
  81. void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu);
  82. void cx18_in_work_handler(struct work_struct *work);
  83. #endif