~ubuntu-branches/ubuntu/quantal/zaptel/quantal

« back to all changes in this revision

Viewing changes to kernel/vzaphfc/fifo.h

  • Committer: Bazaar Package Importer
  • Author(s): Tzafrir Cohen
  • Date: 2008-08-28 22:58:23 UTC
  • mfrom: (11.1.11 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080828225823-r8bdunirm8hmc76m
Tags: 1:1.4.11~dfsg-2
* Patch xpp_fxs_power: Fixed an issue with hook detection of the Astribank
  FXS module.
* Don't fail init.d script if fxotune fails. This may happen if running it
  when Asterisk is already running.
* Bump standards version to 3.8.0.0 .
* Ignore false lintian warning ("m-a a-i" has "a a").
* Patch xpp_fxo_cid_always: do always pass PCM if that's what the user
  asked.
* Patch vzaphfc_proc_root_dir: fix vzaphfc on 2.6.26.
* Patch wcte12xp_flags: Proper time for irq save flags.
* Patch headers_2627: Fix location of semaphore.h for 2.6.27 .
* Patch xpp_fxs_dtmf_leak: Don't play DTMFs to the wrong channel.
* Patch wctdm_fix_alarm: Fix sending channel alarms.
* Patch device_class_2626: Fix building 2.6.26 (Closes: #493397).
* Using dh_lintian for lintian overrides, hence requiring debhelper 6.0.7.
* Lintian: we know we have direct changes. Too bad we're half-upstream :-(
* Fix doc-base section names. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * zaphfc.c - Zaptel driver for HFC-S PCI A based ISDN BRI cards
 
3
 *
 
4
 * Copyright (C) 2004 Daniele Orlandi
 
5
 * Copyright (C) 2002, 2003, 2004, Junghanns.NET GmbH
 
6
 *
 
7
 * Daniele "Vihai" Orlandi <daniele@orlandi.com> 
 
8
 *
 
9
 * Major rewrite of the driver made by
 
10
 * Klaus-Peter Junghanns <kpj@junghanns.net>
 
11
 *
 
12
 * This program is free software and may be modified and
 
13
 * distributed under the terms of the GNU Public License.
 
14
 *
 
15
 */
 
16
 
 
17
#ifndef _HFC_FIFO_H
 
18
#define _HFC_FIFO_H
 
19
 
 
20
#include "vzaphfc.h"
 
21
 
 
22
static inline u16 *Z1_F1(struct hfc_chan_simplex *chan)
 
23
{
 
24
        return chan->z1_base + (*chan->f1 * 4);
 
25
}
 
26
 
 
27
static inline u16 *Z2_F1(struct hfc_chan_simplex *chan)
 
28
{
 
29
        return chan->z2_base + (*chan->f1 * 4);
 
30
}
 
31
 
 
32
static inline u16 *Z1_F2(struct hfc_chan_simplex *chan)
 
33
{
 
34
        return chan->z1_base + (*chan->f2 * 4);
 
35
}
 
36
 
 
37
static inline u16 *Z2_F2(struct hfc_chan_simplex *chan)
 
38
{
 
39
        return chan->z2_base + (*chan->f2 * 4);
 
40
}
 
41
 
 
42
static inline u16 Z_inc(struct hfc_chan_simplex *chan, u16 z, u16 inc)
 
43
{
 
44
        // declared as u32 in order to manage overflows
 
45
        u32 newz = z + inc;
 
46
        if (newz > chan->z_max)
 
47
                newz -= chan->fifo_size;
 
48
 
 
49
        return newz;
 
50
}
 
51
 
 
52
static inline u8 F_inc(struct hfc_chan_simplex *chan, u8 f, u8 inc)
 
53
{
 
54
        // declared as u16 in order to manage overflows
 
55
        u16 newf = f + inc;
 
56
        if (newf > chan->f_max)
 
57
                newf -= chan->f_num;
 
58
 
 
59
        return newf;
 
60
}
 
61
 
 
62
static inline u16 hfc_fifo_used_rx(struct hfc_chan_simplex *chan)
 
63
{
 
64
        return (*Z1_F2(chan) - *Z2_F2(chan) + chan->fifo_size) % chan->fifo_size;
 
65
}
 
66
 
 
67
static inline u16 hfc_fifo_get_frame_size(struct hfc_chan_simplex *chan)
 
68
{
 
69
 // This +1 is needed because in frame mode the available bytes are Z2-Z1+1
 
70
 // while in transparent mode I wouldn't consider the byte pointed by Z2 to
 
71
 // be available, otherwise, the FIFO would always contain one byte, even
 
72
 // when Z1==Z2
 
73
 
 
74
        return hfc_fifo_used_rx(chan) + 1;
 
75
}
 
76
 
 
77
static inline u8 hfc_fifo_u8(struct hfc_chan_simplex *chan, u16 z)
 
78
{
 
79
        return *((u8 *)(chan->z_base + z));
 
80
}
 
81
 
 
82
static inline u16 hfc_fifo_used_tx(struct hfc_chan_simplex *chan)
 
83
{
 
84
        return (*Z1_F1(chan) - *Z2_F1(chan) + chan->fifo_size) % chan->fifo_size;
 
85
}
 
86
 
 
87
static inline u16 hfc_fifo_free_rx(struct hfc_chan_simplex *chan)
 
88
{
 
89
        u16 free_bytes=*Z2_F1(chan) - *Z1_F1(chan);
 
90
 
 
91
        if (free_bytes > 0)
 
92
                return free_bytes;
 
93
        else
 
94
                return free_bytes + chan->fifo_size;
 
95
}
 
96
 
 
97
static inline u16 hfc_fifo_free_tx(struct hfc_chan_simplex *chan)
 
98
{
 
99
        u16 free_bytes=*Z2_F1(chan) - *Z1_F1(chan);
 
100
 
 
101
        if (free_bytes > 0)
 
102
                return free_bytes;
 
103
        else
 
104
                return free_bytes + chan->fifo_size;
 
105
}
 
106
 
 
107
static inline int hfc_fifo_has_frames(struct hfc_chan_simplex *chan)
 
108
{
 
109
        return *chan->f1 != *chan->f2;
 
110
}
 
111
 
 
112
static inline u8 hfc_fifo_used_frames(struct hfc_chan_simplex *chan)
 
113
{
 
114
        return (*chan->f1 - *chan->f2 + chan->f_num) % chan->f_num;
 
115
}
 
116
 
 
117
static inline u8 hfc_fifo_free_frames(struct hfc_chan_simplex *chan)
 
118
{
 
119
        return (*chan->f2 - *chan->f1 + chan->f_num) % chan->f_num;
 
120
}
 
121
 
 
122
int hfc_fifo_get(struct hfc_chan_simplex *chan, void *data, int size);
 
123
void hfc_fifo_put(struct hfc_chan_simplex *chan, void *data, int size);
 
124
void hfc_fifo_drop(struct hfc_chan_simplex *chan, int size);
 
125
int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size);
 
126
void hfc_fifo_drop_frame(struct hfc_chan_simplex *chan);
 
127
void hfc_fifo_put_frame(struct hfc_chan_simplex *chan, void *data, int size);
 
128
void hfc_clear_fifo_rx(struct hfc_chan_simplex *chan);
 
129
void hfc_clear_fifo_tx(struct hfc_chan_simplex *chan);
 
130
 
 
131
#endif