aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorTobias Jakobi <tjakobi@math.uni-bielefeld.de>2016-09-21 22:36:13 -0400
committerInki Dae <daeinki@gmail.com>2016-09-30 11:39:33 -0400
commitadeb6f44858c7b0665847545374532ebdcf04a91 (patch)
treef71f4519533b98248fcf8aa801aa87eee6ca1b39 /drivers/gpu
parentc0d656dd2d76db1e7db61609ec8549d38ce0bbff (diff)
drm/exynos: mixer: convert booleans to flags in mixer context
The mixer context struct already has a 'flags' field, so we can use it to store the 'interlace', 'vp_enabled' and 'has_sclk' booleans. We use the non-atomic helper functions to access these bits. Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index e1d47f9435fc..eff85891c4db 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -73,6 +73,9 @@ enum mixer_version_id {
73enum mixer_flag_bits { 73enum mixer_flag_bits {
74 MXR_BIT_POWERED, 74 MXR_BIT_POWERED,
75 MXR_BIT_VSYNC, 75 MXR_BIT_VSYNC,
76 MXR_BIT_INTERLACE,
77 MXR_BIT_VP_ENABLED,
78 MXR_BIT_HAS_SCLK,
76}; 79};
77 80
78static const uint32_t mixer_formats[] = { 81static const uint32_t mixer_formats[] = {
@@ -98,9 +101,6 @@ struct mixer_context {
98 struct exynos_drm_plane planes[MIXER_WIN_NR]; 101 struct exynos_drm_plane planes[MIXER_WIN_NR];
99 int pipe; 102 int pipe;
100 unsigned long flags; 103 unsigned long flags;
101 bool interlace;
102 bool vp_enabled;
103 bool has_sclk;
104 104
105 struct mixer_resources mixer_res; 105 struct mixer_resources mixer_res;
106 enum mixer_version_id mxr_ver; 106 enum mixer_version_id mxr_ver;
@@ -346,7 +346,7 @@ static void mixer_vsync_set_update(struct mixer_context *ctx, bool enable)
346 mixer_reg_writemask(res, MXR_STATUS, enable ? 346 mixer_reg_writemask(res, MXR_STATUS, enable ?
347 MXR_STATUS_SYNC_ENABLE : 0, MXR_STATUS_SYNC_ENABLE); 347 MXR_STATUS_SYNC_ENABLE : 0, MXR_STATUS_SYNC_ENABLE);
348 348
349 if (ctx->vp_enabled) 349 if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags))
350 vp_reg_write(res, VP_SHADOW_UPDATE, enable ? 350 vp_reg_write(res, VP_SHADOW_UPDATE, enable ?
351 VP_SHADOW_UPDATE_ENABLE : 0); 351 VP_SHADOW_UPDATE_ENABLE : 0);
352} 352}
@@ -357,8 +357,8 @@ static void mixer_cfg_scan(struct mixer_context *ctx, unsigned int height)
357 u32 val; 357 u32 val;
358 358
359 /* choosing between interlace and progressive mode */ 359 /* choosing between interlace and progressive mode */
360 val = (ctx->interlace ? MXR_CFG_SCAN_INTERLACE : 360 val = test_bit(MXR_BIT_INTERLACE, &ctx->flags) ?
361 MXR_CFG_SCAN_PROGRESSIVE); 361 MXR_CFG_SCAN_INTERLACE : MXR_CFG_SCAN_PROGRESSIVE;
362 362
363 if (ctx->mxr_ver != MXR_VER_128_0_0_184) { 363 if (ctx->mxr_ver != MXR_VER_128_0_0_184) {
364 /* choosing between proper HD and SD mode */ 364 /* choosing between proper HD and SD mode */
@@ -436,9 +436,10 @@ static void mixer_cfg_layer(struct mixer_context *ctx, unsigned int win,
436 mixer_reg_writemask(res, MXR_LAYER_CFG, 436 mixer_reg_writemask(res, MXR_LAYER_CFG,
437 MXR_LAYER_CFG_GRP1_VAL(priority), 437 MXR_LAYER_CFG_GRP1_VAL(priority),
438 MXR_LAYER_CFG_GRP1_MASK); 438 MXR_LAYER_CFG_GRP1_MASK);
439
439 break; 440 break;
440 case VP_DEFAULT_WIN: 441 case VP_DEFAULT_WIN:
441 if (ctx->vp_enabled) { 442 if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
442 vp_reg_writemask(res, VP_ENABLE, val, VP_ENABLE_ON); 443 vp_reg_writemask(res, VP_ENABLE, val, VP_ENABLE_ON);
443 mixer_reg_writemask(res, MXR_CFG, val, 444 mixer_reg_writemask(res, MXR_CFG, val,
444 MXR_CFG_VP_ENABLE); 445 MXR_CFG_VP_ENABLE);
@@ -501,7 +502,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
501 chroma_addr[0] = exynos_drm_fb_dma_addr(fb, 1); 502 chroma_addr[0] = exynos_drm_fb_dma_addr(fb, 1);
502 503
503 if (mode->flags & DRM_MODE_FLAG_INTERLACE) { 504 if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
504 ctx->interlace = true; 505 __set_bit(MXR_BIT_INTERLACE, &ctx->flags);
505 if (tiled_mode) { 506 if (tiled_mode) {
506 luma_addr[1] = luma_addr[0] + 0x40; 507 luma_addr[1] = luma_addr[0] + 0x40;
507 chroma_addr[1] = chroma_addr[0] + 0x40; 508 chroma_addr[1] = chroma_addr[0] + 0x40;
@@ -510,7 +511,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
510 chroma_addr[1] = chroma_addr[0] + fb->pitches[0]; 511 chroma_addr[1] = chroma_addr[0] + fb->pitches[0];
511 } 512 }
512 } else { 513 } else {
513 ctx->interlace = false; 514 __clear_bit(MXR_BIT_INTERLACE, &ctx->flags);
514 luma_addr[1] = 0; 515 luma_addr[1] = 0;
515 chroma_addr[1] = 0; 516 chroma_addr[1] = 0;
516 } 517 }
@@ -518,7 +519,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
518 spin_lock_irqsave(&res->reg_slock, flags); 519 spin_lock_irqsave(&res->reg_slock, flags);
519 520
520 /* interlace or progressive scan mode */ 521 /* interlace or progressive scan mode */
521 val = (ctx->interlace ? ~0 : 0); 522 val = (test_bit(MXR_BIT_INTERLACE, &ctx->flags) ? ~0 : 0);
522 vp_reg_writemask(res, VP_MODE, val, VP_MODE_LINE_SKIP); 523 vp_reg_writemask(res, VP_MODE, val, VP_MODE_LINE_SKIP);
523 524
524 /* setup format */ 525 /* setup format */
@@ -541,7 +542,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
541 542
542 vp_reg_write(res, VP_DST_WIDTH, state->crtc.w); 543 vp_reg_write(res, VP_DST_WIDTH, state->crtc.w);
543 vp_reg_write(res, VP_DST_H_POSITION, state->crtc.x); 544 vp_reg_write(res, VP_DST_H_POSITION, state->crtc.x);
544 if (ctx->interlace) { 545 if (test_bit(MXR_BIT_INTERLACE, &ctx->flags)) {
545 vp_reg_write(res, VP_DST_HEIGHT, state->crtc.h / 2); 546 vp_reg_write(res, VP_DST_HEIGHT, state->crtc.h / 2);
546 vp_reg_write(res, VP_DST_V_POSITION, state->crtc.y / 2); 547 vp_reg_write(res, VP_DST_V_POSITION, state->crtc.y / 2);
547 } else { 548 } else {
@@ -636,9 +637,9 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
636 src_y_offset = 0; 637 src_y_offset = 0;
637 638
638 if (mode->flags & DRM_MODE_FLAG_INTERLACE) 639 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
639 ctx->interlace = true; 640 __set_bit(MXR_BIT_INTERLACE, &ctx->flags);
640 else 641 else
641 ctx->interlace = false; 642 __clear_bit(MXR_BIT_INTERLACE, &ctx->flags);
642 643
643 spin_lock_irqsave(&res->reg_slock, flags); 644 spin_lock_irqsave(&res->reg_slock, flags);
644 645
@@ -733,7 +734,7 @@ static void mixer_win_reset(struct mixer_context *ctx)
733 mixer_reg_write(res, MXR_BG_COLOR1, 0x008080); 734 mixer_reg_write(res, MXR_BG_COLOR1, 0x008080);
734 mixer_reg_write(res, MXR_BG_COLOR2, 0x008080); 735 mixer_reg_write(res, MXR_BG_COLOR2, 0x008080);
735 736
736 if (ctx->vp_enabled) { 737 if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
737 /* configuration of Video Processor Registers */ 738 /* configuration of Video Processor Registers */
738 vp_win_reset(ctx); 739 vp_win_reset(ctx);
739 vp_default_filter(res); 740 vp_default_filter(res);
@@ -742,7 +743,7 @@ static void mixer_win_reset(struct mixer_context *ctx)
742 /* disable all layers */ 743 /* disable all layers */
743 mixer_reg_writemask(res, MXR_CFG, 0, MXR_CFG_GRP0_ENABLE); 744 mixer_reg_writemask(res, MXR_CFG, 0, MXR_CFG_GRP0_ENABLE);
744 mixer_reg_writemask(res, MXR_CFG, 0, MXR_CFG_GRP1_ENABLE); 745 mixer_reg_writemask(res, MXR_CFG, 0, MXR_CFG_GRP1_ENABLE);
745 if (ctx->vp_enabled) 746 if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags))
746 mixer_reg_writemask(res, MXR_CFG, 0, MXR_CFG_VP_ENABLE); 747 mixer_reg_writemask(res, MXR_CFG, 0, MXR_CFG_VP_ENABLE);
747 748
748 spin_unlock_irqrestore(&res->reg_slock, flags); 749 spin_unlock_irqrestore(&res->reg_slock, flags);
@@ -767,7 +768,7 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg)
767 val &= ~MXR_INT_STATUS_VSYNC; 768 val &= ~MXR_INT_STATUS_VSYNC;
768 769
769 /* interlace scan need to check shadow register */ 770 /* interlace scan need to check shadow register */
770 if (ctx->interlace) { 771 if (test_bit(MXR_BIT_INTERLACE, &ctx->flags)) {
771 base = mixer_reg_read(res, MXR_GRAPHIC_BASE(0)); 772 base = mixer_reg_read(res, MXR_GRAPHIC_BASE(0));
772 shadow = mixer_reg_read(res, MXR_GRAPHIC_BASE_S(0)); 773 shadow = mixer_reg_read(res, MXR_GRAPHIC_BASE_S(0));
773 if (base != shadow) 774 if (base != shadow)
@@ -867,7 +868,7 @@ static int vp_resources_init(struct mixer_context *mixer_ctx)
867 return -ENODEV; 868 return -ENODEV;
868 } 869 }
869 870
870 if (mixer_ctx->has_sclk) { 871 if (test_bit(MXR_BIT_HAS_SCLK, &mixer_ctx->flags)) {
871 mixer_res->sclk_mixer = devm_clk_get(dev, "sclk_mixer"); 872 mixer_res->sclk_mixer = devm_clk_get(dev, "sclk_mixer");
872 if (IS_ERR(mixer_res->sclk_mixer)) { 873 if (IS_ERR(mixer_res->sclk_mixer)) {
873 dev_err(dev, "failed to get clock 'sclk_mixer'\n"); 874 dev_err(dev, "failed to get clock 'sclk_mixer'\n");
@@ -917,7 +918,7 @@ static int mixer_initialize(struct mixer_context *mixer_ctx,
917 return ret; 918 return ret;
918 } 919 }
919 920
920 if (mixer_ctx->vp_enabled) { 921 if (test_bit(MXR_BIT_VP_ENABLED, &mixer_ctx->flags)) {
921 /* acquire vp resources: regs, irqs, clocks */ 922 /* acquire vp resources: regs, irqs, clocks */
922 ret = vp_resources_init(mixer_ctx); 923 ret = vp_resources_init(mixer_ctx);
923 if (ret) { 924 if (ret) {
@@ -1160,7 +1161,8 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data)
1160 return ret; 1161 return ret;
1161 1162
1162 for (i = 0; i < MIXER_WIN_NR; i++) { 1163 for (i = 0; i < MIXER_WIN_NR; i++) {
1163 if (i == VP_DEFAULT_WIN && !ctx->vp_enabled) 1164 if (i == VP_DEFAULT_WIN && !test_bit(MXR_BIT_VP_ENABLED,
1165 &ctx->flags))
1164 continue; 1166 continue;
1165 1167
1166 ret = exynos_plane_init(drm_dev, &ctx->planes[i], i, 1168 ret = exynos_plane_init(drm_dev, &ctx->planes[i], i,
@@ -1215,10 +1217,13 @@ static int mixer_probe(struct platform_device *pdev)
1215 1217
1216 ctx->pdev = pdev; 1218 ctx->pdev = pdev;
1217 ctx->dev = dev; 1219 ctx->dev = dev;
1218 ctx->vp_enabled = drv->is_vp_enabled;
1219 ctx->has_sclk = drv->has_sclk;
1220 ctx->mxr_ver = drv->version; 1220 ctx->mxr_ver = drv->version;
1221 1221
1222 if (drv->is_vp_enabled)
1223 __set_bit(MXR_BIT_VP_ENABLED, &ctx->flags);
1224 if (drv->has_sclk)
1225 __set_bit(MXR_BIT_HAS_SCLK, &ctx->flags);
1226
1222 platform_set_drvdata(pdev, ctx); 1227 platform_set_drvdata(pdev, ctx);
1223 1228
1224 ret = component_add(&pdev->dev, &mixer_component_ops); 1229 ret = component_add(&pdev->dev, &mixer_component_ops);
@@ -1244,9 +1249,9 @@ static int __maybe_unused exynos_mixer_suspend(struct device *dev)
1244 1249
1245 clk_disable_unprepare(res->hdmi); 1250 clk_disable_unprepare(res->hdmi);
1246 clk_disable_unprepare(res->mixer); 1251 clk_disable_unprepare(res->mixer);
1247 if (ctx->vp_enabled) { 1252 if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
1248 clk_disable_unprepare(res->vp); 1253 clk_disable_unprepare(res->vp);
1249 if (ctx->has_sclk) 1254 if (test_bit(MXR_BIT_HAS_SCLK, &ctx->flags))
1250 clk_disable_unprepare(res->sclk_mixer); 1255 clk_disable_unprepare(res->sclk_mixer);
1251 } 1256 }
1252 1257
@@ -1269,14 +1274,14 @@ static int __maybe_unused exynos_mixer_resume(struct device *dev)
1269 DRM_ERROR("Failed to prepare_enable the hdmi clk [%d]\n", ret); 1274 DRM_ERROR("Failed to prepare_enable the hdmi clk [%d]\n", ret);
1270 return ret; 1275 return ret;
1271 } 1276 }
1272 if (ctx->vp_enabled) { 1277 if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) {
1273 ret = clk_prepare_enable(res->vp); 1278 ret = clk_prepare_enable(res->vp);
1274 if (ret < 0) { 1279 if (ret < 0) {
1275 DRM_ERROR("Failed to prepare_enable the vp clk [%d]\n", 1280 DRM_ERROR("Failed to prepare_enable the vp clk [%d]\n",
1276 ret); 1281 ret);
1277 return ret; 1282 return ret;
1278 } 1283 }
1279 if (ctx->has_sclk) { 1284 if (test_bit(MXR_BIT_HAS_SCLK, &ctx->flags)) {
1280 ret = clk_prepare_enable(res->sclk_mixer); 1285 ret = clk_prepare_enable(res->sclk_mixer);
1281 if (ret < 0) { 1286 if (ret < 0) {
1282 DRM_ERROR("Failed to prepare_enable the " \ 1287 DRM_ERROR("Failed to prepare_enable the " \