linux/drivers/staging/msm/mdp_ppp_v20.c
<<
>>
Prefs
   1/* Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
   2 *
   3 * This program is free software; you can redistribute it and/or modify
   4 * it under the terms of the GNU General Public License version 2 and
   5 * only version 2 as published by the Free Software Foundation.
   6 *
   7 * This program is distributed in the hope that it will be useful,
   8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10 * GNU General Public License for more details.
  11 *
  12 * You should have received a copy of the GNU General Public License
  13 * along with this program; if not, write to the Free Software
  14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15 * 02110-1301, USA.
  16 */
  17
  18#include <linux/module.h>
  19#include <linux/kernel.h>
  20#include <linux/sched.h>
  21#include <linux/time.h>
  22#include <linux/init.h>
  23#include <linux/interrupt.h>
  24#include <linux/fb.h>
  25#include "linux/proc_fs.h"
  26
  27#include <mach/hardware.h>
  28#include <linux/io.h>
  29
  30#include <asm/system.h>
  31#include <asm/mach-types.h>
  32#include <linux/semaphore.h>
  33#include <asm/div64.h>
  34
  35#include "mdp.h"
  36#include "msm_fb.h"
  37
  38static MDP_SCALE_MODE mdp_curr_up_scale_xy;
  39static MDP_SCALE_MODE mdp_curr_down_scale_x;
  40static MDP_SCALE_MODE mdp_curr_down_scale_y;
  41
  42static long long mdp_do_div(long long num, long long den)
  43{
  44        do_div(num, den);
  45        return num;
  46}
  47
  48struct mdp_table_entry mdp_gaussian_blur_table[] = {
  49        /* max variance */
  50        { 0x5fffc, 0x20000080 },
  51        { 0x50280, 0x20000080 },
  52        { 0x5fffc, 0x20000080 },
  53        { 0x50284, 0x20000080 },
  54        { 0x5fffc, 0x20000080 },
  55        { 0x50288, 0x20000080 },
  56        { 0x5fffc, 0x20000080 },
  57        { 0x5028c, 0x20000080 },
  58        { 0x5fffc, 0x20000080 },
  59        { 0x50290, 0x20000080 },
  60        { 0x5fffc, 0x20000080 },
  61        { 0x50294, 0x20000080 },
  62        { 0x5fffc, 0x20000080 },
  63        { 0x50298, 0x20000080 },
  64        { 0x5fffc, 0x20000080 },
  65        { 0x5029c, 0x20000080 },
  66        { 0x5fffc, 0x20000080 },
  67        { 0x502a0, 0x20000080 },
  68        { 0x5fffc, 0x20000080 },
  69        { 0x502a4, 0x20000080 },
  70        { 0x5fffc, 0x20000080 },
  71        { 0x502a8, 0x20000080 },
  72        { 0x5fffc, 0x20000080 },
  73        { 0x502ac, 0x20000080 },
  74        { 0x5fffc, 0x20000080 },
  75        { 0x502b0, 0x20000080 },
  76        { 0x5fffc, 0x20000080 },
  77        { 0x502b4, 0x20000080 },
  78        { 0x5fffc, 0x20000080 },
  79        { 0x502b8, 0x20000080 },
  80        { 0x5fffc, 0x20000080 },
  81        { 0x502bc, 0x20000080 },
  82        { 0x5fffc, 0x20000080 },
  83        { 0x502c0, 0x20000080 },
  84        { 0x5fffc, 0x20000080 },
  85        { 0x502c4, 0x20000080 },
  86        { 0x5fffc, 0x20000080 },
  87        { 0x502c8, 0x20000080 },
  88        { 0x5fffc, 0x20000080 },
  89        { 0x502cc, 0x20000080 },
  90        { 0x5fffc, 0x20000080 },
  91        { 0x502d0, 0x20000080 },
  92        { 0x5fffc, 0x20000080 },
  93        { 0x502d4, 0x20000080 },
  94        { 0x5fffc, 0x20000080 },
  95        { 0x502d8, 0x20000080 },
  96        { 0x5fffc, 0x20000080 },
  97        { 0x502dc, 0x20000080 },
  98        { 0x5fffc, 0x20000080 },
  99        { 0x502e0, 0x20000080 },
 100        { 0x5fffc, 0x20000080 },
 101        { 0x502e4, 0x20000080 },
 102        { 0x5fffc, 0x20000080 },
 103        { 0x502e8, 0x20000080 },
 104        { 0x5fffc, 0x20000080 },
 105        { 0x502ec, 0x20000080 },
 106        { 0x5fffc, 0x20000080 },
 107        { 0x502f0, 0x20000080 },
 108        { 0x5fffc, 0x20000080 },
 109        { 0x502f4, 0x20000080 },
 110        { 0x5fffc, 0x20000080 },
 111        { 0x502f8, 0x20000080 },
 112        { 0x5fffc, 0x20000080 },
 113        { 0x502fc, 0x20000080 },
 114        { 0x5fffc, 0x20000080 },
 115        { 0x50300, 0x20000080 },
 116        { 0x5fffc, 0x20000080 },
 117        { 0x50304, 0x20000080 },
 118        { 0x5fffc, 0x20000080 },
 119        { 0x50308, 0x20000080 },
 120        { 0x5fffc, 0x20000080 },
 121        { 0x5030c, 0x20000080 },
 122        { 0x5fffc, 0x20000080 },
 123        { 0x50310, 0x20000080 },
 124        { 0x5fffc, 0x20000080 },
 125        { 0x50314, 0x20000080 },
 126        { 0x5fffc, 0x20000080 },
 127        { 0x50318, 0x20000080 },
 128        { 0x5fffc, 0x20000080 },
 129        { 0x5031c, 0x20000080 },
 130        { 0x5fffc, 0x20000080 },
 131        { 0x50320, 0x20000080 },
 132        { 0x5fffc, 0x20000080 },
 133        { 0x50324, 0x20000080 },
 134        { 0x5fffc, 0x20000080 },
 135        { 0x50328, 0x20000080 },
 136        { 0x5fffc, 0x20000080 },
 137        { 0x5032c, 0x20000080 },
 138        { 0x5fffc, 0x20000080 },
 139        { 0x50330, 0x20000080 },
 140        { 0x5fffc, 0x20000080 },
 141        { 0x50334, 0x20000080 },
 142        { 0x5fffc, 0x20000080 },
 143        { 0x50338, 0x20000080 },
 144        { 0x5fffc, 0x20000080 },
 145        { 0x5033c, 0x20000080 },
 146        { 0x5fffc, 0x20000080 },
 147        { 0x50340, 0x20000080 },
 148        { 0x5fffc, 0x20000080 },
 149        { 0x50344, 0x20000080 },
 150        { 0x5fffc, 0x20000080 },
 151        { 0x50348, 0x20000080 },
 152        { 0x5fffc, 0x20000080 },
 153        { 0x5034c, 0x20000080 },
 154        { 0x5fffc, 0x20000080 },
 155        { 0x50350, 0x20000080 },
 156        { 0x5fffc, 0x20000080 },
 157        { 0x50354, 0x20000080 },
 158        { 0x5fffc, 0x20000080 },
 159        { 0x50358, 0x20000080 },
 160        { 0x5fffc, 0x20000080 },
 161        { 0x5035c, 0x20000080 },
 162        { 0x5fffc, 0x20000080 },
 163        { 0x50360, 0x20000080 },
 164        { 0x5fffc, 0x20000080 },
 165        { 0x50364, 0x20000080 },
 166        { 0x5fffc, 0x20000080 },
 167        { 0x50368, 0x20000080 },
 168        { 0x5fffc, 0x20000080 },
 169        { 0x5036c, 0x20000080 },
 170        { 0x5fffc, 0x20000080 },
 171        { 0x50370, 0x20000080 },
 172        { 0x5fffc, 0x20000080 },
 173        { 0x50374, 0x20000080 },
 174        { 0x5fffc, 0x20000080 },
 175        { 0x50378, 0x20000080 },
 176        { 0x5fffc, 0x20000080 },
 177        { 0x5037c, 0x20000080 },
 178};
 179
 180static void load_scale_table(
 181        struct mdp_table_entry *table, int len)
 182{
 183        int i;
 184        for (i = 0; i < len; i++)
 185                MDP_OUTP(MDP_BASE + table[i].reg, table[i].val);
 186}
 187
 188static void mdp_load_pr_upscale_table(void)
 189{
 190        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 191        MDP_OUTP(MDP_BASE + 0x50200, 0x7fc00000);
 192        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 193        MDP_OUTP(MDP_BASE + 0x50204, 0x7fc00000);
 194        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 195        MDP_OUTP(MDP_BASE + 0x50208, 0x7fc00000);
 196        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 197        MDP_OUTP(MDP_BASE + 0x5020c, 0x7fc00000);
 198        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 199        MDP_OUTP(MDP_BASE + 0x50210, 0x7fc00000);
 200        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 201        MDP_OUTP(MDP_BASE + 0x50214, 0x7fc00000);
 202        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 203        MDP_OUTP(MDP_BASE + 0x50218, 0x7fc00000);
 204        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 205        MDP_OUTP(MDP_BASE + 0x5021c, 0x7fc00000);
 206        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 207        MDP_OUTP(MDP_BASE + 0x50220, 0x7fc00000);
 208        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 209        MDP_OUTP(MDP_BASE + 0x50224, 0x7fc00000);
 210        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 211        MDP_OUTP(MDP_BASE + 0x50228, 0x7fc00000);
 212        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 213        MDP_OUTP(MDP_BASE + 0x5022c, 0x7fc00000);
 214        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 215        MDP_OUTP(MDP_BASE + 0x50230, 0x7fc00000);
 216        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 217        MDP_OUTP(MDP_BASE + 0x50234, 0x7fc00000);
 218        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 219        MDP_OUTP(MDP_BASE + 0x50238, 0x7fc00000);
 220        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 221        MDP_OUTP(MDP_BASE + 0x5023c, 0x7fc00000);
 222        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 223        MDP_OUTP(MDP_BASE + 0x50240, 0x0);
 224        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 225        MDP_OUTP(MDP_BASE + 0x50244, 0x0);
 226        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 227        MDP_OUTP(MDP_BASE + 0x50248, 0x0);
 228        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 229        MDP_OUTP(MDP_BASE + 0x5024c, 0x0);
 230        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 231        MDP_OUTP(MDP_BASE + 0x50250, 0x0);
 232        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 233        MDP_OUTP(MDP_BASE + 0x50254, 0x0);
 234        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 235        MDP_OUTP(MDP_BASE + 0x50258, 0x0);
 236        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 237        MDP_OUTP(MDP_BASE + 0x5025c, 0x0);
 238        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 239        MDP_OUTP(MDP_BASE + 0x50260, 0x0);
 240        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 241        MDP_OUTP(MDP_BASE + 0x50264, 0x0);
 242        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 243        MDP_OUTP(MDP_BASE + 0x50268, 0x0);
 244        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 245        MDP_OUTP(MDP_BASE + 0x5026c, 0x0);
 246        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 247        MDP_OUTP(MDP_BASE + 0x50270, 0x0);
 248        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 249        MDP_OUTP(MDP_BASE + 0x50274, 0x0);
 250        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 251        MDP_OUTP(MDP_BASE + 0x50278, 0x0);
 252        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 253        MDP_OUTP(MDP_BASE + 0x5027c, 0x0);
 254}
 255
 256static void mdp_load_pr_downscale_table_x_point2TOpoint4(void)
 257{
 258        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 259        MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000);
 260        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 261        MDP_OUTP(MDP_BASE + 0x50284, 0x7fc00000);
 262        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 263        MDP_OUTP(MDP_BASE + 0x50288, 0x7fc00000);
 264        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 265        MDP_OUTP(MDP_BASE + 0x5028c, 0x7fc00000);
 266        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 267        MDP_OUTP(MDP_BASE + 0x50290, 0x7fc00000);
 268        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 269        MDP_OUTP(MDP_BASE + 0x50294, 0x7fc00000);
 270        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 271        MDP_OUTP(MDP_BASE + 0x50298, 0x7fc00000);
 272        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 273        MDP_OUTP(MDP_BASE + 0x5029c, 0x7fc00000);
 274        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 275        MDP_OUTP(MDP_BASE + 0x502a0, 0x7fc00000);
 276        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 277        MDP_OUTP(MDP_BASE + 0x502a4, 0x7fc00000);
 278        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 279        MDP_OUTP(MDP_BASE + 0x502a8, 0x7fc00000);
 280        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 281        MDP_OUTP(MDP_BASE + 0x502ac, 0x7fc00000);
 282        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 283        MDP_OUTP(MDP_BASE + 0x502b0, 0x7fc00000);
 284        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 285        MDP_OUTP(MDP_BASE + 0x502b4, 0x7fc00000);
 286        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 287        MDP_OUTP(MDP_BASE + 0x502b8, 0x7fc00000);
 288        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 289        MDP_OUTP(MDP_BASE + 0x502bc, 0x7fc00000);
 290        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 291        MDP_OUTP(MDP_BASE + 0x502c0, 0x0);
 292        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 293        MDP_OUTP(MDP_BASE + 0x502c4, 0x0);
 294        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 295        MDP_OUTP(MDP_BASE + 0x502c8, 0x0);
 296        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 297        MDP_OUTP(MDP_BASE + 0x502cc, 0x0);
 298        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 299        MDP_OUTP(MDP_BASE + 0x502d0, 0x0);
 300        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 301        MDP_OUTP(MDP_BASE + 0x502d4, 0x0);
 302        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 303        MDP_OUTP(MDP_BASE + 0x502d8, 0x0);
 304        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 305        MDP_OUTP(MDP_BASE + 0x502dc, 0x0);
 306        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 307        MDP_OUTP(MDP_BASE + 0x502e0, 0x0);
 308        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 309        MDP_OUTP(MDP_BASE + 0x502e4, 0x0);
 310        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 311        MDP_OUTP(MDP_BASE + 0x502e8, 0x0);
 312        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 313        MDP_OUTP(MDP_BASE + 0x502ec, 0x0);
 314        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 315        MDP_OUTP(MDP_BASE + 0x502f0, 0x0);
 316        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 317        MDP_OUTP(MDP_BASE + 0x502f4, 0x0);
 318        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 319        MDP_OUTP(MDP_BASE + 0x502f8, 0x0);
 320        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 321        MDP_OUTP(MDP_BASE + 0x502fc, 0x0);
 322}
 323
 324static void mdp_load_pr_downscale_table_y_point2TOpoint4(void)
 325{
 326        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 327        MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000);
 328        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 329        MDP_OUTP(MDP_BASE + 0x50304, 0x7fc00000);
 330        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 331        MDP_OUTP(MDP_BASE + 0x50308, 0x7fc00000);
 332        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 333        MDP_OUTP(MDP_BASE + 0x5030c, 0x7fc00000);
 334        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 335        MDP_OUTP(MDP_BASE + 0x50310, 0x7fc00000);
 336        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 337        MDP_OUTP(MDP_BASE + 0x50314, 0x7fc00000);
 338        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 339        MDP_OUTP(MDP_BASE + 0x50318, 0x7fc00000);
 340        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 341        MDP_OUTP(MDP_BASE + 0x5031c, 0x7fc00000);
 342        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 343        MDP_OUTP(MDP_BASE + 0x50320, 0x7fc00000);
 344        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 345        MDP_OUTP(MDP_BASE + 0x50324, 0x7fc00000);
 346        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 347        MDP_OUTP(MDP_BASE + 0x50328, 0x7fc00000);
 348        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 349        MDP_OUTP(MDP_BASE + 0x5032c, 0x7fc00000);
 350        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 351        MDP_OUTP(MDP_BASE + 0x50330, 0x7fc00000);
 352        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 353        MDP_OUTP(MDP_BASE + 0x50334, 0x7fc00000);
 354        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 355        MDP_OUTP(MDP_BASE + 0x50338, 0x7fc00000);
 356        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 357        MDP_OUTP(MDP_BASE + 0x5033c, 0x7fc00000);
 358        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 359        MDP_OUTP(MDP_BASE + 0x50340, 0x0);
 360        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 361        MDP_OUTP(MDP_BASE + 0x50344, 0x0);
 362        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 363        MDP_OUTP(MDP_BASE + 0x50348, 0x0);
 364        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 365        MDP_OUTP(MDP_BASE + 0x5034c, 0x0);
 366        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 367        MDP_OUTP(MDP_BASE + 0x50350, 0x0);
 368        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 369        MDP_OUTP(MDP_BASE + 0x50354, 0x0);
 370        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 371        MDP_OUTP(MDP_BASE + 0x50358, 0x0);
 372        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 373        MDP_OUTP(MDP_BASE + 0x5035c, 0x0);
 374        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 375        MDP_OUTP(MDP_BASE + 0x50360, 0x0);
 376        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 377        MDP_OUTP(MDP_BASE + 0x50364, 0x0);
 378        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 379        MDP_OUTP(MDP_BASE + 0x50368, 0x0);
 380        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 381        MDP_OUTP(MDP_BASE + 0x5036c, 0x0);
 382        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 383        MDP_OUTP(MDP_BASE + 0x50370, 0x0);
 384        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 385        MDP_OUTP(MDP_BASE + 0x50374, 0x0);
 386        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 387        MDP_OUTP(MDP_BASE + 0x50378, 0x0);
 388        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 389        MDP_OUTP(MDP_BASE + 0x5037c, 0x0);
 390}
 391
 392static void mdp_load_pr_downscale_table_x_point4TOpoint6(void)
 393{
 394        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 395        MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000);
 396        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 397        MDP_OUTP(MDP_BASE + 0x50284, 0x7fc00000);
 398        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 399        MDP_OUTP(MDP_BASE + 0x50288, 0x7fc00000);
 400        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 401        MDP_OUTP(MDP_BASE + 0x5028c, 0x7fc00000);
 402        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 403        MDP_OUTP(MDP_BASE + 0x50290, 0x7fc00000);
 404        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 405        MDP_OUTP(MDP_BASE + 0x50294, 0x7fc00000);
 406        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 407        MDP_OUTP(MDP_BASE + 0x50298, 0x7fc00000);
 408        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 409        MDP_OUTP(MDP_BASE + 0x5029c, 0x7fc00000);
 410        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 411        MDP_OUTP(MDP_BASE + 0x502a0, 0x7fc00000);
 412        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 413        MDP_OUTP(MDP_BASE + 0x502a4, 0x7fc00000);
 414        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 415        MDP_OUTP(MDP_BASE + 0x502a8, 0x7fc00000);
 416        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 417        MDP_OUTP(MDP_BASE + 0x502ac, 0x7fc00000);
 418        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 419        MDP_OUTP(MDP_BASE + 0x502b0, 0x7fc00000);
 420        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 421        MDP_OUTP(MDP_BASE + 0x502b4, 0x7fc00000);
 422        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 423        MDP_OUTP(MDP_BASE + 0x502b8, 0x7fc00000);
 424        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 425        MDP_OUTP(MDP_BASE + 0x502bc, 0x7fc00000);
 426        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 427        MDP_OUTP(MDP_BASE + 0x502c0, 0x0);
 428        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 429        MDP_OUTP(MDP_BASE + 0x502c4, 0x0);
 430        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 431        MDP_OUTP(MDP_BASE + 0x502c8, 0x0);
 432        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 433        MDP_OUTP(MDP_BASE + 0x502cc, 0x0);
 434        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 435        MDP_OUTP(MDP_BASE + 0x502d0, 0x0);
 436        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 437        MDP_OUTP(MDP_BASE + 0x502d4, 0x0);
 438        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 439        MDP_OUTP(MDP_BASE + 0x502d8, 0x0);
 440        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 441        MDP_OUTP(MDP_BASE + 0x502dc, 0x0);
 442        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 443        MDP_OUTP(MDP_BASE + 0x502e0, 0x0);
 444        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 445        MDP_OUTP(MDP_BASE + 0x502e4, 0x0);
 446        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 447        MDP_OUTP(MDP_BASE + 0x502e8, 0x0);
 448        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 449        MDP_OUTP(MDP_BASE + 0x502ec, 0x0);
 450        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 451        MDP_OUTP(MDP_BASE + 0x502f0, 0x0);
 452        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 453        MDP_OUTP(MDP_BASE + 0x502f4, 0x0);
 454        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 455        MDP_OUTP(MDP_BASE + 0x502f8, 0x0);
 456        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 457        MDP_OUTP(MDP_BASE + 0x502fc, 0x0);
 458}
 459
 460static void mdp_load_pr_downscale_table_y_point4TOpoint6(void)
 461{
 462        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 463        MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000);
 464        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 465        MDP_OUTP(MDP_BASE + 0x50304, 0x7fc00000);
 466        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 467        MDP_OUTP(MDP_BASE + 0x50308, 0x7fc00000);
 468        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 469        MDP_OUTP(MDP_BASE + 0x5030c, 0x7fc00000);
 470        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 471        MDP_OUTP(MDP_BASE + 0x50310, 0x7fc00000);
 472        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 473        MDP_OUTP(MDP_BASE + 0x50314, 0x7fc00000);
 474        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 475        MDP_OUTP(MDP_BASE + 0x50318, 0x7fc00000);
 476        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 477        MDP_OUTP(MDP_BASE + 0x5031c, 0x7fc00000);
 478        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 479        MDP_OUTP(MDP_BASE + 0x50320, 0x7fc00000);
 480        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 481        MDP_OUTP(MDP_BASE + 0x50324, 0x7fc00000);
 482        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 483        MDP_OUTP(MDP_BASE + 0x50328, 0x7fc00000);
 484        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 485        MDP_OUTP(MDP_BASE + 0x5032c, 0x7fc00000);
 486        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 487        MDP_OUTP(MDP_BASE + 0x50330, 0x7fc00000);
 488        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 489        MDP_OUTP(MDP_BASE + 0x50334, 0x7fc00000);
 490        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 491        MDP_OUTP(MDP_BASE + 0x50338, 0x7fc00000);
 492        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 493        MDP_OUTP(MDP_BASE + 0x5033c, 0x7fc00000);
 494        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 495        MDP_OUTP(MDP_BASE + 0x50340, 0x0);
 496        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 497        MDP_OUTP(MDP_BASE + 0x50344, 0x0);
 498        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 499        MDP_OUTP(MDP_BASE + 0x50348, 0x0);
 500        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 501        MDP_OUTP(MDP_BASE + 0x5034c, 0x0);
 502        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 503        MDP_OUTP(MDP_BASE + 0x50350, 0x0);
 504        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 505        MDP_OUTP(MDP_BASE + 0x50354, 0x0);
 506        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 507        MDP_OUTP(MDP_BASE + 0x50358, 0x0);
 508        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 509        MDP_OUTP(MDP_BASE + 0x5035c, 0x0);
 510        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 511        MDP_OUTP(MDP_BASE + 0x50360, 0x0);
 512        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 513        MDP_OUTP(MDP_BASE + 0x50364, 0x0);
 514        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 515        MDP_OUTP(MDP_BASE + 0x50368, 0x0);
 516        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 517        MDP_OUTP(MDP_BASE + 0x5036c, 0x0);
 518        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 519        MDP_OUTP(MDP_BASE + 0x50370, 0x0);
 520        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 521        MDP_OUTP(MDP_BASE + 0x50374, 0x0);
 522        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 523        MDP_OUTP(MDP_BASE + 0x50378, 0x0);
 524        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 525        MDP_OUTP(MDP_BASE + 0x5037c, 0x0);
 526}
 527
 528static void mdp_load_pr_downscale_table_x_point6TOpoint8(void)
 529{
 530        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 531        MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000);
 532        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 533        MDP_OUTP(MDP_BASE + 0x50284, 0x7fc00000);
 534        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 535        MDP_OUTP(MDP_BASE + 0x50288, 0x7fc00000);
 536        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 537        MDP_OUTP(MDP_BASE + 0x5028c, 0x7fc00000);
 538        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 539        MDP_OUTP(MDP_BASE + 0x50290, 0x7fc00000);
 540        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 541        MDP_OUTP(MDP_BASE + 0x50294, 0x7fc00000);
 542        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 543        MDP_OUTP(MDP_BASE + 0x50298, 0x7fc00000);
 544        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 545        MDP_OUTP(MDP_BASE + 0x5029c, 0x7fc00000);
 546        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 547        MDP_OUTP(MDP_BASE + 0x502a0, 0x7fc00000);
 548        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 549        MDP_OUTP(MDP_BASE + 0x502a4, 0x7fc00000);
 550        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 551        MDP_OUTP(MDP_BASE + 0x502a8, 0x7fc00000);
 552        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 553        MDP_OUTP(MDP_BASE + 0x502ac, 0x7fc00000);
 554        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 555        MDP_OUTP(MDP_BASE + 0x502b0, 0x7fc00000);
 556        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 557        MDP_OUTP(MDP_BASE + 0x502b4, 0x7fc00000);
 558        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 559        MDP_OUTP(MDP_BASE + 0x502b8, 0x7fc00000);
 560        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 561        MDP_OUTP(MDP_BASE + 0x502bc, 0x7fc00000);
 562        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 563        MDP_OUTP(MDP_BASE + 0x502c0, 0x0);
 564        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 565        MDP_OUTP(MDP_BASE + 0x502c4, 0x0);
 566        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 567        MDP_OUTP(MDP_BASE + 0x502c8, 0x0);
 568        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 569        MDP_OUTP(MDP_BASE + 0x502cc, 0x0);
 570        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 571        MDP_OUTP(MDP_BASE + 0x502d0, 0x0);
 572        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 573        MDP_OUTP(MDP_BASE + 0x502d4, 0x0);
 574        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 575        MDP_OUTP(MDP_BASE + 0x502d8, 0x0);
 576        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 577        MDP_OUTP(MDP_BASE + 0x502dc, 0x0);
 578        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 579        MDP_OUTP(MDP_BASE + 0x502e0, 0x0);
 580        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 581        MDP_OUTP(MDP_BASE + 0x502e4, 0x0);
 582        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 583        MDP_OUTP(MDP_BASE + 0x502e8, 0x0);
 584        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 585        MDP_OUTP(MDP_BASE + 0x502ec, 0x0);
 586        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 587        MDP_OUTP(MDP_BASE + 0x502f0, 0x0);
 588        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 589        MDP_OUTP(MDP_BASE + 0x502f4, 0x0);
 590        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 591        MDP_OUTP(MDP_BASE + 0x502f8, 0x0);
 592        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 593        MDP_OUTP(MDP_BASE + 0x502fc, 0x0);
 594}
 595
 596static void mdp_load_pr_downscale_table_y_point6TOpoint8(void)
 597{
 598        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 599        MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000);
 600        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 601        MDP_OUTP(MDP_BASE + 0x50304, 0x7fc00000);
 602        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 603        MDP_OUTP(MDP_BASE + 0x50308, 0x7fc00000);
 604        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 605        MDP_OUTP(MDP_BASE + 0x5030c, 0x7fc00000);
 606        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 607        MDP_OUTP(MDP_BASE + 0x50310, 0x7fc00000);
 608        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 609        MDP_OUTP(MDP_BASE + 0x50314, 0x7fc00000);
 610        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 611        MDP_OUTP(MDP_BASE + 0x50318, 0x7fc00000);
 612        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 613        MDP_OUTP(MDP_BASE + 0x5031c, 0x7fc00000);
 614        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 615        MDP_OUTP(MDP_BASE + 0x50320, 0x7fc00000);
 616        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 617        MDP_OUTP(MDP_BASE + 0x50324, 0x7fc00000);
 618        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 619        MDP_OUTP(MDP_BASE + 0x50328, 0x7fc00000);
 620        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 621        MDP_OUTP(MDP_BASE + 0x5032c, 0x7fc00000);
 622        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 623        MDP_OUTP(MDP_BASE + 0x50330, 0x7fc00000);
 624        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 625        MDP_OUTP(MDP_BASE + 0x50334, 0x7fc00000);
 626        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 627        MDP_OUTP(MDP_BASE + 0x50338, 0x7fc00000);
 628        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 629        MDP_OUTP(MDP_BASE + 0x5033c, 0x7fc00000);
 630        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 631        MDP_OUTP(MDP_BASE + 0x50340, 0x0);
 632        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 633        MDP_OUTP(MDP_BASE + 0x50344, 0x0);
 634        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 635        MDP_OUTP(MDP_BASE + 0x50348, 0x0);
 636        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 637        MDP_OUTP(MDP_BASE + 0x5034c, 0x0);
 638        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 639        MDP_OUTP(MDP_BASE + 0x50350, 0x0);
 640        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 641        MDP_OUTP(MDP_BASE + 0x50354, 0x0);
 642        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 643        MDP_OUTP(MDP_BASE + 0x50358, 0x0);
 644        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 645        MDP_OUTP(MDP_BASE + 0x5035c, 0x0);
 646        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 647        MDP_OUTP(MDP_BASE + 0x50360, 0x0);
 648        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 649        MDP_OUTP(MDP_BASE + 0x50364, 0x0);
 650        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 651        MDP_OUTP(MDP_BASE + 0x50368, 0x0);
 652        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 653        MDP_OUTP(MDP_BASE + 0x5036c, 0x0);
 654        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 655        MDP_OUTP(MDP_BASE + 0x50370, 0x0);
 656        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 657        MDP_OUTP(MDP_BASE + 0x50374, 0x0);
 658        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 659        MDP_OUTP(MDP_BASE + 0x50378, 0x0);
 660        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 661        MDP_OUTP(MDP_BASE + 0x5037c, 0x0);
 662}
 663
 664static void mdp_load_pr_downscale_table_x_point8TO1(void)
 665{
 666        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 667        MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000);
 668        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 669        MDP_OUTP(MDP_BASE + 0x50284, 0x7fc00000);
 670        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 671        MDP_OUTP(MDP_BASE + 0x50288, 0x7fc00000);
 672        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 673        MDP_OUTP(MDP_BASE + 0x5028c, 0x7fc00000);
 674        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 675        MDP_OUTP(MDP_BASE + 0x50290, 0x7fc00000);
 676        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 677        MDP_OUTP(MDP_BASE + 0x50294, 0x7fc00000);
 678        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 679        MDP_OUTP(MDP_BASE + 0x50298, 0x7fc00000);
 680        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 681        MDP_OUTP(MDP_BASE + 0x5029c, 0x7fc00000);
 682        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 683        MDP_OUTP(MDP_BASE + 0x502a0, 0x7fc00000);
 684        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 685        MDP_OUTP(MDP_BASE + 0x502a4, 0x7fc00000);
 686        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 687        MDP_OUTP(MDP_BASE + 0x502a8, 0x7fc00000);
 688        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 689        MDP_OUTP(MDP_BASE + 0x502ac, 0x7fc00000);
 690        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 691        MDP_OUTP(MDP_BASE + 0x502b0, 0x7fc00000);
 692        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 693        MDP_OUTP(MDP_BASE + 0x502b4, 0x7fc00000);
 694        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 695        MDP_OUTP(MDP_BASE + 0x502b8, 0x7fc00000);
 696        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 697        MDP_OUTP(MDP_BASE + 0x502bc, 0x7fc00000);
 698        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 699        MDP_OUTP(MDP_BASE + 0x502c0, 0x0);
 700        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 701        MDP_OUTP(MDP_BASE + 0x502c4, 0x0);
 702        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 703        MDP_OUTP(MDP_BASE + 0x502c8, 0x0);
 704        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 705        MDP_OUTP(MDP_BASE + 0x502cc, 0x0);
 706        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 707        MDP_OUTP(MDP_BASE + 0x502d0, 0x0);
 708        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 709        MDP_OUTP(MDP_BASE + 0x502d4, 0x0);
 710        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 711        MDP_OUTP(MDP_BASE + 0x502d8, 0x0);
 712        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 713        MDP_OUTP(MDP_BASE + 0x502dc, 0x0);
 714        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 715        MDP_OUTP(MDP_BASE + 0x502e0, 0x0);
 716        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 717        MDP_OUTP(MDP_BASE + 0x502e4, 0x0);
 718        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 719        MDP_OUTP(MDP_BASE + 0x502e8, 0x0);
 720        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 721        MDP_OUTP(MDP_BASE + 0x502ec, 0x0);
 722        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 723        MDP_OUTP(MDP_BASE + 0x502f0, 0x0);
 724        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 725        MDP_OUTP(MDP_BASE + 0x502f4, 0x0);
 726        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 727        MDP_OUTP(MDP_BASE + 0x502f8, 0x0);
 728        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 729        MDP_OUTP(MDP_BASE + 0x502fc, 0x0);
 730}
 731
 732static void mdp_load_pr_downscale_table_y_point8TO1(void)
 733{
 734        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 735        MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000);
 736        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 737        MDP_OUTP(MDP_BASE + 0x50304, 0x7fc00000);
 738        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 739        MDP_OUTP(MDP_BASE + 0x50308, 0x7fc00000);
 740        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 741        MDP_OUTP(MDP_BASE + 0x5030c, 0x7fc00000);
 742        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 743        MDP_OUTP(MDP_BASE + 0x50310, 0x7fc00000);
 744        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 745        MDP_OUTP(MDP_BASE + 0x50314, 0x7fc00000);
 746        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 747        MDP_OUTP(MDP_BASE + 0x50318, 0x7fc00000);
 748        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 749        MDP_OUTP(MDP_BASE + 0x5031c, 0x7fc00000);
 750        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 751        MDP_OUTP(MDP_BASE + 0x50320, 0x7fc00000);
 752        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 753        MDP_OUTP(MDP_BASE + 0x50324, 0x7fc00000);
 754        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 755        MDP_OUTP(MDP_BASE + 0x50328, 0x7fc00000);
 756        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 757        MDP_OUTP(MDP_BASE + 0x5032c, 0x7fc00000);
 758        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 759        MDP_OUTP(MDP_BASE + 0x50330, 0x7fc00000);
 760        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 761        MDP_OUTP(MDP_BASE + 0x50334, 0x7fc00000);
 762        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 763        MDP_OUTP(MDP_BASE + 0x50338, 0x7fc00000);
 764        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 765        MDP_OUTP(MDP_BASE + 0x5033c, 0x7fc00000);
 766        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 767        MDP_OUTP(MDP_BASE + 0x50340, 0x0);
 768        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 769        MDP_OUTP(MDP_BASE + 0x50344, 0x0);
 770        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 771        MDP_OUTP(MDP_BASE + 0x50348, 0x0);
 772        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 773        MDP_OUTP(MDP_BASE + 0x5034c, 0x0);
 774        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 775        MDP_OUTP(MDP_BASE + 0x50350, 0x0);
 776        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 777        MDP_OUTP(MDP_BASE + 0x50354, 0x0);
 778        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 779        MDP_OUTP(MDP_BASE + 0x50358, 0x0);
 780        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 781        MDP_OUTP(MDP_BASE + 0x5035c, 0x0);
 782        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 783        MDP_OUTP(MDP_BASE + 0x50360, 0x0);
 784        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 785        MDP_OUTP(MDP_BASE + 0x50364, 0x0);
 786        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 787        MDP_OUTP(MDP_BASE + 0x50368, 0x0);
 788        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 789        MDP_OUTP(MDP_BASE + 0x5036c, 0x0);
 790        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 791        MDP_OUTP(MDP_BASE + 0x50370, 0x0);
 792        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 793        MDP_OUTP(MDP_BASE + 0x50374, 0x0);
 794        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 795        MDP_OUTP(MDP_BASE + 0x50378, 0x0);
 796        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff);
 797        MDP_OUTP(MDP_BASE + 0x5037c, 0x0);
 798}
 799
 800static void mdp_load_bc_upscale_table(void)
 801{
 802        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
 803        MDP_OUTP(MDP_BASE + 0x50200, 0x7fc00000);
 804        MDP_OUTP(MDP_BASE + 0x5fffc, 0xff80000d);
 805        MDP_OUTP(MDP_BASE + 0x50204, 0x7ec003f9);
 806        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec0001c);
 807        MDP_OUTP(MDP_BASE + 0x50208, 0x7d4003f3);
 808        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40002b);
 809        MDP_OUTP(MDP_BASE + 0x5020c, 0x7b8003ed);
 810        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfd80003c);
 811        MDP_OUTP(MDP_BASE + 0x50210, 0x794003e8);
 812        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc0004d);
 813        MDP_OUTP(MDP_BASE + 0x50214, 0x76c003e4);
 814        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfc40005f);
 815        MDP_OUTP(MDP_BASE + 0x50218, 0x73c003e0);
 816        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb800071);
 817        MDP_OUTP(MDP_BASE + 0x5021c, 0x708003de);
 818        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfac00085);
 819        MDP_OUTP(MDP_BASE + 0x50220, 0x6d0003db);
 820        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa000098);
 821        MDP_OUTP(MDP_BASE + 0x50224, 0x698003d9);
 822        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf98000ac);
 823        MDP_OUTP(MDP_BASE + 0x50228, 0x654003d8);
 824        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8c000c1);
 825        MDP_OUTP(MDP_BASE + 0x5022c, 0x610003d7);
 826        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf84000d5);
 827        MDP_OUTP(MDP_BASE + 0x50230, 0x5c8003d7);
 828        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf7c000e9);
 829        MDP_OUTP(MDP_BASE + 0x50234, 0x580003d7);
 830        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf74000fd);
 831        MDP_OUTP(MDP_BASE + 0x50238, 0x534003d8);
 832        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c00112);
 833        MDP_OUTP(MDP_BASE + 0x5023c, 0x4e8003d8);
 834        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6800126);
 835        MDP_OUTP(MDP_BASE + 0x50240, 0x494003da);
 836        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600013a);
 837        MDP_OUTP(MDP_BASE + 0x50244, 0x448003db);
 838        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600014d);
 839        MDP_OUTP(MDP_BASE + 0x50248, 0x3f4003dd);
 840        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00160);
 841        MDP_OUTP(MDP_BASE + 0x5024c, 0x3a4003df);
 842        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00172);
 843        MDP_OUTP(MDP_BASE + 0x50250, 0x354003e1);
 844        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00184);
 845        MDP_OUTP(MDP_BASE + 0x50254, 0x304003e3);
 846        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6000195);
 847        MDP_OUTP(MDP_BASE + 0x50258, 0x2b0003e6);
 848        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf64001a6);
 849        MDP_OUTP(MDP_BASE + 0x5025c, 0x260003e8);
 850        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c001b4);
 851        MDP_OUTP(MDP_BASE + 0x50260, 0x214003eb);
 852        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf78001c2);
 853        MDP_OUTP(MDP_BASE + 0x50264, 0x1c4003ee);
 854        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf80001cf);
 855        MDP_OUTP(MDP_BASE + 0x50268, 0x17c003f1);
 856        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf90001db);
 857        MDP_OUTP(MDP_BASE + 0x5026c, 0x134003f3);
 858        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa0001e5);
 859        MDP_OUTP(MDP_BASE + 0x50270, 0xf0003f6);
 860        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb4001ee);
 861        MDP_OUTP(MDP_BASE + 0x50274, 0xac003f9);
 862        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc001f5);
 863        MDP_OUTP(MDP_BASE + 0x50278, 0x70003fb);
 864        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe4001fb);
 865        MDP_OUTP(MDP_BASE + 0x5027c, 0x34003fe);
 866}
 867
 868static void mdp_load_bc_downscale_table_x_point2TOpoint4(void)
 869{
 870        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ac00084);
 871        MDP_OUTP(MDP_BASE + 0x50280, 0x23400083);
 872        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b000084);
 873        MDP_OUTP(MDP_BASE + 0x50284, 0x23000083);
 874        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b400084);
 875        MDP_OUTP(MDP_BASE + 0x50288, 0x23000082);
 876        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b400085);
 877        MDP_OUTP(MDP_BASE + 0x5028c, 0x23000081);
 878        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b800085);
 879        MDP_OUTP(MDP_BASE + 0x50290, 0x23000080);
 880        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1bc00086);
 881        MDP_OUTP(MDP_BASE + 0x50294, 0x22c0007f);
 882        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c000086);
 883        MDP_OUTP(MDP_BASE + 0x50298, 0x2280007f);
 884        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c400086);
 885        MDP_OUTP(MDP_BASE + 0x5029c, 0x2280007e);
 886        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c800086);
 887        MDP_OUTP(MDP_BASE + 0x502a0, 0x2280007d);
 888        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc00086);
 889        MDP_OUTP(MDP_BASE + 0x502a4, 0x2240007d);
 890        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc00087);
 891        MDP_OUTP(MDP_BASE + 0x502a8, 0x2240007c);
 892        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d000087);
 893        MDP_OUTP(MDP_BASE + 0x502ac, 0x2240007b);
 894        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d400087);
 895        MDP_OUTP(MDP_BASE + 0x502b0, 0x2200007b);
 896        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d400088);
 897        MDP_OUTP(MDP_BASE + 0x502b4, 0x22400079);
 898        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d800088);
 899        MDP_OUTP(MDP_BASE + 0x502b8, 0x22400078);
 900        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc00088);
 901        MDP_OUTP(MDP_BASE + 0x502bc, 0x22400077);
 902        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc00089);
 903        MDP_OUTP(MDP_BASE + 0x502c0, 0x22000077);
 904        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1e000089);
 905        MDP_OUTP(MDP_BASE + 0x502c4, 0x22000076);
 906        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1e400089);
 907        MDP_OUTP(MDP_BASE + 0x502c8, 0x22000075);
 908        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec00088);
 909        MDP_OUTP(MDP_BASE + 0x502cc, 0x21c00075);
 910        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec00089);
 911        MDP_OUTP(MDP_BASE + 0x502d0, 0x21c00074);
 912        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f000089);
 913        MDP_OUTP(MDP_BASE + 0x502d4, 0x21c00073);
 914        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f400089);
 915        MDP_OUTP(MDP_BASE + 0x502d8, 0x21800073);
 916        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f40008a);
 917        MDP_OUTP(MDP_BASE + 0x502dc, 0x21800072);
 918        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f80008a);
 919        MDP_OUTP(MDP_BASE + 0x502e0, 0x21800071);
 920        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1fc0008a);
 921        MDP_OUTP(MDP_BASE + 0x502e4, 0x21800070);
 922        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1fc0008b);
 923        MDP_OUTP(MDP_BASE + 0x502e8, 0x2180006f);
 924        MDP_OUTP(MDP_BASE + 0x5fffc, 0x2000008c);
 925        MDP_OUTP(MDP_BASE + 0x502ec, 0x2140006e);
 926        MDP_OUTP(MDP_BASE + 0x5fffc, 0x2040008c);
 927        MDP_OUTP(MDP_BASE + 0x502f0, 0x2140006d);
 928        MDP_OUTP(MDP_BASE + 0x5fffc, 0x2080008c);
 929        MDP_OUTP(MDP_BASE + 0x502f4, 0x2100006d);
 930        MDP_OUTP(MDP_BASE + 0x5fffc, 0x20c0008c);
 931        MDP_OUTP(MDP_BASE + 0x502f8, 0x2100006c);
 932        MDP_OUTP(MDP_BASE + 0x5fffc, 0x20c0008d);
 933        MDP_OUTP(MDP_BASE + 0x502fc, 0x2100006b);
 934}
 935
 936static void mdp_load_bc_downscale_table_y_point2TOpoint4(void)
 937{
 938        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ac00084);
 939        MDP_OUTP(MDP_BASE + 0x50300, 0x23400083);
 940        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b000084);
 941        MDP_OUTP(MDP_BASE + 0x50304, 0x23000083);
 942        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b400084);
 943        MDP_OUTP(MDP_BASE + 0x50308, 0x23000082);
 944        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b400085);
 945        MDP_OUTP(MDP_BASE + 0x5030c, 0x23000081);
 946        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b800085);
 947        MDP_OUTP(MDP_BASE + 0x50310, 0x23000080);
 948        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1bc00086);
 949        MDP_OUTP(MDP_BASE + 0x50314, 0x22c0007f);
 950        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c000086);
 951        MDP_OUTP(MDP_BASE + 0x50318, 0x2280007f);
 952        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c400086);
 953        MDP_OUTP(MDP_BASE + 0x5031c, 0x2280007e);
 954        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c800086);
 955        MDP_OUTP(MDP_BASE + 0x50320, 0x2280007d);
 956        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc00086);
 957        MDP_OUTP(MDP_BASE + 0x50324, 0x2240007d);
 958        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc00087);
 959        MDP_OUTP(MDP_BASE + 0x50328, 0x2240007c);
 960        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d000087);
 961        MDP_OUTP(MDP_BASE + 0x5032c, 0x2240007b);
 962        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d400087);
 963        MDP_OUTP(MDP_BASE + 0x50330, 0x2200007b);
 964        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d400088);
 965        MDP_OUTP(MDP_BASE + 0x50334, 0x22400079);
 966        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d800088);
 967        MDP_OUTP(MDP_BASE + 0x50338, 0x22400078);
 968        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc00088);
 969        MDP_OUTP(MDP_BASE + 0x5033c, 0x22400077);
 970        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc00089);
 971        MDP_OUTP(MDP_BASE + 0x50340, 0x22000077);
 972        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1e000089);
 973        MDP_OUTP(MDP_BASE + 0x50344, 0x22000076);
 974        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1e400089);
 975        MDP_OUTP(MDP_BASE + 0x50348, 0x22000075);
 976        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec00088);
 977        MDP_OUTP(MDP_BASE + 0x5034c, 0x21c00075);
 978        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec00089);
 979        MDP_OUTP(MDP_BASE + 0x50350, 0x21c00074);
 980        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f000089);
 981        MDP_OUTP(MDP_BASE + 0x50354, 0x21c00073);
 982        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f400089);
 983        MDP_OUTP(MDP_BASE + 0x50358, 0x21800073);
 984        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f40008a);
 985        MDP_OUTP(MDP_BASE + 0x5035c, 0x21800072);
 986        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f80008a);
 987        MDP_OUTP(MDP_BASE + 0x50360, 0x21800071);
 988        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1fc0008a);
 989        MDP_OUTP(MDP_BASE + 0x50364, 0x21800070);
 990        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1fc0008b);
 991        MDP_OUTP(MDP_BASE + 0x50368, 0x2180006f);
 992        MDP_OUTP(MDP_BASE + 0x5fffc, 0x2000008c);
 993        MDP_OUTP(MDP_BASE + 0x5036c, 0x2140006e);
 994        MDP_OUTP(MDP_BASE + 0x5fffc, 0x2040008c);
 995        MDP_OUTP(MDP_BASE + 0x50370, 0x2140006d);
 996        MDP_OUTP(MDP_BASE + 0x5fffc, 0x2080008c);
 997        MDP_OUTP(MDP_BASE + 0x50374, 0x2100006d);
 998        MDP_OUTP(MDP_BASE + 0x5fffc, 0x20c0008c);
 999        MDP_OUTP(MDP_BASE + 0x50378, 0x2100006c);
