1/* 2 * Copyright 2010 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 * 23 * Author: Alex Deucher <alexander.deucher@amd.com> 24 * 25 */ 26 27#ifdef HAVE_CONFIG_H 28#include "config.h" 29#endif 30 31#ifdef XF86DRM_MODE 32 33#include "xf86.h" 34 35#include "exa.h" 36 37#include "radeon.h" 38#include "radeon_reg.h" 39#include "evergreen_shader.h" 40#include "evergreen_reg.h" 41#include "evergreen_state.h" 42 43#include "radeon_video.h" 44 45#include <X11/extensions/Xv.h> 46#include "fourcc.h" 47 48#include "damage.h" 49 50#include "radeon_exa_shared.h" 51#include "radeon_vbo.h" 52 53/* Parameters for ITU-R BT.601 and ITU-R BT.709 colour spaces 54 note the difference to the parameters used in overlay are due 55 to 10bit vs. float calcs */ 56static REF_TRANSFORM trans[2] = 57{ 58 {1.1643, 0.0, 1.5960, -0.3918, -0.8129, 2.0172, 0.0}, /* BT.601 */ 59 {1.1643, 0.0, 1.7927, -0.2132, -0.5329, 2.1124, 0.0} /* BT.709 */ 60}; 61 62void 63EVERGREENDisplayTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv) 64{ 65 RADEONInfoPtr info = RADEONPTR(pScrn); 66 struct radeon_accel_state *accel_state = info->accel_state; 67 PixmapPtr pPixmap = pPriv->pPixmap; 68 BoxPtr pBox = REGION_RECTS(&pPriv->clip); 69 int nBox = REGION_NUM_RECTS(&pPriv->clip); 70 int dstxoff, dstyoff; 71 struct r600_accel_object src_obj, dst_obj; 72 cb_config_t cb_conf; 73 tex_resource_t tex_res; 74 tex_sampler_t tex_samp; 75 shader_config_t vs_conf, ps_conf; 76 /* 77 * y' = y - .0625 78 * u' = u - .5 79 * v' = v - .5; 80 * 81 * r = 1.1643 * y' + 0.0 * u' + 1.5958 * v' 82 * g = 1.1643 * y' - 0.39173 * u' - 0.81290 * v' 83 * b = 1.1643 * y' + 2.017 * u' + 0.0 * v' 84 * 85 * DP3 might look like the straightforward solution 86 * but we'd need to move the texture yuv values in 87 * the same reg for this to work. Therefore use MADs. 88 * Brightness just adds to the off constant. 89 * Contrast is multiplication of luminance. 90 * Saturation and hue change the u and v coeffs. 91 * Default values (before adjustments - depend on colorspace): 92 * yco = 1.1643 93 * uco = 0, -0.39173, 2.017 94 * vco = 1.5958, -0.8129, 0 95 * off = -0.0625 * yco + -0.5 * uco[r] + -0.5 * vco[r], 96 * -0.0625 * yco + -0.5 * uco[g] + -0.5 * vco[g], 97 * -0.0625 * yco + -0.5 * uco[b] + -0.5 * vco[b], 98 * 99 * temp = MAD(yco, yuv.yyyy, off) 100 * temp = MAD(uco, yuv.uuuu, temp) 101 * result = MAD(vco, yuv.vvvv, temp) 102 */ 103 /* TODO: calc consts in the shader */ 104 const float Loff = -0.0627; 105 const float Coff = -0.502; 106 float uvcosf, uvsinf; 107 float yco; 108 float uco[3], vco[3], off[3]; 109 float bright, cont, gamma; 110 int ref = pPriv->transform_index; 111 Bool needgamma = FALSE; 112 float *ps_alu_consts; 113 const_config_t ps_const_conf; 114 float *vs_alu_consts; 115 const_config_t vs_const_conf; 116 117 cont = RTFContrast(pPriv->contrast); 118 bright = RTFBrightness(pPriv->brightness); 119 gamma = (float)pPriv->gamma / 1000.0; 120 uvcosf = RTFSaturation(pPriv->saturation) * cos(RTFHue(pPriv->hue)); 121 uvsinf = RTFSaturation(pPriv->saturation) * sin(RTFHue(pPriv->hue)); 122 /* overlay video also does pre-gamma contrast/sat adjust, should we? */ 123 124 yco = trans[ref].RefLuma * cont; 125 uco[0] = -trans[ref].RefRCr * uvsinf; 126 uco[1] = trans[ref].RefGCb * uvcosf - trans[ref].RefGCr * uvsinf; 127 uco[2] = trans[ref].RefBCb * uvcosf; 128 vco[0] = trans[ref].RefRCr * uvcosf; 129 vco[1] = trans[ref].RefGCb * uvsinf + trans[ref].RefGCr * uvcosf; 130 vco[2] = trans[ref].RefBCb * uvsinf; 131 off[0] = Loff * yco + Coff * (uco[0] + vco[0]) + bright; 132 off[1] = Loff * yco + Coff * (uco[1] + vco[1]) + bright; 133 off[2] = Loff * yco + Coff * (uco[2] + vco[2]) + bright; 134 135 // XXX 136 gamma = 1.0; 137 138 if (gamma != 1.0) { 139 needgamma = TRUE; 140 /* note: gamma correction is out = in ^ gamma; 141 gpu can only do LG2/EX2 therefore we transform into 142 in ^ gamma = 2 ^ (log2(in) * gamma). 143 Lots of scalar ops, unfortunately (better solution?) - 144 without gamma that's 3 inst, with gamma it's 10... 145 could use different gamma factors per channel, 146 if that's of any use. */ 147 } 148 149 CLEAR (cb_conf); 150 CLEAR (tex_res); 151 CLEAR (tex_samp); 152 CLEAR (vs_conf); 153 CLEAR (ps_conf); 154 CLEAR (vs_const_conf); 155 CLEAR (ps_const_conf); 156 157 dst_obj.offset = 0; 158 src_obj.offset = 0; 159 dst_obj.bo = radeon_get_pixmap_bo(pPixmap); 160 dst_obj.tiling_flags = radeon_get_pixmap_tiling(pPixmap); 161 dst_obj.surface = radeon_get_pixmap_surface(pPixmap); 162 163 dst_obj.pitch = exaGetPixmapPitch(pPixmap) / (pPixmap->drawable.bitsPerPixel / 8); 164 165 src_obj.pitch = pPriv->src_pitch; 166 src_obj.width = pPriv->w; 167 src_obj.height = pPriv->h; 168 src_obj.bpp = 16; 169 src_obj.domain = RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT; 170 src_obj.bo = pPriv->src_bo[pPriv->currentBuffer]; 171 src_obj.tiling_flags = 0; 172 src_obj.surface = NULL; 173 174 dst_obj.width = pPixmap->drawable.width; 175 dst_obj.height = pPixmap->drawable.height; 176 dst_obj.bpp = pPixmap->drawable.bitsPerPixel; 177 dst_obj.domain = RADEON_GEM_DOMAIN_VRAM; 178 179 if (!R600SetAccelState(pScrn, 180 &src_obj, 181 NULL, 182 &dst_obj, 183 accel_state->xv_vs_offset, accel_state->xv_ps_offset, 184 3, 0xffffffff)) 185 return; 186 187#ifdef COMPOSITE 188 dstxoff = -pPixmap->screen_x + pPixmap->drawable.x; 189 dstyoff = -pPixmap->screen_y + pPixmap->drawable.y; 190#else 191 dstxoff = 0; 192 dstyoff = 0; 193#endif 194 195 radeon_vbo_check(pScrn, &accel_state->vbo, 16); 196 radeon_vbo_check(pScrn, &accel_state->cbuf, 512); 197 radeon_cp_start(pScrn); 198 199 evergreen_set_default_state(pScrn); 200 201 evergreen_set_generic_scissor(pScrn, 0, 0, accel_state->dst_obj.width, accel_state->dst_obj.height); 202 evergreen_set_screen_scissor(pScrn, 0, 0, accel_state->dst_obj.width, accel_state->dst_obj.height); 203 evergreen_set_window_scissor(pScrn, 0, 0, accel_state->dst_obj.width, accel_state->dst_obj.height); 204 205 /* PS bool constant */ 206 switch(pPriv->id) { 207 case FOURCC_YV12: 208 case FOURCC_I420: 209 evergreen_set_bool_consts(pScrn, SQ_BOOL_CONST_ps, (1 << 0)); 210 break; 211 case FOURCC_UYVY: 212 case FOURCC_YUY2: 213 default: 214 evergreen_set_bool_consts(pScrn, SQ_BOOL_CONST_ps, (0 << 0)); 215 break; 216 } 217 218 /* Shader */ 219 vs_conf.shader_addr = accel_state->vs_mc_addr; 220 vs_conf.shader_size = accel_state->vs_size; 221 vs_conf.num_gprs = 2; 222 vs_conf.stack_size = 0; 223 vs_conf.bo = accel_state->shaders_bo; 224 evergreen_vs_setup(pScrn, &vs_conf, RADEON_GEM_DOMAIN_VRAM); 225 226 ps_conf.shader_addr = accel_state->ps_mc_addr; 227 ps_conf.shader_size = accel_state->ps_size; 228 ps_conf.num_gprs = 3; 229 ps_conf.stack_size = 1; 230 ps_conf.clamp_consts = 0; 231 ps_conf.export_mode = 2; 232 ps_conf.bo = accel_state->shaders_bo; 233 evergreen_ps_setup(pScrn, &ps_conf, RADEON_GEM_DOMAIN_VRAM); 234 235 /* Texture */ 236 switch(pPriv->id) { 237 case FOURCC_YV12: 238 case FOURCC_I420: 239 accel_state->src_size[0] = accel_state->src_obj[0].pitch * pPriv->h; 240 241 /* Y texture */ 242 tex_res.id = 0; 243 tex_res.w = accel_state->src_obj[0].width; 244 tex_res.h = accel_state->src_obj[0].height; 245 tex_res.pitch = accel_state->src_obj[0].pitch; 246 tex_res.depth = 0; 247 tex_res.dim = SQ_TEX_DIM_2D; 248 tex_res.base = accel_state->src_obj[0].offset; 249 tex_res.mip_base = accel_state->src_obj[0].offset; 250 tex_res.size = accel_state->src_size[0]; 251 tex_res.bo = accel_state->src_obj[0].bo; 252 tex_res.mip_bo = accel_state->src_obj[0].bo; 253 tex_res.surface = NULL; 254 255 tex_res.format = FMT_8; 256 tex_res.dst_sel_x = SQ_SEL_X; /* Y */ 257 tex_res.dst_sel_y = SQ_SEL_1; 258 tex_res.dst_sel_z = SQ_SEL_1; 259 tex_res.dst_sel_w = SQ_SEL_1; 260 261 tex_res.base_level = 0; 262 tex_res.last_level = 0; 263 tex_res.perf_modulation = 0; 264 tex_res.interlaced = 0; 265 if (accel_state->src_obj[0].tiling_flags == 0) 266 tex_res.array_mode = 1; 267 evergreen_set_tex_resource(pScrn, &tex_res, accel_state->src_obj[0].domain); 268 269 /* Y sampler */ 270 tex_samp.id = 0; 271 tex_samp.clamp_x = SQ_TEX_CLAMP_LAST_TEXEL; 272 tex_samp.clamp_y = SQ_TEX_CLAMP_LAST_TEXEL; 273 tex_samp.clamp_z = SQ_TEX_WRAP; 274 275 /* xxx: switch to bicubic */ 276 tex_samp.xy_mag_filter = SQ_TEX_XY_FILTER_BILINEAR; 277 tex_samp.xy_min_filter = SQ_TEX_XY_FILTER_BILINEAR; 278 279 tex_samp.z_filter = SQ_TEX_Z_FILTER_NONE; 280 tex_samp.mip_filter = 0; /* no mipmap */ 281 evergreen_set_tex_sampler(pScrn, &tex_samp); 282 283 /* U or V texture */ 284 tex_res.id = 1; 285 tex_res.format = FMT_8; 286 tex_res.w = accel_state->src_obj[0].width >> 1; 287 tex_res.h = accel_state->src_obj[0].height >> 1; 288 tex_res.pitch = RADEON_ALIGN(accel_state->src_obj[0].pitch >> 1, pPriv->hw_align); 289 tex_res.dst_sel_x = SQ_SEL_X; /* V or U */ 290 tex_res.dst_sel_y = SQ_SEL_1; 291 tex_res.dst_sel_z = SQ_SEL_1; 292 tex_res.dst_sel_w = SQ_SEL_1; 293 tex_res.interlaced = 0; 294 295 tex_res.base = accel_state->src_obj[0].offset + pPriv->planev_offset; 296 tex_res.mip_base = accel_state->src_obj[0].offset + pPriv->planev_offset; 297 tex_res.size = tex_res.pitch * (pPriv->h >> 1); 298 if (accel_state->src_obj[0].tiling_flags == 0) 299 tex_res.array_mode = 1; 300 evergreen_set_tex_resource(pScrn, &tex_res, accel_state->src_obj[0].domain); 301 302 /* U or V sampler */ 303 tex_samp.id = 1; 304 evergreen_set_tex_sampler(pScrn, &tex_samp); 305 306 /* U or V texture */ 307 tex_res.id = 2; 308 tex_res.format = FMT_8; 309 tex_res.w = accel_state->src_obj[0].width >> 1; 310 tex_res.h = accel_state->src_obj[0].height >> 1; 311 tex_res.pitch = RADEON_ALIGN(accel_state->src_obj[0].pitch >> 1, pPriv->hw_align); 312 tex_res.dst_sel_x = SQ_SEL_X; /* V or U */ 313 tex_res.dst_sel_y = SQ_SEL_1; 314 tex_res.dst_sel_z = SQ_SEL_1; 315 tex_res.dst_sel_w = SQ_SEL_1; 316 tex_res.interlaced = 0; 317 318 tex_res.base = accel_state->src_obj[0].offset + pPriv->planeu_offset; 319 tex_res.mip_base = accel_state->src_obj[0].offset + pPriv->planeu_offset; 320 tex_res.size = tex_res.pitch * (pPriv->h >> 1); 321 if (accel_state->src_obj[0].tiling_flags == 0) 322 tex_res.array_mode = 1; 323 evergreen_set_tex_resource(pScrn, &tex_res, accel_state->src_obj[0].domain); 324 325 /* UV sampler */ 326 tex_samp.id = 2; 327 evergreen_set_tex_sampler(pScrn, &tex_samp); 328 break; 329 case FOURCC_UYVY: 330 case FOURCC_YUY2: 331 default: 332 accel_state->src_size[0] = accel_state->src_obj[0].pitch * pPriv->h; 333 334 /* YUV texture */ 335 tex_res.id = 0; 336 tex_res.w = accel_state->src_obj[0].width; 337 tex_res.h = accel_state->src_obj[0].height; 338 tex_res.pitch = accel_state->src_obj[0].pitch >> 1; 339 tex_res.depth = 0; 340 tex_res.dim = SQ_TEX_DIM_2D; 341 tex_res.base = accel_state->src_obj[0].offset; 342 tex_res.mip_base = accel_state->src_obj[0].offset; 343 tex_res.size = accel_state->src_size[0]; 344 tex_res.bo = accel_state->src_obj[0].bo; 345 tex_res.mip_bo = accel_state->src_obj[0].bo; 346 tex_res.surface = NULL; 347 348 if (pPriv->id == FOURCC_UYVY) 349 tex_res.format = FMT_GB_GR; 350 else 351 tex_res.format = FMT_BG_RG; 352 tex_res.dst_sel_x = SQ_SEL_Y; 353 tex_res.dst_sel_y = SQ_SEL_X; 354 tex_res.dst_sel_z = SQ_SEL_Z; 355 tex_res.dst_sel_w = SQ_SEL_1; 356 357 tex_res.base_level = 0; 358 tex_res.last_level = 0; 359 tex_res.perf_modulation = 0; 360 tex_res.interlaced = 0; 361 if (accel_state->src_obj[0].tiling_flags == 0) 362 tex_res.array_mode = 1; 363 evergreen_set_tex_resource(pScrn, &tex_res, accel_state->src_obj[0].domain); 364 365 /* YUV sampler */ 366 tex_samp.id = 0; 367 tex_samp.clamp_x = SQ_TEX_CLAMP_LAST_TEXEL; 368 tex_samp.clamp_y = SQ_TEX_CLAMP_LAST_TEXEL; 369 tex_samp.clamp_z = SQ_TEX_WRAP; 370 371 tex_samp.xy_mag_filter = SQ_TEX_XY_FILTER_BILINEAR; 372 tex_samp.xy_min_filter = SQ_TEX_XY_FILTER_BILINEAR; 373 374 tex_samp.z_filter = SQ_TEX_Z_FILTER_NONE; 375 tex_samp.mip_filter = 0; /* no mipmap */ 376 evergreen_set_tex_sampler(pScrn, &tex_samp); 377 378 break; 379 } 380 381 cb_conf.id = 0; 382 cb_conf.w = accel_state->dst_obj.pitch; 383 cb_conf.h = accel_state->dst_obj.height; 384 cb_conf.base = accel_state->dst_obj.offset; 385 cb_conf.bo = accel_state->dst_obj.bo; 386 cb_conf.surface = accel_state->dst_obj.surface; 387 388 switch (accel_state->dst_obj.bpp) { 389 case 16: 390 if (pPixmap->drawable.depth == 15) { 391 cb_conf.format = COLOR_1_5_5_5; 392 cb_conf.comp_swap = 1; /* ARGB */ 393 } else { 394 cb_conf.format = COLOR_5_6_5; 395 cb_conf.comp_swap = 2; /* RGB */ 396 } 397#if X_BYTE_ORDER == X_BIG_ENDIAN 398 cb_conf.endian = ENDIAN_8IN16; 399#endif 400 break; 401 case 32: 402 cb_conf.format = COLOR_8_8_8_8; 403 cb_conf.comp_swap = 1; /* ARGB */ 404#if X_BYTE_ORDER == X_BIG_ENDIAN 405 cb_conf.endian = ENDIAN_8IN32; 406#endif 407 break; 408 default: 409 return; 410 } 411 412 cb_conf.source_format = EXPORT_4C_16BPC; 413 cb_conf.blend_clamp = 1; 414 cb_conf.pmask = 0xf; 415 cb_conf.rop = 3; 416 if (accel_state->dst_obj.tiling_flags == 0) { 417 cb_conf.array_mode = 1; 418 cb_conf.non_disp_tiling = 1; 419 } 420 evergreen_set_render_target(pScrn, &cb_conf, accel_state->dst_obj.domain); 421 422 evergreen_set_spi(pScrn, (1 - 1), 1); 423 424 /* PS alu constants */ 425 ps_const_conf.size_bytes = 256; 426 ps_const_conf.type = SHADER_TYPE_PS; 427 ps_alu_consts = radeon_vbo_space(pScrn, &accel_state->cbuf, 256); 428 ps_const_conf.bo = accel_state->cbuf.vb_bo; 429 ps_const_conf.const_addr = accel_state->cbuf.vb_mc_addr + accel_state->cbuf.vb_offset; 430 ps_const_conf.cpu_ptr = (uint32_t *)(char *)ps_alu_consts; 431 432 ps_alu_consts[0] = off[0]; 433 ps_alu_consts[1] = off[1]; 434 ps_alu_consts[2] = off[2]; 435 ps_alu_consts[3] = yco; 436 437 ps_alu_consts[4] = uco[0]; 438 ps_alu_consts[5] = uco[1]; 439 ps_alu_consts[6] = uco[2]; 440 ps_alu_consts[7] = gamma; 441 442 ps_alu_consts[8] = vco[0]; 443 ps_alu_consts[9] = vco[1]; 444 ps_alu_consts[10] = vco[2]; 445 ps_alu_consts[11] = 0.0; 446 447 radeon_vbo_commit(pScrn, &accel_state->cbuf); 448 evergreen_set_alu_consts(pScrn, &ps_const_conf, RADEON_GEM_DOMAIN_GTT); 449 450 /* VS alu constants */ 451 vs_const_conf.size_bytes = 256; 452 vs_const_conf.type = SHADER_TYPE_VS; 453 vs_alu_consts = radeon_vbo_space(pScrn, &accel_state->cbuf, 256); 454 vs_const_conf.bo = accel_state->cbuf.vb_bo; 455 vs_const_conf.const_addr = accel_state->cbuf.vb_mc_addr + accel_state->cbuf.vb_offset; 456 vs_const_conf.cpu_ptr = (uint32_t *)(char *)vs_alu_consts; 457 458 vs_alu_consts[0] = 1.0 / pPriv->w; 459 vs_alu_consts[1] = 1.0 / pPriv->h; 460 vs_alu_consts[2] = 0.0; 461 vs_alu_consts[3] = 0.0; 462 463 radeon_vbo_commit(pScrn, &accel_state->cbuf); 464 evergreen_set_alu_consts(pScrn, &vs_const_conf, RADEON_GEM_DOMAIN_GTT); 465 466 if (pPriv->vsync) { 467 xf86CrtcPtr crtc; 468 if (pPriv->desired_crtc) 469 crtc = pPriv->desired_crtc; 470 else 471 crtc = radeon_pick_best_crtc(pScrn, 472 pPriv->drw_x, 473 pPriv->drw_x + pPriv->dst_w, 474 pPriv->drw_y, 475 pPriv->drw_y + pPriv->dst_h); 476 if (crtc) 477 evergreen_cp_wait_vline_sync(pScrn, pPixmap, 478 crtc, 479 pPriv->drw_y - crtc->y, 480 (pPriv->drw_y - crtc->y) + pPriv->dst_h); 481 } 482 483 while (nBox--) { 484 float srcX, srcY, srcw, srch; 485 int dstX, dstY, dstw, dsth; 486 float *vb; 487 488 489 dstX = pBox->x1 + dstxoff; 490 dstY = pBox->y1 + dstyoff; 491 dstw = pBox->x2 - pBox->x1; 492 dsth = pBox->y2 - pBox->y1; 493 494 srcX = pPriv->src_x; 495 srcX += ((pBox->x1 - pPriv->drw_x) * 496 pPriv->src_w) / (float)pPriv->dst_w; 497 srcY = pPriv->src_y; 498 srcY += ((pBox->y1 - pPriv->drw_y) * 499 pPriv->src_h) / (float)pPriv->dst_h; 500 501 srcw = (pPriv->src_w * dstw) / (float)pPriv->dst_w; 502 srch = (pPriv->src_h * dsth) / (float)pPriv->dst_h; 503 504 vb = radeon_vbo_space(pScrn, &accel_state->vbo, 16); 505 506 vb[0] = (float)dstX; 507 vb[1] = (float)dstY; 508 vb[2] = (float)srcX; 509 vb[3] = (float)srcY; 510 511 vb[4] = (float)dstX; 512 vb[5] = (float)(dstY + dsth); 513 vb[6] = (float)srcX; 514 vb[7] = (float)(srcY + srch); 515 516 vb[8] = (float)(dstX + dstw); 517 vb[9] = (float)(dstY + dsth); 518 vb[10] = (float)(srcX + srcw); 519 vb[11] = (float)(srcY + srch); 520 521 radeon_vbo_commit(pScrn, &accel_state->vbo); 522 523 pBox++; 524 } 525 526 evergreen_finish_op(pScrn, 16); 527 528 DamageDamageRegion(pPriv->pDraw, &pPriv->clip); 529} 530 531#endif 532