summaryrefslogtreecommitdiff
path: root/drivers/dahdi/zaphfc/fifo.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dahdi/zaphfc/fifo.c')
-rw-r--r--drivers/dahdi/zaphfc/fifo.c116
1 files changed, 63 insertions, 53 deletions
diff --git a/drivers/dahdi/zaphfc/fifo.c b/drivers/dahdi/zaphfc/fifo.c
index fa25f9a..8c23fa3 100644
--- a/drivers/dahdi/zaphfc/fifo.c
+++ b/drivers/dahdi/zaphfc/fifo.c
@@ -29,7 +29,9 @@ static void hfc_fifo_mem_read(struct hfc_chan_simplex *chan,
chan->z_base + z_start,
size);
} else {
- // Buffer wrap
+ /*
+ * Buffer wrap
+ */
memcpy(data,
chan->z_base + z_start,
bytes_to_boundary);
@@ -49,7 +51,9 @@ static void hfc_fifo_mem_write(struct hfc_chan_simplex *chan,
data,
size);
} else {
- // FIFO wrap
+ /*
+ * FIFO wrap
+ */
memcpy(chan->z_base + *Z1_F1(chan),
data,
@@ -66,13 +70,17 @@ int hfc_fifo_get(struct hfc_chan_simplex *chan,
{
int available_bytes;
- // Some useless statistic
+ /*
+ * Some useless statistic
+ */
chan->bytes += size;
available_bytes = hfc_fifo_used_rx(chan);
if (available_bytes < size && !chan->fifo_underrun++) {
- // print the warning only once
+ /*
+ * print the warning only once
+ */
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -88,26 +96,6 @@ int hfc_fifo_get(struct hfc_chan_simplex *chan,
return available_bytes - size;
}
-/*
-static void hfc_fifo_drop(struct hfc_chan_simplex *chan, int size)
-{
- int available_bytes = hfc_fifo_used_rx(chan);
- if (available_bytes + 1 < size) {
- printk(KERN_WARNING hfc_DRIVER_PREFIX
- "card %d: "
- "chan %s: "
- "RX FIFO not enough (%d) bytes to drop!\n",
- chan->chan->card->cardnum,
- chan->chan->name,
- available_bytes);
-
- return;
- }
-
- *Z2_F2(chan) = Z_inc(chan, *Z2_F2(chan), size);
-}
-*/
-
void hfc_fifo_put(struct hfc_chan_simplex *chan,
void *data, int size)
{
@@ -116,7 +104,9 @@ void hfc_fifo_put(struct hfc_chan_simplex *chan,
int free_bytes = hfc_fifo_free_tx(chan);
if (!used_bytes && !chan->fifo_underrun++) {
- // print warning only once, to make timing not worse
+ /*
+ * print warning only once, to make timing not worse
+ */
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -144,9 +134,11 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
{
int frame_size;
u16 newz2 ;
-
+
if (*chan->f1 == *chan->f2) {
- // nothing received, strange uh?
+ /*
+ * nothing received, strange uh?
+ */
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -157,11 +149,13 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
return -1;
}
- // frame_size includes CRC+CRC+STAT
+ /*
+ * frame_size includes CRC+CRC+STAT
+ */
frame_size = hfc_fifo_get_frame_size(chan);
#ifdef DEBUG
- if(debug_level == 3) {
+ if (debug_level == 3) {
printk(KERN_DEBUG hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -169,7 +163,7 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
chan->chan->card->cardnum,
chan->chan->name,
frame_size);
- } else if(debug_level >= 4) {
+ } else if (debug_level >= 4) {
printk(KERN_DEBUG hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -180,14 +174,14 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
frame_size);
}
- if(debug_level >= 3) {
+ if (debug_level >= 3) {
int i;
- for (i=0; i < frame_size; i++) {
+ for (i = 0; i < frame_size; i++) {
printk("%02x", hfc_fifo_u8(chan,
Z_inc(chan, *Z2_F2(chan), i)));
}
- printk("\n");
+ printk("\n");
}
#endif
@@ -207,22 +201,30 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
return -1;
}
- // STAT is not really received
+ /*
+ * STAT is not really received
+ */
chan->bytes += frame_size - 1;
- // Calculate beginning of the next frame
+ /*
+ * Calculate beginning of the next frame
+ */
newz2 = Z_inc(chan, *Z2_F2(chan), frame_size);
- // We cannot use hfc_fifo_get because of different semantic of
- // "available bytes" and to avoid useless increment of Z2
+ /*
+ * We cannot use hfc_fifo_get because of different semantic of
+ * "available bytes" and to avoid useless increment of Z2
+ */
hfc_fifo_mem_read(chan, *Z2_F2(chan), data,
frame_size < max_size ? frame_size : max_size);
if (hfc_fifo_u8(chan, Z_inc(chan, *Z2_F2(chan),
frame_size - 1)) != 0x00) {
- // CRC not ok, frame broken, skipping
+ /*
+ * CRC not ok, frame broken, skipping
+ */
#ifdef DEBUG
- if(debug_level >= 2) {
+ if (debug_level >= 2) {
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -242,7 +244,9 @@ int hfc_fifo_get_frame(struct hfc_chan_simplex *chan, void *data, int max_size)
*chan->f2 = F_inc(chan, *chan->f2, 1);
- // Set Z2 for the next frame we're going to receive
+ /*
+ * Set Z2 for the next frame we're going to receive
+ */
*Z2_F2(chan) = newz2;
return frame_size;
@@ -254,7 +258,9 @@ void hfc_fifo_drop_frame(struct hfc_chan_simplex *chan)
u16 newz2;
if (*chan->f1 == *chan->f2) {
- // nothing received, strange eh?
+ /*
+ * nothing received, strange eh?
+ */
printk(KERN_WARNING hfc_DRIVER_PREFIX
"card %d: "
"chan %s: "
@@ -265,16 +271,18 @@ void hfc_fifo_drop_frame(struct hfc_chan_simplex *chan)
return;
}
-// chan->drops++;
-
available_bytes = hfc_fifo_used_rx(chan) + 1;
- // Calculate beginning of the next frame
+ /*
+ * Calculate beginning of the next frame
+ */
newz2 = Z_inc(chan, *Z2_F2(chan), available_bytes);
*chan->f2 = F_inc(chan, *chan->f2, 1);
- // Set Z2 for the next frame we're going to receive
+ /*
+ * Set Z2 for the next frame we're going to receive
+ */
*Z2_F2(chan) = newz2;
}
@@ -306,8 +314,8 @@ void hfc_fifo_put_frame(struct hfc_chan_simplex *chan,
if (debug_level >= 3) {
int i;
- for (i=0; i<size; i++)
- printk("%02x",((u8 *)data)[i]);
+ for (i = 0; i < size; i++)
+ printk("%02x", ((u8 *)data)[i]);
printk("\n");
}
@@ -351,12 +359,14 @@ void hfc_clear_fifo_tx(struct hfc_chan_simplex *chan)
*Z1_F1(chan) = *Z2_F1(chan);
if (chan->chan->status == open_voice) {
- // Make sure that at least hfc_TX_FIFO_PRELOAD bytes are
- // present in the TX FIFOs
-
- // Create hfc_TX_FIFO_PRELOAD bytes of empty data
- // (0x7f is mute audio)
- u8 empty_fifo[hfc_TX_FIFO_PRELOAD + DAHDI_CHUNKSIZE + hfc_RX_FIFO_PRELOAD];
+ /*
+ * Make sure that at least hfc_TX_FIFO_PRELOAD bytes are
+ * present in the TX FIFOs
+ * Create hfc_TX_FIFO_PRELOAD bytes of empty data
+ * (0x7f is mute audio)
+ */
+ u8 empty_fifo[hfc_TX_FIFO_PRELOAD +
+ DAHDI_CHUNKSIZE + hfc_RX_FIFO_PRELOAD];
memset(empty_fifo, 0x7f, sizeof(empty_fifo));
hfc_fifo_put(chan, empty_fifo, sizeof(empty_fifo));