idp_val.c
20.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* idp_val.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* The adaptation layer for video related legacy API functions.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by ClearCase. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Log$
*
* 12 05 2011 hung-wen.hsieh
* removed!
* .
*
* 10 12 2011 hung-wen.hsieh
* removed!
* .
*
* 09 30 2011 ct.fang
* removed!
* .
*
* 06 17 2011 chrono.wu
* removed!
* .
*
* 06 09 2011 peter.wang
* removed!
* .
*
* 05 24 2011 peter.wang
* removed!
* .
*
* 04 11 2011 ct.fang
* removed!
* .
*
* 04 07 2011 ct.fang
* removed!
* .
*
* 12 06 2010 cm.huang
* removed!
* .
*
* 11 23 2010 cm.huang
* removed!
* .
*
* 11 13 2010 cm.huang
* NULL
* .
*
* 08 10 2010 ct.fang
* removed!
* .
*
* 08 05 2010 ct.fang
* removed!
* .
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
* Fix build warnings
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
*
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by ClearCase. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#define THIS_FILE_BELONGS_TO_IMAGE_DATA_PATH_MODULE_INTERNAL
#include "drv_features_mdp.h"
#if defined(DRV_IDP_SUPPORT)
#include "kal_general_types.h"
#include "img_common_enum.h"
#include "idp_val.h"
#include "idp_video_decode.h"
/***************************************************
* Video Processing
***************************************************/
/***************************************************
* macro definitions
***************************************************/
#if defined(__MTK_TARGET__)
#if defined(DRV_IDP_MT6236_SERIES) \
|| defined(DRV_IDP_MT6276E2_SERIES) \
|| defined(DRV_IDP_6238_SERIES) \
|| defined(DRV_IDP_MT6255_SERIES) \
|| defined(DRV_IDP_MT6256_SERIES)
#define IDP_VAL_VP_API_IS_SUPPORTED
#endif
#endif
#if defined(DRV_IDP_6238_SERIES)
typedef struct
{
kal_uint32 clip_conv_disp_width;
kal_uint32 clip_conv_disp_height;
kal_uint32 clip_conv_clip_left;
kal_uint32 clip_conv_clip_right;
kal_uint32 clip_conv_clip_top;
kal_uint32 clip_conv_clip_bottom;
} CLIP_CONVERT_T;
static void
srcclip_2_dstclip_hori(img_rot_angle_enum_t const rot_angle,
kal_uint32 const src_width,
kal_uint32 const tar_width,
kal_uint32 const src_x1,
kal_uint32 const src_x2,
kal_uint32 * const dst_x1,
kal_uint32 * const dst_x2)
{
if (NULL == dst_x1)
{
ASSERT(0);
}
if (NULL == dst_x2)
{
ASSERT(0);
}
{
kal_uint32 const tar_x1 = ((src_x1 * tar_width) / src_width);
// [MAUI_01207646]
kal_uint32 const tar_x2 = (((src_x2 + 1) * tar_width) / src_width) - 1;
(*dst_x1) = tar_x1;
(*dst_x2) = tar_x2;
}
}
static void
srcclip_2_dstclip_vert(img_rot_angle_enum_t const rot_angle,
kal_uint32 const src_height,
kal_uint32 const tar_height,
kal_uint32 const src_y1,
kal_uint32 const src_y2,
kal_uint32 * const dst_y1,
kal_uint32 * const dst_y2)
{
if (NULL == dst_y1)
{
ASSERT(0);
}
if (NULL == dst_y2)
{
ASSERT(0);
}
{
kal_uint32 const tar_y1 = ((src_y1 * tar_height) / src_height);
// [MAUI_01207646]
kal_uint32 const tar_y2 = (((src_y2 + 1) * tar_height) / src_height) - 1;
(*dst_y1) = tar_y1;
(*dst_y2) = tar_y2;
}
}
/**
* @status OK
* @common none
*/
static kal_bool
_src_clip_to_dst_clip_convert(idp_val_vp_param_t* param,CLIP_CONVERT_T *prRender_Convert)
{
kal_uint32 dst_clip_x1;
kal_uint32 dst_clip_x2;
kal_uint32 dst_clip_y1;
kal_uint32 dst_clip_y2;
kal_uint32 video_src_width_with_dummy, video_src_height_with_dummy;
kal_uint32 video_target_width_with_dummy, video_target_height_with_dummy;
kal_uint32 video_target_width_wo_dummy, video_target_height_wo_dummy;
kal_uint32 real_video_display_width; /* The display target width after rotation */
kal_uint32 real_video_display_height; /* The display target height after rotation */
kal_uint32 real_video_clip_left; /* the clip_left after resizing and rotation. */
kal_uint32 real_video_clip_right; /* the clip_right after resizing and rotation. */
kal_uint32 real_video_clip_top; /* the clip_top after resizing and rotation. */
kal_uint32 real_video_clip_bottom; /* the clip_bottom after resizing and rotation. */
kal_uint32 const src_clip_width = param->src_clip_left - param->src_clip_right + 1;
kal_uint32 const src_clip_height= param->src_clip_bottom - param->src_clip_top + 1;
video_src_width_with_dummy = param->video_src_width;
video_src_height_with_dummy = param->video_src_height;
video_target_width_wo_dummy = param->dst_width;
video_target_height_wo_dummy = param->dst_height;
// [MAUI_01245490]
video_target_width_with_dummy = (((kal_uint32)(video_target_width_wo_dummy) *
(kal_uint32)(video_src_width_with_dummy) +
(kal_uint32)(src_clip_width) - 1) /
(kal_uint32)(src_clip_width));
video_target_height_with_dummy = (((kal_uint32)(video_target_height_wo_dummy) *
(kal_uint32)(video_src_height_with_dummy) +
(kal_uint32)(src_clip_height) - 1) /
(kal_uint32)(src_clip_height));
for (;;)
{
srcclip_2_dstclip_hori(param->rotation_angle,
video_src_width_with_dummy,
video_target_width_with_dummy,
param->src_clip_left,
param->src_clip_right,
&dst_clip_x1,
&dst_clip_x2);
if ((dst_clip_x2 - dst_clip_x1 + 1) < video_target_width_wo_dummy)
{
++video_target_width_with_dummy;
continue;
}
else if ((dst_clip_x2 - dst_clip_x1 + 1) > video_target_width_wo_dummy)
{
dst_clip_x2 = (dst_clip_x1 + video_target_width_wo_dummy - 1);
break;
}
else
{
break;
}
}
for (;;)
{
srcclip_2_dstclip_vert(param->rotation_angle,
video_src_height_with_dummy,
video_target_height_with_dummy,
param->src_clip_top,
param->src_clip_bottom,
&dst_clip_y1,
&dst_clip_y2);
if ((dst_clip_y2 - dst_clip_y1 + 1) < video_target_height_wo_dummy)
{
++video_target_height_with_dummy;
continue;
}
else if ((dst_clip_y2 - dst_clip_y1 + 1) > video_target_height_wo_dummy)
{
dst_clip_y2 = (dst_clip_y1 + video_target_height_wo_dummy - 1);
break;
}
else
{
break;
}
}
real_video_display_width = video_target_width_with_dummy;
real_video_display_height = video_target_height_with_dummy;
real_video_clip_left = dst_clip_x1;
real_video_clip_right = dst_clip_x2;
real_video_clip_top = dst_clip_y1;
real_video_clip_bottom = dst_clip_y2;
(*prRender_Convert).clip_conv_disp_width = real_video_display_width;
(*prRender_Convert).clip_conv_disp_height = real_video_display_height;
(*prRender_Convert).clip_conv_clip_left = real_video_clip_left;
(*prRender_Convert).clip_conv_clip_right = real_video_clip_right;
(*prRender_Convert).clip_conv_clip_top = real_video_clip_top;
(*prRender_Convert).clip_conv_clip_bottom = real_video_clip_bottom;
} // end of va2_vr_vp_6268_src_clip_to_dst_clip_convert
#endif //#if defined(DRV_IDP_6238_SERIES)
kal_bool
idp_val_vp_open(
kal_uint32 * const key)
{
#if defined(IDP_VAL_VP_API_IS_SUPPORTED)
#if defined(DRV_IDP_MT6256_E2_SERIES) && defined(MJPG_DECODE)
idp_video_decode_mjpg_mode_disable();
#endif
return idp_video_decode_open(key);
#else // #if defined(IDP_VAL_VP_API_IS_SUPPORTED)
return KAL_FALSE;
#endif // #if defined(IDP_VAL_VP_API_IS_SUPPORTED)
}
extern kal_bool
idp_val_vp_close(
kal_uint32 const key)
{
#if defined(IDP_VAL_VP_API_IS_SUPPORTED)
return idp_video_decode_close(key);
#else
return KAL_FALSE;
#endif
}
extern kal_bool
idp_val_vp_start(
kal_uint32 const key)
{
#if defined(IDP_VAL_VP_API_IS_SUPPORTED)
return idp_video_decode_start_all(key);
#else
return KAL_FALSE;
#endif
}
extern kal_bool
idp_val_vp_stop(
kal_uint32 const key)
{
#if defined(IDP_VAL_VP_API_IS_SUPPORTED)
return idp_video_decode_stop(key);
#else
return KAL_FALSE;
#endif
}
extern kal_bool
idp_val_vp_is_busy(
kal_uint32 const key,
kal_bool * const busy)
{
#if defined(IDP_VAL_VP_API_IS_SUPPORTED)
return idp_video_decode_is_busy(key, busy);
#else
return KAL_FALSE;
#endif
}
extern kal_bool
idp_val_vp_config(
kal_uint32 const key,
idp_val_vp_param_t* param)
{
#if defined(IDP_VAL_VP_API_IS_SUPPORTED)
#if defined(DRV_IDP_6238_SERIES)
CLIP_CONVERT_T idp_val_vp_Convert;
_src_clip_to_dst_clip_convert(param,&idp_val_vp_Convert);
#endif //#if defined(DRV_IDP_6238_SERIES)
return idp_video_decode_config(
key,
/* not in use */
IDP_VIDEO_DECODE_INTMEM_START_ADDRESS, 0,
IDP_VIDEO_DECODE_INTMEM_SIZE, 0,
#if defined(DRV_IDP_6238_SERIES)
IDP_VIDEO_DECODE_DC_TARGET_WIDTH, idp_val_vp_Convert.clip_conv_disp_width,
IDP_VIDEO_DECODE_DC_TARGET_HEIGHT, idp_val_vp_Convert.clip_conv_disp_height,
#endif //#if defined(DRV_IDP_6238_SERIES)
IDP_VIDEO_DECODE_EXTMEM_START_ADDRESS, param->ext_working_buffer_addr,
IDP_VIDEO_DECODE_EXTMEM_SIZE, param->ext_working_buffer_size,
IDP_VIDEO_DECODE_DONE_CB, param->frame_done_cb,
IDP_VIDEO_DECODE_DONE_CB_PARAM, param->frame_done_cb_param,
IDP_VIDEO_DECODE_SRC_WIDTH, param->video_src_width,
IDP_VIDEO_DECODE_SRC_HEIGHT, param->video_src_height,
/* not in use */
IDP_VIDEO_DECODE_TARGET_WIDTH_FOR_TVOUT, 0,
IDP_VIDEO_DECODE_TARGET_HEIGHT_FOR_TVOUT, 0,
#if defined(DRV_IDP_6238_SERIES)
IDP_VIDEO_DECODE_TARGET_WIDTH, idp_val_vp_Convert.clip_conv_disp_width,
IDP_VIDEO_DECODE_TARGET_HEIGHT, idp_val_vp_Convert.clip_conv_disp_height,
IDP_VIDEO_DECODE_ENABLE_CLIP, KAL_TRUE,
IDP_VIDEO_DECODE_CLIP_LEFT, idp_val_vp_Convert.clip_conv_clip_left,
IDP_VIDEO_DECODE_CLIP_RIGHT, idp_val_vp_Convert.clip_conv_clip_right,
IDP_VIDEO_DECODE_CLIP_TOP, idp_val_vp_Convert.clip_conv_clip_top,
IDP_VIDEO_DECODE_CLIP_BOTTOM, idp_val_vp_Convert.clip_conv_clip_bottom,
#else
IDP_VIDEO_DECODE_TARGET_WIDTH, param->dst_width,
IDP_VIDEO_DECODE_TARGET_HEIGHT, param->dst_height,
IDP_VIDEO_DECODE_ENABLE_CLIP, KAL_TRUE,
IDP_VIDEO_DECODE_CLIP_LEFT, param->src_clip_left,
IDP_VIDEO_DECODE_CLIP_RIGHT, param->src_clip_right,
IDP_VIDEO_DECODE_CLIP_TOP, param->src_clip_top,
IDP_VIDEO_DECODE_CLIP_BOTTOM, param->src_clip_bottom,
#endif // #if defined(DRV_IDP_6238_SERIES)
IDP_VIDEO_DECODE_CONTRAST_LEVEL, param->contrast_level, /**< should be 0x80 in normal cases. */
IDP_VIDEO_DECODE_BRIGHTNESS_LEVEL, param->brightness_level, /**< should be 0x80 in normal cases. */
IDP_VIDEO_DECODE_ROT_ANGLE, param->rotation_angle,
IDP_VIDEO_DECODE_IMAGE_DATA_FORMAT, param->dst_color_format, /**< most common is IMG_COLOR_FMT_RGB565 */
IDP_VIDEO_DECODE_ENABLE_PITCH, param->pitch_enable,
IDP_VIDEO_DECODE_BG_IMAGE_WIDTH, param->pitch_width,
IDP_VIDEO_DECODE_TRIGGER_LCD, KAL_FALSE,
IDP_VIDEO_DECODE_FORCE_LCD_HW_TRIGGER, KAL_FALSE,
/* not in use */
IDP_VIDEO_DECODE_SRC_FMT_4X4, KAL_FALSE,
IDP_VIDEO_DECODE_ENABLE_MP4DEBLK, KAL_FALSE,
IDP_VIDEO_DECODE_MP4DEBLK_QUANT_BUF, 0x0,
IDP_VIDEO_DECODE_RESIZER_U_VALUE, 8,
IDP_VIDEO_DECODE_RESIZER_V_VALUE, 15,
0);
#else // #if defined(IDP_VAL_VP_API_IS_SUPPORTED)
return KAL_FALSE;
#endif // #if defined(IDP_VAL_VP_API_IS_SUPPORTED)
}
extern kal_bool
idp_val_vp_config_src_buffer_addr(
kal_uint32 const key,
kal_uint32 addr0,
kal_uint32 addr1,
kal_uint32 addr2)
{
#if defined(IDP_VAL_VP_API_IS_SUPPORTED)
return idp_video_decode_config(
key,
IDP_VIDEO_DECODE_VIDEO_Y_BUFFER_ADDRESS, addr0,
IDP_VIDEO_DECODE_VIDEO_U_BUFFER_ADDRESS, addr1,
IDP_VIDEO_DECODE_VIDEO_V_BUFFER_ADDRESS, addr2,
0);
#else
return KAL_FALSE;
#endif
}
extern kal_bool
idp_val_vp_config_dst_buffer_addr(
kal_uint32 const key,
kal_uint32 addr0,
kal_uint32 addr1,
kal_uint32 addr2)
{
#if defined(IDP_VAL_VP_API_IS_SUPPORTED)
return idp_video_decode_config(
key,
#if defined(DRV_IDP_6238_SERIES)
IDP_VIDEO_DECODE_DC_RDMA_ADDR,addr0,
#endif //#if defined(DRV_IDP_6238_SERIES)
IDP_VIDEO_DECODE_FRAME_BUFFER_ADDRESS, addr0,
IDP_VIDEO_DECODE_FRAME_BUFFER_ADDRESS_2, addr0,
0);
#else
return KAL_FALSE;
#endif
}
static kal_bool
_idp_val_vp_sample_callback_func(void* param)
{
return KAL_TRUE;
}
void
idp_val_vp_sample_code(void)
{
kal_uint32 key;
idp_val_vp_param_t param;
kal_uint32 y_addr = 0, u_addr = 0, v_addr = 0;
kal_uint32 dst_fb_1 = 0;//, dst_fb_2;
if (KAL_FALSE == idp_val_vp_open(&key))
{
return; // Open fail, do error handling...
}
// For each video frame
{
kal_bool busy;
do
{
if (KAL_FALSE == idp_val_vp_is_busy(key, &busy))
{
return; // check busy fail, do error handling...
}
if (KAL_TRUE == busy)
{
// Do sleep like kal_sleep_task(1); for 4.615ms to yield CPU to other tasks.
}
else
{
break;
}
} while (1);
param.ext_working_buffer_addr = 0x0;
param.ext_working_buffer_size = 0x0;
param.video_src_width = 320;
param.video_src_height = 240;
param.src_color_format = IMG_COLOR_FMT_YUV420;
param.src_clip_left = 0;
param.src_clip_right = 319;
param.src_clip_top = 0;
param.src_clip_bottom = 239;
param.contrast_level = 0x80;
param.brightness_level = 0x80;
// Assume both MT6236/MT6276 EVB both use HVGA (480x320) LCM
param.dst_width = 426;
param.dst_height = 320;
// Destination clip is currently not supported, just ignore those or set them as no dst clipping
param.dst_clip_left = 0;
param.dst_clip_right = 425;
param.dst_clip_top = 0;
param.dst_clip_bottom = 319;
param.rotation_angle = IMG_ROT_ANGLE_90;
// Use RGB565 or UYVY, suggest to use UYVY on MT6236 since no HW spatial dithering is supported.
param.dst_color_format = IMG_COLOR_FMT_RGB565;
param.pitch_enable = KAL_FALSE;
param.pitch_width = 320; // Since the destinaation frame buffer is for rotated image, the pitch width should be 320 rather than 426.
param.frame_done_cb = _idp_val_vp_sample_callback_func; // Will be invoked in HISR once done...
param.frame_done_cb_param = NULL;
if (KAL_FALSE == idp_val_vp_config(key, ¶m))
{
return; // config error, do error handling...
}
// Please be careful the Y, U, V addresses cannot be cacheable, i.e., cannot be any address higher than 0xF000_0000.
// Please notice the addresses need to be format aligned...they cannot be odd number
if (KAL_FALSE == idp_val_vp_config_src_buffer_addr(key, y_addr, u_addr, v_addr))
{
return; // config error, do error handling...
}
// Do something to toggle dst double frame buffer switch.
// Assume to use color formats those have only single plane, such as RGB or UYVY packed format.
if (KAL_FALSE == idp_val_vp_config_dst_buffer_addr(key, dst_fb_1, 0, 0))
{
return;
}
}
// To stop video processing...
{
kal_bool busy;
do
{
if (KAL_FALSE == idp_val_vp_is_busy(key, &busy))
{
return; // check busy fail, do error handling...
}
if (KAL_TRUE == busy)
{
// Do sleep like kal_sleep_task(1); for 4.615ms to yield CPU to other tasks.
}
else
{
break;
}
} while (1);
}
// To close video processing to release resources...
if (KAL_FALSE == idp_val_vp_close(key))
{
return; // do error handling...
}
key = 0x0;
return;
}
#endif //#if defined(DRV_IDP_SUPPORT)