diff options
author | Sjur Braendeland <sjur.brandeland@stericsson.com> | 2010-03-30 09:56:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-30 22:08:46 -0400 |
commit | b482cd2053e3b90a7b33a78c63cdb6badf2ec383 (patch) | |
tree | 1c05e28f19a194b52bf43730fa498dcdb0e92b59 /net/caif/cfvidl.c | |
parent | 2721c5b9dd2a56a9710021c00146bb26ba8dd7b3 (diff) |
net-caif: add CAIF core protocol stack
CAIF generic protocol implementation. This layer is
somewhat generic in order to be able to use and test it outside
the Linux Kernel.
cfctrl.c - CAIF control protocol layer
cfdbgl.c - CAIF debug protocol layer
cfdgml.c - CAIF datagram protocol layer
cffrml.c - CAIF framing protocol layer
cfmuxl.c - CAIF mux protocol layer
cfrfml.c - CAIF remote file manager protocol layer
cfserl.c - CAIF serial (fragmentation) protocol layer
cfsrvl.c - CAIF generic service layer functions
cfutill.c - CAIF utility protocol layer
cfveil.c - CAIF AT protocol layer
cfvidl.c - CAIF video protocol layer
Signed-off-by: Sjur Braendeland <sjur.brandeland@stericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/caif/cfvidl.c')
-rw-r--r-- | net/caif/cfvidl.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/net/caif/cfvidl.c b/net/caif/cfvidl.c new file mode 100644 index 000000000000..89ad4ea239f1 --- /dev/null +++ b/net/caif/cfvidl.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * Copyright (C) ST-Ericsson AB 2010 | ||
3 | * Author: Sjur Brendeland/sjur.brandeland@stericsson.com | ||
4 | * License terms: GNU General Public License (GPL) version 2 | ||
5 | */ | ||
6 | |||
7 | #include <linux/kernel.h> | ||
8 | #include <linux/types.h> | ||
9 | #include <linux/slab.h> | ||
10 | #include <linux/errno.h> | ||
11 | #include <net/caif/caif_layer.h> | ||
12 | #include <net/caif/cfsrvl.h> | ||
13 | #include <net/caif/cfpkt.h> | ||
14 | |||
15 | #define container_obj(layr) ((struct cfsrvl *) layr) | ||
16 | |||
17 | static int cfvidl_receive(struct cflayer *layr, struct cfpkt *pkt); | ||
18 | static int cfvidl_transmit(struct cflayer *layr, struct cfpkt *pkt); | ||
19 | |||
20 | struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info) | ||
21 | { | ||
22 | struct cfsrvl *vid = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC); | ||
23 | if (!vid) { | ||
24 | pr_warning("CAIF: %s(): Out of memory\n", __func__); | ||
25 | return NULL; | ||
26 | } | ||
27 | caif_assert(offsetof(struct cfsrvl, layer) == 0); | ||
28 | |||
29 | memset(vid, 0, sizeof(struct cfsrvl)); | ||
30 | cfsrvl_init(vid, channel_id, dev_info); | ||
31 | vid->layer.receive = cfvidl_receive; | ||
32 | vid->layer.transmit = cfvidl_transmit; | ||
33 | snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ - 1, "vid1"); | ||
34 | return &vid->layer; | ||
35 | } | ||
36 | |||
37 | static int cfvidl_receive(struct cflayer *layr, struct cfpkt *pkt) | ||
38 | { | ||
39 | u32 videoheader; | ||
40 | if (cfpkt_extr_head(pkt, &videoheader, 4) < 0) { | ||
41 | pr_err("CAIF: %s(): Packet is erroneous!\n", __func__); | ||
42 | cfpkt_destroy(pkt); | ||
43 | return -EPROTO; | ||
44 | } | ||
45 | return layr->up->receive(layr->up, pkt); | ||
46 | } | ||
47 | |||
48 | static int cfvidl_transmit(struct cflayer *layr, struct cfpkt *pkt) | ||
49 | { | ||
50 | struct cfsrvl *service = container_obj(layr); | ||
51 | struct caif_payload_info *info; | ||
52 | u32 videoheader = 0; | ||
53 | int ret; | ||
54 | if (!cfsrvl_ready(service, &ret)) | ||
55 | return ret; | ||
56 | cfpkt_add_head(pkt, &videoheader, 4); | ||
57 | /* Add info for MUX-layer to route the packet out */ | ||
58 | info = cfpkt_info(pkt); | ||
59 | info->channel_id = service->layer.id; | ||
60 | info->dev_info = &service->dev_info; | ||
61 | ret = layr->dn->transmit(layr->dn, pkt); | ||
62 | if (ret < 0) | ||
63 | cfpkt_extr_head(pkt, &videoheader, 4); | ||
64 | return ret; | ||
65 | } | ||