blob: 0a0004960d96d7db5a98d67bdd6416e22ebfcb83
1 | #include "CVpp.h" |
2 | #include <CTvLog.h> |
3 | #include "../tvsetting/CTvSetting.h" |
4 | #include "../tvutils/tvutils.h" |
5 | #include <cutils/properties.h> |
6 | #include "CPQdb.h" |
7 | #include <math.h> |
8 | #include <stdio.h> |
9 | #include <unistd.h> |
10 | #include <sys/types.h> |
11 | #include <sys/stat.h> |
12 | #include <sys/ioctl.h> |
13 | #include <fcntl.h> |
14 | #include <string.h> |
15 | #include <pthread.h> |
16 | #include <errno.h> |
17 | #include <dlfcn.h> |
18 | #include "CTvLog.h" |
19 | #include "../tvconfig/tvconfig.h" |
20 | #include "CAv.h" |
21 | |
22 | #ifdef LOG_TAG |
23 | #undef LOG_TAG |
24 | #define LOG_TAG "CVpp" |
25 | #endif |
26 | CVpp::CVpp() |
27 | { |
28 | vpp_amvideo_fd = -1; |
29 | vpp_amvideo_3d_fd = -1; |
30 | mpPqData = new CPqData(); |
31 | } |
32 | |
33 | CVpp::~CVpp() |
34 | { |
35 | if (mpPqData != NULL) { |
36 | delete mpPqData; |
37 | mpPqData = NULL; |
38 | } |
39 | } |
40 | |
41 | int CVpp::Vpp_Init(const char *pq_db_path) |
42 | { |
43 | LOGD("Vpp_Init pq_db_path = %s", pq_db_path); |
44 | if (mpPqData->openPqDB(pq_db_path)) { |
45 | LOGW("%s, open pq failed!", __FUNCTION__); |
46 | } else { |
47 | LOGD("%s, open pq success!", __FUNCTION__); |
48 | } |
49 | |
50 | int ret = -1; |
51 | int backlight = 100; |
52 | int offset_r = 0, offset_g = 0, offset_b = 0, gain_r = 1024, gain_g = 1024, gain_b = 1024; |
53 | |
54 | Vpp_GetVppConfig(); |
55 | |
56 | ret = VPP_OpenModule(); |
57 | backlight = GetBacklight(SOURCE_TYPE_TV); |
58 | |
59 | if (mbVppCfg_backlight_init) { |
60 | backlight = (backlight + 100) * 255 / 200; |
61 | |
62 | if (backlight < 127 || backlight > 255) { |
63 | backlight = 255; |
64 | } |
65 | } |
66 | |
67 | SetBacklight(backlight, SOURCE_TYPE_TV, 0); |
68 | |
69 | if (SSMReadNonStandardValue() & 1) { |
70 | Set_Fixed_NonStandard(0); //close |
71 | } else { |
72 | Set_Fixed_NonStandard(2); //open |
73 | } |
74 | |
75 | LoadVppSettings(SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D); |
76 | |
77 | return ret; |
78 | } |
79 | |
80 | int CVpp::Vpp_Uninit(void) |
81 | { |
82 | Vpp_ResetLastVppSettingsSourceType(); |
83 | VPP_CloseModule(); |
84 | mpPqData->closeDb(); |
85 | return 0; |
86 | } |
87 | CPqData *CVpp::getPqData() |
88 | { |
89 | return mpPqData; |
90 | } |
91 | |
92 | int CVpp::doSuspend() |
93 | { |
94 | return mpPqData->closeDb(); |
95 | } |
96 | |
97 | int CVpp::doResume() |
98 | { |
99 | return mpPqData->reopenDB(); |
100 | } |
101 | int CVpp::VPP_OpenModule(void) |
102 | { |
103 | |
104 | if (vpp_amvideo_fd < 0) { |
105 | vpp_amvideo_fd = open(VPP_DEV_PATH, O_RDWR); |
106 | |
107 | LOGD("~~~open~~~##VPP_OpenModule##VPP_DEV_PATH : %s##", VPP_DEV_PATH); |
108 | |
109 | if (vpp_amvideo_fd < 0) { |
110 | LOGE("Open vpp module, error(%s)!\n", strerror(errno)); |
111 | return -1; |
112 | } |
113 | } |
114 | |
115 | if (vpp_amvideo_3d_fd < 0) { |
116 | vpp_amvideo_3d_fd = open(VPP_3D_DEV_PATH, O_RDWR); |
117 | LOGD("~~~open~~~##VPP_OpenModule##VPP_3D_DEV_PATH : %s##", VPP_3D_DEV_PATH); |
118 | |
119 | if (vpp_amvideo_3d_fd < 0) { |
120 | LOGE("Open vpp 3d module, error(%s)!\n", strerror(errno)); |
121 | return -1; |
122 | } |
123 | } |
124 | |
125 | return vpp_amvideo_fd; |
126 | } |
127 | |
128 | int CVpp::VPP_CloseModule(void) |
129 | { |
130 | if (vpp_amvideo_fd >= 0) { |
131 | close ( vpp_amvideo_fd); |
132 | vpp_amvideo_fd = -1; |
133 | } |
134 | |
135 | if (vpp_amvideo_3d_fd >= 0) { |
136 | close ( vpp_amvideo_3d_fd); |
137 | vpp_amvideo_3d_fd = -1; |
138 | } |
139 | |
140 | return 0; |
141 | } |
142 | |
143 | int CVpp::VPP_DeviceIOCtl(int request, ...) |
144 | { |
145 | int tmp_ret = -1; |
146 | va_list ap; |
147 | void *arg; |
148 | va_start(ap, request); |
149 | arg = va_arg ( ap, void * ); |
150 | va_end(ap); |
151 | tmp_ret = ioctl(vpp_amvideo_fd, request, arg); |
152 | return tmp_ret; |
153 | } |
154 | |
155 | int CVpp::Vpp_LoadRegs(am_regs_t regs) |
156 | { |
157 | LOGD("~~~VPP_DeviceIOCtl~~~##Vpp_LoadRegs##AMVECM_IOC_LOAD_REG##"); |
158 | |
159 | int count_retry = 20; |
160 | int rt = 0; |
161 | while (count_retry) { |
162 | rt = VPP_DeviceIOCtl(AMVECM_IOC_LOAD_REG, ®s); |
163 | if (rt < 0) { |
164 | LOGE("%s, error(%s), errno(%d)\n", __FUNCTION__, strerror(errno), errno); |
165 | if (errno == EBUSY) { |
166 | LOGE("%s, %s, retry...\n", __FUNCTION__, strerror(errno)); |
167 | count_retry--; |
168 | continue; |
169 | } |
170 | break; |
171 | } |
172 | break; |
173 | } |
174 | |
175 | return rt; |
176 | } |
177 | |
178 | int CVpp::isPreviewWindow() |
179 | { |
180 | char prop_value[PROPERTY_VALUE_MAX]; |
181 | memset(prop_value, '\0', PROPERTY_VALUE_MAX); |
182 | property_get("tv.is.preview.window", prop_value, "false"); |
183 | LOGD("%s, prop tv.is.preview.window is \"%s\".\n", __FUNCTION__, prop_value); |
184 | return (strcmp(prop_value, "true") == 0) ? 1 : 0; |
185 | } |
186 | |
187 | int CVpp::LoadVppSettings(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, |
188 | is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
189 | { |
190 | int val = 0, ret = -1; |
191 | vpp_color_temperature_mode_t temp_mode = VPP_COLOR_TEMPERATURE_MODE_STANDARD; |
192 | vpp_picture_mode_t pqmode = VPP_PICTURE_MODE_STANDARD; |
193 | vpp_display_mode_t dispmode = VPP_DISPLAY_MODE_169; |
194 | vpp_noise_reduction_mode_t nr_mode = VPP_NOISE_REDUCTION_MODE_MID; |
195 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
196 | |
197 | if ((vpp_setting_last_source_type == source_type) && (vpp_setting_last_sig_fmt == sig_fmt) |
198 | /*&& ( vpp_setting_last_3d_status == status showbo mark)*/ |
199 | && (vpp_setting_last_trans_fmt == trans_fmt)) { |
200 | return -1; |
201 | } |
202 | |
203 | nr_mode = GetNoiseReductionMode(source_type); |
204 | ret |= Vpp_SetNoiseReductionMode(nr_mode, source_type, source_port, sig_fmt, is3d, trans_fmt); |
205 | ret |= Vpp_SetXVYCCMode(VPP_XVYCC_MODE_STANDARD, source_type, source_port, sig_fmt, is3d, |
206 | trans_fmt); |
207 | ret |= Vpp_SetMCDIMode(VPP_MCDI_MODE_STANDARD, source_type, source_port, sig_fmt, is3d, |
208 | trans_fmt); |
209 | ret |= Vpp_SetDeblockMode(VPP_DEBLOCK_MODE_MIDDLE, source_port, sig_fmt, is3d, trans_fmt); |
210 | |
211 | Vpp_LoadDI(source_type, sig_fmt, is3d, trans_fmt); |
212 | Vpp_LoadBasicRegs(source_type, sig_fmt, is3d, trans_fmt); |
213 | Vpp_LoadGamma(source_type, sig_fmt); |
214 | |
215 | ret |= Vpp_SetBaseColorMode(GetBaseColorMode(), source_port, sig_fmt, is3d, trans_fmt); |
216 | |
217 | if (isPreviewWindow()) { |
218 | temp_mode = GetColorTemperature(SOURCE_TYPE_MPEG); |
219 | if (temp_mode == VPP_COLOR_TEMPERATURE_MODE_USER) { |
220 | ret |= Vpp_SetColorTemperatureUser(temp_mode, SOURCE_TYPE_MPEG); |
221 | } else { |
222 | CheckColorTemperatureParamAlldata(TVIN_PORT_HDMI0, sig_fmt, trans_fmt); // check colortmp backup data |
223 | ret |= Vpp_SetColorTemperature(temp_mode, SOURCE_TYPE_MPEG, source_port, sig_fmt, trans_fmt); |
224 | } |
225 | } else { |
226 | temp_mode = GetColorTemperature(source_type); |
227 | if (temp_mode == VPP_COLOR_TEMPERATURE_MODE_USER) { |
228 | ret |= Vpp_SetColorTemperatureUser(temp_mode, source_type); |
229 | } else { |
230 | CheckColorTemperatureParamAlldata(TVIN_PORT_HDMI0, sig_fmt, trans_fmt); // check colortmp backup data |
231 | ret |= Vpp_SetColorTemperature(temp_mode, source_type, source_port, sig_fmt, trans_fmt); |
232 | } |
233 | } |
234 | |
235 | pqmode = GetPQMode(source_type); |
236 | ret |= Vpp_SetPQMode(pqmode, source_type, source_port, sig_fmt, is3d, trans_fmt); |
237 | |
238 | ret |= SetDNLP(source_type, source_port, sig_fmt, is3d, trans_fmt); |
239 | |
240 | vpp_setting_last_source_type = source_type; |
241 | vpp_setting_last_sig_fmt = sig_fmt; |
242 | //showbo mark vpp_setting_last_3d_status = status; |
243 | vpp_setting_last_trans_fmt = trans_fmt; |
244 | |
245 | return 0; |
246 | } |
247 | |
248 | int CVpp::Vpp_GetVppConfig(void) |
249 | { |
250 | const char *config_value; |
251 | int cfg_item_count = 0; |
252 | char *token = NULL; |
253 | const char *strDelimit = ","; |
254 | char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; |
255 | |
256 | config_value = config_get_str(CFG_SECTION_TV, "vpp.pqmode.depend.bklight", "null"); |
257 | |
258 | if (strcmp(config_value, "enable") == 0) { |
259 | mbVppCfg_pqmode_depend_bklight = true; |
260 | } else { |
261 | mbVppCfg_pqmode_depend_bklight = false; |
262 | } |
263 | |
264 | config_value = config_get_str(CFG_SECTION_TV, "vpp.color.temp.bysource", "enable"); |
265 | |
266 | if (strcmp(config_value, "enable") == 0) { |
267 | mbVppCfg_colortemp_by_source = true; |
268 | } else { |
269 | mbVppCfg_colortemp_by_source = true; |
270 | } |
271 | |
272 | config_value = config_get_str(CFG_SECTION_TV, "vpp.panoroma.switch", "null"); |
273 | |
274 | if (strcmp(config_value, "enable") == 0) { |
275 | mbVppCfg_panorama_switch = true; |
276 | } else { |
277 | mbVppCfg_panorama_switch = false; |
278 | } |
279 | |
280 | config_value = config_get_str(CFG_SECTION_TV, "vpp.backlight.reverse", "null"); |
281 | |
282 | if (strcmp(config_value, "enable") == 0) { |
283 | mbVppCfg_backlight_reverse = true; |
284 | } else { |
285 | mbVppCfg_backlight_reverse = false; |
286 | } |
287 | |
288 | config_value = config_get_str(CFG_SECTION_TV, "vpp.backlight.init", "null"); |
289 | |
290 | if (strcmp(config_value, "enable") == 0) { |
291 | mbVppCfg_backlight_init = true; |
292 | } else { |
293 | mbVppCfg_backlight_init = false; |
294 | } |
295 | |
296 | config_value = config_get_str(CFG_SECTION_TV, "vpp.pqwithout.hue", "null"); |
297 | |
298 | if (strcmp(config_value, "enable") == 0) { |
299 | mbVppCfg_pqmode_without_hue = true; |
300 | } else { |
301 | mbVppCfg_pqmode_without_hue = false; |
302 | } |
303 | |
304 | config_value = config_get_str(CFG_SECTION_TV, "vpp.hue.reverse", "null"); |
305 | |
306 | if (strcmp(config_value, "enable") == 0) { |
307 | mbVppCfg_hue_reverse = true; |
308 | } else { |
309 | mbVppCfg_hue_reverse = false; |
310 | } |
311 | |
312 | config_value = config_get_str(CFG_SECTION_TV, "vpp.gamma.onoff", "null"); |
313 | |
314 | if (strcmp(config_value, "disable") == 0) { |
315 | mbVppCfg_gamma_onoff = true; |
316 | } else { |
317 | mbVppCfg_gamma_onoff = false; |
318 | } |
319 | |
320 | config_value = config_get_str(CFG_SECTION_TV, "vpp.whitebalance.same_param", "null"); |
321 | |
322 | if (strcmp(config_value, "enable") == 0) { |
323 | mbVppCfg_whitebalance_sameparam = true; |
324 | } else { |
325 | mbVppCfg_whitebalance_sameparam = false; |
326 | } |
327 | |
328 | config_value = config_get_str(CFG_SECTION_TV, "vpp.new.cm", "disable"); |
329 | |
330 | if (strcmp(config_value, "enable") == 0) { |
331 | mbVppCfg_new_cm = true; |
332 | } else { |
333 | mbVppCfg_new_cm = false; |
334 | } |
335 | |
336 | config_value = config_get_str(CFG_SECTION_TV, "vpp.new.nr", "disable"); |
337 | |
338 | if (strcmp(config_value, "enable") == 0) { |
339 | mbVppCfg_new_nr = true; |
340 | } else { |
341 | mbVppCfg_new_nr = false; |
342 | } |
343 | |
344 | return 0; |
345 | } |
346 | |
347 | int CVpp::Vpp_LoadDI(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, |
348 | is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
349 | { |
350 | am_regs_t regs; |
351 | int ret = -1; |
352 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
353 | if (mpPqData->getRegValues("GeneralDITable", source_port, sig_fmt, is3d, trans_fmt, ®s) > 0) { |
354 | if (Vpp_LoadRegs(regs) < 0) { |
355 | LOGE("%s, Vpp_LoadRegs failed!\n", __FUNCTION__); |
356 | } else { |
357 | ret = 0; |
358 | } |
359 | } else { |
360 | LOGE("%s getRegValues failed!\n", "Vpp_LoadDI"); |
361 | } |
362 | return ret; |
363 | } |
364 | |
365 | int CVpp::Vpp_LoadBasicRegs(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, |
366 | is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
367 | { |
368 | am_regs_t regs; |
369 | int ret = -1, rangeRet = -1, formatRet = -1, enableFlag = -1; |
370 | |
371 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
372 | |
373 | if (mpPqData->getRegValues("GeneralCommonTable", source_port, sig_fmt, is3d, trans_fmt, ®s) > 0) { |
374 | if (Vpp_LoadRegs(regs) < 0) { |
375 | LOGE("%s, Vpp_LoadRegs failed!\n", __FUNCTION__); |
376 | } else { |
377 | ret = 0; |
378 | } |
379 | } else { |
380 | LOGE("%s getRegValues failed!\n", "Vpp_LoadBasicRegs"); |
381 | } |
382 | |
383 | if (mpPqData->LoadAllPQData(source_port, sig_fmt, is3d, trans_fmt, enableFlag) == 0) { |
384 | ret = 0; |
385 | } else { |
386 | LOGE("%s, getPQData failed!\n", "Vpp_LoadBasicRegs"); |
387 | ret = -1; |
388 | } |
389 | |
390 | return ret; |
391 | } |
392 | |
393 | int CVpp::Vpp_ResetLastVppSettingsSourceType(void) |
394 | { |
395 | vpp_setting_last_source_type = SOURCE_TYPE_MAX; |
396 | vpp_setting_last_sig_fmt = TVIN_SIG_FMT_MAX; |
397 | //showbo mark vpp_setting_last_3d_status = STATUS3D_MAX; |
398 | vpp_setting_last_trans_fmt = TVIN_TFMT_3D_MAX; |
399 | return 0; |
400 | } |
401 | |
402 | int CVpp::VPP3D_DeviceIOCtl(int request, ...) |
403 | { |
404 | int tmp_ret = -1; |
405 | va_list ap; |
406 | void *arg; |
407 | |
408 | if (vpp_amvideo_3d_fd >= 0) { |
409 | va_start(ap, request); |
410 | arg = va_arg ( ap, void * ); |
411 | va_end(ap); |
412 | |
413 | tmp_ret = ioctl(vpp_amvideo_3d_fd, request, arg); |
414 | return tmp_ret; |
415 | } |
416 | |
417 | return -1; |
418 | } |
419 | |
420 | int CVpp::Vpp_GetPQModeValue(tv_source_input_type_t source_type, vpp_picture_mode_t pq_mode, |
421 | vpp_pq_para_t *pq_para) |
422 | { |
423 | vpp_pq_para_t parms; |
424 | vpp_picture_mode_t real_pq_mode; |
425 | |
426 | if (pq_para == NULL) { |
427 | return -1; |
428 | } |
429 | |
430 | if (pq_mode == VPP_PICTURE_MODE_MOVIE) { |
431 | real_pq_mode = VPP_PICTURE_MODE_SOFT; |
432 | } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { |
433 | real_pq_mode = VPP_PICTURE_MODE_BRIGHT; |
434 | } else { |
435 | real_pq_mode = pq_mode; |
436 | } |
437 | if (mpPqData->PQ_GetPQModeParams(source_type, real_pq_mode, pq_para) == 0) { |
438 | if (mbVppCfg_pqmode_without_hue) { |
439 | SSMReadHue(source_type, &(pq_para->hue)); |
440 | } |
441 | if (pq_mode == VPP_PICTURE_MODE_MOVIE) { |
442 | pq_para->brightness -= 10; |
443 | pq_para->contrast -= 10; |
444 | pq_para->saturation -= 10; |
445 | pq_para->sharpness -= 10; |
446 | } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { |
447 | pq_para->brightness += 10; |
448 | pq_para->contrast += 10; |
449 | pq_para->saturation += 10; |
450 | pq_para->sharpness += 10; |
451 | } else { |
452 | } |
453 | |
454 | } else { |
455 | LOGE("%s, PQ_GetPQModeParams failed!\n", "Vpp_GetPQModeValue"); |
456 | return -1; |
457 | } |
458 | |
459 | return 0; |
460 | } |
461 | |
462 | int CVpp::Vpp_SetPQParams(tv_source_input_type_t source_type, vpp_picture_mode_t pq_mode, |
463 | vpp_pq_para_t pq_para, tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, |
464 | tvin_trans_fmt_t trans_fmt) |
465 | { |
466 | int ret = 0, brightness = 50, contrast = 50, saturation = 50, hue = 50, sharnpess = 50; |
467 | am_regs_t regs, regs_l; |
468 | int level; |
469 | |
470 | if (pq_para.brightness >= 0 && pq_para.brightness <= 100) { |
471 | if (mpPqData->PQ_GetBrightnessParams(source_port, sig_fmt, is3d, trans_fmt, |
472 | pq_para.brightness, &brightness) == 0) { |
473 | } else { |
474 | LOGE("%s, PQ_GetBrightnessParams error!\n", "Vpp_SetPQParams"); |
475 | } |
476 | |
477 | ret |= VPP_SetVideoBrightness(brightness); |
478 | } |
479 | |
480 | if (pq_para.contrast >= 0 && pq_para.contrast <= 100) { |
481 | if (mpPqData->PQ_GetContrastParams(source_port, sig_fmt, is3d, trans_fmt, pq_para.contrast, |
482 | &contrast) == 0) { |
483 | } else { |
484 | LOGE("%s, PQ_GetBrightnessParams error!\n", "Vpp_SetPQParams"); |
485 | } |
486 | |
487 | ret |= VPP_SetVideoContrast(contrast); |
488 | } |
489 | |
490 | if (pq_para.saturation >= 0 && pq_para.saturation <= 100) { |
491 | if (mpPqData->PQ_GetSaturationParams(source_port, sig_fmt, is3d, trans_fmt, |
492 | pq_para.saturation, &saturation) == 0) { |
493 | |
494 | if (mbVppCfg_hue_reverse) { |
495 | pq_para.hue = 100 - pq_para.hue; |
496 | } else { |
497 | pq_para.hue = pq_para.hue; |
498 | } |
499 | |
500 | if (mpPqData->PQ_GetHueParams(source_port, sig_fmt, is3d, trans_fmt, pq_para.hue, &hue) |
501 | == 0) { |
502 | if ((source_type == SOURCE_TYPE_TV || source_type == SOURCE_TYPE_AV) && (sig_fmt |
503 | == TVIN_SIG_FMT_CVBS_NTSC_M || sig_fmt == TVIN_SIG_FMT_CVBS_NTSC_443)) { |
504 | } else { |
505 | hue = 0; |
506 | } |
507 | } else { |
508 | LOGE("%s, PQ_GetHueParams error!\n", "Vpp_SetPQParams"); |
509 | } |
510 | } else { |
511 | LOGE("%s, PQ_GetSaturationParams error!\n", "Vpp_SetPQParams"); |
512 | } |
513 | |
514 | ret |= VPP_SetVideoSaturationHue(saturation, hue); |
515 | } |
516 | |
517 | if (pq_para.sharpness >= 0 && pq_para.sharpness <= 100) { |
518 | level = pq_para.sharpness; |
519 | |
520 | if (mpPqData->PQ_GetSharpnessParams(source_port, sig_fmt, is3d, trans_fmt, level, ®s, |
521 | ®s_l) == 0) { |
522 | if (Vpp_LoadRegs(regs) < 0) { |
523 | LOGE("%s, load reg for sharpness0 failed!\n", __FUNCTION__); |
524 | } |
525 | if (mpPqData->getSharpnessFlag() == 6 && Vpp_LoadRegs(regs_l) < 0) { |
526 | LOGE("%s, load reg for sharpness1 failed!\n", __FUNCTION__); |
527 | } |
528 | } else { |
529 | LOGE("%s, PQ_GetSharpnessParams failed!\n", __FUNCTION__); |
530 | } |
531 | } |
532 | |
533 | if (pq_mode == VPP_PICTURE_MODE_MOVIE) { |
534 | ret |= SetColorTemperature(VPP_COLOR_TEMPERATURE_MODE_WARM, source_type, 1); |
535 | } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { |
536 | ret |= SetColorTemperature(VPP_COLOR_TEMPERATURE_MODE_COLD, source_type, 1); |
537 | } |
538 | |
539 | return ret; |
540 | } |
541 | |
542 | int CVpp::Vpp_SetPQMode(vpp_picture_mode_t pq_mode, tv_source_input_type_t source_type, |
543 | tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, |
544 | tvin_trans_fmt_t trans_fmt) |
545 | { |
546 | vpp_pq_para_t pq_para; |
547 | int ret = -1; |
548 | |
549 | if (pq_mode == VPP_PICTURE_MODE_USER) { |
550 | ret = SSMReadBrightness(source_type, &pq_para.brightness); |
551 | ret = SSMReadContrast(source_type, &pq_para.contrast); |
552 | ret = SSMReadSaturation(source_type, &pq_para.saturation); |
553 | ret = SSMReadHue(source_type, &pq_para.hue); |
554 | ret = SSMReadSharpness(source_type, &pq_para.sharpness); |
555 | } /*else if (pq_mode == VPP_PICTURE_MODE_MOVIE) { |
556 | ret = Vpp_GetPQModeValue ( source_type, VPP_PICTURE_MODE_SOFT, &pq_para ); |
557 | pq_para.brightness -=10; |
558 | pq_para.contrast -=10; |
559 | pq_para.saturation -=10; |
560 | pq_para.sharpness -=10; |
561 | } else if (pq_mode == VPP_PICTURE_MODE_COLORFUL) { |
562 | ret = Vpp_GetPQModeValue ( source_type, VPP_PICTURE_MODE_BRIGHT, &pq_para ); |
563 | pq_para.brightness +=10; |
564 | pq_para.contrast +=10; |
565 | pq_para.saturation +=10; |
566 | pq_para.sharpness +=10; |
567 | }*/else { |
568 | ret = Vpp_GetPQModeValue(source_type, pq_mode, &pq_para); |
569 | } |
570 | |
571 | ret |= Vpp_SetPQParams(source_type, pq_mode, pq_para, source_port, sig_fmt, is3d, trans_fmt); |
572 | |
573 | return ret; |
574 | } |
575 | |
576 | int CVpp::SavePQMode(vpp_picture_mode_t pq_mode, tv_source_input_type_t source_type) |
577 | { |
578 | vpp_pq_para_t pq_para; |
579 | int ret = -1; |
580 | int tmp_pic_mode = 0; |
581 | |
582 | tmp_pic_mode = (int) pq_mode; |
583 | ret = SSMSavePictureMode(source_type, tmp_pic_mode); |
584 | return ret; |
585 | } |
586 | |
587 | int CVpp::SetPQMode(vpp_picture_mode_t pq_mode, tv_source_input_type_t source_type, |
588 | tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) |
589 | { |
590 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
591 | |
592 | if (0 == Vpp_SetPQMode(pq_mode, source_type, source_port, sig_fmt, is3d, trans_fmt)) { |
593 | if (is_save == 1) { |
594 | return SavePQMode(pq_mode, source_type); |
595 | } else { |
596 | return 0; |
597 | } |
598 | } |
599 | |
600 | LOGE("%s, failed!", "SetPQMode"); |
601 | return -1; |
602 | } |
603 | |
604 | vpp_picture_mode_t CVpp::GetPQMode(tv_source_input_type_t source_type) |
605 | { |
606 | vpp_picture_mode_t data = VPP_PICTURE_MODE_STANDARD; |
607 | int tmp_pic_mode = 0; |
608 | |
609 | SSMReadPictureMode(source_type, &tmp_pic_mode); |
610 | data = (vpp_picture_mode_t) tmp_pic_mode; |
611 | |
612 | if (data < VPP_PICTURE_MODE_STANDARD || data >= VPP_PICTURE_MODE_MAX) { |
613 | data = VPP_PICTURE_MODE_STANDARD; |
614 | } |
615 | |
616 | return data; |
617 | } |
618 | |
619 | int CVpp::Vpp_SetColorDemoMode(vpp_color_demomode_t demomode) |
620 | { |
621 | cm_regmap_t regmap; |
622 | unsigned long *temp_regmap; |
623 | int i = 0; |
624 | int tmp_demo_mode = 0; |
625 | vpp_display_mode_t displaymode = VPP_DISPLAY_MODE_MODE43; |
626 | |
627 | switch (demomode) { |
628 | case VPP_COLOR_DEMO_MODE_YOFF: |
629 | temp_regmap = DemoColorYOffRegMap; |
630 | break; |
631 | |
632 | case VPP_COLOR_DEMO_MODE_COFF: |
633 | temp_regmap = DemoColorCOffRegMap; |
634 | break; |
635 | |
636 | case VPP_COLOR_DEMO_MODE_GOFF: |
637 | temp_regmap = DemoColorGOffRegMap; |
638 | break; |
639 | |
640 | case VPP_COLOR_DEMO_MODE_MOFF: |
641 | temp_regmap = DemoColorMOffRegMap; |
642 | break; |
643 | |
644 | case VPP_COLOR_DEMO_MODE_ROFF: |
645 | temp_regmap = DemoColorROffRegMap; |
646 | break; |
647 | |
648 | case VPP_COLOR_DEMO_MODE_BOFF: |
649 | temp_regmap = DemoColorBOffRegMap; |
650 | break; |
651 | |
652 | case VPP_COLOR_DEMO_MODE_RGBOFF: |
653 | temp_regmap = DemoColorRGBOffRegMap; |
654 | break; |
655 | |
656 | case VPP_COLOR_DEMO_MODE_YMCOFF: |
657 | temp_regmap = DemoColorYMCOffRegMap; |
658 | break; |
659 | |
660 | case VPP_COLOR_DEMO_MODE_ALLOFF: |
661 | temp_regmap = DemoColorALLOffRegMap; |
662 | break; |
663 | |
664 | case VPP_COLOR_DEMO_MODE_ALLON: |
665 | default: |
666 | if (displaymode == VPP_DISPLAY_MODE_MODE43) { |
667 | temp_regmap = DemoColorSplit4_3RegMap; |
668 | } else { |
669 | temp_regmap = DemoColorSplitRegMap; |
670 | } |
671 | |
672 | break; |
673 | } |
674 | |
675 | for (i = 0; i < CM_REG_NUM; i++) { |
676 | regmap.reg[i] = temp_regmap[i]; |
677 | } |
678 | |
679 | if (VPP_SetCMRegisterMap(®map) == 0) { |
680 | tmp_demo_mode = demomode; |
681 | LOGD("%s, demomode[%d] success.", "Vpp_SetColorDemoMode", demomode); |
682 | return 0; |
683 | } |
684 | |
685 | LOGE("%s, demomode[%d] failed.", "Vpp_SetColorDemoMode", demomode); |
686 | return -1; |
687 | } |
688 | |
689 | int CVpp::Vpp_SetBaseColorMode(vpp_color_basemode_t basemode, tvin_port_t source_port, |
690 | tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
691 | { |
692 | int ret = -1; |
693 | am_regs_t regs; |
694 | LOGD("%s.\n", "Vpp_SetBaseColorMode"); |
695 | |
696 | if (mbVppCfg_new_cm) { |
697 | if (mpPqData->PQ_GetCM2Params((vpp_color_management2_t) basemode, source_port, sig_fmt, |
698 | is3d, trans_fmt, ®s) == 0) { |
699 | ret = Vpp_LoadRegs(regs); |
700 | } else { |
701 | LOGE("PQ_GetCM2Params failed!\n"); |
702 | } |
703 | } |
704 | |
705 | return ret; |
706 | } |
707 | |
708 | int CVpp::Vpp_SetColorTemperatureUser(vpp_color_temperature_mode_t temp_mode, |
709 | tv_source_input_type_t source_type) |
710 | { |
711 | tcon_rgb_ogo_t rgbogo; |
712 | unsigned int gain_r, gain_g, gain_b; |
713 | |
714 | if (SSMReadRGBGainRStart(0, &gain_r) != 0) { |
715 | return -1; |
716 | } |
717 | |
718 | rgbogo.r_gain = gain_r; |
719 | |
720 | if (SSMReadRGBGainGStart(0, &gain_g) != 0) { |
721 | return -1; |
722 | } |
723 | |
724 | rgbogo.g_gain = gain_g; |
725 | |
726 | if (SSMReadRGBGainBStart(0, &gain_b) != 0) { |
727 | return -1; |
728 | } |
729 | |
730 | rgbogo.b_gain = gain_b; |
731 | rgbogo.r_post_offset = 0; |
732 | rgbogo.r_pre_offset = 0; |
733 | rgbogo.g_post_offset = 0; |
734 | rgbogo.g_pre_offset = 0; |
735 | rgbogo.b_post_offset = 0; |
736 | rgbogo.b_pre_offset = 0; |
737 | |
738 | if (VPP_SetRGBOGO(&rgbogo) == 0) { |
739 | return 0; |
740 | } |
741 | |
742 | LOGE("%s, source_type_user[%d] failed.", "Vpp_SetColorTemperatureUser", source_type); |
743 | return -1; |
744 | } |
745 | |
746 | int CVpp::Vpp_SetColorTemperature(vpp_color_temperature_mode_t Tempmode, |
747 | tv_source_input_type_t source_type, tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, |
748 | tvin_trans_fmt_t trans_fmt) |
749 | { |
750 | tcon_rgb_ogo_t rgbogo, rgbPreOffset; |
751 | int ret = -1; |
752 | |
753 | if (mbVppCfg_gamma_onoff) { |
754 | VPP_SetGammaOnOff(0); |
755 | } else { |
756 | VPP_SetGammaOnOff(1); |
757 | } |
758 | |
759 | GetColorTemperatureParams(Tempmode, &rgbogo); |
760 | |
761 | if (VPP_SetRGBOGO(&rgbogo) == 0) { |
762 | return 0; |
763 | } |
764 | |
765 | LOGE("%s, source_type[%d] failed.", "Vpp_SetColorTemperature", source_type); |
766 | return -1; |
767 | } |
768 | |
769 | int CVpp::Vpp_SetBrightness(int value, tv_source_input_type_t source_type, tvin_port_t source_port, |
770 | tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
771 | { |
772 | int ret = -1; |
773 | int params; |
774 | int level; |
775 | |
776 | if (value >= 0 && value <= 100) { |
777 | level = value; |
778 | LOGD("%s.\n", "Vpp_SetBrightness"); |
779 | |
780 | if (mpPqData->PQ_GetBrightnessParams(source_port, sig_fmt, is3d, trans_fmt, level, ¶ms) |
781 | == 0) { |
782 | if (VPP_SetVideoBrightness(params) == 0) { |
783 | return 0; |
784 | } |
785 | } else { |
786 | LOGE("%s, PQ_GetBrightnessParams failed!\n", "Vpp_SetBrightness"); |
787 | } |
788 | } |
789 | |
790 | return ret; |
791 | } |
792 | |
793 | int CVpp::VPP_SetVideoBrightness(int value) |
794 | { |
795 | FILE *fp = NULL; |
796 | |
797 | fp = fopen("/sys/class/amvecm/brightness", "w"); |
798 | |
799 | LOGD("~~~fopen~~~##VPP_SetVideoBrightness##%s : %d ##", "/sys/class/amvecm/brightness", value); |
800 | |
801 | if (fp == NULL) { |
802 | LOGE("Open /sys/class/amvecm/brightness error(%s)!\n", strerror(errno)); |
803 | return -1; |
804 | } |
805 | |
806 | fprintf(fp, "%d", value); |
807 | fclose(fp); |
808 | fp = NULL; |
809 | |
810 | return 0; |
811 | } |
812 | |
813 | int CVpp::SetBrightness(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, |
814 | tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) |
815 | { |
816 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
817 | |
818 | if (0 == Vpp_SetBrightness(value, source_type, source_port, sig_fmt, is3d, trans_fmt)) { |
819 | if (is_save == 1) { |
820 | return SSMSaveBrightness(source_type, value); |
821 | } else { |
822 | return 0; |
823 | } |
824 | } else { |
825 | LOGE("%s, failed!", "SetBrightness"); |
826 | return -1; |
827 | } |
828 | return 0; |
829 | } |
830 | |
831 | int CVpp::GetBrightness(tv_source_input_type_t source_type) |
832 | { |
833 | int data = 50; |
834 | vpp_pq_para_t pq_para; |
835 | vpp_picture_mode_t pq_mode = GetPQMode(source_type); |
836 | |
837 | if (pq_mode == VPP_PICTURE_MODE_USER) { |
838 | SSMReadBrightness(source_type, &data); |
839 | } else { |
840 | if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { |
841 | data = pq_para.brightness; |
842 | } |
843 | } |
844 | |
845 | if (data < 0 || data > 100) { |
846 | data = 50; |
847 | } |
848 | |
849 | return data; |
850 | } |
851 | |
852 | int CVpp::Vpp_SetContrast(int value, tv_source_input_type_t source_type, tvin_port_t source_port, |
853 | tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
854 | { |
855 | int ret = -1; |
856 | int params; |
857 | int level; |
858 | |
859 | if (value >= 0 && value <= 100) { |
860 | level = value; |
861 | LOGD("%s.\n", "Vpp_SetContrast"); |
862 | |
863 | if (mpPqData->PQ_GetContrastParams(source_port, sig_fmt, is3d, trans_fmt, level, ¶ms) |
864 | == 0) { |
865 | if (VPP_SetVideoContrast(params) == 0) { |
866 | return 0; |
867 | } |
868 | } else { |
869 | LOGE("%s, PQ_GetContrastParams failed!\n", "Vpp_SetContrast"); |
870 | } |
871 | } |
872 | |
873 | return ret; |
874 | } |
875 | |
876 | int CVpp::VPP_SetVideoContrast(int value) |
877 | { |
878 | FILE *fp = NULL; |
879 | |
880 | fp = fopen("/sys/class/amvecm/contrast", "w"); |
881 | LOGD("~~~fopen~~~##VPP_SetVideoContrast##%s : %d ##", "/sys/class/amvecm/contrast", value); |
882 | |
883 | if (fp == NULL) { |
884 | LOGE("Open /sys/class/amvecm/contrast error(%s)!\n", strerror(errno)); |
885 | return -1; |
886 | } |
887 | |
888 | fprintf(fp, "%d", value); |
889 | fclose(fp); |
890 | fp = NULL; |
891 | |
892 | return 0; |
893 | } |
894 | |
895 | int CVpp::SetContrast(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, |
896 | tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) |
897 | { |
898 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
899 | |
900 | if (0 == Vpp_SetContrast(value, source_type, source_port, sig_fmt, is3d, trans_fmt)) { |
901 | if (is_save == 1) { |
902 | return SSMSaveContrast(source_type, value); |
903 | } else { |
904 | return 0; |
905 | } |
906 | } else { |
907 | LOGE("%s, failed!", "SetContrast"); |
908 | return -1; |
909 | } |
910 | } |
911 | |
912 | int CVpp::GetContrast(tv_source_input_type_t source_type) |
913 | { |
914 | int data = 50; |
915 | vpp_pq_para_t pq_para; |
916 | vpp_picture_mode_t pq_mode = GetPQMode(source_type); |
917 | |
918 | if (pq_mode == VPP_PICTURE_MODE_USER) { |
919 | SSMReadContrast(source_type, &data); |
920 | } else { |
921 | if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { |
922 | data = pq_para.contrast; |
923 | } |
924 | } |
925 | |
926 | if (data < 0 || data > 100) { |
927 | data = 50; |
928 | } |
929 | |
930 | return data; |
931 | } |
932 | |
933 | int CVpp::Vpp_SetSaturation(int value, tv_source_input_type_t source_type, tvin_port_t source_port, |
934 | tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
935 | { |
936 | int ret = -1; |
937 | int params; |
938 | int level; |
939 | int hue = 0; |
940 | |
941 | if (value >= 0 && value <= 100) { |
942 | level = value; |
943 | |
944 | if (mpPqData->PQ_GetSaturationParams(source_port, sig_fmt, is3d, trans_fmt, level, ¶ms) |
945 | == 0) { |
946 | if (VPP_SetVideoSaturationHue(params, hue) == 0) { |
947 | return 0; |
948 | } |
949 | } else { |
950 | } |
951 | } |
952 | |
953 | return ret; |
954 | } |
955 | |
956 | int CVpp::SetSaturation(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, |
957 | tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) |
958 | { |
959 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
960 | |
961 | if (0 == Vpp_SetSaturation(value, source_type, source_port, sig_fmt, is3d, trans_fmt)) { |
962 | if (is_save == 1) { |
963 | return SSMSaveSaturation(source_type, value); |
964 | } else { |
965 | return 0; |
966 | } |
967 | } else { |
968 | LOGE("%s, failed!", "SetSaturation"); |
969 | return -1; |
970 | } |
971 | } |
972 | |
973 | int CVpp::GetSaturation(tv_source_input_type_t source_type) |
974 | { |
975 | int data = 50; |
976 | vpp_pq_para_t pq_para; |
977 | vpp_picture_mode_t pq_mode = GetPQMode(source_type); |
978 | |
979 | if (pq_mode == VPP_PICTURE_MODE_USER) { |
980 | SSMReadSaturation(source_type, &data); |
981 | } else { |
982 | if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { |
983 | data = pq_para.saturation; |
984 | } |
985 | } |
986 | |
987 | if (data < 0 || data > 100) { |
988 | data = 50; |
989 | } |
990 | |
991 | return data; |
992 | } |
993 | |
994 | int CVpp::Vpp_SetHue(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, |
995 | tvin_port_t source_port, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
996 | { |
997 | int ret = -1; |
998 | int params, saturation_params; |
999 | int level, saturation_level; |
1000 | |
1001 | if (value >= 0 && value <= 100) { |
1002 | if (mbVppCfg_hue_reverse) { |
1003 | level = 100 - value; |
1004 | } else { |
1005 | level = value; |
1006 | } |
1007 | |
1008 | if (mpPqData->PQ_GetHueParams(source_port, sig_fmt, is3d, trans_fmt, level, ¶ms) == 0) { |
1009 | saturation_level = GetSaturation(source_type); |
1010 | |
1011 | if (mpPqData->PQ_GetSaturationParams(source_port, sig_fmt, is3d, trans_fmt, |
1012 | saturation_level, &saturation_params) == 0) { |
1013 | } else { |
1014 | saturation_params = -20; |
1015 | } |
1016 | |
1017 | if (VPP_SetVideoSaturationHue(saturation_params, params) == 0) { |
1018 | return 0; |
1019 | } |
1020 | } else { |
1021 | LOGE("PQ_GetHueParams failed!\n"); |
1022 | } |
1023 | } |
1024 | |
1025 | return ret; |
1026 | } |
1027 | |
1028 | int CVpp::SetHue(int value, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, |
1029 | tvin_trans_fmt_t trans_fmt, is_3d_type_t is3d, int is_save) |
1030 | { |
1031 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
1032 | |
1033 | if (0 == Vpp_SetHue(value, source_type, sig_fmt, source_port, is3d, trans_fmt)) { |
1034 | if (is_save == 1) { |
1035 | return SSMSaveHue(source_type, value); |
1036 | } else { |
1037 | return 0; |
1038 | } |
1039 | } else { |
1040 | LOGE("%s, failed!", "SetHue"); |
1041 | return -1; |
1042 | } |
1043 | |
1044 | return 0; |
1045 | } |
1046 | |
1047 | int CVpp::GetHue(tv_source_input_type_t source_type) |
1048 | { |
1049 | int data = 50; |
1050 | vpp_pq_para_t pq_para; |
1051 | vpp_picture_mode_t pq_mode = GetPQMode(source_type); |
1052 | |
1053 | if (pq_mode == VPP_PICTURE_MODE_USER) { |
1054 | SSMReadHue(source_type, &data); |
1055 | } else { |
1056 | if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { |
1057 | data = pq_para.hue; |
1058 | } |
1059 | } |
1060 | |
1061 | if (data < 0 || data > 100) { |
1062 | data = 50; |
1063 | } |
1064 | |
1065 | return data; |
1066 | } |
1067 | |
1068 | int CVpp::Vpp_SetSharpness(int value, tv_source_input_type_t source_type, tvin_port_t source_port, |
1069 | tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
1070 | { |
1071 | int ret = -1; |
1072 | am_regs_t regs, regs_l; |
1073 | int level; |
1074 | |
1075 | if (value >= 0 && value <= 100) { |
1076 | level = value; |
1077 | |
1078 | if (mpPqData->PQ_GetSharpnessParams(source_port, sig_fmt, is3d, trans_fmt, level, ®s, ®s_l) == 0) { |
1079 | LOGD("%s, sharpness flag:%d\n", __FUNCTION__, mpPqData->getSharpnessFlag()); |
1080 | if (mpPqData->getSharpnessFlag() == 6) { |
1081 | if (Vpp_LoadRegs(regs) >= 0 && Vpp_LoadRegs(regs_l) >= 0) |
1082 | ret = 0; |
1083 | } else { |
1084 | if (Vpp_LoadRegs(regs) >= 0) |
1085 | ret = 0; |
1086 | } |
1087 | } else { |
1088 | } |
1089 | } |
1090 | |
1091 | return ret; |
1092 | } |
1093 | |
1094 | int CVpp::SetSharpness(int value, tv_source_input_type_t source_type, int is_enable, |
1095 | is_3d_type_t is3d, tvin_sig_fmt_t sig_fmt, tvin_trans_fmt_t trans_fmt, int is_save) |
1096 | { |
1097 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
1098 | |
1099 | if (Vpp_SetSharpness(value, source_type, source_port, sig_fmt, is3d, trans_fmt) < 0) { |
1100 | LOGE("%s, failed!", "SetSharpness"); |
1101 | return -1; |
1102 | } |
1103 | |
1104 | if (is_save == 1) { |
1105 | if (is_enable) { |
1106 | return SSMSaveSharpness(source_type, value); |
1107 | |
1108 | } |
1109 | } |
1110 | |
1111 | return 0; |
1112 | } |
1113 | |
1114 | int CVpp::GetSharpness(tv_source_input_type_t source_type) |
1115 | { |
1116 | int data = 50; |
1117 | vpp_pq_para_t pq_para; |
1118 | vpp_picture_mode_t pq_mode = GetPQMode(source_type); |
1119 | |
1120 | if (pq_mode == VPP_PICTURE_MODE_USER) { |
1121 | SSMReadSharpness(source_type, &data); |
1122 | } else { |
1123 | if (Vpp_GetPQModeValue(source_type, pq_mode, &pq_para) == 0) { |
1124 | data = pq_para.sharpness; |
1125 | } |
1126 | } |
1127 | |
1128 | if (data < 0 || data > 100) { |
1129 | data = 50; |
1130 | } |
1131 | |
1132 | LOGD("%s, data[%d].", "GetSharpness", data); |
1133 | return data; |
1134 | } |
1135 | |
1136 | int CVpp::SetColorSpaceMode(vpp_color_space_type_t colorSpace) |
1137 | { |
1138 | int ret = -1, fileRet = -1; |
1139 | SSMSaveColorSpaceStart(colorSpace); |
1140 | |
1141 | switch (colorSpace) { |
1142 | case VPP_COLOR_SPACE_RGB: |
1143 | //marked by haifeng |
1144 | // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1da1 0xc" ); |
1145 | // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d70 0x208" ); |
1146 | // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d71 0x74" ); |
1147 | break; |
1148 | |
1149 | case VPP_COLOR_SPACE_YUV: |
1150 | //marked by haifeng |
1151 | // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1da1 0xe" ); |
1152 | // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d70 0x208" ); |
1153 | // SetFileAttrValue ( "/sys/class/register/reg", "wc 0x1d71 0x76" ); |
1154 | break; |
1155 | |
1156 | default: |
1157 | break; |
1158 | } |
1159 | |
1160 | return 0; |
1161 | } |
1162 | |
1163 | int CVpp::Vpp_SetNoiseReductionMode(vpp_noise_reduction_mode_t nr_mode, |
1164 | tv_source_input_type_t source_type, tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, |
1165 | is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
1166 | { |
1167 | int ret = -1; |
1168 | am_regs_t regs; |
1169 | |
1170 | if (mbVppCfg_new_nr) { |
1171 | if (mpPqData->PQ_GetNR2Params((vpp_noise_reduction2_mode_t) nr_mode, source_port, sig_fmt, |
1172 | is3d, trans_fmt, ®s) == 0) { |
1173 | ret = Vpp_LoadRegs(regs); |
1174 | } else { |
1175 | LOGE("PQ_GetNR2Params failed!\n"); |
1176 | } |
1177 | } |
1178 | |
1179 | return ret; |
1180 | } |
1181 | |
1182 | int CVpp::SaveNoiseReductionMode(vpp_noise_reduction_mode_t nr_mode, |
1183 | tv_source_input_type_t source_type) |
1184 | { |
1185 | int tmp_save_noisereduction_mode = (int) nr_mode; |
1186 | return SSMSaveNoiseReduction(source_type, tmp_save_noisereduction_mode); |
1187 | } |
1188 | |
1189 | int CVpp::SetNoiseReductionMode(vpp_noise_reduction_mode_t nr_mode, |
1190 | tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, |
1191 | tvin_trans_fmt_t trans_fmt, int is_save) |
1192 | { |
1193 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
1194 | if (0 == Vpp_SetNoiseReductionMode(nr_mode, source_type, source_port, sig_fmt, is3d, trans_fmt)) { |
1195 | if (is_save == 1) { |
1196 | return SaveNoiseReductionMode(nr_mode, source_type); |
1197 | } else { |
1198 | return 0; |
1199 | } |
1200 | } |
1201 | |
1202 | LOGE("%s, failed!", __FUNCTION__); |
1203 | return -1; |
1204 | } |
1205 | |
1206 | vpp_noise_reduction_mode_t CVpp::GetNoiseReductionMode(tv_source_input_type_t source_type) |
1207 | { |
1208 | vpp_noise_reduction_mode_t data = VPP_NOISE_REDUCTION_MODE_MID; |
1209 | int tmp_nr_mode = 0; |
1210 | |
1211 | SSMReadNoiseReduction(source_type, &tmp_nr_mode); |
1212 | data = (vpp_noise_reduction_mode_t) tmp_nr_mode; |
1213 | |
1214 | if (data < VPP_NOISE_REDUCTION_MODE_OFF || data > VPP_NOISE_REDUCTION_MODE_AUTO) { |
1215 | data = VPP_NOISE_REDUCTION_MODE_MID; |
1216 | } |
1217 | |
1218 | return data; |
1219 | } |
1220 | |
1221 | int CVpp::Vpp_SetXVYCCMode(vpp_xvycc_mode_t xvycc_mode, tv_source_input_type_t source_type, |
1222 | tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, |
1223 | tvin_trans_fmt_t trans_fmt) |
1224 | { |
1225 | int ret = -1; |
1226 | am_regs_t regs, regs_1; |
1227 | char prop_value[PROPERTY_VALUE_MAX]; |
1228 | |
1229 | memset(prop_value, '\0', 16); |
1230 | const char *config_value; |
1231 | config_value = config_get_str(CFG_SECTION_TV, "vpp.xvycc.switch_control", "null"); |
1232 | |
1233 | if (strcmp(config_value, "enable") == 0) { |
1234 | if (mpPqData->PQ_GetXVYCCParams((vpp_xvycc_mode_t) xvycc_mode, source_port, sig_fmt, is3d, |
1235 | trans_fmt, ®s, ®s_1) == 0) { |
1236 | ret = Vpp_LoadRegs(regs); |
1237 | ret |= Vpp_LoadRegs(regs_1); |
1238 | } else { |
1239 | LOGE("PQ_GetXVYCCParams failed!\n"); |
1240 | } |
1241 | } else { |
1242 | LOGE("disable xvycc!\n"); |
1243 | } |
1244 | return ret; |
1245 | } |
1246 | |
1247 | int CVpp::Vpp_SetMCDIMode(vpp_mcdi_mode_t mcdi_mode, tv_source_input_type_t source_type, |
1248 | tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, |
1249 | tvin_trans_fmt_t trans_fmt) |
1250 | { |
1251 | int ret = -1; |
1252 | am_regs_t regs; |
1253 | |
1254 | if (mpPqData->PQ_GetMCDIParams((vpp_mcdi_mode_t) mcdi_mode, source_port, sig_fmt, is3d, |
1255 | trans_fmt, ®s) == 0) { |
1256 | ret = Vpp_LoadRegs(regs); |
1257 | } else { |
1258 | LOGE("%s, PQ_GetMCDIParams failed!\n", __FUNCTION__); |
1259 | } |
1260 | return ret; |
1261 | } |
1262 | |
1263 | int CVpp::Vpp_SetDeblockMode(vpp_deblock_mode_t mode, tvin_port_t source_port, |
1264 | tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
1265 | { |
1266 | int ret = -1; |
1267 | am_regs_t regs; |
1268 | |
1269 | if (mpPqData->PQ_GetDeblockParams(mode, source_port, sig_fmt, is3d, trans_fmt, ®s) == 0) { |
1270 | ret = Vpp_LoadRegs(regs); |
1271 | } else { |
1272 | LOGE("%s PQ_GetDeblockParams failed!\n", __FUNCTION__); |
1273 | } |
1274 | return ret; |
1275 | } |
1276 | |
1277 | int CVpp::Vpp_LoadGammaDefault(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt) |
1278 | { |
1279 | int ret = -1; |
1280 | int panel_id = 0; |
1281 | tcon_gamma_table_t gamma_r, gamma_g, gamma_b; |
1282 | |
1283 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType(source_type); |
1284 | |
1285 | LOGD("Enter %s.\n", __FUNCTION__); |
1286 | ret = mpPqData->PQ_GetGammaTableR(panel_id, source_port, sig_fmt, &gamma_r); |
1287 | ret |= mpPqData->PQ_GetGammaTableG(panel_id, source_port, sig_fmt, &gamma_g); |
1288 | ret |= mpPqData->PQ_GetGammaTableB(panel_id, source_port, sig_fmt, &gamma_b); |
1289 | |
1290 | if (ret == 0) { |
1291 | VPP_SetGammaTbl_R((unsigned short *) gamma_r.data); |
1292 | VPP_SetGammaTbl_G((unsigned short *) gamma_g.data); |
1293 | VPP_SetGammaTbl_B((unsigned short *) gamma_b.data); |
1294 | } else { |
1295 | LOGE("%s, PQ_GetGammaTable failed!", __FUNCTION__); |
1296 | } |
1297 | |
1298 | return ret; |
1299 | |
1300 | } |
1301 | |
1302 | int CVpp::Vpp_LoadGammaSpecial(int gammaValue) |
1303 | { |
1304 | int ret = -1; |
1305 | int panel_id = 0; |
1306 | tcon_gamma_table_t gamma_r, gamma_g, gamma_b; |
1307 | |
1308 | LOGD("Enter %s.\n", __FUNCTION__); |
1309 | ret = mpPqData->PQ_GetGammaSpecialTable(gammaValue, "Red", &gamma_r); |
1310 | ret |= mpPqData->PQ_GetGammaSpecialTable(gammaValue, "Green", &gamma_g); |
1311 | ret |= mpPqData->PQ_GetGammaSpecialTable(gammaValue, "Blue", &gamma_b); |
1312 | |
1313 | if (ret == 0) { |
1314 | VPP_SetGammaTbl_R((unsigned short *) gamma_r.data); |
1315 | VPP_SetGammaTbl_G((unsigned short *) gamma_g.data); |
1316 | VPP_SetGammaTbl_B((unsigned short *) gamma_b.data); |
1317 | } else { |
1318 | LOGE("%s, PQ_GetGammaSpecialTable failed!", __FUNCTION__); |
1319 | } |
1320 | |
1321 | return ret; |
1322 | |
1323 | } |
1324 | |
1325 | int CVpp::Vpp_LoadGamma(tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt) |
1326 | { |
1327 | int gammaValue = 0, ret = -1; |
1328 | |
1329 | if (SSMReadGammaValue(&gammaValue) < 0) { |
1330 | LOGE("%s, SSMReadGammaValue ERROR, So Load Default GAMMA!\n", __FUNCTION__); |
1331 | ret = Vpp_LoadGammaDefault(source_type, sig_fmt); |
1332 | return -1; |
1333 | } |
1334 | |
1335 | if (gammaValue < -4 || gammaValue > 4) { |
1336 | LOGE("%s, Gamma Value beyond the UI's range of -4 to 4 .\n", __FUNCTION__); |
1337 | gammaValue = 0; |
1338 | SSMSaveGammaValue(gammaValue); |
1339 | } |
1340 | |
1341 | switch (gammaValue) { |
1342 | case 0: |
1343 | ret = Vpp_LoadGammaDefault(source_type, sig_fmt); |
1344 | break; |
1345 | |
1346 | default: |
1347 | ret = Vpp_LoadGammaSpecial(gammaValue); |
1348 | break; |
1349 | } |
1350 | |
1351 | return ret; |
1352 | } |
1353 | |
1354 | /*int CVpp::SetGammaValue(int gammaValue) |
1355 | { |
1356 | int ret = -1; |
1357 | tvin_sig_fmt_t sig_fmt = TVIN_SIG_FMT_NULL; |
1358 | tv_source_input_type_t source_type = SOURCE_TYPE_TV; |
1359 | sig_fmt = Tvin_GetSigFormat(); |
1360 | source_type = Tvin_GetSrcInputType(); |
1361 | LOGD("%s, source_type = %d, sig_fmt = %d, gammaValue = %d\n", __FUNCTION__, (int)source_type, |
1362 | (int)sig_fmt, gammaValue); |
1363 | if (gammaValue >= -4 || gammaValue <= 4) { |
1364 | switch (gammaValue) { |
1365 | case 0: |
1366 | ret = Vpp_LoadGammaDefault(source_type, sig_fmt); |
1367 | break; |
1368 | default: |
1369 | ret = Vpp_LoadGammaSpecial(gammaValue); |
1370 | break; |
1371 | } |
1372 | if (0 == ret) |
1373 | ret = SSMSaveGammaValue(gammaValue); |
1374 | } |
1375 | return ret; |
1376 | }*/ |
1377 | |
1378 | int CVpp::GetGammaValue() |
1379 | { |
1380 | int gammaValue = 0; |
1381 | |
1382 | if (SSMReadGammaValue(&gammaValue) < 0) { |
1383 | LOGE("%s, SSMReadGammaValue ERROR!!!\n", __FUNCTION__); |
1384 | return -1; |
1385 | } |
1386 | |
1387 | return gammaValue; |
1388 | } |
1389 | |
1390 | /*int CVpp::SetColorDemoMode ( vpp_color_demomode_t demomode ) |
1391 | { |
1392 | tv_source_input_type_t source_type = Tvin_GetSrcInputType(); |
1393 | tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceType ( source_type ); |
1394 | tvin_sig_fmt_t sig_fmt = Tvin_GetSigFormat(); |
1395 | is_3d_type_t is3d = Tvin_Get3DStatus(); |
1396 | tvin_trans_fmt_t trans_fmt = Tvin_GetSigTransFormat(); |
1397 | |
1398 | return SetBaseColorMode ( VPP_COLOR_BASE_MODE_DEMO ,source_port,sig_fmt,status,trans_fmt); |
1399 | }*/ |
1400 | |
1401 | vpp_color_demomode_t CVpp::GetColorDemoMode(void) |
1402 | { |
1403 | vpp_color_demomode_t data = VPP_COLOR_DEMO_MODE_ALLON; |
1404 | unsigned char tmp_demo_mode = 0; |
1405 | SSMReadColorDemoMode(&tmp_demo_mode); |
1406 | data = (vpp_color_demomode_t) tmp_demo_mode; |
1407 | |
1408 | if (data < VPP_COLOR_DEMO_MODE_ALLON || data > VPP_COLOR_DEMO_MODE_ALLOFF) { |
1409 | data = VPP_COLOR_DEMO_MODE_ALLON; |
1410 | } |
1411 | |
1412 | return data; |
1413 | } |
1414 | |
1415 | int CVpp::SetBaseColorModeWithoutSave(vpp_color_basemode_t basemode, tvin_port_t source_port, |
1416 | tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
1417 | { |
1418 | int ret = -1; |
1419 | am_regs_t regs; |
1420 | |
1421 | if (mbVppCfg_new_cm) { |
1422 | if (mpPqData->PQ_GetCM2Params((vpp_color_management2_t) basemode, source_port, sig_fmt, |
1423 | is3d, trans_fmt, ®s) == 0) { |
1424 | ret = Vpp_LoadRegs(regs); |
1425 | } else { |
1426 | LOGE("PQ_GetCM2Params failed!\n"); |
1427 | } |
1428 | } |
1429 | |
1430 | return ret; |
1431 | } |
1432 | |
1433 | int CVpp::SaveBaseColorMode(vpp_color_basemode_t basemode) |
1434 | { |
1435 | int ret = -1; |
1436 | |
1437 | if (basemode == VPP_COLOR_BASE_MODE_DEMO) { |
1438 | ret = 0; |
1439 | } else { |
1440 | ret |= SSMSaveColorBaseMode(basemode); |
1441 | } |
1442 | |
1443 | return ret; |
1444 | } |
1445 | |
1446 | int CVpp::SetBaseColorMode(vpp_color_basemode_t basemode, tvin_port_t source_port, |
1447 | tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
1448 | { |
1449 | if (0 == SetBaseColorModeWithoutSave(basemode, source_port, sig_fmt, is3d, trans_fmt)) { |
1450 | return SaveBaseColorMode(basemode); |
1451 | } else { |
1452 | LOGE("SetBaseColorMode() Failed!!!"); |
1453 | return -1; |
1454 | } |
1455 | return 0; |
1456 | } |
1457 | |
1458 | vpp_color_basemode_t CVpp::GetBaseColorMode(void) |
1459 | { |
1460 | vpp_color_basemode_t data = VPP_COLOR_BASE_MODE_OFF; |
1461 | unsigned char tmp_base_mode = 0; |
1462 | SSMReadColorBaseMode(&tmp_base_mode); |
1463 | data = (vpp_color_basemode_t) tmp_base_mode; |
1464 | |
1465 | if (data < VPP_COLOR_BASE_MODE_OFF || data >= VPP_COLOR_BASE_MODE_MAX) { |
1466 | data = VPP_COLOR_BASE_MODE_OPTIMIZE; |
1467 | } |
1468 | |
1469 | return data; |
1470 | } |
1471 | |
1472 | int CVpp::SetColorTempWithoutSave(vpp_color_temperature_mode_t Tempmode, |
1473 | tv_source_input_type_t source_type) |
1474 | { |
1475 | tcon_rgb_ogo_t rgbogo; |
1476 | int ret = -1; |
1477 | |
1478 | if (mbVppCfg_whitebalance_sameparam) { |
1479 | source_type = SOURCE_TYPE_TV; //set all source share to use one group |
1480 | } |
1481 | |
1482 | if (mbVppCfg_gamma_onoff) { |
1483 | VPP_SetGammaOnOff(0); |
1484 | } else { |
1485 | VPP_SetGammaOnOff(1); |
1486 | } |
1487 | |
1488 | GetColorTemperatureParams(Tempmode, &rgbogo); |
1489 | |
1490 | return VPP_SetRGBOGO(&rgbogo); |
1491 | |
1492 | } |
1493 | |
1494 | int CVpp::SaveColorTemp(vpp_color_temperature_mode_t Tempmode, tv_source_input_type_t source_type) |
1495 | { |
1496 | int ret = -1; |
1497 | int tmp_temp_mode = 0; |
1498 | tcon_rgb_ogo_t rgbogo; |
1499 | |
1500 | if (mbVppCfg_whitebalance_sameparam) { |
1501 | source_type = SOURCE_TYPE_TV; //set all source share to use one group |
1502 | } |
1503 | |
1504 | GetColorTemperatureParams(Tempmode, &rgbogo); |
1505 | |
1506 | if (Tempmode < VPP_COLOR_TEMPERATURE_MODE_USER) { |
1507 | ret = SSMSaveRGBGainRStart(0, rgbogo.r_gain); |
1508 | ret |= SSMSaveRGBGainGStart(0, rgbogo.g_gain); |
1509 | ret |= SSMSaveRGBGainBStart(0, rgbogo.b_gain); |
1510 | } |
1511 | |
1512 | tmp_temp_mode = (int) Tempmode; |
1513 | |
1514 | if (mbVppCfg_colortemp_by_source) { |
1515 | ret |= SSMSaveColorTemperature((int) source_type, tmp_temp_mode); |
1516 | } else { |
1517 | ret |= SSMSaveColorTemperature(0, tmp_temp_mode); |
1518 | } |
1519 | |
1520 | return ret; |
1521 | } |
1522 | |
1523 | int CVpp::SetColorTemperature(vpp_color_temperature_mode_t Tempmode, |
1524 | tv_source_input_type_t source_type, int is_save) |
1525 | { |
1526 | if (SetColorTempWithoutSave(Tempmode, source_type) < 0) { |
1527 | LOGE("%s, failed!", __FUNCTION__); |
1528 | return -1; |
1529 | } else { |
1530 | if (is_save == 1) { |
1531 | return SaveColorTemp(Tempmode, source_type); |
1532 | } else { |
1533 | return 0; |
1534 | } |
1535 | } |
1536 | } |
1537 | |
1538 | vpp_color_temperature_mode_t CVpp::GetColorTemperature(tv_source_input_type_t source_type) |
1539 | { |
1540 | vpp_color_temperature_mode_t data = VPP_COLOR_TEMPERATURE_MODE_STANDARD; |
1541 | int tmp_temp_mode = 0; |
1542 | |
1543 | if (mbVppCfg_colortemp_by_source) { |
1544 | SSMReadColorTemperature((int) source_type, &tmp_temp_mode); |
1545 | } else { |
1546 | SSMReadColorTemperature(0, &tmp_temp_mode); |
1547 | } |
1548 | |
1549 | data = (vpp_color_temperature_mode_t) tmp_temp_mode; |
1550 | |
1551 | if (data < VPP_COLOR_TEMPERATURE_MODE_STANDARD || data > VPP_COLOR_TEMPERATURE_MODE_USER) { |
1552 | data = VPP_COLOR_TEMPERATURE_MODE_STANDARD; |
1553 | } |
1554 | |
1555 | return data; |
1556 | } |
1557 | |
1558 | int CVpp::VPP_SetNonLinearFactor(int value) |
1559 | { |
1560 | FILE *fp = NULL; |
1561 | |
1562 | fp = fopen("/sys/class/video/nonlinear_factor", "w"); |
1563 | LOGD("~~~fopen~~~##VPP_SetNonLinearFactor##%s : %d ##", "/sys/class/video/nonlinear_factor", |
1564 | value); |
1565 | |
1566 | if (fp == NULL) { |
1567 | LOGE("Open /sys/class/video/nonlinear_factor error(%s)!\n", strerror(errno)); |
1568 | return -1; |
1569 | } |
1570 | |
1571 | fprintf(fp, "%d", value); |
1572 | |
1573 | fclose(fp); |
1574 | fp = NULL; |
1575 | |
1576 | return 0; |
1577 | } |
1578 | |
1579 | vpp_display_mode_t CVpp::GetDisplayMode(tv_source_input_type_t source_type) |
1580 | { |
1581 | vpp_display_mode_t data = VPP_DISPLAY_MODE_169; |
1582 | int tmp_dis_mode = 0; |
1583 | |
1584 | SSMReadDisplayMode(source_type, &tmp_dis_mode); |
1585 | data = (vpp_display_mode_t) tmp_dis_mode; |
1586 | |
1587 | return data; |
1588 | } |
1589 | |
1590 | int CVpp::SetBacklightWithoutSave(int value, tv_source_input_type_t source_type) |
1591 | { |
1592 | int backlight_value, backlight_reverse = 0; |
1593 | int ret = -1; |
1594 | int tmp_pic_mode = 0; |
1595 | |
1596 | source_type = SOURCE_TYPE_TV; |
1597 | |
1598 | if (value < 0 || value > 100) { |
1599 | value = 100; |
1600 | } |
1601 | |
1602 | if (mbVppCfg_backlight_reverse) { |
1603 | backlight_value = (100 - value) * 255 / 100; |
1604 | } else { |
1605 | backlight_value = value * 255 / 100; |
1606 | } |
1607 | |
1608 | return VPP_SetBackLightLevel(backlight_value); |
1609 | } |
1610 | |
1611 | int CVpp::VPP_SetBackLightLevel(int value) |
1612 | { |
1613 | FILE *fp = NULL; |
1614 | fp = fopen("/sys/class/backlight/aml-bl/brightness", "w"); |
1615 | LOGD("~~~fopen~~~##VPP_SetBackLightLevel##%s : %d ##", |
1616 | "/sys/class/backlight/aml-bl/brightness", value); |
1617 | |
1618 | if (fp == NULL) { |
1619 | LOGE("Open /sys/class/backlight/aml-bl/brightness error(%s)!\n", strerror(errno)); |
1620 | return -1; |
1621 | } |
1622 | |
1623 | fprintf(fp, "%d", value); |
1624 | |
1625 | fclose(fp); |
1626 | fp = NULL; |
1627 | |
1628 | return 0; |
1629 | } |
1630 | |
1631 | int CVpp::SetBacklight(int value, tv_source_input_type_t source_type, int is_save) |
1632 | { |
1633 | static const int MIN_BACKLIGHT_VALUE = 1; |
1634 | if (value >= MIN_BACKLIGHT_VALUE) { |
1635 | if (SetBacklightWithoutSave(value, source_type) < 0) { |
1636 | LOGE("%s, failed !", __FUNCTION__); |
1637 | return -1; |
1638 | } |
1639 | |
1640 | } else { |
1641 | if (SetBacklightWithoutSave(MIN_BACKLIGHT_VALUE, source_type) < 0) { |
1642 | LOGE("%s, failed !", __FUNCTION__); |
1643 | return -1; |
1644 | } |
1645 | } |
1646 | if (is_save == 1) { |
1647 | return SaveBacklight(value, source_type); |
1648 | } else { |
1649 | return 0; |
1650 | } |
1651 | } |
1652 | |
1653 | int CVpp::GetBacklight(tv_source_input_type_t source_type) |
1654 | { |
1655 | int data = 0; |
1656 | vpp_pq_para_t pq_para; |
1657 | |
1658 | if (mbVppCfg_pqmode_depend_bklight) { |
1659 | vpp_picture_mode_t pq_mode = GetPQMode(source_type); |
1660 | |
1661 | if (pq_mode == VPP_PICTURE_MODE_USER) { |
1662 | SSMReadBackLightVal(source_type, &data); |
1663 | } else { |
1664 | Vpp_GetPQModeValue(source_type, pq_mode, &pq_para); |
1665 | data = pq_para.backlight; |
1666 | } |
1667 | } else { |
1668 | source_type = SOURCE_TYPE_TV; |
1669 | SSMReadBackLightVal(source_type, &data); |
1670 | } |
1671 | |
1672 | if (data < 0 || data > 100) { |
1673 | data = 100; |
1674 | } |
1675 | |
1676 | return data; |
1677 | } |
1678 | |
1679 | int CVpp::SaveBacklight(int value, tv_source_input_type_t source_type) |
1680 | { |
1681 | int backlight_value, backlight_reverse = 0; |
1682 | int ret = -1; |
1683 | int tmp_pic_mode = 0; |
1684 | |
1685 | if (!mbVppCfg_pqmode_depend_bklight) { |
1686 | source_type = SOURCE_TYPE_TV; |
1687 | } |
1688 | |
1689 | if (value < 0 || value > 100) { |
1690 | value = 100; |
1691 | } |
1692 | |
1693 | ret = SSMSaveBackLightVal(source_type, value); |
1694 | |
1695 | return ret; |
1696 | } |
1697 | |
1698 | int CVpp::VPP_SetBackLight_Switch(int value) |
1699 | { |
1700 | FILE *fp = NULL; |
1701 | fp = fopen("/sys/class/backlight/aml-bl/bl_power", "w"); |
1702 | LOGD("~~~fopen~~~##VPP_SetBackLight_Switch##%s : %d ##", |
1703 | "/sys/class/backlight/aml-bl/bl_power", value); |
1704 | |
1705 | if (fp == NULL) { |
1706 | LOGE("Open /sys/class/backlight/aml-bl/bl_power error(%s)!\n", strerror(errno)); |
1707 | return -1; |
1708 | } |
1709 | |
1710 | fprintf(fp, "%d", value); |
1711 | |
1712 | fclose(fp); |
1713 | fp = NULL; |
1714 | |
1715 | return 0; |
1716 | } |
1717 | |
1718 | int CVpp::VPP_GetBackLight_Switch(void) |
1719 | { |
1720 | FILE *fp = NULL; |
1721 | int value; |
1722 | |
1723 | fp = fopen("/sys/class/backlight/aml-bl/bl_power", "w"); |
1724 | |
1725 | if (fp == NULL) { |
1726 | LOGE("Open /sys/class/backlight/aml-bl/bl_power error(%s)!\n", strerror(errno)); |
1727 | return -1; |
1728 | } |
1729 | |
1730 | fscanf(fp, "%d", &value); |
1731 | LOGD("~~~fopen~~~##VPP_GetBackLight_Switch##%s : %d ##", |
1732 | "/sys/class/backlight/aml-bl/bl_power", value); |
1733 | |
1734 | fclose(fp); |
1735 | fp = NULL; |
1736 | if (value < 0) { |
1737 | return 0; |
1738 | } else { |
1739 | return value; |
1740 | } |
1741 | } |
1742 | |
1743 | int CVpp::SetDNLP(tv_source_input_type_t source_type, tvin_port_t source_port, |
1744 | tvin_sig_fmt_t sig_fmt, is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
1745 | { |
1746 | unsigned int dnlp_switch = 0; |
1747 | |
1748 | int ret = -1; |
1749 | int dnlpFlag = -1; |
1750 | ve_dnlp_t dnlp; |
1751 | ve_dnlp_table_t newdnlp; |
1752 | |
1753 | dnlp_switch = 1; |
1754 | |
1755 | if (mpPqData->PQ_GetDNLPParams(source_port, sig_fmt, is3d, trans_fmt, &dnlp, &newdnlp, |
1756 | &dnlpFlag) == 0) { |
1757 | newdnlp.en = dnlp_switch; |
1758 | LOGE("PQ_GetDNLPParams ok!\n"); |
1759 | LOGE( |
1760 | "newdnlp.en:%d,newdnlp.method:%d,newdnlp.cliprate:%d,newdnlp.lowrange:%d,newdnlp.hghrange:%d,newdnlp.lowalpha:%d,newdnlp.midalpha:%d,newdnlp.hghalpha:%d\n", |
1761 | newdnlp.en, newdnlp.method, newdnlp.cliprate, newdnlp.lowrange, newdnlp.hghrange, |
1762 | newdnlp.lowalpha, newdnlp.midalpha, newdnlp.hghalpha); |
1763 | if (source_type == SOURCE_TYPE_DTV) { |
1764 | SetFileAttrValue("/sys/module/am_vecm/parameters/dnlp_en", "0"); |
1765 | } else { |
1766 | VPP_SetVENewDNLP(&newdnlp); |
1767 | SetFileAttrValue("/sys/module/am_vecm/parameters/dnlp_en", "1"); |
1768 | } |
1769 | ret = 1; |
1770 | } else { |
1771 | LOGE("mpPqData->PQ_GetDNLPParams failed!\n"); |
1772 | } |
1773 | |
1774 | return ret; |
1775 | } |
1776 | |
1777 | int CVpp::VPP_SetVEDNLP(const struct ve_dnlp_s *pDNLP) |
1778 | { |
1779 | int rt = VPP_DeviceIOCtl(AMVECM_IOC_VE_DNLP, pDNLP); |
1780 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEDNLP##AMVECM_IOC_VE_DNLP##"); |
1781 | |
1782 | if (rt < 0) { |
1783 | LOGE("Vpp_api_SetVEDNLP, error(%s)!\n", strerror(errno)); |
1784 | } |
1785 | |
1786 | return rt; |
1787 | } |
1788 | |
1789 | int CVpp::VPP_SetVENewDNLP(const ve_dnlp_table_t *pDNLP) |
1790 | { |
1791 | int rt = VPP_DeviceIOCtl(AMVECM_IOC_VE_NEW_DNLP, pDNLP); |
1792 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVENewDNLP##AMVECM_IOC_VE_NEW_DNLP##"); |
1793 | |
1794 | if (rt < 0) { |
1795 | LOGE("VPP_SetVENewDNLP, error(%s)!\n", strerror(errno)); |
1796 | } |
1797 | |
1798 | return rt; |
1799 | } |
1800 | |
1801 | int CVpp::SetDnlp_OFF(void) |
1802 | { |
1803 | if (Vpp_SetDnlpOff() < 0) { |
1804 | LOGE("%s failed.\n", __FUNCTION__); |
1805 | return -1; |
1806 | } else { |
1807 | LOGE("%s success.\n", __FUNCTION__); |
1808 | SSMSaveDnlpStart(1); //save dnlp status to e2rom |
1809 | return 0; |
1810 | } |
1811 | } |
1812 | int CVpp::SetDnlp_ON(void) |
1813 | { |
1814 | if (Vpp_SetDnlpOn() < 0) { |
1815 | LOGE("%s failed.\n", __FUNCTION__); |
1816 | return -1; |
1817 | } else { |
1818 | LOGE("%s success.\n", __FUNCTION__); |
1819 | SSMSaveDnlpStart(0); //save dnlp status to e2rom |
1820 | return 0; |
1821 | } |
1822 | } |
1823 | |
1824 | int CVpp::Vpp_SetDnlpOff(void) |
1825 | { |
1826 | //According linux driver to modify the AMSTREAM_IOC_VE_DNLP_DIS to the AMVECM_IOC_VE_DNLP_DIS. |
1827 | //int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DNLP_DIS); |
1828 | int rt = VPP_DeviceIOCtl(AMVECM_IOC_VE_DNLP_DIS); |
1829 | LOGD("~~~VPP_DeviceIOCtl~~~##Vpp_SetDnlpOff##AMVECM_IOC_VE_DNLP_DIS##"); |
1830 | |
1831 | if (rt < 0) { |
1832 | LOGE("Vpp_SetDnlpOff, error(%s)!\n", strerror(errno)); |
1833 | } |
1834 | |
1835 | return rt; |
1836 | } |
1837 | |
1838 | int CVpp::Vpp_SetDnlpOn(void) |
1839 | { |
1840 | //According linux driver to modify the AMSTREAM_IOC_VE_DNLP_DIS to the AMVECM_IOC_VE_DNLP_DIS. |
1841 | //int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DNLP_EN); |
1842 | int rt = VPP_DeviceIOCtl(AMVECM_IOC_VE_DNLP_EN); |
1843 | LOGD("~~~VPP_DeviceIOCtl~~~##Vpp_SetDnlpOn##AMVECM_IOC_VE_DNLP_EN##"); |
1844 | |
1845 | if (rt < 0) { |
1846 | LOGE("Vpp_SetDnlpOn, error(%s)!\n", strerror(errno)); |
1847 | } |
1848 | |
1849 | return rt; |
1850 | } |
1851 | int CVpp::GetDnlp_Status() |
1852 | { |
1853 | unsigned char status = 0; |
1854 | SSMReadDnlpStart(&status); |
1855 | LOGD("%s, %d.", __FUNCTION__, status); |
1856 | return status; |
1857 | } |
1858 | |
1859 | int CVpp::VPP_SetRGBOGO(const struct tcon_rgb_ogo_s *rgbogo) |
1860 | { |
1861 | int rt = VPP_DeviceIOCtl(AMVECM_IOC_S_RGB_OGO, rgbogo); |
1862 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetRGBOGO##AMVECM_IOC_S_RGB_OGO##"); |
1863 | usleep(50 * 1000); |
1864 | |
1865 | if (rt < 0) { |
1866 | LOGE("Vpp_api_SetRGBOGO, error(%s)!\n", strerror(errno)); |
1867 | } |
1868 | |
1869 | return rt; |
1870 | } |
1871 | |
1872 | int CVpp::VPP_GetRGBOGO(const struct tcon_rgb_ogo_s *rgbogo) |
1873 | { |
1874 | int rt = VPP_DeviceIOCtl(AMVECM_IOC_G_RGB_OGO, rgbogo); |
1875 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_GetRGBOGO##AMVECM_IOC_G_RGB_OGO##"); |
1876 | |
1877 | if (rt < 0) { |
1878 | LOGE("Vpp_api_GetRGBOGO, error(%s)!\n", strerror(errno)); |
1879 | } |
1880 | |
1881 | return rt; |
1882 | } |
1883 | |
1884 | int CVpp::RGBGainValueSSMToRisterMapping(int gainValue) //0~255 |
1885 | { |
1886 | int mapValue = 0; |
1887 | |
1888 | if (gainValue < 0 || gainValue > 255) { |
1889 | mapValue = 1024; |
1890 | } else { |
1891 | if (gainValue == 255) { |
1892 | mapValue = 1536; |
1893 | } else { |
1894 | mapValue = 512 + gainValue * (1536 - 512) / 256; |
1895 | } |
1896 | } |
1897 | |
1898 | return mapValue;//512~1536 |
1899 | } |
1900 | |
1901 | //RGB OFFSET:-128~127 <-----> -512~512 |
1902 | int CVpp::RGBOffsetValueSSMToRisterMapping(int offsetValue) //-128~127 |
1903 | { |
1904 | int mapValue = 0; |
1905 | |
1906 | if (offsetValue < -128 || offsetValue > 127) { |
1907 | offsetValue = 0; |
1908 | } |
1909 | |
1910 | if (offsetValue == 127) { |
1911 | mapValue = 512; |
1912 | } else { |
1913 | mapValue = 1024 * offsetValue / 256; |
1914 | } |
1915 | |
1916 | return mapValue;//-512~512 |
1917 | } |
1918 | |
1919 | int CVpp::FactorySetPQMode_Brightness(int source_type, int pq_mode, int brightness) |
1920 | { |
1921 | int ret = -1; |
1922 | vpp_pq_para_t pq_para; |
1923 | |
1924 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
1925 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
1926 | pq_para.brightness = brightness; |
1927 | |
1928 | if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, |
1929 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
1930 | ret = 0; |
1931 | } else { |
1932 | ret = 1; |
1933 | } |
1934 | } else { |
1935 | ret = -1; |
1936 | } |
1937 | |
1938 | return ret; |
1939 | } |
1940 | |
1941 | int CVpp::FactoryGetPQMode_Brightness(int source_type, int pq_mode) |
1942 | { |
1943 | vpp_pq_para_t pq_para; |
1944 | |
1945 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
1946 | (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { |
1947 | return -1; |
1948 | } |
1949 | |
1950 | return pq_para.brightness; |
1951 | } |
1952 | |
1953 | int CVpp::FactorySetPQMode_Contrast(int source_type, int pq_mode, int contrast) |
1954 | { |
1955 | int ret = -1; |
1956 | vpp_pq_para_t pq_para; |
1957 | |
1958 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
1959 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
1960 | pq_para.contrast = contrast; |
1961 | |
1962 | if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, |
1963 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
1964 | ret = 0; |
1965 | } else { |
1966 | ret = 1; |
1967 | } |
1968 | } else { |
1969 | ret = -1; |
1970 | } |
1971 | |
1972 | return ret; |
1973 | } |
1974 | |
1975 | int CVpp::FactoryGetPQMode_Contrast(int source_type, int pq_mode) |
1976 | { |
1977 | vpp_pq_para_t pq_para; |
1978 | |
1979 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
1980 | (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { |
1981 | return -1; |
1982 | } |
1983 | |
1984 | return pq_para.contrast; |
1985 | } |
1986 | |
1987 | int CVpp::FactorySetPQMode_Saturation(int source_type, int pq_mode, int saturation) |
1988 | { |
1989 | int ret = -1; |
1990 | vpp_pq_para_t pq_para; |
1991 | |
1992 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
1993 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
1994 | pq_para.saturation = saturation; |
1995 | |
1996 | if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, |
1997 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
1998 | ret = 0; |
1999 | } else { |
2000 | ret = 1; |
2001 | } |
2002 | } else { |
2003 | ret = -1; |
2004 | } |
2005 | |
2006 | return ret; |
2007 | } |
2008 | |
2009 | int CVpp::FactoryGetPQMode_Saturation(int source_type, int pq_mode) |
2010 | { |
2011 | vpp_pq_para_t pq_para; |
2012 | |
2013 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
2014 | (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { |
2015 | return -1; |
2016 | } |
2017 | |
2018 | return pq_para.saturation; |
2019 | } |
2020 | |
2021 | int CVpp::FactorySetPQMode_Hue(int source_type, int pq_mode, int hue) |
2022 | { |
2023 | int ret = -1; |
2024 | vpp_pq_para_t pq_para; |
2025 | |
2026 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
2027 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
2028 | pq_para.hue = hue; |
2029 | |
2030 | if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, |
2031 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
2032 | ret = 0; |
2033 | } else { |
2034 | ret = 1; |
2035 | } |
2036 | } else { |
2037 | ret = -1; |
2038 | } |
2039 | |
2040 | return ret; |
2041 | } |
2042 | |
2043 | int CVpp::FactoryGetPQMode_Hue(int source_type, int pq_mode) |
2044 | { |
2045 | vpp_pq_para_t pq_para; |
2046 | |
2047 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
2048 | (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { |
2049 | return -1; |
2050 | } |
2051 | |
2052 | return pq_para.hue; |
2053 | } |
2054 | |
2055 | int CVpp::FactorySetPQMode_Sharpness(int source_type, int pq_mode, int sharpness) |
2056 | { |
2057 | int ret = -1; |
2058 | vpp_pq_para_t pq_para; |
2059 | |
2060 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
2061 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
2062 | pq_para.sharpness = sharpness; |
2063 | |
2064 | if (mpPqData->PQ_SetPQModeParams((tv_source_input_type_t) source_type, |
2065 | (vpp_picture_mode_t) pq_mode, &pq_para) == 0) { |
2066 | ret = 0; |
2067 | } else { |
2068 | ret = 1; |
2069 | } |
2070 | } else { |
2071 | ret = -1; |
2072 | } |
2073 | |
2074 | return ret; |
2075 | } |
2076 | |
2077 | int CVpp::FactoryGetPQMode_Sharpness(int source_type, int pq_mode) |
2078 | { |
2079 | vpp_pq_para_t pq_para; |
2080 | |
2081 | if (mpPqData->PQ_GetPQModeParams((tv_source_input_type_t) source_type, |
2082 | (vpp_picture_mode_t) pq_mode, &pq_para) != 0) { |
2083 | return -1; |
2084 | } |
2085 | |
2086 | return pq_para.sharpness; |
2087 | } |
2088 | |
2089 | unsigned short CVpp::CalColorTemperatureParamsChecksum(void) |
2090 | { |
2091 | unsigned char data_buf[SSM_CR_RGBOGO_LEN]; |
2092 | unsigned short sum = 0; |
2093 | int cnt; |
2094 | USUC usuc; |
2095 | |
2096 | SSMReadRGBOGOValue(0, SSM_CR_RGBOGO_LEN, data_buf); |
2097 | |
2098 | for (cnt = 0; cnt < SSM_CR_RGBOGO_LEN; cnt++) { |
2099 | sum += data_buf[cnt]; |
2100 | } |
2101 | |
2102 | //checksum = 0xff - sum % 0xff; |
2103 | |
2104 | LOGD("%s, sum = 0x%X.\n", __FUNCTION__, sum); |
2105 | |
2106 | return sum; |
2107 | } |
2108 | |
2109 | int CVpp::SetColorTempParamsChecksum(void) |
2110 | { |
2111 | int ret = 0; |
2112 | USUC usuc; |
2113 | |
2114 | usuc.s = CalColorTemperatureParamsChecksum(); |
2115 | |
2116 | LOGD("%s, sum = 0x%X.\n", __FUNCTION__, usuc.s); |
2117 | |
2118 | ret |= SSMSaveRGBOGOValue(SSM_CR_RGBOGO_LEN, SSM_CR_RGBOGO_CHKSUM_LEN, usuc.c); |
2119 | |
2120 | return ret; |
2121 | } |
2122 | unsigned short CVpp::GetColorTempParamsChecksum(void) |
2123 | { |
2124 | USUC usuc; |
2125 | |
2126 | SSMReadRGBOGOValue(SSM_CR_RGBOGO_LEN, SSM_CR_RGBOGO_CHKSUM_LEN, usuc.c); |
2127 | |
2128 | LOGD("%s, sum = 0x%X.\n", __FUNCTION__, usuc.s); |
2129 | |
2130 | return usuc.s; |
2131 | |
2132 | } |
2133 | |
2134 | int CVpp::CheckTempDataLable(void) |
2135 | { |
2136 | USUC usuc; |
2137 | USUC ret; |
2138 | |
2139 | SSMReadRGBOGOValue(SSM_CR_RGBOGO_LEN - 2, 2, ret.c); |
2140 | |
2141 | usuc.c[0] = 0x55; |
2142 | usuc.c[1] = 0xAA; |
2143 | |
2144 | if ((usuc.c[0] == ret.c[0]) && (usuc.c[1] == ret.c[1])) { |
2145 | LOGD("%s, lable ok.\n", __FUNCTION__); |
2146 | return 1; |
2147 | } else { |
2148 | LOGD("%s, lable error.\n", CFG_SECTION_TV); |
2149 | return 0; |
2150 | } |
2151 | } |
2152 | |
2153 | int CVpp::SetTempDataLable(void) |
2154 | { |
2155 | USUC usuc; |
2156 | int ret = 0; |
2157 | |
2158 | usuc.c[0] = 0x55; |
2159 | usuc.c[1] = 0xAA; |
2160 | |
2161 | ret = SSMSaveRGBOGOValue(SSM_CR_RGBOGO_LEN - 2, 2, usuc.c); |
2162 | |
2163 | return ret; |
2164 | } |
2165 | |
2166 | int CVpp::GetColorTemperatureParams(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params) |
2167 | { |
2168 | // CheckColorTemperatureParamAlldata(source_port,sig_fmt,trans_fmt); |
2169 | |
2170 | return ReadColorTemperatureParams(Tempmode, params); |
2171 | } |
2172 | |
2173 | int CVpp::ReadColorTemperatureParams(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params) |
2174 | { |
2175 | SUC suc; |
2176 | USUC usuc; |
2177 | int ret = 0; |
2178 | |
2179 | if (VPP_COLOR_TEMPERATURE_MODE_STANDARD == Tempmode) { //standard |
2180 | ret |= SSMReadRGBOGOValue(0, 2, usuc.c); |
2181 | params->en = usuc.s; |
2182 | |
2183 | ret |= SSMReadRGBOGOValue(2, 2, suc.c); |
2184 | params->r_pre_offset = suc.s; |
2185 | |
2186 | ret |= SSMReadRGBOGOValue(4, 2, suc.c); |
2187 | params->g_pre_offset = suc.s; |
2188 | |
2189 | ret |= SSMReadRGBOGOValue(6, 2, suc.c); |
2190 | params->b_pre_offset = suc.s; |
2191 | |
2192 | ret |= SSMReadRGBOGOValue(8, 2, usuc.c); |
2193 | params->r_gain = usuc.s; |
2194 | |
2195 | ret |= SSMReadRGBOGOValue(10, 2, usuc.c); |
2196 | params->g_gain = usuc.s; |
2197 | |
2198 | ret |= SSMReadRGBOGOValue(12, 2, usuc.c); |
2199 | params->b_gain = usuc.s; |
2200 | |
2201 | ret |= SSMReadRGBOGOValue(14, 2, suc.c); |
2202 | params->r_post_offset = suc.s; |
2203 | |
2204 | ret |= SSMReadRGBOGOValue(16, 2, suc.c); |
2205 | params->g_post_offset = suc.s; |
2206 | |
2207 | ret |= SSMReadRGBOGOValue(18, 2, suc.c); |
2208 | params->b_post_offset = suc.s; |
2209 | } else if (VPP_COLOR_TEMPERATURE_MODE_WARM == Tempmode) { //warm |
2210 | ret |= SSMReadRGBOGOValue(20, 2, usuc.c); |
2211 | params->en = usuc.s; |
2212 | |
2213 | ret |= SSMReadRGBOGOValue(22, 2, suc.c); |
2214 | params->r_pre_offset = suc.s; |
2215 | |
2216 | ret |= SSMReadRGBOGOValue(24, 2, suc.c); |
2217 | params->g_pre_offset = suc.s; |
2218 | |
2219 | ret |= SSMReadRGBOGOValue(26, 2, suc.c); |
2220 | params->b_pre_offset = suc.s; |
2221 | |
2222 | ret |= SSMReadRGBOGOValue(28, 2, usuc.c); |
2223 | params->r_gain = usuc.s; |
2224 | ret |= SSMReadRGBOGOValue(30, 2, usuc.c); |
2225 | params->g_gain = usuc.s; |
2226 | |
2227 | ret |= SSMReadRGBOGOValue(32, 2, usuc.c); |
2228 | params->b_gain = usuc.s; |
2229 | |
2230 | ret |= SSMReadRGBOGOValue(34, 2, suc.c); |
2231 | params->r_post_offset = suc.s; |
2232 | |
2233 | ret |= SSMReadRGBOGOValue(36, 2, suc.c); |
2234 | params->g_post_offset = suc.s; |
2235 | |
2236 | ret |= SSMReadRGBOGOValue(38, 2, suc.c); |
2237 | params->b_post_offset = suc.s; |
2238 | } else if (VPP_COLOR_TEMPERATURE_MODE_COLD == Tempmode) { //cool |
2239 | ret |= SSMReadRGBOGOValue(40, 2, usuc.c); |
2240 | params->en = usuc.s; |
2241 | |
2242 | ret |= SSMReadRGBOGOValue(42, 2, suc.c); |
2243 | params->r_pre_offset = suc.s; |
2244 | |
2245 | ret |= SSMReadRGBOGOValue(44, 2, suc.c); |
2246 | params->g_pre_offset = suc.s; |
2247 | |
2248 | ret |= SSMReadRGBOGOValue(46, 2, suc.c); |
2249 | params->b_pre_offset = suc.s; |
2250 | |
2251 | ret |= SSMReadRGBOGOValue(48, 2, usuc.c); |
2252 | params->r_gain = usuc.s; |
2253 | ret |= SSMReadRGBOGOValue(50, 2, usuc.c); |
2254 | params->g_gain = usuc.s; |
2255 | |
2256 | ret |= SSMReadRGBOGOValue(52, 2, usuc.c); |
2257 | params->b_gain = usuc.s; |
2258 | ret |= SSMReadRGBOGOValue(54, 2, suc.c); |
2259 | params->r_post_offset = suc.s; |
2260 | |
2261 | ret |= SSMReadRGBOGOValue(56, 2, suc.c); |
2262 | params->g_post_offset = suc.s; |
2263 | |
2264 | ret |= SSMReadRGBOGOValue(58, 2, suc.c); |
2265 | params->b_post_offset = suc.s; |
2266 | } |
2267 | |
2268 | LOGD("%s, rgain[%d], ggain[%d],bgain[%d],roffset[%d],goffset[%d],boffset[%d]\n", __FUNCTION__, |
2269 | params->r_gain, params->g_gain, params->b_gain, params->r_post_offset, |
2270 | params->g_post_offset, params->b_post_offset); |
2271 | |
2272 | return ret; |
2273 | } |
2274 | |
2275 | int CVpp::SetColorTemperatureParams(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params) |
2276 | { |
2277 | // CheckColorTemperatureParamAlldata(source_port,sig_fmt,trans_fmt); |
2278 | |
2279 | SaveColorTemperatureParams(Tempmode, params); |
2280 | SetColorTempParamsChecksum(); |
2281 | |
2282 | return 0; |
2283 | } |
2284 | |
2285 | int CVpp::SaveColorTemperatureParams(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params) |
2286 | { |
2287 | SUC suc; |
2288 | USUC usuc; |
2289 | int ret = 0; |
2290 | |
2291 | if (VPP_COLOR_TEMPERATURE_MODE_STANDARD == Tempmode) { //standard |
2292 | usuc.s = params.en; |
2293 | ret |= SSMSaveRGBOGOValue(0, 2, usuc.c); |
2294 | |
2295 | suc.s = params.r_pre_offset; |
2296 | ret |= SSMSaveRGBOGOValue(2, 2, suc.c); |
2297 | |
2298 | suc.s = params.g_pre_offset; |
2299 | ret |= SSMSaveRGBOGOValue(4, 2, suc.c); |
2300 | |
2301 | suc.s = params.b_pre_offset; |
2302 | ret |= SSMSaveRGBOGOValue(6, 2, suc.c); |
2303 | |
2304 | usuc.s = params.r_gain; |
2305 | ret |= SSMSaveRGBOGOValue(8, 2, usuc.c); |
2306 | |
2307 | usuc.s = params.g_gain; |
2308 | ret |= SSMSaveRGBOGOValue(10, 2, usuc.c); |
2309 | |
2310 | usuc.s = params.b_gain; |
2311 | ret |= SSMSaveRGBOGOValue(12, 2, usuc.c); |
2312 | |
2313 | suc.s = params.r_post_offset; |
2314 | ret |= SSMSaveRGBOGOValue(14, 2, suc.c); |
2315 | |
2316 | suc.s = params.g_post_offset; |
2317 | ret |= SSMSaveRGBOGOValue(16, 2, suc.c); |
2318 | |
2319 | suc.s = params.b_post_offset; |
2320 | ret |= SSMSaveRGBOGOValue(18, 2, suc.c); |
2321 | } else if (VPP_COLOR_TEMPERATURE_MODE_WARM == Tempmode) { //warm |
2322 | usuc.s = params.en; |
2323 | ret |= SSMSaveRGBOGOValue(20, 2, usuc.c); |
2324 | |
2325 | suc.s = params.r_pre_offset; |
2326 | ret |= SSMSaveRGBOGOValue(22, 2, suc.c); |
2327 | |
2328 | suc.s = params.g_pre_offset; |
2329 | ret |= SSMSaveRGBOGOValue(24, 2, suc.c); |
2330 | suc.s = params.b_pre_offset; |
2331 | ret |= SSMSaveRGBOGOValue(26, 2, suc.c); |
2332 | |
2333 | usuc.s = params.r_gain; |
2334 | ret |= SSMSaveRGBOGOValue(28, 2, usuc.c); |
2335 | |
2336 | usuc.s = params.g_gain; |
2337 | ret |= SSMSaveRGBOGOValue(30, 2, usuc.c); |
2338 | |
2339 | usuc.s = params.b_gain; |
2340 | ret |= SSMSaveRGBOGOValue(32, 2, usuc.c); |
2341 | |
2342 | suc.s = params.r_post_offset; |
2343 | ret |= SSMSaveRGBOGOValue(34, 2, suc.c); |
2344 | |
2345 | suc.s = params.g_post_offset; |
2346 | ret |= SSMSaveRGBOGOValue(36, 2, suc.c); |
2347 | |
2348 | suc.s = params.b_post_offset; |
2349 | ret |= SSMSaveRGBOGOValue(38, 2, suc.c); |
2350 | } else if (VPP_COLOR_TEMPERATURE_MODE_COLD == Tempmode) { //cool |
2351 | usuc.s = params.en; |
2352 | ret |= SSMSaveRGBOGOValue(40, 2, usuc.c); |
2353 | |
2354 | suc.s = params.r_pre_offset; |
2355 | ret |= SSMSaveRGBOGOValue(42, 2, suc.c); |
2356 | |
2357 | suc.s = params.g_pre_offset; |
2358 | ret |= SSMSaveRGBOGOValue(44, 2, suc.c); |
2359 | |
2360 | suc.s = params.b_pre_offset; |
2361 | ret |= SSMSaveRGBOGOValue(46, 2, suc.c); |
2362 | |
2363 | usuc.s = params.r_gain; |
2364 | ret |= SSMSaveRGBOGOValue(48, 2, usuc.c); |
2365 | |
2366 | usuc.s = params.g_gain; |
2367 | ret |= SSMSaveRGBOGOValue(50, 2, usuc.c); |
2368 | |
2369 | usuc.s = params.b_gain; |
2370 | ret |= SSMSaveRGBOGOValue(52, 2, usuc.c); |
2371 | |
2372 | suc.s = params.r_post_offset; |
2373 | ret |= SSMSaveRGBOGOValue(54, 2, suc.c); |
2374 | |
2375 | suc.s = params.g_post_offset; |
2376 | ret |= SSMSaveRGBOGOValue(56, 2, suc.c); |
2377 | |
2378 | suc.s = params.b_post_offset; |
2379 | ret |= SSMSaveRGBOGOValue(58, 2, suc.c); |
2380 | } |
2381 | |
2382 | LOGD("%s, rgain[%d], ggain[%d],bgain[%d],roffset[%d],goffset[%d],boffset[%d]\n", __FUNCTION__, |
2383 | params.r_gain, params.g_gain, params.b_gain, params.r_post_offset, |
2384 | params.g_post_offset, params.b_post_offset); |
2385 | return ret; |
2386 | } |
2387 | |
2388 | int CVpp::CheckColorTemperatureParams(void) |
2389 | { |
2390 | int i = 0; |
2391 | tcon_rgb_ogo_t rgbogo; |
2392 | |
2393 | for (i = 0; i < 3; i++) { |
2394 | ReadColorTemperatureParams((vpp_color_temperature_mode_t) i, &rgbogo); |
2395 | |
2396 | if (rgbogo.r_gain > 2047 || rgbogo.b_gain > 2047 || rgbogo.g_gain > 2047 || rgbogo.r_gain |
2397 | < 0 || rgbogo.b_gain < 0 || rgbogo.g_gain < 0) { |
2398 | if (rgbogo.r_post_offset > 1023 || rgbogo.g_post_offset > 1023 || rgbogo.b_post_offset |
2399 | > 1023 || rgbogo.r_post_offset < -1024 || rgbogo.g_post_offset < -1024 |
2400 | || rgbogo.b_post_offset < -1024) { |
2401 | return 0; |
2402 | } |
2403 | } |
2404 | } |
2405 | |
2406 | return 1; |
2407 | } |
2408 | |
2409 | int CVpp::RestoeColorTemperatureParamsFromDB(tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, |
2410 | tvin_trans_fmt_t trans_fmt) |
2411 | { |
2412 | int i = 0; |
2413 | tcon_rgb_ogo_t rgbogo; |
2414 | |
2415 | LOGD("%s, restore color temperature params from DB.\n", __FUNCTION__); |
2416 | |
2417 | for (i = 0; i < 3; i++) { |
2418 | mpPqData->PQ_GetColorTemperatureParams((vpp_color_temperature_mode_t) i, source_port, |
2419 | sig_fmt, trans_fmt, &rgbogo); |
2420 | SaveColorTemperatureParams((vpp_color_temperature_mode_t) i, rgbogo); |
2421 | } |
2422 | |
2423 | SetColorTempParamsChecksum(); |
2424 | |
2425 | return 0; |
2426 | } |
2427 | |
2428 | int CVpp::CheckColorTemperatureParamAlldata(tvin_port_t source_port, tvin_sig_fmt_t sig_fmt, |
2429 | tvin_trans_fmt_t trans_fmt) |
2430 | { |
2431 | if (CheckTempDataLable() && (CalColorTemperatureParamsChecksum() |
2432 | == GetColorTempParamsChecksum())) { |
2433 | LOGD("%s, color temperature param lable & checksum ok.\n", __FUNCTION__); |
2434 | |
2435 | if (CheckColorTemperatureParams() == 0) { |
2436 | LOGD("%s, color temperature params check failed.\n", __FUNCTION__); |
2437 | RestoeColorTemperatureParamsFromDB(source_port, sig_fmt, trans_fmt); |
2438 | } |
2439 | } else { |
2440 | LOGD("%s, color temperature param data error.\n", __FUNCTION__); |
2441 | |
2442 | SetTempDataLable(); |
2443 | RestoeColorTemperatureParamsFromDB(source_port, sig_fmt, trans_fmt); |
2444 | } |
2445 | |
2446 | return 0; |
2447 | } |
2448 | |
2449 | int CVpp::FactorySetColorTemp_Rgain(int source_type, int colortemp_mode, int rgain) |
2450 | { |
2451 | tcon_rgb_ogo_t rgbogo; |
2452 | |
2453 | GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); |
2454 | rgbogo.r_gain = rgain; |
2455 | LOGD("%s, source_type[%d], colortemp_mode[%d], rgain[%d].", __FUNCTION__, source_type, |
2456 | colortemp_mode, rgain); |
2457 | rgbogo.en = 1; |
2458 | |
2459 | if (VPP_SetRGBOGO(&rgbogo) == 0) { |
2460 | return 0; |
2461 | } |
2462 | |
2463 | return -1; |
2464 | } |
2465 | |
2466 | int CVpp::FactorySaveColorTemp_Rgain(int source_type, int colortemp_mode, int rgain) |
2467 | { |
2468 | tcon_rgb_ogo_t rgbogo; |
2469 | |
2470 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2471 | rgbogo.r_gain = rgain; |
2472 | return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); |
2473 | } |
2474 | |
2475 | LOGE("FactorySaveColorTemp_Rgain error!\n"); |
2476 | return -1; |
2477 | } |
2478 | |
2479 | int CVpp::FactoryGetColorTemp_Rgain(int source_type, int colortemp_mode) |
2480 | { |
2481 | tcon_rgb_ogo_t rgbogo; |
2482 | |
2483 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2484 | return rgbogo.r_gain; |
2485 | } |
2486 | |
2487 | LOGE("FactoryGetColorTemp_Rgain error!\n"); |
2488 | return -1; |
2489 | } |
2490 | |
2491 | int CVpp::FactorySetColorTemp_Ggain(int source_type, int colortemp_mode, int ggain) |
2492 | { |
2493 | tcon_rgb_ogo_t rgbogo; |
2494 | |
2495 | GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); |
2496 | rgbogo.g_gain = ggain; |
2497 | LOGD("%s, source_type[%d], colortemp_mode[%d], ggain[%d].", __FUNCTION__, source_type, |
2498 | colortemp_mode, ggain); |
2499 | rgbogo.en = 1; |
2500 | |
2501 | if (VPP_SetRGBOGO(&rgbogo) == 0) { |
2502 | return 0; |
2503 | } |
2504 | |
2505 | return -1; |
2506 | } |
2507 | |
2508 | int CVpp::FactorySaveColorTemp_Ggain(int source_type, int colortemp_mode, int ggain) |
2509 | { |
2510 | tcon_rgb_ogo_t rgbogo; |
2511 | |
2512 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2513 | rgbogo.g_gain = ggain; |
2514 | return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); |
2515 | } |
2516 | |
2517 | LOGE("FactorySaveColorTemp_Ggain error!\n"); |
2518 | return -1; |
2519 | } |
2520 | |
2521 | int CVpp::FactoryGetColorTemp_Ggain(int source_type, int colortemp_mode) |
2522 | { |
2523 | tcon_rgb_ogo_t rgbogo; |
2524 | |
2525 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2526 | return rgbogo.g_gain; |
2527 | } |
2528 | |
2529 | LOGE("FactoryGetColorTemp_Ggain error!\n"); |
2530 | return -1; |
2531 | } |
2532 | |
2533 | int CVpp::FactorySetColorTemp_Bgain(int source_type, int colortemp_mode, int bgain) |
2534 | { |
2535 | tcon_rgb_ogo_t rgbogo; |
2536 | |
2537 | GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); |
2538 | rgbogo.b_gain = bgain; |
2539 | LOGD("%s, source_type[%d], colortemp_mode[%d], bgain[%d].", __FUNCTION__, source_type, |
2540 | colortemp_mode, bgain); |
2541 | rgbogo.en = 1; |
2542 | |
2543 | if (VPP_SetRGBOGO(&rgbogo) == 0) { |
2544 | return 0; |
2545 | } |
2546 | |
2547 | return -1; |
2548 | } |
2549 | |
2550 | int CVpp::FactorySaveColorTemp_Bgain(int source_type, int colortemp_mode, int bgain) |
2551 | { |
2552 | tcon_rgb_ogo_t rgbogo; |
2553 | |
2554 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2555 | rgbogo.b_gain = bgain; |
2556 | return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); |
2557 | } |
2558 | |
2559 | LOGE("FactorySaveColorTemp_Bgain error!\n"); |
2560 | return -1; |
2561 | } |
2562 | |
2563 | int CVpp::FactoryGetColorTemp_Bgain(int source_type, int colortemp_mode) |
2564 | { |
2565 | tcon_rgb_ogo_t rgbogo; |
2566 | |
2567 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2568 | return rgbogo.b_gain; |
2569 | } |
2570 | |
2571 | LOGE("FactoryGetColorTemp_Bgain error!\n"); |
2572 | return -1; |
2573 | } |
2574 | |
2575 | int CVpp::FactorySetColorTemp_Roffset(int source_type, int colortemp_mode, int roffset) |
2576 | { |
2577 | tcon_rgb_ogo_t rgbogo; |
2578 | |
2579 | GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); |
2580 | rgbogo.r_post_offset = roffset; |
2581 | LOGD("%s, source_type[%d], colortemp_mode[%d], r_post_offset[%d].", __FUNCTION__, source_type, |
2582 | colortemp_mode, roffset); |
2583 | rgbogo.en = 1; |
2584 | |
2585 | if (VPP_SetRGBOGO(&rgbogo) == 0) { |
2586 | return 0; |
2587 | } |
2588 | |
2589 | return -1; |
2590 | } |
2591 | |
2592 | int CVpp::FactorySaveColorTemp_Roffset(int source_type, int colortemp_mode, int roffset) |
2593 | { |
2594 | tcon_rgb_ogo_t rgbogo; |
2595 | |
2596 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2597 | rgbogo.r_post_offset = roffset; |
2598 | return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); |
2599 | } |
2600 | |
2601 | LOGE("FactorySaveColorTemp_Roffset error!\n"); |
2602 | return -1; |
2603 | } |
2604 | |
2605 | int CVpp::FactoryGetColorTemp_Roffset(int source_type, int colortemp_mode) |
2606 | { |
2607 | tcon_rgb_ogo_t rgbogo; |
2608 | |
2609 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2610 | return rgbogo.r_post_offset; |
2611 | } |
2612 | |
2613 | LOGE("FactoryGetColorTemp_Roffset error!\n"); |
2614 | return -1; |
2615 | } |
2616 | |
2617 | int CVpp::FactorySetColorTemp_Goffset(int source_type, int colortemp_mode, int goffset) |
2618 | { |
2619 | tcon_rgb_ogo_t rgbogo; |
2620 | |
2621 | GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); |
2622 | rgbogo.g_post_offset = goffset; |
2623 | LOGD("%s, source_type[%d], colortemp_mode[%d], g_post_offset[%d].", __FUNCTION__, source_type, |
2624 | colortemp_mode, goffset); |
2625 | rgbogo.en = 1; |
2626 | |
2627 | if (VPP_SetRGBOGO(&rgbogo) == 0) { |
2628 | return 0; |
2629 | } |
2630 | |
2631 | return -1; |
2632 | } |
2633 | |
2634 | int CVpp::FactorySaveColorTemp_Goffset(int source_type, int colortemp_mode, int goffset) |
2635 | { |
2636 | tcon_rgb_ogo_t rgbogo; |
2637 | |
2638 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2639 | rgbogo.g_post_offset = goffset; |
2640 | return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); |
2641 | } |
2642 | |
2643 | LOGE("FactorySaveColorTemp_Goffset error!\n"); |
2644 | return -1; |
2645 | } |
2646 | |
2647 | int CVpp::FactoryGetColorTemp_Goffset(int source_type, int colortemp_mode) |
2648 | { |
2649 | tcon_rgb_ogo_t rgbogo; |
2650 | |
2651 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2652 | return rgbogo.g_post_offset; |
2653 | } |
2654 | |
2655 | LOGE("FactoryGetColorTemp_Goffset error!\n"); |
2656 | return -1; |
2657 | } |
2658 | |
2659 | int CVpp::FactorySetColorTemp_Boffset(int source_type, int colortemp_mode, int boffset) |
2660 | { |
2661 | tcon_rgb_ogo_t rgbogo; |
2662 | |
2663 | GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo); |
2664 | rgbogo.b_post_offset = boffset; |
2665 | LOGD("%s, source_type[%d], colortemp_mode[%d], b_post_offset[%d].", __FUNCTION__, source_type, |
2666 | colortemp_mode, boffset); |
2667 | rgbogo.en = 1; |
2668 | |
2669 | if (VPP_SetRGBOGO(&rgbogo) == 0) { |
2670 | return 0; |
2671 | } |
2672 | |
2673 | return -1; |
2674 | } |
2675 | |
2676 | int CVpp::FactorySaveColorTemp_Boffset(int source_type, int colortemp_mode, int boffset) |
2677 | { |
2678 | tcon_rgb_ogo_t rgbogo; |
2679 | |
2680 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2681 | rgbogo.b_post_offset = boffset; |
2682 | return SetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, rgbogo); |
2683 | } |
2684 | |
2685 | LOGE("FactorySaveColorTemp_Boffset error!\n"); |
2686 | return -1; |
2687 | } |
2688 | |
2689 | int CVpp::FactoryGetColorTemp_Boffset(int source_type, int colortemp_mode) |
2690 | { |
2691 | tcon_rgb_ogo_t rgbogo; |
2692 | |
2693 | if (0 == GetColorTemperatureParams((vpp_color_temperature_mode_t) colortemp_mode, &rgbogo)) { |
2694 | return rgbogo.b_post_offset; |
2695 | } |
2696 | |
2697 | LOGE("FactoryGetColorTemp_Boffset error!\n"); |
2698 | return -1; |
2699 | } |
2700 | |
2701 | int CVpp::FactoryGetTestPattern(void) |
2702 | { |
2703 | unsigned char data = VPP_TEST_PATTERN_NONE; |
2704 | SSMReadTestPattern(&data); |
2705 | return data; |
2706 | } |
2707 | |
2708 | int CVpp::FactoryResetPQMode(void) |
2709 | { |
2710 | mpPqData->PQ_ResetAllPQModeParams(); |
2711 | return 0; |
2712 | } |
2713 | |
2714 | int CVpp::FactoryResetNonlinear(void) |
2715 | { |
2716 | mpPqData->PQ_ResetAllNoLineParams(); |
2717 | return 0; |
2718 | } |
2719 | |
2720 | int CVpp::FactoryResetColorTemp(void) |
2721 | { |
2722 | mpPqData->PQ_ResetAllColorTemperatureParams(); |
2723 | return 0; |
2724 | } |
2725 | |
2726 | int CVpp::FactorySetParamsDefault(void) |
2727 | { |
2728 | FactoryResetPQMode(); |
2729 | FactoryResetNonlinear(); |
2730 | FactoryResetColorTemp(); |
2731 | mpPqData->PQ_ResetAllOverscanParams(); |
2732 | return 0; |
2733 | } |
2734 | |
2735 | int CVpp::FactorySetDDRSSC(int step) |
2736 | { |
2737 | int ret = -1; |
2738 | |
2739 | switch (step) { |
2740 | case 1: |
2741 | // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac86" ); |
2742 | break; |
2743 | |
2744 | case 2: |
2745 | // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac85" ); |
2746 | break; |
2747 | |
2748 | case 3: |
2749 | // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac75" ); |
2750 | break; |
2751 | |
2752 | case 4: |
2753 | // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac65" ); |
2754 | break; |
2755 | |
2756 | case 5: |
2757 | // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000acb3" ); |
2758 | break; |
2759 | |
2760 | case 0: |
2761 | default: |
2762 | // ret = Tv_MiscRegs ( "wc 0x14e6 0x0000ac24" ); |
2763 | break; |
2764 | } |
2765 | |
2766 | if (ret < 0) { |
2767 | return -1; |
2768 | } |
2769 | |
2770 | return SSMSaveDDRSSC(step); |
2771 | } |
2772 | |
2773 | int CVpp::FactoryGetDDRSSC(void) |
2774 | { |
2775 | unsigned char data = 0; |
2776 | SSMReadDDRSSC(&data); |
2777 | return data; |
2778 | } |
2779 | |
2780 | int CVpp::SetLVDSSSC(int step) |
2781 | { |
2782 | int ret = -1; |
2783 | if (step > 4) |
2784 | step = 4; |
2785 | ret = TvMisc_SetLVDSSSC(step); |
2786 | return ret; |
2787 | } |
2788 | int CVpp::FactorySetLVDSSSC(int step) |
2789 | { |
2790 | int ret = -1; |
2791 | unsigned char data[2] = {0, 0}; |
2792 | char cmd_tmp_1[128]; |
2793 | int value = 0, panel_idx = 0, tmp = 0; |
2794 | const char *PanelIdx; |
2795 | if (step > 3) |
2796 | step = 3; |
2797 | |
2798 | PanelIdx = config_get_str ( CFG_SECTION_TV, "get.panel.index", "0" ); |
2799 | panel_idx = strtoul(PanelIdx, NULL, 10); |
2800 | LOGD ("%s, panel_idx = %x", __FUNCTION__, panel_idx); |
2801 | SSMReadLVDSSSC(data); |
2802 | |
2803 | //every 2 bits represent one panel, use 2 byte store 8 panels |
2804 | value = (data[1] << 8) | data[0]; |
2805 | step = step & 0x03; |
2806 | panel_idx = panel_idx * 2; |
2807 | tmp = 3 << panel_idx; |
2808 | value = (value & (~tmp)) | (step << panel_idx); |
2809 | data[0] = value & 0xFF; |
2810 | data[1] = (value >> 8) & 0xFF; |
2811 | LOGD ("%s, tmp = %x, save value = %x", __FUNCTION__, tmp, value); |
2812 | |
2813 | SetLVDSSSC(step); |
2814 | return SSMSaveLVDSSSC(data); |
2815 | } |
2816 | |
2817 | int CVpp::FactoryGetLVDSSSC(void) |
2818 | { |
2819 | unsigned char data[2] = {0, 0}; |
2820 | int value = 0, panel_idx = 0; |
2821 | const char *PanelIdx = config_get_str ( CFG_SECTION_TV, "get.panel.index", "0" ); |
2822 | |
2823 | panel_idx = strtoul(PanelIdx, NULL, 10); |
2824 | SSMReadLVDSSSC(data); |
2825 | value = (data[1] << 8) | data[0]; |
2826 | value = (value >> (2 * panel_idx)) & 0x03; |
2827 | LOGD ("%s, panel_idx = %x, value= %d", __FUNCTION__, panel_idx, value); |
2828 | return value; |
2829 | } |
2830 | |
2831 | noline_params_t CVpp::FactoryGetNolineParams(int type, int source_type) |
2832 | { |
2833 | int ret = -1; |
2834 | noline_params_t noline_params; |
2835 | |
2836 | memset(&noline_params, 0, sizeof(noline_params_t)); |
2837 | |
2838 | switch (type) { |
2839 | case NOLINE_PARAMS_TYPE_BRIGHTNESS: |
2840 | ret = mpPqData->PQ_GetNoLineAllBrightnessParams((tv_source_input_type_t) source_type, |
2841 | &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, |
2842 | &noline_params.osd75, &noline_params.osd100); |
2843 | |
2844 | case NOLINE_PARAMS_TYPE_CONTRAST: |
2845 | ret = mpPqData->PQ_GetNoLineAllContrastParams((tv_source_input_type_t) source_type, |
2846 | &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, |
2847 | &noline_params.osd75, &noline_params.osd100); |
2848 | |
2849 | case NOLINE_PARAMS_TYPE_SATURATION: |
2850 | ret = mpPqData->PQ_GetNoLineAllSaturationParams((tv_source_input_type_t) source_type, |
2851 | &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, |
2852 | &noline_params.osd75, &noline_params.osd100); |
2853 | |
2854 | case NOLINE_PARAMS_TYPE_HUE: |
2855 | ret = mpPqData->PQ_GetNoLineAllHueParams((tv_source_input_type_t) source_type, |
2856 | &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, |
2857 | &noline_params.osd75, &noline_params.osd100); |
2858 | |
2859 | case NOLINE_PARAMS_TYPE_SHARPNESS: |
2860 | ret = mpPqData->PQ_GetNoLineAllSharpnessParams((tv_source_input_type_t) source_type, |
2861 | &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, |
2862 | &noline_params.osd75, &noline_params.osd100); |
2863 | |
2864 | case NOLINE_PARAMS_TYPE_VOLUME: |
2865 | ret = mpPqData->PQ_GetNoLineAllVolumeParams((tv_source_input_type_t) source_type, |
2866 | &noline_params.osd0, &noline_params.osd25, &noline_params.osd50, |
2867 | &noline_params.osd75, &noline_params.osd100); |
2868 | |
2869 | default: |
2870 | break; |
2871 | } |
2872 | |
2873 | return noline_params; |
2874 | } |
2875 | |
2876 | int CVpp::FactorySetNolineParams(int type, int source_type, noline_params_t noline_params) |
2877 | { |
2878 | int ret = -1; |
2879 | |
2880 | switch (type) { |
2881 | case NOLINE_PARAMS_TYPE_BRIGHTNESS: |
2882 | ret = mpPqData->PQ_SetNoLineAllBrightnessParams((tv_source_input_type_t) source_type, |
2883 | noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, |
2884 | noline_params.osd100); |
2885 | break; |
2886 | |
2887 | case NOLINE_PARAMS_TYPE_CONTRAST: |
2888 | ret = mpPqData->PQ_SetNoLineAllContrastParams((tv_source_input_type_t) source_type, |
2889 | noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, |
2890 | noline_params.osd100); |
2891 | break; |
2892 | |
2893 | case NOLINE_PARAMS_TYPE_SATURATION: |
2894 | ret = mpPqData->PQ_SetNoLineAllSaturationParams((tv_source_input_type_t) source_type, |
2895 | noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, |
2896 | noline_params.osd100); |
2897 | |
2898 | case NOLINE_PARAMS_TYPE_HUE: |
2899 | ret = mpPqData->PQ_SetNoLineAllHueParams((tv_source_input_type_t) source_type, |
2900 | noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, |
2901 | noline_params.osd100); |
2902 | |
2903 | case NOLINE_PARAMS_TYPE_SHARPNESS: |
2904 | ret = mpPqData->PQ_SetNoLineAllSharpnessParams((tv_source_input_type_t) source_type, |
2905 | noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, |
2906 | noline_params.osd100); |
2907 | |
2908 | case NOLINE_PARAMS_TYPE_VOLUME: |
2909 | ret = mpPqData->PQ_SetNoLineAllVolumeParams((tv_source_input_type_t) source_type, |
2910 | noline_params.osd0, noline_params.osd25, noline_params.osd50, noline_params.osd75, |
2911 | noline_params.osd100); |
2912 | |
2913 | default: |
2914 | break; |
2915 | } |
2916 | |
2917 | return ret; |
2918 | } |
2919 | |
2920 | int CVpp::FactorySetOverscan(int source_type, int fmt, int status_3d, int trans_fmt, |
2921 | tvin_cutwin_t cutwin_t) |
2922 | { |
2923 | int ret = -1; |
2924 | ret = mpPqData->PQ_SetOverscanParams((tv_source_input_type_t) source_type, |
2925 | (tvin_sig_fmt_t) fmt, INDEX_2D, (tvin_trans_fmt_t) trans_fmt, cutwin_t); |
2926 | |
2927 | if (ret == 0) { |
2928 | } else { |
2929 | LOGE("%s, PQ_SetOverscanParams fail.\n", __FUNCTION__); |
2930 | } |
2931 | return ret; |
2932 | } |
2933 | |
2934 | tvin_cutwin_t CVpp::FactoryGetOverscan(int source_type, int fmt, is_3d_type_t is3d, int trans_fmt) |
2935 | { |
2936 | int ret = -1; |
2937 | tvin_cutwin_t cutwin_t; |
2938 | memset(&cutwin_t, 0, sizeof(cutwin_t)); |
2939 | |
2940 | if (trans_fmt < TVIN_TFMT_2D || trans_fmt > TVIN_TFMT_3D_LDGD) { |
2941 | return cutwin_t; |
2942 | } |
2943 | |
2944 | ret = mpPqData->PQ_GetOverscanParams((tv_source_input_type_t) source_type, |
2945 | (tvin_sig_fmt_t) fmt, is3d, (tvin_trans_fmt_t) trans_fmt, VPP_DISPLAY_MODE_169, |
2946 | &cutwin_t); |
2947 | |
2948 | if (ret == 0) { |
2949 | } else { |
2950 | LOGE("%s, PQ_GetOverscanParams faild.\n", __FUNCTION__); |
2951 | } |
2952 | |
2953 | return cutwin_t; |
2954 | } |
2955 | |
2956 | int CVpp::FactorySetBacklightPWM_Frequency(int freq) |
2957 | { |
2958 | LOGD("%s,FactorySetBacklightPWM_Frequency set freq %d .\n", __FUNCTION__, freq); |
2959 | return 1; |
2960 | } |
2961 | |
2962 | int CVpp::FactoryGetBacklightPWM_Frequency(void) |
2963 | { |
2964 | int freq = 50; |
2965 | LOGD("%s,FactoryGetBacklightPWM_Frequency set freq %d .\n", CFG_SECTION_TV, freq); |
2966 | return freq; |
2967 | } |
2968 | |
2969 | int CVpp::FactorySetBacklight_Switch_status(int status) |
2970 | { |
2971 | LOGD("%s,FactorySetBacklight_Switch_status set status %d .\n", __FUNCTION__, status); |
2972 | return 1; |
2973 | } |
2974 | |
2975 | int CVpp::FactoryGetBacklight_Switch_status(void) |
2976 | { |
2977 | int status = 1; |
2978 | LOGD("%s,FactoryGetBacklight_Switch_status get status %d .\n", __FUNCTION__, status); |
2979 | return status; |
2980 | } |
2981 | |
2982 | int CVpp::FactorySetBacklightPWM_Duty(int duty) |
2983 | { |
2984 | LOGD("%s,FactorySetBacklight_Switch_status set duty %d .\n", __FUNCTION__, duty); |
2985 | return 1; |
2986 | } |
2987 | |
2988 | int CVpp::FactoryGetBacklightPWM_Duty(void) |
2989 | { |
2990 | int duty = 1; |
2991 | LOGD("%s,FactoryGetBacklight_Switch_status get duty %d .\n", __FUNCTION__, duty); |
2992 | return duty; |
2993 | } |
2994 | |
2995 | int CVpp::FactorySetLVDS_ColorDepth(int depth) |
2996 | { |
2997 | LOGD("%s,FactorySetLVDS_ColorDepth set depth %d .\n", CFG_SECTION_TV, depth); |
2998 | return 1; |
2999 | } |
3000 | |
3001 | int CVpp::FactoryGetLVDS_ColorDepth(void) |
3002 | { |
3003 | int depth = 1; |
3004 | LOGD("%s,FactorySetLVDS_ColorDepth get freq %d .\n", __FUNCTION__, depth); |
3005 | return depth; |
3006 | } |
3007 | |
3008 | int CVpp::FactorySetLVDS_ColorDither_status(int status) |
3009 | { |
3010 | LOGD("%s,FactorySetLVDS_ColorDither_status set status %d .\n", __FUNCTION__, status); |
3011 | return 1; |
3012 | } |
3013 | |
3014 | int CVpp::FactoryGetLVDS_ColorDither_status(void) |
3015 | { |
3016 | int status = 1; |
3017 | LOGD("%s,FactoryGetLVDS_ColorDither_status get status %d .\n", __FUNCTION__, status); |
3018 | return status; |
3019 | } |
3020 | |
3021 | int CVpp::FactorySetLVDS_Mapping_status(int status) |
3022 | { |
3023 | LOGD("%s,FactorySetLVDS_Mapping_status set status %d .\n", __FUNCTION__, status); |
3024 | return 1; |
3025 | } |
3026 | |
3027 | int CVpp::FactoryGetLVDS_Mapping_status(void) |
3028 | { |
3029 | int status = 1; |
3030 | LOGD("%s,FactoryGetLVDS_Mapping_status get status %d .\n", __FUNCTION__, status); |
3031 | return status; |
3032 | } |
3033 | |
3034 | int CVpp::FactorySetLVDS_PortSwap_status(int status) |
3035 | { |
3036 | LOGD("%s,FactorySetLVDS_PortSwap_status set status %d .\n", __FUNCTION__, status); |
3037 | return 1; |
3038 | } |
3039 | |
3040 | int CVpp::FactoryGetLVDS_PortSwap_status(void) |
3041 | { |
3042 | int status = 1; |
3043 | LOGD("%s,FactoryGetLVDS_PortSwap_status get status %d .\n", __FUNCTION__, status); |
3044 | return status; |
3045 | } |
3046 | |
3047 | int CVpp::VPPSSMRestoreDefault() |
3048 | { |
3049 | int i = 0, tmp_val = 0; |
3050 | int tmp_panorama_nor = 0, tmp_panorama_full = 0; |
3051 | int offset_r = 0, offset_g = 0, offset_b = 0, gain_r = 1024, gain_g = 1024, gain_b = 1024; |
3052 | int8_t std_buf[6] = { 0, 0, 0, 0, 0, 0 }; |
3053 | int8_t warm_buf[6] = { 0, 0, -8, 0, 0, 0 }; |
3054 | int8_t cold_buf[6] = { -8, 0, 0, 0, 0, 0 }; |
3055 | unsigned char tmp[2] = {0, 0}; |
3056 | |
3057 | SSMSaveColorDemoMode ( VPP_COLOR_DEMO_MODE_ALLON); |
3058 | SSMSaveColorBaseMode ( VPP_COLOR_BASE_MODE_OPTIMIZE); |
3059 | SSMSaveRGBGainRStart(0, gain_r); |
3060 | SSMSaveRGBGainGStart(0, gain_g); |
3061 | SSMSaveRGBGainBStart(0, gain_b); |
3062 | SSMSaveRGBPostOffsetRStart(0, offset_r); |
3063 | SSMSaveRGBPostOffsetGStart(0, offset_g); |
3064 | SSMSaveRGBPostOffsetBStart(0, offset_b); |
3065 | SSMSaveUserNatureLightSwitch(1); |
3066 | SSMSaveGammaValue(0); |
3067 | SSMSaveGraphyBacklight(100); |
3068 | SSMSaveDBCStart(0); |
3069 | SSMSaveDnlpStart(0); //0: ON,1: OFF,default is on |
3070 | SSMSaveAPL(30); |
3071 | SSMSaveAPL2(30); |
3072 | SSMSaveBD(30); |
3073 | SSMSaveBP(30); |
3074 | |
3075 | SSMSaveFBCELECmodeVal(11); |
3076 | SSMSaveFBCN360BackLightVal(10); |
3077 | SSMSaveFBCN360ColorTempVal(1); // standard colortemp |
3078 | |
3079 | SSMSaveFBCN310ColorTempVal(0); |
3080 | SSMSaveFBCN310LightsensorVal(0); |
3081 | SSMSaveFBCN310Dream_PanelVal(1); |
3082 | SSMSaveFBCN310MULT_PQVal(1); |
3083 | SSMSaveFBCN310MEMCVal(2); |
3084 | SSMSaveFBCN310BackLightVal(254); |
3085 | for (i = 0; i < 6; i++) { |
3086 | SSMSaveRGBValueStart(i + VPP_COLOR_TEMPERATURE_MODE_STANDARD * 6, std_buf[i]); //0~5 |
3087 | SSMSaveRGBValueStart(i + VPP_COLOR_TEMPERATURE_MODE_WARM * 6, warm_buf[i]); //6~11 |
3088 | SSMSaveRGBValueStart(i + VPP_COLOR_TEMPERATURE_MODE_COLD * 6, cold_buf[i]); //12~17 |
3089 | } |
3090 | |
3091 | for (i = 0; i < SOURCE_TYPE_MAX; i++) { |
3092 | if (i == SOURCE_TYPE_HDMI) { |
3093 | SSMSaveColorSpaceStart ( VPP_COLOR_SPACE_AUTO); |
3094 | } |
3095 | |
3096 | tmp_val = VPP_COLOR_TEMPERATURE_MODE_STANDARD; |
3097 | tmp_panorama_nor = VPP_PANORAMA_MODE_NORMAL; |
3098 | tmp_panorama_full = VPP_PANORAMA_MODE_FULL; |
3099 | |
3100 | if (i == SOURCE_TYPE_HDMI) { |
3101 | SSMSavePanoramaStart(i, tmp_panorama_full); |
3102 | } else { |
3103 | SSMSavePanoramaStart(i, tmp_panorama_nor); |
3104 | } |
3105 | |
3106 | SSMSaveColorTemperature(i, tmp_val); |
3107 | tmp_val = 50; |
3108 | SSMSaveBrightness(i, tmp_val); |
3109 | SSMSaveContrast(i, tmp_val); |
3110 | SSMSaveSaturation(i, tmp_val); |
3111 | SSMSaveHue(i, tmp_val); |
3112 | SSMSaveSharpness(i, tmp_val); |
3113 | tmp_val = VPP_PICTURE_MODE_STANDARD; |
3114 | SSMSavePictureMode(i, tmp_val); |
3115 | tmp_val = VPP_DISPLAY_MODE_169; |
3116 | SSMSaveDisplayMode(i, tmp_val); |
3117 | tmp_val = VPP_NOISE_REDUCTION_MODE_AUTO; |
3118 | SSMSaveNoiseReduction(i, tmp_val); |
3119 | tmp_val = 100; |
3120 | SSMSaveBackLightVal(i, tmp_val); |
3121 | } |
3122 | |
3123 | SSMSaveDDRSSC(0); |
3124 | SSMSaveLVDSSSC(tmp); |
3125 | return 0; |
3126 | } |
3127 | |
3128 | int CVpp::VPPSSMFacRestoreDefault() |
3129 | { |
3130 | return VPPSSMRestoreDefault(); |
3131 | } |
3132 | |
3133 | int CVpp::SetRGBValue(vpp_color_temperature_mode_t temp_mode, unsigned char data_buf[]) |
3134 | { |
3135 | int8_t r_gain = 0, b_gain = 0, g_gain = 0, r_offset = 0, g_offset = 0, b_offset = 0; |
3136 | int ret = -1; |
3137 | tcon_rgb_ogo_t rgbogo; |
3138 | rgbogo.en = 1; |
3139 | rgbogo.r_pre_offset = 0; |
3140 | rgbogo.g_pre_offset = 0; |
3141 | rgbogo.b_pre_offset = 0; |
3142 | r_gain = data_buf[0]; |
3143 | g_gain = data_buf[1]; |
3144 | b_gain = data_buf[2]; |
3145 | r_offset = data_buf[3]; |
3146 | g_offset = data_buf[4]; |
3147 | b_offset = data_buf[5]; |
3148 | int mode = (int) temp_mode; |
3149 | |
3150 | switch (mode) { |
3151 | case 1: |
3152 | ret = SSMSaveRGBValueStart(0 + mode * 6, r_gain); |
3153 | ret |= SSMSaveRGBValueStart(1 + mode * 6, g_gain); |
3154 | ret |= SSMSaveRGBValueStart(2 + mode * 6, b_gain); |
3155 | ret |= SSMSaveRGBValueStart(3 + mode * 6, r_offset); |
3156 | ret |= SSMSaveRGBValueStart(4 + mode * 6, g_offset); |
3157 | ret |= SSMSaveRGBValueStart(5 + mode * 6, b_offset); |
3158 | break; |
3159 | |
3160 | case 2: |
3161 | ret = SSMSaveRGBValueStart(0 + mode * 6, r_gain); |
3162 | ret |= SSMSaveRGBValueStart(1 + mode * 6, g_gain); |
3163 | ret |= SSMSaveRGBValueStart(2 + mode * 6, b_gain); |
3164 | ret |= SSMSaveRGBValueStart(3 + mode * 6, r_offset); |
3165 | ret |= SSMSaveRGBValueStart(4 + mode * 6, g_offset); |
3166 | ret |= SSMSaveRGBValueStart(5 + mode * 6, b_offset); |
3167 | break; |
3168 | |
3169 | case 0: |
3170 | default: |
3171 | ret = SSMSaveRGBValueStart(0, r_gain); |
3172 | ret |= SSMSaveRGBValueStart(1, g_gain); |
3173 | ret |= SSMSaveRGBValueStart(2, b_gain); |
3174 | ret |= SSMSaveRGBValueStart(3, r_offset); |
3175 | ret |= SSMSaveRGBValueStart(4, g_offset); |
3176 | ret |= SSMSaveRGBValueStart(5, b_offset); |
3177 | break; |
3178 | } |
3179 | |
3180 | if (ret == 0) { |
3181 | rgbogo.r_gain = RGBGainValueSSMToRisterMapping(r_gain + 128); |
3182 | rgbogo.g_gain = RGBGainValueSSMToRisterMapping(g_gain + 128); |
3183 | rgbogo.b_gain = RGBGainValueSSMToRisterMapping(b_gain + 128); |
3184 | rgbogo.r_post_offset = RGBOffsetValueSSMToRisterMapping(r_offset); |
3185 | rgbogo.g_post_offset = RGBOffsetValueSSMToRisterMapping(g_offset); |
3186 | rgbogo.b_post_offset = RGBOffsetValueSSMToRisterMapping(b_offset); |
3187 | ret |= VPP_SetRGBOGO(&rgbogo); |
3188 | } |
3189 | |
3190 | return ret; |
3191 | } |
3192 | |
3193 | int CVpp::GetRGBValue(vpp_color_temperature_mode_t temp_mode, tcon_rgb_ogo_t *p_rgbogo) |
3194 | { |
3195 | int8_t r_gain = 0, b_gain = 0, g_gain = 0, r_offset = 0, g_offset = 0, b_offset = 0; |
3196 | int ret = -1; |
3197 | |
3198 | p_rgbogo->en = 1; |
3199 | p_rgbogo->r_pre_offset = 0; |
3200 | p_rgbogo->g_pre_offset = 0; |
3201 | p_rgbogo->b_pre_offset = 0; |
3202 | p_rgbogo->r_gain = 0; |
3203 | p_rgbogo->g_gain = 0; |
3204 | p_rgbogo->b_gain = 0; |
3205 | p_rgbogo->r_post_offset = 0; |
3206 | p_rgbogo->g_post_offset = 0; |
3207 | p_rgbogo->b_post_offset = 0; |
3208 | int mode = (int) temp_mode; |
3209 | |
3210 | switch (mode) { |
3211 | case 1: |
3212 | ret = SSMReadRGBValueStart(0 + mode * 6, &r_gain); |
3213 | ret |= SSMReadRGBValueStart(1 + mode * 6, &g_gain); |
3214 | ret |= SSMReadRGBValueStart(2 + mode * 6, &b_gain); |
3215 | ret |= SSMReadRGBValueStart(3 + mode * 6, &r_offset); |
3216 | ret |= SSMReadRGBValueStart(4 + mode * 6, &g_offset); |
3217 | ret |= SSMReadRGBValueStart(5 + mode * 6, &b_offset); |
3218 | break; |
3219 | |
3220 | case 2: |
3221 | ret = SSMReadRGBValueStart(0 + mode * 6, &r_gain); |
3222 | ret |= SSMReadRGBValueStart(1 + mode * 6, &g_gain); |
3223 | ret |= SSMReadRGBValueStart(2 + mode * 6, &b_gain); |
3224 | ret |= SSMReadRGBValueStart(3 + mode * 6, &r_offset); |
3225 | ret |= SSMReadRGBValueStart(4 + mode * 6, &g_offset); |
3226 | ret |= SSMReadRGBValueStart(5 + mode * 6, &b_offset); |
3227 | break; |
3228 | |
3229 | case 0: |
3230 | default: |
3231 | ret = SSMReadRGBValueStart(0, &r_gain); |
3232 | ret |= SSMReadRGBValueStart(1, &g_gain); |
3233 | ret |= SSMReadRGBValueStart(2, &b_gain); |
3234 | ret |= SSMReadRGBValueStart(3, &r_offset); |
3235 | ret |= SSMReadRGBValueStart(4, &g_offset); |
3236 | ret |= SSMReadRGBValueStart(5, &b_offset); |
3237 | break; |
3238 | } |
3239 | |
3240 | p_rgbogo->r_gain = r_gain + 128; //r_gain:-128~127 |
3241 | p_rgbogo->g_gain = g_gain + 128; |
3242 | p_rgbogo->b_gain = b_gain + 128; |
3243 | p_rgbogo->r_post_offset = r_offset; |
3244 | p_rgbogo->g_post_offset = g_offset; |
3245 | p_rgbogo->b_post_offset = b_offset; |
3246 | |
3247 | return ret; |
3248 | } |
3249 | |
3250 | #define PI 3.14159265358979 |
3251 | void CVpp::video_set_saturation_hue(signed char saturation, signed char hue, signed long *mab) |
3252 | { |
3253 | signed short ma = (signed short) (cos((float) hue * PI / 128.0) * ((float) saturation / 128.0 |
3254 | + 1.0) * 256.0); |
3255 | signed short mb = (signed short) (sin((float) hue * PI / 128.0) * ((float) saturation / 128.0 |
3256 | + 1.0) * 256.0); |
3257 | |
3258 | if (ma > 511) { |
3259 | ma = 511; |
3260 | } |
3261 | |
3262 | if (ma < -512) { |
3263 | ma = -512; |
3264 | } |
3265 | |
3266 | if (mb > 511) { |
3267 | mb = 511; |
3268 | } |
3269 | |
3270 | if (mb < -512) { |
3271 | mb = -512; |
3272 | } |
3273 | |
3274 | *mab = ((ma & 0x3ff) << 16) | (mb & 0x3ff); |
3275 | } |
3276 | |
3277 | void CVpp::video_get_saturation_hue(signed char *sat, signed char *hue, signed long *mab) |
3278 | { |
3279 | signed long temp = *mab; |
3280 | signed int ma = (signed int) ((temp << 6) >> 22); |
3281 | signed int mb = (signed int) ((temp << 22) >> 22); |
3282 | signed int sat16 = (signed int) ((sqrt( |
3283 | ((float) ma * (float) ma + (float) mb * (float) mb) / 65536.0) - 1.0) * 128.0); |
3284 | signed int hue16 = (signed int) (atan((float) mb / (float) ma) * 128.0 / PI); |
3285 | |
3286 | if (sat16 > 127) { |
3287 | sat16 = 127; |
3288 | } |
3289 | |
3290 | if (sat16 < -128) { |
3291 | sat16 = -128; |
3292 | } |
3293 | |
3294 | if (hue16 > 127) { |
3295 | hue16 = 127; |
3296 | } |
3297 | |
3298 | if (hue16 < -128) { |
3299 | hue16 = -128; |
3300 | } |
3301 | |
3302 | *sat = (signed char) sat16; |
3303 | *hue = (signed char) hue16; |
3304 | } |
3305 | |
3306 | int CVpp::VPP_SetVideoSaturationHue(int satVal, int hueVal) |
3307 | { |
3308 | FILE *fp = NULL; |
3309 | signed long temp; |
3310 | |
3311 | fp = fopen("/sys/class/amvecm/saturation_hue", "w"); |
3312 | LOGD("~~~fopen~~~##VPP_SetVideoSaturationHue##%s : %d %d##", |
3313 | "/sys/class/amvecm/saturation_hue", satVal, hueVal); |
3314 | |
3315 | if (fp == NULL) { |
3316 | LOGE("Open /sys/class/amvecm/saturation_hue error(%s)!\n", strerror(errno)); |
3317 | return -1; |
3318 | } |
3319 | |
3320 | video_set_saturation_hue(satVal, hueVal, &temp); |
3321 | fprintf(fp, "0x%lx", temp); |
3322 | |
3323 | fclose(fp); |
3324 | fp = NULL; |
3325 | |
3326 | return 0; |
3327 | } |
3328 | |
3329 | int CVpp::VPP_SetVideoSaturation(int saturation) |
3330 | { |
3331 | FILE *fp = NULL; |
3332 | |
3333 | fp = fopen("/sys/class/amvecm/saturation_hue", "w"); |
3334 | LOGD("~~~fopen~~~##VPP_SetVideoSaturation##%s : %d ##", "/sys/class/amvecm/saturation_hue", |
3335 | saturation); |
3336 | |
3337 | if (fp == NULL) { |
3338 | LOGE("Open /sys/class/amvecm/saturation_hue error(%s)!\n", strerror(errno)); |
3339 | return -1; |
3340 | } |
3341 | |
3342 | fprintf(fp, "0x%x", saturation); |
3343 | |
3344 | fclose(fp); |
3345 | fp = NULL; |
3346 | |
3347 | return 0; |
3348 | } |
3349 | |
3350 | int CVpp::VPP_SetVideoHue(int hue) |
3351 | { |
3352 | FILE *fp = NULL; |
3353 | |
3354 | fp = fopen("/sys/class/amvecm/saturation_hue", "w"); |
3355 | LOGD("~~~fopen~~~##VPP_SetVideoHue##%s : %d ##", "/sys/class/amvecm/saturation_hue", hue); |
3356 | |
3357 | if (fp == NULL) { |
3358 | LOGE("Open /sys/class/amvecm/saturation_hue error(%s)!\n", strerror(errno)); |
3359 | return -1; |
3360 | } |
3361 | |
3362 | fprintf(fp, "0x%x", hue); |
3363 | |
3364 | fclose(fp); |
3365 | fp = NULL; |
3366 | return 0; |
3367 | } |
3368 | |
3369 | int CVpp::VPP_SetGammaTbl_R(unsigned short red[256]) |
3370 | { |
3371 | struct tcon_gamma_table_s Redtbl; |
3372 | int rt = -1, i = 0; |
3373 | |
3374 | for (i = 0; i < 256; i++) { |
3375 | Redtbl.data[i] = red[i]; |
3376 | } |
3377 | |
3378 | rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_R, &Redtbl); |
3379 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaTbl_R##AMVECM_IOC_GAMMA_TABLE_R##"); |
3380 | |
3381 | if (rt < 0) { |
3382 | LOGE("Vpp_api_SetGammaTbl_R, error(%s)!\n", strerror(errno)); |
3383 | } |
3384 | |
3385 | return rt; |
3386 | } |
3387 | |
3388 | int CVpp::VPP_SetGammaTbl_G(unsigned short green[256]) |
3389 | { |
3390 | struct tcon_gamma_table_s Greentbl; |
3391 | int rt = -1, i = 0; |
3392 | |
3393 | for (i = 0; i < 256; i++) { |
3394 | Greentbl.data[i] = green[i]; |
3395 | } |
3396 | |
3397 | rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_G, &Greentbl); |
3398 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaTbl_G##AMVECM_IOC_GAMMA_TABLE_G##"); |
3399 | |
3400 | if (rt < 0) { |
3401 | LOGE("Vpp_api_SetGammaTbl_R, error(%s)!\n", strerror(errno)); |
3402 | } |
3403 | |
3404 | return rt; |
3405 | } |
3406 | |
3407 | int CVpp::VPP_SetGammaTbl_B(unsigned short blue[256]) |
3408 | { |
3409 | struct tcon_gamma_table_s Bluetbl; |
3410 | int rt = -1, i = 0; |
3411 | |
3412 | for (i = 0; i < 256; i++) { |
3413 | Bluetbl.data[i] = blue[i]; |
3414 | } |
3415 | |
3416 | rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_B, &Bluetbl); |
3417 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaTbl_B##AMVECM_IOC_GAMMA_TABLE_B##"); |
3418 | |
3419 | if (rt < 0) { |
3420 | LOGE("Vpp_api_SetGammaTbl_R, error(%s)!\n", strerror(errno)); |
3421 | } |
3422 | |
3423 | return rt; |
3424 | } |
3425 | |
3426 | int CVpp::VPP_SetGammaOnOff(unsigned char onoff) |
3427 | { |
3428 | int rt = -1; |
3429 | |
3430 | if (onoff == 1) { |
3431 | rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_EN); |
3432 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaOnOff##AMVECM_IOC_GAMMA_TABLE_EN##"); |
3433 | } |
3434 | |
3435 | if (onoff == 0) { |
3436 | rt = VPP_DeviceIOCtl(AMVECM_IOC_GAMMA_TABLE_DIS); |
3437 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetGammaOnOff##AMVECM_IOC_GAMMA_TABLE_DIS##"); |
3438 | } |
3439 | |
3440 | if (rt < 0) { |
3441 | LOGE("Vpp_api_SetGammaOnOff, error(%s)!\n", strerror(errno)); |
3442 | } |
3443 | |
3444 | return rt; |
3445 | } |
3446 | |
3447 | int CVpp::VPP_SetGrayPattern(int value) |
3448 | { |
3449 | |
3450 | FILE *fp = NULL; |
3451 | if (value < 0) { |
3452 | value = 0; |
3453 | } else if (value > 255) { |
3454 | value = 255; |
3455 | } |
3456 | value = value << 16 | 0x8080; |
3457 | |
3458 | fp = fopen("/sys/class/video/test_screen", "w"); |
3459 | LOGD("~~~fopen~~~##VPP_SetGrayPattern##%s : %x ##", "/sys/class/video/test_screen", value); |
3460 | |
3461 | if (fp == NULL) { |
3462 | LOGE("Open /sys/classs/video/test_screen error(%s)!\n", strerror(errno)); |
3463 | return -1; |
3464 | } |
3465 | |
3466 | fprintf(fp, "0x%x", value); |
3467 | fclose(fp); |
3468 | fp = NULL; |
3469 | |
3470 | return 0; |
3471 | } |
3472 | |
3473 | int CVpp::VPP_GetGrayPattern() |
3474 | { |
3475 | FILE *fp = NULL; |
3476 | int value; |
3477 | fp = fopen("/sys/class/video/test_screen", "r+"); |
3478 | |
3479 | LOGD("~~~fopen~~~##VPP_GetGrayPattern##%s ##", "/sys/class/video/test_screen"); |
3480 | |
3481 | if (fp == NULL) { |
3482 | LOGE("Open /sys/class/video/test_screen error(%s)!\n", strerror(errno)); |
3483 | return -1; |
3484 | } |
3485 | |
3486 | fscanf(fp, "%d", &value); |
3487 | fclose(fp); |
3488 | fp = NULL; |
3489 | if (value < 0) { |
3490 | return 0; |
3491 | } else { |
3492 | value = value >> 16; |
3493 | if (value > 255) { |
3494 | value = 255; |
3495 | } |
3496 | return value; |
3497 | } |
3498 | |
3499 | } |
3500 | |
3501 | int CVpp::VPP_SplitScreenEffect(int width, int v_register) |
3502 | { |
3503 | FILE *fp = fopen("/sys/class/amlogic/debug", "w"); |
3504 | |
3505 | if (fp == NULL) { |
3506 | LOGE("Open /sys/class/amlogic/debug ERROR(%s)!!\n", strerror(errno)); |
3507 | return -1; |
3508 | } |
3509 | LOGD("width = %x----v_register = %x", width, v_register); |
3510 | fprintf(fp, "w %x v %x", width, v_register); |
3511 | fclose(fp); |
3512 | fp = NULL; |
3513 | |
3514 | return 0; |
3515 | } |
3516 | int CVpp::VPP_SetVideoNoiseReduction(int value) |
3517 | { |
3518 | FILE *fp = NULL; |
3519 | |
3520 | fp = fopen("/sys/class/deinterlace/di0/parameters", "w"); |
3521 | LOGD("~~~fopen~~~##VPP_SetVideoNoiseReduction##%s : %d ##", |
3522 | "/sys/class/deinterlace/di0/parameters", value); |
3523 | |
3524 | if (fp == NULL) { |
3525 | LOGE("Open /sys/class/deinterlace/di0/parameters ERROR(%s)!!\n", strerror(errno)); |
3526 | return -1; |
3527 | } |
3528 | |
3529 | fprintf(fp, "noise_reduction_level=%x", value); |
3530 | fclose(fp); |
3531 | fp = NULL; |
3532 | |
3533 | return 0; |
3534 | } |
3535 | |
3536 | int CVpp::VPP_SetDeinterlaceMode(int value) |
3537 | { |
3538 | FILE *fp = NULL; |
3539 | |
3540 | fp = fopen("/sys/module/deinterlace/parameters/deinterlace_mode", "w"); |
3541 | LOGD("~~~fopen~~~##VPP_SetDeinterlaceMode##%s : %d ##", |
3542 | "/sys/module/deinterlace/parameters/deinterlace_mode", value); |
3543 | |
3544 | if (fp == NULL) { |
3545 | LOGE("Open /sys/module/deinterlace/parameters/deinterlace_mode error(%s)!\n", |
3546 | strerror(errno)); |
3547 | return -1; |
3548 | } |
3549 | |
3550 | fprintf(fp, "%d", value); |
3551 | |
3552 | fclose(fp); |
3553 | fp = NULL; |
3554 | |
3555 | return 0; |
3556 | } |
3557 | |
3558 | int CVpp::GetHistogram_AVE(void) |
3559 | { |
3560 | ve_hist_t hist; |
3561 | hist.sum = 0; |
3562 | hist.height = 0; |
3563 | hist.width = 0; |
3564 | hist.ave = 0; |
3565 | |
3566 | if (Vpp_GetAVGHistogram(&hist) == 0) { |
3567 | LOGD("%s: %d.\n", __FUNCTION__, hist.ave); |
3568 | } else { |
3569 | LOGE("%s failed.\n", __FUNCTION__); |
3570 | } |
3571 | |
3572 | return hist.ave; |
3573 | } |
3574 | |
3575 | int CVpp::Vpp_GetAVGHistogram(struct ve_hist_s *hist) |
3576 | { |
3577 | //int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_G_HIST_AVG, hist); |
3578 | int rt = VPP_DeviceIOCtl(AMVECM_IOC_G_HIST_AVG, hist); |
3579 | LOGD("~~~VPP_DeviceIOCtl~~~##Vpp_GetAVGHistogram##AMVECM_IOC_G_HIST_AVG##"); |
3580 | |
3581 | if (rt < 0) { |
3582 | LOGE("Vpp_GetAVGHistogram, error(%s)!\n", strerror(errno)); |
3583 | } |
3584 | |
3585 | return rt; |
3586 | } |
3587 | |
3588 | int CVpp::VPP_SetVEBlackExtension(const struct ve_bext_s *pBExt) |
3589 | { |
3590 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_BEXT, pBExt); |
3591 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEBlackExtension##AMSTREAM_IOC_VE_BEXT##"); |
3592 | |
3593 | if (rt < 0) { |
3594 | LOGE("Vpp_api_SetVEBlackExtension, error(%s)!\n", strerror(errno)); |
3595 | } |
3596 | |
3597 | return rt; |
3598 | } |
3599 | |
3600 | tvin_cutwin_t CVpp::GetOverscan(tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, |
3601 | is_3d_type_t is3d, tvin_trans_fmt_t trans_fmt) |
3602 | { |
3603 | int ret = -1; |
3604 | char tmp_buf[16]; |
3605 | tvin_cutwin_t cutwin_t; |
3606 | memset(&cutwin_t, 0, sizeof(cutwin_t)); |
3607 | |
3608 | if (trans_fmt < TVIN_TFMT_2D || trans_fmt > TVIN_TFMT_3D_LDGD) { |
3609 | return cutwin_t; |
3610 | } |
3611 | |
3612 | vpp_display_mode_t scrmode = GetDisplayMode(source_type); |
3613 | ret = mpPqData->PQ_GetOverscanParams(source_type, fmt, is3d, trans_fmt, scrmode, &cutwin_t); |
3614 | |
3615 | return cutwin_t; |
3616 | } |
3617 | |
3618 | int CVpp::VPP_SetVideoCrop(int Voffset0, int Hoffset0, int Voffset1, int Hoffset1) |
3619 | { |
3620 | int fd = -1; |
3621 | char set_str[32]; |
3622 | |
3623 | fd = open("/sys/class/video/crop", O_RDWR); |
3624 | |
3625 | LOGD("~~~open~~~##VPP_SetVideoCrop##%s : %d %d %d %d##", "/sys/class/video/crop", Voffset0, |
3626 | Hoffset0, Voffset1, Hoffset1); |
3627 | |
3628 | if (fd < 0) { |
3629 | LOGE("Open /sys/class/video/crop error(%s)!\n", strerror(errno)); |
3630 | return -1; |
3631 | } |
3632 | |
3633 | memset(set_str, 0, 32); |
3634 | sprintf(set_str, "%d %d %d %d", Voffset0, Hoffset0, Voffset1, Hoffset1); |
3635 | write(fd, set_str, strlen(set_str)); |
3636 | close(fd); |
3637 | |
3638 | return 0; |
3639 | } |
3640 | |
3641 | int CVpp::VPP_SetVESharpness(const struct ve_hsvs_s *pHSVS) |
3642 | { |
3643 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_HSVS, pHSVS); |
3644 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVESharpness##AMSTREAM_IOC_VE_HSVS##"); |
3645 | |
3646 | if (rt < 0) { |
3647 | LOGE("Vpp_api_SetVESharpness, error(%s)!\n", strerror(errno)); |
3648 | } |
3649 | |
3650 | return rt; |
3651 | } |
3652 | |
3653 | int CVpp::VPP_SetVEChromaCoring(const struct ve_ccor_s *pCCor) |
3654 | { |
3655 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_CCOR, pCCor); |
3656 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEChromaCoring##AMSTREAM_IOC_VE_CCOR##"); |
3657 | |
3658 | if (rt < 0) { |
3659 | LOGE("Vpp_api_SetVEChromaCoring, error(%s)!\n", strerror(errno)); |
3660 | } |
3661 | |
3662 | return rt; |
3663 | } |
3664 | |
3665 | int CVpp::VPP_SetVEBlueEnh(const struct ve_benh_s *pBEnh) |
3666 | { |
3667 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_BENH, pBEnh); |
3668 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEBlueEnh##AMSTREAM_IOC_VE_BENH##"); |
3669 | |
3670 | if (rt < 0) { |
3671 | LOGE("Vpp_api_SetVEBlueEnh, error(%s)!\n", strerror(errno)); |
3672 | } |
3673 | |
3674 | return rt; |
3675 | } |
3676 | |
3677 | int CVpp::VPP_SetVEDemo(const struct ve_demo_s *pDemo) |
3678 | { |
3679 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DEMO, pDemo); |
3680 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEDemo##AMSTREAM_IOC_VE_DEMO##"); |
3681 | |
3682 | if (rt < 0) { |
3683 | LOGE("Vpp_api_SetVEDemo, error(%s)!\n", strerror(errno)); |
3684 | } |
3685 | |
3686 | return rt; |
3687 | } |
3688 | |
3689 | int CVpp::VPP_SetVERegisterMap(const struct ve_regmap_s *pRegMap) |
3690 | { |
3691 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_REGMAP, pRegMap); |
3692 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVERegisterMap##AMSTREAM_IOC_VE_REGMAP##"); |
3693 | |
3694 | if (rt < 0) { |
3695 | LOGE("Vpp_api_SetVERegisterMap, error(%s)!\n", strerror(errno)); |
3696 | } |
3697 | |
3698 | return rt; |
3699 | } |
3700 | |
3701 | int CVpp::VPP_SetVEDebug(const unsigned long long *pLData) |
3702 | { |
3703 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_VE_DEBUG, pLData); |
3704 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetVEDebug##AMSTREAM_IOC_VE_DEBUG##"); |
3705 | |
3706 | if (rt < 0) { |
3707 | LOGE("Vpp_api_SetVEDebug, error(%s)!\n", strerror(errno)); |
3708 | } |
3709 | |
3710 | return rt; |
3711 | } |
3712 | |
3713 | int CVpp::VPP_SetCMRegion(const struct cm_region_s *pRegion) |
3714 | { |
3715 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_REGION, pRegion); |
3716 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMRegion##AMSTREAM_IOC_CM_REGION##"); |
3717 | |
3718 | if (rt < 0) { |
3719 | LOGE("Vpp_api_SetCMRegion, error(%s)!\n", strerror(errno)); |
3720 | } |
3721 | |
3722 | return rt; |
3723 | } |
3724 | |
3725 | int CVpp::VPP_SetCMTopLayer(const struct cm_top_s *pTop) |
3726 | { |
3727 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_TOP, pTop); |
3728 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMTopLayer##AMSTREAM_IOC_CM_TOP##"); |
3729 | |
3730 | if (rt < 0) { |
3731 | LOGE("Vpp_api_SetCMTopLayer, error(%s)!\n", strerror(errno)); |
3732 | } |
3733 | |
3734 | return rt; |
3735 | } |
3736 | |
3737 | int CVpp::VPP_SetCMDemo(const struct cm_demo_s *pDemo) |
3738 | { |
3739 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_DEMO, pDemo); |
3740 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMDemo##AMSTREAM_IOC_CM_DEMO##"); |
3741 | |
3742 | if (rt < 0) { |
3743 | LOGE("Vpp_api_SetCMDemo, error(%s)!\n", strerror(errno)); |
3744 | } |
3745 | |
3746 | return rt; |
3747 | } |
3748 | |
3749 | int CVpp::VPP_SetCMRegisterMap(struct cm_regmap_s *pRegMap) |
3750 | { |
3751 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_REGMAP, pRegMap); |
3752 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMRegisterMap##AMSTREAM_IOC_CM_REGMAP##"); |
3753 | |
3754 | if (rt < 0) { |
3755 | LOGE("Vpp_api_SetCMRegisterMap, error(%s)!\n", strerror(errno)); |
3756 | } |
3757 | |
3758 | return rt; |
3759 | } |
3760 | |
3761 | int CVpp::VPP_SetCMDebug(const unsigned long long *pLData) |
3762 | { |
3763 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_CM_DEBUG, pLData); |
3764 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetCMDebug##AMSTREAM_IOC_CM_DEBUG##"); |
3765 | |
3766 | if (rt < 0) { |
3767 | LOGE("=VPP CPP=> set cm debug, error (%s)", strerror(errno)); |
3768 | } |
3769 | |
3770 | return rt; |
3771 | } |
3772 | |
3773 | int CVpp::VPP_SetAVSyncEnable(const unsigned int enable) |
3774 | { |
3775 | int rt = VPP_DeviceIOCtl(AMSTREAM_IOC_SYNCENABLE, enable); |
3776 | LOGD("~~~VPP_DeviceIOCtl~~~##VPP_SetAVSyncEnable##AMSTREAM_IOC_SYNCENABLE##"); |
3777 | |
3778 | if (rt < 0) { |
3779 | LOGE("Vpp_api_SetAVSyncEnable, error(%s)!\n", strerror(errno)); |
3780 | } |
3781 | |
3782 | return rt; |
3783 | } |
3784 | int CVpp::VPP_SetScalerPathSel(const unsigned int value) |
3785 | { |
3786 | FILE *fp = NULL; |
3787 | |
3788 | fp = fopen("/sys/class/video/video_scaler_path_sel", "w"); |
3789 | LOGD("~~~fopen~~~##VPP_SetScalerPathSel##%s : %d ##", "/sys/class/video/video_scaler_path_sel", |
3790 | value); |
3791 | if (fp == NULL) { |
3792 | LOGE("Open /sys/class/video/video_scaler_path_sel error(%s)!\n", strerror(errno)); |
3793 | return -1; |
3794 | } |
3795 | fprintf(fp, "%d", value); |
3796 | fclose(fp); |
3797 | fp = NULL; |
3798 | return 0; |
3799 | } |
3800 |