idp_scen_common_mt6252.c
22.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
/*****************************************************************************
* 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_scen_common_mt6252.c
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
*
* Extract common port of vr, ic, pv scen for code shrinking.
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by ClearCase. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Log$
*
* 02 18 2014 chrono.wu
* removed!
* .
*
* 01 21 2014 chrono.wu
* removed!
* .
*
* 03 25 2013 chrono.wu
* removed!
* MT6260 WVGA Camera features support full screen.
*
* 12 13 2012 peter.wang
* removed!
* .
*
* 09 24 2012 peter.wang
* removed!
* .
*
* 09 11 2012 peter.wang
* removed!
* .
*
* 06 12 2012 peter.wang
* removed!
* .
*
* 05 25 2012 peter.wang
* removed!
* .
*
* 04 18 2012 peter.wang
* removed!
* .
*
* 02 24 2012 peter.wang
* removed!
* .
*
* 02 19 2012 peter.wang
* removed!
* .
*
* 02 15 2012 peter.wang
* removed!
* .
*
* 12 16 2011 peter.wang
* removed!
* .
*
* 09 15 2011 peter.wang
* removed!
* .
*
* 05 17 2011 peter.wang
* removed!
* .
*
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by ClearCase. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/****************************************************************************
* macros and options
****************************************************************************/
#define THIS_FILE_BELONGS_TO_IMAGE_DATA_PATH_MODULE_INTERNAL
/****************************************************************************
* include directives
****************************************************************************/
#include "drv_comm.h"
#if defined(DRV_IDP_6252_SERIES)
#include <mt6252/idp_engines.h>
#include <idp_cam_if.h>
#include <idp_camera_preview.h>
#include <mt6252/idp_scen_common_mt6252.h>
/****************************************************************************
* external symbols
****************************************************************************/
/****************************************************************************
* local typedef
****************************************************************************/
/****************************************************************************
* common variables
****************************************************************************/
// this flag is used to indicate whether MDP triple display buffer is enabled or not
#if defined(MDP_SUPPORT_CP_TRIPLE_DISPLAY_BUFFER)
kal_bool _idp_scen_triple_display_buffer_enable = KAL_FALSE;
kal_uint32 _idp_scen_display_buffer_addr[3];
kal_uint32 _idp_scen_display_buffer_cnt = 0;
#endif
// this buffer used for delay one frame trigger LCD display
#if defined(__ATV_SUPPORT__)
kal_uint32 completed_display_buffer_count = 0;
#endif
#if defined(IDP_MM_COLOR_SUPPORT)
COLOR_HANDLE mm_color_handle;
#endif
/****************************************************************************
* Callback function bodies
****************************************************************************/
#if defined(MDP_SUPPORT_CP_TRIPLE_DISPLAY_BUFFER)
kal_bool idp_scen_acquire_write_buffer(void)
{
CAL_CALLBACK_ID_ENUM eCBID;
if (KAL_TRUE == _idp_scen_triple_display_buffer_enable)
{
CAL_BUFFER_CB_STRUCT rFrmDoneCBArg;
// enable acquire next buffer process only
rFrmDoneCBArg.EnableReleaseWriteBuffer= KAL_FALSE;
rFrmDoneCBArg.EnableAcquireWriteBuffer= KAL_TRUE;
// current preview and video encode frame done do the same thing in cal_cb
// maybe different if design change
// now only preview have triple buffer.
if (1)
{
eCBID = IDPCAL_CBID_CAM_PREVIEW_DISPLAY_FRM_DONE;
}
else
{
eCBID = IDPCAL_CBID_VIDEO_ENCODE_PREVIEW_DISPLAY_FRM_DONE;
}
pfIDP_CAL_CB(eCBID , &rFrmDoneCBArg, sizeof(CAL_BUFFER_CB_STRUCT));
// record next buffer address for triple display buffer
if (NULL != rFrmDoneCBArg.NextFrameBufferAddr)
{
if (_idp_scen_display_buffer_cnt < 3) // mdp only hold 1 or 2
{
_idp_scen_display_buffer_addr[_idp_scen_display_buffer_cnt] = rFrmDoneCBArg.NextFrameBufferAddr;
_idp_scen_display_buffer_cnt++;
}
}
}
return KAL_TRUE;
}
#endif
/****************************************************************************
* common function bodies
****************************************************************************/
kal_bool
idp_common_open_hook(
idp_owner_t * const owner)
{
#if defined(__MTK_TARGET__)
kal_bool result;
// open crz
result = idp_resz_crz_open(&(owner->crz_key));
if (KAL_FALSE == result)
{
return KAL_FALSE;
}
//owner->have_config_resz_crz = KAL_FALSE;
kal_mem_set(&crz_struct, 0x0, sizeof(idp_resz_crz_struct));
// open rotdma0
result = idp_imgdma_rotdma0_open(&(owner->irt0_key));
if (KAL_FALSE == result)
{
return KAL_FALSE;
}
owner->have_config_imgdma_irt0 = KAL_FALSE;
kal_mem_set(&rotdma0_struct, 0x0, sizeof(idp_imgdma_rotdma0_struct));
#endif
return KAL_TRUE;
}
kal_bool
idp_common_stop_hook(
idp_owner_t * const owner)
{
#if defined(__MTK_TARGET__)
idp_resz_crz_stop(owner->crz_key, &crz_struct);
idp_imgdma_rotdma0_stop(owner->irt0_key, &rotdma0_struct);
#endif
return KAL_TRUE;
}
kal_bool
idp_common_start_input_hook(
idp_owner_t * const owner)
{
#if defined(__MTK_TARGET__)
idp_resz_crz_start(owner->crz_key, &crz_struct);
#endif
return KAL_TRUE;
}
kal_bool
idp_common_start_output_hook(
idp_owner_t * const owner)
{
#if defined(__MTK_TARGET__)
idp_imgdma_rotdma0_start(owner->irt0_key, &rotdma0_struct);
#endif
return KAL_TRUE;
}
kal_bool
idp_common_is_busy_hook(
idp_owner_t const * const owner,
kal_bool * const busy)
{
#if defined(__MTK_TARGET__)
idp_imgdma_rotdma0_is_busy(owner->irt0_key, busy, &rotdma0_struct);
if (KAL_TRUE == (*busy))
{
return KAL_TRUE;
}
idp_resz_crz_is_busy(owner->crz_key, busy, &crz_struct);
#endif
return KAL_TRUE;
}
kal_bool
idp_common_is_in_use_hook(void)
{
#if defined(__MTK_TARGET__)
if (KAL_TRUE == idp_resz_crz_is_in_use())
{
return KAL_TRUE;
}
if (KAL_TRUE == idp_imgdma_rotdma0_is_in_use())
{
return KAL_TRUE;
}
#endif
return KAL_FALSE;
}
kal_bool
idp_common_query_hook(
idp_owner_t * const owner,
va_list ap)
{
kal_uint32 para_type;
kal_bool finish = KAL_FALSE;
IDP_CAL_QUERY_TYPE_T eTypeTmp = IDP_CAL_QUERY_PATH_SUPPORT;
img_rot_angle_enum_t eDesiredAngleTmp = IMG_ROT_ANGLE_0;
while (KAL_FALSE == finish)
{
para_type = va_arg(ap, kal_uint32);
switch (para_type)
{
case 0:
finish = KAL_TRUE;
break;
case IDP_CAMERA_PREVIEW_QUERY_TYPE:
//case IDP_CAMERA_CAPTURE_TO_JPEG_QUERY_TYPE:
//case IDP_VIDEO_ENCODE_QUERY_TYPE:
eTypeTmp = (IDP_CAL_QUERY_TYPE_T) va_arg(ap, kal_uint32);
break;
case IDP_CAMERA_PREVIEW_QUERY_ARG_PATH:
//case IDP_CAMERA_CAPTURE_TO_JPEG_QUERY_ARG_PATH:
//case IDP_VIDEO_ENCODE_QUERY_ARG_PATH:
case IDP_CAMERA_PREVIEW_QUERY_ARG_CLR_FMT:
//case IDP_CAMERA_CAPTURE_TO_JPEG_QUERY_ARG_CLR_FMT:
//case IDP_VIDEO_ENCODE_QUERY_ARG_CLR_FMT:
va_arg(ap, kal_uint32);
break;
case IDP_CAMERA_PREVIEW_QUERY_ARG_DESIRED_ANGLE:
//case IDP_CAMERA_CAPTURE_TO_JPEG_QUERY_ARG_DESIRED_ANGLE:
//case IDP_VIDEO_ENCODE_QUERY_ARG_DESIRED_ANGLE:
eDesiredAngleTmp = (img_rot_angle_enum_t) va_arg(ap, kal_uint32);
break;
case IDP_CAMERA_PREVIEW_QUERY_RESULT:
//case IDP_CAMERA_CAPTURE_TO_JPEG_QUERY_RESULT:
//case IDP_VIDEO_ENCODE_QUERY_RESULT:
{
kal_uint32 * const pu4Result = va_arg(ap, kal_uint32*);
if (eTypeTmp == IDP_CAL_QUERY_PATH_SUPPORT)
{
#if defined(MT6252H) || defined(MT6252)
//MT6252 MDP hardware only supports display path, main image path
(*pu4Result) = (kal_uint32) KAL_FALSE;
#elif defined(MT6250) || defined(MT6260) || defined(MT6261)
//MT6250 MDP need pp path
(*pu4Result) = (kal_uint32) KAL_TRUE;
#endif
}
else if (eTypeTmp == IDP_CAL_QUERY_ROT_CAP)
{
// 90, 270, MT6252 display rotator only supports rotation CC 90 with mirror
(*pu4Result) = ((eDesiredAngleTmp & 0x01 == 0x01) ? (kal_uint32) IMG_MIRROR_ROT_ANGLE_90 : (kal_uint32) IMG_ROT_ANGLE_0);
}
#if defined(MDP_SUPPORT_CP_TRIPLE_DISPLAY_BUFFER)
else if (eTypeTmp == IDP_CAL_QUERY_FRAME_DONE_CB_FUNC)
{
(*pu4Result) = (kal_uint32)idp_scen_acquire_write_buffer;
}
#endif
}
break;
default:
return KAL_FALSE;
}
}
return KAL_TRUE;
}
kal_bool
idp_dummy_hook(
idp_owner_t * const owner)
{
return KAL_TRUE;
}
void
idp_dummy_hook2(
idp_owner_t * const owner)
{
}
kal_bool
idp_dummy_hook3(void)
{
return KAL_TRUE;
}
void idp_config_crz_crop(
kal_uint16 image_src_width,
kal_uint16 image_src_height,
kal_uint16 crop_width,
kal_uint16 crop_height)
{
crz_struct.crop_left1 = (image_src_width - crop_width) >> 1;
crz_struct.crop_right1 = crz_struct.crop_left1 + (crop_width - 1);
crz_struct.crop_top1 = (image_src_height - crop_height) >> 1;
crz_struct.crop_bottom1 = crz_struct.crop_top1 + (crop_height - 1);
}
#if defined(IDP_TILE_MODE_SUPPORT)
// Tile mode related function
static kal_uint32 gcd(kal_uint32 m, kal_uint32 n)
{
kal_uint32 r;
while (n != 0)
{
r = m % n;
m = n;
n = r;
}
return m;
}
void
idp_bi_tile_calc(
kal_uint32 src_w, kal_uint32 src_h,
kal_uint32 tar_w, kal_uint32 tar_h,
tile_calc_para *tile_result)
{
kal_uint32 in_ratio, in_resid;
kal_uint32 round_step;
kal_uint32 curr_tile_first_idx, curr_tile_last_idx;
kal_uint32 prev_last_round_idx, prev_tile_last_idx;
kal_uint32 tar_tile_size;
kal_uint32 curr_last_round_idx;
// Compute the ratio and resid
in_ratio = (src_w << 20) / tar_w;
in_resid = src_w % tar_w;
// Set tile is target witdh / 2
tar_tile_size = tar_w / 2;
// Compute the rounding step, every rounding step will have src pixel = tar pixel
// Ex. 10 -> 15, GCD = 5, 15/3 = 5, every 3 pixel(tar) meat 2 pixel(src)
// 0, 2/3, 4/3, 6/3, 8/3, 10/3, 12/3, 14/3, 16/3, 18/3, 20/3, 22/3, 24/3, 26/3, 28/3
// [tar/GCD(src,tar)]
round_step = tar_w / gcd(src_w, tar_w);
/*********************************************************************
* Tile #0 Setting.
*********************************************************************/
// Compute the last output rounding index of the current tile
curr_tile_first_idx = 0;
curr_tile_last_idx = tar_tile_size - 1;
// A0 = {O0/[tar/GCD(src,tar)]} * [tar/GCD(src,tar)]
curr_last_round_idx = (curr_tile_last_idx/round_step) * round_step;
// Left source index = 0
tile_result->tile_bi_sa_src_start_pos[0] = 0;
if (src_w != tar_w)
{
// Right source index = {[(O0-A0) * Ratio] >> 20} + [(src*A0)/tar] + 1
tile_result->tile_bi_sa_src_end_pos[0] = (kal_uint32)((((curr_tile_last_idx-curr_last_round_idx) * in_ratio) >> 20) +
((src_w*curr_last_round_idx)/tar_w) +
1);
}
else
{
// Right source index = {[(O0-A0) * Ratio] >> 20} + [(src*A0)/tar]
tile_result->tile_bi_sa_src_end_pos[0] = (kal_uint32)((((curr_tile_last_idx-curr_last_round_idx) * in_ratio) >> 20) +
((src_w*curr_last_round_idx)/tar_w));
}
if (tile_result->tile_bi_sa_src_end_pos[0] >= src_w)
{
tile_result->tile_bi_sa_src_end_pos[0] = src_w - 1;
}
tile_result->tile_adj_src_start_pos[0] = tile_result->tile_bi_sa_src_start_pos[0] & 0xFFFFFFFE;
tile_result->tile_adj_src_end_pos[0] = tile_result->tile_bi_sa_src_end_pos[0] | 0x00000001;
tile_result->tile_src_size_x[0] = tile_result->tile_adj_src_end_pos[0] - tile_result->tile_adj_src_start_pos[0] + 1;
tile_result->tile_start_pos_x[0] = 0;
tile_result->tile_init_resid_x[0] = 0;
tile_result->tile_trunc_err_comp_x[0] = tar_w;
tile_result->tile_start_pos_y[0] = 0;
tile_result->tile_trunc_err_comp_y[0] = tar_h;
tile_result->tile_init_resid_y[0] = 0;
/*********************************************************************
* Tile #1 Setting.
*********************************************************************/
prev_last_round_idx = curr_last_round_idx;
prev_tile_last_idx = curr_tile_last_idx;
curr_tile_first_idx += tar_tile_size;
curr_tile_last_idx += tar_tile_size;
// {A1 = {O1/[tar/GCD(src,tar)]} * [tar/GCD(src,tar)]
curr_last_round_idx = (curr_tile_last_idx/round_step) * round_step;
// Compute tile parameters
if (curr_tile_first_idx == (prev_last_round_idx + round_step)) // Of1 == A0 + [tar/GCD(src,tar)]
{
// Left source index = (src*Of1) / tar
tile_result->tile_bi_sa_src_start_pos[1] = (src_w*curr_tile_first_idx) / tar_w;
if (src_w != tar_w)
{
// Right source index = {[(O1-A1) * Ratio] >> 20} + [(src¡ÑA1)/tar] + 1
tile_result->tile_bi_sa_src_end_pos[1] = (kal_uint32)((((curr_tile_last_idx-curr_last_round_idx) * in_ratio) >> 20) +
((src_w*curr_last_round_idx)/tar_w) +
1);
}
else
{
// Right source index = {[(O1-A1) * Ratio] >> 20} + [(src¡ÑA1)/tar]
tile_result->tile_bi_sa_src_end_pos[1] = (kal_uint32)((((curr_tile_last_idx-curr_last_round_idx) * in_ratio) >> 20) +
((src_w*curr_last_round_idx)/tar_w));
}
tile_result->tile_start_pos_x[1] = 0;
tile_result->tile_init_resid_x[1] = 0;
}
else
{
// Left source index = {[(O0+1-A0) * Ratio] >> 20} + [(src * A0 )/tar]
tile_result->tile_bi_sa_src_start_pos[1] = (kal_uint32)((((prev_tile_last_idx+1-prev_last_round_idx) * in_ratio) >> 20) +
((src_w*prev_last_round_idx)/tar_w));
// Left source index = {[(O1-A1) * Ratio] >> 20} + [(src * A1 )/tar] + 1
tile_result->tile_bi_sa_src_end_pos[1] = (kal_uint32)((((curr_tile_last_idx-curr_last_round_idx) * in_ratio) >> 20) +
((src_w*curr_last_round_idx)/tar_w) +
1);
// Start position = [(O0+1-A0) * Ratio] & 0x000FFFFF
tile_result->tile_start_pos_x[1] = ((prev_tile_last_idx+1-prev_last_round_idx) * in_ratio) & 0x000FFFFF;
// Initial residual = [(O0+1-A0) * Residual] % tar
tile_result->tile_init_resid_x[1] = ((prev_tile_last_idx+1-prev_last_round_idx) * in_resid) % tar_w;
}
if (tile_result->tile_bi_sa_src_end_pos[1] >= src_w)
{
tile_result->tile_bi_sa_src_end_pos[1] = src_w - 1;
}
tile_result->tile_adj_src_start_pos[1] = tile_result->tile_bi_sa_src_start_pos[1] & 0xFFFFFFFE;
tile_result->tile_adj_src_end_pos[1] = tile_result->tile_bi_sa_src_end_pos[1] | 0x00000001;
tile_result->tile_src_size_x[1] = tile_result->tile_adj_src_end_pos[1] - tile_result->tile_adj_src_start_pos[1] + 1;
tile_result->tile_trunc_err_comp_x[1] = tar_w;
tile_result->tile_start_pos_y[1] = 0;
tile_result->tile_trunc_err_comp_y[1] = tar_h;
tile_result->tile_init_resid_y[1] = 0;
}
void
idp_sa_tile_calc(
kal_uint32 src_w, kal_uint32 src_h,
kal_uint32 tar_w, kal_uint32 tar_h,
tile_calc_para *tile_result)
{
kal_uint32 in_ratio, in_ratio_y;
kal_uint32 curr_tile_last_idx;
kal_uint32 prev_tile_remain_weight;
kal_uint32 tar_tile_size;
// Compute the ratio
in_ratio = ((kal_uint32)(tar_w-1)<<20)/(src_w-1);
in_ratio_y = ((kal_uint32)(tar_h-1)<<20)/(src_h-1);
// Set tile is target witdh / 2
tar_tile_size = tar_w / 2;
/*********************************************************************
* Tile #0 Setting.
*********************************************************************/
curr_tile_last_idx = tar_tile_size - 1;
// Compute tile parameters
tile_result->tile_bi_sa_src_start_pos[0] = 0;
// {{[2*(O0+1)-1]<<20} + 3*Ratio-1}/(2*Ratio) - 1;
tile_result->tile_bi_sa_src_end_pos[0] = (kal_uint32)(((((((curr_tile_last_idx+1)<<1)-1)<<20)+(in_ratio*3)-1)/(in_ratio<<1)) - 1);
// [(1<<20)+Ratio] / 2
tile_result->tile_sa_init_weight[0] = (kal_uint32)(((1<<20) + in_ratio) >> 1);
tile_result->tile_adj_src_start_pos[0] = tile_result->tile_bi_sa_src_start_pos[0] & 0xFFFFFFFE;
tile_result->tile_adj_src_end_pos[0] = tile_result->tile_bi_sa_src_end_pos[0] | 0x00000001;
tile_result->tile_src_size_x[0] = tile_result->tile_adj_src_end_pos[0] - tile_result->tile_adj_src_start_pos[0] + 1;
tile_result->tile_start_pos_x[0] = tile_result->tile_sa_init_weight[0];
tile_result->tile_start_pos_y[0] = (kal_uint32)(((1<<20) + in_ratio_y) >> 1);
tile_result->tile_trunc_err_comp_x[0] = 0;
tile_result->tile_trunc_err_comp_y[0] = 0;
tile_result->tile_init_resid_x[0] = 0;
tile_result->tile_init_resid_y[0] = 0;
/*********************************************************************
* Tile #1 Setting.
*********************************************************************/
curr_tile_last_idx += tar_tile_size;
// Compute the remaining weight of the previous tile
// B1 = IW0 + [Ratio * (R0-L0)] - [(O0-Of0+1) << 20]
prev_tile_remain_weight = tile_result->tile_sa_init_weight[0] +
(in_ratio * (tile_result->tile_bi_sa_src_end_pos[0]-tile_result->tile_bi_sa_src_start_pos[0])) -
(tar_tile_size << 20);
if (prev_tile_remain_weight == 0)
{
tile_result->tile_bi_sa_src_start_pos[1] = tile_result->tile_bi_sa_src_end_pos[0] + 1;
tile_result->tile_bi_sa_src_end_pos[1] = src_w - 1;
tile_result->tile_sa_init_weight[1] = in_ratio;
}
else
{
tile_result->tile_bi_sa_src_start_pos[1] = tile_result->tile_bi_sa_src_end_pos[0];
tile_result->tile_bi_sa_src_end_pos[1] = src_w - 1;
tile_result->tile_sa_init_weight[1] = (kal_uint32) prev_tile_remain_weight;
}
tile_result->tile_adj_src_start_pos[1] = tile_result->tile_bi_sa_src_start_pos[1] & 0xFFFFFFFE;
tile_result->tile_adj_src_end_pos[1] = tile_result->tile_bi_sa_src_end_pos[1] | 0x00000001;
tile_result->tile_src_size_x[1] = tile_result->tile_adj_src_end_pos[1] - tile_result->tile_adj_src_start_pos[1] + 1;
tile_result->tile_start_pos_x[1] = tile_result->tile_sa_init_weight[1];
tile_result->tile_start_pos_y[1] = (kal_uint32)(((1<<20) + in_ratio_y) >> 1);
tile_result->tile_trunc_err_comp_x[1] = 0;
tile_result->tile_trunc_err_comp_y[1] = 0;
tile_result->tile_init_resid_x[1] = 0;
tile_result->tile_init_resid_y[1] = 0;
}
#endif
#endif // #if defined(DRV_IDP_6252_SERIES)