blob: cb14a7830197d2a13d2d84ec6c0323c3ef7a1e3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
* Copyright (C) 2012 Spreadtrum Communications Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __SBUF_H
#define __SBUF_H
/* flag for CMD/DONE msg type */
#define SMSG_CMD_SBUF_INIT 0x0001
#define SMSG_DONE_SBUF_INIT 0x0002
/* flag for EVENT msg type */
#define SMSG_EVENT_SBUF_WRPTR 0x0001
#define SMSG_EVENT_SBUF_RDPTR 0x0002
/* ring buf header */
struct sbuf_ring_header {
/* send-buffer info */
uint32_t txbuf_addr;
uint32_t txbuf_size;
uint32_t txbuf_rdptr;
uint32_t txbuf_wrptr;
/* recv-buffer info */
uint32_t rxbuf_addr;
uint32_t rxbuf_size;
uint32_t rxbuf_rdptr;
uint32_t rxbuf_wrptr;
};
/* sbuf_mem is the structure of smem for rings */
struct sbuf_smem_header {
uint32_t ringnr;
struct sbuf_ring_header headers[0];
};
struct sbuf_ring {
/* tx/rx buffer info */
volatile struct sbuf_ring_header *header;
void *txbuf_virt;
void *rxbuf_virt;
/* send/recv wait queue */
wait_queue_head_t txwait;
wait_queue_head_t rxwait;
/* send/recv mutex */
struct mutex txlock;
struct mutex rxlock;
void (*handler)(int event, void *data);
void *data;
};
#define SBUF_STATE_IDLE 0
#define SBUF_STATE_READY 1
struct sbuf_mgr {
uint8_t dst;
uint8_t channel;
uint32_t state;
void *smem_virt;
uint32_t smem_addr;
uint32_t smem_size;
uint32_t ringnr;
struct sbuf_ring *rings;
struct task_struct *thread;
};
#endif
|