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