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