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