Commit e878bc06 authored by Shaun Ruffell's avatar Shaun Ruffell

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: default avatarShaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.astersk.org/svn/dahdi/tools/trunk@9352 17933a7a-c749-41c5-a318-cba88f637d49
parent 1462933a
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment