127 #include <linux/slab.h>
181 " - member = %s (slot_tx %d, bank_tx %d, "
182 "slot_rx %d, bank_rx %d hfc_conf %d "
183 "tx_data %d rx_is_off %d)%s\n",
184 member->
dsp->name, member->
dsp->pcm_slot_tx,
185 member->
dsp->pcm_bank_tx, member->
dsp->pcm_slot_rx,
186 member->
dsp->pcm_bank_rx, member->
dsp->hfc_conf,
187 member->
dsp->tx_data, member->
dsp->rx_is_off,
188 (member->
dsp == dsp) ?
" *this*" :
"");
198 dsp_cmx_search_conf(
u32 id)
255 dsp->member = member;
281 if (list_empty(&dsp->
conf->mlist)) {
289 if (member->
dsp == dsp) {
298 "%s: dsp is not present in its own conf_meber list.\n",
309 *dsp_cmx_new_conf(
u32 id)
324 INIT_LIST_HEAD(&conf->
mlist);
345 if (!list_empty(&conf->
mlist)) {
366 memset(&cq, 0,
sizeof(cq));
368 cq.p1 = param1 | (param2 << 8);
369 cq.p2 = param3 | (param4 << 8);
388 int memb = 0,
i, ii, i1, i2;
391 int same_hfc = -1, same_pcm = -1, current_conf = -1,
400 __func__, dsp->
name);
406 "%s removing %s from HFC conf %d "
407 "because dsp is split\n", __func__,
416 if (!dsp->
echo.software && !dsp->
echo.hardware) {
421 " PCM slot %d (TX) %d (RX) because"
422 " dsp is split (no echo)\n",
436 dsp->
echo.hardware = 0;
440 dsp->
echo.hardware = 1;
450 "%s refresh %s for echo using slot %d\n",
455 dsp->
echo.hardware = 1;
461 memset(freeslots, 1,
sizeof(freeslots));
482 "%s no slot available for echo\n",
485 dsp->
echo.software = 1;
495 "%s assign echo for %s using slot %d\n",
499 dsp->
echo.hardware = 1;
508 if (list_empty(&conf->
mlist)) {
514 same_hfc = member->
dsp->features.hfc_id;
515 same_pcm = member->
dsp->features.pcm_id;
519 if (member->
dsp->tx_mix) {
522 "%s dsp %s cannot form a conf, because "
523 "tx_mix is turned on\n", __func__,
532 "%s removing %s from HFC "
533 "conf %d because not "
534 "possible with hardware\n",
538 dsp_cmx_hw_message(dsp,
548 "%s from PCM slot %d (TX)"
549 " slot %d (RX) because not"
550 " possible with hardware\n",
555 dsp_cmx_hw_message(dsp,
569 if (member->
dsp->echo.hardware || member->
dsp->echo.software) {
572 "%s dsp %s cannot form a conf, because "
573 "echo is turned on\n", __func__,
578 if (member->
dsp->tx_mix) {
581 "%s dsp %s cannot form a conf, because "
582 "tx_mix is turned on\n",
583 __func__, member->
dsp->name);
587 if (member->
dsp->tx_volume) {
590 "%s dsp %s cannot form a conf, because "
591 "tx_volume is changed\n",
592 __func__, member->
dsp->name);
595 if (member->
dsp->rx_volume) {
598 "%s dsp %s cannot form a conf, because "
599 "rx_volume is changed\n",
600 __func__, member->
dsp->name);
604 if (member->
dsp->tx_data) {
607 "%s dsp %s tx_data is turned on\n",
608 __func__, member->
dsp->name);
612 if (member->
dsp->pipeline.inuse) {
615 "%s dsp %s cannot form a conf, because "
616 "pipeline exists\n", __func__,
621 if (member->
dsp->bf_enable) {
624 "conf, because encryption is enabled\n",
625 __func__, member->
dsp->name);
629 if (member->
dsp->features.pcm_id < 0) {
632 "%s dsp %s cannot form a conf, because "
633 "dsp has no PCM bus\n",
634 __func__, member->
dsp->name);
638 if (member->
dsp->features.pcm_id != same_pcm) {
641 "%s dsp %s cannot form a conf, because "
642 "dsp is on a different PCM bus than the "
644 __func__, member->
dsp->name);
648 if (same_hfc != member->
dsp->features.hfc_id)
651 if (current_conf < 0 && member->dsp->
hfc_conf >= 0)
652 current_conf = member->
dsp->hfc_conf;
654 if (member->
dsp->hfc_conf < 0)
668 "%s conf %d cannot form a HW conference, "
669 "because dsp is alone\n", __func__, conf->
id);
691 if (member->
dsp->hfc_conf >= 0) {
694 "%s removing %s from HFC conf %d because "
695 "two parties require only a PCM slot\n",
696 __func__, member->
dsp->name,
697 member->
dsp->hfc_conf);
698 dsp_cmx_hw_message(member->
dsp,
700 member->
dsp->hfc_conf = -1;
702 if (nextm->
dsp->hfc_conf >= 0) {
705 "%s removing %s from HFC conf %d because "
706 "two parties require only a PCM slot\n",
707 __func__, nextm->
dsp->name,
708 nextm->
dsp->hfc_conf);
709 dsp_cmx_hw_message(nextm->
dsp,
711 nextm->
dsp->hfc_conf = -1;
714 if (member->
dsp->features.pcm_banks > 1 &&
715 nextm->
dsp->features.pcm_banks > 1 &&
716 member->
dsp->features.hfc_id !=
717 nextm->
dsp->features.hfc_id) {
719 if (member->
dsp->pcm_slot_tx >= 0 &&
720 member->
dsp->pcm_slot_rx >= 0 &&
721 nextm->
dsp->pcm_slot_tx >= 0 &&
722 nextm->
dsp->pcm_slot_rx >= 0 &&
723 nextm->
dsp->pcm_slot_tx ==
724 member->
dsp->pcm_slot_rx &&
725 nextm->
dsp->pcm_slot_rx ==
726 member->
dsp->pcm_slot_tx &&
727 nextm->
dsp->pcm_slot_tx ==
728 member->
dsp->pcm_slot_tx &&
729 member->
dsp->pcm_bank_tx !=
730 member->
dsp->pcm_bank_rx &&
731 nextm->
dsp->pcm_bank_tx !=
732 nextm->
dsp->pcm_bank_rx) {
736 "%s dsp %s & %s stay joined on "
737 "PCM slot %d bank %d (TX) bank %d "
738 "(RX) (on different chips)\n",
742 member->
dsp->pcm_slot_tx,
743 member->
dsp->pcm_bank_tx,
744 member->
dsp->pcm_bank_rx);
750 memset(freeslots, 1,
sizeof(freeslots));
752 if (dsp != member->
dsp &&
754 member->
dsp->features.pcm_id ==
767 ii = member->
dsp->features.pcm_slots;
776 "%s no slot available for "
777 "%s & %s\n", __func__,
784 member->
dsp->pcm_slot_tx =
i;
785 member->
dsp->pcm_slot_rx =
i;
786 nextm->
dsp->pcm_slot_tx =
i;
787 nextm->
dsp->pcm_slot_rx =
i;
788 member->
dsp->pcm_bank_rx = 0;
789 member->
dsp->pcm_bank_tx = 1;
790 nextm->
dsp->pcm_bank_rx = 1;
791 nextm->
dsp->pcm_bank_tx = 0;
794 "%s adding %s & %s to new PCM slot %d "
795 "(TX and RX on different chips) because "
796 "both members have not same slots\n",
800 member->
dsp->pcm_slot_tx);
802 member->
dsp->pcm_slot_tx, member->
dsp->pcm_bank_tx,
803 member->
dsp->pcm_slot_rx, member->
dsp->pcm_bank_rx);
805 nextm->
dsp->pcm_slot_tx, nextm->
dsp->pcm_bank_tx,
806 nextm->
dsp->pcm_slot_rx, nextm->
dsp->pcm_bank_rx);
813 if (member->
dsp->pcm_slot_tx >= 0 &&
814 member->
dsp->pcm_slot_rx >= 0 &&
815 nextm->
dsp->pcm_slot_tx >= 0 &&
816 nextm->
dsp->pcm_slot_rx >= 0 &&
817 nextm->
dsp->pcm_slot_tx ==
818 member->
dsp->pcm_slot_rx &&
819 nextm->
dsp->pcm_slot_rx ==
820 member->
dsp->pcm_slot_tx &&
821 member->
dsp->pcm_slot_tx !=
822 member->
dsp->pcm_slot_rx &&
823 member->
dsp->pcm_bank_tx == 0 &&
824 member->
dsp->pcm_bank_rx == 0 &&
825 nextm->
dsp->pcm_bank_tx == 0 &&
826 nextm->
dsp->pcm_bank_rx == 0) {
830 "%s dsp %s & %s stay joined on PCM "
831 "slot %d (TX) %d (RX) on same chip "
832 "or one bank PCM)\n", __func__,
835 member->
dsp->pcm_slot_tx,
836 member->
dsp->pcm_slot_rx);
842 memset(freeslots, 1,
sizeof(freeslots));
844 if (dsp != member->
dsp &&
846 member->
dsp->features.pcm_id ==
859 ii = member->
dsp->features.pcm_slots;
868 "%s no slot available "
869 "for %s & %s\n", __func__,
884 "%s no slot available "
893 member->
dsp->pcm_slot_tx = i1;
894 member->
dsp->pcm_slot_rx = i2;
895 nextm->
dsp->pcm_slot_tx = i2;
896 nextm->
dsp->pcm_slot_rx = i1;
897 member->
dsp->pcm_bank_rx = 0;
898 member->
dsp->pcm_bank_tx = 0;
899 nextm->
dsp->pcm_bank_rx = 0;
900 nextm->
dsp->pcm_bank_tx = 0;
903 "%s adding %s & %s to new PCM slot %d "
904 "(TX) %d (RX) on same chip or one bank "
905 "PCM, because both members have not "
906 "crossed slots\n", __func__,
909 member->
dsp->pcm_slot_tx,
910 member->
dsp->pcm_slot_rx);
912 member->
dsp->pcm_slot_tx, member->
dsp->pcm_bank_tx,
913 member->
dsp->pcm_slot_rx, member->
dsp->pcm_bank_rx);
915 nextm->
dsp->pcm_slot_tx, nextm->
dsp->pcm_bank_tx,
916 nextm->
dsp->pcm_slot_rx, nextm->
dsp->pcm_bank_rx);
932 "%s conference %d cannot be formed, because "
933 "members are on different chips or not "
951 if (current_conf >= 0) {
956 if (!member->
dsp->features.hfc_conf)
959 if (member->
dsp->hdlc)
962 if (member->
dsp->hfc_conf == current_conf)
965 memset(freeslots, 1,
sizeof(freeslots));
972 dsp != member->
dsp &&
974 member->
dsp->features.pcm_id ==
988 ii = member->
dsp->features.pcm_slots;
998 "%s conference %d cannot be formed,"
999 " because no slot free\n",
1000 __func__, conf->
id);
1005 "%s changing dsp %s to HW conference "
1006 "%d slot %d\n", __func__,
1007 member->
dsp->name, current_conf,
i);
1009 member->
dsp->pcm_slot_tx =
i;
1010 member->
dsp->pcm_slot_rx =
i;
1011 member->
dsp->pcm_bank_tx = 2;
1012 member->
dsp->pcm_bank_rx = 2;
1013 member->
dsp->hfc_conf = current_conf;
1016 dsp_cmx_hw_message(member->
dsp,
1027 memset(freeunits, 1,
sizeof(freeunits));
1030 if (dsp->
features.hfc_id == same_hfc &&
1048 "%s conference %d cannot be formed, because "
1049 "no conference number free\n",
1050 __func__, conf->
id);
1090 if (list_empty(&conf->
mlist)) {
1093 "conference is empty, so we remove it.\n");
1111 conf = dsp_cmx_search_conf(conf_id);
1115 "conference doesn't exist yet, creating.\n");
1117 conf = dsp_cmx_new_conf(conf_id);
1120 }
else if (!list_empty(&conf->
mlist)) {
1123 if (dsp->
hdlc && !member->
dsp->hdlc) {
1126 "cannot join transparent conference.\n");
1129 if (!dsp->
hdlc && member->
dsp->hdlc) {
1132 "cannot join hdlc conference.\n");
1137 err = dsp_cmx_add_conf_member(dsp, conf);
1143 if (list_empty(&conf->
mlist)) {
1146 "we are alone in this conference, so exit.\n");
1158 #ifdef CMX_DELAY_DEBUG
1161 showdelay(
struct dsp *dsp,
int samples,
int delay)
1163 char bar[] =
"--------------------------------------------------|";
1166 delaycount += samples;
1167 if (delaycount < 8000)
1171 sdelay = delay * 50 / (
dsp_poll << 2);
1174 sdelay > 50 ?
"..." : bar + 50 - sdelay);
1196 "%s line %d: packet from card is too large (%d bytes). "
1197 "please make card send smaller packets OR increase "
1198 "CMX_BUFF_SIZE\n", __FILE__, __LINE__, len);
1236 "cmx_receive(dsp=%lx): UNDERRUN (or overrun the "
1237 "maximum delay), adjusting read pointer! "
1240 if (dsp->features.unordered) {
1243 dsp->rx_W = (dsp->rx_R + dsp->cmx_delay)
1246 dsp->rx_W = (dsp->rx_R + (
dsp_poll >> 1))
1251 dsp->rx_W = dsp->cmx_delay;
1263 "cmx_receive(dsp=%lx): OVERRUN (because "
1264 "twice the delay is reached), adjusting "
1265 "read pointer! (inst %s)\n",
1268 if (dsp->features.unordered) {
1270 dsp->rx_W = (dsp->rx_R + dsp->cmx_delay)
1274 dsp->rx_W = dsp->cmx_delay;
1282 "cmx_receive(dsp=%lx): rx_R(dsp)=%05x rx_W(dsp)=%05x len=%d %s\n",
1283 (
u_long)dsp, dsp->
rx_R, dsp->rx_W, len, dsp->name);
1299 #ifdef CMX_DELAY_DEBUG
1309 dsp_cmx_send_member(
struct dsp *dsp,
int len,
s32 *
c,
int members)
1314 u8 *
d, *
p, *
q, *o_q;
1316 int r, rr,
t,
tt, o_r, o_rr;
1319 int tx_data_only = 0;
1326 if (((dsp->
conf && dsp->
conf->hardware) ||
1327 dsp->
echo.hardware) &&
1329 !(dsp->
tone.tone && dsp->
tone.software)) {
1334 if (dsp->
conf && dsp->
conf->software && dsp->
conf->hardware)
1336 if (dsp->
echo.software && dsp->
echo.hardware)
1342 "SEND members=%d dsp=%s, conf=%p, rx_R=%05x rx_W=%05x\n",
1354 nskb = mI_alloc_skb(len + preload,
GFP_ATOMIC);
1357 "FATAL ERROR in mISDN_dsp.o: cannot alloc %d bytes\n",
1361 hh = mISDN_HEAD_P(nskb);
1370 d =
skb_put(nskb, preload + len);
1383 if (dsp->
tone.tone && dsp->
tone.software) {
1391 if (!dsp->
tx_mix && t != tt) {
1394 sprintf(debugbuf,
"TX sending (%04x-%04x)%p: ", t, tt, p);
1396 while (r != rr && t != tt) {
1398 if (
strlen(debugbuf) < 48)
1419 if (!conf || members <= 1) {
1421 if (!dsp->
echo.software) {
1423 while (r != rr && t != tt) {
1440 while (r != rr && t != tt) {
1454 #ifdef CMX_CONF_DEBUG
1462 if (other == member)
1471 if (!dsp->
echo.software) {
1476 while (o_r != o_rr && t != tt) {
1481 while (o_r != o_rr) {
1491 while (r != rr && t != tt) {
1495 if (sample < -32768)
1497 else if (sample > 32767)
1514 #ifdef DSP_NEVER_DEFINED
1519 if (!dsp->
echo.software) {
1524 while (r != rr && t != tt) {
1527 if (sample < -32768)
1529 else if (sample > 32767)
1538 if (sample < -32768)
1540 else if (sample > 32767)
1552 while (r != rr && t != tt) {
1554 if (sample < -32768)
1556 else if (sample > 32767)
1565 if (sample < -32768)
1567 else if (sample > 32767)
1595 "FATAL ERROR in mISDN_dsp.o: "
1596 "cannot alloc %d bytes\n", len);
1598 thh = mISDN_HEAD_P(txskb);
1625 static u32 jittercount;
1628 static u16 dsp_count;
1629 static int dsp_count_valid;
1637 int mustmix, members;
1642 int jittercheck = 0,
delay,
i;
1649 if (!dsp_count_valid) {
1652 dsp_count_valid = 1;
1655 length = count - dsp_count;
1666 if (jittercount >= 8000) {
1667 jittercount -= 8000;
1679 members = count_list_member(&conf->
mlist);
1680 #ifdef CMX_CONF_DEBUG
1690 dsp_cmx_send_member(dsp, length, mixbuffer, members);
1702 members = count_list_member(&conf->
mlist);
1703 #ifdef CMX_CONF_DEBUG
1704 if (conf->
software && members > 1) {
1706 if (conf->
software && members > 2) {
1711 if (member->
dsp->hdlc)
1714 memset(mixbuffer, 0, length *
sizeof(
s32));
1732 dsp_cmx_send_member(member->
dsp, length,
1733 mixbuffer, members);
1788 "%s lowest rx_delay of %d bytes for"
1789 " dsp %s are now removed.\n",
1819 "%s lowest tx_delay of %d bytes for"
1820 " dsp %s are now removed.\n",
1849 dsp_spl_jiffies =
jiffies + 1;
1857 spin_unlock_irqrestore(&
dsp_lock, flags);
1870 char debugbuf[256] =
"";
1880 if (space < skb->len) {
1885 "%d, w=0x%04x, ww=0x%04x\n", __func__, space,
1895 "cmx_transmit(dsp=%lx) %d bytes to 0x%x-0x%x. %s\n",
1901 sprintf(debugbuf,
"TX getting (%04x-%04x)%p: ", w, ww, p);
1905 if (
strlen(debugbuf) < 48)
1909 w = (w + 1) & CMX_BUFF_MASK;
1938 if (dsp->
echo.software) {
1941 hh = mISDN_HEAD_P(nskb);
1951 if (dsp->
conf->hardware)
1954 if (dsp->
echo.software || member->
dsp != dsp) {
1957 hh = mISDN_HEAD_P(nskb);