aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/exynos/exynos_drm_fimc.c
diff options
context:
space:
mode:
authorAndrzej Hajda <a.hajda@samsung.com>2014-05-19 06:54:08 -0400
committerInki Dae <daeinki@gmail.com>2014-06-01 13:07:11 -0400
commitacd8afa82447be541df3e1d5759cf7fe16b5ea74 (patch)
tree422a940102be1633956f680b7279706b0924694e /drivers/gpu/drm/exynos/exynos_drm_fimc.c
parent8b4609cd80a1150e2dbb3fa69626611002bde1b4 (diff)
drm/exynos/fimc: replace hw access macros with functions
HW access macros implicitly depended on presence of ctx local variable. This patch replaces them with C functions. Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com>
Diffstat (limited to 'drivers/gpu/drm/exynos/exynos_drm_fimc.c')
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimc.c311
1 files changed, 150 insertions, 161 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
index 409775f1efa1..7a66f18c99d5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -69,9 +69,6 @@
69#define get_fimc_context(dev) platform_get_drvdata(to_platform_device(dev)) 69#define get_fimc_context(dev) platform_get_drvdata(to_platform_device(dev))
70#define get_ctx_from_ippdrv(ippdrv) container_of(ippdrv,\ 70#define get_ctx_from_ippdrv(ippdrv) container_of(ippdrv,\
71 struct fimc_context, ippdrv); 71 struct fimc_context, ippdrv);
72#define fimc_read(offset) readl(ctx->regs + (offset))
73#define fimc_write(cfg, offset) writel(cfg, ctx->regs + (offset))
74
75enum fimc_wb { 72enum fimc_wb {
76 FIMC_WB_NONE, 73 FIMC_WB_NONE,
77 FIMC_WB_A, 74 FIMC_WB_A,
@@ -172,39 +169,53 @@ struct fimc_context {
172 bool suspended; 169 bool suspended;
173}; 170};
174 171
172static u32 fimc_read(struct fimc_context *ctx, u32 reg)
173{
174 return readl(ctx->regs + reg);
175}
176
177static void fimc_write(struct fimc_context *ctx, u32 val, u32 reg)
178{
179 writel(val, ctx->regs + reg);
180}
181
182static void fimc_set_bits(struct fimc_context *ctx, u32 reg, u32 bits)
183{
184 void __iomem *r = ctx->regs + reg;
185
186 writel(readl(r) | bits, r);
187}
188
189static void fimc_clear_bits(struct fimc_context *ctx, u32 reg, u32 bits)
190{
191 void __iomem *r = ctx->regs + reg;
192
193 writel(readl(r) & ~bits, r);
194}
195
175static void fimc_sw_reset(struct fimc_context *ctx) 196static void fimc_sw_reset(struct fimc_context *ctx)
176{ 197{
177 u32 cfg; 198 u32 cfg;
178 199
179 /* stop dma operation */ 200 /* stop dma operation */
180 cfg = fimc_read(EXYNOS_CISTATUS); 201 cfg = fimc_read(ctx, EXYNOS_CISTATUS);
181 if (EXYNOS_CISTATUS_GET_ENVID_STATUS(cfg)) { 202 if (EXYNOS_CISTATUS_GET_ENVID_STATUS(cfg))
182 cfg = fimc_read(EXYNOS_MSCTRL); 203 fimc_clear_bits(ctx, EXYNOS_MSCTRL, EXYNOS_MSCTRL_ENVID);
183 cfg &= ~EXYNOS_MSCTRL_ENVID;
184 fimc_write(cfg, EXYNOS_MSCTRL);
185 }
186 204
187 cfg = fimc_read(EXYNOS_CISRCFMT); 205 fimc_set_bits(ctx, EXYNOS_CISRCFMT, EXYNOS_CISRCFMT_ITU601_8BIT);
188 cfg |= EXYNOS_CISRCFMT_ITU601_8BIT;
189 fimc_write(cfg, EXYNOS_CISRCFMT);
190 206
191 /* disable image capture */ 207 /* disable image capture */
192 cfg = fimc_read(EXYNOS_CIIMGCPT); 208 fimc_clear_bits(ctx, EXYNOS_CIIMGCPT,
193 cfg &= ~(EXYNOS_CIIMGCPT_IMGCPTEN_SC | EXYNOS_CIIMGCPT_IMGCPTEN); 209 EXYNOS_CIIMGCPT_IMGCPTEN_SC | EXYNOS_CIIMGCPT_IMGCPTEN);
194 fimc_write(cfg, EXYNOS_CIIMGCPT);
195 210
196 /* s/w reset */ 211 /* s/w reset */
197 cfg = fimc_read(EXYNOS_CIGCTRL); 212 fimc_set_bits(ctx, EXYNOS_CIGCTRL, EXYNOS_CIGCTRL_SWRST);
198 cfg |= (EXYNOS_CIGCTRL_SWRST);
199 fimc_write(cfg, EXYNOS_CIGCTRL);
200 213
201 /* s/w reset complete */ 214 /* s/w reset complete */
202 cfg = fimc_read(EXYNOS_CIGCTRL); 215 fimc_clear_bits(ctx, EXYNOS_CIGCTRL, EXYNOS_CIGCTRL_SWRST);
203 cfg &= ~EXYNOS_CIGCTRL_SWRST;
204 fimc_write(cfg, EXYNOS_CIGCTRL);
205 216
206 /* reset sequence */ 217 /* reset sequence */
207 fimc_write(0x0, EXYNOS_CIFCNTSEQ); 218 fimc_write(ctx, 0x0, EXYNOS_CIFCNTSEQ);
208} 219}
209 220
210static int fimc_set_camblk_fimd0_wb(struct fimc_context *ctx) 221static int fimc_set_camblk_fimd0_wb(struct fimc_context *ctx)
@@ -220,7 +231,7 @@ static void fimc_set_type_ctrl(struct fimc_context *ctx, enum fimc_wb wb)
220 231
221 DRM_DEBUG_KMS("wb[%d]\n", wb); 232 DRM_DEBUG_KMS("wb[%d]\n", wb);
222 233
223 cfg = fimc_read(EXYNOS_CIGCTRL); 234 cfg = fimc_read(ctx, EXYNOS_CIGCTRL);
224 cfg &= ~(EXYNOS_CIGCTRL_TESTPATTERN_MASK | 235 cfg &= ~(EXYNOS_CIGCTRL_TESTPATTERN_MASK |
225 EXYNOS_CIGCTRL_SELCAM_ITU_MASK | 236 EXYNOS_CIGCTRL_SELCAM_ITU_MASK |
226 EXYNOS_CIGCTRL_SELCAM_MIPI_MASK | 237 EXYNOS_CIGCTRL_SELCAM_MIPI_MASK |
@@ -246,7 +257,7 @@ static void fimc_set_type_ctrl(struct fimc_context *ctx, enum fimc_wb wb)
246 break; 257 break;
247 } 258 }
248 259
249 fimc_write(cfg, EXYNOS_CIGCTRL); 260 fimc_write(ctx, cfg, EXYNOS_CIGCTRL);
250} 261}
251 262
252static void fimc_set_polarity(struct fimc_context *ctx, 263static void fimc_set_polarity(struct fimc_context *ctx,
@@ -259,7 +270,7 @@ static void fimc_set_polarity(struct fimc_context *ctx,
259 DRM_DEBUG_KMS("inv_href[%d]inv_hsync[%d]\n", 270 DRM_DEBUG_KMS("inv_href[%d]inv_hsync[%d]\n",
260 pol->inv_href, pol->inv_hsync); 271 pol->inv_href, pol->inv_hsync);
261 272
262 cfg = fimc_read(EXYNOS_CIGCTRL); 273 cfg = fimc_read(ctx, EXYNOS_CIGCTRL);
263 cfg &= ~(EXYNOS_CIGCTRL_INVPOLPCLK | EXYNOS_CIGCTRL_INVPOLVSYNC | 274 cfg &= ~(EXYNOS_CIGCTRL_INVPOLPCLK | EXYNOS_CIGCTRL_INVPOLVSYNC |
264 EXYNOS_CIGCTRL_INVPOLHREF | EXYNOS_CIGCTRL_INVPOLHSYNC); 275 EXYNOS_CIGCTRL_INVPOLHREF | EXYNOS_CIGCTRL_INVPOLHSYNC);
265 276
@@ -272,7 +283,7 @@ static void fimc_set_polarity(struct fimc_context *ctx,
272 if (pol->inv_hsync) 283 if (pol->inv_hsync)
273 cfg |= EXYNOS_CIGCTRL_INVPOLHSYNC; 284 cfg |= EXYNOS_CIGCTRL_INVPOLHSYNC;
274 285
275 fimc_write(cfg, EXYNOS_CIGCTRL); 286 fimc_write(ctx, cfg, EXYNOS_CIGCTRL);
276} 287}
277 288
278static void fimc_handle_jpeg(struct fimc_context *ctx, bool enable) 289static void fimc_handle_jpeg(struct fimc_context *ctx, bool enable)
@@ -281,13 +292,13 @@ static void fimc_handle_jpeg(struct fimc_context *ctx, bool enable)
281 292
282 DRM_DEBUG_KMS("enable[%d]\n", enable); 293 DRM_DEBUG_KMS("enable[%d]\n", enable);
283 294
284 cfg = fimc_read(EXYNOS_CIGCTRL); 295 cfg = fimc_read(ctx, EXYNOS_CIGCTRL);
285 if (enable) 296 if (enable)
286 cfg |= EXYNOS_CIGCTRL_CAM_JPEG; 297 cfg |= EXYNOS_CIGCTRL_CAM_JPEG;
287 else 298 else
288 cfg &= ~EXYNOS_CIGCTRL_CAM_JPEG; 299 cfg &= ~EXYNOS_CIGCTRL_CAM_JPEG;
289 300
290 fimc_write(cfg, EXYNOS_CIGCTRL); 301 fimc_write(ctx, cfg, EXYNOS_CIGCTRL);
291} 302}
292 303
293static void fimc_mask_irq(struct fimc_context *ctx, bool enable) 304static void fimc_mask_irq(struct fimc_context *ctx, bool enable)
@@ -296,48 +307,39 @@ static void fimc_mask_irq(struct fimc_context *ctx, bool enable)
296 307
297 DRM_DEBUG_KMS("enable[%d]\n", enable); 308 DRM_DEBUG_KMS("enable[%d]\n", enable);
298 309
299 cfg = fimc_read(EXYNOS_CIGCTRL); 310 cfg = fimc_read(ctx, EXYNOS_CIGCTRL);
300 if (enable) { 311 if (enable) {
301 cfg &= ~EXYNOS_CIGCTRL_IRQ_OVFEN; 312 cfg &= ~EXYNOS_CIGCTRL_IRQ_OVFEN;
302 cfg |= EXYNOS_CIGCTRL_IRQ_ENABLE | EXYNOS_CIGCTRL_IRQ_LEVEL; 313 cfg |= EXYNOS_CIGCTRL_IRQ_ENABLE | EXYNOS_CIGCTRL_IRQ_LEVEL;
303 } else 314 } else
304 cfg &= ~EXYNOS_CIGCTRL_IRQ_ENABLE; 315 cfg &= ~EXYNOS_CIGCTRL_IRQ_ENABLE;
305 fimc_write(cfg, EXYNOS_CIGCTRL); 316 fimc_write(ctx, cfg, EXYNOS_CIGCTRL);
306} 317}
307 318
308static void fimc_clear_irq(struct fimc_context *ctx) 319static void fimc_clear_irq(struct fimc_context *ctx)
309{ 320{
310 u32 cfg; 321 fimc_set_bits(ctx, EXYNOS_CIGCTRL, EXYNOS_CIGCTRL_IRQ_CLR);
311
312 cfg = fimc_read(EXYNOS_CIGCTRL);
313 cfg |= EXYNOS_CIGCTRL_IRQ_CLR;
314 fimc_write(cfg, EXYNOS_CIGCTRL);
315} 322}
316 323
317static bool fimc_check_ovf(struct fimc_context *ctx) 324static bool fimc_check_ovf(struct fimc_context *ctx)
318{ 325{
319 struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; 326 struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
320 u32 cfg, status, flag; 327 u32 status, flag;
321 328
322 status = fimc_read(EXYNOS_CISTATUS); 329 status = fimc_read(ctx, EXYNOS_CISTATUS);
323 flag = EXYNOS_CISTATUS_OVFIY | EXYNOS_CISTATUS_OVFICB | 330 flag = EXYNOS_CISTATUS_OVFIY | EXYNOS_CISTATUS_OVFICB |
324 EXYNOS_CISTATUS_OVFICR; 331 EXYNOS_CISTATUS_OVFICR;
325 332
326 DRM_DEBUG_KMS("flag[0x%x]\n", flag); 333 DRM_DEBUG_KMS("flag[0x%x]\n", flag);
327 334
328 if (status & flag) { 335 if (status & flag) {
329 cfg = fimc_read(EXYNOS_CIWDOFST); 336 fimc_set_bits(ctx, EXYNOS_CIWDOFST,
330 cfg |= (EXYNOS_CIWDOFST_CLROVFIY | EXYNOS_CIWDOFST_CLROVFICB | 337 EXYNOS_CIWDOFST_CLROVFIY | EXYNOS_CIWDOFST_CLROVFICB |
331 EXYNOS_CIWDOFST_CLROVFICR); 338 EXYNOS_CIWDOFST_CLROVFICR);
332 339 fimc_clear_bits(ctx, EXYNOS_CIWDOFST,
333 fimc_write(cfg, EXYNOS_CIWDOFST); 340 EXYNOS_CIWDOFST_CLROVFIY | EXYNOS_CIWDOFST_CLROVFICB |
334
335 cfg = fimc_read(EXYNOS_CIWDOFST);
336 cfg &= ~(EXYNOS_CIWDOFST_CLROVFIY | EXYNOS_CIWDOFST_CLROVFICB |
337 EXYNOS_CIWDOFST_CLROVFICR); 341 EXYNOS_CIWDOFST_CLROVFICR);
338 342
339 fimc_write(cfg, EXYNOS_CIWDOFST);
340
341 dev_err(ippdrv->dev, "occurred overflow at %d, status 0x%x.\n", 343 dev_err(ippdrv->dev, "occurred overflow at %d, status 0x%x.\n",
342 ctx->id, status); 344 ctx->id, status);
343 return true; 345 return true;
@@ -350,7 +352,7 @@ static bool fimc_check_frame_end(struct fimc_context *ctx)
350{ 352{
351 u32 cfg; 353 u32 cfg;
352 354
353 cfg = fimc_read(EXYNOS_CISTATUS); 355 cfg = fimc_read(ctx, EXYNOS_CISTATUS);
354 356
355 DRM_DEBUG_KMS("cfg[0x%x]\n", cfg); 357 DRM_DEBUG_KMS("cfg[0x%x]\n", cfg);
356 358
@@ -358,7 +360,7 @@ static bool fimc_check_frame_end(struct fimc_context *ctx)
358 return false; 360 return false;
359 361
360 cfg &= ~(EXYNOS_CISTATUS_FRAMEEND); 362 cfg &= ~(EXYNOS_CISTATUS_FRAMEEND);
361 fimc_write(cfg, EXYNOS_CISTATUS); 363 fimc_write(ctx, cfg, EXYNOS_CISTATUS);
362 364
363 return true; 365 return true;
364} 366}
@@ -368,7 +370,7 @@ static int fimc_get_buf_id(struct fimc_context *ctx)
368 u32 cfg; 370 u32 cfg;
369 int frame_cnt, buf_id; 371 int frame_cnt, buf_id;
370 372
371 cfg = fimc_read(EXYNOS_CISTATUS2); 373 cfg = fimc_read(ctx, EXYNOS_CISTATUS2);
372 frame_cnt = EXYNOS_CISTATUS2_GET_FRAMECOUNT_BEFORE(cfg); 374 frame_cnt = EXYNOS_CISTATUS2_GET_FRAMECOUNT_BEFORE(cfg);
373 375
374 if (frame_cnt == 0) 376 if (frame_cnt == 0)
@@ -395,13 +397,13 @@ static void fimc_handle_lastend(struct fimc_context *ctx, bool enable)
395 397
396 DRM_DEBUG_KMS("enable[%d]\n", enable); 398 DRM_DEBUG_KMS("enable[%d]\n", enable);
397 399
398 cfg = fimc_read(EXYNOS_CIOCTRL); 400 cfg = fimc_read(ctx, EXYNOS_CIOCTRL);
399 if (enable) 401 if (enable)
400 cfg |= EXYNOS_CIOCTRL_LASTENDEN; 402 cfg |= EXYNOS_CIOCTRL_LASTENDEN;
401 else 403 else
402 cfg &= ~EXYNOS_CIOCTRL_LASTENDEN; 404 cfg &= ~EXYNOS_CIOCTRL_LASTENDEN;
403 405
404 fimc_write(cfg, EXYNOS_CIOCTRL); 406 fimc_write(ctx, cfg, EXYNOS_CIOCTRL);
405} 407}
406 408
407 409
@@ -413,18 +415,18 @@ static int fimc_src_set_fmt_order(struct fimc_context *ctx, u32 fmt)
413 DRM_DEBUG_KMS("fmt[0x%x]\n", fmt); 415 DRM_DEBUG_KMS("fmt[0x%x]\n", fmt);
414 416
415 /* RGB */ 417 /* RGB */
416 cfg = fimc_read(EXYNOS_CISCCTRL); 418 cfg = fimc_read(ctx, EXYNOS_CISCCTRL);
417 cfg &= ~EXYNOS_CISCCTRL_INRGB_FMT_RGB_MASK; 419 cfg &= ~EXYNOS_CISCCTRL_INRGB_FMT_RGB_MASK;
418 420
419 switch (fmt) { 421 switch (fmt) {
420 case DRM_FORMAT_RGB565: 422 case DRM_FORMAT_RGB565:
421 cfg |= EXYNOS_CISCCTRL_INRGB_FMT_RGB565; 423 cfg |= EXYNOS_CISCCTRL_INRGB_FMT_RGB565;
422 fimc_write(cfg, EXYNOS_CISCCTRL); 424 fimc_write(ctx, cfg, EXYNOS_CISCCTRL);
423 return 0; 425 return 0;
424 case DRM_FORMAT_RGB888: 426 case DRM_FORMAT_RGB888:
425 case DRM_FORMAT_XRGB8888: 427 case DRM_FORMAT_XRGB8888:
426 cfg |= EXYNOS_CISCCTRL_INRGB_FMT_RGB888; 428 cfg |= EXYNOS_CISCCTRL_INRGB_FMT_RGB888;
427 fimc_write(cfg, EXYNOS_CISCCTRL); 429 fimc_write(ctx, cfg, EXYNOS_CISCCTRL);
428 return 0; 430 return 0;
429 default: 431 default:
430 /* bypass */ 432 /* bypass */
@@ -432,7 +434,7 @@ static int fimc_src_set_fmt_order(struct fimc_context *ctx, u32 fmt)
432 } 434 }
433 435
434 /* YUV */ 436 /* YUV */
435 cfg = fimc_read(EXYNOS_MSCTRL); 437 cfg = fimc_read(ctx, EXYNOS_MSCTRL);
436 cfg &= ~(EXYNOS_MSCTRL_ORDER2P_SHIFT_MASK | 438 cfg &= ~(EXYNOS_MSCTRL_ORDER2P_SHIFT_MASK |
437 EXYNOS_MSCTRL_C_INT_IN_2PLANE | 439 EXYNOS_MSCTRL_C_INT_IN_2PLANE |
438 EXYNOS_MSCTRL_ORDER422_YCBYCR); 440 EXYNOS_MSCTRL_ORDER422_YCBYCR);
@@ -472,7 +474,7 @@ static int fimc_src_set_fmt_order(struct fimc_context *ctx, u32 fmt)
472 return -EINVAL; 474 return -EINVAL;
473 } 475 }
474 476
475 fimc_write(cfg, EXYNOS_MSCTRL); 477 fimc_write(ctx, cfg, EXYNOS_MSCTRL);
476 478
477 return 0; 479 return 0;
478} 480}
@@ -485,7 +487,7 @@ static int fimc_src_set_fmt(struct device *dev, u32 fmt)
485 487
486 DRM_DEBUG_KMS("fmt[0x%x]\n", fmt); 488 DRM_DEBUG_KMS("fmt[0x%x]\n", fmt);
487 489
488 cfg = fimc_read(EXYNOS_MSCTRL); 490 cfg = fimc_read(ctx, EXYNOS_MSCTRL);
489 cfg &= ~EXYNOS_MSCTRL_INFORMAT_RGB; 491 cfg &= ~EXYNOS_MSCTRL_INFORMAT_RGB;
490 492
491 switch (fmt) { 493 switch (fmt) {
@@ -520,9 +522,9 @@ static int fimc_src_set_fmt(struct device *dev, u32 fmt)
520 return -EINVAL; 522 return -EINVAL;
521 } 523 }
522 524
523 fimc_write(cfg, EXYNOS_MSCTRL); 525 fimc_write(ctx, cfg, EXYNOS_MSCTRL);
524 526
525 cfg = fimc_read(EXYNOS_CIDMAPARAM); 527 cfg = fimc_read(ctx, EXYNOS_CIDMAPARAM);
526 cfg &= ~EXYNOS_CIDMAPARAM_R_MODE_MASK; 528 cfg &= ~EXYNOS_CIDMAPARAM_R_MODE_MASK;
527 529
528 if (fmt == DRM_FORMAT_NV12MT) 530 if (fmt == DRM_FORMAT_NV12MT)
@@ -530,7 +532,7 @@ static int fimc_src_set_fmt(struct device *dev, u32 fmt)
530 else 532 else
531 cfg |= EXYNOS_CIDMAPARAM_R_MODE_LINEAR; 533 cfg |= EXYNOS_CIDMAPARAM_R_MODE_LINEAR;
532 534
533 fimc_write(cfg, EXYNOS_CIDMAPARAM); 535 fimc_write(ctx, cfg, EXYNOS_CIDMAPARAM);
534 536
535 return fimc_src_set_fmt_order(ctx, fmt); 537 return fimc_src_set_fmt_order(ctx, fmt);
536} 538}
@@ -545,11 +547,11 @@ static int fimc_src_set_transf(struct device *dev,
545 547
546 DRM_DEBUG_KMS("degree[%d]flip[0x%x]\n", degree, flip); 548 DRM_DEBUG_KMS("degree[%d]flip[0x%x]\n", degree, flip);
547 549
548 cfg1 = fimc_read(EXYNOS_MSCTRL); 550 cfg1 = fimc_read(ctx, EXYNOS_MSCTRL);
549 cfg1 &= ~(EXYNOS_MSCTRL_FLIP_X_MIRROR | 551 cfg1 &= ~(EXYNOS_MSCTRL_FLIP_X_MIRROR |
550 EXYNOS_MSCTRL_FLIP_Y_MIRROR); 552 EXYNOS_MSCTRL_FLIP_Y_MIRROR);
551 553
552 cfg2 = fimc_read(EXYNOS_CITRGFMT); 554 cfg2 = fimc_read(ctx, EXYNOS_CITRGFMT);
553 cfg2 &= ~EXYNOS_CITRGFMT_INROT90_CLOCKWISE; 555 cfg2 &= ~EXYNOS_CITRGFMT_INROT90_CLOCKWISE;
554 556
555 switch (degree) { 557 switch (degree) {
@@ -588,8 +590,8 @@ static int fimc_src_set_transf(struct device *dev,
588 return -EINVAL; 590 return -EINVAL;
589 } 591 }
590 592
591 fimc_write(cfg1, EXYNOS_MSCTRL); 593 fimc_write(ctx, cfg1, EXYNOS_MSCTRL);
592 fimc_write(cfg2, EXYNOS_CITRGFMT); 594 fimc_write(ctx, cfg2, EXYNOS_CITRGFMT);
593 *swap = (cfg2 & EXYNOS_CITRGFMT_INROT90_CLOCKWISE) ? 1 : 0; 595 *swap = (cfg2 & EXYNOS_CITRGFMT_INROT90_CLOCKWISE) ? 1 : 0;
594 596
595 return 0; 597 return 0;
@@ -614,17 +616,17 @@ static int fimc_set_window(struct fimc_context *ctx,
614 * set window offset 1, 2 size 616 * set window offset 1, 2 size
615 * check figure 43-21 in user manual 617 * check figure 43-21 in user manual
616 */ 618 */
617 cfg = fimc_read(EXYNOS_CIWDOFST); 619 cfg = fimc_read(ctx, EXYNOS_CIWDOFST);
618 cfg &= ~(EXYNOS_CIWDOFST_WINHOROFST_MASK | 620 cfg &= ~(EXYNOS_CIWDOFST_WINHOROFST_MASK |
619 EXYNOS_CIWDOFST_WINVEROFST_MASK); 621 EXYNOS_CIWDOFST_WINVEROFST_MASK);
620 cfg |= (EXYNOS_CIWDOFST_WINHOROFST(h1) | 622 cfg |= (EXYNOS_CIWDOFST_WINHOROFST(h1) |
621 EXYNOS_CIWDOFST_WINVEROFST(v1)); 623 EXYNOS_CIWDOFST_WINVEROFST(v1));
622 cfg |= EXYNOS_CIWDOFST_WINOFSEN; 624 cfg |= EXYNOS_CIWDOFST_WINOFSEN;
623 fimc_write(cfg, EXYNOS_CIWDOFST); 625 fimc_write(ctx, cfg, EXYNOS_CIWDOFST);
624 626
625 cfg = (EXYNOS_CIWDOFST2_WINHOROFST2(h2) | 627 cfg = (EXYNOS_CIWDOFST2_WINHOROFST2(h2) |
626 EXYNOS_CIWDOFST2_WINVEROFST2(v2)); 628 EXYNOS_CIWDOFST2_WINVEROFST2(v2));
627 fimc_write(cfg, EXYNOS_CIWDOFST2); 629 fimc_write(ctx, cfg, EXYNOS_CIWDOFST2);
628 630
629 return 0; 631 return 0;
630} 632}
@@ -644,7 +646,7 @@ static int fimc_src_set_size(struct device *dev, int swap,
644 cfg = (EXYNOS_ORGISIZE_HORIZONTAL(img_sz.hsize) | 646 cfg = (EXYNOS_ORGISIZE_HORIZONTAL(img_sz.hsize) |
645 EXYNOS_ORGISIZE_VERTICAL(img_sz.vsize)); 647 EXYNOS_ORGISIZE_VERTICAL(img_sz.vsize));
646 648
647 fimc_write(cfg, EXYNOS_ORGISIZE); 649 fimc_write(ctx, cfg, EXYNOS_ORGISIZE);
648 650
649 DRM_DEBUG_KMS("x[%d]y[%d]w[%d]h[%d]\n", pos->x, pos->y, pos->w, pos->h); 651 DRM_DEBUG_KMS("x[%d]y[%d]w[%d]h[%d]\n", pos->x, pos->y, pos->w, pos->h);
650 652
@@ -656,12 +658,12 @@ static int fimc_src_set_size(struct device *dev, int swap,
656 } 658 }
657 659
658 /* set input DMA image size */ 660 /* set input DMA image size */
659 cfg = fimc_read(EXYNOS_CIREAL_ISIZE); 661 cfg = fimc_read(ctx, EXYNOS_CIREAL_ISIZE);
660 cfg &= ~(EXYNOS_CIREAL_ISIZE_HEIGHT_MASK | 662 cfg &= ~(EXYNOS_CIREAL_ISIZE_HEIGHT_MASK |
661 EXYNOS_CIREAL_ISIZE_WIDTH_MASK); 663 EXYNOS_CIREAL_ISIZE_WIDTH_MASK);
662 cfg |= (EXYNOS_CIREAL_ISIZE_WIDTH(img_pos.w) | 664 cfg |= (EXYNOS_CIREAL_ISIZE_WIDTH(img_pos.w) |
663 EXYNOS_CIREAL_ISIZE_HEIGHT(img_pos.h)); 665 EXYNOS_CIREAL_ISIZE_HEIGHT(img_pos.h));
664 fimc_write(cfg, EXYNOS_CIREAL_ISIZE); 666 fimc_write(ctx, cfg, EXYNOS_CIREAL_ISIZE);
665 667
666 /* 668 /*
667 * set input FIFO image size 669 * set input FIFO image size
@@ -670,18 +672,18 @@ static int fimc_src_set_size(struct device *dev, int swap,
670 cfg = (EXYNOS_CISRCFMT_ITU601_8BIT | 672 cfg = (EXYNOS_CISRCFMT_ITU601_8BIT |
671 EXYNOS_CISRCFMT_SOURCEHSIZE(img_sz.hsize) | 673 EXYNOS_CISRCFMT_SOURCEHSIZE(img_sz.hsize) |
672 EXYNOS_CISRCFMT_SOURCEVSIZE(img_sz.vsize)); 674 EXYNOS_CISRCFMT_SOURCEVSIZE(img_sz.vsize));
673 fimc_write(cfg, EXYNOS_CISRCFMT); 675 fimc_write(ctx, cfg, EXYNOS_CISRCFMT);
674 676
675 /* offset Y(RGB), Cb, Cr */ 677 /* offset Y(RGB), Cb, Cr */
676 cfg = (EXYNOS_CIIYOFF_HORIZONTAL(img_pos.x) | 678 cfg = (EXYNOS_CIIYOFF_HORIZONTAL(img_pos.x) |
677 EXYNOS_CIIYOFF_VERTICAL(img_pos.y)); 679 EXYNOS_CIIYOFF_VERTICAL(img_pos.y));
678 fimc_write(cfg, EXYNOS_CIIYOFF); 680 fimc_write(ctx, cfg, EXYNOS_CIIYOFF);
679 cfg = (EXYNOS_CIICBOFF_HORIZONTAL(img_pos.x) | 681 cfg = (EXYNOS_CIICBOFF_HORIZONTAL(img_pos.x) |
680 EXYNOS_CIICBOFF_VERTICAL(img_pos.y)); 682 EXYNOS_CIICBOFF_VERTICAL(img_pos.y));
681 fimc_write(cfg, EXYNOS_CIICBOFF); 683 fimc_write(ctx, cfg, EXYNOS_CIICBOFF);
682 cfg = (EXYNOS_CIICROFF_HORIZONTAL(img_pos.x) | 684 cfg = (EXYNOS_CIICROFF_HORIZONTAL(img_pos.x) |
683 EXYNOS_CIICROFF_VERTICAL(img_pos.y)); 685 EXYNOS_CIICROFF_VERTICAL(img_pos.y));
684 fimc_write(cfg, EXYNOS_CIICROFF); 686 fimc_write(ctx, cfg, EXYNOS_CIICROFF);
685 687
686 return fimc_set_window(ctx, &img_pos, &img_sz); 688 return fimc_set_window(ctx, &img_pos, &img_sz);
687} 689}
@@ -715,25 +717,25 @@ static int fimc_src_set_addr(struct device *dev,
715 switch (buf_type) { 717 switch (buf_type) {
716 case IPP_BUF_ENQUEUE: 718 case IPP_BUF_ENQUEUE:
717 config = &property->config[EXYNOS_DRM_OPS_SRC]; 719 config = &property->config[EXYNOS_DRM_OPS_SRC];
718 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y], 720 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_Y],
719 EXYNOS_CIIYSA(buf_id)); 721 EXYNOS_CIIYSA(buf_id));
720 722
721 if (config->fmt == DRM_FORMAT_YVU420) { 723 if (config->fmt == DRM_FORMAT_YVU420) {
722 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR], 724 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_CR],
723 EXYNOS_CIICBSA(buf_id)); 725 EXYNOS_CIICBSA(buf_id));
724 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB], 726 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_CB],
725 EXYNOS_CIICRSA(buf_id)); 727 EXYNOS_CIICRSA(buf_id));
726 } else { 728 } else {
727 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB], 729 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_CB],
728 EXYNOS_CIICBSA(buf_id)); 730 EXYNOS_CIICBSA(buf_id));
729 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR], 731 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_CR],
730 EXYNOS_CIICRSA(buf_id)); 732 EXYNOS_CIICRSA(buf_id));
731 } 733 }
732 break; 734 break;
733 case IPP_BUF_DEQUEUE: 735 case IPP_BUF_DEQUEUE:
734 fimc_write(0x0, EXYNOS_CIIYSA(buf_id)); 736 fimc_write(ctx, 0x0, EXYNOS_CIIYSA(buf_id));
735 fimc_write(0x0, EXYNOS_CIICBSA(buf_id)); 737 fimc_write(ctx, 0x0, EXYNOS_CIICBSA(buf_id));
736 fimc_write(0x0, EXYNOS_CIICRSA(buf_id)); 738 fimc_write(ctx, 0x0, EXYNOS_CIICRSA(buf_id));
737 break; 739 break;
738 default: 740 default:
739 /* bypass */ 741 /* bypass */
@@ -758,22 +760,22 @@ static int fimc_dst_set_fmt_order(struct fimc_context *ctx, u32 fmt)
758 DRM_DEBUG_KMS("fmt[0x%x]\n", fmt); 760 DRM_DEBUG_KMS("fmt[0x%x]\n", fmt);
759 761
760 /* RGB */ 762 /* RGB */
761 cfg = fimc_read(EXYNOS_CISCCTRL); 763 cfg = fimc_read(ctx, EXYNOS_CISCCTRL);
762 cfg &= ~EXYNOS_CISCCTRL_OUTRGB_FMT_RGB_MASK; 764 cfg &= ~EXYNOS_CISCCTRL_OUTRGB_FMT_RGB_MASK;
763 765
764 switch (fmt) { 766 switch (fmt) {
765 case DRM_FORMAT_RGB565: 767 case DRM_FORMAT_RGB565:
766 cfg |= EXYNOS_CISCCTRL_OUTRGB_FMT_RGB565; 768 cfg |= EXYNOS_CISCCTRL_OUTRGB_FMT_RGB565;
767 fimc_write(cfg, EXYNOS_CISCCTRL); 769 fimc_write(ctx, cfg, EXYNOS_CISCCTRL);
768 return 0; 770 return 0;
769 case DRM_FORMAT_RGB888: 771 case DRM_FORMAT_RGB888:
770 cfg |= EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888; 772 cfg |= EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888;
771 fimc_write(cfg, EXYNOS_CISCCTRL); 773 fimc_write(ctx, cfg, EXYNOS_CISCCTRL);
772 return 0; 774 return 0;
773 case DRM_FORMAT_XRGB8888: 775 case DRM_FORMAT_XRGB8888:
774 cfg |= (EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888 | 776 cfg |= (EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888 |
775 EXYNOS_CISCCTRL_EXTRGB_EXTENSION); 777 EXYNOS_CISCCTRL_EXTRGB_EXTENSION);
776 fimc_write(cfg, EXYNOS_CISCCTRL); 778 fimc_write(ctx, cfg, EXYNOS_CISCCTRL);
777 break; 779 break;
778 default: 780 default:
779 /* bypass */ 781 /* bypass */
@@ -781,7 +783,7 @@ static int fimc_dst_set_fmt_order(struct fimc_context *ctx, u32 fmt)
781 } 783 }
782 784
783 /* YUV */ 785 /* YUV */
784 cfg = fimc_read(EXYNOS_CIOCTRL); 786 cfg = fimc_read(ctx, EXYNOS_CIOCTRL);
785 cfg &= ~(EXYNOS_CIOCTRL_ORDER2P_MASK | 787 cfg &= ~(EXYNOS_CIOCTRL_ORDER2P_MASK |
786 EXYNOS_CIOCTRL_ORDER422_MASK | 788 EXYNOS_CIOCTRL_ORDER422_MASK |
787 EXYNOS_CIOCTRL_YCBCR_PLANE_MASK); 789 EXYNOS_CIOCTRL_YCBCR_PLANE_MASK);
@@ -823,7 +825,7 @@ static int fimc_dst_set_fmt_order(struct fimc_context *ctx, u32 fmt)
823 return -EINVAL; 825 return -EINVAL;
824 } 826 }
825 827
826 fimc_write(cfg, EXYNOS_CIOCTRL); 828 fimc_write(ctx, cfg, EXYNOS_CIOCTRL);
827 829
828 return 0; 830 return 0;
829} 831}
@@ -836,16 +838,16 @@ static int fimc_dst_set_fmt(struct device *dev, u32 fmt)
836 838
837 DRM_DEBUG_KMS("fmt[0x%x]\n", fmt); 839 DRM_DEBUG_KMS("fmt[0x%x]\n", fmt);
838 840
839 cfg = fimc_read(EXYNOS_CIEXTEN); 841 cfg = fimc_read(ctx, EXYNOS_CIEXTEN);
840 842
841 if (fmt == DRM_FORMAT_AYUV) { 843 if (fmt == DRM_FORMAT_AYUV) {
842 cfg |= EXYNOS_CIEXTEN_YUV444_OUT; 844 cfg |= EXYNOS_CIEXTEN_YUV444_OUT;
843 fimc_write(cfg, EXYNOS_CIEXTEN); 845 fimc_write(ctx, cfg, EXYNOS_CIEXTEN);
844 } else { 846 } else {
845 cfg &= ~EXYNOS_CIEXTEN_YUV444_OUT; 847 cfg &= ~EXYNOS_CIEXTEN_YUV444_OUT;
846 fimc_write(cfg, EXYNOS_CIEXTEN); 848 fimc_write(ctx, cfg, EXYNOS_CIEXTEN);
847 849
848 cfg = fimc_read(EXYNOS_CITRGFMT); 850 cfg = fimc_read(ctx, EXYNOS_CITRGFMT);
849 cfg &= ~EXYNOS_CITRGFMT_OUTFORMAT_MASK; 851 cfg &= ~EXYNOS_CITRGFMT_OUTFORMAT_MASK;
850 852
851 switch (fmt) { 853 switch (fmt) {
@@ -878,10 +880,10 @@ static int fimc_dst_set_fmt(struct device *dev, u32 fmt)
878 return -EINVAL; 880 return -EINVAL;
879 } 881 }
880 882
881 fimc_write(cfg, EXYNOS_CITRGFMT); 883 fimc_write(ctx, cfg, EXYNOS_CITRGFMT);
882 } 884 }
883 885
884 cfg = fimc_read(EXYNOS_CIDMAPARAM); 886 cfg = fimc_read(ctx, EXYNOS_CIDMAPARAM);
885 cfg &= ~EXYNOS_CIDMAPARAM_W_MODE_MASK; 887 cfg &= ~EXYNOS_CIDMAPARAM_W_MODE_MASK;
886 888
887 if (fmt == DRM_FORMAT_NV12MT) 889 if (fmt == DRM_FORMAT_NV12MT)
@@ -889,7 +891,7 @@ static int fimc_dst_set_fmt(struct device *dev, u32 fmt)
889 else 891 else
890 cfg |= EXYNOS_CIDMAPARAM_W_MODE_LINEAR; 892 cfg |= EXYNOS_CIDMAPARAM_W_MODE_LINEAR;
891 893
892 fimc_write(cfg, EXYNOS_CIDMAPARAM); 894 fimc_write(ctx, cfg, EXYNOS_CIDMAPARAM);
893 895
894 return fimc_dst_set_fmt_order(ctx, fmt); 896 return fimc_dst_set_fmt_order(ctx, fmt);
895} 897}
@@ -904,7 +906,7 @@ static int fimc_dst_set_transf(struct device *dev,
904 906
905 DRM_DEBUG_KMS("degree[%d]flip[0x%x]\n", degree, flip); 907 DRM_DEBUG_KMS("degree[%d]flip[0x%x]\n", degree, flip);
906 908
907 cfg = fimc_read(EXYNOS_CITRGFMT); 909 cfg = fimc_read(ctx, EXYNOS_CITRGFMT);
908 cfg &= ~EXYNOS_CITRGFMT_FLIP_MASK; 910 cfg &= ~EXYNOS_CITRGFMT_FLIP_MASK;
909 cfg &= ~EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE; 911 cfg &= ~EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE;
910 912
@@ -944,7 +946,7 @@ static int fimc_dst_set_transf(struct device *dev,
944 return -EINVAL; 946 return -EINVAL;
945 } 947 }
946 948
947 fimc_write(cfg, EXYNOS_CITRGFMT); 949 fimc_write(ctx, cfg, EXYNOS_CITRGFMT);
948 *swap = (cfg & EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE) ? 1 : 0; 950 *swap = (cfg & EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE) ? 1 : 0;
949 951
950 return 0; 952 return 0;
@@ -960,7 +962,7 @@ static int fimc_set_prescaler(struct fimc_context *ctx, struct fimc_scaler *sc,
960 int ret = 0; 962 int ret = 0;
961 u32 src_w, src_h, dst_w, dst_h; 963 u32 src_w, src_h, dst_w, dst_h;
962 964
963 cfg_ext = fimc_read(EXYNOS_CITRGFMT); 965 cfg_ext = fimc_read(ctx, EXYNOS_CITRGFMT);
964 if (cfg_ext & EXYNOS_CITRGFMT_INROT90_CLOCKWISE) { 966 if (cfg_ext & EXYNOS_CITRGFMT_INROT90_CLOCKWISE) {
965 src_w = src->h; 967 src_w = src->h;
966 src_h = src->w; 968 src_h = src->w;
@@ -1009,11 +1011,11 @@ static int fimc_set_prescaler(struct fimc_context *ctx, struct fimc_scaler *sc,
1009 cfg = (EXYNOS_CISCPRERATIO_SHFACTOR(shfactor) | 1011 cfg = (EXYNOS_CISCPRERATIO_SHFACTOR(shfactor) |
1010 EXYNOS_CISCPRERATIO_PREHORRATIO(1 << hfactor) | 1012 EXYNOS_CISCPRERATIO_PREHORRATIO(1 << hfactor) |
1011 EXYNOS_CISCPRERATIO_PREVERRATIO(1 << vfactor)); 1013 EXYNOS_CISCPRERATIO_PREVERRATIO(1 << vfactor));
1012 fimc_write(cfg, EXYNOS_CISCPRERATIO); 1014 fimc_write(ctx, cfg, EXYNOS_CISCPRERATIO);
1013 1015
1014 cfg = (EXYNOS_CISCPREDST_PREDSTWIDTH(pre_dst_width) | 1016 cfg = (EXYNOS_CISCPREDST_PREDSTWIDTH(pre_dst_width) |
1015 EXYNOS_CISCPREDST_PREDSTHEIGHT(pre_dst_height)); 1017 EXYNOS_CISCPREDST_PREDSTHEIGHT(pre_dst_height));
1016 fimc_write(cfg, EXYNOS_CISCPREDST); 1018 fimc_write(ctx, cfg, EXYNOS_CISCPREDST);
1017 1019
1018 return ret; 1020 return ret;
1019} 1021}
@@ -1027,7 +1029,7 @@ static void fimc_set_scaler(struct fimc_context *ctx, struct fimc_scaler *sc)
1027 DRM_DEBUG_KMS("hratio[%d]vratio[%d]\n", 1029 DRM_DEBUG_KMS("hratio[%d]vratio[%d]\n",
1028 sc->hratio, sc->vratio); 1030 sc->hratio, sc->vratio);
1029 1031
1030 cfg = fimc_read(EXYNOS_CISCCTRL); 1032 cfg = fimc_read(ctx, EXYNOS_CISCCTRL);
1031 cfg &= ~(EXYNOS_CISCCTRL_SCALERBYPASS | 1033 cfg &= ~(EXYNOS_CISCCTRL_SCALERBYPASS |
1032 EXYNOS_CISCCTRL_SCALEUP_H | EXYNOS_CISCCTRL_SCALEUP_V | 1034 EXYNOS_CISCCTRL_SCALEUP_H | EXYNOS_CISCCTRL_SCALEUP_V |
1033 EXYNOS_CISCCTRL_MAIN_V_RATIO_MASK | 1035 EXYNOS_CISCCTRL_MAIN_V_RATIO_MASK |
@@ -1047,14 +1049,14 @@ static void fimc_set_scaler(struct fimc_context *ctx, struct fimc_scaler *sc)
1047 1049
1048 cfg |= (EXYNOS_CISCCTRL_MAINHORRATIO((sc->hratio >> 6)) | 1050 cfg |= (EXYNOS_CISCCTRL_MAINHORRATIO((sc->hratio >> 6)) |
1049 EXYNOS_CISCCTRL_MAINVERRATIO((sc->vratio >> 6))); 1051 EXYNOS_CISCCTRL_MAINVERRATIO((sc->vratio >> 6)));
1050 fimc_write(cfg, EXYNOS_CISCCTRL); 1052 fimc_write(ctx, cfg, EXYNOS_CISCCTRL);
1051 1053
1052 cfg_ext = fimc_read(EXYNOS_CIEXTEN); 1054 cfg_ext = fimc_read(ctx, EXYNOS_CIEXTEN);
1053 cfg_ext &= ~EXYNOS_CIEXTEN_MAINHORRATIO_EXT_MASK; 1055 cfg_ext &= ~EXYNOS_CIEXTEN_MAINHORRATIO_EXT_MASK;
1054 cfg_ext &= ~EXYNOS_CIEXTEN_MAINVERRATIO_EXT_MASK; 1056 cfg_ext &= ~EXYNOS_CIEXTEN_MAINVERRATIO_EXT_MASK;
1055 cfg_ext |= (EXYNOS_CIEXTEN_MAINHORRATIO_EXT(sc->hratio) | 1057 cfg_ext |= (EXYNOS_CIEXTEN_MAINHORRATIO_EXT(sc->hratio) |
1056 EXYNOS_CIEXTEN_MAINVERRATIO_EXT(sc->vratio)); 1058 EXYNOS_CIEXTEN_MAINVERRATIO_EXT(sc->vratio));
1057 fimc_write(cfg_ext, EXYNOS_CIEXTEN); 1059 fimc_write(ctx, cfg_ext, EXYNOS_CIEXTEN);
1058} 1060}
1059 1061
1060static int fimc_dst_set_size(struct device *dev, int swap, 1062static int fimc_dst_set_size(struct device *dev, int swap,
@@ -1072,12 +1074,12 @@ static int fimc_dst_set_size(struct device *dev, int swap,
1072 cfg = (EXYNOS_ORGOSIZE_HORIZONTAL(img_sz.hsize) | 1074 cfg = (EXYNOS_ORGOSIZE_HORIZONTAL(img_sz.hsize) |
1073 EXYNOS_ORGOSIZE_VERTICAL(img_sz.vsize)); 1075 EXYNOS_ORGOSIZE_VERTICAL(img_sz.vsize));
1074 1076
1075 fimc_write(cfg, EXYNOS_ORGOSIZE); 1077 fimc_write(ctx, cfg, EXYNOS_ORGOSIZE);
1076 1078
1077 DRM_DEBUG_KMS("x[%d]y[%d]w[%d]h[%d]\n", pos->x, pos->y, pos->w, pos->h); 1079 DRM_DEBUG_KMS("x[%d]y[%d]w[%d]h[%d]\n", pos->x, pos->y, pos->w, pos->h);
1078 1080
1079 /* CSC ITU */ 1081 /* CSC ITU */
1080 cfg = fimc_read(EXYNOS_CIGCTRL); 1082 cfg = fimc_read(ctx, EXYNOS_CIGCTRL);
1081 cfg &= ~EXYNOS_CIGCTRL_CSC_MASK; 1083 cfg &= ~EXYNOS_CIGCTRL_CSC_MASK;
1082 1084
1083 if (sz->hsize >= FIMC_WIDTH_ITU_709) 1085 if (sz->hsize >= FIMC_WIDTH_ITU_709)
@@ -1085,7 +1087,7 @@ static int fimc_dst_set_size(struct device *dev, int swap,
1085 else 1087 else
1086 cfg |= EXYNOS_CIGCTRL_CSC_ITU601; 1088 cfg |= EXYNOS_CIGCTRL_CSC_ITU601;
1087 1089
1088 fimc_write(cfg, EXYNOS_CIGCTRL); 1090 fimc_write(ctx, cfg, EXYNOS_CIGCTRL);
1089 1091
1090 if (swap) { 1092 if (swap) {
1091 img_pos.w = pos->h; 1093 img_pos.w = pos->h;
@@ -1095,27 +1097,27 @@ static int fimc_dst_set_size(struct device *dev, int swap,
1095 } 1097 }
1096 1098
1097 /* target image size */ 1099 /* target image size */
1098 cfg = fimc_read(EXYNOS_CITRGFMT); 1100 cfg = fimc_read(ctx, EXYNOS_CITRGFMT);
1099 cfg &= ~(EXYNOS_CITRGFMT_TARGETH_MASK | 1101 cfg &= ~(EXYNOS_CITRGFMT_TARGETH_MASK |
1100 EXYNOS_CITRGFMT_TARGETV_MASK); 1102 EXYNOS_CITRGFMT_TARGETV_MASK);
1101 cfg |= (EXYNOS_CITRGFMT_TARGETHSIZE(img_pos.w) | 1103 cfg |= (EXYNOS_CITRGFMT_TARGETHSIZE(img_pos.w) |
1102 EXYNOS_CITRGFMT_TARGETVSIZE(img_pos.h)); 1104 EXYNOS_CITRGFMT_TARGETVSIZE(img_pos.h));
1103 fimc_write(cfg, EXYNOS_CITRGFMT); 1105 fimc_write(ctx, cfg, EXYNOS_CITRGFMT);
1104 1106
1105 /* target area */ 1107 /* target area */
1106 cfg = EXYNOS_CITAREA_TARGET_AREA(img_pos.w * img_pos.h); 1108 cfg = EXYNOS_CITAREA_TARGET_AREA(img_pos.w * img_pos.h);
1107 fimc_write(cfg, EXYNOS_CITAREA); 1109 fimc_write(ctx, cfg, EXYNOS_CITAREA);
1108 1110
1109 /* offset Y(RGB), Cb, Cr */ 1111 /* offset Y(RGB), Cb, Cr */
1110 cfg = (EXYNOS_CIOYOFF_HORIZONTAL(img_pos.x) | 1112 cfg = (EXYNOS_CIOYOFF_HORIZONTAL(img_pos.x) |
1111 EXYNOS_CIOYOFF_VERTICAL(img_pos.y)); 1113 EXYNOS_CIOYOFF_VERTICAL(img_pos.y));
1112 fimc_write(cfg, EXYNOS_CIOYOFF); 1114 fimc_write(ctx, cfg, EXYNOS_CIOYOFF);
1113 cfg = (EXYNOS_CIOCBOFF_HORIZONTAL(img_pos.x) | 1115 cfg = (EXYNOS_CIOCBOFF_HORIZONTAL(img_pos.x) |
1114 EXYNOS_CIOCBOFF_VERTICAL(img_pos.y)); 1116 EXYNOS_CIOCBOFF_VERTICAL(img_pos.y));
1115 fimc_write(cfg, EXYNOS_CIOCBOFF); 1117 fimc_write(ctx, cfg, EXYNOS_CIOCBOFF);
1116 cfg = (EXYNOS_CIOCROFF_HORIZONTAL(img_pos.x) | 1118 cfg = (EXYNOS_CIOCROFF_HORIZONTAL(img_pos.x) |
1117 EXYNOS_CIOCROFF_VERTICAL(img_pos.y)); 1119 EXYNOS_CIOCROFF_VERTICAL(img_pos.y));
1118 fimc_write(cfg, EXYNOS_CIOCROFF); 1120 fimc_write(ctx, cfg, EXYNOS_CIOCROFF);
1119 1121
1120 return 0; 1122 return 0;
1121} 1123}
@@ -1125,7 +1127,7 @@ static int fimc_dst_get_buf_seq(struct fimc_context *ctx)
1125 u32 cfg, i, buf_num = 0; 1127 u32 cfg, i, buf_num = 0;
1126 u32 mask = 0x00000001; 1128 u32 mask = 0x00000001;
1127 1129
1128 cfg = fimc_read(EXYNOS_CIFCNTSEQ); 1130 cfg = fimc_read(ctx, EXYNOS_CIFCNTSEQ);
1129 1131
1130 for (i = 0; i < FIMC_REG_SZ; i++) 1132 for (i = 0; i < FIMC_REG_SZ; i++)
1131 if (cfg & (mask << i)) 1133 if (cfg & (mask << i))
@@ -1150,7 +1152,7 @@ static int fimc_dst_set_buf_seq(struct fimc_context *ctx, u32 buf_id,
1150 mutex_lock(&ctx->lock); 1152 mutex_lock(&ctx->lock);
1151 1153
1152 /* mask register set */ 1154 /* mask register set */
1153 cfg = fimc_read(EXYNOS_CIFCNTSEQ); 1155 cfg = fimc_read(ctx, EXYNOS_CIFCNTSEQ);
1154 1156
1155 switch (buf_type) { 1157 switch (buf_type) {
1156 case IPP_BUF_ENQUEUE: 1158 case IPP_BUF_ENQUEUE:
@@ -1168,7 +1170,7 @@ static int fimc_dst_set_buf_seq(struct fimc_context *ctx, u32 buf_id,
1168 /* sequence id */ 1170 /* sequence id */
1169 cfg &= ~mask; 1171 cfg &= ~mask;
1170 cfg |= (enable << buf_id); 1172 cfg |= (enable << buf_id);
1171 fimc_write(cfg, EXYNOS_CIFCNTSEQ); 1173 fimc_write(ctx, cfg, EXYNOS_CIFCNTSEQ);
1172 1174
1173 /* interrupt enable */ 1175 /* interrupt enable */
1174 if (buf_type == IPP_BUF_ENQUEUE && 1176 if (buf_type == IPP_BUF_ENQUEUE &&
@@ -1215,25 +1217,25 @@ static int fimc_dst_set_addr(struct device *dev,
1215 case IPP_BUF_ENQUEUE: 1217 case IPP_BUF_ENQUEUE:
1216 config = &property->config[EXYNOS_DRM_OPS_DST]; 1218 config = &property->config[EXYNOS_DRM_OPS_DST];
1217 1219
1218 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y], 1220 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_Y],
1219 EXYNOS_CIOYSA(buf_id)); 1221 EXYNOS_CIOYSA(buf_id));
1220 1222
1221 if (config->fmt == DRM_FORMAT_YVU420) { 1223 if (config->fmt == DRM_FORMAT_YVU420) {
1222 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR], 1224 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_CR],
1223 EXYNOS_CIOCBSA(buf_id)); 1225 EXYNOS_CIOCBSA(buf_id));
1224 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB], 1226 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_CB],
1225 EXYNOS_CIOCRSA(buf_id)); 1227 EXYNOS_CIOCRSA(buf_id));
1226 } else { 1228 } else {
1227 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB], 1229 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_CB],
1228 EXYNOS_CIOCBSA(buf_id)); 1230 EXYNOS_CIOCBSA(buf_id));
1229 fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR], 1231 fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_CR],
1230 EXYNOS_CIOCRSA(buf_id)); 1232 EXYNOS_CIOCRSA(buf_id));
1231 } 1233 }
1232 break; 1234 break;
1233 case IPP_BUF_DEQUEUE: 1235 case IPP_BUF_DEQUEUE:
1234 fimc_write(0x0, EXYNOS_CIOYSA(buf_id)); 1236 fimc_write(ctx, 0x0, EXYNOS_CIOYSA(buf_id));
1235 fimc_write(0x0, EXYNOS_CIOCBSA(buf_id)); 1237 fimc_write(ctx, 0x0, EXYNOS_CIOCBSA(buf_id));
1236 fimc_write(0x0, EXYNOS_CIOCRSA(buf_id)); 1238 fimc_write(ctx, 0x0, EXYNOS_CIOCRSA(buf_id));
1237 break; 1239 break;
1238 default: 1240 default:
1239 /* bypass */ 1241 /* bypass */
@@ -1465,15 +1467,15 @@ static void fimc_clear_addr(struct fimc_context *ctx)
1465 int i; 1467 int i;
1466 1468
1467 for (i = 0; i < FIMC_MAX_SRC; i++) { 1469 for (i = 0; i < FIMC_MAX_SRC; i++) {
1468 fimc_write(0, EXYNOS_CIIYSA(i)); 1470 fimc_write(ctx, 0, EXYNOS_CIIYSA(i));
1469 fimc_write(0, EXYNOS_CIICBSA(i)); 1471 fimc_write(ctx, 0, EXYNOS_CIICBSA(i));
1470 fimc_write(0, EXYNOS_CIICRSA(i)); 1472 fimc_write(ctx, 0, EXYNOS_CIICRSA(i));
1471 } 1473 }
1472 1474
1473 for (i = 0; i < FIMC_MAX_DST; i++) { 1475 for (i = 0; i < FIMC_MAX_DST; i++) {
1474 fimc_write(0, EXYNOS_CIOYSA(i)); 1476 fimc_write(ctx, 0, EXYNOS_CIOYSA(i));
1475 fimc_write(0, EXYNOS_CIOCBSA(i)); 1477 fimc_write(ctx, 0, EXYNOS_CIOCBSA(i));
1476 fimc_write(0, EXYNOS_CIOCRSA(i)); 1478 fimc_write(ctx, 0, EXYNOS_CIOCRSA(i));
1477 } 1479 }
1478} 1480}
1479 1481
@@ -1539,10 +1541,10 @@ static int fimc_ippdrv_start(struct device *dev, enum drm_exynos_ipp_cmd cmd)
1539 fimc_handle_lastend(ctx, false); 1541 fimc_handle_lastend(ctx, false);
1540 1542
1541 /* setup dma */ 1543 /* setup dma */
1542 cfg0 = fimc_read(EXYNOS_MSCTRL); 1544 cfg0 = fimc_read(ctx, EXYNOS_MSCTRL);
1543 cfg0 &= ~EXYNOS_MSCTRL_INPUT_MASK; 1545 cfg0 &= ~EXYNOS_MSCTRL_INPUT_MASK;
1544 cfg0 |= EXYNOS_MSCTRL_INPUT_MEMORY; 1546 cfg0 |= EXYNOS_MSCTRL_INPUT_MEMORY;
1545 fimc_write(cfg0, EXYNOS_MSCTRL); 1547 fimc_write(ctx, cfg0, EXYNOS_MSCTRL);
1546 break; 1548 break;
1547 case IPP_CMD_WB: 1549 case IPP_CMD_WB:
1548 fimc_set_type_ctrl(ctx, FIMC_WB_A); 1550 fimc_set_type_ctrl(ctx, FIMC_WB_A);
@@ -1567,41 +1569,33 @@ static int fimc_ippdrv_start(struct device *dev, enum drm_exynos_ipp_cmd cmd)
1567 } 1569 }
1568 1570
1569 /* Reset status */ 1571 /* Reset status */
1570 fimc_write(0x0, EXYNOS_CISTATUS); 1572 fimc_write(ctx, 0x0, EXYNOS_CISTATUS);
1571 1573
1572 cfg0 = fimc_read(EXYNOS_CIIMGCPT); 1574 cfg0 = fimc_read(ctx, EXYNOS_CIIMGCPT);
1573 cfg0 &= ~EXYNOS_CIIMGCPT_IMGCPTEN_SC; 1575 cfg0 &= ~EXYNOS_CIIMGCPT_IMGCPTEN_SC;
1574 cfg0 |= EXYNOS_CIIMGCPT_IMGCPTEN_SC; 1576 cfg0 |= EXYNOS_CIIMGCPT_IMGCPTEN_SC;
1575 1577
1576 /* Scaler */ 1578 /* Scaler */
1577 cfg1 = fimc_read(EXYNOS_CISCCTRL); 1579 cfg1 = fimc_read(ctx, EXYNOS_CISCCTRL);
1578 cfg1 &= ~EXYNOS_CISCCTRL_SCAN_MASK; 1580 cfg1 &= ~EXYNOS_CISCCTRL_SCAN_MASK;
1579 cfg1 |= (EXYNOS_CISCCTRL_PROGRESSIVE | 1581 cfg1 |= (EXYNOS_CISCCTRL_PROGRESSIVE |
1580 EXYNOS_CISCCTRL_SCALERSTART); 1582 EXYNOS_CISCCTRL_SCALERSTART);
1581 1583
1582 fimc_write(cfg1, EXYNOS_CISCCTRL); 1584 fimc_write(ctx, cfg1, EXYNOS_CISCCTRL);
1583 1585
1584 /* Enable image capture*/ 1586 /* Enable image capture*/
1585 cfg0 |= EXYNOS_CIIMGCPT_IMGCPTEN; 1587 cfg0 |= EXYNOS_CIIMGCPT_IMGCPTEN;
1586 fimc_write(cfg0, EXYNOS_CIIMGCPT); 1588 fimc_write(ctx, cfg0, EXYNOS_CIIMGCPT);
1587 1589
1588 /* Disable frame end irq */ 1590 /* Disable frame end irq */
1589 cfg0 = fimc_read(EXYNOS_CIGCTRL); 1591 fimc_clear_bits(ctx, EXYNOS_CIGCTRL, EXYNOS_CIGCTRL_IRQ_END_DISABLE);
1590 cfg0 &= ~EXYNOS_CIGCTRL_IRQ_END_DISABLE;
1591 fimc_write(cfg0, EXYNOS_CIGCTRL);
1592 1592
1593 cfg0 = fimc_read(EXYNOS_CIOCTRL); 1593 fimc_clear_bits(ctx, EXYNOS_CIOCTRL, EXYNOS_CIOCTRL_WEAVE_MASK);
1594 cfg0 &= ~EXYNOS_CIOCTRL_WEAVE_MASK;
1595 fimc_write(cfg0, EXYNOS_CIOCTRL);
1596 1594
1597 if (cmd == IPP_CMD_M2M) { 1595 if (cmd == IPP_CMD_M2M) {
1598 cfg0 = fimc_read(EXYNOS_MSCTRL); 1596 fimc_set_bits(ctx, EXYNOS_MSCTRL, EXYNOS_MSCTRL_ENVID);
1599 cfg0 |= EXYNOS_MSCTRL_ENVID;
1600 fimc_write(cfg0, EXYNOS_MSCTRL);
1601 1597
1602 cfg0 = fimc_read(EXYNOS_MSCTRL); 1598 fimc_set_bits(ctx, EXYNOS_MSCTRL, EXYNOS_MSCTRL_ENVID);
1603 cfg0 |= EXYNOS_MSCTRL_ENVID;
1604 fimc_write(cfg0, EXYNOS_MSCTRL);
1605 } 1599 }
1606 1600
1607 return 0; 1601 return 0;
@@ -1618,10 +1612,10 @@ static void fimc_ippdrv_stop(struct device *dev, enum drm_exynos_ipp_cmd cmd)
1618 switch (cmd) { 1612 switch (cmd) {
1619 case IPP_CMD_M2M: 1613 case IPP_CMD_M2M:
1620 /* Source clear */ 1614 /* Source clear */
1621 cfg = fimc_read(EXYNOS_MSCTRL); 1615 cfg = fimc_read(ctx, EXYNOS_MSCTRL);
1622 cfg &= ~EXYNOS_MSCTRL_INPUT_MASK; 1616 cfg &= ~EXYNOS_MSCTRL_INPUT_MASK;
1623 cfg &= ~EXYNOS_MSCTRL_ENVID; 1617 cfg &= ~EXYNOS_MSCTRL_ENVID;
1624 fimc_write(cfg, EXYNOS_MSCTRL); 1618 fimc_write(ctx, cfg, EXYNOS_MSCTRL);
1625 break; 1619 break;
1626 case IPP_CMD_WB: 1620 case IPP_CMD_WB:
1627 exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb); 1621 exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb);
@@ -1635,22 +1629,17 @@ static void fimc_ippdrv_stop(struct device *dev, enum drm_exynos_ipp_cmd cmd)
1635 fimc_mask_irq(ctx, false); 1629 fimc_mask_irq(ctx, false);
1636 1630
1637 /* reset sequence */ 1631 /* reset sequence */
1638 fimc_write(0x0, EXYNOS_CIFCNTSEQ); 1632 fimc_write(ctx, 0x0, EXYNOS_CIFCNTSEQ);
1639 1633
1640 /* Scaler disable */ 1634 /* Scaler disable */
1641 cfg = fimc_read(EXYNOS_CISCCTRL); 1635 fimc_clear_bits(ctx, EXYNOS_CISCCTRL, EXYNOS_CISCCTRL_SCALERSTART);
1642 cfg &= ~EXYNOS_CISCCTRL_SCALERSTART;
1643 fimc_write(cfg, EXYNOS_CISCCTRL);
1644 1636
1645 /* Disable image capture */ 1637 /* Disable image capture */
1646 cfg = fimc_read(EXYNOS_CIIMGCPT); 1638 fimc_clear_bits(ctx, EXYNOS_CIIMGCPT,
1647 cfg &= ~(EXYNOS_CIIMGCPT_IMGCPTEN_SC | EXYNOS_CIIMGCPT_IMGCPTEN); 1639 EXYNOS_CIIMGCPT_IMGCPTEN_SC | EXYNOS_CIIMGCPT_IMGCPTEN);
1648 fimc_write(cfg, EXYNOS_CIIMGCPT);
1649 1640
1650 /* Enable frame end irq */ 1641 /* Enable frame end irq */
1651 cfg = fimc_read(EXYNOS_CIGCTRL); 1642 fimc_set_bits(ctx, EXYNOS_CIGCTRL, EXYNOS_CIGCTRL_IRQ_END_DISABLE);
1652 cfg |= EXYNOS_CIGCTRL_IRQ_END_DISABLE;
1653 fimc_write(cfg, EXYNOS_CIGCTRL);
1654} 1643}
1655 1644
1656static void fimc_put_clocks(struct fimc_context *ctx) 1645static void fimc_put_clocks(struct fimc_context *ctx)