ark_track.c 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731
  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. track_context *g_ptrack_context;
  218. static user_header* g_pheader_buf;
  219. static z_stream stream;
  220. static int initialized;
  221. unsigned int track_pic_id;
  222. unsigned int radar_pic_id;
  223. unsigned int car_pic_id;
  224. unsigned int track2_pic_id;//small track for vbox
  225. extern struct carback_context* g_carback_context;
  226. extern int first_draw_track;
  227. extern int track_switch_id;
  228. static user2_header* g_pheader2_buf;
  229. track_context2 *g_ptrack_context2 = NULL;
  230. #if 0
  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. #endif
  240. static void show_header_info(void)
  241. {
  242. user_header* p = g_pheader_buf;
  243. if(p == NULL) {
  244. printk(KERN_ERR "header_info_show error!\n");
  245. return;
  246. }
  247. 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",\
  248. 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);
  249. ARKTRACK_DBGPRTK("track rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->track_rect.pos_x,\
  250. p->track_rect.pos_y,p->track_rect.width,p->track_rect.height);
  251. ARKTRACK_DBGPRTK("car rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->car_rect.pos_x,\
  252. p->car_rect.pos_y,p->car_rect.width,p->car_rect.height);
  253. ARKTRACK_DBGPRTK("signal rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->signal_rect.pos_x,\
  254. p->signal_rect.pos_y,p->signal_rect.width,p->signal_rect.height);
  255. ARKTRACK_DBGPRTK("append1 rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->append1_rect.pos_x,\
  256. p->append1_rect.pos_y,p->append1_rect.width,p->append1_rect.height);
  257. ARKTRACK_DBGPRTK("append2 rect ===> pos_x=%d pos_y=%d width=%d height=%d\n",p->append2_rect.pos_x,\
  258. p->append2_rect.pos_y,p->append2_rect.width,p->append2_rect.height);
  259. ARKTRACK_DBGPRTK("radar0 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[0].pos_x,\
  260. p->radar_rect[0].pos_y,p->radar_rect[0].width,p->radar_rect[0].height);
  261. ARKTRACK_DBGPRTK("radar1 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[1].pos_x,\
  262. p->radar_rect[1].pos_y,p->radar_rect[1].width,p->radar_rect[1].height);
  263. ARKTRACK_DBGPRTK("radar2 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[2].pos_x,\
  264. p->radar_rect[2].pos_y,p->radar_rect[2].width,p->radar_rect[2].height);
  265. ARKTRACK_DBGPRTK("radar3 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->radar_rect[3].pos_x,\
  266. p->radar_rect[3].pos_y,p->radar_rect[3].width,p->radar_rect[3].height);
  267. ARKTRACK_DBGPRTK("track2 rect===> pos_x=%d pos_y=%d width=%d height=%d\n",p->track2_rect.pos_x,\
  268. p->track2_rect.pos_y,p->track2_rect.width,p->track2_rect.height);
  269. 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",\
  270. 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);
  271. 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",\
  272. 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);
  273. 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",\
  274. 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);
  275. 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",\
  276. 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);
  277. 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",\
  278. 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);
  279. 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",\
  280. 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);
  281. 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",\
  282. 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);
  283. }
  284. static int check_header_info(void)
  285. {
  286. int i;
  287. int fail = -1;
  288. user_header* p = g_pheader_buf;
  289. //check header info
  290. if(p->identity !=ARK_IDENTITY || p->track_total == 0 || p->file_size <= sizeof(user_header)){
  291. printk(KERN_ERR "identity info error!\n");
  292. return fail;
  293. }
  294. if(p->track_rect.width > g_carback_context->screen_width || p->track_rect.width == 0){
  295. printk(KERN_ERR "track rect width error!\n");
  296. return fail;
  297. }
  298. if(p->track_rect.height > g_carback_context->screen_height || p->track_rect.height == 0){
  299. printk(KERN_ERR "track rect height error!\n");
  300. return fail;
  301. }
  302. for(i = 0;i < TRACK_MAX; i++){
  303. if(TRACK_MAX < p->track[i].image_store_id){
  304. printk(KERN_ERR "track[%d].image_store_id error!\n",i);
  305. return fail;
  306. }
  307. }
  308. for(i = 0;i < CAR_MAX; i++){
  309. if(CAR_MAX < p->car[i].image_store_id){
  310. printk(KERN_ERR "track[%d].image_store_id error!\n",i);
  311. return fail;
  312. }
  313. }
  314. for(i = 0;i < p->radar_total; i++){
  315. if(RADAR_MAX < p->radar[i].image_store_id){
  316. printk(KERN_ERR "track[%d].image_store_id error!\n",i);
  317. return fail;
  318. }
  319. }
  320. for(i = 0;i < TRACK_MAX; i++){
  321. if(TRACK_MAX < p->track2[i].image_store_id){
  322. printk(KERN_ERR "track2[%d].image_store_id error!\n",i);
  323. return fail;
  324. }
  325. }
  326. return 0;
  327. }
  328. static bool is_radar_image_id(unsigned int image_id){
  329. int i;
  330. for(i = 0;i < RADAR_MAX; i++){
  331. if(radar_idmap[i].image_id == image_id){
  332. return true;
  333. }
  334. }
  335. return false;
  336. }
  337. int set_disp_track_id(unsigned int track_id)
  338. {
  339. static unsigned int pre_id = IMAGE_ID_NONE;
  340. track_context *p = g_ptrack_context;
  341. if(p == NULL){
  342. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  343. return -1;
  344. }
  345. if(track_id >= TRACK_MAX && track_id < IMAGE_ID_NONE){
  346. printk(KERN_ERR "set disp track image id error!\n" );
  347. return -1;
  348. }
  349. if(pre_id != track_id || IMAGE_ID_NONE == track_id){
  350. p->disp_track_id = track_id;
  351. pre_id = track_id;
  352. }
  353. return 0;
  354. }
  355. int set_disp_car_id(unsigned int car_id)
  356. {
  357. static unsigned int pre_id = IMAGE_ID_NONE;
  358. track_context *p = g_ptrack_context;
  359. if(p == NULL){
  360. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  361. return -1;
  362. }
  363. if(car_id >= CAR_MAX && car_id < IMAGE_ID_NONE){
  364. printk(KERN_ERR "set disp car image id error!\n" );
  365. return -1;
  366. }
  367. if(pre_id != car_id || IMAGE_ID_NONE == car_id){
  368. p->disp_car_id = car_id;
  369. pre_id = car_id;
  370. }
  371. return 0;
  372. }
  373. int set_disp_radar_id(unsigned int radar_id)
  374. {
  375. static unsigned int pre_id = IMAGE_ID_NONE;
  376. track_context *p = g_ptrack_context;
  377. unsigned int image_id;
  378. unsigned char channel;
  379. unsigned int mask = 0xff000000;
  380. unsigned int disp_id = 0;
  381. if(p == NULL){
  382. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  383. return -1;
  384. }
  385. if(IMAGE_ID_NONE == radar_id){
  386. p->disp_radar_id = IMAGE_ID_NONE;
  387. pre_id = IMAGE_ID_NONE;
  388. return 0;
  389. }
  390. if(pre_id == radar_id){
  391. return 0;
  392. }
  393. for(channel = RADAR_CHANNEL_FL; channel <= RADAR_CHANNEL_RR;channel++){
  394. image_id = radar_id & (mask >> 8*channel);
  395. if(!is_radar_image_id(image_id)){
  396. printk(KERN_ERR "set disp radar id channel=%d ,error!\n",channel);
  397. continue;
  398. }
  399. disp_id |= image_id;
  400. }
  401. p->disp_radar_id = disp_id;
  402. pre_id = disp_id;
  403. //printk(KERN_ALERT "set disp radar id disp_id=0x%0x.\n",disp_id);
  404. return 0;
  405. }
  406. int set_disp_signal_id(unsigned int disp_signal_id)
  407. {
  408. static unsigned int pre_id = IMAGE_ID_NONE;
  409. track_context *p = g_ptrack_context;
  410. if(p == NULL){
  411. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  412. return -1;
  413. }
  414. if(disp_signal_id >= SIGNAL_MAX && disp_signal_id < IMAGE_ID_NONE){
  415. printk(KERN_ERR "set disp signal image id error!\n" );
  416. return -1;
  417. }
  418. if(pre_id != disp_signal_id || IMAGE_ID_NONE == disp_signal_id){
  419. p->disp_signal_id = disp_signal_id;
  420. pre_id = disp_signal_id;
  421. }
  422. //printk(KERN_ALERT "++++++p->disp_signal_id = %d\n" ,p->disp_signal_id);
  423. return 0;
  424. }
  425. int set_disp_append1_id(unsigned int disp_append1_id)
  426. {
  427. static unsigned int pre_id = IMAGE_ID_NONE;
  428. track_context *p = g_ptrack_context;
  429. if(p == NULL){
  430. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  431. return -1;
  432. }
  433. if(disp_append1_id >= APPEND1_MAX && disp_append1_id < IMAGE_ID_NONE){
  434. printk(KERN_ERR "set_disp_append1_id image id error!\n" );
  435. return -1;
  436. }
  437. if(pre_id != disp_append1_id || IMAGE_ID_NONE == disp_append1_id){
  438. p->disp_append1_id = disp_append1_id;
  439. pre_id = disp_append1_id;
  440. }
  441. //printk(KERN_ALERT "++++++p->disp_append1_id = %d\n" ,p->disp_append1_id);
  442. return 0;
  443. }
  444. int set_disp_append2_id(unsigned int disp_append2_id)
  445. {
  446. static unsigned int pre_id = IMAGE_ID_NONE;
  447. track_context *p = g_ptrack_context;
  448. if(p == NULL){
  449. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  450. return -1;
  451. }
  452. if(disp_append2_id >= APPEND2_MAX && disp_append2_id < IMAGE_ID_NONE){
  453. printk(KERN_ERR "set_disp_append2_id image id error!\n" );
  454. return -1;
  455. }
  456. if(pre_id != disp_append2_id || IMAGE_ID_NONE == disp_append2_id){
  457. p->disp_append2_id = disp_append2_id;
  458. pre_id = disp_append2_id;
  459. }
  460. //printk(KERN_ALERT "++++++p->disp_append2_id = %d\n" ,p->disp_append2_id);
  461. return 0;
  462. }
  463. int set_disp_track2_id(unsigned int track2_id)
  464. {
  465. static unsigned int pre_id = IMAGE_ID_NONE;
  466. track_context *p = g_ptrack_context;
  467. if(p == NULL){
  468. printk(KERN_ALERT "%s: g_ptrack_context NULL, error!\n", __FUNCTION__);
  469. return -1;
  470. }
  471. if(track2_id >= TRACK_MAX && track2_id < IMAGE_ID_NONE){
  472. printk(KERN_ERR "set disp track2 image id error!\n" );
  473. return -1;
  474. }
  475. if(pre_id != track2_id || IMAGE_ID_NONE == track2_id){
  476. p->disp_track2_id = track2_id;
  477. pre_id = track2_id;
  478. }
  479. return 0;
  480. }
  481. /*
  482. *set_disp_mradar_id: radar new solution
  483. *
  484. *-------------------------front-----------------------
  485. *
  486. * mradar0 mradar1 mradar2 mradar3
  487. * +-----------------+
  488. * | |
  489. * | |
  490. * mradar8 | | mradar12
  491. * | |
  492. * mradar9 | | mradar13
  493. * | |
  494. * mradar10| | mradar14
  495. * | |
  496. * mradar11| | mradar15
  497. * | |
  498. * | |
  499. * +-----------------+
  500. * mradar4 mradar5 mradar6 mradar7
  501. *
  502. *-------------------------rear-----------------------
  503. */
  504. int set_disp_mradar_id(unsigned char *pimage_id)
  505. {
  506. static unsigned char pre_mradar_id[MRADAR_MAX]={0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF};
  507. unsigned char mradar_id[MRADAR_MAX];
  508. track_context2 *p = g_ptrack_context2;
  509. int i;
  510. if(p == NULL){
  511. //printk(KERN_ALERT "%s: no header2 ,set mradar id invalid!\n", __FUNCTION__);
  512. return 0;
  513. }
  514. memcpy(mradar_id, pimage_id, MRADAR_MAX);
  515. for(i = 0; i < MRADAR_MAX; i++){
  516. ARKTRACK_DBGPRTK("mradar_id[%d]=%d\n", i, mradar_id[i]);
  517. if(mradar_id[i] > 0xF){
  518. printk(KERN_ALERT "%s: mradar_id[%d]=%d, MRADAR_MAX=0xF, error.\n", __FUNCTION__, i, mradar_id[i]);
  519. return -1;
  520. }
  521. }
  522. for(i = 0; i < MRADAR_MAX; i++){
  523. if(pre_mradar_id[i] != mradar_id[i]){
  524. break;
  525. }
  526. }
  527. if(i < MRADAR_MAX){
  528. memcpy(p->disp_mradar_id, mradar_id, MRADAR_MAX);
  529. memcpy(pre_mradar_id, mradar_id, MRADAR_MAX);
  530. p->disp_mradar_id_change = 1;
  531. }
  532. return 0;
  533. }
  534. static int init_track_context(unsigned int addr)
  535. {
  536. int ret = -1;
  537. int size;
  538. int i;
  539. unsigned char *p;
  540. //printk(KERN_ALERT "init_track_context ...\n");
  541. if(addr == 0){
  542. printk(KERN_ERR "addr error!\n");
  543. return ret;
  544. }
  545. g_pheader_buf = (user_header*)addr;
  546. show_header_info();
  547. if(check_header_info() < 0){
  548. printk(KERN_ERR "identity info error!\n");
  549. return ret;
  550. }
  551. p = vzalloc(sizeof(track_context));
  552. if (p == NULL) {
  553. printk(KERN_ERR "%s %d: failed to allocate track_context\n",__FUNCTION__, __LINE__);
  554. return -ENOMEM;
  555. }
  556. g_ptrack_context = (track_context *)p;
  557. g_ptrack_context->disp_track_size = 4 * g_pheader_buf->track_rect.width * g_pheader_buf->track_rect.height;
  558. if(g_pheader_buf->track_total > 0){
  559. size = 4* g_pheader_buf->track_rect.width * g_pheader_buf->track_rect.height;
  560. p = vzalloc(size);
  561. if (p == NULL) {
  562. printk(KERN_ERR "%s %d: failed to allocate track\n",__FUNCTION__, __LINE__);
  563. ret = -ENOMEM;
  564. goto err_track2;
  565. }
  566. g_ptrack_context->disp_track_buf = p;
  567. g_ptrack_context->disp_track_size= size;
  568. }
  569. if(g_pheader_buf->car_total > 0){
  570. size = 4* g_pheader_buf->car_rect.width * g_pheader_buf->car_rect.height;
  571. p = vzalloc(size);
  572. if (p == NULL) {
  573. printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
  574. ret = -ENOMEM;
  575. goto err_car;
  576. }
  577. g_ptrack_context->disp_car_buf = p;
  578. g_ptrack_context->disp_car_size= size;
  579. }
  580. if(g_pheader_buf->signal_total> 0){
  581. size = 4* g_pheader_buf->signal_rect.width * g_pheader_buf->signal_rect.height;
  582. p = vzalloc(size);
  583. if (p == NULL) {
  584. printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
  585. ret = -ENOMEM;
  586. goto err_car;
  587. }
  588. g_ptrack_context->disp_signal_buf = p;
  589. g_ptrack_context->disp_signal_size= size;
  590. }
  591. if(g_pheader_buf->append1_total> 0){
  592. size = 4* g_pheader_buf->append1_rect.width * g_pheader_buf->append1_rect.height;
  593. p = vzalloc(size);
  594. if (p == NULL) {
  595. printk(KERN_ERR "%s %d: failed to allocate car\n",__FUNCTION__, __LINE__);
  596. ret = -ENOMEM;
  597. goto err_car;
  598. }
  599. g_ptrack_context->disp_append1_buf = p;
  600. g_ptrack_context->disp_append1_size= size;
  601. }
  602. if(g_pheader_buf->append2_total> 0){
  603. size = 4* g_pheader_buf->append2_rect.width * g_pheader_buf->append2_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_append2_buf = p;
  611. g_ptrack_context->disp_append2_size= size;
  612. }
  613. if(g_pheader_buf->radar_total > 0){
  614. size = 4* g_pheader_buf->radar_rect[0].width * g_pheader_buf->radar_rect[0].height;
  615. for(i = 0; i < 4;i++){
  616. p = vzalloc(size);
  617. if (p == NULL) {
  618. printk(KERN_ERR "%s %d: failed to allocate radar\n",__FUNCTION__, __LINE__);
  619. ret = -ENOMEM;
  620. while(i-- >= 0){
  621. vfree(g_ptrack_context->disp_radar_buf[i]);
  622. }
  623. goto err_radar;
  624. }
  625. g_ptrack_context->disp_radar_buf[i] = p;
  626. g_ptrack_context->disp_radar_size = size;
  627. }
  628. }
  629. if(g_pheader_buf->track2_total > 0){
  630. size = 4* g_pheader_buf->track2_rect.width * g_pheader_buf->track2_rect.height;
  631. p = vzalloc(size);
  632. if (p == NULL) {
  633. printk(KERN_ERR "%s %d: failed to allocate track2\n",__FUNCTION__, __LINE__);
  634. ret = -ENOMEM;
  635. goto err_track2;
  636. }
  637. g_ptrack_context->disp_track2_buf = p;
  638. g_ptrack_context->disp_track2_size= size;
  639. }
  640. g_ptrack_context->pheader_buf = g_pheader_buf;
  641. g_ptrack_context->disp_xpos = g_pheader_buf->track_rect.pos_x;
  642. g_ptrack_context->disp_ypos = g_pheader_buf->track_rect.pos_y;
  643. g_ptrack_context->disp_width = g_carback_context->screen_width;
  644. g_ptrack_context->disp_height = g_carback_context->screen_height;
  645. memcpy(&g_ptrack_context->track_param,&g_pheader_buf->track_rect,sizeof(track_param_context));
  646. g_ptrack_context->file_type = g_pheader_buf->file_type;
  647. g_ptrack_context->disp_track_id = IMAGE_ID_NONE;
  648. g_ptrack_context->disp_car_id = IMAGE_ID_NONE;
  649. g_ptrack_context->disp_radar_id = IMAGE_ID_NONE;
  650. g_ptrack_context->disp_track2_id= IMAGE_ID_NONE;
  651. return 0;
  652. err_track2:
  653. for(i = 0; i < 4;i++)
  654. if(g_ptrack_context->disp_radar_buf[i])
  655. vfree(g_ptrack_context->disp_radar_buf[i]);
  656. err_radar:
  657. if(g_ptrack_context->disp_car_buf)
  658. vfree(g_ptrack_context->disp_car_buf);
  659. err_car:
  660. if(g_ptrack_context)
  661. vfree(g_ptrack_context);
  662. return ret;
  663. }
  664. static void show_header2_info(void)
  665. {
  666. user2_header* p = g_pheader2_buf;
  667. rect_info *prect;
  668. item_info *pitem;
  669. int i;
  670. if(p == NULL) {
  671. printk(KERN_ERR "header_info_show error!\n");
  672. return;
  673. }
  674. ARKTRACK_DBGPRTK("header2_buf ===>identity=0x%0x,file_type=0x%0x file_size=0x%0x\n", p->identity,p->file_type,p->file_size);
  675. for(i = 0; i < MRADAR_MAX; i++){
  676. prect = &p->mradar_rect[i];
  677. pitem = &p->mradar[i][0];
  678. ARKTRACK_DBGPRTK("mradar_rect[%d]===>total=%d, pos_x=%d pos_y=%d width=%d height=%d\n",\
  679. i, p->mradar_total[i], prect->pos_x, prect->pos_y, prect->width, prect->height);
  680. 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",\
  681. i, pitem->image_type, pitem->image_store_id, pitem->image_id, pitem->image_offset, pitem->image_size);
  682. }
  683. }
  684. static int check_header2_info(void)
  685. {
  686. int i, j;
  687. user2_header* p = g_pheader2_buf;
  688. if(p == NULL) {
  689. printk(KERN_ERR "check_header2_info error!\n");
  690. return -1;
  691. }
  692. //check header info
  693. if(p->identity != ARK_IDENTITY || p->file_size <= sizeof(user2_header)){
  694. printk(KERN_ERR "header2 identity info error!\n");
  695. return -1;
  696. }
  697. for(j = 0 ;j < MRADAR_MAX; j++){
  698. for(i = 0;i < MRADAR_ITEM_MAX; i++){
  699. if(MRADAR_MAX < p->mradar[j][i].image_id){
  700. printk(KERN_ALERT "track[%d].image_id error!\n",i);
  701. return -1;
  702. }
  703. }
  704. }
  705. printk(KERN_ALERT "check_header2_info success!\n");
  706. return 0;
  707. }
  708. static int init_track_context2(unsigned int addr)
  709. {
  710. unsigned int header2_addr_start;
  711. unsigned char *p;
  712. int ret = -1;
  713. int size;
  714. int i;
  715. //printk(KERN_ALERT "file_type=%0x ---> HEADER2_FILE_FLAG=%0x.\n", g_pheader_buf->file_type, HEADER2_FILE_FLAG);
  716. if((g_pheader_buf->file_type & 0x80000000) != HEADER2_FILE_FLAG){
  717. printk(KERN_ALERT "only header file.\n");
  718. return 0;
  719. }
  720. printk(KERN_ALERT "%s: start.\n", __func__);
  721. if(addr == 0){
  722. printk(KERN_ERR "addr error!\n");
  723. return -1;
  724. }
  725. //g_pheader2_buf = (user2_header*)(addr + g_pheader_buf->file_size);
  726. p = vzalloc(sizeof(user2_header));
  727. if (p == NULL) {
  728. printk(KERN_ERR "%s: failed to user2_header.\n",__FUNCTION__);
  729. return -1;
  730. }
  731. header2_addr_start = addr + g_pheader_buf->file_size;
  732. printk(KERN_ALERT "header2_addr_start=0x%0x.\n", header2_addr_start);
  733. memcpy(p, (void *)header2_addr_start, sizeof(user2_header));
  734. g_pheader2_buf = (user2_header*)p;
  735. show_header2_info();
  736. if(check_header2_info() < 0){
  737. printk(KERN_ALERT "check_header2_info failed!\n");
  738. return -1;
  739. }
  740. p = vzalloc(sizeof(track_context2));
  741. if (p == NULL) {
  742. printk(KERN_ERR "%s %d: failed to allocate track_context2\n",__FUNCTION__, __LINE__);
  743. return -1;
  744. }
  745. memset(p, 0 ,sizeof(track_context2));
  746. g_ptrack_context2 = (track_context2 *)p;
  747. g_ptrack_context2->pheader2_buf = g_pheader2_buf;
  748. g_ptrack_context2->file_type = g_pheader2_buf->file_type;
  749. memset(g_ptrack_context2->disp_mradar_id, 0x0F ,MRADAR_MAX);
  750. for(i = 0; i < MRADAR_MAX; i++){
  751. size = 4* g_pheader2_buf->mradar_rect[i].width * g_pheader2_buf->mradar_rect[i].height;
  752. p = vzalloc(size);
  753. if (p == NULL) {
  754. printk(KERN_ERR "%s %d: failed to allocate radar\n",__FUNCTION__, __LINE__);
  755. ret = -ENOMEM;
  756. while(i-- >= 0){
  757. vfree(g_ptrack_context2->disp_mradar_buf[i]);
  758. }
  759. vfree(g_pheader2_buf);
  760. return -1;
  761. }
  762. g_ptrack_context2->disp_mradar_buf[i] = p;
  763. g_ptrack_context2->disp_mradar_size[i]= size;
  764. memcpy(&g_ptrack_context2->mradar_param.mradar_rect[i], &g_pheader2_buf->mradar_rect[i], sizeof(rect_info));
  765. ARKTRACK_DBGPRTK("mradar_buf[%d]=0x%0x, size=0x%0x \n",i, p, size);
  766. }
  767. printk(KERN_ALERT "%s: success.\n", __func__);
  768. return 0;
  769. }
  770. static int get_radar_channel(unsigned int image_id){
  771. int i;
  772. int channel = -1;
  773. for(i = 0;i < RADAR_MAX; i++){
  774. if(radar_idmap[i].image_id == image_id){
  775. channel = radar_idmap[i].dis_channel;
  776. break;
  777. }
  778. }
  779. return channel;
  780. }
  781. static unsigned int get_picture_addr(enum image_type type, unsigned int id)
  782. {
  783. unsigned int offset;
  784. int i;
  785. if(type == IMAGE_TYPE_TRACK){
  786. offset = g_pheader_buf->track[id].image_offset;
  787. }
  788. else if(type == IMAGE_TYPE_CAR){
  789. offset = g_pheader_buf->car[id].image_offset;
  790. }
  791. else if(type == IMAGE_TYPE_SIGNAL){
  792. offset = g_pheader_buf->signal[id].image_offset;
  793. }
  794. else if(type == IMAGE_TYPE_APPEND1){
  795. offset = g_pheader_buf->append1[id].image_offset;
  796. }
  797. else if(type == IMAGE_TYPE_APPEND2){
  798. offset = g_pheader_buf->append2[id].image_offset;
  799. }
  800. else if(type == IMAGE_TYPE_RADAR){
  801. for(i = 0; i < RADAR_MAX;i++){
  802. if(g_pheader_buf->radar[i].image_id == id){
  803. offset = g_pheader_buf->radar[i].image_offset;
  804. break;
  805. }
  806. }
  807. }
  808. else if(type == IMAGE_TYPE_TRACK2){
  809. offset = g_pheader_buf->track2[id].image_offset;
  810. }
  811. return g_carback_context->track_data_virtaddr +offset;
  812. }
  813. static unsigned int get_picture_offset(enum image_type type, unsigned int id)
  814. {
  815. unsigned int offset = 0;
  816. int i;
  817. if(type == IMAGE_TYPE_TRACK){
  818. offset = g_pheader_buf->track[id].image_offset;
  819. }
  820. else if(type == IMAGE_TYPE_CAR){
  821. offset = g_pheader_buf->car[id].image_offset;
  822. }
  823. else if(type == IMAGE_TYPE_SIGNAL){
  824. offset = g_pheader_buf->signal[id].image_offset;
  825. }
  826. else if(type == IMAGE_TYPE_APPEND1){
  827. offset = g_pheader_buf->append1[id].image_offset;
  828. }
  829. else if(type == IMAGE_TYPE_APPEND2){
  830. offset = g_pheader_buf->append2[id].image_offset;
  831. }
  832. else if(type == IMAGE_TYPE_RADAR){
  833. for(i = 0; i < RADAR_MAX;i++){
  834. if(g_pheader_buf->radar[i].image_id == id){
  835. offset = g_pheader_buf->radar[i].image_offset;
  836. break;
  837. }
  838. }
  839. }
  840. else if(type == IMAGE_TYPE_TRACK2){
  841. offset = g_pheader_buf->track2[id].image_offset;
  842. }
  843. return offset;
  844. }
  845. static unsigned int get_picture_size(enum image_type type, unsigned int id)
  846. {
  847. unsigned int image_size = 0;
  848. int i;
  849. if(type == IMAGE_TYPE_TRACK){
  850. image_size = g_pheader_buf->track[id].image_size;
  851. }
  852. else if(type == IMAGE_TYPE_CAR){
  853. image_size = g_pheader_buf->car[id].image_size;
  854. }
  855. else if(type == IMAGE_TYPE_SIGNAL){
  856. image_size = g_pheader_buf->signal[id].image_size;
  857. }
  858. else if(type == IMAGE_TYPE_APPEND1){
  859. image_size = g_pheader_buf->append1[id].image_size;
  860. }
  861. else if(type == IMAGE_TYPE_APPEND2){
  862. image_size = g_pheader_buf->append2[id].image_size;
  863. }
  864. else if(type == IMAGE_TYPE_RADAR){
  865. for(i = 0; i < RADAR_MAX;i++){
  866. if(g_pheader_buf->radar[i].image_id == id){
  867. image_size = g_pheader_buf->radar[i].image_size;
  868. break;
  869. }
  870. }
  871. }
  872. else if(type == IMAGE_TYPE_TRACK2){
  873. image_size = g_pheader_buf->track2[id].image_size;
  874. }
  875. return image_size;
  876. }
  877. /* Returns length of decompressed data. */
  878. static int zlib_uncompress_block(void *dst, int dstlen, void *src, int srclen)
  879. {
  880. int err;
  881. stream.next_in = src;
  882. stream.avail_in = srclen;
  883. stream.next_out = dst;
  884. stream.avail_out = dstlen;
  885. err = zlib_inflateReset(&stream);
  886. if (err != Z_OK) {
  887. printk("zlib_inflateReset error %d\n", err);
  888. zlib_inflateEnd(&stream);
  889. zlib_inflateInit(&stream);
  890. }
  891. err = zlib_inflate(&stream, Z_FINISH);
  892. if (err != Z_STREAM_END)
  893. goto err;
  894. return stream.total_out;
  895. err:
  896. printk(KERN_ERR "Error %d while decompressing!\n", err);
  897. printk(KERN_ERR "%p(%d)->%p(%d)\n", src, srclen, dst, dstlen);
  898. return -EIO;
  899. }
  900. static int zlib_uncompress_init(void)
  901. {
  902. if (!initialized++) {
  903. stream.workspace = vmalloc(zlib_inflate_workspacesize());
  904. if ( !stream.workspace ) {
  905. initialized = 0;
  906. return -ENOMEM;
  907. }
  908. stream.next_in = NULL;
  909. stream.avail_in = 0;
  910. zlib_inflateInit(&stream);
  911. }
  912. return 0;
  913. }
  914. static void zlib_uncompress_exit(void)
  915. {
  916. if (!--initialized) {
  917. zlib_inflateEnd(&stream);
  918. vfree(stream.workspace);
  919. }
  920. }
  921. static void copy_line_data(unsigned int *dest,unsigned int *src,unsigned int width,enum cover_type cover)
  922. {
  923. unsigned int i;
  924. unsigned int* psrc = (unsigned int*)src;
  925. unsigned int* pdest = (unsigned int*)dest;
  926. if(cover == SRC_COVER_DST){
  927. memcpy(pdest,psrc,width*PIXEL_DATA_SIZE);
  928. }else if(cover == DST_COVER_SRC2){
  929. for(i = 0;i < width;i++){
  930. if(*pdest == PIXEL_DATA_NONE || *pdest == PIXEL_DATA_ZERO)
  931. *pdest = *psrc;
  932. psrc++;
  933. pdest++;
  934. }
  935. }
  936. else if(cover == SRC_COVER_DST2){
  937. for(i = 0;i < width;i++){
  938. if(*psrc == 0xFFFFFFFF || *psrc == PIXEL_DATA_NONE || *psrc == PIXEL_DATA_ZERO){
  939. psrc++;
  940. pdest++;
  941. continue;
  942. }
  943. *pdest = *psrc;
  944. psrc++;
  945. pdest++;
  946. }
  947. }
  948. }
  949. static int copy_pic_data(void *dest,void *src,enum image_type type,unsigned int id,enum cover_type cover)
  950. {
  951. unsigned int width;
  952. unsigned int height;
  953. unsigned int pos_x;
  954. unsigned int pos_y;
  955. track_param_context* p = &g_ptrack_context->track_param;
  956. unsigned int* dest_tmp;
  957. unsigned int* src_tmp;
  958. int radar_channel;
  959. int i;
  960. if(dest == NULL || src == NULL){
  961. printk(KERN_ERR "paint car dest src error!\n");
  962. return -1;
  963. }
  964. if(type == IMAGE_TYPE_TRACK){
  965. width = p->track_rect.width;
  966. height= p->track_rect.height;
  967. pos_x = p->track_rect.pos_x;
  968. pos_y = p->track_rect.pos_y;
  969. }
  970. else if(type == IMAGE_TYPE_CAR){
  971. width = p->car_rect.width;
  972. height= p->car_rect.height;
  973. pos_x = p->car_rect.pos_x;
  974. pos_y = p->car_rect.pos_y;
  975. }
  976. else if(type == IMAGE_TYPE_RADAR){
  977. radar_channel = get_radar_channel(id);
  978. if(radar_channel < 0){
  979. printk(KERN_ERR "get radar_channel error!\n");
  980. return -1;
  981. }
  982. width = p->radar_rect[radar_channel].width;
  983. height= p->radar_rect[radar_channel].height;
  984. pos_x = p->radar_rect[radar_channel].pos_x;
  985. pos_y = p->radar_rect[radar_channel].pos_y;
  986. }
  987. else if(type == IMAGE_TYPE_SIGNAL){
  988. width = p->signal_rect.width;
  989. height= p->signal_rect.height;
  990. pos_x = p->signal_rect.pos_x;
  991. pos_y = p->signal_rect.pos_y;
  992. }
  993. else if(type == IMAGE_TYPE_APPEND1){
  994. width = p->append1_rect.width;
  995. height= p->append1_rect.height;
  996. pos_x = p->append1_rect.pos_x;
  997. pos_y = p->append1_rect.pos_y;
  998. }
  999. else if(type == IMAGE_TYPE_APPEND2){
  1000. width = p->append2_rect.width;
  1001. height= p->append2_rect.height;
  1002. pos_x = p->append2_rect.pos_x;
  1003. pos_y = p->append2_rect.pos_y;
  1004. }
  1005. else if(type == IMAGE_TYPE_TRACK2){
  1006. width = p->track2_rect.width;
  1007. height= p->track2_rect.height;
  1008. pos_x = p->track2_rect.pos_x;
  1009. pos_y = p->track2_rect.pos_y;
  1010. }
  1011. else if(type == IMAGE_TYPE_MRADAR){
  1012. mradar_param_context* p2 = &g_ptrack_context2->mradar_param;
  1013. width = p2->mradar_rect[id].width;
  1014. height= p2->mradar_rect[id].height;
  1015. pos_x = p2->mradar_rect[id].pos_x;
  1016. pos_y = p2->mradar_rect[id].pos_y;
  1017. }
  1018. else{
  1019. printk(KERN_ERR "paint car type error!\n");
  1020. return -1;
  1021. }
  1022. for(i = 0; i < height;i++){
  1023. dest_tmp = dest + g_ptrack_context->disp_width * (pos_y + i) * PIXEL_DATA_SIZE + pos_x * PIXEL_DATA_SIZE;
  1024. src_tmp = src + i * width * PIXEL_DATA_SIZE;
  1025. copy_line_data(dest_tmp,src_tmp,width,cover);
  1026. }
  1027. return 0;
  1028. }
  1029. static unsigned int subjoin_car_pic(void *dest)
  1030. {
  1031. static unsigned int last_id = IMAGE_ID_NONE;
  1032. track_context *p = g_ptrack_context;
  1033. void *dest_car = p->disp_car_buf;
  1034. unsigned int dest_size = p->disp_car_size;
  1035. unsigned int fill_size = 0;
  1036. unsigned int source_size;
  1037. unsigned int source_offset;
  1038. void *source;
  1039. if(p->disp_car_id > CAR_MAX)
  1040. return 0;
  1041. if(first_draw_track)
  1042. last_id = IMAGE_ID_NONE;
  1043. source_offset = get_picture_offset(IMAGE_TYPE_CAR,p->disp_car_id);
  1044. source_size = get_picture_size(IMAGE_TYPE_CAR,p->disp_car_id);
  1045. //printk(KERN_ALERT "source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
  1046. if(source_size == 0 || source_offset < sizeof(user_header)){
  1047. printk(KERN_ERR "subjoin car pic source error, disp_car_id=0x%0x.\n",p->disp_car_id);
  1048. return 0;
  1049. }
  1050. if(last_id == IMAGE_ID_NONE || last_id != p->disp_car_id){
  1051. source = (void*)get_picture_addr(IMAGE_TYPE_CAR,p->disp_car_id);
  1052. fill_size = zlib_uncompress_block(dest_car, dest_size, source, source_size);
  1053. if(fill_size != dest_size){
  1054. printk(KERN_ERR " zlib uncompress car error!\n");
  1055. return fill_size;
  1056. }
  1057. }
  1058. copy_pic_data(dest,dest_car,IMAGE_TYPE_CAR,p->disp_car_id,SRC_COVER_DST);
  1059. last_id = p->disp_car_id;
  1060. return fill_size;
  1061. }
  1062. static unsigned int subjoin_signal_pic(void *dest)
  1063. {
  1064. static unsigned int last_id = IMAGE_ID_NONE;
  1065. track_context *p = g_ptrack_context;
  1066. void *dest_signal = p->disp_signal_buf;
  1067. unsigned int dest_size = p->disp_signal_size;
  1068. unsigned int fill_size = 0;
  1069. unsigned int source_size;
  1070. unsigned int source_offset;
  1071. void *source;
  1072. if(p->disp_signal_id > SIGNAL_MAX)
  1073. return 0;
  1074. if(first_draw_track)
  1075. last_id = IMAGE_ID_NONE;
  1076. source_offset = get_picture_offset(IMAGE_TYPE_SIGNAL,p->disp_signal_id);
  1077. source_size = get_picture_size(IMAGE_TYPE_SIGNAL,p->disp_signal_id);
  1078. //printk(KERN_ALERT "~~~~~~source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
  1079. if(source_size == 0 || source_offset < sizeof(user_header)){
  1080. printk(KERN_ERR "subjoin signal pic source error, disp_signal_id=0x%0x.\n",p->disp_signal_id);
  1081. return 0;
  1082. }
  1083. if(last_id == IMAGE_ID_NONE || last_id != p->disp_signal_id){
  1084. source = (void*)get_picture_addr(IMAGE_TYPE_SIGNAL,p->disp_signal_id);
  1085. fill_size = zlib_uncompress_block(dest_signal, dest_size, source, source_size);
  1086. if(fill_size != dest_size){
  1087. printk(KERN_ERR " zlib uncompress signal error!\n");
  1088. return fill_size;
  1089. }
  1090. }
  1091. copy_pic_data(dest,dest_signal,IMAGE_TYPE_SIGNAL,p->disp_signal_id,SRC_COVER_DST);
  1092. last_id = p->disp_signal_id;
  1093. return fill_size;
  1094. }
  1095. static unsigned int subjoin_append1_pic(void *dest)
  1096. {
  1097. static unsigned int last_id = IMAGE_ID_NONE;
  1098. track_context *p = g_ptrack_context;
  1099. void *dest_append1 = p->disp_append1_buf;
  1100. unsigned int dest_size = p->disp_append1_size;
  1101. unsigned int fill_size = 0;
  1102. unsigned int source_size;
  1103. unsigned int source_offset;
  1104. void *source;
  1105. if(p->disp_append1_id > APPEND1_MAX)
  1106. return 0;
  1107. if(first_draw_track)
  1108. last_id = IMAGE_ID_NONE;
  1109. source_offset = get_picture_offset(IMAGE_TYPE_APPEND1,p->disp_append1_id);
  1110. source_size = get_picture_size(IMAGE_TYPE_APPEND1,p->disp_append1_id);
  1111. //printk(KERN_ALERT "++++++ subjoin_append1_pic source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
  1112. if(source_size == 0 || source_offset < sizeof(user_header)){
  1113. printk(KERN_ERR "subjoin append1 pic source error, disp_append1_id=0x%0x.\n",p->disp_append1_id);
  1114. return 0;
  1115. }
  1116. if(last_id == IMAGE_ID_NONE || last_id != p->disp_append1_id){
  1117. source = (void*)get_picture_addr(IMAGE_TYPE_APPEND1,p->disp_append1_id);
  1118. fill_size = zlib_uncompress_block(dest_append1, dest_size, source, source_size);
  1119. if(fill_size != dest_size){
  1120. printk(KERN_ERR " zlib uncompress append1 error!\n");
  1121. return fill_size;
  1122. }
  1123. }
  1124. copy_pic_data(dest,dest_append1,IMAGE_TYPE_APPEND1,p->disp_append1_id,SRC_COVER_DST);
  1125. last_id = p->disp_append1_id;
  1126. return fill_size;
  1127. }
  1128. static unsigned int subjoin_append2_pic(void *dest)
  1129. {
  1130. static unsigned int last_id = IMAGE_ID_NONE;
  1131. track_context *p = g_ptrack_context;
  1132. void *dest_append2 = p->disp_append2_buf;
  1133. unsigned int dest_size = p->disp_append2_size;
  1134. unsigned int fill_size = 0;
  1135. unsigned int source_size;
  1136. unsigned int source_offset;
  1137. void *source;
  1138. if(p->disp_append2_id > APPEND2_MAX)
  1139. return 0;
  1140. if(first_draw_track)
  1141. last_id = IMAGE_ID_NONE;
  1142. source_offset = get_picture_offset(IMAGE_TYPE_APPEND2,p->disp_append2_id);
  1143. source_size = get_picture_size(IMAGE_TYPE_APPEND2,p->disp_append2_id);
  1144. //printk(KERN_ALERT "++++++ subjoin_append2_pic source_offset=%0x ,source_size=%0x\n",source_offset,source_size );
  1145. if(source_size == 0 || source_offset < sizeof(user_header)){
  1146. printk(KERN_ERR "subjoin append2 pic source error, disp_append2_id=0x%0x.\n",p->disp_append2_id);
  1147. return 0;
  1148. }
  1149. if(last_id == IMAGE_ID_NONE || last_id != p->disp_append2_id){
  1150. source = (void*)get_picture_addr(IMAGE_TYPE_APPEND2,p->disp_append2_id);
  1151. fill_size = zlib_uncompress_block(dest_append2, dest_size, source, source_size);
  1152. if(fill_size != dest_size){
  1153. printk(KERN_ERR " zlib uncompress append2 error!\n");
  1154. return fill_size;
  1155. }
  1156. }
  1157. copy_pic_data(dest,dest_append2,IMAGE_TYPE_APPEND2,p->disp_append2_id,SRC_COVER_DST);
  1158. last_id = p->disp_append2_id;
  1159. return fill_size;
  1160. }
  1161. static unsigned int subjoin_track_pic(void *dest)
  1162. {
  1163. static unsigned int last_id = IMAGE_ID_NONE;
  1164. track_context *p = g_ptrack_context;
  1165. void *dest_track = p->disp_track_buf;
  1166. unsigned int dest_size = p->disp_track_size;
  1167. unsigned int fill_size = 0;
  1168. unsigned int source_size;
  1169. unsigned int source_offset;
  1170. void *source;
  1171. if(p->disp_track_id > TRACK_MAX)
  1172. return 0;
  1173. if(first_draw_track)
  1174. last_id = IMAGE_ID_NONE;
  1175. source_offset = get_picture_offset(IMAGE_TYPE_TRACK,p->disp_track_id);
  1176. source_size = get_picture_size(IMAGE_TYPE_TRACK,p->disp_track_id);
  1177. if(source_size == 0 || source_offset < sizeof(user_header)){
  1178. printk(KERN_ERR "subjoin track pic source error, disp_track_id=0x%0x.\n",p->disp_track_id);
  1179. return 0;
  1180. }
  1181. if(last_id == IMAGE_ID_NONE || last_id != p->disp_track_id){
  1182. source = (void*)get_picture_addr(IMAGE_TYPE_TRACK,p->disp_track_id);
  1183. fill_size = zlib_uncompress_block(dest_track, dest_size, source, source_size);
  1184. if(fill_size != dest_size){
  1185. printk(KERN_ERR " zlib uncompress track error!\n");
  1186. return fill_size;
  1187. }
  1188. }
  1189. copy_pic_data(dest,dest_track,IMAGE_TYPE_TRACK,p->disp_track_id,SRC_COVER_DST);
  1190. last_id = p->disp_track_id;
  1191. //printk(KERN_ALERT "p->disp_track_id = %d",p->disp_track_id);
  1192. return fill_size;
  1193. }
  1194. static unsigned int subjoin_radar_pic(void *dest)
  1195. {
  1196. static unsigned int last_id = IMAGE_ID_NONE;
  1197. track_context *p = g_ptrack_context;
  1198. void *dest_radar = p->disp_radar_buf[0];
  1199. unsigned int dest_size = p->disp_radar_size;
  1200. unsigned int mask = 0xff000000;
  1201. unsigned int image_id;
  1202. unsigned char channel;
  1203. unsigned int fill_size = 0;
  1204. unsigned int source_size;
  1205. unsigned int source_offset;
  1206. void *source;
  1207. if(p->disp_radar_id == IMAGE_ID_NONE)
  1208. return 0;
  1209. if(first_draw_track)
  1210. last_id = IMAGE_ID_NONE;
  1211. for(channel = RADAR_CHANNEL_FL; channel <= RADAR_CHANNEL_RR;channel++){
  1212. image_id = p->disp_radar_id & (mask >> 8*channel);
  1213. if(!is_radar_image_id(image_id)){
  1214. printk(KERN_ERR " subjoin radar id channel=%d image_id=0x%0x, error!\n",channel,image_id);
  1215. continue;
  1216. }
  1217. dest_radar = p->disp_radar_buf[channel];
  1218. source_size = get_picture_size(IMAGE_TYPE_RADAR,image_id);
  1219. source_offset = get_picture_offset(IMAGE_TYPE_RADAR,image_id);
  1220. //printk(KERN_ALERT "channel=%d image_id=0x%0x ---> source_offset=%0x ,source_size=%0x \n",channel,image_id,source_offset,source_size );
  1221. if(source_size == 0 || source_offset < sizeof(user_header)){
  1222. printk(KERN_ERR "subjoin radar pic source error,channel=%d image_id=0x%0x.\n",channel,image_id);
  1223. continue;
  1224. }
  1225. if(last_id == IMAGE_ID_NONE || last_id != p->disp_radar_id){
  1226. source = (void*)get_picture_addr(IMAGE_TYPE_RADAR,image_id);
  1227. fill_size = zlib_uncompress_block(dest_radar, dest_size, source, source_size);
  1228. if(fill_size != dest_size){
  1229. printk(KERN_ERR " zlib uncompress radar error!\n");
  1230. return fill_size;
  1231. }
  1232. }
  1233. if(channel == RADAR_CHANNEL_RR){
  1234. copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,SRC_COVER_DST);
  1235. }
  1236. else{
  1237. copy_pic_data(dest,dest_radar,IMAGE_TYPE_RADAR,image_id,SRC_COVER_DST);
  1238. }
  1239. }
  1240. last_id = p->disp_radar_id;
  1241. return fill_size;
  1242. }
  1243. static unsigned int subjoin_track2_pic(void *dest)
  1244. {
  1245. static unsigned int last_id = IMAGE_ID_NONE;
  1246. track_context *p = g_ptrack_context;
  1247. void *dest_track2 = p->disp_track2_buf;
  1248. unsigned int dest_size = p->disp_track2_size;
  1249. unsigned int fill_size = 0;
  1250. unsigned int source_size;
  1251. unsigned int source_offset;
  1252. void *source;
  1253. if(p->disp_track2_id > TRACK_MAX)
  1254. return 0;
  1255. if(first_draw_track)
  1256. last_id = IMAGE_ID_NONE;
  1257. source_offset = get_picture_offset(IMAGE_TYPE_TRACK2,p->disp_track2_id);
  1258. source_size = get_picture_size(IMAGE_TYPE_TRACK2,p->disp_track2_id);
  1259. if(source_size == 0 || source_offset < sizeof(user_header)){
  1260. printk(KERN_ERR "subjoin track2 pic source error, disp_track2_id=0x%0x.\n",p->disp_track2_id);
  1261. return 0;
  1262. }
  1263. if(last_id == IMAGE_ID_NONE || last_id != p->disp_radar_id){
  1264. source = (void*)get_picture_addr(IMAGE_TYPE_TRACK2,p->disp_track2_id);
  1265. fill_size = zlib_uncompress_block(dest_track2, dest_size, source, source_size);
  1266. if(fill_size != dest_size){
  1267. printk(KERN_ERR " zlib uncompress track2 error!\n");
  1268. return fill_size;
  1269. }
  1270. }
  1271. copy_pic_data(dest,dest_track2,IMAGE_TYPE_TRACK2,p->disp_track2_id,SRC_COVER_DST);
  1272. last_id = p->disp_track2_id;
  1273. return fill_size;
  1274. }
  1275. static unsigned int subjoin_mradar_pic(void *dest)
  1276. {
  1277. static unsigned char last_mradar_id[MRADAR_MAX]={0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF};
  1278. track_context2 *p = g_ptrack_context2;
  1279. void *dest_buf;
  1280. unsigned int dest_size;
  1281. unsigned int fill_size = 0;
  1282. unsigned int source_size;
  1283. unsigned int source_offset;
  1284. void *source;
  1285. int i,item_id;
  1286. if(p == NULL)
  1287. return -1;
  1288. if(first_draw_track) {
  1289. for(i = 0; i < MRADAR_MAX; i++){
  1290. last_mradar_id[i] = 0x0F;
  1291. }
  1292. }
  1293. for(i = 0; i < MRADAR_MAX; i++){
  1294. if(p->disp_mradar_id[i] == 0x0F)
  1295. continue;
  1296. item_id = p->disp_mradar_id[i];
  1297. dest_buf = p->disp_mradar_buf[i];
  1298. dest_size = p->disp_mradar_size[i];
  1299. source_offset = g_pheader2_buf->mradar[i][item_id].image_offset + g_pheader_buf->file_size;
  1300. source_size = g_pheader2_buf->mradar[i][item_id].image_size;
  1301. //printk(KERN_ALERT "mradar[%d][%d]: source_offset=0x%0x ,source_size=0x%0x \n",i,item_id,source_offset,source_size);
  1302. if(source_size == 0 || source_offset < sizeof(user2_header)){
  1303. //printk(KERN_ERR "subjoin mradar pic source error, mradar[%d][%d].\n",i, item_id);
  1304. continue;
  1305. }
  1306. if(last_mradar_id[i] == 0x0F || last_mradar_id[i] != p->disp_mradar_id[i]){
  1307. source =(void*)(g_carback_context->track_data_virtaddr+source_offset);
  1308. fill_size = zlib_uncompress_block(dest_buf, dest_size, source, source_size);
  1309. if(fill_size != dest_size){
  1310. printk(KERN_ERR " zlib uncompress mradar error, fill_size=%0x, dest_size=%0x.\n", fill_size, dest_size);
  1311. return fill_size;
  1312. }
  1313. }
  1314. copy_pic_data(dest, dest_buf, IMAGE_TYPE_MRADAR, i, SRC_COVER_DST2);
  1315. }
  1316. for(i = 0; i < MRADAR_MAX; i++)
  1317. last_mradar_id[i] = p->disp_mradar_id[i];
  1318. p->disp_mradar_id_change = 0;
  1319. return fill_size;
  1320. }
  1321. int track_paint_init(void)
  1322. {
  1323. int ret = 0;
  1324. if(zlib_uncompress_init()){
  1325. printk(KERN_ERR "zlib uncompress init failed!\n" );
  1326. return -1;
  1327. }
  1328. if (*(volatile unsigned int*)g_carback_context->track_data_virtaddr != MKTAG('R', 'S', 'T', 'K')) {
  1329. printk(KERN_ALERT "reservingtrack check failed!\n" );
  1330. return -1;
  1331. }
  1332. if(init_track_context(g_carback_context->track_data_virtaddr) < 0){
  1333. printk(KERN_ERR "init track context failed.\n" );
  1334. return -1;
  1335. }
  1336. if(init_track_context2(g_carback_context->track_data_virtaddr) < 0){
  1337. printk(KERN_ERR "init track context2 failed.\n" );
  1338. g_ptrack_context2 = NULL;
  1339. return -1;
  1340. }
  1341. if(g_carback_context && g_carback_context->screen_width >= g_ptrack_context->disp_width && g_carback_context->screen_height>= g_ptrack_context->disp_height){
  1342. g_carback_context->track_disp_width = g_ptrack_context->disp_width;
  1343. g_carback_context->track_disp_height= g_ptrack_context->disp_height;
  1344. g_carback_context->track_disp_xpos = g_ptrack_context->disp_xpos;
  1345. g_carback_context->track_disp_ypos = g_ptrack_context->disp_ypos;
  1346. g_carback_context->ptrack_param = &g_ptrack_context->track_param;
  1347. g_carback_context->file_type = g_ptrack_context->file_type;
  1348. g_carback_context->pmradar_param = NULL;
  1349. if(g_ptrack_context2)
  1350. g_carback_context->pmradar_param = &g_ptrack_context2->mradar_param;
  1351. printk(KERN_ALERT "++++++track_switch_id = %d",track_switch_id);
  1352. if(track_switch_id == 0){
  1353. set_disp_track_id(TRACK_STRAIGHT_FORWARD_ID);
  1354. set_disp_car_id(CAR_NORMAL_STATUS_ID);
  1355. set_disp_radar_id(RADAR_NORMAL_STATUS_ID);
  1356. set_disp_track2_id(IMAGE_ID_NONE);
  1357. set_disp_signal_id(IMAGE_ID_NONE);
  1358. set_disp_append1_id(APPEND1_NORMAL_STATUS_ID);
  1359. set_disp_append2_id(APPEND2_NORMAL_STATUS_ID);
  1360. }else if(track_switch_id == 1){
  1361. set_disp_track_id(IMAGE_ID_NONE);
  1362. set_disp_car_id(CAR_NORMAL_STATUS_ID);
  1363. set_disp_radar_id(RADAR_NORMAL_STATUS_ID);
  1364. set_disp_track2_id(TRACK2_STRAIGHT_FORWARD_ID);
  1365. set_disp_signal_id(IMAGE_ID_NONE);
  1366. set_disp_append1_id(APPEND1_NORMAL_STATUS_ID);
  1367. set_disp_append2_id(APPEND2_NORMAL_STATUS_ID);
  1368. }else{
  1369. set_disp_track_id(TRACK_STRAIGHT_FORWARD_ID);
  1370. set_disp_car_id(CAR_NORMAL_STATUS_ID);
  1371. set_disp_radar_id(RADAR_NORMAL_STATUS_ID);
  1372. set_disp_track2_id(IMAGE_ID_NONE);
  1373. set_disp_signal_id(IMAGE_ID_NONE);
  1374. set_disp_append1_id(APPEND1_NORMAL_STATUS_ID);
  1375. set_disp_append2_id(APPEND2_NORMAL_STATUS_ID);
  1376. }
  1377. printk("track_paint init width=%d, height=%d,xpos=%d,ypos=%d.\n",g_carback_context->track_disp_width,\
  1378. g_carback_context->track_disp_height,g_carback_context->track_disp_xpos,g_carback_context->track_disp_ypos);
  1379. }
  1380. else{
  1381. printk(KERN_ALERT "track paint init out width or height fail!\n" );
  1382. ret = -1;
  1383. }
  1384. return ret;
  1385. }
  1386. void track_paint_deinit(void)
  1387. {
  1388. int i;
  1389. zlib_uncompress_exit();
  1390. if(g_ptrack_context->disp_track2_buf)
  1391. vfree(g_ptrack_context->disp_track2_buf);
  1392. for(i = 0; i < 4;i++)
  1393. if(g_ptrack_context->disp_radar_buf[i])
  1394. vfree(g_ptrack_context->disp_radar_buf[i]);
  1395. if(g_ptrack_context->disp_car_buf)
  1396. vfree(g_ptrack_context->disp_car_buf);
  1397. if(g_ptrack_context)
  1398. vfree(g_ptrack_context);
  1399. }
  1400. unsigned int track_paint_fill(void *dest, unsigned int width, unsigned int height)
  1401. {
  1402. static unsigned int last_track_id = 0;
  1403. static unsigned int last_car_id = 0;
  1404. static unsigned int last_radar_id = 0;
  1405. static unsigned int last_signal_id = -1;
  1406. static unsigned int last_append1_id = -1;
  1407. static unsigned int last_append2_id = -1;
  1408. static unsigned int last_track2_id= 0;
  1409. track_context *p = g_ptrack_context;
  1410. user_header* ph = g_pheader_buf;
  1411. if(p == NULL || g_carback_context == NULL){
  1412. printk(KERN_ERR "track_paint_fill g_ptrack_context or carback_context null\n" );
  1413. return 0;
  1414. }
  1415. if( width > p->disp_width || height > p->disp_height){
  1416. printk(KERN_ERR "track paint fill width height error!\n" );
  1417. return 0;
  1418. }
  1419. if(p->disp_track_id > TRACK_MAX && p->disp_track_id < IMAGE_ID_NONE)
  1420. return 0;
  1421. if(!g_carback_context->track_setting){
  1422. memset(dest,0,g_carback_context->track_display_size);
  1423. last_track_id = 0;
  1424. last_car_id = 0;
  1425. last_radar_id = 0;
  1426. last_signal_id = -1;
  1427. last_append1_id = -1;
  1428. last_append2_id = -1;
  1429. last_track2_id= 0;
  1430. return g_carback_context->track_display_size;
  1431. }
  1432. if (p->disp_track_id == IMAGE_ID_NONE && p->disp_track2_id == IMAGE_ID_NONE){
  1433. memset(dest,0,p->disp_track_size);
  1434. if(ph->car_total)
  1435. subjoin_car_pic(dest);
  1436. if(ph->radar_total)
  1437. subjoin_radar_pic(dest);
  1438. last_track_id = p->disp_track_id;
  1439. last_car_id = p->disp_car_id;
  1440. last_radar_id = p->disp_radar_id;
  1441. return p->disp_track_size;
  1442. }
  1443. if( g_carback_context->carback_signal ){
  1444. if(last_track_id == p->disp_track_id && last_car_id == p->disp_car_id &&
  1445. last_radar_id == p->disp_radar_id &&last_track2_id == p->disp_track2_id && last_signal_id == p->disp_signal_id
  1446. && last_append1_id == p->disp_append1_id && last_append2_id == p->disp_append2_id){
  1447. if(g_ptrack_context2 == NULL || !g_ptrack_context2->disp_mradar_id_change)
  1448. return 0;
  1449. }
  1450. }
  1451. if( !g_carback_context->carback_signal ){
  1452. if(last_signal_id != p->disp_signal_id)
  1453. memset(dest,0,g_carback_context->track_display_size);
  1454. ark_track_no_signal_handle();
  1455. if(ph->signal_total)
  1456. subjoin_signal_pic(dest);
  1457. if(ph->append2_total)
  1458. subjoin_append2_pic(dest);
  1459. }else{
  1460. if(g_carback_context->layer_status){
  1461. if(ph->track_total )
  1462. subjoin_track_pic(dest);
  1463. if(ph->car_total)
  1464. subjoin_car_pic(dest);
  1465. if(ph->radar_total)
  1466. subjoin_radar_pic(dest);
  1467. if(ph->track2_total)
  1468. subjoin_track2_pic(dest);
  1469. if(g_ptrack_context2) {
  1470. subjoin_mradar_pic(dest);
  1471. }
  1472. }
  1473. }
  1474. if(g_carback_context->layer_status){
  1475. last_track_id = p->disp_track_id;
  1476. last_car_id = p->disp_car_id;
  1477. last_radar_id = p->disp_radar_id;
  1478. last_track2_id= p->disp_track2_id;
  1479. }
  1480. last_signal_id = p->disp_signal_id;
  1481. last_append1_id = p->disp_append1_id;
  1482. last_append2_id = p->disp_append2_id;
  1483. return g_carback_context->track_display_size;
  1484. }