3 ** Copyright 2009 Samsung Electronics Co, Ltd.
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
9 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
21 #define LOG_TAG "SKIA"
22 #include <utils/Log.h>
26 #ifdef FIMG2D_USE_M2M1SHOT2
27 #include "videodev2.h"
28 #include <linux/m2m1shot2.h>
30 /* include freq leveling and compromise table */
31 #include "sec_g2d_comp.h"
32 unsigned int fmt_m2m1shot1_format
[] = {
38 unsigned int xfer_m2m1shot2_format
[] = {
39 M2M1SHOT2_BLEND_CLEAR
,
42 M2M1SHOT2_BLEND_SRCOVER
,
45 unsigned int filter_m2m1shot2_format
[] = {
46 M2M1SHOT2_SCFILTER_BILINEAR
,
47 M2M1SHOT2_SCFILTER_BILINEAR
,
50 unsigned int repeat_m2m1shot2_format
[] = {
51 M2M1SHOT2_REPEAT_CLAMP
,
52 M2M1SHOT2_REPEAT_REPEAT
,
53 M2M1SHOT2_REPEAT_REFLECT
,
54 M2M1SHOT2_REPEAT_NONE
,
58 pthread_mutex_t s_g2d_lock
= PTHREAD_MUTEX_INITIALIZER
;
60 struct blitinfo_table optbl
[] = {
61 { (int)BLIT_OP_NONE
, "NONE" },
62 { (int)BLIT_OP_SOLID_FILL
, "FILL" },
63 { (int)BLIT_OP_CLR
, "CLR" },
64 { (int)BLIT_OP_SRC
, "SRC" },
65 { (int)BLIT_OP_DST
, "DST" },
66 { (int)BLIT_OP_SRC_OVER
, "SRC_OVER" },
67 { (int)BLIT_OP_DST_OVER
, "DST_OVER" },
68 { (int)BLIT_OP_SRC_IN
, "SRC_IN" },
69 { (int)BLIT_OP_DST_IN
, "DST_IN" },
70 { (int)BLIT_OP_SRC_OUT
, "SRC_OUT" },
71 { (int)BLIT_OP_DST_OUT
, "DST_OUT" },
72 { (int)BLIT_OP_SRC_ATOP
, "SRC_ATOP" },
73 { (int)BLIT_OP_DST_ATOP
, "DST_ATOP" },
74 { (int)BLIT_OP_XOR
, "XOR" },
75 { (int)BLIT_OP_ADD
, "ADD" },
76 { (int)BLIT_OP_MULTIPLY
, "MULTIPLY" },
77 { (int)BLIT_OP_SCREEN
, "SCREEN" },
78 { (int)BLIT_OP_DARKEN
, "DARKEN" },
79 { (int)BLIT_OP_LIGHTEN
, "LIGHTEN" },
80 { (int)BLIT_OP_DISJ_SRC_OVER
, "DISJ_SRC_OVER" },
81 { (int)BLIT_OP_DISJ_DST_OVER
, "DISJ_DST_OVER" },
82 { (int)BLIT_OP_DISJ_SRC_IN
, "DISJ_SRC_IN" },
83 { (int)BLIT_OP_DISJ_DST_IN
, "DISJ_DST_IN" },
84 { (int)BLIT_OP_DISJ_SRC_OUT
, "DISJ_SRC_OUT" },
85 { (int)BLIT_OP_DISJ_DST_OUT
, "DISJ_DST_OUT" },
86 { (int)BLIT_OP_DISJ_SRC_ATOP
, "DISJ_SRC_ATOP" },
87 { (int)BLIT_OP_DISJ_DST_ATOP
, "DISJ_DST_ATOP" },
88 { (int)BLIT_OP_DISJ_XOR
, "DISJ_XOR" },
89 { (int)BLIT_OP_CONJ_SRC_OVER
, "CONJ_SRC_OVER" },
90 { (int)BLIT_OP_CONJ_DST_OVER
, "CONJ_DST_OVER" },
91 { (int)BLIT_OP_CONJ_SRC_IN
, "CONJ_SRC_IN" },
92 { (int)BLIT_OP_CONJ_DST_IN
, "CONJ_DST_IN" },
93 { (int)BLIT_OP_CONJ_SRC_OUT
, "CONJ_SRC_OUT" },
94 { (int)BLIT_OP_CONJ_DST_OUT
, "CONJ_DST_OUT" },
95 { (int)BLIT_OP_CONJ_SRC_ATOP
, "CONJ_SRC_ATOP" },
96 { (int)BLIT_OP_CONJ_DST_ATOP
, "CONJ_DST_ATOP" },
97 { (int)BLIT_OP_CONJ_XOR
, "CONJ_XOR" },
98 { (int)BLIT_OP_USER_COEFF
, "USER_COEFF" },
99 { (int)BLIT_OP_END
, "" },
102 struct blitinfo_table repeat_tbl
[] = {
103 { (int)NO_REPEAT
, "NON" },
104 { (int)REPEAT_NORMAL
, "DEFAULT" },
105 { (int)REPEAT_PAD
, "PAD" },
106 { (int)REPEAT_REFLECT
, "REFLECT, MIRROR" },
107 { (int)REPEAT_CLAMP
, "CLAMP" },
111 void VOID_FUNC(__attribute__((__unused__
)) const char *format
, ...)
117 m_flagCreate
= false;
122 if (m_flagCreate
== true)
123 PRINT("%s::this is not Destroyed fail\n", __func__
);
126 bool FimgApi::Create(void)
130 if (t_Lock() == false) {
131 PRINT("%s::t_Lock() fail\n", __func__
);
135 if (m_flagCreate
== true) {
136 PRINT("%s::Already Created fail\n", __func__
);
140 if (t_Create() == false) {
141 PRINT("%s::t_Create() fail\n", __func__
);
156 bool FimgApi::Destroy(void)
160 if (t_Lock() == false) {
161 PRINT("%s::t_Lock() fail\n", __func__
);
165 if (m_flagCreate
== false) {
166 PRINT("%s::Already Destroyed fail\n", __func__
);
170 if (t_Destroy() == false) {
171 PRINT("%s::t_Destroy() fail\n", __func__
);
175 m_flagCreate
= false;
185 #ifdef FIMG2D_USE_M2M1SHOT2
186 bool FimgApi::Stretch_v5(struct m2m1shot2
*cmd
)
190 if (t_Lock() == false) {
191 PRINT("%s::t_Lock() fail\n", __func__
);
195 if (m_flagCreate
== false) {
196 PRINT("%s::This is not Created fail\n", __func__
);
200 if (t_Stretch_v5(cmd
) == false) {
213 bool FimgApi::Stretch(struct fimg2d_blit
*cmd
)
217 if (t_Lock() == false) {
218 PRINT("%s::t_Lock() fail\n", __func__
);
222 if (m_flagCreate
== false) {
223 PRINT("%s::This is not Created fail\n", __func__
);
227 if (t_Stretch(cmd
) == false) {
240 bool FimgApi::Sync(void)
244 if (m_flagCreate
== false) {
245 PRINT("%s::This is not Created fail\n", __func__
);
249 if (t_Sync() == false)
259 bool FimgApi::t_Create(void)
261 PRINT("%s::This is empty virtual function fail\n", __func__
);
265 bool FimgApi::t_Destroy(void)
267 PRINT("%s::This is empty virtual function fail\n", __func__
);
271 bool FimgApi::t_Stretch(__attribute__((__unused__
)) struct fimg2d_blit
*cmd
)
273 PRINT("%s::This is empty virtual function fail\n", __func__
);
276 #ifdef FIMG2D_USE_M2M1SHOT2
277 bool FimgApi::t_Stretch_v5(__attribute__((__unused__
)) struct m2m1shot2
*cmd
)
279 PRINT("%s::This is empty virtual function fail\n", __func__
);
283 bool FimgApi::t_Sync(void)
285 PRINT("%s::This is empty virtual function fail\n", __func__
);
289 bool FimgApi::t_Lock(void)
291 PRINT("%s::This is empty virtual function fail\n", __func__
);
295 bool FimgApi::t_UnLock(void)
297 PRINT("%s::This is empty virtual function fail\n", __func__
);
301 //---------------------------------------------------------------------------//
303 //---------------------------------------------------------------------------//
304 extern "C" int stretchFimgApi(struct fimg2d_blit
*cmd
)
306 pthread_mutex_lock(&s_g2d_lock
);
308 FimgApi
* fimgApi
= createFimgApi();
310 if (fimgApi
== NULL
) {
311 PRINT("%s::createFimgApi() fail\n", __func__
);
312 pthread_mutex_unlock(&s_g2d_lock
);
316 if (fimgApi
->Stretch(cmd
) == false) {
318 destroyFimgApi(fimgApi
);
320 pthread_mutex_unlock(&s_g2d_lock
);
325 destroyFimgApi(fimgApi
);
327 pthread_mutex_unlock(&s_g2d_lock
);
331 extern "C" int SyncFimgApi(void)
333 pthread_mutex_lock(&s_g2d_lock
);
334 FimgApi
* fimgApi
= createFimgApi();
335 if (fimgApi
== NULL
) {
336 PRINT("%s::createFimgApi() fail\n", __func__
);
337 pthread_mutex_unlock(&s_g2d_lock
);
341 if (fimgApi
->Sync() == false) {
343 destroyFimgApi(fimgApi
);
345 pthread_mutex_unlock(&s_g2d_lock
);
350 destroyFimgApi(fimgApi
);
352 pthread_mutex_unlock(&s_g2d_lock
);
356 #ifdef FIMG2D_USE_M2M1SHOT2
357 extern "C" int stretchFimgApi_v5(struct m2m1shot2
*cmd
)
359 pthread_mutex_lock(&s_g2d_lock
);
361 FimgApi
* fimgApi
= createFimgApi();
363 if (fimgApi
== NULL
) {
364 PRINT("%s::createFimgApi() fail\n", __func__
);
365 pthread_mutex_unlock(&s_g2d_lock
);
369 if (fimgApi
->Stretch_v5(cmd
) == false) {
371 destroyFimgApi(fimgApi
);
373 pthread_mutex_unlock(&s_g2d_lock
);
378 destroyFimgApi(fimgApi
);
380 pthread_mutex_unlock(&s_g2d_lock
);
384 #ifdef FIMGAPI_HAL_FREQLEVELING
385 int FimgApiFreqleveling(Fimg
*fimg
)
387 static struct timeval prev
;
388 static int prev_level
= -1;
389 struct timeval current
;
390 unsigned int size
= (unsigned int)(fimg
->clipR
- fimg
->clipL
) *
391 (unsigned int)(fimg
->clipB
- fimg
->clipT
);
392 int result
= MIN_LEVEL
;
393 unsigned long time
= 0;
395 gettimeofday(¤t
, NULL
);
396 if ((current
.tv_sec
- prev
.tv_sec
) * 1000000 +
397 (current
.tv_usec
- prev
.tv_usec
) < 20000 && prev_level
!= -1) {
405 for (int i
= 0; i
< MIN_LEVEL
; i
++) {
406 if (fimg_standard_size
[i
] < size
)
412 #ifdef FIMGAPI_HAL_DEBUG
413 ALOGE("freq leveling : %d", result
);
419 #ifdef FIMGAPI_HAL_COMPROMISE
420 bool FimgApiCompromise(Fimg
*fimg
)
422 struct compromise_param param
;
424 /* source format setting*/
425 param
.src_fmt
= (fimg
->srcColorFormat
== 0)? 0 : 1;
426 param
.dst_fmt
= (fimg
->dstColorFormat
== 0)? 0 : 1;
428 /* scaling setting */
429 if (fimg
->srcW
== fimg
->dstW
&& fimg
->srcH
== fimg
->dstH
)
431 else if (fimg
->srcW
* fimg
->srcH
< fimg
->dstW
* fimg
->dstH
)
436 /* filter_mode setting */
437 param
.isFilter
= fimg
->isFilter
;
439 /* blending mode setting */
440 if (fimg
->xfermode
== 1)
442 else if (fimg
->xfermode
== 3)
447 param
.clipW
= (fimg
->clipR
- fimg
->clipL
) * 1.2;
448 param
.clipH
= (fimg
->clipB
- fimg
->clipT
) * 0.8;
449 #ifdef FIMGAPI_HAL_DEBUG
450 ALOGE("compromise [%d %d %d %d %d] [comp %d and %d]", param
.src_fmt
, param
.dst_fmt
,
451 param
.isScaling
, param
.isFilter
, param
.isSrcOver
, param
.clipW
* param
.clipH
,
452 comp_value
[param
.src_fmt
][param
.dst_fmt
][param
.isScaling
][param
.isFilter
][param
.isSrcOver
]);
455 if ((param
.clipW
* param
.clipH
) < comp_value
[param
.src_fmt
][param
.dst_fmt
][param
.isScaling
][param
.isFilter
][param
.isSrcOver
])
461 void printDataBlitImage_v5(struct m2m1shot2_image
* image
)
464 SLOGI("flags : %u", image
->flags
);
465 SLOGI("memory : %u", image
->memory
);
466 /* image.buffer : address and buffer size */
468 struct m2m1shot2_buffer
&buffer
= image
->plane
[0];
469 SLOGI("address %x", buffer
.userptr
);
470 SLOGI("length %u", buffer
.length
);
472 /* image.format : color format and coordinate */
473 struct m2m1shot2_format
&image_fmt
= image
->fmt
;
474 SLOGI("width : %u", image_fmt
.width
);
475 SLOGI("height: %u", image_fmt
.height
);
476 SLOGI("format: %u", image_fmt
.pixelformat
);
478 /* image.format : color format and coordinate */
479 SLOGI("crop : %d, %d (%u x %u)", image_fmt
.crop
.left
,
480 image_fmt
.crop
.top
, image_fmt
.crop
.width
, image_fmt
.crop
.height
);
481 SLOGI("widnow : %d, %d (%u x %u)", image_fmt
.window
.left
,
482 image_fmt
.window
.top
, image_fmt
.window
.width
, image_fmt
.window
.height
);
483 /* image.extra : parameter (only source image) */
484 struct m2m1shot2_extra
&extra
= image
->ext
;
485 SLOGI("scaler_filter : %u", extra
.scaler_filter
);
486 SLOGI("composite : %u",extra
.composit_mode
);
487 SLOGI("g_alpha : %u", extra
.galpha
);
488 SLOGI("repeat : %u", extra
.xrepeat
);
491 void printDataBlit_v5(const char *title
, int called
, struct m2m1shot2 cmd
)
493 SLOGI("%s (from %d)\n", title
, called
);
494 SLOGI("cmd flag %x", cmd
.flags
);
495 SLOGI("- - - - - - - destination - - - - - -");
496 printDataBlitImage_v5(&cmd
.target
);
497 SLOGI("- - - - - - - destination (source[0]-");
498 printDataBlitImage_v5(&cmd
.sources
[0]);
499 SLOGI("- - - - - - - source - - - - - - - - ");
500 printDataBlitImage_v5(&cmd
.sources
[1]);
503 void copy_m2m1shot2_image(struct m2m1shot2_image
*dst
, struct m2m1shot2_image
*src
)
505 /* initialize the image */
506 memset(dst
, 0, sizeof(struct m2m1shot2_image
));
509 dst
->flags
= src
->flags
;
510 dst
->fence
= src
->fence
;
511 dst
->memory
= src
->memory
;
512 dst
->num_planes
= src
->num_planes
;
514 /* image.buffer : address and buffer size */
515 struct m2m1shot2_buffer
&d_buffer
= dst
->plane
[0];
516 struct m2m1shot2_buffer
&s_buffer
= src
->plane
[0];
517 d_buffer
.userptr
= s_buffer
.userptr
;
518 d_buffer
.length
= s_buffer
.length
;
519 d_buffer
.offset
= s_buffer
.offset
;
521 /* image.format : color format and coordinate */
522 struct m2m1shot2_format
&d_format
= dst
->fmt
;
523 struct m2m1shot2_format
&s_format
= src
->fmt
;
524 d_format
.width
= s_format
.width
;
525 d_format
.height
= s_format
.height
;
526 d_format
.pixelformat
= s_format
.pixelformat
;
528 d_format
.crop
.left
= s_format
.crop
.left
;
529 d_format
.crop
.top
= s_format
.crop
.top
;
530 d_format
.crop
.width
= s_format
.crop
.width
;
531 d_format
.crop
.height
= s_format
.crop
.height
;
533 d_format
.window
.left
= s_format
.window
.left
;
534 d_format
.window
.top
= s_format
.window
.top
;
535 d_format
.window
.width
= s_format
.window
.width
;
536 d_format
.window
.height
= s_format
.window
.height
;
538 /* image.extra : parameter (only source image) */
539 struct m2m1shot2_extra
&d_extra
= dst
->ext
;
540 struct m2m1shot2_extra
&s_extra
= src
->ext
;
541 d_extra
.scaler_filter
= s_extra
.scaler_filter
;
542 d_extra
.fillcolor
= s_extra
.fillcolor
;
543 d_extra
.transform
= s_extra
.transform
;
544 d_extra
.composit_mode
= s_extra
.composit_mode
;
545 d_extra
.galpha_red
= d_extra
.galpha_green
=
546 d_extra
.galpha
= d_extra
.galpha_blue
= s_extra
.galpha
;
547 d_extra
.xrepeat
= s_extra
.xrepeat
;
548 d_extra
.yrepeat
= s_extra
.yrepeat
;
551 unsigned int scale_factor_to_fixed(float m
) {
552 unsigned int value
= m
* (1 << 16);
553 return value
& 0xFFFFFFFF;
556 int requestFimgApi_v5(Fimg
*fimg
)
558 struct m2m1shot2 cmd
;
560 #ifdef FIMGAPI_HAL_COMPROMISE
561 if (FimgApiCompromise(fimg
) == false)
564 #ifdef FIMGAPI_G2D_NEAREST_UNSUPPORT
565 if (fimg
->isFilter
== false)
568 /* initialize the command */
569 memset(&cmd
, 0, sizeof(cmd
));
570 cmd
.sources
= new m2m1shot2_image
[3];
573 struct m2m1shot2_image
&srcImage
= cmd
.sources
[1];
574 struct m2m1shot2_image
&dstImage
= cmd
.sources
[0];
576 cmd
.flags
= (fimg
->isDither
) & 0x1; /* dither | nonblock | error response */
578 /* initialize the image */
579 memset(&srcImage
, 0, sizeof(srcImage
));
580 memset(&dstImage
, 0, sizeof(dstImage
));
583 srcImage
.flags
= M2M1SHOT2_IMGFLAG_PREMUL_ALPHA
| M2M1SHOT2_IMGFLAG_GLOBAL_ALPHA
;
584 srcImage
.fence
= 0; /* no use */
585 srcImage
.memory
= M2M1SHOT2_BUFTYPE_USERPTR
;
586 srcImage
.num_planes
= 1;
588 /* image.buffer : address and buffer size */
589 struct m2m1shot2_buffer
&s_buffer
= srcImage
.plane
[0];
590 s_buffer
.userptr
= (unsigned long) fimg
->srcAddr
;
591 s_buffer
.length
= s_buffer
.payload
= fimg
->srcFH
* fimg
->srcFWStride
;
594 /* image.format : color format and coordinate */
595 struct m2m1shot2_format
&s_format
= srcImage
.fmt
;
596 s_format
.width
= fimg
->srcFWStride
/ fimg
->srcBPP
;
597 s_format
.height
= fimg
->srcFH
;
598 s_format
.pixelformat
= fmt_m2m1shot1_format
[fimg
->srcColorFormat
];
600 s_format
.crop
.left
= fimg
->srcX
;
601 s_format
.crop
.top
= fimg
->srcY
;
602 s_format
.crop
.width
= fimg
->srcW
;
603 s_format
.crop
.height
= fimg
->srcH
;
605 s_format
.window
.left
= fimg
->dstX
;
606 s_format
.window
.top
= fimg
->dstY
;
607 s_format
.window
.width
= fimg
->dstW
;
608 s_format
.window
.height
= fimg
->dstH
;
610 /* image.extra : parameter (only source image) */
611 struct m2m1shot2_extra
&s_extra
= srcImage
.ext
;
612 if (fimg
->matrixSw
!= 1.0f
|| fimg
->matrixSh
!= 1.0f
) {
613 /* caculate factor and enable factor */
614 /* or not, draw from source size to destination size */
615 s_extra
.scaler_filter
= M2M1SHOT2_SCFILTER_BILINEAR
;
616 /* set the scaling ratio */
617 float Sw
= 1.0f
/ fimg
->matrixSw
;
618 float Sh
= 1.0f
/ fimg
->matrixSh
;
619 s_extra
.horizontal_factor
= scale_factor_to_fixed(Sw
);
620 s_extra
.vertical_factor
= scale_factor_to_fixed(Sh
);
621 srcImage
.flags
|= M2M1SHOT2_IMGFLAG_XSCALE_FACTOR
;
622 srcImage
.flags
|= M2M1SHOT2_IMGFLAG_YSCALE_FACTOR
;
624 s_extra
.scaler_filter
= M2M1SHOT2_SCFILTER_NONE
;
625 cmd
.flags
|= M2M1SHOT2_IMGFLAG_NO_RESCALING
;
628 s_extra
.fillcolor
= fimg
->fillcolor
;
629 s_extra
.transform
= 0;
630 s_extra
.composit_mode
= xfer_m2m1shot2_format
[fimg
->xfermode
];
631 s_extra
.galpha_red
= s_extra
.galpha_green
=
632 s_extra
.galpha_blue
= s_extra
.galpha
= fimg
->alpha
;
633 s_extra
.xrepeat
= s_extra
.yrepeat
= repeat_m2m1shot2_format
[fimg
->tileModeX
];
636 dstImage
.flags
= M2M1SHOT2_IMGFLAG_PREMUL_ALPHA
;
638 dstImage
.memory
= M2M1SHOT2_BUFTYPE_USERPTR
;
639 dstImage
.num_planes
= 1;
641 /* image.buffer : address and buffer size */
642 struct m2m1shot2_buffer
&d_buffer
= dstImage
.plane
[0];
643 d_buffer
.userptr
= (unsigned long) fimg
->dstAddr
;
644 d_buffer
.length
= d_buffer
.payload
= fimg
->dstFH
* fimg
->dstFWStride
;
647 /* image.format : color format and coordinate */
648 struct m2m1shot2_format
&d_format
= dstImage
.fmt
;
649 d_format
.width
= fimg
->dstFWStride
/ fimg
->dstBPP
;
650 d_format
.height
= fimg
->dstFH
;
651 d_format
.pixelformat
= fmt_m2m1shot1_format
[fimg
->dstColorFormat
];
653 d_format
.crop
.left
= d_format
.window
.left
= fimg
->clipL
;
654 d_format
.crop
.top
= d_format
.window
.top
= fimg
->clipT
;
655 d_format
.crop
.width
= d_format
.window
.width
= fimg
->clipR
- fimg
->clipL
;
656 d_format
.crop
.height
= d_format
.window
.height
= fimg
->clipB
- fimg
->clipT
;
658 /* image.extra : parameter (only source image) */
659 struct m2m1shot2_extra
&d_extra
= dstImage
.ext
;
660 d_extra
.scaler_filter
= M2M1SHOT2_SCFILTER_NONE
;
661 d_extra
.fillcolor
= fimg
->fillcolor
;
662 d_extra
.transform
= 0;
663 d_extra
.composit_mode
= M2M1SHOT2_BLEND_NONE
;
664 d_extra
.galpha_red
= d_extra
.galpha_green
=
665 d_extra
.galpha
= d_extra
.galpha_blue
= 0x0;
666 d_extra
.xrepeat
= d_extra
.yrepeat
= M2M1SHOT2_REPEAT_NONE
;
668 copy_m2m1shot2_image(&cmd
.target
, &dstImage
);
669 /* src img[0] need to set xfermode::src for drawing dst */
670 d_extra
.composit_mode
= M2M1SHOT2_BLEND_SRC
;
672 /* freq supports 4 level as frequency and size*/
673 #ifdef FIMGAPI_HAL_FREQLEVELING
674 static int prev_level
[4];
675 static int level_count
= -1;
676 static int current_level
= 4;
679 level
= FimgApiFreqleveling(fimg
);
680 if (level_count
== -1) {
681 for (int i
= 0; i
< 4; i
++)
685 prev_level
[level_count
% 4] = level
;
687 fimg
->level
= prev_level
[0];
688 for (int i
= 1; i
< 4; i
++) {
689 if (prev_level
[i
] < fimg
->level
)
690 fimg
->level
= prev_level
[i
];
694 #ifdef FIMGAPI_HAL_DEBUG
695 printDataBlit_v5(__func__
, fimg
->called
, cmd
);
697 /* if it does not success, need to debug */
698 if (stretchFimgApi_v5(&cmd
) < 0) {
699 ALOGE("%s : g2d hardware operation failed", __func__
);
706 void printDataBlit(char *title
, const char *called
, struct fimg2d_blit
*cmd
)
708 struct fimg2d_image
*srcImage
;
709 struct fimg2d_image
*dstImage
;
710 struct fimg2d_param
*srcParam
;
711 srcImage
= cmd
->src
[1];
713 srcParam
= &srcImage
->param
;
715 SLOGI("%s (From %s)\n", title
, called
);
716 SLOGI(" sequence_no. = %u\n", cmd
->seq_no
);
717 SLOGI(" blit_op = %d(%s)\n", srcImage
->op
, optbl
[srcImage
->op
].str
);
718 SLOGI(" fill_color = %X\n", srcParam
->solid_color
);
719 SLOGI(" global_alpha = %u\n", (unsigned int)srcParam
->g_alpha
);
720 SLOGI(" PREMULT = %s\n", srcParam
->premult
== PREMULTIPLIED
? "PREMULTIPLIED" : "NON-PREMULTIPLIED");
721 SLOGI(" do_dither = %s\n", cmd
->dither
== true ? "dither" : "no-dither");
722 SLOGI(" repeat = %d(%s)\n", srcParam
->repeat
.mode
,
723 repeat_tbl
[srcParam
->repeat
.mode
].str
);
725 printDataBlitRotate(srcParam
->rotate
);
727 printDataBlitScale(&srcParam
->scaling
);
729 printDataBlitImage("SRC", srcImage
);
730 printDataBlitImage("DST", dstImage
);
732 if (srcImage
!= NULL
)
733 printDataBlitRect("SRC", &srcImage
->rect
);
734 if (srcParam
!= NULL
)
735 printDataBlitRect("SRC_CLIP(same as DST)", &srcParam
->clipping
);
736 if (dstImage
!= NULL
)
737 printDataBlitRect("DST_CLIP", &dstImage
->rect
);
740 void printDataBlitImage(const char *title
, struct fimg2d_image
*image
)
743 SLOGI(" Image_%s\n", title
);
744 SLOGI(" addr = %lx\n", image
->addr
.start
);
745 SLOGI(" format = %s\n", image
->fmt
== 0 ? "ARGB_8888" : "RGB_565");
746 SLOGI(" size = (%d, %d)\n", image
->width
, image
->height
);
748 SLOGI(" Image_%s : NULL\n", title
);
752 void printDataBlitRect(const char *title
, struct fimg2d_clip
*clipping
)
754 if (NULL
!= clipping
&& clipping
->enable
== 1) {
755 SLOGI(" RECT_%s\n", title
);
756 SLOGI(" (x1, y1) = (%d, %d)\n", clipping
->x1
, clipping
->y1
);
757 SLOGI(" (x2, y2) = (%d, %d)\n", clipping
->x2
, clipping
->y2
);
758 SLOGI(" (width, height) = (%d, %d)\n", clipping
->x2
- clipping
->x1
, clipping
->y2
- clipping
->y1
);
760 SLOGI(" RECT_%s : NULL\n", title
);
764 void printDataBlitRect(const char *title
, struct fimg2d_rect
*rect
)
767 SLOGI(" RECT_%s\n", title
);
768 SLOGI(" (x1, y1) = (%d, %d)\n", rect
->x1
, rect
->y1
);
769 SLOGI(" (x2, y2) = (%d, %d)\n", rect
->x2
, rect
->y2
);
770 SLOGI(" (width, height) = (%d, %d)\n", rect
->x2
- rect
->x1
, rect
->y2
- rect
->y1
);
772 SLOGI(" RECT_%s : NULL\n", title
);
776 void printDataBlitRotate(int rotate
)
778 SLOGI(" ROTATE : %d\n", rotate
);
781 void printDataBlitScale(struct fimg2d_scale
*scaling
)
784 if (scaling
->mode
!= 0) {
785 SLOGI(" scale_mode : %s\n",
786 (scaling
->mode
== 1 ? "SCALING_BILINEAR" : "NO_SCALING"));
787 SLOGI(" src : (src_w, src_h) = (%d, %d)\n", scaling
->src_w
, scaling
->src_h
);
788 SLOGI(" dst : (dst_w, dst_h) = (%d, %d)\n", scaling
->dst_w
, scaling
->dst_h
);
789 SLOGI(" scaling_factor : (scale_w, scale_y) = (%3.2f, %3.2f)\n", (double)scaling
->dst_w
/ scaling
->src_w
, (double)scaling
->dst_h
/ scaling
->src_h
);
791 SLOGI(" scale_mode : NO_SCALING\n");