Loading...
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 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 | /* drivers/video/msm/src/drv/mdp/mdp_ppp.c
*
* Copyright (C) 2007 Google Incorporated
* Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/time.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/fb.h>
#include <msm_mdp.h>
#include <linux/file.h>
#include <linux/major.h>
#include "linux/proc_fs.h"
#include <mach/hardware.h>
#include <linux/io.h>
#include <asm/system.h>
#include <asm/mach-types.h>
#include <linux/semaphore.h>
#include "mdp.h"
#include "msm_fb.h"
#define MDP_IS_IMGTYPE_BAD(x) (((x) >= MDP_IMGTYPE_LIMIT) && \
(((x) < MDP_IMGTYPE2_START) || \
((x) >= MDP_IMGTYPE_LIMIT2)))
static uint32_t bytes_per_pixel[] = {
[MDP_RGB_565] = 2,
[MDP_RGB_888] = 3,
[MDP_XRGB_8888] = 4,
[MDP_ARGB_8888] = 4,
[MDP_RGBA_8888] = 4,
[MDP_BGRA_8888] = 4,
[MDP_Y_CBCR_H2V1] = 1,
[MDP_Y_CBCR_H2V2] = 1,
[MDP_Y_CRCB_H2V1] = 1,
[MDP_Y_CRCB_H2V2] = 1,
[MDP_YCRYCB_H2V1] = 2,
[MDP_BGR_565] = 2
};
extern uint32 mdp_plv[];
extern struct semaphore mdp_ppp_mutex;
uint32_t mdp_get_bytes_per_pixel(uint32_t format)
{
uint32_t bpp = 0;
if (format < ARRAY_SIZE(bytes_per_pixel))
bpp = bytes_per_pixel[format];
BUG_ON(!bpp);
return bpp;
}
static uint32 mdp_conv_matx_rgb2yuv(uint32 input_pixel,
uint16 *matrix_and_bias_vector,
uint32 *clamp_vector,
uint32 *look_up_table)
{
uint8 input_C2, input_C0, input_C1;
uint32 output;
int32 comp_C2, comp_C1, comp_C0, temp;
int32 temp1, temp2, temp3;
int32 matrix[9];
int32 bias_vector[3];
int32 Y_low_limit, Y_high_limit, C_low_limit, C_high_limit;
int32 i;
uint32 _is_lookup_table_enabled;
input_C2 = (input_pixel >> 16) & 0xFF;
input_C1 = (input_pixel >> 8) & 0xFF;
input_C0 = (input_pixel >> 0) & 0xFF;
comp_C0 = input_C0;
comp_C1 = input_C1;
comp_C2 = input_C2;
for (i = 0; i < 9; i++)
matrix[i] =
((int32) (((int32) matrix_and_bias_vector[i]) << 20)) >> 20;
bias_vector[0] = (int32) (matrix_and_bias_vector[9] & 0xFF);
bias_vector[1] = (int32) (matrix_and_bias_vector[10] & 0xFF);
bias_vector[2] = (int32) (matrix_and_bias_vector[11] & 0xFF);
Y_low_limit = (int32) clamp_vector[0];
Y_high_limit = (int32) clamp_vector[1];
C_low_limit = (int32) clamp_vector[2];
C_high_limit = (int32) clamp_vector[3];
if (look_up_table == 0) /* check for NULL point */
_is_lookup_table_enabled = 0;
else
_is_lookup_table_enabled = 1;
if (_is_lookup_table_enabled == 1) {
comp_C2 = (look_up_table[comp_C2] >> 16) & 0xFF;
comp_C1 = (look_up_table[comp_C1] >> 8) & 0xFF;
comp_C0 = (look_up_table[comp_C0] >> 0) & 0xFF;
}
/*
* Color Conversion
* reorder input colors
*/
temp = comp_C2;
comp_C2 = comp_C1;
comp_C1 = comp_C0;
comp_C0 = temp;
/* matrix multiplication */
temp1 = comp_C0 * matrix[0] + comp_C1 * matrix[1] + comp_C2 * matrix[2];
temp2 = comp_C0 * matrix[3] + comp_C1 * matrix[4] + comp_C2 * matrix[5];
temp3 = comp_C0 * matrix[6] + comp_C1 * matrix[7] + comp_C2 * matrix[8];
comp_C0 = temp1 + 0x100;
comp_C1 = temp2 + 0x100;
comp_C2 = temp3 + 0x100;
/* take interger part */
comp_C0 >>= 9;
comp_C1 >>= 9;
comp_C2 >>= 9;
/* post bias (+) */
comp_C0 += bias_vector[0];
comp_C1 += bias_vector[1];
comp_C2 += bias_vector[2];
/* limit pixel to 8-bit */
if (comp_C0 < 0)
comp_C0 = 0;
if (comp_C0 > 255)
comp_C0 = 255;
if (comp_C1 < 0)
comp_C1 = 0;
if (comp_C1 > 255)
comp_C1 = 255;
if (comp_C2 < 0)
comp_C2 = 0;
if (comp_C2 > 255)
comp_C2 = 255;
/* clamp */
if (comp_C0 < Y_low_limit)
comp_C0 = Y_low_limit;
if (comp_C0 > Y_high_limit)
comp_C0 = Y_high_limit;
if (comp_C1 < C_low_limit)
comp_C1 = C_low_limit;
if (comp_C1 > C_high_limit)
comp_C1 = C_high_limit;
if (comp_C2 < C_low_limit)
comp_C2 = C_low_limit;
if (comp_C2 > C_high_limit)
comp_C2 = C_high_limit;
output = (comp_C2 << 16) | (comp_C1 << 8) | comp_C0;
return output;
}
uint32 mdp_conv_matx_yuv2rgb(uint32 input_pixel,
uint16 *matrix_and_bias_vector,
uint32 *clamp_vector, uint32 *look_up_table)
{
uint8 input_C2, input_C0, input_C1;
uint32 output;
int32 comp_C2, comp_C1, comp_C0, temp;
int32 temp1, temp2, temp3;
int32 matrix[9];
int32 bias_vector[3];
int32 Y_low_limit, Y_high_limit, C_low_limit, C_high_limit;
int32 i;
uint32 _is_lookup_table_enabled;
input_C2 = (input_pixel >> 16) & 0xFF;
input_C1 = (input_pixel >> 8) & 0xFF;
input_C0 = (input_pixel >> 0) & 0xFF;
comp_C0 = input_C0;
comp_C1 = input_C1;
comp_C2 = input_C2;
for (i = 0; i < 9; i++)
matrix[i] =
((int32) (((int32) matrix_and_bias_vector[i]) << 20)) >> 20;
bias_vector[0] = (int32) (matrix_and_bias_vector[9] & 0xFF);
bias_vector[1] = (int32) (matrix_and_bias_vector[10] & 0xFF);
bias_vector[2] = (int32) (matrix_and_bias_vector[11] & 0xFF);
Y_low_limit = (int32) clamp_vector[0];
Y_high_limit = (int32) clamp_vector[1];
C_low_limit = (int32) clamp_vector[2];
C_high_limit = (int32) clamp_vector[3];
if (look_up_table == 0) /* check for NULL point */
_is_lookup_table_enabled = 0;
else
_is_lookup_table_enabled = 1;
/* clamp */
if (comp_C0 < Y_low_limit)
comp_C0 = Y_low_limit;
if (comp_C0 > Y_high_limit)
comp_C0 = Y_high_limit;
if (comp_C1 < C_low_limit)
comp_C1 = C_low_limit;
if (comp_C1 > C_high_limit)
comp_C1 = C_high_limit;
if (comp_C2 < C_low_limit)
comp_C2 = C_low_limit;
if (comp_C2 > C_high_limit)
comp_C2 = C_high_limit;
/*
* Color Conversion
* pre bias (-)
*/
comp_C0 -= bias_vector[0];
comp_C1 -= bias_vector[1];
comp_C2 -= bias_vector[2];
/* matrix multiplication */
temp1 = comp_C0 * matrix[0] + comp_C1 * matrix[1] + comp_C2 * matrix[2];
temp2 = comp_C0 * matrix[3] + comp_C1 * matrix[4] + comp_C2 * matrix[5];
temp3 = comp_C0 * matrix[6] + comp_C1 * matrix[7] + comp_C2 * matrix[8];
comp_C0 = temp1 + 0x100;
comp_C1 = temp2 + 0x100;
comp_C2 = temp3 + 0x100;
/* take interger part */
comp_C0 >>= 9;
comp_C1 >>= 9;
comp_C2 >>= 9;
/* reorder output colors */
temp = comp_C0;
comp_C0 = comp_C1;
comp_C1 = comp_C2;
comp_C2 = temp;
/* limit pixel to 8-bit */
if (comp_C0 < 0)
comp_C0 = 0;
if (comp_C0 > 255)
comp_C0 = 255;
if (comp_C1 < 0)
comp_C1 = 0;
if (comp_C1 > 255)
comp_C1 = 255;
if (comp_C2 < 0)
comp_C2 = 0;
if (comp_C2 > 255)
comp_C2 = 255;
/* Look-up table */
if (_is_lookup_table_enabled == 1) {
comp_C2 = (look_up_table[comp_C2] >> 16) & 0xFF;
comp_C1 = (look_up_table[comp_C1] >> 8) & 0xFF;
comp_C0 = (look_up_table[comp_C0] >> 0) & 0xFF;
}
output = (comp_C2 << 16) | (comp_C1 << 8) | comp_C0;
return output;
}
static uint32 mdp_calc_tpval(MDPIMG *mdpImg)
{
uint32 tpVal;
uint8 plane_tp;
tpVal = 0;
if ((mdpImg->imgType == MDP_RGB_565)
|| (mdpImg->imgType == MDP_BGR_565)) {
/*
* transparent color conversion into 24 bpp
*
* C2R_8BIT
* left shift the entire bit and or it with the upper most bits
*/
plane_tp = (uint8) ((mdpImg->tpVal & 0xF800) >> 11);
tpVal |= ((plane_tp << 3) | ((plane_tp & 0x1C) >> 2)) << 16;
/* C1B_8BIT */
plane_tp = (uint8) (mdpImg->tpVal & 0x1F);
tpVal |= ((plane_tp << 3) | ((plane_tp & 0x1C) >> 2)) << 8;
/* C0G_8BIT */
plane_tp = (uint8) ((mdpImg->tpVal & 0x7E0) >> 5);
tpVal |= ((plane_tp << 2) | ((plane_tp & 0x30) >> 4));
} else {
/* 24bit RGB to RBG conversion */
tpVal = (mdpImg->tpVal & 0xFF00) >> 8;
tpVal |= (mdpImg->tpVal & 0xFF) << 8;
tpVal |= (mdpImg->tpVal & 0xFF0000);
}
return tpVal;
}
static uint8 *mdp_get_chroma_addr(MDPIBUF *iBuf)
{
uint8 *dest1;
dest1 = NULL;
switch (iBuf->ibuf_type) {
case MDP_Y_CBCR_H2V2:
case MDP_Y_CRCB_H2V2:
case MDP_Y_CBCR_H2V1:
case MDP_Y_CRCB_H2V1:
dest1 = (uint8 *) iBuf->buf;
dest1 += iBuf->ibuf_width * iBuf->ibuf_height * iBuf->bpp;
break;
default:
break;
}
return dest1;
}
static void mdp_ppp_setbg(MDPIBUF *iBuf)
{
uint8 *bg0_addr;
uint8 *bg1_addr;
uint32 bg0_ystride, bg1_ystride;
uint32 ppp_src_cfg_reg, unpack_pattern;
int v_slice, h_slice;
v_slice = h_slice = 1;
bg0_addr = (uint8 *) iBuf->buf;
bg1_addr = mdp_get_chroma_addr(iBuf);
bg0_ystride = iBuf->ibuf_width * iBuf->bpp;
bg1_ystride = iBuf->ibuf_width * iBuf->bpp;
switch (iBuf->ibuf_type) {
case MDP_BGR_565:
case MDP_RGB_565:
/* 888 = 3bytes
* RGB = 3Components
* RGB interleaved
*/
ppp_src_cfg_reg = PPP_SRC_C2R_5BITS | PPP_SRC_C0G_6BITS |
PPP_SRC_C1B_5BITS | PPP_SRC_BPP_INTERLVD_2BYTES |
PPP_SRC_INTERLVD_3COMPONENTS | PPP_SRC_UNPACK_TIGHT |
PPP_SRC_UNPACK_ALIGN_LSB |
PPP_SRC_FETCH_PLANES_INTERLVD;
if (iBuf->ibuf_type == MDP_RGB_565)
unpack_pattern =
MDP_GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8);
else
unpack_pattern =
MDP_GET_PACK_PATTERN(0, CLR_B, CLR_G, CLR_R, 8);
break;
case MDP_RGB_888:
/*
* 888 = 3bytes
* RGB = 3Components
* RGB interleaved
*/
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS | PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS | PPP_SRC_BPP_INTERLVD_3BYTES |
PPP_SRC_INTERLVD_3COMPONENTS | PPP_SRC_UNPACK_TIGHT |
PPP_SRC_UNPACK_ALIGN_LSB | PPP_SRC_FETCH_PLANES_INTERLVD;
unpack_pattern =
MDP_GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8);
break;
case MDP_BGRA_8888:
case MDP_RGBA_8888:
case MDP_ARGB_8888:
case MDP_XRGB_8888:
/*
* 8888 = 4bytes
* ARGB = 4Components
* ARGB interleaved
*/
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS | PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS | PPP_SRC_C3A_8BITS | PPP_SRC_C3_ALPHA_EN |
PPP_SRC_BPP_INTERLVD_4BYTES | PPP_SRC_INTERLVD_4COMPONENTS |
PPP_SRC_UNPACK_TIGHT | PPP_SRC_UNPACK_ALIGN_LSB |
PPP_SRC_FETCH_PLANES_INTERLVD;
if (iBuf->ibuf_type == MDP_BGRA_8888)
unpack_pattern =
MDP_GET_PACK_PATTERN(CLR_ALPHA, CLR_R, CLR_G, CLR_B,
8);
else if (iBuf->ibuf_type == MDP_RGBA_8888)
unpack_pattern =
MDP_GET_PACK_PATTERN(CLR_ALPHA, CLR_B, CLR_G, CLR_R,
8);
else
unpack_pattern =
MDP_GET_PACK_PATTERN(CLR_ALPHA, CLR_R, CLR_G, CLR_B,
8);
break;
case MDP_Y_CBCR_H2V2:
case MDP_Y_CRCB_H2V2:
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS |
PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS |
PPP_SRC_C3A_8BITS |
PPP_SRC_BPP_INTERLVD_2BYTES |
PPP_SRC_INTERLVD_2COMPONENTS |
PPP_SRC_UNPACK_TIGHT |
PPP_SRC_UNPACK_ALIGN_LSB | PPP_SRC_FETCH_PLANES_PSEUDOPLNR;
if (iBuf->ibuf_type == MDP_Y_CBCR_H2V1)
unpack_pattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8);
else
unpack_pattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8);
v_slice = h_slice = 2;
break;
case MDP_YCRYCB_H2V1:
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS |
PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS |
PPP_SRC_C3A_8BITS |
PPP_SRC_BPP_INTERLVD_2BYTES |
PPP_SRC_INTERLVD_4COMPONENTS |
PPP_SRC_UNPACK_TIGHT | PPP_SRC_UNPACK_ALIGN_LSB;
unpack_pattern =
MDP_GET_PACK_PATTERN(CLR_Y, CLR_CR, CLR_Y, CLR_CB, 8);
h_slice = 2;
break;
case MDP_Y_CBCR_H2V1:
case MDP_Y_CRCB_H2V1:
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS |
PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS |
PPP_SRC_C3A_8BITS |
PPP_SRC_BPP_INTERLVD_2BYTES |
PPP_SRC_INTERLVD_2COMPONENTS |
PPP_SRC_UNPACK_TIGHT |
PPP_SRC_UNPACK_ALIGN_LSB | PPP_SRC_FETCH_PLANES_PSEUDOPLNR;
if (iBuf->ibuf_type == MDP_Y_CBCR_H2V1)
unpack_pattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8);
else
unpack_pattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8);
h_slice = 2;
break;
default:
return;
}
/* starting input address adjustment */
mdp_adjust_start_addr(&bg0_addr, &bg1_addr, v_slice, h_slice,
iBuf->roi.lcd_x, iBuf->roi.lcd_y,
iBuf->ibuf_width, iBuf->ibuf_height, iBuf->bpp,
iBuf, 1);
/*
* 0x01c0: background plane 0 addr
* 0x01c4: background plane 1 addr
* 0x01c8: background plane 2 addr
* 0x01cc: bg y stride for plane 0 and 1
* 0x01d0: bg y stride for plane 2
* 0x01d4: bg src PPP config
* 0x01d8: unpack pattern
*/
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01c0, bg0_addr);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01c4, bg1_addr);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01cc,
(bg1_ystride << 16) | bg0_ystride);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01d4, ppp_src_cfg_reg);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01d8, unpack_pattern);
}
#define IS_PSEUDOPLNR(img) ((img == MDP_Y_CRCB_H2V2) | \
(img == MDP_Y_CBCR_H2V2) | \
(img == MDP_Y_CRCB_H2V1) | \
(img == MDP_Y_CBCR_H2V1))
#define IMG_LEN(rect_h, w, rect_w, bpp) (((rect_h) * w) * bpp)
#define Y_TO_CRCB_RATIO(format) \
((format == MDP_Y_CBCR_H2V2 || format == MDP_Y_CRCB_H2V2) ? 2 :\
(format == MDP_Y_CBCR_H2V1 || format == MDP_Y_CRCB_H2V1) ? 1 : 1)
static void get_len(struct mdp_img *img, struct mdp_rect *rect, uint32_t bpp,
uint32_t *len0, uint32_t *len1)
{
*len0 = IMG_LEN(rect->h, img->width, rect->w, bpp);
if (IS_PSEUDOPLNR(img->format))
*len1 = *len0/Y_TO_CRCB_RATIO(img->format);
else
*len1 = 0;
}
static void flush_imgs(struct mdp_blit_req *req, int src_bpp, int dst_bpp,
struct file *p_src_file, struct file *p_dst_file)
{
#ifdef CONFIG_ANDROID_PMEM
uint32_t src0_len, src1_len, dst0_len, dst1_len;
/* flush src images to memory before dma to mdp */
get_len(&req->src, &req->src_rect, src_bpp,
&src0_len, &src1_len);
flush_pmem_file(p_src_file,
req->src.offset, src0_len);
if (IS_PSEUDOPLNR(req->src.format))
flush_pmem_file(p_src_file,
req->src.offset + src0_len, src1_len);
get_len(&req->dst, &req->dst_rect, dst_bpp, &dst0_len, &dst1_len);
flush_pmem_file(p_dst_file, req->dst.offset, dst0_len);
if (IS_PSEUDOPLNR(req->dst.format))
flush_pmem_file(p_dst_file,
req->dst.offset + dst0_len, dst1_len);
#endif
}
static void mdp_start_ppp(struct msm_fb_data_type *mfd, MDPIBUF *iBuf,
struct mdp_blit_req *req, struct file *p_src_file, struct file *p_dst_file)
{
uint8 *src0, *src1;
uint8 *dest0, *dest1;
uint16 inpBpp;
uint32 dest0_ystride;
uint32 src_width;
uint32 src_height;
uint32 src0_ystride;
uint32 dst_roi_width;
uint32 dst_roi_height;
uint32 ppp_src_cfg_reg, ppp_operation_reg, ppp_dst_cfg_reg;
uint32 alpha, tpVal;
uint32 packPattern;
uint32 dst_packPattern;
boolean inputRGB, outputRGB, pseudoplanr_output;
int sv_slice, sh_slice;
int dv_slice, dh_slice;
boolean perPixelAlpha = FALSE;
boolean ppp_lookUp_enable = FALSE;
sv_slice = sh_slice = dv_slice = dh_slice = 1;
alpha = tpVal = 0;
src_width = iBuf->mdpImg.width;
src_height = iBuf->roi.y + iBuf->roi.height;
src1 = NULL;
dest1 = NULL;
inputRGB = outputRGB = TRUE;
pseudoplanr_output = FALSE;
ppp_operation_reg = 0;
ppp_dst_cfg_reg = 0;
ppp_src_cfg_reg = 0;
/* Wait for the pipe to clear */
do { } while (mdp_ppp_pipe_wait() <= 0);
/*
* destination config
*/
switch (iBuf->ibuf_type) {
case MDP_RGB_888:
dst_packPattern =
MDP_GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8);
ppp_dst_cfg_reg =
PPP_DST_C0G_8BIT | PPP_DST_C1B_8BIT | PPP_DST_C2R_8BIT |
PPP_DST_PACKET_CNT_INTERLVD_3ELEM | PPP_DST_PACK_TIGHT |
PPP_DST_PACK_ALIGN_LSB | PPP_DST_OUT_SEL_AXI |
PPP_DST_BPP_3BYTES | PPP_DST_PLANE_INTERLVD;
break;
case MDP_XRGB_8888:
case MDP_ARGB_8888:
case MDP_RGBA_8888:
if (iBuf->ibuf_type == MDP_BGRA_8888)
dst_packPattern =
MDP_GET_PACK_PATTERN(CLR_ALPHA, CLR_R, CLR_G, CLR_B,
8);
else if (iBuf->ibuf_type == MDP_RGBA_8888)
dst_packPattern =
MDP_GET_PACK_PATTERN(CLR_ALPHA, CLR_B, CLR_G, CLR_R,
8);
else
dst_packPattern =
MDP_GET_PACK_PATTERN(CLR_ALPHA, CLR_R, CLR_G, CLR_B,
8);
ppp_dst_cfg_reg = PPP_DST_C0G_8BIT |
PPP_DST_C1B_8BIT |
PPP_DST_C2R_8BIT |
PPP_DST_C3A_8BIT |
PPP_DST_C3ALPHA_EN |
PPP_DST_PACKET_CNT_INTERLVD_4ELEM |
PPP_DST_PACK_TIGHT |
PPP_DST_PACK_ALIGN_LSB |
PPP_DST_OUT_SEL_AXI |
PPP_DST_BPP_4BYTES | PPP_DST_PLANE_INTERLVD;
break;
case MDP_Y_CBCR_H2V2:
case MDP_Y_CRCB_H2V2:
if (iBuf->ibuf_type == MDP_Y_CBCR_H2V2)
dst_packPattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8);
else
dst_packPattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8);
ppp_dst_cfg_reg = PPP_DST_C2R_8BIT |
PPP_DST_C0G_8BIT |
PPP_DST_C1B_8BIT |
PPP_DST_C3A_8BIT |
PPP_DST_PACKET_CNT_INTERLVD_2ELEM |
PPP_DST_PACK_TIGHT |
PPP_DST_PACK_ALIGN_LSB |
PPP_DST_OUT_SEL_AXI | PPP_DST_BPP_2BYTES;
ppp_operation_reg |= PPP_OP_DST_CHROMA_420;
outputRGB = FALSE;
pseudoplanr_output = TRUE;
/*
* vertically (y direction) and horizontally (x direction)
* sample reduction by 2
*/
/*
* H2V2(YUV420) Cosite
*
* Y Y Y Y
* CbCr CbCr
* Y Y Y Y
* Y Y Y Y
* CbCr CbCr
* Y Y Y Y
*/
dv_slice = dh_slice = 2;
/* (x,y) and (width,height) must be even numbern */
iBuf->roi.lcd_x = (iBuf->roi.lcd_x / 2) * 2;
iBuf->roi.dst_width = (iBuf->roi.dst_width / 2) * 2;
iBuf->roi.x = (iBuf->roi.x / 2) * 2;
iBuf->roi.width = (iBuf->roi.width / 2) * 2;
iBuf->roi.lcd_y = (iBuf->roi.lcd_y / 2) * 2;
iBuf->roi.dst_height = (iBuf->roi.dst_height / 2) * 2;
iBuf->roi.y = (iBuf->roi.y / 2) * 2;
iBuf->roi.height = (iBuf->roi.height / 2) * 2;
break;
case MDP_YCRYCB_H2V1:
dst_packPattern =
MDP_GET_PACK_PATTERN(CLR_Y, CLR_CR, CLR_Y, CLR_CB, 8);
ppp_dst_cfg_reg =
PPP_DST_C2R_8BIT | PPP_DST_C0G_8BIT | PPP_DST_C1B_8BIT |
PPP_DST_C3A_8BIT | PPP_DST_PACKET_CNT_INTERLVD_4ELEM |
PPP_DST_PACK_TIGHT | PPP_DST_PACK_ALIGN_LSB |
PPP_DST_OUT_SEL_AXI | PPP_DST_BPP_2BYTES |
PPP_DST_PLANE_INTERLVD;
ppp_operation_reg |= PPP_OP_DST_CHROMA_H2V1;
outputRGB = FALSE;
/*
* horizontally (x direction) sample reduction by 2
*
* H2V1(YUV422) Cosite
*
* YCbCr Y YCbCr Y
* YCbCr Y YCbCr Y
* YCbCr Y YCbCr Y
* YCbCr Y YCbCr Y
*/
dh_slice = 2;
/*
* if it's TV-Out/MDP_YCRYCB_H2V1, let's go through the
* preloaded gamma setting of 2.2 when the content is
* non-linear ppp_lookUp_enable = TRUE;
*/
/* x and width must be even number */
iBuf->roi.lcd_x = (iBuf->roi.lcd_x / 2) * 2;
iBuf->roi.dst_width = (iBuf->roi.dst_width / 2) * 2;
iBuf->roi.x = (iBuf->roi.x / 2) * 2;
iBuf->roi.width = (iBuf->roi.width / 2) * 2;
break;
case MDP_Y_CBCR_H2V1:
case MDP_Y_CRCB_H2V1:
if (iBuf->ibuf_type == MDP_Y_CBCR_H2V1)
dst_packPattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8);
else
dst_packPattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8);
ppp_dst_cfg_reg = PPP_DST_C2R_8BIT |
PPP_DST_C0G_8BIT |
PPP_DST_C1B_8BIT |
PPP_DST_C3A_8BIT |
PPP_DST_PACKET_CNT_INTERLVD_2ELEM |
PPP_DST_PACK_TIGHT |
PPP_DST_PACK_ALIGN_LSB |
PPP_DST_OUT_SEL_AXI | PPP_DST_BPP_2BYTES;
ppp_operation_reg |= PPP_OP_DST_CHROMA_H2V1;
outputRGB = FALSE;
pseudoplanr_output = TRUE;
/* horizontally (x direction) sample reduction by 2 */
dh_slice = 2;
/* x and width must be even number */
iBuf->roi.lcd_x = (iBuf->roi.lcd_x / 2) * 2;
iBuf->roi.dst_width = (iBuf->roi.dst_width / 2) * 2;
iBuf->roi.x = (iBuf->roi.x / 2) * 2;
iBuf->roi.width = (iBuf->roi.width / 2) * 2;
break;
case MDP_BGR_565:
case MDP_RGB_565:
default:
if (iBuf->ibuf_type == MDP_RGB_565)
dst_packPattern =
MDP_GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8);
else
dst_packPattern =
MDP_GET_PACK_PATTERN(0, CLR_B, CLR_G, CLR_R, 8);
ppp_dst_cfg_reg = PPP_DST_C0G_6BIT |
PPP_DST_C1B_5BIT |
PPP_DST_C2R_5BIT |
PPP_DST_PACKET_CNT_INTERLVD_3ELEM |
PPP_DST_PACK_TIGHT |
PPP_DST_PACK_ALIGN_LSB |
PPP_DST_OUT_SEL_AXI |
PPP_DST_BPP_2BYTES | PPP_DST_PLANE_INTERLVD;
break;
}
/* source config */
switch (iBuf->mdpImg.imgType) {
case MDP_RGB_888:
inpBpp = 3;
/*
* 565 = 2bytes
* RGB = 3Components
* RGB interleaved
*/
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS | PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS | PPP_SRC_BPP_INTERLVD_3BYTES |
PPP_SRC_INTERLVD_3COMPONENTS | PPP_SRC_UNPACK_TIGHT |
PPP_SRC_UNPACK_ALIGN_LSB |
PPP_SRC_FETCH_PLANES_INTERLVD;
packPattern = MDP_GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8);
ppp_operation_reg |= PPP_OP_COLOR_SPACE_RGB |
PPP_OP_SRC_CHROMA_RGB | PPP_OP_DST_CHROMA_RGB;
break;
case MDP_BGRA_8888:
case MDP_RGBA_8888:
case MDP_ARGB_8888:
perPixelAlpha = TRUE;
case MDP_XRGB_8888:
inpBpp = 4;
/*
* 8888 = 4bytes
* ARGB = 4Components
* ARGB interleaved
*/
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS | PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS | PPP_SRC_C3A_8BITS |
PPP_SRC_C3_ALPHA_EN | PPP_SRC_BPP_INTERLVD_4BYTES |
PPP_SRC_INTERLVD_4COMPONENTS | PPP_SRC_UNPACK_TIGHT |
PPP_SRC_UNPACK_ALIGN_LSB |
PPP_SRC_FETCH_PLANES_INTERLVD;
if (iBuf->mdpImg.imgType == MDP_BGRA_8888)
packPattern =
MDP_GET_PACK_PATTERN(CLR_ALPHA, CLR_R, CLR_G, CLR_B,
8);
else if (iBuf->mdpImg.imgType == MDP_RGBA_8888)
packPattern =
MDP_GET_PACK_PATTERN(CLR_ALPHA, CLR_B, CLR_G, CLR_R,
8);
else
packPattern =
MDP_GET_PACK_PATTERN(CLR_ALPHA, CLR_R, CLR_G, CLR_B,
8);
ppp_operation_reg |= PPP_OP_COLOR_SPACE_RGB |
PPP_OP_SRC_CHROMA_RGB | PPP_OP_DST_CHROMA_RGB;
break;
case MDP_Y_CBCR_H2V2:
case MDP_Y_CRCB_H2V2:
inpBpp = 1;
src1 = (uint8 *) iBuf->mdpImg.cbcr_addr;
/*
* CbCr = 2bytes
* CbCr = 2Components
* Y+CbCr
*/
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS | PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS | PPP_SRC_BPP_INTERLVD_2BYTES |
PPP_SRC_INTERLVD_2COMPONENTS | PPP_SRC_UNPACK_TIGHT |
PPP_SRC_UNPACK_ALIGN_LSB |
PPP_SRC_FETCH_PLANES_PSEUDOPLNR;
if (iBuf->mdpImg.imgType == MDP_Y_CRCB_H2V2)
packPattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8);
else
packPattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8);
ppp_operation_reg |= PPP_OP_COLOR_SPACE_YCBCR |
PPP_OP_SRC_CHROMA_420 |
PPP_OP_SRC_CHROMA_COSITE |
PPP_OP_DST_CHROMA_RGB | PPP_OP_DST_CHROMA_COSITE;
inputRGB = FALSE;
sh_slice = sv_slice = 2;
break;
case MDP_YCRYCB_H2V1:
inpBpp = 2;
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS |
PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS |
PPP_SRC_C3A_8BITS |
PPP_SRC_BPP_INTERLVD_2BYTES |
PPP_SRC_INTERLVD_4COMPONENTS |
PPP_SRC_UNPACK_TIGHT | PPP_SRC_UNPACK_ALIGN_LSB;
packPattern =
MDP_GET_PACK_PATTERN(CLR_Y, CLR_CR, CLR_Y, CLR_CB, 8);
ppp_operation_reg |= PPP_OP_SRC_CHROMA_H2V1 |
PPP_OP_SRC_CHROMA_COSITE | PPP_OP_DST_CHROMA_COSITE;
/*
* if it's TV-Out/MDP_YCRYCB_H2V1, let's go through the
* preloaded inverse gamma setting of 2.2 since they're
* symetric when the content is non-linear
* ppp_lookUp_enable = TRUE;
*/
/* x and width must be even number */
iBuf->roi.lcd_x = (iBuf->roi.lcd_x / 2) * 2;
iBuf->roi.dst_width = (iBuf->roi.dst_width / 2) * 2;
iBuf->roi.x = (iBuf->roi.x / 2) * 2;
iBuf->roi.width = (iBuf->roi.width / 2) * 2;
inputRGB = FALSE;
sh_slice = 2;
break;
case MDP_Y_CBCR_H2V1:
case MDP_Y_CRCB_H2V1:
inpBpp = 1;
src1 = (uint8 *) iBuf->mdpImg.cbcr_addr;
ppp_src_cfg_reg = PPP_SRC_C2R_8BITS |
PPP_SRC_C0G_8BITS |
PPP_SRC_C1B_8BITS |
PPP_SRC_C3A_8BITS |
PPP_SRC_BPP_INTERLVD_2BYTES |
PPP_SRC_INTERLVD_2COMPONENTS |
PPP_SRC_UNPACK_TIGHT |
PPP_SRC_UNPACK_ALIGN_LSB | PPP_SRC_FETCH_PLANES_PSEUDOPLNR;
if (iBuf->mdpImg.imgType == MDP_Y_CBCR_H2V1)
packPattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8);
else
packPattern =
MDP_GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8);
ppp_operation_reg |= PPP_OP_SRC_CHROMA_H2V1 |
PPP_OP_SRC_CHROMA_COSITE | PPP_OP_DST_CHROMA_COSITE;
inputRGB = FALSE;
sh_slice = 2;
break;
case MDP_BGR_565:
case MDP_RGB_565:
default:
inpBpp = 2;
/*
* 565 = 2bytes
* RGB = 3Components
* RGB interleaved
*/
ppp_src_cfg_reg = PPP_SRC_C2R_5BITS | PPP_SRC_C0G_6BITS |
PPP_SRC_C1B_5BITS | PPP_SRC_BPP_INTERLVD_2BYTES |
PPP_SRC_INTERLVD_3COMPONENTS | PPP_SRC_UNPACK_TIGHT |
PPP_SRC_UNPACK_ALIGN_LSB |
PPP_SRC_FETCH_PLANES_INTERLVD;
if (iBuf->mdpImg.imgType == MDP_RGB_565)
packPattern =
MDP_GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8);
else
packPattern =
MDP_GET_PACK_PATTERN(0, CLR_B, CLR_G, CLR_R, 8);
ppp_operation_reg |= PPP_OP_COLOR_SPACE_RGB |
PPP_OP_SRC_CHROMA_RGB | PPP_OP_DST_CHROMA_RGB;
break;
}
if (pseudoplanr_output)
ppp_dst_cfg_reg |= PPP_DST_PLANE_PSEUDOPLN;
/* YCbCr to RGB color conversion flag */
if ((!inputRGB) && (outputRGB)) {
ppp_operation_reg |= PPP_OP_CONVERT_YCBCR2RGB |
PPP_OP_CONVERT_ON;
/*
* primary/secondary is sort of misleading term...but
* in mdp2.2/3.0 we only use primary matrix (forward/rev)
* in mdp3.1 we use set1(prim) and set2(secd)
*/
#ifdef CONFIG_FB_MSM_MDP31
ppp_operation_reg |= PPP_OP_CONVERT_MATRIX_SECONDARY |
PPP_OP_DST_RGB;
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0240, 0);
#endif
if (ppp_lookUp_enable) {
ppp_operation_reg |= PPP_OP_LUT_C0_ON |
PPP_OP_LUT_C1_ON | PPP_OP_LUT_C2_ON;
}
}
/* RGB to YCbCr color conversion flag */
if ((inputRGB) && (!outputRGB)) {
ppp_operation_reg |= PPP_OP_CONVERT_RGB2YCBCR |
PPP_OP_CONVERT_ON;
#ifdef CONFIG_FB_MSM_MDP31
ppp_operation_reg |= PPP_OP_CONVERT_MATRIX_PRIMARY |
PPP_OP_DST_YCBCR;
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0240, 0x1e);
#endif
if (ppp_lookUp_enable) {
ppp_operation_reg |= PPP_OP_LUT_C0_ON |
PPP_OP_LUT_C1_ON | PPP_OP_LUT_C2_ON;
}
}
/* YCbCr to YCbCr color conversion flag */
if ((!inputRGB) && (!outputRGB)) {
if ((ppp_lookUp_enable) &&
(iBuf->mdpImg.imgType != iBuf->ibuf_type)) {
ppp_operation_reg |= PPP_OP_LUT_C0_ON;
}
}
ppp_src_cfg_reg |= (iBuf->roi.x % 2) ? PPP_SRC_BPP_ROI_ODD_X : 0;
ppp_src_cfg_reg |= (iBuf->roi.y % 2) ? PPP_SRC_BPP_ROI_ODD_Y : 0;
if (req->flags & MDP_DEINTERLACE)
ppp_operation_reg |= PPP_OP_DEINT_EN;
/* Dither at DMA side only since iBuf format is RGB888 */
if (iBuf->mdpImg.mdpOp & MDPOP_DITHER)
ppp_operation_reg |= PPP_OP_DITHER_EN;
if (iBuf->mdpImg.mdpOp & MDPOP_ROTATION) {
ppp_operation_reg |= PPP_OP_ROT_ON;
if (iBuf->mdpImg.mdpOp & MDPOP_ROT90) {
ppp_operation_reg |= PPP_OP_ROT_90;
}
if (iBuf->mdpImg.mdpOp & MDPOP_LR) {
ppp_operation_reg |= PPP_OP_FLIP_LR;
}
if (iBuf->mdpImg.mdpOp & MDPOP_UD) {
ppp_operation_reg |= PPP_OP_FLIP_UD;
}
}
src0_ystride = src_width * inpBpp;
dest0_ystride = iBuf->ibuf_width * iBuf->bpp;
/* no need to care about rotation since it's the real-XY. */
dst_roi_width = iBuf->roi.dst_width;
dst_roi_height = iBuf->roi.dst_height;
src0 = (uint8 *) iBuf->mdpImg.bmy_addr;
dest0 = (uint8 *) iBuf->buf;
/* Jumping from Y-Plane to Chroma Plane */
dest1 = mdp_get_chroma_addr(iBuf);
/* first pixel addr calculation */
mdp_adjust_start_addr(&src0, &src1, sv_slice, sh_slice, iBuf->roi.x,
iBuf->roi.y, src_width, src_height, inpBpp, iBuf,
0);
mdp_adjust_start_addr(&dest0, &dest1, dv_slice, dh_slice,
iBuf->roi.lcd_x, iBuf->roi.lcd_y,
iBuf->ibuf_width, iBuf->ibuf_height, iBuf->bpp,
iBuf, 2);
/* set scale operation */
mdp_set_scale(iBuf, dst_roi_width, dst_roi_height,
inputRGB, outputRGB, &ppp_operation_reg);
/*
* setting background source for blending
*/
mdp_set_blend_attr(iBuf, &alpha, &tpVal, perPixelAlpha,
&ppp_operation_reg);
if (ppp_operation_reg & PPP_OP_BLEND_ON) {
mdp_ppp_setbg(iBuf);
if (iBuf->ibuf_type == MDP_YCRYCB_H2V1) {
ppp_operation_reg |= PPP_OP_BG_CHROMA_H2V1;
if (iBuf->mdpImg.mdpOp & MDPOP_TRANSP) {
tpVal = mdp_conv_matx_rgb2yuv(tpVal,
(uint16 *) &
mdp_ccs_rgb2yuv,
&mdp_plv[0], NULL);
}
}
}
/*
* 0x0004: enable dbg bus
* 0x0100: "don't care" Edge Condit until scaling is on
* 0x0104: xrc tile x&y size u7.6 format = 7bit.6bit
* 0x0108: src pixel size
* 0x010c: component plane 0 starting address
* 0x011c: component plane 0 ystride
* 0x0124: PPP source config register
* 0x0128: unpacked pattern from lsb to msb (eg. RGB->BGR)
*/
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0108, (iBuf->roi.height << 16 |
iBuf->roi.width));
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x010c, src0); /* comp.plane 0 */
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0110, src1); /* comp.plane 1 */
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x011c,
(src0_ystride << 16 | src0_ystride));
/* setup for rgb 565 */
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0124, ppp_src_cfg_reg);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0128, packPattern);
/*
* 0x0138: PPP destination operation register
* 0x014c: constant_alpha|transparent_color
* 0x0150: PPP destination config register
* 0x0154: PPP packing pattern
*/
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0138, ppp_operation_reg);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x014c, alpha << 24 | tpVal);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0150, ppp_dst_cfg_reg);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0154, dst_packPattern);
/*
* 0x0164: ROI height and width
* 0x0168: Component Plane 0 starting addr
* 0x016c: Component Plane 1 starting addr
* 0x0178: Component Plane 1/0 y stride
*/
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0164,
(dst_roi_height << 16 | dst_roi_width));
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0168, dest0);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x016c, dest1);
MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0178,
(dest0_ystride << 16 | dest0_ystride));
flush_imgs(req, inpBpp, iBuf->bpp, p_src_file, p_dst_file);
#ifdef CONFIG_MDP_PPP_ASYNC_OP
mdp_ppp_process_curr_djob();
#else
mdp_pipe_kickoff(MDP_PPP_TERM, mfd);
#endif
}
static int mdp_ppp_verify_req(struct mdp_blit_req *req)
{
u32 src_width, src_height, dst_width, dst_height;
if (req == NULL)
return -1;
if (MDP_IS_IMGTYPE_BAD(req->src.format) ||
MDP_IS_IMGTYPE_BAD(req->dst.format))
return -1;
if ((req->src.width == 0) || (req->src.height == 0) ||
(req->src_rect.w == 0) || (req->src_rect.h == 0) ||
(req->dst.width == 0) || (req->dst.height == 0) ||
(req->dst_rect.w == 0) || (req->dst_rect.h == 0))
return -1;
if (((req->src_rect.x + req->src_rect.w) > req->src.width) ||
((req->src_rect.y + req->src_rect.h) > req->src.height))
return -1;
if (((req->dst_rect.x + req->dst_rect.w) > req->dst.width) ||
((req->dst_rect.y + req->dst_rect.h) > req->dst.height))
return -1;
/*
* scaling range check
*/
src_width = req->src_rect.w;
src_height = req->src_rect.h;
if (req->flags & MDP_ROT_90) {
dst_width = req->dst_rect.h;
dst_height = req->dst_rect.w;
} else {
dst_width = req->dst_rect.w;
dst_height = req->dst_rect.h;
}
switch (req->dst.format) {
case MDP_Y_CRCB_H2V2:
case MDP_Y_CBCR_H2V2:
src_width = (src_width / 2) * 2;
src_height = (src_height / 2) * 2;
dst_width = (src_width / 2) * 2;
dst_height = (src_height / 2) * 2;
break;
case MDP_Y_CRCB_H2V1:
case MDP_Y_CBCR_H2V1:
case MDP_YCRYCB_H2V1:
src_width = (src_width / 2) * 2;
dst_width = (src_width / 2) * 2;
break;
default:
break;
}
if (((MDP_SCALE_Q_FACTOR * dst_width) / src_width >
MDP_MAX_X_SCALE_FACTOR)
|| ((MDP_SCALE_Q_FACTOR * dst_width) / src_width <
MDP_MIN_X_SCALE_FACTOR))
return -1;
if (((MDP_SCALE_Q_FACTOR * dst_height) / src_height >
MDP_MAX_Y_SCALE_FACTOR)
|| ((MDP_SCALE_Q_FACTOR * dst_height) / src_height <
MDP_MIN_Y_SCALE_FACTOR))
return -1;
return 0;
}
/**
* get_gem_img() - retrieve drm obj's start address and size
* @img: contains drm file descriptor and gem handle
* @start: repository of starting address of drm obj allocated memory
* @len: repository of size of drm obj alloacted memory
*
**/
int get_gem_img(struct mdp_img *img, unsigned long *start, unsigned long *len)
{
panic("waaaaaaaah");
//return kgsl_gem_obj_addr(img->memory_id, (int)img->priv, start, len);
}
int get_img(struct mdp_img *img, struct fb_info *info, unsigned long *start,
unsigned long *len, struct file **pp_file)
{
int put_needed, ret = 0;
struct file *file;
unsigned long vstart;
#ifdef CONFIG_ANDROID_PMEM
if (!get_pmem_file(img->memory_id, start, &vstart, len, pp_file))
return 0;
#endif
file = fget_light(img->memory_id, &put_needed);
if (file == NULL)
return -1;
if (MAJOR(file->f_dentry->d_inode->i_rdev) == FB_MAJOR) {
*start = info->fix.smem_start;
*len = info->fix.smem_len;
*pp_file = file;
} else {
ret = -1;
fput_light(file, put_needed);
}
return ret;
}
int mdp_ppp_blit(struct fb_info *info, struct mdp_blit_req *req,
struct file **pp_src_file, struct file **pp_dst_file)
{
unsigned long src_start, dst_start;
unsigned long src_len = 0;
unsigned long dst_len = 0;
MDPIBUF iBuf;
u32 dst_width, dst_height;
struct file *p_src_file = 0 , *p_dst_file = 0;
struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par;
if (req->dst.format == MDP_FB_FORMAT)
req->dst.format = mfd->fb_imgType;
if (req->src.format == MDP_FB_FORMAT)
req->src.format = mfd->fb_imgType;
if (req->flags & MDP_BLIT_SRC_GEM) {
if (get_gem_img(&req->src, &src_start, &src_len) < 0)
return -1;
} else {
get_img(&req->src, info, &src_start, &src_len, &p_src_file);
}
if (src_len == 0) {
printk(KERN_ERR "mdp_ppp: could not retrieve image from "
"memory\n");
return -1;
}
if (req->flags & MDP_BLIT_DST_GEM) {
if (get_gem_img(&req->dst, &dst_start, &dst_len) < 0)
return -1;
} else {
get_img(&req->dst, info, &dst_start, &dst_len, &p_dst_file);
}
if (dst_len == 0) {
printk(KERN_ERR "mdp_ppp: could not retrieve image from "
"memory\n");
return -1;
}
*pp_src_file = p_src_file;
*pp_dst_file = p_dst_file;
if (mdp_ppp_verify_req(req)) {
printk(KERN_ERR "mdp_ppp: invalid image!\n");
return -1;
}
iBuf.ibuf_width = req->dst.width;
iBuf.ibuf_height = req->dst.height;
iBuf.bpp = bytes_per_pixel[req->dst.format];
iBuf.ibuf_type = req->dst.format;
iBuf.buf = (uint8 *) dst_start;
iBuf.buf += req->dst.offset;
iBuf.roi.lcd_x = req->dst_rect.x;
iBuf.roi.lcd_y = req->dst_rect.y;
iBuf.roi.dst_width = req->dst_rect.w;
iBuf.roi.dst_height = req->dst_rect.h;
iBuf.roi.x = req->src_rect.x;
iBuf.roi.width = req->src_rect.w;
iBuf.roi.y = req->src_rect.y;
iBuf.roi.height = req->src_rect.h;
iBuf.mdpImg.width = req->src.width;
iBuf.mdpImg.imgType = req->src.format;
iBuf.mdpImg.bmy_addr = (uint32 *) (src_start + req->src.offset);
iBuf.mdpImg.cbcr_addr =
(uint32 *) ((uint32) iBuf.mdpImg.bmy_addr +
req->src.width * req->src.height);
iBuf.mdpImg.mdpOp = MDPOP_NOP;
/* blending check */
if (req->transp_mask != MDP_TRANSP_NOP) {
iBuf.mdpImg.mdpOp |= MDPOP_TRANSP;
iBuf.mdpImg.tpVal = req->transp_mask;
iBuf.mdpImg.tpVal = mdp_calc_tpval(&iBuf.mdpImg);
}
req->alpha &= 0xff;
if (req->alpha < MDP_ALPHA_NOP) {
iBuf.mdpImg.mdpOp |= MDPOP_ALPHAB;
iBuf.mdpImg.alpha = req->alpha;
}
/* rotation check */
if (req->flags & MDP_FLIP_LR)
iBuf.mdpImg.mdpOp |= MDPOP_LR;
if (req->flags & MDP_FLIP_UD)
iBuf.mdpImg.mdpOp |= MDPOP_UD;
if (req->flags & MDP_ROT_90)
iBuf.mdpImg.mdpOp |= MDPOP_ROT90;
if (req->flags & MDP_DITHER)
iBuf.mdpImg.mdpOp |= MDPOP_DITHER;
if (req->flags & MDP_BLEND_FG_PREMULT) {
#ifdef CONFIG_FB_MSM_MDP31
iBuf.mdpImg.mdpOp |= MDPOP_FG_PM_ALPHA;
#else
return -EINVAL;
#endif
}
if (req->flags & MDP_DEINTERLACE) {
#ifdef CONFIG_FB_MSM_MDP31
if ((req->src.format != MDP_Y_CBCR_H2V2) &&
(req->src.format != MDP_Y_CRCB_H2V2))
#endif
return -EINVAL;
}
/* scale check */
if (req->flags & MDP_ROT_90) {
dst_width = req->dst_rect.h;
dst_height = req->dst_rect.w;
} else {
dst_width = req->dst_rect.w;
dst_height = req->dst_rect.h;
}
if ((iBuf.roi.width != dst_width) || (iBuf.roi.height != dst_height))
iBuf.mdpImg.mdpOp |= MDPOP_ASCALE;
if (req->flags & MDP_BLUR) {
#ifdef CONFIG_FB_MSM_MDP31
if (req->flags & MDP_SHARPENING)
printk(KERN_WARNING
"mdp: MDP_SHARPENING is set with MDP_BLUR!\n");
req->flags |= MDP_SHARPENING;
req->sharpening_strength = -127;
#else
iBuf.mdpImg.mdpOp |= MDPOP_ASCALE | MDPOP_BLUR;
#endif
}
if (req->flags & MDP_SHARPENING) {
#ifdef CONFIG_FB_MSM_MDP31
if ((req->sharpening_strength > 127) ||
(req->sharpening_strength < -127)) {
printk(KERN_ERR
"%s: sharpening strength out of range\n",
__func__);
return -EINVAL;
}
iBuf.mdpImg.mdpOp |= MDPOP_ASCALE | MDPOP_SHARPENING;
iBuf.mdpImg.sp_value = req->sharpening_strength & 0xff;
#else
return -EINVAL;
#endif
}
down(&mdp_ppp_mutex);
/* MDP cmd block enable */
mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE);
#ifdef CONFIG_FB_MSM_MDP31
mdp_start_ppp(mfd, &iBuf, req, p_src_file, p_dst_file);
#else
/* bg tile fetching HW workaround */
if (((iBuf.mdpImg.mdpOp & (MDPOP_TRANSP | MDPOP_ALPHAB)) ||
(req->src.format == MDP_ARGB_8888) ||
(req->src.format == MDP_BGRA_8888) ||
(req->src.format == MDP_RGBA_8888)) &&
(iBuf.mdpImg.mdpOp & MDPOP_ROT90) && (req->dst_rect.w <= 16)) {
int dst_h, src_w, i;
src_w = req->src_rect.w;
dst_h = iBuf.roi.dst_height;
for (i = 0; i < (req->dst_rect.h / 16); i++) {
/* this tile size */
iBuf.roi.dst_height = 16;
iBuf.roi.width =
(16 * req->src_rect.w) / req->dst_rect.h;
/* if it's out of scale range... */
if (((MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) /
iBuf.roi.width) > MDP_MAX_X_SCALE_FACTOR)
iBuf.roi.width =
(MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) /
MDP_MAX_X_SCALE_FACTOR;
else if (((MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) /
iBuf.roi.width) < MDP_MIN_X_SCALE_FACTOR)
iBuf.roi.width =
(MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) /
MDP_MIN_X_SCALE_FACTOR;
mdp_start_ppp(mfd, &iBuf, req, p_src_file, p_dst_file);
/* next tile location */
iBuf.roi.lcd_y += 16;
iBuf.roi.x += iBuf.roi.width;
/* this is for a remainder update */
dst_h -= 16;
src_w -= iBuf.roi.width;
}
if ((dst_h < 0) || (src_w < 0))
printk
("msm_fb: mdp_blt_ex() unexpected result! line:%d\n",
__LINE__);
/* remainder update */
if ((dst_h > 0) && (src_w > 0)) {
u32 tmp_v;
iBuf.roi.dst_height = dst_h;
iBuf.roi.width = src_w;
if (((MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) /
iBuf.roi.width) > MDP_MAX_X_SCALE_FACTOR) {
tmp_v =
(MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) /
MDP_MAX_X_SCALE_FACTOR +
(MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) %
MDP_MAX_X_SCALE_FACTOR ? 1 : 0;
/* move x location as roi width gets bigger */
iBuf.roi.x -= tmp_v - iBuf.roi.width;
iBuf.roi.width = tmp_v;
} else
if (((MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) /
iBuf.roi.width) < MDP_MIN_X_SCALE_FACTOR) {
tmp_v =
(MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) /
MDP_MIN_X_SCALE_FACTOR +
(MDP_SCALE_Q_FACTOR * iBuf.roi.dst_height) %
MDP_MIN_X_SCALE_FACTOR ? 1 : 0;
/*
* we don't move x location for continuity of
* source image
*/
iBuf.roi.width = tmp_v;
}
mdp_start_ppp(mfd, &iBuf, req, p_src_file, p_dst_file);
}
} else {
mdp_start_ppp(mfd, &iBuf, req, p_src_file, p_dst_file);
}
#endif
/* MDP cmd block disable */
mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE);
up(&mdp_ppp_mutex);
return 0;
}
|