12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 2d8408326SSeung-Woo Kim /* 3d8408326SSeung-Woo Kim * Copyright (C) 2011 Samsung Electronics Co.Ltd 4d8408326SSeung-Woo Kim * Authors: 5d8408326SSeung-Woo Kim * Seung-Woo Kim <sw0312.kim@samsung.com> 6d8408326SSeung-Woo Kim * Inki Dae <inki.dae@samsung.com> 7d8408326SSeung-Woo Kim * Joonyoung Shim <jy0922.shim@samsung.com> 8d8408326SSeung-Woo Kim * 9d8408326SSeung-Woo Kim * Based on drivers/media/video/s5p-tv/mixer_reg.c 10d8408326SSeung-Woo Kim */ 11d8408326SSeung-Woo Kim 122bda34d7SSam Ravnborg #include <linux/clk.h> 132bda34d7SSam Ravnborg #include <linux/component.h> 142bda34d7SSam Ravnborg #include <linux/delay.h> 15d8408326SSeung-Woo Kim #include <linux/i2c.h> 16d8408326SSeung-Woo Kim #include <linux/interrupt.h> 17d8408326SSeung-Woo Kim #include <linux/irq.h> 182bda34d7SSam Ravnborg #include <linux/kernel.h> 192bda34d7SSam Ravnborg #include <linux/ktime.h> 203f1c781dSSachin Kamat #include <linux/of.h> 2148f6155aSMarek Szyprowski #include <linux/of_device.h> 222bda34d7SSam Ravnborg #include <linux/platform_device.h> 232bda34d7SSam Ravnborg #include <linux/pm_runtime.h> 242bda34d7SSam Ravnborg #include <linux/regulator/consumer.h> 252bda34d7SSam Ravnborg #include <linux/spinlock.h> 262bda34d7SSam Ravnborg #include <linux/wait.h> 27d8408326SSeung-Woo Kim 282bda34d7SSam Ravnborg #include <drm/drm_fourcc.h> 292bda34d7SSam Ravnborg #include <drm/drm_vblank.h> 30d8408326SSeung-Woo Kim #include <drm/exynos_drm.h> 31d8408326SSeung-Woo Kim 32663d8766SRahul Sharma #include "exynos_drm_crtc.h" 332bda34d7SSam Ravnborg #include "exynos_drm_drv.h" 340488f50eSMarek Szyprowski #include "exynos_drm_fb.h" 357ee14cdcSGustavo Padovan #include "exynos_drm_plane.h" 362bda34d7SSam Ravnborg #include "regs-mixer.h" 372bda34d7SSam Ravnborg #include "regs-vp.h" 3822b21ae6SJoonyoung Shim 39f041b257SSean Paul #define MIXER_WIN_NR 3 40fbbb1e1aSMarek Szyprowski #define VP_DEFAULT_WIN 2 41d8408326SSeung-Woo Kim 422a6e4cd5STobias Jakobi /* 432a6e4cd5STobias Jakobi * Mixer color space conversion coefficient triplet. 442a6e4cd5STobias Jakobi * Used for CSC from RGB to YCbCr. 452a6e4cd5STobias Jakobi * Each coefficient is a 10-bit fixed point number with 462a6e4cd5STobias Jakobi * sign and no integer part, i.e. 472a6e4cd5STobias Jakobi * [0:8] = fractional part (representing a value y = x / 2^9) 482a6e4cd5STobias Jakobi * [9] = sign 492a6e4cd5STobias Jakobi * Negative values are encoded with two's complement. 502a6e4cd5STobias Jakobi */ 512a6e4cd5STobias Jakobi #define MXR_CSC_C(x) ((int)((x) * 512.0) & 0x3ff) 522a6e4cd5STobias Jakobi #define MXR_CSC_CT(a0, a1, a2) \ 532a6e4cd5STobias Jakobi ((MXR_CSC_C(a0) << 20) | (MXR_CSC_C(a1) << 10) | (MXR_CSC_C(a2) << 0)) 542a6e4cd5STobias Jakobi 552a6e4cd5STobias Jakobi /* YCbCr value, used for mixer background color configuration. */ 562a6e4cd5STobias Jakobi #define MXR_YCBCR_VAL(y, cb, cr) (((y) << 16) | ((cb) << 8) | ((cr) << 0)) 572a6e4cd5STobias Jakobi 587a57ca7cSTobias Jakobi /* The pixelformats that are natively supported by the mixer. */ 597a57ca7cSTobias Jakobi #define MXR_FORMAT_RGB565 4 607a57ca7cSTobias Jakobi #define MXR_FORMAT_ARGB1555 5 617a57ca7cSTobias Jakobi #define MXR_FORMAT_ARGB4444 6 627a57ca7cSTobias Jakobi #define MXR_FORMAT_ARGB8888 7 637a57ca7cSTobias Jakobi 641e123441SRahul Sharma enum mixer_version_id { 651e123441SRahul Sharma MXR_VER_0_0_0_16, 661e123441SRahul Sharma MXR_VER_16_0_33_0, 67def5e095SRahul Sharma MXR_VER_128_0_0_184, 681e123441SRahul Sharma }; 691e123441SRahul Sharma 70a44652e8SAndrzej Hajda enum mixer_flag_bits { 71a44652e8SAndrzej Hajda MXR_BIT_POWERED, 720df5e4acSAndrzej Hajda MXR_BIT_VSYNC, 73adeb6f44STobias Jakobi MXR_BIT_INTERLACE, 74adeb6f44STobias Jakobi MXR_BIT_VP_ENABLED, 75adeb6f44STobias Jakobi MXR_BIT_HAS_SCLK, 76a44652e8SAndrzej Hajda }; 77a44652e8SAndrzej Hajda 78fbbb1e1aSMarek Szyprowski static const uint32_t mixer_formats[] = { 79fbbb1e1aSMarek Szyprowski DRM_FORMAT_XRGB4444, 8026a7af3eSTobias Jakobi DRM_FORMAT_ARGB4444, 81fbbb1e1aSMarek Szyprowski DRM_FORMAT_XRGB1555, 8226a7af3eSTobias Jakobi DRM_FORMAT_ARGB1555, 83fbbb1e1aSMarek Szyprowski DRM_FORMAT_RGB565, 84fbbb1e1aSMarek Szyprowski DRM_FORMAT_XRGB8888, 85fbbb1e1aSMarek Szyprowski DRM_FORMAT_ARGB8888, 86fbbb1e1aSMarek Szyprowski }; 87fbbb1e1aSMarek Szyprowski 88fbbb1e1aSMarek Szyprowski static const uint32_t vp_formats[] = { 89fbbb1e1aSMarek Szyprowski DRM_FORMAT_NV12, 90fbbb1e1aSMarek Szyprowski DRM_FORMAT_NV21, 91fbbb1e1aSMarek Szyprowski }; 92fbbb1e1aSMarek Szyprowski 9322b21ae6SJoonyoung Shim struct mixer_context { 944551789fSSean Paul struct platform_device *pdev; 95cf8fc4f1SJoonyoung Shim struct device *dev; 961055b39fSInki Dae struct drm_device *drm_dev; 97*07dc3678SMarek Szyprowski void *dma_priv; 9893bca243SGustavo Padovan struct exynos_drm_crtc *crtc; 997ee14cdcSGustavo Padovan struct exynos_drm_plane planes[MIXER_WIN_NR]; 100a44652e8SAndrzej Hajda unsigned long flags; 10122b21ae6SJoonyoung Shim 102524c59f1SAndrzej Hajda int irq; 103524c59f1SAndrzej Hajda void __iomem *mixer_regs; 104524c59f1SAndrzej Hajda void __iomem *vp_regs; 105524c59f1SAndrzej Hajda spinlock_t reg_slock; 106524c59f1SAndrzej Hajda struct clk *mixer; 107524c59f1SAndrzej Hajda struct clk *vp; 108524c59f1SAndrzej Hajda struct clk *hdmi; 109524c59f1SAndrzej Hajda struct clk *sclk_mixer; 110524c59f1SAndrzej Hajda struct clk *sclk_hdmi; 111524c59f1SAndrzej Hajda struct clk *mout_mixer; 1121e123441SRahul Sharma enum mixer_version_id mxr_ver; 113acc8bf04SAndrzej Hajda int scan_value; 1141e123441SRahul Sharma }; 1151e123441SRahul Sharma 1161e123441SRahul Sharma struct mixer_drv_data { 1171e123441SRahul Sharma enum mixer_version_id version; 1181b8e5747SRahul Sharma bool is_vp_enabled; 119ff830c96SMarek Szyprowski bool has_sclk; 12022b21ae6SJoonyoung Shim }; 12122b21ae6SJoonyoung Shim 122fd2d2fc2SMarek Szyprowski static const struct exynos_drm_plane_config plane_configs[MIXER_WIN_NR] = { 123fd2d2fc2SMarek Szyprowski { 124fd2d2fc2SMarek Szyprowski .zpos = 0, 125fd2d2fc2SMarek Szyprowski .type = DRM_PLANE_TYPE_PRIMARY, 126fd2d2fc2SMarek Szyprowski .pixel_formats = mixer_formats, 127fd2d2fc2SMarek Szyprowski .num_pixel_formats = ARRAY_SIZE(mixer_formats), 128a2cb911eSMarek Szyprowski .capabilities = EXYNOS_DRM_PLANE_CAP_DOUBLE | 129482582c0SChristoph Manszewski EXYNOS_DRM_PLANE_CAP_ZPOS | 1306ac99a32SChristoph Manszewski EXYNOS_DRM_PLANE_CAP_PIX_BLEND | 1316ac99a32SChristoph Manszewski EXYNOS_DRM_PLANE_CAP_WIN_BLEND, 132fd2d2fc2SMarek Szyprowski }, { 133fd2d2fc2SMarek Szyprowski .zpos = 1, 134fd2d2fc2SMarek Szyprowski .type = DRM_PLANE_TYPE_CURSOR, 135fd2d2fc2SMarek Szyprowski .pixel_formats = mixer_formats, 136fd2d2fc2SMarek Szyprowski .num_pixel_formats = ARRAY_SIZE(mixer_formats), 137a2cb911eSMarek Szyprowski .capabilities = EXYNOS_DRM_PLANE_CAP_DOUBLE | 138482582c0SChristoph Manszewski EXYNOS_DRM_PLANE_CAP_ZPOS | 1396ac99a32SChristoph Manszewski EXYNOS_DRM_PLANE_CAP_PIX_BLEND | 1406ac99a32SChristoph Manszewski EXYNOS_DRM_PLANE_CAP_WIN_BLEND, 141fd2d2fc2SMarek Szyprowski }, { 142fd2d2fc2SMarek Szyprowski .zpos = 2, 143fd2d2fc2SMarek Szyprowski .type = DRM_PLANE_TYPE_OVERLAY, 144fd2d2fc2SMarek Szyprowski .pixel_formats = vp_formats, 145fd2d2fc2SMarek Szyprowski .num_pixel_formats = ARRAY_SIZE(vp_formats), 146a2cb911eSMarek Szyprowski .capabilities = EXYNOS_DRM_PLANE_CAP_SCALE | 147f40031c2STobias Jakobi EXYNOS_DRM_PLANE_CAP_ZPOS | 1486ac99a32SChristoph Manszewski EXYNOS_DRM_PLANE_CAP_TILE | 1496ac99a32SChristoph Manszewski EXYNOS_DRM_PLANE_CAP_WIN_BLEND, 150fd2d2fc2SMarek Szyprowski }, 151fd2d2fc2SMarek Szyprowski }; 152fd2d2fc2SMarek Szyprowski 153d8408326SSeung-Woo Kim static const u8 filter_y_horiz_tap8[] = { 154d8408326SSeung-Woo Kim 0, -1, -1, -1, -1, -1, -1, -1, 155d8408326SSeung-Woo Kim -1, -1, -1, -1, -1, 0, 0, 0, 156d8408326SSeung-Woo Kim 0, 2, 4, 5, 6, 6, 6, 6, 157d8408326SSeung-Woo Kim 6, 5, 5, 4, 3, 2, 1, 1, 158d8408326SSeung-Woo Kim 0, -6, -12, -16, -18, -20, -21, -20, 159d8408326SSeung-Woo Kim -20, -18, -16, -13, -10, -8, -5, -2, 160d8408326SSeung-Woo Kim 127, 126, 125, 121, 114, 107, 99, 89, 161d8408326SSeung-Woo Kim 79, 68, 57, 46, 35, 25, 16, 8, 162d8408326SSeung-Woo Kim }; 163d8408326SSeung-Woo Kim 164d8408326SSeung-Woo Kim static const u8 filter_y_vert_tap4[] = { 165d8408326SSeung-Woo Kim 0, -3, -6, -8, -8, -8, -8, -7, 166d8408326SSeung-Woo Kim -6, -5, -4, -3, -2, -1, -1, 0, 167d8408326SSeung-Woo Kim 127, 126, 124, 118, 111, 102, 92, 81, 168d8408326SSeung-Woo Kim 70, 59, 48, 37, 27, 19, 11, 5, 169d8408326SSeung-Woo Kim 0, 5, 11, 19, 27, 37, 48, 59, 170d8408326SSeung-Woo Kim 70, 81, 92, 102, 111, 118, 124, 126, 171d8408326SSeung-Woo Kim 0, 0, -1, -1, -2, -3, -4, -5, 172d8408326SSeung-Woo Kim -6, -7, -8, -8, -8, -8, -6, -3, 173d8408326SSeung-Woo Kim }; 174d8408326SSeung-Woo Kim 175d8408326SSeung-Woo Kim static const u8 filter_cr_horiz_tap4[] = { 176d8408326SSeung-Woo Kim 0, -3, -6, -8, -8, -8, -8, -7, 177d8408326SSeung-Woo Kim -6, -5, -4, -3, -2, -1, -1, 0, 178d8408326SSeung-Woo Kim 127, 126, 124, 118, 111, 102, 92, 81, 179d8408326SSeung-Woo Kim 70, 59, 48, 37, 27, 19, 11, 5, 180d8408326SSeung-Woo Kim }; 181d8408326SSeung-Woo Kim 182524c59f1SAndrzej Hajda static inline u32 vp_reg_read(struct mixer_context *ctx, u32 reg_id) 183d8408326SSeung-Woo Kim { 184524c59f1SAndrzej Hajda return readl(ctx->vp_regs + reg_id); 185d8408326SSeung-Woo Kim } 186d8408326SSeung-Woo Kim 187524c59f1SAndrzej Hajda static inline void vp_reg_write(struct mixer_context *ctx, u32 reg_id, 188d8408326SSeung-Woo Kim u32 val) 189d8408326SSeung-Woo Kim { 190524c59f1SAndrzej Hajda writel(val, ctx->vp_regs + reg_id); 191d8408326SSeung-Woo Kim } 192d8408326SSeung-Woo Kim 193524c59f1SAndrzej Hajda static inline void vp_reg_writemask(struct mixer_context *ctx, u32 reg_id, 194d8408326SSeung-Woo Kim u32 val, u32 mask) 195d8408326SSeung-Woo Kim { 196524c59f1SAndrzej Hajda u32 old = vp_reg_read(ctx, reg_id); 197d8408326SSeung-Woo Kim 198d8408326SSeung-Woo Kim val = (val & mask) | (old & ~mask); 199524c59f1SAndrzej Hajda writel(val, ctx->vp_regs + reg_id); 200d8408326SSeung-Woo Kim } 201d8408326SSeung-Woo Kim 202524c59f1SAndrzej Hajda static inline u32 mixer_reg_read(struct mixer_context *ctx, u32 reg_id) 203d8408326SSeung-Woo Kim { 204524c59f1SAndrzej Hajda return readl(ctx->mixer_regs + reg_id); 205d8408326SSeung-Woo Kim } 206d8408326SSeung-Woo Kim 207524c59f1SAndrzej Hajda static inline void mixer_reg_write(struct mixer_context *ctx, u32 reg_id, 208d8408326SSeung-Woo Kim u32 val) 209d8408326SSeung-Woo Kim { 210524c59f1SAndrzej Hajda writel(val, ctx->mixer_regs + reg_id); 211d8408326SSeung-Woo Kim } 212d8408326SSeung-Woo Kim 213524c59f1SAndrzej Hajda static inline void mixer_reg_writemask(struct mixer_context *ctx, 214d8408326SSeung-Woo Kim u32 reg_id, u32 val, u32 mask) 215d8408326SSeung-Woo Kim { 216524c59f1SAndrzej Hajda u32 old = mixer_reg_read(ctx, reg_id); 217d8408326SSeung-Woo Kim 218d8408326SSeung-Woo Kim val = (val & mask) | (old & ~mask); 219524c59f1SAndrzej Hajda writel(val, ctx->mixer_regs + reg_id); 220d8408326SSeung-Woo Kim } 221d8408326SSeung-Woo Kim 222d8408326SSeung-Woo Kim static void mixer_regs_dump(struct mixer_context *ctx) 223d8408326SSeung-Woo Kim { 224d8408326SSeung-Woo Kim #define DUMPREG(reg_id) \ 225d8408326SSeung-Woo Kim do { \ 2266be90056SInki Dae DRM_DEV_DEBUG_KMS(ctx->dev, #reg_id " = %08x\n", \ 227524c59f1SAndrzej Hajda (u32)readl(ctx->mixer_regs + reg_id)); \ 228d8408326SSeung-Woo Kim } while (0) 229d8408326SSeung-Woo Kim 230d8408326SSeung-Woo Kim DUMPREG(MXR_STATUS); 231d8408326SSeung-Woo Kim DUMPREG(MXR_CFG); 232d8408326SSeung-Woo Kim DUMPREG(MXR_INT_EN); 233d8408326SSeung-Woo Kim DUMPREG(MXR_INT_STATUS); 234d8408326SSeung-Woo Kim 235d8408326SSeung-Woo Kim DUMPREG(MXR_LAYER_CFG); 236d8408326SSeung-Woo Kim DUMPREG(MXR_VIDEO_CFG); 237d8408326SSeung-Woo Kim 238d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC0_CFG); 239d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC0_BASE); 240d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC0_SPAN); 241d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC0_WH); 242d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC0_SXY); 243d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC0_DXY); 244d8408326SSeung-Woo Kim 245d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC1_CFG); 246d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC1_BASE); 247d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC1_SPAN); 248d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC1_WH); 249d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC1_SXY); 250d8408326SSeung-Woo Kim DUMPREG(MXR_GRAPHIC1_DXY); 251d8408326SSeung-Woo Kim #undef DUMPREG 252d8408326SSeung-Woo Kim } 253d8408326SSeung-Woo Kim 254d8408326SSeung-Woo Kim static void vp_regs_dump(struct mixer_context *ctx) 255d8408326SSeung-Woo Kim { 256d8408326SSeung-Woo Kim #define DUMPREG(reg_id) \ 257d8408326SSeung-Woo Kim do { \ 2586be90056SInki Dae DRM_DEV_DEBUG_KMS(ctx->dev, #reg_id " = %08x\n", \ 259524c59f1SAndrzej Hajda (u32) readl(ctx->vp_regs + reg_id)); \ 260d8408326SSeung-Woo Kim } while (0) 261d8408326SSeung-Woo Kim 262d8408326SSeung-Woo Kim DUMPREG(VP_ENABLE); 263d8408326SSeung-Woo Kim DUMPREG(VP_SRESET); 264d8408326SSeung-Woo Kim DUMPREG(VP_SHADOW_UPDATE); 265d8408326SSeung-Woo Kim DUMPREG(VP_FIELD_ID); 266d8408326SSeung-Woo Kim DUMPREG(VP_MODE); 267d8408326SSeung-Woo Kim DUMPREG(VP_IMG_SIZE_Y); 268d8408326SSeung-Woo Kim DUMPREG(VP_IMG_SIZE_C); 269d8408326SSeung-Woo Kim DUMPREG(VP_PER_RATE_CTRL); 270d8408326SSeung-Woo Kim DUMPREG(VP_TOP_Y_PTR); 271d8408326SSeung-Woo Kim DUMPREG(VP_BOT_Y_PTR); 272d8408326SSeung-Woo Kim DUMPREG(VP_TOP_C_PTR); 273d8408326SSeung-Woo Kim DUMPREG(VP_BOT_C_PTR); 274d8408326SSeung-Woo Kim DUMPREG(VP_ENDIAN_MODE); 275d8408326SSeung-Woo Kim DUMPREG(VP_SRC_H_POSITION); 276d8408326SSeung-Woo Kim DUMPREG(VP_SRC_V_POSITION); 277d8408326SSeung-Woo Kim DUMPREG(VP_SRC_WIDTH); 278d8408326SSeung-Woo Kim DUMPREG(VP_SRC_HEIGHT); 279d8408326SSeung-Woo Kim DUMPREG(VP_DST_H_POSITION); 280d8408326SSeung-Woo Kim DUMPREG(VP_DST_V_POSITION); 281d8408326SSeung-Woo Kim DUMPREG(VP_DST_WIDTH); 282d8408326SSeung-Woo Kim DUMPREG(VP_DST_HEIGHT); 283d8408326SSeung-Woo Kim DUMPREG(VP_H_RATIO); 284d8408326SSeung-Woo Kim DUMPREG(VP_V_RATIO); 285d8408326SSeung-Woo Kim 286d8408326SSeung-Woo Kim #undef DUMPREG 287d8408326SSeung-Woo Kim } 288d8408326SSeung-Woo Kim 289524c59f1SAndrzej Hajda static inline void vp_filter_set(struct mixer_context *ctx, 290d8408326SSeung-Woo Kim int reg_id, const u8 *data, unsigned int size) 291d8408326SSeung-Woo Kim { 292d8408326SSeung-Woo Kim /* assure 4-byte align */ 293d8408326SSeung-Woo Kim BUG_ON(size & 3); 294d8408326SSeung-Woo Kim for (; size; size -= 4, reg_id += 4, data += 4) { 295d8408326SSeung-Woo Kim u32 val = (data[0] << 24) | (data[1] << 16) | 296d8408326SSeung-Woo Kim (data[2] << 8) | data[3]; 297524c59f1SAndrzej Hajda vp_reg_write(ctx, reg_id, val); 298d8408326SSeung-Woo Kim } 299d8408326SSeung-Woo Kim } 300d8408326SSeung-Woo Kim 301524c59f1SAndrzej Hajda static void vp_default_filter(struct mixer_context *ctx) 302d8408326SSeung-Woo Kim { 303524c59f1SAndrzej Hajda vp_filter_set(ctx, VP_POLY8_Y0_LL, 304e25e1b66SSachin Kamat filter_y_horiz_tap8, sizeof(filter_y_horiz_tap8)); 305524c59f1SAndrzej Hajda vp_filter_set(ctx, VP_POLY4_Y0_LL, 306e25e1b66SSachin Kamat filter_y_vert_tap4, sizeof(filter_y_vert_tap4)); 307524c59f1SAndrzej Hajda vp_filter_set(ctx, VP_POLY4_C0_LL, 308e25e1b66SSachin Kamat filter_cr_horiz_tap4, sizeof(filter_cr_horiz_tap4)); 309d8408326SSeung-Woo Kim } 310d8408326SSeung-Woo Kim 311f657a996SMarek Szyprowski static void mixer_cfg_gfx_blend(struct mixer_context *ctx, unsigned int win, 3126ac99a32SChristoph Manszewski unsigned int pixel_alpha, unsigned int alpha) 313f657a996SMarek Szyprowski { 3146ac99a32SChristoph Manszewski u32 win_alpha = alpha >> 8; 315f657a996SMarek Szyprowski u32 val; 316f657a996SMarek Szyprowski 317f657a996SMarek Szyprowski val = MXR_GRP_CFG_COLOR_KEY_DISABLE; /* no blank key */ 318482582c0SChristoph Manszewski switch (pixel_alpha) { 319482582c0SChristoph Manszewski case DRM_MODE_BLEND_PIXEL_NONE: 320482582c0SChristoph Manszewski break; 321482582c0SChristoph Manszewski case DRM_MODE_BLEND_COVERAGE: 322482582c0SChristoph Manszewski val |= MXR_GRP_CFG_PIXEL_BLEND_EN; 323482582c0SChristoph Manszewski break; 324482582c0SChristoph Manszewski case DRM_MODE_BLEND_PREMULTI: 325482582c0SChristoph Manszewski default: 326f657a996SMarek Szyprowski val |= MXR_GRP_CFG_BLEND_PRE_MUL; 327f657a996SMarek Szyprowski val |= MXR_GRP_CFG_PIXEL_BLEND_EN; 328482582c0SChristoph Manszewski break; 329f657a996SMarek Szyprowski } 3306ac99a32SChristoph Manszewski 3316ac99a32SChristoph Manszewski if (alpha != DRM_BLEND_ALPHA_OPAQUE) { 3326ac99a32SChristoph Manszewski val |= MXR_GRP_CFG_WIN_BLEND_EN; 3336ac99a32SChristoph Manszewski val |= win_alpha; 3346ac99a32SChristoph Manszewski } 335524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_GRAPHIC_CFG(win), 336f657a996SMarek Szyprowski val, MXR_GRP_CFG_MISC_MASK); 337f657a996SMarek Szyprowski } 338f657a996SMarek Szyprowski 3396ac99a32SChristoph Manszewski static void mixer_cfg_vp_blend(struct mixer_context *ctx, unsigned int alpha) 340f657a996SMarek Szyprowski { 3416ac99a32SChristoph Manszewski u32 win_alpha = alpha >> 8; 3426ac99a32SChristoph Manszewski u32 val = 0; 343f657a996SMarek Szyprowski 3446ac99a32SChristoph Manszewski if (alpha != DRM_BLEND_ALPHA_OPAQUE) { 3456ac99a32SChristoph Manszewski val |= MXR_VID_CFG_BLEND_EN; 3466ac99a32SChristoph Manszewski val |= win_alpha; 3476ac99a32SChristoph Manszewski } 348524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_VIDEO_CFG, val); 349f657a996SMarek Szyprowski } 350f657a996SMarek Szyprowski 3516a3b45adSAndrzej Hajda static bool mixer_is_synced(struct mixer_context *ctx) 352d8408326SSeung-Woo Kim { 3536a3b45adSAndrzej Hajda u32 base, shadow; 354d8408326SSeung-Woo Kim 3556a3b45adSAndrzej Hajda if (ctx->mxr_ver == MXR_VER_16_0_33_0 || 3566a3b45adSAndrzej Hajda ctx->mxr_ver == MXR_VER_128_0_0_184) 3576a3b45adSAndrzej Hajda return !(mixer_reg_read(ctx, MXR_CFG) & 3586a3b45adSAndrzej Hajda MXR_CFG_LAYER_UPDATE_COUNT_MASK); 3596a3b45adSAndrzej Hajda 3606a3b45adSAndrzej Hajda if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags) && 3616a3b45adSAndrzej Hajda vp_reg_read(ctx, VP_SHADOW_UPDATE)) 3626a3b45adSAndrzej Hajda return false; 3636a3b45adSAndrzej Hajda 3646a3b45adSAndrzej Hajda base = mixer_reg_read(ctx, MXR_CFG); 3656a3b45adSAndrzej Hajda shadow = mixer_reg_read(ctx, MXR_CFG_S); 3666a3b45adSAndrzej Hajda if (base != shadow) 3676a3b45adSAndrzej Hajda return false; 3686a3b45adSAndrzej Hajda 3696a3b45adSAndrzej Hajda base = mixer_reg_read(ctx, MXR_GRAPHIC_BASE(0)); 3706a3b45adSAndrzej Hajda shadow = mixer_reg_read(ctx, MXR_GRAPHIC_BASE_S(0)); 3716a3b45adSAndrzej Hajda if (base != shadow) 3726a3b45adSAndrzej Hajda return false; 3736a3b45adSAndrzej Hajda 3746a3b45adSAndrzej Hajda base = mixer_reg_read(ctx, MXR_GRAPHIC_BASE(1)); 3756a3b45adSAndrzej Hajda shadow = mixer_reg_read(ctx, MXR_GRAPHIC_BASE_S(1)); 3766a3b45adSAndrzej Hajda if (base != shadow) 3776a3b45adSAndrzej Hajda return false; 3786a3b45adSAndrzej Hajda 3796a3b45adSAndrzej Hajda return true; 3806a3b45adSAndrzej Hajda } 3816a3b45adSAndrzej Hajda 3826a3b45adSAndrzej Hajda static int mixer_wait_for_sync(struct mixer_context *ctx) 3836a3b45adSAndrzej Hajda { 3846a3b45adSAndrzej Hajda ktime_t timeout = ktime_add_us(ktime_get(), 100000); 3856a3b45adSAndrzej Hajda 3866a3b45adSAndrzej Hajda while (!mixer_is_synced(ctx)) { 3876a3b45adSAndrzej Hajda usleep_range(1000, 2000); 3886a3b45adSAndrzej Hajda if (ktime_compare(ktime_get(), timeout) > 0) 3896a3b45adSAndrzej Hajda return -ETIMEDOUT; 3906a3b45adSAndrzej Hajda } 3916a3b45adSAndrzej Hajda return 0; 3926a3b45adSAndrzej Hajda } 3936a3b45adSAndrzej Hajda 3946a3b45adSAndrzej Hajda static void mixer_disable_sync(struct mixer_context *ctx) 3956a3b45adSAndrzej Hajda { 3966a3b45adSAndrzej Hajda mixer_reg_writemask(ctx, MXR_STATUS, 0, MXR_STATUS_SYNC_ENABLE); 3976a3b45adSAndrzej Hajda } 3986a3b45adSAndrzej Hajda 3996a3b45adSAndrzej Hajda static void mixer_enable_sync(struct mixer_context *ctx) 4006a3b45adSAndrzej Hajda { 4016a3b45adSAndrzej Hajda if (ctx->mxr_ver == MXR_VER_16_0_33_0 || 4026a3b45adSAndrzej Hajda ctx->mxr_ver == MXR_VER_128_0_0_184) 4036a3b45adSAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, ~0, MXR_CFG_LAYER_UPDATE); 4046a3b45adSAndrzej Hajda mixer_reg_writemask(ctx, MXR_STATUS, ~0, MXR_STATUS_SYNC_ENABLE); 405adeb6f44STobias Jakobi if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) 4066a3b45adSAndrzej Hajda vp_reg_write(ctx, VP_SHADOW_UPDATE, VP_SHADOW_UPDATE_ENABLE); 407d8408326SSeung-Woo Kim } 408d8408326SSeung-Woo Kim 4093fc40ca9SAndrzej Hajda static void mixer_cfg_scan(struct mixer_context *ctx, int width, int height) 410d8408326SSeung-Woo Kim { 411d8408326SSeung-Woo Kim u32 val; 412d8408326SSeung-Woo Kim 413d8408326SSeung-Woo Kim /* choosing between interlace and progressive mode */ 414adeb6f44STobias Jakobi val = test_bit(MXR_BIT_INTERLACE, &ctx->flags) ? 415adeb6f44STobias Jakobi MXR_CFG_SCAN_INTERLACE : MXR_CFG_SCAN_PROGRESSIVE; 416d8408326SSeung-Woo Kim 417acc8bf04SAndrzej Hajda if (ctx->mxr_ver == MXR_VER_128_0_0_184) 418524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_RESOLUTION, 4193fc40ca9SAndrzej Hajda MXR_MXR_RES_HEIGHT(height) | MXR_MXR_RES_WIDTH(width)); 420d8408326SSeung-Woo Kim else 421acc8bf04SAndrzej Hajda val |= ctx->scan_value; 422d8408326SSeung-Woo Kim 423524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, val, MXR_CFG_SCAN_MASK); 424d8408326SSeung-Woo Kim } 425d8408326SSeung-Woo Kim 42613e810f1SChristoph Manszewski static void mixer_cfg_rgb_fmt(struct mixer_context *ctx, struct drm_display_mode *mode) 427d8408326SSeung-Woo Kim { 42813e810f1SChristoph Manszewski enum hdmi_quantization_range range = drm_default_rgb_quant_range(mode); 429d8408326SSeung-Woo Kim u32 val; 430d8408326SSeung-Woo Kim 43113e810f1SChristoph Manszewski if (mode->vdisplay < 720) { 43213e810f1SChristoph Manszewski val = MXR_CFG_RGB601; 433e9e5ba93SChristoph Manszewski } else { 43413e810f1SChristoph Manszewski val = MXR_CFG_RGB709; 43513e810f1SChristoph Manszewski 4362a6e4cd5STobias Jakobi /* Configure the BT.709 CSC matrix for full range RGB. */ 437524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_CM_COEFF_Y, 4382a6e4cd5STobias Jakobi MXR_CSC_CT( 0.184, 0.614, 0.063) | 4392a6e4cd5STobias Jakobi MXR_CM_COEFF_RGB_FULL); 440524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_CM_COEFF_CB, 4412a6e4cd5STobias Jakobi MXR_CSC_CT(-0.102, -0.338, 0.440)); 442524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_CM_COEFF_CR, 4432a6e4cd5STobias Jakobi MXR_CSC_CT( 0.440, -0.399, -0.040)); 444d8408326SSeung-Woo Kim } 445d8408326SSeung-Woo Kim 44613e810f1SChristoph Manszewski if (range == HDMI_QUANTIZATION_RANGE_FULL) 44713e810f1SChristoph Manszewski val |= MXR_CFG_QUANT_RANGE_FULL; 44813e810f1SChristoph Manszewski else 44913e810f1SChristoph Manszewski val |= MXR_CFG_QUANT_RANGE_LIMITED; 45013e810f1SChristoph Manszewski 451524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, val, MXR_CFG_RGB_FMT_MASK); 452d8408326SSeung-Woo Kim } 453d8408326SSeung-Woo Kim 4545b1d5bc6STobias Jakobi static void mixer_cfg_layer(struct mixer_context *ctx, unsigned int win, 455a2cb911eSMarek Szyprowski unsigned int priority, bool enable) 456d8408326SSeung-Woo Kim { 457d8408326SSeung-Woo Kim u32 val = enable ? ~0 : 0; 458d8408326SSeung-Woo Kim 459d8408326SSeung-Woo Kim switch (win) { 460d8408326SSeung-Woo Kim case 0: 461524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, val, MXR_CFG_GRP0_ENABLE); 462524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_LAYER_CFG, 463a2cb911eSMarek Szyprowski MXR_LAYER_CFG_GRP0_VAL(priority), 464a2cb911eSMarek Szyprowski MXR_LAYER_CFG_GRP0_MASK); 465d8408326SSeung-Woo Kim break; 466d8408326SSeung-Woo Kim case 1: 467524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, val, MXR_CFG_GRP1_ENABLE); 468524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_LAYER_CFG, 469a2cb911eSMarek Szyprowski MXR_LAYER_CFG_GRP1_VAL(priority), 470a2cb911eSMarek Szyprowski MXR_LAYER_CFG_GRP1_MASK); 471adeb6f44STobias Jakobi 472d8408326SSeung-Woo Kim break; 4735e68fef2SMarek Szyprowski case VP_DEFAULT_WIN: 474adeb6f44STobias Jakobi if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) { 475524c59f1SAndrzej Hajda vp_reg_writemask(ctx, VP_ENABLE, val, VP_ENABLE_ON); 476524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, val, 4771b8e5747SRahul Sharma MXR_CFG_VP_ENABLE); 478524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_LAYER_CFG, 479a2cb911eSMarek Szyprowski MXR_LAYER_CFG_VP_VAL(priority), 480a2cb911eSMarek Szyprowski MXR_LAYER_CFG_VP_MASK); 4811b8e5747SRahul Sharma } 482d8408326SSeung-Woo Kim break; 483d8408326SSeung-Woo Kim } 484d8408326SSeung-Woo Kim } 485d8408326SSeung-Woo Kim 486d8408326SSeung-Woo Kim static void mixer_run(struct mixer_context *ctx) 487d8408326SSeung-Woo Kim { 488524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_STATUS, ~0, MXR_STATUS_REG_RUN); 489d8408326SSeung-Woo Kim } 490d8408326SSeung-Woo Kim 491381be025SRahul Sharma static void mixer_stop(struct mixer_context *ctx) 492381be025SRahul Sharma { 493381be025SRahul Sharma int timeout = 20; 494381be025SRahul Sharma 495524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_STATUS, 0, MXR_STATUS_REG_RUN); 496381be025SRahul Sharma 497524c59f1SAndrzej Hajda while (!(mixer_reg_read(ctx, MXR_STATUS) & MXR_STATUS_REG_IDLE) && 498381be025SRahul Sharma --timeout) 499381be025SRahul Sharma usleep_range(10000, 12000); 500381be025SRahul Sharma } 501381be025SRahul Sharma 502521d98a3SAndrzej Hajda static void mixer_commit(struct mixer_context *ctx) 503521d98a3SAndrzej Hajda { 504521d98a3SAndrzej Hajda struct drm_display_mode *mode = &ctx->crtc->base.state->adjusted_mode; 505521d98a3SAndrzej Hajda 5063fc40ca9SAndrzej Hajda mixer_cfg_scan(ctx, mode->hdisplay, mode->vdisplay); 50713e810f1SChristoph Manszewski mixer_cfg_rgb_fmt(ctx, mode); 508521d98a3SAndrzej Hajda mixer_run(ctx); 509521d98a3SAndrzej Hajda } 510521d98a3SAndrzej Hajda 5112eeb2e5eSGustavo Padovan static void vp_video_buffer(struct mixer_context *ctx, 5122eeb2e5eSGustavo Padovan struct exynos_drm_plane *plane) 513d8408326SSeung-Woo Kim { 5140114f404SMarek Szyprowski struct exynos_drm_plane_state *state = 5150114f404SMarek Szyprowski to_exynos_plane_state(plane->base.state); 5160114f404SMarek Szyprowski struct drm_framebuffer *fb = state->base.fb; 517e47726a1SMarek Szyprowski unsigned int priority = state->base.normalized_zpos + 1; 518d8408326SSeung-Woo Kim unsigned long flags; 519d8408326SSeung-Woo Kim dma_addr_t luma_addr[2], chroma_addr[2]; 5200f752694STobias Jakobi bool is_tiled, is_nv21; 521d8408326SSeung-Woo Kim u32 val; 522d8408326SSeung-Woo Kim 5230f752694STobias Jakobi is_nv21 = (fb->format->format == DRM_FORMAT_NV21); 5240f752694STobias Jakobi is_tiled = (fb->modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE); 525f40031c2STobias Jakobi 5260488f50eSMarek Szyprowski luma_addr[0] = exynos_drm_fb_dma_addr(fb, 0); 5270488f50eSMarek Szyprowski chroma_addr[0] = exynos_drm_fb_dma_addr(fb, 1); 528d8408326SSeung-Woo Kim 52971469944SAndrzej Hajda if (test_bit(MXR_BIT_INTERLACE, &ctx->flags)) { 5300f752694STobias Jakobi if (is_tiled) { 531d8408326SSeung-Woo Kim luma_addr[1] = luma_addr[0] + 0x40; 532d8408326SSeung-Woo Kim chroma_addr[1] = chroma_addr[0] + 0x40; 533d8408326SSeung-Woo Kim } else { 5342eeb2e5eSGustavo Padovan luma_addr[1] = luma_addr[0] + fb->pitches[0]; 5350ccc1c8fSTobias Jakobi chroma_addr[1] = chroma_addr[0] + fb->pitches[1]; 536d8408326SSeung-Woo Kim } 537d8408326SSeung-Woo Kim } else { 538d8408326SSeung-Woo Kim luma_addr[1] = 0; 539d8408326SSeung-Woo Kim chroma_addr[1] = 0; 540d8408326SSeung-Woo Kim } 541d8408326SSeung-Woo Kim 542524c59f1SAndrzej Hajda spin_lock_irqsave(&ctx->reg_slock, flags); 543d8408326SSeung-Woo Kim 544d8408326SSeung-Woo Kim /* interlace or progressive scan mode */ 545adeb6f44STobias Jakobi val = (test_bit(MXR_BIT_INTERLACE, &ctx->flags) ? ~0 : 0); 546524c59f1SAndrzej Hajda vp_reg_writemask(ctx, VP_MODE, val, VP_MODE_LINE_SKIP); 547d8408326SSeung-Woo Kim 548d8408326SSeung-Woo Kim /* setup format */ 5490f752694STobias Jakobi val = (is_nv21 ? VP_MODE_NV21 : VP_MODE_NV12); 5500f752694STobias Jakobi val |= (is_tiled ? VP_MODE_MEM_TILED : VP_MODE_MEM_LINEAR); 551524c59f1SAndrzej Hajda vp_reg_writemask(ctx, VP_MODE, val, VP_MODE_FMT_MASK); 552d8408326SSeung-Woo Kim 553d8408326SSeung-Woo Kim /* setting size of input image */ 554524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_IMG_SIZE_Y, VP_IMG_HSIZE(fb->pitches[0]) | 5552eeb2e5eSGustavo Padovan VP_IMG_VSIZE(fb->height)); 556dc500cfbSTobias Jakobi /* chroma plane for NV12/NV21 is half the height of the luma plane */ 5570ccc1c8fSTobias Jakobi vp_reg_write(ctx, VP_IMG_SIZE_C, VP_IMG_HSIZE(fb->pitches[1]) | 5582eeb2e5eSGustavo Padovan VP_IMG_VSIZE(fb->height / 2)); 559d8408326SSeung-Woo Kim 560524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_SRC_WIDTH, state->src.w); 561524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_SRC_H_POSITION, 5620114f404SMarek Szyprowski VP_SRC_H_POSITION_VAL(state->src.x)); 563524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_DST_WIDTH, state->crtc.w); 564524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_DST_H_POSITION, state->crtc.x); 5650ccc1c8fSTobias Jakobi 566adeb6f44STobias Jakobi if (test_bit(MXR_BIT_INTERLACE, &ctx->flags)) { 5670ccc1c8fSTobias Jakobi vp_reg_write(ctx, VP_SRC_HEIGHT, state->src.h / 2); 5680ccc1c8fSTobias Jakobi vp_reg_write(ctx, VP_SRC_V_POSITION, state->src.y / 2); 569524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_DST_HEIGHT, state->crtc.h / 2); 570524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_DST_V_POSITION, state->crtc.y / 2); 571d8408326SSeung-Woo Kim } else { 5720ccc1c8fSTobias Jakobi vp_reg_write(ctx, VP_SRC_HEIGHT, state->src.h); 5730ccc1c8fSTobias Jakobi vp_reg_write(ctx, VP_SRC_V_POSITION, state->src.y); 574524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_DST_HEIGHT, state->crtc.h); 575524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_DST_V_POSITION, state->crtc.y); 576d8408326SSeung-Woo Kim } 577d8408326SSeung-Woo Kim 578524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_H_RATIO, state->h_ratio); 579524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_V_RATIO, state->v_ratio); 580d8408326SSeung-Woo Kim 581524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_ENDIAN_MODE, VP_ENDIAN_MODE_LITTLE); 582d8408326SSeung-Woo Kim 583d8408326SSeung-Woo Kim /* set buffer address to vp */ 584524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_TOP_Y_PTR, luma_addr[0]); 585524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_BOT_Y_PTR, luma_addr[1]); 586524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_TOP_C_PTR, chroma_addr[0]); 587524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_BOT_C_PTR, chroma_addr[1]); 588d8408326SSeung-Woo Kim 589e47726a1SMarek Szyprowski mixer_cfg_layer(ctx, plane->index, priority, true); 5906ac99a32SChristoph Manszewski mixer_cfg_vp_blend(ctx, state->base.alpha); 591d8408326SSeung-Woo Kim 592524c59f1SAndrzej Hajda spin_unlock_irqrestore(&ctx->reg_slock, flags); 593d8408326SSeung-Woo Kim 594c0734fbaSTobias Jakobi mixer_regs_dump(ctx); 595d8408326SSeung-Woo Kim vp_regs_dump(ctx); 596d8408326SSeung-Woo Kim } 597d8408326SSeung-Woo Kim 5982eeb2e5eSGustavo Padovan static void mixer_graph_buffer(struct mixer_context *ctx, 5992eeb2e5eSGustavo Padovan struct exynos_drm_plane *plane) 600d8408326SSeung-Woo Kim { 6010114f404SMarek Szyprowski struct exynos_drm_plane_state *state = 6020114f404SMarek Szyprowski to_exynos_plane_state(plane->base.state); 6030114f404SMarek Szyprowski struct drm_framebuffer *fb = state->base.fb; 604e47726a1SMarek Szyprowski unsigned int priority = state->base.normalized_zpos + 1; 605d8408326SSeung-Woo Kim unsigned long flags; 60640bdfb0aSMarek Szyprowski unsigned int win = plane->index; 6072611015cSTobias Jakobi unsigned int x_ratio = 0, y_ratio = 0; 6085dff6905STobias Jakobi unsigned int dst_x_offset, dst_y_offset; 609482582c0SChristoph Manszewski unsigned int pixel_alpha; 610d8408326SSeung-Woo Kim dma_addr_t dma_addr; 611d8408326SSeung-Woo Kim unsigned int fmt; 612d8408326SSeung-Woo Kim u32 val; 613d8408326SSeung-Woo Kim 614482582c0SChristoph Manszewski if (fb->format->has_alpha) 615482582c0SChristoph Manszewski pixel_alpha = state->base.pixel_blend_mode; 616482582c0SChristoph Manszewski else 617482582c0SChristoph Manszewski pixel_alpha = DRM_MODE_BLEND_PIXEL_NONE; 618482582c0SChristoph Manszewski 619438b74a5SVille Syrjälä switch (fb->format->format) { 6207a57ca7cSTobias Jakobi case DRM_FORMAT_XRGB4444: 62126a7af3eSTobias Jakobi case DRM_FORMAT_ARGB4444: 6227a57ca7cSTobias Jakobi fmt = MXR_FORMAT_ARGB4444; 6237a57ca7cSTobias Jakobi break; 624d8408326SSeung-Woo Kim 6257a57ca7cSTobias Jakobi case DRM_FORMAT_XRGB1555: 62626a7af3eSTobias Jakobi case DRM_FORMAT_ARGB1555: 6277a57ca7cSTobias Jakobi fmt = MXR_FORMAT_ARGB1555; 628d8408326SSeung-Woo Kim break; 6297a57ca7cSTobias Jakobi 6307a57ca7cSTobias Jakobi case DRM_FORMAT_RGB565: 6317a57ca7cSTobias Jakobi fmt = MXR_FORMAT_RGB565; 632d8408326SSeung-Woo Kim break; 6337a57ca7cSTobias Jakobi 6347a57ca7cSTobias Jakobi case DRM_FORMAT_XRGB8888: 6357a57ca7cSTobias Jakobi case DRM_FORMAT_ARGB8888: 6361e60d62fSTobias Jakobi default: 6377a57ca7cSTobias Jakobi fmt = MXR_FORMAT_ARGB8888; 6387a57ca7cSTobias Jakobi break; 639d8408326SSeung-Woo Kim } 640d8408326SSeung-Woo Kim 641e463b069SMarek Szyprowski /* ratio is already checked by common plane code */ 642e463b069SMarek Szyprowski x_ratio = state->h_ratio == (1 << 15); 643e463b069SMarek Szyprowski y_ratio = state->v_ratio == (1 << 15); 644d8408326SSeung-Woo Kim 6450114f404SMarek Szyprowski dst_x_offset = state->crtc.x; 6460114f404SMarek Szyprowski dst_y_offset = state->crtc.y; 647d8408326SSeung-Woo Kim 6485dff6905STobias Jakobi /* translate dma address base s.t. the source image offset is zero */ 6490488f50eSMarek Szyprowski dma_addr = exynos_drm_fb_dma_addr(fb, 0) 650272725c7SVille Syrjälä + (state->src.x * fb->format->cpp[0]) 6510114f404SMarek Szyprowski + (state->src.y * fb->pitches[0]); 652d8408326SSeung-Woo Kim 653524c59f1SAndrzej Hajda spin_lock_irqsave(&ctx->reg_slock, flags); 654d8408326SSeung-Woo Kim 655d8408326SSeung-Woo Kim /* setup format */ 656524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_GRAPHIC_CFG(win), 657d8408326SSeung-Woo Kim MXR_GRP_CFG_FORMAT_VAL(fmt), MXR_GRP_CFG_FORMAT_MASK); 658d8408326SSeung-Woo Kim 659d8408326SSeung-Woo Kim /* setup geometry */ 660524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_GRAPHIC_SPAN(win), 661272725c7SVille Syrjälä fb->pitches[0] / fb->format->cpp[0]); 662d8408326SSeung-Woo Kim 6630114f404SMarek Szyprowski val = MXR_GRP_WH_WIDTH(state->src.w); 6640114f404SMarek Szyprowski val |= MXR_GRP_WH_HEIGHT(state->src.h); 665d8408326SSeung-Woo Kim val |= MXR_GRP_WH_H_SCALE(x_ratio); 666d8408326SSeung-Woo Kim val |= MXR_GRP_WH_V_SCALE(y_ratio); 667524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_GRAPHIC_WH(win), val); 668d8408326SSeung-Woo Kim 669d8408326SSeung-Woo Kim /* setup offsets in display image */ 670d8408326SSeung-Woo Kim val = MXR_GRP_DXY_DX(dst_x_offset); 671d8408326SSeung-Woo Kim val |= MXR_GRP_DXY_DY(dst_y_offset); 672524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_GRAPHIC_DXY(win), val); 673d8408326SSeung-Woo Kim 674d8408326SSeung-Woo Kim /* set buffer address to mixer */ 675524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_GRAPHIC_BASE(win), dma_addr); 676d8408326SSeung-Woo Kim 677e47726a1SMarek Szyprowski mixer_cfg_layer(ctx, win, priority, true); 6786ac99a32SChristoph Manszewski mixer_cfg_gfx_blend(ctx, win, pixel_alpha, state->base.alpha); 679aaf8b49eSRahul Sharma 680524c59f1SAndrzej Hajda spin_unlock_irqrestore(&ctx->reg_slock, flags); 681c0734fbaSTobias Jakobi 682c0734fbaSTobias Jakobi mixer_regs_dump(ctx); 683d8408326SSeung-Woo Kim } 684d8408326SSeung-Woo Kim 685d8408326SSeung-Woo Kim static void vp_win_reset(struct mixer_context *ctx) 686d8408326SSeung-Woo Kim { 687a696394cSTobias Jakobi unsigned int tries = 100; 688d8408326SSeung-Woo Kim 689524c59f1SAndrzej Hajda vp_reg_write(ctx, VP_SRESET, VP_SRESET_PROCESSING); 6908646dcb8SDan Carpenter while (--tries) { 691d8408326SSeung-Woo Kim /* waiting until VP_SRESET_PROCESSING is 0 */ 692524c59f1SAndrzej Hajda if (~vp_reg_read(ctx, VP_SRESET) & VP_SRESET_PROCESSING) 693d8408326SSeung-Woo Kim break; 69402b3de43STomasz Stanislawski mdelay(10); 695d8408326SSeung-Woo Kim } 696d8408326SSeung-Woo Kim WARN(tries == 0, "failed to reset Video Processor\n"); 697d8408326SSeung-Woo Kim } 698d8408326SSeung-Woo Kim 699cf8fc4f1SJoonyoung Shim static void mixer_win_reset(struct mixer_context *ctx) 700cf8fc4f1SJoonyoung Shim { 701cf8fc4f1SJoonyoung Shim unsigned long flags; 702cf8fc4f1SJoonyoung Shim 703524c59f1SAndrzej Hajda spin_lock_irqsave(&ctx->reg_slock, flags); 704cf8fc4f1SJoonyoung Shim 705524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, MXR_CFG_DST_HDMI, MXR_CFG_DST_MASK); 706cf8fc4f1SJoonyoung Shim 707cf8fc4f1SJoonyoung Shim /* set output in RGB888 mode */ 708524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, MXR_CFG_OUT_RGB888, MXR_CFG_OUT_MASK); 709cf8fc4f1SJoonyoung Shim 710cf8fc4f1SJoonyoung Shim /* 16 beat burst in DMA */ 711524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_STATUS, MXR_STATUS_16_BURST, 712cf8fc4f1SJoonyoung Shim MXR_STATUS_BURST_MASK); 713cf8fc4f1SJoonyoung Shim 714a2cb911eSMarek Szyprowski /* reset default layer priority */ 715524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_LAYER_CFG, 0); 716cf8fc4f1SJoonyoung Shim 7172a6e4cd5STobias Jakobi /* set all background colors to RGB (0,0,0) */ 718524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_BG_COLOR0, MXR_YCBCR_VAL(0, 128, 128)); 719524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_BG_COLOR1, MXR_YCBCR_VAL(0, 128, 128)); 720524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_BG_COLOR2, MXR_YCBCR_VAL(0, 128, 128)); 721cf8fc4f1SJoonyoung Shim 722adeb6f44STobias Jakobi if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) { 723cf8fc4f1SJoonyoung Shim /* configuration of Video Processor Registers */ 724cf8fc4f1SJoonyoung Shim vp_win_reset(ctx); 725524c59f1SAndrzej Hajda vp_default_filter(ctx); 7261b8e5747SRahul Sharma } 727cf8fc4f1SJoonyoung Shim 728cf8fc4f1SJoonyoung Shim /* disable all layers */ 729524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, 0, MXR_CFG_GRP0_ENABLE); 730524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, 0, MXR_CFG_GRP1_ENABLE); 731adeb6f44STobias Jakobi if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) 732524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_CFG, 0, MXR_CFG_VP_ENABLE); 733cf8fc4f1SJoonyoung Shim 7345dff6905STobias Jakobi /* set all source image offsets to zero */ 735524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_GRAPHIC_SXY(0), 0); 736524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_GRAPHIC_SXY(1), 0); 7375dff6905STobias Jakobi 738524c59f1SAndrzej Hajda spin_unlock_irqrestore(&ctx->reg_slock, flags); 739cf8fc4f1SJoonyoung Shim } 740cf8fc4f1SJoonyoung Shim 7414551789fSSean Paul static irqreturn_t mixer_irq_handler(int irq, void *arg) 7424551789fSSean Paul { 7434551789fSSean Paul struct mixer_context *ctx = arg; 7446a3b45adSAndrzej Hajda u32 val; 7454551789fSSean Paul 746524c59f1SAndrzej Hajda spin_lock(&ctx->reg_slock); 7474551789fSSean Paul 7484551789fSSean Paul /* read interrupt status for handling and clearing flags for VSYNC */ 749524c59f1SAndrzej Hajda val = mixer_reg_read(ctx, MXR_INT_STATUS); 7504551789fSSean Paul 7514551789fSSean Paul /* handling VSYNC */ 7524551789fSSean Paul if (val & MXR_INT_STATUS_VSYNC) { 75381a464dfSAndrzej Hajda /* vsync interrupt use different bit for read and clear */ 75481a464dfSAndrzej Hajda val |= MXR_INT_CLEAR_VSYNC; 75581a464dfSAndrzej Hajda val &= ~MXR_INT_STATUS_VSYNC; 75681a464dfSAndrzej Hajda 7574551789fSSean Paul /* interlace scan need to check shadow register */ 7586a3b45adSAndrzej Hajda if (test_bit(MXR_BIT_INTERLACE, &ctx->flags) 7596a3b45adSAndrzej Hajda && !mixer_is_synced(ctx)) 7602eced8e9SAndrzej Hajda goto out; 7612eced8e9SAndrzej Hajda 762eafd540aSGustavo Padovan drm_crtc_handle_vblank(&ctx->crtc->base); 7634551789fSSean Paul } 7644551789fSSean Paul 7654551789fSSean Paul out: 7664551789fSSean Paul /* clear interrupts */ 767524c59f1SAndrzej Hajda mixer_reg_write(ctx, MXR_INT_STATUS, val); 7684551789fSSean Paul 769524c59f1SAndrzej Hajda spin_unlock(&ctx->reg_slock); 7704551789fSSean Paul 7714551789fSSean Paul return IRQ_HANDLED; 7724551789fSSean Paul } 7734551789fSSean Paul 7744551789fSSean Paul static int mixer_resources_init(struct mixer_context *mixer_ctx) 7754551789fSSean Paul { 7764551789fSSean Paul struct device *dev = &mixer_ctx->pdev->dev; 7774551789fSSean Paul struct resource *res; 7784551789fSSean Paul int ret; 7794551789fSSean Paul 780524c59f1SAndrzej Hajda spin_lock_init(&mixer_ctx->reg_slock); 7814551789fSSean Paul 782524c59f1SAndrzej Hajda mixer_ctx->mixer = devm_clk_get(dev, "mixer"); 783524c59f1SAndrzej Hajda if (IS_ERR(mixer_ctx->mixer)) { 7844551789fSSean Paul dev_err(dev, "failed to get clock 'mixer'\n"); 7854551789fSSean Paul return -ENODEV; 7864551789fSSean Paul } 7874551789fSSean Paul 788524c59f1SAndrzej Hajda mixer_ctx->hdmi = devm_clk_get(dev, "hdmi"); 789524c59f1SAndrzej Hajda if (IS_ERR(mixer_ctx->hdmi)) { 79004427ec5SMarek Szyprowski dev_err(dev, "failed to get clock 'hdmi'\n"); 791524c59f1SAndrzej Hajda return PTR_ERR(mixer_ctx->hdmi); 79204427ec5SMarek Szyprowski } 79304427ec5SMarek Szyprowski 794524c59f1SAndrzej Hajda mixer_ctx->sclk_hdmi = devm_clk_get(dev, "sclk_hdmi"); 795524c59f1SAndrzej Hajda if (IS_ERR(mixer_ctx->sclk_hdmi)) { 7964551789fSSean Paul dev_err(dev, "failed to get clock 'sclk_hdmi'\n"); 7974551789fSSean Paul return -ENODEV; 7984551789fSSean Paul } 7994551789fSSean Paul res = platform_get_resource(mixer_ctx->pdev, IORESOURCE_MEM, 0); 8004551789fSSean Paul if (res == NULL) { 8014551789fSSean Paul dev_err(dev, "get memory resource failed.\n"); 8024551789fSSean Paul return -ENXIO; 8034551789fSSean Paul } 8044551789fSSean Paul 805524c59f1SAndrzej Hajda mixer_ctx->mixer_regs = devm_ioremap(dev, res->start, 8064551789fSSean Paul resource_size(res)); 807524c59f1SAndrzej Hajda if (mixer_ctx->mixer_regs == NULL) { 8084551789fSSean Paul dev_err(dev, "register mapping failed.\n"); 8094551789fSSean Paul return -ENXIO; 8104551789fSSean Paul } 8114551789fSSean Paul 8124551789fSSean Paul res = platform_get_resource(mixer_ctx->pdev, IORESOURCE_IRQ, 0); 8134551789fSSean Paul if (res == NULL) { 8144551789fSSean Paul dev_err(dev, "get interrupt resource failed.\n"); 8154551789fSSean Paul return -ENXIO; 8164551789fSSean Paul } 8174551789fSSean Paul 8184551789fSSean Paul ret = devm_request_irq(dev, res->start, mixer_irq_handler, 8194551789fSSean Paul 0, "drm_mixer", mixer_ctx); 8204551789fSSean Paul if (ret) { 8214551789fSSean Paul dev_err(dev, "request interrupt failed.\n"); 8224551789fSSean Paul return ret; 8234551789fSSean Paul } 824524c59f1SAndrzej Hajda mixer_ctx->irq = res->start; 8254551789fSSean Paul 8264551789fSSean Paul return 0; 8274551789fSSean Paul } 8284551789fSSean Paul 8294551789fSSean Paul static int vp_resources_init(struct mixer_context *mixer_ctx) 8304551789fSSean Paul { 8314551789fSSean Paul struct device *dev = &mixer_ctx->pdev->dev; 8324551789fSSean Paul struct resource *res; 8334551789fSSean Paul 834524c59f1SAndrzej Hajda mixer_ctx->vp = devm_clk_get(dev, "vp"); 835524c59f1SAndrzej Hajda if (IS_ERR(mixer_ctx->vp)) { 8364551789fSSean Paul dev_err(dev, "failed to get clock 'vp'\n"); 8374551789fSSean Paul return -ENODEV; 8384551789fSSean Paul } 839ff830c96SMarek Szyprowski 840adeb6f44STobias Jakobi if (test_bit(MXR_BIT_HAS_SCLK, &mixer_ctx->flags)) { 841524c59f1SAndrzej Hajda mixer_ctx->sclk_mixer = devm_clk_get(dev, "sclk_mixer"); 842524c59f1SAndrzej Hajda if (IS_ERR(mixer_ctx->sclk_mixer)) { 8434551789fSSean Paul dev_err(dev, "failed to get clock 'sclk_mixer'\n"); 8444551789fSSean Paul return -ENODEV; 8454551789fSSean Paul } 846524c59f1SAndrzej Hajda mixer_ctx->mout_mixer = devm_clk_get(dev, "mout_mixer"); 847524c59f1SAndrzej Hajda if (IS_ERR(mixer_ctx->mout_mixer)) { 848ff830c96SMarek Szyprowski dev_err(dev, "failed to get clock 'mout_mixer'\n"); 8494551789fSSean Paul return -ENODEV; 8504551789fSSean Paul } 8514551789fSSean Paul 852524c59f1SAndrzej Hajda if (mixer_ctx->sclk_hdmi && mixer_ctx->mout_mixer) 853524c59f1SAndrzej Hajda clk_set_parent(mixer_ctx->mout_mixer, 854524c59f1SAndrzej Hajda mixer_ctx->sclk_hdmi); 855ff830c96SMarek Szyprowski } 8564551789fSSean Paul 8574551789fSSean Paul res = platform_get_resource(mixer_ctx->pdev, IORESOURCE_MEM, 1); 8584551789fSSean Paul if (res == NULL) { 8594551789fSSean Paul dev_err(dev, "get memory resource failed.\n"); 8604551789fSSean Paul return -ENXIO; 8614551789fSSean Paul } 8624551789fSSean Paul 863524c59f1SAndrzej Hajda mixer_ctx->vp_regs = devm_ioremap(dev, res->start, 8644551789fSSean Paul resource_size(res)); 865524c59f1SAndrzej Hajda if (mixer_ctx->vp_regs == NULL) { 8664551789fSSean Paul dev_err(dev, "register mapping failed.\n"); 8674551789fSSean Paul return -ENXIO; 8684551789fSSean Paul } 8694551789fSSean Paul 8704551789fSSean Paul return 0; 8714551789fSSean Paul } 8724551789fSSean Paul 87393bca243SGustavo Padovan static int mixer_initialize(struct mixer_context *mixer_ctx, 874f37cd5e8SInki Dae struct drm_device *drm_dev) 8754551789fSSean Paul { 8764551789fSSean Paul int ret; 8774551789fSSean Paul 878eb88e422SGustavo Padovan mixer_ctx->drm_dev = drm_dev; 8794551789fSSean Paul 8804551789fSSean Paul /* acquire resources: regs, irqs, clocks */ 8814551789fSSean Paul ret = mixer_resources_init(mixer_ctx); 8824551789fSSean Paul if (ret) { 8836f83d208SInki Dae DRM_DEV_ERROR(mixer_ctx->dev, 8846f83d208SInki Dae "mixer_resources_init failed ret=%d\n", ret); 8854551789fSSean Paul return ret; 8864551789fSSean Paul } 8874551789fSSean Paul 888adeb6f44STobias Jakobi if (test_bit(MXR_BIT_VP_ENABLED, &mixer_ctx->flags)) { 8894551789fSSean Paul /* acquire vp resources: regs, irqs, clocks */ 8904551789fSSean Paul ret = vp_resources_init(mixer_ctx); 8914551789fSSean Paul if (ret) { 8926f83d208SInki Dae DRM_DEV_ERROR(mixer_ctx->dev, 8936f83d208SInki Dae "vp_resources_init failed ret=%d\n", ret); 8944551789fSSean Paul return ret; 8954551789fSSean Paul } 8964551789fSSean Paul } 8974551789fSSean Paul 898*07dc3678SMarek Szyprowski return exynos_drm_register_dma(drm_dev, mixer_ctx->dev, 899*07dc3678SMarek Szyprowski &mixer_ctx->dma_priv); 9001055b39fSInki Dae } 9011055b39fSInki Dae 90293bca243SGustavo Padovan static void mixer_ctx_remove(struct mixer_context *mixer_ctx) 903d8408326SSeung-Woo Kim { 904*07dc3678SMarek Szyprowski exynos_drm_unregister_dma(mixer_ctx->drm_dev, mixer_ctx->dev, 905*07dc3678SMarek Szyprowski &mixer_ctx->dma_priv); 906f041b257SSean Paul } 907f041b257SSean Paul 90893bca243SGustavo Padovan static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) 909f041b257SSean Paul { 91093bca243SGustavo Padovan struct mixer_context *mixer_ctx = crtc->ctx; 911d8408326SSeung-Woo Kim 9120df5e4acSAndrzej Hajda __set_bit(MXR_BIT_VSYNC, &mixer_ctx->flags); 9130df5e4acSAndrzej Hajda if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) 914f041b257SSean Paul return 0; 915d8408326SSeung-Woo Kim 916d8408326SSeung-Woo Kim /* enable vsync interrupt */ 917524c59f1SAndrzej Hajda mixer_reg_writemask(mixer_ctx, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC); 918524c59f1SAndrzej Hajda mixer_reg_writemask(mixer_ctx, MXR_INT_EN, ~0, MXR_INT_EN_VSYNC); 919d8408326SSeung-Woo Kim 920d8408326SSeung-Woo Kim return 0; 921d8408326SSeung-Woo Kim } 922d8408326SSeung-Woo Kim 92393bca243SGustavo Padovan static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) 924d8408326SSeung-Woo Kim { 92593bca243SGustavo Padovan struct mixer_context *mixer_ctx = crtc->ctx; 926d8408326SSeung-Woo Kim 9270df5e4acSAndrzej Hajda __clear_bit(MXR_BIT_VSYNC, &mixer_ctx->flags); 9280df5e4acSAndrzej Hajda 9290df5e4acSAndrzej Hajda if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) 930947710c6SAndrzej Hajda return; 931947710c6SAndrzej Hajda 932d8408326SSeung-Woo Kim /* disable vsync interrupt */ 933524c59f1SAndrzej Hajda mixer_reg_writemask(mixer_ctx, MXR_INT_STATUS, ~0, MXR_INT_CLEAR_VSYNC); 934524c59f1SAndrzej Hajda mixer_reg_writemask(mixer_ctx, MXR_INT_EN, 0, MXR_INT_EN_VSYNC); 935d8408326SSeung-Woo Kim } 936d8408326SSeung-Woo Kim 9373dbaab16SMarek Szyprowski static void mixer_atomic_begin(struct exynos_drm_crtc *crtc) 9383dbaab16SMarek Szyprowski { 9396a3b45adSAndrzej Hajda struct mixer_context *ctx = crtc->ctx; 9403dbaab16SMarek Szyprowski 9416a3b45adSAndrzej Hajda if (!test_bit(MXR_BIT_POWERED, &ctx->flags)) 9423dbaab16SMarek Szyprowski return; 9433dbaab16SMarek Szyprowski 9446a3b45adSAndrzej Hajda if (mixer_wait_for_sync(ctx)) 9456a3b45adSAndrzej Hajda dev_err(ctx->dev, "timeout waiting for VSYNC\n"); 9466a3b45adSAndrzej Hajda mixer_disable_sync(ctx); 9473dbaab16SMarek Szyprowski } 9483dbaab16SMarek Szyprowski 9491e1d1393SGustavo Padovan static void mixer_update_plane(struct exynos_drm_crtc *crtc, 9501e1d1393SGustavo Padovan struct exynos_drm_plane *plane) 951d8408326SSeung-Woo Kim { 95293bca243SGustavo Padovan struct mixer_context *mixer_ctx = crtc->ctx; 953d8408326SSeung-Woo Kim 9546be90056SInki Dae DRM_DEV_DEBUG_KMS(mixer_ctx->dev, "win: %d\n", plane->index); 955d8408326SSeung-Woo Kim 956a44652e8SAndrzej Hajda if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) 957dda9012bSShirish S return; 958dda9012bSShirish S 9595e68fef2SMarek Szyprowski if (plane->index == VP_DEFAULT_WIN) 9602eeb2e5eSGustavo Padovan vp_video_buffer(mixer_ctx, plane); 961d8408326SSeung-Woo Kim else 9622eeb2e5eSGustavo Padovan mixer_graph_buffer(mixer_ctx, plane); 963d8408326SSeung-Woo Kim } 964d8408326SSeung-Woo Kim 9651e1d1393SGustavo Padovan static void mixer_disable_plane(struct exynos_drm_crtc *crtc, 9661e1d1393SGustavo Padovan struct exynos_drm_plane *plane) 967d8408326SSeung-Woo Kim { 96893bca243SGustavo Padovan struct mixer_context *mixer_ctx = crtc->ctx; 969d8408326SSeung-Woo Kim unsigned long flags; 970d8408326SSeung-Woo Kim 9716be90056SInki Dae DRM_DEV_DEBUG_KMS(mixer_ctx->dev, "win: %d\n", plane->index); 972d8408326SSeung-Woo Kim 973a44652e8SAndrzej Hajda if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) 974db43fd16SPrathyush K return; 975db43fd16SPrathyush K 976524c59f1SAndrzej Hajda spin_lock_irqsave(&mixer_ctx->reg_slock, flags); 977a2cb911eSMarek Szyprowski mixer_cfg_layer(mixer_ctx, plane->index, 0, false); 978524c59f1SAndrzej Hajda spin_unlock_irqrestore(&mixer_ctx->reg_slock, flags); 9793dbaab16SMarek Szyprowski } 9803dbaab16SMarek Szyprowski 9813dbaab16SMarek Szyprowski static void mixer_atomic_flush(struct exynos_drm_crtc *crtc) 9823dbaab16SMarek Szyprowski { 9833dbaab16SMarek Szyprowski struct mixer_context *mixer_ctx = crtc->ctx; 9843dbaab16SMarek Szyprowski 9853dbaab16SMarek Szyprowski if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) 9863dbaab16SMarek Szyprowski return; 987d8408326SSeung-Woo Kim 9886a3b45adSAndrzej Hajda mixer_enable_sync(mixer_ctx); 989a392276dSAndrzej Hajda exynos_crtc_handle_event(crtc); 990d8408326SSeung-Woo Kim } 991d8408326SSeung-Woo Kim 99211f95489SInki Dae static void mixer_atomic_enable(struct exynos_drm_crtc *crtc) 993db43fd16SPrathyush K { 9943cecda03SGustavo Padovan struct mixer_context *ctx = crtc->ctx; 995db43fd16SPrathyush K 996a44652e8SAndrzej Hajda if (test_bit(MXR_BIT_POWERED, &ctx->flags)) 997db43fd16SPrathyush K return; 998db43fd16SPrathyush K 999af65c804SSean Paul pm_runtime_get_sync(ctx->dev); 1000af65c804SSean Paul 1001a121d179SAndrzej Hajda exynos_drm_pipe_clk_enable(crtc, true); 1002a121d179SAndrzej Hajda 10036a3b45adSAndrzej Hajda mixer_disable_sync(ctx); 10043dbaab16SMarek Szyprowski 1005524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_STATUS, ~0, MXR_STATUS_SOFT_RESET); 1006d74ed937SRahul Sharma 10070df5e4acSAndrzej Hajda if (test_bit(MXR_BIT_VSYNC, &ctx->flags)) { 1008524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_INT_STATUS, ~0, 1009524c59f1SAndrzej Hajda MXR_INT_CLEAR_VSYNC); 1010524c59f1SAndrzej Hajda mixer_reg_writemask(ctx, MXR_INT_EN, ~0, MXR_INT_EN_VSYNC); 10110df5e4acSAndrzej Hajda } 1012db43fd16SPrathyush K mixer_win_reset(ctx); 1013ccf034a9SGustavo Padovan 101471469944SAndrzej Hajda mixer_commit(ctx); 101571469944SAndrzej Hajda 10166a3b45adSAndrzej Hajda mixer_enable_sync(ctx); 10173dbaab16SMarek Szyprowski 1018ccf034a9SGustavo Padovan set_bit(MXR_BIT_POWERED, &ctx->flags); 1019db43fd16SPrathyush K } 1020db43fd16SPrathyush K 102111f95489SInki Dae static void mixer_atomic_disable(struct exynos_drm_crtc *crtc) 1022db43fd16SPrathyush K { 10233cecda03SGustavo Padovan struct mixer_context *ctx = crtc->ctx; 1024c329f667SJoonyoung Shim int i; 1025db43fd16SPrathyush K 1026a44652e8SAndrzej Hajda if (!test_bit(MXR_BIT_POWERED, &ctx->flags)) 1027b4bfa3c7SRahul Sharma return; 1028db43fd16SPrathyush K 1029381be025SRahul Sharma mixer_stop(ctx); 1030c0734fbaSTobias Jakobi mixer_regs_dump(ctx); 1031c329f667SJoonyoung Shim 1032c329f667SJoonyoung Shim for (i = 0; i < MIXER_WIN_NR; i++) 10331e1d1393SGustavo Padovan mixer_disable_plane(crtc, &ctx->planes[i]); 1034db43fd16SPrathyush K 1035a121d179SAndrzej Hajda exynos_drm_pipe_clk_enable(crtc, false); 1036a121d179SAndrzej Hajda 1037ccf034a9SGustavo Padovan pm_runtime_put(ctx->dev); 1038ccf034a9SGustavo Padovan 1039a44652e8SAndrzej Hajda clear_bit(MXR_BIT_POWERED, &ctx->flags); 1040db43fd16SPrathyush K } 1041db43fd16SPrathyush K 10426ace38a5SAndrzej Hajda static int mixer_mode_valid(struct exynos_drm_crtc *crtc, 10436ace38a5SAndrzej Hajda const struct drm_display_mode *mode) 1044f041b257SSean Paul { 10456ace38a5SAndrzej Hajda struct mixer_context *ctx = crtc->ctx; 10466ace38a5SAndrzej Hajda u32 w = mode->hdisplay, h = mode->vdisplay; 1047f041b257SSean Paul 10486be90056SInki Dae DRM_DEV_DEBUG_KMS(ctx->dev, "xres=%d, yres=%d, refresh=%d, intl=%d\n", 10496be90056SInki Dae w, h, mode->vrefresh, 10506be90056SInki Dae !!(mode->flags & DRM_MODE_FLAG_INTERLACE)); 1051f041b257SSean Paul 10526ace38a5SAndrzej Hajda if (ctx->mxr_ver == MXR_VER_128_0_0_184) 10536ace38a5SAndrzej Hajda return MODE_OK; 1054f041b257SSean Paul 1055f041b257SSean Paul if ((w >= 464 && w <= 720 && h >= 261 && h <= 576) || 1056f041b257SSean Paul (w >= 1024 && w <= 1280 && h >= 576 && h <= 720) || 1057f041b257SSean Paul (w >= 1664 && w <= 1920 && h >= 936 && h <= 1080)) 10586ace38a5SAndrzej Hajda return MODE_OK; 1059f041b257SSean Paul 1060ae58c03eSDaniel Drake if ((w == 1024 && h == 768) || 1061ae58c03eSDaniel Drake (w == 1366 && h == 768) || 1062ae58c03eSDaniel Drake (w == 1280 && h == 1024)) 10630900673eSAndrzej Hajda return MODE_OK; 10640900673eSAndrzej Hajda 10656ace38a5SAndrzej Hajda return MODE_BAD; 1066f041b257SSean Paul } 1067f041b257SSean Paul 1068acc8bf04SAndrzej Hajda static bool mixer_mode_fixup(struct exynos_drm_crtc *crtc, 1069acc8bf04SAndrzej Hajda const struct drm_display_mode *mode, 1070acc8bf04SAndrzej Hajda struct drm_display_mode *adjusted_mode) 1071acc8bf04SAndrzej Hajda { 1072acc8bf04SAndrzej Hajda struct mixer_context *ctx = crtc->ctx; 1073acc8bf04SAndrzej Hajda int width = mode->hdisplay, height = mode->vdisplay, i; 1074acc8bf04SAndrzej Hajda 10755a884be5SKrzysztof Wilczynski static const struct { 1076acc8bf04SAndrzej Hajda int hdisplay, vdisplay, htotal, vtotal, scan_val; 10775a884be5SKrzysztof Wilczynski } modes[] = { 1078acc8bf04SAndrzej Hajda { 720, 480, 858, 525, MXR_CFG_SCAN_NTSC | MXR_CFG_SCAN_SD }, 1079acc8bf04SAndrzej Hajda { 720, 576, 864, 625, MXR_CFG_SCAN_PAL | MXR_CFG_SCAN_SD }, 1080acc8bf04SAndrzej Hajda { 1280, 720, 1650, 750, MXR_CFG_SCAN_HD_720 | MXR_CFG_SCAN_HD }, 1081acc8bf04SAndrzej Hajda { 1920, 1080, 2200, 1125, MXR_CFG_SCAN_HD_1080 | 1082acc8bf04SAndrzej Hajda MXR_CFG_SCAN_HD } 1083acc8bf04SAndrzej Hajda }; 1084acc8bf04SAndrzej Hajda 1085acc8bf04SAndrzej Hajda if (mode->flags & DRM_MODE_FLAG_INTERLACE) 1086acc8bf04SAndrzej Hajda __set_bit(MXR_BIT_INTERLACE, &ctx->flags); 1087acc8bf04SAndrzej Hajda else 1088acc8bf04SAndrzej Hajda __clear_bit(MXR_BIT_INTERLACE, &ctx->flags); 1089acc8bf04SAndrzej Hajda 1090acc8bf04SAndrzej Hajda if (ctx->mxr_ver == MXR_VER_128_0_0_184) 1091acc8bf04SAndrzej Hajda return true; 1092acc8bf04SAndrzej Hajda 1093acc8bf04SAndrzej Hajda for (i = 0; i < ARRAY_SIZE(modes); ++i) 1094acc8bf04SAndrzej Hajda if (width <= modes[i].hdisplay && height <= modes[i].vdisplay) { 1095acc8bf04SAndrzej Hajda ctx->scan_value = modes[i].scan_val; 1096acc8bf04SAndrzej Hajda if (width < modes[i].hdisplay || 1097acc8bf04SAndrzej Hajda height < modes[i].vdisplay) { 1098acc8bf04SAndrzej Hajda adjusted_mode->hdisplay = modes[i].hdisplay; 1099acc8bf04SAndrzej Hajda adjusted_mode->hsync_start = modes[i].hdisplay; 1100acc8bf04SAndrzej Hajda adjusted_mode->hsync_end = modes[i].htotal; 1101acc8bf04SAndrzej Hajda adjusted_mode->htotal = modes[i].htotal; 1102acc8bf04SAndrzej Hajda adjusted_mode->vdisplay = modes[i].vdisplay; 1103acc8bf04SAndrzej Hajda adjusted_mode->vsync_start = modes[i].vdisplay; 1104acc8bf04SAndrzej Hajda adjusted_mode->vsync_end = modes[i].vtotal; 1105acc8bf04SAndrzej Hajda adjusted_mode->vtotal = modes[i].vtotal; 1106acc8bf04SAndrzej Hajda } 1107acc8bf04SAndrzej Hajda 1108acc8bf04SAndrzej Hajda return true; 1109acc8bf04SAndrzej Hajda } 1110acc8bf04SAndrzej Hajda 1111acc8bf04SAndrzej Hajda return false; 1112acc8bf04SAndrzej Hajda } 1113acc8bf04SAndrzej Hajda 1114f3aaf762SKrzysztof Kozlowski static const struct exynos_drm_crtc_ops mixer_crtc_ops = { 111511f95489SInki Dae .atomic_enable = mixer_atomic_enable, 111611f95489SInki Dae .atomic_disable = mixer_atomic_disable, 1117d8408326SSeung-Woo Kim .enable_vblank = mixer_enable_vblank, 1118d8408326SSeung-Woo Kim .disable_vblank = mixer_disable_vblank, 11193dbaab16SMarek Szyprowski .atomic_begin = mixer_atomic_begin, 11209cc7610aSGustavo Padovan .update_plane = mixer_update_plane, 11219cc7610aSGustavo Padovan .disable_plane = mixer_disable_plane, 11223dbaab16SMarek Szyprowski .atomic_flush = mixer_atomic_flush, 11236ace38a5SAndrzej Hajda .mode_valid = mixer_mode_valid, 1124acc8bf04SAndrzej Hajda .mode_fixup = mixer_mode_fixup, 1125f041b257SSean Paul }; 11260ea6822fSRahul Sharma 11275e6cc1c5SArvind Yadav static const struct mixer_drv_data exynos5420_mxr_drv_data = { 1128def5e095SRahul Sharma .version = MXR_VER_128_0_0_184, 1129def5e095SRahul Sharma .is_vp_enabled = 0, 1130def5e095SRahul Sharma }; 1131def5e095SRahul Sharma 11325e6cc1c5SArvind Yadav static const struct mixer_drv_data exynos5250_mxr_drv_data = { 1133aaf8b49eSRahul Sharma .version = MXR_VER_16_0_33_0, 1134aaf8b49eSRahul Sharma .is_vp_enabled = 0, 1135aaf8b49eSRahul Sharma }; 1136aaf8b49eSRahul Sharma 11375e6cc1c5SArvind Yadav static const struct mixer_drv_data exynos4212_mxr_drv_data = { 1138ff830c96SMarek Szyprowski .version = MXR_VER_0_0_0_16, 1139ff830c96SMarek Szyprowski .is_vp_enabled = 1, 1140ff830c96SMarek Szyprowski }; 1141ff830c96SMarek Szyprowski 11425e6cc1c5SArvind Yadav static const struct mixer_drv_data exynos4210_mxr_drv_data = { 11431e123441SRahul Sharma .version = MXR_VER_0_0_0_16, 11441b8e5747SRahul Sharma .is_vp_enabled = 1, 1145ff830c96SMarek Szyprowski .has_sclk = 1, 11461e123441SRahul Sharma }; 11471e123441SRahul Sharma 11485e6cc1c5SArvind Yadav static const struct of_device_id mixer_match_types[] = { 1149aaf8b49eSRahul Sharma { 1150ff830c96SMarek Szyprowski .compatible = "samsung,exynos4210-mixer", 1151ff830c96SMarek Szyprowski .data = &exynos4210_mxr_drv_data, 1152ff830c96SMarek Szyprowski }, { 1153ff830c96SMarek Szyprowski .compatible = "samsung,exynos4212-mixer", 1154ff830c96SMarek Szyprowski .data = &exynos4212_mxr_drv_data, 1155ff830c96SMarek Szyprowski }, { 1156aaf8b49eSRahul Sharma .compatible = "samsung,exynos5-mixer", 1157cc57caf0SRahul Sharma .data = &exynos5250_mxr_drv_data, 1158cc57caf0SRahul Sharma }, { 1159cc57caf0SRahul Sharma .compatible = "samsung,exynos5250-mixer", 1160cc57caf0SRahul Sharma .data = &exynos5250_mxr_drv_data, 1161aaf8b49eSRahul Sharma }, { 1162def5e095SRahul Sharma .compatible = "samsung,exynos5420-mixer", 1163def5e095SRahul Sharma .data = &exynos5420_mxr_drv_data, 1164def5e095SRahul Sharma }, { 11651e123441SRahul Sharma /* end node */ 11661e123441SRahul Sharma } 11671e123441SRahul Sharma }; 116839b58a39SSjoerd Simons MODULE_DEVICE_TABLE(of, mixer_match_types); 11691e123441SRahul Sharma 1170f37cd5e8SInki Dae static int mixer_bind(struct device *dev, struct device *manager, void *data) 1171d8408326SSeung-Woo Kim { 11728103ef1bSAndrzej Hajda struct mixer_context *ctx = dev_get_drvdata(dev); 1173f37cd5e8SInki Dae struct drm_device *drm_dev = data; 11747ee14cdcSGustavo Padovan struct exynos_drm_plane *exynos_plane; 1175fd2d2fc2SMarek Szyprowski unsigned int i; 11766e2a3b66SGustavo Padovan int ret; 1177d8408326SSeung-Woo Kim 1178e2dc3f72SAlban Browaeys ret = mixer_initialize(ctx, drm_dev); 1179e2dc3f72SAlban Browaeys if (ret) 1180e2dc3f72SAlban Browaeys return ret; 1181e2dc3f72SAlban Browaeys 1182fd2d2fc2SMarek Szyprowski for (i = 0; i < MIXER_WIN_NR; i++) { 1183adeb6f44STobias Jakobi if (i == VP_DEFAULT_WIN && !test_bit(MXR_BIT_VP_ENABLED, 1184adeb6f44STobias Jakobi &ctx->flags)) 1185ab144201SMarek Szyprowski continue; 1186ab144201SMarek Szyprowski 118740bdfb0aSMarek Szyprowski ret = exynos_plane_init(drm_dev, &ctx->planes[i], i, 11882c82607bSAndrzej Hajda &plane_configs[i]); 11897ee14cdcSGustavo Padovan if (ret) 11907ee14cdcSGustavo Padovan return ret; 11917ee14cdcSGustavo Padovan } 11927ee14cdcSGustavo Padovan 11935d3d0995SGustavo Padovan exynos_plane = &ctx->planes[DEFAULT_WIN]; 11947ee14cdcSGustavo Padovan ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base, 1195d644951cSAndrzej Hajda EXYNOS_DISPLAY_TYPE_HDMI, &mixer_crtc_ops, ctx); 119693bca243SGustavo Padovan if (IS_ERR(ctx->crtc)) { 1197e2dc3f72SAlban Browaeys mixer_ctx_remove(ctx); 119893bca243SGustavo Padovan ret = PTR_ERR(ctx->crtc); 119993bca243SGustavo Padovan goto free_ctx; 12008103ef1bSAndrzej Hajda } 12018103ef1bSAndrzej Hajda 12028103ef1bSAndrzej Hajda return 0; 120393bca243SGustavo Padovan 120493bca243SGustavo Padovan free_ctx: 120593bca243SGustavo Padovan devm_kfree(dev, ctx); 120693bca243SGustavo Padovan return ret; 12078103ef1bSAndrzej Hajda } 12088103ef1bSAndrzej Hajda 12098103ef1bSAndrzej Hajda static void mixer_unbind(struct device *dev, struct device *master, void *data) 12108103ef1bSAndrzej Hajda { 12118103ef1bSAndrzej Hajda struct mixer_context *ctx = dev_get_drvdata(dev); 12128103ef1bSAndrzej Hajda 121393bca243SGustavo Padovan mixer_ctx_remove(ctx); 12148103ef1bSAndrzej Hajda } 12158103ef1bSAndrzej Hajda 12168103ef1bSAndrzej Hajda static const struct component_ops mixer_component_ops = { 12178103ef1bSAndrzej Hajda .bind = mixer_bind, 12188103ef1bSAndrzej Hajda .unbind = mixer_unbind, 12198103ef1bSAndrzej Hajda }; 12208103ef1bSAndrzej Hajda 12218103ef1bSAndrzej Hajda static int mixer_probe(struct platform_device *pdev) 12228103ef1bSAndrzej Hajda { 12238103ef1bSAndrzej Hajda struct device *dev = &pdev->dev; 122448f6155aSMarek Szyprowski const struct mixer_drv_data *drv; 12258103ef1bSAndrzej Hajda struct mixer_context *ctx; 12268103ef1bSAndrzej Hajda int ret; 1227d8408326SSeung-Woo Kim 1228f041b257SSean Paul ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); 1229f041b257SSean Paul if (!ctx) { 12306f83d208SInki Dae DRM_DEV_ERROR(dev, "failed to alloc mixer context.\n"); 1231d8408326SSeung-Woo Kim return -ENOMEM; 1232f041b257SSean Paul } 1233d8408326SSeung-Woo Kim 123448f6155aSMarek Szyprowski drv = of_device_get_match_data(dev); 1235aaf8b49eSRahul Sharma 12364551789fSSean Paul ctx->pdev = pdev; 1237d873ab99SSeung-Woo Kim ctx->dev = dev; 12381e123441SRahul Sharma ctx->mxr_ver = drv->version; 1239d8408326SSeung-Woo Kim 1240adeb6f44STobias Jakobi if (drv->is_vp_enabled) 1241adeb6f44STobias Jakobi __set_bit(MXR_BIT_VP_ENABLED, &ctx->flags); 1242adeb6f44STobias Jakobi if (drv->has_sclk) 1243adeb6f44STobias Jakobi __set_bit(MXR_BIT_HAS_SCLK, &ctx->flags); 1244adeb6f44STobias Jakobi 12458103ef1bSAndrzej Hajda platform_set_drvdata(pdev, ctx); 1246df5225bcSInki Dae 1247df5225bcSInki Dae ret = component_add(&pdev->dev, &mixer_component_ops); 124886650408SAndrzej Hajda if (!ret) 12498103ef1bSAndrzej Hajda pm_runtime_enable(dev); 1250df5225bcSInki Dae 1251df5225bcSInki Dae return ret; 1252f37cd5e8SInki Dae } 1253f37cd5e8SInki Dae 1254d8408326SSeung-Woo Kim static int mixer_remove(struct platform_device *pdev) 1255d8408326SSeung-Woo Kim { 12568103ef1bSAndrzej Hajda pm_runtime_disable(&pdev->dev); 12578103ef1bSAndrzej Hajda 1258df5225bcSInki Dae component_del(&pdev->dev, &mixer_component_ops); 1259df5225bcSInki Dae 1260d8408326SSeung-Woo Kim return 0; 1261d8408326SSeung-Woo Kim } 1262d8408326SSeung-Woo Kim 1263e0fea7e7SArnd Bergmann static int __maybe_unused exynos_mixer_suspend(struct device *dev) 1264ccf034a9SGustavo Padovan { 1265ccf034a9SGustavo Padovan struct mixer_context *ctx = dev_get_drvdata(dev); 1266ccf034a9SGustavo Padovan 1267524c59f1SAndrzej Hajda clk_disable_unprepare(ctx->hdmi); 1268524c59f1SAndrzej Hajda clk_disable_unprepare(ctx->mixer); 1269adeb6f44STobias Jakobi if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) { 1270524c59f1SAndrzej Hajda clk_disable_unprepare(ctx->vp); 1271adeb6f44STobias Jakobi if (test_bit(MXR_BIT_HAS_SCLK, &ctx->flags)) 1272524c59f1SAndrzej Hajda clk_disable_unprepare(ctx->sclk_mixer); 1273ccf034a9SGustavo Padovan } 1274ccf034a9SGustavo Padovan 1275ccf034a9SGustavo Padovan return 0; 1276ccf034a9SGustavo Padovan } 1277ccf034a9SGustavo Padovan 1278e0fea7e7SArnd Bergmann static int __maybe_unused exynos_mixer_resume(struct device *dev) 1279ccf034a9SGustavo Padovan { 1280ccf034a9SGustavo Padovan struct mixer_context *ctx = dev_get_drvdata(dev); 1281ccf034a9SGustavo Padovan int ret; 1282ccf034a9SGustavo Padovan 1283524c59f1SAndrzej Hajda ret = clk_prepare_enable(ctx->mixer); 1284ccf034a9SGustavo Padovan if (ret < 0) { 12856f83d208SInki Dae DRM_DEV_ERROR(ctx->dev, 12866f83d208SInki Dae "Failed to prepare_enable the mixer clk [%d]\n", 12876f83d208SInki Dae ret); 1288ccf034a9SGustavo Padovan return ret; 1289ccf034a9SGustavo Padovan } 1290524c59f1SAndrzej Hajda ret = clk_prepare_enable(ctx->hdmi); 1291ccf034a9SGustavo Padovan if (ret < 0) { 12926f83d208SInki Dae DRM_DEV_ERROR(dev, 12936f83d208SInki Dae "Failed to prepare_enable the hdmi clk [%d]\n", 12946f83d208SInki Dae ret); 1295ccf034a9SGustavo Padovan return ret; 1296ccf034a9SGustavo Padovan } 1297adeb6f44STobias Jakobi if (test_bit(MXR_BIT_VP_ENABLED, &ctx->flags)) { 1298524c59f1SAndrzej Hajda ret = clk_prepare_enable(ctx->vp); 1299ccf034a9SGustavo Padovan if (ret < 0) { 13006f83d208SInki Dae DRM_DEV_ERROR(dev, 13016f83d208SInki Dae "Failed to prepare_enable the vp clk [%d]\n", 1302ccf034a9SGustavo Padovan ret); 1303ccf034a9SGustavo Padovan return ret; 1304ccf034a9SGustavo Padovan } 1305adeb6f44STobias Jakobi if (test_bit(MXR_BIT_HAS_SCLK, &ctx->flags)) { 1306524c59f1SAndrzej Hajda ret = clk_prepare_enable(ctx->sclk_mixer); 1307ccf034a9SGustavo Padovan if (ret < 0) { 13086f83d208SInki Dae DRM_DEV_ERROR(dev, 13096f83d208SInki Dae "Failed to prepare_enable the " \ 1310ccf034a9SGustavo Padovan "sclk_mixer clk [%d]\n", 1311ccf034a9SGustavo Padovan ret); 1312ccf034a9SGustavo Padovan return ret; 1313ccf034a9SGustavo Padovan } 1314ccf034a9SGustavo Padovan } 1315ccf034a9SGustavo Padovan } 1316ccf034a9SGustavo Padovan 1317ccf034a9SGustavo Padovan return 0; 1318ccf034a9SGustavo Padovan } 1319ccf034a9SGustavo Padovan 1320ccf034a9SGustavo Padovan static const struct dev_pm_ops exynos_mixer_pm_ops = { 1321ccf034a9SGustavo Padovan SET_RUNTIME_PM_OPS(exynos_mixer_suspend, exynos_mixer_resume, NULL) 13227e915746SMarek Szyprowski SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 13237e915746SMarek Szyprowski pm_runtime_force_resume) 1324ccf034a9SGustavo Padovan }; 1325ccf034a9SGustavo Padovan 1326d8408326SSeung-Woo Kim struct platform_driver mixer_driver = { 1327d8408326SSeung-Woo Kim .driver = { 1328aaf8b49eSRahul Sharma .name = "exynos-mixer", 1329d8408326SSeung-Woo Kim .owner = THIS_MODULE, 1330ccf034a9SGustavo Padovan .pm = &exynos_mixer_pm_ops, 1331aaf8b49eSRahul Sharma .of_match_table = mixer_match_types, 1332d8408326SSeung-Woo Kim }, 1333d8408326SSeung-Woo Kim .probe = mixer_probe, 133456550d94SGreg Kroah-Hartman .remove = mixer_remove, 1335d8408326SSeung-Woo Kim }; 1336