temp revert rk change
[firefly-linux-kernel-4.4.55.git] / drivers / media / video / tegra / avp / trpc.h
1 /*
2  * Copyright (C) 2010 Google, Inc.
3  *
4  * Author:
5  *   Dima Zavin <dima@android.com>
6  *
7  * This software is licensed under the terms of the GNU General Public
8  * License version 2, as published by the Free Software Foundation, and
9  * may be copied, distributed, and modified under those terms.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  */
17
18 #ifndef __ARM_MACH_TEGRA_RPC_H
19 #define __ARM_MACH_TEGRA_RPC_H
20
21 #include <linux/list.h>
22 #include <linux/seq_file.h>
23 #include <linux/tegra_rpc.h>
24
25 struct trpc_endpoint;
26 struct trpc_ep_ops {
27         /* send is allowed to sleep */
28         int     (*send)(struct trpc_endpoint *ep, void *buf, size_t len);
29         /* notify_recv is NOT allowed to sleep */
30         void    (*notify_recv)(struct trpc_endpoint *ep);
31         /* close is allowed to sleep */
32         void    (*close)(struct trpc_endpoint *ep);
33         /* not allowed to sleep, not allowed to call back into trpc */
34         void    (*show)(struct seq_file *s, struct trpc_endpoint *ep);
35 };
36
37 enum {
38         TRPC_NODE_LOCAL,
39         TRPC_NODE_REMOTE,
40 };
41
42 struct trpc_node {
43         struct list_head        list;
44         const char              *name;
45         int                     type;
46         void                    *priv;
47
48         int                     (*try_connect)(struct trpc_node *node,
49                                                struct trpc_node *src,
50                                                struct trpc_endpoint *from);
51 };
52
53 struct trpc_endpoint *trpc_peer(struct trpc_endpoint *ep);
54 void *trpc_priv(struct trpc_endpoint *ep);
55 const char *trpc_name(struct trpc_endpoint *ep);
56
57 void trpc_put(struct trpc_endpoint *ep);
58 void trpc_get(struct trpc_endpoint *ep);
59
60 int trpc_send_msg(struct trpc_node *src, struct trpc_endpoint *ep, void *buf,
61                   size_t len, gfp_t gfp_flags);
62 int trpc_recv_msg(struct trpc_node *src, struct trpc_endpoint *ep,
63                   void *buf, size_t len, long timeout);
64 struct trpc_endpoint *trpc_create(struct trpc_node *owner, const char *name,
65                                   struct trpc_ep_ops *ops, void *priv);
66 struct trpc_endpoint *trpc_create_connect(struct trpc_node *src, char *name,
67                                           struct trpc_ep_ops *ops, void *priv,
68                                           long timeout);
69 int trpc_connect(struct trpc_endpoint *from, long timeout);
70 struct trpc_endpoint *trpc_create_peer(struct trpc_node *owner,
71                                        struct trpc_endpoint *ep,
72                                        struct trpc_ep_ops *ops,
73                                        void *priv);
74 void trpc_close(struct trpc_endpoint *ep);
75 int trpc_wait_peer(struct trpc_endpoint *ep, long timeout);
76
77 int trpc_node_register(struct trpc_node *node);
78 void trpc_node_unregister(struct trpc_node *node);
79
80 #endif