[dahdi-commits] sruffell: branch linux/sruffell/dahdi-linux-stackreduction r7077 - in /linux/...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Tue Aug 25 13:36:34 CDT 2009
Author: sruffell
Date: Tue Aug 25 13:36:31 2009
New Revision: 7077
URL: http://svn.asterisk.org/svn-view/dahdi?view=rev&rev=7077
Log:
wctdm24xxp: Reduce stack usage of wctdm_ioctl.
Modified:
linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/Kbuild
linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/wctdm24xxp/base.c
Modified: linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/Kbuild
URL: http://svn.asterisk.org/svn-view/dahdi/linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/Kbuild?view=diff&rev=7077&r1=7076&r2=7077
==============================================================================
--- linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/Kbuild (original)
+++ linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/Kbuild Tue Aug 25 13:36:31 2009
@@ -5,7 +5,7 @@
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_DYNAMIC_ETH) += dahdi_dynamic_eth.o
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_TRANSCODE) += dahdi_transcode.o
-obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCT4XXP) += wct4xxp/
+#obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCT4XXP) += wct4xxp/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTC4XXP) += wctc4xxp/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTDM24XXP) += wctdm24xxp/
obj-$(DAHDI_BUILD_ALL)$(CONFIG_DAHDI_WCTE12XP) += wcte12xp/
Modified: linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/wctdm24xxp/base.c
URL: http://svn.asterisk.org/svn-view/dahdi/linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=7077&r1=7076&r2=7077
==============================================================================
--- linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/team/sruffell/dahdi-linux-stackreduction/drivers/dahdi/wctdm24xxp/base.c Tue Aug 25 13:36:31 2009
@@ -2700,49 +2700,313 @@
return;
}
-static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long data)
-{
+static int wctdm_ioctl_onhooktransfer(struct dahdi_chan *chan,
+ unsigned long data)
+{
+ struct wctdm *wc = chan->pvt;
+ struct fxs *const fxs = &wc->mods[chan->chanpos - 1].fxs;
+ int x;
+
+ if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
+ return -EINVAL;
+ if (get_user(x, (__user int *) data))
+ return -EFAULT;
+ fxs->ohttimer = x << 3;
+
+ /* Active mode when idle */
+ fxs->idletxhookstate = POLARITY_XOR(chan->chanpos - 1) ?
+ SLIC_LF_ACTIVE_REV :
+ SLIC_LF_ACTIVE_FWD;
+
+ if ((fxs->lasttxhook == SLIC_LF_ACTIVE_FWD) ||
+ (fxs->lasttxhook == SLIC_LF_ACTIVE_REV)) {
+
+ /* Apply the change if appropriate */
+ fxs->lasttxhook = 0x10 |
+ POLARITY_XOR(chan->chanpos - 1) ?
+ SLIC_LF_OHTRAN_REV :
+ SLIC_LF_OHTRAN_FWD;
+
+ wc->sethook[chan->chanpos - 1] =
+ CMD_WR(64, fxs->lasttxhook);
+ /* wctdm_setreg(wc, chan->chanpos - 1, 64,
+ * fxs->lasttxhook); */
+ }
+ return 0;
+}
+
+static int wctdm_ioctl_get_stats(struct dahdi_chan *chan, unsigned long data)
+{
+ struct wctdm *wc = chan->pvt;
struct wctdm_stats stats;
+ const int channel = chan->chanpos - 1;
+
+ if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) {
+ stats.tipvolt = wctdm_getreg(wc, channel, 80) * -376;
+ stats.ringvolt = wctdm_getreg(wc, channel, 81) * -376;
+ stats.batvolt = wctdm_getreg(wc, channel, 82) * -376;
+ } else if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXO) {
+ stats.tipvolt = (s8)wctdm_getreg(wc, channel, 29) * 1000;
+ stats.ringvolt = (s8)wctdm_getreg(wc, channel, 29) * 1000;
+ stats.batvolt = (s8)wctdm_getreg(wc, channel, 29) * 1000;
+ } else {
+ return -EINVAL;
+ }
+
+ if (copy_to_user((__user void *) data, &stats, sizeof(stats)))
+ return -EFAULT;
+
+ return 0;
+}
+
+static int wctdm_ioctl_get_regs(struct dahdi_chan *chan, unsigned long data)
+{
+ struct wctdm *wc = chan->pvt;
struct wctdm_regs regs;
+ int x;
+
+ if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) {
+ for (x = 0; x < NUM_INDIRECT_REGS; ++x)
+ regs.indirect[x] = wctdm_proslic_getreg_indirect(wc,
+ chan->chanpos-1, x);
+ for (x = 0; x < NUM_REGS; ++x)
+ regs.direct[x] = wctdm_getreg(wc, chan->chanpos - 1, x);
+ } else if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_QRV) {
+ memset(®s, 0, sizeof(regs));
+ for (x = 0; x < 0x32; ++x)
+ regs.direct[x] = wctdm_getreg(wc, chan->chanpos - 1, x);
+ } else {
+ memset(®s, 0, sizeof(regs));
+ for (x = 0; x < NUM_FXO_REGS; ++x)
+ regs.direct[x] = wctdm_getreg(wc, chan->chanpos - 1, x);
+ }
+ if (copy_to_user((__user void *)data, ®s, sizeof(regs)))
+ return -EFAULT;
+ return 0;
+}
+
+static int wctdm_ioctl_set_regs(struct dahdi_chan *chan, unsigned long data)
+{
+ struct wctdm *wc = chan->pvt;
struct wctdm_regop regop;
+ struct fxs *const fxs = &wc->mods[chan->chanpos - 1].fxs;
+
+ if (copy_from_user(®op, (__user void *) data, sizeof(regop)))
+ return -EFAULT;
+ if (regop.indirect) {
+ if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
+ return -EINVAL;
+
+ printk(KERN_INFO "Setting indirect %d to 0x%04x on %d\n",
+ regop.reg, regop.val, chan->chanpos);
+
+ wctdm_proslic_setreg_indirect(wc, chan->chanpos - 1,
+ regop.reg, regop.val);
+ } else {
+ regop.val &= 0xff;
+
+ if (regop.reg == 64)
+ fxs->lasttxhook = (regop.val & 0x0f) | 0x10;
+
+ printk(KERN_INFO "Setting direct %d to %04x on %d\n",
+ regop.reg, regop.val, chan->chanpos);
+
+ wctdm_setreg(wc, chan->chanpos - 1, regop.reg, regop.val);
+ }
+ return 0;
+}
+
+static int wctdm_ioctl_set_echotune(struct dahdi_chan *chan, unsigned long data)
+{
+ struct wctdm *wc = chan->pvt;
struct wctdm_echo_coefs echoregs;
+
+ printk(KERN_INFO "-- Setting echo registers: \n");
+ if (copy_from_user(&echoregs, (__user void *) data, sizeof(echoregs)))
+ return -EFAULT;
+
+ if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXO)
+ return -EINVAL;
+
+ /* Set the ACIM register */
+ wctdm_setreg(wc, chan->chanpos - 1, 30, echoregs.acim);
+
+ /* Set the digital echo canceller registers */
+ wctdm_setreg(wc, chan->chanpos - 1, 45, echoregs.coef1);
+ wctdm_setreg(wc, chan->chanpos - 1, 46, echoregs.coef2);
+ wctdm_setreg(wc, chan->chanpos - 1, 47, echoregs.coef3);
+ wctdm_setreg(wc, chan->chanpos - 1, 48, echoregs.coef4);
+ wctdm_setreg(wc, chan->chanpos - 1, 49, echoregs.coef5);
+ wctdm_setreg(wc, chan->chanpos - 1, 50, echoregs.coef6);
+ wctdm_setreg(wc, chan->chanpos - 1, 51, echoregs.coef7);
+ wctdm_setreg(wc, chan->chanpos - 1, 52, echoregs.coef8);
+
+ printk(KERN_INFO "-- Set echo registers successfully\n");
+
+ return 0;
+}
+
+static int wctdm_ioctl_radio_getparam(struct dahdi_chan *chan,
+ unsigned long data)
+{
+ struct wctdm *wc = chan->pvt;
+ struct dahdi_radio_param p;
+
+ if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_QRV)
+ return -ENOTTY;
+
+ if (copy_from_user(&p, (__user void *)data, sizeof(p)))
+ return -EFAULT;
+
+ p.data = 0; /* start with 0 value in output */
+
+ switch (p.radpar) {
+ case DAHDI_RADPAR_INVERTCOR:
+ if (wc->radmode[chan->chanpos - 1] & RADMODE_INVERTCOR)
+ p.data = 1;
+ break;
+ case DAHDI_RADPAR_IGNORECOR:
+ if (wc->radmode[chan->chanpos - 1] & RADMODE_IGNORECOR)
+ p.data = 1;
+ break;
+ case DAHDI_RADPAR_IGNORECT:
+ if (wc->radmode[chan->chanpos - 1] & RADMODE_IGNORECT)
+ p.data = 1;
+ break;
+ case DAHDI_RADPAR_EXTRXTONE:
+ p.data = 0;
+ if (wc->radmode[chan->chanpos - 1] & RADMODE_EXTTONE) {
+ p.data = 1;
+ if (wc->radmode[chan->chanpos - 1] & RADMODE_EXTINVERT)
+ p.data = 2;
+ }
+ break;
+ case DAHDI_RADPAR_DEBOUNCETIME:
+ p.data = wc->debouncetime[chan->chanpos - 1];
+ break;
+ case DAHDI_RADPAR_RXGAIN:
+ p.data = wc->rxgain[chan->chanpos - 1] - 1199;
+ break;
+ case DAHDI_RADPAR_TXGAIN:
+ p.data = wc->txgain[chan->chanpos - 1] - 3599;
+ break;
+ case DAHDI_RADPAR_DEEMP:
+ p.data = 0;
+ if (wc->radmode[chan->chanpos - 1] & RADMODE_DEEMP)
+ p.data = 1;
+ break;
+ case DAHDI_RADPAR_PREEMP:
+ p.data = 0;
+ if (wc->radmode[chan->chanpos - 1] & RADMODE_PREEMP)
+ p.data = 1;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (copy_to_user((__user void *)data, &p, sizeof(p)))
+ return -EFAULT;
+
+ return 0;
+}
+
+static int wctdm_ioctl_radio_setparam(struct dahdi_chan *chan,
+ unsigned long data)
+{
+ struct wctdm *wc = chan->pvt;
+ struct dahdi_radio_param p;
+
+ if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_QRV)
+ return -ENOTTY;
+
+ if (copy_from_user(&p, (__user void *)data, sizeof(p)))
+ return -EFAULT;
+
+ switch (p.radpar) {
+ case DAHDI_RADPAR_INVERTCOR:
+ if (p.data)
+ wc->radmode[chan->chanpos - 1] |= RADMODE_INVERTCOR;
+ else
+ wc->radmode[chan->chanpos - 1] &= ~RADMODE_INVERTCOR;
+ return 0;
+ case DAHDI_RADPAR_IGNORECOR:
+ if (p.data)
+ wc->radmode[chan->chanpos - 1] |= RADMODE_IGNORECOR;
+ else
+ wc->radmode[chan->chanpos - 1] &= ~RADMODE_IGNORECOR;
+ return 0;
+ case DAHDI_RADPAR_IGNORECT:
+ if (p.data)
+ wc->radmode[chan->chanpos - 1] |= RADMODE_IGNORECT;
+ else
+ wc->radmode[chan->chanpos - 1] &= ~RADMODE_IGNORECT;
+ return 0;
+ case DAHDI_RADPAR_EXTRXTONE:
+ if (p.data)
+ wc->radmode[chan->chanpos - 1] |= RADMODE_EXTTONE;
+ else
+ wc->radmode[chan->chanpos - 1] &= ~RADMODE_EXTTONE;
+
+ if (p.data > 1)
+ wc->radmode[chan->chanpos - 1] |= RADMODE_EXTINVERT;
+ else
+ wc->radmode[chan->chanpos - 1] &= ~RADMODE_EXTINVERT;
+
+ return 0;
+ case DAHDI_RADPAR_DEBOUNCETIME:
+ wc->debouncetime[chan->chanpos - 1] = p.data;
+ return 0;
+ case DAHDI_RADPAR_RXGAIN:
+ /* if out of range */
+ if ((p.data <= -1200) || (p.data > 1552))
+ return -EINVAL;
+
+ wc->rxgain[chan->chanpos - 1] = p.data + 1199;
+ break;
+ case DAHDI_RADPAR_TXGAIN:
+ /* if out of range */
+ if (wc->radmode[chan->chanpos - 1] & RADMODE_PREEMP) {
+ if ((p.data <= -2400) || (p.data > 0))
+ return -EINVAL;
+ } else {
+ if ((p.data <= -3600) || (p.data > 1200))
+ return -EINVAL;
+ }
+ wc->txgain[chan->chanpos - 1] = p.data + 3599;
+ break;
+ case DAHDI_RADPAR_DEEMP:
+ if (p.data)
+ wc->radmode[chan->chanpos - 1] |= RADMODE_DEEMP;
+ else
+ wc->radmode[chan->chanpos - 1] &= ~RADMODE_DEEMP;
+ wc->rxgain[chan->chanpos - 1] = 1199;
+ break;
+ case DAHDI_RADPAR_PREEMP:
+ if (p.data)
+ wc->radmode[chan->chanpos - 1] |= RADMODE_PREEMP;
+ else
+ wc->radmode[chan->chanpos - 1] &= ~RADMODE_PREEMP;
+ wc->txgain[chan->chanpos - 1] = 3599;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ qrv_dosetup(chan, wc);
+ return 0;
+}
+
+static int wctdm_ioctl(struct dahdi_chan *chan,
+ unsigned int cmd, unsigned long data)
+{
struct dahdi_hwgain hwgain;
struct wctdm *wc = chan->pvt;
+ struct fxs *const fxs = &wc->mods[chan->chanpos - 1].fxs;
int x;
- union {
- struct dahdi_radio_stat s;
- struct dahdi_radio_param p;
- } stack;
- struct fxs *const fxs = &wc->mods[chan->chanpos - 1].fxs;
switch (cmd) {
case DAHDI_ONHOOKTRANSFER:
- if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
- return -EINVAL;
- if (get_user(x, (__user int *) data))
- return -EFAULT;
- fxs->ohttimer = x << 3;
-
- /* Active mode when idle */
- fxs->idletxhookstate = POLARITY_XOR(chan->chanpos - 1) ?
- SLIC_LF_ACTIVE_REV :
- SLIC_LF_ACTIVE_FWD;
-
- if ((fxs->lasttxhook == SLIC_LF_ACTIVE_FWD) ||
- (fxs->lasttxhook == SLIC_LF_ACTIVE_REV)) {
-
- /* Apply the change if appropriate */
- fxs->lasttxhook = 0x10 |
- POLARITY_XOR(chan->chanpos - 1) ?
- SLIC_LF_OHTRAN_REV :
- SLIC_LF_OHTRAN_FWD;
-
- wc->sethook[chan->chanpos - 1] =
- CMD_WR(64, fxs->lasttxhook);
- /* wctdm_setreg(wc, chan->chanpos - 1, 64,
- * fxs->lasttxhook); */
- }
- break;
+ return wctdm_ioctl_onhooktransfer(chan, data);
case DAHDI_VMWI_CONFIG:
if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
return -EINVAL;
@@ -2763,81 +3027,13 @@
set_vmwi(wc, chan->chanpos - 1);
break;
case WCTDM_GET_STATS:
- if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) {
- stats.tipvolt = wctdm_getreg(wc, chan->chanpos - 1, 80) * -376;
- stats.ringvolt = wctdm_getreg(wc, chan->chanpos - 1, 81) * -376;
- stats.batvolt = wctdm_getreg(wc, chan->chanpos - 1, 82) * -376;
- } else if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXO) {
- stats.tipvolt = (signed char)wctdm_getreg(wc, chan->chanpos - 1, 29) * 1000;
- stats.ringvolt = (signed char)wctdm_getreg(wc, chan->chanpos - 1, 29) * 1000;
- stats.batvolt = (signed char)wctdm_getreg(wc, chan->chanpos - 1, 29) * 1000;
- } else
- return -EINVAL;
- if (copy_to_user((__user void *) data, &stats, sizeof(stats)))
- return -EFAULT;
- break;
+ return wctdm_ioctl_get_stats(chan, data);
case WCTDM_GET_REGS:
- if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) {
- for (x=0;x<NUM_INDIRECT_REGS;x++)
- regs.indirect[x] = wctdm_proslic_getreg_indirect(wc, chan->chanpos -1, x);
- for (x=0;x<NUM_REGS;x++)
- regs.direct[x] = wctdm_getreg(wc, chan->chanpos - 1, x);
- } else if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_QRV) {
- memset(®s, 0, sizeof(regs));
- for (x=0;x<0x32;x++)
- regs.direct[x] = wctdm_getreg(wc, chan->chanpos - 1, x);
- } else {
- memset(®s, 0, sizeof(regs));
- for (x=0;x<NUM_FXO_REGS;x++)
- regs.direct[x] = wctdm_getreg(wc, chan->chanpos - 1, x);
- }
- if (copy_to_user((__user void *)data, ®s, sizeof(regs)))
- return -EFAULT;
- break;
+ return wctdm_ioctl_get_regs(chan, data);
case WCTDM_SET_REG:
- if (copy_from_user(®op, (__user void *) data, sizeof(regop)))
- return -EFAULT;
- if (regop.indirect) {
- if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
- return -EINVAL;
- printk(KERN_INFO "Setting indirect %d to 0x%04x on %d\n", regop.reg, regop.val, chan->chanpos);
- wctdm_proslic_setreg_indirect(wc, chan->chanpos - 1, regop.reg, regop.val);
- } else {
- regop.val &= 0xff;
- if (regop.reg == 64)
- fxs->lasttxhook = (regop.val & 0x0f) | 0x10;
-
- printk(KERN_INFO "Setting direct %d to %04x on %d\n", regop.reg, regop.val, chan->chanpos);
- wctdm_setreg(wc, chan->chanpos - 1, regop.reg, regop.val);
- }
- break;
+ return wctdm_ioctl_set_regs(chan, data);
case WCTDM_SET_ECHOTUNE:
- printk(KERN_INFO "-- Setting echo registers: \n");
- if (copy_from_user(&echoregs, (__user void *) data, sizeof(echoregs)))
- return -EFAULT;
-
- if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXO) {
- /* Set the ACIM register */
- wctdm_setreg(wc, chan->chanpos - 1, 30, echoregs.acim);
-
- /* Set the digital echo canceller registers */
- wctdm_setreg(wc, chan->chanpos - 1, 45, echoregs.coef1);
- wctdm_setreg(wc, chan->chanpos - 1, 46, echoregs.coef2);
- wctdm_setreg(wc, chan->chanpos - 1, 47, echoregs.coef3);
- wctdm_setreg(wc, chan->chanpos - 1, 48, echoregs.coef4);
- wctdm_setreg(wc, chan->chanpos - 1, 49, echoregs.coef5);
- wctdm_setreg(wc, chan->chanpos - 1, 50, echoregs.coef6);
- wctdm_setreg(wc, chan->chanpos - 1, 51, echoregs.coef7);
- wctdm_setreg(wc, chan->chanpos - 1, 52, echoregs.coef8);
-
- printk(KERN_INFO "-- Set echo registers successfully\n");
-
- break;
- } else {
- return -EINVAL;
-
- }
- break;
+ return wctdm_ioctl_set_echotune(chan, data);
case DAHDI_SET_HWGAIN:
if (copy_from_user(&hwgain, (__user void *) data, sizeof(hwgain)))
return -EFAULT;
@@ -2878,146 +3074,9 @@
wc->sethook[chan->chanpos - 1] = CMD_WR(64, fxs->lasttxhook);
break;
case DAHDI_RADIO_GETPARAM:
- if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_QRV)
- return -ENOTTY;
- if (copy_from_user(&stack.p, (__user void *) data, sizeof(stack.p)))
- return -EFAULT;
- stack.p.data = 0; /* start with 0 value in output */
- switch(stack.p.radpar) {
- case DAHDI_RADPAR_INVERTCOR:
- if (wc->radmode[chan->chanpos - 1] & RADMODE_INVERTCOR)
- stack.p.data = 1;
- break;
- case DAHDI_RADPAR_IGNORECOR:
- if (wc->radmode[chan->chanpos - 1] & RADMODE_IGNORECOR)
- stack.p.data = 1;
- break;
- case DAHDI_RADPAR_IGNORECT:
- if (wc->radmode[chan->chanpos - 1] & RADMODE_IGNORECT)
- stack.p.data = 1;
- break;
- case DAHDI_RADPAR_EXTRXTONE:
- stack.p.data = 0;
- if (wc->radmode[chan->chanpos - 1] & RADMODE_EXTTONE)
- {
- stack.p.data = 1;
- if (wc->radmode[chan->chanpos - 1] & RADMODE_EXTINVERT)
- {
- stack.p.data = 2;
- }
- }
- break;
- case DAHDI_RADPAR_DEBOUNCETIME:
- stack.p.data = wc->debouncetime[chan->chanpos - 1];
- break;
- case DAHDI_RADPAR_RXGAIN:
- stack.p.data = wc->rxgain[chan->chanpos - 1] - 1199;
- break;
- case DAHDI_RADPAR_TXGAIN:
- stack.p.data = wc->txgain[chan->chanpos - 1] - 3599;
- break;
- case DAHDI_RADPAR_DEEMP:
- stack.p.data = 0;
- if (wc->radmode[chan->chanpos - 1] & RADMODE_DEEMP)
- {
- stack.p.data = 1;
- }
- break;
- case DAHDI_RADPAR_PREEMP:
- stack.p.data = 0;
- if (wc->radmode[chan->chanpos - 1] & RADMODE_PREEMP)
- {
- stack.p.data = 1;
- }
- break;
- default:
- return -EINVAL;
- }
- if (copy_to_user((__user void *) data, &stack.p, sizeof(stack.p)))
- return -EFAULT;
- break;
+ return wctdm_ioctl_radio_getparam(chan, data);
case DAHDI_RADIO_SETPARAM:
- if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_QRV)
- return -ENOTTY;
- if (copy_from_user(&stack.p, (__user void *) data, sizeof(stack.p)))
- return -EFAULT;
- switch(stack.p.radpar) {
- case DAHDI_RADPAR_INVERTCOR:
- if (stack.p.data)
- wc->radmode[chan->chanpos - 1] |= RADMODE_INVERTCOR;
- else
- wc->radmode[chan->chanpos - 1] &= ~RADMODE_INVERTCOR;
- return 0;
- case DAHDI_RADPAR_IGNORECOR:
- if (stack.p.data)
- wc->radmode[chan->chanpos - 1] |= RADMODE_IGNORECOR;
- else
- wc->radmode[chan->chanpos - 1] &= ~RADMODE_IGNORECOR;
- return 0;
- case DAHDI_RADPAR_IGNORECT:
- if (stack.p.data)
- wc->radmode[chan->chanpos - 1] |= RADMODE_IGNORECT;
- else
- wc->radmode[chan->chanpos - 1] &= ~RADMODE_IGNORECT;
- return 0;
- case DAHDI_RADPAR_EXTRXTONE:
- if (stack.p.data)
- wc->radmode[chan->chanpos - 1] |= RADMODE_EXTTONE;
- else
- wc->radmode[chan->chanpos - 1] &= ~RADMODE_EXTTONE;
- if (stack.p.data > 1)
- wc->radmode[chan->chanpos - 1] |= RADMODE_EXTINVERT;
- else
- wc->radmode[chan->chanpos - 1] &= ~RADMODE_EXTINVERT;
- return 0;
- case DAHDI_RADPAR_DEBOUNCETIME:
- wc->debouncetime[chan->chanpos - 1] = stack.p.data;
- return 0;
- case DAHDI_RADPAR_RXGAIN:
- /* if out of range */
- if ((stack.p.data <= -1200) || (stack.p.data > 1552))
- {
- return -EINVAL;
- }
- wc->rxgain[chan->chanpos - 1] = stack.p.data + 1199;
- break;
- case DAHDI_RADPAR_TXGAIN:
- /* if out of range */
- if (wc->radmode[chan->chanpos -1] & RADMODE_PREEMP)
- {
- if ((stack.p.data <= -2400) || (stack.p.data > 0))
- {
- return -EINVAL;
- }
- }
- else
- {
- if ((stack.p.data <= -3600) || (stack.p.data > 1200))
- {
- return -EINVAL;
- }
- }
- wc->txgain[chan->chanpos - 1] = stack.p.data + 3599;
- break;
- case DAHDI_RADPAR_DEEMP:
- if (stack.p.data)
- wc->radmode[chan->chanpos - 1] |= RADMODE_DEEMP;
- else
- wc->radmode[chan->chanpos - 1] &= ~RADMODE_DEEMP;
- wc->rxgain[chan->chanpos - 1] = 1199;
- break;
- case DAHDI_RADPAR_PREEMP:
- if (stack.p.data)
- wc->radmode[chan->chanpos - 1] |= RADMODE_PREEMP;
- else
- wc->radmode[chan->chanpos - 1] &= ~RADMODE_PREEMP;
- wc->txgain[chan->chanpos - 1] = 3599;
- break;
- default:
- return -EINVAL;
- }
- qrv_dosetup(chan,wc);
- return 0;
+ return wctdm_ioctl_radio_setparam(chan, data);
default:
return -ENOTTY;
}
More information about the dahdi-commits
mailing list