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