• Home
  • Raw
  • Download

Lines Matching refs:ctx

254 static inline void fimd_set_bits(struct fimd_context *ctx, u32 reg, u32 mask,  in fimd_set_bits()  argument
257 val = (val & mask) | (readl(ctx->regs + reg) & ~mask); in fimd_set_bits()
258 writel(val, ctx->regs + reg); in fimd_set_bits()
263 struct fimd_context *ctx = crtc->ctx; in fimd_enable_vblank() local
266 if (ctx->suspended) in fimd_enable_vblank()
269 if (!test_and_set_bit(0, &ctx->irq_flags)) { in fimd_enable_vblank()
270 val = readl(ctx->regs + VIDINTCON0); in fimd_enable_vblank()
274 if (ctx->i80_if) { in fimd_enable_vblank()
287 writel(val, ctx->regs + VIDINTCON0); in fimd_enable_vblank()
295 struct fimd_context *ctx = crtc->ctx; in fimd_disable_vblank() local
298 if (ctx->suspended) in fimd_disable_vblank()
301 if (test_and_clear_bit(0, &ctx->irq_flags)) { in fimd_disable_vblank()
302 val = readl(ctx->regs + VIDINTCON0); in fimd_disable_vblank()
306 if (ctx->i80_if) { in fimd_disable_vblank()
313 writel(val, ctx->regs + VIDINTCON0); in fimd_disable_vblank()
319 struct fimd_context *ctx = crtc->ctx; in fimd_wait_for_vblank() local
321 if (ctx->suspended) in fimd_wait_for_vblank()
324 atomic_set(&ctx->wait_vsync_event, 1); in fimd_wait_for_vblank()
330 if (!wait_event_timeout(ctx->wait_vsync_queue, in fimd_wait_for_vblank()
331 !atomic_read(&ctx->wait_vsync_event), in fimd_wait_for_vblank()
333 DRM_DEV_DEBUG_KMS(ctx->dev, "vblank wait timed out.\n"); in fimd_wait_for_vblank()
336 static void fimd_enable_video_output(struct fimd_context *ctx, unsigned int win, in fimd_enable_video_output() argument
339 u32 val = readl(ctx->regs + WINCON(win)); in fimd_enable_video_output()
346 writel(val, ctx->regs + WINCON(win)); in fimd_enable_video_output()
349 static void fimd_enable_shadow_channel_path(struct fimd_context *ctx, in fimd_enable_shadow_channel_path() argument
353 u32 val = readl(ctx->regs + SHADOWCON); in fimd_enable_shadow_channel_path()
360 writel(val, ctx->regs + SHADOWCON); in fimd_enable_shadow_channel_path()
365 struct fimd_context *ctx = crtc->ctx; in fimd_clear_channels() local
370 ret = pm_runtime_resume_and_get(ctx->dev); in fimd_clear_channels()
372 dev_err(ctx->dev, "failed to enable FIMD device.\n"); in fimd_clear_channels()
376 clk_prepare_enable(ctx->bus_clk); in fimd_clear_channels()
377 clk_prepare_enable(ctx->lcd_clk); in fimd_clear_channels()
381 u32 val = readl(ctx->regs + WINCON(win)); in fimd_clear_channels()
384 fimd_enable_video_output(ctx, win, false); in fimd_clear_channels()
386 if (ctx->driver_data->has_shadowcon) in fimd_clear_channels()
387 fimd_enable_shadow_channel_path(ctx, win, in fimd_clear_channels()
396 ctx->suspended = false; in fimd_clear_channels()
398 fimd_enable_vblank(ctx->crtc); in fimd_clear_channels()
399 fimd_wait_for_vblank(ctx->crtc); in fimd_clear_channels()
400 fimd_disable_vblank(ctx->crtc); in fimd_clear_channels()
402 ctx->suspended = true; in fimd_clear_channels()
405 clk_disable_unprepare(ctx->lcd_clk); in fimd_clear_channels()
406 clk_disable_unprepare(ctx->bus_clk); in fimd_clear_channels()
408 pm_runtime_put(ctx->dev); in fimd_clear_channels()
418 struct fimd_context *ctx = crtc->ctx; in fimd_atomic_check() local
423 DRM_DEV_ERROR(ctx->dev, "Mode has zero clock value.\n"); in fimd_atomic_check()
429 if (ctx->i80_if) { in fimd_atomic_check()
437 lcd_rate = clk_get_rate(ctx->lcd_clk); in fimd_atomic_check()
439 DRM_DEV_ERROR(ctx->dev, in fimd_atomic_check()
448 DRM_DEV_ERROR(ctx->dev, "requested pixel clock(%lu) too low\n", in fimd_atomic_check()
453 ctx->clkdiv = (clkdiv < 0x100) ? clkdiv : 0xff; in fimd_atomic_check()
458 static void fimd_setup_trigger(struct fimd_context *ctx) in fimd_setup_trigger() argument
460 void __iomem *timing_base = ctx->regs + ctx->driver_data->timing_base; in fimd_setup_trigger()
461 u32 trg_type = ctx->driver_data->trg_type; in fimd_setup_trigger()
467 if (ctx->driver_data->has_hw_trigger) in fimd_setup_trigger()
469 if (ctx->driver_data->has_trigger_per_te) in fimd_setup_trigger()
480 struct fimd_context *ctx = crtc->ctx; in fimd_commit() local
482 const struct fimd_driver_data *driver_data = ctx->driver_data; in fimd_commit()
483 void *timing_base = ctx->regs + driver_data->timing_base; in fimd_commit()
486 if (ctx->suspended) in fimd_commit()
493 if (ctx->i80_if) { in fimd_commit()
494 val = ctx->i80ifcon | I80IFEN_ENABLE; in fimd_commit()
501 if (driver_data->has_vtsel && ctx->sysreg && in fimd_commit()
502 regmap_update_bits(ctx->sysreg, in fimd_commit()
506 DRM_DEV_ERROR(ctx->dev, in fimd_commit()
515 vidcon1 = ctx->vidcon1; in fimd_commit()
520 writel(vidcon1, ctx->regs + driver_data->timing_base + VIDCON1); in fimd_commit()
530 writel(val, ctx->regs + driver_data->timing_base + VIDTCON0); in fimd_commit()
540 writel(val, ctx->regs + driver_data->timing_base + VIDTCON1); in fimd_commit()
544 writel(ctx->vidout_con, timing_base + VIDOUT_CON); in fimd_commit()
547 if (ctx->sysreg && regmap_update_bits(ctx->sysreg, in fimd_commit()
551 DRM_DEV_ERROR(ctx->dev, in fimd_commit()
559 if (driver_data->has_mic_bypass && ctx->sysreg && in fimd_commit()
560 regmap_update_bits(ctx->sysreg, in fimd_commit()
564 DRM_DEV_ERROR(ctx->dev, in fimd_commit()
574 writel(val, ctx->regs + driver_data->timing_base + VIDTCON2); in fimd_commit()
576 fimd_setup_trigger(ctx); in fimd_commit()
582 val = ctx->vidcon0; in fimd_commit()
585 if (ctx->driver_data->has_clksel) in fimd_commit()
588 if (ctx->clkdiv > 1) in fimd_commit()
589 val |= VIDCON0_CLKVAL_F(ctx->clkdiv - 1) | VIDCON0_CLKDIR; in fimd_commit()
591 writel(val, ctx->regs + VIDCON0); in fimd_commit()
594 static void fimd_win_set_bldeq(struct fimd_context *ctx, unsigned int win, in fimd_win_set_bldeq() argument
617 fimd_set_bits(ctx, BLENDEQx(win), mask, val); in fimd_win_set_bldeq()
620 static void fimd_win_set_bldmod(struct fimd_context *ctx, unsigned int win, in fimd_win_set_bldmod() argument
638 fimd_set_bits(ctx, WINCON(win), WINCONx_BLEND_MODE_MASK, val); in fimd_win_set_bldmod()
647 writel(val, ctx->regs + VIDOSD_C(win)); in fimd_win_set_bldmod()
651 writel(val, ctx->regs + VIDWnALPHA0(win)); in fimd_win_set_bldmod()
655 writel(val, ctx->regs + VIDWnALPHA1(win)); in fimd_win_set_bldmod()
657 fimd_set_bits(ctx, BLENDCON, BLENDCON_NEW_MASK, in fimd_win_set_bldmod()
661 static void fimd_win_set_pixfmt(struct fimd_context *ctx, unsigned int win, in fimd_win_set_pixfmt() argument
664 struct exynos_drm_plane *plane = &ctx->planes[win]; in fimd_win_set_pixfmt()
681 if (ctx->driver_data->has_limited_fmt && !win) { in fimd_win_set_pixfmt()
724 writel(WIN_RGB_ORDER_REVERSE, ctx->regs + WIN_RGB_ORDER(win)); in fimd_win_set_pixfmt()
727 writel(WIN_RGB_ORDER_FORWARD, ctx->regs + WIN_RGB_ORDER(win)); in fimd_win_set_pixfmt()
743 fimd_set_bits(ctx, WINCON(win), ~WINCONx_BLEND_MODE_MASK, val); in fimd_win_set_pixfmt()
747 fimd_win_set_bldmod(ctx, win, alpha, pixel_alpha); in fimd_win_set_pixfmt()
748 fimd_win_set_bldeq(ctx, win, alpha, pixel_alpha); in fimd_win_set_pixfmt()
752 static void fimd_win_set_colkey(struct fimd_context *ctx, unsigned int win) in fimd_win_set_colkey() argument
761 writel(keycon0, ctx->regs + WKEYCON0_BASE(win)); in fimd_win_set_colkey()
762 writel(keycon1, ctx->regs + WKEYCON1_BASE(win)); in fimd_win_set_colkey()
772 static void fimd_shadow_protect_win(struct fimd_context *ctx, in fimd_shadow_protect_win() argument
787 if (ctx->driver_data->has_shadowcon) { in fimd_shadow_protect_win()
795 val = readl(ctx->regs + reg); in fimd_shadow_protect_win()
800 writel(val, ctx->regs + reg); in fimd_shadow_protect_win()
805 struct fimd_context *ctx = crtc->ctx; in fimd_atomic_begin() local
808 if (ctx->suspended) in fimd_atomic_begin()
812 fimd_shadow_protect_win(ctx, i, true); in fimd_atomic_begin()
817 struct fimd_context *ctx = crtc->ctx; in fimd_atomic_flush() local
820 if (ctx->suspended) in fimd_atomic_flush()
824 fimd_shadow_protect_win(ctx, i, false); in fimd_atomic_flush()
834 struct fimd_context *ctx = crtc->ctx; in fimd_update_plane() local
843 if (ctx->suspended) in fimd_update_plane()
852 writel(val, ctx->regs + VIDWx_BUF_START(win, 0)); in fimd_update_plane()
857 writel(val, ctx->regs + VIDWx_BUF_END(win, 0)); in fimd_update_plane()
859 DRM_DEV_DEBUG_KMS(ctx->dev, in fimd_update_plane()
862 DRM_DEV_DEBUG_KMS(ctx->dev, "ovl_width = %d, ovl_height = %d\n", in fimd_update_plane()
872 writel(val, ctx->regs + VIDWx_BUF_SIZE(win, 0)); in fimd_update_plane()
879 writel(val, ctx->regs + VIDOSD_A(win)); in fimd_update_plane()
891 writel(val, ctx->regs + VIDOSD_B(win)); in fimd_update_plane()
893 DRM_DEV_DEBUG_KMS(ctx->dev, in fimd_update_plane()
903 writel(val, ctx->regs + offset); in fimd_update_plane()
905 DRM_DEV_DEBUG_KMS(ctx->dev, "osd size = 0x%x\n", in fimd_update_plane()
909 fimd_win_set_pixfmt(ctx, win, fb, state->src.w); in fimd_update_plane()
913 fimd_win_set_colkey(ctx, win); in fimd_update_plane()
915 fimd_enable_video_output(ctx, win, true); in fimd_update_plane()
917 if (ctx->driver_data->has_shadowcon) in fimd_update_plane()
918 fimd_enable_shadow_channel_path(ctx, win, true); in fimd_update_plane()
920 if (ctx->i80_if) in fimd_update_plane()
921 atomic_set(&ctx->win_updated, 1); in fimd_update_plane()
927 struct fimd_context *ctx = crtc->ctx; in fimd_disable_plane() local
930 if (ctx->suspended) in fimd_disable_plane()
933 fimd_enable_video_output(ctx, win, false); in fimd_disable_plane()
935 if (ctx->driver_data->has_shadowcon) in fimd_disable_plane()
936 fimd_enable_shadow_channel_path(ctx, win, false); in fimd_disable_plane()
941 struct fimd_context *ctx = crtc->ctx; in fimd_atomic_enable() local
943 if (!ctx->suspended) in fimd_atomic_enable()
946 ctx->suspended = false; in fimd_atomic_enable()
948 if (pm_runtime_resume_and_get(ctx->dev) < 0) { in fimd_atomic_enable()
949 dev_warn(ctx->dev, "failed to enable FIMD device.\n"); in fimd_atomic_enable()
954 if (test_and_clear_bit(0, &ctx->irq_flags)) in fimd_atomic_enable()
955 fimd_enable_vblank(ctx->crtc); in fimd_atomic_enable()
957 fimd_commit(ctx->crtc); in fimd_atomic_enable()
962 struct fimd_context *ctx = crtc->ctx; in fimd_atomic_disable() local
965 if (ctx->suspended) in fimd_atomic_disable()
974 fimd_disable_plane(crtc, &ctx->planes[i]); in fimd_atomic_disable()
980 writel(0, ctx->regs + VIDCON0); in fimd_atomic_disable()
982 pm_runtime_put_sync(ctx->dev); in fimd_atomic_disable()
983 ctx->suspended = true; in fimd_atomic_disable()
988 struct fimd_context *ctx = dev_get_drvdata(dev); in fimd_trigger() local
989 const struct fimd_driver_data *driver_data = ctx->driver_data; in fimd_trigger()
990 void *timing_base = ctx->regs + driver_data->timing_base; in fimd_trigger()
997 if (atomic_read(&ctx->triggering)) in fimd_trigger()
1001 atomic_set(&ctx->triggering, 1); in fimd_trigger()
1011 if (!test_bit(0, &ctx->irq_flags)) in fimd_trigger()
1012 atomic_set(&ctx->triggering, 0); in fimd_trigger()
1017 struct fimd_context *ctx = crtc->ctx; in fimd_te_handler() local
1018 u32 trg_type = ctx->driver_data->trg_type; in fimd_te_handler()
1021 if (!ctx->drm_dev) in fimd_te_handler()
1031 if (atomic_add_unless(&ctx->win_updated, -1, 0)) in fimd_te_handler()
1032 fimd_trigger(ctx->dev); in fimd_te_handler()
1036 if (atomic_read(&ctx->wait_vsync_event)) { in fimd_te_handler()
1037 atomic_set(&ctx->wait_vsync_event, 0); in fimd_te_handler()
1038 wake_up(&ctx->wait_vsync_queue); in fimd_te_handler()
1041 if (test_bit(0, &ctx->irq_flags)) in fimd_te_handler()
1042 drm_crtc_handle_vblank(&ctx->crtc->base); in fimd_te_handler()
1047 struct fimd_context *ctx = container_of(clk, struct fimd_context, in fimd_dp_clock_enable() local
1050 writel(val, ctx->regs + DP_MIE_CLKCON); in fimd_dp_clock_enable()
1068 struct fimd_context *ctx = (struct fimd_context *)dev_id; in fimd_irq_handler() local
1071 val = readl(ctx->regs + VIDINTCON1); in fimd_irq_handler()
1073 clear_bit = ctx->i80_if ? VIDINTCON1_INT_I80 : VIDINTCON1_INT_FRAME; in fimd_irq_handler()
1075 writel(clear_bit, ctx->regs + VIDINTCON1); in fimd_irq_handler()
1078 if (!ctx->drm_dev) in fimd_irq_handler()
1081 if (!ctx->i80_if) in fimd_irq_handler()
1082 drm_crtc_handle_vblank(&ctx->crtc->base); in fimd_irq_handler()
1084 if (ctx->i80_if) { in fimd_irq_handler()
1086 atomic_set(&ctx->triggering, 0); in fimd_irq_handler()
1089 if (atomic_read(&ctx->wait_vsync_event)) { in fimd_irq_handler()
1090 atomic_set(&ctx->wait_vsync_event, 0); in fimd_irq_handler()
1091 wake_up(&ctx->wait_vsync_queue); in fimd_irq_handler()
1101 struct fimd_context *ctx = dev_get_drvdata(dev); in fimd_bind() local
1107 ctx->drm_dev = drm_dev; in fimd_bind()
1110 if (ctx->driver_data->has_bgr_support) { in fimd_bind()
1111 ctx->configs[i].pixel_formats = fimd_extended_formats; in fimd_bind()
1112 ctx->configs[i].num_pixel_formats = ARRAY_SIZE(fimd_extended_formats); in fimd_bind()
1114 ctx->configs[i].pixel_formats = fimd_formats; in fimd_bind()
1115 ctx->configs[i].num_pixel_formats = ARRAY_SIZE(fimd_formats); in fimd_bind()
1118 ctx->configs[i].zpos = i; in fimd_bind()
1119 ctx->configs[i].type = fimd_win_types[i]; in fimd_bind()
1120 ctx->configs[i].capabilities = capabilities[i]; in fimd_bind()
1121 ret = exynos_plane_init(drm_dev, &ctx->planes[i], i, in fimd_bind()
1122 &ctx->configs[i]); in fimd_bind()
1127 exynos_plane = &ctx->planes[DEFAULT_WIN]; in fimd_bind()
1128 ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base, in fimd_bind()
1129 EXYNOS_DISPLAY_TYPE_LCD, &fimd_crtc_ops, ctx); in fimd_bind()
1130 if (IS_ERR(ctx->crtc)) in fimd_bind()
1131 return PTR_ERR(ctx->crtc); in fimd_bind()
1133 if (ctx->driver_data->has_dp_clk) { in fimd_bind()
1134 ctx->dp_clk.enable = fimd_dp_clock_enable; in fimd_bind()
1135 ctx->crtc->pipe_clk = &ctx->dp_clk; in fimd_bind()
1138 if (ctx->encoder) in fimd_bind()
1139 exynos_dpi_bind(drm_dev, ctx->encoder); in fimd_bind()
1144 ret = fimd_clear_channels(ctx->crtc); in fimd_bind()
1149 return exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv); in fimd_bind()
1155 struct fimd_context *ctx = dev_get_drvdata(dev); in fimd_unbind() local
1157 fimd_atomic_disable(ctx->crtc); in fimd_unbind()
1159 exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev, &ctx->dma_priv); in fimd_unbind()
1161 if (ctx->encoder) in fimd_unbind()
1162 exynos_dpi_remove(ctx->encoder); in fimd_unbind()
1173 struct fimd_context *ctx; in fimd_probe() local
1180 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); in fimd_probe()
1181 if (!ctx) in fimd_probe()
1184 ctx->dev = dev; in fimd_probe()
1185 ctx->suspended = true; in fimd_probe()
1186 ctx->driver_data = of_device_get_match_data(dev); in fimd_probe()
1189 ctx->vidcon1 |= VIDCON1_INV_VDEN; in fimd_probe()
1191 ctx->vidcon1 |= VIDCON1_INV_VCLK; in fimd_probe()
1197 ctx->i80_if = true; in fimd_probe()
1199 if (ctx->driver_data->has_vidoutcon) in fimd_probe()
1200 ctx->vidout_con |= VIDOUT_CON_F_I80_LDI0; in fimd_probe()
1202 ctx->vidcon0 |= VIDCON0_VIDOUT_I80_LDI0; in fimd_probe()
1207 ctx->vidcon0 |= VIDCON0_DSI_EN; in fimd_probe()
1211 ctx->i80ifcon = LCD_CS_SETUP(val); in fimd_probe()
1214 ctx->i80ifcon |= LCD_WR_SETUP(val); in fimd_probe()
1217 ctx->i80ifcon |= LCD_WR_ACTIVE(val); in fimd_probe()
1220 ctx->i80ifcon |= LCD_WR_HOLD(val); in fimd_probe()
1224 ctx->sysreg = syscon_regmap_lookup_by_phandle(dev->of_node, in fimd_probe()
1226 if (IS_ERR(ctx->sysreg)) { in fimd_probe()
1228 ctx->sysreg = NULL; in fimd_probe()
1231 ctx->bus_clk = devm_clk_get(dev, "fimd"); in fimd_probe()
1232 if (IS_ERR(ctx->bus_clk)) { in fimd_probe()
1234 return PTR_ERR(ctx->bus_clk); in fimd_probe()
1237 ctx->lcd_clk = devm_clk_get(dev, "sclk_fimd"); in fimd_probe()
1238 if (IS_ERR(ctx->lcd_clk)) { in fimd_probe()
1240 return PTR_ERR(ctx->lcd_clk); in fimd_probe()
1243 ctx->regs = devm_platform_ioremap_resource(pdev, 0); in fimd_probe()
1244 if (IS_ERR(ctx->regs)) in fimd_probe()
1245 return PTR_ERR(ctx->regs); in fimd_probe()
1247 ret = platform_get_irq_byname(pdev, ctx->i80_if ? "lcd_sys" : "vsync"); in fimd_probe()
1251 ret = devm_request_irq(dev, ret, fimd_irq_handler, 0, "drm_fimd", ctx); in fimd_probe()
1257 init_waitqueue_head(&ctx->wait_vsync_queue); in fimd_probe()
1258 atomic_set(&ctx->wait_vsync_event, 0); in fimd_probe()
1260 platform_set_drvdata(pdev, ctx); in fimd_probe()
1262 ctx->encoder = exynos_dpi_probe(dev); in fimd_probe()
1263 if (IS_ERR(ctx->encoder)) in fimd_probe()
1264 return PTR_ERR(ctx->encoder); in fimd_probe()
1291 struct fimd_context *ctx = dev_get_drvdata(dev); in exynos_fimd_suspend() local
1293 clk_disable_unprepare(ctx->lcd_clk); in exynos_fimd_suspend()
1294 clk_disable_unprepare(ctx->bus_clk); in exynos_fimd_suspend()
1301 struct fimd_context *ctx = dev_get_drvdata(dev); in exynos_fimd_resume() local
1304 ret = clk_prepare_enable(ctx->bus_clk); in exynos_fimd_resume()
1312 ret = clk_prepare_enable(ctx->lcd_clk); in exynos_fimd_resume()