ark_track.c 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804
  1. #include <linux/kernel.h>
  2. #include <linux/proc_fs.h>
  3. #include <linux/platform_device.h>
  4. #include <asm/setup.h>
  5. #include <linux/zlib.h>
  6. #include <linux/cdev.h>
  7. #include "ark_track.h"
  8. #include "ark1668e_carback.h"
  9. #include "ark_mcu.h"
  10. #include <asm/cacheflush.h>
  11. #include <linux/dma-mapping.h>
  12. #include <linux/vmalloc.h>
  13. const idmap_info radar_idmap[RADAR_MAX] =
  14. {
  15. //FL
  16. { "FL_00",FL_00,0},
  17. { "FL_01",FL_01,0},
  18. { "FL_02",FL_02,0},
  19. { "FL_03",FL_03,0},
  20. { "FL_04",FL_04,0},
  21. { "FL_05",FL_05,0},
  22. { "FL_06",FL_06,0},
  23. { "FL_10",FL_10,0},
  24. { "FL_11",FL_11,0},
  25. { "FL_12",FL_12,0},
  26. { "FL_13",FL_13,0},
  27. { "FL_14",FL_14,0},
  28. { "FL_15",FL_15,0},
  29. { "FL_16",FL_16,0},
  30. { "FL_20",FL_20,0},
  31. { "FL_21",FL_21,0},
  32. { "FL_22",FL_22,0},
  33. { "FL_23",FL_23,0},
  34. { "FL_24",FL_24,0},
  35. { "FL_25",FL_25,0},
  36. { "FL_26",FL_26,0},
  37. { "FL_30",FL_30,0},
  38. { "FL_31",FL_31,0},
  39. { "FL_32",FL_32,0},
  40. { "FL_33",FL_33,0},
  41. { "FL_34",FL_34,0},
  42. { "FL_35",FL_35,0},
  43. { "FL_36",FL_36,0},
  44. { "FL_40",FL_40,0},
  45. { "FL_41",FL_41,0},
  46. { "FL_42",FL_42,0},
  47. { "FL_43",FL_43,0},
  48. { "FL_44",FL_44,0},
  49. { "FL_45",FL_45,0},
  50. { "FL_46",FL_46,0},
  51. { "FL_50",FL_50,0},
  52. { "FL_51",FL_51,0},
  53. { "FL_52",FL_52,0},
  54. { "FL_53",FL_53,0},
  55. { "FL_54",FL_54,0},
  56. { "FL_55",FL_55,0},
  57. { "FL_56",FL_56,0},
  58. { "FL_60",FL_60,0},
  59. { "FL_61",FL_61,0},
  60. { "FL_62",FL_62,0},
  61. { "FL_63",FL_63,0},
  62. { "FL_64",FL_64,0},
  63. { "FL_65",FL_65,0},
  64. { "FL_66",FL_66,0},
  65. //FR
  66. { "FR_00",FR_00,1},
  67. { "FR_01",FR_01,1},
  68. { "FR_02",FR_02,1},
  69. { "FR_03",FR_03,1},
  70. { "FR_04",FR_04,1},
  71. { "FR_05",FR_05,1},
  72. { "FR_06",FR_06,1},
  73. { "FR_10",FR_10,1},
  74. { "FR_11",FR_11,1},
  75. { "FR_12",FR_12,1},
  76. { "FR_13",FR_13,1},
  77. { "FR_14",FR_14,1},
  78. { "FR_15",FR_15,1},
  79. { "FR_16",FR_16,1},
  80. { "FR_20",FR_20,1},
  81. { "FR_21",FR_21,1},
  82. { "FR_22",FR_22,1},
  83. { "FR_23",FR_23,1},
  84. { "FR_24",FR_24,1},
  85. { "FR_25",FR_25,1},
  86. { "FR_26",FR_26,1},
  87. { "FR_30",FR_30,1},
  88. { "FR_31",FR_31,1},
  89. { "FR_32",FR_32,1},
  90. { "FR_33",FR_33,1},
  91. { "FR_34",FR_34,1},
  92. { "FR_35",FR_35,1},
  93. { "FR_36",FR_36,1},
  94. { "FR_40",FR_40,1},
  95. { "FR_41",FR_41,1},
  96. { "FR_42",FR_42,1},
  97. { "FR_43",FR_43,1},
  98. { "FR_44",FR_44,1},
  99. { "FR_45",FR_45,1},
  100. { "FR_46",FR_46,1},
  101. { "FR_50",FR_50,1},
  102. { "FR_51",FR_51,1},
  103. { "FR_52",FR_52,1},
  104. { "FR_53",FR_53,1},
  105. { "FR_54",FR_54,1},
  106. { "FR_55",FR_55,1},
  107. { "FR_56",FR_56,1},
  108. { "FR_60",FR_60,1},
  109. { "FR_61",FR_61,1},
  110. { "FR_62",FR_62,1},
  111. { "FR_63",FR_63,1},
  112. { "FR_64",FR_64,1},
  113. { "FR_65",FR_65,1},
  114. { "FR_66",FR_66,1},
  115. //RL
  116. { "RL_00",RL_00,2},
  117. { "RL_01",RL_01,2},
  118. { "RL_02",RL_02,2},
  119. { "RL_03",RL_03,2},
  120. { "RL_04",RL_04,2},
  121. { "RL_05",RL_05,2},
  122. { "RL_06",RL_06,2},
  123. { "RL_10",RL_10,2},
  124. { "RL_11",RL_11,2},
  125. { "RL_12",RL_12,2},
  126. { "RL_13",RL_13,2},
  127. { "RL_14",RL_14,2},
  128. { "RL_15",RL_15,2},
  129. { "RL_16",RL_16,2},
  130. { "RL_20",RL_20,2},
  131. { "RL_21",RL_21,2},
  132. { "RL_22",RL_22,2},
  133. { "RL_23",RL_23,2},
  134. { "RL_24",RL_24,2},
  135. { "RL_25",RL_25,2},
  136. { "RL_26",RL_26,2},
  137. { "RL_30",RL_30,2},
  138. { "RL_31",RL_31,2},
  139. { "RL_32",RL_32,2},
  140. { "RL_33",RL_33,2},
  141. { "RL_34",RL_34,2},
  142. { "RL_35",RL_35,2},
  143. { "RL_36",RL_36,2},
  144. { "RL_40",RL_40,2},
  145. { "RL_41",RL_41,2},
  146. { "RL_42",RL_42,2},
  147. { "RL_43",RL_43,2},
  148. { "RL_44",RL_44,2},
  149. { "RL_45",RL_45,2},
  150. { "RL_46",RL_46,2},
  151. { "RL_50",RL_50,2},
  152. { "RL_51",RL_51,2},
  153. { "RL_52",RL_52,2},
  154. { "RL_53",RL_53,2},
  155. { "RL_54",RL_54,2},
  156. { "RL_55",RL_55,2},
  157. { "RL_56",RL_56,2},
  158. { "RL_60",RL_60,2},
  159. { "RL_61",RL_61,2},
  160. { "RL_62",RL_62,2},
  161. { "RL_63",RL_63,2},
  162. { "RL_64",RL_64,2},
  163. { "RL_65",RL_65,2},
  164. { "RL_66",RL_66,2},
  165. //RR
  166. { "RR_00",RR_00,3},
  167. { "RR_01",RR_01,3},
  168. { "RR_02",RR_02,3},
  169. { "RR_03",RR_03,3},
  170. { "RR_04",RR_04,3},
  171. { "RR_05",RR_05,3},
  172. { "RR_06",RR_06,3},
  173. { "RR_10",RR_10,3},
  174. { "RR_11",RR_11,3},
  175. { "RR_12",RR_12,3},
  176. { "RR_13",RR_13,3},
  177. { "RR_14",RR_14,3},
  178. { "RR_15",RR_15,3},
  179. { "RR_16",RR_16,3},
  180. { "RR_20",RR_20,3},
  181. { "RR_21",RR_21,3},
  182. { "RR_22",RR_22,3},
  183. { "RR_23",RR_23,3},
  184. { "RR_24",RR_24,3},
  185. { "RR_25",RR_25,3},
  186. { "RR_26",RR_26,3},
  187. { "RR_30",RR_30,3},
  188. { "RR_31",RR_31,3},
  189. { "RR_32",RR_32,3},
  190. { "RR_33",RR_33,3},
  191. { "RR_34",RR_34,3},
  192. { "RR_35",RR_35,3},
  193. { "RR_36",RR_36,3},
  194. { "RR_40",RR_40,3},
  195. { "RR_41",RR_41,3},
  196. { "RR_42",RR_42,3},
  197. { "RR_43",RR_43,3},
  198. { "RR_44",RR_44,3},
  199. { "RR_45",RR_45,3},
  200. { "RR_46",RR_46,3},
  201. { "RR_50",RR_50,3},
  202. { "RR_51",RR_51,3},
  203. { "RR_52",RR_52,3},
  204. { "RR_53",RR_53,3},
  205. { "RR_54",RR_54,3},
  206. { "RR_55",RR_55,3},
  207. { "RR_56",RR_56,3},
  208. { "RR_60",RR_60,3},
  209. { "RR_61",RR_61,3},
  210. { "RR_62",RR_62,3},
  211. { "RR_63",RR_63,3},
  212. { "RR_64",RR_64,3},
  213. { "RR_65",RR_65,3},
  214. { "RR_66",RR_66,3},
  215. };
  216. extern int dvr_detect_carback_signal(void);
  217. extern int vbox_track_paint;
  218. track_context *g_ptrack_context;
  219. static user_header* g_pheader_buf;
  220. static z_stream stream;
  221. static int initialized;
  222. unsigned int track_pic_id;
  223. unsigned int radar_pic_id;
  224. unsigned int car_pic_id;
  225. unsigned int track2_pic_id;//small track for vbox
  226. extern struct carback_context* g_carback_context;
  227. extern int first_draw_track;
  228. extern int track_switch_id;
  229. static user2_header* g_pheader2_buf;
  230. track_context2 *g_ptrack_context2 = NULL;
  231. static unsigned int get_time_ms(void)
  232. {
  233. struct timeval tv;
  234. //float s;
  235. do_gettimeofday(&tv);
  236. //s = tv.tv_usec; s *= 0.000001; s += tv.tv_sec;
  237. return tv.tv_sec * 1000 + tv.tv_usec / 1000;
  238. }
  239. static void show_header_info(void)
  240. {
  241. user_header* p = g_pheader_buf;
  242. if(p == NULL) {
  243. printk(KERN_ERR "header_info_show error!\n");
  244. return;
  245. }
  246. 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",\
  247. 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);
  248. ARKTRACK_DBGPRTK("track rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->track_rect.pos_x,\
  249. p->track_rect.pos_y,p->track_rect.width,p->track_rect.height);
  250. ARKTRACK_DBGPRTK("car rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->car_rect.pos_x,\
  251. p->car_rect.pos_y,p->car_rect.width,p->car_rect.height);
  252. ARKTRACK_DBGPRTK("signal rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->signal_rect.pos_x,\
  253. p->signal_rect.pos_y,p->signal_rect.width,p->signal_rect.height);
  254. ARKTRACK_DBGPRTK("append1 rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->append1_rect.pos_x,\
  255. p->append1_rect.pos_y,p->append1_rect.width,p->append1_rect.height);
  256. ARKTRACK_DBGPRTK("append2 rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->append2_rect.pos_x,\
  257. p->append2_rect.pos_y,p->append2_rect.width,p->append2_rect.height);
  258. ARKTRACK_DBGPRTK("radar0 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[0].pos_x,\
  259. p->radar_rect[0].pos_y,p->radar_rect[0].width,p->radar_rect[0].height);
  260. ARKTRACK_DBGPRTK("radar1 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[1].pos_x,\
  261. p->radar_rect[1].pos_y,p->radar_rect[1].width,p->radar_rect[1].height);
  262. ARKTRACK_DBGPRTK("radar2 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[2].pos_x,\
  263. p->radar_rect[2].pos_y,p->radar_rect[2].width,p->radar_rect[2].height);
  264. ARKTRACK_DBGPRTK("radar3 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[3].pos_x,\
  265. p->radar_rect[3].pos_y,p->radar_rect[3].width,p->radar_rect[3].height);
  266. ARKTRACK_DBGPRTK("track2 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->track2_rect.pos_x,\
  267. p->track2_rect.pos_y,p->track2_rect.width,p->track2_rect.height);
  268. 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",\
  269. 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);
  270. 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",\
  271. 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);
  272. 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",\
  273. 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);
  274. 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",\
  275. 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);
  276. 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",\
  277. 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);
  278. 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",\
  279. 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);
  280. 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",\
  281. 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);
  282. }
  283. static void set_rect_default(void)
  284. {
  285. user_header* p = g_pheader_buf;
  286. p->car_total = 0;
  287. p->radar_total = 0;
  288. p->track_rect.pos_x = 0;
  289. p->track_rect.pos_y = 0;
  290. p->track_rect.width = g_carback_context->screen_width;
  291. p->track_rect.height= g_carback_context->screen_height;
  292. p->car_rect.pos_x = 0;
  293. p->car_rect.pos_y = 0;
  294. p->car_rect.width = 0;
  295. p->car_rect.height= 0;
  296. p->radar_rect[0].pos_x = 0;
  297. p->radar_rect[0].pos_y = 0;
  298. p->radar_rect[0].width = 0;
  299. p->radar_rect[0].height= 0;
  300. p->radar_rect[1].pos_x = 0;
  301. p->radar_rect[1].pos_y = 0;
  302. p->radar_rect[1].width = 0;
  303. p->radar_rect[1].height= 0;
  304. p->radar_rect[2].pos_x = 0;
  305. p->radar_rect[2].pos_y = 0;
  306. p->radar_rect[2].width = 0;
  307. p->radar_rect[2].height= 0;
  308. p->radar_rect[3].pos_x = 0;
  309. p->radar_rect[3].pos_y = 0;
  310. p->radar_rect[3].width = 0;
  311. p->radar_rect[3].height= 0;
  312. p->track2_rect.pos_x = 0;
  313. p->track2_rect.pos_y = 0;
  314. p->track2_rect.width = 0;
  315. p->track2_rect.height= 0;
  316. }
  317. static int check_header_info(void)
  318. {
  319. int i;
  320. int fail = -1;
  321. user_header* p = g_pheader_buf;
  322. //check header info
  323. if(p->identity !=ARK_IDENTITY || p->track_total == 0 || p->file_size <= sizeof(user_header)){
  324. printk(KERN_ERR "identity info error!\n");
  325. return fail;
  326. }
  327. if(p->track_rect.width > g_carback_context->screen_width || p->track_rect.width == 0){
  328. printk(KERN_ERR "track rect width error!\n");
  329. return fail;
  330. }
  331. if(p->track_rect.height > g_carback_context->screen_height || p->track_rect.height == 0){
  332. printk(KERN_ERR "track rect height error!\n");
  333. return fail;
  334. }
  335. for(i = 0;i < TRACK_MAX; i++){
  336. if(TRACK_MAX < p->track[i].image_store_id){
  337. printk(KERN_ERR "track[%d].image_store_id error!\n",i);
  338. return fail;
  339. }
  340. }
  341. for(i = 0;i < CAR_MAX; i++){
  342. if(CAR_MAX < p->car[i].image_store_id){
  343. printk(KERN_ERR "track[%d].image_store_id error!\n",i);
  344. return fail;
  345. }
  346. }
  347. for(i = 0;i < p->radar_total; i++){
  348. if(RADAR_MAX < p->radar[i].image_store_id){
  349. printk(KERN_ERR "track[%d].image_store_id error!\n",i);
  350. return fail;
  351. }
  352. }
  353. for(i = 0;i < TRACK_MAX; i++){
  354. if(TRACK_MAX < p->track2[i].image_store_id){
  355. printk(KERN_ERR "track2[%d].image_store_id error!\n",i);
  356. return fail;
  357. }
  358. }
  359. return 0;
  360. }
  361. static bool is_radar_image_id(unsigned int image_id){
  362. int i;
  363. for(i = 0;i < RADAR_MAX; i++){
  364. if(radar_idmap[i].image_id == image_id){
  365. return true;
  366. }
  367. }
  368. return false;
  369. }
  370. int set_disp_track_id(unsigned int track_id)
  371. {
  372. static unsigned int pre_id = IMAGE_ID_NONE;
  373. track_context *p = g_ptrack_context;
  374. if(p == NULL){
  375. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  376. return -1;
  377. }
  378. if(track_id >= TRACK_MAX && track_id < IMAGE_ID_NONE){
  379. printk(KERN_ERR "set disp track image id error!\n" );
  380. return -1;
  381. }
  382. if(pre_id != track_id || IMAGE_ID_NONE == track_id){
  383. p->disp_track_id = track_id;
  384. pre_id = track_id;
  385. }
  386. return 0;
  387. }
  388. int set_disp_car_id(unsigned int car_id)
  389. {
  390. static unsigned int pre_id = IMAGE_ID_NONE;
  391. track_context *p = g_ptrack_context;
  392. if(p == NULL){
  393. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  394. return -1;
  395. }
  396. if(car_id >= CAR_MAX && car_id < IMAGE_ID_NONE){
  397. printk(KERN_ERR "set disp car image id error!\n" );
  398. return -1;
  399. }
  400. if(pre_id != car_id || IMAGE_ID_NONE == car_id){
  401. p->disp_car_id = car_id;
  402. pre_id = car_id;
  403. }
  404. return 0;
  405. }
  406. int set_disp_radar_id(unsigned int radar_id)
  407. {
  408. static unsigned int pre_id = IMAGE_ID_NONE;
  409. track_context *p = g_ptrack_context;
  410. unsigned int image_id;
  411. unsigned char channel;
  412. unsigned int mask = 0xff000000;
  413. unsigned int disp_id = 0;
  414. if(p == NULL){
  415. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  416. return -1;
  417. }
  418. if(IMAGE_ID_NONE == radar_id){
  419. p->disp_radar_id = IMAGE_ID_NONE;
  420. pre_id = IMAGE_ID_NONE;
  421. return 0;
  422. }
  423. if(pre_id == radar_id){
  424. return 0;
  425. }
  426. for(channel = RADAR_CHANNEL_FL; channel <= RADAR_CHANNEL_RR;channel++){
  427. image_id = radar_id & (mask >> 8*channel);
  428. if(!is_radar_image_id(image_id)){
  429. printk(KERN_ERR "set disp radar id channel=%d ,error!\n",channel);
  430. continue;
  431. }
  432. disp_id |= image_id;
  433. }
  434. p->disp_radar_id = disp_id;
  435. pre_id = disp_id;
  436. //printk(KERN_ALERT "set disp radar id disp_id=0x%0x.\n",disp_id);
  437. return 0;
  438. }
  439. int set_disp_signal_id(unsigned int disp_signal_id)
  440. {
  441. static unsigned int pre_id = IMAGE_ID_NONE;
  442. track_context *p = g_ptrack_context;
  443. if(p == NULL){
  444. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  445. return -1;
  446. }
  447. if(disp_signal_id >= SIGNAL_MAX && disp_signal_id < IMAGE_ID_NONE){
  448. printk(KERN_ERR "set disp signal image id error!\n" );
  449. return -1;
  450. }
  451. if(pre_id != disp_signal_id || IMAGE_ID_NONE == disp_signal_id){
  452. p->disp_signal_id = disp_signal_id;
  453. pre_id = disp_signal_id;
  454. }
  455. //printk(KERN_ALERT "++++++p->disp_signal_id = %d\n" ,p->disp_signal_id);
  456. return 0;
  457. }
  458. int set_disp_append1_id(unsigned int disp_append1_id)
  459. {
  460. static unsigned int pre_id = IMAGE_ID_NONE;
  461. track_context *p = g_ptrack_context;
  462. if(p == NULL){
  463. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  464. return -1;
  465. }
  466. if(disp_append1_id >= APPEND1_MAX && disp_append1_id < IMAGE_ID_NONE){
  467. printk(KERN_ERR "set_disp_append1_id image id error!\n" );
  468. return -1;
  469. }
  470. if(pre_id != disp_append1_id || IMAGE_ID_NONE == disp_append1_id){
  471. p->disp_append1_id = disp_append1_id;
  472. pre_id = disp_append1_id;
  473. }
  474. //printk(KERN_ALERT "++++++p->disp_append1_id = %d\n" ,p->disp_append1_id);
  475. return 0;
  476. }
  477. int set_disp_append2_id(unsigned int disp_append2_id)
  478. {
  479. static unsigned int pre_id = IMAGE_ID_NONE;
  480. track_context *p = g_ptrack_context;
  481. if(p == NULL){
  482. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  483. return -1;
  484. }
  485. if(disp_append2_id >= APPEND2_MAX && disp_append2_id < IMAGE_ID_NONE){
  486. printk(KERN_ERR "set_disp_append2_id image id error!\n" );
  487. return -1;
  488. }
  489. if(pre_id != disp_append2_id || IMAGE_ID_NONE == disp_append2_id){
  490. p->disp_append2_id = disp_append2_id;
  491. pre_id = disp_append2_id;
  492. }
  493. //printk(KERN_ALERT "++++++p->disp_append2_id = %d\n" ,p->disp_append2_id);
  494. return 0;
  495. }
  496. int set_disp_track2_id(unsigned int track2_id)
  497. {
  498. static unsigned int pre_id = IMAGE_ID_NONE;
  499. track_context *p = g_ptrack_context;
  500. if(p == NULL){
  501. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  502. return -1;
  503. }
  504. if(track2_id >= TRACK_MAX && track2_id < IMAGE_ID_NONE){
  505. printk(KERN_ERR "set disp track2 image id error!\n" );
  506. return -1;
  507. }
  508. if(pre_id != track2_id || IMAGE_ID_NONE == track2_id){
  509. p->disp_track2_id = track2_id;
  510. pre_id = track2_id;
  511. }
  512. return 0;
  513. }
  514. /*
  515. *set_disp_mradar_id: radar new solution
  516. *
  517. *-------------------------front-----------------------
  518. *
  519. * mradar0 mradar1 mradar2 mradar3
  520. * +-----------------+
  521. * | |
  522. * | |
  523. * mradar8 | | mradar12
  524. * | |
  525. * mradar9 | | mradar13
  526. * | |
  527. * mradar10| | mradar14
  528. * | |
  529. * mradar11| | mradar15
  530. * | |
  531. * | |
  532. * +-----------------+
  533. * mradar4 mradar5 mradar6 mradar7
  534. *
  535. *-------------------------rear-----------------------
  536. */
  537. int set_disp_mradar_id(unsigned char *pimage_id)
  538. {
  539. static unsigned char pre_mradar_id[MRADAR_MAX]={0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF};
  540. unsigned char mradar_id[MRADAR_MAX];
  541. track_context2 *p = g_ptrack_context2;
  542. int i;
  543. if(p == NULL){
  544. //printk(KERN_ALERT "%s: no header2 ,set mradar id invalid!\n", __FUNCTION__);
  545. return 0;
  546. }
  547. memcpy(mradar_id, pimage_id, MRADAR_MAX);
  548. for(i = 0; i < MRADAR_MAX; i++){
  549. ARKTRACK_DBGPRTK("mradar_id[%d]=%d\n", i, mradar_id[i]);
  550. if(mradar_id[i] > 0xF){
  551. printk(KERN_ALERT "%s: mradar_id[%d]=%d, MRADAR_MAX=0xF, error.\n", __FUNCTION__, i, mradar_id[i]);
  552. return -1;
  553. }
  554. }
  555. for(i = 0; i < MRADAR_MAX; i++){
  556. if(pre_mradar_id[i] != mradar_id[i]){
  557. break;
  558. }
  559. }
  560. if(i < MRADAR_MAX){
  561. memcpy(p->disp_mradar_id, mradar_id, MRADAR_MAX);
  562. memcpy(pre_mradar_id, mradar_id, MRADAR_MAX);
  563. p->disp_mradar_id_change = 1;
  564. }
  565. return 0;
  566. }
  567. static int init_track_context(unsigned int addr)
  568. {
  569. int ret = -1;
  570. int size;
  571. int i;
  572. unsigned char *p;
  573. //printk(KERN_ALERT "init_track_context ...\n");
  574. if(addr == 0){
  575. printk(KERN_ERR "addr error!\n");
  576. return ret;
  577. }
  578. g_pheader_buf = (user_header*)addr;
  579. show_header_info();
  580. if(check_header_info() < 0){
  581. printk(KERN_ERR "identity info error!\n");
  582. return ret;
  583. }
  584. p = vzalloc(sizeof(track_context));
  585. if (p == NULL) {
  586. printk(KERN_ERR "%s %d: failed to allocate track_context\n",__FUNCTION__, __LINE__);
  587. return -ENOMEM;
  588. }
  589. g_ptrack_context = (track_context *)p;
  590. g_ptrack_context->disp_track_size = 4 * g_pheader_buf->track_rect.width * g_pheader_buf->track_rect.height;
  591. if(g_pheader_buf->track_total > 0){
  592. size = 4* g_pheader_buf->track_rect.width * g_pheader_buf->track_rect.height;
  593. p = vzalloc(size);
  594. if (p == NULL) {
  595. printk(KERN_ERR "%s %d: failed to allocate track\n",__FUNCTION__, __LINE__);
  596. ret = -ENOMEM;
  597. goto err_track2;
  598. }
  599. g_ptrack_context->disp_track_buf = p;
  600. g_ptrack_context->disp_track_size= size;
  601. }
  602. if(g_pheader_buf->car_total > 0){
  603. size = 4* g_pheader_buf->car_rect.width * g_pheader_buf->car_rect.height;
  604. p = vzalloc(size);
  605. if (p == NULL) {
  606. printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
  607. ret = -ENOMEM;
  608. goto err_car;
  609. }
  610. g_ptrack_context->disp_car_buf = p;
  611. g_ptrack_context->disp_car_size= size;
  612. }
  613. if(g_pheader_buf->signal_total> 0){
  614. size = 4* g_pheader_buf->signal_rect.width * g_pheader_buf->signal_rect.height;
  615. p = vzalloc(size);
  616. if (p == NULL) {
  617. printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
  618. ret = -ENOMEM;
  619. goto err_car;
  620. }
  621. g_ptrack_context->disp_signal_buf = p;
  622. g_ptrack_context->disp_signal_size= size;
  623. }
  624. if(g_pheader_buf->append1_total> 0){
  625. size = 4* g_pheader_buf->append1_rect.width * g_pheader_buf->append1_rect.height;
  626. p = vzalloc(size);
  627. if (p == NULL) {
  628. printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
  629. ret = -ENOMEM;
  630. goto err_car;
  631. }
  632. g_ptrack_context->disp_append1_buf = p;
  633. g_ptrack_context->disp_append1_size= size;
  634. }
  635. if(g_pheader_buf->append2_total> 0){
  636. size = 4* g_pheader_buf->append2_rect.width * g_pheader_buf->append2_rect.height;
  637. p = vzalloc(size);
  638. if (p == NULL) {
  639. printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
  640. ret = -ENOMEM;
  641. goto err_car;
  642. }
  643. g_ptrack_context->disp_append2_buf = p;
  644. g_ptrack_context->disp_append2_size= size;
  645. }
  646. if(g_pheader_buf->radar_total > 0){
  647. size = 4* g_pheader_buf->radar_rect[0].width * g_pheader_buf->radar_rect[0].height;
  648. for(i = 0; i < 4;i++){
  649. p = vzalloc(size);
  650. if (p == NULL) {
  651. printk(KERN_ERR "%s %d: failed to allocate radar\n",__FUNCTION__, __LINE__);
  652. ret = -ENOMEM;
  653. while(i-- >= 0){
  654. vfree(g_ptrack_context->disp_radar_buf[i]);
  655. }
  656. goto err_radar;
  657. }
  658. g_ptrack_context->disp_radar_buf[i] = p;
  659. g_ptrack_context->disp_radar_size = size;
  660. }
  661. }
  662. if(g_pheader_buf->track2_total > 0){
  663. size = 4* g_pheader_buf->track2_rect.width * g_pheader_buf->track2_rect.height;
  664. p = vzalloc(size);
  665. if (p == NULL) {
  666. printk(KERN_ERR "%s %d: failed to allocate track2\n",__FUNCTION__, __LINE__);
  667. ret = -ENOMEM;
  668. goto err_track2;
  669. }
  670. g_ptrack_context->disp_track2_buf = p;
  671. g_ptrack_context->disp_track2_size= size;
  672. }
  673. g_ptrack_context->pheader_buf = g_pheader_buf;
  674. g_ptrack_context->disp_xpos = g_pheader_buf->track_rect.pos_x;
  675. g_ptrack_context->disp_ypos = g_pheader_buf->track_rect.pos_y;
  676. g_ptrack_context->disp_width = g_carback_context->screen_width;
  677. g_ptrack_context->disp_height = g_carback_context->screen_height;
  678. memcpy(&g_ptrack_context->track_param,&g_pheader_buf->track_rect,sizeof(track_param_context));
  679. g_ptrack_context->file_type = g_pheader_buf->file_type;
  680. g_ptrack_context->disp_track_id = IMAGE_ID_NONE;
  681. g_ptrack_context->disp_car_id = IMAGE_ID_NONE;
  682. g_ptrack_context->disp_radar_id = IMAGE_ID_NONE;
  683. g_ptrack_context->disp_track2_id= IMAGE_ID_NONE;
  684. return 0;
  685. err_track2:
  686. for(i = 0; i < 4;i++)
  687. if(g_ptrack_context->disp_radar_buf[i])
  688. vfree(g_ptrack_context->disp_radar_buf[i]);
  689. err_radar:
  690. if(g_ptrack_context->disp_car_buf)
  691. vfree(g_ptrack_context->disp_car_buf);
  692. err_car:
  693. if(g_ptrack_context)
  694. vfree(g_ptrack_context);
  695. return ret;
  696. }
  697. static void show_header2_info(void)
  698. {
  699. user2_header* p = g_pheader2_buf;
  700. rect_info *prect;
  701. item_info *pitem;
  702. int i;
  703. if(p == NULL) {
  704. printk(KERN_ERR "header_info_show error!\n");
  705. return;
  706. }
  707. ARKTRACK_DBGPRTK("header2_buf ===>identity=0x%0x,file_type=0x%0x file_size=0x%0x\n", p->identity,p->file_type,p->file_size);
  708. for(i = 0; i < MRADAR_MAX; i++){
  709. prect = &p->mradar_rect[i];
  710. pitem = &p->mradar[i][0];
  711. ARKTRACK_DBGPRTK("mradar_rect[%d]===>total=%d, pos_x=%d pos_y=%d width=%d height=%d\n",\
  712. i, p->mradar_total[i], prect->pos_x, prect->pos_y, prect->width, prect->height);
  713. 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",\
  714. i, pitem->image_type, pitem->image_store_id, pitem->image_id, pitem->image_offset, pitem->image_size);
  715. }
  716. }
  717. static int check_header2_info(void)
  718. {
  719. int i, j;
  720. user2_header* p = g_pheader2_buf;
  721. if(p == NULL) {
  722. printk(KERN_ERR "check_header2_info error!\n");
  723. return -1;
  724. }
  725. //check header info
  726. if(p->identity != ARK_IDENTITY || p->file_size <= sizeof(user2_header)){
  727. printk(KERN_ERR "header2 identity info error!\n");
  728. return -1;
  729. }
  730. for(j = 0 ;j < MRADAR_MAX; j++){
  731. for(i = 0;i < MRADAR_ITEM_MAX; i++){
  732. if(MRADAR_MAX < p->mradar[j][i].image_id){
  733. printk(KERN_ALERT "track[%d].image_id error!\n",i);
  734. return -1;
  735. }
  736. }
  737. }
  738. printk(KERN_ALERT "check_header2_info success!\n");
  739. return 0;
  740. }
  741. static int init_track_context2(unsigned int addr)
  742. {
  743. unsigned int header2_addr_start;
  744. unsigned char *p;
  745. int ret = -1;
  746. int size;
  747. int i;
  748. //printk(KERN_ALERT "file_type=%0x ---> HEADER2_FILE_FLAG=%0x.\n", g_pheader_buf->file_type, HEADER2_FILE_FLAG);
  749. if((g_pheader_buf->file_type & 0x80000000) != HEADER2_FILE_FLAG){
  750. printk(KERN_ALERT "only header file.\n");
  751. return 0;
  752. }
  753. printk(KERN_ALERT "%s: start.\n", __func__);
  754. if(addr == 0){
  755. printk(KERN_ERR "addr error!\n");
  756. return -1;
  757. }
  758. //g_pheader2_buf = (user2_header*)(addr + g_pheader_buf->file_size);
  759. p = vzalloc(sizeof(user2_header));
  760. if (p == NULL) {
  761. printk(KERN_ERR "%s: failed to user2_header.\n",__FUNCTION__);
  762. return -1;
  763. }
  764. header2_addr_start = addr + g_pheader_buf->file_size;
  765. printk(KERN_ALERT "header2_addr_start=0x%0x.\n", header2_addr_start);
  766. memcpy(p, (void *)header2_addr_start, sizeof(user2_header));
  767. g_pheader2_buf = (user2_header*)p;
  768. show_header2_info();
  769. if(check_header2_info() < 0){
  770. printk(KERN_ALERT "check_header2_info failed!\n");
  771. return -1;
  772. }
  773. p = vzalloc(sizeof(track_context2));
  774. if (p == NULL) {
  775. printk(KERN_ERR "%s %d: failed to allocate track_context2\n",__FUNCTION__, __LINE__);
  776. return -1;
  777. }
  778. memset(p, 0 ,sizeof(track_context2));
  779. g_ptrack_context2 = (track_context2 *)p;
  780. g_ptrack_context2->pheader2_buf = g_pheader2_buf;
  781. g_ptrack_context2->file_type = g_pheader2_buf->file_type;
  782. memset(g_ptrack_context2->disp_mradar_id, 0x0F ,MRADAR_MAX);
  783. for(i = 0; i < MRADAR_MAX; i++){
  784. size = 4* g_pheader2_buf->mradar_rect[i].width * g_pheader2_buf->mradar_rect[i].height;
  785. p = vzalloc(size);
  786. if (p == NULL) {
  787. printk(KERN_ERR "%s %d: failed to allocate radar\n",__FUNCTION__, __LINE__);
  788. ret = -ENOMEM;
  789. while(i-- >= 0){
  790. vfree(g_ptrack_context2->disp_mradar_buf[i]);
  791. }
  792. vfree(g_pheader2_buf);
  793. return -1;
  794. }
  795. g_ptrack_context2->disp_mradar_buf[i] = p;
  796. g_ptrack_context2->disp_mradar_size[i]= size;
  797. memcpy(&g_ptrack_context2->mradar_param.mradar_rect[i], &g_pheader2_buf->mradar_rect[i], sizeof(rect_info));
  798. ARKTRACK_DBGPRTK("mradar_buf[%d]=0x%0x, size=0x%0x \n",i, p, size);
  799. }
  800. printk(KERN_ALERT "%s: success.\n", __func__);
  801. return 0;
  802. }
  803. static int get_radar_channel(unsigned int image_id){
  804. int i;
  805. int channel = -1;
  806. for(i = 0;i < RADAR_MAX; i++){
  807. if(radar_idmap[i].image_id == image_id){
  808. channel = radar_idmap[i].dis_channel;
  809. break;
  810. }
  811. }
  812. return channel;
  813. }
  814. static unsigned int get_picture_addr(enum image_type type, unsigned int id)
  815. {
  816. unsigned int offset;
  817. int i;
  818. if(type == IMAGE_TYPE_TRACK){
  819. offset = g_pheader_buf->track[id].image_offset;
  820. }
  821. else if(type == IMAGE_TYPE_CAR){
  822. offset = g_pheader_buf->car[id].image_offset;
  823. }
  824. else if(type == IMAGE_TYPE_SIGNAL){
  825. offset = g_pheader_buf->signal[id].image_offset;
  826. }
  827. else if(type == IMAGE_TYPE_APPEND1){
  828. offset = g_pheader_buf->append1[id].image_offset;
  829. }
  830. else if(type == IMAGE_TYPE_APPEND2){
  831. offset = g_pheader_buf->append2[id].image_offset;
  832. }
  833. else if(type == IMAGE_TYPE_RADAR){
  834. for(i = 0; i < RADAR_MAX;i++){
  835. if(g_pheader_buf->radar[i].image_id == id){
  836. offset = g_pheader_buf->radar[i].image_offset;
  837. break;
  838. }
  839. }
  840. }
  841. else if(type == IMAGE_TYPE_TRACK2){
  842. offset = g_pheader_buf->track2[id].image_offset;
  843. }
  844. return g_carback_context->track_data_virtaddr +offset;
  845. }
  846. static unsigned int get_picture_offset(enum image_type type, unsigned int id)
  847. {
  848. unsigned int offset = 0;
  849. int i;
  850. if(type == IMAGE_TYPE_TRACK){
  851. offset = g_pheader_buf->track[id].image_offset;
  852. }
  853. else if(type == IMAGE_TYPE_CAR){
  854. offset = g_pheader_buf->car[id].image_offset;
  855. }
  856. else if(type == IMAGE_TYPE_SIGNAL){
  857. offset = g_pheader_buf->signal[id].image_offset;
  858. }
  859. else if(type == IMAGE_TYPE_APPEND1){
  860. offset = g_pheader_buf->append1[id].image_offset;
  861. }
  862. else if(type == IMAGE_TYPE_APPEND2){
  863. offset = g_pheader_buf->append2[id].image_offset;
  864. }
  865. else if(type == IMAGE_TYPE_RADAR){
  866. for(i = 0; i < RADAR_MAX;i++){
  867. if(g_pheader_buf->radar[i].image_id == id){
  868. offset = g_pheader_buf->radar[i].image_offset;
  869. break;
  870. }
  871. }
  872. }
  873. else if(type == IMAGE_TYPE_TRACK2){
  874. offset = g_pheader_buf->track2[id].image_offset;
  875. }
  876. return offset;
  877. }
  878. static unsigned int get_picture_size(enum image_type type, unsigned int id)
  879. {
  880. unsigned int image_size = 0;
  881. int i;
  882. if(type == IMAGE_TYPE_TRACK){
  883. image_size = g_pheader_buf->track[id].image_size;
  884. }
  885. else if(type == IMAGE_TYPE_CAR){
  886. image_size = g_pheader_buf->car[id].image_size;
  887. }
  888. else if(type == IMAGE_TYPE_SIGNAL){
  889. image_size = g_pheader_buf->signal[id].image_size;
  890. }
  891. else if(type == IMAGE_TYPE_APPEND1){
  892. image_size = g_pheader_buf->append1[id].image_size;
  893. }
  894. else if(type == IMAGE_TYPE_APPEND2){
  895. image_size = g_pheader_buf->append2[id].image_size;
  896. }
  897. else if(type == IMAGE_TYPE_RADAR){
  898. for(i = 0; i < RADAR_MAX;i++){
  899. if(g_pheader_buf->radar[i].image_id == id){
  900. image_size = g_pheader_buf->radar[i].image_size;
  901. break;
  902. }
  903. }
  904. }
  905. else if(type == IMAGE_TYPE_TRACK2){
  906. image_size = g_pheader_buf->track2[id].image_size;
  907. }
  908. return image_size;
  909. }
  910. static unsigned int get_picture_num(enum image_type type)
  911. {
  912. unsigned int picture_num = 0;
  913. if(type == IMAGE_TYPE_TRACK){
  914. picture_num = g_pheader_buf->track_total;
  915. }
  916. else if(type == IMAGE_TYPE_CAR){
  917. picture_num = g_pheader_buf->car_total;
  918. }
  919. else if(type == IMAGE_TYPE_RADAR){
  920. picture_num = g_pheader_buf->radar_total;
  921. }
  922. else if(type == IMAGE_TYPE_TRACK2){
  923. picture_num = g_pheader_buf->track2_total;
  924. }
  925. //printk("get image_type = %d, num = %d !",type,picture_num);
  926. return picture_num;
  927. }
  928. /* Returns length of decompressed data. */
  929. static int zlib_uncompress_block(void *dst, int dstlen, void *src, int srclen)
  930. {
  931. int err;
  932. stream.next_in = src;
  933. stream.avail_in = srclen;
  934. stream.next_out = dst;
  935. stream.avail_out = dstlen;
  936. err = zlib_inflateReset(&stream);
  937. if (err != Z_OK) {
  938. printk("zlib_inflateReset error %d\n", err);
  939. zlib_inflateEnd(&stream);
  940. zlib_inflateInit(&stream);
  941. }
  942. err = zlib_inflate(&stream, Z_FINISH);
  943. if (err != Z_STREAM_END)
  944. goto err;
  945. return stream.total_out;
  946. err:
  947. printk(KERN_ERR "Error %d while decompressing!\n", err);
  948. printk(KERN_ERR "%p(%d)->%p(%d)\n", src, srclen, dst, dstlen);
  949. return -EIO;
  950. }
  951. static int zlib_uncompress_init(void)
  952. {
  953. if (!initialized++) {
  954. stream.workspace = vmalloc(zlib_inflate_workspacesize());
  955. if ( !stream.workspace ) {
  956. initialized = 0;
  957. return -ENOMEM;
  958. }
  959. stream.next_in = NULL;
  960. stream.avail_in = 0;
  961. zlib_inflateInit(&stream);
  962. }
  963. return 0;
  964. }
  965. static void zlib_uncompress_exit(void)
  966. {
  967. if (!--initialized) {
  968. zlib_inflateEnd(&stream);
  969. vfree(stream.workspace);
  970. }
  971. }
  972. static void copy_line_data(unsigned int *dest,unsigned int *src,unsigned int width,enum cover_type cover)
  973. {
  974. unsigned int i;
  975. unsigned int* psrc = (unsigned int*)src;
  976. unsigned int* pdest = (unsigned int*)dest;
  977. if(cover == SRC_COVER_DST){
  978. memcpy(pdest,psrc,width*PIXEL_DATA_SIZE);
  979. }else if(cover == DST_COVER_SRC2){
  980. for(i = 0;i < width;i++){
  981. if(*pdest == PIXEL_DATA_NONE || *pdest == PIXEL_DATA_ZERO)
  982. *pdest = *psrc;
  983. psrc++;
  984. pdest++;
  985. }
  986. }
  987. else if(cover == SRC_COVER_DST2){
  988. for(i = 0;i < width;i++){
  989. if(*psrc == 0xFFFFFFFF || *psrc == PIXEL_DATA_NONE || *psrc == PIXEL_DATA_ZERO){
  990. psrc++;
  991. pdest++;
  992. continue;
  993. }
  994. *pdest = *psrc;
  995. psrc++;
  996. pdest++;
  997. }
  998. }
  999. }
  1000. static int copy_pic_data(void *dest,void *src,enum image_type type,unsigned int id,enum cover_type cover)
  1001. {
  1002. unsigned int width;
  1003. unsigned int height;
  1004. unsigned int pos_x;
  1005. unsigned int pos_y;
  1006. track_param_context* p = &g_ptrack_context->track_param;
  1007. unsigned int* dest_tmp;
  1008. unsigned int* src_tmp;
  1009. int radar_channel;
  1010. int i;
  1011. if(dest == NULL || src == NULL){
  1012. printk(KERN_ERR "paint car dest src error!\n");
  1013. return -1;
  1014. }
  1015. if(type == IMAGE_TYPE_TRACK){
  1016. width = p->track_rect.width;
  1017. height= p->track_rect.height;
  1018. pos_x = p->track_rect.pos_x;
  1019. pos_y = p->track_rect.pos_y;
  1020. }
  1021. else if(type == IMAGE_TYPE_CAR){
  1022. width = p->car_rect.width;
  1023. height= p->car_rect.height;
  1024. pos_x = p->car_rect.pos_x;
  1025. pos_y = p->car_rect.pos_y;
  1026. }
  1027. else if(type == IMAGE_TYPE_RADAR){
  1028. radar_channel = get_radar_channel(id);
  1029. if(radar_channel < 0){
  1030. printk(KERN_ERR "get radar_channel error!\n");
  1031. return -1;
  1032. }
  1033. width = p->radar_rect[radar_channel].width;
  1034. height= p->radar_rect[radar_channel].height;
  1035. pos_x = p->radar_rect[radar_channel].pos_x;
  1036. pos_y = p->radar_rect[radar_channel].pos_y;
  1037. }
  1038. else if(type == IMAGE_TYPE_SIGNAL){
  1039. width = p->signal_rect.width;
  1040. height= p->signal_rect.height;
  1041. pos_x = p->signal_rect.pos_x;
  1042. pos_y = p->signal_rect.pos_y;
  1043. }
  1044. else if(type == IMAGE_TYPE_APPEND1){
  1045. width = p->append1_rect.width;
  1046. height= p->append1_rect.height;
  1047. pos_x = p->append1_rect.pos_x;
  1048. pos_y = p->append1_rect.pos_y;
  1049. }
  1050. else if(type == IMAGE_TYPE_APPEND2){
  1051. width = p->append2_rect.width;
  1052. height= p->append2_rect.height;
  1053. pos_x = p->append2_rect.pos_x;
  1054. pos_y = p->append2_rect.pos_y;
  1055. }
  1056. else if(type == IMAGE_TYPE_TRACK2){
  1057. width = p->track2_rect.width;
  1058. height= p->track2_rect.height;
  1059. pos_x = p->track2_rect.pos_x;
  1060. pos_y = p->track2_rect.pos_y;
  1061. }
  1062. else if(type == IMAGE_TYPE_MRADAR){
  1063. mradar_param_context* p2 = &g_ptrack_context2->mradar_param;
  1064. width = p2->mradar_rect[id].width;
  1065. height= p2->mradar_rect[id].height;
  1066. pos_x = p2->mradar_rect[id].pos_x;
  1067. pos_y = p2->mradar_rect[id].pos_y;
  1068. }
  1069. else{
  1070. printk(KERN_ERR "paint car type error!\n");
  1071. return -1;
  1072. }
  1073. for(i = 0; i < height;i++){
  1074. dest_tmp = dest + g_ptrack_context->disp_width * (pos_y + i) * PIXEL_DATA_SIZE + pos_x * PIXEL_DATA_SIZE;
  1075. src_tmp = src + i * width * PIXEL_DATA_SIZE;
  1076. copy_line_data(dest_tmp,src_tmp,width,cover);
  1077. }
  1078. return 0;
  1079. }
  1080. static unsigned int subjoin_car_pic(void *dest)
  1081. {
  1082. static unsigned int last_id = IMAGE_ID_NONE;
  1083. track_context *p = g_ptrack_context;
  1084. void *dest_car = p->disp_car_buf;
  1085. unsigned int dest_size = p->disp_car_size;
  1086. unsigned int fill_size = 0;
  1087. unsigned int source_size;
  1088. unsigned int source_offset;
  1089. void *source;
  1090. if(p->disp_car_id > CAR_MAX)
  1091. return 0;
  1092. if(first_draw_track)
  1093. last_id = IMAGE_ID_NONE;
  1094. source_offset = get_picture_offset(IMAGE_TYPE_CAR,p->disp_car_id);
  1095. source_size = get_picture_size(IMAGE_TYPE_CAR,p->disp_car_id);
  1096. //printk(KERN_ALERT "source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
  1097. if(source_size == 0 || source_offset < sizeof(user_header)){
  1098. printk(KERN_ERR "subjoin car pic source error, disp_car_id=0x%0x.\n",p->disp_car_id);
  1099. return 0;
  1100. }
  1101. if(last_id == IMAGE_ID_NONE || last_id != p->disp_car_id){
  1102. source = (void*)get_picture_addr(IMAGE_TYPE_CAR,p->disp_car_id);
  1103. fill_size = zlib_uncompress_block(dest_car, dest_size, source, source_size);
  1104. if(fill_size != dest_size){
  1105. printk(KERN_ERR " zlib uncompress car error!\n");
  1106. return fill_size;
  1107. }
  1108. }
  1109. copy_pic_data(dest,dest_car,IMAGE_TYPE_CAR,p->disp_car_id,SRC_COVER_DST);
  1110. last_id = p->disp_car_id;
  1111. return fill_size;
  1112. }
  1113. static unsigned int subjoin_signal_pic(void *dest)
  1114. {
  1115. static unsigned int last_id = IMAGE_ID_NONE;
  1116. track_context *p = g_ptrack_context;
  1117. void *dest_signal = p->disp_signal_buf;
  1118. unsigned int dest_size = p->disp_signal_size;
  1119. unsigned int fill_size = 0;
  1120. unsigned int source_size;
  1121. unsigned int source_offset;
  1122. void *source;
  1123. if(p->disp_signal_id > SIGNAL_MAX)
  1124. return 0;
  1125. if(first_draw_track)
  1126. last_id = IMAGE_ID_NONE;
  1127. source_offset = get_picture_offset(IMAGE_TYPE_SIGNAL,p->disp_signal_id);
  1128. source_size = get_picture_size(IMAGE_TYPE_SIGNAL,p->disp_signal_id);
  1129. //printk(KERN_ALERT "~~~~~~source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
  1130. if(source_size == 0 || source_offset < sizeof(user_header)){
  1131. printk(KERN_ERR "subjoin signal pic source error, disp_signal_id=0x%0x.\n",p->disp_signal_id);
  1132. return 0;
  1133. }
  1134. if(last_id == IMAGE_ID_NONE || last_id != p->disp_signal_id){
  1135. source = (void*)get_picture_addr(IMAGE_TYPE_SIGNAL,p->disp_signal_id);
  1136. fill_size = zlib_uncompress_block(dest_signal, dest_size, source, source_size);
  1137. if(fill_size != dest_size){
  1138. printk(KERN_ERR " zlib uncompress signal error!\n");
  1139. return fill_size;
  1140. }
  1141. }
  1142. copy_pic_data(dest,dest_signal,IMAGE_TYPE_SIGNAL,p->disp_signal_id,SRC_COVER_DST);
  1143. last_id = p->disp_signal_id;
  1144. return fill_size;
  1145. }
  1146. static unsigned int subjoin_append1_pic(void *dest)
  1147. {
  1148. static unsigned int last_id = IMAGE_ID_NONE;
  1149. track_context *p = g_ptrack_context;
  1150. void *dest_append1 = p->disp_append1_buf;
  1151. unsigned int dest_size = p->disp_append1_size;
  1152. unsigned int fill_size = 0;
  1153. unsigned int source_size;
  1154. unsigned int source_offset;
  1155. void *source;
  1156. if(p->disp_append1_id > APPEND1_MAX)
  1157. return 0;
  1158. if(first_draw_track)
  1159. last_id = IMAGE_ID_NONE;
  1160. source_offset = get_picture_offset(IMAGE_TYPE_APPEND1,p->disp_append1_id);
  1161. source_size = get_picture_size(IMAGE_TYPE_APPEND1,p->disp_append1_id);
  1162. //printk(KERN_ALERT "++++++ subjoin_append1_pic source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
  1163. if(source_size == 0 || source_offset < sizeof(user_header)){
  1164. printk(KERN_ERR "subjoin append1 pic source error, disp_append1_id=0x%0x.\n",p->disp_append1_id);
  1165. return 0;
  1166. }
  1167. if(last_id == IMAGE_ID_NONE || last_id != p->disp_append1_id){
  1168. source = (void*)get_picture_addr(IMAGE_TYPE_APPEND1,p->disp_append1_id);
  1169. fill_size = zlib_uncompress_block(dest_append1, dest_size, source, source_size);
  1170. if(fill_size != dest_size){
  1171. printk(KERN_ERR " zlib uncompress append1 error!\n");
  1172. return fill_size;
  1173. }
  1174. }
  1175. copy_pic_data(dest,dest_append1,IMAGE_TYPE_APPEND1,p->disp_append1_id,SRC_COVER_DST);
  1176. last_id = p->disp_append1_id;
  1177. return fill_size;
  1178. }
  1179. static unsigned int subjoin_append2_pic(void *dest)
  1180. {
  1181. static unsigned int last_id = IMAGE_ID_NONE;
  1182. track_context *p = g_ptrack_context;
  1183. void *dest_append2 = p->disp_append2_buf;
  1184. unsigned int dest_size = p->disp_append2_size;
  1185. unsigned int fill_size = 0;
  1186. unsigned int source_size;
  1187. unsigned int source_offset;
  1188. void *source;
  1189. if(p->disp_append2_id > APPEND2_MAX)
  1190. return 0;
  1191. if(first_draw_track)
  1192. last_id = IMAGE_ID_NONE;
  1193. source_offset = get_picture_offset(IMAGE_TYPE_APPEND2,p->disp_append2_id);
  1194. source_size = get_picture_size(IMAGE_TYPE_APPEND2,p->disp_append2_id);
  1195. //printk(KERN_ALERT "++++++ subjoin_append2_pic source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
  1196. if(source_size == 0 || source_offset < sizeof(user_header)){
  1197. printk(KERN_ERR "subjoin append2 pic source error, disp_append2_id=0x%0x.\n",p->disp_append2_id);
  1198. return 0;
  1199. }
  1200. if(last_id == IMAGE_ID_NONE || last_id != p->disp_append2_id){
  1201. source = (void*)get_picture_addr(IMAGE_TYPE_APPEND2,p->disp_append2_id);
  1202. fill_size = zlib_uncompress_block(dest_append2, dest_size, source, source_size);
  1203. if(fill_size != dest_size){
  1204. printk(KERN_ERR " zlib uncompress append2 error!\n");
  1205. return fill_size;
  1206. }
  1207. }
  1208. copy_pic_data(dest,dest_append2,IMAGE_TYPE_APPEND2,p->disp_append2_id,SRC_COVER_DST);
  1209. last_id = p->disp_append2_id;
  1210. return fill_size;
  1211. }
  1212. static unsigned int subjoin_track_pic(void *dest)
  1213. {
  1214. static unsigned int last_id = IMAGE_ID_NONE;
  1215. track_context *p = g_ptrack_context;
  1216. void *dest_track = p->disp_track_buf;
  1217. unsigned int dest_size = p->disp_track_size;
  1218. unsigned int fill_size = 0;
  1219. unsigned int source_size;
  1220. unsigned int source_offset;
  1221. void *source;
  1222. if(p->disp_track_id > TRACK_MAX)
  1223. return 0;
  1224. if(first_draw_track)
  1225. last_id = IMAGE_ID_NONE;
  1226. source_offset = get_picture_offset(IMAGE_TYPE_TRACK,p->disp_track_id);
  1227. source_size = get_picture_size(IMAGE_TYPE_TRACK,p->disp_track_id);
  1228. if(source_size == 0 || source_offset < sizeof(user_header)){
  1229. printk(KERN_ERR "subjoin track pic source error, disp_track_id=0x%0x.\n",p->disp_track_id);
  1230. return 0;
  1231. }
  1232. if(last_id == IMAGE_ID_NONE || last_id != p->disp_track_id){
  1233. source = (void*)get_picture_addr(IMAGE_TYPE_TRACK,p->disp_track_id);
  1234. fill_size = zlib_uncompress_block(dest_track, dest_size, source, source_size);
  1235. if(fill_size != dest_size){
  1236. printk(KERN_ERR " zlib uncompress track error!\n");
  1237. return fill_size;
  1238. }
  1239. }
  1240. copy_pic_data(dest,dest_track,IMAGE_TYPE_TRACK,p->disp_track_id,SRC_COVER_DST);
  1241. last_id = p->disp_track_id;
  1242. //printk(KERN_ALERT "p->disp_track_id = %d",p->disp_track_id);
  1243. return fill_size;
  1244. }
  1245. static unsigned int subjoin_radar_pic(void *dest)
  1246. {
  1247. static unsigned int last_id = IMAGE_ID_NONE;
  1248. track_context *p = g_ptrack_context;
  1249. void *dest_radar = p->disp_radar_buf[0];
  1250. unsigned int dest_size = p->disp_radar_size;
  1251. unsigned int mask = 0xff000000;
  1252. unsigned int image_id;
  1253. unsigned char channel;
  1254. unsigned int fill_size = 0;
  1255. unsigned int source_size;
  1256. unsigned int source_offset;
  1257. void *source;
  1258. if(p->disp_radar_id == IMAGE_ID_NONE)
  1259. return 0;
  1260. if(first_draw_track)
  1261. last_id = IMAGE_ID_NONE;
  1262. for(channel = RADAR_CHANNEL_FL; channel <= RADAR_CHANNEL_RR;channel++){
  1263. image_id = p->disp_radar_id & (mask >> 8*channel);
  1264. if(!is_radar_image_id(image_id)){
  1265. printk(KERN_ERR " subjoin radar id channel=%d image_id=0x%0x, error!\n",channel,image_id);
  1266. continue;
  1267. }
  1268. dest_radar = p->disp_radar_buf[channel];
  1269. source_size = get_picture_size(IMAGE_TYPE_RADAR,image_id);
  1270. source_offset = get_picture_offset(IMAGE_TYPE_RADAR,image_id);
  1271. //printk(KERN_ALERT "channel=%d image_id=0x%0x ---> source_offset=%0x ,source_size=%0x \n",channel,image_id,source_offset,source_size );
  1272. if(source_size == 0 || source_offset < sizeof(user_header)){
  1273. printk(KERN_ERR "subjoin radar pic source error,channel=%d image_id=0x%0x.\n",channel,image_id);
  1274. continue;
  1275. }
  1276. if(last_id == IMAGE_ID_NONE || last_id != p->disp_radar_id){
  1277. source = (void*)get_picture_addr(IMAGE_TYPE_RADAR,image_id);
  1278. fill_size = zlib_uncompress_block(dest_radar, dest_size, source, source_size);
  1279. if(fill_size != dest_size){
  1280. printk(KERN_ERR " zlib uncompress radar error!\n");
  1281. return fill_size;
  1282. }
  1283. }
  1284. if(vbox_track_paint){
  1285. copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,SRC_COVER_DST2);//wheel paint
  1286. }else{
  1287. if(channel == RADAR_CHANNEL_RR){
  1288. copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,SRC_COVER_DST);
  1289. //copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,DST_COVER_SRC2);
  1290. }
  1291. else{
  1292. copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,SRC_COVER_DST);
  1293. }
  1294. }
  1295. }
  1296. last_id = p->disp_radar_id;
  1297. return fill_size;
  1298. }
  1299. static unsigned int subjoin_track2_pic(void *dest)
  1300. {
  1301. static unsigned int last_id = IMAGE_ID_NONE;
  1302. track_context *p = g_ptrack_context;
  1303. void *dest_track2 = p->disp_track2_buf;
  1304. unsigned int dest_size = p->disp_track2_size;
  1305. unsigned int fill_size = 0;
  1306. unsigned int source_size;
  1307. unsigned int source_offset;
  1308. void *source;
  1309. if(p->disp_track2_id > TRACK_MAX)
  1310. return 0;
  1311. if(first_draw_track)
  1312. last_id = IMAGE_ID_NONE;
  1313. source_offset = get_picture_offset(IMAGE_TYPE_TRACK2,p->disp_track2_id);
  1314. source_size = get_picture_size(IMAGE_TYPE_TRACK2,p->disp_track2_id);
  1315. if(source_size == 0 || source_offset < sizeof(user_header)){
  1316. printk(KERN_ERR "subjoin track2 pic source error, disp_track2_id=0x%0x.\n",p->disp_track2_id);
  1317. return 0;
  1318. }
  1319. if(last_id == IMAGE_ID_NONE || last_id != p->disp_radar_id){
  1320. source = (void*)get_picture_addr(IMAGE_TYPE_TRACK2,p->disp_track2_id);
  1321. fill_size = zlib_uncompress_block(dest_track2, dest_size, source, source_size);
  1322. if(fill_size != dest_size){
  1323. printk(KERN_ERR " zlib uncompress track2 error!\n");
  1324. return fill_size;
  1325. }
  1326. }
  1327. copy_pic_data(dest,dest_track2,IMAGE_TYPE_TRACK2,p->disp_track2_id,SRC_COVER_DST);
  1328. last_id = p->disp_track2_id;
  1329. return fill_size;
  1330. }
  1331. static unsigned int subjoin_mradar_pic(void *dest)
  1332. {
  1333. static unsigned char last_mradar_id[MRADAR_MAX]={0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF};
  1334. track_context2 *p = g_ptrack_context2;
  1335. void *dest_buf;
  1336. unsigned int dest_size;
  1337. unsigned int fill_size = 0;
  1338. unsigned int source_size;
  1339. unsigned int source_offset;
  1340. void *source;
  1341. int i,item_id;
  1342. if(p == NULL)
  1343. return -1;
  1344. if(first_draw_track) {
  1345. for(i = 0; i < MRADAR_MAX; i++){
  1346. last_mradar_id[i] = 0x0F;
  1347. }
  1348. }
  1349. for(i = 0; i < MRADAR_MAX; i++){
  1350. if(p->disp_mradar_id[i] == 0x0F)
  1351. continue;
  1352. item_id = p->disp_mradar_id[i];
  1353. dest_buf = p->disp_mradar_buf[i];
  1354. dest_size = p->disp_mradar_size[i];
  1355. source_offset = g_pheader2_buf->mradar[i][item_id].image_offset + g_pheader_buf->file_size;
  1356. source_size = g_pheader2_buf->mradar[i][item_id].image_size;
  1357. //printk(KERN_ALERT "mradar[%d][%d]: source_offset=0x%0x ,source_size=0x%0x \n",i,item_id,source_offset,source_size);
  1358. if(source_size == 0 || source_offset < sizeof(user2_header)){
  1359. //printk(KERN_ERR "subjoin mradar pic source error, mradar[%d][%d].\n",i, item_id);
  1360. continue;
  1361. }
  1362. if(last_mradar_id[i] == 0x0F || last_mradar_id[i] != p->disp_mradar_id[i]){
  1363. source =(void*)(g_carback_context->track_data_virtaddr+source_offset);
  1364. fill_size = zlib_uncompress_block(dest_buf, dest_size, source, source_size);
  1365. if(fill_size != dest_size){
  1366. printk(KERN_ERR " zlib uncompress mradar error, fill_size=%0x, dest_size=%0x.\n", fill_size, dest_size);
  1367. return fill_size;
  1368. }
  1369. }
  1370. copy_pic_data(dest, dest_buf, IMAGE_TYPE_MRADAR, i, SRC_COVER_DST2);
  1371. }
  1372. for(i = 0; i < MRADAR_MAX; i++)
  1373. last_mradar_id[i] = p->disp_mradar_id[i];
  1374. p->disp_mradar_id_change = 0;
  1375. return fill_size;
  1376. }
  1377. int track_paint_init(void)
  1378. {
  1379. int ret = 0;
  1380. if(zlib_uncompress_init()){
  1381. printk(KERN_ERR "zlib uncompress init failed!\n" );
  1382. return -1;
  1383. }
  1384. if (*(volatile unsigned int*)g_carback_context->track_data_virtaddr != MKTAG('R', 'S', 'T', 'K')) {
  1385. printk(KERN_ALERT "reservingtrack check failed!\n" );
  1386. return -1;
  1387. }
  1388. if(init_track_context(g_carback_context->track_data_virtaddr) < 0){
  1389. printk(KERN_ERR "init track context failed.\n" );
  1390. return -1;
  1391. }
  1392. if(init_track_context2(g_carback_context->track_data_virtaddr) < 0){
  1393. printk(KERN_ERR "init track context2 failed.\n" );
  1394. g_ptrack_context2 = NULL;
  1395. return -1;
  1396. }
  1397. if(g_carback_context && g_carback_context->screen_width >= g_ptrack_context->disp_width && g_carback_context->screen_height>= g_ptrack_context->disp_height){
  1398. g_carback_context->track_disp_width = g_ptrack_context->disp_width;
  1399. g_carback_context->track_disp_height= g_ptrack_context->disp_height;
  1400. g_carback_context->track_disp_xpos = g_ptrack_context->disp_xpos;
  1401. g_carback_context->track_disp_ypos = g_ptrack_context->disp_ypos;
  1402. g_carback_context->ptrack_param = &g_ptrack_context->track_param;
  1403. g_carback_context->file_type = g_ptrack_context->file_type;
  1404. g_carback_context->pmradar_param = NULL;
  1405. if(g_ptrack_context2)
  1406. g_carback_context->pmradar_param = &g_ptrack_context2->mradar_param;
  1407. printk(KERN_ALERT "++++++track_switch_id = %d",track_switch_id);
  1408. if(track_switch_id == 0){
  1409. set_disp_track_id(TRACK_STRAIGHT_FORWARD_ID);
  1410. set_disp_car_id(CAR_NORMAL_STATUS_ID);
  1411. set_disp_radar_id(RADAR_NORMAL_STATUS_ID);
  1412. set_disp_track2_id(IMAGE_ID_NONE);
  1413. set_disp_signal_id(IMAGE_ID_NONE);
  1414. set_disp_append1_id(APPEND1_NORMAL_STATUS_ID);
  1415. set_disp_append2_id(APPEND2_NORMAL_STATUS_ID);
  1416. }else if(track_switch_id == 1){
  1417. set_disp_track_id(IMAGE_ID_NONE);
  1418. set_disp_car_id(CAR_NORMAL_STATUS_ID);
  1419. set_disp_radar_id(RADAR_NORMAL_STATUS_ID);
  1420. set_disp_track2_id(TRACK2_STRAIGHT_FORWARD_ID);
  1421. set_disp_signal_id(IMAGE_ID_NONE);
  1422. set_disp_append1_id(APPEND1_NORMAL_STATUS_ID);
  1423. set_disp_append2_id(APPEND2_NORMAL_STATUS_ID);
  1424. }else{
  1425. set_disp_track_id(TRACK_STRAIGHT_FORWARD_ID);
  1426. set_disp_car_id(CAR_NORMAL_STATUS_ID);
  1427. set_disp_radar_id(RADAR_NORMAL_STATUS_ID);
  1428. set_disp_track2_id(IMAGE_ID_NONE);
  1429. set_disp_signal_id(IMAGE_ID_NONE);
  1430. set_disp_append1_id(APPEND1_NORMAL_STATUS_ID);
  1431. set_disp_append2_id(APPEND2_NORMAL_STATUS_ID);
  1432. }
  1433. printk("track_paint init width=%d, height=%d,xpos=%d,ypos=%d.\n",g_carback_context->track_disp_width,\
  1434. g_carback_context->track_disp_height,g_carback_context->track_disp_xpos,g_carback_context->track_disp_ypos);
  1435. }
  1436. else{
  1437. printk(KERN_ALERT "track paint init out width or height fail!\n" );
  1438. ret = -1;
  1439. }
  1440. if(vbox_track_paint){
  1441. return ret;
  1442. }
  1443. return ret;
  1444. }
  1445. void track_paint_deinit(void)
  1446. {
  1447. int i;
  1448. zlib_uncompress_exit();
  1449. if(g_ptrack_context->disp_track2_buf)
  1450. vfree(g_ptrack_context->disp_track2_buf);
  1451. for(i = 0; i < 4;i++)
  1452. if(g_ptrack_context->disp_radar_buf[i])
  1453. vfree(g_ptrack_context->disp_radar_buf[i]);
  1454. if(g_ptrack_context->disp_car_buf)
  1455. vfree(g_ptrack_context->disp_car_buf);
  1456. if(g_ptrack_context)
  1457. vfree(g_ptrack_context);
  1458. }
  1459. unsigned int track_paint_fill(void *dest, unsigned int width, unsigned int height)
  1460. {
  1461. unsigned int fill_size, source_size, dest_size, source_offset;
  1462. static unsigned int last_track_id = 0;
  1463. static unsigned int last_car_id = 0;
  1464. static unsigned int last_radar_id = 0;
  1465. static unsigned int last_signal_id = -1;
  1466. static unsigned int last_append1_id = -1;
  1467. static unsigned int last_append2_id = -1;
  1468. static unsigned int last_track2_id= 0;
  1469. track_context *p = g_ptrack_context;
  1470. user_header* ph = g_pheader_buf;
  1471. void *source;
  1472. if(p == NULL || g_carback_context == NULL){
  1473. printk(KERN_ERR "track_paint_fill g_ptrack_context or carback_context null\n" );
  1474. return 0;
  1475. }
  1476. if( width > p->disp_width || height > p->disp_height){
  1477. printk(KERN_ERR "track paint fill width height error!\n" );
  1478. return 0;
  1479. }
  1480. if(p->disp_track_id > TRACK_MAX && p->disp_track_id < IMAGE_ID_NONE)
  1481. return 0;
  1482. if(!g_carback_context->track_setting){
  1483. memset(dest,0,g_carback_context->track_display_size);
  1484. last_track_id = 0;
  1485. last_car_id = 0;
  1486. last_radar_id = 0;
  1487. last_signal_id = -1;
  1488. last_append1_id = -1;
  1489. last_append2_id = -1;
  1490. last_track2_id= 0;
  1491. return g_carback_context->track_display_size;
  1492. }
  1493. if (p->disp_track_id == IMAGE_ID_NONE && p->disp_track2_id == IMAGE_ID_NONE){
  1494. memset(dest,0,p->disp_track_size);
  1495. return p->disp_track_size;
  1496. }
  1497. if( g_carback_context->carback_signal ){
  1498. if(last_track_id == p->disp_track_id && last_car_id == p->disp_car_id &&
  1499. last_radar_id == p->disp_radar_id &&last_track2_id == p->disp_track2_id && last_signal_id == p->disp_signal_id
  1500. && last_append1_id == p->disp_append1_id && last_append2_id == p->disp_append2_id){
  1501. if(g_ptrack_context2 == NULL || !g_ptrack_context2->disp_mradar_id_change)
  1502. return 0;
  1503. }
  1504. }
  1505. if( !g_carback_context->carback_signal ){
  1506. if(last_signal_id != p->disp_signal_id)
  1507. memset(dest,0,g_carback_context->track_display_size);
  1508. if(ph->signal_total)
  1509. subjoin_signal_pic(dest);
  1510. if(ph->append2_total)
  1511. subjoin_append2_pic(dest);
  1512. }else{
  1513. if(!g_carback_context->track_append_setting){
  1514. memset(dest,0,g_carback_context->track_display_size);
  1515. g_carback_context->track_append_setting = 1;
  1516. }
  1517. if(ph->track_total )
  1518. subjoin_track_pic(dest);
  1519. if(ph->car_total)
  1520. subjoin_car_pic(dest);
  1521. if(ph->radar_total)
  1522. subjoin_radar_pic(dest);
  1523. if(ph->append1_total)
  1524. subjoin_append1_pic(dest);
  1525. if(ph->append2_total)
  1526. subjoin_append2_pic(dest);
  1527. if(ph->track2_total)
  1528. subjoin_track2_pic(dest);
  1529. if(g_ptrack_context2 && vbox_track_paint) {
  1530. subjoin_mradar_pic(dest);
  1531. }
  1532. }
  1533. last_track_id = p->disp_track_id;
  1534. last_car_id = p->disp_car_id;
  1535. last_radar_id = p->disp_radar_id;
  1536. last_signal_id = p->disp_signal_id;
  1537. last_append1_id = p->disp_append1_id;
  1538. last_append2_id = p->disp_append2_id;
  1539. last_track2_id= p->disp_track2_id;
  1540. return fill_size;
  1541. }