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