| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804 |
- #include <linux/kernel.h>
- #include <linux/proc_fs.h>
- #include <linux/platform_device.h>
- #include <asm/setup.h>
- #include <linux/zlib.h>
- #include <linux/cdev.h>
- #include "ark_track.h"
- #include "ark1668e_carback.h"
- #include "ark_mcu.h"
- #include <asm/cacheflush.h>
- #include <linux/dma-mapping.h>
- #include <linux/vmalloc.h>
- const idmap_info radar_idmap[RADAR_MAX] =
- {
- //FL
- { "FL_00",FL_00,0},
- { "FL_01",FL_01,0},
- { "FL_02",FL_02,0},
- { "FL_03",FL_03,0},
- { "FL_04",FL_04,0},
- { "FL_05",FL_05,0},
- { "FL_06",FL_06,0},
- { "FL_10",FL_10,0},
- { "FL_11",FL_11,0},
- { "FL_12",FL_12,0},
- { "FL_13",FL_13,0},
- { "FL_14",FL_14,0},
- { "FL_15",FL_15,0},
- { "FL_16",FL_16,0},
- { "FL_20",FL_20,0},
- { "FL_21",FL_21,0},
- { "FL_22",FL_22,0},
- { "FL_23",FL_23,0},
- { "FL_24",FL_24,0},
- { "FL_25",FL_25,0},
- { "FL_26",FL_26,0},
- { "FL_30",FL_30,0},
- { "FL_31",FL_31,0},
- { "FL_32",FL_32,0},
- { "FL_33",FL_33,0},
- { "FL_34",FL_34,0},
- { "FL_35",FL_35,0},
- { "FL_36",FL_36,0},
- { "FL_40",FL_40,0},
- { "FL_41",FL_41,0},
- { "FL_42",FL_42,0},
- { "FL_43",FL_43,0},
- { "FL_44",FL_44,0},
- { "FL_45",FL_45,0},
- { "FL_46",FL_46,0},
- { "FL_50",FL_50,0},
- { "FL_51",FL_51,0},
- { "FL_52",FL_52,0},
- { "FL_53",FL_53,0},
- { "FL_54",FL_54,0},
- { "FL_55",FL_55,0},
- { "FL_56",FL_56,0},
- { "FL_60",FL_60,0},
- { "FL_61",FL_61,0},
- { "FL_62",FL_62,0},
- { "FL_63",FL_63,0},
- { "FL_64",FL_64,0},
- { "FL_65",FL_65,0},
- { "FL_66",FL_66,0},
- //FR
- { "FR_00",FR_00,1},
- { "FR_01",FR_01,1},
- { "FR_02",FR_02,1},
- { "FR_03",FR_03,1},
- { "FR_04",FR_04,1},
- { "FR_05",FR_05,1},
- { "FR_06",FR_06,1},
- { "FR_10",FR_10,1},
- { "FR_11",FR_11,1},
- { "FR_12",FR_12,1},
- { "FR_13",FR_13,1},
- { "FR_14",FR_14,1},
- { "FR_15",FR_15,1},
- { "FR_16",FR_16,1},
- { "FR_20",FR_20,1},
- { "FR_21",FR_21,1},
- { "FR_22",FR_22,1},
- { "FR_23",FR_23,1},
- { "FR_24",FR_24,1},
- { "FR_25",FR_25,1},
- { "FR_26",FR_26,1},
- { "FR_30",FR_30,1},
- { "FR_31",FR_31,1},
- { "FR_32",FR_32,1},
- { "FR_33",FR_33,1},
- { "FR_34",FR_34,1},
- { "FR_35",FR_35,1},
- { "FR_36",FR_36,1},
- { "FR_40",FR_40,1},
- { "FR_41",FR_41,1},
- { "FR_42",FR_42,1},
- { "FR_43",FR_43,1},
- { "FR_44",FR_44,1},
- { "FR_45",FR_45,1},
- { "FR_46",FR_46,1},
- { "FR_50",FR_50,1},
- { "FR_51",FR_51,1},
- { "FR_52",FR_52,1},
- { "FR_53",FR_53,1},
- { "FR_54",FR_54,1},
- { "FR_55",FR_55,1},
- { "FR_56",FR_56,1},
- { "FR_60",FR_60,1},
- { "FR_61",FR_61,1},
- { "FR_62",FR_62,1},
- { "FR_63",FR_63,1},
- { "FR_64",FR_64,1},
- { "FR_65",FR_65,1},
- { "FR_66",FR_66,1},
- //RL
- { "RL_00",RL_00,2},
- { "RL_01",RL_01,2},
- { "RL_02",RL_02,2},
- { "RL_03",RL_03,2},
- { "RL_04",RL_04,2},
- { "RL_05",RL_05,2},
- { "RL_06",RL_06,2},
- { "RL_10",RL_10,2},
- { "RL_11",RL_11,2},
- { "RL_12",RL_12,2},
- { "RL_13",RL_13,2},
- { "RL_14",RL_14,2},
- { "RL_15",RL_15,2},
- { "RL_16",RL_16,2},
- { "RL_20",RL_20,2},
- { "RL_21",RL_21,2},
- { "RL_22",RL_22,2},
- { "RL_23",RL_23,2},
- { "RL_24",RL_24,2},
- { "RL_25",RL_25,2},
- { "RL_26",RL_26,2},
- { "RL_30",RL_30,2},
- { "RL_31",RL_31,2},
- { "RL_32",RL_32,2},
- { "RL_33",RL_33,2},
- { "RL_34",RL_34,2},
- { "RL_35",RL_35,2},
- { "RL_36",RL_36,2},
- { "RL_40",RL_40,2},
- { "RL_41",RL_41,2},
- { "RL_42",RL_42,2},
- { "RL_43",RL_43,2},
- { "RL_44",RL_44,2},
- { "RL_45",RL_45,2},
- { "RL_46",RL_46,2},
- { "RL_50",RL_50,2},
- { "RL_51",RL_51,2},
- { "RL_52",RL_52,2},
- { "RL_53",RL_53,2},
- { "RL_54",RL_54,2},
- { "RL_55",RL_55,2},
- { "RL_56",RL_56,2},
- { "RL_60",RL_60,2},
- { "RL_61",RL_61,2},
- { "RL_62",RL_62,2},
- { "RL_63",RL_63,2},
- { "RL_64",RL_64,2},
- { "RL_65",RL_65,2},
- { "RL_66",RL_66,2},
- //RR
- { "RR_00",RR_00,3},
- { "RR_01",RR_01,3},
- { "RR_02",RR_02,3},
- { "RR_03",RR_03,3},
- { "RR_04",RR_04,3},
- { "RR_05",RR_05,3},
- { "RR_06",RR_06,3},
- { "RR_10",RR_10,3},
- { "RR_11",RR_11,3},
- { "RR_12",RR_12,3},
- { "RR_13",RR_13,3},
- { "RR_14",RR_14,3},
- { "RR_15",RR_15,3},
- { "RR_16",RR_16,3},
- { "RR_20",RR_20,3},
- { "RR_21",RR_21,3},
- { "RR_22",RR_22,3},
- { "RR_23",RR_23,3},
- { "RR_24",RR_24,3},
- { "RR_25",RR_25,3},
- { "RR_26",RR_26,3},
- { "RR_30",RR_30,3},
- { "RR_31",RR_31,3},
- { "RR_32",RR_32,3},
- { "RR_33",RR_33,3},
- { "RR_34",RR_34,3},
- { "RR_35",RR_35,3},
- { "RR_36",RR_36,3},
- { "RR_40",RR_40,3},
- { "RR_41",RR_41,3},
- { "RR_42",RR_42,3},
- { "RR_43",RR_43,3},
- { "RR_44",RR_44,3},
- { "RR_45",RR_45,3},
- { "RR_46",RR_46,3},
- { "RR_50",RR_50,3},
- { "RR_51",RR_51,3},
- { "RR_52",RR_52,3},
- { "RR_53",RR_53,3},
- { "RR_54",RR_54,3},
- { "RR_55",RR_55,3},
- { "RR_56",RR_56,3},
- { "RR_60",RR_60,3},
- { "RR_61",RR_61,3},
- { "RR_62",RR_62,3},
- { "RR_63",RR_63,3},
- { "RR_64",RR_64,3},
- { "RR_65",RR_65,3},
- { "RR_66",RR_66,3},
- };
- extern int dvr_detect_carback_signal(void);
- extern int vbox_track_paint;
- track_context *g_ptrack_context;
- static user_header* g_pheader_buf;
- static z_stream stream;
- static int initialized;
- unsigned int track_pic_id;
- unsigned int radar_pic_id;
- unsigned int car_pic_id;
- unsigned int track2_pic_id;//small track for vbox
- extern struct carback_context* g_carback_context;
- extern int first_draw_track;
- extern int track_switch_id;
- static user2_header* g_pheader2_buf;
- track_context2 *g_ptrack_context2 = NULL;
- static unsigned int get_time_ms(void)
- {
- struct timeval tv;
- //float s;
- do_gettimeofday(&tv);
- //s = tv.tv_usec; s *= 0.000001; s += tv.tv_sec;
- return tv.tv_sec * 1000 + tv.tv_usec / 1000;
- }
- static void show_header_info(void)
- {
- user_header* p = g_pheader_buf;
- if(p == NULL) {
- printk(KERN_ERR "header_info_show error!\n");
- return;
- }
- ARKTRACK_DBGPRTK("header_buf ===>identity=0x%0x track_total=%d car_total=%d signal_total= %d append1 = %d append2 = %d radar_total=%d file_type=0x%0x file_size=0x%0x\n",\
- p->identity,p->track_total,p->car_total,p->signal_total,p->append1_total,p->append2_total,p->radar_total,p->file_type,p->file_size);
- ARKTRACK_DBGPRTK("track rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->track_rect.pos_x,\
- p->track_rect.pos_y,p->track_rect.width,p->track_rect.height);
- ARKTRACK_DBGPRTK("car rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->car_rect.pos_x,\
- p->car_rect.pos_y,p->car_rect.width,p->car_rect.height);
- ARKTRACK_DBGPRTK("signal rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->signal_rect.pos_x,\
- p->signal_rect.pos_y,p->signal_rect.width,p->signal_rect.height);
- ARKTRACK_DBGPRTK("append1 rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->append1_rect.pos_x,\
- p->append1_rect.pos_y,p->append1_rect.width,p->append1_rect.height);
- ARKTRACK_DBGPRTK("append2 rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->append2_rect.pos_x,\
- p->append2_rect.pos_y,p->append2_rect.width,p->append2_rect.height);
- ARKTRACK_DBGPRTK("radar0 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[0].pos_x,\
- p->radar_rect[0].pos_y,p->radar_rect[0].width,p->radar_rect[0].height);
- ARKTRACK_DBGPRTK("radar1 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[1].pos_x,\
- p->radar_rect[1].pos_y,p->radar_rect[1].width,p->radar_rect[1].height);
- ARKTRACK_DBGPRTK("radar2 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[2].pos_x,\
- p->radar_rect[2].pos_y,p->radar_rect[2].width,p->radar_rect[2].height);
- ARKTRACK_DBGPRTK("radar3 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[3].pos_x,\
- p->radar_rect[3].pos_y,p->radar_rect[3].width,p->radar_rect[3].height);
- ARKTRACK_DBGPRTK("track2 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->track2_rect.pos_x,\
- p->track2_rect.pos_y,p->track2_rect.width,p->track2_rect.height);
- ARKTRACK_DBGPRTK("track[0] image===> image_type=%d image_store_id=%d image_id=0x%0x image_offset=0x%0x image_size=0x%0x\n",\
- p->track[0].image_type,p->track[0].image_store_id,p->track[0].image_id,p->track[0].image_offset,p->track[0].image_size);
- ARKTRACK_DBGPRTK("car[0] image===> image_type=%d image_store_id=%d image_id=0x%0x image_offset=0x%0x image_size=0x%0x\n",\
- p->car[0].image_type,p->car[0].image_store_id,p->car[0].image_id,p->car[0].image_offset,p->car[0].image_size);
- ARKTRACK_DBGPRTK("signal[0] image===> image_type=%d image_store_id=%d image_id=0x%0x image_offset=0x%0x image_size=0x%0x\n",\
- p->signal[0].image_type,p->signal[0].image_store_id,p->signal[0].image_id,p->signal[0].image_offset,p->signal[0].image_size);
- ARKTRACK_DBGPRTK("append1[0] image===> image_type=%d image_store_id=%d image_id=0x%0x image_offset=0x%0x image_size=0x%0x\n",\
- p->append1[0].image_type,p->append1[0].image_store_id,p->append1[0].image_id,p->append1[0].image_offset,p->append1[0].image_size);
- ARKTRACK_DBGPRTK("append2[0] image===> image_type=%d image_store_id=%d image_id=0x%0x image_offset=0x%0x image_size=0x%0x\n",\
- p->append2[0].image_type,p->append2[0].image_store_id,p->append2[0].image_id,p->append2[0].image_offset,p->append2[0].image_size);
- ARKTRACK_DBGPRTK("radar[1] image===> image_type=%d image_store_id=%d image_id=0x%0x image_offset=0x%0x image_size=0x%0x\n",\
- p->radar[1].image_type,p->radar[1].image_store_id,p->radar[1].image_id,p->radar[1].image_offset,p->radar[1].image_size);
- ARKTRACK_DBGPRTK("track2[0]image===> image_type=%d image_store_id=%d image_id=0x%0x image_offset=0x%0x image_size=0x%0x\n",\
- p->track2[0].image_type,p->track2[0].image_store_id,p->track2[0].image_id,p->track2[0].image_offset,p->track2[0].image_size);
- }
- static void set_rect_default(void)
- {
- user_header* p = g_pheader_buf;
- p->car_total = 0;
- p->radar_total = 0;
- p->track_rect.pos_x = 0;
- p->track_rect.pos_y = 0;
- p->track_rect.width = g_carback_context->screen_width;
- p->track_rect.height= g_carback_context->screen_height;
- p->car_rect.pos_x = 0;
- p->car_rect.pos_y = 0;
- p->car_rect.width = 0;
- p->car_rect.height= 0;
- p->radar_rect[0].pos_x = 0;
- p->radar_rect[0].pos_y = 0;
- p->radar_rect[0].width = 0;
- p->radar_rect[0].height= 0;
- p->radar_rect[1].pos_x = 0;
- p->radar_rect[1].pos_y = 0;
- p->radar_rect[1].width = 0;
- p->radar_rect[1].height= 0;
- p->radar_rect[2].pos_x = 0;
- p->radar_rect[2].pos_y = 0;
- p->radar_rect[2].width = 0;
- p->radar_rect[2].height= 0;
- p->radar_rect[3].pos_x = 0;
- p->radar_rect[3].pos_y = 0;
- p->radar_rect[3].width = 0;
- p->radar_rect[3].height= 0;
-
- p->track2_rect.pos_x = 0;
- p->track2_rect.pos_y = 0;
- p->track2_rect.width = 0;
- p->track2_rect.height= 0;
-
- }
- static int check_header_info(void)
- {
- int i;
- int fail = -1;
- user_header* p = g_pheader_buf;
- //check header info
- if(p->identity !=ARK_IDENTITY || p->track_total == 0 || p->file_size <= sizeof(user_header)){
- printk(KERN_ERR "identity info error!\n");
- return fail;
- }
- if(p->track_rect.width > g_carback_context->screen_width || p->track_rect.width == 0){
- printk(KERN_ERR "track rect width error!\n");
- return fail;
- }
- if(p->track_rect.height > g_carback_context->screen_height || p->track_rect.height == 0){
- printk(KERN_ERR "track rect height error!\n");
- return fail;
- }
- for(i = 0;i < TRACK_MAX; i++){
- if(TRACK_MAX < p->track[i].image_store_id){
- printk(KERN_ERR "track[%d].image_store_id error!\n",i);
- return fail;
- }
- }
-
- for(i = 0;i < CAR_MAX; i++){
- if(CAR_MAX < p->car[i].image_store_id){
- printk(KERN_ERR "track[%d].image_store_id error!\n",i);
- return fail;
- }
- }
-
- for(i = 0;i < p->radar_total; i++){
- if(RADAR_MAX < p->radar[i].image_store_id){
- printk(KERN_ERR "track[%d].image_store_id error!\n",i);
- return fail;
- }
- }
-
- for(i = 0;i < TRACK_MAX; i++){
- if(TRACK_MAX < p->track2[i].image_store_id){
- printk(KERN_ERR "track2[%d].image_store_id error!\n",i);
- return fail;
- }
- }
- return 0;
- }
- static bool is_radar_image_id(unsigned int image_id){
- int i;
- for(i = 0;i < RADAR_MAX; i++){
- if(radar_idmap[i].image_id == image_id){
- return true;
- }
-
- }
-
- return false;
- }
- int set_disp_track_id(unsigned int track_id)
- {
- static unsigned int pre_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- if(p == NULL){
- printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
- return -1;
- }
-
- if(track_id >= TRACK_MAX && track_id < IMAGE_ID_NONE){
- printk(KERN_ERR "set disp track image id error!\n" );
- return -1;
- }
-
- if(pre_id != track_id || IMAGE_ID_NONE == track_id){
- p->disp_track_id = track_id;
- pre_id = track_id;
- }
- return 0;
- }
- int set_disp_car_id(unsigned int car_id)
- {
- static unsigned int pre_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- if(p == NULL){
- printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
- return -1;
- }
- if(car_id >= CAR_MAX && car_id < IMAGE_ID_NONE){
- printk(KERN_ERR "set disp car image id error!\n" );
- return -1;
- }
-
- if(pre_id != car_id || IMAGE_ID_NONE == car_id){
- p->disp_car_id = car_id;
- pre_id = car_id;
- }
-
- return 0;
- }
- int set_disp_radar_id(unsigned int radar_id)
- {
- static unsigned int pre_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- unsigned int image_id;
- unsigned char channel;
- unsigned int mask = 0xff000000;
- unsigned int disp_id = 0;
-
- if(p == NULL){
- printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
- return -1;
- }
- if(IMAGE_ID_NONE == radar_id){
- p->disp_radar_id = IMAGE_ID_NONE;
- pre_id = IMAGE_ID_NONE;
- return 0;
- }
-
- if(pre_id == radar_id){
- return 0;
- }
-
- for(channel = RADAR_CHANNEL_FL; channel <= RADAR_CHANNEL_RR;channel++){
-
- image_id = radar_id & (mask >> 8*channel);
- if(!is_radar_image_id(image_id)){
- printk(KERN_ERR "set disp radar id channel=%d ,error!\n",channel);
- continue;
- }
-
- disp_id |= image_id;
- }
- p->disp_radar_id = disp_id;
- pre_id = disp_id;
- //printk(KERN_ALERT "set disp radar id disp_id=0x%0x.\n",disp_id);
-
- return 0;
- }
- int set_disp_signal_id(unsigned int disp_signal_id)
- {
- static unsigned int pre_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- if(p == NULL){
- printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
- return -1;
- }
- if(disp_signal_id >= SIGNAL_MAX && disp_signal_id < IMAGE_ID_NONE){
- printk(KERN_ERR "set disp signal image id error!\n" );
- return -1;
- }
-
- if(pre_id != disp_signal_id || IMAGE_ID_NONE == disp_signal_id){
- p->disp_signal_id = disp_signal_id;
- pre_id = disp_signal_id;
- }
- //printk(KERN_ALERT "++++++p->disp_signal_id = %d\n" ,p->disp_signal_id);
- return 0;
- }
- int set_disp_append1_id(unsigned int disp_append1_id)
- {
- static unsigned int pre_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- if(p == NULL){
- printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
- return -1;
- }
- if(disp_append1_id >= APPEND1_MAX && disp_append1_id < IMAGE_ID_NONE){
- printk(KERN_ERR "set_disp_append1_id image id error!\n" );
- return -1;
- }
-
- if(pre_id != disp_append1_id || IMAGE_ID_NONE == disp_append1_id){
- p->disp_append1_id = disp_append1_id;
- pre_id = disp_append1_id;
- }
- //printk(KERN_ALERT "++++++p->disp_append1_id = %d\n" ,p->disp_append1_id);
- return 0;
- }
- int set_disp_append2_id(unsigned int disp_append2_id)
- {
- static unsigned int pre_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- if(p == NULL){
- printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
- return -1;
- }
- if(disp_append2_id >= APPEND2_MAX && disp_append2_id < IMAGE_ID_NONE){
- printk(KERN_ERR "set_disp_append2_id image id error!\n" );
- return -1;
- }
-
- if(pre_id != disp_append2_id || IMAGE_ID_NONE == disp_append2_id){
- p->disp_append2_id = disp_append2_id;
- pre_id = disp_append2_id;
- }
- //printk(KERN_ALERT "++++++p->disp_append2_id = %d\n" ,p->disp_append2_id);
- return 0;
- }
- int set_disp_track2_id(unsigned int track2_id)
- {
- static unsigned int pre_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
-
- if(p == NULL){
- printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
- return -1;
- }
-
- if(track2_id >= TRACK_MAX && track2_id < IMAGE_ID_NONE){
- printk(KERN_ERR "set disp track2 image id error!\n" );
- return -1;
- }
-
- if(pre_id != track2_id || IMAGE_ID_NONE == track2_id){
- p->disp_track2_id = track2_id;
- pre_id = track2_id;
- }
- return 0;
- }
- /*
- *set_disp_mradar_id: radar new solution
- *
- *-------------------------front-----------------------
- *
- * mradar0 mradar1 mradar2 mradar3
- * +-----------------+
- * | |
- * | |
- * mradar8 | | mradar12
- * | |
- * mradar9 | | mradar13
- * | |
- * mradar10| | mradar14
- * | |
- * mradar11| | mradar15
- * | |
- * | |
- * +-----------------+
- * mradar4 mradar5 mradar6 mradar7
- *
- *-------------------------rear-----------------------
- */
- int set_disp_mradar_id(unsigned char *pimage_id)
- {
- static unsigned char pre_mradar_id[MRADAR_MAX]={0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF};
- unsigned char mradar_id[MRADAR_MAX];
- track_context2 *p = g_ptrack_context2;
- int i;
- if(p == NULL){
- //printk(KERN_ALERT "%s: no header2 ,set mradar id invalid!\n", __FUNCTION__);
- return 0;
- }
- memcpy(mradar_id, pimage_id, MRADAR_MAX);
- for(i = 0; i < MRADAR_MAX; i++){
- ARKTRACK_DBGPRTK("mradar_id[%d]=%d\n", i, mradar_id[i]);
- if(mradar_id[i] > 0xF){
- printk(KERN_ALERT "%s: mradar_id[%d]=%d, MRADAR_MAX=0xF, error.\n", __FUNCTION__, i, mradar_id[i]);
- return -1;
- }
- }
-
- for(i = 0; i < MRADAR_MAX; i++){
- if(pre_mradar_id[i] != mradar_id[i]){
- break;
- }
- }
- if(i < MRADAR_MAX){
- memcpy(p->disp_mradar_id, mradar_id, MRADAR_MAX);
- memcpy(pre_mradar_id, mradar_id, MRADAR_MAX);
- p->disp_mradar_id_change = 1;
- }
- return 0;
- }
- static int init_track_context(unsigned int addr)
- {
- int ret = -1;
- int size;
- int i;
- unsigned char *p;
- //printk(KERN_ALERT "init_track_context ...\n");
- if(addr == 0){
- printk(KERN_ERR "addr error!\n");
- return ret;
- }
-
- g_pheader_buf = (user_header*)addr;
- show_header_info();
- if(check_header_info() < 0){
- printk(KERN_ERR "identity info error!\n");
- return ret;
- }
-
- p = vzalloc(sizeof(track_context));
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate track_context\n",__FUNCTION__, __LINE__);
- return -ENOMEM;
- }
- g_ptrack_context = (track_context *)p;
- g_ptrack_context->disp_track_size = 4 * g_pheader_buf->track_rect.width * g_pheader_buf->track_rect.height;
- if(g_pheader_buf->track_total > 0){
- size = 4* g_pheader_buf->track_rect.width * g_pheader_buf->track_rect.height;
- p = vzalloc(size);
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate track\n",__FUNCTION__, __LINE__);
- ret = -ENOMEM;
- goto err_track2;
- }
- g_ptrack_context->disp_track_buf = p;
- g_ptrack_context->disp_track_size= size;
- }
- if(g_pheader_buf->car_total > 0){
- size = 4* g_pheader_buf->car_rect.width * g_pheader_buf->car_rect.height;
- p = vzalloc(size);
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
- ret = -ENOMEM;
- goto err_car;
- }
- g_ptrack_context->disp_car_buf = p;
- g_ptrack_context->disp_car_size= size;
- }
- if(g_pheader_buf->signal_total> 0){
- size = 4* g_pheader_buf->signal_rect.width * g_pheader_buf->signal_rect.height;
- p = vzalloc(size);
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
- ret = -ENOMEM;
- goto err_car;
- }
- g_ptrack_context->disp_signal_buf = p;
- g_ptrack_context->disp_signal_size= size;
- }
- if(g_pheader_buf->append1_total> 0){
- size = 4* g_pheader_buf->append1_rect.width * g_pheader_buf->append1_rect.height;
- p = vzalloc(size);
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
- ret = -ENOMEM;
- goto err_car;
- }
- g_ptrack_context->disp_append1_buf = p;
- g_ptrack_context->disp_append1_size= size;
- }
- if(g_pheader_buf->append2_total> 0){
- size = 4* g_pheader_buf->append2_rect.width * g_pheader_buf->append2_rect.height;
- p = vzalloc(size);
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
- ret = -ENOMEM;
- goto err_car;
- }
- g_ptrack_context->disp_append2_buf = p;
- g_ptrack_context->disp_append2_size= size;
- }
- if(g_pheader_buf->radar_total > 0){
- size = 4* g_pheader_buf->radar_rect[0].width * g_pheader_buf->radar_rect[0].height;
- for(i = 0; i < 4;i++){
- p = vzalloc(size);
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate radar\n",__FUNCTION__, __LINE__);
- ret = -ENOMEM;
- while(i-- >= 0){
- vfree(g_ptrack_context->disp_radar_buf[i]);
- }
- goto err_radar;
- }
- g_ptrack_context->disp_radar_buf[i] = p;
- g_ptrack_context->disp_radar_size = size;
- }
- }
- if(g_pheader_buf->track2_total > 0){
- size = 4* g_pheader_buf->track2_rect.width * g_pheader_buf->track2_rect.height;
- p = vzalloc(size);
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate track2\n",__FUNCTION__, __LINE__);
- ret = -ENOMEM;
- goto err_track2;
- }
- g_ptrack_context->disp_track2_buf = p;
- g_ptrack_context->disp_track2_size= size;
- }
- g_ptrack_context->pheader_buf = g_pheader_buf;
- g_ptrack_context->disp_xpos = g_pheader_buf->track_rect.pos_x;
- g_ptrack_context->disp_ypos = g_pheader_buf->track_rect.pos_y;
- g_ptrack_context->disp_width = g_carback_context->screen_width;
- g_ptrack_context->disp_height = g_carback_context->screen_height;
- memcpy(&g_ptrack_context->track_param,&g_pheader_buf->track_rect,sizeof(track_param_context));
- g_ptrack_context->file_type = g_pheader_buf->file_type;
-
- g_ptrack_context->disp_track_id = IMAGE_ID_NONE;
- g_ptrack_context->disp_car_id = IMAGE_ID_NONE;
- g_ptrack_context->disp_radar_id = IMAGE_ID_NONE;
- g_ptrack_context->disp_track2_id= IMAGE_ID_NONE;
- return 0;
-
- err_track2:
- for(i = 0; i < 4;i++)
- if(g_ptrack_context->disp_radar_buf[i])
- vfree(g_ptrack_context->disp_radar_buf[i]);
- err_radar:
- if(g_ptrack_context->disp_car_buf)
- vfree(g_ptrack_context->disp_car_buf);
- err_car:
- if(g_ptrack_context)
- vfree(g_ptrack_context);
-
- return ret;
- }
- static void show_header2_info(void)
- {
- user2_header* p = g_pheader2_buf;
- rect_info *prect;
- item_info *pitem;
- int i;
- if(p == NULL) {
- printk(KERN_ERR "header_info_show error!\n");
- return;
- }
- ARKTRACK_DBGPRTK("header2_buf ===>identity=0x%0x,file_type=0x%0x file_size=0x%0x\n", p->identity,p->file_type,p->file_size);
- for(i = 0; i < MRADAR_MAX; i++){
- prect = &p->mradar_rect[i];
- pitem = &p->mradar[i][0];
- ARKTRACK_DBGPRTK("mradar_rect[%d]===>total=%d, pos_x=%d pos_y=%d width=%d height=%d\n",\
- i, p->mradar_total[i], prect->pos_x, prect->pos_y, prect->width, prect->height);
- ARKTRACK_DBGPRTK("mradar[%d][0] ===> image_type=%d image_store_id=%d image_id=0x%0x image_offset=0x%0x image_size=0x%0x\n",\
- i, pitem->image_type, pitem->image_store_id, pitem->image_id, pitem->image_offset, pitem->image_size);
- }
- }
- static int check_header2_info(void)
- {
- int i, j;
- user2_header* p = g_pheader2_buf;
- if(p == NULL) {
- printk(KERN_ERR "check_header2_info error!\n");
- return -1;
- }
- //check header info
- if(p->identity != ARK_IDENTITY || p->file_size <= sizeof(user2_header)){
- printk(KERN_ERR "header2 identity info error!\n");
- return -1;
- }
- for(j = 0 ;j < MRADAR_MAX; j++){
- for(i = 0;i < MRADAR_ITEM_MAX; i++){
- if(MRADAR_MAX < p->mradar[j][i].image_id){
- printk(KERN_ALERT "track[%d].image_id error!\n",i);
- return -1;
- }
- }
- }
-
- printk(KERN_ALERT "check_header2_info success!\n");
- return 0;
- }
- static int init_track_context2(unsigned int addr)
- {
- unsigned int header2_addr_start;
- unsigned char *p;
- int ret = -1;
- int size;
- int i;
- //printk(KERN_ALERT "file_type=%0x ---> HEADER2_FILE_FLAG=%0x.\n", g_pheader_buf->file_type, HEADER2_FILE_FLAG);
- if((g_pheader_buf->file_type & 0x80000000) != HEADER2_FILE_FLAG){
- printk(KERN_ALERT "only header file.\n");
- return 0;
- }
- printk(KERN_ALERT "%s: start.\n", __func__);
-
- if(addr == 0){
- printk(KERN_ERR "addr error!\n");
- return -1;
- }
-
- //g_pheader2_buf = (user2_header*)(addr + g_pheader_buf->file_size);
- p = vzalloc(sizeof(user2_header));
- if (p == NULL) {
- printk(KERN_ERR "%s: failed to user2_header.\n",__FUNCTION__);
- return -1;
- }
- header2_addr_start = addr + g_pheader_buf->file_size;
- printk(KERN_ALERT "header2_addr_start=0x%0x.\n", header2_addr_start);
- memcpy(p, (void *)header2_addr_start, sizeof(user2_header));
- g_pheader2_buf = (user2_header*)p;
-
- show_header2_info();
- if(check_header2_info() < 0){
- printk(KERN_ALERT "check_header2_info failed!\n");
- return -1;
- }
- p = vzalloc(sizeof(track_context2));
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate track_context2\n",__FUNCTION__, __LINE__);
- return -1;
- }
- memset(p, 0 ,sizeof(track_context2));
- g_ptrack_context2 = (track_context2 *)p;
- g_ptrack_context2->pheader2_buf = g_pheader2_buf;
- g_ptrack_context2->file_type = g_pheader2_buf->file_type;
- memset(g_ptrack_context2->disp_mradar_id, 0x0F ,MRADAR_MAX);
-
- for(i = 0; i < MRADAR_MAX; i++){
- size = 4* g_pheader2_buf->mradar_rect[i].width * g_pheader2_buf->mradar_rect[i].height;
- p = vzalloc(size);
- if (p == NULL) {
- printk(KERN_ERR "%s %d: failed to allocate radar\n",__FUNCTION__, __LINE__);
- ret = -ENOMEM;
- while(i-- >= 0){
- vfree(g_ptrack_context2->disp_mradar_buf[i]);
- }
- vfree(g_pheader2_buf);
- return -1;
- }
- g_ptrack_context2->disp_mradar_buf[i] = p;
- g_ptrack_context2->disp_mradar_size[i]= size;
- memcpy(&g_ptrack_context2->mradar_param.mradar_rect[i], &g_pheader2_buf->mradar_rect[i], sizeof(rect_info));
- ARKTRACK_DBGPRTK("mradar_buf[%d]=0x%0x, size=0x%0x \n",i, p, size);
- }
-
- printk(KERN_ALERT "%s: success.\n", __func__);
- return 0;
- }
- static int get_radar_channel(unsigned int image_id){
- int i;
- int channel = -1;
- for(i = 0;i < RADAR_MAX; i++){
- if(radar_idmap[i].image_id == image_id){
- channel = radar_idmap[i].dis_channel;
- break;
- }
-
- }
-
- return channel;
- }
- static unsigned int get_picture_addr(enum image_type type, unsigned int id)
- {
- unsigned int offset;
- int i;
-
- if(type == IMAGE_TYPE_TRACK){
- offset = g_pheader_buf->track[id].image_offset;
- }
- else if(type == IMAGE_TYPE_CAR){
- offset = g_pheader_buf->car[id].image_offset;
- }
- else if(type == IMAGE_TYPE_SIGNAL){
- offset = g_pheader_buf->signal[id].image_offset;
- }
- else if(type == IMAGE_TYPE_APPEND1){
- offset = g_pheader_buf->append1[id].image_offset;
- }
- else if(type == IMAGE_TYPE_APPEND2){
- offset = g_pheader_buf->append2[id].image_offset;
- }
- else if(type == IMAGE_TYPE_RADAR){
- for(i = 0; i < RADAR_MAX;i++){
- if(g_pheader_buf->radar[i].image_id == id){
- offset = g_pheader_buf->radar[i].image_offset;
- break;
- }
- }
- }
- else if(type == IMAGE_TYPE_TRACK2){
- offset = g_pheader_buf->track2[id].image_offset;
- }
- return g_carback_context->track_data_virtaddr +offset;
- }
- static unsigned int get_picture_offset(enum image_type type, unsigned int id)
- {
- unsigned int offset = 0;
- int i;
-
- if(type == IMAGE_TYPE_TRACK){
- offset = g_pheader_buf->track[id].image_offset;
- }
- else if(type == IMAGE_TYPE_CAR){
- offset = g_pheader_buf->car[id].image_offset;
- }
- else if(type == IMAGE_TYPE_SIGNAL){
- offset = g_pheader_buf->signal[id].image_offset;
- }
- else if(type == IMAGE_TYPE_APPEND1){
- offset = g_pheader_buf->append1[id].image_offset;
- }
- else if(type == IMAGE_TYPE_APPEND2){
- offset = g_pheader_buf->append2[id].image_offset;
- }
- else if(type == IMAGE_TYPE_RADAR){
- for(i = 0; i < RADAR_MAX;i++){
- if(g_pheader_buf->radar[i].image_id == id){
- offset = g_pheader_buf->radar[i].image_offset;
- break;
- }
- }
- }
- else if(type == IMAGE_TYPE_TRACK2){
- offset = g_pheader_buf->track2[id].image_offset;
- }
- return offset;
- }
- static unsigned int get_picture_size(enum image_type type, unsigned int id)
- {
- unsigned int image_size = 0;
- int i;
-
- if(type == IMAGE_TYPE_TRACK){
- image_size = g_pheader_buf->track[id].image_size;
- }
- else if(type == IMAGE_TYPE_CAR){
- image_size = g_pheader_buf->car[id].image_size;
- }
- else if(type == IMAGE_TYPE_SIGNAL){
- image_size = g_pheader_buf->signal[id].image_size;
- }
- else if(type == IMAGE_TYPE_APPEND1){
- image_size = g_pheader_buf->append1[id].image_size;
- }
- else if(type == IMAGE_TYPE_APPEND2){
- image_size = g_pheader_buf->append2[id].image_size;
- }
- else if(type == IMAGE_TYPE_RADAR){
- for(i = 0; i < RADAR_MAX;i++){
- if(g_pheader_buf->radar[i].image_id == id){
- image_size = g_pheader_buf->radar[i].image_size;
- break;
- }
- }
- }
- else if(type == IMAGE_TYPE_TRACK2){
- image_size = g_pheader_buf->track2[id].image_size;
- }
- return image_size;
- }
- static unsigned int get_picture_num(enum image_type type)
- {
- unsigned int picture_num = 0;
- if(type == IMAGE_TYPE_TRACK){
- picture_num = g_pheader_buf->track_total;
- }
- else if(type == IMAGE_TYPE_CAR){
- picture_num = g_pheader_buf->car_total;
- }
- else if(type == IMAGE_TYPE_RADAR){
- picture_num = g_pheader_buf->radar_total;
- }
- else if(type == IMAGE_TYPE_TRACK2){
- picture_num = g_pheader_buf->track2_total;
- }
- //printk("get image_type = %d, num = %d !",type,picture_num);
- return picture_num;
- }
- /* Returns length of decompressed data. */
- static int zlib_uncompress_block(void *dst, int dstlen, void *src, int srclen)
- {
- int err;
- stream.next_in = src;
- stream.avail_in = srclen;
- stream.next_out = dst;
- stream.avail_out = dstlen;
- err = zlib_inflateReset(&stream);
- if (err != Z_OK) {
- printk("zlib_inflateReset error %d\n", err);
- zlib_inflateEnd(&stream);
- zlib_inflateInit(&stream);
- }
- err = zlib_inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END)
- goto err;
- return stream.total_out;
- err:
- printk(KERN_ERR "Error %d while decompressing!\n", err);
- printk(KERN_ERR "%p(%d)->%p(%d)\n", src, srclen, dst, dstlen);
- return -EIO;
- }
- static int zlib_uncompress_init(void)
- {
- if (!initialized++) {
- stream.workspace = vmalloc(zlib_inflate_workspacesize());
- if ( !stream.workspace ) {
- initialized = 0;
- return -ENOMEM;
- }
- stream.next_in = NULL;
- stream.avail_in = 0;
- zlib_inflateInit(&stream);
- }
- return 0;
- }
- static void zlib_uncompress_exit(void)
- {
- if (!--initialized) {
- zlib_inflateEnd(&stream);
- vfree(stream.workspace);
- }
- }
- static void copy_line_data(unsigned int *dest,unsigned int *src,unsigned int width,enum cover_type cover)
- {
- unsigned int i;
- unsigned int* psrc = (unsigned int*)src;
- unsigned int* pdest = (unsigned int*)dest;
-
- if(cover == SRC_COVER_DST){
- memcpy(pdest,psrc,width*PIXEL_DATA_SIZE);
- }else if(cover == DST_COVER_SRC2){
- for(i = 0;i < width;i++){
- if(*pdest == PIXEL_DATA_NONE || *pdest == PIXEL_DATA_ZERO)
- *pdest = *psrc;
-
- psrc++;
- pdest++;
- }
- }
- else if(cover == SRC_COVER_DST2){
- for(i = 0;i < width;i++){
- if(*psrc == 0xFFFFFFFF || *psrc == PIXEL_DATA_NONE || *psrc == PIXEL_DATA_ZERO){
- psrc++;
- pdest++;
- continue;
- }
- *pdest = *psrc;
- psrc++;
- pdest++;
- }
- }
- }
- static int copy_pic_data(void *dest,void *src,enum image_type type,unsigned int id,enum cover_type cover)
- {
- unsigned int width;
- unsigned int height;
- unsigned int pos_x;
- unsigned int pos_y;
- track_param_context* p = &g_ptrack_context->track_param;
- unsigned int* dest_tmp;
- unsigned int* src_tmp;
- int radar_channel;
- int i;
-
- if(dest == NULL || src == NULL){
- printk(KERN_ERR "paint car dest src error!\n");
- return -1;
- }
- if(type == IMAGE_TYPE_TRACK){
- width = p->track_rect.width;
- height= p->track_rect.height;
- pos_x = p->track_rect.pos_x;
- pos_y = p->track_rect.pos_y;
- }
- else if(type == IMAGE_TYPE_CAR){
-
- width = p->car_rect.width;
- height= p->car_rect.height;
- pos_x = p->car_rect.pos_x;
- pos_y = p->car_rect.pos_y;
- }
- else if(type == IMAGE_TYPE_RADAR){
-
- radar_channel = get_radar_channel(id);
- if(radar_channel < 0){
- printk(KERN_ERR "get radar_channel error!\n");
- return -1;
- }
- width = p->radar_rect[radar_channel].width;
- height= p->radar_rect[radar_channel].height;
- pos_x = p->radar_rect[radar_channel].pos_x;
- pos_y = p->radar_rect[radar_channel].pos_y;
- }
- else if(type == IMAGE_TYPE_SIGNAL){
- width = p->signal_rect.width;
- height= p->signal_rect.height;
- pos_x = p->signal_rect.pos_x;
- pos_y = p->signal_rect.pos_y;
- }
- else if(type == IMAGE_TYPE_APPEND1){
- width = p->append1_rect.width;
- height= p->append1_rect.height;
- pos_x = p->append1_rect.pos_x;
- pos_y = p->append1_rect.pos_y;
- }
- else if(type == IMAGE_TYPE_APPEND2){
- width = p->append2_rect.width;
- height= p->append2_rect.height;
- pos_x = p->append2_rect.pos_x;
- pos_y = p->append2_rect.pos_y;
- }
- else if(type == IMAGE_TYPE_TRACK2){
-
- width = p->track2_rect.width;
- height= p->track2_rect.height;
- pos_x = p->track2_rect.pos_x;
- pos_y = p->track2_rect.pos_y;
- }
- else if(type == IMAGE_TYPE_MRADAR){
- mradar_param_context* p2 = &g_ptrack_context2->mradar_param;
- width = p2->mradar_rect[id].width;
- height= p2->mradar_rect[id].height;
- pos_x = p2->mradar_rect[id].pos_x;
- pos_y = p2->mradar_rect[id].pos_y;
- }
- else{
- printk(KERN_ERR "paint car type error!\n");
- return -1;
- }
-
- for(i = 0; i < height;i++){
- dest_tmp = dest + g_ptrack_context->disp_width * (pos_y + i) * PIXEL_DATA_SIZE + pos_x * PIXEL_DATA_SIZE;
- src_tmp = src + i * width * PIXEL_DATA_SIZE;
- copy_line_data(dest_tmp,src_tmp,width,cover);
- }
-
- return 0;
- }
- static unsigned int subjoin_car_pic(void *dest)
- {
- static unsigned int last_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- void *dest_car = p->disp_car_buf;
- unsigned int dest_size = p->disp_car_size;
- unsigned int fill_size = 0;
- unsigned int source_size;
- unsigned int source_offset;
- void *source;
-
- if(p->disp_car_id > CAR_MAX)
- return 0;
-
- if(first_draw_track)
- last_id = IMAGE_ID_NONE;
-
- source_offset = get_picture_offset(IMAGE_TYPE_CAR,p->disp_car_id);
- source_size = get_picture_size(IMAGE_TYPE_CAR,p->disp_car_id);
- //printk(KERN_ALERT "source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
- if(source_size == 0 || source_offset < sizeof(user_header)){
- printk(KERN_ERR "subjoin car pic source error, disp_car_id=0x%0x.\n",p->disp_car_id);
- return 0;
- }
- if(last_id == IMAGE_ID_NONE || last_id != p->disp_car_id){
- source = (void*)get_picture_addr(IMAGE_TYPE_CAR,p->disp_car_id);
- fill_size = zlib_uncompress_block(dest_car, dest_size, source, source_size);
- if(fill_size != dest_size){
- printk(KERN_ERR " zlib uncompress car error!\n");
- return fill_size;
- }
- }
-
- copy_pic_data(dest,dest_car,IMAGE_TYPE_CAR,p->disp_car_id,SRC_COVER_DST);
- last_id = p->disp_car_id;
- return fill_size;
- }
- static unsigned int subjoin_signal_pic(void *dest)
- {
- static unsigned int last_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- void *dest_signal = p->disp_signal_buf;
- unsigned int dest_size = p->disp_signal_size;
- unsigned int fill_size = 0;
- unsigned int source_size;
- unsigned int source_offset;
- void *source;
-
- if(p->disp_signal_id > SIGNAL_MAX)
- return 0;
-
- if(first_draw_track)
- last_id = IMAGE_ID_NONE;
-
- source_offset = get_picture_offset(IMAGE_TYPE_SIGNAL,p->disp_signal_id);
- source_size = get_picture_size(IMAGE_TYPE_SIGNAL,p->disp_signal_id);
- //printk(KERN_ALERT "~~~~~~source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
- if(source_size == 0 || source_offset < sizeof(user_header)){
- printk(KERN_ERR "subjoin signal pic source error, disp_signal_id=0x%0x.\n",p->disp_signal_id);
- return 0;
- }
- if(last_id == IMAGE_ID_NONE || last_id != p->disp_signal_id){
- source = (void*)get_picture_addr(IMAGE_TYPE_SIGNAL,p->disp_signal_id);
- fill_size = zlib_uncompress_block(dest_signal, dest_size, source, source_size);
- if(fill_size != dest_size){
- printk(KERN_ERR " zlib uncompress signal error!\n");
- return fill_size;
- }
- }
-
- copy_pic_data(dest,dest_signal,IMAGE_TYPE_SIGNAL,p->disp_signal_id,SRC_COVER_DST);
- last_id = p->disp_signal_id;
- return fill_size;
- }
- static unsigned int subjoin_append1_pic(void *dest)
- {
- static unsigned int last_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- void *dest_append1 = p->disp_append1_buf;
- unsigned int dest_size = p->disp_append1_size;
- unsigned int fill_size = 0;
- unsigned int source_size;
- unsigned int source_offset;
- void *source;
-
- if(p->disp_append1_id > APPEND1_MAX)
- return 0;
-
- if(first_draw_track)
- last_id = IMAGE_ID_NONE;
-
- source_offset = get_picture_offset(IMAGE_TYPE_APPEND1,p->disp_append1_id);
- source_size = get_picture_size(IMAGE_TYPE_APPEND1,p->disp_append1_id);
-
- //printk(KERN_ALERT "++++++ subjoin_append1_pic source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
-
- if(source_size == 0 || source_offset < sizeof(user_header)){
- printk(KERN_ERR "subjoin append1 pic source error, disp_append1_id=0x%0x.\n",p->disp_append1_id);
- return 0;
- }
- if(last_id == IMAGE_ID_NONE || last_id != p->disp_append1_id){
- source = (void*)get_picture_addr(IMAGE_TYPE_APPEND1,p->disp_append1_id);
- fill_size = zlib_uncompress_block(dest_append1, dest_size, source, source_size);
- if(fill_size != dest_size){
- printk(KERN_ERR " zlib uncompress append1 error!\n");
- return fill_size;
- }
- }
-
- copy_pic_data(dest,dest_append1,IMAGE_TYPE_APPEND1,p->disp_append1_id,SRC_COVER_DST);
- last_id = p->disp_append1_id;
- return fill_size;
- }
- static unsigned int subjoin_append2_pic(void *dest)
- {
- static unsigned int last_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- void *dest_append2 = p->disp_append2_buf;
- unsigned int dest_size = p->disp_append2_size;
- unsigned int fill_size = 0;
- unsigned int source_size;
- unsigned int source_offset;
- void *source;
-
- if(p->disp_append2_id > APPEND2_MAX)
- return 0;
-
- if(first_draw_track)
- last_id = IMAGE_ID_NONE;
-
- source_offset = get_picture_offset(IMAGE_TYPE_APPEND2,p->disp_append2_id);
- source_size = get_picture_size(IMAGE_TYPE_APPEND2,p->disp_append2_id);
-
- //printk(KERN_ALERT "++++++ subjoin_append2_pic source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
-
- if(source_size == 0 || source_offset < sizeof(user_header)){
- printk(KERN_ERR "subjoin append2 pic source error, disp_append2_id=0x%0x.\n",p->disp_append2_id);
- return 0;
- }
- if(last_id == IMAGE_ID_NONE || last_id != p->disp_append2_id){
- source = (void*)get_picture_addr(IMAGE_TYPE_APPEND2,p->disp_append2_id);
- fill_size = zlib_uncompress_block(dest_append2, dest_size, source, source_size);
- if(fill_size != dest_size){
- printk(KERN_ERR " zlib uncompress append2 error!\n");
- return fill_size;
- }
- }
-
- copy_pic_data(dest,dest_append2,IMAGE_TYPE_APPEND2,p->disp_append2_id,SRC_COVER_DST);
- last_id = p->disp_append2_id;
- return fill_size;
- }
- static unsigned int subjoin_track_pic(void *dest)
- {
- static unsigned int last_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- void *dest_track = p->disp_track_buf;
- unsigned int dest_size = p->disp_track_size;
- unsigned int fill_size = 0;
- unsigned int source_size;
- unsigned int source_offset;
- void *source;
-
- if(p->disp_track_id > TRACK_MAX)
- return 0;
-
- if(first_draw_track)
- last_id = IMAGE_ID_NONE;
-
- source_offset = get_picture_offset(IMAGE_TYPE_TRACK,p->disp_track_id);
- source_size = get_picture_size(IMAGE_TYPE_TRACK,p->disp_track_id);
- if(source_size == 0 || source_offset < sizeof(user_header)){
- printk(KERN_ERR "subjoin track pic source error, disp_track_id=0x%0x.\n",p->disp_track_id);
- return 0;
- }
-
- if(last_id == IMAGE_ID_NONE || last_id != p->disp_track_id){
- source = (void*)get_picture_addr(IMAGE_TYPE_TRACK,p->disp_track_id);
- fill_size = zlib_uncompress_block(dest_track, dest_size, source, source_size);
- if(fill_size != dest_size){
- printk(KERN_ERR " zlib uncompress track error!\n");
- return fill_size;
- }
- }
-
- copy_pic_data(dest,dest_track,IMAGE_TYPE_TRACK,p->disp_track_id,SRC_COVER_DST);
- last_id = p->disp_track_id;
- //printk(KERN_ALERT "p->disp_track_id = %d",p->disp_track_id);
- return fill_size;
- }
- static unsigned int subjoin_radar_pic(void *dest)
- {
- static unsigned int last_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- void *dest_radar = p->disp_radar_buf[0];
- unsigned int dest_size = p->disp_radar_size;
- unsigned int mask = 0xff000000;
- unsigned int image_id;
- unsigned char channel;
- unsigned int fill_size = 0;
- unsigned int source_size;
- unsigned int source_offset;
- void *source;
- if(p->disp_radar_id == IMAGE_ID_NONE)
- return 0;
-
- if(first_draw_track)
- last_id = IMAGE_ID_NONE;
-
- for(channel = RADAR_CHANNEL_FL; channel <= RADAR_CHANNEL_RR;channel++){
- image_id = p->disp_radar_id & (mask >> 8*channel);
- if(!is_radar_image_id(image_id)){
- printk(KERN_ERR " subjoin radar id channel=%d image_id=0x%0x, error!\n",channel,image_id);
- continue;
- }
- dest_radar = p->disp_radar_buf[channel];
- source_size = get_picture_size(IMAGE_TYPE_RADAR,image_id);
- source_offset = get_picture_offset(IMAGE_TYPE_RADAR,image_id);
- //printk(KERN_ALERT "channel=%d image_id=0x%0x ---> source_offset=%0x ,source_size=%0x \n",channel,image_id,source_offset,source_size );
- if(source_size == 0 || source_offset < sizeof(user_header)){
- printk(KERN_ERR "subjoin radar pic source error,channel=%d image_id=0x%0x.\n",channel,image_id);
- continue;
- }
-
- if(last_id == IMAGE_ID_NONE || last_id != p->disp_radar_id){
- source = (void*)get_picture_addr(IMAGE_TYPE_RADAR,image_id);
- fill_size = zlib_uncompress_block(dest_radar, dest_size, source, source_size);
- if(fill_size != dest_size){
- printk(KERN_ERR " zlib uncompress radar error!\n");
- return fill_size;
- }
- }
-
- if(vbox_track_paint){
- copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,SRC_COVER_DST2);//wheel paint
- }else{
- if(channel == RADAR_CHANNEL_RR){
- copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,SRC_COVER_DST);
- //copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,DST_COVER_SRC2);
- }
- else{
- copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,SRC_COVER_DST);
- }
- }
-
- }
-
- last_id = p->disp_radar_id;
- return fill_size;
- }
- static unsigned int subjoin_track2_pic(void *dest)
- {
- static unsigned int last_id = IMAGE_ID_NONE;
- track_context *p = g_ptrack_context;
- void *dest_track2 = p->disp_track2_buf;
- unsigned int dest_size = p->disp_track2_size;
- unsigned int fill_size = 0;
- unsigned int source_size;
- unsigned int source_offset;
- void *source;
-
- if(p->disp_track2_id > TRACK_MAX)
- return 0;
-
- if(first_draw_track)
- last_id = IMAGE_ID_NONE;
-
- source_offset = get_picture_offset(IMAGE_TYPE_TRACK2,p->disp_track2_id);
- source_size = get_picture_size(IMAGE_TYPE_TRACK2,p->disp_track2_id);
- if(source_size == 0 || source_offset < sizeof(user_header)){
- printk(KERN_ERR "subjoin track2 pic source error, disp_track2_id=0x%0x.\n",p->disp_track2_id);
- return 0;
- }
-
- if(last_id == IMAGE_ID_NONE || last_id != p->disp_radar_id){
- source = (void*)get_picture_addr(IMAGE_TYPE_TRACK2,p->disp_track2_id);
- fill_size = zlib_uncompress_block(dest_track2, dest_size, source, source_size);
- if(fill_size != dest_size){
- printk(KERN_ERR " zlib uncompress track2 error!\n");
- return fill_size;
- }
- }
-
- copy_pic_data(dest,dest_track2,IMAGE_TYPE_TRACK2,p->disp_track2_id,SRC_COVER_DST);
- last_id = p->disp_track2_id;
-
- return fill_size;
- }
- static unsigned int subjoin_mradar_pic(void *dest)
- {
- static unsigned char last_mradar_id[MRADAR_MAX]={0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF};
- track_context2 *p = g_ptrack_context2;
- void *dest_buf;
- unsigned int dest_size;
- unsigned int fill_size = 0;
- unsigned int source_size;
- unsigned int source_offset;
- void *source;
- int i,item_id;
-
- if(p == NULL)
- return -1;
-
- if(first_draw_track) {
- for(i = 0; i < MRADAR_MAX; i++){
- last_mradar_id[i] = 0x0F;
- }
- }
- for(i = 0; i < MRADAR_MAX; i++){
-
- if(p->disp_mradar_id[i] == 0x0F)
- continue;
-
- item_id = p->disp_mradar_id[i];
- dest_buf = p->disp_mradar_buf[i];
- dest_size = p->disp_mradar_size[i];
- source_offset = g_pheader2_buf->mradar[i][item_id].image_offset + g_pheader_buf->file_size;
- source_size = g_pheader2_buf->mradar[i][item_id].image_size;
- //printk(KERN_ALERT "mradar[%d][%d]: source_offset=0x%0x ,source_size=0x%0x \n",i,item_id,source_offset,source_size);
- if(source_size == 0 || source_offset < sizeof(user2_header)){
- //printk(KERN_ERR "subjoin mradar pic source error, mradar[%d][%d].\n",i, item_id);
- continue;
- }
-
- if(last_mradar_id[i] == 0x0F || last_mradar_id[i] != p->disp_mradar_id[i]){
- source =(void*)(g_carback_context->track_data_virtaddr+source_offset);
- fill_size = zlib_uncompress_block(dest_buf, dest_size, source, source_size);
- if(fill_size != dest_size){
- printk(KERN_ERR " zlib uncompress mradar error, fill_size=%0x, dest_size=%0x.\n", fill_size, dest_size);
- return fill_size;
- }
- }
-
- copy_pic_data(dest, dest_buf, IMAGE_TYPE_MRADAR, i, SRC_COVER_DST2);
-
- }
-
- for(i = 0; i < MRADAR_MAX; i++)
- last_mradar_id[i] = p->disp_mradar_id[i];
-
- p->disp_mradar_id_change = 0;
-
- return fill_size;
- }
- int track_paint_init(void)
- {
- int ret = 0;
- if(zlib_uncompress_init()){
- printk(KERN_ERR "zlib uncompress init failed!\n" );
- return -1;
- }
-
- if (*(volatile unsigned int*)g_carback_context->track_data_virtaddr != MKTAG('R', 'S', 'T', 'K')) {
- printk(KERN_ALERT "reservingtrack check failed!\n" );
- return -1;
- }
-
- if(init_track_context(g_carback_context->track_data_virtaddr) < 0){
- printk(KERN_ERR "init track context failed.\n" );
- return -1;
- }
- if(init_track_context2(g_carback_context->track_data_virtaddr) < 0){
- printk(KERN_ERR "init track context2 failed.\n" );
- g_ptrack_context2 = NULL;
- return -1;
- }
- if(g_carback_context && g_carback_context->screen_width >= g_ptrack_context->disp_width && g_carback_context->screen_height>= g_ptrack_context->disp_height){
- g_carback_context->track_disp_width = g_ptrack_context->disp_width;
- g_carback_context->track_disp_height= g_ptrack_context->disp_height;
- g_carback_context->track_disp_xpos = g_ptrack_context->disp_xpos;
- g_carback_context->track_disp_ypos = g_ptrack_context->disp_ypos;
- g_carback_context->ptrack_param = &g_ptrack_context->track_param;
- g_carback_context->file_type = g_ptrack_context->file_type;
- g_carback_context->pmradar_param = NULL;
- if(g_ptrack_context2)
- g_carback_context->pmradar_param = &g_ptrack_context2->mradar_param;
-
- printk(KERN_ALERT "++++++track_switch_id = %d",track_switch_id);
- if(track_switch_id == 0){
- set_disp_track_id(TRACK_STRAIGHT_FORWARD_ID);
- set_disp_car_id(CAR_NORMAL_STATUS_ID);
- set_disp_radar_id(RADAR_NORMAL_STATUS_ID);
- set_disp_track2_id(IMAGE_ID_NONE);
- set_disp_signal_id(IMAGE_ID_NONE);
- set_disp_append1_id(APPEND1_NORMAL_STATUS_ID);
- set_disp_append2_id(APPEND2_NORMAL_STATUS_ID);
- }else if(track_switch_id == 1){
- set_disp_track_id(IMAGE_ID_NONE);
- set_disp_car_id(CAR_NORMAL_STATUS_ID);
- set_disp_radar_id(RADAR_NORMAL_STATUS_ID);
- set_disp_track2_id(TRACK2_STRAIGHT_FORWARD_ID);
- set_disp_signal_id(IMAGE_ID_NONE);
- set_disp_append1_id(APPEND1_NORMAL_STATUS_ID);
- set_disp_append2_id(APPEND2_NORMAL_STATUS_ID);
- }else{
- set_disp_track_id(TRACK_STRAIGHT_FORWARD_ID);
- set_disp_car_id(CAR_NORMAL_STATUS_ID);
- set_disp_radar_id(RADAR_NORMAL_STATUS_ID);
- set_disp_track2_id(IMAGE_ID_NONE);
- set_disp_signal_id(IMAGE_ID_NONE);
- set_disp_append1_id(APPEND1_NORMAL_STATUS_ID);
- set_disp_append2_id(APPEND2_NORMAL_STATUS_ID);
- }
-
- printk("track_paint init width=%d, height=%d,xpos=%d,ypos=%d.\n",g_carback_context->track_disp_width,\
- g_carback_context->track_disp_height,g_carback_context->track_disp_xpos,g_carback_context->track_disp_ypos);
- }
- else{
- printk(KERN_ALERT "track paint init out width or height fail!\n" );
- ret = -1;
- }
-
- if(vbox_track_paint){
- return ret;
- }
- return ret;
- }
- void track_paint_deinit(void)
- {
- int i;
-
- zlib_uncompress_exit();
-
- if(g_ptrack_context->disp_track2_buf)
- vfree(g_ptrack_context->disp_track2_buf);
- for(i = 0; i < 4;i++)
- if(g_ptrack_context->disp_radar_buf[i])
- vfree(g_ptrack_context->disp_radar_buf[i]);
-
- if(g_ptrack_context->disp_car_buf)
- vfree(g_ptrack_context->disp_car_buf);
-
- if(g_ptrack_context)
- vfree(g_ptrack_context);
- }
- unsigned int track_paint_fill(void *dest, unsigned int width, unsigned int height)
- {
- unsigned int fill_size, source_size, dest_size, source_offset;
- static unsigned int last_track_id = 0;
- static unsigned int last_car_id = 0;
- static unsigned int last_radar_id = 0;
- static unsigned int last_signal_id = -1;
- static unsigned int last_append1_id = -1;
- static unsigned int last_append2_id = -1;
- static unsigned int last_track2_id= 0;
- track_context *p = g_ptrack_context;
- user_header* ph = g_pheader_buf;
- void *source;
-
- if(p == NULL || g_carback_context == NULL){
- printk(KERN_ERR "track_paint_fill g_ptrack_context or carback_context null\n" );
- return 0;
- }
- if( width > p->disp_width || height > p->disp_height){
- printk(KERN_ERR "track paint fill width height error!\n" );
- return 0;
- }
-
- if(p->disp_track_id > TRACK_MAX && p->disp_track_id < IMAGE_ID_NONE)
- return 0;
- if(!g_carback_context->track_setting){
- memset(dest,0,g_carback_context->track_display_size);
- last_track_id = 0;
- last_car_id = 0;
- last_radar_id = 0;
- last_signal_id = -1;
- last_append1_id = -1;
- last_append2_id = -1;
- last_track2_id= 0;
- return g_carback_context->track_display_size;
- }
- if (p->disp_track_id == IMAGE_ID_NONE && p->disp_track2_id == IMAGE_ID_NONE){
- memset(dest,0,p->disp_track_size);
- return p->disp_track_size;
- }
-
- if( g_carback_context->carback_signal ){
- if(last_track_id == p->disp_track_id && last_car_id == p->disp_car_id &&
- last_radar_id == p->disp_radar_id &&last_track2_id == p->disp_track2_id && last_signal_id == p->disp_signal_id
- && last_append1_id == p->disp_append1_id && last_append2_id == p->disp_append2_id){
- if(g_ptrack_context2 == NULL || !g_ptrack_context2->disp_mradar_id_change)
- return 0;
- }
- }
- if( !g_carback_context->carback_signal ){
- if(last_signal_id != p->disp_signal_id)
- memset(dest,0,g_carback_context->track_display_size);
- if(ph->signal_total)
- subjoin_signal_pic(dest);
- if(ph->append2_total)
- subjoin_append2_pic(dest);
- }else{
- if(!g_carback_context->track_append_setting){
- memset(dest,0,g_carback_context->track_display_size);
- g_carback_context->track_append_setting = 1;
- }
- if(ph->track_total )
- subjoin_track_pic(dest);
-
- if(ph->car_total)
- subjoin_car_pic(dest);
- if(ph->radar_total)
- subjoin_radar_pic(dest);
- if(ph->append1_total)
- subjoin_append1_pic(dest);
- if(ph->append2_total)
- subjoin_append2_pic(dest);
-
- if(ph->track2_total)
- subjoin_track2_pic(dest);
-
- if(g_ptrack_context2 && vbox_track_paint) {
- subjoin_mradar_pic(dest);
- }
- }
- last_track_id = p->disp_track_id;
- last_car_id = p->disp_car_id;
- last_radar_id = p->disp_radar_id;
- last_signal_id = p->disp_signal_id;
- last_append1_id = p->disp_append1_id;
- last_append2_id = p->disp_append2_id;
- last_track2_id= p->disp_track2_id;
-
- return fill_size;
- }
|