ixj.c 312 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553
  1. /****************************************************************************
  2. * ixj.c
  3. *
  4. * Device Driver for Quicknet Technologies, Inc.'s Telephony cards
  5. * including the Internet PhoneJACK, Internet PhoneJACK Lite,
  6. * Internet PhoneJACK PCI, Internet LineJACK, Internet PhoneCARD and
  7. * SmartCABLE
  8. *
  9. * (c) Copyright 1999-2001 Quicknet Technologies, Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version
  14. * 2 of the License, or (at your option) any later version.
  15. *
  16. * Author: Ed Okerson, <eokerson@quicknet.net>
  17. *
  18. * Contributors: Greg Herlein, <gherlein@quicknet.net>
  19. * David W. Erhart, <derhart@quicknet.net>
  20. * John Sellers, <jsellers@quicknet.net>
  21. * Mike Preston, <mpreston@quicknet.net>
  22. *
  23. * Fixes: David Huggins-Daines, <dhd@cepstral.com>
  24. * Fabio Ferrari, <fabio.ferrari@digitro.com.br>
  25. * Artis Kugevics, <artis@mt.lv>
  26. * Daniele Bellucci, <bellucda@tiscali.it>
  27. *
  28. * More information about the hardware related to this driver can be found
  29. * at our website: http://www.quicknet.net
  30. *
  31. * IN NO EVENT SHALL QUICKNET TECHNOLOGIES, INC. BE LIABLE TO ANY PARTY FOR
  32. * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  33. * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF QUICKNET
  34. * TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. * QUICKNET TECHNOLOGIES, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  37. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  38. * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
  39. * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION
  40. * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  41. *
  42. ***************************************************************************/
  43. /*
  44. * Revision 4.8 2003/07/09 19:39:00 Daniele Bellucci
  45. * Audit some copy_*_user and minor cleanup.
  46. *
  47. * Revision 4.7 2001/08/13 06:19:33 craigs
  48. * Added additional changes from Alan Cox and John Anderson for
  49. * 2.2 to 2.4 cleanup and bounds checking
  50. *
  51. * Revision 4.6 2001/08/13 01:05:05 craigs
  52. * Really fixed PHONE_QUERY_CODEC problem this time
  53. *
  54. * Revision 4.5 2001/08/13 00:11:03 craigs
  55. * Fixed problem in handling of PHONE_QUERY_CODEC, thanks to Shane Anderson
  56. *
  57. * Revision 4.4 2001/08/07 07:58:12 craigs
  58. * Changed back to three digit version numbers
  59. * Added tagbuild target to allow automatic and easy tagging of versions
  60. *
  61. * Revision 4.3 2001/08/07 07:24:47 craigs
  62. * Added ixj-ver.h to allow easy configuration management of driver
  63. * Added display of version number in /prox/ixj
  64. *
  65. * Revision 4.2 2001/08/06 07:07:19 craigs
  66. * Reverted IXJCTL_DSP_TYPE and IXJCTL_DSP_VERSION files to original
  67. * behaviour of returning int rather than short *
  68. *
  69. * Revision 4.1 2001/08/05 00:17:37 craigs
  70. * More changes for correct PCMCIA installation
  71. * Start of changes for backward Linux compatibility
  72. *
  73. * Revision 4.0 2001/08/04 12:33:12 craigs
  74. * New version using GNU autoconf
  75. *
  76. * Revision 3.105 2001/07/20 23:14:32 eokerson
  77. * More work on CallerID generation when using ring cadences.
  78. *
  79. * Revision 3.104 2001/07/06 01:33:55 eokerson
  80. * Some bugfixes from Robert Vojta <vojta@ipex.cz> and a few mods to the Makefile.
  81. *
  82. * Revision 3.103 2001/07/05 19:20:16 eokerson
  83. * Updated HOWTO
  84. * Changed mic gain to 30dB on Internet LineJACK mic/speaker port.
  85. *
  86. * Revision 3.102 2001/07/03 23:51:21 eokerson
  87. * Un-mute mic on Internet LineJACK when in speakerphone mode.
  88. *
  89. * Revision 3.101 2001/07/02 19:26:56 eokerson
  90. * Removed initialiazation of ixjdebug and ixj_convert_loaded so they will go in the .bss instead of the .data
  91. *
  92. * Revision 3.100 2001/07/02 19:18:27 eokerson
  93. * Changed driver to make dynamic allocation possible. We now pass IXJ * between functions instead of array indexes.
  94. * Fixed the way the POTS and PSTN ports interact during a PSTN call to allow local answering.
  95. * Fixed speaker mode on Internet LineJACK.
  96. *
  97. * Revision 3.99 2001/05/09 14:11:16 eokerson
  98. * Fixed kmalloc error in ixj_build_filter_cadence. Thanks David Chan <cat@waulogy.stanford.edu>.
  99. *
  100. * Revision 3.98 2001/05/08 19:55:33 eokerson
  101. * Fixed POTS hookstate detection while it is connected to PSTN port.
  102. *
  103. * Revision 3.97 2001/05/08 00:01:04 eokerson
  104. * Fixed kernel oops when sending caller ID data.
  105. *
  106. * Revision 3.96 2001/05/04 23:09:30 eokerson
  107. * Now uses one kernel timer for each card, instead of one for the entire driver.
  108. *
  109. * Revision 3.95 2001/04/25 22:06:47 eokerson
  110. * Fixed squawking at beginning of some G.723.1 calls.
  111. *
  112. * Revision 3.94 2001/04/03 23:42:00 eokerson
  113. * Added linear volume ioctls
  114. * Added raw filter load ioctl
  115. *
  116. * Revision 3.93 2001/02/27 01:00:06 eokerson
  117. * Fixed blocking in CallerID.
  118. * Reduced size of ixj structure for smaller driver footprint.
  119. *
  120. * Revision 3.92 2001/02/20 22:02:59 eokerson
  121. * Fixed isapnp and pcmcia module compatibility for 2.4.x kernels.
  122. * Improved PSTN ring detection.
  123. * Fixed wink generation on POTS ports.
  124. *
  125. * Revision 3.91 2001/02/13 00:55:44 eokerson
  126. * Turn AEC back on after changing frame sizes.
  127. *
  128. * Revision 3.90 2001/02/12 16:42:00 eokerson
  129. * Added ALAW codec, thanks to Fabio Ferrari for the table based converters to make ALAW from ULAW.
  130. *
  131. * Revision 3.89 2001/02/12 15:41:16 eokerson
  132. * Fix from Artis Kugevics - Tone gains were not being set correctly.
  133. *
  134. * Revision 3.88 2001/02/05 23:25:42 eokerson
  135. * Fixed lockup bugs with deregister.
  136. *
  137. * Revision 3.87 2001/01/29 21:00:39 eokerson
  138. * Fix from Fabio Ferrari <fabio.ferrari@digitro.com.br> to properly handle EAGAIN and EINTR during non-blocking write.
  139. * Updated copyright date.
  140. *
  141. * Revision 3.86 2001/01/23 23:53:46 eokerson
  142. * Fixes to G.729 compatibility.
  143. *
  144. * Revision 3.85 2001/01/23 21:30:36 eokerson
  145. * Added verbage about cards supported.
  146. * Removed commands that put the card in low power mode at some times that it should not be in low power mode.
  147. *
  148. * Revision 3.84 2001/01/22 23:32:10 eokerson
  149. * Some bugfixes from David Huggins-Daines, <dhd@cepstral.com> and other cleanups.
  150. *
  151. * Revision 3.83 2001/01/19 14:51:41 eokerson
  152. * Fixed ixj_WriteDSPCommand to decrement usage counter when command fails.
  153. *
  154. * Revision 3.82 2001/01/19 00:34:49 eokerson
  155. * Added verbosity to write overlap errors.
  156. *
  157. * Revision 3.81 2001/01/18 23:56:54 eokerson
  158. * Fixed PSTN line test functions.
  159. *
  160. * Revision 3.80 2001/01/18 22:29:27 eokerson
  161. * Updated AEC/AGC values for different cards.
  162. *
  163. * Revision 3.79 2001/01/17 02:58:54 eokerson
  164. * Fixed AEC reset after Caller ID.
  165. * Fixed Codec lockup after Caller ID on Call Waiting when not using 30ms frames.
  166. *
  167. * Revision 3.78 2001/01/16 19:43:09 eokerson
  168. * Added support for Linux 2.4.x kernels.
  169. *
  170. * Revision 3.77 2001/01/09 04:00:52 eokerson
  171. * Linetest will now test the line, even if it has previously succeeded.
  172. *
  173. * Revision 3.76 2001/01/08 19:27:00 eokerson
  174. * Fixed problem with standard cable on Internet PhoneCARD.
  175. *
  176. * Revision 3.75 2000/12/22 16:52:14 eokerson
  177. * Modified to allow hookstate detection on the POTS port when the PSTN port is selected.
  178. *
  179. * Revision 3.74 2000/12/08 22:41:50 eokerson
  180. * Added capability for G729B.
  181. *
  182. * Revision 3.73 2000/12/07 23:35:16 eokerson
  183. * Added capability to have different ring pattern before CallerID data.
  184. * Added hookstate checks in CallerID routines to stop FSK.
  185. *
  186. * Revision 3.72 2000/12/06 19:31:31 eokerson
  187. * Modified signal behavior to only send one signal per event.
  188. *
  189. * Revision 3.71 2000/12/06 03:23:08 eokerson
  190. * Fixed CallerID on Call Waiting.
  191. *
  192. * Revision 3.70 2000/12/04 21:29:37 eokerson
  193. * Added checking to Smart Cable gain functions.
  194. *
  195. * Revision 3.69 2000/12/04 21:05:20 eokerson
  196. * Changed ixjdebug levels.
  197. * Added ioctls to change gains in Internet Phone CARD Smart Cable.
  198. *
  199. * Revision 3.68 2000/12/04 00:17:21 craigs
  200. * Changed mixer voice gain to +6dB rather than 0dB
  201. *
  202. * Revision 3.67 2000/11/30 21:25:51 eokerson
  203. * Fixed write signal errors.
  204. *
  205. * Revision 3.66 2000/11/29 22:42:44 eokerson
  206. * Fixed PSTN ring detect problems.
  207. *
  208. * Revision 3.65 2000/11/29 07:31:55 craigs
  209. * Added new 425Hz filter co-efficients
  210. * Added card-specific DTMF prescaler initialisation
  211. *
  212. * Revision 3.64 2000/11/28 14:03:32 craigs
  213. * Changed certain mixer initialisations to be 0dB rather than 12dB
  214. * Added additional information to /proc/ixj
  215. *
  216. * Revision 3.63 2000/11/28 11:38:41 craigs
  217. * Added display of AEC modes in AUTO and AGC mode
  218. *
  219. * Revision 3.62 2000/11/28 04:05:44 eokerson
  220. * Improved PSTN ring detection routine.
  221. *
  222. * Revision 3.61 2000/11/27 21:53:12 eokerson
  223. * Fixed flash detection.
  224. *
  225. * Revision 3.60 2000/11/27 15:57:29 eokerson
  226. * More work on G.729 load routines.
  227. *
  228. * Revision 3.59 2000/11/25 21:55:12 eokerson
  229. * Fixed errors in G.729 load routine.
  230. *
  231. * Revision 3.58 2000/11/25 04:08:29 eokerson
  232. * Added board locks around G.729 and TS85 load routines.
  233. *
  234. * Revision 3.57 2000/11/24 05:35:17 craigs
  235. * Added ability to retrieve mixer values on LineJACK
  236. * Added complete initialisation of all mixer values at startup
  237. * Fixed spelling mistake
  238. *
  239. * Revision 3.56 2000/11/23 02:52:11 robertj
  240. * Added cvs change log keyword.
  241. * Fixed bug in capabilities list when using G.729 module.
  242. *
  243. */
  244. #include "ixj-ver.h"
  245. #define PERFMON_STATS
  246. #define IXJDEBUG 0
  247. #define MAXRINGS 5
  248. #include <linux/module.h>
  249. #include <linux/init.h>
  250. #include <linux/sched.h>
  251. #include <linux/kernel.h> /* printk() */
  252. #include <linux/fs.h> /* everything... */
  253. #include <linux/errno.h> /* error codes */
  254. #include <linux/slab.h>
  255. #include <linux/mutex.h>
  256. #include <linux/mm.h>
  257. #include <linux/ioport.h>
  258. #include <linux/interrupt.h>
  259. #include <linux/proc_fs.h>
  260. #include <linux/poll.h>
  261. #include <linux/timer.h>
  262. #include <linux/delay.h>
  263. #include <linux/pci.h>
  264. #include <asm/io.h>
  265. #include <asm/uaccess.h>
  266. #include <linux/isapnp.h>
  267. #include "ixj.h"
  268. #define TYPE(inode) (iminor(inode) >> 4)
  269. #define NUM(inode) (iminor(inode) & 0xf)
  270. static DEFINE_MUTEX(ixj_mutex);
  271. static int ixjdebug;
  272. static int hertz = HZ;
  273. static int samplerate = 100;
  274. module_param(ixjdebug, int, 0);
  275. static DEFINE_PCI_DEVICE_TABLE(ixj_pci_tbl) = {
  276. { PCI_VENDOR_ID_QUICKNET, PCI_DEVICE_ID_QUICKNET_XJ,
  277. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  278. { }
  279. };
  280. MODULE_DEVICE_TABLE(pci, ixj_pci_tbl);
  281. /************************************************************************
  282. *
  283. * ixjdebug meanings are now bit mapped instead of level based
  284. * Values can be or'ed together to turn on multiple messages
  285. *
  286. * bit 0 (0x0001) = any failure
  287. * bit 1 (0x0002) = general messages
  288. * bit 2 (0x0004) = POTS ringing related
  289. * bit 3 (0x0008) = PSTN events
  290. * bit 4 (0x0010) = PSTN Cadence state details
  291. * bit 5 (0x0020) = Tone detection triggers
  292. * bit 6 (0x0040) = Tone detection cadence details
  293. * bit 7 (0x0080) = ioctl tracking
  294. * bit 8 (0x0100) = signal tracking
  295. * bit 9 (0x0200) = CallerID generation details
  296. *
  297. ************************************************************************/
  298. #ifdef IXJ_DYN_ALLOC
  299. static IXJ *ixj[IXJMAX];
  300. #define get_ixj(b) ixj[(b)]
  301. /*
  302. * Allocate a free IXJ device
  303. */
  304. static IXJ *ixj_alloc()
  305. {
  306. for(cnt=0; cnt<IXJMAX; cnt++)
  307. {
  308. if(ixj[cnt] == NULL || !ixj[cnt]->DSPbase)
  309. {
  310. j = kmalloc(sizeof(IXJ), GFP_KERNEL);
  311. if (j == NULL)
  312. return NULL;
  313. ixj[cnt] = j;
  314. return j;
  315. }
  316. }
  317. return NULL;
  318. }
  319. static void ixj_fsk_free(IXJ *j)
  320. {
  321. kfree(j->fskdata);
  322. j->fskdata = NULL;
  323. }
  324. static void ixj_fsk_alloc(IXJ *j)
  325. {
  326. if(!j->fskdata) {
  327. j->fskdata = kmalloc(8000, GFP_KERNEL);
  328. if (!j->fskdata) {
  329. if(ixjdebug & 0x0200) {
  330. printk("IXJ phone%d - allocate failed\n", j->board);
  331. }
  332. return;
  333. } else {
  334. j->fsksize = 8000;
  335. if(ixjdebug & 0x0200) {
  336. printk("IXJ phone%d - allocate succeeded\n", j->board);
  337. }
  338. }
  339. }
  340. }
  341. #else
  342. static IXJ ixj[IXJMAX];
  343. #define get_ixj(b) (&ixj[(b)])
  344. /*
  345. * Allocate a free IXJ device
  346. */
  347. static IXJ *ixj_alloc(void)
  348. {
  349. int cnt;
  350. for(cnt=0; cnt<IXJMAX; cnt++) {
  351. if(!ixj[cnt].DSPbase)
  352. return &ixj[cnt];
  353. }
  354. return NULL;
  355. }
  356. static inline void ixj_fsk_free(IXJ *j) {;}
  357. static inline void ixj_fsk_alloc(IXJ *j)
  358. {
  359. j->fsksize = 8000;
  360. }
  361. #endif
  362. #ifdef PERFMON_STATS
  363. #define ixj_perfmon(x) ((x)++)
  364. #else
  365. #define ixj_perfmon(x) do { } while(0)
  366. #endif
  367. static int ixj_convert_loaded;
  368. static int ixj_WriteDSPCommand(unsigned short, IXJ *j);
  369. /************************************************************************
  370. *
  371. * These are function definitions to allow external modules to register
  372. * enhanced functionality call backs.
  373. *
  374. ************************************************************************/
  375. static int Stub(IXJ * J, unsigned long arg)
  376. {
  377. return 0;
  378. }
  379. static IXJ_REGFUNC ixj_PreRead = &Stub;
  380. static IXJ_REGFUNC ixj_PostRead = &Stub;
  381. static IXJ_REGFUNC ixj_PreWrite = &Stub;
  382. static IXJ_REGFUNC ixj_PostWrite = &Stub;
  383. static void ixj_read_frame(IXJ *j);
  384. static void ixj_write_frame(IXJ *j);
  385. static void ixj_init_timer(IXJ *j);
  386. static void ixj_add_timer(IXJ * j);
  387. static void ixj_timeout(unsigned long ptr);
  388. static int read_filters(IXJ *j);
  389. static int LineMonitor(IXJ *j);
  390. static int ixj_fasync(int fd, struct file *, int mode);
  391. static int ixj_set_port(IXJ *j, int arg);
  392. static int ixj_set_pots(IXJ *j, int arg);
  393. static int ixj_hookstate(IXJ *j);
  394. static int ixj_record_start(IXJ *j);
  395. static void ixj_record_stop(IXJ *j);
  396. static void set_rec_volume(IXJ *j, int volume);
  397. static int get_rec_volume(IXJ *j);
  398. static int set_rec_codec(IXJ *j, int rate);
  399. static void ixj_vad(IXJ *j, int arg);
  400. static int ixj_play_start(IXJ *j);
  401. static void ixj_play_stop(IXJ *j);
  402. static int ixj_set_tone_on(unsigned short arg, IXJ *j);
  403. static int ixj_set_tone_off(unsigned short, IXJ *j);
  404. static int ixj_play_tone(IXJ *j, char tone);
  405. static void ixj_aec_start(IXJ *j, int level);
  406. static int idle(IXJ *j);
  407. static void ixj_ring_on(IXJ *j);
  408. static void ixj_ring_off(IXJ *j);
  409. static void aec_stop(IXJ *j);
  410. static void ixj_ringback(IXJ *j);
  411. static void ixj_busytone(IXJ *j);
  412. static void ixj_dialtone(IXJ *j);
  413. static void ixj_cpt_stop(IXJ *j);
  414. static char daa_int_read(IXJ *j);
  415. static char daa_CR_read(IXJ *j, int cr);
  416. static int daa_set_mode(IXJ *j, int mode);
  417. static int ixj_linetest(IXJ *j);
  418. static int ixj_daa_write(IXJ *j);
  419. static int ixj_daa_cid_read(IXJ *j);
  420. static void DAA_Coeff_US(IXJ *j);
  421. static void DAA_Coeff_UK(IXJ *j);
  422. static void DAA_Coeff_France(IXJ *j);
  423. static void DAA_Coeff_Germany(IXJ *j);
  424. static void DAA_Coeff_Australia(IXJ *j);
  425. static void DAA_Coeff_Japan(IXJ *j);
  426. static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf);
  427. static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr);
  428. static int ixj_init_tone(IXJ *j, IXJ_TONE * ti);
  429. static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp);
  430. static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp);
  431. /* Serial Control Interface funtions */
  432. static int SCI_Control(IXJ *j, int control);
  433. static int SCI_Prepare(IXJ *j);
  434. static int SCI_WaitHighSCI(IXJ *j);
  435. static int SCI_WaitLowSCI(IXJ *j);
  436. static DWORD PCIEE_GetSerialNumber(WORD wAddress);
  437. static int ixj_PCcontrol_wait(IXJ *j);
  438. static void ixj_pre_cid(IXJ *j);
  439. static void ixj_write_cid(IXJ *j);
  440. static void ixj_write_cid_bit(IXJ *j, int bit);
  441. static int set_base_frame(IXJ *j, int size);
  442. static int set_play_codec(IXJ *j, int rate);
  443. static void set_rec_depth(IXJ *j, int depth);
  444. static int ixj_mixer(long val, IXJ *j);
  445. /************************************************************************
  446. CT8020/CT8021 Host Programmers Model
  447. Host address Function Access
  448. DSPbase +
  449. 0-1 Aux Software Status Register (reserved) Read Only
  450. 2-3 Software Status Register Read Only
  451. 4-5 Aux Software Control Register (reserved) Read Write
  452. 6-7 Software Control Register Read Write
  453. 8-9 Hardware Status Register Read Only
  454. A-B Hardware Control Register Read Write
  455. C-D Host Transmit (Write) Data Buffer Access Port (buffer input)Write Only
  456. E-F Host Receive (Read) Data Buffer Access Port (buffer input) Read Only
  457. ************************************************************************/
  458. static inline void ixj_read_HSR(IXJ *j)
  459. {
  460. j->hsr.bytes.low = inb_p(j->DSPbase + 8);
  461. j->hsr.bytes.high = inb_p(j->DSPbase + 9);
  462. }
  463. static inline int IsControlReady(IXJ *j)
  464. {
  465. ixj_read_HSR(j);
  466. return j->hsr.bits.controlrdy ? 1 : 0;
  467. }
  468. static inline int IsPCControlReady(IXJ *j)
  469. {
  470. j->pccr1.byte = inb_p(j->XILINXbase + 3);
  471. return j->pccr1.bits.crr ? 1 : 0;
  472. }
  473. static inline int IsStatusReady(IXJ *j)
  474. {
  475. ixj_read_HSR(j);
  476. return j->hsr.bits.statusrdy ? 1 : 0;
  477. }
  478. static inline int IsRxReady(IXJ *j)
  479. {
  480. ixj_read_HSR(j);
  481. ixj_perfmon(j->rxreadycheck);
  482. return j->hsr.bits.rxrdy ? 1 : 0;
  483. }
  484. static inline int IsTxReady(IXJ *j)
  485. {
  486. ixj_read_HSR(j);
  487. ixj_perfmon(j->txreadycheck);
  488. return j->hsr.bits.txrdy ? 1 : 0;
  489. }
  490. static inline void set_play_volume(IXJ *j, int volume)
  491. {
  492. if (ixjdebug & 0x0002)
  493. printk(KERN_INFO "IXJ: /dev/phone%d Setting Play Volume to 0x%4.4x\n", j->board, volume);
  494. ixj_WriteDSPCommand(0xCF02, j);
  495. ixj_WriteDSPCommand(volume, j);
  496. }
  497. static int set_play_volume_linear(IXJ *j, int volume)
  498. {
  499. int newvolume, dspplaymax;
  500. if (ixjdebug & 0x0002)
  501. printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Play Volume to 0x%4.4x\n", j->board, volume);
  502. if(volume > 100 || volume < 0) {
  503. return -1;
  504. }
  505. /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
  506. switch (j->cardtype) {
  507. case QTI_PHONEJACK:
  508. dspplaymax = 0x380;
  509. break;
  510. case QTI_LINEJACK:
  511. if(j->port == PORT_PSTN) {
  512. dspplaymax = 0x48;
  513. } else {
  514. dspplaymax = 0x100;
  515. }
  516. break;
  517. case QTI_PHONEJACK_LITE:
  518. dspplaymax = 0x380;
  519. break;
  520. case QTI_PHONEJACK_PCI:
  521. dspplaymax = 0x6C;
  522. break;
  523. case QTI_PHONECARD:
  524. dspplaymax = 0x50;
  525. break;
  526. default:
  527. return -1;
  528. }
  529. newvolume = (dspplaymax * volume) / 100;
  530. set_play_volume(j, newvolume);
  531. return 0;
  532. }
  533. static inline void set_play_depth(IXJ *j, int depth)
  534. {
  535. if (depth > 60)
  536. depth = 60;
  537. if (depth < 0)
  538. depth = 0;
  539. ixj_WriteDSPCommand(0x5280 + depth, j);
  540. }
  541. static inline int get_play_volume(IXJ *j)
  542. {
  543. ixj_WriteDSPCommand(0xCF00, j);
  544. return j->ssr.high << 8 | j->ssr.low;
  545. }
  546. static int get_play_volume_linear(IXJ *j)
  547. {
  548. int volume, newvolume, dspplaymax;
  549. /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
  550. switch (j->cardtype) {
  551. case QTI_PHONEJACK:
  552. dspplaymax = 0x380;
  553. break;
  554. case QTI_LINEJACK:
  555. if(j->port == PORT_PSTN) {
  556. dspplaymax = 0x48;
  557. } else {
  558. dspplaymax = 0x100;
  559. }
  560. break;
  561. case QTI_PHONEJACK_LITE:
  562. dspplaymax = 0x380;
  563. break;
  564. case QTI_PHONEJACK_PCI:
  565. dspplaymax = 0x6C;
  566. break;
  567. case QTI_PHONECARD:
  568. dspplaymax = 100;
  569. break;
  570. default:
  571. return -1;
  572. }
  573. volume = get_play_volume(j);
  574. newvolume = (volume * 100) / dspplaymax;
  575. if(newvolume > 100)
  576. newvolume = 100;
  577. return newvolume;
  578. }
  579. static inline BYTE SLIC_GetState(IXJ *j)
  580. {
  581. if (j->cardtype == QTI_PHONECARD) {
  582. j->pccr1.byte = 0;
  583. j->psccr.bits.dev = 3;
  584. j->psccr.bits.rw = 1;
  585. outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
  586. ixj_PCcontrol_wait(j);
  587. j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
  588. ixj_PCcontrol_wait(j);
  589. if (j->pslic.bits.powerdown)
  590. return PLD_SLIC_STATE_OC;
  591. else if (!j->pslic.bits.ring0 && !j->pslic.bits.ring1)
  592. return PLD_SLIC_STATE_ACTIVE;
  593. else
  594. return PLD_SLIC_STATE_RINGING;
  595. } else {
  596. j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
  597. }
  598. return j->pld_slicr.bits.state;
  599. }
  600. static bool SLIC_SetState(BYTE byState, IXJ *j)
  601. {
  602. bool fRetVal = false;
  603. if (j->cardtype == QTI_PHONECARD) {
  604. if (j->flags.pcmciasct) {
  605. switch (byState) {
  606. case PLD_SLIC_STATE_TIPOPEN:
  607. case PLD_SLIC_STATE_OC:
  608. j->pslic.bits.powerdown = 1;
  609. j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
  610. fRetVal = true;
  611. break;
  612. case PLD_SLIC_STATE_RINGING:
  613. if (j->readers || j->writers) {
  614. j->pslic.bits.powerdown = 0;
  615. j->pslic.bits.ring0 = 1;
  616. j->pslic.bits.ring1 = 0;
  617. fRetVal = true;
  618. }
  619. break;
  620. case PLD_SLIC_STATE_OHT: /* On-hook transmit */
  621. case PLD_SLIC_STATE_STANDBY:
  622. case PLD_SLIC_STATE_ACTIVE:
  623. if (j->readers || j->writers) {
  624. j->pslic.bits.powerdown = 0;
  625. } else {
  626. j->pslic.bits.powerdown = 1;
  627. }
  628. j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
  629. fRetVal = true;
  630. break;
  631. case PLD_SLIC_STATE_APR: /* Active polarity reversal */
  632. case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
  633. default:
  634. fRetVal = false;
  635. break;
  636. }
  637. j->psccr.bits.dev = 3;
  638. j->psccr.bits.rw = 0;
  639. outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
  640. ixj_PCcontrol_wait(j);
  641. }
  642. } else {
  643. /* Set the C1, C2, C3 & B2EN signals. */
  644. switch (byState) {
  645. case PLD_SLIC_STATE_OC:
  646. j->pld_slicw.bits.c1 = 0;
  647. j->pld_slicw.bits.c2 = 0;
  648. j->pld_slicw.bits.c3 = 0;
  649. j->pld_slicw.bits.b2en = 0;
  650. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  651. fRetVal = true;
  652. break;
  653. case PLD_SLIC_STATE_RINGING:
  654. j->pld_slicw.bits.c1 = 1;
  655. j->pld_slicw.bits.c2 = 0;
  656. j->pld_slicw.bits.c3 = 0;
  657. j->pld_slicw.bits.b2en = 1;
  658. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  659. fRetVal = true;
  660. break;
  661. case PLD_SLIC_STATE_ACTIVE:
  662. j->pld_slicw.bits.c1 = 0;
  663. j->pld_slicw.bits.c2 = 1;
  664. j->pld_slicw.bits.c3 = 0;
  665. j->pld_slicw.bits.b2en = 0;
  666. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  667. fRetVal = true;
  668. break;
  669. case PLD_SLIC_STATE_OHT: /* On-hook transmit */
  670. j->pld_slicw.bits.c1 = 1;
  671. j->pld_slicw.bits.c2 = 1;
  672. j->pld_slicw.bits.c3 = 0;
  673. j->pld_slicw.bits.b2en = 0;
  674. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  675. fRetVal = true;
  676. break;
  677. case PLD_SLIC_STATE_TIPOPEN:
  678. j->pld_slicw.bits.c1 = 0;
  679. j->pld_slicw.bits.c2 = 0;
  680. j->pld_slicw.bits.c3 = 1;
  681. j->pld_slicw.bits.b2en = 0;
  682. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  683. fRetVal = true;
  684. break;
  685. case PLD_SLIC_STATE_STANDBY:
  686. j->pld_slicw.bits.c1 = 1;
  687. j->pld_slicw.bits.c2 = 0;
  688. j->pld_slicw.bits.c3 = 1;
  689. j->pld_slicw.bits.b2en = 1;
  690. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  691. fRetVal = true;
  692. break;
  693. case PLD_SLIC_STATE_APR: /* Active polarity reversal */
  694. j->pld_slicw.bits.c1 = 0;
  695. j->pld_slicw.bits.c2 = 1;
  696. j->pld_slicw.bits.c3 = 1;
  697. j->pld_slicw.bits.b2en = 0;
  698. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  699. fRetVal = true;
  700. break;
  701. case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
  702. j->pld_slicw.bits.c1 = 1;
  703. j->pld_slicw.bits.c2 = 1;
  704. j->pld_slicw.bits.c3 = 1;
  705. j->pld_slicw.bits.b2en = 0;
  706. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  707. fRetVal = true;
  708. break;
  709. default:
  710. fRetVal = false;
  711. break;
  712. }
  713. }
  714. return fRetVal;
  715. }
  716. static int ixj_wink(IXJ *j)
  717. {
  718. BYTE slicnow;
  719. slicnow = SLIC_GetState(j);
  720. j->pots_winkstart = jiffies;
  721. SLIC_SetState(PLD_SLIC_STATE_OC, j);
  722. msleep(jiffies_to_msecs(j->winktime));
  723. SLIC_SetState(slicnow, j);
  724. return 0;
  725. }
  726. static void ixj_init_timer(IXJ *j)
  727. {
  728. init_timer(&j->timer);
  729. j->timer.function = ixj_timeout;
  730. j->timer.data = (unsigned long)j;
  731. }
  732. static void ixj_add_timer(IXJ *j)
  733. {
  734. j->timer.expires = jiffies + (hertz / samplerate);
  735. add_timer(&j->timer);
  736. }
  737. static void ixj_tone_timeout(IXJ *j)
  738. {
  739. IXJ_TONE ti;
  740. j->tone_state++;
  741. if (j->tone_state == 3) {
  742. j->tone_state = 0;
  743. if (j->cadence_t) {
  744. j->tone_cadence_state++;
  745. if (j->tone_cadence_state >= j->cadence_t->elements_used) {
  746. switch (j->cadence_t->termination) {
  747. case PLAY_ONCE:
  748. ixj_cpt_stop(j);
  749. break;
  750. case REPEAT_LAST_ELEMENT:
  751. j->tone_cadence_state--;
  752. ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
  753. break;
  754. case REPEAT_ALL:
  755. j->tone_cadence_state = 0;
  756. if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
  757. ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
  758. ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
  759. ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
  760. ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
  761. ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
  762. ixj_init_tone(j, &ti);
  763. }
  764. ixj_set_tone_on(j->cadence_t->ce[0].tone_on_time, j);
  765. ixj_set_tone_off(j->cadence_t->ce[0].tone_off_time, j);
  766. ixj_play_tone(j, j->cadence_t->ce[0].index);
  767. break;
  768. }
  769. } else {
  770. if (j->cadence_t->ce[j->tone_cadence_state].gain0) {
  771. ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
  772. ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
  773. ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
  774. ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
  775. ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
  776. ixj_init_tone(j, &ti);
  777. }
  778. ixj_set_tone_on(j->cadence_t->ce[j->tone_cadence_state].tone_on_time, j);
  779. ixj_set_tone_off(j->cadence_t->ce[j->tone_cadence_state].tone_off_time, j);
  780. ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
  781. }
  782. }
  783. }
  784. }
  785. static inline void ixj_kill_fasync(IXJ *j, IXJ_SIGEVENT event, int dir)
  786. {
  787. if(j->ixj_signals[event]) {
  788. if(ixjdebug & 0x0100)
  789. printk("Sending signal for event %d\n", event);
  790. /* Send apps notice of change */
  791. /* see config.h for macro definition */
  792. kill_fasync(&(j->async_queue), j->ixj_signals[event], dir);
  793. }
  794. }
  795. static void ixj_pstn_state(IXJ *j)
  796. {
  797. int var;
  798. union XOPXR0 XR0, daaint;
  799. var = 10;
  800. XR0.reg = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg;
  801. daaint.reg = 0;
  802. XR0.bitreg.RMR = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
  803. j->pld_scrr.byte = inb_p(j->XILINXbase);
  804. if (j->pld_scrr.bits.daaflag) {
  805. daa_int_read(j);
  806. if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.RING) {
  807. if(time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) {
  808. daaint.bitreg.RING = 1;
  809. if(ixjdebug & 0x0008) {
  810. printk(KERN_INFO "IXJ DAA Ring Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
  811. }
  812. } else {
  813. daa_set_mode(j, SOP_PU_RESET);
  814. }
  815. }
  816. if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Caller_ID) {
  817. daaint.bitreg.Caller_ID = 1;
  818. j->pstn_cid_intr = 1;
  819. j->pstn_cid_received = jiffies;
  820. if(ixjdebug & 0x0008) {
  821. printk(KERN_INFO "IXJ DAA Caller_ID Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
  822. }
  823. }
  824. if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Cadence) {
  825. daaint.bitreg.Cadence = 1;
  826. if(ixjdebug & 0x0008) {
  827. printk(KERN_INFO "IXJ DAA Cadence Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
  828. }
  829. }
  830. if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK != XR0.bitreg.VDD_OK) {
  831. daaint.bitreg.VDD_OK = 1;
  832. daaint.bitreg.SI_0 = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK;
  833. }
  834. }
  835. daa_CR_read(j, 1);
  836. if(j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR != XR0.bitreg.RMR && time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) {
  837. daaint.bitreg.RMR = 1;
  838. daaint.bitreg.SI_1 = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
  839. if(ixjdebug & 0x0008) {
  840. printk(KERN_INFO "IXJ DAA RMR /dev/phone%d was %s for %ld\n", j->board, XR0.bitreg.RMR?"on":"off", jiffies - j->pstn_last_rmr);
  841. }
  842. j->pstn_prev_rmr = j->pstn_last_rmr;
  843. j->pstn_last_rmr = jiffies;
  844. }
  845. switch(j->daa_mode) {
  846. case SOP_PU_SLEEP:
  847. if (daaint.bitreg.RING) {
  848. if (!j->flags.pstn_ringing) {
  849. if (j->daa_mode != SOP_PU_RINGING) {
  850. j->pstn_ring_int = jiffies;
  851. daa_set_mode(j, SOP_PU_RINGING);
  852. }
  853. }
  854. }
  855. break;
  856. case SOP_PU_RINGING:
  857. if (daaint.bitreg.RMR) {
  858. if (ixjdebug & 0x0008) {
  859. printk(KERN_INFO "IXJ Ring Cadence a state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
  860. }
  861. if (daaint.bitreg.SI_1) { /* Rising edge of RMR */
  862. j->flags.pstn_rmr = 1;
  863. j->pstn_ring_start = jiffies;
  864. j->pstn_ring_stop = 0;
  865. j->ex.bits.pstn_ring = 0;
  866. if (j->cadence_f[4].state == 0) {
  867. j->cadence_f[4].state = 1;
  868. j->cadence_f[4].on1min = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 - var)) / 10000);
  869. j->cadence_f[4].on1dot = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100)) / 10000);
  870. j->cadence_f[4].on1max = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 + var)) / 10000);
  871. } else if (j->cadence_f[4].state == 2) {
  872. if((time_after(jiffies, j->cadence_f[4].off1min) &&
  873. time_before(jiffies, j->cadence_f[4].off1max))) {
  874. if (j->cadence_f[4].on2) {
  875. j->cadence_f[4].state = 3;
  876. j->cadence_f[4].on2min = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 - var)) / 10000));
  877. j->cadence_f[4].on2dot = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100)) / 10000));
  878. j->cadence_f[4].on2max = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 + var)) / 10000));
  879. } else {
  880. j->cadence_f[4].state = 7;
  881. }
  882. } else {
  883. if (ixjdebug & 0x0008) {
  884. printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
  885. j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
  886. j->cadence_f[4].off1);
  887. }
  888. j->cadence_f[4].state = 0;
  889. }
  890. } else if (j->cadence_f[4].state == 4) {
  891. if((time_after(jiffies, j->cadence_f[4].off2min) &&
  892. time_before(jiffies, j->cadence_f[4].off2max))) {
  893. if (j->cadence_f[4].on3) {
  894. j->cadence_f[4].state = 5;
  895. j->cadence_f[4].on3min = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 - var)) / 10000));
  896. j->cadence_f[4].on3dot = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100)) / 10000));
  897. j->cadence_f[4].on3max = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 + var)) / 10000));
  898. } else {
  899. j->cadence_f[4].state = 7;
  900. }
  901. } else {
  902. if (ixjdebug & 0x0008) {
  903. printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
  904. j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
  905. j->cadence_f[4].off2);
  906. }
  907. j->cadence_f[4].state = 0;
  908. }
  909. } else if (j->cadence_f[4].state == 6) {
  910. if((time_after(jiffies, j->cadence_f[4].off3min) &&
  911. time_before(jiffies, j->cadence_f[4].off3max))) {
  912. j->cadence_f[4].state = 7;
  913. } else {
  914. if (ixjdebug & 0x0008) {
  915. printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
  916. j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
  917. j->cadence_f[4].off3);
  918. }
  919. j->cadence_f[4].state = 0;
  920. }
  921. } else {
  922. j->cadence_f[4].state = 0;
  923. }
  924. } else { /* Falling edge of RMR */
  925. j->pstn_ring_start = 0;
  926. j->pstn_ring_stop = jiffies;
  927. if (j->cadence_f[4].state == 1) {
  928. if(!j->cadence_f[4].on1) {
  929. j->cadence_f[4].state = 7;
  930. } else if((time_after(jiffies, j->cadence_f[4].on1min) &&
  931. time_before(jiffies, j->cadence_f[4].on1max))) {
  932. if (j->cadence_f[4].off1) {
  933. j->cadence_f[4].state = 2;
  934. j->cadence_f[4].off1min = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 - var)) / 10000));
  935. j->cadence_f[4].off1dot = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100)) / 10000));
  936. j->cadence_f[4].off1max = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 + var)) / 10000));
  937. } else {
  938. j->cadence_f[4].state = 7;
  939. }
  940. } else {
  941. if (ixjdebug & 0x0008) {
  942. printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
  943. j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
  944. j->cadence_f[4].on1);
  945. }
  946. j->cadence_f[4].state = 0;
  947. }
  948. } else if (j->cadence_f[4].state == 3) {
  949. if((time_after(jiffies, j->cadence_f[4].on2min) &&
  950. time_before(jiffies, j->cadence_f[4].on2max))) {
  951. if (j->cadence_f[4].off2) {
  952. j->cadence_f[4].state = 4;
  953. j->cadence_f[4].off2min = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 - var)) / 10000));
  954. j->cadence_f[4].off2dot = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100)) / 10000));
  955. j->cadence_f[4].off2max = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 + var)) / 10000));
  956. } else {
  957. j->cadence_f[4].state = 7;
  958. }
  959. } else {
  960. if (ixjdebug & 0x0008) {
  961. printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
  962. j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
  963. j->cadence_f[4].on2);
  964. }
  965. j->cadence_f[4].state = 0;
  966. }
  967. } else if (j->cadence_f[4].state == 5) {
  968. if((time_after(jiffies, j->cadence_f[4].on3min) &&
  969. time_before(jiffies, j->cadence_f[4].on3max))) {
  970. if (j->cadence_f[4].off3) {
  971. j->cadence_f[4].state = 6;
  972. j->cadence_f[4].off3min = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 - var)) / 10000));
  973. j->cadence_f[4].off3dot = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100)) / 10000));
  974. j->cadence_f[4].off3max = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 + var)) / 10000));
  975. } else {
  976. j->cadence_f[4].state = 7;
  977. }
  978. } else {
  979. j->cadence_f[4].state = 0;
  980. }
  981. } else {
  982. if (ixjdebug & 0x0008) {
  983. printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
  984. j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
  985. j->cadence_f[4].on3);
  986. }
  987. j->cadence_f[4].state = 0;
  988. }
  989. }
  990. if (ixjdebug & 0x0010) {
  991. printk(KERN_INFO "IXJ Ring Cadence b state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
  992. }
  993. if (ixjdebug & 0x0010) {
  994. switch(j->cadence_f[4].state) {
  995. case 1:
  996. printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
  997. j->cadence_f[4].on1, j->cadence_f[4].on1min, j->cadence_f[4].on1dot, j->cadence_f[4].on1max);
  998. break;
  999. case 2:
  1000. printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
  1001. j->cadence_f[4].off1, j->cadence_f[4].off1min, j->cadence_f[4].off1dot, j->cadence_f[4].off1max);
  1002. break;
  1003. case 3:
  1004. printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
  1005. j->cadence_f[4].on2, j->cadence_f[4].on2min, j->cadence_f[4].on2dot, j->cadence_f[4].on2max);
  1006. break;
  1007. case 4:
  1008. printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
  1009. j->cadence_f[4].off2, j->cadence_f[4].off2min, j->cadence_f[4].off2dot, j->cadence_f[4].off2max);
  1010. break;
  1011. case 5:
  1012. printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
  1013. j->cadence_f[4].on3, j->cadence_f[4].on3min, j->cadence_f[4].on3dot, j->cadence_f[4].on3max);
  1014. break;
  1015. case 6:
  1016. printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
  1017. j->cadence_f[4].off3, j->cadence_f[4].off3min, j->cadence_f[4].off3dot, j->cadence_f[4].off3max);
  1018. break;
  1019. }
  1020. }
  1021. }
  1022. if (j->cadence_f[4].state == 7) {
  1023. j->cadence_f[4].state = 0;
  1024. j->pstn_ring_stop = jiffies;
  1025. j->ex.bits.pstn_ring = 1;
  1026. ixj_kill_fasync(j, SIG_PSTN_RING, POLL_IN);
  1027. if(ixjdebug & 0x0008) {
  1028. printk(KERN_INFO "IXJ Ring int set /dev/phone%d at %ld\n", j->board, jiffies);
  1029. }
  1030. }
  1031. if((j->pstn_ring_int != 0 && time_after(jiffies, j->pstn_ring_int + (hertz * 5)) && !j->flags.pstn_rmr) ||
  1032. (j->pstn_ring_stop != 0 && time_after(jiffies, j->pstn_ring_stop + (hertz * 5)))) {
  1033. if(ixjdebug & 0x0008) {
  1034. printk("IXJ DAA no ring in 5 seconds /dev/phone%d at %ld\n", j->board, jiffies);
  1035. printk("IXJ DAA pstn ring int /dev/phone%d at %ld\n", j->board, j->pstn_ring_int);
  1036. printk("IXJ DAA pstn ring stop /dev/phone%d at %ld\n", j->board, j->pstn_ring_stop);
  1037. }
  1038. j->pstn_ring_stop = j->pstn_ring_int = 0;
  1039. daa_set_mode(j, SOP_PU_SLEEP);
  1040. }
  1041. outb_p(j->pld_scrw.byte, j->XILINXbase);
  1042. if (j->pstn_cid_intr && time_after(jiffies, j->pstn_cid_received + hertz)) {
  1043. ixj_daa_cid_read(j);
  1044. j->ex.bits.caller_id = 1;
  1045. ixj_kill_fasync(j, SIG_CALLER_ID, POLL_IN);
  1046. j->pstn_cid_intr = 0;
  1047. }
  1048. if (daaint.bitreg.Cadence) {
  1049. if(ixjdebug & 0x0008) {
  1050. printk("IXJ DAA Cadence interrupt going to sleep /dev/phone%d\n", j->board);
  1051. }
  1052. daa_set_mode(j, SOP_PU_SLEEP);
  1053. j->ex.bits.pstn_ring = 0;
  1054. }
  1055. break;
  1056. case SOP_PU_CONVERSATION:
  1057. if (daaint.bitreg.VDD_OK) {
  1058. if(!daaint.bitreg.SI_0) {
  1059. if (!j->pstn_winkstart) {
  1060. if(ixjdebug & 0x0008) {
  1061. printk("IXJ DAA possible wink /dev/phone%d %ld\n", j->board, jiffies);
  1062. }
  1063. j->pstn_winkstart = jiffies;
  1064. }
  1065. } else {
  1066. if (j->pstn_winkstart) {
  1067. if(ixjdebug & 0x0008) {
  1068. printk("IXJ DAA possible wink end /dev/phone%d %ld\n", j->board, jiffies);
  1069. }
  1070. j->pstn_winkstart = 0;
  1071. }
  1072. }
  1073. }
  1074. if (j->pstn_winkstart && time_after(jiffies, j->pstn_winkstart + ((hertz * j->winktime) / 1000))) {
  1075. if(ixjdebug & 0x0008) {
  1076. printk("IXJ DAA wink detected going to sleep /dev/phone%d %ld\n", j->board, jiffies);
  1077. }
  1078. daa_set_mode(j, SOP_PU_SLEEP);
  1079. j->pstn_winkstart = 0;
  1080. j->ex.bits.pstn_wink = 1;
  1081. ixj_kill_fasync(j, SIG_PSTN_WINK, POLL_IN);
  1082. }
  1083. break;
  1084. }
  1085. }
  1086. static void ixj_timeout(unsigned long ptr)
  1087. {
  1088. int board;
  1089. unsigned long jifon;
  1090. IXJ *j = (IXJ *)ptr;
  1091. board = j->board;
  1092. if (j->DSPbase && atomic_read(&j->DSPWrite) == 0 && test_and_set_bit(board, (void *)&j->busyflags) == 0) {
  1093. ixj_perfmon(j->timerchecks);
  1094. j->hookstate = ixj_hookstate(j);
  1095. if (j->tone_state) {
  1096. if (!(j->hookstate)) {
  1097. ixj_cpt_stop(j);
  1098. if (j->m_hook) {
  1099. j->m_hook = 0;
  1100. j->ex.bits.hookstate = 1;
  1101. ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
  1102. }
  1103. clear_bit(board, &j->busyflags);
  1104. ixj_add_timer(j);
  1105. return;
  1106. }
  1107. if (j->tone_state == 1)
  1108. jifon = ((hertz * j->tone_on_time) * 25 / 100000);
  1109. else
  1110. jifon = ((hertz * j->tone_on_time) * 25 / 100000) + ((hertz * j->tone_off_time) * 25 / 100000);
  1111. if (time_before(jiffies, j->tone_start_jif + jifon)) {
  1112. if (j->tone_state == 1) {
  1113. ixj_play_tone(j, j->tone_index);
  1114. if (j->dsp.low == 0x20) {
  1115. clear_bit(board, &j->busyflags);
  1116. ixj_add_timer(j);
  1117. return;
  1118. }
  1119. } else {
  1120. ixj_play_tone(j, 0);
  1121. if (j->dsp.low == 0x20) {
  1122. clear_bit(board, &j->busyflags);
  1123. ixj_add_timer(j);
  1124. return;
  1125. }
  1126. }
  1127. } else {
  1128. ixj_tone_timeout(j);
  1129. if (j->flags.dialtone) {
  1130. ixj_dialtone(j);
  1131. }
  1132. if (j->flags.busytone) {
  1133. ixj_busytone(j);
  1134. if (j->dsp.low == 0x20) {
  1135. clear_bit(board, &j->busyflags);
  1136. ixj_add_timer(j);
  1137. return;
  1138. }
  1139. }
  1140. if (j->flags.ringback) {
  1141. ixj_ringback(j);
  1142. if (j->dsp.low == 0x20) {
  1143. clear_bit(board, &j->busyflags);
  1144. ixj_add_timer(j);
  1145. return;
  1146. }
  1147. }
  1148. if (!j->tone_state) {
  1149. ixj_cpt_stop(j);
  1150. }
  1151. }
  1152. }
  1153. if (!(j->tone_state && j->dsp.low == 0x20)) {
  1154. if (IsRxReady(j)) {
  1155. ixj_read_frame(j);
  1156. }
  1157. if (IsTxReady(j)) {
  1158. ixj_write_frame(j);
  1159. }
  1160. }
  1161. if (j->flags.cringing) {
  1162. if (j->hookstate & 1) {
  1163. j->flags.cringing = 0;
  1164. ixj_ring_off(j);
  1165. } else if(j->cadence_f[5].enable && ((!j->cadence_f[5].en_filter) || (j->cadence_f[5].en_filter && j->flags.firstring))) {
  1166. switch(j->cadence_f[5].state) {
  1167. case 0:
  1168. j->cadence_f[5].on1dot = jiffies + (long)((j->cadence_f[5].on1 * (hertz * 100) / 10000));
  1169. if (time_before(jiffies, j->cadence_f[5].on1dot)) {
  1170. if(ixjdebug & 0x0004) {
  1171. printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
  1172. }
  1173. ixj_ring_on(j);
  1174. }
  1175. j->cadence_f[5].state = 1;
  1176. break;
  1177. case 1:
  1178. if (time_after(jiffies, j->cadence_f[5].on1dot)) {
  1179. j->cadence_f[5].off1dot = jiffies + (long)((j->cadence_f[5].off1 * (hertz * 100) / 10000));
  1180. if(ixjdebug & 0x0004) {
  1181. printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
  1182. }
  1183. ixj_ring_off(j);
  1184. j->cadence_f[5].state = 2;
  1185. }
  1186. break;
  1187. case 2:
  1188. if (time_after(jiffies, j->cadence_f[5].off1dot)) {
  1189. if(ixjdebug & 0x0004) {
  1190. printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
  1191. }
  1192. ixj_ring_on(j);
  1193. if (j->cadence_f[5].on2) {
  1194. j->cadence_f[5].on2dot = jiffies + (long)((j->cadence_f[5].on2 * (hertz * 100) / 10000));
  1195. j->cadence_f[5].state = 3;
  1196. } else {
  1197. j->cadence_f[5].state = 7;
  1198. }
  1199. }
  1200. break;
  1201. case 3:
  1202. if (time_after(jiffies, j->cadence_f[5].on2dot)) {
  1203. if(ixjdebug & 0x0004) {
  1204. printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
  1205. }
  1206. ixj_ring_off(j);
  1207. if (j->cadence_f[5].off2) {
  1208. j->cadence_f[5].off2dot = jiffies + (long)((j->cadence_f[5].off2 * (hertz * 100) / 10000));
  1209. j->cadence_f[5].state = 4;
  1210. } else {
  1211. j->cadence_f[5].state = 7;
  1212. }
  1213. }
  1214. break;
  1215. case 4:
  1216. if (time_after(jiffies, j->cadence_f[5].off2dot)) {
  1217. if(ixjdebug & 0x0004) {
  1218. printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
  1219. }
  1220. ixj_ring_on(j);
  1221. if (j->cadence_f[5].on3) {
  1222. j->cadence_f[5].on3dot = jiffies + (long)((j->cadence_f[5].on3 * (hertz * 100) / 10000));
  1223. j->cadence_f[5].state = 5;
  1224. } else {
  1225. j->cadence_f[5].state = 7;
  1226. }
  1227. }
  1228. break;
  1229. case 5:
  1230. if (time_after(jiffies, j->cadence_f[5].on3dot)) {
  1231. if(ixjdebug & 0x0004) {
  1232. printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
  1233. }
  1234. ixj_ring_off(j);
  1235. if (j->cadence_f[5].off3) {
  1236. j->cadence_f[5].off3dot = jiffies + (long)((j->cadence_f[5].off3 * (hertz * 100) / 10000));
  1237. j->cadence_f[5].state = 6;
  1238. } else {
  1239. j->cadence_f[5].state = 7;
  1240. }
  1241. }
  1242. break;
  1243. case 6:
  1244. if (time_after(jiffies, j->cadence_f[5].off3dot)) {
  1245. if(ixjdebug & 0x0004) {
  1246. printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
  1247. }
  1248. j->cadence_f[5].state = 7;
  1249. }
  1250. break;
  1251. case 7:
  1252. if(ixjdebug & 0x0004) {
  1253. printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
  1254. }
  1255. j->flags.cidring = 1;
  1256. j->cadence_f[5].state = 0;
  1257. break;
  1258. }
  1259. if (j->flags.cidring && !j->flags.cidsent) {
  1260. j->flags.cidsent = 1;
  1261. if(j->fskdcnt) {
  1262. SLIC_SetState(PLD_SLIC_STATE_OHT, j);
  1263. ixj_pre_cid(j);
  1264. }
  1265. j->flags.cidring = 0;
  1266. }
  1267. clear_bit(board, &j->busyflags);
  1268. ixj_add_timer(j);
  1269. return;
  1270. } else {
  1271. if (time_after(jiffies, j->ring_cadence_jif + (hertz / 2))) {
  1272. if (j->flags.cidring && !j->flags.cidsent) {
  1273. j->flags.cidsent = 1;
  1274. if(j->fskdcnt) {
  1275. SLIC_SetState(PLD_SLIC_STATE_OHT, j);
  1276. ixj_pre_cid(j);
  1277. }
  1278. j->flags.cidring = 0;
  1279. }
  1280. j->ring_cadence_t--;
  1281. if (j->ring_cadence_t == -1)
  1282. j->ring_cadence_t = 15;
  1283. j->ring_cadence_jif = jiffies;
  1284. if (j->ring_cadence & 1 << j->ring_cadence_t) {
  1285. if(j->flags.cidsent && j->cadence_f[5].en_filter)
  1286. j->flags.firstring = 1;
  1287. else
  1288. ixj_ring_on(j);
  1289. } else {
  1290. ixj_ring_off(j);
  1291. if(!j->flags.cidsent)
  1292. j->flags.cidring = 1;
  1293. }
  1294. }
  1295. clear_bit(board, &j->busyflags);
  1296. ixj_add_timer(j);
  1297. return;
  1298. }
  1299. }
  1300. if (!j->flags.ringing) {
  1301. if (j->hookstate) { /* & 1) { */
  1302. if (j->dsp.low != 0x20 &&
  1303. SLIC_GetState(j) != PLD_SLIC_STATE_ACTIVE) {
  1304. SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
  1305. }
  1306. LineMonitor(j);
  1307. read_filters(j);
  1308. ixj_WriteDSPCommand(0x511B, j);
  1309. j->proc_load = j->ssr.high << 8 | j->ssr.low;
  1310. if (!j->m_hook && (j->hookstate & 1)) {
  1311. j->m_hook = j->ex.bits.hookstate = 1;
  1312. ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
  1313. }
  1314. } else {
  1315. if (j->ex.bits.dtmf_ready) {
  1316. j->dtmf_wp = j->dtmf_rp = j->ex.bits.dtmf_ready = 0;
  1317. }
  1318. if (j->m_hook) {
  1319. j->m_hook = 0;
  1320. j->ex.bits.hookstate = 1;
  1321. ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
  1322. }
  1323. }
  1324. }
  1325. if (j->cardtype == QTI_LINEJACK && !j->flags.pstncheck && j->flags.pstn_present) {
  1326. ixj_pstn_state(j);
  1327. }
  1328. if (j->ex.bytes) {
  1329. wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
  1330. }
  1331. clear_bit(board, &j->busyflags);
  1332. }
  1333. ixj_add_timer(j);
  1334. }
  1335. static int ixj_status_wait(IXJ *j)
  1336. {
  1337. unsigned long jif;
  1338. jif = jiffies + ((60 * hertz) / 100);
  1339. while (!IsStatusReady(j)) {
  1340. ixj_perfmon(j->statuswait);
  1341. if (time_after(jiffies, jif)) {
  1342. ixj_perfmon(j->statuswaitfail);
  1343. return -1;
  1344. }
  1345. }
  1346. return 0;
  1347. }
  1348. static int ixj_PCcontrol_wait(IXJ *j)
  1349. {
  1350. unsigned long jif;
  1351. jif = jiffies + ((60 * hertz) / 100);
  1352. while (!IsPCControlReady(j)) {
  1353. ixj_perfmon(j->pcontrolwait);
  1354. if (time_after(jiffies, jif)) {
  1355. ixj_perfmon(j->pcontrolwaitfail);
  1356. return -1;
  1357. }
  1358. }
  1359. return 0;
  1360. }
  1361. static int ixj_WriteDSPCommand(unsigned short cmd, IXJ *j)
  1362. {
  1363. BYTES bytes;
  1364. unsigned long jif;
  1365. atomic_inc(&j->DSPWrite);
  1366. if(atomic_read(&j->DSPWrite) > 1) {
  1367. printk("IXJ %d DSP write overlap attempting command 0x%4.4x\n", j->board, cmd);
  1368. return -1;
  1369. }
  1370. bytes.high = (cmd & 0xFF00) >> 8;
  1371. bytes.low = cmd & 0x00FF;
  1372. jif = jiffies + ((60 * hertz) / 100);
  1373. while (!IsControlReady(j)) {
  1374. ixj_perfmon(j->iscontrolready);
  1375. if (time_after(jiffies, jif)) {
  1376. ixj_perfmon(j->iscontrolreadyfail);
  1377. atomic_dec(&j->DSPWrite);
  1378. if(atomic_read(&j->DSPWrite) > 0) {
  1379. printk("IXJ %d DSP overlaped command 0x%4.4x during control ready failure.\n", j->board, cmd);
  1380. while(atomic_read(&j->DSPWrite) > 0) {
  1381. atomic_dec(&j->DSPWrite);
  1382. }
  1383. }
  1384. return -1;
  1385. }
  1386. }
  1387. outb(bytes.low, j->DSPbase + 6);
  1388. outb(bytes.high, j->DSPbase + 7);
  1389. if (ixj_status_wait(j)) {
  1390. j->ssr.low = 0xFF;
  1391. j->ssr.high = 0xFF;
  1392. atomic_dec(&j->DSPWrite);
  1393. if(atomic_read(&j->DSPWrite) > 0) {
  1394. printk("IXJ %d DSP overlaped command 0x%4.4x during status wait failure.\n", j->board, cmd);
  1395. while(atomic_read(&j->DSPWrite) > 0) {
  1396. atomic_dec(&j->DSPWrite);
  1397. }
  1398. }
  1399. return -1;
  1400. }
  1401. /* Read Software Status Register */
  1402. j->ssr.low = inb_p(j->DSPbase + 2);
  1403. j->ssr.high = inb_p(j->DSPbase + 3);
  1404. atomic_dec(&j->DSPWrite);
  1405. if(atomic_read(&j->DSPWrite) > 0) {
  1406. printk("IXJ %d DSP overlaped command 0x%4.4x\n", j->board, cmd);
  1407. while(atomic_read(&j->DSPWrite) > 0) {
  1408. atomic_dec(&j->DSPWrite);
  1409. }
  1410. }
  1411. return 0;
  1412. }
  1413. /***************************************************************************
  1414. *
  1415. * General Purpose IO Register read routine
  1416. *
  1417. ***************************************************************************/
  1418. static inline int ixj_gpio_read(IXJ *j)
  1419. {
  1420. if (ixj_WriteDSPCommand(0x5143, j))
  1421. return -1;
  1422. j->gpio.bytes.low = j->ssr.low;
  1423. j->gpio.bytes.high = j->ssr.high;
  1424. return 0;
  1425. }
  1426. static inline void LED_SetState(int state, IXJ *j)
  1427. {
  1428. if (j->cardtype == QTI_LINEJACK) {
  1429. j->pld_scrw.bits.led1 = state & 0x1 ? 1 : 0;
  1430. j->pld_scrw.bits.led2 = state & 0x2 ? 1 : 0;
  1431. j->pld_scrw.bits.led3 = state & 0x4 ? 1 : 0;
  1432. j->pld_scrw.bits.led4 = state & 0x8 ? 1 : 0;
  1433. outb(j->pld_scrw.byte, j->XILINXbase);
  1434. }
  1435. }
  1436. /*********************************************************************
  1437. * GPIO Pins are configured as follows on the Quicknet Internet
  1438. * PhoneJACK Telephony Cards
  1439. *
  1440. * POTS Select GPIO_6=0 GPIO_7=0
  1441. * Mic/Speaker Select GPIO_6=0 GPIO_7=1
  1442. * Handset Select GPIO_6=1 GPIO_7=0
  1443. *
  1444. * SLIC Active GPIO_1=0 GPIO_2=1 GPIO_5=0
  1445. * SLIC Ringing GPIO_1=1 GPIO_2=1 GPIO_5=0
  1446. * SLIC Open Circuit GPIO_1=0 GPIO_2=0 GPIO_5=0
  1447. *
  1448. * Hook Switch changes reported on GPIO_3
  1449. *********************************************************************/
  1450. static int ixj_set_port(IXJ *j, int arg)
  1451. {
  1452. if (j->cardtype == QTI_PHONEJACK_LITE) {
  1453. if (arg != PORT_POTS)
  1454. return 10;
  1455. else
  1456. return 0;
  1457. }
  1458. switch (arg) {
  1459. case PORT_POTS:
  1460. j->port = PORT_POTS;
  1461. switch (j->cardtype) {
  1462. case QTI_PHONECARD:
  1463. if (j->flags.pcmciasct == 1)
  1464. SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
  1465. else
  1466. return 11;
  1467. break;
  1468. case QTI_PHONEJACK_PCI:
  1469. j->pld_slicw.pcib.mic = 0;
  1470. j->pld_slicw.pcib.spk = 0;
  1471. outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
  1472. break;
  1473. case QTI_LINEJACK:
  1474. ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
  1475. if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
  1476. Software Control Register */
  1477. return 2;
  1478. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  1479. outb(j->pld_scrw.byte, j->XILINXbase);
  1480. j->pld_clock.byte = 0;
  1481. outb(j->pld_clock.byte, j->XILINXbase + 0x04);
  1482. j->pld_slicw.bits.rly1 = 1;
  1483. j->pld_slicw.bits.spken = 0;
  1484. outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
  1485. ixj_mixer(0x1200, j); /* Turn Off MIC switch on mixer left */
  1486. ixj_mixer(0x1401, j); /* Turn On Mono1 switch on mixer left */
  1487. ixj_mixer(0x1300, j); /* Turn Off MIC switch on mixer right */
  1488. ixj_mixer(0x1501, j); /* Turn On Mono1 switch on mixer right */
  1489. ixj_mixer(0x0E80, j); /*Mic mute */
  1490. ixj_mixer(0x0F00, j); /* Set mono out (SLIC) to 0dB */
  1491. ixj_mixer(0x0080, j); /* Mute Master Left volume */
  1492. ixj_mixer(0x0180, j); /* Mute Master Right volume */
  1493. SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
  1494. /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
  1495. break;
  1496. case QTI_PHONEJACK:
  1497. j->gpio.bytes.high = 0x0B;
  1498. j->gpio.bits.gpio6 = 0;
  1499. j->gpio.bits.gpio7 = 0;
  1500. ixj_WriteDSPCommand(j->gpio.word, j);
  1501. break;
  1502. }
  1503. break;
  1504. case PORT_PSTN:
  1505. if (j->cardtype == QTI_LINEJACK) {
  1506. ixj_WriteDSPCommand(0xC534, j); /* Write CODEC config to Software Control Register */
  1507. j->pld_slicw.bits.rly3 = 0;
  1508. j->pld_slicw.bits.rly1 = 1;
  1509. j->pld_slicw.bits.spken = 0;
  1510. outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
  1511. j->port = PORT_PSTN;
  1512. } else {
  1513. return 4;
  1514. }
  1515. break;
  1516. case PORT_SPEAKER:
  1517. j->port = PORT_SPEAKER;
  1518. switch (j->cardtype) {
  1519. case QTI_PHONECARD:
  1520. if (j->flags.pcmciasct) {
  1521. SLIC_SetState(PLD_SLIC_STATE_OC, j);
  1522. }
  1523. break;
  1524. case QTI_PHONEJACK_PCI:
  1525. j->pld_slicw.pcib.mic = 1;
  1526. j->pld_slicw.pcib.spk = 1;
  1527. outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
  1528. break;
  1529. case QTI_LINEJACK:
  1530. ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
  1531. if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
  1532. Software Control Register */
  1533. return 2;
  1534. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  1535. outb(j->pld_scrw.byte, j->XILINXbase);
  1536. j->pld_clock.byte = 0;
  1537. outb(j->pld_clock.byte, j->XILINXbase + 0x04);
  1538. j->pld_slicw.bits.rly1 = 1;
  1539. j->pld_slicw.bits.spken = 1;
  1540. outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
  1541. ixj_mixer(0x1201, j); /* Turn On MIC switch on mixer left */
  1542. ixj_mixer(0x1400, j); /* Turn Off Mono1 switch on mixer left */
  1543. ixj_mixer(0x1301, j); /* Turn On MIC switch on mixer right */
  1544. ixj_mixer(0x1500, j); /* Turn Off Mono1 switch on mixer right */
  1545. ixj_mixer(0x0E06, j); /*Mic un-mute 0dB */
  1546. ixj_mixer(0x0F80, j); /* Mute mono out (SLIC) */
  1547. ixj_mixer(0x0000, j); /* Set Master Left volume to 0dB */
  1548. ixj_mixer(0x0100, j); /* Set Master Right volume to 0dB */
  1549. break;
  1550. case QTI_PHONEJACK:
  1551. j->gpio.bytes.high = 0x0B;
  1552. j->gpio.bits.gpio6 = 0;
  1553. j->gpio.bits.gpio7 = 1;
  1554. ixj_WriteDSPCommand(j->gpio.word, j);
  1555. break;
  1556. }
  1557. break;
  1558. case PORT_HANDSET:
  1559. if (j->cardtype != QTI_PHONEJACK) {
  1560. return 5;
  1561. } else {
  1562. j->gpio.bytes.high = 0x0B;
  1563. j->gpio.bits.gpio6 = 1;
  1564. j->gpio.bits.gpio7 = 0;
  1565. ixj_WriteDSPCommand(j->gpio.word, j);
  1566. j->port = PORT_HANDSET;
  1567. }
  1568. break;
  1569. default:
  1570. return 6;
  1571. break;
  1572. }
  1573. return 0;
  1574. }
  1575. static int ixj_set_pots(IXJ *j, int arg)
  1576. {
  1577. if (j->cardtype == QTI_LINEJACK) {
  1578. if (arg) {
  1579. if (j->port == PORT_PSTN) {
  1580. j->pld_slicw.bits.rly1 = 0;
  1581. outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
  1582. j->flags.pots_pstn = 1;
  1583. return 1;
  1584. } else {
  1585. j->flags.pots_pstn = 0;
  1586. return 0;
  1587. }
  1588. } else {
  1589. j->pld_slicw.bits.rly1 = 1;
  1590. outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
  1591. j->flags.pots_pstn = 0;
  1592. return 1;
  1593. }
  1594. } else {
  1595. return 0;
  1596. }
  1597. }
  1598. static void ixj_ring_on(IXJ *j)
  1599. {
  1600. if (j->dsp.low == 0x20) /* Internet PhoneJACK */
  1601. {
  1602. if (ixjdebug & 0x0004)
  1603. printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
  1604. j->gpio.bytes.high = 0x0B;
  1605. j->gpio.bytes.low = 0x00;
  1606. j->gpio.bits.gpio1 = 1;
  1607. j->gpio.bits.gpio2 = 1;
  1608. j->gpio.bits.gpio5 = 0;
  1609. ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring signal */
  1610. } else /* Internet LineJACK, Internet PhoneJACK Lite or Internet PhoneJACK PCI */
  1611. {
  1612. if (ixjdebug & 0x0004)
  1613. printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
  1614. SLIC_SetState(PLD_SLIC_STATE_RINGING, j);
  1615. }
  1616. }
  1617. static int ixj_siadc(IXJ *j, int val)
  1618. {
  1619. if(j->cardtype == QTI_PHONECARD){
  1620. if(j->flags.pcmciascp){
  1621. if(val == -1)
  1622. return j->siadc.bits.rxg;
  1623. if(val < 0 || val > 0x1F)
  1624. return -1;
  1625. j->siadc.bits.hom = 0; /* Handset Out Mute */
  1626. j->siadc.bits.lom = 0; /* Line Out Mute */
  1627. j->siadc.bits.rxg = val; /*(0xC000 - 0x41C8) / 0x4EF; RX PGA Gain */
  1628. j->psccr.bits.addr = 6; /* R/W Smart Cable Register Address */
  1629. j->psccr.bits.rw = 0; /* Read / Write flag */
  1630. j->psccr.bits.dev = 0;
  1631. outb(j->siadc.byte, j->XILINXbase + 0x00);
  1632. outb(j->psccr.byte, j->XILINXbase + 0x01);
  1633. ixj_PCcontrol_wait(j);
  1634. return j->siadc.bits.rxg;
  1635. }
  1636. }
  1637. return -1;
  1638. }
  1639. static int ixj_sidac(IXJ *j, int val)
  1640. {
  1641. if(j->cardtype == QTI_PHONECARD){
  1642. if(j->flags.pcmciascp){
  1643. if(val == -1)
  1644. return j->sidac.bits.txg;
  1645. if(val < 0 || val > 0x1F)
  1646. return -1;
  1647. j->sidac.bits.srm = 1; /* Speaker Right Mute */
  1648. j->sidac.bits.slm = 1; /* Speaker Left Mute */
  1649. j->sidac.bits.txg = val; /* (0xC000 - 0x45E4) / 0x5D3; TX PGA Gain */
  1650. j->psccr.bits.addr = 7; /* R/W Smart Cable Register Address */
  1651. j->psccr.bits.rw = 0; /* Read / Write flag */
  1652. j->psccr.bits.dev = 0;
  1653. outb(j->sidac.byte, j->XILINXbase + 0x00);
  1654. outb(j->psccr.byte, j->XILINXbase + 0x01);
  1655. ixj_PCcontrol_wait(j);
  1656. return j->sidac.bits.txg;
  1657. }
  1658. }
  1659. return -1;
  1660. }
  1661. static int ixj_pcmcia_cable_check(IXJ *j)
  1662. {
  1663. j->pccr1.byte = inb_p(j->XILINXbase + 0x03);
  1664. if (!j->flags.pcmciastate) {
  1665. j->pccr2.byte = inb_p(j->XILINXbase + 0x02);
  1666. if (j->pccr1.bits.drf || j->pccr2.bits.rstc) {
  1667. j->flags.pcmciastate = 4;
  1668. return 0;
  1669. }
  1670. if (j->pccr1.bits.ed) {
  1671. j->pccr1.bits.ed = 0;
  1672. j->psccr.bits.dev = 3;
  1673. j->psccr.bits.rw = 1;
  1674. outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
  1675. ixj_PCcontrol_wait(j);
  1676. j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
  1677. j->pslic.bits.led2 = j->pslic.bits.det ? 1 : 0;
  1678. j->psccr.bits.dev = 3;
  1679. j->psccr.bits.rw = 0;
  1680. outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
  1681. ixj_PCcontrol_wait(j);
  1682. return j->pslic.bits.led2 ? 1 : 0;
  1683. } else if (j->flags.pcmciasct) {
  1684. return j->r_hook;
  1685. } else {
  1686. return 1;
  1687. }
  1688. } else if (j->flags.pcmciastate == 4) {
  1689. if (!j->pccr1.bits.drf) {
  1690. j->flags.pcmciastate = 3;
  1691. }
  1692. return 0;
  1693. } else if (j->flags.pcmciastate == 3) {
  1694. j->pccr2.bits.pwr = 0;
  1695. j->pccr2.bits.rstc = 1;
  1696. outb(j->pccr2.byte, j->XILINXbase + 0x02);
  1697. j->checkwait = jiffies + (hertz * 2);
  1698. j->flags.incheck = 1;
  1699. j->flags.pcmciastate = 2;
  1700. return 0;
  1701. } else if (j->flags.pcmciastate == 2) {
  1702. if (j->flags.incheck) {
  1703. if (time_before(jiffies, j->checkwait)) {
  1704. return 0;
  1705. } else {
  1706. j->flags.incheck = 0;
  1707. }
  1708. }
  1709. j->pccr2.bits.pwr = 0;
  1710. j->pccr2.bits.rstc = 0;
  1711. outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
  1712. j->flags.pcmciastate = 1;
  1713. return 0;
  1714. } else if (j->flags.pcmciastate == 1) {
  1715. j->flags.pcmciastate = 0;
  1716. if (!j->pccr1.bits.drf) {
  1717. j->psccr.bits.dev = 3;
  1718. j->psccr.bits.rw = 1;
  1719. outb_p(j->psccr.byte, j->XILINXbase + 0x01);
  1720. ixj_PCcontrol_wait(j);
  1721. j->flags.pcmciascp = 1; /* Set Cable Present Flag */
  1722. j->flags.pcmciasct = (inw_p(j->XILINXbase + 0x00) >> 8) & 0x03; /* Get Cable Type */
  1723. if (j->flags.pcmciasct == 3) {
  1724. j->flags.pcmciastate = 4;
  1725. return 0;
  1726. } else if (j->flags.pcmciasct == 0) {
  1727. j->pccr2.bits.pwr = 1;
  1728. j->pccr2.bits.rstc = 0;
  1729. outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
  1730. j->port = PORT_SPEAKER;
  1731. } else {
  1732. j->port = PORT_POTS;
  1733. }
  1734. j->sic1.bits.cpd = 0; /* Chip Power Down */
  1735. j->sic1.bits.mpd = 0; /* MIC Bias Power Down */
  1736. j->sic1.bits.hpd = 0; /* Handset Bias Power Down */
  1737. j->sic1.bits.lpd = 0; /* Line Bias Power Down */
  1738. j->sic1.bits.spd = 1; /* Speaker Drive Power Down */
  1739. j->psccr.bits.addr = 1; /* R/W Smart Cable Register Address */
  1740. j->psccr.bits.rw = 0; /* Read / Write flag */
  1741. j->psccr.bits.dev = 0;
  1742. outb(j->sic1.byte, j->XILINXbase + 0x00);
  1743. outb(j->psccr.byte, j->XILINXbase + 0x01);
  1744. ixj_PCcontrol_wait(j);
  1745. j->sic2.bits.al = 0; /* Analog Loopback DAC analog -> ADC analog */
  1746. j->sic2.bits.dl2 = 0; /* Digital Loopback DAC -> ADC one bit */
  1747. j->sic2.bits.dl1 = 0; /* Digital Loopback ADC -> DAC one bit */
  1748. j->sic2.bits.pll = 0; /* 1 = div 10, 0 = div 5 */
  1749. j->sic2.bits.hpd = 0; /* HPF disable */
  1750. j->psccr.bits.addr = 2; /* R/W Smart Cable Register Address */
  1751. j->psccr.bits.rw = 0; /* Read / Write flag */
  1752. j->psccr.bits.dev = 0;
  1753. outb(j->sic2.byte, j->XILINXbase + 0x00);
  1754. outb(j->psccr.byte, j->XILINXbase + 0x01);
  1755. ixj_PCcontrol_wait(j);
  1756. j->psccr.bits.addr = 3; /* R/W Smart Cable Register Address */
  1757. j->psccr.bits.rw = 0; /* Read / Write flag */
  1758. j->psccr.bits.dev = 0;
  1759. outb(0x00, j->XILINXbase + 0x00); /* PLL Divide N1 */
  1760. outb(j->psccr.byte, j->XILINXbase + 0x01);
  1761. ixj_PCcontrol_wait(j);
  1762. j->psccr.bits.addr = 4; /* R/W Smart Cable Register Address */
  1763. j->psccr.bits.rw = 0; /* Read / Write flag */
  1764. j->psccr.bits.dev = 0;
  1765. outb(0x09, j->XILINXbase + 0x00); /* PLL Multiply M1 */
  1766. outb(j->psccr.byte, j->XILINXbase + 0x01);
  1767. ixj_PCcontrol_wait(j);
  1768. j->sirxg.bits.lig = 1; /* Line In Gain */
  1769. j->sirxg.bits.lim = 1; /* Line In Mute */
  1770. j->sirxg.bits.mcg = 0; /* MIC In Gain was 3 */
  1771. j->sirxg.bits.mcm = 0; /* MIC In Mute */
  1772. j->sirxg.bits.him = 0; /* Handset In Mute */
  1773. j->sirxg.bits.iir = 1; /* IIR */
  1774. j->psccr.bits.addr = 5; /* R/W Smart Cable Register Address */
  1775. j->psccr.bits.rw = 0; /* Read / Write flag */
  1776. j->psccr.bits.dev = 0;
  1777. outb(j->sirxg.byte, j->XILINXbase + 0x00);
  1778. outb(j->psccr.byte, j->XILINXbase + 0x01);
  1779. ixj_PCcontrol_wait(j);
  1780. ixj_siadc(j, 0x17);
  1781. ixj_sidac(j, 0x1D);
  1782. j->siaatt.bits.sot = 0;
  1783. j->psccr.bits.addr = 9; /* R/W Smart Cable Register Address */
  1784. j->psccr.bits.rw = 0; /* Read / Write flag */
  1785. j->psccr.bits.dev = 0;
  1786. outb(j->siaatt.byte, j->XILINXbase + 0x00);
  1787. outb(j->psccr.byte, j->XILINXbase + 0x01);
  1788. ixj_PCcontrol_wait(j);
  1789. if (j->flags.pcmciasct == 1 && !j->readers && !j->writers) {
  1790. j->psccr.byte = j->pslic.byte = 0;
  1791. j->pslic.bits.powerdown = 1;
  1792. j->psccr.bits.dev = 3;
  1793. j->psccr.bits.rw = 0;
  1794. outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
  1795. ixj_PCcontrol_wait(j);
  1796. }
  1797. }
  1798. return 0;
  1799. } else {
  1800. j->flags.pcmciascp = 0;
  1801. return 0;
  1802. }
  1803. return 0;
  1804. }
  1805. static int ixj_hookstate(IXJ *j)
  1806. {
  1807. int fOffHook = 0;
  1808. switch (j->cardtype) {
  1809. case QTI_PHONEJACK:
  1810. ixj_gpio_read(j);
  1811. fOffHook = j->gpio.bits.gpio3read ? 1 : 0;
  1812. break;
  1813. case QTI_LINEJACK:
  1814. case QTI_PHONEJACK_LITE:
  1815. case QTI_PHONEJACK_PCI:
  1816. SLIC_GetState(j);
  1817. if(j->cardtype == QTI_LINEJACK && j->flags.pots_pstn == 1 && (j->readers || j->writers)) {
  1818. fOffHook = j->pld_slicr.bits.potspstn ? 1 : 0;
  1819. if(fOffHook != j->p_hook) {
  1820. if(!j->checkwait) {
  1821. j->checkwait = jiffies;
  1822. }
  1823. if(time_before(jiffies, j->checkwait + 2)) {
  1824. fOffHook ^= 1;
  1825. } else {
  1826. j->checkwait = 0;
  1827. }
  1828. j->p_hook = fOffHook;
  1829. printk("IXJ : /dev/phone%d pots-pstn hookstate check %d at %ld\n", j->board, fOffHook, jiffies);
  1830. }
  1831. } else {
  1832. if (j->pld_slicr.bits.state == PLD_SLIC_STATE_ACTIVE ||
  1833. j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) {
  1834. if (j->flags.ringing || j->flags.cringing) {
  1835. if (!in_interrupt()) {
  1836. msleep(20);
  1837. }
  1838. SLIC_GetState(j);
  1839. if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) {
  1840. ixj_ring_on(j);
  1841. }
  1842. }
  1843. if (j->cardtype == QTI_PHONEJACK_PCI) {
  1844. j->pld_scrr.byte = inb_p(j->XILINXbase);
  1845. fOffHook = j->pld_scrr.pcib.det ? 1 : 0;
  1846. } else
  1847. fOffHook = j->pld_slicr.bits.det ? 1 : 0;
  1848. }
  1849. }
  1850. break;
  1851. case QTI_PHONECARD:
  1852. fOffHook = ixj_pcmcia_cable_check(j);
  1853. break;
  1854. }
  1855. if (j->r_hook != fOffHook) {
  1856. j->r_hook = fOffHook;
  1857. if (j->port == PORT_SPEAKER || j->port == PORT_HANDSET) { // || (j->port == PORT_PSTN && j->flags.pots_pstn == 0)) {
  1858. j->ex.bits.hookstate = 1;
  1859. ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
  1860. } else if (!fOffHook) {
  1861. j->flash_end = jiffies + ((60 * hertz) / 100);
  1862. }
  1863. }
  1864. if (fOffHook) {
  1865. if(time_before(jiffies, j->flash_end)) {
  1866. j->ex.bits.flash = 1;
  1867. j->flash_end = 0;
  1868. ixj_kill_fasync(j, SIG_FLASH, POLL_IN);
  1869. }
  1870. } else {
  1871. if(time_before(jiffies, j->flash_end)) {
  1872. fOffHook = 1;
  1873. }
  1874. }
  1875. if (j->port == PORT_PSTN && j->daa_mode == SOP_PU_CONVERSATION)
  1876. fOffHook |= 2;
  1877. if (j->port == PORT_SPEAKER) {
  1878. if(j->cardtype == QTI_PHONECARD) {
  1879. if(j->flags.pcmciascp && j->flags.pcmciasct) {
  1880. fOffHook |= 2;
  1881. }
  1882. } else {
  1883. fOffHook |= 2;
  1884. }
  1885. }
  1886. if (j->port == PORT_HANDSET)
  1887. fOffHook |= 2;
  1888. return fOffHook;
  1889. }
  1890. static void ixj_ring_off(IXJ *j)
  1891. {
  1892. if (j->dsp.low == 0x20) /* Internet PhoneJACK */
  1893. {
  1894. if (ixjdebug & 0x0004)
  1895. printk(KERN_INFO "IXJ Ring Off\n");
  1896. j->gpio.bytes.high = 0x0B;
  1897. j->gpio.bytes.low = 0x00;
  1898. j->gpio.bits.gpio1 = 0;
  1899. j->gpio.bits.gpio2 = 1;
  1900. j->gpio.bits.gpio5 = 0;
  1901. ixj_WriteDSPCommand(j->gpio.word, j);
  1902. } else /* Internet LineJACK */
  1903. {
  1904. if (ixjdebug & 0x0004)
  1905. printk(KERN_INFO "IXJ Ring Off\n");
  1906. if(!j->flags.cidplay)
  1907. SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
  1908. SLIC_GetState(j);
  1909. }
  1910. }
  1911. static void ixj_ring_start(IXJ *j)
  1912. {
  1913. j->flags.cringing = 1;
  1914. if (ixjdebug & 0x0004)
  1915. printk(KERN_INFO "IXJ Cadence Ringing Start /dev/phone%d\n", j->board);
  1916. if (ixj_hookstate(j) & 1) {
  1917. if (j->port == PORT_POTS)
  1918. ixj_ring_off(j);
  1919. j->flags.cringing = 0;
  1920. if (ixjdebug & 0x0004)
  1921. printk(KERN_INFO "IXJ Cadence Ringing Stopped /dev/phone%d off hook\n", j->board);
  1922. } else if(j->cadence_f[5].enable && (!j->cadence_f[5].en_filter)) {
  1923. j->ring_cadence_jif = jiffies;
  1924. j->flags.cidsent = j->flags.cidring = 0;
  1925. j->cadence_f[5].state = 0;
  1926. if(j->cadence_f[5].on1)
  1927. ixj_ring_on(j);
  1928. } else {
  1929. j->ring_cadence_jif = jiffies;
  1930. j->ring_cadence_t = 15;
  1931. if (j->ring_cadence & 1 << j->ring_cadence_t) {
  1932. ixj_ring_on(j);
  1933. } else {
  1934. ixj_ring_off(j);
  1935. }
  1936. j->flags.cidsent = j->flags.cidring = j->flags.firstring = 0;
  1937. }
  1938. }
  1939. static int ixj_ring(IXJ *j)
  1940. {
  1941. char cntr;
  1942. unsigned long jif;
  1943. j->flags.ringing = 1;
  1944. if (ixj_hookstate(j) & 1) {
  1945. ixj_ring_off(j);
  1946. j->flags.ringing = 0;
  1947. return 1;
  1948. }
  1949. for (cntr = 0; cntr < j->maxrings; cntr++) {
  1950. jif = jiffies + (1 * hertz);
  1951. ixj_ring_on(j);
  1952. while (time_before(jiffies, jif)) {
  1953. if (ixj_hookstate(j) & 1) {
  1954. ixj_ring_off(j);
  1955. j->flags.ringing = 0;
  1956. return 1;
  1957. }
  1958. schedule_timeout_interruptible(1);
  1959. if (signal_pending(current))
  1960. break;
  1961. }
  1962. jif = jiffies + (3 * hertz);
  1963. ixj_ring_off(j);
  1964. while (time_before(jiffies, jif)) {
  1965. if (ixj_hookstate(j) & 1) {
  1966. msleep(10);
  1967. if (ixj_hookstate(j) & 1) {
  1968. j->flags.ringing = 0;
  1969. return 1;
  1970. }
  1971. }
  1972. schedule_timeout_interruptible(1);
  1973. if (signal_pending(current))
  1974. break;
  1975. }
  1976. }
  1977. ixj_ring_off(j);
  1978. j->flags.ringing = 0;
  1979. return 0;
  1980. }
  1981. static int ixj_open(struct phone_device *p, struct file *file_p)
  1982. {
  1983. IXJ *j = get_ixj(p->board);
  1984. file_p->private_data = j;
  1985. if (!j->DSPbase)
  1986. return -ENODEV;
  1987. if (file_p->f_mode & FMODE_READ) {
  1988. if(!j->readers) {
  1989. j->readers++;
  1990. } else {
  1991. return -EBUSY;
  1992. }
  1993. }
  1994. if (file_p->f_mode & FMODE_WRITE) {
  1995. if(!j->writers) {
  1996. j->writers++;
  1997. } else {
  1998. if (file_p->f_mode & FMODE_READ){
  1999. j->readers--;
  2000. }
  2001. return -EBUSY;
  2002. }
  2003. }
  2004. if (j->cardtype == QTI_PHONECARD) {
  2005. j->pslic.bits.powerdown = 0;
  2006. j->psccr.bits.dev = 3;
  2007. j->psccr.bits.rw = 0;
  2008. outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
  2009. ixj_PCcontrol_wait(j);
  2010. }
  2011. j->flags.cidplay = 0;
  2012. j->flags.cidcw_ack = 0;
  2013. if (ixjdebug & 0x0002)
  2014. printk(KERN_INFO "Opening board %d\n", p->board);
  2015. j->framesread = j->frameswritten = 0;
  2016. return 0;
  2017. }
  2018. static int ixj_release(struct inode *inode, struct file *file_p)
  2019. {
  2020. IXJ_TONE ti;
  2021. int cnt;
  2022. IXJ *j = file_p->private_data;
  2023. int board = j->p.board;
  2024. /*
  2025. * Set up locks to ensure that only one process is talking to the DSP at a time.
  2026. * This is necessary to keep the DSP from locking up.
  2027. */
  2028. while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
  2029. schedule_timeout_interruptible(1);
  2030. if (ixjdebug & 0x0002)
  2031. printk(KERN_INFO "Closing board %d\n", NUM(inode));
  2032. if (j->cardtype == QTI_PHONECARD)
  2033. ixj_set_port(j, PORT_SPEAKER);
  2034. else
  2035. ixj_set_port(j, PORT_POTS);
  2036. aec_stop(j);
  2037. ixj_play_stop(j);
  2038. ixj_record_stop(j);
  2039. set_play_volume(j, 0x100);
  2040. set_rec_volume(j, 0x100);
  2041. ixj_ring_off(j);
  2042. /* Restore the tone table to default settings. */
  2043. ti.tone_index = 10;
  2044. ti.gain0 = 1;
  2045. ti.freq0 = hz941;
  2046. ti.gain1 = 0;
  2047. ti.freq1 = hz1209;
  2048. ixj_init_tone(j, &ti);
  2049. ti.tone_index = 11;
  2050. ti.gain0 = 1;
  2051. ti.freq0 = hz941;
  2052. ti.gain1 = 0;
  2053. ti.freq1 = hz1336;
  2054. ixj_init_tone(j, &ti);
  2055. ti.tone_index = 12;
  2056. ti.gain0 = 1;
  2057. ti.freq0 = hz941;
  2058. ti.gain1 = 0;
  2059. ti.freq1 = hz1477;
  2060. ixj_init_tone(j, &ti);
  2061. ti.tone_index = 13;
  2062. ti.gain0 = 1;
  2063. ti.freq0 = hz800;
  2064. ti.gain1 = 0;
  2065. ti.freq1 = 0;
  2066. ixj_init_tone(j, &ti);
  2067. ti.tone_index = 14;
  2068. ti.gain0 = 1;
  2069. ti.freq0 = hz1000;
  2070. ti.gain1 = 0;
  2071. ti.freq1 = 0;
  2072. ixj_init_tone(j, &ti);
  2073. ti.tone_index = 15;
  2074. ti.gain0 = 1;
  2075. ti.freq0 = hz1250;
  2076. ti.gain1 = 0;
  2077. ti.freq1 = 0;
  2078. ixj_init_tone(j, &ti);
  2079. ti.tone_index = 16;
  2080. ti.gain0 = 1;
  2081. ti.freq0 = hz950;
  2082. ti.gain1 = 0;
  2083. ti.freq1 = 0;
  2084. ixj_init_tone(j, &ti);
  2085. ti.tone_index = 17;
  2086. ti.gain0 = 1;
  2087. ti.freq0 = hz1100;
  2088. ti.gain1 = 0;
  2089. ti.freq1 = 0;
  2090. ixj_init_tone(j, &ti);
  2091. ti.tone_index = 18;
  2092. ti.gain0 = 1;
  2093. ti.freq0 = hz1400;
  2094. ti.gain1 = 0;
  2095. ti.freq1 = 0;
  2096. ixj_init_tone(j, &ti);
  2097. ti.tone_index = 19;
  2098. ti.gain0 = 1;
  2099. ti.freq0 = hz1500;
  2100. ti.gain1 = 0;
  2101. ti.freq1 = 0;
  2102. ixj_init_tone(j, &ti);
  2103. ti.tone_index = 20;
  2104. ti.gain0 = 1;
  2105. ti.freq0 = hz1600;
  2106. ti.gain1 = 0;
  2107. ti.freq1 = 0;
  2108. ixj_init_tone(j, &ti);
  2109. ti.tone_index = 21;
  2110. ti.gain0 = 1;
  2111. ti.freq0 = hz1800;
  2112. ti.gain1 = 0;
  2113. ti.freq1 = 0;
  2114. ixj_init_tone(j, &ti);
  2115. ti.tone_index = 22;
  2116. ti.gain0 = 1;
  2117. ti.freq0 = hz2100;
  2118. ti.gain1 = 0;
  2119. ti.freq1 = 0;
  2120. ixj_init_tone(j, &ti);
  2121. ti.tone_index = 23;
  2122. ti.gain0 = 1;
  2123. ti.freq0 = hz1300;
  2124. ti.gain1 = 0;
  2125. ti.freq1 = 0;
  2126. ixj_init_tone(j, &ti);
  2127. ti.tone_index = 24;
  2128. ti.gain0 = 1;
  2129. ti.freq0 = hz2450;
  2130. ti.gain1 = 0;
  2131. ti.freq1 = 0;
  2132. ixj_init_tone(j, &ti);
  2133. ti.tone_index = 25;
  2134. ti.gain0 = 1;
  2135. ti.freq0 = hz350;
  2136. ti.gain1 = 0;
  2137. ti.freq1 = hz440;
  2138. ixj_init_tone(j, &ti);
  2139. ti.tone_index = 26;
  2140. ti.gain0 = 1;
  2141. ti.freq0 = hz440;
  2142. ti.gain1 = 0;
  2143. ti.freq1 = hz480;
  2144. ixj_init_tone(j, &ti);
  2145. ti.tone_index = 27;
  2146. ti.gain0 = 1;
  2147. ti.freq0 = hz480;
  2148. ti.gain1 = 0;
  2149. ti.freq1 = hz620;
  2150. ixj_init_tone(j, &ti);
  2151. set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
  2152. set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
  2153. j->ex.bits.dtmf_ready = 0;
  2154. j->dtmf_state = 0;
  2155. j->dtmf_wp = j->dtmf_rp = 0;
  2156. j->rec_mode = j->play_mode = -1;
  2157. j->flags.ringing = 0;
  2158. j->maxrings = MAXRINGS;
  2159. j->ring_cadence = USA_RING_CADENCE;
  2160. if(j->cadence_f[5].enable) {
  2161. j->cadence_f[5].enable = j->cadence_f[5].en_filter = j->cadence_f[5].state = 0;
  2162. }
  2163. j->drybuffer = 0;
  2164. j->winktime = 320;
  2165. j->flags.dtmf_oob = 0;
  2166. for (cnt = 0; cnt < 4; cnt++)
  2167. j->cadence_f[cnt].enable = 0;
  2168. idle(j);
  2169. if(j->cardtype == QTI_PHONECARD) {
  2170. SLIC_SetState(PLD_SLIC_STATE_OC, j);
  2171. }
  2172. if (file_p->f_mode & FMODE_READ)
  2173. j->readers--;
  2174. if (file_p->f_mode & FMODE_WRITE)
  2175. j->writers--;
  2176. if (j->read_buffer && !j->readers) {
  2177. kfree(j->read_buffer);
  2178. j->read_buffer = NULL;
  2179. j->read_buffer_size = 0;
  2180. }
  2181. if (j->write_buffer && !j->writers) {
  2182. kfree(j->write_buffer);
  2183. j->write_buffer = NULL;
  2184. j->write_buffer_size = 0;
  2185. }
  2186. j->rec_codec = j->play_codec = 0;
  2187. j->rec_frame_size = j->play_frame_size = 0;
  2188. j->flags.cidsent = j->flags.cidring = 0;
  2189. if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) {
  2190. ixj_set_port(j, PORT_PSTN);
  2191. daa_set_mode(j, SOP_PU_SLEEP);
  2192. ixj_set_pots(j, 1);
  2193. }
  2194. ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
  2195. /* Set up the default signals for events */
  2196. for (cnt = 0; cnt < 35; cnt++)
  2197. j->ixj_signals[cnt] = SIGIO;
  2198. /* Set the excetion signal enable flags */
  2199. j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
  2200. j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
  2201. j->ex_sig.bits.f3 = j->ex_sig.bits.fc0 = j->ex_sig.bits.fc1 = j->ex_sig.bits.fc2 = j->ex_sig.bits.fc3 = 1;
  2202. file_p->private_data = NULL;
  2203. clear_bit(board, &j->busyflags);
  2204. return 0;
  2205. }
  2206. static int read_filters(IXJ *j)
  2207. {
  2208. unsigned short fc, cnt, trg;
  2209. int var;
  2210. trg = 0;
  2211. if (ixj_WriteDSPCommand(0x5144, j)) {
  2212. if(ixjdebug & 0x0001) {
  2213. printk(KERN_INFO "Read Frame Counter failed!\n");
  2214. }
  2215. return -1;
  2216. }
  2217. fc = j->ssr.high << 8 | j->ssr.low;
  2218. if (fc == j->frame_count)
  2219. return 1;
  2220. j->frame_count = fc;
  2221. if (j->dtmf_proc)
  2222. return 1;
  2223. var = 10;
  2224. for (cnt = 0; cnt < 4; cnt++) {
  2225. if (ixj_WriteDSPCommand(0x5154 + cnt, j)) {
  2226. if(ixjdebug & 0x0001) {
  2227. printk(KERN_INFO "Select Filter %d failed!\n", cnt);
  2228. }
  2229. return -1;
  2230. }
  2231. if (ixj_WriteDSPCommand(0x515C, j)) {
  2232. if(ixjdebug & 0x0001) {
  2233. printk(KERN_INFO "Read Filter History %d failed!\n", cnt);
  2234. }
  2235. return -1;
  2236. }
  2237. j->filter_hist[cnt] = j->ssr.high << 8 | j->ssr.low;
  2238. if (j->cadence_f[cnt].enable) {
  2239. if (j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) {
  2240. if (j->cadence_f[cnt].state == 0) {
  2241. j->cadence_f[cnt].state = 1;
  2242. j->cadence_f[cnt].on1min = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 - var)) / 10000));
  2243. j->cadence_f[cnt].on1dot = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100)) / 10000));
  2244. j->cadence_f[cnt].on1max = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 + var)) / 10000));
  2245. } else if (j->cadence_f[cnt].state == 2 &&
  2246. (time_after(jiffies, j->cadence_f[cnt].off1min) &&
  2247. time_before(jiffies, j->cadence_f[cnt].off1max))) {
  2248. if (j->cadence_f[cnt].on2) {
  2249. j->cadence_f[cnt].state = 3;
  2250. j->cadence_f[cnt].on2min = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 - var)) / 10000));
  2251. j->cadence_f[cnt].on2dot = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100)) / 10000));
  2252. j->cadence_f[cnt].on2max = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 + var)) / 10000));
  2253. } else {
  2254. j->cadence_f[cnt].state = 7;
  2255. }
  2256. } else if (j->cadence_f[cnt].state == 4 &&
  2257. (time_after(jiffies, j->cadence_f[cnt].off2min) &&
  2258. time_before(jiffies, j->cadence_f[cnt].off2max))) {
  2259. if (j->cadence_f[cnt].on3) {
  2260. j->cadence_f[cnt].state = 5;
  2261. j->cadence_f[cnt].on3min = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 - var)) / 10000));
  2262. j->cadence_f[cnt].on3dot = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100)) / 10000));
  2263. j->cadence_f[cnt].on3max = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 + var)) / 10000));
  2264. } else {
  2265. j->cadence_f[cnt].state = 7;
  2266. }
  2267. } else {
  2268. j->cadence_f[cnt].state = 0;
  2269. }
  2270. } else if (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)) {
  2271. if (j->cadence_f[cnt].state == 1) {
  2272. if(!j->cadence_f[cnt].on1) {
  2273. j->cadence_f[cnt].state = 7;
  2274. } else if((time_after(jiffies, j->cadence_f[cnt].on1min) &&
  2275. time_before(jiffies, j->cadence_f[cnt].on1max))) {
  2276. if(j->cadence_f[cnt].off1) {
  2277. j->cadence_f[cnt].state = 2;
  2278. j->cadence_f[cnt].off1min = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 - var)) / 10000));
  2279. j->cadence_f[cnt].off1dot = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100)) / 10000));
  2280. j->cadence_f[cnt].off1max = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 + var)) / 10000));
  2281. } else {
  2282. j->cadence_f[cnt].state = 7;
  2283. }
  2284. } else {
  2285. j->cadence_f[cnt].state = 0;
  2286. }
  2287. } else if (j->cadence_f[cnt].state == 3) {
  2288. if((time_after(jiffies, j->cadence_f[cnt].on2min) &&
  2289. time_before(jiffies, j->cadence_f[cnt].on2max))) {
  2290. if(j->cadence_f[cnt].off2) {
  2291. j->cadence_f[cnt].state = 4;
  2292. j->cadence_f[cnt].off2min = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 - var)) / 10000));
  2293. j->cadence_f[cnt].off2dot = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100)) / 10000));
  2294. j->cadence_f[cnt].off2max = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 + var)) / 10000));
  2295. } else {
  2296. j->cadence_f[cnt].state = 7;
  2297. }
  2298. } else {
  2299. j->cadence_f[cnt].state = 0;
  2300. }
  2301. } else if (j->cadence_f[cnt].state == 5) {
  2302. if ((time_after(jiffies, j->cadence_f[cnt].on3min) &&
  2303. time_before(jiffies, j->cadence_f[cnt].on3max))) {
  2304. if(j->cadence_f[cnt].off3) {
  2305. j->cadence_f[cnt].state = 6;
  2306. j->cadence_f[cnt].off3min = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 - var)) / 10000));
  2307. j->cadence_f[cnt].off3dot = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100)) / 10000));
  2308. j->cadence_f[cnt].off3max = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 + var)) / 10000));
  2309. } else {
  2310. j->cadence_f[cnt].state = 7;
  2311. }
  2312. } else {
  2313. j->cadence_f[cnt].state = 0;
  2314. }
  2315. } else {
  2316. j->cadence_f[cnt].state = 0;
  2317. }
  2318. } else {
  2319. switch(j->cadence_f[cnt].state) {
  2320. case 1:
  2321. if(time_after(jiffies, j->cadence_f[cnt].on1dot) &&
  2322. !j->cadence_f[cnt].off1 &&
  2323. !j->cadence_f[cnt].on2 && !j->cadence_f[cnt].off2 &&
  2324. !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
  2325. j->cadence_f[cnt].state = 7;
  2326. }
  2327. break;
  2328. case 3:
  2329. if(time_after(jiffies, j->cadence_f[cnt].on2dot) &&
  2330. !j->cadence_f[cnt].off2 &&
  2331. !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
  2332. j->cadence_f[cnt].state = 7;
  2333. }
  2334. break;
  2335. case 5:
  2336. if(time_after(jiffies, j->cadence_f[cnt].on3dot) &&
  2337. !j->cadence_f[cnt].off3) {
  2338. j->cadence_f[cnt].state = 7;
  2339. }
  2340. break;
  2341. }
  2342. }
  2343. if (ixjdebug & 0x0040) {
  2344. printk(KERN_INFO "IXJ Tone Cadence state = %d /dev/phone%d at %ld\n", j->cadence_f[cnt].state, j->board, jiffies);
  2345. switch(j->cadence_f[cnt].state) {
  2346. case 0:
  2347. printk(KERN_INFO "IXJ /dev/phone%d No Tone detected\n", j->board);
  2348. break;
  2349. case 1:
  2350. printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %u %ld - %ld - %ld\n", j->board,
  2351. j->cadence_f[cnt].on1, j->cadence_f[cnt].on1min, j->cadence_f[cnt].on1dot, j->cadence_f[cnt].on1max);
  2352. break;
  2353. case 2:
  2354. printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min,
  2355. j->cadence_f[cnt].off1max);
  2356. break;
  2357. case 3:
  2358. printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on2min,
  2359. j->cadence_f[cnt].on2max);
  2360. break;
  2361. case 4:
  2362. printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off2min,
  2363. j->cadence_f[cnt].off2max);
  2364. break;
  2365. case 5:
  2366. printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on3min,
  2367. j->cadence_f[cnt].on3max);
  2368. break;
  2369. case 6:
  2370. printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off3min,
  2371. j->cadence_f[cnt].off3max);
  2372. break;
  2373. }
  2374. }
  2375. }
  2376. if (j->cadence_f[cnt].state == 7) {
  2377. j->cadence_f[cnt].state = 0;
  2378. if (j->cadence_f[cnt].enable == 1)
  2379. j->cadence_f[cnt].enable = 0;
  2380. switch (cnt) {
  2381. case 0:
  2382. if(ixjdebug & 0x0020) {
  2383. printk(KERN_INFO "Filter Cadence 0 triggered %ld\n", jiffies);
  2384. }
  2385. j->ex.bits.fc0 = 1;
  2386. ixj_kill_fasync(j, SIG_FC0, POLL_IN);
  2387. break;
  2388. case 1:
  2389. if(ixjdebug & 0x0020) {
  2390. printk(KERN_INFO "Filter Cadence 1 triggered %ld\n", jiffies);
  2391. }
  2392. j->ex.bits.fc1 = 1;
  2393. ixj_kill_fasync(j, SIG_FC1, POLL_IN);
  2394. break;
  2395. case 2:
  2396. if(ixjdebug & 0x0020) {
  2397. printk(KERN_INFO "Filter Cadence 2 triggered %ld\n", jiffies);
  2398. }
  2399. j->ex.bits.fc2 = 1;
  2400. ixj_kill_fasync(j, SIG_FC2, POLL_IN);
  2401. break;
  2402. case 3:
  2403. if(ixjdebug & 0x0020) {
  2404. printk(KERN_INFO "Filter Cadence 3 triggered %ld\n", jiffies);
  2405. }
  2406. j->ex.bits.fc3 = 1;
  2407. ixj_kill_fasync(j, SIG_FC3, POLL_IN);
  2408. break;
  2409. }
  2410. }
  2411. if (j->filter_en[cnt] && ((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) ||
  2412. (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)))) {
  2413. if((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12))) {
  2414. trg = 1;
  2415. } else if((j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3))) {
  2416. trg = 0;
  2417. }
  2418. switch (cnt) {
  2419. case 0:
  2420. if(ixjdebug & 0x0020) {
  2421. printk(KERN_INFO "Filter 0 triggered %d at %ld\n", trg, jiffies);
  2422. }
  2423. j->ex.bits.f0 = 1;
  2424. ixj_kill_fasync(j, SIG_F0, POLL_IN);
  2425. break;
  2426. case 1:
  2427. if(ixjdebug & 0x0020) {
  2428. printk(KERN_INFO "Filter 1 triggered %d at %ld\n", trg, jiffies);
  2429. }
  2430. j->ex.bits.f1 = 1;
  2431. ixj_kill_fasync(j, SIG_F1, POLL_IN);
  2432. break;
  2433. case 2:
  2434. if(ixjdebug & 0x0020) {
  2435. printk(KERN_INFO "Filter 2 triggered %d at %ld\n", trg, jiffies);
  2436. }
  2437. j->ex.bits.f2 = 1;
  2438. ixj_kill_fasync(j, SIG_F2, POLL_IN);
  2439. break;
  2440. case 3:
  2441. if(ixjdebug & 0x0020) {
  2442. printk(KERN_INFO "Filter 3 triggered %d at %ld\n", trg, jiffies);
  2443. }
  2444. j->ex.bits.f3 = 1;
  2445. ixj_kill_fasync(j, SIG_F3, POLL_IN);
  2446. break;
  2447. }
  2448. }
  2449. }
  2450. return 0;
  2451. }
  2452. static int LineMonitor(IXJ *j)
  2453. {
  2454. if (j->dtmf_proc) {
  2455. return -1;
  2456. }
  2457. j->dtmf_proc = 1;
  2458. if (ixj_WriteDSPCommand(0x7000, j)) /* Line Monitor */
  2459. return -1;
  2460. j->dtmf.bytes.high = j->ssr.high;
  2461. j->dtmf.bytes.low = j->ssr.low;
  2462. if (!j->dtmf_state && j->dtmf.bits.dtmf_valid) {
  2463. j->dtmf_state = 1;
  2464. j->dtmf_current = j->dtmf.bits.digit;
  2465. }
  2466. if (j->dtmf_state && !j->dtmf.bits.dtmf_valid) /* && j->dtmf_wp != j->dtmf_rp) */
  2467. {
  2468. if(!j->cidcw_wait) {
  2469. j->dtmfbuffer[j->dtmf_wp] = j->dtmf_current;
  2470. j->dtmf_wp++;
  2471. if (j->dtmf_wp == 79)
  2472. j->dtmf_wp = 0;
  2473. j->ex.bits.dtmf_ready = 1;
  2474. if(j->ex_sig.bits.dtmf_ready) {
  2475. ixj_kill_fasync(j, SIG_DTMF_READY, POLL_IN);
  2476. }
  2477. }
  2478. else if(j->dtmf_current == 0x00 || j->dtmf_current == 0x0D) {
  2479. if(ixjdebug & 0x0020) {
  2480. printk("IXJ phone%d saw CIDCW Ack DTMF %d from display at %ld\n", j->board, j->dtmf_current, jiffies);
  2481. }
  2482. j->flags.cidcw_ack = 1;
  2483. }
  2484. j->dtmf_state = 0;
  2485. }
  2486. j->dtmf_proc = 0;
  2487. return 0;
  2488. }
  2489. /************************************************************************
  2490. *
  2491. * Functions to allow alaw <-> ulaw conversions.
  2492. *
  2493. ************************************************************************/
  2494. static void ulaw2alaw(unsigned char *buff, unsigned long len)
  2495. {
  2496. static unsigned char table_ulaw2alaw[] =
  2497. {
  2498. 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D,
  2499. 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25,
  2500. 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D,
  2501. 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35,
  2502. 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02,
  2503. 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A,
  2504. 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12,
  2505. 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B,
  2506. 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63,
  2507. 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79,
  2508. 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71,
  2509. 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D,
  2510. 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45,
  2511. 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D,
  2512. 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51,
  2513. 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5,
  2514. 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD,
  2515. 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5,
  2516. 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD,
  2517. 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5,
  2518. 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82,
  2519. 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A,
  2520. 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92,
  2521. 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB,
  2522. 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3,
  2523. 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9,
  2524. 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1,
  2525. 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD,
  2526. 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5,
  2527. 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD,
  2528. 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1,
  2529. 0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5
  2530. };
  2531. while (len--)
  2532. {
  2533. *buff = table_ulaw2alaw[*(unsigned char *)buff];
  2534. buff++;
  2535. }
  2536. }
  2537. static void alaw2ulaw(unsigned char *buff, unsigned long len)
  2538. {
  2539. static unsigned char table_alaw2ulaw[] =
  2540. {
  2541. 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C,
  2542. 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24,
  2543. 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C,
  2544. 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34,
  2545. 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D,
  2546. 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
  2547. 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D,
  2548. 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15,
  2549. 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65,
  2550. 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E,
  2551. 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A,
  2552. 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D,
  2553. 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B,
  2554. 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43,
  2555. 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59,
  2556. 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51,
  2557. 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC,
  2558. 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4,
  2559. 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC,
  2560. 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4,
  2561. 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D,
  2562. 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85,
  2563. 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D,
  2564. 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95,
  2565. 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5,
  2566. 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE,
  2567. 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA,
  2568. 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED,
  2569. 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB,
  2570. 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3,
  2571. 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9,
  2572. 0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1
  2573. };
  2574. while (len--)
  2575. {
  2576. *buff = table_alaw2ulaw[*(unsigned char *)buff];
  2577. buff++;
  2578. }
  2579. }
  2580. static ssize_t ixj_read(struct file * file_p, char __user *buf, size_t length, loff_t * ppos)
  2581. {
  2582. unsigned long i = *ppos;
  2583. IXJ * j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
  2584. DECLARE_WAITQUEUE(wait, current);
  2585. if (j->flags.inread)
  2586. return -EALREADY;
  2587. j->flags.inread = 1;
  2588. add_wait_queue(&j->read_q, &wait);
  2589. set_current_state(TASK_INTERRUPTIBLE);
  2590. mb();
  2591. while (!j->read_buffer_ready || (j->dtmf_state && j->flags.dtmf_oob)) {
  2592. ++j->read_wait;
  2593. if (file_p->f_flags & O_NONBLOCK) {
  2594. set_current_state(TASK_RUNNING);
  2595. remove_wait_queue(&j->read_q, &wait);
  2596. j->flags.inread = 0;
  2597. return -EAGAIN;
  2598. }
  2599. if (!ixj_hookstate(j)) {
  2600. set_current_state(TASK_RUNNING);
  2601. remove_wait_queue(&j->read_q, &wait);
  2602. j->flags.inread = 0;
  2603. return 0;
  2604. }
  2605. interruptible_sleep_on(&j->read_q);
  2606. if (signal_pending(current)) {
  2607. set_current_state(TASK_RUNNING);
  2608. remove_wait_queue(&j->read_q, &wait);
  2609. j->flags.inread = 0;
  2610. return -EINTR;
  2611. }
  2612. }
  2613. remove_wait_queue(&j->read_q, &wait);
  2614. set_current_state(TASK_RUNNING);
  2615. /* Don't ever copy more than the user asks */
  2616. if(j->rec_codec == ALAW)
  2617. ulaw2alaw(j->read_buffer, min(length, j->read_buffer_size));
  2618. i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size));
  2619. j->read_buffer_ready = 0;
  2620. if (i) {
  2621. j->flags.inread = 0;
  2622. return -EFAULT;
  2623. } else {
  2624. j->flags.inread = 0;
  2625. return min(length, j->read_buffer_size);
  2626. }
  2627. }
  2628. static ssize_t ixj_enhanced_read(struct file * file_p, char __user *buf, size_t length,
  2629. loff_t * ppos)
  2630. {
  2631. int pre_retval;
  2632. ssize_t read_retval = 0;
  2633. IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
  2634. pre_retval = ixj_PreRead(j, 0L);
  2635. switch (pre_retval) {
  2636. case NORMAL:
  2637. read_retval = ixj_read(file_p, buf, length, ppos);
  2638. ixj_PostRead(j, 0L);
  2639. break;
  2640. case NOPOST:
  2641. read_retval = ixj_read(file_p, buf, length, ppos);
  2642. break;
  2643. case POSTONLY:
  2644. ixj_PostRead(j, 0L);
  2645. break;
  2646. default:
  2647. read_retval = pre_retval;
  2648. }
  2649. return read_retval;
  2650. }
  2651. static ssize_t ixj_write(struct file *file_p, const char __user *buf, size_t count, loff_t * ppos)
  2652. {
  2653. unsigned long i = *ppos;
  2654. IXJ *j = file_p->private_data;
  2655. DECLARE_WAITQUEUE(wait, current);
  2656. if (j->flags.inwrite)
  2657. return -EALREADY;
  2658. j->flags.inwrite = 1;
  2659. add_wait_queue(&j->write_q, &wait);
  2660. set_current_state(TASK_INTERRUPTIBLE);
  2661. mb();
  2662. while (!j->write_buffers_empty) {
  2663. ++j->write_wait;
  2664. if (file_p->f_flags & O_NONBLOCK) {
  2665. set_current_state(TASK_RUNNING);
  2666. remove_wait_queue(&j->write_q, &wait);
  2667. j->flags.inwrite = 0;
  2668. return -EAGAIN;
  2669. }
  2670. if (!ixj_hookstate(j)) {
  2671. set_current_state(TASK_RUNNING);
  2672. remove_wait_queue(&j->write_q, &wait);
  2673. j->flags.inwrite = 0;
  2674. return 0;
  2675. }
  2676. interruptible_sleep_on(&j->write_q);
  2677. if (signal_pending(current)) {
  2678. set_current_state(TASK_RUNNING);
  2679. remove_wait_queue(&j->write_q, &wait);
  2680. j->flags.inwrite = 0;
  2681. return -EINTR;
  2682. }
  2683. }
  2684. set_current_state(TASK_RUNNING);
  2685. remove_wait_queue(&j->write_q, &wait);
  2686. if (j->write_buffer_wp + count >= j->write_buffer_end)
  2687. j->write_buffer_wp = j->write_buffer;
  2688. i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size));
  2689. if (i) {
  2690. j->flags.inwrite = 0;
  2691. return -EFAULT;
  2692. }
  2693. if(j->play_codec == ALAW)
  2694. alaw2ulaw(j->write_buffer_wp, min(count, j->write_buffer_size));
  2695. j->flags.inwrite = 0;
  2696. return min(count, j->write_buffer_size);
  2697. }
  2698. static ssize_t ixj_enhanced_write(struct file * file_p, const char __user *buf, size_t count, loff_t * ppos)
  2699. {
  2700. int pre_retval;
  2701. ssize_t write_retval = 0;
  2702. IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
  2703. pre_retval = ixj_PreWrite(j, 0L);
  2704. switch (pre_retval) {
  2705. case NORMAL:
  2706. write_retval = ixj_write(file_p, buf, count, ppos);
  2707. if (write_retval > 0) {
  2708. ixj_PostWrite(j, 0L);
  2709. j->write_buffer_wp += write_retval;
  2710. j->write_buffers_empty--;
  2711. }
  2712. break;
  2713. case NOPOST:
  2714. write_retval = ixj_write(file_p, buf, count, ppos);
  2715. if (write_retval > 0) {
  2716. j->write_buffer_wp += write_retval;
  2717. j->write_buffers_empty--;
  2718. }
  2719. break;
  2720. case POSTONLY:
  2721. ixj_PostWrite(j, 0L);
  2722. break;
  2723. default:
  2724. write_retval = pre_retval;
  2725. }
  2726. return write_retval;
  2727. }
  2728. static void ixj_read_frame(IXJ *j)
  2729. {
  2730. int cnt, dly;
  2731. if (j->read_buffer) {
  2732. for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
  2733. if (!(cnt % 16) && !IsRxReady(j)) {
  2734. dly = 0;
  2735. while (!IsRxReady(j)) {
  2736. if (dly++ > 5) {
  2737. dly = 0;
  2738. break;
  2739. }
  2740. udelay(10);
  2741. }
  2742. }
  2743. /* Throw away word 0 of the 8021 compressed format to get standard G.729. */
  2744. if (j->rec_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
  2745. inb_p(j->DSPbase + 0x0E);
  2746. inb_p(j->DSPbase + 0x0F);
  2747. }
  2748. *(j->read_buffer + cnt) = inb_p(j->DSPbase + 0x0E);
  2749. *(j->read_buffer + cnt + 1) = inb_p(j->DSPbase + 0x0F);
  2750. }
  2751. ++j->framesread;
  2752. if (j->intercom != -1) {
  2753. if (IsTxReady(get_ixj(j->intercom))) {
  2754. for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
  2755. if (!(cnt % 16) && !IsTxReady(j)) {
  2756. dly = 0;
  2757. while (!IsTxReady(j)) {
  2758. if (dly++ > 5) {
  2759. dly = 0;
  2760. break;
  2761. }
  2762. udelay(10);
  2763. }
  2764. }
  2765. outb_p(*(j->read_buffer + cnt), get_ixj(j->intercom)->DSPbase + 0x0C);
  2766. outb_p(*(j->read_buffer + cnt + 1), get_ixj(j->intercom)->DSPbase + 0x0D);
  2767. }
  2768. get_ixj(j->intercom)->frameswritten++;
  2769. }
  2770. } else {
  2771. j->read_buffer_ready = 1;
  2772. wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
  2773. wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
  2774. if(j->ixj_signals[SIG_READ_READY])
  2775. ixj_kill_fasync(j, SIG_READ_READY, POLL_OUT);
  2776. }
  2777. }
  2778. }
  2779. static short fsk[][6][20] =
  2780. {
  2781. {
  2782. {
  2783. 0, 17846, 29934, 32364, 24351, 8481, -10126, -25465, -32587, -29196,
  2784. -16384, 1715, 19260, 30591, 32051, 23170, 6813, -11743, -26509, -32722
  2785. },
  2786. {
  2787. -28377, -14876, 3425, 20621, 31163, 31650, 21925, 5126, -13328, -27481,
  2788. -32767, -27481, -13328, 5126, 21925, 31650, 31163, 20621, 3425, -14876
  2789. },
  2790. {
  2791. -28377, -32722, -26509, -11743, 6813, 23170, 32051, 30591, 19260, 1715,
  2792. -16384, -29196, -32587, -25465, -10126, 8481, 24351, 32364, 29934, 17846
  2793. },
  2794. {
  2795. 0, -17846, -29934, -32364, -24351, -8481, 10126, 25465, 32587, 29196,
  2796. 16384, -1715, -19260, -30591, -32051, -23170, -6813, 11743, 26509, 32722
  2797. },
  2798. {
  2799. 28377, 14876, -3425, -20621, -31163, -31650, -21925, -5126, 13328, 27481,
  2800. 32767, 27481, 13328, -5126, -21925, -31650, -31163, -20621, -3425, 14876
  2801. },
  2802. {
  2803. 28377, 32722, 26509, 11743, -6813, -23170, -32051, -30591, -19260, -1715,
  2804. 16384, 29196, 32587, 25465, 10126, -8481, -24351, -32364, -29934, -17846
  2805. }
  2806. },
  2807. {
  2808. {
  2809. 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126,
  2810. 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126
  2811. },
  2812. {
  2813. -28377, -21925, -13328, -3425, 6813, 16384, 24351, 29934, 32587, 32051,
  2814. 28377, 21925, 13328, 3425, -6813, -16384, -24351, -29934, -32587, -32051
  2815. },
  2816. {
  2817. -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925,
  2818. 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925
  2819. },
  2820. {
  2821. 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126,
  2822. 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126
  2823. },
  2824. {
  2825. 28377, 21925, 13328, 3425, -6813, -16383, -24351, -29934, -32587, -32051,
  2826. -28377, -21925, -13328, -3425, 6813, 16383, 24351, 29934, 32587, 32051
  2827. },
  2828. {
  2829. 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925,
  2830. -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925
  2831. }
  2832. }
  2833. };
  2834. static void ixj_write_cid_bit(IXJ *j, int bit)
  2835. {
  2836. while (j->fskcnt < 20) {
  2837. if(j->fskdcnt < (j->fsksize - 1))
  2838. j->fskdata[j->fskdcnt++] = fsk[bit][j->fskz][j->fskcnt];
  2839. j->fskcnt += 3;
  2840. }
  2841. j->fskcnt %= 20;
  2842. if (!bit)
  2843. j->fskz++;
  2844. if (j->fskz >= 6)
  2845. j->fskz = 0;
  2846. }
  2847. static void ixj_write_cid_byte(IXJ *j, char byte)
  2848. {
  2849. IXJ_CBYTE cb;
  2850. cb.cbyte = byte;
  2851. ixj_write_cid_bit(j, 0);
  2852. ixj_write_cid_bit(j, cb.cbits.b0 ? 1 : 0);
  2853. ixj_write_cid_bit(j, cb.cbits.b1 ? 1 : 0);
  2854. ixj_write_cid_bit(j, cb.cbits.b2 ? 1 : 0);
  2855. ixj_write_cid_bit(j, cb.cbits.b3 ? 1 : 0);
  2856. ixj_write_cid_bit(j, cb.cbits.b4 ? 1 : 0);
  2857. ixj_write_cid_bit(j, cb.cbits.b5 ? 1 : 0);
  2858. ixj_write_cid_bit(j, cb.cbits.b6 ? 1 : 0);
  2859. ixj_write_cid_bit(j, cb.cbits.b7 ? 1 : 0);
  2860. ixj_write_cid_bit(j, 1);
  2861. }
  2862. static void ixj_write_cid_seize(IXJ *j)
  2863. {
  2864. int cnt;
  2865. for (cnt = 0; cnt < 150; cnt++) {
  2866. ixj_write_cid_bit(j, 0);
  2867. ixj_write_cid_bit(j, 1);
  2868. }
  2869. for (cnt = 0; cnt < 180; cnt++) {
  2870. ixj_write_cid_bit(j, 1);
  2871. }
  2872. }
  2873. static void ixj_write_cidcw_seize(IXJ *j)
  2874. {
  2875. int cnt;
  2876. for (cnt = 0; cnt < 80; cnt++) {
  2877. ixj_write_cid_bit(j, 1);
  2878. }
  2879. }
  2880. static int ixj_write_cid_string(IXJ *j, char *s, int checksum)
  2881. {
  2882. int cnt;
  2883. for (cnt = 0; cnt < strlen(s); cnt++) {
  2884. ixj_write_cid_byte(j, s[cnt]);
  2885. checksum = (checksum + s[cnt]);
  2886. }
  2887. return checksum;
  2888. }
  2889. static void ixj_pad_fsk(IXJ *j, int pad)
  2890. {
  2891. int cnt;
  2892. for (cnt = 0; cnt < pad; cnt++) {
  2893. if(j->fskdcnt < (j->fsksize - 1))
  2894. j->fskdata[j->fskdcnt++] = 0x0000;
  2895. }
  2896. for (cnt = 0; cnt < 720; cnt++) {
  2897. if(j->fskdcnt < (j->fsksize - 1))
  2898. j->fskdata[j->fskdcnt++] = 0x0000;
  2899. }
  2900. }
  2901. static void ixj_pre_cid(IXJ *j)
  2902. {
  2903. j->cid_play_codec = j->play_codec;
  2904. j->cid_play_frame_size = j->play_frame_size;
  2905. j->cid_play_volume = get_play_volume(j);
  2906. j->cid_play_flag = j->flags.playing;
  2907. j->cid_rec_codec = j->rec_codec;
  2908. j->cid_rec_volume = get_rec_volume(j);
  2909. j->cid_rec_flag = j->flags.recording;
  2910. j->cid_play_aec_level = j->aec_level;
  2911. switch(j->baseframe.low) {
  2912. case 0xA0:
  2913. j->cid_base_frame_size = 20;
  2914. break;
  2915. case 0x50:
  2916. j->cid_base_frame_size = 10;
  2917. break;
  2918. case 0xF0:
  2919. j->cid_base_frame_size = 30;
  2920. break;
  2921. }
  2922. ixj_play_stop(j);
  2923. ixj_cpt_stop(j);
  2924. j->flags.cidplay = 1;
  2925. set_base_frame(j, 30);
  2926. set_play_codec(j, LINEAR16);
  2927. set_play_volume(j, 0x1B);
  2928. ixj_play_start(j);
  2929. }
  2930. static void ixj_post_cid(IXJ *j)
  2931. {
  2932. ixj_play_stop(j);
  2933. if(j->cidsize > 5000) {
  2934. SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
  2935. }
  2936. j->flags.cidplay = 0;
  2937. if(ixjdebug & 0x0200) {
  2938. printk("IXJ phone%d Finished Playing CallerID data %ld\n", j->board, jiffies);
  2939. }
  2940. ixj_fsk_free(j);
  2941. j->fskdcnt = 0;
  2942. set_base_frame(j, j->cid_base_frame_size);
  2943. set_play_codec(j, j->cid_play_codec);
  2944. ixj_aec_start(j, j->cid_play_aec_level);
  2945. set_play_volume(j, j->cid_play_volume);
  2946. set_rec_codec(j, j->cid_rec_codec);
  2947. set_rec_volume(j, j->cid_rec_volume);
  2948. if(j->cid_rec_flag)
  2949. ixj_record_start(j);
  2950. if(j->cid_play_flag)
  2951. ixj_play_start(j);
  2952. if(j->cid_play_flag) {
  2953. wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
  2954. }
  2955. }
  2956. static void ixj_write_cid(IXJ *j)
  2957. {
  2958. char sdmf1[50];
  2959. char sdmf2[50];
  2960. char sdmf3[80];
  2961. char mdmflen, len1, len2, len3;
  2962. int pad;
  2963. int checksum = 0;
  2964. if (j->dsp.low == 0x20 || j->flags.cidplay)
  2965. return;
  2966. j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
  2967. j->cidsize = j->cidcnt = 0;
  2968. ixj_fsk_alloc(j);
  2969. strcpy(sdmf1, j->cid_send.month);
  2970. strcat(sdmf1, j->cid_send.day);
  2971. strcat(sdmf1, j->cid_send.hour);
  2972. strcat(sdmf1, j->cid_send.min);
  2973. strcpy(sdmf2, j->cid_send.number);
  2974. strcpy(sdmf3, j->cid_send.name);
  2975. len1 = strlen(sdmf1);
  2976. len2 = strlen(sdmf2);
  2977. len3 = strlen(sdmf3);
  2978. mdmflen = len1 + len2 + len3 + 6;
  2979. while(1){
  2980. ixj_write_cid_seize(j);
  2981. ixj_write_cid_byte(j, 0x80);
  2982. checksum = 0x80;
  2983. ixj_write_cid_byte(j, mdmflen);
  2984. checksum = checksum + mdmflen;
  2985. ixj_write_cid_byte(j, 0x01);
  2986. checksum = checksum + 0x01;
  2987. ixj_write_cid_byte(j, len1);
  2988. checksum = checksum + len1;
  2989. checksum = ixj_write_cid_string(j, sdmf1, checksum);
  2990. if(ixj_hookstate(j) & 1)
  2991. break;
  2992. ixj_write_cid_byte(j, 0x02);
  2993. checksum = checksum + 0x02;
  2994. ixj_write_cid_byte(j, len2);
  2995. checksum = checksum + len2;
  2996. checksum = ixj_write_cid_string(j, sdmf2, checksum);
  2997. if(ixj_hookstate(j) & 1)
  2998. break;
  2999. ixj_write_cid_byte(j, 0x07);
  3000. checksum = checksum + 0x07;
  3001. ixj_write_cid_byte(j, len3);
  3002. checksum = checksum + len3;
  3003. checksum = ixj_write_cid_string(j, sdmf3, checksum);
  3004. if(ixj_hookstate(j) & 1)
  3005. break;
  3006. checksum %= 256;
  3007. checksum ^= 0xFF;
  3008. checksum += 1;
  3009. ixj_write_cid_byte(j, (char) checksum);
  3010. pad = j->fskdcnt % 240;
  3011. if (pad) {
  3012. pad = 240 - pad;
  3013. }
  3014. ixj_pad_fsk(j, pad);
  3015. break;
  3016. }
  3017. ixj_write_frame(j);
  3018. }
  3019. static void ixj_write_cidcw(IXJ *j)
  3020. {
  3021. IXJ_TONE ti;
  3022. char sdmf1[50];
  3023. char sdmf2[50];
  3024. char sdmf3[80];
  3025. char mdmflen, len1, len2, len3;
  3026. int pad;
  3027. int checksum = 0;
  3028. if (j->dsp.low == 0x20 || j->flags.cidplay)
  3029. return;
  3030. j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
  3031. j->cidsize = j->cidcnt = 0;
  3032. ixj_fsk_alloc(j);
  3033. j->flags.cidcw_ack = 0;
  3034. ti.tone_index = 23;
  3035. ti.gain0 = 1;
  3036. ti.freq0 = hz440;
  3037. ti.gain1 = 0;
  3038. ti.freq1 = 0;
  3039. ixj_init_tone(j, &ti);
  3040. ixj_set_tone_on(1500, j);
  3041. ixj_set_tone_off(32, j);
  3042. if(ixjdebug & 0x0200) {
  3043. printk("IXJ cidcw phone%d first tone start at %ld\n", j->board, jiffies);
  3044. }
  3045. ixj_play_tone(j, 23);
  3046. clear_bit(j->board, &j->busyflags);
  3047. while(j->tone_state)
  3048. schedule_timeout_interruptible(1);
  3049. while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
  3050. schedule_timeout_interruptible(1);
  3051. if(ixjdebug & 0x0200) {
  3052. printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies);
  3053. }
  3054. ti.tone_index = 24;
  3055. ti.gain0 = 1;
  3056. ti.freq0 = hz2130;
  3057. ti.gain1 = 0;
  3058. ti.freq1 = hz2750;
  3059. ixj_init_tone(j, &ti);
  3060. ixj_set_tone_off(10, j);
  3061. ixj_set_tone_on(600, j);
  3062. if(ixjdebug & 0x0200) {
  3063. printk("IXJ cidcw phone%d second tone start at %ld\n", j->board, jiffies);
  3064. }
  3065. ixj_play_tone(j, 24);
  3066. clear_bit(j->board, &j->busyflags);
  3067. while(j->tone_state)
  3068. schedule_timeout_interruptible(1);
  3069. while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
  3070. schedule_timeout_interruptible(1);
  3071. if(ixjdebug & 0x0200) {
  3072. printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies);
  3073. }
  3074. j->cidcw_wait = jiffies + ((50 * hertz) / 100);
  3075. clear_bit(j->board, &j->busyflags);
  3076. while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait))
  3077. schedule_timeout_interruptible(1);
  3078. while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
  3079. schedule_timeout_interruptible(1);
  3080. j->cidcw_wait = 0;
  3081. if(!j->flags.cidcw_ack) {
  3082. if(ixjdebug & 0x0200) {
  3083. printk("IXJ cidcw phone%d did not receive ACK from display %ld\n", j->board, jiffies);
  3084. }
  3085. ixj_post_cid(j);
  3086. if(j->cid_play_flag) {
  3087. wake_up_interruptible(&j->write_q); /* Wake any blocked readers */
  3088. }
  3089. return;
  3090. } else {
  3091. ixj_pre_cid(j);
  3092. }
  3093. j->flags.cidcw_ack = 0;
  3094. strcpy(sdmf1, j->cid_send.month);
  3095. strcat(sdmf1, j->cid_send.day);
  3096. strcat(sdmf1, j->cid_send.hour);
  3097. strcat(sdmf1, j->cid_send.min);
  3098. strcpy(sdmf2, j->cid_send.number);
  3099. strcpy(sdmf3, j->cid_send.name);
  3100. len1 = strlen(sdmf1);
  3101. len2 = strlen(sdmf2);
  3102. len3 = strlen(sdmf3);
  3103. mdmflen = len1 + len2 + len3 + 6;
  3104. ixj_write_cidcw_seize(j);
  3105. ixj_write_cid_byte(j, 0x80);
  3106. checksum = 0x80;
  3107. ixj_write_cid_byte(j, mdmflen);
  3108. checksum = checksum + mdmflen;
  3109. ixj_write_cid_byte(j, 0x01);
  3110. checksum = checksum + 0x01;
  3111. ixj_write_cid_byte(j, len1);
  3112. checksum = checksum + len1;
  3113. checksum = ixj_write_cid_string(j, sdmf1, checksum);
  3114. ixj_write_cid_byte(j, 0x02);
  3115. checksum = checksum + 0x02;
  3116. ixj_write_cid_byte(j, len2);
  3117. checksum = checksum + len2;
  3118. checksum = ixj_write_cid_string(j, sdmf2, checksum);
  3119. ixj_write_cid_byte(j, 0x07);
  3120. checksum = checksum + 0x07;
  3121. ixj_write_cid_byte(j, len3);
  3122. checksum = checksum + len3;
  3123. checksum = ixj_write_cid_string(j, sdmf3, checksum);
  3124. checksum %= 256;
  3125. checksum ^= 0xFF;
  3126. checksum += 1;
  3127. ixj_write_cid_byte(j, (char) checksum);
  3128. pad = j->fskdcnt % 240;
  3129. if (pad) {
  3130. pad = 240 - pad;
  3131. }
  3132. ixj_pad_fsk(j, pad);
  3133. if(ixjdebug & 0x0200) {
  3134. printk("IXJ cidcw phone%d sent FSK data at %ld\n", j->board, jiffies);
  3135. }
  3136. }
  3137. static void ixj_write_vmwi(IXJ *j, int msg)
  3138. {
  3139. char mdmflen;
  3140. int pad;
  3141. int checksum = 0;
  3142. if (j->dsp.low == 0x20 || j->flags.cidplay)
  3143. return;
  3144. j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
  3145. j->cidsize = j->cidcnt = 0;
  3146. ixj_fsk_alloc(j);
  3147. mdmflen = 3;
  3148. if (j->port == PORT_POTS)
  3149. SLIC_SetState(PLD_SLIC_STATE_OHT, j);
  3150. ixj_write_cid_seize(j);
  3151. ixj_write_cid_byte(j, 0x82);
  3152. checksum = 0x82;
  3153. ixj_write_cid_byte(j, mdmflen);
  3154. checksum = checksum + mdmflen;
  3155. ixj_write_cid_byte(j, 0x0B);
  3156. checksum = checksum + 0x0B;
  3157. ixj_write_cid_byte(j, 1);
  3158. checksum = checksum + 1;
  3159. if(msg) {
  3160. ixj_write_cid_byte(j, 0xFF);
  3161. checksum = checksum + 0xFF;
  3162. }
  3163. else {
  3164. ixj_write_cid_byte(j, 0x00);
  3165. checksum = checksum + 0x00;
  3166. }
  3167. checksum %= 256;
  3168. checksum ^= 0xFF;
  3169. checksum += 1;
  3170. ixj_write_cid_byte(j, (char) checksum);
  3171. pad = j->fskdcnt % 240;
  3172. if (pad) {
  3173. pad = 240 - pad;
  3174. }
  3175. ixj_pad_fsk(j, pad);
  3176. }
  3177. static void ixj_write_frame(IXJ *j)
  3178. {
  3179. int cnt, frame_count, dly;
  3180. IXJ_WORD dat;
  3181. frame_count = 0;
  3182. if(j->flags.cidplay) {
  3183. for(cnt = 0; cnt < 480; cnt++) {
  3184. if (!(cnt % 16) && !IsTxReady(j)) {
  3185. dly = 0;
  3186. while (!IsTxReady(j)) {
  3187. if (dly++ > 5) {
  3188. dly = 0;
  3189. break;
  3190. }
  3191. udelay(10);
  3192. }
  3193. }
  3194. dat.word = j->fskdata[j->cidcnt++];
  3195. outb_p(dat.bytes.low, j->DSPbase + 0x0C);
  3196. outb_p(dat.bytes.high, j->DSPbase + 0x0D);
  3197. cnt++;
  3198. }
  3199. if(j->cidcnt >= j->fskdcnt) {
  3200. ixj_post_cid(j);
  3201. }
  3202. /* This may seem rude, but if we just played one frame of FSK data for CallerID
  3203. and there is real audio data in the buffer, we need to throw it away because
  3204. we just used it's time slot */
  3205. if (j->write_buffer_rp > j->write_buffer_wp) {
  3206. j->write_buffer_rp += j->cid_play_frame_size * 2;
  3207. if (j->write_buffer_rp >= j->write_buffer_end) {
  3208. j->write_buffer_rp = j->write_buffer;
  3209. }
  3210. j->write_buffers_empty++;
  3211. wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
  3212. wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
  3213. }
  3214. } else if (j->write_buffer && j->write_buffers_empty < 1) {
  3215. if (j->write_buffer_wp > j->write_buffer_rp) {
  3216. frame_count =
  3217. (j->write_buffer_wp - j->write_buffer_rp) / (j->play_frame_size * 2);
  3218. }
  3219. if (j->write_buffer_rp > j->write_buffer_wp) {
  3220. frame_count =
  3221. (j->write_buffer_wp - j->write_buffer) / (j->play_frame_size * 2) +
  3222. (j->write_buffer_end - j->write_buffer_rp) / (j->play_frame_size * 2);
  3223. }
  3224. if (frame_count >= 1) {
  3225. if (j->ver.low == 0x12 && j->play_mode && j->flags.play_first_frame) {
  3226. BYTES blankword;
  3227. switch (j->play_mode) {
  3228. case PLAYBACK_MODE_ULAW:
  3229. case PLAYBACK_MODE_ALAW:
  3230. blankword.low = blankword.high = 0xFF;
  3231. break;
  3232. case PLAYBACK_MODE_8LINEAR:
  3233. case PLAYBACK_MODE_16LINEAR:
  3234. default:
  3235. blankword.low = blankword.high = 0x00;
  3236. break;
  3237. case PLAYBACK_MODE_8LINEAR_WSS:
  3238. blankword.low = blankword.high = 0x80;
  3239. break;
  3240. }
  3241. for (cnt = 0; cnt < 16; cnt++) {
  3242. if (!(cnt % 16) && !IsTxReady(j)) {
  3243. dly = 0;
  3244. while (!IsTxReady(j)) {
  3245. if (dly++ > 5) {
  3246. dly = 0;
  3247. break;
  3248. }
  3249. udelay(10);
  3250. }
  3251. }
  3252. outb_p((blankword.low), j->DSPbase + 0x0C);
  3253. outb_p((blankword.high), j->DSPbase + 0x0D);
  3254. }
  3255. j->flags.play_first_frame = 0;
  3256. } else if (j->play_codec == G723_63 && j->flags.play_first_frame) {
  3257. for (cnt = 0; cnt < 24; cnt++) {
  3258. BYTES blankword;
  3259. if(cnt == 12) {
  3260. blankword.low = 0x02;
  3261. blankword.high = 0x00;
  3262. }
  3263. else {
  3264. blankword.low = blankword.high = 0x00;
  3265. }
  3266. if (!(cnt % 16) && !IsTxReady(j)) {
  3267. dly = 0;
  3268. while (!IsTxReady(j)) {
  3269. if (dly++ > 5) {
  3270. dly = 0;
  3271. break;
  3272. }
  3273. udelay(10);
  3274. }
  3275. }
  3276. outb_p((blankword.low), j->DSPbase + 0x0C);
  3277. outb_p((blankword.high), j->DSPbase + 0x0D);
  3278. }
  3279. j->flags.play_first_frame = 0;
  3280. }
  3281. for (cnt = 0; cnt < j->play_frame_size * 2; cnt += 2) {
  3282. if (!(cnt % 16) && !IsTxReady(j)) {
  3283. dly = 0;
  3284. while (!IsTxReady(j)) {
  3285. if (dly++ > 5) {
  3286. dly = 0;
  3287. break;
  3288. }
  3289. udelay(10);
  3290. }
  3291. }
  3292. /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */
  3293. if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
  3294. if (j->write_buffer_rp[cnt] == 0 &&
  3295. j->write_buffer_rp[cnt + 1] == 0 &&
  3296. j->write_buffer_rp[cnt + 2] == 0 &&
  3297. j->write_buffer_rp[cnt + 3] == 0 &&
  3298. j->write_buffer_rp[cnt + 4] == 0 &&
  3299. j->write_buffer_rp[cnt + 5] == 0 &&
  3300. j->write_buffer_rp[cnt + 6] == 0 &&
  3301. j->write_buffer_rp[cnt + 7] == 0 &&
  3302. j->write_buffer_rp[cnt + 8] == 0 &&
  3303. j->write_buffer_rp[cnt + 9] == 0) {
  3304. /* someone is trying to write silence lets make this a type 0 frame. */
  3305. outb_p(0x00, j->DSPbase + 0x0C);
  3306. outb_p(0x00, j->DSPbase + 0x0D);
  3307. } else {
  3308. /* so all other frames are type 1. */
  3309. outb_p(0x01, j->DSPbase + 0x0C);
  3310. outb_p(0x00, j->DSPbase + 0x0D);
  3311. }
  3312. }
  3313. outb_p(*(j->write_buffer_rp + cnt), j->DSPbase + 0x0C);
  3314. outb_p(*(j->write_buffer_rp + cnt + 1), j->DSPbase + 0x0D);
  3315. *(j->write_buffer_rp + cnt) = 0;
  3316. *(j->write_buffer_rp + cnt + 1) = 0;
  3317. }
  3318. j->write_buffer_rp += j->play_frame_size * 2;
  3319. if (j->write_buffer_rp >= j->write_buffer_end) {
  3320. j->write_buffer_rp = j->write_buffer;
  3321. }
  3322. j->write_buffers_empty++;
  3323. wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
  3324. wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
  3325. ++j->frameswritten;
  3326. }
  3327. } else {
  3328. j->drybuffer++;
  3329. }
  3330. if(j->ixj_signals[SIG_WRITE_READY]) {
  3331. ixj_kill_fasync(j, SIG_WRITE_READY, POLL_OUT);
  3332. }
  3333. }
  3334. static int idle(IXJ *j)
  3335. {
  3336. if (ixj_WriteDSPCommand(0x0000, j)) /* DSP Idle */
  3337. return 0;
  3338. if (j->ssr.high || j->ssr.low) {
  3339. return 0;
  3340. } else {
  3341. j->play_mode = -1;
  3342. j->flags.playing = 0;
  3343. j->rec_mode = -1;
  3344. j->flags.recording = 0;
  3345. return 1;
  3346. }
  3347. }
  3348. static int set_base_frame(IXJ *j, int size)
  3349. {
  3350. unsigned short cmd;
  3351. int cnt;
  3352. idle(j);
  3353. j->cid_play_aec_level = j->aec_level;
  3354. aec_stop(j);
  3355. for (cnt = 0; cnt < 10; cnt++) {
  3356. if (idle(j))
  3357. break;
  3358. }
  3359. if (j->ssr.high || j->ssr.low)
  3360. return -1;
  3361. if (j->dsp.low != 0x20) {
  3362. switch (size) {
  3363. case 30:
  3364. cmd = 0x07F0;
  3365. /* Set Base Frame Size to 240 pg9-10 8021 */
  3366. break;
  3367. case 20:
  3368. cmd = 0x07A0;
  3369. /* Set Base Frame Size to 160 pg9-10 8021 */
  3370. break;
  3371. case 10:
  3372. cmd = 0x0750;
  3373. /* Set Base Frame Size to 80 pg9-10 8021 */
  3374. break;
  3375. default:
  3376. return -1;
  3377. }
  3378. } else {
  3379. if (size == 30)
  3380. return size;
  3381. else
  3382. return -1;
  3383. }
  3384. if (ixj_WriteDSPCommand(cmd, j)) {
  3385. j->baseframe.high = j->baseframe.low = 0xFF;
  3386. return -1;
  3387. } else {
  3388. j->baseframe.high = j->ssr.high;
  3389. j->baseframe.low = j->ssr.low;
  3390. /* If the status returned is 0x0000 (pg9-9 8021) the call failed */
  3391. if(j->baseframe.high == 0x00 && j->baseframe.low == 0x00) {
  3392. return -1;
  3393. }
  3394. }
  3395. ixj_aec_start(j, j->cid_play_aec_level);
  3396. return size;
  3397. }
  3398. static int set_rec_codec(IXJ *j, int rate)
  3399. {
  3400. int retval = 0;
  3401. j->rec_codec = rate;
  3402. switch (rate) {
  3403. case G723_63:
  3404. if (j->ver.low != 0x12 || ixj_convert_loaded) {
  3405. j->rec_frame_size = 12;
  3406. j->rec_mode = 0;
  3407. } else {
  3408. retval = 1;
  3409. }
  3410. break;
  3411. case G723_53:
  3412. if (j->ver.low != 0x12 || ixj_convert_loaded) {
  3413. j->rec_frame_size = 10;
  3414. j->rec_mode = 0;
  3415. } else {
  3416. retval = 1;
  3417. }
  3418. break;
  3419. case TS85:
  3420. if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
  3421. j->rec_frame_size = 16;
  3422. j->rec_mode = 0;
  3423. } else {
  3424. retval = 1;
  3425. }
  3426. break;
  3427. case TS48:
  3428. if (j->ver.low != 0x12 || ixj_convert_loaded) {
  3429. j->rec_frame_size = 9;
  3430. j->rec_mode = 0;
  3431. } else {
  3432. retval = 1;
  3433. }
  3434. break;
  3435. case TS41:
  3436. if (j->ver.low != 0x12 || ixj_convert_loaded) {
  3437. j->rec_frame_size = 8;
  3438. j->rec_mode = 0;
  3439. } else {
  3440. retval = 1;
  3441. }
  3442. break;
  3443. case G728:
  3444. if (j->dsp.low != 0x20) {
  3445. j->rec_frame_size = 48;
  3446. j->rec_mode = 0;
  3447. } else {
  3448. retval = 1;
  3449. }
  3450. break;
  3451. case G729:
  3452. if (j->dsp.low != 0x20) {
  3453. if (!j->flags.g729_loaded) {
  3454. retval = 1;
  3455. break;
  3456. }
  3457. switch (j->baseframe.low) {
  3458. case 0xA0:
  3459. j->rec_frame_size = 10;
  3460. break;
  3461. case 0x50:
  3462. j->rec_frame_size = 5;
  3463. break;
  3464. default:
  3465. j->rec_frame_size = 15;
  3466. break;
  3467. }
  3468. j->rec_mode = 0;
  3469. } else {
  3470. retval = 1;
  3471. }
  3472. break;
  3473. case G729B:
  3474. if (j->dsp.low != 0x20) {
  3475. if (!j->flags.g729_loaded) {
  3476. retval = 1;
  3477. break;
  3478. }
  3479. switch (j->baseframe.low) {
  3480. case 0xA0:
  3481. j->rec_frame_size = 12;
  3482. break;
  3483. case 0x50:
  3484. j->rec_frame_size = 6;
  3485. break;
  3486. default:
  3487. j->rec_frame_size = 18;
  3488. break;
  3489. }
  3490. j->rec_mode = 0;
  3491. } else {
  3492. retval = 1;
  3493. }
  3494. break;
  3495. case ULAW:
  3496. switch (j->baseframe.low) {
  3497. case 0xA0:
  3498. j->rec_frame_size = 80;
  3499. break;
  3500. case 0x50:
  3501. j->rec_frame_size = 40;
  3502. break;
  3503. default:
  3504. j->rec_frame_size = 120;
  3505. break;
  3506. }
  3507. j->rec_mode = 4;
  3508. break;
  3509. case ALAW:
  3510. switch (j->baseframe.low) {
  3511. case 0xA0:
  3512. j->rec_frame_size = 80;
  3513. break;
  3514. case 0x50:
  3515. j->rec_frame_size = 40;
  3516. break;
  3517. default:
  3518. j->rec_frame_size = 120;
  3519. break;
  3520. }
  3521. j->rec_mode = 4;
  3522. break;
  3523. case LINEAR16:
  3524. switch (j->baseframe.low) {
  3525. case 0xA0:
  3526. j->rec_frame_size = 160;
  3527. break;
  3528. case 0x50:
  3529. j->rec_frame_size = 80;
  3530. break;
  3531. default:
  3532. j->rec_frame_size = 240;
  3533. break;
  3534. }
  3535. j->rec_mode = 5;
  3536. break;
  3537. case LINEAR8:
  3538. switch (j->baseframe.low) {
  3539. case 0xA0:
  3540. j->rec_frame_size = 80;
  3541. break;
  3542. case 0x50:
  3543. j->rec_frame_size = 40;
  3544. break;
  3545. default:
  3546. j->rec_frame_size = 120;
  3547. break;
  3548. }
  3549. j->rec_mode = 6;
  3550. break;
  3551. case WSS:
  3552. switch (j->baseframe.low) {
  3553. case 0xA0:
  3554. j->rec_frame_size = 80;
  3555. break;
  3556. case 0x50:
  3557. j->rec_frame_size = 40;
  3558. break;
  3559. default:
  3560. j->rec_frame_size = 120;
  3561. break;
  3562. }
  3563. j->rec_mode = 7;
  3564. break;
  3565. default:
  3566. kfree(j->read_buffer);
  3567. j->rec_frame_size = 0;
  3568. j->rec_mode = -1;
  3569. j->read_buffer = NULL;
  3570. j->read_buffer_size = 0;
  3571. retval = 1;
  3572. break;
  3573. }
  3574. return retval;
  3575. }
  3576. static int ixj_record_start(IXJ *j)
  3577. {
  3578. unsigned short cmd = 0x0000;
  3579. if (j->read_buffer) {
  3580. ixj_record_stop(j);
  3581. }
  3582. j->flags.recording = 1;
  3583. ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
  3584. if(ixjdebug & 0x0002)
  3585. printk("IXJ %d Starting Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
  3586. if (!j->rec_mode) {
  3587. switch (j->rec_codec) {
  3588. case G723_63:
  3589. cmd = 0x5131;
  3590. break;
  3591. case G723_53:
  3592. cmd = 0x5132;
  3593. break;
  3594. case TS85:
  3595. cmd = 0x5130; /* TrueSpeech 8.5 */
  3596. break;
  3597. case TS48:
  3598. cmd = 0x5133; /* TrueSpeech 4.8 */
  3599. break;
  3600. case TS41:
  3601. cmd = 0x5134; /* TrueSpeech 4.1 */
  3602. break;
  3603. case G728:
  3604. cmd = 0x5135;
  3605. break;
  3606. case G729:
  3607. case G729B:
  3608. cmd = 0x5136;
  3609. break;
  3610. default:
  3611. return 1;
  3612. }
  3613. if (ixj_WriteDSPCommand(cmd, j))
  3614. return -1;
  3615. }
  3616. if (!j->read_buffer) {
  3617. if (!j->read_buffer)
  3618. j->read_buffer = kmalloc(j->rec_frame_size * 2, GFP_ATOMIC);
  3619. if (!j->read_buffer) {
  3620. printk("Read buffer allocation for ixj board %d failed!\n", j->board);
  3621. return -ENOMEM;
  3622. }
  3623. }
  3624. j->read_buffer_size = j->rec_frame_size * 2;
  3625. if (ixj_WriteDSPCommand(0x5102, j)) /* Set Poll sync mode */
  3626. return -1;
  3627. switch (j->rec_mode) {
  3628. case 0:
  3629. cmd = 0x1C03; /* Record C1 */
  3630. break;
  3631. case 4:
  3632. if (j->ver.low == 0x12) {
  3633. cmd = 0x1E03; /* Record C1 */
  3634. } else {
  3635. cmd = 0x1E01; /* Record C1 */
  3636. }
  3637. break;
  3638. case 5:
  3639. if (j->ver.low == 0x12) {
  3640. cmd = 0x1E83; /* Record C1 */
  3641. } else {
  3642. cmd = 0x1E81; /* Record C1 */
  3643. }
  3644. break;
  3645. case 6:
  3646. if (j->ver.low == 0x12) {
  3647. cmd = 0x1F03; /* Record C1 */
  3648. } else {
  3649. cmd = 0x1F01; /* Record C1 */
  3650. }
  3651. break;
  3652. case 7:
  3653. if (j->ver.low == 0x12) {
  3654. cmd = 0x1F83; /* Record C1 */
  3655. } else {
  3656. cmd = 0x1F81; /* Record C1 */
  3657. }
  3658. break;
  3659. }
  3660. if (ixj_WriteDSPCommand(cmd, j))
  3661. return -1;
  3662. if (j->flags.playing) {
  3663. ixj_aec_start(j, j->aec_level);
  3664. }
  3665. return 0;
  3666. }
  3667. static void ixj_record_stop(IXJ *j)
  3668. {
  3669. if (ixjdebug & 0x0002)
  3670. printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
  3671. kfree(j->read_buffer);
  3672. j->read_buffer = NULL;
  3673. j->read_buffer_size = 0;
  3674. if (j->rec_mode > -1) {
  3675. ixj_WriteDSPCommand(0x5120, j);
  3676. j->rec_mode = -1;
  3677. }
  3678. j->flags.recording = 0;
  3679. }
  3680. static void ixj_vad(IXJ *j, int arg)
  3681. {
  3682. if (arg)
  3683. ixj_WriteDSPCommand(0x513F, j);
  3684. else
  3685. ixj_WriteDSPCommand(0x513E, j);
  3686. }
  3687. static void set_rec_depth(IXJ *j, int depth)
  3688. {
  3689. if (depth > 60)
  3690. depth = 60;
  3691. if (depth < 0)
  3692. depth = 0;
  3693. ixj_WriteDSPCommand(0x5180 + depth, j);
  3694. }
  3695. static void set_dtmf_prescale(IXJ *j, int volume)
  3696. {
  3697. ixj_WriteDSPCommand(0xCF07, j);
  3698. ixj_WriteDSPCommand(volume, j);
  3699. }
  3700. static int get_dtmf_prescale(IXJ *j)
  3701. {
  3702. ixj_WriteDSPCommand(0xCF05, j);
  3703. return j->ssr.high << 8 | j->ssr.low;
  3704. }
  3705. static void set_rec_volume(IXJ *j, int volume)
  3706. {
  3707. if(j->aec_level == AEC_AGC) {
  3708. if (ixjdebug & 0x0002)
  3709. printk(KERN_INFO "IXJ: /dev/phone%d Setting AGC Threshold to 0x%4.4x\n", j->board, volume);
  3710. ixj_WriteDSPCommand(0xCF96, j);
  3711. ixj_WriteDSPCommand(volume, j);
  3712. } else {
  3713. if (ixjdebug & 0x0002)
  3714. printk(KERN_INFO "IXJ: /dev/phone %d Setting Record Volume to 0x%4.4x\n", j->board, volume);
  3715. ixj_WriteDSPCommand(0xCF03, j);
  3716. ixj_WriteDSPCommand(volume, j);
  3717. }
  3718. }
  3719. static int set_rec_volume_linear(IXJ *j, int volume)
  3720. {
  3721. int newvolume, dsprecmax;
  3722. if (ixjdebug & 0x0002)
  3723. printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Record Volume to 0x%4.4x\n", j->board, volume);
  3724. if(volume > 100 || volume < 0) {
  3725. return -1;
  3726. }
  3727. /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
  3728. switch (j->cardtype) {
  3729. case QTI_PHONEJACK:
  3730. dsprecmax = 0x440;
  3731. break;
  3732. case QTI_LINEJACK:
  3733. dsprecmax = 0x180;
  3734. ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
  3735. ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
  3736. ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
  3737. break;
  3738. case QTI_PHONEJACK_LITE:
  3739. dsprecmax = 0x4C0;
  3740. break;
  3741. case QTI_PHONEJACK_PCI:
  3742. dsprecmax = 0x100;
  3743. break;
  3744. case QTI_PHONECARD:
  3745. dsprecmax = 0x400;
  3746. break;
  3747. default:
  3748. return -1;
  3749. }
  3750. newvolume = (dsprecmax * volume) / 100;
  3751. set_rec_volume(j, newvolume);
  3752. return 0;
  3753. }
  3754. static int get_rec_volume(IXJ *j)
  3755. {
  3756. if(j->aec_level == AEC_AGC) {
  3757. if (ixjdebug & 0x0002)
  3758. printk(KERN_INFO "Getting AGC Threshold\n");
  3759. ixj_WriteDSPCommand(0xCF86, j);
  3760. if (ixjdebug & 0x0002)
  3761. printk(KERN_INFO "AGC Threshold is 0x%2.2x%2.2x\n", j->ssr.high, j->ssr.low);
  3762. return j->ssr.high << 8 | j->ssr.low;
  3763. } else {
  3764. if (ixjdebug & 0x0002)
  3765. printk(KERN_INFO "Getting Record Volume\n");
  3766. ixj_WriteDSPCommand(0xCF01, j);
  3767. return j->ssr.high << 8 | j->ssr.low;
  3768. }
  3769. }
  3770. static int get_rec_volume_linear(IXJ *j)
  3771. {
  3772. int volume, newvolume, dsprecmax;
  3773. switch (j->cardtype) {
  3774. case QTI_PHONEJACK:
  3775. dsprecmax = 0x440;
  3776. break;
  3777. case QTI_LINEJACK:
  3778. dsprecmax = 0x180;
  3779. break;
  3780. case QTI_PHONEJACK_LITE:
  3781. dsprecmax = 0x4C0;
  3782. break;
  3783. case QTI_PHONEJACK_PCI:
  3784. dsprecmax = 0x100;
  3785. break;
  3786. case QTI_PHONECARD:
  3787. dsprecmax = 0x400;
  3788. break;
  3789. default:
  3790. return -1;
  3791. }
  3792. volume = get_rec_volume(j);
  3793. newvolume = (volume * 100) / dsprecmax;
  3794. if(newvolume > 100)
  3795. newvolume = 100;
  3796. return newvolume;
  3797. }
  3798. static int get_rec_level(IXJ *j)
  3799. {
  3800. int retval;
  3801. ixj_WriteDSPCommand(0xCF88, j);
  3802. retval = j->ssr.high << 8 | j->ssr.low;
  3803. retval = (retval * 256) / 240;
  3804. return retval;
  3805. }
  3806. static void ixj_aec_start(IXJ *j, int level)
  3807. {
  3808. j->aec_level = level;
  3809. if (ixjdebug & 0x0002)
  3810. printk(KERN_INFO "AGC set = 0x%2.2x\n", j->aec_level);
  3811. if (!level) {
  3812. aec_stop(j);
  3813. } else {
  3814. if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
  3815. ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer */
  3816. ixj_WriteDSPCommand(0x0300, j);
  3817. }
  3818. ixj_WriteDSPCommand(0xB001, j); /* AEC On */
  3819. ixj_WriteDSPCommand(0xE013, j); /* Advanced AEC C1 */
  3820. switch (level) {
  3821. case AEC_LOW:
  3822. ixj_WriteDSPCommand(0x0000, j); /* Advanced AEC C2 = off */
  3823. ixj_WriteDSPCommand(0xE011, j);
  3824. ixj_WriteDSPCommand(0xFFFF, j);
  3825. ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
  3826. ixj_WriteDSPCommand(0x0000, j); /* to off */
  3827. break;
  3828. case AEC_MED:
  3829. ixj_WriteDSPCommand(0x0600, j); /* Advanced AEC C2 = on medium */
  3830. ixj_WriteDSPCommand(0xE011, j);
  3831. ixj_WriteDSPCommand(0x0080, j);
  3832. ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
  3833. ixj_WriteDSPCommand(0x0000, j); /* to off */
  3834. break;
  3835. case AEC_HIGH:
  3836. ixj_WriteDSPCommand(0x0C00, j); /* Advanced AEC C2 = on high */
  3837. ixj_WriteDSPCommand(0xE011, j);
  3838. ixj_WriteDSPCommand(0x0080, j);
  3839. ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
  3840. ixj_WriteDSPCommand(0x0000, j); /* to off */
  3841. break;
  3842. case AEC_AGC:
  3843. /* First we have to put the AEC into advance auto mode so that AGC will not conflict with it */
  3844. ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
  3845. ixj_WriteDSPCommand(0xE011, j);
  3846. ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
  3847. ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
  3848. if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
  3849. ixj_WriteDSPCommand(0x0224, j);
  3850. else
  3851. ixj_WriteDSPCommand(0x1224, j);
  3852. ixj_WriteDSPCommand(0xE014, j);
  3853. ixj_WriteDSPCommand(0x0003, j); /* Lock threshold at 3dB */
  3854. ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
  3855. /* Now we can set the AGC initial parameters and turn it on */
  3856. ixj_WriteDSPCommand(0xCF90, j); /* Set AGC Minimum gain */
  3857. ixj_WriteDSPCommand(0x0020, j); /* to 0.125 (-18dB) */
  3858. ixj_WriteDSPCommand(0xCF91, j); /* Set AGC Maximum gain */
  3859. ixj_WriteDSPCommand(0x1000, j); /* to 16 (24dB) */
  3860. ixj_WriteDSPCommand(0xCF92, j); /* Set AGC start gain */
  3861. ixj_WriteDSPCommand(0x0800, j); /* to 8 (+18dB) */
  3862. ixj_WriteDSPCommand(0xCF93, j); /* Set AGC hold time */
  3863. ixj_WriteDSPCommand(0x1F40, j); /* to 2 seconds (units are 250us) */
  3864. ixj_WriteDSPCommand(0xCF94, j); /* Set AGC Attack Time Constant */
  3865. ixj_WriteDSPCommand(0x0005, j); /* to 8ms */
  3866. ixj_WriteDSPCommand(0xCF95, j); /* Set AGC Decay Time Constant */
  3867. ixj_WriteDSPCommand(0x000D, j); /* to 4096ms */
  3868. ixj_WriteDSPCommand(0xCF96, j); /* Set AGC Attack Threshold */
  3869. ixj_WriteDSPCommand(0x1200, j); /* to 25% */
  3870. ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
  3871. ixj_WriteDSPCommand(0x0001, j); /* to on */
  3872. break;
  3873. case AEC_AUTO:
  3874. ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
  3875. ixj_WriteDSPCommand(0xE011, j);
  3876. ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
  3877. ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
  3878. if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
  3879. ixj_WriteDSPCommand(0x0224, j);
  3880. else
  3881. ixj_WriteDSPCommand(0x1224, j);
  3882. ixj_WriteDSPCommand(0xE014, j);
  3883. ixj_WriteDSPCommand(0x0003, j); /* Lock threshold at 3dB */
  3884. ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
  3885. break;
  3886. }
  3887. }
  3888. }
  3889. static void aec_stop(IXJ *j)
  3890. {
  3891. j->aec_level = AEC_OFF;
  3892. if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
  3893. ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer back */
  3894. ixj_WriteDSPCommand(0x0700, j);
  3895. }
  3896. if (j->play_mode != -1 && j->rec_mode != -1)
  3897. {
  3898. ixj_WriteDSPCommand(0xB002, j); /* AEC Stop */
  3899. }
  3900. }
  3901. static int set_play_codec(IXJ *j, int rate)
  3902. {
  3903. int retval = 0;
  3904. j->play_codec = rate;
  3905. switch (rate) {
  3906. case G723_63:
  3907. if (j->ver.low != 0x12 || ixj_convert_loaded) {
  3908. j->play_frame_size = 12;
  3909. j->play_mode = 0;
  3910. } else {
  3911. retval = 1;
  3912. }
  3913. break;
  3914. case G723_53:
  3915. if (j->ver.low != 0x12 || ixj_convert_loaded) {
  3916. j->play_frame_size = 10;
  3917. j->play_mode = 0;
  3918. } else {
  3919. retval = 1;
  3920. }
  3921. break;
  3922. case TS85:
  3923. if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
  3924. j->play_frame_size = 16;
  3925. j->play_mode = 0;
  3926. } else {
  3927. retval = 1;
  3928. }
  3929. break;
  3930. case TS48:
  3931. if (j->ver.low != 0x12 || ixj_convert_loaded) {
  3932. j->play_frame_size = 9;
  3933. j->play_mode = 0;
  3934. } else {
  3935. retval = 1;
  3936. }
  3937. break;
  3938. case TS41:
  3939. if (j->ver.low != 0x12 || ixj_convert_loaded) {
  3940. j->play_frame_size = 8;
  3941. j->play_mode = 0;
  3942. } else {
  3943. retval = 1;
  3944. }
  3945. break;
  3946. case G728:
  3947. if (j->dsp.low != 0x20) {
  3948. j->play_frame_size = 48;
  3949. j->play_mode = 0;
  3950. } else {
  3951. retval = 1;
  3952. }
  3953. break;
  3954. case G729:
  3955. if (j->dsp.low != 0x20) {
  3956. if (!j->flags.g729_loaded) {
  3957. retval = 1;
  3958. break;
  3959. }
  3960. switch (j->baseframe.low) {
  3961. case 0xA0:
  3962. j->play_frame_size = 10;
  3963. break;
  3964. case 0x50:
  3965. j->play_frame_size = 5;
  3966. break;
  3967. default:
  3968. j->play_frame_size = 15;
  3969. break;
  3970. }
  3971. j->play_mode = 0;
  3972. } else {
  3973. retval = 1;
  3974. }
  3975. break;
  3976. case G729B:
  3977. if (j->dsp.low != 0x20) {
  3978. if (!j->flags.g729_loaded) {
  3979. retval = 1;
  3980. break;
  3981. }
  3982. switch (j->baseframe.low) {
  3983. case 0xA0:
  3984. j->play_frame_size = 12;
  3985. break;
  3986. case 0x50:
  3987. j->play_frame_size = 6;
  3988. break;
  3989. default:
  3990. j->play_frame_size = 18;
  3991. break;
  3992. }
  3993. j->play_mode = 0;
  3994. } else {
  3995. retval = 1;
  3996. }
  3997. break;
  3998. case ULAW:
  3999. switch (j->baseframe.low) {
  4000. case 0xA0:
  4001. j->play_frame_size = 80;
  4002. break;
  4003. case 0x50:
  4004. j->play_frame_size = 40;
  4005. break;
  4006. default:
  4007. j->play_frame_size = 120;
  4008. break;
  4009. }
  4010. j->play_mode = 2;
  4011. break;
  4012. case ALAW:
  4013. switch (j->baseframe.low) {
  4014. case 0xA0:
  4015. j->play_frame_size = 80;
  4016. break;
  4017. case 0x50:
  4018. j->play_frame_size = 40;
  4019. break;
  4020. default:
  4021. j->play_frame_size = 120;
  4022. break;
  4023. }
  4024. j->play_mode = 2;
  4025. break;
  4026. case LINEAR16:
  4027. switch (j->baseframe.low) {
  4028. case 0xA0:
  4029. j->play_frame_size = 160;
  4030. break;
  4031. case 0x50:
  4032. j->play_frame_size = 80;
  4033. break;
  4034. default:
  4035. j->play_frame_size = 240;
  4036. break;
  4037. }
  4038. j->play_mode = 6;
  4039. break;
  4040. case LINEAR8:
  4041. switch (j->baseframe.low) {
  4042. case 0xA0:
  4043. j->play_frame_size = 80;
  4044. break;
  4045. case 0x50:
  4046. j->play_frame_size = 40;
  4047. break;
  4048. default:
  4049. j->play_frame_size = 120;
  4050. break;
  4051. }
  4052. j->play_mode = 4;
  4053. break;
  4054. case WSS:
  4055. switch (j->baseframe.low) {
  4056. case 0xA0:
  4057. j->play_frame_size = 80;
  4058. break;
  4059. case 0x50:
  4060. j->play_frame_size = 40;
  4061. break;
  4062. default:
  4063. j->play_frame_size = 120;
  4064. break;
  4065. }
  4066. j->play_mode = 5;
  4067. break;
  4068. default:
  4069. kfree(j->write_buffer);
  4070. j->play_frame_size = 0;
  4071. j->play_mode = -1;
  4072. j->write_buffer = NULL;
  4073. j->write_buffer_size = 0;
  4074. retval = 1;
  4075. break;
  4076. }
  4077. return retval;
  4078. }
  4079. static int ixj_play_start(IXJ *j)
  4080. {
  4081. unsigned short cmd = 0x0000;
  4082. if (j->write_buffer) {
  4083. ixj_play_stop(j);
  4084. }
  4085. if(ixjdebug & 0x0002)
  4086. printk("IXJ %d Starting Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
  4087. j->flags.playing = 1;
  4088. ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
  4089. j->flags.play_first_frame = 1;
  4090. j->drybuffer = 0;
  4091. if (!j->play_mode) {
  4092. switch (j->play_codec) {
  4093. case G723_63:
  4094. cmd = 0x5231;
  4095. break;
  4096. case G723_53:
  4097. cmd = 0x5232;
  4098. break;
  4099. case TS85:
  4100. cmd = 0x5230; /* TrueSpeech 8.5 */
  4101. break;
  4102. case TS48:
  4103. cmd = 0x5233; /* TrueSpeech 4.8 */
  4104. break;
  4105. case TS41:
  4106. cmd = 0x5234; /* TrueSpeech 4.1 */
  4107. break;
  4108. case G728:
  4109. cmd = 0x5235;
  4110. break;
  4111. case G729:
  4112. case G729B:
  4113. cmd = 0x5236;
  4114. break;
  4115. default:
  4116. return 1;
  4117. }
  4118. if (ixj_WriteDSPCommand(cmd, j))
  4119. return -1;
  4120. }
  4121. j->write_buffer = kmalloc(j->play_frame_size * 2, GFP_ATOMIC);
  4122. if (!j->write_buffer) {
  4123. printk("Write buffer allocation for ixj board %d failed!\n", j->board);
  4124. return -ENOMEM;
  4125. }
  4126. /* j->write_buffers_empty = 2; */
  4127. j->write_buffers_empty = 1;
  4128. j->write_buffer_size = j->play_frame_size * 2;
  4129. j->write_buffer_end = j->write_buffer + j->play_frame_size * 2;
  4130. j->write_buffer_rp = j->write_buffer_wp = j->write_buffer;
  4131. if (ixj_WriteDSPCommand(0x5202, j)) /* Set Poll sync mode */
  4132. return -1;
  4133. switch (j->play_mode) {
  4134. case 0:
  4135. cmd = 0x2C03;
  4136. break;
  4137. case 2:
  4138. if (j->ver.low == 0x12) {
  4139. cmd = 0x2C23;
  4140. } else {
  4141. cmd = 0x2C21;
  4142. }
  4143. break;
  4144. case 4:
  4145. if (j->ver.low == 0x12) {
  4146. cmd = 0x2C43;
  4147. } else {
  4148. cmd = 0x2C41;
  4149. }
  4150. break;
  4151. case 5:
  4152. if (j->ver.low == 0x12) {
  4153. cmd = 0x2C53;
  4154. } else {
  4155. cmd = 0x2C51;
  4156. }
  4157. break;
  4158. case 6:
  4159. if (j->ver.low == 0x12) {
  4160. cmd = 0x2C63;
  4161. } else {
  4162. cmd = 0x2C61;
  4163. }
  4164. break;
  4165. }
  4166. if (ixj_WriteDSPCommand(cmd, j))
  4167. return -1;
  4168. if (ixj_WriteDSPCommand(0x2000, j)) /* Playback C2 */
  4169. return -1;
  4170. if (ixj_WriteDSPCommand(0x2000 + j->play_frame_size, j)) /* Playback C3 */
  4171. return -1;
  4172. if (j->flags.recording) {
  4173. ixj_aec_start(j, j->aec_level);
  4174. }
  4175. return 0;
  4176. }
  4177. static void ixj_play_stop(IXJ *j)
  4178. {
  4179. if (ixjdebug & 0x0002)
  4180. printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
  4181. kfree(j->write_buffer);
  4182. j->write_buffer = NULL;
  4183. j->write_buffer_size = 0;
  4184. if (j->play_mode > -1) {
  4185. ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */
  4186. j->play_mode = -1;
  4187. }
  4188. j->flags.playing = 0;
  4189. }
  4190. static inline int get_play_level(IXJ *j)
  4191. {
  4192. int retval;
  4193. ixj_WriteDSPCommand(0xCF8F, j); /* 8022 Reference page 9-38 */
  4194. return j->ssr.high << 8 | j->ssr.low;
  4195. retval = j->ssr.high << 8 | j->ssr.low;
  4196. retval = (retval * 256) / 240;
  4197. return retval;
  4198. }
  4199. static unsigned int ixj_poll(struct file *file_p, poll_table * wait)
  4200. {
  4201. unsigned int mask = 0;
  4202. IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
  4203. poll_wait(file_p, &(j->poll_q), wait);
  4204. if (j->read_buffer_ready > 0)
  4205. mask |= POLLIN | POLLRDNORM; /* readable */
  4206. if (j->write_buffers_empty > 0)
  4207. mask |= POLLOUT | POLLWRNORM; /* writable */
  4208. if (j->ex.bytes)
  4209. mask |= POLLPRI;
  4210. return mask;
  4211. }
  4212. static int ixj_play_tone(IXJ *j, char tone)
  4213. {
  4214. if (!j->tone_state) {
  4215. if(ixjdebug & 0x0002) {
  4216. printk("IXJ %d starting tone %d at %ld\n", j->board, tone, jiffies);
  4217. }
  4218. if (j->dsp.low == 0x20) {
  4219. idle(j);
  4220. }
  4221. j->tone_start_jif = jiffies;
  4222. j->tone_state = 1;
  4223. }
  4224. j->tone_index = tone;
  4225. if (ixj_WriteDSPCommand(0x6000 + j->tone_index, j))
  4226. return -1;
  4227. return 0;
  4228. }
  4229. static int ixj_set_tone_on(unsigned short arg, IXJ *j)
  4230. {
  4231. j->tone_on_time = arg;
  4232. if (ixj_WriteDSPCommand(0x6E04, j)) /* Set Tone On Period */
  4233. return -1;
  4234. if (ixj_WriteDSPCommand(arg, j))
  4235. return -1;
  4236. return 0;
  4237. }
  4238. static int SCI_WaitHighSCI(IXJ *j)
  4239. {
  4240. int cnt;
  4241. j->pld_scrr.byte = inb_p(j->XILINXbase);
  4242. if (!j->pld_scrr.bits.sci) {
  4243. for (cnt = 0; cnt < 10; cnt++) {
  4244. udelay(32);
  4245. j->pld_scrr.byte = inb_p(j->XILINXbase);
  4246. if ((j->pld_scrr.bits.sci))
  4247. return 1;
  4248. }
  4249. if (ixjdebug & 0x0001)
  4250. printk(KERN_INFO "SCI Wait High failed %x\n", j->pld_scrr.byte);
  4251. return 0;
  4252. } else
  4253. return 1;
  4254. }
  4255. static int SCI_WaitLowSCI(IXJ *j)
  4256. {
  4257. int cnt;
  4258. j->pld_scrr.byte = inb_p(j->XILINXbase);
  4259. if (j->pld_scrr.bits.sci) {
  4260. for (cnt = 0; cnt < 10; cnt++) {
  4261. udelay(32);
  4262. j->pld_scrr.byte = inb_p(j->XILINXbase);
  4263. if (!(j->pld_scrr.bits.sci))
  4264. return 1;
  4265. }
  4266. if (ixjdebug & 0x0001)
  4267. printk(KERN_INFO "SCI Wait Low failed %x\n", j->pld_scrr.byte);
  4268. return 0;
  4269. } else
  4270. return 1;
  4271. }
  4272. static int SCI_Control(IXJ *j, int control)
  4273. {
  4274. switch (control) {
  4275. case SCI_End:
  4276. j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
  4277. j->pld_scrw.bits.c1 = 0; /* to no selection */
  4278. break;
  4279. case SCI_Enable_DAA:
  4280. j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
  4281. j->pld_scrw.bits.c1 = 0; /* to write to DAA */
  4282. break;
  4283. case SCI_Enable_Mixer:
  4284. j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
  4285. j->pld_scrw.bits.c1 = 1; /* to write to mixer */
  4286. break;
  4287. case SCI_Enable_EEPROM:
  4288. j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
  4289. j->pld_scrw.bits.c1 = 1; /* to write to EEPROM */
  4290. break;
  4291. default:
  4292. return 0;
  4293. break;
  4294. }
  4295. outb_p(j->pld_scrw.byte, j->XILINXbase);
  4296. switch (control) {
  4297. case SCI_End:
  4298. return 1;
  4299. break;
  4300. case SCI_Enable_DAA:
  4301. case SCI_Enable_Mixer:
  4302. case SCI_Enable_EEPROM:
  4303. if (!SCI_WaitHighSCI(j))
  4304. return 0;
  4305. break;
  4306. default:
  4307. return 0;
  4308. break;
  4309. }
  4310. return 1;
  4311. }
  4312. static int SCI_Prepare(IXJ *j)
  4313. {
  4314. if (!SCI_Control(j, SCI_End))
  4315. return 0;
  4316. if (!SCI_WaitLowSCI(j))
  4317. return 0;
  4318. return 1;
  4319. }
  4320. static int ixj_get_mixer(long val, IXJ *j)
  4321. {
  4322. int reg = (val & 0x1F00) >> 8;
  4323. return j->mix.vol[reg];
  4324. }
  4325. static int ixj_mixer(long val, IXJ *j)
  4326. {
  4327. BYTES bytes;
  4328. bytes.high = (val & 0x1F00) >> 8;
  4329. bytes.low = val & 0x00FF;
  4330. /* save mixer value so we can get back later on */
  4331. j->mix.vol[bytes.high] = bytes.low;
  4332. outb_p(bytes.high & 0x1F, j->XILINXbase + 0x03); /* Load Mixer Address */
  4333. outb_p(bytes.low, j->XILINXbase + 0x02); /* Load Mixer Data */
  4334. SCI_Control(j, SCI_Enable_Mixer);
  4335. SCI_Control(j, SCI_End);
  4336. return 0;
  4337. }
  4338. static int daa_load(BYTES * p_bytes, IXJ *j)
  4339. {
  4340. outb_p(p_bytes->high, j->XILINXbase + 0x03);
  4341. outb_p(p_bytes->low, j->XILINXbase + 0x02);
  4342. if (!SCI_Control(j, SCI_Enable_DAA))
  4343. return 0;
  4344. else
  4345. return 1;
  4346. }
  4347. static int ixj_daa_cr4(IXJ *j, char reg)
  4348. {
  4349. BYTES bytes;
  4350. switch (j->daa_mode) {
  4351. case SOP_PU_SLEEP:
  4352. bytes.high = 0x14;
  4353. break;
  4354. case SOP_PU_RINGING:
  4355. bytes.high = 0x54;
  4356. break;
  4357. case SOP_PU_CONVERSATION:
  4358. bytes.high = 0x94;
  4359. break;
  4360. case SOP_PU_PULSEDIALING:
  4361. bytes.high = 0xD4;
  4362. break;
  4363. }
  4364. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = reg;
  4365. switch (j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGX) {
  4366. case 0:
  4367. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 0;
  4368. break;
  4369. case 1:
  4370. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 2;
  4371. break;
  4372. case 2:
  4373. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 1;
  4374. break;
  4375. case 3:
  4376. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 3;
  4377. break;
  4378. }
  4379. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
  4380. if (!daa_load(&bytes, j))
  4381. return 0;
  4382. if (!SCI_Prepare(j))
  4383. return 0;
  4384. return 1;
  4385. }
  4386. static char daa_int_read(IXJ *j)
  4387. {
  4388. BYTES bytes;
  4389. if (!SCI_Prepare(j))
  4390. return 0;
  4391. bytes.high = 0x38;
  4392. bytes.low = 0x00;
  4393. outb_p(bytes.high, j->XILINXbase + 0x03);
  4394. outb_p(bytes.low, j->XILINXbase + 0x02);
  4395. if (!SCI_Control(j, SCI_Enable_DAA))
  4396. return 0;
  4397. bytes.high = inb_p(j->XILINXbase + 0x03);
  4398. bytes.low = inb_p(j->XILINXbase + 0x02);
  4399. if (bytes.low != ALISDAA_ID_BYTE) {
  4400. if (ixjdebug & 0x0001)
  4401. printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
  4402. return 0;
  4403. }
  4404. if (!SCI_Control(j, SCI_Enable_DAA))
  4405. return 0;
  4406. if (!SCI_Control(j, SCI_End))
  4407. return 0;
  4408. bytes.high = inb_p(j->XILINXbase + 0x03);
  4409. bytes.low = inb_p(j->XILINXbase + 0x02);
  4410. j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg = bytes.high;
  4411. return 1;
  4412. }
  4413. static char daa_CR_read(IXJ *j, int cr)
  4414. {
  4415. IXJ_WORD wdata;
  4416. BYTES bytes;
  4417. if (!SCI_Prepare(j))
  4418. return 0;
  4419. switch (j->daa_mode) {
  4420. case SOP_PU_SLEEP:
  4421. bytes.high = 0x30 + cr;
  4422. break;
  4423. case SOP_PU_RINGING:
  4424. bytes.high = 0x70 + cr;
  4425. break;
  4426. case SOP_PU_CONVERSATION:
  4427. bytes.high = 0xB0 + cr;
  4428. break;
  4429. case SOP_PU_PULSEDIALING:
  4430. default:
  4431. bytes.high = 0xF0 + cr;
  4432. break;
  4433. }
  4434. bytes.low = 0x00;
  4435. outb_p(bytes.high, j->XILINXbase + 0x03);
  4436. outb_p(bytes.low, j->XILINXbase + 0x02);
  4437. if (!SCI_Control(j, SCI_Enable_DAA))
  4438. return 0;
  4439. bytes.high = inb_p(j->XILINXbase + 0x03);
  4440. bytes.low = inb_p(j->XILINXbase + 0x02);
  4441. if (bytes.low != ALISDAA_ID_BYTE) {
  4442. if (ixjdebug & 0x0001)
  4443. printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
  4444. return 0;
  4445. }
  4446. if (!SCI_Control(j, SCI_Enable_DAA))
  4447. return 0;
  4448. if (!SCI_Control(j, SCI_End))
  4449. return 0;
  4450. wdata.word = inw_p(j->XILINXbase + 0x02);
  4451. switch(cr){
  4452. case 5:
  4453. j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = wdata.bytes.high;
  4454. break;
  4455. case 4:
  4456. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = wdata.bytes.high;
  4457. break;
  4458. case 3:
  4459. j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = wdata.bytes.high;
  4460. break;
  4461. case 2:
  4462. j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = wdata.bytes.high;
  4463. break;
  4464. case 1:
  4465. j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = wdata.bytes.high;
  4466. break;
  4467. case 0:
  4468. j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = wdata.bytes.high;
  4469. break;
  4470. default:
  4471. return 0;
  4472. }
  4473. return 1;
  4474. }
  4475. static int ixj_daa_cid_reset(IXJ *j)
  4476. {
  4477. int i;
  4478. BYTES bytes;
  4479. if (ixjdebug & 0x0002)
  4480. printk("DAA Clearing CID ram\n");
  4481. if (!SCI_Prepare(j))
  4482. return 0;
  4483. bytes.high = 0x58;
  4484. bytes.low = 0x00;
  4485. outb_p(bytes.high, j->XILINXbase + 0x03);
  4486. outb_p(bytes.low, j->XILINXbase + 0x02);
  4487. if (!SCI_Control(j, SCI_Enable_DAA))
  4488. return 0;
  4489. if (!SCI_WaitHighSCI(j))
  4490. return 0;
  4491. for (i = 0; i < ALISDAA_CALLERID_SIZE - 1; i += 2) {
  4492. bytes.high = bytes.low = 0x00;
  4493. outb_p(bytes.high, j->XILINXbase + 0x03);
  4494. if (i < ALISDAA_CALLERID_SIZE - 1)
  4495. outb_p(bytes.low, j->XILINXbase + 0x02);
  4496. if (!SCI_Control(j, SCI_Enable_DAA))
  4497. return 0;
  4498. if (!SCI_WaitHighSCI(j))
  4499. return 0;
  4500. }
  4501. if (!SCI_Control(j, SCI_End))
  4502. return 0;
  4503. if (ixjdebug & 0x0002)
  4504. printk("DAA CID ram cleared\n");
  4505. return 1;
  4506. }
  4507. static int ixj_daa_cid_read(IXJ *j)
  4508. {
  4509. int i;
  4510. BYTES bytes;
  4511. char CID[ALISDAA_CALLERID_SIZE];
  4512. bool mContinue;
  4513. char *pIn, *pOut;
  4514. if (!SCI_Prepare(j))
  4515. return 0;
  4516. bytes.high = 0x78;
  4517. bytes.low = 0x00;
  4518. outb_p(bytes.high, j->XILINXbase + 0x03);
  4519. outb_p(bytes.low, j->XILINXbase + 0x02);
  4520. if (!SCI_Control(j, SCI_Enable_DAA))
  4521. return 0;
  4522. if (!SCI_WaitHighSCI(j))
  4523. return 0;
  4524. bytes.high = inb_p(j->XILINXbase + 0x03);
  4525. bytes.low = inb_p(j->XILINXbase + 0x02);
  4526. if (bytes.low != ALISDAA_ID_BYTE) {
  4527. if (ixjdebug & 0x0001)
  4528. printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
  4529. return 0;
  4530. }
  4531. for (i = 0; i < ALISDAA_CALLERID_SIZE; i += 2) {
  4532. bytes.high = bytes.low = 0x00;
  4533. outb_p(bytes.high, j->XILINXbase + 0x03);
  4534. outb_p(bytes.low, j->XILINXbase + 0x02);
  4535. if (!SCI_Control(j, SCI_Enable_DAA))
  4536. return 0;
  4537. if (!SCI_WaitHighSCI(j))
  4538. return 0;
  4539. CID[i + 0] = inb_p(j->XILINXbase + 0x03);
  4540. CID[i + 1] = inb_p(j->XILINXbase + 0x02);
  4541. }
  4542. if (!SCI_Control(j, SCI_End))
  4543. return 0;
  4544. pIn = CID;
  4545. pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
  4546. mContinue = true;
  4547. while (mContinue) {
  4548. if ((pIn[1] & 0x03) == 0x01) {
  4549. pOut[0] = pIn[0];
  4550. }
  4551. if ((pIn[2] & 0x0c) == 0x04) {
  4552. pOut[1] = ((pIn[2] & 0x03) << 6) | ((pIn[1] & 0xfc) >> 2);
  4553. }
  4554. if ((pIn[3] & 0x30) == 0x10) {
  4555. pOut[2] = ((pIn[3] & 0x0f) << 4) | ((pIn[2] & 0xf0) >> 4);
  4556. }
  4557. if ((pIn[4] & 0xc0) == 0x40) {
  4558. pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6);
  4559. } else {
  4560. mContinue = false;
  4561. }
  4562. pIn += 5, pOut += 4;
  4563. }
  4564. memset(&j->cid, 0, sizeof(PHONE_CID));
  4565. pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
  4566. pOut += 4;
  4567. strncpy(j->cid.month, pOut, 2);
  4568. pOut += 2;
  4569. strncpy(j->cid.day, pOut, 2);
  4570. pOut += 2;
  4571. strncpy(j->cid.hour, pOut, 2);
  4572. pOut += 2;
  4573. strncpy(j->cid.min, pOut, 2);
  4574. pOut += 3;
  4575. j->cid.numlen = *pOut;
  4576. pOut += 1;
  4577. strncpy(j->cid.number, pOut, j->cid.numlen);
  4578. pOut += j->cid.numlen + 1;
  4579. j->cid.namelen = *pOut;
  4580. pOut += 1;
  4581. strncpy(j->cid.name, pOut, j->cid.namelen);
  4582. ixj_daa_cid_reset(j);
  4583. return 1;
  4584. }
  4585. static char daa_get_version(IXJ *j)
  4586. {
  4587. BYTES bytes;
  4588. if (!SCI_Prepare(j))
  4589. return 0;
  4590. bytes.high = 0x35;
  4591. bytes.low = 0x00;
  4592. outb_p(bytes.high, j->XILINXbase + 0x03);
  4593. outb_p(bytes.low, j->XILINXbase + 0x02);
  4594. if (!SCI_Control(j, SCI_Enable_DAA))
  4595. return 0;
  4596. bytes.high = inb_p(j->XILINXbase + 0x03);
  4597. bytes.low = inb_p(j->XILINXbase + 0x02);
  4598. if (bytes.low != ALISDAA_ID_BYTE) {
  4599. if (ixjdebug & 0x0001)
  4600. printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
  4601. return 0;
  4602. }
  4603. if (!SCI_Control(j, SCI_Enable_DAA))
  4604. return 0;
  4605. if (!SCI_Control(j, SCI_End))
  4606. return 0;
  4607. bytes.high = inb_p(j->XILINXbase + 0x03);
  4608. bytes.low = inb_p(j->XILINXbase + 0x02);
  4609. if (ixjdebug & 0x0002)
  4610. printk("DAA CR5 Byte high = 0x%x low = 0x%x\n", bytes.high, bytes.low);
  4611. j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = bytes.high;
  4612. return bytes.high;
  4613. }
  4614. static int daa_set_mode(IXJ *j, int mode)
  4615. {
  4616. /* NOTE:
  4617. The DAA *MUST* be in the conversation mode if the
  4618. PSTN line is to be seized (PSTN line off-hook).
  4619. Taking the PSTN line off-hook while the DAA is in
  4620. a mode other than conversation mode will cause a
  4621. hardware failure of the ALIS-A part.
  4622. NOTE:
  4623. The DAA can only go to SLEEP, RINGING or PULSEDIALING modes
  4624. if the PSTN line is on-hook. Failure to have the PSTN line
  4625. in the on-hook state WILL CAUSE A HARDWARE FAILURE OF THE
  4626. ALIS-A part.
  4627. */
  4628. BYTES bytes;
  4629. j->flags.pstn_rmr = 0;
  4630. if (!SCI_Prepare(j))
  4631. return 0;
  4632. switch (mode) {
  4633. case SOP_PU_RESET:
  4634. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  4635. outb_p(j->pld_scrw.byte, j->XILINXbase);
  4636. j->pld_slicw.bits.rly2 = 0;
  4637. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  4638. bytes.high = 0x10;
  4639. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
  4640. daa_load(&bytes, j);
  4641. if (!SCI_Prepare(j))
  4642. return 0;
  4643. j->daa_mode = SOP_PU_SLEEP;
  4644. break;
  4645. case SOP_PU_SLEEP:
  4646. if(j->daa_mode == SOP_PU_SLEEP)
  4647. {
  4648. break;
  4649. }
  4650. if (ixjdebug & 0x0008)
  4651. printk(KERN_INFO "phone DAA: SOP_PU_SLEEP at %ld\n", jiffies);
  4652. /* if(j->daa_mode == SOP_PU_CONVERSATION) */
  4653. {
  4654. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  4655. outb_p(j->pld_scrw.byte, j->XILINXbase);
  4656. j->pld_slicw.bits.rly2 = 0;
  4657. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  4658. bytes.high = 0x10;
  4659. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
  4660. daa_load(&bytes, j);
  4661. if (!SCI_Prepare(j))
  4662. return 0;
  4663. }
  4664. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  4665. outb_p(j->pld_scrw.byte, j->XILINXbase);
  4666. j->pld_slicw.bits.rly2 = 0;
  4667. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  4668. bytes.high = 0x10;
  4669. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
  4670. daa_load(&bytes, j);
  4671. if (!SCI_Prepare(j))
  4672. return 0;
  4673. j->daa_mode = SOP_PU_SLEEP;
  4674. j->flags.pstn_ringing = 0;
  4675. j->ex.bits.pstn_ring = 0;
  4676. j->pstn_sleeptil = jiffies + (hertz / 4);
  4677. wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
  4678. wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
  4679. wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
  4680. break;
  4681. case SOP_PU_RINGING:
  4682. if (ixjdebug & 0x0008)
  4683. printk(KERN_INFO "phone DAA: SOP_PU_RINGING at %ld\n", jiffies);
  4684. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  4685. outb_p(j->pld_scrw.byte, j->XILINXbase);
  4686. j->pld_slicw.bits.rly2 = 0;
  4687. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  4688. bytes.high = 0x50;
  4689. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
  4690. daa_load(&bytes, j);
  4691. if (!SCI_Prepare(j))
  4692. return 0;
  4693. j->daa_mode = SOP_PU_RINGING;
  4694. break;
  4695. case SOP_PU_CONVERSATION:
  4696. if (ixjdebug & 0x0008)
  4697. printk(KERN_INFO "phone DAA: SOP_PU_CONVERSATION at %ld\n", jiffies);
  4698. bytes.high = 0x90;
  4699. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
  4700. daa_load(&bytes, j);
  4701. if (!SCI_Prepare(j))
  4702. return 0;
  4703. j->pld_slicw.bits.rly2 = 1;
  4704. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  4705. j->pld_scrw.bits.daafsyncen = 1; /* Turn on DAA Frame Sync */
  4706. outb_p(j->pld_scrw.byte, j->XILINXbase);
  4707. j->daa_mode = SOP_PU_CONVERSATION;
  4708. j->flags.pstn_ringing = 0;
  4709. j->ex.bits.pstn_ring = 0;
  4710. j->pstn_sleeptil = jiffies;
  4711. j->pstn_ring_start = j->pstn_ring_stop = j->pstn_ring_int = 0;
  4712. break;
  4713. case SOP_PU_PULSEDIALING:
  4714. if (ixjdebug & 0x0008)
  4715. printk(KERN_INFO "phone DAA: SOP_PU_PULSEDIALING at %ld\n", jiffies);
  4716. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  4717. outb_p(j->pld_scrw.byte, j->XILINXbase);
  4718. j->pld_slicw.bits.rly2 = 0;
  4719. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  4720. bytes.high = 0xD0;
  4721. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
  4722. daa_load(&bytes, j);
  4723. if (!SCI_Prepare(j))
  4724. return 0;
  4725. j->daa_mode = SOP_PU_PULSEDIALING;
  4726. break;
  4727. default:
  4728. break;
  4729. }
  4730. return 1;
  4731. }
  4732. static int ixj_daa_write(IXJ *j)
  4733. {
  4734. BYTES bytes;
  4735. j->flags.pstncheck = 1;
  4736. daa_set_mode(j, SOP_PU_SLEEP);
  4737. if (!SCI_Prepare(j))
  4738. return 0;
  4739. outb_p(j->pld_scrw.byte, j->XILINXbase);
  4740. bytes.high = 0x14;
  4741. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
  4742. if (!daa_load(&bytes, j))
  4743. return 0;
  4744. bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg;
  4745. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg;
  4746. if (!daa_load(&bytes, j))
  4747. return 0;
  4748. bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg;
  4749. bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
  4750. if (!daa_load(&bytes, j))
  4751. return 0;
  4752. if (!SCI_Prepare(j))
  4753. return 0;
  4754. bytes.high = 0x1F;
  4755. bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg;
  4756. if (!daa_load(&bytes, j))
  4757. return 0;
  4758. bytes.high = j->m_DAAShadowRegs.XOP_xr6_W.reg;
  4759. bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg;
  4760. if (!daa_load(&bytes, j))
  4761. return 0;
  4762. bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg;
  4763. bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg;
  4764. if (!daa_load(&bytes, j))
  4765. return 0;
  4766. bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg;
  4767. bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg;
  4768. if (!daa_load(&bytes, j))
  4769. return 0;
  4770. bytes.high = j->m_DAAShadowRegs.XOP_xr0_W.reg;
  4771. bytes.low = 0x00;
  4772. if (!daa_load(&bytes, j))
  4773. return 0;
  4774. if (!SCI_Prepare(j))
  4775. return 0;
  4776. bytes.high = 0x00;
  4777. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7];
  4778. if (!daa_load(&bytes, j))
  4779. return 0;
  4780. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6];
  4781. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5];
  4782. if (!daa_load(&bytes, j))
  4783. return 0;
  4784. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4];
  4785. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3];
  4786. if (!daa_load(&bytes, j))
  4787. return 0;
  4788. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2];
  4789. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1];
  4790. if (!daa_load(&bytes, j))
  4791. return 0;
  4792. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0];
  4793. bytes.low = 0x00;
  4794. if (!daa_load(&bytes, j))
  4795. return 0;
  4796. if (!SCI_Control(j, SCI_End))
  4797. return 0;
  4798. if (!SCI_WaitLowSCI(j))
  4799. return 0;
  4800. bytes.high = 0x01;
  4801. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7];
  4802. if (!daa_load(&bytes, j))
  4803. return 0;
  4804. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6];
  4805. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5];
  4806. if (!daa_load(&bytes, j))
  4807. return 0;
  4808. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4];
  4809. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3];
  4810. if (!daa_load(&bytes, j))
  4811. return 0;
  4812. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2];
  4813. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1];
  4814. if (!daa_load(&bytes, j))
  4815. return 0;
  4816. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0];
  4817. bytes.low = 0x00;
  4818. if (!daa_load(&bytes, j))
  4819. return 0;
  4820. if (!SCI_Control(j, SCI_End))
  4821. return 0;
  4822. if (!SCI_WaitLowSCI(j))
  4823. return 0;
  4824. bytes.high = 0x02;
  4825. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7];
  4826. if (!daa_load(&bytes, j))
  4827. return 0;
  4828. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6];
  4829. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5];
  4830. if (!daa_load(&bytes, j))
  4831. return 0;
  4832. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4];
  4833. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3];
  4834. if (!daa_load(&bytes, j))
  4835. return 0;
  4836. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2];
  4837. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1];
  4838. if (!daa_load(&bytes, j))
  4839. return 0;
  4840. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0];
  4841. bytes.low = 0x00;
  4842. if (!daa_load(&bytes, j))
  4843. return 0;
  4844. if (!SCI_Control(j, SCI_End))
  4845. return 0;
  4846. if (!SCI_WaitLowSCI(j))
  4847. return 0;
  4848. bytes.high = 0x03;
  4849. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7];
  4850. if (!daa_load(&bytes, j))
  4851. return 0;
  4852. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6];
  4853. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5];
  4854. if (!daa_load(&bytes, j))
  4855. return 0;
  4856. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4];
  4857. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3];
  4858. if (!daa_load(&bytes, j))
  4859. return 0;
  4860. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2];
  4861. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1];
  4862. if (!daa_load(&bytes, j))
  4863. return 0;
  4864. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0];
  4865. bytes.low = 0x00;
  4866. if (!daa_load(&bytes, j))
  4867. return 0;
  4868. if (!SCI_Control(j, SCI_End))
  4869. return 0;
  4870. if (!SCI_WaitLowSCI(j))
  4871. return 0;
  4872. bytes.high = 0x04;
  4873. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7];
  4874. if (!daa_load(&bytes, j))
  4875. return 0;
  4876. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6];
  4877. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5];
  4878. if (!daa_load(&bytes, j))
  4879. return 0;
  4880. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4];
  4881. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3];
  4882. if (!daa_load(&bytes, j))
  4883. return 0;
  4884. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2];
  4885. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1];
  4886. if (!daa_load(&bytes, j))
  4887. return 0;
  4888. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0];
  4889. bytes.low = 0x00;
  4890. if (!daa_load(&bytes, j))
  4891. return 0;
  4892. if (!SCI_Control(j, SCI_End))
  4893. return 0;
  4894. if (!SCI_WaitLowSCI(j))
  4895. return 0;
  4896. bytes.high = 0x05;
  4897. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7];
  4898. if (!daa_load(&bytes, j))
  4899. return 0;
  4900. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6];
  4901. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5];
  4902. if (!daa_load(&bytes, j))
  4903. return 0;
  4904. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4];
  4905. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3];
  4906. if (!daa_load(&bytes, j))
  4907. return 0;
  4908. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2];
  4909. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1];
  4910. if (!daa_load(&bytes, j))
  4911. return 0;
  4912. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0];
  4913. bytes.low = 0x00;
  4914. if (!daa_load(&bytes, j))
  4915. return 0;
  4916. if (!SCI_Control(j, SCI_End))
  4917. return 0;
  4918. if (!SCI_WaitLowSCI(j))
  4919. return 0;
  4920. bytes.high = 0x06;
  4921. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7];
  4922. if (!daa_load(&bytes, j))
  4923. return 0;
  4924. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6];
  4925. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5];
  4926. if (!daa_load(&bytes, j))
  4927. return 0;
  4928. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4];
  4929. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3];
  4930. if (!daa_load(&bytes, j))
  4931. return 0;
  4932. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2];
  4933. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1];
  4934. if (!daa_load(&bytes, j))
  4935. return 0;
  4936. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0];
  4937. bytes.low = 0x00;
  4938. if (!daa_load(&bytes, j))
  4939. return 0;
  4940. if (!SCI_Control(j, SCI_End))
  4941. return 0;
  4942. if (!SCI_WaitLowSCI(j))
  4943. return 0;
  4944. bytes.high = 0x07;
  4945. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7];
  4946. if (!daa_load(&bytes, j))
  4947. return 0;
  4948. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6];
  4949. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5];
  4950. if (!daa_load(&bytes, j))
  4951. return 0;
  4952. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4];
  4953. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3];
  4954. if (!daa_load(&bytes, j))
  4955. return 0;
  4956. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2];
  4957. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1];
  4958. if (!daa_load(&bytes, j))
  4959. return 0;
  4960. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0];
  4961. bytes.low = 0x00;
  4962. if (!daa_load(&bytes, j))
  4963. return 0;
  4964. if (!SCI_Control(j, SCI_End))
  4965. return 0;
  4966. if (!SCI_WaitLowSCI(j))
  4967. return 0;
  4968. bytes.high = 0x08;
  4969. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7];
  4970. if (!daa_load(&bytes, j))
  4971. return 0;
  4972. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6];
  4973. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5];
  4974. if (!daa_load(&bytes, j))
  4975. return 0;
  4976. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4];
  4977. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3];
  4978. if (!daa_load(&bytes, j))
  4979. return 0;
  4980. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2];
  4981. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1];
  4982. if (!daa_load(&bytes, j))
  4983. return 0;
  4984. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0];
  4985. bytes.low = 0x00;
  4986. if (!daa_load(&bytes, j))
  4987. return 0;
  4988. if (!SCI_Control(j, SCI_End))
  4989. return 0;
  4990. if (!SCI_WaitLowSCI(j))
  4991. return 0;
  4992. bytes.high = 0x09;
  4993. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3];
  4994. if (!daa_load(&bytes, j))
  4995. return 0;
  4996. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2];
  4997. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1];
  4998. if (!daa_load(&bytes, j))
  4999. return 0;
  5000. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0];
  5001. bytes.low = 0x00;
  5002. if (!daa_load(&bytes, j))
  5003. return 0;
  5004. if (!SCI_Control(j, SCI_End))
  5005. return 0;
  5006. if (!SCI_WaitLowSCI(j))
  5007. return 0;
  5008. bytes.high = 0x0A;
  5009. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3];
  5010. if (!daa_load(&bytes, j))
  5011. return 0;
  5012. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2];
  5013. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1];
  5014. if (!daa_load(&bytes, j))
  5015. return 0;
  5016. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0];
  5017. bytes.low = 0x00;
  5018. if (!daa_load(&bytes, j))
  5019. return 0;
  5020. if (!SCI_Control(j, SCI_End))
  5021. return 0;
  5022. if (!SCI_WaitLowSCI(j))
  5023. return 0;
  5024. bytes.high = 0x0B;
  5025. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3];
  5026. if (!daa_load(&bytes, j))
  5027. return 0;
  5028. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2];
  5029. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1];
  5030. if (!daa_load(&bytes, j))
  5031. return 0;
  5032. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0];
  5033. bytes.low = 0x00;
  5034. if (!daa_load(&bytes, j))
  5035. return 0;
  5036. if (!SCI_Control(j, SCI_End))
  5037. return 0;
  5038. if (!SCI_WaitLowSCI(j))
  5039. return 0;
  5040. bytes.high = 0x0C;
  5041. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3];
  5042. if (!daa_load(&bytes, j))
  5043. return 0;
  5044. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2];
  5045. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1];
  5046. if (!daa_load(&bytes, j))
  5047. return 0;
  5048. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0];
  5049. bytes.low = 0x00;
  5050. if (!daa_load(&bytes, j))
  5051. return 0;
  5052. if (!SCI_Control(j, SCI_End))
  5053. return 0;
  5054. if (!SCI_WaitLowSCI(j))
  5055. return 0;
  5056. bytes.high = 0x0D;
  5057. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3];
  5058. if (!daa_load(&bytes, j))
  5059. return 0;
  5060. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2];
  5061. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1];
  5062. if (!daa_load(&bytes, j))
  5063. return 0;
  5064. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0];
  5065. bytes.low = 0x00;
  5066. if (!daa_load(&bytes, j))
  5067. return 0;
  5068. if (!SCI_Control(j, SCI_End))
  5069. return 0;
  5070. if (!SCI_WaitLowSCI(j))
  5071. return 0;
  5072. bytes.high = 0x0E;
  5073. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7];
  5074. if (!daa_load(&bytes, j))
  5075. return 0;
  5076. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6];
  5077. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5];
  5078. if (!daa_load(&bytes, j))
  5079. return 0;
  5080. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4];
  5081. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3];
  5082. if (!daa_load(&bytes, j))
  5083. return 0;
  5084. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2];
  5085. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1];
  5086. if (!daa_load(&bytes, j))
  5087. return 0;
  5088. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0];
  5089. bytes.low = 0x00;
  5090. if (!daa_load(&bytes, j))
  5091. return 0;
  5092. if (!SCI_Control(j, SCI_End))
  5093. return 0;
  5094. if (!SCI_WaitLowSCI(j))
  5095. return 0;
  5096. bytes.high = 0x0F;
  5097. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7];
  5098. if (!daa_load(&bytes, j))
  5099. return 0;
  5100. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6];
  5101. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5];
  5102. if (!daa_load(&bytes, j))
  5103. return 0;
  5104. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4];
  5105. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3];
  5106. if (!daa_load(&bytes, j))
  5107. return 0;
  5108. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2];
  5109. bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1];
  5110. if (!daa_load(&bytes, j))
  5111. return 0;
  5112. bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0];
  5113. bytes.low = 0x00;
  5114. if (!daa_load(&bytes, j))
  5115. return 0;
  5116. udelay(32);
  5117. j->pld_scrr.byte = inb_p(j->XILINXbase);
  5118. if (!SCI_Control(j, SCI_End))
  5119. return 0;
  5120. outb_p(j->pld_scrw.byte, j->XILINXbase);
  5121. if (ixjdebug & 0x0002)
  5122. printk("DAA Coefficients Loaded\n");
  5123. j->flags.pstncheck = 0;
  5124. return 1;
  5125. }
  5126. static int ixj_set_tone_off(unsigned short arg, IXJ *j)
  5127. {
  5128. j->tone_off_time = arg;
  5129. if (ixj_WriteDSPCommand(0x6E05, j)) /* Set Tone Off Period */
  5130. return -1;
  5131. if (ixj_WriteDSPCommand(arg, j))
  5132. return -1;
  5133. return 0;
  5134. }
  5135. static int ixj_get_tone_on(IXJ *j)
  5136. {
  5137. if (ixj_WriteDSPCommand(0x6E06, j)) /* Get Tone On Period */
  5138. return -1;
  5139. return 0;
  5140. }
  5141. static int ixj_get_tone_off(IXJ *j)
  5142. {
  5143. if (ixj_WriteDSPCommand(0x6E07, j)) /* Get Tone Off Period */
  5144. return -1;
  5145. return 0;
  5146. }
  5147. static void ixj_busytone(IXJ *j)
  5148. {
  5149. j->flags.ringback = 0;
  5150. j->flags.dialtone = 0;
  5151. j->flags.busytone = 1;
  5152. ixj_set_tone_on(0x07D0, j);
  5153. ixj_set_tone_off(0x07D0, j);
  5154. ixj_play_tone(j, 27);
  5155. }
  5156. static void ixj_dialtone(IXJ *j)
  5157. {
  5158. j->flags.ringback = 0;
  5159. j->flags.dialtone = 1;
  5160. j->flags.busytone = 0;
  5161. if (j->dsp.low == 0x20) {
  5162. return;
  5163. } else {
  5164. ixj_set_tone_on(0xFFFF, j);
  5165. ixj_set_tone_off(0x0000, j);
  5166. ixj_play_tone(j, 25);
  5167. }
  5168. }
  5169. static void ixj_cpt_stop(IXJ *j)
  5170. {
  5171. if(j->tone_state || j->tone_cadence_state)
  5172. {
  5173. j->flags.dialtone = 0;
  5174. j->flags.busytone = 0;
  5175. j->flags.ringback = 0;
  5176. ixj_set_tone_on(0x0001, j);
  5177. ixj_set_tone_off(0x0000, j);
  5178. ixj_play_tone(j, 0);
  5179. j->tone_state = j->tone_cadence_state = 0;
  5180. if (j->cadence_t) {
  5181. kfree(j->cadence_t->ce);
  5182. kfree(j->cadence_t);
  5183. j->cadence_t = NULL;
  5184. }
  5185. }
  5186. if (j->play_mode == -1 && j->rec_mode == -1)
  5187. idle(j);
  5188. if (j->play_mode != -1 && j->dsp.low == 0x20)
  5189. ixj_play_start(j);
  5190. if (j->rec_mode != -1 && j->dsp.low == 0x20)
  5191. ixj_record_start(j);
  5192. }
  5193. static void ixj_ringback(IXJ *j)
  5194. {
  5195. j->flags.busytone = 0;
  5196. j->flags.dialtone = 0;
  5197. j->flags.ringback = 1;
  5198. ixj_set_tone_on(0x0FA0, j);
  5199. ixj_set_tone_off(0x2EE0, j);
  5200. ixj_play_tone(j, 26);
  5201. }
  5202. static void ixj_testram(IXJ *j)
  5203. {
  5204. ixj_WriteDSPCommand(0x3001, j); /* Test External SRAM */
  5205. }
  5206. static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp)
  5207. {
  5208. ixj_cadence *lcp;
  5209. IXJ_CADENCE_ELEMENT __user *cep;
  5210. IXJ_CADENCE_ELEMENT *lcep;
  5211. IXJ_TONE ti;
  5212. int err;
  5213. lcp = kmalloc(sizeof(ixj_cadence), GFP_KERNEL);
  5214. if (lcp == NULL)
  5215. return -ENOMEM;
  5216. err = -EFAULT;
  5217. if (copy_from_user(&lcp->elements_used,
  5218. &cp->elements_used, sizeof(int)))
  5219. goto out;
  5220. if (copy_from_user(&lcp->termination,
  5221. &cp->termination, sizeof(IXJ_CADENCE_TERM)))
  5222. goto out;
  5223. if (get_user(cep, &cp->ce))
  5224. goto out;
  5225. err = -EINVAL;
  5226. if ((unsigned)lcp->elements_used >= ~0U/sizeof(IXJ_CADENCE_ELEMENT))
  5227. goto out;
  5228. err = -ENOMEM;
  5229. lcep = kmalloc(sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used, GFP_KERNEL);
  5230. if (!lcep)
  5231. goto out;
  5232. err = -EFAULT;
  5233. if (copy_from_user(lcep, cep, sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used))
  5234. goto out1;
  5235. if (j->cadence_t) {
  5236. kfree(j->cadence_t->ce);
  5237. kfree(j->cadence_t);
  5238. }
  5239. lcp->ce = (void *) lcep;
  5240. j->cadence_t = lcp;
  5241. j->tone_cadence_state = 0;
  5242. ixj_set_tone_on(lcp->ce[0].tone_on_time, j);
  5243. ixj_set_tone_off(lcp->ce[0].tone_off_time, j);
  5244. if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
  5245. ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
  5246. ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
  5247. ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
  5248. ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
  5249. ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
  5250. ixj_init_tone(j, &ti);
  5251. }
  5252. ixj_play_tone(j, lcp->ce[0].index);
  5253. return 1;
  5254. out1:
  5255. kfree(lcep);
  5256. out:
  5257. kfree(lcp);
  5258. return err;
  5259. }
  5260. static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp)
  5261. {
  5262. IXJ_FILTER_CADENCE *lcp;
  5263. lcp = memdup_user(cp, sizeof(IXJ_FILTER_CADENCE));
  5264. if (IS_ERR(lcp)) {
  5265. if(ixjdebug & 0x0001) {
  5266. printk(KERN_INFO "Could not allocate memory for cadence or could not copy cadence to kernel\n");
  5267. }
  5268. return PTR_ERR(lcp);
  5269. }
  5270. if (lcp->filter > 5) {
  5271. if(ixjdebug & 0x0001) {
  5272. printk(KERN_INFO "Cadence out of range\n");
  5273. }
  5274. kfree(lcp);
  5275. return -1;
  5276. }
  5277. j->cadence_f[lcp->filter].state = 0;
  5278. j->cadence_f[lcp->filter].enable = lcp->enable;
  5279. j->filter_en[lcp->filter] = j->cadence_f[lcp->filter].en_filter = lcp->en_filter;
  5280. j->cadence_f[lcp->filter].on1 = lcp->on1;
  5281. j->cadence_f[lcp->filter].on1min = 0;
  5282. j->cadence_f[lcp->filter].on1max = 0;
  5283. j->cadence_f[lcp->filter].off1 = lcp->off1;
  5284. j->cadence_f[lcp->filter].off1min = 0;
  5285. j->cadence_f[lcp->filter].off1max = 0;
  5286. j->cadence_f[lcp->filter].on2 = lcp->on2;
  5287. j->cadence_f[lcp->filter].on2min = 0;
  5288. j->cadence_f[lcp->filter].on2max = 0;
  5289. j->cadence_f[lcp->filter].off2 = lcp->off2;
  5290. j->cadence_f[lcp->filter].off2min = 0;
  5291. j->cadence_f[lcp->filter].off2max = 0;
  5292. j->cadence_f[lcp->filter].on3 = lcp->on3;
  5293. j->cadence_f[lcp->filter].on3min = 0;
  5294. j->cadence_f[lcp->filter].on3max = 0;
  5295. j->cadence_f[lcp->filter].off3 = lcp->off3;
  5296. j->cadence_f[lcp->filter].off3min = 0;
  5297. j->cadence_f[lcp->filter].off3max = 0;
  5298. if(ixjdebug & 0x0002) {
  5299. printk(KERN_INFO "Cadence %d loaded\n", lcp->filter);
  5300. }
  5301. kfree(lcp);
  5302. return 0;
  5303. }
  5304. static void add_caps(IXJ *j)
  5305. {
  5306. j->caps = 0;
  5307. j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET;
  5308. strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)");
  5309. j->caplist[j->caps].captype = vendor;
  5310. j->caplist[j->caps].handle = j->caps++;
  5311. j->caplist[j->caps].captype = device;
  5312. switch (j->cardtype) {
  5313. case QTI_PHONEJACK:
  5314. strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK");
  5315. break;
  5316. case QTI_LINEJACK:
  5317. strcpy(j->caplist[j->caps].desc, "Quicknet Internet LineJACK");
  5318. break;
  5319. case QTI_PHONEJACK_LITE:
  5320. strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK Lite");
  5321. break;
  5322. case QTI_PHONEJACK_PCI:
  5323. strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK PCI");
  5324. break;
  5325. case QTI_PHONECARD:
  5326. strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneCARD");
  5327. break;
  5328. }
  5329. j->caplist[j->caps].cap = j->cardtype;
  5330. j->caplist[j->caps].handle = j->caps++;
  5331. strcpy(j->caplist[j->caps].desc, "POTS");
  5332. j->caplist[j->caps].captype = port;
  5333. j->caplist[j->caps].cap = pots;
  5334. j->caplist[j->caps].handle = j->caps++;
  5335. /* add devices that can do speaker/mic */
  5336. switch (j->cardtype) {
  5337. case QTI_PHONEJACK:
  5338. case QTI_LINEJACK:
  5339. case QTI_PHONEJACK_PCI:
  5340. case QTI_PHONECARD:
  5341. strcpy(j->caplist[j->caps].desc, "SPEAKER");
  5342. j->caplist[j->caps].captype = port;
  5343. j->caplist[j->caps].cap = speaker;
  5344. j->caplist[j->caps].handle = j->caps++;
  5345. default:
  5346. break;
  5347. }
  5348. /* add devices that can do handset */
  5349. switch (j->cardtype) {
  5350. case QTI_PHONEJACK:
  5351. strcpy(j->caplist[j->caps].desc, "HANDSET");
  5352. j->caplist[j->caps].captype = port;
  5353. j->caplist[j->caps].cap = handset;
  5354. j->caplist[j->caps].handle = j->caps++;
  5355. break;
  5356. default:
  5357. break;
  5358. }
  5359. /* add devices that can do PSTN */
  5360. switch (j->cardtype) {
  5361. case QTI_LINEJACK:
  5362. strcpy(j->caplist[j->caps].desc, "PSTN");
  5363. j->caplist[j->caps].captype = port;
  5364. j->caplist[j->caps].cap = pstn;
  5365. j->caplist[j->caps].handle = j->caps++;
  5366. break;
  5367. default:
  5368. break;
  5369. }
  5370. /* add codecs - all cards can do uLaw, linear 8/16, and Windows sound system */
  5371. strcpy(j->caplist[j->caps].desc, "ULAW");
  5372. j->caplist[j->caps].captype = codec;
  5373. j->caplist[j->caps].cap = ULAW;
  5374. j->caplist[j->caps].handle = j->caps++;
  5375. strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit");
  5376. j->caplist[j->caps].captype = codec;
  5377. j->caplist[j->caps].cap = LINEAR16;
  5378. j->caplist[j->caps].handle = j->caps++;
  5379. strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit");
  5380. j->caplist[j->caps].captype = codec;
  5381. j->caplist[j->caps].cap = LINEAR8;
  5382. j->caplist[j->caps].handle = j->caps++;
  5383. strcpy(j->caplist[j->caps].desc, "Windows Sound System");
  5384. j->caplist[j->caps].captype = codec;
  5385. j->caplist[j->caps].cap = WSS;
  5386. j->caplist[j->caps].handle = j->caps++;
  5387. /* software ALAW codec, made from ULAW */
  5388. strcpy(j->caplist[j->caps].desc, "ALAW");
  5389. j->caplist[j->caps].captype = codec;
  5390. j->caplist[j->caps].cap = ALAW;
  5391. j->caplist[j->caps].handle = j->caps++;
  5392. /* version 12 of the 8020 does the following codecs in a broken way */
  5393. if (j->dsp.low != 0x20 || j->ver.low != 0x12) {
  5394. strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps");
  5395. j->caplist[j->caps].captype = codec;
  5396. j->caplist[j->caps].cap = G723_63;
  5397. j->caplist[j->caps].handle = j->caps++;
  5398. strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps");
  5399. j->caplist[j->caps].captype = codec;
  5400. j->caplist[j->caps].cap = G723_53;
  5401. j->caplist[j->caps].handle = j->caps++;
  5402. strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps");
  5403. j->caplist[j->caps].captype = codec;
  5404. j->caplist[j->caps].cap = TS48;
  5405. j->caplist[j->caps].handle = j->caps++;
  5406. strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps");
  5407. j->caplist[j->caps].captype = codec;
  5408. j->caplist[j->caps].cap = TS41;
  5409. j->caplist[j->caps].handle = j->caps++;
  5410. }
  5411. /* 8020 chips can do TS8.5 native, and 8021/8022 can load it */
  5412. if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
  5413. strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps");
  5414. j->caplist[j->caps].captype = codec;
  5415. j->caplist[j->caps].cap = TS85;
  5416. j->caplist[j->caps].handle = j->caps++;
  5417. }
  5418. /* 8021 chips can do G728 */
  5419. if (j->dsp.low == 0x21) {
  5420. strcpy(j->caplist[j->caps].desc, "G.728 16kbps");
  5421. j->caplist[j->caps].captype = codec;
  5422. j->caplist[j->caps].cap = G728;
  5423. j->caplist[j->caps].handle = j->caps++;
  5424. }
  5425. /* 8021/8022 chips can do G729 if loaded */
  5426. if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
  5427. strcpy(j->caplist[j->caps].desc, "G.729A 8kbps");
  5428. j->caplist[j->caps].captype = codec;
  5429. j->caplist[j->caps].cap = G729;
  5430. j->caplist[j->caps].handle = j->caps++;
  5431. }
  5432. if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
  5433. strcpy(j->caplist[j->caps].desc, "G.729B 8kbps");
  5434. j->caplist[j->caps].captype = codec;
  5435. j->caplist[j->caps].cap = G729B;
  5436. j->caplist[j->caps].handle = j->caps++;
  5437. }
  5438. }
  5439. static int capabilities_check(IXJ *j, struct phone_capability *pcreq)
  5440. {
  5441. int cnt;
  5442. int retval = 0;
  5443. for (cnt = 0; cnt < j->caps; cnt++) {
  5444. if (pcreq->captype == j->caplist[cnt].captype
  5445. && pcreq->cap == j->caplist[cnt].cap) {
  5446. retval = 1;
  5447. break;
  5448. }
  5449. }
  5450. return retval;
  5451. }
  5452. static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg)
  5453. {
  5454. IXJ_TONE ti;
  5455. IXJ_FILTER jf;
  5456. IXJ_FILTER_RAW jfr;
  5457. void __user *argp = (void __user *)arg;
  5458. struct inode *inode = file_p->f_path.dentry->d_inode;
  5459. unsigned int minor = iminor(inode);
  5460. unsigned int raise, mant;
  5461. int board = NUM(inode);
  5462. IXJ *j = get_ixj(NUM(inode));
  5463. int retval = 0;
  5464. /*
  5465. * Set up locks to ensure that only one process is talking to the DSP at a time.
  5466. * This is necessary to keep the DSP from locking up.
  5467. */
  5468. while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
  5469. schedule_timeout_interruptible(1);
  5470. if (ixjdebug & 0x0040)
  5471. printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
  5472. if (minor >= IXJMAX) {
  5473. clear_bit(board, &j->busyflags);
  5474. return -ENODEV;
  5475. }
  5476. /*
  5477. * Check ioctls only root can use.
  5478. */
  5479. if (!capable(CAP_SYS_ADMIN)) {
  5480. switch (cmd) {
  5481. case IXJCTL_TESTRAM:
  5482. case IXJCTL_HZ:
  5483. retval = -EPERM;
  5484. }
  5485. }
  5486. switch (cmd) {
  5487. case IXJCTL_TESTRAM:
  5488. ixj_testram(j);
  5489. retval = (j->ssr.high << 8) + j->ssr.low;
  5490. break;
  5491. case IXJCTL_CARDTYPE:
  5492. retval = j->cardtype;
  5493. break;
  5494. case IXJCTL_SERIAL:
  5495. retval = j->serial;
  5496. break;
  5497. case IXJCTL_VERSION:
  5498. {
  5499. char arg_str[100];
  5500. snprintf(arg_str, sizeof(arg_str),
  5501. "\nDriver version %i.%i.%i", IXJ_VER_MAJOR,
  5502. IXJ_VER_MINOR, IXJ_BLD_VER);
  5503. if (copy_to_user(argp, arg_str, strlen(arg_str)))
  5504. retval = -EFAULT;
  5505. }
  5506. break;
  5507. case PHONE_RING_CADENCE:
  5508. j->ring_cadence = arg;
  5509. break;
  5510. case IXJCTL_CIDCW:
  5511. if(arg) {
  5512. if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
  5513. retval = -EFAULT;
  5514. break;
  5515. }
  5516. } else {
  5517. memset(&j->cid_send, 0, sizeof(PHONE_CID));
  5518. }
  5519. ixj_write_cidcw(j);
  5520. break;
  5521. /* Binary compatbility */
  5522. case OLD_PHONE_RING_START:
  5523. arg = 0;
  5524. /* Fall through */
  5525. case PHONE_RING_START:
  5526. if(arg) {
  5527. if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
  5528. retval = -EFAULT;
  5529. break;
  5530. }
  5531. ixj_write_cid(j);
  5532. } else {
  5533. memset(&j->cid_send, 0, sizeof(PHONE_CID));
  5534. }
  5535. ixj_ring_start(j);
  5536. break;
  5537. case PHONE_RING_STOP:
  5538. j->flags.cringing = 0;
  5539. if(j->cadence_f[5].enable) {
  5540. j->cadence_f[5].state = 0;
  5541. }
  5542. ixj_ring_off(j);
  5543. break;
  5544. case PHONE_RING:
  5545. retval = ixj_ring(j);
  5546. break;
  5547. case PHONE_EXCEPTION:
  5548. retval = j->ex.bytes;
  5549. if(j->ex.bits.flash) {
  5550. j->flash_end = 0;
  5551. j->ex.bits.flash = 0;
  5552. }
  5553. j->ex.bits.pstn_ring = 0;
  5554. j->ex.bits.caller_id = 0;
  5555. j->ex.bits.pstn_wink = 0;
  5556. j->ex.bits.f0 = 0;
  5557. j->ex.bits.f1 = 0;
  5558. j->ex.bits.f2 = 0;
  5559. j->ex.bits.f3 = 0;
  5560. j->ex.bits.fc0 = 0;
  5561. j->ex.bits.fc1 = 0;
  5562. j->ex.bits.fc2 = 0;
  5563. j->ex.bits.fc3 = 0;
  5564. j->ex.bits.reserved = 0;
  5565. break;
  5566. case PHONE_HOOKSTATE:
  5567. j->ex.bits.hookstate = 0;
  5568. retval = j->hookstate; //j->r_hook;
  5569. break;
  5570. case IXJCTL_SET_LED:
  5571. LED_SetState(arg, j);
  5572. break;
  5573. case PHONE_FRAME:
  5574. retval = set_base_frame(j, arg);
  5575. break;
  5576. case PHONE_REC_CODEC:
  5577. retval = set_rec_codec(j, arg);
  5578. break;
  5579. case PHONE_VAD:
  5580. ixj_vad(j, arg);
  5581. break;
  5582. case PHONE_REC_START:
  5583. ixj_record_start(j);
  5584. break;
  5585. case PHONE_REC_STOP:
  5586. ixj_record_stop(j);
  5587. break;
  5588. case PHONE_REC_DEPTH:
  5589. set_rec_depth(j, arg);
  5590. break;
  5591. case PHONE_REC_VOLUME:
  5592. if(arg == -1) {
  5593. retval = get_rec_volume(j);
  5594. }
  5595. else {
  5596. set_rec_volume(j, arg);
  5597. retval = arg;
  5598. }
  5599. break;
  5600. case PHONE_REC_VOLUME_LINEAR:
  5601. if(arg == -1) {
  5602. retval = get_rec_volume_linear(j);
  5603. }
  5604. else {
  5605. set_rec_volume_linear(j, arg);
  5606. retval = arg;
  5607. }
  5608. break;
  5609. case IXJCTL_DTMF_PRESCALE:
  5610. if(arg == -1) {
  5611. retval = get_dtmf_prescale(j);
  5612. }
  5613. else {
  5614. set_dtmf_prescale(j, arg);
  5615. retval = arg;
  5616. }
  5617. break;
  5618. case PHONE_REC_LEVEL:
  5619. retval = get_rec_level(j);
  5620. break;
  5621. case IXJCTL_SC_RXG:
  5622. retval = ixj_siadc(j, arg);
  5623. break;
  5624. case IXJCTL_SC_TXG:
  5625. retval = ixj_sidac(j, arg);
  5626. break;
  5627. case IXJCTL_AEC_START:
  5628. ixj_aec_start(j, arg);
  5629. break;
  5630. case IXJCTL_AEC_STOP:
  5631. aec_stop(j);
  5632. break;
  5633. case IXJCTL_AEC_GET_LEVEL:
  5634. retval = j->aec_level;
  5635. break;
  5636. case PHONE_PLAY_CODEC:
  5637. retval = set_play_codec(j, arg);
  5638. break;
  5639. case PHONE_PLAY_START:
  5640. retval = ixj_play_start(j);
  5641. break;
  5642. case PHONE_PLAY_STOP:
  5643. ixj_play_stop(j);
  5644. break;
  5645. case PHONE_PLAY_DEPTH:
  5646. set_play_depth(j, arg);
  5647. break;
  5648. case PHONE_PLAY_VOLUME:
  5649. if(arg == -1) {
  5650. retval = get_play_volume(j);
  5651. }
  5652. else {
  5653. set_play_volume(j, arg);
  5654. retval = arg;
  5655. }
  5656. break;
  5657. case PHONE_PLAY_VOLUME_LINEAR:
  5658. if(arg == -1) {
  5659. retval = get_play_volume_linear(j);
  5660. }
  5661. else {
  5662. set_play_volume_linear(j, arg);
  5663. retval = arg;
  5664. }
  5665. break;
  5666. case PHONE_PLAY_LEVEL:
  5667. retval = get_play_level(j);
  5668. break;
  5669. case IXJCTL_DSP_TYPE:
  5670. retval = (j->dsp.high << 8) + j->dsp.low;
  5671. break;
  5672. case IXJCTL_DSP_VERSION:
  5673. retval = (j->ver.high << 8) + j->ver.low;
  5674. break;
  5675. case IXJCTL_HZ:
  5676. hertz = arg;
  5677. break;
  5678. case IXJCTL_RATE:
  5679. if (arg > hertz)
  5680. retval = -1;
  5681. else
  5682. samplerate = arg;
  5683. break;
  5684. case IXJCTL_DRYBUFFER_READ:
  5685. put_user(j->drybuffer, (unsigned long __user *) argp);
  5686. break;
  5687. case IXJCTL_DRYBUFFER_CLEAR:
  5688. j->drybuffer = 0;
  5689. break;
  5690. case IXJCTL_FRAMES_READ:
  5691. put_user(j->framesread, (unsigned long __user *) argp);
  5692. break;
  5693. case IXJCTL_FRAMES_WRITTEN:
  5694. put_user(j->frameswritten, (unsigned long __user *) argp);
  5695. break;
  5696. case IXJCTL_READ_WAIT:
  5697. put_user(j->read_wait, (unsigned long __user *) argp);
  5698. break;
  5699. case IXJCTL_WRITE_WAIT:
  5700. put_user(j->write_wait, (unsigned long __user *) argp);
  5701. break;
  5702. case PHONE_MAXRINGS:
  5703. j->maxrings = arg;
  5704. break;
  5705. case PHONE_SET_TONE_ON_TIME:
  5706. ixj_set_tone_on(arg, j);
  5707. break;
  5708. case PHONE_SET_TONE_OFF_TIME:
  5709. ixj_set_tone_off(arg, j);
  5710. break;
  5711. case PHONE_GET_TONE_ON_TIME:
  5712. if (ixj_get_tone_on(j)) {
  5713. retval = -1;
  5714. } else {
  5715. retval = (j->ssr.high << 8) + j->ssr.low;
  5716. }
  5717. break;
  5718. case PHONE_GET_TONE_OFF_TIME:
  5719. if (ixj_get_tone_off(j)) {
  5720. retval = -1;
  5721. } else {
  5722. retval = (j->ssr.high << 8) + j->ssr.low;
  5723. }
  5724. break;
  5725. case PHONE_PLAY_TONE:
  5726. if (!j->tone_state)
  5727. retval = ixj_play_tone(j, arg);
  5728. else
  5729. retval = -1;
  5730. break;
  5731. case PHONE_GET_TONE_STATE:
  5732. retval = j->tone_state;
  5733. break;
  5734. case PHONE_DTMF_READY:
  5735. retval = j->ex.bits.dtmf_ready;
  5736. break;
  5737. case PHONE_GET_DTMF:
  5738. if (ixj_hookstate(j)) {
  5739. if (j->dtmf_rp != j->dtmf_wp) {
  5740. retval = j->dtmfbuffer[j->dtmf_rp];
  5741. j->dtmf_rp++;
  5742. if (j->dtmf_rp == 79)
  5743. j->dtmf_rp = 0;
  5744. if (j->dtmf_rp == j->dtmf_wp) {
  5745. j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
  5746. }
  5747. }
  5748. }
  5749. break;
  5750. case PHONE_GET_DTMF_ASCII:
  5751. if (ixj_hookstate(j)) {
  5752. if (j->dtmf_rp != j->dtmf_wp) {
  5753. switch (j->dtmfbuffer[j->dtmf_rp]) {
  5754. case 10:
  5755. retval = 42; /* '*'; */
  5756. break;
  5757. case 11:
  5758. retval = 48; /*'0'; */
  5759. break;
  5760. case 12:
  5761. retval = 35; /*'#'; */
  5762. break;
  5763. case 28:
  5764. retval = 65; /*'A'; */
  5765. break;
  5766. case 29:
  5767. retval = 66; /*'B'; */
  5768. break;
  5769. case 30:
  5770. retval = 67; /*'C'; */
  5771. break;
  5772. case 31:
  5773. retval = 68; /*'D'; */
  5774. break;
  5775. default:
  5776. retval = 48 + j->dtmfbuffer[j->dtmf_rp];
  5777. break;
  5778. }
  5779. j->dtmf_rp++;
  5780. if (j->dtmf_rp == 79)
  5781. j->dtmf_rp = 0;
  5782. if(j->dtmf_rp == j->dtmf_wp)
  5783. {
  5784. j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
  5785. }
  5786. }
  5787. }
  5788. break;
  5789. case PHONE_DTMF_OOB:
  5790. j->flags.dtmf_oob = arg;
  5791. break;
  5792. case PHONE_DIALTONE:
  5793. ixj_dialtone(j);
  5794. break;
  5795. case PHONE_BUSY:
  5796. ixj_busytone(j);
  5797. break;
  5798. case PHONE_RINGBACK:
  5799. ixj_ringback(j);
  5800. break;
  5801. case PHONE_WINK:
  5802. if(j->cardtype == QTI_PHONEJACK)
  5803. retval = -1;
  5804. else
  5805. retval = ixj_wink(j);
  5806. break;
  5807. case PHONE_CPT_STOP:
  5808. ixj_cpt_stop(j);
  5809. break;
  5810. case PHONE_QUERY_CODEC:
  5811. {
  5812. struct phone_codec_data pd;
  5813. int val;
  5814. int proto_size[] = {
  5815. -1,
  5816. 12, 10, 16, 9, 8, 48, 5,
  5817. 40, 40, 80, 40, 40, 6
  5818. };
  5819. if(copy_from_user(&pd, argp, sizeof(pd))) {
  5820. retval = -EFAULT;
  5821. break;
  5822. }
  5823. if(pd.type<1 || pd.type>13) {
  5824. retval = -EPROTONOSUPPORT;
  5825. break;
  5826. }
  5827. if(pd.type<G729)
  5828. val=proto_size[pd.type];
  5829. else switch(j->baseframe.low)
  5830. {
  5831. case 0xA0:val=2*proto_size[pd.type];break;
  5832. case 0x50:val=proto_size[pd.type];break;
  5833. default:val=proto_size[pd.type]*3;break;
  5834. }
  5835. pd.buf_min=pd.buf_max=pd.buf_opt=val;
  5836. if(copy_to_user(argp, &pd, sizeof(pd)))
  5837. retval = -EFAULT;
  5838. break;
  5839. }
  5840. case IXJCTL_DSP_IDLE:
  5841. idle(j);
  5842. break;
  5843. case IXJCTL_MIXER:
  5844. if ((arg & 0xff) == 0xff)
  5845. retval = ixj_get_mixer(arg, j);
  5846. else
  5847. ixj_mixer(arg, j);
  5848. break;
  5849. case IXJCTL_DAA_COEFF_SET:
  5850. switch (arg) {
  5851. case DAA_US:
  5852. DAA_Coeff_US(j);
  5853. retval = ixj_daa_write(j);
  5854. break;
  5855. case DAA_UK:
  5856. DAA_Coeff_UK(j);
  5857. retval = ixj_daa_write(j);
  5858. break;
  5859. case DAA_FRANCE:
  5860. DAA_Coeff_France(j);
  5861. retval = ixj_daa_write(j);
  5862. break;
  5863. case DAA_GERMANY:
  5864. DAA_Coeff_Germany(j);
  5865. retval = ixj_daa_write(j);
  5866. break;
  5867. case DAA_AUSTRALIA:
  5868. DAA_Coeff_Australia(j);
  5869. retval = ixj_daa_write(j);
  5870. break;
  5871. case DAA_JAPAN:
  5872. DAA_Coeff_Japan(j);
  5873. retval = ixj_daa_write(j);
  5874. break;
  5875. default:
  5876. retval = 1;
  5877. break;
  5878. }
  5879. break;
  5880. case IXJCTL_DAA_AGAIN:
  5881. ixj_daa_cr4(j, arg | 0x02);
  5882. break;
  5883. case IXJCTL_PSTN_LINETEST:
  5884. retval = ixj_linetest(j);
  5885. break;
  5886. case IXJCTL_VMWI:
  5887. ixj_write_vmwi(j, arg);
  5888. break;
  5889. case IXJCTL_CID:
  5890. if (copy_to_user(argp, &j->cid, sizeof(PHONE_CID)))
  5891. retval = -EFAULT;
  5892. j->ex.bits.caller_id = 0;
  5893. break;
  5894. case IXJCTL_WINK_DURATION:
  5895. j->winktime = arg;
  5896. break;
  5897. case IXJCTL_PORT:
  5898. if (arg)
  5899. retval = ixj_set_port(j, arg);
  5900. else
  5901. retval = j->port;
  5902. break;
  5903. case IXJCTL_POTS_PSTN:
  5904. retval = ixj_set_pots(j, arg);
  5905. break;
  5906. case PHONE_CAPABILITIES:
  5907. add_caps(j);
  5908. retval = j->caps;
  5909. break;
  5910. case PHONE_CAPABILITIES_LIST:
  5911. add_caps(j);
  5912. if (copy_to_user(argp, j->caplist, sizeof(struct phone_capability) * j->caps))
  5913. retval = -EFAULT;
  5914. break;
  5915. case PHONE_CAPABILITIES_CHECK:
  5916. {
  5917. struct phone_capability cap;
  5918. if (copy_from_user(&cap, argp, sizeof(cap)))
  5919. retval = -EFAULT;
  5920. else {
  5921. add_caps(j);
  5922. retval = capabilities_check(j, &cap);
  5923. }
  5924. }
  5925. break;
  5926. case PHONE_PSTN_SET_STATE:
  5927. daa_set_mode(j, arg);
  5928. break;
  5929. case PHONE_PSTN_GET_STATE:
  5930. retval = j->daa_mode;
  5931. j->ex.bits.pstn_ring = 0;
  5932. break;
  5933. case IXJCTL_SET_FILTER:
  5934. if (copy_from_user(&jf, argp, sizeof(jf)))
  5935. retval = -EFAULT;
  5936. else
  5937. retval = ixj_init_filter(j, &jf);
  5938. break;
  5939. case IXJCTL_SET_FILTER_RAW:
  5940. if (copy_from_user(&jfr, argp, sizeof(jfr)))
  5941. retval = -EFAULT;
  5942. else
  5943. retval = ixj_init_filter_raw(j, &jfr);
  5944. break;
  5945. case IXJCTL_GET_FILTER_HIST:
  5946. if(arg<0||arg>3)
  5947. retval = -EINVAL;
  5948. else
  5949. retval = j->filter_hist[arg];
  5950. break;
  5951. case IXJCTL_INIT_TONE:
  5952. if (copy_from_user(&ti, argp, sizeof(ti)))
  5953. retval = -EFAULT;
  5954. else
  5955. retval = ixj_init_tone(j, &ti);
  5956. break;
  5957. case IXJCTL_TONE_CADENCE:
  5958. retval = ixj_build_cadence(j, argp);
  5959. break;
  5960. case IXJCTL_FILTER_CADENCE:
  5961. retval = ixj_build_filter_cadence(j, argp);
  5962. break;
  5963. case IXJCTL_SIGCTL:
  5964. if (copy_from_user(&j->sigdef, argp, sizeof(IXJ_SIGDEF))) {
  5965. retval = -EFAULT;
  5966. break;
  5967. }
  5968. j->ixj_signals[j->sigdef.event] = j->sigdef.signal;
  5969. if(j->sigdef.event < 33) {
  5970. raise = 1;
  5971. for(mant = 0; mant < j->sigdef.event; mant++){
  5972. raise *= 2;
  5973. }
  5974. if(j->sigdef.signal)
  5975. j->ex_sig.bytes |= raise;
  5976. else
  5977. j->ex_sig.bytes &= (raise^0xffff);
  5978. }
  5979. break;
  5980. case IXJCTL_INTERCOM_STOP:
  5981. if(arg < 0 || arg >= IXJMAX)
  5982. return -EINVAL;
  5983. j->intercom = -1;
  5984. ixj_record_stop(j);
  5985. ixj_play_stop(j);
  5986. idle(j);
  5987. get_ixj(arg)->intercom = -1;
  5988. ixj_record_stop(get_ixj(arg));
  5989. ixj_play_stop(get_ixj(arg));
  5990. idle(get_ixj(arg));
  5991. break;
  5992. case IXJCTL_INTERCOM_START:
  5993. if(arg < 0 || arg >= IXJMAX)
  5994. return -EINVAL;
  5995. j->intercom = arg;
  5996. ixj_record_start(j);
  5997. ixj_play_start(j);
  5998. get_ixj(arg)->intercom = board;
  5999. ixj_play_start(get_ixj(arg));
  6000. ixj_record_start(get_ixj(arg));
  6001. break;
  6002. }
  6003. if (ixjdebug & 0x0040)
  6004. printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
  6005. clear_bit(board, &j->busyflags);
  6006. return retval;
  6007. }
  6008. static long ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg)
  6009. {
  6010. long ret;
  6011. mutex_lock(&ixj_mutex);
  6012. ret = do_ixj_ioctl(file_p, cmd, arg);
  6013. mutex_unlock(&ixj_mutex);
  6014. return ret;
  6015. }
  6016. static int ixj_fasync(int fd, struct file *file_p, int mode)
  6017. {
  6018. IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
  6019. return fasync_helper(fd, file_p, mode, &j->async_queue);
  6020. }
  6021. static const struct file_operations ixj_fops =
  6022. {
  6023. .owner = THIS_MODULE,
  6024. .read = ixj_enhanced_read,
  6025. .write = ixj_enhanced_write,
  6026. .poll = ixj_poll,
  6027. .unlocked_ioctl = ixj_ioctl,
  6028. .release = ixj_release,
  6029. .fasync = ixj_fasync,
  6030. .llseek = default_llseek,
  6031. };
  6032. static int ixj_linetest(IXJ *j)
  6033. {
  6034. j->flags.pstncheck = 1; /* Testing */
  6035. j->flags.pstn_present = 0; /* Assume the line is not there */
  6036. daa_int_read(j); /*Clear DAA Interrupt flags */
  6037. /* */
  6038. /* Hold all relays in the normally de-energized position. */
  6039. /* */
  6040. j->pld_slicw.bits.rly1 = 0;
  6041. j->pld_slicw.bits.rly2 = 0;
  6042. j->pld_slicw.bits.rly3 = 0;
  6043. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  6044. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  6045. outb_p(j->pld_scrw.byte, j->XILINXbase);
  6046. j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
  6047. if (j->pld_slicr.bits.potspstn) {
  6048. j->flags.pots_pstn = 1;
  6049. j->flags.pots_correct = 0;
  6050. LED_SetState(0x4, j);
  6051. } else {
  6052. j->flags.pots_pstn = 0;
  6053. j->pld_slicw.bits.rly1 = 0;
  6054. j->pld_slicw.bits.rly2 = 0;
  6055. j->pld_slicw.bits.rly3 = 1;
  6056. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  6057. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  6058. outb_p(j->pld_scrw.byte, j->XILINXbase);
  6059. daa_set_mode(j, SOP_PU_CONVERSATION);
  6060. msleep(1000);
  6061. daa_int_read(j);
  6062. daa_set_mode(j, SOP_PU_RESET);
  6063. if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
  6064. j->flags.pots_correct = 0; /* Should not be line voltage on POTS port. */
  6065. LED_SetState(0x4, j);
  6066. j->pld_slicw.bits.rly3 = 0;
  6067. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  6068. } else {
  6069. j->flags.pots_correct = 1;
  6070. LED_SetState(0x8, j);
  6071. j->pld_slicw.bits.rly1 = 1;
  6072. j->pld_slicw.bits.rly2 = 0;
  6073. j->pld_slicw.bits.rly3 = 0;
  6074. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  6075. }
  6076. }
  6077. j->pld_slicw.bits.rly3 = 0;
  6078. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  6079. daa_set_mode(j, SOP_PU_CONVERSATION);
  6080. msleep(1000);
  6081. daa_int_read(j);
  6082. daa_set_mode(j, SOP_PU_RESET);
  6083. if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
  6084. j->pstn_sleeptil = jiffies + (hertz / 4);
  6085. j->flags.pstn_present = 1;
  6086. } else {
  6087. j->flags.pstn_present = 0;
  6088. }
  6089. if (j->flags.pstn_present) {
  6090. if (j->flags.pots_correct) {
  6091. LED_SetState(0xA, j);
  6092. } else {
  6093. LED_SetState(0x6, j);
  6094. }
  6095. } else {
  6096. if (j->flags.pots_correct) {
  6097. LED_SetState(0x9, j);
  6098. } else {
  6099. LED_SetState(0x5, j);
  6100. }
  6101. }
  6102. j->flags.pstncheck = 0; /* Testing */
  6103. return j->flags.pstn_present;
  6104. }
  6105. static int ixj_selfprobe(IXJ *j)
  6106. {
  6107. unsigned short cmd;
  6108. int cnt;
  6109. BYTES bytes;
  6110. init_waitqueue_head(&j->poll_q);
  6111. init_waitqueue_head(&j->read_q);
  6112. init_waitqueue_head(&j->write_q);
  6113. while(atomic_read(&j->DSPWrite) > 0)
  6114. atomic_dec(&j->DSPWrite);
  6115. if (ixjdebug & 0x0002)
  6116. printk(KERN_INFO "Write IDLE to Software Control Register\n");
  6117. ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
  6118. if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
  6119. return -1;
  6120. /* The read values of the SSR should be 0x00 for the IDLE command */
  6121. if (j->ssr.low || j->ssr.high)
  6122. return -1;
  6123. if (ixjdebug & 0x0002)
  6124. printk(KERN_INFO "Get Device ID Code\n");
  6125. if (ixj_WriteDSPCommand(0x3400, j)) /* Get Device ID Code */
  6126. return -1;
  6127. j->dsp.low = j->ssr.low;
  6128. j->dsp.high = j->ssr.high;
  6129. if (ixjdebug & 0x0002)
  6130. printk(KERN_INFO "Get Device Version Code\n");
  6131. if (ixj_WriteDSPCommand(0x3800, j)) /* Get Device Version Code */
  6132. return -1;
  6133. j->ver.low = j->ssr.low;
  6134. j->ver.high = j->ssr.high;
  6135. if (!j->cardtype) {
  6136. if (j->dsp.low == 0x21) {
  6137. bytes.high = bytes.low = inb_p(j->XILINXbase + 0x02);
  6138. outb_p(bytes.low ^ 0xFF, j->XILINXbase + 0x02);
  6139. /* Test for Internet LineJACK or Internet PhoneJACK Lite */
  6140. bytes.low = inb_p(j->XILINXbase + 0x02);
  6141. if (bytes.low == bytes.high) /* Register is read only on */
  6142. /* Internet PhoneJack Lite */
  6143. {
  6144. j->cardtype = QTI_PHONEJACK_LITE;
  6145. if (!request_region(j->XILINXbase, 4, "ixj control")) {
  6146. printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
  6147. return -1;
  6148. }
  6149. j->pld_slicw.pcib.e1 = 1;
  6150. outb_p(j->pld_slicw.byte, j->XILINXbase);
  6151. } else {
  6152. j->cardtype = QTI_LINEJACK;
  6153. if (!request_region(j->XILINXbase, 8, "ixj control")) {
  6154. printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
  6155. return -1;
  6156. }
  6157. }
  6158. } else if (j->dsp.low == 0x22) {
  6159. j->cardtype = QTI_PHONEJACK_PCI;
  6160. request_region(j->XILINXbase, 4, "ixj control");
  6161. j->pld_slicw.pcib.e1 = 1;
  6162. outb_p(j->pld_slicw.byte, j->XILINXbase);
  6163. } else
  6164. j->cardtype = QTI_PHONEJACK;
  6165. } else {
  6166. switch (j->cardtype) {
  6167. case QTI_PHONEJACK:
  6168. if (!j->dsp.low != 0x20) {
  6169. j->dsp.high = 0x80;
  6170. j->dsp.low = 0x20;
  6171. ixj_WriteDSPCommand(0x3800, j);
  6172. j->ver.low = j->ssr.low;
  6173. j->ver.high = j->ssr.high;
  6174. }
  6175. break;
  6176. case QTI_LINEJACK:
  6177. if (!request_region(j->XILINXbase, 8, "ixj control")) {
  6178. printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
  6179. return -1;
  6180. }
  6181. break;
  6182. case QTI_PHONEJACK_LITE:
  6183. case QTI_PHONEJACK_PCI:
  6184. if (!request_region(j->XILINXbase, 4, "ixj control")) {
  6185. printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
  6186. return -1;
  6187. }
  6188. j->pld_slicw.pcib.e1 = 1;
  6189. outb_p(j->pld_slicw.byte, j->XILINXbase);
  6190. break;
  6191. case QTI_PHONECARD:
  6192. break;
  6193. }
  6194. }
  6195. if (j->dsp.low == 0x20 || j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
  6196. if (ixjdebug & 0x0002)
  6197. printk(KERN_INFO "Write CODEC config to Software Control Register\n");
  6198. if (ixj_WriteDSPCommand(0xC462, j)) /* Write CODEC config to Software Control Register */
  6199. return -1;
  6200. if (ixjdebug & 0x0002)
  6201. printk(KERN_INFO "Write CODEC timing to Software Control Register\n");
  6202. if (j->cardtype == QTI_PHONEJACK) {
  6203. cmd = 0x9FF2;
  6204. } else {
  6205. cmd = 0x9FF5;
  6206. }
  6207. if (ixj_WriteDSPCommand(cmd, j)) /* Write CODEC timing to Software Control Register */
  6208. return -1;
  6209. } else {
  6210. if (set_base_frame(j, 30) != 30)
  6211. return -1;
  6212. if (ixjdebug & 0x0002)
  6213. printk(KERN_INFO "Write CODEC config to Software Control Register\n");
  6214. if (j->cardtype == QTI_PHONECARD) {
  6215. if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
  6216. return -1;
  6217. }
  6218. if (j->cardtype == QTI_LINEJACK) {
  6219. if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
  6220. return -1;
  6221. if (ixjdebug & 0x0002)
  6222. printk(KERN_INFO "Turn on the PLD Clock at 8Khz\n");
  6223. j->pld_clock.byte = 0;
  6224. outb_p(j->pld_clock.byte, j->XILINXbase + 0x04);
  6225. }
  6226. }
  6227. if (j->dsp.low == 0x20) {
  6228. if (ixjdebug & 0x0002)
  6229. printk(KERN_INFO "Configure GPIO pins\n");
  6230. j->gpio.bytes.high = 0x09;
  6231. /* bytes.low = 0xEF; 0xF7 */
  6232. j->gpio.bits.gpio1 = 1;
  6233. j->gpio.bits.gpio2 = 1;
  6234. j->gpio.bits.gpio3 = 0;
  6235. j->gpio.bits.gpio4 = 1;
  6236. j->gpio.bits.gpio5 = 1;
  6237. j->gpio.bits.gpio6 = 1;
  6238. j->gpio.bits.gpio7 = 1;
  6239. ixj_WriteDSPCommand(j->gpio.word, j); /* Set GPIO pin directions */
  6240. if (ixjdebug & 0x0002)
  6241. printk(KERN_INFO "Enable SLIC\n");
  6242. j->gpio.bytes.high = 0x0B;
  6243. j->gpio.bytes.low = 0x00;
  6244. j->gpio.bits.gpio1 = 0;
  6245. j->gpio.bits.gpio2 = 1;
  6246. j->gpio.bits.gpio5 = 0;
  6247. ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring stop signal */
  6248. j->port = PORT_POTS;
  6249. } else {
  6250. if (j->cardtype == QTI_LINEJACK) {
  6251. LED_SetState(0x1, j);
  6252. msleep(100);
  6253. LED_SetState(0x2, j);
  6254. msleep(100);
  6255. LED_SetState(0x4, j);
  6256. msleep(100);
  6257. LED_SetState(0x8, j);
  6258. msleep(100);
  6259. LED_SetState(0x0, j);
  6260. daa_get_version(j);
  6261. if (ixjdebug & 0x0002)
  6262. printk("Loading DAA Coefficients\n");
  6263. DAA_Coeff_US(j);
  6264. if (!ixj_daa_write(j)) {
  6265. printk("DAA write failed on board %d\n", j->board);
  6266. return -1;
  6267. }
  6268. if(!ixj_daa_cid_reset(j)) {
  6269. printk("DAA CID reset failed on board %d\n", j->board);
  6270. return -1;
  6271. }
  6272. j->flags.pots_correct = 0;
  6273. j->flags.pstn_present = 0;
  6274. ixj_linetest(j);
  6275. if (j->flags.pots_correct) {
  6276. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  6277. outb_p(j->pld_scrw.byte, j->XILINXbase);
  6278. j->pld_slicw.bits.rly1 = 1;
  6279. j->pld_slicw.bits.spken = 1;
  6280. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  6281. SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
  6282. /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
  6283. j->port = PORT_POTS;
  6284. }
  6285. ixj_set_port(j, PORT_PSTN);
  6286. ixj_set_pots(j, 1);
  6287. if (ixjdebug & 0x0002)
  6288. printk(KERN_INFO "Enable Mixer\n");
  6289. ixj_mixer(0x0000, j); /*Master Volume Left unmute 0db */
  6290. ixj_mixer(0x0100, j); /*Master Volume Right unmute 0db */
  6291. ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
  6292. ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
  6293. ixj_mixer(0x0480, j); /*FM Left mute */
  6294. ixj_mixer(0x0580, j); /*FM Right mute */
  6295. ixj_mixer(0x0680, j); /*CD Left mute */
  6296. ixj_mixer(0x0780, j); /*CD Right mute */
  6297. ixj_mixer(0x0880, j); /*Line Left mute */
  6298. ixj_mixer(0x0980, j); /*Line Right mute */
  6299. ixj_mixer(0x0A80, j); /*Aux left mute */
  6300. ixj_mixer(0x0B80, j); /*Aux right mute */
  6301. ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
  6302. ixj_mixer(0x0D80, j); /*Mono2 mute */
  6303. ixj_mixer(0x0E80, j); /*Mic mute */
  6304. ixj_mixer(0x0F00, j); /*Mono Out Volume unmute 0db */
  6305. ixj_mixer(0x1000, j); /*Voice Left and Right out only */
  6306. ixj_mixer(0x110C, j);
  6307. ixj_mixer(0x1200, j); /*Mono1 switch on mixer left */
  6308. ixj_mixer(0x1401, j);
  6309. ixj_mixer(0x1300, j); /*Mono1 switch on mixer right */
  6310. ixj_mixer(0x1501, j);
  6311. ixj_mixer(0x1700, j); /*Clock select */
  6312. ixj_mixer(0x1800, j); /*ADC input from mixer */
  6313. ixj_mixer(0x1901, j); /*Mic gain 30db */
  6314. if (ixjdebug & 0x0002)
  6315. printk(KERN_INFO "Setting Default US Ring Cadence Detection\n");
  6316. j->cadence_f[4].state = 0;
  6317. j->cadence_f[4].on1 = 0; /*Cadence Filter 4 is used for PSTN ring cadence */
  6318. j->cadence_f[4].off1 = 0;
  6319. j->cadence_f[4].on2 = 0;
  6320. j->cadence_f[4].off2 = 0;
  6321. j->cadence_f[4].on3 = 0;
  6322. j->cadence_f[4].off3 = 0; /* These should represent standard US ring pulse. */
  6323. j->pstn_last_rmr = jiffies;
  6324. } else {
  6325. if (j->cardtype == QTI_PHONECARD) {
  6326. ixj_WriteDSPCommand(0xCF07, j);
  6327. ixj_WriteDSPCommand(0x00B0, j);
  6328. ixj_set_port(j, PORT_SPEAKER);
  6329. } else {
  6330. ixj_set_port(j, PORT_POTS);
  6331. SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
  6332. /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
  6333. }
  6334. }
  6335. }
  6336. j->intercom = -1;
  6337. j->framesread = j->frameswritten = 0;
  6338. j->read_wait = j->write_wait = 0;
  6339. j->rxreadycheck = j->txreadycheck = 0;
  6340. /* initialise the DTMF prescale to a sensible value */
  6341. if (j->cardtype == QTI_LINEJACK) {
  6342. set_dtmf_prescale(j, 0x10);
  6343. } else {
  6344. set_dtmf_prescale(j, 0x40);
  6345. }
  6346. set_play_volume(j, 0x100);
  6347. set_rec_volume(j, 0x100);
  6348. if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
  6349. return -1;
  6350. /* The read values of the SSR should be 0x00 for the IDLE command */
  6351. if (j->ssr.low || j->ssr.high)
  6352. return -1;
  6353. if (ixjdebug & 0x0002)
  6354. printk(KERN_INFO "Enable Line Monitor\n");
  6355. if (ixjdebug & 0x0002)
  6356. printk(KERN_INFO "Set Line Monitor to Asyncronous Mode\n");
  6357. if (ixj_WriteDSPCommand(0x7E01, j)) /* Asynchronous Line Monitor */
  6358. return -1;
  6359. if (ixjdebug & 0x002)
  6360. printk(KERN_INFO "Enable DTMF Detectors\n");
  6361. if (ixj_WriteDSPCommand(0x5151, j)) /* Enable DTMF detection */
  6362. return -1;
  6363. if (ixj_WriteDSPCommand(0x6E01, j)) /* Set Asyncronous Tone Generation */
  6364. return -1;
  6365. set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
  6366. set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
  6367. j->ex.bits.dtmf_ready = 0;
  6368. j->dtmf_state = 0;
  6369. j->dtmf_wp = j->dtmf_rp = 0;
  6370. j->rec_mode = j->play_mode = -1;
  6371. j->flags.ringing = 0;
  6372. j->maxrings = MAXRINGS;
  6373. j->ring_cadence = USA_RING_CADENCE;
  6374. j->drybuffer = 0;
  6375. j->winktime = 320;
  6376. j->flags.dtmf_oob = 0;
  6377. for (cnt = 0; cnt < 4; cnt++)
  6378. j->cadence_f[cnt].enable = 0;
  6379. /* must be a device on the specified address */
  6380. ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
  6381. /* Set up the default signals for events */
  6382. for (cnt = 0; cnt < 35; cnt++)
  6383. j->ixj_signals[cnt] = SIGIO;
  6384. /* Set the excetion signal enable flags */
  6385. j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
  6386. j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
  6387. j->ex_sig.bits.f3 = j->ex_sig.bits.fc0 = j->ex_sig.bits.fc1 = j->ex_sig.bits.fc2 = j->ex_sig.bits.fc3 = 1;
  6388. #ifdef IXJ_DYN_ALLOC
  6389. j->fskdata = NULL;
  6390. #endif
  6391. j->fskdcnt = 0;
  6392. j->cidcw_wait = 0;
  6393. /* Register with the Telephony for Linux subsystem */
  6394. j->p.f_op = &ixj_fops;
  6395. j->p.open = ixj_open;
  6396. j->p.board = j->board;
  6397. phone_register_device(&j->p, PHONE_UNIT_ANY);
  6398. ixj_init_timer(j);
  6399. ixj_add_timer(j);
  6400. return 0;
  6401. }
  6402. /*
  6403. * Exported service for pcmcia card handling
  6404. */
  6405. IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx)
  6406. {
  6407. IXJ *j = ixj_alloc();
  6408. j->board = 0;
  6409. j->DSPbase = dsp;
  6410. j->XILINXbase = xilinx;
  6411. j->cardtype = QTI_PHONECARD;
  6412. ixj_selfprobe(j);
  6413. return j;
  6414. }
  6415. EXPORT_SYMBOL(ixj_pcmcia_probe); /* Fpr PCMCIA */
  6416. static int ixj_get_status_proc(char *buf)
  6417. {
  6418. int len;
  6419. int cnt;
  6420. IXJ *j;
  6421. len = 0;
  6422. len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER);
  6423. len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ));
  6424. len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS));
  6425. len += sprintf(buf + len, "\nUsing old telephony API");
  6426. len += sprintf(buf + len, "\nDebug Level %d\n", ixjdebug);
  6427. for (cnt = 0; cnt < IXJMAX; cnt++) {
  6428. j = get_ixj(cnt);
  6429. if(j==NULL)
  6430. continue;
  6431. if (j->DSPbase) {
  6432. len += sprintf(buf + len, "\nCard Num %d", cnt);
  6433. len += sprintf(buf + len, "\nDSP Base Address 0x%4.4x", j->DSPbase);
  6434. if (j->cardtype != QTI_PHONEJACK)
  6435. len += sprintf(buf + len, "\nXILINX Base Address 0x%4.4x", j->XILINXbase);
  6436. len += sprintf(buf + len, "\nDSP Type %2.2x%2.2x", j->dsp.high, j->dsp.low);
  6437. len += sprintf(buf + len, "\nDSP Version %2.2x.%2.2x", j->ver.high, j->ver.low);
  6438. len += sprintf(buf + len, "\nSerial Number %8.8x", j->serial);
  6439. switch (j->cardtype) {
  6440. case (QTI_PHONEJACK):
  6441. len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK");
  6442. break;
  6443. case (QTI_LINEJACK):
  6444. len += sprintf(buf + len, "\nCard Type = Internet LineJACK");
  6445. if (j->flags.g729_loaded)
  6446. len += sprintf(buf + len, " w/G.729 A/B");
  6447. len += sprintf(buf + len, " Country = %d", j->daa_country);
  6448. break;
  6449. case (QTI_PHONEJACK_LITE):
  6450. len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK Lite");
  6451. if (j->flags.g729_loaded)
  6452. len += sprintf(buf + len, " w/G.729 A/B");
  6453. break;
  6454. case (QTI_PHONEJACK_PCI):
  6455. len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK PCI");
  6456. if (j->flags.g729_loaded)
  6457. len += sprintf(buf + len, " w/G.729 A/B");
  6458. break;
  6459. case (QTI_PHONECARD):
  6460. len += sprintf(buf + len, "\nCard Type = Internet PhoneCARD");
  6461. if (j->flags.g729_loaded)
  6462. len += sprintf(buf + len, " w/G.729 A/B");
  6463. len += sprintf(buf + len, "\nSmart Cable %spresent", j->pccr1.bits.drf ? "not " : "");
  6464. if (!j->pccr1.bits.drf)
  6465. len += sprintf(buf + len, "\nSmart Cable type %d", j->flags.pcmciasct);
  6466. len += sprintf(buf + len, "\nSmart Cable state %d", j->flags.pcmciastate);
  6467. break;
  6468. default:
  6469. len += sprintf(buf + len, "\nCard Type = %d", j->cardtype);
  6470. break;
  6471. }
  6472. len += sprintf(buf + len, "\nReaders %d", j->readers);
  6473. len += sprintf(buf + len, "\nWriters %d", j->writers);
  6474. add_caps(j);
  6475. len += sprintf(buf + len, "\nCapabilities %d", j->caps);
  6476. if (j->dsp.low != 0x20)
  6477. len += sprintf(buf + len, "\nDSP Processor load %d", j->proc_load);
  6478. if (j->flags.cidsent)
  6479. len += sprintf(buf + len, "\nCaller ID data sent");
  6480. else
  6481. len += sprintf(buf + len, "\nCaller ID data not sent");
  6482. len += sprintf(buf + len, "\nPlay CODEC ");
  6483. switch (j->play_codec) {
  6484. case G723_63:
  6485. len += sprintf(buf + len, "G.723.1 6.3");
  6486. break;
  6487. case G723_53:
  6488. len += sprintf(buf + len, "G.723.1 5.3");
  6489. break;
  6490. case TS85:
  6491. len += sprintf(buf + len, "TrueSpeech 8.5");
  6492. break;
  6493. case TS48:
  6494. len += sprintf(buf + len, "TrueSpeech 4.8");
  6495. break;
  6496. case TS41:
  6497. len += sprintf(buf + len, "TrueSpeech 4.1");
  6498. break;
  6499. case G728:
  6500. len += sprintf(buf + len, "G.728");
  6501. break;
  6502. case G729:
  6503. len += sprintf(buf + len, "G.729");
  6504. break;
  6505. case G729B:
  6506. len += sprintf(buf + len, "G.729B");
  6507. break;
  6508. case ULAW:
  6509. len += sprintf(buf + len, "uLaw");
  6510. break;
  6511. case ALAW:
  6512. len += sprintf(buf + len, "aLaw");
  6513. break;
  6514. case LINEAR16:
  6515. len += sprintf(buf + len, "16 bit Linear");
  6516. break;
  6517. case LINEAR8:
  6518. len += sprintf(buf + len, "8 bit Linear");
  6519. break;
  6520. case WSS:
  6521. len += sprintf(buf + len, "Windows Sound System");
  6522. break;
  6523. default:
  6524. len += sprintf(buf + len, "NO CODEC CHOSEN");
  6525. break;
  6526. }
  6527. len += sprintf(buf + len, "\nRecord CODEC ");
  6528. switch (j->rec_codec) {
  6529. case G723_63:
  6530. len += sprintf(buf + len, "G.723.1 6.3");
  6531. break;
  6532. case G723_53:
  6533. len += sprintf(buf + len, "G.723.1 5.3");
  6534. break;
  6535. case TS85:
  6536. len += sprintf(buf + len, "TrueSpeech 8.5");
  6537. break;
  6538. case TS48:
  6539. len += sprintf(buf + len, "TrueSpeech 4.8");
  6540. break;
  6541. case TS41:
  6542. len += sprintf(buf + len, "TrueSpeech 4.1");
  6543. break;
  6544. case G728:
  6545. len += sprintf(buf + len, "G.728");
  6546. break;
  6547. case G729:
  6548. len += sprintf(buf + len, "G.729");
  6549. break;
  6550. case G729B:
  6551. len += sprintf(buf + len, "G.729B");
  6552. break;
  6553. case ULAW:
  6554. len += sprintf(buf + len, "uLaw");
  6555. break;
  6556. case ALAW:
  6557. len += sprintf(buf + len, "aLaw");
  6558. break;
  6559. case LINEAR16:
  6560. len += sprintf(buf + len, "16 bit Linear");
  6561. break;
  6562. case LINEAR8:
  6563. len += sprintf(buf + len, "8 bit Linear");
  6564. break;
  6565. case WSS:
  6566. len += sprintf(buf + len, "Windows Sound System");
  6567. break;
  6568. default:
  6569. len += sprintf(buf + len, "NO CODEC CHOSEN");
  6570. break;
  6571. }
  6572. len += sprintf(buf + len, "\nAEC ");
  6573. switch (j->aec_level) {
  6574. case AEC_OFF:
  6575. len += sprintf(buf + len, "Off");
  6576. break;
  6577. case AEC_LOW:
  6578. len += sprintf(buf + len, "Low");
  6579. break;
  6580. case AEC_MED:
  6581. len += sprintf(buf + len, "Med");
  6582. break;
  6583. case AEC_HIGH:
  6584. len += sprintf(buf + len, "High");
  6585. break;
  6586. case AEC_AUTO:
  6587. len += sprintf(buf + len, "Auto");
  6588. break;
  6589. case AEC_AGC:
  6590. len += sprintf(buf + len, "AEC/AGC");
  6591. break;
  6592. default:
  6593. len += sprintf(buf + len, "unknown(%i)", j->aec_level);
  6594. break;
  6595. }
  6596. len += sprintf(buf + len, "\nRec volume 0x%x", get_rec_volume(j));
  6597. len += sprintf(buf + len, "\nPlay volume 0x%x", get_play_volume(j));
  6598. len += sprintf(buf + len, "\nDTMF prescale 0x%x", get_dtmf_prescale(j));
  6599. len += sprintf(buf + len, "\nHook state %d", j->hookstate); /* j->r_hook); */
  6600. if (j->cardtype == QTI_LINEJACK) {
  6601. len += sprintf(buf + len, "\nPOTS Correct %d", j->flags.pots_correct);
  6602. len += sprintf(buf + len, "\nPSTN Present %d", j->flags.pstn_present);
  6603. len += sprintf(buf + len, "\nPSTN Check %d", j->flags.pstncheck);
  6604. len += sprintf(buf + len, "\nPOTS to PSTN %d", j->flags.pots_pstn);
  6605. switch (j->daa_mode) {
  6606. case SOP_PU_SLEEP:
  6607. len += sprintf(buf + len, "\nDAA PSTN On Hook");
  6608. break;
  6609. case SOP_PU_RINGING:
  6610. len += sprintf(buf + len, "\nDAA PSTN Ringing");
  6611. len += sprintf(buf + len, "\nRinging state = %d", j->cadence_f[4].state);
  6612. break;
  6613. case SOP_PU_CONVERSATION:
  6614. len += sprintf(buf + len, "\nDAA PSTN Off Hook");
  6615. break;
  6616. case SOP_PU_PULSEDIALING:
  6617. len += sprintf(buf + len, "\nDAA PSTN Pulse Dialing");
  6618. break;
  6619. }
  6620. len += sprintf(buf + len, "\nDAA RMR = %d", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR);
  6621. len += sprintf(buf + len, "\nDAA VDD OK = %d", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK);
  6622. len += sprintf(buf + len, "\nDAA CR0 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg);
  6623. len += sprintf(buf + len, "\nDAA CR1 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg);
  6624. len += sprintf(buf + len, "\nDAA CR2 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg);
  6625. len += sprintf(buf + len, "\nDAA CR3 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg);
  6626. len += sprintf(buf + len, "\nDAA CR4 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg);
  6627. len += sprintf(buf + len, "\nDAA CR5 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg);
  6628. len += sprintf(buf + len, "\nDAA XR0 = 0x%02x", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg);
  6629. len += sprintf(buf + len, "\nDAA ringstop %ld - jiffies %ld", j->pstn_ring_stop, jiffies);
  6630. }
  6631. switch (j->port) {
  6632. case PORT_POTS:
  6633. len += sprintf(buf + len, "\nPort POTS");
  6634. break;
  6635. case PORT_PSTN:
  6636. len += sprintf(buf + len, "\nPort PSTN");
  6637. break;
  6638. case PORT_SPEAKER:
  6639. len += sprintf(buf + len, "\nPort SPEAKER/MIC");
  6640. break;
  6641. case PORT_HANDSET:
  6642. len += sprintf(buf + len, "\nPort HANDSET");
  6643. break;
  6644. }
  6645. if (j->dsp.low == 0x21 || j->dsp.low == 0x22) {
  6646. len += sprintf(buf + len, "\nSLIC state ");
  6647. switch (SLIC_GetState(j)) {
  6648. case PLD_SLIC_STATE_OC:
  6649. len += sprintf(buf + len, "OC");
  6650. break;
  6651. case PLD_SLIC_STATE_RINGING:
  6652. len += sprintf(buf + len, "RINGING");
  6653. break;
  6654. case PLD_SLIC_STATE_ACTIVE:
  6655. len += sprintf(buf + len, "ACTIVE");
  6656. break;
  6657. case PLD_SLIC_STATE_OHT: /* On-hook transmit */
  6658. len += sprintf(buf + len, "OHT");
  6659. break;
  6660. case PLD_SLIC_STATE_TIPOPEN:
  6661. len += sprintf(buf + len, "TIPOPEN");
  6662. break;
  6663. case PLD_SLIC_STATE_STANDBY:
  6664. len += sprintf(buf + len, "STANDBY");
  6665. break;
  6666. case PLD_SLIC_STATE_APR: /* Active polarity reversal */
  6667. len += sprintf(buf + len, "APR");
  6668. break;
  6669. case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
  6670. len += sprintf(buf + len, "OHTPR");
  6671. break;
  6672. default:
  6673. len += sprintf(buf + len, "%d", SLIC_GetState(j));
  6674. break;
  6675. }
  6676. }
  6677. len += sprintf(buf + len, "\nBase Frame %2.2x.%2.2x", j->baseframe.high, j->baseframe.low);
  6678. len += sprintf(buf + len, "\nCID Base Frame %2d", j->cid_base_frame_size);
  6679. #ifdef PERFMON_STATS
  6680. len += sprintf(buf + len, "\nTimer Checks %ld", j->timerchecks);
  6681. len += sprintf(buf + len, "\nRX Ready Checks %ld", j->rxreadycheck);
  6682. len += sprintf(buf + len, "\nTX Ready Checks %ld", j->txreadycheck);
  6683. len += sprintf(buf + len, "\nFrames Read %ld", j->framesread);
  6684. len += sprintf(buf + len, "\nFrames Written %ld", j->frameswritten);
  6685. len += sprintf(buf + len, "\nDry Buffer %ld", j->drybuffer);
  6686. len += sprintf(buf + len, "\nRead Waits %ld", j->read_wait);
  6687. len += sprintf(buf + len, "\nWrite Waits %ld", j->write_wait);
  6688. len += sprintf(buf + len, "\nStatus Waits %ld", j->statuswait);
  6689. len += sprintf(buf + len, "\nStatus Wait Fails %ld", j->statuswaitfail);
  6690. len += sprintf(buf + len, "\nPControl Waits %ld", j->pcontrolwait);
  6691. len += sprintf(buf + len, "\nPControl Wait Fails %ld", j->pcontrolwaitfail);
  6692. len += sprintf(buf + len, "\nIs Control Ready Checks %ld", j->iscontrolready);
  6693. len += sprintf(buf + len, "\nIs Control Ready Check failures %ld", j->iscontrolreadyfail);
  6694. #endif
  6695. len += sprintf(buf + len, "\n");
  6696. }
  6697. }
  6698. return len;
  6699. }
  6700. static int ixj_read_proc(char *page, char **start, off_t off,
  6701. int count, int *eof, void *data)
  6702. {
  6703. int len = ixj_get_status_proc(page);
  6704. if (len <= off+count) *eof = 1;
  6705. *start = page + off;
  6706. len -= off;
  6707. if (len>count) len = count;
  6708. if (len<0) len = 0;
  6709. return len;
  6710. }
  6711. static void cleanup(void)
  6712. {
  6713. int cnt;
  6714. IXJ *j;
  6715. for (cnt = 0; cnt < IXJMAX; cnt++) {
  6716. j = get_ixj(cnt);
  6717. if(j != NULL && j->DSPbase) {
  6718. if (ixjdebug & 0x0002)
  6719. printk(KERN_INFO "IXJ: Deleting timer for /dev/phone%d\n", cnt);
  6720. del_timer(&j->timer);
  6721. if (j->cardtype == QTI_LINEJACK) {
  6722. j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
  6723. outb_p(j->pld_scrw.byte, j->XILINXbase);
  6724. j->pld_slicw.bits.rly1 = 0;
  6725. j->pld_slicw.bits.rly2 = 0;
  6726. j->pld_slicw.bits.rly3 = 0;
  6727. outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
  6728. LED_SetState(0x0, j);
  6729. if (ixjdebug & 0x0002)
  6730. printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
  6731. release_region(j->XILINXbase, 8);
  6732. } else if (j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
  6733. if (ixjdebug & 0x0002)
  6734. printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
  6735. release_region(j->XILINXbase, 4);
  6736. }
  6737. kfree(j->read_buffer);
  6738. kfree(j->write_buffer);
  6739. if (j->dev)
  6740. pnp_device_detach(j->dev);
  6741. if (ixjdebug & 0x0002)
  6742. printk(KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt);
  6743. phone_unregister_device(&j->p);
  6744. if (ixjdebug & 0x0002)
  6745. printk(KERN_INFO "IXJ: Releasing DSP address for /dev/phone%d\n", cnt);
  6746. release_region(j->DSPbase, 16);
  6747. #ifdef IXJ_DYN_ALLOC
  6748. if (ixjdebug & 0x0002)
  6749. printk(KERN_INFO "IXJ: Freeing memory for /dev/phone%d\n", cnt);
  6750. kfree(j);
  6751. ixj[cnt] = NULL;
  6752. #endif
  6753. }
  6754. }
  6755. if (ixjdebug & 0x0002)
  6756. printk(KERN_INFO "IXJ: Removing /proc/ixj\n");
  6757. remove_proc_entry ("ixj", NULL);
  6758. }
  6759. /* Typedefs */
  6760. typedef struct {
  6761. BYTE length;
  6762. DWORD bits;
  6763. } DATABLOCK;
  6764. static void PCIEE_WriteBit(WORD wEEPROMAddress, BYTE lastLCC, BYTE byData)
  6765. {
  6766. lastLCC = lastLCC & 0xfb;
  6767. lastLCC = lastLCC | (byData ? 4 : 0);
  6768. outb(lastLCC, wEEPROMAddress); /*set data out bit as appropriate */
  6769. mdelay(1);
  6770. lastLCC = lastLCC | 0x01;
  6771. outb(lastLCC, wEEPROMAddress); /*SK rising edge */
  6772. byData = byData << 1;
  6773. lastLCC = lastLCC & 0xfe;
  6774. mdelay(1);
  6775. outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
  6776. }
  6777. static BYTE PCIEE_ReadBit(WORD wEEPROMAddress, BYTE lastLCC)
  6778. {
  6779. mdelay(1);
  6780. lastLCC = lastLCC | 0x01;
  6781. outb(lastLCC, wEEPROMAddress); /*SK rising edge */
  6782. lastLCC = lastLCC & 0xfe;
  6783. mdelay(1);
  6784. outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
  6785. return ((inb(wEEPROMAddress) >> 3) & 1);
  6786. }
  6787. static bool PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult)
  6788. {
  6789. BYTE lastLCC;
  6790. WORD wEEPROMAddress = wAddress + 3;
  6791. DWORD i;
  6792. BYTE byResult;
  6793. *pwResult = 0;
  6794. lastLCC = inb(wEEPROMAddress);
  6795. lastLCC = lastLCC | 0x02;
  6796. lastLCC = lastLCC & 0xfe;
  6797. outb(lastLCC, wEEPROMAddress); /* CS hi, SK lo */
  6798. mdelay(1); /* delay */
  6799. PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
  6800. PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
  6801. PCIEE_WriteBit(wEEPROMAddress, lastLCC, 0);
  6802. for (i = 0; i < 8; i++) {
  6803. PCIEE_WriteBit(wEEPROMAddress, lastLCC, wLoc & 0x80 ? 1 : 0);
  6804. wLoc <<= 1;
  6805. }
  6806. for (i = 0; i < 16; i++) {
  6807. byResult = PCIEE_ReadBit(wEEPROMAddress, lastLCC);
  6808. *pwResult = (*pwResult << 1) | byResult;
  6809. }
  6810. mdelay(1); /* another delay */
  6811. lastLCC = lastLCC & 0xfd;
  6812. outb(lastLCC, wEEPROMAddress); /* negate CS */
  6813. return 0;
  6814. }
  6815. static DWORD PCIEE_GetSerialNumber(WORD wAddress)
  6816. {
  6817. WORD wLo, wHi;
  6818. if (PCIEE_ReadWord(wAddress, 62, &wLo))
  6819. return 0;
  6820. if (PCIEE_ReadWord(wAddress, 63, &wHi))
  6821. return 0;
  6822. return (((DWORD) wHi << 16) | wLo);
  6823. }
  6824. static int dspio[IXJMAX + 1] =
  6825. {
  6826. 0,
  6827. };
  6828. static int xio[IXJMAX + 1] =
  6829. {
  6830. 0,
  6831. };
  6832. module_param_array(dspio, int, NULL, 0);
  6833. module_param_array(xio, int, NULL, 0);
  6834. MODULE_DESCRIPTION("Quicknet VoIP Telephony card module - www.quicknet.net");
  6835. MODULE_AUTHOR("Ed Okerson <eokerson@quicknet.net>");
  6836. MODULE_LICENSE("GPL");
  6837. static void __exit ixj_exit(void)
  6838. {
  6839. cleanup();
  6840. }
  6841. static IXJ *new_ixj(unsigned long port)
  6842. {
  6843. IXJ *res;
  6844. if (!request_region(port, 16, "ixj DSP")) {
  6845. printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", port);
  6846. return NULL;
  6847. }
  6848. res = ixj_alloc();
  6849. if (!res) {
  6850. release_region(port, 16);
  6851. printk(KERN_INFO "ixj: out of memory\n");
  6852. return NULL;
  6853. }
  6854. res->DSPbase = port;
  6855. return res;
  6856. }
  6857. static int __init ixj_probe_isapnp(int *cnt)
  6858. {
  6859. int probe = 0;
  6860. int func = 0x110;
  6861. struct pnp_dev *dev = NULL, *old_dev = NULL;
  6862. while (1) {
  6863. do {
  6864. IXJ *j;
  6865. int result;
  6866. old_dev = dev;
  6867. dev = pnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'),
  6868. ISAPNP_FUNCTION(func), old_dev);
  6869. if (!dev || !dev->card)
  6870. break;
  6871. result = pnp_device_attach(dev);
  6872. if (result < 0) {
  6873. printk("pnp attach failed %d \n", result);
  6874. break;
  6875. }
  6876. if (pnp_activate_dev(dev) < 0) {
  6877. printk("pnp activate failed (out of resources?)\n");
  6878. pnp_device_detach(dev);
  6879. return -ENOMEM;
  6880. }
  6881. if (!pnp_port_valid(dev, 0)) {
  6882. pnp_device_detach(dev);
  6883. return -ENODEV;
  6884. }
  6885. j = new_ixj(pnp_port_start(dev, 0));
  6886. if (!j)
  6887. break;
  6888. if (func != 0x110)
  6889. j->XILINXbase = pnp_port_start(dev, 1); /* get real port */
  6890. switch (func) {
  6891. case (0x110):
  6892. j->cardtype = QTI_PHONEJACK;
  6893. break;
  6894. case (0x310):
  6895. j->cardtype = QTI_LINEJACK;
  6896. break;
  6897. case (0x410):
  6898. j->cardtype = QTI_PHONEJACK_LITE;
  6899. break;
  6900. }
  6901. j->board = *cnt;
  6902. probe = ixj_selfprobe(j);
  6903. if(!probe) {
  6904. j->serial = dev->card->serial;
  6905. j->dev = dev;
  6906. switch (func) {
  6907. case 0x110:
  6908. printk(KERN_INFO "ixj: found Internet PhoneJACK at 0x%x\n", j->DSPbase);
  6909. break;
  6910. case 0x310:
  6911. printk(KERN_INFO "ixj: found Internet LineJACK at 0x%x\n", j->DSPbase);
  6912. break;
  6913. case 0x410:
  6914. printk(KERN_INFO "ixj: found Internet PhoneJACK Lite at 0x%x\n", j->DSPbase);
  6915. break;
  6916. }
  6917. }
  6918. ++*cnt;
  6919. } while (dev);
  6920. if (func == 0x410)
  6921. break;
  6922. if (func == 0x310)
  6923. func = 0x410;
  6924. if (func == 0x110)
  6925. func = 0x310;
  6926. dev = NULL;
  6927. }
  6928. return probe;
  6929. }
  6930. static int __init ixj_probe_isa(int *cnt)
  6931. {
  6932. int i, probe;
  6933. /* Use passed parameters for older kernels without PnP */
  6934. for (i = 0; i < IXJMAX; i++) {
  6935. if (dspio[i]) {
  6936. IXJ *j = new_ixj(dspio[i]);
  6937. if (!j)
  6938. break;
  6939. j->XILINXbase = xio[i];
  6940. j->cardtype = 0;
  6941. j->board = *cnt;
  6942. probe = ixj_selfprobe(j);
  6943. j->dev = NULL;
  6944. ++*cnt;
  6945. }
  6946. }
  6947. return 0;
  6948. }
  6949. static int __init ixj_probe_pci(int *cnt)
  6950. {
  6951. struct pci_dev *pci = NULL;
  6952. int i, probe = 0;
  6953. IXJ *j = NULL;
  6954. for (i = 0; i < IXJMAX - *cnt; i++) {
  6955. pci = pci_get_device(PCI_VENDOR_ID_QUICKNET,
  6956. PCI_DEVICE_ID_QUICKNET_XJ, pci);
  6957. if (!pci)
  6958. break;
  6959. if (pci_enable_device(pci))
  6960. break;
  6961. j = new_ixj(pci_resource_start(pci, 0));
  6962. if (!j)
  6963. break;
  6964. j->serial = (PCIEE_GetSerialNumber)pci_resource_start(pci, 2);
  6965. j->XILINXbase = j->DSPbase + 0x10;
  6966. j->cardtype = QTI_PHONEJACK_PCI;
  6967. j->board = *cnt;
  6968. probe = ixj_selfprobe(j);
  6969. if (!probe)
  6970. printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase);
  6971. ++*cnt;
  6972. }
  6973. pci_dev_put(pci);
  6974. return probe;
  6975. }
  6976. static int __init ixj_init(void)
  6977. {
  6978. int cnt = 0;
  6979. int probe = 0;
  6980. cnt = 0;
  6981. /* These might be no-ops, see above. */
  6982. if ((probe = ixj_probe_isapnp(&cnt)) < 0) {
  6983. return probe;
  6984. }
  6985. if ((probe = ixj_probe_isa(&cnt)) < 0) {
  6986. return probe;
  6987. }
  6988. if ((probe = ixj_probe_pci(&cnt)) < 0) {
  6989. return probe;
  6990. }
  6991. printk(KERN_INFO "ixj driver initialized.\n");
  6992. create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL);
  6993. return probe;
  6994. }
  6995. module_init(ixj_init);
  6996. module_exit(ixj_exit);
  6997. static void DAA_Coeff_US(IXJ *j)
  6998. {
  6999. int i;
  7000. j->daa_country = DAA_US;
  7001. /*----------------------------------------------- */
  7002. /* CAO */
  7003. for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
  7004. j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
  7005. }
  7006. /* Bytes for IM-filter part 1 (04): 0E,32,E2,2F,C2,5A,C0,00 */
  7007. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x03;
  7008. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0x4B;
  7009. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x5D;
  7010. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xCD;
  7011. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x24;
  7012. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xC5;
  7013. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
  7014. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
  7015. /* Bytes for IM-filter part 2 (05): 72,85,00,0E,2B,3A,D0,08 */
  7016. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x71;
  7017. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x1A;
  7018. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
  7019. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
  7020. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xB5;
  7021. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
  7022. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
  7023. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
  7024. /* Bytes for FRX-filter (08): 03,8F,48,F2,8F,48,70,08 */
  7025. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x05;
  7026. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xA3;
  7027. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x72;
  7028. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
  7029. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x3F;
  7030. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x3B;
  7031. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
  7032. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
  7033. /* Bytes for FRR-filter (07): 04,8F,38,7F,9B,EA,B0,08 */
  7034. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x05;
  7035. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
  7036. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
  7037. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x3E;
  7038. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x32;
  7039. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xDA;
  7040. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
  7041. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
  7042. /* Bytes for AX-filter (0A): 16,55,DD,CA */
  7043. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x41;
  7044. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
  7045. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
  7046. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
  7047. /* Bytes for AR-filter (09): 52,D3,11,42 */
  7048. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
  7049. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
  7050. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
  7051. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
  7052. /* Bytes for TH-filter part 1 (00): 00,42,48,81,B3,80,00,98 */
  7053. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
  7054. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
  7055. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
  7056. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
  7057. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA5;
  7058. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
  7059. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
  7060. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
  7061. /* Bytes for TH-filter part 2 (01): 02,F2,33,A0,68,AB,8A,AD */
  7062. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
  7063. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xA2;
  7064. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2B;
  7065. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
  7066. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
  7067. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAB;
  7068. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
  7069. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xCC;
  7070. /* Bytes for TH-filter part 3 (02): 00,88,DA,54,A4,BA,2D,BB */
  7071. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
  7072. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
  7073. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xD2;
  7074. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x24;
  7075. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBA;
  7076. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xA9;
  7077. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x3B;
  7078. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xA6;
  7079. /* ; (10K, 0.68uF) */
  7080. /* */
  7081. /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
  7082. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
  7083. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
  7084. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
  7085. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
  7086. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
  7087. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
  7088. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
  7089. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
  7090. /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
  7091. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
  7092. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
  7093. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
  7094. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
  7095. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
  7096. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
  7097. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
  7098. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
  7099. /* Levelmetering Ringing (0D):B2,45,0F,8E */
  7100. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
  7101. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
  7102. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
  7103. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
  7104. /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
  7105. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1C; */
  7106. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0xB3; */
  7107. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0xAB; */
  7108. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xAB; */
  7109. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x54; */
  7110. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x2D; */
  7111. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0x62; */
  7112. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x2D; */
  7113. /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
  7114. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x2D; */
  7115. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x62; */
  7116. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; */
  7117. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBB; */
  7118. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x2A; */
  7119. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7D; */
  7120. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; */
  7121. /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD4; */
  7122. /* */
  7123. /* Levelmetering Ringing (0D):B2,45,0F,8E */
  7124. /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; */
  7125. /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x05; */
  7126. /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; */
  7127. /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; */
  7128. /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
  7129. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
  7130. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
  7131. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
  7132. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
  7133. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
  7134. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
  7135. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
  7136. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
  7137. /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
  7138. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
  7139. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
  7140. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
  7141. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
  7142. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
  7143. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
  7144. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
  7145. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
  7146. /* */
  7147. /* ;CR Registers */
  7148. /* Config. Reg. 0 (filters) (cr0):FE ; CLK gen. by crystal */
  7149. j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
  7150. /* Config. Reg. 1 (dialing) (cr1):05 */
  7151. j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
  7152. /* Config. Reg. 2 (caller ID) (cr2):04 */
  7153. j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
  7154. /* Config. Reg. 3 (testloops) (cr3):03 ; SEL Bit==0, HP-disabled */
  7155. j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
  7156. /* Config. Reg. 4 (analog gain) (cr4):02 */
  7157. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
  7158. /* Config. Reg. 5 (Version) (cr5):02 */
  7159. /* Config. Reg. 6 (Reserved) (cr6):00 */
  7160. /* Config. Reg. 7 (Reserved) (cr7):00 */
  7161. /* */
  7162. /* ;xr Registers */
  7163. /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
  7164. j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
  7165. /* Ext. Reg. 1 (Interrupt enable) (xr1):3C Cadence, RING, Caller ID, VDD_OK */
  7166. j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x3C;
  7167. /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
  7168. j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
  7169. /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off == 1 */
  7170. j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x3B; /*0x32; */
  7171. /* Ext. Reg. 4 (Cadence) (xr4):00 */
  7172. j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
  7173. /* Ext. Reg. 5 (Ring timer) (xr5):22 */
  7174. j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
  7175. /* Ext. Reg. 6 (Power State) (xr6):00 */
  7176. j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
  7177. /* Ext. Reg. 7 (Vdd) (xr7):40 */
  7178. j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
  7179. /* */
  7180. /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
  7181. /* 12,33,5A,C3 ; 770 Hz */
  7182. /* 13,3C,5B,32 ; 852 Hz */
  7183. /* 1D,1B,5C,CC ; 941 Hz */
  7184. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
  7185. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
  7186. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
  7187. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
  7188. /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
  7189. /* EC,1D,52,22 ; 1336 Hz */
  7190. /* AA,AC,51,D2 ; 1477 Hz */
  7191. /* 9B,3B,51,25 ; 1633 Hz */
  7192. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
  7193. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
  7194. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
  7195. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
  7196. }
  7197. static void DAA_Coeff_UK(IXJ *j)
  7198. {
  7199. int i;
  7200. j->daa_country = DAA_UK;
  7201. /*----------------------------------------------- */
  7202. /* CAO */
  7203. for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
  7204. j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
  7205. }
  7206. /* Bytes for IM-filter part 1 (04): 00,C2,BB,A8,CB,81,A0,00 */
  7207. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
  7208. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xC2;
  7209. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
  7210. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xA8;
  7211. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xCB;
  7212. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
  7213. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
  7214. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
  7215. /* Bytes for IM-filter part 2 (05): 40,00,00,0A,A4,33,E0,08 */
  7216. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x40;
  7217. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x00;
  7218. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
  7219. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
  7220. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xA4;
  7221. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
  7222. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
  7223. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
  7224. /* Bytes for FRX-filter (08): 07,9B,ED,24,B2,A2,A0,08 */
  7225. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
  7226. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9B;
  7227. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xED;
  7228. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x24;
  7229. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0xB2;
  7230. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0xA2;
  7231. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xA0;
  7232. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
  7233. /* Bytes for FRR-filter (07): 0F,92,F2,B2,87,D2,30,08 */
  7234. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
  7235. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x92;
  7236. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF2;
  7237. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0xB2;
  7238. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
  7239. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xD2;
  7240. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x30;
  7241. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
  7242. /* Bytes for AX-filter (0A): 1B,A5,DD,CA */
  7243. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x1B;
  7244. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xA5;
  7245. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
  7246. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
  7247. /* Bytes for AR-filter (09): E2,27,10,D6 */
  7248. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
  7249. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x27;
  7250. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
  7251. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
  7252. /* Bytes for TH-filter part 1 (00): 80,2D,38,8B,D0,00,00,98 */
  7253. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
  7254. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x2D;
  7255. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x38;
  7256. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x8B;
  7257. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xD0;
  7258. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x00;
  7259. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
  7260. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
  7261. /* Bytes for TH-filter part 2 (01): 02,5A,53,F0,0B,5F,84,D4 */
  7262. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
  7263. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x5A;
  7264. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x53;
  7265. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xF0;
  7266. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x0B;
  7267. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5F;
  7268. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x84;
  7269. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xD4;
  7270. /* Bytes for TH-filter part 3 (02): 00,88,6A,A4,8F,52,F5,32 */
  7271. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
  7272. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
  7273. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x6A;
  7274. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA4;
  7275. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x8F;
  7276. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x52;
  7277. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xF5;
  7278. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x32;
  7279. /* ; idle */
  7280. /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
  7281. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
  7282. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
  7283. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
  7284. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
  7285. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
  7286. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
  7287. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
  7288. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
  7289. /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
  7290. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
  7291. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
  7292. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
  7293. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
  7294. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
  7295. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
  7296. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
  7297. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
  7298. /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V less possible? */
  7299. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
  7300. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
  7301. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
  7302. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
  7303. /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
  7304. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
  7305. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
  7306. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
  7307. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
  7308. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
  7309. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
  7310. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
  7311. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
  7312. /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
  7313. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
  7314. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
  7315. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
  7316. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
  7317. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
  7318. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
  7319. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
  7320. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
  7321. /* ;CR Registers */
  7322. /* Config. Reg. 0 (filters) (cr0):FF */
  7323. j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
  7324. /* Config. Reg. 1 (dialing) (cr1):05 */
  7325. j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
  7326. /* Config. Reg. 2 (caller ID) (cr2):04 */
  7327. j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
  7328. /* Config. Reg. 3 (testloops) (cr3):00 ; */
  7329. j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
  7330. /* Config. Reg. 4 (analog gain) (cr4):02 */
  7331. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
  7332. /* Config. Reg. 5 (Version) (cr5):02 */
  7333. /* Config. Reg. 6 (Reserved) (cr6):00 */
  7334. /* Config. Reg. 7 (Reserved) (cr7):00 */
  7335. /* ;xr Registers */
  7336. /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
  7337. j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
  7338. /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
  7339. j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
  7340. /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
  7341. j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
  7342. /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
  7343. j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
  7344. /* Ext. Reg. 4 (Cadence) (xr4):00 */
  7345. j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
  7346. /* Ext. Reg. 5 (Ring timer) (xr5):22 */
  7347. j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
  7348. /* Ext. Reg. 6 (Power State) (xr6):00 */
  7349. j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
  7350. /* Ext. Reg. 7 (Vdd) (xr7):46 */
  7351. j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
  7352. /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
  7353. /* 12,33,5A,C3 ; 770 Hz */
  7354. /* 13,3C,5B,32 ; 852 Hz */
  7355. /* 1D,1B,5C,CC ; 941 Hz */
  7356. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
  7357. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
  7358. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
  7359. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
  7360. /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
  7361. /* EC,1D,52,22 ; 1336 Hz */
  7362. /* AA,AC,51,D2 ; 1477 Hz */
  7363. /* 9B,3B,51,25 ; 1633 Hz */
  7364. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
  7365. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
  7366. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
  7367. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
  7368. }
  7369. static void DAA_Coeff_France(IXJ *j)
  7370. {
  7371. int i;
  7372. j->daa_country = DAA_FRANCE;
  7373. /*----------------------------------------------- */
  7374. /* CAO */
  7375. for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
  7376. j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
  7377. }
  7378. /* Bytes for IM-filter part 1 (04): 02,A2,43,2C,22,AF,A0,00 */
  7379. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x02;
  7380. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA2;
  7381. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x43;
  7382. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2C;
  7383. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x22;
  7384. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xAF;
  7385. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
  7386. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
  7387. /* Bytes for IM-filter part 2 (05): 67,CE,00,0C,22,33,E0,08 */
  7388. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x67;
  7389. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xCE;
  7390. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
  7391. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x2C;
  7392. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x22;
  7393. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
  7394. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
  7395. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
  7396. /* Bytes for FRX-filter (08): 07,9A,28,F6,23,4A,B0,08 */
  7397. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
  7398. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9A;
  7399. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x28;
  7400. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0xF6;
  7401. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x23;
  7402. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x4A;
  7403. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xB0;
  7404. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
  7405. /* Bytes for FRR-filter (07): 03,8F,F9,2F,9E,FA,20,08 */
  7406. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
  7407. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
  7408. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
  7409. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
  7410. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9E;
  7411. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xFA;
  7412. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
  7413. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
  7414. /* Bytes for AX-filter (0A): 16,B5,DD,CA */
  7415. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x16;
  7416. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
  7417. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
  7418. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
  7419. /* Bytes for AR-filter (09): 52,C7,10,D6 */
  7420. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
  7421. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
  7422. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
  7423. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
  7424. /* Bytes for TH-filter part 1 (00): 00,42,48,81,A6,80,00,98 */
  7425. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
  7426. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
  7427. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
  7428. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
  7429. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA6;
  7430. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
  7431. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
  7432. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
  7433. /* Bytes for TH-filter part 2 (01): 02,AC,2A,30,78,AC,8A,2C */
  7434. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
  7435. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAC;
  7436. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
  7437. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x30;
  7438. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x78;
  7439. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAC;
  7440. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x8A;
  7441. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x2C;
  7442. /* Bytes for TH-filter part 3 (02): 00,88,DA,A5,22,BA,2C,45 */
  7443. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
  7444. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
  7445. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
  7446. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA5;
  7447. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x22;
  7448. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xBA;
  7449. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x2C;
  7450. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x45;
  7451. /* ; idle */
  7452. /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
  7453. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
  7454. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
  7455. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
  7456. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
  7457. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
  7458. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
  7459. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
  7460. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
  7461. /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
  7462. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
  7463. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
  7464. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
  7465. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
  7466. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
  7467. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
  7468. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
  7469. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
  7470. /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
  7471. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
  7472. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
  7473. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
  7474. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
  7475. /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
  7476. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
  7477. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
  7478. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
  7479. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
  7480. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
  7481. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
  7482. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
  7483. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
  7484. /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
  7485. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
  7486. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
  7487. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
  7488. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
  7489. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
  7490. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
  7491. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
  7492. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
  7493. /* ;CR Registers */
  7494. /* Config. Reg. 0 (filters) (cr0):FF */
  7495. j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
  7496. /* Config. Reg. 1 (dialing) (cr1):05 */
  7497. j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
  7498. /* Config. Reg. 2 (caller ID) (cr2):04 */
  7499. j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
  7500. /* Config. Reg. 3 (testloops) (cr3):00 ; */
  7501. j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
  7502. /* Config. Reg. 4 (analog gain) (cr4):02 */
  7503. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
  7504. /* Config. Reg. 5 (Version) (cr5):02 */
  7505. /* Config. Reg. 6 (Reserved) (cr6):00 */
  7506. /* Config. Reg. 7 (Reserved) (cr7):00 */
  7507. /* ;xr Registers */
  7508. /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
  7509. j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
  7510. /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
  7511. j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
  7512. /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
  7513. j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
  7514. /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
  7515. j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
  7516. /* Ext. Reg. 4 (Cadence) (xr4):00 */
  7517. j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
  7518. /* Ext. Reg. 5 (Ring timer) (xr5):22 */
  7519. j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
  7520. /* Ext. Reg. 6 (Power State) (xr6):00 */
  7521. j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
  7522. /* Ext. Reg. 7 (Vdd) (xr7):46 */
  7523. j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
  7524. /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
  7525. /* 12,33,5A,C3 ; 770 Hz */
  7526. /* 13,3C,5B,32 ; 852 Hz */
  7527. /* 1D,1B,5C,CC ; 941 Hz */
  7528. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
  7529. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
  7530. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
  7531. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
  7532. /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
  7533. /* EC,1D,52,22 ; 1336 Hz */
  7534. /* AA,AC,51,D2 ; 1477 Hz */
  7535. /* 9B,3B,51,25 ; 1633 Hz */
  7536. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
  7537. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
  7538. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
  7539. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
  7540. }
  7541. static void DAA_Coeff_Germany(IXJ *j)
  7542. {
  7543. int i;
  7544. j->daa_country = DAA_GERMANY;
  7545. /*----------------------------------------------- */
  7546. /* CAO */
  7547. for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
  7548. j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
  7549. }
  7550. /* Bytes for IM-filter part 1 (04): 00,CE,BB,B8,D2,81,B0,00 */
  7551. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
  7552. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xCE;
  7553. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
  7554. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xB8;
  7555. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xD2;
  7556. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
  7557. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xB0;
  7558. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
  7559. /* Bytes for IM-filter part 2 (05): 45,8F,00,0C,D2,3A,D0,08 */
  7560. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x45;
  7561. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x8F;
  7562. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
  7563. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0C;
  7564. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xD2;
  7565. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x3A;
  7566. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xD0;
  7567. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
  7568. /* Bytes for FRX-filter (08): 07,AA,E2,34,24,89,20,08 */
  7569. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
  7570. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xAA;
  7571. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
  7572. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
  7573. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x24;
  7574. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x89;
  7575. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x20;
  7576. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
  7577. /* Bytes for FRR-filter (07): 02,87,FA,37,9A,CA,B0,08 */
  7578. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x02;
  7579. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
  7580. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xFA;
  7581. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x37;
  7582. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9A;
  7583. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCA;
  7584. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
  7585. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
  7586. /* Bytes for AX-filter (0A): 72,D5,DD,CA */
  7587. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x72;
  7588. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xD5;
  7589. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
  7590. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
  7591. /* Bytes for AR-filter (09): 72,42,13,4B */
  7592. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x72;
  7593. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x42;
  7594. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x13;
  7595. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0x4B;
  7596. /* Bytes for TH-filter part 1 (00): 80,52,48,81,AD,80,00,98 */
  7597. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
  7598. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
  7599. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
  7600. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
  7601. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAD;
  7602. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
  7603. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
  7604. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
  7605. /* Bytes for TH-filter part 2 (01): 02,42,5A,20,E8,1A,81,27 */
  7606. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
  7607. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x42;
  7608. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x5A;
  7609. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
  7610. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
  7611. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x1A;
  7612. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
  7613. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x27;
  7614. /* Bytes for TH-filter part 3 (02): 00,88,63,26,BD,4B,A3,C2 */
  7615. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
  7616. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
  7617. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x63;
  7618. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x26;
  7619. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBD;
  7620. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x4B;
  7621. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xA3;
  7622. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xC2;
  7623. /* ; (10K, 0.68uF) */
  7624. /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
  7625. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
  7626. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3B;
  7627. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x9B;
  7628. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xBA;
  7629. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0xD4;
  7630. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x1C;
  7631. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xB3;
  7632. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
  7633. /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
  7634. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x13;
  7635. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x42;
  7636. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
  7637. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
  7638. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0xD4;
  7639. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x73;
  7640. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0xCA;
  7641. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
  7642. /* Levelmetering Ringing (0D):B2,45,0F,8E */
  7643. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xB2;
  7644. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
  7645. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
  7646. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
  7647. /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
  7648. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
  7649. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
  7650. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
  7651. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
  7652. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
  7653. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
  7654. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
  7655. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
  7656. /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
  7657. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
  7658. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
  7659. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
  7660. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
  7661. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
  7662. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
  7663. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
  7664. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
  7665. /* ;CR Registers */
  7666. /* Config. Reg. 0 (filters) (cr0):FF ; all Filters enabled, CLK from ext. source */
  7667. j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
  7668. /* Config. Reg. 1 (dialing) (cr1):05 ; Manual Ring, Ring metering enabled */
  7669. j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
  7670. /* Config. Reg. 2 (caller ID) (cr2):04 ; Analog Gain 0dB, FSC internal */
  7671. j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
  7672. /* Config. Reg. 3 (testloops) (cr3):00 ; SEL Bit==0, HP-enabled */
  7673. j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
  7674. /* Config. Reg. 4 (analog gain) (cr4):02 */
  7675. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
  7676. /* Config. Reg. 5 (Version) (cr5):02 */
  7677. /* Config. Reg. 6 (Reserved) (cr6):00 */
  7678. /* Config. Reg. 7 (Reserved) (cr7):00 */
  7679. /* ;xr Registers */
  7680. /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
  7681. j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
  7682. /* Ext. Reg. 1 (Interrupt enable) (xr1):1C ; Ring, CID, VDDOK Interrupts enabled */
  7683. j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
  7684. /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
  7685. j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
  7686. /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off==1, U0=3.5V, R=200Ohm */
  7687. j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x32;
  7688. /* Ext. Reg. 4 (Cadence) (xr4):00 */
  7689. j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
  7690. /* Ext. Reg. 5 (Ring timer) (xr5):22 */
  7691. j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
  7692. /* Ext. Reg. 6 (Power State) (xr6):00 */
  7693. j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
  7694. /* Ext. Reg. 7 (Vdd) (xr7):40 ; VDD=4.25 V */
  7695. j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
  7696. /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
  7697. /* 12,33,5A,C3 ; 770 Hz */
  7698. /* 13,3C,5B,32 ; 852 Hz */
  7699. /* 1D,1B,5C,CC ; 941 Hz */
  7700. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
  7701. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
  7702. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
  7703. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
  7704. /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
  7705. /* EC,1D,52,22 ; 1336 Hz */
  7706. /* AA,AC,51,D2 ; 1477 Hz */
  7707. /* 9B,3B,51,25 ; 1633 Hz */
  7708. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
  7709. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
  7710. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
  7711. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
  7712. }
  7713. static void DAA_Coeff_Australia(IXJ *j)
  7714. {
  7715. int i;
  7716. j->daa_country = DAA_AUSTRALIA;
  7717. /*----------------------------------------------- */
  7718. /* CAO */
  7719. for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
  7720. j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
  7721. }
  7722. /* Bytes for IM-filter part 1 (04): 00,A3,AA,28,B3,82,D0,00 */
  7723. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
  7724. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA3;
  7725. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xAA;
  7726. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x28;
  7727. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xB3;
  7728. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x82;
  7729. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xD0;
  7730. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
  7731. /* Bytes for IM-filter part 2 (05): 70,96,00,09,32,6B,C0,08 */
  7732. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x70;
  7733. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x96;
  7734. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
  7735. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x09;
  7736. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x32;
  7737. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x6B;
  7738. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xC0;
  7739. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
  7740. /* Bytes for FRX-filter (08): 07,96,E2,34,32,9B,30,08 */
  7741. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
  7742. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x96;
  7743. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
  7744. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
  7745. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x32;
  7746. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x9B;
  7747. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
  7748. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
  7749. /* Bytes for FRR-filter (07): 0F,9A,E9,2F,22,CC,A0,08 */
  7750. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
  7751. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x9A;
  7752. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xE9;
  7753. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
  7754. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x22;
  7755. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCC;
  7756. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xA0;
  7757. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
  7758. /* Bytes for AX-filter (0A): CB,45,DD,CA */
  7759. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0xCB;
  7760. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0x45;
  7761. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
  7762. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
  7763. /* Bytes for AR-filter (09): 1B,67,10,D6 */
  7764. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x1B;
  7765. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x67;
  7766. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
  7767. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
  7768. /* Bytes for TH-filter part 1 (00): 80,52,48,81,AF,80,00,98 */
  7769. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
  7770. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
  7771. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
  7772. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
  7773. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAF;
  7774. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
  7775. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
  7776. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
  7777. /* Bytes for TH-filter part 2 (01): 02,DB,52,B0,38,01,82,AC */
  7778. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
  7779. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xDB;
  7780. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x52;
  7781. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
  7782. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x38;
  7783. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x01;
  7784. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x82;
  7785. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xAC;
  7786. /* Bytes for TH-filter part 3 (02): 00,88,4A,3E,2C,3B,24,46 */
  7787. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
  7788. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
  7789. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x4A;
  7790. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x3E;
  7791. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x2C;
  7792. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x3B;
  7793. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x24;
  7794. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x46;
  7795. /* ; idle */
  7796. /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
  7797. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
  7798. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
  7799. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
  7800. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
  7801. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
  7802. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
  7803. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
  7804. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
  7805. /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
  7806. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
  7807. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
  7808. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
  7809. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
  7810. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
  7811. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
  7812. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
  7813. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
  7814. /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
  7815. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
  7816. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
  7817. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
  7818. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
  7819. /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
  7820. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
  7821. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
  7822. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
  7823. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
  7824. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
  7825. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
  7826. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
  7827. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
  7828. /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
  7829. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
  7830. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
  7831. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
  7832. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
  7833. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
  7834. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
  7835. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
  7836. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
  7837. /* ;CR Registers */
  7838. /* Config. Reg. 0 (filters) (cr0):FF */
  7839. j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
  7840. /* Config. Reg. 1 (dialing) (cr1):05 */
  7841. j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
  7842. /* Config. Reg. 2 (caller ID) (cr2):04 */
  7843. j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
  7844. /* Config. Reg. 3 (testloops) (cr3):00 ; */
  7845. j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
  7846. /* Config. Reg. 4 (analog gain) (cr4):02 */
  7847. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
  7848. /* Config. Reg. 5 (Version) (cr5):02 */
  7849. /* Config. Reg. 6 (Reserved) (cr6):00 */
  7850. /* Config. Reg. 7 (Reserved) (cr7):00 */
  7851. /* ;xr Registers */
  7852. /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
  7853. j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
  7854. /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
  7855. j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
  7856. /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
  7857. j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
  7858. /* Ext. Reg. 3 (DC Char) (xr3):2B ; */
  7859. j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x2B;
  7860. /* Ext. Reg. 4 (Cadence) (xr4):00 */
  7861. j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
  7862. /* Ext. Reg. 5 (Ring timer) (xr5):22 */
  7863. j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
  7864. /* Ext. Reg. 6 (Power State) (xr6):00 */
  7865. j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
  7866. /* Ext. Reg. 7 (Vdd) (xr7):40 */
  7867. j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
  7868. /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
  7869. /* 12,33,5A,C3 ; 770 Hz */
  7870. /* 13,3C,5B,32 ; 852 Hz */
  7871. /* 1D,1B,5C,CC ; 941 Hz */
  7872. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
  7873. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
  7874. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
  7875. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
  7876. /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
  7877. /* EC,1D,52,22 ; 1336 Hz */
  7878. /* AA,AC,51,D2 ; 1477 Hz */
  7879. /* 9B,3B,51,25 ; 1633 Hz */
  7880. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
  7881. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
  7882. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
  7883. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
  7884. }
  7885. static void DAA_Coeff_Japan(IXJ *j)
  7886. {
  7887. int i;
  7888. j->daa_country = DAA_JAPAN;
  7889. /*----------------------------------------------- */
  7890. /* CAO */
  7891. for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
  7892. j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
  7893. }
  7894. /* Bytes for IM-filter part 1 (04): 06,BD,E2,2D,BA,F9,A0,00 */
  7895. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x06;
  7896. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xBD;
  7897. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xE2;
  7898. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2D;
  7899. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xBA;
  7900. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xF9;
  7901. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
  7902. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
  7903. /* Bytes for IM-filter part 2 (05): 6F,F7,00,0E,34,33,E0,08 */
  7904. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x6F;
  7905. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xF7;
  7906. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
  7907. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0E;
  7908. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x34;
  7909. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
  7910. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
  7911. j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
  7912. /* Bytes for FRX-filter (08): 02,8F,68,77,9C,58,F0,08 */
  7913. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x02;
  7914. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x8F;
  7915. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x68;
  7916. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x77;
  7917. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x9C;
  7918. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x58;
  7919. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xF0;
  7920. j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
  7921. /* Bytes for FRR-filter (07): 03,8F,38,73,87,EA,20,08 */
  7922. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
  7923. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
  7924. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0x38;
  7925. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x73;
  7926. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
  7927. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xEA;
  7928. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
  7929. j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
  7930. /* Bytes for AX-filter (0A): 51,C5,DD,CA */
  7931. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x51;
  7932. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xC5;
  7933. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
  7934. j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
  7935. /* Bytes for AR-filter (09): 25,A7,10,D6 */
  7936. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
  7937. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xA7;
  7938. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
  7939. j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
  7940. /* Bytes for TH-filter part 1 (00): 00,42,48,81,AE,80,00,98 */
  7941. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
  7942. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
  7943. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
  7944. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
  7945. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAE;
  7946. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
  7947. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
  7948. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
  7949. /* Bytes for TH-filter part 2 (01): 02,AB,2A,20,99,5B,89,28 */
  7950. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
  7951. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAB;
  7952. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
  7953. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
  7954. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x99;
  7955. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5B;
  7956. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x89;
  7957. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x28;
  7958. /* Bytes for TH-filter part 3 (02): 00,88,DA,25,34,C5,4C,BA */
  7959. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
  7960. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
  7961. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
  7962. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x25;
  7963. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x34;
  7964. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xC5;
  7965. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x4C;
  7966. j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xBA;
  7967. /* ; idle */
  7968. /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
  7969. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
  7970. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
  7971. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
  7972. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
  7973. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
  7974. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
  7975. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
  7976. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
  7977. /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
  7978. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
  7979. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
  7980. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
  7981. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
  7982. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
  7983. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
  7984. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
  7985. j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
  7986. /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V ????????? */
  7987. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
  7988. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
  7989. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
  7990. j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
  7991. /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
  7992. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
  7993. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
  7994. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
  7995. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
  7996. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
  7997. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
  7998. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
  7999. j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
  8000. /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
  8001. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
  8002. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
  8003. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
  8004. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
  8005. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
  8006. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
  8007. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
  8008. j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
  8009. /* ;CR Registers */
  8010. /* Config. Reg. 0 (filters) (cr0):FF */
  8011. j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
  8012. /* Config. Reg. 1 (dialing) (cr1):05 */
  8013. j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
  8014. /* Config. Reg. 2 (caller ID) (cr2):04 */
  8015. j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
  8016. /* Config. Reg. 3 (testloops) (cr3):00 ; */
  8017. j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
  8018. /* Config. Reg. 4 (analog gain) (cr4):02 */
  8019. j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
  8020. /* Config. Reg. 5 (Version) (cr5):02 */
  8021. /* Config. Reg. 6 (Reserved) (cr6):00 */
  8022. /* Config. Reg. 7 (Reserved) (cr7):00 */
  8023. /* ;xr Registers */
  8024. /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
  8025. j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
  8026. /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
  8027. j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
  8028. /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
  8029. j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
  8030. /* Ext. Reg. 3 (DC Char) (xr3):22 ; */
  8031. j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x22;
  8032. /* Ext. Reg. 4 (Cadence) (xr4):00 */
  8033. j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
  8034. /* Ext. Reg. 5 (Ring timer) (xr5):22 */
  8035. j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
  8036. /* Ext. Reg. 6 (Power State) (xr6):00 */
  8037. j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
  8038. /* Ext. Reg. 7 (Vdd) (xr7):40 */
  8039. j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
  8040. /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
  8041. /* 12,33,5A,C3 ; 770 Hz */
  8042. /* 13,3C,5B,32 ; 852 Hz */
  8043. /* 1D,1B,5C,CC ; 941 Hz */
  8044. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
  8045. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
  8046. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
  8047. j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
  8048. /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
  8049. /* EC,1D,52,22 ; 1336 Hz */
  8050. /* AA,AC,51,D2 ; 1477 Hz */
  8051. /* 9B,3B,51,25 ; 1633 Hz */
  8052. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
  8053. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
  8054. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
  8055. j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
  8056. }
  8057. static s16 tone_table[][19] =
  8058. {
  8059. { /* f20_50[] 11 */
  8060. 32538, /* A1 = 1.985962 */
  8061. -32325, /* A2 = -0.986511 */
  8062. -343, /* B2 = -0.010493 */
  8063. 0, /* B1 = 0 */
  8064. 343, /* B0 = 0.010493 */
  8065. 32619, /* A1 = 1.990906 */
  8066. -32520, /* A2 = -0.992462 */
  8067. 19179, /* B2 = 0.585327 */
  8068. -19178, /* B1 = -1.170593 */
  8069. 19179, /* B0 = 0.585327 */
  8070. 32723, /* A1 = 1.997314 */
  8071. -32686, /* A2 = -0.997528 */
  8072. 9973, /* B2 = 0.304352 */
  8073. -9955, /* B1 = -0.607605 */
  8074. 9973, /* B0 = 0.304352 */
  8075. 7, /* Internal filter scaling */
  8076. 159, /* Minimum in-band energy threshold */
  8077. 21, /* 21/32 in-band to broad-band ratio */
  8078. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8079. },
  8080. { /* f133_200[] 12 */
  8081. 32072, /* A1 = 1.95752 */
  8082. -31896, /* A2 = -0.973419 */
  8083. -435, /* B2 = -0.013294 */
  8084. 0, /* B1 = 0 */
  8085. 435, /* B0 = 0.013294 */
  8086. 32188, /* A1 = 1.9646 */
  8087. -32400, /* A2 = -0.98877 */
  8088. 15139, /* B2 = 0.462036 */
  8089. -14882, /* B1 = -0.908356 */
  8090. 15139, /* B0 = 0.462036 */
  8091. 32473, /* A1 = 1.981995 */
  8092. -32524, /* A2 = -0.992584 */
  8093. 23200, /* B2 = 0.708008 */
  8094. -23113, /* B1 = -1.410706 */
  8095. 23200, /* B0 = 0.708008 */
  8096. 7, /* Internal filter scaling */
  8097. 159, /* Minimum in-band energy threshold */
  8098. 21, /* 21/32 in-band to broad-band ratio */
  8099. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8100. },
  8101. { /* f300 13 */
  8102. 31769, /* A1 = -1.939026 */
  8103. -32584, /* A2 = 0.994385 */
  8104. -475, /* B2 = -0.014522 */
  8105. 0, /* B1 = 0.000000 */
  8106. 475, /* B0 = 0.014522 */
  8107. 31789, /* A1 = -1.940247 */
  8108. -32679, /* A2 = 0.997284 */
  8109. 17280, /* B2 = 0.527344 */
  8110. -16865, /* B1 = -1.029358 */
  8111. 17280, /* B0 = 0.527344 */
  8112. 31841, /* A1 = -1.943481 */
  8113. -32681, /* A2 = 0.997345 */
  8114. 543, /* B2 = 0.016579 */
  8115. -525, /* B1 = -0.032097 */
  8116. 543, /* B0 = 0.016579 */
  8117. 5, /* Internal filter scaling */
  8118. 159, /* Minimum in-band energy threshold */
  8119. 21, /* 21/32 in-band to broad-band ratio */
  8120. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8121. },
  8122. { /* f300_420[] 14 */
  8123. 30750, /* A1 = 1.876892 */
  8124. -31212, /* A2 = -0.952515 */
  8125. -804, /* B2 = -0.024541 */
  8126. 0, /* B1 = 0 */
  8127. 804, /* B0 = 0.024541 */
  8128. 30686, /* A1 = 1.872925 */
  8129. -32145, /* A2 = -0.980988 */
  8130. 14747, /* B2 = 0.450043 */
  8131. -13703, /* B1 = -0.836395 */
  8132. 14747, /* B0 = 0.450043 */
  8133. 31651, /* A1 = 1.931824 */
  8134. -32321, /* A2 = -0.986389 */
  8135. 24425, /* B2 = 0.745422 */
  8136. -23914, /* B1 = -1.459595 */
  8137. 24427, /* B0 = 0.745483 */
  8138. 7, /* Internal filter scaling */
  8139. 159, /* Minimum in-band energy threshold */
  8140. 21, /* 21/32 in-band to broad-band ratio */
  8141. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8142. },
  8143. { /* f330 15 */
  8144. 31613, /* A1 = -1.929565 */
  8145. -32646, /* A2 = 0.996277 */
  8146. -185, /* B2 = -0.005657 */
  8147. 0, /* B1 = 0.000000 */
  8148. 185, /* B0 = 0.005657 */
  8149. 31620, /* A1 = -1.929932 */
  8150. -32713, /* A2 = 0.998352 */
  8151. 19253, /* B2 = 0.587585 */
  8152. -18566, /* B1 = -1.133179 */
  8153. 19253, /* B0 = 0.587585 */
  8154. 31674, /* A1 = -1.933228 */
  8155. -32715, /* A2 = 0.998413 */
  8156. 2575, /* B2 = 0.078590 */
  8157. -2495, /* B1 = -0.152283 */
  8158. 2575, /* B0 = 0.078590 */
  8159. 5, /* Internal filter scaling */
  8160. 159, /* Minimum in-band energy threshold */
  8161. 21, /* 21/32 in-band to broad-band ratio */
  8162. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8163. },
  8164. { /* f300_425[] 16 */
  8165. 30741, /* A1 = 1.876282 */
  8166. -31475, /* A2 = -0.960541 */
  8167. -703, /* B2 = -0.021484 */
  8168. 0, /* B1 = 0 */
  8169. 703, /* B0 = 0.021484 */
  8170. 30688, /* A1 = 1.873047 */
  8171. -32248, /* A2 = -0.984161 */
  8172. 14542, /* B2 = 0.443787 */
  8173. -13523, /* B1 = -0.825439 */
  8174. 14542, /* B0 = 0.443817 */
  8175. 31494, /* A1 = 1.922302 */
  8176. -32366, /* A2 = -0.987762 */
  8177. 21577, /* B2 = 0.658508 */
  8178. -21013, /* B1 = -1.282532 */
  8179. 21577, /* B0 = 0.658508 */
  8180. 7, /* Internal filter scaling */
  8181. 159, /* Minimum in-band energy threshold */
  8182. 21, /* 21/32 in-band to broad-band ratio */
  8183. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8184. },
  8185. { /* f330_440[] 17 */
  8186. 30627, /* A1 = 1.869324 */
  8187. -31338, /* A2 = -0.95636 */
  8188. -843, /* B2 = -0.025749 */
  8189. 0, /* B1 = 0 */
  8190. 843, /* B0 = 0.025749 */
  8191. 30550, /* A1 = 1.864685 */
  8192. -32221, /* A2 = -0.983337 */
  8193. 13594, /* B2 = 0.414886 */
  8194. -12589, /* B1 = -0.768402 */
  8195. 13594, /* B0 = 0.414886 */
  8196. 31488, /* A1 = 1.921936 */
  8197. -32358, /* A2 = -0.987518 */
  8198. 24684, /* B2 = 0.753296 */
  8199. -24029, /* B1 = -1.466614 */
  8200. 24684, /* B0 = 0.753296 */
  8201. 7, /* Internal filter scaling */
  8202. 159, /* Minimum in-band energy threshold */
  8203. 21, /* 21/32 in-band to broad-band ratio */
  8204. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8205. },
  8206. { /* f340 18 */
  8207. 31546, /* A1 = -1.925476 */
  8208. -32646, /* A2 = 0.996277 */
  8209. -445, /* B2 = -0.013588 */
  8210. 0, /* B1 = 0.000000 */
  8211. 445, /* B0 = 0.013588 */
  8212. 31551, /* A1 = -1.925781 */
  8213. -32713, /* A2 = 0.998352 */
  8214. 23884, /* B2 = 0.728882 */
  8215. -22979, /* B1 = -1.402527 */
  8216. 23884, /* B0 = 0.728882 */
  8217. 31606, /* A1 = -1.929138 */
  8218. -32715, /* A2 = 0.998413 */
  8219. 863, /* B2 = 0.026367 */
  8220. -835, /* B1 = -0.050985 */
  8221. 863, /* B0 = 0.026367 */
  8222. 5, /* Internal filter scaling */
  8223. 159, /* Minimum in-band energy threshold */
  8224. 21, /* 21/32 in-band to broad-band ratio */
  8225. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8226. },
  8227. { /* f350_400[] 19 */
  8228. 31006, /* A1 = 1.892517 */
  8229. -32029, /* A2 = -0.977448 */
  8230. -461, /* B2 = -0.014096 */
  8231. 0, /* B1 = 0 */
  8232. 461, /* B0 = 0.014096 */
  8233. 30999, /* A1 = 1.892029 */
  8234. -32487, /* A2 = -0.991455 */
  8235. 11325, /* B2 = 0.345612 */
  8236. -10682, /* B1 = -0.651978 */
  8237. 11325, /* B0 = 0.345612 */
  8238. 31441, /* A1 = 1.919067 */
  8239. -32526, /* A2 = -0.992615 */
  8240. 24324, /* B2 = 0.74231 */
  8241. -23535, /* B1 = -1.436523 */
  8242. 24324, /* B0 = 0.74231 */
  8243. 7, /* Internal filter scaling */
  8244. 159, /* Minimum in-band energy threshold */
  8245. 21, /* 21/32 in-band to broad-band ratio */
  8246. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8247. },
  8248. { /* f350_440[] */
  8249. 30634, /* A1 = 1.869751 */
  8250. -31533, /* A2 = -0.962341 */
  8251. -680, /* B2 = -0.020782 */
  8252. 0, /* B1 = 0 */
  8253. 680, /* B0 = 0.020782 */
  8254. 30571, /* A1 = 1.865906 */
  8255. -32277, /* A2 = -0.985016 */
  8256. 12894, /* B2 = 0.393524 */
  8257. -11945, /* B1 = -0.729065 */
  8258. 12894, /* B0 = 0.393524 */
  8259. 31367, /* A1 = 1.91449 */
  8260. -32379, /* A2 = -0.988129 */
  8261. 23820, /* B2 = 0.726929 */
  8262. -23104, /* B1 = -1.410217 */
  8263. 23820, /* B0 = 0.726929 */
  8264. 7, /* Internal filter scaling */
  8265. 159, /* Minimum in-band energy threshold */
  8266. 21, /* 21/32 in-band to broad-band ratio */
  8267. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8268. },
  8269. { /* f350_450[] */
  8270. 30552, /* A1 = 1.864807 */
  8271. -31434, /* A2 = -0.95929 */
  8272. -690, /* B2 = -0.021066 */
  8273. 0, /* B1 = 0 */
  8274. 690, /* B0 = 0.021066 */
  8275. 30472, /* A1 = 1.859924 */
  8276. -32248, /* A2 = -0.984161 */
  8277. 13385, /* B2 = 0.408478 */
  8278. -12357, /* B1 = -0.754242 */
  8279. 13385, /* B0 = 0.408478 */
  8280. 31358, /* A1 = 1.914001 */
  8281. -32366, /* A2 = -0.987732 */
  8282. 26488, /* B2 = 0.80835 */
  8283. -25692, /* B1 = -1.568176 */
  8284. 26490, /* B0 = 0.808411 */
  8285. 7, /* Internal filter scaling */
  8286. 159, /* Minimum in-band energy threshold */
  8287. 21, /* 21/32 in-band to broad-band ratio */
  8288. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8289. },
  8290. { /* f360 */
  8291. 31397, /* A1 = -1.916321 */
  8292. -32623, /* A2 = 0.995605 */
  8293. -117, /* B2 = -0.003598 */
  8294. 0, /* B1 = 0.000000 */
  8295. 117, /* B0 = 0.003598 */
  8296. 31403, /* A1 = -1.916687 */
  8297. -32700, /* A2 = 0.997925 */
  8298. 3388, /* B2 = 0.103401 */
  8299. -3240, /* B1 = -0.197784 */
  8300. 3388, /* B0 = 0.103401 */
  8301. 31463, /* A1 = -1.920410 */
  8302. -32702, /* A2 = 0.997986 */
  8303. 13346, /* B2 = 0.407288 */
  8304. -12863, /* B1 = -0.785126 */
  8305. 13346, /* B0 = 0.407288 */
  8306. 5, /* Internal filter scaling */
  8307. 159, /* Minimum in-band energy threshold */
  8308. 21, /* 21/32 in-band to broad-band ratio */
  8309. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8310. },
  8311. { /* f380_420[] */
  8312. 30831, /* A1 = 1.881775 */
  8313. -32064, /* A2 = -0.978546 */
  8314. -367, /* B2 = -0.01122 */
  8315. 0, /* B1 = 0 */
  8316. 367, /* B0 = 0.01122 */
  8317. 30813, /* A1 = 1.880737 */
  8318. -32456, /* A2 = -0.990509 */
  8319. 11068, /* B2 = 0.337769 */
  8320. -10338, /* B1 = -0.631042 */
  8321. 11068, /* B0 = 0.337769 */
  8322. 31214, /* A1 = 1.905212 */
  8323. -32491, /* A2 = -0.991577 */
  8324. 16374, /* B2 = 0.499695 */
  8325. -15781, /* B1 = -0.963196 */
  8326. 16374, /* B0 = 0.499695 */
  8327. 7, /* Internal filter scaling */
  8328. 159, /* Minimum in-band energy threshold */
  8329. 21, /* 21/32 in-band to broad-band ratio */
  8330. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8331. },
  8332. { /* f392 */
  8333. 31152, /* A1 = -1.901428 */
  8334. -32613, /* A2 = 0.995300 */
  8335. -314, /* B2 = -0.009605 */
  8336. 0, /* B1 = 0.000000 */
  8337. 314, /* B0 = 0.009605 */
  8338. 31156, /* A1 = -1.901672 */
  8339. -32694, /* A2 = 0.997742 */
  8340. 28847, /* B2 = 0.880371 */
  8341. -2734, /* B1 = -0.166901 */
  8342. 28847, /* B0 = 0.880371 */
  8343. 31225, /* A1 = -1.905823 */
  8344. -32696, /* A2 = 0.997803 */
  8345. 462, /* B2 = 0.014108 */
  8346. -442, /* B1 = -0.027019 */
  8347. 462, /* B0 = 0.014108 */
  8348. 5, /* Internal filter scaling */
  8349. 159, /* Minimum in-band energy threshold */
  8350. 21, /* 21/32 in-band to broad-band ratio */
  8351. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8352. },
  8353. { /* f400_425[] */
  8354. 30836, /* A1 = 1.882141 */
  8355. -32296, /* A2 = -0.985596 */
  8356. -324, /* B2 = -0.009903 */
  8357. 0, /* B1 = 0 */
  8358. 324, /* B0 = 0.009903 */
  8359. 30825, /* A1 = 1.881409 */
  8360. -32570, /* A2 = -0.993958 */
  8361. 16847, /* B2 = 0.51416 */
  8362. -15792, /* B1 = -0.963898 */
  8363. 16847, /* B0 = 0.51416 */
  8364. 31106, /* A1 = 1.89856 */
  8365. -32584, /* A2 = -0.994415 */
  8366. 9579, /* B2 = 0.292328 */
  8367. -9164, /* B1 = -0.559357 */
  8368. 9579, /* B0 = 0.292328 */
  8369. 7, /* Internal filter scaling */
  8370. 159, /* Minimum in-band energy threshold */
  8371. 21, /* 21/32 in-band to broad-band ratio */
  8372. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8373. },
  8374. { /* f400_440[] */
  8375. 30702, /* A1 = 1.873962 */
  8376. -32134, /* A2 = -0.980682 */
  8377. -517, /* B2 = -0.015793 */
  8378. 0, /* B1 = 0 */
  8379. 517, /* B0 = 0.015793 */
  8380. 30676, /* A1 = 1.872375 */
  8381. -32520, /* A2 = -0.992462 */
  8382. 8144, /* B2 = 0.24855 */
  8383. -7596, /* B1 = -0.463684 */
  8384. 8144, /* B0 = 0.24855 */
  8385. 31084, /* A1 = 1.897217 */
  8386. -32547, /* A2 = -0.993256 */
  8387. 22713, /* B2 = 0.693176 */
  8388. -21734, /* B1 = -1.326599 */
  8389. 22713, /* B0 = 0.693176 */
  8390. 7, /* Internal filter scaling */
  8391. 159, /* Minimum in-band energy threshold */
  8392. 21, /* 21/32 in-band to broad-band ratio */
  8393. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8394. },
  8395. { /* f400_450[] */
  8396. 30613, /* A1 = 1.86853 */
  8397. -32031, /* A2 = -0.977509 */
  8398. -618, /* B2 = -0.018866 */
  8399. 0, /* B1 = 0 */
  8400. 618, /* B0 = 0.018866 */
  8401. 30577, /* A1 = 1.866272 */
  8402. -32491, /* A2 = -0.991577 */
  8403. 9612, /* B2 = 0.293335 */
  8404. -8935, /* B1 = -0.54541 */
  8405. 9612, /* B0 = 0.293335 */
  8406. 31071, /* A1 = 1.896484 */
  8407. -32524, /* A2 = -0.992584 */
  8408. 21596, /* B2 = 0.659058 */
  8409. -20667, /* B1 = -1.261414 */
  8410. 21596, /* B0 = 0.659058 */
  8411. 7, /* Internal filter scaling */
  8412. 159, /* Minimum in-band energy threshold */
  8413. 21, /* 21/32 in-band to broad-band ratio */
  8414. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8415. },
  8416. { /* f420 */
  8417. 30914, /* A1 = -1.886841 */
  8418. -32584, /* A2 = 0.994385 */
  8419. -426, /* B2 = -0.013020 */
  8420. 0, /* B1 = 0.000000 */
  8421. 426, /* B0 = 0.013020 */
  8422. 30914, /* A1 = -1.886841 */
  8423. -32679, /* A2 = 0.997314 */
  8424. 17520, /* B2 = 0.534668 */
  8425. -16471, /* B1 = -1.005310 */
  8426. 17520, /* B0 = 0.534668 */
  8427. 31004, /* A1 = -1.892334 */
  8428. -32683, /* A2 = 0.997406 */
  8429. 819, /* B2 = 0.025023 */
  8430. -780, /* B1 = -0.047619 */
  8431. 819, /* B0 = 0.025023 */
  8432. 5, /* Internal filter scaling */
  8433. 159, /* Minimum in-band energy threshold */
  8434. 21, /* 21/32 in-band to broad-band ratio */
  8435. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8436. },
  8437. #if 0
  8438. { /* f425 */
  8439. 30881, /* A1 = -1.884827 */
  8440. -32603, /* A2 = 0.994965 */
  8441. -496, /* B2 = -0.015144 */
  8442. 0, /* B1 = 0.000000 */
  8443. 496, /* B0 = 0.015144 */
  8444. 30880, /* A1 = -1.884766 */
  8445. -32692, /* A2 = 0.997711 */
  8446. 24767, /* B2 = 0.755859 */
  8447. -23290, /* B1 = -1.421509 */
  8448. 24767, /* B0 = 0.755859 */
  8449. 30967, /* A1 = -1.890076 */
  8450. -32694, /* A2 = 0.997772 */
  8451. 728, /* B2 = 0.022232 */
  8452. -691, /* B1 = -0.042194 */
  8453. 728, /* B0 = 0.022232 */
  8454. 5, /* Internal filter scaling */
  8455. 159, /* Minimum in-band energy threshold */
  8456. 21, /* 21/32 in-band to broad-band ratio */
  8457. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8458. },
  8459. #else
  8460. {
  8461. 30850,
  8462. -32534,
  8463. -504,
  8464. 0,
  8465. 504,
  8466. 30831,
  8467. -32669,
  8468. 24303,
  8469. -22080,
  8470. 24303,
  8471. 30994,
  8472. -32673,
  8473. 1905,
  8474. -1811,
  8475. 1905,
  8476. 5,
  8477. 129,
  8478. 17,
  8479. 0xff5
  8480. },
  8481. #endif
  8482. { /* f425_450[] */
  8483. 30646, /* A1 = 1.870544 */
  8484. -32327, /* A2 = -0.986572 */
  8485. -287, /* B2 = -0.008769 */
  8486. 0, /* B1 = 0 */
  8487. 287, /* B0 = 0.008769 */
  8488. 30627, /* A1 = 1.869324 */
  8489. -32607, /* A2 = -0.995087 */
  8490. 13269, /* B2 = 0.404968 */
  8491. -12376, /* B1 = -0.755432 */
  8492. 13269, /* B0 = 0.404968 */
  8493. 30924, /* A1 = 1.887512 */
  8494. -32619, /* A2 = -0.995453 */
  8495. 19950, /* B2 = 0.608826 */
  8496. -18940, /* B1 = -1.156006 */
  8497. 19950, /* B0 = 0.608826 */
  8498. 7, /* Internal filter scaling */
  8499. 159, /* Minimum in-band energy threshold */
  8500. 21, /* 21/32 in-band to broad-band ratio */
  8501. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8502. },
  8503. { /* f425_475[] */
  8504. 30396, /* A1 = 1.855225 */
  8505. -32014, /* A2 = -0.97699 */
  8506. -395, /* B2 = -0.012055 */
  8507. 0, /* B1 = 0 */
  8508. 395, /* B0 = 0.012055 */
  8509. 30343, /* A1 = 1.85199 */
  8510. -32482, /* A2 = -0.991302 */
  8511. 17823, /* B2 = 0.543945 */
  8512. -16431, /* B1 = -1.002869 */
  8513. 17823, /* B0 = 0.543945 */
  8514. 30872, /* A1 = 1.884338 */
  8515. -32516, /* A2 = -0.99231 */
  8516. 18124, /* B2 = 0.553101 */
  8517. -17246, /* B1 = -1.052673 */
  8518. 18124, /* B0 = 0.553101 */
  8519. 7, /* Internal filter scaling */
  8520. 159, /* Minimum in-band energy threshold */
  8521. 21, /* 21/32 in-band to broad-band ratio */
  8522. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8523. },
  8524. { /* f435 */
  8525. 30796, /* A1 = -1.879639 */
  8526. -32603, /* A2 = 0.994965 */
  8527. -254, /* B2 = -0.007762 */
  8528. 0, /* B1 = 0.000000 */
  8529. 254, /* B0 = 0.007762 */
  8530. 30793, /* A1 = -1.879456 */
  8531. -32692, /* A2 = 0.997711 */
  8532. 18934, /* B2 = 0.577820 */
  8533. -17751, /* B1 = -1.083496 */
  8534. 18934, /* B0 = 0.577820 */
  8535. 30882, /* A1 = -1.884888 */
  8536. -32694, /* A2 = 0.997772 */
  8537. 1858, /* B2 = 0.056713 */
  8538. -1758, /* B1 = -0.107357 */
  8539. 1858, /* B0 = 0.056713 */
  8540. 5, /* Internal filter scaling */
  8541. 159, /* Minimum in-band energy threshold */
  8542. 21, /* 21/32 in-band to broad-band ratio */
  8543. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8544. },
  8545. { /* f440_450[] */
  8546. 30641, /* A1 = 1.870239 */
  8547. -32458, /* A2 = -0.99057 */
  8548. -155, /* B2 = -0.004735 */
  8549. 0, /* B1 = 0 */
  8550. 155, /* B0 = 0.004735 */
  8551. 30631, /* A1 = 1.869568 */
  8552. -32630, /* A2 = -0.995789 */
  8553. 11453, /* B2 = 0.349548 */
  8554. -10666, /* B1 = -0.651001 */
  8555. 11453, /* B0 = 0.349548 */
  8556. 30810, /* A1 = 1.880554 */
  8557. -32634, /* A2 = -0.995941 */
  8558. 12237, /* B2 = 0.373474 */
  8559. -11588, /* B1 = -0.707336 */
  8560. 12237, /* B0 = 0.373474 */
  8561. 7, /* Internal filter scaling */
  8562. 159, /* Minimum in-band energy threshold */
  8563. 21, /* 21/32 in-band to broad-band ratio */
  8564. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8565. },
  8566. { /* f440_480[] */
  8567. 30367, /* A1 = 1.853455 */
  8568. -32147, /* A2 = -0.981079 */
  8569. -495, /* B2 = -0.015113 */
  8570. 0, /* B1 = 0 */
  8571. 495, /* B0 = 0.015113 */
  8572. 30322, /* A1 = 1.850769 */
  8573. -32543, /* A2 = -0.993134 */
  8574. 10031, /* B2 = 0.306152 */
  8575. -9252, /* B1 = -0.564728 */
  8576. 10031, /* B0 = 0.306152 */
  8577. 30770, /* A1 = 1.878052 */
  8578. -32563, /* A2 = -0.993774 */
  8579. 22674, /* B2 = 0.691956 */
  8580. -21465, /* B1 = -1.31012 */
  8581. 22674, /* B0 = 0.691956 */
  8582. 7, /* Internal filter scaling */
  8583. 159, /* Minimum in-band energy threshold */
  8584. 21, /* 21/32 in-band to broad-band ratio */
  8585. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8586. },
  8587. { /* f445 */
  8588. 30709, /* A1 = -1.874329 */
  8589. -32603, /* A2 = 0.994965 */
  8590. -83, /* B2 = -0.002545 */
  8591. 0, /* B1 = 0.000000 */
  8592. 83, /* B0 = 0.002545 */
  8593. 30704, /* A1 = -1.874084 */
  8594. -32692, /* A2 = 0.997711 */
  8595. 10641, /* B2 = 0.324738 */
  8596. -9947, /* B1 = -0.607147 */
  8597. 10641, /* B0 = 0.324738 */
  8598. 30796, /* A1 = -1.879639 */
  8599. -32694, /* A2 = 0.997772 */
  8600. 10079, /* B2 = 0.307587 */
  8601. 9513, /* B1 = 0.580688 */
  8602. 10079, /* B0 = 0.307587 */
  8603. 5, /* Internal filter scaling */
  8604. 159, /* Minimum in-band energy threshold */
  8605. 21, /* 21/32 in-band to broad-band ratio */
  8606. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8607. },
  8608. { /* f450 */
  8609. 30664, /* A1 = -1.871643 */
  8610. -32603, /* A2 = 0.994965 */
  8611. -164, /* B2 = -0.005029 */
  8612. 0, /* B1 = 0.000000 */
  8613. 164, /* B0 = 0.005029 */
  8614. 30661, /* A1 = -1.871399 */
  8615. -32692, /* A2 = 0.997711 */
  8616. 15294, /* B2 = 0.466736 */
  8617. -14275, /* B1 = -0.871307 */
  8618. 15294, /* B0 = 0.466736 */
  8619. 30751, /* A1 = -1.876953 */
  8620. -32694, /* A2 = 0.997772 */
  8621. 3548, /* B2 = 0.108284 */
  8622. -3344, /* B1 = -0.204155 */
  8623. 3548, /* B0 = 0.108284 */
  8624. 5, /* Internal filter scaling */
  8625. 159, /* Minimum in-band energy threshold */
  8626. 21, /* 21/32 in-band to broad-band ratio */
  8627. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8628. },
  8629. { /* f452 */
  8630. 30653, /* A1 = -1.870911 */
  8631. -32615, /* A2 = 0.995361 */
  8632. -209, /* B2 = -0.006382 */
  8633. 0, /* B1 = 0.000000 */
  8634. 209, /* B0 = 0.006382 */
  8635. 30647, /* A1 = -1.870605 */
  8636. -32702, /* A2 = 0.997986 */
  8637. 18971, /* B2 = 0.578979 */
  8638. -17716, /* B1 = -1.081299 */
  8639. 18971, /* B0 = 0.578979 */
  8640. 30738, /* A1 = -1.876099 */
  8641. -32702, /* A2 = 0.998016 */
  8642. 2967, /* B2 = 0.090561 */
  8643. -2793, /* B1 = -0.170502 */
  8644. 2967, /* B0 = 0.090561 */
  8645. 5, /* Internal filter scaling */
  8646. 159, /* Minimum in-band energy threshold */
  8647. 21, /* 21/32 in-band to broad-band ratio */
  8648. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8649. },
  8650. { /* f475 */
  8651. 30437, /* A1 = -1.857727 */
  8652. -32603, /* A2 = 0.994965 */
  8653. -264, /* B2 = -0.008062 */
  8654. 0, /* B1 = 0.000000 */
  8655. 264, /* B0 = 0.008062 */
  8656. 30430, /* A1 = -1.857300 */
  8657. -32692, /* A2 = 0.997711 */
  8658. 21681, /* B2 = 0.661682 */
  8659. -20082, /* B1 = -1.225708 */
  8660. 21681, /* B0 = 0.661682 */
  8661. 30526, /* A1 = -1.863220 */
  8662. -32694, /* A2 = 0.997742 */
  8663. 1559, /* B2 = 0.047600 */
  8664. -1459, /* B1 = -0.089096 */
  8665. 1559, /* B0 = 0.047600 */
  8666. 5, /* Internal filter scaling */
  8667. 159, /* Minimum in-band energy threshold */
  8668. 21, /* 21/32 in-band to broad-band ratio */
  8669. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8670. },
  8671. { /* f480_620[] */
  8672. 28975, /* A1 = 1.768494 */
  8673. -30955, /* A2 = -0.944672 */
  8674. -1026, /* B2 = -0.03133 */
  8675. 0, /* B1 = 0 */
  8676. 1026, /* B0 = 0.03133 */
  8677. 28613, /* A1 = 1.746399 */
  8678. -32089, /* A2 = -0.979309 */
  8679. 14214, /* B2 = 0.433807 */
  8680. -12202, /* B1 = -0.744812 */
  8681. 14214, /* B0 = 0.433807 */
  8682. 30243, /* A1 = 1.845947 */
  8683. -32238, /* A2 = -0.983856 */
  8684. 24825, /* B2 = 0.757629 */
  8685. -23402, /* B1 = -1.428345 */
  8686. 24825, /* B0 = 0.757629 */
  8687. 7, /* Internal filter scaling */
  8688. 159, /* Minimum in-band energy threshold */
  8689. 21, /* 21/32 in-band to broad-band ratio */
  8690. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8691. },
  8692. { /* f494 */
  8693. 30257, /* A1 = -1.846741 */
  8694. -32605, /* A2 = 0.995056 */
  8695. -249, /* B2 = -0.007625 */
  8696. 0, /* B1 = 0.000000 */
  8697. 249, /* B0 = 0.007625 */
  8698. 30247, /* A1 = -1.846191 */
  8699. -32694, /* A2 = 0.997772 */
  8700. 18088, /* B2 = 0.552002 */
  8701. -16652, /* B1 = -1.016418 */
  8702. 18088, /* B0 = 0.552002 */
  8703. 30348, /* A1 = -1.852295 */
  8704. -32696, /* A2 = 0.997803 */
  8705. 2099, /* B2 = 0.064064 */
  8706. -1953, /* B1 = -0.119202 */
  8707. 2099, /* B0 = 0.064064 */
  8708. 5, /* Internal filter scaling */
  8709. 159, /* Minimum in-band energy threshold */
  8710. 21, /* 21/32 in-band to broad-band ratio */
  8711. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8712. },
  8713. { /* f500 */
  8714. 30202, /* A1 = -1.843431 */
  8715. -32624, /* A2 = 0.995622 */
  8716. -413, /* B2 = -0.012622 */
  8717. 0, /* B1 = 0.000000 */
  8718. 413, /* B0 = 0.012622 */
  8719. 30191, /* A1 = -1.842721 */
  8720. -32714, /* A2 = 0.998364 */
  8721. 25954, /* B2 = 0.792057 */
  8722. -23890, /* B1 = -1.458131 */
  8723. 25954, /* B0 = 0.792057 */
  8724. 30296, /* A1 = -1.849172 */
  8725. -32715, /* A2 = 0.998397 */
  8726. 2007, /* B2 = 0.061264 */
  8727. -1860, /* B1 = -0.113568 */
  8728. 2007, /* B0 = 0.061264 */
  8729. 5, /* Internal filter scaling */
  8730. 159, /* Minimum in-band energy threshold */
  8731. 21, /* 21/32 in-band to broad-band ratio */
  8732. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8733. },
  8734. { /* f520 */
  8735. 30001, /* A1 = -1.831116 */
  8736. -32613, /* A2 = 0.995270 */
  8737. -155, /* B2 = -0.004750 */
  8738. 0, /* B1 = 0.000000 */
  8739. 155, /* B0 = 0.004750 */
  8740. 29985, /* A1 = -1.830200 */
  8741. -32710, /* A2 = 0.998260 */
  8742. 6584, /* B2 = 0.200928 */
  8743. -6018, /* B1 = -0.367355 */
  8744. 6584, /* B0 = 0.200928 */
  8745. 30105, /* A1 = -1.837524 */
  8746. -32712, /* A2 = 0.998291 */
  8747. 23812, /* B2 = 0.726685 */
  8748. -21936, /* B1 = -1.338928 */
  8749. 23812, /* B0 = 0.726685 */
  8750. 5, /* Internal filter scaling */
  8751. 159, /* Minimum in-band energy threshold */
  8752. 21, /* 21/32 in-band to broad-band ratio */
  8753. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8754. },
  8755. { /* f523 */
  8756. 29964, /* A1 = -1.828918 */
  8757. -32601, /* A2 = 0.994904 */
  8758. -101, /* B2 = -0.003110 */
  8759. 0, /* B1 = 0.000000 */
  8760. 101, /* B0 = 0.003110 */
  8761. 29949, /* A1 = -1.827942 */
  8762. -32700, /* A2 = 0.997925 */
  8763. 11041, /* B2 = 0.336975 */
  8764. -10075, /* B1 = -0.614960 */
  8765. 11041, /* B0 = 0.336975 */
  8766. 30070, /* A1 = -1.835388 */
  8767. -32702, /* A2 = 0.997986 */
  8768. 16762, /* B2 = 0.511536 */
  8769. -15437, /* B1 = -0.942230 */
  8770. 16762, /* B0 = 0.511536 */
  8771. 5, /* Internal filter scaling */
  8772. 159, /* Minimum in-band energy threshold */
  8773. 21, /* 21/32 in-band to broad-band ratio */
  8774. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8775. },
  8776. { /* f525 */
  8777. 29936, /* A1 = -1.827209 */
  8778. -32584, /* A2 = 0.994415 */
  8779. -91, /* B2 = -0.002806 */
  8780. 0, /* B1 = 0.000000 */
  8781. 91, /* B0 = 0.002806 */
  8782. 29921, /* A1 = -1.826233 */
  8783. -32688, /* A2 = 0.997559 */
  8784. 11449, /* B2 = 0.349396 */
  8785. -10426, /* B1 = -0.636383 */
  8786. 11449, /* B0 = 0.349396 */
  8787. 30045, /* A1 = -1.833862 */
  8788. -32688, /* A2 = 0.997589 */
  8789. 13055, /* B2 = 0.398407 */
  8790. -12028, /* B1 = -0.734161 */
  8791. 13055, /* B0 = 0.398407 */
  8792. 5, /* Internal filter scaling */
  8793. 159, /* Minimum in-band energy threshold */
  8794. 21, /* 21/32 in-band to broad-band ratio */
  8795. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8796. },
  8797. { /* f540_660[] */
  8798. 28499, /* A1 = 1.739441 */
  8799. -31129, /* A2 = -0.949982 */
  8800. -849, /* B2 = -0.025922 */
  8801. 0, /* B1 = 0 */
  8802. 849, /* B0 = 0.025922 */
  8803. 28128, /* A1 = 1.716797 */
  8804. -32130, /* A2 = -0.98056 */
  8805. 14556, /* B2 = 0.444214 */
  8806. -12251, /* B1 = -0.747772 */
  8807. 14556, /* B0 = 0.444244 */
  8808. 29667, /* A1 = 1.81073 */
  8809. -32244, /* A2 = -0.984039 */
  8810. 23038, /* B2 = 0.703064 */
  8811. -21358, /* B1 = -1.303589 */
  8812. 23040, /* B0 = 0.703125 */
  8813. 7, /* Internal filter scaling */
  8814. 159, /* Minimum in-band energy threshold */
  8815. 21, /* 21/32 in-band to broad-band ratio */
  8816. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8817. },
  8818. { /* f587 */
  8819. 29271, /* A1 = -1.786560 */
  8820. -32599, /* A2 = 0.994873 */
  8821. -490, /* B2 = -0.014957 */
  8822. 0, /* B1 = 0.000000 */
  8823. 490, /* B0 = 0.014957 */
  8824. 29246, /* A1 = -1.785095 */
  8825. -32700, /* A2 = 0.997925 */
  8826. 28961, /* B2 = 0.883850 */
  8827. -25796, /* B1 = -1.574463 */
  8828. 28961, /* B0 = 0.883850 */
  8829. 29383, /* A1 = -1.793396 */
  8830. -32700, /* A2 = 0.997955 */
  8831. 1299, /* B2 = 0.039650 */
  8832. -1169, /* B1 = -0.071396 */
  8833. 1299, /* B0 = 0.039650 */
  8834. 5, /* Internal filter scaling */
  8835. 159, /* Minimum in-band energy threshold */
  8836. 21, /* 21/32 in-band to broad-band ratio */
  8837. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8838. },
  8839. { /* f590 */
  8840. 29230, /* A1 = -1.784058 */
  8841. -32584, /* A2 = 0.994415 */
  8842. -418, /* B2 = -0.012757 */
  8843. 0, /* B1 = 0.000000 */
  8844. 418, /* B0 = 0.012757 */
  8845. 29206, /* A1 = -1.782593 */
  8846. -32688, /* A2 = 0.997559 */
  8847. 36556, /* B2 = 1.115601 */
  8848. -32478, /* B1 = -1.982300 */
  8849. 36556, /* B0 = 1.115601 */
  8850. 29345, /* A1 = -1.791077 */
  8851. -32688, /* A2 = 0.997589 */
  8852. 897, /* B2 = 0.027397 */
  8853. -808, /* B1 = -0.049334 */
  8854. 897, /* B0 = 0.027397 */
  8855. 5, /* Internal filter scaling */
  8856. 159, /* Minimum in-band energy threshold */
  8857. 21, /* 21/32 in-band to broad-band ratio */
  8858. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8859. },
  8860. { /* f600 */
  8861. 29116, /* A1 = -1.777100 */
  8862. -32603, /* A2 = 0.994965 */
  8863. -165, /* B2 = -0.005039 */
  8864. 0, /* B1 = 0.000000 */
  8865. 165, /* B0 = 0.005039 */
  8866. 29089, /* A1 = -1.775452 */
  8867. -32708, /* A2 = 0.998199 */
  8868. 6963, /* B2 = 0.212494 */
  8869. -6172, /* B1 = -0.376770 */
  8870. 6963, /* B0 = 0.212494 */
  8871. 29237, /* A1 = -1.784485 */
  8872. -32710, /* A2 = 0.998230 */
  8873. 24197, /* B2 = 0.738464 */
  8874. -21657, /* B1 = -1.321899 */
  8875. 24197, /* B0 = 0.738464 */
  8876. 5, /* Internal filter scaling */
  8877. 159, /* Minimum in-band energy threshold */
  8878. 21, /* 21/32 in-band to broad-band ratio */
  8879. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8880. },
  8881. { /* f660 */
  8882. 28376, /* A1 = -1.731934 */
  8883. -32567, /* A2 = 0.993896 */
  8884. -363, /* B2 = -0.011102 */
  8885. 0, /* B1 = 0.000000 */
  8886. 363, /* B0 = 0.011102 */
  8887. 28337, /* A1 = -1.729614 */
  8888. -32683, /* A2 = 0.997434 */
  8889. 21766, /* B2 = 0.664246 */
  8890. -18761, /* B1 = -1.145081 */
  8891. 21766, /* B0 = 0.664246 */
  8892. 28513, /* A1 = -1.740356 */
  8893. -32686, /* A2 = 0.997498 */
  8894. 2509, /* B2 = 0.076584 */
  8895. -2196, /* B1 = -0.134041 */
  8896. 2509, /* B0 = 0.076584 */
  8897. 5, /* Internal filter scaling */
  8898. 159, /* Minimum in-band energy threshold */
  8899. 21, /* 21/32 in-band to broad-band ratio */
  8900. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8901. },
  8902. { /* f700 */
  8903. 27844, /* A1 = -1.699463 */
  8904. -32563, /* A2 = 0.993744 */
  8905. -366, /* B2 = -0.011187 */
  8906. 0, /* B1 = 0.000000 */
  8907. 366, /* B0 = 0.011187 */
  8908. 27797, /* A1 = -1.696655 */
  8909. -32686, /* A2 = 0.997498 */
  8910. 22748, /* B2 = 0.694214 */
  8911. -19235, /* B1 = -1.174072 */
  8912. 22748, /* B0 = 0.694214 */
  8913. 27995, /* A1 = -1.708740 */
  8914. -32688, /* A2 = 0.997559 */
  8915. 2964, /* B2 = 0.090477 */
  8916. -2546, /* B1 = -0.155449 */
  8917. 2964, /* B0 = 0.090477 */
  8918. 5, /* Internal filter scaling */
  8919. 159, /* Minimum in-band energy threshold */
  8920. 21, /* 21/32 in-band to broad-band ratio */
  8921. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8922. },
  8923. { /* f740 */
  8924. 27297, /* A1 = -1.666077 */
  8925. -32551, /* A2 = 0.993408 */
  8926. -345, /* B2 = -0.010540 */
  8927. 0, /* B1 = 0.000000 */
  8928. 345, /* B0 = 0.010540 */
  8929. 27240, /* A1 = -1.662598 */
  8930. -32683, /* A2 = 0.997406 */
  8931. 22560, /* B2 = 0.688477 */
  8932. -18688, /* B1 = -1.140625 */
  8933. 22560, /* B0 = 0.688477 */
  8934. 27461, /* A1 = -1.676147 */
  8935. -32684, /* A2 = 0.997467 */
  8936. 3541, /* B2 = 0.108086 */
  8937. -2985, /* B1 = -0.182220 */
  8938. 3541, /* B0 = 0.108086 */
  8939. 5, /* Internal filter scaling */
  8940. 159, /* Minimum in-band energy threshold */
  8941. 21, /* 21/32 in-band to broad-band ratio */
  8942. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8943. },
  8944. { /* f750 */
  8945. 27155, /* A1 = -1.657410 */
  8946. -32551, /* A2 = 0.993408 */
  8947. -462, /* B2 = -0.014117 */
  8948. 0, /* B1 = 0.000000 */
  8949. 462, /* B0 = 0.014117 */
  8950. 27097, /* A1 = -1.653870 */
  8951. -32683, /* A2 = 0.997406 */
  8952. 32495, /* B2 = 0.991699 */
  8953. -26776, /* B1 = -1.634338 */
  8954. 32495, /* B0 = 0.991699 */
  8955. 27321, /* A1 = -1.667542 */
  8956. -32684, /* A2 = 0.997467 */
  8957. 1835, /* B2 = 0.056007 */
  8958. -1539, /* B1 = -0.093948 */
  8959. 1835, /* B0 = 0.056007 */
  8960. 5, /* Internal filter scaling */
  8961. 159, /* Minimum in-band energy threshold */
  8962. 21, /* 21/32 in-band to broad-band ratio */
  8963. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8964. },
  8965. { /* f750_1450[] */
  8966. 19298, /* A1 = 1.177917 */
  8967. -24471, /* A2 = -0.746796 */
  8968. -4152, /* B2 = -0.126709 */
  8969. 0, /* B1 = 0 */
  8970. 4152, /* B0 = 0.126709 */
  8971. 12902, /* A1 = 0.787476 */
  8972. -29091, /* A2 = -0.887817 */
  8973. 12491, /* B2 = 0.38121 */
  8974. -1794, /* B1 = -0.109528 */
  8975. 12494, /* B0 = 0.381317 */
  8976. 26291, /* A1 = 1.604736 */
  8977. -30470, /* A2 = -0.929901 */
  8978. 28859, /* B2 = 0.880737 */
  8979. -26084, /* B1 = -1.592102 */
  8980. 28861, /* B0 = 0.880798 */
  8981. 7, /* Internal filter scaling */
  8982. 159, /* Minimum in-band energy threshold */
  8983. 21, /* 21/32 in-band to broad-band ratio */
  8984. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  8985. },
  8986. { /* f770 */
  8987. 26867, /* A1 = -1.639832 */
  8988. -32551, /* A2 = 0.993408 */
  8989. -123, /* B2 = -0.003755 */
  8990. 0, /* B1 = 0.000000 */
  8991. 123, /* B0 = 0.003755 */
  8992. 26805, /* A1 = -1.636108 */
  8993. -32683, /* A2 = 0.997406 */
  8994. 17297, /* B2 = 0.527863 */
  8995. -14096, /* B1 = -0.860382 */
  8996. 17297, /* B0 = 0.527863 */
  8997. 27034, /* A1 = -1.650085 */
  8998. -32684, /* A2 = 0.997467 */
  8999. 12958, /* B2 = 0.395477 */
  9000. -10756, /* B1 = -0.656525 */
  9001. 12958, /* B0 = 0.395477 */
  9002. 5, /* Internal filter scaling */
  9003. 159, /* Minimum in-band energy threshold */
  9004. 21, /* 21/32 in-band to broad-band ratio */
  9005. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9006. },
  9007. { /* f800 */
  9008. 26413, /* A1 = -1.612122 */
  9009. -32547, /* A2 = 0.993286 */
  9010. -223, /* B2 = -0.006825 */
  9011. 0, /* B1 = 0.000000 */
  9012. 223, /* B0 = 0.006825 */
  9013. 26342, /* A1 = -1.607849 */
  9014. -32686, /* A2 = 0.997498 */
  9015. 6391, /* B2 = 0.195053 */
  9016. -5120, /* B1 = -0.312531 */
  9017. 6391, /* B0 = 0.195053 */
  9018. 26593, /* A1 = -1.623108 */
  9019. -32688, /* A2 = 0.997559 */
  9020. 23681, /* B2 = 0.722717 */
  9021. -19328, /* B1 = -1.179688 */
  9022. 23681, /* B0 = 0.722717 */
  9023. 5, /* Internal filter scaling */
  9024. 159, /* Minimum in-band energy threshold */
  9025. 21, /* 21/32 in-band to broad-band ratio */
  9026. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9027. },
  9028. { /* f816 */
  9029. 26168, /* A1 = -1.597209 */
  9030. -32528, /* A2 = 0.992706 */
  9031. -235, /* B2 = -0.007182 */
  9032. 0, /* B1 = 0.000000 */
  9033. 235, /* B0 = 0.007182 */
  9034. 26092, /* A1 = -1.592590 */
  9035. -32675, /* A2 = 0.997192 */
  9036. 20823, /* B2 = 0.635498 */
  9037. -16510, /* B1 = -1.007751 */
  9038. 20823, /* B0 = 0.635498 */
  9039. 26363, /* A1 = -1.609070 */
  9040. -32677, /* A2 = 0.997253 */
  9041. 6739, /* B2 = 0.205688 */
  9042. -5459, /* B1 = -0.333206 */
  9043. 6739, /* B0 = 0.205688 */
  9044. 5, /* Internal filter scaling */
  9045. 159, /* Minimum in-band energy threshold */
  9046. 21, /* 21/32 in-band to broad-band ratio */
  9047. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9048. },
  9049. { /* f850 */
  9050. 25641, /* A1 = -1.565063 */
  9051. -32536, /* A2 = 0.992950 */
  9052. -121, /* B2 = -0.003707 */
  9053. 0, /* B1 = 0.000000 */
  9054. 121, /* B0 = 0.003707 */
  9055. 25560, /* A1 = -1.560059 */
  9056. -32684, /* A2 = 0.997437 */
  9057. 18341, /* B2 = 0.559753 */
  9058. -14252, /* B1 = -0.869904 */
  9059. 18341, /* B0 = 0.559753 */
  9060. 25837, /* A1 = -1.577026 */
  9061. -32684, /* A2 = 0.997467 */
  9062. 16679, /* B2 = 0.509003 */
  9063. -13232, /* B1 = -0.807648 */
  9064. 16679, /* B0 = 0.509003 */
  9065. 5, /* Internal filter scaling */
  9066. 159, /* Minimum in-band energy threshold */
  9067. 21, /* 21/32 in-band to broad-band ratio */
  9068. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9069. },
  9070. { /* f857_1645[] */
  9071. 16415, /* A1 = 1.001953 */
  9072. -23669, /* A2 = -0.722321 */
  9073. -4549, /* B2 = -0.138847 */
  9074. 0, /* B1 = 0 */
  9075. 4549, /* B0 = 0.138847 */
  9076. 8456, /* A1 = 0.516174 */
  9077. -28996, /* A2 = -0.884918 */
  9078. 13753, /* B2 = 0.419724 */
  9079. -12, /* B1 = -0.000763 */
  9080. 13757, /* B0 = 0.419846 */
  9081. 24632, /* A1 = 1.503418 */
  9082. -30271, /* A2 = -0.923828 */
  9083. 29070, /* B2 = 0.887146 */
  9084. -25265, /* B1 = -1.542114 */
  9085. 29073, /* B0 = 0.887268 */
  9086. 7, /* Internal filter scaling */
  9087. 159, /* Minimum in-band energy threshold */
  9088. 21, /* 21/32 in-band to broad-band ratio */
  9089. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9090. },
  9091. { /* f900 */
  9092. 24806, /* A1 = -1.514099 */
  9093. -32501, /* A2 = 0.991852 */
  9094. -326, /* B2 = -0.009969 */
  9095. 0, /* B1 = 0.000000 */
  9096. 326, /* B0 = 0.009969 */
  9097. 24709, /* A1 = -1.508118 */
  9098. -32659, /* A2 = 0.996674 */
  9099. 20277, /* B2 = 0.618835 */
  9100. -15182, /* B1 = -0.926636 */
  9101. 20277, /* B0 = 0.618835 */
  9102. 25022, /* A1 = -1.527222 */
  9103. -32661, /* A2 = 0.996735 */
  9104. 4320, /* B2 = 0.131836 */
  9105. -3331, /* B1 = -0.203339 */
  9106. 4320, /* B0 = 0.131836 */
  9107. 5, /* Internal filter scaling */
  9108. 159, /* Minimum in-band energy threshold */
  9109. 21, /* 21/32 in-band to broad-band ratio */
  9110. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9111. },
  9112. { /* f900_1300[] */
  9113. 19776, /* A1 = 1.207092 */
  9114. -27437, /* A2 = -0.837341 */
  9115. -2666, /* B2 = -0.081371 */
  9116. 0, /* B1 = 0 */
  9117. 2666, /* B0 = 0.081371 */
  9118. 16302, /* A1 = 0.995026 */
  9119. -30354, /* A2 = -0.926361 */
  9120. 10389, /* B2 = 0.317062 */
  9121. -3327, /* B1 = -0.203064 */
  9122. 10389, /* B0 = 0.317062 */
  9123. 24299, /* A1 = 1.483154 */
  9124. -30930, /* A2 = -0.943909 */
  9125. 25016, /* B2 = 0.763428 */
  9126. -21171, /* B1 = -1.292236 */
  9127. 25016, /* B0 = 0.763428 */
  9128. 7, /* Internal filter scaling */
  9129. 159, /* Minimum in-band energy threshold */
  9130. 21, /* 21/32 in-band to broad-band ratio */
  9131. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9132. },
  9133. { /* f935_1215[] */
  9134. 20554, /* A1 = 1.254517 */
  9135. -28764, /* A2 = -0.877838 */
  9136. -2048, /* B2 = -0.062515 */
  9137. 0, /* B1 = 0 */
  9138. 2048, /* B0 = 0.062515 */
  9139. 18209, /* A1 = 1.11145 */
  9140. -30951, /* A2 = -0.94458 */
  9141. 9390, /* B2 = 0.286575 */
  9142. -3955, /* B1 = -0.241455 */
  9143. 9390, /* B0 = 0.286575 */
  9144. 23902, /* A1 = 1.458923 */
  9145. -31286, /* A2 = -0.954803 */
  9146. 23252, /* B2 = 0.709595 */
  9147. -19132, /* B1 = -1.167725 */
  9148. 23252, /* B0 = 0.709595 */
  9149. 7, /* Internal filter scaling */
  9150. 159, /* Minimum in-band energy threshold */
  9151. 21, /* 21/32 in-band to broad-band ratio */
  9152. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9153. },
  9154. { /* f941_1477[] */
  9155. 17543, /* A1 = 1.07074 */
  9156. -26220, /* A2 = -0.800201 */
  9157. -3298, /* B2 = -0.100647 */
  9158. 0, /* B1 = 0 */
  9159. 3298, /* B0 = 0.100647 */
  9160. 12423, /* A1 = 0.75827 */
  9161. -30036, /* A2 = -0.916626 */
  9162. 12651, /* B2 = 0.386078 */
  9163. -2444, /* B1 = -0.14917 */
  9164. 12653, /* B0 = 0.386154 */
  9165. 23518, /* A1 = 1.435425 */
  9166. -30745, /* A2 = -0.938293 */
  9167. 27282, /* B2 = 0.832581 */
  9168. -22529, /* B1 = -1.375122 */
  9169. 27286, /* B0 = 0.832703 */
  9170. 7, /* Internal filter scaling */
  9171. 159, /* Minimum in-band energy threshold */
  9172. 21, /* 21/32 in-band to broad-band ratio */
  9173. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9174. },
  9175. { /* f942 */
  9176. 24104, /* A1 = -1.471252 */
  9177. -32507, /* A2 = 0.992065 */
  9178. -351, /* B2 = -0.010722 */
  9179. 0, /* B1 = 0.000000 */
  9180. 351, /* B0 = 0.010722 */
  9181. 23996, /* A1 = -1.464600 */
  9182. -32671, /* A2 = 0.997040 */
  9183. 22848, /* B2 = 0.697266 */
  9184. -16639, /* B1 = -1.015564 */
  9185. 22848, /* B0 = 0.697266 */
  9186. 24332, /* A1 = -1.485168 */
  9187. -32673, /* A2 = 0.997101 */
  9188. 4906, /* B2 = 0.149727 */
  9189. -3672, /* B1 = -0.224174 */
  9190. 4906, /* B0 = 0.149727 */
  9191. 5, /* Internal filter scaling */
  9192. 159, /* Minimum in-band energy threshold */
  9193. 21, /* 21/32 in-band to broad-band ratio */
  9194. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9195. },
  9196. { /* f950 */
  9197. 23967, /* A1 = -1.462830 */
  9198. -32507, /* A2 = 0.992065 */
  9199. -518, /* B2 = -0.015821 */
  9200. 0, /* B1 = 0.000000 */
  9201. 518, /* B0 = 0.015821 */
  9202. 23856, /* A1 = -1.456055 */
  9203. -32671, /* A2 = 0.997040 */
  9204. 26287, /* B2 = 0.802246 */
  9205. -19031, /* B1 = -1.161560 */
  9206. 26287, /* B0 = 0.802246 */
  9207. 24195, /* A1 = -1.476746 */
  9208. -32673, /* A2 = 0.997101 */
  9209. 2890, /* B2 = 0.088196 */
  9210. -2151, /* B1 = -0.131317 */
  9211. 2890, /* B0 = 0.088196 */
  9212. 5, /* Internal filter scaling */
  9213. 159, /* Minimum in-band energy threshold */
  9214. 21, /* 21/32 in-band to broad-band ratio */
  9215. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9216. },
  9217. { /* f950_1400[] */
  9218. 18294, /* A1 = 1.116638 */
  9219. -26962, /* A2 = -0.822845 */
  9220. -2914, /* B2 = -0.088936 */
  9221. 0, /* B1 = 0 */
  9222. 2914, /* B0 = 0.088936 */
  9223. 14119, /* A1 = 0.861786 */
  9224. -30227, /* A2 = -0.922455 */
  9225. 11466, /* B2 = 0.349945 */
  9226. -2833, /* B1 = -0.172943 */
  9227. 11466, /* B0 = 0.349945 */
  9228. 23431, /* A1 = 1.430115 */
  9229. -30828, /* A2 = -0.940796 */
  9230. 25331, /* B2 = 0.773071 */
  9231. -20911, /* B1 = -1.276367 */
  9232. 25331, /* B0 = 0.773071 */
  9233. 7, /* Internal filter scaling */
  9234. 159, /* Minimum in-band energy threshold */
  9235. 21, /* 21/32 in-band to broad-band ratio */
  9236. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9237. },
  9238. { /* f975 */
  9239. 23521, /* A1 = -1.435608 */
  9240. -32489, /* A2 = 0.991516 */
  9241. -193, /* B2 = -0.005915 */
  9242. 0, /* B1 = 0.000000 */
  9243. 193, /* B0 = 0.005915 */
  9244. 23404, /* A1 = -1.428467 */
  9245. -32655, /* A2 = 0.996582 */
  9246. 17740, /* B2 = 0.541412 */
  9247. -12567, /* B1 = -0.767029 */
  9248. 17740, /* B0 = 0.541412 */
  9249. 23753, /* A1 = -1.449829 */
  9250. -32657, /* A2 = 0.996613 */
  9251. 9090, /* B2 = 0.277405 */
  9252. -6662, /* B1 = -0.406647 */
  9253. 9090, /* B0 = 0.277405 */
  9254. 5, /* Internal filter scaling */
  9255. 159, /* Minimum in-band energy threshold */
  9256. 21, /* 21/32 in-band to broad-band ratio */
  9257. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9258. },
  9259. { /* f1000 */
  9260. 23071, /* A1 = -1.408203 */
  9261. -32489, /* A2 = 0.991516 */
  9262. -293, /* B2 = -0.008965 */
  9263. 0, /* B1 = 0.000000 */
  9264. 293, /* B0 = 0.008965 */
  9265. 22951, /* A1 = -1.400818 */
  9266. -32655, /* A2 = 0.996582 */
  9267. 5689, /* B2 = 0.173645 */
  9268. -3951, /* B1 = -0.241150 */
  9269. 5689, /* B0 = 0.173645 */
  9270. 23307, /* A1 = -1.422607 */
  9271. -32657, /* A2 = 0.996613 */
  9272. 18692, /* B2 = 0.570435 */
  9273. -13447, /* B1 = -0.820770 */
  9274. 18692, /* B0 = 0.570435 */
  9275. 5, /* Internal filter scaling */
  9276. 159, /* Minimum in-band energy threshold */
  9277. 21, /* 21/32 in-band to broad-band ratio */
  9278. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9279. },
  9280. { /* f1020 */
  9281. 22701, /* A1 = -1.385620 */
  9282. -32474, /* A2 = 0.991058 */
  9283. -292, /* B2 = -0.008933 */
  9284. 0, /*163840 , B1 = 10.000000 */
  9285. 292, /* B0 = 0.008933 */
  9286. 22564, /* A1 = -1.377258 */
  9287. -32655, /* A2 = 0.996552 */
  9288. 20756, /* B2 = 0.633423 */
  9289. -14176, /* B1 = -0.865295 */
  9290. 20756, /* B0 = 0.633423 */
  9291. 22960, /* A1 = -1.401428 */
  9292. -32657, /* A2 = 0.996613 */
  9293. 6520, /* B2 = 0.198990 */
  9294. -4619, /* B1 = -0.281937 */
  9295. 6520, /* B0 = 0.198990 */
  9296. 5, /* Internal filter scaling */
  9297. 159, /* Minimum in-band energy threshold */
  9298. 21, /* 21/32 in-band to broad-band ratio */
  9299. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9300. },
  9301. { /* f1050 */
  9302. 22142, /* A1 = -1.351501 */
  9303. -32474, /* A2 = 0.991058 */
  9304. -147, /* B2 = -0.004493 */
  9305. 0, /* B1 = 0.000000 */
  9306. 147, /* B0 = 0.004493 */
  9307. 22000, /* A1 = -1.342834 */
  9308. -32655, /* A2 = 0.996552 */
  9309. 15379, /* B2 = 0.469360 */
  9310. -10237, /* B1 = -0.624847 */
  9311. 15379, /* B0 = 0.469360 */
  9312. 22406, /* A1 = -1.367554 */
  9313. -32657, /* A2 = 0.996613 */
  9314. 17491, /* B2 = 0.533783 */
  9315. -12096, /* B1 = -0.738312 */
  9316. 17491, /* B0 = 0.533783 */
  9317. 5, /* Internal filter scaling */
  9318. 159, /* Minimum in-band energy threshold */
  9319. 21, /* 21/32 in-band to broad-band ratio */
  9320. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9321. },
  9322. { /* f1100_1750[] */
  9323. 12973, /* A1 = 0.79184 */
  9324. -24916, /* A2 = -0.760376 */
  9325. 6655, /* B2 = 0.203102 */
  9326. 367, /* B1 = 0.0224 */
  9327. 6657, /* B0 = 0.203171 */
  9328. 5915, /* A1 = 0.361053 */
  9329. -29560, /* A2 = -0.90213 */
  9330. -7777, /* B2 = -0.23735 */
  9331. 0, /* B1 = 0 */
  9332. 7777, /* B0 = 0.23735 */
  9333. 20510, /* A1 = 1.251892 */
  9334. -30260, /* A2 = -0.923462 */
  9335. 26662, /* B2 = 0.81366 */
  9336. -20573, /* B1 = -1.255737 */
  9337. 26668, /* B0 = 0.813843 */
  9338. 7, /* Internal filter scaling */
  9339. 159, /* Minimum in-band energy threshold */
  9340. 21, /* 21/32 in-band to broad-band ratio */
  9341. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9342. },
  9343. { /* f1140 */
  9344. 20392, /* A1 = -1.244629 */
  9345. -32460, /* A2 = 0.990601 */
  9346. -270, /* B2 = -0.008240 */
  9347. 0, /* B1 = 0.000000 */
  9348. 270, /* B0 = 0.008240 */
  9349. 20218, /* A1 = -1.234009 */
  9350. -32655, /* A2 = 0.996582 */
  9351. 21337, /* B2 = 0.651154 */
  9352. -13044, /* B1 = -0.796143 */
  9353. 21337, /* B0 = 0.651154 */
  9354. 20684, /* A1 = -1.262512 */
  9355. -32657, /* A2 = 0.996643 */
  9356. 8572, /* B2 = 0.261612 */
  9357. -5476, /* B1 = -0.334244 */
  9358. 8572, /* B0 = 0.261612 */
  9359. 5, /* Internal filter scaling */
  9360. 159, /* Minimum in-band energy threshold */
  9361. 21, /* 21/32 in-band to broad-band ratio */
  9362. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9363. },
  9364. { /* f1200 */
  9365. 19159, /* A1 = -1.169373 */
  9366. -32456, /* A2 = 0.990509 */
  9367. -335, /* B2 = -0.010252 */
  9368. 0, /* B1 = 0.000000 */
  9369. 335, /* B0 = 0.010252 */
  9370. 18966, /* A1 = -1.157593 */
  9371. -32661, /* A2 = 0.996735 */
  9372. 6802, /* B2 = 0.207588 */
  9373. -3900, /* B1 = -0.238098 */
  9374. 6802, /* B0 = 0.207588 */
  9375. 19467, /* A1 = -1.188232 */
  9376. -32661, /* A2 = 0.996765 */
  9377. 25035, /* B2 = 0.764008 */
  9378. -15049, /* B1 = -0.918579 */
  9379. 25035, /* B0 = 0.764008 */
  9380. 5, /* Internal filter scaling */
  9381. 159, /* Minimum in-band energy threshold */
  9382. 21, /* 21/32 in-band to broad-band ratio */
  9383. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9384. },
  9385. { /* f1209 */
  9386. 18976, /* A1 = -1.158264 */
  9387. -32439, /* A2 = 0.989990 */
  9388. -183, /* B2 = -0.005588 */
  9389. 0, /* B1 = 0.000000 */
  9390. 183, /* B0 = 0.005588 */
  9391. 18774, /* A1 = -1.145874 */
  9392. -32650, /* A2 = 0.996429 */
  9393. 15468, /* B2 = 0.472076 */
  9394. -8768, /* B1 = -0.535217 */
  9395. 15468, /* B0 = 0.472076 */
  9396. 19300, /* A1 = -1.177979 */
  9397. -32652, /* A2 = 0.996490 */
  9398. 19840, /* B2 = 0.605499 */
  9399. -11842, /* B1 = -0.722809 */
  9400. 19840, /* B0 = 0.605499 */
  9401. 5, /* Internal filter scaling */
  9402. 159, /* Minimum in-band energy threshold */
  9403. 21, /* 21/32 in-band to broad-band ratio */
  9404. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9405. },
  9406. { /* f1330 */
  9407. 16357, /* A1 = -0.998413 */
  9408. -32368, /* A2 = 0.987793 */
  9409. -217, /* B2 = -0.006652 */
  9410. 0, /* B1 = 0.000000 */
  9411. 217, /* B0 = 0.006652 */
  9412. 16107, /* A1 = -0.983126 */
  9413. -32601, /* A2 = 0.994904 */
  9414. 11602, /* B2 = 0.354065 */
  9415. -5555, /* B1 = -0.339111 */
  9416. 11602, /* B0 = 0.354065 */
  9417. 16722, /* A1 = -1.020630 */
  9418. -32603, /* A2 = 0.994965 */
  9419. 15574, /* B2 = 0.475311 */
  9420. -8176, /* B1 = -0.499069 */
  9421. 15574, /* B0 = 0.475311 */
  9422. 5, /* Internal filter scaling */
  9423. 159, /* Minimum in-band energy threshold */
  9424. 21, /* 21/32 in-band to broad-band ratio */
  9425. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9426. },
  9427. { /* f1336 */
  9428. 16234, /* A1 = -0.990875 */
  9429. 32404, /* A2 = -0.988922 */
  9430. -193, /* B2 = -0.005908 */
  9431. 0, /* B1 = 0.000000 */
  9432. 193, /* B0 = 0.005908 */
  9433. 15986, /* A1 = -0.975769 */
  9434. -32632, /* A2 = 0.995880 */
  9435. 18051, /* B2 = 0.550903 */
  9436. -8658, /* B1 = -0.528473 */
  9437. 18051, /* B0 = 0.550903 */
  9438. 16591, /* A1 = -1.012695 */
  9439. -32634, /* A2 = 0.995941 */
  9440. 15736, /* B2 = 0.480240 */
  9441. -8125, /* B1 = -0.495926 */
  9442. 15736, /* B0 = 0.480240 */
  9443. 5, /* Internal filter scaling */
  9444. 159, /* Minimum in-band energy threshold */
  9445. 21, /* 21/32 in-band to broad-band ratio */
  9446. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9447. },
  9448. { /* f1366 */
  9449. 15564, /* A1 = -0.949982 */
  9450. -32404, /* A2 = 0.988922 */
  9451. -269, /* B2 = -0.008216 */
  9452. 0, /* B1 = 0.000000 */
  9453. 269, /* B0 = 0.008216 */
  9454. 15310, /* A1 = -0.934479 */
  9455. -32632, /* A2 = 0.995880 */
  9456. 10815, /* B2 = 0.330063 */
  9457. -4962, /* B1 = -0.302887 */
  9458. 10815, /* B0 = 0.330063 */
  9459. 15924, /* A1 = -0.971924 */
  9460. -32634, /* A2 = 0.995941 */
  9461. 18880, /* B2 = 0.576172 */
  9462. -9364, /* B1 = -0.571594 */
  9463. 18880, /* B0 = 0.576172 */
  9464. 5, /* Internal filter scaling */
  9465. 159, /* Minimum in-band energy threshold */
  9466. 21, /* 21/32 in-band to broad-band ratio */
  9467. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9468. },
  9469. { /* f1380 */
  9470. 15247, /* A1 = -0.930603 */
  9471. -32397, /* A2 = 0.988708 */
  9472. -244, /* B2 = -0.007451 */
  9473. 0, /* B1 = 0.000000 */
  9474. 244, /* B0 = 0.007451 */
  9475. 14989, /* A1 = -0.914886 */
  9476. -32627, /* A2 = 0.995697 */
  9477. 18961, /* B2 = 0.578644 */
  9478. -8498, /* B1 = -0.518707 */
  9479. 18961, /* B0 = 0.578644 */
  9480. 15608, /* A1 = -0.952667 */
  9481. -32628, /* A2 = 0.995758 */
  9482. 11145, /* B2 = 0.340134 */
  9483. -5430, /* B1 = -0.331467 */
  9484. 11145, /* B0 = 0.340134 */
  9485. 5, /* Internal filter scaling */
  9486. 159, /* Minimum in-band energy threshold */
  9487. 21, /* 21/32 in-band to broad-band ratio */
  9488. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9489. },
  9490. { /* f1400 */
  9491. 14780, /* A1 = -0.902130 */
  9492. -32393, /* A2 = 0.988586 */
  9493. -396, /* B2 = -0.012086 */
  9494. 0, /* B1 = 0.000000 */
  9495. 396, /* B0 = 0.012086 */
  9496. 14510, /* A1 = -0.885651 */
  9497. -32630, /* A2 = 0.995819 */
  9498. 6326, /* B2 = 0.193069 */
  9499. -2747, /* B1 = -0.167671 */
  9500. 6326, /* B0 = 0.193069 */
  9501. 15154, /* A1 = -0.924957 */
  9502. -32632, /* A2 = 0.995850 */
  9503. 23235, /* B2 = 0.709076 */
  9504. -10983, /* B1 = -0.670380 */
  9505. 23235, /* B0 = 0.709076 */
  9506. 5, /* Internal filter scaling */
  9507. 159, /* Minimum in-band energy threshold */
  9508. 21, /* 21/32 in-band to broad-band ratio */
  9509. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9510. },
  9511. { /* f1477 */
  9512. 13005, /* A1 = -0.793793 */
  9513. -32368, /* A2 = 0.987823 */
  9514. -500, /* B2 = -0.015265 */
  9515. 0, /* B1 = 0.000000 */
  9516. 500, /* B0 = 0.015265 */
  9517. 12708, /* A1 = -0.775665 */
  9518. -32615, /* A2 = 0.995331 */
  9519. 11420, /* B2 = 0.348526 */
  9520. -4306, /* B1 = -0.262833 */
  9521. 11420, /* B0 = 0.348526 */
  9522. 13397, /* A1 = -0.817688 */
  9523. -32615, /* A2 = 0.995361 */
  9524. 9454, /* B2 = 0.288528 */
  9525. -3981, /* B1 = -0.243027 */
  9526. 9454, /* B0 = 0.288528 */
  9527. 5, /* Internal filter scaling */
  9528. 159, /* Minimum in-band energy threshold */
  9529. 21, /* 21/32 in-band to broad-band ratio */
  9530. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9531. },
  9532. { /* f1600 */
  9533. 10046, /* A1 = -0.613190 */
  9534. -32331, /* A2 = 0.986694 */
  9535. -455, /* B2 = -0.013915 */
  9536. 0, /* B1 = 0.000000 */
  9537. 455, /* B0 = 0.013915 */
  9538. 9694, /* A1 = -0.591705 */
  9539. -32601, /* A2 = 0.994934 */
  9540. 6023, /* B2 = 0.183815 */
  9541. -1708, /* B1 = -0.104279 */
  9542. 6023, /* B0 = 0.183815 */
  9543. 10478, /* A1 = -0.639587 */
  9544. -32603, /* A2 = 0.994965 */
  9545. 22031, /* B2 = 0.672333 */
  9546. -7342, /* B1 = -0.448151 */
  9547. 22031, /* B0 = 0.672333 */
  9548. 5, /* Internal filter scaling */
  9549. 159, /* Minimum in-band energy threshold */
  9550. 21, /* 21/32 in-band to broad-band ratio */
  9551. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9552. },
  9553. { /* f1633_1638[] */
  9554. 9181, /* A1 = 0.560394 */
  9555. -32256, /* A2 = -0.984375 */
  9556. -556, /* B2 = -0.016975 */
  9557. 0, /* B1 = 0 */
  9558. 556, /* B0 = 0.016975 */
  9559. 8757, /* A1 = 0.534515 */
  9560. -32574, /* A2 = -0.99408 */
  9561. 8443, /* B2 = 0.25769 */
  9562. -2135, /* B1 = -0.130341 */
  9563. 8443, /* B0 = 0.25769 */
  9564. 9691, /* A1 = 0.591522 */
  9565. -32574, /* A2 = -0.99411 */
  9566. 15446, /* B2 = 0.471375 */
  9567. -4809, /* B1 = -0.293579 */
  9568. 15446, /* B0 = 0.471375 */
  9569. 7, /* Internal filter scaling */
  9570. 159, /* Minimum in-band energy threshold */
  9571. 21, /* 21/32 in-band to broad-band ratio */
  9572. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9573. },
  9574. { /* f1800 */
  9575. 5076, /* A1 = -0.309875 */
  9576. -32304, /* A2 = 0.985840 */
  9577. -508, /* B2 = -0.015503 */
  9578. 0, /* B1 = 0.000000 */
  9579. 508, /* B0 = 0.015503 */
  9580. 4646, /* A1 = -0.283600 */
  9581. -32605, /* A2 = 0.995026 */
  9582. 6742, /* B2 = 0.205780 */
  9583. -878, /* B1 = -0.053635 */
  9584. 6742, /* B0 = 0.205780 */
  9585. 5552, /* A1 = -0.338928 */
  9586. -32605, /* A2 = 0.995056 */
  9587. 23667, /* B2 = 0.722260 */
  9588. -4297, /* B1 = -0.262329 */
  9589. 23667, /* B0 = 0.722260 */
  9590. 5, /* Internal filter scaling */
  9591. 159, /* Minimum in-band energy threshold */
  9592. 21, /* 21/32 in-band to broad-band ratio */
  9593. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9594. },
  9595. { /* f1860 */
  9596. 3569, /* A1 = -0.217865 */
  9597. -32292, /* A2 = 0.985504 */
  9598. -239, /* B2 = -0.007322 */
  9599. 0, /* B1 = 0.000000 */
  9600. 239, /* B0 = 0.007322 */
  9601. 3117, /* A1 = -0.190277 */
  9602. -32603, /* A2 = 0.994965 */
  9603. 18658, /* B2 = 0.569427 */
  9604. -1557, /* B1 = -0.095032 */
  9605. 18658, /* B0 = 0.569427 */
  9606. 4054, /* A1 = -0.247437 */
  9607. -32603, /* A2 = 0.994965 */
  9608. 18886, /* B2 = 0.576385 */
  9609. -2566, /* B1 = -0.156647 */
  9610. 18886, /* B0 = 0.576385 */
  9611. 5, /* Internal filter scaling */
  9612. 159, /* Minimum in-band energy threshold */
  9613. 21, /* 21/32 in-band to broad-band ratio */
  9614. 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
  9615. },
  9616. };
  9617. static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf)
  9618. {
  9619. unsigned short cmd;
  9620. int cnt, max;
  9621. if (jf->filter > 3) {
  9622. return -1;
  9623. }
  9624. if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) /* Select Filter */
  9625. return -1;
  9626. if (!jf->enable) {
  9627. if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
  9628. return -1;
  9629. else
  9630. return 0;
  9631. } else {
  9632. if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
  9633. return -1;
  9634. /* Select the filter (f0 - f3) to use. */
  9635. if (ixj_WriteDSPCommand(0x5154 + jf->filter, j))
  9636. return -1;
  9637. }
  9638. if (jf->freq < 12 && jf->freq > 3) {
  9639. /* Select the frequency for the selected filter. */
  9640. if (ixj_WriteDSPCommand(0x5170 + jf->freq, j))
  9641. return -1;
  9642. } else if (jf->freq > 11) {
  9643. /* We need to load a programmable filter set for undefined */
  9644. /* frequencies. So we will point the filter to a programmable set. */
  9645. /* Since there are only 4 filters and 4 programmable sets, we will */
  9646. /* just point the filter to the same number set and program it for the */
  9647. /* frequency we want. */
  9648. if (ixj_WriteDSPCommand(0x5170 + jf->filter, j))
  9649. return -1;
  9650. if (j->ver.low != 0x12) {
  9651. cmd = 0x515B;
  9652. max = 19;
  9653. } else {
  9654. cmd = 0x515E;
  9655. max = 15;
  9656. }
  9657. if (ixj_WriteDSPCommand(cmd, j))
  9658. return -1;
  9659. for (cnt = 0; cnt < max; cnt++) {
  9660. if (ixj_WriteDSPCommand(tone_table[jf->freq - 12][cnt], j))
  9661. return -1;
  9662. }
  9663. }
  9664. j->filter_en[jf->filter] = jf->enable;
  9665. return 0;
  9666. }
  9667. static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr)
  9668. {
  9669. unsigned short cmd;
  9670. int cnt, max;
  9671. if (jfr->filter > 3) {
  9672. return -1;
  9673. }
  9674. if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) /* Select Filter */
  9675. return -1;
  9676. if (!jfr->enable) {
  9677. if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
  9678. return -1;
  9679. else
  9680. return 0;
  9681. } else {
  9682. if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
  9683. return -1;
  9684. /* Select the filter (f0 - f3) to use. */
  9685. if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j))
  9686. return -1;
  9687. }
  9688. /* We need to load a programmable filter set for undefined */
  9689. /* frequencies. So we will point the filter to a programmable set. */
  9690. /* Since there are only 4 filters and 4 programmable sets, we will */
  9691. /* just point the filter to the same number set and program it for the */
  9692. /* frequency we want. */
  9693. if (ixj_WriteDSPCommand(0x5170 + jfr->filter, j))
  9694. return -1;
  9695. if (j->ver.low != 0x12) {
  9696. cmd = 0x515B;
  9697. max = 19;
  9698. } else {
  9699. cmd = 0x515E;
  9700. max = 15;
  9701. }
  9702. if (ixj_WriteDSPCommand(cmd, j))
  9703. return -1;
  9704. for (cnt = 0; cnt < max; cnt++) {
  9705. if (ixj_WriteDSPCommand(jfr->coeff[cnt], j))
  9706. return -1;
  9707. }
  9708. j->filter_en[jfr->filter] = jfr->enable;
  9709. return 0;
  9710. }
  9711. static int ixj_init_tone(IXJ *j, IXJ_TONE * ti)
  9712. {
  9713. int freq0, freq1;
  9714. unsigned short data;
  9715. if (ti->freq0) {
  9716. freq0 = ti->freq0;
  9717. } else {
  9718. freq0 = 0x7FFF;
  9719. }
  9720. if (ti->freq1) {
  9721. freq1 = ti->freq1;
  9722. } else {
  9723. freq1 = 0x7FFF;
  9724. }
  9725. if(ti->tone_index > 12 && ti->tone_index < 28)
  9726. {
  9727. if (ixj_WriteDSPCommand(0x6800 + ti->tone_index, j))
  9728. return -1;
  9729. if (ixj_WriteDSPCommand(0x6000 + (ti->gain1 << 4) + ti->gain0, j))
  9730. return -1;
  9731. data = freq0;
  9732. if (ixj_WriteDSPCommand(data, j))
  9733. return -1;
  9734. data = freq1;
  9735. if (ixj_WriteDSPCommand(data, j))
  9736. return -1;
  9737. }
  9738. return freq0;
  9739. }