diff options
author | Shaun Ruffell <sruffell@digium.com> | 2010-09-20 20:30:49 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2010-09-20 20:30:49 +0000 |
commit | a13372d29d628f2f56f2a111f69ef6c1a7bb10c5 (patch) | |
tree | 07008e2f00f77ea68cfd026c38932656fb081acb | |
parent | 1960c8563955d13ac543d09eb2e4e6a65a754afc (diff) |
dahdi_cfg: DAHDI_INDIRECT -> DAHDI_SPECIFY when configuring pciradio channels.
While slightly less efficient, this is only used when configuring the
channels initially (not the hot path) and allows dahdi-base.c to assume
that the open "file" pointer always refers to the channel on which to
perform the operation.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@9352 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r-- | dahdi_cfg.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/dahdi_cfg.c b/dahdi_cfg.c index 9386e00..f8ae052 100644 --- a/dahdi_cfg.c +++ b/dahdi_cfg.c @@ -176,16 +176,6 @@ static const char *sigtype_to_str(const int sig) } } -int ind_ioctl(int channo, int fd, int op, void *data) -{ - struct dahdi_indirect_data ind; - - ind.chan = channo; - ind.op = op; - ind.data = data; - return ioctl(fd, DAHDI_INDIRECT, &ind); -} - static void clear_fields() { @@ -1091,6 +1081,7 @@ static int rad_chanconfig(char *keyword, char *args) int res = 0; int x,i,n; struct dahdi_radio_param p; + int chanfd; toneindex = 1; bzero(chans, sizeof(chans)); @@ -1099,8 +1090,21 @@ static int rad_chanconfig(char *keyword, char *args) return -1; for (x=1;x<DAHDI_MAX_CHANNELS;x++) { if (chans[x]) { + const char *CHANNEL_FILENAME = "/dev/dahdi/channel"; + chanfd = open(CHANNEL_FILENAME, O_RDWR); + if (-1 == chanfd) { + error("Failed to open '%s'.\n", CHANNEL_FILENAME); + exit(-1); + } + + res = ioctl(chanfd, DAHDI_SPECIFY, &x); + if (res) { + error("Failed to open channel %d.\n", x); + close(chanfd); + continue; + } p.radpar = DAHDI_RADPAR_NUMTONES; - if (ind_ioctl(x,fd,DAHDI_RADIO_GETPARAM,&p) == -1) + if (ioctl(chanfd,DAHDI_RADIO_GETPARAM,&p) == -1) n = 0; else n = p.data; @@ -1108,7 +1112,7 @@ static int rad_chanconfig(char *keyword, char *args) if (n) { p.radpar = DAHDI_RADPAR_INITTONE; - if (ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p) == -1) { + if (ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p) == -1) { error("Cannot init tones for channel %d\n",x); } if (!rxtones[0]) for(i = 1; i <= n; i++) @@ -1118,7 +1122,7 @@ static int rad_chanconfig(char *keyword, char *args) p.radpar = DAHDI_RADPAR_RXTONE; p.index = i; p.data = rxtones[i]; - if (ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p) == -1) + if (ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p) == -1) error("Cannot set rxtone on channel %d\n",x); } if (rxtags[i]) @@ -1126,7 +1130,7 @@ static int rad_chanconfig(char *keyword, char *args) p.radpar = DAHDI_RADPAR_RXTONECLASS; p.index = i; p.data = rxtags[i]; - if (ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p) == -1) + if (ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p) == -1) error("Cannot set rxtag on channel %d\n",x); } if (txtones[i]) @@ -1134,7 +1138,7 @@ static int rad_chanconfig(char *keyword, char *args) p.radpar = DAHDI_RADPAR_TXTONE; p.index = i; p.data = txtones[i]; - if (ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p) == -1) + if (ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p) == -1) error("Cannot set txtone on channel %d\n",x); } } else { /* if we may have DCS receive */ @@ -1143,7 +1147,7 @@ static int rad_chanconfig(char *keyword, char *args) p.radpar = DAHDI_RADPAR_RXTONE; p.index = 0; p.data = rxtones[0]; - if (ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p) == -1) + if (ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p) == -1) error("Cannot set DCS rxtone on channel %d\n",x); } } @@ -1152,7 +1156,7 @@ static int rad_chanconfig(char *keyword, char *args) p.radpar = DAHDI_RADPAR_TXTONE; p.index = 0; p.data = txtones[0]; - if (ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p) == -1) + if (ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p) == -1) error("Cannot set default txtone on channel %d\n",x); } } @@ -1160,41 +1164,43 @@ static int rad_chanconfig(char *keyword, char *args) { p.radpar = DAHDI_RADPAR_DEBOUNCETIME; p.data = debouncetime; - if (ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p) == -1) + if (ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p) == -1) error("Cannot set debouncetime on channel %d\n",x); } if (bursttime) { p.radpar = DAHDI_RADPAR_BURSTTIME; p.data = bursttime; - if (ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p) == -1) + if (ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p) == -1) error("Cannot set bursttime on channel %d\n",x); } p.radpar = DAHDI_RADPAR_DEEMP; p.data = deemp; - ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p); + ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p); p.radpar = DAHDI_RADPAR_PREEMP; p.data = preemp; - ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p); + ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p); p.radpar = DAHDI_RADPAR_TXGAIN; p.data = txgain; - ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p); + ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p); p.radpar = DAHDI_RADPAR_RXGAIN; p.data = rxgain; - ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p); + ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p); p.radpar = DAHDI_RADPAR_INVERTCOR; p.data = invertcor; - ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p); + ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p); p.radpar = DAHDI_RADPAR_EXTRXTONE; p.data = exttone; - ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p); + ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p); if (corthresh) { p.radpar = DAHDI_RADPAR_CORTHRESH; p.data = corthresh - 1; - if (ind_ioctl(x,fd,DAHDI_RADIO_SETPARAM,&p) == -1) + if (ioctl(chanfd,DAHDI_RADIO_SETPARAM,&p) == -1) error("Cannot set corthresh on channel %d\n",x); } + + close(chanfd); } } clear_fields(); |