gc2053.c 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510
  1. #include <linux/module.h>
  2. #include <linux/i2c.h>
  3. #include <linux/delay.h>
  4. #include "ark_camera.h"
  5. #include "ark_isp_exposure_cmos.h"
  6. #include "Gem_isp_io.h"
  7. static u32_t isp_video_width = 1920;
  8. static u32_t isp_video_height = 1080;
  9. static u32_t isp_sensor_bit = ARKN141_ISP_SENSOR_BIT_10;
  10. static unsigned int isp_yuv_format = ARKN141_ISP_YUV_FORMAT_Y_UV420; // ISP??YUV??????脢陆????
  11. static unsigned int isp_sensor_fps = 0;
  12. // 猫沤路氓聫鈥揑SP猫搂鈥犆┞⑩€樏�♀€灻�锯€溍モ€÷好ヂ奥好ヂ�该ヂ�∶ぢ光€�(1080P忙藛鈥撁ㄢ偓鈥�720P)
  13. u32_t isp_get_video_width (void)
  14. {
  15. return isp_video_width;
  16. }
  17. u32_t isp_get_video_height (void)
  18. {
  19. return isp_video_height;
  20. }
  21. //0茂录拧y_uv420 1:y_uv422 2:yuv420 3:yuv422
  22. unsigned int isp_get_video_format (void)
  23. {
  24. return isp_yuv_format;
  25. }
  26. unsigned int isp_get_video_image_size (void)
  27. {
  28. if(isp_yuv_format == ARKN141_ISP_YUV_FORMAT_Y_UV420 || isp_yuv_format == ARKN141_ISP_YUV_FORMAT_YUV420)
  29. return isp_video_width * isp_video_height * 3 / 2;
  30. else // ARKN141_ISP_YUV_FORMAT_Y_UV422 ARKN141_ISP_YUV_FORMAT_Y_UV422
  31. return isp_video_width * isp_video_height * 2;
  32. }
  33. unsigned int isp_get_sensor_bit (void)
  34. {
  35. return isp_sensor_bit;
  36. }
  37. unsigned int isp_get_sensor_fps(void)
  38. {
  39. return isp_sensor_fps;
  40. }
  41. static struct i2c_client *i2c_client;
  42. static int I2C_WRITE (unsigned int addr, unsigned int data)
  43. {
  44. return i2c_smbus_write_byte_data(i2c_client, addr, data);
  45. }
  46. static unsigned int I2C_READ (unsigned int addr)
  47. {
  48. return i2c_smbus_read_byte_data(i2c_client, addr);
  49. }
  50. typedef struct stSensor_cfg {
  51. unsigned int addr;
  52. unsigned char data;
  53. } sensor_cfg;
  54. static struct stSensor_cfg stSensor_cfg_1080P25FPS_10bit[] =
  55. {
  56. //window_size=1920*1080
  57. //mclk=24mhz,pclk=74.25mhz
  58. //pixel_line_total=2640,line_frame_total=1125
  59. //row_time=35.55usus,frame_rate=25fps
  60. /*system*/
  61. 0xfe,0x80,
  62. 0xfe,0x80,
  63. 0xfe,0x80,
  64. 0xfe,0x00,
  65. 0xf2,0x00,//[1]I2C_open_ena [0]pwd_dn
  66. 0xf3,0x0f,//00[3]Sdata_pad_io [2:0]Ssync_pad_io
  67. 0xf4,0x36,//[6:4]pll_ldo_set
  68. 0xf5,0xc0,//[7]soc_mclk_enable [6]pll_ldo_en [5:4]cp_clk_sel [3:0]cp_clk_div
  69. 0xf6,0x44,//[7:3]wpllclk_div [2:0]refmp_div
  70. 0xf7,0x01,//[7]refdiv2d5_en [6]refdiv1d5_en [5:4]scaler_mode [3]refmp_enb [1]div2en [0]pllmp_en
  71. 0xf8,0x63,//38////38//[7:0]pllmp_div
  72. 0xf9,0x40,//82//[7:3]rpllclk_div [2:1]pllmp_prediv [0]analog_pwc
  73. 0xfc,0x8e,
  74. /*cisctl&analog*/
  75. 0xfe,0x00,
  76. 0x87,0x18, //[6]aec_delay_mode
  77. 0xee,0x30, //[5:4]dwen_sramen
  78. 0xd0,0xb7, //ramp_en
  79. 0x03,0x04,
  80. 0x04,0x60,
  81. 0x05,0x05,// 0x528 = 1320
  82. 0x06,0x28,//
  83. 0x07,0x00,
  84. 0x08,0x11, //19
  85. 0x09,0x00,
  86. 0x0a,0x02, //cisctl row start
  87. 0x0b,0x00,
  88. 0x0c,0x02, //cisctl col start
  89. 0x0d,0x04,
  90. 0x0e,0x40, //38
  91. 0x12,0xe2, //vsync_ahead_mode
  92. 0x13,0x16,
  93. 0x19,0x0a, //ad_pipe_num
  94. 0x21,0x1c, //eqc1fc_eqc2fc_sw
  95. 0x28,0x0a, //16//eqc2_c2clpen_sw
  96. 0x29,0x24, //eq_post_width
  97. 0x2b,0x04, //c2clpen --eqc2
  98. 0x32,0xf8, //[5]txh_en ->avdd28
  99. 0x37,0x03, //[3:2]eqc2sel=0
  100. 0x39,0x15,//17 //[3:0]rsgl
  101. 0x43,0x07,//vclamp
  102. 0x44,0x40, //0e//post_tx_width
  103. 0x46,0x0b,
  104. 0x4b,0x20, //rst_tx_width
  105. 0x4e,0x08, //12//ramp_t1_width
  106. 0x55,0x20, //read_tx_width_pp
  107. 0x66,0x05, //18//stspd_width_r1
  108. 0x67,0x05, //40//5//stspd_width_r
  109. 0x77,0x01, //dacin offset x31
  110. 0x78,0x00, //dacin offset
  111. 0x7c,0x93, //[1:0] co1comp
  112. 0x8c,0x12, //12 ramp_t1_ref
  113. 0x8d,0x92,//90
  114. 0x90,0x01,
  115. 0x9d,0x10,
  116. 0xce,0x7c,//70//78//[4:2]c1isel
  117. 0xd2,0x41,//[5:3]c2clamp
  118. 0xd3,0xdc,//ec//0x39[7]=0,0xd3[3]=1 rsgh=vref
  119. 0xe6,0x50,//ramps offset
  120. /*gain*/
  121. 0xb6,0xc0,
  122. 0xb0,0x70,
  123. 0xb1,0x01,
  124. 0xb2,0x00,
  125. 0xb3,0x00,
  126. 0xb4,0x00,
  127. 0xb8,0x01,
  128. 0xb9,0x00,
  129. /*blk*/
  130. 0x26,0x30,//23 //[4]氓鈥犫劉0茂录艗氓鈥β╪ mode
  131. 0xfe,0x01,
  132. 0x40,0x23,
  133. 0x55,0x07,
  134. 0x60,0x40, //[7:0]WB_offset
  135. 0xfe,0x04,
  136. 0x14,0x78, //g1 ratio
  137. 0x15,0x78, //r ratio
  138. 0x16,0x78, //b ratio
  139. 0x17,0x78, //g2 ratio
  140. /*window*/
  141. 0xfe,0x01,
  142. 0x92,0x00, //win y1
  143. 0x94,0x03, //win x1
  144. 0x95,0x04,
  145. 0x96,0x38, //[10:0]out_height
  146. 0x97,0x07,
  147. 0x98,0x80, //[11:0]out_width
  148. /*ISP*/
  149. 0xfe,0x01,
  150. 0x01,0x05,//03//[3]dpc blending mode [2]noise_mode [1:0]center_choose 2b'11:median 2b'10:avg 2'b00:near
  151. 0x02,0x89, //[7:0]BFF_sram_mode
  152. 0x04,0x01, //[0]DD_en
  153. 0x07,0xa6,
  154. 0x08,0xa9,
  155. 0x09,0xa8,
  156. 0x0a,0xa7,
  157. 0x0b,0xff,
  158. 0x0c,0xff,
  159. 0x0f,0x00,
  160. 0x50,0x1c,
  161. 0x89,0x03,
  162. 0xfe,0x04,
  163. 0x28,0x86,//84
  164. 0x29,0x86,//84
  165. 0x2a,0x86,//84
  166. 0x2b,0x68,//84
  167. 0x2c,0x68,//84
  168. 0x2d,0x68,//84
  169. 0x2e,0x68,//83
  170. 0x2f,0x68,//82
  171. 0x30,0x4f,//82
  172. 0x31,0x68,//82
  173. 0x32,0x67,//82
  174. 0x33,0x66,//82
  175. 0x34,0x66,//82
  176. 0x35,0x66,//82
  177. 0x36,0x66,//64
  178. 0x37,0x66,//68
  179. 0x38,0x62,
  180. 0x39,0x62,
  181. 0x3a,0x62,
  182. 0x3b,0x62,
  183. 0x3c,0x62,
  184. 0x3d,0x62,
  185. 0x3e,0x62,
  186. 0x3f,0x62,
  187. /****DVP & MIPI****/
  188. 0xfe,0x01,
  189. 0x9a,0x06, //[5]OUT_gate_mode [4]hsync_delay_half_pclk [3]data_delay_half_pclk [2]vsync_polarity [1]hsync_polarity [0]pclk_out_polarity
  190. 0xfe,0x00,
  191. 0x7b,0x28, //[7:6]updn [5:4]drv_high_data [3:2]drv_low_data [1:0]drv_pclk
  192. 0x23,0x2d, //[3]rst_rc [2:1]drv_sync [0]pwd_rc
  193. 0xfe,0x03,
  194. 0x01,0x20, //27[6:5]clkctr [2]phy-lane1_en [1]phy-lane0_en [0]phy_clk_en
  195. 0x02,0x56, //[7:6]data1ctr [5:4]data0ctr [3:0]mipi_diff
  196. 0x03,0xb2, //b6[7]clklane_p2s_sel [6:5]data0hs_ph [4]data0_delay1s [3]clkdelay1s [2]mipi_en [1:0]clkhs_ph
  197. 0x12,0x80,
  198. 0x13,0x07, //LWC
  199. 0xfe,0x00,
  200. 0x3e,0x40, //91[7]lane_ena [6]DVPBUF_ena [5]ULPEna [4]MIPI_ena [3]mipi_set_auto_disable [2]RAW8_mode [1]ine_sync_mode [0]double_lane_en
  201. };
  202. static struct stSensor_cfg stSensor_cfg_1080P30FPS_10bit[] =
  203. {
  204. //window_size=1920*1080
  205. //mclk=24mhz,pclk=74.25mhz
  206. //pixel_line_total=2200,line_frame_total=1125
  207. //row_time=29.629us,frame_rate=30fps
  208. /*system*/
  209. 0xfe,0x80,
  210. 0xfe,0x80,
  211. 0xfe,0x80,
  212. 0xfe,0x00,
  213. 0xf2,0x00,//[1]I2C_open_ena [0]pwd_dn
  214. 0xf3,0x0f,//00[3]Sdata_pad_io [2:0]Ssync_pad_io
  215. 0xf4,0x36,//[6:4]pll_ldo_set
  216. 0xf5,0xc0,//[7]soc_mclk_enable [6]pll_ldo_en [5:4]cp_clk_sel [3:0]cp_clk_div
  217. 0xf6,0x44,//[7:3]wpllclk_div [2:0]refmp_div
  218. 0xf7,0x01,//[7]refdiv2d5_en [6]refdiv1d5_en [5:4]scaler_mode [3]refmp_enb [1]div2en [0]pllmp_en
  219. 0xf8,0x63,//38////38//[7:0]pllmp_div
  220. 0xf9,0x40,//82//[7:3]rpllclk_div [2:1]pllmp_prediv [0]analog_pwc
  221. 0xfc,0x8e,
  222. /*cisctl&analog*/
  223. 0xfe,0x00,
  224. 0x87,0x18, //[6]aec_delay_mode
  225. 0xee,0x30, //[5:4]dwen_sramen
  226. 0xd0,0xb7, //ramp_en
  227. 0x03,0x04,
  228. 0x04,0x60,
  229. 0x05,0x04,// 0x44c = 1100
  230. 0x06,0x4c,//
  231. 0x07,0x00,
  232. 0x08,0x11, //19
  233. 0x09,0x00,
  234. 0x0a,0x02, //cisctl row start
  235. 0x0b,0x00,
  236. 0x0c,0x02, //cisctl col start
  237. 0x0d,0x04,
  238. 0x0e,0x40, //38
  239. 0x12,0xe2, //vsync_ahead_mode
  240. 0x13,0x16,
  241. 0x19,0x0a, //ad_pipe_num
  242. 0x21,0x1c, //eqc1fc_eqc2fc_sw
  243. 0x28,0x0a, //16//eqc2_c2clpen_sw
  244. 0x29,0x24, //eq_post_width
  245. 0x2b,0x04, //c2clpen --eqc2
  246. 0x32,0xf8, //[5]txh_en ->avdd28
  247. 0x37,0x03, //[3:2]eqc2sel=0
  248. 0x39,0x15,//17 //[3:0]rsgl
  249. 0x43,0x07,//vclamp
  250. 0x44,0x40, //0e//post_tx_width
  251. 0x46,0x0b,
  252. 0x4b,0x20, //rst_tx_width
  253. 0x4e,0x08, //12//ramp_t1_width
  254. 0x55,0x20, //read_tx_width_pp
  255. 0x66,0x05, //18//stspd_width_r1
  256. 0x67,0x05, //40//5//stspd_width_r
  257. 0x77,0x01, //dacin offset x31
  258. 0x78,0x00, //dacin offset
  259. 0x7c,0x93, //[1:0] co1comp
  260. 0x8c,0x12, //12 ramp_t1_ref
  261. 0x8d,0x92,//90
  262. 0x90,0x01,
  263. 0x9d,0x10,
  264. 0xce,0x7c,//70//78//[4:2]c1isel
  265. 0xd2,0x41,//[5:3]c2clamp
  266. 0xd3,0xdc,//ec//0x39[7]=0,0xd3[3]=1 rsgh=vref
  267. 0xe6,0x50,//ramps offset
  268. /*gain*/
  269. 0xb6,0xc0,
  270. 0xb0,0x70,
  271. 0xb1,0x01,
  272. 0xb2,0x00,
  273. 0xb3,0x00,
  274. 0xb4,0x00,
  275. 0xb8,0x01,
  276. 0xb9,0x00,
  277. /*blk*/
  278. 0x26,0x30,//23 //[4]氓鈥犫劉0茂录艗氓鈥β╪ mode
  279. 0xfe,0x01,
  280. 0x40,0x23,
  281. 0x55,0x07,
  282. 0x60,0x40, //[7:0]WB_offset
  283. 0xfe,0x04,
  284. 0x14,0x78, //g1 ratio
  285. 0x15,0x78, //r ratio
  286. 0x16,0x78, //b ratio
  287. 0x17,0x78, //g2 ratio
  288. /*window*/
  289. 0xfe,0x01,
  290. 0x92,0x00, //win y1
  291. 0x94,0x03, //win x1
  292. 0x95,0x04,
  293. 0x96,0x38, //[10:0]out_height
  294. 0x97,0x07,
  295. 0x98,0x80, //[11:0]out_width
  296. /*ISP*/
  297. 0xfe,0x01,
  298. 0x01,0x05,//03//[3]dpc blending mode [2]noise_mode [1:0]center_choose 2b'11:median 2b'10:avg 2'b00:near
  299. 0x02,0x89, //[7:0]BFF_sram_mode
  300. 0x04,0x01, //[0]DD_en
  301. 0x07,0xa6,
  302. 0x08,0xa9,
  303. 0x09,0xa8,
  304. 0x0a,0xa7,
  305. 0x0b,0xff,
  306. 0x0c,0xff,
  307. 0x0f,0x00,
  308. 0x50,0x1c,
  309. 0x89,0x03,
  310. 0xfe,0x04,
  311. 0x28,0x86,//84
  312. 0x29,0x86,//84
  313. 0x2a,0x86,//84
  314. 0x2b,0x68,//84
  315. 0x2c,0x68,//84
  316. 0x2d,0x68,//84
  317. 0x2e,0x68,//83
  318. 0x2f,0x68,//82
  319. 0x30,0x4f,//82
  320. 0x31,0x68,//82
  321. 0x32,0x67,//82
  322. 0x33,0x66,//82
  323. 0x34,0x66,//82
  324. 0x35,0x66,//82
  325. 0x36,0x66,//64
  326. 0x37,0x66,//68
  327. 0x38,0x62,
  328. 0x39,0x62,
  329. 0x3a,0x62,
  330. 0x3b,0x62,
  331. 0x3c,0x62,
  332. 0x3d,0x62,
  333. 0x3e,0x62,
  334. 0x3f,0x62,
  335. /****DVP & MIPI****/
  336. 0xfe,0x01,
  337. 0x9a,0x06, //[5]OUT_gate_mode [4]hsync_delay_half_pclk [3]data_delay_half_pclk [2]vsync_polarity [1]hsync_polarity [0]pclk_out_polarity
  338. 0xfe,0x00,
  339. 0x7b,0x28, //[7:6]updn [5:4]drv_high_data [3:2]drv_low_data [1:0]drv_pclk
  340. 0x23,0x2d, //[3]rst_rc [2:1]drv_sync [0]pwd_rc
  341. 0xfe,0x03,
  342. 0x01,0x20, //27[6:5]clkctr [2]phy-lane1_en [1]phy-lane0_en [0]phy_clk_en
  343. 0x02,0x56, //[7:6]data1ctr [5:4]data0ctr [3:0]mipi_diff
  344. 0x03,0xb2, //b6[7]clklane_p2s_sel [6:5]data0hs_ph [4]data0_delay1s [3]clkdelay1s [2]mipi_en [1:0]clkhs_ph
  345. 0x12,0x80,
  346. 0x13,0x07, //LWC
  347. 0xfe,0x00,
  348. 0x3e,0x40, //91[7]lane_ena [6]DVPBUF_ena [5]ULPEna [4]MIPI_ena [3]mipi_set_auto_disable [2]RAW8_mode [1]ine_sync_mode [0]double_lane_en
  349. };
  350. // 1080P/30fps忙篓隆氓录聫 10bit
  351. int gc2053_init_30fps_10bit (void)
  352. {
  353. int i;
  354. XM_printf ("cmos sensor gc2053 init 1080P 30fps 10bit mode\n");
  355. for(i = 0; i < sizeof(stSensor_cfg_1080P30FPS_10bit)/sizeof(stSensor_cfg_1080P30FPS_10bit[0]); i ++)
  356. {
  357. if(I2C_WRITE (stSensor_cfg_1080P30FPS_10bit[i].addr, stSensor_cfg_1080P30FPS_10bit[i].data) < 0)
  358. return -1;
  359. }
  360. return 0;
  361. }
  362. // 1080P/25fps忙篓隆氓录聫 10bit
  363. int gc2053_init_25fps_10bit (void)
  364. {
  365. int i;
  366. XM_printf ("cmos sensor gc2053 init 1080P 25fps 10bit mode\n");
  367. for(i = 0; i < sizeof(stSensor_cfg_1080P25FPS_10bit)/sizeof(stSensor_cfg_1080P25FPS_10bit[0]); i ++)
  368. {
  369. if(I2C_WRITE (stSensor_cfg_1080P25FPS_10bit[i].addr, stSensor_cfg_1080P25FPS_10bit[i].data) < 0)
  370. return -1;
  371. }
  372. return 0;
  373. }
  374. // 氓藛聺氓搂鈥姑ヅ掆€揅MOS sensor
  375. // 猫驴鈥澝モ€号久モ偓录
  376. // 0 success
  377. // -1 failure
  378. int arkn141_isp_cmos_sensor_init (void)
  379. {
  380. // 氓藛聺氓搂鈥姑ヅ掆€� GC2053
  381. return 0;
  382. }
  383. // 氓陇聧盲陆聧CMOS sensor
  384. // 猫驴鈥澝モ€号久モ偓录
  385. // 0 success
  386. // -1 failure
  387. int arkn141_isp_cmos_sensor_reset (void)
  388. {
  389. // 氓陇聧盲陆聧 GC2053
  390. return 0;
  391. }
  392. // 猫炉禄氓聫鈥搒ensor莽拧鈥灻ヂ�€灻ヂ�溍モ劉篓氓鈥犫€γヂ��
  393. // 猫炉禄氓鈥÷好�♀€灻︹€⒙懊モ偓录盲驴聺氓颅藴氓艙篓data忙艗鈥∶┾€櫵喢ε掆€∶ヂ愨€樏�♀€灻ヅ撀懊ヂ濃偓.
  394. // 猫鈥孤ッ︹€⒙懊モ偓录盲赂聧氓陇鸥32盲陆聧, 氓掳鈥犆┞�溍ぢ铰嵜р€澛�0氓隆芦氓鈥︹€�
  395. // 猫驴鈥澝モ€号久モ偓录
  396. // 0 success
  397. // -1 failure
  398. int arkn141_isp_cmos_sensor_read_register (u32_t addr, u32_t *data)
  399. {
  400. u8 val = i2c_smbus_read_byte_data(i2c_client, addr);
  401. *data = val;
  402. return 0;
  403. }
  404. // 氓鈥犫劉氓鈥βッ︹€⒙懊β嵚�モ€犫€γヂ�姑ニ喡皊ensor莽拧鈥灻ヂ�€灻ヂ�溍モ劉篓
  405. // 猫驴鈥澝モ€号久モ偓录
  406. // 0 success
  407. // -1 failure
  408. int arkn141_isp_cmos_sensor_write_register (u32_t addr, u32_t data)
  409. {
  410. return i2c_smbus_write_byte_data(i2c_client, addr, data);
  411. }
  412. #define EXPOSURE_LINES_ADDR (0x3012) // Integration time adjustment (I2C) Designated in line units
  413. #define AGAIN_ADDR (0x3060) // analog_gain
  414. #define DGAIN_ADDR (0x305E) // global_gain
  415. #define STD_30_LINES (1125)
  416. #define CMOS_STD_INTTIME (STD_30_LINES-2)
  417. static cmos_inttime_t cmos_inttime;
  418. static cmos_gain_t cmos_gain;
  419. static u16_t FRM_LENGTH = STD_30_LINES;
  420. static u32_t regValTable[29][4] = { {0x00, 0x00,0x01,0x00},//0xb4 0xb3 0xb8 0xb9
  421. {0x00, 0x10,0x01,0x0c},
  422. {0x00, 0x20,0x01,0x1b},
  423. {0x00, 0x30,0x01,0x2c},
  424. {0x00, 0x40,0x01,0x3f},
  425. {0x00, 0x50,0x02,0x16},
  426. {0x00, 0x60,0x02,0x35},
  427. {0x00, 0x70,0x03,0x16},
  428. {0x00, 0x80,0x04,0x02},
  429. {0x00, 0x90,0x04,0x31},
  430. {0x00, 0xa0,0x05,0x32},
  431. {0x00, 0xb0,0x06,0x35},
  432. {0x00, 0xc0,0x08,0x04},
  433. {0x00, 0x5a,0x09,0x19},
  434. {0x00, 0x83,0x0b,0x0f},
  435. {0x00, 0x93,0x0d,0x12},
  436. {0x00, 0x84,0x10,0x00},
  437. {0x00, 0x94,0x12,0x3a},
  438. {0x01, 0x2c,0x1a,0x02},
  439. {0x01, 0x3c,0x1b,0x20},
  440. {0x00, 0x8c,0x20,0x0f},
  441. {0x00, 0x9c,0x26,0x07},
  442. {0x02, 0x64,0x36,0x21},
  443. {0x02, 0x74,0x37,0x3a},
  444. {0x00, 0xc6,0x3d,0x02},
  445. {0x00, 0xdc,0x3f,0x3f},
  446. {0x02, 0x85,0x3f,0x3f},
  447. {0x02, 0x95,0x3f,0x3f},
  448. {0x00, 0xce,0x3f,0x3f},
  449. };
  450. static u32_t analog_gain_table[29] =
  451. {
  452. /* zephyr@2017-04-18 */
  453. 1024,
  454. 1184,
  455. 1424,
  456. 1632,
  457. 2032,
  458. 2352,
  459. 2832,
  460. 3248,
  461. 4160,
  462. 4800,
  463. 5776,
  464. 6640,
  465. 8064,
  466. 9296,
  467. 11552,
  468. 13312,
  469. 16432,
  470. 18912,
  471. 22528,
  472. 25936,
  473. 31840,
  474. 36656,
  475. 45600,
  476. 52512,
  477. 64768,
  478. 82880,
  479. 88000,
  480. 107904,
  481. 113168,
  482. };
  483. static u32_t digital_gain_table[] =
  484. {
  485. 64, 65, 66, 67, 68, 69, 70, 71,
  486. 72, 73, 74, 75, 76, 77, 78, 79,
  487. 80, 81, 82, 83, 84, 85, 86, 87,
  488. 88, 89, 90, 91, 92, 93, 94, 95,
  489. 96, 97, 98, 99, 100, 101, 102, 103,
  490. 104, 105, 106, 107, 108, 109, 110, 111,
  491. 112, 113, 114, 115, 116, 117, 118, 119,
  492. 120, 121, 122, 123, 124, 125, 126, 127
  493. };
  494. // PCLK = 74.25MHz
  495. // Frame Size = 2040 * 1214
  496. // fps = 74.25 * 1000000 / (2040 * 1214) = 29.98 帧/秒
  497. static cmos_inttime_ptr_t cmos_inttime_initialize(void)
  498. {
  499. cmos_inttime.full_lines = FRM_LENGTH;
  500. cmos_inttime.full_lines_limit = 65535;
  501. cmos_inttime.max_lines_target = (u16_t)(FRM_LENGTH - 2);
  502. cmos_inttime.min_lines_target = 2;
  503. cmos_inttime.exposure_ashort = 0;
  504. return &cmos_inttime;
  505. }
  506. // The sensor's integration time is obtained by the following formula.
  507. static void cmos_inttime_update (cmos_inttime_ptr_t p_inttime)
  508. {
  509. u16_t exp_time;
  510. exp_time = (u16_t)p_inttime->exposure_ashort;
  511. if(exp_time < 2)
  512. exp_time = 2;
  513. //arkn141_isp_cmos_sensor_write_register (0xfe, 0x00 ) ; // Page 0
  514. arkn141_isp_cmos_sensor_write_register (0x03, (u8_t)((exp_time >> 8) & 0x3F) ); // P0:0x03 Exposure [13:8]
  515. arkn141_isp_cmos_sensor_write_register (0x04, (u8_t)(exp_time ) ); //P0:0x04 Exposure [7:0]
  516. }
  517. // 设置CMOS sensor允许使用的最大增益
  518. static int gc2053_cmos_max_gain_set (cmos_gain_ptr_t gain, unsigned int max_analog_gain, unsigned int max_digital_gain);
  519. // The Programmable Gain Control (PGC) of this device consists of the analog block and digital block.
  520. static cmos_gain_ptr_t cmos_gain_initialize(void)
  521. {
  522. cmos_gain.again_shift = 10;
  523. #if IQ_20190522
  524. cmos_gain.max_again_target = 113168; // 111倍
  525. #else
  526. // 20190626 减小最大增益倍数到72倍,减轻低照度下的噪声
  527. cmos_gain.max_again_target = 72 * 1024; // 72倍
  528. #endif
  529. cmos_gain.again_count = sizeof(analog_gain_table)/sizeof(analog_gain_table[0]);
  530. cmos_gain.dgain_shift = 6;
  531. //cmos_gain.max_dgain_target = 127;// 2倍
  532. cmos_gain.max_dgain_target = 64;
  533. cmos_gain.dgain_count = sizeof(digital_gain_table)/sizeof(digital_gain_table[0]);
  534. return &cmos_gain;
  535. }
  536. // 设置CMOS sensor允许使用的最大增益
  537. int gc2053_cmos_max_gain_set (cmos_gain_ptr_t gain, unsigned int max_analog_gain, unsigned int max_digital_gain)
  538. {
  539. int count, index;
  540. if(gain == NULL)
  541. return -1;
  542. if(max_analog_gain == 0)
  543. {
  544. max_analog_gain = 1; // 禁止模拟增益
  545. }
  546. if(gain->max_again_target != 1)
  547. {
  548. // 在增益表中查找该最大增益值
  549. count = sizeof(analog_gain_table) / sizeof(analog_gain_table[0]);
  550. for (index = 0; index < count; index ++)
  551. {
  552. if(analog_gain_table[index] >= max_analog_gain)
  553. {
  554. break;
  555. }
  556. }
  557. if(index >= count)
  558. index = count - 1; // 使用最后一个增益值
  559. // 修改最大可用的增益值
  560. gain->max_again_target = analog_gain_table[index];
  561. gain->again_count = index + 1; // 修改可用的增益项数量
  562. }
  563. if(max_digital_gain == 0)
  564. {
  565. max_digital_gain = 1; // 禁止数字增益
  566. }
  567. if(gain->max_dgain_target != 1)
  568. {
  569. // 在增益表中查找该最大增益值
  570. count = sizeof(digital_gain_table) / sizeof(digital_gain_table[0]);
  571. for (index = 0; index < count; index ++)
  572. {
  573. if(digital_gain_table[index] >= max_digital_gain)
  574. {
  575. break;
  576. }
  577. }
  578. if(index >= count)
  579. index = count - 1; // 使用最后一个增益值
  580. // 修改最大可用的增益值
  581. gain->max_dgain_target = digital_gain_table[index];
  582. gain->dgain_count = index + 1; // 修改可用的增益项数量
  583. }
  584. return 0;
  585. }
  586. // 设置CMOS sensor允许使用的最大增益
  587. int gc2053_cmos_max_gain_get (cmos_gain_ptr_t gain, unsigned int* max_analog_gain, unsigned int* max_digital_gain)
  588. {
  589. if(gain == NULL)
  590. return -1;
  591. *max_analog_gain = gain->max_again_target;
  592. *max_digital_gain = gain->max_dgain_target;
  593. return 0;
  594. }
  595. static void cmos_gain_update (cmos_gain_ptr_t gain)
  596. {
  597. u8_t u8DgainHigh, u8DgainLow;
  598. u32_t dgain = digital_gain_table[gain->dindex];
  599. u8DgainHigh = (dgain >> 6) & 0x0f;
  600. u8DgainLow = (dgain & 0x3f) << 2;
  601. arkn141_isp_cmos_sensor_write_register (0xb1, u8DgainHigh);
  602. arkn141_isp_cmos_sensor_write_register (0xb2, u8DgainLow);
  603. // analog gain
  604. arkn141_isp_cmos_sensor_write_register (0xb4, regValTable[gain->aindex][0]);
  605. arkn141_isp_cmos_sensor_write_register (0xb3, regValTable[gain->aindex][1]);
  606. arkn141_isp_cmos_sensor_write_register (0xb8, regValTable[gain->aindex][2]);
  607. arkn141_isp_cmos_sensor_write_register (0xb9, regValTable[gain->aindex][3]);
  608. }
  609. // 根据曝光量计算模拟增益
  610. static u32_t analog_gain_from_exposure_calculate (cmos_gain_ptr_t gain, u32_t exposure, u32_t exposure_max)
  611. {
  612. // 二分法查找最接近的模拟增益
  613. // 计算精度非常重要,会导致曝光的抖动
  614. int l, h, m, match;
  615. i64_t exp;
  616. i64_t mid;
  617. u32_t again = 1 << gain->again_shift;
  618. match = 0;
  619. if(exposure <= exposure_max)
  620. {
  621. gain->again = analog_gain_table[0];
  622. gain->aindex = 0;
  623. return exposure;
  624. }
  625. if(gain->again_count == 0)
  626. {
  627. gain->again = analog_gain_table[0];
  628. gain->aindex = 0;
  629. return exposure;
  630. }
  631. l = 0;
  632. h = gain->again_count - 1;
  633. if(h < 0)
  634. h = 0;
  635. //h = sizeof(analog_gain_table)/sizeof(analog_gain_table[0]) - 1;
  636. //exp = (i64_t)(1 << gain->again_shift);
  637. //exp = exp * (i64_t)exposure;
  638. exp = exposure;
  639. while(l <= h)
  640. {
  641. m = (l + h) >> 1;
  642. mid = analog_gain_table[m];
  643. mid = mid * (i64_t)exposure_max;
  644. mid = div_s64(mid, again);
  645. // 寻找满足 mid <= exp的最大m
  646. if(mid < exp)
  647. {
  648. if(m > match)
  649. match = m;
  650. // 需增大模拟增益
  651. l = m + 1;
  652. }
  653. else if(mid > exp)
  654. {
  655. // 需减小模拟增益
  656. h = m - 1;
  657. }
  658. else
  659. {
  660. // mid == exp
  661. match = m;
  662. break;
  663. }
  664. }
  665. m = match;
  666. gain->again = analog_gain_table[m];
  667. gain->aindex = (u16_t)m;
  668. //return (u32_t)(exp / analog_gain_table[m]);
  669. exp = exp * (i64_t)again;
  670. exp = div_s64(exp, analog_gain_table[m]);
  671. return (u32_t)exp;
  672. }
  673. // 根据曝光量计算数字增益
  674. // 数字增益
  675. static u32_t digital_gain_from_exposure_calculate (cmos_gain_ptr_t gain, u32_t exposure, u32_t exposure_max)
  676. {
  677. int l, h, m, match;
  678. i64_t exp;
  679. i64_t mid;
  680. u32_t dgain = 1 << gain->dgain_shift;
  681. match = 0;
  682. if(exposure <= exposure_max)
  683. {
  684. gain->dgain = digital_gain_table[0];
  685. gain->dindex = 0;
  686. return exposure;
  687. }
  688. if(gain->dgain_count == 0)
  689. {
  690. gain->dgain = digital_gain_table[0];
  691. gain->dindex = 0;
  692. return exposure;
  693. }
  694. l = 0;
  695. h = gain->dgain_count - 1;
  696. if(h < 0)
  697. h = 0;
  698. exp = exposure;
  699. while(l <= h)
  700. {
  701. m = (l + h) >> 1;
  702. mid = digital_gain_table[m];
  703. mid = mid * (i64_t)exposure_max;
  704. mid = div_s64(mid, dgain);
  705. // 寻找满足 mid <= exp的最大m
  706. if(mid < exp)
  707. {
  708. if(m > match)
  709. match = m;
  710. // 需增大模拟增益
  711. l = m + 1;
  712. }
  713. else if(mid > exp)
  714. {
  715. // 需减小模拟增益
  716. h = m - 1;
  717. }
  718. else
  719. {
  720. // mid == exp
  721. match = m;
  722. break;
  723. }
  724. }
  725. m = match;
  726. gain->dgain = digital_gain_table[m];
  727. gain->dindex = (u16_t)m;
  728. //return (u32_t)(exp / analog_gain_table[m]);
  729. exp = exp * (i64_t)dgain;
  730. exp = div_s64(exp, digital_gain_table[m]);
  731. return (u32_t)exp;
  732. }
  733. static u32_t last_exp_time, last_again, last_dgain;
  734. static void cmos_inttime_gain_reset (void)
  735. {
  736. last_exp_time = 0xFFFFFFFF;
  737. last_again = 0xFFFFFFFF;
  738. last_dgain = 0xFFFFFFFF;
  739. }
  740. // 返回值表示延迟指定的时间以便等待sensor曝光参数产生作用
  741. // 1 表示下一帧sensor曝光参数产生影响
  742. // 2 表示延迟1帧sensor曝光参数产生影响
  743. // 3 表示延迟2帧sensor曝光参数产生影响
  744. static int cmos_inttime_gain_update (cmos_inttime_ptr_t p_inttime, cmos_gain_ptr_t gain)
  745. {
  746. u16_t exp_time;
  747. if(p_inttime)
  748. {
  749. exp_time = (u16_t)p_inttime->exposure_ashort;
  750. if(exp_time < 2)
  751. exp_time = 2;
  752. //arkn141_isp_cmos_sensor_write_register (0xfe, 0x00 ) ; // Page 0
  753. arkn141_isp_cmos_sensor_write_register (0x03, (u8_t)((exp_time >> 8) & 0x3F) ); // P0:0x03 Exposure [13:8]
  754. arkn141_isp_cmos_sensor_write_register (0x04, (u8_t)(exp_time ) ); //P0:0x04 Exposure [7:0]
  755. }
  756. if(gain)
  757. {
  758. cmos_gain_update (gain);
  759. }
  760. // 返回值表示延迟指定的时间以便等待sensor曝光参数产生作用
  761. // 1 表示下一帧sensor曝光参数产生影响
  762. // 2 表示延迟1帧sensor曝光参数产生影响
  763. // 3 表示延迟2帧sensor曝光参数产生影响
  764. return 2;
  765. }
  766. static void cmos_inttime_gain_update_manual (cmos_inttime_ptr_t p_inttime, cmos_gain_ptr_t gain)
  767. {
  768. u16_t exp_time;
  769. u16_t shutter_sweep_line_count;
  770. int i, aindex, dindex;
  771. // 猫庐隆莽庐鈥攁index, dindex
  772. for (i = 0; i < gain->again_count; i++)
  773. {
  774. if(analog_gain_table[i] >= gain->again)
  775. break;
  776. }
  777. if(i == gain->again_count)
  778. i = gain->again_count - 1;
  779. aindex = i;
  780. gain->aindex = aindex;
  781. gain->again_lookup = i;
  782. for (i = 0; i < gain->dgain_count; i++)
  783. {
  784. if(digital_gain_table[i] >= gain->dgain)
  785. break;
  786. }
  787. if(i == gain->dgain_count)
  788. i = gain->dgain_count - 1;
  789. dindex = i;
  790. gain->dindex = dindex;
  791. if(p_inttime->exposure_ashort >= (FRM_LENGTH - 2))
  792. p_inttime->exposure_ashort = (FRM_LENGTH - 2);
  793. cmos_inttime_gain_update (p_inttime, gain);
  794. }
  795. static u32_t cmos_get_iso (cmos_gain_ptr_t gain)
  796. {
  797. i64_t iso = gain->again * gain->dgain;
  798. iso = (iso * 100) >> (gain->again_shift + gain->dgain_shift);
  799. gain->iso = (u32_t)iso;
  800. return gain->iso;
  801. }
  802. static void cmos_fps_set (cmos_inttime_ptr_t p_inttime, u8_t fps)
  803. {
  804. switch (fps)
  805. {
  806. case 30:
  807. default:
  808. p_inttime->full_lines = FRM_LENGTH; //STD_30_LINES;
  809. p_inttime->lines_per_500ms = FRM_LENGTH * 30 / 2; //STD_30_LINES * 30 / 2;
  810. break;
  811. }
  812. }
  813. // 设置sensor readout drection
  814. // horz_reverse_direction --> 1 horz reverse direction 垂直反向
  815. // --> 0 horz normal direction
  816. // vert_reverse_direction --> 1 vert reverse direction 水平反向
  817. // --> 0 vert normal direction
  818. static int cmos_sensor_set_readout_direction (u8_t horz_reverse_direction, u8_t vert_reverse_direction)
  819. {
  820. return 0;
  821. }
  822. static const char *gc2053_cmos_sensor_get_sensor_name (void)
  823. {
  824. return "GC2053";
  825. }
  826. extern void isp_sensor_set_reset_pin_low (void);
  827. extern void isp_sensor_set_reset_pin_high (void);
  828. extern int gc2053_init_25fps_10bit (void);
  829. extern int gc2053_init_30fps_10bit (void);
  830. static int gc2053_isp_sensor_init(isp_sen_ptr_t p_sen)
  831. {
  832. int ret = 0;
  833. int loop = 10;
  834. int video_format = ARKN141_VIDEO_FORMAT_1080P_30;
  835. if( video_format == ARKN141_VIDEO_FORMAT_1080P_30
  836. )
  837. {
  838. }
  839. else
  840. {
  841. // un-support video format
  842. XM_printf ("un-support video format (%d)\n", video_format );
  843. return -1;
  844. }
  845. while(loop > 0)
  846. {
  847. // tLOW >= 500ns
  848. isp_sensor_set_reset_pin_low ();
  849. mdelay (5);
  850. isp_sensor_set_reset_pin_high ();
  851. mdelay (2);
  852. cmos_inttime_gain_reset ();
  853. if (isp_sensor_fps == 30)
  854. ret = gc2053_init_30fps_10bit ();
  855. else
  856. ret = gc2053_init_25fps_10bit ();
  857. if(ret == 0)
  858. {
  859. //cmos_sensor_set_readout_direction (1, 1);
  860. }
  861. if(ret == 0)
  862. break;
  863. loop --;
  864. }
  865. if(loop == 0)
  866. {
  867. ret = -1;
  868. XM_printf ("gc2053 init video format(%d) NG\n", video_format);
  869. }
  870. else
  871. {
  872. ret = 0;
  873. XM_printf ("gc2053 init video format(%d) OK\n", video_format);
  874. }
  875. return ret;
  876. }
  877. static void gc2053_cmos_isp_awb_init (isp_awb_ptr_t p_awb) // 白平衡初始参数
  878. {
  879. //p_awb->enable = 0;
  880. p_awb->enable = 1;
  881. p_awb->mode = 1; //0:无效; 1:算法1,统一估计; 2:算法2,基于参考光源
  882. p_awb->manual = 0;//0=自动白平衡 1=手动白平衡
  883. p_awb->weight[0][0] = 1;
  884. p_awb->weight[0][1] = 2;
  885. p_awb->weight[0][2] = 1;
  886. p_awb->weight[1][0] = 2;
  887. p_awb->weight[1][1] = 4;
  888. p_awb->weight[1][2] = 2;
  889. p_awb->weight[2][0] = 1;
  890. p_awb->weight[2][1] = 2;
  891. p_awb->weight[2][2] = 1;
  892. //p_awb->black = 4;
  893. p_awb->black = 16;
  894. p_awb->white = 210;
  895. p_awb->jitter = 13;
  896. p_awb->r2g_min = 256/4;
  897. p_awb->r2g_max = 256*4;
  898. p_awb->b2g_min = 256/4;
  899. p_awb->b2g_max = 256*4;
  900. // G/R, G/B,
  901. #if 0
  902. p_awb->r2g_light[0] = 182; // DAY
  903. p_awb->b2g_light[0] = 203;
  904. p_awb->r2g_light[1] = 194; // CWF
  905. p_awb->b2g_light[1] = 158;
  906. p_awb->r2g_light[2] = 222; // A
  907. p_awb->b2g_light[2] = 131;
  908. p_awb->r2g_light[3] = 246; // TL84
  909. p_awb->b2g_light[3] = 154;
  910. #else
  911. p_awb->r2g_light[0] = 120; // 自然光 //old:117
  912. p_awb->b2g_light[0] = 153; //old:158
  913. p_awb->r2g_light[1] = 127; // DAY //old:124
  914. p_awb->b2g_light[1] = 161; //old:162
  915. p_awb->r2g_light[2] = 155; // CWF //old:151
  916. p_awb->b2g_light[2] = 96; //old:98
  917. p_awb->r2g_light[3] = 208; // A //old:206
  918. p_awb->b2g_light[3] = 83; //old:82
  919. p_awb->r2g_light[4] = 241; // TL84 //old:232
  920. p_awb->b2g_light[4] = 83; //old:83
  921. #endif
  922. p_awb->r2g_light[5] = 0;
  923. p_awb->b2g_light[5] = 0;
  924. p_awb->r2g_light[6] = 0;
  925. p_awb->b2g_light[6] = 0;
  926. p_awb->r2g_light[7] = 0;
  927. p_awb->b2g_light[7] = 0;
  928. p_awb->use_light[0] = 1;
  929. p_awb->use_light[1] = 1;
  930. p_awb->use_light[2] = 1;
  931. p_awb->use_light[3] = 1;
  932. p_awb->use_light[4] = 1;
  933. p_awb->use_light[5] = 0;
  934. p_awb->use_light[6] = 0;
  935. p_awb->use_light[7] = 0;
  936. p_awb->gain_g2r = 426;//434;
  937. p_awb->gain_g2b = 280;//348;
  938. isp_awb_init_io (p_awb);
  939. }
  940. static isp_gamma_polyline_tbl gamma_polyline_tbl[] = {
  941. // 提升场景的对比度
  942. { 128,
  943. {
  944. 0, 140, 336, 588, 896, 1260, 1680, 2156,
  945. 2688, 3276, 3920, 4620, 5376, 6188, 7056, 7980,
  946. 8960, 9996, 11088, 12236, 13440, 14700, 16016, 17388,
  947. 18816, 20300, 21840, 23436, 25088, 26796, 28560, 30380,
  948. 32256, 34644, 36464, 38228, 39936, 41588, 43184, 44724,
  949. 46208, 47636, 49008, 50324, 51584, 52788, 53936, 55028,
  950. 56064, 57044, 57968, 58836, 59648, 60404, 61104, 61748,
  951. 62336, 62868, 63344, 63764, 64128, 64436, 64688, 64884,
  952. 65024
  953. }
  954. },
  955. };
  956. static const isp_gamma_polyline_tbl *gc2053_cmos_isp_get_gamma_table (int *tbl_count)
  957. {
  958. *tbl_count = sizeof(gamma_polyline_tbl)/sizeof(gamma_polyline_tbl[0]);
  959. return gamma_polyline_tbl;
  960. }
  961. static void gc2053_cmos_isp_colors_init (isp_colors_ptr_t p_colors) // 色彩初始参数
  962. {
  963. int i, j;
  964. p_colors->colorm.enable = 0;// 色矩阵
  965. p_colors->colorm.matrixcoeff[0][0] = 256;
  966. p_colors->colorm.matrixcoeff[0][1] = 0;
  967. p_colors->colorm.matrixcoeff[0][2] = 0;
  968. p_colors->colorm.matrixcoeff[1][0] = 0;
  969. p_colors->colorm.matrixcoeff[1][1] = 256;
  970. p_colors->colorm.matrixcoeff[1][2] = 0;
  971. p_colors->colorm.matrixcoeff[2][0] = 0;
  972. p_colors->colorm.matrixcoeff[2][1] = 0;
  973. p_colors->colorm.matrixcoeff[2][2] = 256;
  974. p_colors->gamma.enable = 1;
  975. for (i = 0; i < 65; i++)
  976. {
  977. p_colors->gamma.gamma_lut[i] = gamma_polyline_tbl[0].gamma_lut[i];
  978. }
  979. // 使用0~255范围, 尽量保留所有的细节
  980. p_colors->rgb2ypbpr_type = HDTV_type_0255;
  981. isp_create_rgb2ycbcr_matrix (p_colors->rgb2ypbpr_type, &p_colors->rgb2yuv);
  982. // demosaic 参数
  983. p_colors->demosaic.mode = 0;
  984. p_colors->demosaic.coff_00_07 = 32;
  985. p_colors->demosaic.coff_20_27 = 255; // 滤波
  986. p_colors->demosaic.horz_thread = 0;
  987. //p_colors->demosaic.demk = 128;
  988. p_colors->demosaic.demk = 512; // 20161230 改善解析度(树叶,纹理)
  989. p_colors->demosaic.demDhv_ofst = 0;
  990. isp_colors_init_io(p_colors);
  991. }
  992. static const unsigned char noise0_0[17] = {
  993. 255, 255, 255, 255,
  994. 255, 248, 240, 212,
  995. 212, 212, 212, 212,
  996. 212, 212, 212, 212,
  997. 212
  998. };
  999. static const unsigned char noise1_0[17] = {
  1000. 255, 255, 255, 255,
  1001. 255, 248, 240, 212,
  1002. 192, 160, 144, 128,
  1003. 128, 128, 128, 128,
  1004. 128
  1005. };
  1006. static void gc2053_cmos_isp_denoise_init (isp_denoise_ptr_t p_denoise)// 降噪初始设置
  1007. {
  1008. int i, x0, y0, x1, y1, x2, y2, x3, y3;
  1009. int a, b, c, d, e, f, delta;
  1010. p_denoise->enable2d = 7;
  1011. if(isp_get_work_mode() == ISP_WORK_MODE_NORMAL)
  1012. {
  1013. #if ISP_3D_DENOISE_SUPPORT
  1014. p_denoise->enable3d = 7;
  1015. #else
  1016. p_denoise->enable3d = 0;
  1017. #endif
  1018. }
  1019. else
  1020. {
  1021. p_denoise->enable3d = 0;
  1022. }
  1023. //p_denoise->sensitiv0 = 4;
  1024. //p_denoise->sensitiv1 = 4;
  1025. p_denoise->sensitiv0 = 3; // 降低降噪强度, 提升清晰度
  1026. p_denoise->sensitiv1 = 3;
  1027. p_denoise->sel_3d_table = 3; // 3的降噪效果较好
  1028. p_denoise->sel_3d_matrix = 1;
  1029. p_denoise->y_thres0 = 6;
  1030. p_denoise->u_thres0 = 10;
  1031. p_denoise->v_thres0 = 10;
  1032. p_denoise->y_thres1 = 6;
  1033. p_denoise->u_thres1 = 10;
  1034. p_denoise->v_thres1 = 10;
  1035. p_denoise->y_thres2 = 6;
  1036. p_denoise->u_thres2 = 11;
  1037. p_denoise->v_thres2 = 11;
  1038. for (i = 0; i <= 16; i ++)
  1039. {
  1040. p_denoise->noise0[i] = noise0_0[i];
  1041. }
  1042. for (i = 0; i <= 16; i ++)
  1043. {
  1044. p_denoise->noise1[i] = noise1_0[i];
  1045. }
  1046. isp_denoise_init_io (p_denoise);
  1047. }
  1048. // 20170227 增加场景的解析度拉伸, 增加通透度, 增加低照度场景的解析度
  1049. static const unsigned char gc2053_default_resolt[33] = {
  1050. 200, 210, 215, 220, 225, 227,
  1051. 230, 230, 233, 235, 235, 235,
  1052. 235, 235, 235, 235, 235, 235,
  1053. 235, 235, 235, 235, 235, 235,
  1054. 235, 235, 235, 235, 235, 230,
  1055. 225, 220, 220,
  1056. };
  1057. #define ERIS_COLORT_1 1
  1058. #if ERIS_COLORT_1
  1059. static const unsigned int gc2053_default_colort_old[33] = {
  1060. 64, 128, 192, 256, 320, 384, 511, 511,
  1061. 511, 511, 511, 511, 511, 511, 511, 511,
  1062. 511, 511, 511, 511, 511, 511, 511, 511,
  1063. 511, 511, 511, 511, 448, 384, 256, 192,
  1064. 128
  1065. };
  1066. static const unsigned int gc2053_default_colort[33] = {
  1067. 64, 128, 192, 256, 272, 320, 384, 384,
  1068. 384, 384, 384, 384, 384, 384, 384, 384,
  1069. 384, 384, 384, 384, 384, 384, 384, 384,
  1070. 384, 384, 384, 384, 320, 272, 256, 192,
  1071. 128
  1072. };
  1073. #else
  1074. /*
  1075. static unsigned int gc2053_default_colort[33] = {
  1076. 1, 1, 1, 1, 1, 1, 1, 1,
  1077. 16, 24, 32, 40, 64, 80, 96, 112,
  1078. 128, 160, 212, 256, 256, 256, 256, 256,
  1079. 256, 256, 256, 256, 256, 256, 256, 256,
  1080. 128
  1081. };*/
  1082. static const unsigned int gc2053_default_colort_1[33] = {
  1083. 32, 38, 44, 50, 56, 62,
  1084. 68, 74, 80, 86, 92, 98,
  1085. 104, 110, 116, 122, 128, 152,
  1086. 176, 200, 224, 248, 272, 296,
  1087. 320, 343, 367, 391, 415, 439,
  1088. 463, 487, 511,
  1089. };
  1090. static const unsigned int gc2053_default_colort[33] = {
  1091. 8, 8, 8, 8, 8, 8,
  1092. 16, 16, 16, 16, 16, 16,
  1093. 32, 32, 32, 32, 32, 48,
  1094. 48, 48, 48, 64, 64, 96,
  1095. 96, 64, 64, 48, 48, 48,
  1096. 32, 32, 32,
  1097. };
  1098. #endif
  1099. static void gc2053_cmos_isp_eris_init(isp_eris_ptr_t p_eris) // 宽动态初始设置
  1100. {
  1101. int i, j, x0, y0, x1, y1, x2, y2;
  1102. int a, b, c, d;
  1103. p_eris->enable = 1;
  1104. #if ERIS_MANUAL
  1105. p_eris->manual = 1;
  1106. #else
  1107. p_eris->manual = 0;
  1108. #endif
  1109. p_eris->target = 128;
  1110. p_eris->black = 12;
  1111. // 10bit使用D2~D11, D0~D1固定为0
  1112. //if(isp_get_sensor_bit() == ARKN141_ISP_SENSOR_BIT_12)
  1113. // p_eris->white = 4095; // 尽可能保留动态范围
  1114. //else
  1115. p_eris->white = 1023; // 尽可能保留动态范围
  1116. p_eris->gain_max = 256; //256;
  1117. //p_eris->gain_max = 128; //256;
  1118. //p_eris->gain_min = 64; //256;
  1119. p_eris->gain_min = 16;
  1120. //p_eris->gain_man = 256;
  1121. p_eris->gain_man = 360;
  1122. p_eris->cont_max = 256; // 2*64;
  1123. p_eris->cont_min = 64; // 6*64;
  1124. p_eris->cont_man = 16;
  1125. p_eris->dfsEris = 1;
  1126. p_eris->varEris = 0;
  1127. p_eris->resols = 0;
  1128. p_eris->resoli = 0;
  1129. p_eris->spacev = 0;
  1130. for (i = 0; i < 33; i++)
  1131. {
  1132. p_eris->resolt[i] = gc2053_default_resolt[i];
  1133. }
  1134. for (i = 0; i < 33; i++)
  1135. {
  1136. // p_eris->colort[i] = 512;
  1137. p_eris->colort[i] = gc2053_default_colort[i];
  1138. }
  1139. // ERIS直方图初始设置
  1140. // u8_t hist_thresh[4] = {0x10, 0x40, 0x80, 0xc0};
  1141. p_eris->eris_hist_thresh[0] = 0x10;
  1142. p_eris->eris_hist_thresh[1] = 0x40;
  1143. p_eris->eris_hist_thresh[2] = 0x80;
  1144. p_eris->eris_hist_thresh[3] = 0xC0;
  1145. isp_eris_init_io(p_eris);
  1146. }
  1147. #if 1
  1148. const unsigned short lenscoeff[]=
  1149. {
  1150. // r
  1151. 4096,4315,4322,4317,4331, 4339,4355,4361,4406,4443,
  1152. 4467,4466,4485,4519,4552, 4591,4648,4702,4771,4847,
  1153. 4923,5001,5125,5242,5373, 5518,5694,5885,6047,6230,
  1154. 6416,6597,6821,7055,7305, 7481,7799,7799,7799,7799,
  1155. 7799,7799,7799,7799,7799, 7799,7799,7799,7799,7799,
  1156. 7799,7799,7799,7799,7799, 7799,7799,7799,7799,7799,
  1157. 7799,7799,7799,7799,7799,
  1158. // g
  1159. 4096,4315,4322,4317,4331, 4339,4355,4361,4406,4443,
  1160. 4467,4466,4485,4519,4552, 4591,4648,4702,4771,4847,
  1161. 4923,5001,5125,5242,5373, 5518,5694,5885,6047,6230,
  1162. 6416,6597,6821,7055,7305, 7481,7799,7799,7799,7799,
  1163. 7799,7799,7799,7799,7799, 7799,7799,7799,7799,7799,
  1164. 7799,7799,7799,7799,7799, 7799,7799,7799,7799,7799,
  1165. 7799,7799,7799,7799,7799,
  1166. // b
  1167. 4096,4315,4322,4317,4331, 4339,4355,4361,4406,4443,
  1168. 4467,4466,4485,4519,4552, 4591,4648,4702,4771,4847,
  1169. 4923,5001,5125,5242,5373, 5518,5694,5885,6047,6230,
  1170. 6416,6597,6821,7055,7305, 7481,7799,7799,7799,7799,
  1171. 7799,7799,7799,7799,7799, 7799,7799,7799,7799,7799,
  1172. 7799,7799,7799,7799,7799, 7799,7799,7799,7799,7799,
  1173. 7799,7799,7799,7799,7799,
  1174. };
  1175. #else
  1176. const unsigned short lenscoeff[]=
  1177. {
  1178. // r
  1179. 4096,4320,4335,4340,4351, 4368,4406,4442,4459,4467,
  1180. 4480,4510,4555,4594,4642, 4692,4750,4812,4883,4954,
  1181. 5109,5281,5463,5681,5900, 6172,6449,6789,7057,7387,
  1182. 7728,8106,8602,9000,9362, 9471,9826,10479,10479,10479,
  1183. 10479,10479,10479,10479,10479,10479,10479,10479,10479,10479,
  1184. 10479,10479,10479,10479,10479,10479,10479,10479,10479,10479,
  1185. 10479,10479,10479,10479,10479,
  1186. // g
  1187. 4096,4320,4335,4340,4351, 4368,4406,4442,4459,4467,
  1188. 4480,4510,4555,4594,4642, 4692,4750,4812,4883,4954,
  1189. 5109,5281,5463,5681,5900, 6172,6449,6789,7057,7387,
  1190. 7728,8106,8602,9000,9362, 9471,9826,10479,10479,10479,
  1191. 10479,10479,10479,10479,10479,10479,10479,10479,10479,10479,
  1192. 10479,10479,10479,10479,10479,10479,10479,10479,10479,10479,
  1193. 10479,10479,10479,10479,10479,
  1194. // b
  1195. 4096,4320,4335,4340,4351, 4368,4406,4442,4459,4467,
  1196. 4480,4510,4555,4594,4642, 4692,4750,4812,4883,4954,
  1197. 5109,5281,5463,5681,5900, 6172,6449,6789,7057,7387,
  1198. 7728,8106,8602,9000,9362, 9471,9826,10479,10479,10479,
  1199. 10479,10479,10479,10479,10479,10479,10479,10479,10479,10479,
  1200. 10479,10479,10479,10479,10479,10479,10479,10479,10479,10479,
  1201. 10479,10479,10479,10479,10479,
  1202. };
  1203. #endif
  1204. #define Ycenter_x 960
  1205. #define Ycenter_y 540
  1206. #define CenterRx Ycenter_x
  1207. #define CenterRy Ycenter_y
  1208. #define CenterGx Ycenter_x
  1209. #define CenterGy Ycenter_y
  1210. #define CenterBx Ycenter_x
  1211. #define CenterBy Ycenter_y
  1212. static void gc2053_cmos_isp_fesp_init(isp_fesp_ptr_t p_fesp) // 镜头校正, fix-pattern-correction, 坏点去除初始设置
  1213. {
  1214. int i, j, k;
  1215. int x0, y0, x1, y1, x2, y2, x3, y3;
  1216. int a, b, c, d, e, f, delta;
  1217. // unsigned short R_lenslut[65];
  1218. // unsigned short G_lenslut[65];
  1219. // unsigned short B_lenslut[65];
  1220. // unsigned short Y_lenslut[65];
  1221. p_fesp->Lensshade.enable = 0;
  1222. p_fesp->Lensshade.scale = 1;
  1223. p_fesp->Lensshade.lscofst = 50;
  1224. p_fesp->Lensshade.rcenterRx = CenterRx;
  1225. p_fesp->Lensshade.rcenterRy = CenterRy;
  1226. p_fesp->Lensshade.rcenterGx = CenterRx;
  1227. p_fesp->Lensshade.rcenterGy = CenterRy;
  1228. p_fesp->Lensshade.rcenterBx = CenterRx;
  1229. p_fesp->Lensshade.rcenterBy = CenterRy;
  1230. for( i=0 ; i < 195 ;i++ )
  1231. {
  1232. p_fesp->Lensshade.coef[i] = lenscoeff[i];
  1233. }
  1234. // fix pattern correction
  1235. p_fesp->Fixpatt.enable = 1;
  1236. p_fesp->Fixpatt.mode = 0;
  1237. p_fesp->Fixpatt.rBlacklevel = 0x40;
  1238. p_fesp->Fixpatt.grBlacklevel = 0x40;
  1239. p_fesp->Fixpatt.gbBlacklevel = 0x40;
  1240. p_fesp->Fixpatt.bBlacklevel = 0x40;
  1241. p_fesp->Fixpatt.profile[0] = 255;
  1242. p_fesp->Fixpatt.profile[1] = 255;
  1243. p_fesp->Fixpatt.profile[2] = 255;
  1244. p_fesp->Fixpatt.profile[3] = 255;
  1245. p_fesp->Fixpatt.profile[4] = 255;
  1246. p_fesp->Fixpatt.profile[5] = 255;
  1247. p_fesp->Fixpatt.profile[6] = 255;
  1248. p_fesp->Fixpatt.profile[7] = 255;
  1249. p_fesp->Fixpatt.profile[8] = 255;
  1250. p_fesp->Fixpatt.profile[9] = 255;
  1251. p_fesp->Fixpatt.profile[10] = 255;
  1252. p_fesp->Fixpatt.profile[11] = 255;
  1253. p_fesp->Fixpatt.profile[12] = 255;
  1254. p_fesp->Fixpatt.profile[13] = 255;
  1255. p_fesp->Fixpatt.profile[14] = 255;
  1256. p_fesp->Fixpatt.profile[15] = 255;
  1257. p_fesp->Fixpatt.profile[16] = 255;
  1258. // bad pixel correction
  1259. p_fesp->Badpix.enable = 1;
  1260. p_fesp->Badpix.mode = 0;
  1261. p_fesp->Badpix.thresh = 19; // IMX322 实测最低坏点判断阈值
  1262. p_fesp->Badpix.profile[0] = 255;
  1263. p_fesp->Badpix.profile[1] = 255;
  1264. p_fesp->Badpix.profile[2] = 255;
  1265. p_fesp->Badpix.profile[3] = 255;
  1266. p_fesp->Badpix.profile[4] = 255;
  1267. p_fesp->Badpix.profile[5] = 255;
  1268. p_fesp->Badpix.profile[6] = 255;
  1269. p_fesp->Badpix.profile[7] = 255;
  1270. p_fesp->Badpix.profile[8] = 255;
  1271. p_fesp->Badpix.profile[9] = 255;
  1272. p_fesp->Badpix.profile[10] = 255;
  1273. p_fesp->Badpix.profile[11] = 255;
  1274. p_fesp->Badpix.profile[12] = 255;
  1275. p_fesp->Badpix.profile[13] = 255;
  1276. p_fesp->Badpix.profile[14] = 255;
  1277. p_fesp->Badpix.profile[15] = 255;
  1278. // cross talk correction
  1279. // cross talk的阈值越大, 图像越模糊. 8是一个较合适的值.
  1280. // 使用3D降噪来去除噪声
  1281. p_fesp->Crosstalk.enable = 1;
  1282. p_fesp->Crosstalk.mode = 1;
  1283. p_fesp->Crosstalk.thresh = 10;
  1284. p_fesp->Crosstalk.snsCgf = 3; // 值越大, 滤除奇异点的能力越大.
  1285. p_fesp->Crosstalk.thres0cgf = 10;
  1286. p_fesp->Crosstalk.thres1cgf = 10;
  1287. p_fesp->Crosstalk.profile[0] = 255;
  1288. p_fesp->Crosstalk.profile[1] = 255;
  1289. p_fesp->Crosstalk.profile[2] = 255;
  1290. p_fesp->Crosstalk.profile[3] = 243;
  1291. p_fesp->Crosstalk.profile[4] = 243;
  1292. p_fesp->Crosstalk.profile[5] = 243;
  1293. p_fesp->Crosstalk.profile[6] = 243;
  1294. p_fesp->Crosstalk.profile[7] = 243;
  1295. p_fesp->Crosstalk.profile[8] = 232;
  1296. p_fesp->Crosstalk.profile[9] = 232;
  1297. p_fesp->Crosstalk.profile[10] = 232;
  1298. p_fesp->Crosstalk.profile[11] = 232;
  1299. p_fesp->Crosstalk.profile[12] = 232;
  1300. p_fesp->Crosstalk.profile[13] = 212;
  1301. p_fesp->Crosstalk.profile[14] = 212;
  1302. p_fesp->Crosstalk.profile[15] = 212;
  1303. p_fesp->Crosstalk.profile[16] = 212;
  1304. isp_fesp_init_io (p_fesp);
  1305. }
  1306. #define SATUATION_OFFSET 64 // 饱和度补偿
  1307. static void gc2053_cmos_isp_enhance_init (isp_enhance_ptr_t p_enhance) // 图像增强初始设置
  1308. {
  1309. p_enhance->sharp.enable = 1;
  1310. p_enhance->sharp.mode = 0;
  1311. p_enhance->sharp.coring = 0;// 0-7
  1312. //p_enhance->sharp.strength = 64;//64;//32;//128;
  1313. //p_enhance->sharp.strength = 32;
  1314. p_enhance->sharp.strength = 255;
  1315. //p_enhance->sharp.strength = 196;
  1316. //p_enhance->sharp.gainmax = 256;
  1317. //p_enhance->sharp.gainmax = 128; // 20170223 盲驴庐忙鈥澛姑ぢ嘎好�铰幻ヂ韭��♀€灻┾€澛惷ヅ掆€�
  1318. //p_enhance->sharp.gainmax = 144; // 20170305 氓戮庐猫掳茠, 氓垄啪氓艩聽盲赂鈧�р€毬�,
  1319. //p_enhance->sharp.gainmax = 160; // 20170803莽鈩⒙矫ヂぢ┟�仿�β碘€姑�♀€灻�р€犆┞⑩€樏�铰γр€芭捗�♀€灻��€犆ニ喡�β�€澝���ぢ糕偓莽沤掳氓艙潞0330莽篓聧氓路庐, 氓垄啪氓艩聽茅鈥澛惷ヅ掆€撁�ㄢ€姑ヂ郝γ︹€澛姑モ€撯€灻��€犆ニ喡�ヂ郝�
  1320. p_enhance->sharp.gainmax = 255; // 20170805忙聽鹿忙聧庐20170804猫路炉忙碌鈥姑�烩€溍ε九�,猫陆娄莽鈥芭捗�韭���€犆ヂ郝γ�酒�0330莽篓聧氓路庐,
  1321. // 茅鈧�∶�库€∶ニ嗏€犆ε韭惷�р€犆┞⑩€�, 莽卢卢盲赂鈧��铰懊ヅ撀�(0330)莽拧鈥灻┾€澛惷ヅ掆€撁ヂ郝γ�酒捗┞��, 忙聫聬氓聧鈥∶┾€澛惷ヅ掆€撁ヂ⑴久р€号犆ㄢ€÷�256
  1322. p_enhance->bcst.enable = 1;
  1323. //p_enhance->bcst.bright = -24; // -256~255
  1324. p_enhance->bcst.bright = 0; // -256~255
  1325. p_enhance->bcst.contrast = 1024;//1024; // 0~1.xxx
  1326. p_enhance->bcst.satuation = 1024 + SATUATION_OFFSET; //0~1.xxx
  1327. // p_enhance->bcst.hue = 0; // -128~127
  1328. p_enhance->bcst.hue = 0;
  1329. p_enhance->bcst.offset0 = 0; // 0~255
  1330. p_enhance->bcst.offset1 = 128; // 0~255
  1331. //p_enhance->bcst.offset1 = 116; // 0~255
  1332. isp_enhance_init_io (p_enhance);
  1333. }
  1334. static void gc2053_cmos_isp_ae_init (isp_ae_ptr_t p_ae) // 自动曝光初始设置
  1335. {
  1336. p_ae->histoBand[0] = 0x10;
  1337. p_ae->histoBand[1] = 0x40;
  1338. p_ae->histoBand[2] = 0x80;
  1339. p_ae->histoBand[3] = 0xc0;
  1340. p_ae->winWeight[0][0] = 1;
  1341. p_ae->winWeight[0][1] = 2;
  1342. p_ae->winWeight[0][2] = 1;
  1343. p_ae->winWeight[1][0] = 6;
  1344. p_ae->winWeight[1][1] = 14;
  1345. p_ae->winWeight[1][2] = 6;
  1346. p_ae->winWeight[2][0] = 12;
  1347. p_ae->winWeight[2][1] = 15;
  1348. p_ae->winWeight[2][2] = 12;
  1349. //p_ae->bright_target = 10;
  1350. p_ae->bright_target = AE_BRIGHT_TARGET_DEFAULT;
  1351. //p_ae->bright_target = 26;
  1352. p_ae->black_target = 128;
  1353. p_ae->compensation = AE_COMPENSATION_DEFAULT;
  1354. }
  1355. static void gc2053_cmos_isp_sys_init (isp_sys_ptr_t p_sys, isp_param_ptr_t p_isp) // 系统初始设置 (sensor pixel位数, bayer mode)
  1356. {
  1357. p_sys->ispenbale = 0;
  1358. p_sys->ckpolar = 0;
  1359. p_sys->vcpolar = 0;
  1360. p_sys->hcpolar = 0;
  1361. p_sys->vmskenable = 0; // 自动丢帧. 保留,必须设置为0
  1362. p_sys->frameratei = 0;
  1363. p_sys->framerateo = 0; // 保留,必须设置为0
  1364. #if 0
  1365. p_sys->frameratei = 30;
  1366. p_sys->framerateo = 0; // 保留,必须设置为0
  1367. p_sys->vifrasel0 = 0xAAAAAAAA;
  1368. p_sys->vifrasel1 = 0;
  1369. #else
  1370. p_sys->frameratei = 0;
  1371. p_sys->framerateo = 0;
  1372. p_sys->vifrasel0 = 0;
  1373. p_sys->vifrasel1 = 0;
  1374. #endif
  1375. // IN/OUT (60帧/55帧, ),
  1376. #if 0
  1377. p_sys->frameratei = 64;
  1378. p_sys->framerateo = 64;
  1379. p_sys->vifrasel0 = 0xFFFFFFFF; // 29
  1380. // p_sys->vifrasel1 = 0x07FFEFFE; // 25
  1381. p_sys->vifrasel1 = 0xFFFFFFFF; // 22
  1382. #endif
  1383. // IN/OUT (1帧/1帧)
  1384. // p_sys->frameratei = 0;
  1385. // p_sys->vifrasel0 = 0x00000000;
  1386. // p_sys->vifrasel1 = 0x00000000;
  1387. //(0.表示8位 1:表示10位 2:表示12位 3:表示14位)
  1388. //XM_printf("sensor bit: 0:8bit 1:10bit 2:12bit 3:14bit \n");
  1389. p_sys->sensorbit = ARKN141_ISP_SENSOR_BIT_10;
  1390. // 0:RGGB 1:GRBG 2:BGGR 3:GBRG
  1391. //XM_printf("bayer mode: 0:RGGB 1:GRBG 2:BGGR 3:GBRG \n");
  1392. //p_sys->bayermode = ARKN141_ISP_RAW_IMAGE_BAYER_MODE_BGGR;
  1393. p_sys->bayermode = ARKN141_ISP_RAW_IMAGE_BAYER_MODE_RGGB;
  1394. p_sys->imagewidth = p_isp->image_width;
  1395. p_sys->imageheight = p_isp->image_height;
  1396. // imagehblank, zonestridex, zonestridey 是以ISP Core的时钟为计数基准,
  1397. // 计算时首先按照Sensor Pixel Clock时序进行计算, 然后换算到ISP Core Clock,
  1398. p_sys->imagehblank = 0;
  1399. p_sys->zonestridex = 0;
  1400. p_sys->zonestridey = 0;
  1401. p_sys->resizebit = 2;
  1402. //使能
  1403. p_sys->vmanSftenable = 0;
  1404. p_sys->vchkIntenable = 1;// 帧开始
  1405. p_sys->pabtIntenable = 1; //点异常
  1406. p_sys->fendIntenable = 1; // 帧完成
  1407. p_sys->fabtIntenable = 1; // 地址异常
  1408. p_sys->babtIntenable = 1; //总线异常
  1409. p_sys->ffiqIntenable = 0; //快中断
  1410. p_sys->pendIntenable = 1; //中止 ,如果一帧未完成,会完成该帧
  1411. p_sys->infoIntenable = 1; // 使能ISP的曝光统计完成中断
  1412. // 设置 场
  1413. p_sys->vmanSftset = 0;
  1414. p_sys->vchkIntclr = 1;
  1415. p_sys->pabtIntclr = 1;
  1416. p_sys->fendIntset = 1;
  1417. p_sys->fendIntclr = 1;
  1418. p_sys->fabtIntclr = 1;
  1419. p_sys->babtIntclr = 1;
  1420. p_sys->ffiqIntclr = 1;
  1421. p_sys->pendIntclr = 1;
  1422. p_sys->infoStaclr = 1;
  1423. p_sys->vchkIntraw = 0;
  1424. p_sys->pabtIntraw = 0;
  1425. p_sys->fendIntraw = 0;
  1426. p_sys->fabtIntraw = 0;
  1427. p_sys->babtIntraw = 0;
  1428. p_sys->ffiqIntraw = 0;
  1429. p_sys->pendIntraw = 0;
  1430. p_sys->vchkIntmsk = 0;
  1431. p_sys->pabtIntmsk = 0;
  1432. p_sys->fendIntmsk = 0;
  1433. p_sys->fabtIntmsk = 0;
  1434. p_sys->babtIntmsk = 0;
  1435. p_sys->ffiqIntmsk = 0;
  1436. p_sys->pendIntmsk = 0;
  1437. p_sys->fendIntid[0] = 0;
  1438. p_sys->fendIntid[1] = 1;
  1439. p_sys->fendIntid[2] = 2;
  1440. p_sys->fendIntid[3] = 3;
  1441. p_sys->ffiqIntdelay = 4;// 快中断
  1442. p_sys->fendStaid = 0;
  1443. p_sys->infoStadone = 0;
  1444. if(isp_get_work_mode() == ISP_WORK_MODE_NORMAL)
  1445. {
  1446. p_sys->debugmode = 0;
  1447. p_sys->testenable = 0; // 开启dram测试模式
  1448. p_sys->rawmenable = 0; // 1 允许RAW写出
  1449. p_sys->yuvenable = 1; // 0:关掉数据输出 1:打开
  1450. #if ISP_3D_DENOISE_SUPPORT
  1451. p_sys->refenable = 1; // 1;3D 参考帧开启 0:关闭
  1452. #else
  1453. p_sys->refenable = 0; // 1;3D 参考帧开启 0:关闭
  1454. #endif
  1455. }
  1456. else if(isp_get_work_mode() == ISP_WORK_MODE_RAW)
  1457. {
  1458. // RAW写出会占用3D参考帧通道
  1459. p_sys->debugmode = 1;
  1460. p_sys->testenable = 0; // 开启dram测试模式
  1461. p_sys->rawmenable = 1; // 1 允许RAW写出
  1462. p_sys->yuvenable = 1; // 0:关掉数据输出 1:打开
  1463. p_sys->refenable = 0; // 1;3D 参考帧开启 0:关闭
  1464. }
  1465. else if(isp_get_work_mode() == ISP_WORK_MODE_AUTOTEST)
  1466. {
  1467. p_sys->debugmode = 1;
  1468. p_sys->testenable = 1; // 开启dram测试模式
  1469. p_sys->rawmenable = 0; // 1 允许RAW写出
  1470. p_sys->yuvenable = 1; // 0:关掉数据输出 1:打开
  1471. p_sys->refenable = 1; // 1;3D 参考帧开启 0:关闭
  1472. // 使能参考帧 (DRAM测试模式使用REFBUF指向的数据为RAW数据)
  1473. }
  1474. else
  1475. {
  1476. p_sys->debugmode = 0;
  1477. p_sys->testenable = 0; // 开启dram测试模式
  1478. p_sys->rawmenable = 0; // 1 允许RAW写出
  1479. p_sys->yuvenable = 1; // 0:关掉数据输出 1:打开
  1480. #if ISP_3D_DENOISE_SUPPORT
  1481. p_sys->refenable = 1; // 1;3D 参考帧开启 0:关闭
  1482. #else
  1483. p_sys->refenable = 0; // 1;3D 参考帧开启 0:关闭
  1484. #endif
  1485. }
  1486. #if ISP_3D_DENOISE_SUPPORT
  1487. XM_printf ("ISP 3D Enable\n");
  1488. #else
  1489. XM_printf ("ISP 3D Disable\n");
  1490. #endif
  1491. /*
  1492. #if 1
  1493. p_sys->debugmode = 0;
  1494. p_sys->testenable = 0; //开启dram测试模式
  1495. p_sys->rawmenable = 0;
  1496. p_sys->yuvenable = 1;//0:关掉数据输出 1:打开
  1497. p_sys->refenable = 1;//1;
  1498. #else // catch raw
  1499. p_sys->debugmode = 0;
  1500. p_sys->testenable = 0; //开启dram测试模式
  1501. p_sys->rawmenable = 0;
  1502. p_sys->yuvenable = 1;//0:关掉数据输出
  1503. p_sys->refenable = 1;
  1504. #endif
  1505. */
  1506. p_sys->yuvformat = isp_get_video_format (); //0茂录拧y_uv420 1:y_uv422 2:yuv420 3:yuv422
  1507. //XM_printf("0茂录拧y_uv420 1:y_uv422 2:yuv420 3:yuv422 \n");
  1508. //p_sys->dmalock = 2; //总线锁使能 2:使能 其他数值为关闭
  1509. p_sys->dmalock = 0; // 总线锁使能 2:使能 其他数值为关闭
  1510. // 总线锁禁止会减少H264的编码时间
  1511. p_sys->hstride = p_isp->image_stride; //图像跨度 16字节倍数
  1512. p_sys->refaddr = p_isp->ref_addr; //参考帧地址
  1513. p_sys->rawaddr0 = p_isp->raw_addr[0];
  1514. p_sys->rawaddr1 = p_isp->raw_addr[1];
  1515. p_sys->rawaddr2 = p_isp->raw_addr[2];
  1516. p_sys->rawaddr3 = p_isp->raw_addr[3];
  1517. p_sys->yaddr0 = p_isp->y_addr[0];
  1518. p_sys->uaddr0 = p_isp->u_addr[0];
  1519. p_sys->vaddr0 = p_isp->v_addr[0];
  1520. p_sys->yaddr1 = p_isp->y_addr[1];
  1521. p_sys->uaddr1 = p_isp->u_addr[1];
  1522. p_sys->vaddr1 = p_isp->v_addr[1];
  1523. p_sys->yaddr2 = p_isp->y_addr[2];
  1524. p_sys->uaddr2 = p_isp->u_addr[2];
  1525. p_sys->vaddr2 = p_isp->v_addr[2];
  1526. p_sys->yaddr3 = p_isp->y_addr[3];
  1527. p_sys->uaddr3 = p_isp->u_addr[3];
  1528. p_sys->vaddr3 = p_isp->v_addr[3];
  1529. }
  1530. // ISP运行设置
  1531. extern cmos_exposure_t isp_exposure;
  1532. typedef struct _isp_awb_polyline_tbl {
  1533. int inttime;
  1534. int black;
  1535. int jitter;
  1536. } isp_awb_polyline_tbl;
  1537. static isp_awb_polyline_tbl awb_polyline_tbl[] = {
  1538. { 1, 16, 10 },
  1539. { 5, 8, 13 },
  1540. { 800, 8, 13 },
  1541. { CMOS_STD_INTTIME, 16, 13 }
  1542. };
  1543. static void awb_match_inttime (int inttime, isp_awb_polyline_tbl *awb_tbl)
  1544. {
  1545. int i;
  1546. int val;
  1547. isp_awb_polyline_tbl *lo, *hi;
  1548. int count = sizeof(awb_polyline_tbl)/sizeof(awb_polyline_tbl[0]);
  1549. for (i = 0; i < count; i ++)
  1550. {
  1551. if(inttime <= awb_polyline_tbl[i].inttime)
  1552. break;
  1553. }
  1554. //匹配
  1555. if(inttime == awb_polyline_tbl[i].inttime)
  1556. {
  1557. memcpy (awb_tbl, &awb_polyline_tbl[i], sizeof(isp_awb_polyline_tbl));
  1558. return;
  1559. }
  1560. // 边界
  1561. else if(inttime < awb_polyline_tbl[0].inttime)
  1562. {
  1563. memcpy (awb_tbl, &awb_polyline_tbl[0], sizeof(isp_awb_polyline_tbl));
  1564. return;
  1565. }
  1566. else if(i == count)
  1567. {
  1568. memcpy (awb_tbl, &awb_polyline_tbl[count - 1], sizeof(isp_awb_polyline_tbl));
  1569. return;
  1570. }
  1571. lo = &awb_polyline_tbl[i - 1];
  1572. hi = &awb_polyline_tbl[i];
  1573. val = (lo->black + (hi->black - lo->black) * (inttime - lo->inttime) / (hi->inttime - lo->inttime));
  1574. if(val < 4)
  1575. val = 4;
  1576. else if(val > 48)
  1577. val = 48;
  1578. awb_tbl->black = val;
  1579. val = (lo->jitter + (hi->jitter - lo->jitter) * (inttime - lo->inttime) / (hi->inttime - lo->inttime));
  1580. if(val < 4)
  1581. val = 4;
  1582. else if(val > 48)
  1583. val = 48;
  1584. awb_tbl->jitter = val;
  1585. }
  1586. static void gc2053_cmos_isp_awb_run (isp_awb_ptr_t p_awb)
  1587. {
  1588. }
  1589. #if IQ_20190522
  1590. static const isp_demosaic_polyline_tbl demosaic_polyline_tbl[] = {
  1591. // gain demk
  1592. { 1, 90 },
  1593. { 8, 104 },
  1594. { 32, 132 },
  1595. { 64, 240 },
  1596. { 100, 240 },
  1597. { 600, 212},
  1598. { 1*CMOS_STD_INTTIME, 148 }, // 艙枚驴陋脝么脛拢脛芒脭枚脪忙脢卤, 沤脣脢卤脢鹿脛脺艙脧沤贸碌脛demk脰碌, 卤拢鲁脰艙脧潞脙碌脛艙芒脦枚露脠, 脥卢脢卤脭毛脡霉艙脧碌脥
  1599. { 8*CMOS_STD_INTTIME, 48 }, // 艙枚驴陋脝么脛拢脛芒脭枚脪忙脢卤, 沤脣脢卤脢鹿脛脺艙脧沤贸碌脛demk脰碌, 卤拢鲁脰艙脧潞脙碌脛艙芒脦枚露脠, 脥卢脢卤脭毛脡霉艙脧碌脥
  1600. { 20*CMOS_STD_INTTIME, 16 }, // 虏脦驴艗 f:\脗路虏芒脢脫脝碌\20170114脥铆脡脧\RAW\20170114\212128\212128_21212841_ISP_DEMK_064.PNG
  1601. // 艗忙鹿脣艙芒脦枚露脠脫毛脭毛脡霉
  1602. { 35*CMOS_STD_INTTIME, 6 }, // 艙脧沤贸脢媒脳脰脭枚脪忙
  1603. { 64*CMOS_STD_INTTIME, 3 }, // 艙脧沤贸脢媒脳脰脭枚脪忙
  1604. };
  1605. #else
  1606. // 20190626 降低拉伸强度,降低噪声
  1607. static const isp_demosaic_polyline_tbl demosaic_polyline_tbl[] = {
  1608. // gain demk
  1609. { 1, 90-16 },
  1610. { 8, 104-16 },
  1611. { 32, 132-16 },
  1612. { 64, 240-32 },
  1613. { 100, 240-32 },
  1614. { 600, 212-24},
  1615. { 1*CMOS_STD_INTTIME, 148-16 }, // 仅开启模拟增益时, 此时使能较大的demk值, 保持较好的解析度, 同时噪声较低
  1616. { 8*CMOS_STD_INTTIME, 48-12 }, // 仅开启模拟增益时, 此时使能较大的demk值, 保持较好的解析度, 同时噪声较低
  1617. { 20*CMOS_STD_INTTIME, 16-4 }, // 参考 f:\路测视频\20170114晚上\RAW\20170114\212128\212128_21212841_ISP_DEMK_064.PNG
  1618. // 兼顾解析度与噪声
  1619. { 35*CMOS_STD_INTTIME, 6-3 }, // 较大数字增益
  1620. { 64*CMOS_STD_INTTIME, 3-1 }, // 较大数字增益
  1621. };
  1622. #endif
  1623. static const isp_demosaic_polyline_tbl *gc2053_cmos_isp_get_demosaic_table (int *tbl_count)
  1624. {
  1625. *tbl_count = sizeof(demosaic_polyline_tbl)/sizeof(demosaic_polyline_tbl[0]);
  1626. return demosaic_polyline_tbl;
  1627. }
  1628. #if IQ_20190522
  1629. static const isp_sharp_polyline_tbl gc2053_sharp_polyline_tbl[] = {
  1630. // inttime strength gainmax
  1631. { 3, 64, 200 },
  1632. { CMOS_STD_INTTIME, 64, 200 },
  1633. { CMOS_STD_INTTIME*8, 40, 96 },
  1634. { CMOS_STD_INTTIME*32, 24, 64 }
  1635. };
  1636. #elif SENSOR_GC2053
  1637. // 20191022 增加白天的锐度
  1638. static const isp_sharp_polyline_tbl gc2053_sharp_polyline_tbl[] = {
  1639. // inttime strength gainmax
  1640. { 3, 64, 210 },
  1641. { CMOS_STD_INTTIME, 56, 180 },
  1642. { CMOS_STD_INTTIME*8, 24, 64 },
  1643. { CMOS_STD_INTTIME*32, 10, 24 },
  1644. { CMOS_STD_INTTIME*48, 6, 16 }
  1645. };
  1646. #else
  1647. // 20190626 艙碌碌脥碌脥脮脮露脠脧脗碌脛脠帽露脠拢卢艙碌碌脥脭毛脡霉
  1648. static const isp_sharp_polyline_tbl gc2053_sharp_polyline_tbl[] = {
  1649. // inttime strength gainmax
  1650. { 3, 64, 144 },
  1651. { CMOS_STD_INTTIME, 56, 144 },
  1652. { CMOS_STD_INTTIME*8, 24, 64 },
  1653. { CMOS_STD_INTTIME*32, 10, 24 },
  1654. { CMOS_STD_INTTIME*48, 6, 16 }
  1655. };
  1656. #endif
  1657. static const isp_sharp_polyline_tbl *gc2053_cmos_isp_get_sharp_table (int *tbl_count)
  1658. {
  1659. *tbl_count = sizeof(gc2053_sharp_polyline_tbl)/sizeof(gc2053_sharp_polyline_tbl[0]);
  1660. return gc2053_sharp_polyline_tbl;
  1661. }
  1662. #if IQ_20190522
  1663. static const isp_denoise_inttime_polyline_tbl denoise_inttime_polyline_tbl[] = {
  1664. // inttime_gain y_0 u_0 v_0 y_1 u_1 v_1 y_2 u_2 v_2
  1665. {
  1666. 1, 7, 10, 10, 7, 10, 10, 3, 3, 3,
  1667. //1, 5, 3, 3, 5, 3, 3, 4, 3, 3,
  1668. } ,
  1669. // 20170305 艙芦2D碌脛艙碌脭毛脟驴露脠艗玫1(-1), 卤拢脕么啪眉露脿碌脛脧啪艙脷
  1670. {
  1671. 12, 7, 10, 10, 7, 10, 10, 3, 3, 3,
  1672. //32, 5, 4, 4, 5, 4, 4, 4, 3, 3,
  1673. } ,
  1674. {
  1675. 128, 7, 12, 12, 7, 12, 12, 3, 3, 3,
  1676. //128, 4, 4, 4, 4, 4, 4, 4, 3, 3,
  1677. } ,
  1678. // e:\proj\ARKN141\test\ISP碌梅脢脭\20170202
  1679. {
  1680. 1073, 9, 13, 13, 9, 13, 13, 4, 3, 3,
  1681. },
  1682. {
  1683. CMOS_STD_INTTIME*2, 12, 14, 14, 12, 14, 14, 5, 6, 6,
  1684. },
  1685. {
  1686. //CMOS_STD_INTTIME*4, 10, 10, 10, 10, 10, 10, 8, 8, 8,
  1687. CMOS_STD_INTTIME*4, 14, 18, 18, 14, 18, 18, 8, 8, 8,
  1688. } ,
  1689. {
  1690. CMOS_STD_INTTIME*12, 22, 28, 28, 22, 28, 28, 12, 12, 12,
  1691. //CMOS_STD_INTTIME*12, 12, 14, 14, 12, 14, 14, 12, 12, 12,
  1692. } ,
  1693. {
  1694. CMOS_STD_INTTIME*14, 26, 32, 32, 26, 32, 32, 13, 13, 13,
  1695. //CMOS_STD_INTTIME*14, 14, 16, 16, 14, 16, 16, 13, 13, 13,
  1696. } ,
  1697. {
  1698. CMOS_STD_INTTIME*20, 33, 40, 40, 33, 40, 40, 13, 13, 13,
  1699. //CMOS_STD_INTTIME*20, 22, 25, 25, 22, 25, 25, 13, 13, 13,
  1700. },
  1701. {
  1702. CMOS_STD_INTTIME*40, 52, 60, 60, 52, 60, 60, 13, 13, 13,
  1703. },
  1704. {
  1705. CMOS_STD_INTTIME*64, 84, 94, 94, 84, 94, 94, 13, 13, 13,
  1706. },
  1707. {
  1708. CMOS_STD_INTTIME*128, 160, 190, 190, 160, 190, 190, 8, 9, 9,
  1709. },
  1710. {
  1711. CMOS_STD_INTTIME*177, 220, 240, 240, 223, 240, 240, 13, 13, 13,
  1712. },
  1713. };
  1714. #else
  1715. // 20190626 脭枚艗脫艙碌脭毛脟驴露脠拢卢艙碌碌脥脭毛脡霉
  1716. static const isp_denoise_inttime_polyline_tbl denoise_inttime_polyline_tbl[] = {
  1717. // inttime_gain y_0 u_0 v_0 y_1 u_1 v_1 y_2 u_2 v_2
  1718. {
  1719. 1, 8, 11, 11, 8, 11, 11, 3, 3, 3,
  1720. //1, 5, 3, 3, 5, 3, 3, 4, 3, 3,
  1721. } ,
  1722. // 20170305 艙芦2D碌脛艙碌脭毛脟驴露脠艗玫1(-1), 卤拢脕么啪眉露脿碌脛脧啪艙脷
  1723. {
  1724. 12, 8, 11, 11, 8, 11, 11, 3, 3, 3,
  1725. //32, 5, 4, 4, 5, 4, 4, 4, 3, 3,
  1726. } ,
  1727. {
  1728. 128, 8, 13, 13, 8, 13, 13, 3, 3, 3,
  1729. //128, 4, 4, 4, 4, 4, 4, 4, 3, 3,
  1730. } ,
  1731. // e:\proj\ARKN141\test\ISP碌梅脢脭\20170202
  1732. {
  1733. 1073, 10, 15, 15, 10, 15, 15, 4, 3, 3,
  1734. },
  1735. {
  1736. CMOS_STD_INTTIME*2, 13, 15, 15, 13, 15, 15, 5, 6, 6,
  1737. },
  1738. {
  1739. //CMOS_STD_INTTIME*4, 10, 10, 10, 10, 10, 10, 8, 8, 8,
  1740. CMOS_STD_INTTIME*4, 15, 20, 20, 15, 20, 20, 8, 8, 8,
  1741. } ,
  1742. {
  1743. CMOS_STD_INTTIME*12, 24, 32, 32, 24, 32, 32, 12, 12, 12,
  1744. //CMOS_STD_INTTIME*12, 12, 14, 14, 12, 14, 14, 12, 12, 12,
  1745. } ,
  1746. {
  1747. CMOS_STD_INTTIME*14, 28, 36, 36, 28, 36, 36, 13, 13, 13,
  1748. //CMOS_STD_INTTIME*14, 14, 16, 16, 14, 16, 16, 13, 13, 13,
  1749. } ,
  1750. {
  1751. CMOS_STD_INTTIME*20, 33, 48, 48, 33, 48, 48, 13, 13, 13,
  1752. //CMOS_STD_INTTIME*20, 22, 25, 25, 22, 25, 25, 13, 13, 13,
  1753. },
  1754. {
  1755. CMOS_STD_INTTIME*40, 48, 60, 60, 48, 60, 60, 13, 13, 13,
  1756. },
  1757. {
  1758. CMOS_STD_INTTIME*64, 56, 64, 64, 56, 64, 64, 13, 13, 13,
  1759. },
  1760. {
  1761. CMOS_STD_INTTIME*80, 80, 128, 128, 80, 128, 128, 8, 9, 9,
  1762. },
  1763. {
  1764. CMOS_STD_INTTIME*128, 128, 160, 160, 128, 160, 160, 8, 9, 9,
  1765. },
  1766. {
  1767. CMOS_STD_INTTIME*177, 220, 240, 240, 223, 240, 240, 13, 13, 13,
  1768. },
  1769. };
  1770. #endif
  1771. static const isp_denoise_inttime_polyline_tbl *gc2053_cmos_isp_get_denoise_table (int *tbl_count)
  1772. {
  1773. *tbl_count = sizeof(denoise_inttime_polyline_tbl)/sizeof(denoise_inttime_polyline_tbl[0]);
  1774. return (isp_denoise_inttime_polyline_tbl *)denoise_inttime_polyline_tbl;
  1775. }
  1776. #if IQ_20190522
  1777. static const isp_eris_polyline_tbl eris_polyline_tbl[] = {
  1778. // 20170305 脭枚艗脫露脤脝脴鹿芒鲁隆鸥掳碌脛脌颅脡矛脟驴露脠, 啪脛脡脝艙芒脦枚露脠艗掳脩脮脡芦
  1779. { 1, 96, (int)(0.86 * 512), (int)(0.45 * 512) },
  1780. // 20190325掳脳脤矛脗路虏芒拢卢脡芦虏脢脝芦禄脝拢卢艙碌碌脥掳脳脤矛碌脛脡芦虏脢脌颅脡矛脟驴露脠
  1781. // 20190426掳脳脤矛脗路虏芒拢卢脕脕鲁隆鸥掳脧脗艙拧脰镁脦茂露楼虏驴脡脭脦垄鹿媒脝脴拢卢艙碌碌脥脕脕露脠脭枚脪忙
  1782. { 5, 96, (int)(0.91 * 512), (int)(0.45 * 512) },
  1783. { 32, 112, (int)(0.92 * 512), (int)(0.45 * 512) },
  1784. { 80, 212, (int)(0.93 * 512), (int)(0.45 * 512) },
  1785. { 400, 212, (int)(0.94 * 512), (int)(0.45 * 512) },
  1786. { 700, 240, (int)(0.92 * 512), (int)(0.45 * 512) },
  1787. { 820, 240, (int)(0.91 * 512), (int)(0.45 * 512) },
  1788. { 900, 256, (int)(0.90 * 512), (int)(0.45 * 512) },
  1789. { 1023, 256, (int)(0.86 * 512), (int)(0.40 * 512) },
  1790. // 脗路虏芒脭毛脡霉脝芦沤贸拢卢艙碌碌脥脕脕露脠脭枚脪忙拢卢脪脰脰脝脭毛脡霉
  1791. { CMOS_STD_INTTIME, 240, (int)(0.80 * 512), (int)(0.40 * 512) },
  1792. { CMOS_STD_INTTIME*2, 214, (int)(0.75 * 512), (int)(0.40 * 512) },
  1793. { CMOS_STD_INTTIME*10, 210, (int)(0.50 * 512), (int)(0.30 * 512) },
  1794. { CMOS_STD_INTTIME*12, 210, (int)(0.40 * 512), (int)(0.2 * 512) },
  1795. { CMOS_STD_INTTIME*30, 240, (int)(0.24 * 512), (int)(0.2 * 512) },
  1796. { CMOS_STD_INTTIME*60, 320, (int)(0.15 * 512), (int)(0.2 * 512) },
  1797. { CMOS_STD_INTTIME*128, 320, (int)(0.10 * 512), (int)(0.2 * 512) },
  1798. };
  1799. #elif SENSOR_GC2053
  1800. /****
  1801. // 20191021 增强白天颜色的饱和度
  1802. static const isp_eris_polyline_tbl eris_polyline_tbl[] = {
  1803. // 20170305 增加短曝光场景的拉伸强度, 改善解析度及颜色
  1804. { 1, 96, (int)(0.80 * 512), (int)(0.60 * 512) },
  1805. // 20190325白天路测,色彩偏黄,降低白天的色彩拉伸强度
  1806. // 20190426白天路测,亮场景下建筑物顶部稍微过曝,降低亮度增益
  1807. { 5, 96, (int)(0.85 * 512), (int)(0.60 * 512) },
  1808. { 32, 112, (int)(0.86 * 512), (int)(0.60 * 512) },
  1809. { 80, 212, (int)(0.87 * 512), (int)(0.60 * 512) },
  1810. { 400, 212, (int)(0.88 * 512), (int)(0.60 * 512) },
  1811. { 700, 240, (int)(0.86 * 512), (int)(0.60 * 512) },
  1812. { 820, 240, (int)(0.85 * 512), (int)(0.60 * 512) },
  1813. { 900, 256, (int)(0.80 * 512), (int)(0.60 * 512) },
  1814. { 1023, 256, (int)(0.70 * 512), (int)(0.55 * 512) },
  1815. // 路测噪声偏大,降低亮度增益,抑制噪声
  1816. { CMOS_STD_INTTIME, 240, (int)(0.60 * 512), (int)(0.55 * 512) },
  1817. { CMOS_STD_INTTIME*2, 214, (int)(0.50 * 512), (int)(0.55 * 512) },
  1818. { CMOS_STD_INTTIME*10, 210, (int)(0.30 * 512), (int)(0.45 * 512) },
  1819. { CMOS_STD_INTTIME*12, 210, (int)(0.15 * 512), (int)(0.35 * 512) },
  1820. // 降低低照度增益,减轻噪声
  1821. { CMOS_STD_INTTIME*30, 160, (int)(0.10 * 512), (int)(0.25 * 512) },
  1822. { CMOS_STD_INTTIME*60, 144, (int)(0.10 * 512), (int)(0.2 * 512) },
  1823. { CMOS_STD_INTTIME*128, 144, (int)(0.10 * 512), (int)(0.2 * 512) },
  1824. };
  1825. *****/
  1826. // 20191022 增强白天颜色的饱和度
  1827. static const isp_eris_polyline_tbl eris_polyline_tbl[] = {
  1828. // 20170305 增加短曝光场景的拉伸强度, 改善解析度及颜色
  1829. { 1, 96, (int)(0.80 * 512), (int)(0.80 * 512) },
  1830. // 20190325白天路测,色彩偏黄,降低白天的色彩拉伸强度
  1831. // 20190426白天路测,亮场景下建筑物顶部稍微过曝,降低亮度增益
  1832. { 5, 96, (int)(0.85 * 512), (int)(0.80 * 512) },
  1833. { 32, 112, (int)(0.86 * 512), (int)(0.80 * 512) },
  1834. { 80, 212, (int)(0.87 * 512), (int)(0.80 * 512) },
  1835. { 400, 212, (int)(0.88 * 512), (int)(0.80 * 512) },
  1836. { 700, 240, (int)(0.86 * 512), (int)(0.80 * 512) },
  1837. { 820, 240, (int)(0.85 * 512), (int)(0.80 * 512) },
  1838. { 900, 256, (int)(0.80 * 512), (int)(0.80 * 512) },
  1839. { 1023, 256, (int)(0.70 * 512), (int)(0.75 * 512) },
  1840. // 路测噪声偏大,降低亮度增益,抑制噪声
  1841. { CMOS_STD_INTTIME, 240, (int)(0.60 * 512), (int)(0.75 * 512) },
  1842. { CMOS_STD_INTTIME*2, 214, (int)(0.50 * 512), (int)(0.70 * 512) },
  1843. { CMOS_STD_INTTIME*10, 210, (int)(0.30 * 512), (int)(0.60 * 512) },
  1844. { CMOS_STD_INTTIME*12, 210, (int)(0.15 * 512), (int)(0.45 * 512) },
  1845. // 降低低照度增益,减轻噪声
  1846. { CMOS_STD_INTTIME*30, 160, (int)(0.10 * 512), (int)(0.25 * 512) },
  1847. { CMOS_STD_INTTIME*60, 144, (int)(0.10 * 512), (int)(0.2 * 512) },
  1848. { CMOS_STD_INTTIME*128, 144, (int)(0.10 * 512), (int)(0.2 * 512) },
  1849. };
  1850. #else
  1851. // 20191022 增强白天颜色的饱和度
  1852. static const isp_eris_polyline_tbl eris_polyline_tbl[] = {
  1853. // 20170305 增加短曝光场景的拉伸强度, 改善解析度及颜色
  1854. { 1, 96, (int)(0.80 * 512), (int)(0.45 * 512) },
  1855. // 20190325白天路测,色彩偏黄,降低白天的色彩拉伸强度
  1856. // 20190426白天路测,亮场景下建筑物顶部稍微过曝,降低亮度增益
  1857. { 5, 96, (int)(0.85 * 512), (int)(0.45 * 512) },
  1858. { 32, 112, (int)(0.86 * 512), (int)(0.45 * 512) },
  1859. { 80, 212, (int)(0.87 * 512), (int)(0.45 * 512) },
  1860. { 400, 212, (int)(0.88 * 512), (int)(0.45 * 512) },
  1861. { 700, 240, (int)(0.86 * 512), (int)(0.45 * 512) },
  1862. { 820, 240, (int)(0.85 * 512), (int)(0.45 * 512) },
  1863. { 900, 256, (int)(0.80 * 512), (int)(0.45 * 512) },
  1864. { 1023, 256, (int)(0.70 * 512), (int)(0.40 * 512) },
  1865. // 路测噪声偏大,降低亮度增益,抑制噪声
  1866. { CMOS_STD_INTTIME, 240, (int)(0.60 * 512), (int)(0.40 * 512) },
  1867. { CMOS_STD_INTTIME*2, 214, (int)(0.50 * 512), (int)(0.40 * 512) },
  1868. { CMOS_STD_INTTIME*10, 210, (int)(0.30 * 512), (int)(0.30 * 512) },
  1869. { CMOS_STD_INTTIME*12, 210, (int)(0.15 * 512), (int)(0.2 * 512) },
  1870. // 降低低照度增益,减轻噪声
  1871. { CMOS_STD_INTTIME*30, 160, (int)(0.10 * 512), (int)(0.2 * 512) },
  1872. { CMOS_STD_INTTIME*60, 144, (int)(0.10 * 512), (int)(0.2 * 512) },
  1873. { CMOS_STD_INTTIME*128, 144, (int)(0.10 * 512), (int)(0.2 * 512) },
  1874. };
  1875. #endif
  1876. static const isp_eris_polyline_tbl* gc2053_cmos_isp_get_eris_auto_table(int *tbl_count)
  1877. {
  1878. *tbl_count = sizeof(eris_polyline_tbl)/sizeof(eris_polyline_tbl[0]);
  1879. return eris_polyline_tbl;
  1880. }
  1881. static const isp_eris_man_polyline_tbl eris_man_polyline_tbl[] = {
  1882. { 1, 112, 160, (int)(0.95 * 512), (int)(0.75 * 512) },
  1883. { 5, 144, 160, (int)(0.96 * 512), (int)(0.75 * 512) },
  1884. { 32, 196, 160, (int)(0.97 * 512), (int)(0.75 * 512) },
  1885. { 80, 240, 144, (int)(0.99 * 512), (int)(0.8 * 512) },
  1886. { 700, 240, 80, (int)(0.99 * 512), (int)(0.9 * 512) },
  1887. { 1023, 320, 64, (int)(0.98 * 512), (int)(0.9 * 512) },
  1888. // 20170217 地下车库测试发现, N141墙壁上指引标志的色彩偏暗, 稍微提高暗场景下色彩的比率因子(+0.1)
  1889. { CMOS_STD_INTTIME, 320, 48, (int)(0.98 * 512), (int)(0.8 * 512) },
  1890. { CMOS_STD_INTTIME*4, 320, 32, (int)(0.98 * 512), (int)(0.6 * 512) },
  1891. { CMOS_STD_INTTIME*10, 440, 32, (int)(0.95 * 512), (int)(0.6 * 512) },
  1892. { CMOS_STD_INTTIME*12, 440, 32, (int)(0.85 * 512), (int)(0.5 * 512) },
  1893. { CMOS_STD_INTTIME*15, 440, 32, (int)(0.80 * 512), (int)(0.5 * 512) },
  1894. { CMOS_STD_INTTIME*35, 440, 32, (int)(0.60 * 512), (int)(0.4 * 512) },
  1895. { CMOS_STD_INTTIME*60, 440, 32, (int)(0.50 * 512), (int)(0.4 * 512) },
  1896. { CMOS_STD_INTTIME*128, 440, 32, (int)(0.40 * 512), (int)(0.2 * 512) },
  1897. { CMOS_STD_INTTIME*177, 440, 32, (int)(0.20 * 512), (int)(0.2 * 512) },
  1898. };
  1899. static const isp_eris_man_polyline_tbl *gc2053_cmos_isp_get_eris_man_table(int *tbl_count)
  1900. {
  1901. *tbl_count = sizeof(eris_man_polyline_tbl)/sizeof(eris_man_polyline_tbl[0]);
  1902. return eris_man_polyline_tbl;
  1903. }
  1904. // 3D关闭时的参数,
  1905. static const isp_crosstalk_polyline_tbl crosstalk_polyline_tbl[] = {
  1906. // inttime_gain crosstalk
  1907. // 20170217上午及之前使用的版本
  1908. { 50, 2 + 2 },
  1909. { 100, 3 + 2 },
  1910. { 161, 3 + 2 },
  1911. { 242, 3 + 2 },
  1912. { 1024, 3 + 3 },
  1913. // 20190321 晚上路测,噪声偏大,增加降噪强度
  1914. { CMOS_STD_INTTIME, 5 + 4 },
  1915. { CMOS_STD_INTTIME * 2, 8 + 4 },
  1916. { CMOS_STD_INTTIME * 4, 10 + 7 },
  1917. { CMOS_STD_INTTIME * 10, 12 + 12 },
  1918. { CMOS_STD_INTTIME * 30, 24 + 18 },
  1919. { CMOS_STD_INTTIME * 64, 48 + 23 },
  1920. { CMOS_STD_INTTIME * 128, 64 + 33 },
  1921. { CMOS_STD_INTTIME * 177, 128 },
  1922. };
  1923. static const isp_crosstalk_polyline_tbl *gc2053_cmos_isp_get_crosstalk_table (int *tbl_count)
  1924. {
  1925. *tbl_count = sizeof(crosstalk_polyline_tbl)/sizeof(crosstalk_polyline_tbl[0]);
  1926. return crosstalk_polyline_tbl;
  1927. }
  1928. #pragma data_alignment=32
  1929. #if IQ_20190522
  1930. static const isp_enhance_polyline_tbl enhance_polyline_tbl[] = {
  1931. // inttime bright contrast
  1932. //{ 3, -6, 1024 },
  1933. //{ 64, -8, 1024 },
  1934. // 保留短曝光低光处的细节
  1935. { 3, -2, 1024 },
  1936. { 64, -2, 1024 },
  1937. { 512, -4, 1024 },
  1938. { 800, -4, 1024 },
  1939. { 1125, -4, 1024 }, // 场景光照较弱时, 噪声增加, 相应增加黑电平
  1940. { CMOS_STD_INTTIME * 2, -4, 1024},
  1941. // 20190321 夜晚路测,噪声偏大,增大黑电平
  1942. { CMOS_STD_INTTIME * 16, -5, 1024},
  1943. };
  1944. #else
  1945. // 20190626 增大低照度场景下的黑电平
  1946. static const isp_enhance_polyline_tbl enhance_polyline_tbl[] = {
  1947. // inttime bright contrast
  1948. //{ 3, -6, 1024 },
  1949. //{ 64, -8, 1024 },
  1950. // 保留短曝光低光处的细节
  1951. { 3, -2, 1024 },
  1952. { 64, -2, 1024 },
  1953. { 512, -4, 1024 },
  1954. { 800, -4, 1024 },
  1955. { 1125, -4, 1024 }, // 场景光照较弱时, 噪声增加, 相应增加黑电平
  1956. { CMOS_STD_INTTIME * 2, -4, 1024},
  1957. // 20190321 夜晚路测,噪声偏大,增大黑电平
  1958. { CMOS_STD_INTTIME * 16, -5, 1024},
  1959. { CMOS_STD_INTTIME * 32, -7, 1024},
  1960. { CMOS_STD_INTTIME * 64, -9, 1024},
  1961. };
  1962. #endif
  1963. static const isp_enhance_polyline_tbl * gc2053_cmos_isp_get_enhance_table (int *tbl_count)
  1964. {
  1965. *tbl_count = sizeof(enhance_polyline_tbl)/sizeof(enhance_polyline_tbl[0]);
  1966. return enhance_polyline_tbl;
  1967. }
  1968. #if 1
  1969. static const isp_satuation_polyline_tbl satuation_polyline_tbl[] = {
  1970. // inttime satuation
  1971. { 1 * CMOS_STD_INTTIME, 900 },
  1972. { 10 * CMOS_STD_INTTIME, 800 },
  1973. { 12 * CMOS_STD_INTTIME, 720 },
  1974. { 24 * CMOS_STD_INTTIME, 512 },
  1975. { 32 * CMOS_STD_INTTIME, 384 },
  1976. { 64 * CMOS_STD_INTTIME, 384 },
  1977. };
  1978. #else
  1979. // 20190626 脭枚艗脫脡芦虏脢卤楼潞脥露脠
  1980. static const isp_satuation_polyline_tbl satuation_polyline_tbl[] = {
  1981. // inttime satuation
  1982. { 1 * CMOS_STD_INTTIME, 1000 },
  1983. { 10 * CMOS_STD_INTTIME, 900 },
  1984. { 12 * CMOS_STD_INTTIME, 800 },
  1985. { 24 * CMOS_STD_INTTIME, 640 },
  1986. { 32 * CMOS_STD_INTTIME, 512 },
  1987. { 64 * CMOS_STD_INTTIME, 512 },
  1988. };
  1989. #endif
  1990. static const isp_satuation_polyline_tbl * gc2053_cmos_isp_get_satuation_table (int *tbl_count)
  1991. {
  1992. *tbl_count = sizeof(satuation_polyline_tbl)/sizeof(satuation_polyline_tbl[0]);
  1993. return satuation_polyline_tbl;
  1994. }
  1995. #define AE_GAIN(x) ((unsigned int)(x*1.0))
  1996. // 20190422白天测试,与原厂比较,曝光过曝
  1997. static const isp_ae_polyline_tbl ae_polyline_tbl_20190422[] = {
  1998. // 1) 增加短曝光场景下(包括逆光)的亮度
  1999. { 1, AE_GAIN(64), 128, {1, 1, 1, 2, 5, 2, 12, 15, 12} },
  2000. { 16, AE_GAIN(60), 128, {1, 1, 1, 4, 10, 4, 12, 15, 12} },
  2001. { 32, AE_GAIN(56), 128, {2, 3, 2, 6, 15, 6, 12, 15, 12} },
  2002. { 64, AE_GAIN(56), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2003. { 512, AE_GAIN(53), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2004. { 878, AE_GAIN(47), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2005. // 2 增加海岸城晚上路边两侧的亮度
  2006. //{ CMOS_STD_INTTIME, AE_GAIN(27), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2007. //{ CMOS_STD_INTTIME*5/2, AE_GAIN(22), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2008. //{ CMOS_STD_INTTIME*8, AE_GAIN(18), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2009. { CMOS_STD_INTTIME, AE_GAIN(39), 128, {3, 4, 3, 5, 7, 5, 7, 7, 7 } },
  2010. { CMOS_STD_INTTIME*5/2, AE_GAIN(33), 128, {4, 4, 4, 5, 7, 5, 7, 7, 7 } },
  2011. { CMOS_STD_INTTIME*4, AE_GAIN(24), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2012. { CMOS_STD_INTTIME*8, AE_GAIN(19), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2013. };
  2014. static const isp_ae_polyline_tbl ae_polyline_tbl_new[] = {
  2015. // 1) 增加短曝光场景下(包括逆光)的亮度
  2016. { 1, AE_GAIN(58), 128, {1, 1, 1, 2, 5, 2, 12, 15, 12} },
  2017. { 16, AE_GAIN(54), 128, {1, 1, 1, 4, 10, 4, 12, 15, 12} },
  2018. { 32, AE_GAIN(50), 128, {2, 3, 2, 6, 15, 6, 12, 15, 12} },
  2019. { 64, AE_GAIN(50), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2020. { 512, AE_GAIN(48), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2021. { 878, AE_GAIN(48), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2022. // 2 增加海岸城晚上路边两侧的亮度
  2023. //{ CMOS_STD_INTTIME, AE_GAIN(27), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2024. //{ CMOS_STD_INTTIME*5/2, AE_GAIN(22), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2025. //{ CMOS_STD_INTTIME*8, AE_GAIN(18), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2026. { CMOS_STD_INTTIME, AE_GAIN(48), 128, {3, 4, 3, 5, 7, 5, 7, 7, 7 } },
  2027. { CMOS_STD_INTTIME*5/2, AE_GAIN(42), 128, {4, 4, 4, 5, 7, 5, 7, 7, 7 } },
  2028. { CMOS_STD_INTTIME*4, AE_GAIN(32), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2029. { CMOS_STD_INTTIME*8, AE_GAIN(18), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2030. };
  2031. static const isp_ae_polyline_tbl ae_polyline_tbl_20170322_pm[] = {
  2032. // 1) 增加短曝光场景下(包括逆光)的亮度
  2033. { 1, AE_GAIN(36), 128, {1, 1, 1, 2, 5, 2, 12, 15, 12} },
  2034. { 16, AE_GAIN(36), 128, {1, 1, 1, 4, 10, 4, 12, 15, 12} },
  2035. { 32, AE_GAIN(36), 128, {2, 3, 2, 6, 15, 6, 12, 15, 12} },
  2036. { 64, AE_GAIN(40), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2037. { 512, AE_GAIN(40), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2038. { 878, AE_GAIN(40), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2039. // 2 增加海岸城晚上路边两侧的亮度
  2040. //{ CMOS_STD_INTTIME, AE_GAIN(27), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2041. //{ CMOS_STD_INTTIME*5/2, AE_GAIN(22), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2042. //{ CMOS_STD_INTTIME*8, AE_GAIN(18), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2043. { CMOS_STD_INTTIME, AE_GAIN(39), 128, {3, 4, 3, 5, 7, 5, 7, 7, 7 } },
  2044. { CMOS_STD_INTTIME*5/2, AE_GAIN(33), 128, {4, 4, 4, 5, 7, 5, 7, 7, 7 } },
  2045. { CMOS_STD_INTTIME*4, AE_GAIN(24), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2046. { CMOS_STD_INTTIME*8, AE_GAIN(19), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2047. };
  2048. /****
  2049. static const isp_ae_polyline_tbl ae_polyline_tbl[] = {
  2050. // 1) 氓垄啪氓艩聽莽鸥颅忙鈥郝澝モ€︹€懊ヅ撀好︹劉炉盲赂鈥�(氓艗鈥γ︹€孤�┾偓鈥犆モ€︹€�)莽拧鈥灻ぢ郝�ヂ郝�
  2051. { 1, AE_GAIN(32), 128, {1, 2, 1, 2, 5, 2, 12, 15, 12} },
  2052. { 16, AE_GAIN(32), 128, {1, 2, 1, 4, 10, 4, 12, 15, 12} },
  2053. { 32, AE_GAIN(32), 128, {2, 4, 2, 6, 15, 6, 12, 15, 12} },
  2054. { 64, AE_GAIN(32), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2055. { 512, AE_GAIN(33), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2056. { 878, AE_GAIN(35), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2057. // 2 氓垄啪氓艩聽忙碌路氓虏赂氓鸥沤忙鈩⑴∶ぢ概犆�仿��韭姑ぢ嘎っぢ韭��♀€灻ぢ郝�ヂ郝�
  2058. //{ CMOS_STD_INTTIME, AE_GAIN(27), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2059. //{ CMOS_STD_INTTIME*5/2, AE_GAIN(22), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2060. //{ CMOS_STD_INTTIME*8, AE_GAIN(18), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2061. { CMOS_STD_INTTIME, AE_GAIN(35), 128, {3, 4, 3, 5, 7, 5, 7, 7, 7 } },
  2062. { CMOS_STD_INTTIME*5/2, AE_GAIN(33), 128, {4, 4, 4, 5, 7, 5, 7, 7, 7 } },
  2063. { CMOS_STD_INTTIME*4, AE_GAIN(24), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2064. { CMOS_STD_INTTIME*8, AE_GAIN(19), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2065. };
  2066. ****/
  2067. /****
  2068. // 20191021 改善白天/晚上过曝的问题
  2069. static const isp_ae_polyline_tbl ae_polyline_tbl[] = {
  2070. // 1) 增加短曝光场景下(包括逆光)的亮度
  2071. { 1, AE_GAIN(24), 128, {2, 3, 2, 2, 5, 2, 12, 15, 12} },
  2072. { 16, AE_GAIN(24), 128, {2, 3, 2, 4, 10, 4, 12, 15, 12} },
  2073. { 32, AE_GAIN(24), 128, {3, 5, 3, 6, 15, 6, 12, 15, 12} },
  2074. { 64, AE_GAIN(24), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2075. { 512, AE_GAIN(24), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2076. { 878, AE_GAIN(24), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2077. // 2 增加海岸城晚上路边两侧的亮度
  2078. //{ CMOS_STD_INTTIME, AE_GAIN(27), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2079. //{ CMOS_STD_INTTIME*5/2, AE_GAIN(22), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2080. //{ CMOS_STD_INTTIME*8, AE_GAIN(18), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2081. { CMOS_STD_INTTIME, AE_GAIN(24), 128, {3, 4, 3, 5, 7, 5, 7, 7, 7 } },
  2082. { CMOS_STD_INTTIME*5/2, AE_GAIN(22), 128, {4, 4, 4, 5, 7, 5, 7, 7, 7 } },
  2083. { CMOS_STD_INTTIME*4, AE_GAIN(18), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2084. { CMOS_STD_INTTIME*8, AE_GAIN(16), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2085. };
  2086. *****/
  2087. // 20191030
  2088. // 测试发现阴天白天亮度稍微偏暗, 增加场景亮度
  2089. static const isp_ae_polyline_tbl ae_polyline_tbl[] = {
  2090. // 1) 增加短曝光场景下(包括逆光)的亮度
  2091. { 1, AE_GAIN(32), 128, {2, 3, 2, 2, 5, 2, 12, 15, 12} },
  2092. { 16, AE_GAIN(32), 128, {2, 3, 2, 4, 10, 4, 12, 15, 12} },
  2093. { 32, AE_GAIN(32), 128, {3, 5, 3, 6, 15, 6, 12, 15, 12} },
  2094. { 64, AE_GAIN(32), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2095. { 512, AE_GAIN(32), 128, {4, 5, 4, 5, 10, 5, 6, 10, 6} },
  2096. { 878, AE_GAIN(29), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2097. // 2 增加海岸城晚上路边两侧的亮度
  2098. //{ CMOS_STD_INTTIME, AE_GAIN(27), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2099. //{ CMOS_STD_INTTIME*5/2, AE_GAIN(22), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2100. //{ CMOS_STD_INTTIME*8, AE_GAIN(18), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2101. { CMOS_STD_INTTIME, AE_GAIN(25), 128, {3, 4, 3, 5, 7, 5, 7, 7, 7 } },
  2102. { CMOS_STD_INTTIME*5/2, AE_GAIN(22), 128, {4, 4, 4, 5, 7, 5, 7, 7, 7 } },
  2103. { CMOS_STD_INTTIME*4, AE_GAIN(18), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2104. { CMOS_STD_INTTIME*8, AE_GAIN(16), 128, {7, 7, 7, 7, 7, 7, 7, 7, 7 } },
  2105. };
  2106. static const isp_ae_polyline_tbl *gc2053_cmos_isp_get_ae_table (int *tbl_count)
  2107. {
  2108. *tbl_count = sizeof(ae_polyline_tbl)/sizeof(ae_polyline_tbl[0]);
  2109. return ae_polyline_tbl;
  2110. }
  2111. static void gc2053_cmos_isp_set_day_night_mode (cmos_gain_ptr_t gain, int day_night) // day_night = 1, 夜晚增强模式, day_night = 0, 普通模式
  2112. {
  2113. }
  2114. u32_t isp_init_cmos_sensor (cmos_sensor_t *cmos_sensor)
  2115. {
  2116. memset (cmos_sensor, 0, sizeof(cmos_sensor_t));
  2117. cmos_sensor->cmos_gain_initialize = cmos_gain_initialize;
  2118. cmos_sensor->cmos_max_gain_set = gc2053_cmos_max_gain_set;
  2119. cmos_sensor->cmos_max_gain_get = gc2053_cmos_max_gain_get;
  2120. //cmos_sensor->cmos_gain_update = cmos_gain_update;
  2121. cmos_sensor->cmos_inttime_initialize = cmos_inttime_initialize;
  2122. //cmos_sensor->cmos_inttime_update = cmos_inttime_update;
  2123. cmos_sensor->cmos_inttime_gain_update = cmos_inttime_gain_update;
  2124. cmos_sensor->cmos_inttime_gain_update_manual = cmos_inttime_gain_update_manual;
  2125. cmos_sensor->analog_gain_from_exposure_calculate = analog_gain_from_exposure_calculate;
  2126. cmos_sensor->digital_gain_from_exposure_calculate = digital_gain_from_exposure_calculate;
  2127. cmos_sensor->cmos_get_iso = cmos_get_iso;
  2128. cmos_sensor->cmos_fps_set = cmos_fps_set;
  2129. cmos_sensor->cmos_sensor_set_readout_direction = cmos_sensor_set_readout_direction;
  2130. cmos_sensor->cmos_sensor_get_sensor_name = gc2053_cmos_sensor_get_sensor_name;
  2131. // sensor初始化
  2132. cmos_sensor->cmos_isp_sensor_init = gc2053_isp_sensor_init;
  2133. cmos_sensor->cmos_isp_awb_init = gc2053_cmos_isp_awb_init;
  2134. cmos_sensor->cmos_isp_colors_init = gc2053_cmos_isp_colors_init;
  2135. cmos_sensor->cmos_isp_denoise_init = gc2053_cmos_isp_denoise_init;
  2136. cmos_sensor->cmos_isp_eris_init = gc2053_cmos_isp_eris_init;
  2137. cmos_sensor->cmos_isp_fesp_init = gc2053_cmos_isp_fesp_init;
  2138. cmos_sensor->cmos_isp_enhance_init = gc2053_cmos_isp_enhance_init;
  2139. cmos_sensor->cmos_isp_ae_init = gc2053_cmos_isp_ae_init;
  2140. cmos_sensor->cmos_isp_sys_init = gc2053_cmos_isp_sys_init;
  2141. cmos_sensor->cmos_isp_awb_run = NULL;
  2142. cmos_sensor->cmos_isp_colors_run = NULL;
  2143. cmos_sensor->cmos_isp_denoise_run = NULL;
  2144. cmos_sensor->cmos_isp_eris_run = NULL;
  2145. cmos_sensor->cmos_isp_fesp_run = NULL;
  2146. cmos_sensor->cmos_isp_enhance_run = NULL;
  2147. cmos_sensor->cmos_isp_ae_run = NULL;
  2148. cmos_sensor->cmos_isp_sharp_run = NULL;
  2149. cmos_sensor->cmos_isp_get_gamma_table = gc2053_cmos_isp_get_gamma_table;
  2150. cmos_sensor->cmos_isp_get_denoise_table = gc2053_cmos_isp_get_denoise_table;
  2151. cmos_sensor->cmos_isp_get_eris_auto_table = gc2053_cmos_isp_get_eris_auto_table; // 自动模式
  2152. cmos_sensor->cmos_isp_get_eris_man_table = gc2053_cmos_isp_get_eris_man_table; // 手动模式
  2153. cmos_sensor->cmos_isp_get_crosstalk_table = gc2053_cmos_isp_get_crosstalk_table;
  2154. cmos_sensor->cmos_isp_get_fpn_table = NULL;
  2155. cmos_sensor->cmos_isp_get_lsc_table = NULL;
  2156. cmos_sensor->cmos_isp_get_satuation_table = gc2053_cmos_isp_get_satuation_table;
  2157. cmos_sensor->cmos_isp_get_enhance_table = gc2053_cmos_isp_get_enhance_table;
  2158. cmos_sensor->cmos_isp_get_sharp_table = gc2053_cmos_isp_get_sharp_table;
  2159. cmos_sensor->cmos_isp_get_ae_table = gc2053_cmos_isp_get_ae_table;
  2160. cmos_sensor->cmos_isp_get_demosaic_table = gc2053_cmos_isp_get_demosaic_table;
  2161. return 0;
  2162. }
  2163. EXPORT_SYMBOL(isp_init_cmos_sensor);
  2164. static int
  2165. gc2053_probe(struct i2c_client *client, const struct i2c_device_id *id)
  2166. {
  2167. i2c_client = client;
  2168. of_property_read_u32(client->dev.of_node, "sensor-fps", &isp_sensor_fps);
  2169. return 0;
  2170. }
  2171. static int
  2172. gc2053_remove(struct i2c_client *client)
  2173. {
  2174. return 0;
  2175. }
  2176. static const struct of_device_id gc2053_of_match[] = {
  2177. { .compatible = "arkmicro,gc2053" },
  2178. { }
  2179. };
  2180. MODULE_DEVICE_TABLE(of, gc2053_of_match);
  2181. static const struct i2c_device_id gc2053_id[] = {
  2182. { "gc2053", 0 },
  2183. { }
  2184. };
  2185. MODULE_DEVICE_TABLE(i2c, gc2053_id);
  2186. static struct i2c_driver gc2053_driver = {
  2187. .driver = {
  2188. .name = "gc2053",
  2189. .of_match_table = of_match_ptr(gc2053_of_match),
  2190. },
  2191. .probe = gc2053_probe,
  2192. .remove = gc2053_remove,
  2193. .id_table = gc2053_id,
  2194. };
  2195. module_i2c_driver(gc2053_driver);
  2196. MODULE_DESCRIPTION("Sensor gc2053 driver");
  2197. MODULE_AUTHOR("Sim");
  2198. MODULE_LICENSE("GPL v2");