From b730255a7b8f572a2d6d905c128c7a86b75eca2e Mon Sep 17 00:00:00 2001 From: kpfleming Date: Tue, 6 Feb 2007 21:57:38 +0000 Subject: revert transcoder driver to last version that passed PQ testing... improved version will come back once testing has been completed and bugs are found/fixed git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2092 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zttranscode.c | 66 ++++++++++++++++++++++------------------------------------- 1 file changed, 24 insertions(+), 42 deletions(-) (limited to 'zttranscode.c') diff --git a/zttranscode.c b/zttranscode.c index 39e84ae..c12db53 100644 --- a/zttranscode.c +++ b/zttranscode.c @@ -3,7 +3,7 @@ * * Written by Mark Spencer * - * Copyright (C) 2006, Digium, Inc. + * Copyright (C) 2006-2007, Digium, Inc. * * All rights reserved. * @@ -72,7 +72,7 @@ struct zt_transcoder *zt_transcoder_alloc(int numchans) init_waitqueue_head(&ztc->channels[x].ready); ztc->channels[x].parent = ztc; ztc->channels[x].offset = x; - ztc->channels[x].flags.chan_built = 0; + ztc->channels[x].chan_built = 0; ztc->channels[x].built_fmts = 0; } @@ -163,7 +163,7 @@ int zt_transcoder_alert(struct zt_transcoder_channel *ztc) if (debug) printk("ZT Transcoder Alert!\n"); if (ztc->tch) - ztc->tch->busy = 0; + ztc->tch->status &= ~ZT_TC_FLAG_BUSY; wake_up_interruptible(&ztc->ready); return 0; @@ -178,14 +178,14 @@ static int zt_tc_open(struct inode *inode, struct file *file) if (!(ztc = kmalloc(sizeof(*ztc), GFP_KERNEL))) return -ENOMEM; - if (!(zth = kmalloc(sizeof(*zth), GFP_KERNEL))) { + if (!(zth = kmalloc(sizeof(*zth), GFP_KERNEL | GFP_DMA))) { kfree(ztc); return -ENOMEM; } memset(ztc, 0, sizeof(*ztc)); memset(zth, 0, sizeof(*zth)); - ztc->flags.transient = ztc->flags.busy = 1; + ztc->flags = ZT_TC_FLAG_TRANSIENT | ZT_TC_FLAG_BUSY; ztc->tch = zth; if (debug) printk("Allocated Transcoder Channel, header is at %p!\n", zth); @@ -207,9 +207,9 @@ static void ztc_release(struct zt_transcoder_channel *ztc) if (!ztc) return; - ztc->flags.busy = 0; + ztc->flags &= ~(ZT_TC_FLAG_BUSY); - if (ztc->tch) { + if(ztc->tch) { for (page = virt_to_page(zth); page < virt_to_page((unsigned long) zth + sizeof(*zth)); page++) @@ -218,15 +218,9 @@ static void ztc_release(struct zt_transcoder_channel *ztc) } ztc->tch = NULL; - - if (ztc->flags.have_reference) { - module_put(ztc->parent->owner); - ztc->flags.have_reference = 0; - } - - if (ztc->flags.transient) + /* Actually reset the transcoder channel */ + if (ztc->flags & ZT_TC_FLAG_TRANSIENT) kfree(ztc); - if (debug) printk("Released Transcoder!\n"); } @@ -238,7 +232,7 @@ static int zt_tc_release(struct inode *inode, struct file *file) return 0; } -static int do_allocate(struct zt_transcoder_channel **ztc) +static int do_reset(struct zt_transcoder_channel **ztc) { struct zt_transcoder_channel *newztc = NULL, *origztc = NULL; struct zt_transcode_header *zth = (*ztc)->tch; @@ -259,17 +253,13 @@ static int do_allocate(struct zt_transcoder_channel **ztc) match = 1; for (x = 0; x < tc->numchannels; x++) { - if (tc->channels[x].flags.busy) + if (tc->channels[x].flags & ZT_TC_FLAG_BUSY) continue; - if (tc->channels[x].flags.chan_built && - ((zth->srcfmt | zth->dstfmt) != tc->channels[x].built_fmts)) - continue; - - if (!try_module_get(tc->owner)) + if ((tc->channels[x].chan_built) && ((zth->srcfmt | zth->dstfmt) != tc->channels[x].built_fmts)) continue; newztc = &tc->channels[x]; - newztc->flags.busy = 1; + newztc->flags = ZT_TC_FLAG_BUSY; break; } } @@ -283,14 +273,7 @@ static int do_allocate(struct zt_transcoder_channel **ztc) (*ztc) = newztc; (*ztc)->tch = origztc->tch; origztc->tch = NULL; - /* ensure that the 'busy' flag doesn't get cleared, - even for a short time, so no other thread will - grab this channel - */ - origztc->flags.busy = 1; - (*ztc)->flags = origztc->flags; - (*ztc)->flags.transient = 0; - (*ztc)->flags.have_reference = 1; + (*ztc)->flags |= (origztc->flags & ~(ZT_TC_FLAG_TRANSIENT)); ztc_release(origztc); } @@ -306,7 +289,7 @@ static int wait_busy(struct zt_transcoder_channel *ztc) int ret; for (;;) { - if (!ztc->tch->busy) + if (!(ztc->tch->status & ZT_TC_FLAG_BUSY)) return 0; if ((ret = schluffen(&ztc->ready))) return ret; @@ -357,29 +340,29 @@ static int zt_tc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ret = zt_tc_getinfo(data); break; case ZT_TCOP_ALLOCATE: - ret = do_allocate(&ztc); + /* Reset transcoder, possibly changing who we point to */ + ret = do_reset(&ztc); file->private_data = ztc; break; case ZT_TCOP_RELEASE: ret = ztc->parent->operation(ztc, ZT_TCOP_RELEASE); - if (ztc->flags.have_reference) { - module_put(ztc->parent->owner); - ztc->flags.have_reference = 0; - } + break; + case ZT_TCOP_TEST: + ret = ztc->parent->operation(ztc, ZT_TCOP_TEST); break; case ZT_TCOP_TRANSCODE: if (!ztc->parent->operation) return -EINVAL; - ztc->tch->busy = 1; + ztc->tch->status |= ZT_TC_FLAG_BUSY; if (!(ret = ztc->parent->operation(ztc, ZT_TCOP_TRANSCODE))) { - /* Wait for busy to go away if we are in blocking mode */ + /* Wait for busy to go away if we're not non-blocking */ if (!(file->f_flags & O_NONBLOCK)) { if (!(ret = wait_busy(ztc))) ret = ztc->errorstatus; } } else - ztc->tch->busy = 0; + ztc->tch->status &= ~ZT_TC_FLAG_BUSY; break; default: ret = -ENOSYS; @@ -440,8 +423,7 @@ static unsigned int zt_tc_poll(struct file *file, struct poll_table_struct *wait return -EINVAL; poll_wait(file, &ztc->ready, wait_table); - - return ztc->tch->busy ? 0 : POLLPRI; + return ztc->tch->status & ZT_TC_FLAG_BUSY ? 0 : POLLPRI; } struct file_operations __zt_transcode_fops = { -- cgit v1.2.3