12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162 |
- /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #define DRIVER_AUTHOR "Archana Ramchandran <archanar@codeaurora.org>"
- #define DRIVER_NAME "radio-iris"
- #define DRIVER_CARD "Qualcomm FM Radio Transceiver"
- #define DRIVER_DESC "Driver for Qualcomm FM Radio Transceiver "
- #include <linux/version.h>
- #include <linux/init.h>
- #include <linux/delay.h>
- #include <linux/uaccess.h>
- #include <linux/kfifo.h>
- #include <linux/param.h>
- #include <linux/interrupt.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/sched.h>
- #include <linux/version.h>
- #include <linux/videodev2.h>
- #include <linux/mutex.h>
- #include <linux/unistd.h>
- #include <linux/atomic.h>
- #include <linux/platform_device.h>
- #include <linux/workqueue.h>
- #include <linux/slab.h>
- #include <media/v4l2-common.h>
- #include <media/v4l2-ioctl.h>
- #include <media/radio-iris.h>
- #include <asm/unaligned.h>
- static unsigned int rds_buf = 100;
- static int oda_agt;
- static int grp_mask;
- static int rt_plus_carrier = -1;
- static int ert_carrier = -1;
- static unsigned char ert_buf[256];
- static unsigned char ert_len;
- static unsigned char c_byt_pair_index;
- static char utf_8_flag;
- static char rt_ert_flag;
- static char formatting_dir;
- static unsigned char sig_blend = CTRL_ON;
- static DEFINE_MUTEX(iris_fm);
- module_param(rds_buf, uint, 0);
- MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*");
- module_param(sig_blend, byte, S_IWUSR | S_IRUGO);
- MODULE_PARM_DESC(sig_blend, "signal blending switch: 0:OFF 1:ON");
- static void radio_hci_cmd_task(unsigned long arg);
- static void radio_hci_rx_task(unsigned long arg);
- static struct video_device *video_get_dev(void);
- static DEFINE_RWLOCK(hci_task_lock);
- extern struct mutex fm_smd_enable;
- typedef int (*radio_hci_request_func)(struct radio_hci_dev *hdev,
- int (*req)(struct
- radio_hci_dev * hdev, unsigned long param),
- unsigned long param, __u32 timeout);
- struct iris_device {
- struct device *dev;
- struct kfifo data_buf[IRIS_BUF_MAX];
- int pending_xfrs[IRIS_XFR_MAX];
- int xfr_bytes_left;
- int xfr_in_progress;
- struct completion sync_xfr_start;
- int tune_req;
- unsigned int mode;
- int is_fm_closing;
- __u16 pi;
- __u8 pty;
- __u8 ps_repeatcount;
- __u8 prev_trans_rds;
- __u8 af_jump_bit;
- struct video_device *videodev;
- struct mutex lock;
- spinlock_t buf_lock[IRIS_BUF_MAX];
- wait_queue_head_t event_queue;
- wait_queue_head_t read_queue;
- struct radio_hci_dev *fm_hdev;
- struct v4l2_capability *g_cap;
- struct v4l2_control *g_ctl;
- struct hci_fm_mute_mode_req mute_mode;
- struct hci_fm_stereo_mode_req stereo_mode;
- struct hci_fm_station_rsp fm_st_rsp;
- struct hci_fm_search_station_req srch_st;
- struct hci_fm_search_rds_station_req srch_rds;
- struct hci_fm_search_station_list_req srch_st_list;
- struct hci_fm_recv_conf_req recv_conf;
- struct hci_fm_trans_conf_req_struct trans_conf;
- struct hci_fm_rds_grp_req rds_grp;
- unsigned char g_search_mode;
- unsigned char power_mode;
- int search_on;
- unsigned int tone_freq;
- unsigned char spur_table_size;
- unsigned char g_scan_time;
- unsigned int g_antenna;
- unsigned int g_rds_grp_proc_ps;
- unsigned char event_mask;
- enum iris_region_t region;
- struct hci_fm_dbg_param_rsp st_dbg_param;
- struct hci_ev_srch_list_compl srch_st_result;
- struct hci_fm_riva_poke riva_data_req;
- struct hci_fm_ssbi_req ssbi_data_accs;
- struct hci_fm_ssbi_peek ssbi_peek_reg;
- struct hci_fm_sig_threshold_rsp sig_th;
- struct hci_fm_ch_det_threshold ch_det_threshold;
- struct hci_fm_data_rd_rsp default_data;
- struct hci_fm_spur_data spur_data;
- unsigned char is_station_valid;
- struct hci_fm_blend_table blend_tbl;
- char is_rds_grp_3A_enabled;
- char is_ert_enabled;
- char is_rt_plus_enabled;
- };
- static struct video_device *priv_videodev;
- static int iris_do_calibration(struct iris_device *radio);
- static void hci_buff_ert(struct iris_device *radio,
- struct rds_grp_data *rds_buf);
- static void hci_ev_rt_plus(struct iris_device *radio,
- struct rds_grp_data rds_buf);
- static void hci_ev_ert(struct iris_device *radio);
- static int update_spur_table(struct iris_device *radio);
- static int initialise_recv(struct iris_device *radio);
- static int initialise_trans(struct iris_device *radio);
- static int is_enable_rx_possible(struct iris_device *radio);
- static int is_enable_tx_possible(struct iris_device *radio);
- static struct v4l2_queryctrl iris_v4l2_queryctrl[] = {
- {
- .id = V4L2_CID_AUDIO_VOLUME,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Volume",
- .minimum = 0,
- .maximum = 15,
- .step = 1,
- .default_value = 15,
- },
- {
- .id = V4L2_CID_AUDIO_BALANCE,
- .flags = V4L2_CTRL_FLAG_DISABLED,
- },
- {
- .id = V4L2_CID_AUDIO_BASS,
- .flags = V4L2_CTRL_FLAG_DISABLED,
- },
- {
- .id = V4L2_CID_AUDIO_TREBLE,
- .flags = V4L2_CTRL_FLAG_DISABLED,
- },
- {
- .id = V4L2_CID_AUDIO_MUTE,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Mute",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 1,
- },
- {
- .id = V4L2_CID_AUDIO_LOUDNESS,
- .flags = V4L2_CTRL_FLAG_DISABLED,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SRCHMODE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Search mode",
- .minimum = 0,
- .maximum = 7,
- .step = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SCANDWELL,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Search dwell time",
- .minimum = 0,
- .maximum = 7,
- .step = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SRCHON,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Search on/off",
- .minimum = 0,
- .maximum = 1,
- .step = 1,
- .default_value = 1,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_STATE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "radio 0ff/rx/tx/reset",
- .minimum = 0,
- .maximum = 3,
- .step = 1,
- .default_value = 1,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_REGION,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "radio standard",
- .minimum = 0,
- .maximum = 2,
- .step = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SIGNAL_TH,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Signal Threshold",
- .minimum = 0x80,
- .maximum = 0x7F,
- .step = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SRCH_PTY,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Search PTY",
- .minimum = 0,
- .maximum = 31,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SRCH_PI,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Search PI",
- .minimum = 0,
- .maximum = 0xFF,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SRCH_CNT,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Preset num",
- .minimum = 0,
- .maximum = 12,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_EMPHASIS,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Emphasis",
- .minimum = 0,
- .maximum = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RDS_STD,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "RDS standard",
- .minimum = 0,
- .maximum = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SPACING,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Channel spacing",
- .minimum = 0,
- .maximum = 2,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RDSON,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "RDS on/off",
- .minimum = 0,
- .maximum = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RDSGROUP_MASK,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "RDS group mask",
- .minimum = 0,
- .maximum = 0xFFFFFFFF,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RDSGROUP_PROC,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "RDS processing",
- .minimum = 0,
- .maximum = 0xFF,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RDSD_BUF,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "RDS data groups to buffer",
- .minimum = 1,
- .maximum = 21,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_PSALL,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "pass all ps strings",
- .minimum = 0,
- .maximum = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_LP_MODE,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Low power mode",
- .minimum = 0,
- .maximum = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_ANTENNA,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "headset/internal",
- .minimum = 0,
- .maximum = 1,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_TX_SETPSREPEATCOUNT,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Set PS REPEATCOUNT",
- .minimum = 0,
- .maximum = 15,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_PS_NAME,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Stop PS NAME",
- .minimum = 0,
- .maximum = 1,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_RT,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Stop RT",
- .minimum = 0,
- .maximum = 1,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SOFT_MUTE,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Soft Mute",
- .minimum = 0,
- .maximum = 1,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Riva addr",
- .minimum = 0x3180000,
- .maximum = 0x31E0004,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Data len",
- .minimum = 0,
- .maximum = 0xFF,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RIVA_PEEK,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "Riva peek",
- .minimum = 0,
- .maximum = 1,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RIVA_POKE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Riva poke",
- .minimum = 0x3180000,
- .maximum = 0x31E0004,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Ssbi addr",
- .minimum = 0x280,
- .maximum = 0x37F,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SSBI_PEEK,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Ssbi peek",
- .minimum = 0,
- .maximum = 0x37F,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SSBI_POKE,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "ssbi poke",
- .minimum = 0x01,
- .maximum = 0xFF,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_HLSI,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "set hlsi",
- .minimum = 0,
- .maximum = 2,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "RDS grp",
- .minimum = 0,
- .maximum = 1,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Notch filter",
- .minimum = 0,
- .maximum = 2,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_READ_DEFAULT,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Read default",
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Write default",
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_SET_CALIBRATION,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "SET Calibration",
- .minimum = 0,
- .maximum = 1,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_DO_CALIBRATION,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .name = "SET Calibration",
- .minimum = 0,
- .maximum = 1,
- },
- {
- .id = V4L2_CID_PRIVATE_IRIS_GET_SINR,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "GET SINR",
- .minimum = -128,
- .maximum = 127,
- },
- {
- .id = V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Intf High Threshold",
- .minimum = 0,
- .maximum = 0xFF,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "Intf low Threshold",
- .minimum = 0,
- .maximum = 0xFF,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_SINR_THRESHOLD,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "SINR Threshold",
- .minimum = -128,
- .maximum = 127,
- .default_value = 0,
- },
- {
- .id = V4L2_CID_PRIVATE_SINR_SAMPLES,
- .type = V4L2_CTRL_TYPE_INTEGER,
- .name = "SINR samples",
- .minimum = 1,
- .maximum = 0xFF,
- .default_value = 0,
- },
- };
- static void iris_q_event(struct iris_device *radio,
- enum iris_evt_t event)
- {
- struct kfifo *data_b = &radio->data_buf[IRIS_BUF_EVENTS];
- unsigned char evt = event;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- if (kfifo_in_locked(data_b, &evt, 1, &radio->buf_lock[IRIS_BUF_EVENTS]))
- wake_up_interruptible(&radio->event_queue);
- }
- static int hci_send_frame(struct sk_buff *skb)
- {
- struct radio_hci_dev *hdev = (struct radio_hci_dev *) skb->dev;
- if (!hdev) {
- kfree_skb(skb);
- return -ENODEV;
- }
- __net_timestamp(skb);
- skb_orphan(skb);
- return hdev->send(skb);
- }
- static void radio_hci_cmd_task(unsigned long arg)
- {
- struct radio_hci_dev *hdev = (struct radio_hci_dev *) arg;
- struct sk_buff *skb;
- if (!(atomic_read(&hdev->cmd_cnt))
- && time_after(jiffies, hdev->cmd_last_tx + HZ)) {
- FMDERR("%s command tx timeout", hdev->name);
- atomic_set(&hdev->cmd_cnt, 1);
- }
- skb = skb_dequeue(&hdev->cmd_q);
- if (atomic_read(&hdev->cmd_cnt) && skb) {
- kfree_skb(hdev->sent_cmd);
- hdev->sent_cmd = skb_clone(skb, GFP_ATOMIC);
- if (hdev->sent_cmd) {
- atomic_dec(&hdev->cmd_cnt);
- hci_send_frame(skb);
- hdev->cmd_last_tx = jiffies;
- } else {
- skb_queue_head(&hdev->cmd_q, skb);
- tasklet_schedule(&hdev->cmd_task);
- }
- }
- }
- static void radio_hci_rx_task(unsigned long arg)
- {
- struct radio_hci_dev *hdev = (struct radio_hci_dev *) arg;
- struct sk_buff *skb;
- read_lock(&hci_task_lock);
- skb = skb_dequeue(&hdev->rx_q);
- radio_hci_event_packet(hdev, skb);
- read_unlock(&hci_task_lock);
- }
- int radio_hci_register_dev(struct radio_hci_dev *hdev)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- if (!radio) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- if (!hdev) {
- FMDERR("hdev is null");
- return -EINVAL;
- }
- hdev->flags = 0;
- tasklet_init(&hdev->cmd_task, radio_hci_cmd_task, (unsigned long)
- hdev);
- tasklet_init(&hdev->rx_task, radio_hci_rx_task, (unsigned long)
- hdev);
- init_waitqueue_head(&hdev->req_wait_q);
- skb_queue_head_init(&hdev->rx_q);
- skb_queue_head_init(&hdev->cmd_q);
- skb_queue_head_init(&hdev->raw_q);
- if (!radio)
- FMDERR(":radio is null");
- radio->fm_hdev = hdev;
- return 0;
- }
- EXPORT_SYMBOL(radio_hci_register_dev);
- int radio_hci_unregister_dev(void)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- struct radio_hci_dev *hdev = NULL;
- if (!radio && !radio->fm_hdev) {
- FMDERR("radio/hdev is null");
- return -EINVAL;
- }
- hdev = radio->fm_hdev;
- tasklet_kill(&hdev->rx_task);
- tasklet_kill(&hdev->cmd_task);
- skb_queue_purge(&hdev->rx_q);
- skb_queue_purge(&hdev->cmd_q);
- skb_queue_purge(&hdev->raw_q);
- radio->fm_hdev = NULL;
- return 0;
- }
- EXPORT_SYMBOL(radio_hci_unregister_dev);
- int radio_hci_recv_frame(struct sk_buff *skb)
- {
- struct radio_hci_dev *hdev = (struct radio_hci_dev *) skb->dev;
- if (!hdev) {
- FMDERR("%s hdev is null while receiving frame", hdev->name);
- kfree_skb(skb);
- return -ENXIO;
- }
- __net_timestamp(skb);
- radio_hci_event_packet(hdev, skb);
- kfree_skb(skb);
- return 0;
- }
- EXPORT_SYMBOL(radio_hci_recv_frame);
- int radio_hci_send_cmd(struct radio_hci_dev *hdev, __u16 opcode, __u32 plen,
- void *param)
- {
- int len = RADIO_HCI_COMMAND_HDR_SIZE + plen;
- struct radio_hci_command_hdr *hdr;
- struct sk_buff *skb;
- int ret = 0;
- skb = alloc_skb(len, GFP_ATOMIC);
- if (!skb) {
- FMDERR("%s no memory for command", hdev->name);
- return -ENOMEM;
- }
- hdr = (struct radio_hci_command_hdr *) skb_put(skb,
- RADIO_HCI_COMMAND_HDR_SIZE);
- hdr->opcode = cpu_to_le16(opcode);
- hdr->plen = plen;
- if (plen)
- memcpy(skb_put(skb, plen), param, plen);
- skb->dev = (void *) hdev;
- ret = hci_send_frame(skb);
- return ret;
- }
- EXPORT_SYMBOL(radio_hci_send_cmd);
- static int hci_fm_enable_recv_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_ENABLE_RECV_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_tone_generator(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- __u16 opcode = 0;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ,
- HCI_FM_SET_INTERNAL_TONE_GENRATOR);
- return radio_hci_send_cmd(hdev, opcode,
- sizeof(radio->tone_freq), &radio->tone_freq);
- }
- static int hci_fm_enable_trans_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ,
- HCI_OCF_FM_ENABLE_TRANS_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_disable_recv_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_DISABLE_RECV_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_disable_trans_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ,
- HCI_OCF_FM_DISABLE_TRANS_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_get_fm_recv_conf_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_RECV_CONF_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_get_fm_trans_conf_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_TRANS_CONF_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_set_fm_recv_conf_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_recv_conf_req *recv_conf_req =
- (struct hci_fm_recv_conf_req *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_RECV_CONF_REQ);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*recv_conf_req)),
- recv_conf_req);
- }
- static int hci_set_fm_trans_conf_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_trans_conf_req_struct *trans_conf_req =
- (struct hci_fm_trans_conf_req_struct *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_TRANS_CONF_REQ);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*trans_conf_req)),
- trans_conf_req);
- }
- static int hci_fm_get_station_param_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_STATION_PARAM_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_set_fm_mute_mode_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_mute_mode_req *mute_mode_req =
- (struct hci_fm_mute_mode_req *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_MUTE_MODE_REQ);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*mute_mode_req)),
- mute_mode_req);
- }
- static int hci_trans_ps_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_tx_ps *tx_ps_req =
- (struct hci_fm_tx_ps *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ,
- HCI_OCF_FM_RDS_PS_REQ);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*tx_ps_req)),
- tx_ps_req);
- }
- static int hci_trans_rt_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_tx_rt *tx_rt_req =
- (struct hci_fm_tx_rt *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ,
- HCI_OCF_FM_RDS_RT_REQ);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*tx_rt_req)),
- tx_rt_req);
- }
- static int hci_set_fm_stereo_mode_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_stereo_mode_req *stereo_mode_req =
- (struct hci_fm_stereo_mode_req *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_STEREO_MODE_REQ);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*stereo_mode_req)),
- stereo_mode_req);
- }
- static int hci_fm_set_antenna_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- __u8 antenna = param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_ANTENNA);
- return radio_hci_send_cmd(hdev, opcode, sizeof(antenna), &antenna);
- }
- static int hci_fm_set_sig_threshold_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- __u8 sig_threshold = param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_SIGNAL_THRESHOLD);
- return radio_hci_send_cmd(hdev, opcode, sizeof(sig_threshold),
- &sig_threshold);
- }
- static int hci_fm_set_event_mask(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- u16 opcode = 0;
- u8 event_mask = param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_EVENT_MASK);
- return radio_hci_send_cmd(hdev, opcode, sizeof(event_mask),
- &event_mask);
- }
- static int hci_fm_get_sig_threshold_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_SIGNAL_THRESHOLD);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_get_program_service_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_get_radio_text_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_RADIO_TEXT_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_get_af_list_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_AF_LIST_REQ);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_search_stations_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_search_station_req *srch_stations =
- (struct hci_fm_search_station_req *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SEARCH_STATIONS);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*srch_stations)),
- srch_stations);
- }
- static int hci_fm_srch_rds_stations_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_search_rds_station_req *srch_stations =
- (struct hci_fm_search_rds_station_req *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SEARCH_RDS_STATIONS);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*srch_stations)),
- srch_stations);
- }
- static int hci_fm_srch_station_list_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_search_station_list_req *srch_list =
- (struct hci_fm_search_station_list_req *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SEARCH_STATIONS_LIST);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*srch_list)),
- srch_list);
- }
- static int hci_fm_cancel_search_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_CANCEL_SEARCH);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_rds_grp_mask_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_rds_grp_req *fm_grp_mask =
- (struct hci_fm_rds_grp_req *)param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_RDS_GRP);
- return radio_hci_send_cmd(hdev, opcode, sizeof(*fm_grp_mask),
- fm_grp_mask);
- }
- static int hci_fm_rds_grp_process_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- __u32 fm_grps_process = param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_RDS_GRP_PROCESS);
- return radio_hci_send_cmd(hdev, opcode, sizeof(fm_grps_process),
- &fm_grps_process);
- }
- static int hci_fm_tune_station_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- __u32 tune_freq = param;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_TUNE_STATION_REQ);
- return radio_hci_send_cmd(hdev, opcode, sizeof(tune_freq), &tune_freq);
- }
- static int hci_def_data_read_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_def_data_rd_req *def_data_rd =
- (struct hci_fm_def_data_rd_req *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_DEFAULT_DATA_READ);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*def_data_rd)),
- def_data_rd);
- }
- static int hci_def_data_write_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_def_data_wr_req *def_data_wr =
- (struct hci_fm_def_data_wr_req *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_DEFAULT_DATA_WRITE);
- return radio_hci_send_cmd(hdev, opcode, (def_data_wr->length+2),
- def_data_wr);
- }
- static int hci_set_notch_filter_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- __u8 notch_filter_val = param;
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_EN_NOTCH_CTRL);
- return radio_hci_send_cmd(hdev, opcode, sizeof(notch_filter_val),
- ¬ch_filter_val);
- }
- static int hci_fm_reset_req(struct radio_hci_dev *hdev, unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_RESET);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_get_feature_lists_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_FEATURE_LIST);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_do_calibration_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- __u8 mode = param;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_DO_CALIBRATION);
- return radio_hci_send_cmd(hdev, opcode, sizeof(mode), &mode);
- }
- static int hci_read_grp_counters_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- __u8 reset_counters = param;
- opcode = hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ,
- HCI_OCF_FM_READ_GRP_COUNTERS);
- return radio_hci_send_cmd(hdev, opcode, sizeof(reset_counters),
- &reset_counters);
- }
- static int hci_peek_data_req(struct radio_hci_dev *hdev, unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_riva_data *peek_data = (struct hci_fm_riva_data *)param;
- opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ,
- HCI_OCF_FM_PEEK_DATA);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*peek_data)),
- peek_data);
- }
- static int hci_poke_data_req(struct radio_hci_dev *hdev, unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_riva_poke *poke_data = (struct hci_fm_riva_poke *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ,
- HCI_OCF_FM_POKE_DATA);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*poke_data)),
- poke_data);
- }
- static int hci_ssbi_peek_reg_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_ssbi_peek *ssbi_peek = (struct hci_fm_ssbi_peek *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ,
- HCI_OCF_FM_SSBI_PEEK_REG);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*ssbi_peek)),
- ssbi_peek);
- }
- static int hci_ssbi_poke_reg_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- struct hci_fm_ssbi_req *ssbi_poke = (struct hci_fm_ssbi_req *) param;
- opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ,
- HCI_OCF_FM_SSBI_POKE_REG);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*ssbi_poke)),
- ssbi_poke);
- }
- static int hci_fm_get_station_dbg_param_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- __u16 opcode = 0;
- opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ,
- HCI_OCF_FM_STATION_DBG_PARAM);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_set_ch_det_th(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- struct hci_fm_ch_det_threshold *ch_det_th =
- (struct hci_fm_ch_det_threshold *) param;
- u16 opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_CH_DET_THRESHOLD);
- return radio_hci_send_cmd(hdev, opcode, sizeof((*ch_det_th)),
- ch_det_th);
- }
- static int hci_fm_get_ch_det_th(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- u16 opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_CH_DET_THRESHOLD);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_get_blend_tbl(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- u16 opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_BLND_TBL);
- return radio_hci_send_cmd(hdev, opcode, 0, NULL);
- }
- static int hci_fm_set_blend_tbl(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- struct hci_fm_blend_table *blnd_tbl =
- (struct hci_fm_blend_table *) param;
- u16 opcode;
- if (blnd_tbl == NULL) {
- FMDERR("%s, blend tbl is null\n", __func__);
- return -EINVAL;
- }
- opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_BLND_TBL);
- return radio_hci_send_cmd(hdev, opcode,
- sizeof(struct hci_fm_blend_table), blnd_tbl);
- }
- static int radio_hci_err(__u32 code)
- {
- switch (code) {
- case 0:
- return 0;
- case 0x01:
- return -EBADRQC;
- case 0x02:
- return -ENOTCONN;
- case 0x03:
- return -EIO;
- case 0x07:
- return -ENOMEM;
- case 0x0c:
- return -EBUSY;
- case 0x11:
- return -EOPNOTSUPP;
- case 0x12:
- return -EINVAL;
- default:
- return -ENOSYS;
- }
- }
- static int __radio_hci_request(struct radio_hci_dev *hdev,
- int (*req)(struct radio_hci_dev *hdev,
- unsigned long param),
- unsigned long param, __u32 timeout, int interruptible)
- {
- int err = 0;
- DECLARE_WAITQUEUE(wait, current);
- mutex_lock(&iris_fm);
- hdev->req_status = HCI_REQ_PEND;
- add_wait_queue(&hdev->req_wait_q, &wait);
- if (interruptible)
- set_current_state(TASK_INTERRUPTIBLE);
- else
- set_current_state(TASK_UNINTERRUPTIBLE);
- err = req(hdev, param);
- schedule_timeout(msecs_to_jiffies(timeout));
- remove_wait_queue(&hdev->req_wait_q, &wait);
- if (interruptible && signal_pending(current)) {
- mutex_unlock(&iris_fm);
- return -EINTR;
- }
- switch (hdev->req_status) {
- case HCI_REQ_DONE:
- case HCI_REQ_STATUS:
- err = radio_hci_err(hdev->req_result);
- break;
- case HCI_REQ_CANCELED:
- err = -hdev->req_result;
- break;
- default:
- err = -ETIMEDOUT;
- break;
- }
- hdev->req_status = hdev->req_result = 0;
- mutex_unlock(&iris_fm);
- return err;
- }
- static inline int radio_hci_request_interruptible(struct radio_hci_dev *hdev,
- int (*req)(struct
- radio_hci_dev * hdev, unsigned long param),
- unsigned long param, __u32 timeout)
- {
- int ret = 0;
- ret = __radio_hci_request(hdev, req, param, timeout, 1);
- return ret;
- }
- static inline int radio_hci_request_uninterruptible(struct radio_hci_dev *hdev,
- int (*req)(struct
- radio_hci_dev * hdev, unsigned long param),
- unsigned long param, __u32 timeout)
- {
- int ret = 0;
- ret = __radio_hci_request(hdev, req, param, timeout, 0);
- return ret;
- }
- static inline int radio_hci_request(struct radio_hci_dev *hdev,
- int (*req)(struct
- radio_hci_dev * hdev, unsigned long param),
- unsigned long param, __u32 timeout)
- {
- return radio_hci_request_interruptible(hdev, req, param, timeout);
- }
- static inline int hci_conf_event_mask(__u8 *arg,
- struct radio_hci_dev *hdev)
- {
- u8 event_mask = *arg;
- return radio_hci_request(hdev, hci_fm_set_event_mask,
- event_mask, RADIO_HCI_TIMEOUT);
- }
- static int hci_set_fm_recv_conf(struct hci_fm_recv_conf_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_recv_conf_req *set_recv_conf = arg;
- ret = radio_hci_request(hdev, hci_set_fm_recv_conf_req, (unsigned
- long)set_recv_conf, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_set_fm_trans_conf(struct hci_fm_trans_conf_req_struct *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_trans_conf_req_struct *set_trans_conf = arg;
- ret = radio_hci_request(hdev, hci_set_fm_trans_conf_req, (unsigned
- long)set_trans_conf, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_fm_tune_station(__u32 *arg, struct radio_hci_dev *hdev)
- {
- int ret = 0;
- __u32 tune_freq = *arg;
- ret = radio_hci_request(hdev, hci_fm_tune_station_req, tune_freq,
- RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_set_fm_mute_mode(struct hci_fm_mute_mode_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_mute_mode_req *set_mute_conf = arg;
- ret = radio_hci_request(hdev, hci_set_fm_mute_mode_req, (unsigned
- long)set_mute_conf, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_set_fm_stereo_mode(struct hci_fm_stereo_mode_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_stereo_mode_req *set_stereo_conf = arg;
- ret = radio_hci_request(hdev, hci_set_fm_stereo_mode_req, (unsigned
- long)set_stereo_conf, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_fm_set_antenna(__u8 *arg, struct radio_hci_dev *hdev)
- {
- int ret = 0;
- __u8 antenna = *arg;
- ret = radio_hci_request(hdev, hci_fm_set_antenna_req, antenna,
- RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_fm_set_signal_threshold(__u8 *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- __u8 sig_threshold = *arg;
- ret = radio_hci_request(hdev, hci_fm_set_sig_threshold_req,
- sig_threshold, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_fm_search_stations(struct hci_fm_search_station_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_search_station_req *srch_stations = arg;
- ret = radio_hci_request(hdev, hci_fm_search_stations_req, (unsigned
- long)srch_stations, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_fm_search_rds_stations(struct hci_fm_search_rds_station_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_search_rds_station_req *srch_stations = arg;
- ret = radio_hci_request(hdev, hci_fm_srch_rds_stations_req, (unsigned
- long)srch_stations, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_fm_search_station_list
- (struct hci_fm_search_station_list_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_search_station_list_req *srch_list = arg;
- ret = radio_hci_request(hdev, hci_fm_srch_station_list_req, (unsigned
- long)srch_list, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_fm_rds_grp(struct hci_fm_rds_grp_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_rds_grp_req *fm_grp_mask = arg;
- ret = radio_hci_request(hdev, hci_fm_rds_grp_mask_req, (unsigned
- long)fm_grp_mask, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_fm_rds_grps_process(__u32 *arg, struct radio_hci_dev *hdev)
- {
- int ret = 0;
- __u32 fm_grps_process = *arg;
- ret = radio_hci_request(hdev, hci_fm_rds_grp_process_req,
- fm_grps_process, RADIO_HCI_TIMEOUT);
- return ret;
- }
- int hci_def_data_read(struct hci_fm_def_data_rd_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_def_data_rd_req *def_data_rd = arg;
- ret = radio_hci_request(hdev, hci_def_data_read_req, (unsigned
- long)def_data_rd, RADIO_HCI_TIMEOUT);
- return ret;
- }
- int hci_def_data_write(struct hci_fm_def_data_wr_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_def_data_wr_req *def_data_wr = arg;
- ret = radio_hci_request(hdev, hci_def_data_write_req, (unsigned
- long)def_data_wr, RADIO_HCI_TIMEOUT);
- return ret;
- }
- int hci_fm_do_calibration(__u8 *arg, struct radio_hci_dev *hdev)
- {
- int ret = 0;
- __u8 mode = *arg;
- ret = radio_hci_request(hdev, hci_fm_do_calibration_req, mode,
- RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_read_grp_counters(__u8 *arg, struct radio_hci_dev *hdev)
- {
- int ret = 0;
- __u8 reset_counters = *arg;
- ret = radio_hci_request(hdev, hci_read_grp_counters_req,
- reset_counters, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_set_notch_filter(__u8 *arg, struct radio_hci_dev *hdev)
- {
- int ret = 0;
- __u8 notch_filter = *arg;
- ret = radio_hci_request(hdev, hci_set_notch_filter_req,
- notch_filter, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_peek_data(struct hci_fm_riva_data *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_riva_data *peek_data = arg;
- ret = radio_hci_request(hdev, hci_peek_data_req, (unsigned
- long)peek_data, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_poke_data(struct hci_fm_riva_poke *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_riva_poke *poke_data = arg;
- ret = radio_hci_request(hdev, hci_poke_data_req, (unsigned
- long)poke_data, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_ssbi_peek_reg(struct hci_fm_ssbi_peek *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_ssbi_peek *ssbi_peek_reg = arg;
- ret = radio_hci_request(hdev, hci_ssbi_peek_reg_req, (unsigned
- long)ssbi_peek_reg, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_ssbi_poke_reg(struct hci_fm_ssbi_req *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_ssbi_req *ssbi_poke_reg = arg;
- ret = radio_hci_request(hdev, hci_ssbi_poke_reg_req, (unsigned
- long)ssbi_poke_reg, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_set_ch_det_thresholds_req(struct hci_fm_ch_det_threshold *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_ch_det_threshold *ch_det_threshold = arg;
- ret = radio_hci_request(hdev, hci_fm_set_ch_det_th,
- (unsigned long)ch_det_threshold, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_fm_set_cal_req_proc(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- u16 opcode = 0;
- struct hci_fm_set_cal_req_proc *cal_req =
- (struct hci_fm_set_cal_req_proc *)param;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_CALIBRATION);
- return radio_hci_send_cmd(hdev, opcode,
- sizeof(struct hci_fm_set_cal_req_proc), cal_req);
- }
- static int hci_fm_do_cal_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- u16 opcode = 0;
- u8 cal_mode = param;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_DO_CALIBRATION);
- return radio_hci_send_cmd(hdev, opcode, sizeof(cal_mode),
- &cal_mode);
- }
- static int hci_fm_set_spur_tbl_req(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- u16 opcode = 0, len = 0;
- struct hci_fm_set_spur_table_req *spur_req =
- (struct hci_fm_set_spur_table_req *)param;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_SET_SPUR_TABLE);
- if (spur_req->no_of_freqs_entries > ENTRIES_EACH_CMD)
- len = (ENTRIES_EACH_CMD * SPUR_DATA_LEN)
- + SPUR_DATA_INDEX;
- else
- len = (spur_req->no_of_freqs_entries * SPUR_DATA_LEN)
- + SPUR_DATA_INDEX;
- return radio_hci_send_cmd(hdev, opcode, len, spur_req);
- }
- static int hci_fm_get_spur_tbl_data(struct radio_hci_dev *hdev,
- unsigned long param)
- {
- u16 opcode = 0;
- unsigned int spur_freq = (unsigned int)param;
- opcode = hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ,
- HCI_OCF_FM_GET_SPUR_TABLE);
- return radio_hci_send_cmd(hdev, opcode, sizeof(int), &spur_freq);
- }
- static int hci_set_blend_tbl_req(struct hci_fm_blend_table *arg,
- struct radio_hci_dev *hdev)
- {
- int ret = 0;
- struct hci_fm_blend_table *blend_tbl = arg;
- ret = radio_hci_request(hdev, hci_fm_set_blend_tbl,
- (unsigned long)blend_tbl, RADIO_HCI_TIMEOUT);
- return ret;
- }
- static int hci_cmd_internal(unsigned int cmd, struct radio_hci_dev *hdev,
- int interruptible)
- {
- int ret = 0;
- unsigned long arg = 0;
- radio_hci_request_func radio_hci_request;
- if (!hdev)
- return -ENODEV;
- radio_hci_request = interruptible ? radio_hci_request_interruptible :
- radio_hci_request_uninterruptible;
- switch (cmd) {
- case HCI_FM_ENABLE_RECV_CMD:
- ret = radio_hci_request(hdev, hci_fm_enable_recv_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_DISABLE_RECV_CMD:
- ret = radio_hci_request(hdev, hci_fm_disable_recv_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_RECV_CONF_CMD:
- ret = radio_hci_request(hdev, hci_get_fm_recv_conf_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_STATION_PARAM_CMD:
- ret = radio_hci_request(hdev,
- hci_fm_get_station_param_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_SIGNAL_TH_CMD:
- ret = radio_hci_request(hdev,
- hci_fm_get_sig_threshold_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_PROGRAM_SERVICE_CMD:
- ret = radio_hci_request(hdev,
- hci_fm_get_program_service_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_RADIO_TEXT_CMD:
- ret = radio_hci_request(hdev, hci_fm_get_radio_text_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_AF_LIST_CMD:
- ret = radio_hci_request(hdev, hci_fm_get_af_list_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_CANCEL_SEARCH_CMD:
- ret = radio_hci_request(hdev, hci_fm_cancel_search_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_RESET_CMD:
- ret = radio_hci_request(hdev, hci_fm_reset_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_FEATURES_CMD:
- ret = radio_hci_request(hdev,
- hci_fm_get_feature_lists_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_STATION_DBG_PARAM_CMD:
- ret = radio_hci_request(hdev,
- hci_fm_get_station_dbg_param_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_ENABLE_TRANS_CMD:
- ret = radio_hci_request(hdev, hci_fm_enable_trans_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_DISABLE_TRANS_CMD:
- ret = radio_hci_request(hdev, hci_fm_disable_trans_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_TX_CONFIG:
- ret = radio_hci_request(hdev, hci_get_fm_trans_conf_req, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_DET_CH_TH_CMD:
- ret = radio_hci_request(hdev, hci_fm_get_ch_det_th, arg,
- RADIO_HCI_TIMEOUT);
- break;
- case HCI_FM_GET_BLND_TBL_CMD:
- ret = radio_hci_request(hdev, hci_fm_get_blend_tbl, arg,
- RADIO_HCI_TIMEOUT);
- break;
- default:
- ret = -EINVAL;
- break;
- }
- return ret;
- }
- static int hci_cmd(unsigned int cmd, struct radio_hci_dev *hdev)
- {
- return hci_cmd_internal(cmd, hdev, 1);
- }
- static int hci_cmd_uninterruptible(unsigned int cmd, struct radio_hci_dev *hdev)
- {
- return hci_cmd_internal(cmd, hdev, 0);
- }
- static void radio_hci_req_complete(struct radio_hci_dev *hdev, int result)
- {
- hdev->req_result = result;
- hdev->req_status = HCI_REQ_DONE;
- wake_up(&hdev->req_wait_q);
- }
- static void radio_hci_status_complete(struct radio_hci_dev *hdev, int result)
- {
- hdev->req_result = result;
- hdev->req_status = HCI_REQ_STATUS;
- wake_up(&hdev->req_wait_q);
- }
- static void hci_cc_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb)
- {
- __u8 status = *((__u8 *) skb->data);
- if (status)
- return;
- radio_hci_req_complete(hdev, status);
- }
- static void hci_cc_fm_disable_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- __u8 status = *((__u8 *) skb->data);
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- if ((radio->mode == FM_TURNING_OFF) && (status == 0)) {
- if (!radio->is_fm_closing)
- iris_q_event(radio, IRIS_EVT_RADIO_DISABLED);
- radio_hci_req_complete(hdev, status);
- radio->mode = FM_OFF;
- goto handle_rds;
- } else if (radio->mode == FM_CALIB) {
- radio_hci_req_complete(hdev, status);
- return;
- } else if ((radio->mode == FM_RECV) || (radio->mode == FM_TRANS)) {
- iris_q_event(radio, IRIS_EVT_RADIO_DISABLED);
- radio->mode = FM_OFF;
- goto handle_rds;
- } else if ((radio->mode == FM_TURNING_OFF) && (status != 0)) {
- radio_hci_req_complete(hdev, status);
- goto handle_rds;
- }
- handle_rds :
- radio->g_rds_grp_proc_ps = 0;
- memset(&radio->rds_grp, 0, sizeof(radio->rds_grp));
- grp_mask = 0;
- oda_agt = 0;
- rt_plus_carrier = -1;
- ert_carrier = -1;
- memset(ert_buf, 0, 256);
- ert_len = 0;
- c_byt_pair_index = 0;
- utf_8_flag = 0;
- rt_ert_flag = 0;
- formatting_dir = 0;
- radio->is_ert_enabled = 0;
- radio->is_rt_plus_enabled = 0;
- radio->is_rds_grp_3A_enabled = 0;
- }
- static void hci_cc_conf_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb)
- {
- struct hci_fm_conf_rsp *rsp = (void *)skb->data;
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- if (rsp->status)
- return;
- radio->recv_conf = rsp->recv_conf_rsp;
- radio_hci_req_complete(hdev, rsp->status);
- }
- static void hci_cc_fm_trans_get_conf_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct hci_fm_get_trans_conf_rsp *rsp = (void *)skb->data;
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- if (rsp->status)
- return;
- memcpy((void *)&radio->trans_conf, (void*)&rsp->trans_conf_rsp,
- sizeof(rsp->trans_conf_rsp));
- radio_hci_req_complete(hdev, rsp->status);
- }
- static void hci_cc_fm_enable_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct hci_fm_conf_rsp *rsp = (void *)skb->data;
- //struct iris_device *radio = video_get_drvdata(video_get_dev());
- if (rsp->status) {
- radio_hci_req_complete(hdev, rsp->status);
- return;
- }
-
- radio_hci_req_complete(hdev, rsp->status);
- }
- static void hci_cc_fm_trans_set_conf_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct hci_fm_conf_rsp *rsp = (void *)skb->data;
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- if (rsp->status)
- return;
- iris_q_event(radio, HCI_EV_CMD_COMPLETE);
- radio_hci_req_complete(hdev, rsp->status);
- }
- static void hci_cc_sig_threshold_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct hci_fm_sig_threshold_rsp *rsp = (void *)skb->data;
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- if (rsp->status)
- return;
- memcpy(&radio->sig_th, rsp, sizeof(struct hci_fm_sig_threshold_rsp));
- radio_hci_req_complete(hdev, rsp->status);
- }
- static void hci_cc_station_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- struct hci_fm_station_rsp *rsp = (void *)skb->data;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- radio->fm_st_rsp = *(rsp);
- /* Tune is always succesful */
- radio_hci_req_complete(hdev, 0);
- }
- static void hci_cc_prg_srv_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb)
- {
- struct hci_fm_prgm_srv_rsp *rsp = (void *)skb->data;
- if (rsp->status)
- return;
- radio_hci_req_complete(hdev, rsp->status);
- }
- static void hci_cc_rd_txt_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb)
- {
- struct hci_fm_radio_txt_rsp *rsp = (void *)skb->data;
- if (rsp->status)
- return;
- radio_hci_req_complete(hdev, rsp->status);
- }
- static void hci_cc_af_list_rsp(struct radio_hci_dev *hdev, struct sk_buff *skb)
- {
- struct hci_fm_af_list_rsp *rsp = (void *)skb->data;
- if (rsp->status)
- return;
- radio_hci_req_complete(hdev, rsp->status);
- }
- static void hci_cc_feature_list_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct hci_fm_feature_list_rsp *rsp = (void *)skb->data;
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- struct v4l2_capability *v4l_cap = radio->g_cap;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- if (rsp->status)
- return;
- v4l_cap->capabilities = (rsp->feature_mask & 0x000002) |
- (rsp->feature_mask & 0x000001);
- radio_hci_req_complete(hdev, rsp->status);
- }
- static void hci_cc_dbg_param_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- struct hci_fm_dbg_param_rsp *rsp = (void *)skb->data;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- radio->st_dbg_param = *(rsp);
- if (radio->st_dbg_param.status)
- return;
- radio_hci_req_complete(hdev, radio->st_dbg_param.status);
- }
- static void iris_q_evt_data(struct iris_device *radio,
- char *data, int len, int event)
- {
- struct kfifo *data_b;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- data_b = &radio->data_buf[event];
- if (kfifo_in_locked(data_b, data, len, &radio->buf_lock[event]))
- wake_up_interruptible(&radio->event_queue);
- }
- static void hci_cc_riva_peek_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- __u8 status = *((__u8 *) skb->data);
- int len;
- char *data;
- if (status)
- return;
- len = skb->data[RIVA_PEEK_LEN_OFSET] + RIVA_PEEK_PARAM;
- data = kmalloc(len, GFP_ATOMIC);
- if (!data) {
- FMDERR("Memory allocation failed");
- return;
- }
- memcpy(data, &skb->data[PEEK_DATA_OFSET], len);
- iris_q_evt_data(radio, data, len, IRIS_BUF_PEEK);
- radio_hci_req_complete(hdev, status);
- kfree(data);
- }
- static void hci_cc_riva_read_default_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- __u8 status = *((__u8 *) skb->data);
- __u8 len;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- if (status)
- return;
- len = skb->data[1];
- memset(&radio->default_data, 0 , sizeof(struct hci_fm_data_rd_rsp));
- memcpy(&radio->default_data, &skb->data[0], len+2);
- iris_q_evt_data(radio, &skb->data[0], len+2, IRIS_BUF_RD_DEFAULT);
- radio_hci_req_complete(hdev, status);
- }
- static void hci_cc_get_spur_tbl(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- __u8 status;
- if (unlikely(radio == NULL)) {
- FMDERR(":radio is null");
- return;
- }
- if (unlikely(skb == NULL)) {
- FMDERR("%s, socket buffer is null\n", __func__);
- return;
- }
- status = *((__u8 *) skb->data);
- if (!status) {
- iris_q_evt_data(radio, &skb->data[1], SPUR_DATA_LEN,
- IRIS_BUF_SPUR);
- iris_q_event(radio, IRIS_EVT_SPUR_TBL);
- }
- radio_hci_req_complete(hdev, status);
- }
- static void hci_cc_ssbi_peek_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- __u8 status = *((__u8 *) skb->data);
- char *data;
- if (status)
- return;
- data = kmalloc(SSBI_PEEK_LEN, GFP_ATOMIC);
- if (!data) {
- FMDERR("Memory allocation failed");
- return;
- }
- data[0] = skb->data[PEEK_DATA_OFSET];
- iris_q_evt_data(radio, data, SSBI_PEEK_LEN, IRIS_BUF_SSBI_PEEK);
- radio_hci_req_complete(hdev, status);
- kfree(data);
- }
- static void hci_cc_rds_grp_cntrs_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- __u8 status = *((__u8 *) skb->data);
- char *data;
- if (status)
- return;
- data = kmalloc(RDS_GRP_CNTR_LEN, GFP_ATOMIC);
- if (!data) {
- FMDERR("memory allocation failed");
- return;
- }
- memcpy(data, &skb->data[1], RDS_GRP_CNTR_LEN);
- iris_q_evt_data(radio, data, RDS_GRP_CNTR_LEN, IRIS_BUF_RDS_CNTRS);
- radio_hci_req_complete(hdev, status);
- kfree(data);
- }
- static void hci_cc_do_calibration_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- static struct hci_cc_do_calibration_rsp rsp;
- rsp.status = skb->data[0];
- rsp.mode = skb->data[CALIB_MODE_OFSET];
- if (rsp.status) {
- FMDERR("status = %d", rsp.status);
- return;
- }
- if (rsp.mode == PROCS_CALIB_MODE) {
- memcpy(&rsp.data[0], &skb->data[CALIB_DATA_OFSET],
- PROCS_CALIB_SIZE);
- iris_q_evt_data(radio, rsp.data, PROCS_CALIB_SIZE,
- IRIS_BUF_CAL_DATA);
- } else {
- return;
- }
- radio_hci_req_complete(hdev, rsp.status);
- }
- static void hci_cc_get_ch_det_threshold_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- u8 status = skb->data[0];
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- if (status) {
- FMDERR("status = %d", status);
- return;
- }
- memcpy(&radio->ch_det_threshold, &skb->data[1],
- sizeof(struct hci_fm_ch_det_threshold));
- radio_hci_req_complete(hdev, status);
- }
- static void hci_cc_get_blend_tbl_rsp(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- u8 status;
- if (unlikely(radio == NULL)) {
- FMDERR(":radio is null");
- return;
- }
- if (unlikely(skb == NULL)) {
- FMDERR("%s, socket buffer is null\n", __func__);
- return;
- }
- status = skb->data[0];
- if (!status)
- memcpy(&radio->blend_tbl, &skb->data[1],
- sizeof(struct hci_fm_blend_table));
- radio_hci_req_complete(hdev, status);
- }
- static inline void hci_cmd_complete_event(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct hci_ev_cmd_complete *cmd_compl_ev = (void *) skb->data;
- __u16 opcode;
- skb_pull(skb, sizeof(*cmd_compl_ev));
- opcode = __le16_to_cpu(cmd_compl_ev->cmd_opcode);
- switch (opcode) {
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_ENABLE_RECV_REQ):
- case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_ENABLE_TRANS_REQ):
- hci_cc_fm_enable_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_RECV_CONF_REQ):
- hci_cc_conf_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_DISABLE_RECV_REQ):
- case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_DISABLE_TRANS_REQ):
- hci_cc_fm_disable_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_RECV_CONF_REQ):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_MUTE_MODE_REQ):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_STEREO_MODE_REQ):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_ANTENNA):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_SIGNAL_THRESHOLD):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_CANCEL_SEARCH):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_RDS_GRP):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_RDS_GRP_PROCESS):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_EN_WAN_AVD_CTRL):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_EN_NOTCH_CTRL):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_CH_DET_THRESHOLD):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_BLND_TBL):
- case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_RDS_RT_REQ):
- case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_RDS_PS_REQ):
- case hci_common_cmd_op_pack(HCI_OCF_FM_DEFAULT_DATA_WRITE):
- hci_cc_rsp(hdev, skb);
- break;
- case hci_common_cmd_op_pack(HCI_OCF_FM_RESET):
- case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_SSBI_POKE_REG):
- case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_POKE_DATA):
- case hci_diagnostic_cmd_op_pack(HCI_FM_SET_INTERNAL_TONE_GENRATOR):
- case hci_common_cmd_op_pack(HCI_OCF_FM_SET_CALIBRATION):
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_SET_EVENT_MASK):
- case hci_common_cmd_op_pack(HCI_OCF_FM_SET_SPUR_TABLE):
- hci_cc_rsp(hdev, skb);
- break;
- case hci_common_cmd_op_pack(HCI_OCF_FM_GET_SPUR_TABLE):
- hci_cc_get_spur_tbl(hdev, skb);
- break;
- case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_SSBI_PEEK_REG):
- hci_cc_ssbi_peek_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_SIGNAL_THRESHOLD):
- hci_cc_sig_threshold_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_STATION_PARAM_REQ):
- hci_cc_station_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ):
- hci_cc_prg_srv_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_RADIO_TEXT_REQ):
- hci_cc_rd_txt_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_AF_LIST_REQ):
- hci_cc_af_list_rsp(hdev, skb);
- break;
- case hci_common_cmd_op_pack(HCI_OCF_FM_DEFAULT_DATA_READ):
- hci_cc_riva_read_default_rsp(hdev, skb);
- break;
- case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_PEEK_DATA):
- hci_cc_riva_peek_rsp(hdev, skb);
- break;
- case hci_common_cmd_op_pack(HCI_OCF_FM_GET_FEATURE_LIST):
- hci_cc_feature_list_rsp(hdev, skb);
- break;
- case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_STATION_DBG_PARAM):
- hci_cc_dbg_param_rsp(hdev, skb);
- break;
- case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_SET_TRANS_CONF_REQ):
- hci_cc_fm_trans_set_conf_rsp(hdev, skb);
- break;
- case hci_status_param_op_pack(HCI_OCF_FM_READ_GRP_COUNTERS):
- hci_cc_rds_grp_cntrs_rsp(hdev, skb);
- break;
- case hci_common_cmd_op_pack(HCI_OCF_FM_DO_CALIBRATION):
- hci_cc_do_calibration_rsp(hdev, skb);
- break;
- case hci_trans_ctrl_cmd_op_pack(HCI_OCF_FM_GET_TRANS_CONF_REQ):
- hci_cc_fm_trans_get_conf_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_CH_DET_THRESHOLD):
- hci_cc_get_ch_det_threshold_rsp(hdev, skb);
- break;
- case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_BLND_TBL):
- hci_cc_get_blend_tbl_rsp(hdev, skb);
- break;
- default:
- FMDERR("%s opcode 0x%x", hdev->name, opcode);
- break;
- }
- }
- static inline void hci_cmd_status_event(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct hci_ev_cmd_status *ev = (void *) skb->data;
- radio_hci_status_complete(hdev, ev->status);
- }
- static inline void hci_ev_tune_status(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- int i;
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- memcpy(&radio->fm_st_rsp.station_rsp, &skb->data[0],
- sizeof(struct hci_ev_tune_status));
- if (radio->fm_st_rsp.station_rsp.sub_event == AF_JMP_TUNE)
- iris_q_event(radio, IRIS_EVT_AFJMP);
- else
- iris_q_event(radio, IRIS_EVT_TUNE_SUCC);
- for (i = 0; i < IRIS_BUF_MAX; i++) {
- if (i >= IRIS_BUF_RT_RDS)
- kfifo_reset(&radio->data_buf[i]);
- }
- if (radio->fm_st_rsp.station_rsp.serv_avble)
- iris_q_event(radio, IRIS_EVT_ABOVE_TH);
- else
- iris_q_event(radio, IRIS_EVT_BELOW_TH);
- if (radio->fm_st_rsp.station_rsp.stereo_prg)
- iris_q_event(radio, IRIS_EVT_STEREO);
- else if (radio->fm_st_rsp.station_rsp.stereo_prg == 0)
- iris_q_event(radio, IRIS_EVT_MONO);
- if (radio->fm_st_rsp.station_rsp.rds_sync_status)
- iris_q_event(radio, IRIS_EVT_RDS_AVAIL);
- else
- iris_q_event(radio, IRIS_EVT_RDS_NOT_AVAIL);
- }
- static inline void hci_ev_search_compl(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- iris_q_event(radio, IRIS_EVT_SEEK_COMPLETE);
- }
- static inline void hci_ev_srch_st_list_compl(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- struct hci_ev_srch_list_compl *ev ;
- int cnt;
- int stn_num;
- int rel_freq;
- int abs_freq;
- int len;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
- if (!ev) {
- FMDERR("Memory allocation failed");
- return ;
- }
- ev->num_stations_found = skb->data[STN_NUM_OFFSET];
- len = ev->num_stations_found * PARAMS_PER_STATION + STN_FREQ_OFFSET;
- for (cnt = STN_FREQ_OFFSET, stn_num = 0;
- (cnt < len) && (stn_num < ev->num_stations_found)
- && (stn_num < ARRAY_SIZE(ev->rel_freq));
- cnt += PARAMS_PER_STATION, stn_num++) {
- abs_freq = *((int *)&skb->data[cnt]);
- rel_freq = abs_freq - radio->recv_conf.band_low_limit;
- rel_freq = (rel_freq * 20) / KHZ_TO_MHZ;
- ev->rel_freq[stn_num].rel_freq_lsb = GET_LSB(rel_freq);
- ev->rel_freq[stn_num].rel_freq_msb = GET_MSB(rel_freq);
- }
- len = ev->num_stations_found * 2 + sizeof(ev->num_stations_found);
- iris_q_event(radio, IRIS_EVT_NEW_SRCH_LIST);
- iris_q_evt_data(radio, (char *)ev, len, IRIS_BUF_SRCH_LIST);
- kfree(ev);
- }
- static inline void hci_ev_search_next(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- iris_q_event(radio, IRIS_EVT_SCAN_NEXT);
- }
- static inline void hci_ev_stereo_status(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- __u8 st_status = *((__u8 *) skb->data);
- if (st_status)
- iris_q_event(radio, IRIS_EVT_STEREO);
- else
- iris_q_event(radio, IRIS_EVT_MONO);
- }
- static void hci_ev_raw_rds_group_data(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio;
- unsigned char blocknum, index;
- struct rds_grp_data temp;
- unsigned int mask_bit;
- unsigned short int aid, agt, gtc;
- unsigned short int carrier;
- radio = video_get_drvdata(video_get_dev());
- index = RDSGRP_DATA_OFFSET;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return;
- }
- for (blocknum = 0; blocknum < RDS_BLOCKS_NUM; blocknum++) {
- temp.rdsBlk[blocknum].rdsLsb =
- (skb->data[index]);
- temp.rdsBlk[blocknum].rdsMsb =
- (skb->data[index+1]);
- temp.rdsBlk[blocknum].blockStatus =
- (skb->data[RDSGRP_DATA_OFFSET + blocknum +
- (RDS_BLOCKS_NUM << 1)]);
- index = index + 2;
- }
- aid = AID(temp.rdsBlk[3].rdsLsb, temp.rdsBlk[3].rdsMsb);
- gtc = GTC(temp.rdsBlk[1].rdsMsb);
- agt = AGT(temp.rdsBlk[1].rdsLsb);
- if (gtc == GRP_3A) {
- switch (aid) {
- case ERT_AID:
- /* calculate the grp mask for RDS grp
- * which will contain actual eRT text
- *
- * Bit Pos 0 1 2 3 4 5 6 7
- * Grp Type 0A 0B 1A 1B 2A 2B 3A 3B
- *
- * similary for rest grps
- */
- if (!radio->is_ert_enabled)
- break;
- mask_bit = (((agt >> 1) << 1) + (agt & 1));
- oda_agt = (1 << mask_bit);
- utf_8_flag = (temp.rdsBlk[2].rdsLsb & 1);
- formatting_dir = EXTRACT_BIT(temp.rdsBlk[2].rdsLsb,
- ERT_FORMAT_DIR_BIT);
- if (ert_carrier != agt)
- iris_q_event(radio, IRIS_EVT_NEW_ODA);
- ert_carrier = agt;
- break;
- case RT_PLUS_AID:
- /* calculate the grp mask for RDS grp
- * which will contain actual eRT text
- *
- * Bit Pos 0 1 2 3 4 5 6 7
- * Grp Type 0A 0B 1A 1B 2A 2B 3A 3B
- *
- * similary for rest grps
- */
- if (!radio->is_rt_plus_enabled)
- break;
- mask_bit = (((agt >> 1) << 1) + (agt & 1));
- oda_agt = (1 << mask_bit);
- /*Extract 5th bit of MSB (b7b6b5b4b3b2b1b0)*/
- rt_ert_flag = EXTRACT_BIT(temp.rdsBlk[2].rdsMsb,
- RT_ERT_FLAG_BIT);
- if (rt_plus_carrier != agt)
- iris_q_event(radio, IRIS_EVT_NEW_ODA);
- rt_plus_carrier = agt;
- break;
- default:
- oda_agt = 0;
- break;
- }
- } else {
- carrier = gtc;
- if ((carrier == rt_plus_carrier)&&
- radio->is_rt_plus_enabled) {
- hci_ev_rt_plus(radio, temp);
- }else if ((carrier == ert_carrier) &&
- radio->is_ert_enabled) {
- hci_buff_ert(radio, &temp);
- }else {
- iris_q_evt_data(radio, (char *)(&temp),
- sizeof (struct rds_grp_data), IRIS_BUF_RAW_RDS);
- iris_q_event(radio, IRIS_EVT_NEW_RAW_RDS);
- }
- }
- }
- static void hci_buff_ert(struct iris_device *radio,
- struct rds_grp_data *rds_buf)
- {
- int i;
- unsigned short int info_byte = 0;
- unsigned short int byte_pair_index;
- byte_pair_index = AGT(rds_buf->rdsBlk[1].rdsLsb);
- if (byte_pair_index == 0) {
- c_byt_pair_index = 0;
- ert_len = 0;
- }
- if (c_byt_pair_index == byte_pair_index) {
- c_byt_pair_index++;
- for (i = 2; i <= 3; i++) {
- info_byte = rds_buf->rdsBlk[i].rdsLsb;
- info_byte |= (rds_buf->rdsBlk[i].rdsMsb << 8);
- ert_buf[ert_len++] = rds_buf->rdsBlk[i].rdsMsb;
- ert_buf[ert_len++] = rds_buf->rdsBlk[i].rdsLsb;
- if ((utf_8_flag == 0)
- && (info_byte == CARRIAGE_RETURN)) {
- ert_len -= 2;
- break;
- } else if ((utf_8_flag == 1)
- &&
- (rds_buf->rdsBlk[i].rdsMsb
- == CARRIAGE_RETURN)) {
- info_byte = CARRIAGE_RETURN;
- ert_len -= 2;
- break;
- } else if ((utf_8_flag == 1)
- &&
- (rds_buf->rdsBlk[i].rdsLsb
- == CARRIAGE_RETURN)) {
- info_byte = CARRIAGE_RETURN;
- ert_len--;
- break;
- }
- }
- if ((byte_pair_index == MAX_ERT_SEGMENT) ||
- (info_byte == CARRIAGE_RETURN)) {
- hci_ev_ert(radio);
- c_byt_pair_index = 0;
- ert_len = 0;
- }
- } else {
- ert_len = 0;
- c_byt_pair_index = 0;
- }
- }
- static void hci_ev_ert(struct iris_device *radio)
- {
- char *data = NULL;
- if (ert_len <= 0)
- return;
- data = kmalloc((ert_len + 3), GFP_ATOMIC);
- if (data != NULL) {
- data[0] = ert_len;
- data[1] = utf_8_flag;
- data[2] = formatting_dir;
- memcpy((data + 3), ert_buf, ert_len);
- if (radio->is_ert_enabled) {
- iris_q_evt_data(radio, data,
- (ert_len + 3), IRIS_BUF_ERT);
- iris_q_event(radio, IRIS_EVT_NEW_ERT);
- }
- kfree(data);
- }
- }
- static void hci_ev_rt_plus(struct iris_device *radio,
- struct rds_grp_data rds_buf)
- {
- char tag_type1, tag_type2;
- char *data = NULL;
- int len = 0;
- int tags_num = 0;
- char item_toggle;
- char item_running;
- unsigned short int agt;
- item_toggle = EXTRACT_BIT(rds_buf.rdsBlk[1].rdsLsb,
- ITEM_TOGGLE_BIT);
- item_running = EXTRACT_BIT(rds_buf.rdsBlk[1].rdsLsb,
- ITEM_RUNNING_BIT);
- agt = AGT(rds_buf.rdsBlk[1].rdsLsb);
- /*right most 3 bits of Lsb of block 2
- * and left most 3 bits of Msb of block 3
- */
- tag_type1 = (((agt & TAG1_MSB_MASK) << TAG1_MSB_OFFSET) |
- (rds_buf.rdsBlk[2].rdsMsb >> TAG1_LSB_OFFSET));
- /*right most 1 bit of lsb of 3rd block
- * and left most 5 bits of Msb of 4th block
- */
- tag_type2 = (((rds_buf.rdsBlk[2].rdsLsb & TAG2_MSB_MASK)
- << TAG2_MSB_OFFSET) |
- (rds_buf.rdsBlk[3].rdsMsb >> TAG2_LSB_OFFSET));
- if (tag_type1 != DUMMY_CLASS) {
- len += RT_PLUS_LEN_1_TAG;
- tags_num++;
- }
- if (tag_type2 != DUMMY_CLASS) {
- len += RT_PLUS_LEN_1_TAG;
- tags_num++;
- }
- if (len != 0) {
- len += 4;
- data = kmalloc(len, GFP_ATOMIC);
- } else {
- FMDERR("Len is zero\n");
- return ;
- }
- if (data != NULL) {
- data[0] = tags_num;
- len = 1;
- data[len++] = rt_ert_flag;
- data[len++] = item_toggle;
- data[len++] = item_running;
- if (tag_type1 != DUMMY_CLASS) {
- data[len++] = tag_type1;
- /*start position of tag1
- *right most 5 bits of msb of 3rd block
- *and left most bit of lsb of 3rd block
- */
- data[len++] = (((rds_buf.rdsBlk[2].rdsMsb &
- TAG1_POS_MSB_MASK)
- << TAG1_POS_MSB_OFFSET)
- |
- (rds_buf.rdsBlk[2].rdsLsb >>
- TAG1_POS_LSB_OFFSET));
- /*length of tag1
- *left most 6 bits of lsb of 3rd block
- */
- data[len++] = ((rds_buf.rdsBlk[2].rdsLsb
- >> TAG1_LEN_OFFSET)
- &
- TAG1_LEN_MASK) + 1;
- }
- if (tag_type2 != DUMMY_CLASS) {
- data[len++] = tag_type2;
- /*start position of tag2
- *right most 3 bit of msb of 4th block
- *and left most 3 bits of lsb of 4th block
- */
- data[len++] = (((rds_buf.rdsBlk[3].rdsMsb
- & TAG2_POS_MSB_MASK)
- << TAG2_POS_MSB_OFFSET)
- |
- (rds_buf.rdsBlk[3].rdsLsb
- >> TAG2_POS_LSB_OFFSET));
- /*length of tag2
- *right most 5 bits of lsb of 4th block
- */
- data[len++] = (rds_buf.rdsBlk[3].rdsLsb
- & TAG2_LEN_MASK) + 1;
- }
- if (radio->is_rt_plus_enabled) {
- iris_q_evt_data(radio, data,
- len, IRIS_BUF_RT_PLUS);
- iris_q_event(radio, IRIS_EVT_NEW_RT_PLUS);
- }
- kfree(data);
- } else {
- FMDERR("memory allocation failed\n");
- }
- }
- static inline void hci_ev_program_service(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- int len;
- char *data;
- len = (skb->data[RDS_PS_LENGTH_OFFSET] * RDS_STRING) + RDS_OFFSET;
- iris_q_event(radio, IRIS_EVT_NEW_PS_RDS);
- data = kmalloc(len, GFP_ATOMIC);
- if (!data) {
- FMDERR("Failed to allocate memory");
- return;
- }
- data[0] = skb->data[RDS_PS_LENGTH_OFFSET];
- data[1] = skb->data[RDS_PTYPE];
- data[2] = skb->data[RDS_PID_LOWER];
- data[3] = skb->data[RDS_PID_HIGHER];
- data[4] = 0;
- memcpy(data+RDS_OFFSET, &skb->data[RDS_PS_DATA_OFFSET], len-RDS_OFFSET);
- iris_q_evt_data(radio, data, len, IRIS_BUF_PS_RDS);
- kfree(data);
- }
- static inline void hci_ev_radio_text(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- int len = 0;
- char *data;
- iris_q_event(radio, IRIS_EVT_NEW_RT_RDS);
- while ((skb->data[len+RDS_OFFSET] != 0x0d) && (len < MAX_RT_LENGTH))
- len++;
- data = kmalloc(len+RDS_OFFSET, GFP_ATOMIC);
- if (!data) {
- FMDERR("Failed to allocate memory");
- return;
- }
- data[0] = len;
- data[1] = skb->data[RDS_PTYPE];
- data[2] = skb->data[RDS_PID_LOWER];
- data[3] = skb->data[RDS_PID_HIGHER];
- data[4] = skb->data[RT_A_B_FLAG_OFFSET];
- memcpy(data+RDS_OFFSET, &skb->data[RDS_OFFSET], len);
- data[len+RDS_OFFSET] = 0x00;
- iris_q_evt_data(radio, data, len+RDS_OFFSET, IRIS_BUF_RT_RDS);
- kfree(data);
- }
- static void hci_ev_af_list(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- struct hci_ev_af_list ev;
- ev.tune_freq = *((int *) &skb->data[0]);
- ev.pi_code = *((__le16 *) &skb->data[PI_CODE_OFFSET]);
- ev.af_size = skb->data[AF_SIZE_OFFSET];
- if (ev.af_size > AF_LIST_MAX) {
- FMDERR("AF list size received more than available size");
- return;
- }
- memcpy(&ev.af_list[0], &skb->data[AF_LIST_OFFSET], ev.af_size * sizeof(int));
- iris_q_event(radio, IRIS_EVT_NEW_AF_LIST);
- iris_q_evt_data(radio, (char *)&ev, (7 + ev.af_size * sizeof(int)), IRIS_BUF_AF_LIST);
- }
- static void hci_ev_rds_lock_status(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- __u8 rds_status = skb->data[0];
- if (rds_status)
- iris_q_event(radio, IRIS_EVT_RDS_AVAIL);
- else
- iris_q_event(radio, IRIS_EVT_RDS_NOT_AVAIL);
- }
- static void hci_ev_service_available(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- u8 serv_avble = skb->data[0];
- if (serv_avble)
- iris_q_event(radio, IRIS_EVT_ABOVE_TH);
- else
- iris_q_event(radio, IRIS_EVT_BELOW_TH);
- }
- static void hci_ev_rds_grp_complete(struct radio_hci_dev *hdev,
- struct sk_buff *skb)
- {
- struct iris_device *radio = video_get_drvdata(video_get_dev());
- iris_q_event(radio, IRIS_EVT_TXRDSDONE);
- }
- void radio_hci_event_packet(struct radio_hci_dev *hdev, struct sk_buff *skb)
- {
- struct radio_hci_event_hdr *hdr;
- u8 event;
- if (skb == NULL) {
- FMDERR("Socket buffer is NULL");
- return;
- }
- hdr = (void *) skb->data;
- event = hdr->evt;
- skb_pull(skb, RADIO_HCI_EVENT_HDR_SIZE);
- switch (event) {
- case HCI_EV_TUNE_STATUS:
- hci_ev_tune_status(hdev, skb);
- break;
- case HCI_EV_SEARCH_PROGRESS:
- case HCI_EV_SEARCH_RDS_PROGRESS:
- case HCI_EV_SEARCH_LIST_PROGRESS:
- hci_ev_search_next(hdev, skb);
- break;
- case HCI_EV_STEREO_STATUS:
- hci_ev_stereo_status(hdev, skb);
- break;
- case HCI_EV_RDS_LOCK_STATUS:
- hci_ev_rds_lock_status(hdev, skb);
- break;
- case HCI_EV_SERVICE_AVAILABLE:
- hci_ev_service_available(hdev, skb);
- break;
- case HCI_EV_RDS_RX_DATA:
- hci_ev_raw_rds_group_data(hdev, skb);
- break;
- case HCI_EV_PROGRAM_SERVICE:
- hci_ev_program_service(hdev, skb);
- break;
- case HCI_EV_RADIO_TEXT:
- hci_ev_radio_text(hdev, skb);
- break;
- case HCI_EV_FM_AF_LIST:
- hci_ev_af_list(hdev, skb);
- break;
- case HCI_EV_TX_RDS_GRP_COMPL:
- hci_ev_rds_grp_complete(hdev, skb);
- break;
- case HCI_EV_TX_RDS_CONT_GRP_COMPL:
- break;
- case HCI_EV_CMD_COMPLETE:
- hci_cmd_complete_event(hdev, skb);
- break;
- case HCI_EV_CMD_STATUS:
- hci_cmd_status_event(hdev, skb);
- break;
- case HCI_EV_SEARCH_COMPLETE:
- case HCI_EV_SEARCH_RDS_COMPLETE:
- hci_ev_search_compl(hdev, skb);
- break;
- case HCI_EV_SEARCH_LIST_COMPLETE:
- hci_ev_srch_st_list_compl(hdev, skb);
- break;
- default:
- break;
- }
- }
- /*
- * fops/IOCTL helper functions
- */
- static int iris_search(struct iris_device *radio, int on, int dir)
- {
- int retval = 0;
- enum search_t srch;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- srch = radio->g_search_mode & SRCH_MODE;
- radio->search_on = on;
- if (on) {
- switch (srch) {
- case SCAN_FOR_STRONG:
- case SCAN_FOR_WEAK:
- radio->srch_st_list.srch_list_dir = dir;
- radio->srch_st_list.srch_list_mode = srch;
- retval = hci_fm_search_station_list(
- &radio->srch_st_list, radio->fm_hdev);
- break;
- case RDS_SEEK_PTY:
- case RDS_SCAN_PTY:
- case RDS_SEEK_PI:
- srch = srch - SEARCH_RDS_STNS_MODE_OFFSET;
- radio->srch_rds.srch_station.srch_mode = srch;
- radio->srch_rds.srch_station.srch_dir = dir;
- radio->srch_rds.srch_station.scan_time =
- radio->g_scan_time;
- retval = hci_fm_search_rds_stations(&radio->srch_rds,
- radio->fm_hdev);
- break;
- default:
- radio->srch_st.srch_mode = srch;
- radio->srch_st.scan_time = radio->g_scan_time;
- radio->srch_st.srch_dir = dir;
- retval = hci_fm_search_stations(
- &radio->srch_st, radio->fm_hdev);
- break;
- }
- } else {
- retval = hci_cmd(HCI_FM_CANCEL_SEARCH_CMD, radio->fm_hdev);
- }
- return retval;
- }
- static int set_low_power_mode(struct iris_device *radio, int power_mode)
- {
- int rds_grps_proc = 0x00;
- int retval = 0;
- struct hci_fm_rds_grp_req grp_3a;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- if (radio->power_mode != power_mode) {
- if (power_mode) {
- memcpy(&grp_3a, &radio->rds_grp,
- sizeof(struct hci_fm_rds_grp_req));
- /* Disable 3A group */
- grp_3a.rds_grp_enable_mask &= ~FM_RDS_3A_GRP;
- retval = hci_fm_rds_grp(&grp_3a, radio->fm_hdev);
- if (retval < 0)
- FMDERR("error in disable 3A group mask\n");
- radio->event_mask = 0x00;
- if (radio->af_jump_bit)
- rds_grps_proc = 0x00 | AF_JUMP_ENABLE;
- else
- rds_grps_proc = 0x00;
- retval = hci_fm_rds_grps_process(
- &rds_grps_proc,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Disable RDS failed");
- return retval;
- }
- retval = hci_conf_event_mask(&radio->event_mask,
- radio->fm_hdev);
- } else {
- /* Enable RDS group to normal */
- retval = hci_fm_rds_grp(&radio->rds_grp,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("error in enable 3A group mask\n");
- radio->event_mask = SIG_LEVEL_INTR |
- RDS_SYNC_INTR | AUDIO_CTRL_INTR;
- retval = hci_conf_event_mask(&radio->event_mask,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Enable Async events failed");
- return retval;
- }
- retval = hci_fm_rds_grps_process(
- &radio->g_rds_grp_proc_ps,
- radio->fm_hdev);
- }
- radio->power_mode = power_mode;
- }
- return retval;
- }
- static int iris_recv_set_region(struct iris_device *radio, int req_region)
- {
- int retval;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- radio->region = req_region;
- retval = hci_set_fm_recv_conf(
- &radio->recv_conf,
- radio->fm_hdev);
- return retval;
- }
- static int iris_trans_set_region(struct iris_device *radio, int req_region)
- {
- int retval;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- radio->region = req_region;
- retval = hci_set_fm_trans_conf(
- &radio->trans_conf,
- radio->fm_hdev);
- return retval;
- }
- static int iris_set_freq(struct iris_device *radio, unsigned int freq)
- {
- int retval;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- retval = hci_fm_tune_station(&freq, radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error while setting the frequency : %d\n", retval);
- return retval;
- }
- static int iris_vidioc_queryctrl(struct file *file, void *priv,
- struct v4l2_queryctrl *qc)
- {
- unsigned char i;
- int retval = -EINVAL;
- for (i = 0; i < ARRAY_SIZE(iris_v4l2_queryctrl); i++) {
- if (qc->id && qc->id == iris_v4l2_queryctrl[i].id) {
- memcpy(qc, &(iris_v4l2_queryctrl[i]), sizeof(*qc));
- retval = 0;
- break;
- }
- }
- return retval;
- }
- static int iris_do_calibration(struct iris_device *radio)
- {
- char cal_mode = 0x00;
- int retval = 0x00;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- cal_mode = PROCS_CALIB_MODE;
- radio->mode = FM_CALIB;
- retval = hci_cmd(HCI_FM_ENABLE_RECV_CMD,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Enable failed before calibration %x", retval);
- radio->mode = FM_OFF;
- return retval;
- }
- retval = radio_hci_request(radio->fm_hdev, hci_fm_do_cal_req,
- (unsigned long)cal_mode, RADIO_HCI_TIMEOUT);
- if (retval < 0) {
- FMDERR("Do Process calibration failed %x", retval);
- radio->mode = FM_RECV;
- return retval;
- }
- retval = hci_cmd(HCI_FM_DISABLE_RECV_CMD,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Disable Failed after calibration %d", retval);
- return retval;
- }
- static int iris_vidioc_g_ctrl(struct file *file, void *priv,
- struct v4l2_control *ctrl)
- {
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- int retval = 0;
- int cf0;
- struct hci_fm_def_data_rd_req rd;
- int lsb, msb;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- switch (ctrl->id) {
- case V4L2_CID_AUDIO_VOLUME:
- break;
- case V4L2_CID_AUDIO_MUTE:
- ctrl->value = radio->mute_mode.hard_mute;
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCHMODE:
- ctrl->value = radio->g_search_mode;
- break;
- case V4L2_CID_PRIVATE_IRIS_SCANDWELL:
- ctrl->value = radio->g_scan_time;
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCHON:
- ctrl->value = radio->search_on;
- break;
- case V4L2_CID_PRIVATE_IRIS_STATE:
- ctrl->value = radio->mode;
- break;
- case V4L2_CID_PRIVATE_IRIS_IOVERC:
- retval = hci_cmd(HCI_FM_STATION_DBG_PARAM_CMD, radio->fm_hdev);
- if (retval < 0)
- return retval;
- ctrl->value = radio->st_dbg_param.io_verc;
- break;
- case V4L2_CID_PRIVATE_IRIS_INTDET:
- retval = hci_cmd(HCI_FM_STATION_DBG_PARAM_CMD, radio->fm_hdev);
- if (retval < 0)
- return retval;
- ctrl->value = radio->st_dbg_param.in_det_out;
- break;
- case V4L2_CID_PRIVATE_IRIS_REGION:
- ctrl->value = radio->region;
- break;
- case V4L2_CID_PRIVATE_IRIS_SIGNAL_TH:
- retval = hci_cmd(HCI_FM_GET_SIGNAL_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Error in get signal threshold %d\n", retval);
- return retval;
- }
- ctrl->value = radio->sig_th.sig_threshold;
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCH_PTY:
- ctrl->value = radio->srch_rds.srch_pty;
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCH_PI:
- ctrl->value = radio->srch_rds.srch_pi;
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCH_CNT:
- ctrl->value = radio->srch_st_result.num_stations_found;
- break;
- case V4L2_CID_PRIVATE_IRIS_EMPHASIS:
- if (radio->mode == FM_RECV) {
- ctrl->value = radio->recv_conf.emphasis;
- } else if (radio->mode == FM_TRANS) {
- ctrl->value = radio->trans_conf.emphasis;
- } else {
- FMDERR("Error in radio mode"
- " %d\n", retval);
- return -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_RDS_STD:
- if (radio->mode == FM_RECV) {
- ctrl->value = radio->recv_conf.rds_std;
- } else if (radio->mode == FM_TRANS) {
- ctrl->value = radio->trans_conf.rds_std;
- } else {
- FMDERR("Error in radio mode"
- " %d\n", retval);
- return -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_SPACING:
- if (radio->mode == FM_RECV) {
- ctrl->value = radio->recv_conf.ch_spacing;
- } else {
- FMDERR("Error in radio mode"
- " %d\n", retval);
- return -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSON:
- if (radio->mode == FM_RECV) {
- ctrl->value = radio->recv_conf.rds_std;
- } else {
- FMDERR("Error in radio mode"
- " %d\n", retval);
- return -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGROUP_MASK:
- ctrl->value = radio->rds_grp.rds_grp_enable_mask;
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGROUP_PROC:
- case V4L2_CID_PRIVATE_IRIS_PSALL:
- ctrl->value = (radio->g_rds_grp_proc_ps << RDS_CONFIG_OFFSET);
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSD_BUF:
- ctrl->value = radio->rds_grp.rds_buf_size;
- break;
- case V4L2_CID_PRIVATE_IRIS_LP_MODE:
- ctrl->value = radio->power_mode;
- break;
- case V4L2_CID_PRIVATE_IRIS_ANTENNA:
- ctrl->value = radio->g_antenna;
- break;
- case V4L2_CID_PRIVATE_IRIS_SOFT_MUTE:
- ctrl->value = radio->mute_mode.soft_mute;
- break;
- case V4L2_CID_PRIVATE_IRIS_DO_CALIBRATION:
- retval = iris_do_calibration(radio);
- break;
- case V4L2_CID_PRIVATE_IRIS_GET_SINR:
- if (radio->mode == FM_RECV) {
- retval = hci_cmd(HCI_FM_GET_STATION_PARAM_CMD,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get SINR Failed");
- return retval;
- }
- ctrl->value = radio->fm_st_rsp.station_rsp.sinr;
- } else
- retval = -EINVAL;
- break;
- case V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD:
- retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get High det threshold failed %x", retval);
- return retval;
- }
- ctrl->value = radio->ch_det_threshold.high_th;
- break;
- case V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD:
- retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get Low det threshold failed %x", retval);
- return retval;
- }
- ctrl->value = radio->ch_det_threshold.low_th;
- break;
- case V4L2_CID_PRIVATE_SINR_THRESHOLD:
- retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get SINR threshold failed %x", retval);
- return retval;
- }
- ctrl->value = radio->ch_det_threshold.sinr;
- break;
- case V4L2_CID_PRIVATE_SINR_SAMPLES:
- retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get SINR samples failed %x", retval);
- return retval;
- }
- ctrl->value = radio->ch_det_threshold.sinr_samples;
- break;
- case V4L2_CID_PRIVATE_VALID_CHANNEL:
- ctrl->value = radio->is_station_valid;
- break;
- case V4L2_CID_PRIVATE_AF_RMSSI_TH:
- rd.mode = FM_RDS_CNFG_MODE;
- rd.length = FM_RDS_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get AF Jump Threshold failed %x", retval);
- return retval;
- }
- lsb = radio->default_data.data[AF_RMSSI_TH_LSB_OFFSET];
- msb = radio->default_data.data[AF_RMSSI_TH_MSB_OFFSET];
- ctrl->value = ((msb << 8) | lsb);
- break;
- case V4L2_CID_PRIVATE_AF_RMSSI_SAMPLES:
- rd.mode = FM_RDS_CNFG_MODE;
- rd.length = FM_RDS_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get AF jump rmssi samples failed %x", retval);
- return retval;
- }
- ctrl->value = radio->default_data.data[AF_RMSSI_SAMPLES_OFFSET];
- break;
- case V4L2_CID_PRIVATE_GOOD_CH_RMSSI_TH:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("get good channel rmssi th failed %x", retval);
- return retval;
- }
- ctrl->value = radio->default_data.data[GD_CH_RMSSI_TH_OFFSET];
- if (ctrl->value > MAX_GD_CH_RMSSI_TH)
- ctrl->value -= 256;
- break;
- case V4L2_CID_PRIVATE_SRCHALGOTYPE:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("get search algo type failed %x", retval);
- return retval;
- }
- ctrl->value = radio->default_data.data[SRCH_ALGO_TYPE_OFFSET];
- break;
- case V4L2_CID_PRIVATE_SINRFIRSTSTAGE:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed %x", retval);
- return retval;
- }
- ctrl->value = radio->default_data.data[SINRFIRSTSTAGE_OFFSET];
- if (ctrl->value > MAX_SINR_FIRSTSTAGE)
- ctrl->value -= 256;
- break;
- case V4L2_CID_PRIVATE_RMSSIFIRSTSTAGE:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed %x", retval);
- return retval;
- }
- ctrl->value = radio->default_data.data[RMSSIFIRSTSTAGE_OFFSET];
- if (ctrl->value > MAX_RMSSI_FIRSTSTAGE)
- ctrl->value -= 256;
- break;
- case V4L2_CID_PRIVATE_CF0TH12:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed %x", retval);
- return retval;
- }
- ctrl->value = radio->default_data.data[CF0TH12_BYTE1_OFFSET];
- cf0 = radio->default_data.data[CF0TH12_BYTE2_OFFSET];
- ctrl->value |= (cf0 << 8);
- cf0 = radio->default_data.data[CF0TH12_BYTE3_OFFSET];
- ctrl->value |= (cf0 << 16);
- cf0 = radio->default_data.data[CF0TH12_BYTE4_OFFSET];
- if (cf0 > 127)
- cf0 -= 256;
- ctrl->value |= (cf0 << 24);
- break;
- case V4L2_CID_PRIVATE_SOFT_MUTE_TH:
- rd.mode = DIG_AUDIO_0_MODE;
- rd.length = DIG_AUDIO_0_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed %x", retval);
- return retval;
- }
- ctrl->value = radio->default_data.data[SMUTE_TH_OFFSET];
- if (ctrl->value > MAX_SOFTMUTE_TH)
- ctrl->value -= 256;
- break;
- case V4L2_CID_PRIVATE_BLEND_SINRHI:
- retval = hci_cmd(HCI_FM_GET_BLND_TBL_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to get blend table %d", retval);
- goto END;
- }
- ctrl->value = radio->blend_tbl.scBlendSinrHi;
- break;
- case V4L2_CID_PRIVATE_BLEND_RMSSIHI:
- retval = hci_cmd(HCI_FM_GET_BLND_TBL_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to get blend table %d", retval);
- goto END;
- }
- ctrl->value = radio->blend_tbl.scBlendRmssiHi;
- break;
- default:
- retval = -EINVAL;
- }
- if (ctrl != NULL && retval < 0)
- FMDERR("get control failed: %d, ret: %d\n", ctrl->id, retval);
- return retval;
- }
- static int iris_vidioc_g_ext_ctrls(struct file *file, void *priv,
- struct v4l2_ext_controls *ctrl)
- {
- int retval = 0;
- char *data = NULL;
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- struct hci_fm_def_data_rd_req default_data_rd;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- switch ((ctrl->controls[0]).id) {
- case V4L2_CID_PRIVATE_IRIS_READ_DEFAULT:
- data = (ctrl->controls[0]).string;
- memset(&default_data_rd, 0, sizeof(default_data_rd));
- if (copy_from_user(&default_data_rd.mode, data,
- sizeof(default_data_rd)))
- return -EFAULT;
- retval = hci_def_data_read(&default_data_rd, radio->fm_hdev);
- break;
- default:
- retval = -EINVAL;
- }
- return retval;
- }
- static int iris_vidioc_s_ext_ctrls(struct file *file, void *priv,
- struct v4l2_ext_controls *ctrl)
- {
- int retval = 0;
- size_t bytes_to_copy;
- struct hci_fm_tx_ps tx_ps;
- struct hci_fm_tx_rt tx_rt;
- struct hci_fm_def_data_wr_req default_data;
- struct hci_fm_set_cal_req_proc proc_cal_req;
- struct hci_fm_set_spur_table_req spur_tbl_req;
- char *spur_data;
- char tmp_buf[2];
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- char *data = NULL;
- if ((ctrl == NULL) || (ctrl->controls == NULL)
- || (ctrl->count == 0)) {
- retval = -EINVAL;
- return retval;
- }
- switch ((ctrl->controls[0]).id) {
- case V4L2_CID_RDS_TX_PS_NAME:
- FMDBG("In V4L2_CID_RDS_TX_PS_NAME\n");
- /*Pass a sample PS string */
- memset(tx_ps.ps_data, 0, MAX_PS_LENGTH);
- bytes_to_copy = min(ctrl->controls[0].size,
- (size_t)MAX_PS_LENGTH);
- data = (ctrl->controls[0]).string;
- if (copy_from_user(tx_ps.ps_data,
- data, bytes_to_copy))
- return -EFAULT;
- tx_ps.ps_control = 0x01;
- tx_ps.pi = radio->pi;
- tx_ps.pty = radio->pty;
- tx_ps.ps_repeatcount = radio->ps_repeatcount;
- tx_ps.ps_num = (bytes_to_copy / PS_STRING_LEN);
- retval = radio_hci_request(radio->fm_hdev, hci_trans_ps_req,
- (unsigned long)&tx_ps, RADIO_HCI_TIMEOUT);
- break;
- case V4L2_CID_RDS_TX_RADIO_TEXT:
- bytes_to_copy =
- min((ctrl->controls[0]).size, (size_t)MAX_RT_LENGTH);
- data = (ctrl->controls[0]).string;
- memset(tx_rt.rt_data, 0, MAX_RT_LENGTH);
- if (copy_from_user(tx_rt.rt_data,
- data, bytes_to_copy))
- return -EFAULT;
- tx_rt.rt_control = 0x01;
- tx_rt.pi = radio->pi;
- tx_rt.pty = radio->pty;
- tx_rt.rt_len = bytes_to_copy;
- retval = radio_hci_request(radio->fm_hdev, hci_trans_rt_req,
- (unsigned long)&tx_rt, RADIO_HCI_TIMEOUT);
- break;
- case V4L2_CID_PRIVATE_IRIS_WRITE_DEFAULT:
- data = (ctrl->controls[0]).string;
- memset(&default_data, 0, sizeof(default_data));
- /*
- * Check if length of the 'FM Default Data' to be sent
- * is within the maximum 'FM Default Data' packet limit.
- * Max. 'FM Default Data' packet length is 251 bytes:
- * 1 byte - XFR Mode
- * 1 byte - length of the default data
- * 249 bytes - actual data to be configured
- */
- if (ctrl->controls[0].size > (DEFAULT_DATA_SIZE + 2)) {
- pr_err("%s: Default data buffer overflow!\n", __func__);
- return -EINVAL;
- }
- /* copy only 'size' bytes of data as requested by user */
- retval = copy_from_user(&default_data, data,
- ctrl->controls[0].size);
- if (retval > 0) {
- pr_err("%s: Failed to copy %d bytes of default data"
- " passed by user\n", __func__, retval);
- return -EFAULT;
- }
- FMDBG("%s: XFR Mode\t: 0x%x\n", __func__, default_data.mode);
- FMDBG("%s: XFR Data Length\t: %d\n", __func__,
- default_data.length);
- /*
- * Check if the 'length' of the actual XFR data to be configured
- * is valid or not. Length of actual XFR data should be always
- * 2 bytes less than the total length of the 'FM Default Data'.
- * Length of 'FM Default Data' DEF_DATA_LEN: (1+1+XFR Data Size)
- * Length of 'Actual XFR Data' XFR_DATA_LEN: (DEF_DATA_LEN - 2)
- */
- if (default_data.length != (ctrl->controls[0].size - 2)) {
- pr_err("%s: Invalid 'length' parameter passed for "
- "actual xfr data\n", __func__);
- return -EINVAL;
- }
- retval = hci_def_data_write(&default_data, radio->fm_hdev);
- break;
- case V4L2_CID_PRIVATE_IRIS_SET_CALIBRATION:
- data = (ctrl->controls[0]).string;
- bytes_to_copy = (ctrl->controls[0]).size;
- if (bytes_to_copy < PROCS_CALIB_SIZE) {
- FMDERR("data is less than required size");
- return -EFAULT;
- }
- memset(proc_cal_req.data, 0, PROCS_CALIB_SIZE);
- proc_cal_req.mode = PROCS_CALIB_MODE;
- if (copy_from_user(&proc_cal_req.data[0],
- data, sizeof(proc_cal_req.data)))
- return -EFAULT;
- retval = radio_hci_request(radio->fm_hdev,
- hci_fm_set_cal_req_proc,
- (unsigned long)&proc_cal_req,
- RADIO_HCI_TIMEOUT);
- if (retval < 0)
- FMDERR("Set Process calibration failed %d", retval);
- break;
- case V4L2_CID_PRIVATE_IRIS_SET_SPURTABLE:
- memset(&spur_tbl_req, 0, sizeof(spur_tbl_req));
- data = (ctrl->controls[0]).string;
- if (copy_from_user(&bytes_to_copy, &((ctrl->controls[0]).size),
- sizeof(bytes_to_copy))) {
- retval = -EFAULT;
- goto END;
- }
- if (copy_from_user(&tmp_buf[0], &data[0],
- sizeof(tmp_buf))) {
- retval = -EFAULT;
- goto END;
- }
- spur_tbl_req.mode = tmp_buf[0];
- spur_tbl_req.no_of_freqs_entries = tmp_buf[1];
- if (((spur_tbl_req.no_of_freqs_entries * SPUR_DATA_LEN) !=
- bytes_to_copy - 2) ||
- ((spur_tbl_req.no_of_freqs_entries * SPUR_DATA_LEN) >
- 2 * FM_SPUR_TBL_SIZE)) {
- FMDERR("Invalid data len: data[1] = %d, bytes = %zu",
- spur_tbl_req.no_of_freqs_entries,
- bytes_to_copy);
- retval = -EINVAL;
- goto END;
- }
- spur_data =
- kmalloc((spur_tbl_req.no_of_freqs_entries * SPUR_DATA_LEN)
- + 2, GFP_ATOMIC);
- if (!spur_data) {
- FMDERR("Allocation failed for Spur data");
- retval = -EFAULT;
- goto END;
- }
- if (copy_from_user(spur_data,
- &data[2], (bytes_to_copy - 2))) {
- kfree(spur_data);
- retval = -EFAULT;
- goto END;
- }
- if (spur_tbl_req.no_of_freqs_entries <= ENTRIES_EACH_CMD) {
- memcpy(&spur_tbl_req.spur_data[0], spur_data,
- (spur_tbl_req.no_of_freqs_entries *
- SPUR_DATA_LEN));
- retval = radio_hci_request(radio->fm_hdev,
- hci_fm_set_spur_tbl_req,
- (unsigned long)&spur_tbl_req,
- RADIO_HCI_TIMEOUT);
- } else {
- memcpy(&spur_tbl_req.spur_data[0], spur_data,
- (ENTRIES_EACH_CMD * SPUR_DATA_LEN));
- retval = radio_hci_request(radio->fm_hdev,
- hci_fm_set_spur_tbl_req,
- (unsigned long)&spur_tbl_req,
- RADIO_HCI_TIMEOUT);
- if (retval < 0) {
- FMDERR("Spur command failed to execute");
- kfree(spur_data);
- goto END;
- }
- spur_tbl_req.mode = 0x02;/* 02-Continue mode */
- spur_tbl_req.no_of_freqs_entries =
- spur_tbl_req.no_of_freqs_entries
- - ENTRIES_EACH_CMD;
- memcpy(&spur_tbl_req.spur_data[0],
- &spur_data[ENTRIES_EACH_CMD * SPUR_DATA_LEN],
- (spur_tbl_req.no_of_freqs_entries * SPUR_DATA_LEN));
- retval = radio_hci_request(radio->fm_hdev,
- hci_fm_set_spur_tbl_req,
- (unsigned long)&spur_tbl_req,
- RADIO_HCI_TIMEOUT);
- }
- kfree(spur_data);
- break;
- default:
- FMDBG("Shouldn't reach here\n");
- retval = -1;
- }
- return retval;
- }
- static int iris_vidioc_s_ctrl(struct file *file, void *priv,
- struct v4l2_control *ctrl)
- {
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- int retval = 0;
- unsigned int rds_grps_proc = 0;
- __u8 temp_val = 0;
- int prev;
- unsigned long arg = 0;
- struct hci_fm_tx_ps tx_ps = {0};
- struct hci_fm_tx_rt tx_rt = {0};
- struct hci_fm_def_data_rd_req rd;
- struct hci_fm_def_data_wr_req wrd;
- char sinr_th, sinr;
- __u8 intf_det_low_th, intf_det_high_th, intf_det_out;
- unsigned int spur_freq;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- switch (ctrl->id) {
- case V4L2_CID_PRIVATE_IRIS_TX_TONE:
- radio->tone_freq = ctrl->value;
- retval = radio_hci_request(radio->fm_hdev,
- hci_fm_tone_generator, arg,
- RADIO_HCI_TIMEOUT);
- if (retval < 0)
- FMDERR("Error while setting the tone %d", retval);
- break;
- case V4L2_CID_AUDIO_VOLUME:
- break;
- case V4L2_CID_AUDIO_MUTE:
- radio->mute_mode.hard_mute = ctrl->value;
- retval = hci_set_fm_mute_mode(
- &radio->mute_mode,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error while set FM hard mute"" %d\n",
- retval);
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCHMODE:
- radio->g_search_mode = ctrl->value;
- break;
- case V4L2_CID_PRIVATE_IRIS_SCANDWELL:
- radio->g_scan_time = ctrl->value;
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCHON:
- iris_search(radio, ctrl->value, SRCH_DIR_UP);
- break;
- case V4L2_CID_PRIVATE_IRIS_STATE:
- switch (ctrl->value) {
- case FM_RECV:
- if (radio->mode != FM_OFF) {
- FMDERR("FM is not in proper state\n");
- retval = -EINVAL;
- goto END;
- }
- if (is_enable_rx_possible(radio) != 0) {
- FMDERR("%s: fm is not in proper state\n",
- __func__);
- retval = -EINVAL;
- goto END;
- }
- radio->mode = FM_RECV_TURNING_ON;
- retval = hci_cmd(HCI_FM_ENABLE_RECV_CMD,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Error while enabling RECV FM"
- " %d\n", retval);
- radio->mode = FM_OFF;
- goto END;
- } else {
- retval = initialise_recv(radio);
- if (retval < 0) {
- FMDERR("Error while initialising"\
- "radio %d\n", retval);
- hci_cmd(HCI_FM_DISABLE_RECV_CMD,
- radio->fm_hdev);
- radio->mode = FM_OFF;
- goto END;
- }
- }
- if (radio->mode == FM_RECV_TURNING_ON) {
- radio->mode = FM_RECV;
- iris_q_event(radio, IRIS_EVT_RADIO_READY);
- }
- break;
- case FM_TRANS:
- if (is_enable_tx_possible(radio) != 0) {
- retval = -EINVAL;
- goto END;
- }
- radio->mode = FM_TRANS_TURNING_ON;
- retval = hci_cmd(HCI_FM_ENABLE_TRANS_CMD,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Error while enabling TRANS FM"
- " %d\n", retval);
- radio->mode = FM_OFF;
- goto END;
- } else {
- retval = initialise_trans(radio);
- if (retval < 0) {
- FMDERR("Error while initialising"\
- "radio %d\n", retval);
- hci_cmd(HCI_FM_DISABLE_TRANS_CMD,
- radio->fm_hdev);
- radio->mode = FM_OFF;
- goto END;
- }
- }
- if (radio->mode == FM_TRANS_TURNING_ON) {
- radio->mode = FM_TRANS;
- iris_q_event(radio, IRIS_EVT_RADIO_READY);
- }
- break;
- case FM_OFF:
- radio->spur_table_size = 0;
- switch (radio->mode) {
- case FM_RECV:
- radio->mode = FM_TURNING_OFF;
- retval = hci_cmd(HCI_FM_DISABLE_RECV_CMD,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Err on disable recv FM"
- " %d\n", retval);
- radio->mode = FM_RECV;
- goto END;
- }
- break;
- case FM_TRANS:
- radio->mode = FM_TURNING_OFF;
- retval = hci_cmd(HCI_FM_DISABLE_TRANS_CMD,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Err disabling trans FM"
- " %d\n", retval);
- radio->mode = FM_TRANS;
- goto END;
- }
- break;
- default:
- retval = -EINVAL;
- }
- break;
- default:
- retval = -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_REGION:
- if (radio->mode == FM_RECV) {
- retval = iris_recv_set_region(radio, ctrl->value);
- } else {
- if (radio->mode == FM_TRANS)
- retval = iris_trans_set_region(radio,
- ctrl->value);
- else
- retval = -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_SIGNAL_TH:
- temp_val = ctrl->value;
- retval = hci_fm_set_signal_threshold(
- &temp_val,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Error while setting signal threshold\n");
- break;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCH_PTY:
- radio->srch_rds.srch_pty = ctrl->value;
- radio->srch_st_list.srch_pty = ctrl->value;
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCH_PI:
- radio->srch_rds.srch_pi = ctrl->value;
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCH_CNT:
- radio->srch_st_list.srch_list_max = ctrl->value;
- break;
- case V4L2_CID_PRIVATE_IRIS_SPACING:
- if (radio->mode == FM_RECV) {
- radio->recv_conf.ch_spacing = ctrl->value;
- retval = hci_set_fm_recv_conf(
- &radio->recv_conf,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error in setting channel spacing");
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_EMPHASIS:
- switch (radio->mode) {
- case FM_RECV:
- radio->recv_conf.emphasis = ctrl->value;
- retval = hci_set_fm_recv_conf(
- &radio->recv_conf,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error in setting emphasis");
- break;
- case FM_TRANS:
- radio->trans_conf.emphasis = ctrl->value;
- retval = hci_set_fm_trans_conf(
- &radio->trans_conf,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error in setting emphasis");
- break;
- default:
- retval = -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_RDS_STD:
- switch (radio->mode) {
- case FM_RECV:
- radio->recv_conf.rds_std = ctrl->value;
- retval = hci_set_fm_recv_conf(
- &radio->recv_conf,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error in rds_std");
- break;
- case FM_TRANS:
- radio->trans_conf.rds_std = ctrl->value;
- retval = hci_set_fm_trans_conf(
- &radio->trans_conf,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error in rds_Std");
- break;
- default:
- retval = -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSON:
- switch (radio->mode) {
- case FM_RECV:
- radio->recv_conf.rds_std = ctrl->value;
- retval = hci_set_fm_recv_conf(
- &radio->recv_conf,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error in rds_std");
- break;
- case FM_TRANS:
- radio->trans_conf.rds_std = ctrl->value;
- retval = hci_set_fm_trans_conf(
- &radio->trans_conf,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error in rds_Std");
- break;
- default:
- retval = -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGROUP_MASK:
- grp_mask = (grp_mask | oda_agt | ctrl->value);
- radio->rds_grp.rds_grp_enable_mask = grp_mask;
- radio->rds_grp.rds_buf_size = 1;
- radio->rds_grp.en_rds_change_filter = 0;
- retval = hci_fm_rds_grp(&radio->rds_grp, radio->fm_hdev);
- if (retval < 0)
- FMDERR("error in setting group mask\n");
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGRP_RT:
- if ((ctrl->value < 0) || (ctrl->value > 1))
- return -EINVAL;
- prev = radio->g_rds_grp_proc_ps;
- radio->g_rds_grp_proc_ps &= ~(1 << RDS_RT_OFFSET);
- radio->g_rds_grp_proc_ps |=
- (ctrl->value << RDS_RT_OFFSET);
- retval = hci_fm_rds_grps_process(
- &radio->g_rds_grp_proc_ps,
- radio->fm_hdev);
- if (retval < 0)
- radio->g_rds_grp_proc_ps = prev;
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGRP_PS_SIMPLE:
- prev = radio->g_rds_grp_proc_ps;
- if ((ctrl->value < 0) || (ctrl->value > 1))
- return -EINVAL;
- radio->g_rds_grp_proc_ps &= ~(1 << RDS_PS_SIMPLE_OFFSET);
- radio->g_rds_grp_proc_ps |=
- (ctrl->value << RDS_PS_SIMPLE_OFFSET);
- retval = hci_fm_rds_grps_process(
- &radio->g_rds_grp_proc_ps,
- radio->fm_hdev);
- if (retval < 0)
- radio->g_rds_grp_proc_ps = prev;
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGRP_3A:
- prev = grp_mask;
- if ((ctrl->value < 0) || (ctrl->value > 1))
- return -EINVAL;
- grp_mask &= ~(1 << RDS_GRP_3A);
- grp_mask |= (ctrl->value << RDS_GRP_3A);
- radio->rds_grp.rds_grp_enable_mask = grp_mask;
- radio->rds_grp.rds_buf_size = 1;
- radio->rds_grp.en_rds_change_filter = 0;
- retval = hci_fm_rds_grp(&radio->rds_grp, radio->fm_hdev);
- if (retval < 0)
- grp_mask = prev;
- else
- radio->is_rds_grp_3A_enabled = ctrl->value;
- if (ctrl->value == 0) {
- radio->is_rt_plus_enabled = 0;
- radio->is_ert_enabled = 0;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGRP_RT_PLUS:
- retval = 0;
- if ((ctrl->value == 1) && (radio->is_rds_grp_3A_enabled == 1))
- radio->is_rt_plus_enabled = ctrl->value;
- else if ((ctrl->value == 0))
- radio->is_rt_plus_enabled = ctrl->value;
- else
- retval = -EINVAL;
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGRP_ERT:
- retval = 0;
- if ((ctrl->value == 1) && (radio->is_rds_grp_3A_enabled == 1))
- radio->is_ert_enabled = ctrl->value;
- else if ((ctrl->value == 0))
- radio->is_ert_enabled = ctrl->value;
- else
- retval = -EINVAL;
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGROUP_PROC:
- prev = radio->g_rds_grp_proc_ps;
- rds_grps_proc = radio->g_rds_grp_proc_ps | ctrl->value;
- radio->g_rds_grp_proc_ps = (rds_grps_proc >> RDS_CONFIG_OFFSET);
- retval = hci_fm_rds_grps_process(
- &radio->g_rds_grp_proc_ps,
- radio->fm_hdev);
- if (retval < 0)
- radio->g_rds_grp_proc_ps = prev;
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSD_BUF:
- radio->rds_grp.rds_buf_size = ctrl->value;
- break;
- case V4L2_CID_PRIVATE_IRIS_PSALL:
- prev = radio->g_rds_grp_proc_ps;
- rds_grps_proc = (ctrl->value << RDS_CONFIG_OFFSET);
- radio->g_rds_grp_proc_ps |= rds_grps_proc;
- retval = hci_fm_rds_grps_process(
- &radio->g_rds_grp_proc_ps,
- radio->fm_hdev);
- if (retval < 0)
- radio->g_rds_grp_proc_ps = prev;
- break;
- case V4L2_CID_PRIVATE_IRIS_AF_JUMP:
- /*Clear the current AF jump settings*/
- if ((ctrl->value < 0) || (ctrl->value > 1))
- return -EINVAL;
- prev = radio->g_rds_grp_proc_ps;
- radio->g_rds_grp_proc_ps &= ~(1 << RDS_AF_JUMP_OFFSET);
- radio->af_jump_bit = ctrl->value;
- rds_grps_proc = 0x00;
- rds_grps_proc = (ctrl->value << RDS_AF_JUMP_OFFSET);
- radio->g_rds_grp_proc_ps |= rds_grps_proc;
- retval = hci_fm_rds_grps_process(
- &radio->g_rds_grp_proc_ps,
- radio->fm_hdev);
- if (retval < 0)
- radio->g_rds_grp_proc_ps = prev;
- break;
- case V4L2_CID_PRIVATE_IRIS_LP_MODE:
- set_low_power_mode(radio, ctrl->value);
- break;
- case V4L2_CID_PRIVATE_IRIS_ANTENNA:
- temp_val = ctrl->value;
- retval = hci_fm_set_antenna(&temp_val, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Set Antenna failed retval = %x", retval);
- return retval;
- }
- radio->g_antenna = ctrl->value;
- break;
- case V4L2_CID_RDS_TX_PTY:
- radio->pty = ctrl->value;
- break;
- case V4L2_CID_RDS_TX_PI:
- radio->pi = ctrl->value;
- break;
- case V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_PS_NAME:
- tx_ps.ps_control = 0x00;
- retval = radio_hci_request(radio->fm_hdev, hci_trans_ps_req,
- (unsigned long)&tx_ps, RADIO_HCI_TIMEOUT);
- break;
- case V4L2_CID_PRIVATE_IRIS_STOP_RDS_TX_RT:
- tx_rt.rt_control = 0x00;
- retval = radio_hci_request(radio->fm_hdev, hci_trans_rt_req,
- (unsigned long)&tx_rt, RADIO_HCI_TIMEOUT);
- break;
- case V4L2_CID_PRIVATE_IRIS_TX_SETPSREPEATCOUNT:
- radio->ps_repeatcount = ctrl->value;
- break;
- case V4L2_CID_TUNE_POWER_LEVEL:
- if (ctrl->value > FM_TX_PWR_LVL_MAX)
- ctrl->value = FM_TX_PWR_LVL_MAX;
- if (ctrl->value < FM_TX_PWR_LVL_0)
- ctrl->value = FM_TX_PWR_LVL_0;
- rd.mode = FM_TX_PHY_CFG_MODE;
- rd.length = FM_TX_PHY_CFG_LEN;
- rd.param_len = 0x00;
- rd.param = 0x00;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Default data read failed for PHY_CFG %d\n",
- retval);
- break;
- }
- memset(&wrd, 0, sizeof(wrd));
- wrd.mode = FM_TX_PHY_CFG_MODE;
- wrd.length = FM_TX_PHY_CFG_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[FM_TX_PWR_GAIN_OFFSET] =
- (ctrl->value) * FM_TX_PWR_LVL_STEP_SIZE;
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("Default write failed for PHY_TXGAIN %d\n",
- retval);
- break;
- case V4L2_CID_PRIVATE_IRIS_SOFT_MUTE:
- radio->mute_mode.soft_mute = ctrl->value;
- retval = hci_set_fm_mute_mode(
- &radio->mute_mode,
- radio->fm_hdev);
- if (retval < 0)
- FMDERR("Error while setting FM soft mute"" %d\n",
- retval);
- break;
- case V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_ADDR:
- radio->riva_data_req.cmd_params.start_addr = ctrl->value;
- break;
- case V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN:
- if ((ctrl->value > 0) &&
- (ctrl->value <= MAX_RIVA_PEEK_RSP_SIZE)) {
- radio->riva_data_req.cmd_params.length = ctrl->value;
- } else {
- FMDERR("Length %d is more than the buffer size %d\n",
- ctrl->value, MAX_RIVA_PEEK_RSP_SIZE);
- retval = -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_RIVA_POKE:
- if (radio->riva_data_req.cmd_params.length <= MAX_RIVA_PEEK_RSP_SIZE) {
- retval = copy_from_user(radio->riva_data_req.data,
- (void *)ctrl->value,
- radio->riva_data_req.cmd_params.length);
- if (retval == 0) {
- radio->riva_data_req.cmd_params.subopcode =
- RIVA_POKE_OPCODE;
- retval = hci_poke_data(&radio->riva_data_req,
- radio->fm_hdev);
- } else {
- retval = -EINVAL;
- }
- } else {
- FMDERR("Can not copy into driver's buffer. Length %d is more than"
- "the buffer size %d\n", radio->riva_data_req.cmd_params.length,
- MAX_RIVA_PEEK_RSP_SIZE);
- retval = -EINVAL;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR:
- radio->ssbi_data_accs.start_addr = ctrl->value;
- break;
- case V4L2_CID_PRIVATE_IRIS_SSBI_POKE:
- radio->ssbi_data_accs.data = ctrl->value;
- retval = hci_ssbi_poke_reg(&radio->ssbi_data_accs ,
- radio->fm_hdev);
- break;
- case V4L2_CID_PRIVATE_IRIS_RIVA_PEEK:
- radio->riva_data_req.cmd_params.subopcode = RIVA_PEEK_OPCODE;
- ctrl->value = hci_peek_data(&radio->riva_data_req.cmd_params ,
- radio->fm_hdev);
- break;
- case V4L2_CID_PRIVATE_IRIS_SSBI_PEEK:
- radio->ssbi_peek_reg.start_address = ctrl->value;
- hci_ssbi_peek_reg(&radio->ssbi_peek_reg, radio->fm_hdev);
- break;
- case V4L2_CID_PRIVATE_IRIS_RDS_GRP_COUNTERS:
- temp_val = ctrl->value;
- hci_read_grp_counters(&temp_val, radio->fm_hdev);
- break;
- case V4L2_CID_PRIVATE_IRIS_HLSI:
- retval = hci_cmd(HCI_FM_GET_RECV_CONF_CMD,
- radio->fm_hdev);
- if (retval)
- break;
- radio->recv_conf.hlsi = ctrl->value;
- retval = hci_set_fm_recv_conf(
- &radio->recv_conf,
- radio->fm_hdev);
- break;
- case V4L2_CID_PRIVATE_IRIS_SET_NOTCH_FILTER:
- temp_val = ctrl->value;
- retval = hci_set_notch_filter(&temp_val, radio->fm_hdev);
- break;
- case V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD:
- retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to get chnl det thresholds %d", retval);
- return retval;
- }
- radio->ch_det_threshold.high_th = ctrl->value;
- retval = hci_set_ch_det_thresholds_req(&radio->ch_det_threshold,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to set High det threshold %d ", retval);
- return retval;
- }
- break;
- case V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD:
- retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to get chnl det thresholds %d", retval);
- return retval;
- }
- radio->ch_det_threshold.low_th = ctrl->value;
- retval = hci_set_ch_det_thresholds_req(&radio->ch_det_threshold,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to Set Low det threshold %d", retval);
- return retval;
- }
- break;
- case V4L2_CID_PRIVATE_SINR_THRESHOLD:
- retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to get chnl det thresholds %d", retval);
- return retval;
- }
- radio->ch_det_threshold.sinr = ctrl->value;
- retval = hci_set_ch_det_thresholds_req(&radio->ch_det_threshold,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to set SINR threshold %d", retval);
- return retval;
- }
- break;
- case V4L2_CID_PRIVATE_SINR_SAMPLES:
- retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to get chnl det thresholds %d", retval);
- return retval;
- }
- radio->ch_det_threshold.sinr_samples = ctrl->value;
- retval = hci_set_ch_det_thresholds_req(&radio->ch_det_threshold,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to set SINR samples %d", retval);
- return retval;
- }
- break;
- case V4L2_CID_PRIVATE_IRIS_SRCH_ALGORITHM:
- case V4L2_CID_PRIVATE_IRIS_SET_AUDIO_PATH:
- /*
- These private controls are place holders to keep the
- driver compatible with changes done in the frameworks
- which are specific to TAVARUA.
- */
- retval = 0;
- break;
- case V4L2_CID_PRIVATE_SPUR_FREQ:
- if (radio->spur_table_size >= MAX_SPUR_FREQ_LIMIT) {
- FMDERR("%s: Spur Table Full!\n", __func__);
- retval = -1;
- } else
- radio->spur_data.freq[radio->spur_table_size] =
- ctrl->value;
- break;
- case V4L2_CID_PRIVATE_SPUR_FREQ_RMSSI:
- if (radio->spur_table_size >= MAX_SPUR_FREQ_LIMIT) {
- FMDERR("%s: Spur Table Full!\n", __func__);
- retval = -1;
- } else
- radio->spur_data.rmssi[radio->spur_table_size] =
- ctrl->value;
- break;
- case V4L2_CID_PRIVATE_SPUR_SELECTION:
- if (radio->spur_table_size >= MAX_SPUR_FREQ_LIMIT) {
- FMDERR("%s: Spur Table Full!\n", __func__);
- retval = -1;
- } else {
- radio->spur_data.enable[radio->spur_table_size] =
- ctrl->value;
- radio->spur_table_size++;
- }
- break;
- case V4L2_CID_PRIVATE_UPDATE_SPUR_TABLE:
- update_spur_table(radio);
- break;
- case V4L2_CID_PRIVATE_VALID_CHANNEL:
- retval = hci_cmd(HCI_FM_GET_DET_CH_TH_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("%s: Failed to determine channel's validity\n",
- __func__);
- return retval;
- } else {
- sinr_th = radio->ch_det_threshold.sinr;
- intf_det_low_th = radio->ch_det_threshold.low_th;
- intf_det_high_th = radio->ch_det_threshold.high_th;
- }
- retval = hci_cmd(HCI_FM_GET_STATION_PARAM_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("%s: Failed to determine channel's validity\n",
- __func__);
- return retval;
- } else
- sinr = radio->fm_st_rsp.station_rsp.sinr;
- retval = hci_cmd(HCI_FM_STATION_DBG_PARAM_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("%s: Failed to determine channel's validity\n",
- __func__);
- return retval;
- } else
- intf_det_out = radio->st_dbg_param.in_det_out;
- if ((sinr >= sinr_th) && (intf_det_out >= intf_det_low_th) &&
- (intf_det_out <= intf_det_high_th))
- radio->is_station_valid = VALID_CHANNEL;
- else
- radio->is_station_valid = INVALID_CHANNEL;
- break;
- case V4L2_CID_PRIVATE_AF_RMSSI_TH:
- rd.mode = FM_RDS_CNFG_MODE;
- rd.length = FM_RDS_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get AF Jump RMSSI Threshold failed %x", retval);
- return retval;
- }
- wrd.mode = FM_RDS_CNFG_MODE;
- wrd.length = FM_RDS_CNFG_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[AF_RMSSI_TH_LSB_OFFSET] = ((ctrl->value) & 255);
- wrd.data[AF_RMSSI_TH_MSB_OFFSET] = ((ctrl->value) >> 8);
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("set AF jump RMSSI threshold failed\n");
- break;
- case V4L2_CID_PRIVATE_AF_RMSSI_SAMPLES:
- rd.mode = FM_RDS_CNFG_MODE;
- rd.length = FM_RDS_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get AF Jump RMSSI SAMPLES failed %x", retval);
- return retval;
- }
- wrd.mode = FM_RDS_CNFG_MODE;
- wrd.length = FM_RDS_CNFG_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[AF_RMSSI_SAMPLES_OFFSET] = ctrl->value;
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("set AF jump RMSSI Samples failed\n");
- break;
- case V4L2_CID_PRIVATE_GOOD_CH_RMSSI_TH:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Get good channel RMSSI th failed %x", retval);
- return retval;
- }
- wrd.mode = FM_RX_CONFG_MODE;
- wrd.length = FM_RX_CNFG_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[GD_CH_RMSSI_TH_OFFSET] = ctrl->value;
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("set good channel RMSSI th failed\n");
- break;
- case V4L2_CID_PRIVATE_SRCHALGOTYPE:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed %x", retval);
- return retval;
- }
- wrd.mode = FM_RX_CONFG_MODE;
- wrd.length = FM_RX_CNFG_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[SRCH_ALGO_TYPE_OFFSET] = ctrl->value;
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("set Search Algo Type failed\n");
- break;
- case V4L2_CID_PRIVATE_SINRFIRSTSTAGE:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed %x", retval);
- return retval;
- }
- wrd.mode = FM_RX_CONFG_MODE;
- wrd.length = FM_RX_CNFG_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[SINRFIRSTSTAGE_OFFSET] = ctrl->value;
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("set SINR First Stage failed\n");
- break;
- case V4L2_CID_PRIVATE_RMSSIFIRSTSTAGE:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed %x", retval);
- return retval;
- }
- wrd.mode = FM_RX_CONFG_MODE;
- wrd.length = FM_RX_CNFG_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[RMSSIFIRSTSTAGE_OFFSET] = ctrl->value;
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("set RMSSI First Stage failed\n");
- break;
- case V4L2_CID_PRIVATE_CF0TH12:
- rd.mode = FM_RX_CONFG_MODE;
- rd.length = FM_RX_CNFG_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed %x", retval);
- return retval;
- }
- wrd.mode = FM_RX_CONFG_MODE;
- wrd.length = FM_RX_CNFG_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[CF0TH12_BYTE1_OFFSET] = (ctrl->value & 255);
- wrd.data[CF0TH12_BYTE2_OFFSET] = ((ctrl->value >> 8) & 255);
- wrd.data[CF0TH12_BYTE3_OFFSET] = ((ctrl->value >> 16) & 255);
- wrd.data[CF0TH12_BYTE4_OFFSET] = ((ctrl->value >> 24) & 255);
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("set CF0 Threshold failed\n");
- break;
- case V4L2_CID_PRIVATE_SOFT_MUTE_TH:
- rd.mode = DIG_AUDIO_0_MODE;
- rd.length = DIG_AUDIO_0_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed %x", retval);
- return retval;
- }
- wrd.mode = DIG_AUDIO_0_MODE;
- wrd.length = DIG_AUDIO_0_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[SMUTE_TH_OFFSET] = ctrl->value;
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("Set Soft mute Threshold failed\n");
- break;
- case V4L2_CID_PRIVATE_IRIS_RDSGRP_ALL:
- if((ctrl->value < 0) || (ctrl->value > 1)) {
- retval = -EINVAL;
- break;
- }
- if (ctrl->value == 0) {
- radio->rds_grp.rds_grp_enable_mask = 0;
- } else {
- radio->rds_grp.rds_grp_enable_mask = RDS_GRPS_ALL;
- radio->rds_grp.rds_buf_size = 1;
- radio->rds_grp.en_rds_change_filter = 0;
- retval = hci_fm_rds_grp(&radio->rds_grp,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("error in setting all group mask\n");
- } else if(ctrl->value == 0){
- grp_mask = 0;
- oda_agt = 0;
- radio->is_rds_grp_3A_enabled = 0;
- radio->is_rt_plus_enabled = 0;
- radio->is_ert_enabled = 0;
- } else {
- grp_mask = RDS_GRPS_ALL;
- radio->is_rds_grp_3A_enabled = 1;
- }
- }
- break;
- case V4L2_CID_PRIVATE_RXREPEATCOUNT:
- rd.mode = RDS_PS0_XFR_MODE;
- rd.length = RDS_PS0_LEN;
- rd.param_len = 0;
- rd.param = 0;
- retval = hci_def_data_read(&rd, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("default data read failed for PS0 %x", retval);
- return retval;
- }
- wrd.mode = RDS_PS0_XFR_MODE;
- wrd.length = RDS_PS0_LEN;
- memcpy(&wrd.data, &radio->default_data.data,
- radio->default_data.ret_data_len);
- wrd.data[RX_REPEATE_BYTE_OFFSET] = 1;
- retval = hci_def_data_write(&wrd, radio->fm_hdev);
- if (retval < 0)
- FMDERR("set RxRePeat count failed\n");
- break;
- case V4L2_CID_PRIVATE_IRIS_GET_SPUR_TBL:
- spur_freq = ctrl->value;
- retval = radio_hci_request(radio->fm_hdev,
- hci_fm_get_spur_tbl_data,
- (unsigned long)spur_freq,
- RADIO_HCI_TIMEOUT);
- if (retval < 0)
- FMDERR("get Spur data failed\n");
- break;
- case V4L2_CID_PRIVATE_BLEND_SINRHI:
- if (!is_valid_blend_value(ctrl->value)) {
- FMDERR("%s: blend sinr count is not valid\n",
- __func__);
- retval = -EINVAL;
- goto END;
- }
- retval = hci_cmd(HCI_FM_GET_BLND_TBL_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to get blend table %d", retval);
- goto END;
- }
- radio->blend_tbl.scBlendSinrHi = ctrl->value;
- retval = hci_set_blend_tbl_req(&radio->blend_tbl,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to set blend tble %d ", retval);
- goto END;
- }
- break;
- case V4L2_CID_PRIVATE_BLEND_RMSSIHI:
- if (!is_valid_blend_value(ctrl->value)) {
- FMDERR("%s: blend rmssi count is not valid\n",
- __func__);
- retval = -EINVAL;
- goto END;
- }
- retval = hci_cmd(HCI_FM_GET_BLND_TBL_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to get blend table %d", retval);
- goto END;
- }
- radio->blend_tbl.scBlendRmssiHi = ctrl->value;
- retval = hci_set_blend_tbl_req(&radio->blend_tbl,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to set blend tble %d ", retval);
- goto END;
- }
- break;
- default:
- retval = -EINVAL;
- }
- END:
- if (retval > 0)
- retval = -EINVAL;
- return retval;
- }
- static int update_spur_table(struct iris_device *radio)
- {
- struct hci_fm_def_data_wr_req default_data;
- int len = 0, index = 0, offset = 0, i = 0;
- int retval = 0, temp = 0, cnt = 0;
- memset(&default_data, 0, sizeof(default_data));
- /* Pass the mode of SPUR_CLK */
- default_data.mode = CKK_SPUR;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- temp = radio->spur_table_size;
- for (cnt = 0; cnt < (temp / 5); cnt++) {
- offset = 0;
- /*
- * Program the spur entries in spur table in following order:
- * Spur index
- * Length of the spur data
- * Spur Data:
- * MSB of the spur frequency
- * LSB of the spur frequency
- * Enable/Disable the spur frequency
- * RMSSI value of the spur frequency
- */
- default_data.data[offset++] = ENTRY_0 + cnt;
- for (i = 0; i < SPUR_ENTRIES_PER_ID; i++) {
- default_data.data[offset++] = GET_FREQ(COMPUTE_SPUR(
- radio->spur_data.freq[index]), 0);
- default_data.data[offset++] = GET_FREQ(COMPUTE_SPUR(
- radio->spur_data.freq[index]), 1);
- default_data.data[offset++] =
- radio->spur_data.enable[index];
- default_data.data[offset++] =
- radio->spur_data.rmssi[index];
- index++;
- }
- len = (SPUR_ENTRIES_PER_ID * SPUR_DATA_SIZE);
- default_data.length = (len + 1);
- retval = hci_def_data_write(&default_data, radio->fm_hdev);
- if (retval < 0) {
- FMDBG("%s: Failed to configure entries for ID : %d\n",
- __func__, default_data.data[0]);
- return retval;
- }
- }
- /* Compute balance SPUR frequencies to be programmed */
- temp %= SPUR_ENTRIES_PER_ID;
- if (temp > 0) {
- offset = 0;
- default_data.data[offset++] = (radio->spur_table_size / 5);
- for (i = 0; i < temp; i++) {
- default_data.data[offset++] = GET_FREQ(COMPUTE_SPUR(
- radio->spur_data.freq[index]), 0);
- default_data.data[offset++] = GET_FREQ(COMPUTE_SPUR(
- radio->spur_data.freq[index]), 1);
- default_data.data[offset++] =
- radio->spur_data.enable[index];
- default_data.data[offset++] =
- radio->spur_data.rmssi[index];
- index++;
- }
- len = (temp * SPUR_DATA_SIZE);
- default_data.length = (len + 1);
- retval = hci_def_data_write(&default_data, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("%s: Failed to configure entries for ID : %d\n",
- __func__, default_data.data[0]);
- return retval;
- }
- }
- return retval;
- }
- static int iris_vidioc_g_tuner(struct file *file, void *priv,
- struct v4l2_tuner *tuner)
- {
- int retval;
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- if (tuner->index > 0) {
- FMDERR("Invalid Tuner Index");
- return -EINVAL;
- }
- if (radio->mode == FM_RECV) {
- retval = hci_cmd(HCI_FM_GET_STATION_PARAM_CMD, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to Get station params");
- return retval;
- }
- tuner->type = V4L2_TUNER_RADIO;
- tuner->rangelow =
- radio->recv_conf.band_low_limit * TUNE_PARAM;
- tuner->rangehigh =
- radio->recv_conf.band_high_limit * TUNE_PARAM;
- tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
- tuner->capability = V4L2_TUNER_CAP_LOW;
- tuner->signal = radio->fm_st_rsp.station_rsp.rssi;
- tuner->audmode = radio->fm_st_rsp.station_rsp.stereo_prg;
- tuner->afc = 0;
- } else if (radio->mode == FM_TRANS) {
- retval = hci_cmd(HCI_FM_GET_TX_CONFIG, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("get Tx config failed %d\n", retval);
- return retval;
- } else {
- tuner->type = V4L2_TUNER_RADIO;
- tuner->rangelow =
- radio->trans_conf.band_low_limit * TUNE_PARAM;
- tuner->rangehigh =
- radio->trans_conf.band_high_limit * TUNE_PARAM;
- }
- } else
- return -EINVAL;
- return 0;
- }
- static int iris_vidioc_s_tuner(struct file *file, void *priv,
- struct v4l2_tuner *tuner)
- {
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- int retval = 0;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- if (tuner->index > 0)
- return -EINVAL;
- if (radio->mode == FM_RECV) {
- radio->recv_conf.band_low_limit = tuner->rangelow / TUNE_PARAM;
- radio->recv_conf.band_high_limit =
- tuner->rangehigh / TUNE_PARAM;
- if (tuner->audmode == V4L2_TUNER_MODE_MONO) {
- radio->stereo_mode.stereo_mode = 0x01;
- retval = hci_set_fm_stereo_mode(
- &radio->stereo_mode,
- radio->fm_hdev);
- } else {
- radio->stereo_mode.stereo_mode = 0x00;
- retval = hci_set_fm_stereo_mode(
- &radio->stereo_mode,
- radio->fm_hdev);
- }
- if (retval < 0)
- FMDERR(": set tuner failed with %d\n", retval);
- return retval;
- } else if (radio->mode == FM_TRANS) {
- radio->trans_conf.band_low_limit =
- tuner->rangelow / TUNE_PARAM;
- radio->trans_conf.band_high_limit =
- tuner->rangehigh / TUNE_PARAM;
- } else
- return -EINVAL;
- return retval;
- }
- static int iris_vidioc_g_frequency(struct file *file, void *priv,
- struct v4l2_frequency *freq)
- {
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- if ((freq != NULL) && (radio != NULL)) {
- freq->frequency =
- radio->fm_st_rsp.station_rsp.station_freq * TUNE_PARAM;
- } else
- return -EINVAL;
- return 0;
- }
- static int iris_vidioc_s_frequency(struct file *file, void *priv,
- struct v4l2_frequency *freq)
- {
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- int retval = -1;
- freq->frequency = freq->frequency / TUNE_PARAM;
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- if (freq->type != V4L2_TUNER_RADIO)
- return -EINVAL;
- /* We turn off RDS prior to tuning to a new station.
- because of a bug in SoC which prevents tuning
- during RDS transmission.
- */
- if (radio->mode == FM_TRANS
- && (radio->trans_conf.rds_std == 0 ||
- radio->trans_conf.rds_std == 1)) {
- radio->prev_trans_rds = radio->trans_conf.rds_std;
- radio->trans_conf.rds_std = 2;
- hci_set_fm_trans_conf(&radio->trans_conf,
- radio->fm_hdev);
- }
- retval = iris_set_freq(radio, freq->frequency);
- if (radio->mode == FM_TRANS
- && radio->trans_conf.rds_std == 2
- && (radio->prev_trans_rds == 1
- || radio->prev_trans_rds == 0)) {
- radio->trans_conf.rds_std = radio->prev_trans_rds;
- hci_set_fm_trans_conf(&radio->trans_conf,
- radio->fm_hdev);
- }
- if (retval < 0)
- FMDERR(" set frequency failed with %d\n", retval);
- return retval;
- }
- static int iris_fops_release(struct file *file)
- {
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- int retval = 0;
- FMDBG("Enter %s ", __func__);
- if (radio == NULL)
- return -EINVAL;
- if (radio->mode == FM_OFF)
- goto END;
- if (radio->mode == FM_RECV)
- radio->is_fm_closing = 1;
- radio->mode = FM_TURNING_OFF;
- retval = hci_cmd_uninterruptible(HCI_FM_DISABLE_RECV_CMD,
- radio->fm_hdev);
- radio->is_fm_closing = 0;
- else if (radio->mode == FM_TRANS)
- radio->is_fm_closing = 1;
- radio->mode = FM_TURNING_OFF;
- retval = hci_cmd_uninterruptible(HCI_FM_DISABLE_TRANS_CMD,
- radio->fm_hdev);
- radio->is_fm_closing = 0;
- } else if (radio->mode == FM_CALIB) {
- radio->mode = FM_OFF;
- return retval;
- }
- END:
- mutex_lock(&fm_smd_enable);
- if (radio->fm_hdev != NULL)
- radio->fm_hdev->close_smd();
- mutex_unlock(&fm_smd_enable);
- if (retval < 0)
- FMDERR("Err on disable FM %d\n", retval);
- radio->mode = FM_OFF;
- return retval;
- }
- static int iris_vidioc_dqbuf(struct file *file, void *priv,
- struct v4l2_buffer *buffer)
- {
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- enum iris_buf_t buf_type = -1;
- unsigned char buf_fifo[STD_BUF_SIZE] = {0};
- struct kfifo *data_fifo = NULL;
- unsigned char *buf = NULL;
- unsigned int len = 0, retval = -1;
- if ((radio == NULL) || (buffer == NULL)) {
- FMDERR("radio/buffer is NULL\n");
- return -ENXIO;
- }
- buf_type = buffer->index;
- buf = (unsigned char *)buffer->m.userptr;
- len = buffer->length;
- if ((buf_type < IRIS_BUF_MAX) && (buf_type >= 0)) {
- data_fifo = &radio->data_buf[buf_type];
- if (buf_type == IRIS_BUF_EVENTS)
- if (wait_event_interruptible(radio->event_queue,
- kfifo_len(data_fifo)) < 0)
- return -EINTR;
- } else {
- FMDERR("invalid buffer type\n");
- return -EINVAL;
- }
- if (len <= STD_BUF_SIZE) {
- buffer->bytesused = kfifo_out_locked(data_fifo, &buf_fifo[0],
- len, &radio->buf_lock[buf_type]);
- } else {
- FMDERR("kfifo_out_locked can not use len more than 128\n");
- return -EINVAL;
- }
- retval = copy_to_user(buf, &buf_fifo[0], buffer->bytesused);
- if (retval > 0) {
- FMDERR("Failed to copy %d bytes of data\n", retval);
- return -EAGAIN;
- }
- return retval;
- }
- static int iris_vidioc_g_fmt_type_private(struct file *file, void *priv,
- struct v4l2_format *f)
- {
- return 0;
- }
- static int iris_vidioc_s_hw_freq_seek(struct file *file, void *priv,
- struct v4l2_hw_freq_seek *seek)
- {
- struct iris_device *radio = video_get_drvdata(video_devdata(file));
- int dir;
- if (seek->seek_upward)
- dir = SRCH_DIR_UP;
- else
- dir = SRCH_DIR_DOWN;
- return iris_search(radio, CTRL_ON, dir);
- }
- static int iris_vidioc_querycap(struct file *file, void *priv,
- struct v4l2_capability *capability)
- {
- struct iris_device *radio = video_get_drvdata(video_devdata(file));;
- FMDBG("%s\n", __func__);
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver));
- strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card));
- capability->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
- radio->g_cap = capability;
- return 0;
- }
- static int initialise_recv(struct iris_device *radio)
- {
- int retval;
- if (unlikely(radio == NULL)) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- radio->mute_mode.soft_mute = CTRL_OFF;
- retval = hci_set_fm_mute_mode(&radio->mute_mode,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to enable Smute\n");
- return retval;
- }
- radio->stereo_mode.stereo_mode = CTRL_OFF;
- radio->stereo_mode.sig_blend = sig_blend;
- radio->stereo_mode.intf_blend = CTRL_ON;
- radio->stereo_mode.most_switch = CTRL_ON;
- retval = hci_set_fm_stereo_mode(&radio->stereo_mode,
- radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Failed to set stereo mode\n");
- return retval;
- }
- radio->event_mask = SIG_LEVEL_INTR | RDS_SYNC_INTR | AUDIO_CTRL_INTR;
- retval = hci_conf_event_mask(&radio->event_mask, radio->fm_hdev);
- if (retval < 0) {
- FMDERR("Enable Async events failed");
- return retval;
- }
- retval = hci_cmd(HCI_FM_GET_RECV_CONF_CMD, radio->fm_hdev);
- if (retval < 0)
- FMDERR("Failed to get the Recv Config\n");
- return retval;
- }
- static int initialise_trans(struct iris_device *radio)
- {
- int retval;
- if (unlikely(radio == NULL)) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- retval = hci_cmd(HCI_FM_GET_TX_CONFIG, radio->fm_hdev);
- if (retval < 0)
- FMDERR("get frequency failed %d\n", retval);
- return retval;
- }
- static int is_enable_rx_possible(struct iris_device *radio)
- {
- int retval = 1;
- if (unlikely(radio == NULL)) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- if (radio->mode == FM_OFF || radio->mode == FM_RECV)
- retval = 0;
- return retval;
- }
- static int is_enable_tx_possible(struct iris_device *radio)
- {
- int retval = 1;
- if (radio->mode == FM_OFF || radio->mode == FM_TRANS)
- retval = 0;
- return retval;
- }
- static const struct v4l2_ioctl_ops iris_ioctl_ops = {
- .vidioc_querycap = iris_vidioc_querycap,
- .vidioc_queryctrl = iris_vidioc_queryctrl,
- .vidioc_g_ctrl = iris_vidioc_g_ctrl,
- .vidioc_s_ctrl = iris_vidioc_s_ctrl,
- .vidioc_g_tuner = iris_vidioc_g_tuner,
- .vidioc_s_tuner = iris_vidioc_s_tuner,
- .vidioc_g_frequency = iris_vidioc_g_frequency,
- .vidioc_s_frequency = iris_vidioc_s_frequency,
- .vidioc_s_hw_freq_seek = iris_vidioc_s_hw_freq_seek,
- .vidioc_dqbuf = iris_vidioc_dqbuf,
- .vidioc_g_fmt_type_private = iris_vidioc_g_fmt_type_private,
- .vidioc_s_ext_ctrls = iris_vidioc_s_ext_ctrls,
- .vidioc_g_ext_ctrls = iris_vidioc_g_ext_ctrls,
- };
- static int is_initialized = 0;
- static int video_open(struct file *file) {
- int retval;
- if (!is_initialized) {
- retval = hci_fm_smd_register();
- if (retval) {
- FMDERR(": hci_fm_smd_register failed\n");
- return retval;
- }
- is_initialized = 1;
- }
- return 0;
- }
- static const struct v4l2_file_operations iris_fops = {
- .owner = THIS_MODULE,
- .unlocked_ioctl = video_ioctl2,
- .release = iris_fops_release,
- .open = video_open,
- };
- static struct video_device iris_viddev_template = {
- .fops = &iris_fops,
- .ioctl_ops = &iris_ioctl_ops,
- .name = DRIVER_NAME,
- .release = video_device_release,
- };
- static struct video_device *video_get_dev(void)
- {
- return priv_videodev;
- }
- static int __init iris_probe(struct platform_device *pdev)
- {
- struct iris_device *radio;
- int retval;
- int radio_nr = -1;
- int i;
- if (!pdev) {
- FMDERR(": pdev is null\n");
- return -ENOMEM;
- }
- radio = kzalloc(sizeof(struct iris_device), GFP_KERNEL);
- if (!radio) {
- FMDERR(": Could not allocate radio device\n");
- return -ENOMEM;
- }
- radio->dev = &pdev->dev;
- platform_set_drvdata(pdev, radio);
- radio->videodev = video_device_alloc();
- if (!radio->videodev) {
- FMDERR(": Could not allocate V4L device\n");
- kfree(radio);
- return -ENOMEM;
- }
- memcpy(radio->videodev, &iris_viddev_template,
- sizeof(iris_viddev_template));
- for (i = 0; i < IRIS_BUF_MAX; i++) {
- int kfifo_alloc_rc = 0;
- spin_lock_init(&radio->buf_lock[i]);
- if ((i == IRIS_BUF_RAW_RDS) || (i == IRIS_BUF_PEEK))
- kfifo_alloc_rc = kfifo_alloc(&radio->data_buf[i],
- rds_buf*3, GFP_KERNEL);
- else if ((i == IRIS_BUF_CAL_DATA) || (i == IRIS_BUF_RT_RDS))
- kfifo_alloc_rc = kfifo_alloc(&radio->data_buf[i],
- STD_BUF_SIZE*2, GFP_KERNEL);
- else
- kfifo_alloc_rc = kfifo_alloc(&radio->data_buf[i],
- STD_BUF_SIZE, GFP_KERNEL);
- if (kfifo_alloc_rc != 0) {
- FMDERR("failed allocating buffers %d\n",
- kfifo_alloc_rc);
- for (; i > -1; i--)
- kfifo_free(&radio->data_buf[i]);
- video_device_release(radio->videodev);
- kfree(radio);
- return -ENOMEM;
- }
- }
- mutex_init(&radio->lock);
- init_completion(&radio->sync_xfr_start);
- radio->tune_req = 0;
- radio->prev_trans_rds = 2;
- radio->is_fm_closing = 0;
- init_waitqueue_head(&radio->event_queue);
- init_waitqueue_head(&radio->read_queue);
- video_set_drvdata(radio->videodev, radio);
- if (NULL == video_get_drvdata(radio->videodev))
- FMDERR(": video_get_drvdata failed\n");
- retval = video_register_device(radio->videodev, VFL_TYPE_RADIO,
- radio_nr);
- if (retval) {
- FMDERR(": Could not register video device\n");
- mutex_destroy(&radio->lock);
- video_device_release(radio->videodev);
- for (; i > -1; i--)
- kfifo_free(&radio->data_buf[i]);
- kfree(radio);
- return retval;
- } else {
- priv_videodev = kzalloc(sizeof(struct video_device),
- GFP_KERNEL);
- if (priv_videodev != NULL) {
- memcpy(priv_videodev, radio->videodev,
- sizeof(struct video_device));
- } else {
- mutex_destroy(&radio->lock);
- video_unregister_device(radio->videodev);
- video_device_release(radio->videodev);
- for (; i > -1; i--)
- kfifo_free(&radio->data_buf[i]);
- kfree(radio);
- return -ENOMEM;
- }
- }
- return 0;
- }
- static int __devexit iris_remove(struct platform_device *pdev)
- {
- int i;
- struct iris_device *radio = platform_get_drvdata(pdev);
- if (radio == NULL) {
- FMDERR(":radio is null");
- return -EINVAL;
- }
- hci_fm_smd_deregister();
- video_unregister_device(radio->videodev);
- for (i = 0; i < IRIS_BUF_MAX; i++)
- kfifo_free(&radio->data_buf[i]);
- kfree(radio);
- platform_set_drvdata(pdev, NULL);
- return 0;
- }
- static const struct of_device_id iris_fm_match[] = {
- {.compatible = "qcom,iris_fm"},
- {}
- };
- static struct platform_driver iris_driver = {
- .driver = {
- .owner = THIS_MODULE,
- .name = "iris_fm",
- .of_match_table = iris_fm_match,
- },
- .remove = __devexit_p(iris_remove),
- };
- static int __init iris_radio_init(void)
- {
- return platform_driver_probe(&iris_driver, iris_probe);
- }
- module_init(iris_radio_init);
- static void __exit iris_radio_exit(void)
- {
- platform_driver_unregister(&iris_driver);
- }
- module_exit(iris_radio_exit);
- MODULE_LICENSE("GPL v2");
- MODULE_AUTHOR(DRIVER_AUTHOR);
- MODULE_DESCRIPTION(DRIVER_DESC);
|