1000        MDP_OUTP(MDP_BASE + 0x5fffc, 0x20c0008d);
1001        MDP_OUTP(MDP_BASE + 0x5037c, 0x2100006b);
1002}
1003
1004static void mdp_load_bc_downscale_table_x_point4TOpoint6(void)
1005{
1006        MDP_OUTP(MDP_BASE + 0x5fffc, 0x740008c);
1007        MDP_OUTP(MDP_BASE + 0x50280, 0x33800088);
1008        MDP_OUTP(MDP_BASE + 0x5fffc, 0x800008e);
1009        MDP_OUTP(MDP_BASE + 0x50284, 0x33400084);
1010        MDP_OUTP(MDP_BASE + 0x5fffc, 0x8400092);
1011        MDP_OUTP(MDP_BASE + 0x50288, 0x33000080);
1012        MDP_OUTP(MDP_BASE + 0x5fffc, 0x9000094);
1013        MDP_OUTP(MDP_BASE + 0x5028c, 0x3300007b);
1014        MDP_OUTP(MDP_BASE + 0x5fffc, 0x9c00098);
1015        MDP_OUTP(MDP_BASE + 0x50290, 0x32400077);
1016        MDP_OUTP(MDP_BASE + 0x5fffc, 0xa40009b);
1017        MDP_OUTP(MDP_BASE + 0x50294, 0x32000073);
1018        MDP_OUTP(MDP_BASE + 0x5fffc, 0xb00009d);
1019        MDP_OUTP(MDP_BASE + 0x50298, 0x31c0006f);
1020        MDP_OUTP(MDP_BASE + 0x5fffc, 0xbc000a0);
1021        MDP_OUTP(MDP_BASE + 0x5029c, 0x3140006b);
1022        MDP_OUTP(MDP_BASE + 0x5fffc, 0xc8000a2);
1023        MDP_OUTP(MDP_BASE + 0x502a0, 0x31000067);
1024        MDP_OUTP(MDP_BASE + 0x5fffc, 0xd8000a5);
1025        MDP_OUTP(MDP_BASE + 0x502a4, 0x30800062);
1026        MDP_OUTP(MDP_BASE + 0x5fffc, 0xe4000a8);
1027        MDP_OUTP(MDP_BASE + 0x502a8, 0x2fc0005f);
1028        MDP_OUTP(MDP_BASE + 0x5fffc, 0xec000aa);
1029        MDP_OUTP(MDP_BASE + 0x502ac, 0x2fc0005b);
1030        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8000ad);
1031        MDP_OUTP(MDP_BASE + 0x502b0, 0x2f400057);
1032        MDP_OUTP(MDP_BASE + 0x5fffc, 0x108000b0);
1033        MDP_OUTP(MDP_BASE + 0x502b4, 0x2e400054);
1034        MDP_OUTP(MDP_BASE + 0x5fffc, 0x114000b2);
1035        MDP_OUTP(MDP_BASE + 0x502b8, 0x2e000050);
1036        MDP_OUTP(MDP_BASE + 0x5fffc, 0x124000b4);
1037        MDP_OUTP(MDP_BASE + 0x502bc, 0x2d80004c);
1038        MDP_OUTP(MDP_BASE + 0x5fffc, 0x130000b6);
1039        MDP_OUTP(MDP_BASE + 0x502c0, 0x2d000049);
1040        MDP_OUTP(MDP_BASE + 0x5fffc, 0x140000b8);
1041        MDP_OUTP(MDP_BASE + 0x502c4, 0x2c800045);
1042        MDP_OUTP(MDP_BASE + 0x5fffc, 0x150000b9);
1043        MDP_OUTP(MDP_BASE + 0x502c8, 0x2c000042);
1044        MDP_OUTP(MDP_BASE + 0x5fffc, 0x15c000bd);
1045        MDP_OUTP(MDP_BASE + 0x502cc, 0x2b40003e);
1046        MDP_OUTP(MDP_BASE + 0x5fffc, 0x16c000bf);
1047        MDP_OUTP(MDP_BASE + 0x502d0, 0x2a80003b);
1048        MDP_OUTP(MDP_BASE + 0x5fffc, 0x17c000bf);
1049        MDP_OUTP(MDP_BASE + 0x502d4, 0x2a000039);
1050        MDP_OUTP(MDP_BASE + 0x5fffc, 0x188000c2);
1051        MDP_OUTP(MDP_BASE + 0x502d8, 0x29400036);
1052        MDP_OUTP(MDP_BASE + 0x5fffc, 0x19c000c4);
1053        MDP_OUTP(MDP_BASE + 0x502dc, 0x28800032);
1054        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ac000c5);
1055        MDP_OUTP(MDP_BASE + 0x502e0, 0x2800002f);
1056        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1bc000c7);
1057        MDP_OUTP(MDP_BASE + 0x502e4, 0x2740002c);
1058        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc000c8);
1059        MDP_OUTP(MDP_BASE + 0x502e8, 0x26c00029);
1060        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc000c9);
1061        MDP_OUTP(MDP_BASE + 0x502ec, 0x26000027);
1062        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec000cc);
1063        MDP_OUTP(MDP_BASE + 0x502f0, 0x25000024);
1064        MDP_OUTP(MDP_BASE + 0x5fffc, 0x200000cc);
1065        MDP_OUTP(MDP_BASE + 0x502f4, 0x24800021);
1066        MDP_OUTP(MDP_BASE + 0x5fffc, 0x210000cd);
1067        MDP_OUTP(MDP_BASE + 0x502f8, 0x23800020);
1068        MDP_OUTP(MDP_BASE + 0x5fffc, 0x220000ce);
1069        MDP_OUTP(MDP_BASE + 0x502fc, 0x2300001d);
1070}
1071
1072static void mdp_load_bc_downscale_table_y_point4TOpoint6(void)
1073{
1074        MDP_OUTP(MDP_BASE + 0x5fffc, 0x740008c);
1075        MDP_OUTP(MDP_BASE + 0x50300, 0x33800088);
1076        MDP_OUTP(MDP_BASE + 0x5fffc, 0x800008e);
1077        MDP_OUTP(MDP_BASE + 0x50304, 0x33400084);
1078        MDP_OUTP(MDP_BASE + 0x5fffc, 0x8400092);
1079        MDP_OUTP(MDP_BASE + 0x50308, 0x33000080);
1080        MDP_OUTP(MDP_BASE + 0x5fffc, 0x9000094);
1081        MDP_OUTP(MDP_BASE + 0x5030c, 0x3300007b);
1082        MDP_OUTP(MDP_BASE + 0x5fffc, 0x9c00098);
1083        MDP_OUTP(MDP_BASE + 0x50310, 0x32400077);
1084        MDP_OUTP(MDP_BASE + 0x5fffc, 0xa40009b);
1085        MDP_OUTP(MDP_BASE + 0x50314, 0x32000073);
1086        MDP_OUTP(MDP_BASE + 0x5fffc, 0xb00009d);
1087        MDP_OUTP(MDP_BASE + 0x50318, 0x31c0006f);
1088        MDP_OUTP(MDP_BASE + 0x5fffc, 0xbc000a0);
1089        MDP_OUTP(MDP_BASE + 0x5031c, 0x3140006b);
1090        MDP_OUTP(MDP_BASE + 0x5fffc, 0xc8000a2);
1091        MDP_OUTP(MDP_BASE + 0x50320, 0x31000067);
1092        MDP_OUTP(MDP_BASE + 0x5fffc, 0xd8000a5);
1093        MDP_OUTP(MDP_BASE + 0x50324, 0x30800062);
1094        MDP_OUTP(MDP_BASE + 0x5fffc, 0xe4000a8);
1095        MDP_OUTP(MDP_BASE + 0x50328, 0x2fc0005f);
1096        MDP_OUTP(MDP_BASE + 0x5fffc, 0xec000aa);
1097        MDP_OUTP(MDP_BASE + 0x5032c, 0x2fc0005b);
1098        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8000ad);
1099        MDP_OUTP(MDP_BASE + 0x50330, 0x2f400057);
1100        MDP_OUTP(MDP_BASE + 0x5fffc, 0x108000b0);
1101        MDP_OUTP(MDP_BASE + 0x50334, 0x2e400054);
1102        MDP_OUTP(MDP_BASE + 0x5fffc, 0x114000b2);
1103        MDP_OUTP(MDP_BASE + 0x50338, 0x2e000050);
1104        MDP_OUTP(MDP_BASE + 0x5fffc, 0x124000b4);
1105        MDP_OUTP(MDP_BASE + 0x5033c, 0x2d80004c);
1106        MDP_OUTP(MDP_BASE + 0x5fffc, 0x130000b6);
1107        MDP_OUTP(MDP_BASE + 0x50340, 0x2d000049);
1108        MDP_OUTP(MDP_BASE + 0x5fffc, 0x140000b8);
1109        MDP_OUTP(MDP_BASE + 0x50344, 0x2c800045);
1110        MDP_OUTP(MDP_BASE + 0x5fffc, 0x150000b9);
1111        MDP_OUTP(MDP_BASE + 0x50348, 0x2c000042);
1112        MDP_OUTP(MDP_BASE + 0x5fffc, 0x15c000bd);
1113        MDP_OUTP(MDP_BASE + 0x5034c, 0x2b40003e);
1114        MDP_OUTP(MDP_BASE + 0x5fffc, 0x16c000bf);
1115        MDP_OUTP(MDP_BASE + 0x50350, 0x2a80003b);
1116        MDP_OUTP(MDP_BASE + 0x5fffc, 0x17c000bf);
1117        MDP_OUTP(MDP_BASE + 0x50354, 0x2a000039);
1118        MDP_OUTP(MDP_BASE + 0x5fffc, 0x188000c2);
1119        MDP_OUTP(MDP_BASE + 0x50358, 0x29400036);
1120        MDP_OUTP(MDP_BASE + 0x5fffc, 0x19c000c4);
1121        MDP_OUTP(MDP_BASE + 0x5035c, 0x28800032);
1122        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ac000c5);
1123        MDP_OUTP(MDP_BASE + 0x50360, 0x2800002f);
1124        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1bc000c7);
1125        MDP_OUTP(MDP_BASE + 0x50364, 0x2740002c);
1126        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc000c8);
1127        MDP_OUTP(MDP_BASE + 0x50368, 0x26c00029);
1128        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc000c9);
1129        MDP_OUTP(MDP_BASE + 0x5036c, 0x26000027);
1130        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec000cc);
1131        MDP_OUTP(MDP_BASE + 0x50370, 0x25000024);
1132        MDP_OUTP(MDP_BASE + 0x5fffc, 0x200000cc);
1133        MDP_OUTP(MDP_BASE + 0x50374, 0x24800021);
1134        MDP_OUTP(MDP_BASE + 0x5fffc, 0x210000cd);
1135        MDP_OUTP(MDP_BASE + 0x50378, 0x23800020);
1136        MDP_OUTP(MDP_BASE + 0x5fffc, 0x220000ce);
1137        MDP_OUTP(MDP_BASE + 0x5037c, 0x2300001d);
1138}
1139
1140static void mdp_load_bc_downscale_table_x_point6TOpoint8(void)
1141{
1142        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000070);
1143        MDP_OUTP(MDP_BASE + 0x50280, 0x4bc00068);
1144        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000078);
1145        MDP_OUTP(MDP_BASE + 0x50284, 0x4bc00060);
1146        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000080);
1147        MDP_OUTP(MDP_BASE + 0x50288, 0x4b800059);
1148        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000089);
1149        MDP_OUTP(MDP_BASE + 0x5028c, 0x4b000052);
1150        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe400091);
1151        MDP_OUTP(MDP_BASE + 0x50290, 0x4a80004b);
1152        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40009a);
1153        MDP_OUTP(MDP_BASE + 0x50294, 0x4a000044);
1154        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe8000a3);
1155        MDP_OUTP(MDP_BASE + 0x50298, 0x4940003d);
1156        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec000ac);
1157        MDP_OUTP(MDP_BASE + 0x5029c, 0x48400037);
1158        MDP_OUTP(MDP_BASE + 0x5fffc, 0xff0000b4);
1159        MDP_OUTP(MDP_BASE + 0x502a0, 0x47800031);
1160        MDP_OUTP(MDP_BASE + 0x5fffc, 0xff8000bd);
1161        MDP_OUTP(MDP_BASE + 0x502a4, 0x4640002b);
1162        MDP_OUTP(MDP_BASE + 0x5fffc, 0xc5);
1163        MDP_OUTP(MDP_BASE + 0x502a8, 0x45000026);
1164        MDP_OUTP(MDP_BASE + 0x5fffc, 0x8000ce);
1165        MDP_OUTP(MDP_BASE + 0x502ac, 0x43800021);
1166        MDP_OUTP(MDP_BASE + 0x5fffc, 0x10000d6);
1167        MDP_OUTP(MDP_BASE + 0x502b0, 0x4240001c);
1168        MDP_OUTP(MDP_BASE + 0x5fffc, 0x18000df);
1169        MDP_OUTP(MDP_BASE + 0x502b4, 0x40800018);
1170        MDP_OUTP(MDP_BASE + 0x5fffc, 0x24000e6);
1171        MDP_OUTP(MDP_BASE + 0x502b8, 0x3f000014);
1172        MDP_OUTP(MDP_BASE + 0x5fffc, 0x30000ee);
1173        MDP_OUTP(MDP_BASE + 0x502bc, 0x3d400010);
1174        MDP_OUTP(MDP_BASE + 0x5fffc, 0x40000f5);
1175        MDP_OUTP(MDP_BASE + 0x502c0, 0x3b80000c);
1176        MDP_OUTP(MDP_BASE + 0x5fffc, 0x50000fc);
1177        MDP_OUTP(MDP_BASE + 0x502c4, 0x39800009);
1178        MDP_OUTP(MDP_BASE + 0x5fffc, 0x6000102);
1179        MDP_OUTP(MDP_BASE + 0x502c8, 0x37c00006);
1180        MDP_OUTP(MDP_BASE + 0x5fffc, 0x7000109);
1181        MDP_OUTP(MDP_BASE + 0x502cc, 0x35800004);
1182        MDP_OUTP(MDP_BASE + 0x5fffc, 0x840010e);
1183        MDP_OUTP(MDP_BASE + 0x502d0, 0x33800002);
1184        MDP_OUTP(MDP_BASE + 0x5fffc, 0x9800114);
1185        MDP_OUTP(MDP_BASE + 0x502d4, 0x31400000);
1186        MDP_OUTP(MDP_BASE + 0x5fffc, 0xac00119);
1187        MDP_OUTP(MDP_BASE + 0x502d8, 0x2f4003fe);
1188        MDP_OUTP(MDP_BASE + 0x5fffc, 0xc40011e);
1189        MDP_OUTP(MDP_BASE + 0x502dc, 0x2d0003fc);
1190        MDP_OUTP(MDP_BASE + 0x5fffc, 0xdc00121);
1191        MDP_OUTP(MDP_BASE + 0x502e0, 0x2b0003fb);
1192        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf400125);
1193        MDP_OUTP(MDP_BASE + 0x502e4, 0x28c003fa);
1194        MDP_OUTP(MDP_BASE + 0x5fffc, 0x11000128);
1195        MDP_OUTP(MDP_BASE + 0x502e8, 0x268003f9);
1196        MDP_OUTP(MDP_BASE + 0x5fffc, 0x12c0012a);
1197        MDP_OUTP(MDP_BASE + 0x502ec, 0x244003f9);
1198        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1480012c);
1199        MDP_OUTP(MDP_BASE + 0x502f0, 0x224003f8);
1200        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1640012e);
1201        MDP_OUTP(MDP_BASE + 0x502f4, 0x200003f8);
1202        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1800012f);
1203        MDP_OUTP(MDP_BASE + 0x502f8, 0x1e0003f8);
1204        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1a00012f);
1205        MDP_OUTP(MDP_BASE + 0x502fc, 0x1c0003f8);
1206}
1207
1208static void mdp_load_bc_downscale_table_y_point6TOpoint8(void)
1209{
1210        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000070);
1211        MDP_OUTP(MDP_BASE + 0x50300, 0x4bc00068);
1212        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000078);
1213        MDP_OUTP(MDP_BASE + 0x50304, 0x4bc00060);
1214        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000080);
1215        MDP_OUTP(MDP_BASE + 0x50308, 0x4b800059);
1216        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000089);
1217        MDP_OUTP(MDP_BASE + 0x5030c, 0x4b000052);
1218        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe400091);
1219        MDP_OUTP(MDP_BASE + 0x50310, 0x4a80004b);
1220        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40009a);
1221        MDP_OUTP(MDP_BASE + 0x50314, 0x4a000044);
1222        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe8000a3);
1223        MDP_OUTP(MDP_BASE + 0x50318, 0x4940003d);
1224        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec000ac);
1225        MDP_OUTP(MDP_BASE + 0x5031c, 0x48400037);
1226        MDP_OUTP(MDP_BASE + 0x5fffc, 0xff0000b4);
1227        MDP_OUTP(MDP_BASE + 0x50320, 0x47800031);
1228        MDP_OUTP(MDP_BASE + 0x5fffc, 0xff8000bd);
1229        MDP_OUTP(MDP_BASE + 0x50324, 0x4640002b);
1230        MDP_OUTP(MDP_BASE + 0x5fffc, 0xc5);
1231        MDP_OUTP(MDP_BASE + 0x50328, 0x45000026);
1232        MDP_OUTP(MDP_BASE + 0x5fffc, 0x8000ce);
1233        MDP_OUTP(MDP_BASE + 0x5032c, 0x43800021);
1234        MDP_OUTP(MDP_BASE + 0x5fffc, 0x10000d6);
1235        MDP_OUTP(MDP_BASE + 0x50330, 0x4240001c);
1236        MDP_OUTP(MDP_BASE + 0x5fffc, 0x18000df);
1237        MDP_OUTP(MDP_BASE + 0x50334, 0x40800018);
1238        MDP_OUTP(MDP_BASE + 0x5fffc, 0x24000e6);
1239        MDP_OUTP(MDP_BASE + 0x50338, 0x3f000014);
1240        MDP_OUTP(MDP_BASE + 0x5fffc, 0x30000ee);
1241        MDP_OUTP(MDP_BASE + 0x5033c, 0x3d400010);
1242        MDP_OUTP(MDP_BASE + 0x5fffc, 0x40000f5);
1243        MDP_OUTP(MDP_BASE + 0x50340, 0x3b80000c);
1244        MDP_OUTP(MDP_BASE + 0x5fffc, 0x50000fc);
1245        MDP_OUTP(MDP_BASE + 0x50344, 0x39800009);
1246        MDP_OUTP(MDP_BASE + 0x5fffc, 0x6000102);
1247        MDP_OUTP(MDP_BASE + 0x50348, 0x37c00006);
1248        MDP_OUTP(MDP_BASE + 0x5fffc, 0x7000109);
1249        MDP_OUTP(MDP_BASE + 0x5034c, 0x35800004);
1250        MDP_OUTP(MDP_BASE + 0x5fffc, 0x840010e);
1251        MDP_OUTP(MDP_BASE + 0x50350, 0x33800002);
1252        MDP_OUTP(MDP_BASE + 0x5fffc, 0x9800114);
1253        MDP_OUTP(MDP_BASE + 0x50354, 0x31400000);
1254        MDP_OUTP(MDP_BASE + 0x5fffc, 0xac00119);
1255        MDP_OUTP(MDP_BASE + 0x50358, 0x2f4003fe);
1256        MDP_OUTP(MDP_BASE + 0x5fffc, 0xc40011e);
1257        MDP_OUTP(MDP_BASE + 0x5035c, 0x2d0003fc);
1258        MDP_OUTP(MDP_BASE + 0x5fffc, 0xdc00121);
1259        MDP_OUTP(MDP_BASE + 0x50360, 0x2b0003fb);
1260        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf400125);
1261        MDP_OUTP(MDP_BASE + 0x50364, 0x28c003fa);
1262        MDP_OUTP(MDP_BASE + 0x5fffc, 0x11000128);
1263        MDP_OUTP(MDP_BASE + 0x50368, 0x268003f9);
1264        MDP_OUTP(MDP_BASE + 0x5fffc, 0x12c0012a);
1265        MDP_OUTP(MDP_BASE + 0x5036c, 0x244003f9);
1266        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1480012c);
1267        MDP_OUTP(MDP_BASE + 0x50370, 0x224003f8);
1268        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1640012e);
1269        MDP_OUTP(MDP_BASE + 0x50374, 0x200003f8);
1270        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1800012f);
1271        MDP_OUTP(MDP_BASE + 0x50378, 0x1e0003f8);
1272        MDP_OUTP(MDP_BASE + 0x5fffc, 0x1a00012f);
1273        MDP_OUTP(MDP_BASE + 0x5037c, 0x1c0003f8);
1274}
1275
1276static void mdp_load_bc_downscale_table_x_point8TO1(void)
1277{
1278        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
1279        MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000);
1280        MDP_OUTP(MDP_BASE + 0x5fffc, 0xff80000d);
1281        MDP_OUTP(MDP_BASE + 0x50284, 0x7ec003f9);
1282        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec0001c);
1283        MDP_OUTP(MDP_BASE + 0x50288, 0x7d4003f3);
1284        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40002b);
1285        MDP_OUTP(MDP_BASE + 0x5028c, 0x7b8003ed);
1286        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfd80003c);
1287        MDP_OUTP(MDP_BASE + 0x50290, 0x794003e8);
1288        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc0004d);
1289        MDP_OUTP(MDP_BASE + 0x50294, 0x76c003e4);
1290        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfc40005f);
1291        MDP_OUTP(MDP_BASE + 0x50298, 0x73c003e0);
1292        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb800071);
1293        MDP_OUTP(MDP_BASE + 0x5029c, 0x708003de);
1294        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfac00085);
1295        MDP_OUTP(MDP_BASE + 0x502a0, 0x6d0003db);
1296        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa000098);
1297        MDP_OUTP(MDP_BASE + 0x502a4, 0x698003d9);
1298        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf98000ac);
1299        MDP_OUTP(MDP_BASE + 0x502a8, 0x654003d8);
1300        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8c000c1);
1301        MDP_OUTP(MDP_BASE + 0x502ac, 0x610003d7);
1302        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf84000d5);
1303        MDP_OUTP(MDP_BASE + 0x502b0, 0x5c8003d7);
1304        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf7c000e9);
1305        MDP_OUTP(MDP_BASE + 0x502b4, 0x580003d7);
1306        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf74000fd);
1307        MDP_OUTP(MDP_BASE + 0x502b8, 0x534003d8);
1308        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c00112);
1309        MDP_OUTP(MDP_BASE + 0x502bc, 0x4e8003d8);
1310        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6800126);
1311        MDP_OUTP(MDP_BASE + 0x502c0, 0x494003da);
1312        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600013a);
1313        MDP_OUTP(MDP_BASE + 0x502c4, 0x448003db);
1314        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600014d);
1315        MDP_OUTP(MDP_BASE + 0x502c8, 0x3f4003dd);
1316        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00160);
1317        MDP_OUTP(MDP_BASE + 0x502cc, 0x3a4003df);
1318        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00172);
1319        MDP_OUTP(MDP_BASE + 0x502d0, 0x354003e1);
1320        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00184);
1321        MDP_OUTP(MDP_BASE + 0x502d4, 0x304003e3);
1322        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6000195);
1323        MDP_OUTP(MDP_BASE + 0x502d8, 0x2b0003e6);
1324        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf64001a6);
1325        MDP_OUTP(MDP_BASE + 0x502dc, 0x260003e8);
1326        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c001b4);
1327        MDP_OUTP(MDP_BASE + 0x502e0, 0x214003eb);
1328        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf78001c2);
1329        MDP_OUTP(MDP_BASE + 0x502e4, 0x1c4003ee);
1330        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf80001cf);
1331        MDP_OUTP(MDP_BASE + 0x502e8, 0x17c003f1);
1332        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf90001db);
1333        MDP_OUTP(MDP_BASE + 0x502ec, 0x134003f3);
1334        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa0001e5);
1335        MDP_OUTP(MDP_BASE + 0x502f0, 0xf0003f6);
1336        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb4001ee);
1337        MDP_OUTP(MDP_BASE + 0x502f4, 0xac003f9);
1338        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc001f5);
1339        MDP_OUTP(MDP_BASE + 0x502f8, 0x70003fb);
1340        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe4001fb);
1341        MDP_OUTP(MDP_BASE + 0x502fc, 0x34003fe);
1342}
1343
1344static void mdp_load_bc_downscale_table_y_point8TO1(void)
1345{
1346        MDP_OUTP(MDP_BASE + 0x5fffc, 0x0);
1347        MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000);
1348        MDP_OUTP(MDP_BASE + 0x5fffc, 0xff80000d);
1349        MDP_OUTP(MDP_BASE + 0x50304, 0x7ec003f9);
1350        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec0001c);
1351        MDP_OUTP(MDP_BASE + 0x50308, 0x7d4003f3);
1352        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40002b);
1353        MDP_OUTP(MDP_BASE + 0x5030c, 0x7b8003ed);
1354        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfd80003c);
1355        MDP_OUTP(MDP_BASE + 0x50310, 0x794003e8);
1356        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc0004d);
1357        MDP_OUTP(MDP_BASE + 0x50314, 0x76c003e4);
1358        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfc40005f);
1359        MDP_OUTP(MDP_BASE + 0x50318, 0x73c003e0);
1360        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb800071);
1361        MDP_OUTP(MDP_BASE + 0x5031c, 0x708003de);
1362        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfac00085);
1363        MDP_OUTP(MDP_BASE + 0x50320, 0x6d0003db);
1364        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa000098);
1365        MDP_OUTP(MDP_BASE + 0x50324, 0x698003d9);
1366        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf98000ac);
1367        MDP_OUTP(MDP_BASE + 0x50328, 0x654003d8);
1368        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8c000c1);
1369        MDP_OUTP(MDP_BASE + 0x5032c, 0x610003d7);
1370        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf84000d5);
1371        MDP_OUTP(MDP_BASE + 0x50330, 0x5c8003d7);
1372        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf7c000e9);
1373        MDP_OUTP(MDP_BASE + 0x50334, 0x580003d7);
1374        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf74000fd);
1375        MDP_OUTP(MDP_BASE + 0x50338, 0x534003d8);
1376        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c00112);
1377        MDP_OUTP(MDP_BASE + 0x5033c, 0x4e8003d8);
1378        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6800126);
1379        MDP_OUTP(MDP_BASE + 0x50340, 0x494003da);
1380        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600013a);
1381        MDP_OUTP(MDP_BASE + 0x50344, 0x448003db);
1382        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600014d);
1383        MDP_OUTP(MDP_BASE + 0x50348, 0x3f4003dd);
1384        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00160);
1385        MDP_OUTP(MDP_BASE + 0x5034c, 0x3a4003df);
1386        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00172);
1387        MDP_OUTP(MDP_BASE + 0x50350, 0x354003e1);
1388        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00184);
1389        MDP_OUTP(MDP_BASE + 0x50354, 0x304003e3);
1390        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6000195);
1391        MDP_OUTP(MDP_BASE + 0x50358, 0x2b0003e6);
1392        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf64001a6);
1393        MDP_OUTP(MDP_BASE + 0x5035c, 0x260003e8);
1394        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c001b4);
1395        MDP_OUTP(MDP_BASE + 0x50360, 0x214003eb);
1396        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf78001c2);
1397        MDP_OUTP(MDP_BASE + 0x50364, 0x1c4003ee);
1398        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf80001cf);
1399        MDP_OUTP(MDP_BASE + 0x50368, 0x17c003f1);
1400        MDP_OUTP(MDP_BASE + 0x5fffc, 0xf90001db);
1401        MDP_OUTP(MDP_BASE + 0x5036c, 0x134003f3);
1402        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa0001e5);
1403        MDP_OUTP(MDP_BASE + 0x50370, 0xf0003f6);
1404        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb4001ee);
1405        MDP_OUTP(MDP_BASE + 0x50374, 0xac003f9);
1406        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc001f5);
1407        MDP_OUTP(MDP_BASE + 0x50378, 0x70003fb);
1408        MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe4001fb);
1409        MDP_OUTP(MDP_BASE + 0x5037c, 0x34003fe);
1410}
1411
1412static int mdp_get_edge_cond(MDPIBUF *iBuf, uint32 *dup, uint32 *dup2)
1413{
1414        uint32 reg;
1415        uint32 dst_roi_width;   /* Dimensions of DST ROI. */
1416        uint32 dst_roi_height;  /* Used to calculate scaling ratios. */
1417
1418        /*
1419         * positions of the luma pixel(relative to the image ) required for
1420         * scaling the ROI
1421         */
1422        int32 luma_interp_point_left = 0; /* left-most luma pixel needed */
1423        int32 luma_interp_point_right = 0; /* right-most luma pixel needed */
1424        int32 luma_interp_point_top = 0; /* top-most luma pixel needed */
1425        int32 luma_interp_point_bottom = 0; /* bottom-most luma pixel needed */
1426
1427        /*
1428         * positions of the chroma pixel(relative to the image ) required for
1429         * interpolating a chroma value at all required luma positions
1430         */
1431        /* left-most chroma pixel needed */
1432        int32 chroma_interp_point_left = 0;
1433        /* right-most chroma pixel needed */
1434        int32 chroma_interp_point_right = 0;
1435        /* top-most chroma pixel needed */
1436        int32 chroma_interp_point_top = 0;
1437        /* bottom-most chroma pixel needed */
1438        int32 chroma_interp_point_bottom = 0;
1439
1440        /*
1441         * a rectangular region within the chroma plane of the "image".
1442         * Chroma pixels falling inside of this rectangle belongs to the ROI
1443         */
1444        int32 chroma_bound_left = 0;
1445        int32 chroma_bound_right = 0;
1446        int32 chroma_bound_top = 0;
1447        int32 chroma_bound_bottom = 0;
1448
1449        /*
1450         * number of chroma pixels to replicate on the left, right,
1451         * top and bottom edge of the ROI.
1452         */
1453        int32 chroma_repeat_left = 0;
1454        int32 chroma_repeat_right = 0;
1455        int32 chroma_repeat_top = 0;
1456        int32 chroma_repeat_bottom = 0;
1457
1458        /*
1459         * number of luma pixels to replicate on the left, right,
1460         * top and bottom edge of the ROI.
1461         */
1462        int32 luma_repeat_left = 0;
1463        int32 luma_repeat_right = 0;
1464        int32 luma_repeat_top = 0;
1465        int32 luma_repeat_bottom = 0;
1466
1467        boolean chroma_edge_enable;
1468
1469        uint32 _is_scale_enabled = 0;
1470        uint32 _is_yuv_offsite_vertical = 0;
1471
1472        /* fg edge duplicate */
1473        reg = 0x0;
1474
1475        if (iBuf->mdpImg.mdpOp & MDPOP_ASCALE) {        /* if scaling enabled */
1476
1477                _is_scale_enabled = 1;
1478
1479                /*
1480                 * if rotation mode involves a 90 deg rotation, flip
1481                 * dst_roi_width with dst_roi_height.
1482                 * Scaling ratios is based on source ROI dimensions, and
1483                 * dst ROI dimensions before rotation.
1484                 */
1485                if (iBuf->mdpImg.mdpOp & MDPOP_ROT90) {
1486                        dst_roi_width = iBuf->roi.dst_height;
1487                        dst_roi_height = iBuf->roi.dst_width;
1488                } else {
1489                        dst_roi_width = iBuf->roi.dst_width;
1490                        dst_roi_height = iBuf->roi.dst_height;
1491                }
1492
1493                /*
1494                 * Find out the luma pixels needed for scaling in the
1495                 * x direction (LEFT and RIGHT).  Locations of pixels are
1496                 * relative to the ROI. Upper-left corner of ROI corresponds
1497                 * to coordinates (0,0). Also set the number of luma pixel
1498                 * to repeat.
1499                 */
1500                if (iBuf->roi.width > 3 * dst_roi_width) {
1501                        /* scale factor < 1/3 */
1502                        luma_interp_point_left = 0;
1503                        luma_interp_point_right = (iBuf->roi.width - 1);
1504                        luma_repeat_left = 0;
1505                        luma_repeat_right = 0;
1506                } else if (iBuf->roi.width == 3 * dst_roi_width) {
1507                        /* scale factor == 1/3 */
1508                        luma_interp_point_left = 0;
1509                        luma_interp_point_right = (iBuf->roi.width - 1) + 1;
1510                        luma_repeat_left = 0;
1511                        luma_repeat_right = 1;
1512                } else if ((iBuf->roi.width > dst_roi_width) &&
1513                           (iBuf->roi.width < 3 * dst_roi_width)) {
1514                        /* 1/3 < scale factor < 1 */
1515                        luma_interp_point_left = -1;
1516                        luma_interp_point_right = (iBuf->roi.width - 1) + 1;
1517                        luma_repeat_left = 1;
1518                        luma_repeat_right = 1;
1519                }
1520
1521                else if (iBuf->roi.width == dst_roi_width) {
1522                        /* scale factor == 1 */
1523                        luma_interp_point_left = -1;
1524                        luma_interp_point_right = (iBuf->roi.width - 1) + 2;
1525                        luma_repeat_left = 1;
1526                        luma_repeat_right = 2;
1527                } else {        /* (iBuf->roi.width < dst_roi_width) */
1528                          /* scale factor > 1 */
1529                        luma_interp_point_left = -2;
1530                        luma_interp_point_right = (iBuf->roi.width - 1) + 2;
1531                        luma_repeat_left = 2;
1532                        luma_repeat_right = 2;
1533                }
1534
1535                /*
1536                 * Find out the number of pixels needed for scaling in the
1537                 * y direction (TOP and BOTTOM).  Locations of pixels are
1538                 * relative to the ROI. Upper-left corner of ROI corresponds
1539                 * to coordinates (0,0). Also set the number of luma pixel
1540                 * to repeat.
1541                 */
1542                if (iBuf->roi.height > 3 * dst_roi_height) {
1543                        /* scale factor < 1/3 */
1544                        luma_interp_point_top = 0;
1545                        luma_interp_point_bottom = (iBuf->roi.height - 1);
1546                        luma_repeat_top = 0;
1547                        luma_repeat_bottom = 0;
1548                } else if (iBuf->roi.height == 3 * dst_roi_height) {
1549                        /* scale factor == 1/3 */
1550                        luma_interp_point_top = 0;
1551                        luma_interp_point_bottom = (iBuf->roi.height - 1) + 1;
1552                        luma_repeat_top = 0;
1553                        luma_repeat_bottom = 1;
1554                } else if ((iBuf->roi.height > dst_roi_height) &&
1555                           (iBuf->roi.height < 3 * dst_roi_height)) {
1556                        /* 1/3 < scale factor < 1 */
1557                        luma_interp_point_top = -1;
1558                        luma_interp_point_bottom = (iBuf->roi.height - 1) + 1;
1559                        luma_repeat_top = 1;
1560                        luma_repeat_bottom = 1;
1561                } else if (iBuf->roi.height == dst_roi_height) {
1562                        /* scale factor == 1 */
1563                        luma_interp_point_top = -1;
1564                        luma_interp_point_bottom = (iBuf->roi.height - 1) + 2;
1565                        luma_repeat_top = 1;
1566                        luma_repeat_bottom = 2;
1567                } else {        /* (iBuf->roi.height < dst_roi_height) */
1568                         /* scale factor > 1 */
1569                        luma_interp_point_top = -2;
1570                        luma_interp_point_bottom = (iBuf->roi.height - 1) + 2;
1571                        luma_repeat_top = 2;
1572                        luma_repeat_bottom = 2;
1573                }
1574        }                       /* if (iBuf->scale.scale_flag) */
1575        else {                  /* scaling disabled */
1576                /*
1577                 * Since no scaling needed, Tile Fetch does not require any
1578                 * more luma pixel than what the ROI contains.
1579                 */
1580                luma_interp_point_left = (int32) 0;
1581                luma_interp_point_right = (int32) (iBuf->roi.width - 1);
1582                luma_interp_point_top = (int32) 0;
1583                luma_interp_point_bottom = (int32) (iBuf->roi.height - 1);
1584
1585                luma_repeat_left = 0;
1586                luma_repeat_right = 0;
1587                luma_repeat_top = 0;
1588                luma_repeat_bottom = 0;
1589        }
1590
1591        /* After adding the ROI offsets, we have locations of
1592         * luma_interp_points relative to the image.
1593         */
1594        luma_interp_point_left += (int32) (iBuf->roi.x);
1595        luma_interp_point_right += (int32) (iBuf->roi.x);
1596        luma_interp_point_top += (int32) (iBuf->roi.y);
1597        luma_interp_point_bottom += (int32) (iBuf->roi.y);
1598
1599        /*
1600         * After adding the ROI offsets, we have locations of
1601         * chroma_interp_points relative to the image.
1602         */
1603        chroma_interp_point_left = luma_interp_point_left;
1604        chroma_interp_point_right = luma_interp_point_right;
1605        chroma_interp_point_top = luma_interp_point_top;
1606        chroma_interp_point_bottom = luma_interp_point_bottom;
1607
1608        chroma_edge_enable = TRUE;
1609        /* find out which chroma pixels are needed for chroma upsampling. */
1610        switch (iBuf->mdpImg.imgType) {
1611                /*
1612                 * cosite in horizontal axis
1613                 * fully sampled in vertical axis
1614                 */
1615        case MDP_Y_CBCR_H2V1:
1616        case MDP_Y_CRCB_H2V1:
1617        case MDP_YCRYCB_H2V1:
1618                /* floor( luma_interp_point_left / 2 ); */
1619                chroma_interp_point_left = luma_interp_point_left >> 1;
1620                /* floor( ( luma_interp_point_right + 1 ) / 2 ); */
1621                chroma_interp_point_right = (luma_interp_point_right + 1) >> 1;
1622
1623                chroma_interp_point_top = luma_interp_point_top;
1624                chroma_interp_point_bottom = luma_interp_point_bottom;
1625                break;
1626
1627                /*
1628                 * cosite in horizontal axis
1629                 * offsite in vertical axis
1630                 */
1631        case MDP_Y_CBCR_H2V2:
1632        case MDP_Y_CRCB_H2V2:
1633                /* floor( luma_interp_point_left / 2) */
1634                chroma_interp_point_left = luma_interp_point_left >> 1;
1635
1636                /* floor( ( luma_interp_point_right + 1 )/ 2 ) */
1637                chroma_interp_point_right = (luma_interp_point_right + 1) >> 1;
1638
1639                /* floor( (luma_interp_point_top - 1 ) / 2 ) */
1640                chroma_interp_point_top = (luma_interp_point_top - 1) >> 1;
1641
1642                /* floor( ( luma_interp_point_bottom + 1 ) / 2 ) */
1643                chroma_interp_point_bottom =
1644                    (luma_interp_point_bottom + 1) >> 1;
1645
1646                _is_yuv_offsite_vertical = 1;
1647                break;
1648
1649        default:
1650                chroma_edge_enable = FALSE;
1651                chroma_interp_point_left = luma_interp_point_left;
1652                chroma_interp_point_right = luma_interp_point_right;
1653                chroma_interp_point_top = luma_interp_point_top;
1654                chroma_interp_point_bottom = luma_interp_point_bottom;
1655
1656                break;
1657        }
1658
1659        /* only if the image type is in YUV domain, we calculate chroma edge */
1660        if (chroma_edge_enable) {
1661                /* Defines which chroma pixels belongs to the roi */
1662                switch (iBuf->mdpImg.imgType) {
1663                        /*
1664                         * Cosite in horizontal direction, and fully sampled
1665                         * in vertical direction.
1666                         */
1667                case MDP_Y_CBCR_H2V1:
1668                case MDP_Y_CRCB_H2V1:
1669                case MDP_YCRYCB_H2V1:
1670                        /*
1671                         * width of chroma ROI is 1/2 of size of luma ROI
1672                         * height of chroma ROI same as size of luma ROI
1673                         */
1674                        chroma_bound_left = iBuf->roi.x / 2;
1675
1676                        /* there are half as many chroma pixel as luma pixels */
1677                        chroma_bound_right =
1678                            (iBuf->roi.width + iBuf->roi.x - 1) / 2;
1679                        chroma_bound_top = iBuf->roi.y;
1680                        chroma_bound_bottom =
1681                            (iBuf->roi.height + iBuf->roi.y - 1);
1682                        break;
1683
1684                case MDP_Y_CBCR_H2V2:
1685                case MDP_Y_CRCB_H2V2:
1686                        /*
1687                         * cosite in horizontal dir, and offsite in vertical dir
1688                         * width of chroma ROI is 1/2 of size of luma ROI
1689                         * height of chroma ROI is 1/2 of size of luma ROI
1690                         */
1691
1692                        chroma_bound_left = iBuf->roi.x / 2;
1693                        chroma_bound_right =
1694                            (iBuf->roi.width + iBuf->roi.x - 1) / 2;
1695                        chroma_bound_top = iBuf->roi.y / 2;
1696                        chroma_bound_bottom =
1697                            (iBuf->roi.height + iBuf->roi.y - 1) / 2;
1698                        break;
1699
1700                default:
1701                        /*
1702                         * If no valid chroma sub-sampling format specified,
1703                         * assume 4:4:4 ( i.e. fully sampled).  Set ROI
1704                         * boundaries for chroma same as ROI boundaries for
1705                         * luma.
1706                         */
1707                        chroma_bound_left = iBuf->roi.x;
1708                        chroma_bound_right = iBuf->roi.width + iBuf->roi.x - 1;
1709                        chroma_bound_top = iBuf->roi.y;
1710                        chroma_bound_bottom =
1711                            (iBuf->roi.height + iBuf->roi.y - 1);
1712                        break;
1713                }
1714
1715                /*
1716                 * Knowing which chroma pixels are needed, and which chroma
1717                 * pixels belong to the ROI (i.e. available for fetching ),
1718                 * calculate how many chroma pixels Tile Fetch needs to
1719                 * duplicate.  If any required chroma pixels falls outside
1720                 * of the ROI, Tile Fetch must obtain them by replicating
1721                 * pixels.
1722                 */
1723                if (chroma_bound_left > chroma_interp_point_left)
1724                        chroma_repeat_left =
1725                            chroma_bound_left - chroma_interp_point_left;
1726                else
1727                        chroma_repeat_left = 0;
1728
1729                if (chroma_interp_point_right > chroma_bound_right)
1730                        chroma_repeat_right =
1731                            chroma_interp_point_right - chroma_bound_right;
1732                else
1733                        chroma_repeat_right = 0;
1734
1735                if (chroma_bound_top > chroma_interp_point_top)
1736                        chroma_repeat_top =
1737                            chroma_bound_top - chroma_interp_point_top;
1738                else
1739                        chroma_repeat_top = 0;
1740
1741                if (chroma_interp_point_bottom > chroma_bound_bottom)
1742                        chroma_repeat_bottom =
1743                            chroma_interp_point_bottom - chroma_bound_bottom;
1744                else
1745                        chroma_repeat_bottom = 0;
1746
1747                if (_is_scale_enabled && (iBuf->roi.height == 1)
1748                    && _is_yuv_offsite_vertical) {
1749                        chroma_repeat_bottom = 3;
1750                        chroma_repeat_top = 0;
1751                }
1752        }
1753        /* make sure chroma repeats are non-negative */
1754        if ((chroma_repeat_left < 0) || (chroma_repeat_right < 0) ||
1755            (chroma_repeat_top < 0) || (chroma_repeat_bottom < 0))
1756                return -1;
1757
1758        /* make sure chroma repeats are no larger than 3 pixels */
1759        if ((chroma_repeat_left > 3) || (chroma_repeat_right > 3) ||
1760            (chroma_repeat_top > 3) || (chroma_repeat_bottom > 3))
1761                return -1;
1762
1763        /* make sure luma repeats are non-negative */
1764        if ((luma_repeat_left < 0) || (luma_repeat_right < 0) ||
1765            (luma_repeat_top < 0) || (luma_repeat_bottom < 0))
1766                return -1;
1767
1768        /* make sure luma repeats are no larger than 3 pixels */
1769        if ((luma_repeat_left > 3) || (luma_repeat_right > 3) ||
1770            (luma_repeat_top > 3) || (luma_repeat_bottom > 3))
1771                return -1;
1772
1773        /* write chroma_repeat_left to register */
1774        reg |= (chroma_repeat_left & 3) << MDP_LEFT_CHROMA;
1775
1776        /* write chroma_repeat_right to register */
1777        reg |= (chroma_repeat_right & 3) << MDP_RIGHT_CHROMA;
1778
1779        /* write chroma_repeat_top to register */
1780        reg |= (chroma_repeat_top & 3) << MDP_TOP_CHROMA;
1781
1782        /* write chroma_repeat_bottom to register */
1783        reg |= (chroma_repeat_bottom & 3) << MDP_BOTTOM_CHROMA;
1784
1785        /* write luma_repeat_left to register */
1786        reg |= (luma_repeat_left & 3) << MDP_LEFT_LUMA;
1787
1788        /* write luma_repeat_right to register */
1789        reg |= (luma_repeat_right & 3) << MDP_RIGHT_LUMA;
1790
1791        /* write luma_repeat_top to register */
1792        reg |= (luma_repeat_top & 3) << MDP_TOP_LUMA;
1793
1794        /* write luma_repeat_bottom to register */
1795        reg |= (luma_repeat_bottom & 3) << MDP_BOTTOM_LUMA;
1796
1797        /* done with reg */
1798        *dup = reg;
1799
1800        /* bg edge duplicate */
1801        reg = 0x0;
1802
1803        switch (iBuf->ibuf_type) {
1804        case MDP_Y_CBCR_H2V2:
1805        case MDP_Y_CRCB_H2V2:
1806                /*
1807                 * Edge condition for MDP_Y_CRCB/CBCR_H2V2 cosite only.
1808                 * For 420 cosite, 1 chroma replicated on all sides except
1809                 * left, so reg 101b8 should be 0x0209. For 420 offsite,
1810                 * 1 chroma replicated all sides.
1811                 */
1812                if (iBuf->roi.lcd_y == 0) {
1813                        reg |= BIT(MDP_TOP_CHROMA);
1814                }
1815
1816                if ((iBuf->roi.lcd_y + iBuf->roi.dst_height) ==
1817                    iBuf->ibuf_height) {
1818                        reg |= BIT(MDP_BOTTOM_CHROMA);
1819                }
1820
1821                if (((iBuf->roi.lcd_x + iBuf->roi.dst_width) ==
1822                     iBuf->ibuf_width) && ((iBuf->roi.dst_width % 2) == 0)) {
1823                        reg |= BIT(MDP_RIGHT_CHROMA);
1824                }
1825
1826                break;
1827
1828        case MDP_Y_CBCR_H2V1:
1829        case MDP_Y_CRCB_H2V1:
1830        case MDP_YCRYCB_H2V1:
1831                if (((iBuf->roi.lcd_x + iBuf->roi.dst_width) ==
1832                     iBuf->ibuf_width) && ((iBuf->roi.dst_width % 2) == 0)) {
1833                        reg |= BIT(MDP_RIGHT_CHROMA);
1834                }
1835                break;
1836        default:
1837                break;
1838        }
1839
1840        *dup2 = reg;
1841
1842        return 0;
1843}
1844
1845#define ADJUST_IP               /* for 1/3 scale factor fix */
1846
1847static int mdp_calc_scale_params(
1848/* ROI origin coordinate for the dimension */
1849                                        uint32 org,
1850/* src ROI dimension */
1851                                        uint32 dim_in,
1852/* scaled ROI dimension*/
1853                                        uint32 dim_out,
1854/* is this ROI width dimension? */
1855                                        boolean is_W,
1856/* initial phase location address */
1857                                        int32 *phase_init_ptr,
1858/* phase increment location address */
1859                                        uint32 *phase_step_ptr,
1860/* ROI start over-fetch location address */
1861                                        uint32 *num_repl_beg_ptr,
1862/* ROI end over-fetch location address */
1863                                        uint32 *num_repl_end_ptr)
1864{
1865        boolean rpa_on = FALSE;
1866        int init_phase = 0;
1867        uint32 beg_of = 0;
1868        uint32 end_of = 0;
1869        uint64 numer = 0;
1870        uint64 denom = 0;
1871        /*uint64 inverter = 1; */
1872        int64 point5 = 1;
1873        int64 one = 1;
1874        int64 k1, k2, k3, k4;   /* linear equation coefficients */
1875        uint64 int_mask;
1876        uint64 fract_mask;
1877        uint64 Os;
1878        int64 Osprime;
1879        int64 Od;
1880        int64 Odprime;
1881        int64 Oreq;
1882        uint64 Es;
1883        uint64 Ed;
1884        uint64 Ereq;
1885#ifdef ADJUST_IP
1886        int64 IP64;
1887        int64 delta;
1888#endif
1889        uint32 mult;
1890
1891        /*
1892         * The phase accumulator should really be rational for all cases in a
1893         * general purpose polyphase scaler for a tiled architecture with
1894         * non-zero * origin capability because there is no way to represent
1895         * certain scale factors in fixed point regardless of precision.
1896         * The error incurred in attempting to use fixed point is most
1897         * eggregious for SF where 1/SF is an integral multiple of 1/3.
1898         *
1899         * However, since the MDP2 has already been committed to HW, we
1900         * only use the rational phase accumulator (RPA) when 1/SF is an
1901         * integral multiple of 1/3.  This will help minimize regressions in
1902         * matching the HW to the C-Sim.
1903         */
1904        /*
1905         * Set the RPA flag for this dimension.
1906         *
1907         * In order for 1/SF (dim_in/dim_out) to be an integral multiple of
1908         * 1/3, dim_out must be an integral multiple of 3.
1909         */
1910        if (!(dim_out % 3)) {
1911                mult = dim_out / 3;
1912                rpa_on = (!(dim_in % mult));
1913        }
1914
1915        numer = dim_out;
1916        denom = dim_in;
1917
1918        /*
1919         * convert to U30.34 before division
1920         *
1921         * The K vectors carry 4 extra bits of precision
1922         * and are rounded.
1923         *
1924         * We initially go 5 bits over then round by adding
1925         * 1 and right shifting by 1
1926         * so final result is U31.33
1927         */
1928        numer <<= PQF_PLUS_5;
1929
1930        /* now calculate the scale factor (aka k3) */
1931        k3 = ((mdp_do_div(numer, denom) + 1) >> 1);
1932
1933        /* check scale factor for legal range [0.25 - 4.0] */
1934        if (((k3 >> 4) < (1LL << PQF_MINUS_2)) ||
1935            ((k3 >> 4) > (1LL << PQF_PLUS_2))) {
1936                return -1;
1937        }
1938
1939        /* calculate inverse scale factor (aka k1) for phase init */
1940        numer = dim_in;
1941        denom = dim_out;
1942        numer <<= PQF_PLUS_5;
1943        k1 = ((mdp_do_div(numer, denom) + 1) >> 1);
1944
1945        /*
1946         * calculate initial phase and ROI overfetch
1947         */
1948        /* convert point5 & one to S39.24 (will always be positive) */
1949        point5 <<= (PQF_PLUS_4 - 1);
1950        one <<= PQF_PLUS_4;
1951        k2 = ((k1 - one) >> 1);
1952        init_phase = (int)(k2 >> 4);
1953        k4 = ((k3 - one) >> 1);
1954        if (k3 == one) {
1955                /* the simple case; SF = 1.0 */
1956                beg_of = 1;
1957                end_of = 2;
1958        } else {
1959                /* calculate the masks */
1960                fract_mask = one - 1;
1961                int_mask = ~fract_mask;
1962
1963                if (!rpa_on) {
1964                        /*
1965                         * FIXED POINT IMPLEMENTATION
1966                         */
1967                        if (!org) {
1968                                /* A fairly simple case; ROI origin = 0 */
1969                                if (k1 < one) {
1970                                        /* upscaling */
1971                                        beg_of = end_of = 2;
1972                                }
1973                                /* 0.33 <= SF < 1.0 */
1974                                else if (k1 < (3LL << PQF_PLUS_4))
1975                                        beg_of = end_of = 1;
1976                                /* 0.33 == SF */
1977                                else if (k1 == (3LL << PQF_PLUS_4)) {
1978                                        beg_of = 0;
1979                                        end_of = 1;
1980                                }
1981                                /* 0.25 <= SF < 0.33 */
1982                                else
1983                                        beg_of = end_of = 0;
1984                        } else {
1985                                /*
1986                                 * The complicated case; ROI origin != 0
1987                                 * init_phase needs to be adjusted
1988                                 * OF is also position dependent
1989                                 */
1990
1991                                /* map (org - .5) into destination space */
1992                                Os = ((uint64) org << 1) - 1;
1993                                Od = ((k3 * Os) >> 1) + k4;
1994
1995                                /* take the ceiling */
1996                                Odprime = (Od & int_mask);
1997                                if (Odprime != Od)
1998                                        Odprime += one;
1999
2000                                /* now map that back to source space */
2001                                Osprime = (k1 * (Odprime >> PQF_PLUS_4)) + k2;
2002
2003                                /* then floor & decrement to calculate the required
2004                                   starting coordinate */
2005                                Oreq = (Osprime & int_mask) - one;
2006
2007                                /* calculate end coord in destination space then map to
2008                                   source space */
2009                                Ed = Odprime +
2010                                    ((uint64) dim_out << PQF_PLUS_4) - one;
2011                                Es = (k1 * (Ed >> PQF_PLUS_4)) + k2;
2012
2013                                /* now floor & increment by 2 to calculate the required
2014                                   ending coordinate */
2015                                Ereq = (Es & int_mask) + (one << 1);
2016
2017                                /* calculate initial phase */
2018#ifdef ADJUST_IP
2019
2020                                IP64 = Osprime - Oreq;
2021                                delta = ((int64) (org) << PQF_PLUS_4) - Oreq;
2022                                IP64 -= delta;
2023
2024                                /* limit to valid range before the left shift */
2025                                delta = (IP64 & (1LL << 63)) ? 4 : -4;
2026                                delta <<= PQF_PLUS_4;
2027                                while (abs((int)(IP64 >> PQF_PLUS_4)) > 4)
2028                                        IP64 += delta;
2029
2030                                /* right shift to account for extra bits of precision */
2031                                init_phase = (int)(IP64 >> 4);
2032
2033#else /* ADJUST_IP */
2034
2035                                /* just calculate the real initial phase */
2036                                init_phase = (int)((Osprime - Oreq) >> 4);
2037
2038#endif /* ADJUST_IP */
2039
2040                                /* calculate the overfetch */
2041                                beg_of = org - (uint32) (Oreq >> PQF_PLUS_4);
2042                                end_of =
2043                                    (uint32) (Ereq >> PQF_PLUS_4) - (org +
2044                                                                     dim_in -
2045                                                                     1);
2046                        }
2047                } else {
2048                        /*
2049                         * RPA IMPLEMENTATION
2050                         *
2051                         * init_phase needs to be calculated in all RPA_on cases
2052                         * because it's a numerator, not a fixed point value.
2053                         */
2054
2055                        /* map (org - .5) into destination space */
2056                        Os = ((uint64) org << PQF_PLUS_4) - point5;
2057                        Od = mdp_do_div((dim_out * (Os + point5)),
2058                                        dim_in) - point5;
2059
2060                        /* take the ceiling */
2061                        Odprime = (Od & int_mask);
2062                        if (Odprime != Od)
2063                                Odprime += one;
2064
2065                        /* now map that back to source space */
2066                        Osprime =
2067                            mdp_do_div((dim_in * (Odprime + point5)),
2068                                       dim_out) - point5;
2069
2070                        /* then floor & decrement to calculate the required
2071                           starting coordinate */
2072                        Oreq = (Osprime & int_mask) - one;
2073
2074                        /* calculate end coord in destination space then map to
2075                           source space */
2076                        Ed = Odprime + ((uint64) dim_out << PQF_PLUS_4) - one;
2077                        Es = mdp_do_div((dim_in * (Ed + point5)),
2078                                        dim_out) - point5;
2079
2080                        /* now floor & increment by 2 to calculate the required
2081                           ending coordinate */
2082                        Ereq = (Es & int_mask) + (one << 1);
2083
2084                        /* calculate initial phase */
2085
2086#ifdef ADJUST_IP
2087
2088                        IP64 = Osprime - Oreq;
2089                        delta = ((int64) (org) << PQF_PLUS_4) - Oreq;
2090                        IP64 -= delta;
2091
2092                        /* limit to valid range before the left shift */
2093                        delta = (IP64 & (1LL << 63)) ? 4 : -4;
2094                        delta <<= PQF_PLUS_4;
2095                        while (abs((int)(IP64 >> PQF_PLUS_4)) > 4)
2096                                IP64 += delta;
2097
2098                        /* right shift to account for extra bits of precision */
2099                        init_phase = (int)(IP64 >> 4);
2100
2101#else /* ADJUST_IP */
2102
2103                        /* just calculate the real initial phase */
2104                        init_phase = (int)((Osprime - Oreq) >> 4);
2105
2106#endif /* ADJUST_IP */
2107
2108                        /* calculate the overfetch */
2109                        beg_of = org - (uint32) (Oreq >> PQF_PLUS_4);
2110                        end_of =
2111                            (uint32) (Ereq >> PQF_PLUS_4) - (org + dim_in - 1);
2112                }
2113        }
2114
2115        /* return the scale parameters */
2116        *phase_init_ptr = init_phase;
2117        *phase_step_ptr = (uint32) (k1 >> 4);
2118        *num_repl_beg_ptr = beg_of;
2119        *num_repl_end_ptr = end_of;
2120
2121        return 0;
2122}
2123
2124static uint8 *mdp_adjust_rot_addr(MDPIBUF *iBuf, uint8 *addr, uint32 uv)
2125{
2126        uint32 dest_ystride = iBuf->ibuf_width * iBuf->bpp;
2127        uint32 h_slice = 1;
2128
2129        if (uv && ((iBuf->ibuf_type == MDP_Y_CBCR_H2V2) ||
2130                (iBuf->ibuf_type == MDP_Y_CRCB_H2V2)))
2131                h_slice = 2;
2132
2133        if (MDP_CHKBIT(iBuf->mdpImg.mdpOp, MDPOP_ROT90) ^
2134            MDP_CHKBIT(iBuf->mdpImg.mdpOp, MDPOP_LR)) {
2135                addr =
2136                    addr + (iBuf->roi.dst_width -
2137                            MIN(16, iBuf->roi.dst_width)) * iBuf->bpp;
2138        }
2139        if (MDP_CHKBIT(iBuf->mdpImg.mdpOp, MDPOP_UD)) {
2140                addr =
2141                    addr + ((iBuf->roi.dst_height -
2142                        MIN(16, iBuf->roi.dst_height))/h_slice) * dest_ystride;
2143        }
2144
2145        return addr;
2146}
2147
2148void mdp_set_scale(MDPIBUF *iBuf,
2149                   uint32 dst_roi_width,
2150                   uint32 dst_roi_height,
2151                   boolean inputRGB, boolean outputRGB, uint32 *pppop_reg_ptr)
2152{
2153        uint32 dst_roi_width_scale;
2154        uint32 dst_roi_height_scale;
2155        boolean use_pr;
2156        uint32 phasex_step = 0;
2157        uint32 phasey_step = 0;
2158        int32 phasex_init = 0;
2159        int32 phasey_init = 0;
2160        uint32 lines_dup = 0;
2161        uint32 lines_dup_bg = 0;
2162        uint32 dummy;
2163        uint32 mdp_blur = 0;
2164
2165        if (iBuf->mdpImg.mdpOp & MDPOP_ASCALE) {
2166                if (iBuf->mdpImg.mdpOp & MDPOP_ROT90) {
2167                        dst_roi_width_scale = dst_roi_height;
2168                        dst_roi_height_scale = dst_roi_width;
2169                } else {
2170                        dst_roi_width_scale = dst_roi_width;
2171                        dst_roi_height_scale = dst_roi_height;
2172                }
2173
2174                mdp_blur = iBuf->mdpImg.mdpOp & MDPOP_BLUR;
2175
2176                if ((dst_roi_width_scale != iBuf->roi.width) ||
2177                    (dst_roi_height_scale != iBuf->roi.height) ||
2178                        mdp_blur) {
2179                        *pppop_reg_ptr |=
2180                            (PPP_OP_SCALE_Y_ON | PPP_OP_SCALE_X_ON);
2181
2182                /* let's use SHIM logic to calculate the partial ROI scaling */
2183#if 0
2184                        phasex_step =
2185                            (uint32) mdp_do_div(0x20000000 * iBuf->roi.width,
2186                                                dst_roi_width_scale);
2187                        phasey_step =
2188                            (uint32) mdp_do_div(0x20000000 * iBuf->roi.height,
2189                                                dst_roi_height_scale);
2190
2191/*
2192    phasex_step= ((long long) iBuf->roi.width * 0x20000000)/dst_roi_width_scale;
2193    phasey_step= ((long long)iBuf->roi.height * 0x20000000)/dst_roi_height_scale;
2194*/
2195
2196                        phasex_init =
2197                            (((long long)phasex_step - 0x20000000) >> 1);
2198                        phasey_init =
2199                            (((long long)phasey_step - 0x20000000) >> 1);
2200
2201#else
2202                        mdp_calc_scale_params(iBuf->roi.x, iBuf->roi.width,
2203                                              dst_roi_width_scale, 1,
2204                                              &phasex_init, &phasex_step,
2205                                              &dummy, &dummy);
2206                        mdp_calc_scale_params(iBuf->roi.y, iBuf->roi.height,
2207                                              dst_roi_height_scale, 0,
2208                                              &phasey_init, &phasey_step,
2209                                              &dummy, &dummy);
2210#endif
2211                        MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x013c,
2212                                 phasex_init);
2213                        MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0140,
2214                                 phasey_init);
2215                        MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0144,
2216                                 phasex_step);
2217                        MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0148,
2218                                 phasey_step);
2219
2220                        use_pr = (inputRGB) && (outputRGB);
2221
2222                        if ((dst_roi_width_scale > iBuf->roi.width) ||
2223                            (dst_roi_height_scale > iBuf->roi.height)) {
2224                                if ((use_pr)
2225                                    && (mdp_curr_up_scale_xy !=
2226                                        MDP_PR_SCALE_UP)) {
2227                                        mdp_load_pr_upscale_table();
2228                                        mdp_curr_up_scale_xy = MDP_PR_SCALE_UP;
2229                                } else if ((!use_pr)
2230                                           && (mdp_curr_up_scale_xy !=
2231                                               MDP_BC_SCALE_UP)) {
2232                                        mdp_load_bc_upscale_table();
2233                                        mdp_curr_up_scale_xy = MDP_BC_SCALE_UP;
2234                                }
2235                        }
2236
2237                        if (mdp_blur) {
2238                                load_scale_table(mdp_gaussian_blur_table,
2239                                        ARRAY_SIZE(mdp_gaussian_blur_table));
2240                                mdp_curr_down_scale_x = MDP_SCALE_BLUR;
2241                                mdp_curr_down_scale_y = MDP_SCALE_BLUR;
2242                        }
2243
2244                        /* 0.2 < x <= 1 scaling factor */
2245                        if ((dst_roi_width_scale <= iBuf->roi.width) &&
2246                                !mdp_blur) {
2247                                if (((dst_roi_width_scale * 10) /
2248                                     iBuf->roi.width) > 8) {
2249                                        if ((use_pr)
2250                                            && (mdp_curr_down_scale_x !=
2251                                                MDP_PR_SCALE_POINT8_1)) {
2252                                                mdp_load_pr_downscale_table_x_point8TO1
2253                                                    ();
2254                                                mdp_curr_down_scale_x =
2255                                                    MDP_PR_SCALE_POINT8_1;
2256                                        } else if ((!use_pr)
2257                                                   && (mdp_curr_down_scale_x !=
2258                                                       MDP_BC_SCALE_POINT8_1)) {
2259                                                mdp_load_bc_downscale_table_x_point8TO1
2260                                                    ();
2261                                                mdp_curr_down_scale_x =
2262                                                    MDP_BC_SCALE_POINT8_1;
2263                                        }
2264                                } else
2265                                    if (((dst_roi_width_scale * 10) /
2266                                         iBuf->roi.width) > 6) {
2267                                        if ((use_pr)
2268                                            && (mdp_curr_down_scale_x !=
2269                                                MDP_PR_SCALE_POINT6_POINT8)) {
2270                                                mdp_load_pr_downscale_table_x_point6TOpoint8
2271                                                    ();
2272                                                mdp_curr_down_scale_x =
2273                                                    MDP_PR_SCALE_POINT6_POINT8;
2274                                        } else if ((!use_pr)
2275                                                   && (mdp_curr_down_scale_x !=
2276                                                       MDP_BC_SCALE_POINT6_POINT8))
2277                                        {
2278                                                mdp_load_bc_downscale_table_x_point6TOpoint8
2279                                                    ();
2280                                                mdp_curr_down_scale_x =
2281                                                    MDP_BC_SCALE_POINT6_POINT8;
2282                                        }
2283                                } else
2284                                    if (((dst_roi_width_scale * 10) /
2285                                         iBuf->roi.width) > 4) {
2286                                        if ((use_pr)
2287                                            && (mdp_curr_down_scale_x !=
2288                                                MDP_PR_SCALE_POINT4_POINT6)) {
2289                                                mdp_load_pr_downscale_table_x_point4TOpoint6
2290                                                    ();
2291                                                mdp_curr_down_scale_x =
2292                                                    MDP_PR_SCALE_POINT4_POINT6;
2293                                        } else if ((!use_pr)
2294                                                   && (mdp_curr_down_scale_x !=
2295                                                       MDP_BC_SCALE_POINT4_POINT6))
2296                                        {
2297                                                mdp_load_bc_downscale_table_x_point4TOpoint6
2298                                                    ();
2299                                                mdp_curr_down_scale_x =
2300                                                    MDP_BC_SCALE_POINT4_POINT6;
2301                                        }
2302                                } else {
2303                                        if ((use_pr)
2304                                            && (mdp_curr_down_scale_x !=
2305                                                MDP_PR_SCALE_POINT2_POINT4)) {
2306                                                mdp_load_pr_downscale_table_x_point2TOpoint4
2307                                                    ();
2308                                                mdp_curr_down_scale_x =
2309                                                    MDP_PR_SCALE_POINT2_POINT4;
2310                                        } else if ((!use_pr)
2311                                                   && (mdp_curr_down_scale_x !=
2312                                                       MDP_BC_SCALE_POINT2_POINT4))
2313                                        {
2314                                                mdp_load_bc_downscale_table_x_point2TOpoint4
2315                                                    ();
2316                                                mdp_curr_down_scale_x =
2317                                                    MDP_BC_SCALE_POINT2_POINT4;
2318                                        }
2319                                }
2320                        }
2321                        /* 0.2 < y <= 1 scaling factor */
2322                        if ((dst_roi_height_scale <= iBuf->roi.height) &&
2323                                !mdp_blur) {
2324                                if (((dst_roi_height_scale * 10) /
2325                                     iBuf->roi.height) > 8) {
2326                                        if ((use_pr)
2327                                            && (mdp_curr_down_scale_y !=
2328                                                MDP_PR_SCALE_POINT8_1)) {
2329                                                mdp_load_pr_downscale_table_y_point8TO1
2330                                                    ();
2331                                                mdp_curr_down_scale_y =
2332                                                    MDP_PR_SCALE_POINT8_1;
2333                                        } else if ((!use_pr)
2334                                                   && (mdp_curr_down_scale_y !=
2335                                                       MDP_BC_SCALE_POINT8_1)) {
2336                                                mdp_load_bc_downscale_table_y_point8TO1
2337                                                    ();
2338                                                mdp_curr_down_scale_y =
2339                                                    MDP_BC_SCALE_POINT8_1;
2340                                        }
2341                                } else
2342                                    if (((dst_roi_height_scale * 10) /
2343                                         iBuf->roi.height) > 6) {
2344                                        if ((use_pr)
2345                                            && (mdp_curr_down_scale_y !=
2346                                                MDP_PR_SCALE_POINT6_POINT8)) {
2347                                                mdp_load_pr_downscale_table_y_point6TOpoint8
2348                                                    ();
2349                                                mdp_curr_down_scale_y =
2350                                                    MDP_PR_SCALE_POINT6_POINT8;
2351                                        } else if ((!use_pr)
2352                                                   && (mdp_curr_down_scale_y !=
2353                                                       MDP_BC_SCALE_POINT6_POINT8))
2354                                        {
2355                                                mdp_load_bc_downscale_table_y_point6TOpoint8
2356                                                    ();
2357                                                mdp_curr_down_scale_y =
2358                                                    MDP_BC_SCALE_POINT6_POINT8;
2359                                        }
2360                                } else
2361                                    if (((dst_roi_height_scale * 10) /
2362                                         iBuf->roi.height) > 4) {
2363                                        if ((use_pr)
2364                                            && (mdp_curr_down_scale_y !=
2365                                                MDP_PR_SCALE_POINT4_POINT6)) {
2366                                                mdp_load_pr_downscale_table_y_point4TOpoint6
2367                                                    ();
2368                                                mdp_curr_down_scale_y =
2369                                                    MDP_PR_SCALE_POINT4_POINT6;
2370                                        } else if ((!use_pr)
2371                                                   && (mdp_curr_down_scale_y !=
2372                                                       MDP_BC_SCALE_POINT4_POINT6))
2373                                        {
2374                                                mdp_load_bc_downscale_table_y_point4TOpoint6
2375                                                    ();
2376                                                mdp_curr_down_scale_y =
2377                                                    MDP_BC_SCALE_POINT4_POINT6;
2378                                        }
2379                                } else {
2380                                        if ((use_pr)
2381                                            && (mdp_curr_down_scale_y !=
2382                                                MDP_PR_SCALE_POINT2_POINT4)) {
2383                                                mdp_load_pr_downscale_table_y_point2TOpoint4
2384                                                    ();
2385                                                mdp_curr_down_scale_y =
2386                                                    MDP_PR_SCALE_POINT2_POINT4;
2387                                        } else if ((!use_pr)
2388                                                   && (mdp_curr_down_scale_y !=
2389                                                       MDP_BC_SCALE_POINT2_POINT4))
2390                                        {
2391                                                mdp_load_bc_downscale_table_y_point2TOpoint4
2392                                                    ();
2393                                                mdp_curr_down_scale_y =
2394                                                    MDP_BC_SCALE_POINT2_POINT4;
2395                                        }
2396                                }
2397                        }
2398                } else {
2399                        iBuf->mdpImg.mdpOp &= ~(MDPOP_ASCALE);
2400                }
2401        }
2402        /* setting edge condition here after scaling check */
2403        if (mdp_get_edge_cond(iBuf, &lines_dup, &lines_dup_bg))
2404                printk(KERN_ERR "msm_fb: mdp_get_edge_cond() error!\n");
2405
2406        MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01b8, lines_dup);
2407        MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01bc, lines_dup_bg);
2408}
2409
2410void mdp_init_scale_table(void)
2411{
2412        mdp_curr_up_scale_xy = MDP_INIT_SCALE;
2413        mdp_curr_down_scale_x = MDP_INIT_SCALE;
2414        mdp_curr_down_scale_y = MDP_INIT_SCALE;
2415}
2416
2417void mdp_adjust_start_addr(uint8 **src0,
2418                           uint8 **src1,
2419                           int v_slice,
2420                           int h_slice,
2421                           int x,
2422                           int y,
2423                           uint32 width,
2424                           uint32 height, int bpp, MDPIBUF *iBuf, int layer)
2425{
2426        *src0 += (x + y * width) * bpp;
2427
2428        /* if it's dest/bg buffer, we need to adjust it for rotation */
2429        if (layer != 0)
2430                *src0 = mdp_adjust_rot_addr(iBuf, *src0, 0);
2431
2432        if (*src1) {
2433                /*
2434                 * MDP_Y_CBCR_H2V2/MDP_Y_CRCB_H2V2 cosite for now
2435                 * we need to shift x direction same as y dir for offsite
2436                 */
2437                *src1 +=
2438                    ((x / h_slice) * h_slice +
2439                     ((y == 0) ? 0 : ((y + 1) / v_slice - 1) * width)) * bpp;
2440
2441                /* if it's dest/bg buffer, we need to adjust it for rotation */
2442                if (layer != 0)
2443                        *src1 = mdp_adjust_rot_addr(iBuf, *src1, 1);
2444        }
2445}
2446
2447void mdp_set_blend_attr(MDPIBUF *iBuf,
2448                        uint32 *alpha,
2449                        uint32 *tpVal,
2450                        uint32 perPixelAlpha, uint32 *pppop_reg_ptr)
2451{
2452        if (perPixelAlpha) {
2453                *pppop_reg_ptr |= PPP_OP_ROT_ON |
2454                    PPP_OP_BLEND_ON | PPP_OP_BLEND_SRCPIXEL_ALPHA;
2455        } else {
2456                if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB)
2457                    && (iBuf->mdpImg.alpha == 0xff)) {
2458                        iBuf->mdpImg.mdpOp &= ~(MDPOP_ALPHAB);
2459                }
2460
2461                if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB)
2462                    && (iBuf->mdpImg.mdpOp & MDPOP_TRANSP)) {
2463                        *pppop_reg_ptr |=
2464                            PPP_OP_ROT_ON | PPP_OP_BLEND_ON |
2465                            PPP_OP_BLEND_CONSTANT_ALPHA |
2466                            PPP_OP_BLEND_ALPHA_BLEND_NORMAL |
2467                            PPP_BLEND_CALPHA_TRNASP;
2468
2469                        *alpha = iBuf->mdpImg.alpha;
2470                        *tpVal = iBuf->mdpImg.tpVal;
2471                } else {
2472                        if (iBuf->mdpImg.mdpOp & MDPOP_TRANSP) {
2473                                *pppop_reg_ptr |= PPP_OP_ROT_ON |
2474                                    PPP_OP_BLEND_ON |
2475                                    PPP_OP_BLEND_SRCPIXEL_TRANSP;
2476                                *tpVal = iBuf->mdpImg.tpVal;
2477                        } else if (iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) {
2478                                *pppop_reg_ptr |= PPP_OP_ROT_ON |
2479                                    PPP_OP_BLEND_ON |
2480                                    PPP_OP_BLEND_ALPHA_BLEND_NORMAL |
2481                                    PPP_OP_BLEND_CONSTANT_ALPHA;
2482                                *alpha = iBuf->mdpImg.alpha;
2483                        }
2484                }
2485        }
2486}
2487